@thoughtflow/core 0.1.2
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/LICENSE +21 -0
- package/README.md +247 -0
- package/dist/adapters/llm/adapter-factory.d.ts +43 -0
- package/dist/adapters/llm/adapter-factory.d.ts.map +1 -0
- package/dist/adapters/llm/adapter-factory.js +52 -0
- package/dist/adapters/llm/adapter-factory.js.map +1 -0
- package/dist/adapters/llm/anthropic.adapter.d.ts +28 -0
- package/dist/adapters/llm/anthropic.adapter.d.ts.map +1 -0
- package/dist/adapters/llm/anthropic.adapter.js +295 -0
- package/dist/adapters/llm/anthropic.adapter.js.map +1 -0
- package/dist/adapters/llm/llm-adapter.interface.d.ts +2 -0
- package/dist/adapters/llm/llm-adapter.interface.d.ts.map +1 -0
- package/dist/adapters/llm/llm-adapter.interface.js +3 -0
- package/dist/adapters/llm/llm-adapter.interface.js.map +1 -0
- package/dist/adapters/llm/mock.adapter.d.ts +60 -0
- package/dist/adapters/llm/mock.adapter.d.ts.map +1 -0
- package/dist/adapters/llm/mock.adapter.js +113 -0
- package/dist/adapters/llm/mock.adapter.js.map +1 -0
- package/dist/adapters/llm/model-profiles.d.ts +42 -0
- package/dist/adapters/llm/model-profiles.d.ts.map +1 -0
- package/dist/adapters/llm/model-profiles.js +120 -0
- package/dist/adapters/llm/model-profiles.js.map +1 -0
- package/dist/adapters/llm/ollama.adapter.d.ts +21 -0
- package/dist/adapters/llm/ollama.adapter.d.ts.map +1 -0
- package/dist/adapters/llm/ollama.adapter.js +375 -0
- package/dist/adapters/llm/ollama.adapter.js.map +1 -0
- package/dist/adapters/llm/openai.adapter.d.ts +35 -0
- package/dist/adapters/llm/openai.adapter.d.ts.map +1 -0
- package/dist/adapters/llm/openai.adapter.js +586 -0
- package/dist/adapters/llm/openai.adapter.js.map +1 -0
- package/dist/contexts/context-decomposer.d.ts +15 -0
- package/dist/contexts/context-decomposer.d.ts.map +1 -0
- package/dist/contexts/context-decomposer.js +97 -0
- package/dist/contexts/context-decomposer.js.map +1 -0
- package/dist/contexts/context-document-manager.d.ts +21 -0
- package/dist/contexts/context-document-manager.d.ts.map +1 -0
- package/dist/contexts/context-document-manager.js +69 -0
- package/dist/contexts/context-document-manager.js.map +1 -0
- package/dist/contexts/context-router.d.ts +14 -0
- package/dist/contexts/context-router.d.ts.map +1 -0
- package/dist/contexts/context-router.js +94 -0
- package/dist/contexts/context-router.js.map +1 -0
- package/dist/contracts/codebase-analysis.types.d.ts +204 -0
- package/dist/contracts/codebase-analysis.types.d.ts.map +1 -0
- package/dist/contracts/codebase-analysis.types.js +19 -0
- package/dist/contracts/codebase-analysis.types.js.map +1 -0
- package/dist/contracts/context-document.types.d.ts +82 -0
- package/dist/contracts/context-document.types.d.ts.map +1 -0
- package/dist/contracts/context-document.types.js +3 -0
- package/dist/contracts/context-document.types.js.map +1 -0
- package/dist/contracts/conversation-status.enum.d.ts +11 -0
- package/dist/contracts/conversation-status.enum.d.ts.map +1 -0
- package/dist/contracts/conversation-status.enum.js +19 -0
- package/dist/contracts/conversation-status.enum.js.map +1 -0
- package/dist/contracts/conversation.types.d.ts +245 -0
- package/dist/contracts/conversation.types.d.ts.map +1 -0
- package/dist/contracts/conversation.types.js +3 -0
- package/dist/contracts/conversation.types.js.map +1 -0
- package/dist/contracts/doc-graph.types.d.ts +220 -0
- package/dist/contracts/doc-graph.types.d.ts.map +1 -0
- package/dist/contracts/doc-graph.types.js +15 -0
- package/dist/contracts/doc-graph.types.js.map +1 -0
- package/dist/contracts/events.types.d.ts +47 -0
- package/dist/contracts/events.types.d.ts.map +1 -0
- package/dist/contracts/events.types.js +3 -0
- package/dist/contracts/events.types.js.map +1 -0
- package/dist/contracts/execution-runner.types.d.ts +13 -0
- package/dist/contracts/execution-runner.types.d.ts.map +1 -0
- package/dist/contracts/execution-runner.types.js +3 -0
- package/dist/contracts/execution-runner.types.js.map +1 -0
- package/dist/contracts/index.d.ts +25 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +41 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/interrupt.types.d.ts +62 -0
- package/dist/contracts/interrupt.types.d.ts.map +1 -0
- package/dist/contracts/interrupt.types.js +5 -0
- package/dist/contracts/interrupt.types.js.map +1 -0
- package/dist/contracts/knowledge-graph.types.d.ts +112 -0
- package/dist/contracts/knowledge-graph.types.d.ts.map +1 -0
- package/dist/contracts/knowledge-graph.types.js +13 -0
- package/dist/contracts/knowledge-graph.types.js.map +1 -0
- package/dist/contracts/llm.types.d.ts +137 -0
- package/dist/contracts/llm.types.d.ts.map +1 -0
- package/dist/contracts/llm.types.js +3 -0
- package/dist/contracts/llm.types.js.map +1 -0
- package/dist/contracts/mcp.types.d.ts +330 -0
- package/dist/contracts/mcp.types.d.ts.map +1 -0
- package/dist/contracts/mcp.types.js +10 -0
- package/dist/contracts/mcp.types.js.map +1 -0
- package/dist/contracts/memory.types.d.ts +33 -0
- package/dist/contracts/memory.types.d.ts.map +1 -0
- package/dist/contracts/memory.types.js +3 -0
- package/dist/contracts/memory.types.js.map +1 -0
- package/dist/contracts/message.types.d.ts +40 -0
- package/dist/contracts/message.types.d.ts.map +1 -0
- package/dist/contracts/message.types.js +3 -0
- package/dist/contracts/message.types.js.map +1 -0
- package/dist/contracts/plugin.types.d.ts +31 -0
- package/dist/contracts/plugin.types.d.ts.map +1 -0
- package/dist/contracts/plugin.types.js +3 -0
- package/dist/contracts/plugin.types.js.map +1 -0
- package/dist/contracts/problem-tree.types.d.ts +158 -0
- package/dist/contracts/problem-tree.types.d.ts.map +1 -0
- package/dist/contracts/problem-tree.types.js +3 -0
- package/dist/contracts/problem-tree.types.js.map +1 -0
- package/dist/contracts/prompt.types.d.ts +41 -0
- package/dist/contracts/prompt.types.d.ts.map +1 -0
- package/dist/contracts/prompt.types.js +3 -0
- package/dist/contracts/prompt.types.js.map +1 -0
- package/dist/contracts/skill.types.d.ts +39 -0
- package/dist/contracts/skill.types.d.ts.map +1 -0
- package/dist/contracts/skill.types.js +3 -0
- package/dist/contracts/skill.types.js.map +1 -0
- package/dist/contracts/storage.types.d.ts +154 -0
- package/dist/contracts/storage.types.d.ts.map +1 -0
- package/dist/contracts/storage.types.js +11 -0
- package/dist/contracts/storage.types.js.map +1 -0
- package/dist/contracts/structural-decoder.types.d.ts +251 -0
- package/dist/contracts/structural-decoder.types.d.ts.map +1 -0
- package/dist/contracts/structural-decoder.types.js +14 -0
- package/dist/contracts/structural-decoder.types.js.map +1 -0
- package/dist/contracts/subagent.types.d.ts +311 -0
- package/dist/contracts/subagent.types.d.ts.map +1 -0
- package/dist/contracts/subagent.types.js +3 -0
- package/dist/contracts/subagent.types.js.map +1 -0
- package/dist/contracts/task-board.types.d.ts +178 -0
- package/dist/contracts/task-board.types.d.ts.map +1 -0
- package/dist/contracts/task-board.types.js +67 -0
- package/dist/contracts/task-board.types.js.map +1 -0
- package/dist/contracts/task-flow.types.d.ts +127 -0
- package/dist/contracts/task-flow.types.d.ts.map +1 -0
- package/dist/contracts/task-flow.types.js +32 -0
- package/dist/contracts/task-flow.types.js.map +1 -0
- package/dist/contracts/tool-capability.types.d.ts +34 -0
- package/dist/contracts/tool-capability.types.d.ts.map +1 -0
- package/dist/contracts/tool-capability.types.js +3 -0
- package/dist/contracts/tool-capability.types.js.map +1 -0
- package/dist/contracts/tool.types.d.ts +132 -0
- package/dist/contracts/tool.types.d.ts.map +1 -0
- package/dist/contracts/tool.types.js +3 -0
- package/dist/contracts/tool.types.js.map +1 -0
- package/dist/contracts/vector-store.types.d.ts +79 -0
- package/dist/contracts/vector-store.types.d.ts.map +1 -0
- package/dist/contracts/vector-store.types.js +3 -0
- package/dist/contracts/vector-store.types.js.map +1 -0
- package/dist/conversation.class.d.ts +154 -0
- package/dist/conversation.class.d.ts.map +1 -0
- package/dist/conversation.class.js +1221 -0
- package/dist/conversation.class.js.map +1 -0
- package/dist/events/conversation-events.bus.d.ts +28 -0
- package/dist/events/conversation-events.bus.d.ts.map +1 -0
- package/dist/events/conversation-events.bus.js +127 -0
- package/dist/events/conversation-events.bus.js.map +1 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -0
- package/dist/libs/abort-controller.class.d.ts +7 -0
- package/dist/libs/abort-controller.class.d.ts.map +1 -0
- package/dist/libs/abort-controller.class.js +20 -0
- package/dist/libs/abort-controller.class.js.map +1 -0
- package/dist/libs/ac-verifier.d.ts +10 -0
- package/dist/libs/ac-verifier.d.ts.map +1 -0
- package/dist/libs/ac-verifier.js +52 -0
- package/dist/libs/ac-verifier.js.map +1 -0
- package/dist/libs/advanced-hitl-interrupts.d.ts +223 -0
- package/dist/libs/advanced-hitl-interrupts.d.ts.map +1 -0
- package/dist/libs/advanced-hitl-interrupts.js +412 -0
- package/dist/libs/advanced-hitl-interrupts.js.map +1 -0
- package/dist/libs/advanced-scheduling.d.ts +71 -0
- package/dist/libs/advanced-scheduling.d.ts.map +1 -0
- package/dist/libs/advanced-scheduling.js +208 -0
- package/dist/libs/advanced-scheduling.js.map +1 -0
- package/dist/libs/analysis-completion-gate.class.d.ts +67 -0
- package/dist/libs/analysis-completion-gate.class.d.ts.map +1 -0
- package/dist/libs/analysis-completion-gate.class.js +305 -0
- package/dist/libs/analysis-completion-gate.class.js.map +1 -0
- package/dist/libs/analysis-pipeline.class.d.ts +104 -0
- package/dist/libs/analysis-pipeline.class.d.ts.map +1 -0
- package/dist/libs/analysis-pipeline.class.js +250 -0
- package/dist/libs/analysis-pipeline.class.js.map +1 -0
- package/dist/libs/approval-workflows.d.ts +223 -0
- package/dist/libs/approval-workflows.d.ts.map +1 -0
- package/dist/libs/approval-workflows.js +459 -0
- package/dist/libs/approval-workflows.js.map +1 -0
- package/dist/libs/audit-logger.d.ts +194 -0
- package/dist/libs/audit-logger.d.ts.map +1 -0
- package/dist/libs/audit-logger.js +320 -0
- package/dist/libs/audit-logger.js.map +1 -0
- package/dist/libs/autonomous-orchestrator.class.d.ts +159 -0
- package/dist/libs/autonomous-orchestrator.class.d.ts.map +1 -0
- package/dist/libs/autonomous-orchestrator.class.js +343 -0
- package/dist/libs/autonomous-orchestrator.class.js.map +1 -0
- package/dist/libs/checkpoint-manager.d.ts +217 -0
- package/dist/libs/checkpoint-manager.d.ts.map +1 -0
- package/dist/libs/checkpoint-manager.js +320 -0
- package/dist/libs/checkpoint-manager.js.map +1 -0
- package/dist/libs/checkpointer-backends.d.ts +97 -0
- package/dist/libs/checkpointer-backends.d.ts.map +1 -0
- package/dist/libs/checkpointer-backends.js +536 -0
- package/dist/libs/checkpointer-backends.js.map +1 -0
- package/dist/libs/code-analysis-pipeline.class.d.ts +149 -0
- package/dist/libs/code-analysis-pipeline.class.d.ts.map +1 -0
- package/dist/libs/code-analysis-pipeline.class.js +946 -0
- package/dist/libs/code-analysis-pipeline.class.js.map +1 -0
- package/dist/libs/codebase/deep-analyzer.d.ts +58 -0
- package/dist/libs/codebase/deep-analyzer.d.ts.map +1 -0
- package/dist/libs/codebase/deep-analyzer.js +239 -0
- package/dist/libs/codebase/deep-analyzer.js.map +1 -0
- package/dist/libs/codebase/graph/dependency-extractor.d.ts +20 -0
- package/dist/libs/codebase/graph/dependency-extractor.d.ts.map +1 -0
- package/dist/libs/codebase/graph/dependency-extractor.js +171 -0
- package/dist/libs/codebase/graph/dependency-extractor.js.map +1 -0
- package/dist/libs/codebase/graph/graph-analysis.d.ts +42 -0
- package/dist/libs/codebase/graph/graph-analysis.d.ts.map +1 -0
- package/dist/libs/codebase/graph/graph-analysis.js +222 -0
- package/dist/libs/codebase/graph/graph-analysis.js.map +1 -0
- package/dist/libs/codebase/graph/graph-visualizer.d.ts +12 -0
- package/dist/libs/codebase/graph/graph-visualizer.d.ts.map +1 -0
- package/dist/libs/codebase/graph/graph-visualizer.js +99 -0
- package/dist/libs/codebase/graph/graph-visualizer.js.map +1 -0
- package/dist/libs/codebase/indexer/batch-processor.d.ts +18 -0
- package/dist/libs/codebase/indexer/batch-processor.d.ts.map +1 -0
- package/dist/libs/codebase/indexer/batch-processor.js +39 -0
- package/dist/libs/codebase/indexer/batch-processor.js.map +1 -0
- package/dist/libs/codebase/indexer/chunker-markdown.d.ts +19 -0
- package/dist/libs/codebase/indexer/chunker-markdown.d.ts.map +1 -0
- package/dist/libs/codebase/indexer/chunker-markdown.js +138 -0
- package/dist/libs/codebase/indexer/chunker-markdown.js.map +1 -0
- package/dist/libs/codebase/indexer/chunker.d.ts +21 -0
- package/dist/libs/codebase/indexer/chunker.d.ts.map +1 -0
- package/dist/libs/codebase/indexer/chunker.js +97 -0
- package/dist/libs/codebase/indexer/chunker.js.map +1 -0
- package/dist/libs/codebase/indexer/explorer.d.ts +29 -0
- package/dist/libs/codebase/indexer/explorer.d.ts.map +1 -0
- package/dist/libs/codebase/indexer/explorer.js +278 -0
- package/dist/libs/codebase/indexer/explorer.js.map +1 -0
- package/dist/libs/codebase/indexer/indexer.d.ts +35 -0
- package/dist/libs/codebase/indexer/indexer.d.ts.map +1 -0
- package/dist/libs/codebase/indexer/indexer.js +172 -0
- package/dist/libs/codebase/indexer/indexer.js.map +1 -0
- package/dist/libs/codebase/knowledge/cross-referencer.d.ts +32 -0
- package/dist/libs/codebase/knowledge/cross-referencer.d.ts.map +1 -0
- package/dist/libs/codebase/knowledge/cross-referencer.js +132 -0
- package/dist/libs/codebase/knowledge/cross-referencer.js.map +1 -0
- package/dist/libs/codebase/knowledge/markdown-extractor.d.ts +34 -0
- package/dist/libs/codebase/knowledge/markdown-extractor.d.ts.map +1 -0
- package/dist/libs/codebase/knowledge/markdown-extractor.js +273 -0
- package/dist/libs/codebase/knowledge/markdown-extractor.js.map +1 -0
- package/dist/libs/codebase/knowledge/summarizer.d.ts +25 -0
- package/dist/libs/codebase/knowledge/summarizer.d.ts.map +1 -0
- package/dist/libs/codebase/knowledge/summarizer.js +61 -0
- package/dist/libs/codebase/knowledge/summarizer.js.map +1 -0
- package/dist/libs/codebase/search/bm25.d.ts +23 -0
- package/dist/libs/codebase/search/bm25.d.ts.map +1 -0
- package/dist/libs/codebase/search/bm25.js +93 -0
- package/dist/libs/codebase/search/bm25.js.map +1 -0
- package/dist/libs/codebase/search/hybrid-search.d.ts +22 -0
- package/dist/libs/codebase/search/hybrid-search.d.ts.map +1 -0
- package/dist/libs/codebase/search/hybrid-search.js +80 -0
- package/dist/libs/codebase/search/hybrid-search.js.map +1 -0
- package/dist/libs/codebase-index.class.d.ts +66 -0
- package/dist/libs/codebase-index.class.d.ts.map +1 -0
- package/dist/libs/codebase-index.class.js +598 -0
- package/dist/libs/codebase-index.class.js.map +1 -0
- package/dist/libs/command-manager.d.ts +148 -0
- package/dist/libs/command-manager.d.ts.map +1 -0
- package/dist/libs/command-manager.js +306 -0
- package/dist/libs/command-manager.js.map +1 -0
- package/dist/libs/compiled-subagent.manager.d.ts +102 -0
- package/dist/libs/compiled-subagent.manager.d.ts.map +1 -0
- package/dist/libs/compiled-subagent.manager.js +224 -0
- package/dist/libs/compiled-subagent.manager.js.map +1 -0
- package/dist/libs/conditional-flow.d.ts +156 -0
- package/dist/libs/conditional-flow.d.ts.map +1 -0
- package/dist/libs/conditional-flow.js +295 -0
- package/dist/libs/conditional-flow.js.map +1 -0
- package/dist/libs/context-propagator.d.ts +184 -0
- package/dist/libs/context-propagator.d.ts.map +1 -0
- package/dist/libs/context-propagator.js +295 -0
- package/dist/libs/context-propagator.js.map +1 -0
- package/dist/libs/context-window.class.d.ts +86 -0
- package/dist/libs/context-window.class.d.ts.map +1 -0
- package/dist/libs/context-window.class.js +187 -0
- package/dist/libs/context-window.class.js.map +1 -0
- package/dist/libs/conversation-runner.class.d.ts +172 -0
- package/dist/libs/conversation-runner.class.d.ts.map +1 -0
- package/dist/libs/conversation-runner.class.js +1619 -0
- package/dist/libs/conversation-runner.class.js.map +1 -0
- package/dist/libs/cost-estimation.d.ts +104 -0
- package/dist/libs/cost-estimation.d.ts.map +1 -0
- package/dist/libs/cost-estimation.js +287 -0
- package/dist/libs/cost-estimation.js.map +1 -0
- package/dist/libs/debug-logger.class.d.ts +9 -0
- package/dist/libs/debug-logger.class.d.ts.map +1 -0
- package/dist/libs/debug-logger.class.js +28 -0
- package/dist/libs/debug-logger.class.js.map +1 -0
- package/dist/libs/decoder-registry.class.d.ts +43 -0
- package/dist/libs/decoder-registry.class.d.ts.map +1 -0
- package/dist/libs/decoder-registry.class.js +138 -0
- package/dist/libs/decoder-registry.class.js.map +1 -0
- package/dist/libs/distributed-execution.d.ts +122 -0
- package/dist/libs/distributed-execution.d.ts.map +1 -0
- package/dist/libs/distributed-execution.js +360 -0
- package/dist/libs/distributed-execution.js.map +1 -0
- package/dist/libs/divergence-detector.class.d.ts +45 -0
- package/dist/libs/divergence-detector.class.d.ts.map +1 -0
- package/dist/libs/divergence-detector.class.js +227 -0
- package/dist/libs/divergence-detector.class.js.map +1 -0
- package/dist/libs/doc-graph-builder.class.d.ts +90 -0
- package/dist/libs/doc-graph-builder.class.d.ts.map +1 -0
- package/dist/libs/doc-graph-builder.class.js +531 -0
- package/dist/libs/doc-graph-builder.class.js.map +1 -0
- package/dist/libs/durability-mode.d.ts +187 -0
- package/dist/libs/durability-mode.d.ts.map +1 -0
- package/dist/libs/durability-mode.js +385 -0
- package/dist/libs/durability-mode.js.map +1 -0
- package/dist/libs/durable-execution.d.ts +196 -0
- package/dist/libs/durable-execution.d.ts.map +1 -0
- package/dist/libs/durable-execution.js +397 -0
- package/dist/libs/durable-execution.js.map +1 -0
- package/dist/libs/dynamic-fanout.d.ts +175 -0
- package/dist/libs/dynamic-fanout.d.ts.map +1 -0
- package/dist/libs/dynamic-fanout.js +329 -0
- package/dist/libs/dynamic-fanout.js.map +1 -0
- package/dist/libs/execution-caching.d.ts +185 -0
- package/dist/libs/execution-caching.d.ts.map +1 -0
- package/dist/libs/execution-caching.js +401 -0
- package/dist/libs/execution-caching.js.map +1 -0
- package/dist/libs/fallback-decoder.class.d.ts +30 -0
- package/dist/libs/fallback-decoder.class.d.ts.map +1 -0
- package/dist/libs/fallback-decoder.class.js +302 -0
- package/dist/libs/fallback-decoder.class.js.map +1 -0
- package/dist/libs/general-purpose-subagent.d.ts +160 -0
- package/dist/libs/general-purpose-subagent.d.ts.map +1 -0
- package/dist/libs/general-purpose-subagent.js +289 -0
- package/dist/libs/general-purpose-subagent.js.map +1 -0
- package/dist/libs/graphql-federation.d.ts +84 -0
- package/dist/libs/graphql-federation.d.ts.map +1 -0
- package/dist/libs/graphql-federation.js +235 -0
- package/dist/libs/graphql-federation.js.map +1 -0
- package/dist/libs/in-memory-job-store.d.ts +14 -0
- package/dist/libs/in-memory-job-store.d.ts.map +1 -0
- package/dist/libs/in-memory-job-store.js +35 -0
- package/dist/libs/in-memory-job-store.js.map +1 -0
- package/dist/libs/incremental-analyzer.class.d.ts +151 -0
- package/dist/libs/incremental-analyzer.class.d.ts.map +1 -0
- package/dist/libs/incremental-analyzer.class.js +798 -0
- package/dist/libs/incremental-analyzer.class.js.map +1 -0
- package/dist/libs/interrupt-manager.d.ts +178 -0
- package/dist/libs/interrupt-manager.d.ts.map +1 -0
- package/dist/libs/interrupt-manager.js +246 -0
- package/dist/libs/interrupt-manager.js.map +1 -0
- package/dist/libs/knowledge-graph.class.d.ts +90 -0
- package/dist/libs/knowledge-graph.class.d.ts.map +1 -0
- package/dist/libs/knowledge-graph.class.js +406 -0
- package/dist/libs/knowledge-graph.class.js.map +1 -0
- package/dist/libs/llm-retry.d.ts +47 -0
- package/dist/libs/llm-retry.d.ts.map +1 -0
- package/dist/libs/llm-retry.js +148 -0
- package/dist/libs/llm-retry.js.map +1 -0
- package/dist/libs/local-execution.runner.d.ts +5 -0
- package/dist/libs/local-execution.runner.d.ts.map +1 -0
- package/dist/libs/local-execution.runner.js +26 -0
- package/dist/libs/local-execution.runner.js.map +1 -0
- package/dist/libs/mcp/jsonrpc.class.d.ts +24 -0
- package/dist/libs/mcp/jsonrpc.class.d.ts.map +1 -0
- package/dist/libs/mcp/jsonrpc.class.js +42 -0
- package/dist/libs/mcp/jsonrpc.class.js.map +1 -0
- package/dist/libs/mcp/mcp-server.class.d.ts +69 -0
- package/dist/libs/mcp/mcp-server.class.d.ts.map +1 -0
- package/dist/libs/mcp/mcp-server.class.js +541 -0
- package/dist/libs/mcp/mcp-server.class.js.map +1 -0
- package/dist/libs/mcp/mcp-tool-registry.class.d.ts +28 -0
- package/dist/libs/mcp/mcp-tool-registry.class.d.ts.map +1 -0
- package/dist/libs/mcp/mcp-tool-registry.class.js +229 -0
- package/dist/libs/mcp/mcp-tool-registry.class.js.map +1 -0
- package/dist/libs/memory-file.loader.d.ts +54 -0
- package/dist/libs/memory-file.loader.d.ts.map +1 -0
- package/dist/libs/memory-file.loader.js +171 -0
- package/dist/libs/memory-file.loader.js.map +1 -0
- package/dist/libs/message-history.class.d.ts +21 -0
- package/dist/libs/message-history.class.d.ts.map +1 -0
- package/dist/libs/message-history.class.js +98 -0
- package/dist/libs/message-history.class.js.map +1 -0
- package/dist/libs/message-utils.d.ts +6 -0
- package/dist/libs/message-utils.d.ts.map +1 -0
- package/dist/libs/message-utils.js +37 -0
- package/dist/libs/message-utils.js.map +1 -0
- package/dist/libs/model-ref-resolver.d.ts +25 -0
- package/dist/libs/model-ref-resolver.d.ts.map +1 -0
- package/dist/libs/model-ref-resolver.js +58 -0
- package/dist/libs/model-ref-resolver.js.map +1 -0
- package/dist/libs/multi-tenant.d.ts +69 -0
- package/dist/libs/multi-tenant.d.ts.map +1 -0
- package/dist/libs/multi-tenant.js +196 -0
- package/dist/libs/multi-tenant.js.map +1 -0
- package/dist/libs/observability.d.ts +105 -0
- package/dist/libs/observability.d.ts.map +1 -0
- package/dist/libs/observability.js +278 -0
- package/dist/libs/observability.js.map +1 -0
- package/dist/libs/payload-offload.manager.d.ts +57 -0
- package/dist/libs/payload-offload.manager.d.ts.map +1 -0
- package/dist/libs/payload-offload.manager.js +195 -0
- package/dist/libs/payload-offload.manager.js.map +1 -0
- package/dist/libs/performance-optimization.d.ts +53 -0
- package/dist/libs/performance-optimization.d.ts.map +1 -0
- package/dist/libs/performance-optimization.js +221 -0
- package/dist/libs/performance-optimization.js.map +1 -0
- package/dist/libs/pipeline-run-registry.class.d.ts +56 -0
- package/dist/libs/pipeline-run-registry.class.d.ts.map +1 -0
- package/dist/libs/pipeline-run-registry.class.js +217 -0
- package/dist/libs/pipeline-run-registry.class.js.map +1 -0
- package/dist/libs/problem-tree.class.d.ts +51 -0
- package/dist/libs/problem-tree.class.d.ts.map +1 -0
- package/dist/libs/problem-tree.class.js +305 -0
- package/dist/libs/problem-tree.class.js.map +1 -0
- package/dist/libs/production-deployment.d.ts +99 -0
- package/dist/libs/production-deployment.d.ts.map +1 -0
- package/dist/libs/production-deployment.js +249 -0
- package/dist/libs/production-deployment.js.map +1 -0
- package/dist/libs/prompt-builder.class.d.ts +14 -0
- package/dist/libs/prompt-builder.class.d.ts.map +1 -0
- package/dist/libs/prompt-builder.class.js +79 -0
- package/dist/libs/prompt-builder.class.js.map +1 -0
- package/dist/libs/prompt-loader.class.d.ts +6 -0
- package/dist/libs/prompt-loader.class.d.ts.map +1 -0
- package/dist/libs/prompt-loader.class.js +17 -0
- package/dist/libs/prompt-loader.class.js.map +1 -0
- package/dist/libs/resource-decoder.class.d.ts +22 -0
- package/dist/libs/resource-decoder.class.d.ts.map +1 -0
- package/dist/libs/resource-decoder.class.js +713 -0
- package/dist/libs/resource-decoder.class.js.map +1 -0
- package/dist/libs/router-node.class.d.ts +83 -0
- package/dist/libs/router-node.class.d.ts.map +1 -0
- package/dist/libs/router-node.class.js +208 -0
- package/dist/libs/router-node.class.js.map +1 -0
- package/dist/libs/runtime-policy-llm.adapter.d.ts +23 -0
- package/dist/libs/runtime-policy-llm.adapter.d.ts.map +1 -0
- package/dist/libs/runtime-policy-llm.adapter.js +189 -0
- package/dist/libs/runtime-policy-llm.adapter.js.map +1 -0
- package/dist/libs/saga-orchestrator.d.ts +208 -0
- package/dist/libs/saga-orchestrator.d.ts.map +1 -0
- package/dist/libs/saga-orchestrator.js +410 -0
- package/dist/libs/saga-orchestrator.js.map +1 -0
- package/dist/libs/sandbox-execution.d.ts +187 -0
- package/dist/libs/sandbox-execution.d.ts.map +1 -0
- package/dist/libs/sandbox-execution.js +354 -0
- package/dist/libs/sandbox-execution.js.map +1 -0
- package/dist/libs/security-hardening.d.ts +73 -0
- package/dist/libs/security-hardening.d.ts.map +1 -0
- package/dist/libs/security-hardening.js +243 -0
- package/dist/libs/security-hardening.js.map +1 -0
- package/dist/libs/server-concurrency-pool.d.ts +52 -0
- package/dist/libs/server-concurrency-pool.d.ts.map +1 -0
- package/dist/libs/server-concurrency-pool.js +108 -0
- package/dist/libs/server-concurrency-pool.js.map +1 -0
- package/dist/libs/service-mesh.d.ts +101 -0
- package/dist/libs/service-mesh.d.ts.map +1 -0
- package/dist/libs/service-mesh.js +261 -0
- package/dist/libs/service-mesh.js.map +1 -0
- package/dist/libs/skill-loader.class.d.ts +77 -0
- package/dist/libs/skill-loader.class.d.ts.map +1 -0
- package/dist/libs/skill-loader.class.js +292 -0
- package/dist/libs/skill-loader.class.js.map +1 -0
- package/dist/libs/smart-tool-prompt.class.d.ts +11 -0
- package/dist/libs/smart-tool-prompt.class.d.ts.map +1 -0
- package/dist/libs/smart-tool-prompt.class.js +56 -0
- package/dist/libs/smart-tool-prompt.class.js.map +1 -0
- package/dist/libs/status-machine.class.d.ts +8 -0
- package/dist/libs/status-machine.class.d.ts.map +1 -0
- package/dist/libs/status-machine.class.js +55 -0
- package/dist/libs/status-machine.class.js.map +1 -0
- package/dist/libs/stream-emitter.class.d.ts +9 -0
- package/dist/libs/stream-emitter.class.d.ts.map +1 -0
- package/dist/libs/stream-emitter.class.js +58 -0
- package/dist/libs/stream-emitter.class.js.map +1 -0
- package/dist/libs/streaming-iterator.d.ts +136 -0
- package/dist/libs/streaming-iterator.d.ts.map +1 -0
- package/dist/libs/streaming-iterator.js +248 -0
- package/dist/libs/streaming-iterator.js.map +1 -0
- package/dist/libs/structured-call.d.ts +40 -0
- package/dist/libs/structured-call.d.ts.map +1 -0
- package/dist/libs/structured-call.js +306 -0
- package/dist/libs/structured-call.js.map +1 -0
- package/dist/libs/subagent-executor.class.d.ts +127 -0
- package/dist/libs/subagent-executor.class.d.ts.map +1 -0
- package/dist/libs/subagent-executor.class.js +202 -0
- package/dist/libs/subagent-executor.class.js.map +1 -0
- package/dist/libs/subagent-job-manager.d.ts +27 -0
- package/dist/libs/subagent-job-manager.d.ts.map +1 -0
- package/dist/libs/subagent-job-manager.js +254 -0
- package/dist/libs/subagent-job-manager.js.map +1 -0
- package/dist/libs/subagent-registry.class.d.ts +90 -0
- package/dist/libs/subagent-registry.class.d.ts.map +1 -0
- package/dist/libs/subagent-registry.class.js +183 -0
- package/dist/libs/subagent-registry.class.js.map +1 -0
- package/dist/libs/subagent-router.class.d.ts +67 -0
- package/dist/libs/subagent-router.class.d.ts.map +1 -0
- package/dist/libs/subagent-router.class.js +200 -0
- package/dist/libs/subagent-router.class.js.map +1 -0
- package/dist/libs/subgraph.d.ts +246 -0
- package/dist/libs/subgraph.d.ts.map +1 -0
- package/dist/libs/subgraph.js +438 -0
- package/dist/libs/subgraph.js.map +1 -0
- package/dist/libs/task-board.class.d.ts +53 -0
- package/dist/libs/task-board.class.d.ts.map +1 -0
- package/dist/libs/task-board.class.js +245 -0
- package/dist/libs/task-board.class.js.map +1 -0
- package/dist/libs/task-flow/auto-answer-engine.class.d.ts +22 -0
- package/dist/libs/task-flow/auto-answer-engine.class.d.ts.map +1 -0
- package/dist/libs/task-flow/auto-answer-engine.class.js +56 -0
- package/dist/libs/task-flow/auto-answer-engine.class.js.map +1 -0
- package/dist/libs/task-flow/controlled-coding-engine.class.d.ts +18 -0
- package/dist/libs/task-flow/controlled-coding-engine.class.d.ts.map +1 -0
- package/dist/libs/task-flow/controlled-coding-engine.class.js +156 -0
- package/dist/libs/task-flow/controlled-coding-engine.class.js.map +1 -0
- package/dist/libs/task-flow/dependency-analyzer.class.d.ts +16 -0
- package/dist/libs/task-flow/dependency-analyzer.class.d.ts.map +1 -0
- package/dist/libs/task-flow/dependency-analyzer.class.js +173 -0
- package/dist/libs/task-flow/dependency-analyzer.class.js.map +1 -0
- package/dist/libs/task-flow/git/git-commit-push.class.d.ts +59 -0
- package/dist/libs/task-flow/git/git-commit-push.class.d.ts.map +1 -0
- package/dist/libs/task-flow/git/git-commit-push.class.js +250 -0
- package/dist/libs/task-flow/git/git-commit-push.class.js.map +1 -0
- package/dist/libs/task-flow/git/git-worktree.class.d.ts +53 -0
- package/dist/libs/task-flow/git/git-worktree.class.d.ts.map +1 -0
- package/dist/libs/task-flow/git/git-worktree.class.js +199 -0
- package/dist/libs/task-flow/git/git-worktree.class.js.map +1 -0
- package/dist/libs/task-flow/git/git.types.d.ts +115 -0
- package/dist/libs/task-flow/git/git.types.d.ts.map +1 -0
- package/dist/libs/task-flow/git/git.types.js +4 -0
- package/dist/libs/task-flow/git/git.types.js.map +1 -0
- package/dist/libs/task-flow/git/index.d.ts +4 -0
- package/dist/libs/task-flow/git/index.d.ts.map +1 -0
- package/dist/libs/task-flow/git/index.js +23 -0
- package/dist/libs/task-flow/git/index.js.map +1 -0
- package/dist/libs/task-flow/index.d.ts +10 -0
- package/dist/libs/task-flow/index.d.ts.map +1 -0
- package/dist/libs/task-flow/index.js +26 -0
- package/dist/libs/task-flow/index.js.map +1 -0
- package/dist/libs/task-flow/phase-progress-store.class.d.ts +22 -0
- package/dist/libs/task-flow/phase-progress-store.class.d.ts.map +1 -0
- package/dist/libs/task-flow/phase-progress-store.class.js +174 -0
- package/dist/libs/task-flow/phase-progress-store.class.js.map +1 -0
- package/dist/libs/task-flow/pipeline/index.d.ts +5 -0
- package/dist/libs/task-flow/pipeline/index.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/index.js +24 -0
- package/dist/libs/task-flow/pipeline/index.js.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline-builder.class.d.ts +57 -0
- package/dist/libs/task-flow/pipeline/pipeline-builder.class.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline-builder.class.js +95 -0
- package/dist/libs/task-flow/pipeline/pipeline-builder.class.js.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline-runner.class.d.ts +45 -0
- package/dist/libs/task-flow/pipeline/pipeline-runner.class.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline-runner.class.js +256 -0
- package/dist/libs/task-flow/pipeline/pipeline-runner.class.js.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline.types.d.ts +113 -0
- package/dist/libs/task-flow/pipeline/pipeline.types.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/pipeline.types.js +13 -0
- package/dist/libs/task-flow/pipeline/pipeline.types.js.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/commit-push.stage.d.ts +39 -0
- package/dist/libs/task-flow/pipeline/stages/commit-push.stage.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/commit-push.stage.js +120 -0
- package/dist/libs/task-flow/pipeline/stages/commit-push.stage.js.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/docker-env.stage.d.ts +56 -0
- package/dist/libs/task-flow/pipeline/stages/docker-env.stage.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/docker-env.stage.js +179 -0
- package/dist/libs/task-flow/pipeline/stages/docker-env.stage.js.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/fn.stage.d.ts +29 -0
- package/dist/libs/task-flow/pipeline/stages/fn.stage.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/fn.stage.js +41 -0
- package/dist/libs/task-flow/pipeline/stages/fn.stage.js.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/git-worktree.stage.d.ts +34 -0
- package/dist/libs/task-flow/pipeline/stages/git-worktree.stage.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/git-worktree.stage.js +65 -0
- package/dist/libs/task-flow/pipeline/stages/git-worktree.stage.js.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/index.d.ts +5 -0
- package/dist/libs/task-flow/pipeline/stages/index.d.ts.map +1 -0
- package/dist/libs/task-flow/pipeline/stages/index.js +21 -0
- package/dist/libs/task-flow/pipeline/stages/index.js.map +1 -0
- package/dist/libs/task-flow/role-orchestrator.class.d.ts +24 -0
- package/dist/libs/task-flow/role-orchestrator.class.d.ts.map +1 -0
- package/dist/libs/task-flow/role-orchestrator.class.js +67 -0
- package/dist/libs/task-flow/role-orchestrator.class.js.map +1 -0
- package/dist/libs/task-flow/task-flow-orchestrator.class.d.ts +49 -0
- package/dist/libs/task-flow/task-flow-orchestrator.class.d.ts.map +1 -0
- package/dist/libs/task-flow/task-flow-orchestrator.class.js +140 -0
- package/dist/libs/task-flow/task-flow-orchestrator.class.js.map +1 -0
- package/dist/libs/task-flow/task-gate-engine.class.d.ts +23 -0
- package/dist/libs/task-flow/task-gate-engine.class.d.ts.map +1 -0
- package/dist/libs/task-flow/task-gate-engine.class.js +152 -0
- package/dist/libs/task-flow/task-gate-engine.class.js.map +1 -0
- package/dist/libs/thoughtflow-agent-hierarchy.d.ts +153 -0
- package/dist/libs/thoughtflow-agent-hierarchy.d.ts.map +1 -0
- package/dist/libs/thoughtflow-agent-hierarchy.js +913 -0
- package/dist/libs/thoughtflow-agent-hierarchy.js.map +1 -0
- package/dist/libs/thoughtflow-knowledge-graph.d.ts +233 -0
- package/dist/libs/thoughtflow-knowledge-graph.d.ts.map +1 -0
- package/dist/libs/thoughtflow-knowledge-graph.js +17 -0
- package/dist/libs/thoughtflow-knowledge-graph.js.map +1 -0
- package/dist/libs/thoughtflow-orchestrator-layers.d.ts +169 -0
- package/dist/libs/thoughtflow-orchestrator-layers.d.ts.map +1 -0
- package/dist/libs/thoughtflow-orchestrator-layers.js +83 -0
- package/dist/libs/thoughtflow-orchestrator-layers.js.map +1 -0
- package/dist/libs/thoughtflow-orchestrator.d.ts +123 -0
- package/dist/libs/thoughtflow-orchestrator.d.ts.map +1 -0
- package/dist/libs/thoughtflow-orchestrator.js +304 -0
- package/dist/libs/thoughtflow-orchestrator.js.map +1 -0
- package/dist/libs/thoughtflow-sdlc-phases.d.ts +67 -0
- package/dist/libs/thoughtflow-sdlc-phases.d.ts.map +1 -0
- package/dist/libs/thoughtflow-sdlc-phases.js +234 -0
- package/dist/libs/thoughtflow-sdlc-phases.js.map +1 -0
- package/dist/libs/thoughtflow-tool-skill-wiring.d.ts +120 -0
- package/dist/libs/thoughtflow-tool-skill-wiring.d.ts.map +1 -0
- package/dist/libs/thoughtflow-tool-skill-wiring.js +360 -0
- package/dist/libs/thoughtflow-tool-skill-wiring.js.map +1 -0
- package/dist/libs/time-travel-execution.d.ts +189 -0
- package/dist/libs/time-travel-execution.d.ts.map +1 -0
- package/dist/libs/time-travel-execution.js +401 -0
- package/dist/libs/time-travel-execution.js.map +1 -0
- package/dist/libs/tool-capabilities.data.d.ts +3 -0
- package/dist/libs/tool-capabilities.data.d.ts.map +1 -0
- package/dist/libs/tool-capabilities.data.js +1462 -0
- package/dist/libs/tool-capabilities.data.js.map +1 -0
- package/dist/libs/tool-discovery.class.d.ts +12 -0
- package/dist/libs/tool-discovery.class.d.ts.map +1 -0
- package/dist/libs/tool-discovery.class.js +61 -0
- package/dist/libs/tool-discovery.class.js.map +1 -0
- package/dist/libs/tool-metadata-registry.class.d.ts +19 -0
- package/dist/libs/tool-metadata-registry.class.d.ts.map +1 -0
- package/dist/libs/tool-metadata-registry.class.js +123 -0
- package/dist/libs/tool-metadata-registry.class.js.map +1 -0
- package/dist/libs/tool-router.class.d.ts +15 -0
- package/dist/libs/tool-router.class.d.ts.map +1 -0
- package/dist/libs/tool-router.class.js +50 -0
- package/dist/libs/tool-router.class.js.map +1 -0
- package/dist/libs/tool-router.d.ts +32 -0
- package/dist/libs/tool-router.d.ts.map +1 -0
- package/dist/libs/tool-router.js +155 -0
- package/dist/libs/tool-router.js.map +1 -0
- package/dist/libs/typescript-decoder.class.d.ts +36 -0
- package/dist/libs/typescript-decoder.class.d.ts.map +1 -0
- package/dist/libs/typescript-decoder.class.js +397 -0
- package/dist/libs/typescript-decoder.class.js.map +1 -0
- package/dist/libs/utils.d.ts +2 -0
- package/dist/libs/utils.d.ts.map +1 -0
- package/dist/libs/utils.js +13 -0
- package/dist/libs/utils.js.map +1 -0
- package/dist/libs/validation-engine.d.ts +197 -0
- package/dist/libs/validation-engine.d.ts.map +1 -0
- package/dist/libs/validation-engine.js +366 -0
- package/dist/libs/validation-engine.js.map +1 -0
- package/dist/patterns/vision-review.pattern.d.ts +18 -0
- package/dist/patterns/vision-review.pattern.d.ts.map +1 -0
- package/dist/patterns/vision-review.pattern.js +22 -0
- package/dist/patterns/vision-review.pattern.js.map +1 -0
- package/dist/plugins/browser.plugin.d.ts +20 -0
- package/dist/plugins/browser.plugin.d.ts.map +1 -0
- package/dist/plugins/browser.plugin.js +26 -0
- package/dist/plugins/browser.plugin.js.map +1 -0
- package/dist/plugins/codebase-intelligence.plugin.d.ts +7 -0
- package/dist/plugins/codebase-intelligence.plugin.d.ts.map +1 -0
- package/dist/plugins/codebase-intelligence.plugin.js +35 -0
- package/dist/plugins/codebase-intelligence.plugin.js.map +1 -0
- package/dist/plugins/docker.plugin.d.ts +18 -0
- package/dist/plugins/docker.plugin.d.ts.map +1 -0
- package/dist/plugins/docker.plugin.js +30 -0
- package/dist/plugins/docker.plugin.js.map +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +20 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/workspace.plugin.d.ts +28 -0
- package/dist/plugins/workspace.plugin.d.ts.map +1 -0
- package/dist/plugins/workspace.plugin.js +42 -0
- package/dist/plugins/workspace.plugin.js.map +1 -0
- package/dist/protocol/types.d.ts +34 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +3 -0
- package/dist/protocol/types.js.map +1 -0
- package/dist/quick/agent-kit.d.ts +93 -0
- package/dist/quick/agent-kit.d.ts.map +1 -0
- package/dist/quick/agent-kit.js +148 -0
- package/dist/quick/agent-kit.js.map +1 -0
- package/dist/quick/core-preset.d.ts +36 -0
- package/dist/quick/core-preset.d.ts.map +1 -0
- package/dist/quick/core-preset.js +38 -0
- package/dist/quick/core-preset.js.map +1 -0
- package/dist/quick/demo-runtime-config.d.ts +99 -0
- package/dist/quick/demo-runtime-config.d.ts.map +1 -0
- package/dist/quick/demo-runtime-config.js +115 -0
- package/dist/quick/demo-runtime-config.js.map +1 -0
- package/dist/skills/skill-loader.class.d.ts +10 -0
- package/dist/skills/skill-loader.class.d.ts.map +1 -0
- package/dist/skills/skill-loader.class.js +56 -0
- package/dist/skills/skill-loader.class.js.map +1 -0
- package/dist/storage/in-memory.adapter.d.ts +33 -0
- package/dist/storage/in-memory.adapter.d.ts.map +1 -0
- package/dist/storage/in-memory.adapter.js +153 -0
- package/dist/storage/in-memory.adapter.js.map +1 -0
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +20 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/json-file.adapter.d.ts +38 -0
- package/dist/storage/json-file.adapter.d.ts.map +1 -0
- package/dist/storage/json-file.adapter.js +259 -0
- package/dist/storage/json-file.adapter.js.map +1 -0
- package/dist/storage/vector/factory.d.ts +4 -0
- package/dist/storage/vector/factory.d.ts.map +1 -0
- package/dist/storage/vector/factory.js +51 -0
- package/dist/storage/vector/factory.js.map +1 -0
- package/dist/storage/vector/index.d.ts +9 -0
- package/dist/storage/vector/index.d.ts.map +1 -0
- package/dist/storage/vector/index.js +25 -0
- package/dist/storage/vector/index.js.map +1 -0
- package/dist/storage/vector/lancedb-vector-store.d.ts +28 -0
- package/dist/storage/vector/lancedb-vector-store.d.ts.map +1 -0
- package/dist/storage/vector/lancedb-vector-store.js +189 -0
- package/dist/storage/vector/lancedb-vector-store.js.map +1 -0
- package/dist/storage/vector/memory-vector-store.d.ts +18 -0
- package/dist/storage/vector/memory-vector-store.d.ts.map +1 -0
- package/dist/storage/vector/memory-vector-store.js +101 -0
- package/dist/storage/vector/memory-vector-store.js.map +1 -0
- package/dist/storage/vector/mock-embedding.d.ts +10 -0
- package/dist/storage/vector/mock-embedding.d.ts.map +1 -0
- package/dist/storage/vector/mock-embedding.js +36 -0
- package/dist/storage/vector/mock-embedding.js.map +1 -0
- package/dist/storage/vector/ollama-embedding.d.ts +17 -0
- package/dist/storage/vector/ollama-embedding.d.ts.map +1 -0
- package/dist/storage/vector/ollama-embedding.js +38 -0
- package/dist/storage/vector/ollama-embedding.js.map +1 -0
- package/dist/storage/vector/transformers-embedding.d.ts +23 -0
- package/dist/storage/vector/transformers-embedding.d.ts.map +1 -0
- package/dist/storage/vector/transformers-embedding.js +80 -0
- package/dist/storage/vector/transformers-embedding.js.map +1 -0
- package/dist/tools/base/path-utils.d.ts +13 -0
- package/dist/tools/base/path-utils.d.ts.map +1 -0
- package/dist/tools/base/path-utils.js +96 -0
- package/dist/tools/base/path-utils.js.map +1 -0
- package/dist/tools/base/pii-guard.middleware.d.ts +45 -0
- package/dist/tools/base/pii-guard.middleware.d.ts.map +1 -0
- package/dist/tools/base/pii-guard.middleware.js +140 -0
- package/dist/tools/base/pii-guard.middleware.js.map +1 -0
- package/dist/tools/base/tool-base.class.d.ts +16 -0
- package/dist/tools/base/tool-base.class.d.ts.map +1 -0
- package/dist/tools/base/tool-base.class.js +17 -0
- package/dist/tools/base/tool-base.class.js.map +1 -0
- package/dist/tools/base/tool-result-normalizer.class.d.ts +6 -0
- package/dist/tools/base/tool-result-normalizer.class.d.ts.map +1 -0
- package/dist/tools/base/tool-result-normalizer.class.js +33 -0
- package/dist/tools/base/tool-result-normalizer.class.js.map +1 -0
- package/dist/tools/base/tool-status-tracker.class.d.ts +9 -0
- package/dist/tools/base/tool-status-tracker.class.d.ts.map +1 -0
- package/dist/tools/base/tool-status-tracker.class.js +42 -0
- package/dist/tools/base/tool-status-tracker.class.js.map +1 -0
- package/dist/tools/codebase/codebase-analyze.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-analyze.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-analyze.tool.js +20 -0
- package/dist/tools/codebase/codebase-analyze.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-crossref.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-crossref.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-crossref.tool.js +20 -0
- package/dist/tools/codebase/codebase-crossref.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-flow.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-flow.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-flow.tool.js +20 -0
- package/dist/tools/codebase/codebase-flow.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-graph-circular.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-graph-circular.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-graph-circular.tool.js +17 -0
- package/dist/tools/codebase/codebase-graph-circular.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-graph-query.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-graph-query.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-graph-query.tool.js +21 -0
- package/dist/tools/codebase/codebase-graph-query.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-graph-stats.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-graph-stats.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-graph-stats.tool.js +17 -0
- package/dist/tools/codebase/codebase-graph-stats.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-graph-visualize.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-graph-visualize.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-graph-visualize.tool.js +21 -0
- package/dist/tools/codebase/codebase-graph-visualize.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-impact.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-impact.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-impact.tool.js +21 -0
- package/dist/tools/codebase/codebase-impact.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-index.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-index.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-index.tool.js +21 -0
- package/dist/tools/codebase/codebase-index.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-knowledge.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-knowledge.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-knowledge.tool.js +22 -0
- package/dist/tools/codebase/codebase-knowledge.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-search.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-search.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-search.tool.js +24 -0
- package/dist/tools/codebase/codebase-search.tool.js.map +1 -0
- package/dist/tools/codebase/codebase-status.tool.d.ts +9 -0
- package/dist/tools/codebase/codebase-status.tool.d.ts.map +1 -0
- package/dist/tools/codebase/codebase-status.tool.js +19 -0
- package/dist/tools/codebase/codebase-status.tool.js.map +1 -0
- package/dist/tools/conversation-history.tool.d.ts +13 -0
- package/dist/tools/conversation-history.tool.d.ts.map +1 -0
- package/dist/tools/conversation-history.tool.js +66 -0
- package/dist/tools/conversation-history.tool.js.map +1 -0
- package/dist/tools/database/db-diagram.tool.d.ts +10 -0
- package/dist/tools/database/db-diagram.tool.d.ts.map +1 -0
- package/dist/tools/database/db-diagram.tool.js +78 -0
- package/dist/tools/database/db-diagram.tool.js.map +1 -0
- package/dist/tools/database/db-index-suggest.tool.d.ts +10 -0
- package/dist/tools/database/db-index-suggest.tool.d.ts.map +1 -0
- package/dist/tools/database/db-index-suggest.tool.js +94 -0
- package/dist/tools/database/db-index-suggest.tool.js.map +1 -0
- package/dist/tools/database/db-migration.tool.d.ts +10 -0
- package/dist/tools/database/db-migration.tool.d.ts.map +1 -0
- package/dist/tools/database/db-migration.tool.js +88 -0
- package/dist/tools/database/db-migration.tool.js.map +1 -0
- package/dist/tools/database/index.d.ts +4 -0
- package/dist/tools/database/index.d.ts.map +1 -0
- package/dist/tools/database/index.js +20 -0
- package/dist/tools/database/index.js.map +1 -0
- package/dist/tools/devops/ci-diagnose.tool.d.ts +10 -0
- package/dist/tools/devops/ci-diagnose.tool.d.ts.map +1 -0
- package/dist/tools/devops/ci-diagnose.tool.js +30 -0
- package/dist/tools/devops/ci-diagnose.tool.js.map +1 -0
- package/dist/tools/devops/ci-workflow.tool.d.ts +10 -0
- package/dist/tools/devops/ci-workflow.tool.d.ts.map +1 -0
- package/dist/tools/devops/ci-workflow.tool.js +28 -0
- package/dist/tools/devops/ci-workflow.tool.js.map +1 -0
- package/dist/tools/devops/deploy-check.tool.d.ts +10 -0
- package/dist/tools/devops/deploy-check.tool.d.ts.map +1 -0
- package/dist/tools/devops/deploy-check.tool.js +67 -0
- package/dist/tools/devops/deploy-check.tool.js.map +1 -0
- package/dist/tools/devops/docker-optimize.tool.d.ts +10 -0
- package/dist/tools/devops/docker-optimize.tool.d.ts.map +1 -0
- package/dist/tools/devops/docker-optimize.tool.js +68 -0
- package/dist/tools/devops/docker-optimize.tool.js.map +1 -0
- package/dist/tools/devops/env-check.tool.d.ts +10 -0
- package/dist/tools/devops/env-check.tool.d.ts.map +1 -0
- package/dist/tools/devops/env-check.tool.js +81 -0
- package/dist/tools/devops/env-check.tool.js.map +1 -0
- package/dist/tools/devops/env-generate.tool.d.ts +10 -0
- package/dist/tools/devops/env-generate.tool.d.ts.map +1 -0
- package/dist/tools/devops/env-generate.tool.js +64 -0
- package/dist/tools/devops/env-generate.tool.js.map +1 -0
- package/dist/tools/devops/index.d.ts +8 -0
- package/dist/tools/devops/index.d.ts.map +1 -0
- package/dist/tools/devops/index.js +24 -0
- package/dist/tools/devops/index.js.map +1 -0
- package/dist/tools/devops/k8s-manifests.tool.d.ts +10 -0
- package/dist/tools/devops/k8s-manifests.tool.d.ts.map +1 -0
- package/dist/tools/devops/k8s-manifests.tool.js +19 -0
- package/dist/tools/devops/k8s-manifests.tool.js.map +1 -0
- package/dist/tools/docs/api-client.tool.d.ts +10 -0
- package/dist/tools/docs/api-client.tool.d.ts.map +1 -0
- package/dist/tools/docs/api-client.tool.js +106 -0
- package/dist/tools/docs/api-client.tool.js.map +1 -0
- package/dist/tools/docs/doc-check-coverage.tool.d.ts +10 -0
- package/dist/tools/docs/doc-check-coverage.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-check-coverage.tool.js +44 -0
- package/dist/tools/docs/doc-check-coverage.tool.js.map +1 -0
- package/dist/tools/docs/doc-check-links.tool.d.ts +10 -0
- package/dist/tools/docs/doc-check-links.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-check-links.tool.js +88 -0
- package/dist/tools/docs/doc-check-links.tool.js.map +1 -0
- package/dist/tools/docs/doc-gen-adr.tool.d.ts +10 -0
- package/dist/tools/docs/doc-gen-adr.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-gen-adr.tool.js +25 -0
- package/dist/tools/docs/doc-gen-adr.tool.js.map +1 -0
- package/dist/tools/docs/doc-gen-api.tool.d.ts +10 -0
- package/dist/tools/docs/doc-gen-api.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-gen-api.tool.js +70 -0
- package/dist/tools/docs/doc-gen-api.tool.js.map +1 -0
- package/dist/tools/docs/doc-gen-diagrams.tool.d.ts +10 -0
- package/dist/tools/docs/doc-gen-diagrams.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-gen-diagrams.tool.js +31 -0
- package/dist/tools/docs/doc-gen-diagrams.tool.js.map +1 -0
- package/dist/tools/docs/doc-gen-readme.tool.d.ts +10 -0
- package/dist/tools/docs/doc-gen-readme.tool.d.ts.map +1 -0
- package/dist/tools/docs/doc-gen-readme.tool.js +71 -0
- package/dist/tools/docs/doc-gen-readme.tool.js.map +1 -0
- package/dist/tools/docs/index.d.ts +8 -0
- package/dist/tools/docs/index.d.ts.map +1 -0
- package/dist/tools/docs/index.js +24 -0
- package/dist/tools/docs/index.js.map +1 -0
- package/dist/tools/memory/index.d.ts +7 -0
- package/dist/tools/memory/index.d.ts.map +1 -0
- package/dist/tools/memory/index.js +23 -0
- package/dist/tools/memory/index.js.map +1 -0
- package/dist/tools/memory/memory-context.tool.d.ts +12 -0
- package/dist/tools/memory/memory-context.tool.d.ts.map +1 -0
- package/dist/tools/memory/memory-context.tool.js +25 -0
- package/dist/tools/memory/memory-context.tool.js.map +1 -0
- package/dist/tools/memory/memory-lessons.tool.d.ts +12 -0
- package/dist/tools/memory/memory-lessons.tool.d.ts.map +1 -0
- package/dist/tools/memory/memory-lessons.tool.js +30 -0
- package/dist/tools/memory/memory-lessons.tool.js.map +1 -0
- package/dist/tools/memory/memory-patterns.tool.d.ts +12 -0
- package/dist/tools/memory/memory-patterns.tool.d.ts.map +1 -0
- package/dist/tools/memory/memory-patterns.tool.js +31 -0
- package/dist/tools/memory/memory-patterns.tool.js.map +1 -0
- package/dist/tools/memory/memory-recall.tool.d.ts +12 -0
- package/dist/tools/memory/memory-recall.tool.d.ts.map +1 -0
- package/dist/tools/memory/memory-recall.tool.js +24 -0
- package/dist/tools/memory/memory-recall.tool.js.map +1 -0
- package/dist/tools/memory/memory-save.tool.d.ts +12 -0
- package/dist/tools/memory/memory-save.tool.d.ts.map +1 -0
- package/dist/tools/memory/memory-save.tool.js +28 -0
- package/dist/tools/memory/memory-save.tool.js.map +1 -0
- package/dist/tools/neural/comparative-analysis.tool.d.ts +38 -0
- package/dist/tools/neural/comparative-analysis.tool.d.ts.map +1 -0
- package/dist/tools/neural/comparative-analysis.tool.js +241 -0
- package/dist/tools/neural/comparative-analysis.tool.js.map +1 -0
- package/dist/tools/neural/index.d.ts +12 -0
- package/dist/tools/neural/index.d.ts.map +1 -0
- package/dist/tools/neural/index.js +28 -0
- package/dist/tools/neural/index.js.map +1 -0
- package/dist/tools/neural/neural-deadcode.tool.d.ts +11 -0
- package/dist/tools/neural/neural-deadcode.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-deadcode.tool.js +133 -0
- package/dist/tools/neural/neural-deadcode.tool.js.map +1 -0
- package/dist/tools/neural/neural-debug.tool.d.ts +12 -0
- package/dist/tools/neural/neural-debug.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-debug.tool.js +205 -0
- package/dist/tools/neural/neural-debug.tool.js.map +1 -0
- package/dist/tools/neural/neural-explain.tool.d.ts +10 -0
- package/dist/tools/neural/neural-explain.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-explain.tool.js +100 -0
- package/dist/tools/neural/neural-explain.tool.js.map +1 -0
- package/dist/tools/neural/neural-optimize.tool.d.ts +10 -0
- package/dist/tools/neural/neural-optimize.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-optimize.tool.js +117 -0
- package/dist/tools/neural/neural-optimize.tool.js.map +1 -0
- package/dist/tools/neural/neural-pattern.tool.d.ts +11 -0
- package/dist/tools/neural/neural-pattern.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-pattern.tool.js +169 -0
- package/dist/tools/neural/neural-pattern.tool.js.map +1 -0
- package/dist/tools/neural/neural-review.tool.d.ts +12 -0
- package/dist/tools/neural/neural-review.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-review.tool.js +152 -0
- package/dist/tools/neural/neural-review.tool.js.map +1 -0
- package/dist/tools/neural/neural-security.tool.d.ts +17 -0
- package/dist/tools/neural/neural-security.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-security.tool.js +256 -0
- package/dist/tools/neural/neural-security.tool.js.map +1 -0
- package/dist/tools/neural/neural-similar.tool.d.ts +10 -0
- package/dist/tools/neural/neural-similar.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-similar.tool.js +141 -0
- package/dist/tools/neural/neural-similar.tool.js.map +1 -0
- package/dist/tools/neural/neural-smells.tool.d.ts +10 -0
- package/dist/tools/neural/neural-smells.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-smells.tool.js +123 -0
- package/dist/tools/neural/neural-smells.tool.js.map +1 -0
- package/dist/tools/neural/neural-suggest.tool.d.ts +10 -0
- package/dist/tools/neural/neural-suggest.tool.d.ts.map +1 -0
- package/dist/tools/neural/neural-suggest.tool.js +64 -0
- package/dist/tools/neural/neural-suggest.tool.js.map +1 -0
- package/dist/tools/planning/adaptive-lookup.tool.d.ts +38 -0
- package/dist/tools/planning/adaptive-lookup.tool.d.ts.map +1 -0
- package/dist/tools/planning/adaptive-lookup.tool.js +279 -0
- package/dist/tools/planning/adaptive-lookup.tool.js.map +1 -0
- package/dist/tools/planning/index.d.ts +9 -0
- package/dist/tools/planning/index.d.ts.map +1 -0
- package/dist/tools/planning/index.js +25 -0
- package/dist/tools/planning/index.js.map +1 -0
- package/dist/tools/planning/pm-breakdown.tool.d.ts +10 -0
- package/dist/tools/planning/pm-breakdown.tool.d.ts.map +1 -0
- package/dist/tools/planning/pm-breakdown.tool.js +48 -0
- package/dist/tools/planning/pm-breakdown.tool.js.map +1 -0
- package/dist/tools/planning/pm-deps.tool.d.ts +10 -0
- package/dist/tools/planning/pm-deps.tool.d.ts.map +1 -0
- package/dist/tools/planning/pm-deps.tool.js +29 -0
- package/dist/tools/planning/pm-deps.tool.js.map +1 -0
- package/dist/tools/planning/pm-estimate.tool.d.ts +10 -0
- package/dist/tools/planning/pm-estimate.tool.d.ts.map +1 -0
- package/dist/tools/planning/pm-estimate.tool.js +40 -0
- package/dist/tools/planning/pm-estimate.tool.js.map +1 -0
- package/dist/tools/planning/pm-progress.tool.d.ts +10 -0
- package/dist/tools/planning/pm-progress.tool.d.ts.map +1 -0
- package/dist/tools/planning/pm-progress.tool.js +29 -0
- package/dist/tools/planning/pm-progress.tool.js.map +1 -0
- package/dist/tools/planning/pm-risks.tool.d.ts +10 -0
- package/dist/tools/planning/pm-risks.tool.d.ts.map +1 -0
- package/dist/tools/planning/pm-risks.tool.js +34 -0
- package/dist/tools/planning/pm-risks.tool.js.map +1 -0
- package/dist/tools/planning/problem-tree.tool.d.ts +24 -0
- package/dist/tools/planning/problem-tree.tool.d.ts.map +1 -0
- package/dist/tools/planning/problem-tree.tool.js +307 -0
- package/dist/tools/planning/problem-tree.tool.js.map +1 -0
- package/dist/tools/planning/solve-complex.tool.d.ts +69 -0
- package/dist/tools/planning/solve-complex.tool.d.ts.map +1 -0
- package/dist/tools/planning/solve-complex.tool.js +633 -0
- package/dist/tools/planning/solve-complex.tool.js.map +1 -0
- package/dist/tools/quality/index.d.ts +8 -0
- package/dist/tools/quality/index.d.ts.map +1 -0
- package/dist/tools/quality/index.js +24 -0
- package/dist/tools/quality/index.js.map +1 -0
- package/dist/tools/quality/quality-complexity.tool.d.ts +12 -0
- package/dist/tools/quality/quality-complexity.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-complexity.tool.js +152 -0
- package/dist/tools/quality/quality-complexity.tool.js.map +1 -0
- package/dist/tools/quality/quality-coupling.tool.d.ts +10 -0
- package/dist/tools/quality/quality-coupling.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-coupling.tool.js +51 -0
- package/dist/tools/quality/quality-coupling.tool.js.map +1 -0
- package/dist/tools/quality/quality-coverage.tool.d.ts +10 -0
- package/dist/tools/quality/quality-coverage.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-coverage.tool.js +104 -0
- package/dist/tools/quality/quality-coverage.tool.js.map +1 -0
- package/dist/tools/quality/quality-deps.tool.d.ts +12 -0
- package/dist/tools/quality/quality-deps.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-deps.tool.js +119 -0
- package/dist/tools/quality/quality-deps.tool.js.map +1 -0
- package/dist/tools/quality/quality-duplication.tool.d.ts +10 -0
- package/dist/tools/quality/quality-duplication.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-duplication.tool.js +100 -0
- package/dist/tools/quality/quality-duplication.tool.js.map +1 -0
- package/dist/tools/quality/quality-size.tool.d.ts +10 -0
- package/dist/tools/quality/quality-size.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-size.tool.js +94 -0
- package/dist/tools/quality/quality-size.tool.js.map +1 -0
- package/dist/tools/quality/quality-types.tool.d.ts +10 -0
- package/dist/tools/quality/quality-types.tool.d.ts.map +1 -0
- package/dist/tools/quality/quality-types.tool.js +95 -0
- package/dist/tools/quality/quality-types.tool.js.map +1 -0
- package/dist/tools/refactor/eslint-fix.tool.d.ts +27 -0
- package/dist/tools/refactor/eslint-fix.tool.d.ts.map +1 -0
- package/dist/tools/refactor/eslint-fix.tool.js +295 -0
- package/dist/tools/refactor/eslint-fix.tool.js.map +1 -0
- package/dist/tools/refactor/index.d.ts +10 -0
- package/dist/tools/refactor/index.d.ts.map +1 -0
- package/dist/tools/refactor/index.js +26 -0
- package/dist/tools/refactor/index.js.map +1 -0
- package/dist/tools/refactor/refactor-async.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-async.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-async.tool.js +100 -0
- package/dist/tools/refactor/refactor-async.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-barrel.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-barrel.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-barrel.tool.js +72 -0
- package/dist/tools/refactor/refactor-barrel.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-extract.tool.d.ts +11 -0
- package/dist/tools/refactor/refactor-extract.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-extract.tool.js +64 -0
- package/dist/tools/refactor/refactor-extract.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-imports.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-imports.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-imports.tool.js +108 -0
- package/dist/tools/refactor/refactor-imports.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-move.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-move.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-move.tool.js +99 -0
- package/dist/tools/refactor/refactor-move.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-rename.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-rename.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-rename.tool.js +69 -0
- package/dist/tools/refactor/refactor-rename.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-split.tool.d.ts +10 -0
- package/dist/tools/refactor/refactor-split.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-split.tool.js +80 -0
- package/dist/tools/refactor/refactor-split.tool.js.map +1 -0
- package/dist/tools/refactor/refactor-types.tool.d.ts +11 -0
- package/dist/tools/refactor/refactor-types.tool.d.ts.map +1 -0
- package/dist/tools/refactor/refactor-types.tool.js +123 -0
- package/dist/tools/refactor/refactor-types.tool.js.map +1 -0
- package/dist/tools/subagent-conversation.tool.d.ts +13 -0
- package/dist/tools/subagent-conversation.tool.d.ts.map +1 -0
- package/dist/tools/subagent-conversation.tool.js +31 -0
- package/dist/tools/subagent-conversation.tool.js.map +1 -0
- package/dist/tools/subagent-job.tool.d.ts +24 -0
- package/dist/tools/subagent-job.tool.d.ts.map +1 -0
- package/dist/tools/subagent-job.tool.js +146 -0
- package/dist/tools/subagent-job.tool.js.map +1 -0
- package/dist/tools/testing/index.d.ts +7 -0
- package/dist/tools/testing/index.d.ts.map +1 -0
- package/dist/tools/testing/index.js +23 -0
- package/dist/tools/testing/index.js.map +1 -0
- package/dist/tools/testing/test-fix.tool.d.ts +10 -0
- package/dist/tools/testing/test-fix.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-fix.tool.js +56 -0
- package/dist/tools/testing/test-fix.tool.js.map +1 -0
- package/dist/tools/testing/test-fuzz.tool.d.ts +10 -0
- package/dist/tools/testing/test-fuzz.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-fuzz.tool.js +42 -0
- package/dist/tools/testing/test-fuzz.tool.js.map +1 -0
- package/dist/tools/testing/test-gap.tool.d.ts +10 -0
- package/dist/tools/testing/test-gap.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-gap.tool.js +36 -0
- package/dist/tools/testing/test-gap.tool.js.map +1 -0
- package/dist/tools/testing/test-gen-integration.tool.d.ts +10 -0
- package/dist/tools/testing/test-gen-integration.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-gen-integration.tool.js +57 -0
- package/dist/tools/testing/test-gen-integration.tool.js.map +1 -0
- package/dist/tools/testing/test-gen-unit.tool.d.ts +10 -0
- package/dist/tools/testing/test-gen-unit.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-gen-unit.tool.js +51 -0
- package/dist/tools/testing/test-gen-unit.tool.js.map +1 -0
- package/dist/tools/testing/test-snapshot.tool.d.ts +10 -0
- package/dist/tools/testing/test-snapshot.tool.d.ts.map +1 -0
- package/dist/tools/testing/test-snapshot.tool.js +49 -0
- package/dist/tools/testing/test-snapshot.tool.js.map +1 -0
- package/dist/tools/tool-name.tool.d.ts +9 -0
- package/dist/tools/tool-name.tool.d.ts.map +1 -0
- package/dist/tools/tool-name.tool.js +28 -0
- package/dist/tools/tool-name.tool.js.map +1 -0
- package/dist/tools/tool-registry.class.d.ts +57 -0
- package/dist/tools/tool-registry.class.d.ts.map +1 -0
- package/dist/tools/tool-registry.class.js +311 -0
- package/dist/tools/tool-registry.class.js.map +1 -0
- package/dist/tools/workspace/analyze-project.tool.d.ts +38 -0
- package/dist/tools/workspace/analyze-project.tool.d.ts.map +1 -0
- package/dist/tools/workspace/analyze-project.tool.js +455 -0
- package/dist/tools/workspace/analyze-project.tool.js.map +1 -0
- package/dist/tools/workspace/auto-commit.tool.d.ts +11 -0
- package/dist/tools/workspace/auto-commit.tool.d.ts.map +1 -0
- package/dist/tools/workspace/auto-commit.tool.js +86 -0
- package/dist/tools/workspace/auto-commit.tool.js.map +1 -0
- package/dist/tools/workspace/batch-write-files.tool.d.ts +11 -0
- package/dist/tools/workspace/batch-write-files.tool.d.ts.map +1 -0
- package/dist/tools/workspace/batch-write-files.tool.js +97 -0
- package/dist/tools/workspace/batch-write-files.tool.js.map +1 -0
- package/dist/tools/workspace/browser.tool.d.ts +24 -0
- package/dist/tools/workspace/browser.tool.d.ts.map +1 -0
- package/dist/tools/workspace/browser.tool.js +170 -0
- package/dist/tools/workspace/browser.tool.js.map +1 -0
- package/dist/tools/workspace/codebase-research.tool.d.ts +11 -0
- package/dist/tools/workspace/codebase-research.tool.d.ts.map +1 -0
- package/dist/tools/workspace/codebase-research.tool.js +90 -0
- package/dist/tools/workspace/codebase-research.tool.js.map +1 -0
- package/dist/tools/workspace/docker.tool.d.ts +29 -0
- package/dist/tools/workspace/docker.tool.d.ts.map +1 -0
- package/dist/tools/workspace/docker.tool.js +235 -0
- package/dist/tools/workspace/docker.tool.js.map +1 -0
- package/dist/tools/workspace/edit-file.tool.d.ts +32 -0
- package/dist/tools/workspace/edit-file.tool.d.ts.map +1 -0
- package/dist/tools/workspace/edit-file.tool.js +172 -0
- package/dist/tools/workspace/edit-file.tool.js.map +1 -0
- package/dist/tools/workspace/find-files.tool.d.ts +12 -0
- package/dist/tools/workspace/find-files.tool.d.ts.map +1 -0
- package/dist/tools/workspace/find-files.tool.js +120 -0
- package/dist/tools/workspace/find-files.tool.js.map +1 -0
- package/dist/tools/workspace/get-task.tool.d.ts +12 -0
- package/dist/tools/workspace/get-task.tool.d.ts.map +1 -0
- package/dist/tools/workspace/get-task.tool.js +31 -0
- package/dist/tools/workspace/get-task.tool.js.map +1 -0
- package/dist/tools/workspace/git.tool.d.ts +32 -0
- package/dist/tools/workspace/git.tool.d.ts.map +1 -0
- package/dist/tools/workspace/git.tool.js +279 -0
- package/dist/tools/workspace/git.tool.js.map +1 -0
- package/dist/tools/workspace/grep.tool.d.ts +16 -0
- package/dist/tools/workspace/grep.tool.d.ts.map +1 -0
- package/dist/tools/workspace/grep.tool.js +172 -0
- package/dist/tools/workspace/grep.tool.js.map +1 -0
- package/dist/tools/workspace/http-request.tool.d.ts +11 -0
- package/dist/tools/workspace/http-request.tool.d.ts.map +1 -0
- package/dist/tools/workspace/http-request.tool.js +102 -0
- package/dist/tools/workspace/http-request.tool.js.map +1 -0
- package/dist/tools/workspace/index.d.ts +29 -0
- package/dist/tools/workspace/index.d.ts.map +1 -0
- package/dist/tools/workspace/index.js +45 -0
- package/dist/tools/workspace/index.js.map +1 -0
- package/dist/tools/workspace/knowledge.tool.d.ts +25 -0
- package/dist/tools/workspace/knowledge.tool.d.ts.map +1 -0
- package/dist/tools/workspace/knowledge.tool.js +236 -0
- package/dist/tools/workspace/knowledge.tool.js.map +1 -0
- package/dist/tools/workspace/list-dir.tool.d.ts +14 -0
- package/dist/tools/workspace/list-dir.tool.d.ts.map +1 -0
- package/dist/tools/workspace/list-dir.tool.js +136 -0
- package/dist/tools/workspace/list-dir.tool.js.map +1 -0
- package/dist/tools/workspace/list-tasks.tool.d.ts +26 -0
- package/dist/tools/workspace/list-tasks.tool.d.ts.map +1 -0
- package/dist/tools/workspace/list-tasks.tool.js +31 -0
- package/dist/tools/workspace/list-tasks.tool.js.map +1 -0
- package/dist/tools/workspace/multi-file-patch.tool.d.ts +35 -0
- package/dist/tools/workspace/multi-file-patch.tool.d.ts.map +1 -0
- package/dist/tools/workspace/multi-file-patch.tool.js +185 -0
- package/dist/tools/workspace/multi-file-patch.tool.js.map +1 -0
- package/dist/tools/workspace/patch-file.tool.d.ts +30 -0
- package/dist/tools/workspace/patch-file.tool.d.ts.map +1 -0
- package/dist/tools/workspace/patch-file.tool.js +207 -0
- package/dist/tools/workspace/patch-file.tool.js.map +1 -0
- package/dist/tools/workspace/pipeline-run.tool.d.ts +11 -0
- package/dist/tools/workspace/pipeline-run.tool.d.ts.map +1 -0
- package/dist/tools/workspace/pipeline-run.tool.js +160 -0
- package/dist/tools/workspace/pipeline-run.tool.js.map +1 -0
- package/dist/tools/workspace/plan.tool.d.ts +44 -0
- package/dist/tools/workspace/plan.tool.d.ts.map +1 -0
- package/dist/tools/workspace/plan.tool.js +271 -0
- package/dist/tools/workspace/plan.tool.js.map +1 -0
- package/dist/tools/workspace/process-manager.tool.d.ts +23 -0
- package/dist/tools/workspace/process-manager.tool.d.ts.map +1 -0
- package/dist/tools/workspace/process-manager.tool.js +227 -0
- package/dist/tools/workspace/process-manager.tool.js.map +1 -0
- package/dist/tools/workspace/project-context.tool.d.ts +11 -0
- package/dist/tools/workspace/project-context.tool.d.ts.map +1 -0
- package/dist/tools/workspace/project-context.tool.js +124 -0
- package/dist/tools/workspace/project-context.tool.js.map +1 -0
- package/dist/tools/workspace/project-scanner.tool.d.ts +56 -0
- package/dist/tools/workspace/project-scanner.tool.d.ts.map +1 -0
- package/dist/tools/workspace/project-scanner.tool.js +979 -0
- package/dist/tools/workspace/project-scanner.tool.js.map +1 -0
- package/dist/tools/workspace/read-file.tool.d.ts +11 -0
- package/dist/tools/workspace/read-file.tool.d.ts.map +1 -0
- package/dist/tools/workspace/read-file.tool.js +84 -0
- package/dist/tools/workspace/read-file.tool.js.map +1 -0
- package/dist/tools/workspace/run-tsc.tool.d.ts +11 -0
- package/dist/tools/workspace/run-tsc.tool.d.ts.map +1 -0
- package/dist/tools/workspace/run-tsc.tool.js +94 -0
- package/dist/tools/workspace/run-tsc.tool.js.map +1 -0
- package/dist/tools/workspace/safe-edit-policy.tool.d.ts +12 -0
- package/dist/tools/workspace/safe-edit-policy.tool.d.ts.map +1 -0
- package/dist/tools/workspace/safe-edit-policy.tool.js +135 -0
- package/dist/tools/workspace/safe-edit-policy.tool.js.map +1 -0
- package/dist/tools/workspace/search-code.tool.d.ts +15 -0
- package/dist/tools/workspace/search-code.tool.d.ts.map +1 -0
- package/dist/tools/workspace/search-code.tool.js +286 -0
- package/dist/tools/workspace/search-code.tool.js.map +1 -0
- package/dist/tools/workspace/store.tool.d.ts +20 -0
- package/dist/tools/workspace/store.tool.d.ts.map +1 -0
- package/dist/tools/workspace/store.tool.js +246 -0
- package/dist/tools/workspace/store.tool.js.map +1 -0
- package/dist/tools/workspace/terminal-run.tool.d.ts +11 -0
- package/dist/tools/workspace/terminal-run.tool.d.ts.map +1 -0
- package/dist/tools/workspace/terminal-run.tool.js +122 -0
- package/dist/tools/workspace/terminal-run.tool.js.map +1 -0
- package/dist/tools/workspace/vision-browser.tool.d.ts +32 -0
- package/dist/tools/workspace/vision-browser.tool.d.ts.map +1 -0
- package/dist/tools/workspace/vision-browser.tool.js +270 -0
- package/dist/tools/workspace/vision-browser.tool.js.map +1 -0
- package/dist/tools/workspace/write-file.tool.d.ts +11 -0
- package/dist/tools/workspace/write-file.tool.d.ts.map +1 -0
- package/dist/tools/workspace/write-file.tool.js +77 -0
- package/dist/tools/workspace/write-file.tool.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1619 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConversationRunner = void 0;
|
|
4
|
+
const contracts_1 = require("../contracts");
|
|
5
|
+
const debug_logger_class_1 = require("./debug-logger.class");
|
|
6
|
+
// ─────────────────────────────────────────────────────────────
|
|
7
|
+
// Utility: collect tool calls from any Ollama response shape
|
|
8
|
+
// ─────────────────────────────────────────────────────────────
|
|
9
|
+
function normalizeToolArgs(raw) {
|
|
10
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
11
|
+
return {};
|
|
12
|
+
return raw;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Walk any Ollama response node and collect { name, arguments } tool call objects.
|
|
16
|
+
* Handles: tool_calls[], calls[], { function: { name, arguments } }, direct { name, arguments }.
|
|
17
|
+
*/
|
|
18
|
+
function collectStructuredToolCalls(node) {
|
|
19
|
+
const out = [];
|
|
20
|
+
const walk = (value) => {
|
|
21
|
+
if (!value)
|
|
22
|
+
return;
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
for (const item of value)
|
|
25
|
+
walk(item);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (typeof value !== "object")
|
|
29
|
+
return;
|
|
30
|
+
const obj = value;
|
|
31
|
+
if (typeof obj.name === "string") {
|
|
32
|
+
out.push({ id: typeof obj.id === "string" ? obj.id : undefined, name: obj.name, arguments: normalizeToolArgs(obj.arguments) });
|
|
33
|
+
}
|
|
34
|
+
if (obj.function && typeof obj.function === "object") {
|
|
35
|
+
const fn = obj.function;
|
|
36
|
+
if (typeof fn.name === "string") {
|
|
37
|
+
out.push({ id: typeof obj.id === "string" ? obj.id : undefined, name: fn.name, arguments: normalizeToolArgs(fn.arguments) });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (Array.isArray(obj.tool_calls))
|
|
41
|
+
for (const tc of obj.tool_calls)
|
|
42
|
+
walk(tc);
|
|
43
|
+
if (Array.isArray(obj.calls))
|
|
44
|
+
for (const c of obj.calls)
|
|
45
|
+
walk(c);
|
|
46
|
+
};
|
|
47
|
+
walk(node);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
function collectJsonCandidates(content) {
|
|
51
|
+
const text = (content || "").trim();
|
|
52
|
+
if (!text)
|
|
53
|
+
return [];
|
|
54
|
+
const candidates = [text];
|
|
55
|
+
const fenced = /```(?:json)?\s*([\s\S]*?)```/gi;
|
|
56
|
+
let match;
|
|
57
|
+
while ((match = fenced.exec(text)) !== null) {
|
|
58
|
+
const block = (match[1] || "").trim();
|
|
59
|
+
if (block)
|
|
60
|
+
candidates.push(block);
|
|
61
|
+
}
|
|
62
|
+
return candidates;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extract tool calls that the LLM embedded as JSON text instead of using the tool API.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Attempt to repair common LLM JSON formatting mistakes:
|
|
69
|
+
* - Single-quoted string values: body: '{"title":"Buy milk"}' → body: "{\"title\":\"Buy milk\"}"
|
|
70
|
+
*/
|
|
71
|
+
function repairLlmJson(raw) {
|
|
72
|
+
// Replace single-quoted string values with properly double-quoted+escaped equivalents.
|
|
73
|
+
// Matches: (after : or , or [ or {) 'content' where content may contain double-quotes
|
|
74
|
+
return raw.replace(/(?<=[,:{[\s]\s*)'((?:[^'\\]|\\.)*)'/g, (_match, inner) => `"${inner.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`);
|
|
75
|
+
}
|
|
76
|
+
function extractTextualToolCalls(content, allowedToolNames) {
|
|
77
|
+
const calls = [];
|
|
78
|
+
const seen = new Set();
|
|
79
|
+
for (const candidate of collectJsonCandidates(content)) {
|
|
80
|
+
if (!/^[\[{]/.test(candidate))
|
|
81
|
+
continue;
|
|
82
|
+
for (const attempt of [candidate, repairLlmJson(candidate)]) {
|
|
83
|
+
try {
|
|
84
|
+
const parsed = JSON.parse(attempt);
|
|
85
|
+
const parsedCalls = collectStructuredToolCalls(parsed);
|
|
86
|
+
for (const call of parsedCalls) {
|
|
87
|
+
if (!allowedToolNames.has(call.name))
|
|
88
|
+
continue;
|
|
89
|
+
const sig = `${call.name}:${JSON.stringify(call.arguments || {})}`;
|
|
90
|
+
if (seen.has(sig))
|
|
91
|
+
continue;
|
|
92
|
+
seen.add(sig);
|
|
93
|
+
calls.push(call);
|
|
94
|
+
}
|
|
95
|
+
if (parsedCalls.length > 0)
|
|
96
|
+
break; // repair succeeded
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
/* invalid JSON fragment — try next attempt */
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return calls;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Detect when the LLM described what it wanted to do as text/bash blocks
|
|
107
|
+
* instead of actually calling tools.
|
|
108
|
+
*/
|
|
109
|
+
function isLikelyTextualToolAttempt(content) {
|
|
110
|
+
const text = content || "";
|
|
111
|
+
const hasShellBlock = /```(?:bash|sh|shell)\n/i.test(text);
|
|
112
|
+
const hasCommandLikeLines = /(^|\n)\s*(?:\$\s*)?(?:npm|pnpm|yarn|node|python|rg|grep|git|ls|cat|sed)\b/im.test(text);
|
|
113
|
+
const hasToolName = /\b(?:read_file|write_file|edit_file|search_codebase|terminal_run|spawn_subagents|web_search|fetch_page|browser_[a-z_]+)\b/i.test(text);
|
|
114
|
+
const hasIntentVerb = /\b(?:let me|i(?:'ll| will)|uzyje|użyję|uruchomie|uruchomię|wywolam|wywołam|call|invoke|run)\b/i.test(text);
|
|
115
|
+
// Also detect when the entire response is a raw tool-call JSON object written as text
|
|
116
|
+
// e.g. {"name": "http_request", "arguments": {...}}
|
|
117
|
+
const hasRawToolCallJson = /\{\s*"name"\s*:\s*"[a-z_]+"\s*,\s*"arguments"\s*:\s*\{/i.test(text);
|
|
118
|
+
return hasShellBlock || hasCommandLikeLines || hasRawToolCallJson || (hasToolName && hasIntentVerb);
|
|
119
|
+
}
|
|
120
|
+
// ─────────────────────────────────────────────────────────────
|
|
121
|
+
// Read-only vs action tool classification (for stall detection)
|
|
122
|
+
// ─────────────────────────────────────────────────────────────
|
|
123
|
+
const READ_ONLY_TOOLS = new Set([
|
|
124
|
+
"read_file", "list_directory", "list_dir", "search_files", "grep", "find_files",
|
|
125
|
+
"git_status", "git_diff", "search_codebase", "knowledge_search", "knowledge_read",
|
|
126
|
+
"knowledge_list", "search_plan", "read_plan_section", "search_tasks", "web_search",
|
|
127
|
+
"fetch_page", "browser_get_text", "browser_screenshot", "browser_navigate",
|
|
128
|
+
"codebase_search", "codebase_status", "codebase_graph_query", "codebase_graph_visualize",
|
|
129
|
+
"codebase_graph_circular", "codebase_graph_stats", "codebase_impact", "codebase_flow",
|
|
130
|
+
"codebase_knowledge", "codebase_crossref", "neural_explain", "neural_suggest",
|
|
131
|
+
"neural_review", "neural_debug", "neural_security", "neural_smells", "neural_deadcode",
|
|
132
|
+
"neural_similar", "neural_pattern", "neural_optimize", "quality_complexity",
|
|
133
|
+
"quality_coupling", "quality_coverage", "quality_deps", "quality_duplication",
|
|
134
|
+
"quality_size", "quality_types", "doc_check_links", "doc_check_coverage",
|
|
135
|
+
"db_diagram", "db_index_suggest", "deploy_check", "env_check",
|
|
136
|
+
"memory_recall", "memory_context", "memory_lessons", "memory_patterns",
|
|
137
|
+
"pm_estimate", "pm_risks", "pm_progress", "analyze_project", "project_context",
|
|
138
|
+
"codebase_research", "project_scanner", "safe_edit_policy",
|
|
139
|
+
]);
|
|
140
|
+
const ACTION_TOOLS = new Set([
|
|
141
|
+
"write_file", "edit_file", "terminal_run", "knowledge_write", "knowledge_update",
|
|
142
|
+
"container_restart", "app_start", "app_stop"
|
|
143
|
+
]);
|
|
144
|
+
/**
|
|
145
|
+
* Number of duplicate identical tool invocations (same name + args) before
|
|
146
|
+
* the runner injects a doom-loop warning into the conversation history.
|
|
147
|
+
* This escalates beyond the passive [DUPLICATE CALL] prefix in tool results.
|
|
148
|
+
*/
|
|
149
|
+
const DOOM_LOOP_THRESHOLD = 3;
|
|
150
|
+
/** Hard safety limit for iterations per turn — prevents infinite loops when no budget is set. */
|
|
151
|
+
const DEFAULT_MAX_ITERATIONS = 20;
|
|
152
|
+
/** After this many consecutive read-only calls, inject a termination hint to push the model to produce output. */
|
|
153
|
+
const TERMINATION_HINT_AFTER = 6;
|
|
154
|
+
/** Absolute maximum consecutive read-only calls before forced termination. */
|
|
155
|
+
const MAX_CONSECUTIVE_READ_ONLY = 12;
|
|
156
|
+
class ConversationRunner {
|
|
157
|
+
deps;
|
|
158
|
+
log;
|
|
159
|
+
pendingInterrupt = null;
|
|
160
|
+
constructor(deps) {
|
|
161
|
+
this.deps = deps;
|
|
162
|
+
this.log = deps.logger ?? debug_logger_class_1.DebugLogger.NOOP;
|
|
163
|
+
}
|
|
164
|
+
hasPendingInterrupt() {
|
|
165
|
+
return this.pendingInterrupt !== null;
|
|
166
|
+
}
|
|
167
|
+
getPendingInterruptSnapshot() {
|
|
168
|
+
if (!this.pendingInterrupt)
|
|
169
|
+
return null;
|
|
170
|
+
return this.toPendingInterruptSnapshot(this.pendingInterrupt);
|
|
171
|
+
}
|
|
172
|
+
restorePendingInterrupt(snapshot) {
|
|
173
|
+
if (!snapshot) {
|
|
174
|
+
this.pendingInterrupt = null;
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const interruptToolCalls = snapshot.interruptTools
|
|
178
|
+
.map((item) => {
|
|
179
|
+
const toolCall = snapshot.toolCalls[item.index];
|
|
180
|
+
if (!toolCall)
|
|
181
|
+
return null;
|
|
182
|
+
return {
|
|
183
|
+
index: item.index,
|
|
184
|
+
toolCall: {
|
|
185
|
+
name: toolCall.name,
|
|
186
|
+
arguments: { ...(toolCall.args ?? {}) }
|
|
187
|
+
},
|
|
188
|
+
config: {
|
|
189
|
+
allowedDecisions: [...item.config.allowedDecisions],
|
|
190
|
+
description: item.config.description
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
})
|
|
194
|
+
.filter((value) => value !== null);
|
|
195
|
+
this.pendingInterrupt = {
|
|
196
|
+
interrupt: this.cloneInterrupt(snapshot.interrupt),
|
|
197
|
+
toolCalls: snapshot.toolCalls.map((toolCall) => ({
|
|
198
|
+
name: toolCall.name,
|
|
199
|
+
arguments: { ...(toolCall.args ?? {}) }
|
|
200
|
+
})),
|
|
201
|
+
interruptToolCalls
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
getPendingInterrupt() {
|
|
205
|
+
return this.pendingInterrupt ? this.cloneInterrupt(this.pendingInterrupt.interrupt) : null;
|
|
206
|
+
}
|
|
207
|
+
async runTurn(builtPrompt, options) {
|
|
208
|
+
const toolExecutions = [];
|
|
209
|
+
let totalTokensIn = 0;
|
|
210
|
+
let totalTokensOut = 0;
|
|
211
|
+
let lastThinking;
|
|
212
|
+
let iterationsUsed = 0;
|
|
213
|
+
let stopReason = "completed";
|
|
214
|
+
let runtimeMetadata = this.normalizeRuntimeMetadata(options?.metadata);
|
|
215
|
+
// Stall detection state
|
|
216
|
+
const STALL_LIMIT = 14;
|
|
217
|
+
let consecutiveReadOnly = 0;
|
|
218
|
+
const recentSignatures = [];
|
|
219
|
+
const uniqueSignatures = new Set();
|
|
220
|
+
// Doom-loop tracking: counts duplicate invocations per exact signature.
|
|
221
|
+
const doomLoopCounts = new Map();
|
|
222
|
+
const allToolNames = new Set(this.deps.toolRegistry.getLlmToolSpecs().map((t) => t.name));
|
|
223
|
+
const maxIterations = this.normalizeMaxIterations(options?.maxIterations) ?? DEFAULT_MAX_ITERATIONS;
|
|
224
|
+
const toolCallBudget = this.createToolCallBudget(options?.maxToolCalls, options?.maxToolCallsPerTool);
|
|
225
|
+
if (this.pendingInterrupt) {
|
|
226
|
+
throw new Error("Conversation is interrupted and waiting for decisions. Call resume() before sendPrompt().");
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
230
|
+
this.deps.eventsBus.pushAgentUpdate("run_start", {
|
|
231
|
+
phase: "turn",
|
|
232
|
+
model: this.deps.getModel(),
|
|
233
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
234
|
+
});
|
|
235
|
+
this.throwIfAborted(options?.signal);
|
|
236
|
+
this.log.info("runner", `start model=${this.deps.getModel()} tools=[${[...allToolNames].join(",")}]`);
|
|
237
|
+
// Only add system message if one doesn't already exist in history.
|
|
238
|
+
// runTurn is called once per sendPrompt() — system message must appear
|
|
239
|
+
// exactly once at position 0, otherwise vLLM rejects with
|
|
240
|
+
// "System message must be at the beginning."
|
|
241
|
+
const existingSystem = this.deps.history.snapshot().find(m => m.role === "system");
|
|
242
|
+
if (!existingSystem) {
|
|
243
|
+
const systemMessage = this.deps.history.unshift("system", builtPrompt.systemPrompt, {
|
|
244
|
+
turn: "system",
|
|
245
|
+
...(options?.metadata ?? {})
|
|
246
|
+
});
|
|
247
|
+
this.deps.eventsBus.pushMessage(systemMessage);
|
|
248
|
+
}
|
|
249
|
+
const userMessage = this.deps.history.push("user", builtPrompt.userPrompt, {
|
|
250
|
+
turn: "user",
|
|
251
|
+
...(options?.metadata ?? {})
|
|
252
|
+
});
|
|
253
|
+
this.deps.eventsBus.pushMessage(userMessage);
|
|
254
|
+
let finalOutput = "";
|
|
255
|
+
while (true) {
|
|
256
|
+
this.throwIfAborted(options?.signal);
|
|
257
|
+
if (maxIterations !== undefined && iterationsUsed >= maxIterations) {
|
|
258
|
+
stopReason = "max-iterations";
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
const currentIteration = iterationsUsed + 1;
|
|
262
|
+
this.deps.eventsBus.pushAgentUpdate("iteration_start", {
|
|
263
|
+
phase: "turn",
|
|
264
|
+
iteration: currentIteration,
|
|
265
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
266
|
+
});
|
|
267
|
+
this.log.info("runner", `iteration ${currentIteration}`);
|
|
268
|
+
const allowedToolSpecs = await this.resolveAllowedToolSpecs("turn", currentIteration, runtimeMetadata, builtPrompt.userPrompt);
|
|
269
|
+
const allowedToolNames = new Set(allowedToolSpecs.map((tool) => tool.name));
|
|
270
|
+
const selectedModel = this.resolveModelForIteration("turn", currentIteration);
|
|
271
|
+
await this.deps.beforeModelHook?.({
|
|
272
|
+
phase: "turn",
|
|
273
|
+
iteration: currentIteration,
|
|
274
|
+
model: selectedModel,
|
|
275
|
+
messages: this.deps.history.snapshot(),
|
|
276
|
+
metadata: { ...runtimeMetadata },
|
|
277
|
+
});
|
|
278
|
+
const shouldStream = options?.stream !== false;
|
|
279
|
+
const requestBase = {
|
|
280
|
+
model: selectedModel,
|
|
281
|
+
messages: this.deps.contextWindowManager
|
|
282
|
+
? this.deps.contextWindowManager.trim(this.deps.history.snapshotWithResolvedPayloads())
|
|
283
|
+
: this.deps.history.snapshotWithResolvedPayloads(),
|
|
284
|
+
tools: allowedToolSpecs,
|
|
285
|
+
signal: options?.signal,
|
|
286
|
+
thinking: this.deps.thinking,
|
|
287
|
+
temperature: this.deps.temperature,
|
|
288
|
+
numCtx: this.deps.numCtx,
|
|
289
|
+
seed: this.deps.seed,
|
|
290
|
+
};
|
|
291
|
+
const response = shouldStream
|
|
292
|
+
? await this.deps.llmAdapter.streamChat(requestBase, (chunk) => this.deps.eventsBus.pushStreamChunk({
|
|
293
|
+
...chunk,
|
|
294
|
+
metadata: {
|
|
295
|
+
...(chunk.metadata ?? {}),
|
|
296
|
+
phase: "turn",
|
|
297
|
+
iteration: currentIteration,
|
|
298
|
+
node: "model",
|
|
299
|
+
model: selectedModel,
|
|
300
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
301
|
+
},
|
|
302
|
+
}))
|
|
303
|
+
: await this.deps.llmAdapter.chat(requestBase);
|
|
304
|
+
iterationsUsed++;
|
|
305
|
+
await this.deps.afterModelHook?.({
|
|
306
|
+
phase: "turn",
|
|
307
|
+
iteration: iterationsUsed,
|
|
308
|
+
model: selectedModel,
|
|
309
|
+
messages: this.deps.history.snapshot(),
|
|
310
|
+
metadata: { ...runtimeMetadata },
|
|
311
|
+
response: response.message,
|
|
312
|
+
});
|
|
313
|
+
totalTokensIn += response.tokensInput ?? 0;
|
|
314
|
+
totalTokensOut += response.tokensOutput ?? 0;
|
|
315
|
+
if (response.message?.thinking)
|
|
316
|
+
lastThinking = response.message.thinking;
|
|
317
|
+
this.deps.eventsBus.pushAgentUpdate("model_response", {
|
|
318
|
+
phase: "turn",
|
|
319
|
+
iteration: iterationsUsed,
|
|
320
|
+
model: selectedModel,
|
|
321
|
+
toolCalls: response.message?.toolCalls?.length ?? 0,
|
|
322
|
+
tokensInput: response.tokensInput ?? 0,
|
|
323
|
+
tokensOutput: response.tokensOutput ?? 0,
|
|
324
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
325
|
+
});
|
|
326
|
+
finalOutput = response.message?.content ?? "";
|
|
327
|
+
this.log.verbose("runner", `llm response tokIn=${response.tokensInput ?? 0} tokOut=${response.tokensOutput ?? 0} toolCalls=${response.message?.toolCalls?.length ?? 0} contentLen=${finalOutput.length}`);
|
|
328
|
+
if (finalOutput.length > 0)
|
|
329
|
+
this.log.verbose("runner", `llm text: ${finalOutput.slice(0, 200)}${finalOutput.length > 200 ? "…" : ""}`);
|
|
330
|
+
// Empty response guard — model returned nothing (no content, no reasoning, no tools).
|
|
331
|
+
// Retry the iteration instead of completing with empty output.
|
|
332
|
+
if (!finalOutput && !response.message?.thinking && !response.message?.reasoningContent &&
|
|
333
|
+
(!response.message?.toolCalls || response.message.toolCalls.length === 0)) {
|
|
334
|
+
this.log.info("runner", `empty LLM response — retrying iteration ${currentIteration}`);
|
|
335
|
+
this.deps.eventsBus.pushAgentUpdate("model_response", {
|
|
336
|
+
phase: "turn", iteration: currentIteration, model: selectedModel, toolCalls: 0,
|
|
337
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
338
|
+
});
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const assistantMessage = this.deps.history.pushAssistant(finalOutput, response.message?.toolCalls, response.message?.reasoningContent);
|
|
342
|
+
this.deps.eventsBus.pushMessage(assistantMessage);
|
|
343
|
+
if (!response.message?.toolCalls || response.message.toolCalls.length === 0) {
|
|
344
|
+
// ─── Textual tool-call recovery ───────────────────────────
|
|
345
|
+
// LLM sometimes forgets it has function calling and writes JSON/bash as text.
|
|
346
|
+
const textualCalls = extractTextualToolCalls(finalOutput, allowedToolNames);
|
|
347
|
+
if (textualCalls.length > 0) {
|
|
348
|
+
for (const tc of textualCalls) {
|
|
349
|
+
if (!this.consumeToolCallBudget(toolCallBudget, tc.name)) {
|
|
350
|
+
stopReason = "max-tool-calls";
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
const result = await this.executeTool(tc.name, tc.arguments, toolExecutions, options, runtimeMetadata);
|
|
354
|
+
const commandResult = this.applyToolCommand(result.command, runtimeMetadata);
|
|
355
|
+
runtimeMetadata = commandResult.metadata;
|
|
356
|
+
this.trackStallSignals(tc.name, tc.arguments, uniqueSignatures, recentSignatures);
|
|
357
|
+
if (READ_ONLY_TOOLS.has(tc.name))
|
|
358
|
+
consecutiveReadOnly++;
|
|
359
|
+
else if (ACTION_TOOLS.has(tc.name)) {
|
|
360
|
+
consecutiveReadOnly = 0;
|
|
361
|
+
recentSignatures.length = 0;
|
|
362
|
+
}
|
|
363
|
+
const toolOutput = result.success ? result.output ?? "" : `ERROR: ${result.error ?? "Unknown error"}`;
|
|
364
|
+
const toolMsg = this.deps.history.pushToolResult(tc.name, toolOutput, "call_textual_" + Date.now() + "_" + Math.random().toString(36).slice(2, 6));
|
|
365
|
+
this.deps.eventsBus.pushMessage(toolMsg);
|
|
366
|
+
if (commandResult.goto === "end_turn") {
|
|
367
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
368
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
369
|
+
return {
|
|
370
|
+
output: commandResult.outputOverride ?? finalOutput,
|
|
371
|
+
thinking: lastThinking,
|
|
372
|
+
stopReason: "completed",
|
|
373
|
+
status: this.deps.statusMachine.current,
|
|
374
|
+
messages: this.deps.history.snapshot(),
|
|
375
|
+
toolExecutions,
|
|
376
|
+
tokensInput: totalTokensIn,
|
|
377
|
+
tokensOutput: totalTokensOut,
|
|
378
|
+
iterationsUsed
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
if (commandResult.goto === "next_iteration") {
|
|
382
|
+
break;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
if (stopReason !== "completed")
|
|
386
|
+
break;
|
|
387
|
+
if (options?.signal?.aborted)
|
|
388
|
+
break;
|
|
389
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
390
|
+
const stallResult = this.checkStall(consecutiveReadOnly, recentSignatures, STALL_LIMIT, uniqueSignatures);
|
|
391
|
+
if (stallResult) {
|
|
392
|
+
stopReason = stallResult;
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
// LLM tried to call tools as text but JSON was not parseable
|
|
398
|
+
const looksLikeToolAttempt = isLikelyTextualToolAttempt(finalOutput);
|
|
399
|
+
const recoveryCount = this.deps.history.snapshot().filter((m) => m.role === "user" && m.content.startsWith("⚠️ Tool-calling reminder")).length;
|
|
400
|
+
if (looksLikeToolAttempt && recoveryCount < 2) {
|
|
401
|
+
const recoveryMsg = this.deps.history.push("user", "⚠️ Tool-calling reminder: You wrote commands as text but did NOT call any tools. " +
|
|
402
|
+
"You MUST use the tool-calling API (function call mechanism) to read files, write files, and run commands. " +
|
|
403
|
+
"Do NOT write bash code blocks — actually CALL the tools. Available tools: " +
|
|
404
|
+
[...allowedToolNames].join(", ") +
|
|
405
|
+
". Please proceed by calling the appropriate tool now.");
|
|
406
|
+
this.deps.eventsBus.pushMessage(recoveryMsg);
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
// Genuinely finished — no more tool calls
|
|
410
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
411
|
+
stopReason = "completed";
|
|
412
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
413
|
+
this.deps.eventsBus.pushAgentUpdate("run_complete", {
|
|
414
|
+
phase: "turn",
|
|
415
|
+
stopReason: "completed",
|
|
416
|
+
iterations: iterationsUsed,
|
|
417
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
418
|
+
});
|
|
419
|
+
this.log.info("runner", `done stopReason=completed iterations=${iterationsUsed} tokIn=${totalTokensIn} tokOut=${totalTokensOut}`);
|
|
420
|
+
return {
|
|
421
|
+
output: finalOutput,
|
|
422
|
+
thinking: lastThinking,
|
|
423
|
+
stopReason,
|
|
424
|
+
status: this.deps.statusMachine.current,
|
|
425
|
+
messages: this.deps.history.snapshot(),
|
|
426
|
+
toolExecutions,
|
|
427
|
+
tokensInput: totalTokensIn,
|
|
428
|
+
tokensOutput: totalTokensOut,
|
|
429
|
+
iterationsUsed
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
// ─── Process native tool calls ─────────────────────────────
|
|
433
|
+
const filteredToolCalls = this.filterBlockedToolCalls(response.message?.toolCalls ?? [], {
|
|
434
|
+
phase: "turn",
|
|
435
|
+
iteration: iterationsUsed,
|
|
436
|
+
metadata: runtimeMetadata,
|
|
437
|
+
}, toolExecutions);
|
|
438
|
+
if (filteredToolCalls.length === 0) {
|
|
439
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
440
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const pendingInterrupt = this.buildPendingInterrupt(filteredToolCalls);
|
|
444
|
+
if (pendingInterrupt) {
|
|
445
|
+
this.pendingInterrupt = pendingInterrupt;
|
|
446
|
+
stopReason = "interrupted";
|
|
447
|
+
this.transition(contracts_1.ConversationStatus.INTERRUPTED);
|
|
448
|
+
this.deps.eventsBus.pushInterrupt(pendingInterrupt.interrupt);
|
|
449
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
450
|
+
this.log.info("runner", `interrupted actions=${pendingInterrupt.interrupt.request.actionRequests.length}`);
|
|
451
|
+
return {
|
|
452
|
+
output: finalOutput,
|
|
453
|
+
thinking: lastThinking,
|
|
454
|
+
stopReason,
|
|
455
|
+
status: this.deps.statusMachine.current,
|
|
456
|
+
messages: this.deps.history.snapshot(),
|
|
457
|
+
toolExecutions,
|
|
458
|
+
interrupt: this.cloneInterrupt(pendingInterrupt.interrupt),
|
|
459
|
+
tokensInput: totalTokensIn,
|
|
460
|
+
tokensOutput: totalTokensOut,
|
|
461
|
+
iterationsUsed
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
this.transition(contracts_1.ConversationStatus.WAITING_TOOL);
|
|
465
|
+
for (let _tcIdx = 0; _tcIdx < filteredToolCalls.length; _tcIdx++) {
|
|
466
|
+
const toolCall = filteredToolCalls[_tcIdx];
|
|
467
|
+
this.throwIfAborted(options?.signal);
|
|
468
|
+
if (!this.consumeToolCallBudget(toolCallBudget, toolCall.name)) {
|
|
469
|
+
stopReason = "max-tool-calls";
|
|
470
|
+
for (let _skipIdx = _tcIdx; _skipIdx < filteredToolCalls.length; _skipIdx++) {
|
|
471
|
+
const _skipped = filteredToolCalls[_skipIdx];
|
|
472
|
+
const _skipMsg = this.deps.history.pushToolResult(_skipped.name, `\u26a0\ufe0f Tool call skipped: tool call budget exhausted.`, _skipped.id ?? `call_skip_${Date.now()}_${_skipIdx}`);
|
|
473
|
+
this.deps.eventsBus.pushMessage(_skipMsg);
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
this.log.info("tool", `call ${toolCall.name}`);
|
|
478
|
+
this.log.verbose("tool", `args ${toolCall.name}`, toolCall.arguments);
|
|
479
|
+
const signature = `${toolCall.name}:${JSON.stringify(toolCall.arguments ?? {})}`;
|
|
480
|
+
const isDuplicate = uniqueSignatures.has(signature);
|
|
481
|
+
this.trackStallSignals(toolCall.name, toolCall.arguments, uniqueSignatures, recentSignatures);
|
|
482
|
+
if (ACTION_TOOLS.has(toolCall.name)) {
|
|
483
|
+
consecutiveReadOnly = 0;
|
|
484
|
+
recentSignatures.length = 0;
|
|
485
|
+
}
|
|
486
|
+
else if (READ_ONLY_TOOLS.has(toolCall.name)) {
|
|
487
|
+
consecutiveReadOnly++;
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
consecutiveReadOnly = 0; // unknown tools count as activity
|
|
491
|
+
}
|
|
492
|
+
const stallResult = this.checkStall(consecutiveReadOnly, recentSignatures, STALL_LIMIT, uniqueSignatures);
|
|
493
|
+
if (stallResult) {
|
|
494
|
+
stopReason = stallResult;
|
|
495
|
+
for (let _skipIdx = _tcIdx; _skipIdx < filteredToolCalls.length; _skipIdx++) {
|
|
496
|
+
const _skipped = filteredToolCalls[_skipIdx];
|
|
497
|
+
const _skipMsg = this.deps.history.pushToolResult(_skipped.name, `\u26a0\ufe0f Tool call skipped: ${stallResult === "stall" ? "stall detected after too many consecutive read-only tool calls" : "repetition detected after repeated identical tool calls"}.`, _skipped.id ?? `call_skip_${Date.now()}_${_skipIdx}`);
|
|
498
|
+
this.deps.eventsBus.pushMessage(_skipMsg);
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
const execution = await this.executeToolWithRetry(toolCall.name, toolCall.arguments ?? {}, options, runtimeMetadata);
|
|
503
|
+
this.deps.eventsBus.pushToolEvent(execution.startedTrace);
|
|
504
|
+
this.deps.eventsBus.pushToolEvent(execution.trace);
|
|
505
|
+
toolExecutions.push(execution.trace);
|
|
506
|
+
this.log.info("tool", `result ${toolCall.name} ${execution.result.success ? "OK" : "ERROR"}`);
|
|
507
|
+
this.log.verbose("tool", `output ${toolCall.name}`, (execution.result.output ?? execution.result.error ?? "").slice(0, 300));
|
|
508
|
+
const duplicatePrefix = isDuplicate
|
|
509
|
+
? `[DUPLICATE CALL: you already called '${toolCall.name}' with these exact arguments. Below is the same result. Stop repeating this call.]\n\n`
|
|
510
|
+
: "";
|
|
511
|
+
const toolOutput = execution.result.success
|
|
512
|
+
? duplicatePrefix + (execution.result.output ?? "")
|
|
513
|
+
: `ERROR: ${execution.result.error ?? "Unknown tool error"}`;
|
|
514
|
+
const toolMessage = this.deps.history.pushToolResult(toolCall.name, toolOutput, toolCall.id ?? execution.trace.id);
|
|
515
|
+
this.deps.eventsBus.pushMessage(toolMessage);
|
|
516
|
+
if (this.injectTerminationHint(consecutiveReadOnly)) {
|
|
517
|
+
stopReason = "stall";
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
// Doom-loop injection: escalate after repeated identical calls.
|
|
521
|
+
if (isDuplicate) {
|
|
522
|
+
const doomCount = (doomLoopCounts.get(signature) ?? 0) + 1;
|
|
523
|
+
doomLoopCounts.set(signature, doomCount);
|
|
524
|
+
if (doomCount >= DOOM_LOOP_THRESHOLD) {
|
|
525
|
+
this.log.info("runner", `doom-loop ${toolCall.name} count=${doomCount + 1}`);
|
|
526
|
+
const doomMsg = this.deps.history.push("user", `⚠️ Doom-loop warning: You have called '${toolCall.name}' with identical arguments ${doomCount + 1} times. ` +
|
|
527
|
+
`This call cannot produce a different result. You MUST break this loop now: ` +
|
|
528
|
+
`try a different tool, a different approach, or conclude and summarize your findings.`);
|
|
529
|
+
this.deps.eventsBus.pushMessage(doomMsg);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const commandResult = this.applyToolCommand(execution.result.command, runtimeMetadata);
|
|
533
|
+
runtimeMetadata = commandResult.metadata;
|
|
534
|
+
if (commandResult.goto === "end_turn") {
|
|
535
|
+
this.ensureToolResultsForBatch(filteredToolCalls, "turn ended by tool command");
|
|
536
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
537
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
538
|
+
return {
|
|
539
|
+
output: commandResult.outputOverride ?? finalOutput,
|
|
540
|
+
thinking: lastThinking,
|
|
541
|
+
stopReason: "completed",
|
|
542
|
+
status: this.deps.statusMachine.current,
|
|
543
|
+
messages: this.deps.history.snapshot(),
|
|
544
|
+
toolExecutions,
|
|
545
|
+
tokensInput: totalTokensIn,
|
|
546
|
+
tokensOutput: totalTokensOut,
|
|
547
|
+
iterationsUsed
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
if (commandResult.goto === "next_iteration") {
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
// ── Placeholder results for unmatched tool calls (DeepSeek compat) ─
|
|
555
|
+
if (stopReason && stopReason !== "completed") {
|
|
556
|
+
this.ensureToolResultsForBatch(filteredToolCalls, "execution terminated early");
|
|
557
|
+
}
|
|
558
|
+
if (stopReason !== "completed") {
|
|
559
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
// Persist message history snapshot after each tool-call round-trip
|
|
563
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
564
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
565
|
+
}
|
|
566
|
+
// Fell out of the while loop due to stall/repetition/abort
|
|
567
|
+
if (stopReason === "aborted" || options?.signal?.aborted) {
|
|
568
|
+
stopReason = "aborted";
|
|
569
|
+
this.transition(contracts_1.ConversationStatus.CANCELLED);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
573
|
+
}
|
|
574
|
+
this.deps.eventsBus.pushAgentUpdate("run_complete", {
|
|
575
|
+
phase: "turn",
|
|
576
|
+
stopReason,
|
|
577
|
+
iterations: iterationsUsed,
|
|
578
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
579
|
+
});
|
|
580
|
+
this.log.info("runner", `done stopReason=${stopReason} iterations=${iterationsUsed} tokIn=${totalTokensIn} tokOut=${totalTokensOut}`);
|
|
581
|
+
return {
|
|
582
|
+
output: finalOutput,
|
|
583
|
+
thinking: lastThinking,
|
|
584
|
+
stopReason,
|
|
585
|
+
status: this.deps.statusMachine.current,
|
|
586
|
+
messages: this.deps.history.snapshot(),
|
|
587
|
+
toolExecutions,
|
|
588
|
+
tokensInput: totalTokensIn,
|
|
589
|
+
tokensOutput: totalTokensOut,
|
|
590
|
+
iterationsUsed
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
this.restorePendingInterrupt(null);
|
|
595
|
+
if (this.isAbortError(error)) {
|
|
596
|
+
this.log.info("runner", "aborted");
|
|
597
|
+
this.transition(contracts_1.ConversationStatus.CANCELLED);
|
|
598
|
+
return {
|
|
599
|
+
output: "",
|
|
600
|
+
thinking: lastThinking,
|
|
601
|
+
stopReason: "aborted",
|
|
602
|
+
status: this.deps.statusMachine.current,
|
|
603
|
+
messages: this.deps.history.snapshot(),
|
|
604
|
+
toolExecutions,
|
|
605
|
+
tokensInput: totalTokensIn,
|
|
606
|
+
tokensOutput: totalTokensOut,
|
|
607
|
+
iterationsUsed
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
const err = error instanceof Error ? error : new Error("Unknown conversation error");
|
|
611
|
+
this.log.info("runner", `error: ${err.message}`);
|
|
612
|
+
this.transition(contracts_1.ConversationStatus.FAILED);
|
|
613
|
+
this.deps.eventsBus.pushError(err);
|
|
614
|
+
throw err;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
async resumeTurn(response, options) {
|
|
618
|
+
const pending = this.pendingInterrupt;
|
|
619
|
+
if (!pending) {
|
|
620
|
+
throw new Error("No pending interrupt to resume.");
|
|
621
|
+
}
|
|
622
|
+
const toolExecutions = [];
|
|
623
|
+
let totalTokensIn = 0;
|
|
624
|
+
let totalTokensOut = 0;
|
|
625
|
+
let lastThinking;
|
|
626
|
+
let iterationsUsed = 0;
|
|
627
|
+
let stopReason = "completed";
|
|
628
|
+
let runtimeMetadata = this.normalizeRuntimeMetadata(options?.metadata);
|
|
629
|
+
const STALL_LIMIT = 14;
|
|
630
|
+
let consecutiveReadOnly = 0;
|
|
631
|
+
const recentSignatures = [];
|
|
632
|
+
const uniqueSignatures = new Set();
|
|
633
|
+
// Doom-loop tracking: counts duplicate invocations per exact signature.
|
|
634
|
+
const doomLoopCounts = new Map();
|
|
635
|
+
const maxIterations = this.normalizeMaxIterations(options?.maxIterations) ?? DEFAULT_MAX_ITERATIONS;
|
|
636
|
+
const toolCallBudget = this.createToolCallBudget(options?.maxToolCalls, options?.maxToolCallsPerTool);
|
|
637
|
+
try {
|
|
638
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
639
|
+
this.deps.eventsBus.pushAgentUpdate("run_start", {
|
|
640
|
+
phase: "resume",
|
|
641
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
642
|
+
});
|
|
643
|
+
this.throwIfAborted(options?.signal);
|
|
644
|
+
const resolvedResponse = this.resolveResumeResponse(response, pending);
|
|
645
|
+
const decisionResult = this.applyInterruptDecisions(resolvedResponse, pending);
|
|
646
|
+
this.deps.eventsBus.pushInterruptResolved(pending.interrupt.id, resolvedResponse.decisions);
|
|
647
|
+
this.pendingInterrupt = null;
|
|
648
|
+
if (decisionResult.hasRejectedToolCalls) {
|
|
649
|
+
for (const message of decisionResult.artificialToolMessages) {
|
|
650
|
+
const toolMessage = this.deps.history.pushToolResult(message.toolName, message.content, message.toolCallId ?? `call_rejected_${Date.now()}`);
|
|
651
|
+
this.deps.eventsBus.pushMessage(toolMessage);
|
|
652
|
+
}
|
|
653
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
this.transition(contracts_1.ConversationStatus.WAITING_TOOL);
|
|
657
|
+
for (const toolCall of decisionResult.revisedToolCalls) {
|
|
658
|
+
this.throwIfAborted(options?.signal);
|
|
659
|
+
if (!this.consumeToolCallBudget(toolCallBudget, toolCall.name)) {
|
|
660
|
+
stopReason = "max-tool-calls";
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
if (!this.isToolAllowed("resume", 0, toolCall.name, runtimeMetadata)) {
|
|
664
|
+
const skipped = this.createSkippedToolTrace(toolCall.name, toolCall.arguments, "Tool blocked by dynamic toolFilter.");
|
|
665
|
+
this.deps.eventsBus.pushToolEvent(skipped);
|
|
666
|
+
toolExecutions.push(skipped);
|
|
667
|
+
const blockedMessage = this.deps.history.pushToolResult(toolCall.name, `ERROR: Tool '${toolCall.name}' is blocked by toolFilter for phase 'resume'.`, toolCall.id ?? `call_blocked_${Date.now()}`);
|
|
668
|
+
this.deps.eventsBus.pushMessage(blockedMessage);
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
this.log.info("tool", `call ${toolCall.name}`);
|
|
672
|
+
this.log.verbose("tool", `args ${toolCall.name}`, toolCall.arguments);
|
|
673
|
+
const signature = `${toolCall.name}:${JSON.stringify(toolCall.arguments ?? {})}`;
|
|
674
|
+
const isDuplicate = uniqueSignatures.has(signature);
|
|
675
|
+
this.trackStallSignals(toolCall.name, toolCall.arguments, uniqueSignatures, recentSignatures);
|
|
676
|
+
if (ACTION_TOOLS.has(toolCall.name)) {
|
|
677
|
+
consecutiveReadOnly = 0;
|
|
678
|
+
recentSignatures.length = 0;
|
|
679
|
+
}
|
|
680
|
+
else if (READ_ONLY_TOOLS.has(toolCall.name)) {
|
|
681
|
+
consecutiveReadOnly++;
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
consecutiveReadOnly = 0;
|
|
685
|
+
}
|
|
686
|
+
const stallResult = this.checkStall(consecutiveReadOnly, recentSignatures, STALL_LIMIT, uniqueSignatures);
|
|
687
|
+
if (stallResult) {
|
|
688
|
+
stopReason = stallResult;
|
|
689
|
+
break;
|
|
690
|
+
}
|
|
691
|
+
const execution = await this.executeToolWithRetry(toolCall.name, toolCall.arguments ?? {}, options, runtimeMetadata);
|
|
692
|
+
this.deps.eventsBus.pushToolEvent(execution.startedTrace);
|
|
693
|
+
this.deps.eventsBus.pushToolEvent(execution.trace);
|
|
694
|
+
toolExecutions.push(execution.trace);
|
|
695
|
+
const duplicatePrefix = isDuplicate
|
|
696
|
+
? `[DUPLICATE CALL: you already called '${toolCall.name}' with these exact arguments. Below is the same result. Stop repeating this call.]\n\n`
|
|
697
|
+
: "";
|
|
698
|
+
const toolOutput = execution.result.success
|
|
699
|
+
? duplicatePrefix + (execution.result.output ?? "")
|
|
700
|
+
: `ERROR: ${execution.result.error ?? "Unknown tool error"}`;
|
|
701
|
+
const toolMessage = this.deps.history.pushToolResult(toolCall.name, toolOutput, toolCall.id ?? execution.trace.id);
|
|
702
|
+
this.deps.eventsBus.pushMessage(toolMessage);
|
|
703
|
+
if (this.injectTerminationHint(consecutiveReadOnly)) {
|
|
704
|
+
stopReason = "stall";
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
const commandResult = this.applyToolCommand(execution.result.command, runtimeMetadata);
|
|
708
|
+
runtimeMetadata = commandResult.metadata;
|
|
709
|
+
if (commandResult.goto === "end_turn") {
|
|
710
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
711
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
712
|
+
return {
|
|
713
|
+
output: commandResult.outputOverride ?? "",
|
|
714
|
+
thinking: lastThinking,
|
|
715
|
+
stopReason: "completed",
|
|
716
|
+
status: this.deps.statusMachine.current,
|
|
717
|
+
messages: this.deps.history.snapshot(),
|
|
718
|
+
toolExecutions,
|
|
719
|
+
tokensInput: totalTokensIn,
|
|
720
|
+
tokensOutput: totalTokensOut,
|
|
721
|
+
iterationsUsed
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
if (commandResult.goto === "next_iteration") {
|
|
725
|
+
break;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
729
|
+
if (stopReason === "completed") {
|
|
730
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
let finalOutput = "";
|
|
734
|
+
while (stopReason === "completed") {
|
|
735
|
+
this.throwIfAborted(options?.signal);
|
|
736
|
+
if (maxIterations !== undefined && iterationsUsed >= maxIterations) {
|
|
737
|
+
stopReason = "max-iterations";
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
const currentIteration = iterationsUsed + 1;
|
|
741
|
+
this.deps.eventsBus.pushAgentUpdate("iteration_start", {
|
|
742
|
+
phase: "resume",
|
|
743
|
+
iteration: currentIteration,
|
|
744
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
745
|
+
});
|
|
746
|
+
const userMsg = this.deps.history.snapshot().find((m) => m.role === "user");
|
|
747
|
+
const allowedToolSpecs = await this.resolveAllowedToolSpecs("resume", currentIteration, runtimeMetadata, userMsg?.content);
|
|
748
|
+
const allowedToolNames = new Set(allowedToolSpecs.map((tool) => tool.name));
|
|
749
|
+
const selectedModel = this.resolveModelForIteration("resume", currentIteration);
|
|
750
|
+
await this.deps.beforeModelHook?.({
|
|
751
|
+
phase: "resume",
|
|
752
|
+
iteration: currentIteration,
|
|
753
|
+
model: selectedModel,
|
|
754
|
+
messages: this.deps.history.snapshot(),
|
|
755
|
+
metadata: { ...runtimeMetadata },
|
|
756
|
+
});
|
|
757
|
+
const responseChunk = await this.deps.llmAdapter.streamChat({
|
|
758
|
+
model: selectedModel,
|
|
759
|
+
messages: this.deps.contextWindowManager
|
|
760
|
+
? this.deps.contextWindowManager.trim(this.deps.history.snapshot())
|
|
761
|
+
: this.deps.history.snapshot(),
|
|
762
|
+
tools: allowedToolSpecs,
|
|
763
|
+
signal: options?.signal,
|
|
764
|
+
thinking: this.deps.thinking,
|
|
765
|
+
temperature: this.deps.temperature,
|
|
766
|
+
numCtx: this.deps.numCtx,
|
|
767
|
+
seed: this.deps.seed
|
|
768
|
+
}, (chunk) => this.deps.eventsBus.pushStreamChunk({
|
|
769
|
+
...chunk,
|
|
770
|
+
metadata: {
|
|
771
|
+
...(chunk.metadata ?? {}),
|
|
772
|
+
phase: "resume",
|
|
773
|
+
iteration: currentIteration,
|
|
774
|
+
node: "model",
|
|
775
|
+
model: selectedModel,
|
|
776
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
777
|
+
},
|
|
778
|
+
}));
|
|
779
|
+
iterationsUsed++;
|
|
780
|
+
await this.deps.afterModelHook?.({
|
|
781
|
+
phase: "resume",
|
|
782
|
+
iteration: iterationsUsed,
|
|
783
|
+
model: selectedModel,
|
|
784
|
+
messages: this.deps.history.snapshot(),
|
|
785
|
+
metadata: { ...runtimeMetadata },
|
|
786
|
+
response: responseChunk.message,
|
|
787
|
+
});
|
|
788
|
+
totalTokensIn += responseChunk.tokensInput ?? 0;
|
|
789
|
+
totalTokensOut += responseChunk.tokensOutput ?? 0;
|
|
790
|
+
if (responseChunk.message?.thinking)
|
|
791
|
+
lastThinking = responseChunk.message.thinking;
|
|
792
|
+
this.deps.eventsBus.pushAgentUpdate("model_response", {
|
|
793
|
+
phase: "resume",
|
|
794
|
+
iteration: iterationsUsed,
|
|
795
|
+
model: selectedModel,
|
|
796
|
+
toolCalls: responseChunk.message?.toolCalls?.length ?? 0,
|
|
797
|
+
tokensInput: responseChunk.tokensInput ?? 0,
|
|
798
|
+
tokensOutput: responseChunk.tokensOutput ?? 0,
|
|
799
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
800
|
+
});
|
|
801
|
+
finalOutput = responseChunk.message?.content ?? "";
|
|
802
|
+
const assistantMessage = this.deps.history.pushAssistant(finalOutput, responseChunk.message?.toolCalls, responseChunk.message?.reasoningContent);
|
|
803
|
+
this.deps.eventsBus.pushMessage(assistantMessage);
|
|
804
|
+
if (!responseChunk.message?.toolCalls || responseChunk.message.toolCalls.length === 0) {
|
|
805
|
+
const textualCalls = extractTextualToolCalls(finalOutput, allowedToolNames);
|
|
806
|
+
if (textualCalls.length > 0) {
|
|
807
|
+
for (const tc of textualCalls) {
|
|
808
|
+
if (!allowedToolNames.has(tc.name)) {
|
|
809
|
+
const skipped = this.createSkippedToolTrace(tc.name, tc.arguments, "Tool blocked by dynamic toolFilter.");
|
|
810
|
+
this.deps.eventsBus.pushToolEvent(skipped);
|
|
811
|
+
toolExecutions.push(skipped);
|
|
812
|
+
const blockedMessage = this.deps.history.pushToolResult(tc.name, `ERROR: Tool '${tc.name}' is blocked by toolFilter for phase 'resume'.`, `call_blocked_${Date.now()}_${Math.random().toString(36).slice(2, 6)}`);
|
|
813
|
+
this.deps.eventsBus.pushMessage(blockedMessage);
|
|
814
|
+
continue;
|
|
815
|
+
}
|
|
816
|
+
if (!this.consumeToolCallBudget(toolCallBudget, tc.name)) {
|
|
817
|
+
stopReason = "max-tool-calls";
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
const result = await this.executeTool(tc.name, tc.arguments, toolExecutions, options, runtimeMetadata);
|
|
821
|
+
const commandResult = this.applyToolCommand(result.command, runtimeMetadata);
|
|
822
|
+
runtimeMetadata = commandResult.metadata;
|
|
823
|
+
this.trackStallSignals(tc.name, tc.arguments, uniqueSignatures, recentSignatures);
|
|
824
|
+
if (READ_ONLY_TOOLS.has(tc.name))
|
|
825
|
+
consecutiveReadOnly++;
|
|
826
|
+
else if (ACTION_TOOLS.has(tc.name)) {
|
|
827
|
+
consecutiveReadOnly = 0;
|
|
828
|
+
recentSignatures.length = 0;
|
|
829
|
+
}
|
|
830
|
+
const toolOutput = result.success
|
|
831
|
+
? result.output ?? ""
|
|
832
|
+
: `ERROR: ${result.error ?? "Unknown error"}`;
|
|
833
|
+
const toolMsg = this.deps.history.pushToolResult(tc.name, toolOutput, "call_textual_" + Date.now() + "_" + Math.random().toString(36).slice(2, 6));
|
|
834
|
+
this.deps.eventsBus.pushMessage(toolMsg);
|
|
835
|
+
if (commandResult.goto === "end_turn") {
|
|
836
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
837
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
838
|
+
return {
|
|
839
|
+
output: commandResult.outputOverride ?? finalOutput,
|
|
840
|
+
thinking: lastThinking,
|
|
841
|
+
stopReason: "completed",
|
|
842
|
+
status: this.deps.statusMachine.current,
|
|
843
|
+
messages: this.deps.history.snapshot(),
|
|
844
|
+
toolExecutions,
|
|
845
|
+
tokensInput: totalTokensIn,
|
|
846
|
+
tokensOutput: totalTokensOut,
|
|
847
|
+
iterationsUsed
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
if (commandResult.goto === "next_iteration") {
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
if (stopReason !== "completed")
|
|
855
|
+
break;
|
|
856
|
+
if (options?.signal?.aborted)
|
|
857
|
+
break;
|
|
858
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
859
|
+
const stallResult = this.checkStall(consecutiveReadOnly, recentSignatures, STALL_LIMIT, uniqueSignatures);
|
|
860
|
+
if (stallResult) {
|
|
861
|
+
stopReason = stallResult;
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
const looksLikeToolAttempt = isLikelyTextualToolAttempt(finalOutput);
|
|
867
|
+
const recoveryCount = this.deps.history.snapshot().filter((m) => m.role === "user" && m.content.startsWith("⚠️ Tool-calling reminder")).length;
|
|
868
|
+
if (looksLikeToolAttempt && recoveryCount < 2) {
|
|
869
|
+
const recoveryMsg = this.deps.history.push("user", "⚠️ Tool-calling reminder: You wrote commands as text but did NOT call any tools. " +
|
|
870
|
+
"You MUST use the tool-calling API (function call mechanism) to read files, write files, and run commands. " +
|
|
871
|
+
"Do NOT write bash code blocks — actually CALL the tools. Available tools: " +
|
|
872
|
+
[...allowedToolNames].join(", ") +
|
|
873
|
+
". Please proceed by calling the appropriate tool now.");
|
|
874
|
+
this.deps.eventsBus.pushMessage(recoveryMsg);
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
878
|
+
stopReason = "completed";
|
|
879
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
880
|
+
this.deps.eventsBus.pushAgentUpdate("run_complete", {
|
|
881
|
+
phase: "resume",
|
|
882
|
+
stopReason: "completed",
|
|
883
|
+
iterations: iterationsUsed,
|
|
884
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
885
|
+
});
|
|
886
|
+
return {
|
|
887
|
+
output: finalOutput,
|
|
888
|
+
thinking: lastThinking,
|
|
889
|
+
stopReason,
|
|
890
|
+
status: this.deps.statusMachine.current,
|
|
891
|
+
messages: this.deps.history.snapshot(),
|
|
892
|
+
toolExecutions,
|
|
893
|
+
tokensInput: totalTokensIn,
|
|
894
|
+
tokensOutput: totalTokensOut,
|
|
895
|
+
iterationsUsed
|
|
896
|
+
};
|
|
897
|
+
}
|
|
898
|
+
const filteredToolCalls = this.filterBlockedToolCalls(responseChunk.message?.toolCalls ?? [], {
|
|
899
|
+
phase: "resume",
|
|
900
|
+
iteration: iterationsUsed,
|
|
901
|
+
metadata: runtimeMetadata,
|
|
902
|
+
}, toolExecutions);
|
|
903
|
+
if (filteredToolCalls.length === 0) {
|
|
904
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
905
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
906
|
+
continue;
|
|
907
|
+
}
|
|
908
|
+
const nextPendingInterrupt = this.buildPendingInterrupt(filteredToolCalls);
|
|
909
|
+
if (nextPendingInterrupt) {
|
|
910
|
+
this.pendingInterrupt = nextPendingInterrupt;
|
|
911
|
+
stopReason = "interrupted";
|
|
912
|
+
this.transition(contracts_1.ConversationStatus.INTERRUPTED);
|
|
913
|
+
this.deps.eventsBus.pushInterrupt(nextPendingInterrupt.interrupt);
|
|
914
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
915
|
+
return {
|
|
916
|
+
output: finalOutput,
|
|
917
|
+
thinking: lastThinking,
|
|
918
|
+
stopReason,
|
|
919
|
+
status: this.deps.statusMachine.current,
|
|
920
|
+
messages: this.deps.history.snapshot(),
|
|
921
|
+
toolExecutions,
|
|
922
|
+
interrupt: this.cloneInterrupt(nextPendingInterrupt.interrupt),
|
|
923
|
+
tokensInput: totalTokensIn,
|
|
924
|
+
tokensOutput: totalTokensOut,
|
|
925
|
+
iterationsUsed
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
this.transition(contracts_1.ConversationStatus.WAITING_TOOL);
|
|
929
|
+
for (let _tcIdx = 0; _tcIdx < filteredToolCalls.length; _tcIdx++) {
|
|
930
|
+
const toolCall = filteredToolCalls[_tcIdx];
|
|
931
|
+
this.throwIfAborted(options?.signal);
|
|
932
|
+
if (!this.consumeToolCallBudget(toolCallBudget, toolCall.name)) {
|
|
933
|
+
stopReason = "max-tool-calls";
|
|
934
|
+
for (let _skipIdx = _tcIdx; _skipIdx < filteredToolCalls.length; _skipIdx++) {
|
|
935
|
+
const _skipped = filteredToolCalls[_skipIdx];
|
|
936
|
+
const _skipMsg = this.deps.history.pushToolResult(_skipped.name, `\u26a0\ufe0f Tool call skipped: tool call budget exhausted.`, _skipped.id ?? `call_skip_${Date.now()}_${_skipIdx}`);
|
|
937
|
+
this.deps.eventsBus.pushMessage(_skipMsg);
|
|
938
|
+
}
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
const signature = `${toolCall.name}:${JSON.stringify(toolCall.arguments ?? {})}`;
|
|
942
|
+
const isDuplicate = uniqueSignatures.has(signature);
|
|
943
|
+
this.trackStallSignals(toolCall.name, toolCall.arguments, uniqueSignatures, recentSignatures);
|
|
944
|
+
if (ACTION_TOOLS.has(toolCall.name)) {
|
|
945
|
+
consecutiveReadOnly = 0;
|
|
946
|
+
recentSignatures.length = 0;
|
|
947
|
+
}
|
|
948
|
+
else if (READ_ONLY_TOOLS.has(toolCall.name)) {
|
|
949
|
+
consecutiveReadOnly++;
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
consecutiveReadOnly = 0;
|
|
953
|
+
}
|
|
954
|
+
const stallResult = this.checkStall(consecutiveReadOnly, recentSignatures, STALL_LIMIT, uniqueSignatures);
|
|
955
|
+
if (stallResult) {
|
|
956
|
+
stopReason = stallResult;
|
|
957
|
+
for (let _skipIdx = _tcIdx; _skipIdx < filteredToolCalls.length; _skipIdx++) {
|
|
958
|
+
const _skipped = filteredToolCalls[_skipIdx];
|
|
959
|
+
const _skipMsg = this.deps.history.pushToolResult(_skipped.name, `\u26a0\ufe0f Tool call skipped: ${stallResult === "stall" ? "stall detected after too many consecutive read-only tool calls" : "repetition detected after repeated identical tool calls"}.`, _skipped.id ?? `call_skip_${Date.now()}_${_skipIdx}`);
|
|
960
|
+
this.deps.eventsBus.pushMessage(_skipMsg);
|
|
961
|
+
}
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
const execution = await this.executeToolWithRetry(toolCall.name, toolCall.arguments ?? {}, options, runtimeMetadata);
|
|
965
|
+
this.deps.eventsBus.pushToolEvent(execution.startedTrace);
|
|
966
|
+
this.deps.eventsBus.pushToolEvent(execution.trace);
|
|
967
|
+
toolExecutions.push(execution.trace);
|
|
968
|
+
const duplicatePrefix = isDuplicate
|
|
969
|
+
? `[DUPLICATE CALL: you already called '${toolCall.name}' with these exact arguments. Below is the same result. Stop repeating this call.]\n\n`
|
|
970
|
+
: "";
|
|
971
|
+
const toolOutput = execution.result.success
|
|
972
|
+
? duplicatePrefix + (execution.result.output ?? "")
|
|
973
|
+
: `ERROR: ${execution.result.error ?? "Unknown tool error"}`;
|
|
974
|
+
const toolMessage = this.deps.history.pushToolResult(toolCall.name, toolOutput, toolCall.id ?? execution.trace.id);
|
|
975
|
+
this.deps.eventsBus.pushMessage(toolMessage);
|
|
976
|
+
if (this.injectTerminationHint(consecutiveReadOnly)) {
|
|
977
|
+
stopReason = "stall";
|
|
978
|
+
break;
|
|
979
|
+
}
|
|
980
|
+
// Doom-loop injection: escalate after repeated identical calls.
|
|
981
|
+
if (isDuplicate) {
|
|
982
|
+
const doomCount = (doomLoopCounts.get(signature) ?? 0) + 1;
|
|
983
|
+
doomLoopCounts.set(signature, doomCount);
|
|
984
|
+
if (doomCount >= DOOM_LOOP_THRESHOLD) {
|
|
985
|
+
this.log.info("runner", `doom-loop ${toolCall.name} count=${doomCount + 1}`);
|
|
986
|
+
const doomMsg = this.deps.history.push("user", `⚠️ Doom-loop warning: You have called '${toolCall.name}' with identical arguments ${doomCount + 1} times. ` +
|
|
987
|
+
`This call cannot produce a different result. You MUST break this loop now: ` +
|
|
988
|
+
`try a different tool, a different approach, or conclude and summarize your findings.`);
|
|
989
|
+
this.deps.eventsBus.pushMessage(doomMsg);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
const commandResult = this.applyToolCommand(execution.result.command, runtimeMetadata);
|
|
993
|
+
runtimeMetadata = commandResult.metadata;
|
|
994
|
+
if (commandResult.goto === "end_turn") {
|
|
995
|
+
this.ensureToolResultsForBatch(filteredToolCalls, "turn ended by tool command");
|
|
996
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
997
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
998
|
+
return {
|
|
999
|
+
output: commandResult.outputOverride ?? finalOutput,
|
|
1000
|
+
thinking: lastThinking,
|
|
1001
|
+
stopReason: "completed",
|
|
1002
|
+
status: this.deps.statusMachine.current,
|
|
1003
|
+
messages: this.deps.history.snapshot(),
|
|
1004
|
+
toolExecutions,
|
|
1005
|
+
tokensInput: totalTokensIn,
|
|
1006
|
+
tokensOutput: totalTokensOut,
|
|
1007
|
+
iterationsUsed
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
if (commandResult.goto === "next_iteration") {
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
// ── Placeholder results for unmatched tool calls (DeepSeek compat) ─
|
|
1015
|
+
if (stopReason && stopReason !== "completed") {
|
|
1016
|
+
this.ensureToolResultsForBatch(filteredToolCalls, "execution terminated early");
|
|
1017
|
+
}
|
|
1018
|
+
if (stopReason !== "completed") {
|
|
1019
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
await this.deps.onTurnComplete?.([...this.deps.history.snapshot()]);
|
|
1023
|
+
this.transition(contracts_1.ConversationStatus.RUNNING);
|
|
1024
|
+
}
|
|
1025
|
+
if (stopReason === "aborted" || options?.signal?.aborted) {
|
|
1026
|
+
stopReason = "aborted";
|
|
1027
|
+
this.transition(contracts_1.ConversationStatus.CANCELLED);
|
|
1028
|
+
}
|
|
1029
|
+
else {
|
|
1030
|
+
this.transition(contracts_1.ConversationStatus.COMPLETED);
|
|
1031
|
+
}
|
|
1032
|
+
this.deps.eventsBus.pushAgentUpdate("run_complete", {
|
|
1033
|
+
phase: "resume",
|
|
1034
|
+
stopReason,
|
|
1035
|
+
iterations: iterationsUsed,
|
|
1036
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata),
|
|
1037
|
+
});
|
|
1038
|
+
return {
|
|
1039
|
+
output: "",
|
|
1040
|
+
thinking: lastThinking,
|
|
1041
|
+
stopReason,
|
|
1042
|
+
status: this.deps.statusMachine.current,
|
|
1043
|
+
messages: this.deps.history.snapshot(),
|
|
1044
|
+
toolExecutions,
|
|
1045
|
+
tokensInput: totalTokensIn,
|
|
1046
|
+
tokensOutput: totalTokensOut,
|
|
1047
|
+
iterationsUsed
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
catch (error) {
|
|
1051
|
+
this.restorePendingInterrupt(null);
|
|
1052
|
+
if (this.isAbortError(error)) {
|
|
1053
|
+
this.transition(contracts_1.ConversationStatus.CANCELLED);
|
|
1054
|
+
return {
|
|
1055
|
+
output: "",
|
|
1056
|
+
thinking: lastThinking,
|
|
1057
|
+
stopReason: "aborted",
|
|
1058
|
+
status: this.deps.statusMachine.current,
|
|
1059
|
+
messages: this.deps.history.snapshot(),
|
|
1060
|
+
toolExecutions,
|
|
1061
|
+
tokensInput: totalTokensIn,
|
|
1062
|
+
tokensOutput: totalTokensOut,
|
|
1063
|
+
iterationsUsed
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
const err = error instanceof Error ? error : new Error("Unknown conversation error");
|
|
1067
|
+
this.transition(contracts_1.ConversationStatus.FAILED);
|
|
1068
|
+
this.deps.eventsBus.pushError(err);
|
|
1069
|
+
throw err;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
// ─────────────────────────────────────────────────────────────
|
|
1073
|
+
// Helpers
|
|
1074
|
+
// ─────────────────────────────────────────────────────────────
|
|
1075
|
+
buildPendingInterrupt(toolCalls) {
|
|
1076
|
+
if (!toolCalls.length)
|
|
1077
|
+
return null;
|
|
1078
|
+
const interruptToolCalls = [];
|
|
1079
|
+
for (let i = 0; i < toolCalls.length; i++) {
|
|
1080
|
+
const toolCall = toolCalls[i];
|
|
1081
|
+
const resolved = this.resolveInterruptConfig(toolCall.name);
|
|
1082
|
+
if (!resolved)
|
|
1083
|
+
continue;
|
|
1084
|
+
interruptToolCalls.push({ index: i, toolCall, config: resolved });
|
|
1085
|
+
}
|
|
1086
|
+
if (!interruptToolCalls.length)
|
|
1087
|
+
return null;
|
|
1088
|
+
const actionRequests = interruptToolCalls.map(({ toolCall, config }) => ({
|
|
1089
|
+
name: toolCall.name,
|
|
1090
|
+
args: toolCall.arguments ?? {},
|
|
1091
|
+
description: config.description ??
|
|
1092
|
+
`${this.deps.interruptDescriptionPrefix ?? "Tool execution requires approval"}\n\nTool: ${toolCall.name}\nArgs: ${JSON.stringify(toolCall.arguments ?? {}, null, 2)}`
|
|
1093
|
+
}));
|
|
1094
|
+
const reviewConfigs = interruptToolCalls.map(({ toolCall, config }) => ({
|
|
1095
|
+
actionName: toolCall.name,
|
|
1096
|
+
allowedDecisions: [...config.allowedDecisions]
|
|
1097
|
+
}));
|
|
1098
|
+
const interrupt = {
|
|
1099
|
+
id: `interrupt_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`,
|
|
1100
|
+
request: {
|
|
1101
|
+
actionRequests,
|
|
1102
|
+
reviewConfigs
|
|
1103
|
+
},
|
|
1104
|
+
createdAt: new Date().toISOString()
|
|
1105
|
+
};
|
|
1106
|
+
return {
|
|
1107
|
+
interrupt,
|
|
1108
|
+
toolCalls: toolCalls.map((toolCall) => ({
|
|
1109
|
+
id: toolCall.id,
|
|
1110
|
+
name: toolCall.name,
|
|
1111
|
+
arguments: { ...(toolCall.arguments ?? {}) }
|
|
1112
|
+
})),
|
|
1113
|
+
interruptToolCalls
|
|
1114
|
+
};
|
|
1115
|
+
}
|
|
1116
|
+
resolveInterruptConfig(toolName) {
|
|
1117
|
+
const interruptOn = this.deps.interruptOn;
|
|
1118
|
+
if (!interruptOn)
|
|
1119
|
+
return null;
|
|
1120
|
+
const config = interruptOn[toolName];
|
|
1121
|
+
if (config === undefined || config === false) {
|
|
1122
|
+
return null;
|
|
1123
|
+
}
|
|
1124
|
+
if (config === true) {
|
|
1125
|
+
return {
|
|
1126
|
+
allowedDecisions: [...contracts_1.DEFAULT_INTERRUPT_DECISIONS]
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
const allowedDecisions = config.allowedDecisions && config.allowedDecisions.length > 0
|
|
1130
|
+
? [...config.allowedDecisions]
|
|
1131
|
+
: [...contracts_1.DEFAULT_INTERRUPT_DECISIONS];
|
|
1132
|
+
return {
|
|
1133
|
+
allowedDecisions,
|
|
1134
|
+
description: config.description
|
|
1135
|
+
};
|
|
1136
|
+
}
|
|
1137
|
+
applyInterruptDecisions(response, pending) {
|
|
1138
|
+
const decisions = response?.decisions;
|
|
1139
|
+
if (!decisions || !Array.isArray(decisions)) {
|
|
1140
|
+
throw new Error("Invalid HITLResponse: decisions must be a non-empty array");
|
|
1141
|
+
}
|
|
1142
|
+
if (decisions.length !== pending.interruptToolCalls.length) {
|
|
1143
|
+
throw new Error(`Number of human decisions (${decisions.length}) does not match number of hanging tool calls (${pending.interruptToolCalls.length}).`);
|
|
1144
|
+
}
|
|
1145
|
+
const revisedToolCalls = [];
|
|
1146
|
+
const artificialToolMessages = [];
|
|
1147
|
+
let hasRejectedToolCalls = false;
|
|
1148
|
+
let interruptDecisionIndex = 0;
|
|
1149
|
+
for (let i = 0; i < pending.toolCalls.length; i++) {
|
|
1150
|
+
const toolCall = pending.toolCalls[i];
|
|
1151
|
+
const interruptToolCall = pending.interruptToolCalls.find((entry) => entry.index === i);
|
|
1152
|
+
if (!interruptToolCall) {
|
|
1153
|
+
revisedToolCalls.push(toolCall);
|
|
1154
|
+
continue;
|
|
1155
|
+
}
|
|
1156
|
+
const decision = decisions[interruptDecisionIndex++];
|
|
1157
|
+
const processed = this.processDecision(decision, toolCall, interruptToolCall.config);
|
|
1158
|
+
if (decision.type === "reject") {
|
|
1159
|
+
hasRejectedToolCalls = true;
|
|
1160
|
+
}
|
|
1161
|
+
if (processed.revisedToolCall) {
|
|
1162
|
+
revisedToolCalls.push(processed.revisedToolCall);
|
|
1163
|
+
}
|
|
1164
|
+
if (processed.toolMessage) {
|
|
1165
|
+
artificialToolMessages.push({ toolName: toolCall.name, content: processed.toolMessage, toolCallId: toolCall.id });
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (hasRejectedToolCalls) {
|
|
1169
|
+
for (const call of revisedToolCalls) {
|
|
1170
|
+
if (!artificialToolMessages.some((msg) => msg.toolName === call.name)) {
|
|
1171
|
+
artificialToolMessages.push({
|
|
1172
|
+
toolName: call.name,
|
|
1173
|
+
content: `Tool call '${call.name}' deferred because another reviewed action in this batch was rejected.`,
|
|
1174
|
+
toolCallId: call.id,
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
return {
|
|
1180
|
+
revisedToolCalls,
|
|
1181
|
+
artificialToolMessages,
|
|
1182
|
+
hasRejectedToolCalls
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
resolveResumeResponse(response, pending) {
|
|
1186
|
+
if (response &&
|
|
1187
|
+
typeof response === "object" &&
|
|
1188
|
+
!Array.isArray(response) &&
|
|
1189
|
+
"decisions" in response) {
|
|
1190
|
+
return response;
|
|
1191
|
+
}
|
|
1192
|
+
if (!response || typeof response !== "object" || Array.isArray(response)) {
|
|
1193
|
+
throw new Error("Invalid resume payload. Expected decisions array or interrupt-id map.");
|
|
1194
|
+
}
|
|
1195
|
+
const mapped = response[pending.interrupt.id];
|
|
1196
|
+
if (!mapped) {
|
|
1197
|
+
throw new Error(`Missing resume response for interrupt id '${pending.interrupt.id}'.`);
|
|
1198
|
+
}
|
|
1199
|
+
return mapped;
|
|
1200
|
+
}
|
|
1201
|
+
processDecision(decision, toolCall, config) {
|
|
1202
|
+
const allowedDecisions = config.allowedDecisions;
|
|
1203
|
+
if (decision.type === "approve" && allowedDecisions.includes("approve")) {
|
|
1204
|
+
return {
|
|
1205
|
+
revisedToolCall: {
|
|
1206
|
+
name: toolCall.name,
|
|
1207
|
+
arguments: { ...(toolCall.arguments ?? {}) }
|
|
1208
|
+
},
|
|
1209
|
+
toolMessage: null
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
if (decision.type === "edit" && allowedDecisions.includes("edit")) {
|
|
1213
|
+
if (!decision.editedAction || typeof decision.editedAction.name !== "string") {
|
|
1214
|
+
throw new Error(`Invalid edited action for tool "${toolCall.name}": name must be a string`);
|
|
1215
|
+
}
|
|
1216
|
+
if (!decision.editedAction.args || typeof decision.editedAction.args !== "object") {
|
|
1217
|
+
throw new Error(`Invalid edited action for tool "${toolCall.name}": args must be an object`);
|
|
1218
|
+
}
|
|
1219
|
+
return {
|
|
1220
|
+
revisedToolCall: {
|
|
1221
|
+
name: decision.editedAction.name,
|
|
1222
|
+
arguments: { ...(decision.editedAction.args ?? {}) }
|
|
1223
|
+
},
|
|
1224
|
+
toolMessage: null
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
if (decision.type === "reject" && allowedDecisions.includes("reject")) {
|
|
1228
|
+
if (decision.message !== undefined && typeof decision.message !== "string") {
|
|
1229
|
+
throw new Error(`Tool call response for "${toolCall.name}" must be a string, got ${typeof decision.message}`);
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
revisedToolCall: null,
|
|
1233
|
+
toolMessage: decision.message ??
|
|
1234
|
+
`User rejected the tool call for '${toolCall.name}'. Please revise your plan.`
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
throw new Error(`Unexpected human decision: ${JSON.stringify(decision)}. Decision type '${decision.type}' is not allowed for tool '${toolCall.name}'. Expected one of ${JSON.stringify(allowedDecisions)} based on the tool's configuration.`);
|
|
1238
|
+
}
|
|
1239
|
+
cloneInterrupt(interrupt) {
|
|
1240
|
+
return {
|
|
1241
|
+
id: interrupt.id,
|
|
1242
|
+
createdAt: interrupt.createdAt,
|
|
1243
|
+
request: {
|
|
1244
|
+
actionRequests: interrupt.request.actionRequests.map((action) => ({
|
|
1245
|
+
name: action.name,
|
|
1246
|
+
args: { ...(action.args ?? {}) },
|
|
1247
|
+
description: action.description
|
|
1248
|
+
})),
|
|
1249
|
+
reviewConfigs: interrupt.request.reviewConfigs.map((config) => ({
|
|
1250
|
+
actionName: config.actionName,
|
|
1251
|
+
allowedDecisions: [...config.allowedDecisions]
|
|
1252
|
+
}))
|
|
1253
|
+
}
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
toPendingInterruptSnapshot(pending) {
|
|
1257
|
+
return {
|
|
1258
|
+
interrupt: this.cloneInterrupt(pending.interrupt),
|
|
1259
|
+
toolCalls: pending.toolCalls.map((toolCall) => ({
|
|
1260
|
+
name: toolCall.name,
|
|
1261
|
+
args: { ...(toolCall.arguments ?? {}) }
|
|
1262
|
+
})),
|
|
1263
|
+
interruptTools: pending.interruptToolCalls.map((item) => ({
|
|
1264
|
+
index: item.index,
|
|
1265
|
+
config: {
|
|
1266
|
+
allowedDecisions: [...item.config.allowedDecisions],
|
|
1267
|
+
description: item.config.description
|
|
1268
|
+
}
|
|
1269
|
+
}))
|
|
1270
|
+
};
|
|
1271
|
+
}
|
|
1272
|
+
applyToolCommand(command, currentMetadata) {
|
|
1273
|
+
if (!command) {
|
|
1274
|
+
return {
|
|
1275
|
+
metadata: currentMetadata,
|
|
1276
|
+
goto: "continue",
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
const mergedMetadata = this.normalizeRuntimeMetadata({
|
|
1280
|
+
...currentMetadata,
|
|
1281
|
+
...(command.update?.state ?? {}),
|
|
1282
|
+
...(command.update?.metadata ?? {}),
|
|
1283
|
+
});
|
|
1284
|
+
const goto = command.goto ?? "continue";
|
|
1285
|
+
return {
|
|
1286
|
+
metadata: mergedMetadata,
|
|
1287
|
+
goto,
|
|
1288
|
+
outputOverride: command.message,
|
|
1289
|
+
};
|
|
1290
|
+
}
|
|
1291
|
+
trackStallSignals(toolName, args, uniqueSignatures, recentSignatures) {
|
|
1292
|
+
const sig = `${toolName}:${JSON.stringify(args ?? {})}`;
|
|
1293
|
+
uniqueSignatures.add(sig);
|
|
1294
|
+
recentSignatures.push(sig);
|
|
1295
|
+
if (recentSignatures.length > 12)
|
|
1296
|
+
recentSignatures.shift();
|
|
1297
|
+
}
|
|
1298
|
+
checkStall(consecutiveReadOnly, recentSignatures, stallLimit, uniqueSignatures) {
|
|
1299
|
+
if (!this.deps.stallDetection)
|
|
1300
|
+
return null;
|
|
1301
|
+
if (consecutiveReadOnly >= stallLimit) {
|
|
1302
|
+
return "stall";
|
|
1303
|
+
}
|
|
1304
|
+
if (recentSignatures.length >= 8) {
|
|
1305
|
+
const unique = new Set(recentSignatures);
|
|
1306
|
+
if (unique.size <= 3)
|
|
1307
|
+
return "repetition";
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
ensureToolResultsForBatch(filteredToolCalls, reason) {
|
|
1312
|
+
const snapshot = this.deps.history.snapshot();
|
|
1313
|
+
const executedIds = new Set();
|
|
1314
|
+
for (const msg of snapshot) {
|
|
1315
|
+
if (msg.role === "tool" && msg.toolCallId)
|
|
1316
|
+
executedIds.add(msg.toolCallId);
|
|
1317
|
+
}
|
|
1318
|
+
for (const tc of filteredToolCalls) {
|
|
1319
|
+
if (tc.id && !executedIds.has(tc.id)) {
|
|
1320
|
+
this.deps.history.pushToolResult(tc.name, `⚠️ Skipped: ${reason}.`, tc.id);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
injectTerminationHint(consecutiveReadOnly) {
|
|
1325
|
+
if (consecutiveReadOnly < TERMINATION_HINT_AFTER)
|
|
1326
|
+
return false;
|
|
1327
|
+
if (consecutiveReadOnly >= MAX_CONSECUTIVE_READ_ONLY) {
|
|
1328
|
+
const stopMsg = this.deps.history.push("user", `⚠️ You have made ${consecutiveReadOnly} consecutive read-only tool calls. ` +
|
|
1329
|
+
`You have enough information. You MUST now produce your FINAL answer directly — ` +
|
|
1330
|
+
`do NOT call any more tools. Summarize your findings and respond to the user.`);
|
|
1331
|
+
this.deps.eventsBus.pushMessage(stopMsg);
|
|
1332
|
+
return true;
|
|
1333
|
+
}
|
|
1334
|
+
const hintMsg = this.deps.history.push("user", `You have made ${consecutiveReadOnly} read-only calls in a row. ` +
|
|
1335
|
+
`You likely have enough context now. Unless you need specific additional data, ` +
|
|
1336
|
+
`please conclude and produce your final answer directly — do not call more tools.`);
|
|
1337
|
+
this.deps.eventsBus.pushMessage(hintMsg);
|
|
1338
|
+
return false;
|
|
1339
|
+
}
|
|
1340
|
+
resolveModelForIteration(phase, iteration) {
|
|
1341
|
+
const defaultModel = this.deps.getModel();
|
|
1342
|
+
const selectedModel = this.deps.selectModel?.({
|
|
1343
|
+
phase,
|
|
1344
|
+
iteration,
|
|
1345
|
+
defaultModel,
|
|
1346
|
+
messages: this.deps.history.snapshot(),
|
|
1347
|
+
});
|
|
1348
|
+
if (typeof selectedModel !== "string") {
|
|
1349
|
+
return defaultModel;
|
|
1350
|
+
}
|
|
1351
|
+
const trimmed = selectedModel.trim();
|
|
1352
|
+
return trimmed.length > 0 ? trimmed : defaultModel;
|
|
1353
|
+
}
|
|
1354
|
+
normalizeMaxIterations(value) {
|
|
1355
|
+
if (typeof value !== "number") {
|
|
1356
|
+
return undefined;
|
|
1357
|
+
}
|
|
1358
|
+
if (!Number.isFinite(value)) {
|
|
1359
|
+
return undefined;
|
|
1360
|
+
}
|
|
1361
|
+
return Math.max(0, Math.floor(value));
|
|
1362
|
+
}
|
|
1363
|
+
createToolCallBudget(maxToolCalls, maxToolCallsPerTool) {
|
|
1364
|
+
const maxTotal = this.normalizePositiveInt(maxToolCalls);
|
|
1365
|
+
const maxPerTool = {};
|
|
1366
|
+
if (maxToolCallsPerTool && typeof maxToolCallsPerTool === "object") {
|
|
1367
|
+
for (const [toolName, limit] of Object.entries(maxToolCallsPerTool)) {
|
|
1368
|
+
const normalized = this.normalizePositiveInt(limit);
|
|
1369
|
+
if (normalized !== undefined) {
|
|
1370
|
+
maxPerTool[toolName] = normalized;
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return {
|
|
1375
|
+
maxTotal,
|
|
1376
|
+
maxPerTool,
|
|
1377
|
+
totalUsed: 0,
|
|
1378
|
+
perToolUsed: new Map(),
|
|
1379
|
+
};
|
|
1380
|
+
}
|
|
1381
|
+
consumeToolCallBudget(budget, toolName) {
|
|
1382
|
+
if (budget.maxTotal !== undefined && budget.totalUsed >= budget.maxTotal) {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
const perToolLimit = budget.maxPerTool[toolName];
|
|
1386
|
+
const perToolUsed = budget.perToolUsed.get(toolName) ?? 0;
|
|
1387
|
+
if (perToolLimit !== undefined && perToolUsed >= perToolLimit) {
|
|
1388
|
+
return false;
|
|
1389
|
+
}
|
|
1390
|
+
budget.totalUsed += 1;
|
|
1391
|
+
budget.perToolUsed.set(toolName, perToolUsed + 1);
|
|
1392
|
+
return true;
|
|
1393
|
+
}
|
|
1394
|
+
normalizePositiveInt(value) {
|
|
1395
|
+
if (typeof value !== "number") {
|
|
1396
|
+
return undefined;
|
|
1397
|
+
}
|
|
1398
|
+
if (!Number.isFinite(value)) {
|
|
1399
|
+
return undefined;
|
|
1400
|
+
}
|
|
1401
|
+
const normalized = Math.floor(value);
|
|
1402
|
+
return normalized > 0 ? normalized : undefined;
|
|
1403
|
+
}
|
|
1404
|
+
resolveStreamNamespace(metadata) {
|
|
1405
|
+
const fromStreamNamespace = metadata["streamNamespace"];
|
|
1406
|
+
if (typeof fromStreamNamespace === "string" && fromStreamNamespace.trim().length > 0) {
|
|
1407
|
+
return fromStreamNamespace.trim();
|
|
1408
|
+
}
|
|
1409
|
+
const fromNamespace = metadata["namespace"];
|
|
1410
|
+
if (typeof fromNamespace === "string" && fromNamespace.trim().length > 0) {
|
|
1411
|
+
return fromNamespace.trim();
|
|
1412
|
+
}
|
|
1413
|
+
return "root";
|
|
1414
|
+
}
|
|
1415
|
+
async resolveAllowedToolSpecs(phase, iteration, metadata, userMessage) {
|
|
1416
|
+
const allSpecs = this.deps.toolRegistry.getLlmToolSpecs();
|
|
1417
|
+
// Apply tool router if configured (before toolFilter)
|
|
1418
|
+
let specs = allSpecs;
|
|
1419
|
+
if (this.deps.toolRouter && userMessage) {
|
|
1420
|
+
try {
|
|
1421
|
+
const allTools = this.deps.toolRegistry.getAll();
|
|
1422
|
+
const messages = this.deps.history.snapshot();
|
|
1423
|
+
const historyText = messages.slice(-4).map((m) => m.content).join("\n").slice(-1000);
|
|
1424
|
+
const result = await this.deps.toolRouter.selectTools(userMessage, allTools, { phase, iteration, conversationHistory: historyText });
|
|
1425
|
+
specs = result.toolSpecs;
|
|
1426
|
+
}
|
|
1427
|
+
catch {
|
|
1428
|
+
specs = allSpecs; // fallback to all tools on error
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
if (!this.deps.toolFilter) {
|
|
1432
|
+
return specs;
|
|
1433
|
+
}
|
|
1434
|
+
const permissions = this.extractPermissions(metadata);
|
|
1435
|
+
return specs.filter((tool) => {
|
|
1436
|
+
return this.deps.toolFilter?.({
|
|
1437
|
+
phase,
|
|
1438
|
+
iteration,
|
|
1439
|
+
toolName: tool.name,
|
|
1440
|
+
metadata,
|
|
1441
|
+
permissions,
|
|
1442
|
+
}) !== false;
|
|
1443
|
+
});
|
|
1444
|
+
}
|
|
1445
|
+
isToolAllowed(phase, iteration, toolName, metadata) {
|
|
1446
|
+
if (!this.deps.toolFilter) {
|
|
1447
|
+
return true;
|
|
1448
|
+
}
|
|
1449
|
+
const permissions = this.extractPermissions(metadata);
|
|
1450
|
+
return this.deps.toolFilter({
|
|
1451
|
+
phase,
|
|
1452
|
+
iteration,
|
|
1453
|
+
toolName,
|
|
1454
|
+
metadata,
|
|
1455
|
+
permissions,
|
|
1456
|
+
}) !== false;
|
|
1457
|
+
}
|
|
1458
|
+
extractPermissions(metadata) {
|
|
1459
|
+
const raw = metadata["permissions"];
|
|
1460
|
+
if (!Array.isArray(raw)) {
|
|
1461
|
+
return [];
|
|
1462
|
+
}
|
|
1463
|
+
return raw.filter((item) => typeof item === "string");
|
|
1464
|
+
}
|
|
1465
|
+
filterBlockedToolCalls(toolCalls, context, toolExecutions) {
|
|
1466
|
+
const allowed = [];
|
|
1467
|
+
for (const toolCall of toolCalls) {
|
|
1468
|
+
if (this.isToolAllowed(context.phase, context.iteration, toolCall.name, context.metadata)) {
|
|
1469
|
+
allowed.push(toolCall);
|
|
1470
|
+
continue;
|
|
1471
|
+
}
|
|
1472
|
+
const skipped = this.createSkippedToolTrace(toolCall.name, toolCall.arguments, "Tool blocked by dynamic toolFilter.");
|
|
1473
|
+
this.deps.eventsBus.pushToolEvent(skipped);
|
|
1474
|
+
toolExecutions.push(skipped);
|
|
1475
|
+
const blockedMessage = this.deps.history.pushToolResult(toolCall.name, `ERROR: Tool '${toolCall.name}' is blocked by toolFilter for phase '${context.phase}'.`, toolCall.id ?? `call_blocked_${Date.now()}`);
|
|
1476
|
+
this.deps.eventsBus.pushMessage(blockedMessage);
|
|
1477
|
+
}
|
|
1478
|
+
return allowed;
|
|
1479
|
+
}
|
|
1480
|
+
createSkippedToolTrace(toolName, input, reason) {
|
|
1481
|
+
const now = new Date().toISOString();
|
|
1482
|
+
return {
|
|
1483
|
+
id: `tool_skipped_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,
|
|
1484
|
+
toolName,
|
|
1485
|
+
input,
|
|
1486
|
+
status: "SKIPPED",
|
|
1487
|
+
startedAt: now,
|
|
1488
|
+
endedAt: now,
|
|
1489
|
+
durationMs: 0,
|
|
1490
|
+
error: reason,
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
async executeToolWithRetry(name, args, options, runtimeMetadata) {
|
|
1494
|
+
const retryConfig = this.resolveToolRetryConfig(name, args);
|
|
1495
|
+
let attempt = 0;
|
|
1496
|
+
for (;;) {
|
|
1497
|
+
const execution = await this.deps.toolRegistry.execute(name, args, {
|
|
1498
|
+
conversationId: this.deps.conversationId,
|
|
1499
|
+
sessionId: this.deps.sessionId,
|
|
1500
|
+
signal: options?.signal,
|
|
1501
|
+
state: runtimeMetadata ?? options?.metadata,
|
|
1502
|
+
runtimeContext: runtimeMetadata ?? options?.metadata,
|
|
1503
|
+
metadata: runtimeMetadata ?? options?.metadata,
|
|
1504
|
+
conversation: this.deps.caller,
|
|
1505
|
+
emitProgress: (message, data) => {
|
|
1506
|
+
const progressTrace = {
|
|
1507
|
+
id: `tool_progress_${Date.now()}`,
|
|
1508
|
+
toolName: name,
|
|
1509
|
+
input: args,
|
|
1510
|
+
status: "RUNNING",
|
|
1511
|
+
startedAt: new Date().toISOString(),
|
|
1512
|
+
output: message,
|
|
1513
|
+
error: data ? JSON.stringify(data) : undefined
|
|
1514
|
+
};
|
|
1515
|
+
this.deps.eventsBus.pushToolEvent(progressTrace);
|
|
1516
|
+
this.deps.eventsBus.pushCustomEvent("tool_progress", {
|
|
1517
|
+
toolName: name,
|
|
1518
|
+
message,
|
|
1519
|
+
data: data ? JSON.stringify(data) : undefined,
|
|
1520
|
+
attempt: attempt + 1,
|
|
1521
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata ?? options?.metadata ?? {}),
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
});
|
|
1525
|
+
if (execution.result.success) {
|
|
1526
|
+
return execution;
|
|
1527
|
+
}
|
|
1528
|
+
if (!retryConfig || attempt >= retryConfig.maxRetries) {
|
|
1529
|
+
return execution;
|
|
1530
|
+
}
|
|
1531
|
+
attempt += 1;
|
|
1532
|
+
this.deps.eventsBus.pushAgentUpdate("tool_retry", {
|
|
1533
|
+
toolName: name,
|
|
1534
|
+
attempt,
|
|
1535
|
+
namespace: this.resolveStreamNamespace(runtimeMetadata ?? options?.metadata ?? {}),
|
|
1536
|
+
});
|
|
1537
|
+
if (retryConfig.retryDelayMs > 0) {
|
|
1538
|
+
await this.waitForRetryDelay(retryConfig.retryDelayMs, options?.signal);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
resolveToolRetryConfig(toolName, input) {
|
|
1543
|
+
const policy = this.deps.toolRetryPolicy;
|
|
1544
|
+
if (!policy) {
|
|
1545
|
+
return null;
|
|
1546
|
+
}
|
|
1547
|
+
const maxRetries = this.normalizePositiveInt(policy.maxRetries);
|
|
1548
|
+
if (!maxRetries) {
|
|
1549
|
+
return null;
|
|
1550
|
+
}
|
|
1551
|
+
const tool = this.deps.toolRegistry.getAll().find((entry) => entry.name === toolName);
|
|
1552
|
+
if (tool?.isDestructive?.(input)) {
|
|
1553
|
+
return null;
|
|
1554
|
+
}
|
|
1555
|
+
const allowlist = new Set((policy.retryableTools ?? []).filter((name) => typeof name === "string"));
|
|
1556
|
+
const isRetryable = tool?.retryable === true || allowlist.has(toolName);
|
|
1557
|
+
if (!isRetryable) {
|
|
1558
|
+
return null;
|
|
1559
|
+
}
|
|
1560
|
+
return {
|
|
1561
|
+
maxRetries,
|
|
1562
|
+
retryDelayMs: Math.max(0, policy.retryDelayMs ?? 0),
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
async waitForRetryDelay(ms, signal) {
|
|
1566
|
+
await new Promise((resolve, reject) => {
|
|
1567
|
+
if (signal?.aborted) {
|
|
1568
|
+
reject(new Error("Conversation aborted"));
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
const timer = setTimeout(() => {
|
|
1572
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1573
|
+
resolve();
|
|
1574
|
+
}, ms);
|
|
1575
|
+
const onAbort = () => {
|
|
1576
|
+
clearTimeout(timer);
|
|
1577
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1578
|
+
reject(new Error("Conversation aborted"));
|
|
1579
|
+
};
|
|
1580
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
async executeTool(name, args, toolExecutions, options, runtimeMetadata) {
|
|
1584
|
+
const execution = await this.executeToolWithRetry(name, args, options, runtimeMetadata);
|
|
1585
|
+
this.deps.eventsBus.pushToolEvent(execution.startedTrace);
|
|
1586
|
+
this.deps.eventsBus.pushToolEvent(execution.trace);
|
|
1587
|
+
toolExecutions.push(execution.trace);
|
|
1588
|
+
return execution.result;
|
|
1589
|
+
}
|
|
1590
|
+
transition(status) {
|
|
1591
|
+
const next = this.deps.statusMachine.transitionTo(status);
|
|
1592
|
+
this.deps.eventsBus.setStatus(next);
|
|
1593
|
+
}
|
|
1594
|
+
normalizeRuntimeMetadata(metadata) {
|
|
1595
|
+
const candidate = { ...(metadata ?? {}) };
|
|
1596
|
+
if (!this.deps.normalizeRuntimeMetadata) {
|
|
1597
|
+
return candidate;
|
|
1598
|
+
}
|
|
1599
|
+
return this.deps.normalizeRuntimeMetadata(candidate);
|
|
1600
|
+
}
|
|
1601
|
+
throwIfAborted(signal) {
|
|
1602
|
+
if (signal?.aborted)
|
|
1603
|
+
throw new Error("Conversation aborted");
|
|
1604
|
+
}
|
|
1605
|
+
isAbortError(error) {
|
|
1606
|
+
if (error instanceof Error && /aborted/i.test(error.message))
|
|
1607
|
+
return true;
|
|
1608
|
+
// DOMException (AbortError / TimeoutError) from fetch — in Node < 21, DOMException does not
|
|
1609
|
+
// extend Error, so we check the duck-typed `name` property directly.
|
|
1610
|
+
if (error != null && typeof error === "object") {
|
|
1611
|
+
const name = error.name;
|
|
1612
|
+
if (name === "AbortError" || name === "TimeoutError")
|
|
1613
|
+
return true;
|
|
1614
|
+
}
|
|
1615
|
+
return false;
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
exports.ConversationRunner = ConversationRunner;
|
|
1619
|
+
//# sourceMappingURL=conversation-runner.class.js.map
|