qlogicagent 0.1.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/README.md +45 -0
- package/dist/agent/agent.d.ts +44 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +114 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/tool-loop.d.ts +65 -0
- package/dist/agent/tool-loop.d.ts.map +1 -0
- package/dist/agent/tool-loop.js +576 -0
- package/dist/agent/tool-loop.js.map +1 -0
- package/dist/agent/types.d.ts +176 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +15 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/cli/main.d.ts +12 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +24 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/stdio-server.d.ts +46 -0
- package/dist/cli/stdio-server.d.ts.map +1 -0
- package/dist/cli/stdio-server.js +464 -0
- package/dist/cli/stdio-server.js.map +1 -0
- package/dist/config/config.d.ts +18 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +22 -0
- package/dist/config/config.js.map +1 -0
- package/dist/contracts/hooks.d.ts +121 -0
- package/dist/contracts/hooks.d.ts.map +1 -0
- package/dist/contracts/hooks.js +8 -0
- package/dist/contracts/hooks.js.map +1 -0
- package/dist/contracts/index.d.ts +11 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +11 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/planner.d.ts +36 -0
- package/dist/contracts/planner.d.ts.map +1 -0
- package/dist/contracts/planner.js +3 -0
- package/dist/contracts/planner.js.map +1 -0
- package/dist/contracts/skill-candidate.d.ts +64 -0
- package/dist/contracts/skill-candidate.d.ts.map +1 -0
- package/dist/contracts/skill-candidate.js +196 -0
- package/dist/contracts/skill-candidate.js.map +1 -0
- package/dist/contracts/todo.d.ts +15 -0
- package/dist/contracts/todo.d.ts.map +1 -0
- package/dist/contracts/todo.js +10 -0
- package/dist/contracts/todo.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/builtin-providers.d.ts +11 -0
- package/dist/llm/builtin-providers.d.ts.map +1 -0
- package/dist/llm/builtin-providers.js +532 -0
- package/dist/llm/builtin-providers.js.map +1 -0
- package/dist/llm/index.d.ts +16 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/llm-client.d.ts +44 -0
- package/dist/llm/llm-client.d.ts.map +1 -0
- package/dist/llm/llm-client.js +68 -0
- package/dist/llm/llm-client.js.map +1 -0
- package/dist/llm/model-catalog.d.ts +54 -0
- package/dist/llm/model-catalog.d.ts.map +1 -0
- package/dist/llm/model-catalog.js +192 -0
- package/dist/llm/model-catalog.js.map +1 -0
- package/dist/llm/provider-def.d.ts +60 -0
- package/dist/llm/provider-def.d.ts.map +1 -0
- package/dist/llm/provider-def.js +13 -0
- package/dist/llm/provider-def.js.map +1 -0
- package/dist/llm/provider-registry.d.ts +55 -0
- package/dist/llm/provider-registry.d.ts.map +1 -0
- package/dist/llm/provider-registry.js +148 -0
- package/dist/llm/provider-registry.js.map +1 -0
- package/dist/llm/transport.d.ts +63 -0
- package/dist/llm/transport.d.ts.map +1 -0
- package/dist/llm/transport.js +28 -0
- package/dist/llm/transport.js.map +1 -0
- package/dist/llm/transports/anthropic-messages.d.ts +32 -0
- package/dist/llm/transports/anthropic-messages.d.ts.map +1 -0
- package/dist/llm/transports/anthropic-messages.js +294 -0
- package/dist/llm/transports/anthropic-messages.js.map +1 -0
- package/dist/llm/transports/openai-chat.d.ts +37 -0
- package/dist/llm/transports/openai-chat.d.ts.map +1 -0
- package/dist/llm/transports/openai-chat.js +166 -0
- package/dist/llm/transports/openai-chat.js.map +1 -0
- package/dist/orchestration/agent-registry.d.ts +42 -0
- package/dist/orchestration/agent-registry.d.ts.map +1 -0
- package/dist/orchestration/agent-registry.js +117 -0
- package/dist/orchestration/agent-registry.js.map +1 -0
- package/dist/orchestration/approval-aware-tool-plan.d.ts +33 -0
- package/dist/orchestration/approval-aware-tool-plan.d.ts.map +1 -0
- package/dist/orchestration/approval-aware-tool-plan.js +88 -0
- package/dist/orchestration/approval-aware-tool-plan.js.map +1 -0
- package/dist/orchestration/context-compression.d.ts +221 -0
- package/dist/orchestration/context-compression.d.ts.map +1 -0
- package/dist/orchestration/context-compression.js +584 -0
- package/dist/orchestration/context-compression.js.map +1 -0
- package/dist/orchestration/conversation-repair.d.ts +62 -0
- package/dist/orchestration/conversation-repair.d.ts.map +1 -0
- package/dist/orchestration/conversation-repair.js +430 -0
- package/dist/orchestration/conversation-repair.js.map +1 -0
- package/dist/orchestration/curator-scheduler.d.ts +120 -0
- package/dist/orchestration/curator-scheduler.d.ts.map +1 -0
- package/dist/orchestration/curator-scheduler.js +136 -0
- package/dist/orchestration/curator-scheduler.js.map +1 -0
- package/dist/orchestration/embedded-failover-policy.d.ts +111 -0
- package/dist/orchestration/embedded-failover-policy.d.ts.map +1 -0
- package/dist/orchestration/embedded-failover-policy.js +169 -0
- package/dist/orchestration/embedded-failover-policy.js.map +1 -0
- package/dist/orchestration/error-classification.d.ts +13 -0
- package/dist/orchestration/error-classification.d.ts.map +1 -0
- package/dist/orchestration/error-classification.js +78 -0
- package/dist/orchestration/error-classification.js.map +1 -0
- package/dist/orchestration/failover-classification.d.ts +9 -0
- package/dist/orchestration/failover-classification.d.ts.map +1 -0
- package/dist/orchestration/failover-classification.js +382 -0
- package/dist/orchestration/failover-classification.js.map +1 -0
- package/dist/orchestration/failover-error.d.ts +34 -0
- package/dist/orchestration/failover-error.d.ts.map +1 -0
- package/dist/orchestration/failover-error.js +199 -0
- package/dist/orchestration/failover-error.js.map +1 -0
- package/dist/orchestration/fork-subagent.d.ts +101 -0
- package/dist/orchestration/fork-subagent.d.ts.map +1 -0
- package/dist/orchestration/fork-subagent.js +99 -0
- package/dist/orchestration/fork-subagent.js.map +1 -0
- package/dist/orchestration/index.d.ts +121 -0
- package/dist/orchestration/index.d.ts.map +1 -0
- package/dist/orchestration/index.js +268 -0
- package/dist/orchestration/index.js.map +1 -0
- package/dist/orchestration/memory-flush-policy.d.ts +58 -0
- package/dist/orchestration/memory-flush-policy.d.ts.map +1 -0
- package/dist/orchestration/memory-flush-policy.js +86 -0
- package/dist/orchestration/memory-flush-policy.js.map +1 -0
- package/dist/orchestration/memory-provider.d.ts +15 -0
- package/dist/orchestration/memory-provider.d.ts.map +1 -0
- package/dist/orchestration/memory-provider.js +3 -0
- package/dist/orchestration/memory-provider.js.map +1 -0
- package/dist/orchestration/parallel-tool-calls.d.ts +42 -0
- package/dist/orchestration/parallel-tool-calls.d.ts.map +1 -0
- package/dist/orchestration/parallel-tool-calls.js +60 -0
- package/dist/orchestration/parallel-tool-calls.js.map +1 -0
- package/dist/orchestration/prompt-cache-strategy.d.ts +127 -0
- package/dist/orchestration/prompt-cache-strategy.d.ts.map +1 -0
- package/dist/orchestration/prompt-cache-strategy.js +229 -0
- package/dist/orchestration/prompt-cache-strategy.js.map +1 -0
- package/dist/orchestration/reactive-compact.d.ts +74 -0
- package/dist/orchestration/reactive-compact.d.ts.map +1 -0
- package/dist/orchestration/reactive-compact.js +79 -0
- package/dist/orchestration/reactive-compact.js.map +1 -0
- package/dist/orchestration/retry-loop.d.ts +23 -0
- package/dist/orchestration/retry-loop.d.ts.map +1 -0
- package/dist/orchestration/retry-loop.js +25 -0
- package/dist/orchestration/retry-loop.js.map +1 -0
- package/dist/orchestration/skill-candidate.d.ts +53 -0
- package/dist/orchestration/skill-candidate.d.ts.map +1 -0
- package/dist/orchestration/skill-candidate.js +142 -0
- package/dist/orchestration/skill-candidate.js.map +1 -0
- package/dist/orchestration/skill-consolidation.d.ts +124 -0
- package/dist/orchestration/skill-consolidation.d.ts.map +1 -0
- package/dist/orchestration/skill-consolidation.js +221 -0
- package/dist/orchestration/skill-consolidation.js.map +1 -0
- package/dist/orchestration/skill-improvement.d.ts +60 -0
- package/dist/orchestration/skill-improvement.d.ts.map +1 -0
- package/dist/orchestration/skill-improvement.js +67 -0
- package/dist/orchestration/skill-improvement.js.map +1 -0
- package/dist/orchestration/skill-similarity.d.ts +99 -0
- package/dist/orchestration/skill-similarity.d.ts.map +1 -0
- package/dist/orchestration/skill-similarity.js +132 -0
- package/dist/orchestration/skill-similarity.js.map +1 -0
- package/dist/orchestration/streaming-tool-executor.d.ts +74 -0
- package/dist/orchestration/streaming-tool-executor.d.ts.map +1 -0
- package/dist/orchestration/streaming-tool-executor.js +97 -0
- package/dist/orchestration/streaming-tool-executor.js.map +1 -0
- package/dist/orchestration/team-orchestration.d.ts +196 -0
- package/dist/orchestration/team-orchestration.d.ts.map +1 -0
- package/dist/orchestration/team-orchestration.js +370 -0
- package/dist/orchestration/team-orchestration.js.map +1 -0
- package/dist/orchestration/team-tool-loop-wiring.d.ts +93 -0
- package/dist/orchestration/team-tool-loop-wiring.d.ts.map +1 -0
- package/dist/orchestration/team-tool-loop-wiring.js +148 -0
- package/dist/orchestration/team-tool-loop-wiring.js.map +1 -0
- package/dist/orchestration/tool-choice-policy.d.ts +55 -0
- package/dist/orchestration/tool-choice-policy.d.ts.map +1 -0
- package/dist/orchestration/tool-choice-policy.js +165 -0
- package/dist/orchestration/tool-choice-policy.js.map +1 -0
- package/dist/orchestration/tool-loop-state.d.ts +51 -0
- package/dist/orchestration/tool-loop-state.d.ts.map +1 -0
- package/dist/orchestration/tool-loop-state.js +134 -0
- package/dist/orchestration/tool-loop-state.js.map +1 -0
- package/dist/orchestration/tool-schema.d.ts +40 -0
- package/dist/orchestration/tool-schema.d.ts.map +1 -0
- package/dist/orchestration/tool-schema.js +298 -0
- package/dist/orchestration/tool-schema.js.map +1 -0
- package/dist/orchestration/transcript-repair.d.ts +43 -0
- package/dist/orchestration/transcript-repair.d.ts.map +1 -0
- package/dist/orchestration/transcript-repair.js +427 -0
- package/dist/orchestration/transcript-repair.js.map +1 -0
- package/dist/orchestration/turn-loop-guard.d.ts +87 -0
- package/dist/orchestration/turn-loop-guard.d.ts.map +1 -0
- package/dist/orchestration/turn-loop-guard.js +93 -0
- package/dist/orchestration/turn-loop-guard.js.map +1 -0
- package/dist/orchestration/web-browser-policy.d.ts +18 -0
- package/dist/orchestration/web-browser-policy.d.ts.map +1 -0
- package/dist/orchestration/web-browser-policy.js +40 -0
- package/dist/orchestration/web-browser-policy.js.map +1 -0
- package/dist/runtime/context-compression.d.ts +62 -0
- package/dist/runtime/context-compression.d.ts.map +1 -0
- package/dist/runtime/context-compression.js +275 -0
- package/dist/runtime/context-compression.js.map +1 -0
- package/dist/runtime/hook-registry.d.ts +13 -0
- package/dist/runtime/hook-registry.d.ts.map +1 -0
- package/dist/runtime/hook-registry.js +54 -0
- package/dist/runtime/hook-registry.js.map +1 -0
- package/dist/runtime/memory-hooks.d.ts +24 -0
- package/dist/runtime/memory-hooks.d.ts.map +1 -0
- package/dist/runtime/memory-hooks.js +66 -0
- package/dist/runtime/memory-hooks.js.map +1 -0
- package/dist/runtime/tool-eligibility.d.ts +60 -0
- package/dist/runtime/tool-eligibility.d.ts.map +1 -0
- package/dist/runtime/tool-eligibility.js +112 -0
- package/dist/runtime/tool-eligibility.js.map +1 -0
- package/dist/skills/index.d.ts +109 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +83 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/memory-extractor.d.ts +65 -0
- package/dist/skills/memory-extractor.d.ts.map +1 -0
- package/dist/skills/memory-extractor.js +174 -0
- package/dist/skills/memory-extractor.js.map +1 -0
- package/dist/skills/memory-query-tool.d.ts +44 -0
- package/dist/skills/memory-query-tool.d.ts.map +1 -0
- package/dist/skills/memory-query-tool.js +128 -0
- package/dist/skills/memory-query-tool.js.map +1 -0
- package/dist/skills/memory-store.d.ts +67 -0
- package/dist/skills/memory-store.d.ts.map +1 -0
- package/dist/skills/memory-store.js +229 -0
- package/dist/skills/memory-store.js.map +1 -0
- package/dist/skills/memory-tool.d.ts +68 -0
- package/dist/skills/memory-tool.d.ts.map +1 -0
- package/dist/skills/memory-tool.js +193 -0
- package/dist/skills/memory-tool.js.map +1 -0
- package/dist/skills/portable-tool.d.ts +72 -0
- package/dist/skills/portable-tool.d.ts.map +1 -0
- package/dist/skills/portable-tool.js +15 -0
- package/dist/skills/portable-tool.js.map +1 -0
- package/dist/skills/qmemory-adapter.d.ts +53 -0
- package/dist/skills/qmemory-adapter.d.ts.map +1 -0
- package/dist/skills/qmemory-adapter.js +166 -0
- package/dist/skills/qmemory-adapter.js.map +1 -0
- package/dist/skills/skill-frontmatter.d.ts +20 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.js +345 -0
- package/dist/skills/skill-frontmatter.js.map +1 -0
- package/dist/skills/skill-guard.d.ts +24 -0
- package/dist/skills/skill-guard.d.ts.map +1 -0
- package/dist/skills/skill-guard.js +230 -0
- package/dist/skills/skill-guard.js.map +1 -0
- package/dist/skills/skill-loader.d.ts +17 -0
- package/dist/skills/skill-loader.d.ts.map +1 -0
- package/dist/skills/skill-loader.js +304 -0
- package/dist/skills/skill-loader.js.map +1 -0
- package/dist/skills/skill-source.d.ts +120 -0
- package/dist/skills/skill-source.d.ts.map +1 -0
- package/dist/skills/skill-source.js +127 -0
- package/dist/skills/skill-source.js.map +1 -0
- package/dist/skills/skill-types.d.ts +200 -0
- package/dist/skills/skill-types.d.ts.map +1 -0
- package/dist/skills/skill-types.js +7 -0
- package/dist/skills/skill-types.js.map +1 -0
- package/dist/skills/think-tool.d.ts +17 -0
- package/dist/skills/think-tool.d.ts.map +1 -0
- package/dist/skills/think-tool.js +60 -0
- package/dist/skills/think-tool.js.map +1 -0
- package/dist/skills/todo-tool.d.ts +64 -0
- package/dist/skills/todo-tool.d.ts.map +1 -0
- package/dist/skills/todo-tool.js +115 -0
- package/dist/skills/todo-tool.js.map +1 -0
- package/dist/skills/tools/agent-tool.d.ts +92 -0
- package/dist/skills/tools/agent-tool.d.ts.map +1 -0
- package/dist/skills/tools/agent-tool.js +143 -0
- package/dist/skills/tools/agent-tool.js.map +1 -0
- package/dist/skills/tools/apply-patch-tool.d.ts +30 -0
- package/dist/skills/tools/apply-patch-tool.d.ts.map +1 -0
- package/dist/skills/tools/apply-patch-tool.js +185 -0
- package/dist/skills/tools/apply-patch-tool.js.map +1 -0
- package/dist/skills/tools/ask-user-tool.d.ts +81 -0
- package/dist/skills/tools/ask-user-tool.d.ts.map +1 -0
- package/dist/skills/tools/ask-user-tool.js +122 -0
- package/dist/skills/tools/ask-user-tool.js.map +1 -0
- package/dist/skills/tools/brief-tool.d.ts +75 -0
- package/dist/skills/tools/brief-tool.d.ts.map +1 -0
- package/dist/skills/tools/brief-tool.js +96 -0
- package/dist/skills/tools/brief-tool.js.map +1 -0
- package/dist/skills/tools/browser-tool.d.ts +115 -0
- package/dist/skills/tools/browser-tool.d.ts.map +1 -0
- package/dist/skills/tools/browser-tool.js +156 -0
- package/dist/skills/tools/browser-tool.js.map +1 -0
- package/dist/skills/tools/checkpoint-tool.d.ts +67 -0
- package/dist/skills/tools/checkpoint-tool.d.ts.map +1 -0
- package/dist/skills/tools/checkpoint-tool.js +103 -0
- package/dist/skills/tools/checkpoint-tool.js.map +1 -0
- package/dist/skills/tools/config-tool.d.ts +64 -0
- package/dist/skills/tools/config-tool.d.ts.map +1 -0
- package/dist/skills/tools/config-tool.js +144 -0
- package/dist/skills/tools/config-tool.js.map +1 -0
- package/dist/skills/tools/cron-tool.d.ts +117 -0
- package/dist/skills/tools/cron-tool.d.ts.map +1 -0
- package/dist/skills/tools/cron-tool.js +176 -0
- package/dist/skills/tools/cron-tool.js.map +1 -0
- package/dist/skills/tools/edit-tool.d.ts +44 -0
- package/dist/skills/tools/edit-tool.d.ts.map +1 -0
- package/dist/skills/tools/edit-tool.js +71 -0
- package/dist/skills/tools/edit-tool.js.map +1 -0
- package/dist/skills/tools/exec-tool.d.ts +103 -0
- package/dist/skills/tools/exec-tool.d.ts.map +1 -0
- package/dist/skills/tools/exec-tool.js +134 -0
- package/dist/skills/tools/exec-tool.js.map +1 -0
- package/dist/skills/tools/image-generate-tool.d.ts +63 -0
- package/dist/skills/tools/image-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/image-generate-tool.js +68 -0
- package/dist/skills/tools/image-generate-tool.js.map +1 -0
- package/dist/skills/tools/instructions-tool.d.ts +104 -0
- package/dist/skills/tools/instructions-tool.d.ts.map +1 -0
- package/dist/skills/tools/instructions-tool.js +188 -0
- package/dist/skills/tools/instructions-tool.js.map +1 -0
- package/dist/skills/tools/lsp-tool.d.ts +154 -0
- package/dist/skills/tools/lsp-tool.d.ts.map +1 -0
- package/dist/skills/tools/lsp-tool.js +228 -0
- package/dist/skills/tools/lsp-tool.js.map +1 -0
- package/dist/skills/tools/mcp-client-types.d.ts +270 -0
- package/dist/skills/tools/mcp-client-types.d.ts.map +1 -0
- package/dist/skills/tools/mcp-client-types.js +54 -0
- package/dist/skills/tools/mcp-client-types.js.map +1 -0
- package/dist/skills/tools/mcp-tool.d.ts +250 -0
- package/dist/skills/tools/mcp-tool.d.ts.map +1 -0
- package/dist/skills/tools/mcp-tool.js +504 -0
- package/dist/skills/tools/mcp-tool.js.map +1 -0
- package/dist/skills/tools/memory-tool.d.ts +75 -0
- package/dist/skills/tools/memory-tool.d.ts.map +1 -0
- package/dist/skills/tools/memory-tool.js +89 -0
- package/dist/skills/tools/memory-tool.js.map +1 -0
- package/dist/skills/tools/monitor-tool.d.ts +114 -0
- package/dist/skills/tools/monitor-tool.d.ts.map +1 -0
- package/dist/skills/tools/monitor-tool.js +132 -0
- package/dist/skills/tools/monitor-tool.js.map +1 -0
- package/dist/skills/tools/music-generate-tool.d.ts +56 -0
- package/dist/skills/tools/music-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/music-generate-tool.js +63 -0
- package/dist/skills/tools/music-generate-tool.js.map +1 -0
- package/dist/skills/tools/notify-tool.d.ts +54 -0
- package/dist/skills/tools/notify-tool.d.ts.map +1 -0
- package/dist/skills/tools/notify-tool.js +63 -0
- package/dist/skills/tools/notify-tool.js.map +1 -0
- package/dist/skills/tools/patch-tool.d.ts +46 -0
- package/dist/skills/tools/patch-tool.d.ts.map +1 -0
- package/dist/skills/tools/patch-tool.js +506 -0
- package/dist/skills/tools/patch-tool.js.map +1 -0
- package/dist/skills/tools/pdf-tool.d.ts +67 -0
- package/dist/skills/tools/pdf-tool.d.ts.map +1 -0
- package/dist/skills/tools/pdf-tool.js +89 -0
- package/dist/skills/tools/pdf-tool.js.map +1 -0
- package/dist/skills/tools/plan-mode-tool.d.ts +60 -0
- package/dist/skills/tools/plan-mode-tool.d.ts.map +1 -0
- package/dist/skills/tools/plan-mode-tool.js +123 -0
- package/dist/skills/tools/plan-mode-tool.js.map +1 -0
- package/dist/skills/tools/read-tool.d.ts +52 -0
- package/dist/skills/tools/read-tool.d.ts.map +1 -0
- package/dist/skills/tools/read-tool.js +85 -0
- package/dist/skills/tools/read-tool.js.map +1 -0
- package/dist/skills/tools/repl-tool.d.ts +71 -0
- package/dist/skills/tools/repl-tool.d.ts.map +1 -0
- package/dist/skills/tools/repl-tool.js +70 -0
- package/dist/skills/tools/repl-tool.js.map +1 -0
- package/dist/skills/tools/search-tool.d.ts +113 -0
- package/dist/skills/tools/search-tool.d.ts.map +1 -0
- package/dist/skills/tools/search-tool.js +226 -0
- package/dist/skills/tools/search-tool.js.map +1 -0
- package/dist/skills/tools/send-message-tool.d.ts +52 -0
- package/dist/skills/tools/send-message-tool.d.ts.map +1 -0
- package/dist/skills/tools/send-message-tool.js +77 -0
- package/dist/skills/tools/send-message-tool.js.map +1 -0
- package/dist/skills/tools/skill-list-tool.d.ts +34 -0
- package/dist/skills/tools/skill-list-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-list-tool.js +55 -0
- package/dist/skills/tools/skill-list-tool.js.map +1 -0
- package/dist/skills/tools/skill-manage-tool.d.ts +74 -0
- package/dist/skills/tools/skill-manage-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-manage-tool.js +154 -0
- package/dist/skills/tools/skill-manage-tool.js.map +1 -0
- package/dist/skills/tools/skill-view-tool.d.ts +38 -0
- package/dist/skills/tools/skill-view-tool.d.ts.map +1 -0
- package/dist/skills/tools/skill-view-tool.js +73 -0
- package/dist/skills/tools/skill-view-tool.js.map +1 -0
- package/dist/skills/tools/sleep-tool.d.ts +50 -0
- package/dist/skills/tools/sleep-tool.d.ts.map +1 -0
- package/dist/skills/tools/sleep-tool.js +82 -0
- package/dist/skills/tools/sleep-tool.js.map +1 -0
- package/dist/skills/tools/structured-output-tool.d.ts +117 -0
- package/dist/skills/tools/structured-output-tool.d.ts.map +1 -0
- package/dist/skills/tools/structured-output-tool.js +177 -0
- package/dist/skills/tools/structured-output-tool.js.map +1 -0
- package/dist/skills/tools/task-tool.d.ts +105 -0
- package/dist/skills/tools/task-tool.d.ts.map +1 -0
- package/dist/skills/tools/task-tool.js +162 -0
- package/dist/skills/tools/task-tool.js.map +1 -0
- package/dist/skills/tools/team-tool.d.ts +90 -0
- package/dist/skills/tools/team-tool.d.ts.map +1 -0
- package/dist/skills/tools/team-tool.js +106 -0
- package/dist/skills/tools/team-tool.js.map +1 -0
- package/dist/skills/tools/tool-search-tool.d.ts +52 -0
- package/dist/skills/tools/tool-search-tool.d.ts.map +1 -0
- package/dist/skills/tools/tool-search-tool.js +111 -0
- package/dist/skills/tools/tool-search-tool.js.map +1 -0
- package/dist/skills/tools/tts-tool.d.ts +39 -0
- package/dist/skills/tools/tts-tool.d.ts.map +1 -0
- package/dist/skills/tools/tts-tool.js +46 -0
- package/dist/skills/tools/tts-tool.js.map +1 -0
- package/dist/skills/tools/video-edit-tool.d.ts +70 -0
- package/dist/skills/tools/video-edit-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-edit-tool.js +75 -0
- package/dist/skills/tools/video-edit-tool.js.map +1 -0
- package/dist/skills/tools/video-generate-tool.d.ts +63 -0
- package/dist/skills/tools/video-generate-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-generate-tool.js +67 -0
- package/dist/skills/tools/video-generate-tool.js.map +1 -0
- package/dist/skills/tools/video-merge-tool.d.ts +106 -0
- package/dist/skills/tools/video-merge-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-merge-tool.js +93 -0
- package/dist/skills/tools/video-merge-tool.js.map +1 -0
- package/dist/skills/tools/video-upscale-tool.d.ts +46 -0
- package/dist/skills/tools/video-upscale-tool.d.ts.map +1 -0
- package/dist/skills/tools/video-upscale-tool.js +53 -0
- package/dist/skills/tools/video-upscale-tool.js.map +1 -0
- package/dist/skills/tools/web-fetch-tool.d.ts +79 -0
- package/dist/skills/tools/web-fetch-tool.d.ts.map +1 -0
- package/dist/skills/tools/web-fetch-tool.js +93 -0
- package/dist/skills/tools/web-fetch-tool.js.map +1 -0
- package/dist/skills/tools/web-search-tool.d.ts +58 -0
- package/dist/skills/tools/web-search-tool.d.ts.map +1 -0
- package/dist/skills/tools/web-search-tool.js +87 -0
- package/dist/skills/tools/web-search-tool.js.map +1 -0
- package/dist/skills/tools/worktree-tool.d.ts +70 -0
- package/dist/skills/tools/worktree-tool.d.ts.map +1 -0
- package/dist/skills/tools/worktree-tool.js +148 -0
- package/dist/skills/tools/worktree-tool.js.map +1 -0
- package/dist/skills/tools/write-tool.d.ts +46 -0
- package/dist/skills/tools/write-tool.d.ts.map +1 -0
- package/dist/skills/tools/write-tool.js +82 -0
- package/dist/skills/tools/write-tool.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill similarity — pure strategy for detecting near-duplicate skills
|
|
3
|
+
* before creation and during curator consolidation reviews.
|
|
4
|
+
*
|
|
5
|
+
* Computes multi-signal similarity between skills:
|
|
6
|
+
* 1. Tool-set Jaccard overlap (primary signal for auto-generated skills)
|
|
7
|
+
* 2. Title/description cosine bigram similarity (complementary signal)
|
|
8
|
+
* 3. Step-count proximity (minor signal for workflow complexity)
|
|
9
|
+
*
|
|
10
|
+
* No I/O — all functions are pure.
|
|
11
|
+
*/
|
|
12
|
+
/** Minimal skill profile for similarity comparison. */
|
|
13
|
+
export interface SkillSimilarityProfile {
|
|
14
|
+
skillKey: string;
|
|
15
|
+
title: string;
|
|
16
|
+
tools: readonly string[];
|
|
17
|
+
stepCount?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Result of a pairwise similarity comparison. */
|
|
20
|
+
export interface SimilarityScore {
|
|
21
|
+
/** Overall similarity [0, 1]. */
|
|
22
|
+
overall: number;
|
|
23
|
+
/** Tool-set Jaccard index [0, 1]. */
|
|
24
|
+
toolJaccard: number;
|
|
25
|
+
/** Title bigram similarity [0, 1]. */
|
|
26
|
+
titleSimilarity: number;
|
|
27
|
+
/** Step-count proximity [0, 1]. */
|
|
28
|
+
stepProximity: number;
|
|
29
|
+
}
|
|
30
|
+
/** A candidate detected as similar during pre-creation check. */
|
|
31
|
+
export interface SimilarSkillMatch {
|
|
32
|
+
existingSkillKey: string;
|
|
33
|
+
score: SimilarityScore;
|
|
34
|
+
}
|
|
35
|
+
/** Policy for similarity thresholds. */
|
|
36
|
+
export interface SkillSimilarityPolicy {
|
|
37
|
+
/**
|
|
38
|
+
* Overall similarity threshold to block creation and emit "improve"
|
|
39
|
+
* instead. Default: 0.75.
|
|
40
|
+
*/
|
|
41
|
+
blockCreationThreshold: number;
|
|
42
|
+
/**
|
|
43
|
+
* Overall similarity threshold to flag for curator review.
|
|
44
|
+
* Default: 0.55.
|
|
45
|
+
*/
|
|
46
|
+
curatorReviewThreshold: number;
|
|
47
|
+
/** Weight of toolJaccard in overall score. Default: 0.60. */
|
|
48
|
+
toolWeight: number;
|
|
49
|
+
/** Weight of titleSimilarity in overall score. Default: 0.30. */
|
|
50
|
+
titleWeight: number;
|
|
51
|
+
/** Weight of stepProximity in overall score. Default: 0.10. */
|
|
52
|
+
stepWeight: number;
|
|
53
|
+
}
|
|
54
|
+
export declare const DEFAULT_SKILL_SIMILARITY_POLICY: SkillSimilarityPolicy;
|
|
55
|
+
/**
|
|
56
|
+
* Compute Jaccard index between two tool sets.
|
|
57
|
+
* Returns 0 if both sets are empty.
|
|
58
|
+
*/
|
|
59
|
+
export declare function toolSetJaccard(toolsA: readonly string[], toolsB: readonly string[]): number;
|
|
60
|
+
/**
|
|
61
|
+
* Compute character-bigram similarity between two strings.
|
|
62
|
+
* Uses Dice coefficient of bigram sets.
|
|
63
|
+
*/
|
|
64
|
+
export declare function bigramSimilarity(a: string, b: string): number;
|
|
65
|
+
/**
|
|
66
|
+
* Compute step-count proximity [0, 1].
|
|
67
|
+
* Returns 1 when counts are identical, decreases with difference.
|
|
68
|
+
*/
|
|
69
|
+
export declare function stepCountProximity(stepsA: number | undefined, stepsB: number | undefined): number;
|
|
70
|
+
/**
|
|
71
|
+
* Compute overall similarity between two skill profiles.
|
|
72
|
+
*/
|
|
73
|
+
export declare function computeSimilarity(a: SkillSimilarityProfile, b: SkillSimilarityProfile, policy?: Partial<SkillSimilarityPolicy>): SimilarityScore;
|
|
74
|
+
/**
|
|
75
|
+
* Check a new skill candidate against existing skills for similarity.
|
|
76
|
+
*
|
|
77
|
+
* Returns all existing skills above curatorReviewThreshold, sorted
|
|
78
|
+
* by descending similarity. The caller should:
|
|
79
|
+
* - Block creation if any match ≥ blockCreationThreshold (emit improve instead)
|
|
80
|
+
* - Tag for curator review if match ≥ curatorReviewThreshold
|
|
81
|
+
*/
|
|
82
|
+
export declare function findSimilarSkills(newSkill: SkillSimilarityProfile, existingSkills: readonly SkillSimilarityProfile[], policy?: Partial<SkillSimilarityPolicy>): SimilarSkillMatch[];
|
|
83
|
+
/**
|
|
84
|
+
* Determine creation decision based on similarity matches.
|
|
85
|
+
*/
|
|
86
|
+
export type SimilarityDecision = {
|
|
87
|
+
action: "create";
|
|
88
|
+
reason: string;
|
|
89
|
+
} | {
|
|
90
|
+
action: "improve";
|
|
91
|
+
targetSkillKey: string;
|
|
92
|
+
reason: string;
|
|
93
|
+
} | {
|
|
94
|
+
action: "flag-for-review";
|
|
95
|
+
targetSkillKey: string;
|
|
96
|
+
reason: string;
|
|
97
|
+
};
|
|
98
|
+
export declare function decideSimilarityAction(matches: readonly SimilarSkillMatch[], policy?: Partial<SkillSimilarityPolicy>): SimilarityDecision;
|
|
99
|
+
//# sourceMappingURL=skill-similarity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-similarity.d.ts","sourceRoot":"","sources":["../../src/orchestration/skill-similarity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,uDAAuD;AACvD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,iEAAiE;AACjE,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,eAAe,CAAC;CACxB;AAED,wCAAwC;AACxC,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED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|
1
|
+
/**
|
|
2
|
+
* Skill similarity — pure strategy for detecting near-duplicate skills
|
|
3
|
+
* before creation and during curator consolidation reviews.
|
|
4
|
+
*
|
|
5
|
+
* Computes multi-signal similarity between skills:
|
|
6
|
+
* 1. Tool-set Jaccard overlap (primary signal for auto-generated skills)
|
|
7
|
+
* 2. Title/description cosine bigram similarity (complementary signal)
|
|
8
|
+
* 3. Step-count proximity (minor signal for workflow complexity)
|
|
9
|
+
*
|
|
10
|
+
* No I/O — all functions are pure.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_SKILL_SIMILARITY_POLICY = {
|
|
13
|
+
blockCreationThreshold: 0.75,
|
|
14
|
+
curatorReviewThreshold: 0.55,
|
|
15
|
+
toolWeight: 0.60,
|
|
16
|
+
titleWeight: 0.30,
|
|
17
|
+
stepWeight: 0.10,
|
|
18
|
+
};
|
|
19
|
+
// ── Core similarity functions ──────────────────────────────────────
|
|
20
|
+
/**
|
|
21
|
+
* Compute Jaccard index between two tool sets.
|
|
22
|
+
* Returns 0 if both sets are empty.
|
|
23
|
+
*/
|
|
24
|
+
export function toolSetJaccard(toolsA, toolsB) {
|
|
25
|
+
const setA = new Set(toolsA.map((t) => t.toLowerCase()));
|
|
26
|
+
const setB = new Set(toolsB.map((t) => t.toLowerCase()));
|
|
27
|
+
if (setA.size === 0 && setB.size === 0)
|
|
28
|
+
return 0;
|
|
29
|
+
let intersection = 0;
|
|
30
|
+
for (const t of setA) {
|
|
31
|
+
if (setB.has(t))
|
|
32
|
+
intersection++;
|
|
33
|
+
}
|
|
34
|
+
const union = setA.size + setB.size - intersection;
|
|
35
|
+
return union === 0 ? 0 : intersection / union;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Compute character-bigram similarity between two strings.
|
|
39
|
+
* Uses Dice coefficient of bigram sets.
|
|
40
|
+
*/
|
|
41
|
+
export function bigramSimilarity(a, b) {
|
|
42
|
+
const bigramsA = extractBigrams(a.toLowerCase());
|
|
43
|
+
const bigramsB = extractBigrams(b.toLowerCase());
|
|
44
|
+
if (bigramsA.size === 0 && bigramsB.size === 0)
|
|
45
|
+
return 0;
|
|
46
|
+
if (bigramsA.size === 0 || bigramsB.size === 0)
|
|
47
|
+
return 0;
|
|
48
|
+
let intersection = 0;
|
|
49
|
+
for (const bg of bigramsA) {
|
|
50
|
+
if (bigramsB.has(bg))
|
|
51
|
+
intersection++;
|
|
52
|
+
}
|
|
53
|
+
// Dice coefficient = 2 * |intersection| / (|A| + |B|)
|
|
54
|
+
return (2 * intersection) / (bigramsA.size + bigramsB.size);
|
|
55
|
+
}
|
|
56
|
+
function extractBigrams(s) {
|
|
57
|
+
const bigrams = new Set();
|
|
58
|
+
const normalized = s.replace(/[^a-z0-9\u4e00-\u9fff]/g, " ").trim();
|
|
59
|
+
for (let i = 0; i < normalized.length - 1; i++) {
|
|
60
|
+
bigrams.add(normalized.slice(i, i + 2));
|
|
61
|
+
}
|
|
62
|
+
return bigrams;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Compute step-count proximity [0, 1].
|
|
66
|
+
* Returns 1 when counts are identical, decreases with difference.
|
|
67
|
+
*/
|
|
68
|
+
export function stepCountProximity(stepsA, stepsB) {
|
|
69
|
+
if (stepsA == null || stepsB == null)
|
|
70
|
+
return 0.5; // neutral if unknown
|
|
71
|
+
if (stepsA === 0 && stepsB === 0)
|
|
72
|
+
return 1;
|
|
73
|
+
const diff = Math.abs(stepsA - stepsB);
|
|
74
|
+
const max = Math.max(stepsA, stepsB);
|
|
75
|
+
return 1 - diff / max;
|
|
76
|
+
}
|
|
77
|
+
// ── Composite similarity ───────────────────────────────────────────
|
|
78
|
+
/**
|
|
79
|
+
* Compute overall similarity between two skill profiles.
|
|
80
|
+
*/
|
|
81
|
+
export function computeSimilarity(a, b, policy) {
|
|
82
|
+
const resolved = { ...DEFAULT_SKILL_SIMILARITY_POLICY, ...policy };
|
|
83
|
+
const toolJaccard = toolSetJaccard(a.tools, b.tools);
|
|
84
|
+
const titleSimilarity = bigramSimilarity(a.title, b.title);
|
|
85
|
+
const stepProximity = stepCountProximity(a.stepCount, b.stepCount);
|
|
86
|
+
const overall = resolved.toolWeight * toolJaccard +
|
|
87
|
+
resolved.titleWeight * titleSimilarity +
|
|
88
|
+
resolved.stepWeight * stepProximity;
|
|
89
|
+
return { overall, toolJaccard, titleSimilarity, stepProximity };
|
|
90
|
+
}
|
|
91
|
+
// ── Pre-creation duplicate check ───────────────────────────────────
|
|
92
|
+
/**
|
|
93
|
+
* Check a new skill candidate against existing skills for similarity.
|
|
94
|
+
*
|
|
95
|
+
* Returns all existing skills above curatorReviewThreshold, sorted
|
|
96
|
+
* by descending similarity. The caller should:
|
|
97
|
+
* - Block creation if any match ≥ blockCreationThreshold (emit improve instead)
|
|
98
|
+
* - Tag for curator review if match ≥ curatorReviewThreshold
|
|
99
|
+
*/
|
|
100
|
+
export function findSimilarSkills(newSkill, existingSkills, policy) {
|
|
101
|
+
const resolved = { ...DEFAULT_SKILL_SIMILARITY_POLICY, ...policy };
|
|
102
|
+
const matches = [];
|
|
103
|
+
for (const existing of existingSkills) {
|
|
104
|
+
if (existing.skillKey === newSkill.skillKey)
|
|
105
|
+
continue; // skip self
|
|
106
|
+
const score = computeSimilarity(newSkill, existing, resolved);
|
|
107
|
+
if (score.overall >= resolved.curatorReviewThreshold) {
|
|
108
|
+
matches.push({ existingSkillKey: existing.skillKey, score });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return matches.sort((a, b) => b.score.overall - a.score.overall);
|
|
112
|
+
}
|
|
113
|
+
export function decideSimilarityAction(matches, policy) {
|
|
114
|
+
const resolved = { ...DEFAULT_SKILL_SIMILARITY_POLICY, ...policy };
|
|
115
|
+
if (matches.length === 0) {
|
|
116
|
+
return { action: "create", reason: "no similar skills found" };
|
|
117
|
+
}
|
|
118
|
+
const top = matches[0];
|
|
119
|
+
if (top.score.overall >= resolved.blockCreationThreshold) {
|
|
120
|
+
return {
|
|
121
|
+
action: "improve",
|
|
122
|
+
targetSkillKey: top.existingSkillKey,
|
|
123
|
+
reason: `similarity ${(top.score.overall * 100).toFixed(0)}% ≥ creation threshold ${(resolved.blockCreationThreshold * 100).toFixed(0)}% (tool overlap: ${(top.score.toolJaccard * 100).toFixed(0)}%)`,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
action: "flag-for-review",
|
|
128
|
+
targetSkillKey: top.existingSkillKey,
|
|
129
|
+
reason: `similarity ${(top.score.overall * 100).toFixed(0)}% between review and creation thresholds`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=skill-similarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-similarity.js","sourceRoot":"","sources":["../../src/orchestration/skill-similarity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAkDH,MAAM,CAAC,MAAM,+BAA+B,GAA0B;IACpE,sBAAsB,EAAE,IAAI;IAC5B,sBAAsB,EAAE,IAAI;IAC5B,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,IAAI;CACjB,CAAC;AAEF,sEAAsE;AAEtE;;;GAGG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAyB,EACzB,MAAyB;IAEzB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;IAEzD,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAEjD,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,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GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,sBAAsB,EAAE,CAAC;QACzD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,cAAc,EAAE,GAAG,CAAC,gBAAgB;YACpC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,0BAA0B,CAAC,QAAQ,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI;SACvM,CAAC;IACJ,CAAC;IAED,OAAO;QACL,MAAM,EAAE,iBAAiB;QACzB,cAAc,EAAE,GAAG,CAAC,gBAAgB;QACpC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,0CAA0C;KACrG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StreamingToolExecutor — Executes tool calls as they arrive during LLM streaming.
|
|
3
|
+
*
|
|
4
|
+
* Aligned with Claude Code's StreamingToolExecutor pattern:
|
|
5
|
+
* - As each complete tool_use block arrives during streaming, immediately dispatch execution
|
|
6
|
+
* - Don't wait for the full LLM response to finish before starting tool execution
|
|
7
|
+
* - Results queue up and can be collected at any time
|
|
8
|
+
*
|
|
9
|
+
* This reduces perceived latency by overlapping LLM generation time with tool execution time.
|
|
10
|
+
*/
|
|
11
|
+
export interface StreamingToolCall {
|
|
12
|
+
id: string;
|
|
13
|
+
function: {
|
|
14
|
+
name: string;
|
|
15
|
+
arguments: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface StreamingToolResult<T = unknown> {
|
|
19
|
+
toolCallId: string;
|
|
20
|
+
toolName: string;
|
|
21
|
+
result: T;
|
|
22
|
+
ok: boolean;
|
|
23
|
+
startedAt: number;
|
|
24
|
+
completedAt: number;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface StreamingToolExecutorConfig {
|
|
28
|
+
/** Maximum concurrent tool executions (default: 8) */
|
|
29
|
+
maxConcurrency: number;
|
|
30
|
+
/** Abort signal for cancellation */
|
|
31
|
+
abortSignal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
export type ToolExecutorFn<T = unknown> = (toolCall: StreamingToolCall, abortSignal?: AbortSignal) => Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Streaming tool executor that dispatches tool calls immediately as they complete
|
|
36
|
+
* during LLM streaming output, rather than waiting for the full response.
|
|
37
|
+
*
|
|
38
|
+
* Usage:
|
|
39
|
+
* ```ts
|
|
40
|
+
* const executor = createStreamingToolExecutor(executeFn, { maxConcurrency: 4 });
|
|
41
|
+
* // During streaming, as each tool block completes:
|
|
42
|
+
* executor.addTool(toolCall);
|
|
43
|
+
* // Periodically collect completed results:
|
|
44
|
+
* const results = executor.getCompletedResults();
|
|
45
|
+
* // After streaming ends, wait for all remaining:
|
|
46
|
+
* const allResults = await executor.flush();
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export interface StreamingToolExecutor<T = unknown> {
|
|
50
|
+
/** Add a tool call for immediate execution. Returns false if at capacity. */
|
|
51
|
+
addTool(toolCall: StreamingToolCall): boolean;
|
|
52
|
+
/** Get results that have completed since last call (non-blocking). */
|
|
53
|
+
getCompletedResults(): StreamingToolResult<T>[];
|
|
54
|
+
/** Wait for all pending tool calls to complete and return all results. */
|
|
55
|
+
flush(): Promise<StreamingToolResult<T>[]>;
|
|
56
|
+
/** Number of currently executing tool calls. */
|
|
57
|
+
readonly pendingCount: number;
|
|
58
|
+
/** Total number of tool calls dispatched. */
|
|
59
|
+
readonly dispatchedCount: number;
|
|
60
|
+
/** Whether the executor has been aborted. */
|
|
61
|
+
readonly aborted: boolean;
|
|
62
|
+
}
|
|
63
|
+
export declare function createStreamingToolExecutor<T = unknown>(executeFn: ToolExecutorFn<T>, config?: Partial<StreamingToolExecutorConfig>): StreamingToolExecutor<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Determine if a tool call can be dispatched immediately during streaming
|
|
66
|
+
* based on its manifest properties.
|
|
67
|
+
*/
|
|
68
|
+
export declare function canDispatchDuringStreaming(toolCall: StreamingToolCall, manifest?: {
|
|
69
|
+
approvalMode?: "user-confirm" | "pre-authorized";
|
|
70
|
+
requiresApproval?: boolean;
|
|
71
|
+
serialOnly?: boolean;
|
|
72
|
+
parallelSafe?: boolean;
|
|
73
|
+
}): boolean;
|
|
74
|
+
//# sourceMappingURL=streaming-tool-executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-tool-executor.d.ts","sourceRoot":"","sources":["../../src/orchestration/streaming-tool-executor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,GAAG,OAAO;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,CAAC,CAAC;IACV,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,2BAA2B;IAC1C,sDAAsD;IACtD,cAAc,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B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Code's StreamingToolExecutor pattern:
|
|
5
|
+
* - As each complete tool_use block arrives during streaming, immediately dispatch execution
|
|
6
|
+
* - Don't wait for the full LLM response to finish before starting tool execution
|
|
7
|
+
* - Results queue up and can be collected at any time
|
|
8
|
+
*
|
|
9
|
+
* This reduces perceived latency by overlapping LLM generation time with tool execution time.
|
|
10
|
+
*/
|
|
11
|
+
export function createStreamingToolExecutor(executeFn, config = {}) {
|
|
12
|
+
const maxConcurrency = Math.max(1, config.maxConcurrency ?? 8);
|
|
13
|
+
const abortSignal = config.abortSignal;
|
|
14
|
+
const pending = [];
|
|
15
|
+
const completedQueue = [];
|
|
16
|
+
let dispatchedCount = 0;
|
|
17
|
+
let aborted = false;
|
|
18
|
+
if (abortSignal) {
|
|
19
|
+
abortSignal.addEventListener("abort", () => { aborted = true; }, { once: true });
|
|
20
|
+
}
|
|
21
|
+
function addTool(toolCall) {
|
|
22
|
+
if (aborted)
|
|
23
|
+
return false;
|
|
24
|
+
if (pending.length >= maxConcurrency)
|
|
25
|
+
return false;
|
|
26
|
+
dispatchedCount += 1;
|
|
27
|
+
const startedAt = Date.now();
|
|
28
|
+
const entry = {
|
|
29
|
+
toolCallId: toolCall.id,
|
|
30
|
+
toolName: toolCall.function.name,
|
|
31
|
+
startedAt,
|
|
32
|
+
promise: executeFn(toolCall, abortSignal)
|
|
33
|
+
.then((result) => ({
|
|
34
|
+
toolCallId: toolCall.id,
|
|
35
|
+
toolName: toolCall.function.name,
|
|
36
|
+
result,
|
|
37
|
+
ok: true,
|
|
38
|
+
startedAt,
|
|
39
|
+
completedAt: Date.now(),
|
|
40
|
+
}))
|
|
41
|
+
.catch((err) => ({
|
|
42
|
+
toolCallId: toolCall.id,
|
|
43
|
+
toolName: toolCall.function.name,
|
|
44
|
+
result: undefined,
|
|
45
|
+
ok: false,
|
|
46
|
+
startedAt,
|
|
47
|
+
completedAt: Date.now(),
|
|
48
|
+
error: err instanceof Error ? err.message : String(err),
|
|
49
|
+
}))
|
|
50
|
+
.then((result) => {
|
|
51
|
+
// Move from pending to completed queue
|
|
52
|
+
const idx = pending.indexOf(entry);
|
|
53
|
+
if (idx >= 0)
|
|
54
|
+
pending.splice(idx, 1);
|
|
55
|
+
completedQueue.push(result);
|
|
56
|
+
return result;
|
|
57
|
+
}),
|
|
58
|
+
};
|
|
59
|
+
pending.push(entry);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
function getCompletedResults() {
|
|
63
|
+
const results = completedQueue.splice(0);
|
|
64
|
+
return results;
|
|
65
|
+
}
|
|
66
|
+
async function flush() {
|
|
67
|
+
if (pending.length > 0) {
|
|
68
|
+
await Promise.allSettled(pending.map((e) => e.promise));
|
|
69
|
+
}
|
|
70
|
+
return completedQueue.splice(0);
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
addTool,
|
|
74
|
+
getCompletedResults,
|
|
75
|
+
flush,
|
|
76
|
+
get pendingCount() { return pending.length; },
|
|
77
|
+
get dispatchedCount() { return dispatchedCount; },
|
|
78
|
+
get aborted() { return aborted; },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Determine if a tool call can be dispatched immediately during streaming
|
|
83
|
+
* based on its manifest properties.
|
|
84
|
+
*/
|
|
85
|
+
export function canDispatchDuringStreaming(toolCall, manifest) {
|
|
86
|
+
if (!manifest)
|
|
87
|
+
return false;
|
|
88
|
+
// Cannot dispatch during streaming if it requires user approval
|
|
89
|
+
if (manifest.approvalMode === "user-confirm" || manifest.requiresApproval)
|
|
90
|
+
return false;
|
|
91
|
+
// Cannot dispatch if explicitly serial-only
|
|
92
|
+
if (manifest.serialOnly)
|
|
93
|
+
return false;
|
|
94
|
+
// Safe to dispatch during streaming
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=streaming-tool-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streaming-tool-executor.js","sourceRoot":"","sources":["../../src/orchestration/strea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AO;QACL,OAAO;QACP,mBAAmB;QACnB,KAAK;QACL,IAAI,YAAY,KAAK,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C,IAAI,eAAe,KAAK,OAAO,eAAe,CAAC,CAAC,CAAC;QACjD,IAAI,OAAO,KAAK,OAAO,OAAO,CAAC,CAAC,CAAC;KAClC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAA2B,EAAE,QAKvE;IACC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,gEAAgE;IAChE,IAAI,QAAQ,CAAC,YAAY,KAAK,cAAc,IAAI,QAAQ,CAAC,gBAAgB;QAAE,OAAO,KAAK,CAAC;IACxF,4CAA4C;IAC5C,IAAI,QAAQ,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IACtC,oCAAoC;IACpC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Team Orchestration Strategy — multi-agent coordination layer.
|
|
3
|
+
*
|
|
4
|
+
* Extends the existing sidechain foundation with team/swarm semantics:
|
|
5
|
+
* - Parallel agent spawning (multiple sidechains at once)
|
|
6
|
+
* - Role-based agent assignment (planner / executor / reviewer)
|
|
7
|
+
* - Shared knowledge pool via merge policies
|
|
8
|
+
* - Budget-aware concurrency limits
|
|
9
|
+
* - Lifecycle state machine for team coordination
|
|
10
|
+
*
|
|
11
|
+
* Architecture:
|
|
12
|
+
* Gateway ─── Hub ─── orchestration (this module, pure strategy)
|
|
13
|
+
* │
|
|
14
|
+
* ┌───────────┼───────────┐
|
|
15
|
+
* │ TeamCoordinator │ ← Hub runtime (multi-sidechain-coordinator.ts)
|
|
16
|
+
* │ │ │
|
|
17
|
+
* │ ├── Agent #1 (planner)
|
|
18
|
+
* │ ├── Agent #2 (executor)
|
|
19
|
+
* │ └── Agent #3 (reviewer)
|
|
20
|
+
* └───────────────────────┘
|
|
21
|
+
*
|
|
22
|
+
* This module provides:
|
|
23
|
+
* 1. Type definitions (TeamPlan, AgentRole, TeamLifecycle)
|
|
24
|
+
* 2. Pure strategy functions (plan resolution, role assignment, budget allocation)
|
|
25
|
+
* 3. Merge/aggregation policies (how agent results combine)
|
|
26
|
+
*
|
|
27
|
+
* Hub consumes these types and strategy functions in its coordinator runtime.
|
|
28
|
+
* Gateway consumes TeamPlan to spawn/manage multiple sidechain executions.
|
|
29
|
+
*/
|
|
30
|
+
import type { SidechainType, SidechainMergePolicy, SidechainBudgetTier, SidechainToolAccessMode } from "./index.js";
|
|
31
|
+
/** Roles an agent can take within a team execution. */
|
|
32
|
+
export type AgentRole = "planner" | "executor" | "reviewer" | "researcher" | "custom";
|
|
33
|
+
/** Execution mode for a team. */
|
|
34
|
+
export type TeamExecutionMode = "parallel" | "sequential" | "pipeline" | "adaptive";
|
|
35
|
+
/** How team results are aggregated into the parent execution. */
|
|
36
|
+
export type TeamAggregationPolicy = "first-success" | "majority-vote" | "merge-all" | "reviewer-gate" | "planner-sync";
|
|
37
|
+
/** Current lifecycle state of a team execution. */
|
|
38
|
+
export type TeamLifecycleState = "planning" | "spawning" | "executing" | "aggregating" | "reviewing" | "completed" | "failed" | "cancelled";
|
|
39
|
+
/** Specification for a single agent within a team. */
|
|
40
|
+
export interface TeamAgentSpec {
|
|
41
|
+
/** Unique ID within the team (e.g., "agent-1", "researcher-a"). */
|
|
42
|
+
agentId: string;
|
|
43
|
+
/** Role this agent plays. */
|
|
44
|
+
role: AgentRole;
|
|
45
|
+
/** Human-readable label for tracing. */
|
|
46
|
+
label: string;
|
|
47
|
+
/** The sidechain type this agent maps to. */
|
|
48
|
+
sidechainType: SidechainType;
|
|
49
|
+
/** Task description / system prompt override for this agent. */
|
|
50
|
+
taskDescription: string;
|
|
51
|
+
/** Tool access mode for this agent's sidechain. */
|
|
52
|
+
toolAccessMode: SidechainToolAccessMode;
|
|
53
|
+
/** Budget tier for this agent. */
|
|
54
|
+
budgetTier: SidechainBudgetTier;
|
|
55
|
+
/** Which agents this one depends on (for sequential/pipeline modes). */
|
|
56
|
+
dependsOn: string[];
|
|
57
|
+
/** Maximum tokens this agent can consume. */
|
|
58
|
+
maxTokenBudget: number;
|
|
59
|
+
/** Maximum tool calls this agent can make. */
|
|
60
|
+
maxToolCalls: number;
|
|
61
|
+
/** Timeout in milliseconds (0 = inherit from team). */
|
|
62
|
+
timeoutMs: number;
|
|
63
|
+
}
|
|
64
|
+
/** A complete team execution plan. */
|
|
65
|
+
export interface TeamPlan {
|
|
66
|
+
/** Unique team execution ID. */
|
|
67
|
+
teamId: string;
|
|
68
|
+
/** Execution mode for this team. */
|
|
69
|
+
mode: TeamExecutionMode;
|
|
70
|
+
/** How results from all agents are aggregated. */
|
|
71
|
+
aggregationPolicy: TeamAggregationPolicy;
|
|
72
|
+
/** All agent specs in this team. */
|
|
73
|
+
agents: TeamAgentSpec[];
|
|
74
|
+
/** Maximum concurrent agent executions (0 = unlimited). */
|
|
75
|
+
maxConcurrency: number;
|
|
76
|
+
/** Team-level timeout in ms (0 = no timeout). */
|
|
77
|
+
timeoutMs: number;
|
|
78
|
+
/** Total token budget across all agents. */
|
|
79
|
+
totalTokenBudget: number;
|
|
80
|
+
/** Whether early termination is allowed when one agent fails. */
|
|
81
|
+
failFast: boolean;
|
|
82
|
+
/** Shared context provided to all agents. */
|
|
83
|
+
sharedContext: string;
|
|
84
|
+
/** Merge policy for the final team output back to parent. */
|
|
85
|
+
mergePolicy: SidechainMergePolicy;
|
|
86
|
+
}
|
|
87
|
+
/** Result from a single agent within a team. */
|
|
88
|
+
export interface TeamAgentResult {
|
|
89
|
+
agentId: string;
|
|
90
|
+
role: AgentRole;
|
|
91
|
+
status: "completed" | "failed" | "cancelled" | "timeout";
|
|
92
|
+
output: string;
|
|
93
|
+
tokenUsage: {
|
|
94
|
+
prompt: number;
|
|
95
|
+
completion: number;
|
|
96
|
+
};
|
|
97
|
+
toolCallCount: number;
|
|
98
|
+
durationMs: number;
|
|
99
|
+
error?: string;
|
|
100
|
+
}
|
|
101
|
+
/** Aggregated result from team execution. */
|
|
102
|
+
export interface TeamResult {
|
|
103
|
+
teamId: string;
|
|
104
|
+
state: TeamLifecycleState;
|
|
105
|
+
agentResults: TeamAgentResult[];
|
|
106
|
+
aggregatedOutput: string;
|
|
107
|
+
totalTokenUsage: {
|
|
108
|
+
prompt: number;
|
|
109
|
+
completion: number;
|
|
110
|
+
};
|
|
111
|
+
totalDurationMs: number;
|
|
112
|
+
}
|
|
113
|
+
/** Maximum agents allowed in a team (safety bound). */
|
|
114
|
+
export declare const TEAM_MAX_AGENTS = 8;
|
|
115
|
+
/** Maximum recursion depth (teams spawning teams). */
|
|
116
|
+
export declare const TEAM_MAX_DEPTH = 2;
|
|
117
|
+
/**
|
|
118
|
+
* Resolve a team plan from a high-level task decomposition.
|
|
119
|
+
*
|
|
120
|
+
* This is the main entry point: given a set of subtasks and constraints,
|
|
121
|
+
* produce a concrete TeamPlan that the coordinator can execute.
|
|
122
|
+
*/
|
|
123
|
+
export declare function resolveTeamPlan(params: {
|
|
124
|
+
teamId: string;
|
|
125
|
+
subtasks: Array<{
|
|
126
|
+
id: string;
|
|
127
|
+
role: AgentRole;
|
|
128
|
+
label: string;
|
|
129
|
+
task: string;
|
|
130
|
+
dependsOn?: string[];
|
|
131
|
+
}>;
|
|
132
|
+
mode?: TeamExecutionMode;
|
|
133
|
+
aggregationPolicy?: TeamAggregationPolicy;
|
|
134
|
+
totalTokenBudget?: number;
|
|
135
|
+
timeoutMs?: number;
|
|
136
|
+
failFast?: boolean;
|
|
137
|
+
sharedContext?: string;
|
|
138
|
+
mergePolicy?: SidechainMergePolicy;
|
|
139
|
+
}): TeamPlan;
|
|
140
|
+
/**
|
|
141
|
+
* Map agent role to sidechain type for existing Hub plumbing compatibility.
|
|
142
|
+
*/
|
|
143
|
+
export declare function mapRoleToSidechainType(role: AgentRole): SidechainType;
|
|
144
|
+
/**
|
|
145
|
+
* Resolve tool access mode for a given role.
|
|
146
|
+
*/
|
|
147
|
+
export declare function resolveAgentToolAccess(role: AgentRole): SidechainToolAccessMode;
|
|
148
|
+
/**
|
|
149
|
+
* Allocate token budgets proportionally by role weight.
|
|
150
|
+
*/
|
|
151
|
+
export declare function allocateTokenBudgets(agents: TeamAgentSpec[], totalBudget: number): TeamAgentSpec[];
|
|
152
|
+
/**
|
|
153
|
+
* Infer execution mode from agent dependency graph.
|
|
154
|
+
*/
|
|
155
|
+
export declare function inferExecutionMode(agents: TeamAgentSpec[]): TeamExecutionMode;
|
|
156
|
+
/**
|
|
157
|
+
* Infer aggregation policy from mode and agent composition.
|
|
158
|
+
*/
|
|
159
|
+
export declare function inferAggregationPolicy(mode: TeamExecutionMode, agents: TeamAgentSpec[]): TeamAggregationPolicy;
|
|
160
|
+
/**
|
|
161
|
+
* Determine the execution order for agents given their dependency graph.
|
|
162
|
+
* Returns groups of agent IDs that can execute concurrently.
|
|
163
|
+
*
|
|
164
|
+
* Example: [[planner], [executor-a, executor-b], [reviewer]]
|
|
165
|
+
*/
|
|
166
|
+
export declare function resolveExecutionOrder(agents: TeamAgentSpec[]): string[][];
|
|
167
|
+
/**
|
|
168
|
+
* Aggregate team results into a single output string.
|
|
169
|
+
*/
|
|
170
|
+
export declare function aggregateTeamResults(results: TeamAgentResult[], policy: TeamAggregationPolicy): string;
|
|
171
|
+
/**
|
|
172
|
+
* Validate a team plan before execution.
|
|
173
|
+
* Returns a list of issues (empty = valid).
|
|
174
|
+
*/
|
|
175
|
+
export declare function validateTeamPlan(plan: TeamPlan): string[];
|
|
176
|
+
/**
|
|
177
|
+
* Determine if a team execution should be cancelled early based on current state.
|
|
178
|
+
*/
|
|
179
|
+
export declare function shouldCancelTeam(params: {
|
|
180
|
+
plan: TeamPlan;
|
|
181
|
+
results: TeamAgentResult[];
|
|
182
|
+
elapsedMs: number;
|
|
183
|
+
}): {
|
|
184
|
+
cancel: boolean;
|
|
185
|
+
reason: string;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Build the task prompt for a specific agent, incorporating shared context
|
|
189
|
+
* and outputs from dependency agents.
|
|
190
|
+
*/
|
|
191
|
+
export declare function buildAgentTaskPrompt(params: {
|
|
192
|
+
agent: TeamAgentSpec;
|
|
193
|
+
plan: TeamPlan;
|
|
194
|
+
dependencyResults: TeamAgentResult[];
|
|
195
|
+
}): string;
|
|
196
|
+
//# sourceMappingURL=team-orchestration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-orchestration.d.ts","sourceRoot":"","sources":["../../src/orchestration/team-orchestration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAMpH,uDAAuD;AACvD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,CAAC;AAEtF,iCAAiC;AACjC,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,YAAY,GACZ,UAAU,GACV,UAAU,CAAC;AAEf,iEAAiE;AACjE,MAAM,MAAM,qBAAqB,GAC7B,eAAe,GACf,eAAe,GACf,WAAW,GACX,eAAe,GACf,cAAc,CAAC;AAEnB,mDAAmD;AACnD,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,UAAU,GACV,WAAW,GACX,aAAa,GACb,WAAW,GACX,WAAW,GACX,QAAQ,GACR,WAAW,CAAC;AAMhB,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAC;IAChB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,aAAa,EAAE,aAAa,CAAC;IAC7B,gEAAgE;IAChE,eAAe,EA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