import { createSyntheticMessage, type AITriggerConfig } from '@zhin.js/core'; import { type ImRuntime, type Message } from '@zhin.js/core/runtime'; import { type ConfigDocumentPort, type RootResourceInstaller, type RuntimeConfigDocument } from '@zhin.js/runtime'; import { AIService, ZhinAgent, type AssistantConfig, type ApprovalPort, type TurnRequestPorts, type TurnRequest, InteractionRouter } from '@zhin.js/agent'; import { AgentRuntime, type ToolCapability } from '@zhin.js/agent/runtime'; export { AgentRuntime, AgentTurnCoordinator } from '@zhin.js/agent/runtime'; export { InteractionRouter } from '@zhin.js/agent'; type AIConfig = NonNullable[0]>; interface AgentToolLike { readonly name: string; readonly description: string; readonly parameters: { readonly type: 'object'; properties?: Record; required?: string[]; }; execute(args: Record): Promise; readonly source?: string; readonly platforms?: readonly string[]; readonly scopes?: readonly ('private' | 'group' | 'channel')[]; readonly permissions?: readonly string[]; readonly hidden?: boolean; readonly approval?: 'always' | 'once' | 'never' | 'on-risk'; } export declare function resolveAiConfig(config: RuntimeConfigDocument | ConfigDocumentPort): Promise; export declare function resolveAssistantConfigDocument(config: RuntimeConfigDocument | ConfigDocumentPort): Promise; export declare function resolveCollaborationConfigDocument(config: RuntimeConfigDocument | ConfigDocumentPort): Promise; export interface InstallAgentHostOptions { /** Process-owned execution authority attached to exactly one Root. */ readonly runtime: AgentRuntime; /** Root-owned authority shared by every Agent generation. */ readonly interactions: InteractionRouter; /** @deprecated Prefer the generation-owned Primary Config. Test overrides only. */ readonly ai?: AIConfig; /** @deprecated Prefer the generation-owned Primary Config. Test overrides only. */ readonly assistant?: AssistantConfig; /** @deprecated Prefer the generation-owned Primary Config. Test overrides only. */ readonly collaboration?: unknown; readonly im: ImRuntime; readonly projectRoot: string; /** * Resolve Endpoint Owner id for `/approve` + bashAlways key. * Key: `localName` (e.g. icqq) or live endpoint name (uin). */ readonly resolveEndpointOwner?: (adapterLocalName: string, endpointKey: string) => string | undefined; /** * Resolve Endpoint trusted id 列表(plugins..trusted / endpoints[].trusted)。 * 对齐 legacy resolveSenderRoles:trusted 角色弱于 master(不参与 Owner 审批放行)。 */ readonly resolveEndpointTrusted?: (adapterLocalName: string, endpointKey: string) => readonly string[]; /** Extra Host tools (e.g. Speech Host voice_stt / voice_tts). */ readonly extraTools?: readonly AgentToolLike[]; /** Optional inbound STT (Speech Host). */ readonly transcribeUrl?: (audioUrl: string) => Promise; /** Optional host approval channel; absent channels fail closed for on-risk tools. */ readonly approvalPort?: ApprovalPort; } /** * Plugin Runtime Agent Host: * - AIService from top-level `ai` * - Command miss → `ai:` trigger → **ZhinAgent.process** (inbound queue + session) * - CapabilityIngress tools + `ai.mcpServers` + SOUL/AGENTS/TOOLS bootstrap * - SubagentSystem + `spawn_task` (parallel sub-agents) + deferred meta tools * - Optional inbound STT / `@agent` specialist prompt injection * - `registerAIHook` / `aiHookRuntimeBus`, ScheduleJobEngine + `schedule_*` * - Assistant profile sync + Event Ingress registry (HTTP via Console API) * - Collaboration storage + Runtime peer/at/handback/dispatch gate * - Subagent/main-turn `bash` (sandbox + safety) + Owner `/approve` 命令面 */ export declare function installAgentHost(options: InstallAgentHostOptions): RootResourceInstaller; interface RuntimeSenderRoles { readonly isMaster: boolean; readonly isTrusted: boolean; } /** * 对齐 legacy resolveSenderRoles(ai-trigger.ts:260): * trigger.masters ∪ endpoint master → master 角色(审批放行); * trigger.trusted ∪ endpoint trusted → trusted 角色(弱于 master,不参与 Owner 审批)。 */ export declare function resolveRuntimeSenderRoles(message: Message, endpointMaster: string | undefined, endpointTrusted: readonly string[], trigger?: AITriggerConfig): RuntimeSenderRoles; export declare function bridgeRuntimeMessage(message: Message, endpointMaster: string | undefined, roles: RuntimeSenderRoles): import("@zhin.js/core").AgentTurnMessage; /** * Canonical IM → Agent TurnRequest mapper. Runtime Message remains owned by IM. */ export declare function createRuntimeTurnRequest(message: Message, text: string, roles: RuntimeSenderRoles, input: Readonly<{ traceId: string; turnId: string; signal: AbortSignal; workspaceRoot: string; network?: TurnRequest['policy']['network']; ports: TurnRequestPorts; }>): TurnRequest; /** IM adapter for the origin-neutral interaction authority. */ export declare function createRuntimeQuestionPort(interactions: InteractionRouter, message: Message): NonNullable; /** Consume an interaction reply before middleware, commands, or Agent fallback. */ export declare function consumeRuntimeInteraction(interactions: InteractionRouter, message: Message): Promise; interface RuntimeTranscriptDraft { readonly direction: 'inbound' | 'outbound'; readonly body: string; readonly messageId?: string; readonly senderId?: string; readonly senderName?: string; readonly senderRole?: string; } /** * im_transcripts 落库(缺口 1,对齐 legacy register-chat-message-store)。 * scene 字段经 resolveSceneFieldsFromMessage 计算,与 chat_history 工具查询 * (buildImTranscriptQuery)保持同一 SSOT;调用方等待 projection settle。 */ export declare function recordRuntimeTranscript(agent: Pick, commMessage: ReturnType, draft: RuntimeTranscriptDraft): Promise; /** * 群/频道旁听(缺口 2,对齐 legacy register-group-session-passive): * 未触发 AI 的共享会话消息写入 Passive Group Context,供后续 @ 时带入上下文。 * 仅群/频道生效(私聊 / sandbox 不旁听,与 legacy dispatcher 适用范围一致)。 */ export declare function recordPassiveGroupContext(agent: Pick, message: Message, commMessage: ReturnType): Promise; export declare function resolveTriggerTimeoutMs(trigger?: AITriggerConfig): number; export declare function renderTriggerError(trigger: AITriggerConfig | undefined, detail: string): string; export declare class TriggerTimeoutError extends Error { constructor(timeoutMs: number); } /** * Runs one ingress-owned turn with a cancellation signal. On timeout the * signal reaches the inbound queue, PromptController, provider stream, and * tool execution instead of merely hiding a late result. */ export declare function withTriggerTimeout(run: (signal: AbortSignal) => Promise, timeoutMs: number): Promise; /** @deprecated Promise inputs cannot be cancelled; pass a signal-aware callback. */ export declare function withTriggerTimeout(promise: Promise, timeoutMs: number): Promise; export declare function runtimeApprovalPolicy(approval: ToolCapability['approval']): 'never' | 'always' | 'once' | 'on-risk'; /** A small non-interactive ApprovalPort suitable for CLI/service hosts and tests. */ export declare function createDeterministicApprovalPort(decision?: 'approve' | 'deny'): ApprovalPort; /** * 新 Plugin Runtime 的 AI 触发判定,对齐 legacy `shouldTriggerAI` 的顺序: * ignorePrefixes → 前缀 → @(群/频道,metadata.mentioned) → 私聊 → 关键词(仅单人会话)。 * * 与 legacy 的差异:Runtime Message.content 为纯文本,at 信息由适配器经 * `metadata.mentioned: true` 标注(icqq 扫 CQ 码、QQ 官方看 AT 事件、slack 看 * app_mention);且前缀触发对群聊同样生效(test-bot 群聊依赖 `ai:` 前缀, * legacy 群/频道仅 @ 触发)。 */ export declare function matchAiTrigger(message: Message, trigger: AITriggerConfig | undefined): { content: string; } | null; //# sourceMappingURL=agent-host-installer.d.ts.map