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,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ChildToolExecutorGuard: enforces project-root and packet-scope isolation.
|
|
4
|
+
*
|
|
5
|
+
* R3 (v0.2.20): the policy only canonicalizes scope.paths into the child
|
|
6
|
+
* prompt, but the actual tool arguments (read_file path, glob base, grep
|
|
7
|
+
* path, batch_read nested args) were not validated. A child could read
|
|
8
|
+
* absolute paths, `../` escapes, outside-scope files, or symlink targets
|
|
9
|
+
* pointing outside the project.
|
|
10
|
+
*
|
|
11
|
+
* This guard wraps the child tool executor and performs a realpath-based
|
|
12
|
+
* containment check on every path-bearing argument before delegating to
|
|
13
|
+
* the real executor.
|
|
14
|
+
*
|
|
15
|
+
* Two containment boundaries:
|
|
16
|
+
* 1. Canonical project root (always enforced).
|
|
17
|
+
* 2. Packet scope paths (enforced when the packet specifies a non-empty
|
|
18
|
+
* scope). The path must be inside the root AND inside at least one
|
|
19
|
+
* scope realpath.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.ScopeHolder = void 0;
|
|
23
|
+
exports.evaluateToolCall = evaluateToolCall;
|
|
24
|
+
exports.createChildToolExecutorGuard = createChildToolExecutorGuard;
|
|
25
|
+
const path_1 = require("path");
|
|
26
|
+
const fs_1 = require("fs");
|
|
27
|
+
/** Tools whose arguments carry a single primary path under key `path`. */
|
|
28
|
+
const PATH_TOOLS = new Set(['read_file', 'list_files']);
|
|
29
|
+
/** Tools whose arguments carry a base/glob root under `path`. */
|
|
30
|
+
const BASE_PATH_TOOLS = new Set(['glob']);
|
|
31
|
+
/** Tools whose arguments carry a search base under `path`. */
|
|
32
|
+
const SEARCH_PATH_TOOLS = new Set(['grep']);
|
|
33
|
+
/** batch_read nests step args; each step has { tool, args }. */
|
|
34
|
+
const BATCH_TOOL = 'batch_read';
|
|
35
|
+
/**
|
|
36
|
+
* Return the realpath of the nearest existing ancestor of `p`.
|
|
37
|
+
*
|
|
38
|
+
* This handles not-yet-created paths (the target doesn't exist, but its
|
|
39
|
+
* parent dir does) and symlinked parent directories: we walk up until we
|
|
40
|
+
* find a path that exists, then resolve its realpath. Symlink escapes in
|
|
41
|
+
* an existing ancestor are caught because realpath resolves them.
|
|
42
|
+
*/
|
|
43
|
+
function nearestExistingAncestorRealpath(p) {
|
|
44
|
+
let current = p;
|
|
45
|
+
for (let i = 0; i < 64; i++) {
|
|
46
|
+
if ((0, fs_1.existsSync)(current)) {
|
|
47
|
+
try {
|
|
48
|
+
return (0, fs_1.realpathSync)(current);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
// Distinguish ENOENT (path disappeared between existsSync and realpathSync)
|
|
52
|
+
// from permission/I/O errors. ENOENT: continue walking up. Others: fail.
|
|
53
|
+
const code = err?.code;
|
|
54
|
+
if (code === 'ENOENT') {
|
|
55
|
+
// Path vanished between existsSync and realpathSync (TOCTOU).
|
|
56
|
+
// Continue walking up to find an existing ancestor.
|
|
57
|
+
const parent = (0, path_1.resolve)(current, '..');
|
|
58
|
+
if (parent === current)
|
|
59
|
+
return undefined;
|
|
60
|
+
current = parent;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// EACCES, EIO, etc: cannot resolve realpath — treat as unresolvable.
|
|
64
|
+
// Returning undefined signals to the caller that containment cannot be
|
|
65
|
+
// verified, and the path should be rejected.
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const parent = (0, path_1.resolve)(current, '..');
|
|
70
|
+
if (parent === current)
|
|
71
|
+
return undefined; // filesystem root, no existing ancestor
|
|
72
|
+
current = parent;
|
|
73
|
+
}
|
|
74
|
+
return undefined; // loop exhausted, no existing ancestor found
|
|
75
|
+
}
|
|
76
|
+
/** True if `candidate` is `ancestor` or inside it (both realpaths). */
|
|
77
|
+
function isInsideOrEqual(candidate, ancestor) {
|
|
78
|
+
if (candidate === ancestor)
|
|
79
|
+
return true;
|
|
80
|
+
const rel = (0, path_1.relative)(ancestor, candidate);
|
|
81
|
+
return rel !== '' && !rel.startsWith('..') && !(0, path_1.isAbsolute)(rel);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Check that a path stays inside root (and inside a scope if scopes given).
|
|
85
|
+
*
|
|
86
|
+
* Strategy: resolve the path against root, then take the realpath of its
|
|
87
|
+
* nearest existing ancestor. If that ancestor is outside root, the path
|
|
88
|
+
* escapes (via `..`, absolute outside root, or symlinked parent). If scopes
|
|
89
|
+
* are specified, the ancestor must also be inside a scope OR the path must
|
|
90
|
+
* descend into a scope from the root (ancestor is root itself, remaining
|
|
91
|
+
* suffix enters a scope).
|
|
92
|
+
*/
|
|
93
|
+
function checkContainment(rawPath, rootReal, scopeReals) {
|
|
94
|
+
if (typeof rawPath !== 'string' || rawPath.trim() === '') {
|
|
95
|
+
return { contained: false, reason: 'empty path' };
|
|
96
|
+
}
|
|
97
|
+
const resolved = (0, path_1.resolve)(rootReal, rawPath);
|
|
98
|
+
const ancestorReal = nearestExistingAncestorRealpath(resolved);
|
|
99
|
+
// If no existing ancestor could be resolved (e.g. EACCES on realpathSync),
|
|
100
|
+
// containment cannot be verified — reject the path.
|
|
101
|
+
if (ancestorReal === undefined) {
|
|
102
|
+
return { contained: false, reason: `cannot verify path containment: ${rawPath}` };
|
|
103
|
+
}
|
|
104
|
+
// Boundary 1: must be inside root.
|
|
105
|
+
if (!isInsideOrEqual(ancestorReal, rootReal)) {
|
|
106
|
+
return { contained: false, reason: `path escapes project root: ${rawPath}` };
|
|
107
|
+
}
|
|
108
|
+
// Boundary 2: if scopes specified, the target must be inside a scope.
|
|
109
|
+
if (scopeReals.length > 0) {
|
|
110
|
+
// If the ancestor is already inside a scope, ok.
|
|
111
|
+
const ancestorInScope = scopeReals.some(s => isInsideOrEqual(ancestorReal, s));
|
|
112
|
+
if (!ancestorInScope) {
|
|
113
|
+
// Ancestor is root (or above scope) but target may descend into a
|
|
114
|
+
// scope. Re-resolve the full target's nearest-existing-ancestor
|
|
115
|
+
// against each scope: the resolved path relative to root must, when
|
|
116
|
+
// joined, fall inside a scope realpath.
|
|
117
|
+
const targetInScope = scopeReals.some(s => {
|
|
118
|
+
// Compute where the target would resolve to relative to root, then
|
|
119
|
+
// check containment against the scope realpath.
|
|
120
|
+
const targetResolved = (0, path_1.resolve)(rootReal, rawPath);
|
|
121
|
+
const targetAncestor = nearestExistingAncestorRealpath(targetResolved);
|
|
122
|
+
return targetAncestor !== undefined && isInsideOrEqual(targetAncestor, s);
|
|
123
|
+
});
|
|
124
|
+
if (!targetInScope) {
|
|
125
|
+
return { contained: false, reason: `path outside packet scope: ${rawPath}` };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { contained: true };
|
|
130
|
+
}
|
|
131
|
+
/** Extract path-bearing arguments from a tool call. */
|
|
132
|
+
function extractPathArgs(tool, args) {
|
|
133
|
+
const paths = [];
|
|
134
|
+
if (PATH_TOOLS.has(tool) ||
|
|
135
|
+
BASE_PATH_TOOLS.has(tool) ||
|
|
136
|
+
SEARCH_PATH_TOOLS.has(tool)) {
|
|
137
|
+
const p = args.path;
|
|
138
|
+
if (typeof p === 'string') {
|
|
139
|
+
paths.push(p);
|
|
140
|
+
}
|
|
141
|
+
// glob/grep with no path default to cwd (inside root) - no check needed.
|
|
142
|
+
}
|
|
143
|
+
if (tool === BATCH_TOOL) {
|
|
144
|
+
const steps = args.steps;
|
|
145
|
+
if (Array.isArray(steps)) {
|
|
146
|
+
for (const step of steps) {
|
|
147
|
+
if (step && typeof step === 'object' && typeof step.tool === 'string') {
|
|
148
|
+
const stepArgs = step.args && typeof step.args === 'object'
|
|
149
|
+
? step.args
|
|
150
|
+
: {};
|
|
151
|
+
paths.push(...extractPathArgs(step.tool, stepArgs));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return paths;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Evaluate whether a tool call is allowed under the guard's boundaries.
|
|
160
|
+
* Pure (modulo realpath reads) so it can be tested in isolation.
|
|
161
|
+
*/
|
|
162
|
+
function evaluateToolCall(tool, args, options) {
|
|
163
|
+
const rootReal = nearestExistingAncestorRealpath(options.rootCwd);
|
|
164
|
+
if (rootReal === undefined) {
|
|
165
|
+
return { ok: false, tool, reason: 'cannot resolve project root realpath' };
|
|
166
|
+
}
|
|
167
|
+
const scopeReals = (options.scopePaths ?? []).map(p => nearestExistingAncestorRealpath((0, path_1.resolve)(rootReal, p))).filter((s) => s !== undefined);
|
|
168
|
+
const pathArgs = extractPathArgs(tool, args);
|
|
169
|
+
for (const path of pathArgs) {
|
|
170
|
+
const verdict = checkContainment(path, rootReal, scopeReals);
|
|
171
|
+
if (!verdict.contained) {
|
|
172
|
+
return { ok: false, tool, reason: verdict.reason ?? 'path rejected', path };
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { ok: true };
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A mutable scope holder: the supervisor sets the current packet's scope
|
|
179
|
+
* before running it, so the turn-level guard can enforce per-packet scope
|
|
180
|
+
* containment without rebuilding the executor per packet.
|
|
181
|
+
*/
|
|
182
|
+
class ScopeHolder {
|
|
183
|
+
constructor() {
|
|
184
|
+
this.current = [];
|
|
185
|
+
}
|
|
186
|
+
setScope(paths) {
|
|
187
|
+
this.current = paths;
|
|
188
|
+
}
|
|
189
|
+
clear() {
|
|
190
|
+
this.current = [];
|
|
191
|
+
}
|
|
192
|
+
getScope() {
|
|
193
|
+
return this.current;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.ScopeHolder = ScopeHolder;
|
|
197
|
+
/**
|
|
198
|
+
* Wrap a child tool executor with containment enforcement. The returned
|
|
199
|
+
* executor delegates to `inner` only when all path-bearing args are inside
|
|
200
|
+
* the project root (and inside the packet scope, if the scope holder is set).
|
|
201
|
+
*/
|
|
202
|
+
function createChildToolExecutorGuard(inner, options) {
|
|
203
|
+
return async (name, args, abortSignal) => {
|
|
204
|
+
const scopePaths = options.scopeHolder?.getScope() ?? options.scopePaths ?? [];
|
|
205
|
+
const verdict = evaluateToolCall(name, args, {
|
|
206
|
+
rootCwd: options.rootCwd,
|
|
207
|
+
scopePaths,
|
|
208
|
+
});
|
|
209
|
+
if (!verdict.ok) {
|
|
210
|
+
return JSON.stringify({
|
|
211
|
+
success: false,
|
|
212
|
+
output: '',
|
|
213
|
+
error: `Subagent scope guard rejected ${verdict.tool}: ${verdict.reason}`,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
return inner(name, args, abortSignal);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=child-executor-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"child-executor-guard.js","sourceRoot":"","sources":["../../../src/runtime/subagents/child-executor-guard.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAsLH,4CAsBC;AA4BD,oEA2BC;AAjQD,+BAAqD;AACrD,2BAA8C;AAE9C,0EAA0E;AAC1E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC;AAExD,iE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IAAI,EAAE,WAAW,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentContextBuilder: assembles the independent child message context.
|
|
3
|
+
*
|
|
4
|
+
* A child does NOT inherit the parent's full transcript. It receives a role
|
|
5
|
+
* system prompt, a read-only summary of the root objective, and the specific
|
|
6
|
+
* task packet with canonical scope. Optional capsule/evidence are injected only
|
|
7
|
+
* when available, kept compact to avoid polluting the child context.
|
|
8
|
+
*/
|
|
9
|
+
import type { Message } from '../../services/llm';
|
|
10
|
+
import type { ContextCapsule } from '../../harness/types';
|
|
11
|
+
import type { SubtaskPacket } from './types';
|
|
12
|
+
export interface ChildContextInputs {
|
|
13
|
+
/** Canonical project root the child operates in. */
|
|
14
|
+
cwd: string;
|
|
15
|
+
/** The task packet (objective, scope, expectedOutput, hints). */
|
|
16
|
+
packet: SubtaskPacket;
|
|
17
|
+
/** Canonical scope paths already validated by policy. */
|
|
18
|
+
canonicalScopePaths?: string[];
|
|
19
|
+
/** Read-only summary of the root objective; never the full parent transcript. */
|
|
20
|
+
rootObjectiveSummary?: string;
|
|
21
|
+
/** Parent harness capsule, compacted to its salient fields. */
|
|
22
|
+
capsule?: ContextCapsule;
|
|
23
|
+
/** Model/provider info shown to the child so it understands its limits. */
|
|
24
|
+
modelLabel?: string;
|
|
25
|
+
/** Active project instructions / skill guidance (read-only). */
|
|
26
|
+
projectInstructions?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Build the child message list. The first message is always the role system
|
|
30
|
+
* prompt; a single user message frames the task. The child loop appends its
|
|
31
|
+
* own assistant/tool messages on top of this.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildChildMessages(inputs: ChildContextInputs): Message[];
|
|
34
|
+
//# sourceMappingURL=context-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-builder.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/context-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,iEAAiE;IACjE,MAAM,EAAE,aAAa,CAAC;IACtB,yDAAyD;IACzD,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,iFAAiF;IACjF,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,EAAE,CAwDxE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SubagentContextBuilder: assembles the independent child message context.
|
|
4
|
+
*
|
|
5
|
+
* A child does NOT inherit the parent's full transcript. It receives a role
|
|
6
|
+
* system prompt, a read-only summary of the root objective, and the specific
|
|
7
|
+
* task packet with canonical scope. Optional capsule/evidence are injected only
|
|
8
|
+
* when available, kept compact to avoid polluting the child context.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.buildChildMessages = buildChildMessages;
|
|
12
|
+
const presets_1 = require("./presets");
|
|
13
|
+
/**
|
|
14
|
+
* Build the child message list. The first message is always the role system
|
|
15
|
+
* prompt; a single user message frames the task. The child loop appends its
|
|
16
|
+
* own assistant/tool messages on top of this.
|
|
17
|
+
*/
|
|
18
|
+
function buildChildMessages(inputs) {
|
|
19
|
+
const { packet, cwd } = inputs;
|
|
20
|
+
const systemPrompt = assembleSystemPrompt(inputs);
|
|
21
|
+
const userPrompt = assembleUserPrompt(inputs);
|
|
22
|
+
return [
|
|
23
|
+
{ role: 'system', content: systemPrompt },
|
|
24
|
+
{ role: 'user', content: userPrompt },
|
|
25
|
+
];
|
|
26
|
+
function assembleSystemPrompt(i) {
|
|
27
|
+
const rolePrompt = (0, presets_1.systemPromptForRole)(packet.role);
|
|
28
|
+
const lines = [rolePrompt, ''];
|
|
29
|
+
lines.push(`# Operating context`);
|
|
30
|
+
lines.push(`- Project root: ${cwd}`);
|
|
31
|
+
if (i.modelLabel)
|
|
32
|
+
lines.push(`- Model: ${i.modelLabel}`);
|
|
33
|
+
lines.push('- You are a child agent at delegation depth 1. You may NOT create further subagents.');
|
|
34
|
+
lines.push('- You may NOT edit, write, delete, commit, push, publish, install, or run shell commands.');
|
|
35
|
+
if (i.rootObjectiveSummary) {
|
|
36
|
+
lines.push('');
|
|
37
|
+
lines.push(`# Root objective (read-only summary)`);
|
|
38
|
+
lines.push(truncate(i.rootObjectiveSummary, 800));
|
|
39
|
+
}
|
|
40
|
+
if (i.projectInstructions) {
|
|
41
|
+
lines.push('');
|
|
42
|
+
lines.push(`# Project instructions (read-only)`);
|
|
43
|
+
lines.push(truncate(i.projectInstructions, 1200));
|
|
44
|
+
}
|
|
45
|
+
if (i.capsule) {
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push(`# Parent context capsule (read-only)`);
|
|
48
|
+
lines.push(compactCapsule(i.capsule));
|
|
49
|
+
}
|
|
50
|
+
return lines.join('\n');
|
|
51
|
+
}
|
|
52
|
+
function assembleUserPrompt(i) {
|
|
53
|
+
const lines = [];
|
|
54
|
+
lines.push(`## Task`);
|
|
55
|
+
lines.push(`role: ${packet.role}`);
|
|
56
|
+
lines.push(`objective: ${packet.objective}`);
|
|
57
|
+
if (packet.reason)
|
|
58
|
+
lines.push(`reason: ${packet.reason}`);
|
|
59
|
+
if (i.canonicalScopePaths && i.canonicalScopePaths.length > 0) {
|
|
60
|
+
lines.push(`scope: ${i.canonicalScopePaths.join(', ')}`);
|
|
61
|
+
}
|
|
62
|
+
if (packet.contextHints && packet.contextHints.length > 0) {
|
|
63
|
+
lines.push(`hints:`);
|
|
64
|
+
for (const hint of packet.contextHints)
|
|
65
|
+
lines.push(` - ${hint}`);
|
|
66
|
+
}
|
|
67
|
+
if (packet.expectedOutput) {
|
|
68
|
+
lines.push(`expected output: ${packet.expectedOutput}`);
|
|
69
|
+
}
|
|
70
|
+
lines.push('');
|
|
71
|
+
lines.push('Investigate now using only the read-only tools available to you, then emit the JSON result object as specified in your system prompt.');
|
|
72
|
+
return lines.join('\n');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function compactCapsule(capsule) {
|
|
76
|
+
const lines = [];
|
|
77
|
+
if (capsule.contract?.objective)
|
|
78
|
+
lines.push(`- contract objective: ${truncate(capsule.contract.objective, 200)}`);
|
|
79
|
+
if (capsule.completed.length > 0)
|
|
80
|
+
lines.push(`- completed: ${truncate(capsule.completed.join('; '), 300)}`);
|
|
81
|
+
if (capsule.openTodos.length > 0)
|
|
82
|
+
lines.push(`- open todos: ${truncate(capsule.openTodos.join('; '), 300)}`);
|
|
83
|
+
if (capsule.changedFiles.length > 0)
|
|
84
|
+
lines.push(`- changed files: ${truncate(capsule.changedFiles.join(', '), 300)}`);
|
|
85
|
+
if (capsule.keyFacts.length > 0) {
|
|
86
|
+
lines.push(`- key facts:`);
|
|
87
|
+
for (const fact of capsule.keyFacts.slice(0, 5))
|
|
88
|
+
lines.push(` - ${truncate(fact.content, 160)}`);
|
|
89
|
+
}
|
|
90
|
+
if (capsule.nextAction)
|
|
91
|
+
lines.push(`- next action: ${truncate(capsule.nextAction, 200)}`);
|
|
92
|
+
return lines.length > 0 ? lines.join('\n') : '(no capsule fields)';
|
|
93
|
+
}
|
|
94
|
+
function truncate(text, max) {
|
|
95
|
+
if (text.length <= max)
|
|
96
|
+
return text;
|
|
97
|
+
return `${text.slice(0, max - 1)}…`;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=context-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-builder.js","sourceRoot":"","sources":["../../../src/runtime/subagents/context-builder.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;AA6BH,gDAwDC;AAjFD,uCAAgD;AAoBhD;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,MAA0B;IAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;IAC/B,MAAM,YAAY,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAE9C,OAAO;QACL,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE;QACzC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE;KACtC,CAAC;IAEF,SAAS,oBAAoB,CAAC,CAAqB;QACjD,MAAM,UAAU,GAAG,IAAA,6BAAmB,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,KAAK,GAAa,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,CAAC,UAAU;YAAE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC;QACzD,KAAK,CAAC,IAAI,CAAC,sFAAsF,CAAC,CAAC;QACnG,KAAK,CAAC,IAAI,CAAC,2FAA2F,CAAC,CAAC;QACxG,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAA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E,CAAC,CAAC;IAC7G,IAAI,OAAO,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,oBAAoB,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACtH,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACpG,CAAC;IACD,IAAI,OAAO,CAAC,UAAU;QAAE,KAAK,CAAC,IAAI,CAAC,kBAAkB,QAAQ,CAAC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1F,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC;AACrE,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAW;IACzC,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IACpC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent runtime public surface.
|
|
3
|
+
*
|
|
4
|
+
* v0.2.20 exposes a read-only subagent runtime. The root Agent may request
|
|
5
|
+
* 1-3 independent investigation packets; a Supervisor runs them as isolated
|
|
6
|
+
* child agents under a unified budget, permission boundary and trace.
|
|
7
|
+
*/
|
|
8
|
+
export * from './types';
|
|
9
|
+
export * from './presets';
|
|
10
|
+
export { evaluateSubtaskPolicy, canonicalizeScopePaths, hasExplicitDelegationIntent, clampSubagentConfig, type PolicyContext, type PolicyVerdict, type PolicyRejectReason, } from './policy';
|
|
11
|
+
export { SubagentBudgetLedger, TurnTaskState, budgetLimitsFromConfig, type SubagentBudgetLimits, type ReservedBudget, type BudgetSnapshot, type BudgetViolation, } from './budget';
|
|
12
|
+
export { buildChildMessages, type ChildContextInputs } from './context-builder';
|
|
13
|
+
export { parseSubtaskResult, extractJsonObject, type ParsedSubtaskPayload } from './result-parser';
|
|
14
|
+
export { createChildToolExecutorGuard, evaluateToolCall, ScopeHolder, type GuardOptions, type GuardVerdict, } from './child-executor-guard';
|
|
15
|
+
export { runSubtask, type SubagentRunnerDeps, type ChildToolSet, type ExecuteChildQuery, type RunSubtaskOutcome, } from './runner';
|
|
16
|
+
export { SubagentProviderGate, type ProviderGateOptions, } from './provider-gate';
|
|
17
|
+
export { runSubtaskBatch, type SubagentSupervisorDeps, type RunBatchOutcome, } from './supervisor';
|
|
18
|
+
export { createSubtaskTool, coerceSubtaskRequest, summarizeBatchForModel, } from './tool';
|
|
19
|
+
export { createProductionExecuteQuery, createChildLlmConfig, type SubagentLlmFactoryDeps, } from './production';
|
|
20
|
+
export { createSubagentToolForTurn, createSubagentBundleForTurn, deriveRootLlmConfig, type SubagentTurnInputs, type SubagentTurnBundle, } from './runtime-integration';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,sBAAsB,EACtB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EACL,4BAA4B,EAC5B,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,UAAU,EACV,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,KAAK,sBAAsB,EAC3B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,4BAA4B,EAC5B,oBAAoB,EACpB,KAAK,sBAAsB,GAC5B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Subagent runtime public surface.
|
|
4
|
+
*
|
|
5
|
+
* v0.2.20 exposes a read-only subagent runtime. The root Agent may request
|
|
6
|
+
* 1-3 independent investigation packets; a Supervisor runs them as isolated
|
|
7
|
+
* child agents under a unified budget, permission boundary and trace.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.deriveRootLlmConfig = exports.createSubagentBundleForTurn = exports.createSubagentToolForTurn = exports.createChildLlmConfig = exports.createProductionExecuteQuery = exports.summarizeBatchForModel = exports.coerceSubtaskRequest = exports.createSubtaskTool = exports.runSubtaskBatch = exports.SubagentProviderGate = exports.runSubtask = exports.ScopeHolder = exports.evaluateToolCall = exports.createChildToolExecutorGuard = exports.extractJsonObject = exports.parseSubtaskResult = exports.buildChildMessages = exports.budgetLimitsFromConfig = exports.TurnTaskState = exports.SubagentBudgetLedger = exports.clampSubagentConfig = exports.hasExplicitDelegationIntent = exports.canonicalizeScopePaths = exports.evaluateSubtaskPolicy = void 0;
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./presets"), exports);
|
|
27
|
+
var policy_1 = require("./policy");
|
|
28
|
+
Object.defineProperty(exports, "evaluateSubtaskPolicy", { enumerable: true, get: function () { return policy_1.evaluateSubtaskPolicy; } });
|
|
29
|
+
Object.defineProperty(exports, "canonicalizeScopePaths", { enumerable: true, get: function () { return policy_1.canonicalizeScopePaths; } });
|
|
30
|
+
Object.defineProperty(exports, "hasExplicitDelegationIntent", { enumerable: true, get: function () { return policy_1.hasExplicitDelegationIntent; } });
|
|
31
|
+
Object.defineProperty(exports, "clampSubagentConfig", { enumerable: true, get: function () { return policy_1.clampSubagentConfig; } });
|
|
32
|
+
var budget_1 = require("./budget");
|
|
33
|
+
Object.defineProperty(exports, "SubagentBudgetLedger", { enumerable: true, get: function () { return budget_1.SubagentBudgetLedger; } });
|
|
34
|
+
Object.defineProperty(exports, "TurnTaskState", { enumerable: true, get: function () { return budget_1.TurnTaskState; } });
|
|
35
|
+
Object.defineProperty(exports, "budgetLimitsFromConfig", { enumerable: true, get: function () { return budget_1.budgetLimitsFromConfig; } });
|
|
36
|
+
var context_builder_1 = require("./context-builder");
|
|
37
|
+
Object.defineProperty(exports, "buildChildMessages", { enumerable: true, get: function () { return context_builder_1.buildChildMessages; } });
|
|
38
|
+
var result_parser_1 = require("./result-parser");
|
|
39
|
+
Object.defineProperty(exports, "parseSubtaskResult", { enumerable: true, get: function () { return result_parser_1.parseSubtaskResult; } });
|
|
40
|
+
Object.defineProperty(exports, "extractJsonObject", { enumerable: true, get: function () { return result_parser_1.extractJsonObject; } });
|
|
41
|
+
var child_executor_guard_1 = require("./child-executor-guard");
|
|
42
|
+
Object.defineProperty(exports, "createChildToolExecutorGuard", { enumerable: true, get: function () { return child_executor_guard_1.createChildToolExecutorGuard; } });
|
|
43
|
+
Object.defineProperty(exports, "evaluateToolCall", { enumerable: true, get: function () { return child_executor_guard_1.evaluateToolCall; } });
|
|
44
|
+
Object.defineProperty(exports, "ScopeHolder", { enumerable: true, get: function () { return child_executor_guard_1.ScopeHolder; } });
|
|
45
|
+
var runner_1 = require("./runner");
|
|
46
|
+
Object.defineProperty(exports, "runSubtask", { enumerable: true, get: function () { return runner_1.runSubtask; } });
|
|
47
|
+
var provider_gate_1 = require("./provider-gate");
|
|
48
|
+
Object.defineProperty(exports, "SubagentProviderGate", { enumerable: true, get: function () { return provider_gate_1.SubagentProviderGate; } });
|
|
49
|
+
var supervisor_1 = require("./supervisor");
|
|
50
|
+
Object.defineProperty(exports, "runSubtaskBatch", { enumerable: true, get: function () { return supervisor_1.runSubtaskBatch; } });
|
|
51
|
+
var tool_1 = require("./tool");
|
|
52
|
+
Object.defineProperty(exports, "createSubtaskTool", { enumerable: true, get: function () { return tool_1.createSubtaskTool; } });
|
|
53
|
+
Object.defineProperty(exports, "coerceSubtaskRequest", { enumerable: true, get: function () { return tool_1.coerceSubtaskRequest; } });
|
|
54
|
+
Object.defineProperty(exports, "summarizeBatchForModel", { enumerable: true, get: function () { return tool_1.summarizeBatchForModel; } });
|
|
55
|
+
var production_1 = require("./production");
|
|
56
|
+
Object.defineProperty(exports, "createProductionExecuteQuery", { enumerable: true, get: function () { return production_1.createProductionExecuteQuery; } });
|
|
57
|
+
Object.defineProperty(exports, "createChildLlmConfig", { enumerable: true, get: function () { return production_1.createChildLlmConfig; } });
|
|
58
|
+
var runtime_integration_1 = require("./runtime-integration");
|
|
59
|
+
Object.defineProperty(exports, "createSubagentToolForTurn", { enumerable: true, get: function () { return runtime_integration_1.createSubagentToolForTurn; } });
|
|
60
|
+
Object.defineProperty(exports, "createSubagentBundleForTurn", { enumerable: true, get: function () { return runtime_integration_1.createSubagentBundleForTurn; } });
|
|
61
|
+
Object.defineProperty(exports, "deriveRootLlmConfig", { enumerable: true, get: function () { return runtime_integration_1.deriveRootLlmConfig; } });
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/subagents/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,4CAA0B;AAC1B,mCAQkB;AAPhB,+GAAA,qBAAqB,OAAA;AACrB,gHAAA,sBAAsB,OAAA;AACtB,qHAAA,2BAA2B,OAAA;AAC3B,6GAAA,mBAAmB,OAAA;AAKrB,mCAQkB;AAPhB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,gHAAA,sBAAsB,OAAA;AAMxB,qDAAgF;AAAvE,qHAAA,kBAAkB,OAAA;AAC3B,iDAAmG;AAA1F,mHAAA,kBAAkB,OAAA;AAAE,kHAAA,iBAAiB,OAAA;AAC9C,+DAMgC;AAL9B,oIAAA,4BAA4B,OAAA;AAC5B,wHAAA,gBAAgB,OAAA;AAChB,mHAAA,WAAW,OAAA;AAIb,mCAMkB;AALhB,oGAAA,UAAU,OAAA;AAMZ,iDAGyB;AAFvB,qHAAA,oBAAoB,OAAA;AAGtB,2CAIsB;AAHpB,6GAAA,eAAe,OAAA;AAIjB,+BAIgB;AAHd,yGAAA,iBAAiB,OAAA;AACjB,4GAAA,oBAAoB,OAAA;AACpB,8GAAA,sBAAsB,OAAA;AAExB,2CAIsB;AAHpB,0HAAA,4BAA4B,OAAA;AAC5B,kHAAA,oBAAoB,OAAA;AAGtB,6DAM+B;AAL7B,gIAAA,yBAAyB,OAAA;AACzB,kIAAA,2BAA2B,OAAA;AAC3B,0HAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentPolicy: deterministic approval gate for `subtask` requests.
|
|
3
|
+
*
|
|
4
|
+
* The root Agent proposes work packages; the runtime decides whether they may
|
|
5
|
+
* run. Every allow/reject decision is recorded with a reason and a budget
|
|
6
|
+
* snapshot, so the policy is auditable rather than hidden in a classifier.
|
|
7
|
+
*
|
|
8
|
+
* Scope canonicalization lives here too: child paths must stay inside the
|
|
9
|
+
* project root. `../`, absolute escapes and symlink escapes are rejected.
|
|
10
|
+
*/
|
|
11
|
+
import type { SubagentConfig, SubtaskRequest } from './types';
|
|
12
|
+
export type PolicyVerdict = {
|
|
13
|
+
allowed: true;
|
|
14
|
+
canonicalScope: Map<number, string[]>;
|
|
15
|
+
} | {
|
|
16
|
+
allowed: false;
|
|
17
|
+
reason: PolicyRejectReason;
|
|
18
|
+
detail?: string;
|
|
19
|
+
};
|
|
20
|
+
export type PolicyRejectReason = 'mode_off' | 'not_root_depth' | 'explicit_intent_missing' | 'too_many_tasks' | 'role_disabled' | 'objective_unbounded' | 'duplicate_scope' | 'scope_escape' | 'pending_permission' | 'parent_aborted' | 'budget_exhausted' | 'provider_unavailable' | 'concurrency_limit' | 'empty_request' | 'not_eligible_for_delegation';
|
|
21
|
+
export interface PolicyContext {
|
|
22
|
+
/** Current delegation depth. Only depth 0 (root) may delegate. */
|
|
23
|
+
depth: number;
|
|
24
|
+
/** Canonical project root the children operate in. */
|
|
25
|
+
cwd: string;
|
|
26
|
+
/** Active config. */
|
|
27
|
+
config: SubagentConfig;
|
|
28
|
+
/** Root objective text, used to detect explicit delegation intent. */
|
|
29
|
+
rootObjective: string;
|
|
30
|
+
/** Subtasks already started in this root turn. */
|
|
31
|
+
tasksStartedThisTurn: number;
|
|
32
|
+
/** Children currently running. */
|
|
33
|
+
runningChildren: number;
|
|
34
|
+
/** A permission request is awaiting user decision. */
|
|
35
|
+
hasPendingPermission: boolean;
|
|
36
|
+
/** Parent turn abort signal has fired. */
|
|
37
|
+
parentAborted: boolean;
|
|
38
|
+
/** Remaining aggregate model-request budget for the turn. */
|
|
39
|
+
remainingModelRequests: number;
|
|
40
|
+
/** Provider gate can reserve a slot for every task in the batch. */
|
|
41
|
+
providerCanReserve: (count: number) => boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Canonicalize a list of scope paths against the project root.
|
|
45
|
+
*
|
|
46
|
+
* Returns the canonical relative paths for paths that stay inside the root,
|
|
47
|
+
* or `null` if any path escapes (via `..`, absolute outside root, or symlink).
|
|
48
|
+
* Symlink defense only applies to paths that exist on disk: a non-existent
|
|
49
|
+
* path cannot be a symlink escape, and skipping it avoids root/child realpath
|
|
50
|
+
* basis mismatches (e.g. macOS `/tmp` -> `/private/tmp`).
|
|
51
|
+
*/
|
|
52
|
+
export declare function canonicalizeScopePaths(rootCwd: string, paths: readonly string[] | undefined): {
|
|
53
|
+
ok: true;
|
|
54
|
+
paths: string[];
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
reason: 'scope_escape';
|
|
58
|
+
path: string;
|
|
59
|
+
};
|
|
60
|
+
export declare function hasExplicitDelegationIntent(rootObjective: string): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Evaluate a `subtask` request against the policy. This is the single
|
|
63
|
+
* deterministic gate every request must pass before any child is queued.
|
|
64
|
+
*/
|
|
65
|
+
export declare function evaluateSubtaskPolicy(request: SubtaskRequest, ctx: PolicyContext): PolicyVerdict;
|
|
66
|
+
/** Clamp a user-provided config value to the enforced bounds. */
|
|
67
|
+
export declare function clampSubagentConfig(config: SubagentConfig): SubagentConfig;
|
|
68
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/runtime/subagents/policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,KAAK,EACV,cAAc,EAId,cAAc,EACf,MAAM,SAAS,CAAC;AAGjB,MAAM,MAAM,aAAa,GACrB;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CAAE,GACxD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,gBAAgB,GAChB,yBAAyB,GACzB,gBAAgB,GAChB,eAAe,GACf,qBAAqB,GACrB,iBAAiB,GACjB,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,kBAAkB,GAClB,sBAA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