@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.
@@ -210,7 +210,6 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
210
210
  conversationId?: string | undefined;
211
211
  turnId?: string | undefined;
212
212
  modelId?: string | undefined;
213
- stepId?: string | undefined;
214
213
  route?: {
215
214
  modelId: string;
216
215
  capabilityId: string;
@@ -223,6 +222,7 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
223
222
  baseURL?: string | undefined;
224
223
  endpointModelId?: string | undefined;
225
224
  } | undefined;
225
+ stepId?: string | undefined;
226
226
  createdAt?: number | undefined;
227
227
  }, {
228
228
  id: string;
@@ -244,7 +244,6 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
244
244
  conversationId?: string | undefined;
245
245
  turnId?: string | undefined;
246
246
  modelId?: string | undefined;
247
- stepId?: string | undefined;
248
247
  route?: {
249
248
  modelId: string;
250
249
  capabilityId: string;
@@ -257,6 +256,7 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
257
256
  baseURL?: string | undefined;
258
257
  endpointModelId?: string | undefined;
259
258
  } | undefined;
259
+ stepId?: string | undefined;
260
260
  createdAt?: number | undefined;
261
261
  }>;
262
262
  type LlmUsageTokenLedgerEntry = z.infer<typeof LlmUsageTokenLedgerEntry>;
@@ -413,7 +413,6 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
413
413
  parentRunId?: string | undefined;
414
414
  conversationId?: string | undefined;
415
415
  turnId?: string | undefined;
416
- stepId?: string | undefined;
417
416
  route?: {
418
417
  modelId: string;
419
418
  capabilityId: string;
@@ -426,6 +425,7 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
426
425
  baseURL?: string | undefined;
427
426
  endpointModelId?: string | undefined;
428
427
  } | undefined;
428
+ stepId?: string | undefined;
429
429
  createdAt?: number | undefined;
430
430
  }, {
431
431
  id: string;
@@ -458,7 +458,6 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
458
458
  parentRunId?: string | undefined;
459
459
  conversationId?: string | undefined;
460
460
  turnId?: string | undefined;
461
- stepId?: string | undefined;
462
461
  route?: {
463
462
  modelId: string;
464
463
  capabilityId: string;
@@ -471,6 +470,7 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
471
470
  baseURL?: string | undefined;
472
471
  endpointModelId?: string | undefined;
473
472
  } | undefined;
473
+ stepId?: string | undefined;
474
474
  createdAt?: number | undefined;
475
475
  }>;
476
476
  type ContextComponentTokenLedgerEntry = z.infer<typeof ContextComponentTokenLedgerEntry>;
@@ -583,7 +583,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
583
583
  conversationId?: string | undefined;
584
584
  turnId?: string | undefined;
585
585
  modelId?: string | undefined;
586
- stepId?: string | undefined;
587
586
  route?: {
588
587
  modelId: string;
589
588
  capabilityId: string;
@@ -596,6 +595,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
596
595
  baseURL?: string | undefined;
597
596
  endpointModelId?: string | undefined;
598
597
  } | undefined;
598
+ stepId?: string | undefined;
599
599
  createdAt?: number | undefined;
600
600
  }, {
601
601
  id: string;
@@ -617,7 +617,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
617
617
  conversationId?: string | undefined;
618
618
  turnId?: string | undefined;
619
619
  modelId?: string | undefined;
620
- stepId?: string | undefined;
621
620
  route?: {
622
621
  modelId: string;
623
622
  capabilityId: string;
@@ -630,6 +629,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
630
629
  baseURL?: string | undefined;
631
630
  endpointModelId?: string | undefined;
632
631
  } | undefined;
632
+ stepId?: string | undefined;
633
633
  createdAt?: number | undefined;
634
634
  }>, z.ZodObject<{
635
635
  id: z.ZodString;
@@ -784,7 +784,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
784
784
  parentRunId?: string | undefined;
785
785
  conversationId?: string | undefined;
786
786
  turnId?: string | undefined;
787
- stepId?: string | undefined;
788
787
  route?: {
789
788
  modelId: string;
790
789
  capabilityId: string;
@@ -797,6 +796,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
797
796
  baseURL?: string | undefined;
798
797
  endpointModelId?: string | undefined;
799
798
  } | undefined;
799
+ stepId?: string | undefined;
800
800
  createdAt?: number | undefined;
801
801
  }, {
802
802
  id: string;
@@ -829,7 +829,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
829
829
  parentRunId?: string | undefined;
830
830
  conversationId?: string | undefined;
831
831
  turnId?: string | undefined;
832
- stepId?: string | undefined;
833
832
  route?: {
834
833
  modelId: string;
835
834
  capabilityId: string;
@@ -842,6 +841,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
842
841
  baseURL?: string | undefined;
843
842
  endpointModelId?: string | undefined;
844
843
  } | undefined;
844
+ stepId?: string | undefined;
845
845
  createdAt?: number | undefined;
846
846
  }>]>;
847
847
  type TokenLedgerEntry = z.infer<typeof TokenLedgerEntry>;
@@ -210,7 +210,6 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
210
210
  conversationId?: string | undefined;
211
211
  turnId?: string | undefined;
212
212
  modelId?: string | undefined;
213
- stepId?: string | undefined;
214
213
  route?: {
215
214
  modelId: string;
216
215
  capabilityId: string;
@@ -223,6 +222,7 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
223
222
  baseURL?: string | undefined;
224
223
  endpointModelId?: string | undefined;
225
224
  } | undefined;
225
+ stepId?: string | undefined;
226
226
  createdAt?: number | undefined;
227
227
  }, {
228
228
  id: string;
@@ -244,7 +244,6 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
244
244
  conversationId?: string | undefined;
245
245
  turnId?: string | undefined;
246
246
  modelId?: string | undefined;
247
- stepId?: string | undefined;
248
247
  route?: {
249
248
  modelId: string;
250
249
  capabilityId: string;
@@ -257,6 +256,7 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
257
256
  baseURL?: string | undefined;
258
257
  endpointModelId?: string | undefined;
259
258
  } | undefined;
259
+ stepId?: string | undefined;
260
260
  createdAt?: number | undefined;
261
261
  }>;
262
262
  type LlmUsageTokenLedgerEntry = z.infer<typeof LlmUsageTokenLedgerEntry>;
@@ -413,7 +413,6 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
413
413
  parentRunId?: string | undefined;
414
414
  conversationId?: string | undefined;
415
415
  turnId?: string | undefined;
416
- stepId?: string | undefined;
417
416
  route?: {
418
417
  modelId: string;
419
418
  capabilityId: string;
@@ -426,6 +425,7 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
426
425
  baseURL?: string | undefined;
427
426
  endpointModelId?: string | undefined;
428
427
  } | undefined;
428
+ stepId?: string | undefined;
429
429
  createdAt?: number | undefined;
430
430
  }, {
431
431
  id: string;
@@ -458,7 +458,6 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
458
458
  parentRunId?: string | undefined;
459
459
  conversationId?: string | undefined;
460
460
  turnId?: string | undefined;
461
- stepId?: string | undefined;
462
461
  route?: {
463
462
  modelId: string;
464
463
  capabilityId: string;
@@ -471,6 +470,7 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
471
470
  baseURL?: string | undefined;
472
471
  endpointModelId?: string | undefined;
473
472
  } | undefined;
473
+ stepId?: string | undefined;
474
474
  createdAt?: number | undefined;
475
475
  }>;
476
476
  type ContextComponentTokenLedgerEntry = z.infer<typeof ContextComponentTokenLedgerEntry>;
@@ -583,7 +583,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
583
583
  conversationId?: string | undefined;
584
584
  turnId?: string | undefined;
585
585
  modelId?: string | undefined;
586
- stepId?: string | undefined;
587
586
  route?: {
588
587
  modelId: string;
589
588
  capabilityId: string;
@@ -596,6 +595,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
596
595
  baseURL?: string | undefined;
597
596
  endpointModelId?: string | undefined;
598
597
  } | undefined;
598
+ stepId?: string | undefined;
599
599
  createdAt?: number | undefined;
600
600
  }, {
601
601
  id: string;
@@ -617,7 +617,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
617
617
  conversationId?: string | undefined;
618
618
  turnId?: string | undefined;
619
619
  modelId?: string | undefined;
620
- stepId?: string | undefined;
621
620
  route?: {
622
621
  modelId: string;
623
622
  capabilityId: string;
@@ -630,6 +629,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
630
629
  baseURL?: string | undefined;
631
630
  endpointModelId?: string | undefined;
632
631
  } | undefined;
632
+ stepId?: string | undefined;
633
633
  createdAt?: number | undefined;
634
634
  }>, z.ZodObject<{
635
635
  id: z.ZodString;
@@ -784,7 +784,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
784
784
  parentRunId?: string | undefined;
785
785
  conversationId?: string | undefined;
786
786
  turnId?: string | undefined;
787
- stepId?: string | undefined;
788
787
  route?: {
789
788
  modelId: string;
790
789
  capabilityId: string;
@@ -797,6 +796,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
797
796
  baseURL?: string | undefined;
798
797
  endpointModelId?: string | undefined;
799
798
  } | undefined;
799
+ stepId?: string | undefined;
800
800
  createdAt?: number | undefined;
801
801
  }, {
802
802
  id: string;
@@ -829,7 +829,6 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
829
829
  parentRunId?: string | undefined;
830
830
  conversationId?: string | undefined;
831
831
  turnId?: string | undefined;
832
- stepId?: string | undefined;
833
832
  route?: {
834
833
  modelId: string;
835
834
  capabilityId: string;
@@ -842,6 +841,7 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
842
841
  baseURL?: string | undefined;
843
842
  endpointModelId?: string | undefined;
844
843
  } | undefined;
844
+ stepId?: string | undefined;
845
845
  createdAt?: number | undefined;
846
846
  }>]>;
847
847
  type TokenLedgerEntry = z.infer<typeof TokenLedgerEntry>;
package/dist/index.cjs CHANGED
@@ -3982,13 +3982,21 @@ var GraphExecutor = class {
3982
3982
  if (existing) {
3983
3983
  throw new Error(`Graph checkpoint already exists: ${checkpointKey}`);
3984
3984
  }
3985
- this.ephemeralLocals.set(checkpointKey, { ...local });
3985
+ const initialLocal = this.executionCheckpointPort ? {
3986
+ ...local,
3987
+ executorLocal: {
3988
+ ...isRecord4(local.executorLocal) ? local.executorLocal : {},
3989
+ stepCount: 0,
3990
+ maxSteps: options.maxSteps ?? this.config.maxSteps
3991
+ }
3992
+ } : local;
3993
+ this.ephemeralLocals.set(checkpointKey, { ...initialLocal });
3986
3994
  await this.commitCheckpoint(checkpointKey, {
3987
3995
  nodeId,
3988
3996
  ...this.executionCheckpointPort ? { executionStatus: "ready" } : {},
3989
3997
  revision: 1,
3990
3998
  schemaVersion: ENGINE_STATE_SCHEMA_VERSION,
3991
- local: sanitizeCheckpointLocal(local)
3999
+ local: sanitizeCheckpointLocal(initialLocal)
3992
4000
  });
3993
4001
  return this.runUntilYieldQueued(
3994
4002
  checkpointKey,
@@ -14306,7 +14314,7 @@ function createAwaitingUserWatcher(options) {
14306
14314
  const onClose = () => {
14307
14315
  dispose();
14308
14316
  };
14309
- eventBus.on("event", onEvent);
14317
+ if (options.stateOwner !== "host") eventBus.on("event", onEvent);
14310
14318
  eventBus.on("close", onClose);
14311
14319
  return dispose;
14312
14320
  }
@@ -14782,6 +14790,7 @@ var DefaultRunSupervisor = class {
14782
14790
  this.runSlotLimiter = createRunSlotLimiter({ maxActiveRuns: options.maxActiveRuns });
14783
14791
  this.runConcurrencyKeys = createRunConcurrencyKeyRegistry();
14784
14792
  this.awaitingUserWatcher = createAwaitingUserWatcher({
14793
+ stateOwner: options.awaitingUserStateOwner,
14785
14794
  markAwaitingUser: (runId, patch) => this.getHandle(runId).markAwaitingUser(patch),
14786
14795
  onDisposed: (runId) => {
14787
14796
  this.eventWatchDisposers.delete(runId);
@@ -14978,8 +14987,17 @@ var DefaultRunSupervisor = class {
14978
14987
  canRestoreRun: this.canRestoreRun
14979
14988
  });
14980
14989
  }
14981
- async pause(runId, reason) {
14982
- await this.withRunControlLock(runId, () => this.getHandle(runId).pause(reason));
14990
+ async pause(runId, reason, expectedExecutionId) {
14991
+ await this.withRunControlLock(runId, async () => {
14992
+ const handle = this.getHandle(runId);
14993
+ if (expectedExecutionId !== void 0) {
14994
+ const record = await this.registryStore.load(runId);
14995
+ if (record?.metadata?.executionId !== expectedExecutionId) {
14996
+ throw new RunInteractionConflictError(runId, "pause execution ownership has changed");
14997
+ }
14998
+ }
14999
+ await handle.pause(reason);
15000
+ });
14983
15001
  }
14984
15002
  async resumePausedRun(input) {
14985
15003
  return this.withRunControlLock(input.runId, async () => {