stitchkit 0.68.11 → 0.69.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 (120) hide show
  1. package/README.md +30 -1
  2. package/dist/agent-runtime/coding-tool-contract.d.ts +155 -0
  3. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -0
  4. package/dist/agent-runtime/coding-tool-files.d.ts +3 -0
  5. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -0
  6. package/dist/agent-runtime/coding-tool-paths.d.ts +19 -0
  7. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -0
  8. package/dist/agent-runtime/coding-tool-search-patch.d.ts +3 -0
  9. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -0
  10. package/dist/agent-runtime/coding-tool-shell.d.ts +3 -0
  11. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -0
  12. package/dist/agent-runtime/coding-tools.d.ts +17 -0
  13. package/dist/agent-runtime/coding-tools.d.ts.map +1 -0
  14. package/dist/agent-runtime/compaction.d.ts +2 -0
  15. package/dist/agent-runtime/compaction.d.ts.map +1 -1
  16. package/dist/agent-runtime/contained-files.d.ts +31 -0
  17. package/dist/agent-runtime/contained-files.d.ts.map +1 -0
  18. package/dist/agent-runtime/control-schema.d.ts +1074 -0
  19. package/dist/agent-runtime/control-schema.d.ts.map +1 -0
  20. package/dist/agent-runtime/conversations.d.ts +128 -0
  21. package/dist/agent-runtime/conversations.d.ts.map +1 -0
  22. package/dist/agent-runtime/event-schema.d.ts +96 -0
  23. package/dist/agent-runtime/event-schema.d.ts.map +1 -1
  24. package/dist/agent-runtime/harness-contract.d.ts +169 -0
  25. package/dist/agent-runtime/harness-contract.d.ts.map +1 -0
  26. package/dist/agent-runtime/harness-control.d.ts +25 -0
  27. package/dist/agent-runtime/harness-control.d.ts.map +1 -0
  28. package/dist/agent-runtime/harness-file-resources.d.ts +33 -0
  29. package/dist/agent-runtime/harness-file-resources.d.ts.map +1 -0
  30. package/dist/agent-runtime/harness-resources.d.ts +5 -0
  31. package/dist/agent-runtime/harness-resources.d.ts.map +1 -0
  32. package/dist/agent-runtime/harness.d.ts +12 -0
  33. package/dist/agent-runtime/harness.d.ts.map +1 -0
  34. package/dist/agent-runtime/history.d.ts +2 -0
  35. package/dist/agent-runtime/history.d.ts.map +1 -1
  36. package/dist/agent-runtime/models.d.ts +199 -0
  37. package/dist/agent-runtime/models.d.ts.map +1 -1
  38. package/dist/agent-runtime/prompt.d.ts +2 -0
  39. package/dist/agent-runtime/prompt.d.ts.map +1 -1
  40. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  41. package/dist/agent-runtime/runtime.d.ts +11 -3
  42. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  43. package/dist/agent-runtime/schemas.d.ts +49 -0
  44. package/dist/agent-runtime/schemas.d.ts.map +1 -1
  45. package/dist/agent-runtime/sqlite.d.ts +2 -0
  46. package/dist/agent-runtime/sqlite.d.ts.map +1 -1
  47. package/dist/agent-runtime/store-driver.d.ts +61 -212
  48. package/dist/agent-runtime/store-driver.d.ts.map +1 -1
  49. package/dist/agent-runtime/store.d.ts +368 -1
  50. package/dist/agent-runtime/store.d.ts.map +1 -1
  51. package/dist/agent-runtime/terminal-commit.d.ts +12 -1
  52. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  53. package/dist/agent-runtime/terminal-status.d.ts +8 -0
  54. package/dist/agent-runtime/terminal-status.d.ts.map +1 -1
  55. package/dist/agent-runtime-browser.d.ts +1 -0
  56. package/dist/agent-runtime-browser.d.ts.map +1 -1
  57. package/dist/agent-runtime-browser.js +217 -1
  58. package/dist/agent-runtime-coding-tools.d.ts +2 -0
  59. package/dist/agent-runtime-coding-tools.d.ts.map +1 -0
  60. package/dist/agent-runtime-coding-tools.js +706 -0
  61. package/dist/agent-runtime-harness.d.ts +2 -0
  62. package/dist/agent-runtime-harness.d.ts.map +1 -0
  63. package/dist/agent-runtime-harness.js +700 -0
  64. package/dist/agent-runtime-openrouter.d.ts +14 -1
  65. package/dist/agent-runtime-openrouter.d.ts.map +1 -1
  66. package/dist/agent-runtime-openrouter.js +211 -0
  67. package/dist/agent-runtime-sqlite-bun.js +4 -3
  68. package/dist/agent-runtime-sqlite-node.js +4 -3
  69. package/dist/agent-runtime.d.ts +5 -3
  70. package/dist/agent-runtime.d.ts.map +1 -1
  71. package/dist/agent-runtime.js +106 -2580
  72. package/dist/application/diagnostic-journal-contract.d.ts +164 -0
  73. package/dist/application/diagnostic-journal-contract.d.ts.map +1 -0
  74. package/dist/application/diagnostic-journal-manager.d.ts +12 -0
  75. package/dist/application/diagnostic-journal-manager.d.ts.map +1 -0
  76. package/dist/application/diagnostic-journal-storage.d.ts +29 -0
  77. package/dist/application/diagnostic-journal-storage.d.ts.map +1 -0
  78. package/dist/application/diagnostic-journal.d.ts +11 -0
  79. package/dist/application/diagnostic-journal.d.ts.map +1 -0
  80. package/dist/application.d.ts +2 -0
  81. package/dist/application.d.ts.map +1 -1
  82. package/dist/application.js +561 -17
  83. package/dist/browser/socket-io.d.ts.map +1 -1
  84. package/dist/cli.js +8 -6
  85. package/dist/{index-8vpzxg55.js → index-10gbbbaa.js} +103 -2
  86. package/dist/index-3eqrkqhg.js +2565 -0
  87. package/dist/{index-hcx9yypn.js → index-444747ww.js} +7 -7
  88. package/dist/{index-hxh98zbm.js → index-d1jsvkyk.js} +1 -1
  89. package/dist/index-es0h4w26.js +63 -0
  90. package/dist/{index-grgvpbch.js → index-gqdfpv4n.js} +4 -2
  91. package/dist/{index-bt5179zb.js → index-h7ctj1kp.js} +5 -3
  92. package/dist/{index-y2ctppmg.js → index-h8vn1jcr.js} +7 -73
  93. package/dist/{index-hqza5nde.js → index-hsabxjz0.js} +78 -77
  94. package/dist/index-kg9xx84n.js +73 -0
  95. package/dist/{index-hb0mncmj.js → index-kxxyvkka.js} +2 -2
  96. package/dist/{index-2t6zt5cg.js → index-mbxds404.js} +7 -5
  97. package/dist/{index-f24xg2cw.js → index-p1be103g.js} +1 -1
  98. package/dist/{index-xyvxez9r.js → index-q7gdep2c.js} +5 -5
  99. package/dist/{index-t23p2b68.js → index-t4dpby6e.js} +1 -1
  100. package/dist/index-tg3m2ec5.js +157 -0
  101. package/dist/index-v3dpzpjw.js +92 -0
  102. package/dist/{index-eqqyd9v8.js → index-wwst0td5.js} +2 -46
  103. package/dist/{index-ysphyxax.js → index-x1th9s8c.js} +23 -2
  104. package/dist/index-xxsq3ca1.js +51 -0
  105. package/dist/{index-22tjt2rk.js → index-zh459sfj.js} +1 -1
  106. package/dist/index.js +51 -37
  107. package/dist/internal/ai-sdk-typed.d.ts +14 -0
  108. package/dist/internal/ai-sdk-typed.d.ts.map +1 -0
  109. package/dist/node.js +5 -5
  110. package/dist/observability/index.js +4 -4
  111. package/dist/realtime/request.d.ts +5 -0
  112. package/dist/realtime/request.d.ts.map +1 -1
  113. package/dist/remote.js +6 -6
  114. package/dist/server/index.js +9 -9
  115. package/dist/testing.js +5 -5
  116. package/dist/tool-invoker.js +6 -5
  117. package/dist/tools.js +21 -17
  118. package/llms-full.txt +342 -27
  119. package/package.json +10 -2
  120. package/dist/{index-pgsyp3xh.js → index-x18ndp4p.js} +3 -3
package/llms-full.txt CHANGED
@@ -59,12 +59,15 @@ own, recorded as an ADR.
59
59
  | `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 |
60
60
  | `stitchkit/declaration` | build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
61
61
  | `stitchkit/react` | browser | stable | `createCursorQuery`, `createCacheBridge` |
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 |
62
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the 14 minors since 0.56.2, most recently 0.69.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
63
+ | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
64
+ | `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 |
63
65
  | `stitchkit/agent-runtime/openrouter` | server | evolving | isolated OpenRouter language-model adapter |
64
66
  | `stitchkit/agent-runtime/browser` | browser + server | evolving | canonical agent records, events and reconnect cursor without execution or sinks |
65
67
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
66
68
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
67
- | `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 |
69
+ | `@stitchkit/tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
70
+ | `stitchkit/application` | server | evolving<br>_redefined in 3 of the 14 minors since 0.56.2, most recently 0.67.0_ | managed resource graph, readiness, admission, schedules and bounded shutdown |
68
71
  | `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
69
72
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
70
73
 
@@ -166,6 +169,8 @@ map — feature → packages:
166
169
  | In-process contract tools (`stitchkit/tools/invoker`) | — |
167
170
  | MCP / agent adapters (`stitchkit/tools`) | `@modelcontextprotocol/server` `ai` |
168
171
  | Agent application runtime (`stitchkit/agent-runtime`) | `ai` |
172
+ | Headless Agent harness (`stitchkit/agent-runtime/harness`) | `ai` |
173
+ | Agent coding tools (`stitchkit/agent-runtime/coding-tools`) | — |
169
174
  | OpenRouter runtime adapter (`stitchkit/agent-runtime/openrouter`) | `ai` `@openrouter/ai-sdk-provider` |
170
175
  | SQLite agent store (`stitchkit/agent-runtime/sqlite/bun` or `/node`) | — (runtime built-in) |
171
176
  | MCP host/client tests | `@modelcontextprotocol/client` |
@@ -213,6 +218,17 @@ For a complete production-shaped app, run `bun create stitchkit my-app`. The
213
218
  canonical generated topology is maintained in
214
219
  [`packages/create-stitchkit/template`](../../packages/create-stitchkit/template).
215
220
 
221
+ For a terminal Agent host instead, run
222
+ `bun create stitchkit my-agent --template agent`, copy `.env.example` to `.env`,
223
+ set `OPENROUTER_API_KEY`, then run `bun run dev` and choose a live tool-capable
224
+ model with `/model`. The provider catalog owns the exact model id and context window and presents
225
+ weekly popularity separately from sourced benchmark observations; `OPENROUTER_MODEL` is only an
226
+ optional preferred row. That profile is a thin `stitchkit.agent.ts` composition over the official
227
+ `@stitchkit/tui` package and canonical headless harness:
228
+ durable SQLite history, lazy skills, direct coding tools, approval continuations
229
+ and recovery stay framework-owned primitives, while model choice, permissions,
230
+ executables and OS isolation remain application policy.
231
+
216
232
 
217
233
  ==============================================================================
218
234
  # Guide: Contracts (docs/guide/contracts.md)
@@ -3991,33 +4007,82 @@ provider-reported input usage and cost to decide whether the extra search round
3991
4007
  is beneficial. Controller evidence intentionally omits query text, prompts,
3992
4008
  arguments and application context. → ADR 0129.
3993
4009
 
3994
- ### Executable headless harness and capability map
4010
+ ### Published headless harness and structured runner
4011
+
4012
+ `stitchkit/agent-runtime/harness` publishes the resource-aware composition over
4013
+ `createAgentRuntime`. `createHeadlessAgentHarness` accepts the existing protocol and store,
4014
+ caller-provided model resolution, bounded instruction/skill/resource loading, direct tools and a
4015
+ prompt-budget callback. Resource names are unique; count, UTF-8 bytes and diagnostics are bounded.
4016
+ Invalid resources fail before a provider request. Diagnostics are evidence for the caller: their
4017
+ observer is isolated, and the loader decides whether a reported condition is fatal.
4018
+
4019
+ `createAgentHarnessFileResources` is the optional filesystem implementation. It reads only
4020
+ caller-declared absolute roots, refuses symlinks and reports provenance as
4021
+ `rootId:relative/path`. Instructions enter the prompt immediately. Skills and ordinary resources
4022
+ enter as bounded name/description summaries; `read_resource` loads one exact body later as
4023
+ a normal direct typed tool. Custom loaders remain supported unchanged.
3995
4024
 
3996
- [`packages/core/examples/headless-agent-harness.ts`](../../packages/core/examples/headless-agent-harness.ts)
3997
- is the complete resource-aware recipe. It accepts injected protocol, model,
3998
- tool and store ports, validates resources plus diagnostics, carries provenance
3999
- into the prompt and delegates execution to `createAgentRuntime`. Importing the
4000
- example starts no process, opens no database and discovers no filesystem path.
4025
+ Each run may resolve a different provider adapter without changing the harness. The
4026
+ `profile-applied` observation records the actual `AgentModelDescriptor`, resource kind/name/
4027
+ provenance and sorted direct tool names; it intentionally contains no resource text, prompts,
4028
+ arguments or credentials. Observer failure never changes the canonical run outcome.
4029
+
4030
+ [`packages/core/examples/headless-agent-runner.ts`](../../packages/core/examples/headless-agent-runner.ts)
4031
+ is a reference structured control loop for `submit`, `interrupt`, `snapshot` and bounded `close`.
4032
+ It starts no process and chooses no framing, authentication or transport. Importing either example
4033
+ has no side effect; an external supervisor owns process placement and restart.
4001
4034
 
4002
4035
  | Concern | Public Stitchkit composition | Boundary |
4003
4036
  | --- | --- | --- |
4004
4037
  | execution loop | `createAgentRuntime` | already available; do not copy a second loop |
4005
4038
  | model choice | `defineModelRegistry` and `models.resolve` | provider credentials/discovery stay application-owned |
4006
- | resources | injected loader → `composeAgentPrompt` sections | paths, trust, precedence and watching stay application-owned |
4039
+ | resources | `createHeadlessAgentHarness` → `composeAgentPrompt` | paths, trust, precedence and watching stay application-owned |
4007
4040
  | tools | `mountAgent` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
4008
4041
  | follow-up | `runs.inputPolicy: 'queue'` | durable FIFO after the current run |
4009
4042
  | interrupt | `interrupt` or `interrupt-next` | `interrupt-next` terminates the active run and gives the new durable admission next priority |
4010
4043
  | recovery | `runtime.recover` + `scanRecoverable` | replay safety and context reconstruction are explicit callbacks |
4011
- | reconnect | canonical snapshot + `advanceAgentRuntimeEventCursor` | transient deltas are replaceable; durable event IDs deduplicate |
4044
+ | reconnect | canonical snapshot + `advanceAgentMultiSessionCursor` | conversation/run-scoped gaps require resync |
4012
4045
  | persistence | memory reference, public driver, or SQLite leaf | product rows/outbox remain outside the runtime store |
4013
-
4014
- Pi's steering queue waits for the current tool calls and injects the steering
4015
- message at its next loop boundary. It is therefore not an alias for
4016
- `interrupt-next`: Stitchkit requests termination of the active durable run,
4017
- waits for its terminal settlement, and executes the prioritized successor.
4018
- Pi follow-up is closest to Stitchkit `queue`, while JSONL trees, branching,
4019
- workspace discovery, permissions and terminal UI remain embedding-application
4020
- features rather than runtime requirements.
4046
+ | executable lifecycle | structured runner example | framing, auth, process placement, restart and OS isolation stay host-owned |
4047
+
4048
+ `createAgentHarnessControlServer` adds transport-neutral correlated requests, shared observers and
4049
+ one exclusive controller lease per conversation. `close()` on a connection detaches only that
4050
+ client; it never closes the harness. Normal `event` delivery stays serialized. A bounded slow
4051
+ consumer is detached and receives `resync-required` through the required synchronous
4052
+ `onOverflow` callback; that callback closes/aborts the underlying transport, which then reconnects
4053
+ and requests a fresh snapshot. It never writes a second frame concurrently with a blocked
4054
+ `deliver`. Browser code uses `createAgentControlView`,
4055
+ `reduceAgentControlSnapshot` and `reduceAgentControlEvent`; the reducer owns no renderer and marks a
4056
+ conversation `resyncRequired` after a transient sequence gap.
4057
+
4058
+ Configure `loop.toolApproval` to use the installed AI SDK approval policy and
4059
+ `loop.toolApprovalSecret` to sign exact requests. A request is stored on the terminal assistant
4060
+ before any effect. `pendingApprovals()` derives unresolved requests from canonical messages;
4061
+ `respondToApproval()` writes one tool-role approval response and queues a successor. The SDK
4062
+ revalidates the signature/tool call/input before the original direct tool reaches its existing
4063
+ fence. Reconnect and SQLite reopen require no promise registry. Remembered policy and a stronger
4064
+ cross-crash exactly-once guarantee remain application concerns.
4065
+
4066
+ `stitchkit/agent-runtime/coding-tools` returns ordinary direct runtime tools named `read_file`,
4067
+ `write_file`, `search_files`, `apply_patch`, `run_command` and optional `read_output`. Every call passes a
4068
+ required host authorization callback. File paths are relative, bounded and contained after
4069
+ realpath resolution; writes/edits reject symlink targets, content is strict UTF-8 and retained
4070
+ bytes are finite. Shell accepts a finite alias mapped by the host to an absolute executable plus an
4071
+ argument array — never a shell command string — and uses only the explicitly supplied environment.
4072
+ Arguments, output and time are bounded, while cancellation terminates the child. The configured
4073
+ root and cwd are path boundaries, not a security sandbox: isolate the process when an executable
4074
+ must not access the rest of the machine.
4075
+
4076
+ `apply_patch` binds the exact source to `baseSha256`, supports dry-run, authorizes the exact
4077
+ replacement count, result digest and byte size, then rechecks the base under a per-target lock
4078
+ before same-directory atomic replacement. It deliberately does not claim
4079
+ multi-file atomicity. With an optional `AgentCodingArtifactStore`, shell output beyond the inline
4080
+ preview continues into an opaque bounded artifact and `read_output` reads slices without
4081
+ exposing a host path. Without a store, the previous finite output-limit behavior is unchanged.
4082
+
4083
+ One `createAgentHarnessFileResources` instance represents one immutable discovery generation:
4084
+ concurrent and repeated `load()` calls share it, so a direct resource read cannot cross into a
4085
+ new catalog unexpectedly. Construct a new loader to refresh after filesystem changes.
4021
4086
 
4022
4087
  Runtime events preserve reasoning/text/tool lifecycle order. Durable admission,
4023
4088
  checkpoint, run-state and terminal events carry stable identities; transient
@@ -5163,6 +5228,54 @@ replenishes once; it is flow-control credit, not a durable acknowledgement. The
5163
5228
  application snapshot sink now shares the same latest-value mechanics without
5164
5229
  changing its revision or status contract. → ADR 0119.
5165
5230
 
5231
+ ### Bounded local diagnostic journal
5232
+
5233
+ Use `createDiagnosticJournal` when a process needs finite, ordered local metadata evidence and the
5234
+ deployment log pipeline is not the right boundary:
5235
+
5236
+ ```ts
5237
+ import { createDiagnosticJournal } from 'stitchkit/application'
5238
+ import { z } from 'zod'
5239
+
5240
+ const journal = await createDiagnosticJournal({
5241
+ eventSchema: z.object({
5242
+ kind: z.enum(['resource_failed', 'recovery_started']),
5243
+ resource: z.string().max(80),
5244
+ }).strict(),
5245
+ path: '/var/lib/example/diagnostic.jsonl', // operator configuration, never request data
5246
+ limits: {
5247
+ maxEventBytes: 4 * 1024,
5248
+ maxPendingItems: 128,
5249
+ maxPendingBytes: 512 * 1024,
5250
+ maxFileBytes: 8 * 1024 * 1024,
5251
+ maxFiles: 4,
5252
+ },
5253
+ onFailure: (failure) => internalLogger.error(failure),
5254
+ })
5255
+
5256
+ const result = journal.submit({ kind: 'recovery_started', resource: 'database' })
5257
+ if (result.outcome === 'refused') internalCounter.add(1, { reason: result.reason })
5258
+
5259
+ // During managed-resource close. Timeout ends this wait, not the physical append.
5260
+ await journal.close({ timeoutMs: 5_000 })
5261
+ ```
5262
+
5263
+ The owner schema and JSON serialization run synchronously before admission. Accepted frames carry
5264
+ a process epoch and contiguous sequence and retain their complete bytes inside both pending limits
5265
+ until their append attempt settles. Capacity, invalid, oversized, closed and terminal-failure
5266
+ refusals are explicit; accepted ordered frames are never evicted.
5267
+
5268
+ The absolute path's parent must already exist and be operator-controlled. One manager owns it via
5269
+ an exclusive `.lock`; new files use mode `0600` by default. `maxFiles` includes the active file,
5270
+ and a non-newline startup tail is rotated intact rather than guessed or repaired. An abrupt process
5271
+ death may leave the lock for an operator to remove only after proving the former owner is gone.
5272
+
5273
+ `flush()` means every accepted append through that call's boundary settled. It is not `fsync`, a
5274
+ durable receipt, exactly-once execution or remote delivery. Timeout/cancellation bound only the
5275
+ waiter; the writer retains physical capacity until settlement. There is no reader or upload API.
5276
+ Use a durable application store or deployment-owned log collector when restart recovery, replay or
5277
+ aggregation is required. → [ADR 0134](../decisions/0134-diagnostic-journal-is-bounded-local-evidence.md).
5278
+
5166
5279
  Shutdown performs one phase barrier at a time: stop admission everywhere,
5167
5280
  cancel future schedules, drain admitted work, then close in reverse stable
5168
5281
  topological order. Every hook shares the same grace deadline. Forced cleanup
@@ -6197,7 +6310,10 @@ from the contract and validated on both sides:
6197
6310
  const result = await socket.request(
6198
6311
  'room:join',
6199
6312
  'general',
6200
- { timeoutMs: 5_000 },
6313
+ {
6314
+ timeoutMs: 5_000,
6315
+ onPhase: (phase) => roomJoinMetrics.record(phase),
6316
+ },
6201
6317
  )
6202
6318
  // result: { joined: boolean }
6203
6319
  ```
@@ -6242,6 +6358,22 @@ closed phase:
6242
6358
  | `timeout` | the existing native acknowledgement timeout won |
6243
6359
  | `disconnected` | the request began disconnected or an in-flight disconnect won |
6244
6360
 
6361
+ When a caller needs to join those phases to its own invocation, put `onPhase`
6362
+ on that request's options and keep the caller identity in the hook's closure:
6363
+
6364
+ ```ts
6365
+ await socket.request('room:join', 'general', {
6366
+ timeoutMs: 5_000,
6367
+ onPhase: (phase) => recordPhase({ operationId, phase }),
6368
+ })
6369
+ ```
6370
+
6371
+ The client-wide hook receives every observed request; a request hook receives
6372
+ only its invocation. If the same function is supplied in both places it runs
6373
+ once per phase. The closure is local: Stitchkit does not retain `operationId`,
6374
+ add it to the event or transmit it to the peer. A request hook works without a
6375
+ client-wide hook, and the no-hook path installs no phase listeners.
6376
+
6245
6377
  Engine handoff is not proof of a physical network write. Engine acknowledgement
6246
6378
  receipt is not a remote clock, end-to-end RTT or proof that application
6247
6379
  validation has run. The useful interval is local and monotonic:
@@ -6254,9 +6386,9 @@ with Socket.IO acknowledgement ids, but those ids are never exposed. A timeout
6254
6386
  or disconnect is terminal, a late packet cannot reopen the identity, and sync
6255
6387
  or async observer failures are ignored so telemetry cannot change request
6256
6388
  correctness. With no hook, no request identity, Engine.IO listener or correlation
6257
- map entry is created. The low-level `createSocketIOClient` and non-owning
6258
- `bindRealtimeClient` remain unchanged; this phase surface belongs to the
6259
- canonical composed client that owns both transport and validation.
6389
+ map entry is created. The low-level `createSocketIOClient` implements the same
6390
+ request option, so a non-owning `bindRealtimeClient` over that transport keeps
6391
+ request-scoped observation without opening a second connection.
6260
6392
 
6261
6393
  ## Low-level transport
6262
6394
 
@@ -8737,6 +8869,47 @@ additive** — adopting it changes nothing in your code. (See
8737
8869
  So upgrading is: read the `### ⚠️ Breaking changes` of every version *above* your
8738
8870
  current one *up to* your target, and apply each snippet.
8739
8871
 
8872
+ ## Released migration: 0.69.0
8873
+
8874
+ ### Direct coding-tool operation names
8875
+
8876
+ `createAgentCodingTools` no longer prefixes durable operation identity with `coding_`, and the
8877
+ unguarded exact-string edit tool is gone. Update approval maps, presenters and tests together:
8878
+
8879
+ ```ts
8880
+ // before
8881
+ { coding_read_file: 'approved', coding_search: 'approved', coding_patch_file: 'user-approval' }
8882
+
8883
+ // after
8884
+ { read_file: 'approved', search_files: 'approved', apply_patch: 'user-approval' }
8885
+ ```
8886
+
8887
+ The full mapping is `coding_read_file → read_file`, `coding_write_file → write_file`,
8888
+ `coding_search → search_files`, `coding_patch_file → apply_patch`, `coding_shell → run_command`,
8889
+ `coding_read_artifact → read_output` and `harness_read_resource → read_resource`. Replace
8890
+ `coding_edit_file` with `read_file` followed by guarded `apply_patch`; `read_file` now returns the
8891
+ required SHA-256. If the host declares no executable aliases, expect `run_command` to be absent.
8892
+
8893
+ ### Durable Agent approval message variants
8894
+
8895
+ If a renderer, store adapter or export pipeline exhaustively switches over
8896
+ `AgentMessage.role`, add the `tool` branch. If it switches over
8897
+ `AgentMessagePart.type`, add `tool-approval-request` and `tool-approval-response`.
8898
+ They are durable provider-continuation evidence: preserve them in storage and provider history;
8899
+ a UI may render them as approval state or intentionally omit their visual row.
8900
+
8901
+ ```ts
8902
+ // before
8903
+ const unreachable: never = message.role
8904
+
8905
+ // after
8906
+ if (message.role === 'tool') renderToolContinuation(message.parts)
8907
+ else renderExistingRole(message)
8908
+ ```
8909
+
8910
+ No data migration is needed. The schema still accepts all earlier records, and applications that
8911
+ do not exhaustively branch over these unions compile unchanged.
8912
+
8740
8913
  ## Before you bump, if you implement an agent store
8741
8914
 
8742
8915
  One step, and it is mechanical. If your project has an `AgentRuntimeStore` — a
@@ -11298,10 +11471,10 @@ The browser-and-server entrypoint. Re-exports everything from
11298
11471
  | `RealtimeAcknowledgedEvent` | _type_ | event-name union restricted to definitions with an `ack` schema |
11299
11472
  | `RealtimeAcknowledgement` | _type_ | validated acknowledgement output inferred from an event definition |
11300
11473
  | `RealtimeRequestArguments` | _type_ | request arguments inferred from an acknowledged event tuple |
11301
- | `RealtimeRequestOptions` | _type_ | finite positive native acknowledgement `timeoutMs` |
11474
+ | `RealtimeRequestOptions` | _type_ | finite positive native acknowledgement `timeoutMs` plus an optional invocation-scoped `onPhase` observer |
11302
11475
  | `RealtimeRequestPhaseSchema` / `RealtimeRequestPhase` | schema / _type_ | closed `engine-handoff` / `engine-ack-received` / `settled` / `timeout` / `disconnected` lifecycle |
11303
11476
  | `RealtimeRequestPhaseEventSchema` / `RealtimeRequestPhaseEvent` | schema / _type_ | strict metadata-only `{ requestId, event, phase, elapsedMs }` observation |
11304
- | `RealtimeRequestPhaseHook` | _type_ | isolated sync/async observer accepted by `RealtimeClientOptions.onRequestPhase` |
11477
+ | `RealtimeRequestPhaseHook` | _type_ | isolated sync/async observer accepted globally by `RealtimeClientOptions.onRequestPhase` or per invocation by `RealtimeRequestOptions.onPhase` |
11305
11478
  | `RealtimeRequestTimeoutError` | class | stable `REALTIME_REQUEST_TIMEOUT` rejection |
11306
11479
  | `RealtimeRequestDisconnectedError` | class | stable `REALTIME_REQUEST_DISCONNECTED` rejection, including an immediate disconnected call |
11307
11480
  | `RealtimeRequestInvalidAcknowledgementError` | class | invalid ack was reported through `onRejected` and the request rejected |
@@ -11712,6 +11885,29 @@ cutovers are covered by the executable
11712
11885
  | `CreditWindow` / `CreditWindowSnapshot` / `CreditWindowSnapshotSchema` | _type_ / schema | byte-credit handle and absolute accounting record |
11713
11886
  | `CreditAcquireResult` / `CreditLease` | _type_ | reasoned refusal or idempotently releasable byte-credit lease |
11714
11887
 
11888
+ ### Bounded diagnostic journal
11889
+
11890
+ | Export | Kind | Summary |
11891
+ |--------|------|---------|
11892
+ | `createDiagnosticJournal` | function | create one schema-owned FIFO JSONL writer with bounded retained memory, exclusive local path ownership and finite rotation |
11893
+ | `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
11894
+ | `DiagnosticJournalLimitsSchema` / `DiagnosticJournalLimits` | schema / _type_ | positive event, pending-item, pending-byte, file-byte and retained-file limits |
11895
+ | `DiagnosticJournalSubmitResultSchema` / `DiagnosticJournalSubmitResult` | schema / _type_ | accepted epoch/sequence or explicit invalid, oversized, capacity, closed or failed refusal |
11896
+ | `DiagnosticJournalStatusSchema` / `DiagnosticJournalStatus` | schema / _type_ | state, limits, exact admission/write/failure counters, pending ownership, rotations, partial tails and last safe sequences |
11897
+ | `DiagnosticJournalFrameSchema` / `DiagnosticJournalFrame` | schema / _type_ | version-1 JSONL frame carrying process epoch, contiguous accepted sequence and schema-validated JSON event |
11898
+ | `DiagnosticJournalWaitResultSchema` / `DiagnosticJournalWaitResult` | schema / _type_ | flush settlement boundary with truthful settled, timed-out or cancelled result |
11899
+ | `DiagnosticJournalCloseResultSchema` / `DiagnosticJournalCloseResult` | schema / _type_ | physical close or caller timeout/cancellation without pretending an active write stopped |
11900
+ | `DiagnosticJournalStateSchema` / `DiagnosticJournalState` | schema / _type_ | `open \| draining \| closed \| failed` |
11901
+ | `DiagnosticJournalRefusalReasonSchema` / `DiagnosticJournalRefusalReason` | schema / _type_ | `closed \| failed \| invalid \| oversized \| item-capacity \| byte-capacity` |
11902
+ | `DiagnosticJournalFailurePhaseSchema` / `DiagnosticJournalFailurePhase` | schema / _type_ | internal `write \| rotation \| close` failure phase exposed only to status and the isolated observer |
11903
+ | `DiagnosticJournalWaitOptions` / `DiagnosticJournalFailure` | _type_ | caller wait signal/timeout and isolated internal failure callback record |
11904
+
11905
+ `accepted` is bounded in-memory admission and `written` is completed append, not `fsync` or durable
11906
+ delivery. The journal has no reader/replay/upload API. See the
11907
+ [guide](../guide/application-kernel.md#bounded-local-diagnostic-journal),
11908
+ [architecture](../architecture/diagnostic-journal.md) and [ADR
11909
+ 0134](../decisions/0134-diagnostic-journal-is-bounded-local-evidence.md).
11910
+
11715
11911
  ### Managed schedules
11716
11912
 
11717
11913
  | Export | Kind | Summary |
@@ -11823,6 +12019,21 @@ Server-only optional application runtime. See the
11823
12019
  | `createMemoryAgentRuntimeStore` | function | process-local reference adapter, not production durability |
11824
12020
  | `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid AI SDK messages |
11825
12021
  | `defineModelRegistry` | function | typed language-model descriptors, capabilities and provider construction |
12022
+ | `AgentModelCatalogSchema` / `AgentModelCatalog` | schema / _type_ | provider-neutral complete/partial model catalog with separately sourced popularity, metrics, prices and observation time |
12023
+ | `AgentModelCatalogEntrySchema` / `AgentModelCatalogEntry` | schema / _type_ | one canonical provider model descriptor with optional price, popularity and metric evidence |
12024
+ | `AgentModelPriceSchema` / `AgentModelPrice` | schema / _type_ | normalized per-token input/output pricing and source currency |
12025
+ | `AgentModelPopularitySchema` / `AgentModelPopularity` | schema / _type_ | independently sourced ranked popularity observation with window and timestamp |
12026
+ | `AgentModelMetricSchema` / `AgentModelMetric` | schema / _type_ | independently sourced benchmark measurement with provenance and observation time |
12027
+ | `AgentModelCatalogProvider` | _type_ | abortable live catalog loader supplied by a provider adapter or application |
12028
+ | `AgentModelSearchInputSchema` / `AgentModelSearchInput` | schema / _type_ | bounded catalog text query and result ceiling |
12029
+ | `AgentModelSearchResultSchema` / `AgentModelSearchResult` | schema / _type_ | exact bounded catalog projection with total match count |
12030
+ | `searchAgentModelCatalog` | function | deterministic bounded search over a loaded canonical catalog |
12031
+ | `AgentModelSelectionSchema` / `AgentModelSelection` / `AgentModelSelectionStore` | schema / _type_ | durable per-conversation model choice; runtime resolvers receive run and snapshot to recover the model pinned to input metadata |
12032
+ | `createMemoryAgentModelSelectionStore` | function | process-local selection reference adapter |
12033
+ | `AgentConversationReader` | _type_ | optional bounded conversation-summary and message-history reader; not part of the required runtime store contract |
12034
+ | `AgentConversationSummarySchema` / `AgentConversationSummary` | schema / _type_ | bounded durable conversation list item with version, activity and preview |
12035
+ | `AgentConversationPageSchema` / `AgentConversationPage` | schema / _type_ | cursor-paged conversation summaries |
12036
+ | `AgentConversationMessagePageSchema` / `AgentConversationMessagePage` | schema / _type_ | cursor-paged durable message history |
11826
12037
  | `composeAgentPrompt` | function | ordered prompt contributions and provenance-aware signed context budget; irreducible reservation deficits are `oversized`, not compactable history |
11827
12038
  | `structuredCompaction` | function | summarize a provider-valid snapshot range and replace it through CAS |
11828
12039
  | `createAgentSessionCoordinator` | function | strict process-local queue/interrupt/supersede lifecycle |
@@ -11926,7 +12137,10 @@ History and context-budget exports are `projectAgentHistoryDetailed`,
11926
12137
  `AgentPromptBudget`, `AgentPromptSection`, `AgentPromptSectionContext`, `AgentTokenCount`,
11927
12138
  `AgentTokenCountSchema`, `ComposeAgentPromptOptions` and `ComposedAgentPrompt`. Whole-turn history
11928
12139
  selection never splits a tool chronology and reports why every canonical record was retained or
11929
- removed.
12140
+ removed. `AgentHistoryEvidencePolicy` is the shared opt-in for marked failed-assistant evidence in
12141
+ projection, budgeting and structured compaction; `isAssistantHistoryEvidence` applies it. The
12142
+ compatibility default omits it. Approval message schemas are
12143
+ `AgentToolApprovalRequestPartSchema` and `AgentToolApprovalResponsePartSchema`.
11930
12144
 
11931
12145
  Model exports are `AgentLanguageModelProvider`, `AgentModelCapability`,
11932
12146
  `AgentModelCapabilitySchema`, `AgentModelDescriptor`,
@@ -11953,12 +12167,69 @@ Managed effects and operator telemetry additionally export `AgentToolFenceConfig
11953
12167
  may accompany checkpoint/terminal writes and tool context; internal causes are redacted unless an
11954
12168
  operator-only observability sink explicitly opts in.
11955
12169
 
12170
+ ## `stitchkit/agent-runtime/harness`
12171
+
12172
+ Server-only evolving facade over the canonical Agent runtime. It requires the optional `ai` peer
12173
+ and introduces no store, queue or model-provider implementation of its own.
12174
+
12175
+ | Export | Kind | Summary |
12176
+ |--------|------|---------|
12177
+ | `createHeadlessAgentHarness` | function | compose one `createAgentRuntime` with caller-supplied model resolution, bounded resources, tools and prompt policy; adds canonical `snapshot` |
12178
+ | `HeadlessAgentHarness` / `HeadlessAgentHarnessConfig` | _type_ | runtime facade and injected ownership boundary |
12179
+ | `HeadlessAgentModelResolver` | _type_ | per-run preflight/resolve port returning the actual `AgentResolvedModel` |
12180
+ | `AgentHarnessResourceSchema` / `AgentHarnessResource` | schema / _type_ | strict instruction, skill or resource with name, text and provenance |
12181
+ | `AgentHarnessResourceKindSchema` / `AgentHarnessResourceKind` | schema / _type_ | closed `instruction`, `skill` or `resource` vocabulary |
12182
+ | `AgentHarnessResourceResult` | _type_ | one loader result containing resources and diagnostics |
12183
+ | `AgentHarnessResourceDiagnosticSchema` / `AgentHarnessResourceDiagnostic` | schema / _type_ | bounded caller evidence; observer failure is isolated |
12184
+ | `AgentHarnessLimitsSchema` / `AgentHarnessLimits` | schema / _type_ | resource count, total UTF-8 bytes and diagnostic ceilings |
12185
+ | `AgentHarnessProfileEventSchema` / `AgentHarnessProfileEvent` | schema / _type_ | actual model descriptor, non-content resource provenance and sorted direct tool identities applied to one run |
12186
+ | `createAgentHarnessFileResources` | function | discover explicit instruction/skill/resource roots with symlink containment, bounded summaries and direct exact reads |
12187
+ | `AgentHarnessFileRootSchema` / `AgentHarnessFileRoot` | schema / _type_ | caller-owned absolute path, public root ID and resource kind |
12188
+ | `AgentHarnessFileLimitsSchema` / `AgentHarnessFileLimits` | schema / _type_ | file count, depth, per-file and aggregate byte ceilings |
12189
+ | `AgentHarnessFileResources` | _type_ | loader plus direct `read_resource` definition for lazy exact content |
12190
+ | `createAgentHarnessControlServer` | function | transport-neutral correlated requests, observer attachments and exclusive controller leases |
12191
+ | `AgentHarnessControlServer` / `AgentHarnessControlConnection` | _type_ | host server and detachable connection lifecycle; `deliver` is serialized, while required out-of-band `onOverflow` closes/aborts a slow transport before reconnect |
12192
+ | `AgentHarnessControlServerConfig` | _type_ | explicit per-connection pending-event bound for failure-isolated control delivery |
12193
+ | `AgentHarnessPendingApproval` / `AgentHarnessApprovalDecision` | _type_ | exact durable pending request and allow/deny successor input |
12194
+
12195
+ Resources default to at most 64 entries, 1 MiB of total UTF-8 text and 128 diagnostics. Duplicate
12196
+ names and exceeded bounds fail before the provider step. Recovery remains the underlying runtime's
12197
+ explicit policy; use the Bun or Node SQLite leaf for durable reopen.
12198
+
12199
+ ## `stitchkit/agent-runtime/coding-tools`
12200
+
12201
+ Server-only evolving, peer-free direct runtime tools. `createAgentCodingTools(config)` returns
12202
+ `read_file`, `write_file`, `search_files`, `apply_patch`, optional `run_command` and, when an
12203
+ artifact store is supplied, `read_output`.
12204
+
12205
+ | Export | Kind | Summary |
12206
+ |--------|------|---------|
12207
+ | `createAgentCodingTools` | function | construct direct host-authorized bounded file, search, guarded patch, shell and artifact runtime-tool definitions |
12208
+ | `AgentCodingToolDefinition` | _type_ | peer-free structural direct-tool shape accepted by the canonical runtime-tool surface |
12209
+ | `AgentCodingToolConfig` | _type_ | absolute root, required authorization callback, finite executable alias map, exact child environment and optional limits |
12210
+ | `AgentCodingToolAuthorizationSchema` / `AgentCodingToolAuthorization` | schema / _type_ | discriminated read/write/search/patch/shell/artifact decision presented to host policy before effect |
12211
+ | `AgentCodingToolLimitsSchema` / `AgentCodingToolLimits` | schema / _type_ | explicit path/read/write/argument-count/argument-byte/output/artifact/timeout ceilings |
12212
+ | `AgentCodingArtifactStore` | _type_ | host-owned opaque artifact write and bounded read boundary |
12213
+ | `FileReadInputSchema` / `FileReadOutputSchema` | schema | bounded strict-UTF-8 byte slice; offsets must align with UTF-8 code-point boundaries |
12214
+ | `FileWriteInputSchema` / `FileWriteOutputSchema` | schema | create-only by default or explicit atomic replacement; symlink targets fail closed |
12215
+ | `createShellInputSchema` / `ShellOutputSchema` | schema | enumerated executable alias plus arguments and concrete relative cwd; explicit exited/timeout/output-limit/cancelled outcome |
12216
+
12217
+ The default ceilings are 4,096 path bytes, 256 KiB read/write/output, 128 shell arguments, 64 KiB
12218
+ of aggregate argument text, 4 MiB per artifact and 30 seconds. The root is a path-resolution
12219
+ boundary, not an OS sandbox; executable behavior, process
12220
+ isolation, credentials and external-effect idempotency remain host responsibilities.
12221
+
11956
12222
  ## `stitchkit/agent-runtime/browser`
11957
12223
 
11958
12224
  Browser-safe canonical agent data. It re-exports the run, message, part, usage,
11959
12225
  terminal and provider-envelope schemas/types listed under
11960
12226
  `stitchkit/agent-runtime`, together with all runtime delivery event schemas,
11961
- `AgentRuntimeEventCursorSchema`, `advanceAgentRuntimeEventCursor` and
12227
+ `AgentRuntimeEventCursorSchema`, `advanceAgentRuntimeEventCursor`,
12228
+ `AgentControlRequestSchema` / `AgentControlRequest`, `AgentControlResponseSchema` /
12229
+ `AgentControlResponse`, `AgentControlDeliverySchema` / `AgentControlDelivery`, `AgentMultiSessionCursorSchema` /
12230
+ `AgentMultiSessionCursor`, `AgentConversationView`, `AgentControlView`,
12231
+ `advanceAgentMultiSessionCursor`, `createAgentControlView`, `reduceAgentControlSnapshot`,
12232
+ `reduceAgentControlEvent` and
11962
12233
  `agentDurableEventId`. It imports no model provider, executor, store, event sink
11963
12234
  or Node context module.
11964
12235
 
@@ -11972,7 +12243,9 @@ Use this entrypoint from client components and shared DTO packages. The full
11972
12243
  | Export | Kind | Summary |
11973
12244
  |--------|------|---------|
11974
12245
  | `openRouterProvider` | function | isolated `@openrouter/ai-sdk-provider` language-model factory |
12246
+ | `openRouterModelCatalog` | function | complete tool-capable text catalog plus independent weekly popularity and available benchmark observations |
11975
12247
  | `OpenRouterProviderSettings` | _type_ | official provider settings accepted by the factory |
12248
+ | `OpenRouterModelCatalogOptions` / `OpenRouterCatalogFetch` | _type_ | credential, timeout, clock and injected fetch boundary for catalog loading |
11976
12249
 
11977
12250
  ## `stitchkit/agent-runtime/sqlite/bun`
11978
12251
 
@@ -11981,13 +12254,55 @@ loaded by the neutral, browser or Node runtime surfaces.
11981
12254
 
11982
12255
  | Export | Kind | Summary |
11983
12256
  |--------|------|---------|
11984
- | `createBunSqliteAgentRuntimeStore` | function | open an owned Bun SQLite connection, initialize/validate schema v1 and return `{ store, close }` |
12257
+ | `createBunSqliteAgentRuntimeStore` | function | open an owned Bun SQLite connection, initialize/validate schema v1 and return `{ store, conversations, close }` |
11985
12258
  | `BunSqliteAgentRuntimeStoreConfig` | _type_ | database filename plus optional create and initialization policies |
11986
12259
  | `createSqliteAgentRuntimeStore` | function | build the normalized store over an injected synchronous SQLite boundary |
11987
12260
  | `initializeAgentRuntimeSqlite` | function | initialize or validate only Stitchkit's namespaced SQLite schema |
11988
12261
  | `AgentRuntimeSqliteDatabase` / `AgentRuntimeSqliteStatement` / `AgentRuntimeSqliteValue` | _type_ | minimal runtime-neutral synchronous SQLite boundary |
11989
12262
  | `SqliteAgentRuntimeStore` / `SqliteAgentRuntimeStoreConfig` | _type_ | durable store handle, owned connection lifecycle and initialization policy |
11990
12263
 
12264
+ ---
12265
+
12266
+ ## `@stitchkit/tui`
12267
+
12268
+ Separate optional evolving Bun/OpenTUI package over a caller-composed headless harness.
12269
+
12270
+ | Export | Kind | Summary |
12271
+ |--------|------|---------|
12272
+ | `defineAgentTui` | function | typed config for title/theme/status rows, model catalog, context, commands, runtime bundle and optional host-evidenced recovery policy; the default never requeues acquired effects |
12273
+ | `runAgentTui` | function | start one fresh durable conversation and terminal controller, recover durable work and publish its authenticated local session; `initialConversationId` is an explicit resume override |
12274
+ | `defineTuiCommand` / `resolveTuiCommand` | function | typed composable slash-command registry; unknown slash input remains an ordinary model prompt |
12275
+ | `createAgentTuiController` | function | single admission, selection, approval, interruption and conversation-switch owner over the harness |
12276
+ | `startAgentTuiSessionHost` / `createAgentTuiClient` | function | authenticated mode-`0600` Unix-socket host/client for status, submit and interrupt through that controller |
12277
+ | `listAgentTuiSessions` | function | discover live local terminal session IDs and their current conversation |
12278
+ | `createAgentTuiComposer` / `navigateAgentTuiHistory` | function | multiline draft and reversible prompt-history state |
12279
+ | `defaultAgentTuiStatusLine` / `AgentTuiStatusLineFormatter` | function / _type_ | terminal-native default rows and a host formatter over model capacity, durable snapshot, activity, workspace and local identities; `statusLine: false` hides the rows |
12280
+ | `createAgentTuiDiagnosticRecorder` / `AgentTuiDiagnosticEventSchema` | function / schema | bounded per-session metadata journal that rejects prompt, reasoning, tool-input and provider-cause payloads before disk admission |
12281
+
12282
+ The `stitchkit-agent` binary loads `stitchkit.agent.ts` by default and also exposes `sessions`,
12283
+ `status`, `send` and `interrupt`. `--workspace` addresses a host outside the caller's cwd,
12284
+ `send --idempotency-key` accepts caller-owned retry identity, and `interrupt` defaults to the
12285
+ active run returned by `status`. Session descriptors and sockets are local control credentials,
12286
+ not a remote API.
12287
+ Interactive `/resume` and `/sessions` open the durable conversation picker. `/clear` creates a new
12288
+ conversation and keeps the previous one available there; it is not a viewport-only operation.
12289
+ The slash palette owns its highlighted selection: Up/Down move it, Tab completes it, Enter runs
12290
+ the exact command and Escape dismisses it. Partial input is never submitted while the palette is
12291
+ active; unknown slash text with no match remains an ordinary model prompt.
12292
+
12293
+ ### `@stitchkit/tui/core`
12294
+
12295
+ Renderer-neutral state only. This entrypoint imports neither React/OpenTUI nor the agent runtime.
12296
+
12297
+ | Export | Kind | Summary |
12298
+ |--------|------|---------|
12299
+ | `createTerminalCollection` / `reduceTerminalCollection` | function | identity-stable live collection selection, reconciliation, windowing and resize |
12300
+ | `createTerminalFeedViewport` / `reduceTerminalFeedViewport` | function | generic follow-tail, history anchoring, unseen and bounded visible-range state |
12301
+ | `createTerminalPaneState` / `reduceTerminalPaneState` | function | bounded split-pane focus, resize and single-pane collapse |
12302
+ | `createTerminalCommandPalette` / `terminalCommandMatches` | function | bounded command filtering and keyboard selection over a collision-validated registry |
12303
+ | `resolveExactTerminalCommand` / `validateTerminalCommands` | function | exact dispatch and fail-closed name/alias validation |
12304
+ | `createTerminalOperationState` / `reduceTerminalOperationState` | function | confirmation and single-pending-operation lifecycle |
12305
+
11991
12306
  ## `stitchkit/agent-runtime/sqlite/node`
11992
12307
 
11993
12308
  Node 22.5+ built-in SQLite persistence. It shares the schema and semantics of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.68.11",
3
+ "version": "0.69.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",
@@ -84,6 +84,14 @@
84
84
  "types": "./dist/agent-runtime.d.ts",
85
85
  "import": "./dist/agent-runtime.js"
86
86
  },
87
+ "./agent-runtime/harness": {
88
+ "types": "./dist/agent-runtime-harness.d.ts",
89
+ "import": "./dist/agent-runtime-harness.js"
90
+ },
91
+ "./agent-runtime/coding-tools": {
92
+ "types": "./dist/agent-runtime-coding-tools.d.ts",
93
+ "import": "./dist/agent-runtime-coding-tools.js"
94
+ },
87
95
  "./agent-runtime/browser": {
88
96
  "types": "./dist/agent-runtime-browser.d.ts",
89
97
  "import": "./dist/agent-runtime-browser.js"
@@ -135,7 +143,7 @@
135
143
  "scripts": {
136
144
  "check": "bun x tsc --noEmit",
137
145
  "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",
138
- "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/agent-runtime-sqlite-bun.ts src/agent-runtime-sqlite-node.ts src/application.ts src/application-grammy.ts src/application-opentelemetry.ts --outdir dist --target node --packages external --splitting --root src",
146
+ "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-harness.ts src/agent-runtime-coding-tools.ts src/agent-runtime-openrouter.ts src/agent-runtime-sqlite-bun.ts src/agent-runtime-sqlite-node.ts src/application.ts src/application-grammy.ts src/application-opentelemetry.ts --outdir dist --target node --packages external --splitting --root src",
139
147
  "build:js": "bun run build:browser && bun run build:server && bun scripts/preserve-webpack-ignore.mjs",
140
148
  "build:types": "bun x tsc -p tsconfig.build.json --emitDeclarationOnly && bun scripts/rewrite-declaration-specifiers.mjs",
141
149
  "build": "rm -rf dist && bun run build:js && bun run build:types && bun scripts/check-browser-clean.mjs && bun scripts/check-env-live.mjs && bun scripts/check-public-types.mjs",
@@ -1,9 +1,9 @@
1
- import {
2
- isRecord
3
- } from "./index-qyrqwr4c.js";
4
1
  import {
5
2
  AppError
6
3
  } from "./index-0w9abg87.js";
4
+ import {
5
+ isRecord
6
+ } from "./index-qyrqwr4c.js";
7
7
 
8
8
  // src/contract/define.ts
9
9
  import { z } from "zod";