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