@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
|
@@ -101,6 +101,7 @@ export { evaluateModelInputCompatibility, listCompatibleModelIds } from './runti
|
|
|
101
101
|
export { isRuntimeFailureFact } from './runtime-kernel/graph-engine/functions/runtimeFailureFact.cjs';
|
|
102
102
|
export { noopAudit } from './runtime-kernel/audit/noopAudit.cjs';
|
|
103
103
|
export { normalizeToolArgs } from './runtime-kernel/tools/argNormalizer.cjs';
|
|
104
|
+
export { parseEngineCheckpoint } from './runtime-kernel/graph-engine/functions/parseEngineCheckpoint.cjs';
|
|
104
105
|
export { projectChildRuntimeEventToSubRunTrace } from './runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.cjs';
|
|
105
106
|
export { readCheckpointContextUsage } from './runtime-kernel/graph-engine/functions/engineStateSnapshot.cjs';
|
|
106
107
|
export { requestEnricherRegistry } from './runtime-kernel/enrichment/registry.cjs';
|
package/dist/runtime-kernel.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export { evaluateModelInputCompatibility, listCompatibleModelIds } from './runti
|
|
|
101
101
|
export { isRuntimeFailureFact } from './runtime-kernel/graph-engine/functions/runtimeFailureFact.js';
|
|
102
102
|
export { noopAudit } from './runtime-kernel/audit/noopAudit.js';
|
|
103
103
|
export { normalizeToolArgs } from './runtime-kernel/tools/argNormalizer.js';
|
|
104
|
+
export { parseEngineCheckpoint } from './runtime-kernel/graph-engine/functions/parseEngineCheckpoint.js';
|
|
104
105
|
export { projectChildRuntimeEventToSubRunTrace } from './runtime-kernel/child-run-trace/projectChildRuntimeEventToSubRunTrace.js';
|
|
105
106
|
export { readCheckpointContextUsage } from './runtime-kernel/graph-engine/functions/engineStateSnapshot.js';
|
|
106
107
|
export { requestEnricherRegistry } from './runtime-kernel/enrichment/registry.js';
|
package/dist/runtime-kernel.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(graph_engine_exports, {
|
|
|
34
34
|
evaluatePrimaryPromptCapacity: () => evaluatePrimaryPromptCapacity,
|
|
35
35
|
isRunPauseSignal: () => isRunPauseSignal,
|
|
36
36
|
isRuntimeFailureFact: () => isRuntimeFailureFact,
|
|
37
|
+
parseEngineCheckpoint: () => parseEngineCheckpoint,
|
|
37
38
|
readCheckpointContextUsage: () => readCheckpointContextUsage,
|
|
38
39
|
requireEventStoreId: () => requireEventStoreId,
|
|
39
40
|
resolveEffectivePromptBudget: () => resolveEffectivePromptBudget,
|
|
@@ -3155,23 +3156,23 @@ var GraphExecutor = class {
|
|
|
3155
3156
|
};
|
|
3156
3157
|
}
|
|
3157
3158
|
async saveCheckpoint(checkpointKey, state) {
|
|
3158
|
-
const
|
|
3159
|
+
const checkpoint2 = this.sanitize({
|
|
3159
3160
|
...state,
|
|
3160
3161
|
revision: (state.revision ?? 0) + 1
|
|
3161
3162
|
});
|
|
3162
|
-
await this.commitCheckpoint(checkpointKey,
|
|
3163
|
-
return
|
|
3163
|
+
await this.commitCheckpoint(checkpointKey, checkpoint2);
|
|
3164
|
+
return checkpoint2;
|
|
3164
3165
|
}
|
|
3165
|
-
async commitCheckpoint(checkpointKey,
|
|
3166
|
+
async commitCheckpoint(checkpointKey, checkpoint2) {
|
|
3166
3167
|
if (this.executionCheckpointPort) {
|
|
3167
|
-
await this.executionCheckpointPort.commit(checkpointKey,
|
|
3168
|
+
await this.executionCheckpointPort.commit(checkpointKey, checkpoint2);
|
|
3168
3169
|
} else {
|
|
3169
|
-
await this.checkpointer.save(checkpointKey,
|
|
3170
|
+
await this.checkpointer.save(checkpointKey, checkpoint2);
|
|
3170
3171
|
}
|
|
3171
3172
|
}
|
|
3172
3173
|
async saveCheckpointAndBuildResult(checkpointKey, state, events, stepCount) {
|
|
3173
|
-
const
|
|
3174
|
-
return { events, checkpoint, stepCount };
|
|
3174
|
+
const checkpoint2 = await this.saveCheckpoint(checkpointKey, state);
|
|
3175
|
+
return { events, checkpoint: checkpoint2, stepCount };
|
|
3175
3176
|
}
|
|
3176
3177
|
async runUntilYieldInternal(checkpointKey, initialState, reportStepsUsed, maxSteps) {
|
|
3177
3178
|
let state = initialState;
|
|
@@ -9298,16 +9299,16 @@ function requireEventStoreId(eventStoreId) {
|
|
|
9298
9299
|
}
|
|
9299
9300
|
function createMonotonicEventStoreIdFactory(nowProvider = () => Date.now()) {
|
|
9300
9301
|
let lastTimestamp = 0;
|
|
9301
|
-
let
|
|
9302
|
+
let counter2 = 0;
|
|
9302
9303
|
return () => {
|
|
9303
9304
|
const timestamp = Math.max(nowProvider(), lastTimestamp);
|
|
9304
9305
|
if (timestamp === lastTimestamp) {
|
|
9305
|
-
|
|
9306
|
+
counter2 += 1;
|
|
9306
9307
|
} else {
|
|
9307
9308
|
lastTimestamp = timestamp;
|
|
9308
|
-
|
|
9309
|
+
counter2 = 0;
|
|
9309
9310
|
}
|
|
9310
|
-
return `${String(timestamp).padStart(13, "0")}-${String(
|
|
9311
|
+
return `${String(timestamp).padStart(13, "0")}-${String(counter2).padStart(4, "0")}`;
|
|
9311
9312
|
};
|
|
9312
9313
|
}
|
|
9313
9314
|
|
|
@@ -9719,6 +9720,76 @@ function assertNonNegativeSafeInteger(value, field) {
|
|
|
9719
9720
|
throw new Error(`${field} \u5FC5\u987B\u662F\u975E\u8D1F\u5B89\u5168\u6574\u6570\u3002`);
|
|
9720
9721
|
}
|
|
9721
9722
|
}
|
|
9723
|
+
var counter = z.number().int().nonnegative();
|
|
9724
|
+
var executor = z.object({
|
|
9725
|
+
stepCount: counter,
|
|
9726
|
+
phase: z.string().optional(),
|
|
9727
|
+
maxSteps: counter.optional(),
|
|
9728
|
+
remainingSteps: z.number().int().optional(),
|
|
9729
|
+
finalStepPolicy: z.enum(["final_answer", "force_tools"]).optional(),
|
|
9730
|
+
finalStepForcedTools: z.array(z.string()).optional(),
|
|
9731
|
+
lastStepsHintThreshold: counter.optional(),
|
|
9732
|
+
systemReminderPolicy: AgentSpecSystemReminderPolicy.optional(),
|
|
9733
|
+
toolObservationPolicy: AgentSpecToolObservationGovernancePolicy.optional(),
|
|
9734
|
+
runLockedModelId: z.string().optional(),
|
|
9735
|
+
lastSuccessfulLlmModelId: z.string().optional(),
|
|
9736
|
+
llmInvocationKind: z.enum(["user_initiated", "continuation"]).optional(),
|
|
9737
|
+
llmInvocationCount: counter.optional(),
|
|
9738
|
+
lockRequestedModelId: z.boolean().optional(),
|
|
9739
|
+
contextCompaction: z.object({
|
|
9740
|
+
attemptCount: counter,
|
|
9741
|
+
committedCount: counter,
|
|
9742
|
+
lastCommittedFingerprint: z.string().optional()
|
|
9743
|
+
}).strict().optional()
|
|
9744
|
+
}).strict();
|
|
9745
|
+
var checkpoint = z.object({
|
|
9746
|
+
nodeId: z.string().min(1),
|
|
9747
|
+
schemaVersion: z.literal(ENGINE_STATE_SCHEMA_VERSION).optional(),
|
|
9748
|
+
revision: counter.optional(),
|
|
9749
|
+
executionStatus: z.enum(["ready", "executing", "yielded", "awaiting_user"]).optional(),
|
|
9750
|
+
local: z.object({
|
|
9751
|
+
runId: RunIdSchema.optional(),
|
|
9752
|
+
parentRunId: RunIdSchema.optional(),
|
|
9753
|
+
conversationId: z.string().optional(),
|
|
9754
|
+
turnId: z.string().optional(),
|
|
9755
|
+
request: SerializableJsonRecord.optional(),
|
|
9756
|
+
history: z.array(RuntimeEvent).optional(),
|
|
9757
|
+
newEvents: z.array(RuntimeEvent).optional(),
|
|
9758
|
+
executorLocal: executor.optional(),
|
|
9759
|
+
pendingToolCalls: z.array(z.object({
|
|
9760
|
+
id: ToolCallIdSchema,
|
|
9761
|
+
type: z.literal("function"),
|
|
9762
|
+
function: z.object({ name: z.string().min(1), arguments: z.string() }).strict()
|
|
9763
|
+
}).strict()).optional(),
|
|
9764
|
+
executingToolCallId: ToolCallIdSchema.optional(),
|
|
9765
|
+
toolBatchCompletionMode: z.enum(["continue_to_llm", "yield_after_batch"]).optional(),
|
|
9766
|
+
pendingInteractionSpec: SerializableJsonRecord.optional(),
|
|
9767
|
+
lastToolResult: SerializableJsonRecord.optional(),
|
|
9768
|
+
finalAnswer: z.string().optional(),
|
|
9769
|
+
answerId: z.string().optional(),
|
|
9770
|
+
chunkSeq: counter.optional(),
|
|
9771
|
+
contextUsage: ContextUsageSnapshot.optional()
|
|
9772
|
+
}).passthrough().optional()
|
|
9773
|
+
}).strict();
|
|
9774
|
+
function parseEngineCheckpoint(value) {
|
|
9775
|
+
const result = checkpoint.parse(SerializableJsonRecord.parse(value));
|
|
9776
|
+
for (const key of [
|
|
9777
|
+
"memory",
|
|
9778
|
+
"signal",
|
|
9779
|
+
"toolContext",
|
|
9780
|
+
"runtimeEventSink",
|
|
9781
|
+
"runtimeEventCommitPort",
|
|
9782
|
+
"runtimeFailureFactSink",
|
|
9783
|
+
"summarizationCallbacks",
|
|
9784
|
+
"commitExecutionBoundary",
|
|
9785
|
+
"toolRecoveryPort"
|
|
9786
|
+
]) {
|
|
9787
|
+
if (result.local && Object.hasOwn(result.local, key)) {
|
|
9788
|
+
throw new Error(`Checkpoint must not contain execution capability: ${key}`);
|
|
9789
|
+
}
|
|
9790
|
+
}
|
|
9791
|
+
return result;
|
|
9792
|
+
}
|
|
9722
9793
|
|
|
9723
9794
|
// src/runtime-kernel/tools/index.ts
|
|
9724
9795
|
var tools_exports = {};
|
|
@@ -10180,14 +10251,14 @@ var EventBusEventPersistence = class {
|
|
|
10180
10251
|
checkpointWritesActive;
|
|
10181
10252
|
checkpointEvents = [];
|
|
10182
10253
|
/** Graph 的执行边界复用同一有序队列;没有第二条事件写入链。 */
|
|
10183
|
-
async commitCheckpoint(checkpointKey,
|
|
10254
|
+
async commitCheckpoint(checkpointKey, checkpoint2) {
|
|
10184
10255
|
const writer = this.options.checkpointWriter;
|
|
10185
10256
|
if (!writer || !this.checkpointWritesActive) throw new Error("Checkpoint writer is not active");
|
|
10186
10257
|
const events = this.checkpointEvents;
|
|
10187
10258
|
this.checkpointEvents = [];
|
|
10188
10259
|
await this.enqueueWrite(() => writer({
|
|
10189
10260
|
checkpointKey,
|
|
10190
|
-
checkpoint,
|
|
10261
|
+
checkpoint: checkpoint2,
|
|
10191
10262
|
events: events.map((event) => ({ event, eventStoreId: this.options.nextEventStoreId() }))
|
|
10192
10263
|
}));
|
|
10193
10264
|
}
|
|
@@ -11880,15 +11951,15 @@ function hasSeedHistoryPrefix(history, seedHistory) {
|
|
|
11880
11951
|
}
|
|
11881
11952
|
return true;
|
|
11882
11953
|
}
|
|
11883
|
-
function readCheckpointHistory(
|
|
11884
|
-
if (!
|
|
11885
|
-
const history =
|
|
11954
|
+
function readCheckpointHistory(checkpoint2) {
|
|
11955
|
+
if (!checkpoint2?.local) return [];
|
|
11956
|
+
const history = checkpoint2.local.history;
|
|
11886
11957
|
if (!Array.isArray(history)) return [];
|
|
11887
11958
|
return parseRuntimeEvents(history);
|
|
11888
11959
|
}
|
|
11889
11960
|
async function recoverChildRunEventsFromCheckpoint(params) {
|
|
11890
|
-
const
|
|
11891
|
-
const history = readCheckpointHistory(
|
|
11961
|
+
const checkpoint2 = await params.checkpointer.load(params.checkpointKey);
|
|
11962
|
+
const history = readCheckpointHistory(checkpoint2);
|
|
11892
11963
|
if (history.length === 0) {
|
|
11893
11964
|
return [];
|
|
11894
11965
|
}
|
|
@@ -12184,9 +12255,9 @@ var ChildRunInvoker = class {
|
|
|
12184
12255
|
async continueChild(config, runId, conversationId) {
|
|
12185
12256
|
const persistence = config.persistence;
|
|
12186
12257
|
if (!persistence || persistence.expectedRevision === void 0) throw new Error("Missing child continuation contract");
|
|
12187
|
-
const
|
|
12188
|
-
if (!
|
|
12189
|
-
const local = readGraphAgentLocal({ ...
|
|
12258
|
+
const checkpoint2 = await persistence.checkpointer.load(runId);
|
|
12259
|
+
if (!checkpoint2 || checkpoint2.local?.conversationId !== conversationId) throw new Error("Child checkpoint identity mismatch");
|
|
12260
|
+
const local = readGraphAgentLocal({ ...checkpoint2.local, runtimeEventSink: config.runtimeEventSink });
|
|
12190
12261
|
const request = local.request;
|
|
12191
12262
|
if (!request || !local.turnId || !request.model_id) throw new Error("Child recovery input is incomplete");
|
|
12192
12263
|
const context = createChildRunToolContext({
|
|
@@ -13463,7 +13534,15 @@ function createRunConcurrencyKeyRegistry() {
|
|
|
13463
13534
|
runIdByKey.delete(concurrencyKey);
|
|
13464
13535
|
}
|
|
13465
13536
|
}
|
|
13466
|
-
|
|
13537
|
+
function transfer(previous, next, concurrencyKey) {
|
|
13538
|
+
if (runIdByKey.get(concurrencyKey) !== previous || keyByRunId.has(next)) {
|
|
13539
|
+
throw new RunConcurrencyKeyOccupiedError(concurrencyKey, runIdByKey.get(concurrencyKey) ?? previous, next);
|
|
13540
|
+
}
|
|
13541
|
+
keyByRunId.delete(previous);
|
|
13542
|
+
keyByRunId.set(next, concurrencyKey);
|
|
13543
|
+
runIdByKey.set(concurrencyKey, next);
|
|
13544
|
+
}
|
|
13545
|
+
return { acquire, release, transfer };
|
|
13467
13546
|
}
|
|
13468
13547
|
|
|
13469
13548
|
// src/runtime-kernel/run-supervisor/functions/runRegistration.ts
|
|
@@ -13712,6 +13791,9 @@ var DefaultRunSupervisor = class {
|
|
|
13712
13791
|
});
|
|
13713
13792
|
}
|
|
13714
13793
|
async registerRun(spec) {
|
|
13794
|
+
if (spec.replacesPausedRun) {
|
|
13795
|
+
return this.withRunControlLock(spec.replacesPausedRun.runId, () => this.registerPausedReplacement(spec));
|
|
13796
|
+
}
|
|
13715
13797
|
const runId = spec.runId ?? this.runIdFactory();
|
|
13716
13798
|
if (this.handles.has(runId) || await this.registryStore.load(runId)) {
|
|
13717
13799
|
throw new RunAlreadyRegisteredError(runId);
|
|
@@ -13722,13 +13804,51 @@ var DefaultRunSupervisor = class {
|
|
|
13722
13804
|
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
13723
13805
|
const record = createInitialRunRecord({ runId, spec, startedAt });
|
|
13724
13806
|
try {
|
|
13725
|
-
await
|
|
13807
|
+
if (spec.admissionCommit) await spec.admissionCommit(record);
|
|
13808
|
+
else await this.registryStore.save(record);
|
|
13726
13809
|
} catch (error) {
|
|
13727
13810
|
this.releaseRunAdmission(runId);
|
|
13728
13811
|
throw error;
|
|
13729
13812
|
}
|
|
13730
13813
|
return this.attachRun(record, spec, controller);
|
|
13731
13814
|
}
|
|
13815
|
+
async registerPausedReplacement(spec) {
|
|
13816
|
+
const target = spec.replacesPausedRun;
|
|
13817
|
+
if (!target || !spec.concurrencyKey || !spec.admissionCommit || !this.registryStore.compareAndSwap) {
|
|
13818
|
+
throw new Error("Paused replacement requires concurrency identity and atomic admissionCommit");
|
|
13819
|
+
}
|
|
13820
|
+
this.getHandle(target.runId);
|
|
13821
|
+
const previous = await this.registryStore.load(target.runId);
|
|
13822
|
+
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) {
|
|
13823
|
+
throw new RunInteractionConflictError(target.runId, "replacement does not match the settled pause");
|
|
13824
|
+
}
|
|
13825
|
+
const runId = spec.runId ?? this.runIdFactory();
|
|
13826
|
+
if (this.handles.has(runId) || await this.registryStore.load(runId)) throw new RunAlreadyRegisteredError(runId);
|
|
13827
|
+
this.runConcurrencyKeys.transfer(previous.runId, runId, spec.concurrencyKey);
|
|
13828
|
+
this.runSlotLimiter.release(previous.runId);
|
|
13829
|
+
this.runSlotLimiter.acquire(runId);
|
|
13830
|
+
const now = this.now();
|
|
13831
|
+
const record = createInitialRunRecord({ runId, spec, startedAt: now });
|
|
13832
|
+
const next = {
|
|
13833
|
+
...previous,
|
|
13834
|
+
status: "cancelled",
|
|
13835
|
+
updatedAt: now,
|
|
13836
|
+
errorIfAny: { errorCode: "RUN_REPLACED", message: "Replaced by a newly accepted request", recoverable: false }
|
|
13837
|
+
};
|
|
13838
|
+
try {
|
|
13839
|
+
await spec.admissionCommit(record, { previous, next });
|
|
13840
|
+
} catch (error) {
|
|
13841
|
+
this.runSlotLimiter.release(runId);
|
|
13842
|
+
this.runSlotLimiter.acquire(previous.runId);
|
|
13843
|
+
this.runConcurrencyKeys.transfer(runId, previous.runId, spec.concurrencyKey);
|
|
13844
|
+
throw error;
|
|
13845
|
+
}
|
|
13846
|
+
this.cleanupRunResources(previous.runId);
|
|
13847
|
+
this.notifyTerminalWaiters(previous.runId);
|
|
13848
|
+
const controller = new AbortController();
|
|
13849
|
+
forwardParentAbortSignal(controller, spec.parentSignal);
|
|
13850
|
+
return this.attachRun(record, spec, controller);
|
|
13851
|
+
}
|
|
13732
13852
|
async restoreRun(spec) {
|
|
13733
13853
|
if (!this.registryStore.compareAndSwap) throw new Error("Run restoration requires atomic registry transitions");
|
|
13734
13854
|
return this.withRunControlLock(spec.runId, async () => {
|
|
@@ -13852,7 +13972,7 @@ var DefaultRunSupervisor = class {
|
|
|
13852
13972
|
return this.withRunControlLock(input.runId, async () => {
|
|
13853
13973
|
const handle = this.getHandle(input.runId);
|
|
13854
13974
|
const record = await this.registryStore.load(input.runId);
|
|
13855
|
-
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt) {
|
|
13975
|
+
if (!record || record.status !== "paused" || record.pausedAt === void 0 || record.updatedAt !== input.expectedUpdatedAt || input.expectedExecutionId !== void 0 && record.metadata?.executionId !== input.expectedExecutionId) {
|
|
13856
13976
|
throw new RunInteractionConflictError(input.runId, "run is not settled at the expected pause");
|
|
13857
13977
|
}
|
|
13858
13978
|
await persistRunTransition(this.registryStore, record, {
|
|
@@ -13993,7 +14113,7 @@ var DefaultRunSupervisor = class {
|
|
|
13993
14113
|
}
|
|
13994
14114
|
const awaitingUserWithoutClaim = { ...awaitingUser };
|
|
13995
14115
|
Reflect.deleteProperty(awaitingUserWithoutClaim, "resumeClaim");
|
|
13996
|
-
|
|
14116
|
+
const nextRecord = {
|
|
13997
14117
|
...record,
|
|
13998
14118
|
status: "running",
|
|
13999
14119
|
updatedAt: this.now(),
|
|
@@ -14003,6 +14123,10 @@ var DefaultRunSupervisor = class {
|
|
|
14003
14123
|
metadata: {
|
|
14004
14124
|
...record.metadata ?? {},
|
|
14005
14125
|
...execution ? { executionId: execution.executionId } : {},
|
|
14126
|
+
...execution?.inputEventIds ? { resumeInputs: {
|
|
14127
|
+
eventIds: [...execution.inputEventIds],
|
|
14128
|
+
checkpointRevision: pendingInteraction.checkpointRevision
|
|
14129
|
+
} } : {},
|
|
14006
14130
|
awaitingUser: {
|
|
14007
14131
|
...awaitingUserWithoutClaim,
|
|
14008
14132
|
interaction: {
|
|
@@ -14011,7 +14135,9 @@ var DefaultRunSupervisor = class {
|
|
|
14011
14135
|
}
|
|
14012
14136
|
}
|
|
14013
14137
|
}
|
|
14014
|
-
}
|
|
14138
|
+
};
|
|
14139
|
+
if (execution?.admissionCommit) await execution.admissionCommit(record, nextRecord);
|
|
14140
|
+
else await persistRunTransition(this.registryStore, record, nextRecord);
|
|
14015
14141
|
const executionController = new AbortController();
|
|
14016
14142
|
forwardParentAbortSignal(executionController, parentSignal);
|
|
14017
14143
|
handle.replaceExecutionAbortController(executionController, execution?.executionId ?? (typeof record.metadata?.executionId === "string" ? record.metadata.executionId : void 0));
|
|
@@ -14177,13 +14303,13 @@ __export(system_reminder_exports, {
|
|
|
14177
14303
|
|
|
14178
14304
|
// src/runtime-kernel/testkit/defaultGraphExecutor.ts
|
|
14179
14305
|
function createDefaultGraphExecutor(options) {
|
|
14180
|
-
const
|
|
14306
|
+
const executor2 = new GraphExecutor(
|
|
14181
14307
|
options.checkpointer ?? new MemoryCheckpointer(),
|
|
14182
14308
|
{ maxSteps: options.maxSteps ?? 8 }
|
|
14183
14309
|
);
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14310
|
+
executor2.registerNode(new UserNode());
|
|
14311
|
+
executor2.registerNode(options.llmNode);
|
|
14312
|
+
executor2.registerNode(new ToolNode({
|
|
14187
14313
|
toolRuntime: options.toolRuntime,
|
|
14188
14314
|
observationPreview: options.observationPreview,
|
|
14189
14315
|
auditPort: options.auditPort,
|
|
@@ -14191,8 +14317,8 @@ function createDefaultGraphExecutor(options) {
|
|
|
14191
14317
|
modelInputCapabilityValidator: options.modelInputCapabilityValidator,
|
|
14192
14318
|
modelInputResolver: options.modelInputResolver
|
|
14193
14319
|
}));
|
|
14194
|
-
|
|
14195
|
-
return
|
|
14320
|
+
executor2.registerNode(new WaitUserNode({ auditPort: options.auditPort }));
|
|
14321
|
+
return executor2;
|
|
14196
14322
|
}
|
|
14197
14323
|
|
|
14198
14324
|
// src/runtime-kernel/testkit/graphLoopHarness.ts
|
|
@@ -14217,7 +14343,7 @@ function createGraphLoopHarness(options) {
|
|
|
14217
14343
|
return {
|
|
14218
14344
|
async run() {
|
|
14219
14345
|
const checkpointKey = options.runId ?? options.turnId;
|
|
14220
|
-
const
|
|
14346
|
+
const executor2 = createDefaultGraphExecutor({
|
|
14221
14347
|
llmNode: options.createLlmNode({
|
|
14222
14348
|
llmCaller: options.llmCaller,
|
|
14223
14349
|
toolRuntime: options.toolRuntime
|
|
@@ -14247,8 +14373,8 @@ function createGraphLoopHarness(options) {
|
|
|
14247
14373
|
signal: options.signal ?? options.toolContext.abortSignal,
|
|
14248
14374
|
executorLocal
|
|
14249
14375
|
};
|
|
14250
|
-
await
|
|
14251
|
-
const result = await
|
|
14376
|
+
await executor2.prime(checkpointKey, local, "user");
|
|
14377
|
+
const result = await executor2.runUntilYield(checkpointKey);
|
|
14252
14378
|
return {
|
|
14253
14379
|
checkpointNodeId: result.checkpoint.nodeId,
|
|
14254
14380
|
stepCount: result.stepCount,
|
|
@@ -14258,6 +14384,6 @@ function createGraphLoopHarness(options) {
|
|
|
14258
14384
|
};
|
|
14259
14385
|
}
|
|
14260
14386
|
|
|
14261
|
-
export { AuditEnvelopePersistenceError, BUILTIN_SYSTEM_REMINDER_TEMPLATES, BUILTIN_SYSTEM_REMINDER_TRIGGERS, BaseTool, ChildRunParentTraceProjection, CommonParameterTypes, CompositeAuditPort, DefaultTokenizerPort, EMPTY_MODEL_INPUT_REQUIREMENT, ENGINE_ERROR_CODES, ENGINE_STATE_SCHEMA_VERSION, EventStoreAuditPort, FileAuditPort, GraphAgentExecutor, GraphExecutor, INITIAL_CANONICAL_INFERENCE_STREAM_STATE, LLMPolicyEngine, LLM_IMAGE_INPUT_ERROR_CODES, LLM_MODEL_ELIGIBILITY_ERROR_CODE, LlmCaller, LlmImageInputError, LlmModelEligibilityError, LlmNode, MODEL_INPUT_ERROR_CODES, MODEL_INPUT_PLACEMENTS, MemoryCheckpointer, MemoryEventStore, ModelInputCapabilityError, ModelResolver, PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, REASONING_EFFORTS, RunPauseRequested, RunRecoveryBlockedError, RuntimeEventSubRunTracePublisher, SYSTEM_REMINDER_RULES, SystemReminderRegistry, ToolModelInputResolutionError, ToolNode, ToolParameterSchemaError, UserNode, WaitUserNode, addLedgerAggregate, addUsageTotals, advanceCanonicalInferenceStreamState, agentHasToolTrigger, aggregateCanonicalUsage, aggregateTokenLedgerEntries, applySystemReminders, assertModelInputCompatibility, assertToolParameterSchema, audit_exports as audit, child_run_trace_exports as childRunTrace, child_runs_exports as childRuns, computeCost, computeToolIdempotencyKey, consoleAudit, consumeCanonicalInferenceStream, copyToolContextRuntimeCapability, countToolCallsInCurrentRequest, createCompositeAudit, createConsoleAudit, createContextComponentLedgerEntry, createDefaultGraphExecutor, createDefaultSystemReminderRegistry, createDefaultTokenizerPort, createEventStoreAudit, createFileAudit, createFixedChatModelCatalog, createGraphLoopHarness, createHostToolCallBootstrap, createLlmUsageLedgerEntry, createModelInputCompatibilityError, createMonotonicEventStoreIdFactory, createRunTokenUsageAggregate, createSystemReminderRules, defaultPolicyEngine, defaultSystemReminderRegistry, deriveModelInputRequirement, emitAuditEnvelope, emitSandboxDecisionAudit, enrichment_exports as enrichment, ensureToolContextRuntimeCapability, evaluateModelInputCompatibility, evaluatePrimaryPromptCapacity, events_exports as events, execution_exports as execution, findCachedToolOutputByIdempotencyKey, getToolContextRuntimeBinding, graph_engine_exports as graph, hostReminderTextTemplate, isRunPauseSignal, isRuntimeFailureFact, isValidReasoningEffort, lastStepsHintTemplate, listCompatibleModelIds, llm_exports as llm, maxStepsForceFinalAnswerTemplate, noopAudit, normalizeToolArgs, parseToolModelInputDeclaration, periodicProgressReflectionTemplate, phaseEqualsTrigger, projectChildRuntimeEventToSubRunTrace, readCheckpointContextUsage, readNonEmptyStrings, readToolContextPersistedHistory, readToolContextWorkingHistory, remainingStepsLeqTrigger, requestEnricherRegistry, requireEventStoreId, resolveEffectiveEffort, resolveEffectivePromptBudget, resolveToolModelInput, run_context_exports as runContext, run_supervisor_exports as runSupervisor, stepCountModuloTrigger, stripRuntimeReservedToolContextPatch, summarizeCheckpoint, system_reminder_exports as systemReminder, telemetry_exports as telemetry, toDisplayStep, token_accounting_exports as tokenAccounting, toolCallStreakTemplate, toolCallStreakTrigger, tools_exports as tools };
|
|
14387
|
+
export { AuditEnvelopePersistenceError, BUILTIN_SYSTEM_REMINDER_TEMPLATES, BUILTIN_SYSTEM_REMINDER_TRIGGERS, BaseTool, ChildRunParentTraceProjection, CommonParameterTypes, CompositeAuditPort, DefaultTokenizerPort, EMPTY_MODEL_INPUT_REQUIREMENT, ENGINE_ERROR_CODES, ENGINE_STATE_SCHEMA_VERSION, EventStoreAuditPort, FileAuditPort, GraphAgentExecutor, GraphExecutor, INITIAL_CANONICAL_INFERENCE_STREAM_STATE, LLMPolicyEngine, LLM_IMAGE_INPUT_ERROR_CODES, LLM_MODEL_ELIGIBILITY_ERROR_CODE, LlmCaller, LlmImageInputError, LlmModelEligibilityError, LlmNode, MODEL_INPUT_ERROR_CODES, MODEL_INPUT_PLACEMENTS, MemoryCheckpointer, MemoryEventStore, ModelInputCapabilityError, ModelResolver, PRIMARY_PROMPT_CAPACITY_ERROR_CODE, PrimaryPromptCapacityError, REASONING_EFFORTS, RunPauseRequested, RunRecoveryBlockedError, RuntimeEventSubRunTracePublisher, SYSTEM_REMINDER_RULES, SystemReminderRegistry, ToolModelInputResolutionError, ToolNode, ToolParameterSchemaError, UserNode, WaitUserNode, addLedgerAggregate, addUsageTotals, advanceCanonicalInferenceStreamState, agentHasToolTrigger, aggregateCanonicalUsage, aggregateTokenLedgerEntries, applySystemReminders, assertModelInputCompatibility, assertToolParameterSchema, audit_exports as audit, child_run_trace_exports as childRunTrace, child_runs_exports as childRuns, computeCost, computeToolIdempotencyKey, consoleAudit, consumeCanonicalInferenceStream, copyToolContextRuntimeCapability, countToolCallsInCurrentRequest, createCompositeAudit, createConsoleAudit, createContextComponentLedgerEntry, createDefaultGraphExecutor, createDefaultSystemReminderRegistry, createDefaultTokenizerPort, createEventStoreAudit, createFileAudit, createFixedChatModelCatalog, createGraphLoopHarness, createHostToolCallBootstrap, createLlmUsageLedgerEntry, createModelInputCompatibilityError, createMonotonicEventStoreIdFactory, createRunTokenUsageAggregate, createSystemReminderRules, defaultPolicyEngine, defaultSystemReminderRegistry, deriveModelInputRequirement, emitAuditEnvelope, emitSandboxDecisionAudit, enrichment_exports as enrichment, ensureToolContextRuntimeCapability, evaluateModelInputCompatibility, evaluatePrimaryPromptCapacity, events_exports as events, execution_exports as execution, findCachedToolOutputByIdempotencyKey, getToolContextRuntimeBinding, graph_engine_exports as graph, hostReminderTextTemplate, isRunPauseSignal, isRuntimeFailureFact, isValidReasoningEffort, lastStepsHintTemplate, listCompatibleModelIds, llm_exports as llm, maxStepsForceFinalAnswerTemplate, noopAudit, normalizeToolArgs, parseEngineCheckpoint, parseToolModelInputDeclaration, periodicProgressReflectionTemplate, phaseEqualsTrigger, projectChildRuntimeEventToSubRunTrace, readCheckpointContextUsage, readNonEmptyStrings, readToolContextPersistedHistory, readToolContextWorkingHistory, remainingStepsLeqTrigger, requestEnricherRegistry, requireEventStoreId, resolveEffectiveEffort, resolveEffectivePromptBudget, resolveToolModelInput, run_context_exports as runContext, run_supervisor_exports as runSupervisor, stepCountModuloTrigger, stripRuntimeReservedToolContextPatch, summarizeCheckpoint, system_reminder_exports as systemReminder, telemetry_exports as telemetry, toDisplayStep, token_accounting_exports as tokenAccounting, toolCallStreakTemplate, toolCallStreakTrigger, tools_exports as tools };
|
|
14262
14388
|
//# sourceMappingURL=runtime-kernel.js.map
|
|
14263
14389
|
//# sourceMappingURL=runtime-kernel.js.map
|