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,165 @@
1
- # Upgrading 0.75.0 → 0.103.0 — stitchkit docs slice
1
+ # Upgrading 0.81.0 → 0.104.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.75.0 → 0.103.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.81.0 → 0.104.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.75.0 → 0.103.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.81.0 → 0.104.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.104.0
13
+
14
+ JS bundles carrying Darwin native capabilities also need the
15
+ [delivery migration first affected in 0.103.13](#released-migration-010313).
16
+ Consumers upgrading from 0.103.12 or earlier must apply it even if their TypeScript API is unchanged.
17
+
18
+ ### CLI runtime-tool construction
19
+
20
+ **Who must act:** callers writing a schema-dependent handler or MCP/AI `present` directly
21
+ inside an annotated `CliConfig.runtimeTools` or `CliInvokerConfig.runtimeTools` object.
22
+ Native `commands` and values returned by `defineRuntimeTool` / `createRuntimeToolFactory`
23
+ remain valid. Execution, auth, validation and the invocation result envelope keep their behavior.
24
+
25
+ Construct a CLI-only managed definition with the neutral schema-aware type before registration:
26
+
27
+ ```ts
28
+ import type { CliInvokerConfig, RuntimeToolExecutionWithOutput } from 'stitchkit/cli'
29
+ import { z } from 'zod'
30
+
31
+ const input = z.object({ text: z.string() })
32
+ const output = z.object({ size: z.number() })
33
+ // Before: handler receives the heterogeneous registry context.
34
+ const config: CliInvokerConfig = {
35
+ name: 'app',
36
+ runtimeTools: [{
37
+ name: 'measure', description: 'Measure text',
38
+ identity: { serviceName: 'text', action: 'measure', method: 'POST' },
39
+ transports: ['CLI'], input, output,
40
+ handler: ({ input }) => ({ size: String(input.text).length }),
41
+ }],
42
+ }
43
+ // After: handler input and output derive from the construction schemas.
44
+ const measure = {
45
+ name: 'measure', description: 'Measure text',
46
+ identity: { serviceName: 'text', action: 'measure', method: 'POST' },
47
+ transports: ['CLI'], input, output,
48
+ handler: ({ input }) => ({ size: input.text.length }),
49
+ } satisfies RuntimeToolExecutionWithOutput<typeof input, typeof output>
50
+ const nextConfig: CliInvokerConfig = { name: 'app', runtimeTools: [measure] }
51
+ ```
52
+
53
+ For a shared MCP/AI tool, construct the definition with `defineRuntimeTool` from
54
+ `stitchkit/tools`, including its typed SDK `present` callbacks, then pass the returned value
55
+ to `runtimeTools`. Install the corresponding SDK peers for that integration. A CLI-only
56
+ consumer needs `stitchkit`, `zod` and its ordinary Node type tooling.
57
+
58
+ `RuntimeToolExecution` names the heterogeneous registration contract. Call a registered
59
+ operation through `createCli` or `createCliInvoker`; its erased handler input is `never`
60
+ because the managed runner owns schema validation before execution. For a managed void
61
+ definition, use `RuntimeToolDefinitionWithoutOutput<typeof input>`.
62
+
63
+ ### MCP construction, state stores and delivery
64
+
65
+ **Who must act:** schema-dependent runtime tool literals written directly inside MCP mount
66
+ configuration, MCP presenters returning malformed content or metadata, custom `StateStore`
67
+ implementations, file-store consumers using retired lock
68
+ options, broadcast consumers reading `halt` or retrying unknown send outcomes, and consumers
69
+ that validate HTTP error envelopes with a closed schema. Applications collecting raw tool
70
+ causes from `console.error` must configure an internal tool hook sink.
71
+
72
+ MCP-only code can import the existing server factories from `stitchkit/tools/mcp` and
73
+ construct its schema-aware tool before heterogeneous registration:
74
+
75
+ ```ts
76
+ import { buildMcpServer, type RuntimeMcpToolDefinitionWithOutput } from 'stitchkit/tools/mcp'
77
+ import { z } from 'zod'
78
+ const input = z.object({ value: z.number() })
79
+ const output = z.object({ doubled: z.number() })
80
+ // Before: runtimeTools: [{ input, output, handler, present }]
81
+ const double = {
82
+ name: 'double', description: 'Double a number',
83
+ identity: { serviceName: 'numbers', action: 'double', method: 'POST' },
84
+ input, output,
85
+ handler: ({ input }) => ({ doubled: input.value * 2 }),
86
+ present: { mcp: ({ doubled }) => ({ content: [{ type: 'text', text: String(doubled) }] }) },
87
+ } satisfies RuntimeMcpToolDefinitionWithOutput<typeof input, typeof output>
88
+ const server = buildMcpServer({ serverInfo: { name: 'numbers', version: '1' }, services: [], runtimeTools: [double] })
89
+ ```
90
+
91
+ Full MCP/AI integrations keep `defineRuntimeTool` from `stitchkit/tools`; those typed values
92
+ remain accepted by the MCP leaf and CLI. The leaf requires the MCP SDK and Zod, with no AI peer.
93
+
94
+ `RuntimeMcpPresentation` preserves the official SDK's required `content` and typed `_meta`
95
+ fields. A presenter returning `{}` must return `{ content: [] }`; text blocks require string
96
+ text, and metadata must be an object. `structuredContent` and `isError` remain framework-owned.
97
+ This restores SDK checks that an indexed mapped type previously erased.
98
+
99
+ Unexpected tool causes remain in `hooks.onToolError` and the `error` field of
100
+ `hooks.afterToolCall`. Protocol stderr carries safe errors. MCP resolver failures use those
101
+ same observers without executing the handler or its lifecycle again. HTTP's default
102
+ unexpected-error logging retains its behavior.
103
+
104
+ A custom state adapter's `update` must invoke `transition(current, context)` while it still
105
+ owns the serialized transaction. `context.assertHeld()` checks the actual transaction or lock
106
+ generation and refuses after completion, rollback or ownership loss. A no-op guard cannot
107
+ satisfy this contract. Existing transition callbacks may keep one parameter. For the owning
108
+ file adapter, replace `{ staleLockMs, retryMs, lockTimeoutMs }` with `{ lockTimeoutMs }`:
109
+ the remaining budget controls acquisition waiting, never expiry of a live transaction.
110
+ Unknown legacy PID locks and historical temporary files are preserved; recover them only
111
+ after independently proving their owner is gone.
112
+
113
+ Broadcast consumers change `report.halt.reason` checks to the closed `halt.kind` union:
114
+ `retry-after`, `transient`, `permanent` or `ambiguous`. A custom MTProto adapter can classify
115
+ an acknowledged flood refusal as `{ kind: 'retry-after', retryAfterMs: wait }`; the exact
116
+ provider wait is respected. A wait over `maxRetryDelayMs` halts with the recipient pending.
117
+ Unknown write outcome becomes `uncertain`; restarting the same broadcast does not send it
118
+ again. A retry classification must certify that the attempt did not apply the external effect.
119
+
120
+ HTTP errors gain optional boolean `error.retryable`; framed contract streams use the same
121
+ field. Update closed consumer schemas before producers declaring it. `false` on 502 and
122
+ `true` on 409 remain explicit recommendations through the remote tool path. An absent field
123
+ retains prior status-derived defaults; the field does not change the HTTP client's retry policy.
124
+ The existing seventh `ApiError` constructor argument remains `ErrorOptions`; retryability is
125
+ the new eighth argument.
126
+
127
+ Caller cancellation now reaches `implementRemote`'s existing HTTP call. Applications bind
128
+ signals to `createCli` / `createCliInvoker` and cooperative handlers observe `ctx.signal`.
129
+ `REQUEST_ABORTED` is nonretryable and exits 130. A disconnected caller does not prove that
130
+ an origin ignoring cancellation or an external provider stopped; keep resource leases until
131
+ that work actually completes.
132
+
133
+ ## Released migration: 0.103.13
134
+
135
+ ### Darwin native assets in JS distributions
136
+
137
+ **Who must act:** Bun JS builds using `--outfile`, copying only `outputs[0]`, custom
138
+ single-file/archive packagers and installers delivering native process/files capabilities.
139
+ First affected publication: **0.103.13**. It shipped as a patch; its changed delivery graph
140
+ requires this migration despite unchanged API signatures.
141
+
142
+ ```sh
143
+ # Before: one JS file was assumed to be the entire distribution.
144
+ bun build src/native.ts --target=bun --outfile=dist/native.js
145
+ # After: retain every output, with its relative path.
146
+ bun build src/native.ts --target=bun --outdir=dist --entry-naming=native.js
147
+ ```
148
+
149
+ For `Bun.build`, copy **all** `result.outputs`, not just the JS entry or `outputs[0]`.
150
+ A single-file JS distribution cannot embed a native `.node` addon automatically.
151
+ An archive may contain JS plus companion assets, materialized together before execution.
152
+ Custom output layout uses the evolving build-only packaging contract in the
153
+ [native IO guide](native-io.md#public-native-packaging).
154
+
155
+ Three deliveries have different rules: an ordinary npm install retains the package's
156
+ native assets; a JS distribution must ship its complete output graph; a Bun compiled
157
+ executable embeds the matching addon and may still use `--outfile`.
158
+ The [native IO guide](native-io.md#libraries-with-a-zod-only-runtime) is the canonical recipe.
159
+ Check the resulting artifact offline outside the build tree and `node_modules`, including
160
+ process identity, live-owner lock refusal, dead-owner recovery and contained IO.
161
+ A missing or corrupt addon remains `unavailable`, never evidence that an owner died.
162
+
12
163
  ## Released migration: 0.103.0
13
164
 
14
165
  ### Diagnostic journal startup preserves torn evidence and inspects archives
@@ -901,217 +1052,3 @@ compile error instead of building a URL with an unresolved segment. Measured
901
1052
  across three consuming applications before release (373 endpoints with path
902
1053
  segments), no explicit schema missed a field: the migration is deleting
903
1054
  schemas that only repeated the path, or nothing.
904
-
905
- ## Released migration: 0.80.0
906
-
907
- One thing, and only if you parse an async-operation snapshot.
908
-
909
- ```bash
910
- rg -n "createAsyncOperationSnapshotSchema"
911
- ```
912
-
913
- `progress` on a parsed snapshot used to be `unknown`. The factory built its
914
- object shapes with a conditional spread, and the narrowing inside it widened
915
- your schema back to a bare `ZodType`, so the emitted declaration threw the type
916
- argument away. It is now the output of the schema you configured.
917
-
918
- ```ts
919
- const schema = createAsyncOperationSnapshotSchema({
920
- progress: z.object({ done: z.number(), total: z.number() }),
921
- failure: z.object({ code: z.string() }),
922
- })
923
- const snap = schema.parse(body)
924
- if (snap.phase === 'running') {
925
- // before: `snap.progress` was `unknown` — this needed a cast or a narrow
926
- // after: it is `{ done: number; total: number } | undefined`
927
- console.log(snap.progress?.done)
928
- }
929
- ```
930
-
931
- **If you cast it**, delete the cast — it was working around the erased type.
932
- **If you assigned something else to it**, the compiler now refuses, and it was
933
- already a value the schema rejected at run time.
934
-
935
- **If you pass explicit type arguments**, the no-progress form takes one now, not
936
- two: the factory is two overloads. Pass none.
937
-
938
- ```ts
939
- // before: createAsyncOperationSnapshotSchema<undefined, typeof Failure>({ failure: Failure })
940
- // after: createAsyncOperationSnapshotSchema({ failure: Failure })
941
- ```
942
-
943
- Nothing about parsing moves. A snapshot configured without `progress` still
944
- strips an unexpected `progress` rather than refusing it — that behaviour is why
945
- this is overloads and not one normalised key.
946
-
947
- **If you compile with `skipLibCheck: false`**, this is also the release that
948
- makes `stitchkit/tools/contract` compile at all: it carried five `TS2344`
949
- errors, one per phase, from the same conditional spread.
950
-
951
- ## Released migration: 0.79.0
952
-
953
- One thing, and only if you assert on the whole snapshot.
954
-
955
- ```bash
956
- rg -n "getSnapshot\(\)|projectApplicationStatus|status\(\)" --glob '*.test.ts' --glob '*.spec.ts'
957
- ```
958
-
959
- `ApplicationSnapshot` and `ApplicationStatusProjection` each gained a
960
- `restarting` field — ids in the snapshot, a count in the projection. A reader
961
- that names the fields it wants is unaffected. A test that compares the whole
962
- object with `toEqual` fails until it adds the field:
963
-
964
- ```ts
965
- // before
966
- expect(body).toEqual({ id, lifecycle: 'ready', /* … */ resources: { total: 1, ready: 1, degraded: 0, failed: 0 } })
967
- // after
968
- expect(body).toEqual({ id, lifecycle: 'ready', /* … */ resources: { total: 1, ready: 1, degraded: 0, failed: 0 }, restarting: 0 })
969
- ```
970
-
971
- It is zero except while a restart is running, and then it names the subtree being
972
- replaced. That is the point: a snapshot taken mid-restart used to be
973
- indistinguishable from a resource that had failed on its own, so a dashboard read
974
- a planned replacement as an outage.
975
-
976
- **If you watch a hub across a restart**, nothing to change, but the behaviour is
977
- different and better: closing a hub now tells its subscribers `unavailable` /
978
- `source-unavailable` instead of dropping them, so a page stops showing a value
979
- that will never update again.
980
-
981
- **If you need a tool contract in a browser**, `stitchkit/tools/contract` now
982
- carries the async-operation helpers, its schemas and the view-file input/output
983
- without the runtime. `stitchkit/tools` still exports all of them.
984
-
985
- ## Released migration: 0.78.0
986
-
987
- Two mechanical edits. Find them both:
988
-
989
- ```bash
990
- rg -n "createDecisionPipeline|createDiagnosticJournal" --glob '*.ts' --glob '*.tsx'
991
- ```
992
-
993
- **1. `createDecisionPipeline` takes a deadline.**
994
-
995
- ```ts
996
- // before
997
- createDecisionPipeline([policyA, policyB])
998
- // after
999
- createDecisionPipeline([policyA, policyB], { policyTimeoutMs: 2_000 })
1000
- ```
1001
-
1002
- Pick a number your slowest policy comfortably beats. There is no default on
1003
- purpose: a policy that never settles hangs every caller of the operation it
1004
- guards, and the framework has no basis for choosing that number for you.
1005
-
1006
- Past the deadline — and on a throw, and on a non-decision — the pipeline raises
1007
- `DecisionPolicyError` naming the policy, with the trace so far. If you already
1008
- catch that for a bad return value, you now catch two more cases with it.
1009
-
1010
- **2. `createDiagnosticJournal` moved.**
1011
-
1012
- ```ts
1013
- // before
1014
- import { createDiagnosticJournal } from 'stitchkit/application'
1015
- // after
1016
- import { createDiagnosticJournal } from 'stitchkit/application/diagnostic-journal'
1017
- ```
1018
-
1019
- Only the factory moved. `DiagnosticJournalConfig`, every
1020
- `DiagnosticJournal*Schema` and `readDiagnosticJournalLockDiagnosis` stay where
1021
- they were.
1022
-
1023
- **If you restart resources**, nothing to change — but three things that did not
1024
- work now do: a managed schedule can be restarted, a restarted keyspace accepts
1025
- writes again, and a restarted managed server is actually shut down at exit. If
1026
- you pass `managedServerResource` a server *instance*, a restart is now refused
1027
- by name; pass a factory (`server: (context) => …`) to restart it.
1028
-
1029
- ## Released migration: 0.77.0
1030
-
1031
- Two type renames, and only if you named them. Nothing runtime moved.
1032
-
1033
- ```bash
1034
- rg -n "EventDecision|EventUndecided" --glob '*.ts' --glob '*.tsx'
1035
- ```
1036
-
1037
- ```ts
1038
- // before
1039
- import type { EventDecision, EventUndecided } from 'stitchkit/live'
1040
- // after
1041
- import type { PolicyDecision, UndecidedOutcome } from 'stitchkit/live'
1042
- ```
1043
-
1044
- The shapes are identical — `{ outcome: 'allow' } | { outcome: 'deny', reason } | { outcome: 'defer' }`
1045
- and `'allow' | 'deny'`. If you only ever *return* decisions from listeners and never named the
1046
- type, the search above finds nothing and there is nothing to do.
1047
-
1048
- They were renamed because `createDecisionPipeline` (new in this release) votes with exactly the
1049
- same three outcomes, and two identical types under two names is the thing that makes a search for
1050
- either one return half the truth.
1051
-
1052
- ## Released migration: 0.76.0
1053
-
1054
- One change, and only if you hand `createWatchClient` a transport you wrote yourself.
1055
-
1056
- ```bash
1057
- rg -n "createWatchClient" --glob '*.ts'
1058
- ```
1059
-
1060
- If the `transport:` you pass is a bound realtime client — `bindRealtimeClient(...)` or
1061
- `createRealtimeClient(...)` — there is nothing to do: it already carries
1062
- `onConnectionChange`. If it is an object you assembled, add the fourth member:
1063
-
1064
- ```ts
1065
- onConnectionChange(listener: (connected: boolean, reason?: string) => void): () => void
1066
- ```
1067
-
1068
- It is required because the client recovers through it: on a drop it publishes
1069
- `unavailable` to subscribers and forgets what was opened, and on a fresh
1070
- connection it re-opens every key that still has a listener. Without it a watch
1071
- stays "open" on the client after a server restart while the hub remembers
1072
- nothing, and the face stops updating without saying so.
1073
-
1074
- ## Released migration: 0.75.0
1075
-
1076
- Two mechanical renames and one option that has to move. Nothing about a passing
1077
- request changes.
1078
-
1079
- ### 1. A route group's `onRequest`
1080
-
1081
- ```bash
1082
- rg -n "hooks:\s*\{[^}]*onRequest" --glob '*.ts'
1083
- ```
1084
-
1085
- Any match **inside a `groups: [...]` entry** must move. The hook was accepted and
1086
- never dispatched, so the behaviour you have today is "no hook"; the fix is to
1087
- decide which one you meant:
1088
-
1089
- ```ts
1090
- // refuse before dispatch, for the whole server
1091
- createServer({ groups, hooks: { onRequest: gate } });
1092
-
1093
- // gate this group once the endpoint is known
1094
- groups: [{ pathPrefix: '/admin', services, hooks: { authorize: gate } }]
1095
- ```
1096
-
1097
- A group that still declares `onRequest` fails at startup with that message.
1098
-
1099
- ### 2. The SQLite boundary type
1100
-
1101
- ```bash
1102
- rg -l "AgentRuntimeSqlite(Database|Statement|Value)" | xargs sed -i \
1103
- -e 's/AgentRuntimeSqliteDatabase/SqliteDatabase/g' \
1104
- -e 's/AgentRuntimeSqliteStatement/SqliteStatement/g' \
1105
- -e 's/AgentRuntimeSqliteValue/SqliteValue/g'
1106
- ```
1107
-
1108
- Type-only: the same three methods, the same structural compatibility with
1109
- `bun:sqlite` and a `node:sqlite` wrapper, imported from the same entrypoints.
1110
- `initializeAgentRuntimeSqlite` keeps its name — it really is the agent runtime's
1111
- schema.
1112
-
1113
- ### 3. Nothing else
1114
-
1115
- `stitchkit/live`, the watch hub, the keyspace and the trust fence are all
1116
- additive. Adopt them when you want them; the guide is
1117
- [Live data](./live.md).
@@ -11,10 +11,10 @@ Contains: Guide: Upgrading, general (docs/guide/upgrading.md)
11
11
 
12
12
  Load this slice, then every range slice between your installed version and the target:
13
13
 
14
- - 0.75.0 → 0.103.0: `llms/upgrading-0.75.0-0.103.0.txt`
15
- - 0.61.0 → 0.74.0: `llms/upgrading-0.61.0-0.74.0.txt`
16
- - 0.44.0 → 0.60.0: `llms/upgrading-0.44.0-0.60.0.txt`
17
- - 0.37.0 → 0.37.0: `llms/upgrading-0.37.0.txt`
14
+ - 0.81.0 → 0.104.0: `llms/upgrading-0.81.0-0.104.0.txt`
15
+ - 0.62.0 → 0.80.0: `llms/upgrading-0.62.0-0.80.0.txt`
16
+ - 0.44.0 → 0.61.0: `llms/upgrading-0.44.0-0.61.0.txt`
17
+ - 0.37.0 → 0.44.0: `llms/upgrading-0.37.0-0.44.0.txt`
18
18
 
19
19
  # Upgrading stitchkit
20
20