@bastani/atomic 0.9.85 → 0.9.86

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 +40 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +34 -0
  3. package/dist/builtin/intercom/README.md +10 -9
  4. package/dist/builtin/intercom/broker/away-asks.ts +272 -0
  5. package/dist/builtin/intercom/broker/broker.ts +171 -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 +124 -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 +40 -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 +24 -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
@@ -8174,6 +8174,7 @@ class JournalProjection {
8174
8174
  ...handle.repositoryRoot !== undefined ? { repositoryRoot: handle.repositoryRoot } : existing?.handle.repositoryRoot !== undefined ? { repositoryRoot: existing.handle.repositoryRoot } : {},
8175
8175
  ...handle.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: handle.gitWorktreeRoot } : existing?.handle.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: existing.handle.gitWorktreeRoot } : {},
8176
8176
  ...(handle.worktreeRootMappings ?? existing?.handle.worktreeRootMappings) !== undefined ? { worktreeRootMappings: handle.worktreeRootMappings ?? existing?.handle.worktreeRootMappings } : {},
8177
+ ...(handle.worktreeRestoreOutcomes ?? existing?.handle.worktreeRestoreOutcomes) !== undefined ? { worktreeRestoreOutcomes: handle.worktreeRestoreOutcomes ?? existing?.handle.worktreeRestoreOutcomes } : {},
8177
8178
  pendingStageMessages: handle.pendingStageMessages ?? existing?.handle.pendingStageMessages ?? [],
8178
8179
  ...handle.possibleStages !== undefined ? { possibleStages: handle.possibleStages } : existing?.handle.possibleStages !== undefined ? { possibleStages: existing.handle.possibleStages } : {},
8179
8180
  ...forkedFrom !== undefined ? { forkedFrom } : {},
@@ -8472,6 +8473,7 @@ class JournalProjection {
8472
8473
  ...h.gitWorktreeRoot !== undefined ? { gitWorktreeRoot: h.gitWorktreeRoot } : {},
8473
8474
  ...h.snapshots !== undefined ? { snapshots: h.snapshots } : {},
8474
8475
  ...h.worktreeRootMappings !== undefined ? { worktreeRootMappings: h.worktreeRootMappings } : {},
8476
+ ...h.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: h.worktreeRestoreOutcomes } : {},
8475
8477
  ...h.forkedFrom !== undefined ? { forkedFrom: h.forkedFrom } : {},
8476
8478
  ...h.workspace !== undefined ? { workspace: h.workspace } : {},
8477
8479
  ...h.snapshot !== undefined ? { snapshot: h.snapshot } : {},
@@ -12079,14 +12081,20 @@ var init_sqlite_run_journal = __esm(() => {
12079
12081
  });
12080
12082
 
12081
12083
  // dist/builtin/workflows/src/durable/worktree-snapshots.ts
12082
- import { isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
12084
+ import { existsSync as existsSync2 } from "node:fs";
12085
+ import { isAbsolute as isAbsolute2, join as join4, relative, resolve as resolve2, sep } from "node:path";
12083
12086
  import {
12084
12087
  canonicalizeWorktreePath,
12088
+ formatDegradedRestoreNotice,
12089
+ formatUnrestoredNotice,
12090
+ isGitUnavailableError,
12085
12091
  isHeadOnlyAdvance,
12086
12092
  isWorkspaceDriftError,
12093
+ isWorkspaceRestoreError,
12087
12094
  isWorkspaceSnapshotError,
12088
12095
  removeRestoredWorktree,
12089
- restoreWorktree,
12096
+ restoreBestWorktree,
12097
+ unrestoredRecord,
12090
12098
  verifyWorktree,
12091
12099
  WorkspaceDriftError
12092
12100
  } from "@bastani/atomic";
@@ -12164,13 +12172,26 @@ function originalRoot(root, mappings) {
12164
12172
  }
12165
12173
  return root;
12166
12174
  }
12175
+ function earlierBoundaryHeads(boundaries, root, mappings, snapshot) {
12176
+ const heads = [];
12177
+ for (const boundary of [...boundaries].reverse()) {
12178
+ if (originalRoot(boundary.root, mappings) !== root)
12179
+ continue;
12180
+ const head = boundary.snapshot.head;
12181
+ if (head !== snapshot.head && !heads.includes(head))
12182
+ heads.push(head);
12183
+ }
12184
+ return heads;
12185
+ }
12167
12186
  async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
12168
12187
  const mappings = options.mappings ?? [];
12188
+ const boundaries = await listWorkflowSnapshotBoundaries(journal, runId);
12169
12189
  const latest = new Map;
12170
- for (const boundary of await listWorkflowSnapshotBoundaries(journal, runId)) {
12190
+ for (const boundary of boundaries) {
12171
12191
  latest.set(originalRoot(boundary.root, mappings), boundary);
12172
12192
  }
12173
12193
  const restored = [];
12194
+ const unrestored = [];
12174
12195
  const announcements = [];
12175
12196
  try {
12176
12197
  for (const [root, { snapshot }] of latest) {
@@ -12181,11 +12202,16 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
12181
12202
  await verifyWorktree(snapshot, mapped, { settings: options.settings, signal: options.signal });
12182
12203
  continue;
12183
12204
  } catch (error) {
12205
+ options.signal?.throwIfAborted();
12206
+ if (isGitUnavailableError(error)) {
12207
+ unrestored.push({ root, here: mapped, snapshot, reason: error });
12208
+ continue;
12209
+ }
12184
12210
  if (isWorkspaceDriftError(error) && await isHeadOnlyAdvance(error, options.signal))
12185
12211
  continue;
12186
12212
  if (isWorkspaceDriftError(error))
12187
12213
  drift = error;
12188
- else if (isWorkspaceSnapshotError(error)) {
12214
+ else if (isWorkspaceSnapshotError(error) || isWorkspaceRestoreError(error)) {
12189
12215
  drift = new WorkspaceDriftError({
12190
12216
  root: mapped,
12191
12217
  expectedHead: snapshot.head,
@@ -12199,11 +12225,17 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
12199
12225
  }
12200
12226
  let worktree;
12201
12227
  try {
12202
- worktree = await restoreWorktree(snapshot, {
12228
+ const best = await restoreBestWorktree(snapshot, {
12203
12229
  blobs: journal.snapshotBlobs,
12204
12230
  storeDir: options.storeDir,
12205
- signal: options.signal
12231
+ signal: options.signal,
12232
+ candidates: earlierBoundaryHeads(boundaries, root, mappings, snapshot)
12206
12233
  });
12234
+ if (best.status === "unrestored") {
12235
+ unrestored.push({ root, here: mapped, snapshot, reason: best.reason });
12236
+ continue;
12237
+ }
12238
+ worktree = best;
12207
12239
  } catch (cause) {
12208
12240
  options.signal?.throwIfAborted();
12209
12241
  throw new WorkspaceDriftError({
@@ -12221,7 +12253,8 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
12221
12253
  to: worktree.path,
12222
12254
  snapshotId: snapshot.id,
12223
12255
  tree: snapshot.tree,
12224
- restoredAt: new Date().toISOString()
12256
+ restoredAt: new Date().toISOString(),
12257
+ ...worktree.degraded === undefined ? {} : { degraded: worktree.degraded }
12225
12258
  };
12226
12259
  restored.push(mapping);
12227
12260
  announcements.push({ mapping, warnings: worktree.warnings });
@@ -12251,8 +12284,52 @@ async function resolveWorkflowSnapshotFrontier(journal, runId, options = {}) {
12251
12284
  for (const warning of warnings)
12252
12285
  options.onWarning?.(warning, mapping);
12253
12286
  }
12287
+ for (const checkout of unrestored)
12288
+ options.onUnrestored?.(checkout);
12254
12289
  return restored;
12255
12290
  }
12291
+ function within(root, path) {
12292
+ const suffix = relative(root, path);
12293
+ return suffix !== ".." && !suffix.startsWith(`..${sep}`) && !isAbsolute2(suffix);
12294
+ }
12295
+ function runWorktreeRestoreOutcomes(input) {
12296
+ const list = [];
12297
+ for (const mapping of input.restored) {
12298
+ if (mapping.degraded === undefined)
12299
+ continue;
12300
+ list.push({
12301
+ root: mapping.from,
12302
+ snapshotId: mapping.snapshotId,
12303
+ message: formatDegradedRestoreNotice(mapping, input.snapshots.get(mapping.snapshotId), [], "workflow run"),
12304
+ at: mapping.restoredAt,
12305
+ degraded: mapping.degraded
12306
+ });
12307
+ }
12308
+ const { continuing, launchCwd } = input;
12309
+ const leftHere = continuing !== undefined && input.unrestored.some((checkout) => within(canonicalizeWorktreePath(checkout.here), canonicalizeWorktreePath(continuing)));
12310
+ const launch = leftHere && launchCwd !== undefined && !existsSync2(continuing);
12311
+ const continuedIn = launch ? resolve2(launchCwd) : undefined;
12312
+ for (const checkout of input.unrestored) {
12313
+ const record = unrestoredRecord(checkout.snapshot, checkout.reason, continuedIn ?? continuing ?? checkout.here, launch ? "launch" : "recorded");
12314
+ list.push({
12315
+ root: checkout.root,
12316
+ snapshotId: checkout.snapshot.id,
12317
+ message: formatUnrestoredNotice(checkout.root, record, "workflow run"),
12318
+ at: record.at,
12319
+ unrestored: record
12320
+ });
12321
+ }
12322
+ const fresh = [...list];
12323
+ const touched = new Set(list.map((outcome) => outcome.root));
12324
+ for (const outcome of input.previous) {
12325
+ if (outcome.degraded === undefined || touched.has(outcome.root))
12326
+ continue;
12327
+ const current = input.mappings.findLast((mapping) => mapping.from === outcome.root);
12328
+ if (current?.degraded !== undefined && current.snapshotId === outcome.snapshotId)
12329
+ list.push(outcome);
12330
+ }
12331
+ return continuedIn === undefined ? { list, fresh } : { list, fresh, continuedIn };
12332
+ }
12256
12333
  var init_worktree_snapshots = __esm(() => {
12257
12334
  init_types();
12258
12335
  });
@@ -16573,7 +16650,7 @@ var init_child_invocation = __esm(() => {
16573
16650
  });
16574
16651
 
16575
16652
  // dist/builtin/workflows/src/engine/run-resume-preflight.ts
16576
- import { existsSync as existsSync2 } from "node:fs";
16653
+ import { existsSync as existsSync3 } from "node:fs";
16577
16654
  import { isAbsolute as isAbsolute3 } from "node:path";
16578
16655
  import { JsonlSessionStore as JsonlSessionStore2, resolveSessionStore as resolveSessionStore2 } from "@bastani/atomic";
16579
16656
  function describeStore(store, selectedBy) {
@@ -16609,7 +16686,7 @@ async function assertWaitingStageSessionsExist(waiting, runId, storage, rootRunI
16609
16686
  checked.add(stage.sessionId);
16610
16687
  if (await opened.store.readHeader(stage.sessionId) !== undefined)
16611
16688
  continue;
16612
- if (stage.sessionFile !== undefined && isAbsolute3(stage.sessionFile) && existsSync2(stage.sessionFile))
16689
+ if (stage.sessionFile !== undefined && isAbsolute3(stage.sessionFile) && existsSync3(stage.sessionFile))
16613
16690
  continue;
16614
16691
  missing.push(stage.sessionId);
16615
16692
  }
@@ -20256,24 +20333,11 @@ var init_factory = __esm(() => {
20256
20333
  });
20257
20334
 
20258
20335
  // dist/builtin/workflows/src/durable/run-restore-preconditions.ts
20259
- import {
20260
- runRestorePreconditionError,
20261
- worktreeNeedsRestore
20262
- } from "@bastani/atomic";
20263
- async function runRestorePreconditionFailure(journal, runId, mappings, settings, signal) {
20264
- const restoring = [];
20265
- for (const boundary of workflowSnapshotFrontier(await listWorkflowSnapshotBoundaries(journal, runId))) {
20266
- const here = mapWorkflowWorktreePath(boundary.root, mappings);
20267
- if (await worktreeNeedsRestore(boundary.snapshot, here, { settings, signal })) {
20268
- restoring.push({ root: boundary.root, remotes: boundary.snapshot.remotes });
20269
- }
20270
- }
20271
- return await runRestorePreconditionError(runId, restoring);
20272
- }
20273
- var restorePreconditionsChecked;
20336
+ var restorePreconditionsChecked, resumeLaunchCwd, recordedInvocationCwd;
20274
20337
  var init_run_restore_preconditions = __esm(() => {
20275
- init_worktree_snapshots();
20276
20338
  restorePreconditionsChecked = Symbol("restore-preconditions-checked");
20339
+ resumeLaunchCwd = Symbol("resume-launch-cwd");
20340
+ recordedInvocationCwd = Symbol("recorded-invocation-cwd");
20277
20341
  });
20278
20342
 
20279
20343
  // dist/builtin/workflows/src/durable/run-result.ts
@@ -20482,11 +20546,11 @@ async function transitionDurableWorkflowStatus(backend, workflowId, expectedStat
20482
20546
  }
20483
20547
 
20484
20548
  // dist/builtin/workflows/src/durable/worktree-snapshot-recorder.ts
20485
- import { isAbsolute as isAbsolute4, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
20549
+ import { isAbsolute as isAbsolute4, relative as relative2, resolve as resolve3, sep as sep2 } from "node:path";
20486
20550
  import {
20487
20551
  canonicalizeWorktreePath as canonicalizeWorktreePath2,
20488
20552
  captureWorktreeSnapshot,
20489
- isGitUnavailableError,
20553
+ isGitUnavailableError as isGitUnavailableError2,
20490
20554
  isWorkspaceGitError,
20491
20555
  serializeWorkspaceError,
20492
20556
  WorkspaceSnapshotError
@@ -20534,7 +20598,7 @@ function containsDirectory(root, directory) {
20534
20598
  function createWorkflowSnapshotRecorder(input) {
20535
20599
  let gitUnavailable = false;
20536
20600
  const report = (error) => {
20537
- if (isGitUnavailableError(error))
20601
+ if (isGitUnavailableError2(error))
20538
20602
  gitUnavailable = true;
20539
20603
  input.run.snapshotUnavailable ??= serializeWorkspaceError(error);
20540
20604
  };
@@ -20551,8 +20615,8 @@ function createWorkflowSnapshotRecorder(input) {
20551
20615
  signal?.throwIfAborted();
20552
20616
  const latest = await snapshotAncestry(journal, input.rootRunId);
20553
20617
  const snapshots = [];
20554
- const workflowCwd = resolve2(input.cwd());
20555
- for (const directory of new Set([workflowCwd, ...directories.map((path) => resolve2(workflowCwd, path))])) {
20618
+ const workflowCwd = resolve3(input.cwd());
20619
+ for (const directory of new Set([workflowCwd, ...directories.map((path) => resolve3(workflowCwd, path))])) {
20556
20620
  try {
20557
20621
  const physical = canonicalizeWorktreePath2(directory);
20558
20622
  const previous = [...latest.values()].filter((snapshot) => containsDirectory(snapshot.root, physical)).sort((a, b) => b.root.length - a.root.length)[0];
@@ -20606,7 +20670,7 @@ var init_workflow_artifact_env = __esm(() => {
20606
20670
 
20607
20671
  // dist/builtin/workflows/src/shared/workflow-artifacts.ts
20608
20672
  import { randomUUID as randomUUID7 } from "node:crypto";
20609
- import { existsSync as existsSync3 } from "node:fs";
20673
+ import { existsSync as existsSync4 } from "node:fs";
20610
20674
  import { mkdir, readdir, rm, stat } from "node:fs/promises";
20611
20675
  import { dirname as dirname4, join as join6 } from "node:path";
20612
20676
  import { getAgentDir as getAgentDir5, getEnvValue } from "@bastani/atomic";
@@ -20657,7 +20721,7 @@ function workflowRunArtifactsIntact(run, sessionRuns = store.runs()) {
20657
20721
  const ownerIds = workflowRunReferencedArtifactOwnerIds(run, sessionRuns);
20658
20722
  if (ownerIds.length === 0)
20659
20723
  return;
20660
- return ownerIds.every((ownerId) => existsSync3(workflowArtifactRunPath(ownerId)));
20724
+ return ownerIds.every((ownerId) => existsSync4(workflowArtifactRunPath(ownerId)));
20661
20725
  }
20662
20726
  function workflowRunResumeCandidate(run, sessionRuns = store.runs(), backend) {
20663
20727
  backend = availableRunDurableBackend(sessionRuns, run.id) ?? backend;
@@ -21048,7 +21112,7 @@ import {
21048
21112
  createChildProcessEnvironment,
21049
21113
  createGitEnvironment,
21050
21114
  isGitProvisionError as isGitProvisionError2,
21051
- isGitUnavailableError as isGitUnavailableError2,
21115
+ isGitUnavailableError as isGitUnavailableError3,
21052
21116
  isRetryableGitProvisionError,
21053
21117
  resolveGit,
21054
21118
  resolveGitSync
@@ -21101,7 +21165,7 @@ async function prepareTaskGit(signal) {
21101
21165
  resolveGitSync();
21102
21166
  return;
21103
21167
  } catch (error) {
21104
- const notInstalled = isGitUnavailableError2(error) && error.code === "not-installed";
21168
+ const notInstalled = isGitUnavailableError3(error) && error.code === "not-installed";
21105
21169
  if (!isGitProvisionError2(error) || !(notInstalled || isRetryableGitProvisionError(error)))
21106
21170
  return;
21107
21171
  }
@@ -22405,7 +22469,7 @@ var init_worktree = __esm(() => {
22405
22469
 
22406
22470
  // dist/builtin/workflows/src/runs/shared/worktree-cwd.ts
22407
22471
  import { lstatSync as lstatSync6, realpathSync as realpathSync4 } from "node:fs";
22408
- import { dirname as dirname10, isAbsolute as isAbsolute9, relative as relative6, resolve as resolve9, sep as sep7 } from "node:path";
22472
+ import { dirname as dirname10, isAbsolute as isAbsolute9, relative as relative6, resolve as resolve10, sep as sep7 } from "node:path";
22409
22473
  function relativePathWithin(root, candidate) {
22410
22474
  const path = relative6(root, candidate);
22411
22475
  return path === ".." || path.startsWith(`..${sep7}`) || isAbsolute9(path) ? undefined : path;
@@ -22424,14 +22488,14 @@ function resolveWorktreeStageCwd(cwd, setup) {
22424
22488
  if (cwd === undefined || cwd.length === 0)
22425
22489
  return;
22426
22490
  const absoluteInput = isAbsolute9(cwd);
22427
- const candidate = absoluteInput ? cwd : resolve9(setup.cwd, cwd);
22491
+ const candidate = absoluteInput ? cwd : resolve10(setup.cwd, cwd);
22428
22492
  if (!absoluteInput && relativePathWithin(setup.worktreeRoot, candidate) === undefined) {
22429
22493
  throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a cwd inside the worktree.`);
22430
22494
  }
22431
22495
  const candidateRealPath = existingRealPath(candidate, "cwd");
22432
22496
  const worktreeRelative = relativePathWithin(worktreeRoot, candidateRealPath);
22433
22497
  if (worktreeRelative !== undefined)
22434
- return resolve9(setup.worktreeRoot, worktreeRelative);
22498
+ return resolve10(setup.worktreeRoot, worktreeRelative);
22435
22499
  if (!isAbsolute9(cwd)) {
22436
22500
  throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a path that remains inside the selected worktree.`);
22437
22501
  }
@@ -22442,7 +22506,7 @@ function resolveWorktreeStageCwd(cwd, setup) {
22442
22506
  if (repositoryRelative === undefined) {
22443
22507
  throw new Error(repositoryRoot === worktreeRoot ? `atomic-workflows: cwd ${cwd} is outside gitWorktreeDir ${setup.worktreeRoot}, which belongs to a different repository than the invoking cwd; choose a cwd inside the worktree, or omit cwd.` : `atomic-workflows: cwd ${cwd} is outside gitWorktreeDir ${setup.worktreeRoot}; use a cwd inside the invoking repository so Atomic can remap it, or omit cwd.`);
22444
22508
  }
22445
- const mappedCwd = resolve9(setup.worktreeRoot, repositoryRelative);
22509
+ const mappedCwd = resolve10(setup.worktreeRoot, repositoryRelative);
22446
22510
  const mappedRealPath = existingRealPath(mappedCwd, "remapped worktree cwd");
22447
22511
  if (relativePathWithin(worktreeRoot, mappedRealPath) === undefined) {
22448
22512
  throw new Error(`atomic-workflows: cwd ${cwd} remaps through a path that resolves outside gitWorktreeDir ${setup.worktreeRoot}; remove the escaping symlink or omit cwd.`);
@@ -22452,8 +22516,8 @@ function resolveWorktreeStageCwd(cwd, setup) {
22452
22516
  var init_worktree_cwd = () => {};
22453
22517
 
22454
22518
  // dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts
22455
- import { existsSync as existsSync6 } from "node:fs";
22456
- import { isAbsolute as isAbsolute10, resolve as resolve10 } from "node:path";
22519
+ import { existsSync as existsSync7 } from "node:fs";
22520
+ import { isAbsolute as isAbsolute10, resolve as resolve11 } from "node:path";
22457
22521
  function normalizeTaskContexts(previous) {
22458
22522
  if (previous === undefined)
22459
22523
  return [];
@@ -22506,7 +22570,7 @@ function taskPrevious(options) {
22506
22570
  function resolveWorkflowPath(filePath, baseDir) {
22507
22571
  if (isAbsolute10(filePath))
22508
22572
  return filePath;
22509
- return resolve10(baseDir ?? process.cwd(), filePath);
22573
+ return resolve11(baseDir ?? process.cwd(), filePath);
22510
22574
  }
22511
22575
  function taskBaseDir(options) {
22512
22576
  if (typeof options.chainDir === "string" && options.chainDir.trim().length > 0) {
@@ -22522,7 +22586,7 @@ function taskReadInstruction(options, requireFiles) {
22522
22586
  return "";
22523
22587
  const baseDir = taskBaseDir(options);
22524
22588
  const files = options.reads.map((file) => resolveWorkflowPath(file, baseDir));
22525
- const missing = requireFiles ? files.find((file) => !existsSync6(file)) : undefined;
22589
+ const missing = requireFiles ? files.find((file) => !existsSync7(file)) : undefined;
22526
22590
  if (missing !== undefined) {
22527
22591
  throw new Error(`atomic-workflows: referenced artifact does not exist: ${missing}`);
22528
22592
  }
@@ -22661,7 +22725,7 @@ function taskWithSharedDefaults(taskOptions, options) {
22661
22725
  var init_executor_task_prompts = () => {};
22662
22726
 
22663
22727
  // dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts
22664
- import { isAbsolute as isAbsolute11, join as join14, resolve as resolve11 } from "node:path";
22728
+ import { isAbsolute as isAbsolute11, join as join14, resolve as resolve12 } from "node:path";
22665
22729
  import { CONFIG_DIR_NAME, inheritWorkspace, WorkspaceBindingError as WorkspaceBindingError2 } from "@bastani/atomic";
22666
22730
  function positiveConcurrency(value2) {
22667
22731
  if (typeof value2 !== "number" || !Number.isFinite(value2) || value2 < 1)
@@ -22828,7 +22892,7 @@ function workflowInvocationMetadata(inputDefaults, workflowInvocationCwd, cache,
22828
22892
  function resolvedTaskCwd(cwd, workflowInvocationCwd) {
22829
22893
  if (cwd === undefined)
22830
22894
  return;
22831
- return isAbsolute11(cwd) ? cwd : resolve11(workflowInvocationCwd, cwd);
22895
+ return isAbsolute11(cwd) ? cwd : resolve12(workflowInvocationCwd, cwd);
22832
22896
  }
22833
22897
  function taskWorktreeOutputsRoot(runId) {
22834
22898
  return join14(workflowArtifactRunPath(runId), "task-outputs");
@@ -22841,7 +22905,7 @@ function prepareTaskWorktrees(tasks, options, runId, scope, workflowInvocationCw
22841
22905
  throw new Error("atomic-workflows: worktree and gitWorktreeDir are mutually exclusive; use gitWorktreeDir for a reusable worktree or worktree:true for temporary isolated worktrees.");
22842
22906
  }
22843
22907
  const explicitCwd = tasks.find((task) => typeof task.cwd === "string")?.cwd;
22844
- const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute11(explicitCwd) ? explicitCwd : resolve11(workflowInvocationCwd, explicitCwd);
22908
+ const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute11(explicitCwd) ? explicitCwd : resolve12(workflowInvocationCwd, explicitCwd);
22845
22909
  const conflict = findWorktreeTaskCwdConflict(tasks.map((task) => ({ agent: task.name, cwd: resolvedTaskCwd(task.cwd, workflowInvocationCwd) })), sharedCwd);
22846
22910
  if (conflict !== undefined)
22847
22911
  throw new Error(formatWorktreeTaskCwdConflict(conflict, sharedCwd));
@@ -27060,13 +27124,13 @@ function raceAbort2(operation, signal) {
27060
27124
 
27061
27125
  // dist/builtin/workflows/src/shared/possible-stages.ts
27062
27126
  import { createHash as createHash3 } from "node:crypto";
27063
- import { existsSync as existsSync7, readFileSync as readFileSync4 } from "node:fs";
27064
- import { dirname as dirname11, join as join15, relative as relative7, resolve as resolve12, sep as sep8 } from "node:path";
27127
+ import { existsSync as existsSync8, readFileSync as readFileSync4 } from "node:fs";
27128
+ import { dirname as dirname11, join as join15, relative as relative7, resolve as resolve13, sep as sep8 } from "node:path";
27065
27129
  import { fileURLToPath as fileURLToPath3 } from "node:url";
27066
27130
  function scanPossibleStagesFromSource(entrySourcePath, options = {}) {
27067
27131
  const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
27068
- const scanner = new PossibleStagesScanner(maxDepth, resolve12(entrySourcePath));
27069
- const entryPath = resolve12(entrySourcePath);
27132
+ const scanner = new PossibleStagesScanner(maxDepth, resolve13(entrySourcePath));
27133
+ const entryPath = resolve13(entrySourcePath);
27070
27134
  scanner.scanSubtree(entryPath, "", 0, [entryPath]);
27071
27135
  scanner.noteZeroStages(entryPath);
27072
27136
  return {
@@ -29144,7 +29208,7 @@ function resolveRelativeSpecifier(specifier, importingFile) {
29144
29208
  return candidates.find((candidate) => isFileSync(candidate));
29145
29209
  }
29146
29210
  function isFileSync(path) {
29147
- if (!existsSync7(path))
29211
+ if (!existsSync8(path))
29148
29212
  return false;
29149
29213
  try {
29150
29214
  readFileSync4(path, { flag: "r" });
@@ -70605,7 +70669,7 @@ var init_loop_until_done = __esm(() => {
70605
70669
  });
70606
70670
 
70607
70671
  // dist/builtin/workflows/builtin/open-claude-design-images.ts
70608
- import { existsSync as existsSync8 } from "node:fs";
70672
+ import { existsSync as existsSync9 } from "node:fs";
70609
70673
  import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile8 } from "node:fs/promises";
70610
70674
  import { dirname as dirname13, join as join25 } from "node:path";
70611
70675
  import { AuthStorage } from "@bastani/atomic";
@@ -70804,7 +70868,7 @@ async function runReferenceImagesStep(tool, request, deps = {}) {
70804
70868
  return outcome.ok ? outcome.value : { status: "failed", reason: "tool-failed", paths: [] };
70805
70869
  }
70806
70870
  function existingReferenceImagePaths(status) {
70807
- return status.status === "generated" ? status.paths.filter((path) => existsSync8(path)) : [];
70871
+ return status.status === "generated" ? status.paths.filter((path) => existsSync9(path)) : [];
70808
70872
  }
70809
70873
  var referenceImagesStatusSchema, REFERENCE_IMAGES_DIRNAME = "references", REFERENCE_IMAGES_TOOL_TIMEOUT_MS, IMAGE_REQUEST_TIMEOUT_MS, IMAGE_REQUEST_MAX_RETRIES = 1, IMAGE_SIZE = "1536x1024", PRODUCT_EXCERPT_CHARS = 1000, DESIGN_EXCERPT_CHARS = 1500, REFERENCES_EXCERPT_CHARS = 1500, REFERENCE_IMAGE_DIRECTIONS, SURFACE_BY_OUTPUT_TYPE, GPT_IMAGE_ID, PREFERRED_VARIANTS, LOWER_TIER_VARIANTS, PREFERRED_FALLBACK_PROVIDER = "openrouter", IMAGE_EXTENSIONS;
70810
70874
  var init_open_claude_design_images = __esm(() => {
@@ -72471,8 +72535,8 @@ var init_ralph_models = __esm(() => {
72471
72535
  });
72472
72536
 
72473
72537
  // dist/builtin/workflows/builtin/ralph-runner.ts
72474
- import { existsSync as existsSync9 } from "node:fs";
72475
- import { join as join29, resolve as resolve13 } from "node:path";
72538
+ import { existsSync as existsSync10 } from "node:fs";
72539
+ import { join as join29, resolve as resolve14 } from "node:path";
72476
72540
  async function runRalphWorkflow(ctx, options) {
72477
72541
  const { prompt, acceptanceCriteria, maxLoops, comparisonBaseBranch, workflowStartCwd, createPr, runId } = options;
72478
72542
  let latestReviewReportPath;
@@ -72484,7 +72548,7 @@ async function runRalphWorkflow(ctx, options) {
72484
72548
  let finalPrReport;
72485
72549
  const workflowCwdContext = workflowCwdContextSection(workflowStartCwd);
72486
72550
  const workflowPrompt = prompt;
72487
- const workflowResearchPath = resolve13(workflowStartCwd, defaultResearchPath(workflowPrompt));
72551
+ const workflowResearchPath = resolve14(workflowStartCwd, defaultResearchPath(workflowPrompt));
72488
72552
  const implementationNotesPath = await createImplementationNotesFile(workflowPrompt, runId);
72489
72553
  const qaVideoPath = await createQaEvidenceVideoPath(runId);
72490
72554
  const artifactDir = await createWorkflowArtifactDirectory(runId);
@@ -72735,7 +72799,7 @@ Read it before implementation or delegation because it is the primary current im
72735
72799
  if (approved)
72736
72800
  break;
72737
72801
  }
72738
- const qaVideoAvailable = existsSync9(qaVideoPath);
72802
+ const qaVideoAvailable = existsSync10(qaVideoPath);
72739
72803
  const unapprovedHandoff = createPr === true && !approved;
72740
72804
  const escalationEvidence = unapprovedHandoff ? convergence_escalation_evidence(convergenceEntries) : [];
72741
72805
  if (createPr === true) {
@@ -73094,7 +73158,7 @@ var init_tournament_prompts = __esm(() => {
73094
73158
 
73095
73159
  // dist/builtin/workflows/builtin/tournament-runner.ts
73096
73160
  import { mkdir as mkdir6, readFile as readFile6, writeFile as writeFile10 } from "node:fs/promises";
73097
- import { join as join30, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve14 } from "node:path";
73161
+ import { join as join30, isAbsolute as isAbsolute12, relative as relative9, resolve as resolve15 } from "node:path";
73098
73162
  import { Type as Type23 } from "typebox";
73099
73163
  function serializableObject3(value2) {
73100
73164
  if (value2 === null || Array.isArray(value2) || typeof value2 !== "object")
@@ -73131,8 +73195,8 @@ function criterionSlug(id) {
73131
73195
  }
73132
73196
  function judgeArtifactPath(judgesDir, job, criterionIndex) {
73133
73197
  const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
73134
- const root = resolve14(judgesDir);
73135
- const path = resolve14(judgesDir, filename);
73198
+ const root = resolve15(judgesDir);
73199
+ const path = resolve15(judgesDir, filename);
73136
73200
  const fromRoot = relative9(root, path);
73137
73201
  if (fromRoot.startsWith("..") || isAbsolute12(fromRoot)) {
73138
73202
  throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
@@ -77464,7 +77528,7 @@ var init_client = __esm(() => {
77464
77528
  throw new Error(`Unknown broker message type: ${brokerMessage.type}`);
77465
77529
  }
77466
77530
  }
77467
- async disconnect() {
77531
+ async disconnect(options = {}) {
77468
77532
  if (this.connectAttempt !== undefined && this._sessionId === null) {
77469
77533
  this.connectAttempt.abort();
77470
77534
  return;
@@ -77498,7 +77562,7 @@ var init_client = __esm(() => {
77498
77562
  socket.once("close", onClose);
77499
77563
  socket.once("error", onError);
77500
77564
  try {
77501
- writeMessage(socket, { type: "unregister" });
77565
+ writeMessage(socket, { type: "unregister", ...options.resumable === true ? { resumable: true } : {} });
77502
77566
  socket.end();
77503
77567
  } catch {
77504
77568
  socket.destroy();
@@ -77758,7 +77822,7 @@ var init_client = __esm(() => {
77758
77822
  }
77759
77823
  return this.restoringRecipientRequest({ type: "acknowledge_released_child_wake", childName });
77760
77824
  }
77761
- acknowledgeReleasedChildReply(reply, accepted) {
77825
+ acknowledgeReleasedChildReply(reply, accepted, deliverToChild = false) {
77762
77826
  if (!this.socket || this.socket.destroyed)
77763
77827
  return false;
77764
77828
  this.requireBrokerProtocol("released_child_reply_ack");
@@ -77766,7 +77830,8 @@ var init_client = __esm(() => {
77766
77830
  type: "released_child_reply_ack",
77767
77831
  messageId: reply.message.id,
77768
77832
  handoffId: reply.handoffId,
77769
- accepted
77833
+ accepted,
77834
+ ...deliverToChild ? { deliverToChild: true } : {}
77770
77835
  });
77771
77836
  return true;
77772
77837
  }
@@ -78207,7 +78272,7 @@ var init_shared_storage_setting = __esm(() => {
78207
78272
  // dist/builtin/intercom/broker/spawn.ts
78208
78273
  import { spawn } from "child_process";
78209
78274
  import { randomUUID as randomUUID16 } from "crypto";
78210
- import { appendFileSync, chmodSync, closeSync as closeSync4, existsSync as existsSync10, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
78275
+ import { appendFileSync, chmodSync, closeSync as closeSync4, existsSync as existsSync11, mkdirSync as mkdirSync9, openSync as openSync4, readFileSync as readFileSync7, readSync as readSync2, renameSync, statSync as statSync6, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "fs";
78211
78276
  import { join as join32, dirname as dirname16 } from "path";
78212
78277
  import { fileURLToPath as fileURLToPath5 } from "url";
78213
78278
  import { createRequire as createRequire3 } from "module";
@@ -78219,7 +78284,7 @@ import {
78219
78284
  processSharedStorageSelection
78220
78285
  } from "@bastani/atomic";
78221
78286
  function isIntercomPackageRoot(dir) {
78222
- return existsSync10(join32(dir, "package.json")) && existsSync10(join32(dir, "broker"));
78287
+ return existsSync11(join32(dir, "package.json")) && existsSync11(join32(dir, "broker"));
78223
78288
  }
78224
78289
  function resolveIntercomPackageRoot(moduleHref) {
78225
78290
  const here = dirname16(fileURLToPath5(moduleHref));
@@ -78229,7 +78294,7 @@ function resolveIntercomPackageRoot(moduleHref) {
78229
78294
  }
78230
78295
  function resolveBrokerEntrypoint(packageRoot) {
78231
78296
  const bundled = join32(packageRoot, "broker", "broker.bundle.mjs");
78232
- return existsSync10(bundled) ? bundled : join32(packageRoot, "broker", "broker.ts");
78297
+ return existsSync11(bundled) ? bundled : join32(packageRoot, "broker", "broker.ts");
78233
78298
  }
78234
78299
  function ensurePrivateDirectory(path) {
78235
78300
  mkdirSync9(path, { recursive: true, mode: 448 });
@@ -78533,7 +78598,7 @@ async function isBrokerRunning() {
78533
78598
  if (await checkSocketConnectable()) {
78534
78599
  return true;
78535
78600
  }
78536
- if (!existsSync10(getBrokerPidPath()))
78601
+ if (!existsSync11(getBrokerPidPath()))
78537
78602
  return false;
78538
78603
  try {
78539
78604
  const pid = parseInt(readFileSync7(getBrokerPidPath(), "utf-8").trim(), 10);
@@ -78599,7 +78664,7 @@ function isProcessAlive(pid) {
78599
78664
  }
78600
78665
  }
78601
78666
  function isSpawnLockStale(lockPath = getBrokerSpawnLockPath(), nowMs = Date.now()) {
78602
- if (!existsSync10(lockPath)) {
78667
+ if (!existsSync11(lockPath)) {
78603
78668
  return false;
78604
78669
  }
78605
78670
  try {
@@ -78727,10 +78792,10 @@ var init_reply_waiter = __esm(() => {
78727
78792
  });
78728
78793
 
78729
78794
  // dist/builtin/intercom/config.ts
78730
- import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
78795
+ import { existsSync as existsSync12, readFileSync as readFileSync8 } from "fs";
78731
78796
  import { getAgentConfigPaths } from "@bastani/atomic";
78732
78797
  function loadConfig() {
78733
- if (!existsSync11(CONFIG_PATH)) {
78798
+ if (!existsSync12(CONFIG_PATH)) {
78734
78799
  return { ...defaults };
78735
78800
  }
78736
78801
  try {
@@ -78812,7 +78877,7 @@ var init_config = __esm(() => {
78812
78877
  init_diagnostics();
78813
78878
  init_reply_waiter();
78814
78879
  CONFIG_PATHS = getAgentConfigPaths("intercom", "config.json");
78815
- CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync11(path)) ?? CONFIG_PATHS[0];
78880
+ CONFIG_PATH = CONFIG_PATHS.find((path) => existsSync12(path)) ?? CONFIG_PATHS[0];
78816
78881
  DEFAULT_BROKER_ARGS = ["--no-install", "tsx"];
78817
78882
  defaults = {
78818
78883
  brokerCommand: DEFAULT_BROKER_COMMAND,
@@ -79528,11 +79593,22 @@ function childPlacement(shared, root, workspace) {
79528
79593
  const binding = shared && isBoundWorkspace(workspace) ? bindingIdentity2(workspace) : root;
79529
79594
  return binding === undefined ? {} : { workspaceBinding: binding };
79530
79595
  }
79531
- function placedExecution(execution, worktree) {
79596
+ function placedExecution(execution, worktree, partial) {
79532
79597
  const workspace = execution.workspace;
79598
+ const outcomes = partial === undefined ? {} : {
79599
+ worktreeRestoreOutcomes: [
79600
+ ...execution.worktreeRestoreOutcomes ?? [],
79601
+ partial
79602
+ ]
79603
+ };
79533
79604
  if (!isBoundWorkspace(workspace))
79534
- return { ...execution, cwd: worktree };
79535
- return { ...execution, cwd: worktree, workspace: { ...workspace, worktree } };
79605
+ return { ...execution, cwd: worktree, ...outcomes };
79606
+ return {
79607
+ ...execution,
79608
+ cwd: worktree,
79609
+ workspace: { ...workspace, worktree },
79610
+ ...outcomes
79611
+ };
79536
79612
  }
79537
79613
  function carriedSnapshot(execution) {
79538
79614
  return execution.workspaceSnapshot;
@@ -80165,14 +80241,14 @@ var UNATTRIBUTED_WRITE = "other";
80165
80241
  var init_pool_coordination_stats = () => {};
80166
80242
 
80167
80243
  // dist/builtin/workflows/src/workers/pooled-watch-trace.ts
80168
- import { dirname as dirname17, join as join33, resolve as resolve15 } from "node:path";
80244
+ import { dirname as dirname17, join as join33, resolve as resolve16 } from "node:path";
80169
80245
  import { appendDebugRecord, isDebugEnabled as isDebugEnabled2, reportDebug } from "@bastani/atomic";
80170
80246
  function configurePooledWatchTrace(journal, processRole) {
80171
80247
  journalPath = journal;
80172
80248
  role = processRole;
80173
80249
  }
80174
80250
  function ownTraceFile(journal, setting) {
80175
- return setting === "1" ? join33(dirname17(resolve15(journal)), "pooled-watch-trace.jsonl") : resolve15(setting);
80251
+ return setting === "1" ? join33(dirname17(resolve16(journal)), "pooled-watch-trace.jsonl") : resolve16(setting);
80176
80252
  }
80177
80253
  function tracePooledWatch(step, detail) {
80178
80254
  if (!isDebugEnabled2("pooled-watch"))
@@ -80611,7 +80687,7 @@ function runsWhilePaused(command) {
80611
80687
  if (command.kind !== "task")
80612
80688
  return false;
80613
80689
  const action = command.action.kind;
80614
- return action === "cancel" || action === "output" || action === "detail" || action === "transcript";
80690
+ return action === "cancel" || action === "output" || action === "detail" || action === "transcript" || action === "commands";
80615
80691
  }
80616
80692
 
80617
80693
  // dist/builtin/workflows/src/workers/stage-watch-coalesce.ts
@@ -80912,9 +80988,9 @@ var init_worker_timing = __esm(() => {
80912
80988
  // dist/builtin/workflows/src/workers/pool-coordinator.ts
80913
80989
  import { fork } from "node:child_process";
80914
80990
  import { randomUUID as randomUUID18 } from "node:crypto";
80915
- import { existsSync as existsSync12 } from "node:fs";
80991
+ import { existsSync as existsSync13 } from "node:fs";
80916
80992
  import { appendFile, mkdir as mkdir7, rm as rm4, rmdir as rmdir2 } from "node:fs/promises";
80917
- import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join34, resolve as resolve16 } from "node:path";
80993
+ import { delimiter, dirname as dirname19, isAbsolute as isAbsolute14, join as join34, resolve as resolve17 } from "node:path";
80918
80994
  import { setTimeout as delay4 } from "node:timers/promises";
80919
80995
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
80920
80996
  import { setDebugSetting } from "@bastani/atomic";
@@ -80923,7 +80999,7 @@ function unconfirmedCleanup(groups) {
80923
80999
  return new WorkerCleanupUnconfirmedError({ processGroups: groups });
80924
81000
  }
80925
81001
  function workerLogDirectory(journalPath, root) {
80926
- return join34(dirname19(resolve16(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
81002
+ return join34(dirname19(resolve17(journalPath)), "worker-logs", encodeURIComponent(root).replaceAll(".", "%2E"));
80927
81003
  }
80928
81004
  function traceAnchor(options) {
80929
81005
  return options.shared === undefined ? options.journalPath : join34(options.shared.stateDirectory, "shared-pool");
@@ -81374,7 +81450,7 @@ class PoolCoordinator {
81374
81450
  if (options.shared !== undefined)
81375
81451
  this.journal ??= await this.countedJournal(await openDurableJournal(options.durable));
81376
81452
  else {
81377
- if (options.journalShard !== undefined && !existsSync12(options.journalPath))
81453
+ if (options.journalShard !== undefined && !existsSync13(options.journalPath))
81378
81454
  throw new JournalShardUnavailableError2({
81379
81455
  code: "shard-missing",
81380
81456
  shardId: options.journalShard,
@@ -82617,7 +82693,10 @@ class PoolCoordinator {
82617
82693
  slot.worktree = claimed.worktree;
82618
82694
  for (const id of this.remoteWatches.takenOver(claimed.work.id))
82619
82695
  this.endRemoteWatch(id, "attempt_fenced");
82620
- return claimed.worktree === undefined ? claimed.work : { ...claimed.work, execution: placedExecution(claimed.work.execution, claimed.worktree) };
82696
+ return claimed.worktree === undefined ? claimed.work : {
82697
+ ...claimed.work,
82698
+ execution: placedExecution(claimed.work.execution, claimed.worktree, claimed.partial)
82699
+ };
82621
82700
  }
82622
82701
  const held = slot.work;
82623
82702
  if (!held)
@@ -82786,7 +82865,14 @@ class PoolCoordinator {
82786
82865
  const restore = satellite.restore;
82787
82866
  if (!chosen.restore || binding === undefined || restore === undefined)
82788
82867
  return worktree === undefined ? { work } : { work, worktree };
82789
- const restored = await this.whileHolding(queue, lease, work, leaseMs, (signal) => restore(binding, this.restoreOptions(satellite, signal, carriedSnapshot(work.execution))), AbortSignal.any([this.closedSignal.signal, slot.exited.signal]));
82868
+ let partial;
82869
+ const restored = await this.whileHolding(queue, lease, work, leaseMs, async (signal) => {
82870
+ const result = await restore(binding, this.restoreOptions(satellite, signal, carriedSnapshot(work.execution)));
82871
+ if (typeof result === "string")
82872
+ return result;
82873
+ partial = result.partial;
82874
+ return result.path;
82875
+ }, AbortSignal.any([this.closedSignal.signal, slot.exited.signal]));
82790
82876
  if (this.closed)
82791
82877
  return;
82792
82878
  if ("closed" in restored) {
@@ -82795,7 +82881,7 @@ class PoolCoordinator {
82795
82881
  }
82796
82882
  if ("path" in restored) {
82797
82883
  await this.restoreSucceeded(satellite, backoff, binding);
82798
- return { work, worktree: restored.path };
82884
+ return partial === undefined ? { work, worktree: restored.path } : { work, worktree: restored.path, partial };
82799
82885
  }
82800
82886
  satellite.placementFailed(restored.error);
82801
82887
  await queue.releaseUnplaced(lease, work);
@@ -84574,6 +84660,10 @@ class PooledStageTaskSource {
84574
84660
  followTaskTranscript(id) {
84575
84661
  return this.records.some((task) => task.ref.taskId === id && task.kind === "agent") ? { historyOnly: true } : undefined;
84576
84662
  }
84663
+ async taskCommands(id) {
84664
+ const reply = await this.request(id, { kind: "commands" });
84665
+ return reply.ok && reply.value.kind === "commands" ? reply.value.catalog : undefined;
84666
+ }
84577
84667
  extensionStatuses(id) {
84578
84668
  return this.statuses.get(id) ?? NO_STATUSES;
84579
84669
  }
@@ -85494,8 +85584,8 @@ var init_pooled_stage_registry = __esm(() => {
85494
85584
  // dist/builtin/workflows/src/workers/local-pool.ts
85495
85585
  import { fork as fork2 } from "node:child_process";
85496
85586
  import { randomUUID as randomUUID20 } from "node:crypto";
85497
- import { existsSync as existsSync13 } from "node:fs";
85498
- import { join as join35, resolve as resolve17 } from "node:path";
85587
+ import { existsSync as existsSync14 } from "node:fs";
85588
+ import { join as join35, resolve as resolve18 } from "node:path";
85499
85589
  import { setTimeout as delay5 } from "node:timers/promises";
85500
85590
  import { fileURLToPath as fileURLToPath6 } from "node:url";
85501
85591
  import {
@@ -85739,7 +85829,7 @@ class LocalWorkerPool {
85739
85829
  async prepare(root, store) {
85740
85830
  if (this.closed)
85741
85831
  throw new Error("Local worker pool is closed");
85742
- if (this.options.journalShard !== undefined && !existsSync13(this.options.journalPath))
85832
+ if (this.options.journalShard !== undefined && !existsSync14(this.options.journalPath))
85743
85833
  throw new JournalShardUnavailableError3({
85744
85834
  code: "shard-missing",
85745
85835
  shardId: this.options.journalShard,
@@ -85815,7 +85905,7 @@ class LocalWorkerPool {
85815
85905
  const journal = await rootRunJournal(this.backend.journal, root);
85816
85906
  const journalPath = this.options.journalPath;
85817
85907
  if (this.options.durable === undefined) {
85818
- if (!(journal instanceof SqlRunJournal) || resolve17(journalPath) !== resolve17(journal.path) || sqlPoolStorage(journal)?.tables.runs !== "wf_runs")
85908
+ if (!(journal instanceof SqlRunJournal) || resolve18(journalPath) !== resolve18(journal.path) || sqlPoolStorage(journal)?.tables.runs !== "wf_runs")
85819
85909
  throw new Error("Local workers require the same default-prefix SQLite journal");
85820
85910
  return journal;
85821
85911
  }
@@ -86375,6 +86465,7 @@ class LocalWorkerPool {
86375
86465
  config: options.config,
86376
86466
  snapshots: options.snapshots,
86377
86467
  worktreeRootMappings: options.worktreeRootMappings,
86468
+ worktreeRestoreOutcomes: options.worktreeRestoreOutcomes,
86378
86469
  executionMode: options.executionMode,
86379
86470
  workspace: options.workspace,
86380
86471
  ...childPlacement(shared, this.options.workspace, options.workspace),
@@ -86897,7 +86988,7 @@ var init_local_pool = __esm(() => {
86897
86988
  var DEFAULT_POOLED_STAGE_START_MAX_LOAD_PER_CPU = 3, DEFAULT_PLACEMENT_CLAIM_WINDOW_MS = 60000;
86898
86989
 
86899
86990
  // dist/builtin/workflows/src/workers/public-pool.ts
86900
- import { resolve as resolve18 } from "node:path";
86991
+ import { resolve as resolve19 } from "node:path";
86901
86992
  import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
86902
86993
  import { isBoundWorkspace as isBoundWorkspace3, isWorkspace, resolveWorkspace as resolveWorkspace2 } from "@bastani/atomic";
86903
86994
  function shown(value2) {
@@ -86971,11 +87062,11 @@ function workerResources(options, context) {
86971
87062
  heartbeatMs: undefined,
86972
87063
  maxLoadPerCpu: undefined,
86973
87064
  maxWorkerRssBytes: undefined,
86974
- definitions: options.localWorkers.definitions.map((source) => ({ ...source, path: resolve18(cwd, source.path) }))
87065
+ definitions: options.localWorkers.definitions.map((source) => ({ ...source, path: resolve19(cwd, source.path) }))
86975
87066
  };
86976
87067
  const admission = options.admission && {
86977
87068
  ...options.admission,
86978
- ...options.admission.userDatabase ? { userDatabase: resolve18(cwd, options.admission.userDatabase) } : {}
87069
+ ...options.admission.userDatabase ? { userDatabase: resolve19(cwd, options.admission.userDatabase) } : {}
86979
87070
  };
86980
87071
  const userDatabase = admission?.userLimits && admission.userDatabase === undefined ? context.userDatabase() : undefined;
86981
87072
  return JSON.parse(JSON.stringify({
@@ -86992,7 +87083,7 @@ function workerResources(options, context) {
86992
87083
  }));
86993
87084
  }
86994
87085
  function poolUserDatabase(journal) {
86995
- return isLocalPoolJournal(journal) ? undefined : resolve18(coordinationPath(poolDurableJournal(journal)));
87086
+ return isLocalPoolJournal(journal) ? undefined : resolve19(coordinationPath(poolDurableJournal(journal)));
86996
87087
  }
86997
87088
  function withWorkerSettings(options, settings) {
86998
87089
  const configured = settings?.workflows;
@@ -87118,13 +87209,13 @@ async function activatePublicPool(backend, options) {
87118
87209
  registerPoolJournal(backend.journal, poolJournal);
87119
87210
  }
87120
87211
  const cwd = options.cwd ?? process.cwd();
87121
- const userDatabase = options.admission?.userDatabase ? resolve18(cwd, options.admission.userDatabase) : options.admission?.userDatabase;
87122
- if (durable !== undefined && options.admission?.userLimits && userDatabase !== undefined && userDatabase !== resolve18(poolPath))
87123
- throw new Error(`admission.userDatabase must be omitted, or ${resolve18(poolPath)}, for a journal that is not a local SQLite file`);
87124
- const paths = (options.localWorkers?.definitions ?? []).map((source) => resolve18(cwd, source.path));
87212
+ const userDatabase = options.admission?.userDatabase ? resolve19(cwd, options.admission.userDatabase) : options.admission?.userDatabase;
87213
+ if (durable !== undefined && options.admission?.userLimits && userDatabase !== undefined && userDatabase !== resolve19(poolPath))
87214
+ throw new Error(`admission.userDatabase must be omitted, or ${resolve19(poolPath)}, for a journal that is not a local SQLite file`);
87215
+ const paths = (options.localWorkers?.definitions ?? []).map((source) => resolve19(cwd, source.path));
87125
87216
  const digests = new Map(await Promise.all(paths.map(async (path) => [path, await definitionDigest(path)])));
87126
87217
  const resources = workerResources(options, {
87127
- userDatabase: () => durable === undefined ? undefined : resolve18(poolPath),
87218
+ userDatabase: () => durable === undefined ? undefined : resolve19(poolPath),
87128
87219
  digestOf: (path) => digests.get(path),
87129
87220
  coordinator: shared !== undefined || durable === undefined || !options.localWorkers ? undefined : { host: poolHostId(durable.agentDir), database: coordinationDatabase(durable) },
87130
87221
  ...recorded === undefined ? {} : { workers: recorded.placement }
@@ -91977,7 +92068,7 @@ var init_stage_runner_controller = __esm(() => {
91977
92068
  // dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
91978
92069
  import { createHash as createHash6 } from "node:crypto";
91979
92070
  import { mkdir as mkdir8, writeFile as writeFile11 } from "node:fs/promises";
91980
- import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join37, resolve as resolve19 } from "node:path";
92071
+ import { basename as basename5, dirname as dirname21, isAbsolute as isAbsolute16, join as join37, resolve as resolve20 } from "node:path";
91981
92072
  function normalizeMaxOutput2(maxOutput) {
91982
92073
  return {
91983
92074
  bytes: maxOutput?.bytes ?? DEFAULT_MAX_OUTPUT_BYTES,
@@ -92085,7 +92176,7 @@ function renderTranscript(messages, fallbackOutput) {
92085
92176
  `);
92086
92177
  }
92087
92178
  function savedOutputReference(outputPath, fullOutput, transcriptPathValue, transcriptText, transcriptAvailable, warning) {
92088
- const absolutePath = resolve19(outputPath);
92179
+ const absolutePath = resolve20(outputPath);
92089
92180
  const bytes = Buffer.byteLength(fullOutput, "utf8");
92090
92181
  const lines = countLines(fullOutput);
92091
92182
  const transcriptBytes = Buffer.byteLength(transcriptText, "utf8");
@@ -92100,8 +92191,8 @@ function resolveOutputPath(output, runtimeCwd, requestedCwd) {
92100
92191
  return;
92101
92192
  if (isAbsolute16(output))
92102
92193
  return output;
92103
- const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute16(requestedCwd) ? requestedCwd : resolve19(runtimeCwd, requestedCwd);
92104
- return resolve19(baseCwd, output);
92194
+ const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute16(requestedCwd) ? requestedCwd : resolve20(runtimeCwd, requestedCwd);
92195
+ return resolve20(baseCwd, output);
92105
92196
  }
92106
92197
  function degenerateWarning(fullOutput) {
92107
92198
  return fullOutput.trim().length === 0 ? "WARNING: the stage artifact is empty; search the companion transcript for this stage's work." : undefined;
@@ -93500,11 +93591,11 @@ var init_child_workflow_failure_message = __esm(() => {
93500
93591
  });
93501
93592
 
93502
93593
  // dist/builtin/workflows/src/engine/primitives/workflow.ts
93503
- import { existsSync as existsSync14 } from "node:fs";
93594
+ import { existsSync as existsSync15 } from "node:fs";
93504
93595
  import {
93505
93596
  acquireWorkspaceWriterLease,
93506
93597
  isBoundWorkspace as isBoundWorkspace4,
93507
- isWorkspaceRestoreError,
93598
+ isWorkspaceRestoreError as isWorkspaceRestoreError2,
93508
93599
  resolveWorkspace as resolveWorkspace4,
93509
93600
  restoreWorkspace,
93510
93601
  workspaceChangeSet as workspaceChangeSet2
@@ -93692,7 +93783,7 @@ async function bindChildWorkspace(workspace, invocation, signal, owner, restored
93692
93783
  binding = recorded;
93693
93784
  } catch (error) {
93694
93785
  const worktree = mapWorkflowWorktreePath(recorded.worktree, restored);
93695
- if (!isWorkspaceRestoreError(error) || worktree === recorded.worktree || existsSync14(recorded.worktree))
93786
+ if (!isWorkspaceRestoreError2(error) || worktree === recorded.worktree || existsSync15(recorded.worktree))
93696
93787
  throw error;
93697
93788
  binding = { ...recorded, worktree };
93698
93789
  }
@@ -97231,6 +97322,7 @@ import {
97231
97322
  resolveWorktreeSnapshotSettings,
97232
97323
  scheduleSnapshotCollection,
97233
97324
  setUpResumedRunWorktrees,
97325
+ withWorktreeRestoreNotices,
97234
97326
  withWorktreeRootMappings as withWorktreeRootMappings3
97235
97327
  } from "@bastani/atomic";
97236
97328
  async function run(def, inputs, opts = {}) {
@@ -97268,41 +97360,46 @@ async function run(def, inputs, opts = {}) {
97268
97360
  const journal = backend.snapshotJournal;
97269
97361
  if (previous !== undefined && journal !== undefined) {
97270
97362
  const mappings = previous.worktreeRootMappings ?? [];
97271
- if (opts[restorePreconditionsChecked] !== true) {
97272
- if (await backend.workflowOwnership(runId) === "foreign")
97273
- throw new JournalOwnershipError(runId, (await journal.leaseState(runId))?.holderId ?? null);
97274
- const precondition = await runRestorePreconditionFailure(journal, runId, mappings, previous.snapshots ?? opts.snapshots, opts.signal);
97275
- if (precondition !== undefined)
97276
- throw precondition;
97277
- }
97363
+ if (opts[restorePreconditionsChecked] !== true && await backend.workflowOwnership(runId) === "foreign")
97364
+ throw new JournalOwnershipError(runId, (await journal.leaseState(runId))?.holderId ?? null);
97278
97365
  let warningCount = 0;
97366
+ const unrestored = [];
97279
97367
  const restored = await resolveWorkflowSnapshotFrontier(journal, runId, {
97280
97368
  mappings,
97281
97369
  settings: previous.snapshots ?? opts.snapshots,
97282
97370
  signal: opts.signal,
97283
- onRestore: (mapping) => activeStore.recordNotice({
97284
- id: `workflow-worktree-restore:${runId}:${mapping.snapshotId}:${mapping.restoredAt}`,
97285
- runId,
97286
- level: "info",
97287
- message: formatWorktreeRestoreNotice(mapping),
97288
- createdAt: Date.now()
97289
- }),
97290
- onWarning: (warning, mapping) => activeStore.recordNotice({
97291
- id: `workflow-worktree-restore-warning:${runId}:${mapping.snapshotId}:${mapping.restoredAt}:${warningCount++}`,
97292
- runId,
97293
- level: "warning",
97294
- message: formatWorktreeRestoreWarning(warning),
97295
- createdAt: Date.now()
97296
- })
97371
+ onRestore: (mapping) => {
97372
+ if (mapping.degraded !== undefined)
97373
+ return;
97374
+ activeStore.recordNotice({
97375
+ id: `workflow-worktree-restore:${runId}:${mapping.snapshotId}:${mapping.restoredAt}`,
97376
+ runId,
97377
+ level: "info",
97378
+ message: formatWorktreeRestoreNotice(mapping),
97379
+ createdAt: Date.now()
97380
+ });
97381
+ },
97382
+ onWarning: (warning, mapping) => {
97383
+ if (mapping.degraded !== undefined && (warning.code === "omitted-content" || warning.code === "filters"))
97384
+ return;
97385
+ activeStore.recordNotice({
97386
+ id: `workflow-worktree-restore-warning:${runId}:${mapping.snapshotId}:${mapping.restoredAt}:${warningCount++}`,
97387
+ runId,
97388
+ level: "warning",
97389
+ message: formatWorktreeRestoreWarning(warning),
97390
+ createdAt: Date.now()
97391
+ });
97392
+ },
97393
+ onUnrestored: (checkout) => unrestored.push(checkout)
97297
97394
  });
97395
+ const restoreSnapshots = mappings.length > 0 || restored.length > 0 ? new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
97396
+ boundary.snapshot.id,
97397
+ boundary.snapshot
97398
+ ])) : new Map;
97298
97399
  if (mappings.length > 0 || restored.length > 0) {
97299
- const snapshots = new Map((await listWorkflowSnapshotBoundaries(journal, runId)).map((boundary) => [
97300
- boundary.snapshot.id,
97301
- boundary.snapshot
97302
- ]));
97303
97400
  const resumeToken = crypto.randomUUID();
97304
97401
  let blueprintNoticeCount = 0;
97305
- await setUpResumedRunWorktrees({ restored, mappings, snapshots }, {
97402
+ await setUpResumedRunWorktrees({ restored, mappings, snapshots: restoreSnapshots }, {
97306
97403
  signal: opts.signal,
97307
97404
  onNotices: (notices) => {
97308
97405
  for (const notice of notices) {
@@ -97318,15 +97415,41 @@ async function run(def, inputs, opts = {}) {
97318
97415
  });
97319
97416
  }
97320
97417
  const allMappings = [...mappings, ...restored];
97321
- if (restored.length > 0) {
97322
- await backend.commitWorkflowRegistration({ ...previous, worktreeRootMappings: allMappings });
97418
+ const recordedCwd = previous.invocationCwd ?? opts.cwd;
97419
+ const continuing = recordedCwd === undefined ? undefined : mapWorkflowWorktreePath(recordedCwd, allMappings);
97420
+ const outcomes = runWorktreeRestoreOutcomes({
97421
+ restored,
97422
+ unrestored,
97423
+ snapshots: restoreSnapshots,
97424
+ continuing,
97425
+ launchCwd: opts[resumeLaunchCwd] ?? opts.cwd ?? process.cwd(),
97426
+ previous: previous.worktreeRestoreOutcomes ?? [],
97427
+ mappings: allMappings
97428
+ });
97429
+ for (const outcome of outcomes.fresh) {
97430
+ activeStore.recordNotice({
97431
+ id: `workflow-worktree-restore-outcome:${runId}:${outcome.snapshotId}:${outcome.at}`,
97432
+ runId,
97433
+ level: "warning",
97434
+ message: outcome.message,
97435
+ createdAt: Date.now()
97436
+ });
97437
+ }
97438
+ if (restored.length > 0 || outcomes.list.length > 0 || (previous.worktreeRestoreOutcomes?.length ?? 0) > 0) {
97439
+ await backend.commitWorkflowRegistration({
97440
+ ...previous,
97441
+ ...allMappings.length > 0 ? { worktreeRootMappings: allMappings } : {},
97442
+ ...outcomes.list.length > 0 || previous.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: outcomes.list } : {}
97443
+ });
97323
97444
  }
97324
- if (allMappings.length > 0) {
97325
- const cwd = previous.invocationCwd ?? opts.cwd;
97445
+ const cwd = outcomes.continuedIn ?? continuing;
97446
+ if (allMappings.length > 0 || outcomes.list.length > 0) {
97326
97447
  opts = {
97327
97448
  ...opts,
97328
- ...cwd === undefined ? {} : { cwd: mapWorkflowWorktreePath(cwd, allMappings) },
97329
- worktreeRootMappings: allMappings
97449
+ ...cwd === undefined ? {} : { cwd },
97450
+ ...outcomes.continuedIn === undefined || recordedCwd === undefined ? {} : { [recordedInvocationCwd]: recordedCwd },
97451
+ ...allMappings.length > 0 ? { worktreeRootMappings: allMappings } : {},
97452
+ ...outcomes.list.length > 0 ? { worktreeRestoreOutcomes: outcomes.list } : {}
97330
97453
  };
97331
97454
  }
97332
97455
  }
@@ -97349,7 +97472,8 @@ async function run(def, inputs, opts = {}) {
97349
97472
  bindStoreDurableBackend(activeStore, backend);
97350
97473
  }
97351
97474
  const admitted = () => admitWorkflowSessions(backend, { ...opts, runId }, (admittedOpts) => executeUntilSettled(def, resolvedInputs, { ...admittedOpts, store: activeStore, runId, durableBackend: backend }, evictionPolicy));
97352
- return await withWorktreeRootMappings3(opts.worktreeRootMappings ?? [], admitted);
97475
+ const restoreNotices = (opts.worktreeRestoreOutcomes ?? []).map((outcome) => outcome.message);
97476
+ return await withWorktreeRootMappings3(opts.worktreeRootMappings ?? [], () => withWorktreeRestoreNotices(restoreNotices, admitted));
97353
97477
  } finally {
97354
97478
  try {
97355
97479
  await publicPool?.close();
@@ -97465,6 +97589,7 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
97465
97589
  stages: [],
97466
97590
  toolNodes: [],
97467
97591
  ...opts.worktreeRootMappings !== undefined ? { worktreeRootMappings: opts.worktreeRootMappings } : {},
97592
+ ...opts.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: opts.worktreeRestoreOutcomes } : {},
97468
97593
  pendingStageMessages: [
97469
97594
  ...pendingStageMessagesForDurableRun(rootBackend, runId, opts.parentRun?.rootRunId ?? runId)
97470
97595
  ],
@@ -97721,7 +97846,8 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
97721
97846
  durableBackend,
97722
97847
  durableRootBackend: rootBackend,
97723
97848
  snapshots: opts.snapshots,
97724
- worktreeRootMappings: opts.worktreeRootMappings
97849
+ worktreeRootMappings: opts.worktreeRootMappings,
97850
+ worktreeRestoreOutcomes: opts.worktreeRestoreOutcomes
97725
97851
  };
97726
97852
  let evicted;
97727
97853
  let bodySettled = false;
@@ -98303,7 +98429,8 @@ async function executeRun(def, resolvedInputs, opts, eviction) {
98303
98429
  await durableBackend.commitWorkflowRegistration({
98304
98430
  ...durableRootRegistration,
98305
98431
  modelOwner: runSnapshot.modelOwner,
98306
- ...workflowInvocationMetadata(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache, runSnapshot.origin)
98432
+ ...workflowInvocationMetadata(inputRuntimeDefaults, workflowInvocationCwd, gitWorktreeSetupCache, runSnapshot.origin),
98433
+ ...opts[recordedInvocationCwd] === undefined ? {} : { invocationCwd: opts[recordedInvocationCwd] }
98307
98434
  });
98308
98435
  } else {
98309
98436
  await durableBackend.commitWorkflowStatus(runId, "running");
@@ -98665,7 +98792,7 @@ var init_run_claims = __esm(() => {
98665
98792
  // dist/builtin/workflows/src/durable/fork-run.ts
98666
98793
  import { randomUUID as randomUUID22 } from "node:crypto";
98667
98794
  import { statSync as statSync7 } from "node:fs";
98668
- import { isAbsolute as isAbsolute17, resolve as resolve20 } from "node:path";
98795
+ import { isAbsolute as isAbsolute17, resolve as resolve21 } from "node:path";
98669
98796
  import {
98670
98797
  assertSessionBlobStore as assertSessionBlobStore2,
98671
98798
  copySessionBlobs as copySessionBlobs2,
@@ -98692,7 +98819,7 @@ function validateForkOptions(source, runId, options) {
98692
98819
  let directory = false;
98693
98820
  if (typeof options.cwd === "string" && options.cwd.length > 0) {
98694
98821
  try {
98695
- directory = statSync7(resolve20(options.cwd)).isDirectory();
98822
+ directory = statSync7(resolve21(options.cwd)).isDirectory();
98696
98823
  } catch (error) {
98697
98824
  cause = error;
98698
98825
  }
@@ -98718,7 +98845,7 @@ function validateForkOptions(source, runId, options) {
98718
98845
  function forkDestinationCwd(cwd, source) {
98719
98846
  if (cwd === undefined)
98720
98847
  return source.invocationCwd ?? process.cwd();
98721
- return isAbsolute17(cwd) ? cwd : resolve20(cwd);
98848
+ return isAbsolute17(cwd) ? cwd : resolve21(cwd);
98722
98849
  }
98723
98850
  function storageScope(descriptor) {
98724
98851
  if (descriptor === undefined)
@@ -99846,7 +99973,7 @@ var init_registry = () => {};
99846
99973
 
99847
99974
  // dist/builtin/workflows/src/extension/discovery-loaders.ts
99848
99975
  import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
99849
- import { extname, isAbsolute as isAbsolute18, join as join38, resolve as resolve21 } from "node:path";
99976
+ import { extname, isAbsolute as isAbsolute18, join as join38, resolve as resolve22 } from "node:path";
99850
99977
  async function scanWorkflowDir(dir) {
99851
99978
  try {
99852
99979
  const entries = await readdir2(dir, { withFileTypes: true });
@@ -99890,7 +100017,7 @@ async function loadFromPaths(pathsOrMap, kind, baseCwd, diagnostics, getWorkflow
99890
100017
  const all = [];
99891
100018
  const entries = Array.isArray(pathsOrMap) ? pathsOrMap.map((p) => ({ rawPath: p })) : Object.entries(pathsOrMap).map(([name, p]) => ({ rawPath: p, configuredName: name }));
99892
100019
  for (const { rawPath, configuredName } of entries) {
99893
- const absPath = isAbsolute18(rawPath) ? rawPath : resolve21(baseCwd, rawPath);
100020
+ const absPath = isAbsolute18(rawPath) ? rawPath : resolve22(baseCwd, rawPath);
99894
100021
  let pathStats;
99895
100022
  try {
99896
100023
  pathStats = await stat2(absPath);
@@ -100155,7 +100282,7 @@ var init_discovery = __esm(() => {
100155
100282
  });
100156
100283
 
100157
100284
  // dist/builtin/workflows/src/runs/foreground/sdk-fork.ts
100158
- import { resolve as resolve22 } from "node:path";
100285
+ import { resolve as resolve23 } from "node:path";
100159
100286
  function refuseAddedWorkerResources(options, saved) {
100160
100287
  if (saved)
100161
100288
  return;
@@ -100187,7 +100314,7 @@ function refuseChangedWorkerResources(options, handle, backend) {
100187
100314
  const requested = workerResources({
100188
100315
  localWorkers: options.localWorkers ?? saved.localWorkers,
100189
100316
  admission: options.admission ?? saved.admission,
100190
- cwd: options.cwd === undefined ? handle.invocationCwd ?? process.cwd() : resolve22(options.cwd)
100317
+ cwd: options.cwd === undefined ? handle.invocationCwd ?? process.cwd() : resolve23(options.cwd)
100191
100318
  }, {
100192
100319
  userDatabase: () => forkUserDatabase(backend),
100193
100320
  digestOf: (path) => digests.get(path) ?? "",
@@ -100352,23 +100479,59 @@ var init_types2 = __esm(() => {
100352
100479
 
100353
100480
  // dist/builtin/workflows/src/workers/snapshot-restore.ts
100354
100481
  import {
100355
- isGitUnavailableError as isGitUnavailableError3,
100356
- restoreWorktree as restoreWorktree2
100482
+ formatDegradedRestoreNotice as formatDegradedRestoreNotice2,
100483
+ isGitUnavailableError as isGitUnavailableError4,
100484
+ restoreBestWorktree as restoreBestWorktree2,
100485
+ restoreWorktree
100357
100486
  } from "@bastani/atomic";
100358
100487
  function snapshotRestore(options) {
100359
- const restore = options.restore ?? restoreWorktree2;
100360
100488
  const restored = new Map;
100361
- const restoreOnHost = async (binding, target, recorded, signal) => {
100489
+ const restoreOnHost = async (binding, snapshot, recorded, signal) => {
100490
+ const shared = {
100491
+ blobs: options.blobs,
100492
+ storeDir: options.storeDir,
100493
+ signal,
100494
+ git: options.git,
100495
+ ...options.restore === undefined ? {} : { restore: options.restore }
100496
+ };
100362
100497
  try {
100363
- return (await restore(target, {
100364
- ...recorded,
100365
- blobs: options.blobs,
100366
- storeDir: options.storeDir,
100367
- signal,
100368
- git: options.git
100369
- })).path;
100498
+ if (snapshot === undefined)
100499
+ return (await (options.restore ?? restoreWorktree)(binding, {
100500
+ ...recorded,
100501
+ blobs: options.blobs,
100502
+ storeDir: options.storeDir,
100503
+ signal,
100504
+ git: options.git
100505
+ })).path;
100506
+ const best = await restoreBestWorktree2(snapshot, {
100507
+ ...shared,
100508
+ ...recorded.snapshots === undefined ? {} : { target: binding, snapshots: recorded.snapshots }
100509
+ });
100510
+ if (best.status === "unrestored")
100511
+ throw best.reason;
100512
+ if (best.degraded === undefined)
100513
+ return best.path;
100514
+ const restoredAt = new Date().toISOString();
100515
+ const mapping = {
100516
+ from: snapshot.root,
100517
+ to: best.path,
100518
+ snapshotId: snapshot.id,
100519
+ tree: snapshot.tree,
100520
+ restoredAt,
100521
+ degraded: best.degraded
100522
+ };
100523
+ return {
100524
+ path: best.path,
100525
+ partial: {
100526
+ root: snapshot.root,
100527
+ snapshotId: snapshot.id,
100528
+ message: formatDegradedRestoreNotice2(mapping, snapshot, [], "workflow run"),
100529
+ at: restoredAt,
100530
+ degraded: best.degraded
100531
+ }
100532
+ };
100370
100533
  } catch (error) {
100371
- if (signal.aborted || !isGitUnavailableError3(error))
100534
+ if (signal.aborted || !isGitUnavailableError4(error))
100372
100535
  throw error;
100373
100536
  throw new WorkspaceRestoreUnavailableError("no-restore-port", workspaceBindingIdentity(binding), {
100374
100537
  cause: error
@@ -100380,9 +100543,9 @@ function snapshotRestore(options) {
100380
100543
  return restoreOnHost(binding, snapshot, {}, signal);
100381
100544
  const key = JSON.stringify([binding.head, binding.tree]);
100382
100545
  const snapshots = restored.get(key) ?? await options.recorded(binding);
100383
- let path;
100546
+ let result;
100384
100547
  try {
100385
- path = await restoreOnHost(binding, binding, { snapshots }, signal);
100548
+ result = await restoreOnHost(binding, snapshots.at(-1), { snapshots }, signal);
100386
100549
  } catch (error) {
100387
100550
  restored.delete(key);
100388
100551
  throw error;
@@ -100390,7 +100553,7 @@ function snapshotRestore(options) {
100390
100553
  if (!restored.has(key) && restored.size >= RECORDED_SNAPSHOT_ENTRIES)
100391
100554
  restored.clear();
100392
100555
  restored.set(key, snapshots);
100393
- return path;
100556
+ return result;
100394
100557
  };
100395
100558
  }
100396
100559
  var RECORDED_SNAPSHOT_ENTRIES = 256;
@@ -100400,7 +100563,7 @@ var init_snapshot_restore = __esm(() => {
100400
100563
 
100401
100564
  // dist/builtin/workflows/src/workers/worker-host.ts
100402
100565
  import { execFile as execFile2 } from "node:child_process";
100403
- import { existsSync as existsSync15 } from "node:fs";
100566
+ import { existsSync as existsSync16 } from "node:fs";
100404
100567
  import { join as join40 } from "node:path";
100405
100568
  import {
100406
100569
  getAgentDir as getAgentDir9,
@@ -100478,7 +100641,7 @@ function probeGit(git) {
100478
100641
  async function runnableSources(root) {
100479
100642
  const sources = [];
100480
100643
  for (const source of root.config.definitions) {
100481
- if (!existsSync15(source.path))
100644
+ if (!existsSync16(source.path))
100482
100645
  continue;
100483
100646
  const digest = await definitionDigest(source.path);
100484
100647
  if (digest === source.digest)
@@ -100752,14 +100915,24 @@ function hostRestorePort(options, git, shared, journal, agentDir) {
100752
100915
  storeDir: join40(agentDir, "worktree-snapshots"),
100753
100916
  git
100754
100917
  });
100755
- return (binding, hook) => restoreRunWorktree(hook.snapshot?.remotes, () => restore(binding, hook), {
100756
- signal: hook.signal,
100757
- agentDir,
100758
- onNotices: (notices) => {
100759
- for (const notice of notices)
100760
- console.warn(`atomic-workflows: ${notice.message}`);
100761
- }
100762
- });
100918
+ return async (binding, hook) => {
100919
+ let result;
100920
+ const path = await restoreRunWorktree(hook.snapshot?.remotes, async () => {
100921
+ result = await restore(binding, hook);
100922
+ return typeof result === "string" ? result : result.path;
100923
+ }, {
100924
+ signal: hook.signal,
100925
+ agentDir,
100926
+ onNotices: (notices) => {
100927
+ for (const notice of notices)
100928
+ console.warn(`atomic-workflows: ${notice.message}`);
100929
+ }
100930
+ });
100931
+ if (typeof result !== "object" || result.partial === undefined)
100932
+ return path;
100933
+ console.warn(`atomic-workflows: ${result.partial.message}`);
100934
+ return { path, partial: result.partial };
100935
+ };
100763
100936
  }
100764
100937
  async function startWorkflowWorkerHost(options) {
100765
100938
  validated(options);
@@ -100979,7 +101152,7 @@ __export(exports_sdk_surface, {
100979
101152
  isForkSourceNotFoundError: () => isForkSourceNotFoundError,
100980
101153
  isForkSourceOwnershipError: () => isForkSourceOwnershipError,
100981
101154
  isForkTargetNotFoundError: () => isForkTargetNotFoundError,
100982
- isGitUnavailableError: () => isGitUnavailableError4,
101155
+ isGitUnavailableError: () => isGitUnavailableError5,
100983
101156
  isLocalWorkerOptionsError: () => isLocalWorkerOptionsError,
100984
101157
  isLocalWorkerPoolError: () => isLocalWorkerPoolError,
100985
101158
  isPoolAppendRefusedError: () => isPoolAppendRefusedError,
@@ -101049,7 +101222,7 @@ __export(exports_sdk_surface, {
101049
101222
  isWorkspaceError: () => isWorkspaceError,
101050
101223
  isWorkspaceGitError: () => isWorkspaceGitError3,
101051
101224
  isWorkspacePublicationError: () => isWorkspacePublicationError,
101052
- isWorkspaceRestoreError: () => isWorkspaceRestoreError2,
101225
+ isWorkspaceRestoreError: () => isWorkspaceRestoreError3,
101053
101226
  isWorkspaceRestoreUnavailableError: () => isWorkspaceRestoreUnavailableError,
101054
101227
  isWorkspaceSandboxError: () => isWorkspaceSandboxError,
101055
101228
  isWorkspaceSnapshotError: () => isWorkspaceSnapshotError2,
@@ -101128,7 +101301,7 @@ import {
101128
101301
  isDecisionRequestError,
101129
101302
  isDecisionTimeoutError,
101130
101303
  isEventSourceError,
101131
- isGitUnavailableError as isGitUnavailableError4,
101304
+ isGitUnavailableError as isGitUnavailableError5,
101132
101305
  isRetryableDecisionError,
101133
101306
  isRetryableSubscriptionError,
101134
101307
  isRetryableWorkspaceError,
@@ -101150,7 +101323,7 @@ import {
101150
101323
  isWorkspaceError,
101151
101324
  isWorkspaceGitError as isWorkspaceGitError3,
101152
101325
  isWorkspacePublicationError,
101153
- isWorkspaceRestoreError as isWorkspaceRestoreError2,
101326
+ isWorkspaceRestoreError as isWorkspaceRestoreError3,
101154
101327
  isWorkspaceSandboxError,
101155
101328
  isWorkspaceSnapshotError as isWorkspaceSnapshotError2,
101156
101329
  isWorkspaceTimeoutError,
@@ -101241,8 +101414,8 @@ var init_workflows_host_module = __esm(() => {
101241
101414
 
101242
101415
  // dist/builtin/workflows/src/workers/pool-journal.ts
101243
101416
  import { createHash as createHash7, randomUUID as randomUUID24 } from "node:crypto";
101244
- import { existsSync as existsSync16, mkdirSync as mkdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
101245
- import { basename as basename6, dirname as dirname22, join as join41, resolve as resolve23 } from "node:path";
101417
+ import { existsSync as existsSync17, mkdirSync as mkdirSync11, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
101418
+ import { basename as basename6, dirname as dirname22, join as join41, resolve as resolve24 } from "node:path";
101246
101419
  import { createChildProcessEnvironment as createChildProcessEnvironment6 } from "@bastani/atomic";
101247
101420
  import { storageSelectionKey as storageSelectionKey2 } from "@bastani/atomic/storage";
101248
101421
  function poolWorkerEnvironment(durable) {
@@ -101270,7 +101443,7 @@ function isReopenableSelection(selection) {
101270
101443
  }
101271
101444
  function encodeSelection(selection) {
101272
101445
  if (selection.kind === "sqlite")
101273
- return JSON.stringify({ ...selection, path: resolve23(selection.path) });
101446
+ return JSON.stringify({ ...selection, path: resolve24(selection.path) });
101274
101447
  return JSON.stringify({
101275
101448
  ...selection,
101276
101449
  ...selection.options === undefined ? {} : {
@@ -101316,7 +101489,7 @@ function coordinationDatabase(durable) {
101316
101489
  return basename6(coordinationPath(durable), ".sqlite");
101317
101490
  }
101318
101491
  function openCoordinationJournal(path) {
101319
- const file = resolve23(path);
101492
+ const file = resolve24(path);
101320
101493
  let opened = coordinationJournals.get(file);
101321
101494
  if (opened === undefined) {
101322
101495
  mkdirSync11(dirname22(file), { recursive: true });
@@ -101368,7 +101541,7 @@ async function poolJournalOf(journal) {
101368
101541
  if (origin === undefined || !isReopenableSelection(origin.selection))
101369
101542
  return journal;
101370
101543
  const path = coordinationPath(poolDurableJournal(journal));
101371
- if (!existsSync16(path))
101544
+ if (!existsSync17(path))
101372
101545
  return journal;
101373
101546
  const coordination = await openCoordinationJournal(path);
101374
101547
  registerPoolJournal(journal, coordination);
@@ -102094,9 +102267,9 @@ var init_sdk_owner_release = __esm(() => {
102094
102267
 
102095
102268
  // dist/builtin/workflows/src/durable/sdk-recovery-scope.ts
102096
102269
  import { realpathSync as realpathSync5 } from "node:fs";
102097
- import { resolve as resolve24 } from "node:path";
102270
+ import { resolve as resolve25 } from "node:path";
102098
102271
  function canonicalDirectory(path) {
102099
- const absolute = resolve24(path);
102272
+ const absolute = resolve25(path);
102100
102273
  try {
102101
102274
  const canonical = realpathSync5.native(absolute);
102102
102275
  return process.platform === "win32" ? canonical.toLowerCase() : canonical;
@@ -102220,10 +102393,6 @@ async function hasWorktreeSnapshots(backend, workflowId) {
102220
102393
  function crossProjectResumeMessage(workflowId, cwd) {
102221
102394
  return `Workflow run found in different project: ${cwd}. Run /workflow resume ${workflowId} in an interactive session to fork it into the current directory, or open the original project to resume it.`;
102222
102395
  }
102223
- async function restorePreconditionFailure(handle, journal, deps) {
102224
- const error = await runRestorePreconditionFailure(journal, handle.workflowId, handle.worktreeRootMappings ?? [], handle.snapshots, deps.signal);
102225
- return error === undefined ? undefined : { ok: false, reason: "startup_failed", message: error.message, error };
102226
- }
102227
102396
  async function resumeDurableWorkflow(workflowId, deps, catalog) {
102228
102397
  resolveWorktreeSnapshotSettings3(deps.baseRunOpts.snapshots, "sdk", "snapshots");
102229
102398
  const backend = resumeBackend(deps, workflowId);
@@ -102361,9 +102530,6 @@ async function resumeDurableWorkflowClaimed(workflowId, deps, catalog) {
102361
102530
  };
102362
102531
  }
102363
102532
  const snapshotJournal = backend.snapshotJournal;
102364
- const restoreFailure = snapshotJournal === undefined ? undefined : await restorePreconditionFailure(handle, snapshotJournal, deps);
102365
- if (restoreFailure !== undefined)
102366
- return restoreFailure;
102367
102533
  let toolContinuation = deps.baseRunOpts.continuation;
102368
102534
  if (handle.status === "failed" && (handle.failedToolNodeId !== undefined || /^atomic-workflows: ctx\.tool .* aborted by node abort$/s.test(handle.error ?? ""))) {
102369
102535
  const source = durableWorkflowRunSnapshots(backend, handle).find((run) => run.id === handle.workflowId);
@@ -102453,7 +102619,8 @@ async function resumeDurableWorkflowClaimed(workflowId, deps, catalog) {
102453
102619
  runId: resolved.workflowId,
102454
102620
  durableBackend: backend,
102455
102621
  ...toolContinuation === undefined ? {} : { continuation: toolContinuation },
102456
- ...snapshotJournal === undefined ? {} : { [restorePreconditionsChecked]: true }
102622
+ ...snapshotJournal === undefined ? {} : { [restorePreconditionsChecked]: true },
102623
+ ...deps.baseRunOpts.cwd === undefined ? {} : { [resumeLaunchCwd]: deps.baseRunOpts.cwd }
102457
102624
  };
102458
102625
  let launch;
102459
102626
  try {
@@ -102723,6 +102890,7 @@ async function completedWorkflowRunSnapshots(backend, entry, sessionStore) {
102723
102890
  endedAt: handle.updatedAt,
102724
102891
  durationMs: rootDuration,
102725
102892
  ...handle.worktreeRootMappings !== undefined ? { worktreeRootMappings: handle.worktreeRootMappings } : {},
102893
+ ...handle.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: handle.worktreeRestoreOutcomes } : {},
102726
102894
  ...handle.error !== undefined ? { error: handle.error } : {},
102727
102895
  ...handle.exited !== undefined ? { exited: handle.exited } : {},
102728
102896
  ...handle.exitReason !== undefined ? { exitReason: handle.exitReason } : {},
@@ -102769,6 +102937,7 @@ function rootSnapshot(backend, handle, graph) {
102769
102937
  stages: graph.stages,
102770
102938
  toolNodes: graph.toolNodes,
102771
102939
  ...handle.worktreeRootMappings !== undefined ? { worktreeRootMappings: handle.worktreeRootMappings } : {},
102940
+ ...handle.worktreeRestoreOutcomes !== undefined ? { worktreeRestoreOutcomes: handle.worktreeRestoreOutcomes } : {},
102772
102941
  startedAt: handle.createdAt,
102773
102942
  ...terminal ? { endedAt: handle.updatedAt, durationMs: terminalDurationMs } : priorDurationMs === undefined ? {} : { accumulatedDurationMs: priorDurationMs },
102774
102943
  ...handle.error !== undefined ? { error: handle.error } : {},
@@ -104302,6 +104471,8 @@ function summaryRows(detail, now) {
104302
104471
  rows.push(["last progress", formatTime(detail.lastProgressAt)]);
104303
104472
  if (detail.dependencyError !== undefined)
104304
104473
  rows.push(["dependency", detail.dependencyError]);
104474
+ for (const notice of detail.worktreeRestore ?? [])
104475
+ rows.push(["checkout", notice]);
104305
104476
  if (detail.intercomDeliveryIssue !== undefined)
104306
104477
  rows.push(["intercom", detail.intercomDeliveryIssue]);
104307
104478
  if (detail.controlPersistence !== undefined) {
@@ -116323,7 +116494,8 @@ function inspectRun(runId, opts) {
116323
116494
  retryAfterMs: copy.retryAfterMs,
116324
116495
  blockedAt: copy.blockedAt,
116325
116496
  ...strandedRoot ? { strandedRoot: true } : {},
116326
- ...stagePredictionsOf(copy, activeStore.runs())
116497
+ ...stagePredictionsOf(copy, activeStore.runs()),
116498
+ ...copy.worktreeRestoreOutcomes !== undefined && copy.worktreeRestoreOutcomes.length > 0 ? { worktreeRestore: copy.worktreeRestoreOutcomes.map((outcome) => outcome.message) } : {}
116327
116499
  };
116328
116500
  return { ok: true, runId: copy.id, detail };
116329
116501
  }
@@ -124334,7 +124506,8 @@ function buildWorkflowRunStatusDigest(detail) {
124334
124506
  ...detail.forkedFrom === undefined ? {} : { forkedFrom: detail.forkedFrom },
124335
124507
  ...detail.resumeGuidance === undefined ? {} : { resumeGuidance: detail.resumeGuidance },
124336
124508
  ...detail.ownerActiveElsewhere === true ? { ownerActiveElsewhere: true } : {},
124337
- blockers: blockers(detail)
124509
+ blockers: blockers(detail),
124510
+ ...detail.worktreeRestore === undefined ? {} : { worktreeRestore: detail.worktreeRestore }
124338
124511
  };
124339
124512
  }
124340
124513
 
@@ -124487,7 +124660,8 @@ function summarizeRunSnapshot(run, now = Date.now(), options) {
124487
124660
  suspendedStages,
124488
124661
  exitReason: run.exitReason,
124489
124662
  error: run.error ?? (strandedRoot ? IMPOSSIBLE_ROOT_LIVENESS_MESSAGE : undefined),
124490
- ...strandedRoot ? { strandedRoot: true } : {}
124663
+ ...strandedRoot ? { strandedRoot: true } : {},
124664
+ ...run.worktreeRestoreOutcomes !== undefined && run.worktreeRestoreOutcomes.length > 0 ? { worktreeRestore: run.worktreeRestoreOutcomes.map((outcome) => outcome.message) } : {}
124491
124665
  };
124492
124666
  }
124493
124667
  function runMatchesStatusFilter(summary, filter) {
@@ -124794,6 +124968,8 @@ function renderStatusToolContent(result) {
124794
124968
  }
124795
124969
  if (run.dependencyError !== undefined)
124796
124970
  lines.push(` dependency: ${run.dependencyError}`);
124971
+ for (const notice of run.worktreeRestore ?? [])
124972
+ lines.push(` checkout: ${notice}`);
124797
124973
  if (run.intercomDeliveryIssue !== undefined)
124798
124974
  lines.push(` Intercom delivery: ${run.intercomDeliveryIssue}`);
124799
124975
  if (run.controlPersistence !== undefined) {
@@ -126273,6 +126449,8 @@ function statusDigestNoticeText(digest) {
126273
126449
  for (const blocker of digest.blockers) {
126274
126450
  lines.push(`${blocker.kind}: ${blocker.name}${blocker.message === undefined ? "" : ` — ${blocker.message}`}`);
126275
126451
  }
126452
+ for (const notice of digest.worktreeRestore ?? [])
126453
+ lines.push(`checkout: ${notice}`);
126276
126454
  return lines.join(`
126277
126455
  `);
126278
126456
  }