synapsexcoder 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.opencode/opencode.jsonc +102 -0
- package/README.md +353 -0
- package/dist/agents/agent-config-manager.d.ts +58 -0
- package/dist/agents/agent-config-manager.d.ts.map +1 -0
- package/dist/agents/agent-config-manager.js +313 -0
- package/dist/agents/agent-config-manager.js.map +1 -0
- package/dist/agents/base-agents.d.ts +352 -0
- package/dist/agents/base-agents.d.ts.map +1 -0
- package/dist/agents/base-agents.js +3961 -0
- package/dist/agents/base-agents.js.map +1 -0
- package/dist/agents/gated-subagent.d.ts +126 -0
- package/dist/agents/gated-subagent.d.ts.map +1 -0
- package/dist/agents/gated-subagent.js +591 -0
- package/dist/agents/gated-subagent.js.map +1 -0
- package/dist/agents/gated-subagents.d.ts +130 -0
- package/dist/agents/gated-subagents.d.ts.map +1 -0
- package/dist/agents/gated-subagents.js +2014 -0
- package/dist/agents/gated-subagents.js.map +1 -0
- package/dist/agents/internal-gatekeeper.d.ts +167 -0
- package/dist/agents/internal-gatekeeper.d.ts.map +1 -0
- package/dist/agents/internal-gatekeeper.js +1130 -0
- package/dist/agents/internal-gatekeeper.js.map +1 -0
- package/dist/agents/verification-agent.d.ts +86 -0
- package/dist/agents/verification-agent.d.ts.map +1 -0
- package/dist/agents/verification-agent.js +211 -0
- package/dist/agents/verification-agent.js.map +1 -0
- package/dist/analytics/analytics-types.d.ts +113 -0
- package/dist/analytics/analytics-types.d.ts.map +1 -0
- package/dist/analytics/analytics-types.js +8 -0
- package/dist/analytics/analytics-types.js.map +1 -0
- package/dist/analytics/dashboard-generator.d.ts +35 -0
- package/dist/analytics/dashboard-generator.d.ts.map +1 -0
- package/dist/analytics/dashboard-generator.js +365 -0
- package/dist/analytics/dashboard-generator.js.map +1 -0
- package/dist/analytics/index.d.ts +12 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +12 -0
- package/dist/analytics/index.js.map +1 -0
- package/dist/analytics/metrics-aggregator.d.ts +88 -0
- package/dist/analytics/metrics-aggregator.d.ts.map +1 -0
- package/dist/analytics/metrics-aggregator.js +280 -0
- package/dist/analytics/metrics-aggregator.js.map +1 -0
- package/dist/cli/index.d.ts +36 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2677 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/normalize_patch.d.ts +3 -0
- package/dist/cli/normalize_patch.d.ts.map +1 -0
- package/dist/cli/normalize_patch.js +34 -0
- package/dist/cli/normalize_patch.js.map +1 -0
- package/dist/commands/command-processor.d.ts +58 -0
- package/dist/commands/command-processor.d.ts.map +1 -0
- package/dist/commands/command-processor.js +796 -0
- package/dist/commands/command-processor.js.map +1 -0
- package/dist/config/compliance-checker.d.ts +93 -0
- package/dist/config/compliance-checker.d.ts.map +1 -0
- package/dist/config/compliance-checker.js +424 -0
- package/dist/config/compliance-checker.js.map +1 -0
- package/dist/config/enterprise-config.d.ts +173 -0
- package/dist/config/enterprise-config.d.ts.map +1 -0
- package/dist/config/enterprise-config.js +190 -0
- package/dist/config/enterprise-config.js.map +1 -0
- package/dist/config/index.d.ts +13 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -0
- package/dist/context/context-system.d.ts +97 -0
- package/dist/context/context-system.d.ts.map +1 -0
- package/dist/context/context-system.js +880 -0
- package/dist/context/context-system.js.map +1 -0
- package/dist/context/store.d.ts +123 -0
- package/dist/context/store.d.ts.map +1 -0
- package/dist/context/store.js +281 -0
- package/dist/context/store.js.map +1 -0
- package/dist/dasp/dasp-controller.d.ts +83 -0
- package/dist/dasp/dasp-controller.d.ts.map +1 -0
- package/dist/dasp/dasp-controller.js +190 -0
- package/dist/dasp/dasp-controller.js.map +1 -0
- package/dist/dasp/feedback-adapter.d.ts +56 -0
- package/dist/dasp/feedback-adapter.d.ts.map +1 -0
- package/dist/dasp/feedback-adapter.js +158 -0
- package/dist/dasp/feedback-adapter.js.map +1 -0
- package/dist/dasp/index.d.ts +14 -0
- package/dist/dasp/index.d.ts.map +1 -0
- package/dist/dasp/index.js +10 -0
- package/dist/dasp/index.js.map +1 -0
- package/dist/dasp/prompt-templates.d.ts +38 -0
- package/dist/dasp/prompt-templates.d.ts.map +1 -0
- package/dist/dasp/prompt-templates.js +406 -0
- package/dist/dasp/prompt-templates.js.map +1 -0
- package/dist/dasp/vault-rag-provider.d.ts +51 -0
- package/dist/dasp/vault-rag-provider.d.ts.map +1 -0
- package/dist/dasp/vault-rag-provider.js +125 -0
- package/dist/dasp/vault-rag-provider.js.map +1 -0
- package/dist/distribution/cli-distribution.d.ts +68 -0
- package/dist/distribution/cli-distribution.d.ts.map +1 -0
- package/dist/distribution/cli-distribution.js +941 -0
- package/dist/distribution/cli-distribution.js.map +1 -0
- package/dist/docs/doc-generator.d.ts +78 -0
- package/dist/docs/doc-generator.d.ts.map +1 -0
- package/dist/docs/doc-generator.js +297 -0
- package/dist/docs/doc-generator.js.map +1 -0
- package/dist/docs/index.d.ts +13 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/docs/site-builder.d.ts +58 -0
- package/dist/docs/site-builder.d.ts.map +1 -0
- package/dist/docs/site-builder.js +229 -0
- package/dist/docs/site-builder.js.map +1 -0
- package/dist/ecosystem/adapters/claude-adapter.d.ts +29 -0
- package/dist/ecosystem/adapters/claude-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/claude-adapter.js +116 -0
- package/dist/ecosystem/adapters/claude-adapter.js.map +1 -0
- package/dist/ecosystem/adapters/cursor-adapter.d.ts +27 -0
- package/dist/ecosystem/adapters/cursor-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/cursor-adapter.js +93 -0
- package/dist/ecosystem/adapters/cursor-adapter.js.map +1 -0
- package/dist/ecosystem/adapters/v0-adapter.d.ts +30 -0
- package/dist/ecosystem/adapters/v0-adapter.d.ts.map +1 -0
- package/dist/ecosystem/adapters/v0-adapter.js +112 -0
- package/dist/ecosystem/adapters/v0-adapter.js.map +1 -0
- package/dist/ecosystem/ecosystem-router.d.ts +80 -0
- package/dist/ecosystem/ecosystem-router.d.ts.map +1 -0
- package/dist/ecosystem/ecosystem-router.js +241 -0
- package/dist/ecosystem/ecosystem-router.js.map +1 -0
- package/dist/ecosystem/ecosystem-types.d.ts +94 -0
- package/dist/ecosystem/ecosystem-types.d.ts.map +1 -0
- package/dist/ecosystem/ecosystem-types.js +27 -0
- package/dist/ecosystem/ecosystem-types.js.map +1 -0
- package/dist/ecosystem/index.d.ts +10 -0
- package/dist/ecosystem/index.d.ts.map +1 -0
- package/dist/ecosystem/index.js +9 -0
- package/dist/ecosystem/index.js.map +1 -0
- package/dist/integration/agentic-integration.d.ts +73 -0
- package/dist/integration/agentic-integration.d.ts.map +1 -0
- package/dist/integration/agentic-integration.js +253 -0
- package/dist/integration/agentic-integration.js.map +1 -0
- package/dist/integration/background-agents-integration.d.ts +54 -0
- package/dist/integration/background-agents-integration.d.ts.map +1 -0
- package/dist/integration/background-agents-integration.js +225 -0
- package/dist/integration/background-agents-integration.js.map +1 -0
- package/dist/integration/dcp-integration.d.ts +81 -0
- package/dist/integration/dcp-integration.d.ts.map +1 -0
- package/dist/integration/dcp-integration.js +189 -0
- package/dist/integration/dcp-integration.js.map +1 -0
- package/dist/integration/firecrawl-integration.d.ts +61 -0
- package/dist/integration/firecrawl-integration.d.ts.map +1 -0
- package/dist/integration/firecrawl-integration.js +246 -0
- package/dist/integration/firecrawl-integration.js.map +1 -0
- package/dist/integration/index.d.ts +40 -0
- package/dist/integration/index.d.ts.map +1 -0
- package/dist/integration/index.js +43 -0
- package/dist/integration/index.js.map +1 -0
- package/dist/integration/integration-hub.d.ts +43 -0
- package/dist/integration/integration-hub.d.ts.map +1 -0
- package/dist/integration/integration-hub.js +507 -0
- package/dist/integration/integration-hub.js.map +1 -0
- package/dist/integration/integration-loader.d.ts +42 -0
- package/dist/integration/integration-loader.d.ts.map +1 -0
- package/dist/integration/integration-loader.js +240 -0
- package/dist/integration/integration-loader.js.map +1 -0
- package/dist/integration/md-table-formatter-integration.d.ts +41 -0
- package/dist/integration/md-table-formatter-integration.d.ts.map +1 -0
- package/dist/integration/md-table-formatter-integration.js +183 -0
- package/dist/integration/md-table-formatter-integration.js.map +1 -0
- package/dist/integration/native/agentic/agentic-engine.d.ts +52 -0
- package/dist/integration/native/agentic/agentic-engine.d.ts.map +1 -0
- package/dist/integration/native/agentic/agentic-engine.js +267 -0
- package/dist/integration/native/agentic/agentic-engine.js.map +1 -0
- package/dist/integration/native/background/background-engine.d.ts +62 -0
- package/dist/integration/native/background/background-engine.d.ts.map +1 -0
- package/dist/integration/native/background/background-engine.js +167 -0
- package/dist/integration/native/background/background-engine.js.map +1 -0
- package/dist/integration/native/dcp/dcp-engine.d.ts +55 -0
- package/dist/integration/native/dcp/dcp-engine.d.ts.map +1 -0
- package/dist/integration/native/dcp/dcp-engine.js +168 -0
- package/dist/integration/native/dcp/dcp-engine.js.map +1 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.d.ts +66 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.d.ts.map +1 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.js +221 -0
- package/dist/integration/native/firecrawl/firecrawl-engine.js.map +1 -0
- package/dist/integration/native/formatter/formatter-engine.d.ts +47 -0
- package/dist/integration/native/formatter/formatter-engine.d.ts.map +1 -0
- package/dist/integration/native/formatter/formatter-engine.js +130 -0
- package/dist/integration/native/formatter/formatter-engine.js.map +1 -0
- package/dist/integration/native/index.d.ts +41 -0
- package/dist/integration/native/index.d.ts.map +1 -0
- package/dist/integration/native/index.js +80 -0
- package/dist/integration/native/index.js.map +1 -0
- package/dist/integration/native/orchestration/orchestration-engine.d.ts +62 -0
- package/dist/integration/native/orchestration/orchestration-engine.d.ts.map +1 -0
- package/dist/integration/native/orchestration/orchestration-engine.js +177 -0
- package/dist/integration/native/orchestration/orchestration-engine.js.map +1 -0
- package/dist/integration/native/pty/pty-engine.d.ts +45 -0
- package/dist/integration/native/pty/pty-engine.d.ts.map +1 -0
- package/dist/integration/native/pty/pty-engine.js +103 -0
- package/dist/integration/native/pty/pty-engine.js.map +1 -0
- package/dist/integration/native/shell-strategy.d.ts +60 -0
- package/dist/integration/native/shell-strategy.d.ts.map +1 -0
- package/dist/integration/native/shell-strategy.js +131 -0
- package/dist/integration/native/shell-strategy.js.map +1 -0
- package/dist/integration/native/skillful/skillful-engine.d.ts +53 -0
- package/dist/integration/native/skillful/skillful-engine.d.ts.map +1 -0
- package/dist/integration/native/skillful/skillful-engine.js +127 -0
- package/dist/integration/native/skillful/skillful-engine.js.map +1 -0
- package/dist/integration/native/subtask2/subtask2-engine.d.ts +50 -0
- package/dist/integration/native/subtask2/subtask2-engine.d.ts.map +1 -0
- package/dist/integration/native/subtask2/subtask2-engine.js +158 -0
- package/dist/integration/native/subtask2/subtask2-engine.js.map +1 -0
- package/dist/integration/native/supermemory/supermemory-engine.d.ts +63 -0
- package/dist/integration/native/supermemory/supermemory-engine.d.ts.map +1 -0
- package/dist/integration/native/supermemory/supermemory-engine.js +127 -0
- package/dist/integration/native/supermemory/supermemory-engine.js.map +1 -0
- package/dist/integration/native/workspace/workspace-engine.d.ts +75 -0
- package/dist/integration/native/workspace/workspace-engine.d.ts.map +1 -0
- package/dist/integration/native/workspace/workspace-engine.js +216 -0
- package/dist/integration/native/workspace/workspace-engine.js.map +1 -0
- package/dist/integration/oh-my-opencode-integration.d.ts +59 -0
- package/dist/integration/oh-my-opencode-integration.d.ts.map +1 -0
- package/dist/integration/oh-my-opencode-integration.js +180 -0
- package/dist/integration/oh-my-opencode-integration.js.map +1 -0
- package/dist/integration/openagents-control-integration.d.ts +81 -0
- package/dist/integration/openagents-control-integration.d.ts.map +1 -0
- package/dist/integration/openagents-control-integration.js +273 -0
- package/dist/integration/openagents-control-integration.js.map +1 -0
- package/dist/integration/pty-integration.d.ts +64 -0
- package/dist/integration/pty-integration.d.ts.map +1 -0
- package/dist/integration/pty-integration.js +180 -0
- package/dist/integration/pty-integration.js.map +1 -0
- package/dist/integration/shell-strategy-integration.d.ts +26 -0
- package/dist/integration/shell-strategy-integration.d.ts.map +1 -0
- package/dist/integration/shell-strategy-integration.js +110 -0
- package/dist/integration/shell-strategy-integration.js.map +1 -0
- package/dist/integration/skillful-integration.d.ts +74 -0
- package/dist/integration/skillful-integration.d.ts.map +1 -0
- package/dist/integration/skillful-integration.js +317 -0
- package/dist/integration/skillful-integration.js.map +1 -0
- package/dist/integration/subtask2-integration.d.ts +71 -0
- package/dist/integration/subtask2-integration.d.ts.map +1 -0
- package/dist/integration/subtask2-integration.js +240 -0
- package/dist/integration/subtask2-integration.js.map +1 -0
- package/dist/integration/supermemory-integration.d.ts +82 -0
- package/dist/integration/supermemory-integration.d.ts.map +1 -0
- package/dist/integration/supermemory-integration.js +252 -0
- package/dist/integration/supermemory-integration.js.map +1 -0
- package/dist/integration/types.d.ts +218 -0
- package/dist/integration/types.d.ts.map +1 -0
- package/dist/integration/types.js +5 -0
- package/dist/integration/types.js.map +1 -0
- package/dist/integration/workspace-integration.d.ts +46 -0
- package/dist/integration/workspace-integration.d.ts.map +1 -0
- package/dist/integration/workspace-integration.js +181 -0
- package/dist/integration/workspace-integration.js.map +1 -0
- package/dist/knowledge-vault/deepwiki-sync.d.ts +99 -0
- package/dist/knowledge-vault/deepwiki-sync.d.ts.map +1 -0
- package/dist/knowledge-vault/deepwiki-sync.js +381 -0
- package/dist/knowledge-vault/deepwiki-sync.js.map +1 -0
- package/dist/knowledge-vault/index.d.ts +11 -0
- package/dist/knowledge-vault/index.d.ts.map +1 -0
- package/dist/knowledge-vault/index.js +8 -0
- package/dist/knowledge-vault/index.js.map +1 -0
- package/dist/knowledge-vault/knowledge-vault.d.ts +38 -0
- package/dist/knowledge-vault/knowledge-vault.d.ts.map +1 -0
- package/dist/knowledge-vault/knowledge-vault.js +284 -0
- package/dist/knowledge-vault/knowledge-vault.js.map +1 -0
- package/dist/knowledge-vault/opencode-doc-ingest.d.ts +23 -0
- package/dist/knowledge-vault/opencode-doc-ingest.d.ts.map +1 -0
- package/dist/knowledge-vault/opencode-doc-ingest.js +48 -0
- package/dist/knowledge-vault/opencode-doc-ingest.js.map +1 -0
- package/dist/knowledge-vault/types.d.ts +61 -0
- package/dist/knowledge-vault/types.d.ts.map +1 -0
- package/dist/knowledge-vault/types.js +5 -0
- package/dist/knowledge-vault/types.js.map +1 -0
- package/dist/knowledge-vault/vault-config.d.ts +12 -0
- package/dist/knowledge-vault/vault-config.d.ts.map +1 -0
- package/dist/knowledge-vault/vault-config.js +24 -0
- package/dist/knowledge-vault/vault-config.js.map +1 -0
- package/dist/mcp/index.d.ts +28 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +29 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-manager.d.ts +181 -0
- package/dist/mcp/mcp-manager.d.ts.map +1 -0
- package/dist/mcp/mcp-manager.js +621 -0
- package/dist/mcp/mcp-manager.js.map +1 -0
- package/dist/mcp/mcp-types.d.ts +199 -0
- package/dist/mcp/mcp-types.d.ts.map +1 -0
- package/dist/mcp/mcp-types.js +152 -0
- package/dist/mcp/mcp-types.js.map +1 -0
- package/dist/mcp/servers/mcp-server-bridge.d.ts +64 -0
- package/dist/mcp/servers/mcp-server-bridge.d.ts.map +1 -0
- package/dist/mcp/servers/mcp-server-bridge.js +189 -0
- package/dist/mcp/servers/mcp-server-bridge.js.map +1 -0
- package/dist/messages/message-bus.d.ts +148 -0
- package/dist/messages/message-bus.d.ts.map +1 -0
- package/dist/messages/message-bus.js +432 -0
- package/dist/messages/message-bus.js.map +1 -0
- package/dist/modes/custom-mode-registry.d.ts +121 -0
- package/dist/modes/custom-mode-registry.d.ts.map +1 -0
- package/dist/modes/custom-mode-registry.js +306 -0
- package/dist/modes/custom-mode-registry.js.map +1 -0
- package/dist/modes/index.d.ts +10 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +8 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/mode-designer.d.ts +89 -0
- package/dist/modes/mode-designer.d.ts.map +1 -0
- package/dist/modes/mode-designer.js +485 -0
- package/dist/modes/mode-designer.js.map +1 -0
- package/dist/modes/mode-manager.d.ts +27 -0
- package/dist/modes/mode-manager.d.ts.map +1 -0
- package/dist/modes/mode-manager.js +68 -0
- package/dist/modes/mode-manager.js.map +1 -0
- package/dist/modes/synapse-modes.d.ts +26 -0
- package/dist/modes/synapse-modes.d.ts.map +1 -0
- package/dist/modes/synapse-modes.js +69 -0
- package/dist/modes/synapse-modes.js.map +1 -0
- package/dist/opencode/agent-delegate.d.ts +3 -0
- package/dist/opencode/agent-delegate.d.ts.map +1 -0
- package/dist/opencode/agent-delegate.js +3 -0
- package/dist/opencode/agent-delegate.js.map +1 -0
- package/dist/opencode/tool-bridge.d.ts +3 -0
- package/dist/opencode/tool-bridge.d.ts.map +1 -0
- package/dist/opencode/tool-bridge.js +3 -0
- package/dist/opencode/tool-bridge.js.map +1 -0
- package/dist/optimization/token-optimizer-v2.d.ts +18 -0
- package/dist/optimization/token-optimizer-v2.d.ts.map +1 -0
- package/dist/optimization/token-optimizer-v2.js +23 -0
- package/dist/optimization/token-optimizer-v2.js.map +1 -0
- package/dist/optimization/token-optimizer.d.ts +90 -0
- package/dist/optimization/token-optimizer.d.ts.map +1 -0
- package/dist/optimization/token-optimizer.js +399 -0
- package/dist/optimization/token-optimizer.js.map +1 -0
- package/dist/parallel/agent-farm.d.ts +123 -0
- package/dist/parallel/agent-farm.d.ts.map +1 -0
- package/dist/parallel/agent-farm.js +501 -0
- package/dist/parallel/agent-farm.js.map +1 -0
- package/dist/parallel/farm-scheduler.d.ts +115 -0
- package/dist/parallel/farm-scheduler.d.ts.map +1 -0
- package/dist/parallel/farm-scheduler.js +356 -0
- package/dist/parallel/farm-scheduler.js.map +1 -0
- package/dist/parallel/farm-types.d.ts +104 -0
- package/dist/parallel/farm-types.d.ts.map +1 -0
- package/dist/parallel/farm-types.js +9 -0
- package/dist/parallel/farm-types.js.map +1 -0
- package/dist/parallel/farm-worker.d.ts +62 -0
- package/dist/parallel/farm-worker.d.ts.map +1 -0
- package/dist/parallel/farm-worker.js +268 -0
- package/dist/parallel/farm-worker.js.map +1 -0
- package/dist/parallel/index.d.ts +14 -0
- package/dist/parallel/index.d.ts.map +1 -0
- package/dist/parallel/index.js +14 -0
- package/dist/parallel/index.js.map +1 -0
- package/dist/plugin/native-tools.d.ts +8 -0
- package/dist/plugin/native-tools.d.ts.map +1 -0
- package/dist/plugin/native-tools.js +147 -0
- package/dist/plugin/native-tools.js.map +1 -0
- package/dist/plugin/opencode-plugin.d.ts +32 -0
- package/dist/plugin/opencode-plugin.d.ts.map +1 -0
- package/dist/plugin/opencode-plugin.js +119 -0
- package/dist/plugin/opencode-plugin.js.map +1 -0
- package/dist/plugins/plugin-system.d.ts +108 -0
- package/dist/plugins/plugin-system.d.ts.map +1 -0
- package/dist/plugins/plugin-system.js +707 -0
- package/dist/plugins/plugin-system.js.map +1 -0
- package/dist/profiler/cpu-profiler.d.ts +53 -0
- package/dist/profiler/cpu-profiler.d.ts.map +1 -0
- package/dist/profiler/cpu-profiler.js +233 -0
- package/dist/profiler/cpu-profiler.js.map +1 -0
- package/dist/profiler/index.d.ts +36 -0
- package/dist/profiler/index.d.ts.map +1 -0
- package/dist/profiler/index.js +122 -0
- package/dist/profiler/index.js.map +1 -0
- package/dist/profiler/memory-profiler.d.ts +45 -0
- package/dist/profiler/memory-profiler.d.ts.map +1 -0
- package/dist/profiler/memory-profiler.js +211 -0
- package/dist/profiler/memory-profiler.js.map +1 -0
- package/dist/profiler/profiler-types.d.ts +234 -0
- package/dist/profiler/profiler-types.d.ts.map +1 -0
- package/dist/profiler/profiler-types.js +89 -0
- package/dist/profiler/profiler-types.js.map +1 -0
- package/dist/profiler/query-profiler.d.ts +48 -0
- package/dist/profiler/query-profiler.d.ts.map +1 -0
- package/dist/profiler/query-profiler.js +210 -0
- package/dist/profiler/query-profiler.js.map +1 -0
- package/dist/profiler/report-generator.d.ts +17 -0
- package/dist/profiler/report-generator.d.ts.map +1 -0
- package/dist/profiler/report-generator.js +329 -0
- package/dist/profiler/report-generator.js.map +1 -0
- package/dist/sdk/api.d.ts +85 -0
- package/dist/sdk/api.d.ts.map +1 -0
- package/dist/sdk/api.js +155 -0
- package/dist/sdk/api.js.map +1 -0
- package/dist/sdk/hooks.d.ts +58 -0
- package/dist/sdk/hooks.d.ts.map +1 -0
- package/dist/sdk/hooks.js +115 -0
- package/dist/sdk/hooks.js.map +1 -0
- package/dist/sdk/index.d.ts +17 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +14 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/plugin-base.d.ts +198 -0
- package/dist/sdk/plugin-base.d.ts.map +1 -0
- package/dist/sdk/plugin-base.js +227 -0
- package/dist/sdk/plugin-base.js.map +1 -0
- package/dist/security/audit-rules.d.ts +12 -0
- package/dist/security/audit-rules.d.ts.map +1 -0
- package/dist/security/audit-rules.js +214 -0
- package/dist/security/audit-rules.js.map +1 -0
- package/dist/security/index.d.ts +13 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +13 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/sarif-exporter.d.ts +36 -0
- package/dist/security/sarif-exporter.d.ts.map +1 -0
- package/dist/security/sarif-exporter.js +216 -0
- package/dist/security/sarif-exporter.js.map +1 -0
- package/dist/security/security-auditor.d.ts +30 -0
- package/dist/security/security-auditor.d.ts.map +1 -0
- package/dist/security/security-auditor.js +295 -0
- package/dist/security/security-auditor.js.map +1 -0
- package/dist/security/security-types.d.ts +132 -0
- package/dist/security/security-types.d.ts.map +1 -0
- package/dist/security/security-types.js +7 -0
- package/dist/security/security-types.js.map +1 -0
- package/dist/synapsexcoder/agent-delegate.d.ts +128 -0
- package/dist/synapsexcoder/agent-delegate.d.ts.map +1 -0
- package/dist/synapsexcoder/agent-delegate.js +837 -0
- package/dist/synapsexcoder/agent-delegate.js.map +1 -0
- package/dist/synapsexcoder/agent-mailbox.d.ts +26 -0
- package/dist/synapsexcoder/agent-mailbox.d.ts.map +1 -0
- package/dist/synapsexcoder/agent-mailbox.js +64 -0
- package/dist/synapsexcoder/agent-mailbox.js.map +1 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.d.ts +62 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.d.ts.map +1 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.js +223 -0
- package/dist/synapsexcoder/ast-grep/ast-grep-api.js.map +1 -0
- package/dist/synapsexcoder/cited-search.d.ts +32 -0
- package/dist/synapsexcoder/cited-search.d.ts.map +1 -0
- package/dist/synapsexcoder/cited-search.js +141 -0
- package/dist/synapsexcoder/cited-search.js.map +1 -0
- package/dist/synapsexcoder/credential-store.d.ts +42 -0
- package/dist/synapsexcoder/credential-store.d.ts.map +1 -0
- package/dist/synapsexcoder/credential-store.js +165 -0
- package/dist/synapsexcoder/credential-store.js.map +1 -0
- package/dist/synapsexcoder/devcontainer-awareness.d.ts +35 -0
- package/dist/synapsexcoder/devcontainer-awareness.d.ts.map +1 -0
- package/dist/synapsexcoder/devcontainer-awareness.js +133 -0
- package/dist/synapsexcoder/devcontainer-awareness.js.map +1 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.d.ts +31 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.d.ts.map +1 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.js +93 -0
- package/dist/synapsexcoder/execution-loops/helix-loop.js.map +1 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.d.ts +28 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.d.ts.map +1 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.js +77 -0
- package/dist/synapsexcoder/execution-loops/ralp-loop.js.map +1 -0
- package/dist/synapsexcoder/feature-names.d.ts +27 -0
- package/dist/synapsexcoder/feature-names.d.ts.map +1 -0
- package/dist/synapsexcoder/feature-names.js +40 -0
- package/dist/synapsexcoder/feature-names.js.map +1 -0
- package/dist/synapsexcoder/index.d.ts +39 -0
- package/dist/synapsexcoder/index.d.ts.map +1 -0
- package/dist/synapsexcoder/index.js +23 -0
- package/dist/synapsexcoder/index.js.map +1 -0
- package/dist/synapsexcoder/knowledge-provider.d.ts +44 -0
- package/dist/synapsexcoder/knowledge-provider.d.ts.map +1 -0
- package/dist/synapsexcoder/knowledge-provider.js +107 -0
- package/dist/synapsexcoder/knowledge-provider.js.map +1 -0
- package/dist/synapsexcoder/lsp/lsp-layer.d.ts +51 -0
- package/dist/synapsexcoder/lsp/lsp-layer.d.ts.map +1 -0
- package/dist/synapsexcoder/lsp/lsp-layer.js +302 -0
- package/dist/synapsexcoder/lsp/lsp-layer.js.map +1 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.d.ts +37 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.d.ts.map +1 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.js +100 -0
- package/dist/synapsexcoder/migration/opencode-config-migrator.js.map +1 -0
- package/dist/synapsexcoder/runtime-environment.d.ts +35 -0
- package/dist/synapsexcoder/runtime-environment.d.ts.map +1 -0
- package/dist/synapsexcoder/runtime-environment.js +108 -0
- package/dist/synapsexcoder/runtime-environment.js.map +1 -0
- package/dist/synapsexcoder/secret-guard.d.ts +18 -0
- package/dist/synapsexcoder/secret-guard.d.ts.map +1 -0
- package/dist/synapsexcoder/secret-guard.js +69 -0
- package/dist/synapsexcoder/secret-guard.js.map +1 -0
- package/dist/synapsexcoder/self-prompt-engine.d.ts +15 -0
- package/dist/synapsexcoder/self-prompt-engine.d.ts.map +1 -0
- package/dist/synapsexcoder/self-prompt-engine.js +11 -0
- package/dist/synapsexcoder/self-prompt-engine.js.map +1 -0
- package/dist/synapsexcoder/session-observability.d.ts +44 -0
- package/dist/synapsexcoder/session-observability.d.ts.map +1 -0
- package/dist/synapsexcoder/session-observability.js +115 -0
- package/dist/synapsexcoder/session-observability.js.map +1 -0
- package/dist/synapsexcoder/specialist-agents.d.ts +38 -0
- package/dist/synapsexcoder/specialist-agents.d.ts.map +1 -0
- package/dist/synapsexcoder/specialist-agents.js +192 -0
- package/dist/synapsexcoder/specialist-agents.js.map +1 -0
- package/dist/synapsexcoder/swarm/kanban-board.d.ts +34 -0
- package/dist/synapsexcoder/swarm/kanban-board.d.ts.map +1 -0
- package/dist/synapsexcoder/swarm/kanban-board.js +85 -0
- package/dist/synapsexcoder/swarm/kanban-board.js.map +1 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.d.ts +38 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.d.ts.map +1 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.js +93 -0
- package/dist/synapsexcoder/swarm/swarm-mailbox.js.map +1 -0
- package/dist/synapsexcoder/tool-bridge.d.ts +277 -0
- package/dist/synapsexcoder/tool-bridge.d.ts.map +1 -0
- package/dist/synapsexcoder/tool-bridge.js +1356 -0
- package/dist/synapsexcoder/tool-bridge.js.map +1 -0
- package/dist/synapsexcoder/tool-routing.d.ts +28 -0
- package/dist/synapsexcoder/tool-routing.d.ts.map +1 -0
- package/dist/synapsexcoder/tool-routing.js +79 -0
- package/dist/synapsexcoder/tool-routing.js.map +1 -0
- package/dist/synapsexcoder/type-injector.d.ts +26 -0
- package/dist/synapsexcoder/type-injector.d.ts.map +1 -0
- package/dist/synapsexcoder/type-injector.js +124 -0
- package/dist/synapsexcoder/type-injector.js.map +1 -0
- package/dist/synapsexcoder/utils/fuzzy-match.d.ts +25 -0
- package/dist/synapsexcoder/utils/fuzzy-match.d.ts.map +1 -0
- package/dist/synapsexcoder/utils/fuzzy-match.js +83 -0
- package/dist/synapsexcoder/utils/fuzzy-match.js.map +1 -0
- package/dist/synapsexcoder/vault-crawl.d.ts +29 -0
- package/dist/synapsexcoder/vault-crawl.d.ts.map +1 -0
- package/dist/synapsexcoder/vault-crawl.js +103 -0
- package/dist/synapsexcoder/vault-crawl.js.map +1 -0
- package/dist/synapsexcoder/verified-apply.d.ts +39 -0
- package/dist/synapsexcoder/verified-apply.d.ts.map +1 -0
- package/dist/synapsexcoder/verified-apply.js +81 -0
- package/dist/synapsexcoder/verified-apply.js.map +1 -0
- package/dist/synapsexcoder/verified-context-editing.d.ts +34 -0
- package/dist/synapsexcoder/verified-context-editing.d.ts.map +1 -0
- package/dist/synapsexcoder/verified-context-editing.js +80 -0
- package/dist/synapsexcoder/verified-context-editing.js.map +1 -0
- package/dist/synapsexcoder/worker-pool.d.ts +47 -0
- package/dist/synapsexcoder/worker-pool.d.ts.map +1 -0
- package/dist/synapsexcoder/worker-pool.js +120 -0
- package/dist/synapsexcoder/worker-pool.js.map +1 -0
- package/dist/synapsexcoder/workspace-intelligence.d.ts +35 -0
- package/dist/synapsexcoder/workspace-intelligence.d.ts.map +1 -0
- package/dist/synapsexcoder/workspace-intelligence.js +126 -0
- package/dist/synapsexcoder/workspace-intelligence.js.map +1 -0
- package/dist/synapsexcoder/worktree-manager.d.ts +31 -0
- package/dist/synapsexcoder/worktree-manager.d.ts.map +1 -0
- package/dist/synapsexcoder/worktree-manager.js +100 -0
- package/dist/synapsexcoder/worktree-manager.js.map +1 -0
- package/dist/team/index.d.ts +17 -0
- package/dist/team/index.d.ts.map +1 -0
- package/dist/team/index.js +13 -0
- package/dist/team/index.js.map +1 -0
- package/dist/team/team-audit.d.ts +120 -0
- package/dist/team/team-audit.d.ts.map +1 -0
- package/dist/team/team-audit.js +357 -0
- package/dist/team/team-audit.js.map +1 -0
- package/dist/team/team-collaboration.d.ts +150 -0
- package/dist/team/team-collaboration.d.ts.map +1 -0
- package/dist/team/team-collaboration.js +495 -0
- package/dist/team/team-collaboration.js.map +1 -0
- package/dist/team/team-rbac.d.ts +84 -0
- package/dist/team/team-rbac.d.ts.map +1 -0
- package/dist/team/team-rbac.js +259 -0
- package/dist/team/team-rbac.js.map +1 -0
- package/dist/team/team-session-manager.d.ts +100 -0
- package/dist/team/team-session-manager.d.ts.map +1 -0
- package/dist/team/team-session-manager.js +255 -0
- package/dist/team/team-session-manager.js.map +1 -0
- package/dist/thoughts/thoughts-manager.d.ts +52 -0
- package/dist/thoughts/thoughts-manager.d.ts.map +1 -0
- package/dist/thoughts/thoughts-manager.js +271 -0
- package/dist/thoughts/thoughts-manager.js.map +1 -0
- package/dist/tools/api-validator/index.d.ts +97 -0
- package/dist/tools/api-validator/index.d.ts.map +1 -0
- package/dist/tools/api-validator/index.js +312 -0
- package/dist/tools/api-validator/index.js.map +1 -0
- package/dist/tools/code-archaeology/index.d.ts +193 -0
- package/dist/tools/code-archaeology/index.d.ts.map +1 -0
- package/dist/tools/code-archaeology/index.js +468 -0
- package/dist/tools/code-archaeology/index.js.map +1 -0
- package/dist/tools/codebase-search/index.d.ts +126 -0
- package/dist/tools/codebase-search/index.d.ts.map +1 -0
- package/dist/tools/codebase-search/index.js +437 -0
- package/dist/tools/codebase-search/index.js.map +1 -0
- package/dist/tools/context/index.d.ts +162 -0
- package/dist/tools/context/index.d.ts.map +1 -0
- package/dist/tools/context/index.js +332 -0
- package/dist/tools/context/index.js.map +1 -0
- package/dist/tools/deepwiki/analyzer.d.ts +167 -0
- package/dist/tools/deepwiki/analyzer.d.ts.map +1 -0
- package/dist/tools/deepwiki/analyzer.js +925 -0
- package/dist/tools/deepwiki/analyzer.js.map +1 -0
- package/dist/tools/deepwiki/extractor.d.ts +151 -0
- package/dist/tools/deepwiki/extractor.d.ts.map +1 -0
- package/dist/tools/deepwiki/extractor.js +923 -0
- package/dist/tools/deepwiki/extractor.js.map +1 -0
- package/dist/tools/deepwiki/generator.d.ts +89 -0
- package/dist/tools/deepwiki/generator.d.ts.map +1 -0
- package/dist/tools/deepwiki/generator.js +638 -0
- package/dist/tools/deepwiki/generator.js.map +1 -0
- package/dist/tools/deepwiki/index.d.ts +96 -0
- package/dist/tools/deepwiki/index.d.ts.map +1 -0
- package/dist/tools/deepwiki/index.js +282 -0
- package/dist/tools/deepwiki/index.js.map +1 -0
- package/dist/tools/deepwiki/types.d.ts +370 -0
- package/dist/tools/deepwiki/types.d.ts.map +1 -0
- package/dist/tools/deepwiki/types.js +21 -0
- package/dist/tools/deepwiki/types.js.map +1 -0
- package/dist/tools/dependency-mapper/index.d.ts +212 -0
- package/dist/tools/dependency-mapper/index.d.ts.map +1 -0
- package/dist/tools/dependency-mapper/index.js +592 -0
- package/dist/tools/dependency-mapper/index.js.map +1 -0
- package/dist/tools/memory/index.d.ts +120 -0
- package/dist/tools/memory/index.d.ts.map +1 -0
- package/dist/tools/memory/index.js +275 -0
- package/dist/tools/memory/index.js.map +1 -0
- package/dist/tools/normalize_patch.d.ts +3 -0
- package/dist/tools/normalize_patch.d.ts.map +1 -0
- package/dist/tools/normalize_patch.js +22 -0
- package/dist/tools/normalize_patch.js.map +1 -0
- package/dist/tools/pattern-detector/index.d.ts +105 -0
- package/dist/tools/pattern-detector/index.d.ts.map +1 -0
- package/dist/tools/pattern-detector/index.js +526 -0
- package/dist/tools/pattern-detector/index.js.map +1 -0
- package/dist/tools/performance-profiler/index.d.ts +50 -0
- package/dist/tools/performance-profiler/index.d.ts.map +1 -0
- package/dist/tools/performance-profiler/index.js +164 -0
- package/dist/tools/performance-profiler/index.js.map +1 -0
- package/dist/tools/refactoring-engine/index.d.ts +63 -0
- package/dist/tools/refactoring-engine/index.d.ts.map +1 -0
- package/dist/tools/refactoring-engine/index.js +270 -0
- package/dist/tools/refactoring-engine/index.js.map +1 -0
- package/dist/tools/registry.d.ts +36 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +499 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/test-generator/index.d.ts +152 -0
- package/dist/tools/test-generator/index.d.ts.map +1 -0
- package/dist/tools/test-generator/index.js +448 -0
- package/dist/tools/test-generator/index.js.map +1 -0
- package/dist/types/index.d.ts +565 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/path-validator.d.ts +94 -0
- package/dist/utils/path-validator.d.ts.map +1 -0
- package/dist/utils/path-validator.js +192 -0
- package/dist/utils/path-validator.js.map +1 -0
- package/dist/utils/secure-exec.d.ts +92 -0
- package/dist/utils/secure-exec.d.ts.map +1 -0
- package/dist/utils/secure-exec.js +230 -0
- package/dist/utils/secure-exec.js.map +1 -0
- package/dist/verification/claim-parser.d.ts +37 -0
- package/dist/verification/claim-parser.d.ts.map +1 -0
- package/dist/verification/claim-parser.js +231 -0
- package/dist/verification/claim-parser.js.map +1 -0
- package/dist/verification/cross-reference-engine.d.ts +55 -0
- package/dist/verification/cross-reference-engine.d.ts.map +1 -0
- package/dist/verification/cross-reference-engine.js +149 -0
- package/dist/verification/cross-reference-engine.js.map +1 -0
- package/dist/verification/discrepancy-tracker.d.ts +73 -0
- package/dist/verification/discrepancy-tracker.d.ts.map +1 -0
- package/dist/verification/discrepancy-tracker.js +196 -0
- package/dist/verification/discrepancy-tracker.js.map +1 -0
- package/dist/verification/feature-reconciler.d.ts +90 -0
- package/dist/verification/feature-reconciler.d.ts.map +1 -0
- package/dist/verification/feature-reconciler.js +264 -0
- package/dist/verification/feature-reconciler.js.map +1 -0
- package/dist/verification/index.d.ts +16 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +19 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/integration-verifier.d.ts +66 -0
- package/dist/verification/integration-verifier.d.ts.map +1 -0
- package/dist/verification/integration-verifier.js +210 -0
- package/dist/verification/integration-verifier.js.map +1 -0
- package/dist/verification/recursive-audit-loop.d.ts +56 -0
- package/dist/verification/recursive-audit-loop.d.ts.map +1 -0
- package/dist/verification/recursive-audit-loop.js +136 -0
- package/dist/verification/recursive-audit-loop.js.map +1 -0
- package/dist/verification/runtime-verifier.d.ts +37 -0
- package/dist/verification/runtime-verifier.d.ts.map +1 -0
- package/dist/verification/runtime-verifier.js +221 -0
- package/dist/verification/runtime-verifier.js.map +1 -0
- package/dist/verification/types.d.ts +88 -0
- package/dist/verification/types.d.ts.map +1 -0
- package/dist/verification/types.js +5 -0
- package/dist/verification/types.js.map +1 -0
- package/dist/verification/verification-engine.d.ts +48 -0
- package/dist/verification/verification-engine.d.ts.map +1 -0
- package/dist/verification/verification-engine.js +203 -0
- package/dist/verification/verification-engine.js.map +1 -0
- package/opencode-agents/synapse-analyzer.md +64 -0
- package/opencode-agents/synapse-debugger.md +43 -0
- package/opencode-agents/synapse-diff-validator.md +42 -0
- package/opencode-agents/synapse-gatekeeper.md +273 -0
- package/opencode-agents/synapse-master.md +167 -0
- package/opencode-agents/synapse-planner.md +55 -0
- package/opencode-agents/synapse-researcher.md +61 -0
- package/opencode-agents/synapse-reviewer.md +64 -0
- package/opencode-agents/synapse-rewriter.md +62 -0
- package/opencode-agents/synapse-strategist.md +50 -0
- package/opencode-agents/synapse-test-runner.md +43 -0
- package/opencode-agents/synapse-ui-designer.md +61 -0
- package/opencode-agents/synapse-verifier.md +544 -0
- package/package.json +108 -0
- package/src/plugin/opencode-plugin.ts +141 -0
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
import { OpenCodeToolBridge } from "./tool-bridge.js";
|
|
2
|
+
import { ThoughtsManager } from "../thoughts/thoughts-manager.js";
|
|
3
|
+
import { ContextSystem } from "../context/context-system.js";
|
|
4
|
+
import { validateAndResolve } from "../utils/path-validator.js";
|
|
5
|
+
import { writeFileSync, readFileSync, existsSync, mkdirSync } from "fs";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
// Map short agent names to full OpenCode agent names
|
|
8
|
+
const AGENT_NAME_MAP = {
|
|
9
|
+
planner: "synapse-planner",
|
|
10
|
+
analyzer: "synapse-analyzer",
|
|
11
|
+
reviewer: "synapse-reviewer",
|
|
12
|
+
rewriter: "synapse-rewriter",
|
|
13
|
+
ui_designer: "synapse-ui-designer",
|
|
14
|
+
researcher: "synapse-researcher",
|
|
15
|
+
gatekeeper: "synapse-gatekeeper",
|
|
16
|
+
verifier: "synapse-verifier",
|
|
17
|
+
strategist: "synapse-strategist",
|
|
18
|
+
diff_validator: "synapse-diff-validator",
|
|
19
|
+
debugger: "synapse-debugger",
|
|
20
|
+
test_runner: "synapse-test-runner",
|
|
21
|
+
};
|
|
22
|
+
// Expected execution time ranges per agent type (ms)
|
|
23
|
+
const EXPECTED_EXECUTION_TIMES = {
|
|
24
|
+
"synapse-planner": { min: 2000, max: 30000 },
|
|
25
|
+
"synapse-analyzer": { min: 3000, max: 60000 },
|
|
26
|
+
"synapse-reviewer": { min: 2000, max: 45000 },
|
|
27
|
+
"synapse-rewriter": { min: 5000, max: 90000 },
|
|
28
|
+
"synapse-ui-designer": { min: 5000, max: 90000 },
|
|
29
|
+
"synapse-researcher": { min: 3000, max: 60000 },
|
|
30
|
+
"synapse-gatekeeper": { min: 2000, max: 30000 },
|
|
31
|
+
"synapse-verifier": { min: 3000, max: 60000 },
|
|
32
|
+
"synapse-strategist": { min: 2000, max: 30000 },
|
|
33
|
+
"synapse-diff-validator": { min: 2000, max: 30000 },
|
|
34
|
+
"synapse-debugger": { min: 3000, max: 60000 },
|
|
35
|
+
"synapse-test-runner": { min: 3000, max: 60000 },
|
|
36
|
+
};
|
|
37
|
+
// Indicators of model refusal in output
|
|
38
|
+
const REFUSAL_INDICATORS = [
|
|
39
|
+
"i cannot",
|
|
40
|
+
"i can't",
|
|
41
|
+
"i'm unable to",
|
|
42
|
+
"i am unable to",
|
|
43
|
+
"as an ai",
|
|
44
|
+
"i don't have the ability",
|
|
45
|
+
"outside my capabilities",
|
|
46
|
+
"i must decline",
|
|
47
|
+
];
|
|
48
|
+
// Error indicators in output
|
|
49
|
+
const ERROR_INDICATORS = [
|
|
50
|
+
"error:",
|
|
51
|
+
"exception:",
|
|
52
|
+
"traceback",
|
|
53
|
+
"fatal:",
|
|
54
|
+
"panic:",
|
|
55
|
+
"unhandled",
|
|
56
|
+
"stack trace",
|
|
57
|
+
"segmentation fault",
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Convert short agent name to full OpenCode agent name
|
|
61
|
+
*/
|
|
62
|
+
function normalizeAgentName(name) {
|
|
63
|
+
if (name.startsWith("synapse-")) {
|
|
64
|
+
return name;
|
|
65
|
+
}
|
|
66
|
+
return AGENT_NAME_MAP[name] || name;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Extract simple keywords from a task description for pattern matching.
|
|
70
|
+
*/
|
|
71
|
+
function extractTaskKeywords(task) {
|
|
72
|
+
const stopWords = new Set([
|
|
73
|
+
"the",
|
|
74
|
+
"a",
|
|
75
|
+
"an",
|
|
76
|
+
"and",
|
|
77
|
+
"or",
|
|
78
|
+
"but",
|
|
79
|
+
"in",
|
|
80
|
+
"on",
|
|
81
|
+
"at",
|
|
82
|
+
"to",
|
|
83
|
+
"for",
|
|
84
|
+
"of",
|
|
85
|
+
"with",
|
|
86
|
+
"by",
|
|
87
|
+
"is",
|
|
88
|
+
"are",
|
|
89
|
+
"was",
|
|
90
|
+
"were",
|
|
91
|
+
"be",
|
|
92
|
+
"been",
|
|
93
|
+
"being",
|
|
94
|
+
"have",
|
|
95
|
+
"has",
|
|
96
|
+
"had",
|
|
97
|
+
"do",
|
|
98
|
+
"does",
|
|
99
|
+
"did",
|
|
100
|
+
"will",
|
|
101
|
+
"would",
|
|
102
|
+
"could",
|
|
103
|
+
"should",
|
|
104
|
+
"may",
|
|
105
|
+
"might",
|
|
106
|
+
"must",
|
|
107
|
+
"can",
|
|
108
|
+
"this",
|
|
109
|
+
"that",
|
|
110
|
+
"these",
|
|
111
|
+
"those",
|
|
112
|
+
"it",
|
|
113
|
+
"its",
|
|
114
|
+
"not",
|
|
115
|
+
"no",
|
|
116
|
+
"so",
|
|
117
|
+
"if",
|
|
118
|
+
"then",
|
|
119
|
+
"than",
|
|
120
|
+
]);
|
|
121
|
+
return task
|
|
122
|
+
.toLowerCase()
|
|
123
|
+
.split(/\W+/)
|
|
124
|
+
.filter((w) => w.length > 2 && !stopWords.has(w));
|
|
125
|
+
}
|
|
126
|
+
export class AgentDelegate {
|
|
127
|
+
bridge;
|
|
128
|
+
thoughts;
|
|
129
|
+
context;
|
|
130
|
+
projectRoot;
|
|
131
|
+
learningStorePath;
|
|
132
|
+
learningStore;
|
|
133
|
+
constructor(projectRoot) {
|
|
134
|
+
this.projectRoot = projectRoot;
|
|
135
|
+
this.bridge = new OpenCodeToolBridge({ mode: "embedded" }, projectRoot);
|
|
136
|
+
this.thoughts = new ThoughtsManager(projectRoot);
|
|
137
|
+
this.context = new ContextSystem(projectRoot);
|
|
138
|
+
// Initialize persistent learning store
|
|
139
|
+
const learningDir = join(projectRoot, ".synapsexcoder", "learning");
|
|
140
|
+
if (!existsSync(learningDir)) {
|
|
141
|
+
mkdirSync(learningDir, { recursive: true });
|
|
142
|
+
}
|
|
143
|
+
this.learningStorePath = join(learningDir, "execution-patterns.json");
|
|
144
|
+
this.learningStore = this.loadLearningStore();
|
|
145
|
+
}
|
|
146
|
+
// ========================================================================
|
|
147
|
+
// Persistence: Learning Store
|
|
148
|
+
// ========================================================================
|
|
149
|
+
loadLearningStore() {
|
|
150
|
+
if (existsSync(this.learningStorePath)) {
|
|
151
|
+
try {
|
|
152
|
+
const raw = readFileSync(this.learningStorePath, "utf-8");
|
|
153
|
+
return JSON.parse(raw);
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// Corrupted file — start fresh
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return { version: 1, records: [], agentStats: {}, updatedAt: Date.now() };
|
|
160
|
+
}
|
|
161
|
+
saveLearningStore() {
|
|
162
|
+
try {
|
|
163
|
+
this.learningStore.updatedAt = Date.now();
|
|
164
|
+
writeFileSync(this.learningStorePath, JSON.stringify(this.learningStore, null, 2), "utf-8");
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
console.warn(`⚠️ Failed to persist learning store: ${error instanceof Error ? error.message : String(error)}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Debounced async save to avoid blocking on every delegation
|
|
171
|
+
saveLearningStoreDebounced() {
|
|
172
|
+
if (this._saveDebounceTimer) {
|
|
173
|
+
clearTimeout(this._saveDebounceTimer);
|
|
174
|
+
}
|
|
175
|
+
this._saveDebounceTimer = setTimeout(() => {
|
|
176
|
+
this.saveLearningStore();
|
|
177
|
+
this._saveDebounceTimer = null;
|
|
178
|
+
}, 2000); // 2 second debounce
|
|
179
|
+
}
|
|
180
|
+
_saveDebounceTimer = null;
|
|
181
|
+
// ========================================================================
|
|
182
|
+
// Result Analysis & Validation
|
|
183
|
+
// ========================================================================
|
|
184
|
+
/**
|
|
185
|
+
* Classify the failure mode from an execution result.
|
|
186
|
+
* Returns null if the result does not indicate a failure.
|
|
187
|
+
*/
|
|
188
|
+
classifyFailureMode(result, executionTimeMs, timeoutMs) {
|
|
189
|
+
if (result.success)
|
|
190
|
+
return null;
|
|
191
|
+
// Timeout detection
|
|
192
|
+
if (executionTimeMs >= timeoutMs * 0.95 ||
|
|
193
|
+
result.error.toLowerCase().includes("timed out") ||
|
|
194
|
+
result.error.toLowerCase().includes("timeout")) {
|
|
195
|
+
return "timeout";
|
|
196
|
+
}
|
|
197
|
+
const outputLower = (result.output || "").toLowerCase();
|
|
198
|
+
const errorLower = (result.error || "").toLowerCase();
|
|
199
|
+
const combined = `${outputLower} ${errorLower}`;
|
|
200
|
+
// Model refusal
|
|
201
|
+
if (REFUSAL_INDICATORS.some((ind) => combined.includes(ind))) {
|
|
202
|
+
return "model_refusal";
|
|
203
|
+
}
|
|
204
|
+
// Empty output
|
|
205
|
+
if (!result.output || result.output.trim().length === 0) {
|
|
206
|
+
return "empty_output";
|
|
207
|
+
}
|
|
208
|
+
// Agent error (non-zero exit but has error text)
|
|
209
|
+
if (result.error && result.error.trim().length > 0) {
|
|
210
|
+
return "agent_error";
|
|
211
|
+
}
|
|
212
|
+
return "unknown";
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Evaluate result completeness: checks for expected structural indicators
|
|
216
|
+
* in the output such as section headers, code blocks, or structured data.
|
|
217
|
+
* Returns a score 0–1.
|
|
218
|
+
*/
|
|
219
|
+
evaluateCompleteness(output) {
|
|
220
|
+
if (!output || output.trim().length === 0)
|
|
221
|
+
return 0;
|
|
222
|
+
let score = 0;
|
|
223
|
+
const checks = [
|
|
224
|
+
// Has substantive content (more than a trivial response)
|
|
225
|
+
{ test: output.trim().length > 50, weight: 0.2 },
|
|
226
|
+
// Contains structured sections (markdown headers or labeled sections)
|
|
227
|
+
{ test: /^#+\s|\n#+\s|^[-*]\s/m.test(output), weight: 0.15 },
|
|
228
|
+
// Contains code blocks or structured data
|
|
229
|
+
{ test: /```[\s\S]*?```|`[^`]+`/.test(output), weight: 0.15 },
|
|
230
|
+
// Has multiple lines (non-trivial output)
|
|
231
|
+
{ test: output.split("\n").length > 3, weight: 0.15 },
|
|
232
|
+
// No truncation indicators
|
|
233
|
+
{ test: !/(truncated|cut off|incomplete)/i.test(output), weight: 0.1 },
|
|
234
|
+
// Reasonable length (neither too short nor suspiciously brief)
|
|
235
|
+
{ test: output.trim().length > 200, weight: 0.15 },
|
|
236
|
+
// Has a conclusion or summary section
|
|
237
|
+
{
|
|
238
|
+
test: /(summary|conclusion|result|output|done|complete)/i.test(output),
|
|
239
|
+
weight: 0.1,
|
|
240
|
+
},
|
|
241
|
+
];
|
|
242
|
+
for (const check of checks) {
|
|
243
|
+
if (check.test)
|
|
244
|
+
score += check.weight;
|
|
245
|
+
}
|
|
246
|
+
return Math.min(1, score);
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Evaluate result quality: checks for absence of error indicators,
|
|
250
|
+
* reasonable output length, and overall coherence signals.
|
|
251
|
+
* Returns a score 0–1.
|
|
252
|
+
*/
|
|
253
|
+
evaluateQuality(output, error) {
|
|
254
|
+
if (!output || output.trim().length === 0)
|
|
255
|
+
return 0;
|
|
256
|
+
let score = 1.0;
|
|
257
|
+
const outputLower = output.toLowerCase();
|
|
258
|
+
// Penalize for error indicators in output
|
|
259
|
+
for (const indicator of ERROR_INDICATORS) {
|
|
260
|
+
if (outputLower.includes(indicator)) {
|
|
261
|
+
score -= 0.15;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
// Penalize for refusal indicators
|
|
265
|
+
for (const indicator of REFUSAL_INDICATORS) {
|
|
266
|
+
if (outputLower.includes(indicator)) {
|
|
267
|
+
score -= 0.25;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
// Penalize for stderr content
|
|
271
|
+
if (error && error.trim().length > 0) {
|
|
272
|
+
score -= 0.1;
|
|
273
|
+
}
|
|
274
|
+
// Penalize for very short output (likely incomplete)
|
|
275
|
+
if (output.trim().length < 30) {
|
|
276
|
+
score -= 0.3;
|
|
277
|
+
}
|
|
278
|
+
// Reward for structured output
|
|
279
|
+
if (/```[\s\S]*?```/.test(output)) {
|
|
280
|
+
score += 0.05;
|
|
281
|
+
}
|
|
282
|
+
return Math.max(0, Math.min(1, score));
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Evaluate pattern consistency against historical executions for the same
|
|
286
|
+
* agent. Checks whether the output length and structure are consistent
|
|
287
|
+
* with past successful executions.
|
|
288
|
+
* Returns a score 0–1.
|
|
289
|
+
*/
|
|
290
|
+
evaluatePatternConsistency(agent, output, executionTimeMs) {
|
|
291
|
+
const stats = this.learningStore.agentStats[agent];
|
|
292
|
+
if (!stats || stats.totalExecutions < 2) {
|
|
293
|
+
// Not enough history — assume neutral consistency
|
|
294
|
+
return 0.5;
|
|
295
|
+
}
|
|
296
|
+
let score = 0.5;
|
|
297
|
+
const outputLen = output.trim().length;
|
|
298
|
+
// Check if execution time is within the historical average ± 2 standard deviations
|
|
299
|
+
const avgTime = stats.avgExecutionTimeMs;
|
|
300
|
+
if (avgTime > 0) {
|
|
301
|
+
const ratio = executionTimeMs / avgTime;
|
|
302
|
+
if (ratio >= 0.3 && ratio <= 3.0) {
|
|
303
|
+
score += 0.25; // Within reasonable range
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
score -= 0.15; // Outlier
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
// Compare success rate — if this agent usually succeeds, a success is consistent
|
|
310
|
+
const successRate = stats.totalExecutions > 0
|
|
311
|
+
? stats.successCount / stats.totalExecutions
|
|
312
|
+
: 0.5;
|
|
313
|
+
if (successRate > 0.7) {
|
|
314
|
+
score += 0.15;
|
|
315
|
+
}
|
|
316
|
+
else if (successRate < 0.3) {
|
|
317
|
+
score -= 0.1;
|
|
318
|
+
}
|
|
319
|
+
// Penalize if output is trivially short compared to what we'd expect
|
|
320
|
+
if (outputLen < 20 && stats.totalExecutions > 3) {
|
|
321
|
+
score -= 0.2;
|
|
322
|
+
}
|
|
323
|
+
return Math.max(0, Math.min(1, score));
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Evaluate execution time against expected range for the agent type.
|
|
327
|
+
* Returns a score 0–1.
|
|
328
|
+
*/
|
|
329
|
+
evaluateExecutionTime(agent, executionTimeMs) {
|
|
330
|
+
const expected = EXPECTED_EXECUTION_TIMES[agent];
|
|
331
|
+
if (!expected)
|
|
332
|
+
return 0.5; // Unknown agent — neutral score
|
|
333
|
+
if (executionTimeMs < expected.min * 0.5) {
|
|
334
|
+
// Suspiciously fast — likely an error or empty response
|
|
335
|
+
return 0.3;
|
|
336
|
+
}
|
|
337
|
+
if (executionTimeMs <= expected.max) {
|
|
338
|
+
// Within expected range — good
|
|
339
|
+
return 1.0;
|
|
340
|
+
}
|
|
341
|
+
if (executionTimeMs <= expected.max * 1.5) {
|
|
342
|
+
// Slightly over — acceptable
|
|
343
|
+
return 0.7;
|
|
344
|
+
}
|
|
345
|
+
// Way over expected time
|
|
346
|
+
return 0.3;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Calculate a composite confidence score from the four evaluation dimensions.
|
|
350
|
+
*/
|
|
351
|
+
calculateConfidence(completeness, quality, consistency, timeScore) {
|
|
352
|
+
// Weighted average — quality and completeness matter most
|
|
353
|
+
const score = completeness * 0.3 +
|
|
354
|
+
quality * 0.35 +
|
|
355
|
+
consistency * 0.2 +
|
|
356
|
+
timeScore * 0.15;
|
|
357
|
+
return Math.max(0, Math.min(1, score));
|
|
358
|
+
}
|
|
359
|
+
// ========================================================================
|
|
360
|
+
// Pattern Detection & Learning
|
|
361
|
+
// ========================================================================
|
|
362
|
+
/**
|
|
363
|
+
* Extract task-type → model → success-rate correlations.
|
|
364
|
+
* Identifies recurring failure modes and tracks prompt effectiveness.
|
|
365
|
+
* Updates the learning store's agentStats.
|
|
366
|
+
*/
|
|
367
|
+
detectAndRecordPatterns(record) {
|
|
368
|
+
const patternIds = [];
|
|
369
|
+
const agent = record.agent;
|
|
370
|
+
const keywords = extractTaskKeywords(record.taskSummary);
|
|
371
|
+
const statsKey = agent;
|
|
372
|
+
// Initialize or update agent stats
|
|
373
|
+
if (!this.learningStore.agentStats[statsKey]) {
|
|
374
|
+
this.learningStore.agentStats[statsKey] = {
|
|
375
|
+
agent,
|
|
376
|
+
taskKeywords: keywords,
|
|
377
|
+
totalExecutions: 0,
|
|
378
|
+
successCount: 0,
|
|
379
|
+
avgConfidence: 0,
|
|
380
|
+
avgExecutionTimeMs: 0,
|
|
381
|
+
commonFailureModes: {},
|
|
382
|
+
lastExecuted: 0,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
const stats = this.learningStore.agentStats[statsKey];
|
|
386
|
+
const prevTotal = stats.totalExecutions;
|
|
387
|
+
stats.totalExecutions += 1;
|
|
388
|
+
stats.lastExecuted = record.timestamp;
|
|
389
|
+
// Merge keywords (keep unique, cap at 20)
|
|
390
|
+
const keywordSet = new Set([...stats.taskKeywords, ...keywords]);
|
|
391
|
+
stats.taskKeywords = Array.from(keywordSet).slice(0, 20);
|
|
392
|
+
if (record.success) {
|
|
393
|
+
stats.successCount += 1;
|
|
394
|
+
}
|
|
395
|
+
// Running average for confidence
|
|
396
|
+
stats.avgConfidence =
|
|
397
|
+
prevTotal > 0
|
|
398
|
+
? (stats.avgConfidence * prevTotal + record.confidenceScore) /
|
|
399
|
+
(prevTotal + 1)
|
|
400
|
+
: record.confidenceScore;
|
|
401
|
+
// Running average for execution time
|
|
402
|
+
stats.avgExecutionTimeMs =
|
|
403
|
+
prevTotal > 0
|
|
404
|
+
? (stats.avgExecutionTimeMs * prevTotal + record.executionTimeMs) /
|
|
405
|
+
(prevTotal + 1)
|
|
406
|
+
: record.executionTimeMs;
|
|
407
|
+
// Track failure modes
|
|
408
|
+
if (record.failureMode) {
|
|
409
|
+
stats.commonFailureModes[record.failureMode] =
|
|
410
|
+
(stats.commonFailureModes[record.failureMode] || 0) + 1;
|
|
411
|
+
}
|
|
412
|
+
// Detect actionable patterns and add to ContextSystem
|
|
413
|
+
// Pattern: Agent consistently succeeds at a task type
|
|
414
|
+
const successRate = stats.totalExecutions > 0
|
|
415
|
+
? stats.successCount / stats.totalExecutions
|
|
416
|
+
: 0;
|
|
417
|
+
if (stats.totalExecutions >= 3 && successRate >= 0.8) {
|
|
418
|
+
const patternName = `High-success agent: ${agent}`;
|
|
419
|
+
const existing = this.context.findRelevantPatterns({
|
|
420
|
+
keywords: [agent, "high-success"],
|
|
421
|
+
limit: 1,
|
|
422
|
+
});
|
|
423
|
+
if (existing.length > 0) {
|
|
424
|
+
this.context.updatePattern(existing[0].id, {
|
|
425
|
+
description: `Agent ${agent} has ${Math.round(successRate * 100)}% success rate over ${stats.totalExecutions} executions (avg confidence: ${stats.avgConfidence.toFixed(2)})`,
|
|
426
|
+
});
|
|
427
|
+
patternIds.push(existing[0].id);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
const id = this.context.addPattern({
|
|
431
|
+
type: "workflow",
|
|
432
|
+
name: patternName,
|
|
433
|
+
description: `Agent ${agent} has ${Math.round(successRate * 100)}% success rate over ${stats.totalExecutions} executions`,
|
|
434
|
+
examples: [
|
|
435
|
+
{
|
|
436
|
+
input: record.taskSummary.substring(0, 100),
|
|
437
|
+
output: `Success (confidence: ${record.confidenceScore.toFixed(2)})`,
|
|
438
|
+
explanation: `Verified via ${stats.totalExecutions} historical executions`,
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
tags: ["high-success", agent, "auto-learned"],
|
|
442
|
+
});
|
|
443
|
+
patternIds.push(id);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
// Pattern: Recurring failure mode
|
|
447
|
+
for (const [mode, count] of Object.entries(stats.commonFailureModes)) {
|
|
448
|
+
if (count >= 3) {
|
|
449
|
+
const failPatternName = `Recurring failure: ${agent} → ${mode}`;
|
|
450
|
+
const existing = this.context.findRelevantPatterns({
|
|
451
|
+
keywords: [agent, mode, "recurring-failure"],
|
|
452
|
+
limit: 1,
|
|
453
|
+
});
|
|
454
|
+
if (existing.length === 0) {
|
|
455
|
+
const id = this.context.addPattern({
|
|
456
|
+
type: "workflow",
|
|
457
|
+
name: failPatternName,
|
|
458
|
+
description: `Agent ${agent} has failed ${count} times with mode "${mode}". Consider alternative agents or task restructuring.`,
|
|
459
|
+
examples: [
|
|
460
|
+
{
|
|
461
|
+
input: record.taskSummary.substring(0, 100),
|
|
462
|
+
output: `Failure mode: ${mode}`,
|
|
463
|
+
explanation: `Detected across ${count} executions`,
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
tags: ["recurring-failure", agent, mode, "auto-learned"],
|
|
467
|
+
});
|
|
468
|
+
patternIds.push(id);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
// Pattern: Execution time anomaly
|
|
473
|
+
if (stats.totalExecutions >= 5 &&
|
|
474
|
+
record.executionTimeMs > stats.avgExecutionTimeMs * 2.5) {
|
|
475
|
+
const id = this.context.addPattern({
|
|
476
|
+
type: "workflow",
|
|
477
|
+
name: `Slow execution: ${agent}`,
|
|
478
|
+
description: `Agent ${agent} took ${record.executionTimeMs}ms vs average ${Math.round(stats.avgExecutionTimeMs)}ms. Possible complexity spike or resource contention.`,
|
|
479
|
+
examples: [
|
|
480
|
+
{
|
|
481
|
+
input: record.taskSummary.substring(0, 100),
|
|
482
|
+
output: `${record.executionTimeMs}ms (${Math.round(record.executionTimeMs / stats.avgExecutionTimeMs)}x avg)`,
|
|
483
|
+
explanation: "Execution time outlier detected",
|
|
484
|
+
},
|
|
485
|
+
],
|
|
486
|
+
tags: ["slow-execution", agent, "auto-learned"],
|
|
487
|
+
});
|
|
488
|
+
patternIds.push(id);
|
|
489
|
+
}
|
|
490
|
+
return patternIds;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Analyze an execution result and produce structured learning insights.
|
|
494
|
+
*/
|
|
495
|
+
analyzeExecution(agent, task, result, executionTimeMs, timeoutMs, validationPassed) {
|
|
496
|
+
const output = result.output || "";
|
|
497
|
+
const error = result.error || "";
|
|
498
|
+
const failureMode = this.classifyFailureMode(result, executionTimeMs, timeoutMs);
|
|
499
|
+
const completeness = this.evaluateCompleteness(output);
|
|
500
|
+
const quality = this.evaluateQuality(output, error);
|
|
501
|
+
const consistency = this.evaluatePatternConsistency(agent, output, executionTimeMs);
|
|
502
|
+
const timeScore = this.evaluateExecutionTime(agent, executionTimeMs);
|
|
503
|
+
const confidence = this.calculateConfidence(completeness, quality, consistency, timeScore);
|
|
504
|
+
// Build the execution record
|
|
505
|
+
const record = {
|
|
506
|
+
timestamp: Date.now(),
|
|
507
|
+
agent,
|
|
508
|
+
taskSummary: task.substring(0, 200),
|
|
509
|
+
success: result.success && failureMode === null,
|
|
510
|
+
validationPassed,
|
|
511
|
+
executionTimeMs,
|
|
512
|
+
confidenceScore: confidence,
|
|
513
|
+
failureMode,
|
|
514
|
+
outputLengthChars: output.length,
|
|
515
|
+
patternIds: [],
|
|
516
|
+
};
|
|
517
|
+
// Detect patterns and get back created pattern IDs
|
|
518
|
+
const patternIds = this.detectAndRecordPatterns(record);
|
|
519
|
+
record.patternIds = patternIds;
|
|
520
|
+
// Persist execution record (keep last 500 records to bound storage)
|
|
521
|
+
this.learningStore.records.push(record);
|
|
522
|
+
if (this.learningStore.records.length > 500) {
|
|
523
|
+
this.learningStore.records = this.learningStore.records.slice(-500);
|
|
524
|
+
}
|
|
525
|
+
// Use debounced save to avoid blocking (saves after 2s idle)
|
|
526
|
+
this.saveLearningStoreDebounced();
|
|
527
|
+
// Generate actionable recommendations
|
|
528
|
+
const recommendations = [];
|
|
529
|
+
const stats = this.learningStore.agentStats[agent];
|
|
530
|
+
if (failureMode === "timeout") {
|
|
531
|
+
recommendations.push(`Consider increasing timeout for ${agent} or splitting the task into smaller chunks.`);
|
|
532
|
+
}
|
|
533
|
+
if (failureMode === "model_refusal") {
|
|
534
|
+
recommendations.push(`Task may be outside ${agent}'s capabilities. Try rephrasing or using a different agent.`);
|
|
535
|
+
}
|
|
536
|
+
if (failureMode === "empty_output") {
|
|
537
|
+
recommendations.push(`${agent} returned empty output. Check that the prompt provides sufficient context.`);
|
|
538
|
+
}
|
|
539
|
+
if (completeness < 0.4) {
|
|
540
|
+
recommendations.push(`Output appears incomplete. Consider providing more context files or a clearer task description.`);
|
|
541
|
+
}
|
|
542
|
+
if (stats && stats.totalExecutions >= 5) {
|
|
543
|
+
const successRate = stats.successCount / stats.totalExecutions;
|
|
544
|
+
if (successRate < 0.5) {
|
|
545
|
+
recommendations.push(`${agent} has a ${Math.round(successRate * 100)}% success rate. Consider using an alternative agent for this task type.`);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return {
|
|
549
|
+
confidenceScore: confidence,
|
|
550
|
+
resultCompleteness: completeness,
|
|
551
|
+
resultQuality: quality,
|
|
552
|
+
patternConsistency: consistency,
|
|
553
|
+
executionTimeScore: timeScore,
|
|
554
|
+
failureMode,
|
|
555
|
+
patternsDetected: patternIds,
|
|
556
|
+
recommendations,
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
// ========================================================================
|
|
560
|
+
// Security & Spawning
|
|
561
|
+
// ========================================================================
|
|
562
|
+
/**
|
|
563
|
+
* Validates a file path against the project root to prevent path traversal.
|
|
564
|
+
*/
|
|
565
|
+
validateFilePath(filePath) {
|
|
566
|
+
return validateAndResolve(filePath, this.projectRoot);
|
|
567
|
+
}
|
|
568
|
+
// ========================================================================
|
|
569
|
+
// Core Delegation
|
|
570
|
+
// ========================================================================
|
|
571
|
+
/**
|
|
572
|
+
* Delegates a task to a specific sub-agent with enriched context.
|
|
573
|
+
*/
|
|
574
|
+
async delegate(agentName, task, relatedFiles = []) {
|
|
575
|
+
const normalizedAgentName = normalizeAgentName(agentName);
|
|
576
|
+
const timeoutMs = 120000;
|
|
577
|
+
console.log(`🤖 Delegating task to ${normalizedAgentName}...`);
|
|
578
|
+
// 1. Gather Context with path validation
|
|
579
|
+
let fileContext = "";
|
|
580
|
+
for (const file of relatedFiles) {
|
|
581
|
+
try {
|
|
582
|
+
const fullPath = this.validateFilePath(file);
|
|
583
|
+
const content = await this.bridge.readFileContent(fullPath);
|
|
584
|
+
if (content) {
|
|
585
|
+
fileContext += `\n--- File: ${file} ---\n${content.content}\n`;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
catch (error) {
|
|
589
|
+
console.warn(`Warning: Could not read file ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
// 2. Get Learned Patterns & Thoughts
|
|
593
|
+
const contextPrompt = this.context.generateContextPrompt(task);
|
|
594
|
+
const recentThoughts = this.thoughts
|
|
595
|
+
.getRecentThoughts(3)
|
|
596
|
+
.map((t) => `[${t.type.toUpperCase()}] ${t.title}: ${t.content.substring(0, 100)}...`)
|
|
597
|
+
.join("\n");
|
|
598
|
+
// 2b. Inject relevant learned patterns as context
|
|
599
|
+
const learnedPatterns = this.context
|
|
600
|
+
.findRelevantPatterns({
|
|
601
|
+
keywords: extractTaskKeywords(task),
|
|
602
|
+
tags: [normalizedAgentName, "auto-learned"],
|
|
603
|
+
limit: 3,
|
|
604
|
+
})
|
|
605
|
+
.map((p) => `[LEARNED] ${p.name}: ${p.description}`)
|
|
606
|
+
.join("\n");
|
|
607
|
+
// 3. Construct the Optimized Prompt
|
|
608
|
+
const fullPrompt = `
|
|
609
|
+
Task: ${task}
|
|
610
|
+
|
|
611
|
+
${contextPrompt}
|
|
612
|
+
|
|
613
|
+
${recentThoughts ? `## Recent Thoughts/Context\n${recentThoughts}\n` : ""}
|
|
614
|
+
|
|
615
|
+
${learnedPatterns ? `## Learned Patterns\n${learnedPatterns}\n` : ""}
|
|
616
|
+
|
|
617
|
+
${fileContext ? `## Related Files\n${fileContext}\n` : ""}
|
|
618
|
+
|
|
619
|
+
Instructions:
|
|
620
|
+
- Use the provided context to inform your response.
|
|
621
|
+
- If you generate code, ensure it follows the project standards.
|
|
622
|
+
`;
|
|
623
|
+
// 4. Validate required task parameters
|
|
624
|
+
const taskParams = {
|
|
625
|
+
agent: normalizedAgentName,
|
|
626
|
+
prompt: fullPrompt,
|
|
627
|
+
// Ensure required fields are always present per Synapse V5
|
|
628
|
+
load_skills: [],
|
|
629
|
+
run_in_background: false,
|
|
630
|
+
// Use a generic low-effort category; can be refined later
|
|
631
|
+
category: "unspecified-low",
|
|
632
|
+
};
|
|
633
|
+
const callStartTime = Date.now();
|
|
634
|
+
const result = await this.bridge.callTool({
|
|
635
|
+
tool: "task",
|
|
636
|
+
...taskParams,
|
|
637
|
+
});
|
|
638
|
+
// 5. Analyze execution and learn from it
|
|
639
|
+
const execTimeMs = result.metadata?.executionTime ?? Date.now() - callStartTime;
|
|
640
|
+
const adaptedResult = {
|
|
641
|
+
success: result.success,
|
|
642
|
+
output: String(result.output ?? ""),
|
|
643
|
+
error: result.error ?? "",
|
|
644
|
+
};
|
|
645
|
+
const insights = this.analyzeExecution(normalizedAgentName, task, adaptedResult, execTimeMs, timeoutMs, null);
|
|
646
|
+
// 6. Record thought with enriched learning data
|
|
647
|
+
let thoughtID;
|
|
648
|
+
if (result.success) {
|
|
649
|
+
thoughtID = this.thoughts.createThought({
|
|
650
|
+
title: `Delegation to ${agentName}: ${task.substring(0, 30)}...`,
|
|
651
|
+
type: "plan",
|
|
652
|
+
content: [
|
|
653
|
+
`Task: ${task}`,
|
|
654
|
+
`Agent: ${agentName}`,
|
|
655
|
+
`Confidence: ${insights.confidenceScore.toFixed(2)}`,
|
|
656
|
+
`Completeness: ${insights.resultCompleteness.toFixed(2)}`,
|
|
657
|
+
`Quality: ${insights.resultQuality.toFixed(2)}`,
|
|
658
|
+
insights.failureMode ? `Failure Mode: ${insights.failureMode}` : null,
|
|
659
|
+
insights.recommendations.length > 0
|
|
660
|
+
? `Recommendations:\n${insights.recommendations.map((r) => ` - ${r}`).join("\n")}`
|
|
661
|
+
: null,
|
|
662
|
+
`\nResult:\n${String(result.output ?? "")}`,
|
|
663
|
+
]
|
|
664
|
+
.filter(Boolean)
|
|
665
|
+
.join("\n\n"),
|
|
666
|
+
tags: [
|
|
667
|
+
"delegation",
|
|
668
|
+
agentName,
|
|
669
|
+
"auto-generated",
|
|
670
|
+
`confidence-${Math.round(insights.confidenceScore * 100)}`,
|
|
671
|
+
],
|
|
672
|
+
relatedFiles: relatedFiles,
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
else {
|
|
676
|
+
// Record failures as analysis thoughts for post-mortem
|
|
677
|
+
this.thoughts.createThought({
|
|
678
|
+
title: `Failed delegation to ${agentName}: ${task.substring(0, 30)}...`,
|
|
679
|
+
type: "analysis",
|
|
680
|
+
content: [
|
|
681
|
+
`Task: ${task}`,
|
|
682
|
+
`Agent: ${agentName}`,
|
|
683
|
+
`Failure Mode: ${insights.failureMode || "unknown"}`,
|
|
684
|
+
`Error: ${result.error ?? ""}`,
|
|
685
|
+
`Confidence: ${insights.confidenceScore.toFixed(2)}`,
|
|
686
|
+
insights.recommendations.length > 0
|
|
687
|
+
? `Recommendations:\n${insights.recommendations.map((r) => ` - ${r}`).join("\n")}`
|
|
688
|
+
: null,
|
|
689
|
+
]
|
|
690
|
+
.filter(Boolean)
|
|
691
|
+
.join("\n\n"),
|
|
692
|
+
tags: [
|
|
693
|
+
"delegation-failed",
|
|
694
|
+
agentName,
|
|
695
|
+
"auto-generated",
|
|
696
|
+
insights.failureMode || "unknown",
|
|
697
|
+
],
|
|
698
|
+
relatedFiles: relatedFiles,
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
return {
|
|
702
|
+
success: result.success,
|
|
703
|
+
output: String(result.output || result.error || "No output"),
|
|
704
|
+
agent: normalizedAgentName,
|
|
705
|
+
thoughtID,
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
// ========================================================================
|
|
709
|
+
// Self-Learning Execution Loop
|
|
710
|
+
// ========================================================================
|
|
711
|
+
/**
|
|
712
|
+
* Executes a task, validates the result with a real validation command,
|
|
713
|
+
* analyzes the outcome to extract meaningful patterns, and updates the
|
|
714
|
+
* learning store and context system with actionable insights.
|
|
715
|
+
*
|
|
716
|
+
* The confidence score is calculated from four dimensions:
|
|
717
|
+
* - Result completeness (structural analysis of output)
|
|
718
|
+
* - Result quality (absence of errors, reasonable length)
|
|
719
|
+
* - Pattern consistency (matches historical success patterns)
|
|
720
|
+
* - Execution time (within expected range)
|
|
721
|
+
*/
|
|
722
|
+
async learnFromExecution(agentName, task, validationCmd) {
|
|
723
|
+
const result = await this.delegate(agentName, task);
|
|
724
|
+
if (!result.success) {
|
|
725
|
+
// Delegation already recorded the failure in analyzeExecution
|
|
726
|
+
return result;
|
|
727
|
+
}
|
|
728
|
+
let validationPassed = null;
|
|
729
|
+
if (validationCmd) {
|
|
730
|
+
console.log(`🧪 Validating result with: ${validationCmd}`);
|
|
731
|
+
try {
|
|
732
|
+
const validation = await this.bridge.runBash(validationCmd);
|
|
733
|
+
validationPassed = validation.success;
|
|
734
|
+
if (validation.success) {
|
|
735
|
+
console.log("✅ Validation passed! Recording verified pattern...");
|
|
736
|
+
// Record a verified, high-confidence workflow pattern
|
|
737
|
+
this.context.addPattern({
|
|
738
|
+
type: "workflow",
|
|
739
|
+
name: `Verified workflow: ${task.substring(0, 40)}...`,
|
|
740
|
+
description: [
|
|
741
|
+
`Agent ${agentName} successfully completed and passed validation.`,
|
|
742
|
+
`Validation: ${validationCmd}`,
|
|
743
|
+
`Task: ${task.substring(0, 150)}`,
|
|
744
|
+
].join(" "),
|
|
745
|
+
examples: [
|
|
746
|
+
{
|
|
747
|
+
input: task,
|
|
748
|
+
output: `Validated (thought: ${result.thoughtID || "N/A"})`,
|
|
749
|
+
explanation: `Passed validation command: ${validationCmd}`,
|
|
750
|
+
},
|
|
751
|
+
],
|
|
752
|
+
tags: ["verified", agentName, "auto-learned"],
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
else {
|
|
756
|
+
console.warn("❌ Validation failed. Recording failure pattern...");
|
|
757
|
+
const validationError = typeof validation.error === "string"
|
|
758
|
+
? validation.error
|
|
759
|
+
: typeof validation.output === "string"
|
|
760
|
+
? validation.output
|
|
761
|
+
: "Unknown validation error";
|
|
762
|
+
this.context.addPattern({
|
|
763
|
+
type: "workflow",
|
|
764
|
+
name: `Validation failure: ${agentName} → ${task.substring(0, 30)}...`,
|
|
765
|
+
description: [
|
|
766
|
+
`Agent ${agentName} completed but validation failed.`,
|
|
767
|
+
`Validation cmd: ${validationCmd}`,
|
|
768
|
+
`Error: ${validationError.substring(0, 200)}`,
|
|
769
|
+
].join(" "),
|
|
770
|
+
examples: [
|
|
771
|
+
{
|
|
772
|
+
input: task,
|
|
773
|
+
output: `Validation failed: ${validationError.substring(0, 100)}`,
|
|
774
|
+
explanation: "Output was generated but did not pass validation checks",
|
|
775
|
+
},
|
|
776
|
+
],
|
|
777
|
+
tags: ["validation-failed", agentName, "auto-learned"],
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
catch (error) {
|
|
782
|
+
console.warn(`⚠️ Validation command error: ${error instanceof Error ? error.message : String(error)}`);
|
|
783
|
+
validationPassed = false;
|
|
784
|
+
}
|
|
785
|
+
// Re-analyze with validation result factored in
|
|
786
|
+
// This updates the learning store with the validation outcome
|
|
787
|
+
const normalizedAgent = normalizeAgentName(agentName);
|
|
788
|
+
const lastRecord = this.learningStore.records[this.learningStore.records.length - 1];
|
|
789
|
+
if (lastRecord && lastRecord.agent === normalizedAgent) {
|
|
790
|
+
lastRecord.validationPassed = validationPassed;
|
|
791
|
+
if (!validationPassed) {
|
|
792
|
+
lastRecord.failureMode = "validation_failed";
|
|
793
|
+
lastRecord.success = false;
|
|
794
|
+
// Adjust confidence downward for validation failure
|
|
795
|
+
lastRecord.confidenceScore = Math.max(0, lastRecord.confidenceScore * 0.5);
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
// Boost confidence for validation success
|
|
799
|
+
lastRecord.confidenceScore = Math.min(1, lastRecord.confidenceScore * 1.15);
|
|
800
|
+
}
|
|
801
|
+
this.saveLearningStore();
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
return result;
|
|
805
|
+
}
|
|
806
|
+
// ========================================================================
|
|
807
|
+
// Introspection API
|
|
808
|
+
// ========================================================================
|
|
809
|
+
/**
|
|
810
|
+
* Get aggregated learning statistics for all agents.
|
|
811
|
+
*/
|
|
812
|
+
getAgentStats() {
|
|
813
|
+
return { ...this.learningStore.agentStats };
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Get recent execution records, optionally filtered by agent.
|
|
817
|
+
*/
|
|
818
|
+
getRecentExecutions(limit = 10, agent) {
|
|
819
|
+
let records = [...this.learningStore.records];
|
|
820
|
+
if (agent) {
|
|
821
|
+
const normalized = normalizeAgentName(agent);
|
|
822
|
+
records = records.filter((r) => r.agent === normalized);
|
|
823
|
+
}
|
|
824
|
+
return records.slice(-limit);
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Get success rate for a specific agent.
|
|
828
|
+
*/
|
|
829
|
+
getSuccessRate(agent) {
|
|
830
|
+
const normalized = normalizeAgentName(agent);
|
|
831
|
+
const stats = this.learningStore.agentStats[normalized];
|
|
832
|
+
if (!stats || stats.totalExecutions === 0)
|
|
833
|
+
return 0;
|
|
834
|
+
return stats.successCount / stats.totalExecutions;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
//# sourceMappingURL=agent-delegate.js.map
|