@bastani/atomic 0.9.18 → 0.9.19-alpha.10
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 +206 -0
- package/README.md +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +51 -0
- package/dist/builtin/intercom/README.md +28 -18
- package/dist/builtin/intercom/broker/broker.ts +81 -9
- package/dist/builtin/intercom/broker/client.ts +45 -1
- package/dist/builtin/intercom/broker/framing.ts +5 -2
- package/dist/builtin/intercom/broker/group-membership.ts +4 -2
- package/dist/builtin/intercom/broker/presence-handler.ts +14 -0
- package/dist/builtin/intercom/broker/send-handler.ts +61 -6
- package/dist/builtin/intercom/broker/terminal-questions.ts +29 -0
- package/dist/builtin/intercom/index.bundle.mjs +1120 -783
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/recipient-purpose.ts +9 -0
- package/dist/builtin/intercom/recoverable-disconnect.ts +2 -3
- package/dist/builtin/intercom/retry-policy.ts +4 -2
- package/dist/builtin/intercom/skills/intercom/SKILL.md +8 -7
- package/dist/builtin/intercom/types.ts +18 -3
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/README.md +2 -0
- package/dist/builtin/mcp/index.bundle.mjs +2201 -12000
- package/dist/builtin/mcp/package.json +2 -2
- package/dist/builtin/subagents/CHANGELOG.md +57 -0
- package/dist/builtin/subagents/README.md +46 -23
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +8 -8
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
- package/dist/builtin/subagents/agents/debugger.md +2 -2
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +2 -2
- package/dist/builtin/subagents/skills/herdr/LICENSE +201 -0
- package/dist/builtin/subagents/skills/herdr/SKILL.md +202 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +41 -35
- package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1414 -656
- package/dist/builtin/web-access/CHANGELOG.md +19 -0
- package/dist/builtin/web-access/README.md +31 -24
- package/dist/builtin/web-access/index.bundle.mjs +42723 -26674
- package/dist/builtin/web-access/package.json +3 -2
- package/dist/builtin/workflows/CHANGELOG.md +131 -0
- package/dist/builtin/workflows/README.md +15 -16
- package/dist/builtin/workflows/builtin/adversarial-verification.js +5 -7
- package/dist/builtin/workflows/builtin/{chunk-hqpe2cyx.js → chunk-1jth021m.js} +85 -85
- package/dist/builtin/workflows/builtin/{chunk-7430zyas.js → chunk-2377r57g.js} +5 -3
- package/dist/builtin/workflows/builtin/{chunk-79fjkcvh.js → chunk-31j2gs7h.js} +18 -18
- package/dist/builtin/workflows/builtin/{chunk-wgccch41.js → chunk-6w6cvk6b.js} +16 -16
- package/dist/builtin/workflows/builtin/{chunk-zbekjqew.js → chunk-a2kdsqn8.js} +4 -4
- package/dist/builtin/workflows/builtin/{chunk-ze5x3d1r.js → chunk-fg9esgkj.js} +7 -7
- package/dist/builtin/workflows/builtin/{chunk-n8h4yyew.js → chunk-g0csgs7w.js} +11 -11
- package/dist/builtin/workflows/builtin/{chunk-b0v2xab1.js → chunk-ngkqkzej.js} +221 -23
- package/dist/builtin/workflows/builtin/{chunk-ed4jfn5t.js → chunk-nkrafh9s.js} +61 -61
- package/dist/builtin/workflows/builtin/{chunk-reqr3sr3.js → chunk-wf741bv3.js} +22 -22
- package/dist/builtin/workflows/builtin/{chunk-42s7sw0b.js → chunk-yeee2jrc.js} +19 -19
- package/dist/builtin/workflows/builtin/{chunk-6fqs7c01.js → chunk-z0d03ktm.js} +1 -1
- package/dist/builtin/workflows/builtin/{chunk-k3w87x8y.js → chunk-z29qbehr.js} +10 -10
- package/dist/builtin/workflows/builtin/classify-and-act.js +5 -6
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.js +3 -4
- package/dist/builtin/workflows/builtin/generate-and-filter.js +5 -6
- package/dist/builtin/workflows/builtin/goal.js +7 -8
- package/dist/builtin/workflows/builtin/index.js +20 -22
- package/dist/builtin/workflows/builtin/loop-until-done.js +5 -6
- package/dist/builtin/workflows/builtin/open-claude-design.js +3 -3
- package/dist/builtin/workflows/builtin/ralph.js +7 -8
- package/dist/builtin/workflows/builtin/steering-context.js +3 -3
- package/dist/builtin/workflows/builtin/tournament.js +5 -7
- package/dist/builtin/workflows/package.json +6 -6
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +57318 -25709
- package/dist/builtin/workflows/src/index.js +1413 -589
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +4 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +1 -1
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/startup-ui.d.ts +1 -1
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +6 -5
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +5 -1
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +1 -1
- package/dist/core/agent-session-compaction.js +1 -1
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts +1 -1
- package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
- package/dist/core/agent-session-custom-message-commit.js +33 -2
- package/dist/core/agent-session-custom-message-commit.js.map +1 -1
- package/dist/core/agent-session-delivery-forwarding.d.ts +1 -1
- package/dist/core/agent-session-delivery-forwarding.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.d.ts +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +8 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +45 -3
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +2 -2
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +22 -8
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +21 -8
- 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-persistent-custom-messages.d.ts +1 -1
- package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
- package/dist/core/agent-session-persistent-custom-messages.js +13 -3
- package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +1 -1
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts +2 -2
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +105 -18
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
- package/dist/core/agent-session-queue-pause.js +11 -0
- package/dist/core/agent-session-queue-pause.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts +1 -1
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts +13 -4
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +27 -4
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +5 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +44 -34
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-state.d.ts +1 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tasks.d.ts +14 -0
- package/dist/core/agent-session-tasks.d.ts.map +1 -0
- package/dist/core/agent-session-tasks.js +120 -0
- package/dist/core/agent-session-tasks.js.map +1 -0
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +2 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts +1 -0
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +52 -5
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +7 -0
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +3 -0
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +4 -2
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js +2 -0
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +8 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +29 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/export-html/index.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts +1 -1
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extension-session-state.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +4 -4
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +10 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +15 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/event-types.d.ts +2 -1
- package/dist/core/extensions/event-types.d.ts.map +1 -1
- package/dist/core/extensions/event-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +3 -2
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.d.ts +1 -1
- package/dist/core/extensions/loader-api.d.ts.map +1 -1
- package/dist/core/extensions/loader-api.js +10 -0
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +1 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-discovery.d.ts +1 -1
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts +1 -1
- package/dist/core/extensions/loader-host-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-host-modules.js +5 -2
- package/dist/core/extensions/loader-host-modules.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +3 -0
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/reactive-widget.d.ts +6 -0
- package/dist/core/extensions/reactive-widget.d.ts.map +1 -1
- package/dist/core/extensions/reactive-widget.js +7 -1
- package/dist/core/extensions/reactive-widget.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +12 -2
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +49 -4
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-events.d.ts +1 -1
- package/dist/core/extensions/runner-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +17 -2
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runner-shortcuts.d.ts.map +1 -1
- package/dist/core/extensions/runner-shortcuts.js +32 -3
- package/dist/core/extensions/runner-shortcuts.js.map +1 -1
- package/dist/core/extensions/runner-ui.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +17 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +69 -19
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +8 -1
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/tool-types.d.ts +1 -1
- package/dist/core/extensions/tool-types.js.map +1 -1
- package/dist/core/extensions/types.d.ts +1 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +25 -1
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/extensions/workflow-activity-hub.d.ts +25 -0
- package/dist/core/extensions/workflow-activity-hub.d.ts.map +1 -0
- package/dist/core/extensions/workflow-activity-hub.js +183 -0
- package/dist/core/extensions/workflow-activity-hub.js.map +1 -0
- package/dist/core/extensions/workflow-events.d.ts +118 -0
- package/dist/core/extensions/workflow-events.d.ts.map +1 -0
- package/dist/core/extensions/workflow-events.js +2 -0
- package/dist/core/extensions/workflow-events.js.map +1 -0
- package/dist/core/footer-data-provider.d.ts +8 -4
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +97 -11
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/keybinding-identity.d.ts +4 -0
- package/dist/core/keybinding-identity.d.ts.map +1 -0
- package/dist/core/keybinding-identity.js +10 -0
- package/dist/core/keybinding-identity.js.map +1 -0
- package/dist/core/keybindings.d.ts +37 -2
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +9 -2
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/mandatory-runtime-tools.d.ts +1 -1
- package/dist/core/mandatory-runtime-tools.js.map +1 -1
- package/dist/core/model-fallback-failures.js +2 -2
- package/dist/core/model-fallback-failures.js.map +1 -1
- package/dist/core/model-registry.d.ts +5 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +8 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-defaults.js +1 -1
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/resource-loader-assets.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -1
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +2 -2
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts +2 -0
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +231 -191
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/resource-loader-types.d.ts +4 -2
- package/dist/core/resource-loader-types.d.ts.map +1 -1
- package/dist/core/resource-loader-types.js.map +1 -1
- package/dist/core/retry-policy.d.ts +1 -0
- package/dist/core/retry-policy.d.ts.map +1 -1
- package/dist/core/retry-policy.js +2 -1
- package/dist/core/retry-policy.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +3 -3
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +2 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/settings-manager-basic-accessors.d.ts +6 -3
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +25 -8
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-core.d.ts.map +1 -1
- package/dist/core/settings-manager-core.js +10 -4
- package/dist/core/settings-manager-core.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-storage.d.ts +1 -0
- package/dist/core/settings-storage.d.ts.map +1 -1
- package/dist/core/settings-storage.js +18 -0
- package/dist/core/settings-storage.js.map +1 -1
- package/dist/core/settings-types.d.ts +17 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +6 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/agent-adapter.d.ts +44 -0
- package/dist/core/tasks/agent-adapter.d.ts.map +1 -0
- package/dist/core/tasks/agent-adapter.js +112 -0
- package/dist/core/tasks/agent-adapter.js.map +1 -0
- package/dist/core/tasks/command-output.d.ts +15 -0
- package/dist/core/tasks/command-output.d.ts.map +1 -0
- package/dist/core/tasks/command-output.js +29 -0
- package/dist/core/tasks/command-output.js.map +1 -0
- package/dist/core/tasks/completion-ordering.d.ts +11 -0
- package/dist/core/tasks/completion-ordering.d.ts.map +1 -0
- package/dist/core/tasks/completion-ordering.js +19 -0
- package/dist/core/tasks/completion-ordering.js.map +1 -0
- package/dist/core/tasks/completion.d.ts +36 -0
- package/dist/core/tasks/completion.d.ts.map +1 -0
- package/dist/core/tasks/completion.js +119 -0
- package/dist/core/tasks/completion.js.map +1 -0
- package/dist/core/tasks/contracts.d.ts +404 -0
- package/dist/core/tasks/contracts.d.ts.map +1 -0
- package/dist/core/tasks/contracts.js +2 -0
- package/dist/core/tasks/contracts.js.map +1 -0
- package/dist/core/tasks/execution-scope.d.ts +10 -0
- package/dist/core/tasks/execution-scope.d.ts.map +1 -0
- package/dist/core/tasks/execution-scope.js +27 -0
- package/dist/core/tasks/execution-scope.js.map +1 -0
- package/dist/core/tasks/owner-store.d.ts +53 -0
- package/dist/core/tasks/owner-store.d.ts.map +1 -0
- package/dist/core/tasks/owner-store.js +155 -0
- package/dist/core/tasks/owner-store.js.map +1 -0
- package/dist/core/tasks/pause.d.ts +4 -0
- package/dist/core/tasks/pause.d.ts.map +1 -0
- package/dist/core/tasks/pause.js +49 -0
- package/dist/core/tasks/pause.js.map +1 -0
- package/dist/core/tasks/supervisor.d.ts +123 -0
- package/dist/core/tasks/supervisor.d.ts.map +1 -0
- package/dist/core/tasks/supervisor.js +942 -0
- package/dist/core/tasks/supervisor.js.map +1 -0
- package/dist/core/tasks/transcript.d.ts +23 -0
- package/dist/core/tasks/transcript.d.ts.map +1 -0
- package/dist/core/tasks/transcript.js +74 -0
- package/dist/core/tasks/transcript.js.map +1 -0
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts +2 -2
- package/dist/core/tools/ask-user-question/ask-user-question.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/ask-user-question.js +8 -4
- package/dist/core/tools/ask-user-question/ask-user-question.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/build-questionnaire.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/multi-select-view.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/markdown-content-cache.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/preview/preview-block-renderer.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/submit-picker.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/components/tab-bar.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/dialog-builder.js.map +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.d.ts +1 -1
- package/dist/core/tools/ask-user-question/view/tab-content-strategy.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts +32 -3
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +198 -1
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts +25 -5
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +100 -10
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +92 -14
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/file-mutation-coordinator.d.ts +255 -0
- package/dist/core/tools/file-mutation-coordinator.d.ts.map +1 -0
- package/dist/core/tools/file-mutation-coordinator.js +300 -0
- package/dist/core/tools/file-mutation-coordinator.js.map +1 -0
- package/dist/core/tools/file-mutation-queue.d.ts +14 -1
- package/dist/core/tools/file-mutation-queue.d.ts.map +1 -1
- package/dist/core/tools/file-mutation-queue.js +15 -3
- package/dist/core/tools/file-mutation-queue.js.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/hashline.d.ts +9 -0
- package/dist/core/tools/hashline.d.ts.map +1 -1
- package/dist/core/tools/hashline.js +12 -1
- package/dist/core/tools/hashline.js.map +1 -1
- package/dist/core/tools/index.d.ts +15 -4
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +79 -12
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/kill.d.ts +17 -0
- package/dist/core/tools/kill.d.ts.map +1 -0
- package/dist/core/tools/kill.js +49 -0
- package/dist/core/tools/kill.js.map +1 -0
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/non-minting-snapshot-store.d.ts +49 -0
- package/dist/core/tools/non-minting-snapshot-store.d.ts.map +1 -0
- package/dist/core/tools/non-minting-snapshot-store.js +64 -0
- package/dist/core/tools/non-minting-snapshot-store.js.map +1 -0
- package/dist/core/tools/powershell.d.ts +100 -34
- package/dist/core/tools/powershell.d.ts.map +1 -1
- package/dist/core/tools/powershell.js +41 -11
- package/dist/core/tools/powershell.js.map +1 -1
- package/dist/core/tools/read-document-extract.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +1 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/resource-selectors.d.ts +1 -1
- package/dist/core/tools/resource-selectors.d.ts.map +1 -1
- package/dist/core/tools/resource-selectors.js +21 -10
- package/dist/core/tools/resource-selectors.js.map +1 -1
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts +1 -1
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/write.d.ts +30 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +98 -10
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +24 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -1
- package/dist/core/workflow-stage-admission.js +87 -3
- package/dist/core/workflow-stage-admission.js.map +1 -1
- package/dist/extensions/herdr/activity.d.ts +15 -0
- package/dist/extensions/herdr/activity.d.ts.map +1 -0
- package/dist/extensions/herdr/activity.js +24 -0
- package/dist/extensions/herdr/activity.js.map +1 -0
- package/dist/extensions/herdr/environment.d.ts +7 -0
- package/dist/extensions/herdr/environment.d.ts.map +1 -0
- package/dist/extensions/herdr/environment.js +6 -0
- package/dist/extensions/herdr/environment.js.map +1 -0
- package/dist/extensions/herdr/index.d.ts +9 -0
- package/dist/extensions/herdr/index.d.ts.map +1 -0
- package/dist/extensions/herdr/index.js +225 -0
- package/dist/extensions/herdr/index.js.map +1 -0
- package/dist/extensions/herdr/pane-owner.d.ts +30 -0
- package/dist/extensions/herdr/pane-owner.d.ts.map +1 -0
- package/dist/extensions/herdr/pane-owner.js +111 -0
- package/dist/extensions/herdr/pane-owner.js.map +1 -0
- package/dist/extensions/herdr/transport.d.ts +8 -0
- package/dist/extensions/herdr/transport.d.ts.map +1 -0
- package/dist/extensions/herdr/transport.js +28 -0
- package/dist/extensions/herdr/transport.js.map +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +2 -0
- package/dist/extensions/index.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index-extensions.d.ts +3 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +149 -69
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/armin.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +1 -1
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +12 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +44 -0
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts +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 +43 -8
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-editor.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts +2 -2
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts +2 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -3
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +4 -5
- package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-runtime.js +8 -6
- package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +7 -2
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +1 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-terminal-cleanup.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-types.d.ts +8 -3
- 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/chat-session-host-utils.d.ts +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-utils.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-utils.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +17 -2
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +100 -3
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +1 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +1 -1
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +12 -0
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/daxnuts.js.map +1 -1
- package/dist/modes/interactive/components/diff.js.map +1 -1
- package/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/dist/modes/interactive/components/earendil-announcement.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts +7 -6
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +27 -9
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +2 -2
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts +1 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/reserved-bottom-overlay.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/scroll-widget.d.ts +23 -0
- package/dist/modes/interactive/components/scroll-widget.d.ts.map +1 -0
- package/dist/modes/interactive/components/scroll-widget.js +61 -0
- package/dist/modes/interactive/components/scroll-widget.js.map +1 -0
- package/dist/modes/interactive/components/session-selector-header.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/show-images-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/task-completion-message.d.ts +13 -0
- package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-completion-message.js +65 -0
- package/dist/modes/interactive/components/task-completion-message.js.map +1 -0
- package/dist/modes/interactive/components/task-detail.d.ts +27 -0
- package/dist/modes/interactive/components/task-detail.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-detail.js +107 -0
- package/dist/modes/interactive/components/task-detail.js.map +1 -0
- package/dist/modes/interactive/components/task-inspector.d.ts +50 -0
- package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-inspector.js +599 -0
- package/dist/modes/interactive/components/task-inspector.js.map +1 -0
- package/dist/modes/interactive/components/task-list.d.ts +18 -0
- package/dist/modes/interactive/components/task-list.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-list.js +59 -0
- package/dist/modes/interactive/components/task-list.js.map +1 -0
- package/dist/modes/interactive/components/task-live-transcript.d.ts +17 -0
- package/dist/modes/interactive/components/task-live-transcript.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-live-transcript.js +41 -0
- package/dist/modes/interactive/components/task-live-transcript.js.map +1 -0
- package/dist/modes/interactive/components/task-navigation.d.ts +38 -0
- package/dist/modes/interactive/components/task-navigation.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-navigation.js +93 -0
- package/dist/modes/interactive/components/task-navigation.js.map +1 -0
- package/dist/modes/interactive/components/task-row.d.ts +34 -0
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -0
- package/dist/modes/interactive/components/task-row.js +165 -0
- package/dist/modes/interactive/components/task-row.js.map +1 -0
- package/dist/modes/interactive/components/theme-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/components/working-status.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +8 -2
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +3 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +9 -30
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +2 -1
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -4
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +52 -4
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +11 -3
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.js +9 -1
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +19 -0
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +7 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +10 -4
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +6 -6
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
- 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-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +3 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +4 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +30 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +33 -23
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +3 -0
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-summarization-retry-events.js +2 -2
- package/dist/modes/interactive/interactive-summarization-retry-events.js.map +1 -1
- package/dist/modes/interactive/interactive-task-projection.d.ts +13 -0
- package/dist/modes/interactive/interactive-task-projection.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-task-projection.js +72 -0
- package/dist/modes/interactive/interactive-task-projection.js.map +1 -0
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/interactive-windows-subshell.d.ts +17 -0
- package/dist/modes/interactive/interactive-windows-subshell.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-windows-subshell.js +92 -0
- package/dist/modes/interactive/interactive-windows-subshell.js.map +1 -0
- package/dist/modes/interactive/skill-command-autocomplete.d.ts +12 -0
- package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -0
- package/dist/modes/interactive/skill-command-autocomplete.js +69 -0
- package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -0
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +4 -1
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +1 -1
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +2 -2
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +1 -1
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +9 -10
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +29 -12
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts +3 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-diagnostic-view.js +11 -0
- package/dist/modes/interactive-engine/engine-diagnostic-view.js.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.d.ts +2 -2
- package/dist/modes/interactive-engine/engine-dialog-host.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-dialog-host.js +4 -1
- package/dist/modes/interactive-engine/engine-dialog-host.js.map +1 -1
- package/dist/modes/interactive-engine/engine-project-trust.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-project-trust.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-project-trust.js +28 -0
- package/dist/modes/interactive-engine/engine-project-trust.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +3 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +7 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/input-form-host.d.ts +2 -2
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-auth.d.ts +1 -1
- package/dist/modes/interactive-engine/isolated-auth.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +5 -2
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +42 -4
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +21 -1
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +53 -2
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +2 -2
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +19 -8
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.d.ts +1 -1
- package/dist/modes/interactive-engine/remote-model-catalog.js.map +1 -1
- package/dist/modes/interactive-engine/remote-renderer.d.ts +1 -1
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
- package/dist/modes/interactive-engine/session-picker-host.d.ts +2 -2
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -1
- package/dist/modes/json-event.d.ts +1 -1
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-bash-request-owners.d.ts +2 -2
- package/dist/modes/rpc/rpc-bash-request-owners.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -2
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js +2 -2
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +2 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +23 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client-waits.d.ts +1 -1
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +3 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +40 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +4 -2
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +12 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +2 -1
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +12 -2
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +4 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +35 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +17 -1
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/modes/rpc/task-ui-bridge.d.ts +9 -0
- package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -0
- package/dist/modes/rpc/task-ui-bridge.js +146 -0
- package/dist/modes/rpc/task-ui-bridge.js.map +1 -0
- package/dist/self-update-plan.js.map +1 -1
- package/dist/utils/markit.d.ts +2 -0
- package/dist/utils/markit.d.ts.map +1 -1
- package/dist/utils/markit.js +65 -5
- package/dist/utils/markit.js.map +1 -1
- package/docs/background-tasks.md +232 -0
- package/docs/build.md +51 -0
- package/docs/changelog.mdx +8 -8
- package/docs/compaction/reference.md +267 -0
- package/docs/compaction.md +39 -200
- package/docs/computer-use.md +425 -0
- package/docs/containerization.md +9 -5
- package/docs/custom-provider/api-reference.md +145 -0
- package/docs/custom-provider/oauth.md +131 -0
- package/docs/custom-provider/override.md +34 -0
- package/docs/custom-provider/registration.md +163 -0
- package/docs/custom-provider/streaming.md +214 -0
- package/docs/custom-provider.md +43 -607
- package/docs/development.md +68 -30
- package/docs/docs.json +199 -73
- package/docs/environment-variables.md +2 -2
- package/docs/extensions/api-reference.md +1003 -0
- package/docs/extensions/authoring.md +676 -0
- package/docs/extensions/events.md +793 -0
- package/docs/extensions/examples.md +94 -0
- package/docs/extensions/ui.md +470 -0
- package/docs/extensions.md +241 -2623
- package/docs/getting-started/authentication.md +55 -0
- package/docs/getting-started/first-session.md +172 -0
- package/docs/getting-started/installation.md +154 -0
- package/docs/getting-started/project-instructions.md +43 -0
- package/docs/guides/configuration.md +65 -0
- package/docs/guides/intercom.md +24 -0
- package/docs/guides/non-interactive.md +33 -0
- package/docs/guides/subagents.md +24 -0
- package/docs/guides/workflows.md +27 -0
- package/docs/guides.md +41 -0
- package/docs/herdr.md +55 -0
- package/docs/index.md +13 -44
- package/docs/intercom/operations.md +178 -0
- package/docs/intercom/reference.md +150 -0
- package/docs/intercom.md +61 -251
- package/docs/json.md +17 -0
- package/docs/keybindings.md +36 -2
- package/docs/llama-cpp.md +5 -0
- package/docs/models/artificial-analysis-index.md +89 -0
- package/docs/models/evals.md +225 -148
- package/docs/models/model-selection.md +30 -21
- package/docs/models/pareto-efficiency.md +4 -4
- package/docs/models/reference.md +601 -0
- package/docs/models.md +45 -550
- package/docs/packages/authoring.md +88 -0
- package/docs/packages/reference.md +43 -0
- package/docs/packages.md +28 -107
- package/docs/programmatic.md +29 -0
- package/docs/prompt-templates.md +11 -0
- package/docs/providers/reference.md +23 -0
- package/docs/providers.md +59 -62
- package/docs/quickstart.md +45 -239
- package/docs/reference/cli.md +252 -0
- package/docs/reference.md +52 -0
- package/docs/rpc/examples.md +64 -0
- package/docs/rpc/extension-ui.md +198 -0
- package/docs/rpc/protocol.md +1341 -0
- package/docs/rpc.md +109 -1346
- package/docs/sdk/reference.md +1090 -0
- package/docs/sdk.md +64 -756
- package/docs/session-format.md +2 -0
- package/docs/sessions.md +6 -10
- package/docs/settings.md +45 -48
- package/docs/skills/authoring.md +95 -0
- package/docs/skills/reference.md +60 -0
- package/docs/skills.md +37 -117
- package/docs/subagents/authoring.md +37 -0
- package/docs/subagents/reference.md +60 -0
- package/docs/subagents.md +90 -78
- package/docs/terminal-setup.md +1 -1
- package/docs/themes/reference.md +176 -0
- package/docs/themes.md +25 -135
- package/docs/tmux.md +7 -0
- package/docs/tools/edit.md +5 -0
- package/docs/tools.md +67 -1
- package/docs/tui/reference.md +343 -0
- package/docs/tui.md +83 -285
- package/docs/usage.md +31 -210
- package/docs/web-access.md +50 -0
- package/docs/windows.md +6 -5
- package/docs/workflows/api-reference.md +31 -12
- package/docs/workflows/authoring.md +7 -5
- package/docs/workflows/builtins.md +11 -8
- package/docs/workflows/operations.md +117 -39
- package/docs/workflows/reliable-design.md +59 -10
- package/docs/workflows/verification.md +116 -32
- package/docs/workflows.md +7 -3
- package/examples/extensions/gondolin/index.ts +116 -148
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/ssh.ts +56 -34
- package/npm-shrinkwrap.json +798 -678
- package/package.json +11 -11
- /package/dist/builtin/workflows/builtin/{chunk-cg9tmks0.js → chunk-n1910xc4.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-wpckd35c.js → chunk-rc5ec5xx.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-7at6dnkr.js → chunk-tgt0s5e5.js} +0 -0
- /package/dist/builtin/workflows/builtin/{chunk-bfkmzv9h.js → chunk-xtxcq5tj.js} +0 -0
package/dist/core/tools/write.js
CHANGED
|
@@ -4,10 +4,10 @@ import { dirname, join } from "path";
|
|
|
4
4
|
import { Type } from "typebox";
|
|
5
5
|
import { parenthesizedKeyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
6
6
|
import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
7
|
-
import { experimentalToolSamplingProperty } from "../experimental.js";
|
|
8
7
|
import { getRegisteredConflictBlocks, parseConflictBlocks } from "./conflict-registry.js";
|
|
8
|
+
import { assertPriorSessionObservation, computeLiveState, FileMutationConflict, filesystemErrorCode, isExclusiveCreateCollision, isMissingTargetError, } from "./file-mutation-coordinator.js";
|
|
9
9
|
import { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
10
|
-
import { createHashlineSnapshotStore, formatHashlineContent, recordHashlineSnapshot, stripKnownHashlineCopiedContent, stripKnownHashlineCopiedContentWithMeta, } from "./hashline.js";
|
|
10
|
+
import { createHashlineSnapshotStore, formatHashlineContent, hashlineStoreKey, normalizeHashlineContent, recordHashlineSnapshot, stripKnownHashlineCopiedContent, stripKnownHashlineCopiedContentWithMeta, } from "./hashline.js";
|
|
11
11
|
import { resolveToCwd } from "./path-utils.js";
|
|
12
12
|
import { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from "./render-utils.js";
|
|
13
13
|
import { parseArchiveSelector, parseSqliteSelector, resolveArchiveSelector, resolveInternalSelector, sqliteSelectorForPath, writeArchiveSelector, writeInternalSelector, writeSqliteSelector, } from "./resource-selectors.js";
|
|
@@ -115,8 +115,25 @@ function hashlineHeaderForWrite(path, cwd, content, store) {
|
|
|
115
115
|
return `[${snapshot.displayPath}#${snapshot.tag}]`;
|
|
116
116
|
}
|
|
117
117
|
const defaultWriteOperations = {
|
|
118
|
-
|
|
118
|
+
// `wx` is `O_CREAT | O_EXCL`, so the kernel decides the create race rather than this
|
|
119
|
+
// process. Without it the absence check above the write is advisory only.
|
|
120
|
+
writeFile: (path, content, options) => options?.exclusive
|
|
121
|
+
? fsWriteFile(path, content, { encoding: "utf-8", flag: "wx" })
|
|
122
|
+
: fsWriteFile(path, content, "utf-8"),
|
|
119
123
|
mkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => { }),
|
|
124
|
+
readFile: async (path) => {
|
|
125
|
+
try {
|
|
126
|
+
return await fsReadFile(path, "utf8");
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
// Only a genuinely free path becomes `undefined`. A directory, a locked file, or a
|
|
130
|
+
// permissions failure keeps throwing, so the caller reports it rather than treating
|
|
131
|
+
// an occupied path as available and truncating it.
|
|
132
|
+
if (isMissingTargetError(error))
|
|
133
|
+
return undefined;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
},
|
|
120
137
|
};
|
|
121
138
|
class WriteCallRenderComponent extends Text {
|
|
122
139
|
constructor() {
|
|
@@ -235,15 +252,16 @@ function formatWriteResult(result, theme) {
|
|
|
235
252
|
export function createWriteToolDefinition(cwd, options) {
|
|
236
253
|
const ops = options?.operations ?? defaultWriteOperations;
|
|
237
254
|
const hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();
|
|
255
|
+
const resolveMutationRequester = options?.resolveMutationRequester;
|
|
238
256
|
return {
|
|
239
257
|
name: "write",
|
|
240
258
|
label: "write",
|
|
241
259
|
description: "Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.",
|
|
242
260
|
promptSnippet: writeToolSystemPromptContribution.snippet,
|
|
243
261
|
promptGuidelines: [...writeToolSystemPromptContribution.guidelines],
|
|
244
|
-
|
|
262
|
+
constrainedSampling: { type: "json_schema", strict: "prefer" },
|
|
245
263
|
parameters: writeSchema,
|
|
246
|
-
async execute(
|
|
264
|
+
async execute(toolCallId, { path, content }, signal, _onUpdate, ctx) {
|
|
247
265
|
const resourceCtx = ctx;
|
|
248
266
|
const executionCwd = ctx?.cwd || cwd;
|
|
249
267
|
const archive = parseArchiveSelector(path);
|
|
@@ -322,7 +340,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
322
340
|
if (/^[a-z]+:\/\//i.test(path)) {
|
|
323
341
|
const sourcePath = path.startsWith("local://") ? resolveInternalSelector(path, executionCwd) : undefined;
|
|
324
342
|
if (sourcePath)
|
|
325
|
-
return createWriteToolDefinition(executionCwd, options).execute(
|
|
343
|
+
return createWriteToolDefinition(executionCwd, { ...options, hashlineStore }).execute(toolCallId, { path: sourcePath, content }, signal, _onUpdate, ctx);
|
|
326
344
|
const stripped = stripKnownHashlineCopiedContentWithMeta(content, "", executionCwd, hashlineStore, path);
|
|
327
345
|
await writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);
|
|
328
346
|
return {
|
|
@@ -337,7 +355,7 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
337
355
|
}
|
|
338
356
|
const absolutePath = resolveToCwd(path, executionCwd);
|
|
339
357
|
const dir = dirname(absolutePath);
|
|
340
|
-
return withFileMutationQueue(absolutePath, async () => {
|
|
358
|
+
return withFileMutationQueue(absolutePath, async (canonicalKey) => {
|
|
341
359
|
// Do not reject from an abort event listener here: that would release the
|
|
342
360
|
// mutation queue while an in-flight filesystem operation may still finish.
|
|
343
361
|
// Checking signal.aborted after each await observes the same aborts while
|
|
@@ -350,13 +368,84 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
350
368
|
// Create parent directories if needed.
|
|
351
369
|
await ops.mkdir(dir);
|
|
352
370
|
throwIfAborted();
|
|
353
|
-
const
|
|
371
|
+
const requester = resolveMutationRequester?.(toolCallId);
|
|
372
|
+
const conflict = (details) => new FileMutationConflict({
|
|
373
|
+
...details,
|
|
374
|
+
path,
|
|
375
|
+
// Registration resolved this already, so a conflict names the target
|
|
376
|
+
// without paying for a second `realpath` while holding the lock.
|
|
377
|
+
canonicalKey,
|
|
378
|
+
...(requester ? { requester } : {}),
|
|
379
|
+
});
|
|
380
|
+
let existing;
|
|
381
|
+
try {
|
|
382
|
+
existing = await ops.readFile(absolutePath);
|
|
383
|
+
}
|
|
384
|
+
catch (error) {
|
|
385
|
+
// The path is occupied by something this reader cannot open: a directory, a
|
|
386
|
+
// locked file, a permissions failure. Treating that as absence would present it
|
|
387
|
+
// as a fresh create and truncate it, so it is a conflict rather than a fallback.
|
|
388
|
+
const causeCode = filesystemErrorCode(error);
|
|
389
|
+
throw conflict({
|
|
390
|
+
reason: "target_unreadable",
|
|
391
|
+
// Nothing about the target can be described once the read fails, and
|
|
392
|
+
// inventing a size or a tag would be worse than omitting them.
|
|
393
|
+
...(causeCode ? { causeCode } : {}),
|
|
394
|
+
});
|
|
395
|
+
}
|
|
354
396
|
if (existing !== undefined && hasGeneratedMarker(existing))
|
|
355
397
|
throw new Error(`Refusing to overwrite generated file: ${path}`);
|
|
398
|
+
if (existing !== undefined) {
|
|
399
|
+
// `write` replaces a whole file rather than anchoring to a section, so nothing
|
|
400
|
+
// in the call itself says what is being replaced. Having recorded that exact
|
|
401
|
+
// content is the only evidence this session ever saw it, and the store answers
|
|
402
|
+
// for this session alone, which is what makes another agent's file land here as
|
|
403
|
+
// a conflict instead of silently losing.
|
|
404
|
+
//
|
|
405
|
+
// The read above is reused deliberately: it already happened under the queue,
|
|
406
|
+
// so re-reading would only widen the window it closes.
|
|
407
|
+
assertPriorSessionObservation({
|
|
408
|
+
canonicalKey,
|
|
409
|
+
storeKey: hashlineStoreKey(absolutePath),
|
|
410
|
+
path,
|
|
411
|
+
store: hashlineStore.snapshots,
|
|
412
|
+
// Normalized because that is the form `record` stored. Comparing raw bytes
|
|
413
|
+
// would reject every CRLF file the session had read perfectly well.
|
|
414
|
+
live: normalizeHashlineContent(existing),
|
|
415
|
+
...(requester ? { requester } : {}),
|
|
416
|
+
});
|
|
417
|
+
}
|
|
356
418
|
const stripped = stripKnownHashlineCopiedContentWithMeta(content, absolutePath, executionCwd, hashlineStore, path);
|
|
357
419
|
const writeContent = stripped.content;
|
|
358
|
-
|
|
420
|
+
if (existing === undefined) {
|
|
421
|
+
// Nothing was there a moment ago, so this is a create and says so to the
|
|
422
|
+
// filesystem. The mutation queue already excludes other Atomic writers; `O_EXCL`
|
|
423
|
+
// covers the rest, and turns what would have been a silent clobber of a file
|
|
424
|
+
// that appeared in between into a conflict that names it.
|
|
425
|
+
try {
|
|
426
|
+
await ops.writeFile(absolutePath, writeContent, { exclusive: true });
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (!isExclusiveCreateCollision(error))
|
|
430
|
+
throw error;
|
|
431
|
+
const appeared = await ops.readFile(absolutePath).catch(() => undefined);
|
|
432
|
+
throw conflict({
|
|
433
|
+
reason: "target_exists",
|
|
434
|
+
// Only describe the file when it can still be read. `computeLiveState`
|
|
435
|
+
// renders absence for `undefined`, which would contradict the reason.
|
|
436
|
+
...(appeared !== undefined ? { liveState: computeLiveState(appeared) } : {}),
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
else
|
|
441
|
+
await ops.writeFile(absolutePath, writeContent);
|
|
359
442
|
invalidateNativeSearchCache(absolutePath);
|
|
443
|
+
// Recorded as soon as the bytes land, ahead of the abort check below, because an
|
|
444
|
+
// abort cancels reporting the result rather than undoing the write. Left until
|
|
445
|
+
// after it, a cancelled-but-written file would come back as someone else's work on
|
|
446
|
+
// the next overwrite. The hashline engine already records inside `commit` for the
|
|
447
|
+
// same reason.
|
|
448
|
+
const header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);
|
|
360
449
|
let madeExecutable = false;
|
|
361
450
|
if (writeContent.startsWith("#!")) {
|
|
362
451
|
const mode = await fsStat(absolutePath)
|
|
@@ -368,7 +457,6 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
368
457
|
}
|
|
369
458
|
}
|
|
370
459
|
throwIfAborted();
|
|
371
|
-
const header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);
|
|
372
460
|
return {
|
|
373
461
|
content: [
|
|
374
462
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,EAChB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAC5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAsB,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EAErB,sBAAsB,EACtB,+BAA+B,EAC/B,uCAAuC,GACvC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE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,CAAC,OAAO,EAAE,WAAW,CAAC;oBACtD,CAAC,CAAC,oCAAoC,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;YAChF,CAAC;iBAAM,CAAC;gBACP,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC;YAC7B,CAAC;YACD,SAAS,CAAC,OAAO,CAChB,eAAe,CACd,UAAU,EACV,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,EAC5D,KAAK,EACL,SAAS,CAAC,KAAK,CACf,CACD,CAAC;YACF,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,YAAY,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO;YAC5C,MAAM,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;YACjF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACb,MAAM,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport {\n\tchmod as fsChmod,\n\tmkdir as fsMkdir,\n\treaddir as fsReaddir,\n\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.ts\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.ts\";\nimport { experimentalToolSamplingProperty } from \"../experimental.ts\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type ConflictBlock, getRegisteredConflictBlocks, parseConflictBlocks } from \"./conflict-registry.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatHashlineContent,\n\ttype HashlineSnapshotStore,\n\trecordHashlineSnapshot,\n\tstripKnownHashlineCopiedContent,\n\tstripKnownHashlineCopiedContentWithMeta,\n} from \"./hashline.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tparseArchiveSelector,\n\tparseSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n\twriteArchiveSelector,\n\twriteInternalSelector,\n\twriteSqliteSelector,\n} from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writeSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File path, writable internal resource, archive entry, SQLite row selector, or conflict resolution target.\",\n\t\t}),\n\t\tcontent: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Full replacement content. SQLite non-delete writes parse as a JSON5 object; empty content deletes a SQLite row when a row key exists.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const writeToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Create or overwrite a writable path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use write when replacing the full content of a target; use edit for source edits anchored to existing hashline snapshots.\",\n\t] as const),\n} as const);\nexport type WriteToolInput = Static<typeof writeSchema>;\nexport interface WriteToolDetails {\n\tresolvedPath?: string;\n\tmadeExecutable?: boolean;\n\tmeta?: { sourcePath?: string; diagnostics?: unknown };\n\tdiagnostics?: unknown;\n}\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string) => Promise<void>;\n\tmkdir: (dir: string) => Promise<void>;\n}\n\nasync function findConflictBlocks(root: string, limit = 100): Promise<ConflictBlock[]> {\n\tconst out: ConflictBlock[] = [];\n\tasync function walk(dir: string): Promise<void> {\n\t\tfor (const entry of await fsReaddir(dir, { withFileTypes: true }).catch(() => [])) {\n\t\t\tif (out.length >= limit || entry.name === \".git\" || entry.name === \"node_modules\") continue;\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) await walk(full);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst text = await fsReadFile(full, \"utf8\").catch(() => \"\");\n\t\t\t\tif (text.includes(\"<<<<<<<\") && text.includes(\"=======\") && text.includes(\">>>>>>>\"))\n\t\t\t\t\tout.push(...parseConflictBlocks(full, text));\n\t\t\t}\n\t\t}\n\t}\n\tawait walk(root);\n\treturn out;\n}\n/**\n * Reconcile the read-time conflict view (registry, populated by `read\n * …:conflicts`) against the live tree-walk snapshot. A registered block is\n * only trustworthy when the markers still sit at its recorded file+offset —\n * otherwise the file drifted and the id→block mapping would be wrong. When\n * any registered block is still live, resolve ids against the registered\n * ordering (what the agent actually saw); otherwise fall back to the fresh\n * tree walk. This closes the divergent id-space where `conflict://2` could\n * resolve a different block than the read displayed.\n */\nfunction reconcileConflictBlocks(live: ConflictBlock[], cwd: string): ConflictBlock[] {\n\tconst registered = getRegisteredConflictBlocks(cwd);\n\tif (registered.length === 0) return live;\n\tconst liveKeys = new Set(live.map((block) => `${block.file}\\0${block.start}\\0${block.end}`));\n\tconst registeredLive = registered.filter((block) => liveKeys.has(`${block.file}\\0${block.start}\\0${block.end}`));\n\t// If the registered view no longer matches the live tree at all, the file\n\t// changed under us — trust the live walk rather than a stale id mapping.\n\treturn registeredLive.length > 0 ? registeredLive : live;\n}\nfunction conflictReplacement(content: string, block: ConflictBlock): string[] {\n\tconst token = content.trim();\n\tif (token === \"@ours\") return block.ours;\n\tif (token === \"@theirs\") return block.theirs;\n\tif (token === \"@base\") return block.base;\n\tconst normalized = content.endsWith(\"\\n\") ? content.slice(0, -1) : content;\n\treturn normalized === \"\" ? [] : normalized.split(\"\\n\");\n}\nasync function resolveConflictBlocks(blocks: ConflictBlock[], content: string): Promise<string[]> {\n\tconst byFile = new Map<string, ConflictBlock[]>();\n\tfor (const block of blocks) byFile.set(block.file, [...(byFile.get(block.file) ?? []), block]);\n\tconst written: string[] = [];\n\tfor (const [file, fileBlocks] of byFile) {\n\t\tconst text = await fsReadFile(file, \"utf8\"),\n\t\t\tlines = text.split(\"\\n\");\n\t\tfor (const block of fileBlocks.sort((a, b) => b.start - a.start))\n\t\t\tlines.splice(block.start, block.end - block.start + 1, ...conflictReplacement(content, block));\n\t\tawait fsWriteFile(file, lines.join(\"\\n\"), \"utf8\");\n\t\twritten.push(file);\n\t}\n\treturn written;\n}\nasync function conflictSnapshotHeaders(files: string[], cwd: string, store: HashlineSnapshotStore): Promise<string[]> {\n\tconst headers: string[] = [];\n\tfor (const file of [...new Set(files)]) {\n\t\tinvalidateNativeSearchCache(file);\n\t\tconst text = await fsReadFile(file, \"utf8\").catch(() => undefined);\n\t\tif (text !== undefined)\n\t\t\theaders.push(formatHashlineContent(recordHashlineSnapshot(file, cwd, text, store)).split(\"\\n\")[0]!);\n\t}\n\treturn headers;\n}\nconst GENERATED_MARKER_BYTES = 1024;\nconst GENERATED_MARKER_LINES = 40;\nfunction hasGeneratedMarker(text: string): boolean {\n\tconst header = text.slice(0, GENERATED_MARKER_BYTES).split(\"\\n\").slice(0, GENERATED_MARKER_LINES);\n\treturn header.some((line) => /@generated|auto-generated|DO NOT EDIT|GENERATED -- do not edit/i.test(line));\n}\nfunction strippedHashlineNote(stripped: boolean): string {\n\treturn stripped ? \"\\n\\nNote: stripped copied hashline headers and line prefixes before writing.\" : \"\";\n}\nfunction hashlineHeaderForWrite(path: string, cwd: string, content: string, store: HashlineSnapshotStore): string {\n\tconst snapshot = recordHashlineSnapshot(path, cwd, content, store);\n\treturn `[${snapshot.displayPath}#${snapshot.tag}]`;\n}\nconst defaultWriteOperations: WriteOperations = {\n\twriteFile: (path, content) => fsWriteFile(path, content, \"utf-8\"),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\thashlineStore?: HashlineSnapshotStore;\n}\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\thighlightedLines: string[];\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\n\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tconst prefixHighlighted = highlightCode(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\n\nfunction rebuildWriteHighlightCacheFull(rawPath: string | null, fileContent: string): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: highlightCode(normalized, lang),\n\t};\n}\n\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tif (!cache) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (cache.lang !== lang || cache.rawPath !== rawPath) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (!fileContent.startsWith(cache.rawContent)) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache);\n\treturn cache;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.ts\").theme,\n\tcache: WriteHighlightCache | undefined,\n): string {\n\tconst rawPath = str(args?.path);\n\tconst fileContent = str(args?.content);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\")}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst renderedLines = lang\n\t\t\t? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\tconst totalLines = lines.length;\n\t\tconst maxLines = options.expanded ? lines.length : 10;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") +\n\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines, ${totalLines} total`);\n\t\t}\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.ts\").theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.\",\n\t\tpromptSnippet: writeToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...writeToolSystemPromptContribution.guidelines],\n\t\t...experimentalToolSamplingProperty(),\n\t\tparameters: writeSchema,\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\t{ path, content }: { path: string; content: string },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst archive = parseArchiveSelector(path);\n\t\t\tconst parsedSqlite = parseSqliteSelector(path);\n\t\t\tif (parsedSqlite?.table && path.includes(\"?\"))\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tif (\n\t\t\t\tparsedSqlite?.table &&\n\t\t\t\t(parsedSqlite.limit !== undefined ||\n\t\t\t\t\tparsedSqlite.offset !== undefined ||\n\t\t\t\t\tparsedSqlite.where ||\n\t\t\t\t\tparsedSqlite.order ||\n\t\t\t\t\tparsedSqlite.schema ||\n\t\t\t\t\tparsedSqlite.sampleRows !== undefined ||\n\t\t\t\t\tparsedSqlite.query)\n\t\t\t)\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tconst sqlite = sqliteSelectorForPath(path, executionCwd);\n\t\t\tif (!sqlite && parsedSqlite?.table) throw new Error(`SQLite database not found or is not SQLite: ${path}`);\n\t\t\tif (sqlite) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst message = writeSqliteSelector(sqlite, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `${message}${strippedHashlineNote(stripped.stripped)}` }],\n\t\t\t\t\tdetails: { meta: { sourcePath: sqlite.databasePath } },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (archive) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\twriteArchiveSelector(resolvedArchive, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: resolvedArchive.archivePath },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (path.startsWith(\"conflict://\")) {\n\t\t\t\tconst writeContent = stripKnownHashlineCopiedContent(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst target = decodeURIComponent(path.slice(\"conflict://\".length));\n\t\t\t\tif (!target) throw new Error(\"conflict:// target is required.\");\n\t\t\t\tif (target.includes(\"/\"))\n\t\t\t\t\tthrow new Error(\"Scoped conflict resources are read-only; write conflict://<id> or conflict://*.\");\n\t\t\t\tconst liveBlocks = await findConflictBlocks(executionCwd);\n\t\t\t\tif (liveBlocks.length === 0) throw new Error(\"No conflict markers found.\");\n\t\t\t\tconst blocks = reconcileConflictBlocks(liveBlocks, executionCwd);\n\t\t\t\tif (target === \"*\") {\n\t\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\t\tawait resolveConflictBlocks(blocks, writeContent),\n\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\thashlineStore,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Resolved ${blocks.length} conflict${blocks.length === 1 ? \"\" : \"s\"}${headers.length > 0 ? `\\n\\nSnapshots:\\n${headers.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!/^\\d+$/.test(target)) throw new Error(\"Conflict writes must target conflict://<id> or conflict://*.\");\n\t\t\t\tconst id = Number.parseInt(target, 10);\n\t\t\t\tconst block = blocks[id - 1];\n\t\t\t\tif (!block) throw new Error(`Conflict id not found: ${target}`);\n\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\tawait resolveConflictBlocks([block], writeContent),\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Resolved conflict ${target}${headers[0] ? `\\n\\n${headers[0]}` : \"\"}` }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (/^[a-z]+:\\/\\//i.test(path)) {\n\t\t\t\tconst sourcePath = path.startsWith(\"local://\") ? resolveInternalSelector(path, executionCwd) : undefined;\n\t\t\t\tif (sourcePath)\n\t\t\t\t\treturn createWriteToolDefinition(executionCwd, options).execute(\n\t\t\t\t\t\t_toolCallId,\n\t\t\t\t\t\t{ path: sourcePath, content },\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\tctx as never,\n\t\t\t\t\t);\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tawait writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {},\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst absolutePath = resolveToCwd(path, executionCwd);\n\t\t\tconst dir = dirname(absolutePath);\n\t\t\treturn withFileMutationQueue(absolutePath, async () => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\t// Create parent directories if needed.\n\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst existing = await fsReadFile(absolutePath, \"utf8\").catch(() => undefined);\n\t\t\t\tif (existing !== undefined && hasGeneratedMarker(existing))\n\t\t\t\t\tthrow new Error(`Refusing to overwrite generated file: ${path}`);\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(\n\t\t\t\t\tcontent,\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t\tpath,\n\t\t\t\t);\n\t\t\t\tconst writeContent = stripped.content;\n\t\t\t\tawait ops.writeFile(absolutePath, writeContent);\n\t\t\t\tinvalidateNativeSearchCache(absolutePath);\n\t\t\t\tlet madeExecutable = false;\n\t\t\t\tif (writeContent.startsWith(\"#!\")) {\n\t\t\t\t\tconst mode = await fsStat(absolutePath)\n\t\t\t\t\t\t.then((stat) => stat.mode)\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tif (mode !== undefined) {\n\t\t\t\t\t\tawait fsChmod(absolutePath, mode | 0o111);\n\t\t\t\t\t\tmadeExecutable = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `${header}\\nSuccessfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: absolutePath, ...(madeExecutable ? { madeExecutable } : {}) },\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as { path?: string; content?: string } | undefined;\n\t\t\tconst rawPath = str(renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = context.argsComplete\n\t\t\t\t\t? rebuildWriteHighlightCacheFull(rawPath, fileContent)\n\t\t\t\t\t: updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"write.js","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EACN,KAAK,IAAI,OAAO,EAChB,KAAK,IAAI,OAAO,EAChB,OAAO,IAAI,SAAS,EACpB,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE5F,OAAO,EAAsB,2BAA2B,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OA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M,SAAS,GAAI,OAAO,CAAC,aAAuC,IAAI,IAAI,SAAS,EAAE,CAAC;gBACtF,SAAS,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAI,OAAO,CAAC,aAAkC,IAAI,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/E,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,OAA0B;IACtE,OAAO,kBAAkB,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import type { AgentTool } from \"@earendil-works/pi-agent-core\";\nimport { Container, Text } from \"@earendil-works/pi-tui\";\nimport {\n\tchmod as fsChmod,\n\tmkdir as fsMkdir,\n\treaddir as fsReaddir,\n\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname, join } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type ConflictBlock, getRegisteredConflictBlocks, parseConflictBlocks } from \"./conflict-registry.ts\";\nimport {\n\tassertPriorSessionObservation,\n\tcomputeLiveState,\n\tFileMutationConflict,\n\ttype FileMutationConflictDetails,\n\tfilesystemErrorCode,\n\tisExclusiveCreateCollision,\n\tisMissingTargetError,\n\ttype MutationRequesterResolver,\n} from \"./file-mutation-coordinator.ts\";\nimport { withFileMutationQueue } from \"./file-mutation-queue.ts\";\nimport {\n\tcreateHashlineSnapshotStore,\n\tformatHashlineContent,\n\ttype HashlineSnapshotStore,\n\thashlineStoreKey,\n\tnormalizeHashlineContent,\n\trecordHashlineSnapshot,\n\tstripKnownHashlineCopiedContent,\n\tstripKnownHashlineCopiedContentWithMeta,\n} from \"./hashline.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\nimport { invalidArgText, normalizeDisplayText, replaceTabs, shortenPath, str } from \"./render-utils.ts\";\nimport {\n\ttype InternalResourceContext,\n\tparseArchiveSelector,\n\tparseSqliteSelector,\n\tresolveArchiveSelector,\n\tresolveInternalSelector,\n\tsqliteSelectorForPath,\n\twriteArchiveSelector,\n\twriteInternalSelector,\n\twriteSqliteSelector,\n} from \"./resource-selectors.ts\";\nimport { invalidateNativeSearchCache } from \"./search-native.ts\";\nimport { wrapToolDefinition } from \"./tool-definition-wrapper.ts\";\n\nconst writeSchema = Type.Object(\n\t{\n\t\tpath: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"File path, writable internal resource, archive entry, SQLite row selector, or conflict resolution target.\",\n\t\t}),\n\t\tcontent: Type.String({\n\t\t\tdescription:\n\t\t\t\t\"Full replacement content. SQLite non-delete writes parse as a JSON5 object; empty content deletes a SQLite row when a row key exists.\",\n\t\t}),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const writeToolSystemPromptContribution = Object.freeze({\n\tsnippet: \"Create or overwrite a writable path selector.\",\n\tguidelines: Object.freeze([\n\t\t\"Use write when replacing the full content of a target; use edit for source edits anchored to existing hashline snapshots.\",\n\t] as const),\n} as const);\nexport type WriteToolInput = Static<typeof writeSchema>;\nexport interface WriteToolDetails {\n\tresolvedPath?: string;\n\tmadeExecutable?: boolean;\n\tmeta?: { sourcePath?: string; diagnostics?: unknown };\n\tdiagnostics?: unknown;\n}\n\n/** Per-call options for {@link WriteOperations.writeFile}. */\nexport interface WriteFileOptions {\n\t/**\n\t * Create the file, failing with `EEXIST` if the path is already taken, rather than\n\t * truncating whatever is there. Requested only when the tool has just established that the\n\t * target was absent, so it closes the window between that check and the write.\n\t *\n\t * An implementation that cannot express exclusive create may ignore this and overwrite. It\n\t * then loses only the race against writers outside Atomic, since the mutation queue already\n\t * excludes writers inside it.\n\t */\n\texclusive?: boolean;\n}\n\n/**\n * Pluggable operations for the write tool.\n * Override these to delegate file writing to remote systems (for example SSH).\n */\nexport interface WriteOperations {\n\t/** Write content to a file */\n\twriteFile: (absolutePath: string, content: string, options?: WriteFileOptions) => Promise<void>;\n\tmkdir: (dir: string) => Promise<void>;\n\t/**\n\t * Current content of a path, or `undefined` when nothing is there.\n\t *\n\t * `write` reads before every write, to refuse generated files, to check that this session\n\t * has observed what it is replacing, and to decide between creating and overwriting. Those\n\t * checks have to see the same filesystem the write lands on, so this belongs here rather\n\t * than being read from local disk behind an implementation's back.\n\t *\n\t * Report absence as `undefined` and **reject** for anything else. A path that exists but\n\t * cannot be read is not the same as a free path: returning `undefined` for it would present\n\t * an unreadable file as a fresh create and truncate it.\n\t */\n\treadFile: (absolutePath: string) => Promise<string | undefined>;\n}\n\nasync function findConflictBlocks(root: string, limit = 100): Promise<ConflictBlock[]> {\n\tconst out: ConflictBlock[] = [];\n\tasync function walk(dir: string): Promise<void> {\n\t\tfor (const entry of await fsReaddir(dir, { withFileTypes: true }).catch(() => [])) {\n\t\t\tif (out.length >= limit || entry.name === \".git\" || entry.name === \"node_modules\") continue;\n\t\t\tconst full = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) await walk(full);\n\t\t\telse if (entry.isFile()) {\n\t\t\t\tconst text = await fsReadFile(full, \"utf8\").catch(() => \"\");\n\t\t\t\tif (text.includes(\"<<<<<<<\") && text.includes(\"=======\") && text.includes(\">>>>>>>\"))\n\t\t\t\t\tout.push(...parseConflictBlocks(full, text));\n\t\t\t}\n\t\t}\n\t}\n\tawait walk(root);\n\treturn out;\n}\n/**\n * Reconcile the read-time conflict view (registry, populated by `read\n * …:conflicts`) against the live tree-walk snapshot. A registered block is\n * only trustworthy when the markers still sit at its recorded file+offset —\n * otherwise the file drifted and the id→block mapping would be wrong. When\n * any registered block is still live, resolve ids against the registered\n * ordering (what the agent actually saw); otherwise fall back to the fresh\n * tree walk. This closes the divergent id-space where `conflict://2` could\n * resolve a different block than the read displayed.\n */\nfunction reconcileConflictBlocks(live: ConflictBlock[], cwd: string): ConflictBlock[] {\n\tconst registered = getRegisteredConflictBlocks(cwd);\n\tif (registered.length === 0) return live;\n\tconst liveKeys = new Set(live.map((block) => `${block.file}\\0${block.start}\\0${block.end}`));\n\tconst registeredLive = registered.filter((block) => liveKeys.has(`${block.file}\\0${block.start}\\0${block.end}`));\n\t// If the registered view no longer matches the live tree at all, the file\n\t// changed under us — trust the live walk rather than a stale id mapping.\n\treturn registeredLive.length > 0 ? registeredLive : live;\n}\nfunction conflictReplacement(content: string, block: ConflictBlock): string[] {\n\tconst token = content.trim();\n\tif (token === \"@ours\") return block.ours;\n\tif (token === \"@theirs\") return block.theirs;\n\tif (token === \"@base\") return block.base;\n\tconst normalized = content.endsWith(\"\\n\") ? content.slice(0, -1) : content;\n\treturn normalized === \"\" ? [] : normalized.split(\"\\n\");\n}\nasync function resolveConflictBlocks(blocks: ConflictBlock[], content: string): Promise<string[]> {\n\tconst byFile = new Map<string, ConflictBlock[]>();\n\tfor (const block of blocks) byFile.set(block.file, [...(byFile.get(block.file) ?? []), block]);\n\tconst written: string[] = [];\n\tfor (const [file, fileBlocks] of byFile) {\n\t\tconst text = await fsReadFile(file, \"utf8\"),\n\t\t\tlines = text.split(\"\\n\");\n\t\tfor (const block of fileBlocks.sort((a, b) => b.start - a.start))\n\t\t\tlines.splice(block.start, block.end - block.start + 1, ...conflictReplacement(content, block));\n\t\tawait fsWriteFile(file, lines.join(\"\\n\"), \"utf8\");\n\t\twritten.push(file);\n\t}\n\treturn written;\n}\nasync function conflictSnapshotHeaders(files: string[], cwd: string, store: HashlineSnapshotStore): Promise<string[]> {\n\tconst headers: string[] = [];\n\tfor (const file of [...new Set(files)]) {\n\t\tinvalidateNativeSearchCache(file);\n\t\tconst text = await fsReadFile(file, \"utf8\").catch(() => undefined);\n\t\tif (text !== undefined)\n\t\t\theaders.push(formatHashlineContent(recordHashlineSnapshot(file, cwd, text, store)).split(\"\\n\")[0]!);\n\t}\n\treturn headers;\n}\nconst GENERATED_MARKER_BYTES = 1024;\nconst GENERATED_MARKER_LINES = 40;\nfunction hasGeneratedMarker(text: string): boolean {\n\tconst header = text.slice(0, GENERATED_MARKER_BYTES).split(\"\\n\").slice(0, GENERATED_MARKER_LINES);\n\treturn header.some((line) => /@generated|auto-generated|DO NOT EDIT|GENERATED -- do not edit/i.test(line));\n}\nfunction strippedHashlineNote(stripped: boolean): string {\n\treturn stripped ? \"\\n\\nNote: stripped copied hashline headers and line prefixes before writing.\" : \"\";\n}\nfunction hashlineHeaderForWrite(path: string, cwd: string, content: string, store: HashlineSnapshotStore): string {\n\tconst snapshot = recordHashlineSnapshot(path, cwd, content, store);\n\treturn `[${snapshot.displayPath}#${snapshot.tag}]`;\n}\nconst defaultWriteOperations: WriteOperations = {\n\t// `wx` is `O_CREAT | O_EXCL`, so the kernel decides the create race rather than this\n\t// process. Without it the absence check above the write is advisory only.\n\twriteFile: (path, content, options) =>\n\t\toptions?.exclusive\n\t\t\t? fsWriteFile(path, content, { encoding: \"utf-8\", flag: \"wx\" })\n\t\t\t: fsWriteFile(path, content, \"utf-8\"),\n\tmkdir: (dir) => fsMkdir(dir, { recursive: true }).then(() => {}),\n\treadFile: async (path) => {\n\t\ttry {\n\t\t\treturn await fsReadFile(path, \"utf8\");\n\t\t} catch (error) {\n\t\t\t// Only a genuinely free path becomes `undefined`. A directory, a locked file, or a\n\t\t\t// permissions failure keeps throwing, so the caller reports it rather than treating\n\t\t\t// an occupied path as available and truncating it.\n\t\t\tif (isMissingTargetError(error)) return undefined;\n\t\t\tthrow error;\n\t\t}\n\t},\n};\n\nexport interface WriteToolOptions {\n\t/** Custom operations for file writing. Default: local filesystem */\n\toperations?: WriteOperations;\n\thashlineStore?: HashlineSnapshotStore;\n\t/** Resolves who is being rejected when a mutation conflicts. Diagnostic only. */\n\tresolveMutationRequester?: MutationRequesterResolver;\n}\n\ntype WriteHighlightCache = {\n\trawPath: string | null;\n\tlang: string;\n\trawContent: string;\n\tnormalizedLines: string[];\n\thighlightedLines: string[];\n};\n\nclass WriteCallRenderComponent extends Text {\n\tcache?: WriteHighlightCache;\n\n\tconstructor() {\n\t\tsuper(\"\", 0, 0);\n\t}\n}\n\nconst WRITE_PARTIAL_FULL_HIGHLIGHT_LINES = 50;\n\nfunction highlightSingleLine(line: string, lang: string): string {\n\tconst highlighted = highlightCode(line, lang);\n\treturn highlighted[0] ?? \"\";\n}\n\nfunction refreshWriteHighlightPrefix(cache: WriteHighlightCache): void {\n\tconst prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);\n\tif (prefixCount === 0) return;\n\tconst prefixSource = cache.normalizedLines.slice(0, prefixCount).join(\"\\n\");\n\tconst prefixHighlighted = highlightCode(prefixSource, cache.lang);\n\tfor (let i = 0; i < prefixCount; i++) {\n\t\tcache.highlightedLines[i] =\n\t\t\tprefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? \"\", cache.lang);\n\t}\n}\n\nfunction rebuildWriteHighlightCacheFull(rawPath: string | null, fileContent: string): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tconst displayContent = normalizeDisplayText(fileContent);\n\tconst normalized = replaceTabs(displayContent);\n\treturn {\n\t\trawPath,\n\t\tlang,\n\t\trawContent: fileContent,\n\t\tnormalizedLines: normalized.split(\"\\n\"),\n\t\thighlightedLines: highlightCode(normalized, lang),\n\t};\n}\n\nfunction updateWriteHighlightCacheIncremental(\n\tcache: WriteHighlightCache | undefined,\n\trawPath: string | null,\n\tfileContent: string,\n): WriteHighlightCache | undefined {\n\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\tif (!lang) return undefined;\n\tif (!cache) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (cache.lang !== lang || cache.rawPath !== rawPath) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (!fileContent.startsWith(cache.rawContent)) return rebuildWriteHighlightCacheFull(rawPath, fileContent);\n\tif (fileContent.length === cache.rawContent.length) return cache;\n\n\tconst deltaRaw = fileContent.slice(cache.rawContent.length);\n\tconst deltaDisplay = normalizeDisplayText(deltaRaw);\n\tconst deltaNormalized = replaceTabs(deltaDisplay);\n\tcache.rawContent = fileContent;\n\tif (cache.normalizedLines.length === 0) {\n\t\tcache.normalizedLines.push(\"\");\n\t\tcache.highlightedLines.push(\"\");\n\t}\n\n\tconst segments = deltaNormalized.split(\"\\n\");\n\tconst lastIndex = cache.normalizedLines.length - 1;\n\tcache.normalizedLines[lastIndex] += segments[0];\n\tcache.highlightedLines[lastIndex] = highlightSingleLine(cache.normalizedLines[lastIndex], cache.lang);\n\tfor (let i = 1; i < segments.length; i++) {\n\t\tcache.normalizedLines.push(segments[i]);\n\t\tcache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));\n\t}\n\trefreshWriteHighlightPrefix(cache);\n\treturn cache;\n}\n\nfunction trimTrailingEmptyLines(lines: string[]): string[] {\n\tlet end = lines.length;\n\twhile (end > 0 && lines[end - 1] === \"\") {\n\t\tend--;\n\t}\n\treturn lines.slice(0, end);\n}\n\nfunction formatWriteCall(\n\targs: { path?: string; content?: string } | undefined,\n\toptions: ToolRenderResultOptions,\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n\tcache: WriteHighlightCache | undefined,\n): string {\n\tconst rawPath = str(args?.path);\n\tconst fileContent = str(args?.content);\n\tconst path = rawPath !== null ? shortenPath(rawPath) : null;\n\tconst invalidArg = invalidArgText(theme);\n\tlet text = `${theme.fg(\"toolTitle\", theme.bold(\"write\"))} ${path === null ? invalidArg : path ? theme.fg(\"accent\", path) : theme.fg(\"toolOutput\", \"...\")}`;\n\n\tif (fileContent === null) {\n\t\ttext += `\\n\\n${theme.fg(\"error\", \"[invalid content arg - expected string]\")}`;\n\t} else if (fileContent) {\n\t\tconst lang = rawPath ? getLanguageFromPath(rawPath) : undefined;\n\t\tconst renderedLines = lang\n\t\t\t? (cache?.highlightedLines ?? highlightCode(replaceTabs(normalizeDisplayText(fileContent)), lang))\n\t\t\t: normalizeDisplayText(fileContent).split(\"\\n\");\n\t\tconst lines = trimTrailingEmptyLines(renderedLines);\n\t\tconst totalLines = lines.length;\n\t\tconst maxLines = options.expanded ? lines.length : 10;\n\t\tconst displayLines = lines.slice(0, maxLines);\n\t\tconst remaining = lines.length - maxLines;\n\t\ttext += `\\n\\n${displayLines.map((line) => (lang ? line : theme.fg(\"toolOutput\", replaceTabs(line)))).join(\"\\n\")}`;\n\t\tif (remaining > 0) {\n\t\t\ttext +=\n\t\t\t\ttheme.fg(\"muted\", \"\\n... \") +\n\t\t\t\tparenthesizedKeyHint(\"app.tools.expand\", \"Expand\", `${remaining} more lines, ${totalLines} total`);\n\t\t}\n\t}\n\n\treturn text;\n}\n\nfunction formatWriteResult(\n\tresult: { content: Array<{ type: string; text?: string; data?: string; mimeType?: string }>; isError?: boolean },\n\ttheme: typeof import(\"../../modes/interactive/theme/theme.js\").theme,\n): string | undefined {\n\tif (!result.isError) {\n\t\treturn undefined;\n\t}\n\tconst output = result.content\n\t\t.filter((c) => c.type === \"text\")\n\t\t.map((c) => c.text || \"\")\n\t\t.join(\"\\n\");\n\tif (!output) {\n\t\treturn undefined;\n\t}\n\treturn `\\n${theme.fg(\"error\", output)}`;\n}\n\nexport function createWriteToolDefinition(\n\tcwd: string,\n\toptions?: WriteToolOptions,\n): ToolDefinition<typeof writeSchema, WriteToolDetails | undefined> {\n\tconst ops = options?.operations ?? defaultWriteOperations;\n\tconst hashlineStore = options?.hashlineStore ?? createHashlineSnapshotStore();\n\tconst resolveMutationRequester = options?.resolveMutationRequester;\n\treturn {\n\t\tname: \"write\",\n\t\tlabel: \"write\",\n\t\tdescription:\n\t\t\t\"Create or overwrite a file, writable internal resource, archive entry, SQLite row, or merge-conflict resolution.\",\n\t\tpromptSnippet: writeToolSystemPromptContribution.snippet,\n\t\tpromptGuidelines: [...writeToolSystemPromptContribution.guidelines],\n\t\tconstrainedSampling: { type: \"json_schema\", strict: \"prefer\" },\n\t\tparameters: writeSchema,\n\t\tasync execute(\n\t\t\ttoolCallId,\n\t\t\t{ path, content }: { path: string; content: string },\n\t\t\tsignal?: AbortSignal,\n\t\t\t_onUpdate?,\n\t\t\tctx?: ExtensionContext,\n\t\t) {\n\t\t\tconst resourceCtx = ctx as InternalResourceContext | undefined;\n\t\t\tconst executionCwd = ctx?.cwd || cwd;\n\t\t\tconst archive = parseArchiveSelector(path);\n\t\t\tconst parsedSqlite = parseSqliteSelector(path);\n\t\t\tif (parsedSqlite?.table && path.includes(\"?\"))\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tif (\n\t\t\t\tparsedSqlite?.table &&\n\t\t\t\t(parsedSqlite.limit !== undefined ||\n\t\t\t\t\tparsedSqlite.offset !== undefined ||\n\t\t\t\t\tparsedSqlite.where ||\n\t\t\t\t\tparsedSqlite.order ||\n\t\t\t\t\tparsedSqlite.schema ||\n\t\t\t\t\tparsedSqlite.sampleRows !== undefined ||\n\t\t\t\t\tparsedSqlite.query)\n\t\t\t)\n\t\t\t\tthrow new Error(\"SQLite write selectors must not include query parameters.\");\n\t\t\tconst sqlite = sqliteSelectorForPath(path, executionCwd);\n\t\t\tif (!sqlite && parsedSqlite?.table) throw new Error(`SQLite database not found or is not SQLite: ${path}`);\n\t\t\tif (sqlite) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst message = writeSqliteSelector(sqlite, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `${message}${strippedHashlineNote(stripped.stripped)}` }],\n\t\t\t\t\tdetails: { meta: { sourcePath: sqlite.databasePath } },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (archive) {\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst resolvedArchive = resolveArchiveSelector(archive, executionCwd);\n\t\t\t\twriteArchiveSelector(resolvedArchive, stripped.content);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: resolvedArchive.archivePath },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (path.startsWith(\"conflict://\")) {\n\t\t\t\tconst writeContent = stripKnownHashlineCopiedContent(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tconst target = decodeURIComponent(path.slice(\"conflict://\".length));\n\t\t\t\tif (!target) throw new Error(\"conflict:// target is required.\");\n\t\t\t\tif (target.includes(\"/\"))\n\t\t\t\t\tthrow new Error(\"Scoped conflict resources are read-only; write conflict://<id> or conflict://*.\");\n\t\t\t\tconst liveBlocks = await findConflictBlocks(executionCwd);\n\t\t\t\tif (liveBlocks.length === 0) throw new Error(\"No conflict markers found.\");\n\t\t\t\tconst blocks = reconcileConflictBlocks(liveBlocks, executionCwd);\n\t\t\t\tif (target === \"*\") {\n\t\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\t\tawait resolveConflictBlocks(blocks, writeContent),\n\t\t\t\t\t\texecutionCwd,\n\t\t\t\t\t\thashlineStore,\n\t\t\t\t\t);\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\t\ttext: `Resolved ${blocks.length} conflict${blocks.length === 1 ? \"\" : \"s\"}${headers.length > 0 ? `\\n\\nSnapshots:\\n${headers.join(\"\\n\")}` : \"\"}`,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\tdetails: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tif (!/^\\d+$/.test(target)) throw new Error(\"Conflict writes must target conflict://<id> or conflict://*.\");\n\t\t\t\tconst id = Number.parseInt(target, 10);\n\t\t\t\tconst block = blocks[id - 1];\n\t\t\t\tif (!block) throw new Error(`Conflict id not found: ${target}`);\n\t\t\t\tconst headers = await conflictSnapshotHeaders(\n\t\t\t\t\tawait resolveConflictBlocks([block], writeContent),\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: `Resolved conflict ${target}${headers[0] ? `\\n\\n${headers[0]}` : \"\"}` }],\n\t\t\t\t\tdetails: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (/^[a-z]+:\\/\\//i.test(path)) {\n\t\t\t\tconst sourcePath = path.startsWith(\"local://\") ? resolveInternalSelector(path, executionCwd) : undefined;\n\t\t\t\tif (sourcePath)\n\t\t\t\t\treturn createWriteToolDefinition(executionCwd, { ...options, hashlineStore }).execute(\n\t\t\t\t\t\ttoolCallId,\n\t\t\t\t\t\t{ path: sourcePath, content },\n\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t_onUpdate,\n\t\t\t\t\t\tctx as never,\n\t\t\t\t\t);\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(content, \"\", executionCwd, hashlineStore, path);\n\t\t\t\tawait writeInternalSelector(path, executionCwd, stripped.content, resourceCtx);\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `Successfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: {},\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst absolutePath = resolveToCwd(path, executionCwd);\n\t\t\tconst dir = dirname(absolutePath);\n\t\t\treturn withFileMutationQueue(absolutePath, async (canonicalKey) => {\n\t\t\t\t// Do not reject from an abort event listener here: that would release the\n\t\t\t\t// mutation queue while an in-flight filesystem operation may still finish.\n\t\t\t\t// Checking signal.aborted after each await observes the same aborts while\n\t\t\t\t// keeping the queue locked until the current operation has settled.\n\t\t\t\tconst throwIfAborted = (): void => {\n\t\t\t\t\tif (signal?.aborted) throw new Error(\"Operation aborted\");\n\t\t\t\t};\n\n\t\t\t\tthrowIfAborted();\n\t\t\t\t// Create parent directories if needed.\n\t\t\t\tawait ops.mkdir(dir);\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\tconst requester = resolveMutationRequester?.(toolCallId);\n\t\t\t\tconst conflict = (details: Omit<FileMutationConflictDetails, \"path\" | \"canonicalKey\" | \"requester\">) =>\n\t\t\t\t\tnew FileMutationConflict({\n\t\t\t\t\t\t...details,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\t// Registration resolved this already, so a conflict names the target\n\t\t\t\t\t\t// without paying for a second `realpath` while holding the lock.\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\n\t\t\t\tlet existing: string | undefined;\n\t\t\t\ttry {\n\t\t\t\t\texisting = await ops.readFile(absolutePath);\n\t\t\t\t} catch (error) {\n\t\t\t\t\t// The path is occupied by something this reader cannot open: a directory, a\n\t\t\t\t\t// locked file, a permissions failure. Treating that as absence would present it\n\t\t\t\t\t// as a fresh create and truncate it, so it is a conflict rather than a fallback.\n\t\t\t\t\tconst causeCode = filesystemErrorCode(error);\n\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\treason: \"target_unreadable\",\n\t\t\t\t\t\t// Nothing about the target can be described once the read fails, and\n\t\t\t\t\t\t// inventing a size or a tag would be worse than omitting them.\n\t\t\t\t\t\t...(causeCode ? { causeCode } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (existing !== undefined && hasGeneratedMarker(existing))\n\t\t\t\t\tthrow new Error(`Refusing to overwrite generated file: ${path}`);\n\t\t\t\tif (existing !== undefined) {\n\t\t\t\t\t// `write` replaces a whole file rather than anchoring to a section, so nothing\n\t\t\t\t\t// in the call itself says what is being replaced. Having recorded that exact\n\t\t\t\t\t// content is the only evidence this session ever saw it, and the store answers\n\t\t\t\t\t// for this session alone, which is what makes another agent's file land here as\n\t\t\t\t\t// a conflict instead of silently losing.\n\t\t\t\t\t//\n\t\t\t\t\t// The read above is reused deliberately: it already happened under the queue,\n\t\t\t\t\t// so re-reading would only widen the window it closes.\n\t\t\t\t\tassertPriorSessionObservation({\n\t\t\t\t\t\tcanonicalKey,\n\t\t\t\t\t\tstoreKey: hashlineStoreKey(absolutePath),\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tstore: hashlineStore.snapshots,\n\t\t\t\t\t\t// Normalized because that is the form `record` stored. Comparing raw bytes\n\t\t\t\t\t\t// would reject every CRLF file the session had read perfectly well.\n\t\t\t\t\t\tlive: normalizeHashlineContent(existing),\n\t\t\t\t\t\t...(requester ? { requester } : {}),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst stripped = stripKnownHashlineCopiedContentWithMeta(\n\t\t\t\t\tcontent,\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\texecutionCwd,\n\t\t\t\t\thashlineStore,\n\t\t\t\t\tpath,\n\t\t\t\t);\n\t\t\t\tconst writeContent = stripped.content;\n\t\t\t\tif (existing === undefined) {\n\t\t\t\t\t// Nothing was there a moment ago, so this is a create and says so to the\n\t\t\t\t\t// filesystem. The mutation queue already excludes other Atomic writers; `O_EXCL`\n\t\t\t\t\t// covers the rest, and turns what would have been a silent clobber of a file\n\t\t\t\t\t// that appeared in between into a conflict that names it.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait ops.writeFile(absolutePath, writeContent, { exclusive: true });\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (!isExclusiveCreateCollision(error)) throw error;\n\t\t\t\t\t\tconst appeared = await ops.readFile(absolutePath).catch(() => undefined);\n\t\t\t\t\t\tthrow conflict({\n\t\t\t\t\t\t\treason: \"target_exists\",\n\t\t\t\t\t\t\t// Only describe the file when it can still be read. `computeLiveState`\n\t\t\t\t\t\t\t// renders absence for `undefined`, which would contradict the reason.\n\t\t\t\t\t\t\t...(appeared !== undefined ? { liveState: computeLiveState(appeared) } : {}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else await ops.writeFile(absolutePath, writeContent);\n\t\t\t\tinvalidateNativeSearchCache(absolutePath);\n\t\t\t\t// Recorded as soon as the bytes land, ahead of the abort check below, because an\n\t\t\t\t// abort cancels reporting the result rather than undoing the write. Left until\n\t\t\t\t// after it, a cancelled-but-written file would come back as someone else's work on\n\t\t\t\t// the next overwrite. The hashline engine already records inside `commit` for the\n\t\t\t\t// same reason.\n\t\t\t\tconst header = hashlineHeaderForWrite(absolutePath, executionCwd, writeContent, hashlineStore);\n\t\t\t\tlet madeExecutable = false;\n\t\t\t\tif (writeContent.startsWith(\"#!\")) {\n\t\t\t\t\tconst mode = await fsStat(absolutePath)\n\t\t\t\t\t\t.then((stat) => stat.mode)\n\t\t\t\t\t\t.catch(() => undefined);\n\t\t\t\t\tif (mode !== undefined) {\n\t\t\t\t\t\tawait fsChmod(absolutePath, mode | 0o111);\n\t\t\t\t\t\tmadeExecutable = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrowIfAborted();\n\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\t\ttext: `${header}\\nSuccessfully wrote to ${path}${strippedHashlineNote(stripped.stripped)}`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tdetails: { resolvedPath: absolutePath, ...(madeExecutable ? { madeExecutable } : {}) },\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\trenderCall(args, theme, context) {\n\t\t\tconst renderArgs = args as { path?: string; content?: string } | undefined;\n\t\t\tconst rawPath = str(renderArgs?.path);\n\t\t\tconst fileContent = str(renderArgs?.content);\n\t\t\tconst component =\n\t\t\t\t(context.lastComponent as WriteCallRenderComponent | undefined) ?? new WriteCallRenderComponent();\n\t\t\tif (fileContent !== null) {\n\t\t\t\tcomponent.cache = context.argsComplete\n\t\t\t\t\t? rebuildWriteHighlightCacheFull(rawPath, fileContent)\n\t\t\t\t\t: updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent);\n\t\t\t} else {\n\t\t\t\tcomponent.cache = undefined;\n\t\t\t}\n\t\t\tcomponent.setText(\n\t\t\t\tformatWriteCall(\n\t\t\t\t\trenderArgs,\n\t\t\t\t\t{ expanded: context.expanded, isPartial: context.isPartial },\n\t\t\t\t\ttheme,\n\t\t\t\t\tcomponent.cache,\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn component;\n\t\t},\n\t\trenderResult(result, _options, theme, context) {\n\t\t\tconst output = formatWriteResult({ ...result, isError: context.isError }, theme);\n\t\t\tif (!output) {\n\t\t\t\tconst component = (context.lastComponent as Container | undefined) ?? new Container();\n\t\t\t\tcomponent.clear();\n\t\t\t\treturn component;\n\t\t\t}\n\t\t\tconst text = (context.lastComponent as Text | undefined) ?? new Text(\"\", 0, 0);\n\t\t\ttext.setText(output);\n\t\t\treturn text;\n\t\t},\n\t};\n}\n\nexport function createWriteTool(cwd: string, options?: WriteToolOptions): AgentTool<typeof writeSchema> {\n\treturn wrapToolDefinition(createWriteToolDefinition(cwd, options));\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AgentTaskHost, type AgentTaskHostBinding } from "./tasks/agent-adapter.js";
|
|
1
2
|
export type WorkflowStageAdmissionDecision = "admitted" | "late" | "duplicate";
|
|
2
3
|
export interface WorkflowStageAdmissionResult {
|
|
3
4
|
readonly decision: WorkflowStageAdmissionDecision;
|
|
@@ -22,13 +23,36 @@ export declare class WorkflowStageAdmissionBoundary {
|
|
|
22
23
|
private closePromise;
|
|
23
24
|
private readonly closeController;
|
|
24
25
|
private readonly ownedSubagentRunIds;
|
|
26
|
+
private readonly stageAttemptId;
|
|
27
|
+
private taskScope;
|
|
28
|
+
private taskHost;
|
|
29
|
+
private readonly messageDeliveryContext;
|
|
30
|
+
private readonly messageAdmissionContext;
|
|
31
|
+
private readonly messageDeliveries;
|
|
32
|
+
private messageDeliveryTail;
|
|
33
|
+
private taskClose;
|
|
34
|
+
/** Called by the actual stage session; replacement sessions retain the original identity. */
|
|
35
|
+
bindTaskIdentity(sessionId: string, runId: string, stageId: string): void;
|
|
36
|
+
/** Trusted companion integration only; the existing launch guard remains mandatory. */
|
|
37
|
+
bindAgentTaskHost(binding: Omit<AgentTaskHostBinding, "scope">): AgentTaskHost;
|
|
38
|
+
hasAgentTaskHost(): boolean;
|
|
25
39
|
/** Aborts synchronously when close begins so stage-owned work can terminate before late delivery. */
|
|
26
40
|
get closeSignal(): AbortSignal;
|
|
27
41
|
private readonly drainAdmittedWork;
|
|
28
42
|
constructor(drainAdmittedWork?: (() => Promise<void>) | undefined, completedKeys?: Iterable<string>);
|
|
29
43
|
static restore(entries: Iterable<PersistedWorkflowStageAdmission>, drainAdmittedWork?: () => Promise<void>): WorkflowStageAdmissionBoundary;
|
|
44
|
+
/** One FIFO position for an external operation, including its retry waits. */
|
|
45
|
+
runMessageDelivery(deliver: () => void | Promise<void>, routeLate?: () => void | Promise<void>, preserveDestination?: boolean): Promise<void>;
|
|
46
|
+
/** Reentrant SDK commits stay inside their producer's FIFO position. */
|
|
47
|
+
serializeMessageDelivery(deliver: () => void | Promise<void>): Promise<void>;
|
|
48
|
+
/** Excludes tracked model turns: joining those from a native poll would deadlock. */
|
|
49
|
+
waitForMessageDeliveries(): Promise<void>;
|
|
50
|
+
hasMessageDeliveries(): boolean;
|
|
30
51
|
admit(key: string | undefined, deliver: () => void | Promise<void>, routeLate: () => void | Promise<void>): WorkflowStageAdmissionResult;
|
|
31
52
|
trackAdmittedWork(completion: Promise<void>): void;
|
|
53
|
+
/** Join already-reserved queue commits before a native turn polls its input. */
|
|
54
|
+
waitForPendingDeliveries(): Promise<void>;
|
|
55
|
+
hasPendingDeliveries(): boolean;
|
|
32
56
|
registerOwnedSubagentRun(runId: string): void;
|
|
33
57
|
ownsSubagentRun(runId: string): boolean;
|
|
34
58
|
isOpen(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-stage-admission.d.ts","sourceRoot":"","sources":["../../src/core/workflow-stage-admission.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,8BAA8B,GAAG,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/E,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,QAAQ,EAAE,8BAA8B,CAAC;IAClD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC;AAED;;;;;GAKG;AAEH,MAAM,WAAW,+BAA+B;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACpC;AACD,qBAAa,8BAA8B;IAC1C,OAAO,CAAC,IAAI,CAAQ;IACpB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;IACpD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmC;IACrE,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAyB;IACzD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAqB;
|
|
1
|
+
{"version":3,"file":"workflow-stage-admission.d.ts","sourceRoot":"","sources":["../../src/core/workflow-stage-admission.ts"],"names":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1E,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE9C;IAED,oBAAoB,IAAI,OAAO,CAE9B;IAED,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE5C;IAED,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtC;IAED,MAAM,IAAI,OAAO,CAEhB;IAED,IAAI,IAAI,IAAI,CAGX;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrB;YAEa,WAAW;IAOzB,OAAO,CAAC,MAAM;CAOd"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { AgentTaskHost } from "./tasks/agent-adapter.js";
|
|
2
4
|
export class WorkflowStageAdmissionBoundary {
|
|
5
|
+
/** Called by the actual stage session; replacement sessions retain the original identity. */
|
|
6
|
+
bindTaskIdentity(sessionId, runId, stageId) {
|
|
7
|
+
this.taskScope ??= { kind: "workflow-stage", sessionId, runId, stageId, stageAttemptId: this.stageAttemptId };
|
|
8
|
+
}
|
|
9
|
+
/** Trusted companion integration only; the existing launch guard remains mandatory. */
|
|
10
|
+
bindAgentTaskHost(binding) {
|
|
11
|
+
if (!this.open)
|
|
12
|
+
throw new Error("Workflow stage generation is closed");
|
|
13
|
+
if (!this.taskScope)
|
|
14
|
+
throw new Error("Workflow stage task identity is not bound");
|
|
15
|
+
this.taskHost ??= new AgentTaskHost({ ...binding, scope: this.taskScope });
|
|
16
|
+
this.taskHost.updateBinding(binding);
|
|
17
|
+
return this.taskHost;
|
|
18
|
+
}
|
|
19
|
+
hasAgentTaskHost() {
|
|
20
|
+
return this.taskHost !== undefined;
|
|
21
|
+
}
|
|
3
22
|
/** Aborts synchronously when close begins so stage-owned work can terminate before late delivery. */
|
|
4
23
|
get closeSignal() {
|
|
5
24
|
return this.closeController.signal;
|
|
@@ -11,6 +30,10 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
11
30
|
this.invocationContext = new AsyncLocalStorage();
|
|
12
31
|
this.closeController = new AbortController();
|
|
13
32
|
this.ownedSubagentRunIds = new Set();
|
|
33
|
+
this.stageAttemptId = randomUUID();
|
|
34
|
+
this.messageDeliveryContext = new AsyncLocalStorage();
|
|
35
|
+
this.messageAdmissionContext = new AsyncLocalStorage();
|
|
36
|
+
this.messageDeliveries = new Set();
|
|
14
37
|
this.drainAdmittedWork = drainAdmittedWork ?? (async () => { });
|
|
15
38
|
this.completed = new Set(completedKeys);
|
|
16
39
|
}
|
|
@@ -19,6 +42,55 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
19
42
|
? [entry.stageAdmissionKey]
|
|
20
43
|
: []));
|
|
21
44
|
}
|
|
45
|
+
/** One FIFO position for an external operation, including its retry waits. */
|
|
46
|
+
runMessageDelivery(deliver, routeLate, preserveDestination = false) {
|
|
47
|
+
const late = routeLate ??
|
|
48
|
+
(() => {
|
|
49
|
+
throw new Error("Message admission is closed");
|
|
50
|
+
});
|
|
51
|
+
const invoke = () => {
|
|
52
|
+
if (!preserveDestination)
|
|
53
|
+
return deliver();
|
|
54
|
+
// Stage close drains the destination reserved at arrival. SDK commits
|
|
55
|
+
// inside this operation must not be reclassified as late on retry or
|
|
56
|
+
// after waiting for an earlier FIFO slot. Revoke on settlement so detached
|
|
57
|
+
// descendants cannot admit new work into a closed generation.
|
|
58
|
+
const reservation = { active: true };
|
|
59
|
+
return this.messageAdmissionContext.run(reservation, async () => {
|
|
60
|
+
try {
|
|
61
|
+
await deliver();
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
reservation.active = false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
return this.admit(undefined, () => this.serializeMessageDelivery(invoke), late).completion;
|
|
69
|
+
}
|
|
70
|
+
/** Reentrant SDK commits stay inside their producer's FIFO position. */
|
|
71
|
+
serializeMessageDelivery(deliver) {
|
|
72
|
+
if (this.messageDeliveryContext.getStore())
|
|
73
|
+
return this.invoke(deliver);
|
|
74
|
+
const invoke = () => this.messageDeliveryContext.run(true, () => this.invoke(deliver));
|
|
75
|
+
const delivery = this.messageDeliveryTail ? this.messageDeliveryTail.then(invoke) : invoke();
|
|
76
|
+
const settled = delivery.catch(() => undefined);
|
|
77
|
+
this.messageDeliveryTail = settled;
|
|
78
|
+
this.messageDeliveries.add(settled);
|
|
79
|
+
void settled.then(() => {
|
|
80
|
+
this.messageDeliveries.delete(settled);
|
|
81
|
+
if (this.messageDeliveryTail === settled)
|
|
82
|
+
this.messageDeliveryTail = undefined;
|
|
83
|
+
});
|
|
84
|
+
return delivery;
|
|
85
|
+
}
|
|
86
|
+
/** Excludes tracked model turns: joining those from a native poll would deadlock. */
|
|
87
|
+
async waitForMessageDeliveries() {
|
|
88
|
+
while (this.messageDeliveries.size > 0)
|
|
89
|
+
await Promise.all([...this.messageDeliveries]);
|
|
90
|
+
}
|
|
91
|
+
hasMessageDeliveries() {
|
|
92
|
+
return this.messageDeliveries.size > 0;
|
|
93
|
+
}
|
|
22
94
|
admit(key, deliver, routeLate) {
|
|
23
95
|
if (key !== undefined) {
|
|
24
96
|
if (this.completed.has(key))
|
|
@@ -31,10 +103,11 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
31
103
|
};
|
|
32
104
|
}
|
|
33
105
|
}
|
|
34
|
-
const
|
|
106
|
+
const admitted = this.open || this.messageAdmissionContext.getStore()?.active === true;
|
|
107
|
+
const decision = admitted ? "admitted" : "late";
|
|
35
108
|
let completion;
|
|
36
109
|
if (key === undefined) {
|
|
37
|
-
completion = this.invoke(
|
|
110
|
+
completion = this.invoke(admitted ? deliver : routeLate);
|
|
38
111
|
}
|
|
39
112
|
else {
|
|
40
113
|
let resolveCompletion;
|
|
@@ -45,7 +118,7 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
45
118
|
});
|
|
46
119
|
void completion.catch(() => { });
|
|
47
120
|
this.inFlight.set(key, completion);
|
|
48
|
-
const delivery = this.invocationContext.run(key, () => this.invoke(
|
|
121
|
+
const delivery = this.invocationContext.run(key, () => this.invoke(admitted ? deliver : routeLate));
|
|
49
122
|
void delivery.then(resolveCompletion, rejectCompletion);
|
|
50
123
|
void completion.then(() => {
|
|
51
124
|
if (this.inFlight.get(key) !== completion)
|
|
@@ -65,6 +138,13 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
65
138
|
this.pending.add(completion);
|
|
66
139
|
void completion.then(() => this.pending.delete(completion), () => this.pending.delete(completion));
|
|
67
140
|
}
|
|
141
|
+
/** Join already-reserved queue commits before a native turn polls its input. */
|
|
142
|
+
async waitForPendingDeliveries() {
|
|
143
|
+
await Promise.allSettled([...this.pending]);
|
|
144
|
+
}
|
|
145
|
+
hasPendingDeliveries() {
|
|
146
|
+
return this.pending.size > 0;
|
|
147
|
+
}
|
|
68
148
|
registerOwnedSubagentRun(runId) {
|
|
69
149
|
this.ownedSubagentRunIds.add(runId);
|
|
70
150
|
}
|
|
@@ -76,6 +156,7 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
76
156
|
}
|
|
77
157
|
seal() {
|
|
78
158
|
this.open = false;
|
|
159
|
+
this.taskClose ??= this.taskHost?.close("stage-close");
|
|
79
160
|
}
|
|
80
161
|
close() {
|
|
81
162
|
this.seal();
|
|
@@ -87,6 +168,9 @@ export class WorkflowStageAdmissionBoundary {
|
|
|
87
168
|
async finishClose() {
|
|
88
169
|
await Promise.allSettled([...this.pending]);
|
|
89
170
|
await this.drainAdmittedWork();
|
|
171
|
+
const closed = await this.taskClose;
|
|
172
|
+
if (closed && !closed.ok)
|
|
173
|
+
throw new Error(`${closed.error.code}: ${closed.error.message}`);
|
|
90
174
|
}
|
|
91
175
|
invoke(callback) {
|
|
92
176
|
try {
|