import { type ConsoleEventHub, type HttpHost, type RuntimeConsolePage, type RuntimeEndpointSummary } from '@zhin.js/host-http'; import type { ImRuntime, RuntimeMessageEvent } from '@zhin.js/core/runtime'; import type { ConsoleRuntime } from '@zhin.js/pagemanager/plugin-runtime'; import { type DatabaseHost, type PluginNodeSnapshot, type RuntimeSnapshot } from '@zhin.js/plugin-runtime'; import type { RootResourceInstaller, RuntimeConfigDocument } from '@zhin.js/runtime'; /** * Console 返回给前端的路径字段:项目根内 → `./…`,HOME 内 → `~/…`。 * 逻辑名(`agent` / `builtin`)与相对虚路径原样返回,避免 path.resolve 误伤。 */ export declare function displayConsolePath(value: string, projectRoot: string): string; /** * ImRuntime 消息事件 → SSE 事件映射(对齐 console 前端消费形态; * content 只发截断预览,不发完整原始段)。 */ export declare function publishMessageEvent(hub: ConsoleEventHub, event: RuntimeMessageEvent): void; export declare function installConsoleApi(options: { readonly console: ConsoleRuntime; readonly projectRoot: string; readonly apiBase?: string; /** When provided, wires `endpoint.*` RPC to AdapterIndex via ImRuntime. */ readonly im?: ImRuntime; /** When provided, wires `db:info` / `db:tables` RPC to the Database host. */ readonly databaseHost?: DatabaseHost; /** Snapshot accessor backing `/api/stats` and `/api/plugins*`. */ readonly snapshot?: () => RuntimeSnapshot | undefined; /** ScheduleHost — wires `schedule:list`/`cron:list` extended RPC. */ readonly scheduleHost?: unknown; /** Full-scope `system:restart` — typically `process.exit(51)` for CLI daemon. */ readonly onRestart?: () => void; /** Shared console event hub (`hmr:reload` 等由 RootHost 层 publish)。 */ readonly eventHub?: ConsoleEventHub; }): RootResourceInstaller; export declare function registerConsoleApiRoutes(http: HttpHost, consoleRuntime: ConsoleRuntime, projectRoot: string, apiBase?: string, im?: ImRuntime, onRestart?: () => void, databaseHost?: DatabaseHost, snapshot?: () => RuntimeSnapshot | undefined, scheduleHost?: unknown, eventHub?: ConsoleEventHub, primaryConfigDocument?: RuntimeConfigDocument): void; /** Console shell entry shape (`@zhin.js/contract` ConsoleClientEntry 兼容)。 */ export type ConsoleEntryBody = { readonly id: string; readonly name: string; readonly title: string; readonly module: string; readonly resolvedModule: string; readonly order: number; readonly enabled: boolean; readonly meta: { readonly name: string; }; readonly route: string; readonly hash: string; }; export type ConsoleEntriesBody = { readonly entries: readonly ConsoleEntryBody[]; readonly runtimeEnvHint: 'development' | 'production'; }; /** * 映射 Console catalog pages → `GET /entries` 响应(legacy host-api 对齐)。 * SDK `loadConsoleEntries` 消费 `{ entries, runtimeEnvHint }`,动态 import * 每项的 `resolvedModule`(`/assets/client/*` 由 Console Host 静态服务)。 */ export declare function buildConsoleEntriesBody(pages: readonly RuntimeConsolePage[], runtimeEnvHint?: 'development' | 'production'): ConsoleEntriesBody; export type SystemOsMemory = { readonly freeMem: number; readonly totalMem: number; }; /** `GET /api/system/status` 的 data(legacy host-api system-routes 对齐)。 */ export type SystemStatusData = { readonly uptime: number; readonly memory: NodeJS.MemoryUsage | Record; readonly osMemory?: SystemOsMemory; readonly cpu?: { readonly user: number; readonly system: number; }; readonly platform: string; readonly nodeVersion?: string; readonly runtime: 'node' | 'unknown'; readonly pid?: number; readonly timestamp: string; }; /** Host (Node) 系统状态快照 — 移植自 legacy rest/system-routes.ts。 */ export declare function getSystemStatusData(): SystemStatusData; /** `GET /api/stats` 的 data(legacy host-rest-api 对齐;commands/components 暂无新 Runtime 数据源,省略)。 */ export type ConsoleStatsData = { readonly plugins: { readonly total: number; readonly active: number; }; readonly endpoints: { readonly total: number; readonly online: number; }; readonly uptime: number; /** heapUsed,单位 MB(legacy 契约,dashboard 直接 toFixed 展示)。 */ readonly memory: number; readonly runtime: 'node' | 'unknown'; }; export declare function buildConsoleStats(pluginCount: number, endpoints: readonly Pick[]): ConsoleStatsData; /** Console 卡片单条 Feature 分组(对齐 legacy FeatureJSON)。 */ export type ConsolePluginFeature = { readonly name: string; readonly icon: string; readonly desc: string; readonly count: number; readonly items: readonly { readonly name: string; readonly desc?: string; }[]; }; /** * listEndpoints 返回形态:无 owner,用 adapter 平台类型(`@scope/adapter-icqq` → `icqq`)归属插件。 * 与 ImRuntime.listEndpoints / RuntimeEndpointSummary 对齐。 */ export type ConsoleEndpointHint = { readonly name: string; readonly adapter: string; readonly connected: boolean; }; /** `GET /api/plugins` 列表项(legacy buildPluginListItem 对齐)。 */ export type ConsolePluginListItem = { readonly name: string; readonly status: 'active' | 'inactive'; readonly description: string; readonly features: readonly ConsolePluginFeature[]; readonly packageName: string; readonly instanceKey: string; }; export declare function buildPluginListItem(node: PluginNodeSnapshot, snapshot?: RuntimeSnapshot, endpoints?: readonly ConsoleEndpointHint[]): ConsolePluginListItem; /** 从 snapshot.capabilities 按 owner 聚合插件 Feature(对齐 legacy Feature.toJSON)。 */ export declare function buildPluginFeatures(node: PluginNodeSnapshot, snapshot?: RuntimeSnapshot, endpoints?: readonly ConsoleEndpointHint[]): readonly ConsolePluginFeature[]; /** `GET /api/plugins/:name` 详情(legacy host-rest-api 对齐)。 */ export type ConsolePluginDetail = ConsolePluginListItem & { readonly filename: string; readonly filePath: string; readonly version?: string; readonly contextCount: number; readonly contexts: readonly unknown[]; }; export declare function buildPluginDetail(node: PluginNodeSnapshot, version?: string, snapshot?: RuntimeSnapshot, endpoints?: readonly ConsoleEndpointHint[], projectRoot?: string): ConsolePluginDetail; /** Snapshot 中非 root 的插件节点(root 无 parent,对应 legacy root.children)。 */ export declare function listSnapshotPlugins(snapshot: RuntimeSnapshot | undefined): PluginNodeSnapshot[]; /** * Host 级配置键(与 ConfigComposer 对齐)。 * 这些键在文档顶层;插件配置在 `plugins.`。 */ export declare const HOST_CONFIG_KEYS: readonly ["http", "database", "ai", "mcp", "a2a", "speech", "htmlRenderer", "assistant", "collaboration", "log_level", "plugin"]; /** * Console 视角的扁平配置: * - 顶层 host 键(http / database / …)原样 * - `plugins.` 展开为顶层 `key`(与 legacy `config:get(pluginName)` 契约一致) */ export declare function readConsoleConfigDocument(projectRoot: string): Promise>; export declare function flattenConfigDocument(document: Record): Record; /** 配置 Tab 列表:host 键(有值)+ plugins 键 + package.json zhin.plugins。 */ export declare function listConsoleConfigKeys(projectRoot: string, primaryConfigDocument?: RuntimeConfigDocument): Promise; /** * 写入配置键: * - host 键 / 已在顶层的键 → 顶层 * - 其余(插件 instanceKey)→ `plugins.` */ export declare function setProjectConfigKey(projectRoot: string, pluginName: string, data: unknown): Promise<{ restartRequired: boolean; }>; export declare function writeConfigKey(document: Record, key: string, data: unknown): void; /** * 读取插件 schema.json,并转换为 Console 表单使用的 `@zhin.js/schema` toJSON 形态。 * `pluginName` 支持 instanceKey(`icqq`)或包名(`@zhin.js/adapter-icqq`)。 */ export declare function readPluginSchema(projectRoot: string, pluginName?: string): Promise; /** * JSON Schema (draft-2020 / 插件 schema.json) → Console Schema JSON * (`@zhin.js/schema` `toJSON()`:`{ type, object?, list?, inner?, key?, description?, ... }`)。 * * Remote Console 表单按该形态渲染;直接返回 JSON Schema 会导致字段无法展开。 */ export declare function jsonSchemaToConsoleSchema(input: unknown, key?: string): Record | null; /** instanceKey → package 映射(来自项目 package.json 的 `zhin.plugins`)。 */ export declare function readPluginPackageMap(projectRoot: string): Promise>; export declare function readAllPluginSchemas(projectRoot: string): Promise>; //# sourceMappingURL=console-api-installer.d.ts.map