@linnlabs/linnkit 0.35.0 → 0.36.0

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.
@@ -3199,13 +3199,21 @@ var GraphExecutor = class {
3199
3199
  if (existing) {
3200
3200
  throw new Error(`Graph checkpoint already exists: ${checkpointKey}`);
3201
3201
  }
3202
- this.ephemeralLocals.set(checkpointKey, { ...local });
3202
+ const initialLocal = this.executionCheckpointPort ? {
3203
+ ...local,
3204
+ executorLocal: {
3205
+ ...isRecord4(local.executorLocal) ? local.executorLocal : {},
3206
+ stepCount: 0,
3207
+ maxSteps: options.maxSteps ?? this.config.maxSteps
3208
+ }
3209
+ } : local;
3210
+ this.ephemeralLocals.set(checkpointKey, { ...initialLocal });
3203
3211
  await this.commitCheckpoint(checkpointKey, {
3204
3212
  nodeId,
3205
3213
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
3206
3214
  revision: 1,
3207
3215
  schemaVersion: ENGINE_STATE_SCHEMA_VERSION,
3208
- local: sanitizeCheckpointLocal(local)
3216
+ local: sanitizeCheckpointLocal(initialLocal)
3209
3217
  });
3210
3218
  return this.runUntilYieldQueued(
3211
3219
  checkpointKey,
@@ -12049,7 +12057,7 @@ function createAwaitingUserWatcher(options) {
12049
12057
  const onClose = () => {
12050
12058
  dispose();
12051
12059
  };
12052
- eventBus.on("event", onEvent);
12060
+ if (options.stateOwner !== "host") eventBus.on("event", onEvent);
12053
12061
  eventBus.on("close", onClose);
12054
12062
  return dispose;
12055
12063
  }
@@ -12525,6 +12533,7 @@ var DefaultRunSupervisor = class {
12525
12533
  this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
12526
12534
  this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
12527
12535
  this.awaitingUserWatcher = createAwaitingUserWatcher({
12536
+ stateOwner: options.awaitingUserStateOwner,
12528
12537
  markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
12529
12538
  onDisposed: (runId) => {
12530
12539
  this.eventWatchDisposers.delete(runId);
@@ -12721,8 +12730,17 @@ var DefaultRunSupervisor = class {
12721
12730
  canRestoreRun: this.canRestoreRun
12722
12731
  });
12723
12732
  }
12724
- async pause(runId, reason) {
12725
- await this.withRunControlLock(runId, () => this.getHandle(runId).pause(reason));
12733
+ async pause(runId, reason, expectedExecutionId) {
12734
+ await this.withRunControlLock(runId, async () => {
12735
+ const handle = this.getHandle(runId);
12736
+ if (expectedExecutionId !== void 0) {
12737
+ const record = await this.registryStore.load(runId);
12738
+ if (record?.metadata?.executionId !== expectedExecutionId) {
12739
+ throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
12740
+ }
12741
+ }
12742
+ await handle.pause(reason);
12743
+ });
12726
12744
  }
12727
12745
  async resumePausedRun(input) {
12728
12746
  return this.withRunControlLock(input.runId, async () => {