@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.js
CHANGED
|
@@ -119,6 +119,7 @@ __export(runtime_kernel_exports, {
|
|
|
119
119
|
maxStepsForceFinalAnswerTemplate: () => maxStepsForceFinalAnswerTemplate,
|
|
120
120
|
noopAudit: () => noopAudit,
|
|
121
121
|
normalizeToolArgs: () => normalizeToolArgs,
|
|
122
|
+
parseEngineCheckpoint: () => parseEngineCheckpoint,
|
|
122
123
|
parseToolModelInputDeclaration: () => parseToolModelInputDeclaration,
|
|
123
124
|
periodicProgressReflectionTemplate: () => periodicProgressReflectionTemplate,
|
|
124
125
|
phaseEqualsTrigger: () => phaseEqualsTrigger,
|
|
@@ -168,6 +169,7 @@ __export(graph_engine_exports, {
|
|
|
168
169
|
evaluatePrimaryPromptCapacity: () => evaluatePrimaryPromptCapacity,
|
|
169
170
|
isRunPauseSignal: () => isRunPauseSignal,
|
|
170
171
|
isRuntimeFailureFact: () => isRuntimeFailureFact,
|
|
172
|
+
parseEngineCheckpoint: () => parseEngineCheckpoint,
|
|
171
173
|
readCheckpointContextUsage: () => readCheckpointContextUsage,
|
|
172
174
|
requireEventStoreId: () => requireEventStoreId,
|
|
173
175
|
resolveEffectivePromptBudget: () => resolveEffectivePromptBudget,
|
|
@@ -4144,23 +4146,23 @@ var GraphExecutor = class {
|
|
|
4144
4146
|
};
|
|
4145
4147
|
}
|
|
4146
4148
|
async saveCheckpoint(checkpointKey, state) {
|
|
4147
|
-
const
|
|
4149
|
+
const checkpoint2 = this.sanitize({
|
|
4148
4150
|
...state,
|
|
4149
4151
|
revision: (state.revision ?? 0) + 1
|
|
4150
4152
|
});
|
|
4151
|
-
await this.commitCheckpoint(checkpointKey,
|
|
4152
|
-
return
|
|
4153
|
+
await this.commitCheckpoint(checkpointKey, checkpoint2);
|
|
4154
|
+
return checkpoint2;
|
|
4153
4155
|
}
|
|
4154
|
-
async commitCheckpoint(checkpointKey,
|
|
4156
|
+
async commitCheckpoint(checkpointKey, checkpoint2) {
|
|
4155
4157
|
if (this.executionCheckpointPort) {
|
|
4156
|
-
await this.executionCheckpointPort.commit(checkpointKey,
|
|
4158
|
+
await this.executionCheckpointPort.commit(checkpointKey, checkpoint2);
|
|
4157
4159
|
} else {
|
|
4158
|
-
await this.checkpointer.save(checkpointKey,
|
|
4160
|
+
await this.checkpointer.save(checkpointKey, checkpoint2);
|
|
4159
4161
|
}
|
|
4160
4162
|
}
|
|
4161
4163
|
async saveCheckpointAndBuildResult(checkpointKey, state, events, stepCount) {
|
|
4162
|
-
const
|
|
4163
|
-
return { events, checkpoint, stepCount };
|
|
4164
|
+
const checkpoint2 = await this.saveCheckpoint(checkpointKey, state);
|
|
4165
|
+
return { events, checkpoint: checkpoint2, stepCount };
|
|
4164
4166
|
}
|
|
4165
4167
|
async runUntilYieldInternal(checkpointKey, initialState, reportStepsUsed, maxSteps) {
|
|
4166
4168
|
let state = initialState;
|
|
@@ -10304,16 +10306,16 @@ function requireEventStoreId(eventStoreId) {
|
|
|
10304
10306
|
}
|
|
10305
10307
|
function createMonotonicEventStoreIdFactory(nowProvider = () => Date.now()) {
|
|
10306
10308
|
let lastTimestamp = 0;
|
|
10307
|
-
let
|
|
10309
|
+
let counter2 = 0;
|
|
10308
10310
|
return () => {
|
|
10309
10311
|
const timestamp = Math.max(nowProvider(), lastTimestamp);
|
|
10310
10312
|
if (timestamp === lastTimestamp) {
|
|
10311
|
-
|
|
10313
|
+
counter2 += 1;
|
|
10312
10314
|
} else {
|
|
10313
10315
|
lastTimestamp = timestamp;
|
|
10314
|
-
|
|
10316
|
+
counter2 = 0;
|
|
10315
10317
|
}
|
|
10316
|
-
return `${String(timestamp).padStart(13, "0")}-${String(
|
|
10318
|
+
return `${String(timestamp).padStart(13, "0")}-${String(counter2).padStart(4, "0")}`;
|
|
10317
10319
|
};
|
|
10318
10320
|
}
|
|
10319
10321
|
|
|
@@ -10725,6 +10727,76 @@ function assertNonNegativeSafeInteger(value, field) {
|
|
|
10725
10727
|
throw new Error(`${field} \u5FC5\u987B\u662F\u975E\u8D1F\u5B89\u5168\u6574\u6570\u3002`);
|
|
10726
10728
|
}
|
|
10727
10729
|
}
|
|
10730
|
+
var counter = z.number().int().nonnegative();
|
|
10731
|
+
var executor = z.object({
|
|
10732
|
+
stepCount: counter,
|
|
10733
|
+
phase: z.string().optional(),
|
|
10734
|
+
maxSteps: counter.optional(),
|
|
10735
|
+
remainingSteps: z.number().int().optional(),
|
|
10736
|
+
finalStepPolicy: z.enum(["final_answer", "force_tools"]).optional(),
|
|
10737
|
+
finalStepForcedTools: z.array(z.string()).optional(),
|
|
10738
|
+
lastStepsHintThreshold: counter.optional(),
|
|
10739
|
+
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
10740
|
+
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
10741
|
+
runLockedModelId: z.string().optional(),
|
|
10742
|
+
lastSuccessfulLlmModelId: z.string().optional(),
|
|
10743
|
+
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
10744
|
+
llmInvocationCount: counter.optional(),
|
|
10745
|
+
lockRequestedModelId: z.boolean().optional(),
|
|
10746
|
+
contextCompaction: z.object({
|
|
10747
|
+
attemptCount: counter,
|
|
10748
|
+
committedCount: counter,
|
|
10749
|
+
lastCommittedFingerprint: z.string().optional()
|
|
10750
|
+
}).strict().optional()
|
|
10751
|
+
}).strict();
|
|
10752
|
+
var checkpoint = z.object({
|
|
10753
|
+
nodeId: z.string().min(1),
|
|
10754
|
+
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|
|
10755
|
+
revision: counter.optional(),
|
|
10756
|
+
executionStatus: z.enum(["ready", "executing", "yielded", "awaiting_user"]).optional(),
|
|
10757
|
+
local: z.object({
|
|
10758
|
+
runId: RunIdSchema.optional(),
|
|
10759
|
+
parentRunId: RunIdSchema.optional(),
|
|
10760
|
+
conversationId: z.string().optional(),
|
|
10761
|
+
turnId: z.string().optional(),
|
|
10762
|
+
request: SerializableJsonRecord.optional(),
|
|
10763
|
+
history: z.array(RuntimeEvent).optional(),
|
|
10764
|
+
newEvents: z.array(RuntimeEvent).optional(),
|
|
10765
|
+
executorLocal: executor.optional(),
|
|
10766
|
+
pendingToolCalls: z.array(z.object({
|
|
10767
|
+
id: ToolCallIdSchema,
|
|
10768
|
+
type: z.literal("function"),
|
|
10769
|
+
function: z.object({ name: z.string().min(1), arguments: z.string() }).strict()
|
|
10770
|
+
}).strict()).optional(),
|
|
10771
|
+
executingToolCallId: ToolCallIdSchema.optional(),
|
|
10772
|
+
toolBatchCompletionMode: z.enum(["continue_to_llm", "yield_after_batch"]).optional(),
|
|
10773
|
+
pendingInteractionSpec: SerializableJsonRecord.optional(),
|
|
10774
|
+
lastToolResult: SerializableJsonRecord.optional(),
|
|
10775
|
+
finalAnswer: z.string().optional(),
|
|
10776
|
+
answerId: z.string().optional(),
|
|
10777
|
+
chunkSeq: counter.optional(),
|
|
10778
|
+
contextUsage: ContextUsageSnapshot.optional()
|
|
10779
|
+
}).passthrough().optional()
|
|
10780
|
+
}).strict();
|
|
10781
|
+
function parseEngineCheckpoint(value) {
|
|
10782
|
+
const result = checkpoint.parse(SerializableJsonRecord.parse(value));
|
|
10783
|
+
for (const key of [
|
|
10784
|
+
"memory",
|
|
10785
|
+
"signal",
|
|
10786
|
+
"toolContext",
|
|
10787
|
+
"runtimeEventSink",
|
|
10788
|
+
"runtimeEventCommitPort",
|
|
10789
|
+
"runtimeFailureFactSink",
|
|
10790
|
+
"summarizationCallbacks",
|
|
10791
|
+
"commitExecutionBoundary",
|
|
10792
|
+
"toolRecoveryPort"
|
|
10793
|
+
]) {
|
|
10794
|
+
if (result.local && Object.hasOwn(result.local, key)) {
|
|
10795
|
+
throw new Error(`Checkpoint must not contain execution capability: ${key}`);
|
|
10796
|
+
}
|
|
10797
|
+
}
|
|
10798
|
+
return result;
|
|
10799
|
+
}
|
|
10728
10800
|
|
|
10729
10801
|
// src/runtime-kernel/tools/index.ts
|
|
10730
10802
|
var tools_exports = {};
|
|
@@ -11186,14 +11258,14 @@ var EventBusEventPersistence = class {
|
|
|
11186
11258
|
checkpointWritesActive;
|
|
11187
11259
|
checkpointEvents = [];
|
|
11188
11260
|
/** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
|
|
11189
|
-
async commitCheckpoint(checkpointKey,
|
|
11261
|
+
async commitCheckpoint(checkpointKey, checkpoint2) {
|
|
11190
11262
|
const writer = this.options.checkpointWriter;
|
|
11191
11263
|
if (!writer || !this.checkpointWritesActive) throw new Error("Checkpoint writer is not active");
|
|
11192
11264
|
const events = this.checkpointEvents;
|
|
11193
11265
|
this.checkpointEvents = [];
|
|
11194
11266
|
await this.enqueueWrite(() => writer({
|
|
11195
11267
|
checkpointKey,
|
|
11196
|
-
checkpoint,
|
|
11268
|
+
checkpoint: checkpoint2,
|
|
11197
11269
|
events: events.map((event) => ({ event, eventStoreId: this.options.nextEventStoreId() }))
|
|
11198
11270
|
}));
|
|
11199
11271
|
}
|
|
@@ -12886,15 +12958,15 @@ function hasSeedHistoryPrefix(history, seedHistory) {
|
|
|
12886
12958
|
}
|
|
12887
12959
|
return true;
|
|
12888
12960
|
}
|
|
12889
|
-
function readCheckpointHistory(
|
|
12890
|
-
if (!
|
|
12891
|
-
const history =
|
|
12961
|
+
function readCheckpointHistory(checkpoint2) {
|
|
12962
|
+
if (!checkpoint2?.local) return [];
|
|
12963
|
+
const history = checkpoint2.local.history;
|
|
12892
12964
|
if (!Array.isArray(history)) return [];
|
|
12893
12965
|
return parseRuntimeEvents(history);
|
|
12894
12966
|
}
|
|
12895
12967
|
async function recoverChildRunEventsFromCheckpoint(params) {
|
|
12896
|
-
const
|
|
12897
|
-
const history = readCheckpointHistory(
|
|
12968
|
+
const checkpoint2 = await params.checkpointer.load(params.checkpointKey);
|
|
12969
|
+
const history = readCheckpointHistory(checkpoint2);
|
|
12898
12970
|
if (history.length === 0) {
|
|
12899
12971
|
return [];
|
|
12900
12972
|
}
|
|
@@ -13190,9 +13262,9 @@ var ChildRunInvoker = class {
|
|
|
13190
13262
|
async continueChild(config, runId, conversationId) {
|
|
13191
13263
|
const persistence = config.persistence;
|
|
13192
13264
|
if (!persistence || persistence.expectedRevision === void 0) throw new Error("Missing child continuation contract");
|
|
13193
|
-
const
|
|
13194
|
-
if (!
|
|
13195
|
-
const local = readGraphAgentLocal({ ...
|
|
13265
|
+
const checkpoint2 = await persistence.checkpointer.load(runId);
|
|
13266
|
+
if (!checkpoint2 || checkpoint2.local?.conversationId !== conversationId) throw new Error("Child checkpoint identity mismatch");
|
|
13267
|
+
const local = readGraphAgentLocal({ ...checkpoint2.local, runtimeEventSink: config.runtimeEventSink });
|
|
13196
13268
|
const request = local.request;
|
|
13197
13269
|
if (!request || !local.turnId || !request.model_id) throw new Error("Child recovery input is incomplete");
|
|
13198
13270
|
const context = createChildRunToolContext({
|
|
@@ -14469,7 +14541,15 @@ function createRunConcurrencyKeyRegistry() {
|
|
|
14469
14541
|
runIdByKey.delete(concurrencyKey);
|
|
14470
14542
|
}
|
|
14471
14543
|
}
|
|
14472
|
-
|
|
14544
|
+
function transfer(previous, next, concurrencyKey) {
|
|
14545
|
+
if (runIdByKey.get(concurrencyKey) !== previous || keyByRunId.has(next)) {
|
|
14546
|
+
throw new RunConcurrencyKeyOccupiedError(concurrencyKey, runIdByKey.get(concurrencyKey) ?? previous, next);
|
|
14547
|
+
}
|
|
14548
|
+
keyByRunId.delete(previous);
|
|
14549
|
+
keyByRunId.set(next, concurrencyKey);
|
|
14550
|
+
runIdByKey.set(concurrencyKey, next);
|
|
14551
|
+
}
|
|
14552
|
+
return { acquire, release, transfer };
|
|
14473
14553
|
}
|
|
14474
14554
|
|
|
14475
14555
|
// src/runtime-kernel/run-supervisor/functions/runRegistration.ts
|
|
@@ -14718,6 +14798,9 @@ var DefaultRunSupervisor = class {
|
|
|
14718
14798
|
});
|
|
14719
14799
|
}
|
|
14720
14800
|
async registerRun(spec) {
|
|
14801
|
+
if (spec.replacesPausedRun) {
|
|
14802
|
+
return this.withRunControlLock(spec.replacesPausedRun.runId, () => this.registerPausedReplacement(spec));
|
|
14803
|
+
}
|
|
14721
14804
|
const runId = spec.runId ?? this.runIdFactory();
|
|
14722
14805
|
if (this.handles.has(runId) || await this.registryStore.load(runId)) {
|
|
14723
14806
|
throw new RunAlreadyRegisteredError(runId);
|
|
@@ -14728,13 +14811,51 @@ var DefaultRunSupervisor = class {
|
|
|
14728
14811
|
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
14729
14812
|
const record = createInitialRunRecord({ runId, spec, startedAt });
|
|
14730
14813
|
try {
|
|
14731
|
-
await
|
|
14814
|
+
if (spec.admissionCommit) await spec.admissionCommit(record);
|
|
14815
|
+
else await this.registryStore.save(record);
|
|
14732
14816
|
} catch (error) {
|
|
14733
14817
|
this.releaseRunAdmission(runId);
|
|
14734
14818
|
throw error;
|
|
14735
14819
|
}
|
|
14736
14820
|
return this.attachRun(record, spec, controller);
|
|
14737
14821
|
}
|
|
14822
|
+
async registerPausedReplacement(spec) {
|
|
14823
|
+
const target = spec.replacesPausedRun;
|
|
14824
|
+
if (!target || !spec.concurrencyKey || !spec.admissionCommit || !this.registryStore.compareAndSwap) {
|
|
14825
|
+
throw new Error("Paused replacement requires concurrency identity and atomic admissionCommit");
|
|
14826
|
+
}
|
|
14827
|
+
this.getHandle(target.runId);
|
|
14828
|
+
const previous = await this.registryStore.load(target.runId);
|
|
14829
|
+
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) {
|
|
14830
|
+
throw new RunInteractionConflictError(target.runId, "replacement does not match the settled pause");
|
|
14831
|
+
}
|
|
14832
|
+
const runId = spec.runId ?? this.runIdFactory();
|
|
14833
|
+
if (this.handles.has(runId) || await this.registryStore.load(runId)) throw new RunAlreadyRegisteredError(runId);
|
|
14834
|
+
this.runConcurrencyKeys.transfer(previous.runId, runId, spec.concurrencyKey);
|
|
14835
|
+
this.runSlotLimiter.release(previous.runId);
|
|
14836
|
+
this.runSlotLimiter.acquire(runId);
|
|
14837
|
+
const now = this.now();
|
|
14838
|
+
const record = createInitialRunRecord({ runId, spec, startedAt: now });
|
|
14839
|
+
const next = {
|
|
14840
|
+
...previous,
|
|
14841
|
+
status: "cancelled",
|
|
14842
|
+
updatedAt: now,
|
|
14843
|
+
errorIfAny: { errorCode: "RUN_REPLACED", message: "Replaced by a newly accepted request", recoverable: false }
|
|
14844
|
+
};
|
|
14845
|
+
try {
|
|
14846
|
+
await spec.admissionCommit(record, { previous, next });
|
|
14847
|
+
} catch (error) {
|
|
14848
|
+
this.runSlotLimiter.release(runId);
|
|
14849
|
+
this.runSlotLimiter.acquire(previous.runId);
|
|
14850
|
+
this.runConcurrencyKeys.transfer(runId, previous.runId, spec.concurrencyKey);
|
|
14851
|
+
throw error;
|
|
14852
|
+
}
|
|
14853
|
+
this.cleanupRunResources(previous.runId);
|
|
14854
|
+
this.notifyTerminalWaiters(previous.runId);
|
|
14855
|
+
const controller = new AbortController();
|
|
14856
|
+
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
14857
|
+
return this.attachRun(record, spec, controller);
|
|
14858
|
+
}
|
|
14738
14859
|
async restoreRun(spec) {
|
|
14739
14860
|
if (!this.registryStore.compareAndSwap) throw new Error("Run restoration requires atomic registry transitions");
|
|
14740
14861
|
return this.withRunControlLock(spec.runId, async () => {
|
|
@@ -14858,7 +14979,7 @@ var DefaultRunSupervisor = class {
|
|
|
14858
14979
|
return this.withRunControlLock(input.runId, async () => {
|
|
14859
14980
|
const handle = this.getHandle(input.runId);
|
|
14860
14981
|
const record = await this.registryStore.load(input.runId);
|
|
14861
|
-
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt) {
|
|
14982
|
+
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt || input.expectedExecutionId !== void 0 && record.metadata?.executionId !== input.expectedExecutionId) {
|
|
14862
14983
|
throw new RunInteractionConflictError(input.runId, "run is not settled at the expected pause");
|
|
14863
14984
|
}
|
|
14864
14985
|
await persistRunTransition(this.registryStore, record, {
|
|
@@ -14999,7 +15120,7 @@ var DefaultRunSupervisor = class {
|
|
|
14999
15120
|
}
|
|
15000
15121
|
const awaitingUserWithoutClaim = { ...awaitingUser };
|
|
15001
15122
|
Reflect.deleteProperty(awaitingUserWithoutClaim, "resumeClaim");
|
|
15002
|
-
|
|
15123
|
+
const nextRecord = {
|
|
15003
15124
|
...record,
|
|
15004
15125
|
status: "running",
|
|
15005
15126
|
updatedAt: this.now(),
|
|
@@ -15009,6 +15130,10 @@ var DefaultRunSupervisor = class {
|
|
|
15009
15130
|
metadata: {
|
|
15010
15131
|
...record.metadata ?? {},
|
|
15011
15132
|
...execution ? { executionId: execution.executionId } : {},
|
|
15133
|
+
...execution?.inputEventIds ? { resumeInputs: {
|
|
15134
|
+
eventIds: [...execution.inputEventIds],
|
|
15135
|
+
checkpointRevision: pendingInteraction.checkpointRevision
|
|
15136
|
+
} } : {},
|
|
15012
15137
|
awaitingUser: {
|
|
15013
15138
|
...awaitingUserWithoutClaim,
|
|
15014
15139
|
interaction: {
|
|
@@ -15017,7 +15142,9 @@ var DefaultRunSupervisor = class {
|
|
|
15017
15142
|
}
|
|
15018
15143
|
}
|
|
15019
15144
|
}
|
|
15020
|
-
}
|
|
15145
|
+
};
|
|
15146
|
+
if (execution?.admissionCommit) await execution.admissionCommit(record, nextRecord);
|
|
15147
|
+
else await persistRunTransition(this.registryStore, record, nextRecord);
|
|
15021
15148
|
const executionController = new AbortController();
|
|
15022
15149
|
forwardParentAbortSignal(executionController, parentSignal);
|
|
15023
15150
|
handle.replaceExecutionAbortController(executionController, execution?.executionId ?? (typeof record.metadata?.executionId === "string" ? record.metadata.executionId : void 0));
|
|
@@ -15183,13 +15310,13 @@ __export(system_reminder_exports, {
|
|
|
15183
15310
|
|
|
15184
15311
|
// src/runtime-kernel/testkit/defaultGraphExecutor.ts
|
|
15185
15312
|
function createDefaultGraphExecutor(options) {
|
|
15186
|
-
const
|
|
15313
|
+
const executor2 = new GraphExecutor(
|
|
15187
15314
|
options.checkpointer ?? new MemoryCheckpointer(),
|
|
15188
15315
|
{ maxSteps: options.maxSteps ?? 8 }
|
|
15189
15316
|
);
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15317
|
+
executor2.registerNode(new UserNode());
|
|
15318
|
+
executor2.registerNode(options.llmNode);
|
|
15319
|
+
executor2.registerNode(new ToolNode({
|
|
15193
15320
|
toolRuntime: options.toolRuntime,
|
|
15194
15321
|
observationPreview: options.observationPreview,
|
|
15195
15322
|
auditPort: options.auditPort,
|
|
@@ -15197,8 +15324,8 @@ function createDefaultGraphExecutor(options) {
|
|
|
15197
15324
|
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
15198
15325
|
modelInputResolver: options.modelInputResolver
|
|
15199
15326
|
}));
|
|
15200
|
-
|
|
15201
|
-
return
|
|
15327
|
+
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
15328
|
+
return executor2;
|
|
15202
15329
|
}
|
|
15203
15330
|
|
|
15204
15331
|
// src/runtime-kernel/testkit/graphLoopHarness.ts
|
|
@@ -15223,7 +15350,7 @@ function createGraphLoopHarness(options) {
|
|
|
15223
15350
|
return {
|
|
15224
15351
|
async run() {
|
|
15225
15352
|
const checkpointKey = options.runId ?? options.turnId;
|
|
15226
|
-
const
|
|
15353
|
+
const executor2 = createDefaultGraphExecutor({
|
|
15227
15354
|
llmNode: options.createLlmNode({
|
|
15228
15355
|
llmCaller: options.llmCaller,
|
|
15229
15356
|
toolRuntime: options.toolRuntime
|
|
@@ -15253,8 +15380,8 @@ function createGraphLoopHarness(options) {
|
|
|
15253
15380
|
signal: options.signal ?? options.toolContext.abortSignal,
|
|
15254
15381
|
executorLocal
|
|
15255
15382
|
};
|
|
15256
|
-
await
|
|
15257
|
-
const result = await
|
|
15383
|
+
await executor2.prime(checkpointKey, local, "user");
|
|
15384
|
+
const result = await executor2.runUntilYield(checkpointKey);
|
|
15258
15385
|
return {
|
|
15259
15386
|
checkpointNodeId: result.checkpoint.nodeId,
|
|
15260
15387
|
stepCount: result.stepCount,
|
|
@@ -15666,7 +15793,7 @@ async function runAgent(agent, options) {
|
|
|
15666
15793
|
contextBuilder: new QuickstartContextBuilder(agent),
|
|
15667
15794
|
telemetryPort
|
|
15668
15795
|
});
|
|
15669
|
-
const
|
|
15796
|
+
const executor2 = createDefaultGraphExecutor({
|
|
15670
15797
|
llmNode: new LlmNode({ reasoner }),
|
|
15671
15798
|
toolRuntime,
|
|
15672
15799
|
observationPreview: createNoopObservationPreview(),
|
|
@@ -15702,7 +15829,7 @@ async function runAgent(agent, options) {
|
|
|
15702
15829
|
};
|
|
15703
15830
|
await handle.markRunning({ currentNode: "user" });
|
|
15704
15831
|
try {
|
|
15705
|
-
await
|
|
15832
|
+
await executor2.prime(checkpointKey, {
|
|
15706
15833
|
conversationId,
|
|
15707
15834
|
turnId,
|
|
15708
15835
|
request: {
|
|
@@ -15719,7 +15846,7 @@ async function runAgent(agent, options) {
|
|
|
15719
15846
|
signal: handle.signal,
|
|
15720
15847
|
runtimeEventSink: (event, source) => publisher.publish(event, source)
|
|
15721
15848
|
});
|
|
15722
|
-
const result = await
|
|
15849
|
+
const result = await executor2.runUntilYield(checkpointKey);
|
|
15723
15850
|
await Promise.all([callbackTail, persistenceTail]);
|
|
15724
15851
|
await handle.markCompleted({
|
|
15725
15852
|
currentNode: result.checkpoint.nodeId,
|