import { ReActAgent } from '@agforge/core'; import type { BuiltinToolContextInterceptorOptions, EnvironmentInjectInterceptorOptions, ErrorLimitInterceptorOptions, FinishReasonInterceptorOptions, IterationLimitInterceptorOptions, MessageListener, MessageSanitizeMode, TracingInterceptorOptions } from '../agent-interceptors'; import type { AgentsMdProvider } from '../agents-md'; import type { CompressionStrategy, Compressor } from '../context-compression'; import type { ManagedReActAgentInterceptor, ManagedToolInterceptor } from '../managed-interceptor'; import type { McpClient } from '../mcp'; import type { SkillProvider } from '../skill'; import type { ContextInjectOptions } from '../tool-interceptors'; import type { AnyTool, Model, MessageStore } from '@agforge/core'; /** * 压缩功能配置。 * * - `false`: 禁用压缩(使用 InMemoryMessageStore) * - `true` 或不传: 启用默认压缩(使用 ThresholdCompressionStrategy + TruncateCompressor) * - 对象: 自定义压缩配置 */ export type CompressionConfig = boolean | { /** * 压缩策略。 * @default ThresholdCompressionStrategy */ strategy?: CompressionStrategy; /** * 压缩器。 * @default TruncateCompressor */ compressor?: Compressor; }; export type DefaultAgentOptions = { model: Model; tools?: Array; /** 额外的 agent 拦截器(与内置拦截器合并后按 order 排序) */ interceptors?: Array; /** 额外的 tool 拦截器 */ toolInterceptors?: Array; /** 最大连续错误次数,默认 3 */ errorLimit?: ErrorLimitInterceptorOptions | number; /** finishReason 拦截器选项 */ finishReason?: FinishReasonInterceptorOptions; /** 最大迭代次数配置,默认 25。传入 0 关闭迭代限制 */ iterationLimit?: IterationLimitInterceptorOptions | number; /** 系统提示词 */ systemPrompt?: string; /** 消息监听回调。传入后启用消息监听拦截器 */ messageListener?: MessageListener; /** MCP 客户端列表。传入后启用 MCP 工具拦截器 */ mcpClients?: Array; /** * 环境信息配置。 * - EnvironmentItem:单项配置(指定 content 和 position) * - Array:多项配置 * * position 决定注入位置: * - 'system': 静态信息注入到 system 消息(享受 prefix caching) * - 'user': 动态信息通过 system-reminder 注入到 user 消息 */ environment?: EnvironmentInjectInterceptorOptions['environment']; /** AGENTS.md 提供者。传入后启用 AGENTS.md 自动加载和注入 */ agentsMdProvider?: AgentsMdProvider; /** Skill 提供者。传入后启用 Skill 按需披露机制 */ skillProvider?: SkillProvider; /** 追踪拦截器配置。传入后启用追踪拦截器 */ tracing?: TracingInterceptorOptions; /** * 消息存储实例。 * * 使用方式: * - 不需要压缩:传入 InMemoryMessageStore(core 层) * - 需要压缩:传入 InMemoryWritableMessageStore 或继承 WritableMessageStore 的自定义实现 * * 注意: * - 如果传入自定义 messageStore,compression 配置中的 strategy 和 compressor 仍然有效 * - 如果 compression 为 false 或压缩被禁用,可以使用任意 MessageStore 实现 * - 如果 compression 启用,messageStore 应为 WritableMessageStore 实例 * * @default InMemoryWritableMessageStore (启用压缩时) 或 InMemoryMessageStore (禁用压缩时) */ messageStore?: MessageStore; /** * 压缩功能配置。 * * - `false`: 禁用压缩(使用 InMemoryMessageStore) * - `true` 或 `undefined`: 启用默认压缩(使用 ThresholdCompressionStrategy + TruncateCompressor) * - 对象: 自定义压缩配置,可指定 strategy 和/或 compressor * * @default true */ compression?: CompressionConfig; /** * 消息兜底拦截器的操作模式。 * * - 'off': 不启用,不做任何检测或修复 * - 'warn': 仅检测并打印 warning 日志,不修改消息 * - 'fix': 检测、打印 warning 日志并自动修复(默认) * * @default 'fix' */ messageSanitize?: MessageSanitizeMode | 'off'; toolContextInject?: ContextInjectOptions & BuiltinToolContextInterceptorOptions; }; export declare class DefaultAgent extends ReActAgent { constructor({ model, tools, toolInterceptors, interceptors, errorLimit, finishReason, iterationLimit, systemPrompt, messageListener, mcpClients, environment, agentsMdProvider, skillProvider, tracing, messageStore, compression, messageSanitize, toolContextInject, }: DefaultAgentOptions); }