@bastani/atomic 0.9.9 → 0.9.10-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +2 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +3 -3
- package/dist/builtin/intercom/CHANGELOG.md +15 -0
- package/dist/builtin/intercom/README.md +12 -4
- package/dist/builtin/intercom/broker/broker.ts +96 -14
- package/dist/builtin/intercom/broker/client-message-validation.ts +39 -0
- package/dist/builtin/intercom/broker/client.ts +101 -92
- package/dist/builtin/intercom/broker/group-isolation.ts +28 -0
- package/dist/builtin/intercom/broker/send-handler.ts +62 -10
- package/dist/builtin/intercom/broker/send-signature.ts +3 -0
- package/dist/builtin/intercom/broker/supervisor-channel.ts +126 -0
- package/dist/builtin/intercom/closed-workflow-stage-message.ts +66 -0
- package/dist/builtin/intercom/config.ts +10 -0
- package/dist/builtin/intercom/contact-supervisor-tool.ts +14 -10
- package/dist/builtin/intercom/foreground-detach-handoff.ts +12 -2
- package/dist/builtin/intercom/group.ts +46 -0
- package/dist/builtin/intercom/inbound-message-admission.ts +79 -0
- package/dist/builtin/intercom/incoming-message-delivery.ts +49 -0
- package/dist/builtin/intercom/index-heavy.ts +148 -94
- package/dist/builtin/intercom/index.ts +66 -4
- package/dist/builtin/intercom/intercom-test-seams.ts +6 -0
- package/dist/builtin/intercom/intercom-tool.ts +71 -20
- package/dist/builtin/intercom/intercom-utils.ts +15 -2
- package/dist/builtin/intercom/late-stage-message-router.ts +148 -0
- package/dist/builtin/intercom/lifecycle.ts +10 -4
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/intercom/reconnect-backoff.ts +6 -0
- package/dist/builtin/intercom/reply-tracker.ts +8 -0
- package/dist/builtin/intercom/skills/intercom/SKILL.md +2 -0
- package/dist/builtin/intercom/stable-delivery-retry.ts +32 -0
- package/dist/builtin/intercom/subagent-relay.ts +67 -14
- package/dist/builtin/intercom/supervisor-authorization-registry.ts +22 -0
- package/dist/builtin/intercom/terminal-ordering-barrier.ts +144 -25
- package/dist/builtin/intercom/types.ts +18 -5
- package/dist/builtin/intercom/workflow-reply-tracker.ts +19 -0
- package/dist/builtin/intercom/workflow-stage-admission.ts +43 -0
- package/dist/builtin/intercom/workflow-stage-delivery-failure.ts +77 -0
- package/dist/builtin/mcp/CHANGELOG.md +11 -0
- package/dist/builtin/mcp/README.md +6 -2
- package/dist/builtin/mcp/config.ts +8 -8
- package/dist/builtin/mcp/direct-tool-executor.ts +7 -6
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/mcp/proxy-call.ts +5 -4
- package/dist/builtin/mcp/sampling-handler.ts +7 -2
- package/dist/builtin/mcp/tool-call-timeout.ts +101 -0
- package/dist/builtin/mcp/tool-result-renderer.ts +3 -2
- package/dist/builtin/mcp/types.ts +5 -0
- package/dist/builtin/mcp/ui-server.ts +3 -2
- package/dist/builtin/subagents/CHANGELOG.md +21 -0
- package/dist/builtin/subagents/README.md +6 -3
- package/dist/builtin/subagents/agents/code-simplifier.md +1 -1
- package/dist/builtin/subagents/agents/codebase-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-locator.md +1 -1
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +1 -1
- package/dist/builtin/subagents/agents/codebase-pattern-finder.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-analyzer.md +1 -1
- package/dist/builtin/subagents/agents/codebase-research-locator.md +1 -1
- package/dist/builtin/subagents/agents/debugger.md +1 -1
- package/dist/builtin/subagents/agents/worker.md +1 -1
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +37 -61
- package/dist/builtin/subagents/src/extension/notification-content.ts +80 -0
- package/dist/builtin/subagents/src/extension/schemas.ts +9 -0
- package/dist/builtin/subagents/src/extension/tool-description.ts +1 -0
- package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +23 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-chain.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/background/async-execution-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +75 -13
- package/dist/builtin/subagents/src/runs/background/async-status.ts +19 -0
- package/dist/builtin/subagents/src/runs/background/completion-notification.ts +4 -3
- package/dist/builtin/subagents/src/runs/background/notify.ts +76 -15
- package/dist/builtin/subagents/src/runs/background/stale-run-reconciler.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-dynamic.ts +13 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-parallel.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-sequential.ts +1 -0
- package/dist/builtin/subagents/src/runs/background/subagent-runner-step.ts +2 -1
- package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +4 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-runner.ts +13 -0
- package/dist/builtin/subagents/src/runs/foreground/chain-execution-parallel-step.ts +19 -2
- package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +26 -0
- package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +19 -30
- package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +47 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +60 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +21 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +21 -2
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-resume.ts +6 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +2 -0
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +50 -0
- package/dist/builtin/subagents/src/runs/shared/pi-args.ts +16 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +75 -0
- package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +51 -0
- package/dist/builtin/subagents/src/runs/shared/worktree.ts +69 -77
- package/dist/builtin/subagents/src/shared/types-config.ts +6 -0
- package/dist/builtin/subagents/src/slash/slash-commands.ts +3 -2
- package/dist/builtin/subagents/src/tui/render-result-compact.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-result.ts +5 -3
- package/dist/builtin/subagents/src/tui/render-widget-graph.ts +7 -4
- package/dist/builtin/web-access/CHANGELOG.md +11 -0
- package/dist/builtin/web-access/extract-frames.ts +14 -13
- package/dist/builtin/web-access/extract.ts +2 -2
- package/dist/builtin/web-access/gemini-api.ts +0 -3
- package/dist/builtin/web-access/gemini-web-config.ts +1 -3
- package/dist/builtin/web-access/gemini-web.ts +1 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/web-access/perplexity.ts +0 -3
- package/dist/builtin/web-access/result-renderers.ts +7 -5
- package/dist/builtin/web-access/subprocess.ts +100 -0
- package/dist/builtin/web-access/summary-review.ts +14 -3
- package/dist/builtin/web-access/video-extract.ts +12 -17
- package/dist/builtin/web-access/web-search-browser.ts +18 -10
- package/dist/builtin/web-access/web-search-summary.ts +9 -2
- package/dist/builtin/web-access/youtube-extract.ts +22 -25
- package/dist/builtin/workflows/CHANGELOG.md +77 -0
- package/dist/builtin/workflows/README.md +76 -38
- package/dist/builtin/workflows/ambient.d.ts +30 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/adversarial-verification-runner.ts +93 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.d.ts +11 -0
- package/dist/builtin/workflows/builtin/adversarial-verification.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/classify-and-act-runner.ts +110 -0
- package/dist/builtin/workflows/builtin/classify-and-act.d.ts +24 -0
- package/dist/builtin/workflows/builtin/classify-and-act.ts +35 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +8 -2
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-prompts.ts +11 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize-runner.ts +96 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.d.ts +23 -0
- package/dist/builtin/workflows/builtin/fan-out-and-synthesize.ts +32 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-prompts.ts +15 -0
- package/dist/builtin/workflows/builtin/generate-and-filter-runner.ts +75 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.d.ts +11 -0
- package/dist/builtin/workflows/builtin/generate-and-filter.ts +26 -0
- package/dist/builtin/workflows/builtin/goal-models.ts +72 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +2 -64
- package/dist/builtin/workflows/builtin/index.d.ts +44 -0
- package/dist/builtin/workflows/builtin/index.ts +6 -0
- package/dist/builtin/workflows/builtin/loop-until-done-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/loop-until-done-runner.ts +189 -0
- package/dist/builtin/workflows/builtin/loop-until-done.d.ts +34 -0
- package/dist/builtin/workflows/builtin/loop-until-done.ts +31 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +6 -1
- package/dist/builtin/workflows/builtin/pattern-artifact-root.ts +28 -0
- package/dist/builtin/workflows/builtin/ralph-models.ts +26 -5
- package/dist/builtin/workflows/builtin/ralph-runner.ts +1 -0
- package/dist/builtin/workflows/builtin/tournament-prompts.ts +79 -0
- package/dist/builtin/workflows/builtin/tournament-runner.ts +188 -0
- package/dist/builtin/workflows/builtin/tournament.d.ts +33 -0
- package/dist/builtin/workflows/builtin/tournament.ts +34 -0
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring.d.ts +2 -6
- package/dist/builtin/workflows/src/durable/backend.ts +163 -120
- package/dist/builtin/workflows/src/durable/completed-catalog.ts +37 -64
- package/dist/builtin/workflows/src/durable/completed-inspection.ts +4 -72
- package/dist/builtin/workflows/src/durable/dbos-backend.ts +242 -195
- package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +207 -0
- package/dist/builtin/workflows/src/durable/dbos-envelope.ts +42 -42
- package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +155 -0
- package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +126 -0
- package/dist/builtin/workflows/src/durable/dbos-metadata.ts +105 -58
- package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +320 -0
- package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +161 -0
- package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +62 -0
- package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +2 -2
- package/dist/builtin/workflows/src/durable/durable-hash.ts +20 -0
- package/dist/builtin/workflows/src/durable/factory.ts +23 -83
- package/dist/builtin/workflows/src/durable/format-version.ts +4 -10
- package/dist/builtin/workflows/src/durable/index.ts +16 -20
- package/dist/builtin/workflows/src/durable/local-command.ts +63 -0
- package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +177 -0
- package/dist/builtin/workflows/src/durable/prompt-reservations.ts +36 -0
- package/dist/builtin/workflows/src/durable/resume-catalog.ts +2 -200
- package/dist/builtin/workflows/src/durable/resume-eligibility.ts +42 -2
- package/dist/builtin/workflows/src/durable/resume-runtime.ts +121 -118
- package/dist/builtin/workflows/src/durable/retention-policy.ts +42 -0
- package/dist/builtin/workflows/src/durable/run-timing.ts +98 -0
- package/dist/builtin/workflows/src/durable/scoped-backend.ts +62 -14
- package/dist/builtin/workflows/src/durable/stage-primitive.ts +15 -2
- package/dist/builtin/workflows/src/durable/tool-primitive.ts +11 -7
- package/dist/builtin/workflows/src/durable/types.ts +25 -18
- package/dist/builtin/workflows/src/durable/ui-primitive.ts +117 -29
- package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +30 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +20 -5
- package/dist/builtin/workflows/src/engine/primitives/task.ts +3 -2
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +6 -3
- package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +14 -22
- package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +14 -14
- package/dist/builtin/workflows/src/engine/run.ts +35 -37
- package/dist/builtin/workflows/src/engine/runtime.ts +3 -0
- package/dist/builtin/workflows/src/engine/workflow-activity.ts +9 -0
- package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +155 -0
- package/dist/builtin/workflows/src/extension/config-file-loader.ts +13 -0
- package/dist/builtin/workflows/src/extension/config-loader.ts +20 -0
- package/dist/builtin/workflows/src/extension/dispatcher.ts +56 -17
- package/dist/builtin/workflows/src/extension/extension-factory.ts +13 -10
- package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +37 -59
- package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +16 -18
- package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +83 -0
- package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +80 -41
- package/dist/builtin/workflows/src/extension/postmortem-deps.ts +73 -0
- package/dist/builtin/workflows/src/extension/public-types.ts +11 -51
- package/dist/builtin/workflows/src/extension/render-call.ts +3 -9
- package/dist/builtin/workflows/src/extension/render-result.ts +22 -7
- package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +78 -0
- package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +50 -29
- package/dist/builtin/workflows/src/extension/runtime.ts +70 -219
- package/dist/builtin/workflows/src/extension/ui-surface.ts +107 -3
- package/dist/builtin/workflows/src/extension/wiring.ts +76 -7
- package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +10 -5
- package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +27 -5
- package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +49 -19
- package/dist/builtin/workflows/src/extension/workflow-prompts.ts +8 -8
- package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +81 -0
- package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +55 -0
- package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +193 -145
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +9 -133
- package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +189 -0
- package/dist/builtin/workflows/src/extension/workflow-targets.ts +1 -1
- package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +78 -3
- package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +185 -89
- package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +92 -11
- package/dist/builtin/workflows/src/extension/workflow-tool.ts +18 -24
- package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +63 -0
- package/dist/builtin/workflows/src/runs/background/quit.ts +139 -29
- package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +97 -0
- package/dist/builtin/workflows/src/runs/background/run-inspect.ts +111 -0
- package/dist/builtin/workflows/src/runs/background/runner.ts +46 -17
- package/dist/builtin/workflows/src/runs/background/startup-admission.ts +77 -0
- package/dist/builtin/workflows/src/runs/background/status.ts +133 -224
- package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +44 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +57 -256
- package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +7 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +12 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +39 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +75 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +44 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +63 -12
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +30 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +3 -0
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +0 -67
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +6 -0
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +0 -1
- package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +169 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +38 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +21 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +21 -3
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +85 -84
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +195 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +12 -5
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +42 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +100 -8
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +51 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +19 -0
- package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +28 -2
- package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +4 -6
- package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +89 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +29 -133
- package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +130 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-root.ts +84 -0
- package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +77 -63
- package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +4 -0
- package/dist/builtin/workflows/src/sdk-surface.ts +1 -1
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +29 -22
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +26 -24
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +5 -0
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +5 -0
- package/dist/builtin/workflows/src/shared/intercom-group.ts +51 -0
- package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +6 -0
- package/dist/builtin/workflows/src/shared/persistence-restore.ts +4 -0
- package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +3 -0
- package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +13 -0
- package/dist/builtin/workflows/src/shared/returned-run-status.ts +2 -1
- package/dist/builtin/workflows/src/shared/session-transcript.ts +74 -0
- package/dist/builtin/workflows/src/shared/store-stage-methods.ts +1 -0
- package/dist/builtin/workflows/src/shared/store-types.ts +8 -0
- package/dist/builtin/workflows/src/shared/timing.ts +4 -1
- package/dist/builtin/workflows/src/shared/types.ts +2 -6
- package/dist/builtin/workflows/src/tui/chat-surface-message.ts +2 -42
- package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +2 -2
- package/dist/builtin/workflows/src/tui/graph-view-constants.ts +7 -3
- package/dist/builtin/workflows/src/tui/graph-view-input.ts +29 -67
- package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +15 -10
- package/dist/builtin/workflows/src/tui/graph-view-state.ts +0 -2
- package/dist/builtin/workflows/src/tui/graph-view-types.ts +3 -9
- package/dist/builtin/workflows/src/tui/host-input-form.ts +62 -0
- package/dist/builtin/workflows/src/tui/mouse-input.ts +63 -0
- package/dist/builtin/workflows/src/tui/node-card.ts +1 -0
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +67 -42
- package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +49 -0
- package/dist/builtin/workflows/src/tui/session-overlays.ts +3 -104
- package/dist/builtin/workflows/src/tui/session-picker.ts +3 -12
- package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +19 -0
- package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +30 -10
- package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +19 -9
- package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +25 -38
- package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +1 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +7 -6
- package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +7 -1
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +3 -1
- package/dist/builtin/workflows/src/tui/store-widget-installer.ts +19 -20
- package/dist/builtin/workflows/src/tui/switcher.ts +4 -4
- package/dist/builtin/workflows/src/tui/widget.ts +46 -33
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +26 -0
- package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +14 -2
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +26 -27
- package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +208 -69
- package/dist/bun/cli.js +3 -0
- package/dist/bun/cli.js.map +1 -1
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +3 -0
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +19 -2
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-compaction.js +2 -2
- package/dist/core/agent-session-compaction.js.map +1 -1
- package/dist/core/agent-session-events.d.ts.map +1 -1
- package/dist/core/agent-session-events.js +5 -3
- package/dist/core/agent-session-events.js.map +1 -1
- package/dist/core/agent-session-export.js +1 -1
- package/dist/core/agent-session-export.js.map +1 -1
- package/dist/core/agent-session-extension-bindings.d.ts +2 -4
- package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
- package/dist/core/agent-session-extension-bindings.js +9 -2
- package/dist/core/agent-session-extension-bindings.js.map +1 -1
- package/dist/core/agent-session-message-queue.d.ts +6 -0
- package/dist/core/agent-session-message-queue.d.ts.map +1 -1
- package/dist/core/agent-session-message-queue.js +107 -36
- package/dist/core/agent-session-message-queue.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +18 -7
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-models.d.ts +3 -1
- package/dist/core/agent-session-models.d.ts.map +1 -1
- package/dist/core/agent-session-models.js +1 -1
- package/dist/core/agent-session-models.js.map +1 -1
- package/dist/core/agent-session-post-tool-compaction.d.ts +16 -0
- package/dist/core/agent-session-post-tool-compaction.d.ts.map +1 -0
- package/dist/core/agent-session-post-tool-compaction.js +113 -0
- package/dist/core/agent-session-post-tool-compaction.js.map +1 -0
- package/dist/core/agent-session-prompt.d.ts +12 -1
- package/dist/core/agent-session-prompt.d.ts.map +1 -1
- package/dist/core/agent-session-prompt.js +22 -5
- package/dist/core/agent-session-prompt.js.map +1 -1
- package/dist/core/agent-session-runtime.d.ts.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -0
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
- package/dist/core/agent-session-tool-hooks.js +21 -0
- package/dist/core/agent-session-tool-hooks.js.map +1 -1
- package/dist/core/agent-session-tree.d.ts.map +1 -1
- package/dist/core/agent-session-tree.js +2 -1
- package/dist/core/agent-session-tree.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +7 -0
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +6 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +18 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/async/job-manager.d.ts +1 -0
- package/dist/core/async/job-manager.d.ts.map +1 -1
- package/dist/core/async/job-manager.js +29 -5
- package/dist/core/async/job-manager.js.map +1 -1
- package/dist/core/async/session-manager.d.ts +2 -4
- package/dist/core/async/session-manager.d.ts.map +1 -1
- package/dist/core/async/session-manager.js +5 -32
- package/dist/core/async/session-manager.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +2 -0
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/auth-storage.d.ts +20 -10
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +151 -92
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/callback-activity.d.ts +27 -0
- package/dist/core/callback-activity.d.ts.map +1 -0
- package/dist/core/callback-activity.js +44 -0
- package/dist/core/callback-activity.js.map +1 -0
- package/dist/core/compaction/branch-summarization.d.ts +4 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +4 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts +1 -1
- package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
- package/dist/core/compaction/compaction-boundary.js +10 -23
- package/dist/core/compaction/compaction-boundary.js.map +1 -1
- package/dist/core/compaction/compaction-runner.d.ts +4 -1
- package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
- package/dist/core/compaction/compaction-runner.js +1 -1
- package/dist/core/compaction/compaction-runner.js.map +1 -1
- package/dist/core/compaction/compaction-types.d.ts +3 -2
- package/dist/core/compaction/compaction-types.d.ts.map +1 -1
- package/dist/core/compaction/compaction-types.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +6 -6
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +12 -9
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/compaction/range-planner-diagnostics.d.ts +101 -0
- package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -0
- package/dist/core/compaction/range-planner-diagnostics.js +116 -0
- package/dist/core/compaction/range-planner-diagnostics.js.map +1 -0
- package/dist/core/compaction/range-planner.d.ts +13 -3
- package/dist/core/compaction/range-planner.d.ts.map +1 -1
- package/dist/core/compaction/range-planner.js +117 -68
- package/dist/core/compaction/range-planner.js.map +1 -1
- package/dist/core/compaction/truncated-range-recovery.d.ts +47 -0
- package/dist/core/compaction/truncated-range-recovery.d.ts.map +1 -0
- package/dist/core/compaction/truncated-range-recovery.js +112 -0
- package/dist/core/compaction/truncated-range-recovery.js.map +1 -0
- package/dist/core/extensions/api-types.d.ts +2 -2
- package/dist/core/extensions/api-types.d.ts.map +1 -1
- package/dist/core/extensions/api-types.js.map +1 -1
- package/dist/core/extensions/context-types.d.ts +23 -1
- 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/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader-api.js +2 -2
- package/dist/core/extensions/loader-api.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +8 -1
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +9 -6
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/message-types.d.ts +17 -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 +3 -0
- 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-events.d.ts.map +1 -1
- package/dist/core/extensions/runner-events.js +11 -10
- package/dist/core/extensions/runner-events.js.map +1 -1
- package/dist/core/extensions/runtime-types.d.ts +2 -2
- package/dist/core/extensions/runtime-types.d.ts.map +1 -1
- package/dist/core/extensions/runtime-types.js.map +1 -1
- package/dist/core/extensions/ui-types.d.ts +78 -0
- package/dist/core/extensions/ui-types.d.ts.map +1 -1
- package/dist/core/extensions/ui-types.js.map +1 -1
- package/dist/core/model-registry-auth.d.ts +2 -1
- package/dist/core/model-registry-auth.d.ts.map +1 -1
- package/dist/core/model-registry-auth.js +25 -6
- package/dist/core/model-registry-auth.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts +3 -2
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +12 -6
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-dynamic.d.ts +1 -0
- package/dist/core/model-registry-dynamic.d.ts.map +1 -1
- package/dist/core/model-registry-dynamic.js +53 -13
- package/dist/core/model-registry-dynamic.js.map +1 -1
- package/dist/core/model-registry-loader.d.ts +2 -1
- package/dist/core/model-registry-loader.d.ts.map +1 -1
- package/dist/core/model-registry-loader.js +2 -2
- package/dist/core/model-registry-loader.js.map +1 -1
- package/dist/core/model-registry-types.d.ts +10 -3
- package/dist/core/model-registry-types.d.ts.map +1 -1
- package/dist/core/model-registry-types.js.map +1 -1
- package/dist/core/model-registry.d.ts +15 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +214 -30
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/models-store.d.ts +25 -0
- package/dist/core/models-store.d.ts.map +1 -0
- package/dist/core/models-store.js +73 -0
- package/dist/core/models-store.js.map +1 -0
- package/dist/core/oauth-compat.d.ts +17 -0
- package/dist/core/oauth-compat.d.ts.map +1 -0
- package/dist/core/oauth-compat.js +2 -0
- package/dist/core/oauth-compat.js.map +1 -0
- package/dist/core/oauth-provider-bridge.d.ts +40 -0
- package/dist/core/oauth-provider-bridge.d.ts.map +1 -0
- package/dist/core/oauth-provider-bridge.js +169 -0
- package/dist/core/oauth-provider-bridge.js.map +1 -0
- package/dist/core/output-guard.d.ts +2 -0
- package/dist/core/output-guard.d.ts.map +1 -1
- package/dist/core/output-guard.js +14 -0
- package/dist/core/output-guard.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/core/remote-catalog-provider.d.ts.map +1 -0
- package/dist/core/remote-catalog-provider.js +138 -0
- package/dist/core/remote-catalog-provider.js.map +1 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +8 -3
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-core.d.ts +1 -1
- package/dist/core/session-manager-core.d.ts.map +1 -1
- package/dist/core/session-manager-core.js +1 -1
- package/dist/core/session-manager-core.js.map +1 -1
- package/dist/core/session-manager-entries.d.ts +1 -1
- package/dist/core/session-manager-entries.d.ts.map +1 -1
- package/dist/core/session-manager-entries.js.map +1 -1
- package/dist/core/session-manager-history.d.ts +2 -2
- package/dist/core/session-manager-history.js +2 -2
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/session-manager-list.d.ts.map +1 -1
- package/dist/core/session-manager-list.js +65 -23
- package/dist/core/session-manager-list.js.map +1 -1
- package/dist/core/session-manager-types.d.ts +3 -2
- package/dist/core/session-manager-types.d.ts.map +1 -1
- package/dist/core/session-manager-types.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +9 -5
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -3
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.js +2 -2
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.js +2 -2
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.js +2 -2
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -3
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/todos-render.d.ts.map +1 -1
- package/dist/core/tools/todos-render.js +3 -2
- package/dist/core/tools/todos-render.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js +3 -2
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.js +2 -2
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/workflow-stage-admission.d.ts +29 -0
- package/dist/core/workflow-stage-admission.d.ts.map +1 -0
- package/dist/core/workflow-stage-admission.js +81 -0
- package/dist/core/workflow-stage-admission.js.map +1 -0
- package/dist/index-extensions.d.ts +1 -1
- package/dist/index-extensions.d.ts.map +1 -1
- package/dist/index-extensions.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main-types.d.ts +13 -0
- package/dist/main-types.d.ts.map +1 -0
- package/dist/main-types.js +2 -0
- package/dist/main-types.js.map +1 -0
- package/dist/main.d.ts +2 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +25 -17
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +17 -12
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.d.ts +7 -0
- package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
- package/dist/modes/interactive/components/atomic-banner.js +20 -0
- package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +5 -3
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/branch-summary-message.js +3 -4
- package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.d.ts +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-message-renderer.js +4 -0
- package/dist/modes/interactive/components/chat-message-renderer.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 +79 -8
- 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 +4 -2
- package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts +1 -0
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +4 -1
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/compaction-boundary-message.js +3 -4
- package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
- package/dist/modes/interactive/components/host-input-form-mount.d.ts +14 -0
- package/dist/modes/interactive/components/host-input-form-mount.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form-mount.js +79 -0
- package/dist/modes/interactive/components/host-input-form-mount.js.map +1 -0
- package/dist/modes/interactive/components/host-input-form.d.ts +52 -0
- package/dist/modes/interactive/components/host-input-form.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-input-form.js +278 -0
- package/dist/modes/interactive/components/host-input-form.js.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts +46 -0
- package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive/components/host-session-picker.js +183 -0
- package/dist/modes/interactive/components/host-session-picker.js.map +1 -0
- 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 +1 -1
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +2 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +3 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +8 -2
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +7 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +57 -10
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +15 -0
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +35 -3
- package/dist/modes/interactive/components/session-selector.js.map +1 -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.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +9 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-agent-events.js +24 -10
- package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-login.js +7 -1
- package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
- package/dist/modes/interactive/interactive-auth-routing.js +3 -3
- package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-autocomplete.js +49 -0
- package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
- package/dist/modes/interactive/interactive-bash-compact.js +2 -0
- package/dist/modes/interactive/interactive-bash-compact.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-context.js +14 -0
- package/dist/modes/interactive/interactive-extension-context.js.map +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js +1 -1
- package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
- package/dist/modes/interactive/interactive-global-clear.d.ts +13 -0
- package/dist/modes/interactive/interactive-global-clear.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-global-clear.js +11 -0
- package/dist/modes/interactive/interactive-global-clear.js.map +1 -0
- package/dist/modes/interactive/interactive-input-handling.js +17 -10
- package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-base.js +25 -2
- package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-deps.d.ts +4 -3
- 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-helpers.d.ts +4 -1
- package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-helpers.js +14 -1
- package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -2
- package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.d.ts +3 -0
- package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
- package/dist/modes/interactive/interactive-model-routing.js +7 -4
- package/dist/modes/interactive/interactive-model-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-queueing.js +2 -2
- package/dist/modes/interactive/interactive-queueing.js.map +1 -1
- package/dist/modes/interactive/interactive-render-chat.js +25 -4
- package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
- package/dist/modes/interactive/interactive-session-routing.js +3 -0
- package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
- package/dist/modes/interactive/interactive-slash-commands.js +5 -2
- package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts +1 -1
- package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-startup.js +22 -9
- package/dist/modes/interactive/interactive-startup.js.map +1 -1
- package/dist/modes/interactive/interactive-terminal-title.d.ts +6 -0
- package/dist/modes/interactive/interactive-terminal-title.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-terminal-title.js +7 -0
- package/dist/modes/interactive/interactive-terminal-title.js.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts +45 -0
- package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/activity-watchdog.js +74 -0
- package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts +14 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js +56 -0
- package/dist/modes/interactive-engine/create-isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/engine-args.d.ts +10 -0
- package/dist/modes/interactive-engine/engine-args.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-args.js +55 -0
- package/dist/modes/interactive-engine/engine-args.js.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts +7 -0
- package/dist/modes/interactive-engine/engine-child-liveness.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js +50 -0
- package/dist/modes/interactive-engine/engine-child-liveness.js.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts +47 -0
- package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js +276 -0
- package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts +13 -0
- package/dist/modes/interactive-engine/engine-input-form.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-input-form.js +49 -0
- package/dist/modes/interactive-engine/engine-input-form.js.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts +18 -0
- package/dist/modes/interactive-engine/engine-monitor.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-monitor.js +63 -0
- package/dist/modes/interactive-engine/engine-monitor.js.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts +17 -0
- package/dist/modes/interactive-engine/engine-render-service.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-render-service.js +150 -0
- package/dist/modes/interactive-engine/engine-render-service.js.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts +22 -0
- package/dist/modes/interactive-engine/engine-session-picker.d.ts.map +1 -0
- package/dist/modes/interactive-engine/engine-session-picker.js +106 -0
- package/dist/modes/interactive-engine/engine-session-picker.js.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +23 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js +126 -0
- package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts +15 -0
- package/dist/modes/interactive-engine/input-form-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/input-form-host.js +44 -0
- package/dist/modes/interactive-engine/input-form-host.js.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts +75 -0
- package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -0
- package/dist/modes/interactive-engine/isolated-runtime.js +448 -0
- package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -0
- package/dist/modes/interactive-engine/protocol.d.ts +184 -0
- package/dist/modes/interactive-engine/protocol.d.ts.map +1 -0
- package/dist/modes/interactive-engine/protocol.js +254 -0
- package/dist/modes/interactive-engine/protocol.js.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts +33 -0
- package/dist/modes/interactive-engine/remote-command-catalog.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js +51 -0
- package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -0
- package/dist/modes/interactive-engine/remote-component.d.ts +16 -0
- package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-component.js +209 -0
- package/dist/modes/interactive-engine/remote-component.js.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts +25 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js +43 -0
- package/dist/modes/interactive-engine/remote-frame-clamp.js.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts +59 -0
- package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -0
- package/dist/modes/interactive-engine/remote-renderer.js +123 -0
- package/dist/modes/interactive-engine/remote-renderer.js.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts +25 -0
- package/dist/modes/interactive-engine/session-picker-host.d.ts.map +1 -0
- package/dist/modes/interactive-engine/session-picker-host.js +75 -0
- package/dist/modes/interactive-engine/session-picker-host.js.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts +43 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.d.ts.map +1 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js +109 -0
- package/dist/modes/interactive-engine/terminal-mode-controller.js.map +1 -0
- package/dist/modes/rpc/bounded-writer.d.ts +27 -0
- package/dist/modes/rpc/bounded-writer.d.ts.map +1 -0
- package/dist/modes/rpc/bounded-writer.js +103 -0
- package/dist/modes/rpc/bounded-writer.js.map +1 -0
- package/dist/modes/rpc/jsonl.d.ts +15 -12
- package/dist/modes/rpc/jsonl.d.ts.map +1 -1
- package/dist/modes/rpc/jsonl.js +102 -28
- package/dist/modes/rpc/jsonl.js.map +1 -1
- package/dist/modes/rpc/rpc-client-api.d.ts +83 -0
- package/dist/modes/rpc/rpc-client-api.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-api.js +64 -0
- package/dist/modes/rpc/rpc-client-api.js.map +1 -0
- package/dist/modes/rpc/rpc-client-process.d.ts +19 -0
- package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-process.js +79 -0
- package/dist/modes/rpc/rpc-client-process.js.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts +8 -0
- package/dist/modes/rpc/rpc-client-waits.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-client-waits.js +33 -0
- package/dist/modes/rpc/rpc-client-waits.js.map +1 -0
- package/dist/modes/rpc/rpc-client.d.ts +48 -124
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +295 -249
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts +5 -1
- package/dist/modes/rpc/rpc-command-handler.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-command-handler.js +79 -3
- package/dist/modes/rpc/rpc-command-handler.js.map +1 -1
- package/dist/modes/rpc/rpc-event-buffer.d.ts +11 -0
- package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-event-buffer.js +30 -0
- package/dist/modes/rpc/rpc-event-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-extension-ui.d.ts +7 -1
- package/dist/modes/rpc/rpc-extension-ui.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-extension-ui.js +54 -32
- package/dist/modes/rpc/rpc-extension-ui.js.map +1 -1
- package/dist/modes/rpc/rpc-input-scheduler.d.ts +16 -0
- package/dist/modes/rpc/rpc-input-scheduler.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-input-scheduler.js +69 -0
- package/dist/modes/rpc/rpc-input-scheduler.js.map +1 -0
- package/dist/modes/rpc/rpc-input.d.ts +2 -1
- package/dist/modes/rpc/rpc-input.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-input.js +4 -9
- package/dist/modes/rpc/rpc-input.js.map +1 -1
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts +27 -0
- package/dist/modes/rpc/rpc-keybindings-reload.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js +69 -0
- package/dist/modes/rpc/rpc-keybindings-reload.js.map +1 -0
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +63 -8
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-output-buffer.d.ts +10 -0
- package/dist/modes/rpc/rpc-output-buffer.d.ts.map +1 -0
- package/dist/modes/rpc/rpc-output-buffer.js +70 -0
- package/dist/modes/rpc/rpc-output-buffer.js.map +1 -0
- package/dist/modes/rpc/rpc-session-binding.d.ts +16 -1
- package/dist/modes/rpc/rpc-session-binding.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-session-binding.js +16 -3
- package/dist/modes/rpc/rpc-session-binding.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +109 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli-parser.d.ts +2 -0
- package/dist/package-manager-cli-parser.d.ts.map +1 -1
- package/dist/package-manager-cli-parser.js +24 -5
- package/dist/package-manager-cli-parser.js.map +1 -1
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +65 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +46 -0
- package/dist/utils/shell.js.map +1 -1
- package/docs/changelog.mdx +11 -0
- package/docs/compaction.md +53 -17
- package/docs/custom-provider.md +24 -5
- package/docs/development.md +9 -7
- package/docs/docs.json +1 -0
- package/docs/extensions.md +30 -16
- package/docs/intercom.md +489 -0
- package/docs/json.md +1 -1
- package/docs/keybindings.md +1 -1
- package/docs/packages.md +1 -0
- package/docs/quickstart.md +11 -5
- package/docs/rpc.md +9 -7
- package/docs/sdk.md +6 -0
- package/docs/session-format.md +7 -6
- package/docs/sessions.md +4 -2
- package/docs/settings.md +2 -2
- package/docs/subagents.md +7 -2
- package/docs/tui.md +61 -2
- package/docs/usage.md +6 -5
- package/docs/workflows.md +2572 -1379
- package/examples/extensions/handoff.ts +1 -1
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/summarize.ts +1 -1
- package/npm-shrinkwrap.json +225 -76
- package/package.json +7 -6
- package/dist/builtin/workflows/src/durable/file-backend.ts +0 -439
- package/dist/builtin/workflows/src/durable/file-lock.ts +0 -153
- package/dist/builtin/workflows/src/durable/file-state.ts +0 -104
- package/dist/builtin/workflows/src/extension/runtime-direct.ts +0 -96
- package/dist/builtin/workflows/src/extension/workflow-tool-helpers.ts +0 -66
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-output.ts +0 -91
- package/dist/builtin/workflows/src/runs/foreground/executor-direct.ts +0 -282
- package/dist/builtin/workflows/src/shared/resumable-workflow-notices.ts +0 -43
- package/dist/builtin/workflows/src/tui/session-confirm.ts +0 -299
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import type { ExtensionContext } from "@bastani/atomic";
|
|
21
21
|
import type { SubagentExecutorRuntimeDeps, TaskParam } from "./subagent-executor-types.ts";
|
|
22
22
|
import { resolveParallelTaskCwd } from "./subagent-executor-worktree.ts";
|
|
23
|
+
import { inheritedIntercomGroup, resolveChildIntercomGroup } from "../shared/intercom-group.ts";
|
|
23
24
|
|
|
24
25
|
interface ForegroundParallelRunInput {
|
|
25
26
|
tasks: TaskParam[];
|
|
@@ -47,6 +48,8 @@ interface ForegroundParallelRunInput {
|
|
|
47
48
|
onControlEvent?: (event: ControlEvent) => void;
|
|
48
49
|
childIntercomTarget?: (agent: string, index: number) => string | undefined;
|
|
49
50
|
orchestratorIntercomTarget?: string;
|
|
51
|
+
setIntercomGroup?: string | true;
|
|
52
|
+
sharedAutoIntercomGroup?: string;
|
|
50
53
|
foregroundControl?: SubagentState["foregroundControls"] extends Map<string, infer T> ? T : never;
|
|
51
54
|
concurrencyLimit: number;
|
|
52
55
|
liveResults: (SingleResult | undefined)[];
|
|
@@ -58,7 +61,18 @@ interface ForegroundParallelRunInput {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
export async function runForegroundParallelTasks(input: ForegroundParallelRunInput): Promise<SingleResult[]> {
|
|
64
|
+
const intercomDetachController = new AbortController();
|
|
61
65
|
return mapConcurrent(input.tasks, input.concurrencyLimit, async (task, index) => {
|
|
66
|
+
if (intercomDetachController.signal.aborted) {
|
|
67
|
+
return {
|
|
68
|
+
agent: task.agent,
|
|
69
|
+
task: input.taskTexts[index] ?? task.task,
|
|
70
|
+
exitCode: -1,
|
|
71
|
+
messages: [],
|
|
72
|
+
usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, cost: 0, turns: 0 },
|
|
73
|
+
error: "Skipped after foreground group detached for intercom coordination",
|
|
74
|
+
};
|
|
75
|
+
}
|
|
62
76
|
const behavior = input.behaviors[index];
|
|
63
77
|
const effectiveSkills = behavior?.skills;
|
|
64
78
|
const taskCwd = resolveParallelTaskCwd(task, input.paramsCwd, input.worktreeSetup, index);
|
|
@@ -111,7 +125,14 @@ export async function runForegroundParallelTasks(input: ForegroundParallelRunInp
|
|
|
111
125
|
onControlEvent: input.onControlEvent,
|
|
112
126
|
intercomSessionName: input.childIntercomTarget?.(task.agent, index),
|
|
113
127
|
orchestratorIntercomTarget: input.orchestratorIntercomTarget,
|
|
128
|
+
intercomGroup: resolveChildIntercomGroup(
|
|
129
|
+
task.group ?? input.setIntercomGroup,
|
|
130
|
+
inheritedIntercomGroup(input.ctx),
|
|
131
|
+
input.sharedAutoIntercomGroup,
|
|
132
|
+
),
|
|
114
133
|
onDetachedExit: (result) => input.onDetachedExit?.(index, result),
|
|
134
|
+
intercomDetachSignal: intercomDetachController.signal,
|
|
135
|
+
onIntercomDetachCommit: () => intercomDetachController.abort(),
|
|
115
136
|
nestedRoute: input.foregroundControl?.nestedRoute,
|
|
116
137
|
modelOverride: input.modelOverrides[index],
|
|
117
138
|
availableModels: input.availableModels,
|
|
@@ -2,6 +2,7 @@ import { resolveModelCandidate } from "../shared/model-fallback.ts";
|
|
|
2
2
|
import { collectKnownModelProviders, toModelInfo, type ModelInfo } from "../../shared/model-info.ts";
|
|
3
3
|
import { normalizeSkillInput } from "../../agents/skills.ts";
|
|
4
4
|
import { aggregateParallelOutputs } from "../shared/parallel-utils.ts";
|
|
5
|
+
import { sharedAutoGroupForSet } from "../shared/intercom-group.ts";
|
|
5
6
|
import { recordRun } from "../shared/run-history.ts";
|
|
6
7
|
import {
|
|
7
8
|
resolveStepBehavior,
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
resolveParallelTaskCwd,
|
|
44
45
|
} from "./subagent-executor-worktree.ts";
|
|
45
46
|
import { createForegroundControlNotifier, maybeBuildForegroundIntercomReceipt, rememberForegroundRun, replaceForegroundRunChild } from "./subagent-executor-status.ts";
|
|
47
|
+
import { createDetachedCleanupBarrier } from "./detached-cleanup-barrier.ts";
|
|
46
48
|
|
|
47
49
|
export async function runParallelPath(data: ExecutionContextData, deps: ResolvedExecutorDeps): Promise<SubagentToolResult> {
|
|
48
50
|
const {
|
|
@@ -132,6 +134,12 @@ export async function runParallelPath(data: ExecutionContextData, deps: Resolved
|
|
|
132
134
|
deps.config.worktreeSetupHook,
|
|
133
135
|
deps.config.worktreeSetupHookTimeoutMs,
|
|
134
136
|
);
|
|
137
|
+
let worktreeCleanupDeferred = false;
|
|
138
|
+
const detachedCleanup = createDetachedCleanupBarrier(() => {
|
|
139
|
+
if (!worktreeSetup) return;
|
|
140
|
+
buildParallelWorktreeSuffix(worktreeSetup, artifactsDir, tasks as TaskParam[]);
|
|
141
|
+
cleanupWorktrees(worktreeSetup);
|
|
142
|
+
});
|
|
135
143
|
if (errorResult) return errorResult;
|
|
136
144
|
|
|
137
145
|
try {
|
|
@@ -160,7 +168,13 @@ export async function runParallelPath(data: ExecutionContextData, deps: Resolved
|
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
const results = await runForegroundParallelTasks({
|
|
163
|
-
onDetachedExit: (index, result) =>
|
|
171
|
+
onDetachedExit: (index, result) => {
|
|
172
|
+
try {
|
|
173
|
+
replaceForegroundRunChild(deps.state, runId, index, result);
|
|
174
|
+
} finally {
|
|
175
|
+
detachedCleanup.recover(index);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
164
178
|
tasks,
|
|
165
179
|
taskTexts,
|
|
166
180
|
agents,
|
|
@@ -185,6 +199,8 @@ export async function runParallelPath(data: ExecutionContextData, deps: Resolved
|
|
|
185
199
|
onControlEvent,
|
|
186
200
|
childIntercomTarget: childIntercomTarget ? (agent, index) => childIntercomTarget(runId, agent, index) : undefined,
|
|
187
201
|
orchestratorIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
|
|
202
|
+
setIntercomGroup: params.group,
|
|
203
|
+
sharedAutoIntercomGroup: sharedAutoGroupForSet(params.group, tasks),
|
|
188
204
|
foregroundControl,
|
|
189
205
|
concurrencyLimit: parallelConcurrency,
|
|
190
206
|
maxSubagentDepths,
|
|
@@ -221,6 +237,9 @@ export async function runParallelPath(data: ExecutionContextData, deps: Resolved
|
|
|
221
237
|
}
|
|
222
238
|
const detachedIndex = results.findIndex((result) => result.detached);
|
|
223
239
|
const detached = detachedIndex >= 0 ? results[detachedIndex] : undefined;
|
|
240
|
+
worktreeCleanupDeferred = detachedCleanup.defer(
|
|
241
|
+
results.flatMap((result, index) => result.detached ? [index] : []),
|
|
242
|
+
);
|
|
224
243
|
if (detached) {
|
|
225
244
|
return {
|
|
226
245
|
content: [{ type: "text", text: `Parallel run detached for intercom coordination (${detached.agent}). Reply to the supervisor request first. After the child exits, start a fresh follow-up if needed.` }],
|
|
@@ -266,6 +285,6 @@ export async function runParallelPath(data: ExecutionContextData, deps: Resolved
|
|
|
266
285
|
details,
|
|
267
286
|
};
|
|
268
287
|
} finally {
|
|
269
|
-
if (worktreeSetup) cleanupWorktrees(worktreeSetup);
|
|
288
|
+
if (worktreeSetup && !worktreeCleanupDeferred) cleanupWorktrees(worktreeSetup);
|
|
270
289
|
}
|
|
271
290
|
}
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
resolveIntercomSessionTarget,
|
|
26
26
|
resolveSubagentIntercomTarget,
|
|
27
27
|
} from "../../intercom/intercom-bridge.ts";
|
|
28
|
+
import { requestSupervisorAuthorization } from "../../intercom/supervisor-authorization.ts";
|
|
28
29
|
import { resolveCurrentSessionId } from "../../shared/session-identity.ts";
|
|
29
30
|
import { resolveExecutionAgentScope } from "../../agents/agent-scope.ts";
|
|
30
31
|
import {
|
|
@@ -415,6 +416,10 @@ export async function resumeAsyncRun(input: {
|
|
|
415
416
|
}
|
|
416
417
|
|
|
417
418
|
const runId = randomUUID().slice(0, 8);
|
|
419
|
+
const revivedTarget = intercomBridge.active
|
|
420
|
+
? resolveSubagentIntercomTarget(runId, target.agent, 0)
|
|
421
|
+
: undefined;
|
|
422
|
+
const supervisorAuthorization = await requestSupervisorAuthorization(input.deps.pi.events, revivedTarget);
|
|
418
423
|
const artifactConfig: ArtifactConfig = { ...DEFAULT_ARTIFACT_CONFIG, enabled: input.params.artifacts !== false };
|
|
419
424
|
const availableModels = input.ctx.modelRegistry.getAvailable().map(toModelInfo);
|
|
420
425
|
const result = input.deps.runtime.executeAsyncSingle(runId, {
|
|
@@ -444,12 +449,12 @@ export async function resumeAsyncRun(input: {
|
|
|
444
449
|
controlConfig: resolveControlConfig(input.deps.config.control, input.params.control),
|
|
445
450
|
controlIntercomTarget: intercomBridge.active ? intercomBridge.orchestratorTarget : undefined,
|
|
446
451
|
childIntercomTarget: intercomBridge.active ? (agent, index) => resolveSubagentIntercomTarget(runId, agent, index) : undefined,
|
|
452
|
+
supervisorAuthorization,
|
|
447
453
|
availableModels,
|
|
448
454
|
});
|
|
449
455
|
if (result.isError) return result;
|
|
450
456
|
|
|
451
457
|
const revivedId = result.details.asyncId ?? runId;
|
|
452
|
-
const revivedTarget = intercomBridge.active ? resolveSubagentIntercomTarget(revivedId, target.agent, 0) : undefined;
|
|
453
458
|
const sourceLabel = target.source;
|
|
454
459
|
const lines = [
|
|
455
460
|
`Revived ${sourceLabel} subagent from ${target.runId}.`,
|
|
@@ -7,6 +7,7 @@ import { injectSingleProgressInstruction, resolveSingleProgress, writeInitialPro
|
|
|
7
7
|
import { recordRun } from "../shared/run-history.ts";
|
|
8
8
|
import { getSingleResultOutput, compactForegroundDetails } from "../../shared/utils.ts";
|
|
9
9
|
import { updateForegroundNestedProjection } from "../shared/nested-events.ts";
|
|
10
|
+
import { inheritedIntercomGroup, resolveChildIntercomGroup } from "../shared/intercom-group.ts";
|
|
10
11
|
import {
|
|
11
12
|
INTERCOM_BRIDGE_MARKER,
|
|
12
13
|
resolveSubagentIntercomTarget,
|
|
@@ -186,6 +187,7 @@ export async function runSinglePath(data: ExecutionContextData, deps: ResolvedEx
|
|
|
186
187
|
onControlEvent,
|
|
187
188
|
intercomSessionName: childIntercomTarget,
|
|
188
189
|
orchestratorIntercomTarget: data.intercomBridge.active ? data.intercomBridge.orchestratorTarget : undefined,
|
|
190
|
+
intercomGroup: resolveChildIntercomGroup(params.group, inheritedIntercomGroup(ctx), undefined),
|
|
189
191
|
nestedRoute: foregroundControl?.nestedRoute,
|
|
190
192
|
onDetachedExit: (result) => {
|
|
191
193
|
cleanupTransientProgress(progressDir, artifactConfig.enabled);
|
|
@@ -18,6 +18,7 @@ export interface TaskParam {
|
|
|
18
18
|
progress?: boolean;
|
|
19
19
|
model?: string;
|
|
20
20
|
skill?: string | string[] | boolean;
|
|
21
|
+
group?: string | true;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export interface SubagentParamsLike {
|
|
@@ -46,6 +47,7 @@ export interface SubagentParamsLike {
|
|
|
46
47
|
includeProgress?: boolean;
|
|
47
48
|
model?: string;
|
|
48
49
|
skill?: string | string[] | boolean;
|
|
50
|
+
group?: string | true;
|
|
49
51
|
output?: string | boolean;
|
|
50
52
|
outputMode?: "inline" | "file-only";
|
|
51
53
|
reads?: string[] | false;
|
|
@@ -227,7 +227,7 @@ export function createSubagentExecutor(rawDeps: ExecutorDeps): {
|
|
|
227
227
|
const prepared = built.prepared!;
|
|
228
228
|
let nestedForegroundStarted = false;
|
|
229
229
|
try {
|
|
230
|
-
const asyncResult = runAsyncPath(prepared.execData, deps);
|
|
230
|
+
const asyncResult = await runAsyncPath(prepared.execData, deps);
|
|
231
231
|
if (asyncResult) return withForkContext(asyncResult, prepared.effectiveParams.context);
|
|
232
232
|
if (prepared.foregroundControl) {
|
|
233
233
|
prepared.writeNestedForegroundEvent("subagent.nested.started");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
interface OrchestrationCarrier {
|
|
4
|
+
orchestrationContext?: { intercomGroup?: string } | undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** Normalize agent-serialized auto-group sentinels without changing real group names. */
|
|
8
|
+
export function normalizeAutoGroupSentinel(group: string | true | undefined): string | true | undefined {
|
|
9
|
+
if (group === undefined || group === true) return group;
|
|
10
|
+
const sentinel = group.trim().toLowerCase();
|
|
11
|
+
return sentinel === "true" || sentinel === "auto" ? true : group;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Read the inherited stage/session intercom group from the extension context (never from process.env). */
|
|
15
|
+
export function inheritedIntercomGroup(ctx: OrchestrationCarrier | undefined): string | undefined {
|
|
16
|
+
const group = ctx?.orchestrationContext?.intercomGroup;
|
|
17
|
+
return typeof group === "string" && group.trim().length > 0 ? group.trim() : undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolve the intercom group for a spawned subagent child. Precedence:
|
|
22
|
+
* explicit task/parallel/chain group > inherited current-session (stage) group.
|
|
23
|
+
* `true` resolves to `sharedAutoGroup` (a single UUID minted once per parallel
|
|
24
|
+
* set) so every child in the set shares one isolated group. Returns undefined
|
|
25
|
+
* when nothing applies, so the child inherits env/config/default itself.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveChildIntercomGroup(
|
|
28
|
+
explicit: string | true | undefined,
|
|
29
|
+
inherited: string | undefined,
|
|
30
|
+
sharedAutoGroup: string | undefined,
|
|
31
|
+
): string | undefined {
|
|
32
|
+
const normalized = normalizeAutoGroupSentinel(explicit);
|
|
33
|
+
if (normalized === true) return sharedAutoGroup ?? randomUUID();
|
|
34
|
+
if (typeof normalized === "string" && normalized.trim().length > 0) return normalized.trim();
|
|
35
|
+
return inherited;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Mint one shared auto-group UUID for a set when the set-level group or any item
|
|
40
|
+
* requested `true`; otherwise undefined. Ensures all `true` items in one parallel
|
|
41
|
+
* set land in the SAME group.
|
|
42
|
+
*/
|
|
43
|
+
export function sharedAutoGroupForSet(
|
|
44
|
+
setGroup: string | true | undefined,
|
|
45
|
+
items: ReadonlyArray<{ group?: string | true }>,
|
|
46
|
+
): string | undefined {
|
|
47
|
+
const needsAuto = normalizeAutoGroupSentinel(setGroup) === true
|
|
48
|
+
|| items.some((item) => normalizeAutoGroupSentinel(item.group) === true);
|
|
49
|
+
return needsAuto ? randomUUID() : undefined;
|
|
50
|
+
}
|
|
@@ -40,6 +40,10 @@ export const SUBAGENT_PARENT_CAPABILITY_TOKEN_ENV = `${ENV_PREFIX}_SUBAGENT_PARE
|
|
|
40
40
|
export const SUBAGENT_INHERIT_PROJECT_CONTEXT_ENV = `${ENV_PREFIX}_SUBAGENT_INHERIT_PROJECT_CONTEXT`;
|
|
41
41
|
export const SUBAGENT_INHERIT_SKILLS_ENV = `${ENV_PREFIX}_SUBAGENT_INHERIT_SKILLS`;
|
|
42
42
|
export const SUBAGENT_INTERCOM_SESSION_NAME_ENV = `${ENV_PREFIX}_SUBAGENT_INTERCOM_SESSION_NAME`;
|
|
43
|
+
export const SUBAGENT_SUPERVISOR_CAPABILITY_ENV = `${ENV_PREFIX}_SUBAGENT_SUPERVISOR_CAPABILITY`;
|
|
44
|
+
export const SUBAGENT_SUPERVISOR_SESSION_ID_ENV = `${ENV_PREFIX}_SUBAGENT_SUPERVISOR_SESSION_ID`;
|
|
45
|
+
/** Intercom home-group env key (not a _SUBAGENT_ key); resolves ATOMIC_/PI_ variants. */
|
|
46
|
+
export const INTERCOM_GROUP_ENV = `${ENV_PREFIX}_INTERCOM_GROUP`;
|
|
43
47
|
const STRUCTURED_OUTPUT_TOOL_NAME = "structured_output";
|
|
44
48
|
|
|
45
49
|
interface BuildPiArgsInput {
|
|
@@ -61,6 +65,8 @@ interface BuildPiArgsInput {
|
|
|
61
65
|
promptFileStem?: string;
|
|
62
66
|
intercomSessionName?: string;
|
|
63
67
|
orchestratorIntercomTarget?: string;
|
|
68
|
+
intercomGroup?: string;
|
|
69
|
+
supervisorAuthorization?: { capability: string; supervisorSessionId: string };
|
|
64
70
|
runId?: string;
|
|
65
71
|
childAgentName?: string;
|
|
66
72
|
childIndex?: number;
|
|
@@ -262,6 +268,16 @@ export function buildPiArgs(input: BuildPiArgsInput): BuildPiArgsResult {
|
|
|
262
268
|
if (input.orchestratorIntercomTarget) {
|
|
263
269
|
env[SUBAGENT_ORCHESTRATOR_TARGET_ENV] = input.orchestratorIntercomTarget;
|
|
264
270
|
}
|
|
271
|
+
// Always override inherited capability metadata: a child must never pass its
|
|
272
|
+
// own supervisor authority to a descendant that lacks a freshly issued grant.
|
|
273
|
+
env[SUBAGENT_SUPERVISOR_CAPABILITY_ENV] = input.supervisorAuthorization?.capability ?? "";
|
|
274
|
+
env[SUBAGENT_SUPERVISOR_SESSION_ID_ENV] = input.supervisorAuthorization?.supervisorSessionId ?? "";
|
|
275
|
+
// Only assign an intercom group when the child actually has intercom access
|
|
276
|
+
// (peer intercom session name OR contact_supervisor orchestrator target).
|
|
277
|
+
const hasIntercomAccess = Boolean(input.intercomSessionName || input.orchestratorIntercomTarget);
|
|
278
|
+
if (input.intercomGroup && hasIntercomAccess) {
|
|
279
|
+
env[INTERCOM_GROUP_ENV] = input.intercomGroup;
|
|
280
|
+
}
|
|
265
281
|
if (input.runId) {
|
|
266
282
|
env[SUBAGENT_RUN_ID_ENV] = input.runId;
|
|
267
283
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
export interface WorktreeGitResult { stdout: string; stderr: string; status: number | null }
|
|
5
|
+
export type WorktreeGitRunner = (cwd: string, args: string[]) => WorktreeGitResult;
|
|
6
|
+
|
|
7
|
+
function tracked(runGit: WorktreeGitRunner, repo: string, relativePath: string): boolean {
|
|
8
|
+
return runGit(repo, ["ls-files", "--error-unmatch", "--", relativePath]).status === 0;
|
|
9
|
+
}
|
|
10
|
+
function hasTrackedPathComponent(runGit: WorktreeGitRunner, repo: string, relativePath: string): boolean {
|
|
11
|
+
const components = relativePath.split(/[\\/]+/).filter(Boolean);
|
|
12
|
+
let candidate = "";
|
|
13
|
+
for (const component of components) {
|
|
14
|
+
candidate = candidate ? `${candidate}/${component}` : component;
|
|
15
|
+
const result = runGit(repo, ["ls-files", "--stage", "--", candidate]);
|
|
16
|
+
if (result.stdout.split(/\r?\n/).some((line) => line.slice(line.indexOf("\t") + 1) === candidate)) return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
function copySettings(runGit: WorktreeGitRunner, mainRoot: string, worktreeRoot: string, relativePath: string): boolean {
|
|
21
|
+
const source = path.join(mainRoot, relativePath);
|
|
22
|
+
const destination = path.join(worktreeRoot, relativePath);
|
|
23
|
+
if (!fs.existsSync(source) || fs.existsSync(destination) || hasTrackedPathComponent(runGit, worktreeRoot, relativePath)) return false;
|
|
24
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
25
|
+
fs.copyFileSync(source, destination);
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
function configureHooks(runGit: WorktreeGitRunner, mainRoot: string): void {
|
|
29
|
+
const husky = path.join(mainRoot, ".husky");
|
|
30
|
+
const ordinary = path.join(mainRoot, ".git", "hooks");
|
|
31
|
+
let desired: string | undefined;
|
|
32
|
+
try { if (fs.statSync(husky).isDirectory()) desired = husky; } catch { /* continue */ }
|
|
33
|
+
if (!desired) {
|
|
34
|
+
try {
|
|
35
|
+
if (fs.readdirSync(ordinary, { withFileTypes: true }).some((entry) => entry.isFile() && !entry.name.endsWith(".sample"))) desired = ordinary;
|
|
36
|
+
} catch { /* no hooks */ }
|
|
37
|
+
}
|
|
38
|
+
if (!desired) return;
|
|
39
|
+
const current = runGit(mainRoot, ["config", "--get", "core.hooksPath"]);
|
|
40
|
+
if (current.status === 0 && path.resolve(mainRoot, current.stdout.trim()) === desired) return;
|
|
41
|
+
const result = runGit(mainRoot, ["config", "core.hooksPath", desired]);
|
|
42
|
+
if (result.status !== 0) throw new Error(result.stderr.trim() || "failed to configure shared core.hooksPath");
|
|
43
|
+
}
|
|
44
|
+
function copyIncludes(runGit: WorktreeGitRunner, mainRoot: string, worktreeRoot: string): void {
|
|
45
|
+
if (!fs.existsSync(path.join(mainRoot, ".worktreeinclude"))) return;
|
|
46
|
+
const ignored = runGit(mainRoot, ["ls-files", "--others", "--ignored", "--exclude-standard"]);
|
|
47
|
+
const included = runGit(mainRoot, ["ls-files", "--others", "--ignored", "--exclude-from=.worktreeinclude"]);
|
|
48
|
+
if (ignored.status !== 0 || included.status !== 0) return;
|
|
49
|
+
const ignoredPaths = new Set(ignored.stdout.split(/\r?\n/).filter(Boolean));
|
|
50
|
+
for (const relativePath of included.stdout.split(/\r?\n/).filter(Boolean)) {
|
|
51
|
+
if (!ignoredPaths.has(relativePath) || hasTrackedPathComponent(runGit, worktreeRoot, relativePath)) continue;
|
|
52
|
+
const source = path.join(mainRoot, relativePath);
|
|
53
|
+
const destination = path.join(worktreeRoot, relativePath);
|
|
54
|
+
try {
|
|
55
|
+
if (!fs.statSync(source).isFile() || fs.existsSync(destination)) continue;
|
|
56
|
+
fs.mkdirSync(path.dirname(destination), { recursive: true });
|
|
57
|
+
fs.copyFileSync(source, destination);
|
|
58
|
+
} catch { /* concurrent removal */ }
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function performPostCreationSetup(runGit: WorktreeGitRunner, mainRoot: string, worktreeRoot: string): string[] {
|
|
62
|
+
const synthetic: string[] = [];
|
|
63
|
+
if (copySettings(runGit, mainRoot, worktreeRoot, ".atomic/settings.local.json")) synthetic.push(".atomic/settings.local.json");
|
|
64
|
+
if (!tracked(runGit, mainRoot, ".atomic/settings.json") && copySettings(runGit, mainRoot, worktreeRoot, ".atomic/settings.json")) {
|
|
65
|
+
synthetic.push(".atomic/settings.json");
|
|
66
|
+
}
|
|
67
|
+
configureHooks(runGit, mainRoot);
|
|
68
|
+
const source = path.join(mainRoot, "node_modules");
|
|
69
|
+
const destination = path.join(worktreeRoot, "node_modules");
|
|
70
|
+
if (fs.existsSync(source) && !fs.existsSync(destination) && !tracked(runGit, worktreeRoot, "node_modules")) {
|
|
71
|
+
try { fs.symlinkSync(source, destination, process.platform === "win32" ? "junction" : undefined); synthetic.push("node_modules"); } catch { /* optional */ }
|
|
72
|
+
}
|
|
73
|
+
copyIncludes(runGit, mainRoot, worktreeRoot);
|
|
74
|
+
return synthetic;
|
|
75
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
|
|
4
|
+
function readText(file: string): string | undefined {
|
|
5
|
+
try { return fs.readFileSync(file, "utf8"); } catch { return undefined; }
|
|
6
|
+
}
|
|
7
|
+
function samePath(left: string, right: string): boolean {
|
|
8
|
+
try {
|
|
9
|
+
const a = fs.realpathSync.native(left);
|
|
10
|
+
const b = fs.realpathSync.native(right);
|
|
11
|
+
return process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
12
|
+
} catch { return false; }
|
|
13
|
+
}
|
|
14
|
+
export function findGitRoot(cwd: string): string | undefined {
|
|
15
|
+
let current = path.resolve(cwd);
|
|
16
|
+
try { if (!fs.statSync(current).isDirectory()) current = path.dirname(current); } catch { return undefined; }
|
|
17
|
+
while (true) {
|
|
18
|
+
try {
|
|
19
|
+
const entry = fs.statSync(path.join(current, ".git"));
|
|
20
|
+
if (entry.isDirectory() || entry.isFile()) return current;
|
|
21
|
+
} catch { /* walk */ }
|
|
22
|
+
const parent = path.dirname(current);
|
|
23
|
+
if (parent === current) return undefined;
|
|
24
|
+
current = parent;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function resolveMainRepoRoot(repoRoot: string): string | undefined {
|
|
28
|
+
const gitEntry = path.join(repoRoot, ".git");
|
|
29
|
+
let stats: fs.Stats;
|
|
30
|
+
try { stats = fs.statSync(gitEntry); } catch { return undefined; }
|
|
31
|
+
if (stats.isDirectory()) return path.resolve(repoRoot);
|
|
32
|
+
if (!stats.isFile()) return undefined;
|
|
33
|
+
const contents = readText(gitEntry);
|
|
34
|
+
if (contents === undefined || !contents.startsWith("gitdir:")) return undefined;
|
|
35
|
+
const pointer = contents.slice("gitdir:".length).trim();
|
|
36
|
+
if (!pointer) return undefined;
|
|
37
|
+
const gitDir = path.resolve(repoRoot, pointer);
|
|
38
|
+
if (path.basename(path.dirname(gitDir)) !== "worktrees") return undefined;
|
|
39
|
+
const commonGitDir = path.dirname(path.dirname(gitDir));
|
|
40
|
+
if (path.basename(commonGitDir) !== ".git") return undefined;
|
|
41
|
+
const back = readText(path.join(gitDir, "gitdir"))?.trim();
|
|
42
|
+
const common = readText(path.join(gitDir, "commondir"))?.trim();
|
|
43
|
+
if (!back || !common) return undefined;
|
|
44
|
+
if (!samePath(path.resolve(gitDir, back), gitEntry)) return undefined;
|
|
45
|
+
if (!samePath(path.resolve(gitDir, common), commonGitDir)) return undefined;
|
|
46
|
+
return path.dirname(commonGitDir);
|
|
47
|
+
}
|
|
48
|
+
export function findCanonicalGitRoot(cwd: string): string | undefined {
|
|
49
|
+
const repoRoot = findGitRoot(cwd);
|
|
50
|
+
return repoRoot === undefined ? undefined : resolveMainRepoRoot(repoRoot);
|
|
51
|
+
}
|
|
@@ -2,7 +2,9 @@ import { spawnSync } from "node:child_process";
|
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
|
-
import {
|
|
5
|
+
import { createGitEnvironment } from "@bastani/atomic";
|
|
6
|
+
import { performPostCreationSetup } from "./worktree-post-create.js";
|
|
7
|
+
import { findCanonicalGitRoot } from "./worktree-root.js";
|
|
6
8
|
export interface WorktreeSetup {
|
|
7
9
|
cwd: string;
|
|
8
10
|
worktrees: WorktreeInfo[];
|
|
@@ -63,9 +65,10 @@ interface GitResult {
|
|
|
63
65
|
status: number | null;
|
|
64
66
|
}
|
|
65
67
|
interface RepoState {
|
|
66
|
-
|
|
68
|
+
mainRoot: string;
|
|
67
69
|
cwdRelative: string;
|
|
68
70
|
baseCommit: string;
|
|
71
|
+
baseRef: string;
|
|
69
72
|
}
|
|
70
73
|
const DEFAULT_WORKTREE_SETUP_HOOK_TIMEOUT_MS = 30000;
|
|
71
74
|
function runGit(cwd: string, args: string[]): GitResult {
|
|
@@ -85,15 +88,30 @@ function runGitChecked(cwd: string, args: string[]): string {
|
|
|
85
88
|
}
|
|
86
89
|
return result.stdout;
|
|
87
90
|
}
|
|
91
|
+
function originDefaultBranch(mainRoot: string): string | undefined {
|
|
92
|
+
const symbolic = runGit(mainRoot, ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"]);
|
|
93
|
+
let branch = symbolic.status === 0 && symbolic.stdout.trim().startsWith("origin/")
|
|
94
|
+
? symbolic.stdout.trim().slice("origin/".length) : undefined;
|
|
95
|
+
if (!branch) {
|
|
96
|
+
const remote = runGit(mainRoot, ["remote", "show", "origin"]);
|
|
97
|
+
branch = remote.status === 0 ? remote.stdout.match(/^\s*HEAD branch:\s*(\S+)\s*$/m)?.[1] : undefined;
|
|
98
|
+
}
|
|
99
|
+
if (!branch || branch === "(unknown)") return undefined;
|
|
100
|
+
const remoteRef = `refs/remotes/origin/${branch}`;
|
|
101
|
+
if (runGit(mainRoot, ["show-ref", "--verify", "--quiet", remoteRef]).status !== 0
|
|
102
|
+
&& runGit(mainRoot, ["fetch", "origin", `${branch}:${remoteRef}`]).status !== 0) return undefined;
|
|
103
|
+
return `origin/${branch}`;
|
|
104
|
+
}
|
|
88
105
|
function resolveRepoState(cwd: string): RepoState {
|
|
89
106
|
const cwdRelative = resolveRepoCwdRelative(cwd);
|
|
90
|
-
const toplevel = runGitChecked(cwd, ["rev-parse", "--show-toplevel"]).trim();
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
107
|
+
const toplevel = path.resolve(runGitChecked(cwd, ["rev-parse", "--show-toplevel"]).trim());
|
|
108
|
+
const mainRoot = findCanonicalGitRoot(toplevel);
|
|
109
|
+
if (mainRoot === undefined) throw new Error(`unable to resolve canonical main Git repository root from ${toplevel}`);
|
|
110
|
+
const status = runGitChecked(toplevel, ["status", "--porcelain", "--untracked-files=no"]);
|
|
111
|
+
if (status.trim().length > 0) throw new Error("worktree isolation requires a clean git working tree. Commit or stash changes first.");
|
|
112
|
+
const baseRef = originDefaultBranch(mainRoot) || "HEAD";
|
|
113
|
+
const baseCommit = runGitChecked(mainRoot, ["rev-parse", baseRef]).trim();
|
|
114
|
+
return { mainRoot, cwdRelative, baseCommit, baseRef };
|
|
97
115
|
}
|
|
98
116
|
function normalizeComparableCwd(cwd: string): string {
|
|
99
117
|
const resolved = path.resolve(cwd);
|
|
@@ -126,11 +144,19 @@ export function formatWorktreeTaskCwdConflict(
|
|
|
126
144
|
function safePatchAgentName(agent: string): string {
|
|
127
145
|
return agent.replace(/[^\w.-]/g, "_");
|
|
128
146
|
}
|
|
147
|
+
function flattenedWorktreeName(runId: string, index: number): string {
|
|
148
|
+
return `${runId}-${index}`.replaceAll("/", "+");
|
|
149
|
+
}
|
|
129
150
|
function buildWorktreeBranch(runId: string, index: number): string {
|
|
130
|
-
return
|
|
151
|
+
return `worktree-${flattenedWorktreeName(runId, index)}`;
|
|
152
|
+
}
|
|
153
|
+
function buildWorktreePath(mainRoot: string, runId: string, index: number): string {
|
|
154
|
+
return path.join(mainRoot, ".atomic", "worktrees", flattenedWorktreeName(runId, index));
|
|
131
155
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
156
|
+
function ensureWorktreeIgnore(mainRoot: string): void {
|
|
157
|
+
const root = path.join(mainRoot, ".atomic", "worktrees");
|
|
158
|
+
fs.mkdirSync(root, { recursive: true });
|
|
159
|
+
fs.writeFileSync(path.join(root, ".gitignore"), "*\n", "utf8");
|
|
134
160
|
}
|
|
135
161
|
function resolveRepoCwdRelative(cwd: string): string {
|
|
136
162
|
const repoCheck = runGit(cwd, ["rev-parse", "--is-inside-work-tree"]);
|
|
@@ -145,20 +171,12 @@ function resolveRepoCwdRelative(cwd: string): string {
|
|
|
145
171
|
}
|
|
146
172
|
export function resolveExpectedWorktreeAgentCwd(cwd: string, runId: string, index: number): string {
|
|
147
173
|
const cwdRelative = resolveRepoCwdRelative(cwd);
|
|
148
|
-
const
|
|
174
|
+
const toplevel = path.resolve(runGitChecked(cwd, ["rev-parse", "--show-toplevel"]).trim());
|
|
175
|
+
const mainRoot = findCanonicalGitRoot(toplevel);
|
|
176
|
+
if (mainRoot === undefined) throw new Error(`unable to resolve canonical main Git repository root from ${toplevel}`);
|
|
177
|
+
const worktreePath = buildWorktreePath(mainRoot, runId, index);
|
|
149
178
|
return cwdRelative ? path.join(worktreePath, cwdRelative) : worktreePath;
|
|
150
179
|
}
|
|
151
|
-
function linkNodeModulesIfPresent(toplevel: string, worktreePath: string): boolean {
|
|
152
|
-
const nodeModulesPath = path.join(toplevel, "node_modules");
|
|
153
|
-
const nodeModulesLinkPath = path.join(worktreePath, "node_modules");
|
|
154
|
-
if (!fs.existsSync(nodeModulesPath) || fs.existsSync(nodeModulesLinkPath)) return false;
|
|
155
|
-
try {
|
|
156
|
-
fs.symlinkSync(nodeModulesPath, nodeModulesLinkPath);
|
|
157
|
-
return true;
|
|
158
|
-
} catch {
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
180
|
function parseHookTimeout(timeoutMs: number | undefined): number {
|
|
163
181
|
if (timeoutMs === undefined) return DEFAULT_WORKTREE_SETUP_HOOK_TIMEOUT_MS;
|
|
164
182
|
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
|
|
@@ -270,53 +288,46 @@ function runWorktreeSetupHook(
|
|
|
270
288
|
}
|
|
271
289
|
return [...uniquePaths];
|
|
272
290
|
}
|
|
291
|
+
function waitForGitLockRelease(): void {
|
|
292
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|
|
293
|
+
}
|
|
294
|
+
function cleanupSingleWorktree(repoCwd: string, worktree: Pick<WorktreeInfo, "path" | "branch">): void {
|
|
295
|
+
try { runGitChecked(repoCwd, ["worktree", "remove", "--force", worktree.path]); } catch { /* idempotent */ }
|
|
296
|
+
waitForGitLockRelease();
|
|
297
|
+
try { runGitChecked(repoCwd, ["branch", "-D", worktree.branch]); } catch { /* idempotent */ }
|
|
298
|
+
}
|
|
273
299
|
function createSingleWorktree(
|
|
274
|
-
|
|
300
|
+
mainRoot: string,
|
|
275
301
|
cwdRelative: string,
|
|
276
302
|
runId: string,
|
|
277
303
|
index: number,
|
|
304
|
+
baseRef: string,
|
|
278
305
|
baseCommit: string,
|
|
279
306
|
setupHook: ResolvedWorktreeSetupHook | undefined,
|
|
280
307
|
agent: string | undefined,
|
|
281
308
|
): WorktreeInfo {
|
|
282
309
|
const branch = buildWorktreeBranch(runId, index);
|
|
283
|
-
const worktreePath = buildWorktreePath(runId, index);
|
|
284
|
-
const add = runGit(
|
|
310
|
+
const worktreePath = buildWorktreePath(mainRoot, runId, index);
|
|
311
|
+
const add = runGit(mainRoot, ["worktree", "add", "-B", branch, worktreePath, baseRef]);
|
|
285
312
|
if (add.status !== 0) {
|
|
286
313
|
const message = add.stderr.trim() || add.stdout.trim() || `failed to create worktree ${worktreePath}`;
|
|
314
|
+
cleanupSingleWorktree(mainRoot, { path: worktreePath, branch });
|
|
287
315
|
throw new Error(message);
|
|
288
316
|
}
|
|
289
317
|
const agentCwd = cwdRelative ? path.join(worktreePath, cwdRelative) : worktreePath;
|
|
290
318
|
try {
|
|
291
|
-
const
|
|
292
|
-
const syntheticPaths = nodeModulesLinked ? ["node_modules"] : [];
|
|
319
|
+
const syntheticPaths = performPostCreationSetup(runGit, mainRoot, worktreePath);
|
|
293
320
|
if (setupHook) {
|
|
294
|
-
|
|
295
|
-
version: 1,
|
|
296
|
-
|
|
297
|
-
worktreePath,
|
|
298
|
-
agentCwd,
|
|
299
|
-
branch,
|
|
300
|
-
index,
|
|
301
|
-
runId,
|
|
302
|
-
baseCommit,
|
|
303
|
-
agent,
|
|
304
|
-
});
|
|
305
|
-
syntheticPaths.push(...hookSyntheticPaths);
|
|
321
|
+
syntheticPaths.push(...runWorktreeSetupHook(setupHook, {
|
|
322
|
+
version: 1, repoRoot: mainRoot, worktreePath, agentCwd, branch, index, runId, baseCommit, agent,
|
|
323
|
+
}));
|
|
306
324
|
}
|
|
307
325
|
return {
|
|
308
|
-
path: worktreePath,
|
|
309
|
-
|
|
310
|
-
branch,
|
|
311
|
-
index,
|
|
312
|
-
nodeModulesLinked,
|
|
313
|
-
syntheticPaths,
|
|
326
|
+
path: worktreePath, agentCwd, branch, index,
|
|
327
|
+
nodeModulesLinked: syntheticPaths.includes("node_modules"), syntheticPaths,
|
|
314
328
|
};
|
|
315
329
|
} catch (error) {
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
try { runGitChecked(toplevel, ["branch", "-D", branch]); } catch {
|
|
319
|
-
}
|
|
330
|
+
cleanupSingleWorktree(mainRoot, { path: worktreePath, branch });
|
|
320
331
|
throw error;
|
|
321
332
|
}
|
|
322
333
|
}
|
|
@@ -415,44 +426,27 @@ function writeEmptyPatch(patchPath: string): void {
|
|
|
415
426
|
} catch {
|
|
416
427
|
}
|
|
417
428
|
}
|
|
418
|
-
|
|
419
|
-
try { runGitChecked(repoCwd, ["worktree", "remove", "--force", worktree.path]); } catch {
|
|
420
|
-
}
|
|
421
|
-
try { runGitChecked(repoCwd, ["branch", "-D", worktree.branch]); } catch {
|
|
422
|
-
}
|
|
423
|
-
}
|
|
429
|
+
|
|
424
430
|
function hasWorktreeChanges(diff: WorktreeDiff): boolean {
|
|
425
431
|
return diff.filesChanged > 0 || diff.insertions > 0 || diff.deletions > 0 || diff.diffStat.trim().length > 0;
|
|
426
432
|
}
|
|
427
433
|
export function createWorktrees(cwd: string, runId: string, count: number, options?: CreateWorktreesOptions): WorktreeSetup {
|
|
428
434
|
const repo = resolveRepoState(cwd);
|
|
429
|
-
|
|
435
|
+
ensureWorktreeIgnore(repo.mainRoot);
|
|
436
|
+
const setupHook = resolveWorktreeSetupHook(repo.mainRoot, options?.setupHook);
|
|
430
437
|
const worktrees: WorktreeInfo[] = [];
|
|
431
438
|
try {
|
|
432
439
|
for (let index = 0; index < count; index++) {
|
|
433
440
|
worktrees.push(createSingleWorktree(
|
|
434
|
-
repo.
|
|
435
|
-
|
|
436
|
-
runId,
|
|
437
|
-
index,
|
|
438
|
-
repo.baseCommit,
|
|
439
|
-
setupHook,
|
|
440
|
-
options?.agents?.[index],
|
|
441
|
+
repo.mainRoot, repo.cwdRelative, runId, index, repo.baseRef, repo.baseCommit,
|
|
442
|
+
setupHook, options?.agents?.[index],
|
|
441
443
|
));
|
|
442
444
|
}
|
|
443
445
|
} catch (error) {
|
|
444
|
-
cleanupWorktrees({
|
|
445
|
-
cwd: repo.toplevel,
|
|
446
|
-
worktrees,
|
|
447
|
-
baseCommit: repo.baseCommit,
|
|
448
|
-
});
|
|
446
|
+
cleanupWorktrees({ cwd: repo.mainRoot, worktrees, baseCommit: repo.baseCommit });
|
|
449
447
|
throw error;
|
|
450
448
|
}
|
|
451
|
-
return {
|
|
452
|
-
cwd: repo.toplevel,
|
|
453
|
-
worktrees,
|
|
454
|
-
baseCommit: repo.baseCommit,
|
|
455
|
-
};
|
|
449
|
+
return { cwd: repo.mainRoot, worktrees, baseCommit: repo.baseCommit };
|
|
456
450
|
}
|
|
457
451
|
export function diffWorktrees(setup: WorktreeSetup, agents: string[], diffsDir: string): WorktreeDiff[] {
|
|
458
452
|
try {
|
|
@@ -478,8 +472,6 @@ export function cleanupWorktrees(setup: WorktreeSetup): void {
|
|
|
478
472
|
for (let index = setup.worktrees.length - 1; index >= 0; index--) {
|
|
479
473
|
cleanupSingleWorktree(setup.cwd, setup.worktrees[index]!);
|
|
480
474
|
}
|
|
481
|
-
try { runGitChecked(setup.cwd, ["worktree", "prune"]); } catch {
|
|
482
|
-
}
|
|
483
475
|
}
|
|
484
476
|
export function formatWorktreeDiffSummary(diffs: WorktreeDiff[]): string {
|
|
485
477
|
const changed = diffs.filter(hasWorktreeChanges);
|