@lingxiao-office/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/AgentCompletionNoteWriter.d.ts +20 -0
- package/dist/agents/AgentCompletionNoteWriter.d.ts.map +1 -0
- package/dist/agents/AgentCompletionNoteWriter.js +26 -0
- package/dist/agents/AgentCompletionNoteWriter.js.map +1 -0
- package/dist/agents/AgentContextController.d.ts +14 -0
- package/dist/agents/AgentContextController.d.ts.map +1 -0
- package/dist/agents/AgentContextController.js +50 -0
- package/dist/agents/AgentContextController.js.map +1 -0
- package/dist/agents/AgentDefinitionService.d.ts +79 -0
- package/dist/agents/AgentDefinitionService.d.ts.map +1 -0
- package/dist/agents/AgentDefinitionService.js +295 -0
- package/dist/agents/AgentDefinitionService.js.map +1 -0
- package/dist/agents/AgentExecutionResult.d.ts +68 -0
- package/dist/agents/AgentExecutionResult.d.ts.map +1 -0
- package/dist/agents/AgentExecutionResult.js +81 -0
- package/dist/agents/AgentExecutionResult.js.map +1 -0
- package/dist/agents/AgentInterventionHandler.d.ts +33 -0
- package/dist/agents/AgentInterventionHandler.d.ts.map +1 -0
- package/dist/agents/AgentInterventionHandler.js +58 -0
- package/dist/agents/AgentInterventionHandler.js.map +1 -0
- package/dist/agents/AgentMessageHistory.d.ts +27 -0
- package/dist/agents/AgentMessageHistory.d.ts.map +1 -0
- package/dist/agents/AgentMessageHistory.js +43 -0
- package/dist/agents/AgentMessageHistory.js.map +1 -0
- package/dist/agents/AgentPoolRuntime.d.ts +647 -0
- package/dist/agents/AgentPoolRuntime.d.ts.map +1 -0
- package/dist/agents/AgentPoolRuntime.js +1713 -0
- package/dist/agents/AgentPoolRuntime.js.map +1 -0
- package/dist/agents/AgentRoundExecutor.d.ts +56 -0
- package/dist/agents/AgentRoundExecutor.d.ts.map +1 -0
- package/dist/agents/AgentRoundExecutor.js +116 -0
- package/dist/agents/AgentRoundExecutor.js.map +1 -0
- package/dist/agents/AgentRuntimeUtilities.d.ts +14 -0
- package/dist/agents/AgentRuntimeUtilities.d.ts.map +1 -0
- package/dist/agents/AgentRuntimeUtilities.js +169 -0
- package/dist/agents/AgentRuntimeUtilities.js.map +1 -0
- package/dist/agents/AutonomyDecisionEngine.d.ts +20 -0
- package/dist/agents/AutonomyDecisionEngine.d.ts.map +1 -0
- package/dist/agents/AutonomyDecisionEngine.js +150 -0
- package/dist/agents/AutonomyDecisionEngine.js.map +1 -0
- package/dist/agents/BaseAgentRuntime.d.ts +509 -0
- package/dist/agents/BaseAgentRuntime.d.ts.map +1 -0
- package/dist/agents/BaseAgentRuntime.js +3280 -0
- package/dist/agents/BaseAgentRuntime.js.map +1 -0
- package/dist/agents/BlockedAgingPolicy.d.ts +3 -0
- package/dist/agents/BlockedAgingPolicy.d.ts.map +1 -0
- package/dist/agents/BlockedAgingPolicy.js +3 -0
- package/dist/agents/BlockedAgingPolicy.js.map +1 -0
- package/dist/agents/DispatchDecisionCoordinator.d.ts +98 -0
- package/dist/agents/DispatchDecisionCoordinator.d.ts.map +1 -0
- package/dist/agents/DispatchDecisionCoordinator.js +388 -0
- package/dist/agents/DispatchDecisionCoordinator.js.map +1 -0
- package/dist/agents/IntentClassifier.d.ts +19 -0
- package/dist/agents/IntentClassifier.d.ts.map +1 -0
- package/dist/agents/IntentClassifier.js +176 -0
- package/dist/agents/IntentClassifier.js.map +1 -0
- package/dist/agents/LeaderAgent.d.ts +752 -0
- package/dist/agents/LeaderAgent.d.ts.map +1 -0
- package/dist/agents/LeaderAgent.js +3511 -0
- package/dist/agents/LeaderAgent.js.map +1 -0
- package/dist/agents/LeaderBlackboard.d.ts +177 -0
- package/dist/agents/LeaderBlackboard.d.ts.map +1 -0
- package/dist/agents/LeaderBlackboard.js +800 -0
- package/dist/agents/LeaderBlackboard.js.map +1 -0
- package/dist/agents/LeaderDirectTools.d.ts +66 -0
- package/dist/agents/LeaderDirectTools.d.ts.map +1 -0
- package/dist/agents/LeaderDirectTools.js +124 -0
- package/dist/agents/LeaderDirectTools.js.map +1 -0
- package/dist/agents/LeaderExecutionController.d.ts +102 -0
- package/dist/agents/LeaderExecutionController.d.ts.map +1 -0
- package/dist/agents/LeaderExecutionController.js +260 -0
- package/dist/agents/LeaderExecutionController.js.map +1 -0
- package/dist/agents/LeaderPermissionManager.d.ts +117 -0
- package/dist/agents/LeaderPermissionManager.d.ts.map +1 -0
- package/dist/agents/LeaderPermissionManager.js +455 -0
- package/dist/agents/LeaderPermissionManager.js.map +1 -0
- package/dist/agents/LeaderProgressInvariant.d.ts +174 -0
- package/dist/agents/LeaderProgressInvariant.d.ts.map +1 -0
- package/dist/agents/LeaderProgressInvariant.js +479 -0
- package/dist/agents/LeaderProgressInvariant.js.map +1 -0
- package/dist/agents/LeaderSupervisionCoordinator.d.ts +109 -0
- package/dist/agents/LeaderSupervisionCoordinator.d.ts.map +1 -0
- package/dist/agents/LeaderSupervisionCoordinator.js +492 -0
- package/dist/agents/LeaderSupervisionCoordinator.js.map +1 -0
- package/dist/agents/LeaderSupervisionPolicy.d.ts +52 -0
- package/dist/agents/LeaderSupervisionPolicy.d.ts.map +1 -0
- package/dist/agents/LeaderSupervisionPolicy.js +130 -0
- package/dist/agents/LeaderSupervisionPolicy.js.map +1 -0
- package/dist/agents/LeaderTools.d.ts +169 -0
- package/dist/agents/LeaderTools.d.ts.map +1 -0
- package/dist/agents/LeaderTools.js +1693 -0
- package/dist/agents/LeaderTools.js.map +1 -0
- package/dist/agents/LeaderWorkOrchestrator.d.ts +187 -0
- package/dist/agents/LeaderWorkOrchestrator.d.ts.map +1 -0
- package/dist/agents/LeaderWorkOrchestrator.js +554 -0
- package/dist/agents/LeaderWorkOrchestrator.js.map +1 -0
- package/dist/agents/LlmGuard.d.ts +160 -0
- package/dist/agents/LlmGuard.d.ts.map +1 -0
- package/dist/agents/LlmGuard.js +727 -0
- package/dist/agents/LlmGuard.js.map +1 -0
- package/dist/agents/OrchestrationRuntime.d.ts +50 -0
- package/dist/agents/OrchestrationRuntime.d.ts.map +1 -0
- package/dist/agents/OrchestrationRuntime.js +436 -0
- package/dist/agents/OrchestrationRuntime.js.map +1 -0
- package/dist/agents/ProjectControlService.d.ts +18 -0
- package/dist/agents/ProjectControlService.d.ts.map +1 -0
- package/dist/agents/ProjectControlService.js +99 -0
- package/dist/agents/ProjectControlService.js.map +1 -0
- package/dist/agents/RoleCapabilityModel.d.ts +125 -0
- package/dist/agents/RoleCapabilityModel.d.ts.map +1 -0
- package/dist/agents/RoleCapabilityModel.js +303 -0
- package/dist/agents/RoleCapabilityModel.js.map +1 -0
- package/dist/agents/RoleRegistry.d.ts +92 -0
- package/dist/agents/RoleRegistry.d.ts.map +1 -0
- package/dist/agents/RoleRegistry.js +209 -0
- package/dist/agents/RoleRegistry.js.map +1 -0
- package/dist/agents/TaskClassifier.d.ts +34 -0
- package/dist/agents/TaskClassifier.d.ts.map +1 -0
- package/dist/agents/TaskClassifier.js +132 -0
- package/dist/agents/TaskClassifier.js.map +1 -0
- package/dist/agents/TeamSynchronizer.d.ts +113 -0
- package/dist/agents/TeamSynchronizer.d.ts.map +1 -0
- package/dist/agents/TeamSynchronizer.js +250 -0
- package/dist/agents/TeamSynchronizer.js.map +1 -0
- package/dist/agents/UnifiedScheduler.d.ts +111 -0
- package/dist/agents/UnifiedScheduler.d.ts.map +1 -0
- package/dist/agents/UnifiedScheduler.js +246 -0
- package/dist/agents/UnifiedScheduler.js.map +1 -0
- package/dist/agents/WorkerDbClosedClassification.d.ts +51 -0
- package/dist/agents/WorkerDbClosedClassification.d.ts.map +1 -0
- package/dist/agents/WorkerDbClosedClassification.js +59 -0
- package/dist/agents/WorkerDbClosedClassification.js.map +1 -0
- package/dist/agents/WorkerFlushRegistry.d.ts +15 -0
- package/dist/agents/WorkerFlushRegistry.d.ts.map +1 -0
- package/dist/agents/WorkerFlushRegistry.js +33 -0
- package/dist/agents/WorkerFlushRegistry.js.map +1 -0
- package/dist/agents/WorkerProcessEntry.d.ts +12 -0
- package/dist/agents/WorkerProcessEntry.d.ts.map +1 -0
- package/dist/agents/WorkerProcessEntry.js +565 -0
- package/dist/agents/WorkerProcessEntry.js.map +1 -0
- package/dist/agents/WorkerTaskAgent.d.ts +46 -0
- package/dist/agents/WorkerTaskAgent.d.ts.map +1 -0
- package/dist/agents/WorkerTaskAgent.js +114 -0
- package/dist/agents/WorkerTaskAgent.js.map +1 -0
- package/dist/agents/agentP0Message.d.ts +42 -0
- package/dist/agents/agentP0Message.d.ts.map +1 -0
- package/dist/agents/agentP0Message.js +48 -0
- package/dist/agents/agentP0Message.js.map +1 -0
- package/dist/agents/errors/TimeoutError.d.ts +12 -0
- package/dist/agents/errors/TimeoutError.d.ts.map +1 -0
- package/dist/agents/errors/TimeoutError.js +20 -0
- package/dist/agents/errors/TimeoutError.js.map +1 -0
- package/dist/agents/external/ExternalAgentOrphans.d.ts +16 -0
- package/dist/agents/external/ExternalAgentOrphans.d.ts.map +1 -0
- package/dist/agents/external/ExternalAgentOrphans.js +95 -0
- package/dist/agents/external/ExternalAgentOrphans.js.map +1 -0
- package/dist/agents/external/ExternalAgentRunner.d.ts +78 -0
- package/dist/agents/external/ExternalAgentRunner.d.ts.map +1 -0
- package/dist/agents/external/ExternalAgentRunner.js +671 -0
- package/dist/agents/external/ExternalAgentRunner.js.map +1 -0
- package/dist/agents/external/availability.d.ts +16 -0
- package/dist/agents/external/availability.d.ts.map +1 -0
- package/dist/agents/external/availability.js +43 -0
- package/dist/agents/external/availability.js.map +1 -0
- package/dist/agents/external/completionReport.d.ts +17 -0
- package/dist/agents/external/completionReport.d.ts.map +1 -0
- package/dist/agents/external/completionReport.js +167 -0
- package/dist/agents/external/completionReport.js.map +1 -0
- package/dist/agents/external/drivers/ClaudeCodeDriver.d.ts +9 -0
- package/dist/agents/external/drivers/ClaudeCodeDriver.d.ts.map +1 -0
- package/dist/agents/external/drivers/ClaudeCodeDriver.js +210 -0
- package/dist/agents/external/drivers/ClaudeCodeDriver.js.map +1 -0
- package/dist/agents/external/drivers/CodexDriver.d.ts +9 -0
- package/dist/agents/external/drivers/CodexDriver.d.ts.map +1 -0
- package/dist/agents/external/drivers/CodexDriver.js +184 -0
- package/dist/agents/external/drivers/CodexDriver.js.map +1 -0
- package/dist/agents/external/lineReader.d.ts +10 -0
- package/dist/agents/external/lineReader.d.ts.map +1 -0
- package/dist/agents/external/lineReader.js +30 -0
- package/dist/agents/external/lineReader.js.map +1 -0
- package/dist/agents/external/modelResolver.d.ts +5 -0
- package/dist/agents/external/modelResolver.d.ts.map +1 -0
- package/dist/agents/external/modelResolver.js +87 -0
- package/dist/agents/external/modelResolver.js.map +1 -0
- package/dist/agents/external/promptBuilder.d.ts +3 -0
- package/dist/agents/external/promptBuilder.d.ts.map +1 -0
- package/dist/agents/external/promptBuilder.js +39 -0
- package/dist/agents/external/promptBuilder.js.map +1 -0
- package/dist/agents/external/types.d.ts +131 -0
- package/dist/agents/external/types.d.ts.map +1 -0
- package/dist/agents/external/types.js +2 -0
- package/dist/agents/external/types.js.map +1 -0
- package/dist/agents/leader/LeaderContextBuilder.d.ts +155 -0
- package/dist/agents/leader/LeaderContextBuilder.d.ts.map +1 -0
- package/dist/agents/leader/LeaderContextBuilder.js +629 -0
- package/dist/agents/leader/LeaderContextBuilder.js.map +1 -0
- package/dist/agents/leader/LeaderLlmSession.d.ts +11 -0
- package/dist/agents/leader/LeaderLlmSession.d.ts.map +1 -0
- package/dist/agents/leader/LeaderLlmSession.js +17 -0
- package/dist/agents/leader/LeaderLlmSession.js.map +1 -0
- package/dist/agents/leader/LeaderMetaToolRegistry.d.ts +15 -0
- package/dist/agents/leader/LeaderMetaToolRegistry.d.ts.map +1 -0
- package/dist/agents/leader/LeaderMetaToolRegistry.js +73 -0
- package/dist/agents/leader/LeaderMetaToolRegistry.js.map +1 -0
- package/dist/agents/leader/LeaderStreamBuffer.d.ts +15 -0
- package/dist/agents/leader/LeaderStreamBuffer.d.ts.map +1 -0
- package/dist/agents/leader/LeaderStreamBuffer.js +19 -0
- package/dist/agents/leader/LeaderStreamBuffer.js.map +1 -0
- package/dist/agents/leader/LeaderThinkingLoop.d.ts +239 -0
- package/dist/agents/leader/LeaderThinkingLoop.d.ts.map +1 -0
- package/dist/agents/leader/LeaderThinkingLoop.js +950 -0
- package/dist/agents/leader/LeaderThinkingLoop.js.map +1 -0
- package/dist/agents/leader/LeaderToolDispatch.d.ts +48 -0
- package/dist/agents/leader/LeaderToolDispatch.d.ts.map +1 -0
- package/dist/agents/leader/LeaderToolDispatch.js +337 -0
- package/dist/agents/leader/LeaderToolDispatch.js.map +1 -0
- package/dist/agents/leader/LeaderToolFailure.d.ts +22 -0
- package/dist/agents/leader/LeaderToolFailure.d.ts.map +1 -0
- package/dist/agents/leader/LeaderToolFailure.js +25 -0
- package/dist/agents/leader/LeaderToolFailure.js.map +1 -0
- package/dist/agents/leader/LeaderToolGates.d.ts +131 -0
- package/dist/agents/leader/LeaderToolGates.d.ts.map +1 -0
- package/dist/agents/leader/LeaderToolGates.js +290 -0
- package/dist/agents/leader/LeaderToolGates.js.map +1 -0
- package/dist/agents/leader/artifactContent.d.ts +38 -0
- package/dist/agents/leader/artifactContent.d.ts.map +1 -0
- package/dist/agents/leader/artifactContent.js +101 -0
- package/dist/agents/leader/artifactContent.js.map +1 -0
- package/dist/agents/leader/builtinRoles.d.ts +36 -0
- package/dist/agents/leader/builtinRoles.d.ts.map +1 -0
- package/dist/agents/leader/builtinRoles.js +41 -0
- package/dist/agents/leader/builtinRoles.js.map +1 -0
- package/dist/agents/leader/contextLimit.d.ts +25 -0
- package/dist/agents/leader/contextLimit.d.ts.map +1 -0
- package/dist/agents/leader/contextLimit.js +24 -0
- package/dist/agents/leader/contextLimit.js.map +1 -0
- package/dist/agents/leader/contextMemory.d.ts +19 -0
- package/dist/agents/leader/contextMemory.d.ts.map +1 -0
- package/dist/agents/leader/contextMemory.js +18 -0
- package/dist/agents/leader/contextMemory.js.map +1 -0
- package/dist/agents/leader/conversationBuffer.d.ts +23 -0
- package/dist/agents/leader/conversationBuffer.d.ts.map +1 -0
- package/dist/agents/leader/conversationBuffer.js +42 -0
- package/dist/agents/leader/conversationBuffer.js.map +1 -0
- package/dist/agents/leader/dynamicContext.d.ts +23 -0
- package/dist/agents/leader/dynamicContext.d.ts.map +1 -0
- package/dist/agents/leader/dynamicContext.js +51 -0
- package/dist/agents/leader/dynamicContext.js.map +1 -0
- package/dist/agents/leader/p0Message.d.ts +154 -0
- package/dist/agents/leader/p0Message.d.ts.map +1 -0
- package/dist/agents/leader/p0Message.js +229 -0
- package/dist/agents/leader/p0Message.js.map +1 -0
- package/dist/agents/leader/progressReport.d.ts +33 -0
- package/dist/agents/leader/progressReport.d.ts.map +1 -0
- package/dist/agents/leader/progressReport.js +59 -0
- package/dist/agents/leader/progressReport.js.map +1 -0
- package/dist/agents/leader/systemPrompt.d.ts +32 -0
- package/dist/agents/leader/systemPrompt.d.ts.map +1 -0
- package/dist/agents/leader/systemPrompt.js +32 -0
- package/dist/agents/leader/systemPrompt.js.map +1 -0
- package/dist/agents/leader/tools/LeaderAgentControlTools.d.ts +62 -0
- package/dist/agents/leader/tools/LeaderAgentControlTools.d.ts.map +1 -0
- package/dist/agents/leader/tools/LeaderAgentControlTools.js +619 -0
- package/dist/agents/leader/tools/LeaderAgentControlTools.js.map +1 -0
- package/dist/agents/leader/tools/LeaderTaskPlanningTools.d.ts +54 -0
- package/dist/agents/leader/tools/LeaderTaskPlanningTools.d.ts.map +1 -0
- package/dist/agents/leader/tools/LeaderTaskPlanningTools.js +1353 -0
- package/dist/agents/leader/tools/LeaderTaskPlanningTools.js.map +1 -0
- package/dist/agents/leader/userContent.d.ts +15 -0
- package/dist/agents/leader/userContent.d.ts.map +1 -0
- package/dist/agents/leader/userContent.js +50 -0
- package/dist/agents/leader/userContent.js.map +1 -0
- package/dist/agents/leader/workerCompletionFormatter.d.ts +48 -0
- package/dist/agents/leader/workerCompletionFormatter.d.ts.map +1 -0
- package/dist/agents/leader/workerCompletionFormatter.js +53 -0
- package/dist/agents/leader/workerCompletionFormatter.js.map +1 -0
- package/dist/agents/messageMemoryBudget.d.ts +41 -0
- package/dist/agents/messageMemoryBudget.d.ts.map +1 -0
- package/dist/agents/messageMemoryBudget.js +91 -0
- package/dist/agents/messageMemoryBudget.js.map +1 -0
- package/dist/agents/office/OfficeModeProtocol.d.ts +3 -0
- package/dist/agents/office/OfficeModeProtocol.d.ts.map +1 -0
- package/dist/agents/office/OfficeModeProtocol.js +111 -0
- package/dist/agents/office/OfficeModeProtocol.js.map +1 -0
- package/dist/agents/pool/AgentPoolBroadcast.d.ts +25 -0
- package/dist/agents/pool/AgentPoolBroadcast.d.ts.map +1 -0
- package/dist/agents/pool/AgentPoolBroadcast.js +88 -0
- package/dist/agents/pool/AgentPoolBroadcast.js.map +1 -0
- package/dist/agents/pool/AgentPoolCompletionPayload.d.ts +17 -0
- package/dist/agents/pool/AgentPoolCompletionPayload.d.ts.map +1 -0
- package/dist/agents/pool/AgentPoolCompletionPayload.js +2 -0
- package/dist/agents/pool/AgentPoolCompletionPayload.js.map +1 -0
- package/dist/agents/pool/AgentPoolEvents.d.ts +20 -0
- package/dist/agents/pool/AgentPoolEvents.d.ts.map +1 -0
- package/dist/agents/pool/AgentPoolEvents.js +35 -0
- package/dist/agents/pool/AgentPoolEvents.js.map +1 -0
- package/dist/agents/pool/FaultRecovery.d.ts +106 -0
- package/dist/agents/pool/FaultRecovery.d.ts.map +1 -0
- package/dist/agents/pool/FaultRecovery.js +290 -0
- package/dist/agents/pool/FaultRecovery.js.map +1 -0
- package/dist/agents/pool/RemoteDispatchCoordinator.d.ts +63 -0
- package/dist/agents/pool/RemoteDispatchCoordinator.d.ts.map +1 -0
- package/dist/agents/pool/RemoteDispatchCoordinator.js +127 -0
- package/dist/agents/pool/RemoteDispatchCoordinator.js.map +1 -0
- package/dist/agents/pool/SlotScheduler.d.ts +83 -0
- package/dist/agents/pool/SlotScheduler.d.ts.map +1 -0
- package/dist/agents/pool/SlotScheduler.js +292 -0
- package/dist/agents/pool/SlotScheduler.js.map +1 -0
- package/dist/agents/pool/WorkerEventHandlerBinder.d.ts +133 -0
- package/dist/agents/pool/WorkerEventHandlerBinder.d.ts.map +1 -0
- package/dist/agents/pool/WorkerEventHandlerBinder.js +668 -0
- package/dist/agents/pool/WorkerEventHandlerBinder.js.map +1 -0
- package/dist/agents/pool/WorkerLifecycle.d.ts +68 -0
- package/dist/agents/pool/WorkerLifecycle.d.ts.map +1 -0
- package/dist/agents/pool/WorkerLifecycle.js +99 -0
- package/dist/agents/pool/WorkerLifecycle.js.map +1 -0
- package/dist/agents/pool/WorkerPayloadBuilder.d.ts +46 -0
- package/dist/agents/pool/WorkerPayloadBuilder.d.ts.map +1 -0
- package/dist/agents/pool/WorkerPayloadBuilder.js +294 -0
- package/dist/agents/pool/WorkerPayloadBuilder.js.map +1 -0
- package/dist/agents/prompts/PromptTemplates.d.ts +59 -0
- package/dist/agents/prompts/PromptTemplates.d.ts.map +1 -0
- package/dist/agents/prompts/PromptTemplates.js +223 -0
- package/dist/agents/prompts/PromptTemplates.js.map +1 -0
- package/dist/agents/prompts/architect_system.d.ts +30 -0
- package/dist/agents/prompts/architect_system.d.ts.map +1 -0
- package/dist/agents/prompts/architect_system.js +95 -0
- package/dist/agents/prompts/architect_system.js.map +1 -0
- package/dist/agents/prompts/backend_system.d.ts +5 -0
- package/dist/agents/prompts/backend_system.d.ts.map +1 -0
- package/dist/agents/prompts/backend_system.js +64 -0
- package/dist/agents/prompts/backend_system.js.map +1 -0
- package/dist/agents/prompts/evaluator_system.d.ts +5 -0
- package/dist/agents/prompts/evaluator_system.d.ts.map +1 -0
- package/dist/agents/prompts/evaluator_system.js +67 -0
- package/dist/agents/prompts/evaluator_system.js.map +1 -0
- package/dist/agents/prompts/frontend_system.d.ts +5 -0
- package/dist/agents/prompts/frontend_system.d.ts.map +1 -0
- package/dist/agents/prompts/frontend_system.js +66 -0
- package/dist/agents/prompts/frontend_system.js.map +1 -0
- package/dist/agents/prompts/fullstack_system.d.ts +5 -0
- package/dist/agents/prompts/fullstack_system.d.ts.map +1 -0
- package/dist/agents/prompts/fullstack_system.js +64 -0
- package/dist/agents/prompts/fullstack_system.js.map +1 -0
- package/dist/agents/prompts/i18n/catalog.d.ts +172 -0
- package/dist/agents/prompts/i18n/catalog.d.ts.map +1 -0
- package/dist/agents/prompts/i18n/catalog.js +498 -0
- package/dist/agents/prompts/i18n/catalog.js.map +1 -0
- package/dist/agents/prompts/i18n/leader_system_prompt.d.ts +6 -0
- package/dist/agents/prompts/i18n/leader_system_prompt.d.ts.map +1 -0
- package/dist/agents/prompts/i18n/leader_system_prompt.js +909 -0
- package/dist/agents/prompts/i18n/leader_system_prompt.js.map +1 -0
- package/dist/agents/prompts/i18n/userIntentLabels.d.ts +10 -0
- package/dist/agents/prompts/i18n/userIntentLabels.d.ts.map +1 -0
- package/dist/agents/prompts/i18n/userIntentLabels.js +21 -0
- package/dist/agents/prompts/i18n/userIntentLabels.js.map +1 -0
- package/dist/agents/prompts/leader/system_prompt.d.ts +6 -0
- package/dist/agents/prompts/leader/system_prompt.d.ts.map +1 -0
- package/dist/agents/prompts/leader/system_prompt.js +8 -0
- package/dist/agents/prompts/leader/system_prompt.js.map +1 -0
- package/dist/agents/prompts/planner_system.d.ts +5 -0
- package/dist/agents/prompts/planner_system.d.ts.map +1 -0
- package/dist/agents/prompts/planner_system.js +69 -0
- package/dist/agents/prompts/planner_system.js.map +1 -0
- package/dist/agents/prompts/qa_system.d.ts +5 -0
- package/dist/agents/prompts/qa_system.d.ts.map +1 -0
- package/dist/agents/prompts/qa_system.js +57 -0
- package/dist/agents/prompts/qa_system.js.map +1 -0
- package/dist/agents/prompts/shared/fragments.d.ts +54 -0
- package/dist/agents/prompts/shared/fragments.d.ts.map +1 -0
- package/dist/agents/prompts/shared/fragments.js +222 -0
- package/dist/agents/prompts/shared/fragments.js.map +1 -0
- package/dist/agents/prompts/shared/prompt_builder.d.ts +6 -0
- package/dist/agents/prompts/shared/prompt_builder.d.ts.map +1 -0
- package/dist/agents/prompts/shared/prompt_builder.js +17 -0
- package/dist/agents/prompts/shared/prompt_builder.js.map +1 -0
- package/dist/agents/prompts/task-runtime/thinking_instruction.d.ts +2 -0
- package/dist/agents/prompts/task-runtime/thinking_instruction.d.ts.map +1 -0
- package/dist/agents/prompts/task-runtime/thinking_instruction.js +37 -0
- package/dist/agents/prompts/task-runtime/thinking_instruction.js.map +1 -0
- package/dist/agents/prompts/task-runtime/worker_task_prompt.d.ts +42 -0
- package/dist/agents/prompts/task-runtime/worker_task_prompt.d.ts.map +1 -0
- package/dist/agents/prompts/task-runtime/worker_task_prompt.js +181 -0
- package/dist/agents/prompts/task-runtime/worker_task_prompt.js.map +1 -0
- package/dist/agents/prompts/ux_designer_system.d.ts +5 -0
- package/dist/agents/prompts/ux_designer_system.d.ts.map +1 -0
- package/dist/agents/prompts/ux_designer_system.js +60 -0
- package/dist/agents/prompts/ux_designer_system.js.map +1 -0
- package/dist/agents/prompts/worker/system_prompts.d.ts +22 -0
- package/dist/agents/prompts/worker/system_prompts.d.ts.map +1 -0
- package/dist/agents/prompts/worker/system_prompts.js +313 -0
- package/dist/agents/prompts/worker/system_prompts.js.map +1 -0
- package/dist/agents/raw_tool_calls.d.ts +15 -0
- package/dist/agents/raw_tool_calls.d.ts.map +1 -0
- package/dist/agents/raw_tool_calls.js +273 -0
- package/dist/agents/raw_tool_calls.js.map +1 -0
- package/dist/agents/runtime/AgentCore.d.ts +13 -0
- package/dist/agents/runtime/AgentCore.d.ts.map +1 -0
- package/dist/agents/runtime/AgentCore.js +19 -0
- package/dist/agents/runtime/AgentCore.js.map +1 -0
- package/dist/agents/runtime/AgentInboxParsers.d.ts +46 -0
- package/dist/agents/runtime/AgentInboxParsers.d.ts.map +1 -0
- package/dist/agents/runtime/AgentInboxParsers.js +152 -0
- package/dist/agents/runtime/AgentInboxParsers.js.map +1 -0
- package/dist/agents/runtime/AgentRuntimeState.d.ts +36 -0
- package/dist/agents/runtime/AgentRuntimeState.d.ts.map +1 -0
- package/dist/agents/runtime/AgentRuntimeState.js +68 -0
- package/dist/agents/runtime/AgentRuntimeState.js.map +1 -0
- package/dist/agents/runtime/CompletionTerminationPolicy.d.ts +15 -0
- package/dist/agents/runtime/CompletionTerminationPolicy.d.ts.map +1 -0
- package/dist/agents/runtime/CompletionTerminationPolicy.js +18 -0
- package/dist/agents/runtime/CompletionTerminationPolicy.js.map +1 -0
- package/dist/agents/runtime/EternalPatrolJudge.d.ts +23 -0
- package/dist/agents/runtime/EternalPatrolJudge.d.ts.map +1 -0
- package/dist/agents/runtime/EternalPatrolJudge.js +114 -0
- package/dist/agents/runtime/EternalPatrolJudge.js.map +1 -0
- package/dist/agents/runtime/LlmRoundExecutor.d.ts +55 -0
- package/dist/agents/runtime/LlmRoundExecutor.d.ts.map +1 -0
- package/dist/agents/runtime/LlmRoundExecutor.js +382 -0
- package/dist/agents/runtime/LlmRoundExecutor.js.map +1 -0
- package/dist/agents/runtime/LlmStreamHooks.d.ts +59 -0
- package/dist/agents/runtime/LlmStreamHooks.d.ts.map +1 -0
- package/dist/agents/runtime/LlmStreamHooks.js +140 -0
- package/dist/agents/runtime/LlmStreamHooks.js.map +1 -0
- package/dist/agents/runtime/MandatoryVerification.d.ts +23 -0
- package/dist/agents/runtime/MandatoryVerification.d.ts.map +1 -0
- package/dist/agents/runtime/MandatoryVerification.js +108 -0
- package/dist/agents/runtime/MandatoryVerification.js.map +1 -0
- package/dist/agents/runtime/NextSpeakerPolicy.d.ts +53 -0
- package/dist/agents/runtime/NextSpeakerPolicy.d.ts.map +1 -0
- package/dist/agents/runtime/NextSpeakerPolicy.js +162 -0
- package/dist/agents/runtime/NextSpeakerPolicy.js.map +1 -0
- package/dist/agents/runtime/ReasoningLoopDriver.d.ts +32 -0
- package/dist/agents/runtime/ReasoningLoopDriver.d.ts.map +1 -0
- package/dist/agents/runtime/ReasoningLoopDriver.js +58 -0
- package/dist/agents/runtime/ReasoningLoopDriver.js.map +1 -0
- package/dist/agents/runtime/StreamChunkBuffer.d.ts +45 -0
- package/dist/agents/runtime/StreamChunkBuffer.d.ts.map +1 -0
- package/dist/agents/runtime/StreamChunkBuffer.js +57 -0
- package/dist/agents/runtime/StreamChunkBuffer.js.map +1 -0
- package/dist/agents/runtime/ToolCallSafety.d.ts +42 -0
- package/dist/agents/runtime/ToolCallSafety.d.ts.map +1 -0
- package/dist/agents/runtime/ToolCallSafety.js +319 -0
- package/dist/agents/runtime/ToolCallSafety.js.map +1 -0
- package/dist/agents/runtime/ToolFailureLoopGuard.d.ts +163 -0
- package/dist/agents/runtime/ToolFailureLoopGuard.d.ts.map +1 -0
- package/dist/agents/runtime/ToolFailureLoopGuard.js +368 -0
- package/dist/agents/runtime/ToolFailureLoopGuard.js.map +1 -0
- package/dist/agents/runtime/ToolLoopDetector.d.ts +47 -0
- package/dist/agents/runtime/ToolLoopDetector.d.ts.map +1 -0
- package/dist/agents/runtime/ToolLoopDetector.js +108 -0
- package/dist/agents/runtime/ToolLoopDetector.js.map +1 -0
- package/dist/agents/runtime/ToolProgressHeartbeat.d.ts +73 -0
- package/dist/agents/runtime/ToolProgressHeartbeat.d.ts.map +1 -0
- package/dist/agents/runtime/ToolProgressHeartbeat.js +152 -0
- package/dist/agents/runtime/ToolProgressHeartbeat.js.map +1 -0
- package/dist/agents/runtime/ToolResponseProcessor.d.ts +57 -0
- package/dist/agents/runtime/ToolResponseProcessor.d.ts.map +1 -0
- package/dist/agents/runtime/ToolResponseProcessor.js +87 -0
- package/dist/agents/runtime/ToolResponseProcessor.js.map +1 -0
- package/dist/agents/runtime/ToolScheduler.d.ts +31 -0
- package/dist/agents/runtime/ToolScheduler.d.ts.map +1 -0
- package/dist/agents/runtime/ToolScheduler.js +63 -0
- package/dist/agents/runtime/ToolScheduler.js.map +1 -0
- package/dist/agents/runtime/WorkerCompletionPolicy.d.ts +47 -0
- package/dist/agents/runtime/WorkerCompletionPolicy.d.ts.map +1 -0
- package/dist/agents/runtime/WorkerCompletionPolicy.js +304 -0
- package/dist/agents/runtime/WorkerCompletionPolicy.js.map +1 -0
- package/dist/agents/runtime/WorkerInteractiveRuntime.d.ts +87 -0
- package/dist/agents/runtime/WorkerInteractiveRuntime.d.ts.map +1 -0
- package/dist/agents/runtime/WorkerInteractiveRuntime.js +122 -0
- package/dist/agents/runtime/WorkerInteractiveRuntime.js.map +1 -0
- package/dist/agents/runtime/messageSummary.d.ts +7 -0
- package/dist/agents/runtime/messageSummary.d.ts.map +1 -0
- package/dist/agents/runtime/messageSummary.js +21 -0
- package/dist/agents/runtime/messageSummary.js.map +1 -0
- package/dist/agents/runtime/parallelToolBatch.d.ts +39 -0
- package/dist/agents/runtime/parallelToolBatch.d.ts.map +1 -0
- package/dist/agents/runtime/parallelToolBatch.js +64 -0
- package/dist/agents/runtime/parallelToolBatch.js.map +1 -0
- package/dist/config/ModelManager.d.ts +59 -0
- package/dist/config/ModelManager.d.ts.map +1 -0
- package/dist/config/ModelManager.js +256 -0
- package/dist/config/ModelManager.js.map +1 -0
- package/dist/config/defaults.d.ts +468 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +520 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config.d.ts +1225 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +1580 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts/adapters/BlockedAgingPolicy.d.ts +22 -0
- package/dist/contracts/adapters/BlockedAgingPolicy.d.ts.map +1 -0
- package/dist/contracts/adapters/BlockedAgingPolicy.js +29 -0
- package/dist/contracts/adapters/BlockedAgingPolicy.js.map +1 -0
- package/dist/contracts/adapters/EternalPatrolPolicy.d.ts +49 -0
- package/dist/contracts/adapters/EternalPatrolPolicy.d.ts.map +1 -0
- package/dist/contracts/adapters/EternalPatrolPolicy.js +78 -0
- package/dist/contracts/adapters/EternalPatrolPolicy.js.map +1 -0
- package/dist/contracts/adapters/EternalRuntimeProjection.d.ts +39 -0
- package/dist/contracts/adapters/EternalRuntimeProjection.d.ts.map +1 -0
- package/dist/contracts/adapters/EternalRuntimeProjection.js +114 -0
- package/dist/contracts/adapters/EternalRuntimeProjection.js.map +1 -0
- package/dist/contracts/adapters/EventAdapter.d.ts +89 -0
- package/dist/contracts/adapters/EventAdapter.d.ts.map +1 -0
- package/dist/contracts/adapters/EventAdapter.js +535 -0
- package/dist/contracts/adapters/EventAdapter.js.map +1 -0
- package/dist/contracts/adapters/SessionScope.d.ts +12 -0
- package/dist/contracts/adapters/SessionScope.d.ts.map +1 -0
- package/dist/contracts/adapters/SessionScope.js +33 -0
- package/dist/contracts/adapters/SessionScope.js.map +1 -0
- package/dist/contracts/adapters/StatusAdapter.d.ts +238 -0
- package/dist/contracts/adapters/StatusAdapter.d.ts.map +1 -0
- package/dist/contracts/adapters/StatusAdapter.js +719 -0
- package/dist/contracts/adapters/StatusAdapter.js.map +1 -0
- package/dist/contracts/adapters/ThinkContent.d.ts +19 -0
- package/dist/contracts/adapters/ThinkContent.d.ts.map +1 -0
- package/dist/contracts/adapters/ThinkContent.js +99 -0
- package/dist/contracts/adapters/ThinkContent.js.map +1 -0
- package/dist/contracts/constants/eventTypes.d.ts +3 -0
- package/dist/contracts/constants/eventTypes.d.ts.map +1 -0
- package/dist/contracts/constants/eventTypes.js +2 -0
- package/dist/contracts/constants/eventTypes.js.map +1 -0
- package/dist/contracts/constants/leaderToolDefinitions.d.ts +18 -0
- package/dist/contracts/constants/leaderToolDefinitions.d.ts.map +1 -0
- package/dist/contracts/constants/leaderToolDefinitions.js +1070 -0
- package/dist/contracts/constants/leaderToolDefinitions.js.map +1 -0
- package/dist/contracts/constants/statusValues.d.ts +7 -0
- package/dist/contracts/constants/statusValues.d.ts.map +1 -0
- package/dist/contracts/constants/statusValues.js +6 -0
- package/dist/contracts/constants/statusValues.js.map +1 -0
- package/dist/contracts/constants/toolNames.d.ts +8 -0
- package/dist/contracts/constants/toolNames.d.ts.map +1 -0
- package/dist/contracts/constants/toolNames.js +25 -0
- package/dist/contracts/constants/toolNames.js.map +1 -0
- package/dist/contracts/index.d.ts +13 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +13 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/modes.d.ts +93 -0
- package/dist/contracts/modes.d.ts.map +1 -0
- package/dist/contracts/modes.js +104 -0
- package/dist/contracts/modes.js.map +1 -0
- package/dist/contracts/types/Agent.d.ts +164 -0
- package/dist/contracts/types/Agent.d.ts.map +1 -0
- package/dist/contracts/types/Agent.js +156 -0
- package/dist/contracts/types/Agent.js.map +1 -0
- package/dist/contracts/types/Autonomy.d.ts +88 -0
- package/dist/contracts/types/Autonomy.d.ts.map +1 -0
- package/dist/contracts/types/Autonomy.js +126 -0
- package/dist/contracts/types/Autonomy.js.map +1 -0
- package/dist/contracts/types/AutonomyDecision.d.ts +48 -0
- package/dist/contracts/types/AutonomyDecision.d.ts.map +1 -0
- package/dist/contracts/types/AutonomyDecision.js +27 -0
- package/dist/contracts/types/AutonomyDecision.js.map +1 -0
- package/dist/contracts/types/Canvas.d.ts +163 -0
- package/dist/contracts/types/Canvas.d.ts.map +1 -0
- package/dist/contracts/types/Canvas.js +22 -0
- package/dist/contracts/types/Canvas.js.map +1 -0
- package/dist/contracts/types/Event.d.ts +510 -0
- package/dist/contracts/types/Event.d.ts.map +1 -0
- package/dist/contracts/types/Event.js +197 -0
- package/dist/contracts/types/Event.js.map +1 -0
- package/dist/contracts/types/Message.d.ts +94 -0
- package/dist/contracts/types/Message.d.ts.map +1 -0
- package/dist/contracts/types/Message.js +151 -0
- package/dist/contracts/types/Message.js.map +1 -0
- package/dist/contracts/types/Session.d.ts +9 -0
- package/dist/contracts/types/Session.d.ts.map +1 -0
- package/dist/contracts/types/Session.js +2 -0
- package/dist/contracts/types/Session.js.map +1 -0
- package/dist/contracts/types/Status.d.ts +12 -0
- package/dist/contracts/types/Status.d.ts.map +1 -0
- package/dist/contracts/types/Status.js +30 -0
- package/dist/contracts/types/Status.js.map +1 -0
- package/dist/contracts/types/TokenUsage.d.ts +46 -0
- package/dist/contracts/types/TokenUsage.d.ts.map +1 -0
- package/dist/contracts/types/TokenUsage.js +41 -0
- package/dist/contracts/types/TokenUsage.js.map +1 -0
- package/dist/contracts/types/Tool.d.ts +66 -0
- package/dist/contracts/types/Tool.d.ts.map +1 -0
- package/dist/contracts/types/Tool.js +10 -0
- package/dist/contracts/types/Tool.js.map +1 -0
- package/dist/contracts/types/ToolMetadata.d.ts +35 -0
- package/dist/contracts/types/ToolMetadata.d.ts.map +1 -0
- package/dist/contracts/types/ToolMetadata.js +131 -0
- package/dist/contracts/types/ToolMetadata.js.map +1 -0
- package/dist/contracts/types/Workflow.d.ts +278 -0
- package/dist/contracts/types/Workflow.d.ts.map +1 -0
- package/dist/contracts/types/Workflow.js +752 -0
- package/dist/contracts/types/Workflow.js.map +1 -0
- package/dist/core/ActiveSessionCoordinator.d.ts +23 -0
- package/dist/core/ActiveSessionCoordinator.d.ts.map +1 -0
- package/dist/core/ActiveSessionCoordinator.js +34 -0
- package/dist/core/ActiveSessionCoordinator.js.map +1 -0
- package/dist/core/AgentHealthMonitor.d.ts +162 -0
- package/dist/core/AgentHealthMonitor.d.ts.map +1 -0
- package/dist/core/AgentHealthMonitor.js +442 -0
- package/dist/core/AgentHealthMonitor.js.map +1 -0
- package/dist/core/AgentProtocol.d.ts +187 -0
- package/dist/core/AgentProtocol.d.ts.map +1 -0
- package/dist/core/AgentProtocol.js +213 -0
- package/dist/core/AgentProtocol.js.map +1 -0
- package/dist/core/AlertManager.d.ts +66 -0
- package/dist/core/AlertManager.d.ts.map +1 -0
- package/dist/core/AlertManager.js +126 -0
- package/dist/core/AlertManager.js.map +1 -0
- package/dist/core/ArtifactAwareness.d.ts +37 -0
- package/dist/core/ArtifactAwareness.d.ts.map +1 -0
- package/dist/core/ArtifactAwareness.js +212 -0
- package/dist/core/ArtifactAwareness.js.map +1 -0
- package/dist/core/AssumptionTracker.d.ts +88 -0
- package/dist/core/AssumptionTracker.d.ts.map +1 -0
- package/dist/core/AssumptionTracker.js +316 -0
- package/dist/core/AssumptionTracker.js.map +1 -0
- package/dist/core/AstStructuralEngine.d.ts +91 -0
- package/dist/core/AstStructuralEngine.d.ts.map +1 -0
- package/dist/core/AstStructuralEngine.js +436 -0
- package/dist/core/AstStructuralEngine.js.map +1 -0
- package/dist/core/AutonomousFaultPolicy.d.ts +17 -0
- package/dist/core/AutonomousFaultPolicy.d.ts.map +1 -0
- package/dist/core/AutonomousFaultPolicy.js +108 -0
- package/dist/core/AutonomousFaultPolicy.js.map +1 -0
- package/dist/core/BaselineAlertMonitor.d.ts +25 -0
- package/dist/core/BaselineAlertMonitor.d.ts.map +1 -0
- package/dist/core/BaselineAlertMonitor.js +66 -0
- package/dist/core/BaselineAlertMonitor.js.map +1 -0
- package/dist/core/BootstrapDoctor.d.ts +36 -0
- package/dist/core/BootstrapDoctor.d.ts.map +1 -0
- package/dist/core/BootstrapDoctor.js +288 -0
- package/dist/core/BootstrapDoctor.js.map +1 -0
- package/dist/core/BrowserProvider.d.ts +59 -0
- package/dist/core/BrowserProvider.d.ts.map +1 -0
- package/dist/core/BrowserProvider.js +533 -0
- package/dist/core/BrowserProvider.js.map +1 -0
- package/dist/core/BrowserRuntime.d.ts +178 -0
- package/dist/core/BrowserRuntime.d.ts.map +1 -0
- package/dist/core/BrowserRuntime.js +487 -0
- package/dist/core/BrowserRuntime.js.map +1 -0
- package/dist/core/BrowserStealth.d.ts +31 -0
- package/dist/core/BrowserStealth.d.ts.map +1 -0
- package/dist/core/BrowserStealth.js +111 -0
- package/dist/core/BrowserStealth.js.map +1 -0
- package/dist/core/BughuntDagScheduler.d.ts +19 -0
- package/dist/core/BughuntDagScheduler.d.ts.map +1 -0
- package/dist/core/BughuntDagScheduler.js +82 -0
- package/dist/core/BughuntDagScheduler.js.map +1 -0
- package/dist/core/BughuntEvidenceCapture.d.ts +9 -0
- package/dist/core/BughuntEvidenceCapture.d.ts.map +1 -0
- package/dist/core/BughuntEvidenceCapture.js +27 -0
- package/dist/core/BughuntEvidenceCapture.js.map +1 -0
- package/dist/core/BughuntEvidenceExtractor.d.ts +10 -0
- package/dist/core/BughuntEvidenceExtractor.d.ts.map +1 -0
- package/dist/core/BughuntEvidenceExtractor.js +82 -0
- package/dist/core/BughuntEvidenceExtractor.js.map +1 -0
- package/dist/core/BughuntEvidencePack.d.ts +11 -0
- package/dist/core/BughuntEvidencePack.d.ts.map +1 -0
- package/dist/core/BughuntEvidencePack.js +47 -0
- package/dist/core/BughuntEvidencePack.js.map +1 -0
- package/dist/core/BughuntLedger.d.ts +125 -0
- package/dist/core/BughuntLedger.d.ts.map +1 -0
- package/dist/core/BughuntLedger.js +432 -0
- package/dist/core/BughuntLedger.js.map +1 -0
- package/dist/core/BughuntPolicy.d.ts +23 -0
- package/dist/core/BughuntPolicy.d.ts.map +1 -0
- package/dist/core/BughuntPolicy.js +37 -0
- package/dist/core/BughuntPolicy.js.map +1 -0
- package/dist/core/BuildDiagnosticsCollector.d.ts +97 -0
- package/dist/core/BuildDiagnosticsCollector.d.ts.map +1 -0
- package/dist/core/BuildDiagnosticsCollector.js +200 -0
- package/dist/core/BuildDiagnosticsCollector.js.map +1 -0
- package/dist/core/BundledSkillRegistry.d.ts +25 -0
- package/dist/core/BundledSkillRegistry.d.ts.map +1 -0
- package/dist/core/BundledSkillRegistry.js +86 -0
- package/dist/core/BundledSkillRegistry.js.map +1 -0
- package/dist/core/BusMessageTypes.d.ts +109 -0
- package/dist/core/BusMessageTypes.d.ts.map +1 -0
- package/dist/core/BusMessageTypes.js +49 -0
- package/dist/core/BusMessageTypes.js.map +1 -0
- package/dist/core/ChangeImpactResolver.d.ts +71 -0
- package/dist/core/ChangeImpactResolver.d.ts.map +1 -0
- package/dist/core/ChangeImpactResolver.js +130 -0
- package/dist/core/ChangeImpactResolver.js.map +1 -0
- package/dist/core/CleanupRegistry.d.ts +39 -0
- package/dist/core/CleanupRegistry.d.ts.map +1 -0
- package/dist/core/CleanupRegistry.js +91 -0
- package/dist/core/CleanupRegistry.js.map +1 -0
- package/dist/core/ContextManager.d.ts +135 -0
- package/dist/core/ContextManager.d.ts.map +1 -0
- package/dist/core/ContextManager.js +755 -0
- package/dist/core/ContextManager.js.map +1 -0
- package/dist/core/ContextManifest.d.ts +125 -0
- package/dist/core/ContextManifest.d.ts.map +1 -0
- package/dist/core/ContextManifest.js +265 -0
- package/dist/core/ContextManifest.js.map +1 -0
- package/dist/core/ContextMemoryIndex.d.ts +74 -0
- package/dist/core/ContextMemoryIndex.d.ts.map +1 -0
- package/dist/core/ContextMemoryIndex.js +431 -0
- package/dist/core/ContextMemoryIndex.js.map +1 -0
- package/dist/core/ContextRuntimeState.d.ts +43 -0
- package/dist/core/ContextRuntimeState.d.ts.map +1 -0
- package/dist/core/ContextRuntimeState.js +79 -0
- package/dist/core/ContextRuntimeState.js.map +1 -0
- package/dist/core/ContractAllowedScope.d.ts +67 -0
- package/dist/core/ContractAllowedScope.d.ts.map +1 -0
- package/dist/core/ContractAllowedScope.js +109 -0
- package/dist/core/ContractAllowedScope.js.map +1 -0
- package/dist/core/ContractDriftAudit.d.ts +28 -0
- package/dist/core/ContractDriftAudit.d.ts.map +1 -0
- package/dist/core/ContractDriftAudit.js +31 -0
- package/dist/core/ContractDriftAudit.js.map +1 -0
- package/dist/core/ContractHotSync.d.ts +88 -0
- package/dist/core/ContractHotSync.d.ts.map +1 -0
- package/dist/core/ContractHotSync.js +142 -0
- package/dist/core/ContractHotSync.js.map +1 -0
- package/dist/core/ContractPack.d.ts +67 -0
- package/dist/core/ContractPack.d.ts.map +1 -0
- package/dist/core/ContractPack.js +397 -0
- package/dist/core/ContractPack.js.map +1 -0
- package/dist/core/ContractProvenance.d.ts +6 -0
- package/dist/core/ContractProvenance.d.ts.map +1 -0
- package/dist/core/ContractProvenance.js +39 -0
- package/dist/core/ContractProvenance.js.map +1 -0
- package/dist/core/CrashReporter.d.ts +51 -0
- package/dist/core/CrashReporter.d.ts.map +1 -0
- package/dist/core/CrashReporter.js +179 -0
- package/dist/core/CrashReporter.js.map +1 -0
- package/dist/core/DaemonManager.d.ts +100 -0
- package/dist/core/DaemonManager.d.ts.map +1 -0
- package/dist/core/DaemonManager.js +429 -0
- package/dist/core/DaemonManager.js.map +1 -0
- package/dist/core/DagScheduler.d.ts +73 -0
- package/dist/core/DagScheduler.d.ts.map +1 -0
- package/dist/core/DagScheduler.js +111 -0
- package/dist/core/DagScheduler.js.map +1 -0
- package/dist/core/Database.d.ts +545 -0
- package/dist/core/Database.d.ts.map +1 -0
- package/dist/core/Database.js +2158 -0
- package/dist/core/Database.js.map +1 -0
- package/dist/core/DatabaseLockRecovery.d.ts +50 -0
- package/dist/core/DatabaseLockRecovery.d.ts.map +1 -0
- package/dist/core/DatabaseLockRecovery.js +167 -0
- package/dist/core/DatabaseLockRecovery.js.map +1 -0
- package/dist/core/DatabaseRepositories.d.ts +298 -0
- package/dist/core/DatabaseRepositories.d.ts.map +1 -0
- package/dist/core/DatabaseRepositories.js +292 -0
- package/dist/core/DatabaseRepositories.js.map +1 -0
- package/dist/core/DesignAssetCatalog.d.ts +180 -0
- package/dist/core/DesignAssetCatalog.d.ts.map +1 -0
- package/dist/core/DesignAssetCatalog.js +691 -0
- package/dist/core/DesignAssetCatalog.js.map +1 -0
- package/dist/core/DeterministicAcceptance.d.ts +96 -0
- package/dist/core/DeterministicAcceptance.d.ts.map +1 -0
- package/dist/core/DeterministicAcceptance.js +218 -0
- package/dist/core/DeterministicAcceptance.js.map +1 -0
- package/dist/core/Diagnostics.d.ts +49 -0
- package/dist/core/Diagnostics.d.ts.map +1 -0
- package/dist/core/Diagnostics.js +308 -0
- package/dist/core/Diagnostics.js.map +1 -0
- package/dist/core/EternalGoal.d.ts +15 -0
- package/dist/core/EternalGoal.d.ts.map +1 -0
- package/dist/core/EternalGoal.js +67 -0
- package/dist/core/EternalGoal.js.map +1 -0
- package/dist/core/EternalLoop.d.ts +206 -0
- package/dist/core/EternalLoop.d.ts.map +1 -0
- package/dist/core/EternalLoop.js +595 -0
- package/dist/core/EternalLoop.js.map +1 -0
- package/dist/core/EternalRuntimeProjection.d.ts +39 -0
- package/dist/core/EternalRuntimeProjection.d.ts.map +1 -0
- package/dist/core/EternalRuntimeProjection.js +114 -0
- package/dist/core/EternalRuntimeProjection.js.map +1 -0
- package/dist/core/EternalRuntimeTelemetry.d.ts +63 -0
- package/dist/core/EternalRuntimeTelemetry.d.ts.map +1 -0
- package/dist/core/EternalRuntimeTelemetry.js +153 -0
- package/dist/core/EternalRuntimeTelemetry.js.map +1 -0
- package/dist/core/EternalSupervisor.d.ts +108 -0
- package/dist/core/EternalSupervisor.d.ts.map +1 -0
- package/dist/core/EternalSupervisor.js +259 -0
- package/dist/core/EternalSupervisor.js.map +1 -0
- package/dist/core/EventEmitter.d.ts +1325 -0
- package/dist/core/EventEmitter.d.ts.map +1 -0
- package/dist/core/EventEmitter.js +76 -0
- package/dist/core/EventEmitter.js.map +1 -0
- package/dist/core/ExecutionLease.d.ts +46 -0
- package/dist/core/ExecutionLease.d.ts.map +1 -0
- package/dist/core/ExecutionLease.js +123 -0
- package/dist/core/ExecutionLease.js.map +1 -0
- package/dist/core/ExecutionTraceMemory.d.ts +96 -0
- package/dist/core/ExecutionTraceMemory.d.ts.map +1 -0
- package/dist/core/ExecutionTraceMemory.js +243 -0
- package/dist/core/ExecutionTraceMemory.js.map +1 -0
- package/dist/core/FileLock.d.ts +108 -0
- package/dist/core/FileLock.d.ts.map +1 -0
- package/dist/core/FileLock.js +431 -0
- package/dist/core/FileLock.js.map +1 -0
- package/dist/core/HardeningPolicy.d.ts +85 -0
- package/dist/core/HardeningPolicy.d.ts.map +1 -0
- package/dist/core/HardeningPolicy.js +191 -0
- package/dist/core/HardeningPolicy.js.map +1 -0
- package/dist/core/HierarchicalContextManager.d.ts +83 -0
- package/dist/core/HierarchicalContextManager.d.ts.map +1 -0
- package/dist/core/HierarchicalContextManager.js +324 -0
- package/dist/core/HierarchicalContextManager.js.map +1 -0
- package/dist/core/ImportGraphEngine.d.ts +84 -0
- package/dist/core/ImportGraphEngine.d.ts.map +1 -0
- package/dist/core/ImportGraphEngine.js +253 -0
- package/dist/core/ImportGraphEngine.js.map +1 -0
- package/dist/core/IntegrationVerifyInjector.d.ts +76 -0
- package/dist/core/IntegrationVerifyInjector.d.ts.map +1 -0
- package/dist/core/IntegrationVerifyInjector.js +164 -0
- package/dist/core/IntegrationVerifyInjector.js.map +1 -0
- package/dist/core/IntuitionRuntime.d.ts +12 -0
- package/dist/core/IntuitionRuntime.d.ts.map +1 -0
- package/dist/core/IntuitionRuntime.js +137 -0
- package/dist/core/IntuitionRuntime.js.map +1 -0
- package/dist/core/JudgmentService.d.ts +45 -0
- package/dist/core/JudgmentService.d.ts.map +1 -0
- package/dist/core/JudgmentService.js +77 -0
- package/dist/core/JudgmentService.js.map +1 -0
- package/dist/core/LangfuseIntegration.d.ts +208 -0
- package/dist/core/LangfuseIntegration.d.ts.map +1 -0
- package/dist/core/LangfuseIntegration.js +611 -0
- package/dist/core/LangfuseIntegration.js.map +1 -0
- package/dist/core/LlmInputManifest.d.ts +40 -0
- package/dist/core/LlmInputManifest.d.ts.map +1 -0
- package/dist/core/LlmInputManifest.js +94 -0
- package/dist/core/LlmInputManifest.js.map +1 -0
- package/dist/core/LocalLlmGateway.d.ts +75 -0
- package/dist/core/LocalLlmGateway.d.ts.map +1 -0
- package/dist/core/LocalLlmGateway.js +389 -0
- package/dist/core/LocalLlmGateway.js.map +1 -0
- package/dist/core/LocalLlmGatewayServer.d.ts +38 -0
- package/dist/core/LocalLlmGatewayServer.d.ts.map +1 -0
- package/dist/core/LocalLlmGatewayServer.js +85 -0
- package/dist/core/LocalLlmGatewayServer.js.map +1 -0
- package/dist/core/Log.d.ts +97 -0
- package/dist/core/Log.d.ts.map +1 -0
- package/dist/core/Log.js +249 -0
- package/dist/core/Log.js.map +1 -0
- package/dist/core/LogMaintenance.d.ts +38 -0
- package/dist/core/LogMaintenance.d.ts.map +1 -0
- package/dist/core/LogMaintenance.js +239 -0
- package/dist/core/LogMaintenance.js.map +1 -0
- package/dist/core/MarketplaceService.d.ts +57 -0
- package/dist/core/MarketplaceService.d.ts.map +1 -0
- package/dist/core/MarketplaceService.js +982 -0
- package/dist/core/MarketplaceService.js.map +1 -0
- package/dist/core/McpClient.d.ts +93 -0
- package/dist/core/McpClient.d.ts.map +1 -0
- package/dist/core/McpClient.js +277 -0
- package/dist/core/McpClient.js.map +1 -0
- package/dist/core/MessageBus.d.ts +247 -0
- package/dist/core/MessageBus.d.ts.map +1 -0
- package/dist/core/MessageBus.js +852 -0
- package/dist/core/MessageBus.js.map +1 -0
- package/dist/core/Metrics.d.ts +50 -0
- package/dist/core/Metrics.d.ts.map +1 -0
- package/dist/core/Metrics.js +171 -0
- package/dist/core/Metrics.js.map +1 -0
- package/dist/core/MetricsRegistry.d.ts +47 -0
- package/dist/core/MetricsRegistry.d.ts.map +1 -0
- package/dist/core/MetricsRegistry.js +119 -0
- package/dist/core/MetricsRegistry.js.map +1 -0
- package/dist/core/ModeAudit.d.ts +87 -0
- package/dist/core/ModeAudit.d.ts.map +1 -0
- package/dist/core/ModeAudit.js +113 -0
- package/dist/core/ModeAudit.js.map +1 -0
- package/dist/core/ModeRuntimeProjection.d.ts +96 -0
- package/dist/core/ModeRuntimeProjection.d.ts.map +1 -0
- package/dist/core/ModeRuntimeProjection.js +216 -0
- package/dist/core/ModeRuntimeProjection.js.map +1 -0
- package/dist/core/ModeStore.d.ts +62 -0
- package/dist/core/ModeStore.d.ts.map +1 -0
- package/dist/core/ModeStore.js +77 -0
- package/dist/core/ModeStore.js.map +1 -0
- package/dist/core/ModeToolPolicy.d.ts +62 -0
- package/dist/core/ModeToolPolicy.d.ts.map +1 -0
- package/dist/core/ModeToolPolicy.js +145 -0
- package/dist/core/ModeToolPolicy.js.map +1 -0
- package/dist/core/ModeWorktreeService.d.ts +31 -0
- package/dist/core/ModeWorktreeService.d.ts.map +1 -0
- package/dist/core/ModeWorktreeService.js +116 -0
- package/dist/core/ModeWorktreeService.js.map +1 -0
- package/dist/core/OrchestrationTypes.d.ts +114 -0
- package/dist/core/OrchestrationTypes.d.ts.map +1 -0
- package/dist/core/OrchestrationTypes.js +2 -0
- package/dist/core/OrchestrationTypes.js.map +1 -0
- package/dist/core/PatternRecognitionEngine.d.ts +33 -0
- package/dist/core/PatternRecognitionEngine.d.ts.map +1 -0
- package/dist/core/PatternRecognitionEngine.js +82 -0
- package/dist/core/PatternRecognitionEngine.js.map +1 -0
- package/dist/core/PerformanceBaselineTracker.d.ts +28 -0
- package/dist/core/PerformanceBaselineTracker.d.ts.map +1 -0
- package/dist/core/PerformanceBaselineTracker.js +48 -0
- package/dist/core/PerformanceBaselineTracker.js.map +1 -0
- package/dist/core/PermissionStore.d.ts +14 -0
- package/dist/core/PermissionStore.d.ts.map +1 -0
- package/dist/core/PermissionStore.js +318 -0
- package/dist/core/PermissionStore.js.map +1 -0
- package/dist/core/PermissionSystem.d.ts +79 -0
- package/dist/core/PermissionSystem.d.ts.map +1 -0
- package/dist/core/PermissionSystem.js +380 -0
- package/dist/core/PermissionSystem.js.map +1 -0
- package/dist/core/PhasePolicy.d.ts +10 -0
- package/dist/core/PhasePolicy.d.ts.map +1 -0
- package/dist/core/PhasePolicy.js +15 -0
- package/dist/core/PhasePolicy.js.map +1 -0
- package/dist/core/PidRegistry.d.ts +58 -0
- package/dist/core/PidRegistry.d.ts.map +1 -0
- package/dist/core/PidRegistry.js +152 -0
- package/dist/core/PidRegistry.js.map +1 -0
- package/dist/core/ProcessIdleGuard.d.ts +76 -0
- package/dist/core/ProcessIdleGuard.d.ts.map +1 -0
- package/dist/core/ProcessIdleGuard.js +201 -0
- package/dist/core/ProcessIdleGuard.js.map +1 -0
- package/dist/core/ProcessOrphanCleaner.d.ts +37 -0
- package/dist/core/ProcessOrphanCleaner.d.ts.map +1 -0
- package/dist/core/ProcessOrphanCleaner.js +106 -0
- package/dist/core/ProcessOrphanCleaner.js.map +1 -0
- package/dist/core/ProcessSelfProtection.d.ts +45 -0
- package/dist/core/ProcessSelfProtection.d.ts.map +1 -0
- package/dist/core/ProcessSelfProtection.js +234 -0
- package/dist/core/ProcessSelfProtection.js.map +1 -0
- package/dist/core/ProjectBlueprint.d.ts +176 -0
- package/dist/core/ProjectBlueprint.d.ts.map +1 -0
- package/dist/core/ProjectBlueprint.js +542 -0
- package/dist/core/ProjectBlueprint.js.map +1 -0
- package/dist/core/ProjectContracts.d.ts +22 -0
- package/dist/core/ProjectContracts.d.ts.map +1 -0
- package/dist/core/ProjectContracts.js +97 -0
- package/dist/core/ProjectContracts.js.map +1 -0
- package/dist/core/ProjectRetentionPolicy.d.ts +31 -0
- package/dist/core/ProjectRetentionPolicy.d.ts.map +1 -0
- package/dist/core/ProjectRetentionPolicy.js +68 -0
- package/dist/core/ProjectRetentionPolicy.js.map +1 -0
- package/dist/core/ProjectRuntimeManager.d.ts +91 -0
- package/dist/core/ProjectRuntimeManager.d.ts.map +1 -0
- package/dist/core/ProjectRuntimeManager.js +458 -0
- package/dist/core/ProjectRuntimeManager.js.map +1 -0
- package/dist/core/ProjectRuntimeState.d.ts +122 -0
- package/dist/core/ProjectRuntimeState.d.ts.map +1 -0
- package/dist/core/ProjectRuntimeState.js +27 -0
- package/dist/core/ProjectRuntimeState.js.map +1 -0
- package/dist/core/ProxyConfig.d.ts +26 -0
- package/dist/core/ProxyConfig.d.ts.map +1 -0
- package/dist/core/ProxyConfig.js +121 -0
- package/dist/core/ProxyConfig.js.map +1 -0
- package/dist/core/RecoveryRecords.d.ts +29 -0
- package/dist/core/RecoveryRecords.d.ts.map +1 -0
- package/dist/core/RecoveryRecords.js +122 -0
- package/dist/core/RecoveryRecords.js.map +1 -0
- package/dist/core/RepairStrategyEngine.d.ts +94 -0
- package/dist/core/RepairStrategyEngine.d.ts.map +1 -0
- package/dist/core/RepairStrategyEngine.js +268 -0
- package/dist/core/RepairStrategyEngine.js.map +1 -0
- package/dist/core/ResourceBudgetService.d.ts +61 -0
- package/dist/core/ResourceBudgetService.d.ts.map +1 -0
- package/dist/core/ResourceBudgetService.js +257 -0
- package/dist/core/ResourceBudgetService.js.map +1 -0
- package/dist/core/ResumeManager.d.ts +18 -0
- package/dist/core/ResumeManager.d.ts.map +1 -0
- package/dist/core/ResumeManager.js +139 -0
- package/dist/core/ResumeManager.js.map +1 -0
- package/dist/core/RuntimeDiagnostics.d.ts +126 -0
- package/dist/core/RuntimeDiagnostics.d.ts.map +1 -0
- package/dist/core/RuntimeDiagnostics.js +367 -0
- package/dist/core/RuntimeDiagnostics.js.map +1 -0
- package/dist/core/RuntimeGuards.d.ts +16 -0
- package/dist/core/RuntimeGuards.d.ts.map +1 -0
- package/dist/core/RuntimeGuards.js +222 -0
- package/dist/core/RuntimeGuards.js.map +1 -0
- package/dist/core/RuntimeRecoveryController.d.ts +52 -0
- package/dist/core/RuntimeRecoveryController.d.ts.map +1 -0
- package/dist/core/RuntimeRecoveryController.js +156 -0
- package/dist/core/RuntimeRecoveryController.js.map +1 -0
- package/dist/core/ScheduledTaskManager.d.ts +110 -0
- package/dist/core/ScheduledTaskManager.d.ts.map +1 -0
- package/dist/core/ScheduledTaskManager.js +532 -0
- package/dist/core/ScheduledTaskManager.js.map +1 -0
- package/dist/core/ScratchpadReview.d.ts +22 -0
- package/dist/core/ScratchpadReview.d.ts.map +1 -0
- package/dist/core/ScratchpadReview.js +162 -0
- package/dist/core/ScratchpadReview.js.map +1 -0
- package/dist/core/SessionManager.d.ts +3 -0
- package/dist/core/SessionManager.d.ts.map +1 -0
- package/dist/core/SessionManager.js +2 -0
- package/dist/core/SessionManager.js.map +1 -0
- package/dist/core/SessionManagerRuntime.d.ts +3 -0
- package/dist/core/SessionManagerRuntime.d.ts.map +1 -0
- package/dist/core/SessionManagerRuntime.js +3 -0
- package/dist/core/SessionManagerRuntime.js.map +1 -0
- package/dist/core/SessionRuntime.d.ts +2 -0
- package/dist/core/SessionRuntime.d.ts.map +1 -0
- package/dist/core/SessionRuntime.js +2 -0
- package/dist/core/SessionRuntime.js.map +1 -0
- package/dist/core/SessionRuntimeState.d.ts +112 -0
- package/dist/core/SessionRuntimeState.d.ts.map +1 -0
- package/dist/core/SessionRuntimeState.js +250 -0
- package/dist/core/SessionRuntimeState.js.map +1 -0
- package/dist/core/SessionStateKeys.d.ts +138 -0
- package/dist/core/SessionStateKeys.d.ts.map +1 -0
- package/dist/core/SessionStateKeys.js +168 -0
- package/dist/core/SessionStateKeys.js.map +1 -0
- package/dist/core/SharedLedger.d.ts +98 -0
- package/dist/core/SharedLedger.d.ts.map +1 -0
- package/dist/core/SharedLedger.js +145 -0
- package/dist/core/SharedLedger.js.map +1 -0
- package/dist/core/SkillCatalog.d.ts +79 -0
- package/dist/core/SkillCatalog.d.ts.map +1 -0
- package/dist/core/SkillCatalog.js +473 -0
- package/dist/core/SkillCatalog.js.map +1 -0
- package/dist/core/SkillDefinitionService.d.ts +56 -0
- package/dist/core/SkillDefinitionService.d.ts.map +1 -0
- package/dist/core/SkillDefinitionService.js +144 -0
- package/dist/core/SkillDefinitionService.js.map +1 -0
- package/dist/core/SkillPhaseLoader.d.ts +21 -0
- package/dist/core/SkillPhaseLoader.d.ts.map +1 -0
- package/dist/core/SkillPhaseLoader.js +85 -0
- package/dist/core/SkillPhaseLoader.js.map +1 -0
- package/dist/core/SkillSelectionPolicy.d.ts +7 -0
- package/dist/core/SkillSelectionPolicy.d.ts.map +1 -0
- package/dist/core/SkillSelectionPolicy.js +10 -0
- package/dist/core/SkillSelectionPolicy.js.map +1 -0
- package/dist/core/SlidevServerManager.d.ts +51 -0
- package/dist/core/SlidevServerManager.d.ts.map +1 -0
- package/dist/core/SlidevServerManager.js +200 -0
- package/dist/core/SlidevServerManager.js.map +1 -0
- package/dist/core/SoulExtractor.d.ts +34 -0
- package/dist/core/SoulExtractor.d.ts.map +1 -0
- package/dist/core/SoulExtractor.js +100 -0
- package/dist/core/SoulExtractor.js.map +1 -0
- package/dist/core/SpecFirstPipeline.d.ts +77 -0
- package/dist/core/SpecFirstPipeline.d.ts.map +1 -0
- package/dist/core/SpecFirstPipeline.js +95 -0
- package/dist/core/SpecFirstPipeline.js.map +1 -0
- package/dist/core/SpeculativeExecutionController.d.ts +64 -0
- package/dist/core/SpeculativeExecutionController.d.ts.map +1 -0
- package/dist/core/SpeculativeExecutionController.js +263 -0
- package/dist/core/SpeculativeExecutionController.js.map +1 -0
- package/dist/core/SpeculativeOrchestrationPlanner.d.ts +40 -0
- package/dist/core/SpeculativeOrchestrationPlanner.d.ts.map +1 -0
- package/dist/core/SpeculativeOrchestrationPlanner.js +186 -0
- package/dist/core/SpeculativeOrchestrationPlanner.js.map +1 -0
- package/dist/core/StateSemantics.d.ts +238 -0
- package/dist/core/StateSemantics.d.ts.map +1 -0
- package/dist/core/StateSemantics.js +729 -0
- package/dist/core/StateSemantics.js.map +1 -0
- package/dist/core/SystemBrowserOpener.d.ts +25 -0
- package/dist/core/SystemBrowserOpener.d.ts.map +1 -0
- package/dist/core/SystemBrowserOpener.js +154 -0
- package/dist/core/SystemBrowserOpener.js.map +1 -0
- package/dist/core/SystemMessageSlot.d.ts +48 -0
- package/dist/core/SystemMessageSlot.d.ts.map +1 -0
- package/dist/core/SystemMessageSlot.js +130 -0
- package/dist/core/SystemMessageSlot.js.map +1 -0
- package/dist/core/TaintFlowEngine.d.ts +37 -0
- package/dist/core/TaintFlowEngine.d.ts.map +1 -0
- package/dist/core/TaintFlowEngine.js +200 -0
- package/dist/core/TaintFlowEngine.js.map +1 -0
- package/dist/core/TaskBoard.d.ts +243 -0
- package/dist/core/TaskBoard.d.ts.map +1 -0
- package/dist/core/TaskBoard.js +955 -0
- package/dist/core/TaskBoard.js.map +1 -0
- package/dist/core/TaskContextEnricher.d.ts +37 -0
- package/dist/core/TaskContextEnricher.d.ts.map +1 -0
- package/dist/core/TaskContextEnricher.js +147 -0
- package/dist/core/TaskContextEnricher.js.map +1 -0
- package/dist/core/TaskDisplayState.d.ts +21 -0
- package/dist/core/TaskDisplayState.d.ts.map +1 -0
- package/dist/core/TaskDisplayState.js +29 -0
- package/dist/core/TaskDisplayState.js.map +1 -0
- package/dist/core/TaskPriorityEngine.d.ts +31 -0
- package/dist/core/TaskPriorityEngine.d.ts.map +1 -0
- package/dist/core/TaskPriorityEngine.js +122 -0
- package/dist/core/TaskPriorityEngine.js.map +1 -0
- package/dist/core/TeamCommunicationGuard.d.ts +83 -0
- package/dist/core/TeamCommunicationGuard.d.ts.map +1 -0
- package/dist/core/TeamCommunicationGuard.js +221 -0
- package/dist/core/TeamCommunicationGuard.js.map +1 -0
- package/dist/core/TeamCommunicationService.d.ts +55 -0
- package/dist/core/TeamCommunicationService.d.ts.map +1 -0
- package/dist/core/TeamCommunicationService.js +178 -0
- package/dist/core/TeamCommunicationService.js.map +1 -0
- package/dist/core/TeamMailbox.d.ts +203 -0
- package/dist/core/TeamMailbox.d.ts.map +1 -0
- package/dist/core/TeamMailbox.js +729 -0
- package/dist/core/TeamMailbox.js.map +1 -0
- package/dist/core/TeamProtocol.d.ts +70 -0
- package/dist/core/TeamProtocol.d.ts.map +1 -0
- package/dist/core/TeamProtocol.js +75 -0
- package/dist/core/TeamProtocol.js.map +1 -0
- package/dist/core/TeamRequestTracker.d.ts +59 -0
- package/dist/core/TeamRequestTracker.d.ts.map +1 -0
- package/dist/core/TeamRequestTracker.js +212 -0
- package/dist/core/TeamRequestTracker.js.map +1 -0
- package/dist/core/TeamView.d.ts +34 -0
- package/dist/core/TeamView.d.ts.map +1 -0
- package/dist/core/TeamView.js +109 -0
- package/dist/core/TeamView.js.map +1 -0
- package/dist/core/TempDownloadRegistry.d.ts +44 -0
- package/dist/core/TempDownloadRegistry.d.ts.map +1 -0
- package/dist/core/TempDownloadRegistry.js +150 -0
- package/dist/core/TempDownloadRegistry.js.map +1 -0
- package/dist/core/TestRunnerAdapter.d.ts +31 -0
- package/dist/core/TestRunnerAdapter.d.ts.map +1 -0
- package/dist/core/TestRunnerAdapter.js +203 -0
- package/dist/core/TestRunnerAdapter.js.map +1 -0
- package/dist/core/ThinkContent.d.ts +19 -0
- package/dist/core/ThinkContent.d.ts.map +1 -0
- package/dist/core/ThinkContent.js +99 -0
- package/dist/core/ThinkContent.js.map +1 -0
- package/dist/core/TiktokenCache.d.ts +32 -0
- package/dist/core/TiktokenCache.d.ts.map +1 -0
- package/dist/core/TiktokenCache.js +188 -0
- package/dist/core/TiktokenCache.js.map +1 -0
- package/dist/core/TokenTracker.d.ts +64 -0
- package/dist/core/TokenTracker.d.ts.map +1 -0
- package/dist/core/TokenTracker.js +146 -0
- package/dist/core/TokenTracker.js.map +1 -0
- package/dist/core/ToolPruner.d.ts +73 -0
- package/dist/core/ToolPruner.d.ts.map +1 -0
- package/dist/core/ToolPruner.js +297 -0
- package/dist/core/ToolPruner.js.map +1 -0
- package/dist/core/Tracing.d.ts +74 -0
- package/dist/core/Tracing.d.ts.map +1 -0
- package/dist/core/Tracing.js +171 -0
- package/dist/core/Tracing.js.map +1 -0
- package/dist/core/TurnCoordinator.d.ts +12 -0
- package/dist/core/TurnCoordinator.d.ts.map +1 -0
- package/dist/core/TurnCoordinator.js +112 -0
- package/dist/core/TurnCoordinator.js.map +1 -0
- package/dist/core/UpdateChecker.d.ts +32 -0
- package/dist/core/UpdateChecker.d.ts.map +1 -0
- package/dist/core/UpdateChecker.js +129 -0
- package/dist/core/UpdateChecker.js.map +1 -0
- package/dist/core/UserAgent.d.ts +5 -0
- package/dist/core/UserAgent.d.ts.map +1 -0
- package/dist/core/UserAgent.js +34 -0
- package/dist/core/UserAgent.js.map +1 -0
- package/dist/core/VerificationPipeline.d.ts +47 -0
- package/dist/core/VerificationPipeline.d.ts.map +1 -0
- package/dist/core/VerificationPipeline.js +144 -0
- package/dist/core/VerificationPipeline.js.map +1 -0
- package/dist/core/WorkNoteManager.d.ts +94 -0
- package/dist/core/WorkNoteManager.d.ts.map +1 -0
- package/dist/core/WorkNoteManager.js +273 -0
- package/dist/core/WorkNoteManager.js.map +1 -0
- package/dist/core/WorkerProcessRunner.d.ts +330 -0
- package/dist/core/WorkerProcessRunner.d.ts.map +1 -0
- package/dist/core/WorkerProcessRunner.js +903 -0
- package/dist/core/WorkerProcessRunner.js.map +1 -0
- package/dist/core/Workspace.d.ts +85 -0
- package/dist/core/Workspace.d.ts.map +1 -0
- package/dist/core/Workspace.js +151 -0
- package/dist/core/Workspace.js.map +1 -0
- package/dist/core/WorktreeManager.d.ts +63 -0
- package/dist/core/WorktreeManager.d.ts.map +1 -0
- package/dist/core/WorktreeManager.js +147 -0
- package/dist/core/WorktreeManager.js.map +1 -0
- package/dist/core/WorktreeService.d.ts +104 -0
- package/dist/core/WorktreeService.d.ts.map +1 -0
- package/dist/core/WorktreeService.js +335 -0
- package/dist/core/WorktreeService.js.map +1 -0
- package/dist/core/blackboard/BlackboardGraph.d.ts +146 -0
- package/dist/core/blackboard/BlackboardGraph.d.ts.map +1 -0
- package/dist/core/blackboard/BlackboardGraph.js +793 -0
- package/dist/core/blackboard/BlackboardGraph.js.map +1 -0
- package/dist/core/blackboard/CompletionChecker.d.ts +39 -0
- package/dist/core/blackboard/CompletionChecker.d.ts.map +1 -0
- package/dist/core/blackboard/CompletionChecker.js +179 -0
- package/dist/core/blackboard/CompletionChecker.js.map +1 -0
- package/dist/core/blackboard/ContractFormatParser.d.ts +67 -0
- package/dist/core/blackboard/ContractFormatParser.d.ts.map +1 -0
- package/dist/core/blackboard/ContractFormatParser.js +212 -0
- package/dist/core/blackboard/ContractFormatParser.js.map +1 -0
- package/dist/core/blackboard/DispatcherEngine.d.ts +33 -0
- package/dist/core/blackboard/DispatcherEngine.d.ts.map +1 -0
- package/dist/core/blackboard/DispatcherEngine.js +135 -0
- package/dist/core/blackboard/DispatcherEngine.js.map +1 -0
- package/dist/core/blackboard/GraphBridge.d.ts +52 -0
- package/dist/core/blackboard/GraphBridge.d.ts.map +1 -0
- package/dist/core/blackboard/GraphBridge.js +166 -0
- package/dist/core/blackboard/GraphBridge.js.map +1 -0
- package/dist/core/blackboard/GraphStore.d.ts +46 -0
- package/dist/core/blackboard/GraphStore.d.ts.map +1 -0
- package/dist/core/blackboard/GraphStore.js +237 -0
- package/dist/core/blackboard/GraphStore.js.map +1 -0
- package/dist/core/blackboard/WorkerOutputParser.d.ts +25 -0
- package/dist/core/blackboard/WorkerOutputParser.d.ts.map +1 -0
- package/dist/core/blackboard/WorkerOutputParser.js +191 -0
- package/dist/core/blackboard/WorkerOutputParser.js.map +1 -0
- package/dist/core/blackboard/schemas.d.ts +137 -0
- package/dist/core/blackboard/schemas.d.ts.map +1 -0
- package/dist/core/blackboard/schemas.js +102 -0
- package/dist/core/blackboard/schemas.js.map +1 -0
- package/dist/core/blackboard/types.d.ts +115 -0
- package/dist/core/blackboard/types.d.ts.map +1 -0
- package/dist/core/blackboard/types.js +31 -0
- package/dist/core/blackboard/types.js.map +1 -0
- package/dist/core/canvas/CanvasStore.d.ts +64 -0
- package/dist/core/canvas/CanvasStore.d.ts.map +1 -0
- package/dist/core/canvas/CanvasStore.js +193 -0
- package/dist/core/canvas/CanvasStore.js.map +1 -0
- package/dist/core/checkpoint/CheckpointBoundary.d.ts +36 -0
- package/dist/core/checkpoint/CheckpointBoundary.d.ts.map +1 -0
- package/dist/core/checkpoint/CheckpointBoundary.js +147 -0
- package/dist/core/checkpoint/CheckpointBoundary.js.map +1 -0
- package/dist/core/checkpoint/CheckpointPrompt.d.ts +15 -0
- package/dist/core/checkpoint/CheckpointPrompt.d.ts.map +1 -0
- package/dist/core/checkpoint/CheckpointPrompt.js +76 -0
- package/dist/core/checkpoint/CheckpointPrompt.js.map +1 -0
- package/dist/core/checkpoint/CheckpointService.d.ts +55 -0
- package/dist/core/checkpoint/CheckpointService.d.ts.map +1 -0
- package/dist/core/checkpoint/CheckpointService.js +168 -0
- package/dist/core/checkpoint/CheckpointService.js.map +1 -0
- package/dist/core/checkpoint/CheckpointWriter.d.ts +38 -0
- package/dist/core/checkpoint/CheckpointWriter.d.ts.map +1 -0
- package/dist/core/checkpoint/CheckpointWriter.js +193 -0
- package/dist/core/checkpoint/CheckpointWriter.js.map +1 -0
- package/dist/core/checkpoint/ContextRebuild.d.ts +52 -0
- package/dist/core/checkpoint/ContextRebuild.d.ts.map +1 -0
- package/dist/core/checkpoint/ContextRebuild.js +213 -0
- package/dist/core/checkpoint/ContextRebuild.js.map +1 -0
- package/dist/core/checkpoint/MicroCompact.d.ts +32 -0
- package/dist/core/checkpoint/MicroCompact.d.ts.map +1 -0
- package/dist/core/checkpoint/MicroCompact.js +109 -0
- package/dist/core/checkpoint/MicroCompact.js.map +1 -0
- package/dist/core/checkpoint/index.d.ts +11 -0
- package/dist/core/checkpoint/index.d.ts.map +1 -0
- package/dist/core/checkpoint/index.js +11 -0
- package/dist/core/checkpoint/index.js.map +1 -0
- package/dist/core/checkpoint/types.d.ts +47 -0
- package/dist/core/checkpoint/types.d.ts.map +1 -0
- package/dist/core/checkpoint/types.js +24 -0
- package/dist/core/checkpoint/types.js.map +1 -0
- package/dist/core/compress/BlackboardCompressor.d.ts +54 -0
- package/dist/core/compress/BlackboardCompressor.d.ts.map +1 -0
- package/dist/core/compress/BlackboardCompressor.js +342 -0
- package/dist/core/compress/BlackboardCompressor.js.map +1 -0
- package/dist/core/compress/CompressionPipeline.d.ts +93 -0
- package/dist/core/compress/CompressionPipeline.d.ts.map +1 -0
- package/dist/core/compress/CompressionPipeline.js +1143 -0
- package/dist/core/compress/CompressionPipeline.js.map +1 -0
- package/dist/core/compress/CompressionTypes.d.ts +103 -0
- package/dist/core/compress/CompressionTypes.d.ts.map +1 -0
- package/dist/core/compress/CompressionTypes.js +5 -0
- package/dist/core/compress/CompressionTypes.js.map +1 -0
- package/dist/core/compress/ContextDAG.d.ts +149 -0
- package/dist/core/compress/ContextDAG.d.ts.map +1 -0
- package/dist/core/compress/ContextDAG.js +323 -0
- package/dist/core/compress/ContextDAG.js.map +1 -0
- package/dist/core/compress/ContextTokenCalculator.d.ts +46 -0
- package/dist/core/compress/ContextTokenCalculator.d.ts.map +1 -0
- package/dist/core/compress/ContextTokenCalculator.js +216 -0
- package/dist/core/compress/ContextTokenCalculator.js.map +1 -0
- package/dist/core/compress/MessageByteTruncator.d.ts +65 -0
- package/dist/core/compress/MessageByteTruncator.d.ts.map +1 -0
- package/dist/core/compress/MessageByteTruncator.js +178 -0
- package/dist/core/compress/MessageByteTruncator.js.map +1 -0
- package/dist/core/constants.d.ts +67 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +67 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/errors.d.ts +9 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +20 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/git/GitEnv.d.ts +10 -0
- package/dist/core/git/GitEnv.d.ts.map +1 -0
- package/dist/core/git/GitEnv.js +47 -0
- package/dist/core/git/GitEnv.js.map +1 -0
- package/dist/core/git/GitPlatformApi.d.ts +90 -0
- package/dist/core/git/GitPlatformApi.d.ts.map +1 -0
- package/dist/core/git/GitPlatformApi.js +552 -0
- package/dist/core/git/GitPlatformApi.js.map +1 -0
- package/dist/core/git/RealGitService.d.ts +184 -0
- package/dist/core/git/RealGitService.d.ts.map +1 -0
- package/dist/core/git/RealGitService.js +430 -0
- package/dist/core/git/RealGitService.js.map +1 -0
- package/dist/core/hooks/executor.d.ts +51 -0
- package/dist/core/hooks/executor.d.ts.map +1 -0
- package/dist/core/hooks/executor.js +317 -0
- package/dist/core/hooks/executor.js.map +1 -0
- package/dist/core/hooks/index.d.ts +9 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +12 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/registry.d.ts +71 -0
- package/dist/core/hooks/registry.d.ts.map +1 -0
- package/dist/core/hooks/registry.js +231 -0
- package/dist/core/hooks/registry.js.map +1 -0
- package/dist/core/hooks/session_hooks.d.ts +54 -0
- package/dist/core/hooks/session_hooks.d.ts.map +1 -0
- package/dist/core/hooks/session_hooks.js +104 -0
- package/dist/core/hooks/session_hooks.js.map +1 -0
- package/dist/core/hooks/types.d.ts +136 -0
- package/dist/core/hooks/types.d.ts.map +1 -0
- package/dist/core/hooks/types.js +49 -0
- package/dist/core/hooks/types.js.map +1 -0
- package/dist/core/index.d.ts +23 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/ipc/IPCDrainQueue.d.ts +58 -0
- package/dist/core/ipc/IPCDrainQueue.d.ts.map +1 -0
- package/dist/core/ipc/IPCDrainQueue.js +166 -0
- package/dist/core/ipc/IPCDrainQueue.js.map +1 -0
- package/dist/core/mcp-share/McpBundle.d.ts +43 -0
- package/dist/core/mcp-share/McpBundle.d.ts.map +1 -0
- package/dist/core/mcp-share/McpBundle.js +100 -0
- package/dist/core/mcp-share/McpBundle.js.map +1 -0
- package/dist/core/mcp-share/McpShare.d.ts +110 -0
- package/dist/core/mcp-share/McpShare.d.ts.map +1 -0
- package/dist/core/mcp-share/McpShare.js +311 -0
- package/dist/core/mcp-share/McpShare.js.map +1 -0
- package/dist/core/plugins/PluginManifest.d.ts +128 -0
- package/dist/core/plugins/PluginManifest.d.ts.map +1 -0
- package/dist/core/plugins/PluginManifest.js +166 -0
- package/dist/core/plugins/PluginManifest.js.map +1 -0
- package/dist/core/plugins/PluginStore.d.ts +76 -0
- package/dist/core/plugins/PluginStore.d.ts.map +1 -0
- package/dist/core/plugins/PluginStore.js +511 -0
- package/dist/core/plugins/PluginStore.js.map +1 -0
- package/dist/core/session/SessionCleanup.d.ts +15 -0
- package/dist/core/session/SessionCleanup.d.ts.map +1 -0
- package/dist/core/session/SessionCleanup.js +24 -0
- package/dist/core/session/SessionCleanup.js.map +1 -0
- package/dist/core/session/SessionFactory.d.ts +14 -0
- package/dist/core/session/SessionFactory.d.ts.map +1 -0
- package/dist/core/session/SessionFactory.js +15 -0
- package/dist/core/session/SessionFactory.js.map +1 -0
- package/dist/core/session/SessionFork.d.ts +31 -0
- package/dist/core/session/SessionFork.d.ts.map +1 -0
- package/dist/core/session/SessionFork.js +78 -0
- package/dist/core/session/SessionFork.js.map +1 -0
- package/dist/core/session/SessionInitialization.d.ts +23 -0
- package/dist/core/session/SessionInitialization.d.ts.map +1 -0
- package/dist/core/session/SessionInitialization.js +55 -0
- package/dist/core/session/SessionInitialization.js.map +1 -0
- package/dist/core/session/SessionStateSync.d.ts +14 -0
- package/dist/core/session/SessionStateSync.d.ts.map +1 -0
- package/dist/core/session/SessionStateSync.js +23 -0
- package/dist/core/session/SessionStateSync.js.map +1 -0
- package/dist/core/session/TurnCoordinator.d.ts +3 -0
- package/dist/core/session/TurnCoordinator.d.ts.map +1 -0
- package/dist/core/session/TurnCoordinator.js +2 -0
- package/dist/core/session/TurnCoordinator.js.map +1 -0
- package/dist/core/terminalRestore.d.ts +36 -0
- package/dist/core/terminalRestore.d.ts.map +1 -0
- package/dist/core/terminalRestore.js +52 -0
- package/dist/core/terminalRestore.js.map +1 -0
- package/dist/core/transport/LocalTransport.d.ts +11 -0
- package/dist/core/transport/LocalTransport.d.ts.map +1 -0
- package/dist/core/transport/LocalTransport.js +20 -0
- package/dist/core/transport/LocalTransport.js.map +1 -0
- package/dist/core/transport/RemoteWorkerRegistry.d.ts +25 -0
- package/dist/core/transport/RemoteWorkerRegistry.d.ts.map +1 -0
- package/dist/core/transport/RemoteWorkerRegistry.js +77 -0
- package/dist/core/transport/RemoteWorkerRegistry.js.map +1 -0
- package/dist/core/transport/Transport.d.ts +18 -0
- package/dist/core/transport/Transport.d.ts.map +1 -0
- package/dist/core/transport/Transport.js +17 -0
- package/dist/core/transport/Transport.js.map +1 -0
- package/dist/core/transport/WebSocketTransport.d.ts +41 -0
- package/dist/core/transport/WebSocketTransport.d.ts.map +1 -0
- package/dist/core/transport/WebSocketTransport.js +124 -0
- package/dist/core/transport/WebSocketTransport.js.map +1 -0
- package/dist/core/verify/BughuntVerificationRunner.d.ts +45 -0
- package/dist/core/verify/BughuntVerificationRunner.d.ts.map +1 -0
- package/dist/core/verify/BughuntVerificationRunner.js +109 -0
- package/dist/core/verify/BughuntVerificationRunner.js.map +1 -0
- package/dist/core/verify/TargetServiceManager.d.ts +24 -0
- package/dist/core/verify/TargetServiceManager.d.ts.map +1 -0
- package/dist/core/verify/TargetServiceManager.js +115 -0
- package/dist/core/verify/TargetServiceManager.js.map +1 -0
- package/dist/core/workflow/ExecutionGraph.d.ts +83 -0
- package/dist/core/workflow/ExecutionGraph.d.ts.map +1 -0
- package/dist/core/workflow/ExecutionGraph.js +275 -0
- package/dist/core/workflow/ExecutionGraph.js.map +1 -0
- package/dist/core/workflow/ScheduleTriggerSync.d.ts +22 -0
- package/dist/core/workflow/ScheduleTriggerSync.d.ts.map +1 -0
- package/dist/core/workflow/ScheduleTriggerSync.js +141 -0
- package/dist/core/workflow/ScheduleTriggerSync.js.map +1 -0
- package/dist/core/workflow/VariableResolver.d.ts +83 -0
- package/dist/core/workflow/VariableResolver.d.ts.map +1 -0
- package/dist/core/workflow/VariableResolver.js +277 -0
- package/dist/core/workflow/VariableResolver.js.map +1 -0
- package/dist/core/workflow/WorkflowAnalyzer.d.ts +40 -0
- package/dist/core/workflow/WorkflowAnalyzer.d.ts.map +1 -0
- package/dist/core/workflow/WorkflowAnalyzer.js +381 -0
- package/dist/core/workflow/WorkflowAnalyzer.js.map +1 -0
- package/dist/core/workflow/WorkflowEngine.d.ts +158 -0
- package/dist/core/workflow/WorkflowEngine.d.ts.map +1 -0
- package/dist/core/workflow/WorkflowEngine.js +1249 -0
- package/dist/core/workflow/WorkflowEngine.js.map +1 -0
- package/dist/core/workflow/WorkflowManager.d.ts +129 -0
- package/dist/core/workflow/WorkflowManager.d.ts.map +1 -0
- package/dist/core/workflow/WorkflowManager.js +525 -0
- package/dist/core/workflow/WorkflowManager.js.map +1 -0
- package/dist/core/workflow/executors/AgentNodeExecutor.d.ts +21 -0
- package/dist/core/workflow/executors/AgentNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/AgentNodeExecutor.js +44 -0
- package/dist/core/workflow/executors/AgentNodeExecutor.js.map +1 -0
- package/dist/core/workflow/executors/BaseNodeExecutor.d.ts +24 -0
- package/dist/core/workflow/executors/BaseNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/BaseNodeExecutor.js +30 -0
- package/dist/core/workflow/executors/BaseNodeExecutor.js.map +1 -0
- package/dist/core/workflow/executors/ConditionNodeExecutor.d.ts +25 -0
- package/dist/core/workflow/executors/ConditionNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/ConditionNodeExecutor.js +118 -0
- package/dist/core/workflow/executors/ConditionNodeExecutor.js.map +1 -0
- package/dist/core/workflow/executors/DataNodeExecutor.d.ts +26 -0
- package/dist/core/workflow/executors/DataNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/DataNodeExecutor.js +315 -0
- package/dist/core/workflow/executors/DataNodeExecutor.js.map +1 -0
- package/dist/core/workflow/executors/ParallelNodeExecutor.d.ts +17 -0
- package/dist/core/workflow/executors/ParallelNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/ParallelNodeExecutor.js +58 -0
- package/dist/core/workflow/executors/ParallelNodeExecutor.js.map +1 -0
- package/dist/core/workflow/executors/ToolNodeExecutor.d.ts +16 -0
- package/dist/core/workflow/executors/ToolNodeExecutor.d.ts.map +1 -0
- package/dist/core/workflow/executors/ToolNodeExecutor.js +83 -0
- package/dist/core/workflow/executors/ToolNodeExecutor.js.map +1 -0
- package/dist/core/workflow/expressionEvaluator.d.ts +27 -0
- package/dist/core/workflow/expressionEvaluator.d.ts.map +1 -0
- package/dist/core/workflow/expressionEvaluator.js +35 -0
- package/dist/core/workflow/expressionEvaluator.js.map +1 -0
- package/dist/core/workflow/safeExpressionEvaluator.d.ts +28 -0
- package/dist/core/workflow/safeExpressionEvaluator.d.ts.map +1 -0
- package/dist/core/workflow/safeExpressionEvaluator.js +298 -0
- package/dist/core/workflow/safeExpressionEvaluator.js.map +1 -0
- package/dist/core/workflow/types.d.ts +258 -0
- package/dist/core/workflow/types.d.ts.map +1 -0
- package/dist/core/workflow/types.js +7 -0
- package/dist/core/workflow/types.js.map +1 -0
- package/dist/core/workflow/variableScope.d.ts +20 -0
- package/dist/core/workflow/variableScope.d.ts.map +1 -0
- package/dist/core/workflow/variableScope.js +42 -0
- package/dist/core/workflow/variableScope.js.map +1 -0
- package/dist/facade/AgentLoop.d.ts +91 -0
- package/dist/facade/AgentLoop.d.ts.map +1 -0
- package/dist/facade/AgentLoop.js +140 -0
- package/dist/facade/AgentLoop.js.map +1 -0
- package/dist/i18n.d.ts +871 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/i18n.js +1912 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/AnthropicContentGenerator.d.ts +66 -0
- package/dist/llm/AnthropicContentGenerator.d.ts.map +1 -0
- package/dist/llm/AnthropicContentGenerator.js +973 -0
- package/dist/llm/AnthropicContentGenerator.js.map +1 -0
- package/dist/llm/AnthropicToolSchema.d.ts +4 -0
- package/dist/llm/AnthropicToolSchema.d.ts.map +1 -0
- package/dist/llm/AnthropicToolSchema.js +179 -0
- package/dist/llm/AnthropicToolSchema.js.map +1 -0
- package/dist/llm/CircuitBreaker.d.ts +77 -0
- package/dist/llm/CircuitBreaker.d.ts.map +1 -0
- package/dist/llm/CircuitBreaker.js +185 -0
- package/dist/llm/CircuitBreaker.js.map +1 -0
- package/dist/llm/Client.d.ts +59 -0
- package/dist/llm/Client.d.ts.map +1 -0
- package/dist/llm/Client.js +174 -0
- package/dist/llm/Client.js.map +1 -0
- package/dist/llm/ContentGenerationPipeline.d.ts +104 -0
- package/dist/llm/ContentGenerationPipeline.d.ts.map +1 -0
- package/dist/llm/ContentGenerationPipeline.js +85 -0
- package/dist/llm/ContentGenerationPipeline.js.map +1 -0
- package/dist/llm/ContentGenerator.d.ts +137 -0
- package/dist/llm/ContentGenerator.d.ts.map +1 -0
- package/dist/llm/ContentGenerator.js +49 -0
- package/dist/llm/ContentGenerator.js.map +1 -0
- package/dist/llm/CostService.d.ts +121 -0
- package/dist/llm/CostService.d.ts.map +1 -0
- package/dist/llm/CostService.js +287 -0
- package/dist/llm/CostService.js.map +1 -0
- package/dist/llm/LoggingContentGenerator.d.ts +25 -0
- package/dist/llm/LoggingContentGenerator.d.ts.map +1 -0
- package/dist/llm/LoggingContentGenerator.js +82 -0
- package/dist/llm/LoggingContentGenerator.js.map +1 -0
- package/dist/llm/ModelGateway.d.ts +88 -0
- package/dist/llm/ModelGateway.d.ts.map +1 -0
- package/dist/llm/ModelGateway.js +261 -0
- package/dist/llm/ModelGateway.js.map +1 -0
- package/dist/llm/ModelsDevRegistry.d.ts +159 -0
- package/dist/llm/ModelsDevRegistry.d.ts.map +1 -0
- package/dist/llm/ModelsDevRegistry.js +301 -0
- package/dist/llm/ModelsDevRegistry.js.map +1 -0
- package/dist/llm/OpenAIContentGenerator.d.ts +57 -0
- package/dist/llm/OpenAIContentGenerator.d.ts.map +1 -0
- package/dist/llm/OpenAIContentGenerator.js +644 -0
- package/dist/llm/OpenAIContentGenerator.js.map +1 -0
- package/dist/llm/RetryEngine.d.ts +89 -0
- package/dist/llm/RetryEngine.d.ts.map +1 -0
- package/dist/llm/RetryEngine.js +121 -0
- package/dist/llm/RetryEngine.js.map +1 -0
- package/dist/llm/StreamingToolCallParser.d.ts +113 -0
- package/dist/llm/StreamingToolCallParser.d.ts.map +1 -0
- package/dist/llm/StreamingToolCallParser.js +294 -0
- package/dist/llm/StreamingToolCallParser.js.map +1 -0
- package/dist/llm/VercelAIContentGenerator.d.ts +71 -0
- package/dist/llm/VercelAIContentGenerator.d.ts.map +1 -0
- package/dist/llm/VercelAIContentGenerator.js +471 -0
- package/dist/llm/VercelAIContentGenerator.js.map +1 -0
- package/dist/llm/errors.d.ts +44 -0
- package/dist/llm/errors.d.ts.map +1 -0
- package/dist/llm/errors.js +713 -0
- package/dist/llm/errors.js.map +1 -0
- package/dist/llm/http_dispatcher.d.ts +51 -0
- package/dist/llm/http_dispatcher.d.ts.map +1 -0
- package/dist/llm/http_dispatcher.js +151 -0
- package/dist/llm/http_dispatcher.js.map +1 -0
- package/dist/llm/image_blob_store.d.ts +8 -0
- package/dist/llm/image_blob_store.d.ts.map +1 -0
- package/dist/llm/image_blob_store.js +135 -0
- package/dist/llm/image_blob_store.js.map +1 -0
- package/dist/llm/local_vision_fallback.d.ts +37 -0
- package/dist/llm/local_vision_fallback.d.ts.map +1 -0
- package/dist/llm/local_vision_fallback.js +296 -0
- package/dist/llm/local_vision_fallback.js.map +1 -0
- package/dist/llm/message_sanitizer.d.ts +109 -0
- package/dist/llm/message_sanitizer.d.ts.map +1 -0
- package/dist/llm/message_sanitizer.js +536 -0
- package/dist/llm/message_sanitizer.js.map +1 -0
- package/dist/llm/model_capabilities.d.ts +131 -0
- package/dist/llm/model_capabilities.d.ts.map +1 -0
- package/dist/llm/model_capabilities.js +484 -0
- package/dist/llm/model_capabilities.js.map +1 -0
- package/dist/llm/model_capability_config.d.ts +19 -0
- package/dist/llm/model_capability_config.d.ts.map +1 -0
- package/dist/llm/model_capability_config.js +16 -0
- package/dist/llm/model_capability_config.js.map +1 -0
- package/dist/llm/promptCacheKey.d.ts +27 -0
- package/dist/llm/promptCacheKey.d.ts.map +1 -0
- package/dist/llm/promptCacheKey.js +53 -0
- package/dist/llm/promptCacheKey.js.map +1 -0
- package/dist/llm/provider_runtime.d.ts +64 -0
- package/dist/llm/provider_runtime.d.ts.map +1 -0
- package/dist/llm/provider_runtime.js +181 -0
- package/dist/llm/provider_runtime.js.map +1 -0
- package/dist/llm/providers/anthropic.d.ts +7 -0
- package/dist/llm/providers/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/anthropic.js +12 -0
- package/dist/llm/providers/anthropic.js.map +1 -0
- package/dist/llm/providers/bedrock.d.ts +7 -0
- package/dist/llm/providers/bedrock.d.ts.map +1 -0
- package/dist/llm/providers/bedrock.js +14 -0
- package/dist/llm/providers/bedrock.js.map +1 -0
- package/dist/llm/providers/custom.d.ts +10 -0
- package/dist/llm/providers/custom.d.ts.map +1 -0
- package/dist/llm/providers/custom.js +16 -0
- package/dist/llm/providers/custom.js.map +1 -0
- package/dist/llm/providers/google.d.ts +7 -0
- package/dist/llm/providers/google.d.ts.map +1 -0
- package/dist/llm/providers/google.js +12 -0
- package/dist/llm/providers/google.js.map +1 -0
- package/dist/llm/providers/index.d.ts +31 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +36 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/openai.d.ts +7 -0
- package/dist/llm/providers/openai.d.ts.map +1 -0
- package/dist/llm/providers/openai.js +12 -0
- package/dist/llm/providers/openai.js.map +1 -0
- package/dist/llm/reasoningSampling.d.ts +55 -0
- package/dist/llm/reasoningSampling.d.ts.map +1 -0
- package/dist/llm/reasoningSampling.js +72 -0
- package/dist/llm/reasoningSampling.js.map +1 -0
- package/dist/llm/tesseractResolver.d.ts +41 -0
- package/dist/llm/tesseractResolver.d.ts.map +1 -0
- package/dist/llm/tesseractResolver.js +103 -0
- package/dist/llm/tesseractResolver.js.map +1 -0
- package/dist/llm/tokenLimits.d.ts +32 -0
- package/dist/llm/tokenLimits.d.ts.map +1 -0
- package/dist/llm/tokenLimits.js +91 -0
- package/dist/llm/tokenLimits.js.map +1 -0
- package/dist/llm/token_counter.d.ts +82 -0
- package/dist/llm/token_counter.d.ts.map +1 -0
- package/dist/llm/token_counter.js +184 -0
- package/dist/llm/token_counter.js.map +1 -0
- package/dist/llm/types.d.ts +192 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +10 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/llm/usageExtractor.d.ts +36 -0
- package/dist/llm/usageExtractor.d.ts.map +1 -0
- package/dist/llm/usageExtractor.js +156 -0
- package/dist/llm/usageExtractor.js.map +1 -0
- package/dist/mcp-servers/browser-server.d.ts +12 -0
- package/dist/mcp-servers/browser-server.d.ts.map +1 -0
- package/dist/mcp-servers/browser-server.js +264 -0
- package/dist/mcp-servers/browser-server.js.map +1 -0
- package/dist/mcp-servers/code-intelligence-server.d.ts +8 -0
- package/dist/mcp-servers/code-intelligence-server.d.ts.map +1 -0
- package/dist/mcp-servers/code-intelligence-server.js +218 -0
- package/dist/mcp-servers/code-intelligence-server.js.map +1 -0
- package/dist/mcp-servers/memory-server.d.ts +9 -0
- package/dist/mcp-servers/memory-server.d.ts.map +1 -0
- package/dist/mcp-servers/memory-server.js +142 -0
- package/dist/mcp-servers/memory-server.js.map +1 -0
- package/dist/mcp-servers/session-server.d.ts +8 -0
- package/dist/mcp-servers/session-server.d.ts.map +1 -0
- package/dist/mcp-servers/session-server.js +113 -0
- package/dist/mcp-servers/session-server.js.map +1 -0
- package/dist/mcp-servers/shared.d.ts +41 -0
- package/dist/mcp-servers/shared.d.ts.map +1 -0
- package/dist/mcp-servers/shared.js +34 -0
- package/dist/mcp-servers/shared.js.map +1 -0
- package/dist/memory/AssetUsageStore.d.ts +63 -0
- package/dist/memory/AssetUsageStore.d.ts.map +1 -0
- package/dist/memory/AssetUsageStore.js +117 -0
- package/dist/memory/AssetUsageStore.js.map +1 -0
- package/dist/memory/AutoDreamTrigger.d.ts +37 -0
- package/dist/memory/AutoDreamTrigger.d.ts.map +1 -0
- package/dist/memory/AutoDreamTrigger.js +79 -0
- package/dist/memory/AutoDreamTrigger.js.map +1 -0
- package/dist/memory/DistillCommand.d.ts +89 -0
- package/dist/memory/DistillCommand.d.ts.map +1 -0
- package/dist/memory/DistillCommand.js +418 -0
- package/dist/memory/DistillCommand.js.map +1 -0
- package/dist/memory/DreamCommand.d.ts +54 -0
- package/dist/memory/DreamCommand.d.ts.map +1 -0
- package/dist/memory/DreamCommand.js +289 -0
- package/dist/memory/DreamCommand.js.map +1 -0
- package/dist/memory/MemoryDeduplicator.d.ts +38 -0
- package/dist/memory/MemoryDeduplicator.d.ts.map +1 -0
- package/dist/memory/MemoryDeduplicator.js +125 -0
- package/dist/memory/MemoryDeduplicator.js.map +1 -0
- package/dist/memory/MemoryEmbedding.d.ts +25 -0
- package/dist/memory/MemoryEmbedding.d.ts.map +1 -0
- package/dist/memory/MemoryEmbedding.js +104 -0
- package/dist/memory/MemoryEmbedding.js.map +1 -0
- package/dist/memory/MemoryFTS.d.ts +55 -0
- package/dist/memory/MemoryFTS.d.ts.map +1 -0
- package/dist/memory/MemoryFTS.js +333 -0
- package/dist/memory/MemoryFTS.js.map +1 -0
- package/dist/memory/MemoryGC.d.ts +40 -0
- package/dist/memory/MemoryGC.d.ts.map +1 -0
- package/dist/memory/MemoryGC.js +146 -0
- package/dist/memory/MemoryGC.js.map +1 -0
- package/dist/memory/MemoryMaintenance.d.ts +31 -0
- package/dist/memory/MemoryMaintenance.d.ts.map +1 -0
- package/dist/memory/MemoryMaintenance.js +111 -0
- package/dist/memory/MemoryMaintenance.js.map +1 -0
- package/dist/memory/MemoryMaintenanceEvents.d.ts +24 -0
- package/dist/memory/MemoryMaintenanceEvents.d.ts.map +1 -0
- package/dist/memory/MemoryMaintenanceEvents.js +47 -0
- package/dist/memory/MemoryMaintenanceEvents.js.map +1 -0
- package/dist/memory/MemoryMaintenanceStatus.d.ts +61 -0
- package/dist/memory/MemoryMaintenanceStatus.d.ts.map +1 -0
- package/dist/memory/MemoryMaintenanceStatus.js +165 -0
- package/dist/memory/MemoryMaintenanceStatus.js.map +1 -0
- package/dist/memory/MemoryManager.d.ts +80 -0
- package/dist/memory/MemoryManager.d.ts.map +1 -0
- package/dist/memory/MemoryManager.js +310 -0
- package/dist/memory/MemoryManager.js.map +1 -0
- package/dist/memory/MemoryReconciler.d.ts +27 -0
- package/dist/memory/MemoryReconciler.d.ts.map +1 -0
- package/dist/memory/MemoryReconciler.js +163 -0
- package/dist/memory/MemoryReconciler.js.map +1 -0
- package/dist/memory/MemoryService.d.ts +82 -0
- package/dist/memory/MemoryService.d.ts.map +1 -0
- package/dist/memory/MemoryService.js +114 -0
- package/dist/memory/MemoryService.js.map +1 -0
- package/dist/memory/TrajectoryReader.d.ts +39 -0
- package/dist/memory/TrajectoryReader.d.ts.map +1 -0
- package/dist/memory/TrajectoryReader.js +150 -0
- package/dist/memory/TrajectoryReader.js.map +1 -0
- package/dist/memory/types.d.ts +122 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +10 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/plugins/hooks/ChatTransformHook.d.ts +57 -0
- package/dist/plugins/hooks/ChatTransformHook.d.ts.map +1 -0
- package/dist/plugins/hooks/ChatTransformHook.js +59 -0
- package/dist/plugins/hooks/ChatTransformHook.js.map +1 -0
- package/dist/plugins/hooks/ToolHooks.d.ts +125 -0
- package/dist/plugins/hooks/ToolHooks.d.ts.map +1 -0
- package/dist/plugins/hooks/ToolHooks.js +106 -0
- package/dist/plugins/hooks/ToolHooks.js.map +1 -0
- package/dist/plugins/hooks/index.d.ts +8 -0
- package/dist/plugins/hooks/index.d.ts.map +1 -0
- package/dist/plugins/hooks/index.js +6 -0
- package/dist/plugins/hooks/index.js.map +1 -0
- package/dist/runtime/LoggingRuntime.d.ts +35 -0
- package/dist/runtime/LoggingRuntime.d.ts.map +1 -0
- package/dist/runtime/LoggingRuntime.js +87 -0
- package/dist/runtime/LoggingRuntime.js.map +1 -0
- package/dist/runtime/SessionManagerRuntime.d.ts +475 -0
- package/dist/runtime/SessionManagerRuntime.d.ts.map +1 -0
- package/dist/runtime/SessionManagerRuntime.js +2299 -0
- package/dist/runtime/SessionManagerRuntime.js.map +1 -0
- package/dist/runtime/SessionRuntime.d.ts +62 -0
- package/dist/runtime/SessionRuntime.d.ts.map +1 -0
- package/dist/runtime/SessionRuntime.js +241 -0
- package/dist/runtime/SessionRuntime.js.map +1 -0
- package/dist/tools/LazyToolProxy.d.ts +33 -0
- package/dist/tools/LazyToolProxy.d.ts.map +1 -0
- package/dist/tools/LazyToolProxy.js +59 -0
- package/dist/tools/LazyToolProxy.js.map +1 -0
- package/dist/tools/LspClient.d.ts +94 -0
- package/dist/tools/LspClient.d.ts.map +1 -0
- package/dist/tools/LspClient.js +429 -0
- package/dist/tools/LspClient.js.map +1 -0
- package/dist/tools/MetaTool.d.ts +22 -0
- package/dist/tools/MetaTool.d.ts.map +1 -0
- package/dist/tools/MetaTool.js +21 -0
- package/dist/tools/MetaTool.js.map +1 -0
- package/dist/tools/Registry.d.ts +156 -0
- package/dist/tools/Registry.d.ts.map +1 -0
- package/dist/tools/Registry.js +1484 -0
- package/dist/tools/Registry.js.map +1 -0
- package/dist/tools/SchemaUtils.d.ts +5 -0
- package/dist/tools/SchemaUtils.d.ts.map +1 -0
- package/dist/tools/SchemaUtils.js +215 -0
- package/dist/tools/SchemaUtils.js.map +1 -0
- package/dist/tools/Tool.d.ts +90 -0
- package/dist/tools/Tool.d.ts.map +1 -0
- package/dist/tools/Tool.js +128 -0
- package/dist/tools/Tool.js.map +1 -0
- package/dist/tools/ToolMetadata.d.ts +35 -0
- package/dist/tools/ToolMetadata.d.ts.map +1 -0
- package/dist/tools/ToolMetadata.js +139 -0
- package/dist/tools/ToolMetadata.js.map +1 -0
- package/dist/tools/UserToolFactory.d.ts +34 -0
- package/dist/tools/UserToolFactory.d.ts.map +1 -0
- package/dist/tools/UserToolFactory.js +249 -0
- package/dist/tools/UserToolFactory.js.map +1 -0
- package/dist/tools/implementations/AddEdgeTool.d.ts +22 -0
- package/dist/tools/implementations/AddEdgeTool.d.ts.map +1 -0
- package/dist/tools/implementations/AddEdgeTool.js +43 -0
- package/dist/tools/implementations/AddEdgeTool.js.map +1 -0
- package/dist/tools/implementations/AstQueryTool.d.ts +40 -0
- package/dist/tools/implementations/AstQueryTool.d.ts.map +1 -0
- package/dist/tools/implementations/AstQueryTool.js +142 -0
- package/dist/tools/implementations/AstQueryTool.js.map +1 -0
- package/dist/tools/implementations/AttemptCompletionTool.d.ts +178 -0
- package/dist/tools/implementations/AttemptCompletionTool.d.ts.map +1 -0
- package/dist/tools/implementations/AttemptCompletionTool.js +384 -0
- package/dist/tools/implementations/AttemptCompletionTool.js.map +1 -0
- package/dist/tools/implementations/BlackboardTool.d.ts +80 -0
- package/dist/tools/implementations/BlackboardTool.d.ts.map +1 -0
- package/dist/tools/implementations/BlackboardTool.js +87 -0
- package/dist/tools/implementations/BlackboardTool.js.map +1 -0
- package/dist/tools/implementations/BrowserActionTool.d.ts +109 -0
- package/dist/tools/implementations/BrowserActionTool.d.ts.map +1 -0
- package/dist/tools/implementations/BrowserActionTool.js +265 -0
- package/dist/tools/implementations/BrowserActionTool.js.map +1 -0
- package/dist/tools/implementations/BrowserManager.d.ts +191 -0
- package/dist/tools/implementations/BrowserManager.d.ts.map +1 -0
- package/dist/tools/implementations/BrowserManager.js +619 -0
- package/dist/tools/implementations/BrowserManager.js.map +1 -0
- package/dist/tools/implementations/BrowserVisualVerifyTool.d.ts +56 -0
- package/dist/tools/implementations/BrowserVisualVerifyTool.d.ts.map +1 -0
- package/dist/tools/implementations/BrowserVisualVerifyTool.js +269 -0
- package/dist/tools/implementations/BrowserVisualVerifyTool.js.map +1 -0
- package/dist/tools/implementations/BughuntScanToolWrappers.d.ts +28 -0
- package/dist/tools/implementations/BughuntScanToolWrappers.d.ts.map +1 -0
- package/dist/tools/implementations/BughuntScanToolWrappers.js +183 -0
- package/dist/tools/implementations/BughuntScanToolWrappers.js.map +1 -0
- package/dist/tools/implementations/BughuntScanTools.d.ts +48 -0
- package/dist/tools/implementations/BughuntScanTools.d.ts.map +1 -0
- package/dist/tools/implementations/BughuntScanTools.js +502 -0
- package/dist/tools/implementations/BughuntScanTools.js.map +1 -0
- package/dist/tools/implementations/BughuntTaintScanner.d.ts +11 -0
- package/dist/tools/implementations/BughuntTaintScanner.d.ts.map +1 -0
- package/dist/tools/implementations/BughuntTaintScanner.js +82 -0
- package/dist/tools/implementations/BughuntTaintScanner.js.map +1 -0
- package/dist/tools/implementations/CodeSearch.d.ts +55 -0
- package/dist/tools/implementations/CodeSearch.d.ts.map +1 -0
- package/dist/tools/implementations/CodeSearch.js +564 -0
- package/dist/tools/implementations/CodeSearch.js.map +1 -0
- package/dist/tools/implementations/CodeSearchTool.d.ts +17 -0
- package/dist/tools/implementations/CodeSearchTool.d.ts.map +1 -0
- package/dist/tools/implementations/CodeSearchTool.js +35 -0
- package/dist/tools/implementations/CodeSearchTool.js.map +1 -0
- package/dist/tools/implementations/DeclareAssumptionTool.d.ts +21 -0
- package/dist/tools/implementations/DeclareAssumptionTool.d.ts.map +1 -0
- package/dist/tools/implementations/DeclareAssumptionTool.js +60 -0
- package/dist/tools/implementations/DeclareAssumptionTool.js.map +1 -0
- package/dist/tools/implementations/DeclareIntentTool.d.ts +14 -0
- package/dist/tools/implementations/DeclareIntentTool.d.ts.map +1 -0
- package/dist/tools/implementations/DeclareIntentTool.js +41 -0
- package/dist/tools/implementations/DeclareIntentTool.js.map +1 -0
- package/dist/tools/implementations/DesignAssetTool.d.ts +25 -0
- package/dist/tools/implementations/DesignAssetTool.d.ts.map +1 -0
- package/dist/tools/implementations/DesignAssetTool.js +197 -0
- package/dist/tools/implementations/DesignAssetTool.js.map +1 -0
- package/dist/tools/implementations/EditDocxTool.d.ts +60 -0
- package/dist/tools/implementations/EditDocxTool.d.ts.map +1 -0
- package/dist/tools/implementations/EditDocxTool.js +344 -0
- package/dist/tools/implementations/EditDocxTool.js.map +1 -0
- package/dist/tools/implementations/EditPptxTool.d.ts +100 -0
- package/dist/tools/implementations/EditPptxTool.d.ts.map +1 -0
- package/dist/tools/implementations/EditPptxTool.js +447 -0
- package/dist/tools/implementations/EditPptxTool.js.map +1 -0
- package/dist/tools/implementations/EditXlsxTool.d.ts +58 -0
- package/dist/tools/implementations/EditXlsxTool.d.ts.map +1 -0
- package/dist/tools/implementations/EditXlsxTool.js +210 -0
- package/dist/tools/implementations/EditXlsxTool.js.map +1 -0
- package/dist/tools/implementations/ExecutionSandbox.d.ts +51 -0
- package/dist/tools/implementations/ExecutionSandbox.d.ts.map +1 -0
- package/dist/tools/implementations/ExecutionSandbox.js +415 -0
- package/dist/tools/implementations/ExecutionSandbox.js.map +1 -0
- package/dist/tools/implementations/FileCreate.d.ts +15 -0
- package/dist/tools/implementations/FileCreate.d.ts.map +1 -0
- package/dist/tools/implementations/FileCreate.js +68 -0
- package/dist/tools/implementations/FileCreate.js.map +1 -0
- package/dist/tools/implementations/FileParser.d.ts +41 -0
- package/dist/tools/implementations/FileParser.d.ts.map +1 -0
- package/dist/tools/implementations/FileParser.js +524 -0
- package/dist/tools/implementations/FileParser.js.map +1 -0
- package/dist/tools/implementations/FileRead.d.ts +14 -0
- package/dist/tools/implementations/FileRead.d.ts.map +1 -0
- package/dist/tools/implementations/FileRead.js +311 -0
- package/dist/tools/implementations/FileRead.js.map +1 -0
- package/dist/tools/implementations/GenerateCanvasTool.d.ts +109 -0
- package/dist/tools/implementations/GenerateCanvasTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateCanvasTool.js +364 -0
- package/dist/tools/implementations/GenerateCanvasTool.js.map +1 -0
- package/dist/tools/implementations/GenerateDocxTool.d.ts +36 -0
- package/dist/tools/implementations/GenerateDocxTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateDocxTool.js +327 -0
- package/dist/tools/implementations/GenerateDocxTool.js.map +1 -0
- package/dist/tools/implementations/GenerateHtmlDocumentTool.d.ts +149 -0
- package/dist/tools/implementations/GenerateHtmlDocumentTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateHtmlDocumentTool.js +111 -0
- package/dist/tools/implementations/GenerateHtmlDocumentTool.js.map +1 -0
- package/dist/tools/implementations/GenerateHtmlPresentationTool.d.ts +20 -0
- package/dist/tools/implementations/GenerateHtmlPresentationTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateHtmlPresentationTool.js +77 -0
- package/dist/tools/implementations/GenerateHtmlPresentationTool.js.map +1 -0
- package/dist/tools/implementations/GeneratePdfTool.d.ts +48 -0
- package/dist/tools/implementations/GeneratePdfTool.d.ts.map +1 -0
- package/dist/tools/implementations/GeneratePdfTool.js +301 -0
- package/dist/tools/implementations/GeneratePdfTool.js.map +1 -0
- package/dist/tools/implementations/GeneratePptxTool.d.ts +91 -0
- package/dist/tools/implementations/GeneratePptxTool.d.ts.map +1 -0
- package/dist/tools/implementations/GeneratePptxTool.js +570 -0
- package/dist/tools/implementations/GeneratePptxTool.js.map +1 -0
- package/dist/tools/implementations/GenerateSlidevTool.d.ts +26 -0
- package/dist/tools/implementations/GenerateSlidevTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateSlidevTool.js +128 -0
- package/dist/tools/implementations/GenerateSlidevTool.js.map +1 -0
- package/dist/tools/implementations/GenerateXlsxTool.d.ts +63 -0
- package/dist/tools/implementations/GenerateXlsxTool.d.ts.map +1 -0
- package/dist/tools/implementations/GenerateXlsxTool.js +202 -0
- package/dist/tools/implementations/GenerateXlsxTool.js.map +1 -0
- package/dist/tools/implementations/GetTerminalOutput.d.ts +15 -0
- package/dist/tools/implementations/GetTerminalOutput.d.ts.map +1 -0
- package/dist/tools/implementations/GetTerminalOutput.js +97 -0
- package/dist/tools/implementations/GetTerminalOutput.js.map +1 -0
- package/dist/tools/implementations/GitTool.d.ts +70 -0
- package/dist/tools/implementations/GitTool.d.ts.map +1 -0
- package/dist/tools/implementations/GitTool.js +321 -0
- package/dist/tools/implementations/GitTool.js.map +1 -0
- package/dist/tools/implementations/GlobTool.d.ts +16 -0
- package/dist/tools/implementations/GlobTool.d.ts.map +1 -0
- package/dist/tools/implementations/GlobTool.js +85 -0
- package/dist/tools/implementations/GlobTool.js.map +1 -0
- package/dist/tools/implementations/HttpRequestTool.d.ts +33 -0
- package/dist/tools/implementations/HttpRequestTool.d.ts.map +1 -0
- package/dist/tools/implementations/HttpRequestTool.js +197 -0
- package/dist/tools/implementations/HttpRequestTool.js.map +1 -0
- package/dist/tools/implementations/InspectDocxTool.d.ts +14 -0
- package/dist/tools/implementations/InspectDocxTool.d.ts.map +1 -0
- package/dist/tools/implementations/InspectDocxTool.js +78 -0
- package/dist/tools/implementations/InspectDocxTool.js.map +1 -0
- package/dist/tools/implementations/InspectPptxTool.d.ts +14 -0
- package/dist/tools/implementations/InspectPptxTool.d.ts.map +1 -0
- package/dist/tools/implementations/InspectPptxTool.js +81 -0
- package/dist/tools/implementations/InspectPptxTool.js.map +1 -0
- package/dist/tools/implementations/ListDir.d.ts +15 -0
- package/dist/tools/implementations/ListDir.d.ts.map +1 -0
- package/dist/tools/implementations/ListDir.js +156 -0
- package/dist/tools/implementations/ListDir.js.map +1 -0
- package/dist/tools/implementations/LspTool.d.ts +27 -0
- package/dist/tools/implementations/LspTool.d.ts.map +1 -0
- package/dist/tools/implementations/LspTool.js +111 -0
- package/dist/tools/implementations/LspTool.js.map +1 -0
- package/dist/tools/implementations/McpTool.d.ts +41 -0
- package/dist/tools/implementations/McpTool.d.ts.map +1 -0
- package/dist/tools/implementations/McpTool.js +103 -0
- package/dist/tools/implementations/McpTool.js.map +1 -0
- package/dist/tools/implementations/MemoryTool.d.ts +90 -0
- package/dist/tools/implementations/MemoryTool.d.ts.map +1 -0
- package/dist/tools/implementations/MemoryTool.js +167 -0
- package/dist/tools/implementations/MemoryTool.js.map +1 -0
- package/dist/tools/implementations/NodeReplTool.d.ts +20 -0
- package/dist/tools/implementations/NodeReplTool.d.ts.map +1 -0
- package/dist/tools/implementations/NodeReplTool.js +109 -0
- package/dist/tools/implementations/NodeReplTool.js.map +1 -0
- package/dist/tools/implementations/OCRTool.d.ts +33 -0
- package/dist/tools/implementations/OCRTool.d.ts.map +1 -0
- package/dist/tools/implementations/OCRTool.js +253 -0
- package/dist/tools/implementations/OCRTool.js.map +1 -0
- package/dist/tools/implementations/OfficeAssetTool.d.ts +42 -0
- package/dist/tools/implementations/OfficeAssetTool.d.ts.map +1 -0
- package/dist/tools/implementations/OfficeAssetTool.js +210 -0
- package/dist/tools/implementations/OfficeAssetTool.js.map +1 -0
- package/dist/tools/implementations/OfficeOpsTool.d.ts +33 -0
- package/dist/tools/implementations/OfficeOpsTool.d.ts.map +1 -0
- package/dist/tools/implementations/OfficeOpsTool.js +221 -0
- package/dist/tools/implementations/OfficeOpsTool.js.map +1 -0
- package/dist/tools/implementations/OfficeReviewTool.d.ts +75 -0
- package/dist/tools/implementations/OfficeReviewTool.d.ts.map +1 -0
- package/dist/tools/implementations/OfficeReviewTool.js +125 -0
- package/dist/tools/implementations/OfficeReviewTool.js.map +1 -0
- package/dist/tools/implementations/OfficeRuntimeTool.d.ts +40 -0
- package/dist/tools/implementations/OfficeRuntimeTool.d.ts.map +1 -0
- package/dist/tools/implementations/OfficeRuntimeTool.js +266 -0
- package/dist/tools/implementations/OfficeRuntimeTool.js.map +1 -0
- package/dist/tools/implementations/OfficeXmlBuilder.d.ts +226 -0
- package/dist/tools/implementations/OfficeXmlBuilder.d.ts.map +1 -0
- package/dist/tools/implementations/OfficeXmlBuilder.js +560 -0
- package/dist/tools/implementations/OfficeXmlBuilder.js.map +1 -0
- package/dist/tools/implementations/ParallelReadBatchTool.d.ts +21 -0
- package/dist/tools/implementations/ParallelReadBatchTool.d.ts.map +1 -0
- package/dist/tools/implementations/ParallelReadBatchTool.js +90 -0
- package/dist/tools/implementations/ParallelReadBatchTool.js.map +1 -0
- package/dist/tools/implementations/ParseFileTool.d.ts +20 -0
- package/dist/tools/implementations/ParseFileTool.d.ts.map +1 -0
- package/dist/tools/implementations/ParseFileTool.js +59 -0
- package/dist/tools/implementations/ParseFileTool.js.map +1 -0
- package/dist/tools/implementations/PythonExec.d.ts +38 -0
- package/dist/tools/implementations/PythonExec.d.ts.map +1 -0
- package/dist/tools/implementations/PythonExec.js +204 -0
- package/dist/tools/implementations/PythonExec.js.map +1 -0
- package/dist/tools/implementations/PythonExecTool.d.ts +15 -0
- package/dist/tools/implementations/PythonExecTool.d.ts.map +1 -0
- package/dist/tools/implementations/PythonExecTool.js +54 -0
- package/dist/tools/implementations/PythonExecTool.js.map +1 -0
- package/dist/tools/implementations/ReadGraphTool.d.ts +31 -0
- package/dist/tools/implementations/ReadGraphTool.d.ts.map +1 -0
- package/dist/tools/implementations/ReadGraphTool.js +259 -0
- package/dist/tools/implementations/ReadGraphTool.js.map +1 -0
- package/dist/tools/implementations/ScreenshotTool.d.ts +27 -0
- package/dist/tools/implementations/ScreenshotTool.d.ts.map +1 -0
- package/dist/tools/implementations/ScreenshotTool.js +124 -0
- package/dist/tools/implementations/ScreenshotTool.js.map +1 -0
- package/dist/tools/implementations/SendMessageTool.d.ts +21 -0
- package/dist/tools/implementations/SendMessageTool.d.ts.map +1 -0
- package/dist/tools/implementations/SendMessageTool.js +75 -0
- package/dist/tools/implementations/SendMessageTool.js.map +1 -0
- package/dist/tools/implementations/SessionArtifacts.d.ts +22 -0
- package/dist/tools/implementations/SessionArtifacts.d.ts.map +1 -0
- package/dist/tools/implementations/SessionArtifacts.js +141 -0
- package/dist/tools/implementations/SessionArtifacts.js.map +1 -0
- package/dist/tools/implementations/SessionInfoTool.d.ts +10 -0
- package/dist/tools/implementations/SessionInfoTool.d.ts.map +1 -0
- package/dist/tools/implementations/SessionInfoTool.js +38 -0
- package/dist/tools/implementations/SessionInfoTool.js.map +1 -0
- package/dist/tools/implementations/Shell.d.ts +77 -0
- package/dist/tools/implementations/Shell.d.ts.map +1 -0
- package/dist/tools/implementations/Shell.js +772 -0
- package/dist/tools/implementations/Shell.js.map +1 -0
- package/dist/tools/implementations/StructuredPatchTool.d.ts +57 -0
- package/dist/tools/implementations/StructuredPatchTool.d.ts.map +1 -0
- package/dist/tools/implementations/StructuredPatchTool.js +970 -0
- package/dist/tools/implementations/StructuredPatchTool.js.map +1 -0
- package/dist/tools/implementations/SupersedeNodeTool.d.ts +19 -0
- package/dist/tools/implementations/SupersedeNodeTool.d.ts.map +1 -0
- package/dist/tools/implementations/SupersedeNodeTool.js +50 -0
- package/dist/tools/implementations/SupersedeNodeTool.js.map +1 -0
- package/dist/tools/implementations/TeamCreate.d.ts +20 -0
- package/dist/tools/implementations/TeamCreate.d.ts.map +1 -0
- package/dist/tools/implementations/TeamCreate.js +99 -0
- package/dist/tools/implementations/TeamCreate.js.map +1 -0
- package/dist/tools/implementations/TeamDelete.d.ts +11 -0
- package/dist/tools/implementations/TeamDelete.d.ts.map +1 -0
- package/dist/tools/implementations/TeamDelete.js +55 -0
- package/dist/tools/implementations/TeamDelete.js.map +1 -0
- package/dist/tools/implementations/TeamEdit.d.ts +35 -0
- package/dist/tools/implementations/TeamEdit.d.ts.map +1 -0
- package/dist/tools/implementations/TeamEdit.js +254 -0
- package/dist/tools/implementations/TeamEdit.js.map +1 -0
- package/dist/tools/implementations/TeamInboxCheck.d.ts +22 -0
- package/dist/tools/implementations/TeamInboxCheck.d.ts.map +1 -0
- package/dist/tools/implementations/TeamInboxCheck.js +111 -0
- package/dist/tools/implementations/TeamInboxCheck.js.map +1 -0
- package/dist/tools/implementations/TeamInboxTool.d.ts +13 -0
- package/dist/tools/implementations/TeamInboxTool.d.ts.map +1 -0
- package/dist/tools/implementations/TeamInboxTool.js +17 -0
- package/dist/tools/implementations/TeamInboxTool.js.map +1 -0
- package/dist/tools/implementations/TeamListMembers.d.ts +16 -0
- package/dist/tools/implementations/TeamListMembers.d.ts.map +1 -0
- package/dist/tools/implementations/TeamListMembers.js +34 -0
- package/dist/tools/implementations/TeamListMembers.js.map +1 -0
- package/dist/tools/implementations/TeamManageTool.d.ts +33 -0
- package/dist/tools/implementations/TeamManageTool.d.ts.map +1 -0
- package/dist/tools/implementations/TeamManageTool.js +68 -0
- package/dist/tools/implementations/TeamManageTool.js.map +1 -0
- package/dist/tools/implementations/TeamMessageTool.d.ts +94 -0
- package/dist/tools/implementations/TeamMessageTool.d.ts.map +1 -0
- package/dist/tools/implementations/TeamMessageTool.js +89 -0
- package/dist/tools/implementations/TeamMessageTool.js.map +1 -0
- package/dist/tools/implementations/TeamSendMessage.d.ts +57 -0
- package/dist/tools/implementations/TeamSendMessage.d.ts.map +1 -0
- package/dist/tools/implementations/TeamSendMessage.js +290 -0
- package/dist/tools/implementations/TeamSendMessage.js.map +1 -0
- package/dist/tools/implementations/TeamStatus.d.ts +18 -0
- package/dist/tools/implementations/TeamStatus.d.ts.map +1 -0
- package/dist/tools/implementations/TeamStatus.js +106 -0
- package/dist/tools/implementations/TeamStatus.js.map +1 -0
- package/dist/tools/implementations/TeamTaskBoard.d.ts +22 -0
- package/dist/tools/implementations/TeamTaskBoard.d.ts.map +1 -0
- package/dist/tools/implementations/TeamTaskBoard.js +119 -0
- package/dist/tools/implementations/TeamTaskBoard.js.map +1 -0
- package/dist/tools/implementations/TerminalControl.d.ts +27 -0
- package/dist/tools/implementations/TerminalControl.d.ts.map +1 -0
- package/dist/tools/implementations/TerminalControl.js +198 -0
- package/dist/tools/implementations/TerminalControl.js.map +1 -0
- package/dist/tools/implementations/TerminalSessionManager.d.ts +196 -0
- package/dist/tools/implementations/TerminalSessionManager.d.ts.map +1 -0
- package/dist/tools/implementations/TerminalSessionManager.js +525 -0
- package/dist/tools/implementations/TerminalSessionManager.js.map +1 -0
- package/dist/tools/implementations/ToolDiscoveryTool.d.ts +24 -0
- package/dist/tools/implementations/ToolDiscoveryTool.d.ts.map +1 -0
- package/dist/tools/implementations/ToolDiscoveryTool.js +138 -0
- package/dist/tools/implementations/ToolDiscoveryTool.js.map +1 -0
- package/dist/tools/implementations/ToolPreflightTool.d.ts +17 -0
- package/dist/tools/implementations/ToolPreflightTool.d.ts.map +1 -0
- package/dist/tools/implementations/ToolPreflightTool.js +27 -0
- package/dist/tools/implementations/ToolPreflightTool.js.map +1 -0
- package/dist/tools/implementations/TreeSitterSecurityEngine.d.ts +67 -0
- package/dist/tools/implementations/TreeSitterSecurityEngine.d.ts.map +1 -0
- package/dist/tools/implementations/TreeSitterSecurityEngine.js +355 -0
- package/dist/tools/implementations/TreeSitterSecurityEngine.js.map +1 -0
- package/dist/tools/implementations/ValidateOfficeTool.d.ts +33 -0
- package/dist/tools/implementations/ValidateOfficeTool.d.ts.map +1 -0
- package/dist/tools/implementations/ValidateOfficeTool.js +50 -0
- package/dist/tools/implementations/ValidateOfficeTool.js.map +1 -0
- package/dist/tools/implementations/VisualContactSheetTool.d.ts +32 -0
- package/dist/tools/implementations/VisualContactSheetTool.d.ts.map +1 -0
- package/dist/tools/implementations/VisualContactSheetTool.js +234 -0
- package/dist/tools/implementations/VisualContactSheetTool.js.map +1 -0
- package/dist/tools/implementations/WebCommon.d.ts +12 -0
- package/dist/tools/implementations/WebCommon.d.ts.map +1 -0
- package/dist/tools/implementations/WebCommon.js +286 -0
- package/dist/tools/implementations/WebCommon.js.map +1 -0
- package/dist/tools/implementations/WebFetch.d.ts +38 -0
- package/dist/tools/implementations/WebFetch.d.ts.map +1 -0
- package/dist/tools/implementations/WebFetch.js +294 -0
- package/dist/tools/implementations/WebFetch.js.map +1 -0
- package/dist/tools/implementations/WebSearch.d.ts +45 -0
- package/dist/tools/implementations/WebSearch.d.ts.map +1 -0
- package/dist/tools/implementations/WebSearch.js +432 -0
- package/dist/tools/implementations/WebSearch.js.map +1 -0
- package/dist/tools/implementations/WorkNoteTool.d.ts +71 -0
- package/dist/tools/implementations/WorkNoteTool.d.ts.map +1 -0
- package/dist/tools/implementations/WorkNoteTool.js +238 -0
- package/dist/tools/implementations/WorkNoteTool.js.map +1 -0
- package/dist/tools/implementations/WriteFactTool.d.ts +34 -0
- package/dist/tools/implementations/WriteFactTool.d.ts.map +1 -0
- package/dist/tools/implementations/WriteFactTool.js +43 -0
- package/dist/tools/implementations/WriteFactTool.js.map +1 -0
- package/dist/tools/implementations/office/ConditionalFormattingBuilder.d.ts +149 -0
- package/dist/tools/implementations/office/ConditionalFormattingBuilder.d.ts.map +1 -0
- package/dist/tools/implementations/office/ConditionalFormattingBuilder.js +259 -0
- package/dist/tools/implementations/office/ConditionalFormattingBuilder.js.map +1 -0
- package/dist/tools/implementations/office/ExcelWorkbook.d.ts +21 -0
- package/dist/tools/implementations/office/ExcelWorkbook.d.ts.map +1 -0
- package/dist/tools/implementations/office/ExcelWorkbook.js +114 -0
- package/dist/tools/implementations/office/ExcelWorkbook.js.map +1 -0
- package/dist/tools/implementations/office/OfficeAuditLog.d.ts +28 -0
- package/dist/tools/implementations/office/OfficeAuditLog.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficeAuditLog.js +221 -0
- package/dist/tools/implementations/office/OfficeAuditLog.js.map +1 -0
- package/dist/tools/implementations/office/OfficePdfRenderer.d.ts +33 -0
- package/dist/tools/implementations/office/OfficePdfRenderer.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficePdfRenderer.js +194 -0
- package/dist/tools/implementations/office/OfficePdfRenderer.js.map +1 -0
- package/dist/tools/implementations/office/OfficePreviewExtractor.d.ts +6 -0
- package/dist/tools/implementations/office/OfficePreviewExtractor.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficePreviewExtractor.js +493 -0
- package/dist/tools/implementations/office/OfficePreviewExtractor.js.map +1 -0
- package/dist/tools/implementations/office/OfficePreviewModel.d.ts +96 -0
- package/dist/tools/implementations/office/OfficePreviewModel.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficePreviewModel.js +2 -0
- package/dist/tools/implementations/office/OfficePreviewModel.js.map +1 -0
- package/dist/tools/implementations/office/OfficeReview.d.ts +94 -0
- package/dist/tools/implementations/office/OfficeReview.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficeReview.js +496 -0
- package/dist/tools/implementations/office/OfficeReview.js.map +1 -0
- package/dist/tools/implementations/office/OfficeRuntime.d.ts +13 -0
- package/dist/tools/implementations/office/OfficeRuntime.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficeRuntime.js +22 -0
- package/dist/tools/implementations/office/OfficeRuntime.js.map +1 -0
- package/dist/tools/implementations/office/OfficeTemplateRegistry.d.ts +76 -0
- package/dist/tools/implementations/office/OfficeTemplateRegistry.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficeTemplateRegistry.js +624 -0
- package/dist/tools/implementations/office/OfficeTemplateRegistry.js.map +1 -0
- package/dist/tools/implementations/office/OfficeValidator.d.ts +33 -0
- package/dist/tools/implementations/office/OfficeValidator.d.ts.map +1 -0
- package/dist/tools/implementations/office/OfficeValidator.js +651 -0
- package/dist/tools/implementations/office/OfficeValidator.js.map +1 -0
- package/dist/tools/implementations/office/OoxmlTextReplace.d.ts +12 -0
- package/dist/tools/implementations/office/OoxmlTextReplace.d.ts.map +1 -0
- package/dist/tools/implementations/office/OoxmlTextReplace.js +107 -0
- package/dist/tools/implementations/office/OoxmlTextReplace.js.map +1 -0
- package/dist/tools/implementations/office/XlsxStyleBuilder.d.ts +85 -0
- package/dist/tools/implementations/office/XlsxStyleBuilder.d.ts.map +1 -0
- package/dist/tools/implementations/office/XlsxStyleBuilder.js +156 -0
- package/dist/tools/implementations/office/XlsxStyleBuilder.js.map +1 -0
- package/dist/tools/implementations/office/html/HtmlOfficeEngine.d.ts +53 -0
- package/dist/tools/implementations/office/html/HtmlOfficeEngine.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/HtmlOfficeEngine.js +90 -0
- package/dist/tools/implementations/office/html/HtmlOfficeEngine.js.map +1 -0
- package/dist/tools/implementations/office/html/assemble.d.ts +52 -0
- package/dist/tools/implementations/office/html/assemble.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/assemble.js +183 -0
- package/dist/tools/implementations/office/html/assemble.js.map +1 -0
- package/dist/tools/implementations/office/html/components.d.ts +132 -0
- package/dist/tools/implementations/office/html/components.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/components.js +182 -0
- package/dist/tools/implementations/office/html/components.js.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToDocx.d.ts +19 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToDocx.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToDocx.js +180 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToDocx.js.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPdf.d.ts +38 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPdf.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPdf.js +118 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPdf.js.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPptx.d.ts +28 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPptx.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPptx.js +79 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToPptx.js.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToXlsx.d.ts +20 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToXlsx.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToXlsx.js +101 -0
- package/dist/tools/implementations/office/html/exporters/HtmlToXlsx.js.map +1 -0
- package/dist/tools/implementations/office/html/provenance.d.ts +25 -0
- package/dist/tools/implementations/office/html/provenance.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/provenance.js +51 -0
- package/dist/tools/implementations/office/html/provenance.js.map +1 -0
- package/dist/tools/implementations/office/html/themes.d.ts +60 -0
- package/dist/tools/implementations/office/html/themes.d.ts.map +1 -0
- package/dist/tools/implementations/office/html/themes.js +183 -0
- package/dist/tools/implementations/office/html/themes.js.map +1 -0
- package/dist/tools/implementations/rules/RuleLoader.d.ts +27 -0
- package/dist/tools/implementations/rules/RuleLoader.d.ts.map +1 -0
- package/dist/tools/implementations/rules/RuleLoader.js +69 -0
- package/dist/tools/implementations/rules/RuleLoader.js.map +1 -0
- package/dist/tools/implementations/rules/schema.d.ts +236 -0
- package/dist/tools/implementations/rules/schema.d.ts.map +1 -0
- package/dist/tools/implementations/rules/schema.js +119 -0
- package/dist/tools/implementations/rules/schema.js.map +1 -0
- package/dist/tools/implementations/rules/seed.d.ts +18 -0
- package/dist/tools/implementations/rules/seed.d.ts.map +1 -0
- package/dist/tools/implementations/rules/seed.js +252 -0
- package/dist/tools/implementations/rules/seed.js.map +1 -0
- package/dist/tools/implementations/rules/taintFacts.d.ts +26 -0
- package/dist/tools/implementations/rules/taintFacts.d.ts.map +1 -0
- package/dist/tools/implementations/rules/taintFacts.js +48 -0
- package/dist/tools/implementations/rules/taintFacts.js.map +1 -0
- package/dist/tools/implementations/scanners/ScannerAdapter.d.ts +35 -0
- package/dist/tools/implementations/scanners/ScannerAdapter.d.ts.map +1 -0
- package/dist/tools/implementations/scanners/ScannerAdapter.js +2 -0
- package/dist/tools/implementations/scanners/ScannerAdapter.js.map +1 -0
- package/dist/tools/implementations/utils.d.ts +76 -0
- package/dist/tools/implementations/utils.d.ts.map +1 -0
- package/dist/tools/implementations/utils.js +468 -0
- package/dist/tools/implementations/utils.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowAddNodeTool.d.ts +128 -0
- package/dist/tools/implementations/workflow/WorkflowAddNodeTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowAddNodeTool.js +399 -0
- package/dist/tools/implementations/workflow/WorkflowAddNodeTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowApplyTool.d.ts +98 -0
- package/dist/tools/implementations/workflow/WorkflowApplyTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowApplyTool.js +329 -0
- package/dist/tools/implementations/workflow/WorkflowApplyTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowAuditTool.d.ts +12 -0
- package/dist/tools/implementations/workflow/WorkflowAuditTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowAuditTool.js +51 -0
- package/dist/tools/implementations/workflow/WorkflowAuditTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowConnectTool.d.ts +21 -0
- package/dist/tools/implementations/workflow/WorkflowConnectTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowConnectTool.js +175 -0
- package/dist/tools/implementations/workflow/WorkflowConnectTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowCreateTool.d.ts +17 -0
- package/dist/tools/implementations/workflow/WorkflowCreateTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowCreateTool.js +78 -0
- package/dist/tools/implementations/workflow/WorkflowCreateTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowExecuteTool.d.ts +20 -0
- package/dist/tools/implementations/workflow/WorkflowExecuteTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowExecuteTool.js +178 -0
- package/dist/tools/implementations/workflow/WorkflowExecuteTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowGetStatusTool.d.ts +12 -0
- package/dist/tools/implementations/workflow/WorkflowGetStatusTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowGetStatusTool.js +87 -0
- package/dist/tools/implementations/workflow/WorkflowGetStatusTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowInspectTool.d.ts +11 -0
- package/dist/tools/implementations/workflow/WorkflowInspectTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowInspectTool.js +186 -0
- package/dist/tools/implementations/workflow/WorkflowInspectTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowSchemaUtils.d.ts +49 -0
- package/dist/tools/implementations/workflow/WorkflowSchemaUtils.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowSchemaUtils.js +186 -0
- package/dist/tools/implementations/workflow/WorkflowSchemaUtils.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowTool.d.ts +129 -0
- package/dist/tools/implementations/workflow/WorkflowTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowTool.js +141 -0
- package/dist/tools/implementations/workflow/WorkflowTool.js.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowValidateTool.d.ts +11 -0
- package/dist/tools/implementations/workflow/WorkflowValidateTool.d.ts.map +1 -0
- package/dist/tools/implementations/workflow/WorkflowValidateTool.js +238 -0
- package/dist/tools/implementations/workflow/WorkflowValidateTool.js.map +1 -0
- package/dist/tools/index.d.ts +49 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +364 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/officeToolContract.d.ts +2 -0
- package/dist/tools/officeToolContract.d.ts.map +1 -0
- package/dist/tools/officeToolContract.js +2 -0
- package/dist/tools/officeToolContract.js.map +1 -0
- package/dist/tools/slidev/SlidevExporter.d.ts +15 -0
- package/dist/tools/slidev/SlidevExporter.d.ts.map +1 -0
- package/dist/tools/slidev/SlidevExporter.js +112 -0
- package/dist/tools/slidev/SlidevExporter.js.map +1 -0
- package/dist/tools/slidev/SlidevProjectBuilder.d.ts +22 -0
- package/dist/tools/slidev/SlidevProjectBuilder.d.ts.map +1 -0
- package/dist/tools/slidev/SlidevProjectBuilder.js +139 -0
- package/dist/tools/slidev/SlidevProjectBuilder.js.map +1 -0
- package/dist/types/canonical.d.ts +124 -0
- package/dist/types/canonical.d.ts.map +1 -0
- package/dist/types/canonical.js +8 -0
- package/dist/types/canonical.js.map +1 -0
- package/dist/utils/SmartTruncator.d.ts +22 -0
- package/dist/utils/SmartTruncator.d.ts.map +1 -0
- package/dist/utils/SmartTruncator.js +88 -0
- package/dist/utils/SmartTruncator.js.map +1 -0
- package/dist/utils/getPty.d.ts +42 -0
- package/dist/utils/getPty.d.ts.map +1 -0
- package/dist/utils/getPty.js +57 -0
- package/dist/utils/getPty.js.map +1 -0
- package/dist/utils/platform.d.ts +137 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +374 -0
- package/dist/utils/platform.js.map +1 -0
- package/dist/utils/sleep.d.ts +8 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +10 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/textTable.d.ts +27 -0
- package/dist/utils/textTable.d.ts.map +1 -0
- package/dist/utils/textTable.js +55 -0
- package/dist/utils/textTable.js.map +1 -0
- package/dist/version.d.ts +12 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +42 -0
- package/dist/version.js.map +1 -0
- package/dist/web-server/FileChangesApi.d.ts +131 -0
- package/dist/web-server/FileChangesApi.d.ts.map +1 -0
- package/dist/web-server/FileChangesApi.js +552 -0
- package/dist/web-server/FileChangesApi.js.map +1 -0
- package/dist/web-server/GitEnv.d.ts +6 -0
- package/dist/web-server/GitEnv.d.ts.map +1 -0
- package/dist/web-server/GitEnv.js +6 -0
- package/dist/web-server/GitEnv.js.map +1 -0
- package/dist/web-server/GitService.d.ts +151 -0
- package/dist/web-server/GitService.d.ts.map +1 -0
- package/dist/web-server/GitService.js +1172 -0
- package/dist/web-server/GitService.js.map +1 -0
- package/dist/web-server/LocalLlmGatewayRoutes.d.ts +45 -0
- package/dist/web-server/LocalLlmGatewayRoutes.d.ts.map +1 -0
- package/dist/web-server/LocalLlmGatewayRoutes.js +812 -0
- package/dist/web-server/LocalLlmGatewayRoutes.js.map +1 -0
- package/package.json +114 -0
|
@@ -0,0 +1,3280 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BaseAgent - Agent 基类
|
|
3
|
+
* 完整复刻 Python 版本的所有功能
|
|
4
|
+
*
|
|
5
|
+
* 包含:
|
|
6
|
+
* - ContextManager 集成
|
|
7
|
+
* - 多模态上下文注入
|
|
8
|
+
* - 数据库持久化
|
|
9
|
+
* - 完整的事件日志
|
|
10
|
+
* - 消息总线干预检查
|
|
11
|
+
* - 超时重试机制
|
|
12
|
+
* - 原始 XML 工具调用容错解析
|
|
13
|
+
* - 工具结果智能截断
|
|
14
|
+
* - Agent 级上下文管理
|
|
15
|
+
* - 技能注入
|
|
16
|
+
* - Scratchpad 工作笔记
|
|
17
|
+
* - 幻觉检测和处理
|
|
18
|
+
*/
|
|
19
|
+
import { contentToPlainText, thinkingBlocksToText, } from '../llm/types.js';
|
|
20
|
+
import { createFailureResult, createSuccessResult } from './AgentExecutionResult.js';
|
|
21
|
+
import { BUGHUNT_MODE_TOOL_NAMES, OFFICE_TOOL_NAMES } from '../contracts/constants/leaderToolDefinitions.js';
|
|
22
|
+
import { ContextManager } from '../core/ContextManager.js';
|
|
23
|
+
import { renderContextManifest, } from '../core/ContextManifest.js';
|
|
24
|
+
import { buildLlmInputManifest, summarizeLlmInputManifest } from '../core/LlmInputManifest.js';
|
|
25
|
+
import { getLeaderDefaultPermissionContext, isNetworkTool, normalizeToolPermissionContext, } from '../core/PermissionSystem.js';
|
|
26
|
+
import { createPermissionRequestPayload, readAgentControlMessage, } from '../core/AgentProtocol.js';
|
|
27
|
+
import { parseProtocolPayload } from '../core/TeamProtocol.js';
|
|
28
|
+
import { langfuseIntegration } from '../core/LangfuseIntegration.js';
|
|
29
|
+
import { buildSkillInjection, collectAvailableSkills, resolveExplicitSkillMentions, resolveDisabledSkillNames, } from '../core/SkillCatalog.js';
|
|
30
|
+
import { setWorkerFlushFn } from './WorkerFlushRegistry.js';
|
|
31
|
+
import { AssetUsageStore } from '../memory/AssetUsageStore.js';
|
|
32
|
+
import { AGENT_MAX_ITERATIONS, AGENT_MAX_RUNTIME_MINUTES, ENABLE_STREAMING, ENABLE_THINKING_INSTRUCTION, MAX_AGENT_MESSAGES, onConfigReload, } from '../config.js';
|
|
33
|
+
import { THINKING_INSTRUCTION as DEFAULT_THINKING_INSTRUCTION } from './prompts/task-runtime/thinking_instruction.js';
|
|
34
|
+
import { buildWorkerTaskPrompt } from './prompts/task-runtime/worker_task_prompt.js';
|
|
35
|
+
import { hasRawToolSyntax, parseRawToolCalls } from './raw_tool_calls.js';
|
|
36
|
+
import { clearAgentResumeCheckpoint, saveAgentResumeCheckpoint } from '../core/ResumeManager.js';
|
|
37
|
+
import { classifyLLMError, formatLLMErrorLabel } from '../llm/errors.js';
|
|
38
|
+
import { CircuitOpenError } from '../llm/CircuitBreaker.js';
|
|
39
|
+
import { getModelDevInfo } from '../llm/ModelsDevRegistry.js';
|
|
40
|
+
import { getContextWindowSizeFromProvider } from '../llm/model_capabilities.js';
|
|
41
|
+
import { getReasoningGenerateOptions } from '../llm/reasoningSampling.js';
|
|
42
|
+
import { resolveModeRuntimeProjection } from '../core/ModeRuntimeProjection.js';
|
|
43
|
+
import { getTeamMemberRegistry } from '../core/TeamMailbox.js';
|
|
44
|
+
import { createLlmGuard } from './LlmGuard.js';
|
|
45
|
+
import { createEventStreamClient, } from './runtime/LlmRoundExecutor.js';
|
|
46
|
+
import { AgentCore } from './runtime/AgentCore.js';
|
|
47
|
+
import { ToolScheduler } from './runtime/ToolScheduler.js';
|
|
48
|
+
import { healInterruptedToolCalls } from '../llm/message_sanitizer.js';
|
|
49
|
+
import { executeToolCallsWithTruncationGuard, rejectEmptyArgsFileTools } from './runtime/ToolCallSafety.js';
|
|
50
|
+
import { ToolLoopDetector } from './runtime/ToolLoopDetector.js';
|
|
51
|
+
import { getToolFailureLoopGuard } from './runtime/ToolFailureLoopGuard.js';
|
|
52
|
+
import { createToolFailureLoopEscalationPayload } from '../core/AgentProtocol.js';
|
|
53
|
+
import { createStreamHookBuffers, wrapLlmHooksForEmitter } from './runtime/LlmStreamHooks.js';
|
|
54
|
+
import { formatIncomingContent, isStopMessage as inboxIsStopMessage, isPauseMessage as inboxIsPauseMessage, parseInterveneMessage as inboxParseInterveneMessage, parseInterventionControl as inboxParseInterventionControl, isResumeMessage as inboxIsResumeMessage, isInterventionConfirmMessage as inboxIsInterventionConfirmMessage, resolveSenderLabel as inboxResolveSenderLabel, } from './runtime/AgentInboxParsers.js';
|
|
55
|
+
import { startToolProgressHeartbeat, startLlmInFlightHeartbeat } from './runtime/ToolProgressHeartbeat.js';
|
|
56
|
+
import { evaluateRawToolRetryOutcome, } from './runtime/CompletionTerminationPolicy.js';
|
|
57
|
+
import { evaluateNextSpeakerCandidate } from './runtime/NextSpeakerPolicy.js';
|
|
58
|
+
import { AgentRuntimeState } from './runtime/AgentRuntimeState.js';
|
|
59
|
+
import { AgentContextController } from './AgentContextController.js';
|
|
60
|
+
import { AgentInterventionHandler } from './AgentInterventionHandler.js';
|
|
61
|
+
import { AgentRoundExecutor } from './AgentRoundExecutor.js';
|
|
62
|
+
import { inferAgentGatewayPurpose, recordAgentTokenUsage, renderAgentPromptTemplate, summarizeAgentProgress, truncateAgentToolResult, } from './AgentRuntimeUtilities.js';
|
|
63
|
+
import { autoWriteAgentCompletionNote } from './AgentCompletionNoteWriter.js';
|
|
64
|
+
import { evaluateWorkerCompletionCandidate } from './runtime/WorkerCompletionPolicy.js';
|
|
65
|
+
import { runCompletionVerification } from './runtime/MandatoryVerification.js';
|
|
66
|
+
import { decideAgentP0Action } from './agentP0Message.js';
|
|
67
|
+
import { join } from 'path';
|
|
68
|
+
import { homedir } from 'os';
|
|
69
|
+
import { agentLogger } from '../core/Log.js';
|
|
70
|
+
import { executeStop } from '../core/hooks/index.js';
|
|
71
|
+
import { LLM, BUDGET } from '../config/defaults.js';
|
|
72
|
+
import { config as runtimeConfig, getConfigValue } from '../config.js';
|
|
73
|
+
import { normalizeImageRetainRounds } from '../llm/image_blob_store.js';
|
|
74
|
+
import { SESSION_KEYS } from '../core/SessionStateKeys.js';
|
|
75
|
+
import { OFFICE_SUITE_SKILL_NAME } from './office/OfficeModeProtocol.js';
|
|
76
|
+
import { resolveActiveModes, MODE_REGISTRY, ALL_MODE_IDS } from '../contracts/modes.js';
|
|
77
|
+
import { MemoryManager } from '../memory/MemoryManager.js';
|
|
78
|
+
import { TimeoutError } from './errors/TimeoutError.js';
|
|
79
|
+
import { getPromptTemplate } from './prompts/PromptTemplates.js';
|
|
80
|
+
import { TaskClassifier } from './TaskClassifier.js';
|
|
81
|
+
import { AssumptionTracker } from '../core/AssumptionTracker.js';
|
|
82
|
+
import { REQUIRED_AGENT_CONTRACT_TOOLS, REQUIRED_TEAM_CONTRACT_TOOLS, pruneTools, } from '../core/ToolPruner.js';
|
|
83
|
+
import { discoverPlugins } from '../core/plugins/PluginStore.js';
|
|
84
|
+
import { BASE_PARALLEL_SAFE_TOOLS, FILE_MODIFYING_TOOLS, runToolCallsBatch } from './runtime/parallelToolBatch.js';
|
|
85
|
+
import { CONTRACT_PACK_MARKER } from '../core/ContractPack.js';
|
|
86
|
+
import { upsertSystemSlot, collapseSystemSlots, matchesSystemSlot } from '../core/SystemMessageSlot.js';
|
|
87
|
+
/**
|
|
88
|
+
* 把 ToolFailureLoopGuard 的熔断决策转成给 LLM 看的 ERROR 文案。
|
|
89
|
+
* 放在模块顶层(不依赖 class state)以便未来跨模块复用 + 纯函数可单测。
|
|
90
|
+
*/
|
|
91
|
+
export function formatToolFailureLoopError(toolName, decision) {
|
|
92
|
+
const lines = [
|
|
93
|
+
`TOOL_FAILURE_LOOP_TRIPPED: 工具 "${toolName}" 连续 ${decision.count} 次以相同 args + 错误类型(${decision.errorKind})失败,已自动熔断。`,
|
|
94
|
+
];
|
|
95
|
+
if (decision.requiresEscalation) {
|
|
96
|
+
lines.push('本错误属于状态类(permission / mode / write_scope / sandbox / network / schema),继续重试不会改变结果。');
|
|
97
|
+
lines.push('下一步:请通过 escalate_to_leader 或 request_permission_update 申请 Leader 介入;不要再次发起相同调用。');
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
lines.push('本错误非状态类,但已超过熔断阈值,避免 LLM 在已熔断的 key 上继续消耗 round。');
|
|
101
|
+
lines.push('下一步:可主动调整 args 后再试,或通过 escalate_to_leader 上报。');
|
|
102
|
+
}
|
|
103
|
+
lines.push(`\nLLM_RECOVERY=${JSON.stringify({
|
|
104
|
+
code: 'TOOL_FAILURE_LOOP_TRIPPED',
|
|
105
|
+
message: lines.join(' '),
|
|
106
|
+
retryable: false,
|
|
107
|
+
fix: 'Do not retry the same toolName+args+errorKind combination. Escalate to leader or change strategy.',
|
|
108
|
+
failure_loop: {
|
|
109
|
+
toolName: decision.signature.toolName,
|
|
110
|
+
argsHash: decision.signature.argsHash,
|
|
111
|
+
errorKind: decision.signature.errorKind,
|
|
112
|
+
errorCode: decision.signature.errorCode,
|
|
113
|
+
count: decision.count,
|
|
114
|
+
requiresEscalation: decision.requiresEscalation,
|
|
115
|
+
},
|
|
116
|
+
})}`);
|
|
117
|
+
return lines.join('\n');
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* BaseAgent - Agent 基类
|
|
121
|
+
* 完整复刻 Python 版本
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* Worker 侧状态镜像类 system 槽位(contract pack + worker_runtime manifest)。
|
|
125
|
+
* upsertSystemContextMessage / initializeMessagesFromInherited 据此做单槽 in-place 更新,
|
|
126
|
+
* 治本「每轮 append 堆积占满上下文」。
|
|
127
|
+
*/
|
|
128
|
+
const WORKER_SYSTEM_SLOTS = [
|
|
129
|
+
{ kind: 'prefix', prefix: CONTRACT_PACK_MARKER },
|
|
130
|
+
{ kind: 'manifestSlot', slot: 'worker_runtime' },
|
|
131
|
+
];
|
|
132
|
+
/**
|
|
133
|
+
* 将 MCP SDK ContentBlock[] 转换为前端可渲染的 MessageContentPart[]。
|
|
134
|
+
* 检测 block._meta.lingxiao_app 标记,生成 mcp_app part。
|
|
135
|
+
* 无 lingxiao_app 标记的 block 按标准类型映射(text/image_url/image_blob_ref)。
|
|
136
|
+
*/
|
|
137
|
+
function extractMcpContentParts(content) {
|
|
138
|
+
const parts = [];
|
|
139
|
+
for (const block of content) {
|
|
140
|
+
if (!block || typeof block !== 'object')
|
|
141
|
+
continue;
|
|
142
|
+
// 检测 lingxiao_app 标记
|
|
143
|
+
const meta = block._meta;
|
|
144
|
+
const appMeta = meta?.lingxiao_app;
|
|
145
|
+
if (appMeta && typeof appMeta === 'object'
|
|
146
|
+
&& typeof appMeta.html === 'string' && appMeta.html.length > 0) {
|
|
147
|
+
parts.push({
|
|
148
|
+
type: 'mcp_app',
|
|
149
|
+
html: appMeta.html,
|
|
150
|
+
title: typeof appMeta.title === 'string' ? appMeta.title : undefined,
|
|
151
|
+
height: typeof appMeta.height === 'number'
|
|
152
|
+
? Math.min(Math.max(appMeta.height, 100), 800)
|
|
153
|
+
: 'auto',
|
|
154
|
+
actions: Array.isArray(appMeta.actions)
|
|
155
|
+
? appMeta.actions.filter((a) => typeof a?.label === 'string'
|
|
156
|
+
&& typeof a?.event === 'string')
|
|
157
|
+
: undefined,
|
|
158
|
+
});
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
// 标准类型映射
|
|
162
|
+
if (block.type === 'text' && typeof block.text === 'string') {
|
|
163
|
+
parts.push({ type: 'text', text: block.text });
|
|
164
|
+
}
|
|
165
|
+
// image / audio / resource 等类型按现有 image_url / image_blob_ref 映射
|
|
166
|
+
// (MCP SDK image block → 前端 image_url,data:mimeType;base64 格式)
|
|
167
|
+
}
|
|
168
|
+
return parts;
|
|
169
|
+
}
|
|
170
|
+
export class BaseAgent {
|
|
171
|
+
agentId;
|
|
172
|
+
name;
|
|
173
|
+
role;
|
|
174
|
+
systemPrompt;
|
|
175
|
+
toolNames;
|
|
176
|
+
skillNames;
|
|
177
|
+
llm;
|
|
178
|
+
tools;
|
|
179
|
+
bus;
|
|
180
|
+
tracker;
|
|
181
|
+
workspace;
|
|
182
|
+
sessionId;
|
|
183
|
+
model;
|
|
184
|
+
emitter;
|
|
185
|
+
db;
|
|
186
|
+
handle;
|
|
187
|
+
blackboardGraph;
|
|
188
|
+
workflowManager;
|
|
189
|
+
workflowEngine;
|
|
190
|
+
scheduledTaskManager;
|
|
191
|
+
/** Per-role git author identity for commit attribution. */
|
|
192
|
+
gitIdentity;
|
|
193
|
+
/** 带 sessionId 前缀的 bus 收件人名(避免跨会话消息串台) */
|
|
194
|
+
get busName() { return `${this.sessionId}:${this.name}`; }
|
|
195
|
+
/** 本会话 leader 的 bus 收件人名 */
|
|
196
|
+
get leaderBusName() { return `${this.sessionId}:leader`; }
|
|
197
|
+
messages = [];
|
|
198
|
+
stopped = false;
|
|
199
|
+
paused = false;
|
|
200
|
+
stalled = false;
|
|
201
|
+
interventionMessage = null;
|
|
202
|
+
currentLlmAbortController = null;
|
|
203
|
+
/** Leader 注入的 nudge 干预消息,在下轮 LLM 调用时作为 system 注入 */
|
|
204
|
+
nudgeMessage = null;
|
|
205
|
+
pendingInboxInterventionResult = null;
|
|
206
|
+
terminalRuntimeOutcome = null;
|
|
207
|
+
/**
|
|
208
|
+
* 复用同名 worker 时继承的历史对话(来自上一轮运行、已落在 DB 的 agent_conversation)。
|
|
209
|
+
*
|
|
210
|
+
* Why:worker 子进程永远以 isResume=false 启动,run() 会走 initializeMessages → this.messages=[],
|
|
211
|
+
* 把任何预置消息清空。所以"继承上下文"不能靠 WorkerProcessEntry 预先 addMessage(会被清掉),
|
|
212
|
+
* 必须由 run() 在初始化时显式识别这份历史并 weave 进消息序列。非空即代表"这是个被复用/复活的 worker"。
|
|
213
|
+
*
|
|
214
|
+
* 这些消息已存在于 DB(上一轮用同一 agentId 保存),run() 继承时不重复回写历史,
|
|
215
|
+
* 避免下次复用时 agent_conversation 翻倍。
|
|
216
|
+
*/
|
|
217
|
+
inheritedHistory = null;
|
|
218
|
+
/**
|
|
219
|
+
* 继承历史的语义:
|
|
220
|
+
* - 'resume':复活同一个任务(追问 / team 复活),把历史当作基底直接续,不再注入任务指令
|
|
221
|
+
* (续推由随后投递的 leaderMessage / inbox 驱动)。
|
|
222
|
+
* - 'new_task':复用同名 worker 跑一个新任务,历史作为背景上下文,再追加新任务指令与分隔说明。
|
|
223
|
+
*/
|
|
224
|
+
inheritedHistoryMode = 'new_task';
|
|
225
|
+
auditedDefaultBypassFallback = false;
|
|
226
|
+
runtimeState = new AgentRuntimeState();
|
|
227
|
+
MAX_TIMEOUT_RETRIES = runtimeConfig.llm.max_retries;
|
|
228
|
+
/** 外层 LLM 错误重试计数(与 LlmGuard 内部 5 次预算解耦,跨 catch 累加) */
|
|
229
|
+
llmErrorRetryCount = 0;
|
|
230
|
+
LLM_MAX_ERROR_RETRIES = runtimeConfig.llm.max_retries;
|
|
231
|
+
maxIterations;
|
|
232
|
+
maxRuntimeMinutes;
|
|
233
|
+
/** onConfigReload 退订函数:在 agent 终止时调用以防止监听器泄漏 */
|
|
234
|
+
_configReloadUnsubscribe = null;
|
|
235
|
+
MAX_COMPLETION_GUARD_RETRIES = 3;
|
|
236
|
+
/**
|
|
237
|
+
* 连续续跑上限。超过即强制接受当前输出收尾,打破「续跑→短 stop→续跑」空转。
|
|
238
|
+
* 任意真实工具调用会把计数清零,所以正常多轮工作不受影响。
|
|
239
|
+
*/
|
|
240
|
+
MAX_CONTINUATION_RETRIES = 5;
|
|
241
|
+
contextManager;
|
|
242
|
+
contextController;
|
|
243
|
+
interventionHandler;
|
|
244
|
+
roundExecutor;
|
|
245
|
+
lastRuntimeContextFingerprint = null;
|
|
246
|
+
/** 同 toolName+args 连续调用探针;超阈值打断当前 task */
|
|
247
|
+
toolLoopDetector = new ToolLoopDetector({ threshold: 5 });
|
|
248
|
+
/** context:overflow 事件取消订阅函数 */
|
|
249
|
+
_contextOverflowUnsub = null;
|
|
250
|
+
/** P0 紧急消息介入监听取消订阅函数 */
|
|
251
|
+
_p0InterventionUnsub = null;
|
|
252
|
+
/**
|
|
253
|
+
* 框架自动采集的工具产物轨迹 —— 不依赖 worker 主动在 attempt_completion 里
|
|
254
|
+
* 填 artifacts,也能让 Leader 看到 worker 真实改过哪些文件、跑过哪些命令。
|
|
255
|
+
* - file_create → files_created
|
|
256
|
+
* - structured_patch → files_modified
|
|
257
|
+
* - shell → commands_run(command 原文)
|
|
258
|
+
* - python_exec → commands_run(python: 首行)
|
|
259
|
+
* 与 attempt_completion 声明的 artifacts 在 Leader 端按文件路径去重合并。
|
|
260
|
+
*/
|
|
261
|
+
toolTrace = {
|
|
262
|
+
filesCreated: new Set(),
|
|
263
|
+
filesModified: new Set(),
|
|
264
|
+
commandsRun: [],
|
|
265
|
+
};
|
|
266
|
+
assumptionTracker;
|
|
267
|
+
assumptionTrackerProjectRoot;
|
|
268
|
+
/**
|
|
269
|
+
* DAG-based context state — 追踪消息间依赖关系,支持结构性无损压缩。
|
|
270
|
+
* 由 addMessage 自动维护; performContextReset 时用 structuralTrim 替代粗暴的"只留最近 15 条"。
|
|
271
|
+
* 导入: import { ContextDAG } from '../core/compress/ContextDAG.js';
|
|
272
|
+
*/
|
|
273
|
+
contextDAG = null;
|
|
274
|
+
/**
|
|
275
|
+
* worker 调用 attempt_completion 时捕获的结构化收尾结果。
|
|
276
|
+
* run() 结束后透传给 WorkerProcessEntry → task_complete payload → Leader。
|
|
277
|
+
*/
|
|
278
|
+
attemptCompletion;
|
|
279
|
+
/** 权限超时计数:连续超时 2 次则终止 agent */
|
|
280
|
+
permissionTimeoutCount = 0;
|
|
281
|
+
/** 标记 agent 应终止(权限超时等场景) */
|
|
282
|
+
shouldTerminate = false;
|
|
283
|
+
get toolCallCount() {
|
|
284
|
+
return this.runtimeState.toolCallCount;
|
|
285
|
+
}
|
|
286
|
+
set toolCallCount(value) {
|
|
287
|
+
this.runtimeState.toolCallCount = value;
|
|
288
|
+
}
|
|
289
|
+
get currentTaskId() {
|
|
290
|
+
return this.runtimeState.currentTaskId;
|
|
291
|
+
}
|
|
292
|
+
set currentTaskId(value) {
|
|
293
|
+
this.runtimeState.currentTaskId = value;
|
|
294
|
+
}
|
|
295
|
+
get currentTaskWorkingDirectory() {
|
|
296
|
+
return this.runtimeState.currentTaskWorkingDirectory;
|
|
297
|
+
}
|
|
298
|
+
set currentTaskWorkingDirectory(value) {
|
|
299
|
+
this.runtimeState.currentTaskWorkingDirectory = value;
|
|
300
|
+
}
|
|
301
|
+
get currentTaskWriteScope() {
|
|
302
|
+
return this.runtimeState.currentTaskWriteScope;
|
|
303
|
+
}
|
|
304
|
+
set currentTaskWriteScope(value) {
|
|
305
|
+
this.runtimeState.currentTaskWriteScope = value;
|
|
306
|
+
}
|
|
307
|
+
get currentContractAllowedScope() {
|
|
308
|
+
return this.runtimeState.currentContractAllowedScope;
|
|
309
|
+
}
|
|
310
|
+
/** WorkerProcessEntry 在 run 前从 payload 透传契约允许面(多契约已 intersect)。 */
|
|
311
|
+
setContractAllowedScope(scope) {
|
|
312
|
+
this.runtimeState.currentContractAllowedScope = scope;
|
|
313
|
+
}
|
|
314
|
+
get iteration() {
|
|
315
|
+
return this.runtimeState.iteration;
|
|
316
|
+
}
|
|
317
|
+
set iteration(value) {
|
|
318
|
+
this.runtimeState.iteration = value;
|
|
319
|
+
}
|
|
320
|
+
get rawXmlRetryCount() {
|
|
321
|
+
return this.runtimeState.rawXmlRetryCount;
|
|
322
|
+
}
|
|
323
|
+
set rawXmlRetryCount(value) {
|
|
324
|
+
this.runtimeState.rawXmlRetryCount = value;
|
|
325
|
+
}
|
|
326
|
+
get completionGuardRetryCount() {
|
|
327
|
+
return this.runtimeState.completionGuardRetryCount;
|
|
328
|
+
}
|
|
329
|
+
set completionGuardRetryCount(value) {
|
|
330
|
+
this.runtimeState.completionGuardRetryCount = value;
|
|
331
|
+
}
|
|
332
|
+
auditDefaultPermissionContext(source, reason) {
|
|
333
|
+
if (this.auditedDefaultBypassFallback || !this.db)
|
|
334
|
+
return;
|
|
335
|
+
this.auditedDefaultBypassFallback = true;
|
|
336
|
+
const record = {
|
|
337
|
+
sessionId: this.sessionId,
|
|
338
|
+
timestamp: Date.now(),
|
|
339
|
+
actor: this.name === 'leader' ? 'leader' : 'worker',
|
|
340
|
+
source,
|
|
341
|
+
mode: getLeaderDefaultPermissionContext().mode,
|
|
342
|
+
workerName: this.name === 'leader' ? undefined : this.name,
|
|
343
|
+
reason,
|
|
344
|
+
};
|
|
345
|
+
try {
|
|
346
|
+
this.db.updateSessionState(this.sessionId, SESSION_KEYS.PERMISSION_AUDIT_LOG, (current) => {
|
|
347
|
+
const list = Array.isArray(current) ? current : [];
|
|
348
|
+
return [...list.slice(-199), record];
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
catch { /* tolerate */ }
|
|
352
|
+
try {
|
|
353
|
+
this.emitter.emit('permission:audit', record);
|
|
354
|
+
}
|
|
355
|
+
catch { /* tolerate */ }
|
|
356
|
+
}
|
|
357
|
+
getPermissionContext() {
|
|
358
|
+
if (!this.db) {
|
|
359
|
+
return getLeaderDefaultPermissionContext();
|
|
360
|
+
}
|
|
361
|
+
const stored = this.db.getSessionState(this.sessionId, SESSION_KEYS.TOOL_PERMISSION_CONTEXT);
|
|
362
|
+
// 与 LeaderPermissionManager.loadPermissionContextFromState 对齐:
|
|
363
|
+
// session_state 为 null 时,worker 与 leader 统一读取中心化默认权限模式。
|
|
364
|
+
if (stored == null) {
|
|
365
|
+
this.auditDefaultPermissionContext('worker_default_permission_context', 'session 未设置权限上下文,worker 使用中心化默认权限模式。');
|
|
366
|
+
return getLeaderDefaultPermissionContext();
|
|
367
|
+
}
|
|
368
|
+
return normalizeToolPermissionContext(stored);
|
|
369
|
+
}
|
|
370
|
+
async requestPermissionFromLeader(toolName, reason) {
|
|
371
|
+
if (!this.bus || this.name === 'leader') {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
const requestId = `perm-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
375
|
+
const payload = {
|
|
376
|
+
requestId,
|
|
377
|
+
source: 'worker',
|
|
378
|
+
toolName,
|
|
379
|
+
requestedMode: isNetworkTool(toolName) ? 'networked' : 'dev',
|
|
380
|
+
reason,
|
|
381
|
+
workerName: this.name,
|
|
382
|
+
};
|
|
383
|
+
this.bus.send(this.busName, this.leaderBusName, 'permission_request', createPermissionRequestPayload(payload));
|
|
384
|
+
const permissionTimeoutMs = runtimeConfig.agents.permission_timeout_ms;
|
|
385
|
+
const response = await this.bus.waitForMessageType(this.busName, 'permission_response', permissionTimeoutMs);
|
|
386
|
+
if (!response) {
|
|
387
|
+
await this.logEvent('permission_request_timeout', {
|
|
388
|
+
requestId,
|
|
389
|
+
toolName,
|
|
390
|
+
reason,
|
|
391
|
+
timeoutMs: permissionTimeoutMs,
|
|
392
|
+
});
|
|
393
|
+
this.emitter.emit('agent:status', {
|
|
394
|
+
agentId: this.agentId,
|
|
395
|
+
agentName: this.name,
|
|
396
|
+
sessionId: this.sessionId,
|
|
397
|
+
status: `⚠️ 权限审批超时: ${toolName}`,
|
|
398
|
+
});
|
|
399
|
+
// 权限超时:标记终止,让 LLM 循环不再重试该工具
|
|
400
|
+
this.permissionTimeoutCount = (this.permissionTimeoutCount || 0) + 1;
|
|
401
|
+
if (this.permissionTimeoutCount >= 2) {
|
|
402
|
+
// 连续 2 次权限超时,终止 agent
|
|
403
|
+
this.shouldTerminate = true;
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
const parsed = readAgentControlMessage(response);
|
|
408
|
+
return parsed?.kind === 'permission_response' &&
|
|
409
|
+
parsed.requestId === requestId &&
|
|
410
|
+
parsed.decision === 'approved';
|
|
411
|
+
}
|
|
412
|
+
persistResumeCheckpoint(task) {
|
|
413
|
+
if (!this.db) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
saveAgentResumeCheckpoint(this.db, this.sessionId, {
|
|
418
|
+
agentId: this.agentId,
|
|
419
|
+
agentName: this.name,
|
|
420
|
+
agentRole: this.role,
|
|
421
|
+
taskId: task.id,
|
|
422
|
+
iteration: this.iteration,
|
|
423
|
+
toolCallCount: this.toolCallCount,
|
|
424
|
+
timestamp: Date.now() / 1000,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
catch (err) {
|
|
428
|
+
// DB 写入失败(SQLITE_BUSY / 连接关闭)不应杀死 worker 进程
|
|
429
|
+
agentLogger.warn(`[${this.name}] persistResumeCheckpoint failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
clearResumeCheckpoint() {
|
|
433
|
+
if (!this.db) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
clearAgentResumeCheckpoint(this.db, this.sessionId, this.agentId);
|
|
437
|
+
}
|
|
438
|
+
// 思考指令
|
|
439
|
+
static THINKING_INSTRUCTION = DEFAULT_THINKING_INSTRUCTION;
|
|
440
|
+
constructor(config) {
|
|
441
|
+
this.agentId = config.agentId;
|
|
442
|
+
this.name = config.name;
|
|
443
|
+
this.role = config.role;
|
|
444
|
+
this.systemPrompt = config.systemPrompt;
|
|
445
|
+
this.toolNames = config.toolNames;
|
|
446
|
+
this.skillNames = config.skillNames || [];
|
|
447
|
+
this.llm = config.llmClient;
|
|
448
|
+
this.tools = config.toolRegistry;
|
|
449
|
+
this.bus = config.messageBus;
|
|
450
|
+
this.tracker = config.tokenTracker;
|
|
451
|
+
this.workspace = config.workspace;
|
|
452
|
+
this.sessionId = config.sessionId;
|
|
453
|
+
this.model = config.model;
|
|
454
|
+
this.emitter = config.eventEmitter;
|
|
455
|
+
this.db = config.db;
|
|
456
|
+
this.handle = config.handle;
|
|
457
|
+
this.blackboardGraph = config.blackboardGraph;
|
|
458
|
+
this.workflowManager = config.workflowManager;
|
|
459
|
+
this.workflowEngine = config.workflowEngine;
|
|
460
|
+
this.scheduledTaskManager = config.scheduledTaskManager;
|
|
461
|
+
this.gitIdentity = config.gitIdentity;
|
|
462
|
+
this.maxIterations = config.maxIterations ?? AGENT_MAX_ITERATIONS;
|
|
463
|
+
this.maxRuntimeMinutes = config.maxRuntimeMinutes ?? AGENT_MAX_RUNTIME_MINUTES;
|
|
464
|
+
// 注册配置热加载回调:agents.max_iterations / agents.max_runtime_minutes 变化时
|
|
465
|
+
// 更新当前 agent 的迭代/运行时长上限,让 Settings 面板的修改对活跃 agent 立即生效。
|
|
466
|
+
// 仅当 agent 未显式指定 maxIterations/maxRuntimeMinutes 时才跟随全局配置(与构造逻辑一致)。
|
|
467
|
+
this._configReloadUnsubscribe = onConfigReload((cfg) => {
|
|
468
|
+
try {
|
|
469
|
+
if (config.maxIterations == null) {
|
|
470
|
+
this.maxIterations = cfg.agents.max_iterations;
|
|
471
|
+
}
|
|
472
|
+
if (config.maxRuntimeMinutes == null) {
|
|
473
|
+
this.maxRuntimeMinutes = cfg.agents.max_runtime_minutes;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
catch (e) {
|
|
477
|
+
// 参考 ModelManager.ts:279-288 的 try-catch 模式,不阻断其他 reload handler
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
const agentInitContextLimit = this.resolveContextLimit(this.model);
|
|
481
|
+
this.contextManager = new ContextManager(agentInitContextLimit, this.model, this.sessionId, this.db, this.llm, this.emitter, {
|
|
482
|
+
kind: 'agent',
|
|
483
|
+
workspace: this.workspace,
|
|
484
|
+
agentId: this.agentId,
|
|
485
|
+
agentName: this.name,
|
|
486
|
+
}, createLlmGuard);
|
|
487
|
+
this.contextController = new AgentContextController({
|
|
488
|
+
maxMessages: MAX_AGENT_MESSAGES,
|
|
489
|
+
});
|
|
490
|
+
this.interventionHandler = new AgentInterventionHandler({
|
|
491
|
+
bus: this.bus,
|
|
492
|
+
agentId: this.agentId,
|
|
493
|
+
busName: this.busName,
|
|
494
|
+
logger: agentLogger,
|
|
495
|
+
});
|
|
496
|
+
this.roundExecutor = new AgentRoundExecutor({
|
|
497
|
+
llm: this.llm,
|
|
498
|
+
toolRegistry: this.tools,
|
|
499
|
+
contextController: this.contextController,
|
|
500
|
+
interventionHandler: this.interventionHandler,
|
|
501
|
+
logger: agentLogger,
|
|
502
|
+
maxRounds: this.maxIterations,
|
|
503
|
+
model: this.model,
|
|
504
|
+
});
|
|
505
|
+
this._contextOverflowUnsub = this.emitter.subscribe('context:overflow', (data) => {
|
|
506
|
+
if (data.owner !== 'agent' || data.agentId !== this.agentId)
|
|
507
|
+
return;
|
|
508
|
+
agentLogger.warn(`Agent ${this.name} 上下文溢出,执行硬重置`);
|
|
509
|
+
this.performContextReset();
|
|
510
|
+
});
|
|
511
|
+
// 延迟初始化 ContextDAG (避免阻塞构造,只在首次需要时创建)
|
|
512
|
+
this.initContextDAG();
|
|
513
|
+
// 监听 P0 紧急消息(Leader 通过 send_message_to_agent 发送)。
|
|
514
|
+
//
|
|
515
|
+
// 仅当 P0 类型属于真正的"行动指令"(user_intervention / force_terminate)
|
|
516
|
+
// 时才 abort 当前 LLM。其他 P0(task_complete / task_failed / agent_health_critical
|
|
517
|
+
// 等)只是状态广播,不应破坏 worker 正在生成的长 tool_input。
|
|
518
|
+
this._p0InterventionUnsub = this.emitter.subscribe('message:bus:priority', (data) => {
|
|
519
|
+
const action = decideAgentP0Action(data, this.busName);
|
|
520
|
+
if (action.kind === 'abort' &&
|
|
521
|
+
this.currentLlmAbortController &&
|
|
522
|
+
this.interventionHandler.shouldAbort(data)) {
|
|
523
|
+
agentLogger.info(`[Intervention] 收到来自 @${action.sender} 的紧急指令(${action.type}),中断当前 LLM 调用`);
|
|
524
|
+
this.currentLlmAbortController.abort(`P0 ${action.type} from @${action.sender}`);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
resolveContextLimit(model) {
|
|
529
|
+
const providerCtx = getContextWindowSizeFromProvider(model);
|
|
530
|
+
if (providerCtx && providerCtx > 0)
|
|
531
|
+
return providerCtx;
|
|
532
|
+
const info = getModelDevInfo(model);
|
|
533
|
+
if (info?.contextLimit && info.contextLimit > 0)
|
|
534
|
+
return info.contextLimit;
|
|
535
|
+
const configuredLimit = Number(runtimeConfig.llm?.context_max_tokens);
|
|
536
|
+
return Number.isFinite(configuredLimit) && configuredLimit > 0 ? configuredLimit : LLM.CONTEXT_MAX_TOKENS;
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* 执行上下文压缩:优先用 ContextDAG 结构性压缩(每次从当前消息无状态重建图);
|
|
540
|
+
* fallback 到保留 system + 最近 15 条。
|
|
541
|
+
*/
|
|
542
|
+
performContextReset() {
|
|
543
|
+
try {
|
|
544
|
+
// ContextDAG 已初始化时,用结构性三趟压缩(依赖安全、配对安全、确定性)。
|
|
545
|
+
// 关键:每次从 this.messages 重建图(fromMessages),否则 DAG 为空、什么也压不掉。
|
|
546
|
+
if (this.contextDAG) {
|
|
547
|
+
this.contextDAG.fromMessages(this.messages);
|
|
548
|
+
const estimate = this.contextDAG.getActiveTokenEstimate();
|
|
549
|
+
if (estimate > 0) {
|
|
550
|
+
const target = Math.floor(estimate * 0.4); // 释放约 40% 空间
|
|
551
|
+
const result = this.contextDAG.structuralTrim(target);
|
|
552
|
+
if (result.tokensFreed > 0 || result.compressedCount > 0 || result.archivedCount > 0) {
|
|
553
|
+
// 用 toMessages 重建配对安全的消息序列(保留 role/tool_calls/tool_call_id,
|
|
554
|
+
// 仅旧内容替换为 breadcrumb;出口过 sanitizer 兜底)。
|
|
555
|
+
this.messages = this.contextDAG.toMessages();
|
|
556
|
+
agentLogger.info(`Agent ${this.name} DAG 结构性压缩完成: 释放 ~${result.tokensFreed} tokens, 压缩 ${result.compressedCount} 节点, 归档 ${result.archivedCount} 节点, 剩余 ${result.remainingCount} 条`);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
// Fallback: 传统硬重置
|
|
562
|
+
const systemMsg = this.messages[0];
|
|
563
|
+
const runtimeContractPack = this.messages.find(msg => this.isRuntimeContractPackMessage(msg));
|
|
564
|
+
this.messages = this.contextManager.hardReset({
|
|
565
|
+
messages: this.messages,
|
|
566
|
+
preservedMessages: [systemMsg, runtimeContractPack].filter(Boolean),
|
|
567
|
+
recentCount: 15,
|
|
568
|
+
reason: 'agent_context_overflow',
|
|
569
|
+
});
|
|
570
|
+
agentLogger.info(`Agent ${this.name} 上下文压缩完成,保留 ${this.messages.length} 条消息`);
|
|
571
|
+
}
|
|
572
|
+
catch (error) {
|
|
573
|
+
agentLogger.error(`Agent ${this.name} 上下文压缩失败:`, error);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
/** 延迟初始化 ContextDAG */
|
|
577
|
+
async initContextDAG() {
|
|
578
|
+
try {
|
|
579
|
+
const { ContextDAG } = await import('../core/compress/ContextDAG.js');
|
|
580
|
+
this.contextDAG = new ContextDAG();
|
|
581
|
+
}
|
|
582
|
+
catch {
|
|
583
|
+
// 模块不可用时静默降级
|
|
584
|
+
this.contextDAG = null;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* 添加消息到对话历史,带 Ring Buffer 保护
|
|
589
|
+
* #2 优化:在压缩前对大 tool_result 做提前裁剪,减少内存峰值
|
|
590
|
+
*/
|
|
591
|
+
addMessage(msg) {
|
|
592
|
+
// #2: tool_result 提前裁剪 — 超长 tool 输出只保留摘要,减少压缩前内存常驻
|
|
593
|
+
if (msg.role === 'tool' && typeof msg.content === 'string') {
|
|
594
|
+
const contentBytes = Buffer.byteLength(msg.content, 'utf8');
|
|
595
|
+
const TRUNCATE_THRESHOLD = 512 * 1024; // 512KB
|
|
596
|
+
if (contentBytes > TRUNCATE_THRESHOLD) {
|
|
597
|
+
const keep = msg.content.slice(0, TRUNCATE_THRESHOLD);
|
|
598
|
+
msg = { ...msg, content: keep + `\n\n[...tool output truncated: ${contentBytes} bytes total, kept first ${TRUNCATE_THRESHOLD} bytes]` };
|
|
599
|
+
agentLogger.debug(`Agent ${this.name} tool_result truncated from ${contentBytes} to ${TRUNCATE_THRESHOLD} bytes`);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
const before = this.messages.length;
|
|
603
|
+
this.messages = this.contextController.addMessage(msg, this.messages);
|
|
604
|
+
if (before >= MAX_AGENT_MESSAGES || this.messages.length < before + 1) {
|
|
605
|
+
agentLogger.debug(`Ring Buffer 触发,当前消息数: ${this.messages.length}`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
isRuntimeContractPackMessage(msg) {
|
|
609
|
+
return this.contextController.isRuntimeContractPackMessage(msg);
|
|
610
|
+
}
|
|
611
|
+
collapseRuntimeContractPackMessages(messages) {
|
|
612
|
+
return this.contextController.collapseContractPacks(messages);
|
|
613
|
+
}
|
|
614
|
+
upsertSystemContextMessage(content) {
|
|
615
|
+
// 定位 content 属于哪个 worker 状态镜像槽(确定性精确匹配,非启发式)。
|
|
616
|
+
let matched = null;
|
|
617
|
+
for (const matcher of WORKER_SYSTEM_SLOTS) {
|
|
618
|
+
if (matchesSystemSlot(content, matcher)) {
|
|
619
|
+
matched = matcher;
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (matched) {
|
|
624
|
+
const result = upsertSystemSlot(this.messages, matched, content);
|
|
625
|
+
this.messages = result.messages;
|
|
626
|
+
return result.message;
|
|
627
|
+
}
|
|
628
|
+
// 非槽内容(事件/指令):append。
|
|
629
|
+
const message = { role: 'system', content, timestamp: Date.now() / 1000 };
|
|
630
|
+
this.addMessage(message);
|
|
631
|
+
return message;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* 预置继承历史,供 run() 在初始化阶段 weave 进消息序列。
|
|
635
|
+
*
|
|
636
|
+
* Why 不直接 addMessage:worker 子进程以 isResume=false 启动,run() 会走
|
|
637
|
+
* initializeMessages → this.messages=[] 清空。所以历史必须存到 inheritedHistory 字段,
|
|
638
|
+
* 由 run() 优先识别后通过 initializeMessagesFromInherited 注入。
|
|
639
|
+
*/
|
|
640
|
+
seedInheritedHistory(history, mode = 'new_task') {
|
|
641
|
+
this.inheritedHistory = this.collapseRuntimeContractPackMessages(history);
|
|
642
|
+
this.inheritedHistoryMode = mode;
|
|
643
|
+
}
|
|
644
|
+
trimMessageBuffer(messages, protectedCount, maxMessages) {
|
|
645
|
+
return this.contextController.trimMessageBuffer(messages, protectedCount, maxMessages);
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* 获取增强的系统提示
|
|
649
|
+
* 返回稳定核心(可被 Anthropic cache 缓存)+ 动态附加(不缓存)
|
|
650
|
+
*/
|
|
651
|
+
getEnhancedSystemPrompt() {
|
|
652
|
+
let prompt = this.systemPrompt;
|
|
653
|
+
if (ENABLE_THINKING_INSTRUCTION) {
|
|
654
|
+
prompt = BaseAgent.THINKING_INSTRUCTION + '\n\n' + prompt;
|
|
655
|
+
}
|
|
656
|
+
// 自动注入会话空间信息(替代已移除的 session_info 工具)
|
|
657
|
+
prompt += '\n\n--- 会话空间 ---\n';
|
|
658
|
+
prompt += `会话 ID: ${this.sessionId}\n`;
|
|
659
|
+
prompt += `工作区根目录: ${this.workspace}\n`;
|
|
660
|
+
const sessionDir = `${this.workspace}/.lingxiao/sessions/${this.sessionId}`;
|
|
661
|
+
prompt += `Session 目录: ${sessionDir}\n`;
|
|
662
|
+
prompt += `Scratchpad 目录: ${sessionDir}/scratchpad\n`;
|
|
663
|
+
prompt += `Context 目录: ${sessionDir}/context\n`;
|
|
664
|
+
prompt += '\n使用约定:\n';
|
|
665
|
+
prompt += '- shell 命令可直接使用环境变量:$LINGXIAO_SESSION_ID / $LINGXIAO_SESSION_DIR / $LINGXIAO_SCRATCHPAD_DIR\n';
|
|
666
|
+
prompt += '- 当前任务 scratchpad 命名规则:T-<任务号>_<角色>.md\n';
|
|
667
|
+
prompt += '- 路径以上述返回值为准,scratchpad/ 相对路径使用注入的真实目录计算\n';
|
|
668
|
+
prompt += '- 查找当前任务报告时,可优先读取当前 Scratchpad\n';
|
|
669
|
+
// 工作笔记能力说明(稳定内容,可以缓存)
|
|
670
|
+
prompt += '\n\n--- 工作笔记 ---\n'
|
|
671
|
+
+ '你可以通过 `write_work_note` 工具记录当前进展摘要,任务指令中包含详细字段说明和必填要求。\n'
|
|
672
|
+
+ '如需了解前序任务的成果,任务指令中的 Context Manifest 包含前序笔记摘要;\n'
|
|
673
|
+
+ '需要完整细节时,调用 `read_work_notes` 读取完整笔记。\n'
|
|
674
|
+
+ '收到 Leader 的 `request_work_note` 消息时,请主动更新你的工作笔记。';
|
|
675
|
+
prompt += '\n\n--- 可验证假设 ---\n'
|
|
676
|
+
+ '在基于未确认的 API 行为、类型结构、文件内容或测试结果继续实现前,先调用 `declare_assumption`。\n'
|
|
677
|
+
+ '每个假设必须包含 verification_type、target、expected;expected 是精确证据文本,不是置信度或主观判断。\n'
|
|
678
|
+
+ '相关文件被写入后系统会自动验证;若假设被证伪,你会收到 system 反馈,必须停止当前错误方向并修正理解。';
|
|
679
|
+
return prompt;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* 获取动态上下文(长期记忆索引等)— 作为统一 Context Manifest 注入,
|
|
683
|
+
* 不混入主 system prompt,避免动态内容变化导致 Anthropic prompt cache 失效
|
|
684
|
+
*/
|
|
685
|
+
getDynamicContext() {
|
|
686
|
+
try {
|
|
687
|
+
if (getConfigValue('memory.enabled') === false)
|
|
688
|
+
return null;
|
|
689
|
+
const memoryManager = new MemoryManager(this.workspace);
|
|
690
|
+
const memoryContent = memoryManager.getAllIndexContent({ tokenBudget: 1_200, maxEntriesPerScope: 12 });
|
|
691
|
+
if (memoryContent) {
|
|
692
|
+
return renderContextManifest({
|
|
693
|
+
scope: 'worker',
|
|
694
|
+
slot: 'worker_runtime',
|
|
695
|
+
sessionId: this.sessionId,
|
|
696
|
+
persistentMemoryIndex: memoryContent,
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
catch { /* memory not available */ }
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
buildRuntimeContextFingerprint() {
|
|
704
|
+
const state = this.contextManager.getRuntimeState();
|
|
705
|
+
if (state.recentFiles.length === 0 &&
|
|
706
|
+
state.warningLevel === 'ok' &&
|
|
707
|
+
state.consecutiveFailures === 0 &&
|
|
708
|
+
!state.lastArchivePath &&
|
|
709
|
+
state.compactHistory.length === 0) {
|
|
710
|
+
return null;
|
|
711
|
+
}
|
|
712
|
+
return JSON.stringify({
|
|
713
|
+
warningLevel: state.warningLevel,
|
|
714
|
+
consecutiveFailures: state.consecutiveFailures,
|
|
715
|
+
lastArchivePath: state.lastArchivePath || null,
|
|
716
|
+
lastCompact: state.lastCompact
|
|
717
|
+
? {
|
|
718
|
+
timestamp: state.lastCompact.timestamp,
|
|
719
|
+
oldTokens: state.lastCompact.oldTokens,
|
|
720
|
+
newTokens: state.lastCompact.newTokens,
|
|
721
|
+
archivePath: state.lastCompact.archivePath || null,
|
|
722
|
+
}
|
|
723
|
+
: null,
|
|
724
|
+
recentFiles: state.recentFiles.map((file) => ({
|
|
725
|
+
path: file.path,
|
|
726
|
+
timestamp: file.timestamp,
|
|
727
|
+
charCount: file.charCount,
|
|
728
|
+
tokenEstimate: file.tokenEstimate,
|
|
729
|
+
})),
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
buildAgentArtifactManifest() {
|
|
733
|
+
const toolTrace = this.buildToolTraceSnapshot();
|
|
734
|
+
const artifacts = this.attemptCompletion?.artifacts;
|
|
735
|
+
const verification = this.attemptCompletion?.verification;
|
|
736
|
+
if (toolTrace.files_created.length === 0 &&
|
|
737
|
+
toolTrace.files_modified.length === 0 &&
|
|
738
|
+
toolTrace.commands_run.length === 0 &&
|
|
739
|
+
!this.attemptCompletion?.summary &&
|
|
740
|
+
!artifacts &&
|
|
741
|
+
!verification?.length &&
|
|
742
|
+
!this.attemptCompletion?.evidence_refs?.length &&
|
|
743
|
+
!this.attemptCompletion?.contract_compliance) {
|
|
744
|
+
return [];
|
|
745
|
+
}
|
|
746
|
+
return [{
|
|
747
|
+
source: 'worker_runtime',
|
|
748
|
+
taskId: this.currentTaskId || undefined,
|
|
749
|
+
agentId: this.agentId,
|
|
750
|
+
summary: this.attemptCompletion?.summary,
|
|
751
|
+
filesCreated: [...(artifacts?.files_created ?? []), ...toolTrace.files_created],
|
|
752
|
+
filesModified: [...(artifacts?.files_modified ?? []), ...toolTrace.files_modified],
|
|
753
|
+
commandsRun: [...(artifacts?.commands_run ?? []), ...toolTrace.commands_run],
|
|
754
|
+
evidenceRefs: this.attemptCompletion?.evidence_refs,
|
|
755
|
+
contractCompliance: this.attemptCompletion?.contract_compliance,
|
|
756
|
+
toolTrace: {
|
|
757
|
+
filesCreated: toolTrace.files_created,
|
|
758
|
+
filesModified: toolTrace.files_modified,
|
|
759
|
+
commandsRun: toolTrace.commands_run,
|
|
760
|
+
},
|
|
761
|
+
verification,
|
|
762
|
+
nextSteps: this.attemptCompletion?.next_steps,
|
|
763
|
+
}];
|
|
764
|
+
}
|
|
765
|
+
async appendRuntimeContextManifestIfChanged() {
|
|
766
|
+
const fingerprint = this.buildRuntimeContextFingerprint();
|
|
767
|
+
const artifactManifest = this.buildAgentArtifactManifest();
|
|
768
|
+
const combinedFingerprint = JSON.stringify({
|
|
769
|
+
runtime: fingerprint,
|
|
770
|
+
artifacts: artifactManifest,
|
|
771
|
+
});
|
|
772
|
+
if ((!fingerprint && artifactManifest.length === 0) || combinedFingerprint === this.lastRuntimeContextFingerprint) {
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
this.lastRuntimeContextFingerprint = combinedFingerprint;
|
|
776
|
+
// worker_runtime 槽 in-place 注入(带 slot 标记),单槽不堆积;不每轮落库
|
|
777
|
+
// (manifest 是可重算状态镜像,worker 子进程内存即真理,崩溃重算无损)。
|
|
778
|
+
this.upsertSystemContextMessage(renderContextManifest({
|
|
779
|
+
scope: 'worker',
|
|
780
|
+
slot: 'worker_runtime',
|
|
781
|
+
sessionId: this.sessionId,
|
|
782
|
+
runtime: this.contextManager.getRuntimeState(),
|
|
783
|
+
agentArtifacts: artifactManifest,
|
|
784
|
+
}));
|
|
785
|
+
return true;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* 获取工具定义。尊重角色工具白名单,避免所有 agent 都携带全量工具 schema。
|
|
789
|
+
* 接入 ToolPruner:硬模式过滤 + 确定性 token 预算裁剪。
|
|
790
|
+
*/
|
|
791
|
+
async getToolDefinitions(task) {
|
|
792
|
+
const allowedTools = this.toolNames.length > 0 ? this.toolNames : undefined;
|
|
793
|
+
const modes = this.db
|
|
794
|
+
? resolveModeRuntimeProjection({
|
|
795
|
+
sessionId: this.sessionId,
|
|
796
|
+
db: this.db,
|
|
797
|
+
permissionContext: this.getPermissionContext(),
|
|
798
|
+
blackboardAvailable: Boolean(this.blackboardGraph),
|
|
799
|
+
})
|
|
800
|
+
: undefined;
|
|
801
|
+
let callerInTeamRoster = false;
|
|
802
|
+
let callerIsTeamLeader = false;
|
|
803
|
+
if (modes?.collaboration.teamEnabled && this.db) {
|
|
804
|
+
try {
|
|
805
|
+
const member = getTeamMemberRegistry().getByName(this.name, this.sessionId);
|
|
806
|
+
callerInTeamRoster = Boolean(member);
|
|
807
|
+
callerIsTeamLeader = member?.role === 'leader';
|
|
808
|
+
}
|
|
809
|
+
catch {
|
|
810
|
+
callerInTeamRoster = false;
|
|
811
|
+
callerIsTeamLeader = false;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
let definitions = this.tools.getDefinitions(allowedTools, {
|
|
815
|
+
scope: 'worker',
|
|
816
|
+
...(modes
|
|
817
|
+
? {
|
|
818
|
+
modePolicy: {
|
|
819
|
+
modes,
|
|
820
|
+
actor: callerInTeamRoster ? 'team_member' : 'worker',
|
|
821
|
+
agentName: this.name,
|
|
822
|
+
callerInTeamRoster,
|
|
823
|
+
callerIsTeamLeader,
|
|
824
|
+
},
|
|
825
|
+
}
|
|
826
|
+
: {}),
|
|
827
|
+
});
|
|
828
|
+
if (!definitions || definitions.length === 0)
|
|
829
|
+
return definitions;
|
|
830
|
+
const officeMode = this.db?.getSessionState(this.sessionId, SESSION_KEYS.OFFICE_MODE_ACTIVE) === 'true';
|
|
831
|
+
if (!officeMode) {
|
|
832
|
+
const officeNames = new Set(OFFICE_TOOL_NAMES);
|
|
833
|
+
definitions = definitions.filter((tool) => !officeNames.has(tool.function.name));
|
|
834
|
+
}
|
|
835
|
+
// 推断执行模式
|
|
836
|
+
const mode = this.inferToolPrunerMode();
|
|
837
|
+
const tokenBudget = BUDGET.TOOLS_DEFAULT_BUDGET;
|
|
838
|
+
const result = await pruneTools(definitions, {
|
|
839
|
+
mode,
|
|
840
|
+
tokenBudget,
|
|
841
|
+
// Keep the worker hot path deterministic: semantic tool selection is an
|
|
842
|
+
// extra LLM request before the real worker round and can dominate latency.
|
|
843
|
+
context: {
|
|
844
|
+
sessionId: this.sessionId,
|
|
845
|
+
agentId: this.agentId,
|
|
846
|
+
agentName: this.name,
|
|
847
|
+
role: this.role,
|
|
848
|
+
task,
|
|
849
|
+
recentMessages: this.messages,
|
|
850
|
+
},
|
|
851
|
+
});
|
|
852
|
+
if (result.removedTools.length > 0) {
|
|
853
|
+
agentLogger.debug(`[ToolPruner] ${this.name}: removed ${result.removedTools.length} tools (${result.originalTokens}→${result.finalTokens} tokens, status=${result.selectionStatus})`);
|
|
854
|
+
}
|
|
855
|
+
return result.tools;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* 推断 ToolPruner 执行模式:根据 agent 的 toolNames 判断。
|
|
859
|
+
*/
|
|
860
|
+
inferToolPrunerMode() {
|
|
861
|
+
const hasBughunt = this.toolNames.some((t) => BUGHUNT_MODE_TOOL_NAMES.includes(t));
|
|
862
|
+
if (hasBughunt)
|
|
863
|
+
return 'bughunt';
|
|
864
|
+
const officeMode = this.db?.getSessionState(this.sessionId, SESSION_KEYS.OFFICE_MODE_ACTIVE) === 'true';
|
|
865
|
+
if (officeMode)
|
|
866
|
+
return 'office';
|
|
867
|
+
const hasBlackboard = Boolean(this.blackboardGraph) && this.toolNames.some(t => t === 'blackboard');
|
|
868
|
+
if (hasBlackboard)
|
|
869
|
+
return 'blackboard';
|
|
870
|
+
return 'normal';
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* 记录 Agent 事件到数据库
|
|
874
|
+
*/
|
|
875
|
+
async logEvent(eventType, content) {
|
|
876
|
+
if (this.db) {
|
|
877
|
+
try {
|
|
878
|
+
this.db.insertAgentLog({
|
|
879
|
+
session_id: this.sessionId,
|
|
880
|
+
agent_id: this.agentId,
|
|
881
|
+
agent_name: this.name,
|
|
882
|
+
agent_role: this.role,
|
|
883
|
+
task_id: this.currentTaskId || '',
|
|
884
|
+
event_type: eventType,
|
|
885
|
+
content: JSON.stringify(content),
|
|
886
|
+
timestamp: Date.now() / 1000,
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
catch (err) {
|
|
890
|
+
agentLogger.debug(`[${this.name}] logEvent(${eventType}) DB write failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
getAssumptionTracker() {
|
|
895
|
+
if (!this.db)
|
|
896
|
+
return undefined;
|
|
897
|
+
const projectRoot = this.currentTaskWorkingDirectory || this.workspace;
|
|
898
|
+
if (!this.assumptionTracker || this.assumptionTrackerProjectRoot !== projectRoot) {
|
|
899
|
+
this.assumptionTracker = new AssumptionTracker({
|
|
900
|
+
db: this.db,
|
|
901
|
+
emitter: this.emitter,
|
|
902
|
+
logger: agentLogger,
|
|
903
|
+
sessionId: this.sessionId,
|
|
904
|
+
projectRoot,
|
|
905
|
+
});
|
|
906
|
+
this.assumptionTrackerProjectRoot = projectRoot;
|
|
907
|
+
}
|
|
908
|
+
return this.assumptionTracker;
|
|
909
|
+
}
|
|
910
|
+
async handleAssumptionFeedback(batch) {
|
|
911
|
+
if (batch.falsified.length === 0)
|
|
912
|
+
return;
|
|
913
|
+
const content = [
|
|
914
|
+
'[假设证伪] 以下假设已被运行时证据证伪,请停止当前错误方向,修正理解后继续。',
|
|
915
|
+
...batch.falsified.map((item) => `- ${item.id}: ${item.evidence}${item.dependents.length > 0 ? `; dependents=${item.dependents.join(',')}` : ''}`),
|
|
916
|
+
].join('\n');
|
|
917
|
+
const message = { role: 'system', content };
|
|
918
|
+
this.addMessage(message);
|
|
919
|
+
try {
|
|
920
|
+
await this.db?.saveAgentMessage?.(this.sessionId, this.agentId, this.name, message);
|
|
921
|
+
}
|
|
922
|
+
catch (error) {
|
|
923
|
+
agentLogger.warn(`[${this.name}] 保存假设证伪反馈失败: ${error instanceof Error ? error.message : String(error)}`);
|
|
924
|
+
}
|
|
925
|
+
this.emitter.emit('agent:message', {
|
|
926
|
+
agentId: this.agentId,
|
|
927
|
+
message: content,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* 构建任务提示词,包含技能注入
|
|
932
|
+
*/
|
|
933
|
+
buildTaskPrompt(task) {
|
|
934
|
+
const globalSkills = join(homedir(), '.lingxiao', 'skills');
|
|
935
|
+
const projectSkills = join(this.workspace, '.lingxiao', 'skills');
|
|
936
|
+
const disabledNames = resolveDisabledSkillNames();
|
|
937
|
+
const availableSkills = collectAvailableSkills(this.workspace, { disabledNames });
|
|
938
|
+
const taskDescription = task.description;
|
|
939
|
+
const explicitSkills = resolveExplicitSkillMentions(`${taskDescription}\n${this.systemPrompt}`, availableSkills);
|
|
940
|
+
const officeMode = this.db?.getSessionState(this.sessionId, SESSION_KEYS.OFFICE_MODE_ACTIVE) === 'true';
|
|
941
|
+
const officeSkill = officeMode && availableSkills.some((skill) => skill.name === OFFICE_SUITE_SKILL_NAME)
|
|
942
|
+
? [OFFICE_SUITE_SKILL_NAME]
|
|
943
|
+
: [];
|
|
944
|
+
const mergedSkillNames = Array.from(new Set([...this.skillNames, ...explicitSkills, ...officeSkill]));
|
|
945
|
+
const injectedSkills = buildSkillInjection(mergedSkillNames, availableSkills, {
|
|
946
|
+
maxTotalChars: 18_000,
|
|
947
|
+
maxPerSkillChars: 7_500,
|
|
948
|
+
});
|
|
949
|
+
if (injectedSkills.names.length > 0) {
|
|
950
|
+
agentLogger.info(`注入技能: ${injectedSkills.names.join(', ')}`);
|
|
951
|
+
// Record real usage so distill's C gate can later refine proven skills (N5-A).
|
|
952
|
+
try {
|
|
953
|
+
const usageStore = new AssetUsageStore(join(this.workspace, '.lingxiao'));
|
|
954
|
+
for (const name of injectedSkills.names) {
|
|
955
|
+
usageStore.recordUsage({
|
|
956
|
+
assetRef: `skills/${name}`,
|
|
957
|
+
kind: 'skill_injected',
|
|
958
|
+
sessionId: this.sessionId,
|
|
959
|
+
taskId: task.id,
|
|
960
|
+
timestamp: Date.now(),
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
catch { /* usage tracking is best-effort, never breaks injection */ }
|
|
965
|
+
}
|
|
966
|
+
const configuredToolNames = new Set(this.toolNames);
|
|
967
|
+
const toolSurface = {
|
|
968
|
+
tools: this.toolNames.length > 0 ? this.toolNames : this.tools.getAll().map((tool) => tool.name),
|
|
969
|
+
required: [
|
|
970
|
+
...REQUIRED_AGENT_CONTRACT_TOOLS,
|
|
971
|
+
...REQUIRED_TEAM_CONTRACT_TOOLS.filter((name) => configuredToolNames.has(name)),
|
|
972
|
+
],
|
|
973
|
+
mode: this.inferToolPrunerMode(),
|
|
974
|
+
};
|
|
975
|
+
const enabledPlugins = discoverPlugins(this.workspace).filter((plugin) => plugin.enabled);
|
|
976
|
+
const pluginSurface = {
|
|
977
|
+
sources: enabledPlugins.map((plugin) => ({
|
|
978
|
+
id: plugin.id,
|
|
979
|
+
version: plugin.version,
|
|
980
|
+
path: plugin.path,
|
|
981
|
+
manifestPath: plugin.manifestPath,
|
|
982
|
+
scope: plugin.scope,
|
|
983
|
+
enabled: plugin.enabled,
|
|
984
|
+
})),
|
|
985
|
+
runtime: enabledPlugins.flatMap((plugin) => [
|
|
986
|
+
...(plugin.contributions.skills.length > 0 ? [`${plugin.id}:skills`] : []),
|
|
987
|
+
...(plugin.contributions.mcp.length > 0 ? [`${plugin.id}:mcp`] : []),
|
|
988
|
+
]),
|
|
989
|
+
nonRuntime: enabledPlugins.flatMap((plugin) => [
|
|
990
|
+
...(plugin.contributions.apps.length > 0 ? [`${plugin.id}:apps`] : []),
|
|
991
|
+
...(plugin.contributions.assets.length > 0 ? [`${plugin.id}:assets`] : []),
|
|
992
|
+
...(plugin.contributions.tools.length > 0 ? [`${plugin.id}:tools(non-runtime)`] : []),
|
|
993
|
+
...(plugin.contributions.hooks.length > 0 ? [`${plugin.id}:hooks(non-runtime)`] : []),
|
|
994
|
+
...(plugin.contributions.scripts.length > 0 ? [`${plugin.id}:scripts(non-runtime)`] : []),
|
|
995
|
+
]),
|
|
996
|
+
};
|
|
997
|
+
const mcpSurface = {
|
|
998
|
+
servers: enabledPlugins.flatMap((plugin) => plugin.contributions.mcp.map((mcp) => ({
|
|
999
|
+
id: mcp.server.id,
|
|
1000
|
+
name: mcp.server.name,
|
|
1001
|
+
version: mcp.server.registry?.version || mcp.pluginVersion,
|
|
1002
|
+
schemaVersion: mcp.server.registry?.source_id,
|
|
1003
|
+
}))),
|
|
1004
|
+
};
|
|
1005
|
+
const runtimeModes = this.db
|
|
1006
|
+
? resolveModeRuntimeProjection({
|
|
1007
|
+
sessionId: this.sessionId,
|
|
1008
|
+
db: this.db,
|
|
1009
|
+
permissionContext: this.getPermissionContext(),
|
|
1010
|
+
blackboardAvailable: Boolean(this.blackboardGraph),
|
|
1011
|
+
})
|
|
1012
|
+
: undefined;
|
|
1013
|
+
let teamCommunicationEnabled = false;
|
|
1014
|
+
if (runtimeModes?.collaboration.teamEnabled && this.db) {
|
|
1015
|
+
try {
|
|
1016
|
+
teamCommunicationEnabled = Boolean(getTeamMemberRegistry().getByName(this.name, this.sessionId));
|
|
1017
|
+
}
|
|
1018
|
+
catch {
|
|
1019
|
+
teamCommunicationEnabled = false;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const activeModes = [
|
|
1023
|
+
this.inferToolPrunerMode(),
|
|
1024
|
+
...(teamCommunicationEnabled ? ['team'] : []),
|
|
1025
|
+
...(officeMode ? ['office'] : []),
|
|
1026
|
+
...(this.blackboardGraph ? ['blackboard'] : []),
|
|
1027
|
+
];
|
|
1028
|
+
const modes = {
|
|
1029
|
+
active: Array.from(new Set(activeModes.filter((mode) => mode && mode !== 'normal'))),
|
|
1030
|
+
notes: [
|
|
1031
|
+
'mode injection is an additive surface; core contracts remain Context Manifest, ToolRegistry, MCP, and blackboard.',
|
|
1032
|
+
],
|
|
1033
|
+
};
|
|
1034
|
+
// 全模式隔离:遍历激活模式,对声明了 promptBuilder.worker 的模式注入协议文本。
|
|
1035
|
+
// office 激活时 worker 不仅拿到 skill,还要拿到协议文本(JS 路线 + 审美门槛 + 验收)。
|
|
1036
|
+
// 模式关闭时其 prompt 文本完全不进 worker 上下文。
|
|
1037
|
+
const modeProtocolSections = [];
|
|
1038
|
+
if (this.db) {
|
|
1039
|
+
const activeModeMap = resolveActiveModes(this.db, this.sessionId);
|
|
1040
|
+
for (const modeId of ALL_MODE_IDS) {
|
|
1041
|
+
if (!activeModeMap[modeId])
|
|
1042
|
+
continue;
|
|
1043
|
+
const workerBuilder = MODE_REGISTRY[modeId].promptBuilder?.worker;
|
|
1044
|
+
if (!workerBuilder)
|
|
1045
|
+
continue;
|
|
1046
|
+
const content = workerBuilder();
|
|
1047
|
+
if (!content)
|
|
1048
|
+
continue;
|
|
1049
|
+
modeProtocolSections.push({ title: `${modeId} Mode Protocol`, content });
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
return buildWorkerTaskPrompt({
|
|
1053
|
+
task: {
|
|
1054
|
+
id: task.id,
|
|
1055
|
+
subject: task.subject,
|
|
1056
|
+
description: taskDescription,
|
|
1057
|
+
context: task.context,
|
|
1058
|
+
working_directory: task.working_directory,
|
|
1059
|
+
write_scope: task.write_scope,
|
|
1060
|
+
},
|
|
1061
|
+
workspace: this.workspace,
|
|
1062
|
+
sessionId: this.sessionId,
|
|
1063
|
+
role: this.role,
|
|
1064
|
+
globalSkillsDir: globalSkills,
|
|
1065
|
+
projectSkillsDir: projectSkills,
|
|
1066
|
+
injectedSkills,
|
|
1067
|
+
toolSurface,
|
|
1068
|
+
pluginSurface,
|
|
1069
|
+
mcpSurface,
|
|
1070
|
+
modes,
|
|
1071
|
+
manifestSections: modeProtocolSections.length > 0 ? modeProtocolSections : undefined,
|
|
1072
|
+
agentArtifacts: this.buildAgentArtifactManifest(),
|
|
1073
|
+
blackboardEnabled: this.toolNames.some(t => t === 'blackboard'),
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* 初始化消息列表
|
|
1078
|
+
*/
|
|
1079
|
+
async initializeMessages(task) {
|
|
1080
|
+
this.messages = [];
|
|
1081
|
+
// 多模态上下文注入
|
|
1082
|
+
const initialMessages = [];
|
|
1083
|
+
const MAX_INITIAL_IMAGES = normalizeImageRetainRounds(getConfigValue('advanced.image_history_retain_rounds'));
|
|
1084
|
+
if (this.db) {
|
|
1085
|
+
// 获取最近的多模态消息
|
|
1086
|
+
try {
|
|
1087
|
+
const recentHistory = await this.db.getRecentMultimodalMessages?.(this.sessionId, MAX_INITIAL_IMAGES);
|
|
1088
|
+
if (recentHistory) {
|
|
1089
|
+
for (const msg of recentHistory) {
|
|
1090
|
+
if (typeof msg.content === 'object' && Array.isArray(msg.content)) {
|
|
1091
|
+
initialMessages.push(msg);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
catch (e) {
|
|
1097
|
+
agentLogger.warn(`获取多模态上下文失败:`, e);
|
|
1098
|
+
}
|
|
1099
|
+
if (initialMessages.length > 0) {
|
|
1100
|
+
agentLogger.info(`注入了 ${initialMessages.length} 条多模态上下文`);
|
|
1101
|
+
initialMessages.push({
|
|
1102
|
+
role: 'assistant',
|
|
1103
|
+
content: '我已经查看了会话中提供的视觉信息。现在我准备好处理你分配的任务了。',
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
const taskPrompt = this.buildTaskPrompt(task);
|
|
1108
|
+
this.addMessage({
|
|
1109
|
+
role: 'system',
|
|
1110
|
+
content: this.getEnhancedSystemPrompt(),
|
|
1111
|
+
});
|
|
1112
|
+
// 动态上下文(记忆索引等)作为独立 system 消息注入
|
|
1113
|
+
// 这样动态内容变化不会导致 Anthropic prompt cache 失效
|
|
1114
|
+
const dynamicContext = this.getDynamicContext();
|
|
1115
|
+
if (dynamicContext) {
|
|
1116
|
+
// worker_runtime 槽 in-place(与每轮 appendRuntimeContextManifestIfChanged 同槽),单槽不堆积。
|
|
1117
|
+
this.upsertSystemContextMessage(dynamicContext);
|
|
1118
|
+
}
|
|
1119
|
+
for (const msg of initialMessages) {
|
|
1120
|
+
this.addMessage(msg);
|
|
1121
|
+
}
|
|
1122
|
+
this.addMessage({
|
|
1123
|
+
role: 'user',
|
|
1124
|
+
content: `${'='.repeat(40)}\n任务指令:\n${'='.repeat(40)}\n${taskPrompt}`,
|
|
1125
|
+
});
|
|
1126
|
+
// 保存初始对话
|
|
1127
|
+
if (this.db) {
|
|
1128
|
+
for (const msg of this.messages) {
|
|
1129
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, msg);
|
|
1130
|
+
}
|
|
1131
|
+
await this.db.saveAgentState?.({
|
|
1132
|
+
session_id: this.sessionId,
|
|
1133
|
+
agent_id: this.agentId,
|
|
1134
|
+
agent_name: this.name,
|
|
1135
|
+
agent_role: this.role,
|
|
1136
|
+
task_id: task.id,
|
|
1137
|
+
status: 'running',
|
|
1138
|
+
stopped: 0,
|
|
1139
|
+
iteration: 0,
|
|
1140
|
+
timestamp: Date.now() / 1000,
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
this.persistResumeCheckpoint(task);
|
|
1144
|
+
}
|
|
1145
|
+
/**
|
|
1146
|
+
* 继承历史对话的初始化:worker 子进程总以 isResume=false 启动,run() 默认会
|
|
1147
|
+
* initializeMessages → this.messages=[],把 WorkerProcessEntry 预注入的历史清空。
|
|
1148
|
+
* 所以"继承上下文"统一收敛到这里,由 run() 在 inheritedHistory 非空时优先走本方法。
|
|
1149
|
+
*
|
|
1150
|
+
* 两种语义(inheritedHistoryMode):
|
|
1151
|
+
* - 'resume'(追问 / team 复活同一个任务):历史即完整对话基底,不再注入任务指令,
|
|
1152
|
+
* 后续推进由随后投递的 leaderMessage / inbox 干预驱动;恢复 toolCallCount 进度。
|
|
1153
|
+
* - 'new_task'(复用同名 worker 跑新任务):历史作为背景上下文,追加一条 user 分隔说明
|
|
1154
|
+
* + 新任务指令 user 消息;进度按新任务从 0 起(initializeTaskScope 已在 run 开头重置)。
|
|
1155
|
+
*
|
|
1156
|
+
* 持久化:历史早已在 DB(上一轮同 agentId 保存),只回写本次新追加的消息,
|
|
1157
|
+
* 避免下次复用时 agent_conversation 翻倍。
|
|
1158
|
+
*/
|
|
1159
|
+
async initializeMessagesFromInherited(task, recoveredIteration = 0, recoveredToolCallCount = 0) {
|
|
1160
|
+
const inherited = this.inheritedHistory ?? [];
|
|
1161
|
+
// 收敛继承历史中 append-only 累积的状态镜像槽位(contract pack + worker manifest),
|
|
1162
|
+
// 每槽只留最后一条,治本历史残留堆积(inheritedHistory 可能含旧 worker 多条 manifest)。
|
|
1163
|
+
this.messages = collapseSystemSlots([...inherited], WORKER_SYSTEM_SLOTS);
|
|
1164
|
+
if (this.inheritedHistoryMode === 'resume') {
|
|
1165
|
+
// 自愈中断孤儿:worker 被 kill 后恢复时,assistant 发起的 tool_call 可能
|
|
1166
|
+
// 缺配对 tool_result(assistant 已落库、result 未落库)。
|
|
1167
|
+
// 补语义占位,避免 provider 反复合成 [tool result missing]。
|
|
1168
|
+
const { healed, addedCount } = healInterruptedToolCalls(this.messages);
|
|
1169
|
+
if (addedCount > 0) {
|
|
1170
|
+
agentLogger.warn(`[WorkerResumeHeal] 检测到 ${addedCount} 个中断孤儿 tool_call,补占位`);
|
|
1171
|
+
this.messages = healed;
|
|
1172
|
+
}
|
|
1173
|
+
this.runtimeState.restoreProgress(recoveredIteration, recoveredToolCallCount || inherited.filter(m => m.role === 'tool').length);
|
|
1174
|
+
agentLogger.info(`♻️ 复活 worker 恢复对话历史 (共 ${inherited.length} 条消息)`);
|
|
1175
|
+
this.persistResumeCheckpoint(task);
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
const taskPrompt = this.buildTaskPrompt(task);
|
|
1179
|
+
const newMessages = [
|
|
1180
|
+
{
|
|
1181
|
+
role: 'user',
|
|
1182
|
+
content: '以上是你在本会话中之前任务积累的上下文(保留以便你复用对代码库、环境与既有产出的了解)。' +
|
|
1183
|
+
'现在你接到一个新任务,请基于已有了解继续,并以当前任务指令作为完成状态的唯一依据。',
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
role: 'user',
|
|
1187
|
+
content: `${'='.repeat(40)}\n任务指令:\n${'='.repeat(40)}\n${taskPrompt}`,
|
|
1188
|
+
},
|
|
1189
|
+
];
|
|
1190
|
+
for (const msg of newMessages) {
|
|
1191
|
+
this.addMessage(msg);
|
|
1192
|
+
}
|
|
1193
|
+
if (this.db) {
|
|
1194
|
+
for (const msg of newMessages) {
|
|
1195
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, msg);
|
|
1196
|
+
}
|
|
1197
|
+
await this.db.saveAgentState?.({
|
|
1198
|
+
session_id: this.sessionId,
|
|
1199
|
+
agent_id: this.agentId,
|
|
1200
|
+
agent_name: this.name,
|
|
1201
|
+
agent_role: this.role,
|
|
1202
|
+
task_id: task.id,
|
|
1203
|
+
status: 'running',
|
|
1204
|
+
stopped: 0,
|
|
1205
|
+
iteration: 0,
|
|
1206
|
+
timestamp: Date.now() / 1000,
|
|
1207
|
+
});
|
|
1208
|
+
}
|
|
1209
|
+
agentLogger.info(`🔗 复用同名 worker 继承上下文 (继承 ${inherited.length} 条历史 + 新任务指令)`);
|
|
1210
|
+
this.persistResumeCheckpoint(task);
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* 执行工具调用
|
|
1214
|
+
*/
|
|
1215
|
+
async executeToolCall(toolCall) {
|
|
1216
|
+
const { name, arguments: argsStr } = toolCall.function;
|
|
1217
|
+
let args;
|
|
1218
|
+
try {
|
|
1219
|
+
args = JSON.parse(argsStr);
|
|
1220
|
+
}
|
|
1221
|
+
catch (error) {
|
|
1222
|
+
return `ERROR: 工具参数 JSON 解析失败: ${error instanceof Error ? error.message : String(error)}\n原始参数: ${argsStr.slice(0, 500)}`;
|
|
1223
|
+
}
|
|
1224
|
+
const heartbeat = startToolProgressHeartbeat({
|
|
1225
|
+
emitter: this.emitter,
|
|
1226
|
+
toolCall,
|
|
1227
|
+
sessionId: this.sessionId,
|
|
1228
|
+
agentId: this.agentId,
|
|
1229
|
+
agentName: this.name,
|
|
1230
|
+
taskId: this.currentTaskId || undefined,
|
|
1231
|
+
scope: 'agent',
|
|
1232
|
+
});
|
|
1233
|
+
const __toolCallStart = Date.now();
|
|
1234
|
+
try {
|
|
1235
|
+
const assumptionTracker = this.getAssumptionTracker();
|
|
1236
|
+
const assumptionFeedback = (batch) => this.handleAssumptionFeedback(batch);
|
|
1237
|
+
let result = await this.tools.execute(name, args, {
|
|
1238
|
+
db: this.db,
|
|
1239
|
+
sessionId: this.sessionId,
|
|
1240
|
+
agentId: this.agentId,
|
|
1241
|
+
agentName: this.name,
|
|
1242
|
+
workspace: this.workspace,
|
|
1243
|
+
emitter: this.emitter,
|
|
1244
|
+
bus: this.bus,
|
|
1245
|
+
permissionContext: this.getPermissionContext(),
|
|
1246
|
+
llm: this.llm,
|
|
1247
|
+
model: this.model,
|
|
1248
|
+
toolCallId: toolCall.id,
|
|
1249
|
+
taskId: this.currentTaskId || undefined,
|
|
1250
|
+
taskWorkingDirectory: this.currentTaskWorkingDirectory || undefined,
|
|
1251
|
+
taskWriteScope: this.currentTaskWriteScope,
|
|
1252
|
+
contractAllowedScope: this.currentContractAllowedScope,
|
|
1253
|
+
blackboardGraph: this.blackboardGraph,
|
|
1254
|
+
assumptionTracker,
|
|
1255
|
+
assumptionFeedback,
|
|
1256
|
+
workflowManager: this.workflowManager,
|
|
1257
|
+
workflowEngine: this.workflowEngine,
|
|
1258
|
+
scheduledTaskManager: this.scheduledTaskManager,
|
|
1259
|
+
toolRegistry: this.tools,
|
|
1260
|
+
gitIdentity: this.gitIdentity,
|
|
1261
|
+
});
|
|
1262
|
+
// ── ToolFailureLoopGuard:失败先记账,再决定是否重试 ──
|
|
1263
|
+
// 任何工具失败(无论 success=false 还是 PERMISSION_REQUIRED 路径)都先进入 guard
|
|
1264
|
+
// 计数;同 toolName+argsHash+errorKind 累计达阈值时 guard.tripped=true,
|
|
1265
|
+
// 此时不再走本地 PERMISSION_REQUIRED 重试(避免 LLM 自循环),转而构造熔断
|
|
1266
|
+
// 错误返回给上层,Leader/Health 侧通过 agent:tool_failure_loop 事件响应。
|
|
1267
|
+
if (!result.success) {
|
|
1268
|
+
const failureDecision = this.recordToolFailure(name, args, result.error);
|
|
1269
|
+
if (failureDecision.tripped) {
|
|
1270
|
+
// 状态类错误必须升级;其他类型也立即返回熔断结果(防止 LLM 继续调同一 key)
|
|
1271
|
+
const trippedError = formatToolFailureLoopError(name, failureDecision);
|
|
1272
|
+
this.logEvent('tool_failure_loop_tripped', {
|
|
1273
|
+
toolName: name,
|
|
1274
|
+
argsHash: failureDecision.signature.argsHash,
|
|
1275
|
+
errorKind: failureDecision.errorKind,
|
|
1276
|
+
errorCode: failureDecision.signature.errorCode,
|
|
1277
|
+
count: failureDecision.count,
|
|
1278
|
+
threshold: failureDecision.count + 1,
|
|
1279
|
+
requiresEscalation: failureDecision.requiresEscalation,
|
|
1280
|
+
}).catch(() => { });
|
|
1281
|
+
this.emitter.emit('agent:status', {
|
|
1282
|
+
agentId: this.agentId,
|
|
1283
|
+
agentName: this.name,
|
|
1284
|
+
sessionId: this.sessionId,
|
|
1285
|
+
status: failureDecision.requiresEscalation
|
|
1286
|
+
? `🛑 工具 "${name}" 连续 ${failureDecision.count} 次失败(${failureDecision.errorKind}),已停止自循环,需 Leader 介入`
|
|
1287
|
+
: `⚠️ 工具 "${name}" 连续 ${failureDecision.count} 次失败(${failureDecision.errorKind}),已停止自循环`,
|
|
1288
|
+
});
|
|
1289
|
+
// 升级到 Leader:bus 发 tool_failure_loop_escalation 消息,LeaderPermissionManager
|
|
1290
|
+
// 据 errorKind 自动选众合理动作(自动放行 / 拒绝 / 交互审批)。仅 worker 侧发送;
|
|
1291
|
+
// leader 自身不需自升级(这里 name === 'leader' 的场景在 BaseAgentRuntime 中不执行)。
|
|
1292
|
+
if (this.bus && this.name !== 'leader') {
|
|
1293
|
+
const escalationRequestId = `tfl-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
1294
|
+
try {
|
|
1295
|
+
this.bus.send(this.busName, this.leaderBusName, 'tool_failure_loop_escalation', createToolFailureLoopEscalationPayload({
|
|
1296
|
+
requestId: escalationRequestId,
|
|
1297
|
+
workerName: this.name,
|
|
1298
|
+
toolName: name,
|
|
1299
|
+
argsHash: failureDecision.signature.argsHash,
|
|
1300
|
+
errorKind: failureDecision.errorKind,
|
|
1301
|
+
errorCode: failureDecision.signature.errorCode,
|
|
1302
|
+
count: failureDecision.count,
|
|
1303
|
+
requiresEscalation: failureDecision.requiresEscalation,
|
|
1304
|
+
lastErrorMessage: String(result.error || '').split('\n\nLLM_RECOVERY=')[0] || '',
|
|
1305
|
+
}));
|
|
1306
|
+
}
|
|
1307
|
+
catch {
|
|
1308
|
+
// bus 发送失败不应阻断熔断主路径
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
// 失败路径:跳过 PERMISSION_REQUIRED 本地重试(避免 LLM 在已熔断的调用上耗 round)
|
|
1312
|
+
return `ERROR: ${trippedError}`;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
if (!result.success && String(result.error || '').startsWith('PERMISSION_REQUIRED:')) {
|
|
1316
|
+
const approved = await this.requestPermissionFromLeader(name, String(result.error || ''));
|
|
1317
|
+
if (approved) {
|
|
1318
|
+
result = await this.tools.execute(name, args, {
|
|
1319
|
+
db: this.db,
|
|
1320
|
+
sessionId: this.sessionId,
|
|
1321
|
+
agentId: this.agentId,
|
|
1322
|
+
agentName: this.name,
|
|
1323
|
+
workspace: this.workspace,
|
|
1324
|
+
emitter: this.emitter,
|
|
1325
|
+
bus: this.bus,
|
|
1326
|
+
permissionContext: this.getPermissionContext(),
|
|
1327
|
+
llm: this.llm,
|
|
1328
|
+
model: this.model,
|
|
1329
|
+
toolCallId: toolCall.id,
|
|
1330
|
+
taskId: this.currentTaskId || undefined,
|
|
1331
|
+
taskWorkingDirectory: this.currentTaskWorkingDirectory || undefined,
|
|
1332
|
+
taskWriteScope: this.currentTaskWriteScope,
|
|
1333
|
+
contractAllowedScope: this.currentContractAllowedScope,
|
|
1334
|
+
blackboardGraph: this.blackboardGraph,
|
|
1335
|
+
assumptionTracker,
|
|
1336
|
+
assumptionFeedback,
|
|
1337
|
+
workflowManager: this.workflowManager,
|
|
1338
|
+
workflowEngine: this.workflowEngine,
|
|
1339
|
+
scheduledTaskManager: this.scheduledTaskManager,
|
|
1340
|
+
toolRegistry: this.tools,
|
|
1341
|
+
gitIdentity: this.gitIdentity,
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
// Langfuse tool call tracing (non-fatal, fire-and-forget)
|
|
1346
|
+
langfuseIntegration.recordToolCall({
|
|
1347
|
+
toolName: name,
|
|
1348
|
+
args,
|
|
1349
|
+
status: result.success ? 'ok' : 'error',
|
|
1350
|
+
latencyMs: Date.now() - __toolCallStart,
|
|
1351
|
+
agentId: this.agentId,
|
|
1352
|
+
agentName: this.name,
|
|
1353
|
+
taskId: this.currentTaskId || undefined,
|
|
1354
|
+
sessionId: this.sessionId,
|
|
1355
|
+
errorMessage: result.success ? undefined : String(result.error || ''),
|
|
1356
|
+
}).catch(() => { });
|
|
1357
|
+
if (!result.success)
|
|
1358
|
+
return `ERROR: ${result.error}`;
|
|
1359
|
+
// 成功路径:采集工具产物轨迹 + 捕获 attempt_completion 结构化收尾
|
|
1360
|
+
this.recordToolTrace(name, args, result.data);
|
|
1361
|
+
this.recordContextRead(name, args, result.data);
|
|
1362
|
+
const d = result.data;
|
|
1363
|
+
if (d === null || d === undefined)
|
|
1364
|
+
return '';
|
|
1365
|
+
// ── MCP CallToolResult 提取 ──
|
|
1366
|
+
// McpTool.callTool 返回 { success: true, data: CallToolResult }
|
|
1367
|
+
// CallToolResult = { content: ContentBlock[], _meta?, isError? }
|
|
1368
|
+
// 提取 content 数组为 MessageContentPart[],并检测 _meta.lingxiao_app 标记
|
|
1369
|
+
if (typeof d === 'object' && !Array.isArray(d)
|
|
1370
|
+
&& Array.isArray(d.content)
|
|
1371
|
+
&& name === 'mcp') {
|
|
1372
|
+
const callResult = d;
|
|
1373
|
+
if (callResult.isError) {
|
|
1374
|
+
const textParts = callResult.content
|
|
1375
|
+
.filter(b => b.type === 'text' && typeof b.text === 'string')
|
|
1376
|
+
.map(b => b.text).join('\n');
|
|
1377
|
+
return `ERROR: ${textParts || 'MCP tool returned isError'}`;
|
|
1378
|
+
}
|
|
1379
|
+
const parts = extractMcpContentParts(callResult.content);
|
|
1380
|
+
if (parts.length > 0)
|
|
1381
|
+
return parts;
|
|
1382
|
+
// content 为空时回退到 JSON
|
|
1383
|
+
return JSON.stringify(d, null, 2);
|
|
1384
|
+
}
|
|
1385
|
+
if (Array.isArray(d) && d.length > 0 && typeof d[0] === 'object' && 'type' in d[0]) {
|
|
1386
|
+
return d;
|
|
1387
|
+
}
|
|
1388
|
+
if (typeof d === 'string')
|
|
1389
|
+
return d;
|
|
1390
|
+
return JSON.stringify(d, null, 2);
|
|
1391
|
+
}
|
|
1392
|
+
finally {
|
|
1393
|
+
heartbeat.stop();
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* 采集单次工具调用的产物轨迹 / 捕获 attempt_completion 结构化收尾。
|
|
1398
|
+
* 仅在工具执行 success 后调用。失败的工具调用不计入产物。
|
|
1399
|
+
*/
|
|
1400
|
+
recordToolTrace(toolName, args, data) {
|
|
1401
|
+
const a = (args && typeof args === 'object') ? args : {};
|
|
1402
|
+
const pathArg = typeof a.path === 'string' ? a.path : undefined;
|
|
1403
|
+
switch (toolName) {
|
|
1404
|
+
case 'file_create':
|
|
1405
|
+
if (pathArg)
|
|
1406
|
+
this.toolTrace.filesCreated.add(pathArg);
|
|
1407
|
+
break;
|
|
1408
|
+
case 'structured_patch':
|
|
1409
|
+
if (pathArg)
|
|
1410
|
+
this.toolTrace.filesModified.add(pathArg);
|
|
1411
|
+
break;
|
|
1412
|
+
case 'shell': {
|
|
1413
|
+
const cmd = typeof a.command === 'string' ? a.command.trim() : '';
|
|
1414
|
+
if (cmd)
|
|
1415
|
+
this.toolTrace.commandsRun.push(cmd);
|
|
1416
|
+
break;
|
|
1417
|
+
}
|
|
1418
|
+
case 'python_exec': {
|
|
1419
|
+
const code = typeof a.code === 'string' ? a.code.trim() : '';
|
|
1420
|
+
if (code) {
|
|
1421
|
+
const firstLine = code.split('\n')[0]?.slice(0, 120) ?? '';
|
|
1422
|
+
this.toolTrace.commandsRun.push(`python: ${firstLine}`);
|
|
1423
|
+
}
|
|
1424
|
+
break;
|
|
1425
|
+
}
|
|
1426
|
+
case 'attempt_completion':
|
|
1427
|
+
// AttemptCompletionTool.execute 返回 data = AttemptCompletionStructuredResult
|
|
1428
|
+
if (data && typeof data === 'object' && 'summary' in data) {
|
|
1429
|
+
this.attemptCompletion = data;
|
|
1430
|
+
}
|
|
1431
|
+
break;
|
|
1432
|
+
default:
|
|
1433
|
+
break;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* 从 ToolResult.error 文本中提取 LLM_RECOVERY.code(与 createToolError 对齐:error 末尾
|
|
1438
|
+
* 形如 `\n\nLLM_RECOVERY={"code":"...","message":"...",...}`)。若不存在则回退到错误前缀匹配。
|
|
1439
|
+
*/
|
|
1440
|
+
extractToolErrorCode(errorText) {
|
|
1441
|
+
const text = String(errorText || '');
|
|
1442
|
+
if (!text)
|
|
1443
|
+
return '';
|
|
1444
|
+
const marker = 'LLM_RECOVERY=';
|
|
1445
|
+
const idx = text.lastIndexOf(marker);
|
|
1446
|
+
if (idx < 0) {
|
|
1447
|
+
// 退化:取首行第一段作为 code(形如 "TOOL_NOT_FOUND: ...")
|
|
1448
|
+
const firstLine = text.split('\n')[0] || '';
|
|
1449
|
+
const colonIdx = firstLine.indexOf(':');
|
|
1450
|
+
return colonIdx > 0 ? firstLine.slice(0, colonIdx).trim() : firstLine.trim();
|
|
1451
|
+
}
|
|
1452
|
+
const jsonText = text.slice(idx + marker.length).trim();
|
|
1453
|
+
try {
|
|
1454
|
+
const parsed = JSON.parse(jsonText);
|
|
1455
|
+
return typeof parsed?.code === 'string' ? parsed.code : '';
|
|
1456
|
+
}
|
|
1457
|
+
catch {
|
|
1458
|
+
return '';
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
/**
|
|
1462
|
+
* 将一次工具失败计入 ToolFailureLoopGuard。
|
|
1463
|
+
* 成功路径不需调用(registry 内部有独立 success 跟踪)。
|
|
1464
|
+
*/
|
|
1465
|
+
recordToolFailure(toolName, args, errorText) {
|
|
1466
|
+
const errorCode = this.extractToolErrorCode(errorText);
|
|
1467
|
+
const errorMessage = String(errorText || '').split('\n\nLLM_RECOVERY=')[0] || '';
|
|
1468
|
+
const guard = getToolFailureLoopGuard(this.emitter);
|
|
1469
|
+
return guard.record({
|
|
1470
|
+
sessionId: this.sessionId,
|
|
1471
|
+
agentId: this.agentId,
|
|
1472
|
+
agentName: this.name,
|
|
1473
|
+
taskId: this.currentTaskId || undefined,
|
|
1474
|
+
toolName,
|
|
1475
|
+
args,
|
|
1476
|
+
errorCode,
|
|
1477
|
+
errorMessage,
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
recordContextRead(toolName, args, data) {
|
|
1481
|
+
if (typeof data !== 'string' || data.length === 0)
|
|
1482
|
+
return;
|
|
1483
|
+
const a = (args && typeof args === 'object') ? args : {};
|
|
1484
|
+
if (toolName === 'file_read' || toolName === 'parse_file') {
|
|
1485
|
+
const pathArg = typeof a.path === 'string' ? a.path : '';
|
|
1486
|
+
if (pathArg)
|
|
1487
|
+
this.contextManager.trackFileRead(pathArg, data);
|
|
1488
|
+
return;
|
|
1489
|
+
}
|
|
1490
|
+
if (toolName === 'session_artifacts') {
|
|
1491
|
+
const action = typeof a.action === 'string' ? a.action : '';
|
|
1492
|
+
const artifact = typeof a.artifact === 'string' ? a.artifact : '';
|
|
1493
|
+
if (action === 'read' && artifact) {
|
|
1494
|
+
this.contextManager.trackFileRead(artifact, data);
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* 把框架采集的 toolTrace 转成可序列化的产物快照(用于 task_complete payload)。
|
|
1500
|
+
* 数组去重,commands 保序去重。
|
|
1501
|
+
*/
|
|
1502
|
+
buildToolTraceSnapshot() {
|
|
1503
|
+
const created = Array.from(this.toolTrace.filesCreated);
|
|
1504
|
+
const createdSet = new Set(created);
|
|
1505
|
+
// 同一文件若先 create 再 edit,归入 created,不重复进 modified
|
|
1506
|
+
const modified = Array.from(this.toolTrace.filesModified).filter((p) => !createdSet.has(p));
|
|
1507
|
+
const seenCmd = new Set();
|
|
1508
|
+
const commands = [];
|
|
1509
|
+
for (const c of this.toolTrace.commandsRun) {
|
|
1510
|
+
if (!seenCmd.has(c)) {
|
|
1511
|
+
seenCmd.add(c);
|
|
1512
|
+
commands.push(c);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
return { files_created: created, files_modified: modified, commands_run: commands };
|
|
1516
|
+
}
|
|
1517
|
+
canBatchExecuteToolCalls(toolCalls) {
|
|
1518
|
+
return toolCalls.length > 1 && toolCalls.every((toolCall) => BASE_PARALLEL_SAFE_TOOLS.has(toolCall.function.name));
|
|
1519
|
+
}
|
|
1520
|
+
async executeToolCallsBatch(toolCalls) {
|
|
1521
|
+
return runToolCallsBatch(toolCalls, (toolCall) => this.executeToolCall(toolCall), BASE_PARALLEL_SAFE_TOOLS);
|
|
1522
|
+
}
|
|
1523
|
+
createToolScheduler(options) {
|
|
1524
|
+
const logToolCall = options?.logToolCall ?? false;
|
|
1525
|
+
const wasTruncated = options?.wasOutputTruncated ?? false;
|
|
1526
|
+
// pipeline-flush 契约:注册 Worker 侧 flush 回调。
|
|
1527
|
+
// Worker 的 persistToolMessage 是 async(await this.db.saveAgentMessage),
|
|
1528
|
+
// 在信号到达时可能尚未 settle。setWorkerFlushFn 注册一个 no-op 回调,
|
|
1529
|
+
// 实际保护由 WorkerProcessEntry.flushPendingToolResults 的 3s 超时窗口提供,
|
|
1530
|
+
// 确保 clearRuntime()→db.close() 前给 pending async writes 留出 settle 时间。
|
|
1531
|
+
setWorkerFlushFn(() => {
|
|
1532
|
+
// Worker 即时写 DB,无 pending batch 需要 flush。
|
|
1533
|
+
// 此回调存在的意义是让 flushPendingToolResults 不短路(pendingFlushFn !== null),
|
|
1534
|
+
// 从而在 clearRuntime() 前留出 3s settle 窗口给在飞的 saveAgentMessage await。
|
|
1535
|
+
});
|
|
1536
|
+
return new ToolScheduler({
|
|
1537
|
+
checkHighPriorityIntervention: async () => {
|
|
1538
|
+
// 权限超时终止检查:shouldTerminate 由 requestPermissionFromLeader 设置
|
|
1539
|
+
if (this.shouldTerminate) {
|
|
1540
|
+
return { done: true, result: '权限审批连续超时,agent 终止' };
|
|
1541
|
+
}
|
|
1542
|
+
const counts = this.bus.getPendingPriorityCounts(this.busName);
|
|
1543
|
+
if (counts.p0 + counts.p1 === 0) {
|
|
1544
|
+
return null;
|
|
1545
|
+
}
|
|
1546
|
+
const shouldStop = await this.checkInbox();
|
|
1547
|
+
if (shouldStop) {
|
|
1548
|
+
const lastMessage = this.messages[this.messages.length - 1];
|
|
1549
|
+
const lastText = lastMessage ? contentToPlainText(lastMessage.content ?? '') : '未知原因';
|
|
1550
|
+
return { done: true, result: `被Leader停止: ${lastText || '未知原因'}` };
|
|
1551
|
+
}
|
|
1552
|
+
return { done: false };
|
|
1553
|
+
},
|
|
1554
|
+
beforeToolCalls: (toolCalls, context) => {
|
|
1555
|
+
if (context?.source === 'raw_xml') {
|
|
1556
|
+
agentLogger.warn(`[${this.name}] 检测到原始 XML 工具标签,容错解析出 ${toolCalls.length} 个工具调用`);
|
|
1557
|
+
this.emitter.emit('agent:status', {
|
|
1558
|
+
agentId: this.agentId,
|
|
1559
|
+
agentName: this.name,
|
|
1560
|
+
sessionId: this.sessionId,
|
|
1561
|
+
status: `⚠️ 格式容错:解析到 ${toolCalls.length} 个工具调用,执行中...`,
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
this.runtimeState.recordToolCalls(toolCalls.length);
|
|
1565
|
+
this.rawXmlRetryCount = 0;
|
|
1566
|
+
return null;
|
|
1567
|
+
},
|
|
1568
|
+
persistAssistantMessage: async (message) => {
|
|
1569
|
+
this.addMessage(message);
|
|
1570
|
+
if (this.db) {
|
|
1571
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, message);
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
executeToolCallsBatch: (toolCalls) => {
|
|
1575
|
+
if (wasTruncated) {
|
|
1576
|
+
return executeToolCallsWithTruncationGuard(toolCalls, calls => this.executeToolCallsBatch(calls));
|
|
1577
|
+
}
|
|
1578
|
+
// 即使 wasOutputTruncated=false,也对文件编辑类工具做空参数保护。
|
|
1579
|
+
// 某些 provider 截断时 finish_reason 仍报 'stop' 而非 'length',
|
|
1580
|
+
// 导致 wasOutputTruncated 误判为 false,但 args 实际为空。
|
|
1581
|
+
return rejectEmptyArgsFileTools(toolCalls, calls => this.executeToolCallsBatch(calls));
|
|
1582
|
+
},
|
|
1583
|
+
emitToolCall: (toolCall) => {
|
|
1584
|
+
if (logToolCall) {
|
|
1585
|
+
agentLogger.debug(`调用工具: ${toolCall.function.name}`);
|
|
1586
|
+
}
|
|
1587
|
+
this.emitter.emit('agent:tool_call', {
|
|
1588
|
+
agentId: this.agentId,
|
|
1589
|
+
agentName: this.name,
|
|
1590
|
+
sessionId: this.sessionId,
|
|
1591
|
+
taskId: this.currentTaskId || undefined,
|
|
1592
|
+
callId: toolCall.id,
|
|
1593
|
+
tool: toolCall.function.name,
|
|
1594
|
+
input: toolCall.function.arguments,
|
|
1595
|
+
});
|
|
1596
|
+
},
|
|
1597
|
+
transformToolResult: (toolCall, rawResult) => truncateAgentToolResult(toolCall.function.name, rawResult, runtimeConfig.agents.tool_result_max_chars),
|
|
1598
|
+
persistToolMessage: async (message) => {
|
|
1599
|
+
this.addMessage(message);
|
|
1600
|
+
if (this.db) {
|
|
1601
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, message);
|
|
1602
|
+
}
|
|
1603
|
+
},
|
|
1604
|
+
emitToolResult: (toolCall, renderedResult) => {
|
|
1605
|
+
this.emitter.emit('agent:tool_result', {
|
|
1606
|
+
agentId: this.agentId,
|
|
1607
|
+
agentName: this.name,
|
|
1608
|
+
sessionId: this.sessionId,
|
|
1609
|
+
taskId: this.currentTaskId || undefined,
|
|
1610
|
+
callId: toolCall.id,
|
|
1611
|
+
tool: toolCall.function.name,
|
|
1612
|
+
result: renderedResult,
|
|
1613
|
+
});
|
|
1614
|
+
},
|
|
1615
|
+
afterToolResult: async (toolCall) => {
|
|
1616
|
+
const toolName = toolCall.function.name;
|
|
1617
|
+
if (FILE_MODIFYING_TOOLS.has(toolName)) {
|
|
1618
|
+
await this.createAgentFileSnapshot(toolName);
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1621
|
+
shouldStopAfterToolResult: () => {
|
|
1622
|
+
if (this.attemptCompletion) {
|
|
1623
|
+
return { done: true, result: this.attemptCompletion.summary };
|
|
1624
|
+
}
|
|
1625
|
+
return null;
|
|
1626
|
+
},
|
|
1627
|
+
afterToolCalls: ({ toolCallContext }) => {
|
|
1628
|
+
if (toolCallContext?.source === 'raw_xml') {
|
|
1629
|
+
return null;
|
|
1630
|
+
}
|
|
1631
|
+
return null;
|
|
1632
|
+
},
|
|
1633
|
+
onEarlyStop: () => {
|
|
1634
|
+
// Worker 即时写 DB(无延迟批写),onEarlyStop 无需 flush。
|
|
1635
|
+
// 此 hook 作为防御性日志 + 未来批写扩展预留。
|
|
1636
|
+
// 真正的自愈由 resume 路径的 healInterruptedToolCalls 兜底。
|
|
1637
|
+
agentLogger.info(`[${this.name}] onEarlyStop 触发(worker 即时写 DB,无需 flush)`);
|
|
1638
|
+
},
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
createAgentEventStreamClient(actorLabel) {
|
|
1642
|
+
return createEventStreamClient({
|
|
1643
|
+
actorLabel,
|
|
1644
|
+
llm: this.llm,
|
|
1645
|
+
classifyError: classifyLLMError,
|
|
1646
|
+
gatewayContext: {
|
|
1647
|
+
actorType: 'agent',
|
|
1648
|
+
actorLabel,
|
|
1649
|
+
purpose: 'agent',
|
|
1650
|
+
sessionId: this.sessionId,
|
|
1651
|
+
agentId: this.agentId,
|
|
1652
|
+
agentName: this.name,
|
|
1653
|
+
taskId: this.currentTaskId || undefined,
|
|
1654
|
+
role: this.role,
|
|
1655
|
+
},
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Agent 文件变更 snapshot — 记录 Agent 级别的文件修改操作到 Changes timeline
|
|
1660
|
+
*/
|
|
1661
|
+
async createAgentFileSnapshot(toolName) {
|
|
1662
|
+
try {
|
|
1663
|
+
const { FileChangesApi } = await import('../web-server/FileChangesApi.js');
|
|
1664
|
+
const { DatabaseRepositoryAdapter } = await import('../core/DatabaseRepositories.js');
|
|
1665
|
+
const api = new FileChangesApi(new DatabaseRepositoryAdapter(this.db));
|
|
1666
|
+
const iteration = this.runtimeState.toolCallCount;
|
|
1667
|
+
const label = `[agent:${this.name}] [task:${this.currentTaskId || 'unknown'}] [tool] Auto: ${toolName}`;
|
|
1668
|
+
await api.createSnapshot(this.sessionId, label, {
|
|
1669
|
+
agentId: this.agentId,
|
|
1670
|
+
agentName: this.name,
|
|
1671
|
+
agentRole: this.role,
|
|
1672
|
+
taskId: this.currentTaskId || undefined,
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
catch {
|
|
1676
|
+
// non-critical: snapshot failure should not break agent execution
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* 处理 LLM 响应(协调者)
|
|
1681
|
+
*/
|
|
1682
|
+
async processResponse(response, task) {
|
|
1683
|
+
recordAgentTokenUsage(response, this.tracker, this.agentId, this.model);
|
|
1684
|
+
// 处理原生工具调用
|
|
1685
|
+
if (response.tool_calls && response.tool_calls.length > 0) {
|
|
1686
|
+
return this.handleNativeToolCalls(response);
|
|
1687
|
+
}
|
|
1688
|
+
// 没有工具调用,但有文本回复 — 检查是否包含内嵌工具调用
|
|
1689
|
+
const final = contentToPlainText(response.content);
|
|
1690
|
+
const parsedToolCallResult = this.handleParsedToolCalls(final, response);
|
|
1691
|
+
if (parsedToolCallResult) {
|
|
1692
|
+
return parsedToolCallResult;
|
|
1693
|
+
}
|
|
1694
|
+
// 检查是否有无法解析的原始工具语法(格式错乱)
|
|
1695
|
+
const rawSyntaxResult = await this.handleRawToolSyntaxRetry(final, response);
|
|
1696
|
+
if (rawSyntaxResult) {
|
|
1697
|
+
return rawSyntaxResult;
|
|
1698
|
+
}
|
|
1699
|
+
const hasExplicitFinishReason = Boolean(response.finish_reason);
|
|
1700
|
+
if (hasExplicitFinishReason) {
|
|
1701
|
+
// 明确的 API 终止/未终止信号先于最终完成守卫处理:
|
|
1702
|
+
// - 非 stop: 继续接续
|
|
1703
|
+
// - stop: 先尊重 nextSpeaker/stopHook,再要求最终契约证明
|
|
1704
|
+
const continuationResult = await this.evaluateContinuation(final, response, task);
|
|
1705
|
+
if (continuationResult) {
|
|
1706
|
+
return continuationResult;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
// 评估完成状态
|
|
1710
|
+
const completionResult = await this.evaluateCompletionAndRetry(final, response, task);
|
|
1711
|
+
if (completionResult) {
|
|
1712
|
+
return completionResult;
|
|
1713
|
+
}
|
|
1714
|
+
// 正常完成
|
|
1715
|
+
return this.finalizeCompletion(final, task);
|
|
1716
|
+
}
|
|
1717
|
+
// ─── processResponse 子方法 ───────────────────────────────────────────────
|
|
1718
|
+
/**
|
|
1719
|
+
* 处理原生 tool_calls(含死循环检测)
|
|
1720
|
+
*/
|
|
1721
|
+
handleNativeToolCalls(response) {
|
|
1722
|
+
// ── 死循环探针:只对「同 name + 同 args」连续命中累计 ──
|
|
1723
|
+
this.toolLoopDetector.observe(response.tool_calls);
|
|
1724
|
+
if (this.toolLoopDetector.isLooping) {
|
|
1725
|
+
const sig = this.toolLoopDetector.currentSignature ?? '<unknown>';
|
|
1726
|
+
const streak = this.toolLoopDetector.consecutiveCount;
|
|
1727
|
+
agentLogger.warn(`[${this.name}] 检测到工具死循环:${sig} 连续 ${streak} 次,注入系统提示并跳过本轮执行`);
|
|
1728
|
+
this.messages.push({
|
|
1729
|
+
role: 'system',
|
|
1730
|
+
content: `⚠️ [死循环保护] 你已用完全相同的参数连续调用同一个工具 ${streak} 次,这通常意味着策略卡住了。\n` +
|
|
1731
|
+
`请:1) 改变参数(不同 file_path / pattern / query),或 2) 切换到另一种工具,或 3) 直接给出当前已知信息的结论。\n` +
|
|
1732
|
+
`下一次工具调用请使用新的参数、替代工具或转为结论输出:${sig.split('::')[0]}。`,
|
|
1733
|
+
});
|
|
1734
|
+
this.toolLoopDetector.reset();
|
|
1735
|
+
return Promise.resolve({ done: false });
|
|
1736
|
+
}
|
|
1737
|
+
const toolScheduler = this.createToolScheduler({ logToolCall: true, wasOutputTruncated: response.was_output_truncated });
|
|
1738
|
+
return toolScheduler.run({
|
|
1739
|
+
assistantContent: response.content,
|
|
1740
|
+
toolCalls: response.tool_calls,
|
|
1741
|
+
thinking: response.thinking,
|
|
1742
|
+
wasOutputTruncated: response.was_output_truncated,
|
|
1743
|
+
toolCallContext: { source: 'native' },
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* 尝试从纯文本解析内嵌工具调用并执行(含死循环检测)
|
|
1748
|
+
* 返回 null 表示没有可解析的工具调用
|
|
1749
|
+
*/
|
|
1750
|
+
handleParsedToolCalls(final, response) {
|
|
1751
|
+
const parsedToolCalls = parseRawToolCalls(final);
|
|
1752
|
+
if (!parsedToolCalls) {
|
|
1753
|
+
return null;
|
|
1754
|
+
}
|
|
1755
|
+
this.toolLoopDetector.observe(parsedToolCalls);
|
|
1756
|
+
if (this.toolLoopDetector.isLooping) {
|
|
1757
|
+
const sig = this.toolLoopDetector.currentSignature ?? '<unknown>';
|
|
1758
|
+
const streak = this.toolLoopDetector.consecutiveCount;
|
|
1759
|
+
agentLogger.warn(`[${this.name}] 检测到工具死循环(raw_xml):${sig} 连续 ${streak} 次`);
|
|
1760
|
+
this.messages.push({
|
|
1761
|
+
role: 'system',
|
|
1762
|
+
content: `⚠️ [死循环保护] 你已用完全相同的参数连续调用同一个工具 ${streak} 次,请改变参数或切换工具。`,
|
|
1763
|
+
});
|
|
1764
|
+
this.toolLoopDetector.reset();
|
|
1765
|
+
return Promise.resolve({ done: false });
|
|
1766
|
+
}
|
|
1767
|
+
const toolScheduler = this.createToolScheduler({ wasOutputTruncated: response.was_output_truncated });
|
|
1768
|
+
return toolScheduler.run({
|
|
1769
|
+
assistantContent: final,
|
|
1770
|
+
toolCalls: parsedToolCalls,
|
|
1771
|
+
thinking: response.thinking,
|
|
1772
|
+
wasOutputTruncated: response.was_output_truncated,
|
|
1773
|
+
toolCallContext: { source: 'raw_xml' },
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* 处理包含无法解析的原始工具语法(格式错乱)的情况
|
|
1778
|
+
* 返回 null 表示不包含原始工具语法
|
|
1779
|
+
*/
|
|
1780
|
+
async handleRawToolSyntaxRetry(final, response) {
|
|
1781
|
+
if (!hasRawToolSyntax(final)) {
|
|
1782
|
+
return null;
|
|
1783
|
+
}
|
|
1784
|
+
const rawToolRetry = evaluateRawToolRetryOutcome({
|
|
1785
|
+
currentRetryCount: this.rawXmlRetryCount,
|
|
1786
|
+
maxRetryCount: 3,
|
|
1787
|
+
finalMessage: (_nextRetryCount) => `[错误] Agent 反复输出无效工具调用格式,已在第 ${this.iteration} 轮强制终止。最后输出片段: ${final.slice(0, 500)}`,
|
|
1788
|
+
});
|
|
1789
|
+
this.runtimeState.setRawXmlRetryCount(rawToolRetry.nextRetryCount);
|
|
1790
|
+
if (rawToolRetry.type === 'terminate') {
|
|
1791
|
+
agentLogger.error(`[${this.name}] 连续 ${this.rawXmlRetryCount} 次输出原始 XML 标签且无法解析,停止重试`);
|
|
1792
|
+
return { done: true, result: rawToolRetry.finalMessage };
|
|
1793
|
+
}
|
|
1794
|
+
const warningMsg = `🚨 **系统拦截警报**
|
|
1795
|
+
系统检测到您的输出包含试图调用工具的原始标签或 JSON 代码块,但它们没有被上层的 Native Function Calling 引擎正确捕获。
|
|
1796
|
+
|
|
1797
|
+
受此影响,您的调用并未实际执行。请立刻重新思考;工具调用统一通过标准原生 Function Calling 协议发起,文本回复只写解释、结论或用户可见内容。`;
|
|
1798
|
+
agentLogger.warn(`[${this.name}] 触发底层格式错乱阻断防线,强制打回重做 (第 ${this.rawXmlRetryCount} 次)`);
|
|
1799
|
+
this.emitter.emit('agent:status', {
|
|
1800
|
+
agentId: this.agentId,
|
|
1801
|
+
agentName: this.name,
|
|
1802
|
+
sessionId: this.sessionId,
|
|
1803
|
+
status: `⚠️ 格式纠正中 (第 ${this.rawXmlRetryCount}/3 次)...`,
|
|
1804
|
+
});
|
|
1805
|
+
this.addMessage({ role: 'assistant', content: final, thinking: response.thinking });
|
|
1806
|
+
if (this.db) {
|
|
1807
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
1808
|
+
}
|
|
1809
|
+
this.addMessage({ role: 'system', content: warningMsg });
|
|
1810
|
+
if (this.db) {
|
|
1811
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
1812
|
+
}
|
|
1813
|
+
return { done: false };
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* 评估完成状态,如果 completion guard 拒绝则返回重试指令
|
|
1817
|
+
* 返回 null 表示完成校验通过(继续后续流程)
|
|
1818
|
+
*/
|
|
1819
|
+
async evaluateCompletionAndRetry(final, response, task) {
|
|
1820
|
+
// 注:Worker stop 后不做本地截断猜测。
|
|
1821
|
+
// Worker 的真正完成判定交给下方的 completion guard(默认确定性硬校验);
|
|
1822
|
+
// 是否继续完全信任远程 API 的 finish_reason(已在上方非 stop 分支处理)。
|
|
1823
|
+
// 这样杜绝"短 stop 被误判截断 → 反复续跑"的空转。
|
|
1824
|
+
const completionDecision = await this.evaluateCompletionCandidate(final, task);
|
|
1825
|
+
if (!completionDecision.accepted) {
|
|
1826
|
+
const nextRetryCount = this.runtimeState.incrementCompletionGuardRetry();
|
|
1827
|
+
const nonBypassableCompletionReasons = new Set([
|
|
1828
|
+
'missing_contract_compliance_proof',
|
|
1829
|
+
]);
|
|
1830
|
+
const reason = completionDecision.reason || 'unknown';
|
|
1831
|
+
const isNonBypassable = nonBypassableCompletionReasons.has(reason);
|
|
1832
|
+
if (nextRetryCount > this.MAX_COMPLETION_GUARD_RETRIES && isNonBypassable) {
|
|
1833
|
+
const message = `completion guard rejected after ${this.MAX_COMPLETION_GUARD_RETRIES} retries: ${reason}`;
|
|
1834
|
+
agentLogger.error(`[${this.name}] ${message}`);
|
|
1835
|
+
this.emitter.emit('agent:status', {
|
|
1836
|
+
agentId: this.agentId,
|
|
1837
|
+
agentName: this.name,
|
|
1838
|
+
sessionId: this.sessionId,
|
|
1839
|
+
status: `🛑 完成校验失败:${reason}`,
|
|
1840
|
+
});
|
|
1841
|
+
throw new Error(message);
|
|
1842
|
+
}
|
|
1843
|
+
if (nextRetryCount > this.MAX_COMPLETION_GUARD_RETRIES) {
|
|
1844
|
+
// B2: 守护耗尽 — 不抛错(避免死循环),强制接受但记 envelope 可审计(放行不再静默)。
|
|
1845
|
+
this.runtimeState.completionBypassed = { reason, retries: nextRetryCount };
|
|
1846
|
+
agentLogger.warn(`[${this.name}] completion guard 已尝试 ${nextRetryCount} 次,强制接受(标记 UNVERIFIED): ${reason}`);
|
|
1847
|
+
this.emitter.emit('agent:status', {
|
|
1848
|
+
agentId: this.agentId,
|
|
1849
|
+
agentName: this.name,
|
|
1850
|
+
sessionId: this.sessionId,
|
|
1851
|
+
status: `⚠️ 完成校验重试耗尽(${nextRetryCount}次),接受当前输出 [UNVERIFIED: ${reason}]`,
|
|
1852
|
+
});
|
|
1853
|
+
// 继续走正常完成流程,不再 retry — 返回 null
|
|
1854
|
+
}
|
|
1855
|
+
else {
|
|
1856
|
+
agentLogger.warn(`[${this.name}] completion guard 拒绝收尾: ${completionDecision.reason || 'unknown'} (${nextRetryCount}/${this.MAX_COMPLETION_GUARD_RETRIES})`);
|
|
1857
|
+
this.emitter.emit('agent:status', {
|
|
1858
|
+
agentId: this.agentId,
|
|
1859
|
+
agentName: this.name,
|
|
1860
|
+
sessionId: this.sessionId,
|
|
1861
|
+
status: `⚠️ 完成校验未通过 (${nextRetryCount}/${this.MAX_COMPLETION_GUARD_RETRIES}),继续执行中...`,
|
|
1862
|
+
});
|
|
1863
|
+
this.addMessage({ role: 'assistant', content: final, thinking: response.thinking });
|
|
1864
|
+
if (this.db) {
|
|
1865
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
1866
|
+
}
|
|
1867
|
+
this.addMessage({ role: 'user', content: completionDecision.feedback });
|
|
1868
|
+
if (this.db) {
|
|
1869
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
1870
|
+
}
|
|
1871
|
+
return { done: false };
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
this.runtimeState.resetCompletionGuardRetry();
|
|
1875
|
+
agentLogger.debug(`completion guard 通过,任务结束`);
|
|
1876
|
+
return null;
|
|
1877
|
+
}
|
|
1878
|
+
/**
|
|
1879
|
+
* 评估 nextSpeaker 和 stopHook,决定是否需要继续
|
|
1880
|
+
* 返回 null 表示无需继续(应走正常完成流程)
|
|
1881
|
+
*/
|
|
1882
|
+
async evaluateContinuation(final, response, task) {
|
|
1883
|
+
const nextSpeakerVerdict = await evaluateNextSpeakerCandidate({
|
|
1884
|
+
finishReason: response.finish_reason,
|
|
1885
|
+
content: final,
|
|
1886
|
+
hasOpenWork: false,
|
|
1887
|
+
hasExplicitUserGate: false,
|
|
1888
|
+
llm: this.createAgentEventStreamClient(`Agent-${this.name}-NextSpeakerJudge`),
|
|
1889
|
+
model: this.model,
|
|
1890
|
+
messages: this.messages,
|
|
1891
|
+
sessionId: this.sessionId,
|
|
1892
|
+
actorLabel: `Agent-${this.name}-NextSpeakerJudge`,
|
|
1893
|
+
});
|
|
1894
|
+
if (nextSpeakerVerdict.nextSpeaker === 'model') {
|
|
1895
|
+
const continuationRetry = this.runtimeState.incrementContinuationRetry();
|
|
1896
|
+
if (continuationRetry > this.MAX_CONTINUATION_RETRIES) {
|
|
1897
|
+
agentLogger.warn(`[${this.name}] nextSpeaker 连续判 model 已达 ${continuationRetry} 次仍无工具推进,强制收尾`);
|
|
1898
|
+
this.runtimeState.resetContinuationRetry();
|
|
1899
|
+
// 落到下方 stop hook / 正常完成流程
|
|
1900
|
+
}
|
|
1901
|
+
else {
|
|
1902
|
+
// 续写前必须先把本轮已生成的部分输出(assistant content + thinking)入栈。
|
|
1903
|
+
// 否则 messages 末尾只剩"请接续"的 user 消息,模型看不到自己刚才输出的几千字,
|
|
1904
|
+
// 下一轮只会从头重新生成——MAX_CONTINUATION_RETRIES 次预算全部浪费在重写前文上,
|
|
1905
|
+
// 最终强制收尾时输出仍是半截("无法真正续写"的根因)。
|
|
1906
|
+
// 入栈模式与 evaluateCompletionAndRetry / handleRawToolSyntaxRetry 完全一致:
|
|
1907
|
+
// 先 assistant 半截内容,再不注入续写指令到持久化历史
|
|
1908
|
+
this.addMessage({ role: 'assistant', content: final, thinking: response.thinking });
|
|
1909
|
+
if (this.db) {
|
|
1910
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
1911
|
+
}
|
|
1912
|
+
// 不注入 continuation prompt,模型会基于当前上下文自然继续
|
|
1913
|
+
agentLogger.info(`[${this.name}] Agent 续跑 (retry=${continuationRetry}),不注入 prompt`);
|
|
1914
|
+
return { done: false };
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
const stopHook = await this.maybeContinueFromStopHook(final);
|
|
1918
|
+
if (stopHook.shouldContinue) {
|
|
1919
|
+
// Stop hook 要求继续,但不注入到持久化历史
|
|
1920
|
+
agentLogger.info(`[${this.name}] Stop hook 要求继续,不注入 prompt`);
|
|
1921
|
+
return { done: false };
|
|
1922
|
+
}
|
|
1923
|
+
return null;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* 执行最终完成流程:日志、工作笔记、事件发射、状态持久化
|
|
1927
|
+
*/
|
|
1928
|
+
async finalizeCompletion(final, task) {
|
|
1929
|
+
await this.logEvent('agent_completed', {
|
|
1930
|
+
task_id: task.id,
|
|
1931
|
+
result_length: final.length,
|
|
1932
|
+
iterations: this.iteration,
|
|
1933
|
+
tool_calls: this.toolCallCount,
|
|
1934
|
+
result_summary: final,
|
|
1935
|
+
});
|
|
1936
|
+
// 结构化守卫:完成前自动写工作笔记(不依赖 LLM 主动调用)
|
|
1937
|
+
await autoWriteAgentCompletionNote({
|
|
1938
|
+
workspace: this.workspace,
|
|
1939
|
+
sessionId: this.sessionId,
|
|
1940
|
+
agentId: this.agentId,
|
|
1941
|
+
agentName: this.name,
|
|
1942
|
+
role: this.role,
|
|
1943
|
+
task,
|
|
1944
|
+
result: final,
|
|
1945
|
+
messages: this.messages,
|
|
1946
|
+
logger: agentLogger,
|
|
1947
|
+
});
|
|
1948
|
+
// 本 agent 自己的累计用量。usageMap 没有该 agentId 时(极少:无任何
|
|
1949
|
+
// 真实/估算 usage 落账),报 0 而非用 getSessionTotal() 冒充——后者是
|
|
1950
|
+
// 全会话总量,会让单个 agent 的 total 虚高且与 prompt/completion 不自洽。
|
|
1951
|
+
const agentTokenUsage = this.tracker.usageMap?.get(this.agentId);
|
|
1952
|
+
this.emitter.emit('agent:completed', {
|
|
1953
|
+
agentId: this.agentId,
|
|
1954
|
+
agentName: this.name,
|
|
1955
|
+
sessionId: this.sessionId,
|
|
1956
|
+
taskId: task.id,
|
|
1957
|
+
result: final,
|
|
1958
|
+
stats: {
|
|
1959
|
+
iterations: this.iteration,
|
|
1960
|
+
toolCalls: this.toolCallCount,
|
|
1961
|
+
},
|
|
1962
|
+
tokenUsage: {
|
|
1963
|
+
total: agentTokenUsage?.total ?? 0,
|
|
1964
|
+
prompt: agentTokenUsage?.prompt ?? 0,
|
|
1965
|
+
completion: agentTokenUsage?.completion ?? 0,
|
|
1966
|
+
},
|
|
1967
|
+
});
|
|
1968
|
+
if (this.db) {
|
|
1969
|
+
await this.db.saveAgentState?.({
|
|
1970
|
+
session_id: this.sessionId,
|
|
1971
|
+
agent_id: this.agentId,
|
|
1972
|
+
agent_name: this.name,
|
|
1973
|
+
agent_role: this.role,
|
|
1974
|
+
task_id: task.id,
|
|
1975
|
+
status: 'completed',
|
|
1976
|
+
stopped: 0,
|
|
1977
|
+
iteration: this.iteration,
|
|
1978
|
+
timestamp: Date.now() / 1000,
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
return { done: true, result: final };
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* 检查收件箱:处理停止消息和 Leader 干预指令。
|
|
1985
|
+
* @param prePolledMessages 可选的已 poll 消息列表,避免重复 poll
|
|
1986
|
+
* @returns true=需要停止Agent, false=继续运行
|
|
1987
|
+
*/
|
|
1988
|
+
async checkInbox(prePolledMessages) {
|
|
1989
|
+
let messages = prePolledMessages;
|
|
1990
|
+
if (!messages) {
|
|
1991
|
+
messages = this.bus ? this.bus.poll(this.busName) : [];
|
|
1992
|
+
}
|
|
1993
|
+
if (messages.length === 0) {
|
|
1994
|
+
return false;
|
|
1995
|
+
}
|
|
1996
|
+
agentLogger.debug(`📬 收到 ${messages.length} 条消息`);
|
|
1997
|
+
for (const msg of messages) {
|
|
1998
|
+
const senderLabel = inboxResolveSenderLabel(msg);
|
|
1999
|
+
// 用于日志预览 / agent_stopped|paused 事件的 reason:team 协议消息优先取
|
|
2000
|
+
// 协议体 content(人类可读),普通消息取 canonical payload。
|
|
2001
|
+
const protocolMessage = parseProtocolPayload(msg.payload);
|
|
2002
|
+
const content = contentToPlainText(protocolMessage?.content ?? msg.payload);
|
|
2003
|
+
agentLogger.debug(`📨 来自 ${senderLabel}: ${content.slice(0, 80)}${content.length > 80 ? '…' : ''}`);
|
|
2004
|
+
// system_context 是运行时系统注入,必须作为 system role 进入模型上下文。
|
|
2005
|
+
if (msg.type === 'system_context') {
|
|
2006
|
+
const systemMessage = this.upsertSystemContextMessage(content);
|
|
2007
|
+
if (this.db) {
|
|
2008
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, systemMessage);
|
|
2009
|
+
}
|
|
2010
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2011
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2012
|
+
}
|
|
2013
|
+
await this.logEvent('agent_system_context', { from: msg.from, content });
|
|
2014
|
+
const status = content.trim().startsWith(CONTRACT_PACK_MARKER)
|
|
2015
|
+
? '收到 Contract Pack 系统契约更新'
|
|
2016
|
+
: `收到来自${senderLabel}的系统上下文更新`;
|
|
2017
|
+
agentLogger.debug(`🧭 已将系统上下文加入对话: ${status}`);
|
|
2018
|
+
this.emitter.emit('agent:status', {
|
|
2019
|
+
agentId: this.agentId,
|
|
2020
|
+
agentName: this.name,
|
|
2021
|
+
sessionId: this.sessionId,
|
|
2022
|
+
status,
|
|
2023
|
+
});
|
|
2024
|
+
if (this.currentTaskId) {
|
|
2025
|
+
this.emitter.emit('agent:progress', {
|
|
2026
|
+
agentId: this.agentId,
|
|
2027
|
+
name: this.name,
|
|
2028
|
+
sessionId: this.sessionId,
|
|
2029
|
+
taskId: this.currentTaskId,
|
|
2030
|
+
message: `● ${status}`,
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
continue;
|
|
2034
|
+
}
|
|
2035
|
+
// 检查结构化控制命令(暂停/干预/终止);普通文本仅接受整句 stop/停止,避免"请停止分析"类误触发
|
|
2036
|
+
if (inboxIsStopMessage(msg)) {
|
|
2037
|
+
agentLogger.info(`🛑 收到停止命令`);
|
|
2038
|
+
this.stopped = true;
|
|
2039
|
+
this.markTerminalRuntimeOutcome({
|
|
2040
|
+
kind: 'terminated',
|
|
2041
|
+
reason: content || 'Agent stopped by explicit stop command',
|
|
2042
|
+
recoverable: false,
|
|
2043
|
+
phase: 'execute',
|
|
2044
|
+
});
|
|
2045
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2046
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2047
|
+
}
|
|
2048
|
+
await this.logEvent('agent_stopped', { reason: content, iteration: this.iteration });
|
|
2049
|
+
return true;
|
|
2050
|
+
}
|
|
2051
|
+
// 检查暂停命令
|
|
2052
|
+
if (inboxIsPauseMessage(msg)) {
|
|
2053
|
+
agentLogger.info(`⏸ 收到暂停命令`);
|
|
2054
|
+
this.pause();
|
|
2055
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2056
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2057
|
+
}
|
|
2058
|
+
await this.logEvent('agent_paused', { reason: content, iteration: this.iteration });
|
|
2059
|
+
continue;
|
|
2060
|
+
}
|
|
2061
|
+
// 检查干预命令
|
|
2062
|
+
const interveneContent = inboxParseInterveneMessage(msg);
|
|
2063
|
+
if (interveneContent) {
|
|
2064
|
+
agentLogger.info(`🎯 收到干预命令`);
|
|
2065
|
+
this.intervene(interveneContent);
|
|
2066
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2067
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2068
|
+
}
|
|
2069
|
+
await this.logEvent('agent_intervened', { instruction: interveneContent, iteration: this.iteration });
|
|
2070
|
+
continue;
|
|
2071
|
+
}
|
|
2072
|
+
const runtimeIntervention = await this.handleRuntimeInterventionMessage(msg);
|
|
2073
|
+
if (runtimeIntervention) {
|
|
2074
|
+
if (!this.pendingInboxInterventionResult || runtimeIntervention.type === 'repeat') {
|
|
2075
|
+
this.pendingInboxInterventionResult = runtimeIntervention;
|
|
2076
|
+
}
|
|
2077
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2078
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2079
|
+
}
|
|
2080
|
+
continue;
|
|
2081
|
+
}
|
|
2082
|
+
const interventionContent = formatIncomingContent(msg);
|
|
2083
|
+
this.addMessage({ role: 'user', content: interventionContent });
|
|
2084
|
+
if (this.db) {
|
|
2085
|
+
await this.db.saveAgentMessage?.(this.sessionId, this.agentId, this.name, this.messages[this.messages.length - 1]);
|
|
2086
|
+
}
|
|
2087
|
+
// 发送 ACK 确认消息已收到
|
|
2088
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2089
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2090
|
+
}
|
|
2091
|
+
await this.logEvent('agent_intervention', { from: msg.from, content: msg.payload });
|
|
2092
|
+
const interventionStatus = `收到来自${senderLabel}的消息,下一轮调整中`;
|
|
2093
|
+
agentLogger.debug(`📝 已将消息加入对话: ${interventionStatus}`);
|
|
2094
|
+
this.emitter.emit('agent:status', {
|
|
2095
|
+
agentId: this.agentId,
|
|
2096
|
+
agentName: this.name,
|
|
2097
|
+
sessionId: this.sessionId,
|
|
2098
|
+
status: interventionStatus,
|
|
2099
|
+
});
|
|
2100
|
+
if (this.currentTaskId) {
|
|
2101
|
+
this.emitter.emit('agent:progress', {
|
|
2102
|
+
agentId: this.agentId,
|
|
2103
|
+
name: this.name,
|
|
2104
|
+
sessionId: this.sessionId,
|
|
2105
|
+
taskId: this.currentTaskId,
|
|
2106
|
+
message: `● ${interventionStatus}`,
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
return false;
|
|
2111
|
+
}
|
|
2112
|
+
async applyRuntimeIntervention(intervention, msg) {
|
|
2113
|
+
switch (intervention.type) {
|
|
2114
|
+
case 'retry_llm': {
|
|
2115
|
+
agentLogger.info(`[INTERVENTION] retry_llm: 中止当前 LLM 调用并触发重试`);
|
|
2116
|
+
if (this.currentLlmAbortController) {
|
|
2117
|
+
this.currentLlmAbortController.abort('Leader intervention: retry_llm');
|
|
2118
|
+
}
|
|
2119
|
+
return { type: 'repeat' };
|
|
2120
|
+
}
|
|
2121
|
+
case 'swap_model': {
|
|
2122
|
+
const newModel = intervention.param;
|
|
2123
|
+
if (!newModel) {
|
|
2124
|
+
agentLogger.warn(`[INTERVENTION] swap_model 缺少模型参数`);
|
|
2125
|
+
return null;
|
|
2126
|
+
}
|
|
2127
|
+
try {
|
|
2128
|
+
const { getModelManager } = await import('../config/ModelManager.js');
|
|
2129
|
+
getModelManager().getModelByIdStrict(newModel);
|
|
2130
|
+
}
|
|
2131
|
+
catch (error) {
|
|
2132
|
+
agentLogger.warn(`[INTERVENTION] swap_model 拒绝未知模型 ${newModel}: ${error instanceof Error ? error.message : String(error)}`);
|
|
2133
|
+
return null;
|
|
2134
|
+
}
|
|
2135
|
+
agentLogger.info(`[INTERVENTION] swap_model: ${this.model} -> ${newModel}`);
|
|
2136
|
+
this.model = newModel;
|
|
2137
|
+
this.contextManager.updateModel(newModel, this.resolveContextLimit(newModel));
|
|
2138
|
+
return { type: 'repeat' };
|
|
2139
|
+
}
|
|
2140
|
+
case 'nudge': {
|
|
2141
|
+
const content = contentToPlainText(msg.payload).trim();
|
|
2142
|
+
const nudgeText = (intervention.param || content.replace(/^\[INTERVENTION:nudge\]\s*/i, '')).trim();
|
|
2143
|
+
if (nudgeText) {
|
|
2144
|
+
this.nudgeMessage = nudgeText;
|
|
2145
|
+
agentLogger.info(`[INTERVENTION] nudge: ${nudgeText.substring(0, 80)}${nudgeText.length > 80 ? '...' : ''}`);
|
|
2146
|
+
}
|
|
2147
|
+
return { type: 'continue' };
|
|
2148
|
+
}
|
|
2149
|
+
case 'compact_context': {
|
|
2150
|
+
agentLogger.info(`[INTERVENTION] compact_context: 压缩 Agent 上下文`);
|
|
2151
|
+
try {
|
|
2152
|
+
this.contextManager.setMessages(this.messages);
|
|
2153
|
+
const result = await this.contextManager.forceCompact();
|
|
2154
|
+
this.messages = this.contextManager.getMessages();
|
|
2155
|
+
agentLogger.info(`[INTERVENTION] compact_context 完成: ${result.oldTokens} → ${result.newTokens} tokens`);
|
|
2156
|
+
}
|
|
2157
|
+
catch (err) {
|
|
2158
|
+
agentLogger.warn(`[INTERVENTION] compact_context 失败: ${String(err)}`);
|
|
2159
|
+
}
|
|
2160
|
+
return { type: 'repeat' };
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
async handleRuntimeInterventionMessage(msg) {
|
|
2166
|
+
const intervention = inboxParseInterventionControl(msg);
|
|
2167
|
+
if (!intervention)
|
|
2168
|
+
return null;
|
|
2169
|
+
return this.applyRuntimeIntervention(intervention, msg);
|
|
2170
|
+
}
|
|
2171
|
+
/**
|
|
2172
|
+
* 检查并处理 Leader 的运行时干预指令。
|
|
2173
|
+
* 在每次 LLM 调用前调用,识别 [INTERVENTION:*] 前缀消息。
|
|
2174
|
+
* @returns { type: 'repeat' } 触发循环重试, { type: 'continue' } 继续, null 无干预
|
|
2175
|
+
*/
|
|
2176
|
+
async checkInboxForIntervention() {
|
|
2177
|
+
if (this.pendingInboxInterventionResult) {
|
|
2178
|
+
const result = this.pendingInboxInterventionResult;
|
|
2179
|
+
this.pendingInboxInterventionResult = null;
|
|
2180
|
+
return result;
|
|
2181
|
+
}
|
|
2182
|
+
if (!this.bus)
|
|
2183
|
+
return null;
|
|
2184
|
+
try {
|
|
2185
|
+
const messages = this.bus.poll(this.busName);
|
|
2186
|
+
if (messages.length === 0)
|
|
2187
|
+
return null;
|
|
2188
|
+
const shouldStop = await this.checkInbox(messages);
|
|
2189
|
+
if (shouldStop)
|
|
2190
|
+
return { type: 'repeat' };
|
|
2191
|
+
if (this.pendingInboxInterventionResult) {
|
|
2192
|
+
const result = this.pendingInboxInterventionResult;
|
|
2193
|
+
this.pendingInboxInterventionResult = null;
|
|
2194
|
+
return result;
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
catch (err) {
|
|
2198
|
+
agentLogger.warn(`checkInboxForIntervention 出错: ${String(err)}`);
|
|
2199
|
+
}
|
|
2200
|
+
return null;
|
|
2201
|
+
}
|
|
2202
|
+
/**
|
|
2203
|
+
* 检查收件箱是否有恢复暂停的消息
|
|
2204
|
+
*/
|
|
2205
|
+
async checkInboxForResume() {
|
|
2206
|
+
if (!this.bus)
|
|
2207
|
+
return false;
|
|
2208
|
+
try {
|
|
2209
|
+
const messages = this.bus.poll(this.busName);
|
|
2210
|
+
const remaining = [];
|
|
2211
|
+
let resumed = false;
|
|
2212
|
+
for (const msg of messages) {
|
|
2213
|
+
if (inboxIsResumeMessage(msg)) {
|
|
2214
|
+
agentLogger.info(`收到恢复消息,Agent ${this.name} 将继续执行`);
|
|
2215
|
+
resumed = true;
|
|
2216
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2217
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2218
|
+
}
|
|
2219
|
+
continue;
|
|
2220
|
+
}
|
|
2221
|
+
remaining.push(msg);
|
|
2222
|
+
}
|
|
2223
|
+
if (remaining.length > 0) {
|
|
2224
|
+
await this.checkInbox(remaining);
|
|
2225
|
+
}
|
|
2226
|
+
return resumed;
|
|
2227
|
+
}
|
|
2228
|
+
catch (err) {
|
|
2229
|
+
agentLogger.warn(`checkInboxForResume 出错: ${String(err)}`);
|
|
2230
|
+
}
|
|
2231
|
+
return false;
|
|
2232
|
+
}
|
|
2233
|
+
/**
|
|
2234
|
+
* 检查收件箱是否有干预确认消息
|
|
2235
|
+
*/
|
|
2236
|
+
async checkInboxForInterventionConfirm() {
|
|
2237
|
+
if (!this.bus)
|
|
2238
|
+
return false;
|
|
2239
|
+
try {
|
|
2240
|
+
const messages = this.bus.poll(this.busName);
|
|
2241
|
+
const remaining = [];
|
|
2242
|
+
let confirmed = false;
|
|
2243
|
+
for (const msg of messages) {
|
|
2244
|
+
if (inboxIsInterventionConfirmMessage(msg)) {
|
|
2245
|
+
agentLogger.info(`收到干预确认消息,Agent ${this.name} 将继续执行`);
|
|
2246
|
+
confirmed = true;
|
|
2247
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2248
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2249
|
+
}
|
|
2250
|
+
continue;
|
|
2251
|
+
}
|
|
2252
|
+
// 如果收到新的干预指令,替换当前的
|
|
2253
|
+
const interventionResult = await this.handleRuntimeInterventionMessage(msg);
|
|
2254
|
+
if (interventionResult) {
|
|
2255
|
+
this.pendingInboxInterventionResult = interventionResult;
|
|
2256
|
+
agentLogger.info(`收到新的干预指令: ${interventionResult.type}`);
|
|
2257
|
+
confirmed = true;
|
|
2258
|
+
if (this.bus && 'acknowledge' in this.bus && msg.id) {
|
|
2259
|
+
this.bus.acknowledge(this.busName, msg.id);
|
|
2260
|
+
}
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2263
|
+
remaining.push(msg);
|
|
2264
|
+
}
|
|
2265
|
+
if (remaining.length > 0) {
|
|
2266
|
+
await this.checkInbox(remaining);
|
|
2267
|
+
}
|
|
2268
|
+
return confirmed;
|
|
2269
|
+
}
|
|
2270
|
+
catch (err) {
|
|
2271
|
+
agentLogger.warn(`checkInboxForInterventionConfirm 出错: ${String(err)}`);
|
|
2272
|
+
}
|
|
2273
|
+
return false;
|
|
2274
|
+
}
|
|
2275
|
+
async maybeContinueFromStopHook(final) {
|
|
2276
|
+
const hookResult = await executeStop(this.sessionId, final);
|
|
2277
|
+
if (!hookResult.blocked && hookResult.system_messages.length === 0) {
|
|
2278
|
+
return { shouldContinue: false };
|
|
2279
|
+
}
|
|
2280
|
+
const feedback = hookResult.block_reason || hookResult.system_messages.join('\n').trim() || 'Stop Hook 要求继续推进当前任务。';
|
|
2281
|
+
return {
|
|
2282
|
+
shouldContinue: true,
|
|
2283
|
+
feedback,
|
|
2284
|
+
signal: { source: 'stop_hook', detail: feedback },
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
markTerminalRuntimeOutcome(outcome) {
|
|
2288
|
+
const normalized = this.normalizeTerminalRuntimeOutcome(outcome);
|
|
2289
|
+
if (this.terminalRuntimeOutcome?.kind === 'terminated' && outcome.kind !== 'terminated') {
|
|
2290
|
+
return this.terminalRuntimeOutcome.reason;
|
|
2291
|
+
}
|
|
2292
|
+
this.terminalRuntimeOutcome = {
|
|
2293
|
+
kind: normalized.kind,
|
|
2294
|
+
reason: normalized.reason,
|
|
2295
|
+
faultClass: normalized.faultClass,
|
|
2296
|
+
recoverable: normalized.recoverable ?? normalized.kind === 'recovering',
|
|
2297
|
+
phase: normalized.phase,
|
|
2298
|
+
llmErrorKind: normalized.llmErrorKind,
|
|
2299
|
+
};
|
|
2300
|
+
return normalized.reason;
|
|
2301
|
+
}
|
|
2302
|
+
isStoppedRuntimeReason(reason) {
|
|
2303
|
+
const normalized = String(reason || '').trim();
|
|
2304
|
+
return /^Agent stopped(?:\b|$)/i.test(normalized)
|
|
2305
|
+
|| normalized.startsWith('被Leader停止')
|
|
2306
|
+
|| /^Agent stopped before LLM call$/i.test(normalized);
|
|
2307
|
+
}
|
|
2308
|
+
normalizeTerminalRuntimeOutcome(outcome) {
|
|
2309
|
+
if (outcome.kind !== 'terminated' && this.isStoppedRuntimeReason(outcome.reason)) {
|
|
2310
|
+
return {
|
|
2311
|
+
...outcome,
|
|
2312
|
+
kind: 'recovering',
|
|
2313
|
+
faultClass: 'worker_stopped',
|
|
2314
|
+
recoverable: true,
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
return outcome;
|
|
2318
|
+
}
|
|
2319
|
+
buildTerminalFailureResult(summary, defaults) {
|
|
2320
|
+
const outcome = this.normalizeTerminalRuntimeOutcome(this.terminalRuntimeOutcome ?? {
|
|
2321
|
+
kind: defaults.kind,
|
|
2322
|
+
reason: summary,
|
|
2323
|
+
faultClass: defaults.faultClass,
|
|
2324
|
+
recoverable: defaults.recoverable ?? defaults.kind === 'recovering',
|
|
2325
|
+
phase: defaults.phase,
|
|
2326
|
+
});
|
|
2327
|
+
return createFailureResult({
|
|
2328
|
+
summary: outcome.reason || summary,
|
|
2329
|
+
error: outcome.reason || summary,
|
|
2330
|
+
duration: Date.now() - this.runtimeState.startTime,
|
|
2331
|
+
metadata: {
|
|
2332
|
+
iterations: this.iteration,
|
|
2333
|
+
toolCalls: this.toolCallCount,
|
|
2334
|
+
recoverable: outcome.recoverable,
|
|
2335
|
+
faultClass: outcome.faultClass,
|
|
2336
|
+
llmErrorKind: outcome.llmErrorKind,
|
|
2337
|
+
terminalKind: outcome.kind,
|
|
2338
|
+
statusReason: outcome.reason || summary,
|
|
2339
|
+
runtimePhase: outcome.phase ?? defaults.phase,
|
|
2340
|
+
},
|
|
2341
|
+
});
|
|
2342
|
+
}
|
|
2343
|
+
isRuntimeFailureLoopResult(result) {
|
|
2344
|
+
if (!result)
|
|
2345
|
+
return true;
|
|
2346
|
+
const normalized = result.trim();
|
|
2347
|
+
return (/^Agent stopped(?:\b|$)/i.test(normalized) ||
|
|
2348
|
+
/^Agent stopped before LLM call$/i.test(normalized) ||
|
|
2349
|
+
normalized.startsWith('被Leader停止') ||
|
|
2350
|
+
normalized.startsWith('[LLM') ||
|
|
2351
|
+
normalized.startsWith('Conclude phase failed'));
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Agent 主循环
|
|
2355
|
+
*/
|
|
2356
|
+
/**
|
|
2357
|
+
* 双阶段执行入口
|
|
2358
|
+
* Execute 阶段:正常执行任务
|
|
2359
|
+
* Conclude 阶段:超时后快速收尾
|
|
2360
|
+
*/
|
|
2361
|
+
async runWithConclude(task, isResume = false, recoveredState) {
|
|
2362
|
+
try {
|
|
2363
|
+
// Execute 阶段:正常执行
|
|
2364
|
+
return await this.executePhase(task, isResume, recoveredState);
|
|
2365
|
+
}
|
|
2366
|
+
catch (error) {
|
|
2367
|
+
// 如果是 TimeoutError,进入 Conclude 阶段
|
|
2368
|
+
if (error instanceof TimeoutError) {
|
|
2369
|
+
agentLogger.info(`[${this.name}] 执行超时,进入 Conclude 阶段`);
|
|
2370
|
+
return await this.concludePhase(task, error);
|
|
2371
|
+
}
|
|
2372
|
+
// 其他错误直接抛出
|
|
2373
|
+
throw error;
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
/**
|
|
2377
|
+
* Execute 阶段:正常执行任务
|
|
2378
|
+
*/
|
|
2379
|
+
async executePhase(task, isResume = false, recoveredState) {
|
|
2380
|
+
return await this.run(task, isResume, recoveredState);
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Conclude 阶段:超时后快速收尾
|
|
2384
|
+
* 限时 2 分钟,最多 3 轮对话
|
|
2385
|
+
*/
|
|
2386
|
+
async concludePhase(task, timeoutError) {
|
|
2387
|
+
agentLogger.info(`[${this.name}] 开始 Conclude 阶段收尾`);
|
|
2388
|
+
// 注入 Conclude Prompt
|
|
2389
|
+
const taskType = await this.inferTaskType(task);
|
|
2390
|
+
const concludePrompt = getPromptTemplate(taskType, 'conclude');
|
|
2391
|
+
if (concludePrompt) {
|
|
2392
|
+
const progress = summarizeAgentProgress(this.iteration, this.toolCallCount, this.messages);
|
|
2393
|
+
// 如果有黑板图,获取当前状态
|
|
2394
|
+
let factCount = '0';
|
|
2395
|
+
let hintCount = '0';
|
|
2396
|
+
if (this.blackboardGraph) {
|
|
2397
|
+
const snapshot = this.blackboardGraph.getSnapshot(this.sessionId);
|
|
2398
|
+
factCount = String(snapshot.nodes.filter(n => n.kind === 'fact').length);
|
|
2399
|
+
hintCount = String(snapshot.nodes.filter(n => n.kind === 'hint').length);
|
|
2400
|
+
}
|
|
2401
|
+
const promptContent = renderAgentPromptTemplate(concludePrompt.template, {
|
|
2402
|
+
goal: task.description,
|
|
2403
|
+
intent: task.context || '',
|
|
2404
|
+
description: task.description,
|
|
2405
|
+
progress,
|
|
2406
|
+
factCount,
|
|
2407
|
+
hintCount,
|
|
2408
|
+
});
|
|
2409
|
+
this.messages.push({
|
|
2410
|
+
role: 'system',
|
|
2411
|
+
content: promptContent,
|
|
2412
|
+
});
|
|
2413
|
+
}
|
|
2414
|
+
// 限时 2 分钟,最多 3 轮
|
|
2415
|
+
const concludeMaxIterations = 3;
|
|
2416
|
+
const concludeMaxMinutes = 2;
|
|
2417
|
+
try {
|
|
2418
|
+
const core = new AgentCore();
|
|
2419
|
+
const loopResult = await core.run({
|
|
2420
|
+
maxRounds: concludeMaxIterations,
|
|
2421
|
+
maxRuntimeMinutes: concludeMaxMinutes,
|
|
2422
|
+
shouldStop: () => this.stopped,
|
|
2423
|
+
onStopped: async () => this.markTerminalRuntimeOutcome({
|
|
2424
|
+
kind: 'recovering',
|
|
2425
|
+
reason: 'Agent stopped during conclude phase',
|
|
2426
|
+
faultClass: 'worker_stopped',
|
|
2427
|
+
recoverable: true,
|
|
2428
|
+
phase: 'conclude',
|
|
2429
|
+
}),
|
|
2430
|
+
onBoundReached: async (reason) => {
|
|
2431
|
+
agentLogger.info(`[${this.name}] Conclude 阶段达到限制: ${reason}`);
|
|
2432
|
+
return { type: 'break', result: 'Conclude phase completed' };
|
|
2433
|
+
},
|
|
2434
|
+
runRound: async (roundNumber) => this.roundExecutor.executeRuntimeRound({
|
|
2435
|
+
round: roundNumber,
|
|
2436
|
+
run: async () => {
|
|
2437
|
+
if (this.stopped) {
|
|
2438
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2439
|
+
kind: 'recovering',
|
|
2440
|
+
reason: 'Agent stopped during conclude phase',
|
|
2441
|
+
faultClass: 'worker_stopped',
|
|
2442
|
+
recoverable: true,
|
|
2443
|
+
phase: 'conclude',
|
|
2444
|
+
}) };
|
|
2445
|
+
}
|
|
2446
|
+
this.runtimeState.beginRound();
|
|
2447
|
+
// 调用 LLM
|
|
2448
|
+
const tools = await this.getToolDefinitions(task);
|
|
2449
|
+
const guard = createLlmGuard({
|
|
2450
|
+
actorLabel: this.name,
|
|
2451
|
+
maxRetries: 2, // Conclude 阶段减少重试次数
|
|
2452
|
+
backoffBaseMs: runtimeConfig.llm.backoff_base_ms,
|
|
2453
|
+
classifyError: classifyLLMError,
|
|
2454
|
+
cbScope: `conclude::${this.name}`,
|
|
2455
|
+
langfuseSessionId: this.sessionId,
|
|
2456
|
+
langfuseAgentId: this.agentId,
|
|
2457
|
+
langfuseTaskId: task.id,
|
|
2458
|
+
});
|
|
2459
|
+
this.currentLlmAbortController = new AbortController();
|
|
2460
|
+
let response;
|
|
2461
|
+
try {
|
|
2462
|
+
const inputManifest = buildLlmInputManifest({
|
|
2463
|
+
actor: 'worker',
|
|
2464
|
+
actorLabel: this.name,
|
|
2465
|
+
sessionId: this.sessionId,
|
|
2466
|
+
agentId: this.agentId,
|
|
2467
|
+
taskId: task.id,
|
|
2468
|
+
model: this.model,
|
|
2469
|
+
messages: this.messages,
|
|
2470
|
+
tools,
|
|
2471
|
+
});
|
|
2472
|
+
agentLogger.debug(`[llm-input] ${summarizeLlmInputManifest(inputManifest)}`);
|
|
2473
|
+
this.emitter.emit('llm:input_manifest', {
|
|
2474
|
+
sessionId: this.sessionId,
|
|
2475
|
+
actor: 'worker',
|
|
2476
|
+
actorLabel: this.name,
|
|
2477
|
+
manifest: inputManifest,
|
|
2478
|
+
});
|
|
2479
|
+
response = await guard.call(this.llm, this.messages, this.model, tools, ENABLE_STREAMING, this.currentLlmAbortController.signal, {
|
|
2480
|
+
onText: (text) => {
|
|
2481
|
+
this.emitter.emit('agent:text_chunk', {
|
|
2482
|
+
agentId: this.agentId,
|
|
2483
|
+
agentName: this.name,
|
|
2484
|
+
sessionId: this.sessionId,
|
|
2485
|
+
chunk: text,
|
|
2486
|
+
});
|
|
2487
|
+
},
|
|
2488
|
+
}, {
|
|
2489
|
+
actorType: 'agent',
|
|
2490
|
+
actorLabel: this.name,
|
|
2491
|
+
purpose: 'summary',
|
|
2492
|
+
sessionId: this.sessionId,
|
|
2493
|
+
agentId: this.agentId,
|
|
2494
|
+
agentName: this.name,
|
|
2495
|
+
taskId: task.id,
|
|
2496
|
+
role: this.role,
|
|
2497
|
+
},
|
|
2498
|
+
// 防漂移:Worker Conclude 摘要走确定性温度
|
|
2499
|
+
getReasoningGenerateOptions());
|
|
2500
|
+
}
|
|
2501
|
+
catch (error) {
|
|
2502
|
+
// CircuitBreaker OPEN:sleep 到探针窗口再 continue
|
|
2503
|
+
if (error instanceof CircuitOpenError) {
|
|
2504
|
+
const waitMs = error.retryAfterMs;
|
|
2505
|
+
agentLogger.warn(`[${this.name}] Conclude CB OPEN provider="${error.providerKey}",sleep ${Math.ceil(waitMs / 1000)}s`);
|
|
2506
|
+
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
2507
|
+
return { type: 'continue' };
|
|
2508
|
+
}
|
|
2509
|
+
// 超时错误:不重试,直接 continue 重新请求
|
|
2510
|
+
const concludeClassified = classifyLLMError(error);
|
|
2511
|
+
if (concludeClassified.llmErrorKind === 'request_timeout' ||
|
|
2512
|
+
concludeClassified.llmErrorKind === 'connect_timeout' ||
|
|
2513
|
+
concludeClassified.llmErrorKind === 'stream_timeout') {
|
|
2514
|
+
agentLogger.warn(`[${this.name}] Conclude 阶段 LLM 超时 (${concludeClassified.llmErrorKind}),重新请求中...`);
|
|
2515
|
+
return { type: 'continue' };
|
|
2516
|
+
}
|
|
2517
|
+
agentLogger.error(`[${this.name}] Conclude 阶段 LLM 调用失败:`, error);
|
|
2518
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2519
|
+
kind: 'recovering',
|
|
2520
|
+
reason: `Conclude phase failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
2521
|
+
faultClass: 'worker_runtime',
|
|
2522
|
+
recoverable: true,
|
|
2523
|
+
phase: 'conclude',
|
|
2524
|
+
}) };
|
|
2525
|
+
}
|
|
2526
|
+
// 处理响应
|
|
2527
|
+
const { done, result } = await this.processResponse(response, task);
|
|
2528
|
+
if (done) {
|
|
2529
|
+
return { type: 'break', result: result || 'Conclude phase completed' };
|
|
2530
|
+
}
|
|
2531
|
+
return { type: 'continue' };
|
|
2532
|
+
},
|
|
2533
|
+
}),
|
|
2534
|
+
});
|
|
2535
|
+
if (this.terminalRuntimeOutcome || this.isRuntimeFailureLoopResult(loopResult)) {
|
|
2536
|
+
return this.buildTerminalFailureResult(loopResult || 'Conclude phase failed', {
|
|
2537
|
+
kind: 'recovering',
|
|
2538
|
+
faultClass: 'worker_runtime',
|
|
2539
|
+
recoverable: true,
|
|
2540
|
+
phase: 'conclude',
|
|
2541
|
+
});
|
|
2542
|
+
}
|
|
2543
|
+
return createSuccessResult({
|
|
2544
|
+
summary: loopResult || 'Conclude phase completed',
|
|
2545
|
+
filesChanged: [],
|
|
2546
|
+
duration: Date.now() - this.runtimeState.startTime,
|
|
2547
|
+
});
|
|
2548
|
+
}
|
|
2549
|
+
catch (error) {
|
|
2550
|
+
agentLogger.error(`[${this.name}] Conclude 阶段执行错误:`, error);
|
|
2551
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
2552
|
+
return createFailureResult({
|
|
2553
|
+
summary: normalizedError.message,
|
|
2554
|
+
error: normalizedError.stack || normalizedError.message,
|
|
2555
|
+
duration: Date.now() - this.runtimeState.startTime,
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* 推断任务类型
|
|
2561
|
+
*/
|
|
2562
|
+
async inferTaskType(task) {
|
|
2563
|
+
const classification = await TaskClassifier.classify({
|
|
2564
|
+
...task,
|
|
2565
|
+
session_id: task.session_id || this.sessionId,
|
|
2566
|
+
}, {
|
|
2567
|
+
blackboardGraph: this.blackboardGraph,
|
|
2568
|
+
llm: this.createAgentEventStreamClient(`Agent-${this.name}-TaskClassifier`),
|
|
2569
|
+
model: this.model,
|
|
2570
|
+
});
|
|
2571
|
+
agentLogger.info(`[${this.name}] Task classified as ${classification.type}: ${classification.reason}`);
|
|
2572
|
+
return classification.type;
|
|
2573
|
+
}
|
|
2574
|
+
async run(task, isResume = false, recoveredState) {
|
|
2575
|
+
this.runtimeState.initializeTaskScope(task, this.workspace);
|
|
2576
|
+
// 复用同名 worker 跑新任务时,清空上个任务的产物轨迹与收尾,防止旧产物泄漏到新任务。
|
|
2577
|
+
this.toolTrace.filesCreated.clear();
|
|
2578
|
+
this.toolTrace.filesModified.clear();
|
|
2579
|
+
this.toolTrace.commandsRun.length = 0;
|
|
2580
|
+
this.attemptCompletion = undefined;
|
|
2581
|
+
this.terminalRuntimeOutcome = null;
|
|
2582
|
+
const recoveredIteration = recoveredState?.iteration || 0;
|
|
2583
|
+
const recoveredToolCallCount = recoveredState?.toolCallCount || 0;
|
|
2584
|
+
if (this.inheritedHistory && this.inheritedHistory.length > 0) {
|
|
2585
|
+
// 继承历史(复用同名 worker 跑新任务 / 复活同一任务),统一走 inherited 初始化。
|
|
2586
|
+
// 必须优先于 initializeMessages(后者 this.messages=[] 会清空继承内容)。
|
|
2587
|
+
await this.initializeMessagesFromInherited(task, recoveredIteration, recoveredToolCallCount);
|
|
2588
|
+
}
|
|
2589
|
+
else if (isResume && this.db) {
|
|
2590
|
+
const history = await this.db.getAgentConversation?.(this.sessionId, this.agentId);
|
|
2591
|
+
if (history && history.length > 0) {
|
|
2592
|
+
// 自愈中断孤儿:worker 被 kill 后从 DB 恢复时,assistant 发起的 tool_call
|
|
2593
|
+
// 可能缺配对 tool_result。补语义占位,避免 provider 反复合成 [tool result missing]。
|
|
2594
|
+
const { healed, addedCount } = healInterruptedToolCalls(history);
|
|
2595
|
+
if (addedCount > 0) {
|
|
2596
|
+
agentLogger.warn(`[WorkerResumeHeal] 从 DB 恢复时检测到 ${addedCount} 个中断孤儿 tool_call,补占位`);
|
|
2597
|
+
this.messages = healed;
|
|
2598
|
+
}
|
|
2599
|
+
else {
|
|
2600
|
+
this.messages = history;
|
|
2601
|
+
}
|
|
2602
|
+
this.runtimeState.restoreProgress(recoveredIteration, recoveredToolCallCount || history.filter(m => m.role === 'tool').length);
|
|
2603
|
+
agentLogger.info(`♻️ 从数据库恢复对话历史 (共 ${history.length} 条消息)`);
|
|
2604
|
+
}
|
|
2605
|
+
else {
|
|
2606
|
+
await this.initializeMessages(task);
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2609
|
+
else {
|
|
2610
|
+
await this.initializeMessages(task);
|
|
2611
|
+
}
|
|
2612
|
+
this.runtimeState.restoreProgress(recoveredIteration, this.toolCallCount);
|
|
2613
|
+
// 发射 Agent 启动事件
|
|
2614
|
+
await this.logEvent('agent_spawned', {
|
|
2615
|
+
agent_id: this.agentId,
|
|
2616
|
+
name: this.name,
|
|
2617
|
+
role: this.role,
|
|
2618
|
+
task_id: task.id,
|
|
2619
|
+
task_subject: task.subject,
|
|
2620
|
+
});
|
|
2621
|
+
this.emitter.emit('agent:spawned', {
|
|
2622
|
+
sessionId: this.sessionId,
|
|
2623
|
+
agentId: this.agentId,
|
|
2624
|
+
name: this.name,
|
|
2625
|
+
role: this.role,
|
|
2626
|
+
taskId: task.id,
|
|
2627
|
+
baselineRole: this.handle?.capabilityDetails?.baselineRole,
|
|
2628
|
+
skillNames: this.handle?.capabilityDetails?.skillNames,
|
|
2629
|
+
droppedTools: this.handle?.capabilityDetails?.droppedTools,
|
|
2630
|
+
tools: this.handle?.capabilityDetails?.tools,
|
|
2631
|
+
});
|
|
2632
|
+
try {
|
|
2633
|
+
// 不可重试错误的恢复尝试标记(仅允许一次恢复,避免死循环)
|
|
2634
|
+
let nonRetryableRecoveryAttempted = false;
|
|
2635
|
+
const core = new AgentCore();
|
|
2636
|
+
const loopResult = await core.run({
|
|
2637
|
+
maxRounds: this.maxIterations,
|
|
2638
|
+
maxRuntimeMinutes: this.maxRuntimeMinutes,
|
|
2639
|
+
shouldStop: () => this.stopped,
|
|
2640
|
+
onStopped: async () => this.markTerminalRuntimeOutcome({
|
|
2641
|
+
kind: 'recovering',
|
|
2642
|
+
reason: 'Agent stopped',
|
|
2643
|
+
faultClass: 'worker_stopped',
|
|
2644
|
+
recoverable: true,
|
|
2645
|
+
phase: 'execute',
|
|
2646
|
+
}),
|
|
2647
|
+
onBoundReached: async (reason) => {
|
|
2648
|
+
// 如果是时长超时,抛出 TimeoutError 触发 Conclude 阶段
|
|
2649
|
+
if (reason === 'max_runtime') {
|
|
2650
|
+
const elapsedMinutes = (Date.now() - this.runtimeState.startTime) / (1000 * 60);
|
|
2651
|
+
throw new TimeoutError(`Agent ${this.name} 执行超时 (${elapsedMinutes.toFixed(1)} 分钟)`, this.agentId, this.iteration, elapsedMinutes);
|
|
2652
|
+
}
|
|
2653
|
+
// 如果是轮次超时,继续执行(原有逻辑)
|
|
2654
|
+
const continuationMsg = reason === 'max_rounds'
|
|
2655
|
+
? `达到最大迭代窗口 (${this.maxIterations}),继续推进任务`
|
|
2656
|
+
: `达到最大运行时长窗口 (${this.maxRuntimeMinutes} 分钟),继续推进任务`;
|
|
2657
|
+
this.emitter.emit('agent:status', {
|
|
2658
|
+
agentId: this.agentId,
|
|
2659
|
+
agentName: this.name,
|
|
2660
|
+
sessionId: this.sessionId,
|
|
2661
|
+
status: `♻️ ${continuationMsg}`,
|
|
2662
|
+
});
|
|
2663
|
+
await this.logEvent('continuation_window_reached', {
|
|
2664
|
+
reason,
|
|
2665
|
+
iteration: this.iteration,
|
|
2666
|
+
maxIterations: this.maxIterations,
|
|
2667
|
+
maxRuntimeMinutes: this.maxRuntimeMinutes,
|
|
2668
|
+
});
|
|
2669
|
+
this.addMessage({
|
|
2670
|
+
role: 'system',
|
|
2671
|
+
content: `运行时续跑:已达到内部${reason === 'max_rounds' ? '轮次' : '时长'}窗口,但任务尚未完成。请将该窗口视为预算刷新点并继续推进。`,
|
|
2672
|
+
});
|
|
2673
|
+
return { type: 'reset_budget' };
|
|
2674
|
+
},
|
|
2675
|
+
runRound: async (roundNumber) => this.roundExecutor.executeRuntimeRound({
|
|
2676
|
+
round: roundNumber,
|
|
2677
|
+
run: async () => {
|
|
2678
|
+
if (this.stopped) {
|
|
2679
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2680
|
+
kind: 'recovering',
|
|
2681
|
+
reason: 'Agent stopped',
|
|
2682
|
+
faultClass: 'worker_stopped',
|
|
2683
|
+
recoverable: true,
|
|
2684
|
+
phase: 'execute',
|
|
2685
|
+
}) };
|
|
2686
|
+
}
|
|
2687
|
+
// 检查是否被暂停
|
|
2688
|
+
if (this.paused) {
|
|
2689
|
+
// 等待恢复,定期检查 inbox 是否有 resume 消息
|
|
2690
|
+
const resumeMsg = await this.checkInboxForResume();
|
|
2691
|
+
if (!resumeMsg) {
|
|
2692
|
+
// 没有恢复消息,继续等待
|
|
2693
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
2694
|
+
return { type: 'repeat' };
|
|
2695
|
+
}
|
|
2696
|
+
// 收到恢复消息,继续执行
|
|
2697
|
+
this.paused = false;
|
|
2698
|
+
}
|
|
2699
|
+
// 检查是否处于干预等待状态
|
|
2700
|
+
if (this.stalled) {
|
|
2701
|
+
const confirmMsg = await this.checkInboxForInterventionConfirm();
|
|
2702
|
+
if (!confirmMsg) {
|
|
2703
|
+
// 等待用户确认,定期检查 inbox
|
|
2704
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
2705
|
+
return { type: 'repeat' };
|
|
2706
|
+
}
|
|
2707
|
+
// 用户确认继续,恢复执行
|
|
2708
|
+
this.resumeWithIntervention();
|
|
2709
|
+
}
|
|
2710
|
+
this.runtimeState.beginRound();
|
|
2711
|
+
// 上报健康指标给 AgentHandle
|
|
2712
|
+
if (this.handle) {
|
|
2713
|
+
this.handle.lastProgress = Date.now();
|
|
2714
|
+
this.handle.iteration = this.iteration;
|
|
2715
|
+
this.handle.toolCalls = this.toolCallCount;
|
|
2716
|
+
}
|
|
2717
|
+
this.persistResumeCheckpoint(task);
|
|
2718
|
+
// 检查收件箱
|
|
2719
|
+
const shouldStop = await this.checkInbox();
|
|
2720
|
+
if (shouldStop) {
|
|
2721
|
+
return { type: 'break', result: this.terminalRuntimeOutcome?.reason || `被Leader停止: ${this.messages[this.messages.length - 1]?.content || '未知原因'}` };
|
|
2722
|
+
}
|
|
2723
|
+
// 检查并处理 Leader 运行时干预指令
|
|
2724
|
+
const interventionResult = await this.checkInboxForIntervention();
|
|
2725
|
+
if (interventionResult) {
|
|
2726
|
+
if (interventionResult.type === 'repeat') {
|
|
2727
|
+
this.runtimeState.repeatRound();
|
|
2728
|
+
return { type: 'repeat' };
|
|
2729
|
+
}
|
|
2730
|
+
// nudge: continue, message injected below
|
|
2731
|
+
}
|
|
2732
|
+
// 发射思考中事件
|
|
2733
|
+
this.emitter.emit('agent:thinking', {
|
|
2734
|
+
agentId: this.agentId,
|
|
2735
|
+
agentName: this.name,
|
|
2736
|
+
sessionId: this.sessionId,
|
|
2737
|
+
iteration: this.iteration,
|
|
2738
|
+
});
|
|
2739
|
+
const contextStartedAt = Date.now();
|
|
2740
|
+
this.contextManager.setMessages(this.messages);
|
|
2741
|
+
this.messages = await this.contextManager.manage();
|
|
2742
|
+
const managedAt = Date.now();
|
|
2743
|
+
await this.appendRuntimeContextManifestIfChanged();
|
|
2744
|
+
this.contextManager.setMessages(this.messages);
|
|
2745
|
+
const ctxTokens = await this.contextManager.getTokenCount(this.messages);
|
|
2746
|
+
const tokenCountedAt = Date.now();
|
|
2747
|
+
agentLogger.debug(`[llm-phase] ${this.name} context_manage=${managedAt - contextStartedAt}ms token_count=${tokenCountedAt - managedAt}ms`);
|
|
2748
|
+
const ctxState = this.contextManager.getRuntimeState();
|
|
2749
|
+
this.emitter.emit('agent:context_updated', {
|
|
2750
|
+
sessionId: this.sessionId,
|
|
2751
|
+
agentId: this.agentId,
|
|
2752
|
+
agentName: this.name,
|
|
2753
|
+
tokens: ctxTokens,
|
|
2754
|
+
maxTokens: ctxState.maxTokens,
|
|
2755
|
+
});
|
|
2756
|
+
// 注入 Leader nudge 干预消息(如有)
|
|
2757
|
+
if (this.nudgeMessage) {
|
|
2758
|
+
this.messages.push({
|
|
2759
|
+
role: 'system',
|
|
2760
|
+
content: `[Leader 指导] ${this.nudgeMessage}`,
|
|
2761
|
+
});
|
|
2762
|
+
this.nudgeMessage = null; // 消费后清除,避免重复注入
|
|
2763
|
+
}
|
|
2764
|
+
// 调用 LLM
|
|
2765
|
+
const toolsStartedAt = Date.now();
|
|
2766
|
+
const tools = await this.getToolDefinitions(task);
|
|
2767
|
+
agentLogger.debug(`[llm-phase] ${this.name} tool_definitions=${Date.now() - toolsStartedAt}ms tool_count=${tools?.length ?? 0}`);
|
|
2768
|
+
const inputManifest = buildLlmInputManifest({
|
|
2769
|
+
actor: 'worker',
|
|
2770
|
+
actorLabel: this.name,
|
|
2771
|
+
sessionId: this.sessionId,
|
|
2772
|
+
agentId: this.agentId,
|
|
2773
|
+
taskId: task.id,
|
|
2774
|
+
model: this.model,
|
|
2775
|
+
messages: this.messages,
|
|
2776
|
+
tools,
|
|
2777
|
+
});
|
|
2778
|
+
agentLogger.debug(`[llm-input] ${summarizeLlmInputManifest(inputManifest)}`);
|
|
2779
|
+
this.emitter.emit('llm:input_manifest', {
|
|
2780
|
+
sessionId: this.sessionId,
|
|
2781
|
+
actor: 'worker',
|
|
2782
|
+
actorLabel: this.name,
|
|
2783
|
+
manifest: inputManifest,
|
|
2784
|
+
});
|
|
2785
|
+
let response;
|
|
2786
|
+
// ─── LLM 调用(LlmGuard 封装重试逻辑)───
|
|
2787
|
+
// cbScope 按 agent 名字拆分:每个 worker 拥有独立 CircuitBreaker,
|
|
2788
|
+
// 避免单个 worker 连续失败把所有 worker 全员熔断(共享串扰)。
|
|
2789
|
+
const guard = createLlmGuard({
|
|
2790
|
+
actorLabel: this.name,
|
|
2791
|
+
maxRetries: this.MAX_TIMEOUT_RETRIES,
|
|
2792
|
+
backoffBaseMs: runtimeConfig.llm.backoff_base_ms,
|
|
2793
|
+
classifyError: classifyLLMError,
|
|
2794
|
+
cbScope: `agent::${this.name}`,
|
|
2795
|
+
langfuseSessionId: this.sessionId,
|
|
2796
|
+
langfuseAgentId: this.agentId,
|
|
2797
|
+
langfuseTaskId: task.id,
|
|
2798
|
+
});
|
|
2799
|
+
if (this.stopped) {
|
|
2800
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2801
|
+
kind: 'recovering',
|
|
2802
|
+
reason: 'Agent stopped before LLM call',
|
|
2803
|
+
faultClass: 'worker_stopped',
|
|
2804
|
+
recoverable: true,
|
|
2805
|
+
phase: 'execute',
|
|
2806
|
+
}) };
|
|
2807
|
+
}
|
|
2808
|
+
this.currentLlmAbortController = new AbortController();
|
|
2809
|
+
const buffers = createStreamHookBuffers({
|
|
2810
|
+
scope: 'agent',
|
|
2811
|
+
emitter: this.emitter,
|
|
2812
|
+
sessionId: this.sessionId,
|
|
2813
|
+
agentId: this.agentId,
|
|
2814
|
+
agentName: this.name,
|
|
2815
|
+
flushThreshold: runtimeConfig.leader.stream_buffer_flush_threshold,
|
|
2816
|
+
});
|
|
2817
|
+
// in-flight LLM 心跳:request_timeout 全程(首 token 前)worker 除 30s setInterval 外零 IPC,
|
|
2818
|
+
// 父进程心跳阈值会把 LlmGuard 正在重试的活 worker 误判 heartbeat_timeout 杀掉。期间持续 emit
|
|
2819
|
+
// agent:progress(在 WorkerProcessEntry.bridgedEvents → 桥接到父进程 reset lastHeartbeat)。
|
|
2820
|
+
// 声明在 try 外,确保 finally 任何出口(成功/异常/abort)都能 stop。
|
|
2821
|
+
let llmHeartbeat = null;
|
|
2822
|
+
try {
|
|
2823
|
+
llmHeartbeat = startLlmInFlightHeartbeat({
|
|
2824
|
+
emitter: this.emitter,
|
|
2825
|
+
sessionId: this.sessionId,
|
|
2826
|
+
agentId: this.agentId,
|
|
2827
|
+
agentName: this.name,
|
|
2828
|
+
taskId: task.id,
|
|
2829
|
+
scope: 'agent',
|
|
2830
|
+
});
|
|
2831
|
+
response = await guard.call(this.llm, this.messages, this.model, tools, ENABLE_STREAMING, this.currentLlmAbortController.signal, wrapLlmHooksForEmitter({
|
|
2832
|
+
scope: 'agent',
|
|
2833
|
+
emitter: this.emitter,
|
|
2834
|
+
sessionId: this.sessionId,
|
|
2835
|
+
agentId: this.agentId,
|
|
2836
|
+
agentName: this.name,
|
|
2837
|
+
logToolCall: (name) => agentLogger.debug(`\n工具调用: ${name}`),
|
|
2838
|
+
// Wiki 等下游订阅者依赖原始 chunk(按 LLM 输出节奏),不能受缓冲影响
|
|
2839
|
+
onRawTextChunk: (text) => {
|
|
2840
|
+
const self = this;
|
|
2841
|
+
if (typeof self.onStreamChunk === 'function') {
|
|
2842
|
+
self.onStreamChunk(self.currentSectionId ?? '', self.currentSectionTitle ?? '', text);
|
|
2843
|
+
}
|
|
2844
|
+
},
|
|
2845
|
+
}, buffers), {
|
|
2846
|
+
actorType: 'agent',
|
|
2847
|
+
actorLabel: this.name,
|
|
2848
|
+
purpose: inferAgentGatewayPurpose(task, this.role),
|
|
2849
|
+
sessionId: this.sessionId,
|
|
2850
|
+
agentId: this.agentId,
|
|
2851
|
+
agentName: this.name,
|
|
2852
|
+
taskId: task.id,
|
|
2853
|
+
role: this.role,
|
|
2854
|
+
},
|
|
2855
|
+
// 防漂移:Worker 主推理走确定性温度(默认 0),避免工具选择随机抖动
|
|
2856
|
+
getReasoningGenerateOptions());
|
|
2857
|
+
// ─── 成功路径 ───
|
|
2858
|
+
const responseText = typeof response.content === 'string' ? response.content : '';
|
|
2859
|
+
if (responseText) {
|
|
2860
|
+
this.emitter.emit('agent:text', {
|
|
2861
|
+
agentId: this.agentId,
|
|
2862
|
+
agentName: this.name,
|
|
2863
|
+
sessionId: this.sessionId,
|
|
2864
|
+
content: responseText,
|
|
2865
|
+
reasoningContent: thinkingBlocksToText(response.thinking),
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
catch (error) {
|
|
2870
|
+
const abortedSignal = this.currentLlmAbortController?.signal.aborted ?? false;
|
|
2871
|
+
this.currentLlmAbortController = null;
|
|
2872
|
+
// 用户/Leader 主动 abort(ESC、retry_llm、P0 干预):不应进入错误重试路径,
|
|
2873
|
+
// 直接 repeat 让外层主循环按干预后的状态重新跑一次(注入消息、新指令)。
|
|
2874
|
+
// 否则 "LLM call aborted by caller" 会被 classifyLLMError 当成 unknown_error,
|
|
2875
|
+
// 触发 break 或外层 retry 累加,把"中断后重试"变成"中断后退出/反复重试"。
|
|
2876
|
+
const errMsg = error instanceof Error ? error.message : String(error);
|
|
2877
|
+
if (abortedSignal || errMsg.includes('aborted by caller')) {
|
|
2878
|
+
agentLogger.info(`[${this.name}] LLM 调用被 abort(用户/Leader 干预),repeat 主循环`);
|
|
2879
|
+
return { type: 'repeat' };
|
|
2880
|
+
}
|
|
2881
|
+
// CircuitBreaker OPEN:sleep 到探针窗口再 repeat 重试,
|
|
2882
|
+
// 避免 200ms 高频 retry 死循环
|
|
2883
|
+
if (error instanceof CircuitOpenError) {
|
|
2884
|
+
const waitMs = error.retryAfterMs;
|
|
2885
|
+
const waitSec = Math.ceil(waitMs / 1000);
|
|
2886
|
+
agentLogger.warn(`[${this.name}] CB OPEN provider="${error.providerKey}",sleep ${waitSec}s 等待 HALF_OPEN`);
|
|
2887
|
+
this.emitter.emit('agent:status', {
|
|
2888
|
+
agentId: this.agentId,
|
|
2889
|
+
agentName: this.name,
|
|
2890
|
+
sessionId: this.sessionId,
|
|
2891
|
+
status: `🛑 Provider 暂不可用,${waitSec}s 后重试`,
|
|
2892
|
+
});
|
|
2893
|
+
await new Promise((resolve) => setTimeout(resolve, waitMs));
|
|
2894
|
+
return { type: 'repeat' };
|
|
2895
|
+
}
|
|
2896
|
+
const classified = classifyLLMError(error);
|
|
2897
|
+
const errorMsg = classified.message;
|
|
2898
|
+
const errorLabel = formatLLMErrorLabel(classified);
|
|
2899
|
+
const rawErrorDetail = classified.rawMessage || (error instanceof Error ? error.message : String(error));
|
|
2900
|
+
const stackTrace = error instanceof Error ? `\n${error.stack ?? ''}` : '';
|
|
2901
|
+
// === 超时错误:LlmGuard 已不重试直接抛出。走 ESC 中断语义:不注入错误消息、
|
|
2902
|
+
// 不累加外层重试计数,直接 repeat 让主循环重新发起 LLM 请求。
|
|
2903
|
+
// CircuitBreaker 已在 LlmGuard 内累积失败计数,持续超时最终熔断走 CircuitOpenError 停下。
|
|
2904
|
+
if (classified.llmErrorKind === 'request_timeout' ||
|
|
2905
|
+
classified.llmErrorKind === 'connect_timeout' ||
|
|
2906
|
+
classified.llmErrorKind === 'stream_timeout') {
|
|
2907
|
+
agentLogger.warn(`[${this.name}] LLM 超时 (${errorLabel}),重新请求中...`);
|
|
2908
|
+
this.emitter.emit('agent:status', {
|
|
2909
|
+
agentId: this.agentId,
|
|
2910
|
+
agentName: this.name,
|
|
2911
|
+
sessionId: this.sessionId,
|
|
2912
|
+
status: `⏱️ LLM 超时,重新请求中...`,
|
|
2913
|
+
});
|
|
2914
|
+
// 抢救 partial content
|
|
2915
|
+
const partialTimeout = error.partialContent;
|
|
2916
|
+
if (typeof partialTimeout === 'string' && partialTimeout.trim()) {
|
|
2917
|
+
this.messages.push({ role: 'assistant', content: partialTimeout });
|
|
2918
|
+
agentLogger.info(`[${this.name}] 超时重请求:已抢救 partial content (${partialTimeout.length} chars)`);
|
|
2919
|
+
}
|
|
2920
|
+
return { type: 'repeat' };
|
|
2921
|
+
}
|
|
2922
|
+
agentLogger.error(`[${this.name}] LLM ${errorLabel},自动重试中... 完整错误: ${rawErrorDetail}${stackTrace}`);
|
|
2923
|
+
await this.logEvent('llm_error', {
|
|
2924
|
+
iteration: this.iteration,
|
|
2925
|
+
kind: classified.llmErrorKind,
|
|
2926
|
+
error: errorMsg,
|
|
2927
|
+
fullDetail: rawErrorDetail + stackTrace,
|
|
2928
|
+
});
|
|
2929
|
+
// === 上下文溢出兜底:HTTP 413 / context_length_exceeded ===
|
|
2930
|
+
// 重试同样的输入只会反复 413,必须主动触发硬重置压缩;
|
|
2931
|
+
// 同时不再注入错误 system 消息,避免上下文继续膨胀。
|
|
2932
|
+
if (classified.llmErrorKind === 'context_overflow') {
|
|
2933
|
+
const ctxMgr = this.contextManager;
|
|
2934
|
+
const tokens = ctxMgr ? await ctxMgr.getTokenCount().catch(() => 0) : 0;
|
|
2935
|
+
const threshold = ctxMgr?.getThreshold() ?? 0;
|
|
2936
|
+
agentLogger.warn(`[${this.name}] 收到 ${classified.statusCode ?? '?'} ${errorLabel},主动触发硬重置`);
|
|
2937
|
+
this.emitter.emit('context:overflow', {
|
|
2938
|
+
sessionId: this.sessionId,
|
|
2939
|
+
tokens,
|
|
2940
|
+
threshold,
|
|
2941
|
+
owner: 'agent',
|
|
2942
|
+
agentId: this.agentId,
|
|
2943
|
+
agentName: this.name,
|
|
2944
|
+
});
|
|
2945
|
+
this.toolLoopDetector.reset();
|
|
2946
|
+
return { type: 'repeat' };
|
|
2947
|
+
}
|
|
2948
|
+
// === 连续 unknown_error:LlmGuard 内部已重试 5 次仍失败 ===
|
|
2949
|
+
// Worker 无 compact 能力,直接 break 让 Leader 处理(Leader 会触发 compact)。
|
|
2950
|
+
// 不再走外层 retry(已耗尽,追加 error 消息只增上下文恶化问题)。
|
|
2951
|
+
if (classified.llmErrorKind === 'unknown_error') {
|
|
2952
|
+
agentLogger.warn(`[${this.name}] 连续 unknown_error,LlmGuard 内部已重试耗尽,Worker 退出等待 Leader 处理`);
|
|
2953
|
+
// 抢救 partial content:LlmGuard 内部重试时可能已累积部分输出,注入对话历史避免白输
|
|
2954
|
+
const partialUnknown = error.partialContent;
|
|
2955
|
+
if (typeof partialUnknown === 'string' && partialUnknown.trim()) {
|
|
2956
|
+
this.messages.push({ role: 'assistant', content: partialUnknown });
|
|
2957
|
+
agentLogger.info(`[${this.name}] unknown_error 终态:已抢救 partial content (${partialUnknown.length} chars)`);
|
|
2958
|
+
}
|
|
2959
|
+
this.llmErrorRetryCount = 0;
|
|
2960
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2961
|
+
kind: 'recovering',
|
|
2962
|
+
reason: `[${errorLabel}] ${classified.message}`,
|
|
2963
|
+
faultClass: 'worker_runtime',
|
|
2964
|
+
llmErrorKind: classified.llmErrorKind,
|
|
2965
|
+
recoverable: true,
|
|
2966
|
+
phase: 'execute',
|
|
2967
|
+
}) };
|
|
2968
|
+
}
|
|
2969
|
+
// === 鉴权 / 配额耗尽 / Provider 参数错误:retry 没用,必须 break 让 Leader 接管 ===
|
|
2970
|
+
// 但如果 error 自身标记了 retryable=true (如 "content is empty" 瞬态错误),
|
|
2971
|
+
// 则不应 break——应该走下面的重试逻辑。
|
|
2972
|
+
if ((classified.llmErrorKind === 'auth_error' ||
|
|
2973
|
+
classified.llmErrorKind === 'quota_exhausted' ||
|
|
2974
|
+
(classified.llmErrorKind === 'provider_error' && !classified.retryable))) {
|
|
2975
|
+
const isAuth = classified.llmErrorKind === 'auth_error';
|
|
2976
|
+
agentLogger.error(`[${this.name}] 收到 ${classified.statusCode ?? '?'} ${errorLabel},Worker 直接退出等待 Leader 处理`);
|
|
2977
|
+
this.emitter.emit('agent:status', {
|
|
2978
|
+
agentId: this.agentId,
|
|
2979
|
+
agentName: this.name,
|
|
2980
|
+
sessionId: this.sessionId,
|
|
2981
|
+
status: isAuth
|
|
2982
|
+
? `🛑 ${errorLabel}:等待 API Key 修复`
|
|
2983
|
+
: `🛑 ${errorLabel}:等待充值 / 切换模型`,
|
|
2984
|
+
});
|
|
2985
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
2986
|
+
kind: 'failed',
|
|
2987
|
+
reason: `[${errorLabel}] ${classified.message}`,
|
|
2988
|
+
faultClass: 'worker_runtime',
|
|
2989
|
+
recoverable: false,
|
|
2990
|
+
phase: 'execute',
|
|
2991
|
+
}) };
|
|
2992
|
+
}
|
|
2993
|
+
// 注入系统消息告知 Agent 当前错误状态,然后继续重试
|
|
2994
|
+
// 外层重试计数:LlmGuard 内部已穷尽自身预算后才会抛到这里。
|
|
2995
|
+
// 历史 bug:之前每个分支都直接 return repeat → 外层 retry 永远不累加 →
|
|
2996
|
+
// 网络持续抖动时形成 0ms 死循环。
|
|
2997
|
+
const outerRetry = ++this.llmErrorRetryCount;
|
|
2998
|
+
const outerMax = this.LLM_MAX_ERROR_RETRIES;
|
|
2999
|
+
if (outerRetry >= outerMax) {
|
|
3000
|
+
agentLogger.error(`[${this.name}] 外层 LLM 重试已达 ${outerRetry}/${outerMax} 次仍失败 (${errorLabel}),退出等待 Leader 处理`);
|
|
3001
|
+
// 抢救 partial content:LlmGuard 内部重试时可能已累积部分输出
|
|
3002
|
+
const partialExhausted = error.partialContent;
|
|
3003
|
+
if (typeof partialExhausted === 'string' && partialExhausted.trim()) {
|
|
3004
|
+
this.messages.push({ role: 'assistant', content: partialExhausted });
|
|
3005
|
+
agentLogger.info(`[${this.name}] 外层重试耗尽终态:已抢救 partial content (${partialExhausted.length} chars)`);
|
|
3006
|
+
}
|
|
3007
|
+
this.emitter.emit('agent:status', {
|
|
3008
|
+
agentId: this.agentId,
|
|
3009
|
+
agentName: this.name,
|
|
3010
|
+
sessionId: this.sessionId,
|
|
3011
|
+
status: `🛑 LLM 反复失败 (${errorLabel}):等待人工介入`,
|
|
3012
|
+
});
|
|
3013
|
+
this.llmErrorRetryCount = 0;
|
|
3014
|
+
return { type: 'break', result: this.markTerminalRuntimeOutcome({
|
|
3015
|
+
kind: 'recovering',
|
|
3016
|
+
reason: `[${errorLabel}] ${classified.message} (外层重试 ${outerRetry}/${outerMax} 次仍失败)`,
|
|
3017
|
+
faultClass: 'worker_runtime',
|
|
3018
|
+
llmErrorKind: classified.llmErrorKind,
|
|
3019
|
+
recoverable: true,
|
|
3020
|
+
phase: 'execute',
|
|
3021
|
+
}) };
|
|
3022
|
+
}
|
|
3023
|
+
// 注入错误通知,然后继续重试。
|
|
3024
|
+
// 400 provider_error 时不追加 system 消息——消息格式问题追加 system 只会让序列更不合法,
|
|
3025
|
+
// 且 LlmGuard 的 compact 已尝试清理历史。
|
|
3026
|
+
const isBadRequest = classified.llmErrorKind === 'provider_error' && classified.statusCode === 400;
|
|
3027
|
+
if (!isBadRequest) {
|
|
3028
|
+
this.messages.push({
|
|
3029
|
+
role: 'system',
|
|
3030
|
+
content: `⚠️ [系统通知] LLM 调用失败(${errorLabel}: ${rawErrorDetail}),外层已自动重试 ${outerRetry}/${outerMax} 次。系统将继续自动重试。`,
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
else {
|
|
3034
|
+
agentLogger.warn(`[${this.name}] 400 provider_error 外层重试 ${outerRetry}/${outerMax}:不注入 system 消息,依赖 compact+sanitizer 恢复`);
|
|
3035
|
+
}
|
|
3036
|
+
// 外层重试也要给 UI 可见反馈 + 刷新健康监控活动时间。
|
|
3037
|
+
// 否则 worker 在"每轮耗尽 5 次内层重试 → 外层再重试"的超时循环里,
|
|
3038
|
+
// 用户只看到 agent 长时间无输出却无任何告警(本次 bug 现象)。
|
|
3039
|
+
this.emitter.emit('agent:status', {
|
|
3040
|
+
agentId: this.agentId,
|
|
3041
|
+
agentName: this.name,
|
|
3042
|
+
sessionId: this.sessionId,
|
|
3043
|
+
status: `⏳ LLM ${errorLabel}:外层第 ${outerRetry}/${outerMax} 次重试中`,
|
|
3044
|
+
});
|
|
3045
|
+
// 外层退避:1s / 2s / 3s ... 封顶 30s,防止网络抖动时高频空转
|
|
3046
|
+
const outerBackoffMs = Math.min(outerRetry * 1000, 30_000);
|
|
3047
|
+
await new Promise((resolve) => setTimeout(resolve, outerBackoffMs));
|
|
3048
|
+
return { type: 'repeat' }; // 继续主循环,不中断
|
|
3049
|
+
}
|
|
3050
|
+
finally {
|
|
3051
|
+
llmHeartbeat?.stop();
|
|
3052
|
+
// 缓冲在调用结束时强制 flush,保证最后一段(短链 thinking / 残留文本)
|
|
3053
|
+
// 一定会通过 chunk 事件交付给 UI。
|
|
3054
|
+
buffers.flushAll();
|
|
3055
|
+
buffers.dispose();
|
|
3056
|
+
}
|
|
3057
|
+
// ─── 成功路径走到这里:清零外层 LLM 错误计数 ───
|
|
3058
|
+
this.llmErrorRetryCount = 0;
|
|
3059
|
+
// 处理响应
|
|
3060
|
+
const { done, result } = await this.processResponse(response, task);
|
|
3061
|
+
if (done) {
|
|
3062
|
+
this.clearResumeCheckpoint();
|
|
3063
|
+
this.emitter.emit('agent:stop', {
|
|
3064
|
+
agentId: this.agentId,
|
|
3065
|
+
name: this.name,
|
|
3066
|
+
sessionId: this.sessionId,
|
|
3067
|
+
});
|
|
3068
|
+
return { type: 'break', result: result || 'Task completed' };
|
|
3069
|
+
}
|
|
3070
|
+
// ─── 关键:工具执行后、下一轮 LLM 前,再次检查收件箱 ───
|
|
3071
|
+
// 防止在工具执行期间积压的 Leader 消息被延迟处理
|
|
3072
|
+
const postToolShouldStop = await this.checkInbox();
|
|
3073
|
+
if (postToolShouldStop) {
|
|
3074
|
+
return { type: 'break', result: this.terminalRuntimeOutcome?.reason || `被Leader停止: ${this.messages[this.messages.length - 1]?.content || '未知原因'}` };
|
|
3075
|
+
}
|
|
3076
|
+
// 工具执行后也检查干预指令
|
|
3077
|
+
const postToolIntervention = await this.checkInboxForIntervention();
|
|
3078
|
+
if (postToolIntervention && postToolIntervention.type === 'repeat') {
|
|
3079
|
+
this.runtimeState.repeatRound();
|
|
3080
|
+
return { type: 'repeat' };
|
|
3081
|
+
}
|
|
3082
|
+
agentLogger.debug(`第 ${this.iteration} 轮完成,继续下一轮...`);
|
|
3083
|
+
return { type: 'continue' };
|
|
3084
|
+
},
|
|
3085
|
+
}),
|
|
3086
|
+
});
|
|
3087
|
+
if (this.terminalRuntimeOutcome || this.isRuntimeFailureLoopResult(loopResult)) {
|
|
3088
|
+
return this.buildTerminalFailureResult(loopResult || 'Agent stopped', {
|
|
3089
|
+
kind: 'recovering',
|
|
3090
|
+
faultClass: 'worker_runtime',
|
|
3091
|
+
recoverable: true,
|
|
3092
|
+
phase: 'execute',
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
// 生成结构化返回结果
|
|
3096
|
+
const duration = Date.now() - this.runtimeState.startTime;
|
|
3097
|
+
const structuredResult = createSuccessResult({
|
|
3098
|
+
summary: loopResult || 'Agent stopped',
|
|
3099
|
+
// 真实追踪:tool 层执行期间已采集的 create/modify 文件路径(见 this.toolTrace),
|
|
3100
|
+
// 去重后输出 —— 与 worker 路径 collectCompletionFiles 同源数据,保持一致。
|
|
3101
|
+
filesChanged: Array.from(new Set([...this.toolTrace.filesCreated, ...this.toolTrace.filesModified])),
|
|
3102
|
+
duration,
|
|
3103
|
+
metadata: {
|
|
3104
|
+
iterations: this.iteration,
|
|
3105
|
+
toolCalls: this.toolCallCount,
|
|
3106
|
+
},
|
|
3107
|
+
});
|
|
3108
|
+
return structuredResult;
|
|
3109
|
+
}
|
|
3110
|
+
catch (error) {
|
|
3111
|
+
agentLogger.error(`[${this.name}] Agent 执行错误:`, error);
|
|
3112
|
+
this.emitter.emit('agent:error', {
|
|
3113
|
+
agentId: this.agentId,
|
|
3114
|
+
sessionId: this.sessionId,
|
|
3115
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
3116
|
+
});
|
|
3117
|
+
this.clearResumeCheckpoint();
|
|
3118
|
+
throw error;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
/**
|
|
3122
|
+
* 停止 Agent(完全终止,不可恢复)
|
|
3123
|
+
*/
|
|
3124
|
+
stop() {
|
|
3125
|
+
this.stopped = true;
|
|
3126
|
+
this.currentLlmAbortController?.abort();
|
|
3127
|
+
// 不清除 controller:保持 abort 状态,防止 stop() 后又启动新的 LLM call
|
|
3128
|
+
// 下次 LLM call 开始前会在 stopped 检查处拦截
|
|
3129
|
+
// 清理事件监听器
|
|
3130
|
+
if (this._contextOverflowUnsub) {
|
|
3131
|
+
this._contextOverflowUnsub();
|
|
3132
|
+
this._contextOverflowUnsub = null;
|
|
3133
|
+
}
|
|
3134
|
+
if (this._p0InterventionUnsub) {
|
|
3135
|
+
this._p0InterventionUnsub();
|
|
3136
|
+
this._p0InterventionUnsub = null;
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
/**
|
|
3140
|
+
* 暂停 Agent(保留进度,可随时恢复)
|
|
3141
|
+
* 不杀进程,只 abort 当前 LLM 调用,保存 checkpoint
|
|
3142
|
+
*/
|
|
3143
|
+
pause() {
|
|
3144
|
+
this.paused = true;
|
|
3145
|
+
this.currentLlmAbortController?.abort();
|
|
3146
|
+
// 保存 checkpoint 到 DB
|
|
3147
|
+
this.savePauseCheckpoint();
|
|
3148
|
+
agentLogger.info(`Agent ${this.name} 已暂停`);
|
|
3149
|
+
}
|
|
3150
|
+
/**
|
|
3151
|
+
* 干预 Agent(停下来等用户指令)
|
|
3152
|
+
* 暂停当前操作,存储干预指令,等待用户确认后继续
|
|
3153
|
+
*/
|
|
3154
|
+
intervene(instruction) {
|
|
3155
|
+
this.stalled = true;
|
|
3156
|
+
this.currentLlmAbortController?.abort();
|
|
3157
|
+
this.interventionMessage = instruction;
|
|
3158
|
+
// 保存 checkpoint 到 DB
|
|
3159
|
+
this.savePauseCheckpoint();
|
|
3160
|
+
agentLogger.info(`Agent ${this.name} 已收到干预指令,等待确认`);
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* 带着干预指令恢复执行
|
|
3164
|
+
* 将 interventionMessage 注入到对话中
|
|
3165
|
+
*/
|
|
3166
|
+
resumeWithIntervention() {
|
|
3167
|
+
this.stalled = false;
|
|
3168
|
+
this.stopped = false;
|
|
3169
|
+
this.paused = false;
|
|
3170
|
+
if (this.interventionMessage) {
|
|
3171
|
+
// 将干预指令作为 system 消息注入
|
|
3172
|
+
this.messages.push({
|
|
3173
|
+
role: 'system',
|
|
3174
|
+
content: `[用户干预指令] 请按照以下指示调整你的执行方向:\n${this.interventionMessage}`,
|
|
3175
|
+
});
|
|
3176
|
+
agentLogger.info(`已将干预指令注入对话: ${this.interventionMessage.substring(0, 80)}...`);
|
|
3177
|
+
}
|
|
3178
|
+
this.interventionMessage = null;
|
|
3179
|
+
// 不在此创建 AbortController — 主循环在每次 LLM 调用前自行创建
|
|
3180
|
+
}
|
|
3181
|
+
/**
|
|
3182
|
+
* 保存暂停时的 checkpoint 到 DB
|
|
3183
|
+
*/
|
|
3184
|
+
savePauseCheckpoint() {
|
|
3185
|
+
if (this.db && this.currentTaskId) {
|
|
3186
|
+
const checkpoint = {
|
|
3187
|
+
agentId: this.agentId,
|
|
3188
|
+
agentName: this.name,
|
|
3189
|
+
agentRole: this.role,
|
|
3190
|
+
taskId: this.currentTaskId,
|
|
3191
|
+
iteration: this.iteration,
|
|
3192
|
+
toolCallCount: this.toolCallCount,
|
|
3193
|
+
timestamp: Date.now() / 1000,
|
|
3194
|
+
paused: this.paused,
|
|
3195
|
+
stalled: this.stalled,
|
|
3196
|
+
interventionMessage: this.interventionMessage,
|
|
3197
|
+
};
|
|
3198
|
+
try {
|
|
3199
|
+
saveAgentResumeCheckpoint(this.db, this.sessionId, checkpoint);
|
|
3200
|
+
}
|
|
3201
|
+
catch (err) {
|
|
3202
|
+
agentLogger.warn(`保存暂停 checkpoint 失败: ${err}`);
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
/**
|
|
3207
|
+
* 获取工具调用次数
|
|
3208
|
+
*/
|
|
3209
|
+
getToolCallCount() {
|
|
3210
|
+
return this.toolCallCount;
|
|
3211
|
+
}
|
|
3212
|
+
/**
|
|
3213
|
+
* 获取当前迭代次数
|
|
3214
|
+
*/
|
|
3215
|
+
getIterationCount() {
|
|
3216
|
+
return this.iteration;
|
|
3217
|
+
}
|
|
3218
|
+
/**
|
|
3219
|
+
* 框架自动采集的工具产物轨迹(已去重、created/modified 互斥)。
|
|
3220
|
+
* WorkerProcessEntry 在 complete payload 里透传给 Leader。
|
|
3221
|
+
*/
|
|
3222
|
+
getToolTrace() {
|
|
3223
|
+
return this.buildToolTraceSnapshot();
|
|
3224
|
+
}
|
|
3225
|
+
/**
|
|
3226
|
+
* worker 通过 attempt_completion 声明的结构化收尾结果;未调用则为 undefined。
|
|
3227
|
+
*/
|
|
3228
|
+
getAttemptCompletion() {
|
|
3229
|
+
return this.attemptCompletion;
|
|
3230
|
+
}
|
|
3231
|
+
async evaluateCompletionCandidate(final, task) {
|
|
3232
|
+
const toolTrace = this.buildToolTraceSnapshot();
|
|
3233
|
+
const verification = await runCompletionVerification({
|
|
3234
|
+
workingDir: this.workspace,
|
|
3235
|
+
artifacts: this.attemptCompletion?.artifacts,
|
|
3236
|
+
toolTrace,
|
|
3237
|
+
});
|
|
3238
|
+
// 自动合成契约遵守证明:当 worker 有真实工作产物(toolTrace 有文件/命令)
|
|
3239
|
+
// 但未调用 attempt_completion 或未填 contract_compliance 时,
|
|
3240
|
+
// 框架用 toolTrace 证据自动合成基本证明,避免 worker 因格式认知不足反复失败。
|
|
3241
|
+
const hasRealArtifacts = toolTrace.files_created.length > 0 ||
|
|
3242
|
+
toolTrace.files_modified.length > 0 ||
|
|
3243
|
+
toolTrace.commands_run.length > 0;
|
|
3244
|
+
let contractCompliance = this.attemptCompletion?.contract_compliance;
|
|
3245
|
+
if (!contractCompliance && hasRealArtifacts) {
|
|
3246
|
+
const binding = task.orchestration?.contractBinding;
|
|
3247
|
+
const surface = typeof binding?.surface === 'string' && binding.surface.trim() ? binding.surface.trim() : `task:${task.id}`;
|
|
3248
|
+
const evidence = [];
|
|
3249
|
+
if (toolTrace.files_created.length > 0) {
|
|
3250
|
+
evidence.push(`files_created: ${toolTrace.files_created.join(', ')}`);
|
|
3251
|
+
}
|
|
3252
|
+
if (toolTrace.files_modified.length > 0) {
|
|
3253
|
+
evidence.push(`files_modified: ${toolTrace.files_modified.join(', ')}`);
|
|
3254
|
+
}
|
|
3255
|
+
if (toolTrace.commands_run.length > 0) {
|
|
3256
|
+
evidence.push(`commands_run: ${toolTrace.commands_run.slice(0, 5).join('; ')}`);
|
|
3257
|
+
}
|
|
3258
|
+
contractCompliance = {
|
|
3259
|
+
surface,
|
|
3260
|
+
status: 'complied',
|
|
3261
|
+
evidence: evidence.length > 0 ? evidence : ['task completed with tool activity'],
|
|
3262
|
+
deviations: ['无(框架自动合成,worker 未显式声明契约遵守证明)'],
|
|
3263
|
+
};
|
|
3264
|
+
agentLogger.info(`[${this.name}] worker 未提供 contract_compliance,框架用 toolTrace 自动合成 (surface=${surface}, evidence=${evidence.length} items)`);
|
|
3265
|
+
}
|
|
3266
|
+
return evaluateWorkerCompletionCandidate({
|
|
3267
|
+
final,
|
|
3268
|
+
task,
|
|
3269
|
+
role: this.role,
|
|
3270
|
+
messages: this.messages,
|
|
3271
|
+
contractCompliance,
|
|
3272
|
+
verification,
|
|
3273
|
+
hasContractAllowedScope: Boolean(this.currentContractAllowedScope),
|
|
3274
|
+
llm: this.llm,
|
|
3275
|
+
model: this.model,
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
export default BaseAgent;
|
|
3280
|
+
//# sourceMappingURL=BaseAgentRuntime.js.map
|