/** * Executor:单个 session 的执行编排器。 * * 关键点(中文) * - SDK 对外对象叫 `Session`,这里是内部执行层。 * - 一个 Executor 只对应一个固定的 `session_id`。 * - 负责显式 Turn 上下文消费、executing 状态、Composer 编排与 Tool Loop 执行。 */ import type { LanguageModel } from "ai"; import type { Logger } from "../utils/logger/Logger.js"; import type { SessionCompactHistory, SessionExecutor } from "../types/session/SessionExecution.js"; import type { SessionTurnContext } from "../types/executor/SessionTurnContext.js"; import type { AgentPluginExecutionRuntime } from "../types/plugin/PluginRuntime.js"; import type { SessionTurnExecutionResult } from "../types/session/SessionExecution.js"; import type { SessionComposer, SessionComposeInput, SessionStepInput } from "../types/session/SessionComposer.js"; type ExecutorOptions = { /** * 当前会话 ID。 */ session_id: string; /** 当前 Session 使用的统一 Composer。 */ composer: SessionComposer; /** 为 Composer 创建当前 Step 的只读输入快照。 */ get_compose_input: (turn_context: SessionTurnContext | undefined, retry_count: number) => Promise; /** 应用 Session 级固定 system snapshot。 */ apply_system_snapshot?: (input: SessionStepInput) => SessionStepInput; /** 请求 Session 领域生成并提交 canonical 历史压缩。 */ compact_history: SessionCompactHistory; /** * 读取当前 session 使用的模型实例。 */ get_model: () => LanguageModel | undefined; /** * 统一日志器。 */ logger: Logger; /** 创建当前 Session effective Plugin 执行视图。 */ get_plugins?: () => AgentPluginExecutionRuntime; }; /** * Executor 单实例实现。 */ export declare class Executor implements SessionExecutor { /** * 当前 session 标识。 */ readonly session_id: string; private readonly composer; private readonly get_compose_input; private readonly apply_system_snapshot?; private readonly compact_history; private readonly get_model; private readonly get_plugins; private readonly logger; private readonly recovery_policy; private readonly core_engine_runner; private executing; constructor(options: ExecutorOptions); /** * 返回当前 session 是否正在执行。 */ is_executing(): boolean; /** * 执行当前 Session 的一次 Turn。 * * 关键点(中文) * - 这里直接承接单个 Session 实例的一次 Turn 执行编排。 * - scope 绑定、assistant step 持久化、executing 状态都收在实例内部。 */ execute(params: { query: string; turn_context: SessionTurnContext; }): Promise; /** * 调用 Composer 组装当前轮执行输入。 */ private prepare_execute_input; /** * 执行一次已装配完成的 Step 输入。 */ private execute_prepared_input; /** * 解析下一 Session step 实际使用的运行配置。 * * 关键点(中文) * - 调用方必须先提交 Session 统一输入队列,再调用本方法。 * - 每次调用只读取一次 model、system 与 tools,并把它们传给同一个 `streamText()`。 */ private resolve_step_inputs; /** 读取只读 Session 快照并交给统一 Composer。 */ private compose_step; /** * 刷新当前 Session step 的 effective Agent 运行视图。 */ private refresh_step_runtime; /** * 为所有 tool execute callback 绑定显式 Session 运行上下文。 * * 关键点(中文) * - 每个 step 使用独立包装工具,不会在并行 Session 间共享可变指针。 * - Agent 与 Shell 工具通过 ToolExecutionOptions.experimental_context 读取显式快照。 */ private bind_turn_context_to_tools; /** * 读取当前 session 模型。 */ private resolve_model_or_throw; } export {}; //# sourceMappingURL=Executor.d.ts.map