import { createSyntheticMessage, type AITriggerConfig } from '@zhin.js/core'; import type { ImRuntime, Message } from '@zhin.js/core/runtime'; import { type ConfigDocumentPort, type RootResourceInstaller, type RuntimeConfigDocument } from '@zhin.js/runtime'; import { type AgentToolRegistration } from '@zhin.js/plugin-runtime'; import { AIService, ZhinAgent, type AssistantConfig } from '@zhin.js/agent'; import { type ToolCapability } from '@zhin.js/agent/runtime'; 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'; } 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 { /** @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, endpointId: string) => string | undefined; /** * Resolve Endpoint trusted id 列表(plugins..trusted / endpoints[].trusted)。 * 对齐 legacy resolveSenderRoles:trusted 角色弱于 master(不参与 Owner 审批放行)。 */ readonly resolveEndpointTrusted?: (adapterLocalName: string, endpointId: 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; } /** * 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; 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;fire-and-forget,失败仅 debug。 */ export declare function recordRuntimeTranscript(agent: Pick, commMessage: ReturnType, draft: RuntimeTranscriptDraft): void; /** * 群/频道旁听(缺口 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; /** * ai.trigger.timeout 包装:超时即 reject(不取消底层 generation)。 * promise 立即挂 then/catch,超时后迟到的 settle 不会成为 unhandledRejection。 */ export declare function withTriggerTimeout(promise: Promise, timeoutMs: number): Promise; export declare function runtimeApprovalPolicy(approval: ToolCapability['approval']): 'never' | 'always'; /** * Bridge a plugin-registered tool (agentToolsHostToken) into the per-turn * catalog shape. zod-like inputSchemas are reused for argument validation, * mirroring the legacy authoring bridge (parseWithZodSchema). */ export declare function toRegisteredAgentTool(registration: AgentToolRegistration): Parameters[0]; /** * 新 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; export {}; //# sourceMappingURL=agent-host-installer.d.ts.map