stitchkit 0.87.0 → 0.88.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  3. package/dist/agent-runtime/coding-tool-paths.d.ts +1 -1
  4. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  5. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  6. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  7. package/dist/agent-runtime/models.d.ts +14 -0
  8. package/dist/agent-runtime/models.d.ts.map +1 -1
  9. package/dist/agent-runtime/observability.d.ts +8 -0
  10. package/dist/agent-runtime/observability.d.ts.map +1 -1
  11. package/dist/agent-runtime/owned-provider-stream.d.ts +16 -0
  12. package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -0
  13. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  14. package/dist/agent-runtime/runtime-internals.d.ts +12 -0
  15. package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
  16. package/dist/agent-runtime/runtime.d.ts +12 -0
  17. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  18. package/dist/agent-runtime/schemas.d.ts +6 -0
  19. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  20. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  21. package/dist/agent-runtime/store-events.d.ts +2 -0
  22. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  23. package/dist/agent-runtime-browser.js +5 -3
  24. package/dist/agent-runtime-coding-tools.js +27 -16
  25. package/dist/agent-runtime-harness.js +6 -6
  26. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  27. package/dist/agent-runtime-openrouter.js +12 -2
  28. package/dist/agent-runtime-sqlite-bun.js +5 -5
  29. package/dist/agent-runtime-sqlite-node.js +5 -5
  30. package/dist/agent-runtime.d.ts +1 -1
  31. package/dist/agent-runtime.d.ts.map +1 -1
  32. package/dist/agent-runtime.js +11 -8
  33. package/dist/{index-z1m86vc8.js → index-6krwcdcf.js} +2 -1
  34. package/dist/{index-z2452tsw.js → index-bt14acb5.js} +2 -2
  35. package/dist/{index-9553432s.js → index-crykmqkr.js} +1 -1
  36. package/dist/{index-p1b1y93x.js → index-gtj3zc53.js} +5 -1
  37. package/dist/{index-tg3m2ec5.js → index-mqv3b5rh.js} +4 -1
  38. package/dist/{index-35aefxby.js → index-p86mxmpp.js} +123 -7
  39. package/dist/{index-3yrqvza8.js → index-qp3vshvc.js} +7 -7
  40. package/dist/{index-5wezxcxx.js → index-v1qk37y9.js} +2 -2
  41. package/dist/{index-hkm6wysp.js → index-y64k3s0h.js} +1 -1
  42. package/dist/testing.js +14 -3
  43. package/llms-full.txt +90 -12
  44. package/package.json +1 -1
package/llms-full.txt CHANGED
@@ -63,11 +63,11 @@ own, recorded as an ADR.
63
63
  | `stitchkit/tracking/server` | server (Bun or Node) | evolving | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
64
64
  | `stitchkit/release` | browser **and** server | evolving | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
65
65
  | `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
66
- | `stitchkit/observability` | server | stable<br>_redefined in 1 of the 32 minors since 0.56.2, most recently 0.83.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
66
+ | `stitchkit/observability` | server | stable<br>_redefined in 1 of the 33 minors since 0.56.2, most recently 0.83.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
67
67
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, plus the store and managed-resource conformance kits |
68
68
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
69
69
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
70
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 18 of the 32 minors since 0.56.2, most recently 0.87.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
70
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 19 of the 33 minors since 0.56.2, most recently 0.88.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
71
71
  | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults and deterministic race controls |
72
72
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
73
73
  | `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
@@ -76,7 +76,7 @@ own, recorded as an ADR.
76
76
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
77
77
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
78
78
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
79
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 7 of the 32 minors since 0.56.2, most recently 0.83.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
79
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 7 of the 33 minors since 0.56.2, most recently 0.83.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
80
80
  | `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
81
81
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
82
82
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
@@ -4742,6 +4742,11 @@ root and cwd are path boundaries, not a security sandbox: isolate the process wh
4742
4742
  must not access the rest of the machine. Path admission does not constrain `run_command`; an
4743
4743
  executable requires process isolation for that guarantee. → ADR 0172
4744
4744
 
4745
+ An absolute path is still refused. When it is inside the canonical workspace root, the refusal
4746
+ includes the exact workspace-relative `recoveryPath`; an absolute path outside the root has no
4747
+ suggested replacement. Applying the suggestion still passes the same descriptor-relative
4748
+ containment and symlink checks.
4749
+
4745
4750
  `edit_file` replaces one exact snippet. `oldText` is itself the freshness guard for the region it
4746
4751
  changes, so the digest is the optional `expectedSha256` and an edit is one call; pass the digest
4747
4752
  `read_file` returned when you want the whole-file guarantee, and read the `sha256` it returns to
@@ -4765,7 +4770,11 @@ Host-level causes stay scrubbed to `INTERNAL_SERVER_ERROR` and name nothing outs
4765
4770
  `list_directory` marks excluded directories rather than hiding them, and `glob` reports
4766
4771
  `skippedDirectories` beside its matches: an empty result from a tree whose files all live under an
4767
4772
  excluded directory is not "no files", and a model told only "nothing found" concludes the wrong
4768
- thing. `search_files` takes `regex`, `context` lines and an `include` pattern; regex is bounded by
4773
+ thing. `search_files` takes `regex`, `context` lines and an anchored `include` pattern matched
4774
+ against the whole workspace-relative path. `*` does not cross `/`, so files in subdirectories need
4775
+ `**/`; `scannedFiles` counts files admitted by both that filter and host authorization. A `hint`
4776
+ explains the zero only when the filter produced it, rejecting every file the scan reached; an empty
4777
+ tree and a host refusal return the same empty result without blaming the pattern. Regex is bounded by
4769
4778
  refusing backreferences and lookaround and capping line length rather than by a timeout, because a
4770
4779
  JavaScript `RegExp` cannot be interrupted once it starts backtracking. With an optional `AgentCodingArtifactStore`, shell output beyond the inline
4771
4780
  preview continues into an opaque bounded artifact and `read_output` reads slices without
@@ -4952,8 +4961,10 @@ const removed = new Set(page.compacted)
4952
4961
  `items` stays one sequence in the order it happened, and `compacted` names the
4953
4962
  ids inside it that the model no longer sees — the boundary is a mark on the
4954
4963
  conversation, not a second list. A compaction summary sits at the position of
4955
- the first message it replaced, so it appears at the head of the block it
4956
- stands for. Without the flag the page is exactly what it was, `compacted`
4964
+ the last message it replaced, so the block reads through and the summary
4965
+ arrives after it, where it was written; in the model's history, where every
4966
+ replaced message is gone, it occupies the block's place either way. Without
4967
+ the flag the page is exactly what it was, `compacted`
4957
4968
  empty. The v1 → v2 migration baseline records the same thing: the whole
4958
4969
  sequence, with `compacted` naming what had been folded away. A file migrated
4959
4970
  by 0.86.0 has a baseline built from the active history only — the messages
@@ -4973,10 +4984,14 @@ what was published, so a cursor sees no gap on an ordinary stream.
4973
4984
 
4974
4985
  ### Event ledger, projections and durable capabilities
4975
4986
 
4976
- `AgentRuntimeStore` exposes bounded `readEvents`, declared `appendEvent`,
4977
- canonical `exportConversation` and empty-target `importConversation`. Runtime
4978
- transitions and exact provider requests enter the same append-only ledger; the
4979
- normalized head/run/message tables remain the fast operational projection.
4987
+ `AgentRuntimeStore` exposes bounded `readEvents`, declared `appendEvent`, canonical
4988
+ `exportConversation` and empty-target `importConversation`. Runtime transitions, exact provider
4989
+ requests and completed provider response identities enter the same append-only ledger. A
4990
+ `provider/response` payload binds `response: { id, provider? }` to its `runId`, retry `attempt` and
4991
+ `stepNumber`; `step-finished.response` projects the same object to the operator sink. The optional
4992
+ upstream name comes from the model provider's own `resolveResponseProvider` — `openRouterProvider`
4993
+ supplies it — so the runtime carries the fact without learning any gateway's metadata key. The normalized
4994
+ head/run/message tables remain the fast operational projection.
4980
4995
 
4981
4996
  Use `defineAgentProjection` with `createSqliteAgentProjectionStore` for a
4982
4997
  deterministic versioned fold. Every value reports `uptoSeq`, so a caller can
@@ -5268,6 +5283,24 @@ own usage. The two channels answer to different readers — delivering a turn tw
5268
5283
  problem, and omitting a run's cost is an operator's.
5269
5284
  `runtime.stop(key)` is the process-local signal-only escape hatch.
5270
5285
 
5286
+ When an operator has positive evidence that another process owning one known
5287
+ run is gone, close that run through the runtime boundary rather than updating
5288
+ an adapter table or JSON payload directly:
5289
+
5290
+ ```ts
5291
+ await runtime.abandon({
5292
+ conversationId,
5293
+ runId,
5294
+ expectedRevision: run.revision,
5295
+ staleOwner: true,
5296
+ })
5297
+ ```
5298
+
5299
+ The revision protects against stale operator evidence. The mutation updates the
5300
+ canonical run and failed assistant atomically, removes the run from recovery
5301
+ indexes, and publishes the resulting `run-state`. A run that moved since it was
5302
+ read returns a conflict; `staleOwner: true` is mandatory evidence, not a default.
5303
+
5271
5304
  ## Store operations
5272
5305
 
5273
5306
  `AgentRuntimeStore` remains the runtime-facing aggregate. Application adapters
@@ -5712,6 +5745,10 @@ spent nothing, and an omitted object could not tell you which one you had.
5712
5745
  Two costs in different currencies do not add: the sum reports `unavailable`
5713
5746
  rather than picking a label. The core records a currency and never converts one.
5714
5747
 
5748
+ `step-finished.response` identifies the provider response for that one step. The terminal event
5749
+ does not copy the last response: response identity remains per-step, while every terminal usage
5750
+ figure remains a `computed` aggregate.
5751
+
5715
5752
  **A run's figure is durable, and that is where to read it when a channel loses
5716
5753
  it.** `AgentRun.usage` is written at every checkpoint and again with the terminal
5717
5754
  record, so a crashed process leaves behind what it had already spent and a
@@ -11227,6 +11264,37 @@ of the range if you want a different one.
11227
11264
  So upgrading is: read the `### ⚠️ Breaking changes` of every version *above* your
11228
11265
  current one *up to* your target, and apply each snippet.
11229
11266
 
11267
+ ## Released migration: 0.88.0
11268
+
11269
+ Two mechanical edits, and only if your project builds these values rather than only reading them.
11270
+
11271
+ A completed step event now carries the provider's response identity, and the field is required:
11272
+
11273
+ ```ts
11274
+ // before
11275
+ { type: 'step-finished', step: 0, usage }
11276
+
11277
+ // after
11278
+ { type: 'step-finished', step: 0, usage, response: { id: generationId } }
11279
+ ```
11280
+
11281
+ Every event the runtime emits already has it, so a sink that only reads them needs no change. A
11282
+ fixture, a test double or a pipeline that re-validates events persisted by an earlier version does:
11283
+ give the older records a response identity, or keep parsing them with the schema they were written
11284
+ under.
11285
+
11286
+ If you implement the whole `AgentRuntime` interface — usually a mock — add the new method:
11287
+
11288
+ ```ts
11289
+ // before
11290
+ const fake: AgentRuntime = { submit, interrupt, recover, close }
11291
+
11292
+ // after
11293
+ const fake: AgentRuntime = { submit, interrupt, abandon, recover, close }
11294
+ ```
11295
+
11296
+ No data migration is involved, and nothing in the store changes shape.
11297
+
11230
11298
  ## Released migration: 0.87.0
11231
11299
 
11232
11300
  Only if your project implements `AgentConversationReader` itself. A message page
@@ -15503,6 +15571,7 @@ Server-only optional application runtime. See the
15503
15571
  | `AgentAdmissionEventSchema` | schema | post-commit admission projection; removes store rereads but does not imply exactly-once delivery |
15504
15572
  | `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 |
15505
15573
  | `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
15574
+ | `AgentRuntimeAbandonInput` | _type_ | one known orphan identity, expected revision and mandatory stale-owner evidence for `runtime.abandon()` |
15506
15575
  | `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
15507
15576
  | `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
15508
15577
  | `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
@@ -15512,13 +15581,15 @@ Server-only optional application runtime. See the
15512
15581
  | `AgentRunOperationKindSchema` / `AgentRunOperationPhaseSchema` / `AgentRunOperationSchema` / `AgentRunOperation` | schemas / _type_ | latest durable model-request or compaction phase with operation/step identity and original timestamps; request admission is awaited before provider invocation |
15513
15582
  | `RecordRunOperationSchema` / `RecordRunOperation` | schema / _type_ | owner/fencing/revision-checked mutation of `AgentRun.lastOperation` |
15514
15583
  | `createAgentObservability` | function | separate agent-run sink over the shared bounded observability lifecycle |
15584
+ | `AgentProviderResponseSchema` / `AgentProviderResponse` | schema / _type_ | provider-assigned response ID and the optional upstream provider the model's own adapter resolves, shared by `step-finished.response` and durable `provider/response` facts |
15585
+ | `AgentStepFinishedEventSchema` / `AgentStepFinishedEvent` | schema / _type_ | one completed provider step with required usage and provider response identity |
15515
15586
 
15516
15587
  ### Durable capability layer
15517
15588
 
15518
15589
  | Export | Kind | Summary |
15519
15590
  |--------|------|---------|
15520
15591
  | `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive with exact ledger events, recovery projection and durable spill payloads |
15521
- | `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary and bounded page |
15592
+ | `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary (including `provider/request` and `provider/response`) and bounded page |
15522
15593
  | `AppendAgentStoreEventSchema` / `AppendAgentStoreEvent` / `ReadAgentStoreEventsSchema` / `ReadAgentStoreEvents` | schema / _type_ | required append and bounded-read store contracts |
15523
15594
  | `AgentStoreTransitionSchema` / `AgentStoreTransition` / `AgentStoreEventDraft` / `AgentStoreEventDecodeAccepted` / `AgentStoreEventDecodeIgnored` / `AgentStoreEventDecodeResult` / `decodeAgentStoreEvent` | schema / _types_ / function | normalized runtime mutations, append drafts and strict current/ignorable future-event decoding outcomes |
15524
15595
  | `defineAgentProjection` / `AgentProjectionDefinition` / `AgentProjectionValue` / `createAgentProjectionRegistry` / `createSqliteAgentProjectionStore` | functions / _type_ | deterministic folds with persisted version and honest `uptoSeq` checkpoints |
@@ -15541,7 +15612,7 @@ Server-only optional application runtime. See the
15541
15612
  The entrypoint deliberately exports the schemas beside their inferred types so persistence and
15542
15613
  transport adapters validate the same records. Runtime composition types are `AgentRuntime`,
15543
15614
  `AgentRuntimeConfig`, `AgentRuntimeInput`, `AgentRuntimeProtocolInput`, `AgentRuntimeRunContext`,
15544
- `AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeRecoveryInput`,
15615
+ `AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeAbandonInput`, `AgentRuntimeRecoveryInput`,
15545
15616
  `AgentRuntimeRecoveryDecision`, `AgentRuntimeRecoveryOutcome`, `AgentRuntimePublisher`,
15546
15617
  `AgentInputPolicy`, `AgentStopReason`, `AgentCoordinatedRun`, `AgentRunTicket`,
15547
15618
  `AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult` and
@@ -15758,6 +15829,13 @@ so denying `credentials` denies `credentials/token.txt` but not `credentials-bac
15758
15829
  admission happens before descent and file admission before opening; `search_files.include` is also
15759
15830
  applied before content is read. Requested paths must use `/` — a backslash is refused, because the
15760
15831
  containment walk reads it as a separator while a callback would read it as one name.
15832
+ Absolute paths remain refused; an absolute path inside the canonical root carries an exact
15833
+ workspace-relative `recoveryPath`, while one outside the root carries no replacement. The
15834
+ `search_files.include` schema states that its pattern is anchored to the whole workspace-relative
15835
+ path, `*` does not cross `/`, and `**/` is required for nested matches. `scannedFiles` is the
15836
+ post-include/post-authorization comparison count. A `hint` is added only when the filter itself
15837
+ produced the zero — it rejected every file the scan reached — never when there was nothing to
15838
+ reject or the host refused it.
15761
15839
  `run_command` is intentionally outside this guarantee because an executable needs process isolation,
15762
15840
  not path filtering, to constrain its filesystem access. → ADR 0172.
15763
15841
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.87.0",
3
+ "version": "0.88.0",
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",