stitchkit 0.103.13 → 0.104.1

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 (223) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/darwin-native.cjs +1 -3
  3. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
  4. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  5. package/dist/application/directory-inbox-accept.d.ts +13 -0
  6. package/dist/application/directory-inbox-accept.d.ts.map +1 -0
  7. package/dist/application/directory-inbox-contract.d.ts +42 -5
  8. package/dist/application/directory-inbox-contract.d.ts.map +1 -1
  9. package/dist/application/directory-inbox-delivery.d.ts +14 -0
  10. package/dist/application/directory-inbox-delivery.d.ts.map +1 -0
  11. package/dist/application/directory-inbox-files.d.ts +28 -0
  12. package/dist/application/directory-inbox-files.d.ts.map +1 -0
  13. package/dist/application/directory-inbox-state.d.ts +14 -0
  14. package/dist/application/directory-inbox-state.d.ts.map +1 -0
  15. package/dist/application/directory-inbox.d.ts +2 -1
  16. package/dist/application/directory-inbox.d.ts.map +1 -1
  17. package/dist/application/file-state-store.d.ts +2 -8
  18. package/dist/application/file-state-store.d.ts.map +1 -1
  19. package/dist/application/state-store.d.ts +6 -1
  20. package/dist/application/state-store.d.ts.map +1 -1
  21. package/dist/browser/client-arguments.d.ts +4 -0
  22. package/dist/browser/client-arguments.d.ts.map +1 -0
  23. package/dist/browser/client-executors.d.ts.map +1 -1
  24. package/dist/browser/client.d.ts.map +1 -1
  25. package/dist/browser/contract-stream.d.ts.map +1 -1
  26. package/dist/browser/http.d.ts +2 -1
  27. package/dist/browser/http.d.ts.map +1 -1
  28. package/dist/browser/native-fetch.d.ts +8 -0
  29. package/dist/browser/native-fetch.d.ts.map +1 -0
  30. package/dist/contract/errors.d.ts +16 -12
  31. package/dist/contract/errors.d.ts.map +1 -1
  32. package/dist/contract/normalize.d.ts +5 -1
  33. package/dist/contract/normalize.d.ts.map +1 -1
  34. package/dist/contract/stream.d.ts +1 -0
  35. package/dist/contract/stream.d.ts.map +1 -1
  36. package/dist/entrypoints/agent-runtime/browser.js +3 -3
  37. package/dist/entrypoints/agent-runtime/coding-tools.js +6 -6
  38. package/dist/entrypoints/agent-runtime/harness-tools.js +8 -8
  39. package/dist/entrypoints/agent-runtime/harness.js +11 -11
  40. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  41. package/dist/entrypoints/agent-runtime/sandbox.js +6 -6
  42. package/dist/entrypoints/agent-runtime.js +13 -13
  43. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  44. package/dist/entrypoints/application/directory-inbox.js +424 -119
  45. package/dist/entrypoints/application/grammy.js +1 -1
  46. package/dist/entrypoints/application.d.ts +2 -2
  47. package/dist/entrypoints/application.d.ts.map +1 -1
  48. package/dist/entrypoints/application.js +7 -3
  49. package/dist/entrypoints/cli.d.ts +2 -0
  50. package/dist/entrypoints/cli.d.ts.map +1 -1
  51. package/dist/entrypoints/cli.js +757 -136
  52. package/dist/entrypoints/contract.js +3 -3
  53. package/dist/entrypoints/files/packaging.d.ts +3 -0
  54. package/dist/entrypoints/files/packaging.d.ts.map +1 -0
  55. package/dist/entrypoints/files/packaging.js +133 -0
  56. package/dist/entrypoints/files.js +10 -107
  57. package/dist/entrypoints/index.js +7 -7
  58. package/dist/entrypoints/node.js +8 -8
  59. package/dist/entrypoints/observability.js +2 -2
  60. package/dist/entrypoints/react.js +1 -1
  61. package/dist/entrypoints/remote.js +19 -6
  62. package/dist/entrypoints/server.d.ts +1 -1
  63. package/dist/entrypoints/server.d.ts.map +1 -1
  64. package/dist/entrypoints/server.js +23 -17
  65. package/dist/entrypoints/telegram.d.ts +1 -0
  66. package/dist/entrypoints/telegram.d.ts.map +1 -1
  67. package/dist/entrypoints/telegram.js +214 -98
  68. package/dist/entrypoints/testing.js +7 -7
  69. package/dist/entrypoints/tools/connections.d.ts +2 -2
  70. package/dist/entrypoints/tools/connections.d.ts.map +1 -1
  71. package/dist/entrypoints/tools/connections.js +427 -294
  72. package/dist/entrypoints/tools/invoker.js +6 -6
  73. package/dist/entrypoints/tools/mcp.d.ts +12 -0
  74. package/dist/entrypoints/tools/mcp.d.ts.map +1 -0
  75. package/dist/entrypoints/tools/mcp.js +45 -0
  76. package/dist/entrypoints/tools.d.ts +1 -0
  77. package/dist/entrypoints/tools.d.ts.map +1 -1
  78. package/dist/entrypoints/tools.js +82 -1147
  79. package/dist/entrypoints/tracking.js +1 -1
  80. package/dist/files/boundary.d.ts +2 -8
  81. package/dist/files/boundary.d.ts.map +1 -1
  82. package/dist/files/file-io.d.ts +0 -5
  83. package/dist/files/file-io.d.ts.map +1 -1
  84. package/dist/files/native-packaging-layout.d.ts +12 -0
  85. package/dist/files/native-packaging-layout.d.ts.map +1 -0
  86. package/dist/files/native-packaging.d.ts +72 -0
  87. package/dist/files/native-packaging.d.ts.map +1 -0
  88. package/dist/files/read.d.ts +2 -2
  89. package/dist/files/read.d.ts.map +1 -1
  90. package/dist/index-1a6jtnd9.js +88 -0
  91. package/dist/index-269zqj8m.js +77 -0
  92. package/dist/{index-r34mvse1.js → index-27a2pj09.js} +1 -1
  93. package/dist/{index-r956rndn.js → index-2hyavjjj.js} +3 -3
  94. package/dist/{index-m2xqkv55.js → index-2vnh05w4.js} +83 -14
  95. package/dist/{index-pw99k9h5.js → index-43p08g7t.js} +1 -1
  96. package/dist/{index-xwq9j1sf.js → index-4e0ah203.js} +9 -7
  97. package/dist/{index-qapzv4p5.js → index-5z6jn897.js} +1 -1
  98. package/dist/{index-ahvsksw5.js → index-6d9xaxw1.js} +1 -1
  99. package/dist/{index-8zfsgar0.js → index-6drst9sg.js} +11 -5
  100. package/dist/{index-x87j7csh.js → index-77nxk6ay.js} +2 -2
  101. package/dist/{index-dnn9z96q.js → index-a0zzh8ak.js} +3 -3
  102. package/dist/{index-kmpzj1cq.js → index-a3wma1hk.js} +1 -1
  103. package/dist/{index-j8aw2c0e.js → index-bakgedh8.js} +35 -7
  104. package/dist/index-bhb950qs.js +1145 -0
  105. package/dist/{index-tgzhq07n.js → index-cvda079a.js} +1 -1
  106. package/dist/{index-n2gre124.js → index-fa4wg312.js} +4 -4
  107. package/dist/{index-zp4jpkp0.js → index-fk18k56k.js} +2 -2
  108. package/dist/{index-afjvjyck.js → index-g2j7pnak.js} +2 -134
  109. package/dist/index-g95fk660.js +116 -0
  110. package/dist/{index-r5c4fedv.js → index-h2fhjqy7.js} +2 -1
  111. package/dist/{index-sybedc8b.js → index-hbd32c6a.js} +23 -94
  112. package/dist/{index-fyphpknh.js → index-hp9d77wk.js} +1 -1
  113. package/dist/index-jd470k6q.js +109 -0
  114. package/dist/{index-b2bz0kdm.js → index-kb8styz3.js} +4 -3
  115. package/dist/{index-0c419yx7.js → index-kemm0ej5.js} +12 -9
  116. package/dist/{index-db2spkv1.js → index-ptn0g0gj.js} +3 -3
  117. package/dist/{index-w575evhq.js → index-r4r70zmh.js} +1 -1
  118. package/dist/{index-12m2v2a9.js → index-s4evrmp5.js} +1 -1
  119. package/dist/{index-1khy8y7n.js → index-t1sr4aks.js} +3 -3
  120. package/dist/{index-45tdvqa3.js → index-wh0ecvyk.js} +1 -1
  121. package/dist/{index-n53mswt3.js → index-x928baz2.js} +8 -1
  122. package/dist/index-yk4g8805.js +133 -0
  123. package/dist/{index-ygkka6zn.js → index-ywppsaby.js} +28 -5
  124. package/dist/{index-9853ymwb.js → index-za6j7nwy.js} +18 -4
  125. package/dist/internal/bounded-file-read.d.ts +41 -0
  126. package/dist/internal/bounded-file-read.d.ts.map +1 -0
  127. package/dist/internal/exclusive-lock.d.ts +2 -0
  128. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  129. package/dist/internal/with-exclusive-lock.d.ts +4 -2
  130. package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
  131. package/dist/telegram/broadcast-delivery.d.ts +23 -0
  132. package/dist/telegram/broadcast-delivery.d.ts.map +1 -0
  133. package/dist/telegram/broadcast-failure.d.ts +22 -0
  134. package/dist/telegram/broadcast-failure.d.ts.map +1 -0
  135. package/dist/telegram/broadcast-state.d.ts +6 -3
  136. package/dist/telegram/broadcast-state.d.ts.map +1 -1
  137. package/dist/telegram/broadcast.d.ts +10 -5
  138. package/dist/telegram/broadcast.d.ts.map +1 -1
  139. package/dist/tools/cli/format.d.ts.map +1 -1
  140. package/dist/tools/cli/invoke.d.ts +2 -2
  141. package/dist/tools/cli/invoke.d.ts.map +1 -1
  142. package/dist/tools/cli/publication-assets.d.ts +10 -0
  143. package/dist/tools/cli/publication-assets.d.ts.map +1 -0
  144. package/dist/tools/cli/publication-contract.d.ts +75 -0
  145. package/dist/tools/cli/publication-contract.d.ts.map +1 -0
  146. package/dist/tools/cli/publication-control.d.ts +4 -0
  147. package/dist/tools/cli/publication-control.d.ts.map +1 -0
  148. package/dist/tools/cli/publication-storage.d.ts +32 -0
  149. package/dist/tools/cli/publication-storage.d.ts.map +1 -0
  150. package/dist/tools/cli/publication.d.ts +35 -0
  151. package/dist/tools/cli/publication.d.ts.map +1 -0
  152. package/dist/tools/cli/update.d.ts.map +1 -1
  153. package/dist/tools/connections/define.d.ts.map +1 -1
  154. package/dist/tools/connections/error-projection.d.ts +4 -0
  155. package/dist/tools/connections/error-projection.d.ts.map +1 -0
  156. package/dist/tools/connections/errors.d.ts +24 -8
  157. package/dist/tools/connections/errors.d.ts.map +1 -1
  158. package/dist/tools/connections/limits.d.ts +11 -31
  159. package/dist/tools/connections/limits.d.ts.map +1 -1
  160. package/dist/tools/connections/mcp-client.d.ts +6 -4
  161. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  162. package/dist/tools/connections/mcp.d.ts.map +1 -1
  163. package/dist/tools/connections/openapi.d.ts.map +1 -1
  164. package/dist/tools/connections/operation-limits.d.ts +25 -0
  165. package/dist/tools/connections/operation-limits.d.ts.map +1 -0
  166. package/dist/tools/connections/sse-frames.d.ts +11 -2
  167. package/dist/tools/connections/sse-frames.d.ts.map +1 -1
  168. package/dist/tools/connections/sse-session.d.ts +15 -2
  169. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  170. package/dist/tools/connections/types.d.ts +19 -1
  171. package/dist/tools/connections/types.d.ts.map +1 -1
  172. package/dist/tools/execute-result.d.ts.map +1 -1
  173. package/dist/tools/execute.d.ts.map +1 -1
  174. package/dist/tools/internal/observe-hook.d.ts +3 -0
  175. package/dist/tools/internal/observe-hook.d.ts.map +1 -0
  176. package/dist/tools/internal/surface-projector.d.ts +2 -1
  177. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  178. package/dist/tools/mcp/mount.d.ts +2 -2
  179. package/dist/tools/mcp/mount.d.ts.map +1 -1
  180. package/dist/tools/mcp/prepare.d.ts +4 -5
  181. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  182. package/dist/tools/mcp/register.d.ts +4 -1
  183. package/dist/tools/mcp/register.d.ts.map +1 -1
  184. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  185. package/dist/tools/remote.d.ts.map +1 -1
  186. package/dist/tools/runtime-tool-execution.d.ts +65 -0
  187. package/dist/tools/runtime-tool-execution.d.ts.map +1 -0
  188. package/dist/tools/runtime-tool-mcp.d.ts +27 -0
  189. package/dist/tools/runtime-tool-mcp.d.ts.map +1 -0
  190. package/dist/tools/runtime-tool.d.ts +9 -60
  191. package/dist/tools/runtime-tool.d.ts.map +1 -1
  192. package/dist/tools/surface.d.ts +12 -14
  193. package/dist/tools/surface.d.ts.map +1 -1
  194. package/llms/application.2.txt +221 -44
  195. package/llms/application.3.txt +3 -1
  196. package/llms/application.txt +1 -1
  197. package/llms/cli.2.txt +144 -1
  198. package/llms/cli.txt +123 -104
  199. package/llms/contract.txt +1 -1
  200. package/llms/files-packaging.txt +27 -0
  201. package/llms/process.txt +63 -1
  202. package/llms/server.4.txt +4 -1
  203. package/llms/server.5.txt +1 -0
  204. package/llms/stitchkit.2.txt +14 -0
  205. package/llms/stitchkit.txt +6 -4
  206. package/llms/telegram.txt +64 -2
  207. package/llms/tools-connections.txt +3 -0
  208. package/llms/tools-mcp.txt +29 -0
  209. package/llms/tools.2.txt +59 -0
  210. package/llms/tools.3.txt +1 -0
  211. package/llms/tools.txt +11 -52
  212. package/llms/upgrading-0.37.0-0.44.0.txt +444 -0
  213. package/llms/{upgrading-0.44.0-0.60.0.txt → upgrading-0.44.0-0.61.0.txt} +140 -271
  214. package/llms/{upgrading-0.61.0-0.74.0.txt → upgrading-0.62.0-0.80.0.txt} +217 -140
  215. package/llms/{upgrading-0.75.0-0.103.0.txt → upgrading-0.81.0-0.104.0.txt} +154 -217
  216. package/llms/upgrading.txt +4 -4
  217. package/llms-full.txt +745 -60
  218. package/llms.txt +14 -12
  219. package/native-assets.json +8 -0
  220. package/package.json +12 -3
  221. package/dist/index-wykebpn9.js +0 -221
  222. package/llms/upgrading-0.37.0.txt +0 -176
  223. package/dist/{index-69nvze1q.js → index-pptyv13k.js} +3 -3
@@ -1,14 +1,151 @@
1
- # Upgrading 0.44.0 → 0.60.0 — stitchkit docs slice
1
+ # Upgrading 0.44.0 → 0.61.0 — stitchkit docs slice
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
5
 
6
- Contains: Guide: Upgrading, 0.44.0 → 0.60.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.44.0 → 0.61.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.44.0 → 0.60.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.44.0 → 0.61.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.61.0
13
+
14
+ Three behaviour changes between versions. None moves an export — the surface is
15
+ strictly additive — and all three change what a running system does, which is
16
+ what this heading is for.
17
+
18
+ ### A failed `start()` now drains before it rejects
19
+
20
+ The rollback of a failed startup used to close every resource with a zero
21
+ budget: it returned almost at once, by severing requests the server had already
22
+ accepted. It now spends the application's shutdown budget, so a request already
23
+ in flight is answered rather than killed.
24
+
25
+ **What to check.** Nothing, if a failed startup has nothing in flight — the
26
+ rollback still returns immediately. The case to think about is a request that
27
+ never finishes: a hung upstream, a client ignoring a close frame, a streaming
28
+ subscription. Under the default 30s grace and 5s force, a `start()` that used to
29
+ reject in milliseconds can now take 35 seconds to reject.
30
+
31
+ If a fast failure matters more than draining — a supervisor waiting to restart,
32
+ a boot check in CI — declare a smaller budget. The same field is the default for
33
+ `shutdown()` with no options, so this is one decision, not two:
34
+
35
+ ```ts
36
+ // before
37
+ createApplication({ id: 'app', resources })
38
+
39
+ // after
40
+ createApplication({
41
+ id: 'app',
42
+ resources,
43
+ shutdown: { gracePeriodMs: 5_000, forceTimeoutMs: 1_000 },
44
+ })
45
+ ```
46
+
47
+ The budget is a real bound: a `close` that never returns is abandoned when it
48
+ runs out and reported as a `close` failure, and the startup error remains the
49
+ `cause` of the `AggregateError` `start()` rejects with. → ADR 0107
50
+
51
+ ### A refused realtime frame now answers its sender
52
+
53
+ A frame that fails the receiver's `args` schema used to be dropped where it
54
+ landed. If the event carries an acknowledgement, the receiver now answers it
55
+ with a reserved envelope and the sender's `request()` rejects at once with
56
+ `RealtimeRequestRejectedError`. → ADR 0106
57
+
58
+ **What to check before you upgrade one half of a distributed pair.** Look at the
59
+ `ack` schemas on the OLDER peer:
60
+
61
+ ```ts
62
+ // safe: a contract-first acknowledgement refuses the envelope, so the older
63
+ // peer raises RealtimeRequestInvalidAcknowledgementError at once instead of
64
+ // waiting out its deadline. Different error, still an error, and sooner.
65
+ ack: z.object({ stored: z.boolean() })
66
+
67
+ // NOT safe: a schema that validates nothing accepts the refusal AS A VALUE.
68
+ // The older peer reads a refusal as a successful acknowledgement — silently.
69
+ ack: z.unknown()
70
+ ack: z.looseObject({})
71
+ ```
72
+
73
+ If any acknowledgement on the older side is permissive, tighten it before the
74
+ rollout, or upgrade both halves together.
75
+
76
+ Also: the receiver now invokes the peer's raw acknowledgement callback for a
77
+ refused frame, including when the peer is a plain Socket.IO client. That
78
+ callback previously could not run on a refused frame and now can.
79
+
80
+ `RealtimeRejectedEvent['reason']` gained `'rejected-by-peer'`. If you `switch`
81
+ over it exhaustively with an `assertNever` default, that stops compiling — add
82
+ the case.
83
+
84
+ ### Two smaller behaviour changes, easy to miss
85
+
86
+ **`streamSSE`'s `cancel` no longer awaits the generator.** Teardown is now
87
+ unordered relative to request completion. If your generator releases a resource
88
+ in `return()`/`finally` — a temp file, a pooled connection — and anything
89
+ downstream assumed that had finished by the time the response settled, it no
90
+ longer has. Release in the generator's own `finally` and do not depend on the
91
+ ordering.
92
+
93
+ **A `socket.io-client` peer that cannot load no longer kills the process.** With
94
+ `onConnectError` configured, the failure is delivered there with
95
+ `terminal: true` instead of crashing. If your handler logs and moves on, you now
96
+ have a live process whose client will never connect, where a supervisor used to
97
+ restart it. Treat `terminal: true` as fatal if that is what you want.
98
+
99
+ ### `reportHealth` inside `start` is no longer discarded
100
+
101
+ Becoming ready assigned `healthy` unconditionally, throwing away whatever a
102
+ resource reported during `start`. It is now kept, and only a resource that
103
+ reported nothing is assumed healthy.
104
+
105
+ **How to find what this touches:** grep your `start` bodies for **every**
106
+ `reportHealth` call, not only the ones reporting `degraded`. The old
107
+ unconditional assignment was also a repair — a resource that reported
108
+ `'unhealthy'` early in `start` and never corrected itself was quietly fixed up
109
+ on the way to ready.
110
+
111
+ Two cases, and they need opposite fixes.
112
+
113
+ **1. A resource that is genuinely expected to start degraded** — up, but still
114
+ dialling something external. `required` defaults to **`true`**, and readiness
115
+ requires every required resource to be healthy, so such a resource now refuses
116
+ the whole startup where before its report vanished. That is the invariant
117
+ working as intended; what changed is that it can be reached. Say what it is:
118
+
119
+ ```ts
120
+ // before: started, and its report was discarded
121
+ defineManagedResource({ id: 'dialling', start: ({ reportHealth }) => reportHealth('degraded') })
122
+
123
+ // after: says what it is, and does not gate the application
124
+ defineManagedResource({ id: 'dialling', required: false, start: ({ reportHealth }) => reportHealth('degraded') })
125
+ ```
126
+
127
+ **2. A resource that reported `'unhealthy'` early and became healthy later** —
128
+ a pessimistic report before a connection settled. Here `required: false` is the
129
+ **wrong** fix: it would hide a real failure. Report the recovery instead:
130
+
131
+ ```ts
132
+ start: async ({ reportHealth }) => {
133
+ reportHealth('unhealthy')
134
+ await connect()
135
+ reportHealth('healthy') // ← previously unnecessary; now it is the fix
136
+ }
137
+ ```
138
+
139
+ **Also check your health endpoint.** An **optional** resource reporting
140
+ non-healthy during `start` now moves the application aggregate to `degraded`,
141
+ where before it stayed `healthy`. A readiness probe that maps `degraded` to a
142
+ non-200 will flip on upgrade — and a supervisor that restarts on that will loop.
143
+
144
+ The refusals now say which of the two happened: a resource that was never
145
+ healthy is told it "is not healthy" and pointed at `required: false`; one that
146
+ was healthy and stopped is told it "lost readiness" and pointed at
147
+ `onResourceFailure`.
148
+
12
149
  ## Released migration: 0.60.0
13
150
 
14
151
  ### close() says what it achieved
@@ -965,271 +1102,3 @@ implemented or advertised.
965
1102
  only if `legacy: 'serve'` is part of your support policy.
966
1103
  8. Run the consumer's typecheck and runtime gates. A browser/HTTP-only consumer
967
1104
  must continue to work without either MCP package.
968
-
969
- ## Historical breaking migrations through 0.44.0
970
-
971
- HTTP observability now completes inside the framework handler instead of a
972
- nested fetch wrapper. Configure request and tool sinks explicitly:
973
-
974
- ```ts
975
- // before
976
- const audit = createAuditHook({ write })
977
- createServer({
978
- services,
979
- wrapFetch: (handler) => wrapInRequestContext(audit.http(handler)),
980
- })
981
- mountAgent(services, { hooks: audit.toolCall })
982
-
983
- // after
984
- const observability = createObservability({
985
- request: { write, includePayload: true },
986
- tools: { write },
987
- })
988
- createServer({ services, observability: observability.request })
989
- mountAgent(services, { hooks: observability.toolCall })
990
- ```
991
-
992
- Body capture changed from always-on for body methods to opt-in. Set
993
- `includePayload: true` only when the request sink needs the sanitized JSON body.
994
- There is no `createAuditHook` or `audit.http` compatibility path;
995
- `wrapInRequestContext` remains only for custom fetch pipelines.
996
-
997
- Tool introspection now accepts one object-shaped contract/runtime surface. Stop
998
- calling the internal contract collector or merging a locally converted runtime
999
- manifest:
1000
-
1001
- ```ts
1002
- // before
1003
- buildToolManifest(services.flatMap((service) => collectTools(service, 'AGENT')))
1004
- listToolNames(services)
1005
- summarizeTransports(services)
1006
-
1007
- // after
1008
- const surface = { services, runtimeTools }
1009
- buildToolManifest({ ...surface, transport: 'AGENT' })
1010
- listToolNames(surface)
1011
- summarizeTransports(surface)
1012
- ```
1013
-
1014
- `ToolNameEntry` adds `kind: 'contract' | 'runtime'`. `TransportSummary` is now
1015
- `{ contractServices, runtimeTools, totals, sources }`; replace `services` and
1016
- `perService` reads with the explicit counts and mixed-source breakdown. There
1017
- is no positional overload and no `buildRuntimeToolManifest`: Stitchkit owns the
1018
- combined order, transport filtering, canonical presentation schema and
1019
- cross-origin collision checks.
1020
-
1021
- `defineErrors` now uses one Zod-first definition object and returns constructors
1022
- instead of positional throwers. Add explicit `throw`, move message/details/hint
1023
- into one options object, and declare a details schema when that code carries
1024
- structured context:
1025
-
1026
- ```ts
1027
- // before
1028
- const { errors } = defineErrors({ QUOTA_EXCEEDED: 429 })
1029
- errors.QUOTA_EXCEEDED('Try later', { retryAfterSeconds: 30 }, 'Wait')
1030
-
1031
- // after
1032
- const { errors, definitions } = defineErrors({
1033
- QUOTA_EXCEEDED: {
1034
- status: 429,
1035
- details: z.object({ retryAfterSeconds: z.number().positive() }),
1036
- },
1037
- })
1038
- throw errors.QUOTA_EXCEEDED({
1039
- message: 'Try later',
1040
- details: { retryAfterSeconds: 30 },
1041
- hint: 'Wait',
1042
- })
1043
- ```
1044
-
1045
- There is no positional overload. A code without `details` forbids them; use an
1046
- optional object schema when the details object itself is optional. Read status
1047
- and schemas from the frozen `definitions` registry instead of maintaining a
1048
- parallel map.
1049
-
1050
- Managed MCP runtime tools are now declared as immutable data. Move protected
1051
- registrar calls to `runtimeTools`; rename deliberate raw SDK registration to
1052
- `rawTools`. There is no registrar alias:
1053
-
1054
- ```ts
1055
- // before — protected
1056
- createMcpHandler({
1057
- services,
1058
- nativeTools: ({ registerTool }) => registerTool(preview),
1059
- })
1060
-
1061
- // after — protected and prepared with the rest of the surface
1062
- createMcpHandler({ services, runtimeTools: [preview] })
1063
-
1064
- // before — deliberate raw SDK opt-out
1065
- nativeTools: ({ rawServer }, auth) => mountRaw(rawServer, auth)
1066
-
1067
- // after — still a deliberate raw SDK opt-out
1068
- rawTools: (server, auth) => mountRaw(server, auth)
1069
- ```
1070
-
1071
- When identity selects from a bounded set, replace a repeatedly prepared
1072
- `services(auth)` factory with a finite registry:
1073
-
1074
- ```ts
1075
- createMcpHandler({
1076
- surfaces: {
1077
- admin: { services: allServices, runtimeTools: [preview] },
1078
- member: { services: memberServices, runtimeTools: [preview] },
1079
- },
1080
- selectSurface: (auth) => auth.isAdmin ? 'admin' : 'member',
1081
- })
1082
- ```
1083
-
1084
- Keep direct `services(auth)` / `runtimeTools(auth)` only for genuinely
1085
- unbounded definitions; Stitchkit intentionally does not cache arbitrary auth
1086
- values.
1087
-
1088
- Contract success bodies are now determined by the presence of `output`, not by
1089
- the handler's runtime value. A nullable output returns JSON `null` with status
1090
- `200`; `undefined` with a declared output and non-null data without an output
1091
- schema are contract violations:
1092
-
1093
- ```ts
1094
- // nullable JSON data: 200 with body `null`
1095
- session: {
1096
- method: 'GET', path: '/session', desc: 'Current session',
1097
- output: SessionSchema.nullable(),
1098
- }
1099
-
1100
- // bodyless operation: 204 with no body
1101
- logout: {
1102
- method: 'POST', path: '/logout', desc: 'End the session',
1103
- }
1104
- ```
1105
-
1106
- Add an output schema to every handler that returns data. Omit `output` and
1107
- return nothing for bodyless operations; runtime tools follow the same rule and
1108
- type no-output handlers as `void`.
1109
-
1110
- `createToolInvoker` now separates immutable registry preparation from per-call
1111
- runtime state. Move source/context/lifecycle/hooks/output-strip reporting from
1112
- the factory config to the third invocation argument. Use `invokeOrThrow` when a
1113
- nested operation should preserve the normalized `AppError` instead of returning
1114
- a model-facing failure envelope:
1115
-
1116
- ```ts
1117
- // before
1118
- const invoker = createToolInvoker(services, {
1119
- transport: 'AGENT', context: { identity }, lifecycle, hooks,
1120
- })
1121
- const result = await invoker.invoke(name, args)
1122
-
1123
- // after
1124
- const invoker = createToolInvoker(services, { transport: 'AGENT' })
1125
- const result = await invoker.invoke(name, args, {
1126
- context: { identity }, lifecycle, hooks,
1127
- })
1128
- const data = await invoker.invokeOrThrow(name, args, {
1129
- context: { identity }, lifecycle, hooks,
1130
- })
1131
- ```
1132
-
1133
- There is no static runtime-config overload: request identity must not be retained
1134
- by a reusable compiled registry.
1135
-
1136
- Entity cache handlers now require the cached list shape and CRUD policies. Move
1137
- `listKey` under `list`, make detail keys event-aware, and state the list-item
1138
- identity/projection explicitly:
1139
-
1140
- ```ts
1141
- // before
1142
- createEntityCacheHandlers<Entity>({
1143
- getId,
1144
- listKey: ['entities'],
1145
- detailKey: (id) => ['entities', id],
1146
- })
1147
-
1148
- // after
1149
- createEntityCacheHandlers<Entity, EntityListItem>({
1150
- getId,
1151
- getListItemId: (item) => item.id,
1152
- toListItem: (entity) => ({ id: entity.id, name: entity.name }),
1153
- list: {
1154
- key: ['entities'],
1155
- shape: 'paginated',
1156
- createAt: 'start',
1157
- updateMissing: 'skip',
1158
- },
1159
- detailKey: (event) => ['entities', event.id],
1160
- })
1161
- ```
1162
-
1163
- Choose `array`, `paginated`, `infinite-array` or `infinite-paginated` to match
1164
- the actual cached data. A dynamic `list.key` / `detailKey` receives a
1165
- discriminated event and can derive scoped keys from the created/updated entity
1166
- or deleted payload. Add `compare` only when the backend has a canonical order;
1167
- the framework does not guess it or mutate pagination metadata.
1168
-
1169
- Protected native MCP operations now use the transport-neutral runtime tool
1170
- definition. Return the schema-owned value from the handler and move MCP content
1171
- or metadata into `present.mcp`; `structuredContent` and `isError` are
1172
- framework-owned:
1173
-
1174
- ```ts
1175
- // before
1176
- registerTool({ input, output, handler: async () => ({
1177
- content: [{ type: 'image', data, mimeType: 'image/png' }],
1178
- structuredContent: { assetId },
1179
- }) })
1180
-
1181
- // after
1182
- const preview = defineRuntimeTool({
1183
- name: 'render_preview', description, identity, input, output,
1184
- handler: async () => ({ assetId, data }),
1185
- present: {
1186
- mcp: (result) => ({
1187
- content: [{ type: 'image', data: result.data, mimeType: 'image/png' }],
1188
- }),
1189
- },
1190
- })
1191
- runtimeTools: [preview]
1192
- ```
1193
-
1194
- The removed `NativeMcp*` types have no aliases. Use `RuntimeToolDefinition`,
1195
- `RuntimeToolIdentity`, `RuntimeToolHandlerContext` and
1196
- `RuntimeMcpPresentation`. The same definition can now be passed to
1197
- `mountAgent(services, { runtimeTools: [preview] })`; add `present.agent` only
1198
- when the model needs rich text/file content instead of the neutral JSON result.
1199
-
1200
- Trailing wildcards must be named consistently across the path and params schema:
1201
-
1202
- ```ts
1203
- // before
1204
- path: '/app/:slug/*'
1205
- params: z.object({ slug: z.string(), '*': z.string() })
1206
- ctx.params['*']
1207
- api.app({ slug: 'foo', '*': 'a/b' })
1208
-
1209
- // after
1210
- path: '/app/:slug/*filePath'
1211
- params: z.object({ slug: z.string(), filePath: z.string() })
1212
- ctx.params.filePath
1213
- api.app({ slug: 'foo', filePath: 'a/b' })
1214
- ```
1215
-
1216
- Bare wildcards have no compatibility alias; raw routes use the same named form.
1217
-
1218
- ### Expected-401 matchers
1219
-
1220
- `HttpClientConfig.authEndpoints` is removed. Replace manual path prefixes with
1221
- the operations whose 401 response is expected:
1222
-
1223
- ```ts
1224
- // before
1225
- createHttpClient({ baseUrl, authEndpoints: ['/api/auth/'] })
1226
-
1227
- // after
1228
- createHttpClient({
1229
- baseUrl,
1230
- suppressUnauthorizedFor: contractEndpointMatchers(authContract, ['login', 'verify']),
1231
- })
1232
- ```
1233
-
1234
- There is no implicit `/auth/` suppression. Omit `suppressUnauthorizedFor` when
1235
- every 401 should emit the global `unauthorized` event.