@bastani/atomic 0.9.70-alpha.1 → 0.9.71-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +127 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +16 -0
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/package.json +3 -3
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +8 -5
- package/dist/builtin/web-access/index.bundle.mjs +14750 -6455
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/workflows/CHANGELOG.md +20 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +27 -10
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +19 -5
- package/dist/builtin/workflows/src/index.js +19 -5
- package/dist/builtin/workflows/src/local-worker-entry.mjs +19 -5
- package/dist/cli/list-models.d.ts +7 -2
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +22 -50
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +2 -0
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +9 -8
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +24 -7
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +4 -7
- 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-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +6 -10
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +9 -8
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +5 -0
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-transfer.d.ts.map +1 -1
- package/dist/core/agent-session-transfer.js +2 -0
- package/dist/core/agent-session-transfer.js.map +1 -1
- package/dist/core/agent-session-typed-queue.d.ts +19 -0
- package/dist/core/agent-session-typed-queue.d.ts.map +1 -0
- package/dist/core/agent-session-typed-queue.js +34 -0
- package/dist/core/agent-session-typed-queue.js.map +1 -0
- package/dist/core/agent-session-types.d.ts +20 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/cache-warmer.d.ts.map +1 -1
- package/dist/core/cache-warmer.js +2 -0
- package/dist/core/cache-warmer.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +13 -2
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +6 -3
- 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/index.d.ts +1 -1
- 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.map +1 -1
- package/dist/core/extensions/loader-api.js +6 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +2 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +18 -1
- package/dist/core/extensions/message-types.d.ts.map +1 -1
- package/dist/core/extensions/message-types.js.map +1 -1
- package/dist/core/extensions/runner-registries.d.ts.map +1 -1
- package/dist/core/extensions/runner-registries.js +8 -1
- package/dist/core/extensions/runner-registries.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +1 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +1 -0
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/fast-model-variants.d.ts +0 -9
- package/dist/core/fast-model-variants.d.ts.map +1 -1
- package/dist/core/fast-model-variants.js +0 -14
- package/dist/core/fast-model-variants.js.map +1 -1
- package/dist/core/model-config.d.ts +14 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-label.d.ts +38 -0
- package/dist/core/model-label.d.ts.map +1 -0
- package/dist/core/model-label.js +46 -0
- package/dist/core/model-label.js.map +1 -0
- package/dist/core/model-resolver-initial.d.ts +5 -0
- package/dist/core/model-resolver-initial.d.ts.map +1 -1
- package/dist/core/model-resolver-initial.js +26 -1
- package/dist/core/model-resolver-initial.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/model-runtime.d.ts +5 -7
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +14 -19
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/model-switch-thinking-level.d.ts +23 -0
- package/dist/core/model-switch-thinking-level.d.ts.map +1 -0
- package/dist/core/model-switch-thinking-level.js +19 -0
- package/dist/core/model-switch-thinking-level.js.map +1 -0
- package/dist/core/package-manager-git.d.ts +2 -0
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-git.js +32 -4
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-operations.d.ts.map +1 -1
- package/dist/core/package-manager-operations.js +37 -5
- package/dist/core/package-manager-operations.js.map +1 -1
- package/dist/core/package-manager-types.d.ts +7 -1
- package/dist/core/package-manager-types.d.ts.map +1 -1
- package/dist/core/package-manager-types.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +14 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +73 -0
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +11 -4
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/skills.js +1 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/storage/index.d.ts +1 -0
- package/dist/core/storage/index.d.ts.map +1 -1
- package/dist/core/storage/index.js +1 -0
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/node-sqlite.d.ts.map +1 -1
- package/dist/core/storage/node-sqlite.js +13 -8
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/write-ahead-log.d.ts +25 -0
- package/dist/core/storage/write-ahead-log.d.ts.map +1 -0
- package/dist/core/storage/write-ahead-log.js +78 -0
- package/dist/core/storage/write-ahead-log.js.map +1 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tasks/completion.d.ts +3 -2
- package/dist/core/tasks/completion.d.ts.map +1 -1
- package/dist/core/tasks/completion.js +7 -2
- package/dist/core/tasks/completion.js.map +1 -1
- package/dist/core/tasks/heartbeat-notice.d.ts +2 -0
- package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat-notice.js +8 -4
- package/dist/core/tasks/heartbeat-notice.js.map +1 -1
- package/dist/core/tasks/heartbeat.d.ts.map +1 -1
- package/dist/core/tasks/heartbeat.js +1 -0
- package/dist/core/tasks/heartbeat.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +4 -4
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +13 -16
- package/dist/core/tools/write.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +6 -2
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -0
- package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +13 -4
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +3 -0
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/stdio.js +13 -2
- package/dist/extensions/mcp/client/transports/stdio.js.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.d.ts.map +1 -1
- package/dist/extensions/mcp/client/transports/streamable-http.js +41 -3
- package/dist/extensions/mcp/client/transports/streamable-http.js.map +1 -1
- package/dist/extensions/mcp/ui.d.ts +1 -0
- package/dist/extensions/mcp/ui.d.ts.map +1 -1
- package/dist/extensions/mcp/ui.js +33 -24
- package/dist/extensions/mcp/ui.js.map +1 -1
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main-deferred-startup.d.ts +23 -1
- package/dist/main-deferred-startup.d.ts.map +1 -1
- package/dist/main-deferred-startup.js +28 -0
- package/dist/main-deferred-startup.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +8 -14
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -3
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -9
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +15 -3
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +23 -7
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +7 -0
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +5 -2
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +12 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +7 -9
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +1 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +2 -1
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
- package/dist/modes/interactive/components/mermaid.js +2 -1
- package/dist/modes/interactive/components/mermaid.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +9 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +46 -16
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +13 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +4 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +32 -11
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -0
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +6 -5
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +2 -0
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +15 -3
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/task-row.d.ts +1 -0
- package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
- package/dist/modes/interactive/components/task-row.js +3 -1
- package/dist/modes/interactive/components/task-row.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +1 -0
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +3 -0
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-content.js +2 -1
- package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +9 -1
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +3 -4
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +6 -4
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -2
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +1 -1
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +11 -1
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +11 -2
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +11 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +4 -1
- 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-model-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +18 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-prompt-turn.js +5 -1
- package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +17 -6
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +51 -5
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +2 -2
- 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 +9 -12
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-tui.js +6 -5
- package/dist/modes/interactive/interactive-tui.js.map +1 -1
- package/dist/modes/interactive/theme/global-theme.d.ts +1 -0
- package/dist/modes/interactive/theme/global-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/global-theme.js +3 -0
- package/dist/modes/interactive/theme/global-theme.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.d.ts +5 -0
- package/dist/modes/interactive/theme/tui-theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/tui-theme.js +21 -2
- package/dist/modes/interactive/theme/tui-theme.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -5
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +2 -6
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +39 -14
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +2 -5
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-api.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +2 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +11 -4
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-input.d.ts +3 -2
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +5 -1
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +45 -16
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts +3 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +5 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +2 -5
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +26 -4
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/ansi.d.ts +0 -2
- package/dist/utils/ansi.d.ts.map +1 -1
- package/dist/utils/ansi.js +0 -5
- package/dist/utils/ansi.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +5 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +7 -0
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/extensions/api-reference.md +21 -7
- package/docs/extensions/events.md +2 -0
- package/docs/extensions/examples.md +0 -1
- package/docs/extensions.md +7 -0
- package/docs/keybindings.md +1 -1
- package/docs/models/reference.md +8 -6
- package/docs/models-configuration.md +1 -0
- package/docs/models.md +2 -0
- package/docs/packages.md +2 -0
- package/docs/providers.md +14 -5
- package/docs/rpc/protocol.md +8 -2
- package/docs/rpc.md +4 -0
- package/docs/sdk.md +2 -0
- package/docs/storage.md +2 -0
- package/docs/tmux.md +6 -0
- package/docs/tui/reference.md +2 -0
- package/docs/windows.md +26 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/preset.ts +2 -0
- package/examples/extensions/tools.ts +2 -0
- package/npm-shrinkwrap.json +90 -72
- package/package.json +14 -15
- package/schemas/models.schema.json +4 -0
- package/examples/extensions/sandbox/index.ts +0 -323
- package/examples/extensions/sandbox/package-lock.json +0 -92
- package/examples/extensions/sandbox/package.json +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../../src/core/tasks/heartbeat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,2BAA2B,GAI3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,wBAAwB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,cAAc,uBAAuB,CAAC;AAEtC,gFAAgF;AAChF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,yGAAyG;AACzG,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AACjD,qGAAqG;AACrG,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAChD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,mFAAmF;AACnF,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAWzC,2GAA2G;AAC3G,MA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AAG,IAAI,CAAC;QACX,IAAI,IAAI,EAAE,CAAC;QACX,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,uDAAuD;IACvD,OAAO,IAAI,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAC9B,IAAI,MAAM,CAAC,MAAM;YAAE,GAAG,GAAG,MAAM,CAAC;aAC3B,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC;;YAC3C,IAAI,GAAG,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { taskOutputText } from \"./command-output.js\";\nimport type { NativeEvent, OwnerSnapshot, TaskId, TaskRecord } from \"./contracts.js\";\nimport {\n\tDEFAULT_TASK_HEARTBEAT_MS,\n\tformatTaskHeartbeat,\n\tisValidTaskHeartbeatMs,\n\tsingleLine,\n\tTASK_HEARTBEAT_MESSAGE_TYPE,\n\ttype TaskHeartbeatDetails,\n\ttype TaskHeartbeatMessage,\n\ttype TaskHeartbeatTask,\n} from \"./heartbeat-notice.js\";\nimport {\n\ttype OwnerLease,\n\ttype TaskLease,\n\ttype TaskSubscription,\n\ttype TaskSupervisor,\n\ttaskOwnTranscriptEntries,\n} from \"./supervisor.js\";\n\nexport * from \"./heartbeat-notice.js\";\n\n/** Tasks described in full by one notice; further due tasks are only listed. */\nexport const TASK_HEARTBEAT_DETAIL_LIMIT = 8;\n/** Further due tasks listed by name in one notice; the rest are counted. */\nexport const TASK_HEARTBEAT_LIST_LIMIT = 20;\n/** Boundaries due within this window (capped at a quarter cadence) join the notice that is going out. */\nexport const TASK_HEARTBEAT_COALESCE_MS = 60_000;\n/** While the owner has not read the previous notice, due tasks wait and are rechecked this often. */\nexport const TASK_HEARTBEAT_RECHECK_MS = 30_000;\n/** How often a running shell's output is sampled to date its last output. */\nexport const TASK_HEARTBEAT_OUTPUT_SAMPLE_MS = 30_000;\nconst OUTPUT_TAIL_BYTES = 2048;\nconst OUTPUT_TAIL_LINES = 6;\nconst LINE_CHARS = 160;\nconst TITLE_CHARS = 120;\n/** Longest delay a host timer accepts before it overflows to an immediate fire. */\nconst MAX_TIMER_DELAY_MS = 2_147_483_647;\n\n/** Where an owner's heartbeats go. The host binds its own chat; nothing here is model-provided. */\nexport interface TaskHeartbeatDelivery {\n\t/** Cadence for tasks launched without their own `heartbeatMs`; `0` disables. */\n\tdefaultIntervalMs(): number;\n\t/** Whether a heartbeat this owner already sent is still waiting, unread, in its chat. */\n\thasUnreadHeartbeat(): boolean;\n\tdeliver(message: TaskHeartbeatMessage): Promise<void>;\n}\n\n/** The owner's default cadence, or the built-in one when its setting cannot be read or is out of range. */\nexport function defaultTaskHeartbeatMs(delivery: Pick<TaskHeartbeatDelivery, \"defaultIntervalMs\">): number {\n\ttry {\n\t\tconst configured = delivery.defaultIntervalMs();\n\t\treturn isValidTaskHeartbeatMs(configured) ? configured : DEFAULT_TASK_HEARTBEAT_MS;\n\t} catch {\n\t\treturn DEFAULT_TASK_HEARTBEAT_MS;\n\t}\n}\n\nexport interface TaskHeartbeatClock {\n\tnow(): number;\n\tsetTimeout(run: () => void, delayMs: number): object;\n\tclearTimeout(handle: object): void;\n}\n\nconst systemClock: TaskHeartbeatClock = {\n\tnow: () => Date.now(),\n\tsetTimeout: (run, delayMs) => {\n\t\tconst handle = setTimeout(run, delayMs);\n\t\thandle.unref();\n\t\treturn handle;\n\t},\n\tclearTimeout: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),\n};\n\nexport interface TaskHeartbeatMonitorOptions {\n\tsupervisor: TaskSupervisor;\n\towner: OwnerLease;\n\t/** Read on every use, so a replaced session's binding takes over the same owner. */\n\tdelivery: () => TaskHeartbeatDelivery | undefined;\n\tclock?: TaskHeartbeatClock;\n}\n\ntype Tracked = {\n\ttaskId: TaskId;\n\trecord: TaskRecord;\n\t/** First observed running: the anchor of the cadence. */\n\tstartedAt: number;\n\t/** Frozen when the task is first observed; `0` disables. */\n\tintervalMs: number;\n\t/** Next boundary `startedAt + n × intervalMs`; absent when disabled. */\n\tnextAt?: number;\n\tlastActivityAt?: number;\n\tactivityKey: string;\n\t/** Shells: retained output bytes observed so far. */\n\toutputEnd: bigint;\n};\n\nfunction activityKey(task: TaskRecord): string {\n\treturn JSON.stringify([task.currentAction, task.metrics, task.attention, task.model]);\n}\n\n/** Whether the newest message in a child's history is an assistant turn whose tool calls have not returned yet. */\nfunction endsInToolCall(entries: NonNullable<ReturnType<typeof taskOwnTranscriptEntries>>): boolean {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry?.type !== \"message\") continue;\n\t\tconst message = entry.message;\n\t\treturn message.role === \"assistant\" && message.content.some((block) => block.type === \"toolCall\");\n\t}\n\treturn false;\n}\n\n/** First boundary on the `startedAt + n × intervalMs` series strictly after `after`. */\nfunction nextBoundary(startedAt: number, intervalMs: number, after: number): number {\n\tconst n = Math.max(1, Math.floor((after - startedAt) / intervalMs) + 1);\n\tconst boundary = startedAt + n * intervalMs;\n\treturn boundary > after ? boundary : startedAt + (n + 1) * intervalMs;\n}\n\nfunction byBoundary(a: Tracked, b: Tracked): number {\n\tconst left = a.nextAt ?? Number.POSITIVE_INFINITY;\n\tconst right = b.nextAt ?? Number.POSITIVE_INFINITY;\n\tif (left !== right) return left - right;\n\treturn a.taskId < b.taskId ? -1 : a.taskId > b.taskId ? 1 : 0;\n}\n\n/**\n * Periodic \"is this still making progress?\" notices for one task owner's running shells and subagents.\n *\n * It follows the workflow heartbeat rules: boundaries are anchored at the task's start and never at the previous\n * delivery, missed boundaries are skipped rather than replayed, and only one notice per owner is outstanding. Unlike\n * a workflow run, an owner can have many tasks, so tasks due together share one bounded notice, and a task due while\n * the owner has not read the previous notice waits for it rather than losing its turn.\n */\nexport class TaskHeartbeatMonitor {\n\tprivate readonly options: TaskHeartbeatMonitorOptions;\n\tprivate readonly clock: TaskHeartbeatClock;\n\tprivate readonly tracked = new Map<TaskId, Tracked>();\n\tprivate subscription?: TaskSubscription;\n\tprivate timer?: object;\n\t/** The time the current timer wakes for, so an unchanged schedule keeps its timer. */\n\tprivate timerAt?: number;\n\tprivate busy = false;\n\tprivate disposed = false;\n\tprivate recheckAt?: number;\n\tprivate nextSampleAt?: number;\n\n\tconstructor(options: TaskHeartbeatMonitorOptions) {\n\t\tthis.options = options;\n\t\tthis.clock = options.clock ?? systemClock;\n\t}\n\n\t/** Begin watching the owner. Idempotent. */\n\tstart(): void {\n\t\tif (this.subscription || this.disposed) return;\n\t\tconst watched = this.options.supervisor.watchOwnerTasks(this.options.owner);\n\t\tif (!watched.ok) return;\n\t\tthis.subscription = watched.value;\n\t\tthis.subscription.onReconcile = (snapshot, events) => this.reconcile(snapshot, events);\n\t\tthis.reconcile(this.subscription.snapshot, []);\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.subscription?.dispose();\n\t\tthis.subscription = undefined;\n\t\tthis.tracked.clear();\n\t\tthis.disarm();\n\t}\n\n\tprivate reconcile(snapshot: OwnerSnapshot, events: readonly NativeEvent[]): void {\n\t\tif (this.disposed) return;\n\t\tif (snapshot.state !== \"open\") {\n\t\t\tif (snapshot.state === \"closed\") this.dispose();\n\t\t\telse {\n\t\t\t\tthis.tracked.clear();\n\t\t\t\tthis.disarm();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst at = this.clock.now();\n\t\tconst reported = new Set<TaskId>();\n\t\tfor (const event of events) if (event.payload.kind === \"task-activity\") reported.add(event.payload.ref.taskId);\n\t\tconst running = new Set<TaskId>();\n\t\tfor (const task of snapshot.tasks) {\n\t\t\t// Queued, stopping, paused and finished tasks do not heartbeat.\n\t\t\tif (task.execution.kind !== \"running\") continue;\n\t\t\tconst id = task.ref.taskId;\n\t\t\trunning.add(id);\n\t\t\tconst key = activityKey(task);\n\t\t\tconst entry = this.tracked.get(id);\n\t\t\tif (entry) {\n\t\t\t\tentry.record = task;\n\t\t\t\tif (key !== entry.activityKey || reported.has(id)) {\n\t\t\t\t\tentry.activityKey = key;\n\t\t\t\t\tentry.lastActivityAt = at;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst intervalMs = this.resolveInterval(task);\n\t\t\tthis.tracked.set(id, {\n\t\t\t\ttaskId: id,\n\t\t\t\trecord: task,\n\t\t\t\tstartedAt: at,\n\t\t\t\tintervalMs,\n\t\t\t\t...(intervalMs > 0 ? { nextAt: at + intervalMs } : {}),\n\t\t\t\t...(reported.has(id) ? { lastActivityAt: at } : {}),\n\t\t\t\tactivityKey: key,\n\t\t\t\toutputEnd: 0n,\n\t\t\t});\n\t\t}\n\t\tfor (const id of [...this.tracked.keys()]) if (!running.has(id)) this.tracked.delete(id);\n\t\tif (!this.hasSampledShells()) this.nextSampleAt = undefined;\n\t\telse this.nextSampleAt ??= at + TASK_HEARTBEAT_OUTPUT_SAMPLE_MS;\n\t\tthis.arm();\n\t}\n\n\tprivate resolveInterval(task: TaskRecord): number {\n\t\t// Owners with a heartbeat binding fix each task's cadence on its record at admission.\n\t\tif (task.heartbeatMs !== undefined) return isValidTaskHeartbeatMs(task.heartbeatMs) ? task.heartbeatMs : 0;\n\t\tconst delivery = this.options.delivery();\n\t\treturn delivery ? defaultTaskHeartbeatMs(delivery) : DEFAULT_TASK_HEARTBEAT_MS;\n\t}\n\n\tprivate hasSampledShells(): boolean {\n\t\tfor (const entry of this.tracked.values())\n\t\t\tif (entry.record.kind === \"command\" && entry.intervalMs > 0) return true;\n\t\treturn false;\n\t}\n\n\tprivate disarm(): void {\n\t\tif (this.timer === undefined) return;\n\t\tthis.clock.clearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tthis.timerAt = undefined;\n\t}\n\n\tprivate arm(): void {\n\t\tif (this.disposed || this.busy) {\n\t\t\tthis.disarm();\n\t\t\treturn;\n\t\t}\n\t\t// A blocked owner cannot receive anything before its recheck, however many tasks come due meanwhile.\n\t\tlet wakeAt = this.recheckAt ?? Number.POSITIVE_INFINITY;\n\t\tif (this.recheckAt === undefined)\n\t\t\tfor (const entry of this.tracked.values())\n\t\t\t\tif (entry.nextAt !== undefined && entry.nextAt < wakeAt) wakeAt = entry.nextAt;\n\t\tif (this.nextSampleAt !== undefined && this.nextSampleAt < wakeAt) wakeAt = this.nextSampleAt;\n\t\t// Activity reconciles many times a second; it rarely moves the next wake-up.\n\t\tif (this.timer !== undefined && this.timerAt === wakeAt) return;\n\t\tthis.disarm();\n\t\tif (!Number.isFinite(wakeAt)) return;\n\t\tconst delay = Math.min(Math.max(1, Math.ceil(wakeAt - this.clock.now())), MAX_TIMER_DELAY_MS);\n\t\tthis.timerAt = wakeAt;\n\t\tthis.timer = this.clock.setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tthis.timerAt = undefined;\n\t\t\tvoid this.wake();\n\t\t}, delay);\n\t}\n\n\tprivate async wake(): Promise<void> {\n\t\tif (this.disposed || this.busy) return;\n\t\tthis.busy = true;\n\t\ttry {\n\t\t\tconst at = this.clock.now();\n\t\t\tif (this.nextSampleAt !== undefined && this.nextSampleAt <= at) {\n\t\t\t\tawait this.sampleShellOutput(at);\n\t\t\t\tthis.nextSampleAt = this.hasSampledShells() ? at + TASK_HEARTBEAT_OUTPUT_SAMPLE_MS : undefined;\n\t\t\t}\n\t\t\tawait this.beat(at);\n\t\t} catch {\n\t\t\t// A failed check skips this boundary; the next one is already scheduled.\n\t\t} finally {\n\t\t\tthis.busy = false;\n\t\t\tthis.arm();\n\t\t}\n\t}\n\n\tprivate async beat(at: number): Promise<void> {\n\t\tif (this.recheckAt !== undefined && this.recheckAt > at) return;\n\t\tthis.recheckAt = undefined;\n\t\tconst entries = [...this.tracked.values()];\n\t\tif (!entries.some((entry) => entry.nextAt !== undefined && entry.nextAt <= at)) return;\n\t\tconst delivery = this.options.delivery();\n\t\tlet unread = false;\n\t\ttry {\n\t\t\tunread = delivery?.hasUnreadHeartbeat() === true;\n\t\t} catch {\n\t\t\tunread = false;\n\t\t}\n\t\tif (unread) {\n\t\t\t// One outstanding notice per owner: due tasks stay owed and join the next notice instead of stacking.\n\t\t\tthis.recheckAt = at + TASK_HEARTBEAT_RECHECK_MS;\n\t\t\treturn;\n\t\t}\n\t\tconst batch = entries\n\t\t\t.filter(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.nextAt !== undefined &&\n\t\t\t\t\tentry.nextAt <= at + Math.min(TASK_HEARTBEAT_COALESCE_MS, entry.intervalMs / 4),\n\t\t\t)\n\t\t\t.sort(byBoundary);\n\t\tfor (const entry of batch)\n\t\t\tentry.nextAt = nextBoundary(entry.startedAt, entry.intervalMs, Math.max(at, entry.nextAt ?? at));\n\t\tif (!delivery) return;\n\t\tconst details = await this.describe(batch, at);\n\t\t// A task that finished while its notice was being prepared is no longer mentioned.\n\t\tconst live = (taskId: string) => this.tracked.has(taskId as TaskId);\n\t\tdetails.tasks = details.tasks.filter((task) => live(task.taskId));\n\t\tdetails.more = details.more.filter((task) => live(task.taskId));\n\t\tdetails.moreCount = batch.slice(TASK_HEARTBEAT_DETAIL_LIMIT).filter((entry) => live(entry.taskId)).length;\n\t\tif (details.tasks.length === 0 || this.disposed) return;\n\t\tawait delivery.deliver({\n\t\t\tcustomType: TASK_HEARTBEAT_MESSAGE_TYPE,\n\t\t\tcontent: formatTaskHeartbeat(details),\n\t\t\tdisplay: true,\n\t\t\tdetails,\n\t\t});\n\t}\n\n\tprivate async describe(batch: readonly Tracked[], at: number): Promise<TaskHeartbeatDetails> {\n\t\tconst detailed = batch.slice(0, TASK_HEARTBEAT_DETAIL_LIMIT);\n\t\tconst rest = batch.slice(TASK_HEARTBEAT_DETAIL_LIMIT);\n\t\tconst tasks: TaskHeartbeatTask[] = [];\n\t\tfor (const entry of detailed) tasks.push(await this.describeTask(entry, at));\n\t\treturn {\n\t\t\tscheduledAt: at,\n\t\t\ttasks,\n\t\t\tmore: rest.slice(0, TASK_HEARTBEAT_LIST_LIMIT).map((entry) => ({\n\t\t\t\ttaskId: entry.taskId,\n\t\t\t\tkind: entry.record.kind,\n\t\t\t\ttitle: singleLine(entry.record.title, TITLE_CHARS),\n\t\t\t})),\n\t\t\tmoreCount: rest.length,\n\t\t};\n\t}\n\n\tprivate async describeTask(entry: Tracked, at: number): Promise<TaskHeartbeatTask> {\n\t\tconst task = entry.record;\n\t\tconst lease = this.lease(entry.taskId);\n\t\tconst described: TaskHeartbeatTask = {\n\t\t\ttaskId: entry.taskId,\n\t\t\tkind: task.kind,\n\t\t\ttitle: singleLine(task.title, TITLE_CHARS),\n\t\t\t...(task.agentName === undefined ? {} : { agentName: singleLine(task.agentName, TITLE_CHARS) }),\n\t\t\t...(task.kind === \"agent\" && task.model !== undefined ? { model: task.model } : {}),\n\t\t\t...(task.kind === \"agent\" && task.requestedModel !== undefined ? { requestedModel: task.requestedModel } : {}),\n\t\t\telapsedMs: Math.max(0, at - entry.startedAt),\n\t\t\tintervalMs: entry.intervalMs,\n\t\t};\n\t\tif (task.kind === \"command\" && lease) {\n\t\t\tconst end = await this.observeOutput(entry, lease, at);\n\t\t\tif (end !== undefined) described.output = { bytes: Number(end), tail: await this.outputTail(lease, end) };\n\t\t}\n\t\tif (entry.lastActivityAt !== undefined) described.lastActivityAgoMs = Math.max(0, at - entry.lastActivityAt);\n\t\tif (task.kind === \"agent\") {\n\t\t\tconst entries = lease ? taskOwnTranscriptEntries(lease) : undefined;\n\t\t\tif (task.currentAction)\n\t\t\t\tdescribed.currentAction = {\n\t\t\t\t\ttool: singleLine(task.currentAction.tool, 60),\n\t\t\t\t\ttext: singleLine(task.currentAction.text, LINE_CHARS),\n\t\t\t\t\t// The record keeps the last reported action after its tool returns. The child's own history says\n\t\t\t\t\t// whether a call is still outstanding: its last message is an assistant turn that called tools.\n\t\t\t\t\trunning: entries !== undefined && endsInToolCall(entries),\n\t\t\t\t};\n\t\t\tif (task.metrics?.toolCount !== undefined) described.toolCount = task.metrics.toolCount;\n\t\t\tif (task.metrics?.tokenCount !== undefined) described.tokenCount = task.metrics.tokenCount;\n\t\t\tif (entries)\n\t\t\t\tdescribed.turnCount = entries.filter(\n\t\t\t\t\t(item) => item.type === \"message\" && item.message.role === \"assistant\",\n\t\t\t\t).length;\n\t\t}\n\t\tif (task.attention.kind === \"input-needed\")\n\t\t\tdescribed.attention = `waiting for input: ${singleLine(task.attention.prompt, LINE_CHARS)}`;\n\t\telse if (task.attention.kind === \"no-recent-activity\") described.attention = \"no recent activity\";\n\t\treturn described;\n\t}\n\n\tprivate lease(taskId: TaskId): TaskLease | undefined {\n\t\tconst found = this.options.supervisor.lookupTask(this.options.owner, taskId);\n\t\treturn found.ok ? found.value : undefined;\n\t}\n\n\tprivate async sampleShellOutput(at: number): Promise<void> {\n\t\tfor (const entry of [...this.tracked.values()]) {\n\t\t\tif (entry.record.kind !== \"command\" || entry.intervalMs === 0) continue;\n\t\t\tconst lease = this.lease(entry.taskId);\n\t\t\tif (lease) await this.observeOutput(entry, lease, at);\n\t\t}\n\t}\n\n\t/** Current retained output size; growth since the last look dates the shell's last output. */\n\tprivate async observeOutput(entry: Tracked, lease: TaskLease, at: number): Promise<bigint | undefined> {\n\t\tconst end = await findOutputEnd(this.options.supervisor, lease, entry.outputEnd);\n\t\tif (end === undefined) return undefined;\n\t\tif (end > entry.outputEnd) {\n\t\t\tentry.outputEnd = end;\n\t\t\tentry.lastActivityAt = at;\n\t\t}\n\t\treturn end;\n\t}\n\n\tprivate async outputTail(lease: TaskLease, end: bigint): Promise<string[]> {\n\t\tif (end === 0n) return [];\n\t\tconst start = end > BigInt(OUTPUT_TAIL_BYTES) ? end - BigInt(OUTPUT_TAIL_BYTES) : 0n;\n\t\tconst page = await this.options.supervisor.readTaskOutput(lease, {\n\t\t\tstart: String(start),\n\t\t\tmaximumBytes: OUTPUT_TAIL_BYTES,\n\t\t});\n\t\tif (!page.ok) return [];\n\t\tconst lines = taskOutputText(page.value).split(\"\\n\");\n\t\t// The window can open mid-line; that fragment is not a line of output.\n\t\tif (start > 0n) lines.shift();\n\t\treturn lines\n\t\t\t.map((line) => {\n\t\t\t\t// A CRLF ending is not a redraw; a carriage return inside a line redraws it, so its last state counts.\n\t\t\t\tconst ended = line.replace(/\\r+$/, \"\");\n\t\t\t\treturn singleLine(ended.slice(ended.lastIndexOf(\"\\r\") + 1), LINE_CHARS).trimEnd();\n\t\t\t})\n\t\t\t.filter((line) => line.trim().length > 0)\n\t\t\t.slice(-OUTPUT_TAIL_LINES);\n\t}\n}\n\n/**\n * Retained output size of a running shell, found with one-byte reads: a read past the end returns nothing. Gallops\n * from the last known size, then bisects, so a large burst of output costs a few dozen tiny reads, not a full scan.\n */\nasync function findOutputEnd(supervisor: TaskSupervisor, lease: TaskLease, from: bigint): Promise<bigint | undefined> {\n\tconst probe = async (offset: bigint): Promise<{ before: boolean; end: bigint } | undefined> => {\n\t\tconst page = await supervisor.readTaskOutput(lease, { start: String(offset), maximumBytes: 1 });\n\t\tif (!page.ok) return undefined;\n\t\tif (page.value.nextOffset !== undefined) return { before: true, end: BigInt(page.value.nextOffset) };\n\t\tlet end = offset;\n\t\tfor (const chunk of page.value.chunks) if (BigInt(chunk.offsets.end) > end) end = BigInt(chunk.offsets.end);\n\t\tfor (const range of page.value.omittedRanges) if (BigInt(range.end) > end) end = BigInt(range.end);\n\t\t// No byte beyond this page: the output ends at its last byte, or at or before `offset` when it is empty.\n\t\treturn { before: end > offset, end };\n\t};\n\tlet low = from;\n\tconst first = await probe(low);\n\tif (!first) return undefined;\n\tif (!first.before) return first.end > from ? first.end : from;\n\tlet step = 65_536n;\n\tlet high = low + step;\n\tfor (;;) {\n\t\tconst result = await probe(high);\n\t\tif (!result) return undefined;\n\t\tif (!result.before) {\n\t\t\tif (result.end > high) return result.end;\n\t\t\tbreak;\n\t\t}\n\t\tlow = high;\n\t\tstep *= 2n;\n\t\thigh = low + step;\n\t}\n\t// The output ends after `low` and at or before `high`.\n\twhile (high - low > 1n) {\n\t\tconst middle = low + (high - low) / 2n;\n\t\tconst result = await probe(middle);\n\t\tif (!result) return undefined;\n\t\tif (result.before) low = middle;\n\t\telse if (result.end > middle) return result.end;\n\t\telse high = middle;\n\t}\n\treturn high;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../../src/core/tasks/heartbeat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EACN,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,2BAA2B,GAI3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAKN,wBAAwB,GACxB,MAAM,iBAAiB,CAAC;AAEzB,cAAc,uBAAuB,CAAC;AAEtC,gFAAgF;AAChF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAC7C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAC5C,yGAAyG;AACzG,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;AACjD,qGAAqG;AACrG,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAChD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC;AACtD,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,mFAAmF;AACnF,MAAM,kBAAkB,GAAG,aAAa,CAAC;AAWzC,2GAA2G;AAC3G,MAAM,UAAU,sBAAsB,CAAC,QAA0D;IA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,MAAM,CAAC,MAAM,EAAE,CAAC;YACpB,IAAI,MAAM,CAAC,GAAG,GAAG,IAAI;gBAAE,OAAO,MAAM,CAAC,GAAG,CAAC;YACzC,MAAM;QACP,CAAC;QACD,GAAG,GAAG,IAAI,CAAC;QACX,IAAI,IAAI,EAAE,CAAC;QACX,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,uDAAuD;IACvD,OAAO,IAAI,GAAG,GAAG,GAAG,EAAE,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAC;QAC9B,IAAI,MAAM,CAAC,MAAM;YAAE,GAAG,GAAG,MAAM,CAAC;aAC3B,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM;YAAE,OAAO,MAAM,CAAC,GAAG,CAAC;;YAC3C,IAAI,GAAG,MAAM,CAAC;IACpB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import { taskOutputText } from \"./command-output.js\";\nimport type { NativeEvent, OwnerSnapshot, TaskId, TaskRecord } from \"./contracts.js\";\nimport {\n\tDEFAULT_TASK_HEARTBEAT_MS,\n\tformatTaskHeartbeat,\n\tisValidTaskHeartbeatMs,\n\tsingleLine,\n\tTASK_HEARTBEAT_MESSAGE_TYPE,\n\ttype TaskHeartbeatDetails,\n\ttype TaskHeartbeatMessage,\n\ttype TaskHeartbeatTask,\n} from \"./heartbeat-notice.js\";\nimport {\n\ttype OwnerLease,\n\ttype TaskLease,\n\ttype TaskSubscription,\n\ttype TaskSupervisor,\n\ttaskOwnTranscriptEntries,\n} from \"./supervisor.js\";\n\nexport * from \"./heartbeat-notice.js\";\n\n/** Tasks described in full by one notice; further due tasks are only listed. */\nexport const TASK_HEARTBEAT_DETAIL_LIMIT = 8;\n/** Further due tasks listed by name in one notice; the rest are counted. */\nexport const TASK_HEARTBEAT_LIST_LIMIT = 20;\n/** Boundaries due within this window (capped at a quarter cadence) join the notice that is going out. */\nexport const TASK_HEARTBEAT_COALESCE_MS = 60_000;\n/** While the owner has not read the previous notice, due tasks wait and are rechecked this often. */\nexport const TASK_HEARTBEAT_RECHECK_MS = 30_000;\n/** How often a running shell's output is sampled to date its last output. */\nexport const TASK_HEARTBEAT_OUTPUT_SAMPLE_MS = 30_000;\nconst OUTPUT_TAIL_BYTES = 2048;\nconst OUTPUT_TAIL_LINES = 6;\nconst LINE_CHARS = 160;\nconst TITLE_CHARS = 120;\n/** Longest delay a host timer accepts before it overflows to an immediate fire. */\nconst MAX_TIMER_DELAY_MS = 2_147_483_647;\n\n/** Where an owner's heartbeats go. The host binds its own chat; nothing here is model-provided. */\nexport interface TaskHeartbeatDelivery {\n\t/** Cadence for tasks launched without their own `heartbeatMs`; `0` disables. */\n\tdefaultIntervalMs(): number;\n\t/** Whether a heartbeat this owner already sent is still waiting, unread, in its chat. */\n\thasUnreadHeartbeat(): boolean;\n\tdeliver(message: TaskHeartbeatMessage): Promise<void>;\n}\n\n/** The owner's default cadence, or the built-in one when its setting cannot be read or is out of range. */\nexport function defaultTaskHeartbeatMs(delivery: Pick<TaskHeartbeatDelivery, \"defaultIntervalMs\">): number {\n\ttry {\n\t\tconst configured = delivery.defaultIntervalMs();\n\t\treturn isValidTaskHeartbeatMs(configured) ? configured : DEFAULT_TASK_HEARTBEAT_MS;\n\t} catch {\n\t\treturn DEFAULT_TASK_HEARTBEAT_MS;\n\t}\n}\n\nexport interface TaskHeartbeatClock {\n\tnow(): number;\n\tsetTimeout(run: () => void, delayMs: number): object;\n\tclearTimeout(handle: object): void;\n}\n\nconst systemClock: TaskHeartbeatClock = {\n\tnow: () => Date.now(),\n\tsetTimeout: (run, delayMs) => {\n\t\tconst handle = setTimeout(run, delayMs);\n\t\thandle.unref();\n\t\treturn handle;\n\t},\n\tclearTimeout: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),\n};\n\nexport interface TaskHeartbeatMonitorOptions {\n\tsupervisor: TaskSupervisor;\n\towner: OwnerLease;\n\t/** Read on every use, so a replaced session's binding takes over the same owner. */\n\tdelivery: () => TaskHeartbeatDelivery | undefined;\n\tclock?: TaskHeartbeatClock;\n}\n\ntype Tracked = {\n\ttaskId: TaskId;\n\trecord: TaskRecord;\n\t/** First observed running: the anchor of the cadence. */\n\tstartedAt: number;\n\t/** Frozen when the task is first observed; `0` disables. */\n\tintervalMs: number;\n\t/** Next boundary `startedAt + n × intervalMs`; absent when disabled. */\n\tnextAt?: number;\n\tlastActivityAt?: number;\n\tactivityKey: string;\n\t/** Shells: retained output bytes observed so far. */\n\toutputEnd: bigint;\n};\n\nfunction activityKey(task: TaskRecord): string {\n\treturn JSON.stringify([task.currentAction, task.metrics, task.attention, task.model]);\n}\n\n/** Whether the newest message in a child's history is an assistant turn whose tool calls have not returned yet. */\nfunction endsInToolCall(entries: NonNullable<ReturnType<typeof taskOwnTranscriptEntries>>): boolean {\n\tfor (let index = entries.length - 1; index >= 0; index--) {\n\t\tconst entry = entries[index];\n\t\tif (entry?.type !== \"message\") continue;\n\t\tconst message = entry.message;\n\t\treturn message.role === \"assistant\" && message.content.some((block) => block.type === \"toolCall\");\n\t}\n\treturn false;\n}\n\n/** First boundary on the `startedAt + n × intervalMs` series strictly after `after`. */\nfunction nextBoundary(startedAt: number, intervalMs: number, after: number): number {\n\tconst n = Math.max(1, Math.floor((after - startedAt) / intervalMs) + 1);\n\tconst boundary = startedAt + n * intervalMs;\n\treturn boundary > after ? boundary : startedAt + (n + 1) * intervalMs;\n}\n\nfunction byBoundary(a: Tracked, b: Tracked): number {\n\tconst left = a.nextAt ?? Number.POSITIVE_INFINITY;\n\tconst right = b.nextAt ?? Number.POSITIVE_INFINITY;\n\tif (left !== right) return left - right;\n\treturn a.taskId < b.taskId ? -1 : a.taskId > b.taskId ? 1 : 0;\n}\n\n/**\n * Periodic \"is this still making progress?\" notices for one task owner's running shells and subagents.\n *\n * It follows the workflow heartbeat rules: boundaries are anchored at the task's start and never at the previous\n * delivery, missed boundaries are skipped rather than replayed, and only one notice per owner is outstanding. Unlike\n * a workflow run, an owner can have many tasks, so tasks due together share one bounded notice, and a task due while\n * the owner has not read the previous notice waits for it rather than losing its turn.\n */\nexport class TaskHeartbeatMonitor {\n\tprivate readonly options: TaskHeartbeatMonitorOptions;\n\tprivate readonly clock: TaskHeartbeatClock;\n\tprivate readonly tracked = new Map<TaskId, Tracked>();\n\tprivate subscription?: TaskSubscription;\n\tprivate timer?: object;\n\t/** The time the current timer wakes for, so an unchanged schedule keeps its timer. */\n\tprivate timerAt?: number;\n\tprivate busy = false;\n\tprivate disposed = false;\n\tprivate recheckAt?: number;\n\tprivate nextSampleAt?: number;\n\n\tconstructor(options: TaskHeartbeatMonitorOptions) {\n\t\tthis.options = options;\n\t\tthis.clock = options.clock ?? systemClock;\n\t}\n\n\t/** Begin watching the owner. Idempotent. */\n\tstart(): void {\n\t\tif (this.subscription || this.disposed) return;\n\t\tconst watched = this.options.supervisor.watchOwnerTasks(this.options.owner);\n\t\tif (!watched.ok) return;\n\t\tthis.subscription = watched.value;\n\t\tthis.subscription.onReconcile = (snapshot, events) => this.reconcile(snapshot, events);\n\t\tthis.reconcile(this.subscription.snapshot, []);\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.subscription?.dispose();\n\t\tthis.subscription = undefined;\n\t\tthis.tracked.clear();\n\t\tthis.disarm();\n\t}\n\n\tprivate reconcile(snapshot: OwnerSnapshot, events: readonly NativeEvent[]): void {\n\t\tif (this.disposed) return;\n\t\tif (snapshot.state !== \"open\") {\n\t\t\tif (snapshot.state === \"closed\") this.dispose();\n\t\t\telse {\n\t\t\t\tthis.tracked.clear();\n\t\t\t\tthis.disarm();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst at = this.clock.now();\n\t\tconst reported = new Set<TaskId>();\n\t\tfor (const event of events) if (event.payload.kind === \"task-activity\") reported.add(event.payload.ref.taskId);\n\t\tconst running = new Set<TaskId>();\n\t\tfor (const task of snapshot.tasks) {\n\t\t\t// Queued, stopping, paused and finished tasks do not heartbeat.\n\t\t\tif (task.execution.kind !== \"running\") continue;\n\t\t\tconst id = task.ref.taskId;\n\t\t\trunning.add(id);\n\t\t\tconst key = activityKey(task);\n\t\t\tconst entry = this.tracked.get(id);\n\t\t\tif (entry) {\n\t\t\t\tentry.record = task;\n\t\t\t\tif (key !== entry.activityKey || reported.has(id)) {\n\t\t\t\t\tentry.activityKey = key;\n\t\t\t\t\tentry.lastActivityAt = at;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst intervalMs = this.resolveInterval(task);\n\t\t\tthis.tracked.set(id, {\n\t\t\t\ttaskId: id,\n\t\t\t\trecord: task,\n\t\t\t\tstartedAt: at,\n\t\t\t\tintervalMs,\n\t\t\t\t...(intervalMs > 0 ? { nextAt: at + intervalMs } : {}),\n\t\t\t\t...(reported.has(id) ? { lastActivityAt: at } : {}),\n\t\t\t\tactivityKey: key,\n\t\t\t\toutputEnd: 0n,\n\t\t\t});\n\t\t}\n\t\tfor (const id of [...this.tracked.keys()]) if (!running.has(id)) this.tracked.delete(id);\n\t\tif (!this.hasSampledShells()) this.nextSampleAt = undefined;\n\t\telse this.nextSampleAt ??= at + TASK_HEARTBEAT_OUTPUT_SAMPLE_MS;\n\t\tthis.arm();\n\t}\n\n\tprivate resolveInterval(task: TaskRecord): number {\n\t\t// Owners with a heartbeat binding fix each task's cadence on its record at admission.\n\t\tif (task.heartbeatMs !== undefined) return isValidTaskHeartbeatMs(task.heartbeatMs) ? task.heartbeatMs : 0;\n\t\tconst delivery = this.options.delivery();\n\t\treturn delivery ? defaultTaskHeartbeatMs(delivery) : DEFAULT_TASK_HEARTBEAT_MS;\n\t}\n\n\tprivate hasSampledShells(): boolean {\n\t\tfor (const entry of this.tracked.values())\n\t\t\tif (entry.record.kind === \"command\" && entry.intervalMs > 0) return true;\n\t\treturn false;\n\t}\n\n\tprivate disarm(): void {\n\t\tif (this.timer === undefined) return;\n\t\tthis.clock.clearTimeout(this.timer);\n\t\tthis.timer = undefined;\n\t\tthis.timerAt = undefined;\n\t}\n\n\tprivate arm(): void {\n\t\tif (this.disposed || this.busy) {\n\t\t\tthis.disarm();\n\t\t\treturn;\n\t\t}\n\t\t// A blocked owner cannot receive anything before its recheck, however many tasks come due meanwhile.\n\t\tlet wakeAt = this.recheckAt ?? Number.POSITIVE_INFINITY;\n\t\tif (this.recheckAt === undefined)\n\t\t\tfor (const entry of this.tracked.values())\n\t\t\t\tif (entry.nextAt !== undefined && entry.nextAt < wakeAt) wakeAt = entry.nextAt;\n\t\tif (this.nextSampleAt !== undefined && this.nextSampleAt < wakeAt) wakeAt = this.nextSampleAt;\n\t\t// Activity reconciles many times a second; it rarely moves the next wake-up.\n\t\tif (this.timer !== undefined && this.timerAt === wakeAt) return;\n\t\tthis.disarm();\n\t\tif (!Number.isFinite(wakeAt)) return;\n\t\tconst delay = Math.min(Math.max(1, Math.ceil(wakeAt - this.clock.now())), MAX_TIMER_DELAY_MS);\n\t\tthis.timerAt = wakeAt;\n\t\tthis.timer = this.clock.setTimeout(() => {\n\t\t\tthis.timer = undefined;\n\t\t\tthis.timerAt = undefined;\n\t\t\tvoid this.wake();\n\t\t}, delay);\n\t}\n\n\tprivate async wake(): Promise<void> {\n\t\tif (this.disposed || this.busy) return;\n\t\tthis.busy = true;\n\t\ttry {\n\t\t\tconst at = this.clock.now();\n\t\t\tif (this.nextSampleAt !== undefined && this.nextSampleAt <= at) {\n\t\t\t\tawait this.sampleShellOutput(at);\n\t\t\t\tthis.nextSampleAt = this.hasSampledShells() ? at + TASK_HEARTBEAT_OUTPUT_SAMPLE_MS : undefined;\n\t\t\t}\n\t\t\tawait this.beat(at);\n\t\t} catch {\n\t\t\t// A failed check skips this boundary; the next one is already scheduled.\n\t\t} finally {\n\t\t\tthis.busy = false;\n\t\t\tthis.arm();\n\t\t}\n\t}\n\n\tprivate async beat(at: number): Promise<void> {\n\t\tif (this.recheckAt !== undefined && this.recheckAt > at) return;\n\t\tthis.recheckAt = undefined;\n\t\tconst entries = [...this.tracked.values()];\n\t\tif (!entries.some((entry) => entry.nextAt !== undefined && entry.nextAt <= at)) return;\n\t\tconst delivery = this.options.delivery();\n\t\tlet unread = false;\n\t\ttry {\n\t\t\tunread = delivery?.hasUnreadHeartbeat() === true;\n\t\t} catch {\n\t\t\tunread = false;\n\t\t}\n\t\tif (unread) {\n\t\t\t// One outstanding notice per owner: due tasks stay owed and join the next notice instead of stacking.\n\t\t\tthis.recheckAt = at + TASK_HEARTBEAT_RECHECK_MS;\n\t\t\treturn;\n\t\t}\n\t\tconst batch = entries\n\t\t\t.filter(\n\t\t\t\t(entry) =>\n\t\t\t\t\tentry.nextAt !== undefined &&\n\t\t\t\t\tentry.nextAt <= at + Math.min(TASK_HEARTBEAT_COALESCE_MS, entry.intervalMs / 4),\n\t\t\t)\n\t\t\t.sort(byBoundary);\n\t\tfor (const entry of batch)\n\t\t\tentry.nextAt = nextBoundary(entry.startedAt, entry.intervalMs, Math.max(at, entry.nextAt ?? at));\n\t\tif (!delivery) return;\n\t\tconst details = await this.describe(batch, at);\n\t\t// A task that finished while its notice was being prepared is no longer mentioned.\n\t\tconst live = (taskId: string) => this.tracked.has(taskId as TaskId);\n\t\tdetails.tasks = details.tasks.filter((task) => live(task.taskId));\n\t\tdetails.more = details.more.filter((task) => live(task.taskId));\n\t\tdetails.moreCount = batch.slice(TASK_HEARTBEAT_DETAIL_LIMIT).filter((entry) => live(entry.taskId)).length;\n\t\tif (details.tasks.length === 0 || this.disposed) return;\n\t\tawait delivery.deliver({\n\t\t\tcustomType: TASK_HEARTBEAT_MESSAGE_TYPE,\n\t\t\tcontent: formatTaskHeartbeat(details),\n\t\t\tdisplay: true,\n\t\t\tdetails,\n\t\t});\n\t}\n\n\tprivate async describe(batch: readonly Tracked[], at: number): Promise<TaskHeartbeatDetails> {\n\t\tconst detailed = batch.slice(0, TASK_HEARTBEAT_DETAIL_LIMIT);\n\t\tconst rest = batch.slice(TASK_HEARTBEAT_DETAIL_LIMIT);\n\t\tconst tasks: TaskHeartbeatTask[] = [];\n\t\tfor (const entry of detailed) tasks.push(await this.describeTask(entry, at));\n\t\treturn {\n\t\t\tscheduledAt: at,\n\t\t\ttasks,\n\t\t\tmore: rest.slice(0, TASK_HEARTBEAT_LIST_LIMIT).map((entry) => ({\n\t\t\t\ttaskId: entry.taskId,\n\t\t\t\tkind: entry.record.kind,\n\t\t\t\ttitle: singleLine(entry.record.title, TITLE_CHARS),\n\t\t\t})),\n\t\t\tmoreCount: rest.length,\n\t\t};\n\t}\n\n\tprivate async describeTask(entry: Tracked, at: number): Promise<TaskHeartbeatTask> {\n\t\tconst task = entry.record;\n\t\tconst lease = this.lease(entry.taskId);\n\t\tconst described: TaskHeartbeatTask = {\n\t\t\ttaskId: entry.taskId,\n\t\t\tkind: task.kind,\n\t\t\ttitle: singleLine(task.title, TITLE_CHARS),\n\t\t\t...(task.agentName === undefined ? {} : { agentName: singleLine(task.agentName, TITLE_CHARS) }),\n\t\t\t...(task.kind === \"agent\" && task.model !== undefined ? { model: task.model } : {}),\n\t\t\t...(task.kind === \"agent\" && task.thinking !== undefined ? { thinking: task.thinking } : {}),\n\t\t\t...(task.kind === \"agent\" && task.requestedModel !== undefined ? { requestedModel: task.requestedModel } : {}),\n\t\t\telapsedMs: Math.max(0, at - entry.startedAt),\n\t\t\tintervalMs: entry.intervalMs,\n\t\t};\n\t\tif (task.kind === \"command\" && lease) {\n\t\t\tconst end = await this.observeOutput(entry, lease, at);\n\t\t\tif (end !== undefined) described.output = { bytes: Number(end), tail: await this.outputTail(lease, end) };\n\t\t}\n\t\tif (entry.lastActivityAt !== undefined) described.lastActivityAgoMs = Math.max(0, at - entry.lastActivityAt);\n\t\tif (task.kind === \"agent\") {\n\t\t\tconst entries = lease ? taskOwnTranscriptEntries(lease) : undefined;\n\t\t\tif (task.currentAction)\n\t\t\t\tdescribed.currentAction = {\n\t\t\t\t\ttool: singleLine(task.currentAction.tool, 60),\n\t\t\t\t\ttext: singleLine(task.currentAction.text, LINE_CHARS),\n\t\t\t\t\t// The record keeps the last reported action after its tool returns. The child's own history says\n\t\t\t\t\t// whether a call is still outstanding: its last message is an assistant turn that called tools.\n\t\t\t\t\trunning: entries !== undefined && endsInToolCall(entries),\n\t\t\t\t};\n\t\t\tif (task.metrics?.toolCount !== undefined) described.toolCount = task.metrics.toolCount;\n\t\t\tif (task.metrics?.tokenCount !== undefined) described.tokenCount = task.metrics.tokenCount;\n\t\t\tif (entries)\n\t\t\t\tdescribed.turnCount = entries.filter(\n\t\t\t\t\t(item) => item.type === \"message\" && item.message.role === \"assistant\",\n\t\t\t\t).length;\n\t\t}\n\t\tif (task.attention.kind === \"input-needed\")\n\t\t\tdescribed.attention = `waiting for input: ${singleLine(task.attention.prompt, LINE_CHARS)}`;\n\t\telse if (task.attention.kind === \"no-recent-activity\") described.attention = \"no recent activity\";\n\t\treturn described;\n\t}\n\n\tprivate lease(taskId: TaskId): TaskLease | undefined {\n\t\tconst found = this.options.supervisor.lookupTask(this.options.owner, taskId);\n\t\treturn found.ok ? found.value : undefined;\n\t}\n\n\tprivate async sampleShellOutput(at: number): Promise<void> {\n\t\tfor (const entry of [...this.tracked.values()]) {\n\t\t\tif (entry.record.kind !== \"command\" || entry.intervalMs === 0) continue;\n\t\t\tconst lease = this.lease(entry.taskId);\n\t\t\tif (lease) await this.observeOutput(entry, lease, at);\n\t\t}\n\t}\n\n\t/** Current retained output size; growth since the last look dates the shell's last output. */\n\tprivate async observeOutput(entry: Tracked, lease: TaskLease, at: number): Promise<bigint | undefined> {\n\t\tconst end = await findOutputEnd(this.options.supervisor, lease, entry.outputEnd);\n\t\tif (end === undefined) return undefined;\n\t\tif (end > entry.outputEnd) {\n\t\t\tentry.outputEnd = end;\n\t\t\tentry.lastActivityAt = at;\n\t\t}\n\t\treturn end;\n\t}\n\n\tprivate async outputTail(lease: TaskLease, end: bigint): Promise<string[]> {\n\t\tif (end === 0n) return [];\n\t\tconst start = end > BigInt(OUTPUT_TAIL_BYTES) ? end - BigInt(OUTPUT_TAIL_BYTES) : 0n;\n\t\tconst page = await this.options.supervisor.readTaskOutput(lease, {\n\t\t\tstart: String(start),\n\t\t\tmaximumBytes: OUTPUT_TAIL_BYTES,\n\t\t});\n\t\tif (!page.ok) return [];\n\t\tconst lines = taskOutputText(page.value).split(\"\\n\");\n\t\t// The window can open mid-line; that fragment is not a line of output.\n\t\tif (start > 0n) lines.shift();\n\t\treturn lines\n\t\t\t.map((line) => {\n\t\t\t\t// A CRLF ending is not a redraw; a carriage return inside a line redraws it, so its last state counts.\n\t\t\t\tconst ended = line.replace(/\\r+$/, \"\");\n\t\t\t\treturn singleLine(ended.slice(ended.lastIndexOf(\"\\r\") + 1), LINE_CHARS).trimEnd();\n\t\t\t})\n\t\t\t.filter((line) => line.trim().length > 0)\n\t\t\t.slice(-OUTPUT_TAIL_LINES);\n\t}\n}\n\n/**\n * Retained output size of a running shell, found with one-byte reads: a read past the end returns nothing. Gallops\n * from the last known size, then bisects, so a large burst of output costs a few dozen tiny reads, not a full scan.\n */\nasync function findOutputEnd(supervisor: TaskSupervisor, lease: TaskLease, from: bigint): Promise<bigint | undefined> {\n\tconst probe = async (offset: bigint): Promise<{ before: boolean; end: bigint } | undefined> => {\n\t\tconst page = await supervisor.readTaskOutput(lease, { start: String(offset), maximumBytes: 1 });\n\t\tif (!page.ok) return undefined;\n\t\tif (page.value.nextOffset !== undefined) return { before: true, end: BigInt(page.value.nextOffset) };\n\t\tlet end = offset;\n\t\tfor (const chunk of page.value.chunks) if (BigInt(chunk.offsets.end) > end) end = BigInt(chunk.offsets.end);\n\t\tfor (const range of page.value.omittedRanges) if (BigInt(range.end) > end) end = BigInt(range.end);\n\t\t// No byte beyond this page: the output ends at its last byte, or at or before `offset` when it is empty.\n\t\treturn { before: end > offset, end };\n\t};\n\tlet low = from;\n\tconst first = await probe(low);\n\tif (!first) return undefined;\n\tif (!first.before) return first.end > from ? first.end : from;\n\tlet step = 65_536n;\n\tlet high = low + step;\n\tfor (;;) {\n\t\tconst result = await probe(high);\n\t\tif (!result) return undefined;\n\t\tif (!result.before) {\n\t\t\tif (result.end > high) return result.end;\n\t\t\tbreak;\n\t\t}\n\t\tlow = high;\n\t\tstep *= 2n;\n\t\thigh = low + step;\n\t}\n\t// The output ends after `low` and at or before `high`.\n\twhile (high - low > 1n) {\n\t\tconst middle = low + (high - low) / 2n;\n\t\tconst result = await probe(middle);\n\t\tif (!result) return undefined;\n\t\tif (result.before) low = middle;\n\t\telse if (result.end > middle) return result.end;\n\t\telse high = middle;\n\t}\n\treturn high;\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import type {
|
|
1
|
+
import type { AgentTool, AgentToolParams } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { TSchema } from "typebox";
|
|
3
3
|
import type { ExtensionContext, ToolDefinition } from "../extensions/types.ts";
|
|
4
4
|
import type { ToolConcurrency } from "./tool-concurrency.ts";
|
|
5
5
|
declare module "@earendil-works/pi-agent-core" {
|
|
6
|
-
interface AgentTool<TParameters extends
|
|
6
|
+
interface AgentTool<TParameters extends object = object, TDetails = any> {
|
|
7
7
|
/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out. */
|
|
8
8
|
maxResultSizeChars?: number;
|
|
9
9
|
/** Optional prompt metadata retained by factory-created tools registered as extensions. */
|
|
10
10
|
promptSnippet?: string;
|
|
11
11
|
promptGuidelines?: string[];
|
|
12
12
|
/** Ordering against the other calls of the same assistant message; see ToolDefinition.concurrency. */
|
|
13
|
-
concurrency?: ToolConcurrency<
|
|
13
|
+
concurrency?: ToolConcurrency<AgentToolParams<TParameters>>;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
/** Wrap a ToolDefinition into an AgentTool for the core runtime. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-definition-wrapper.d.ts","sourceRoot":"","sources":["../../../src/core/tools/tool-definition-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAU,OAAO,EAAE,MAAM,SAAS,CAAC;AAE/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,QAAQ,+BAA+B,CAAC;IAC9C,UAAU,SAAS,CAAC,WAAW,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,GAAG,GAAG;QACtE,qGAAqG;QACrG,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,2FAA2F;QAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC5B,sGAAsG;QACtG,WAAW,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;KAC5D;CACD;AAYD,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,OAAO,EAAE,QAAQ,GAAG,OAAO,EAC7E,UAAU,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,EAC7C,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,KAAK,gBAAgB,GACpF,SAAS,CAAC,OAAO,EAAE,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;QACxG,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;QAC3C,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAoB,CAAC,CAAC,CAAC,SAAS;QAChH,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,CAC/D,IAAI,CAAC,OAAqD,CAC1D,UAAU,EACV,MAA+B,EAC/B,MAAM,EACN,QAAQ,EACR,OAAO,CACP;KACF,CAAC;AACH,CAAC","sourcesContent":["import type { AgentTool, AgentToolParams } from \"@earendil-works/pi-agent-core\";\nimport type { Static, TSchema } from \"typebox\";\nimport { runCallback, runSynchronousCallback } from \"../callback-activity.ts\";\nimport type { ExtensionContext, ToolDefinition } from \"../extensions/types.ts\";\nimport type { ToolConcurrency } from \"./tool-concurrency.ts\";\n\ndeclare module \"@earendil-works/pi-agent-core\" {\n\tinterface AgentTool<TParameters extends object = object, TDetails = any> {\n\t\t/** Optional per-tool character cap for model-visible result persistence. Use Infinity to opt out. */\n\t\tmaxResultSizeChars?: number;\n\t\t/** Optional prompt metadata retained by factory-created tools registered as extensions. */\n\t\tpromptSnippet?: string;\n\t\tpromptGuidelines?: string[];\n\t\t/** Ordering against the other calls of the same assistant message; see ToolDefinition.concurrency. */\n\t\tconcurrency?: ToolConcurrency<AgentToolParams<TParameters>>;\n\t}\n}\n\ntype PiToolParams<TParams extends TSchema> = Parameters<AgentTool<TParams>[\"execute\"]>[1];\ntype PiPreparedParams<TParams extends TSchema> = ReturnType<NonNullable<AgentTool<TParams>[\"prepareArguments\"]>>;\ntype ContextualAgentExecute<TParams extends TSchema, TDetails> = (\n\ttoolCallId: string,\n\tparams: PiToolParams<TParams>,\n\tsignal?: AbortSignal,\n\tonUpdate?: Parameters<AgentTool<TParams, TDetails>[\"execute\"]>[3],\n\tcontext?: ExtensionContext,\n) => ReturnType<AgentTool<TParams, TDetails>[\"execute\"]>;\n\n/** Wrap a ToolDefinition into an AgentTool for the core runtime. */\nexport function wrapToolDefinition<TParams extends TSchema, TDetails = unknown>(\n\tdefinition: ToolDefinition<TParams, TDetails>,\n\tctxFactory?: (toolCallId: string, signal: AbortSignal | undefined) => ExtensionContext,\n): AgentTool<TParams, TDetails> {\n\treturn {\n\t\tname: definition.name,\n\t\tlabel: definition.label,\n\t\tdescription: definition.description,\n\t\tparameters: definition.parameters,\n\t\toutputSchema: definition.outputSchema,\n\t\t...(Object.hasOwn(definition, \"constrainedSampling\")\n\t\t\t? { constrainedSampling: definition.constrainedSampling }\n\t\t\t: {}),\n\t\tpromptSnippet: definition.promptSnippet,\n\t\tpromptGuidelines: definition.promptGuidelines ? [...definition.promptGuidelines] : undefined,\n\t\tmaxResultSizeChars: definition.maxResultSizeChars,\n\t\tprepareArguments: definition.prepareArguments\n\t\t\t? (args) =>\n\t\t\t\t\trunSynchronousCallback(\n\t\t\t\t\t\t{ kind: \"tool.prepare\", name: definition.name },\n\t\t\t\t\t\t() => definition.prepareArguments?.(args) as PiPreparedParams<TParams>,\n\t\t\t\t\t)\n\t\t\t: undefined,\n\t\texecutionMode: definition.executionMode,\n\t\tconcurrency: definition.concurrency as AgentTool<TParams>[\"concurrency\"],\n\t\texecute: (toolCallId, params, signal, onUpdate, context?: ExtensionContext) =>\n\t\t\trunCallback({ kind: \"tool.execute\", name: definition.name, toolCallId }, () =>\n\t\t\t\tdefinition.execute(\n\t\t\t\t\ttoolCallId,\n\t\t\t\t\tparams as Static<TParams>,\n\t\t\t\t\tsignal,\n\t\t\t\t\tonUpdate,\n\t\t\t\t\t(context ??\n\t\t\t\t\t\tctxFactory?.(toolCallId, signal)) as import(\"../extensions/context-types.ts\").ExtensionToolContext,\n\t\t\t\t),\n\t\t\t),\n\t};\n}\n\n/** Wrap multiple ToolDefinitions into AgentTools for the core runtime. */\nexport function wrapToolDefinitions(\n\tdefinitions: ToolDefinition<TSchema, unknown>[],\n\tctxFactory?: () => ExtensionContext,\n): AgentTool<TSchema, unknown>[] {\n\treturn definitions.map((definition) => wrapToolDefinition(definition, ctxFactory));\n}\n\n/**\n * Synthesize a minimal ToolDefinition from an AgentTool.\n *\n * This keeps AgentSession's internal registry definition-first even when a caller\n * provides plain AgentTool overrides that do not include prompt metadata or renderers.\n */\nexport function createToolDefinitionFromAgentTool<TParams extends TSchema = TSchema, TDetails = unknown>(\n\ttool: AgentTool<TParams, TDetails>,\n): ToolDefinition<TParams, TDetails> {\n\treturn {\n\t\tname: tool.name,\n\t\tlabel: tool.label,\n\t\tdescription: tool.description,\n\t\tparameters: tool.parameters,\n\t\toutputSchema: tool.outputSchema,\n\t\t...(Object.hasOwn(tool, \"constrainedSampling\") ? { constrainedSampling: tool.constrainedSampling } : {}),\n\t\tpromptSnippet: tool.promptSnippet,\n\t\tpromptGuidelines: tool.promptGuidelines,\n\t\tmaxResultSizeChars: tool.maxResultSizeChars,\n\t\tprepareArguments: tool.prepareArguments ? (args) => tool.prepareArguments?.(args) as Static<TParams> : undefined,\n\t\texecutionMode: tool.executionMode,\n\t\tconcurrency: tool.concurrency,\n\t\texecute: async (toolCallId, params, signal, onUpdate, context) =>\n\t\t\t(tool.execute as ContextualAgentExecute<TParams, TDetails>)(\n\t\t\t\ttoolCallId,\n\t\t\t\tparams as PiToolParams<TParams>,\n\t\t\t\tsignal,\n\t\t\t\tonUpdate,\n\t\t\t\tcontext,\n\t\t\t),\n\t};\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../src/core/tools/write.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS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,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAChE;AAoED,MAAM,WAAW,gBAAgB;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,iFAAiF;IACjF,wBAAwB,CAAC,EAAE,yBAAyB,CAAC;CACrD;AAkJD,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,gBAAgB,GACxB,cAAc,CAAC,OAAO,WAAW,EAAE,gBAAgB,GAAG,SAAS,CAAC,CAsRlE;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC,OAAO,WAAW,CAAC,CAEtG"}
|
package/dist/core/tools/write.js
CHANGED
|
@@ -3,7 +3,7 @@ import { chmod as fsChmod, mkdir as fsMkdir, readFile as fsReadFile, stat as fsS
|
|
|
3
3
|
import { dirname } from "path";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
5
|
import { parenthesizedKeyHint } from "../../modes/interactive/components/keybinding-hints.js";
|
|
6
|
-
import { getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
6
|
+
import { CodeHighlighter, getLanguageFromPath, highlightCode } from "../../modes/interactive/theme/theme.js";
|
|
7
7
|
import { findConflictBlocks, reconcileConflictBlocks } from "./conflict-registry.js";
|
|
8
8
|
import { assertPriorSessionObservation, computeLiveState, FileMutationConflict, filesystemErrorCode, isExclusiveCreateCollision, isMissingTargetError, } from "./file-mutation-coordinator.js";
|
|
9
9
|
import { withFileMutationQueue } from "./file-mutation-queue.js";
|
|
@@ -98,6 +98,7 @@ const defaultWriteOperations = {
|
|
|
98
98
|
};
|
|
99
99
|
class WriteCallRenderComponent extends Text {
|
|
100
100
|
cache;
|
|
101
|
+
highlighter = new CodeHighlighter();
|
|
101
102
|
constructor() {
|
|
102
103
|
super("", 0, 0);
|
|
103
104
|
}
|
|
@@ -107,12 +108,12 @@ function highlightSingleLine(line, lang) {
|
|
|
107
108
|
const highlighted = highlightCode(line, lang);
|
|
108
109
|
return highlighted[0] ?? "";
|
|
109
110
|
}
|
|
110
|
-
function refreshWriteHighlightPrefix(cache) {
|
|
111
|
+
function refreshWriteHighlightPrefix(cache, highlighter) {
|
|
111
112
|
const prefixCount = Math.min(WRITE_PARTIAL_FULL_HIGHLIGHT_LINES, cache.normalizedLines.length);
|
|
112
113
|
if (prefixCount === 0)
|
|
113
114
|
return;
|
|
114
115
|
const prefixSource = cache.normalizedLines.slice(0, prefixCount).join("\n");
|
|
115
|
-
const prefixHighlighted =
|
|
116
|
+
const prefixHighlighted = highlighter.highlight(prefixSource, cache.lang);
|
|
116
117
|
for (let i = 0; i < prefixCount; i++) {
|
|
117
118
|
cache.highlightedLines[i] =
|
|
118
119
|
prefixHighlighted[i] ?? highlightSingleLine(cache.normalizedLines[i] ?? "", cache.lang);
|
|
@@ -132,7 +133,7 @@ function rebuildWriteHighlightCacheFull(rawPath, fileContent) {
|
|
|
132
133
|
highlightedLines: highlightCode(normalized, lang),
|
|
133
134
|
};
|
|
134
135
|
}
|
|
135
|
-
function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent) {
|
|
136
|
+
function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent, highlighter) {
|
|
136
137
|
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
137
138
|
if (!lang)
|
|
138
139
|
return undefined;
|
|
@@ -160,7 +161,7 @@ function updateWriteHighlightCacheIncremental(cache, rawPath, fileContent) {
|
|
|
160
161
|
cache.normalizedLines.push(segments[i]);
|
|
161
162
|
cache.highlightedLines.push(highlightSingleLine(segments[i], cache.lang));
|
|
162
163
|
}
|
|
163
|
-
refreshWriteHighlightPrefix(cache);
|
|
164
|
+
refreshWriteHighlightPrefix(cache, highlighter);
|
|
164
165
|
return cache;
|
|
165
166
|
}
|
|
166
167
|
function trimTrailingEmptyLines(lines) {
|
|
@@ -170,7 +171,7 @@ function trimTrailingEmptyLines(lines) {
|
|
|
170
171
|
}
|
|
171
172
|
return lines.slice(0, end);
|
|
172
173
|
}
|
|
173
|
-
function formatWriteCall(args, options, theme, cache) {
|
|
174
|
+
function formatWriteCall(args, options, theme, cache, highlighter) {
|
|
174
175
|
const rawPath = str(args?.path);
|
|
175
176
|
const fileContent = str(args?.content);
|
|
176
177
|
const path = rawPath !== null ? shortenPath(rawPath) : null;
|
|
@@ -182,7 +183,7 @@ function formatWriteCall(args, options, theme, cache) {
|
|
|
182
183
|
else if (fileContent) {
|
|
183
184
|
const lang = rawPath ? getLanguageFromPath(rawPath) : undefined;
|
|
184
185
|
const renderedLines = lang
|
|
185
|
-
? (cache?.highlightedLines ??
|
|
186
|
+
? (cache?.highlightedLines ?? highlighter.highlight(replaceTabs(normalizeDisplayText(fileContent)), lang))
|
|
186
187
|
: normalizeDisplayText(fileContent).split("\n");
|
|
187
188
|
const lines = trimTrailingEmptyLines(renderedLines);
|
|
188
189
|
const totalLines = lines.length;
|
|
@@ -438,15 +439,11 @@ export function createWriteToolDefinition(cwd, options) {
|
|
|
438
439
|
const rawPath = str(renderArgs?.path);
|
|
439
440
|
const fileContent = str(renderArgs?.content);
|
|
440
441
|
const component = context.lastComponent ?? new WriteCallRenderComponent();
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
?
|
|
444
|
-
:
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
component.cache = undefined;
|
|
448
|
-
}
|
|
449
|
-
component.setText(formatWriteCall(renderArgs, { expanded: context.expanded, isPartial: context.isPartial }, theme, component.cache));
|
|
442
|
+
component.cache =
|
|
443
|
+
fileContent !== null && !context.argsComplete
|
|
444
|
+
? updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent, component.highlighter)
|
|
445
|
+
: undefined;
|
|
446
|
+
component.setText(formatWriteCall(renderArgs, { expanded: context.expanded, isPartial: context.isPartial }, theme, component.cache, component.highlighter));
|
|
450
447
|
return component;
|
|
451
448
|
},
|
|
452
449
|
renderResult(result, _options, theme, context) {
|
|
@@ -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,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,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,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACN,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EAEpB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,GAEpB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,qBAAqB,EAErB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,+BAA+B,EAC/B,uCAAuC,GACvC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,E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AU,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\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname } 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, findConflictBlocks, reconcileConflictBlocks } 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\tisInternalUrl,\n\tisUrlLike,\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 (local://), archive entry, SQLite row selector, or conflict resolution target (conflict://).\",\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\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\tconcurrency: \"exclusive\",\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 (isUrlLike(path) && !isInternalUrl(path))\n\t\t\t\tthrow new Error(`Write resource selectors are not supported by this filesystem backend: ${path}`);\n\t\t\tif (isInternalUrl(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
|
+
{"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,QAAQ,IAAI,UAAU,EACtB,IAAI,IAAI,MAAM,EACd,SAAS,IAAI,WAAW,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wDAAwD,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAE7G,OAAO,EAAsB,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACzG,OAAO,EACN,6BAA6B,EAC7B,gBAAgB,EAChB,oBAAoB,EAEpB,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,GAEpB,MAAM,gCAAgC,CAAC;AACxC,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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\treadFile as fsReadFile,\n\tstat as fsStat,\n\twriteFile as fsWriteFile,\n} from \"fs/promises\";\nimport { dirname } from \"path\";\nimport { type Static, Type } from \"typebox\";\nimport { parenthesizedKeyHint } from \"../../modes/interactive/components/keybinding-hints.js\";\nimport { CodeHighlighter, getLanguageFromPath, highlightCode } from \"../../modes/interactive/theme/theme.js\";\nimport type { ExtensionContext, ToolDefinition, ToolRenderResultOptions } from \"../extensions/types.ts\";\nimport { type ConflictBlock, findConflictBlocks, reconcileConflictBlocks } 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\tisInternalUrl,\n\tisUrlLike,\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 (local://), archive entry, SQLite row selector, or conflict resolution target (conflict://).\",\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\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\treadonly highlighter = new CodeHighlighter();\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, highlighter: CodeHighlighter): 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 = highlighter.highlight(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\thighlighter: CodeHighlighter,\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, highlighter);\n\treturn cache;\n}\n\nfunction trimTrailingEmptyLines(lines: readonly 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\thighlighter: CodeHighlighter,\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 ?? highlighter.highlight(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\tconcurrency: \"exclusive\",\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 (isUrlLike(path) && !isInternalUrl(path))\n\t\t\t\tthrow new Error(`Write resource selectors are not supported by this filesystem backend: ${path}`);\n\t\t\tif (isInternalUrl(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\tcomponent.cache =\n\t\t\t\tfileContent !== null && !context.argsComplete\n\t\t\t\t\t? updateWriteHighlightCacheIncremental(component.cache, rawPath, fileContent, component.highlighter)\n\t\t\t\t\t: undefined;\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\tcomponent.highlighter,\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/extensions/codemode/renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAKN,KAAK,cAAc,EAEnB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAsB,mBAAmB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../src/extensions/codemode/renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAKN,KAAK,cAAc,EAEnB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,KAAK,EAAsB,mBAAmB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AA8BzF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAAI,CACnC,cAAc,CAAC,OAAO,cAAc,EAAE,mBAAmB,EAAE,cAAc,CAAC,EAC1E,YAAY,GAAG,cAAc,CA6E7B,CAAC"}
|