@greppleai/grip 0.0.0-stage → 0.0.1
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 +22 -0
- package/README.md +725 -2
- package/dist/bun/cli.d.ts +3 -0
- package/dist/bun/cli.d.ts.map +1 -0
- package/dist/bun/cli.js +11 -0
- package/dist/bun/cli.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 +441 -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 +5176 -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 +456 -0
- package/dist/core/remote-workspace-protocol/contract.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/contract.js +809 -0
- package/dist/core/remote-workspace-protocol/contract.js.map +1 -0
- package/dist/core/remote-workspace-protocol/session.d.ts +247 -0
- package/dist/core/remote-workspace-protocol/session.d.ts.map +1 -0
- package/dist/core/remote-workspace-protocol/session.js +1839 -0
- package/dist/core/remote-workspace-protocol/session.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 +27 -0
- package/dist/core/sandbox/command.d.ts.map +1 -0
- package/dist/core/sandbox/command.js +124 -0
- package/dist/core/sandbox/command.js.map +1 -0
- package/dist/core/sandbox/docker.d.ts +169 -0
- package/dist/core/sandbox/docker.d.ts.map +1 -0
- package/dist/core/sandbox/docker.js +633 -0
- package/dist/core/sandbox/docker.js.map +1 -0
- package/dist/core/sandbox/lima.d.ts +38 -0
- package/dist/core/sandbox/lima.d.ts.map +1 -0
- package/dist/core/sandbox/lima.js +324 -0
- package/dist/core/sandbox/lima.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 +318 -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 +310 -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 +6 -0
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-queue.js +60 -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 +201 -0
- package/dist/core/tools/operations.d.ts.map +1 -0
- package/dist/core/tools/operations.js +697 -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/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 +43 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +304 -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/security.d.ts +19 -0
- package/dist/daemon/security.d.ts.map +1 -0
- package/dist/daemon/security.js +175 -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 +400 -0
- package/dist/daemon/server.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 +673 -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 +763 -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 +29 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/assistant-message.js +149 -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 +16 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/branch-summary-message.js +44 -0
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +45 -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 +80 -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 +184 -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/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 +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -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 +306 -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 +49 -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 +557 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-mode.js +5859 -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 +106 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme.js +1030 -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 +81 -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 +125 -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 +110 -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 +81 -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 +167 -0
- package/docs/rpc.md +1492 -0
- package/docs/rules.md +117 -0
- package/docs/sandbox.md +181 -0
- package/docs/sdk.md +360 -0
- package/docs/session-format.md +414 -0
- package/docs/sessions.md +137 -0
- package/docs/settings.md +371 -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 +129 -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 +31 -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/sandbox-docker/Dockerfile +274 -0
- package/examples/sandbox-docker/README.md +88 -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 +102 -5
|
@@ -0,0 +1,1243 @@
|
|
|
1
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join, posix, resolve, win32 } from "node:path";
|
|
3
|
+
import { Agent } from "@greppleai/grip-agent-core";
|
|
4
|
+
import { clampThinkingLevel, refreshModelCatalog, streamSimple, } from "@greppleai/grip-ai";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { getAgentDir } from "../config.js";
|
|
7
|
+
import { InteractiveMode } from "../modes/interactive/interactive-mode.js";
|
|
8
|
+
import { stopThemeWatcher } from "../modes/interactive/theme/theme.js";
|
|
9
|
+
import { runPrintMode } from "../modes/print-mode.js";
|
|
10
|
+
import { runRpcMode } from "../modes/rpc/rpc-mode.js";
|
|
11
|
+
import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
12
|
+
import { AgentSession, getDefaultActiveToolNames } from "./agent-session.js";
|
|
13
|
+
import { formatNoModelsAvailableMessage } from "./auth-guidance.js";
|
|
14
|
+
import { AuthStorage } from "./auth-storage.js";
|
|
15
|
+
import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
|
|
16
|
+
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
17
|
+
import { freezeLoadedHooks, loadHooks } from "./hooks/config.js";
|
|
18
|
+
import { canonicalProjectHookCwd, canonicalProjectHookIdentity } from "./hooks/trust-store.js";
|
|
19
|
+
import { loadLspConfiguration, } from "./lsp/config-loader.js";
|
|
20
|
+
import { convertToLlm } from "./messages.js";
|
|
21
|
+
import { ModelRegistry } from "./model-registry.js";
|
|
22
|
+
import { findInitialModel, resolveCliModel } from "./model-resolver.js";
|
|
23
|
+
import { restoreStdout, takeOverStdout } from "./output-guard.js";
|
|
24
|
+
import { DefaultResourceLoader } from "./resource-loader.js";
|
|
25
|
+
import { InMemorySessionManager } from "./session/in-memory-session-manager.js";
|
|
26
|
+
import { getDefaultSessionDir } from "./session/jsonl-helpers.js";
|
|
27
|
+
import { LocalSessionManager } from "./session/local-session-manager.js";
|
|
28
|
+
import { assertSessionCwdExists } from "./session-cwd.js";
|
|
29
|
+
import { InMemorySettingsStorage, SettingsManager } from "./settings-manager.js";
|
|
30
|
+
import { getSourceBackend } from "./source-info.js";
|
|
31
|
+
import { isInstallTelemetryEnabled } from "./telemetry.js";
|
|
32
|
+
import { printTimings, time } from "./timings.js";
|
|
33
|
+
import { borrowToolOperations, } from "./tools/operations.js";
|
|
34
|
+
export function isFatalGripAgentDiagnostic(diagnostic) {
|
|
35
|
+
return diagnostic.type === "error" && diagnostic.fatal !== false;
|
|
36
|
+
}
|
|
37
|
+
function formatLspConfigurationDiagnostics(diagnostics) {
|
|
38
|
+
return diagnostics.map((diagnostic) => ({
|
|
39
|
+
type: diagnostic.severity,
|
|
40
|
+
...(diagnostic.severity === "error" ? { fatal: false } : {}),
|
|
41
|
+
message: `LSP configuration (${diagnostic.source}) ${diagnostic.path}: ${diagnostic.message}`,
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function formatHookDiagnostic(diagnostic) {
|
|
45
|
+
const source = diagnostic.source ? ` (${diagnostic.source.kind}: ${diagnostic.source.path})` : "";
|
|
46
|
+
return {
|
|
47
|
+
type: diagnostic.level,
|
|
48
|
+
fatal: false,
|
|
49
|
+
message: `Hook ${diagnostic.code}${source}: ${diagnostic.message}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export class SessionImportFileNotFoundError extends Error {
|
|
53
|
+
filePath;
|
|
54
|
+
constructor(filePath) {
|
|
55
|
+
super(`File not found: ${filePath}`);
|
|
56
|
+
this.name = "SessionImportFileNotFoundError";
|
|
57
|
+
this.filePath = filePath;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isSubagentCwdConfined(cwd, operations, backend) {
|
|
61
|
+
if (backend?.type === "local")
|
|
62
|
+
return true;
|
|
63
|
+
if (backend === undefined)
|
|
64
|
+
return posix.normalize(cwd) === posix.normalize(operations.cwd);
|
|
65
|
+
const pathApi = backend?.type === "remote" && backend.configured && backend.workspace.pathFlavor === "windows" ? win32 : posix;
|
|
66
|
+
const relative = pathApi.relative(pathApi.normalize(operations.cwd), pathApi.normalize(cwd));
|
|
67
|
+
return (relative === "" ||
|
|
68
|
+
(relative !== ".." && !relative.startsWith(`..${pathApi.sep}`) && !pathApi.isAbsolute(relative)));
|
|
69
|
+
}
|
|
70
|
+
function extractUserMessageText(content) {
|
|
71
|
+
if (typeof content === "string") {
|
|
72
|
+
return content;
|
|
73
|
+
}
|
|
74
|
+
return content
|
|
75
|
+
.filter((part) => part.type === "text")
|
|
76
|
+
.map((part) => part.text)
|
|
77
|
+
.join("");
|
|
78
|
+
}
|
|
79
|
+
function blockImagesInMessage(message) {
|
|
80
|
+
if (message.role !== "user" && message.role !== "toolResult")
|
|
81
|
+
return message;
|
|
82
|
+
const { content } = message;
|
|
83
|
+
if (!Array.isArray(content) || !content.some((part) => part.type === "image"))
|
|
84
|
+
return message;
|
|
85
|
+
const filteredContent = content
|
|
86
|
+
.map((part) => (part.type === "image" ? { type: "text", text: "Image reading is disabled." } : part))
|
|
87
|
+
.filter((part, index, parts) => !(part.type === "text" &&
|
|
88
|
+
part.text === "Image reading is disabled." &&
|
|
89
|
+
index > 0 &&
|
|
90
|
+
parts[index - 1].type === "text" &&
|
|
91
|
+
parts[index - 1].text === "Image reading is disabled."));
|
|
92
|
+
return { ...message, content: filteredContent };
|
|
93
|
+
}
|
|
94
|
+
function asLspInputs(input) {
|
|
95
|
+
return input === undefined ? [] : Array.isArray(input) ? input : [input];
|
|
96
|
+
}
|
|
97
|
+
function getAttributionHeaders(model, settingsManager, sessionId) {
|
|
98
|
+
if (sessionId &&
|
|
99
|
+
(model.provider === "opencode" || model.provider === "opencode-go" || model.baseUrl.includes("opencode.ai"))) {
|
|
100
|
+
return { "x-opencode-session": sessionId, "x-opencode-client": "grip" };
|
|
101
|
+
}
|
|
102
|
+
if (!isInstallTelemetryEnabled(settingsManager)) {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
if (model.provider === "openrouter" || model.baseUrl.includes("openrouter.ai")) {
|
|
106
|
+
return {
|
|
107
|
+
"HTTP-Referer": "https://pi.dev",
|
|
108
|
+
"X-OpenRouter-Title": "grip",
|
|
109
|
+
"X-OpenRouter-Categories": "cli-agent",
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (model.provider === "cloudflare-workers-ai" ||
|
|
113
|
+
model.provider === "cloudflare-ai-gateway" ||
|
|
114
|
+
model.baseUrl.includes("api.cloudflare.com") ||
|
|
115
|
+
model.baseUrl.includes("gateway.ai.cloudflare.com")) {
|
|
116
|
+
return {
|
|
117
|
+
"User-Agent": "grip-coding-agent",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
function applyExtensionFlagValues(resourceLoader, extensionFlagValues) {
|
|
123
|
+
if (!extensionFlagValues) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
const diagnostics = [];
|
|
127
|
+
const extensionsResult = resourceLoader.getExtensions();
|
|
128
|
+
const registeredFlags = new Map();
|
|
129
|
+
for (const extension of extensionsResult.extensions) {
|
|
130
|
+
for (const [name, flag] of extension.flags) {
|
|
131
|
+
registeredFlags.set(name, { type: flag.type });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const unknownFlags = [];
|
|
135
|
+
for (const [name, value] of extensionFlagValues) {
|
|
136
|
+
const flag = registeredFlags.get(name);
|
|
137
|
+
if (!flag) {
|
|
138
|
+
unknownFlags.push(name);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (flag.type === "boolean") {
|
|
142
|
+
extensionsResult.runtime.flagValues.set(name, true);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (typeof value === "string") {
|
|
146
|
+
extensionsResult.runtime.flagValues.set(name, value);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
diagnostics.push({
|
|
150
|
+
type: "error",
|
|
151
|
+
message: `Extension flag "--${name}" requires a value`,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
if (unknownFlags.length > 0) {
|
|
155
|
+
diagnostics.push({
|
|
156
|
+
type: "error",
|
|
157
|
+
message: `Unknown option${unknownFlags.length === 1 ? "" : "s"}: ${unknownFlags.map((name) => `--${name}`).join(", ")}`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
return diagnostics;
|
|
161
|
+
}
|
|
162
|
+
async function runInteractiveAppMode(runtimeHost, modelFallbackMessage, options) {
|
|
163
|
+
const interactiveMode = new InteractiveMode(runtimeHost, {
|
|
164
|
+
migratedProviders: options.migratedProviders,
|
|
165
|
+
modelFallbackMessage,
|
|
166
|
+
initialMessage: options.initialMessage,
|
|
167
|
+
initialImages: options.initialImages,
|
|
168
|
+
initialMessages: options.initialMessages,
|
|
169
|
+
verbose: options.verbose,
|
|
170
|
+
tuiMode: options.tuiMode,
|
|
171
|
+
});
|
|
172
|
+
if (options.startupBenchmark) {
|
|
173
|
+
await interactiveMode.init();
|
|
174
|
+
time("interactiveMode.init");
|
|
175
|
+
// Give the TUI's stdin handler a brief chance to consume terminal query replies
|
|
176
|
+
// (Kitty keyboard protocol, device attributes, cell size) before restoring the terminal.
|
|
177
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
178
|
+
interactiveMode.stop();
|
|
179
|
+
stopThemeWatcher();
|
|
180
|
+
printTimings();
|
|
181
|
+
if (process.stdout.writableLength > 0) {
|
|
182
|
+
await new Promise((resolve) => process.stdout.once("drain", resolve));
|
|
183
|
+
}
|
|
184
|
+
if (process.stderr.writableLength > 0) {
|
|
185
|
+
await new Promise((resolve) => process.stderr.once("drain", resolve));
|
|
186
|
+
}
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
printTimings();
|
|
190
|
+
await interactiveMode.run();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Application-level composition root for grip's coding agent runtime.
|
|
194
|
+
*
|
|
195
|
+
* GripAgent owns common app services, the session lifecycle backend, and the
|
|
196
|
+
* current active AgentSession. Conversation behavior stays in AgentSession;
|
|
197
|
+
* session lifecycle/discovery stays in SessionManager implementations.
|
|
198
|
+
*/
|
|
199
|
+
export class GripAgent {
|
|
200
|
+
initialCwd;
|
|
201
|
+
agentDir;
|
|
202
|
+
sessionManager;
|
|
203
|
+
authStorage;
|
|
204
|
+
options;
|
|
205
|
+
_mode;
|
|
206
|
+
_session;
|
|
207
|
+
_services;
|
|
208
|
+
_diagnostics = [];
|
|
209
|
+
_baseDiagnostics = [];
|
|
210
|
+
_hookConfigurationDiagnostics = [];
|
|
211
|
+
_hookRuntimeDiagnostics = [];
|
|
212
|
+
_lspDiagnostics = [];
|
|
213
|
+
_modelFallbackMessage;
|
|
214
|
+
rebindSession;
|
|
215
|
+
beforeSessionInvalidate;
|
|
216
|
+
borrowedToolOperations;
|
|
217
|
+
toolOperationsDisposed = false;
|
|
218
|
+
disposePromise;
|
|
219
|
+
subagentCleanupCallbacks = new Set();
|
|
220
|
+
constructor(options, resolved) {
|
|
221
|
+
this.options = options;
|
|
222
|
+
this.borrowedToolOperations = options.toolOperations ? borrowToolOperations(options.toolOperations) : undefined;
|
|
223
|
+
this._mode = options.mode ?? "embedded";
|
|
224
|
+
this.initialCwd = resolved.cwd;
|
|
225
|
+
this.agentDir = resolved.agentDir;
|
|
226
|
+
this.sessionManager = resolved.sessionManager;
|
|
227
|
+
this.authStorage = resolved.authStorage;
|
|
228
|
+
}
|
|
229
|
+
static setupStdio(options) {
|
|
230
|
+
if (options.mode !== "embedded" && options.mode !== "interactive") {
|
|
231
|
+
takeOverStdout();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
static async create(options = {}) {
|
|
235
|
+
const cwd = options.cwd ?? process.cwd();
|
|
236
|
+
const agentDir = options.agentDir ?? getAgentDir();
|
|
237
|
+
const sessionManager = options.sessionManager ?? new LocalSessionManager({ cwd, sessionDir: getDefaultSessionDir(cwd, agentDir) });
|
|
238
|
+
const authStorage = options.authStorage ?? AuthStorage.create(join(agentDir, "auth.json"));
|
|
239
|
+
return new GripAgent(options, { cwd, agentDir, sessionManager, authStorage });
|
|
240
|
+
}
|
|
241
|
+
get mode() {
|
|
242
|
+
return this._mode;
|
|
243
|
+
}
|
|
244
|
+
get cwd() {
|
|
245
|
+
return this._services?.cwd ?? this.initialCwd;
|
|
246
|
+
}
|
|
247
|
+
async readPipedStdin() {
|
|
248
|
+
if (this._mode === "embedded" || this._mode === "rpc" || process.stdin.isTTY) {
|
|
249
|
+
return undefined;
|
|
250
|
+
}
|
|
251
|
+
const stdinContent = await new Promise((resolve) => {
|
|
252
|
+
let data = "";
|
|
253
|
+
process.stdin.setEncoding("utf8");
|
|
254
|
+
process.stdin.on("data", (chunk) => {
|
|
255
|
+
data += chunk;
|
|
256
|
+
});
|
|
257
|
+
process.stdin.on("end", () => {
|
|
258
|
+
resolve(data.trim() || undefined);
|
|
259
|
+
});
|
|
260
|
+
process.stdin.resume();
|
|
261
|
+
});
|
|
262
|
+
if (stdinContent !== undefined && this._mode === "interactive") {
|
|
263
|
+
this._mode = "print";
|
|
264
|
+
}
|
|
265
|
+
return stdinContent;
|
|
266
|
+
}
|
|
267
|
+
async createServices(cwd) {
|
|
268
|
+
const settingsManager = this.options.settingsManager ?? SettingsManager.create(cwd, this.agentDir);
|
|
269
|
+
if (process.env.GRIP_MODEL_CATALOG_URL) {
|
|
270
|
+
await refreshModelCatalog().catch(() => undefined);
|
|
271
|
+
}
|
|
272
|
+
const modelRegistry = this.options.modelRegistry ?? ModelRegistry.create(this.authStorage, join(this.agentDir, "models.json"));
|
|
273
|
+
const resourceLoader = this.options.resourceLoader ??
|
|
274
|
+
new DefaultResourceLoader({
|
|
275
|
+
...(this.options.resourceLoaderOptions ?? {}),
|
|
276
|
+
cwd,
|
|
277
|
+
agentDir: this.agentDir,
|
|
278
|
+
settingsManager,
|
|
279
|
+
toolOperations: this.options.resourceLoaderOptions?.toolOperations
|
|
280
|
+
? borrowToolOperations(this.options.resourceLoaderOptions.toolOperations)
|
|
281
|
+
: this.borrowedToolOperations,
|
|
282
|
+
});
|
|
283
|
+
await resourceLoader.reload();
|
|
284
|
+
const diagnostics = [];
|
|
285
|
+
const extensionsResult = resourceLoader.getExtensions();
|
|
286
|
+
for (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {
|
|
287
|
+
try {
|
|
288
|
+
modelRegistry.registerProvider(name, config);
|
|
289
|
+
}
|
|
290
|
+
catch (error) {
|
|
291
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
292
|
+
diagnostics.push({
|
|
293
|
+
type: "error",
|
|
294
|
+
message: `Extension "${extensionPath}" error: ${message}`,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
extensionsResult.runtime.pendingProviderRegistrations = [];
|
|
299
|
+
diagnostics.push(...applyExtensionFlagValues(resourceLoader, this.options.extensionFlagValues));
|
|
300
|
+
return {
|
|
301
|
+
cwd,
|
|
302
|
+
agentDir: this.agentDir,
|
|
303
|
+
authStorage: this.authStorage,
|
|
304
|
+
settingsManager,
|
|
305
|
+
modelRegistry,
|
|
306
|
+
resourceLoader,
|
|
307
|
+
diagnostics,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
createSubagentRunRegistry() {
|
|
311
|
+
const runs = new Map();
|
|
312
|
+
return {
|
|
313
|
+
list: () => Array.from(runs.values()).sort((a, b) => a.createdAt.localeCompare(b.createdAt)),
|
|
314
|
+
upsert: (run) => runs.set(run.runId, structuredClone(run)),
|
|
315
|
+
get: (runId) => runs.get(runId),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
createSubagentConfigRegistry() {
|
|
319
|
+
const configs = new Map();
|
|
320
|
+
return {
|
|
321
|
+
list: () => Array.from(configs.values()).sort((a, b) => a.createdAt.localeCompare(b.createdAt)),
|
|
322
|
+
upsert: (config) => configs.set(config.name, structuredClone(config)),
|
|
323
|
+
get: (name) => configs.get(name),
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
resolveEmbeddedSubagentRequest(request, services) {
|
|
327
|
+
const resolvedModel = request.model
|
|
328
|
+
? resolveCliModel({ cliModel: request.model, modelRegistry: services.modelRegistry })
|
|
329
|
+
: undefined;
|
|
330
|
+
if (resolvedModel?.error)
|
|
331
|
+
return { failure: { exitCode: 1, stderr: resolvedModel.error } };
|
|
332
|
+
const toolOperations = request.toolOperations;
|
|
333
|
+
if (!toolOperations) {
|
|
334
|
+
return { failure: { exitCode: 1, stderr: "Subagents require explicit workspace tool operations" } };
|
|
335
|
+
}
|
|
336
|
+
const backendInfo = toolOperations.getBackendInfo?.();
|
|
337
|
+
if (backendInfo?.type === "remote" && !backendInfo.configured) {
|
|
338
|
+
return { failure: { exitCode: 1, stderr: "Subagents cannot run with an unconfigured remote backend" } };
|
|
339
|
+
}
|
|
340
|
+
if (!isSubagentCwdConfined(request.cwd, toolOperations, backendInfo)) {
|
|
341
|
+
return {
|
|
342
|
+
failure: {
|
|
343
|
+
exitCode: 1,
|
|
344
|
+
stderr: `Sandboxed subagent cwd must stay within the sandbox workspace root: ${toolOperations.cwd}`,
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
const backendIdentity = JSON.stringify(backendInfo ?? { type: "unknown", cwd: toolOperations.cwd });
|
|
349
|
+
return { context: { resolvedModel, toolOperations, backendInfo, backendIdentity } };
|
|
350
|
+
}
|
|
351
|
+
selectEmbeddedSubagentSkills(request, services) {
|
|
352
|
+
const requestedSkills = request.skills ?? [];
|
|
353
|
+
const loadedSkills = services.resourceLoader.getSkills().skills;
|
|
354
|
+
const skillsByName = new Map();
|
|
355
|
+
for (const skill of loadedSkills) {
|
|
356
|
+
if (!skillsByName.has(skill.name))
|
|
357
|
+
skillsByName.set(skill.name, skill);
|
|
358
|
+
}
|
|
359
|
+
const missingSkills = [];
|
|
360
|
+
const skills = [];
|
|
361
|
+
for (const name of requestedSkills) {
|
|
362
|
+
const skill = skillsByName.get(name);
|
|
363
|
+
if (skill)
|
|
364
|
+
skills.push(skill);
|
|
365
|
+
else
|
|
366
|
+
missingSkills.push(name);
|
|
367
|
+
}
|
|
368
|
+
if (missingSkills.length > 0) {
|
|
369
|
+
return { failure: { exitCode: 1, stderr: `Unknown subagent skill(s): ${missingSkills.join(", ")}` } };
|
|
370
|
+
}
|
|
371
|
+
return { skills };
|
|
372
|
+
}
|
|
373
|
+
async loadEmbeddedSubagentSkillContent(skill, toolOperations, backendInfo) {
|
|
374
|
+
if (skill.content !== undefined)
|
|
375
|
+
return skill.content;
|
|
376
|
+
if (backendInfo?.type === "local")
|
|
377
|
+
return readFileSync(skill.filePath, "utf-8");
|
|
378
|
+
if (getSourceBackend(skill.sourceInfo) === "local") {
|
|
379
|
+
throw new Error("local skill files are unavailable to a sandboxed subagent");
|
|
380
|
+
}
|
|
381
|
+
return (await toolOperations.readFile(skill.filePath)).toString("utf-8");
|
|
382
|
+
}
|
|
383
|
+
async preloadEmbeddedSubagentSkills(skills, context) {
|
|
384
|
+
const blocks = [];
|
|
385
|
+
for (const skill of skills) {
|
|
386
|
+
try {
|
|
387
|
+
const content = await this.loadEmbeddedSubagentSkillContent(skill, context.toolOperations, context.backendInfo);
|
|
388
|
+
blocks.push(`<preloaded-skill name="${skill.name}" location="${skill.filePath}">\nReferences are relative to ${skill.baseDir}.\n\n${stripFrontmatter(content).trim()}\n</preloaded-skill>`);
|
|
389
|
+
}
|
|
390
|
+
catch (error) {
|
|
391
|
+
return {
|
|
392
|
+
failure: {
|
|
393
|
+
exitCode: 1,
|
|
394
|
+
stderr: `Failed to preload subagent skill ${skill.name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
395
|
+
},
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return { blocks };
|
|
400
|
+
}
|
|
401
|
+
async createEmbeddedSubagentChild(request, requestContext, runnerContext, runId) {
|
|
402
|
+
const settingsStorage = new InMemorySettingsStorage();
|
|
403
|
+
settingsStorage.withLock("global", () => JSON.stringify(runnerContext.services.settingsManager.getGlobalSettings()));
|
|
404
|
+
settingsStorage.withLock("project", () => JSON.stringify(runnerContext.services.settingsManager.getProjectSettings()));
|
|
405
|
+
const settingsManager = SettingsManager.fromStorage(settingsStorage);
|
|
406
|
+
const selection = this.selectEmbeddedSubagentSkills(request, runnerContext.services);
|
|
407
|
+
if (selection.failure)
|
|
408
|
+
return selection;
|
|
409
|
+
const preload = await this.preloadEmbeddedSubagentSkills(selection.skills, requestContext);
|
|
410
|
+
if (preload.failure)
|
|
411
|
+
return preload;
|
|
412
|
+
const childExcludedTools = new Set([
|
|
413
|
+
"subagent",
|
|
414
|
+
"subagent_runs",
|
|
415
|
+
"create_subagent",
|
|
416
|
+
...runnerContext.excludedTools,
|
|
417
|
+
]);
|
|
418
|
+
const requestedTools = request.tools ?? getDefaultActiveToolNames();
|
|
419
|
+
const skillTools = selection.skills.flatMap((skill) => skill.tools ?? []);
|
|
420
|
+
const tools = Array.from(new Set([...requestedTools, ...skillTools])).filter((name) => !childExcludedTools.has(name));
|
|
421
|
+
const child = await GripAgent.create({
|
|
422
|
+
mode: "embedded",
|
|
423
|
+
cwd: request.cwd,
|
|
424
|
+
agentDir: runnerContext.services.agentDir,
|
|
425
|
+
sessionManager: new InMemorySessionManager(request.cwd),
|
|
426
|
+
authStorage: runnerContext.services.authStorage,
|
|
427
|
+
modelRegistry: runnerContext.services.modelRegistry,
|
|
428
|
+
settingsManager,
|
|
429
|
+
model: requestContext.resolvedModel?.model,
|
|
430
|
+
thinkingLevel: requestContext.resolvedModel?.thinkingLevel,
|
|
431
|
+
tools,
|
|
432
|
+
excludedTools: Array.from(childExcludedTools),
|
|
433
|
+
toolOperations: requestContext.toolOperations,
|
|
434
|
+
resourceLoaderOptions: {
|
|
435
|
+
toolOperations: requestContext.toolOperations,
|
|
436
|
+
noExtensions: true,
|
|
437
|
+
noSkills: true,
|
|
438
|
+
noRules: true,
|
|
439
|
+
noPromptTemplates: true,
|
|
440
|
+
noThemes: true,
|
|
441
|
+
noContextFiles: true,
|
|
442
|
+
systemPrompt: "",
|
|
443
|
+
appendSystemPrompt: [],
|
|
444
|
+
systemPromptOverride: () => undefined,
|
|
445
|
+
appendSystemPromptOverride: () => [request.systemPrompt, ...preload.blocks],
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
const session = await child.createAgentSession();
|
|
449
|
+
const now = new Date().toISOString();
|
|
450
|
+
const run = {
|
|
451
|
+
runId,
|
|
452
|
+
sessionReference: session.sessionReference,
|
|
453
|
+
status: "running",
|
|
454
|
+
agent: request.agent,
|
|
455
|
+
task: request.task,
|
|
456
|
+
cwd: request.cwd,
|
|
457
|
+
model: request.model,
|
|
458
|
+
createdAt: now,
|
|
459
|
+
updatedAt: now,
|
|
460
|
+
};
|
|
461
|
+
const childState = {
|
|
462
|
+
child,
|
|
463
|
+
session,
|
|
464
|
+
run,
|
|
465
|
+
toolOperations: requestContext.toolOperations,
|
|
466
|
+
backendIdentity: requestContext.backendIdentity,
|
|
467
|
+
};
|
|
468
|
+
runnerContext.runtime.children.set(runId, childState);
|
|
469
|
+
runnerContext.registry.upsert(run);
|
|
470
|
+
return { childState };
|
|
471
|
+
}
|
|
472
|
+
async prepareEmbeddedSubagentChild(request, requestContext, runnerContext) {
|
|
473
|
+
const continuedRunId = request.continueSession;
|
|
474
|
+
const childState = continuedRunId ? runnerContext.runtime.children.get(continuedRunId) : undefined;
|
|
475
|
+
if (request.continueSession && !childState) {
|
|
476
|
+
return { failure: { exitCode: 1, stderr: `Unknown subagent run id: ${request.continueSession}` } };
|
|
477
|
+
}
|
|
478
|
+
if (childState &&
|
|
479
|
+
(childState.toolOperations !== requestContext.toolOperations ||
|
|
480
|
+
childState.backendIdentity !== requestContext.backendIdentity)) {
|
|
481
|
+
await childState.child.dispose();
|
|
482
|
+
runnerContext.runtime.children.delete(childState.run.runId);
|
|
483
|
+
childState.run = { ...childState.run, status: "failed", updatedAt: new Date().toISOString() };
|
|
484
|
+
runnerContext.registry.upsert(childState.run);
|
|
485
|
+
return {
|
|
486
|
+
failure: {
|
|
487
|
+
exitCode: 1,
|
|
488
|
+
stderr: "The parent workspace backend changed; start a new subagent instead of continuing this run",
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
if (!childState) {
|
|
493
|
+
const runId = `subagent:${runnerContext.runtime.nextRunNumber++}`;
|
|
494
|
+
const creation = await this.createEmbeddedSubagentChild(request, requestContext, runnerContext, runId);
|
|
495
|
+
if (creation.failure)
|
|
496
|
+
return creation;
|
|
497
|
+
return { childState: creation.childState, runId };
|
|
498
|
+
}
|
|
499
|
+
childState.run = {
|
|
500
|
+
...childState.run,
|
|
501
|
+
status: "running",
|
|
502
|
+
task: request.task,
|
|
503
|
+
updatedAt: new Date().toISOString(),
|
|
504
|
+
};
|
|
505
|
+
runnerContext.registry.upsert(childState.run);
|
|
506
|
+
return { childState, runId: childState.run.runId };
|
|
507
|
+
}
|
|
508
|
+
subscribeToEmbeddedSubagentRun(childState, request, output, registry) {
|
|
509
|
+
return childState.session.subscribe((event) => {
|
|
510
|
+
if (event.type !== "message_end")
|
|
511
|
+
return;
|
|
512
|
+
if (event.message.role === "assistant" || event.message.role === "toolResult") {
|
|
513
|
+
request.onMessage(event.message);
|
|
514
|
+
}
|
|
515
|
+
if (event.message.role !== "assistant")
|
|
516
|
+
return;
|
|
517
|
+
output.lastOutput =
|
|
518
|
+
event.message.content
|
|
519
|
+
.filter((part) => part.type === "text")
|
|
520
|
+
.map((part) => part.text)
|
|
521
|
+
.join("\n") || output.lastOutput;
|
|
522
|
+
childState.run = {
|
|
523
|
+
...childState.run,
|
|
524
|
+
lastOutput: output.lastOutput,
|
|
525
|
+
updatedAt: new Date().toISOString(),
|
|
526
|
+
};
|
|
527
|
+
registry.upsert(childState.run);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
async executeEmbeddedSubagentRun(request, preparation, registry) {
|
|
531
|
+
const { childState, runId } = preparation;
|
|
532
|
+
const session = childState.session;
|
|
533
|
+
const output = { lastOutput: childState.run.lastOutput };
|
|
534
|
+
let unsubscribe;
|
|
535
|
+
const abort = () => {
|
|
536
|
+
void session.abort();
|
|
537
|
+
};
|
|
538
|
+
try {
|
|
539
|
+
unsubscribe = this.subscribeToEmbeddedSubagentRun(childState, request, output, registry);
|
|
540
|
+
if (request.signal?.aborted) {
|
|
541
|
+
return {
|
|
542
|
+
exitCode: 1,
|
|
543
|
+
stderr: "Subagent was aborted",
|
|
544
|
+
runId,
|
|
545
|
+
sessionReference: session.sessionReference,
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
request.signal?.addEventListener("abort", abort, { once: true });
|
|
549
|
+
await session.prompt(request.prompt);
|
|
550
|
+
const status = request.signal?.aborted ? "failed" : "completed";
|
|
551
|
+
childState.run = {
|
|
552
|
+
...childState.run,
|
|
553
|
+
status,
|
|
554
|
+
lastOutput: output.lastOutput,
|
|
555
|
+
updatedAt: new Date().toISOString(),
|
|
556
|
+
};
|
|
557
|
+
registry.upsert(childState.run);
|
|
558
|
+
return {
|
|
559
|
+
exitCode: request.signal?.aborted ? 1 : 0,
|
|
560
|
+
stderr: "",
|
|
561
|
+
runId,
|
|
562
|
+
sessionReference: session.sessionReference,
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
childState.run = {
|
|
567
|
+
...childState.run,
|
|
568
|
+
status: "failed",
|
|
569
|
+
updatedAt: new Date().toISOString(),
|
|
570
|
+
};
|
|
571
|
+
registry.upsert(childState.run);
|
|
572
|
+
return {
|
|
573
|
+
exitCode: 1,
|
|
574
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
575
|
+
runId,
|
|
576
|
+
sessionReference: session.sessionReference,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
finally {
|
|
580
|
+
request.signal?.removeEventListener("abort", abort);
|
|
581
|
+
unsubscribe?.();
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
async runEmbeddedSubagent(request, runnerContext) {
|
|
585
|
+
const resolution = this.resolveEmbeddedSubagentRequest(request, runnerContext.services);
|
|
586
|
+
if (resolution.failure)
|
|
587
|
+
return resolution.failure;
|
|
588
|
+
const preparation = await this.prepareEmbeddedSubagentChild(request, resolution.context, runnerContext);
|
|
589
|
+
if (preparation.failure)
|
|
590
|
+
return preparation.failure;
|
|
591
|
+
return this.executeEmbeddedSubagentRun(request, preparation, runnerContext.registry);
|
|
592
|
+
}
|
|
593
|
+
createEmbeddedSubagentRunner(services, excludedTools, registry) {
|
|
594
|
+
const runtime = { nextRunNumber: 1, children: new Map() };
|
|
595
|
+
const runnerContext = { services, excludedTools, registry, runtime };
|
|
596
|
+
const cleanup = async () => {
|
|
597
|
+
for (const { child } of runtime.children.values())
|
|
598
|
+
await child.dispose();
|
|
599
|
+
runtime.children.clear();
|
|
600
|
+
};
|
|
601
|
+
this.subagentCleanupCallbacks.add(cleanup);
|
|
602
|
+
return (request) => this.runEmbeddedSubagent(request, runnerContext);
|
|
603
|
+
}
|
|
604
|
+
shouldDiscoverProjectHooks(resolvedOptions) {
|
|
605
|
+
const hookOperations = resolvedOptions.toolOperations ?? this.borrowedToolOperations;
|
|
606
|
+
const customHookOperationsSupplied = resolvedOptions.toolOperations !== undefined || this.borrowedToolOperations !== undefined;
|
|
607
|
+
const hookBackend = hookOperations?.getBackendInfo?.();
|
|
608
|
+
const trustProjectHooks = resolvedOptions.trustProjectHooks ?? this.options.trustProjectHooks;
|
|
609
|
+
return trustProjectHooks === true && (!customHookOperationsSupplied || hookBackend?.type === "local");
|
|
610
|
+
}
|
|
611
|
+
resolveHookDiscovery(services, resolvedOptions, diagnostics, discoverProjectHooks) {
|
|
612
|
+
const trustedIdentity = resolvedOptions.trustedProjectHooksIdentity ?? this.options.trustedProjectHooksIdentity;
|
|
613
|
+
let cwd = services.cwd;
|
|
614
|
+
if (!discoverProjectHooks)
|
|
615
|
+
return { cwd, discoverProjectHooks };
|
|
616
|
+
try {
|
|
617
|
+
cwd = canonicalProjectHookCwd(services.cwd);
|
|
618
|
+
if (trustedIdentity && canonicalProjectHookIdentity(cwd) !== trustedIdentity) {
|
|
619
|
+
discoverProjectHooks = false;
|
|
620
|
+
diagnostics.push({
|
|
621
|
+
type: "warning",
|
|
622
|
+
message: "Project hook trust identity changed before hook loading; project hooks were not loaded",
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
catch (error) {
|
|
627
|
+
discoverProjectHooks = false;
|
|
628
|
+
diagnostics.push({
|
|
629
|
+
type: "warning",
|
|
630
|
+
message: `Unable to canonicalize project hooks path; project hooks were not loaded: ${error instanceof Error ? error.message : String(error)}`,
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
return { cwd, discoverProjectHooks };
|
|
634
|
+
}
|
|
635
|
+
async loadSessionHooks(services, resolvedOptions, discoverProjectHooks) {
|
|
636
|
+
const diagnostics = [];
|
|
637
|
+
const hookOptions = this.options.hooks;
|
|
638
|
+
const discovery = this.resolveHookDiscovery(services, resolvedOptions, diagnostics, discoverProjectHooks);
|
|
639
|
+
if (hookOptions === false || hookOptions?.enabled === false) {
|
|
640
|
+
return { loadedHooks: undefined, diagnostics };
|
|
641
|
+
}
|
|
642
|
+
const loadedHooks = hookOptions?.snapshot
|
|
643
|
+
? freezeLoadedHooks(hookOptions.snapshot)
|
|
644
|
+
: await loadHooks({
|
|
645
|
+
cwd: discovery.cwd,
|
|
646
|
+
home: hookOptions?.home,
|
|
647
|
+
agentDir: services.agentDir,
|
|
648
|
+
sources: discovery.discoverProjectHooks ? ["user", "project", "local"] : ["user"],
|
|
649
|
+
});
|
|
650
|
+
diagnostics.push(...loadedHooks.diagnostics.map(formatHookDiagnostic));
|
|
651
|
+
return { loadedHooks, diagnostics };
|
|
652
|
+
}
|
|
653
|
+
mergeSessionOptions(resolvedOptions) {
|
|
654
|
+
return {
|
|
655
|
+
model: resolvedOptions.model ?? this.options.model,
|
|
656
|
+
thinkingLevel: resolvedOptions.thinkingLevel ?? this.options.thinkingLevel,
|
|
657
|
+
scopedModels: resolvedOptions.scopedModels ?? this.options.scopedModels,
|
|
658
|
+
tools: resolvedOptions.tools ?? this.options.tools,
|
|
659
|
+
enableLspTools: resolvedOptions.enableLspTools ?? this.options.enableLspTools,
|
|
660
|
+
excludedTools: resolvedOptions.excludedTools ?? this.options.excludedTools,
|
|
661
|
+
noTools: resolvedOptions.noTools ?? this.options.noTools,
|
|
662
|
+
customTools: resolvedOptions.customTools ?? this.options.customTools,
|
|
663
|
+
toolOperations: resolvedOptions.toolOperations
|
|
664
|
+
? borrowToolOperations(resolvedOptions.toolOperations)
|
|
665
|
+
: this.borrowedToolOperations,
|
|
666
|
+
trustProjectAgents: resolvedOptions.trustProjectAgents ?? this.options.trustProjectAgents,
|
|
667
|
+
trustProjectHooks: resolvedOptions.trustProjectHooks ?? this.options.trustProjectHooks,
|
|
668
|
+
trustProjectLspTransports: resolvedOptions.trustProjectLspTransports ?? this.options.trustProjectLspTransports,
|
|
669
|
+
lspConnectionFactories: resolvedOptions.lspConnectionFactories ?? this.options.lspConnectionFactories,
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
resolveSessionLspConfiguration(services, sessionOptions, inputs) {
|
|
673
|
+
if (sessionOptions.toolOperations?.getBackendInfo?.().type === "remote") {
|
|
674
|
+
return Promise.resolve({ configuration: { enabled: false, servers: [] }, diagnostics: [] });
|
|
675
|
+
}
|
|
676
|
+
return loadLspConfiguration({
|
|
677
|
+
settingsManager: services.settingsManager,
|
|
678
|
+
cwd: services.cwd,
|
|
679
|
+
agentDir: services.agentDir,
|
|
680
|
+
inputs,
|
|
681
|
+
trustProjectLspTransports: sessionOptions.trustProjectLspTransports,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
async resolveSessionModel(services, sessionOptions, existingSession) {
|
|
685
|
+
let model = sessionOptions.model;
|
|
686
|
+
let fallbackMessage;
|
|
687
|
+
if (model)
|
|
688
|
+
model = services.modelRegistry.find(model.provider, model.id) ?? model;
|
|
689
|
+
if (!model && existingSession.messages.length > 0 && existingSession.model) {
|
|
690
|
+
const restoredModel = services.modelRegistry.find(existingSession.model.provider, existingSession.model.modelId);
|
|
691
|
+
if (restoredModel && services.modelRegistry.hasConfiguredAuth(restoredModel))
|
|
692
|
+
model = restoredModel;
|
|
693
|
+
if (!model)
|
|
694
|
+
fallbackMessage = `Could not restore model ${existingSession.model.provider}/${existingSession.model.modelId}`;
|
|
695
|
+
}
|
|
696
|
+
if (model)
|
|
697
|
+
return { model, fallbackMessage };
|
|
698
|
+
const result = await findInitialModel({
|
|
699
|
+
scopedModels: [],
|
|
700
|
+
isContinuing: existingSession.messages.length > 0,
|
|
701
|
+
defaultProvider: services.settingsManager.getDefaultProvider(),
|
|
702
|
+
defaultModelId: services.settingsManager.getDefaultModel(),
|
|
703
|
+
defaultThinkingLevel: services.settingsManager.getDefaultThinkingLevel(),
|
|
704
|
+
modelRegistry: services.modelRegistry,
|
|
705
|
+
});
|
|
706
|
+
model = result.model;
|
|
707
|
+
if (!model)
|
|
708
|
+
fallbackMessage = formatNoModelsAvailableMessage();
|
|
709
|
+
else if (fallbackMessage)
|
|
710
|
+
fallbackMessage += `. Using ${model.provider}/${model.id}`;
|
|
711
|
+
return { model, fallbackMessage };
|
|
712
|
+
}
|
|
713
|
+
resolveSessionThinkingLevel(services, activeSession, existingSession, configuredLevel, model) {
|
|
714
|
+
const hasExistingSession = existingSession.messages.length > 0;
|
|
715
|
+
const hasThinkingEntry = activeSession.getBranch().some((entry) => entry.type === "thinking_level_change");
|
|
716
|
+
let thinkingLevel = configuredLevel;
|
|
717
|
+
if (thinkingLevel === undefined && hasExistingSession) {
|
|
718
|
+
thinkingLevel = hasThinkingEntry
|
|
719
|
+
? existingSession.thinkingLevel
|
|
720
|
+
: (services.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL);
|
|
721
|
+
}
|
|
722
|
+
thinkingLevel ??= services.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;
|
|
723
|
+
return model ? clampThinkingLevel(model, thinkingLevel) : "off";
|
|
724
|
+
}
|
|
725
|
+
createCoreAgent(services, activeSession, model, thinkingLevel, extensionRunnerRef) {
|
|
726
|
+
return new Agent({
|
|
727
|
+
initialState: { systemPrompt: "", model, thinkingLevel, tools: [] },
|
|
728
|
+
convertToLlm: (messages) => {
|
|
729
|
+
const converted = convertToLlm(messages);
|
|
730
|
+
return services.settingsManager.getBlockImages() ? converted.map(blockImagesInMessage) : converted;
|
|
731
|
+
},
|
|
732
|
+
streamFn: async (streamModel, context, options) => {
|
|
733
|
+
const auth = await services.modelRegistry.getApiKeyAndHeaders(streamModel);
|
|
734
|
+
if (!auth.ok)
|
|
735
|
+
throw new Error(auth.error);
|
|
736
|
+
const providerRetrySettings = services.settingsManager.getProviderRetrySettings();
|
|
737
|
+
const timeoutMs = options?.timeoutMs ??
|
|
738
|
+
providerRetrySettings.timeoutMs ??
|
|
739
|
+
(streamModel.api === "openai-codex-responses"
|
|
740
|
+
? services.settingsManager.getHttpIdleTimeoutMs()
|
|
741
|
+
: undefined);
|
|
742
|
+
const websocketConnectTimeoutMs = options?.websocketConnectTimeoutMs ?? services.settingsManager.getWebSocketConnectTimeoutMs();
|
|
743
|
+
const attributionHeaders = getAttributionHeaders(streamModel, services.settingsManager, options?.sessionId);
|
|
744
|
+
let headers = attributionHeaders || auth.headers || options?.headers
|
|
745
|
+
? { ...attributionHeaders, ...auth.headers, ...options?.headers }
|
|
746
|
+
: undefined;
|
|
747
|
+
const runner = extensionRunnerRef.current;
|
|
748
|
+
if (runner?.hasHandlers("before_provider_headers")) {
|
|
749
|
+
headers = await runner.emitBeforeProviderHeaders(headers ?? {});
|
|
750
|
+
}
|
|
751
|
+
return streamSimple(streamModel, context, {
|
|
752
|
+
...options,
|
|
753
|
+
apiKey: auth.apiKey,
|
|
754
|
+
timeoutMs,
|
|
755
|
+
websocketConnectTimeoutMs,
|
|
756
|
+
maxRetries: options?.maxRetries ?? providerRetrySettings.maxRetries,
|
|
757
|
+
maxRetryDelayMs: options?.maxRetryDelayMs ?? providerRetrySettings.maxRetryDelayMs,
|
|
758
|
+
headers,
|
|
759
|
+
});
|
|
760
|
+
},
|
|
761
|
+
onPayload: async (payload) => {
|
|
762
|
+
const runner = extensionRunnerRef.current;
|
|
763
|
+
return runner?.hasHandlers("before_provider_request") ? runner.emitBeforeProviderRequest(payload) : payload;
|
|
764
|
+
},
|
|
765
|
+
onResponse: async (response) => {
|
|
766
|
+
const runner = extensionRunnerRef.current;
|
|
767
|
+
if (!runner?.hasHandlers("after_provider_response"))
|
|
768
|
+
return;
|
|
769
|
+
await runner.emit({ type: "after_provider_response", status: response.status, headers: response.headers });
|
|
770
|
+
},
|
|
771
|
+
sessionId: activeSession.getSessionId(),
|
|
772
|
+
transformContext: async (messages) => {
|
|
773
|
+
const runner = extensionRunnerRef.current;
|
|
774
|
+
return runner ? runner.emitContext(messages) : messages;
|
|
775
|
+
},
|
|
776
|
+
steeringMode: services.settingsManager.getSteeringMode(),
|
|
777
|
+
followUpMode: services.settingsManager.getFollowUpMode(),
|
|
778
|
+
transport: services.settingsManager.getTransport(),
|
|
779
|
+
thinkingBudgets: services.settingsManager.getThinkingBudgets(),
|
|
780
|
+
maxRetryDelayMs: services.settingsManager.getProviderRetrySettings().maxRetryDelayMs,
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async buildAgentSession(activeSession, sessionStartEvent) {
|
|
784
|
+
const services = await this.createServices(activeSession.getCwd());
|
|
785
|
+
const diagnostics = [
|
|
786
|
+
...services.diagnostics,
|
|
787
|
+
...services.resourceLoader.getExtensions().errors.map(({ path, error }) => ({
|
|
788
|
+
type: "error",
|
|
789
|
+
message: `Failed to load extension "${path}": ${error}`,
|
|
790
|
+
})),
|
|
791
|
+
];
|
|
792
|
+
const resolvedOptions = (await this.options.resolveSessionOptions?.({ services, session: activeSession, sessionStartEvent })) ?? {};
|
|
793
|
+
diagnostics.push(...(resolvedOptions.diagnostics ?? []));
|
|
794
|
+
const discoverProjectHooks = this.shouldDiscoverProjectHooks(resolvedOptions);
|
|
795
|
+
const hookResolution = await this.loadSessionHooks(services, resolvedOptions, discoverProjectHooks);
|
|
796
|
+
const sessionOptions = this.mergeSessionOptions(resolvedOptions);
|
|
797
|
+
const lspInputs = [...asLspInputs(this.options.lsp), ...asLspInputs(resolvedOptions.lsp)];
|
|
798
|
+
const resolveSessionLspConfiguration = () => this.resolveSessionLspConfiguration(services, sessionOptions, lspInputs);
|
|
799
|
+
const lspResult = await resolveSessionLspConfiguration();
|
|
800
|
+
const lspDiagnostics = formatLspConfigurationDiagnostics(lspResult.diagnostics);
|
|
801
|
+
const baseDiagnostics = [...diagnostics];
|
|
802
|
+
const existingSession = activeSession.buildSessionContext();
|
|
803
|
+
const hasExistingSession = existingSession.messages.length > 0;
|
|
804
|
+
const hasThinkingEntry = activeSession.getBranch().some((entry) => entry.type === "thinking_level_change");
|
|
805
|
+
const modelResolution = await this.resolveSessionModel(services, sessionOptions, existingSession);
|
|
806
|
+
const { model } = modelResolution;
|
|
807
|
+
const thinkingLevel = this.resolveSessionThinkingLevel(services, activeSession, existingSession, sessionOptions.thinkingLevel, model);
|
|
808
|
+
const defaultActiveToolNames = getDefaultActiveToolNames(services.settingsManager.getEnableSubagents(), sessionOptions.enableLspTools ?? services.settingsManager.getEnableLspTools());
|
|
809
|
+
const allowedToolNames = sessionOptions.tools ?? (sessionOptions.noTools === "all" ? [] : undefined);
|
|
810
|
+
const initialActiveToolNames = [
|
|
811
|
+
...(sessionOptions.tools ?? (sessionOptions.noTools ? [] : defaultActiveToolNames)),
|
|
812
|
+
];
|
|
813
|
+
const extensionRunnerRef = {};
|
|
814
|
+
const agent = this.createCoreAgent(services, activeSession, model, thinkingLevel, extensionRunnerRef);
|
|
815
|
+
if (hasExistingSession) {
|
|
816
|
+
agent.state.messages = existingSession.messages;
|
|
817
|
+
if (!hasThinkingEntry)
|
|
818
|
+
activeSession.appendThinkingLevelChange(thinkingLevel);
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
if (model)
|
|
822
|
+
activeSession.appendModelChange(model.provider, model.id);
|
|
823
|
+
activeSession.appendThinkingLevelChange(thinkingLevel);
|
|
824
|
+
}
|
|
825
|
+
const subagentRunRegistry = this.createSubagentRunRegistry();
|
|
826
|
+
const subagentConfigRegistry = this.createSubagentConfigRegistry();
|
|
827
|
+
const hookOptions = this.options.hooks;
|
|
828
|
+
return {
|
|
829
|
+
session: new AgentSession({
|
|
830
|
+
agent,
|
|
831
|
+
session: activeSession,
|
|
832
|
+
settingsManager: services.settingsManager,
|
|
833
|
+
cwd: services.cwd,
|
|
834
|
+
scopedModels: sessionOptions.scopedModels,
|
|
835
|
+
resourceLoader: services.resourceLoader,
|
|
836
|
+
customTools: sessionOptions.customTools,
|
|
837
|
+
toolOperations: sessionOptions.toolOperations,
|
|
838
|
+
modelRegistry: services.modelRegistry,
|
|
839
|
+
initialActiveToolNames,
|
|
840
|
+
enableLspTools: sessionOptions.enableLspTools,
|
|
841
|
+
excludedToolNames: sessionOptions.excludedTools,
|
|
842
|
+
allowedToolNames,
|
|
843
|
+
subagentRunner: this.createEmbeddedSubagentRunner(services, sessionOptions.excludedTools ?? [], subagentRunRegistry),
|
|
844
|
+
subagentRunRegistry,
|
|
845
|
+
subagentConfigRegistry,
|
|
846
|
+
trustProjectAgents: sessionOptions.trustProjectAgents,
|
|
847
|
+
lspConfiguration: lspResult.configuration,
|
|
848
|
+
lspConnectionFactories: sessionOptions.lspConnectionFactories,
|
|
849
|
+
resolveLspConfiguration: resolveSessionLspConfiguration,
|
|
850
|
+
onLspConfigurationDiagnostics: (nextDiagnostics) => {
|
|
851
|
+
this.setLspConfigurationDiagnostics(nextDiagnostics);
|
|
852
|
+
},
|
|
853
|
+
extensionRunnerRef,
|
|
854
|
+
sessionStartEvent,
|
|
855
|
+
loadedHooks: hookResolution.loadedHooks,
|
|
856
|
+
resolveHooks: async () => {
|
|
857
|
+
const nextResolution = await this.loadSessionHooks(services, resolvedOptions, discoverProjectHooks);
|
|
858
|
+
this.setHookConfigurationDiagnostics(nextResolution.diagnostics);
|
|
859
|
+
return nextResolution.loadedHooks;
|
|
860
|
+
},
|
|
861
|
+
hookRunOptions: hookOptions
|
|
862
|
+
? {
|
|
863
|
+
allowedHttpHookUrls: hookOptions.allowedHttpHookUrls,
|
|
864
|
+
httpHookAllowedEnvVars: hookOptions.httpHookAllowedEnvVars,
|
|
865
|
+
}
|
|
866
|
+
: undefined,
|
|
867
|
+
onHookDiagnostic: (diagnostic) => this.addHookDiagnostic(diagnostic),
|
|
868
|
+
}),
|
|
869
|
+
services,
|
|
870
|
+
baseDiagnostics,
|
|
871
|
+
hookDiagnostics: hookResolution.diagnostics,
|
|
872
|
+
lspDiagnostics,
|
|
873
|
+
modelFallbackMessage: modelResolution.fallbackMessage,
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
apply(result) {
|
|
877
|
+
this._session = result.session;
|
|
878
|
+
this._services = result.services;
|
|
879
|
+
this._baseDiagnostics = result.baseDiagnostics;
|
|
880
|
+
this._hookConfigurationDiagnostics = result.hookDiagnostics;
|
|
881
|
+
this._hookRuntimeDiagnostics = [];
|
|
882
|
+
this._lspDiagnostics = result.lspDiagnostics;
|
|
883
|
+
this.refreshDiagnostics();
|
|
884
|
+
this._modelFallbackMessage = result.modelFallbackMessage;
|
|
885
|
+
}
|
|
886
|
+
refreshDiagnostics() {
|
|
887
|
+
this._diagnostics = [
|
|
888
|
+
...this._baseDiagnostics,
|
|
889
|
+
...this._hookConfigurationDiagnostics,
|
|
890
|
+
...this._hookRuntimeDiagnostics,
|
|
891
|
+
...this._lspDiagnostics,
|
|
892
|
+
];
|
|
893
|
+
}
|
|
894
|
+
setLspConfigurationDiagnostics(diagnostics) {
|
|
895
|
+
this._lspDiagnostics = formatLspConfigurationDiagnostics(diagnostics);
|
|
896
|
+
this.refreshDiagnostics();
|
|
897
|
+
}
|
|
898
|
+
setHookConfigurationDiagnostics(diagnostics) {
|
|
899
|
+
this._hookConfigurationDiagnostics = [...diagnostics];
|
|
900
|
+
this.refreshDiagnostics();
|
|
901
|
+
}
|
|
902
|
+
addHookDiagnostic(diagnostic) {
|
|
903
|
+
this._hookRuntimeDiagnostics.push(formatHookDiagnostic(diagnostic));
|
|
904
|
+
this.refreshDiagnostics();
|
|
905
|
+
}
|
|
906
|
+
shouldValidateSessionCwdOnHost() {
|
|
907
|
+
const backendInfo = this.borrowedToolOperations?.getBackendInfo?.();
|
|
908
|
+
return backendInfo === undefined || backendInfo.type === "local";
|
|
909
|
+
}
|
|
910
|
+
async createAgentSession(options = {}) {
|
|
911
|
+
const initialSession = options.session ?? (await this.sessionManager.create());
|
|
912
|
+
if (this.shouldValidateSessionCwdOnHost()) {
|
|
913
|
+
assertSessionCwdExists(initialSession, initialSession.getCwd());
|
|
914
|
+
}
|
|
915
|
+
this.apply(await this.buildAgentSession(initialSession, options.sessionStartEvent));
|
|
916
|
+
return this.session;
|
|
917
|
+
}
|
|
918
|
+
get runtime() {
|
|
919
|
+
if (!this._session) {
|
|
920
|
+
throw new Error("GripAgent session has not been created. Call createAgentSession() first.");
|
|
921
|
+
}
|
|
922
|
+
return this;
|
|
923
|
+
}
|
|
924
|
+
get services() {
|
|
925
|
+
if (!this._services) {
|
|
926
|
+
throw new Error("GripAgent services have not been created. Call createAgentSession() first.");
|
|
927
|
+
}
|
|
928
|
+
return this._services;
|
|
929
|
+
}
|
|
930
|
+
get session() {
|
|
931
|
+
if (!this._session) {
|
|
932
|
+
throw new Error("GripAgent session has not been created. Call createAgentSession() first.");
|
|
933
|
+
}
|
|
934
|
+
return this._session;
|
|
935
|
+
}
|
|
936
|
+
get modelFallbackMessage() {
|
|
937
|
+
return this._modelFallbackMessage;
|
|
938
|
+
}
|
|
939
|
+
get settingsManager() {
|
|
940
|
+
return this.services.settingsManager;
|
|
941
|
+
}
|
|
942
|
+
get modelRegistry() {
|
|
943
|
+
return this.services.modelRegistry;
|
|
944
|
+
}
|
|
945
|
+
get resourceLoader() {
|
|
946
|
+
return this.services.resourceLoader;
|
|
947
|
+
}
|
|
948
|
+
get diagnostics() {
|
|
949
|
+
return this._diagnostics;
|
|
950
|
+
}
|
|
951
|
+
get currentCwd() {
|
|
952
|
+
return this.services.cwd;
|
|
953
|
+
}
|
|
954
|
+
setRebindSession(rebindSession) {
|
|
955
|
+
this.rebindSession = rebindSession;
|
|
956
|
+
}
|
|
957
|
+
setBeforeSessionInvalidate(beforeSessionInvalidate) {
|
|
958
|
+
this.beforeSessionInvalidate = beforeSessionInvalidate;
|
|
959
|
+
}
|
|
960
|
+
async emitBeforeSwitch(reason, targetSessionReference) {
|
|
961
|
+
const runner = this.session.extensionRunner;
|
|
962
|
+
if (!runner.hasHandlers("session_before_switch")) {
|
|
963
|
+
return { cancelled: false };
|
|
964
|
+
}
|
|
965
|
+
const result = await runner.emit({
|
|
966
|
+
type: "session_before_switch",
|
|
967
|
+
reason,
|
|
968
|
+
targetSessionReference,
|
|
969
|
+
targetSessionFile: targetSessionReference,
|
|
970
|
+
});
|
|
971
|
+
return { cancelled: result?.cancel === true };
|
|
972
|
+
}
|
|
973
|
+
async emitBeforeFork(entryId, options) {
|
|
974
|
+
const runner = this.session.extensionRunner;
|
|
975
|
+
if (!runner.hasHandlers("session_before_fork")) {
|
|
976
|
+
return { cancelled: false };
|
|
977
|
+
}
|
|
978
|
+
const result = await runner.emit({
|
|
979
|
+
type: "session_before_fork",
|
|
980
|
+
entryId,
|
|
981
|
+
...options,
|
|
982
|
+
});
|
|
983
|
+
return { cancelled: result?.cancel === true };
|
|
984
|
+
}
|
|
985
|
+
async flushSession(session) {
|
|
986
|
+
const flushPendingSync = session.session.flushPendingSync;
|
|
987
|
+
if (flushPendingSync) {
|
|
988
|
+
await flushPendingSync.call(session.session);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
async replaceCurrentSession(result, reason, targetSessionReference, withSession) {
|
|
992
|
+
const previousSession = this.session;
|
|
993
|
+
try {
|
|
994
|
+
await previousSession.emitHookSessionEnd(reason === "new" ? "clear" : reason === "resume" ? "resume" : "other");
|
|
995
|
+
await emitSessionShutdownEvent(previousSession.extensionRunner, {
|
|
996
|
+
type: "session_shutdown",
|
|
997
|
+
reason,
|
|
998
|
+
targetSessionReference,
|
|
999
|
+
targetSessionFile: targetSessionReference,
|
|
1000
|
+
});
|
|
1001
|
+
await this.flushSession(previousSession);
|
|
1002
|
+
this.beforeSessionInvalidate?.();
|
|
1003
|
+
}
|
|
1004
|
+
catch (error) {
|
|
1005
|
+
await result.session.dispose();
|
|
1006
|
+
throw error;
|
|
1007
|
+
}
|
|
1008
|
+
await previousSession.dispose();
|
|
1009
|
+
this.apply(result);
|
|
1010
|
+
await this.finishSessionReplacement(withSession);
|
|
1011
|
+
}
|
|
1012
|
+
async finishSessionReplacement(withSession) {
|
|
1013
|
+
if (this.rebindSession) {
|
|
1014
|
+
await this.rebindSession(this.session);
|
|
1015
|
+
}
|
|
1016
|
+
if (withSession) {
|
|
1017
|
+
await withSession(this.session.createReplacedSessionContext());
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
async switchSession(sessionPath, options) {
|
|
1021
|
+
const beforeResult = await this.emitBeforeSwitch("resume", sessionPath);
|
|
1022
|
+
if (beforeResult.cancelled) {
|
|
1023
|
+
return beforeResult;
|
|
1024
|
+
}
|
|
1025
|
+
const previousSessionReference = this.session.sessionReference;
|
|
1026
|
+
const nextSession = await this.sessionManager.openReference(sessionPath, { cwdOverride: options?.cwdOverride });
|
|
1027
|
+
if (this.shouldValidateSessionCwdOnHost()) {
|
|
1028
|
+
assertSessionCwdExists(nextSession, this.services.cwd);
|
|
1029
|
+
}
|
|
1030
|
+
const result = await this.buildAgentSession(nextSession, {
|
|
1031
|
+
type: "session_start",
|
|
1032
|
+
reason: "resume",
|
|
1033
|
+
previousSessionReference,
|
|
1034
|
+
previousSessionFile: previousSessionReference,
|
|
1035
|
+
});
|
|
1036
|
+
await this.replaceCurrentSession(result, "resume", nextSession.getSessionReference(), options?.withSession);
|
|
1037
|
+
return { cancelled: false };
|
|
1038
|
+
}
|
|
1039
|
+
async changeDirectory(cwd) {
|
|
1040
|
+
if (!existsSync(cwd) || !statSync(cwd).isDirectory()) {
|
|
1041
|
+
throw new Error(`Directory does not exist: ${cwd}`);
|
|
1042
|
+
}
|
|
1043
|
+
const currentSession = this.session;
|
|
1044
|
+
const persistedSession = currentSession.session;
|
|
1045
|
+
const previousCwd = persistedSession.getCwd();
|
|
1046
|
+
const sessionReference = currentSession.sessionReference;
|
|
1047
|
+
await this.flushSession(currentSession);
|
|
1048
|
+
persistedSession.setCwd(cwd);
|
|
1049
|
+
let result;
|
|
1050
|
+
try {
|
|
1051
|
+
result = await this.buildAgentSession(persistedSession, {
|
|
1052
|
+
type: "session_start",
|
|
1053
|
+
reason: "resume",
|
|
1054
|
+
previousSessionReference: sessionReference,
|
|
1055
|
+
previousSessionFile: sessionReference,
|
|
1056
|
+
});
|
|
1057
|
+
}
|
|
1058
|
+
catch (error) {
|
|
1059
|
+
persistedSession.setCwd(previousCwd);
|
|
1060
|
+
throw error;
|
|
1061
|
+
}
|
|
1062
|
+
try {
|
|
1063
|
+
await this.replaceCurrentSession(result, "resume", sessionReference);
|
|
1064
|
+
}
|
|
1065
|
+
catch (error) {
|
|
1066
|
+
if (this._session === currentSession)
|
|
1067
|
+
persistedSession.setCwd(previousCwd);
|
|
1068
|
+
throw error;
|
|
1069
|
+
}
|
|
1070
|
+
return { cancelled: false };
|
|
1071
|
+
}
|
|
1072
|
+
async newSession(options) {
|
|
1073
|
+
const beforeResult = await this.emitBeforeSwitch("new");
|
|
1074
|
+
if (beforeResult.cancelled) {
|
|
1075
|
+
return beforeResult;
|
|
1076
|
+
}
|
|
1077
|
+
const previousSessionReference = this.session.sessionReference;
|
|
1078
|
+
const nextSession = await this.sessionManager.create({
|
|
1079
|
+
id: options?.id,
|
|
1080
|
+
parentSession: options?.parentSession,
|
|
1081
|
+
});
|
|
1082
|
+
if (options?.setup) {
|
|
1083
|
+
await options.setup(nextSession);
|
|
1084
|
+
}
|
|
1085
|
+
const result = await this.buildAgentSession(nextSession, {
|
|
1086
|
+
type: "session_start",
|
|
1087
|
+
reason: "new",
|
|
1088
|
+
previousSessionReference,
|
|
1089
|
+
previousSessionFile: previousSessionReference,
|
|
1090
|
+
});
|
|
1091
|
+
await this.replaceCurrentSession(result, "new", nextSession.getSessionReference(), options?.withSession);
|
|
1092
|
+
return { cancelled: false };
|
|
1093
|
+
}
|
|
1094
|
+
async fork(entryId, options) {
|
|
1095
|
+
const position = options?.position ?? "before";
|
|
1096
|
+
const beforeResult = await this.emitBeforeFork(entryId, { position });
|
|
1097
|
+
if (beforeResult.cancelled) {
|
|
1098
|
+
return { cancelled: true };
|
|
1099
|
+
}
|
|
1100
|
+
let targetLeafId;
|
|
1101
|
+
let selectedText;
|
|
1102
|
+
const activeAgentSession = this.session;
|
|
1103
|
+
const selectedEntry = activeAgentSession.session.getEntry(entryId);
|
|
1104
|
+
if (!selectedEntry) {
|
|
1105
|
+
throw new Error("Invalid entry ID for forking");
|
|
1106
|
+
}
|
|
1107
|
+
if (position === "at") {
|
|
1108
|
+
targetLeafId = selectedEntry.id;
|
|
1109
|
+
}
|
|
1110
|
+
else {
|
|
1111
|
+
if (selectedEntry.type !== "message" || selectedEntry.message.role !== "user") {
|
|
1112
|
+
throw new Error("Invalid entry ID for forking");
|
|
1113
|
+
}
|
|
1114
|
+
targetLeafId = selectedEntry.parentId;
|
|
1115
|
+
selectedText = extractUserMessageText(selectedEntry.message.content);
|
|
1116
|
+
}
|
|
1117
|
+
const previousSessionReference = activeAgentSession.sessionReference;
|
|
1118
|
+
const activeSession = activeAgentSession.session;
|
|
1119
|
+
let nextSession;
|
|
1120
|
+
try {
|
|
1121
|
+
nextSession = await activeSession.forkSubSession(targetLeafId);
|
|
1122
|
+
}
|
|
1123
|
+
catch (error) {
|
|
1124
|
+
if (!(error instanceof Error && error.message === "Session manager unavailable")) {
|
|
1125
|
+
throw error;
|
|
1126
|
+
}
|
|
1127
|
+
nextSession = await this.sessionManager.forkSession(activeSession, targetLeafId);
|
|
1128
|
+
}
|
|
1129
|
+
const result = await this.buildAgentSession(nextSession, {
|
|
1130
|
+
type: "session_start",
|
|
1131
|
+
reason: "fork",
|
|
1132
|
+
previousSessionReference,
|
|
1133
|
+
previousSessionFile: previousSessionReference,
|
|
1134
|
+
});
|
|
1135
|
+
await this.replaceCurrentSession(result, "fork", nextSession.getSessionReference(), options?.withSession);
|
|
1136
|
+
return { cancelled: false, selectedText };
|
|
1137
|
+
}
|
|
1138
|
+
async importFromJsonl(inputPath, cwdOverride) {
|
|
1139
|
+
const resolvedPath = resolve(inputPath);
|
|
1140
|
+
if (!existsSync(resolvedPath)) {
|
|
1141
|
+
throw new SessionImportFileNotFoundError(resolvedPath);
|
|
1142
|
+
}
|
|
1143
|
+
const beforeResult = await this.emitBeforeSwitch("resume", resolvedPath);
|
|
1144
|
+
if (beforeResult.cancelled) {
|
|
1145
|
+
return beforeResult;
|
|
1146
|
+
}
|
|
1147
|
+
const previousSessionReference = this.session.sessionReference;
|
|
1148
|
+
const nextSession = await this.sessionManager.importJsonl(resolvedPath, { cwdOverride: cwdOverride });
|
|
1149
|
+
if (this.shouldValidateSessionCwdOnHost()) {
|
|
1150
|
+
assertSessionCwdExists(nextSession, this.services.cwd);
|
|
1151
|
+
}
|
|
1152
|
+
const result = await this.buildAgentSession(nextSession, {
|
|
1153
|
+
type: "session_start",
|
|
1154
|
+
reason: "resume",
|
|
1155
|
+
previousSessionReference,
|
|
1156
|
+
previousSessionFile: previousSessionReference,
|
|
1157
|
+
});
|
|
1158
|
+
await this.replaceCurrentSession(result, "resume", nextSession.getSessionReference());
|
|
1159
|
+
return { cancelled: false };
|
|
1160
|
+
}
|
|
1161
|
+
async runMode(options = {}) {
|
|
1162
|
+
const mode = options.mode ?? this._mode;
|
|
1163
|
+
if (mode === "embedded") {
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
if (mode !== "interactive" && !this.session.model) {
|
|
1167
|
+
console.error(chalk.red(formatNoModelsAvailableMessage()));
|
|
1168
|
+
process.exit(1);
|
|
1169
|
+
}
|
|
1170
|
+
if (options.startupBenchmark && mode !== "interactive") {
|
|
1171
|
+
console.error(chalk.red("Error: GRIP_STARTUP_BENCHMARK only supports interactive mode"));
|
|
1172
|
+
process.exit(1);
|
|
1173
|
+
}
|
|
1174
|
+
if (mode === "rpc") {
|
|
1175
|
+
printTimings();
|
|
1176
|
+
await runRpcMode(this);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
if (mode === "interactive") {
|
|
1180
|
+
await runInteractiveAppMode(this, this.modelFallbackMessage, options);
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
printTimings();
|
|
1184
|
+
const exitCode = await runPrintMode(this, {
|
|
1185
|
+
mode: mode === "json" ? "json" : "text",
|
|
1186
|
+
messages: options.initialMessages,
|
|
1187
|
+
initialMessage: options.initialMessage,
|
|
1188
|
+
initialImages: options.initialImages,
|
|
1189
|
+
});
|
|
1190
|
+
stopThemeWatcher();
|
|
1191
|
+
restoreStdout();
|
|
1192
|
+
if (exitCode !== 0) {
|
|
1193
|
+
process.exitCode = exitCode;
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
createSession() {
|
|
1197
|
+
return this.sessionManager.create();
|
|
1198
|
+
}
|
|
1199
|
+
openSessionReference(reference) {
|
|
1200
|
+
return this.sessionManager.openReference(reference);
|
|
1201
|
+
}
|
|
1202
|
+
continueRecentSession() {
|
|
1203
|
+
return this.sessionManager.continueRecent();
|
|
1204
|
+
}
|
|
1205
|
+
forkSessionFrom(reference) {
|
|
1206
|
+
return this.sessionManager.forkFrom(reference);
|
|
1207
|
+
}
|
|
1208
|
+
async listSessions(onProgress) {
|
|
1209
|
+
return this.sessionManager.list(onProgress);
|
|
1210
|
+
}
|
|
1211
|
+
async listAllSessions(onProgress) {
|
|
1212
|
+
return this.sessionManager.listAll(onProgress);
|
|
1213
|
+
}
|
|
1214
|
+
dispose() {
|
|
1215
|
+
this.disposePromise ??= this.disposeRuntime();
|
|
1216
|
+
return this.disposePromise;
|
|
1217
|
+
}
|
|
1218
|
+
async disposeRuntime() {
|
|
1219
|
+
try {
|
|
1220
|
+
if (this._session) {
|
|
1221
|
+
await this.session.emitHookSessionEnd("prompt_input_exit");
|
|
1222
|
+
await emitSessionShutdownEvent(this.session.extensionRunner, {
|
|
1223
|
+
type: "session_shutdown",
|
|
1224
|
+
reason: "quit",
|
|
1225
|
+
});
|
|
1226
|
+
await this.flushSession(this.session);
|
|
1227
|
+
this.beforeSessionInvalidate?.();
|
|
1228
|
+
await this.session.dispose();
|
|
1229
|
+
this._session = undefined;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
finally {
|
|
1233
|
+
if (this.options.ownsToolOperations && !this.toolOperationsDisposed) {
|
|
1234
|
+
this.toolOperationsDisposed = true;
|
|
1235
|
+
await this.options.toolOperations?.dispose?.();
|
|
1236
|
+
}
|
|
1237
|
+
for (const cleanup of this.subagentCleanupCallbacks)
|
|
1238
|
+
await cleanup();
|
|
1239
|
+
this.subagentCleanupCallbacks.clear();
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
//# sourceMappingURL=grip-agent.js.map
|