@bastani/atomic 0.9.76-alpha.1 → 0.9.77-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 (183) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +13 -0
  3. package/dist/builtin/intercom/broker/broker.ts +153 -6
  4. package/dist/builtin/intercom/broker/client.ts +85 -3
  5. package/dist/builtin/intercom/broker/departed-children.ts +471 -0
  6. package/dist/builtin/intercom/broker/recipient-gone-errors.ts +280 -0
  7. package/dist/builtin/intercom/broker/restoring-recipients.ts +108 -7
  8. package/dist/builtin/intercom/broker/send-handler.ts +42 -0
  9. package/dist/builtin/intercom/broker/workflow-stage-aliases.ts +69 -0
  10. package/dist/builtin/intercom/index.bundle.mjs +374 -129
  11. package/dist/builtin/intercom/package.json +2 -2
  12. package/dist/builtin/intercom/types.ts +30 -1
  13. package/dist/builtin/mcp/package.json +1 -1
  14. package/dist/builtin/subagents/CHANGELOG.md +15 -0
  15. package/dist/builtin/subagents/README.md +1 -1
  16. package/dist/builtin/subagents/package.json +3 -3
  17. package/dist/builtin/subagents/skills/agent-browser/SKILL.md +1 -1
  18. package/dist/builtin/subagents/src/extension/index.bundle.mjs +64 -4
  19. package/dist/builtin/web-access/package.json +2 -2
  20. package/dist/builtin/workflows/CHANGELOG.md +14 -0
  21. package/dist/builtin/workflows/README.md +1 -1
  22. package/dist/builtin/workflows/package.json +2 -2
  23. package/dist/builtin/workflows/skills/impeccable/SKILL.md +3 -3
  24. package/dist/builtin/workflows/skills/impeccable/scripts/VERSION +1 -1
  25. package/dist/builtin/workflows/skills/impeccable/scripts/engine-checksums.txt +5 -5
  26. package/dist/builtin/workflows/skills/impeccable/scripts/live-browser.js +71 -56
  27. package/dist/builtin/workflows/src/extension/index.bundle.mjs +315 -112
  28. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +168 -9
  29. package/dist/builtin/workflows/src/index.js +168 -9
  30. package/dist/builtin/workflows/src/local-worker-entry.mjs +168 -9
  31. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  32. package/dist/core/agent-session-compaction.js +2 -1
  33. package/dist/core/agent-session-compaction.js.map +1 -1
  34. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  35. package/dist/core/agent-session-extension-bindings.js +2 -0
  36. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  37. package/dist/core/agent-session-methods.d.ts +1 -0
  38. package/dist/core/agent-session-methods.d.ts.map +1 -1
  39. package/dist/core/agent-session-methods.js.map +1 -1
  40. package/dist/core/agent-session-state.d.ts.map +1 -1
  41. package/dist/core/agent-session-state.js +7 -2
  42. package/dist/core/agent-session-state.js.map +1 -1
  43. package/dist/core/agent-session-tasks.d.ts +6 -0
  44. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  45. package/dist/core/agent-session-tasks.js +13 -25
  46. package/dist/core/agent-session-tasks.js.map +1 -1
  47. package/dist/core/agent-session-types.d.ts +2 -0
  48. package/dist/core/agent-session-types.d.ts.map +1 -1
  49. package/dist/core/agent-session-types.js.map +1 -1
  50. package/dist/core/agent-session.d.ts +1 -0
  51. package/dist/core/agent-session.d.ts.map +1 -1
  52. package/dist/core/agent-session.js +2 -0
  53. package/dist/core/agent-session.js.map +1 -1
  54. package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
  55. package/dist/core/extensions/loader-rollback.js +1 -0
  56. package/dist/core/extensions/loader-rollback.js.map +1 -1
  57. package/dist/core/extensions/runner-context.d.ts +3 -3
  58. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  59. package/dist/core/extensions/runner-context.js +2 -1
  60. package/dist/core/extensions/runner-context.js.map +1 -1
  61. package/dist/core/extensions/runner.d.ts +9 -0
  62. package/dist/core/extensions/runner.d.ts.map +1 -1
  63. package/dist/core/extensions/runner.js +16 -1
  64. package/dist/core/extensions/runner.js.map +1 -1
  65. package/dist/core/sdk-types.d.ts +5 -0
  66. package/dist/core/sdk-types.d.ts.map +1 -1
  67. package/dist/core/sdk-types.js.map +1 -1
  68. package/dist/core/sdk.d.ts.map +1 -1
  69. package/dist/core/sdk.js +8 -1
  70. package/dist/core/sdk.js.map +1 -1
  71. package/dist/core/system-prompt.d.ts +6 -0
  72. package/dist/core/system-prompt.d.ts.map +1 -1
  73. package/dist/core/system-prompt.js +26 -18
  74. package/dist/core/system-prompt.js.map +1 -1
  75. package/dist/core/tasks/agent-adapter.js +2 -2
  76. package/dist/core/tasks/agent-adapter.js.map +1 -1
  77. package/dist/core/tasks/cancel-reason.d.ts +20 -0
  78. package/dist/core/tasks/cancel-reason.d.ts.map +1 -0
  79. package/dist/core/tasks/cancel-reason.js +47 -0
  80. package/dist/core/tasks/cancel-reason.js.map +1 -0
  81. package/dist/core/tasks/child-command-owner.d.ts +1 -1
  82. package/dist/core/tasks/child-command-owner.d.ts.map +1 -1
  83. package/dist/core/tasks/child-command-owner.js +22 -0
  84. package/dist/core/tasks/child-command-owner.js.map +1 -1
  85. package/dist/core/tasks/completion-message.d.ts +11 -0
  86. package/dist/core/tasks/completion-message.d.ts.map +1 -0
  87. package/dist/core/tasks/completion-message.js +30 -0
  88. package/dist/core/tasks/completion-message.js.map +1 -0
  89. package/dist/core/tasks/completion.d.ts +2 -0
  90. package/dist/core/tasks/completion.d.ts.map +1 -1
  91. package/dist/core/tasks/completion.js +30 -14
  92. package/dist/core/tasks/completion.js.map +1 -1
  93. package/dist/core/tasks/contracts.d.ts +4 -0
  94. package/dist/core/tasks/contracts.d.ts.map +1 -1
  95. package/dist/core/tasks/contracts.js.map +1 -1
  96. package/dist/core/tasks/supervisor.d.ts +29 -3
  97. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  98. package/dist/core/tasks/supervisor.js +48 -25
  99. package/dist/core/tasks/supervisor.js.map +1 -1
  100. package/dist/core/tasks/task-view-source.d.ts +6 -0
  101. package/dist/core/tasks/task-view-source.d.ts.map +1 -1
  102. package/dist/core/tasks/task-view-source.js +49 -0
  103. package/dist/core/tasks/task-view-source.js.map +1 -1
  104. package/dist/core/tools/bash-pty-native.d.ts +6 -1
  105. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  106. package/dist/core/tools/bash-pty-native.js +5 -1
  107. package/dist/core/tools/bash-pty-native.js.map +1 -1
  108. package/dist/core/tools/bash.d.ts +5 -0
  109. package/dist/core/tools/bash.d.ts.map +1 -1
  110. package/dist/core/tools/bash.js +14 -5
  111. package/dist/core/tools/bash.js.map +1 -1
  112. package/dist/core/tools/history-protocol.d.ts +15 -1
  113. package/dist/core/tools/history-protocol.d.ts.map +1 -1
  114. package/dist/core/tools/history-protocol.js +9 -7
  115. package/dist/core/tools/history-protocol.js.map +1 -1
  116. package/dist/core/tools/shell-task-status.d.ts.map +1 -1
  117. package/dist/core/tools/shell-task-status.js +3 -13
  118. package/dist/core/tools/shell-task-status.js.map +1 -1
  119. package/dist/core/workflow-stage-admission.d.ts +2 -0
  120. package/dist/core/workflow-stage-admission.d.ts.map +1 -1
  121. package/dist/core/workflow-stage-admission.js +36 -6
  122. package/dist/core/workflow-stage-admission.js.map +1 -1
  123. package/dist/index.d.ts +1 -1
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +2 -2
  126. package/dist/index.js.map +1 -1
  127. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  128. package/dist/modes/interactive/components/chat-session-host-rendering.js +12 -8
  129. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  130. package/dist/modes/interactive/components/chat-session-host-state.d.ts +2 -0
  131. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  132. package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
  133. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  134. package/dist/modes/interactive/components/chat-session-host-types.d.ts +6 -0
  135. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  136. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  137. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  138. package/dist/modes/interactive/components/chat-session-host.js +5 -2
  139. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  140. package/dist/modes/interactive/components/footer.d.ts +8 -5
  141. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  142. package/dist/modes/interactive/components/footer.js +5 -2
  143. package/dist/modes/interactive/components/footer.js.map +1 -1
  144. package/dist/modes/interactive/components/index.d.ts +1 -0
  145. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  146. package/dist/modes/interactive/components/index.js +1 -0
  147. package/dist/modes/interactive/components/index.js.map +1 -1
  148. package/dist/modes/interactive/components/input-label.d.ts +29 -0
  149. package/dist/modes/interactive/components/input-label.d.ts.map +1 -0
  150. package/dist/modes/interactive/components/input-label.js +75 -0
  151. package/dist/modes/interactive/components/input-label.js.map +1 -0
  152. package/dist/modes/interactive/components/task-inspector.d.ts +4 -1
  153. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  154. package/dist/modes/interactive/components/task-inspector.js +6 -2
  155. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  156. package/dist/modes/interactive/components/task-transcript-page.d.ts +12 -1
  157. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  158. package/dist/modes/interactive/components/task-transcript-page.js +63 -6
  159. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  160. package/dist/modes/interactive/interactive-input-handling.js +1 -0
  161. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  162. package/dist/modes/interactive/interactive-slash-commands.js +1 -0
  163. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  164. package/dist/modes/interactive-engine/engine-session-stats.d.ts +1 -1
  165. package/dist/modes/interactive-engine/engine-session-stats.d.ts.map +1 -1
  166. package/dist/modes/interactive-engine/engine-session-stats.js.map +1 -1
  167. package/dist/modes/rpc/task-ui-bridge.d.ts +2 -2
  168. package/dist/modes/rpc/task-ui-bridge.d.ts.map +1 -1
  169. package/dist/modes/rpc/task-ui-bridge.js +2 -0
  170. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  171. package/docs/background-tasks.md +14 -1
  172. package/docs/getting-started/first-session.md +1 -1
  173. package/docs/intercom/operations.md +4 -2
  174. package/docs/intercom/reference.md +18 -1
  175. package/docs/llama-cpp.md +1 -1
  176. package/docs/sessions.md +1 -1
  177. package/docs/subagents.md +5 -1
  178. package/docs/tools.md +1 -1
  179. package/docs/usage.md +1 -12
  180. package/docs/workflows/operations.md +3 -1
  181. package/docs/workflows/verification.md +1 -8
  182. package/npm-shrinkwrap.json +83 -98
  183. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.9.76-alpha.1",
3
+ "version": "0.9.77-alpha.1",
4
4
  "private": true,
5
5
  "description": "Atomic extension providing a private coordination channel between parent and child agent sessions. Fork of: https://github.com/nicobailon/pi-intercom",
6
6
  "contributors": [
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@bastani/atomic": "*",
47
- "@earendil-works/pi-tui": "^1.5.1",
47
+ "@earendil-works/pi-tui": "^1.5.2",
48
48
  "typebox": "*"
49
49
  },
50
50
  "peerDependenciesMeta": {
@@ -1,4 +1,9 @@
1
1
  import type { LiveWorkflowStageRouteRefusalCode } from "./live-route-refusal.js";
2
+ import type {
3
+ IntercomRecipientGoneErrorCode,
4
+ SerializedIntercomRecipientGoneError,
5
+ SubagentEndedOutcome,
6
+ } from "./broker/recipient-gone-errors.js";
2
7
  import type { SerializedIntercomReleasedReplyError } from "./broker/released-reply-errors.js";
3
8
 
4
9
  export interface SessionInfo {
@@ -154,13 +159,25 @@ export type ReleasedReplyRefusalCode = "released_reply_answered" | "released_rep
154
159
  * Why a send or ask was refused, for callers that branch on it; the free-text `reason` stays for people.
155
160
  * `recipient_not_restored`: the sender was held for a subagent that was being restored or woken, and the hold ended
156
161
  * first. `recipient_parked`: the subagent's owner keeps it parked (paused or quit) and never wakes it for a send.
162
+ * The `IntercomRecipientGoneErrorCode`s (#4639) reach a client only inside `delivery_failed.recipientError`, never as
163
+ * its wire `reasonCode`, which older clients validate against the codes they know.
157
164
  */
158
165
  export type DeliveryFailureReasonCode =
159
166
  | "message_id_conflict"
160
167
  | "session_not_found"
161
168
  | "recipient_not_restored"
162
169
  | "recipient_parked"
163
- | ReleasedReplyRefusalCode;
170
+ | ReleasedReplyRefusalCode
171
+ | IntercomRecipientGoneErrorCode;
172
+
173
+ /** One subagent in a `mark_ended_children` frame: its owner reports how its last run ended (#4639). */
174
+ export interface EndedChildFrame {
175
+ childName: string;
176
+ group?: string;
177
+ aliases?: string[];
178
+ outcome: SubagentEndedOutcome;
179
+ childId?: string;
180
+ }
164
181
 
165
182
  /** One released subagent in a `reserve_released_children` frame. */
166
183
  export interface ReleasedChildReservationFrame {
@@ -279,6 +296,11 @@ export type ClientMessage =
279
296
  | { type: "reserve_released_children"; requestId: string; children: ReleasedChildReservationFrame[] }
280
297
  /** #4326: end the reservations this connection made for these child names. */
281
298
  | { type: "drop_released_children"; requestId: string; childNames: string[]; gone?: string; refusal?: string }
299
+ /**
300
+ * #4639: this connection reports how subagents it launched ended, so a send to one with no live session is refused
301
+ * with why and what to do next. Sent only to a broker that advertised `marksEndedChildren`.
302
+ */
303
+ | { type: "mark_ended_children"; requestId: string; children: EndedChildFrame[] }
282
304
  /** #4326: the owner is waking this child; the broker extends the sends held for it once per wake. */
283
305
  | { type: "acknowledge_released_child_wake"; requestId: string; childName: string }
284
306
  /** #4326: the owner answers one `released_child_reply` handoff; an ack that names another handoff is ignored. */
@@ -390,6 +412,8 @@ export type BrokerMessage =
390
412
  claimsWorkflowInvocations?: true;
391
413
  /** #3983: this broker accepts `saving`; absent on older brokers, which drop a client that sends it. */
392
414
  extendsSaves?: true;
415
+ /** #4639: this broker accepts `mark_ended_children`; absent on older brokers, which drop a client that sends it. */
416
+ marksEndedChildren?: true;
393
417
  /** Broker routing mode at registration, for deciding whether a reply wait may release. */
394
418
  multiNodeRouting?: BrokerMultiNodeStatus["status"];
395
419
  /** #4538: the wire protocol versions this broker accepts; absent on brokers of protocol 1. */
@@ -458,6 +482,11 @@ export type BrokerMessage =
458
482
  attemptId?: string;
459
483
  /** #4386: the typed refusal of a reply to a released subagent; its `code` equals `reasonCode`. */
460
484
  error?: SerializedIntercomReleasedReplyError;
485
+ /**
486
+ * #4639: why a subagent with no live session is gone. Carried apart from `error` and `reasonCode`, which older
487
+ * clients validate strictly; they read only `reason`, which is this error's message.
488
+ */
489
+ recipientError?: SerializedIntercomRecipientGoneError;
461
490
  }
462
491
  | { type: "broker_status"; requestId: string; report: BrokerStatusReport }
463
492
  | { type: "shutdown_ack"; requestId: string };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.9.76-alpha.1",
3
+ "version": "0.9.77-alpha.1",
4
4
  "private": true,
5
5
  "description": "Atomic's pi-compatible MCP integration for server connections, OAuth, tools, resources, and terminal management.",
6
6
  "contributors": [
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.77-alpha.1] - 2026-11-11
6
+
7
+ Delegation guidance uses session memory, and messages to ended subagents say how to continue them.
8
+
9
+ - **Memory-informed delegation.** Orchestration guidance weighs earlier sessions, workflow runs and your stated preferences when choosing between a workflow and inline work ([#4648](https://github.com/bastani-inc/atomic/issues/4648), [#4649](https://github.com/bastani-inc/atomic/pull/4649)).
10
+ - **Resumable ended subagents.** An Intercom send to a subagent that finished, failed or was stopped explains how it ended and which `subagent({ action: "resume" })` call continues it ([#4639](https://github.com/bastani-inc/atomic/issues/4639), [#4650](https://github.com/bastani-inc/atomic/pull/4650)).
11
+
12
+ ### Changed
13
+
14
+ - The subagent orchestration guidance now refines the choice between a workflow and inline work with session memory (`history://` sessions and workflow runs) and your stated preferences ([#4648](https://github.com/bastani-inc/atomic/issues/4648))
15
+
16
+ ### Fixed
17
+
18
+ - Fixed Intercom sends to a subagent that completed, failed, was stopped or was cancelled answering `Session not found`: the session that launched it now reports how it ended, so the sender is told why and which `subagent({ action: "resume", id, message })` call continues it ([#4639](https://github.com/bastani-inc/atomic/issues/4639))
19
+
5
20
  ## [0.9.75] - 2026-11-10
6
21
 
7
22
  Woken subagents build blueprints, and the bundled computer-use skills are current.
@@ -304,7 +304,7 @@ Set `disabled: true` to hide a builtin from runtime discovery and agent-facing `
304
304
 
305
305
  ### Prompt assembly
306
306
 
307
- Subagents are designed to be narrow by default. Custom agents start with a clean system prompt and only the context you intentionally give them. They do not automatically inherit Pi’s whole base prompt, project instruction files, or discovered skills catalog.
307
+ Subagents are designed to be narrow by default. Custom agents start with a clean system prompt and only the context you intentionally give them. They do not automatically inherit Pi’s whole base prompt, project instruction files, or discovered skills catalog. An agent with the `read` tool keeps one part of the base prompt, the Session memory guidance, and recalls the project's earlier sessions and workflow runs through `history://` like the session that launched it.
308
308
 
309
309
  Use these fields when an agent should see more:
310
310
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.9.76-alpha.1",
3
+ "version": "0.9.77-alpha.1",
4
4
  "private": true,
5
5
  "description": "Atomic extension for delegating tasks to subagents with parallel execution. Fork of: https://github.com/nicobailon/pi-subagents",
6
6
  "contributors": [
@@ -35,8 +35,8 @@
35
35
  "peerDependencies": {
36
36
  "@bastani/atomic": "*",
37
37
  "@bastani/pi-ai": "*",
38
- "@earendil-works/pi-agent-core": "^1.5.1",
39
- "@earendil-works/pi-tui": "^1.5.1",
38
+ "@earendil-works/pi-agent-core": "^1.5.2",
39
+ "@earendil-works/pi-tui": "^1.5.2",
40
40
  "typebox": "*"
41
41
  },
42
42
  "peerDependenciesMeta": {
@@ -4,7 +4,7 @@ description: Browser automation CLI for AI agents. Use when the user needs to in
4
4
  hidden: true
5
5
  metadata:
6
6
  github-path: skills/agent-browser
7
- github-ref: refs/tags/v0.41.2
7
+ github-ref: refs/tags/v0.42.0
8
8
  github-repo: https://github.com/vercel-labs/agent-browser
9
9
  github-tree-sha: 29ba9c12789b1c54ab76ad40e2472e646d141b85
10
10
  name: agent-browser
@@ -10788,6 +10788,7 @@ function findSubagentChildRecord(records, id) {
10788
10788
  var SUBAGENT_RESERVE_RELEASED_CHILDREN_EVENT = "subagent:reserve-released-children";
10789
10789
  var SUBAGENT_ACKNOWLEDGE_RELEASED_CHILD_WAKE_EVENT = "subagent:acknowledge-released-child-wake";
10790
10790
  var INTERCOM_CONNECTED_EVENT = "intercom:connected";
10791
+ var SUBAGENT_MARK_ENDED_CHILDREN_EVENT = "subagent:mark-ended-children";
10791
10792
  var SUBAGENT_HOLD_FAILURE_EVENT = "subagent:released-child-hold-failure";
10792
10793
  var SUBAGENT_HOLD_RECOVERED_EVENT = "subagent:released-child-hold-recovered";
10793
10794
  function closedOwnerSession(error) {
@@ -10827,6 +10828,30 @@ function releasedChildReservation(record) {
10827
10828
  wake: released
10828
10829
  };
10829
10830
  }
10831
+ var ENDED_OUTCOMES = new Map([
10832
+ ["ok", "completed"],
10833
+ ["error", "failed"],
10834
+ ["interrupted", "stopped"],
10835
+ ["paused", "stopped"],
10836
+ ["quit", "stopped"],
10837
+ [SUBAGENT_CHILD_STAGE_PAUSED_STATUS, "stopped"],
10838
+ ["killed", "cancelled"],
10839
+ [SUBAGENT_CHILD_STAGE_CLOSED_STATUS, "cancelled"]
10840
+ ]);
10841
+ function endedChildMark(record) {
10842
+ if (record.intercomTarget === undefined || record.state !== "terminal")
10843
+ return;
10844
+ const outcome = ENDED_OUTCOMES.get(record.terminalStatus);
10845
+ if (outcome === undefined || releasedChildReservation(record) !== undefined)
10846
+ return;
10847
+ return {
10848
+ childName: record.intercomTarget,
10849
+ ...record.intercomGroup === undefined ? {} : { group: record.intercomGroup },
10850
+ aliases: [record.childSessionId, record.releasedIntercomId].filter((id) => id !== undefined),
10851
+ outcome,
10852
+ childId: record.childId
10853
+ };
10854
+ }
10830
10855
  async function emitIntercomRequest(events, eventName, request) {
10831
10856
  events.emit(eventName, request);
10832
10857
  await (request.completion ?? Promise.resolve());
@@ -10841,6 +10866,24 @@ function reserveReleasedChildren(events, children) {
10841
10866
  function acknowledgeReleasedChildWake(events, childName) {
10842
10867
  return emitIntercomRequest(events, SUBAGENT_ACKNOWLEDGE_RELEASED_CHILD_WAKE_EVENT, { childName }).catch((error) => recordHoldFailure(events, [childName], error));
10843
10868
  }
10869
+ function markEndedChildren(events, children) {
10870
+ if (children.length === 0)
10871
+ return Promise.resolve();
10872
+ return emitIntercomRequest(events, SUBAGENT_MARK_ENDED_CHILDREN_EVENT, { children }).catch((error) => {
10873
+ if (closedOwnerSession(error))
10874
+ return;
10875
+ console.error(`Subagent end report failed (${children.map((child) => child.childName).join(", ")}); sends to them answer Session not found: ${error.message}`);
10876
+ });
10877
+ }
10878
+ function markEndedChildrenOf(events, ownerSessionId) {
10879
+ const marks = [];
10880
+ for (const record of subagentChildRecordsOf(ownerSessionId)) {
10881
+ const mark = endedChildMark(record);
10882
+ if (mark !== undefined)
10883
+ marks.push(mark);
10884
+ }
10885
+ return markEndedChildren(events, marks);
10886
+ }
10844
10887
  function reserveReleasedChildrenOf(events, ownerSessionId) {
10845
10888
  const reservations = [];
10846
10889
  for (const record of subagentChildRecordsOf(ownerSessionId)) {
@@ -11841,6 +11884,9 @@ function taskTranscriptSource(session, runId, intercomTarget, intercomEvents) {
11841
11884
  ...session.subscribe ? { subscribe: session.subscribe.bind(session) } : {},
11842
11885
  ...session.getStreamingMessage ? { getStreamingMessage: session.getStreamingMessage.bind(session) } : {},
11843
11886
  ...session.getCompactionReason ? { getCompactionReason: session.getCompactionReason.bind(session) } : {},
11887
+ ...session.chatSession ? { chatSession: session.chatSession } : {},
11888
+ ...session.isRunning ? { isRunning: session.isRunning.bind(session) } : {},
11889
+ ...session.getQueuedMessages ? { getQueuedMessages: session.getQueuedMessages.bind(session) } : {},
11844
11890
  ...intercomTarget === undefined ? {} : { completionSource: { runId, intercomTarget } },
11845
11891
  ...intercomTarget === undefined || intercomEvents === undefined ? {} : { sendMessage: (text) => sendTaskTranscriptMessage(intercomEvents, intercomTarget, text) }
11846
11892
  };
@@ -11893,7 +11939,7 @@ async function runAgentTask(input) {
11893
11939
  const forked = input.forked ?? (input.options.sessionManager !== undefined && input.options.resumeSession !== true);
11894
11940
  const recordChildTask = (taskId, state, terminalStatus, heldMessages, launch, waitingOn, releasedIntercomId) => {
11895
11941
  const worktree = runWorktreeRecord(input.options.runId, input.options.index ?? 0);
11896
- input.recordChild?.record({
11942
+ const record = {
11897
11943
  runId: input.options.runId,
11898
11944
  index: input.options.index ?? 0,
11899
11945
  agent: input.agent,
@@ -11916,7 +11962,14 @@ async function runAgentTask(input) {
11916
11962
  ...launch ? { launch } : heldMessages?.taskExpands && input.options.resumeSession !== true && childSession.childSessionId === undefined ? { launch: subagentChildLaunch(input.task, input.intentTask, input.options) } : {},
11917
11963
  inherited: subagentChildInheritance(input.options),
11918
11964
  ...subagentChildModelChoice(input.options, agentConfig)
11919
- });
11965
+ };
11966
+ input.recordChild?.record(record);
11967
+ const events = input.options.intercomEvents;
11968
+ if (input.recordChild !== undefined && events !== undefined) {
11969
+ const ended = endedChildMark({ ...record, childId: subagentChildId(record.runId, record.index) });
11970
+ if (ended !== undefined)
11971
+ markEndedChildren(events, [ended]);
11972
+ }
11920
11973
  };
11921
11974
  let dispatched = false;
11922
11975
  let admittedTaskId;
@@ -14779,7 +14832,13 @@ class SubagentControlRuntime {
14779
14832
  getEntries: () => sessionManager.getEntries(),
14780
14833
  subscribe: (listener) => transcriptSession.subscribe(listener),
14781
14834
  getStreamingMessage: () => observedStreamingMessage,
14782
- getCompactionReason: compactionReasonReader(transcriptSession)
14835
+ getCompactionReason: compactionReasonReader(transcriptSession),
14836
+ chatSession: transcriptSession,
14837
+ isRunning: () => transcriptSession.isStreaming,
14838
+ getQueuedMessages: () => ({
14839
+ steering: transcriptSession.getSteeringMessages(),
14840
+ followUp: transcriptSession.getFollowUpMessages()
14841
+ })
14783
14842
  });
14784
14843
  const initialModelId = modelIdForSession(session) ?? candidateModelId;
14785
14844
  effectiveModelId = initialModelId;
@@ -17130,6 +17189,7 @@ function bindReleasedChildWakes(deps, ctx, events, dispatcher = agentWakeDispatc
17130
17189
  const reserveAll = () => {
17131
17190
  indexSubagentChildOwner(ctx);
17132
17191
  reserveReleasedChildrenOf(events, ownerSessionId);
17192
+ markEndedChildrenOf(events, ownerSessionId);
17133
17193
  };
17134
17194
  reserveAll();
17135
17195
  const restore = async (record, request) => {
@@ -21681,7 +21741,7 @@ function parseSubagentNotifyContent(content) {
21681
21741
  var DEFAULT_PROMPT_GUIDANCE = [
21682
21742
  `**Subagent orchestration**: Use subagents for focused specialist work inside workflows or as bounded delegation when a workflow would be unnecessary overhead.
21683
21743
  - Unless the user explicitly chooses inline execution for the specified task, workflows are the default for non-trivial structured work with verifiable objectives; use a workflow for implementation, review, or retry pipelines and let its stages delegate specialists.
21684
- - When the workflow tool is available, decide yourself whether a workflow fits. Prefer one for well-defined work that benefits from durable stages, review loops, recovery or approval gates; work inline for discussion, unclear goals, tiny deterministic low-risk edits, or when the user asks to work inline or quickly. Judge the task's shape first and refine with execution history and user preferences; no workflow history, or history of only inline runs, does not mean every task should run inline. Launch with workflow run using the registered workflow name and inputs matching its contract.
21744
+ - When the workflow tool is available, decide yourself whether a workflow fits. Prefer one for well-defined work that benefits from durable stages, review loops, recovery or approval gates; work inline for discussion, unclear goals, tiny deterministic low-risk edits, or when the user asks to work inline or quickly. Judge the task's shape first and refine with session memory (\`history://\` sessions and workflow runs) and the user's stated preferences; no workflow history, or history of only inline runs, does not mean every task should run inline. Launch with workflow run using the registered workflow name and inputs matching its contract.
21685
21745
  - Honor the user's task-scoped execution preferences without hidden/nested workflows or pressure to reapprove. Preserve appropriate testing, review and evidence inline, and unrelated safety and authorization constraints.
21686
21746
  - On a switch from an active workflow to inline, notify the controlling session to safely hold/stop the affected run, reconcile completed work and in-flight side effects, then continue inline without duplicate execution. Do not claim completed work was undone.
21687
21747
  - Use a single subagent for a focused specialty or parallel tasks for independent work. Keep substantial-overlap tasks together rather than duplicating investigation across agents.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.9.76-alpha.1",
3
+ "version": "0.9.77-alpha.1",
4
4
  "private": true,
5
5
  "description": "Atomic extension for web search, URL fetching, GitHub repo cloning, PDF/video extraction. Fork of: https://github.com/nicobailon/pi-web-access",
6
6
  "contributors": [
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@bastani/atomic": "*",
34
- "@earendil-works/pi-tui": "^1.5.1"
34
+ "@earendil-works/pi-tui": "^1.5.2"
35
35
  },
36
36
  "peerDependenciesMeta": {
37
37
  "@bastani/atomic": {
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.77-alpha.1] - 2026-11-11
10
+
11
+ The workflow page explains stalled runs, and the bundled Impeccable skill is current.
12
+
13
+ - **Blocked, paused and resumed runs.** The `/workflow` page, graph widget, stage switcher, status and connect picker show why no more stages appear, including the blocked reason and a count of blocked stages ([#4643](https://github.com/bastani-inc/atomic/issues/4643), [#4645](https://github.com/bastani-inc/atomic/pull/4645)).
14
+ - **Memory-informed workflow choice.** The `workflow` tool's guidance weighs session memory and your stated preferences when choosing between a workflow and inline work ([#4648](https://github.com/bastani-inc/atomic/issues/4648), [#4649](https://github.com/bastani-inc/atomic/pull/4649)).
15
+ - **Impeccable 4.8.2.** Live Mode keeps accepted variants styled and fonts intact, and `generate-image` honors `OPENAI_BASE_URL` ([#4644](https://github.com/bastani-inc/atomic/pull/4644)).
16
+
17
+ ### Changed
18
+
19
+ - Updated the bundled Impeccable skill to 4.8.2 with engine 0.1.21. In Live Mode, accepting a variant on a page without hot reload keeps it styled until you reload, and variants accepted in different sessions no longer pick up each other's styles. Live captures keep the page's fonts when a font URL has no file extension, when a font face comes from an `@import` or a matching `@media` or `@supports` rule, and when a cross-origin stylesheet redirects. `generate-image` sends its requests, with your `OPENAI_API_KEY`, to `OPENAI_BASE_URL` when that variable is set. Atomic's telemetry and update-check defaults remain off.
20
+ - The `/workflow` graph page now says why no more stages appear and when they will again. Its header puts the run's state before the stage counts and colors the ORCHESTRATOR pill to match: `↑ blocked` with the exit reason when the workflow gave one (shortened to fit), `❚❚ paused`, `○ quit`, or `● resumed` while a resumed run is live. It also counts blocked stages as `↑ N`. The compact graph widget, the stage switcher, `/workflow status` and the `/workflow connect` picker show the same state, and the picker now marks a quit run `○ quit` like `/workflow status` instead of `❚❚` ([#4643](https://github.com/bastani-inc/atomic/issues/4643))
21
+ - The `workflow` tool's guidance now refines the choice between a workflow and inline work with session memory (`history://` sessions and workflow runs) and your stated preferences ([#4648](https://github.com/bastani-inc/atomic/issues/4648))
22
+
9
23
  ## [0.9.75] - 2026-11-10
10
24
 
11
25
  Workflow stages report suspension clearly, design runs get reference images, and resumes build blueprints.
@@ -860,7 +860,7 @@ The live session is unbounded: accepted variants and steered edits are written i
860
860
 
861
861
  The session starts at `user-feedback-N-start`; durable `live-poll-N-M` and `live-reply-N-M` tool nodes own polling and acknowledgements, while `live-generate-*`, `live-steer-*`, `live-manual_edit_apply-*`, and `live-variant_mount_failed-*` mint model stages. Replies pass the event id before the status. Successful `variant_mounted` events are journal-only; `accept`, `discard`, and `prefetch` mint no model stage, and `timeout` is absorbed in the poll node. Nonzero helper exits fail the run rather than looking like timeouts. No `<artifact_dir>/feedback/` directory or per-session record is written.
862
862
 
863
- The poll and reply nodes run the bundled Impeccable 4.8.1 launcher (`skills/impeccable/scripts/impeccable`, or `impeccable.cmd` on Windows) with the `live-poll` verb; the launcher runs the engine binary beside it or downloads and checksum-verifies the pinned engine release on first use, so a machine without network access needs `IMPECCABLE_BIN` pointed at a preinstalled engine. Live sessions persist the selected app root for every helper and support SvelteKit, Nuxt, TanStack Start, Astro, Next.js, Vite, and static HTML injection.
863
+ The poll and reply nodes run the bundled Impeccable 4.8.2 launcher (`skills/impeccable/scripts/impeccable`, or `impeccable.cmd` on Windows) with the `live-poll` verb; the launcher runs the engine binary beside it or downloads and checksum-verifies the pinned engine release on first use, so a machine without network access needs `IMPECCABLE_BIN` pointed at a preinstalled engine. Live sessions persist the selected app root for every helper and support SvelteKit, Nuxt, TanStack Start, Astro, Next.js, Vite, and static HTML injection.
864
864
 
865
865
  Research context moves between stages as artifact files, not inline prompt payloads: the project design context is written to `<artifact_dir>/design-context.md` and the curated references brief to `<artifact_dir>/references.md`; `reference-discovery`, `generate-1`, and `exporter` read the required files via `reads`.
866
866
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.76-alpha.1",
3
+ "version": "0.9.77-alpha.1",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -87,7 +87,7 @@
87
87
  "peerDependencies": {
88
88
  "@bastani/atomic": "*",
89
89
  "@bastani/atomic-natives": "*",
90
- "@earendil-works/pi-tui": "^1.5.1",
90
+ "@earendil-works/pi-tui": "^1.5.2",
91
91
  "typebox": "*"
92
92
  },
93
93
  "peerDependenciesMeta": {
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: impeccable
3
3
  description: "Use when the user wants to design, redesign, shape, critique, audit, polish, simplify, harden, animate, or otherwise improve a frontend interface: websites, landing pages, dashboards, product UI, components, forms, settings, onboarding, empty states, and native iOS or Android screens. Handles UX review, hierarchy, layout, typography, color, motion, UX copy, accessibility, responsive behavior, edge cases, and capturing or documenting design systems (DESIGN.md, tokens). Also for making bland UI bolder, loud UI quieter, or ambitious visual effects. Not for backend-only or non-UI tasks."
4
- version: 4.8.1
4
+ version: 4.8.2
5
5
  license: Apache 2.0
6
6
  metadata:
7
7
  github-repo: https://github.com/pbakaus/impeccable
8
8
  github-path: .pi/skills/impeccable
9
- github-ref: refs/tags/skill-v4.8.1
10
- github-tree-sha: 33f5053739cd5a746d74a30d891e0da61b3f9829
9
+ github-ref: refs/tags/skill-v4.8.2
10
+ github-tree-sha: 130fde11eff1474bfa3b3efb82a3f206e350e0f9
11
11
  allowed-tools:
12
12
  - Bash(npx impeccable *)
13
13
  - Bash(.pi/skills/impeccable/scripts/impeccable *)
@@ -1 +1 @@
1
- 0.1.19
1
+ 0.1.21
@@ -2,8 +2,8 @@
2
2
  # The launchers, the npm shim, `impeccable install` and scripts/fetch-engine.mjs verify
3
3
  # every engine download against this file. Written by
4
4
  # `node scripts/check-engine-release.mjs --record` after each engine release.
5
- 0.1.19 impeccable-darwin-arm64 c35d0b0b250afceb5ab6ee7edfe190a04d76d25c56bac01935a7a1b06d0df818
6
- 0.1.19 impeccable-darwin-x64 df7c2b9cec89df54d1d9722a35aecc48b965dfad190c4ec2e766ce3f7743a544
7
- 0.1.19 impeccable-linux-x64 07b763dc00012e9acf219fe2d2e8980f0810fb8af2e4a41c090107a8351d412f
8
- 0.1.19 impeccable-linux-arm64 73b5662e42f060aba716016c34a7274cc49a998cd0d5da8b84a95d9e4edea729
9
- 0.1.19 impeccable-windows-x64.exe 30427e0cfea383a0adbc5cc554481c3f18337eeabcc4eaf7d9bb48ad2e8b5676
5
+ 0.1.21 impeccable-darwin-arm64 086fd22e54c445a0e792f66d2f168e35ec93f7c59054e1fde539d0d95b01ce41
6
+ 0.1.21 impeccable-darwin-x64 bbcd4307b4dd7e0c8a3a264b880b5d73ae1971cc1d219677b6f7e044b9f05eb7
7
+ 0.1.21 impeccable-linux-x64 579a0b6ff639ed28812ae632c556b6524a5b7d13fff4227cd3095a65554415b6
8
+ 0.1.21 impeccable-linux-arm64 e2cda6ac3eefb1cdd51d147f6e897a19c773fe7bbfbdbd1361eef744d4137080
9
+ 0.1.21 impeccable-windows-x64.exe 4cb1d921315e51ace39af5abbfd2e1be3c8624fcfc5074539f43ba894777fece
@@ -8724,17 +8724,15 @@
8724
8724
  const urlRe = /url\((['"]?)(https?:\/\/[^'")\s]+)\1\)/g;
8725
8725
  const urls = new Set();
8726
8726
  let m;
8727
- while ((m = urlRe.exec(cssText))) {
8728
- if (FONT_EXT_RE.test(m[2])) urls.add(m[2]);
8729
- }
8727
+ while ((m = urlRe.exec(cssText))) urls.add(m[2]);
8730
8728
  const map = new Map();
8731
8729
  await Promise.all([...urls].map(async (url) => {
8732
8730
  try {
8733
8731
  const res = await fetch(url);
8734
8732
  if (!res.ok) return;
8735
8733
  const buf = await res.arrayBuffer();
8736
- const ext = url.toLowerCase().match(FONT_EXT_RE)?.[1] || 'woff2';
8737
- const mime = FONT_MIME[ext] || 'application/octet-stream';
8734
+ const ext = url.toLowerCase().match(FONT_EXT_RE)?.[1];
8735
+ const mime = FONT_MIME[ext] || res.headers.get('content-type')?.split(';')[0].trim() || 'application/octet-stream';
8738
8736
  map.set(url, 'data:' + mime + ';base64,' + bufferToBase64(buf));
8739
8737
  } catch { /* skip; fall through to URL */ }
8740
8738
  }));
@@ -8743,27 +8741,42 @@
8743
8741
  return data ? 'url(' + q + data + q + ')' : orig;
8744
8742
  });
8745
8743
  }
8744
+ // Walks a stylesheet or grouping rule in cascade order. The result is embedded
8745
+ // without its conditional wrappers, so faces behind a false @media or @supports stay out.
8746
+ async function collectFontFaces(source, base, chunks) {
8747
+ let rules;
8748
+ try {
8749
+ rules = source.cssRules;
8750
+ } catch {
8751
+ if (!source.href) return;
8752
+ try {
8753
+ const res = await fetch(source.href);
8754
+ if (!res.ok) return;
8755
+ const parsed = new CSSStyleSheet();
8756
+ parsed.replaceSync(await res.text());
8757
+ // res.url is the base the browser used if the sheet redirected.
8758
+ await collectFontFaces(parsed, res.url || source.href, chunks);
8759
+ } catch { /* ignore; capture is best-effort */ }
8760
+ return;
8761
+ }
8762
+ for (const rule of rules) {
8763
+ if (rule.constructor.name === 'CSSFontFaceRule' || rule.cssText?.startsWith('@font-face')) {
8764
+ chunks.push(absolutizeUrls(rule.cssText, base));
8765
+ } else if (rule.media && !window.matchMedia(rule.media.mediaText).matches) {
8766
+ continue;
8767
+ } else if (rule.constructor.name === 'CSSSupportsRule' && !CSS.supports(rule.conditionText)) {
8768
+ continue;
8769
+ } else if (rule.styleSheet) {
8770
+ await collectFontFaces(rule.styleSheet, rule.styleSheet.href, chunks);
8771
+ } else if (rule.cssRules) {
8772
+ await collectFontFaces(rule, base, chunks);
8773
+ }
8774
+ }
8775
+ }
8746
8776
  async function collectFontCssText() {
8747
8777
  const chunks = [];
8748
- const fontFaceRe = /@font-face\s*\{[^}]*\}/g;
8749
8778
  for (const sheet of document.styleSheets) {
8750
- try {
8751
- const rules = sheet.cssRules;
8752
- for (const rule of rules) {
8753
- if (rule.constructor.name === 'CSSFontFaceRule' || rule.cssText?.startsWith('@font-face')) {
8754
- chunks.push(absolutizeUrls(rule.cssText, sheet.href || document.baseURI));
8755
- }
8756
- }
8757
- } catch {
8758
- if (!sheet.href) continue;
8759
- try {
8760
- const res = await fetch(sheet.href);
8761
- if (!res.ok) continue;
8762
- const text = await res.text();
8763
- let m2;
8764
- while ((m2 = fontFaceRe.exec(text))) chunks.push(absolutizeUrls(m2[0], sheet.href));
8765
- } catch { /* ignore; capture is best-effort */ }
8766
- }
8779
+ await collectFontFaces(sheet, sheet.href || document.baseURI, chunks);
8767
8780
  }
8768
8781
  if (chunks.length === 0) return '';
8769
8782
  return inlineFontUrls(chunks.join('\n'));
@@ -9480,8 +9493,8 @@ void main() {
9480
9493
  // (all other variants are display:none). HMR from the source rewrite will
9481
9494
  // replace the wrapper imminently. Don't eagerly replaceChild here - React
9482
9495
  // reconciliation races with our mutation and throws NotFoundError in Next
9483
- // 16 / Turbopack. Schedule a fallback that runs the manual swap only if
9484
- // HMR hasn't cleaned up by then (keeps static-server flows working).
9496
+ // 16 / Turbopack. A page without HMR commits in scheduleAcceptCleanup;
9497
+ // framework pages get a deferred fallback in case HMR misses the update.
9485
9498
  const acceptedSessionId = currentSessionId;
9486
9499
  const acceptedVariant = visibleVariant;
9487
9500
  const acceptedIsSvelteComponent = svelteComponentSession?.sessionId === acceptedSessionId
@@ -9494,6 +9507,7 @@ void main() {
9494
9507
  id: acceptedSessionId,
9495
9508
  variant: String(acceptedVariant),
9496
9509
  isSvelteComponent: acceptedIsSvelteComponent,
9510
+ paramValues: { ...paramsCurrentValues },
9497
9511
  ...acceptedSnapshot,
9498
9512
  finalizing: false,
9499
9513
  };
@@ -9550,6 +9564,12 @@ void main() {
9550
9564
  // Pick → Go loop while carbonize finishes in the background.
9551
9565
  if (accepted?.isSvelteComponent) {
9552
9566
  commitAcceptedSvelteComponentToDom(accepted.id);
9567
+ } else {
9568
+ // A page with no HMR never swaps the wrapper, and the variant-state
9569
+ // stylesheet goes away below, so commit now or the original and the
9570
+ // other variants show.
9571
+ const wrapper = findVariantsWrapper(accepted.id);
9572
+ if (wrapper && !hasFrameworkHmrOwnership(wrapper)) commitAcceptedVariantToDom(wrapper, accepted);
9553
9573
  }
9554
9574
  cleanupAcceptedSession();
9555
9575
  });
@@ -9600,7 +9620,6 @@ void main() {
9600
9620
  if (deferredRecoverySuperseded(pending?.id, recoveryRevision)) return;
9601
9621
  if (acceptedDomAlreadyClean(pending)) return;
9602
9622
  const sessionId = pending?.id;
9603
- const variantId = pending?.variant;
9604
9623
  const wrappers = findAcceptedRuntimeWrappers(sessionId);
9605
9624
  if (hasFrameworkHmrOwnership(wrappers[0] || pending?.parentElement)) {
9606
9625
  // Vite can coalesce rapid scaffold/carbonize writes and leave the last
@@ -9618,18 +9637,7 @@ void main() {
9618
9637
  return;
9619
9638
  }
9620
9639
  for (const wrapper of wrappers) {
9621
- if (!wrapper?.isConnected) continue;
9622
- const accepted = wrapper.querySelector?.('[data-impeccable-variant="' + variantId + '"]');
9623
- if (!accepted) {
9624
- wrapper.remove();
9625
- continue;
9626
- }
9627
- const parent = wrapper.parentElement;
9628
- if (!parent) continue;
9629
- while (accepted.firstChild) {
9630
- parent.insertBefore(accepted.firstChild, wrapper);
9631
- }
9632
- wrapper.remove();
9640
+ if (wrapper?.isConnected) commitAcceptedVariantToDom(wrapper, pending);
9633
9641
  }
9634
9642
  if (!acceptedDomAlreadyClean(pending)) restoreAcceptedDomFromSnapshot(pending, recoveryRevision);
9635
9643
  }
@@ -9695,26 +9703,33 @@ void main() {
9695
9703
  setLiveState('PICKING');
9696
9704
  }
9697
9705
 
9698
- function commitAcceptedVariantToDom(sessionId, variantId) {
9699
- const wrapper = findVariantsWrapper(sessionId);
9700
- if (!wrapper) return false;
9701
- const accepted = wrapper.querySelector('[data-impeccable-variant="' + variantId + '"]');
9702
- if (!accepted || !accepted.firstElementChild) return false;
9703
- const parent = wrapper.parentElement;
9704
- if (!parent) return false;
9706
+ function scopeAcceptedCss(css, pending) {
9707
+ return css.replace(/\[\s*data-impeccable-variant\s*=\s*(["']?)([^"'\]\s]+)\1\s*(?:[is]\s*)?\]/gi, (_, __, variant) => (
9708
+ '[data-impeccable-accepted="' + pending.id + (variant === pending.variant ? '' : ':' + variant) + '"]'
9709
+ ));
9710
+ }
9705
9711
 
9706
- const style = wrapper.querySelector('style[data-impeccable-css]');
9707
- if (style && !document.querySelector('style[data-impeccable-accepted-css="' + sessionId + '"]')) {
9708
- const promotedStyle = style.cloneNode(true);
9709
- promotedStyle.setAttribute('data-impeccable-accepted-css', sessionId);
9710
- parent.insertBefore(promotedStyle, wrapper);
9712
+ // Keeps the accepted look until reload: the style, then a display: contents
9713
+ // shell carrying the tuned --p-* values. Variant numbers repeat across
9714
+ // sessions, so the shell and its rules move to a per-session attribute that
9715
+ // a later session's variants and CSS cannot match.
9716
+ function commitAcceptedVariantToDom(wrapper, pending) {
9717
+ const parent = wrapper.parentElement;
9718
+ if (!parent) return;
9719
+ const accepted = wrapper.querySelector('[data-impeccable-variant="' + pending.variant + '"]');
9720
+ if (accepted) {
9721
+ const style = wrapper.querySelector('style[data-impeccable-css]');
9722
+ if (style) {
9723
+ style.textContent = scopeAcceptedCss(style.textContent, pending);
9724
+ parent.insertBefore(style, wrapper);
9725
+ }
9726
+ accepted.removeAttribute('data-impeccable-variant');
9727
+ accepted.setAttribute('data-impeccable-accepted', pending.id);
9728
+ accepted.style.display = 'contents';
9729
+ accepted.style.cssText += variantParamDecls(pending.paramValues);
9730
+ parent.insertBefore(accepted, wrapper);
9711
9731
  }
9712
-
9713
- const committed = accepted.cloneNode(true);
9714
- committed.removeAttribute('hidden');
9715
- committed.style.display = 'contents';
9716
- parent.replaceChild(committed, wrapper);
9717
- return true;
9732
+ wrapper.remove();
9718
9733
  }
9719
9734
 
9720
9735
  function handleDiscard() {