@linnlabs/linnkit 0.33.0 → 0.35.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cli.cjs +155 -28
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/cli.js +155 -28
  5. package/dist/cli.js.map +1 -1
  6. package/dist/context-manager.cjs +54 -0
  7. package/dist/context-manager.cjs.map +1 -1
  8. package/dist/context-manager.js +54 -0
  9. package/dist/context-manager.js.map +1 -1
  10. package/dist/index.cjs +175 -43
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.js +175 -43
  13. package/dist/index.js.map +1 -1
  14. package/dist/quickstart.cjs +155 -28
  15. package/dist/quickstart.cjs.map +1 -1
  16. package/dist/quickstart.js +155 -28
  17. package/dist/quickstart.js.map +1 -1
  18. package/dist/runtime-kernel/child-runs/childRunInvoker.d.cts +5 -0
  19. package/dist/runtime-kernel/child-runs/childRunInvoker.d.ts +5 -0
  20. package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.cts +6 -0
  21. package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.ts +6 -0
  22. package/dist/runtime-kernel/graph-engine/index.d.cts +1 -0
  23. package/dist/runtime-kernel/graph-engine/index.d.ts +1 -0
  24. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +22 -4
  25. package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +22 -4
  26. package/dist/runtime-kernel/run-supervisor/index.d.cts +1 -1
  27. package/dist/runtime-kernel/run-supervisor/index.d.ts +1 -1
  28. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +2 -1
  29. package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +2 -1
  30. package/dist/runtime-kernel.cjs +172 -40
  31. package/dist/runtime-kernel.cjs.map +1 -1
  32. package/dist/runtime-kernel.d.cts +1 -0
  33. package/dist/runtime-kernel.d.ts +1 -0
  34. package/dist/runtime-kernel.js +172 -41
  35. package/dist/runtime-kernel.js.map +1 -1
  36. package/dist/testkit.cjs +172 -40
  37. package/dist/testkit.cjs.map +1 -1
  38. package/dist/testkit.js +172 -40
  39. package/dist/testkit.js.map +1 -1
  40. package/docs/integration/child-runs.md +8 -0
  41. package/docs/integration/persistence.md +1 -0
  42. package/docs/integration/run-supervisor.md +3 -0
  43. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -121,6 +121,7 @@ __export(runtime_kernel_exports, {
121
121
  maxStepsForceFinalAnswerTemplate: () => maxStepsForceFinalAnswerTemplate,
122
122
  noopAudit: () => noopAudit,
123
123
  normalizeToolArgs: () => normalizeToolArgs,
124
+ parseEngineCheckpoint: () => parseEngineCheckpoint,
124
125
  parseToolModelInputDeclaration: () => parseToolModelInputDeclaration,
125
126
  periodicProgressReflectionTemplate: () => periodicProgressReflectionTemplate,
126
127
  phaseEqualsTrigger: () => phaseEqualsTrigger,
@@ -170,6 +171,7 @@ __export(graph_engine_exports, {
170
171
  evaluatePrimaryPromptCapacity: () => evaluatePrimaryPromptCapacity,
171
172
  isRunPauseSignal: () => isRunPauseSignal,
172
173
  isRuntimeFailureFact: () => isRuntimeFailureFact,
174
+ parseEngineCheckpoint: () => parseEngineCheckpoint,
173
175
  readCheckpointContextUsage: () => readCheckpointContextUsage,
174
176
  requireEventStoreId: () => requireEventStoreId,
175
177
  resolveEffectivePromptBudget: () => resolveEffectivePromptBudget,
@@ -4146,23 +4148,23 @@ var GraphExecutor = class {
4146
4148
  };
4147
4149
  }
4148
4150
  async saveCheckpoint(checkpointKey, state) {
4149
- const checkpoint = this.sanitize({
4151
+ const checkpoint2 = this.sanitize({
4150
4152
  ...state,
4151
4153
  revision: (state.revision ?? 0) + 1
4152
4154
  });
4153
- await this.commitCheckpoint(checkpointKey, checkpoint);
4154
- return checkpoint;
4155
+ await this.commitCheckpoint(checkpointKey, checkpoint2);
4156
+ return checkpoint2;
4155
4157
  }
4156
- async commitCheckpoint(checkpointKey, checkpoint) {
4158
+ async commitCheckpoint(checkpointKey, checkpoint2) {
4157
4159
  if (this.executionCheckpointPort) {
4158
- await this.executionCheckpointPort.commit(checkpointKey, checkpoint);
4160
+ await this.executionCheckpointPort.commit(checkpointKey, checkpoint2);
4159
4161
  } else {
4160
- await this.checkpointer.save(checkpointKey, checkpoint);
4162
+ await this.checkpointer.save(checkpointKey, checkpoint2);
4161
4163
  }
4162
4164
  }
4163
4165
  async saveCheckpointAndBuildResult(checkpointKey, state, events, stepCount) {
4164
- const checkpoint = await this.saveCheckpoint(checkpointKey, state);
4165
- return { events, checkpoint, stepCount };
4166
+ const checkpoint2 = await this.saveCheckpoint(checkpointKey, state);
4167
+ return { events, checkpoint: checkpoint2, stepCount };
4166
4168
  }
4167
4169
  async runUntilYieldInternal(checkpointKey, initialState, reportStepsUsed, maxSteps) {
4168
4170
  let state = initialState;
@@ -10306,16 +10308,16 @@ function requireEventStoreId(eventStoreId) {
10306
10308
  }
10307
10309
  function createMonotonicEventStoreIdFactory(nowProvider = () => Date.now()) {
10308
10310
  let lastTimestamp = 0;
10309
- let counter = 0;
10311
+ let counter2 = 0;
10310
10312
  return () => {
10311
10313
  const timestamp = Math.max(nowProvider(), lastTimestamp);
10312
10314
  if (timestamp === lastTimestamp) {
10313
- counter += 1;
10315
+ counter2 += 1;
10314
10316
  } else {
10315
10317
  lastTimestamp = timestamp;
10316
- counter = 0;
10318
+ counter2 = 0;
10317
10319
  }
10318
- return `${String(timestamp).padStart(13, "0")}-${String(counter).padStart(4, "0")}`;
10320
+ return `${String(timestamp).padStart(13, "0")}-${String(counter2).padStart(4, "0")}`;
10319
10321
  };
10320
10322
  }
10321
10323
 
@@ -10727,6 +10729,76 @@ function assertNonNegativeSafeInteger(value, field) {
10727
10729
  throw new Error(`${field} \u5FC5\u987B\u662F\u975E\u8D1F\u5B89\u5168\u6574\u6570\u3002`);
10728
10730
  }
10729
10731
  }
10732
+ var counter = zod.z.number().int().nonnegative();
10733
+ var executor = zod.z.object({
10734
+ stepCount: counter,
10735
+ phase: zod.z.string().optional(),
10736
+ maxSteps: counter.optional(),
10737
+ remainingSteps: zod.z.number().int().optional(),
10738
+ finalStepPolicy: zod.z.enum(["final_answer", "force_tools"]).optional(),
10739
+ finalStepForcedTools: zod.z.array(zod.z.string()).optional(),
10740
+ lastStepsHintThreshold: counter.optional(),
10741
+ systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
10742
+ toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
10743
+ runLockedModelId: zod.z.string().optional(),
10744
+ lastSuccessfulLlmModelId: zod.z.string().optional(),
10745
+ llmInvocationKind: zod.z.enum(["user_initiated", "continuation"]).optional(),
10746
+ llmInvocationCount: counter.optional(),
10747
+ lockRequestedModelId: zod.z.boolean().optional(),
10748
+ contextCompaction: zod.z.object({
10749
+ attemptCount: counter,
10750
+ committedCount: counter,
10751
+ lastCommittedFingerprint: zod.z.string().optional()
10752
+ }).strict().optional()
10753
+ }).strict();
10754
+ var checkpoint = zod.z.object({
10755
+ nodeId: zod.z.string().min(1),
10756
+ schemaVersion: zod.z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
10757
+ revision: counter.optional(),
10758
+ executionStatus: zod.z.enum(["ready", "executing", "yielded", "awaiting_user"]).optional(),
10759
+ local: zod.z.object({
10760
+ runId: RunIdSchema.optional(),
10761
+ parentRunId: RunIdSchema.optional(),
10762
+ conversationId: zod.z.string().optional(),
10763
+ turnId: zod.z.string().optional(),
10764
+ request: SerializableJsonRecord.optional(),
10765
+ history: zod.z.array(RuntimeEvent).optional(),
10766
+ newEvents: zod.z.array(RuntimeEvent).optional(),
10767
+ executorLocal: executor.optional(),
10768
+ pendingToolCalls: zod.z.array(zod.z.object({
10769
+ id: ToolCallIdSchema,
10770
+ type: zod.z.literal("function"),
10771
+ function: zod.z.object({ name: zod.z.string().min(1), arguments: zod.z.string() }).strict()
10772
+ }).strict()).optional(),
10773
+ executingToolCallId: ToolCallIdSchema.optional(),
10774
+ toolBatchCompletionMode: zod.z.enum(["continue_to_llm", "yield_after_batch"]).optional(),
10775
+ pendingInteractionSpec: SerializableJsonRecord.optional(),
10776
+ lastToolResult: SerializableJsonRecord.optional(),
10777
+ finalAnswer: zod.z.string().optional(),
10778
+ answerId: zod.z.string().optional(),
10779
+ chunkSeq: counter.optional(),
10780
+ contextUsage: ContextUsageSnapshot.optional()
10781
+ }).passthrough().optional()
10782
+ }).strict();
10783
+ function parseEngineCheckpoint(value) {
10784
+ const result = checkpoint.parse(SerializableJsonRecord.parse(value));
10785
+ for (const key of [
10786
+ "memory",
10787
+ "signal",
10788
+ "toolContext",
10789
+ "runtimeEventSink",
10790
+ "runtimeEventCommitPort",
10791
+ "runtimeFailureFactSink",
10792
+ "summarizationCallbacks",
10793
+ "commitExecutionBoundary",
10794
+ "toolRecoveryPort"
10795
+ ]) {
10796
+ if (result.local && Object.hasOwn(result.local, key)) {
10797
+ throw new Error(`Checkpoint must not contain execution capability: ${key}`);
10798
+ }
10799
+ }
10800
+ return result;
10801
+ }
10730
10802
 
10731
10803
  // src/runtime-kernel/tools/index.ts
10732
10804
  var tools_exports = {};
@@ -11188,14 +11260,14 @@ var EventBusEventPersistence = class {
11188
11260
  checkpointWritesActive;
11189
11261
  checkpointEvents = [];
11190
11262
  /** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
11191
- async commitCheckpoint(checkpointKey, checkpoint) {
11263
+ async commitCheckpoint(checkpointKey, checkpoint2) {
11192
11264
  const writer = this.options.checkpointWriter;
11193
11265
  if (!writer || !this.checkpointWritesActive) throw new Error("Checkpoint writer is not active");
11194
11266
  const events = this.checkpointEvents;
11195
11267
  this.checkpointEvents = [];
11196
11268
  await this.enqueueWrite(() => writer({
11197
11269
  checkpointKey,
11198
- checkpoint,
11270
+ checkpoint: checkpoint2,
11199
11271
  events: events.map((event) => ({ event, eventStoreId: this.options.nextEventStoreId() }))
11200
11272
  }));
11201
11273
  }
@@ -12888,15 +12960,15 @@ function hasSeedHistoryPrefix(history, seedHistory) {
12888
12960
  }
12889
12961
  return true;
12890
12962
  }
12891
- function readCheckpointHistory(checkpoint) {
12892
- if (!checkpoint?.local) return [];
12893
- const history = checkpoint.local.history;
12963
+ function readCheckpointHistory(checkpoint2) {
12964
+ if (!checkpoint2?.local) return [];
12965
+ const history = checkpoint2.local.history;
12894
12966
  if (!Array.isArray(history)) return [];
12895
12967
  return parseRuntimeEvents(history);
12896
12968
  }
12897
12969
  async function recoverChildRunEventsFromCheckpoint(params) {
12898
- const checkpoint = await params.checkpointer.load(params.checkpointKey);
12899
- const history = readCheckpointHistory(checkpoint);
12970
+ const checkpoint2 = await params.checkpointer.load(params.checkpointKey);
12971
+ const history = readCheckpointHistory(checkpoint2);
12900
12972
  if (history.length === 0) {
12901
12973
  return [];
12902
12974
  }
@@ -12942,10 +13014,10 @@ var ChildRunInvoker = class {
12942
13014
  runtimeEventSink,
12943
13015
  runtimeEventCommitPort,
12944
13016
  seedHistoryEvents,
12945
- maxSteps = 8,
12946
13017
  modelId,
12947
13018
  abortSignal
12948
13019
  } = config;
13020
+ const maxSteps = config.initialInput?.request.maxSteps ?? config.maxSteps ?? 8;
12949
13021
  const childRunId = runId ?? generateRunId();
12950
13022
  const internalCheckpointKey = childRunId;
12951
13023
  const resolvedParentRunId = parentRunId ?? parentToolContext.runId;
@@ -12990,7 +13062,8 @@ var ChildRunInvoker = class {
12990
13062
  if (config.persistence?.expectedRevision !== void 0) {
12991
13063
  return this.continueChild(config, childRunId, runtimeConversationId);
12992
13064
  }
12993
- const turnId = generateTurnId();
13065
+ const turnId = config.initialInput?.turnId ?? generateTurnId();
13066
+ if (config.initialInput && (!turnId.trim() || config.initialInput.request.query !== userMessage || config.initialInput.request.promptKey !== agentConfig.promptKey || !config.initialInput.request.model_id)) throw new Error("Child initial input does not match the admitted invocation");
12994
13067
  logger17.info(`\u542F\u52A8 child-run: ${agentConfig.id}`, {
12995
13068
  conversationId: runtimeConversationId,
12996
13069
  checkpointKey: internalCheckpointKey,
@@ -13007,11 +13080,14 @@ var ChildRunInvoker = class {
13007
13080
  });
13008
13081
  const admittedChildUserInput = runtimeEventSink(childUserInput, "ChildRunInvoker.user_input");
13009
13082
  const childModelId = resolveChildRunModelId({
13010
- explicitModelId: modelId,
13083
+ explicitModelId: config.initialInput?.request.model_id ?? modelId,
13011
13084
  agentConfig,
13012
13085
  resolveDefaultModelId: () => this.modelResolver.resolveModelId()
13013
13086
  });
13014
- const request = {
13087
+ const request = config.initialInput ? {
13088
+ ...config.initialInput.request,
13089
+ currentUserEventId: admittedChildUserInput.id
13090
+ } : {
13015
13091
  query: userMessage,
13016
13092
  currentUserEventId: admittedChildUserInput.id,
13017
13093
  promptKey: agentConfig.promptKey,
@@ -13192,9 +13268,9 @@ var ChildRunInvoker = class {
13192
13268
  async continueChild(config, runId, conversationId) {
13193
13269
  const persistence = config.persistence;
13194
13270
  if (!persistence || persistence.expectedRevision === void 0) throw new Error("Missing child continuation contract");
13195
- const checkpoint = await persistence.checkpointer.load(runId);
13196
- if (!checkpoint || checkpoint.local?.conversationId !== conversationId) throw new Error("Child checkpoint identity mismatch");
13197
- const local = readGraphAgentLocal({ ...checkpoint.local, runtimeEventSink: config.runtimeEventSink });
13271
+ const checkpoint2 = await persistence.checkpointer.load(runId);
13272
+ if (!checkpoint2 || checkpoint2.local?.conversationId !== conversationId) throw new Error("Child checkpoint identity mismatch");
13273
+ const local = readGraphAgentLocal({ ...checkpoint2.local, runtimeEventSink: config.runtimeEventSink });
13198
13274
  const request = local.request;
13199
13275
  if (!request || !local.turnId || !request.model_id) throw new Error("Child recovery input is incomplete");
13200
13276
  const context = createChildRunToolContext({
@@ -14471,7 +14547,15 @@ function createRunConcurrencyKeyRegistry() {
14471
14547
  runIdByKey.delete(concurrencyKey);
14472
14548
  }
14473
14549
  }
14474
- return { acquire, release };
14550
+ function transfer(previous, next, concurrencyKey) {
14551
+ if (runIdByKey.get(concurrencyKey) !== previous || keyByRunId.has(next)) {
14552
+ throw new RunConcurrencyKeyOccupiedError(concurrencyKey, runIdByKey.get(concurrencyKey) ?? previous, next);
14553
+ }
14554
+ keyByRunId.delete(previous);
14555
+ keyByRunId.set(next, concurrencyKey);
14556
+ runIdByKey.set(concurrencyKey, next);
14557
+ }
14558
+ return { acquire, release, transfer };
14475
14559
  }
14476
14560
 
14477
14561
  // src/runtime-kernel/run-supervisor/functions/runRegistration.ts
@@ -14720,6 +14804,9 @@ var DefaultRunSupervisor = class {
14720
14804
  });
14721
14805
  }
14722
14806
  async registerRun(spec) {
14807
+ if (spec.replacesPausedRun) {
14808
+ return this.withRunControlLock(spec.replacesPausedRun.runId, () => this.registerPausedReplacement(spec));
14809
+ }
14723
14810
  const runId = spec.runId ?? this.runIdFactory();
14724
14811
  if (this.handles.has(runId) || await this.registryStore.load(runId)) {
14725
14812
  throw new RunAlreadyRegisteredError(runId);
@@ -14730,13 +14817,51 @@ var DefaultRunSupervisor = class {
14730
14817
  forwardParentAbortSignal(controller, spec.parentSignal);
14731
14818
  const record = createInitialRunRecord({ runId, spec, startedAt });
14732
14819
  try {
14733
- await this.registryStore.save(record);
14820
+ if (spec.admissionCommit) await spec.admissionCommit(record);
14821
+ else await this.registryStore.save(record);
14734
14822
  } catch (error) {
14735
14823
  this.releaseRunAdmission(runId);
14736
14824
  throw error;
14737
14825
  }
14738
14826
  return this.attachRun(record, spec, controller);
14739
14827
  }
14828
+ async registerPausedReplacement(spec) {
14829
+ const target = spec.replacesPausedRun;
14830
+ if (!target || !spec.concurrencyKey || !spec.admissionCommit || !this.registryStore.compareAndSwap) {
14831
+ throw new Error("Paused replacement requires concurrency identity and atomic admissionCommit");
14832
+ }
14833
+ this.getHandle(target.runId);
14834
+ const previous = await this.registryStore.load(target.runId);
14835
+ if (!previous || previous.status !== "paused" || previous.pausedAt === void 0 || previous.updatedAt !== target.expectedUpdatedAt || previous.metadata?.executionId !== target.expectedExecutionId || previous.conversationId !== spec.conversationId || previous.parentRunId !== spec.parentRunId) {
14836
+ throw new RunInteractionConflictError(target.runId, "replacement does not match the settled pause");
14837
+ }
14838
+ const runId = spec.runId ?? this.runIdFactory();
14839
+ if (this.handles.has(runId) || await this.registryStore.load(runId)) throw new RunAlreadyRegisteredError(runId);
14840
+ this.runConcurrencyKeys.transfer(previous.runId, runId, spec.concurrencyKey);
14841
+ this.runSlotLimiter.release(previous.runId);
14842
+ this.runSlotLimiter.acquire(runId);
14843
+ const now = this.now();
14844
+ const record = createInitialRunRecord({ runId, spec, startedAt: now });
14845
+ const next = {
14846
+ ...previous,
14847
+ status: "cancelled",
14848
+ updatedAt: now,
14849
+ errorIfAny: { errorCode: "RUN_REPLACED", message: "Replaced by a newly accepted request", recoverable: false }
14850
+ };
14851
+ try {
14852
+ await spec.admissionCommit(record, { previous, next });
14853
+ } catch (error) {
14854
+ this.runSlotLimiter.release(runId);
14855
+ this.runSlotLimiter.acquire(previous.runId);
14856
+ this.runConcurrencyKeys.transfer(runId, previous.runId, spec.concurrencyKey);
14857
+ throw error;
14858
+ }
14859
+ this.cleanupRunResources(previous.runId);
14860
+ this.notifyTerminalWaiters(previous.runId);
14861
+ const controller = new AbortController();
14862
+ forwardParentAbortSignal(controller, spec.parentSignal);
14863
+ return this.attachRun(record, spec, controller);
14864
+ }
14740
14865
  async restoreRun(spec) {
14741
14866
  if (!this.registryStore.compareAndSwap) throw new Error("Run restoration requires atomic registry transitions");
14742
14867
  return this.withRunControlLock(spec.runId, async () => {
@@ -14860,7 +14985,7 @@ var DefaultRunSupervisor = class {
14860
14985
  return this.withRunControlLock(input.runId, async () => {
14861
14986
  const handle = this.getHandle(input.runId);
14862
14987
  const record = await this.registryStore.load(input.runId);
14863
- if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt) {
14988
+ if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt || input.expectedExecutionId !== void 0 && record.metadata?.executionId !== input.expectedExecutionId) {
14864
14989
  throw new RunInteractionConflictError(input.runId, "run is not settled at the expected pause");
14865
14990
  }
14866
14991
  await persistRunTransition(this.registryStore, record, {
@@ -14873,6 +14998,7 @@ var DefaultRunSupervisor = class {
14873
14998
  metadata: { ...record.metadata, executionId: input.executionId }
14874
14999
  });
14875
15000
  const controller = new AbortController();
15001
+ forwardParentAbortSignal(controller, input.parentSignal);
14876
15002
  handle.replaceExecutionAbortController(controller, input.executionId);
14877
15003
  handle.attachTransportEventBus(input.eventBus);
14878
15004
  this.controllers.set(input.runId, controller);
@@ -15001,7 +15127,7 @@ var DefaultRunSupervisor = class {
15001
15127
  }
15002
15128
  const awaitingUserWithoutClaim = { ...awaitingUser };
15003
15129
  Reflect.deleteProperty(awaitingUserWithoutClaim, "resumeClaim");
15004
- await persistRunTransition(this.registryStore, record, {
15130
+ const nextRecord = {
15005
15131
  ...record,
15006
15132
  status: "running",
15007
15133
  updatedAt: this.now(),
@@ -15011,6 +15137,10 @@ var DefaultRunSupervisor = class {
15011
15137
  metadata: {
15012
15138
  ...record.metadata ?? {},
15013
15139
  ...execution ? { executionId: execution.executionId } : {},
15140
+ ...execution?.inputEventIds ? { resumeInputs: {
15141
+ eventIds: [...execution.inputEventIds],
15142
+ checkpointRevision: pendingInteraction.checkpointRevision
15143
+ } } : {},
15014
15144
  awaitingUser: {
15015
15145
  ...awaitingUserWithoutClaim,
15016
15146
  interaction: {
@@ -15019,7 +15149,9 @@ var DefaultRunSupervisor = class {
15019
15149
  }
15020
15150
  }
15021
15151
  }
15022
- });
15152
+ };
15153
+ if (execution?.admissionCommit) await execution.admissionCommit(record, nextRecord);
15154
+ else await persistRunTransition(this.registryStore, record, nextRecord);
15023
15155
  const executionController = new AbortController();
15024
15156
  forwardParentAbortSignal(executionController, parentSignal);
15025
15157
  handle.replaceExecutionAbortController(executionController, execution?.executionId ?? (typeof record.metadata?.executionId === "string" ? record.metadata.executionId : void 0));
@@ -15185,13 +15317,13 @@ __export(system_reminder_exports, {
15185
15317
 
15186
15318
  // src/runtime-kernel/testkit/defaultGraphExecutor.ts
15187
15319
  function createDefaultGraphExecutor(options) {
15188
- const executor = new GraphExecutor(
15320
+ const executor2 = new GraphExecutor(
15189
15321
  options.checkpointer ?? new MemoryCheckpointer(),
15190
15322
  { maxSteps: options.maxSteps ?? 8 }
15191
15323
  );
15192
- executor.registerNode(new UserNode());
15193
- executor.registerNode(options.llmNode);
15194
- executor.registerNode(new ToolNode({
15324
+ executor2.registerNode(new UserNode());
15325
+ executor2.registerNode(options.llmNode);
15326
+ executor2.registerNode(new ToolNode({
15195
15327
  toolRuntime: options.toolRuntime,
15196
15328
  observationPreview: options.observationPreview,
15197
15329
  auditPort: options.auditPort,
@@ -15199,8 +15331,8 @@ function createDefaultGraphExecutor(options) {
15199
15331
  modelInputCapabilityValidator: options.modelInputCapabilityValidator,
15200
15332
  modelInputResolver: options.modelInputResolver
15201
15333
  }));
15202
- executor.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
15203
- return executor;
15334
+ executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
15335
+ return executor2;
15204
15336
  }
15205
15337
 
15206
15338
  // src/runtime-kernel/testkit/graphLoopHarness.ts
@@ -15225,7 +15357,7 @@ function createGraphLoopHarness(options) {
15225
15357
  return {
15226
15358
  async run() {
15227
15359
  const checkpointKey = options.runId ?? options.turnId;
15228
- const executor = createDefaultGraphExecutor({
15360
+ const executor2 = createDefaultGraphExecutor({
15229
15361
  llmNode: options.createLlmNode({
15230
15362
  llmCaller: options.llmCaller,
15231
15363
  toolRuntime: options.toolRuntime
@@ -15255,8 +15387,8 @@ function createGraphLoopHarness(options) {
15255
15387
  signal: options.signal ?? options.toolContext.abortSignal,
15256
15388
  executorLocal
15257
15389
  };
15258
- await executor.prime(checkpointKey, local, "user");
15259
- const result = await executor.runUntilYield(checkpointKey);
15390
+ await executor2.prime(checkpointKey, local, "user");
15391
+ const result = await executor2.runUntilYield(checkpointKey);
15260
15392
  return {
15261
15393
  checkpointNodeId: result.checkpoint.nodeId,
15262
15394
  stepCount: result.stepCount,
@@ -15668,7 +15800,7 @@ async function runAgent(agent, options) {
15668
15800
  contextBuilder: new QuickstartContextBuilder(agent),
15669
15801
  telemetryPort
15670
15802
  });
15671
- const executor = createDefaultGraphExecutor({
15803
+ const executor2 = createDefaultGraphExecutor({
15672
15804
  llmNode: new LlmNode({ reasoner }),
15673
15805
  toolRuntime,
15674
15806
  observationPreview: createNoopObservationPreview(),
@@ -15704,7 +15836,7 @@ async function runAgent(agent, options) {
15704
15836
  };
15705
15837
  await handle.markRunning({ currentNode: "user" });
15706
15838
  try {
15707
- await executor.prime(checkpointKey, {
15839
+ await executor2.prime(checkpointKey, {
15708
15840
  conversationId,
15709
15841
  turnId,
15710
15842
  request: {
@@ -15721,7 +15853,7 @@ async function runAgent(agent, options) {
15721
15853
  signal: handle.signal,
15722
15854
  runtimeEventSink: (event, source) => publisher.publish(event, source)
15723
15855
  });
15724
- const result = await executor.runUntilYield(checkpointKey);
15856
+ const result = await executor2.runUntilYield(checkpointKey);
15725
15857
  await Promise.all([callbackTail, persistenceTail]);
15726
15858
  await handle.markCompleted({
15727
15859
  currentNode: result.checkpoint.nodeId,