import { AgentEngine } from './engine.js'; import type { AgentConfig } from './types.js'; import type { LLMProvider } from '../llm/types.js'; import { ContextManager } from '../context/manager.js'; import { SecurityGuard } from '../security/guard.js'; import { SkillManager } from '../skill/manager.js'; import { ToolRegistry } from '../tool/registry.js'; import type { RegisteredTool } from '../tool/types.js'; import type { Middleware } from '../middleware/types.js'; import type { Hook } from '../hooks/types.js'; export interface AgentProfileLike { id?: string | number; name?: string; description?: string; isDefault?: boolean; agentType?: 'default' | 'specialist' | 'remote' | string; selectedTools?: string[]; disabledTools?: string[]; selectedSkills?: string[]; alwaysInjectSkills?: string[]; maxIterations?: number; maxMessages?: number; toolTimeout?: number; /** 脚本执行超时硬上限(毫秒),不设置时由引擎回退默认 300000 */ maxScriptTimeoutMs?: number; /** LLM 推理超时(毫秒),不设置时由引擎回退默认 180000 */ llmTimeout?: number; model?: string; metadata?: Record; } export interface ResourceScopeOptions { baseToolRegistry: ToolRegistry; baseSkillManager?: SkillManager; profile?: AgentProfileLike; includeTool?: (tool: RegisteredTool, profile?: AgentProfileLike) => boolean; /** skillName 追加在末尾,兼容仅按 (skillId, profile) 使用的历史回调 */ includeSkill?: (skillId: string, profile?: AgentProfileLike, skillName?: string) => boolean; } export interface ResourceScope { toolRegistry: ToolRegistry; skillManager?: SkillManager; missingSkillRequirements: Array<{ skillId: string; missingTools: string[]; }>; } export interface AgentRuntimeOptions { llmProvider: LLMProvider; fallbackProvider?: LLMProvider; tools?: RegisteredTool[]; toolRegistry?: ToolRegistry; skills?: SkillManager; contextManager?: ContextManager; securityGuard?: SecurityGuard; middleware?: Middleware[]; hooks?: Hook[]; profile?: AgentProfileLike; basePrompt?: string | ((scope: ResourceScope) => string); includeTool?: (tool: RegisteredTool, profile?: AgentProfileLike) => boolean; /** skillName 追加在末尾,兼容仅按 (skillId, profile) 使用的历史回调 */ includeSkill?: (skillId: string, profile?: AgentProfileLike, skillName?: string) => boolean; config?: Partial; } export interface AgentRuntime { engine: AgentEngine; toolRegistry: ToolRegistry; skillManager?: SkillManager; contextManager: ContextManager; securityGuard: SecurityGuard; scope: ResourceScope; } /** * 解析 profile 的最终禁用工具列表(含 ask_user 联动)。 * * 统一入口:work-space mapProfile、agent-server buildEngine、runtime-builder * 三处共用此函数,消除「同一开关逻辑散落多处」的漂移风险。 * * 规则: * - 基础列表 = profile.disabledTools(过滤空串/undefined) * - allowInteraction === false:追加 ask_user(强制禁用) * - allowInteraction !== false(默认开启):清除历史残留的 ask_user(强制启用) */ export declare function resolveDeniedTools(profile: { disabledTools?: string[]; allowInteraction?: boolean; } | undefined): string[]; /** * 工具过滤统一入口。 * * 语义(与 buildResourceScope 历史行为逐条一致,golden 测试锚定): * 1. selectedTools 非空时为白名单:不在其中的非 builtin 工具被剔除; * 2. disabledTools 黑名单:命中的工具被剔除(builtin 不豁免); * 3. includeTool 回调可做额外剔除。 */ export declare function filterTools(tools: T[], profile: { selectedTools?: string[]; disabledTools?: string[]; } | undefined, includeTool?: (tool: T, profile?: any) => boolean): T[]; /** * Skill 过滤统一入口。 * * 语义(与 buildResourceScope 历史行为一致): * 1. selectedSkills 为空 = 全量; * 2. 非空时按 id 或 name 双匹配(profile 可能存 DB 主键或引用名); * 3. includeSkill 回调同样传入 name,与 selection 匹配口径一致。 */ export declare function filterSkills(skills: T[], profile: { selectedSkills?: string[]; } | undefined, includeSkill?: (skillId: string, profile?: any, skillName?: string) => boolean): T[]; export declare function buildResourceScope(options: ResourceScopeOptions): ResourceScope; export declare function validateSkillRequirements(skillManager: SkillManager | undefined, toolRegistry: ToolRegistry): Array<{ skillId: string; missingTools: string[]; }>; export declare function createAgentRuntime(options: AgentRuntimeOptions): AgentRuntime; export declare class AgentRuntimeBuilder { private options; withLLMProvider(llmProvider: LLMProvider, fallbackProvider?: LLMProvider): this; withTools(tools: RegisteredTool[] | ToolRegistry): this; withSkills(skills: SkillManager): this; withProfile(profile: AgentProfileLike): this; withPrompt(basePrompt: AgentRuntimeOptions['basePrompt']): this; withResourcePolicy(policy: Pick): this; withConfig(config: Partial): this; build(): AgentRuntime; } //# sourceMappingURL=runtime-builder.d.ts.map