@bastani/atomic 0.9.12 → 0.9.13-alpha.2
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 +150 -0
- package/README.md +35 -17
- package/dist/builtin/i-have-adhd/CHANGELOG.md +17 -0
- package/dist/builtin/i-have-adhd/LICENSE +21 -0
- package/dist/builtin/i-have-adhd/README.md +18 -0
- package/dist/builtin/i-have-adhd/index.ts +238 -0
- package/dist/builtin/i-have-adhd/package.json +56 -0
- package/dist/builtin/i-have-adhd/skills/i-have-adhd/SKILL.md +140 -0
- package/dist/builtin/intercom/CHANGELOG.md +25 -0
- package/dist/builtin/intercom/README.md +30 -16
- package/dist/builtin/intercom/broker/bounded-stderr-install.ts +18 -0
- package/dist/builtin/intercom/broker/bounded-stderr.ts +132 -0
- package/dist/builtin/intercom/broker/broker.ts +12 -23
- package/dist/builtin/intercom/broker/client.ts +81 -5
- package/dist/builtin/intercom/broker/paths.ts +9 -0
- package/dist/builtin/intercom/broker/presence-handler.ts +103 -0
- package/dist/builtin/intercom/broker/spawn.ts +128 -29
- package/dist/builtin/intercom/contact-supervisor-tool.ts +13 -3
- package/dist/builtin/intercom/foreground-detach-handoff.ts +30 -14
- package/dist/builtin/intercom/group.ts +64 -25
- package/dist/builtin/intercom/index-heavy.ts +51 -8
- package/dist/builtin/intercom/index.ts +50 -22
- package/dist/builtin/intercom/intercom-tool.ts +82 -5
- package/dist/builtin/intercom/intercom-utils.ts +15 -29
- package/dist/builtin/intercom/lazy-subagent-ack.ts +11 -6
- package/dist/builtin/intercom/package.json +2 -3
- package/dist/builtin/intercom/runtime-group.ts +13 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +30 -2
- package/dist/builtin/intercom/source-ownership.ts +9 -12
- package/dist/builtin/intercom/subagent-relay.ts +32 -16
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +21 -4
- package/dist/builtin/intercom/types.ts +3 -1
- package/dist/builtin/intercom/ui/compose.ts +8 -6
- package/dist/builtin/intercom/ui/session-list.ts +7 -5
- package/dist/builtin/mcp/CHANGELOG.md +19 -0
- package/dist/builtin/mcp/README.md +3 -1
- package/dist/builtin/mcp/glimpse-ui.ts +2 -1
- package/dist/builtin/mcp/index.ts +10 -26
- package/dist/builtin/mcp/mcp-panel.ts +35 -34
- package/dist/builtin/mcp/mcp-setup-panel.ts +35 -33
- package/dist/builtin/mcp/npx-resolver.ts +3 -2
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/sampling-handler.ts +5 -1
- package/dist/builtin/mcp/server-manager.ts +4 -7
- package/dist/builtin/mcp/startup-warmup.ts +20 -8
- package/dist/builtin/subagents/CHANGELOG.md +63 -0
- package/dist/builtin/subagents/README.md +144 -351
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +5 -5
- package/dist/builtin/subagents/prompts/parallel-context-build.md +2 -2
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +4 -4
- package/dist/builtin/subagents/prompts/review-loop.md +1 -1
- package/dist/builtin/subagents/skills/subagent/SKILL.md +39 -102
- package/dist/builtin/subagents/src/agents/agent-discovery.ts +1 -29
- package/dist/builtin/subagents/src/agents/agent-loaders.ts +1 -40
- package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +6 -135
- package/dist/builtin/subagents/src/agents/agent-management.ts +52 -282
- package/dist/builtin/subagents/src/agents/agent-paths.ts +0 -22
- package/dist/builtin/subagents/src/agents/agent-types.ts +0 -40
- package/dist/builtin/subagents/src/agents/agents.ts +0 -3
- package/dist/builtin/subagents/src/agents/identity.ts +2 -4
- package/dist/builtin/subagents/src/agents/skills-paths.ts +8 -1
- package/dist/builtin/subagents/src/extension/doctor.ts +4 -24
- package/dist/builtin/subagents/src/extension/fanout-child.ts +76 -56
- package/dist/builtin/subagents/src/extension/index.ts +32 -39
- package/dist/builtin/subagents/src/extension/prompt-guidance.ts +2 -2
- package/dist/builtin/subagents/src/extension/schemas.ts +1 -157
- package/dist/builtin/subagents/src/extension/startup-maintenance.ts +25 -46
- package/dist/builtin/subagents/src/extension/tool-description.ts +4 -13
- package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +6 -2
- package/dist/builtin/subagents/src/intercom/result-intercom.ts +27 -29
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +9 -2
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +248 -435
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +8 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +83 -26
- package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +1 -281
- package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +0 -5
- package/dist/builtin/subagents/src/runs/foreground/execution.ts +1 -4
- package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +559 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +103 -259
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +29 -31
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +10 -173
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +7 -5
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +13 -6
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +1 -646
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +2 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +14 -7
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +39 -20
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +16 -11
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +1 -14
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +194 -104
- package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +195 -0
- package/dist/builtin/subagents/src/runs/inprocess/background.ts +90 -0
- package/dist/builtin/subagents/src/runs/inprocess/child-policy.ts +27 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +55 -0
- package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +106 -0
- package/dist/builtin/subagents/src/runs/inprocess/index.ts +50 -0
- package/dist/builtin/subagents/src/runs/inprocess/nested-routing.ts +218 -0
- package/dist/builtin/subagents/src/runs/{shared/subagent-prompt-runtime.ts → inprocess/prompt-behavior.ts} +37 -75
- package/dist/builtin/subagents/src/runs/inprocess/runner.ts +1392 -0
- package/dist/builtin/subagents/src/runs/{shared/nested-events.ts → inprocess/runtime-support/nested-api.ts} +13 -7
- package/dist/builtin/subagents/src/runs/{shared/nested-events-control.ts → inprocess/runtime-support/nested-control.ts} +18 -17
- package/dist/builtin/subagents/src/runs/{shared/nested-events-core.ts → inprocess/runtime-support/nested-core.ts} +14 -61
- package/dist/builtin/subagents/src/runs/{shared/nested-events-projection.ts → inprocess/runtime-support/nested-projection.ts} +4 -12
- package/dist/builtin/subagents/src/runs/{shared/nested-events-registry.ts → inprocess/runtime-support/nested-registry.ts} +19 -4
- package/dist/builtin/subagents/src/runs/{shared/nested-render.ts → inprocess/runtime-support/nested-rendering.ts} +3 -3
- package/dist/builtin/subagents/src/runs/{shared/nested-events-sanitize.ts → inprocess/runtime-support/nested-sanitize.ts} +4 -6
- package/dist/builtin/subagents/src/runs/inprocess.ts +1 -0
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +23 -7
- package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +0 -1
- package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +15 -492
- package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +13 -97
- package/dist/builtin/subagents/src/runs/shared/run-history.ts +3 -5
- package/dist/builtin/subagents/src/runs/shared/single-output.ts +4 -4
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +7 -2
- package/dist/builtin/subagents/src/shared/formatters.ts +2 -56
- package/dist/builtin/subagents/src/shared/settings.ts +14 -350
- package/dist/builtin/subagents/src/shared/types-async.ts +8 -32
- package/dist/builtin/subagents/src/shared/types-config.ts +29 -13
- package/dist/builtin/subagents/src/shared/types-depth.ts +30 -56
- package/dist/builtin/subagents/src/shared/types-results.ts +18 -60
- package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -1
- package/dist/builtin/subagents/src/shared/utils.ts +5 -0
- package/dist/builtin/subagents/src/slash/bridge-settlement.ts +87 -0
- package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +49 -10
- package/dist/builtin/subagents/src/slash/slash-bridge.ts +27 -7
- package/dist/builtin/subagents/src/slash/slash-commands.ts +37 -82
- package/dist/builtin/subagents/src/slash/slash-live-state.ts +3 -94
- package/dist/builtin/subagents/src/tui/render-event-formatting.ts +3 -35
- package/dist/builtin/subagents/src/tui/render-progress.ts +89 -0
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +77 -68
- package/dist/builtin/subagents/src/tui/render-result.ts +79 -99
- package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -6
- package/dist/builtin/subagents/src/tui/render-status-progress.ts +8 -5
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +6 -63
- package/dist/builtin/subagents/src/tui/render-widget.ts +0 -24
- package/dist/builtin/web-access/CHANGELOG.md +14 -0
- package/dist/builtin/web-access/chrome-cookies.ts +3 -2
- package/dist/builtin/web-access/github-api.ts +7 -6
- package/dist/builtin/web-access/github-extract.ts +2 -1
- package/dist/builtin/web-access/package.json +3 -3
- package/dist/builtin/web-access/subprocess.ts +3 -1
- package/dist/builtin/web-access/summary-review.ts +2 -2
- package/dist/builtin/web-access/web-search-features.ts +38 -22
- package/dist/builtin/web-access/web-search-summary.ts +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +70 -0
- package/dist/builtin/workflows/README.md +54 -4
- package/dist/builtin/workflows/builtin/open-claude-design-utils.ts +3 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +25 -20
- package/dist/builtin/workflows/builtin/shared-prompts.ts +5 -2
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/durable/backend.ts +25 -1
- package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +60 -3
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +67 -1
- package/dist/builtin/workflows/src/durable/completed-subtree.ts +22 -7
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +15 -1
- package/dist/builtin/workflows/src/durable/local-command.ts +2 -1
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +1 -0
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +4 -28
- package/dist/builtin/workflows/src/durable/types.ts +22 -1
- package/dist/builtin/workflows/src/durable/workflow-child-result.ts +3 -1
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +1 -1
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +10 -2
- package/dist/builtin/workflows/src/engine/run-durable-topology.ts +9 -2
- package/dist/builtin/workflows/src/engine/run.ts +17 -1
- package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +18 -39
- package/dist/builtin/workflows/src/extension/companions.ts +1 -1
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +10 -1
- package/dist/builtin/workflows/src/extension/config-loader.ts +1 -1
- package/dist/builtin/workflows/src/extension/dispatcher.ts +4 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +2095 -1181
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +332 -39
- package/dist/builtin/workflows/src/extension/mcp.ts +13 -2
- package/dist/builtin/workflows/src/extension/render-result.ts +5 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -3
- package/dist/builtin/workflows/src/extension/runtime.ts +7 -1
- package/dist/builtin/workflows/src/extension/ui-surface.ts +7 -20
- package/dist/builtin/workflows/src/extension/wiring.ts +86 -17
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +12 -3
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +5 -2
- package/dist/builtin/workflows/src/extension/workflow-ports.ts +14 -6
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +11 -6
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +17 -7
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +11 -0
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +18 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +12 -8
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +9 -4
- package/dist/builtin/workflows/src/intercom/intercom-routing.ts +12 -6
- package/dist/builtin/workflows/src/intercom/result-intercom.ts +35 -4
- package/dist/builtin/workflows/src/runs/background/quit.ts +28 -4
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +2 -1
- package/dist/builtin/workflows/src/runs/background/status.ts +70 -8
- package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +11 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +2 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +4 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +26 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +3 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +3 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +688 -38
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +3 -1
- package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +19 -514
- package/dist/builtin/workflows/src/runs/shared/retry.ts +44 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +5 -2
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +2 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +10 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +11 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +34 -2
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +28 -6
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +3 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +4 -0
- package/dist/builtin/workflows/src/shared/run-indicator-status.ts +75 -0
- package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +10 -4
- package/dist/builtin/workflows/src/shared/store-public-types.ts +47 -9
- package/dist/builtin/workflows/src/shared/store-run-methods.ts +42 -8
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +31 -8
- package/dist/builtin/workflows/src/shared/store-types.ts +35 -1
- package/dist/builtin/workflows/src/shared/timing.ts +10 -0
- package/dist/builtin/workflows/src/shared/workflow-artifact-env.ts +21 -0
- package/dist/builtin/workflows/src/shared/workflow-artifacts.ts +2 -5
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +22 -2
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +37 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +0 -15
- package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +38 -47
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +48 -45
- package/dist/builtin/workflows/src/tui/graph-view-layout.ts +266 -0
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +1 -86
- package/dist/builtin/workflows/src/tui/graph-view-render.ts +209 -91
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +5 -7
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +13 -7
- package/dist/builtin/workflows/src/tui/inline-form-editor.ts +8 -6
- package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +2 -1
- package/dist/builtin/workflows/src/tui/inputs-overlay.ts +7 -4
- package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +66 -0
- package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +1 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -1
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +18 -46
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +15 -26
- package/dist/builtin/workflows/src/tui/session-list.ts +1 -1
- package/dist/builtin/workflows/src/tui/session-overlays.ts +19 -12
- package/dist/builtin/workflows/src/tui/session-picker.ts +47 -4
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +5 -14
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +8 -7
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +12 -3
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +1 -11
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +0 -8
- package/dist/builtin/workflows/src/tui/status-list.ts +32 -47
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +9 -5
- package/dist/builtin/workflows/src/tui/widget.ts +16 -46
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +0 -15
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +2 -26
- package/dist/builtin/workflows/src/tui/workflow-status.ts +3 -3
- package/dist/bun/split-loader.js +2 -0
- package/dist/bun/split-loader.js.map +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -2
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/auth-check.d.ts +35 -0
- package/dist/cli/auth-check.d.ts.map +1 -0
- package/dist/cli/auth-check.js +100 -0
- package/dist/cli/auth-check.js.map +1 -0
- package/dist/cli/auth-command.d.ts +27 -0
- package/dist/cli/auth-command.d.ts.map +1 -0
- package/dist/cli/auth-command.js +150 -0
- package/dist/cli/auth-command.js.map +1 -0
- package/dist/cli/config-selector.js +2 -2
- package/dist/cli/config-selector.js.map +1 -1
- package/dist/cli/credential-print.d.ts +18 -23
- package/dist/cli/credential-print.d.ts.map +1 -1
- package/dist/cli/credential-print.js +42 -88
- package/dist/cli/credential-print.js.map +1 -1
- package/dist/cli/experimental/auth.d.ts +16 -0
- package/dist/cli/experimental/auth.d.ts.map +1 -0
- package/dist/cli/experimental/auth.js +13 -0
- package/dist/cli/experimental/auth.js.map +1 -0
- package/dist/cli/experimental/cli.d.ts +6 -0
- package/dist/cli/experimental/cli.d.ts.map +1 -0
- package/dist/cli/experimental/cli.js +5 -0
- package/dist/cli/experimental/cli.js.map +1 -0
- package/dist/cli/experimental/command-options.d.ts +17 -0
- package/dist/cli/experimental/command-options.d.ts.map +1 -0
- package/dist/cli/experimental/command-options.js +35 -0
- package/dist/cli/experimental/command-options.js.map +1 -0
- package/dist/cli/experimental/command.d.ts +63 -0
- package/dist/cli/experimental/command.d.ts.map +1 -0
- package/dist/cli/experimental/command.js +127 -0
- package/dist/cli/experimental/command.js.map +1 -0
- package/dist/cli/experimental/commands/client.d.ts +13 -0
- package/dist/cli/experimental/commands/client.d.ts.map +1 -0
- package/dist/cli/experimental/commands/client.js +25 -0
- package/dist/cli/experimental/commands/client.js.map +1 -0
- package/dist/cli/experimental/commands/pi.d.ts +15 -0
- package/dist/cli/experimental/commands/pi.d.ts.map +1 -0
- package/dist/cli/experimental/commands/pi.js +28 -0
- package/dist/cli/experimental/commands/pi.js.map +1 -0
- package/dist/cli/experimental/commands/server.d.ts +13 -0
- package/dist/cli/experimental/commands/server.d.ts.map +1 -0
- package/dist/cli/experimental/commands/server.js +25 -0
- package/dist/cli/experimental/commands/server.js.map +1 -0
- package/dist/cli/experimental/transport-address.d.ts +10 -0
- package/dist/cli/experimental/transport-address.d.ts.map +1 -0
- package/dist/cli/experimental/transport-address.js +38 -0
- package/dist/cli/experimental/transport-address.js.map +1 -0
- package/dist/cli/session-picker.js +2 -2
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +4 -10
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/remote-session.d.ts +64 -0
- package/dist/client/remote-session.d.ts.map +1 -0
- package/dist/client/remote-session.js +351 -0
- package/dist/client/remote-session.js.map +1 -0
- package/dist/client/transcript.d.ts +12 -0
- package/dist/client/transcript.d.ts.map +1 -0
- package/dist/client/transcript.js +98 -0
- package/dist/client/transcript.js.map +1 -0
- package/dist/core/agent-session-auto-compaction.d.ts +17 -13
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +192 -67
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +2 -0
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-compaction.d.ts +3 -6
- package/dist/core/agent-session-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-compaction.js +64 -28
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts +1 -11
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +64 -37
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +4 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +19 -2
- 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 +1 -0
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +23 -5
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.js +22 -6
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +4 -0
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-retry.d.ts +21 -4
- package/dist/core/agent-session-retry.d.ts.map +1 -1
- package/dist/core/agent-session-retry.js +232 -106
- package/dist/core/agent-session-retry.js.map +1 -1
- package/dist/core/agent-session-runtime-auth.d.ts.map +1 -1
- package/dist/core/agent-session-runtime-auth.js +3 -0
- package/dist/core/agent-session-runtime-auth.js.map +1 -1
- package/dist/core/agent-session-state.d.ts.map +1 -1
- package/dist/core/agent-session-state.js +2 -1
- package/dist/core/agent-session-state.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +37 -14
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +5 -1
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +5 -1
- 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 +18 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +37 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -3
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +18 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +83 -0
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts +5 -0
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +43 -19
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/builtin-packages.d.ts.map +1 -1
- package/dist/core/builtin-packages.js +6 -0
- package/dist/core/builtin-packages.js.map +1 -1
- package/dist/core/codex-fast-mode.d.ts.map +1 -1
- package/dist/core/codex-fast-mode.js +8 -3
- package/dist/core/codex-fast-mode.js.map +1 -1
- package/dist/core/exec.d.ts.map +1 -1
- package/dist/core/exec.js +4 -3
- package/dist/core/exec.js.map +1 -1
- package/dist/core/extensions/agent-events.d.ts +0 -1
- package/dist/core/extensions/agent-events.d.ts.map +1 -1
- package/dist/core/extensions/agent-events.js.map +1 -1
- package/dist/core/extensions/api-types.d.ts +5 -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/context-types.d.ts +40 -0
- package/dist/core/extensions/context-types.d.ts.map +1 -1
- package/dist/core/extensions/context-types.js.map +1 -1
- package/dist/core/extensions/event-results.d.ts +5 -0
- package/dist/core/extensions/event-results.d.ts.map +1 -1
- package/dist/core/extensions/event-results.js.map +1 -1
- package/dist/core/extensions/index.d.ts +2 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js +1 -0
- 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 +14 -1
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-discovery.d.ts.map +1 -1
- package/dist/core/extensions/loader-discovery.js +3 -23
- package/dist/core/extensions/loader-discovery.js.map +1 -1
- package/dist/core/extensions/loader-runtime.d.ts.map +1 -1
- package/dist/core/extensions/loader-runtime.js +20 -3
- package/dist/core/extensions/loader-runtime.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +7 -1
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +6 -0
- 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/provider-types.d.ts +9 -3
- package/dist/core/extensions/provider-types.d.ts.map +1 -1
- package/dist/core/extensions/provider-types.js.map +1 -1
- package/dist/core/extensions/runner-context.d.ts +2 -1
- package/dist/core/extensions/runner-context.d.ts.map +1 -1
- package/dist/core/extensions/runner-context.js +4 -0
- package/dist/core/extensions/runner-context.js.map +1 -1
- package/dist/core/extensions/runner-registries.d.ts +2 -1
- package/dist/core/extensions/runner-registries.d.ts.map +1 -1
- package/dist/core/extensions/runner-registries.js +3 -0
- package/dist/core/extensions/runner-registries.js.map +1 -1
- package/dist/core/extensions/runner-ui.d.ts.map +1 -1
- package/dist/core/extensions/runner-ui.js +1 -0
- package/dist/core/extensions/runner-ui.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +9 -3
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +4 -1
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/stale-context.d.ts +5 -0
- package/dist/core/extensions/stale-context.d.ts.map +1 -0
- package/dist/core/extensions/stale-context.js +11 -0
- package/dist/core/extensions/stale-context.js.map +1 -0
- package/dist/core/extensions/ui-types.d.ts +14 -11
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +3 -2
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/intercom-runtime-group.d.ts +13 -0
- package/dist/core/intercom-runtime-group.d.ts.map +1 -0
- package/dist/core/intercom-runtime-group.js +23 -0
- package/dist/core/intercom-runtime-group.js.map +1 -0
- package/dist/core/keybindings.d.ts +44 -4
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/model-config.d.ts +39 -5
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +6 -0
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-fallback-failures.d.ts +30 -0
- package/dist/core/model-fallback-failures.d.ts.map +1 -0
- package/dist/core/model-fallback-failures.js +610 -0
- package/dist/core/model-fallback-failures.js.map +1 -0
- package/dist/core/model-registry.d.ts +12 -5
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +20 -12
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver-cli.d.ts.map +1 -1
- package/dist/core/model-resolver-cli.js +46 -14
- package/dist/core/model-resolver-cli.js.map +1 -1
- package/dist/core/model-resolver-defaults.d.ts.map +1 -1
- package/dist/core/model-resolver-defaults.js +2 -0
- package/dist/core/model-resolver-defaults.js.map +1 -1
- package/dist/core/model-resolver-scope.d.ts +2 -0
- package/dist/core/model-resolver-scope.d.ts.map +1 -1
- package/dist/core/model-resolver-scope.js +12 -9
- package/dist/core/model-resolver-scope.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-snapshot.d.ts +10 -0
- package/dist/core/model-runtime-snapshot.d.ts.map +1 -1
- package/dist/core/model-runtime-snapshot.js +14 -1
- package/dist/core/model-runtime-snapshot.js.map +1 -1
- package/dist/core/model-runtime-streaming.d.ts +3 -1
- package/dist/core/model-runtime-streaming.d.ts.map +1 -1
- package/dist/core/model-runtime-streaming.js +16 -0
- package/dist/core/model-runtime-streaming.js.map +1 -1
- package/dist/core/model-runtime-types.d.ts +2 -0
- package/dist/core/model-runtime-types.d.ts.map +1 -1
- package/dist/core/model-runtime-types.js.map +1 -1
- package/dist/core/model-runtime.d.ts +37 -10
- package/dist/core/model-runtime.d.ts.map +1 -1
- package/dist/core/model-runtime.js +312 -113
- package/dist/core/model-runtime.js.map +1 -1
- package/dist/core/oauth-login.d.ts.map +1 -1
- package/dist/core/oauth-login.js +2 -1
- package/dist/core/oauth-login.js.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.d.ts.map +1 -1
- package/dist/core/openai-responses-payload-sanitizer.js +18 -2
- package/dist/core/openai-responses-payload-sanitizer.js.map +1 -1
- package/dist/core/package-manager-git.d.ts.map +1 -1
- package/dist/core/package-manager-git.js +56 -10
- package/dist/core/package-manager-git.js.map +1 -1
- package/dist/core/package-manager-manifest.d.ts +1 -1
- package/dist/core/package-manager-manifest.d.ts.map +1 -1
- package/dist/core/package-manager-manifest.js +19 -9
- package/dist/core/package-manager-manifest.js.map +1 -1
- package/dist/core/package-manager-resource-collector.js.map +1 -1
- package/dist/core/package-manager-resource-files.d.ts.map +1 -1
- package/dist/core/package-manager-resource-files.js +1 -2
- package/dist/core/package-manager-resource-files.js.map +1 -1
- package/dist/core/provider-composer-internal.d.ts +10 -2
- package/dist/core/provider-composer-internal.d.ts.map +1 -1
- package/dist/core/provider-composer-internal.js +7 -3
- package/dist/core/provider-composer-internal.js.map +1 -1
- package/dist/core/provider-composer.d.ts.map +1 -1
- package/dist/core/provider-composer.js +19 -12
- package/dist/core/provider-composer.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +2 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +77 -67
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resolve-config-value.d.ts.map +1 -1
- package/dist/core/resolve-config-value.js +3 -0
- package/dist/core/resolve-config-value.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +13 -5
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/retry-policy.d.ts +30 -0
- package/dist/core/retry-policy.d.ts.map +1 -0
- package/dist/core/retry-policy.js +25 -0
- package/dist/core/retry-policy.js.map +1 -0
- package/dist/core/runtime-credentials.d.ts +5 -5
- package/dist/core/runtime-credentials.d.ts.map +1 -1
- package/dist/core/runtime-credentials.js +8 -8
- package/dist/core/runtime-credentials.js.map +1 -1
- package/dist/core/sdk-types.d.ts +8 -2
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +6 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +2 -0
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +7 -0
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +3 -1
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts +8 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +31 -0
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-manager.d.ts +2 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/settings-merge.d.ts.map +1 -1
- package/dist/core/settings-merge.js +13 -16
- package/dist/core/settings-merge.js.map +1 -1
- package/dist/core/settings-types.d.ts +5 -0
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +0 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts +2 -2
- package/dist/core/tools/ask-user-question/state/questionnaire-session.d.ts.map +1 -1
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js +39 -2
- package/dist/core/tools/ask-user-question/state/questionnaire-session.js.map +1 -1
- package/dist/core/tools/bash-async-execution.d.ts +2 -0
- package/dist/core/tools/bash-async-execution.d.ts.map +1 -1
- package/dist/core/tools/bash-async-execution.js +4 -1
- package/dist/core/tools/bash-async-execution.js.map +1 -1
- package/dist/core/tools/bash-async-output.d.ts +1 -0
- package/dist/core/tools/bash-async-output.d.ts.map +1 -1
- package/dist/core/tools/bash-async-output.js +62 -27
- package/dist/core/tools/bash-async-output.js.map +1 -1
- package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
- package/dist/core/tools/bash-pty-native.js +2 -1
- package/dist/core/tools/bash-pty-native.js.map +1 -1
- package/dist/core/tools/bash.d.ts +9 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +34 -16
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/directory-tree.d.ts +11 -0
- package/dist/core/tools/directory-tree.d.ts.map +1 -1
- package/dist/core/tools/directory-tree.js +26 -0
- package/dist/core/tools/directory-tree.js.map +1 -1
- package/dist/core/tools/edit.d.ts +4 -0
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +12 -8
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/errno.d.ts +25 -0
- package/dist/core/tools/errno.d.ts.map +1 -0
- package/dist/core/tools/errno.js +29 -0
- package/dist/core/tools/errno.js.map +1 -0
- package/dist/core/tools/find.d.ts +8 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +20 -15
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +5 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/index.d.ts +7 -7
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +7 -7
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts +4 -0
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +5 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts +8 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +50 -28
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
- package/dist/core/tools/oversized-tool-result.js +129 -22
- package/dist/core/tools/oversized-tool-result.js.map +1 -1
- package/dist/core/tools/persisted-output-file.d.ts +80 -0
- package/dist/core/tools/persisted-output-file.d.ts.map +1 -0
- package/dist/core/tools/persisted-output-file.js +284 -0
- package/dist/core/tools/persisted-output-file.js.map +1 -0
- package/dist/core/tools/read.d.ts +10 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +20 -8
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/search.d.ts +4 -0
- package/dist/core/tools/search.d.ts.map +1 -1
- package/dist/core/tools/search.js +5 -1
- package/dist/core/tools/search.js.map +1 -1
- package/dist/core/tools/session-temp-cleanup.d.ts +133 -0
- package/dist/core/tools/session-temp-cleanup.d.ts.map +1 -0
- package/dist/core/tools/session-temp-cleanup.js +669 -0
- package/dist/core/tools/session-temp-cleanup.js.map +1 -0
- package/dist/core/tools/session-temp-dir.d.ts +116 -0
- package/dist/core/tools/session-temp-dir.d.ts.map +1 -0
- package/dist/core/tools/session-temp-dir.js +409 -0
- package/dist/core/tools/session-temp-dir.js.map +1 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +2 -0
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/tool-limits.d.ts +11 -0
- package/dist/core/tools/tool-limits.d.ts.map +1 -1
- package/dist/core/tools/tool-limits.js +11 -0
- package/dist/core/tools/tool-limits.js.map +1 -1
- package/dist/core/tools/windows-directory-security.d.ts +82 -0
- package/dist/core/tools/windows-directory-security.d.ts.map +1 -0
- package/dist/core/tools/windows-directory-security.js +238 -0
- package/dist/core/tools/windows-directory-security.js.map +1 -0
- package/dist/core/tools/write.d.ts +4 -0
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js +8 -4
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.js +1 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts +1 -1
- package/dist/extensions/llama/huggingface-ui.d.ts.map +1 -1
- package/dist/extensions/llama/huggingface-ui.js +6 -5
- package/dist/extensions/llama/huggingface-ui.js.map +1 -1
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +11 -2
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +24 -8
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/extensions/llama/ui.d.ts.map +1 -1
- package/dist/extensions/llama/ui.js +5 -2
- package/dist/extensions/llama/ui.js.map +1 -1
- package/dist/index-extensions.d.ts +2 -2
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/main-runtime-api-key.d.ts +2 -2
- package/dist/main-runtime-api-key.d.ts.map +1 -1
- package/dist/main-runtime-api-key.js +7 -2
- package/dist/main-runtime-api-key.js.map +1 -1
- package/dist/main-session.js +2 -2
- package/dist/main-session.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +130 -26
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -0
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +6 -2
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +18 -5
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +5 -4
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -2
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +17 -7
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +35 -69
- package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-actions.js +11 -3
- package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-events.js +25 -15
- package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-rendering.js +9 -4
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.d.ts +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
- package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +9 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +14 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.d.ts +32 -0
- package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-transcript.js +173 -5
- package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector-list.js +9 -8
- package/dist/modes/interactive/components/config-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts +1 -1
- package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-editor.js +32 -10
- package/dist/modes/interactive/components/custom-editor.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts +2 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +3 -2
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +3 -2
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts +1 -1
- package/dist/modes/interactive/components/extension-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-input.js +1 -0
- package/dist/modes/interactive/components/extension-input.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +4 -0
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/fast-mode-selector.js +7 -5
- package/dist/modes/interactive/components/fast-mode-selector.js.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts +1 -1
- package/dist/modes/interactive/components/first-time-setup.d.ts.map +1 -1
- package/dist/modes/interactive/components/first-time-setup.js +3 -0
- package/dist/modes/interactive/components/first-time-setup.js.map +1 -1
- package/dist/modes/interactive/components/footer.js +1 -1
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts +1 -1
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -1
- package/dist/modes/interactive/components/host-input-form.js +6 -5
- package/dist/modes/interactive/components/host-input-form.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -1
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +2 -1
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +3 -0
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -0
- package/dist/modes/interactive/components/markdown-transform.js +19 -0
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -0
- package/dist/modes/interactive/components/mermaid.d.ts +11 -0
- package/dist/modes/interactive/components/mermaid.d.ts.map +1 -0
- package/dist/modes/interactive/components/mermaid.js +81 -0
- package/dist/modes/interactive/components/mermaid.js.map +1 -0
- package/dist/modes/interactive/components/model-selector.d.ts +2 -2
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +9 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +3 -2
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +6 -2
- package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/scoped-models-selector.js +39 -13
- package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-delete.js +2 -1
- package/dist/modes/interactive/components/session-selector-delete.js.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector-list.js +12 -11
- package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +3 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-handlers.js +9 -0
- package/dist/modes/interactive/components/settings-selector-handlers.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 +21 -0
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts +3 -3
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +6 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts +8 -1
- package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.js +3 -2
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +2 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +50 -27
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-component.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-component.js +2 -3
- package/dist/modes/interactive/components/tree-selector-component.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-help.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-help.js +3 -1
- package/dist/modes/interactive/components/tree-selector-help.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-label-input.js +1 -0
- package/dist/modes/interactive/components/tree-selector-label-input.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts +1 -1
- package/dist/modes/interactive/components/tree-selector-list.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector-list.js +3 -0
- package/dist/modes/interactive/components/tree-selector-list.js.map +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts +1 -1
- package/dist/modes/interactive/components/trust-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/trust-selector.js +4 -0
- package/dist/modes/interactive/components/trust-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts +1 -1
- package/dist/modes/interactive/components/user-message-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message-selector.js +4 -0
- package/dist/modes/interactive/components/user-message-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.d.ts +4 -1
- package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/user-message.js +10 -2
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +36 -18
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +9 -2
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +5 -1
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +16 -4
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-deferred-startup.js +3 -0
- package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-editor-actions.js +2 -0
- package/dist/modes/interactive/interactive-editor-actions.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +12 -7
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-custom-ui.js +1 -0
- package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-dialogs.js +7 -0
- package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-widgets.js +7 -24
- package/dist/modes/interactive/interactive-extension-widgets.js.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-input-handling.js +9 -8
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +52 -3
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +143 -5
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +2 -2
- package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.js +2 -2
- package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +9 -3
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +1 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +107 -41
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js +1 -1
- package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +24 -6
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-selectors.js +44 -5
- package/dist/modes/interactive/interactive-selectors.js.map +1 -1
- package/dist/modes/interactive/interactive-session-runtime.js +1 -0
- package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +9 -4
- 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 +37 -18
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-tui.d.ts +21 -0
- package/dist/modes/interactive/interactive-tui.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-tui.js +279 -0
- package/dist/modes/interactive/interactive-tui.js.map +1 -0
- package/dist/modes/interactive/streaming-assistant-message.d.ts +34 -0
- package/dist/modes/interactive/streaming-assistant-message.d.ts.map +1 -0
- package/dist/modes/interactive/streaming-assistant-message.js +76 -0
- package/dist/modes/interactive/streaming-assistant-message.js.map +1 -0
- package/dist/modes/interactive/theme/catppuccin-frappe.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-latte.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-macchiato.json +1 -0
- package/dist/modes/interactive/theme/catppuccin-mocha.json +1 -0
- package/dist/modes/interactive/theme/dark.json +1 -0
- package/dist/modes/interactive/theme/light.json +1 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts +10 -0
- package/dist/modes/interactive/theme/terminal-detection.d.ts.map +1 -1
- package/dist/modes/interactive/theme/terminal-detection.js +19 -0
- package/dist/modes/interactive/theme/terminal-detection.js.map +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +2 -2
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +5 -1
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts +3 -1
- package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-controller.js +10 -13
- package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +1 -0
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +4 -0
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +2 -1
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +5 -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-engine/engine-custom-ui.d.ts +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
- package/dist/modes/interactive-engine/engine-custom-ui.js +28 -11
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
- package/dist/modes/interactive-engine/engine-render-service.js +3 -3
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +2 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
- package/dist/modes/interactive-engine/extension-ui-bridge.js +2 -2
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +7 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
- package/dist/modes/interactive-engine/isolated-runtime.js +7 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
- package/dist/modes/interactive-engine/protocol.d.ts +12 -10
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
- package/dist/modes/interactive-engine/protocol.js +14 -11
- package/dist/modes/interactive-engine/protocol.js.map +1 -1
- package/dist/modes/interactive-engine/remote-component.d.ts +11 -1
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
- package/dist/modes/interactive-engine/remote-component.js +48 -8
- package/dist/modes/interactive-engine/remote-component.js.map +1 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +19 -12
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -1
- package/dist/modes/interactive-engine/terminal-mode-controller.js +54 -35
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -1
- package/dist/modes/json-event.d.ts +28 -0
- package/dist/modes/json-event.d.ts.map +1 -0
- package/dist/modes/json-event.js +12 -0
- package/dist/modes/json-event.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +2 -1
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client-process.d.ts +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client-process.js +5 -1
- package/dist/modes/rpc/rpc-client-process.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +7 -2
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +1 -1
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +9 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.js +10 -5
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +3 -0
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input.js +1 -1
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +9 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.js +10 -5
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-provider-auth.js +3 -0
- package/dist/modes/rpc/rpc-provider-auth.js.map +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts +1 -1
- package/dist/modes/rpc/rpc-responses.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-responses.js +13 -1
- package/dist/modes/rpc/rpc-responses.js.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +2 -1
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +9 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/rpc-entry.js +2 -0
- package/dist/rpc-entry.js.map +1 -1
- package/dist/self-update-plan.d.ts.map +1 -1
- package/dist/self-update-plan.js +5 -4
- package/dist/self-update-plan.js.map +1 -1
- package/dist/server/create-harness.d.ts +53 -0
- package/dist/server/create-harness.d.ts.map +1 -0
- package/dist/server/create-harness.js +349 -0
- package/dist/server/create-harness.js.map +1 -0
- package/dist/utils/agent-attribution.d.ts +2 -0
- package/dist/utils/agent-attribution.d.ts.map +1 -0
- package/dist/utils/agent-attribution.js +2 -0
- package/dist/utils/agent-attribution.js.map +1 -0
- package/dist/utils/child-process.d.ts +3 -1
- package/dist/utils/child-process.d.ts.map +1 -1
- package/dist/utils/child-process.js +24 -4
- package/dist/utils/child-process.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +2 -1
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/clipboard.d.ts.map +1 -1
- package/dist/utils/clipboard.js +12 -3
- package/dist/utils/clipboard.js.map +1 -1
- package/dist/utils/management-http.d.ts +23 -0
- package/dist/utils/management-http.d.ts.map +1 -0
- package/dist/utils/management-http.js +50 -0
- package/dist/utils/management-http.js.map +1 -0
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js +2 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +13 -0
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +17 -4
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/tool-result-images.d.ts +17 -0
- package/dist/utils/tool-result-images.d.ts.map +1 -0
- package/dist/utils/tool-result-images.js +41 -0
- package/dist/utils/tool-result-images.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +7 -8
- package/dist/utils/tools-manager.js.map +1 -1
- package/dist/utils/version-check.d.ts +4 -0
- package/dist/utils/version-check.d.ts.map +1 -1
- package/dist/utils/version-check.js +20 -2
- package/dist/utils/version-check.js.map +1 -1
- package/docs/compaction.md +2 -1
- package/docs/custom-provider.md +15 -7
- package/docs/development.md +1 -0
- package/docs/docs.json +1 -0
- package/docs/environment-variables.md +4 -0
- package/docs/extensions.md +102 -18
- package/docs/i-have-adhd.md +36 -0
- package/docs/intercom.md +31 -16
- package/docs/json.md +2 -2
- package/docs/keybindings.md +55 -12
- package/docs/models/model-selection.md +34 -8
- package/docs/models.md +28 -3
- package/docs/providers.md +20 -2
- package/docs/quickstart.md +5 -5
- package/docs/rpc.md +18 -12
- package/docs/sdk.md +43 -7
- package/docs/security.md +10 -10
- package/docs/sessions.md +2 -0
- package/docs/settings.md +32 -6
- package/docs/subagents.md +30 -45
- package/docs/themes.md +5 -3
- package/docs/tools.md +21 -1
- package/docs/tui.md +41 -24
- package/docs/usage.md +40 -14
- package/docs/windows.md +2 -0
- package/docs/workflows.md +237 -25
- package/examples/extensions/custom-provider-anthropic/index.ts +9 -2
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +9 -2
- package/examples/extensions/gondolin/package-lock.json +3 -3
- package/examples/extensions/modal-editor.ts +8 -10
- package/examples/extensions/rainbow-editor.ts +3 -2
- package/examples/extensions/subagent/README.md +16 -45
- package/examples/extensions/subagent/index.ts +6 -96
- package/examples/extensions/subagent/render.ts +0 -78
- package/examples/extensions/subagent/runner.ts +0 -3
- package/examples/extensions/subagent/schemas.ts +0 -13
- package/examples/extensions/subagent/types.ts +1 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +6 -2
- package/examples/sdk/12-full-control.ts +8 -2
- package/examples/sdk/README.md +4 -1
- package/npm-shrinkwrap.json +191 -634
- package/package.json +14 -7
- package/dist/builtin/subagents/src/agents/chain-serializer.ts +0 -257
- package/dist/builtin/subagents/src/runs/background/async-event-journal.ts +0 -112
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +0 -543
- package/dist/builtin/subagents/src/runs/background/async-execution-common.ts +0 -140
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +0 -279
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +0 -99
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +0 -17
- package/dist/builtin/subagents/src/runs/background/async-resume.ts +0 -402
- package/dist/builtin/subagents/src/runs/background/async-status.ts +0 -411
- package/dist/builtin/subagents/src/runs/background/completion-claims.ts +0 -196
- package/dist/builtin/subagents/src/runs/background/completion-dedupe.ts +0 -102
- package/dist/builtin/subagents/src/runs/background/parallel-groups.ts +0 -59
- package/dist/builtin/subagents/src/runs/background/result-delivery-processor.ts +0 -300
- package/dist/builtin/subagents/src/runs/background/result-file-claims.ts +0 -166
- package/dist/builtin/subagents/src/runs/background/result-quarantine.ts +0 -77
- package/dist/builtin/subagents/src/runs/background/result-retry-scheduler.ts +0 -48
- package/dist/builtin/subagents/src/runs/background/result-status.ts +0 -87
- package/dist/builtin/subagents/src/runs/background/result-watcher-data.ts +0 -72
- package/dist/builtin/subagents/src/runs/background/result-watcher.ts +0 -320
- package/dist/builtin/subagents/src/runs/background/run-id-resolver.ts +0 -105
- package/dist/builtin/subagents/src/runs/background/run-status.ts +0 -358
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +0 -457
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +0 -376
- package/dist/builtin/subagents/src/runs/background/subagent-runner-finalize.ts +0 -150
- package/dist/builtin/subagents/src/runs/background/subagent-runner-output.ts +0 -109
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel-helpers.ts +0 -128
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +0 -309
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +0 -173
- package/dist/builtin/subagents/src/runs/background/subagent-runner-state.ts +0 -578
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +0 -330
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +0 -210
- package/dist/builtin/subagents/src/runs/background/subagent-runner-utils.ts +0 -69
- package/dist/builtin/subagents/src/runs/background/subagent-runner.ts +0 -90
- package/dist/builtin/subagents/src/runs/background/top-level-async.ts +0 -12
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-details.ts +0 -38
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-dynamic-step.ts +0 -280
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +0 -217
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +0 -271
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-sequential-step.ts +0 -271
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-types.ts +0 -200
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +0 -184
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-control.ts +0 -140
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-finalize.ts +0 -108
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt-types.ts +0 -17
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +0 -558
- package/dist/builtin/subagents/src/runs/foreground/execution-structured-retries.ts +0 -83
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-chain.ts +0 -109
- package/dist/builtin/subagents/src/runs/shared/attempt-watchdog.ts +0 -126
- package/dist/builtin/subagents/src/runs/shared/chain-outputs.ts +0 -126
- package/dist/builtin/subagents/src/runs/shared/dynamic-fanout.ts +0 -387
- package/dist/builtin/subagents/src/runs/shared/final-drain.ts +0 -39
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +0 -339
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +0 -165
- package/dist/builtin/subagents/src/runs/shared/spawn-env.ts +0 -21
- package/dist/builtin/subagents/src/runs/shared/structured-output.ts +0 -150
- package/dist/builtin/subagents/src/runs/shared/workflow-graph.ts +0 -232
- package/dist/builtin/subagents/src/shared/post-exit-stdio-guard.ts +0 -86
- package/dist/builtin/subagents/src/slash/saved-chain-mapping.ts +0 -60
- package/dist/builtin/subagents/src/tui/render-chain-graph.ts +0 -335
- package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
- package/examples/extensions/subagent/prompts/implement.md +0 -10
- package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
- /package/dist/builtin/subagents/src/runs/{shared/nested-path.ts → inprocess/runtime-support/nested-paths.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-temp-cleanup.js","sourceRoot":"","sources":["../../../src/core/tools/session-temp-cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,UAAU,EACV,SAAS,GACT,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EACN,aAAa,EACb,2BAA2B,EAC3B,cAAc,EACd,sBAAsB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,UAAU,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,kEAAkE;AAClE,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,MAAM,CAAC,MAAM,yBAAyB,GAAG,2BAA2B,GAAG,UAAU,CAAC;AAElF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,gCAAgC,GAAG,UAAU,CAAC;AAE3D,yEAAyE;AACzE,MAAM,CAAC,MAAM,kCAAkC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEjE,mFAAmF;AACnF,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B,MAAM,CAAC,MAAM,mBA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IACF,CAAC,EAAE,6BAA6B,CAAC,CAAC;IAClC,YAAY,CAAC,KAAK,EAAE,EAAE,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAAO,GAA8B,EAAE;IACjF,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;QAChD,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QAC7C,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IACD,IAAI,gBAAgB,EAAE,CAAC;QACtB,OAAO;IACR,CAAC;IACD,qBAAqB,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,yCAAyC;IACxD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAChC,YAAY,CAAC,YAAY,CAAC,CAAC;IAC5B,CAAC;IACD,YAAY,GAAG,SAAS,CAAC;IACzB,gBAAgB,GAAG,KAAK,CAAC;IACzB,sBAAsB,CAAC,KAAK,EAAE,CAAC;IAC/B,oBAAoB,CAAC,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,8DAA8D;AAC9D,MAAM,CAAC,MAAM,2BAA2B,GAAG;IAC1C,kBAAkB;IAClB,kBAAkB;CAClB,CAAC","sourcesContent":["/**\n * Age-based sweeper for tool-output storage.\n *\n * Three targets are reaped, all strictly scoped to tool output:\n *\n * - `<tmpdir>/<APP_NAME>-<owner>/` — the per-session temp trees created by\n * `session-temp-dir.ts`.\n * - `<sessionsRoot>/<project>/tool-results/` — persisted tool results under the\n * default, project-nested session roots.\n * - `<sessionDir>/tool-results/` — the same, for a custom session directory\n * chosen with `--session-dir`, `ATOMIC_CODING_AGENT_SESSION_DIR`, or the\n * `sessionDir` setting, where there is no project nesting to walk.\n *\n * Transcripts, `.jsonl` session files, and every other file under session\n * storage are out of scope: the walk only ever descends into a `tool-results`\n * directory, and only ever deletes inside it.\n *\n * The throttle/lock shape mirrors `packages/subagents/src/shared/artifacts.ts`:\n * a `.last-cleanup` marker skips the scan for a day, a `.cleanup.lock` exclusive\n * lock keeps concurrent sessions from racing, a stale lock left by a crashed\n * process is broken, and lock ownership is rechecked before every destructive\n * step. Those two names are required, but the subagents sweep already owns them\n * inside the default sessions roots, so session-storage scans keep their\n * marker/lock pair in a coding-agent control root keyed by target instead of\n * writing into the scanned directory. The temp root, which nothing else owns,\n * carries its pair directly.\n *\n * Symlinks are never followed. A scan root or a `tool-results` entry that is a\n * symlink is skipped rather than read or deleted, because `readdirSync` and\n * `rmSync` resolve links and would otherwise reach outside the target.\n */\n\nimport { createHash } from \"node:crypto\";\nimport {\n\tcloseSync,\n\tfchmodSync,\n\tfstatSync,\n\tlstatSync,\n\topenSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\trmSync,\n\tstatSync,\n\tunlinkSync,\n\twriteSync,\n} from \"node:fs\";\nimport { join } from \"node:path\";\nimport { getAgentConfigPaths } from \"../../config.ts\";\nimport { getErrnoCode } from \"./errno.ts\";\nimport {\n\tensureTempDir,\n\tgetProtectedSessionTempDirs,\n\tgetTempRootDir,\n\tSESSION_TEMP_FILE_MODE,\n} from \"./session-temp-dir.ts\";\nimport { TOOL_RESULTS_SUBDIR } from \"./tool-limits.js\";\n\nconst MS_PER_DAY = 24 * 60 * 60 * 1000;\n\n/** How long a tool-output tree survives without being touched. */\nexport const SESSION_TEMP_RETENTION_DAYS = 30;\nexport const SESSION_TEMP_RETENTION_MS = SESSION_TEMP_RETENTION_DAYS * MS_PER_DAY;\n\n/** Minimum interval between two sweeps of the same root. */\nexport const SESSION_TEMP_CLEANUP_INTERVAL_MS = MS_PER_DAY;\n\n/** A lock older than this belonged to a process that died holding it. */\nexport const SESSION_TEMP_CLEANUP_LOCK_STALE_MS = 60 * 60 * 1000;\n\n/** How long after startup the sweep runs, so it never sits on the startup path. */\nexport const SESSION_TEMP_CLEANUP_DELAY_MS = 10_000;\n\n/** Deepest directory nesting the mtime walk will descend. */\nconst MAX_SCAN_DEPTH = 32;\n\nexport const CLEANUP_MARKER_FILE = \".last-cleanup\";\nexport const CLEANUP_LOCK_FILE = \".cleanup.lock\";\n\n/**\n * Control root for session-storage scans, inside the owner-scoped temp root.\n * A session id can never sanitize to this name (leading dots are stripped), so\n * it cannot collide with a session temp tree.\n */\nexport const CLEANUP_CONTROL_SUBDIR = \".cleanup\";\n\nexport type SweepOutcome = \"swept\" | \"throttled\" | \"locked\" | \"missing\";\n\nexport interface SweepOptions {\n\t/** Clock override for tests. */\n\tnow?: number;\n\t/** Age past which an untouched entry is reaped. */\n\tretentionMs?: number;\n\t/** Minimum interval between sweeps of this root. */\n\tthrottleMs?: number;\n\t/** Directories that must survive regardless of age. */\n\tprotectedPaths?: Iterable<string>;\n\t/** Parent of the per-target control directories. Defaults to `<tempRoot>/.cleanup`. */\n\tcontrolRoot?: string;\n}\n\n/** Default parent for the marker/lock pair of a session-storage scan. */\nexport function getCleanupControlRoot(): string {\n\treturn join(getTempRootDir(), CLEANUP_CONTROL_SUBDIR);\n}\n\n/**\n * Control directory for one scan target: `<controlRoot>/<digest-of-target>`.\n * Keyed by the target path so two roots never share throttle state.\n */\nexport function getCleanupControlDir(target: string, controlRoot?: string): string {\n\tconst key = createHash(\"sha256\").update(target).digest(\"hex\").slice(0, 16);\n\treturn join(controlRoot ?? getCleanupControlRoot(), key);\n}\n\ninterface FileIdentity {\n\tdev: bigint;\n\tino: bigint;\n}\n\nfunction sameFileIdentity(left: FileIdentity, right: FileIdentity): boolean {\n\treturn left.dev === right.dev && left.ino === right.ino;\n}\n\nfunction realDirectoryIdentity(path: string): FileIdentity | undefined {\n\ttry {\n\t\tconst stat = lstatSync(path, { bigint: true });\n\t\tif (stat.isDirectory() && !stat.isSymbolicLink()) {\n\t\t\treturn { dev: stat.dev, ino: stat.ino };\n\t\t}\n\t} catch {\n\t\t// Missing, unreadable, and changing paths are not cleanup candidates.\n\t}\n\treturn undefined;\n}\n\n/** An existing real directory — not a symlink, not a file, not missing. */\nfunction isRealDirectory(path: string): boolean {\n\treturn realDirectoryIdentity(path) !== undefined;\n}\n\nfunction markerIsFresh(markerPath: string, now: number, throttleMs: number): boolean {\n\ttry {\n\t\tconst stat = lstatSync(markerPath);\n\t\treturn stat.isFile() && !stat.isSymbolicLink() && now - stat.mtimeMs < throttleMs;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\ninterface CleanupLock extends FileIdentity {\n\ttoken: string;\n}\n\nfunction pathIdentifiesFile(path: string, identity: FileIdentity): boolean {\n\ttry {\n\t\tconst stat = lstatSync(path, { bigint: true });\n\t\treturn stat.isFile() && !stat.isSymbolicLink() && sameFileIdentity(stat, identity);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction removeCreatedFile(path: string, identity: FileIdentity): void {\n\ttry {\n\t\tif (pathIdentifiesFile(path, identity)) {\n\t\t\tunlinkSync(path);\n\t\t}\n\t} catch {\n\t\t// Best effort. An uncertain path is left untouched.\n\t}\n}\n/**\n * Take an exclusive lock so two sessions never scan the same target at once.\n *\n * `wx` creation is the exclusivity primitive. Returns an ownership token; a lock\n * left behind by a crashed process is broken once stale, and release only\n * removes a lock that still carries the caller's token.\n */\nfunction acquireCleanupLock(lockPath: string, now: number, staleMs: number): CleanupLock | null {\n\tconst token = `${process.pid}.${now}.${Math.random().toString(36).slice(2)}`;\n\tfor (let attempt = 0; attempt < 2; attempt++) {\n\t\tlet fd: number;\n\t\ttry {\n\t\t\tfd = openSync(lockPath, \"wx+\", SESSION_TEMP_FILE_MODE);\n\t\t} catch (error) {\n\t\t\tif (getErrnoCode(error) !== \"EEXIST\") {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tlet lockMtimeMs: number;\n\t\t\ttry {\n\t\t\t\tlockMtimeMs = statSync(lockPath).mtimeMs;\n\t\t\t} catch {\n\t\t\t\t// The holder released between the failed create and the stat; retry.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (now - lockMtimeMs < staleMs) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (!breakStaleLock(lockPath, lockMtimeMs)) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet lock: CleanupLock | undefined;\n\t\tlet failed = false;\n\t\ttry {\n\t\t\tconst createdStat = fstatSync(fd, { bigint: true });\n\t\t\tlock = { token, dev: createdStat.dev, ino: createdStat.ino };\n\t\t\tif (!createdStat.isFile()) {\n\t\t\t\tfailed = true;\n\t\t\t} else {\n\t\t\t\tif (process.platform !== \"win32\") {\n\t\t\t\t\tfchmodSync(fd, SESSION_TEMP_FILE_MODE);\n\t\t\t\t\tconst modeStat = fstatSync(fd, { bigint: true });\n\t\t\t\t\tif (!modeStat.isFile() || Number(modeStat.mode & 0o777n) !== SESSION_TEMP_FILE_MODE) {\n\t\t\t\t\t\tfailed = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (!failed && writeSync(fd, token) !== token.length) {\n\t\t\t\t\tfailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\tfailed = true;\n\t\t}\n\t\ttry {\n\t\t\tcloseSync(fd);\n\t\t} catch {\n\t\t\tfailed = true;\n\t\t}\n\t\tif (failed || lock === undefined || !pathIdentifiesFile(lockPath, lock) || !ownsCleanupLock(lockPath, lock)) {\n\t\t\tif (lock !== undefined) {\n\t\t\t\tremoveCreatedFile(lockPath, lock);\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t\treturn lock;\n\t}\n\treturn null;\n}\n\n/**\n * Claim a stale lock via rename, then verify it is still the lock observed\n * during stale detection. A lock that changed identity in between belongs to a\n * new holder: hand it back and treat the takeover as contention.\n */\nfunction breakStaleLock(lockPath: string, observedMtimeMs: number): boolean {\n\tconst breakPath = `${lockPath}.break.${process.pid}.${Math.random().toString(36).slice(2)}`;\n\ttry {\n\t\trenameSync(lockPath, breakPath);\n\t} catch {\n\t\t// Another sweep released or broke it first; contend again on create.\n\t\treturn false;\n\t}\n\tlet displacedFreshLock = false;\n\ttry {\n\t\tdisplacedFreshLock = statSync(breakPath).mtimeMs !== observedMtimeMs;\n\t} catch {\n\t\tdisplacedFreshLock = false;\n\t}\n\tif (displacedFreshLock) {\n\t\ttry {\n\t\t\trenameSync(breakPath, lockPath);\n\t\t} catch {\n\t\t\t// Best-effort hand-back; the displaced holder aborts at its next\n\t\t\t// ownership recheck.\n\t\t}\n\t\treturn false;\n\t}\n\ttry {\n\t\tunlinkSync(breakPath);\n\t} catch {\n\t\t// A leftover break file is harmless.\n\t}\n\treturn true;\n}\n\nfunction ownsCleanupLock(lockPath: string, lock: CleanupLock): boolean {\n\ttry {\n\t\treturn (\n\t\t\tpathIdentifiesFile(lockPath, lock) &&\n\t\t\treadFileSync(lockPath, \"utf-8\") === lock.token &&\n\t\t\tpathIdentifiesFile(lockPath, lock)\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction releaseCleanupLock(lockPath: string, lock: CleanupLock): void {\n\ttry {\n\t\tif (ownsCleanupLock(lockPath, lock) && pathIdentifiesFile(lockPath, lock)) {\n\t\t\tunlinkSync(lockPath);\n\t\t}\n\t} catch {\n\t\t// Release is best-effort: an unreleased lock only goes stale and is\n\t\t// broken by a later sweep.\n\t}\n}\n\n/** Publish the throttle marker without ever opening or unlinking its destination. */\nfunction publishCleanupMarker(markerPath: string, now: number): boolean {\n\tconst tempPath = `${markerPath}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;\n\tconst timestamp = String(now);\n\tlet fd: number;\n\ttry {\n\t\tfd = openSync(tempPath, \"wx+\", SESSION_TEMP_FILE_MODE);\n\t} catch {\n\t\treturn false;\n\t}\n\n\tlet identity: FileIdentity | undefined;\n\tlet failed = false;\n\ttry {\n\t\tconst createdStat = fstatSync(fd, { bigint: true });\n\t\tidentity = { dev: createdStat.dev, ino: createdStat.ino };\n\t\tif (!createdStat.isFile()) {\n\t\t\tfailed = true;\n\t\t} else {\n\t\t\tif (process.platform !== \"win32\") {\n\t\t\t\tfchmodSync(fd, SESSION_TEMP_FILE_MODE);\n\t\t\t\tconst modeStat = fstatSync(fd, { bigint: true });\n\t\t\t\tif (!modeStat.isFile() || Number(modeStat.mode & 0o777n) !== SESSION_TEMP_FILE_MODE) {\n\t\t\t\t\tfailed = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!failed && writeSync(fd, timestamp) !== timestamp.length) {\n\t\t\t\tfailed = true;\n\t\t\t}\n\t\t}\n\t} catch {\n\t\tfailed = true;\n\t}\n\ttry {\n\t\tcloseSync(fd);\n\t} catch {\n\t\tfailed = true;\n\t}\n\tif (failed || identity === undefined || !pathIdentifiesFile(tempPath, identity)) {\n\t\tif (identity !== undefined) {\n\t\t\tremoveCreatedFile(tempPath, identity);\n\t\t}\n\t\treturn false;\n\t}\n\n\ttry {\n\t\trenameSync(tempPath, markerPath);\n\t} catch {\n\t\tremoveCreatedFile(tempPath, identity);\n\t\treturn false;\n\t}\n\treturn pathIdentifiesFile(markerPath, identity);\n}\n\ntype ScanFreshness = \"fresh\" | \"stale\" | \"unknown\";\n\n/**\n * Classify whether `entryPath` has a fresh descendant, is fully stale, or could\n * not be scanned completely.\n *\n * Only `stale` authorizes deletion. Symlinks, unreadable entries, and the depth\n * bound fail closed as `unknown`; `ENOENT` is stale because the entry vanished.\n * The walk still exits on its first fresh descendant.\n */\nfunction scanFreshness(entryPath: string, cutoff: number, depth = 0): ScanFreshness {\n\tlet stat: ReturnType<typeof lstatSync>;\n\ttry {\n\t\tstat = lstatSync(entryPath);\n\t} catch (error) {\n\t\treturn getErrnoCode(error) === \"ENOENT\" ? \"stale\" : \"unknown\";\n\t}\n\tif (stat.isSymbolicLink()) {\n\t\treturn \"unknown\";\n\t}\n\tif (stat.mtimeMs >= cutoff) {\n\t\treturn \"fresh\";\n\t}\n\tif (!stat.isDirectory()) {\n\t\treturn \"stale\";\n\t}\n\tif (depth >= MAX_SCAN_DEPTH) {\n\t\treturn \"unknown\";\n\t}\n\tlet children: string[];\n\ttry {\n\t\tchildren = readdirSync(entryPath);\n\t} catch (error) {\n\t\treturn getErrnoCode(error) === \"ENOENT\" ? \"stale\" : \"unknown\";\n\t}\n\tlet foundUnknown = false;\n\tfor (const child of children) {\n\t\tconst freshness = scanFreshness(join(entryPath, child), cutoff, depth + 1);\n\t\tif (freshness === \"fresh\") {\n\t\t\treturn \"fresh\";\n\t\t}\n\t\tif (freshness === \"unknown\") {\n\t\t\tfoundUnknown = true;\n\t\t}\n\t}\n\treturn foundUnknown ? \"unknown\" : \"stale\";\n}\n\ninterface CleanupGate {\n\t/** Whether this sweep still owns the lock; false means another holder took over. */\n\townsLock(): boolean;\n\tcutoff: number;\n\tprotectedPaths: ReadonlySet<string>;\n}\n\n/**\n * Run `scan` under the marker/lock protocol for one target.\n *\n * `controlDir` holds the `.last-cleanup`/`.cleanup.lock` pair; it may be the\n * scanned directory itself (temp root) or a coding-agent-owned directory outside\n * it (session storage).\n */\nfunction withCleanupGate(controlDir: string, options: SweepOptions, scan: (gate: CleanupGate) => void): SweepOutcome {\n\tconst now = options.now ?? Date.now();\n\tconst throttleMs = options.throttleMs ?? SESSION_TEMP_CLEANUP_INTERVAL_MS;\n\ttry {\n\t\t// The control root lives under the owner temp root, so create it through the\n\t\t// same validated, non-recursive path the spill directories use.\n\t\tensureTempDir(controlDir);\n\t} catch {\n\t\t// Without a control directory there is nowhere to record the throttle;\n\t\t// skip rather than sweep unthrottled and unlocked.\n\t\treturn \"locked\";\n\t}\n\tconst markerPath = join(controlDir, CLEANUP_MARKER_FILE);\n\tif (markerIsFresh(markerPath, now, throttleMs)) {\n\t\treturn \"throttled\";\n\t}\n\tconst lockPath = join(controlDir, CLEANUP_LOCK_FILE);\n\tconst token = acquireCleanupLock(lockPath, now, SESSION_TEMP_CLEANUP_LOCK_STALE_MS);\n\tif (token === null) {\n\t\treturn \"locked\";\n\t}\n\tlet aborted = false;\n\ttry {\n\t\tscan({\n\t\t\townsLock: () => {\n\t\t\t\tif (aborted) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif (ownsCleanupLock(lockPath, token)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\taborted = true;\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tcutoff: now - (options.retentionMs ?? SESSION_TEMP_RETENTION_MS),\n\t\t\tprotectedPaths: new Set(options.protectedPaths ?? []),\n\t\t});\n\t\tif (!aborted && ownsCleanupLock(lockPath, token)) {\n\t\t\t// Failing to publish the marker only means the sweep repeats sooner.\n\t\t\tpublishCleanupMarker(markerPath, now);\n\t\t}\n\t} finally {\n\t\treleaseCleanupLock(lockPath, token);\n\t}\n\treturn aborted ? \"locked\" : \"swept\";\n}\n\nfunction isCleanupArtifact(name: string): boolean {\n\treturn (\n\t\tname === CLEANUP_MARKER_FILE ||\n\t\tname.startsWith(`${CLEANUP_MARKER_FILE}.tmp.`) ||\n\t\tname === CLEANUP_LOCK_FILE ||\n\t\tname.startsWith(`${CLEANUP_LOCK_FILE}.`) ||\n\t\tname === CLEANUP_CONTROL_SUBDIR\n\t);\n}\n\n/**\n * Reap per-session temp trees under `<tmpdir>/<APP_NAME>-<owner>/`.\n *\n * A tree is removed only when nothing at any depth inside it is newer than the\n * retention cutoff, and never when it belongs to a session this process\n * registered as live. A symlinked root is refused outright.\n */\nexport function sweepSessionTempRoot(root: string = getTempRootDir(), options: SweepOptions = {}): SweepOutcome {\n\tif (!isRealDirectory(root)) {\n\t\treturn \"missing\";\n\t}\n\tconst gateOptions: SweepOptions = {\n\t\t...options,\n\t\tprotectedPaths: options.protectedPaths ?? getProtectedSessionTempDirs(),\n\t};\n\treturn withCleanupGate(root, gateOptions, (gate) => {\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readdirSync(root);\n\t\t} catch {\n\t\t\t// Cleanup is best-effort housekeeping; an unreadable root is skipped.\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (isCleanupArtifact(entry)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst entryPath = join(root, entry);\n\t\t\tif (gate.protectedPaths.has(entryPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t// A holder displaced by a stale-lock takeover must stop deleting\n\t\t\t// alongside the new owner.\n\t\t\tif (!gate.ownsLock()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst initialIdentity = realDirectoryIdentity(entryPath);\n\t\t\t\tif (initialIdentity === undefined || scanFreshness(entryPath, gate.cutoff) !== \"stale\") {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!gate.ownsLock()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst finalIdentity = realDirectoryIdentity(entryPath);\n\t\t\t\tif (finalIdentity === undefined || !sameFileIdentity(initialIdentity, finalIdentity)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\trmSync(entryPath, { recursive: true, force: true });\n\t\t\t} catch {\n\t\t\t\t// One bad entry must not block the rest of the sweep.\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Reap one `<parent>/tool-results` directory.\n *\n * A symlinked (or otherwise non-directory) `tool-results` is skipped entirely —\n * neither descended into nor deleted — because `readdirSync`/`rmSync` resolve\n * links and would reach the outside directory the link points at.\n *\n * A directory a live session registered is skipped whatever its age. Age alone\n * is not enough here: replaying a persisted result reuses the existing file\n * without touching its mtime, so a month-old file can be advertised to the model\n * this very turn.\n *\n * Otherwise the directory's newest entry decides its fate, exactly as it does for\n * a session temp tree: one fresh descendant keeps the entire tree, stale siblings\n * included.\n */\nfunction reapToolResultsDir(parent: string, cutoff: number, protectedPaths: ReadonlySet<string>): void {\n\tconst toolResultsDir = join(parent, TOOL_RESULTS_SUBDIR);\n\tif (protectedPaths.has(toolResultsDir) || !isRealDirectory(toolResultsDir)) {\n\t\treturn;\n\t}\n\tif (scanFreshness(toolResultsDir, cutoff) !== \"stale\") {\n\t\treturn;\n\t}\n\trmSync(toolResultsDir, { recursive: true, force: true });\n}\n\n/**\n * Reap stale `tool-results` directories under one project-nested sessions root.\n * Only `<sessionsRoot>/<project>/tool-results` is touched — never the sibling\n * `.jsonl` transcripts.\n */\nexport function sweepToolResultsRoot(sessionsRoot: string, options: SweepOptions = {}): SweepOutcome {\n\tif (!isRealDirectory(sessionsRoot)) {\n\t\treturn \"missing\";\n\t}\n\tconst gateOptions: SweepOptions = {\n\t\t...options,\n\t\tprotectedPaths: options.protectedPaths ?? getProtectedSessionTempDirs(),\n\t};\n\treturn withCleanupGate(getCleanupControlDir(sessionsRoot, options.controlRoot), gateOptions, (gate) => {\n\t\tlet entries: string[];\n\t\ttry {\n\t\t\tentries = readdirSync(sessionsRoot);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tconst projectDir = join(sessionsRoot, entry);\n\t\t\tif (!isRealDirectory(projectDir) || gate.protectedPaths.has(projectDir)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!gate.ownsLock()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\treapToolResultsDir(projectDir, gate.cutoff, gate.protectedPaths);\n\t\t\t} catch {\n\t\t\t\t// Keep going so one unreadable project directory does not block the rest.\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Reap `<sessionDir>/tool-results` for a directly chosen session directory.\n *\n * A custom `--session-dir` has no project nesting: session files live in the\n * directory itself, so only its own `tool-results` child is in scope and its\n * siblings — including transcripts — are never touched.\n */\nexport function sweepSessionDirToolResults(sessionDir: string, options: SweepOptions = {}): SweepOutcome {\n\tif (!isRealDirectory(sessionDir)) {\n\t\treturn \"missing\";\n\t}\n\tconst gateOptions: SweepOptions = {\n\t\t...options,\n\t\tprotectedPaths: options.protectedPaths ?? getProtectedSessionTempDirs(),\n\t};\n\treturn withCleanupGate(getCleanupControlDir(sessionDir, options.controlRoot), gateOptions, (gate) => {\n\t\tif (!gate.ownsLock()) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\treapToolResultsDir(sessionDir, gate.cutoff, gate.protectedPaths);\n\t\t} catch {\n\t\t\t// Best effort.\n\t\t}\n\t});\n}\n\nexport interface SessionTempCleanupOptions extends SweepOptions {\n\t/** Temp root override; defaults to the owner-scoped root. */\n\ttempRoot?: string;\n\t/** Project-nested sessions roots; defaults to the configured agent session roots. */\n\tsessionsRoots?: readonly string[];\n\t/** Directly chosen session directories (custom `--session-dir` and friends). */\n\tsessionDirs?: readonly string[];\n}\n\nfunction safeSessionsRoots(): readonly string[] {\n\ttry {\n\t\treturn getAgentConfigPaths(\"sessions\");\n\t} catch {\n\t\treturn [];\n\t}\n}\n\n/** Run every sweep once. Each failure is swallowed: cleanup is housekeeping. */\nexport function runSessionTempCleanup(options: SessionTempCleanupOptions = {}): void {\n\tconst { tempRoot, sessionsRoots, sessionDirs, ...sweepOptions } = options;\n\ttry {\n\t\tsweepSessionTempRoot(tempRoot ?? getTempRootDir(), sweepOptions);\n\t} catch {\n\t\t// Best effort.\n\t}\n\t// Session storage carries the same protection as the temp trees: a live\n\t// session registers its own `tool-results` directory, and a replayed result\n\t// reuses an old file without refreshing its mtime, so age alone cannot keep\n\t// an advertised path alive.\n\tfor (const root of sessionsRoots ?? safeSessionsRoots()) {\n\t\ttry {\n\t\t\tsweepToolResultsRoot(root, sweepOptions);\n\t\t} catch {\n\t\t\t// Best effort.\n\t\t}\n\t}\n\tfor (const dir of sessionDirs ?? []) {\n\t\ttry {\n\t\t\tsweepSessionDirToolResults(dir, sweepOptions);\n\t\t} catch {\n\t\t\t// Best effort.\n\t\t}\n\t}\n}\n\nlet cleanupScheduled = false;\nlet cleanupTimer: ReturnType<typeof setTimeout> | undefined;\nconst scheduledSessionsRoots = new Set<string>();\nconst scheduledSessionDirs = new Set<string>();\n\n/** Arm one deferred sweep for the roots currently pending. */\nfunction armSessionTempCleanup(options: SessionTempCleanupOptions): void {\n\tcleanupScheduled = true;\n\tcleanupTimer = setTimeout(() => {\n\t\t// Drain before the sweep. A session discovered while cleanup is running adds\n\t\t// to the now-empty sets and is rearmed in `finally`, rather than being lost\n\t\t// or starting a second callback alongside this one.\n\t\tconst sessionsRoots = [...scheduledSessionsRoots];\n\t\tconst sessionDirs = [...scheduledSessionDirs];\n\t\tscheduledSessionsRoots.clear();\n\t\tscheduledSessionDirs.clear();\n\t\ttry {\n\t\t\trunSessionTempCleanup({\n\t\t\t\t...options,\n\t\t\t\tsessionsRoots: sessionsRoots.length > 0 ? sessionsRoots : options.sessionsRoots,\n\t\t\t\tsessionDirs,\n\t\t\t});\n\t\t} finally {\n\t\t\tcleanupTimer = undefined;\n\t\t\tcleanupScheduled = false;\n\t\t\tif (scheduledSessionsRoots.size > 0 || scheduledSessionDirs.size > 0) {\n\t\t\t\tarmSessionTempCleanup(options);\n\t\t\t}\n\t\t}\n\t}, SESSION_TEMP_CLEANUP_DELAY_MS);\n\tcleanupTimer.unref?.();\n}\n\n/**\n * Schedule one deferred sweep for the current pending batch.\n *\n * Calls made before or during a sweep merge their targets into sets. The active\n * callback drains one snapshot, remains marked active while it runs, then rearms\n * one new unref'd timer only when later roots arrived.\n */\nexport function scheduleSessionTempCleanup(options: SessionTempCleanupOptions = {}): void {\n\tfor (const root of options.sessionsRoots ?? []) {\n\t\tscheduledSessionsRoots.add(root);\n\t}\n\tfor (const dir of options.sessionDirs ?? []) {\n\t\tscheduledSessionDirs.add(dir);\n\t}\n\tif (cleanupScheduled) {\n\t\treturn;\n\t}\n\tarmSessionTempCleanup(options);\n}\n\n/** Test seam: cancel pending work and forget scheduler state. */\nexport function resetSessionTempCleanupScheduleForTesting(): void {\n\tif (cleanupTimer !== undefined) {\n\t\tclearTimeout(cleanupTimer);\n\t}\n\tcleanupTimer = undefined;\n\tcleanupScheduled = false;\n\tscheduledSessionsRoots.clear();\n\tscheduledSessionDirs.clear();\n}\n\n/** Narrow lock seam for descriptor-mode and release tests. */\nexport const sessionTempCleanupTestHooks = {\n\tacquireCleanupLock,\n\treleaseCleanupLock,\n};\n"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner- and session-scoped temp storage for tool output files.
|
|
3
|
+
*
|
|
4
|
+
* Every file a tool spills to the system temp directory (bash overflow logs,
|
|
5
|
+
* async bash logs, `OutputAccumulator` spill files, and the in-memory-session
|
|
6
|
+
* tool-result fallback) lands under:
|
|
7
|
+
*
|
|
8
|
+
* ```text
|
|
9
|
+
* <tmpdir>/<APP_NAME>-<owner>/<sanitized-session-id>/
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The owner segment mirrors the upstream Claude Code `claude-{uid}` convention
|
|
13
|
+
* (mehmoodosman/claude-code): a shared multi-user temp directory must never let
|
|
14
|
+
* one account write into (or read) another account's tree. The session segment
|
|
15
|
+
* makes the tree reapable as a unit by the age-based sweeper in
|
|
16
|
+
* `session-temp-cleanup.ts` once the session is long gone.
|
|
17
|
+
*/
|
|
18
|
+
/** Directory mode for every directory this module creates (owner-only). */
|
|
19
|
+
export declare const SESSION_TEMP_DIR_MODE = 448;
|
|
20
|
+
/** File mode for persisted tool-output files (owner-only). */
|
|
21
|
+
export declare const SESSION_TEMP_FILE_MODE = 384;
|
|
22
|
+
/**
|
|
23
|
+
* Reduce a value to a single safe path component.
|
|
24
|
+
*
|
|
25
|
+
* Disallowed characters collapse to `_`; leading `.`/`_` and trailing `.`/`_`
|
|
26
|
+
* are stripped so the result can never be `.`, `..`, a hidden sweeper marker
|
|
27
|
+
* file name, or anything that escapes the parent directory. Trimming uses a
|
|
28
|
+
* linear scan rather than a `/^[._]+|[._]+$/` regex to avoid polynomial-time
|
|
29
|
+
* backtracking on adversarial ids (CodeQL js/polynomial-redos).
|
|
30
|
+
*/
|
|
31
|
+
export declare function sanitizeTempPathComponent(value: string, fallback: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Derive the owner component for a named (non-uid) account.
|
|
34
|
+
*
|
|
35
|
+
* Sanitizing a name to a safe path component is lossy, and two distinct
|
|
36
|
+
* accounts can reduce to the same component (`aliceé` and `aliceø` both yield
|
|
37
|
+
* `alice_`). Where the system temp directory is machine-wide and
|
|
38
|
+
* shared-accessible, that would put two accounts in one tree. Appending a short
|
|
39
|
+
* digest of the raw identity keeps distinct accounts on distinct roots, with
|
|
40
|
+
* the readable component in front so the directory stays recognizable.
|
|
41
|
+
*
|
|
42
|
+
* This prevents collision; it is not owner verification. Ownership is proven
|
|
43
|
+
* separately by `verifyOwnedDirectory` — a uid check on POSIX, an owner-SID
|
|
44
|
+
* and DACL check on Windows.
|
|
45
|
+
*
|
|
46
|
+
* Exported as a pure function so the collision property can be tested directly:
|
|
47
|
+
* its only caller reaches this branch on Windows, which a POSIX test host
|
|
48
|
+
* cannot enter.
|
|
49
|
+
*/
|
|
50
|
+
export declare function deriveOwnerComponent(rawIdentity: string): string;
|
|
51
|
+
/**
|
|
52
|
+
* Assemble the account identity used where there is no uid.
|
|
53
|
+
*
|
|
54
|
+
* `userInfo().username` returns the bare account name, so `CONTOSO\Alice` and
|
|
55
|
+
* `FABRIKAM\Alice` would otherwise be one identity and share a tree. Exported
|
|
56
|
+
* for tests: its caller only reaches this branch on Windows.
|
|
57
|
+
*/
|
|
58
|
+
export declare function windowsPrincipal(name: string | undefined): string;
|
|
59
|
+
/** `<tmpdir>/<APP_NAME>-<owner>` — the root every session temp tree lives under. */
|
|
60
|
+
export declare function getTempRootDir(): string;
|
|
61
|
+
/**
|
|
62
|
+
* The temp directory path for a session, without creating it.
|
|
63
|
+
*
|
|
64
|
+
* Falls back to the process-scoped component when no session id is available,
|
|
65
|
+
* so a tool running outside a transcript session still writes inside the
|
|
66
|
+
* owner-scoped root instead of directly into the system temp directory.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveSessionTempDirPath(sessionId?: string): string;
|
|
69
|
+
/** Raised when a temp directory cannot be created or trusted; callers degrade to no spill file. */
|
|
70
|
+
export declare class TempDirRefusedError extends Error {
|
|
71
|
+
constructor(path: string, reason: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create `dir` with owner-only permissions, validating every component below the
|
|
75
|
+
* system temp directory.
|
|
76
|
+
*
|
|
77
|
+
* Temp children always revalidate the canonical owner root and every later
|
|
78
|
+
* component, even after a cache hit. A system temp reaper can delete a session
|
|
79
|
+
* tree, and an attacker must not turn a memoized path into a symlink bypass.
|
|
80
|
+
* Caller-owned paths outside the temp base may use the memo after confirming
|
|
81
|
+
* the leaf is still a real directory.
|
|
82
|
+
*
|
|
83
|
+
* Throws {@link TempDirRefusedError} when a component cannot be trusted. Every
|
|
84
|
+
* caller treats that as "no spill file", never as a fatal error: failing closed
|
|
85
|
+
* loses a convenience artifact, while failing open writes tool output into a
|
|
86
|
+
* directory someone else controls.
|
|
87
|
+
*/
|
|
88
|
+
export declare function ensureTempDir(dir: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Resolve and create the temp directory for a session.
|
|
91
|
+
*
|
|
92
|
+
* Pass an already-resolved directory to reuse a caller-provided path (still
|
|
93
|
+
* created lazily with the same mode).
|
|
94
|
+
*/
|
|
95
|
+
export declare function getSessionTempDir(sessionId?: string): string;
|
|
96
|
+
/** Create `explicitDir` when supplied, otherwise the active session's temp directory. */
|
|
97
|
+
export declare function ensureSessionTempDir(explicitDir?: string): string;
|
|
98
|
+
/** A protection claim held by one owner; releasing twice is a no-op. */
|
|
99
|
+
export interface ProtectedPathLease {
|
|
100
|
+
release(): void;
|
|
101
|
+
}
|
|
102
|
+
/** Protect `paths` until the returned lease is released. */
|
|
103
|
+
export declare function acquireProtectedPaths(paths: readonly string[]): ProtectedPathLease;
|
|
104
|
+
/**
|
|
105
|
+
* Make `sessionId` the default target for writers without a session handle.
|
|
106
|
+
*
|
|
107
|
+
* Deliberately separate from protection: a disposed session must stop protecting
|
|
108
|
+
* its tree, but whichever session ran last still names where an unattached
|
|
109
|
+
* writer spills.
|
|
110
|
+
*/
|
|
111
|
+
export declare function setActiveSessionTempId(sessionId: string): string;
|
|
112
|
+
/** Directories this process must not reap: session temp trees and live tool-results. */
|
|
113
|
+
export declare function getProtectedSessionTempDirs(): ReadonlySet<string>;
|
|
114
|
+
/** Test seam: forget the process-level active/protected session state. */
|
|
115
|
+
export declare function resetSessionTempDirStateForTesting(): void;
|
|
116
|
+
//# sourceMappingURL=session-temp-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-temp-dir.d.ts","sourceRoot":"","sources":["../../../src/core/tools/session-temp-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,MAAQ,CAAC;AAE3C,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,MAAQ,CAAC;AAQ5C;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYjF;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAUhE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAQjE;AAwDD,oFAAoF;AACpF,wBAAgB,cAAc,IAAI,MAAM,CAGvC;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpE;AAcD,mGAAmG;AACnG,qBAAa,mBAAoB,SAAQ,KAAK;IAC7C,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAGvC;CACD;AA+GD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAyBjD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,yFAAyF;AACzF,wBAAgB,oBAAoB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjE;AAgBD,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IAClC,OAAO,IAAI,IAAI,CAAC;CAChB;AAED,4DAA4D;AAC5D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,kBAAkB,CAsBlF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wFAAwF;AACxF,wBAAgB,2BAA2B,IAAI,WAAW,CAAC,MAAM,CAAC,CAEjE;AAED,0EAA0E;AAC1E,wBAAgB,kCAAkC,IAAI,IAAI,CAOzD"}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Owner- and session-scoped temp storage for tool output files.
|
|
3
|
+
*
|
|
4
|
+
* Every file a tool spills to the system temp directory (bash overflow logs,
|
|
5
|
+
* async bash logs, `OutputAccumulator` spill files, and the in-memory-session
|
|
6
|
+
* tool-result fallback) lands under:
|
|
7
|
+
*
|
|
8
|
+
* ```text
|
|
9
|
+
* <tmpdir>/<APP_NAME>-<owner>/<sanitized-session-id>/
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* The owner segment mirrors the upstream Claude Code `claude-{uid}` convention
|
|
13
|
+
* (mehmoodosman/claude-code): a shared multi-user temp directory must never let
|
|
14
|
+
* one account write into (or read) another account's tree. The session segment
|
|
15
|
+
* makes the tree reapable as a unit by the age-based sweeper in
|
|
16
|
+
* `session-temp-cleanup.ts` once the session is long gone.
|
|
17
|
+
*/
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
19
|
+
import { chmodSync, lstatSync, mkdirSync, realpathSync, rmSync } from "node:fs";
|
|
20
|
+
import { tmpdir, userInfo } from "node:os";
|
|
21
|
+
import { dirname, join, sep } from "node:path";
|
|
22
|
+
import { APP_NAME } from "../../config.js";
|
|
23
|
+
import { getErrnoCode } from "./errno.js";
|
|
24
|
+
import { resetWindowsDirectorySecurityStateForTesting, verifyWindowsDirectorySecurity, } from "./windows-directory-security.js";
|
|
25
|
+
/** Directory mode for every directory this module creates (owner-only). */
|
|
26
|
+
export const SESSION_TEMP_DIR_MODE = 0o700;
|
|
27
|
+
/** File mode for persisted tool-output files (owner-only). */
|
|
28
|
+
export const SESSION_TEMP_FILE_MODE = 0o600;
|
|
29
|
+
/** Longest path component this module will emit for a sanitized value. */
|
|
30
|
+
const MAX_PATH_COMPONENT_LENGTH = 64;
|
|
31
|
+
const FALLBACK_SESSION_COMPONENT = "session";
|
|
32
|
+
const FALLBACK_OWNER_COMPONENT = "user";
|
|
33
|
+
/**
|
|
34
|
+
* Reduce a value to a single safe path component.
|
|
35
|
+
*
|
|
36
|
+
* Disallowed characters collapse to `_`; leading `.`/`_` and trailing `.`/`_`
|
|
37
|
+
* are stripped so the result can never be `.`, `..`, a hidden sweeper marker
|
|
38
|
+
* file name, or anything that escapes the parent directory. Trimming uses a
|
|
39
|
+
* linear scan rather than a `/^[._]+|[._]+$/` regex to avoid polynomial-time
|
|
40
|
+
* backtracking on adversarial ids (CodeQL js/polynomial-redos).
|
|
41
|
+
*/
|
|
42
|
+
export function sanitizeTempPathComponent(value, fallback) {
|
|
43
|
+
const collapsed = value.replace(/[^a-zA-Z0-9._-]+/g, "_");
|
|
44
|
+
let start = 0;
|
|
45
|
+
let end = collapsed.length;
|
|
46
|
+
while (start < end && (collapsed[start] === "_" || collapsed[start] === ".")) {
|
|
47
|
+
start++;
|
|
48
|
+
}
|
|
49
|
+
while (end > start && (collapsed[end - 1] === "_" || collapsed[end - 1] === ".")) {
|
|
50
|
+
end--;
|
|
51
|
+
}
|
|
52
|
+
const sanitized = collapsed.slice(start, end).slice(0, MAX_PATH_COMPONENT_LENGTH);
|
|
53
|
+
return sanitized.length > 0 ? sanitized : fallback;
|
|
54
|
+
}
|
|
55
|
+
let cachedOwnerComponent;
|
|
56
|
+
/**
|
|
57
|
+
* Derive the owner component for a named (non-uid) account.
|
|
58
|
+
*
|
|
59
|
+
* Sanitizing a name to a safe path component is lossy, and two distinct
|
|
60
|
+
* accounts can reduce to the same component (`aliceé` and `aliceø` both yield
|
|
61
|
+
* `alice_`). Where the system temp directory is machine-wide and
|
|
62
|
+
* shared-accessible, that would put two accounts in one tree. Appending a short
|
|
63
|
+
* digest of the raw identity keeps distinct accounts on distinct roots, with
|
|
64
|
+
* the readable component in front so the directory stays recognizable.
|
|
65
|
+
*
|
|
66
|
+
* This prevents collision; it is not owner verification. Ownership is proven
|
|
67
|
+
* separately by `verifyOwnedDirectory` — a uid check on POSIX, an owner-SID
|
|
68
|
+
* and DACL check on Windows.
|
|
69
|
+
*
|
|
70
|
+
* Exported as a pure function so the collision property can be tested directly:
|
|
71
|
+
* its only caller reaches this branch on Windows, which a POSIX test host
|
|
72
|
+
* cannot enter.
|
|
73
|
+
*/
|
|
74
|
+
export function deriveOwnerComponent(rawIdentity) {
|
|
75
|
+
// Windows account names are case-insensitive, so `Alice` and `alice` are one
|
|
76
|
+
// account and must resolve to one root. Normalize before both the readable
|
|
77
|
+
// component and the digest: normalizing only the digest would still emit two
|
|
78
|
+
// spellings of one directory, which NTFS then treats as the same path while
|
|
79
|
+
// the sweeper's bookkeeping sees two.
|
|
80
|
+
const normalized = rawIdentity.toLowerCase();
|
|
81
|
+
const readable = sanitizeTempPathComponent(normalized, FALLBACK_OWNER_COMPONENT);
|
|
82
|
+
const digest = createHash("sha256").update(normalized).digest("hex").slice(0, 8);
|
|
83
|
+
return `${readable}-${digest}`;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Assemble the account identity used where there is no uid.
|
|
87
|
+
*
|
|
88
|
+
* `userInfo().username` returns the bare account name, so `CONTOSO\Alice` and
|
|
89
|
+
* `FABRIKAM\Alice` would otherwise be one identity and share a tree. Exported
|
|
90
|
+
* for tests: its caller only reaches this branch on Windows.
|
|
91
|
+
*/
|
|
92
|
+
export function windowsPrincipal(name) {
|
|
93
|
+
const account = name || process.env.USERNAME || process.env.USER || "";
|
|
94
|
+
// USERDOMAIN is the NetBIOS domain and is set for both domain and local
|
|
95
|
+
// accounts; USERDNSDOMAIN appears only on domain-joined hosts and
|
|
96
|
+
// distinguishes two forests that share a NetBIOS name. Neither is
|
|
97
|
+
// authoritative on its own, so both take part in the identity.
|
|
98
|
+
const domain = process.env.USERDNSDOMAIN || process.env.USERDOMAIN || "";
|
|
99
|
+
return domain ? `${domain}\\${account}` : account;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Identify the account that owns the temp tree.
|
|
103
|
+
*
|
|
104
|
+
* POSIX uses the numeric uid, which is already collision-free. Windows has no
|
|
105
|
+
* `process.getuid`, so the domain-qualified principal stands in.
|
|
106
|
+
*/
|
|
107
|
+
function ownerComponent() {
|
|
108
|
+
if (cachedOwnerComponent !== undefined) {
|
|
109
|
+
return cachedOwnerComponent;
|
|
110
|
+
}
|
|
111
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
112
|
+
if (typeof uid === "number" && Number.isFinite(uid)) {
|
|
113
|
+
cachedOwnerComponent = String(uid);
|
|
114
|
+
return cachedOwnerComponent;
|
|
115
|
+
}
|
|
116
|
+
let name;
|
|
117
|
+
try {
|
|
118
|
+
name = userInfo().username;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// A container without a passwd entry cannot name the account; the env
|
|
122
|
+
// fallback inside windowsPrincipal still separates the common case.
|
|
123
|
+
name = undefined;
|
|
124
|
+
}
|
|
125
|
+
cachedOwnerComponent = deriveOwnerComponent(windowsPrincipal(name));
|
|
126
|
+
return cachedOwnerComponent;
|
|
127
|
+
}
|
|
128
|
+
let cachedBaseTempDirs;
|
|
129
|
+
/**
|
|
130
|
+
* Preserve the OS-provided temp spelling for returned paths while caching a
|
|
131
|
+
* canonical form for internal component checks (macOS `/var` → `/private/var`,
|
|
132
|
+
* for example). Nothing below the base is resolved through `realpath`.
|
|
133
|
+
*/
|
|
134
|
+
function baseTempDirs() {
|
|
135
|
+
const raw = tmpdir();
|
|
136
|
+
if (cachedBaseTempDirs?.raw === raw) {
|
|
137
|
+
return cachedBaseTempDirs;
|
|
138
|
+
}
|
|
139
|
+
let canonical = raw;
|
|
140
|
+
try {
|
|
141
|
+
canonical = realpathSync(raw);
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// An unresolvable temp directory is checked as given.
|
|
145
|
+
}
|
|
146
|
+
cachedBaseTempDirs = { raw, canonical };
|
|
147
|
+
return cachedBaseTempDirs;
|
|
148
|
+
}
|
|
149
|
+
/** `<tmpdir>/<APP_NAME>-<owner>` — the root every session temp tree lives under. */
|
|
150
|
+
export function getTempRootDir() {
|
|
151
|
+
const app = sanitizeTempPathComponent(APP_NAME, "atomic");
|
|
152
|
+
return join(baseTempDirs().raw, `${app}-${ownerComponent()}`);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The temp directory path for a session, without creating it.
|
|
156
|
+
*
|
|
157
|
+
* Falls back to the process-scoped component when no session id is available,
|
|
158
|
+
* so a tool running outside a transcript session still writes inside the
|
|
159
|
+
* owner-scoped root instead of directly into the system temp directory.
|
|
160
|
+
*/
|
|
161
|
+
export function resolveSessionTempDirPath(sessionId) {
|
|
162
|
+
const id = sessionId ?? activeSessionId ?? `pid-${process.pid}`;
|
|
163
|
+
return join(getTempRootDir(), sanitizeTempPathComponent(id, FALLBACK_SESSION_COMPONENT));
|
|
164
|
+
}
|
|
165
|
+
const ensuredDirs = new Set();
|
|
166
|
+
/** An existing real directory — not a symlink, not a file, not missing. */
|
|
167
|
+
function isRealDirectory(path) {
|
|
168
|
+
try {
|
|
169
|
+
const stat = lstatSync(path);
|
|
170
|
+
return stat.isDirectory() && !stat.isSymbolicLink();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** Raised when a temp directory cannot be created or trusted; callers degrade to no spill file. */
|
|
177
|
+
export class TempDirRefusedError extends Error {
|
|
178
|
+
constructor(path, reason) {
|
|
179
|
+
super(`Refusing to use temp directory ${path}: ${reason}`);
|
|
180
|
+
this.name = "TempDirRefusedError";
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Confirm one existing component is a directory this account owns, at mode 0700.
|
|
185
|
+
*
|
|
186
|
+
* A looser mode is tightened and re-checked; a component owned by another
|
|
187
|
+
* account, or one whose mode cannot be tightened, is refused rather than used.
|
|
188
|
+
*
|
|
189
|
+
* Windows has no uid or POSIX mode, so the proof comes from the security
|
|
190
|
+
* descriptor instead: the owner SID must be a trusted principal and the DACL
|
|
191
|
+
* must grant access to trusted principals only
|
|
192
|
+
* (see `windows-directory-security.ts`). Node exposes neither — `lstatSync`
|
|
193
|
+
* reports uid/gid 0 on Windows — so the read goes through a PowerShell
|
|
194
|
+
* `Get-Acl` subprocess. Successful verifications are cached per path per
|
|
195
|
+
* process, keyed to the directory's metadata identity so a swapped directory
|
|
196
|
+
* or an in-place DACL edit forces a fresh read. Domain-qualifying the
|
|
197
|
+
* principal (see `windowsPrincipal`) stops two accounts *colliding* by
|
|
198
|
+
* accident, which is a different problem and is not a substitute for this
|
|
199
|
+
* verification.
|
|
200
|
+
*/
|
|
201
|
+
function verifyOwnedDirectory(path, known) {
|
|
202
|
+
let stat = known ?? lstatSync(path);
|
|
203
|
+
if (stat.isSymbolicLink()) {
|
|
204
|
+
throw new TempDirRefusedError(path, "it is a symbolic link");
|
|
205
|
+
}
|
|
206
|
+
if (!stat.isDirectory()) {
|
|
207
|
+
throw new TempDirRefusedError(path, "it is not a directory");
|
|
208
|
+
}
|
|
209
|
+
if (process.platform === "win32") {
|
|
210
|
+
const refusal = verifyWindowsDirectorySecurity(path);
|
|
211
|
+
if (refusal !== undefined) {
|
|
212
|
+
throw new TempDirRefusedError(path, refusal);
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const uid = typeof process.getuid === "function" ? process.getuid() : undefined;
|
|
217
|
+
if (typeof uid === "number" && stat.uid !== uid) {
|
|
218
|
+
throw new TempDirRefusedError(path, "it is owned by another account");
|
|
219
|
+
}
|
|
220
|
+
if ((stat.mode & 0o777) === SESSION_TEMP_DIR_MODE) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
chmodSync(path, SESSION_TEMP_DIR_MODE);
|
|
225
|
+
stat = lstatSync(path);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
throw new TempDirRefusedError(path, "its permissions could not be tightened");
|
|
229
|
+
}
|
|
230
|
+
if ((stat.mode & 0o777) !== SESSION_TEMP_DIR_MODE) {
|
|
231
|
+
throw new TempDirRefusedError(path, "its permissions could not be tightened");
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Create or adopt one path component, never following a link to get there.
|
|
236
|
+
*
|
|
237
|
+
* Creation is non-recursive on purpose: `mkdir -p` resolves an existing symlink
|
|
238
|
+
* on the way down, which is how a link planted at the predictable owner root
|
|
239
|
+
* redirects every later write outside the tree.
|
|
240
|
+
*/
|
|
241
|
+
function ensureOwnedDirectory(path) {
|
|
242
|
+
let stat;
|
|
243
|
+
try {
|
|
244
|
+
stat = lstatSync(path);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
stat = undefined;
|
|
248
|
+
}
|
|
249
|
+
if (stat === undefined) {
|
|
250
|
+
try {
|
|
251
|
+
mkdirSync(path, { recursive: false, mode: SESSION_TEMP_DIR_MODE });
|
|
252
|
+
}
|
|
253
|
+
catch (error) {
|
|
254
|
+
// A concurrent creator winning the race is fine; anything else is not.
|
|
255
|
+
if (getErrnoCode(error) !== "EEXIST") {
|
|
256
|
+
throw new TempDirRefusedError(path, "it could not be created");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
verifyOwnedDirectory(path);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
verifyOwnedDirectory(path, stat);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Adopt the final component, replacing something that is not a directory.
|
|
266
|
+
*
|
|
267
|
+
* Only the leaf gets this treatment: a stale file or link left where a session
|
|
268
|
+
* directory belongs is ours to clear, and removing a symlink removes the link
|
|
269
|
+
* alone. A parent — above all the owner root — is refused instead, because
|
|
270
|
+
* deleting it would be acting on a directory this process does not own.
|
|
271
|
+
*/
|
|
272
|
+
function ensureLeafDirectory(dir) {
|
|
273
|
+
try {
|
|
274
|
+
if (!lstatSync(dir).isDirectory()) {
|
|
275
|
+
rmSync(dir, { force: true });
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
// Nothing at the path yet, or it cannot be inspected; creation decides.
|
|
280
|
+
}
|
|
281
|
+
ensureOwnedDirectory(dir);
|
|
282
|
+
}
|
|
283
|
+
/** Map a lexical temp child to the same path below the canonical temp base. */
|
|
284
|
+
function canonicalTempChild(dir, base) {
|
|
285
|
+
for (const candidate of [base.raw, base.canonical]) {
|
|
286
|
+
const prefix = `${candidate}${sep}`;
|
|
287
|
+
if (dir.startsWith(prefix)) {
|
|
288
|
+
return join(base.canonical, dir.slice(prefix.length));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Create `dir` with owner-only permissions, validating every component below the
|
|
295
|
+
* system temp directory.
|
|
296
|
+
*
|
|
297
|
+
* Temp children always revalidate the canonical owner root and every later
|
|
298
|
+
* component, even after a cache hit. A system temp reaper can delete a session
|
|
299
|
+
* tree, and an attacker must not turn a memoized path into a symlink bypass.
|
|
300
|
+
* Caller-owned paths outside the temp base may use the memo after confirming
|
|
301
|
+
* the leaf is still a real directory.
|
|
302
|
+
*
|
|
303
|
+
* Throws {@link TempDirRefusedError} when a component cannot be trusted. Every
|
|
304
|
+
* caller treats that as "no spill file", never as a fatal error: failing closed
|
|
305
|
+
* loses a convenience artifact, while failing open writes tool output into a
|
|
306
|
+
* directory someone else controls.
|
|
307
|
+
*/
|
|
308
|
+
export function ensureTempDir(dir) {
|
|
309
|
+
const base = baseTempDirs();
|
|
310
|
+
const checkedDir = canonicalTempChild(dir, base);
|
|
311
|
+
if (checkedDir !== undefined) {
|
|
312
|
+
const prefix = `${base.canonical}${sep}`;
|
|
313
|
+
const parts = checkedDir
|
|
314
|
+
.slice(prefix.length)
|
|
315
|
+
.split(sep)
|
|
316
|
+
.filter((part) => part.length > 0);
|
|
317
|
+
let current = base.canonical;
|
|
318
|
+
for (const part of parts.slice(0, -1)) {
|
|
319
|
+
current = join(current, part);
|
|
320
|
+
ensureOwnedDirectory(current);
|
|
321
|
+
}
|
|
322
|
+
ensureLeafDirectory(checkedDir);
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
// A caller-supplied directory outside the system temp base (a session
|
|
326
|
+
// directory, for instance) is the caller's to own; only the leaf is ours.
|
|
327
|
+
if (!(ensuredDirs.has(dir) && isRealDirectory(dir))) {
|
|
328
|
+
mkdirSync(dirname(dir), { recursive: true, mode: SESSION_TEMP_DIR_MODE });
|
|
329
|
+
ensureLeafDirectory(dir);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
ensuredDirs.add(dir);
|
|
333
|
+
return dir;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Resolve and create the temp directory for a session.
|
|
337
|
+
*
|
|
338
|
+
* Pass an already-resolved directory to reuse a caller-provided path (still
|
|
339
|
+
* created lazily with the same mode).
|
|
340
|
+
*/
|
|
341
|
+
export function getSessionTempDir(sessionId) {
|
|
342
|
+
return ensureTempDir(resolveSessionTempDirPath(sessionId));
|
|
343
|
+
}
|
|
344
|
+
/** Create `explicitDir` when supplied, otherwise the active session's temp directory. */
|
|
345
|
+
export function ensureSessionTempDir(explicitDir) {
|
|
346
|
+
return ensureTempDir(explicitDir ?? resolveSessionTempDirPath());
|
|
347
|
+
}
|
|
348
|
+
let activeSessionId;
|
|
349
|
+
/**
|
|
350
|
+
* Refcounted protection for directories the sweeper must not reap.
|
|
351
|
+
*
|
|
352
|
+
* A count rather than a set, because protection has more than one holder and
|
|
353
|
+
* more than one lifetime: a session protects its own tree, an async spill writer
|
|
354
|
+
* outlives the session object it started under, and one session can be replaced
|
|
355
|
+
* by another wrapping the same paths. Releasing one holder must not unprotect a
|
|
356
|
+
* directory another is still writing to, and a session that is gone must stop
|
|
357
|
+
* protecting a tree the startup sweep exists to collect.
|
|
358
|
+
*/
|
|
359
|
+
const protectedPathCounts = new Map();
|
|
360
|
+
/** Protect `paths` until the returned lease is released. */
|
|
361
|
+
export function acquireProtectedPaths(paths) {
|
|
362
|
+
const claimed = paths.filter((path) => path.length > 0);
|
|
363
|
+
for (const path of claimed) {
|
|
364
|
+
protectedPathCounts.set(path, (protectedPathCounts.get(path) ?? 0) + 1);
|
|
365
|
+
}
|
|
366
|
+
let released = false;
|
|
367
|
+
return {
|
|
368
|
+
release() {
|
|
369
|
+
if (released) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
released = true;
|
|
373
|
+
for (const path of claimed) {
|
|
374
|
+
const remaining = (protectedPathCounts.get(path) ?? 0) - 1;
|
|
375
|
+
if (remaining > 0) {
|
|
376
|
+
protectedPathCounts.set(path, remaining);
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
protectedPathCounts.delete(path);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Make `sessionId` the default target for writers without a session handle.
|
|
387
|
+
*
|
|
388
|
+
* Deliberately separate from protection: a disposed session must stop protecting
|
|
389
|
+
* its tree, but whichever session ran last still names where an unattached
|
|
390
|
+
* writer spills.
|
|
391
|
+
*/
|
|
392
|
+
export function setActiveSessionTempId(sessionId) {
|
|
393
|
+
activeSessionId = sessionId;
|
|
394
|
+
return resolveSessionTempDirPath(sessionId);
|
|
395
|
+
}
|
|
396
|
+
/** Directories this process must not reap: session temp trees and live tool-results. */
|
|
397
|
+
export function getProtectedSessionTempDirs() {
|
|
398
|
+
return new Set(protectedPathCounts.keys());
|
|
399
|
+
}
|
|
400
|
+
/** Test seam: forget the process-level active/protected session state. */
|
|
401
|
+
export function resetSessionTempDirStateForTesting() {
|
|
402
|
+
activeSessionId = undefined;
|
|
403
|
+
protectedPathCounts.clear();
|
|
404
|
+
ensuredDirs.clear();
|
|
405
|
+
cachedOwnerComponent = undefined;
|
|
406
|
+
cachedBaseTempDirs = undefined;
|
|
407
|
+
resetWindowsDirectorySecurityStateForTesting();
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=session-temp-dir.js.map
|