@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/testkit.cjs CHANGED
@@ -3180,13 +3180,21 @@ var GraphExecutor = class {
3180
3180
  if (existing) {
3181
3181
  throw new Error(`Graph checkpoint already exists: ${checkpointKey}`);
3182
3182
  }
3183
- this.ephemeralLocals.set(checkpointKey, { ...local });
3183
+ const initialLocal = this.executionCheckpointPort ? {
3184
+ ...local,
3185
+ executorLocal: {
3186
+ ...isRecord4(local.executorLocal) ? local.executorLocal : {},
3187
+ stepCount: 0,
3188
+ maxSteps: options.maxSteps ?? this.config.maxSteps
3189
+ }
3190
+ } : local;
3191
+ this.ephemeralLocals.set(checkpointKey, { ...initialLocal });
3184
3192
  await this.commitCheckpoint(checkpointKey, {
3185
3193
  nodeId,
3186
3194
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
3187
3195
  revision: 1,
3188
3196
  schemaVersion: ENGINE_STATE_SCHEMA_VERSION,
3189
- local: sanitizeCheckpointLocal(local)
3197
+ local: sanitizeCheckpointLocal(initialLocal)
3190
3198
  });
3191
3199
  return this.runUntilYieldQueued(
3192
3200
  checkpointKey,
@@ -13487,7 +13495,7 @@ function createAwaitingUserWatcher(options) {
13487
13495
  const onClose = () => {
13488
13496
  dispose();
13489
13497
  };
13490
- eventBus.on("event", onEvent);
13498
+ if (options.stateOwner !== "host") eventBus.on("event", onEvent);
13491
13499
  eventBus.on("close", onClose);
13492
13500
  return dispose;
13493
13501
  }
@@ -13963,6 +13971,7 @@ var DefaultRunSupervisor = class {
13963
13971
  this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
13964
13972
  this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
13965
13973
  this.awaitingUserWatcher = createAwaitingUserWatcher({
13974
+ stateOwner: options.awaitingUserStateOwner,
13966
13975
  markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
13967
13976
  onDisposed: (runId) => {
13968
13977
  this.eventWatchDisposers.delete(runId);
@@ -14159,8 +14168,17 @@ var DefaultRunSupervisor = class {
14159
14168
  canRestoreRun: this.canRestoreRun
14160
14169
  });
14161
14170
  }
14162
- async pause(runId, reason) {
14163
- await this.withRunControlLock(runId, () => this.getHandle(runId).pause(reason));
14171
+ async pause(runId, reason, expectedExecutionId) {
14172
+ await this.withRunControlLock(runId, async () => {
14173
+ const handle = this.getHandle(runId);
14174
+ if (expectedExecutionId !== void 0) {
14175
+ const record = await this.registryStore.load(runId);
14176
+ if (record?.metadata?.executionId !== expectedExecutionId) {
14177
+ throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
14178
+ }
14179
+ }
14180
+ await handle.pause(reason);
14181
+ });
14164
14182
  }
14165
14183
  async resumePausedRun(input) {
14166
14184
  return this.withRunControlLock(input.runId, async () => {