@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.
package/dist/index.js CHANGED
@@ -3980,13 +3980,21 @@ var GraphExecutor = class {
3980
3980
  if (existing) {
3981
3981
  throw new Error(`Graph checkpoint already exists: ${checkpointKey}`);
3982
3982
  }
3983
- this.ephemeralLocals.set(checkpointKey, { ...local });
3983
+ const initialLocal = this.executionCheckpointPort ? {
3984
+ ...local,
3985
+ executorLocal: {
3986
+ ...isRecord4(local.executorLocal) ? local.executorLocal : {},
3987
+ stepCount: 0,
3988
+ maxSteps: options.maxSteps ?? this.config.maxSteps
3989
+ }
3990
+ } : local;
3991
+ this.ephemeralLocals.set(checkpointKey, { ...initialLocal });
3984
3992
  await this.commitCheckpoint(checkpointKey, {
3985
3993
  nodeId,
3986
3994
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
3987
3995
  revision: 1,
3988
3996
  schemaVersion: ENGINE_STATE_SCHEMA_VERSION,
3989
- local: sanitizeCheckpointLocal(local)
3997
+ local: sanitizeCheckpointLocal(initialLocal)
3990
3998
  });
3991
3999
  return this.runUntilYieldQueued(
3992
4000
  checkpointKey,
@@ -14304,7 +14312,7 @@ function createAwaitingUserWatcher(options) {
14304
14312
  const onClose = () => {
14305
14313
  dispose();
14306
14314
  };
14307
- eventBus.on("event", onEvent);
14315
+ if (options.stateOwner !== "host") eventBus.on("event", onEvent);
14308
14316
  eventBus.on("close", onClose);
14309
14317
  return dispose;
14310
14318
  }
@@ -14780,6 +14788,7 @@ var DefaultRunSupervisor = class {
14780
14788
  this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
14781
14789
  this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
14782
14790
  this.awaitingUserWatcher = createAwaitingUserWatcher({
14791
+ stateOwner: options.awaitingUserStateOwner,
14783
14792
  markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
14784
14793
  onDisposed: (runId) => {
14785
14794
  this.eventWatchDisposers.delete(runId);
@@ -14976,8 +14985,17 @@ var DefaultRunSupervisor = class {
14976
14985
  canRestoreRun: this.canRestoreRun
14977
14986
  });
14978
14987
  }
14979
- async pause(runId, reason) {
14980
- await this.withRunControlLock(runId, () => this.getHandle(runId).pause(reason));
14988
+ async pause(runId, reason, expectedExecutionId) {
14989
+ await this.withRunControlLock(runId, async () => {
14990
+ const handle = this.getHandle(runId);
14991
+ if (expectedExecutionId !== void 0) {
14992
+ const record = await this.registryStore.load(runId);
14993
+ if (record?.metadata?.executionId !== expectedExecutionId) {
14994
+ throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
14995
+ }
14996
+ }
14997
+ await handle.pause(reason);
14998
+ });
14981
14999
  }
14982
15000
  async resumePausedRun(input) {
14983
15001
  return this.withRunControlLock(input.runId, async () => {