/** * Agent:本地 Agent 核心入口与 facade。 * * 职责说明(中文) * - 对外暴露 `Agent` 这一唯一的本地实例类。 * - Agent 直接持有自身状态与长期运行时对象,避免额外 Assembly 复制同一批字段。 * - Session 集合由 `AgentSessions` 管理;长期运行状态由 `AgentState` 管理。 */ import type { Tool } from "ai"; import type { AgentModel } from "../agent/AgentModel.js"; import type { AgentOptions } from "../types/agent/AgentOptions.js"; import type { Shell } from "@downcity/shell"; import type { WorkspaceBase } from "../workspace/WorkspaceBase.js"; import { Logger } from "../utils/logger/Logger.js"; import { AgentSessions } from "../agent/AgentSessions.js"; import { PluginRegistry } from "../plugin/core/PluginRegistry.js"; import type { Hono } from "hono"; import type { PluginSnapshot } from "../types/plugin/PluginState.js"; import { type SystemProfile } from "../executor/composer/system/default/SystemDomain.js"; import type { SystemModelMessage } from "ai"; /** * SDK 本地 Agent。 */ export declare class Agent { /** 当前 Agent 的稳定标识,用于区分 Session 存储目录与运行时归属。 */ readonly id: string; /** 当前 Agent 引用的项目资源与安全边界。 */ readonly workspace: WorkspaceBase; /** 当前 Agent 向所有 Session 提供的工具集合。 */ readonly tools: Record; /** 当前 Agent 已装配的 Plugin 调用与注册入口。 */ readonly plugins: PluginRegistry; /** 当前 Agent 的本地 Session 创建、恢复、查询与归档入口。 */ readonly sessions: AgentSessions; /** * 当前 Agent 持有的默认运行时模型实例。 * * 关键点(中文) * - Agent 只持有调用方传入的实例,不负责模型选择、持久化或恢复。 * - Session 未设置自己的模型时,执行会回退使用该实例。 */ readonly model?: AgentModel; /** 当前 Agent 独享的运行日志器。 */ private readonly logger; /** 提供给 Plugin、Session 与宿主集成层共享的 Agent 执行上下文。 */ private readonly plugin_context; /** 调用方提供的自定义 Session 类;省略时使用 SDK 默认实现。 */ private readonly session_class; /** 当前 Agent 的长期运行状态与生命周期。 */ private readonly state; /** 当前 Agent configured instruction 的可变有序集合。 */ private instruction; /** 取消 Workspace env 变化订阅的函数。 */ private readonly unsubscribe_workspace_env; /** 取消 PluginRegistry 变化订阅的函数。 */ private readonly unsubscribe_plugin_change; /** 当前由 PluginRegistry 注册到 Agent 的 Tool 名称。 */ private readonly plugin_tool_names; constructor(options: AgentOptions); /** * 等待 Agent 持有的长期运行时启动完成。 * * 关键点(中文) * - Agent 构造完成即开始启动 plugin lifecycle 与 ActionSchedule。 * - 调用方在需要确认运行时就绪时使用,例如启动后立刻读取 plugin 状态。 */ ready(): Promise; /** * 释放当前 Agent 持有的长期运行时对象。 * * 关键点(中文) * - 关闭 plugin lifecycle 与 ActionSchedule 等 Agent 自有资源。 * - Workspace 与 Agent 一对一绑定,因此这里同时关闭 Shell 与 Sandbox。 * - 不负责任何 transport(RPC / HTTP);transport 由 `@downcity/server` 自行管理。 */ dispose(): Promise; /** * 更新当前 SDK Agent 的静态基础指令。 */ set_instruction(input: string | string[]): void; /** * 返回当前 agent 绑定的统一日志器。 */ get_logger(): Logger; /** * 返回当前 agent 挂载的 Shell。 */ get_shell(): Shell | undefined; /** 返回当前 Agent 已配置的静态指令快照。 */ get_instructions(): readonly string[]; /** 列出当前 Agent 已注册的 Plugin 状态。 */ list_plugin_states(): PluginSnapshot[]; /** 把当前 Agent 已注册 Plugin 的 HTTP 路由装配到宿主应用。 */ register_plugin_http_routes(app: Hono): void; /** 解析指定 Session 当前可见的完整 system messages。 */ resolve_system_messages(input: { /** 需要解析 system 的 Session 标识。 */ session_id: string; /** system 组合档位;省略时使用 chat。 */ profile?: SystemProfile; }): Promise; /** 将 PluginRegistry 当前 Tool Set 同步到 Agent 持有的工具集合。 */ private sync_plugin_tools; } //# sourceMappingURL=Agent.d.ts.map