openhorse 0.2.19 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/coordinator.d.ts.map +1 -1
- package/dist/agents/fork.d.ts.map +1 -1
- package/dist/agents/fork.js +0 -1
- package/dist/agents/fork.js.map +1 -1
- package/dist/agents/worker-pool.d.ts.map +1 -1
- package/dist/agents/worker-pool.js +3 -1
- package/dist/agents/worker-pool.js.map +1 -1
- package/dist/cli.js +28 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +202 -77
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/parser.d.ts.map +1 -1
- package/dist/commands/parser.js +8 -3
- package/dist/commands/parser.js.map +1 -1
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/core/checkpoint.d.ts.map +1 -1
- package/dist/core/checkpoint.js +3 -0
- package/dist/core/checkpoint.js.map +1 -1
- package/dist/core/cost-tracker.d.ts +45 -5
- package/dist/core/cost-tracker.d.ts.map +1 -1
- package/dist/core/cost-tracker.js +78 -13
- package/dist/core/cost-tracker.js.map +1 -1
- package/dist/framework/index.d.ts +1 -1
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js.map +1 -1
- package/dist/framework/prompt.d.ts.map +1 -1
- package/dist/framework/prompt.js +16 -0
- package/dist/framework/prompt.js.map +1 -1
- package/dist/framework/query.d.ts +25 -0
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +196 -56
- package/dist/framework/query.js.map +1 -1
- package/dist/framework/store.d.ts +6 -1
- package/dist/framework/store.d.ts.map +1 -1
- package/dist/framework/store.js +10 -1
- package/dist/framework/store.js.map +1 -1
- package/dist/harness/context-harness.d.ts.map +1 -1
- package/dist/harness/context-harness.js +6 -1
- package/dist/harness/context-harness.js.map +1 -1
- package/dist/harness/ledger.d.ts +1 -0
- package/dist/harness/ledger.d.ts.map +1 -1
- package/dist/harness/ledger.js +12 -0
- package/dist/harness/ledger.js.map +1 -1
- package/dist/harness/safety.d.ts +2 -0
- package/dist/harness/safety.d.ts.map +1 -1
- package/dist/harness/safety.js +27 -3
- package/dist/harness/safety.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/ink-ui/components/Markdown.d.ts +1 -1
- package/dist/ink-ui/components/Markdown.d.ts.map +1 -1
- package/dist/ink-ui/components/Markdown.js +1 -1
- package/dist/ink-ui/components/Markdown.js.map +1 -1
- package/dist/ink-ui/components/StatusLine.d.ts.map +1 -1
- package/dist/ink-ui/components/StatusLine.js +0 -2
- package/dist/ink-ui/components/StatusLine.js.map +1 -1
- package/dist/ink-ui/runtime/grapheme.d.ts +9 -8
- package/dist/ink-ui/runtime/grapheme.d.ts.map +1 -1
- package/dist/ink-ui/runtime/grapheme.js +14 -60
- package/dist/ink-ui/runtime/grapheme.js.map +1 -1
- package/dist/ink-ui/runtime/input-buffer.d.ts +9 -31
- package/dist/ink-ui/runtime/input-buffer.d.ts.map +1 -1
- package/dist/ink-ui/runtime/input-buffer.js +15 -162
- package/dist/ink-ui/runtime/input-buffer.js.map +1 -1
- package/dist/ink-ui/runtime/native-cursor.js +0 -25
- package/dist/ink-ui/runtime/native-cursor.js.map +1 -1
- package/dist/ink-ui/runtime/prompt-layout.d.ts +9 -29
- package/dist/ink-ui/runtime/prompt-layout.d.ts.map +1 -1
- package/dist/ink-ui/runtime/prompt-layout.js +18 -166
- package/dist/ink-ui/runtime/prompt-layout.js.map +1 -1
- package/dist/ink-ui/runtime/transcript-state.d.ts.map +1 -1
- package/dist/ink-ui/runtime/transcript-state.js +2 -0
- package/dist/ink-ui/runtime/transcript-state.js.map +1 -1
- package/dist/ink-ui/screens/ReplScreen.d.ts.map +1 -1
- package/dist/ink-ui/screens/ReplScreen.js +23 -5
- package/dist/ink-ui/screens/ReplScreen.js.map +1 -1
- package/dist/memory/entrypoint.js +1 -1
- package/dist/memory/entrypoint.js.map +1 -1
- package/dist/memory/storage.js +1 -1
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/store.d.ts +1 -0
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +9 -0
- package/dist/memory/store.js.map +1 -1
- package/dist/runtime/agent-runtime-controller.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-controller.js +25 -0
- package/dist/runtime/agent-runtime-controller.js.map +1 -1
- package/dist/runtime/agent-runtime-protocol.d.ts +4 -1
- package/dist/runtime/agent-runtime-protocol.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-protocol.js +6 -0
- package/dist/runtime/agent-runtime-protocol.js.map +1 -1
- package/dist/runtime/chat-controller.d.ts +27 -0
- package/dist/runtime/chat-controller.d.ts.map +1 -1
- package/dist/runtime/chat-controller.js +374 -88
- package/dist/runtime/chat-controller.js.map +1 -1
- package/dist/runtime/composer/buffer.d.ts +43 -0
- package/dist/runtime/composer/buffer.d.ts.map +1 -0
- package/dist/runtime/composer/buffer.js +176 -0
- package/dist/runtime/composer/buffer.js.map +1 -0
- package/dist/runtime/composer/grapheme.d.ts +19 -0
- package/dist/runtime/composer/grapheme.d.ts.map +1 -0
- package/dist/runtime/composer/grapheme.js +73 -0
- package/dist/runtime/composer/grapheme.js.map +1 -0
- package/dist/runtime/composer/history.d.ts +39 -0
- package/dist/runtime/composer/history.d.ts.map +1 -0
- package/dist/runtime/composer/history.js +91 -0
- package/dist/runtime/composer/history.js.map +1 -0
- package/dist/runtime/composer/layout.d.ts +40 -0
- package/dist/runtime/composer/layout.d.ts.map +1 -0
- package/dist/runtime/composer/layout.js +174 -0
- package/dist/runtime/composer/layout.js.map +1 -0
- package/dist/runtime/rich-text/ansi-parser.d.ts +31 -0
- package/dist/runtime/rich-text/ansi-parser.d.ts.map +1 -0
- package/dist/runtime/rich-text/ansi-parser.js +310 -0
- package/dist/runtime/rich-text/ansi-parser.js.map +1 -0
- package/dist/runtime/rich-text/layout.d.ts +12 -0
- package/dist/runtime/rich-text/layout.d.ts.map +1 -0
- package/dist/runtime/rich-text/layout.js +362 -0
- package/dist/runtime/rich-text/layout.js.map +1 -0
- package/dist/runtime/rich-text/markdown-parser.d.ts +17 -0
- package/dist/runtime/rich-text/markdown-parser.d.ts.map +1 -0
- package/dist/runtime/rich-text/markdown-parser.js +218 -0
- package/dist/runtime/rich-text/markdown-parser.js.map +1 -0
- package/dist/runtime/rich-text/sanitizer.d.ts +18 -0
- package/dist/runtime/rich-text/sanitizer.d.ts.map +1 -0
- package/dist/runtime/rich-text/sanitizer.js +32 -0
- package/dist/runtime/rich-text/sanitizer.js.map +1 -0
- package/dist/runtime/rich-text/types.d.ts +59 -0
- package/dist/runtime/rich-text/types.d.ts.map +1 -0
- package/dist/runtime/rich-text/types.js +17 -0
- package/dist/runtime/rich-text/types.js.map +1 -0
- package/dist/runtime/subagents/budget.d.ts +118 -0
- package/dist/runtime/subagents/budget.d.ts.map +1 -0
- package/dist/runtime/subagents/budget.js +173 -0
- package/dist/runtime/subagents/budget.js.map +1 -0
- package/dist/runtime/subagents/child-executor-guard.d.ts +60 -0
- package/dist/runtime/subagents/child-executor-guard.d.ts.map +1 -0
- package/dist/runtime/subagents/child-executor-guard.js +219 -0
- package/dist/runtime/subagents/child-executor-guard.js.map +1 -0
- package/dist/runtime/subagents/context-builder.d.ts +34 -0
- package/dist/runtime/subagents/context-builder.d.ts.map +1 -0
- package/dist/runtime/subagents/context-builder.js +99 -0
- package/dist/runtime/subagents/context-builder.js.map +1 -0
- package/dist/runtime/subagents/index.d.ts +21 -0
- package/dist/runtime/subagents/index.d.ts.map +1 -0
- package/dist/runtime/subagents/index.js +62 -0
- package/dist/runtime/subagents/index.js.map +1 -0
- package/dist/runtime/subagents/policy.d.ts +68 -0
- package/dist/runtime/subagents/policy.d.ts.map +1 -0
- package/dist/runtime/subagents/policy.js +230 -0
- package/dist/runtime/subagents/policy.js.map +1 -0
- package/dist/runtime/subagents/presets.d.ts +44 -0
- package/dist/runtime/subagents/presets.d.ts.map +1 -0
- package/dist/runtime/subagents/presets.js +148 -0
- package/dist/runtime/subagents/presets.js.map +1 -0
- package/dist/runtime/subagents/production.d.ts +44 -0
- package/dist/runtime/subagents/production.d.ts.map +1 -0
- package/dist/runtime/subagents/production.js +143 -0
- package/dist/runtime/subagents/production.js.map +1 -0
- package/dist/runtime/subagents/provider-gate.d.ts +99 -0
- package/dist/runtime/subagents/provider-gate.d.ts.map +1 -0
- package/dist/runtime/subagents/provider-gate.js +186 -0
- package/dist/runtime/subagents/provider-gate.js.map +1 -0
- package/dist/runtime/subagents/result-parser.d.ts +40 -0
- package/dist/runtime/subagents/result-parser.d.ts.map +1 -0
- package/dist/runtime/subagents/result-parser.js +240 -0
- package/dist/runtime/subagents/result-parser.js.map +1 -0
- package/dist/runtime/subagents/runner.d.ts +53 -0
- package/dist/runtime/subagents/runner.d.ts.map +1 -0
- package/dist/runtime/subagents/runner.js +172 -0
- package/dist/runtime/subagents/runner.js.map +1 -0
- package/dist/runtime/subagents/runtime-integration.d.ts +73 -0
- package/dist/runtime/subagents/runtime-integration.d.ts.map +1 -0
- package/dist/runtime/subagents/runtime-integration.js +148 -0
- package/dist/runtime/subagents/runtime-integration.js.map +1 -0
- package/dist/runtime/subagents/supervisor.d.ts +79 -0
- package/dist/runtime/subagents/supervisor.d.ts.map +1 -0
- package/dist/runtime/subagents/supervisor.js +301 -0
- package/dist/runtime/subagents/supervisor.js.map +1 -0
- package/dist/runtime/subagents/tool.d.ts +38 -0
- package/dist/runtime/subagents/tool.d.ts.map +1 -0
- package/dist/runtime/subagents/tool.js +171 -0
- package/dist/runtime/subagents/tool.js.map +1 -0
- package/dist/runtime/subagents/types.d.ts +152 -0
- package/dist/runtime/subagents/types.d.ts.map +1 -0
- package/dist/runtime/subagents/types.js +56 -0
- package/dist/runtime/subagents/types.js.map +1 -0
- package/dist/runtime/ui-events.d.ts +18 -0
- package/dist/runtime/ui-events.d.ts.map +1 -1
- package/dist/runtime/ui-events.js.map +1 -1
- package/dist/runtime/ui-view-model.d.ts +44 -1
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +90 -37
- package/dist/runtime/ui-view-model.js.map +1 -1
- package/dist/sdk/query.d.ts.map +1 -1
- package/dist/sdk/query.js +0 -1
- package/dist/sdk/query.js.map +1 -1
- package/dist/services/auto-fix/autoFixHook.d.ts.map +1 -1
- package/dist/services/auto-fix/autoFixHook.js +3 -2
- package/dist/services/auto-fix/autoFixHook.js.map +1 -1
- package/dist/services/auto-fix/autoFixRunner.d.ts +2 -2
- package/dist/services/auto-fix/autoFixRunner.d.ts.map +1 -1
- package/dist/services/auto-fix/autoFixRunner.js +2 -2
- package/dist/services/auto-fix/autoFixRunner.js.map +1 -1
- package/dist/services/compact/auto-compact.d.ts +15 -2
- package/dist/services/compact/auto-compact.d.ts.map +1 -1
- package/dist/services/compact/auto-compact.js +59 -27
- package/dist/services/compact/auto-compact.js.map +1 -1
- package/dist/services/compact/compact.d.ts +2 -0
- package/dist/services/compact/compact.d.ts.map +1 -1
- package/dist/services/compact/compact.js +22 -5
- package/dist/services/compact/compact.js.map +1 -1
- package/dist/services/compact/coordinator.d.ts +26 -0
- package/dist/services/compact/coordinator.d.ts.map +1 -0
- package/dist/services/compact/coordinator.js +44 -0
- package/dist/services/compact/coordinator.js.map +1 -0
- package/dist/services/compact/index.d.ts +1 -0
- package/dist/services/compact/index.d.ts.map +1 -1
- package/dist/services/compact/index.js +3 -1
- package/dist/services/compact/index.js.map +1 -1
- package/dist/services/compact/summary-generator.d.ts +6 -2
- package/dist/services/compact/summary-generator.d.ts.map +1 -1
- package/dist/services/compact/summary-generator.js +73 -32
- package/dist/services/compact/summary-generator.js.map +1 -1
- package/dist/services/concurrent-sessions.d.ts.map +1 -1
- package/dist/services/concurrent-sessions.js +3 -0
- package/dist/services/concurrent-sessions.js.map +1 -1
- package/dist/services/config-dir.d.ts +11 -1
- package/dist/services/config-dir.d.ts.map +1 -1
- package/dist/services/config-dir.js +19 -2
- package/dist/services/config-dir.js.map +1 -1
- package/dist/services/config.d.ts +13 -4
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +85 -4
- package/dist/services/config.js.map +1 -1
- package/dist/services/doctor.d.ts +2 -0
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +9 -2
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/global-config.d.ts +33 -1
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/global-config.js +3 -0
- package/dist/services/global-config.js.map +1 -1
- package/dist/services/llm.d.ts +21 -4
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/llm.js +75 -9
- package/dist/services/llm.js.map +1 -1
- package/dist/services/mcp/transports.d.ts +2 -0
- package/dist/services/mcp/transports.d.ts.map +1 -1
- package/dist/services/mcp/transports.js +23 -2
- package/dist/services/mcp/transports.js.map +1 -1
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js.map +1 -1
- package/dist/services/model-context.d.ts +36 -0
- package/dist/services/model-context.d.ts.map +1 -1
- package/dist/services/model-context.js +243 -31
- package/dist/services/model-context.js.map +1 -1
- package/dist/services/redaction.js +1 -1
- package/dist/services/redaction.js.map +1 -1
- package/dist/services/session-memory/sessionMemory.js +1 -1
- package/dist/services/session-memory/sessionMemory.js.map +1 -1
- package/dist/services/session-storage.d.ts +39 -1
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +156 -28
- package/dist/services/session-storage.js.map +1 -1
- package/dist/services/task-manager.d.ts +2 -0
- package/dist/services/task-manager.d.ts.map +1 -1
- package/dist/services/task-manager.js +13 -0
- package/dist/services/task-manager.js.map +1 -1
- package/dist/services/usage-state.d.ts +55 -5
- package/dist/services/usage-state.d.ts.map +1 -1
- package/dist/services/usage-state.js +188 -59
- package/dist/services/usage-state.js.map +1 -1
- package/dist/services/verification-profile.d.ts.map +1 -1
- package/dist/services/verification-profile.js +3 -2
- package/dist/services/verification-profile.js.map +1 -1
- package/dist/services/workspace-diff.d.ts.map +1 -1
- package/dist/services/workspace-diff.js +34 -3
- package/dist/services/workspace-diff.js.map +1 -1
- package/dist/services/yaml-config.js +1 -1
- package/dist/skills/loader.d.ts +1 -1
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +1 -1
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/registry.d.ts +1 -1
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +1 -1
- package/dist/skills/registry.js.map +1 -1
- package/dist/skills/runtime.d.ts +9 -5
- package/dist/skills/runtime.d.ts.map +1 -1
- package/dist/skills/runtime.js +157 -12
- package/dist/skills/runtime.js.map +1 -1
- package/dist/terminal-ui/launch.d.ts +20 -3
- package/dist/terminal-ui/launch.d.ts.map +1 -1
- package/dist/terminal-ui/launch.js +86 -25
- package/dist/terminal-ui/launch.js.map +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +9 -0
- package/dist/terminal-ui/raw-editor.d.ts.map +1 -1
- package/dist/terminal-ui/raw-editor.js +207 -30
- package/dist/terminal-ui/raw-editor.js.map +1 -1
- package/dist/tools/bash_security.d.ts.map +1 -1
- package/dist/tools/bash_security.js +14 -5
- package/dist/tools/bash_security.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +51 -24
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lsp.js.map +1 -1
- package/dist/tools/plan.d.ts.map +1 -1
- package/dist/tools/plan.js +7 -0
- package/dist/tools/plan.js.map +1 -1
- package/dist/tools/web.d.ts +10 -0
- package/dist/tools/web.d.ts.map +1 -1
- package/dist/tools/web.js +84 -4
- package/dist/tools/web.js.map +1 -1
- package/dist/tui-core/frame.d.ts +13 -1
- package/dist/tui-core/frame.d.ts.map +1 -1
- package/dist/tui-core/frame.js +61 -8
- package/dist/tui-core/frame.js.map +1 -1
- package/dist/tui-core/input-parser.d.ts +1 -1
- package/dist/tui-core/input-parser.d.ts.map +1 -1
- package/dist/tui-core/input-parser.js +20 -1
- package/dist/tui-core/input-parser.js.map +1 -1
- package/dist/tui-core/style.d.ts +103 -0
- package/dist/tui-core/style.d.ts.map +1 -0
- package/dist/tui-core/style.js +269 -0
- package/dist/tui-core/style.js.map +1 -0
- package/dist/tui-core/terminal-writer.d.ts.map +1 -1
- package/dist/tui-core/terminal-writer.js +16 -3
- package/dist/tui-core/terminal-writer.js.map +1 -1
- package/dist/tui-ui/inline-surface.d.ts +185 -0
- package/dist/tui-ui/inline-surface.d.ts.map +1 -0
- package/dist/tui-ui/inline-surface.js +615 -0
- package/dist/tui-ui/inline-surface.js.map +1 -0
- package/dist/tui-ui/launch.d.ts +1 -0
- package/dist/tui-ui/launch.d.ts.map +1 -1
- package/dist/tui-ui/launch.js +398 -69
- package/dist/tui-ui/launch.js.map +1 -1
- package/dist/tui-ui/layout.d.ts +51 -2
- package/dist/tui-ui/layout.d.ts.map +1 -1
- package/dist/tui-ui/layout.js +240 -77
- package/dist/tui-ui/layout.js.map +1 -1
- package/dist/tui-ui/render-scheduler.d.ts +37 -0
- package/dist/tui-ui/render-scheduler.d.ts.map +1 -0
- package/dist/tui-ui/render-scheduler.js +118 -0
- package/dist/tui-ui/render-scheduler.js.map +1 -0
- package/dist/tui-ui/runner.d.ts +78 -5
- package/dist/tui-ui/runner.d.ts.map +1 -1
- package/dist/tui-ui/runner.js +317 -22
- package/dist/tui-ui/runner.js.map +1 -1
- package/dist/tui-ui/state.d.ts +38 -7
- package/dist/tui-ui/state.d.ts.map +1 -1
- package/dist/tui-ui/state.js +199 -40
- package/dist/tui-ui/state.js.map +1 -1
- package/dist/tui-ui/theme.d.ts +13 -0
- package/dist/tui-ui/theme.d.ts.map +1 -0
- package/dist/tui-ui/theme.js +20 -0
- package/dist/tui-ui/theme.js.map +1 -0
- package/dist/tui-ui/transcript-cache.d.ts +35 -0
- package/dist/tui-ui/transcript-cache.d.ts.map +1 -0
- package/dist/tui-ui/transcript-cache.js +74 -0
- package/dist/tui-ui/transcript-cache.js.map +1 -0
- package/dist/tui-ui/transcript-layout.d.ts +21 -0
- package/dist/tui-ui/transcript-layout.d.ts.map +1 -0
- package/dist/tui-ui/transcript-layout.js +398 -0
- package/dist/tui-ui/transcript-layout.js.map +1 -0
- package/dist/ui/box.d.ts.map +1 -1
- package/dist/ui/box.js +0 -11
- package/dist/ui/box.js.map +1 -1
- package/dist/ui/command-panel.d.ts.map +1 -1
- package/dist/ui/command-panel.js +1 -3
- package/dist/ui/command-panel.js.map +1 -1
- package/dist/ui/file-completion.js +1 -1
- package/dist/ui/file-completion.js.map +1 -1
- package/dist/ui/markdown.d.ts.map +1 -1
- package/dist/ui/markdown.js +1 -2
- package/dist/ui/markdown.js.map +1 -1
- package/dist/ui/multiline-input.d.ts.map +1 -1
- package/dist/ui/multiline-input.js +1 -2
- package/dist/ui/multiline-input.js.map +1 -1
- package/dist/ui/progress.d.ts.map +1 -1
- package/dist/ui/progress.js +0 -3
- package/dist/ui/progress.js.map +1 -1
- package/dist/ui/status-bar.d.ts +1 -1
- package/dist/ui/status-bar.d.ts.map +1 -1
- package/dist/ui/status-bar.js +2 -16
- package/dist/ui/status-bar.js.map +1 -1
- package/dist/ui/stream-markdown.d.ts +3 -0
- package/dist/ui/stream-markdown.d.ts.map +1 -1
- package/dist/ui/stream-markdown.js +0 -6
- package/dist/ui/stream-markdown.js.map +1 -1
- package/dist/ui/tool-preview.d.ts.map +1 -1
- package/dist/ui/tool-preview.js +0 -1
- package/dist/ui/tool-preview.js.map +1 -1
- package/dist/ui-v2/components/shell.d.ts.map +1 -1
- package/dist/ui-v2/components/shell.js +0 -8
- package/dist/ui-v2/components/shell.js.map +1 -1
- package/package.json +1 -1
- package/dist/cli-dbg.js +0 -717
- package/dist/cli-debug.d.ts +0 -7
- package/dist/cli-debug.d.ts.map +0 -1
- package/dist/cli-debug.js +0 -717
- package/dist/cli-debug.js.map +0 -1
- package/dist/cli-debug2.d.ts +0 -7
- package/dist/cli-debug2.d.ts.map +0 -1
- package/dist/cli-debug2.js +0 -717
- package/dist/cli-debug2.js.map +0 -1
- package/dist/cli-debug3.d.ts +0 -7
- package/dist/cli-debug3.d.ts.map +0 -1
- package/dist/cli-debug3.js +0 -719
- package/dist/cli-debug3.js.map +0 -1
- package/dist/cli-ink.d.ts +0 -8
- package/dist/cli-ink.d.ts.map +0 -1
- package/dist/cli-ink.js +0 -32
- package/dist/cli-ink.js.map +0 -1
- package/dist/cli-patch.js +0 -716
- package/dist/cli-test.js +0 -726
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentProviderGate: shared concurrency + cooldown for child LLM requests.
|
|
3
|
+
*
|
|
4
|
+
* Each child runs its own loop, but all children draw model requests from the
|
|
5
|
+
* same provider account. The gate bounds concurrent in-flight child execution
|
|
6
|
+
* and shares cooldown state so that one child's 429/retry-after pauses new
|
|
7
|
+
* children rather than letting each independently retry into a storm.
|
|
8
|
+
*
|
|
9
|
+
* The gate does NOT own per-request diagnostics or fallback model state - those
|
|
10
|
+
* live in the child's own LLMService. The gate only owns the shared go/no-go.
|
|
11
|
+
*
|
|
12
|
+
* R4 semantics:
|
|
13
|
+
* - `canReserve(count)` only reports whether the provider is in an
|
|
14
|
+
* unrecoverable state (cooldown). Normal concurrency saturation is NOT a
|
|
15
|
+
* reason to reject - the policy should let batches queue and let the FIFO
|
|
16
|
+
* semaphore bound actual peak concurrency.
|
|
17
|
+
* - `acquire(signal?)` queues when slots are full; resolves in FIFO order.
|
|
18
|
+
* An abort signal atomically removes the waiter and rejects, with no leaked
|
|
19
|
+
* active slot or listener.
|
|
20
|
+
* - cooldown has a single wake timer that re-arms on extension; when it
|
|
21
|
+
* fires it drains queued waiters so they do not hang after the last
|
|
22
|
+
* release during cooldown.
|
|
23
|
+
*/
|
|
24
|
+
export interface ProviderGateOptions {
|
|
25
|
+
/** Maximum children running concurrently. */
|
|
26
|
+
maxConcurrent: number;
|
|
27
|
+
/** Optional clock, injectable for deterministic tests. */
|
|
28
|
+
now?: () => number;
|
|
29
|
+
/** Optional timer scheduler (defaults to setTimeout). Injectable for tests. */
|
|
30
|
+
scheduleTimer?: (fn: () => void, ms: number) => {
|
|
31
|
+
clear(): void;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Thrown when an acquire is aborted via its signal. */
|
|
35
|
+
export declare class AcquireAbortedError extends Error {
|
|
36
|
+
constructor();
|
|
37
|
+
}
|
|
38
|
+
export declare class SubagentProviderGate {
|
|
39
|
+
private readonly maxConcurrent;
|
|
40
|
+
private readonly now;
|
|
41
|
+
private readonly scheduleTimer;
|
|
42
|
+
private active;
|
|
43
|
+
private cooldownUntil;
|
|
44
|
+
private waiters;
|
|
45
|
+
private cooldownTimer;
|
|
46
|
+
constructor(options: ProviderGateOptions);
|
|
47
|
+
/** Whether the provider is currently in a cooldown window. */
|
|
48
|
+
isInCooldown(): boolean;
|
|
49
|
+
/** Remaining ms in the current cooldown, or 0. */
|
|
50
|
+
cooldownRemainingMs(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Enter a cooldown after a rate-limit response. New acquires will wait until
|
|
53
|
+
* the window expires. A longer requested cooldown extends; a shorter one is
|
|
54
|
+
* ignored if an active cooldown is longer. Re-arms the wake timer so queued
|
|
55
|
+
* waiters are drained when the cooldown expires (R4: no permanent hang).
|
|
56
|
+
*/
|
|
57
|
+
enterCooldown(retryAfterMs: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* R4: whether the provider can accept new children. Returns false ONLY during
|
|
60
|
+
* cooldown — normal concurrency saturation is not a rejection reason, because
|
|
61
|
+
* the FIFO semaphore queues excess tasks and bounds actual peak concurrency
|
|
62
|
+
* at acquire time.
|
|
63
|
+
*
|
|
64
|
+
* NOTE: the `count` parameter is currently unused. It is reserved for future
|
|
65
|
+
* per-slot reservation checks. Today, policy only needs to know whether the
|
|
66
|
+
* provider is in an unrecoverable state (cooldown).
|
|
67
|
+
*/
|
|
68
|
+
canReserve(_count: number): boolean;
|
|
69
|
+
/** Number of children currently holding a slot. */
|
|
70
|
+
activeCount(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Acquire a slot. Resolves once a slot is free and the provider is not in
|
|
73
|
+
* cooldown. The caller MUST call `release()` when the child finishes.
|
|
74
|
+
*
|
|
75
|
+
* R4: if `signal` is provided and aborts while queued, the waiter is removed
|
|
76
|
+
* atomically and the promise rejects with {@link AcquireAbortedError}. No
|
|
77
|
+
* active slot is leaked and the abort listener is removed.
|
|
78
|
+
*
|
|
79
|
+
* The slot is claimed synchronously before the waiter's microtask runs, so
|
|
80
|
+
* `drainWaiters` never over-allocates beyond `maxConcurrent`.
|
|
81
|
+
*/
|
|
82
|
+
acquire(signal?: AbortSignal): Promise<void>;
|
|
83
|
+
/** Release a slot and wake the next waiter (if not in cooldown). */
|
|
84
|
+
release(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Wake waiters in FIFO order. For each waiter, the slot is claimed
|
|
87
|
+
* synchronously (active += 1) BEFORE the promise is resolved, so the
|
|
88
|
+
* next iteration of the while-loop sees the updated count and won't
|
|
89
|
+
* over-allocate.
|
|
90
|
+
*/
|
|
91
|
+
private drainWaiters;
|
|
92
|
+
/**
|
|
93
|
+
* Arm (or re-arm) a single timer that fires when the current cooldown
|
|
94
|
+
* expires, then drains queued waiters. Re-arming on extension keeps a
|
|
95
|
+
* single pending timer at all times.
|
|
96
|
+
*/
|
|
97
|
+
private armCooldownTimer;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=provider-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-gate.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/provider-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,MAAM,WAAW,m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|
5
|
+
* Each child runs its own loop, but all children draw model requests from the
|
|
6
|
+
* same provider account. The gate bounds concurrent in-flight child execution
|
|
7
|
+
* and shares cooldown state so that one child's 429/retry-after pauses new
|
|
8
|
+
* children rather than letting each independently retry into a storm.
|
|
9
|
+
*
|
|
10
|
+
* The gate does NOT own per-request diagnostics or fallback model state - those
|
|
11
|
+
* live in the child's own LLMService. The gate only owns the shared go/no-go.
|
|
12
|
+
*
|
|
13
|
+
* R4 semantics:
|
|
14
|
+
* - `canReserve(count)` only reports whether the provider is in an
|
|
15
|
+
* unrecoverable state (cooldown). Normal concurrency saturation is NOT a
|
|
16
|
+
* reason to reject - the policy should let batches queue and let the FIFO
|
|
17
|
+
* semaphore bound actual peak concurrency.
|
|
18
|
+
* - `acquire(signal?)` queues when slots are full; resolves in FIFO order.
|
|
19
|
+
* An abort signal atomically removes the waiter and rejects, with no leaked
|
|
20
|
+
* active slot or listener.
|
|
21
|
+
* - cooldown has a single wake timer that re-arms on extension; when it
|
|
22
|
+
* fires it drains queued waiters so they do not hang after the last
|
|
23
|
+
* release during cooldown.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SubagentProviderGate = exports.AcquireAbortedError = void 0;
|
|
27
|
+
/** Thrown when an acquire is aborted via its signal. */
|
|
28
|
+
class AcquireAbortedError extends Error {
|
|
29
|
+
constructor() {
|
|
30
|
+
super('Subagent provider gate acquire was aborted');
|
|
31
|
+
this.name = 'AcquireAbortedError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AcquireAbortedError = AcquireAbortedError;
|
|
35
|
+
class SubagentProviderGate {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.active = 0;
|
|
38
|
+
this.cooldownUntil = 0;
|
|
39
|
+
this.waiters = [];
|
|
40
|
+
this.cooldownTimer = null;
|
|
41
|
+
const maxConcurrent = Number(options.maxConcurrent);
|
|
42
|
+
// N12: guard against NaN/undefined/negative — clamp to 1 as safe minimum.
|
|
43
|
+
this.maxConcurrent = Number.isFinite(maxConcurrent) && maxConcurrent >= 1
|
|
44
|
+
? Math.floor(maxConcurrent)
|
|
45
|
+
: 1;
|
|
46
|
+
this.now = options.now ?? (() => Date.now());
|
|
47
|
+
this.scheduleTimer = options.scheduleTimer ?? defaultScheduleTimer;
|
|
48
|
+
}
|
|
49
|
+
/** Whether the provider is currently in a cooldown window. */
|
|
50
|
+
isInCooldown() {
|
|
51
|
+
return this.now() < this.cooldownUntil;
|
|
52
|
+
}
|
|
53
|
+
/** Remaining ms in the current cooldown, or 0. */
|
|
54
|
+
cooldownRemainingMs() {
|
|
55
|
+
return Math.max(0, this.cooldownUntil - this.now());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Enter a cooldown after a rate-limit response. New acquires will wait until
|
|
59
|
+
* the window expires. A longer requested cooldown extends; a shorter one is
|
|
60
|
+
* ignored if an active cooldown is longer. Re-arms the wake timer so queued
|
|
61
|
+
* waiters are drained when the cooldown expires (R4: no permanent hang).
|
|
62
|
+
*/
|
|
63
|
+
enterCooldown(retryAfterMs) {
|
|
64
|
+
const until = this.now() + Math.max(0, retryAfterMs);
|
|
65
|
+
if (until > this.cooldownUntil) {
|
|
66
|
+
this.cooldownUntil = until;
|
|
67
|
+
this.armCooldownTimer();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* R4: whether the provider can accept new children. Returns false ONLY during
|
|
72
|
+
* cooldown — normal concurrency saturation is not a rejection reason, because
|
|
73
|
+
* the FIFO semaphore queues excess tasks and bounds actual peak concurrency
|
|
74
|
+
* at acquire time.
|
|
75
|
+
*
|
|
76
|
+
* NOTE: the `count` parameter is currently unused. It is reserved for future
|
|
77
|
+
* per-slot reservation checks. Today, policy only needs to know whether the
|
|
78
|
+
* provider is in an unrecoverable state (cooldown).
|
|
79
|
+
*/
|
|
80
|
+
canReserve(_count) {
|
|
81
|
+
return !this.isInCooldown();
|
|
82
|
+
}
|
|
83
|
+
/** Number of children currently holding a slot. */
|
|
84
|
+
activeCount() {
|
|
85
|
+
return this.active;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Acquire a slot. Resolves once a slot is free and the provider is not in
|
|
89
|
+
* cooldown. The caller MUST call `release()` when the child finishes.
|
|
90
|
+
*
|
|
91
|
+
* R4: if `signal` is provided and aborts while queued, the waiter is removed
|
|
92
|
+
* atomically and the promise rejects with {@link AcquireAbortedError}. No
|
|
93
|
+
* active slot is leaked and the abort listener is removed.
|
|
94
|
+
*
|
|
95
|
+
* The slot is claimed synchronously before the waiter's microtask runs, so
|
|
96
|
+
* `drainWaiters` never over-allocates beyond `maxConcurrent`.
|
|
97
|
+
*/
|
|
98
|
+
async acquire(signal) {
|
|
99
|
+
// Already aborted before we even start.
|
|
100
|
+
if (signal?.aborted)
|
|
101
|
+
throw new AcquireAbortedError();
|
|
102
|
+
if (this.canReserve(1) && this.active < this.maxConcurrent) {
|
|
103
|
+
this.active += 1;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await new Promise((resolve, reject) => {
|
|
107
|
+
const waiter = { resolve, reject, signal };
|
|
108
|
+
this.waiters.push(waiter);
|
|
109
|
+
if (signal) {
|
|
110
|
+
const onAbort = () => {
|
|
111
|
+
// Atomically remove this waiter; if it was already claimed by
|
|
112
|
+
// drainWaiters (no longer in the queue), the abort is a no-op.
|
|
113
|
+
const idx = this.waiters.indexOf(waiter);
|
|
114
|
+
if (idx >= 0) {
|
|
115
|
+
this.waiters.splice(idx, 1);
|
|
116
|
+
reject(new AcquireAbortedError());
|
|
117
|
+
}
|
|
118
|
+
signal.removeEventListener('abort', onAbort);
|
|
119
|
+
};
|
|
120
|
+
waiter.onAbort = onAbort;
|
|
121
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
// NOTE: `this.active` was already incremented by drainWaiters when the
|
|
125
|
+
// slot was claimed synchronously, so we do NOT increment here.
|
|
126
|
+
}
|
|
127
|
+
/** Release a slot and wake the next waiter (if not in cooldown). */
|
|
128
|
+
release() {
|
|
129
|
+
this.active = Math.max(0, this.active - 1);
|
|
130
|
+
this.drainWaiters();
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Wake waiters in FIFO order. For each waiter, the slot is claimed
|
|
134
|
+
* synchronously (active += 1) BEFORE the promise is resolved, so the
|
|
135
|
+
* next iteration of the while-loop sees the updated count and won't
|
|
136
|
+
* over-allocate.
|
|
137
|
+
*/
|
|
138
|
+
drainWaiters() {
|
|
139
|
+
while (this.waiters.length > 0 && !this.isInCooldown() && this.active < this.maxConcurrent) {
|
|
140
|
+
const next = this.waiters.shift();
|
|
141
|
+
if (!next)
|
|
142
|
+
continue;
|
|
143
|
+
this.active += 1; // claim synchronously before resolving
|
|
144
|
+
// Remove the abort listener (if any) - the waiter is being fulfilled.
|
|
145
|
+
if (next.signal && next.onAbort) {
|
|
146
|
+
next.signal.removeEventListener('abort', next.onAbort);
|
|
147
|
+
}
|
|
148
|
+
next.resolve();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Arm (or re-arm) a single timer that fires when the current cooldown
|
|
153
|
+
* expires, then drains queued waiters. Re-arming on extension keeps a
|
|
154
|
+
* single pending timer at all times.
|
|
155
|
+
*/
|
|
156
|
+
armCooldownTimer() {
|
|
157
|
+
if (this.cooldownTimer) {
|
|
158
|
+
this.cooldownTimer.clear();
|
|
159
|
+
this.cooldownTimer = null;
|
|
160
|
+
}
|
|
161
|
+
const remaining = this.cooldownRemainingMs();
|
|
162
|
+
if (remaining <= 0) {
|
|
163
|
+
// Cooldown already over - drain immediately.
|
|
164
|
+
this.drainWaiters();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
this.cooldownTimer = this.scheduleTimer(() => {
|
|
168
|
+
this.cooldownTimer = null;
|
|
169
|
+
this.drainWaiters();
|
|
170
|
+
}, remaining);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.SubagentProviderGate = SubagentProviderGate;
|
|
174
|
+
function defaultScheduleTimer(fn, ms) {
|
|
175
|
+
const handle = setTimeout(fn, ms);
|
|
176
|
+
// Don't keep the event loop alive solely for a cooldown wake.
|
|
177
|
+
if (typeof handle === 'object' && handle && 'unref' in handle && typeof handle.unref === 'function') {
|
|
178
|
+
handle.unref();
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
clear() {
|
|
182
|
+
clearTimeout(handle);
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=provider-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-gate.js","sourceRoot":"","sources":["../../../src/runtime/subagents/provider-gate.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAWH,wDAAwD;AACxD,MAAa,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CAAC,4CAA4C,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAUD,MAAa,oBAAoB;IAS/B,YAAY,OAA4B;QALhC,WAAM,GAAG,CAAC,CAAC;QACX,kBAAa,GAAG,CAAC,CAAC;QAClB,YAAO,GAAa,EAAE,CAAC;QACvB,kBAAa,GAA6B,IAAI,CAAC;QAGrD,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QACpD,0EAA0E;QAC1E,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,aAAa,IAAI,CAAC;YACvE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAC3B,CAAC,CAAC,CAAC,CAAC;QACN,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,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B,CAAC,CAAC;QACzC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentResultParser: normalize a child's final text into a fixed schema.
|
|
3
|
+
*
|
|
4
|
+
* Children are instructed to emit a single JSON object. In practice they may
|
|
5
|
+
* wrap it in prose, emit invalid JSON, or omit fields. This parser is the
|
|
6
|
+
* single chokepoint that produces a well-typed {@link SubtaskResult} regardless
|
|
7
|
+
* of provider quirks, so the root Agent only ever sees structured data.
|
|
8
|
+
*/
|
|
9
|
+
import type { SubagentRole, SubtaskResult, SubtaskResultStatus } from './types';
|
|
10
|
+
export interface ParsedSubtaskPayload {
|
|
11
|
+
summary?: unknown;
|
|
12
|
+
findings?: unknown;
|
|
13
|
+
files?: unknown;
|
|
14
|
+
commands?: unknown;
|
|
15
|
+
verification?: unknown;
|
|
16
|
+
risks?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extract the first balanced JSON object from text that may contain prose
|
|
20
|
+
* around it. Returns the parsed object or null if none is found / invalid.
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractJsonObject(text: string): unknown;
|
|
23
|
+
/**
|
|
24
|
+
* Parse a child's final text into a {@link SubtaskResult}.
|
|
25
|
+
*
|
|
26
|
+
* @param id Runtime-generated task id.
|
|
27
|
+
* @param role The role the child ran as.
|
|
28
|
+
* @param content The child's final assistant text (may contain prose + JSON).
|
|
29
|
+
* @param status Terminal status. `completed` requires parseable JSON;
|
|
30
|
+
* otherwise the summary records the failure mode.
|
|
31
|
+
* @param usage Observed usage; defaults to empty.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseSubtaskResult(args: {
|
|
34
|
+
id: string;
|
|
35
|
+
role: SubagentRole;
|
|
36
|
+
content: string;
|
|
37
|
+
status: SubtaskResultStatus;
|
|
38
|
+
usage?: SubtaskResult['usage'];
|
|
39
|
+
}): SubtaskResult;
|
|
40
|
+
//# sourceMappingURL=result-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-parser.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/result-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,YAAY,EAEZ,aAAa,EACb,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAUjB,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAmDvD;AAgED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CAChC,GAAG,aAAa,CAgEhB"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SubagentResultParser: normalize a child's final text into a fixed schema.
|
|
4
|
+
*
|
|
5
|
+
* Children are instructed to emit a single JSON object. In practice they may
|
|
6
|
+
* wrap it in prose, emit invalid JSON, or omit fields. This parser is the
|
|
7
|
+
* single chokepoint that produces a well-typed {@link SubtaskResult} regardless
|
|
8
|
+
* of provider quirks, so the root Agent only ever sees structured data.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.extractJsonObject = extractJsonObject;
|
|
12
|
+
exports.parseSubtaskResult = parseSubtaskResult;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const MAX_FINDINGS = 20;
|
|
15
|
+
const MAX_FILES = 50;
|
|
16
|
+
const MAX_COMMANDS = 20;
|
|
17
|
+
const MAX_VERIFICATION = 10;
|
|
18
|
+
const MAX_RISKS = 10;
|
|
19
|
+
const MAX_FIELD_LEN = 2000;
|
|
20
|
+
/**
|
|
21
|
+
* Extract the first balanced JSON object from text that may contain prose
|
|
22
|
+
* around it. Returns the parsed object or null if none is found / invalid.
|
|
23
|
+
*/
|
|
24
|
+
function extractJsonObject(text) {
|
|
25
|
+
if (!text)
|
|
26
|
+
return null;
|
|
27
|
+
// Iterate over every top-level '{' start position. A child's text may contain
|
|
28
|
+
// prose with brace fragments (e.g. "{ result above }") before the real JSON
|
|
29
|
+
// object, so a candidate that is balanced but not valid JSON must not abort
|
|
30
|
+
// the search — we keep scanning for the next '{'.
|
|
31
|
+
let searchFrom = 0;
|
|
32
|
+
while (searchFrom < text.length) {
|
|
33
|
+
const start = text.indexOf('{', searchFrom);
|
|
34
|
+
if (start === -1)
|
|
35
|
+
return null;
|
|
36
|
+
// Scan for the matching closing brace, respecting nested objects and strings.
|
|
37
|
+
let depth = 0;
|
|
38
|
+
let inString = false;
|
|
39
|
+
let escaped = false;
|
|
40
|
+
let end = -1;
|
|
41
|
+
for (let i = start; i < text.length; i++) {
|
|
42
|
+
const ch = text[i];
|
|
43
|
+
if (inString) {
|
|
44
|
+
if (escaped) {
|
|
45
|
+
escaped = false;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (ch === '\\') {
|
|
49
|
+
escaped = true;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === '"')
|
|
53
|
+
inString = false;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (ch === '"') {
|
|
57
|
+
inString = true;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (ch === '{')
|
|
61
|
+
depth++;
|
|
62
|
+
else if (ch === '}') {
|
|
63
|
+
depth--;
|
|
64
|
+
if (depth === 0) {
|
|
65
|
+
end = i;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (end === -1) {
|
|
71
|
+
// Unbalanced from this start; try a last-ditch parse of the tail.
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(text.slice(start));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const candidate = text.slice(start, end + 1);
|
|
80
|
+
try {
|
|
81
|
+
return JSON.parse(candidate);
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Balanced but not valid JSON (prose fragment). Continue past it.
|
|
85
|
+
searchFrom = end + 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function str(value, max = MAX_FIELD_LEN) {
|
|
91
|
+
if (typeof value === 'string')
|
|
92
|
+
return truncate(value.trim(), max);
|
|
93
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
94
|
+
return String(value);
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
function truncate(s, max) {
|
|
98
|
+
return s.length <= max ? s : `${s.slice(0, max - 1)}…`;
|
|
99
|
+
}
|
|
100
|
+
function parseFindings(raw) {
|
|
101
|
+
if (!Array.isArray(raw))
|
|
102
|
+
return [];
|
|
103
|
+
const out = [];
|
|
104
|
+
for (const item of raw) {
|
|
105
|
+
if (!item || typeof item !== 'object')
|
|
106
|
+
continue;
|
|
107
|
+
const obj = item;
|
|
108
|
+
const title = str(obj.title, 200);
|
|
109
|
+
if (!title)
|
|
110
|
+
continue;
|
|
111
|
+
out.push({
|
|
112
|
+
title,
|
|
113
|
+
severity: parseSeverity(obj.severity),
|
|
114
|
+
evidence: str(obj.evidence, 1500),
|
|
115
|
+
file: obj.file != null ? str(obj.file, 500) : undefined,
|
|
116
|
+
line: typeof obj.line === 'number' && Number.isFinite(obj.line) ? Math.max(0, Math.floor(obj.line)) : undefined,
|
|
117
|
+
});
|
|
118
|
+
if (out.length >= MAX_FINDINGS)
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
function parseSeverity(value) {
|
|
124
|
+
if (value === 'critical' || value === 'high' || value === 'medium' || value === 'low' || value === 'info') {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
function parseStringArray(raw, max) {
|
|
130
|
+
if (!Array.isArray(raw))
|
|
131
|
+
return [];
|
|
132
|
+
const out = [];
|
|
133
|
+
for (const item of raw) {
|
|
134
|
+
const s = str(item, 500);
|
|
135
|
+
if (s)
|
|
136
|
+
out.push(s);
|
|
137
|
+
if (out.length >= max)
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return out;
|
|
141
|
+
}
|
|
142
|
+
function parseCommands(raw) {
|
|
143
|
+
if (!Array.isArray(raw))
|
|
144
|
+
return [];
|
|
145
|
+
const out = [];
|
|
146
|
+
for (const item of raw) {
|
|
147
|
+
if (!item || typeof item !== 'object')
|
|
148
|
+
continue;
|
|
149
|
+
const obj = item;
|
|
150
|
+
const command = str(obj.command, 500);
|
|
151
|
+
if (!command)
|
|
152
|
+
continue;
|
|
153
|
+
out.push({ command, purpose: str(obj.purpose, 500), executed: false });
|
|
154
|
+
if (out.length >= MAX_COMMANDS)
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Parse a child's final text into a {@link SubtaskResult}.
|
|
161
|
+
*
|
|
162
|
+
* @param id Runtime-generated task id.
|
|
163
|
+
* @param role The role the child ran as.
|
|
164
|
+
* @param content The child's final assistant text (may contain prose + JSON).
|
|
165
|
+
* @param status Terminal status. `completed` requires parseable JSON;
|
|
166
|
+
* otherwise the summary records the failure mode.
|
|
167
|
+
* @param usage Observed usage; defaults to empty.
|
|
168
|
+
*/
|
|
169
|
+
function parseSubtaskResult(args) {
|
|
170
|
+
const { id, role, content, status } = args;
|
|
171
|
+
const usage = args.usage ?? types_1.EMPTY_SUBTASK_USAGE;
|
|
172
|
+
if (status !== 'completed') {
|
|
173
|
+
return {
|
|
174
|
+
id,
|
|
175
|
+
role,
|
|
176
|
+
status,
|
|
177
|
+
summary: summarizeFailure(status, content),
|
|
178
|
+
findings: [],
|
|
179
|
+
files: [],
|
|
180
|
+
commands: [],
|
|
181
|
+
verification: [],
|
|
182
|
+
risks: [`child did not complete: ${status}`],
|
|
183
|
+
usage,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const parsed = extractJsonObject(content);
|
|
187
|
+
if (!parsed || typeof parsed !== 'object') {
|
|
188
|
+
return {
|
|
189
|
+
id,
|
|
190
|
+
role,
|
|
191
|
+
status: 'failed',
|
|
192
|
+
summary: truncate(content.trim() || '(no output)', MAX_FIELD_LEN),
|
|
193
|
+
findings: [],
|
|
194
|
+
files: [],
|
|
195
|
+
commands: [],
|
|
196
|
+
verification: [],
|
|
197
|
+
risks: ['child returned non-JSON output'],
|
|
198
|
+
usage,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const payload = parsed;
|
|
202
|
+
const summary = str(payload.summary, MAX_FIELD_LEN);
|
|
203
|
+
if (!summary) {
|
|
204
|
+
return {
|
|
205
|
+
id,
|
|
206
|
+
role,
|
|
207
|
+
status: 'failed',
|
|
208
|
+
summary: truncate(content.trim().slice(0, MAX_FIELD_LEN), MAX_FIELD_LEN),
|
|
209
|
+
findings: parseFindings(payload.findings),
|
|
210
|
+
files: [],
|
|
211
|
+
commands: [],
|
|
212
|
+
verification: [],
|
|
213
|
+
risks: ['child output missing required "summary" field'],
|
|
214
|
+
usage,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
id,
|
|
219
|
+
role,
|
|
220
|
+
status: 'completed',
|
|
221
|
+
summary,
|
|
222
|
+
findings: parseFindings(payload.findings),
|
|
223
|
+
files: parseStringArray(payload.files, MAX_FILES),
|
|
224
|
+
commands: parseCommands(payload.commands),
|
|
225
|
+
verification: parseStringArray(payload.verification, MAX_VERIFICATION),
|
|
226
|
+
risks: parseStringArray(payload.risks, MAX_RISKS),
|
|
227
|
+
usage,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function summarizeFailure(status, content) {
|
|
231
|
+
const tail = truncate(content.trim(), 300);
|
|
232
|
+
switch (status) {
|
|
233
|
+
case 'timed_out': return `Child timed out. Partial output: ${tail || '(none)'}`;
|
|
234
|
+
case 'cancelled': return `Child was cancelled. Partial output: ${tail || '(none)'}`;
|
|
235
|
+
case 'failed': return `Child failed. Output: ${tail || '(none)'}`;
|
|
236
|
+
case 'rejected': return `Child was rejected by policy before running.`;
|
|
237
|
+
default: return tail || '(no output)';
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=result-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-parser.js","sourceRoot":"","sources":["../../../src/runtime/subagents/result-parser.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA8BH,8CAmDC;AA0ED,gDAsEC;AAzND,mCAA8C;AAE9C,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,aAAa,GAAG,IAAI,CAAC;AAW3B;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAEvB,8EAA8E;IAC9E,4EAA4E;IAC5E,4EAA4E;IAC5E,kDAAkD;IAClD,IAA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AK;SACN,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE;QACF,IAAI;QACJ,MAAM,EAAE,WAAW;QACnB,OAAO;QACP,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzC,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC;QACjD,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzC,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,YAAY,EAAE,gBAAgB,CAAC;QACtE,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC;QACjD,KAAK;KACN,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAA2B,EAAE,OAAe;IACpE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IAC3C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,WAAW,CAAC,CAAC,OAAO,oCAAoC,IAAI,IAAI,QAAQ,EAAE,CAAC;QAChF,KAAK,WAAW,CAAC,CAAC,OAAO,wCAAwC,IAAI,IAAI,QAAQ,EAAE,CAAC;QACpF,KAAK,QAAQ,CAAC,CAAC,OAAO,yBAAyB,IAAI,IAAI,QAAQ,EAAE,CAAC;QAClE,KAAK,UAAU,CAAC,CAAC,OAAO,8CAA8C,CAAC;QACvE,OAAO,CAAC,CAAC,OAAO,IAAI,IAAI,aAAa,CAAC;IACxC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentRunner: runs a single child agent to completion and parses its result.
|
|
3
|
+
*
|
|
4
|
+
* The runner is the boundary between the Supervisor and the shared `query()`
|
|
5
|
+
* loop. It is deliberately thin: it derives a child abort signal from the
|
|
6
|
+
* parent, applies a per-child timeout, invokes an injectable `executeQuery`,
|
|
7
|
+
* and normalizes the outcome through {@link parseSubtaskResult}.
|
|
8
|
+
*
|
|
9
|
+
* `executeQuery` is injected so the runner can be tested without a live LLM;
|
|
10
|
+
* the production binding wraps `query()` with a per-child LLMService.
|
|
11
|
+
*/
|
|
12
|
+
import { buildChildMessages } from './context-builder';
|
|
13
|
+
import type { SubtaskPacket, SubtaskResult, SubtaskUsage } from './types';
|
|
14
|
+
/** A filtered, child-safe tool list with its executor. */
|
|
15
|
+
export interface ChildToolSet {
|
|
16
|
+
/** Resolved tool definitions the child may call. */
|
|
17
|
+
tools: unknown[];
|
|
18
|
+
/** Tool name -> executor. */
|
|
19
|
+
toolExecutor: (name: string, args: Record<string, unknown>, abortSignal?: AbortSignal) => Promise<string>;
|
|
20
|
+
}
|
|
21
|
+
/** Injectable child query function. Returns the final assistant text + usage. */
|
|
22
|
+
export type ExecuteChildQuery = (messages: ReturnType<typeof buildChildMessages>, toolSet: ChildToolSet, abortSignal: AbortSignal) => Promise<{
|
|
23
|
+
content: string;
|
|
24
|
+
usage: SubtaskUsage;
|
|
25
|
+
}>;
|
|
26
|
+
export interface SubagentRunnerDeps {
|
|
27
|
+
/** Canonical project root. */
|
|
28
|
+
cwd: string;
|
|
29
|
+
/** Canonical scope paths (already validated). */
|
|
30
|
+
canonicalScopePaths?: string[];
|
|
31
|
+
/** Filtered child tools + executor. */
|
|
32
|
+
toolSet: ChildToolSet;
|
|
33
|
+
/** Injectable query binding (production wraps query(); tests mock it). */
|
|
34
|
+
executeQuery: ExecuteChildQuery;
|
|
35
|
+
/** Per-child wall-clock timeout. */
|
|
36
|
+
timeoutMs: number;
|
|
37
|
+
/** Parent abort signal; child abort is derived from it. */
|
|
38
|
+
parentAbortSignal?: AbortSignal;
|
|
39
|
+
/** Optional read-only context inputs forwarded to the context builder. */
|
|
40
|
+
rootObjectiveSummary?: string;
|
|
41
|
+
modelLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface RunSubtaskOutcome {
|
|
44
|
+
result: SubtaskResult;
|
|
45
|
+
/** Whether the child was aborted by the parent (vs its own timeout). */
|
|
46
|
+
parentCancelled: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Run one child subtask to a terminal state. Never throws: every failure mode
|
|
50
|
+
* (timeout, cancel, error, non-JSON output) is normalized into a SubtaskResult.
|
|
51
|
+
*/
|
|
52
|
+
export declare function runSubtask(packet: SubtaskPacket, deps: SubagentRunnerDeps, taskId: string): Promise<RunSubtaskOutcome>;
|
|
53
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,KAAK,EACV,aAAa,EACb,aAAa,EAEb,YAAY,EACb,MAAM,SAAS,CAAC;AA4BjB,0DAA0D;AAC1D,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,6BAA6B;IAC7B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3G;AAED,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,CAC9B,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,EAC/C,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,WAAW,KACrB,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE,CAAC,CAAC;AAEvD,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;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