stitchkit 0.57.0 → 0.58.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/dist/agent-runtime/compaction.d.ts +3 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +40 -0
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/history.d.ts +13 -0
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +1 -0
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/models.d.ts +39 -3
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +3 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/prompt.d.ts +21 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +9 -1
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +2 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +3 -0
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +7 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/testing.d.ts +10 -1
- package/dist/agent-runtime/testing.d.ts.map +1 -1
- package/dist/agent-runtime.d.ts +4 -4
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +356 -64
- package/dist/{index-1f4fcj0b.js → index-vtjgx3vv.js} +1 -0
- package/dist/testing/agent-store-conformance.d.ts.map +1 -1
- package/dist/testing.d.ts +1 -0
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +169 -4
- package/llms-full.txt +102 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-store-conformance.d.ts","sourceRoot":"","sources":["../../src/testing/agent-store-conformance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,2BAA2B;IAC1C,WAAW,IAAI,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/D;AAwCD,gFAAgF;AAChF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"agent-store-conformance.d.ts","sourceRoot":"","sources":["../../src/testing/agent-store-conformance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,2BAA2B;IAC1C,WAAW,IAAI,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/D;AAwCD,gFAAgF;AAChF,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC,IAAI,CAAC,CAmPf"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare function createHandlerTestClient<T extends Record<string, Endpoin
|
|
|
31
31
|
export declare function createHandlerTestClients<T extends Record<string, ContractDef<Record<string, EndpointDef>, string>>, TServer = unknown, const K extends string = never>(config: HandlerTestClientsConfig<T, TServer, K>): {
|
|
32
32
|
[P in keyof T]: ScopedHttpClient<T[P]['endpoints'], ScopedKeys<K>>;
|
|
33
33
|
};
|
|
34
|
+
export { type AgentRaceBarrier, type AgentRaceDriver, type AgentRaceTrace, type AgentRaceTraceEntry, createAgentRaceBarrier, createAgentRaceDriver, createAgentRaceTrace, } from './agent-runtime/testing';
|
|
34
35
|
export { type AgentStoreConformanceConfig, runAgentStoreConformance, } from './testing/agent-store-conformance';
|
|
35
36
|
export { assertSurfaceDiscovery, type ConformanceTransport, type CreateRealtimeProbeDriverConfig, createRealtimeProbeDriver, type DefineRealtimeProbeConfig, defineRealtimeProbe, type RealtimeDisconnectObservation, RealtimeDisconnectObservationSchema, type RealtimeProbeAdapter, type RealtimeProbeFixture, type RealtimeProbeScenario, type RealtimeRejectionObservation, RealtimeRejectionObservationSchema, type RunSurfaceProbesConfig, runSurfaceProbes, type SurfaceDiscoveryObservation, type SurfaceProbe, type SurfaceProbeDriver, type SurfaceRealtimeDiscoveryObservation, type SurfaceToolDiscoveryObservation, type TransportObservation, TransportObservationSchema, } from './testing/surface-conformance';
|
|
36
37
|
export { assertSurfaceManifestSnapshot, buildSurfaceManifest, type IncompatibleSchemaPolicy, type McpSchemaValidationConfig, type SurfaceAgentProjection, type SurfaceManifest, type SurfaceManifestConfig, type SurfaceManifestExtension, SurfaceManifestExtensionSchema, type SurfaceManifestOperation, SurfaceManifestOperationSchema, type SurfaceManifestRealtimeEvent, SurfaceManifestRealtimeEventSchema, SurfaceManifestSchema, type SurfaceManifestTool, SurfaceManifestToolSchema, type SurfaceManifestToolSurface, SurfaceManifestToolSurfaceSchema, type SurfaceMcpPreparation, SurfaceRealtimeSchemaPairSchema, type SurfaceRuntimeToolDefinition, SurfaceSchemaDigestsSchema, type SurfaceToolDefinition, type SurfaceToolExtension, serializeSurfaceValue, } from './testing/surface-manifest';
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,oBAAoB,EAGzB,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC;AA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5
|
import {
|
|
6
6
|
RealtimeRequestDisconnectedError,
|
|
7
7
|
RealtimeRequestInvalidAcknowledgementError,
|
|
@@ -27,6 +27,81 @@ import {
|
|
|
27
27
|
} from "./index-smpbdg6k.js";
|
|
28
28
|
import"./index-1bx83sw4.js";
|
|
29
29
|
|
|
30
|
+
// src/agent-runtime/testing.ts
|
|
31
|
+
function createAgentRaceBarrier(timeoutMs = 5000) {
|
|
32
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
33
|
+
throw new TypeError("Agent race barrier timeoutMs must be a positive safe integer");
|
|
34
|
+
}
|
|
35
|
+
const reached = Promise.withResolvers();
|
|
36
|
+
const released = Promise.withResolvers();
|
|
37
|
+
let announced = false;
|
|
38
|
+
return {
|
|
39
|
+
reached: reached.promise,
|
|
40
|
+
async wait() {
|
|
41
|
+
if (!announced) {
|
|
42
|
+
announced = true;
|
|
43
|
+
reached.resolve();
|
|
44
|
+
}
|
|
45
|
+
let timer;
|
|
46
|
+
try {
|
|
47
|
+
await Promise.race([
|
|
48
|
+
released.promise,
|
|
49
|
+
new Promise((_resolve, reject) => {
|
|
50
|
+
timer = setTimeout(() => reject(new Error(`Agent race barrier exceeded ${timeoutMs}ms teardown bound`)), timeoutMs);
|
|
51
|
+
})
|
|
52
|
+
]);
|
|
53
|
+
} finally {
|
|
54
|
+
if (timer !== undefined)
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
release: released.resolve
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function createAgentRaceTrace() {
|
|
62
|
+
const recorded = [];
|
|
63
|
+
return {
|
|
64
|
+
record(name) {
|
|
65
|
+
const entry = { name, sequence: recorded.length };
|
|
66
|
+
recorded.push(entry);
|
|
67
|
+
return entry;
|
|
68
|
+
},
|
|
69
|
+
entries: () => recorded.map((entry) => ({ ...entry })),
|
|
70
|
+
assertBefore(first, second) {
|
|
71
|
+
const firstEntry = recorded.find((entry) => entry.name === first);
|
|
72
|
+
const secondEntry = recorded.find((entry) => entry.name === second);
|
|
73
|
+
if (!firstEntry || !secondEntry || firstEntry.sequence >= secondEntry.sequence) {
|
|
74
|
+
throw new Error(`Expected ${first} before ${second}`);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
assertSequence(names) {
|
|
78
|
+
const actual = recorded.map((entry) => entry.name);
|
|
79
|
+
if (actual.length !== names.length || actual.some((name, index) => name !== names[index])) {
|
|
80
|
+
throw new Error(`Expected trace ${names.join(" -> ")}, received ${actual.join(" -> ")}`);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
count: (name) => recorded.filter((entry) => entry.name === name).length
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function createAgentRaceDriver(timeoutMs = 5000) {
|
|
87
|
+
const trace = createAgentRaceTrace();
|
|
88
|
+
const barriers = new Map;
|
|
89
|
+
return {
|
|
90
|
+
trace,
|
|
91
|
+
barrier(name) {
|
|
92
|
+
const existing = barriers.get(name);
|
|
93
|
+
if (existing)
|
|
94
|
+
return existing;
|
|
95
|
+
const created = createAgentRaceBarrier(timeoutMs);
|
|
96
|
+
barriers.set(name, created);
|
|
97
|
+
return created;
|
|
98
|
+
},
|
|
99
|
+
releaseAll() {
|
|
100
|
+
for (const barrier of barriers.values())
|
|
101
|
+
barrier.release();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
30
105
|
// src/testing/agent-store-conformance.ts
|
|
31
106
|
function userMessage(conversationId, id) {
|
|
32
107
|
return AgentMessageSchema.parse({
|
|
@@ -175,15 +250,102 @@ async function runAgentStoreConformance(config) {
|
|
|
175
250
|
})
|
|
176
251
|
});
|
|
177
252
|
requireOutcome(stale, "conflict");
|
|
178
|
-
|
|
253
|
+
await store.recoverRun({
|
|
179
254
|
conversationId,
|
|
180
255
|
runId: running.id,
|
|
181
256
|
expectedRevision: running.revision,
|
|
257
|
+
action: "requeue"
|
|
258
|
+
}).then(() => {
|
|
259
|
+
throw new Error("Acquired recovery replayed without explicit safety evidence");
|
|
260
|
+
}, (error) => {
|
|
261
|
+
if (!(error instanceof TypeError))
|
|
262
|
+
throw error;
|
|
263
|
+
});
|
|
264
|
+
const checkpoint = await store.checkpointRunAssistant({
|
|
265
|
+
conversationId,
|
|
266
|
+
runId: running.id,
|
|
267
|
+
expectedRevision: running.revision,
|
|
268
|
+
ownerId: "conformance-owner",
|
|
269
|
+
assistant: AgentMessageSchema.parse({
|
|
270
|
+
schemaVersion: 1,
|
|
271
|
+
id: running.assistantMessageId,
|
|
272
|
+
conversationId,
|
|
273
|
+
runId: running.id,
|
|
274
|
+
role: "assistant",
|
|
275
|
+
status: "streaming",
|
|
276
|
+
parts: [{ type: "text", text: "checkpoint" }],
|
|
277
|
+
createdAt: "2026-08-22T00:00:00.000Z",
|
|
278
|
+
updatedAt: "2026-08-22T00:00:01.000Z"
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
requireOutcome(checkpoint, "applied");
|
|
282
|
+
const checkpointedRun = checkpoint.snapshot.runs.find((run) => run.id === running.id);
|
|
283
|
+
if (!checkpointedRun)
|
|
284
|
+
throw new Error("Checkpointed run disappeared");
|
|
285
|
+
const terminalAssistant = AgentMessageSchema.parse({
|
|
286
|
+
schemaVersion: 1,
|
|
287
|
+
id: running.assistantMessageId,
|
|
288
|
+
conversationId,
|
|
289
|
+
runId: running.id,
|
|
290
|
+
role: "assistant",
|
|
291
|
+
status: "completed",
|
|
292
|
+
parts: [{ type: "text", text: "done" }],
|
|
293
|
+
createdAt: "2026-08-22T00:00:00.000Z",
|
|
294
|
+
updatedAt: "2026-08-22T00:00:02.000Z"
|
|
295
|
+
});
|
|
296
|
+
const terminalResults = await Promise.all([
|
|
297
|
+
store.commitRunTerminal({
|
|
298
|
+
conversationId,
|
|
299
|
+
runId: running.id,
|
|
300
|
+
expectedRevision: checkpointedRun.revision,
|
|
301
|
+
ownerId: "conformance-owner",
|
|
302
|
+
assistant: terminalAssistant,
|
|
303
|
+
reason: "success"
|
|
304
|
+
}),
|
|
305
|
+
store.commitRunTerminal({
|
|
306
|
+
conversationId,
|
|
307
|
+
runId: running.id,
|
|
308
|
+
expectedRevision: checkpointedRun.revision,
|
|
309
|
+
ownerId: "conformance-owner",
|
|
310
|
+
assistant: terminalAssistant,
|
|
311
|
+
reason: "success"
|
|
312
|
+
})
|
|
313
|
+
]);
|
|
314
|
+
const terminalOutcomes = terminalResults.map((result) => result.outcome).sort();
|
|
315
|
+
if (terminalOutcomes.join(",") !== "applied,conflict") {
|
|
316
|
+
throw new Error(`Terminal race was not linearized: ${terminalOutcomes.join(",")}`);
|
|
317
|
+
}
|
|
318
|
+
const recoveryConversationId = `${conversationId}-recovery`;
|
|
319
|
+
const recoveryInput = userMessage(recoveryConversationId, "recovery-input");
|
|
320
|
+
const recoveryRun = queuedRun(recoveryConversationId, recoveryInput.id, "recovery-run");
|
|
321
|
+
const recoveryAccepted = await store.acceptInputAndAssignRun({
|
|
322
|
+
idempotencyKey: "recovery-request",
|
|
323
|
+
input: recoveryInput,
|
|
324
|
+
run: recoveryRun
|
|
325
|
+
});
|
|
326
|
+
requireOutcome(recoveryAccepted, "applied");
|
|
327
|
+
const recoveryAssigned = recoveryAccepted.snapshot.runs.find((run) => run.id === recoveryRun.id);
|
|
328
|
+
if (!recoveryAssigned)
|
|
329
|
+
throw new Error("Recovery run disappeared after admission");
|
|
330
|
+
const recoveryAcquired = await store.acquireRun({
|
|
331
|
+
conversationId: recoveryConversationId,
|
|
332
|
+
runId: recoveryAssigned.id,
|
|
333
|
+
expectedRevision: recoveryAssigned.revision,
|
|
334
|
+
ownerId: "abandoned-owner"
|
|
335
|
+
});
|
|
336
|
+
requireOutcome(recoveryAcquired, "applied");
|
|
337
|
+
const abandonedRun = recoveryAcquired.snapshot.runs.find((run) => run.id === recoveryRun.id);
|
|
338
|
+
if (!abandonedRun)
|
|
339
|
+
throw new Error("Recovery run disappeared after acquisition");
|
|
340
|
+
const abandoned = await store.recoverRun({
|
|
341
|
+
conversationId: recoveryConversationId,
|
|
342
|
+
runId: abandonedRun.id,
|
|
343
|
+
expectedRevision: abandonedRun.revision,
|
|
182
344
|
action: "abandon"
|
|
183
345
|
});
|
|
184
346
|
requireOutcome(abandoned, "applied");
|
|
185
|
-
const terminalRun = abandoned.snapshot.runs.find((run) => run.id ===
|
|
186
|
-
const terminalMessage = abandoned.snapshot.messages.find((message) => message.id ===
|
|
347
|
+
const terminalRun = abandoned.snapshot.runs.find((run) => run.id === abandonedRun.id);
|
|
348
|
+
const terminalMessage = abandoned.snapshot.messages.find((message) => message.id === abandonedRun.assistantMessageId);
|
|
187
349
|
if (terminalRun?.state !== "abandoned" || terminalMessage?.status !== "failed") {
|
|
188
350
|
throw new Error("Abandon recovery did not atomically terminalize its assistant record");
|
|
189
351
|
}
|
|
@@ -905,6 +1067,9 @@ export {
|
|
|
905
1067
|
assertSurfaceDiscovery,
|
|
906
1068
|
assertSurfaceManifestSnapshot,
|
|
907
1069
|
buildSurfaceManifest,
|
|
1070
|
+
createAgentRaceBarrier,
|
|
1071
|
+
createAgentRaceDriver,
|
|
1072
|
+
createAgentRaceTrace,
|
|
908
1073
|
createHandlerTestClient,
|
|
909
1074
|
createHandlerTestClients,
|
|
910
1075
|
createRealtimeProbeDriver,
|
package/llms-full.txt
CHANGED
|
@@ -3427,7 +3427,10 @@ const prompt = composeAgentPrompt([
|
|
|
3427
3427
|
const runtime = createAgentRuntime({
|
|
3428
3428
|
protocol,
|
|
3429
3429
|
store: createMemoryAgentRuntimeStore(),
|
|
3430
|
-
models: {
|
|
3430
|
+
models: {
|
|
3431
|
+
preflight: () => models.preflight('fast', ['tools']),
|
|
3432
|
+
resolve: () => models.resolve('fast', ['tools']),
|
|
3433
|
+
},
|
|
3431
3434
|
prompt: ({ context, signal, model }) =>
|
|
3432
3435
|
prompt({
|
|
3433
3436
|
context,
|
|
@@ -3577,6 +3580,10 @@ Every mutation carries an expected run revision or snapshot version. Input
|
|
|
3577
3580
|
assignment additionally carries an idempotency identity. A conflict is a
|
|
3578
3581
|
control outcome; stale data is never silently overwritten.
|
|
3579
3582
|
|
|
3583
|
+
Acquisition increments an optional monotonic `fencingToken`. The managed runtime carries it through
|
|
3584
|
+
checkpoint/terminal CAS and tool context, so a distributed adapter can reject an old owner even if
|
|
3585
|
+
an owner label is reused. Lease expiry and renewal remain application-owned.
|
|
3586
|
+
|
|
3580
3587
|
On startup, `runtime.recover({ resolveContext })` consumes bounded lightweight
|
|
3581
3588
|
pages. Its safe default resumes queued runs and reports acquired or
|
|
3582
3589
|
`interrupt_requested` runs as skipped. A policy may requeue acquired work only
|
|
@@ -3613,6 +3620,12 @@ These are post-commit notifications, not a transactional outbox: a process can
|
|
|
3613
3620
|
crash between the database commit and `publish`. Reconnect should load canonical
|
|
3614
3621
|
state. Exactly-once external delivery remains an application-owned outbox.
|
|
3615
3622
|
|
|
3623
|
+
Durable event IDs are derived from run, event type and snapshot version. Use
|
|
3624
|
+
`advanceAgentRuntimeEventCursor` to classify accepted, duplicate and gap delivery; a gap triggers a
|
|
3625
|
+
snapshot reload. `createAgentRuntimeEventSink` adds a bounded failure-isolated lifecycle and typed
|
|
3626
|
+
projection/redaction hook. `onPublishError` records direct publisher failures without changing the
|
|
3627
|
+
already committed run.
|
|
3628
|
+
|
|
3616
3629
|
A named custom stop condition terminalizes with `policy_stop`; its `policyName`
|
|
3617
3630
|
is persisted on the run and included in the terminal event/result. `max-steps`
|
|
3618
3631
|
is the reserved built-in policy name. `loop.prepareStep` is the controlled AI
|
|
@@ -3643,6 +3656,14 @@ effect must be replay-safe.
|
|
|
3643
3656
|
`projectAgentHistory` converts canonical engine records into provider-valid AI
|
|
3644
3657
|
SDK messages and pairs tool calls/results. Provider-required metadata is kept
|
|
3645
3658
|
in a versioned opaque envelope and omitted from product delivery by default.
|
|
3659
|
+
`projectAgentHistoryDetailed` additionally returns one inspectable decision per canonical record;
|
|
3660
|
+
leading assistant records, crash drafts and unmatched tool chronology are never silently passed to
|
|
3661
|
+
the provider.
|
|
3662
|
+
|
|
3663
|
+
`selectAgentHistory` is the non-destructive context-window selector. It removes only whole oldest
|
|
3664
|
+
complete turns, protects system/summary, incomplete and configured recent turns, and reports every
|
|
3665
|
+
keep/remove reason with measured/estimated/unavailable token provenance. An oversized protected turn
|
|
3666
|
+
returns `oversized`; unavailable accounting returns `unavailable` without invented arithmetic.
|
|
3646
3667
|
|
|
3647
3668
|
`ComposedAgentPrompt.instructions` accepts the AI SDK `Instructions` contract.
|
|
3648
3669
|
Use `adaptInstructions` when a provider needs metadata on the system message:
|
|
@@ -3679,22 +3700,32 @@ provider system message. The consumer supplies the structured summary schema
|
|
|
3679
3700
|
and prompt. Pass `previousSummary` for a direct call, or configure
|
|
3680
3701
|
`readPreviousSummary` for runtime-managed compaction, to merge and atomically
|
|
3681
3702
|
replace a leading summary on the next compaction.
|
|
3703
|
+
Set `maxAttempts` to allow bounded conflict recovery. Every retry reloads the snapshot, reselects the
|
|
3704
|
+
eligible range and recomputes the summary; the stale summary is never retried.
|
|
3682
3705
|
|
|
3683
3706
|
## Observability
|
|
3684
3707
|
|
|
3685
3708
|
`createAgentObservability` emits a separate operator-only `AgentRunEvent`. It
|
|
3686
3709
|
reuses the same bounded sink lifecycle as request/tool observability without
|
|
3687
3710
|
sending new event kinds to existing request sinks. Product events omit provider
|
|
3688
|
-
causes
|
|
3689
|
-
|
|
3711
|
+
causes. Operator `internalCause` is also redacted by default; an operator-only sink must explicitly
|
|
3712
|
+
set `includeInternalCause` and own its retention policy.
|
|
3690
3713
|
|
|
3691
3714
|
Usage values carry `provider-reported`, `computed`, `estimated` or
|
|
3692
3715
|
`unavailable` provenance. Cost additionally carries an ISO currency code;
|
|
3693
3716
|
OpenRouter-reported cost is normalized as USD. Missing values remain absent,
|
|
3694
3717
|
never zero-filled.
|
|
3695
3718
|
|
|
3696
|
-
|
|
3697
|
-
|
|
3719
|
+
The sink deduplicates stable event IDs by default. Cross-crash exactly-once still requires a durable
|
|
3720
|
+
outbox.
|
|
3721
|
+
|
|
3722
|
+
## Deterministic race and adapter proof
|
|
3723
|
+
|
|
3724
|
+
`stitchkit/testing` exports `createAgentRaceBarrier`, `createAgentRaceDriver` and
|
|
3725
|
+
`createAgentRaceTrace`. Barriers have bounded teardown, traces assert exact partial order, and the
|
|
3726
|
+
helpers are exercised from packed Bun and Node consumers. `runAgentStoreConformance` runs duplicate,
|
|
3727
|
+
coalescing, collision, stale checkpoint, replay safety, terminal race, compaction and recovery
|
|
3728
|
+
invariants against any fresh durable adapter.
|
|
3698
3729
|
|
|
3699
3730
|
|
|
3700
3731
|
==============================================================================
|
|
@@ -8036,6 +8067,70 @@ Server-only optional application runtime. See the
|
|
|
8036
8067
|
| `AgentRuntimeEventSchema` | schema | transient stream lifecycle plus post-commit admission/checkpoint/run-state/terminal projections |
|
|
8037
8068
|
| `createAgentObservability` | function | separate agent-run sink over the shared bounded observability lifecycle |
|
|
8038
8069
|
|
|
8070
|
+
### Complete runtime inventory
|
|
8071
|
+
|
|
8072
|
+
The entrypoint deliberately exports the schemas beside their inferred types so persistence and
|
|
8073
|
+
transport adapters validate the same records. Runtime composition types are `AgentRuntime`,
|
|
8074
|
+
`AgentRuntimeConfig`, `AgentRuntimeInput`, `AgentRuntimeProtocolInput`, `AgentRuntimeRunContext`,
|
|
8075
|
+
`AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeRecoveryInput`,
|
|
8076
|
+
`AgentRuntimeRecoveryDecision`, `AgentRuntimeRecoveryOutcome`, `AgentRuntimePublisher`,
|
|
8077
|
+
`AgentInputPolicy`, `AgentStopReason`, `AgentCoordinatedRun`, `AgentRunTicket`,
|
|
8078
|
+
`AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult` and
|
|
8079
|
+
`StructuredCompactionConfig`.
|
|
8080
|
+
|
|
8081
|
+
Canonical protocol exports are `AgentProtocol`, `AgentProtocolConfig`, `AgentRecordIdSchema`, `AgentRecordVersionSchema`,
|
|
8082
|
+
`AgentTimestampSchema`, `AgentJsonObjectSchema`, `AgentProviderEnvelopeSchema`,
|
|
8083
|
+
`AgentProviderEnvelope`, `AgentMessagePartSchema`, `AgentMessagePart`, `AgentTextPartSchema`,
|
|
8084
|
+
`AgentReasoningPartSchema`, `AgentFilePartSchema`, `AgentSourcePartSchema`,
|
|
8085
|
+
`AgentToolCallPartSchema`, `AgentToolResultPartSchema`, `AgentOpaquePartSchema`,
|
|
8086
|
+
`AgentControlPartSchema`, `AgentMessageRoleSchema`, `AgentMessageStatusSchema`, `AgentMessage`,
|
|
8087
|
+
`AgentAssistantPlaceholderSchema`, `AgentAssistantPlaceholder`, `AgentRunStateSchema`,
|
|
8088
|
+
`AgentTerminalReasonSchema`, `AgentTerminalReason`, `AgentRun`, `AgentSnapshot`,
|
|
8089
|
+
`AgentUsageValueSchema`, `AgentCostValueSchema`, `AgentUsageSchema`, `AgentUsage` and
|
|
8090
|
+
`AgentRunMetrics`.
|
|
8091
|
+
|
|
8092
|
+
Store command/result exports are `AcceptInputAndAssignRun`, `AcceptInputAndAssignRunSchema`,
|
|
8093
|
+
`AcquireAgentRun`, `AcquireAgentRunSchema`, `CheckpointRunAssistant`,
|
|
8094
|
+
`CheckpointRunAssistantSchema`, `CommitRunTerminal`, `CommitRunTerminalSchema`,
|
|
8095
|
+
`RequestRunInterrupt`, `RequestRunInterruptSchema`, `RecoverAgentRun`, `ReplaceCompactedRange`,
|
|
8096
|
+
`ReplaceCompactedRangeSchema`, `AgentStoreMutationResult`, `AgentStoreMutationResultSchema`,
|
|
8097
|
+
`AgentStoreAppliedSchema`, `AgentStoreConflictSchema`, `AgentStoreDuplicateSchema`,
|
|
8098
|
+
`AgentStoreNotFoundSchema`, `AgentAdmissionIdentity`, `AgentAdmissionIdentitySchema`,
|
|
8099
|
+
`AgentStoredState`, `AgentStoreCompareAndSwapResult`, `AgentHistoryMutation`,
|
|
8100
|
+
`AgentRecoverableDescriptor`, `AgentRecoverableDescriptorSchema`, `AgentRecoverablePage` and
|
|
8101
|
+
`AgentRecoverablePageSchema`.
|
|
8102
|
+
|
|
8103
|
+
History and context-budget exports are `projectAgentHistoryDetailed`,
|
|
8104
|
+
`AgentHistoryProjectionDecision`, `AgentHistoryProjectionResult`, `selectAgentHistory`,
|
|
8105
|
+
`SelectAgentHistoryOptions`, `AgentHistoryBudgetDecision`, `AgentHistoryBudgetResult`,
|
|
8106
|
+
`AgentPromptBudget`, `AgentPromptSection`, `AgentPromptSectionContext`, `AgentTokenCount`,
|
|
8107
|
+
`AgentTokenCountSchema`, `ComposeAgentPromptOptions` and `ComposedAgentPrompt`. Whole-turn history
|
|
8108
|
+
selection never splits a tool chronology and reports why every canonical record was retained or
|
|
8109
|
+
removed.
|
|
8110
|
+
|
|
8111
|
+
Model exports are `AgentLanguageModelProvider`, `AgentModelCapability`,
|
|
8112
|
+
`AgentModelCapabilitySchema`, `AgentModelDeclaration`, `AgentModelDescriptor`,
|
|
8113
|
+
`AgentModelDescriptorSchema`, `AgentModelRegistry`, `AgentModelRegistryConfig`,
|
|
8114
|
+
`AgentModelRegistrySnapshot`, `AgentModelRegistrySnapshotSchema`, `AgentModelSnapshotPolicy`,
|
|
8115
|
+
`AgentResolvedModel` and `validateAgentModelSnapshot`. Registry `preflight` validates availability,
|
|
8116
|
+
provider and required capabilities without constructing the model; runtime `models.preflight`
|
|
8117
|
+
runs before durable admission.
|
|
8118
|
+
|
|
8119
|
+
Delivery exports are `AgentAdmissionEventSchema`, `AgentCheckpointEventSchema`,
|
|
8120
|
+
`AgentRunStateEventSchema`, `AgentTerminalEventSchema`, `AgentTransientDeltaEventSchema`,
|
|
8121
|
+
`AgentReasoningStartEventSchema`, `AgentReasoningDeltaEventSchema`,
|
|
8122
|
+
`AgentReasoningEndEventSchema`, `AgentToolStatusEventSchema`, `AgentRuntimeEvent`,
|
|
8123
|
+
`AgentRuntimeEventCursor`, `AgentRuntimeEventCursorSchema`, `AgentRuntimeCursorAdvance`,
|
|
8124
|
+
`advanceAgentRuntimeEventCursor`, `agentDurableEventId`, `AgentRuntimeEventSink`,
|
|
8125
|
+
`AgentRuntimeEventSinkConfig` and `createAgentRuntimeEventSink`. Cursor gaps require a canonical
|
|
8126
|
+
snapshot reload; the bounded sink isolates transport failure and supports a typed projection step.
|
|
8127
|
+
|
|
8128
|
+
Managed effects and operator telemetry additionally export `AgentToolFenceConfig`,
|
|
8129
|
+
`AgentToolFenceContext`, `AgentObservability`, `AgentRunEvent`, `AgentRunEventSchema`,
|
|
8130
|
+
`AgentRunSinkConfig`, `AgentRunSinkDrop` and `AgentRunSinkError`. A monotonic run `fencingToken`
|
|
8131
|
+
may accompany checkpoint/terminal writes and tool context; internal causes are redacted unless an
|
|
8132
|
+
operator-only observability sink explicitly opts in.
|
|
8133
|
+
|
|
8039
8134
|
## `stitchkit/agent-runtime/openrouter`
|
|
8040
8135
|
|
|
8041
8136
|
| Export | Kind | Summary |
|
|
@@ -8373,6 +8468,8 @@ handler pipeline without opening a TCP port.
|
|
|
8373
8468
|
| `createHandlerTestClients` | function | exact contract-registry batch form |
|
|
8374
8469
|
| `runAgentStoreConformance` | function | reusable black-box duplicate/coalescing/stale/recovery contract for durable agent-store adapters |
|
|
8375
8470
|
| `AgentStoreConformanceConfig` | _type_ | factory configuration for running the same contract against a fresh adapter |
|
|
8471
|
+
| `createAgentRaceBarrier` / `createAgentRaceDriver` / `createAgentRaceTrace` | function | bounded named barriers and exact partial-order traces for deterministic runtime race probes |
|
|
8472
|
+
| `AgentRaceBarrier` / `AgentRaceDriver` / `AgentRaceTrace` / `AgentRaceTraceEntry` | _type_ | public packed-consumer types for the deterministic race harness |
|
|
8376
8473
|
| `HandlerTestClientDefaults` | _type_ | ordinary bare-client defaults with handler-owned `baseUrl` and `fetch` removed |
|
|
8377
8474
|
| `HandlerTestClientConfig` | _type_ | handler, contract, path prefix, scoped config and client request defaults |
|
|
8378
8475
|
| `HandlerTestClientsConfig` | _type_ | batch helper configuration |
|
package/package.json
CHANGED