@bastani/atomic 0.9.85 → 0.9.86-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.
Files changed (125) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +15 -0
  3. package/dist/builtin/intercom/README.md +10 -9
  4. package/dist/builtin/intercom/broker/away-asks.ts +260 -0
  5. package/dist/builtin/intercom/broker/broker.ts +170 -9
  6. package/dist/builtin/intercom/broker/client.ts +5 -3
  7. package/dist/builtin/intercom/broker/held-reply-targets.ts +5 -0
  8. package/dist/builtin/intercom/broker/multinode-router.ts +16 -7
  9. package/dist/builtin/intercom/broker/paths.ts +5 -0
  10. package/dist/builtin/intercom/broker/pending-question-index.ts +119 -0
  11. package/dist/builtin/intercom/broker/released-asker-replies.ts +39 -0
  12. package/dist/builtin/intercom/broker/send-handler.ts +44 -3
  13. package/dist/builtin/intercom/broker/terminal-questions.ts +2 -0
  14. package/dist/builtin/intercom/index.bundle.mjs +799 -177
  15. package/dist/builtin/intercom/package.json +1 -1
  16. package/dist/builtin/intercom/retry-policy.ts +1 -1
  17. package/dist/builtin/intercom/skills/intercom/SKILL.md +29 -35
  18. package/dist/builtin/intercom/types.ts +7 -2
  19. package/dist/builtin/mcp/package.json +1 -1
  20. package/dist/builtin/subagents/CHANGELOG.md +20 -0
  21. package/dist/builtin/subagents/package.json +1 -1
  22. package/dist/builtin/subagents/skills/subagent/SKILL.md +1 -1
  23. package/dist/builtin/subagents/src/extension/index.bundle.mjs +2765 -2719
  24. package/dist/builtin/web-access/package.json +1 -1
  25. package/dist/builtin/workflows/CHANGELOG.md +12 -0
  26. package/dist/builtin/workflows/package.json +1 -1
  27. package/dist/builtin/workflows/src/authoring.d.ts +1 -1
  28. package/dist/builtin/workflows/src/extension/index.bundle.mjs +371 -193
  29. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +358 -181
  30. package/dist/builtin/workflows/src/index.js +356 -183
  31. package/dist/builtin/workflows/src/local-worker-entry.mjs +358 -181
  32. package/dist/builtin/workflows/src/shared/worktree-restore-outcome.d.ts +16 -0
  33. package/dist/builtin/workflows/src/workers/workspace-binding.d.ts +13 -2
  34. package/dist/core/agent-session-methods.d.ts +1 -0
  35. package/dist/core/agent-session-methods.d.ts.map +1 -1
  36. package/dist/core/agent-session-methods.js.map +1 -1
  37. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  38. package/dist/core/agent-session-prompt.js +2 -35
  39. package/dist/core/agent-session-prompt.js.map +1 -1
  40. package/dist/core/agent-session-runtime.d.ts +3 -1
  41. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  42. package/dist/core/agent-session-runtime.js +12 -5
  43. package/dist/core/agent-session-runtime.js.map +1 -1
  44. package/dist/core/agent-session-state.d.ts.map +1 -1
  45. package/dist/core/agent-session-state.js +14 -1
  46. package/dist/core/agent-session-state.js.map +1 -1
  47. package/dist/core/agent-session.d.ts +2 -0
  48. package/dist/core/agent-session.d.ts.map +1 -1
  49. package/dist/core/agent-session.js +3 -1
  50. package/dist/core/agent-session.js.map +1 -1
  51. package/dist/core/resume/index.d.ts +1 -1
  52. package/dist/core/resume/index.d.ts.map +1 -1
  53. package/dist/core/resume/index.js +1 -1
  54. package/dist/core/resume/index.js.map +1 -1
  55. package/dist/core/resume/path-mapping.d.ts +10 -0
  56. package/dist/core/resume/path-mapping.d.ts.map +1 -1
  57. package/dist/core/resume/path-mapping.js +20 -0
  58. package/dist/core/resume/path-mapping.js.map +1 -1
  59. package/dist/core/resume/session-resume.d.ts +5 -0
  60. package/dist/core/resume/session-resume.d.ts.map +1 -1
  61. package/dist/core/resume/session-resume.js +24 -9
  62. package/dist/core/resume/session-resume.js.map +1 -1
  63. package/dist/core/session-worktree-snapshots.d.ts +5 -8
  64. package/dist/core/session-worktree-snapshots.d.ts.map +1 -1
  65. package/dist/core/session-worktree-snapshots.js +34 -99
  66. package/dist/core/session-worktree-snapshots.js.map +1 -1
  67. package/dist/core/skill-catalog.d.ts +11 -0
  68. package/dist/core/skill-catalog.d.ts.map +1 -1
  69. package/dist/core/skill-catalog.js +31 -0
  70. package/dist/core/skill-catalog.js.map +1 -1
  71. package/dist/core/tasks/agent-adapter.d.ts +2 -0
  72. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  73. package/dist/core/tasks/agent-adapter.js +5 -1
  74. package/dist/core/tasks/agent-adapter.js.map +1 -1
  75. package/dist/core/tasks/supervisor.d.ts +17 -0
  76. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  77. package/dist/core/tasks/supervisor.js +12 -6
  78. package/dist/core/tasks/supervisor.js.map +1 -1
  79. package/dist/core/tasks/task-view-source.d.ts +10 -0
  80. package/dist/core/tasks/task-view-source.d.ts.map +1 -1
  81. package/dist/core/tasks/task-view-source.js +24 -1
  82. package/dist/core/tasks/task-view-source.js.map +1 -1
  83. package/dist/core/worktree-snapshot/best-restore.d.ts +45 -0
  84. package/dist/core/worktree-snapshot/best-restore.d.ts.map +1 -0
  85. package/dist/core/worktree-snapshot/best-restore.js +92 -0
  86. package/dist/core/worktree-snapshot/best-restore.js.map +1 -0
  87. package/dist/core/worktree-snapshot/git.d.ts +2 -2
  88. package/dist/core/worktree-snapshot/git.d.ts.map +1 -1
  89. package/dist/core/worktree-snapshot/git.js +2 -5
  90. package/dist/core/worktree-snapshot/git.js.map +1 -1
  91. package/dist/core/worktree-snapshot/index.d.ts +1 -0
  92. package/dist/core/worktree-snapshot/index.d.ts.map +1 -1
  93. package/dist/core/worktree-snapshot/index.js +1 -0
  94. package/dist/core/worktree-snapshot/index.js.map +1 -1
  95. package/dist/core/worktree-snapshot/restore.d.ts.map +1 -1
  96. package/dist/core/worktree-snapshot/restore.js +18 -2
  97. package/dist/core/worktree-snapshot/restore.js.map +1 -1
  98. package/dist/index.d.ts +3 -2
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +1 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/modes/interactive/chat-autocomplete.d.ts +7 -0
  103. package/dist/modes/interactive/chat-autocomplete.d.ts.map +1 -0
  104. package/dist/modes/interactive/chat-autocomplete.js +85 -0
  105. package/dist/modes/interactive/chat-autocomplete.js.map +1 -0
  106. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/task-transcript-page.js +8 -0
  108. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  109. package/dist/modes/interactive/interactive-autocomplete.js +3 -79
  110. package/dist/modes/interactive/interactive-autocomplete.js.map +1 -1
  111. package/dist/modes/interactive/skill-command-autocomplete.d.ts +6 -0
  112. package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -1
  113. package/dist/modes/interactive/skill-command-autocomplete.js +18 -2
  114. package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -1
  115. package/docs/background-tasks.md +1 -1
  116. package/docs/intercom/operations.md +4 -4
  117. package/docs/intercom/reference.md +39 -8
  118. package/docs/intercom.md +26 -9
  119. package/docs/skills.md +3 -1
  120. package/docs/subagents.md +2 -0
  121. package/docs/workflows/api-reference.md +3 -3
  122. package/docs/workflows/operations.md +2 -2
  123. package/docs/worktree-snapshots.md +10 -4
  124. package/npm-shrinkwrap.json +32 -32
  125. package/package.json +3 -3
@@ -9,10 +9,12 @@ description: The intercom tool contract and every intercom setting.
9
9
 
10
10
  | Parameter | Type | Description |
11
11
  |-----------|------|-------------|
12
- | `action` | string | `"list"`, `"groups"`, `"join"`, `"leave"`, `"send"`, `"ask"`, `"reply"`, `"pending"`, or `"status"` |
12
+ | `action` | string | `"list"`, `"groups"`, `"join"`, `"leave"`, `"send"`, `"ask"`, `"reply"`, `"pending"`, `"cancel"`, or `"status"` |
13
13
  | `to` | string | Exact session name/full session ID, unique 8-hex session UUID prefix, or `workflow:<rootRunId>/<segment>[/<segment>...]`; `*` matches one segment and `**` any depth. Sends support pending/future patterns and broadcast; `ask` requires a live target. |
14
14
  | `message` | string | Message text (for send/ask/reply) |
15
15
  | `attachments` | array | Optional `file`, `snippet`, or `context` attachments |
16
+ | `wait` | object | For `ask`: how long to wait for the reply before yielding, as in `bash`. Omit it for the automatic yield (default 10 seconds), use `{ kind: "foreground", budgetMs }` to wait up to a budget, or `{ kind: "background" }` to return at delivery. |
17
+ | `askId` | string | For `cancel`: the ID, or a unique prefix, of one of your pending asks |
16
18
  | `replyTo` | string | Exact message ID or unique 8-hex UUID prefix of an unresolved inbound ask; resolved before current-turn and pending-ask fallback |
17
19
  | `group` | string | Group name for `join` or an optional targeted `leave`; read-only group filter for `list`/`status`. `send`/`ask` remain limited to shared memberships. |
18
20
 
@@ -25,9 +27,10 @@ description: The intercom tool contract and every intercom setting.
25
27
  | `groups` | Lists every group represented by a connected session, with its session count and a marker for each group this session belongs to. Use it to discover names rather than guessing. |
26
28
  | `list` | Returns the current session, active sessions sharing a membership, materialized workflow stages labeled `PENDING` or `RUNNING` with canonical path targets, and possible future literals, globs, and child paths with queued counts. Pass `group` for a read-only view of one group. |
27
29
  | `send` | Fire-and-forget delivery through ordinary Intercom. A live workflow-stage match receives the message immediately. A pending, future, name, or pattern path is persisted as sticky delivery and returns `queued` with `prediction`: `known`, `predicted` or `unknown`. Requires `to` and `message`; cannot message the current session. |
28
- | `ask` | Sends a message and blocks until a live recipient replies (10-minute timeout). An ask to a known workflow stage whose session has not initialized is refused with `pending_stage_ask_unsupported` and recommends ordinary `send`; holding a waiter until a stage eventually starts would be unbounded. A live recipient disconnect fails promptly. Parallel children continue in the same execution after a correlated reply; single-child parent handoffs remain unchanged. |
30
+ | `ask` | Sends a message to a live recipient and returns once it is delivered, with `askId`, `delivered`, and `recipient` (`name`, `state` `idle` or `busy`, and `currentAction` when known). A reply within the `wait` comes back inline; otherwise the ask stays pending with no expiry and the reply arrives later as a message. See [send vs ask vs reply](#send-vs-ask-vs-reply). An ask to a known workflow stage whose session has not initialized is refused with `pending_stage_ask_unsupported` and recommends ordinary `send`. Single-child parent handoffs remain unchanged. |
29
31
  | `reply` | Replies to the intercom-triggered message of the current turn; otherwise falls back to the single unresolved inbound ask. With multiple pending asks, pass `to` or inspect with `pending` first. |
30
- | `pending` | Lists unresolved inbound asks with sender, message ID, elapsed time, and a short preview. |
32
+ | `pending` | Lists unresolved inbound asks with sender, message ID, elapsed time, and a short preview, and your own asks still waiting for a reply with ask ID, target, elapsed time, and the question. |
33
+ | `cancel` | Cancels one of your pending asks by `askId`. A reply that still arrives is shown once, marked late. |
31
34
  | `status` | Shows connection status, session ID, every group this session belongs to, the count of active sessions visible through those memberships, and the broker's multi-node routing state with the number of other brokers live in the shared database. A `group` filter remains a read-only peek. |
32
35
 
33
36
  To give two plain chat sessions a private shared membership, have both call:
@@ -62,6 +65,20 @@ Exact names and IDs take precedence, and an Atomic session ID is tried only afte
62
65
 
63
66
  A reopened session or a restored background subagent registers under the Intercom session ID it had before the restart, so peers can keep using the ID they saw in `intercom list`. The session records that ID in its history as an `intercom_session_identity` entry. The broker never gives an ID to a new registration while a live session holds it; the restarted session then gets a fresh ID. While the broker remembers who last held an ID, only that same Atomic session can take it back.
64
67
 
68
+ #### Sending to several sessions at once
69
+
70
+ `send` also accepts targets that name several recipients:
71
+
72
+ | Target | Reaches |
73
+ | --- | --- |
74
+ | `subagent-worker-*`, `subagent-*`, `*` | Every live session visible in your groups whose name matches, except you. `*` matches any run of characters and is case-insensitive; `*` alone reaches every visible session. |
75
+ | `subagents:*` | Every subagent this session launched, in any run, that is running (foreground or background), released, or paused. |
76
+ | `subagents:<runId>/*` | The same, for the children of one `subagent` run. |
77
+
78
+ Each recipient gets its own direct send, with the same delivery, refusals, receipts, and reconnect retries as sending to it by name. A paused subagent's message is held for it exactly as a direct send to it would be. The result lists every recipient with its outcome: `delivered`, `queued`, `not delivered` with the reason, or `outcome unknown`. It is an error only when no recipient was reached. A glob that matches no visible session is an error that lists the closest visible names, and `subagents:` with no such child is an error too.
79
+
80
+ Patterns match only sessions you can already see in `intercom list`: they never reach outside your groups. `ask` and `replyTo` need one exact target, because a reply to a broadcast question would be ambiguous, so a pattern there is an error. Workflow-stage paths below keep their own pattern rules, including sticky delivery to future stages; plain session patterns match live sessions only.
81
+
65
82
  Workflow stages use the canonical `workflow:<rootRunId>/<segment>[/<segment>...]` path printed by `intercom list` and workflow status surfaces. An exact target works while the row is `PENDING` and after it becomes `RUNNING`. Each segment may be a stage name, run id, or glob: `*` matches one segment and may be embedded, while `**` matches any depth.
66
83
 
67
84
  Status surfaces label pending stages whose pre-start delivery capability is unavailable without presenting a usable target. They never advertise a retained pending stage after its run terminates. The `sessionId` shown by `workflow status` is the stage's Atomic session ID, not a workflow path: it reaches the stage only while the stage is connected and visible to you, and it never queues for a pending stage.
@@ -123,10 +140,12 @@ A background subagent waiting on an `ask`, or on `contact_supervisor` with `need
123
140
  - **When a reply is refused:** you get a not-delivered result, and nothing reaches the subagent, when any of these is true:
124
141
  - the session that launched the subagent has disconnected;
125
142
  - that session ended or dropped the subagent's hold;
126
- - the subagent's call is no longer waiting, for example because it was stopped.
143
+ - the subagent itself ended or was stopped.
144
+
145
+ When the subagent's `ask` already returned (it yielded before the subagent was released), its reply, or a refusal, is held for the subagent like any other send: the subagent wakes and gets it once as a `Reply to your ask` message.
127
146
  - **Who receives held sends:** only the subagent that its owner relaunched, which registers with the supervisor capability the owner issued for it. A session that merely registers under the same name and group, with no capability or with one another session issued, receives none of the held sends and does not end the owner's hold.
128
147
  - **Reply confirmation:** the owner confirms a reply once it has saved it. If it has not within about 8 seconds, the replier gets the [uncertain-outcome failure](/intercom/operations#how-it-works) and can reply again; a replier that disconnects while its reply waits can reply again after it reconnects. A message ID already waiting for confirmation of another reply is refused with `message_id_conflict`.
129
- - **How long a question stays open:** the usual 10-minute reply wait, counted from when the question was asked.
148
+ - **How long a question stays open:** as long as the subagent's call waits for it, counted from when the question was asked.
130
149
  - **Where it works:** without multi-node routing, the replier and the subagent's launching session must be connected to the same broker on the same machine. With multi-node routing on, a question the subagent asked of a session on another node is kept in the shared database, and the replier can reply through any broker that shares it. The reply reaches the launching session's broker, in the order the replier sent its replies.
131
150
  - **After a restart:** when the launching session reopens, the same question remains open until its original deadline; a reply wakes the child. If the broker itself restarts, a question asked of a session on the same broker loses its route, and the child receives the timeout instead. A question asked of a session on another node survives the restart: once the launching session reconnects, a reply reaches it, and a reply that was handed to it just before the restart is handed to it again and saved once.
132
151
  - **Capacity:** the broker keeps at most 10,000 released-asker reply routes at once for questions asked on that broker; questions kept in the shared database do not count. If it reaches that limit, additional routes cannot receive replies and their calls time out. `broker_status` reports `droppedReleasedReplyRoutes`, the number refused at capacity since the broker started; the broker also logs the first overflow.
@@ -196,15 +215,27 @@ Supervisor coordination is granted by the launching parent and can cross groups
196
215
 
197
216
  **`send`** is fire-and-forget — the tool returns immediately after delivery. By default it sends immediately, including in interactive sessions. If you want an approval dialog before non-reply sends, set `confirmSend: true` in config; replies that include `replyTo` still skip confirmation so reply-hint flows continue without an extra approval step.
198
217
 
199
- **`ask`** sends the message and blocks until the recipient responds (10-minute timeout). If the recipient disconnects after delivery, only the exact ask to that peer fails promptly; the timeout remains the backstop for a connected but unresponsive recipient. Up to `maxPendingAsks` waits (default: 6) may run concurrently, including same-target and mixed-target fan-out. Exact sender/message correlation keeps out-of-order replies and selective disconnects from cross-settling another call. Parallel children use this path even when asking their launching parent: only the requester waits, siblings keep executing, and the reply returns from the waiting tool call in the original child execution. A single-child launch retains the exception that a claimed parent ask ends that child and returns a dynamic `[TASK_CONTEXT]` handoff.
218
+ **`ask`** never takes control away from the asker. It returns once the question is delivered, with an ask ID and whether the recipient is idle or busy (and what it is running, when known). It uses the same wait options as `bash`:
219
+
220
+ | `wait` | What the call does |
221
+ |---|---|
222
+ | omitted | Waits up to the automatic yield (default 10 seconds) and returns the reply inline if it comes in time |
223
+ | `{ kind: "foreground", budgetMs }` | Waits up to `budgetMs`, then yields |
224
+ | `{ kind: "background" }` | Returns right after delivery |
225
+
226
+ A call that yields, or that you interrupt, leaves the ask pending. An ask has no expiry. Its reply arrives later as an ordinary message on your own thread that starts `Reply to your ask <id> from <name>` and quotes your question. It starts a turn when you are idle; when you are busy, it arrives after the current tool call, like other incoming messages. A refusal, or a recipient session that ends before it replies, arrives the same way as a failed-ask message starting `Your ask <id> to <name> failed`. A session that is saved (not `--no-session`) and closes is treated as away, not ended, so its asks stay pending until it is resumed.
227
+
228
+ `pending` lists your asks that are still waiting, and `intercom({ action: "cancel", askId })` cancels one. A reply that arrives after you cancelled is still shown once, marked late. Restarting either session keeps the ask: when the asker resumes, the reply is delivered once; when the recipient resumes, it can still `reply`. A reply to a released subagent or to a workflow stage released between turns reaches it like any other send to it: it wakes the subagent, or waits in the run's queue until the stage reopens, and is shown once. A reply to any other asker that is closed is held for it and delivered once when it resumes, also across machines with multi-node routing; the recipient sees `Reply delivered (held for <asker> until it is back)`. If the recipient ends, or can no longer answer, while the asker is closed, the asker gets the failed-ask message when it resumes; a released subagent asker gets it the same way, and is woken for it. What waits for a session that does not come back within 7 days, or that ended for good, is dropped; you can always cancel an ask yourself. Only the asked recipient can answer an ask: a message from another session that names the ask arrives as an ordinary message. A forked session does not inherit its parent's asks. Each reply is shown once, however often a session restarts.
229
+
230
+ Up to `maxPendingAsks` calls (default: 6) may wait for a reply at the same time; further asks are still delivered and their replies arrive as messages. Exact sender/message correlation keeps out-of-order replies and selective disconnects from cross-settling another ask. A single-child launch retains the exception that a claimed parent ask ends that child and returns a dynamic `[TASK_CONTEXT]` handoff.
200
231
 
201
232
  An `idle` registration does not guarantee reply capability. Completed, failed, interrupted, or cancelled noninteractive subagent children reject new asks immediately with `Target noninteractive child is terminal and cannot reply`; continue a resumable child with `subagent({ action: "resume", id, message })`, or launch a fresh child with explicit context instead. If termination wins after admission but before a reply, the exact pending ask fails explicitly too. Live interactive idle sessions remain askable, and completed workflow stages with a retained reply-capable post-mortem conversation keep their existing reopening behavior. `send` transport behavior is unchanged; a retained registration is not a promise that a terminal child's model will consume a send.
202
233
 
203
- **`contact_supervisor`** keeps a narrower policy: one blocking decision/interview wait per child may coexist with ordinary peer asks, but a second concurrent supervisor wait receives `Already waiting for a supervisor reply`. Claimed foreground handoffs allocate no waiter. Mutual peer asks are supported, although both sessions must process inbound work to reply; the per-waiter timeout remains the backstop.
234
+ **`contact_supervisor`** keeps a narrower policy: one blocking decision/interview wait per child may coexist with ordinary peer asks, but a second concurrent supervisor wait receives `Already waiting for a supervisor reply`. Claimed foreground handoffs allocate no waiter. Its decision and interview requests still wait for the reply, with a 10-minute timeout.
204
235
 
205
236
  **`reply`** is receiver-side sugar for replying to an inbound ask. In the turn triggered by an incoming intercom message, `intercom({ action: "reply", message: "..." })` targets that exact sender and message automatically. If you reply later, it falls back to the single unresolved inbound ask; with multiple pending asks, use `pending` and pass `to`, or pass the listed message ID as `replyTo` to disambiguate multiple asks from the same sender. Under the hood this is still a normal `send` with the exact `replyTo` value.
206
237
 
207
- Explicit selectors override the active turn: `to` selects a pending ask from that exact name/full session ID, and `replyTo` selects only that pending ask or the exact active ordinary message. Stale, unknown, or empty thread IDs fail without falling back. If both selectors are supplied, the sender must match the thread. If an asker is still waiting, inspect `pending` and reply using its exact message ID rather than replying implicitly to an unrelated notification. Multiple asks from the same sender require `replyTo`.
238
+ Explicit selectors override the active turn: `to` selects a pending ask from that exact name/full session ID, and `replyTo` selects only that pending ask or the exact active ordinary message. Stale, unknown, or empty thread IDs fail without falling back. If both selectors are supplied, the sender must match the thread. If an ask is still open, inspect `pending` and reply using its exact message ID rather than replying implicitly to an unrelated notification. Multiple asks from the same sender require `replyTo`.
208
239
 
209
240
  ### Attachments
210
241
 
package/docs/intercom.md CHANGED
@@ -12,7 +12,7 @@ Atomic bundles `@bastani/intercom` for direct 1:1 messaging between sessions on
12
12
  The extension registers commands and tools at startup. Connections are lazy: a session connects when you or the model invoke Intercom. Workflow stages and admitted subagent children connect at session start so they are listable and steerable immediately.
13
13
 
14
14
  **Key capabilities:**
15
- - **Session messaging** - `send`, `ask` (blocking, 10-minute timeout), `reply`, `pending`, `list`, `groups`, and `status` via the `intercom` tool
15
+ - **Session messaging** - `send`, `ask` (never blocks; the reply arrives as a message), `reply`, `pending`, `cancel`, `list`, `groups`, and `status` via the `intercom` tool
16
16
  - **Runtime groups** - Add or remove named memberships without restarting; joined sessions keep their broker IDs and later subagents inherit the most recently joined membership
17
17
  - **Session and group discovery** - List connected sessions or every available group, including session counts and membership markers
18
18
  - **Keyboard overlay** - ALT+M or `/intercom` opens a session picker and compose overlay
@@ -94,8 +94,23 @@ intercom({ action: "list" })
94
94
  intercom({ action: "send", to: "research", message: "Check if UserService.validate() handles null" })
95
95
  // → Message sent to research
96
96
 
97
+ // Send one update to every matching session, or to every subagent you launched
98
+ intercom({ action: "send", to: "subagent-worker-*", message: "Scope changed: skip the migration" })
99
+ intercom({ action: "send", to: "subagents:*", message: "Stop and report what you have" })
100
+ // → Each recipient's outcome is listed: delivered, queued, or not delivered with the reason
101
+
97
102
  // The full session ID printed by list is also a valid target
98
103
  intercom({ action: "ask", to: "6332faab-1111-4222-8333-123456789abc", message: "Which validation path should I use?" })
104
+ // → A quick reply comes back inline. Otherwise: Ask 4c4d8427-… delivered to research (busy: running bash).
105
+ // The reply arrives later as a message starting "Reply to your ask 4c4d8427-… from research".
106
+
107
+ // Ask without waiting at all, or wait up to a budget, as with bash
108
+ intercom({ action: "ask", to: "research", message: "Any blockers?", wait: { kind: "background" } })
109
+ intercom({ action: "ask", to: "research", message: "Any blockers?", wait: { kind: "foreground", budgetMs: 60000 } })
110
+
111
+ // Your pending asks, and cancelling one
112
+ intercom({ action: "pending" })
113
+ intercom({ action: "cancel", askId: "4c4d8427" })
99
114
 
100
115
  // Check connection status
101
116
  intercom({ action: "status" })
@@ -128,7 +143,7 @@ Found the issue — UserService.validate() doesn't check for null input.
128
143
  See auth.ts:142-156.
129
144
  ```
130
145
 
131
- The reply hint (enabled by default) points to `intercom({ action: "reply", ... })`, so recipients never need raw sender or `replyTo` IDs. Idle recipients get a new turn immediately; busy interactive recipients receive the message once they go idle. The recipient saves each message to its session as soon as it arrives, and the sender sees `delivered` only after that save. If the recipient closes or crashes before it shows a saved message, resuming that session with `atomic --session <id>` or `/resume` shows the message then, once, in arrival order, if its sender is still connected. A message from a sender that is gone is added once, in full, to the session history without starting a turn, and the recovery notice says the sender is gone. A reply already returned to a waiting `ask`, or a message the recipient refused, is not shown again when the session reopens. If Intercom cannot be reached when the session reopens, or the sender is a background subagent that was relaunched but has not reconnected yet, the message is deferred: it starts no turn, the notice says so, and the next reopen of the session decides again. Sessions started with `--no-session` are not saved, so their messages are not recovered. Attachment content is included in the agent-visible body, and messages are rendered inline and stored in Atomic session history.
146
+ The reply hint (enabled by default) points to `intercom({ action: "reply", ... })`, so recipients never need raw sender or `replyTo` IDs. Idle recipients get a new turn immediately; busy interactive recipients receive the message once they go idle. The recipient saves each message to its session as soon as it arrives, and the sender sees `delivered` only after that save. If the recipient closes or crashes before it shows a saved message, resuming that session with `atomic --session <id>` or `/resume` shows the message then, once, in arrival order, if its sender is still connected. A message from a sender that is gone is added once, in full, to the session history without starting a turn, and the recovery notice says the sender is gone. A reply already returned inline to an `ask`, or a message the recipient refused, is not shown again when the session reopens. If Intercom cannot be reached when the session reopens, or the sender is a background subagent that was relaunched but has not reconnected yet, the message is deferred: it starts no turn, the notice says so, and the next reopen of the session decides again. Sessions started with `--no-session` are not saved, so their messages are not recovered. Attachment content is included in the agent-visible body, and messages are rendered inline and stored in Atomic session history.
132
147
 
133
148
  Working subagents and live workflow stages handle incoming `send` and `ask` messages in the same task and session, according to the sender's `delivery` option:
134
149
 
@@ -144,7 +159,7 @@ For example, `intercom({ action: "send", to: "worker", message: "Stop; the spec
144
159
 
145
160
  This works for foreground and background children. Startup messages join the original task, multiple messages keep arrival order, and asks retain their reply thread. Subagent `pause` and `quit`, owner cancellation, host stop, and terminal children or closed stages take precedence over later input. Use an exact child name or full session ID from `intercom list`, not a workflow-stage path.
146
161
 
147
- A busy non-interactive recipient that is neither an admitted subagent nor a workflow stage can still refuse a message without interrupting its task. A successful `send` receipt means the recipient saved the message, not that its model accepted it. The refusal carries the original reply thread: a waiting `ask` returns an error; otherwise the sender sees **Intercom delivery failed** feedback with a `Sent:` timestamp. That feedback bypasses the ordinary idle queue and does not trigger a standalone agent turn. During an active turn, protected delivery makes it visible and reconciles it at a protocol-safe boundary. Its wording describes the refused send, not the recipient's later activity.
162
+ A busy non-interactive recipient that is neither an admitted subagent nor a workflow stage can still refuse a message without interrupting its task. A successful `send` receipt means the recipient saved the message, not that its model accepted it. The refusal carries the original reply thread: an `ask` gets it as a failed-ask message (or as an error while its call is still waiting); otherwise the sender sees **Intercom delivery failed** feedback with a `Sent:` timestamp. That feedback bypasses the ordinary idle queue and does not trigger a standalone agent turn. During an active turn, protected delivery makes it visible and reconciles it at a protocol-safe boundary. Its wording describes the refused send, not the recipient's later activity.
148
163
 
149
164
  Atomic enables ordinary `intercom` by default, but it respects tool allowlists, exclusions and `noTools: "all"`. Include `"intercom"` in an explicit allowlist when needed. SDK hosts can disable the entire package with `builtins: { intercom: false }`; reload does not restore it. `contact_supervisor` remains subagent-only. Registration is lightweight; broker connection and heavy initialization remain lazy until an Intercom surface is used.
150
165
 
@@ -203,20 +218,22 @@ intercom({
203
218
  message: "Task-3: Add retry logic to API client. Key files: src/api/client.ts, src/api/types.ts. Ask if anything's unclear."
204
219
  })
205
220
 
206
- // Worker hits an ambiguity — asks and waits
221
+ // Worker hits an ambiguity — asks, and keeps working on what it can
207
222
  intercom({
208
223
  action: "ask",
209
224
  to: "planner",
210
225
  message: "Should retry apply to all endpoints or just idempotent ones? Also, max retry count and backoff strategy?"
211
226
  })
212
- // → Reply from planner: Only GET/PUT/DELETE — never POST. Max 3 retries, exponential backoff starting at 100ms.
213
- // Worker continues implementing with the answer, same turn, full context.
227
+ // → If the planner answers within the wait, the reply comes back inline.
228
+ // → Otherwise the ask stays pending, and the answer arrives later as a message:
229
+ // Reply to your ask 4c4d8427-… from planner
230
+ // Only GET/PUT/DELETE — never POST. Max 3 retries, exponential backoff starting at 100ms.
214
231
  ```
215
232
 
216
233
  | Pattern | Action | Why |
217
234
  |---------|--------|-----|
218
235
  | **Task delegation** | Planner uses `send` | Fire-and-forget. Planner doesn't need to wait for an ack. |
219
- | **Clarification request** | Worker uses `ask` | Worker needs the answer to proceed. Blocks until reply. |
236
+ | **Clarification request** | Worker uses `ask` | Worker needs the answer to proceed. It keeps working on what it can; the reply arrives as a message. |
220
237
  | **Discovery escalation** | Worker uses `ask` | Worker needs approval before changing course. |
221
238
  | **Completion report** | Worker uses `ask` | Planner might have follow-up instructions or the next task. |
222
239
  | **Peer handoff** | Sibling uses `send` | A locator, researcher, or debugger passes paths, evidence, or a reproduction straight to the sibling that needs it. |
@@ -241,7 +258,7 @@ Coordinate with other local Atomic sessions on related codebases. Use `/skill:in
241
258
 
242
259
  **Not when:** Unrelated codebases, trivial questions, or when you can proceed independently.
243
260
 
244
- **Principle:** Prefer `send` for notifications; `ask` only when blocked waiting for input.
261
+ **Principle:** Prefer `send` for notifications; `ask` when you need an answer. `ask` never blocks: its reply arrives as a message.
245
262
  </intercom>
246
263
  ```
247
264
 
@@ -253,7 +270,7 @@ When Atomic's [subagent runtime](/subagents) admits a delegated child, the child
253
270
 
254
271
  The tool appears only in a delegated child whose parent granted supervisor coordination. Otherwise the child receives only ordinary `intercom`. Supervisor identity is supplied by the runtime, not environment variables.
255
272
 
256
- In parallel runs, a parent-targeted blocking ask waits in its original child execution. Foreground observations may yield so the parent can reply, but active and queued siblings retain their identities and execution capacity. Sends and progress updates never wait for a reply. A single-child launch retains the terminal fresh-child handoff when its exact live owner claims a blocking parent request.
273
+ In parallel runs, a parent-targeted `contact_supervisor` request waits in its original child execution; an `intercom` ask to the parent returns at delivery and its reply arrives as a message. Foreground observations may yield so the parent can reply, but active and queued siblings retain their identities and execution capacity. Sends and progress updates never wait for a reply. A single-child launch retains the terminal fresh-child handoff when its exact live owner claims a blocking parent request.
257
274
 
258
275
  | Parameter | Type | Description |
259
276
  |-----------|------|-------------|
package/docs/skills.md CHANGED
@@ -167,7 +167,9 @@ Toggle skill commands via `/settings` in interactive mode or in `settings.json`:
167
167
 
168
168
  An editable attached stage chat supports the same `/skill:<selector> [arguments]` commands. Its suggestions come from that stage's effective catalog and settings, not the main chat's catalog. Source tags use the main chat format: `[p]` for project, `[u]` for user, and `[t]` for temporary resources, with npm or Git source details when available. After the stage's resources reload, the next completion request reads the updated catalog and qualified aliases.
169
169
 
170
- Stage chat supports `/skill:` discovery and Tab completion of paths relative to its working directory, but not `@` file-mention suggestions.
170
+ Stage chat supports `/skill:` discovery, `@` file-mention suggestions and Tab completion of paths relative to its working directory.
171
+
172
+ A subagent's chat, opened from `/tasks`, completes the same way from the subagent's own skills and working directory. A finished subagent keeps the skills and directory it had when it finished. A `/skill:<selector>` command typed there reaches the subagent expanded from its own skills, as the subagent itself would expand it; a selector that names none of its skills is sent as typed.
171
173
 
172
174
  Enter starts a turn when idle or steers a streaming turn. Ctrl+F keeps follow-up intent. The stage session expands the command once through its admission route; skill-relative references use the skill directory while ordinary tools keep the stage cwd. Turning off `enableSkillCommands` hides suggestions but does not disable manually typed skill commands. Unknown bare selectors pass through as text; unknown or ambiguous qualified selectors and file-read failures show diagnostics in the attached chat without selecting another skill.
173
175
 
package/docs/subagents.md CHANGED
@@ -336,6 +336,8 @@ Transcript inspection shows the child's conversation as a chat, with the same sc
336
336
 
337
337
  A subagent's transcript names the subagent in its prompt's top rule, as `[subagent: subagent-worker-aabcf28b-1]`, the way an attached workflow stage chat shows `[stage: <name>]`. The name is the subagent's Intercom name, or its agent name when it has none. The chat box is the stage chat's: pending messages, the working line and the usage meter sit above the prompt, and the model and folder line and a count of the subagent's own running tasks sit below it. While the subagent runs in this session, the usage meter and model line show its own session (the model line only while the subagent is idle; while it works, that line reads `working`), and a transcript opened mid-turn shows the working line and any messages already queued for it. A subagent that has finished, or runs in another process, shows the task count only. Typing `/tasks` there opens that subagent's own tasks, the shells it ran and the subagents it launched, instead of the parent's. Inside a nested subagent's transcript, `/tasks` lists that subagent's tasks. Escape or Left returns to the subagent's chat. The main chat's `/tasks` still lists every task, including the shells subagents ran.
338
338
 
339
+ The prompt completes as a stage chat's does: `/` offers `/tasks` and the subagent's own `/skill:` commands, and `@` file mentions and Tab complete paths in the subagent's working directory. A skill command reaches the subagent expanded from its own skills, as the subagent would expand it.
340
+
339
341
  Type in a transcript's prompt and press Enter to message the child through its Intercom target, as an Intercom message from your session would. The child records the message, so it appears in the transcript once delivered; a message Intercom refuses or does not confirm stays in the prompt with the reason.
340
342
 
341
343
  Live transcripts refresh streaming text, tool results, and compaction status without reopening. Earlier pages remain anchored, and leaving the view does not affect execution.
@@ -1906,7 +1906,7 @@ function startWorkflowWorkerHost(options: {
1906
1906
  placement?: {
1907
1907
  prefer?(binding: WorkspaceBinding, options: { signal: AbortSignal }): string | undefined | Promise<string | undefined>;
1908
1908
  };
1909
- restore?: ((binding: WorkspaceBinding, options: { signal: AbortSignal; snapshot?: WorktreeSnapshot }) => Promise<string>) | false;
1909
+ restore?: ((binding: WorkspaceBinding, options: { signal: AbortSignal; snapshot?: WorktreeSnapshot }) => Promise<string | RestoredWorkspace>) | false;
1910
1910
  git?: { path: string; env: Record<string, string> };
1911
1911
  }): Promise<WorkflowWorkerHost>;
1912
1912
 
@@ -1920,7 +1920,7 @@ interface WorkflowWorkerHost {
1920
1920
 
1921
1921
  `workspace` binds the root's pooled children to a repository state, identified by its `remotes`, `head`, `tree` and `envHash`. A child started with `ctx.workflow(child, { workspace })` is bound to its own workspace's state instead. A bound child runs only on a host whose `placement.prefer(binding)` returns the path of a worktree with that tree, or on a host that restores it, at the path the restore resolves; never elsewhere, and never on the root's own workers. A child bound with `ctx.workflow(child, { workspace })` runs with its workspace bound to that host's worktree. A cold host can restore a bound tree, the root's or a child's, with its uncommitted, untracked and unpushed content: the root snapshots its own bound worktree when it starts and a child's bound worktree when it dispatches the child, following the root's `snapshots` settings, and the work carries that snapshot. A binding with no worktree on the root's machine, such as a `WorkspaceBinding` alone, restores only from its remotes and from snapshots that checkpoints recorded of that exact tree. If no host that could run it claims it within `claimWindowMs` (default `60000`), it fails with `WorkspaceRestoreUnavailableError`. A child without a binding runs on any host in the root's recorded working directory.
1922
1922
 
1923
- `startWorkflowWorkerHost` serves every running root with shared placement on `journal`, with up to `maxWorkers` workers, for the worker definitions it has at the same paths and entry digest. `labels` and `hostId` (default: an id kept in this machine's Atomic state) name it in the pool's host registry. `restore` makes a binding's tree available on the host and resolves a verified worktree path. `options.snapshot` is the `WorktreeSnapshot` the work carries, when its root captured one. By default the host restores with [`restoreWorktree`](#worktree-snapshots): it rebuilds the tree from that snapshot, or else from the binding's remotes and the worktree snapshots recorded with the same `tree` and `head` in the shared journal, so uncommitted content restores too, into a new worktree under `<agentDir>/worktree-snapshots/worktrees`, and then builds the worktree's blueprints there from that agent directory's global blueprint and a trusted repository's `.atomic/blueprint.yaml`, before the child starts (a blueprint that fails is a warning the host prints, never a reason to refuse the child; a host given its own `restore` builds none; see [Resume on any machine](/guides/resume-on-any-machine)). `restore: false` turns restoring off; such a host takes bound work only where `prefer` finds its tree. A binding whose restore fails waits before the host tries it again, one second after the first failure and twice as long after each further one, up to a minute; while it waits, the host does not count as able to restore it. `git` is how it runs git, as `{ path, env }`. By default it runs the git `resolveGit()` from `@bastani/atomic` resolves: a host given a `restore` function gets a portable git when the machine has none, and any other host never downloads one and restores by default only when it has git. The host's workers find that git first on their `PATH`, with its `env` set, and `prefer` and `restore` receive it as `options.git` for the git commands they run. `stop()` stops its workers at once and puts the children they held back in the queue, without waiting for a `prefer` or `restore` call in flight (the host aborts the `signal` it passed them) or for workers still starting up, which it stops too. `drain()` lets running children finish first; a `stop()` during a drain stops at once. `stats()` returns `{ hostId, labels, git, restore, maxWorkers, workers, busy, roots, lastPlacementFailure?, lastDetach?, lastHealth? }`: `git` is `"system"`, `"provisioned"` (a portable git Atomic downloaded) or `"unavailable"`, `restore` says whether the host takes bound work it does not have warm, and `roots` holds each served root's `SharedPoolStats` (`ready`, `leased`, `completed`, `failed`, `pendingStageInputs`, `hosts` with their workers, the roots they serve and their leases, and `leases` with `renewedAgoMs` and `expiresInMs`). `lastPlacementFailure` is the last `prefer` or `restore` that failed, `lastDetach` why the host last stopped serving a root, and `lastHealth` the last health warning of its workers, such as a worker cleanup it could not confirm.
1923
+ `startWorkflowWorkerHost` serves every running root with shared placement on `journal`, with up to `maxWorkers` workers, for the worker definitions it has at the same paths and entry digest. `labels` and `hostId` (default: an id kept in this machine's Atomic state) name it in the pool's host registry. `restore` makes a binding's tree available on the host and resolves a verified worktree path. `options.snapshot` is the `WorktreeSnapshot` the work carries, when its root captured one. By default the host restores with [`restoreWorktree`](#worktree-snapshots): it rebuilds the tree from that snapshot, or else from the binding's remotes and the worktree snapshots recorded with the same `tree` and `head` in the shared journal, so uncommitted content restores too, into a new worktree under `<agentDir>/worktree-snapshots/worktrees`, and then builds the worktree's blueprints there from that agent directory's global blueprint and a trusted repository's `.atomic/blueprint.yaml`, before the child starts (a blueprint that fails is a warning the host prints, never a reason to refuse the child; a host given its own `restore` builds none; see [Resume on any machine](/guides/resume-on-any-machine)). When the tree cannot be restored exactly, the default restore restores the best state it can reach, as a run's resume does, and resolves `{ path, partial }`: the child runs at `path` and its stages are told `partial.message`. Your own `restore` may resolve the same shape. A restore that gives nothing rejects, and the host backs off from the binding. `restore: false` turns restoring off; such a host takes bound work only where `prefer` finds its tree. A binding whose restore fails waits before the host tries it again, one second after the first failure and twice as long after each further one, up to a minute; while it waits, the host does not count as able to restore it. `git` is how it runs git, as `{ path, env }`. By default it runs the git `resolveGit()` from `@bastani/atomic` resolves: a host given a `restore` function gets a portable git when the machine has none, and any other host never downloads one and restores by default only when it has git. The host's workers find that git first on their `PATH`, with its `env` set, and `prefer` and `restore` receive it as `options.git` for the git commands they run. `stop()` stops its workers at once and puts the children they held back in the queue, without waiting for a `prefer` or `restore` call in flight (the host aborts the `signal` it passed them) or for workers still starting up, which it stops too. `drain()` lets running children finish first; a `stop()` during a drain stops at once. `stats()` returns `{ hostId, labels, git, restore, maxWorkers, workers, busy, roots, lastPlacementFailure?, lastDetach?, lastHealth? }`: `git` is `"system"`, `"provisioned"` (a portable git Atomic downloaded) or `"unavailable"`, `restore` says whether the host takes bound work it does not have warm, and `roots` holds each served root's `SharedPoolStats` (`ready`, `leased`, `completed`, `failed`, `pendingStageInputs`, `hosts` with their workers, the roots they serve and their leases, and `leases` with `renewedAgoMs` and `expiresInMs`). `lastPlacementFailure` is the last `prefer` or `restore` that failed, `lastDetach` why the host last stopped serving a root, and `lastHealth` the last health warning of its workers, such as a worker cleanup it could not confirm.
1924
1924
 
1925
1925
  #### Worker placement errors
1926
1926
 
@@ -2129,7 +2129,7 @@ Supplies runtime adapters, execution policy, persistence, MCP, cancellation, gra
2129
2129
 
2130
2130
  `snapshots` overrides the session's `snapshots` settings for this run. It accepts `enabled`, `includeUntracked`, `maxFileBytes`, `maxSnapshotBytes`, and `fullEvery`. Both `enabled` and `includeUntracked` default to `true`. A checkpoint records its repository snapshot only when Git, a committed repository, and snapshot-capable journal storage are available.
2131
2131
 
2132
- On resume Atomic compares each worktree with its latest recorded snapshot. A worktree whose files match and whose `HEAD` descends from the recorded one (for example after committing the recorded edits) continues in place, and paths reached through symbolic links are compared by the directories they point at. When it differs or is missing, Atomic restores into a fresh worktree under the Atomic home, reports its location, and runs subsequent work there. It never applies a snapshot to the user's existing checkout. `RunSnapshot.worktreeRootMappings` records `{ from, to, snapshotId, tree, restoredAt }`; each stage's `snapshot` summary reports its id, root, head, tree, omitted count and warnings. Restore preserves Git-stored content, not host-specific pre-clean-filter bytes. Files excluded by ignore rules or size limits must be recreated as needed.
2132
+ On resume Atomic compares each worktree with its latest recorded snapshot. A worktree whose files match and whose `HEAD` descends from the recorded one (for example after committing the recorded edits) continues in place, and paths reached through symbolic links are compared by the directories they point at. When it differs or is missing, Atomic restores into a fresh worktree under the Atomic home, reports its location, and runs subsequent work there. It never applies a snapshot to the user's existing checkout. `RunSnapshot.worktreeRootMappings` records `{ from, to, snapshotId, tree, restoredAt, degraded? }`, and `RunSnapshot.worktreeRestoreOutcomes` lists `{ root, snapshotId, message, at, degraded?, unrestored? }` for each checkout the latest resume restored with less than its snapshot or continued without ([Resuming](/worktree-snapshots#resuming)); each stage's `snapshot` summary reports its id, root, head, tree, omitted count and warnings. Restore preserves Git-stored content, not host-specific pre-clean-filter bytes. Files excluded by ignore rules or size limits must be recreated as needed.
2133
2133
 
2134
2134
  From `@bastani/atomic/workflows`, `listWorkflowSnapshotBoundaries(journal, runId)` lists tool and stage boundaries in journal sequence; `workflowSnapshotFrontier(boundaries)` selects the latest for each root. Pass a boundary's `snapshot` and its journal's `snapshotBlobs` to `restoreWorktreeSnapshot` to materialize that boundary explicitly. Atomic collects the content of snapshots that no resumable run or session retains when a root run finishes; see [Retention and collection](/worktree-snapshots#retention-and-collection).
2135
2135
 
@@ -252,7 +252,7 @@ Mounted HIL and custom prompts take precedence: a `/skill:` answer is literal pr
252
252
 
253
253
  If inspection fails, the host displays the error and keeps your input for retry. It does not send the command to the model.
254
254
 
255
- `/tasks` is reserved for local task inspection; stage extensions cannot override it. Tab completes paths relative to the stage cwd; `@` file mentions are unavailable.
255
+ `/tasks` is reserved for local task inspection; stage extensions cannot override it. `@` file mentions and Tab complete paths relative to the stage cwd.
256
256
 
257
257
  ## Monitor and Control Runs
258
258
 
@@ -532,7 +532,7 @@ If recovery reports `Workflow definition not found`, restore the matching defini
532
532
 
533
533
  A run with a live journal lease cannot be claimed by another executor, even when a long-running tool has not updated its progress. After a process crashes and its lease expires (about two minutes without renewal), inspection reports `crashed`. Concurrent resume attempts admit one executor. The same rules apply across machines that share a journal database; see [Sharing storage across hosts](/storage#sharing-storage-across-hosts).
534
534
 
535
- SDK recovery requires the workflow journal, its snapshot blobs, the workflow definition, and the repository's required commits. `session.workflows.getRun(runId)` and `getStages(runId)` inspect saved state without taking ownership; `resume(runId)` explicitly claims eligible work. If the recorded worktree is missing or has drifted, Atomic restores it to a fresh worktree under the Atomic home and reports the new path; your existing checkout is not modified. Save the full UUID. An owning session can also release checkpointed paused runs through `await session.dispose()` or a session switch, allowing another authorized session to adopt them. See [SDK run control](/sdk#workflow-run-control).
535
+ SDK recovery requires the workflow journal, its snapshot blobs, the workflow definition, and the repository's required commits. `session.workflows.getRun(runId)` and `getStages(runId)` inspect saved state without taking ownership; `resume(runId)` explicitly claims eligible work. If the recorded worktree is missing or has drifted, Atomic restores it to a fresh worktree under the Atomic home and reports the new path; your existing checkout is not modified. A resume never fails because a checkout cannot be restored exactly: Atomic restores the best state it can reach, or continues without the checkout, and says so once in the run's notices and on a `checkout:` line of `/workflow status <run-id>`. The run's stages are told the same in their system prompt. Push the missing commits or restore the missing content, then resume again to get the exact state; see [Resuming](/worktree-snapshots#resuming). Save the full UUID. An owning session can also release checkpointed paused runs through `await session.dispose()` or a session switch, allowing another authorized session to adopt them. See [SDK run control](/sdk#workflow-run-control).
536
536
 
537
537
  Snapshots respect Git ignores and `.atomic/snapshot-ignore`, the built-in deny list, and configured size limits. A tracked denied path keeps its `HEAD` version, not its working-copy change. No deny-listed bytes are captured unless they are already in a commit reachable from a remote-tracking ref. If unpushed history touches a denied path, Atomic omits its bundle; push the listed commits before restoring on another host. Ignored build outputs must be rebuilt. Restore verifies Git-stored content, not host-specific worktree encodings; conversion filters and unavailable LFS objects are reported as warnings.
538
538
 
@@ -73,11 +73,11 @@ When a session resumes, Atomic checks every checkout the session recorded a snap
73
73
  - If another checkout drifted, or the checkout that contains the working directory does not exist on this machine, belongs to another clone, or is no longer a repository with commits, Atomic restores its snapshot automatically into a fresh worktree under `~/.atomic/agent/worktree-snapshots/worktrees/`, prints one line per restored checkout, and continues the session there. Your own checkout is never written to. The lines, and any restore warnings, appear at startup and after `/resume` or `/import` in the TUI, and the session records the warnings with each restore.
74
74
  - A checkout other than the one that contains the session's working directory never stops the resume. One the session worked in on this machine (a sibling worktree, for example) that changed since its snapshot continues as it is. One that is missing, or that another clone holds at its path, is restored into a fresh worktree when Git is available. One that cannot be checked or restored is left out, and a warning names its path, its snapshot and why. Each restored worktree then gets its [blueprints](/guides/resume-on-any-machine) built, and a blueprint step that fails never leaves a checkout out or removes its worktree: it is a warning, and the resume continues.
75
75
  - A resume always opens the session with its full conversation. When a checkout's snapshot cannot be restored exactly (its unpushed commits touched denied paths or were too large to record, a remote is unreachable, a blob is missing or damaged, or a change set does not apply), Atomic restores the best state this machine can reach into a fresh worktree, trying in order:
76
- 1. the recorded `HEAD` with the snapshot's change sets that apply, each one whole or not at all, up to the first that does not;
77
- 2. else the commit closest to the recorded `HEAD` that it can fetch from the recorded remotes: the pushed commit the snapshot's unpushed commits were built on, when the bundle is readable, then the commit of an earlier snapshot of the same checkout, then the tip of the recorded branch (the remote's default branch for a detached `HEAD`);
76
+ 1. the recorded `HEAD` with the snapshot's change sets that apply, each one whole or not at all, up to the first that does not. When this machine's checkout filters change the files it writes, the worktree is kept as written, and the notice names the files that differ;
77
+ 2. else the commit closest to the recorded `HEAD` that it can fetch from the recorded remotes: the pushed commit the snapshot's unpushed commits were built on, when the bundle is readable, then the commits of every earlier snapshot of the same checkout, nearest first, then the tip of the recorded branch (the remote's default branch for a detached `HEAD`);
78
78
  3. else nothing: the session continues in its recorded working directory, used as it is and never written to, or, when that directory is not on this machine, in the directory the resume started from. Git being unavailable on this machine, and a session that refers to a snapshot it holds no record of, end here too.
79
79
 
80
- Each such checkout gets one notice, at startup and after `/resume` or `/import`, that says what was restored, what is missing (commits, change sets and the files they touch) and the next step, for example `Restored /work/app into ~/.atomic/agent/worktree-snapshots/worktrees/… at 3f2a9c1d7b04, the tip of branch main on its remote, instead of the recorded commit 8e0b51c2a7d6, the closest commit available here. Not restored: 1 commit (8e0b51c2a7d6) and the snapshot's uncommitted changes of snapshot 5c1d…. Push commit 8e0b51c2a7d6… (with its history) to a recorded remote, then retry.` A resume that restores everything shows no such notice. The session records the outcome on the restore entry (`restore.degraded`) or, when nothing was restored, as an `unrestored` entry, and `/session snapshot` shows it under the checkout. A later snapshot in a partly restored worktree records the tree and commit it holds, never the original snapshot's, so it never presents a partial restore as the original state; the original snapshot stays the checkout's latest until then, and a later resume on a machine that can reach it restores it fully.
80
+ Each such checkout gets one notice, at startup and after `/resume` or `/import`, that says what was restored, what is missing (commits the restored history does not already hold, change sets and the files they touch) and the next step, for example `Restored /work/app into ~/.atomic/agent/worktree-snapshots/worktrees/… at 3f2a9c1d7b04, the tip of branch main on its remote, instead of the recorded commit 8e0b51c2a7d6, the closest commit available here. Not restored: 1 commit (8e0b51c2a7d6) and the snapshot's uncommitted changes of snapshot 5c1d…. Push commit 8e0b51c2a7d6… (with its history) to a recorded remote, then retry.` A resume that restores everything shows no such notice. The session records the outcome on the restore entry (`restore.degraded`) or, when nothing was restored, as an `unrestored` entry, and `/session snapshot` shows it under the checkout. A later snapshot in a partly restored worktree records the tree and commit it holds, never the original snapshot's, so it never presents a partial restore as the original state; the original snapshot stays the checkout's latest until then, and a later resume on a machine that can reach it restores it fully.
81
81
 
82
82
  Only three things refuse a resume: a session that cannot be read, a snapshot record that fails the security checks below (`invalid-snapshot`, for example a remote with credentials or a Git remote helper), and a restore target that holds other files (`unsafe-target`). Restores never write into an existing checkout, and a checkout with uncommitted changes is used only when you choose it. A refused resume fails with that error; in the TUI, a `/resume` or `/import` that fails this way shows the error and keeps the current session.
83
83
 
@@ -95,7 +95,11 @@ Restore fetches never wait for input. On Linux and macOS they run without a term
95
95
 
96
96
  When the repository uses Git LFS, a restore downloads the LFS objects of the snapshot's files, including files edited or added since the recorded `HEAD`, from the recorded remotes, trying each in order until every LFS file has its content; a remote that is a local path is used as a `file://` URL. The download never waits for input either. A file whose object no recorded remote has stays an LFS pointer, and the `lfs-objects-unavailable` warning lists exactly those files. Push the missing objects from the recording machine (`git lfs push --all <remote>` for committed files, `git lfs push --object-id <remote> <oid>` for an uncommitted edit), then restore again.
97
97
 
98
- Workflow runs follow the same rules at the point where execution resumes: each bound worktree is compared once with the last snapshot recorded for it, continues in place when only `HEAD` moved forward over the same tree, and is restored automatically into a fresh worktree when it drifted. A run, stage, or `gitWorktreeDir` path reached through a symbolic link maps to the restored worktree like the path it points at. See [Workflows operations](/workflows/operations).
98
+ Workflow runs follow the same rules at the point where execution resumes: each bound worktree is compared once with the last snapshot recorded for it, continues in place when only `HEAD` moved forward over the same tree, and is restored automatically into a fresh worktree when it drifted. A run, stage, or `gitWorktreeDir` path reached through a symbolic link maps to the restored worktree like the path it points at.
99
+
100
+ A workflow run also always resumes. A checkout it cannot restore exactly goes through the same three steps as a session's: the recorded `HEAD` with the change sets that apply, else the closest commit this machine can fetch (an earlier snapshot of the same checkout in the run counts), else nothing. Git being unavailable ends at the last step. With nothing restored, the run continues in its recorded directory, used as it is and never written to, or, when that directory is not on this machine, in the directory you resumed it from; the run keeps its recorded directory, so a later resume on a machine that has the checkout restores it. Each such checkout gets one warning in the run's notices and one `checkout:` line in `workflow status`, and the run records it as `worktreeRestoreOutcomes` (the worktree mapping also carries `degraded`), so a later resume or a `forkRun` of the run knows the checkout is partial. A partly restored worktree stays reported until a later resume restores that checkout again. The run's stages are told in their system prompt which checkouts hold less than recorded and what is missing. The same three refusals apply: a run or journal that cannot be read, `invalid-snapshot`, and `unsafe-target`.
101
+
102
+ A pooled child on a worker host that must restore its bound tree does the same: when the tree cannot be restored exactly, the host restores the best state it can reach and runs the child there, and the child's stages are told what is missing. When nothing can be restored, the host puts the child back for another host, as before. See [Workflows operations](/workflows/operations).
99
103
 
100
104
  ## Inspecting snapshots
101
105
 
@@ -153,6 +157,8 @@ if (capture.status === "captured" || capture.status === "unchanged") {
153
157
  - `restoreWorktreeSnapshot(bindingOrSnapshot, { into?, blobs?, snapshots?, storeDir?, onWarning?, signal?, git? })` resolves to the path of a new, verified worktree. `git` (`{ path, env }`) runs that Git executable for the restore instead of the one snapshot operations resolve. `into` must be a new or empty directory. A binding is restored from a matching entry of `snapshots`, or from a host whose object store already holds its tree. Restore checks the target and every blob before writing, and removes what it created when it fails. `onWarning` receives `omitted-content`, `filters`, `lfs-objects-unavailable` (LFS files left as pointers), and `stale-restore-retained` (an interrupted earlier restore that could not be cleaned up, with its `kind`).
154
158
  - `restoreDegradedWorktree(snapshot, failure, { blobs?, storeDir?, candidates?, onWarning?, signal?, git? })` restores the best state of `snapshot` this host can reach after `restoreWorktree` rejected with `failure` (a `WorkspaceRestoreError` that `isDegradableRestoreFailure` accepts: `blob-missing`, `blob-corrupt`, `commits-unavailable`, `delta-failed` or `tree-mismatch`), as a resume does: the recorded `HEAD` with the change sets that apply, else the closest commit it can fetch, trying the snapshot's pushed base, then `candidates` (commit ids, nearest first), then the recorded branch's tip. It resolves `{ path, degraded, warnings }`, where `degraded` (`WorktreeDegradedRestore`) says what the worktree holds (`stage`, `head`, `tree`, `basis`) and what is missing (`missingLinks`, `missingPaths`, `missingCommits`, with the failure's `cause` and `hint`). It rejects with `failure` when no commit is reachable, and with `invalid-snapshot` for a record that fails the security checks.
155
159
  - `verifyWorktree(binding, dir, { settings?, signal? })` resolves to the checkout's current binding when its `HEAD` and tree match, and rejects with `WorkspaceDriftError` otherwise.
160
+ - `restoreBestWorktree(snapshot, { blobs?, storeDir?, candidates?, signal?, git? })` runs the whole ladder a resume uses: `restoreWorktree`, then `restoreDegradedWorktree` when that failure allows it. It resolves `{ status: "restored", path, warnings, degraded? }`, or `{ status: "unrestored", reason }` when nothing could be restored (nothing is written then). It rejects only with `invalid-snapshot`, `unsafe-target`, a failure that is not a typed workspace or Git failure, or, after `signal` aborts, the failure the abort caused. `unrestoredRecord(snapshot, reason, continuedIn, place)` builds the `WorktreeUnrestored` record a resume writes for such a checkout.
161
+ - `withWorktreeRestoreNotices(notices, work)` runs `work` so that every session it opens gets a `worktree_restore` system prompt section listing `notices`, one per checkout restored with less than its snapshot or not at all; a workflow run uses it for its stages. `currentWorktreeRestoreNotices()` returns the notices in effect.
156
162
  - `openSessionInWorktree(sessionManager, { settings, storeDir?, signal?, beforeRecord?, pendingMappings?, keepInPlace? })` checks every recorded checkout and restores drifted or missing ones without building blueprints. It resolves `{ sessionManager, notices }` with the session reopened where it continues and one notice per restored checkout, followed by its warnings. `beforeRecord(mappings)` runs once every checkout is restored, with the mappings of the restored ones (none when nothing needed restoring), and before any restore is recorded in the session; when it rejects, nothing is recorded and the restored worktrees are removed. `pendingMappings` names checkouts already here that the session continues in: they count as recorded while deciding what to restore, and are recorded with the restores only when everything succeeded. `keepInPlace` is a set of checkout roots, after the session's recorded restores, to continue in as they are without verifying them. A checkout whose exact restore fails is restored as `restoreDegradedWorktree` does, and recorded with `restore.degraded`; one of which nothing can be restored, or that `cannotRestore` (roots to the reason, such as a `GitUnavailableError`) names, is left out and recorded as `unrestored`, and the session continues in its recorded directory, or in `fallbackCwd` when that is not here. The result lists those in `unrestored`. With `skipMissingRecords`, a checkout whose latest snapshot the session holds no record of is left out and listed in `missingRecords` instead of failing with `snapshot-not-found`. Only `invalid-snapshot`, `unsafe-target`, and failures that are not about a checkout reject. `resumeSessionWorktree` does the same without reopening the session. For normal SDK resume, pass the stored session directly to `createAgentSession({ sessionManager })`, which checks restore prerequisites and builds blueprints as described in [Resume on any machine](/guides/resume-on-any-machine).
157
163
  - `isHeadOnlyAdvance(driftError, signal?)` resolves `true` when a `WorkspaceDriftError` from `verifyWorktree` only moved `HEAD` forward over the recorded tree, the case resume continues in place.
158
164
  - `canonicalizeWorktreePath(path)` resolves the symbolic links in the existing part of a path and keeps the rest, the form snapshot roots are compared in.
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.85",
3
+ "version": "0.9.86-alpha.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.85",
9
+ "version": "0.9.86-alpha.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.85",
13
- "@bastani/pi-ai": "0.9.85",
12
+ "@bastani/atomic-natives": "0.9.86-alpha.1",
13
+ "@bastani/pi-ai": "0.9.86-alpha.1",
14
14
  "@earendil-works/pi-agent-core": "1.5.2",
15
15
  "@earendil-works/pi-codemode": "1.5.2",
16
16
  "@earendil-works/pi-tui": "1.5.2",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.85",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.85.tgz",
430
+ "version": "0.9.86-alpha.1",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.86-alpha.1.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.85",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.85",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.85",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.85",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.85",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.85",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.85",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.85"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.86-alpha.1",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.86-alpha.1",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.86-alpha.1",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.86-alpha.1",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.86-alpha.1",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.86-alpha.1",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.86-alpha.1",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.86-alpha.1"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.85",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.85.tgz",
449
+ "version": "0.9.86-alpha.1",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.86-alpha.1.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.85",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.85.tgz",
461
+ "version": "0.9.86-alpha.1",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.86-alpha.1.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.85",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.85.tgz",
473
+ "version": "0.9.86-alpha.1",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.86-alpha.1.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.85",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.85.tgz",
488
+ "version": "0.9.86-alpha.1",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.86-alpha.1.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.85",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.85.tgz",
503
+ "version": "0.9.86-alpha.1",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.86-alpha.1.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.85",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.85.tgz",
518
+ "version": "0.9.86-alpha.1",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.86-alpha.1.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.85",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.85.tgz",
533
+ "version": "0.9.86-alpha.1",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.86-alpha.1.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.85",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.85.tgz",
545
+ "version": "0.9.86-alpha.1",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.86-alpha.1.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.85",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.85.tgz",
557
+ "version": "0.9.86-alpha.1",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.86-alpha.1.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.85",
3
+ "version": "0.9.86-alpha.1",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -89,8 +89,8 @@
89
89
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
90
90
  },
91
91
  "dependencies": {
92
- "@bastani/atomic-natives": "0.9.85",
93
- "@bastani/pi-ai": "0.9.85",
92
+ "@bastani/atomic-natives": "0.9.86-alpha.1",
93
+ "@bastani/pi-ai": "0.9.86-alpha.1",
94
94
  "@earendil-works/pi-agent-core": "1.5.2",
95
95
  "@earendil-works/pi-codemode": "1.5.2",
96
96
  "@earendil-works/pi-tui": "1.5.2",