@bastani/atomic 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/dist/builtin/intercom/CHANGELOG.md +22 -0
- package/dist/builtin/intercom/broker/broker-instance.ts +2 -13
- package/dist/builtin/intercom/broker/broker.ts +158 -73
- package/dist/builtin/intercom/broker/durable-ended-queue.ts +14 -2
- package/dist/builtin/intercom/broker/host-command-environment.ts +13 -0
- package/dist/builtin/intercom/broker/hosted-session-errors.ts +1 -0
- package/dist/builtin/intercom/broker/multinode-router.ts +111 -16
- package/dist/builtin/intercom/broker/multinode-state-store.ts +50 -4
- package/dist/builtin/intercom/broker/open-broker-state.ts +5 -4
- package/dist/builtin/intercom/broker/spawn.ts +144 -25
- package/dist/builtin/intercom/broker/sql-add-column.ts +33 -0
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +120 -36
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +75 -13
- package/dist/builtin/intercom/broker/start-announcement.ts +55 -10
- package/dist/builtin/intercom/broker/watchdog.ts +10 -7
- package/dist/builtin/intercom/index.bundle.mjs +111 -27
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +26 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/SKILL.md +30 -52
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +34 -40
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/viewer.html +2 -2
- package/dist/builtin/subagents/skills/skill-creator/scripts/atomic_cli.py +731 -0
- package/dist/builtin/subagents/skills/skill-creator/scripts/generate_report.py +3 -3
- package/dist/builtin/subagents/skills/skill-creator/scripts/improve_description.py +41 -38
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +276 -176
- package/dist/builtin/subagents/skills/skill-creator/scripts/run_loop.py +20 -11
- package/dist/builtin/subagents/skills/skill-creator/scripts/utils.py +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -97
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/index.bundle.mjs +5 -4
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts +10 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +54 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +4 -0
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +17 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +3 -1
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +2 -0
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +34 -13
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts.map +1 -1
- package/dist/core/agent-session-export.js +3 -0
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +27 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +213 -30
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +6 -1
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +35 -3
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +2 -2
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +6 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +15 -2
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-typed-queue.d.ts +14 -1
- package/dist/core/agent-session-typed-queue.d.ts.map +1 -1
- package/dist/core/agent-session-typed-queue.js +26 -1
- package/dist/core/agent-session-typed-queue.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +2 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async-scope.d.ts +9 -4
- package/dist/core/async-scope.d.ts.map +1 -1
- package/dist/core/async-scope.js +13 -5
- package/dist/core/async-scope.js.map +1 -1
- package/dist/core/builtin-diagnostics.js +2 -2
- package/dist/core/builtin-diagnostics.js.map +1 -1
- package/dist/core/chat-admission-order.d.ts.map +1 -1
- package/dist/core/chat-admission-order.js +2 -1
- package/dist/core/chat-admission-order.js.map +1 -1
- package/dist/core/chat-record-saves.d.ts +4 -0
- package/dist/core/chat-record-saves.d.ts.map +1 -0
- package/dist/core/chat-record-saves.js +25 -0
- package/dist/core/chat-record-saves.js.map +1 -0
- package/dist/core/command-deliveries.d.ts +62 -0
- package/dist/core/command-deliveries.d.ts.map +1 -0
- package/dist/core/command-deliveries.js +139 -0
- package/dist/core/command-deliveries.js.map +1 -0
- package/dist/core/diagnostic-writer.d.ts.map +1 -1
- package/dist/core/diagnostic-writer.js +5 -4
- package/dist/core/diagnostic-writer.js.map +1 -1
- package/dist/core/extension-startup-close.d.ts +1 -2
- package/dist/core/extension-startup-close.d.ts.map +1 -1
- package/dist/core/extension-startup-close.js +2 -2
- package/dist/core/extension-startup-close.js.map +1 -1
- package/dist/core/extensions/jiti-aliases.d.ts +11 -0
- package/dist/core/extensions/jiti-aliases.d.ts.map +1 -0
- package/dist/core/extensions/jiti-aliases.js +28 -0
- package/dist/core/extensions/jiti-aliases.js.map +1 -0
- package/dist/core/extensions/loader-api.js +3 -3
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-bindings.js +2 -2
- package/dist/core/extensions/loader-bindings.js.map +1 -1
- package/dist/core/extensions/loader-rollback.d.ts +1 -2
- package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
- package/dist/core/extensions/loader-rollback.js +2 -2
- package/dist/core/extensions/loader-rollback.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +53 -9
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/native-builtin-entries.d.ts +5 -0
- package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -1
- package/dist/core/extensions/native-builtin-entries.js +8 -1
- package/dist/core/extensions/native-builtin-entries.js.map +1 -1
- package/dist/core/extensions/reloadable-scripts.d.ts +21 -2
- package/dist/core/extensions/reloadable-scripts.d.ts.map +1 -1
- package/dist/core/extensions/reloadable-scripts.js +11 -3
- package/dist/core/extensions/reloadable-scripts.js.map +1 -1
- package/dist/core/extensions/source-builtin-imports.d.ts +40 -0
- package/dist/core/extensions/source-builtin-imports.d.ts.map +1 -0
- package/dist/core/extensions/source-builtin-imports.js +142 -0
- package/dist/core/extensions/source-builtin-imports.js.map +1 -0
- package/dist/core/extensions/transform-graph.d.ts +15 -0
- package/dist/core/extensions/transform-graph.d.ts.map +1 -0
- package/dist/core/extensions/transform-graph.js +85 -0
- package/dist/core/extensions/transform-graph.js.map +1 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts +2 -0
- package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
- package/dist/core/extensions/ts-source-specifiers.js +7 -0
- package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
- package/dist/core/extensions/ts-transform-worker.d.ts +2 -0
- package/dist/core/extensions/ts-transform-worker.d.ts.map +1 -0
- package/dist/core/extensions/ts-transform-worker.js +43 -0
- package/dist/core/extensions/ts-transform-worker.js.map +1 -0
- package/dist/core/message-admission.d.ts.map +1 -1
- package/dist/core/message-admission.js +4 -4
- package/dist/core/message-admission.js.map +1 -1
- package/dist/core/messages.d.ts +5 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +35 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +1 -1
- package/dist/core/model-fallback-failures.d.ts.map +1 -1
- package/dist/core/model-fallback-failures.js +18 -1
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/process-start-token.d.ts +7 -0
- package/dist/core/process-start-token.d.ts.map +1 -1
- package/dist/core/process-start-token.js +14 -0
- package/dist/core/process-start-token.js.map +1 -1
- package/dist/core/project-trust-electorate.d.ts +24 -0
- package/dist/core/project-trust-electorate.d.ts.map +1 -0
- package/dist/core/project-trust-electorate.js +52 -0
- package/dist/core/project-trust-electorate.js.map +1 -0
- package/dist/core/project-trust-state.d.ts +15 -0
- package/dist/core/project-trust-state.d.ts.map +1 -1
- package/dist/core/project-trust-state.js +15 -0
- package/dist/core/project-trust-state.js.map +1 -1
- package/dist/core/provider-request-admission.d.ts.map +1 -1
- package/dist/core/provider-request-admission.js +2 -2
- package/dist/core/provider-request-admission.js.map +1 -1
- package/dist/core/queued-input-admission.js +2 -2
- package/dist/core/queued-input-admission.js.map +1 -1
- package/dist/core/queued-message-delivery.d.ts +2 -2
- package/dist/core/queued-message-delivery.d.ts.map +1 -1
- package/dist/core/queued-message-delivery.js +6 -3
- package/dist/core/queued-message-delivery.js.map +1 -1
- package/dist/core/resource-admission-scope.js +2 -2
- package/dist/core/resource-admission-scope.js.map +1 -1
- package/dist/core/resume/blueprint/process.d.ts +3 -4
- package/dist/core/resume/blueprint/process.d.ts.map +1 -1
- package/dist/core/resume/blueprint/process.js +33 -17
- package/dist/core/resume/blueprint/process.js.map +1 -1
- package/dist/core/resume/path-mapping.js +4 -4
- package/dist/core/resume/path-mapping.js.map +1 -1
- package/dist/core/resume/session-resume.d.ts +9 -0
- package/dist/core/resume/session-resume.d.ts.map +1 -1
- package/dist/core/resume/session-resume.js +27 -2
- package/dist/core/resume/session-resume.js.map +1 -1
- package/dist/core/resume-cache-checkpoint.d.ts +27 -1
- package/dist/core/resume-cache-checkpoint.d.ts.map +1 -1
- package/dist/core/resume-cache-checkpoint.js +45 -0
- package/dist/core/resume-cache-checkpoint.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -31
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-lifecycle-scope.d.ts +1 -2
- package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
- package/dist/core/session-lifecycle-scope.js +2 -2
- package/dist/core/session-lifecycle-scope.js.map +1 -1
- package/dist/core/session-lifecycle-work.js +2 -2
- package/dist/core/session-lifecycle-work.js.map +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +3 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-storage.d.ts +12 -0
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +68 -1
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/settings-lock-directory.d.ts.map +1 -1
- package/dist/core/settings-lock-directory.js +4 -3
- package/dist/core/settings-lock-directory.js.map +1 -1
- package/dist/core/settings-write-ownership.d.ts +1 -2
- package/dist/core/settings-write-ownership.d.ts.map +1 -1
- package/dist/core/settings-write-ownership.js +2 -2
- package/dist/core/settings-write-ownership.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +6 -4
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +22 -8
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/system-prompt.d.ts +16 -2
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +33 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
- package/dist/core/tasks/agent-adapter.js +2 -1
- package/dist/core/tasks/agent-adapter.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +3 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/execution-scope.js +2 -2
- package/dist/core/tasks/execution-scope.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
- package/dist/core/tools/history-regex-worker.js +3 -2
- package/dist/core/tools/history-regex-worker.js.map +1 -1
- package/dist/core/tools/shell-task-render.d.ts +3 -2
- package/dist/core/tools/shell-task-render.d.ts.map +1 -1
- package/dist/core/tools/shell-task-render.js +7 -5
- package/dist/core/tools/shell-task-render.js.map +1 -1
- package/dist/core/tools/shell-task-status.d.ts +6 -2
- package/dist/core/tools/shell-task-status.d.ts.map +1 -1
- package/dist/core/tools/shell-task-status.js +13 -8
- package/dist/core/tools/shell-task-status.js.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
- package/dist/core/tools/sqlite-selector-connection.js +4 -3
- package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
- package/dist/core/tools/windows-directory-security.js +2 -1
- package/dist/core/tools/windows-directory-security.js.map +1 -1
- package/dist/core/worktree-snapshot/git.js +2 -2
- package/dist/core/worktree-snapshot/git.js.map +1 -1
- package/dist/extensions/mcp/index.d.ts +6 -1
- package/dist/extensions/mcp/index.d.ts.map +1 -1
- package/dist/extensions/mcp/index.js +150 -18
- package/dist/extensions/mcp/index.js.map +1 -1
- package/dist/extensions/mcp/tool-records.d.ts +44 -9
- package/dist/extensions/mcp/tool-records.d.ts.map +1 -1
- package/dist/extensions/mcp/tool-records.js +58 -16
- package/dist/extensions/mcp/tool-records.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/main-session.d.ts +3 -1
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +1 -0
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +230 -96
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +5 -0
- package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +5 -2
- package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/agent-view-switcher.js +3 -3
- package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.d.ts +6 -0
- package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
- package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/install.js +2 -1
- package/dist/modes/interactive/agent-view/install.js.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.d.ts +4 -2
- package/dist/modes/interactive/agent-view/open-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/open-port.js +4 -3
- package/dist/modes/interactive/agent-view/open-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/prompt-retarget.js +18 -5
- package/dist/modes/interactive/agent-view/prompt-retarget.js.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts +10 -1
- package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/remote-port.js +36 -4
- package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts +56 -0
- package/dist/modes/interactive/agent-view/viewed-keys.d.ts.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js +63 -0
- package/dist/modes/interactive/agent-view/viewed-keys.js.map +1 -0
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts +14 -4
- package/dist/modes/interactive/agent-view/viewed-submit.d.ts.map +1 -1
- package/dist/modes/interactive/agent-view/viewed-submit.js +51 -17
- package/dist/modes/interactive/agent-view/viewed-submit.js.map +1 -1
- package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
- package/dist/modes/interactive/components/agent-panel.js +8 -21
- package/dist/modes/interactive/components/agent-panel.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +18 -5
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +6 -0
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +5 -0
- package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +33 -2
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +58 -2
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/host-session-picker.js +2 -2
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.d.ts +16 -5
- package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
- package/dist/modes/interactive/components/main-composer-keys.js +27 -8
- package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
- package/dist/modes/interactive/components/notice-line.d.ts +8 -25
- package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
- package/dist/modes/interactive/components/notice-line.js +18 -17
- package/dist/modes/interactive/components/notice-line.js.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.d.ts +20 -3
- package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
- package/dist/modes/interactive/components/prompt-slot.js +82 -32
- package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.d.ts +5 -2
- package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
- package/dist/modes/interactive/components/queued-messages-view.js +12 -5
- package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
- package/dist/modes/interactive/components/task-board.d.ts +5 -8
- package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-board.js +5 -49
- package/dist/modes/interactive/components/task-board.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.js +9 -2
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
- package/dist/modes/interactive/components/task-marks.d.ts +19 -0
- package/dist/modes/interactive/components/task-marks.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-marks.js +25 -0
- package/dist/modes/interactive/components/task-marks.js.map +1 -0
- package/dist/modes/interactive/components/task-row.d.ts +10 -2
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +39 -32
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.d.ts +7 -0
- package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-transcript-page.js +106 -10
- package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-block-families.js +8 -9
- package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -1
- package/dist/modes/interactive/extension-command-hold.js +5 -7
- package/dist/modes/interactive/extension-command-hold.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +6 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +21 -7
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts +1 -2
- package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-initial-session-binding.js +2 -2
- package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +13 -4
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +6 -1
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -2
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +6 -0
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +96 -17
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts +5 -0
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +37 -5
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +45 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts +4 -1
- package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js +20 -1
- package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
- package/dist/modes/interactive/interactive-resource-rendering.js +3 -0
- package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +43 -5
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +6 -3
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js +3 -2
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/engine-health.d.ts +2 -0
- package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-health.js.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-quit-intent.js +33 -0
- package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +7 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +15 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/host-listener-failures.d.ts +24 -0
- package/dist/modes/interactive-engine/host-listener-failures.d.ts.map +1 -0
- package/dist/modes/interactive-engine/host-listener-failures.js +98 -0
- package/dist/modes/interactive-engine/host-listener-failures.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +16 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +74 -7
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +5 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +8 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +13 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +69 -4
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +34 -6
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
- package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
- package/dist/modes/rpc/agent-panel-bridge.js +11 -1
- package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
- package/dist/modes/rpc/agent-view-rpc-panel.js +11 -5
- package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +8 -1
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +89 -65
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +21 -0
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +77 -33
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +5 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +8 -2
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +9 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/shell.d.ts +5 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -7
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/worker-threads.d.ts +10 -4
- package/dist/utils/worker-threads.d.ts.map +1 -1
- package/dist/utils/worker-threads.js +10 -4
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/background-tasks.md +10 -10
- package/docs/compaction.md +1 -0
- package/docs/development.md +1 -1
- package/docs/environment-variables.md +4 -0
- package/docs/extensions/api-reference.md +2 -0
- package/docs/extensions/events.md +1 -1
- package/docs/getting-started/installation.md +1 -0
- package/docs/guides/non-interactive.md +2 -0
- package/docs/guides/resume-on-any-machine.md +3 -1
- package/docs/intercom/reference.md +1 -1
- package/docs/keybindings.md +6 -5
- package/docs/libraries/ai.md +2 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/sdk/reference.md +1 -1
- package/docs/sdk.md +6 -0
- package/docs/security.md +4 -2
- package/docs/settings.md +2 -1
- package/docs/storage.md +2 -0
- package/docs/subagents.md +2 -2
- package/docs/tui/reference.md +3 -1
- package/npm-shrinkwrap.json +49 -49
- package/package.json +6 -6
|
@@ -1 +1 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,GAAG,EAAE,CAAC;IACvC,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { type ChildProcess, spawn } from \"node:child_process\";\nimport { constants } from \"node:fs\";\nimport { access, stat } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, sep } from \"node:path\";\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport { getBinDir } from \"../../config.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { createGitEnvironment } from \"../../utils/git-env.ts\";\nimport { isGitProvisionError } from \"../../utils/git-errors.ts\";\nimport { type HostChildProcess, spawnHostProcess } from \"../../utils/host-spawn.ts\";\nimport { pathExists } from \"../../utils/path-exists.ts\";\nimport { redactUrlCredentials } from \"../error-contract.ts\";\nimport { containProcessTree, type ProcessTreeContainment } from \"../process-tree-containment.ts\";\nimport {\n\tGitUnavailableError,\n\tgitInstallCommand,\n\tisGitUnavailableError,\n\tWorkspaceGitError,\n\tWorkspaceSnapshotError,\n} from \"./errors.ts\";\nimport { worktreeSnapshotExcludedRoots } from \"./excluded-roots.ts\";\nimport { canonicalizeWorktreePathAsync } from \"./paths.ts\";\n\n/** The Git executable snapshot operations run, with the environment it needs (a provisioned Git may need some). */\nexport interface GitExecutable {\n\treadonly path: string;\n\treadonly env: Readonly<NodeJS.ProcessEnv>;\n}\n\nexport type GitExecutableResolver = (signal?: AbortSignal) => Promise<GitExecutable>;\n\nconst provisionedGit: GitExecutableResolver = async (signal) => {\n\tconst { resolveGit } = await import(\"../../utils/tools-manager.ts\");\n\treturn resolveGit({ signal });\n};\nlet resolveExecutable: GitExecutableResolver = provisionedGit;\n\n/** The Git every snapshot command of one scope runs instead of the resolver's, such as one restore's. */\nconst scopedExecutable = new AsyncLocalStorage<GitExecutable>();\n\n/**\n * Runs `action` with every snapshot Git command it starts on `executable`, which no resolver is asked for; other\n * operations of this process keep theirs. Undefined: `action` runs as it would without this call.\n */\nexport function withWorktreeSnapshotGit<T>(\n\texecutable: GitExecutable | undefined,\n\taction: () => Promise<T>,\n): Promise<T> {\n\treturn executable === undefined ? action() : scopedExecutable.run(executable, action);\n}\n\n/**\n * Why a snapshot cannot be recorded with the Git already on this machine, checked without downloading one: recording\n * only uses an installed or provisioned Git, so a session that never needs Git otherwise starts no download (#4322). Undefined when such a Git exists, or when an injected resolver decides.\n */\nexport async function installedGitUnavailable(): Promise<GitUnavailableError | undefined> {\n\tif (resolveExecutable !== provisionedGit) return undefined;\n\tconst { resolveInstalledGit } = await import(\"../../utils/tools-manager.ts\");\n\ttry {\n\t\tawait resolveInstalledGit();\n\t\treturn undefined;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return error;\n\t\tif (!isGitProvisionError(error)) throw error;\n\t\t// An earlier download in this process failed another way, such as timing out: no Git is installed.\n\t\treturn new GitUnavailableError(\n\t\t\t{\n\t\t\t\tcode: \"not-installed\",\n\t\t\t\tplatform: process.platform,\n\t\t\t\tarch: process.arch,\n\t\t\t\tinstallDir: join(getBinDir(), \"git\"),\n\t\t\t\tinstallCommand: gitInstallCommand(process.platform),\n\t\t\t},\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\n/**\n * The single place every worktree snapshot Git invocation gets its executable from. Returns the previous resolver so\n * callers can restore it.\n */\nexport function setWorktreeSnapshotGit(resolver: GitExecutableResolver): GitExecutableResolver {\n\tconst previous = resolveExecutable;\n\tresolveExecutable = resolver;\n\treturn previous;\n}\n\nconst NULL_DEVICE = process.platform === \"win32\" ? \"NUL\" : \"/dev/null\";\n/**\n * Settings that keep snapshot commands from running hooks, daemons, maintenance or signing in the user's repository,\n * and let Git for Windows write paths longer than 260 characters, which a restore under the store's long path can\n * reach for a path that fits in the user's checkout (#4932); other platforms ignore `core.longpaths`.\n */\nconst BASE_CONFIG = [\n\t\"-c\",\n\t\"core.longpaths=true\",\n\t\"-c\",\n\t`core.hooksPath=${NULL_DEVICE}`,\n\t\"-c\",\n\t\"core.fsmonitor=false\",\n\t\"-c\",\n\t\"gc.auto=0\",\n\t\"-c\",\n\t\"maintenance.auto=false\",\n\t\"-c\",\n\t\"commit.gpgSign=false\",\n];\n/** Conversion settings that make materialization and verification independent of the host's Git configuration. */\nexport const NEUTRAL_CONVERSION_CONFIG: readonly string[] = [\n\t\"-c\",\n\t\"core.autocrlf=false\",\n\t\"-c\",\n\t\"core.eol=lf\",\n\t\"-c\",\n\t\"core.safecrlf=false\",\n];\n\nexport interface GitRunOptions {\n\treadonly cwd: string;\n\treadonly env?: Readonly<Record<string, string>>;\n\treadonly input?: string | Uint8Array;\n\treadonly signal?: AbortSignal;\n\t/** Exit codes that are results rather than failures, such as 1 from `git cat-file -e`. */\n\treadonly allowExitCodes?: readonly number[];\n\t/** Prepend {@link NEUTRAL_CONVERSION_CONFIG}. */\n\treadonly neutral?: boolean;\n\t/**\n\t * Run a command that talks to a remote so it can never wait for a person: on POSIX it starts in a new session, so\n\t * ssh and credential helpers have no terminal to prompt on and fail at once, and ssh runs in batch mode with a\n\t * bounded connect time unless the user chose their own ssh command (`GIT_SSH_COMMAND`, `GIT_SSH` or\n\t * `core.sshCommand`). A prompt is never answered, so the command fails with the usual {@link WorkspaceGitError}.\n\t */\n\treadonly nonInteractive?: boolean;\n}\n\n/** How long a non-interactive ssh waits for a connection before giving up, in seconds. */\nexport const NON_INTERACTIVE_SSH_CONNECT_TIMEOUT_SECONDS = 15;\n\nexport interface GitRunResult {\n\treadonly stdout: Buffer;\n\treadonly stderr: string;\n\treadonly exitCode: number;\n}\n\nfunction exitStatusReportsClosedInput(): void {}\n\nexport { redactUrlCredentials };\n\nfunction gitOperation(args: readonly string[]): string {\n\tfor (let index = 0; index < args.length; index++) {\n\t\tif (args[index] === \"-c\") index++;\n\t\telse if (!args[index]!.startsWith(\"-\")) return args[index]!;\n\t}\n\treturn \"\";\n}\n\nfunction firstLine(text: string): string {\n\treturn redactUrlCredentials(text.trim().split(\"\\n\", 1)[0] ?? \"\").slice(0, 300);\n}\n\n/** Whether the user's Git configuration (not the environment) names the ssh command Git runs. */\nasync function configuresSshCommand(options: GitRunOptions): Promise<boolean> {\n\tconst lookup = await runGit([\"config\", \"--get\", \"core.sshCommand\"], {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tallowExitCodes: [1],\n\t});\n\treturn lookup.exitCode === 0;\n}\n\n/** Kills `child`, and with it the ssh or helper processes it started when it leads its own session. */\n/** How long an aborted Git command is waited for after it was killed, before its abort is reported anyway. */\nconst ABORTED_GIT_EXIT_WAIT_MS = 10_000;\nconst PROCESS_TREE_POLL_MS = 5;\n\nfunction killChild(child: HostChildProcess, detached: boolean): void {\n\tif (detached && child.pid !== undefined) {\n\t\ttry {\n\t\t\tprocess.kill(-child.pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// The group is already gone, or cannot be signalled: the child itself is all that is left to kill.\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t}\n\t\treturn;\n\t}\n\tchild.kill(\"SIGKILL\");\n}\n\nfunction running(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction treeRunning(tree: ProcessTreeContainment | undefined): boolean {\n\ttry {\n\t\treturn tree !== undefined && tree.activeProcesses() > 0;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction taskkillTree(pid: number, deadline: number): Promise<number[]> {\n\treturn new Promise((resolve) => {\n\t\tlet output = \"\";\n\t\tlet taskkill: ChildProcess;\n\t\ttry {\n\t\t\ttaskkill = spawn(\n\t\t\t\tjoin(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"taskkill.exe\"),\n\t\t\t\t[\"/F\", \"/T\", \"/PID\", String(pid)],\n\t\t\t\t{ stdio: [\"ignore\", \"pipe\", \"ignore\"], windowsHide: true, env: createChildProcessEnvironment() },\n\t\t\t);\n\t\t} catch {\n\t\t\tresolve([]);\n\t\t\treturn;\n\t\t}\n\t\tconst done = () => {\n\t\t\tclearTimeout(bound);\n\t\t\tconst killed = output.split(/\\r?\\n/).map((line) => Number(/\\d+/.exec(line)?.[0]));\n\t\t\tresolve(killed.filter((id) => Number.isInteger(id) && id !== process.pid));\n\t\t};\n\t\tconst bound = setTimeout(done, Math.max(0, deadline - Date.now()));\n\t\ttaskkill.stdout?.on(\"data\", (chunk: Buffer) => {\n\t\t\toutput += chunk.toString(\"utf8\");\n\t\t});\n\t\ttaskkill.once(\"close\", done);\n\t\ttaskkill.once(\"error\", done);\n\t});\n}\n\nasync function stopCommand(\n\tchild: HostChildProcess,\n\tdetached: boolean,\n\ttree: ProcessTreeContainment | undefined,\n): Promise<void> {\n\tconst deadline = Date.now() + ABORTED_GIT_EXIT_WAIT_MS;\n\tlet closed = false;\n\tconst close = () => {\n\t\tclosed = true;\n\t};\n\tchild.once(\"close\", close);\n\tchild.once(\"error\", close);\n\tlet killed: number[] = [];\n\tif (tree?.terminate() !== true) {\n\t\tif (process.platform === \"win32\" && child.pid !== undefined) killed = await taskkillTree(child.pid, deadline);\n\t\telse killChild(child, detached);\n\t}\n\twhile (Date.now() < deadline && !(closed && !treeRunning(tree) && !killed.some(running))) {\n\t\tawait sleep(PROCESS_TREE_POLL_MS);\n\t}\n\ttree?.close();\n}\n\nasync function endTree(tree: ProcessTreeContainment | undefined): Promise<void> {\n\tif (treeRunning(tree) && tree?.terminate()) {\n\t\tconst deadline = Date.now() + ABORTED_GIT_EXIT_WAIT_MS;\n\t\twhile (Date.now() < deadline && treeRunning(tree)) await sleep(PROCESS_TREE_POLL_MS);\n\t}\n\ttree?.close();\n}\n\n/**\n * The `unreadable-path` error for a working directory the process cannot list or enter. Spawning in one fails with the\n * same `ENOENT` or `EACCES` as a missing or non-executable Git, so only the directory itself tells them apart.\n */\nasync function unreadableDirectory(directory: string): Promise<WorkspaceSnapshotError | undefined> {\n\ttry {\n\t\tawait access(directory, constants.R_OK | constants.X_OK);\n\t\treturn undefined;\n\t} catch (error) {\n\t\treturn new WorkspaceSnapshotError(\"unreadable-path\", directory, error as Error);\n\t}\n}\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** The `not-a-repository` refusal for a working directory in a root excluded from snapshots, if it is in one. */\nasync function excludedDirectory(cwd: string): Promise<WorkspaceSnapshotError | undefined> {\n\tconst roots = worktreeSnapshotExcludedRoots();\n\tif (roots.length === 0) return undefined;\n\tconst directory = await canonicalizeWorktreePathAsync(cwd);\n\tfor (const root of roots) {\n\t\tconst path = relative(await canonicalizeWorktreePathAsync(root), directory);\n\t\tif (path !== \"..\" && !path.startsWith(`..${sep}`) && !isAbsolute(path)) {\n\t\t\treturn new WorkspaceSnapshotError(\"not-a-repository\", cwd);\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Runs one Git command through the injected executable. Rejects with the signal's reason when aborted, and with\n * `not-a-repository` before resolving Git when the working directory lies in a root excluded from snapshots.\n */\nexport async function runGit(args: readonly string[], options: GitRunOptions): Promise<GitRunResult> {\n\toptions.signal?.throwIfAborted();\n\tconst excluded = await excludedDirectory(options.cwd);\n\tif (excluded !== undefined) throw excluded;\n\tconst executable = scopedExecutable.getStore() ?? (await resolveExecutable(options.signal));\n\toptions.signal?.throwIfAborted();\n\tconst env = createGitEnvironment(\n\t\t{ GIT_TERMINAL_PROMPT: \"0\", GIT_OPTIONAL_LOCKS: \"0\", GCM_INTERACTIVE: \"never\" },\n\t\tcreateChildProcessEnvironment(executable.env),\n\t);\n\tObject.assign(env, options.env);\n\tif (options.nonInteractive && !env.GIT_SSH_COMMAND && !env.GIT_SSH && !(await configuresSshCommand(options))) {\n\t\tenv.GIT_SSH_COMMAND = `ssh -o BatchMode=yes -o ConnectTimeout=${NON_INTERACTIVE_SSH_CONNECT_TIMEOUT_SECONDS}`;\n\t}\n\t// A new session has no controlling terminal. Windows has no such thing, and `detached` there opens a console.\n\tconst detached = options.nonInteractive === true && process.platform !== \"win32\";\n\tconst argv = [...BASE_CONFIG, ...(options.neutral ? NEUTRAL_CONVERSION_CONFIG : []), ...args];\n\tconst spawnFailure = async (error: NodeJS.ErrnoException): Promise<Error> =>\n\t\t(error.code === \"ENOENT\" || error.code === \"EACCES\") && (await isDirectory(options.cwd))\n\t\t\t? ((await unreadableDirectory(options.cwd)) ??\n\t\t\t\tnew GitUnavailableError(\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"not-installed\",\n\t\t\t\t\t\tplatform: process.platform,\n\t\t\t\t\t\tarch: process.arch,\n\t\t\t\t\t\tinstallDir: join(getBinDir(), \"git\"),\n\t\t\t\t\t\tinstallCommand: gitInstallCommand(process.platform),\n\t\t\t\t\t\tsystemGit: { path: executable.path, problem: \"probe-failed\" },\n\t\t\t\t\t},\n\t\t\t\t\t{ cause: error },\n\t\t\t\t))\n\t\t\t: new WorkspaceGitError(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: gitOperation(args),\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\texitCode: null,\n\t\t\t\t\t\tdetail: (await pathExists(options.cwd))\n\t\t\t\t\t\t\t? firstLine(error.message)\n\t\t\t\t\t\t\t: \"the working directory does not exist\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\treturn new Promise<GitRunResult>((resolve, reject) => {\n\t\tlet child: HostChildProcess;\n\t\ttry {\n\t\t\t// Without fork where that costs the host time in proportion to its memory (#5345).\n\t\t\tchild = spawnHostProcess(executable.path, argv, { cwd: options.cwd, env, stdio: \"pipe\", detached });\n\t\t} catch (error) {\n\t\t\t// Node throws instead of emitting `error` for some failures, such as a path component that is a file.\n\t\t\tvoid spawnFailure(error as NodeJS.ErrnoException).then(reject, reject);\n\t\t\treturn;\n\t\t}\n\t\tconst tree = child.pid === undefined ? undefined : containProcessTree(child.pid);\n\t\tconst stdout: Buffer[] = [];\n\t\tconst stderr: Buffer[] = [];\n\t\tlet settled = false;\n\t\tconst onAbort = () => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\t// Rejects once the process has ended, so nothing it started still works in its directories.\n\t\t\tvoid stopCommand(child, detached, tree).then(() => reject(options.signal?.reason));\n\t\t};\n\t\toptions.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\tconst finish = (action: () => void) => {\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\taction();\n\t\t};\n\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => stdout.push(chunk));\n\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => stderr.push(chunk));\n\t\tchild.on(\"error\", (error: NodeJS.ErrnoException) =>\n\t\t\tfinish(() => {\n\t\t\t\ttree?.close();\n\t\t\t\tvoid spawnFailure(error).then(reject, reject);\n\t\t\t}),\n\t\t);\n\t\tchild.stdin?.on(\"error\", exitStatusReportsClosedInput);\n\t\tchild.on(\"close\", (code) =>\n\t\t\tfinish(() => {\n\t\t\t\tconst result = {\n\t\t\t\t\tstdout: Buffer.concat(stdout),\n\t\t\t\t\tstderr: Buffer.concat(stderr).toString(\"utf8\"),\n\t\t\t\t\texitCode: code ?? -1,\n\t\t\t\t};\n\t\t\t\tvoid endTree(tree).then(() => {\n\t\t\t\t\tif (code === 0 || (code !== null && options.allowExitCodes?.includes(code))) resolve(result);\n\t\t\t\t\telse\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew WorkspaceGitError({\n\t\t\t\t\t\t\t\toperation: gitOperation(args),\n\t\t\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\t\t\texitCode: code,\n\t\t\t\t\t\t\t\tdetail: firstLine(result.stderr),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t\tchild.stdin?.end(options.input === undefined ? undefined : options.input);\n\t});\n}\n\n/** Runs a Git command and returns its standard output as UTF-8 text without the trailing newline. */\nexport async function gitText(args: readonly string[], options: GitRunOptions): Promise<string> {\n\tconst { stdout } = await runGit(args, options);\n\treturn stdout.toString(\"utf8\").replace(/\\n$/, \"\");\n}\n\n/** Splits NUL-terminated Git output. */\nexport function nulFields(output: Buffer | string): string[] {\n\tconst text = typeof output === \"string\" ? output : output.toString(\"utf8\");\n\tconst fields = text.split(\"\\0\");\n\tif (fields.at(-1) === \"\") fields.pop();\n\treturn fields;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/core/worktree-snapshot/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAyB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAA+B,MAAM,gCAAgC,CAAC;AACjG,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,GACtB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M,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;QAAE,MAAM,CAAC,GAAG,EAAE,CAAC;IACvC,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import { type ChildProcess, spawn } from \"node:child_process\";\nimport { constants } from \"node:fs\";\nimport { access, stat } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, sep } from \"node:path\";\nimport { setTimeout as sleep } from \"node:timers/promises\";\nimport { getBinDir } from \"../../config.js\";\nimport { createChildProcessEnvironment } from \"../../utils/child-process.ts\";\nimport { createGitEnvironment } from \"../../utils/git-env.ts\";\nimport { isGitProvisionError } from \"../../utils/git-errors.ts\";\nimport { type HostChildProcess, spawnHostProcess } from \"../../utils/host-spawn.ts\";\nimport { pathExists } from \"../../utils/path-exists.ts\";\nimport { asyncScope } from \"../async-scope.ts\";\nimport { redactUrlCredentials } from \"../error-contract.ts\";\nimport { containProcessTree, type ProcessTreeContainment } from \"../process-tree-containment.ts\";\nimport {\n\tGitUnavailableError,\n\tgitInstallCommand,\n\tisGitUnavailableError,\n\tWorkspaceGitError,\n\tWorkspaceSnapshotError,\n} from \"./errors.ts\";\nimport { worktreeSnapshotExcludedRoots } from \"./excluded-roots.ts\";\nimport { canonicalizeWorktreePathAsync } from \"./paths.ts\";\n\n/** The Git executable snapshot operations run, with the environment it needs (a provisioned Git may need some). */\nexport interface GitExecutable {\n\treadonly path: string;\n\treadonly env: Readonly<NodeJS.ProcessEnv>;\n}\n\nexport type GitExecutableResolver = (signal?: AbortSignal) => Promise<GitExecutable>;\n\nconst provisionedGit: GitExecutableResolver = async (signal) => {\n\tconst { resolveGit } = await import(\"../../utils/tools-manager.ts\");\n\treturn resolveGit({ signal });\n};\nlet resolveExecutable: GitExecutableResolver = provisionedGit;\n\n/** The Git every snapshot command of one scope runs instead of the resolver's, such as one restore's. */\nconst scopedExecutable = asyncScope<GitExecutable>();\n\n/**\n * Runs `action` with every snapshot Git command it starts on `executable`, which no resolver is asked for; other\n * operations of this process keep theirs. Undefined: `action` runs as it would without this call.\n */\nexport function withWorktreeSnapshotGit<T>(\n\texecutable: GitExecutable | undefined,\n\taction: () => Promise<T>,\n): Promise<T> {\n\treturn executable === undefined ? action() : scopedExecutable.run(executable, action);\n}\n\n/**\n * Why a snapshot cannot be recorded with the Git already on this machine, checked without downloading one: recording\n * only uses an installed or provisioned Git, so a session that never needs Git otherwise starts no download (#4322). Undefined when such a Git exists, or when an injected resolver decides.\n */\nexport async function installedGitUnavailable(): Promise<GitUnavailableError | undefined> {\n\tif (resolveExecutable !== provisionedGit) return undefined;\n\tconst { resolveInstalledGit } = await import(\"../../utils/tools-manager.ts\");\n\ttry {\n\t\tawait resolveInstalledGit();\n\t\treturn undefined;\n\t} catch (error) {\n\t\tif (isGitUnavailableError(error)) return error;\n\t\tif (!isGitProvisionError(error)) throw error;\n\t\t// An earlier download in this process failed another way, such as timing out: no Git is installed.\n\t\treturn new GitUnavailableError(\n\t\t\t{\n\t\t\t\tcode: \"not-installed\",\n\t\t\t\tplatform: process.platform,\n\t\t\t\tarch: process.arch,\n\t\t\t\tinstallDir: join(getBinDir(), \"git\"),\n\t\t\t\tinstallCommand: gitInstallCommand(process.platform),\n\t\t\t},\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\n/**\n * The single place every worktree snapshot Git invocation gets its executable from. Returns the previous resolver so\n * callers can restore it.\n */\nexport function setWorktreeSnapshotGit(resolver: GitExecutableResolver): GitExecutableResolver {\n\tconst previous = resolveExecutable;\n\tresolveExecutable = resolver;\n\treturn previous;\n}\n\nconst NULL_DEVICE = process.platform === \"win32\" ? \"NUL\" : \"/dev/null\";\n/**\n * Settings that keep snapshot commands from running hooks, daemons, maintenance or signing in the user's repository,\n * and let Git for Windows write paths longer than 260 characters, which a restore under the store's long path can\n * reach for a path that fits in the user's checkout (#4932); other platforms ignore `core.longpaths`.\n */\nconst BASE_CONFIG = [\n\t\"-c\",\n\t\"core.longpaths=true\",\n\t\"-c\",\n\t`core.hooksPath=${NULL_DEVICE}`,\n\t\"-c\",\n\t\"core.fsmonitor=false\",\n\t\"-c\",\n\t\"gc.auto=0\",\n\t\"-c\",\n\t\"maintenance.auto=false\",\n\t\"-c\",\n\t\"commit.gpgSign=false\",\n];\n/** Conversion settings that make materialization and verification independent of the host's Git configuration. */\nexport const NEUTRAL_CONVERSION_CONFIG: readonly string[] = [\n\t\"-c\",\n\t\"core.autocrlf=false\",\n\t\"-c\",\n\t\"core.eol=lf\",\n\t\"-c\",\n\t\"core.safecrlf=false\",\n];\n\nexport interface GitRunOptions {\n\treadonly cwd: string;\n\treadonly env?: Readonly<Record<string, string>>;\n\treadonly input?: string | Uint8Array;\n\treadonly signal?: AbortSignal;\n\t/** Exit codes that are results rather than failures, such as 1 from `git cat-file -e`. */\n\treadonly allowExitCodes?: readonly number[];\n\t/** Prepend {@link NEUTRAL_CONVERSION_CONFIG}. */\n\treadonly neutral?: boolean;\n\t/**\n\t * Run a command that talks to a remote so it can never wait for a person: on POSIX it starts in a new session, so\n\t * ssh and credential helpers have no terminal to prompt on and fail at once, and ssh runs in batch mode with a\n\t * bounded connect time unless the user chose their own ssh command (`GIT_SSH_COMMAND`, `GIT_SSH` or\n\t * `core.sshCommand`). A prompt is never answered, so the command fails with the usual {@link WorkspaceGitError}.\n\t */\n\treadonly nonInteractive?: boolean;\n}\n\n/** How long a non-interactive ssh waits for a connection before giving up, in seconds. */\nexport const NON_INTERACTIVE_SSH_CONNECT_TIMEOUT_SECONDS = 15;\n\nexport interface GitRunResult {\n\treadonly stdout: Buffer;\n\treadonly stderr: string;\n\treadonly exitCode: number;\n}\n\nfunction exitStatusReportsClosedInput(): void {}\n\nexport { redactUrlCredentials };\n\nfunction gitOperation(args: readonly string[]): string {\n\tfor (let index = 0; index < args.length; index++) {\n\t\tif (args[index] === \"-c\") index++;\n\t\telse if (!args[index]!.startsWith(\"-\")) return args[index]!;\n\t}\n\treturn \"\";\n}\n\nfunction firstLine(text: string): string {\n\treturn redactUrlCredentials(text.trim().split(\"\\n\", 1)[0] ?? \"\").slice(0, 300);\n}\n\n/** Whether the user's Git configuration (not the environment) names the ssh command Git runs. */\nasync function configuresSshCommand(options: GitRunOptions): Promise<boolean> {\n\tconst lookup = await runGit([\"config\", \"--get\", \"core.sshCommand\"], {\n\t\tcwd: options.cwd,\n\t\tenv: options.env,\n\t\tsignal: options.signal,\n\t\tallowExitCodes: [1],\n\t});\n\treturn lookup.exitCode === 0;\n}\n\n/** Kills `child`, and with it the ssh or helper processes it started when it leads its own session. */\n/** How long an aborted Git command is waited for after it was killed, before its abort is reported anyway. */\nconst ABORTED_GIT_EXIT_WAIT_MS = 10_000;\nconst PROCESS_TREE_POLL_MS = 5;\n\nfunction killChild(child: HostChildProcess, detached: boolean): void {\n\tif (detached && child.pid !== undefined) {\n\t\ttry {\n\t\t\tprocess.kill(-child.pid, \"SIGKILL\");\n\t\t} catch {\n\t\t\t// The group is already gone, or cannot be signalled: the child itself is all that is left to kill.\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t}\n\t\treturn;\n\t}\n\tchild.kill(\"SIGKILL\");\n}\n\nfunction running(pid: number): boolean {\n\ttry {\n\t\tprocess.kill(pid, 0);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction treeRunning(tree: ProcessTreeContainment | undefined): boolean {\n\ttry {\n\t\treturn tree !== undefined && tree.activeProcesses() > 0;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction taskkillTree(pid: number, deadline: number): Promise<number[]> {\n\treturn new Promise((resolve) => {\n\t\tlet output = \"\";\n\t\tlet taskkill: ChildProcess;\n\t\ttry {\n\t\t\ttaskkill = spawn(\n\t\t\t\tjoin(process.env.SystemRoot || \"C:\\\\Windows\", \"System32\", \"taskkill.exe\"),\n\t\t\t\t[\"/F\", \"/T\", \"/PID\", String(pid)],\n\t\t\t\t{ stdio: [\"ignore\", \"pipe\", \"ignore\"], windowsHide: true, env: createChildProcessEnvironment() },\n\t\t\t);\n\t\t} catch {\n\t\t\tresolve([]);\n\t\t\treturn;\n\t\t}\n\t\tconst done = () => {\n\t\t\tclearTimeout(bound);\n\t\t\tconst killed = output.split(/\\r?\\n/).map((line) => Number(/\\d+/.exec(line)?.[0]));\n\t\t\tresolve(killed.filter((id) => Number.isInteger(id) && id !== process.pid));\n\t\t};\n\t\tconst bound = setTimeout(done, Math.max(0, deadline - Date.now()));\n\t\ttaskkill.stdout?.on(\"data\", (chunk: Buffer) => {\n\t\t\toutput += chunk.toString(\"utf8\");\n\t\t});\n\t\ttaskkill.once(\"close\", done);\n\t\ttaskkill.once(\"error\", done);\n\t});\n}\n\nasync function stopCommand(\n\tchild: HostChildProcess,\n\tdetached: boolean,\n\ttree: ProcessTreeContainment | undefined,\n): Promise<void> {\n\tconst deadline = Date.now() + ABORTED_GIT_EXIT_WAIT_MS;\n\tlet closed = false;\n\tconst close = () => {\n\t\tclosed = true;\n\t};\n\tchild.once(\"close\", close);\n\tchild.once(\"error\", close);\n\tlet killed: number[] = [];\n\tif (tree?.terminate() !== true) {\n\t\tif (process.platform === \"win32\" && child.pid !== undefined) killed = await taskkillTree(child.pid, deadline);\n\t\telse killChild(child, detached);\n\t}\n\twhile (Date.now() < deadline && !(closed && !treeRunning(tree) && !killed.some(running))) {\n\t\tawait sleep(PROCESS_TREE_POLL_MS);\n\t}\n\ttree?.close();\n}\n\nasync function endTree(tree: ProcessTreeContainment | undefined): Promise<void> {\n\tif (treeRunning(tree) && tree?.terminate()) {\n\t\tconst deadline = Date.now() + ABORTED_GIT_EXIT_WAIT_MS;\n\t\twhile (Date.now() < deadline && treeRunning(tree)) await sleep(PROCESS_TREE_POLL_MS);\n\t}\n\ttree?.close();\n}\n\n/**\n * The `unreadable-path` error for a working directory the process cannot list or enter. Spawning in one fails with the\n * same `ENOENT` or `EACCES` as a missing or non-executable Git, so only the directory itself tells them apart.\n */\nasync function unreadableDirectory(directory: string): Promise<WorkspaceSnapshotError | undefined> {\n\ttry {\n\t\tawait access(directory, constants.R_OK | constants.X_OK);\n\t\treturn undefined;\n\t} catch (error) {\n\t\treturn new WorkspaceSnapshotError(\"unreadable-path\", directory, error as Error);\n\t}\n}\n\nasync function isDirectory(path: string): Promise<boolean> {\n\ttry {\n\t\treturn (await stat(path)).isDirectory();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/** The `not-a-repository` refusal for a working directory in a root excluded from snapshots, if it is in one. */\nasync function excludedDirectory(cwd: string): Promise<WorkspaceSnapshotError | undefined> {\n\tconst roots = worktreeSnapshotExcludedRoots();\n\tif (roots.length === 0) return undefined;\n\tconst directory = await canonicalizeWorktreePathAsync(cwd);\n\tfor (const root of roots) {\n\t\tconst path = relative(await canonicalizeWorktreePathAsync(root), directory);\n\t\tif (path !== \"..\" && !path.startsWith(`..${sep}`) && !isAbsolute(path)) {\n\t\t\treturn new WorkspaceSnapshotError(\"not-a-repository\", cwd);\n\t\t}\n\t}\n\treturn undefined;\n}\n\n/**\n * Runs one Git command through the injected executable. Rejects with the signal's reason when aborted, and with\n * `not-a-repository` before resolving Git when the working directory lies in a root excluded from snapshots.\n */\nexport async function runGit(args: readonly string[], options: GitRunOptions): Promise<GitRunResult> {\n\toptions.signal?.throwIfAborted();\n\tconst excluded = await excludedDirectory(options.cwd);\n\tif (excluded !== undefined) throw excluded;\n\tconst executable = scopedExecutable.getStore() ?? (await resolveExecutable(options.signal));\n\toptions.signal?.throwIfAborted();\n\tconst env = createGitEnvironment(\n\t\t{ GIT_TERMINAL_PROMPT: \"0\", GIT_OPTIONAL_LOCKS: \"0\", GCM_INTERACTIVE: \"never\" },\n\t\tcreateChildProcessEnvironment(executable.env),\n\t);\n\tObject.assign(env, options.env);\n\tif (options.nonInteractive && !env.GIT_SSH_COMMAND && !env.GIT_SSH && !(await configuresSshCommand(options))) {\n\t\tenv.GIT_SSH_COMMAND = `ssh -o BatchMode=yes -o ConnectTimeout=${NON_INTERACTIVE_SSH_CONNECT_TIMEOUT_SECONDS}`;\n\t}\n\t// A new session has no controlling terminal. Windows has no such thing, and `detached` there opens a console.\n\tconst detached = options.nonInteractive === true && process.platform !== \"win32\";\n\tconst argv = [...BASE_CONFIG, ...(options.neutral ? NEUTRAL_CONVERSION_CONFIG : []), ...args];\n\tconst spawnFailure = async (error: NodeJS.ErrnoException): Promise<Error> =>\n\t\t(error.code === \"ENOENT\" || error.code === \"EACCES\") && (await isDirectory(options.cwd))\n\t\t\t? ((await unreadableDirectory(options.cwd)) ??\n\t\t\t\tnew GitUnavailableError(\n\t\t\t\t\t{\n\t\t\t\t\t\tcode: \"not-installed\",\n\t\t\t\t\t\tplatform: process.platform,\n\t\t\t\t\t\tarch: process.arch,\n\t\t\t\t\t\tinstallDir: join(getBinDir(), \"git\"),\n\t\t\t\t\t\tinstallCommand: gitInstallCommand(process.platform),\n\t\t\t\t\t\tsystemGit: { path: executable.path, problem: \"probe-failed\" },\n\t\t\t\t\t},\n\t\t\t\t\t{ cause: error },\n\t\t\t\t))\n\t\t\t: new WorkspaceGitError(\n\t\t\t\t\t{\n\t\t\t\t\t\toperation: gitOperation(args),\n\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\texitCode: null,\n\t\t\t\t\t\tdetail: (await pathExists(options.cwd))\n\t\t\t\t\t\t\t? firstLine(error.message)\n\t\t\t\t\t\t\t: \"the working directory does not exist\",\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\treturn new Promise<GitRunResult>((resolve, reject) => {\n\t\tlet child: HostChildProcess;\n\t\ttry {\n\t\t\t// Without fork where that costs the host time in proportion to its memory (#5345).\n\t\t\tchild = spawnHostProcess(executable.path, argv, { cwd: options.cwd, env, stdio: \"pipe\", detached });\n\t\t} catch (error) {\n\t\t\t// Node throws instead of emitting `error` for some failures, such as a path component that is a file.\n\t\t\tvoid spawnFailure(error as NodeJS.ErrnoException).then(reject, reject);\n\t\t\treturn;\n\t\t}\n\t\tconst tree = child.pid === undefined ? undefined : containProcessTree(child.pid);\n\t\tconst stdout: Buffer[] = [];\n\t\tconst stderr: Buffer[] = [];\n\t\tlet settled = false;\n\t\tconst onAbort = () => {\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\t// Rejects once the process has ended, so nothing it started still works in its directories.\n\t\t\tvoid stopCommand(child, detached, tree).then(() => reject(options.signal?.reason));\n\t\t};\n\t\toptions.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t\tconst finish = (action: () => void) => {\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tif (settled) return;\n\t\t\tsettled = true;\n\t\t\taction();\n\t\t};\n\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => stdout.push(chunk));\n\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => stderr.push(chunk));\n\t\tchild.on(\"error\", (error: NodeJS.ErrnoException) =>\n\t\t\tfinish(() => {\n\t\t\t\ttree?.close();\n\t\t\t\tvoid spawnFailure(error).then(reject, reject);\n\t\t\t}),\n\t\t);\n\t\tchild.stdin?.on(\"error\", exitStatusReportsClosedInput);\n\t\tchild.on(\"close\", (code) =>\n\t\t\tfinish(() => {\n\t\t\t\tconst result = {\n\t\t\t\t\tstdout: Buffer.concat(stdout),\n\t\t\t\t\tstderr: Buffer.concat(stderr).toString(\"utf8\"),\n\t\t\t\t\texitCode: code ?? -1,\n\t\t\t\t};\n\t\t\t\tvoid endTree(tree).then(() => {\n\t\t\t\t\tif (code === 0 || (code !== null && options.allowExitCodes?.includes(code))) resolve(result);\n\t\t\t\t\telse\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew WorkspaceGitError({\n\t\t\t\t\t\t\t\toperation: gitOperation(args),\n\t\t\t\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\t\t\t\texitCode: code,\n\t\t\t\t\t\t\t\tdetail: firstLine(result.stderr),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t\tchild.stdin?.end(options.input === undefined ? undefined : options.input);\n\t});\n}\n\n/** Runs a Git command and returns its standard output as UTF-8 text without the trailing newline. */\nexport async function gitText(args: readonly string[], options: GitRunOptions): Promise<string> {\n\tconst { stdout } = await runGit(args, options);\n\treturn stdout.toString(\"utf8\").replace(/\\n$/, \"\");\n}\n\n/** Splits NUL-terminated Git output. */\nexport function nulFields(output: Buffer | string): string[] {\n\tconst text = typeof output === \"string\" ? output : output.toString(\"utf8\");\n\tconst fields = text.split(\"\\0\");\n\tif (fields.at(-1) === \"\") fields.pop();\n\treturn fields;\n}\n"]}
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
*
|
|
23
23
|
* The session records each declared MCP tool's listing (tool-records.ts). A resumed session declares those tools
|
|
24
24
|
* from their records while their servers reconnect, so its requests keep the tool list the provider cached; a call
|
|
25
|
-
* waits for the server and runs only if the server lists the same tool again.
|
|
25
|
+
* waits for the server and runs only if the server lists the same tool again. It also records the summary the
|
|
26
|
+
* `mcp_servers` section showed for each server, and shows it while the server reconnects.
|
|
26
27
|
*
|
|
27
28
|
* Problems found at startup (config errors, failed connections, servers that need a sign-in) are
|
|
28
29
|
* reported once. `/mcp` opens a manager to sign in, reconnect, enable or disable servers, and change
|
|
@@ -70,6 +71,10 @@ export interface McpServerListing {
|
|
|
70
71
|
connection?: {
|
|
71
72
|
instructions?: string;
|
|
72
73
|
};
|
|
74
|
+
/** The summary the session recorded for the server, shown instead of its instructions while it reconnects. */
|
|
75
|
+
recordedSummary?: string;
|
|
76
|
+
/** The recorded summary is the ellipsis of a longer one, so with room for one character it shows none. */
|
|
77
|
+
recordedSummaryCut?: boolean;
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
75
80
|
* The `mcp_servers` section: every enabled server with codemode or deferred tools, with how its
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,KAAK,EAIX,gBAAgB,EAChB,gBAAgB,EAGhB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAEN,KAAK,eAAe,EAGpB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EAGnB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,uBAAuB,EAAmB,MAAM,YAAY,CAAC;AAI3E,OAAO,KAAK,EAAqC,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA8B3F,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAExD,MAAM,WAAW,mBAAmB;IACnC,uFAAuF;IACvF,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACnF,qFAAqF;IACrF,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5F;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACvB;AAiED,6FAA6F;AAC7F,eAAO,MAAM,mBAAmB,gBAAgB,CAAC;AAGjD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAe9C,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAChC,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,8GAA8G;IAC9G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0GAA0G;IAC1G,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAiCD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,GAAG,MAAM,GAAG,SAAS,CAE7F;AAwFD,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,gBAAgB,CAy8CtF"}
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
*
|
|
23
23
|
* The session records each declared MCP tool's listing (tool-records.ts). A resumed session declares those tools
|
|
24
24
|
* from their records while their servers reconnect, so its requests keep the tool list the provider cached; a call
|
|
25
|
-
* waits for the server and runs only if the server lists the same tool again.
|
|
25
|
+
* waits for the server and runs only if the server lists the same tool again. It also records the summary the
|
|
26
|
+
* `mcp_servers` section showed for each server, and shows it while the server reconnects.
|
|
26
27
|
*
|
|
27
28
|
* Problems found at startup (config errors, failed connections, servers that need a sign-in) are
|
|
28
29
|
* reported once. `/mcp` opens a manager to sign in, reconnect, enable or disable servers, and change
|
|
@@ -40,7 +41,7 @@ import { TOOL_SEARCH_TOOL_NAME } from "../tool-search/tool.js";
|
|
|
40
41
|
import { getMcpToolExposure, loadMcpConfigAsync, mcpRequestTimeoutMs, updateMcpServerConfigAsync, } from "./config.js";
|
|
41
42
|
import { createMcpResourceToolDefinitions } from "./resources.js";
|
|
42
43
|
import { loadMcpRuntime } from "./runtime.lazy.js";
|
|
43
|
-
import { declaredMcpToolNames, isRecordedToolName, MCP_TOOL_RECORD_ENTRY_TYPE, RESOURCE_TOOL_NAMES, readToolRecords, recordableTool, sameListedTool, sameToolRecord,
|
|
44
|
+
import { declaredMcpToolNames, isRecordedToolName, MCP_TOOL_RECORD_ENTRY_TYPE, RESOURCE_TOOL_NAMES, readToolRecords, recordableTool, recordMatchesServer, sameListedTool, sameToolRecord, serverIdentity, } from "./tool-records.js";
|
|
44
45
|
import { createMcpToolDefinition, createMcpToolName, createMcpToolRenderers } from "./tools.js";
|
|
45
46
|
import { showMcpManager } from "./ui.js";
|
|
46
47
|
function isCodemodeDiscoveryTool(tool) {
|
|
@@ -114,12 +115,26 @@ function serverSummary(server) {
|
|
|
114
115
|
const text = server.entry.config.description?.trim() || server.connection?.instructions || "";
|
|
115
116
|
return (text.split("\n", 1)[0] ?? "").trim();
|
|
116
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* The summary a server's line shows with room for `room` characters: its configured description, else its recorded
|
|
120
|
+
* summary while it reconnects (none with room for one character when the record is a cut summary's ellipsis), else
|
|
121
|
+
* the first line of its instructions.
|
|
122
|
+
*/
|
|
123
|
+
function shownSummary(server, room) {
|
|
124
|
+
if (server.entry.config.description?.trim() || server.recordedSummary === undefined) {
|
|
125
|
+
return truncate(serverSummary(server), room);
|
|
126
|
+
}
|
|
127
|
+
return room === 1 && server.recordedSummaryCut ? "" : truncate(server.recordedSummary, room);
|
|
128
|
+
}
|
|
117
129
|
/**
|
|
118
130
|
* The `mcp_servers` section: every enabled server with codemode or deferred tools, with how its
|
|
119
131
|
* tools are reached and a one-line summary. The model learns of the servers from it, since neither
|
|
120
132
|
* codemode nor tool_search lists them. Undefined when there are no such servers.
|
|
121
133
|
*/
|
|
122
134
|
export function renderServersSection(servers) {
|
|
135
|
+
return layOutServersSection(servers)?.text;
|
|
136
|
+
}
|
|
137
|
+
function layOutServersSection(servers) {
|
|
123
138
|
const listed = servers
|
|
124
139
|
.filter((server) => isEnabled(server) && hasIndirectTools(server.entry))
|
|
125
140
|
.sort((a, b) => a.entry.name.localeCompare(b.entry.name));
|
|
@@ -138,11 +153,13 @@ export function renderServersSection(servers) {
|
|
|
138
153
|
const perServer = kept === 0
|
|
139
154
|
? 0
|
|
140
155
|
: Math.min(MAX_SERVER_DESCRIPTION_CHARS, Math.floor((MAX_SERVERS_SECTION_CHARS - size(kept)) / kept) - 2);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
156
|
+
const summarized = perServer > 0
|
|
157
|
+
? listed.slice(0, kept).map((listing) => ({ listing, summary: shownSummary(listing, perServer) }))
|
|
158
|
+
: [];
|
|
159
|
+
const lines = listed
|
|
160
|
+
.slice(0, kept)
|
|
161
|
+
.map((_, index) => (summarized[index]?.summary ? `${heads[index]}: ${summarized[index].summary}` : heads[index]));
|
|
162
|
+
return { text: [intro, ...lines, ...omitted(listed.length - kept)].join("\n"), summarized };
|
|
146
163
|
}
|
|
147
164
|
/**
|
|
148
165
|
* Whether a codemode script needs the server: it names the server's namespace, or searches,
|
|
@@ -313,7 +330,7 @@ export function createMcpExtension(options = {}) {
|
|
|
313
330
|
*/
|
|
314
331
|
const recordedOnly = new Set();
|
|
315
332
|
/** The latest records on the session's branch. */
|
|
316
|
-
let toolRecords = { tools: new Map(), resourceServers: undefined };
|
|
333
|
+
let toolRecords = { tools: new Map(), resourceServers: undefined, summaries: new Map() };
|
|
317
334
|
/** Tool records being appended, by name, and the resource servers being appended, as JSON. */
|
|
318
335
|
const recordingTools = new Map();
|
|
319
336
|
let recordingResources;
|
|
@@ -324,6 +341,16 @@ export function createMcpExtension(options = {}) {
|
|
|
324
341
|
* since it started. The resource tools stay declared for them meanwhile.
|
|
325
342
|
*/
|
|
326
343
|
const pendingResourceServers = new Set();
|
|
344
|
+
/**
|
|
345
|
+
* Servers whose recorded summary the `mcp_servers` section shows: their record matched them when the session
|
|
346
|
+
* started (see recordMatchesServer), and their connection attempt has not settled since.
|
|
347
|
+
*/
|
|
348
|
+
const pendingSummaries = new Set();
|
|
349
|
+
/**
|
|
350
|
+
* The `mcp_servers` section of the prompt being started and the options it was set in, with the summary its
|
|
351
|
+
* line shows from each server's instructions, and the servers whose line shows their recorded summary.
|
|
352
|
+
*/
|
|
353
|
+
let promptSection;
|
|
327
354
|
// Render resumed MCP calls even when their server has not connected or never connects.
|
|
328
355
|
pi.registerToolRenderer((toolName, next) => {
|
|
329
356
|
const registered = next();
|
|
@@ -420,6 +447,8 @@ export function createMcpExtension(options = {}) {
|
|
|
420
447
|
const entry = findServer(server)?.entry ?? connection.entry;
|
|
421
448
|
const previous = serverTools.get(server) ?? new Set();
|
|
422
449
|
const current = new Set();
|
|
450
|
+
// The connection's instructions replace the recorded summary.
|
|
451
|
+
pendingSummaries.delete(server);
|
|
423
452
|
// Like Codex, all tools whose names sanitize to the same name get the hash suffix, so which
|
|
424
453
|
// one would keep the plain name does not depend on the order of the list.
|
|
425
454
|
const plain = [...new Set(connection.tools.map((tool) => tool.name))].map((tool) => createMcpToolName(server, tool));
|
|
@@ -456,6 +485,7 @@ export function createMcpExtension(options = {}) {
|
|
|
456
485
|
};
|
|
457
486
|
/** Make a disabled server's tools unreachable. */
|
|
458
487
|
const hideTools = (server) => {
|
|
488
|
+
pendingSummaries.delete(server);
|
|
459
489
|
for (const name of serverTools.get(server) ?? [])
|
|
460
490
|
withdrawTool(name);
|
|
461
491
|
serverTools.set(server, new Set());
|
|
@@ -476,7 +506,7 @@ export function createMcpExtension(options = {}) {
|
|
|
476
506
|
const record = {
|
|
477
507
|
name,
|
|
478
508
|
server: listed.server,
|
|
479
|
-
|
|
509
|
+
...serverIdentity(entry),
|
|
480
510
|
tool: recordableTool(listed.tool),
|
|
481
511
|
};
|
|
482
512
|
const known = [records.tools.get(name), recordingTools.get(name)];
|
|
@@ -488,7 +518,7 @@ export function createMcpExtension(options = {}) {
|
|
|
488
518
|
let resourceServers;
|
|
489
519
|
if (pendingResourceServers.size === 0 && [...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {
|
|
490
520
|
const current = serversWithResources()
|
|
491
|
-
.map((server) => ({ server: server.entry.name,
|
|
521
|
+
.map((server) => ({ server: server.entry.name, ...serverIdentity(server.entry) }))
|
|
492
522
|
.sort((a, b) => (a.server < b.server ? -1 : a.server > b.server ? 1 : 0));
|
|
493
523
|
const json = JSON.stringify(current);
|
|
494
524
|
const known = [JSON.stringify(records.resourceServers), recordingResources];
|
|
@@ -558,7 +588,7 @@ export function createMcpExtension(options = {}) {
|
|
|
558
588
|
if (!record)
|
|
559
589
|
continue;
|
|
560
590
|
const server = findServer(record.server);
|
|
561
|
-
if (!server || !isEnabled(server) ||
|
|
591
|
+
if (!server || !isEnabled(server) || !recordMatchesServer(server.entry, record))
|
|
562
592
|
continue;
|
|
563
593
|
if (exposureFor(server.entry, record.tool.name, name) === "hidden")
|
|
564
594
|
continue;
|
|
@@ -572,14 +602,75 @@ export function createMcpExtension(options = {}) {
|
|
|
572
602
|
}
|
|
573
603
|
// The resource tools stay declared while a server that had resources reconnects.
|
|
574
604
|
if ([...RESOURCE_TOOL_NAMES].some((name) => declaredNames.has(name))) {
|
|
575
|
-
for (const
|
|
576
|
-
const server = findServer(
|
|
577
|
-
if (server && isEnabled(server) &&
|
|
578
|
-
pendingResourceServers.add(
|
|
605
|
+
for (const record of toolRecords.resourceServers ?? []) {
|
|
606
|
+
const server = findServer(record.server);
|
|
607
|
+
if (server && isEnabled(server) && recordMatchesServer(server.entry, record)) {
|
|
608
|
+
pendingResourceServers.add(record.server);
|
|
579
609
|
}
|
|
580
610
|
}
|
|
581
611
|
syncResourceTools();
|
|
582
612
|
}
|
|
613
|
+
// The `mcp_servers` section shows a server's recorded summary while the server reconnects.
|
|
614
|
+
for (const record of toolRecords.summaries.values()) {
|
|
615
|
+
const server = findServer(record.server);
|
|
616
|
+
if (server && isEnabled(server) && recordMatchesServer(server.entry, record))
|
|
617
|
+
pendingSummaries.add(record.server);
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
/** The summary record of a server whose connection attempt has not settled since the session started. */
|
|
621
|
+
const pendingSummary = (server) => {
|
|
622
|
+
const record = pendingSummaries.has(server.entry.name)
|
|
623
|
+
? toolRecords.summaries.get(server.entry.name)
|
|
624
|
+
: undefined;
|
|
625
|
+
return record && recordMatchesServer(server.entry, record) ? record : undefined;
|
|
626
|
+
};
|
|
627
|
+
/**
|
|
628
|
+
* The records that make the branch's summary records say what the conversation shows of each server once the
|
|
629
|
+
* prompt was sent: the summary its line shows from the server's instructions, or none (for a server with a
|
|
630
|
+
* configured description, no room for a summary, no line, or no longer configured). A missing record counts as
|
|
631
|
+
* no summary, and a line that shows a server's recorded summary keeps its record.
|
|
632
|
+
*/
|
|
633
|
+
const summaryUpdates = (shown, kept) => {
|
|
634
|
+
const updates = [];
|
|
635
|
+
for (const name of new Set([...shown.keys(), ...toolRecords.summaries.keys()])) {
|
|
636
|
+
if (kept.has(name))
|
|
637
|
+
continue;
|
|
638
|
+
const line = shown.get(name);
|
|
639
|
+
const record = toolRecords.summaries.get(name);
|
|
640
|
+
if (line?.summary) {
|
|
641
|
+
// Recorded for the server the line was rendered for, which may have been replaced since.
|
|
642
|
+
const { summary, cut, identity } = line;
|
|
643
|
+
if (!record ||
|
|
644
|
+
record.summary !== summary ||
|
|
645
|
+
(record.cut ?? false) !== cut ||
|
|
646
|
+
record.transport !== identity.transport ||
|
|
647
|
+
record.scope !== identity.scope) {
|
|
648
|
+
updates.push({ server: name, ...identity, summary, ...(cut ? { cut: true } : {}) });
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
else if (record?.summary) {
|
|
652
|
+
updates.push({ server: name, transport: record.transport, scope: record.scope ?? null, summary: "" });
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return updates;
|
|
656
|
+
};
|
|
657
|
+
/** Append summary records; a failed write is tried again with the next prompt, which finds them changed still. */
|
|
658
|
+
const recordSummaries = async (summaries) => {
|
|
659
|
+
const records = toolRecords;
|
|
660
|
+
try {
|
|
661
|
+
await pi.appendEntry(MCP_TOOL_RECORD_ENTRY_TYPE, { tools: [], summaries });
|
|
662
|
+
if (toolRecords === records) {
|
|
663
|
+
for (const record of summaries) {
|
|
664
|
+
if (record.summary)
|
|
665
|
+
records.summaries.set(record.server, record);
|
|
666
|
+
else
|
|
667
|
+
records.summaries.delete(record.server);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
catch {
|
|
672
|
+
// Without the record, a later resume shows the server without a summary until it connects, as before.
|
|
673
|
+
}
|
|
583
674
|
};
|
|
584
675
|
/** Withdraw the recorded tools of a server whose connection attempt settled without listing them. */
|
|
585
676
|
const withdrawUnlistedRecords = (server) => {
|
|
@@ -761,6 +852,8 @@ export function createMcpExtension(options = {}) {
|
|
|
761
852
|
withdrawUnlistedRecords(server.entry.name);
|
|
762
853
|
if (pendingResourceServers.delete(server.entry.name))
|
|
763
854
|
syncResourceTools();
|
|
855
|
+
// A server that did not connect shows no summary, as when it never connected.
|
|
856
|
+
pendingSummaries.delete(server.entry.name);
|
|
764
857
|
}
|
|
765
858
|
}
|
|
766
859
|
})();
|
|
@@ -1306,11 +1399,32 @@ export function createMcpExtension(options = {}) {
|
|
|
1306
1399
|
pi.on("before_agent_start", async (event, ctx) => {
|
|
1307
1400
|
await waitForDirectServers(ctx);
|
|
1308
1401
|
const { sections } = event.systemPromptOptions;
|
|
1309
|
-
const section =
|
|
1402
|
+
const section = layOutServersSection(servers.map((server) => {
|
|
1403
|
+
const record = pendingSummary(server);
|
|
1404
|
+
return { ...server, recordedSummary: record?.summary, recordedSummaryCut: record?.cut };
|
|
1405
|
+
}));
|
|
1310
1406
|
if (section)
|
|
1311
|
-
sections[MCP_SERVERS_SECTION] = section;
|
|
1407
|
+
sections[MCP_SERVERS_SECTION] = section.text;
|
|
1312
1408
|
else
|
|
1313
1409
|
delete sections[MCP_SERVERS_SECTION];
|
|
1410
|
+
const shown = new Map();
|
|
1411
|
+
const kept = new Set();
|
|
1412
|
+
for (const { listing, summary } of section?.summarized ?? []) {
|
|
1413
|
+
if (listing.entry.config.description?.trim())
|
|
1414
|
+
continue;
|
|
1415
|
+
if (listing.recordedSummary !== undefined)
|
|
1416
|
+
kept.add(listing.entry.name);
|
|
1417
|
+
// A summary cut down to its ellipsis is recorded as such: with less room it shows none, as the summary does.
|
|
1418
|
+
else {
|
|
1419
|
+
shown.set(listing.entry.name, {
|
|
1420
|
+
summary,
|
|
1421
|
+
cut: summary === "…" && serverSummary(listing) !== "…",
|
|
1422
|
+
identity: serverIdentity(listing.entry),
|
|
1423
|
+
});
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
// Recorded once the prompt sends its first message (message_end below).
|
|
1427
|
+
promptSection = { options: event.systemPromptOptions, text: section?.text, shown, kept };
|
|
1314
1428
|
});
|
|
1315
1429
|
// A codemode script waits for the servers it names, or for every server when it searches or
|
|
1316
1430
|
// enumerates tools, so their tools are registered before the script runs. tool_search and the
|
|
@@ -1338,8 +1452,24 @@ export function createMcpExtension(options = {}) {
|
|
|
1338
1452
|
await waitForServers(waiting, ctx.signal);
|
|
1339
1453
|
});
|
|
1340
1454
|
// Keep track of the MCP tools the transcript declares, and record the ones whose listing was not recorded yet.
|
|
1455
|
+
// The summaries the prompt's section shows are recorded once its first message ends (the section update, or
|
|
1456
|
+
// the prompt itself when the section did not change), so the records say what the conversation shows. When a
|
|
1457
|
+
// later handler replaced the section or the prompt, the conversation shows no summary. A reply first means the
|
|
1458
|
+
// prompt sent nothing, so nothing changed.
|
|
1341
1459
|
pi.on("message_end", async (event) => {
|
|
1342
1460
|
const { message } = event;
|
|
1461
|
+
if (promptSection) {
|
|
1462
|
+
const { options, text, shown, kept } = promptSection;
|
|
1463
|
+
promptSection = undefined;
|
|
1464
|
+
if (message.role === "system" || message.role === "user" || message.role === "custom") {
|
|
1465
|
+
const sent = text !== undefined &&
|
|
1466
|
+
options.forceSystemPrompt === undefined &&
|
|
1467
|
+
options.sections?.[MCP_SERVERS_SECTION] === text;
|
|
1468
|
+
const updates = sent ? summaryUpdates(shown, kept) : summaryUpdates(new Map(), new Set());
|
|
1469
|
+
if (updates.length > 0)
|
|
1470
|
+
await recordSummaries(updates);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1343
1473
|
if (message.role !== "system" || (!message.toolsAdded && !message.toolsRemoved))
|
|
1344
1474
|
return;
|
|
1345
1475
|
for (const tool of message.toolsRemoved ?? [])
|
|
@@ -1406,10 +1536,12 @@ export function createMcpExtension(options = {}) {
|
|
|
1406
1536
|
toolOwners.clear();
|
|
1407
1537
|
listedTools.clear();
|
|
1408
1538
|
recordedOnly.clear();
|
|
1409
|
-
toolRecords = { tools: new Map(), resourceServers: undefined };
|
|
1539
|
+
toolRecords = { tools: new Map(), resourceServers: undefined, summaries: new Map() };
|
|
1410
1540
|
recordingTools.clear();
|
|
1411
1541
|
recordingResources = undefined;
|
|
1412
1542
|
pendingResourceServers.clear();
|
|
1543
|
+
pendingSummaries.clear();
|
|
1544
|
+
promptSection = undefined;
|
|
1413
1545
|
declaredNames = new Set();
|
|
1414
1546
|
tokensAtSignIn.clear();
|
|
1415
1547
|
resourceToolsExposure = undefined;
|