@greppleai/grip 0.0.0-stage → 0.1.3
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/CHANGELOG.md +115 -0
- package/README.md +731 -2
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +13 -0
- package/dist/bun/cli.js.map +1 -0
- package/dist/bun/embedded-assets.d.ts +3 -0
- package/dist/bun/embedded-assets.d.ts.map +1 -0
- package/dist/bun/embedded-assets.js +52 -0
- package/dist/bun/embedded-assets.js.map +1 -0
- package/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/bun/register-bedrock.d.ts.map +1 -0
- package/dist/bun/register-bedrock.js +4 -0
- package/dist/bun/register-bedrock.js.map +1 -0
- package/dist/bun/restore-sandbox-env.d.ts +13 -0
- package/dist/bun/restore-sandbox-env.d.ts.map +1 -0
- package/dist/bun/restore-sandbox-env.js +32 -0
- package/dist/bun/restore-sandbox-env.js.map +1 -0
- package/dist/cli/args.d.ts +70 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +442 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/file-processor.d.ts +15 -0
- package/dist/cli/file-processor.d.ts.map +1 -0
- package/dist/cli/file-processor.js +60 -0
- package/dist/cli/file-processor.js.map +1 -0
- package/dist/cli/initial-message.d.ts +18 -0
- package/dist/cli/initial-message.d.ts.map +1 -0
- package/dist/cli/initial-message.js +22 -0
- package/dist/cli/initial-message.js.map +1 -0
- package/dist/cli/list-models.d.ts +9 -0
- package/dist/cli/list-models.d.ts.map +1 -0
- package/dist/cli/list-models.js +98 -0
- package/dist/cli/list-models.js.map +1 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.d.ts.map +1 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/session-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +406 -0
- package/dist/config.js.map +1 -0
- package/dist/core/agent-session.d.ts +970 -0
- package/dist/core/agent-session.d.ts.map +1 -0
- package/dist/core/agent-session.js +5191 -0
- package/dist/core/agent-session.js.map +1 -0
- package/dist/core/auth-guidance.d.ts +5 -0
- package/dist/core/auth-guidance.d.ts.map +1 -0
- package/dist/core/auth-guidance.js +21 -0
- package/dist/core/auth-guidance.js.map +1 -0
- package/dist/core/auth-storage.d.ts +150 -0
- package/dist/core/auth-storage.d.ts.map +1 -0
- package/dist/core/auth-storage.js +557 -0
- package/dist/core/auth-storage.js.map +1 -0
- package/dist/core/bash-executor.d.ts +26 -0
- package/dist/core/bash-executor.d.ts.map +1 -0
- package/dist/core/bash-executor.js +99 -0
- package/dist/core/bash-executor.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +83 -0
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/core/compaction/branch-summarization.js +220 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +65 -0
- package/dist/core/compaction/compaction.d.ts.map +1 -0
- package/dist/core/compaction/compaction.js +550 -0
- package/dist/core/compaction/compaction.js.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts +34 -0
- package/dist/core/compaction/compression-detection-ledger.d.ts.map +1 -0
- package/dist/core/compaction/compression-detection-ledger.js +52 -0
- package/dist/core/compaction/compression-detection-ledger.js.map +1 -0
- package/dist/core/compaction/compression-detector.d.ts +71 -0
- package/dist/core/compaction/compression-detector.d.ts.map +1 -0
- package/dist/core/compaction/compression-detector.js +407 -0
- package/dist/core/compaction/compression-detector.js.map +1 -0
- package/dist/core/compaction/compression-economics.d.ts +55 -0
- package/dist/core/compaction/compression-economics.d.ts.map +1 -0
- package/dist/core/compaction/compression-economics.js +151 -0
- package/dist/core/compaction/compression-economics.js.map +1 -0
- package/dist/core/compaction/utils.d.ts +28 -0
- package/dist/core/compaction/utils.d.ts.map +1 -0
- package/dist/core/compaction/utils.js +165 -0
- package/dist/core/compaction/utils.js.map +1 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.d.ts.map +1 -0
- package/dist/core/defaults.js +2 -0
- package/dist/core/defaults.js.map +1 -0
- package/dist/core/diagnostics.d.ts +18 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/event-bus.d.ts +9 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +25 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/exec.d.ts +29 -0
- package/dist/core/exec.d.ts.map +1 -0
- package/dist/core/exec.js +75 -0
- package/dist/core/exec.js.map +1 -0
- package/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
- package/dist/core/export-html/ansi-to-html.js +245 -0
- package/dist/core/export-html/ansi-to-html.js.map +1 -0
- package/dist/core/export-html/index.d.ts +21 -0
- package/dist/core/export-html/index.d.ts.map +1 -0
- package/dist/core/export-html/index.js +230 -0
- package/dist/core/export-html/index.js.map +1 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +32 -0
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
- package/dist/core/export-html/tool-renderer.js +108 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/loader.d.ts +24 -0
- package/dist/core/extensions/loader.d.ts.map +1 -0
- package/dist/core/extensions/loader.js +613 -0
- package/dist/core/extensions/loader.js.map +1 -0
- package/dist/core/extensions/runner.d.ts +160 -0
- package/dist/core/extensions/runner.d.ts.map +1 -0
- package/dist/core/extensions/runner.js +962 -0
- package/dist/core/extensions/runner.js.map +1 -0
- package/dist/core/extensions/types.d.ts +1311 -0
- package/dist/core/extensions/types.d.ts.map +1 -0
- package/dist/core/extensions/types.js +51 -0
- package/dist/core/extensions/types.js.map +1 -0
- package/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/core/extensions/wrapper.d.ts.map +1 -0
- package/dist/core/extensions/wrapper.js +22 -0
- package/dist/core/extensions/wrapper.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +52 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -0
- package/dist/core/footer-data-provider.js +318 -0
- package/dist/core/footer-data-provider.js.map +1 -0
- package/dist/core/grip-agent.d.ts +240 -0
- package/dist/core/grip-agent.d.ts.map +1 -0
- package/dist/core/grip-agent.js +1243 -0
- package/dist/core/grip-agent.js.map +1 -0
- package/dist/core/grip-manifest.d.ts +9 -0
- package/dist/core/grip-manifest.d.ts.map +1 -0
- package/dist/core/grip-manifest.js +25 -0
- package/dist/core/grip-manifest.js.map +1 -0
- package/dist/core/hooks/aggregate.d.ts +5 -0
- package/dist/core/hooks/aggregate.d.ts.map +1 -0
- package/dist/core/hooks/aggregate.js +226 -0
- package/dist/core/hooks/aggregate.js.map +1 -0
- package/dist/core/hooks/config.d.ts +14 -0
- package/dist/core/hooks/config.d.ts.map +1 -0
- package/dist/core/hooks/config.js +372 -0
- package/dist/core/hooks/config.js.map +1 -0
- package/dist/core/hooks/executor.d.ts +12 -0
- package/dist/core/hooks/executor.d.ts.map +1 -0
- package/dist/core/hooks/executor.js +708 -0
- package/dist/core/hooks/executor.js.map +1 -0
- package/dist/core/hooks/index.d.ts +9 -0
- package/dist/core/hooks/index.d.ts.map +1 -0
- package/dist/core/hooks/index.js +14 -0
- package/dist/core/hooks/index.js.map +1 -0
- package/dist/core/hooks/matcher.d.ts +10 -0
- package/dist/core/hooks/matcher.d.ts.map +1 -0
- package/dist/core/hooks/matcher.js +70 -0
- package/dist/core/hooks/matcher.js.map +1 -0
- package/dist/core/hooks/trust-store.d.ts +38 -0
- package/dist/core/hooks/trust-store.d.ts.map +1 -0
- package/dist/core/hooks/trust-store.js +167 -0
- package/dist/core/hooks/trust-store.js.map +1 -0
- package/dist/core/hooks/types.d.ts +234 -0
- package/dist/core/hooks/types.d.ts.map +1 -0
- package/dist/core/hooks/types.js +52 -0
- package/dist/core/hooks/types.js.map +1 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.d.ts.map +1 -0
- package/dist/core/http-dispatcher.js +82 -0
- package/dist/core/http-dispatcher.js.map +1 -0
- package/dist/core/instruction-resource-loader.d.ts +81 -0
- package/dist/core/instruction-resource-loader.d.ts.map +1 -0
- package/dist/core/instruction-resource-loader.js +574 -0
- package/dist/core/instruction-resource-loader.js.map +1 -0
- package/dist/core/keybindings.d.ts +399 -0
- package/dist/core/keybindings.d.ts.map +1 -0
- package/dist/core/keybindings.js +299 -0
- package/dist/core/keybindings.js.map +1 -0
- package/dist/core/lsp/abort.d.ts +3 -0
- package/dist/core/lsp/abort.d.ts.map +1 -0
- package/dist/core/lsp/abort.js +28 -0
- package/dist/core/lsp/abort.js.map +1 -0
- package/dist/core/lsp/client.d.ts +108 -0
- package/dist/core/lsp/client.d.ts.map +1 -0
- package/dist/core/lsp/client.js +586 -0
- package/dist/core/lsp/client.js.map +1 -0
- package/dist/core/lsp/config-loader.d.ts +44 -0
- package/dist/core/lsp/config-loader.d.ts.map +1 -0
- package/dist/core/lsp/config-loader.js +223 -0
- package/dist/core/lsp/config-loader.js.map +1 -0
- package/dist/core/lsp/config.d.ts +134 -0
- package/dist/core/lsp/config.d.ts.map +1 -0
- package/dist/core/lsp/config.js +682 -0
- package/dist/core/lsp/config.js.map +1 -0
- package/dist/core/lsp/diagnostics.d.ts +18 -0
- package/dist/core/lsp/diagnostics.d.ts.map +1 -0
- package/dist/core/lsp/diagnostics.js +311 -0
- package/dist/core/lsp/diagnostics.js.map +1 -0
- package/dist/core/lsp/file-sync.d.ts +58 -0
- package/dist/core/lsp/file-sync.d.ts.map +1 -0
- package/dist/core/lsp/file-sync.js +432 -0
- package/dist/core/lsp/file-sync.js.map +1 -0
- package/dist/core/lsp/integration.d.ts +62 -0
- package/dist/core/lsp/integration.d.ts.map +1 -0
- package/dist/core/lsp/integration.js +145 -0
- package/dist/core/lsp/integration.js.map +1 -0
- package/dist/core/lsp/language-map.d.ts +54 -0
- package/dist/core/lsp/language-map.d.ts.map +1 -0
- package/dist/core/lsp/language-map.js +300 -0
- package/dist/core/lsp/language-map.js.map +1 -0
- package/dist/core/lsp/manager.d.ts +120 -0
- package/dist/core/lsp/manager.d.ts.map +1 -0
- package/dist/core/lsp/manager.js +636 -0
- package/dist/core/lsp/manager.js.map +1 -0
- package/dist/core/lsp/navigation.d.ts +32 -0
- package/dist/core/lsp/navigation.d.ts.map +1 -0
- package/dist/core/lsp/navigation.js +327 -0
- package/dist/core/lsp/navigation.js.map +1 -0
- package/dist/core/lsp/portable-path.d.ts +18 -0
- package/dist/core/lsp/portable-path.d.ts.map +1 -0
- package/dist/core/lsp/portable-path.js +83 -0
- package/dist/core/lsp/portable-path.js.map +1 -0
- package/dist/core/lsp/refactor.d.ts +32 -0
- package/dist/core/lsp/refactor.d.ts.map +1 -0
- package/dist/core/lsp/refactor.js +519 -0
- package/dist/core/lsp/refactor.js.map +1 -0
- package/dist/core/lsp/transport.d.ts +39 -0
- package/dist/core/lsp/transport.d.ts.map +1 -0
- package/dist/core/lsp/transport.js +261 -0
- package/dist/core/lsp/transport.js.map +1 -0
- package/dist/core/messages.d.ts +34 -0
- package/dist/core/messages.d.ts.map +1 -0
- package/dist/core/messages.js +140 -0
- package/dist/core/messages.js.map +1 -0
- package/dist/core/model-registry.d.ts +148 -0
- package/dist/core/model-registry.d.ts.map +1 -0
- package/dist/core/model-registry.js +812 -0
- package/dist/core/model-registry.js.map +1 -0
- package/dist/core/model-resolver.d.ts +115 -0
- package/dist/core/model-resolver.d.ts.map +1 -0
- package/dist/core/model-resolver.js +498 -0
- package/dist/core/model-resolver.js.map +1 -0
- package/dist/core/output-guard.d.ts +7 -0
- package/dist/core/output-guard.d.ts.map +1 -0
- package/dist/core/output-guard.js +89 -0
- package/dist/core/output-guard.js.map +1 -0
- package/dist/core/package-manager.d.ts +209 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +2341 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +57 -0
- package/dist/core/prompt-templates.d.ts.map +1 -0
- package/dist/core/prompt-templates.js +353 -0
- package/dist/core/prompt-templates.js.map +1 -0
- package/dist/core/provider-display-names.d.ts +2 -0
- package/dist/core/provider-display-names.d.ts.map +1 -0
- package/dist/core/provider-display-names.js +33 -0
- package/dist/core/provider-display-names.js.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts +465 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.js +825 -0
- package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts +16 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.js +54 -0
- package/dist/core/remote-workspace-protocol/guest-shared-client.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts +23 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js +112 -0
- package/dist/core/remote-workspace-protocol/guest-shared-outbound-scheduler.js.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts +30 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js +243 -0
- package/dist/core/remote-workspace-protocol/guest-shared-uplink.js.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts +3 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.js +31 -0
- package/dist/core/remote-workspace-protocol/lima-owner-directory.js.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts +9 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.js +89 -0
- package/dist/core/remote-workspace-protocol/lima-owner-lock.js.map +1 -0
- package/dist/core/remote-workspace-protocol/session.d.ts +249 -0
- package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/session.js +1842 -0
- package/dist/core/remote-workspace-protocol/session.js.map +1 -0
- package/dist/core/remote-workspace-protocol/shared-transport.d.ts +71 -0
- package/dist/core/remote-workspace-protocol/shared-transport.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/shared-transport.js +68 -0
- package/dist/core/remote-workspace-protocol/shared-transport.js.map +1 -0
- package/dist/core/resolve-config-value.d.ts +32 -0
- package/dist/core/resolve-config-value.d.ts.map +1 -0
- package/dist/core/resolve-config-value.js +257 -0
- package/dist/core/resolve-config-value.js.map +1 -0
- package/dist/core/resource-loader.d.ts +200 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +1209 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/rules.d.ts +40 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +57 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/sandbox/command.d.ts +25 -0
- package/dist/core/sandbox/command.d.ts.map +1 -0
- package/dist/core/sandbox/command.js +102 -0
- package/dist/core/sandbox/command.js.map +1 -0
- package/dist/core/sandbox/config.d.ts +91 -0
- package/dist/core/sandbox/config.d.ts.map +1 -0
- package/dist/core/sandbox/config.js +88 -0
- package/dist/core/sandbox/config.js.map +1 -0
- package/dist/core/sandbox/lima-guest-binary.d.ts +11 -0
- package/dist/core/sandbox/lima-guest-binary.d.ts.map +1 -0
- package/dist/core/sandbox/lima-guest-binary.js +140 -0
- package/dist/core/sandbox/lima-guest-binary.js.map +1 -0
- package/dist/core/sandbox/lima.d.ts +57 -0
- package/dist/core/sandbox/lima.d.ts.map +1 -0
- package/dist/core/sandbox/lima.js +716 -0
- package/dist/core/sandbox/lima.js.map +1 -0
- package/dist/core/sandbox/shared-lima-roots.d.ts +11 -0
- package/dist/core/sandbox/shared-lima-roots.d.ts.map +1 -0
- package/dist/core/sandbox/shared-lima-roots.js +25 -0
- package/dist/core/sandbox/shared-lima-roots.js.map +1 -0
- package/dist/core/sandbox/update-shared-guest-binary.d.ts +8 -0
- package/dist/core/sandbox/update-shared-guest-binary.d.ts.map +1 -0
- package/dist/core/sandbox/update-shared-guest-binary.js +100 -0
- package/dist/core/sandbox/update-shared-guest-binary.js.map +1 -0
- package/dist/core/session/constants.d.ts +2 -0
- package/dist/core/session/constants.d.ts.map +1 -0
- package/dist/core/session/constants.js +2 -0
- package/dist/core/session/constants.js.map +1 -0
- package/dist/core/session/context-metadata.d.ts +5 -0
- package/dist/core/session/context-metadata.d.ts.map +1 -0
- package/dist/core/session/context-metadata.js +55 -0
- package/dist/core/session/context-metadata.js.map +1 -0
- package/dist/core/session/context.d.ts +14 -0
- package/dist/core/session/context.d.ts.map +1 -0
- package/dist/core/session/context.js +117 -0
- package/dist/core/session/context.js.map +1 -0
- package/dist/core/session/ids.d.ts +9 -0
- package/dist/core/session/ids.d.ts.map +1 -0
- package/dist/core/session/ids.js +21 -0
- package/dist/core/session/ids.js.map +1 -0
- package/dist/core/session/in-memory-session-manager.d.ts +17 -0
- package/dist/core/session/in-memory-session-manager.d.ts.map +1 -0
- package/dist/core/session/in-memory-session-manager.js +40 -0
- package/dist/core/session/in-memory-session-manager.js.map +1 -0
- package/dist/core/session/in-memory-session.d.ts +7 -0
- package/dist/core/session/in-memory-session.d.ts.map +1 -0
- package/dist/core/session/in-memory-session.js +11 -0
- package/dist/core/session/in-memory-session.js.map +1 -0
- package/dist/core/session/jsonl-errors.d.ts +36 -0
- package/dist/core/session/jsonl-errors.d.ts.map +1 -0
- package/dist/core/session/jsonl-errors.js +49 -0
- package/dist/core/session/jsonl-errors.js.map +1 -0
- package/dist/core/session/jsonl-helpers.d.ts +20 -0
- package/dist/core/session/jsonl-helpers.d.ts.map +1 -0
- package/dist/core/session/jsonl-helpers.js +21 -0
- package/dist/core/session/jsonl-helpers.js.map +1 -0
- package/dist/core/session/local-session-manager.d.ts +30 -0
- package/dist/core/session/local-session-manager.d.ts.map +1 -0
- package/dist/core/session/local-session-manager.js +205 -0
- package/dist/core/session/local-session-manager.js.map +1 -0
- package/dist/core/session/local-session.d.ts +9 -0
- package/dist/core/session/local-session.d.ts.map +1 -0
- package/dist/core/session/local-session.js +15 -0
- package/dist/core/session/local-session.js.map +1 -0
- package/dist/core/session/migrations.d.ts +11 -0
- package/dist/core/session/migrations.d.ts.map +1 -0
- package/dist/core/session/migrations.js +78 -0
- package/dist/core/session/migrations.js.map +1 -0
- package/dist/core/session/remote-session-client.d.ts +83 -0
- package/dist/core/session/remote-session-client.d.ts.map +1 -0
- package/dist/core/session/remote-session-client.js +224 -0
- package/dist/core/session/remote-session-client.js.map +1 -0
- package/dist/core/session/remote-session-manager.d.ts +32 -0
- package/dist/core/session/remote-session-manager.d.ts.map +1 -0
- package/dist/core/session/remote-session-manager.js +124 -0
- package/dist/core/session/remote-session-manager.js.map +1 -0
- package/dist/core/session/remote-session.d.ts +20 -0
- package/dist/core/session/remote-session.d.ts.map +1 -0
- package/dist/core/session/remote-session.js +33 -0
- package/dist/core/session/remote-session.js.map +1 -0
- package/dist/core/session/session-manager.d.ts +18 -0
- package/dist/core/session/session-manager.d.ts.map +1 -0
- package/dist/core/session/session-manager.js +2 -0
- package/dist/core/session/session-manager.js.map +1 -0
- package/dist/core/session/session.d.ts +140 -0
- package/dist/core/session/session.d.ts.map +1 -0
- package/dist/core/session/session.js +461 -0
- package/dist/core/session/session.js.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts +39 -0
- package/dist/core/session/stores/in-memory-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/in-memory-session-store.js +168 -0
- package/dist/core/session/stores/in-memory-session-store.js.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts +97 -0
- package/dist/core/session/stores/jsonl-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/jsonl-session-store.js +1140 -0
- package/dist/core/session/stores/jsonl-session-store.js.map +1 -0
- package/dist/core/session/stores/remote-session-store.d.ts +44 -0
- package/dist/core/session/stores/remote-session-store.d.ts.map +1 -0
- package/dist/core/session/stores/remote-session-store.js +159 -0
- package/dist/core/session/stores/remote-session-store.js.map +1 -0
- package/dist/core/session/stores/session-store.d.ts +42 -0
- package/dist/core/session/stores/session-store.d.ts.map +1 -0
- package/dist/core/session/stores/session-store.js +2 -0
- package/dist/core/session/stores/session-store.js.map +1 -0
- package/dist/core/session/types.d.ts +141 -0
- package/dist/core/session/types.d.ts.map +1 -0
- package/dist/core/session/types.js +2 -0
- package/dist/core/session/types.js.map +1 -0
- package/dist/core/session/usage-ledger.d.ts +18 -0
- package/dist/core/session/usage-ledger.d.ts.map +1 -0
- package/dist/core/session/usage-ledger.js +68 -0
- package/dist/core/session/usage-ledger.js.map +1 -0
- package/dist/core/session-cwd.d.ts +19 -0
- package/dist/core/session-cwd.d.ts.map +1 -0
- package/dist/core/session-cwd.js +38 -0
- package/dist/core/session-cwd.js.map +1 -0
- package/dist/core/settings-manager.d.ts +314 -0
- package/dist/core/settings-manager.d.ts.map +1 -0
- package/dist/core/settings-manager.js +991 -0
- package/dist/core/settings-manager.js.map +1 -0
- package/dist/core/skills.d.ts +40 -0
- package/dist/core/skills.d.ts.map +1 -0
- package/dist/core/skills.js +57 -0
- package/dist/core/skills.js.map +1 -0
- package/dist/core/slash-commands.d.ts +15 -0
- package/dist/core/slash-commands.d.ts.map +1 -0
- package/dist/core/slash-commands.js +36 -0
- package/dist/core/slash-commands.js.map +1 -0
- package/dist/core/source-info.d.ts +26 -0
- package/dist/core/source-info.d.ts.map +1 -0
- package/dist/core/source-info.js +27 -0
- package/dist/core/source-info.js.map +1 -0
- package/dist/core/system-prompt.d.ts +32 -0
- package/dist/core/system-prompt.d.ts.map +1 -0
- package/dist/core/system-prompt.js +131 -0
- package/dist/core/system-prompt.js.map +1 -0
- package/dist/core/telemetry.d.ts +3 -0
- package/dist/core/telemetry.d.ts.map +1 -0
- package/dist/core/telemetry.js +9 -0
- package/dist/core/telemetry.js.map +1 -0
- package/dist/core/timings.d.ts +10 -0
- package/dist/core/timings.d.ts.map +1 -0
- package/dist/core/timings.js +41 -0
- package/dist/core/timings.js.map +1 -0
- package/dist/core/tools/bash.d.ts +51 -0
- package/dist/core/tools/bash.d.ts.map +1 -0
- package/dist/core/tools/bash.js +321 -0
- package/dist/core/tools/bash.js.map +1 -0
- package/dist/core/tools/compress-context.d.ts +27 -0
- package/dist/core/tools/compress-context.d.ts.map +1 -0
- package/dist/core/tools/compress-context.js +142 -0
- package/dist/core/tools/compress-context.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +82 -0
- package/dist/core/tools/edit-diff.d.ts.map +1 -0
- package/dist/core/tools/edit-diff.js +327 -0
- package/dist/core/tools/edit-diff.js.map +1 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.d.ts.map +1 -0
- package/dist/core/tools/edit.js +324 -0
- package/dist/core/tools/edit.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +8 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +69 -0
- package/dist/core/tools/file-mutation-queue.js.map +1 -0
- package/dist/core/tools/find.d.ts +22 -0
- package/dist/core/tools/find.d.ts.map +1 -0
- package/dist/core/tools/find.js +268 -0
- package/dist/core/tools/find.js.map +1 -0
- package/dist/core/tools/grep.d.ts +27 -0
- package/dist/core/tools/grep.d.ts.map +1 -0
- package/dist/core/tools/grep.js +332 -0
- package/dist/core/tools/grep.js.map +1 -0
- package/dist/core/tools/hash-store.d.ts +12 -0
- package/dist/core/tools/hash-store.d.ts.map +1 -0
- package/dist/core/tools/hash-store.js +48 -0
- package/dist/core/tools/hash-store.js.map +1 -0
- package/dist/core/tools/hashline/apply.d.ts +40 -0
- package/dist/core/tools/hashline/apply.d.ts.map +1 -0
- package/dist/core/tools/hashline/apply.js +261 -0
- package/dist/core/tools/hashline/apply.js.map +1 -0
- package/dist/core/tools/hashline/hash.d.ts +56 -0
- package/dist/core/tools/hashline/hash.d.ts.map +1 -0
- package/dist/core/tools/hashline/hash.js +196 -0
- package/dist/core/tools/hashline/hash.js.map +1 -0
- package/dist/core/tools/hashline/parse.d.ts +8 -0
- package/dist/core/tools/hashline/parse.d.ts.map +1 -0
- package/dist/core/tools/hashline/parse.js +41 -0
- package/dist/core/tools/hashline/parse.js.map +1 -0
- package/dist/core/tools/hashline/resolve.d.ts +51 -0
- package/dist/core/tools/hashline/resolve.d.ts.map +1 -0
- package/dist/core/tools/hashline/resolve.js +187 -0
- package/dist/core/tools/hashline/resolve.js.map +1 -0
- package/dist/core/tools/hashline-utils.d.ts +6 -0
- package/dist/core/tools/hashline-utils.d.ts.map +1 -0
- package/dist/core/tools/hashline-utils.js +23 -0
- package/dist/core/tools/hashline-utils.js.map +1 -0
- package/dist/core/tools/index.d.ts +36 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/index.js +141 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/ls.d.ts +21 -0
- package/dist/core/tools/ls.d.ts.map +1 -0
- package/dist/core/tools/ls.js +156 -0
- package/dist/core/tools/ls.js.map +1 -0
- package/dist/core/tools/operations.d.ts +212 -0
- package/dist/core/tools/operations.d.ts.map +1 -0
- package/dist/core/tools/operations.js +793 -0
- package/dist/core/tools/operations.js.map +1 -0
- package/dist/core/tools/output-accumulator.d.ts +54 -0
- package/dist/core/tools/output-accumulator.d.ts.map +1 -0
- package/dist/core/tools/output-accumulator.js +184 -0
- package/dist/core/tools/output-accumulator.js.map +1 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.d.ts.map +1 -0
- package/dist/core/tools/path-utils.js +99 -0
- package/dist/core/tools/path-utils.js.map +1 -0
- package/dist/core/tools/read.d.ts +32 -0
- package/dist/core/tools/read.d.ts.map +1 -0
- package/dist/core/tools/read.js +318 -0
- package/dist/core/tools/read.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts +33 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -0
- package/dist/core/tools/render-utils.js +61 -0
- package/dist/core/tools/render-utils.js.map +1 -0
- package/dist/core/tools/replace-diff.d.ts +16 -0
- package/dist/core/tools/replace-diff.d.ts.map +1 -0
- package/dist/core/tools/replace-diff.js +117 -0
- package/dist/core/tools/replace-diff.js.map +1 -0
- package/dist/core/tools/replace-normalize.d.ts +2 -0
- package/dist/core/tools/replace-normalize.d.ts.map +1 -0
- package/dist/core/tools/replace-normalize.js +73 -0
- package/dist/core/tools/replace-normalize.js.map +1 -0
- package/dist/core/tools/replace-render.d.ts +51 -0
- package/dist/core/tools/replace-render.d.ts.map +1 -0
- package/dist/core/tools/replace-render.js +162 -0
- package/dist/core/tools/replace-render.js.map +1 -0
- package/dist/core/tools/runtime.d.ts +2 -0
- package/dist/core/tools/runtime.d.ts.map +1 -0
- package/dist/core/tools/runtime.js +6 -0
- package/dist/core/tools/runtime.js.map +1 -0
- package/dist/core/tools/session-history.d.ts +55 -0
- package/dist/core/tools/session-history.d.ts.map +1 -0
- package/dist/core/tools/session-history.js +649 -0
- package/dist/core/tools/session-history.js.map +1 -0
- package/dist/core/tools/subagent-agents.d.ts +29 -0
- package/dist/core/tools/subagent-agents.d.ts.map +1 -0
- package/dist/core/tools/subagent-agents.js +223 -0
- package/dist/core/tools/subagent-agents.js.map +1 -0
- package/dist/core/tools/subagent.d.ts +185 -0
- package/dist/core/tools/subagent.d.ts.map +1 -0
- package/dist/core/tools/subagent.js +1309 -0
- package/dist/core/tools/subagent.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.js +34 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -0
- package/dist/core/tools/truncate.d.ts +39 -0
- package/dist/core/tools/truncate.d.ts.map +1 -0
- package/dist/core/tools/truncate.js +215 -0
- package/dist/core/tools/truncate.js.map +1 -0
- package/dist/core/tools/websearch.d.ts +33 -0
- package/dist/core/tools/websearch.d.ts.map +1 -0
- package/dist/core/tools/websearch.js +341 -0
- package/dist/core/tools/websearch.js.map +1 -0
- package/dist/core/tools/workspace-tool-host.d.ts +102 -0
- package/dist/core/tools/workspace-tool-host.d.ts.map +1 -0
- package/dist/core/tools/workspace-tool-host.js +348 -0
- package/dist/core/tools/workspace-tool-host.js.map +1 -0
- package/dist/core/tools/write.d.ts +16 -0
- package/dist/core/tools/write.d.ts.map +1 -0
- package/dist/core/tools/write.js +204 -0
- package/dist/core/tools/write.js.map +1 -0
- package/dist/core/workspace-identity.d.ts +7 -0
- package/dist/core/workspace-identity.d.ts.map +1 -0
- package/dist/core/workspace-identity.js +2 -0
- package/dist/core/workspace-identity.js.map +1 -0
- package/dist/daemon/activity-budget.d.ts +10 -0
- package/dist/daemon/activity-budget.d.ts.map +1 -0
- package/dist/daemon/activity-budget.js +34 -0
- package/dist/daemon/activity-budget.js.map +1 -0
- package/dist/daemon/command.d.ts +6 -0
- package/dist/daemon/command.d.ts.map +1 -0
- package/dist/daemon/command.js +58 -0
- package/dist/daemon/command.js.map +1 -0
- package/dist/daemon/config.d.ts +45 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +319 -0
- package/dist/daemon/config.js.map +1 -0
- package/dist/daemon/help.d.ts +2 -0
- package/dist/daemon/help.d.ts.map +1 -0
- package/dist/daemon/help.js +42 -0
- package/dist/daemon/help.js.map +1 -0
- package/dist/daemon/lsp-config.d.ts +4 -0
- package/dist/daemon/lsp-config.d.ts.map +1 -0
- package/dist/daemon/lsp-config.js +155 -0
- package/dist/daemon/lsp-config.js.map +1 -0
- package/dist/daemon/outbound-budget.d.ts +10 -0
- package/dist/daemon/outbound-budget.d.ts.map +1 -0
- package/dist/daemon/outbound-budget.js +30 -0
- package/dist/daemon/outbound-budget.js.map +1 -0
- package/dist/daemon/security.d.ts +19 -0
- package/dist/daemon/security.d.ts.map +1 -0
- package/dist/daemon/security.js +177 -0
- package/dist/daemon/security.js.map +1 -0
- package/dist/daemon/server.d.ts +20 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +480 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/shared-connection.d.ts +33 -0
- package/dist/daemon/shared-connection.d.ts.map +1 -0
- package/dist/daemon/shared-connection.js +271 -0
- package/dist/daemon/shared-connection.js.map +1 -0
- package/dist/daemon/shared-revision.d.ts +5 -0
- package/dist/daemon/shared-revision.d.ts.map +1 -0
- package/dist/daemon/shared-revision.js +61 -0
- package/dist/daemon/shared-revision.js.map +1 -0
- package/dist/daemon/shared-roots.d.ts +9 -0
- package/dist/daemon/shared-roots.d.ts.map +1 -0
- package/dist/daemon/shared-roots.js +33 -0
- package/dist/daemon/shared-roots.js.map +1 -0
- package/dist/daemon/workspace-runtime.d.ts +46 -0
- package/dist/daemon/workspace-runtime.d.ts.map +1 -0
- package/dist/daemon/workspace-runtime.js +705 -0
- package/dist/daemon/workspace-runtime.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +39 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +765 -0
- package/dist/main.js.map +1 -0
- package/dist/migrations.d.ts +35 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +412 -0
- package/dist/migrations.js.map +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +30 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +159 -0
- package/dist/modes/interactive/components/assistant-message.js.map +1 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +36 -0
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/bash-execution.js +173 -0
- package/dist/modes/interactive/components/bash-execution.js.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +18 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -0
- package/dist/modes/interactive/components/bordered-loader.js +54 -0
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +45 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +46 -0
- package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/config-selector.d.ts +74 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +514 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts.map +1 -0
- package/dist/modes/interactive/components/countdown-timer.js +33 -0
- package/dist/modes/interactive/components/countdown-timer.js.map +1 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +25 -0
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-editor.js +85 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -0
- package/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/custom-message.js +81 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -0
- package/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/modes/interactive/components/diff.d.ts.map +1 -0
- package/dist/modes/interactive/components/diff.js +118 -0
- package/dist/modes/interactive/components/diff.js.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -0
- package/dist/modes/interactive/components/dynamic-border.js +21 -0
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-editor.js +128 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -0
- package/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-input.js +61 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/extension-selector.js +83 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts +36 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -0
- package/dist/modes/interactive/components/footer.js +227 -0
- package/dist/modes/interactive/components/footer.js.map +1 -0
- package/dist/modes/interactive/components/hook-execution.d.ts +19 -0
- package/dist/modes/interactive/components/hook-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/hook-execution.js +185 -0
- package/dist/modes/interactive/components/hook-execution.js.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -0
- package/dist/modes/interactive/components/keybinding-hints.js +36 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +55 -0
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -0
- package/dist/modes/interactive/components/login-dialog.js +176 -0
- package/dist/modes/interactive/components/login-dialog.js.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts +4 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +14 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +228 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/message-card.d.ts +9 -0
- package/dist/modes/interactive/components/message-card.d.ts.map +1 -0
- package/dist/modes/interactive/components/message-card.js +24 -0
- package/dist/modes/interactive/components/message-card.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +52 -0
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/model-selector.js +296 -0
- package/dist/modes/interactive/components/model-selector.js.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/oauth-selector.js +165 -0
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +50 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +300 -0
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector-search.js +144 -0
- package/dist/modes/interactive/components/session-selector-search.js.map +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts +108 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/session-selector.js +835 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +81 -0
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-selector.js +455 -0
- package/dist/modes/interactive/components/settings-selector.js.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/show-images-selector.js +39 -0
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +18 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +48 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/modes/interactive/components/theme-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js +50 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +67 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-execution.js +312 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +127 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/tree-selector.js +1098 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message-selector.js +114 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -0
- package/dist/modes/interactive/components/user-message.d.ts +16 -0
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/user-message.js +50 -0
- package/dist/modes/interactive/components/user-message.js.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -0
- package/dist/modes/interactive/components/visual-truncate.js +33 -0
- package/dist/modes/interactive/components/visual-truncate.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +554 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +5870 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -0
- package/dist/modes/interactive/theme/dark.json +86 -0
- package/dist/modes/interactive/theme/light.json +85 -0
- package/dist/modes/interactive/theme/theme-schema.json +335 -0
- package/dist/modes/interactive/theme/theme.d.ts +109 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1040 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -0
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts +29 -0
- package/dist/modes/print-mode.d.ts.map +1 -0
- package/dist/modes/print-mode.js +142 -0
- package/dist/modes/print-mode.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/modes/rpc/jsonl.d.ts.map +1 -0
- package/dist/modes/rpc/jsonl.js +49 -0
- package/dist/modes/rpc/jsonl.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +321 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client.js +755 -0
- package/dist/modes/rpc/rpc-client.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-mode.js +963 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -0
- package/dist/modes/rpc/rpc-types.d.ts +652 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-types.js +8 -0
- package/dist/modes/rpc/rpc-types.js.map +1 -0
- package/dist/package-manager-cli.d.ts +4 -0
- package/dist/package-manager-cli.d.ts.map +1 -0
- package/dist/package-manager-cli.js +488 -0
- package/dist/package-manager-cli.js.map +1 -0
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +25 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/changelog.d.ts +23 -0
- package/dist/utils/changelog.d.ts.map +1 -0
- package/dist/utils/changelog.js +74 -0
- package/dist/utils/changelog.js.map +1 -0
- package/dist/utils/child-process.d.ts +15 -0
- package/dist/utils/child-process.d.ts.map +1 -0
- package/dist/utils/child-process.js +88 -0
- package/dist/utils/child-process.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +13 -0
- package/dist/utils/clipboard-image.d.ts.map +1 -0
- package/dist/utils/clipboard-image.js +248 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/utils/clipboard-native.d.ts.map +1 -0
- package/dist/utils/clipboard-native.js +20 -0
- package/dist/utils/clipboard-native.js.map +1 -0
- package/dist/utils/clipboard.d.ts +4 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/clipboard.js +171 -0
- package/dist/utils/clipboard.js.map +1 -0
- package/dist/utils/deprecation.d.ts +4 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/deprecation.js +13 -0
- package/dist/utils/deprecation.js.map +1 -0
- package/dist/utils/directory-completions.d.ts +5 -0
- package/dist/utils/directory-completions.d.ts.map +1 -0
- package/dist/utils/directory-completions.js +64 -0
- package/dist/utils/directory-completions.js.map +1 -0
- package/dist/utils/exif-orientation.d.ts +6 -0
- package/dist/utils/exif-orientation.d.ts.map +1 -0
- package/dist/utils/exif-orientation.js +166 -0
- package/dist/utils/exif-orientation.js.map +1 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.d.ts.map +1 -0
- package/dist/utils/frontmatter.js +26 -0
- package/dist/utils/frontmatter.js.map +1 -0
- package/dist/utils/fs-watch.d.ts +5 -0
- package/dist/utils/fs-watch.d.ts.map +1 -0
- package/dist/utils/fs-watch.js +25 -0
- package/dist/utils/fs-watch.js.map +1 -0
- package/dist/utils/git.d.ts +27 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +237 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/grip-user-agent.d.ts +2 -0
- package/dist/utils/grip-user-agent.d.ts.map +1 -0
- package/dist/utils/grip-user-agent.js +5 -0
- package/dist/utils/grip-user-agent.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/image-convert.d.ts +12 -0
- package/dist/utils/image-convert.d.ts.map +1 -0
- package/dist/utils/image-convert.js +43 -0
- package/dist/utils/image-convert.js.map +1 -0
- package/dist/utils/image-process.d.ts +18 -0
- package/dist/utils/image-process.d.ts.map +1 -0
- package/dist/utils/image-process.js +83 -0
- package/dist/utils/image-process.js.map +1 -0
- package/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/utils/image-resize-core.d.ts.map +1 -0
- package/dist/utils/image-resize-core.js +133 -0
- package/dist/utils/image-resize-core.js.map +1 -0
- package/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/utils/image-resize-worker.d.ts.map +1 -0
- package/dist/utils/image-resize-worker.js +31 -0
- package/dist/utils/image-resize-worker.js.map +1 -0
- package/dist/utils/image-resize.d.ts +19 -0
- package/dist/utils/image-resize.d.ts.map +1 -0
- package/dist/utils/image-resize.js +86 -0
- package/dist/utils/image-resize.js.map +1 -0
- package/dist/utils/json.d.ts +3 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +7 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/mime.d.ts +3 -0
- package/dist/utils/mime.d.ts.map +1 -0
- package/dist/utils/mime.js +110 -0
- package/dist/utils/mime.js.map +1 -0
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/paths.d.ts +31 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +87 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/photon.d.ts +22 -0
- package/dist/utils/photon.d.ts.map +1 -0
- package/dist/utils/photon.js +126 -0
- package/dist/utils/photon.js.map +1 -0
- package/dist/utils/shell.d.ts +28 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +188 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +125 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts +5 -0
- package/dist/utils/tools-manager.d.ts.map +1 -0
- package/dist/utils/tools-manager.js +329 -0
- package/dist/utils/tools-manager.js.map +1 -0
- package/dist/utils/version-check.d.ts +14 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/dist/utils/version-check.js +91 -0
- package/dist/utils/version-check.js.map +1 -0
- package/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/utils/windows-self-update.d.ts.map +1 -0
- package/dist/utils/windows-self-update.js +77 -0
- package/dist/utils/windows-self-update.js.map +1 -0
- package/docs/compaction.md +408 -0
- package/docs/custom-provider.md +714 -0
- package/docs/daemon-architecture.md +399 -0
- package/docs/daemon.md +112 -0
- package/docs/development.md +72 -0
- package/docs/docs.json +164 -0
- package/docs/extensions.md +2745 -0
- package/docs/hooks.md +85 -0
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/exy.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/index.md +77 -0
- package/docs/json.md +89 -0
- package/docs/keybindings.md +230 -0
- package/docs/lsp.md +499 -0
- package/docs/migrating-to-grip.md +18 -0
- package/docs/models.md +496 -0
- package/docs/packages.md +228 -0
- package/docs/prompt-templates.md +88 -0
- package/docs/providers.md +251 -0
- package/docs/quickstart.md +159 -0
- package/docs/rpc.md +1492 -0
- package/docs/rules.md +117 -0
- package/docs/sandbox.md +104 -0
- package/docs/sdk.md +360 -0
- package/docs/session-format.md +414 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +372 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +246 -0
- package/docs/terminal-setup.md +112 -0
- package/docs/termux.md +112 -0
- package/docs/themes.md +295 -0
- package/docs/tmux.md +61 -0
- package/docs/tui.md +918 -0
- package/docs/usage.md +304 -0
- package/docs/windows.md +17 -0
- package/examples/README.md +29 -0
- package/examples/daemon-docker/Dockerfile +43 -0
- package/examples/daemon-docker/README.md +45 -0
- package/examples/extensions/README.md +208 -0
- package/examples/extensions/auto-commit-on-exit.ts +46 -0
- package/examples/extensions/bash-spawn-hook.ts +30 -0
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/border-status-editor.ts +145 -0
- package/examples/extensions/built-in-tool-renderer.ts +259 -0
- package/examples/extensions/claude-rules.ts +86 -0
- package/examples/extensions/commands.ts +82 -0
- package/examples/extensions/confirm-destructive.ts +59 -0
- package/examples/extensions/custom-compaction.ts +131 -0
- package/examples/extensions/custom-footer.ts +79 -0
- package/examples/extensions/custom-header.ts +73 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +707 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +402 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +104 -0
- package/examples/extensions/dirty-repo-guard.ts +59 -0
- package/examples/extensions/doom-overlay/README.md +46 -0
- package/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/examples/extensions/doom-overlay/doom-component.ts +133 -0
- package/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/examples/extensions/doom-overlay/index.ts +74 -0
- package/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/examples/extensions/dynamic-resources/RULES.md +8 -0
- package/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/examples/extensions/dynamic-resources/index.ts +16 -0
- package/examples/extensions/dynamic-tools.ts +74 -0
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/file-trigger.ts +41 -0
- package/examples/extensions/git-checkpoint.ts +53 -0
- package/examples/extensions/git-merge-and-resolve.ts +125 -0
- package/examples/extensions/github-issue-autocomplete.ts +191 -0
- package/examples/extensions/handoff.ts +191 -0
- package/examples/extensions/hello.ts +26 -0
- package/examples/extensions/hidden-thinking-label.ts +53 -0
- package/examples/extensions/inline-bash.ts +104 -0
- package/examples/extensions/input-transform.ts +43 -0
- package/examples/extensions/interactive-shell.ts +194 -0
- package/examples/extensions/mac-system-theme.ts +47 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/minimal-mode.ts +428 -0
- package/examples/extensions/modal-editor.ts +86 -0
- package/examples/extensions/model-status.ts +31 -0
- package/examples/extensions/notify.ts +55 -0
- package/examples/extensions/overlay-qa-tests.ts +1374 -0
- package/examples/extensions/overlay-test.ts +171 -0
- package/examples/extensions/permission-gate.ts +34 -0
- package/examples/extensions/pirate.ts +47 -0
- package/examples/extensions/plan-mode/README.md +65 -0
- package/examples/extensions/plan-mode/index.ts +346 -0
- package/examples/extensions/plan-mode/utils.ts +172 -0
- package/examples/extensions/preset.ts +426 -0
- package/examples/extensions/prompt-customizer.ts +97 -0
- package/examples/extensions/protected-paths.ts +29 -0
- package/examples/extensions/provider-payload.ts +18 -0
- package/examples/extensions/qna.ts +125 -0
- package/examples/extensions/question.ts +294 -0
- package/examples/extensions/questionnaire.ts +459 -0
- package/examples/extensions/rainbow-editor.ts +88 -0
- package/examples/extensions/reload-runtime.ts +37 -0
- package/examples/extensions/rpc-demo.ts +118 -0
- package/examples/extensions/sandbox/index.ts +320 -0
- package/examples/extensions/sandbox/package-lock.json +92 -0
- package/examples/extensions/sandbox/package.json +19 -0
- package/examples/extensions/send-user-message.ts +97 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/shutdown-command.ts +63 -0
- package/examples/extensions/snake.ts +381 -0
- package/examples/extensions/space-invaders.ts +597 -0
- package/examples/extensions/status-line.ts +32 -0
- package/examples/extensions/structured-output.ts +65 -0
- package/examples/extensions/subagent/README.md +175 -0
- package/examples/extensions/subagent/agents/planner.md +37 -0
- package/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/examples/extensions/subagent/agents/scout.md +50 -0
- package/examples/extensions/subagent/agents/worker.md +24 -0
- package/examples/extensions/subagent/agents.ts +126 -0
- package/examples/extensions/subagent/index.ts +1083 -0
- package/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/examples/extensions/subagent/prompts/implement.md +10 -0
- package/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/examples/extensions/summarize.ts +186 -0
- package/examples/extensions/system-prompt-header.ts +17 -0
- package/examples/extensions/tic-tac-toe.ts +1091 -0
- package/examples/extensions/timed-confirm.ts +70 -0
- package/examples/extensions/titlebar-spinner.ts +58 -0
- package/examples/extensions/todo.ts +306 -0
- package/examples/extensions/tool-override.ts +144 -0
- package/examples/extensions/tools.ts +141 -0
- package/examples/extensions/trigger-compact.ts +50 -0
- package/examples/extensions/truncated-tool.ts +200 -0
- package/examples/extensions/widget-placement.ts +9 -0
- package/examples/extensions/with-deps/index.ts +32 -0
- package/examples/extensions/with-deps/package-lock.json +31 -0
- package/examples/extensions/with-deps/package.json +22 -0
- package/examples/extensions/working-indicator.ts +123 -0
- package/examples/extensions/working-message-test.ts +25 -0
- package/examples/remote-session-server/README.md +71 -0
- package/examples/remote-session-server/server.ts +353 -0
- package/examples/rpc-extension-ui.ts +642 -0
- package/examples/sdk/01-minimal.ts +27 -0
- package/examples/sdk/02-custom-model.ts +54 -0
- package/examples/sdk/03-custom-prompt.ts +76 -0
- package/examples/sdk/04-skills.ts +60 -0
- package/examples/sdk/05-tools.ts +55 -0
- package/examples/sdk/06-extensions.ts +94 -0
- package/examples/sdk/07-context-files.ts +47 -0
- package/examples/sdk/08-prompt-templates.ts +56 -0
- package/examples/sdk/09-api-keys-and-oauth.ts +50 -0
- package/examples/sdk/10-settings.ts +58 -0
- package/examples/sdk/11-sessions.ts +54 -0
- package/examples/sdk/12-full-control.ts +79 -0
- package/examples/sdk/13-session-runtime.ts +49 -0
- package/examples/sdk/README.md +94 -0
- package/npm-shrinkwrap.json +1878 -0
- package/package.json +101 -5
|
@@ -0,0 +1,1083 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subagent Tool - Delegate tasks to specialized agents
|
|
3
|
+
*
|
|
4
|
+
* Spawns a separate `grip` process for each subagent invocation,
|
|
5
|
+
* giving it an isolated context window.
|
|
6
|
+
*
|
|
7
|
+
* Supports three modes:
|
|
8
|
+
* - Single: { agent: "name", task: "..." }
|
|
9
|
+
* - Parallel: { tasks: [{ agent: "name", task: "..." }, ...] }
|
|
10
|
+
* - Chain: { chain: [{ agent: "name", task: "... {previous} ..." }, ...] }
|
|
11
|
+
*
|
|
12
|
+
* Uses JSON mode to capture structured output from subagents.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { spawn } from "node:child_process";
|
|
16
|
+
import * as fs from "node:fs";
|
|
17
|
+
import * as os from "node:os";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
import {
|
|
20
|
+
type ExtensionAPI,
|
|
21
|
+
type ExtensionContext,
|
|
22
|
+
getMarkdownTheme,
|
|
23
|
+
type SubagentUsageStats,
|
|
24
|
+
type Theme,
|
|
25
|
+
type ThemeColor,
|
|
26
|
+
withFileMutationQueue,
|
|
27
|
+
} from "@greppleai/grip";
|
|
28
|
+
import type { AgentToolResult } from "@greppleai/grip-agent-core";
|
|
29
|
+
import type { AssistantMessage, Message } from "@greppleai/grip-ai";
|
|
30
|
+
import { StringEnum } from "@greppleai/grip-ai";
|
|
31
|
+
import { Container, Markdown, Spacer, Text } from "@greppleai/grip-tui";
|
|
32
|
+
import { type Static, Type } from "typebox";
|
|
33
|
+
import { type AgentConfig, type AgentConfigSource, type AgentScope, discoverAgents } from "./agents.ts";
|
|
34
|
+
|
|
35
|
+
const MAX_PARALLEL_TASKS = 8;
|
|
36
|
+
const MAX_CONCURRENCY = 4;
|
|
37
|
+
const COLLAPSED_ITEM_COUNT = 10;
|
|
38
|
+
const PER_TASK_OUTPUT_CAP = 50 * 1024;
|
|
39
|
+
type UsageDisplayStats = Omit<SubagentUsageStats, "contextTokens" | "turns"> &
|
|
40
|
+
Partial<Pick<SubagentUsageStats, "contextTokens" | "turns">>;
|
|
41
|
+
|
|
42
|
+
function formatTokens(count: number): string {
|
|
43
|
+
if (count < 1000) return count.toString();
|
|
44
|
+
if (count < 10000) return `${(count / 1000).toFixed(1)}k`;
|
|
45
|
+
if (count < 1000000) return `${Math.round(count / 1000)}k`;
|
|
46
|
+
return `${(count / 1000000).toFixed(1)}M`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function formatUsageStats(usage: UsageDisplayStats, model?: string): string {
|
|
50
|
+
const parts: string[] = [];
|
|
51
|
+
if (usage.turns) parts.push(`${usage.turns} turn${usage.turns > 1 ? "s" : ""}`);
|
|
52
|
+
if (usage.input) parts.push(`↑${formatTokens(usage.input)}`);
|
|
53
|
+
if (usage.output) parts.push(`↓${formatTokens(usage.output)}`);
|
|
54
|
+
if (usage.cacheRead) parts.push(`R${formatTokens(usage.cacheRead)}`);
|
|
55
|
+
if (usage.cacheWrite) parts.push(`W${formatTokens(usage.cacheWrite)}`);
|
|
56
|
+
if (usage.cost) parts.push(`$${usage.cost.toFixed(4)}`);
|
|
57
|
+
if (usage.contextTokens && usage.contextTokens > 0) {
|
|
58
|
+
parts.push(`ctx:${formatTokens(usage.contextTokens)}`);
|
|
59
|
+
}
|
|
60
|
+
if (model) parts.push(model);
|
|
61
|
+
return parts.join(" ");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type SubagentToolThemeForeground = (color: ThemeColor, text: string) => string;
|
|
65
|
+
|
|
66
|
+
function shortenSubagentToolPath(filePath: string): string {
|
|
67
|
+
const home = os.homedir();
|
|
68
|
+
return filePath.startsWith(home) ? `~${filePath.slice(home.length)}` : filePath;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function formatSubagentBashCall(args: Record<string, unknown>, themeFg: SubagentToolThemeForeground): string {
|
|
72
|
+
const command = (args.command as string) || "...";
|
|
73
|
+
const preview = command.length > 60 ? `${command.slice(0, 60)}...` : command;
|
|
74
|
+
return themeFg("muted", "$ ") + themeFg("toolOutput", preview);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function formatSubagentReadCall(args: Record<string, unknown>, themeFg: SubagentToolThemeForeground): string {
|
|
78
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
79
|
+
const offset = args.offset as number | undefined;
|
|
80
|
+
const limit = args.limit as number | undefined;
|
|
81
|
+
let text = themeFg("accent", shortenSubagentToolPath(rawPath));
|
|
82
|
+
if (offset !== undefined || limit !== undefined) {
|
|
83
|
+
const startLine = offset ?? 1;
|
|
84
|
+
const endLine = limit !== undefined ? startLine + limit - 1 : "";
|
|
85
|
+
text += themeFg("warning", `:${startLine}${endLine ? `-${endLine}` : ""}`);
|
|
86
|
+
}
|
|
87
|
+
return themeFg("muted", "read ") + text;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function formatSubagentWriteCall(args: Record<string, unknown>, themeFg: SubagentToolThemeForeground): string {
|
|
91
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
92
|
+
const content = (args.content || "") as string;
|
|
93
|
+
const lines = content.split("\n").length;
|
|
94
|
+
let text = themeFg("muted", "write ") + themeFg("accent", shortenSubagentToolPath(rawPath));
|
|
95
|
+
if (lines > 1) text += themeFg("dim", ` (${lines} lines)`);
|
|
96
|
+
return text;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function formatUnknownSubagentToolCall(
|
|
100
|
+
toolName: string,
|
|
101
|
+
args: Record<string, unknown>,
|
|
102
|
+
themeFg: SubagentToolThemeForeground,
|
|
103
|
+
): string {
|
|
104
|
+
const argsString = JSON.stringify(args);
|
|
105
|
+
const preview = argsString.length > 50 ? `${argsString.slice(0, 50)}...` : argsString;
|
|
106
|
+
return themeFg("accent", toolName) + themeFg("dim", ` ${preview}`);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function formatToolCall(toolName: string, args: Record<string, unknown>, themeFg: SubagentToolThemeForeground): string {
|
|
110
|
+
switch (toolName) {
|
|
111
|
+
case "bash":
|
|
112
|
+
return formatSubagentBashCall(args, themeFg);
|
|
113
|
+
case "read":
|
|
114
|
+
return formatSubagentReadCall(args, themeFg);
|
|
115
|
+
case "write":
|
|
116
|
+
return formatSubagentWriteCall(args, themeFg);
|
|
117
|
+
case "edit": {
|
|
118
|
+
const rawPath = (args.file_path || args.path || "...") as string;
|
|
119
|
+
return themeFg("muted", "edit ") + themeFg("accent", shortenSubagentToolPath(rawPath));
|
|
120
|
+
}
|
|
121
|
+
case "ls": {
|
|
122
|
+
const rawPath = (args.path || ".") as string;
|
|
123
|
+
return themeFg("muted", "ls ") + themeFg("accent", shortenSubagentToolPath(rawPath));
|
|
124
|
+
}
|
|
125
|
+
case "find": {
|
|
126
|
+
const pattern = (args.pattern || "*") as string;
|
|
127
|
+
const rawPath = (args.path || ".") as string;
|
|
128
|
+
return (
|
|
129
|
+
themeFg("muted", "find ") +
|
|
130
|
+
themeFg("accent", pattern) +
|
|
131
|
+
themeFg("dim", ` in ${shortenSubagentToolPath(rawPath)}`)
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
case "grep": {
|
|
135
|
+
const pattern = (args.pattern || "") as string;
|
|
136
|
+
const rawPath = (args.path || ".") as string;
|
|
137
|
+
return (
|
|
138
|
+
themeFg("muted", "grep ") +
|
|
139
|
+
themeFg("accent", `/${pattern}/`) +
|
|
140
|
+
themeFg("dim", ` in ${shortenSubagentToolPath(rawPath)}`)
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
return formatUnknownSubagentToolCall(toolName, args, themeFg);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
type SubagentResultAgentSource = AgentConfigSource | "unknown";
|
|
149
|
+
|
|
150
|
+
interface SingleResult {
|
|
151
|
+
agent: string;
|
|
152
|
+
agentSource: SubagentResultAgentSource;
|
|
153
|
+
task: string;
|
|
154
|
+
exitCode: number;
|
|
155
|
+
messages: Message[];
|
|
156
|
+
stderr: string;
|
|
157
|
+
usage: SubagentUsageStats;
|
|
158
|
+
model?: string;
|
|
159
|
+
stopReason?: string;
|
|
160
|
+
errorMessage?: string;
|
|
161
|
+
step?: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
interface SubagentProcessEvent {
|
|
165
|
+
type?: unknown;
|
|
166
|
+
message?: unknown;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type SubagentMode = "single" | "parallel" | "chain";
|
|
170
|
+
|
|
171
|
+
interface SubagentDetails {
|
|
172
|
+
mode: SubagentMode;
|
|
173
|
+
agentScope: AgentScope;
|
|
174
|
+
projectAgentsDir: string | null;
|
|
175
|
+
results: SingleResult[];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface SubagentToolResult extends AgentToolResult<SubagentDetails> {
|
|
179
|
+
isError?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function getFinalOutput(messages: Message[]): string {
|
|
183
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
184
|
+
const msg = messages[i];
|
|
185
|
+
if (msg.role === "assistant") {
|
|
186
|
+
for (const part of msg.content) {
|
|
187
|
+
if (part.type === "text") return part.text;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return "";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function isFailedResult(result: SingleResult): boolean {
|
|
195
|
+
return result.exitCode !== 0 || result.stopReason === "error" || result.stopReason === "aborted";
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function getResultOutput(result: SingleResult): string {
|
|
199
|
+
if (isFailedResult(result)) {
|
|
200
|
+
return result.errorMessage || result.stderr || getFinalOutput(result.messages) || "(no output)";
|
|
201
|
+
}
|
|
202
|
+
return getFinalOutput(result.messages) || "(no output)";
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function truncateParallelOutput(output: string): string {
|
|
206
|
+
const byteLength = Buffer.byteLength(output, "utf8");
|
|
207
|
+
if (byteLength <= PER_TASK_OUTPUT_CAP) return output;
|
|
208
|
+
|
|
209
|
+
let truncated = output.slice(0, PER_TASK_OUTPUT_CAP);
|
|
210
|
+
while (Buffer.byteLength(truncated, "utf8") > PER_TASK_OUTPUT_CAP) {
|
|
211
|
+
truncated = truncated.slice(0, -1);
|
|
212
|
+
}
|
|
213
|
+
return `${truncated}\n\n[Output truncated: ${byteLength - Buffer.byteLength(truncated, "utf8")} bytes omitted. Full output preserved in tool details.]`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
type DisplayItem = { type: "text"; text: string } | { type: "toolCall"; name: string; args: Record<string, any> };
|
|
217
|
+
|
|
218
|
+
function getDisplayItems(messages: Message[]): DisplayItem[] {
|
|
219
|
+
const items: DisplayItem[] = [];
|
|
220
|
+
for (const msg of messages) {
|
|
221
|
+
if (msg.role === "assistant") {
|
|
222
|
+
for (const part of msg.content) {
|
|
223
|
+
if (part.type === "text") items.push({ type: "text", text: part.text });
|
|
224
|
+
else if (part.type === "toolCall") items.push({ type: "toolCall", name: part.name, args: part.arguments });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return items;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
async function mapWithConcurrencyLimit<TIn, TOut>(
|
|
232
|
+
items: TIn[],
|
|
233
|
+
concurrency: number,
|
|
234
|
+
fn: (item: TIn, index: number) => Promise<TOut>,
|
|
235
|
+
): Promise<TOut[]> {
|
|
236
|
+
if (items.length === 0) return [];
|
|
237
|
+
const limit = Math.max(1, Math.min(concurrency, items.length));
|
|
238
|
+
const results: TOut[] = new Array(items.length);
|
|
239
|
+
let nextIndex = 0;
|
|
240
|
+
const workers = new Array(limit).fill(null).map(async () => {
|
|
241
|
+
while (true) {
|
|
242
|
+
const current = nextIndex++;
|
|
243
|
+
if (current >= items.length) return;
|
|
244
|
+
results[current] = await fn(items[current], current);
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
await Promise.all(workers);
|
|
248
|
+
return results;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
type TemporaryPromptFile = { dir: string; filePath: string };
|
|
252
|
+
|
|
253
|
+
async function writePromptToTempFile(agentName: string, prompt: string): Promise<TemporaryPromptFile> {
|
|
254
|
+
const tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "grip-subagent-"));
|
|
255
|
+
const safeName = agentName.replace(/[^\w.-]+/g, "_");
|
|
256
|
+
const filePath = path.join(tmpDir, `prompt-${safeName}.md`);
|
|
257
|
+
await withFileMutationQueue(filePath, async () => {
|
|
258
|
+
await fs.promises.writeFile(filePath, prompt, { encoding: "utf-8", mode: 0o600 });
|
|
259
|
+
});
|
|
260
|
+
return { dir: tmpDir, filePath };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type GripInvocation = { command: string; args: string[] };
|
|
264
|
+
|
|
265
|
+
function getGripInvocation(args: string[]): GripInvocation {
|
|
266
|
+
const currentScript = process.argv[1];
|
|
267
|
+
const isBunVirtualScript = currentScript?.startsWith("/$bunfs/root/");
|
|
268
|
+
if (currentScript && !isBunVirtualScript && fs.existsSync(currentScript)) {
|
|
269
|
+
return { command: process.execPath, args: [currentScript, ...args] };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const execName = path.basename(process.execPath).toLowerCase();
|
|
273
|
+
const isGenericRuntime = /^(node|bun)(\.exe)?$/.test(execName);
|
|
274
|
+
if (!isGenericRuntime) {
|
|
275
|
+
return { command: process.execPath, args };
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return { command: "grip", args };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function parseSubagentProcessEvent(line: string): SubagentProcessEvent | undefined {
|
|
282
|
+
if (!line.trim()) return undefined;
|
|
283
|
+
try {
|
|
284
|
+
const event = JSON.parse(line) as unknown;
|
|
285
|
+
return event !== null && typeof event === "object" ? (event as SubagentProcessEvent) : undefined;
|
|
286
|
+
} catch {
|
|
287
|
+
return undefined;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function accumulateSubagentAssistantMessage(result: SingleResult, message: AssistantMessage): void {
|
|
292
|
+
result.usage.turns++;
|
|
293
|
+
const usage = message.usage;
|
|
294
|
+
if (usage) {
|
|
295
|
+
result.usage.input += usage.input || 0;
|
|
296
|
+
result.usage.output += usage.output || 0;
|
|
297
|
+
result.usage.cacheRead += usage.cacheRead || 0;
|
|
298
|
+
result.usage.cacheWrite += usage.cacheWrite || 0;
|
|
299
|
+
result.usage.cost += usage.cost?.total || 0;
|
|
300
|
+
result.usage.contextTokens = usage.totalTokens || 0;
|
|
301
|
+
}
|
|
302
|
+
if (!result.model && message.model) result.model = message.model;
|
|
303
|
+
if (message.stopReason) result.stopReason = message.stopReason;
|
|
304
|
+
if (message.errorMessage) result.errorMessage = message.errorMessage;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function recordSubagentProcessEvent(event: SubagentProcessEvent, result: SingleResult, emitUpdate: () => void): void {
|
|
308
|
+
if (event.type === "message_end" && event.message) {
|
|
309
|
+
const message = event.message as Message;
|
|
310
|
+
result.messages.push(message);
|
|
311
|
+
if (message.role === "assistant") accumulateSubagentAssistantMessage(result, message);
|
|
312
|
+
emitUpdate();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
if (event.type === "tool_result_end" && event.message) {
|
|
316
|
+
result.messages.push(event.message as Message);
|
|
317
|
+
emitUpdate();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
type OnUpdateCallback = (partial: AgentToolResult<SubagentDetails>) => void;
|
|
322
|
+
|
|
323
|
+
async function runSingleAgent(
|
|
324
|
+
defaultCwd: string,
|
|
325
|
+
agents: AgentConfig[],
|
|
326
|
+
agentName: string,
|
|
327
|
+
task: string,
|
|
328
|
+
cwd: string | undefined,
|
|
329
|
+
step: number | undefined,
|
|
330
|
+
signal: AbortSignal | undefined,
|
|
331
|
+
onUpdate: OnUpdateCallback | undefined,
|
|
332
|
+
makeDetails: (results: SingleResult[]) => SubagentDetails,
|
|
333
|
+
): Promise<SingleResult> {
|
|
334
|
+
const agent = agents.find((a) => a.name === agentName);
|
|
335
|
+
|
|
336
|
+
if (!agent) {
|
|
337
|
+
const available = agents.map((a) => `"${a.name}"`).join(", ") || "none";
|
|
338
|
+
return {
|
|
339
|
+
agent: agentName,
|
|
340
|
+
agentSource: "unknown",
|
|
341
|
+
task,
|
|
342
|
+
exitCode: 1,
|
|
343
|
+
messages: [],
|
|
344
|
+
stderr: `Unknown agent: "${agentName}". Available agents: ${available}.`,
|
|
345
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
346
|
+
step,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
const args: string[] = ["--mode", "json", "-p", "--no-session"];
|
|
351
|
+
if (agent.model) args.push("--model", agent.model);
|
|
352
|
+
if (agent.tools && agent.tools.length > 0) args.push("--tools", agent.tools.join(","));
|
|
353
|
+
|
|
354
|
+
let tmpPromptDir: string | null = null;
|
|
355
|
+
let tmpPromptPath: string | null = null;
|
|
356
|
+
|
|
357
|
+
const currentResult: SingleResult = {
|
|
358
|
+
agent: agentName,
|
|
359
|
+
agentSource: agent.source,
|
|
360
|
+
task,
|
|
361
|
+
exitCode: 0,
|
|
362
|
+
messages: [],
|
|
363
|
+
stderr: "",
|
|
364
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
365
|
+
model: agent.model,
|
|
366
|
+
step,
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const emitUpdate = () => {
|
|
370
|
+
if (onUpdate) {
|
|
371
|
+
onUpdate({
|
|
372
|
+
content: [{ type: "text", text: getFinalOutput(currentResult.messages) || "(running...)" }],
|
|
373
|
+
details: makeDetails([currentResult]),
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
try {
|
|
379
|
+
if (agent.systemPrompt.trim()) {
|
|
380
|
+
const tmp = await writePromptToTempFile(agent.name, agent.systemPrompt);
|
|
381
|
+
tmpPromptDir = tmp.dir;
|
|
382
|
+
tmpPromptPath = tmp.filePath;
|
|
383
|
+
args.push("--append-system-prompt", tmpPromptPath);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
args.push(`Task: ${task}`);
|
|
387
|
+
let wasAborted = false;
|
|
388
|
+
|
|
389
|
+
const exitCode = await new Promise<number>((resolve) => {
|
|
390
|
+
const invocation = getGripInvocation(args);
|
|
391
|
+
const proc = spawn(invocation.command, invocation.args, {
|
|
392
|
+
cwd: cwd ?? defaultCwd,
|
|
393
|
+
shell: false,
|
|
394
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
395
|
+
});
|
|
396
|
+
let buffer = "";
|
|
397
|
+
|
|
398
|
+
const processLine = (line: string) => {
|
|
399
|
+
const event = parseSubagentProcessEvent(line);
|
|
400
|
+
if (event) recordSubagentProcessEvent(event, currentResult, emitUpdate);
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
proc.stdout.on("data", (data) => {
|
|
404
|
+
buffer += data.toString();
|
|
405
|
+
const lines = buffer.split("\n");
|
|
406
|
+
buffer = lines.pop() || "";
|
|
407
|
+
for (const line of lines) processLine(line);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
proc.stderr.on("data", (data) => {
|
|
411
|
+
currentResult.stderr += data.toString();
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
proc.on("close", (code) => {
|
|
415
|
+
if (buffer.trim()) processLine(buffer);
|
|
416
|
+
resolve(code ?? 0);
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
proc.on("error", () => {
|
|
420
|
+
resolve(1);
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
if (signal) {
|
|
424
|
+
const killProc = () => {
|
|
425
|
+
wasAborted = true;
|
|
426
|
+
proc.kill("SIGTERM");
|
|
427
|
+
setTimeout(() => {
|
|
428
|
+
if (!proc.killed) proc.kill("SIGKILL");
|
|
429
|
+
}, 5000);
|
|
430
|
+
};
|
|
431
|
+
if (signal.aborted) killProc();
|
|
432
|
+
else signal.addEventListener("abort", killProc, { once: true });
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
currentResult.exitCode = exitCode;
|
|
437
|
+
if (wasAborted) throw new Error("Subagent was aborted");
|
|
438
|
+
return currentResult;
|
|
439
|
+
} finally {
|
|
440
|
+
if (tmpPromptPath)
|
|
441
|
+
try {
|
|
442
|
+
fs.unlinkSync(tmpPromptPath);
|
|
443
|
+
} catch {
|
|
444
|
+
/* ignore */
|
|
445
|
+
}
|
|
446
|
+
if (tmpPromptDir)
|
|
447
|
+
try {
|
|
448
|
+
fs.rmdirSync(tmpPromptDir);
|
|
449
|
+
} catch {
|
|
450
|
+
/* ignore */
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const TaskItem = Type.Object({
|
|
456
|
+
agent: Type.String({ description: "Name of the agent to invoke" }),
|
|
457
|
+
task: Type.String({ description: "Task to delegate to the agent" }),
|
|
458
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
const ChainItem = Type.Object({
|
|
462
|
+
agent: Type.String({ description: "Name of the agent to invoke" }),
|
|
463
|
+
task: Type.String({ description: "Task with optional {previous} placeholder for prior output" }),
|
|
464
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process" })),
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
const AgentScopeSchema = StringEnum(["user", "project", "both"] as const, {
|
|
468
|
+
description: 'Which agent directories to use. Default: "user". Use "both" to include project-local agents.',
|
|
469
|
+
default: "user",
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const SubagentParams = Type.Object({
|
|
473
|
+
agent: Type.Optional(Type.String({ description: "Name of the agent to invoke (for single mode)" })),
|
|
474
|
+
task: Type.Optional(Type.String({ description: "Task to delegate (for single mode)" })),
|
|
475
|
+
tasks: Type.Optional(Type.Array(TaskItem, { description: "Array of {agent, task} for parallel execution" })),
|
|
476
|
+
chain: Type.Optional(Type.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })),
|
|
477
|
+
agentScope: Type.Optional(AgentScopeSchema),
|
|
478
|
+
confirmProjectAgents: Type.Optional(
|
|
479
|
+
Type.Boolean({ description: "Prompt before running project-local agents. Default: true.", default: true }),
|
|
480
|
+
),
|
|
481
|
+
cwd: Type.Optional(Type.String({ description: "Working directory for the agent process (single mode)" })),
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
interface SubagentTask {
|
|
485
|
+
agent: string;
|
|
486
|
+
task: string;
|
|
487
|
+
cwd?: string;
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
interface SubagentExecutionRequest {
|
|
491
|
+
mode: SubagentMode;
|
|
492
|
+
tasks: SubagentTask[];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
type SubagentParameters = Static<typeof SubagentParams>;
|
|
496
|
+
type SubagentDetailsFactory = (results: SingleResult[]) => SubagentDetails;
|
|
497
|
+
|
|
498
|
+
interface SubagentExecutionEnvironment {
|
|
499
|
+
extensionContext: ExtensionContext;
|
|
500
|
+
agents: AgentConfig[];
|
|
501
|
+
agentScope: AgentScope;
|
|
502
|
+
projectAgentsDir: string | null;
|
|
503
|
+
signal: AbortSignal | undefined;
|
|
504
|
+
onUpdate: OnUpdateCallback | undefined;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function resolveSubagentExecutionRequest(params: SubagentParameters): SubagentExecutionRequest | undefined {
|
|
508
|
+
const requests: SubagentExecutionRequest[] = [];
|
|
509
|
+
if (params.chain && params.chain.length > 0) requests.push({ mode: "chain", tasks: params.chain });
|
|
510
|
+
if (params.tasks && params.tasks.length > 0) requests.push({ mode: "parallel", tasks: params.tasks });
|
|
511
|
+
if (params.agent && params.task) {
|
|
512
|
+
requests.push({ mode: "single", tasks: [{ agent: params.agent, task: params.task, cwd: params.cwd }] });
|
|
513
|
+
}
|
|
514
|
+
return requests.length === 1 ? requests[0] : undefined;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function createSubagentDetailsFactory(
|
|
518
|
+
environment: SubagentExecutionEnvironment,
|
|
519
|
+
mode: SubagentMode,
|
|
520
|
+
): SubagentDetailsFactory {
|
|
521
|
+
return (results) => ({
|
|
522
|
+
mode,
|
|
523
|
+
agentScope: environment.agentScope,
|
|
524
|
+
projectAgentsDir: environment.projectAgentsDir,
|
|
525
|
+
results,
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function createSubagentTextResult(text: string, details: SubagentDetails, isError = false): SubagentToolResult {
|
|
530
|
+
const result: SubagentToolResult = { content: [{ type: "text", text }], details };
|
|
531
|
+
if (isError) result.isError = true;
|
|
532
|
+
return result;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
async function approveProjectAgents(
|
|
536
|
+
params: SubagentParameters,
|
|
537
|
+
environment: SubagentExecutionEnvironment,
|
|
538
|
+
confirmProjectAgents: boolean,
|
|
539
|
+
): Promise<boolean> {
|
|
540
|
+
const scopeIncludesProject = environment.agentScope === "project" || environment.agentScope === "both";
|
|
541
|
+
if (!scopeIncludesProject || !confirmProjectAgents || !environment.extensionContext.hasUI) return true;
|
|
542
|
+
const requestedAgentNames = new Set<string>();
|
|
543
|
+
if (params.chain) for (const step of params.chain) requestedAgentNames.add(step.agent);
|
|
544
|
+
if (params.tasks) for (const task of params.tasks) requestedAgentNames.add(task.agent);
|
|
545
|
+
if (params.agent) requestedAgentNames.add(params.agent);
|
|
546
|
+
const firstAgentByName = new Map<string, AgentConfig>();
|
|
547
|
+
for (const agent of environment.agents) {
|
|
548
|
+
if (!firstAgentByName.has(agent.name)) firstAgentByName.set(agent.name, agent);
|
|
549
|
+
}
|
|
550
|
+
const projectAgents = Array.from(requestedAgentNames)
|
|
551
|
+
.map((name) => firstAgentByName.get(name))
|
|
552
|
+
.filter((agent): agent is AgentConfig => agent?.source === "project");
|
|
553
|
+
if (projectAgents.length === 0) return true;
|
|
554
|
+
const names = projectAgents.map((agent) => agent.name).join(", ");
|
|
555
|
+
const dir = environment.projectAgentsDir ?? "(unknown)";
|
|
556
|
+
return environment.extensionContext.ui.confirm(
|
|
557
|
+
"Run project-local agents?",
|
|
558
|
+
`Agents: ${names}\nSource: ${dir}\n\nProject agents are repo-controlled. Only continue for trusted repositories.`,
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function createChainUpdateCallback(
|
|
563
|
+
environment: SubagentExecutionEnvironment,
|
|
564
|
+
completedResults: SingleResult[],
|
|
565
|
+
detailsFactory: SubagentDetailsFactory,
|
|
566
|
+
): OnUpdateCallback | undefined {
|
|
567
|
+
if (!environment.onUpdate) return undefined;
|
|
568
|
+
return (partial) => {
|
|
569
|
+
const currentResult = partial.details?.results[0];
|
|
570
|
+
if (!currentResult) return;
|
|
571
|
+
environment.onUpdate?.({
|
|
572
|
+
content: partial.content,
|
|
573
|
+
details: detailsFactory([...completedResults, currentResult]),
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
async function executeSubagentChain(
|
|
579
|
+
tasks: SubagentTask[],
|
|
580
|
+
environment: SubagentExecutionEnvironment,
|
|
581
|
+
): Promise<AgentToolResult<SubagentDetails>> {
|
|
582
|
+
const results: SingleResult[] = [];
|
|
583
|
+
const detailsFactory = createSubagentDetailsFactory(environment, "chain");
|
|
584
|
+
let previousOutput = "";
|
|
585
|
+
for (let index = 0; index < tasks.length; index++) {
|
|
586
|
+
const step = tasks[index];
|
|
587
|
+
const result = await runSingleAgent(
|
|
588
|
+
environment.extensionContext.cwd,
|
|
589
|
+
environment.agents,
|
|
590
|
+
step.agent,
|
|
591
|
+
step.task.replace(/\{previous\}/g, previousOutput),
|
|
592
|
+
step.cwd,
|
|
593
|
+
index + 1,
|
|
594
|
+
environment.signal,
|
|
595
|
+
createChainUpdateCallback(environment, results, detailsFactory),
|
|
596
|
+
detailsFactory,
|
|
597
|
+
);
|
|
598
|
+
results.push(result);
|
|
599
|
+
if (isFailedResult(result)) {
|
|
600
|
+
return createSubagentTextResult(
|
|
601
|
+
`Chain stopped at step ${index + 1} (${step.agent}): ${getResultOutput(result)}`,
|
|
602
|
+
detailsFactory(results),
|
|
603
|
+
true,
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
previousOutput = getFinalOutput(result.messages);
|
|
607
|
+
}
|
|
608
|
+
const finalResult = results[results.length - 1];
|
|
609
|
+
return createSubagentTextResult(getFinalOutput(finalResult.messages) || "(no output)", detailsFactory(results));
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
function createPendingParallelResults(tasks: SubagentTask[]): SingleResult[] {
|
|
613
|
+
return tasks.map((task) => ({
|
|
614
|
+
agent: task.agent,
|
|
615
|
+
agentSource: "unknown",
|
|
616
|
+
task: task.task,
|
|
617
|
+
exitCode: -1,
|
|
618
|
+
messages: [],
|
|
619
|
+
stderr: "",
|
|
620
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, contextTokens: 0, turns: 0 },
|
|
621
|
+
}));
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function emitParallelProgress(
|
|
625
|
+
environment: SubagentExecutionEnvironment,
|
|
626
|
+
results: SingleResult[],
|
|
627
|
+
detailsFactory: SubagentDetailsFactory,
|
|
628
|
+
): void {
|
|
629
|
+
if (!environment.onUpdate) return;
|
|
630
|
+
const running = results.filter((result) => result.exitCode === -1).length;
|
|
631
|
+
const done = results.length - running;
|
|
632
|
+
environment.onUpdate({
|
|
633
|
+
content: [{ type: "text", text: `Parallel: ${done}/${results.length} done, ${running} running...` }],
|
|
634
|
+
details: detailsFactory([...results]),
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
function formatParallelSummary(result: SingleResult): string {
|
|
639
|
+
const output = truncateParallelOutput(getResultOutput(result));
|
|
640
|
+
const status = isFailedResult(result)
|
|
641
|
+
? `failed${result.stopReason && result.stopReason !== "end" ? ` (${result.stopReason})` : ""}`
|
|
642
|
+
: "completed";
|
|
643
|
+
return `### [${result.agent}] ${status}\n\n${output}`;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
async function executeSubagentsInParallel(
|
|
647
|
+
tasks: SubagentTask[],
|
|
648
|
+
environment: SubagentExecutionEnvironment,
|
|
649
|
+
): Promise<AgentToolResult<SubagentDetails>> {
|
|
650
|
+
const detailsFactory = createSubagentDetailsFactory(environment, "parallel");
|
|
651
|
+
if (tasks.length > MAX_PARALLEL_TASKS) {
|
|
652
|
+
return createSubagentTextResult(
|
|
653
|
+
`Too many parallel tasks (${tasks.length}). Max is ${MAX_PARALLEL_TASKS}.`,
|
|
654
|
+
detailsFactory([]),
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
const allResults = createPendingParallelResults(tasks);
|
|
658
|
+
const results = await mapWithConcurrencyLimit(tasks, MAX_CONCURRENCY, async (task, index) => {
|
|
659
|
+
const result = await runSingleAgent(
|
|
660
|
+
environment.extensionContext.cwd,
|
|
661
|
+
environment.agents,
|
|
662
|
+
task.agent,
|
|
663
|
+
task.task,
|
|
664
|
+
task.cwd,
|
|
665
|
+
undefined,
|
|
666
|
+
environment.signal,
|
|
667
|
+
(partial) => {
|
|
668
|
+
const currentResult = partial.details?.results[0];
|
|
669
|
+
if (!currentResult) return;
|
|
670
|
+
allResults[index] = currentResult;
|
|
671
|
+
emitParallelProgress(environment, allResults, detailsFactory);
|
|
672
|
+
},
|
|
673
|
+
detailsFactory,
|
|
674
|
+
);
|
|
675
|
+
allResults[index] = result;
|
|
676
|
+
emitParallelProgress(environment, allResults, detailsFactory);
|
|
677
|
+
return result;
|
|
678
|
+
});
|
|
679
|
+
const successCount = results.filter((result) => !isFailedResult(result)).length;
|
|
680
|
+
const summaries = results.map(formatParallelSummary);
|
|
681
|
+
return createSubagentTextResult(
|
|
682
|
+
`Parallel: ${successCount}/${results.length} succeeded\n\n${summaries.join("\n\n---\n\n")}`,
|
|
683
|
+
detailsFactory(results),
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
async function executeSingleSubagent(
|
|
688
|
+
task: SubagentTask,
|
|
689
|
+
environment: SubagentExecutionEnvironment,
|
|
690
|
+
): Promise<AgentToolResult<SubagentDetails>> {
|
|
691
|
+
const detailsFactory = createSubagentDetailsFactory(environment, "single");
|
|
692
|
+
const result = await runSingleAgent(
|
|
693
|
+
environment.extensionContext.cwd,
|
|
694
|
+
environment.agents,
|
|
695
|
+
task.agent,
|
|
696
|
+
task.task,
|
|
697
|
+
task.cwd,
|
|
698
|
+
undefined,
|
|
699
|
+
environment.signal,
|
|
700
|
+
environment.onUpdate,
|
|
701
|
+
detailsFactory,
|
|
702
|
+
);
|
|
703
|
+
if (isFailedResult(result)) {
|
|
704
|
+
return createSubagentTextResult(
|
|
705
|
+
`Agent ${result.stopReason || "failed"}: ${getResultOutput(result)}`,
|
|
706
|
+
detailsFactory([result]),
|
|
707
|
+
true,
|
|
708
|
+
);
|
|
709
|
+
}
|
|
710
|
+
return createSubagentTextResult(getFinalOutput(result.messages) || "(no output)", detailsFactory([result]));
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
async function executeSubagentTool(
|
|
714
|
+
params: SubagentParameters,
|
|
715
|
+
signal: AbortSignal | undefined,
|
|
716
|
+
onUpdate: OnUpdateCallback | undefined,
|
|
717
|
+
ctx: ExtensionContext,
|
|
718
|
+
): Promise<AgentToolResult<SubagentDetails>> {
|
|
719
|
+
const agentScope: AgentScope = params.agentScope ?? "user";
|
|
720
|
+
const discovery = discoverAgents(ctx.cwd, agentScope);
|
|
721
|
+
const environment: SubagentExecutionEnvironment = {
|
|
722
|
+
extensionContext: ctx,
|
|
723
|
+
agents: discovery.agents,
|
|
724
|
+
agentScope,
|
|
725
|
+
projectAgentsDir: discovery.projectAgentsDir,
|
|
726
|
+
signal,
|
|
727
|
+
onUpdate,
|
|
728
|
+
};
|
|
729
|
+
const request = resolveSubagentExecutionRequest(params);
|
|
730
|
+
if (!request) {
|
|
731
|
+
const available = discovery.agents.map((agent) => `${agent.name} (${agent.source})`).join(", ") || "none";
|
|
732
|
+
return createSubagentTextResult(
|
|
733
|
+
`Invalid parameters. Provide exactly one mode.\nAvailable agents: ${available}`,
|
|
734
|
+
createSubagentDetailsFactory(environment, "single")([]),
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
const approved = await approveProjectAgents(params, environment, params.confirmProjectAgents ?? true);
|
|
738
|
+
if (!approved) {
|
|
739
|
+
return createSubagentTextResult(
|
|
740
|
+
"Canceled: project-local agents not approved.",
|
|
741
|
+
createSubagentDetailsFactory(environment, request.mode)([]),
|
|
742
|
+
);
|
|
743
|
+
}
|
|
744
|
+
switch (request.mode) {
|
|
745
|
+
case "chain":
|
|
746
|
+
return executeSubagentChain(request.tasks, environment);
|
|
747
|
+
case "parallel":
|
|
748
|
+
return executeSubagentsInParallel(request.tasks, environment);
|
|
749
|
+
case "single":
|
|
750
|
+
return executeSingleSubagent(request.tasks[0], environment);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function renderSubagentChainCall(args: SubagentParameters, scope: AgentScope, theme: Theme): Text | undefined {
|
|
755
|
+
if (!args.chain || args.chain.length === 0) return undefined;
|
|
756
|
+
let text =
|
|
757
|
+
theme.fg("toolTitle", theme.bold("subagent ")) +
|
|
758
|
+
theme.fg("accent", `chain (${args.chain.length} steps)`) +
|
|
759
|
+
theme.fg("muted", ` [${scope}]`);
|
|
760
|
+
for (let index = 0; index < Math.min(args.chain.length, 3); index++) {
|
|
761
|
+
const step = args.chain[index];
|
|
762
|
+
const cleanTask = step.task.replace(/\{previous\}/g, "").trim();
|
|
763
|
+
const preview = cleanTask.length > 40 ? `${cleanTask.slice(0, 40)}...` : cleanTask;
|
|
764
|
+
text +=
|
|
765
|
+
"\n " +
|
|
766
|
+
theme.fg("muted", `${index + 1}.`) +
|
|
767
|
+
" " +
|
|
768
|
+
theme.fg("accent", step.agent) +
|
|
769
|
+
theme.fg("dim", ` ${preview}`);
|
|
770
|
+
}
|
|
771
|
+
if (args.chain.length > 3) text += `\n ${theme.fg("muted", `... +${args.chain.length - 3} more`)}`;
|
|
772
|
+
return new Text(text, 0, 0);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function renderSubagentParallelCall(args: SubagentParameters, scope: AgentScope, theme: Theme): Text | undefined {
|
|
776
|
+
if (!args.tasks || args.tasks.length === 0) return undefined;
|
|
777
|
+
let text =
|
|
778
|
+
theme.fg("toolTitle", theme.bold("subagent ")) +
|
|
779
|
+
theme.fg("accent", `parallel (${args.tasks.length} tasks)`) +
|
|
780
|
+
theme.fg("muted", ` [${scope}]`);
|
|
781
|
+
for (const task of args.tasks.slice(0, 3)) {
|
|
782
|
+
const preview = task.task.length > 40 ? `${task.task.slice(0, 40)}...` : task.task;
|
|
783
|
+
text += `\n ${theme.fg("accent", task.agent)}${theme.fg("dim", ` ${preview}`)}`;
|
|
784
|
+
}
|
|
785
|
+
if (args.tasks.length > 3) text += `\n ${theme.fg("muted", `... +${args.tasks.length - 3} more`)}`;
|
|
786
|
+
return new Text(text, 0, 0);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
function renderSingleSubagentCall(args: SubagentParameters, scope: AgentScope, theme: Theme): Text {
|
|
790
|
+
const agentName = args.agent || "...";
|
|
791
|
+
const preview = args.task ? (args.task.length > 60 ? `${args.task.slice(0, 60)}...` : args.task) : "...";
|
|
792
|
+
let text =
|
|
793
|
+
theme.fg("toolTitle", theme.bold("subagent ")) + theme.fg("accent", agentName) + theme.fg("muted", ` [${scope}]`);
|
|
794
|
+
text += `\n ${theme.fg("dim", preview)}`;
|
|
795
|
+
return new Text(text, 0, 0);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
type SubagentRenderedResult = Container | Text;
|
|
799
|
+
|
|
800
|
+
function renderDisplayItems(items: DisplayItem[], expanded: boolean, theme: Theme, limit?: number): string {
|
|
801
|
+
const toShow = limit ? items.slice(-limit) : items;
|
|
802
|
+
const skipped = limit && items.length > limit ? items.length - limit : 0;
|
|
803
|
+
let text = skipped > 0 ? theme.fg("muted", `... ${skipped} earlier items\n`) : "";
|
|
804
|
+
for (const item of toShow) {
|
|
805
|
+
if (item.type === "text") {
|
|
806
|
+
const preview = expanded ? item.text : item.text.split("\n").slice(0, 3).join("\n");
|
|
807
|
+
text += `${theme.fg("toolOutput", preview)}\n`;
|
|
808
|
+
} else {
|
|
809
|
+
text += `${theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme))}\n`;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return text.trimEnd();
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
function aggregateUsage(results: SingleResult[]): UsageDisplayStats {
|
|
816
|
+
const total: UsageDisplayStats = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 };
|
|
817
|
+
for (const result of results) {
|
|
818
|
+
total.input += result.usage.input;
|
|
819
|
+
total.output += result.usage.output;
|
|
820
|
+
total.cacheRead += result.usage.cacheRead;
|
|
821
|
+
total.cacheWrite += result.usage.cacheWrite;
|
|
822
|
+
total.cost += result.usage.cost;
|
|
823
|
+
total.turns = (total.turns ?? 0) + result.usage.turns;
|
|
824
|
+
}
|
|
825
|
+
return total;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
function appendToolCalls(container: Container, items: DisplayItem[], theme: Theme): void {
|
|
829
|
+
for (const item of items) {
|
|
830
|
+
if (item.type !== "toolCall") continue;
|
|
831
|
+
container.addChild(
|
|
832
|
+
new Text(theme.fg("muted", "→ ") + formatToolCall(item.name, item.args, theme.fg.bind(theme)), 0, 0),
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
function appendFinalOutput(container: Container, output: string): void {
|
|
838
|
+
if (!output) return;
|
|
839
|
+
container.addChild(new Spacer(1));
|
|
840
|
+
container.addChild(new Markdown(output.trim(), 0, 0, getMarkdownTheme()));
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
function appendUsage(container: Container, usage: string, theme: Theme, prefix = ""): void {
|
|
844
|
+
if (!usage) return;
|
|
845
|
+
container.addChild(new Spacer(1));
|
|
846
|
+
container.addChild(new Text(theme.fg("dim", `${prefix}${usage}`), 0, 0));
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
function renderExpandedSingleResult(result: SingleResult, theme: Theme): Container {
|
|
850
|
+
const isError = isFailedResult(result);
|
|
851
|
+
const icon = isError ? theme.fg("error", "✗") : theme.fg("success", "✓");
|
|
852
|
+
const displayItems = getDisplayItems(result.messages);
|
|
853
|
+
const finalOutput = getFinalOutput(result.messages);
|
|
854
|
+
const container = new Container();
|
|
855
|
+
let header = `${icon} ${theme.fg("toolTitle", theme.bold(result.agent))}${theme.fg("muted", ` (${result.agentSource})`)}`;
|
|
856
|
+
if (isError && result.stopReason) header += ` ${theme.fg("error", `[${result.stopReason}]`)}`;
|
|
857
|
+
container.addChild(new Text(header, 0, 0));
|
|
858
|
+
if (isError && result.errorMessage) {
|
|
859
|
+
container.addChild(new Text(theme.fg("error", `Error: ${result.errorMessage}`), 0, 0));
|
|
860
|
+
}
|
|
861
|
+
container.addChild(new Spacer(1));
|
|
862
|
+
container.addChild(new Text(theme.fg("muted", "─── Task ───"), 0, 0));
|
|
863
|
+
container.addChild(new Text(theme.fg("dim", result.task), 0, 0));
|
|
864
|
+
container.addChild(new Spacer(1));
|
|
865
|
+
container.addChild(new Text(theme.fg("muted", "─── Output ───"), 0, 0));
|
|
866
|
+
if (displayItems.length === 0 && !finalOutput) {
|
|
867
|
+
container.addChild(new Text(theme.fg("muted", "(no output)"), 0, 0));
|
|
868
|
+
} else {
|
|
869
|
+
appendToolCalls(container, displayItems, theme);
|
|
870
|
+
appendFinalOutput(container, finalOutput);
|
|
871
|
+
}
|
|
872
|
+
appendUsage(container, formatUsageStats(result.usage, result.model), theme);
|
|
873
|
+
return container;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
function renderCollapsedSingleResult(result: SingleResult, theme: Theme): Text {
|
|
877
|
+
const isError = isFailedResult(result);
|
|
878
|
+
const icon = isError ? theme.fg("error", "✗") : theme.fg("success", "✓");
|
|
879
|
+
const displayItems = getDisplayItems(result.messages);
|
|
880
|
+
let text = `${icon} ${theme.fg("toolTitle", theme.bold(result.agent))}${theme.fg("muted", ` (${result.agentSource})`)}`;
|
|
881
|
+
if (isError && result.stopReason) text += ` ${theme.fg("error", `[${result.stopReason}]`)}`;
|
|
882
|
+
if (isError && result.errorMessage) {
|
|
883
|
+
text += `\n${theme.fg("error", `Error: ${result.errorMessage}`)}`;
|
|
884
|
+
} else if (displayItems.length === 0) {
|
|
885
|
+
text += `\n${theme.fg("muted", "(no output)")}`;
|
|
886
|
+
} else {
|
|
887
|
+
text += `\n${renderDisplayItems(displayItems, false, theme, COLLAPSED_ITEM_COUNT)}`;
|
|
888
|
+
if (displayItems.length > COLLAPSED_ITEM_COUNT) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
889
|
+
}
|
|
890
|
+
const usage = formatUsageStats(result.usage, result.model);
|
|
891
|
+
if (usage) text += `\n${theme.fg("dim", usage)}`;
|
|
892
|
+
return new Text(text, 0, 0);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
function renderSingleSubagentResult(result: SingleResult, expanded: boolean, theme: Theme): SubagentRenderedResult {
|
|
896
|
+
return expanded ? renderExpandedSingleResult(result, theme) : renderCollapsedSingleResult(result, theme);
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
function appendExpandedSubagentResult(
|
|
900
|
+
container: Container,
|
|
901
|
+
result: SingleResult,
|
|
902
|
+
heading: string,
|
|
903
|
+
theme: Theme,
|
|
904
|
+
failed: boolean,
|
|
905
|
+
): void {
|
|
906
|
+
const icon = failed ? theme.fg("error", "✗") : theme.fg("success", "✓");
|
|
907
|
+
const displayItems = getDisplayItems(result.messages);
|
|
908
|
+
container.addChild(new Spacer(1));
|
|
909
|
+
container.addChild(new Text(`${heading} ${icon}`, 0, 0));
|
|
910
|
+
container.addChild(new Text(theme.fg("muted", "Task: ") + theme.fg("dim", result.task), 0, 0));
|
|
911
|
+
appendToolCalls(container, displayItems, theme);
|
|
912
|
+
appendFinalOutput(container, getFinalOutput(result.messages));
|
|
913
|
+
const usage = formatUsageStats(result.usage, result.model);
|
|
914
|
+
if (usage) container.addChild(new Text(theme.fg("dim", usage), 0, 0));
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
function renderExpandedChain(details: SubagentDetails, successCount: number, icon: string, theme: Theme): Container {
|
|
918
|
+
const container = new Container();
|
|
919
|
+
container.addChild(
|
|
920
|
+
new Text(
|
|
921
|
+
icon +
|
|
922
|
+
" " +
|
|
923
|
+
theme.fg("toolTitle", theme.bold("chain ")) +
|
|
924
|
+
theme.fg("accent", `${successCount}/${details.results.length} steps`),
|
|
925
|
+
0,
|
|
926
|
+
0,
|
|
927
|
+
),
|
|
928
|
+
);
|
|
929
|
+
for (const result of details.results) {
|
|
930
|
+
const heading = theme.fg("muted", `─── Step ${result.step}: `) + theme.fg("accent", result.agent);
|
|
931
|
+
appendExpandedSubagentResult(container, result, heading, theme, result.exitCode !== 0);
|
|
932
|
+
}
|
|
933
|
+
appendUsage(container, formatUsageStats(aggregateUsage(details.results)), theme, "Total: ");
|
|
934
|
+
return container;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function renderCollapsedChain(details: SubagentDetails, successCount: number, icon: string, theme: Theme): Text {
|
|
938
|
+
let text =
|
|
939
|
+
icon +
|
|
940
|
+
" " +
|
|
941
|
+
theme.fg("toolTitle", theme.bold("chain ")) +
|
|
942
|
+
theme.fg("accent", `${successCount}/${details.results.length} steps`);
|
|
943
|
+
for (const result of details.results) {
|
|
944
|
+
const resultIcon = result.exitCode === 0 ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
945
|
+
const displayItems = getDisplayItems(result.messages);
|
|
946
|
+
text += `\n\n${theme.fg("muted", `─── Step ${result.step}: `)}${theme.fg("accent", result.agent)} ${resultIcon}`;
|
|
947
|
+
text +=
|
|
948
|
+
displayItems.length === 0
|
|
949
|
+
? `\n${theme.fg("muted", "(no output)")}`
|
|
950
|
+
: `\n${renderDisplayItems(displayItems, false, theme, 5)}`;
|
|
951
|
+
}
|
|
952
|
+
const usage = formatUsageStats(aggregateUsage(details.results));
|
|
953
|
+
if (usage) text += `\n\n${theme.fg("dim", `Total: ${usage}`)}`;
|
|
954
|
+
text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
955
|
+
return new Text(text, 0, 0);
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function renderChainResult(details: SubagentDetails, expanded: boolean, theme: Theme): SubagentRenderedResult {
|
|
959
|
+
const successCount = details.results.filter((result) => result.exitCode === 0).length;
|
|
960
|
+
const icon = successCount === details.results.length ? theme.fg("success", "✓") : theme.fg("error", "✗");
|
|
961
|
+
return expanded
|
|
962
|
+
? renderExpandedChain(details, successCount, icon, theme)
|
|
963
|
+
: renderCollapsedChain(details, successCount, icon, theme);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
interface ParallelStatus {
|
|
967
|
+
running: number;
|
|
968
|
+
successCount: number;
|
|
969
|
+
failCount: number;
|
|
970
|
+
isRunning: boolean;
|
|
971
|
+
icon: string;
|
|
972
|
+
label: string;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
function getParallelStatus(details: SubagentDetails, theme: Theme): ParallelStatus {
|
|
976
|
+
const running = details.results.filter((result) => result.exitCode === -1).length;
|
|
977
|
+
const successCount = details.results.filter((result) => result.exitCode !== -1 && !isFailedResult(result)).length;
|
|
978
|
+
const failCount = details.results.filter((result) => result.exitCode !== -1 && isFailedResult(result)).length;
|
|
979
|
+
const isRunning = running > 0;
|
|
980
|
+
const icon = isRunning
|
|
981
|
+
? theme.fg("warning", "⏳")
|
|
982
|
+
: failCount > 0
|
|
983
|
+
? theme.fg("warning", "◐")
|
|
984
|
+
: theme.fg("success", "✓");
|
|
985
|
+
const label = isRunning
|
|
986
|
+
? `${successCount + failCount}/${details.results.length} done, ${running} running`
|
|
987
|
+
: `${successCount}/${details.results.length} tasks`;
|
|
988
|
+
return { running, successCount, failCount, isRunning, icon, label };
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
function renderExpandedParallel(details: SubagentDetails, status: ParallelStatus, theme: Theme): Container {
|
|
992
|
+
const container = new Container();
|
|
993
|
+
container.addChild(
|
|
994
|
+
new Text(
|
|
995
|
+
`${status.icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status.label)}`,
|
|
996
|
+
0,
|
|
997
|
+
0,
|
|
998
|
+
),
|
|
999
|
+
);
|
|
1000
|
+
for (const result of details.results) {
|
|
1001
|
+
const heading = theme.fg("muted", "─── ") + theme.fg("accent", result.agent);
|
|
1002
|
+
appendExpandedSubagentResult(container, result, heading, theme, isFailedResult(result));
|
|
1003
|
+
}
|
|
1004
|
+
appendUsage(container, formatUsageStats(aggregateUsage(details.results)), theme, "Total: ");
|
|
1005
|
+
return container;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
function renderCollapsedParallel(
|
|
1009
|
+
details: SubagentDetails,
|
|
1010
|
+
status: ParallelStatus,
|
|
1011
|
+
expanded: boolean,
|
|
1012
|
+
theme: Theme,
|
|
1013
|
+
): Text {
|
|
1014
|
+
let text = `${status.icon} ${theme.fg("toolTitle", theme.bold("parallel "))}${theme.fg("accent", status.label)}`;
|
|
1015
|
+
for (const result of details.results) {
|
|
1016
|
+
const resultIcon =
|
|
1017
|
+
result.exitCode === -1
|
|
1018
|
+
? theme.fg("warning", "⏳")
|
|
1019
|
+
: isFailedResult(result)
|
|
1020
|
+
? theme.fg("error", "✗")
|
|
1021
|
+
: theme.fg("success", "✓");
|
|
1022
|
+
const displayItems = getDisplayItems(result.messages);
|
|
1023
|
+
text += `\n\n${theme.fg("muted", "─── ")}${theme.fg("accent", result.agent)} ${resultIcon}`;
|
|
1024
|
+
text +=
|
|
1025
|
+
displayItems.length === 0
|
|
1026
|
+
? `\n${theme.fg("muted", result.exitCode === -1 ? "(running...)" : "(no output)")}`
|
|
1027
|
+
: `\n${renderDisplayItems(displayItems, false, theme, 5)}`;
|
|
1028
|
+
}
|
|
1029
|
+
if (!status.isRunning) {
|
|
1030
|
+
const usage = formatUsageStats(aggregateUsage(details.results));
|
|
1031
|
+
if (usage) text += `\n\n${theme.fg("dim", `Total: ${usage}`)}`;
|
|
1032
|
+
}
|
|
1033
|
+
if (!expanded) text += `\n${theme.fg("muted", "(Ctrl+O to expand)")}`;
|
|
1034
|
+
return new Text(text, 0, 0);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
function renderParallelResult(details: SubagentDetails, expanded: boolean, theme: Theme): SubagentRenderedResult {
|
|
1038
|
+
const status = getParallelStatus(details, theme);
|
|
1039
|
+
if (expanded && !status.isRunning) return renderExpandedParallel(details, status, theme);
|
|
1040
|
+
return renderCollapsedParallel(details, status, expanded, theme);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
export default function (pi: ExtensionAPI) {
|
|
1044
|
+
pi.registerTool({
|
|
1045
|
+
name: "subagent",
|
|
1046
|
+
label: "Subagent",
|
|
1047
|
+
description: [
|
|
1048
|
+
"Delegate tasks to specialized subagents with isolated context.",
|
|
1049
|
+
"Modes: single (agent + task), parallel (tasks array), chain (sequential with {previous} placeholder).",
|
|
1050
|
+
'Default agent scope is "user" (from ~/.grip/agent/agents).',
|
|
1051
|
+
'To enable project-local agents in .grip/agents, set agentScope: "both" (or "project").',
|
|
1052
|
+
].join(" "),
|
|
1053
|
+
parameters: SubagentParams,
|
|
1054
|
+
|
|
1055
|
+
execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
1056
|
+
return executeSubagentTool(params, signal, onUpdate, ctx);
|
|
1057
|
+
},
|
|
1058
|
+
|
|
1059
|
+
renderCall(args, theme, _context) {
|
|
1060
|
+
const scope: AgentScope = args.agentScope ?? "user";
|
|
1061
|
+
const chainCall = renderSubagentChainCall(args, scope, theme);
|
|
1062
|
+
if (chainCall) return chainCall;
|
|
1063
|
+
const parallelCall = renderSubagentParallelCall(args, scope, theme);
|
|
1064
|
+
if (parallelCall) return parallelCall;
|
|
1065
|
+
return renderSingleSubagentCall(args, scope, theme);
|
|
1066
|
+
},
|
|
1067
|
+
|
|
1068
|
+
renderResult(result, { expanded }, theme, _context) {
|
|
1069
|
+
const details = result.details as SubagentDetails | undefined;
|
|
1070
|
+
if (!details || details.results.length === 0) {
|
|
1071
|
+
const text = result.content[0];
|
|
1072
|
+
return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
|
|
1073
|
+
}
|
|
1074
|
+
if (details.mode === "single" && details.results.length === 1) {
|
|
1075
|
+
return renderSingleSubagentResult(details.results[0], expanded, theme);
|
|
1076
|
+
}
|
|
1077
|
+
if (details.mode === "chain") return renderChainResult(details, expanded, theme);
|
|
1078
|
+
if (details.mode === "parallel") return renderParallelResult(details, expanded, theme);
|
|
1079
|
+
const text = result.content[0];
|
|
1080
|
+
return new Text(text?.type === "text" ? text.text : "(no output)", 0, 0);
|
|
1081
|
+
},
|
|
1082
|
+
});
|
|
1083
|
+
}
|