stitchkit 0.87.1 → 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 (43) hide show
  1. package/CHANGELOG.md +64 -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/store-events.d.ts +2 -0
  21. package/dist/agent-runtime/store-events.d.ts.map +1 -1
  22. package/dist/agent-runtime-browser.js +5 -3
  23. package/dist/agent-runtime-coding-tools.js +27 -16
  24. package/dist/agent-runtime-harness.js +6 -6
  25. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  26. package/dist/agent-runtime-openrouter.js +12 -2
  27. package/dist/agent-runtime-sqlite-bun.js +5 -5
  28. package/dist/agent-runtime-sqlite-node.js +5 -5
  29. package/dist/agent-runtime.d.ts +1 -1
  30. package/dist/agent-runtime.d.ts.map +1 -1
  31. package/dist/agent-runtime.js +11 -8
  32. package/dist/{index-z1m86vc8.js → index-6krwcdcf.js} +2 -1
  33. package/dist/{index-z2452tsw.js → index-bt14acb5.js} +2 -2
  34. package/dist/{index-9553432s.js → index-crykmqkr.js} +1 -1
  35. package/dist/{index-p1b1y93x.js → index-gtj3zc53.js} +5 -1
  36. package/dist/{index-tg3m2ec5.js → index-mqv3b5rh.js} +4 -1
  37. package/dist/{index-35aefxby.js → index-p86mxmpp.js} +123 -7
  38. package/dist/{index-6g273pqx.js → index-qp3vshvc.js} +4 -4
  39. package/dist/{index-5wezxcxx.js → index-v1qk37y9.js} +2 -2
  40. package/dist/{index-hkm6wysp.js → index-y64k3s0h.js} +1 -1
  41. package/dist/testing.js +14 -3
  42. package/llms-full.txt +86 -10
  43. 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
@@ -4975,10 +4984,14 @@ what was published, so a cursor sees no gap on an ordinary stream.
4975
4984
 
4976
4985
  ### Event ledger, projections and durable capabilities
4977
4986
 
4978
- `AgentRuntimeStore` exposes bounded `readEvents`, declared `appendEvent`,
4979
- canonical `exportConversation` and empty-target `importConversation`. Runtime
4980
- transitions and exact provider requests enter the same append-only ledger; the
4981
- 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.
4982
4995
 
4983
4996
  Use `defineAgentProjection` with `createSqliteAgentProjectionStore` for a
4984
4997
  deterministic versioned fold. Every value reports `uptoSeq`, so a caller can
@@ -5270,6 +5283,24 @@ own usage. The two channels answer to different readers — delivering a turn tw
5270
5283
  problem, and omitting a run's cost is an operator's.
5271
5284
  `runtime.stop(key)` is the process-local signal-only escape hatch.
5272
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
+
5273
5304
  ## Store operations
5274
5305
 
5275
5306
  `AgentRuntimeStore` remains the runtime-facing aggregate. Application adapters
@@ -5714,6 +5745,10 @@ spent nothing, and an omitted object could not tell you which one you had.
5714
5745
  Two costs in different currencies do not add: the sum reports `unavailable`
5715
5746
  rather than picking a label. The core records a currency and never converts one.
5716
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
+
5717
5752
  **A run's figure is durable, and that is where to read it when a channel loses
5718
5753
  it.** `AgentRun.usage` is written at every checkpoint and again with the terminal
5719
5754
  record, so a crashed process leaves behind what it had already spent and a
@@ -11229,6 +11264,37 @@ of the range if you want a different one.
11229
11264
  So upgrading is: read the `### ⚠️ Breaking changes` of every version *above* your
11230
11265
  current one *up to* your target, and apply each snippet.
11231
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
+
11232
11298
  ## Released migration: 0.87.0
11233
11299
 
11234
11300
  Only if your project implements `AgentConversationReader` itself. A message page
@@ -15505,6 +15571,7 @@ Server-only optional application runtime. See the
15505
15571
  | `AgentAdmissionEventSchema` | schema | post-commit admission projection; removes store rereads but does not imply exactly-once delivery |
15506
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 |
15507
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()` |
15508
15575
  | `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
15509
15576
  | `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
15510
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 |
@@ -15514,13 +15581,15 @@ Server-only optional application runtime. See the
15514
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 |
15515
15582
  | `RecordRunOperationSchema` / `RecordRunOperation` | schema / _type_ | owner/fencing/revision-checked mutation of `AgentRun.lastOperation` |
15516
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 |
15517
15586
 
15518
15587
  ### Durable capability layer
15519
15588
 
15520
15589
  | Export | Kind | Summary |
15521
15590
  |--------|------|---------|
15522
15591
  | `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive with exact ledger events, recovery projection and durable spill payloads |
15523
- | `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 |
15524
15593
  | `AppendAgentStoreEventSchema` / `AppendAgentStoreEvent` / `ReadAgentStoreEventsSchema` / `ReadAgentStoreEvents` | schema / _type_ | required append and bounded-read store contracts |
15525
15594
  | `AgentStoreTransitionSchema` / `AgentStoreTransition` / `AgentStoreEventDraft` / `AgentStoreEventDecodeAccepted` / `AgentStoreEventDecodeIgnored` / `AgentStoreEventDecodeResult` / `decodeAgentStoreEvent` | schema / _types_ / function | normalized runtime mutations, append drafts and strict current/ignorable future-event decoding outcomes |
15526
15595
  | `defineAgentProjection` / `AgentProjectionDefinition` / `AgentProjectionValue` / `createAgentProjectionRegistry` / `createSqliteAgentProjectionStore` | functions / _type_ | deterministic folds with persisted version and honest `uptoSeq` checkpoints |
@@ -15543,7 +15612,7 @@ Server-only optional application runtime. See the
15543
15612
  The entrypoint deliberately exports the schemas beside their inferred types so persistence and
15544
15613
  transport adapters validate the same records. Runtime composition types are `AgentRuntime`,
15545
15614
  `AgentRuntimeConfig`, `AgentRuntimeInput`, `AgentRuntimeProtocolInput`, `AgentRuntimeRunContext`,
15546
- `AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeRecoveryInput`,
15615
+ `AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeAbandonInput`, `AgentRuntimeRecoveryInput`,
15547
15616
  `AgentRuntimeRecoveryDecision`, `AgentRuntimeRecoveryOutcome`, `AgentRuntimePublisher`,
15548
15617
  `AgentInputPolicy`, `AgentStopReason`, `AgentCoordinatedRun`, `AgentRunTicket`,
15549
15618
  `AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult` and
@@ -15760,6 +15829,13 @@ so denying `credentials` denies `credentials/token.txt` but not `credentials-bac
15760
15829
  admission happens before descent and file admission before opening; `search_files.include` is also
15761
15830
  applied before content is read. Requested paths must use `/` — a backslash is refused, because the
15762
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.
15763
15839
  `run_command` is intentionally outside this guarantee because an executable needs process isolation,
15764
15840
  not path filtering, to constrain its filesystem access. → ADR 0172.
15765
15841
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.87.1",
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",