import type { HttpHost } from './http-host.js'; /** 与 basic/cli 接线方对齐的上下文约定。 */ export interface ConsoleRestCtx { /** false = demo 部署:只读 GET 放行,写操作一律 403。 */ readonly fullScope: boolean; readonly projectRoot: string; readonly getEndpoints?: () => readonly { name: string; adapter: string; connected: boolean; status: string; }[]; /** * 可选:返回新 Runtime 的 agent 门面(见 {@link ConsoleAgentRuntime})。 * 未接线时 introspection 降级为空列表 + note,session tree 返回 503。 */ readonly acquireAgentRuntime?: () => { readonly value: ConsoleAgentRuntime; release(): void; } | null; /** Database host(logs 页数据源:SystemLog 模型)。 */ readonly databaseHost?: { readonly dialect: string; readonly started: boolean; readonly models: { get(name: string): unknown; }; }; /** Distinguishes a real IM conversation with no Agent turn from a typo key. */ readonly isKnownConversationSession?: (sessionKey: string) => boolean | undefined | Promise; } /** 内省数据门面 — 由 composition root 从当前 Runtime snapshot 装配。 */ export interface ConsoleAgentIntrospection { commands?(): readonly unknown[]; middlewares?(): readonly unknown[]; components?(): readonly unknown[]; bindings?(): readonly unknown[]; tools?(): readonly unknown[]; promptSections?(): readonly unknown[]; mcp?(): { rows: readonly unknown[]; note?: string; } | readonly unknown[]; renderComponent?(input: Readonly<{ requester: string; name: string; props: unknown; signal: AbortSignal; }>): Promise; } /** Session tree 门面 — 形状对齐 agent 包 SessionTreeRuntimeHandle。 */ export interface ConsoleAgentSessionTree { resolveActiveSessionId(sessionKey: string): Promise; getActiveLeafMessageId(sessionId: string): Promise; listBranchPoints(sessionId: string): Promise; switchActiveLeaf(sessionId: string, messageId: number): Promise; jumpToBranchIndex(sessionId: string, index: number): Promise<{ ok: boolean; message: string; }>; } /** `ctx.acquireAgentRuntime()` 返回值的最小结构约定(全部可选,逐项降级)。 */ export interface ConsoleAgentRuntime { readonly introspection?: ConsoleAgentIntrospection; readonly sessionTree?: ConsoleAgentSessionTree; } export interface ConsoleRestPagesOptions { /** 默认 `/api`。 */ readonly apiBase?: string; /** 测试注入用;默认全局 fetch。 */ readonly fetchFn?: typeof fetch; /** 默认 `https://zhin.js.org/plugins.json`(legacy 同源)。 */ readonly pluginRegistryUrl?: string; /** 默认 `https://registry.npmmirror.com`(legacy 同源)。 */ readonly npmRegistryUrl?: string; /** Component preview deadline; default 5 seconds. */ readonly componentPreviewTimeoutMs?: number; /** Maximum serialized Component preview; default 256 KiB. */ readonly componentPreviewMaxBytes?: number; /** Maximum in-flight Component previews per Console route set; default 2. */ readonly componentPreviewMaxConcurrent?: number; } /** * 注册 Console 页面 REST 路由。返回注销函数(注销全部已注册路由)。 */ export declare function registerConsoleRestPages(host: HttpHost, ctx: ConsoleRestCtx, options?: ConsoleRestPagesOptions): () => void;