@linnlabs/linnkit 0.33.0 → 0.34.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/CHANGELOG.md +16 -0
- package/dist/cli.cjs +154 -28
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +154 -28
- package/dist/cli.js.map +1 -1
- package/dist/context-manager.cjs +54 -0
- package/dist/context-manager.cjs.map +1 -1
- package/dist/context-manager.js +54 -0
- package/dist/context-manager.js.map +1 -1
- package/dist/index.cjs +166 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +166 -39
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +154 -28
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +154 -28
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.cts +6 -0
- package/dist/runtime-kernel/graph-engine/functions/parseEngineCheckpoint.d.ts +6 -0
- package/dist/runtime-kernel/graph-engine/index.d.cts +1 -0
- package/dist/runtime-kernel/graph-engine/index.d.ts +1 -0
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.cts +21 -4
- package/dist/runtime-kernel/run-supervisor/definitions/runSupervisorContracts.d.ts +21 -4
- package/dist/runtime-kernel/run-supervisor/index.d.cts +1 -1
- package/dist/runtime-kernel/run-supervisor/index.d.ts +1 -1
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.cts +2 -1
- package/dist/runtime-kernel/run-supervisor/runSupervisor.d.ts +2 -1
- package/dist/runtime-kernel.cjs +163 -36
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.d.cts +1 -0
- package/dist/runtime-kernel.d.ts +1 -0
- package/dist/runtime-kernel.js +163 -37
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +163 -36
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +163 -36
- package/dist/testkit.js.map +1 -1
- package/docs/integration/persistence.md +1 -0
- package/docs/integration/run-supervisor.md +3 -0
- 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
|
|
4151
|
+
const checkpoint2 = this.sanitize({
|
|
4150
4152
|
...state,
|
|
4151
4153
|
revision: (state.revision ?? 0) + 1
|
|
4152
4154
|
});
|
|
4153
|
-
await this.commitCheckpoint(checkpointKey,
|
|
4154
|
-
return
|
|
4155
|
+
await this.commitCheckpoint(checkpointKey, checkpoint2);
|
|
4156
|
+
return checkpoint2;
|
|
4155
4157
|
}
|
|
4156
|
-
async commitCheckpoint(checkpointKey,
|
|
4158
|
+
async commitCheckpoint(checkpointKey, checkpoint2) {
|
|
4157
4159
|
if (this.executionCheckpointPort) {
|
|
4158
|
-
await this.executionCheckpointPort.commit(checkpointKey,
|
|
4160
|
+
await this.executionCheckpointPort.commit(checkpointKey, checkpoint2);
|
|
4159
4161
|
} else {
|
|
4160
|
-
await this.checkpointer.save(checkpointKey,
|
|
4162
|
+
await this.checkpointer.save(checkpointKey, checkpoint2);
|
|
4161
4163
|
}
|
|
4162
4164
|
}
|
|
4163
4165
|
async saveCheckpointAndBuildResult(checkpointKey, state, events, stepCount) {
|
|
4164
|
-
const
|
|
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
|
|
10311
|
+
let counter2 = 0;
|
|
10310
10312
|
return () => {
|
|
10311
10313
|
const timestamp = Math.max(nowProvider(), lastTimestamp);
|
|
10312
10314
|
if (timestamp === lastTimestamp) {
|
|
10313
|
-
|
|
10315
|
+
counter2 += 1;
|
|
10314
10316
|
} else {
|
|
10315
10317
|
lastTimestamp = timestamp;
|
|
10316
|
-
|
|
10318
|
+
counter2 = 0;
|
|
10317
10319
|
}
|
|
10318
|
-
return `${String(timestamp).padStart(13, "0")}-${String(
|
|
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,
|
|
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(
|
|
12892
|
-
if (!
|
|
12893
|
-
const 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
|
|
12899
|
-
const history = readCheckpointHistory(
|
|
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
|
}
|
|
@@ -13192,9 +13264,9 @@ var ChildRunInvoker = class {
|
|
|
13192
13264
|
async continueChild(config, runId, conversationId) {
|
|
13193
13265
|
const persistence = config.persistence;
|
|
13194
13266
|
if (!persistence || persistence.expectedRevision === void 0) throw new Error("Missing child continuation contract");
|
|
13195
|
-
const
|
|
13196
|
-
if (!
|
|
13197
|
-
const local = readGraphAgentLocal({ ...
|
|
13267
|
+
const checkpoint2 = await persistence.checkpointer.load(runId);
|
|
13268
|
+
if (!checkpoint2 || checkpoint2.local?.conversationId !== conversationId) throw new Error("Child checkpoint identity mismatch");
|
|
13269
|
+
const local = readGraphAgentLocal({ ...checkpoint2.local, runtimeEventSink: config.runtimeEventSink });
|
|
13198
13270
|
const request = local.request;
|
|
13199
13271
|
if (!request || !local.turnId || !request.model_id) throw new Error("Child recovery input is incomplete");
|
|
13200
13272
|
const context = createChildRunToolContext({
|
|
@@ -14471,7 +14543,15 @@ function createRunConcurrencyKeyRegistry() {
|
|
|
14471
14543
|
runIdByKey.delete(concurrencyKey);
|
|
14472
14544
|
}
|
|
14473
14545
|
}
|
|
14474
|
-
|
|
14546
|
+
function transfer(previous, next, concurrencyKey) {
|
|
14547
|
+
if (runIdByKey.get(concurrencyKey) !== previous || keyByRunId.has(next)) {
|
|
14548
|
+
throw new RunConcurrencyKeyOccupiedError(concurrencyKey, runIdByKey.get(concurrencyKey) ?? previous, next);
|
|
14549
|
+
}
|
|
14550
|
+
keyByRunId.delete(previous);
|
|
14551
|
+
keyByRunId.set(next, concurrencyKey);
|
|
14552
|
+
runIdByKey.set(concurrencyKey, next);
|
|
14553
|
+
}
|
|
14554
|
+
return { acquire, release, transfer };
|
|
14475
14555
|
}
|
|
14476
14556
|
|
|
14477
14557
|
// src/runtime-kernel/run-supervisor/functions/runRegistration.ts
|
|
@@ -14720,6 +14800,9 @@ var DefaultRunSupervisor = class {
|
|
|
14720
14800
|
});
|
|
14721
14801
|
}
|
|
14722
14802
|
async registerRun(spec) {
|
|
14803
|
+
if (spec.replacesPausedRun) {
|
|
14804
|
+
return this.withRunControlLock(spec.replacesPausedRun.runId, () => this.registerPausedReplacement(spec));
|
|
14805
|
+
}
|
|
14723
14806
|
const runId = spec.runId ?? this.runIdFactory();
|
|
14724
14807
|
if (this.handles.has(runId) || await this.registryStore.load(runId)) {
|
|
14725
14808
|
throw new RunAlreadyRegisteredError(runId);
|
|
@@ -14730,13 +14813,51 @@ var DefaultRunSupervisor = class {
|
|
|
14730
14813
|
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
14731
14814
|
const record = createInitialRunRecord({ runId, spec, startedAt });
|
|
14732
14815
|
try {
|
|
14733
|
-
await
|
|
14816
|
+
if (spec.admissionCommit) await spec.admissionCommit(record);
|
|
14817
|
+
else await this.registryStore.save(record);
|
|
14734
14818
|
} catch (error) {
|
|
14735
14819
|
this.releaseRunAdmission(runId);
|
|
14736
14820
|
throw error;
|
|
14737
14821
|
}
|
|
14738
14822
|
return this.attachRun(record, spec, controller);
|
|
14739
14823
|
}
|
|
14824
|
+
async registerPausedReplacement(spec) {
|
|
14825
|
+
const target = spec.replacesPausedRun;
|
|
14826
|
+
if (!target || !spec.concurrencyKey || !spec.admissionCommit || !this.registryStore.compareAndSwap) {
|
|
14827
|
+
throw new Error("Paused replacement requires concurrency identity and atomic admissionCommit");
|
|
14828
|
+
}
|
|
14829
|
+
this.getHandle(target.runId);
|
|
14830
|
+
const previous = await this.registryStore.load(target.runId);
|
|
14831
|
+
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) {
|
|
14832
|
+
throw new RunInteractionConflictError(target.runId, "replacement does not match the settled pause");
|
|
14833
|
+
}
|
|
14834
|
+
const runId = spec.runId ?? this.runIdFactory();
|
|
14835
|
+
if (this.handles.has(runId) || await this.registryStore.load(runId)) throw new RunAlreadyRegisteredError(runId);
|
|
14836
|
+
this.runConcurrencyKeys.transfer(previous.runId, runId, spec.concurrencyKey);
|
|
14837
|
+
this.runSlotLimiter.release(previous.runId);
|
|
14838
|
+
this.runSlotLimiter.acquire(runId);
|
|
14839
|
+
const now = this.now();
|
|
14840
|
+
const record = createInitialRunRecord({ runId, spec, startedAt: now });
|
|
14841
|
+
const next = {
|
|
14842
|
+
...previous,
|
|
14843
|
+
status: "cancelled",
|
|
14844
|
+
updatedAt: now,
|
|
14845
|
+
errorIfAny: { errorCode: "RUN_REPLACED", message: "Replaced by a newly accepted request", recoverable: false }
|
|
14846
|
+
};
|
|
14847
|
+
try {
|
|
14848
|
+
await spec.admissionCommit(record, { previous, next });
|
|
14849
|
+
} catch (error) {
|
|
14850
|
+
this.runSlotLimiter.release(runId);
|
|
14851
|
+
this.runSlotLimiter.acquire(previous.runId);
|
|
14852
|
+
this.runConcurrencyKeys.transfer(runId, previous.runId, spec.concurrencyKey);
|
|
14853
|
+
throw error;
|
|
14854
|
+
}
|
|
14855
|
+
this.cleanupRunResources(previous.runId);
|
|
14856
|
+
this.notifyTerminalWaiters(previous.runId);
|
|
14857
|
+
const controller = new AbortController();
|
|
14858
|
+
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
14859
|
+
return this.attachRun(record, spec, controller);
|
|
14860
|
+
}
|
|
14740
14861
|
async restoreRun(spec) {
|
|
14741
14862
|
if (!this.registryStore.compareAndSwap) throw new Error("Run restoration requires atomic registry transitions");
|
|
14742
14863
|
return this.withRunControlLock(spec.runId, async () => {
|
|
@@ -14860,7 +14981,7 @@ var DefaultRunSupervisor = class {
|
|
|
14860
14981
|
return this.withRunControlLock(input.runId, async () => {
|
|
14861
14982
|
const handle = this.getHandle(input.runId);
|
|
14862
14983
|
const record = await this.registryStore.load(input.runId);
|
|
14863
|
-
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt) {
|
|
14984
|
+
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt || input.expectedExecutionId !== void 0 && record.metadata?.executionId !== input.expectedExecutionId) {
|
|
14864
14985
|
throw new RunInteractionConflictError(input.runId, "run is not settled at the expected pause");
|
|
14865
14986
|
}
|
|
14866
14987
|
await persistRunTransition(this.registryStore, record, {
|
|
@@ -15001,7 +15122,7 @@ var DefaultRunSupervisor = class {
|
|
|
15001
15122
|
}
|
|
15002
15123
|
const awaitingUserWithoutClaim = { ...awaitingUser };
|
|
15003
15124
|
Reflect.deleteProperty(awaitingUserWithoutClaim, "resumeClaim");
|
|
15004
|
-
|
|
15125
|
+
const nextRecord = {
|
|
15005
15126
|
...record,
|
|
15006
15127
|
status: "running",
|
|
15007
15128
|
updatedAt: this.now(),
|
|
@@ -15011,6 +15132,10 @@ var DefaultRunSupervisor = class {
|
|
|
15011
15132
|
metadata: {
|
|
15012
15133
|
...record.metadata ?? {},
|
|
15013
15134
|
...execution ? { executionId: execution.executionId } : {},
|
|
15135
|
+
...execution?.inputEventIds ? { resumeInputs: {
|
|
15136
|
+
eventIds: [...execution.inputEventIds],
|
|
15137
|
+
checkpointRevision: pendingInteraction.checkpointRevision
|
|
15138
|
+
} } : {},
|
|
15014
15139
|
awaitingUser: {
|
|
15015
15140
|
...awaitingUserWithoutClaim,
|
|
15016
15141
|
interaction: {
|
|
@@ -15019,7 +15144,9 @@ var DefaultRunSupervisor = class {
|
|
|
15019
15144
|
}
|
|
15020
15145
|
}
|
|
15021
15146
|
}
|
|
15022
|
-
}
|
|
15147
|
+
};
|
|
15148
|
+
if (execution?.admissionCommit) await execution.admissionCommit(record, nextRecord);
|
|
15149
|
+
else await persistRunTransition(this.registryStore, record, nextRecord);
|
|
15023
15150
|
const executionController = new AbortController();
|
|
15024
15151
|
forwardParentAbortSignal(executionController, parentSignal);
|
|
15025
15152
|
handle.replaceExecutionAbortController(executionController, execution?.executionId ?? (typeof record.metadata?.executionId === "string" ? record.metadata.executionId : void 0));
|
|
@@ -15185,13 +15312,13 @@ __export(system_reminder_exports, {
|
|
|
15185
15312
|
|
|
15186
15313
|
// src/runtime-kernel/testkit/defaultGraphExecutor.ts
|
|
15187
15314
|
function createDefaultGraphExecutor(options) {
|
|
15188
|
-
const
|
|
15315
|
+
const executor2 = new GraphExecutor(
|
|
15189
15316
|
options.checkpointer ?? new MemoryCheckpointer(),
|
|
15190
15317
|
{ maxSteps: options.maxSteps ?? 8 }
|
|
15191
15318
|
);
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15319
|
+
executor2.registerNode(new UserNode());
|
|
15320
|
+
executor2.registerNode(options.llmNode);
|
|
15321
|
+
executor2.registerNode(new ToolNode({
|
|
15195
15322
|
toolRuntime: options.toolRuntime,
|
|
15196
15323
|
observationPreview: options.observationPreview,
|
|
15197
15324
|
auditPort: options.auditPort,
|
|
@@ -15199,8 +15326,8 @@ function createDefaultGraphExecutor(options) {
|
|
|
15199
15326
|
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
15200
15327
|
modelInputResolver: options.modelInputResolver
|
|
15201
15328
|
}));
|
|
15202
|
-
|
|
15203
|
-
return
|
|
15329
|
+
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
15330
|
+
return executor2;
|
|
15204
15331
|
}
|
|
15205
15332
|
|
|
15206
15333
|
// src/runtime-kernel/testkit/graphLoopHarness.ts
|
|
@@ -15225,7 +15352,7 @@ function createGraphLoopHarness(options) {
|
|
|
15225
15352
|
return {
|
|
15226
15353
|
async run() {
|
|
15227
15354
|
const checkpointKey = options.runId ?? options.turnId;
|
|
15228
|
-
const
|
|
15355
|
+
const executor2 = createDefaultGraphExecutor({
|
|
15229
15356
|
llmNode: options.createLlmNode({
|
|
15230
15357
|
llmCaller: options.llmCaller,
|
|
15231
15358
|
toolRuntime: options.toolRuntime
|
|
@@ -15255,8 +15382,8 @@ function createGraphLoopHarness(options) {
|
|
|
15255
15382
|
signal: options.signal ?? options.toolContext.abortSignal,
|
|
15256
15383
|
executorLocal
|
|
15257
15384
|
};
|
|
15258
|
-
await
|
|
15259
|
-
const result = await
|
|
15385
|
+
await executor2.prime(checkpointKey, local, "user");
|
|
15386
|
+
const result = await executor2.runUntilYield(checkpointKey);
|
|
15260
15387
|
return {
|
|
15261
15388
|
checkpointNodeId: result.checkpoint.nodeId,
|
|
15262
15389
|
stepCount: result.stepCount,
|
|
@@ -15668,7 +15795,7 @@ async function runAgent(agent, options) {
|
|
|
15668
15795
|
contextBuilder: new QuickstartContextBuilder(agent),
|
|
15669
15796
|
telemetryPort
|
|
15670
15797
|
});
|
|
15671
|
-
const
|
|
15798
|
+
const executor2 = createDefaultGraphExecutor({
|
|
15672
15799
|
llmNode: new LlmNode({ reasoner }),
|
|
15673
15800
|
toolRuntime,
|
|
15674
15801
|
observationPreview: createNoopObservationPreview(),
|
|
@@ -15704,7 +15831,7 @@ async function runAgent(agent, options) {
|
|
|
15704
15831
|
};
|
|
15705
15832
|
await handle.markRunning({ currentNode: "user" });
|
|
15706
15833
|
try {
|
|
15707
|
-
await
|
|
15834
|
+
await executor2.prime(checkpointKey, {
|
|
15708
15835
|
conversationId,
|
|
15709
15836
|
turnId,
|
|
15710
15837
|
request: {
|
|
@@ -15721,7 +15848,7 @@ async function runAgent(agent, options) {
|
|
|
15721
15848
|
signal: handle.signal,
|
|
15722
15849
|
runtimeEventSink: (event, source) => publisher.publish(event, source)
|
|
15723
15850
|
});
|
|
15724
|
-
const result = await
|
|
15851
|
+
const result = await executor2.runUntilYield(checkpointKey);
|
|
15725
15852
|
await Promise.all([callbackTail, persistenceTail]);
|
|
15726
15853
|
await handle.markCompleted({
|
|
15727
15854
|
currentNode: result.checkpoint.nodeId,
|