@bastani/atomic 0.9.65 → 0.9.66

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 (48) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/package.json +1 -1
  7. package/dist/builtin/workflows/src/extension/index.bundle.mjs +154 -36
  8. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +125 -16
  9. package/dist/builtin/workflows/src/index.js +125 -16
  10. package/dist/builtin/workflows/src/local-worker-entry.mjs +125 -16
  11. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +8 -0
  12. package/dist/core/agent-session-auto-compaction.js +2 -2
  13. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  14. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  15. package/dist/core/agent-session-compaction.js +9 -1
  16. package/dist/core/agent-session-compaction.js.map +1 -1
  17. package/dist/core/agent-session-methods.d.ts +5 -2
  18. package/dist/core/agent-session-methods.d.ts.map +1 -1
  19. package/dist/core/agent-session-methods.js.map +1 -1
  20. package/dist/core/agent-session-post-tool-compaction.js +2 -2
  21. package/dist/core/agent-session-post-tool-compaction.js.map +1 -1
  22. package/dist/core/compaction/compaction-runner.d.ts +18 -2
  23. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  24. package/dist/core/compaction/compaction-runner.js +129 -15
  25. package/dist/core/compaction/compaction-runner.js.map +1 -1
  26. package/dist/core/compaction/compaction-types.d.ts +4 -0
  27. package/dist/core/compaction/compaction-types.d.ts.map +1 -1
  28. package/dist/core/compaction/compaction-types.js.map +1 -1
  29. package/dist/core/settings-defaults.d.ts +2 -0
  30. package/dist/core/settings-defaults.d.ts.map +1 -1
  31. package/dist/core/settings-defaults.js +2 -0
  32. package/dist/core/settings-defaults.js.map +1 -1
  33. package/dist/core/settings-manager-basic-accessors.d.ts +2 -0
  34. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  35. package/dist/core/settings-manager-basic-accessors.js +7 -0
  36. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  37. package/dist/core/settings-schema.d.ts +2 -0
  38. package/dist/core/settings-schema.d.ts.map +1 -1
  39. package/dist/core/settings-schema.js +4 -0
  40. package/dist/core/settings-schema.js.map +1 -1
  41. package/docs/compaction.md +5 -1
  42. package/docs/session-format.md +1 -1
  43. package/docs/settings.md +2 -1
  44. package/docs/workflows/api-reference.md +3 -1
  45. package/docs/workflows/operations.md +5 -2
  46. package/npm-shrinkwrap.json +32 -32
  47. package/package.json +3 -3
  48. package/schemas/settings.schema.json +14 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.66] - 2026-11-02
6
+
7
+ Long sessions no longer stall for tens of minutes in automatic compaction, and a crashed workflow root on local workers can resume after its settings or worker code changed.
8
+
9
+ - **Compaction has a time limit:** automatic compaction's model planning now gives up after `compaction.planningTimeoutMs` (five minutes by default) instead of blocking a turn for 15 to 45 minutes, and the turn continues in a fresh context window ([#4199](https://github.com/bastani-inc/atomic/pull/4199))
10
+ - **Resume after settings changes:** a crashed root on local workers resumes after its pool size or admission limits changed, and a change that does block a resume is named with its old and new value ([#4201](https://github.com/bastani-inc/atomic/pull/4201))
11
+ - **Resume after a code edit:** `/workflow resume <id> --accept-entry-changes` resumes a crashed root after a worker definition's entry module was edited, and a resume under another execution mode than the launch now works ([#4213](https://github.com/bastani-inc/atomic/pull/4213))
12
+
13
+ ### Fixed
14
+
15
+ - A workflow root that runs children on local workers (`workflows.localWorkers`) and then crashed, for example when the host killed Atomic, now resumes after `workflows.localWorkers.count`, `workflows.admission.limits` or `workflows.admission.host` changed. Before, any such change refused the resume with `Worker definition compatibility or immutable resource configuration changed`. The error did not say what had changed, and a root with hours of completed work had to start over. The root now resumes with the current values and records them. Completed steps replay from the journal, and new work runs the current code, including any edited helper module. A change that the root's recorded work depends on is still refused, and the error now names each one with its old and new value: a worker definition added or removed, an edited definition entry module, changed `admission.userLimits` or `admission.userDatabase`, or local workers or admission turned on or off ([#4196](https://github.com/bastani-inc/atomic/issues/4196)).
16
+ - A crashed workflow root that runs children on local workers can now be resumed after a worker definition's entry module was edited, by accepting the edit: `/workflow resume <id> --accept-entry-changes`, or `acceptEntryChanges: true` in the SDK. Completed steps replay from the journal, and the root's unfinished children, including children queued before the crash that no worker had started, run the edited module. Without the opt-in the resume is still refused, and the error now names the module, its old and new digest, and the opt-in. Such a root also resumes under another execution mode than it was launched in, for example `runtime.resumeDurableWorkflow(id)` without a policy after a launch from the terminal UI. Before, that resume was accepted and the root then failed with `Pool boundary identity conflict`; its unfinished children now run under the resume's mode ([#4200](https://github.com/bastani-inc/atomic/issues/4200)).
17
+ - Automatic compaction can no longer block a turn for tens of minutes. A long session that crossed the compaction threshold after a tool result waited on the compaction planner with no overall limit. A planner that kept streaming, such as long reasoning over a very large uncached transcript, never tripped the stream idle deadline, and every retry, overflow trim and borrowed fallback model repeated it. Sessions sat 15 to 45 minutes with no new turn and no error. Model planning in automatic compaction now has a time limit, `compaction.planningTimeoutMs`, five minutes by default. When it runs out, the planner request is aborted. Post-tool and overflow compaction then start a fresh context window so the turn continues, and threshold compaction fails with a clear timeout error and leaves the context unchanged. Credential lookups for the session model and each fallback count against the same limit, and a fresh context window reached after failed planning records the cause in `details.freshReason`. Manual `/compact` is not limited ([#4198](https://github.com/bastani-inc/atomic/issues/4198), [#4199](https://github.com/bastani-inc/atomic/pull/4199))
18
+
19
+ ## [0.9.66-alpha.1] - 2026-11-02
20
+
21
+ Long sessions no longer stall for tens of minutes in automatic compaction, and a crashed workflow root on local workers can resume after its settings or worker code changed.
22
+
23
+ - **Compaction has a time limit:** automatic compaction's model planning now gives up after `compaction.planningTimeoutMs` (five minutes by default) instead of blocking a turn for 15 to 45 minutes, and the turn continues in a fresh context window ([#4199](https://github.com/bastani-inc/atomic/pull/4199))
24
+ - **Resume after settings changes:** a crashed root on local workers resumes after its pool size or admission limits changed, and a change that does block a resume is named with its old and new value ([#4201](https://github.com/bastani-inc/atomic/pull/4201))
25
+ - **Resume after a code edit:** `/workflow resume <id> --accept-entry-changes` resumes a crashed root after a worker definition's entry module was edited, and a resume under another execution mode than the launch now works ([#4213](https://github.com/bastani-inc/atomic/pull/4213))
26
+
27
+ ### Fixed
28
+
29
+ - A workflow root that runs children on local workers (`workflows.localWorkers`) and then crashed, for example when the host killed Atomic, now resumes after `workflows.localWorkers.count`, `workflows.admission.limits` or `workflows.admission.host` changed. Before, any such change refused the resume with `Worker definition compatibility or immutable resource configuration changed`. The error did not say what had changed, and a root with hours of completed work had to start over. The root now resumes with the current values and records them. Completed steps replay from the journal, and new work runs the current code, including any edited helper module. A change that the root's recorded work depends on is still refused, and the error now names each one with its old and new value: a worker definition added or removed, an edited definition entry module, changed `admission.userLimits` or `admission.userDatabase`, or local workers or admission turned on or off ([#4196](https://github.com/bastani-inc/atomic/issues/4196)).
30
+ - A crashed workflow root that runs children on local workers can now be resumed after a worker definition's entry module was edited, by accepting the edit: `/workflow resume <id> --accept-entry-changes`, or `acceptEntryChanges: true` in the SDK. Completed steps replay from the journal, and the root's unfinished children, including children queued before the crash that no worker had started, run the edited module. Without the opt-in the resume is still refused, and the error now names the module, its old and new digest, and the opt-in. Such a root also resumes under another execution mode than it was launched in, for example `runtime.resumeDurableWorkflow(id)` without a policy after a launch from the terminal UI. Before, that resume was accepted and the root then failed with `Pool boundary identity conflict`; its unfinished children now run under the resume's mode ([#4200](https://github.com/bastani-inc/atomic/issues/4200)).
31
+ - Automatic compaction can no longer block a turn for tens of minutes. A long session that crossed the compaction threshold after a tool result waited on the compaction planner with no overall limit. A planner that kept streaming, such as long reasoning over a very large uncached transcript, never tripped the stream idle deadline, and every retry, overflow trim and borrowed fallback model repeated it. Sessions sat 15 to 45 minutes with no new turn and no error. Model planning in automatic compaction now has a time limit, `compaction.planningTimeoutMs`, five minutes by default. When it runs out, the planner request is aborted. Post-tool and overflow compaction then start a fresh context window so the turn continues, and threshold compaction fails with a clear timeout error and leaves the context unchanged. Credential lookups for the session model and each fallback count against the same limit, and a fresh context window reached after failed planning records the cause in `details.freshReason`. Manual `/compact` is not limited ([#4198](https://github.com/bastani-inc/atomic/issues/4198), [#4199](https://github.com/bastani-inc/atomic/pull/4199))
32
+
5
33
  ## [0.9.65] - 2026-11-02
6
34
 
7
35
  Subagents launched on a named model stay on that model or fail clearly, and every report names the model a subagent actually ran on.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/intercom",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
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": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/mcp",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
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": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/subagents",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
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": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/web-access",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
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": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.65",
3
+ "version": "0.9.66",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -21095,12 +21095,19 @@ class SqlResourceAdmission {
21095
21095
  if (!(await tx.all(`PRAGMA table_info(${admission.owners})`)).some((entry) => entry.name === "boot"))
21096
21096
  await tx.exec(`ALTER TABLE ${admission.owners} ADD COLUMN boot TEXT`);
21097
21097
  await tx.run(`INSERT INTO ${admission.owners}(id, host, pid, expires_at, boot) VALUES (?, ?, ?, CAST(unixepoch('subsec') * 1000 AS INTEGER) + ?, ?)`, admission.owner, admissionHost, process.pid, OWNER_LEASE_MS, boot);
21098
+ const rootLimits = options.rootLimits ?? "check";
21098
21099
  for (const [scope, limits] of [
21099
21100
  [`root:${options.root}`, options.limits],
21100
21101
  ["user", options.userLimits]
21101
21102
  ]) {
21102
- if (!limits && (scope === "user" || !options.host))
21103
+ const ofRoot = scope !== "user";
21104
+ if (ofRoot && rootLimits === "unchanged")
21103
21105
  continue;
21106
+ if (!limits && (scope === "user" || !options.host)) {
21107
+ if (ofRoot && rootLimits === "replace")
21108
+ await tx.run(`DELETE FROM ${admission.configuration} WHERE scope = ?`, scope);
21109
+ continue;
21110
+ }
21104
21111
  const config = JSON.stringify({
21105
21112
  session: limits?.session ?? null,
21106
21113
  process: limits?.process ?? null,
@@ -21111,6 +21118,10 @@ class SqlResourceAdmission {
21111
21118
  }
21112
21119
  }
21113
21120
  });
21121
+ if (ofRoot && rootLimits === "replace") {
21122
+ await tx.run(`INSERT OR REPLACE INTO ${admission.configuration} VALUES (?, ?)`, scope, config);
21123
+ continue;
21124
+ }
21114
21125
  await tx.run(`INSERT OR IGNORE INTO ${admission.configuration} VALUES (?, ?)`, scope, config);
21115
21126
  if ((await tx.get(`SELECT config FROM ${admission.configuration} WHERE scope = ?`, scope))?.config !== config)
21116
21127
  throw new Error("Conflicting resource admission configuration");
@@ -21550,7 +21561,8 @@ async function admitWorkflowSessions(backend, opts, callback) {
21550
21561
  const admission = await SqlResourceAdmission.open(poolJournalFor(rootBackend.journal), {
21551
21562
  ...config,
21552
21563
  root: opts.parentRun?.rootRunId ?? opts.runId,
21553
- holder: randomUUID8()
21564
+ holder: randomUUID8(),
21565
+ ...opts.parentRun === undefined ? { rootLimits: "replace" } : {}
21554
21566
  });
21555
21567
  return withResourceAdmission(admission, () => callback({
21556
21568
  ...opts,
@@ -63989,6 +64001,12 @@ function expiry(now, duration) {
63989
64001
  positive(expiresAt);
63990
64002
  return expiresAt;
63991
64003
  }
64004
+ function short(digest) {
64005
+ return digest.slice(0, 12);
64006
+ }
64007
+ function shownMode(mode) {
64008
+ return mode === undefined ? "unset" : JSON.stringify(mode);
64009
+ }
63992
64010
 
63993
64011
  class SqlPoolQueue {
63994
64012
  storage;
@@ -64169,7 +64187,7 @@ class SqlPoolQueue {
64169
64187
  throw new Error(STALE_WORK_LEASE);
64170
64188
  });
64171
64189
  }
64172
- async enqueue(lease, descriptor, boundary) {
64190
+ async enqueue(lease, descriptor, boundary, options = {}) {
64173
64191
  lease = snapshotLease(lease);
64174
64192
  const { boundaryId, childRunId, scope } = descriptor;
64175
64193
  const topology = boundary.topology;
@@ -64198,12 +64216,11 @@ class SqlPoolQueue {
64198
64216
  const { now } = await this.authority(tx, lease);
64199
64217
  const previous = await tx.get(`SELECT * FROM ${this.work} WHERE root = ? AND (boundary = ? OR json_extract(descriptor, '$.scope') = ? OR json_extract(descriptor, '$.childRunId') = ?)`, lease.runId, boundaryId, scope, childRunId);
64200
64218
  if (previous) {
64201
- if (previous.fingerprint !== fingerprint)
64202
- throw new Error("Pool boundary identity conflict");
64203
- if (previous.state !== "ready" && previous.state !== "failed" || previous.epoch >= lease.epoch)
64204
- return fromRow(previous);
64205
- await tx.run(`UPDATE ${this.work} SET state = 'ready', epoch = ? WHERE id = ?`, lease.epoch, previous.id);
64206
- return fromRow({ ...previous, state: "ready", epoch: lease.epoch });
64219
+ const row = previous.fingerprint === fingerprint ? previous : await this.rebind(tx, lease, previous, json, JSON.parse(payload), fingerprint, options);
64220
+ if (row.state !== "ready" && row.state !== "failed" || row.epoch >= lease.epoch)
64221
+ return fromRow(row);
64222
+ await tx.run(`UPDATE ${this.work} SET state = 'ready', epoch = ? WHERE id = ?`, lease.epoch, row.id);
64223
+ return fromRow({ ...row, state: "ready", epoch: lease.epoch });
64207
64224
  }
64208
64225
  const siblings = await tx.all(`SELECT json_extract(descriptor, '$.scope') AS scope FROM ${this.work} WHERE root = ?`, lease.runId);
64209
64226
  if (siblings.some((item) => scope.startsWith(`${item.scope}:`) || item.scope.startsWith(`${scope}:`)))
@@ -64234,6 +64251,32 @@ class SqlPoolQueue {
64234
64251
  if (outcome.status === "exists" && !isSameCheckpointValue(outcome.entry.event.payload, boundary))
64235
64252
  throw new Error("Pool boundary identity conflict");
64236
64253
  }
64254
+ async rebind(tx, lease, previous, json, boundary, fingerprint, options) {
64255
+ const queued = JSON.parse(previous.descriptor);
64256
+ const requested = JSON.parse(json);
64257
+ const queuedMode = queued.execution.executionMode;
64258
+ const requestedMode = requested.execution.executionMode;
64259
+ const { executionMode: _mode, ...execution } = requested.execution;
64260
+ const asQueued = {
64261
+ ...requested,
64262
+ digest: queued.digest,
64263
+ execution: queuedMode === undefined ? execution : { ...execution, executionMode: queuedMode }
64264
+ };
64265
+ if (durableHash({ descriptor: asQueued, boundary }) !== previous.fingerprint)
64266
+ throw new Error("Pool boundary identity conflict");
64267
+ const entryEdited = queued.digest !== requested.digest;
64268
+ if (previous.epoch >= lease.epoch) {
64269
+ const changes = [
64270
+ ...entryEdited ? [`entry module (sha256 ${short(queued.digest)} to ${short(requested.digest)})`] : [],
64271
+ ...queuedMode !== requestedMode ? [`execution mode (${shownMode(queuedMode)} to ${shownMode(requestedMode)})`] : []
64272
+ ];
64273
+ throw new Error(`Pool boundary identity conflict: child ${requested.childRunId} is already queued by this incarnation of root ${lease.runId}, and its worker may be running it, so its ${changes.join(" and ")} cannot change`);
64274
+ }
64275
+ if (entryEdited && options.acceptEntryChanges !== true)
64276
+ throw new Error(`Pool boundary identity conflict: child ${requested.childRunId} was queued by an earlier run of root ${lease.runId} with the entry module of worker definition ${requested.definition} at sha256 ${short(queued.digest)}, and the root now runs that module at sha256 ${short(requested.digest)}. Resume the root with /workflow resume ${lease.runId} --accept-entry-changes, or acceptEntryChanges: true in the SDK, to run the child with the edited module, or restore the module.`);
64277
+ await tx.run(`UPDATE ${this.work} SET descriptor = ?, fingerprint = ? WHERE id = ?`, json, fingerprint, previous.id);
64278
+ return { ...previous, descriptor: json, fingerprint };
64279
+ }
64237
64280
  async claim(lease, worker, definitions, durationMs) {
64238
64281
  positive(durationMs);
64239
64282
  lease = snapshotLease(lease);
@@ -69693,7 +69736,9 @@ class PoolCoordinator {
69693
69736
  const queue = this.queue;
69694
69737
  const lease = this.lease;
69695
69738
  const work = await this.retainedTransition(async () => {
69696
- let enqueued = await this.whileRootLate(queue, () => queue.enqueue(lease, command.descriptor, command.boundary));
69739
+ let enqueued = await this.whileRootLate(queue, () => queue.enqueue(lease, command.descriptor, command.boundary, {
69740
+ acceptEntryChanges: command.acceptEntryChanges === true
69741
+ }));
69697
69742
  if (enqueued.state === "completed" && enqueued.epoch < lease.epoch)
69698
69743
  enqueued = await this.whileRootLate(queue, () => queue.reopenCompleted(lease, enqueued.id, failedOnInfrastructureFault)) ?? enqueued;
69699
69744
  const retained = this.retained.get(enqueued.id);
@@ -73242,7 +73287,8 @@ class LocalWorkerPool {
73242
73287
  inputs,
73243
73288
  execution
73244
73289
  },
73245
- boundary
73290
+ boundary,
73291
+ ...this.options.acceptEntryChanges === true ? { acceptEntryChanges: true } : {}
73246
73292
  });
73247
73293
  const work = enqueued.work;
73248
73294
  this.works.set(work.id, work);
@@ -73678,6 +73724,56 @@ var DEFAULT_POOLED_STAGE_START_MAX_LOAD_PER_CPU = 3;
73678
73724
  // dist/builtin/workflows/src/workers/public-pool.ts
73679
73725
  import { resolve as resolve17 } from "node:path";
73680
73726
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
73727
+ function shown(value2) {
73728
+ return value2 === undefined ? "unset" : JSON.stringify(value2);
73729
+ }
73730
+ function isPlainRecord(value2) {
73731
+ return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
73732
+ }
73733
+ function settingChanges(path, saved, current, changes) {
73734
+ if (isDeepStrictEqual2(saved, current))
73735
+ return;
73736
+ if ((saved === undefined || isPlainRecord(saved)) && (current === undefined || isPlainRecord(current))) {
73737
+ for (const key of new Set([...Object.keys(saved ?? {}), ...Object.keys(current ?? {})]))
73738
+ settingChanges(`${path}.${key}`, saved?.[key], current?.[key], changes);
73739
+ return;
73740
+ }
73741
+ changes.push({
73742
+ description: `${path} changed from ${shown(saved)} to ${shown(current)}`,
73743
+ resumable: RESUMABLE_SETTINGS.has(path)
73744
+ });
73745
+ }
73746
+ function resourceChanges(saved, current) {
73747
+ const changes = [];
73748
+ if (saved.localWorkers === undefined !== (current.localWorkers === undefined))
73749
+ changes.push({
73750
+ description: `local workers were turned ${current.localWorkers === undefined ? "off" : "on"}`,
73751
+ resumable: false
73752
+ });
73753
+ else {
73754
+ settingChanges("localWorkers", saved.localWorkers && { ...saved.localWorkers, definitions: undefined }, current.localWorkers && { ...current.localWorkers, definitions: undefined }, changes);
73755
+ }
73756
+ const named = (list) => new Map((list ?? []).map((source) => [`${source.path}#${source.exportName}`, source.digest]));
73757
+ const before = named(saved.definitions);
73758
+ const after = named(current.definitions);
73759
+ for (const [name, digest] of before) {
73760
+ const now = after.get(name);
73761
+ if (now === undefined)
73762
+ changes.push({ description: `worker definition ${name} is no longer listed`, resumable: false });
73763
+ else if (now !== digest)
73764
+ changes.push({
73765
+ description: `the entry module of worker definition ${name} was edited (sha256 ${digest.slice(0, 12)} to ${now.slice(0, 12)})`,
73766
+ resumable: false,
73767
+ entry: true
73768
+ });
73769
+ }
73770
+ for (const name of after.keys())
73771
+ if (!before.has(name))
73772
+ changes.push({ description: `worker definition ${name} was added`, resumable: false });
73773
+ settingChanges("admission", saved.admission, current.admission, changes);
73774
+ settingChanges("coordinator", saved.coordinator, current.coordinator, changes);
73775
+ return changes;
73776
+ }
73681
73777
  function withWorkerSettings(options, settings) {
73682
73778
  const configured = settings?.workflows;
73683
73779
  if (!configured || Array.isArray(configured))
@@ -73694,8 +73790,10 @@ async function restoreWorkerOptions(backend, options) {
73694
73790
  await backend.hydrateWorkflow(source);
73695
73791
  const original = source === undefined ? undefined : backend.getWorkflow(source);
73696
73792
  const saved = original?.resources;
73697
- if (original && !saved && (options.localWorkers || options.admission))
73698
- throw new Error("Immutable resource configuration cannot change on an existing root");
73793
+ if (original && !saved && (options.localWorkers || options.admission)) {
73794
+ const set = [options.localWorkers && "localWorkers", options.admission && "admission"].filter(Boolean).join(" and ");
73795
+ throw new Error(`Root ${source} started without local workers or resource admission, and this resume sets ${set}: immutable resource configuration cannot change on an existing root. Resume it without them, or start a new run.`);
73796
+ }
73699
73797
  return {
73700
73798
  ...options,
73701
73799
  localWorkers: options.localWorkers ?? saved?.localWorkers,
@@ -73758,14 +73856,16 @@ async function activatePublicPool(backend, options) {
73758
73856
  throw new Error(`This root's local workers ran on another machine (${saved.host}). Their work queue and leases are in that machine's pool database, which this machine cannot see, and its workers may still be running children. Resume the root on that machine.`);
73759
73857
  if (saved !== undefined && resources.coordinator !== undefined && saved.host === resources.coordinator.host && saved.database !== resources.coordinator.database)
73760
73858
  throw new Error(`This root's local workers keep their work queue and leases in the pool database ${saved.database} on this machine, but the journal is now selected in a way that uses ${resources.coordinator.database}: its adapter, options, prefix or the agent directory changed. Resume the root with the journal selected as it was when the root started.`);
73761
- if (options.effectiveResources && !isDeepStrictEqual2(options.effectiveResources, resources))
73762
- throw new Error("Worker definition compatibility or immutable resource configuration changed");
73859
+ const refused = options.effectiveResources === undefined ? [] : resourceChanges(options.effectiveResources, resources).filter((change) => !change.resumable && !(change.entry && options.acceptEntryChanges === true));
73860
+ if (refused.length > 0)
73861
+ throw new Error(`Since root ${options.runId} started, ${refused.map((change) => change.description).join("; ")}. Its recorded steps and queued children depend on these, so restore them to resume it, or start a new run. The pool size (localWorkers.count) and the root's own limits (admission.limits and admission.host) can change between resumes.${refused.some((change) => change.entry) ? ` An edited entry module can also be accepted: resume with /workflow resume ${options.runId} --accept-entry-changes, or acceptEntryChanges: true in the SDK, to replay the recorded steps and run the rest of each unfinished child with the edited module.` : ""}`);
73763
73862
  options.effectiveResources = resources;
73764
73863
  if (resources.admission)
73765
73864
  await SqlResourceAdmission.open(poolJournal, {
73766
73865
  ...resources.admission,
73767
73866
  root: options.runId,
73768
- holder: "preflight"
73867
+ holder: "preflight",
73868
+ rootLimits: "unchanged"
73769
73869
  });
73770
73870
  if (!localWorkers)
73771
73871
  return;
@@ -73780,6 +73880,7 @@ async function activatePublicPool(backend, options) {
73780
73880
  startupTimeoutMs: options.localWorkers?.startupTimeoutMs,
73781
73881
  leaseMs: options.localWorkers?.leaseMs,
73782
73882
  maxLoadPerCpu: options.localWorkers?.maxLoadPerCpu ?? DEFAULT_POOLED_STAGE_START_MAX_LOAD_PER_CPU,
73883
+ ...options.acceptEntryChanges === true ? { acceptEntryChanges: true } : {},
73783
73884
  ...options.stageControlRegistry === undefined || options[hostWorkerBindings] ? {} : { stageControlRegistry: options.stageControlRegistry }
73784
73885
  });
73785
73886
  try {
@@ -73790,6 +73891,7 @@ async function activatePublicPool(backend, options) {
73790
73891
  throw error;
73791
73892
  }
73792
73893
  }
73894
+ var RESUMABLE_SETTINGS;
73793
73895
  var init_public_pool = __esm(() => {
73794
73896
  init_journal_backend();
73795
73897
  init_admission_host();
@@ -73798,6 +73900,13 @@ var init_public_pool = __esm(() => {
73798
73900
  init_local_pool();
73799
73901
  init_pool_journal();
73800
73902
  init_resource_admission();
73903
+ RESUMABLE_SETTINGS = new Set([
73904
+ "localWorkers.count",
73905
+ "admission.limits.session",
73906
+ "admission.limits.process",
73907
+ "admission.host.maxLoadPerCpu",
73908
+ "admission.host.minFreeMemoryBytes"
73909
+ ]);
73801
73910
  });
73802
73911
 
73803
73912
  // dist/builtin/workflows/src/engine/primitives/chain.ts
@@ -99982,6 +100091,7 @@ async function injectWorkflowResumeSummary(pi, ctx, runId, run, forkedFrom, back
99982
100091
  }
99983
100092
 
99984
100093
  // dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts
100094
+ var ACCEPT_ENTRY_CHANGES_FLAG = "--accept-entry-changes";
99985
100095
  function stageScopedDurableResumeMessage(workflowId) {
99986
100096
  return `Stage-scoped resume is not supported for durable workflow ${workflowId}. Omit the stage selector to resume the whole run.`;
99987
100097
  }
@@ -100003,7 +100113,7 @@ function deleteWorkflowResumeEntry(workflowId, store2 = store) {
100003
100113
  return run !== undefined && run.status !== "completed" && (run.endedAt === undefined || run.status === "paused");
100004
100114
  });
100005
100115
  }
100006
- async function handleDurableResume(target, ctx, reporter, deps, preparedCatalog) {
100116
+ async function handleDurableResume(target, ctx, reporter, deps, preparedCatalog, resumeOptions = {}) {
100007
100117
  const owner = deps.owner ?? captureWorkflowOwnerResources();
100008
100118
  deps = { ...deps, owner };
100009
100119
  const print = (message) => reporter.info(message);
@@ -100027,7 +100137,7 @@ async function handleDurableResume(target, ctx, reporter, deps, preparedCatalog)
100027
100137
  return openCompletedTarget(resolved.workflowId, catalog.completed, ctx, reporter, deps, runtime);
100028
100138
  }
100029
100139
  if (resolved.kind === "durable") {
100030
- return await resumeDurableTarget(resolved.workflowId, ctx, reporter, deps, runtime);
100140
+ return await resumeDurableTarget(resolved.workflowId, ctx, reporter, deps, runtime, resumeOptions);
100031
100141
  }
100032
100142
  const completedAttempt = await openCompleted(runtime, target, catalog.completed, deps.beforeRestoreCompleted, owner.store);
100033
100143
  if (!completedAttempt.ok && completedAttempt.reason !== "not_found") {
@@ -100039,7 +100149,8 @@ async function handleDurableResume(target, ctx, reporter, deps, preparedCatalog)
100039
100149
  actor: "user",
100040
100150
  ...crossProjectConfirmation(ctx),
100041
100151
  onBeforeResume: (runId, forkedFrom) => injectWorkflowResumeSummary(deps.pi, ctx, runId, undefined, forkedFrom, runtime.durableBackend()),
100042
- ...releasedRunAdoption("workflowId" in resolved ? resolved.workflowId : target, ctx, runtime)
100152
+ ...releasedRunAdoption("workflowId" in resolved ? resolved.workflowId : target, ctx, runtime),
100153
+ ...resumeOptions
100043
100154
  });
100044
100155
  if (result.ok) {
100045
100156
  print(result.message);
@@ -100071,7 +100182,7 @@ ${instruction}: /workflow resume <id>`);
100071
100182
  return true;
100072
100183
  }
100073
100184
  if (picked.result.kind === "durable") {
100074
- return resumeDurableTarget(picked.result.workflowId, ctx, reporter, deps, runtime);
100185
+ return resumeDurableTarget(picked.result.workflowId, ctx, reporter, deps, runtime, resumeOptions);
100075
100186
  }
100076
100187
  if (picked.result.kind === "completed") {
100077
100188
  return openCompletedTarget(picked.result.workflowId, catalog.completed, ctx, reporter, deps, runtime);
@@ -100126,13 +100237,14 @@ function crossProjectConfirmation(ctx) {
100126
100237
  confirmCrossProjectFork: (cwd) => confirm("Resume workflow", `Workflow run found in different project: ${cwd}. Fork it into the current directory?`)
100127
100238
  } : {};
100128
100239
  }
100129
- async function resumeDurableTarget(workflowId, ctx, reporter, deps, runtime) {
100240
+ async function resumeDurableTarget(workflowId, ctx, reporter, deps, runtime, resumeOptions) {
100130
100241
  const result = await runtime.resumeDurableWorkflow(workflowId, {
100131
100242
  policy: workflowPolicyFromContext(ctx),
100132
100243
  actor: "user",
100133
100244
  ...crossProjectConfirmation(ctx),
100134
100245
  onBeforeResume: (runId, forkedFrom) => injectWorkflowResumeSummary(deps.pi, ctx, runId, undefined, forkedFrom, runtime.durableBackend()),
100135
- ...releasedRunAdoption(workflowId, ctx, runtime)
100246
+ ...releasedRunAdoption(workflowId, ctx, runtime),
100247
+ ...resumeOptions
100136
100248
  });
100137
100249
  if (!result.ok)
100138
100250
  reporter.error(result.message);
@@ -101302,7 +101414,8 @@ function createDurableResumeRuntime(deps) {
101302
101414
  ...deps.baseRunOpts(options?.policy),
101303
101415
  ...options?.budget === undefined ? {} : { budget: options.budget },
101304
101416
  ...options?.actor === undefined ? {} : { resumeActor: options.actor },
101305
- ...options?.modelOwner === undefined ? {} : { modelOwner: options.modelOwner }
101417
+ ...options?.modelOwner === undefined ? {} : { modelOwner: options.modelOwner },
101418
+ ...options?.acceptEntryChanges === true ? { acceptEntryChanges: true } : {}
101306
101419
  },
101307
101420
  durableBackend: backend,
101308
101421
  resolveDefinition: async (name, cwd) => (await discoverWorkflows({
@@ -101561,6 +101674,7 @@ function createExtensionRuntime(opts = {}) {
101561
101674
  ...runOptions(options?.policy),
101562
101675
  ...options?.actor === undefined ? {} : { resumeActor: options.actor },
101563
101676
  ...options?.budget === undefined ? {} : { budget: options.budget },
101677
+ ...options?.acceptEntryChanges === true ? { acceptEntryChanges: true } : {},
101564
101678
  continuation: {
101565
101679
  source,
101566
101680
  ...resolvedStage.stageId === undefined ? {} : { resumeFromStageId: resolvedStage.stageId },
@@ -104484,9 +104598,13 @@ ${renderSessionList(store.runs(), { theme, includeAll: true })}`);
104484
104598
  return true;
104485
104599
  }
104486
104600
  if (action === "attach" || action === "resume") {
104487
- const target = rest[0];
104488
- const stageTarget = rest[1];
104489
- const message = action === "resume" ? rest.slice(2).join(" ").trim() || undefined : undefined;
104601
+ const acceptEntryChanges = action === "resume" && rest.includes(ACCEPT_ENTRY_CHANGES_FLAG);
104602
+ const args = acceptEntryChanges ? rest.filter((token) => token !== ACCEPT_ENTRY_CHANGES_FLAG) : rest;
104603
+ const resumeOptions = acceptEntryChanges ? { acceptEntryChanges: true } : {};
104604
+ const durableResume = (workflowId, catalog) => handleDurableResume(workflowId, ctx, reporter, deps, catalog, resumeOptions);
104605
+ const target = args[0];
104606
+ const stageTarget = args[1];
104607
+ const message = action === "resume" ? args.slice(2).join(" ").trim() || undefined : undefined;
104490
104608
  let runId;
104491
104609
  if (!target) {
104492
104610
  const ui = ctx.ui;
@@ -104496,7 +104614,7 @@ ${renderSessionList(store.runs(), { theme, includeAll: true })}`);
104496
104614
 
104497
104615
  Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [stageId]`);
104498
104616
  } else {
104499
- return await handleDurableResume(undefined, ctx, reporter, deps);
104617
+ return await durableResume(undefined);
104500
104618
  }
104501
104619
  return true;
104502
104620
  }
@@ -104521,7 +104639,7 @@ Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [
104521
104639
  const durableEntries = picked.catalog.durable;
104522
104640
  const completedEntries = picked.catalog.completed;
104523
104641
  if (picked.result.kind === "durable" || picked.result.kind === "completed") {
104524
- return await handleDurableResume(picked.result.workflowId, ctx, reporter, deps, {
104642
+ return await durableResume(picked.result.workflowId, {
104525
104643
  resumable: durableEntries,
104526
104644
  completed: completedEntries
104527
104645
  });
@@ -104538,17 +104656,17 @@ Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [
104538
104656
  const isDurableAuthorExit = run?.exited === true && run.status === "failed" && run.resumable === true;
104539
104657
  const isResumableContinuation = run !== undefined && !isPaused && run.exitReason !== "quit" && isWorkflowRunResumable(workflowRunResumeCandidate(run, store.runs(), requireStoreDurableBackend(store, resolved.runId)));
104540
104658
  if (isDurableAuthorExit) {
104541
- return await handleDurableResume(resolved.runId, ctx, reporter, deps);
104659
+ return await durableResume(resolved.runId);
104542
104660
  }
104543
104661
  if (isResumableContinuation) {
104544
104662
  await ensureWorkflowResourcesVisible();
104545
- const continuation = await deps.runtimeForContext(ctx).resumeFailedRun(resolved.runId, undefined, { policy, actor: "user" });
104663
+ const continuation = await deps.runtimeForContext(ctx).resumeFailedRun(resolved.runId, undefined, { policy, actor: "user", ...resumeOptions });
104546
104664
  continuation.ok ? print(continuation.message) : fail(continuation.message);
104547
104665
  } else {
104548
104666
  try {
104549
104667
  const result = await resumeRun(resolved.runId, { ...owner, actor: "user" });
104550
104668
  if (result.ok && !isPaused && result.mode === "snapshot" && run?.exitReason === "quit") {
104551
- return await handleDurableResume(resolved.runId, ctx, reporter, deps);
104669
+ return await durableResume(resolved.runId);
104552
104670
  }
104553
104671
  if (result.ok && result.mode === "partial") {
104554
104672
  fail(result.message ?? `Partially resumed ${result.runId}.`);
@@ -104635,7 +104753,7 @@ Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [
104635
104753
  fail(stageScopedDurableResumeMessage(combined.workflowId));
104636
104754
  return true;
104637
104755
  }
104638
- return await handleDurableResume(combined.workflowId, ctx, reporter, deps);
104756
+ return await durableResume(combined.workflowId);
104639
104757
  }
104640
104758
  if (combined.kind === "live")
104641
104759
  runId = combined.workflowId;
@@ -104644,7 +104762,7 @@ Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [
104644
104762
  fail(`Failed to resolve workflow resume target: ${preparationError}`);
104645
104763
  return true;
104646
104764
  }
104647
- return await handleDurableResume(target, ctx, reporter, deps);
104765
+ return await durableResume(target);
104648
104766
  }
104649
104767
  }
104650
104768
  } else {
@@ -104694,16 +104812,16 @@ Picker requires an interactive UI surface. Pass a runId: /workflow attach <id> [
104694
104812
  }
104695
104813
  await injectWorkflowResumeSummary(deps.pi, ctx, stageRunId, run, undefined, requireStoreDurableBackend(store, stageRunId));
104696
104814
  if (isDurableAuthorExit) {
104697
- return await handleDurableResume(stageRunId, ctx, reporter, deps);
104815
+ return await durableResume(stageRunId);
104698
104816
  }
104699
104817
  if (isResumableContinuation) {
104700
104818
  await ensureWorkflowResourcesVisible();
104701
- const continuation = await deps.runtimeForContext(ctx).resumeFailedRun(stageRunId, stageId, { policy, actor: "user" });
104819
+ const continuation = await deps.runtimeForContext(ctx).resumeFailedRun(stageRunId, stageId, { policy, actor: "user", ...resumeOptions });
104702
104820
  continuation.ok ? print(continuation.message) : fail(continuation.message);
104703
104821
  return true;
104704
104822
  }
104705
104823
  if (!isPaused && run?.exitReason === "quit" && action === "resume") {
104706
- return await handleDurableResume(stageRunId, ctx, reporter, deps);
104824
+ return await durableResume(stageRunId);
104707
104825
  }
104708
104826
  let result;
104709
104827
  try {