stitchkit 0.68.4 → 0.68.6
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/README.md +4 -1
- package/dist/agent-runtime/coordinator.d.ts +5 -2
- package/dist/agent-runtime/coordinator.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +1349 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -0
- package/dist/agent-runtime/events.d.ts +2 -1347
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +2 -0
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +2 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +12 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +12 -0
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +37 -6
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +2 -0
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime-browser.d.ts +4 -0
- package/dist/agent-runtime-browser.d.ts.map +1 -0
- package/dist/agent-runtime-browser.js +424 -0
- package/dist/agent-runtime.js +169 -93
- package/dist/browser/cancellation.d.ts.map +1 -1
- package/dist/{index-thcy3w8c.js → index-n34x0q5e.js} +6 -6
- package/dist/{index-fhsmrzj7.js → index-ysphyxax.js} +4 -1
- package/dist/index.js +6 -6
- package/dist/remote.js +1 -1
- package/dist/testing/agent-store-conformance.d.ts.map +1 -1
- package/dist/testing.js +117 -6
- package/llms-full.txt +71 -10
- package/package.json +6 -2
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentMessageSchema,
|
|
3
3
|
AgentRunSchema
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-ysphyxax.js";
|
|
5
5
|
import {
|
|
6
6
|
createApplication
|
|
7
7
|
} from "./index-6wzr93cg.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
import {
|
|
26
26
|
createClient,
|
|
27
27
|
createClients
|
|
28
|
-
} from "./index-
|
|
28
|
+
} from "./index-n34x0q5e.js";
|
|
29
29
|
import"./index-r5s4wqb5.js";
|
|
30
30
|
import {
|
|
31
31
|
joinRoutePath
|
|
@@ -145,7 +145,14 @@ function requireOutcome(actual, expected) {
|
|
|
145
145
|
async function runAgentStoreConformance(config) {
|
|
146
146
|
const run = `conformance-${crypto.randomUUID()}`;
|
|
147
147
|
const context = {
|
|
148
|
-
conversationIds: [
|
|
148
|
+
conversationIds: [
|
|
149
|
+
run,
|
|
150
|
+
`${run}-recovery`,
|
|
151
|
+
`${run}-absorb`,
|
|
152
|
+
`${run}-causal-history`,
|
|
153
|
+
`${run}-causal-active`,
|
|
154
|
+
`${run}-interrupt-priority`
|
|
155
|
+
]
|
|
149
156
|
};
|
|
150
157
|
const store = await config.createStore(context);
|
|
151
158
|
let failure;
|
|
@@ -169,10 +176,12 @@ async function conformanceScenario(store, conversationIds) {
|
|
|
169
176
|
conversationId,
|
|
170
177
|
recoveryConversationId,
|
|
171
178
|
absorbConversationId,
|
|
172
|
-
causalHistoryConversationId
|
|
179
|
+
causalHistoryConversationId,
|
|
180
|
+
causalActiveConversationId,
|
|
181
|
+
interruptPriorityConversationId
|
|
173
182
|
] = conversationIds;
|
|
174
|
-
if (!conversationId || !recoveryConversationId || !absorbConversationId || !causalHistoryConversationId) {
|
|
175
|
-
throw new Error("Agent store conformance requires
|
|
183
|
+
if (!conversationId || !recoveryConversationId || !absorbConversationId || !causalHistoryConversationId || !causalActiveConversationId || !interruptPriorityConversationId) {
|
|
184
|
+
throw new Error("Agent store conformance requires six conversation identities");
|
|
176
185
|
}
|
|
177
186
|
const absentConversationId = `${conversationId}-absent`;
|
|
178
187
|
const firstInput = userMessage(conversationId, "input-1");
|
|
@@ -554,8 +563,110 @@ async function conformanceScenario(store, conversationIds) {
|
|
|
554
563
|
throw new Error("Abandon recovery did not atomically terminalize its assistant record");
|
|
555
564
|
}
|
|
556
565
|
await assertCausalHistoryOrder(store, causalHistoryConversationId);
|
|
566
|
+
await assertActiveRunCausalOrder(store, causalActiveConversationId);
|
|
567
|
+
await assertInterruptPriorityOrder(store, interruptPriorityConversationId);
|
|
557
568
|
await assertAbsorptionIsAtomic(store, absorbConversationId);
|
|
558
569
|
}
|
|
570
|
+
async function assertInterruptPriorityOrder(store, conversationId) {
|
|
571
|
+
const inputs = ["priority-a", "priority-b", "priority-c"].map((id) => userMessage(conversationId, id));
|
|
572
|
+
const [inputA, inputB, inputC] = inputs;
|
|
573
|
+
if (!inputA || !inputB || !inputC)
|
|
574
|
+
throw new Error("Priority fixture is incomplete");
|
|
575
|
+
const runA = queuedRun(conversationId, inputA.id, "priority-run-a");
|
|
576
|
+
const runB = queuedRun(conversationId, inputB.id, "priority-run-b");
|
|
577
|
+
const runC = AgentRunSchema.parse({
|
|
578
|
+
...queuedRun(conversationId, inputC.id, "priority-run-c"),
|
|
579
|
+
queuePriority: "interrupt-next"
|
|
580
|
+
});
|
|
581
|
+
requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runA.id, input: inputA, run: runA }), "applied");
|
|
582
|
+
const acquiredA = await store.acquireRun({
|
|
583
|
+
conversationId,
|
|
584
|
+
runId: runA.id,
|
|
585
|
+
expectedRevision: runA.revision,
|
|
586
|
+
ownerId: "priority-owner-a"
|
|
587
|
+
});
|
|
588
|
+
requireOutcome(acquiredA, "applied");
|
|
589
|
+
const runningA = acquiredA.snapshot.runs.find((run) => run.id === runA.id);
|
|
590
|
+
if (!runningA)
|
|
591
|
+
throw new Error("Priority lead run disappeared after acquisition");
|
|
592
|
+
requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runB.id, input: inputB, run: runB }), "applied");
|
|
593
|
+
requireOutcome(await store.acceptInputAndAssignRun({ idempotencyKey: runC.id, input: inputC, run: runC }), "applied");
|
|
594
|
+
const active = await store.listActiveRuns(conversationId);
|
|
595
|
+
if (active.map((run) => run.id).join(",") !== `${runA.id},${runC.id},${runB.id}`) {
|
|
596
|
+
throw new Error("Active runs did not place urgent work before ordinary pending work");
|
|
597
|
+
}
|
|
598
|
+
requireOutcome(await store.acquireRun({
|
|
599
|
+
conversationId,
|
|
600
|
+
runId: runB.id,
|
|
601
|
+
expectedRevision: runB.revision,
|
|
602
|
+
ownerId: "priority-owner-b"
|
|
603
|
+
}), "conflict");
|
|
604
|
+
const abandonedA = await store.recoverRun({
|
|
605
|
+
conversationId,
|
|
606
|
+
runId: runA.id,
|
|
607
|
+
expectedRevision: runningA.revision,
|
|
608
|
+
action: "abandon"
|
|
609
|
+
});
|
|
610
|
+
requireOutcome(abandonedA, "applied");
|
|
611
|
+
const queuedC = abandonedA.snapshot.runs.find((run) => run.id === runC.id);
|
|
612
|
+
if (!queuedC)
|
|
613
|
+
throw new Error("Urgent run disappeared after predecessor settlement");
|
|
614
|
+
const acquiredC = await store.acquireRun({
|
|
615
|
+
conversationId,
|
|
616
|
+
runId: runC.id,
|
|
617
|
+
expectedRevision: queuedC.revision,
|
|
618
|
+
ownerId: "priority-owner-c"
|
|
619
|
+
});
|
|
620
|
+
requireOutcome(acquiredC, "applied");
|
|
621
|
+
const runningC = acquiredC.snapshot.runs.find((run) => run.id === runC.id);
|
|
622
|
+
if (!runningC)
|
|
623
|
+
throw new Error("Urgent run disappeared after acquisition");
|
|
624
|
+
requireOutcome(await store.acquireRun({
|
|
625
|
+
conversationId,
|
|
626
|
+
runId: runB.id,
|
|
627
|
+
expectedRevision: runB.revision,
|
|
628
|
+
ownerId: "priority-owner-b"
|
|
629
|
+
}), "conflict");
|
|
630
|
+
const abandonedC = await store.recoverRun({
|
|
631
|
+
conversationId,
|
|
632
|
+
runId: runC.id,
|
|
633
|
+
expectedRevision: runningC.revision,
|
|
634
|
+
action: "abandon"
|
|
635
|
+
});
|
|
636
|
+
requireOutcome(abandonedC, "applied");
|
|
637
|
+
const queuedB = abandonedC.snapshot.runs.find((run) => run.id === runB.id);
|
|
638
|
+
if (!queuedB)
|
|
639
|
+
throw new Error("Ordinary run disappeared after urgent settlement");
|
|
640
|
+
const acquiredB = await store.acquireRun({
|
|
641
|
+
conversationId,
|
|
642
|
+
runId: runB.id,
|
|
643
|
+
expectedRevision: queuedB.revision,
|
|
644
|
+
ownerId: "priority-owner-b"
|
|
645
|
+
});
|
|
646
|
+
requireOutcome(acquiredB, "applied");
|
|
647
|
+
const ordered = acquiredB.snapshot.runs.map((run) => run.id).join(",");
|
|
648
|
+
if (ordered !== `${runA.id},${runC.id},${runB.id}`) {
|
|
649
|
+
throw new Error(`Durable execution order was not preserved: ${ordered}`);
|
|
650
|
+
}
|
|
651
|
+
const [sequenceA, sequenceC, sequenceB] = acquiredB.snapshot.runs.map((run) => run.executionSequence);
|
|
652
|
+
if (sequenceA === undefined || sequenceC === undefined || sequenceB === undefined || !(sequenceA < sequenceC && sequenceC < sequenceB)) {
|
|
653
|
+
throw new Error("Acquisition did not persist increasing execution sequence values");
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
async function assertActiveRunCausalOrder(store, conversationId) {
|
|
657
|
+
for (const id of ["z-causal-run", "a-causal-run"]) {
|
|
658
|
+
const input = userMessage(conversationId, `${id}-input`);
|
|
659
|
+
requireOutcome(await store.acceptInputAndAssignRun({
|
|
660
|
+
idempotencyKey: id,
|
|
661
|
+
input,
|
|
662
|
+
run: queuedRun(conversationId, input.id, id)
|
|
663
|
+
}), "applied");
|
|
664
|
+
}
|
|
665
|
+
const active = await store.listActiveRuns(conversationId);
|
|
666
|
+
if (active.map((run) => run.id).join(",") !== "z-causal-run,a-causal-run") {
|
|
667
|
+
throw new Error("listActiveRuns must preserve causal history order for timestamp ties");
|
|
668
|
+
}
|
|
669
|
+
}
|
|
559
670
|
async function assertCausalHistoryOrder(store, conversationId) {
|
|
560
671
|
const leadInput = userMessage(conversationId, "causal-input-1");
|
|
561
672
|
const leadRun = queuedRun(conversationId, leadInput.id, "causal-run-1");
|
package/llms-full.txt
CHANGED
|
@@ -61,6 +61,7 @@ own, recorded as an ADR.
|
|
|
61
61
|
| `stitchkit/react` | browser | stable | `createCursorQuery`, `createCacheBridge` |
|
|
62
62
|
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 9 of the 13 minors since 0.56.2, most recently 0.66.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
|
|
63
63
|
| `stitchkit/agent-runtime/openrouter` | server | evolving | isolated OpenRouter language-model adapter |
|
|
64
|
+
| `stitchkit/agent-runtime/browser` | browser + server | evolving | canonical agent records, events and reconnect cursor without execution or sinks |
|
|
64
65
|
| `stitchkit/application` | server | evolving<br>_redefined in 3 of the 13 minors since 0.56.2, most recently 0.67.0_ | managed resource graph, readiness, admission, schedules and bounded shutdown |
|
|
65
66
|
| `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
|
|
66
67
|
| `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
|
|
@@ -2428,6 +2429,13 @@ wire `end` frame and, when declared, at least one matching terminal item; EOF is
|
|
|
2428
2429
|
converge on the request operation. See the
|
|
2429
2430
|
[server half](./server.md#contract-first-streams). → ADR 0117.
|
|
2430
2431
|
|
|
2432
|
+
The request deadline bounds the wait for response headers. Once headers arrive,
|
|
2433
|
+
that timer is cleared, while the caller signal remains attached to the response
|
|
2434
|
+
body until it ends or is cancelled. This is the same for a Fetch-config client,
|
|
2435
|
+
`createHttpClient`, the Bun-only `unix` convenience and an injected portable
|
|
2436
|
+
Unix transport. Cancelling a quiet stream therefore releases its server source
|
|
2437
|
+
and transport connection instead of only settling the local iterator.
|
|
2438
|
+
|
|
2431
2439
|
An established NDJSON protocol may keep its item schema as the complete wire
|
|
2432
2440
|
frame. This mode requires a terminal item because an unwrapped response has no
|
|
2433
2441
|
separate safe error/end envelope:
|
|
@@ -3742,6 +3750,21 @@ If the application already owns that loop, continue importing `mountAgent` from
|
|
|
3742
3750
|
this entrypoint uses the tool executor from it, but pulls no MCP peer, so
|
|
3743
3751
|
choosing `mountAgent` alone costs you nothing from here.
|
|
3744
3752
|
|
|
3753
|
+
UI and shared DTO code must import canonical records and delivery validation from
|
|
3754
|
+
`stitchkit/agent-runtime/browser`, not from the server runtime barrel:
|
|
3755
|
+
|
|
3756
|
+
```ts
|
|
3757
|
+
import {
|
|
3758
|
+
AgentRunSchema,
|
|
3759
|
+
AgentRuntimeEventSchema,
|
|
3760
|
+
advanceAgentRuntimeEventCursor,
|
|
3761
|
+
} from 'stitchkit/agent-runtime/browser'
|
|
3762
|
+
```
|
|
3763
|
+
|
|
3764
|
+
This browser-safe entrypoint re-exports the same schemas and inferred types used
|
|
3765
|
+
by the runtime. It intentionally excludes model construction, execution,
|
|
3766
|
+
persistence, event sinks and every Node context dependency.
|
|
3767
|
+
|
|
3745
3768
|
## Install
|
|
3746
3769
|
|
|
3747
3770
|
```sh
|
|
@@ -3941,15 +3964,22 @@ input + queued run → running → execution settled → terminal CAS → succes
|
|
|
3941
3964
|
|
|
3942
3965
|
## What happens to a run when new input arrives
|
|
3943
3966
|
|
|
3944
|
-
`runs.inputPolicy` decides. It takes
|
|
3967
|
+
`runs.inputPolicy` decides. It takes five values, or a function returning one:
|
|
3945
3968
|
|
|
3946
3969
|
| policy | the run in flight | what it already produced |
|
|
3947
3970
|
|--------|-------------------|--------------------------|
|
|
3948
3971
|
| `queue` (default) | finishes first | kept |
|
|
3949
3972
|
| `inject` | continues, and answers the new input too | kept, and built on |
|
|
3950
3973
|
| `interrupt` | ends | kept, and marked as cut off |
|
|
3974
|
+
| `interrupt-next` | ends; this input runs before ordinary queued work | kept, and marked as cut off |
|
|
3951
3975
|
| `supersede` | ends | discarded from the prompt, kept in the record |
|
|
3952
3976
|
|
|
3977
|
+
`interrupt-next` is the explicit priority path for an urgent input. If A is
|
|
3978
|
+
running, ordinary B is queued, and urgent C arrives, the coordinator aborts A,
|
|
3979
|
+
waits for A to settle and then runs C before B. B keeps its durable identity and
|
|
3980
|
+
eventually runs. Urgent inputs remain FIFO among themselves. They do not
|
|
3981
|
+
coalesce into an ordinary pending run: that would erase the priority boundary.
|
|
3982
|
+
|
|
3953
3983
|
`interrupt` and `supersede` differ in exactly one thing, and the question that
|
|
3954
3984
|
picks between them is **not** "was the run interrupted" but **"did anyone see
|
|
3955
3985
|
what it produced"**:
|
|
@@ -4190,12 +4220,20 @@ checkpoint/terminal CAS and tool context, so a distributed adapter can reject an
|
|
|
4190
4220
|
an owner label is reused. Lease expiry and renewal remain application-owned.
|
|
4191
4221
|
|
|
4192
4222
|
On startup, `runtime.recover({ resolveContext })` consumes bounded lightweight
|
|
4193
|
-
pages
|
|
4223
|
+
pages, then restores each conversation's durable execution order before any run
|
|
4224
|
+
acquires. Persisted `executionSequence` orders work that started; queued
|
|
4225
|
+
`interrupt-next` work precedes ordinary queued work with FIFO preserved inside
|
|
4226
|
+
each class. Scan identifiers, equal timestamps and page boundaries therefore
|
|
4227
|
+
never become queue order. Its safe default resumes queued runs and reports acquired or
|
|
4194
4228
|
`interrupt_requested` runs as skipped. A policy may requeue acquired work only
|
|
4195
4229
|
with explicit replay-safe evidence, or abandon it only with stale-owner
|
|
4196
|
-
evidence. Each attempted run returns its own outcome/error; `
|
|
4197
|
-
`
|
|
4198
|
-
|
|
4230
|
+
evidence. Each attempted run returns its own outcome/error; a `resumed` or
|
|
4231
|
+
`requeued` outcome also exposes the terminal `result` promise. The outcome is
|
|
4232
|
+
reported only after durable acquisition, so a lost acquisition is `failed`
|
|
4233
|
+
rather than a successful-looking handoff. `pageSize`, `maxRuns`, and `signal`
|
|
4234
|
+
bound the pass. `runtime.resume(...)` remains available for one known queued
|
|
4235
|
+
record; its `accepted` promise likewise means that the recovered run acquired
|
|
4236
|
+
durable ownership, while `result` carries terminal completion.
|
|
4199
4237
|
|
|
4200
4238
|
Canonical records currently write `schemaVersion: 1`. A durable adapter owns
|
|
4201
4239
|
read-time migration of older rows: migrate to the current shape at its storage
|
|
@@ -4470,7 +4508,8 @@ outbox.
|
|
|
4470
4508
|
`createAgentRaceTrace`. Barriers have bounded teardown, traces assert exact partial order, and the
|
|
4471
4509
|
helpers are exercised from packed Bun and Node consumers. `runAgentStoreConformance` runs duplicate,
|
|
4472
4510
|
coalescing, collision, stale checkpoint, replay safety, terminal race, absorption, bounded reads,
|
|
4473
|
-
causal queued-history order, compaction and recovery invariants against
|
|
4511
|
+
causal queued-history order, durable interrupt priority, compaction and recovery invariants against
|
|
4512
|
+
any fresh durable adapter.
|
|
4474
4513
|
|
|
4475
4514
|
It picks its conversation identities itself and passes them to `createStore(context)` **before the
|
|
4476
4515
|
first mutation**, so an adapter whose runtime rows reference an application-owned conversation row
|
|
@@ -11495,6 +11534,7 @@ Server-only optional application runtime. See the
|
|
|
11495
11534
|
| `defineAgentProtocol` | function | declare context, input metadata, canonical parts and optional pre-CAS terminal acceptance (`allow-empty`, `require-output` or callback) |
|
|
11496
11535
|
| `hasAgentTerminalOutput` | function | generic `require-output` predicate for non-blank text, generated files, structured provider parts and explicit tool-only policy stops |
|
|
11497
11536
|
| `AgentMessageSchema` / `AgentRunSchema` / `AgentSnapshotSchema` | schema | versioned canonical engine records |
|
|
11537
|
+
| `AgentRunQueuePrioritySchema` | schema | durable opt-in priority for queued `interrupt-next` runs |
|
|
11498
11538
|
| `AgentRuntimeStore` | _type_ | aggregate CAS transaction boundary for message, run and compaction mutations |
|
|
11499
11539
|
| `createAgentRuntimeStore` | function | build the aggregate store from one coherent transaction driver; framework owns every state transition |
|
|
11500
11540
|
| `AgentRuntimeStoreDriver` | _type_ | ORM-neutral transaction over a bounded head, normalized runs/admissions, product history and indexed run recovery |
|
|
@@ -11516,7 +11556,7 @@ Server-only optional application runtime. See the
|
|
|
11516
11556
|
| `AgentRuntimeAdmission` | _type_ | canonical committed input, assigned run, pending assistant projection, compatibility IDs and snapshot version |
|
|
11517
11557
|
| `AgentAdmissionEventSchema` | schema | post-commit admission projection; removes store rereads but does not imply exactly-once delivery |
|
|
11518
11558
|
| `AgentRunMetricsSchema` | schema | optional provenance-aware usage and timings; `partial` says the provider never reported the run finished, so the figure beside it is not a confirmed total |
|
|
11519
|
-
| `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with context resolver and explicit evidence policy |
|
|
11559
|
+
| `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
|
|
11520
11560
|
| `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
|
|
11521
11561
|
| `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
|
|
11522
11562
|
| `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
|
|
@@ -11544,7 +11584,8 @@ Canonical protocol exports are `AgentProtocol`, `AgentProtocolConfig`, `AgentTer
|
|
|
11544
11584
|
`AgentToolCallPartSchema`, `AgentToolResultPartSchema`, `AgentOpaquePartSchema`,
|
|
11545
11585
|
`AgentControlPartSchema`, `AgentMessageRoleSchema`, `AgentMessageStatusSchema`, `AgentMessage`,
|
|
11546
11586
|
`AgentAssistantPlaceholderSchema`, `AgentAssistantPlaceholder`, `AgentRunStateSchema`,
|
|
11547
|
-
`AgentTerminalReasonSchema`, `AgentTerminalReason`, `
|
|
11587
|
+
`AgentTerminalReasonSchema`, `AgentTerminalReason`, `AgentRunQueuePrioritySchema`,
|
|
11588
|
+
`AgentRunQueuePriority`, `AgentRun`, `AgentSnapshot`,
|
|
11548
11589
|
`AgentUsageValueSchema`, `AgentCostValueSchema`, `AgentUsageSchema`, `AgentUsage` and
|
|
11549
11590
|
`AgentRunMetrics`.
|
|
11550
11591
|
|
|
@@ -11560,7 +11601,7 @@ integer — `AgentUsageValueSchema` and `AgentTokenCountSchema` refuse a fractio
|
|
|
11560
11601
|
provider figure that is not a whole number is normalised to `unavailable` rather than thrown.
|
|
11561
11602
|
`AgentCostValueSchema.value` stays fractional, because money is.
|
|
11562
11603
|
|
|
11563
|
-
`runs.inputPolicy` takes `queue` (default), `inject`, `interrupt` or `supersede`, or a function of
|
|
11604
|
+
`runs.inputPolicy` takes `queue` (default), `inject`, `interrupt`, `interrupt-next` or `supersede`, or a function of
|
|
11564
11605
|
the raw input returning one. `inject` lets a run in flight take a newly arrived input into its prompt
|
|
11565
11606
|
at a step boundary and answer it too; the absorption is committed in the **same transaction** as that
|
|
11566
11607
|
run's terminal record, via `CommitRunTerminal.absorb`, so a run that ends any other way leaves an
|
|
@@ -11569,6 +11610,12 @@ ordinary queued successor. The absorbed run ends with `terminalReason: 'absorbed
|
|
|
11569
11610
|
its own**; a submission on its idempotency key resolves through that pointer to the answer
|
|
11570
11611
|
(→ ADR 0113).
|
|
11571
11612
|
|
|
11613
|
+
`interrupt-next` interrupts the active run, waits for its real settlement and then executes the new
|
|
11614
|
+
input before ordinary pending work. Ordinary work is not dropped or re-admitted, and urgent work is
|
|
11615
|
+
FIFO within its own class. `AgentRun.queuePriority` persists the pending class;
|
|
11616
|
+
`AgentRun.executionSequence` persists the actual first-acquisition order, so recovery and canonical
|
|
11617
|
+
history preserve the same `A → C → B` order across equal timestamps and scan pages (→ ADR 0127).
|
|
11618
|
+
|
|
11572
11619
|
With `queue`, a durable successor admission is not prompt eligibility: the current executor sees
|
|
11573
11620
|
only records through its own run boundary. Snapshot history is normalized to causal turn order
|
|
11574
11621
|
(assigned input(s), assistant, then successor input(s)) even when the storage codec physically
|
|
@@ -11577,7 +11624,7 @@ appended the successor before the predecessor checkpoint.
|
|
|
11577
11624
|
`AgentRuntimeStore` has two **bounded** reads beside `loadSnapshot`:
|
|
11578
11625
|
`loadRun({ conversationId, runId })` returns an `AgentRunView` — the run, the conversation version it
|
|
11579
11626
|
was read at, and the retained answer once the run is terminal — or `undefined`; `listActiveRuns(conversationId)`
|
|
11580
|
-
returns the runs that have not ended
|
|
11627
|
+
returns the runs that have not ended in durable execution/priority order. Neither reads history, so
|
|
11581
11628
|
neither grows with the length of the conversation, and neither needs anything new from
|
|
11582
11629
|
`AgentRuntimeStoreDriver`. `loadSnapshot` and every mutation result still carry the whole
|
|
11583
11630
|
conversation — that is what the store's reducer validates against, and what the runtime builds a
|
|
@@ -11629,6 +11676,20 @@ Managed effects and operator telemetry additionally export `AgentToolFenceConfig
|
|
|
11629
11676
|
may accompany checkpoint/terminal writes and tool context; internal causes are redacted unless an
|
|
11630
11677
|
operator-only observability sink explicitly opts in.
|
|
11631
11678
|
|
|
11679
|
+
## `stitchkit/agent-runtime/browser`
|
|
11680
|
+
|
|
11681
|
+
Browser-safe canonical agent data. It re-exports the run, message, part, usage,
|
|
11682
|
+
terminal and provider-envelope schemas/types listed under
|
|
11683
|
+
`stitchkit/agent-runtime`, together with all runtime delivery event schemas,
|
|
11684
|
+
`AgentRuntimeEventCursorSchema`, `advanceAgentRuntimeEventCursor` and
|
|
11685
|
+
`agentDurableEventId`. It imports no model provider, executor, store, event sink
|
|
11686
|
+
or Node context module.
|
|
11687
|
+
|
|
11688
|
+
Use this entrypoint from client components and shared DTO packages. The full
|
|
11689
|
+
`stitchkit/agent-runtime` entrypoint remains server-only.
|
|
11690
|
+
|
|
11691
|
+
---
|
|
11692
|
+
|
|
11632
11693
|
## `stitchkit/agent-runtime/openrouter`
|
|
11633
11694
|
|
|
11634
11695
|
| Export | Kind | Summary |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stitchkit",
|
|
3
|
-
"version": "0.68.
|
|
3
|
+
"version": "0.68.6",
|
|
4
4
|
"description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -84,6 +84,10 @@
|
|
|
84
84
|
"types": "./dist/agent-runtime.d.ts",
|
|
85
85
|
"import": "./dist/agent-runtime.js"
|
|
86
86
|
},
|
|
87
|
+
"./agent-runtime/browser": {
|
|
88
|
+
"types": "./dist/agent-runtime-browser.d.ts",
|
|
89
|
+
"import": "./dist/agent-runtime-browser.js"
|
|
90
|
+
},
|
|
87
91
|
"./agent-runtime/openrouter": {
|
|
88
92
|
"types": "./dist/agent-runtime-openrouter.d.ts",
|
|
89
93
|
"import": "./dist/agent-runtime-openrouter.js"
|
|
@@ -122,7 +126,7 @@
|
|
|
122
126
|
},
|
|
123
127
|
"scripts": {
|
|
124
128
|
"check": "bun x tsc --noEmit",
|
|
125
|
-
"build:browser": "bun build src/index.ts src/react.ts src/contract/index.ts src/declaration.ts --outdir dist --target node --packages external --splitting --root src",
|
|
129
|
+
"build:browser": "bun build src/index.ts src/react.ts src/contract/index.ts src/declaration.ts src/agent-runtime-browser.ts --outdir dist --target node --packages external --splitting --root src",
|
|
126
130
|
"build:server": "bun build src/server/index.ts src/node.ts src/tools.ts src/tool-invoker.ts src/cli.ts src/remote.ts src/files.ts src/testing.ts src/observability/index.ts src/agent-runtime.ts src/agent-runtime-openrouter.ts src/application.ts src/application-grammy.ts src/application-opentelemetry.ts --outdir dist --target node --packages external --splitting --root src",
|
|
127
131
|
"build:js": "bun run build:browser && bun run build:server && bun scripts/preserve-webpack-ignore.mjs",
|
|
128
132
|
"build:types": "bun x tsc -p tsconfig.build.json --emitDeclarationOnly && bun scripts/rewrite-declaration-specifiers.mjs",
|