stitchkit 0.107.0 → 0.108.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 (102) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +2 -0
  3. package/darwin-native.cjs +1 -0
  4. package/dist/agent-runtime/sandbox-process-owner.d.ts +3 -3
  5. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
  6. package/dist/agent-runtime/sandbox-process.d.ts +2 -2
  7. package/dist/agent-runtime/sandbox-process.d.ts.map +1 -1
  8. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  9. package/dist/browser/stream.d.ts +38 -12
  10. package/dist/browser/stream.d.ts.map +1 -1
  11. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  12. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  13. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  14. package/dist/entrypoints/application/directory-inbox.js +4 -4
  15. package/dist/entrypoints/bin/upgrade-cli.d.ts +32 -0
  16. package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -1
  17. package/dist/entrypoints/bin/upgrade-cli.js +451 -8
  18. package/dist/entrypoints/cli/publish.js +3 -3
  19. package/dist/entrypoints/files/packaging.d.ts +3 -1
  20. package/dist/entrypoints/files/packaging.d.ts.map +1 -1
  21. package/dist/entrypoints/files/packaging.js +105 -41
  22. package/dist/entrypoints/files.js +3 -3
  23. package/dist/entrypoints/index.d.ts +1 -1
  24. package/dist/entrypoints/index.d.ts.map +1 -1
  25. package/dist/entrypoints/index.js +7 -1
  26. package/dist/entrypoints/process.js +2 -2
  27. package/dist/entrypoints/remote.js +1 -1
  28. package/dist/entrypoints/server.js +4 -4
  29. package/dist/entrypoints/telegram/screens.js +1 -1
  30. package/dist/entrypoints/telegram.d.ts +2 -0
  31. package/dist/entrypoints/telegram.d.ts.map +1 -1
  32. package/dist/entrypoints/telegram.js +337 -3
  33. package/dist/entrypoints/testing.d.ts +1 -0
  34. package/dist/entrypoints/testing.d.ts.map +1 -1
  35. package/dist/entrypoints/testing.js +131 -1
  36. package/dist/files/native-artifact.d.ts +14 -0
  37. package/dist/files/native-artifact.d.ts.map +1 -0
  38. package/dist/files/native-packaging-layout.d.ts +5 -0
  39. package/dist/files/native-packaging-layout.d.ts.map +1 -1
  40. package/dist/files/native-packaging-plugin.d.ts +53 -0
  41. package/dist/files/native-packaging-plugin.d.ts.map +1 -0
  42. package/dist/files/native-packaging.d.ts +1 -35
  43. package/dist/files/native-packaging.d.ts.map +1 -1
  44. package/dist/index-a5qr2rj6.js +26 -0
  45. package/dist/{index-7r74re56.js → index-bh2ht9y5.js} +12 -6
  46. package/dist/{index-dwf0gymy.js → index-e35py42g.js} +1 -1
  47. package/dist/{index-4q9jvqg7.js → index-epg514ys.js} +182 -13
  48. package/dist/{index-mbf4h8kp.js → index-nx49x0tw.js} +1 -1
  49. package/dist/{index-zsqt5q98.js → index-p5kx5vqd.js} +209 -54
  50. package/dist/{index-bnf8s6v3.js → index-t2bsd0hm.js} +1 -1
  51. package/dist/{index-4f37d3bg.js → index-w9mqgnz9.js} +1 -1
  52. package/dist/{index-e05cjgtf.js → index-xvj9h8yh.js} +28 -1
  53. package/dist/internal/bounded-lines.d.ts +46 -2
  54. package/dist/internal/bounded-lines.d.ts.map +1 -1
  55. package/dist/internal/process-identity.d.ts.map +1 -1
  56. package/dist/internal/until-aborted.d.ts +9 -0
  57. package/dist/internal/until-aborted.d.ts.map +1 -0
  58. package/dist/internal/upgrade-affects.d.ts +58 -0
  59. package/dist/internal/upgrade-affects.d.ts.map +1 -0
  60. package/dist/internal/upgrade-plan.d.ts +20 -0
  61. package/dist/internal/upgrade-plan.d.ts.map +1 -1
  62. package/dist/internal/upgrade-usage.d.ts +61 -0
  63. package/dist/internal/upgrade-usage.d.ts.map +1 -0
  64. package/dist/process/bun-child.d.ts +38 -0
  65. package/dist/process/bun-child.d.ts.map +1 -0
  66. package/dist/process/command-owner.d.ts +2 -2
  67. package/dist/process/command-owner.d.ts.map +1 -1
  68. package/dist/process/launch.d.ts +2 -2
  69. package/dist/process/launch.d.ts.map +1 -1
  70. package/dist/process/owned-child.d.ts +2 -1
  71. package/dist/process/owned-child.d.ts.map +1 -1
  72. package/dist/telegram/bot-api.d.ts +10 -4
  73. package/dist/telegram/bot-api.d.ts.map +1 -1
  74. package/dist/telegram/broadcast.d.ts +2 -1
  75. package/dist/telegram/broadcast.d.ts.map +1 -1
  76. package/dist/telegram/not-dispatched.d.ts +26 -0
  77. package/dist/telegram/not-dispatched.d.ts.map +1 -0
  78. package/dist/telegram/operator-channel.d.ts +2 -1
  79. package/dist/telegram/operator-channel.d.ts.map +1 -1
  80. package/dist/telegram/send-failure.d.ts +4 -3
  81. package/dist/telegram/send-failure.d.ts.map +1 -1
  82. package/dist/telegram/transport-connect.d.ts +38 -0
  83. package/dist/telegram/transport-connect.d.ts.map +1 -0
  84. package/dist/telegram/transport.d.ts +43 -0
  85. package/dist/telegram/transport.d.ts.map +1 -0
  86. package/dist/telegram/webhook.d.ts +2 -1
  87. package/dist/telegram/webhook.d.ts.map +1 -1
  88. package/dist/testing/manual-clock.d.ts +82 -0
  89. package/dist/testing/manual-clock.d.ts.map +1 -0
  90. package/llms/files-packaging.txt +4 -1
  91. package/llms/process.txt +19 -5
  92. package/llms/stitchkit.2.txt +211 -628
  93. package/llms/stitchkit.txt +635 -10
  94. package/llms/telegram.txt +36 -3
  95. package/llms/testing.txt +47 -0
  96. package/llms/{upgrading-0.98.0-0.107.0.txt → upgrading-0.100.0-0.108.0.txt} +59 -64
  97. package/llms/{upgrading-0.72.0-0.97.0.txt → upgrading-0.72.0-0.99.0.txt} +64 -3
  98. package/llms/upgrading.txt +34 -2
  99. package/llms-full.txt +246 -17
  100. package/llms.txt +8 -8
  101. package/package.json +1 -1
  102. package/llms/stitchkit.3.txt +0 -177
package/CHANGELOG.md CHANGED
@@ -15,6 +15,90 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.108.1] - 2026-10-07
19
+
20
+ ### Fixed
21
+
22
+ - `stitchkit/process` — **under Bun, `runNativeCommand` no longer waits for its deadline on a command
23
+ that has already exited.** Bun's `node:child_process` can lose a child's `exit` event while the host
24
+ is heavily loaded inside `bun test` (a bare `spawn` of `sh -c 'echo x; exit 1'` received no event at
25
+ all in 4 of 30 parallel runs at load average ~90), so the call hung until `timeoutMs` and failed with
26
+ `Command deadline exceeded`. Under Bun a command is now launched through `Bun.spawn`, presented to the
27
+ command owner with the same events, streams, group ownership and failure reporting; Node still uses
28
+ `node:child_process`. The deadline, stop policy and process-group cleanup are unchanged.
29
+
30
+ ## [0.108.0] - 2026-10-06
31
+
32
+ ### ⚠️ Breaking changes
33
+
34
+ **Who must act:** code with an exhaustive `switch` or `Record` over `TelegramSendFailureReason` or
35
+ `TelegramSendFailure['evidence']`; builds whose entry imports a `stitchkit` installation other
36
+ than the one their native packaging plugin came from.
37
+
38
+ - `stitchkit/telegram` — **a request that never left is its own send outcome.**
39
+ `TelegramSendFailureReason` gains `not-dispatched` (retryable, recipient reachable) and
40
+ `TelegramSendFailure.evidence` gains `transport`: `classifyTelegramSendFailure` returns them for a
41
+ `TelegramNotDispatchedError` anywhere in the cause chain, so a broadcast retries such a send as
42
+ `transient` and the operator channel sends it again, where both used to give it up as unknown.
43
+ `// before: const code: Record<TelegramSendFailureReason, string> = { …, unknown: 'E_UNKNOWN' }`
44
+ → `// after: const code: Record<TelegramSendFailureReason, string> = { …, 'not-dispatched': 'E_NOT_SENT', unknown: 'E_UNKNOWN' }`
45
+ **Who must act:** exhaustive code over the reasons or the evidence. See
46
+ [migration](docs/guide/upgrading.md#a-request-that-never-left-is-its-own-send-outcome). → ADR 0253
47
+ **Affects:** `stitchkit/telegram` TelegramSendFailureReason, TelegramSendFailure(evidence), TELEGRAM_SEND_FAILURE_REASONS, classifyTelegramSendFailure(reason)
48
+ - `stitchkit/files/packaging` — **a packaging plugin fails a build that carries another
49
+ installation's loader.** The plugin packages only the default Darwin loader of the `stitchkit` it
50
+ was created from; an entry that imports another installation (another version, or the same
51
+ version under another path, as when a build tool brings its own copy) used to build, ship that
52
+ installation's default loader and refuse the addon on macOS at run time. The build now fails with
53
+ an error naming both versions and roots.
54
+ `// before: Bun.build({ plugins: [toolCopy.createNativePackaging(…).plugin] }) // entry imports another stitchkit`
55
+ → `// after: Bun.build({ plugins: [entryCopy.createNativePackaging(…).plugin] })`
56
+ **Who must act:** builds that take the plugin from a `stitchkit` the entry does not import. See
57
+ [migration](docs/guide/upgrading.md#a-packaging-plugin-packages-only-its-own-installation). → ADR 0254
58
+ **Affects:** `stitchkit/files/packaging` createNativePackaging(plugin)
59
+
60
+ ### Added
61
+
62
+ - `stitchkit/telegram` — `createTelegramBotTransport()`, a `fetch` for the Bot API senders that
63
+ connects before it writes: a failure before the first byte is `TelegramNotDispatchedError`
64
+ (`stage`: `lookup`, `connect`, `request`), any later one stays unknown. Addresses race in the
65
+ resolver's order (Happy Eyeballs); the lookup, the connection rounds, the answer's time and its size are bounded.
66
+ The senders' `fetch` option is now typed `TelegramFetch` (`(url, init) => Promise<Response>`), which
67
+ the global `fetch` still satisfies. → ADR 0253
68
+ - `stitchkit` — `parseNDJSON` and `parseSSE` read any byte source: a `Response`, a
69
+ `ReadableStream<Uint8Array>` (a Bun child's `stdout`) or an `AsyncIterable<Uint8Array>` (a Node
70
+ child's `stdout`), with `signal` cancelling the source. `createNDJSONDecoder` drives the same
71
+ bounded reader by `push(chunk)` / `end()` for a socket's `data` callback. A line past
72
+ `maxLineBytes` throws `StreamLineLimitError` (`limitBytes`, `lineBytes`) at the chunk that crossed
73
+ the limit, so memory stays bounded; a source ended inside a line under `finalLine:
74
+ 'require-newline'` throws `StreamTruncatedLineError`. They extend the `RangeError` and `SyntaxError`
75
+ thrown before, so `instanceof` still holds; their `name` is now the class name and their message
76
+ ends with the bytes seen. A decoder stops at
77
+ its first error, and an abort rejects with the signal's reason even when `onParseError` is set.
78
+ - `stitchkit/files/packaging` — `inspectNativeArtifact(bytes)` classifies a built artifact as
79
+ `packaged`, `unpackaged` or `no-loader` by a marker every generated loader now carries
80
+ (`module.exports.stitchkitNativeLoader`), in latin1 and UTF-16LE. It replaces the documented search
81
+ for `STITCHKIT_NATIVE_NOT_PACKAGED`, which every bundle with a lock carries as an error code and so
82
+ refused correct builds. → ADR 0254
83
+ - `stitchkit upgrade` — every breaking item from 0.104.0 carries an `**Affects:**` line naming its
84
+ entrypoints and exports (or `behaviour`), and `release:check` refuses a breaking item without it.
85
+ The CLI reads the project's imports (`--cwd`, default `.`) and gives each item a verdict:
86
+ `affects this project` with `path:line`, `not used here`, `behavioural — check by hand` with the
87
+ importing files, or `not declared — check by hand` for older items; `--json` prints the verdicts.
88
+ - `stitchkit/testing` — `createManualClock()`: manual time for schedules, retries and deadlines. Due
89
+ timers fire in deadline order with real event-loop yields between them, so `advance(10_000)` does
90
+ not skip a retry armed at the fifth second; `hold` keeps time still while real work of unknown
91
+ length runs and fails naming it past `holdLimitMs`; `until` moves deadline to deadline; one move
92
+ runs at a time. It is the
93
+ clock of `createManagedSchedule`, a durable sleep, a revision signal and bounded admission.
94
+
95
+ ### Fixed
96
+
97
+ - `stitchkit/server`, `stitchkit/process`, `stitchkit/files` — loading these leaves no longer calls
98
+ a Node API: process identity built its command runner with `promisify(execFile)` at module scope,
99
+ so a browser bundle that reached the server leaf for an error class (where `node:util` is an empty
100
+ module) threw `promisify is not a function` while loading, although nothing called it.
101
+
18
102
  ## [0.107.0] - 2026-10-06
19
103
 
20
104
  ### ⚠️ Breaking changes
@@ -33,6 +117,7 @@ any artifact made without the packaging plugin by 0.105.0–0.106.1.
33
117
  → `// after: createNativePackaging({ platform: 'darwin', architecture: 'arm64', delivery: 'embedded' })`
34
118
  **Who must act:** builds with `delivery: 'embedded'`. See
35
119
  [migration](docs/guide/upgrading.md#embedded-native-packaging-names-no-paths). → ADR 0252
120
+ **Affects:** `stitchkit/files/packaging` createNativePackaging(delivery: 'embedded'), NativePackagingOptions, NativePackagingResult, NativePackagingAsset
36
121
 
37
122
  ### Fixed
38
123
 
@@ -99,6 +184,7 @@ or a failing sink).
99
184
  `// after: onLeaderSettled: (e) => { if (e.kind === 'stopped') stopped(e.cause, e.signal) }`
100
185
  **Who must act:** code that handles a stop in `kind === 'error'`. See
101
186
  [migration](docs/guide/upgrading.md#a-stopped-leader-settles-as-stopped). → ADR 0248
187
+ **Affects:** `stitchkit/process` runNativeCommand(onLeaderSettled), NativeCommandOptions(onLeaderSettled), NativeCommandSettlement
102
188
 
103
189
  ### Added
104
190
 
@@ -183,6 +269,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
183
269
  **Who must act:** code that imports `publishCli` or a `CliPublication*` type from
184
270
  `stitchkit/cli`. See [migration](docs/guide/upgrading.md#cli-publication-has-its-own-entrypoint).
185
271
  → ADR 0245
272
+ **Affects:** `stitchkit/cli` publishCli, CliPublicationOptions, CliPublicationPhase, CliPublicationResult
186
273
 
187
274
  - `stitchkit/process` — **`killGraceMs` becomes the `stop` policy.** How a cancelled command
188
275
  stops is one named object: `target` `'group'` (the signal goes to every member, as before) or
@@ -195,6 +282,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
195
282
  `// before: runNativeCommand({ …, killGraceMs: 500 })` →
196
283
  `// after: runNativeCommand({ …, stop: { target: 'group', graceMs: 500 } })`
197
284
  **Who must act:** callers that pass `killGraceMs`. → ADR 0243
285
+ **Affects:** `stitchkit/process` runNativeCommand(killGraceMs), NativeCommandOptions(killGraceMs)
198
286
 
199
287
  - `stitchkit/process` — **a command's leftover group members are stopped after its leader
200
288
  exits.** `runNativeCommand` takes `descendants: 'terminate-after-leader' | 'leave'`, and
@@ -209,6 +297,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
209
297
  keep running after the command returns. See
210
298
  [migration](docs/guide/upgrading.md#a-command-stops-what-its-leader-left).
211
299
  → ADR 0246
300
+ **Affects:** `stitchkit/process` runNativeCommand(descendants), NativeCommandOptions(descendants)
212
301
 
213
302
  - `stitchkit/server`, `stitchkit/files`, `stitchkit/process` — **bundles no longer emit Darwin
214
303
  addons.** The packaged Darwin loader names its addon by a computed path, so a Bun bundle of
@@ -222,6 +311,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
222
311
  **Who must act:** Darwin packagers of bundled or compiled artifacts using these entrypoints.
223
312
  Linux and portable bundles need no change. See [migration](docs/guide/upgrading.md#released-migration-010313).
224
313
  → ADR 0235
314
+ **Affects:** `stitchkit/server`, `stitchkit/files`, `stitchkit/process` behaviour
225
315
  - `stitchkit/files/packaging` — **`createNativePackaging` checks each addon against a digest the
226
316
  package published, and returns the verified bytes.** `native-assets.json` is now written when
227
317
  Stitchkit is built, at `formatVersion: 2`, with the `path`, `size` and `sha256` of every Darwin
@@ -247,6 +337,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
247
337
  than the literal `'darwin'`.
248
338
  See [migration](docs/guide/upgrading.md#native-packaging-verifies-published-digests).
249
339
  → ADR 0241
340
+ **Affects:** `stitchkit/files/packaging` createNativePackaging(platform), NativePackagingAsset(sourcePath), NativePackagingResult(code)
250
341
  - `stitchkit/files` — **`withExclusiveLock` publishes its lock with the owner already recorded,
251
342
  and `ownerlessGraceMs` defaults to `null`.** The owner record is written to a temporary file
252
343
  and hard-linked to the lock name, so the name never exists without an owner and a stalled
@@ -260,6 +351,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
260
351
  file, and locks on a filesystem without hard links; every other caller is unaffected.
261
352
  See [migration](docs/guide/upgrading.md#exclusive-locks-publish-their-owner-first).
262
353
  → ADR 0238
354
+ **Affects:** `stitchkit/files` withExclusiveLock(ownerlessGraceMs), ExclusiveLockOptions(ownerlessGraceMs)
263
355
  - `stitchkit/tools/connections` — **a `timeoutMs` or `maxResponseBytes` that is not a positive
264
356
  integer within range throws a `RangeError`** instead of falling back to the default. This
265
357
  shipped in 0.104.0 without a breaking entry.
@@ -267,6 +359,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
267
359
  `// after: timeoutMs: 0 (RangeError; omit the option to take the default)`
268
360
  **Who must act:** callers that passed 0, a negative, a fractional or an oversized limit.
269
361
  See [migration](docs/guide/upgrading.md#connection-limits-are-validated).
362
+ **Affects:** `stitchkit/tools/connections` defineMcpClientConnection(timeoutMs), defineOpenApiConnection(timeoutMs), McpConnectionLimits, ConnectionOperationLimits
270
363
  - `stitchkit/testing` — **`serializeSurfaceValue` is removed.** It was a second name for the
271
364
  package's one canonical serializer. `canonicalJson` from `stitchkit/primitives` is that
272
365
  serializer, bounded and with a typed refusal:
@@ -275,6 +368,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
275
368
  **Who must act:** tests that call `serializeSurfaceValue`.
276
369
  See [migration](docs/guide/upgrading.md#one-canonical-json-serializer).
277
370
  → ADR 0199, ADR 0238
371
+ **Affects:** `stitchkit/testing` serializeSurfaceValue
278
372
  - `stitchkit/agent-runtime` — **`canonicalAgentJson` follows the one admissibility table of
279
373
  `canonicalJson`.** A value nested deeper than 100 levels is refused with a
280
374
  `CanonicalJsonError`, and an `undefined` object member is omitted instead of failing. It still
@@ -286,6 +380,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
286
380
  **Who must act:** code that puts a value nested deeper than 100 levels into agent store events,
287
381
  archives or projections. See
288
382
  [migration](docs/guide/upgrading.md#one-canonical-json-serializer).
383
+ **Affects:** `stitchkit/agent-runtime` canonicalAgentJson
289
384
  - `stitchkit/application` — **`DirectoryInbox` sets a hard-linked entry file aside as
290
385
  `invalid`, and `accept` takes the schema's input type.** A dropped file with more than one
291
386
  link is never trusted, because another name can still rewrite it (since 0.104.0, without a
@@ -298,6 +393,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
298
393
  **Who must act:** producers that drop hard links into an inbox directory, and callers that pass
299
394
  `accept` the output of a transforming schema.
300
395
  See [migration](docs/guide/upgrading.md#directory-inbox-entries).
396
+ **Affects:** `stitchkit/application` DirectoryInbox, DirectoryInboxConfig, DirectoryInboxResource; `stitchkit/application/directory-inbox` createDirectoryInbox
301
397
  - `stitchkit/application` — **`createDiagnosticJournal` checks only the last line of each file
302
398
  when it opens** (`startupScan: 'tails'`, the default), so opening no longer parses and
303
399
  validates every line of every retained generation. The scan still reads each file once in
@@ -308,6 +404,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
308
404
  `// after: createDiagnosticJournal({ path, eventSchema, limits, startupScan: 'full' }) (the same full scan)`
309
405
  **Who must act:** operators that read `recovery` at startup to find damaged rows in the middle
310
406
  of a file. See [migration](docs/guide/upgrading.md#journal-startup-scan).
407
+ **Affects:** `stitchkit/application/diagnostic-journal` createDiagnosticJournal(startupScan)
311
408
  - `stitchkit/application/diagnostic-journal`, `stitchkit/application` — **opening a diagnostic
312
409
  journal moves a file it cannot keep in place aside and starts, instead of refusing to start.**
313
410
  A torn active file with `maxFiles: 1`, a generation name that is not a regular file and a
@@ -330,6 +427,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
330
427
  `recovery`; protocols that embed `DiagnosticJournalRecoveryStatusSchema` and their readers.
331
428
  See [migration](docs/guide/upgrading.md#journal-startup-quarantine).
332
429
  → ADR 0240
430
+ **Affects:** `stitchkit/application/diagnostic-journal` createDiagnosticJournal(onStartupRefusal); `stitchkit/application` DiagnosticJournalRecoveryError, DiagnosticJournalRecoveryStatusSchema
333
431
 
334
432
  - `stitchkit/cli`, `stitchkit/tools`, `stitchkit/tools/mcp` — **one runtime-tool declaration.**
335
433
  `RuntimeToolExecution`, `RuntimeToolExecutionWithOutput` (cli), `RuntimeMcpToolDefinition`,
@@ -351,6 +449,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
351
449
  `createRuntimeToolFactory` need no change.
352
450
  See [migration](docs/guide/upgrading.md#one-runtime-tool-declaration).
353
451
  → ADR 0236, ADR 0238
452
+ **Affects:** `stitchkit/cli` RuntimeToolExecution, RuntimeToolExecutionWithOutput; `stitchkit/tools/mcp` RuntimeMcpToolDefinition, RuntimeMcpToolDefinitionWithOutput; `stitchkit/tools` ToolSurfaceDefinition, RuntimeToolDefinitionWithOutput
354
453
  - `stitchkit/tools`, `stitchkit/tools/mcp` — **a flattened union keeps declaration order.**
355
454
  With `flattenUnionInput: true`, properties, enum values and branch labels are advertised in the
356
455
  order of their first appearance across the variants instead of alphabetically, so the bytes of
@@ -362,6 +461,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
362
461
  anyone using `flattenUnionInput: true`: regenerate the snapshots.
363
462
  See [migration](docs/guide/upgrading.md#flattened-unions-keep-declaration-order).
364
463
  → ADR 0238
464
+ **Affects:** `stitchkit/tools`, `stitchkit/tools/mcp` behaviour
365
465
  - `stitchkit/tools`, `stitchkit/cli` — **a list written as text is refused in every
366
466
  string-or-array field.** `coerceJsonArgs`, and so every tool surface, throws a validation error
367
467
  naming the field when a union that keeps a string member receives a string that parses to an
@@ -373,12 +473,14 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
373
473
  **Who must act:** callers that send a JSON array as text to a string-or-array field; a plain
374
474
  string, including one that is not a list the array member accepts, is unchanged.
375
475
  → ADR 0218, ADR 0239, ADR 0238
476
+ **Affects:** `stitchkit/tools`, `stitchkit/cli` behaviour
376
477
  - `stitchkit/agent-runtime` — **the `stitchkit/agent-runtime/harness-tools` leaf is removed.** It
377
478
  was one `mountAgent` call with the run's fence composed in; no consumer imported it.
378
479
  `// before: tools: createAgentHarnessTools(({ context }) => ({ services: [svc], context }))` →
379
480
  `// after: tools: ({ context, toolFenceLifecycle }) => mountAgent([svc], { context, lifecycle: composeToolLifecycle(undefined, toolFenceLifecycle) })`
380
481
  **Who must act:** imports of `stitchkit/agent-runtime/harness-tools`. See
381
482
  [migration](docs/guide/upgrading.md#one-runtime-tool-declaration).
483
+ **Affects:** `stitchkit/agent-runtime/harness-tools` *
382
484
  - `stitchkit/agent-runtime/realtime`, `stitchkit/agent-runtime/browser` — **control errors use one
383
485
  vocabulary, and the binding authorizes requests, not events.** `ACCESS_DENIED` is `FORBIDDEN`, and
384
486
  a closed connection answers `CONNECTION_CLOSED` instead of a denial. `AgentControlErrorCode`
@@ -393,6 +495,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
393
495
  `// after: if (state.error?.code === 'FORBIDDEN') …`
394
496
  **Who must act:** code that compares control error codes, and applications that revoke access while
395
497
  a stream is open (call `binding.revoke`; before, every event re-asked `authorize`).
498
+ **Affects:** `stitchkit/agent-runtime/browser` AgentControlErrorCode, AgentControlErrorCodeSchema, AgentControllerState(error); `stitchkit/agent-runtime/realtime` bindAgentHarnessRealtime(authorize), AgentHarnessRealtimeBinding(revoke)
396
499
  - `stitchkit/contract`, `stitchkit/server`, `stitchkit/node` — **`AppError` takes its fields by
397
500
  name.** The constructor had seven positions, so a call that set only `retryable` read
398
501
  `new AppError(code, message, 409, undefined, undefined, undefined, true)`. The code stays first;
@@ -405,6 +508,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
405
508
  The `notFound`, `badRequest`, `unauthorized`, `forbidden`, `conflict` and `rateLimited` helpers
406
509
  are unchanged. See [migration](docs/guide/upgrading.md#error-constructors-take-named-options).
407
510
  → ADR 0238
511
+ **Affects:** `stitchkit/contract`, `stitchkit/server`, `stitchkit/node` AppError
408
512
  - `stitchkit` — **`ApiError` takes its fields by name.** The constructor had eight positions
409
513
  and call sites ended in `undefined, undefined, retryable`. The code stays first and the rest
410
514
  is one options object; `new ApiError(code)` still works:
@@ -416,6 +520,7 @@ and code that imports `publishCli` or its types from `stitchkit/cli`.
416
520
  `retryable` or `cause` is unaffected. See
417
521
  [migration](docs/guide/upgrading.md#error-constructors-take-named-options).
418
522
  → ADR 0238
523
+ **Affects:** `stitchkit` ApiError
419
524
 
420
525
  ### Added
421
526
 
@@ -559,16 +664,19 @@ native CLI commands and ordinary one-argument state transitions remain valid.
559
664
  in `CliConfig.runtimeTools` / `CliInvokerConfig.runtimeTools`. Existing typed definitions and
560
665
  native `commands` need no change. See [migration](docs/guide/upgrading.md#released-migration-01040).
561
666
  → ADR 0227
667
+ **Affects:** `stitchkit/cli` CliConfig(runtimeTools), CliInvokerConfig(runtimeTools)
562
668
  - `stitchkit/application` — custom state adapters must supply an active, fenced
563
669
  `StateStoreUpdateContext`: `transition(current)` → `transition(current, context)` inside
564
670
  their protected transaction. Remove file-store `staleLockMs` / `retryMs`:
565
671
  `{ staleLockMs, retryMs, lockTimeoutMs }` → `{ lockTimeoutMs }`. Live and unknown owners
566
672
  cannot be reclaimed by age; legacy lock recovery requires proof that the owner stopped.
567
673
  Ordinary one-argument transition callbacks still work. → ADR 0228
674
+ **Affects:** `stitchkit/application` StateStore, StateStoreUpdate, StateStoreUpdateContext; `stitchkit/server` createFileStateStore(staleLockMs), FileStateStoreOptions(retryMs)
568
675
  - `stitchkit/telegram` — broadcast halt uses `TelegramBroadcastFailure`:
569
676
  `report.halt.reason` → `report.halt.kind`. An unknown send outcome becomes durable
570
677
  `uncertain` and halts without replay; explicit retry classifiers certify that the failed
571
678
  attempt did not apply its effect. → ADR 0228
679
+ **Affects:** `stitchkit/telegram` runTelegramBroadcast(halt), TelegramBroadcastReport(halt)
572
680
  - `stitchkit/tools`, `stitchkit/tools/mcp` — construct schema-dependent MCP tools before
573
681
  heterogeneous registration: `runtimeTools: [{ input, output, handler, present }]` →
574
682
  `const tool = { … } satisfies RuntimeMcpToolDefinitionWithOutput<typeof input, typeof output>; runtimeTools: [tool]`.
@@ -576,16 +684,19 @@ native CLI commands and ordinary one-argument state transitions remain valid.
576
684
  official SDK's required content and metadata types: `present: { mcp: () => ({}) }` →
577
685
  `present: { mcp: () => ({ content: [] }) }`. **Who must act:** inline MCP constructors
578
686
  and presenters returning malformed content or metadata. → ADR 0231
687
+ **Affects:** `stitchkit/tools` createMcpHandler(runtimeTools), mountMcp(runtimeTools); `stitchkit/tools/mcp` buildMcpServer(runtimeTools), RuntimeMcpToolPresenters
579
688
  - `stitchkit/contract`, `stitchkit/remote` — error envelopes and framed errors admit an
580
689
  optional boolean `retryable`. A closed error schema must add
581
690
  `retryable: z.boolean().optional()` before upgrading producers that declare it; envelopes
582
691
  without a declaration remain unchanged. See [migrations](docs/guide/upgrading.md).
583
692
  These migrations require a minor release. → ADR 0232
693
+ **Affects:** `stitchkit/contract`, `stitchkit/remote` behaviour
584
694
  - `stitchkit/tools`, `stitchkit/cli` — raw unexpected tool errors are observed through
585
695
  `hooks.onToolError` / `hooks.afterToolCall` instead of being printed on protocol stderr.
586
696
  **Who must act:** applications collecting raw tool causes from `console.error`; configure
587
697
  an internal hook sink instead. MCP resolver failures reach the same observing hooks without
588
698
  rerunning the handler or its lifecycle. → ADR 0229
699
+ **Affects:** `stitchkit/tools`, `stitchkit/cli` behaviour
589
700
 
590
701
  ### Fixed
591
702
 
package/README.md CHANGED
@@ -359,11 +359,13 @@ import { parseSSE } from 'stitchkit' // client: Response → AsyncGene
359
359
  | **Cache Bridge** | `createCacheBridge()` — socket events → TanStack Query cache |
360
360
  | **Auth** | `createAuthHook()` / `createBearerResolver()` — scope-aware auth from `contract.scope` |
361
361
  | **SSE Streaming** | `streamSSE()` / `parseSSE()` — async generator ↔ SSE |
362
+ | **NDJSON** | `ndjsonRoute()` / `parseNDJSON()` / `createNDJSONDecoder()` — bounded lines from a response, a child's stdout or a socket |
362
363
  | **Events** | `createEventBus<EventMap>()` — typed in-process pub/sub |
363
364
  | **Multipart** | typed buffered or streaming single/multi-file uploads with limits and MIME policy |
364
365
  | **Rate Limiting** | `createRateLimiter()` — token bucket, per-key |
365
366
  | **Cache** | `createCache()` — in-memory with TTL + `cacheHeaders()` |
366
367
  | **Errors** | `AppError`, `notFound()`, `badRequest()`, `unauthorized()` |
368
+ | **Manual time** | `createManualClock()` (`stitchkit/testing`) — schedules, retries and deadlines advanced by the test, in order |
367
369
 
368
370
  ## How it compares
369
371
 
package/darwin-native.cjs CHANGED
@@ -22,3 +22,4 @@ module.exports = function loadDarwinAddon() {
22
22
  throw new Error('Darwin addon loading failed', { cause });
23
23
  }
24
24
  };
25
+ module.exports.stitchkitNativeLoader = 'stitchkit-native-loader:unpackaged';
@@ -1,4 +1,4 @@
1
- import type { ChildProcessWithoutNullStreams } from 'node:child_process';
1
+ import type { OwnedChild } from '../process/bun-child.js';
2
2
  import type { AgentProcessSandbox } from './sandbox.js';
3
3
  /**
4
4
  * All entry paths share one command admission limit and one shutdown barrier.
@@ -11,9 +11,9 @@ import type { AgentProcessSandbox } from './sandbox.js';
11
11
  */
12
12
  export declare function sandboxProcessOwner(assertActive: () => void, maximum: number): {
13
13
  admit: () => void;
14
- track: (child: ChildProcessWithoutNullStreams) => void;
14
+ track: (child: OwnedChild) => void;
15
15
  readonly size: number;
16
- spawn(input: Parameters<AgentProcessSandbox['prepare']>[0]): ChildProcessWithoutNullStreams;
16
+ spawn(input: Parameters<AgentProcessSandbox['prepare']>[0]): OwnedChild;
17
17
  stop(): Promise<void>;
18
18
  };
19
19
  //# sourceMappingURL=sandbox-process-owner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-process-owner.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAKzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM;;mBAarD,8BAA8B;;iBAsCrC,UAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;EAqB7D"}
1
+ {"version":3,"file":"sandbox-process-owner.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process-owner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAKvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,IAAI,EAAE,OAAO,EAAE,MAAM;;mBAUrD,UAAU;;iBAsCjB,UAAU,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;;EAqB7D"}
@@ -1,8 +1,8 @@
1
- import type { ChildProcessWithoutNullStreams } from 'node:child_process';
1
+ import type { OwnedChild } from '../process/bun-child.js';
2
2
  import { type SandboxProcess, type SandboxRunOptions } from './sandbox-contract.js';
3
3
  /** Sandbox admission and mandatory caps adapt the shared native command owner. */
4
4
  export declare function spawnSandboxProcess(executable: string, args: string[], limits: {
5
5
  timeoutMs: number;
6
6
  maxOutputBytes: number;
7
- }, options?: SandboxRunOptions, onSpawn?: (child: ChildProcessWithoutNullStreams) => void): SandboxProcess;
7
+ }, options?: SandboxRunOptions, onSpawn?: (child: OwnedChild) => void): SandboxProcess;
8
8
  //# sourceMappingURL=sandbox-process.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sandbox-process.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AAGzE,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,GAAE,iBAAsB,EAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,GACxD,cAAc,CA8ChB"}
1
+ {"version":3,"file":"sandbox-process.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/sandbox-process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAAgB,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,EACrD,OAAO,GAAE,iBAAsB,EAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GACpC,cAAc,CA8ChB"}
@@ -8,11 +8,6 @@ export declare function userMessage(conversationId: string, id: string): {
8
8
  parts: ({
9
9
  type: "text";
10
10
  text: string;
11
- } | {
12
- type: "file";
13
- mediaType: string;
14
- reference: string;
15
- filename?: string | undefined;
16
11
  } | {
17
12
  type: "reasoning";
18
13
  text: string;
@@ -21,6 +16,11 @@ export declare function userMessage(conversationId: string, id: string): {
21
16
  provider: string;
22
17
  data: Record<string, import("zod").JSONType>;
23
18
  } | undefined;
19
+ } | {
20
+ type: "file";
21
+ mediaType: string;
22
+ reference: string;
23
+ filename?: string | undefined;
24
24
  } | {
25
25
  type: "source";
26
26
  sourceId: string;
@@ -1,17 +1,25 @@
1
1
  import type { StreamFinalLinePolicy } from '../contract/define.js';
2
- export { DEFAULT_STREAM_LINE_BYTES } from '../internal/bounded-lines.js';
3
- /** Options for `parseNDJSON`. */
2
+ import { type StreamByteSource } from '../internal/bounded-lines.js';
3
+ export { DEFAULT_STREAM_LINE_BYTES, type StreamByteSource, StreamLineLimitError, StreamTruncatedLineError, } from '../internal/bounded-lines.js';
4
+ /** Options for `parseNDJSON` and `createNDJSONDecoder`. */
4
5
  export interface ParseNDJSONOptions {
5
- /** Maximum bytes retained for one line. Default 1 MiB. */
6
+ /** Maximum bytes retained for one line; past it, `StreamLineLimitError`. Default 1 MiB. */
6
7
  maxLineBytes?: number;
7
8
  /** Called for invalid UTF-8/JSON; without it parsing fails closed. */
8
9
  onParseError?: (raw: string, error: Error) => void;
9
- /** Default `allow`; use `require-newline` when a missing delimiter means truncation. */
10
+ /**
11
+ * Default `allow`; use `require-newline` when a missing delimiter means truncation (a socket or
12
+ * a child's stdout that ends mid-line), so the fragment is `StreamTruncatedLineError`, not a value.
13
+ */
10
14
  finalLine?: StreamFinalLinePolicy;
15
+ /** Stops reading and cancels the source; the iteration rejects with the signal's reason. */
16
+ signal?: AbortSignal;
11
17
  }
12
18
  /**
13
- * Parse a newline-delimited JSON response body — the client half of
14
- * `ndjsonRoute`.
19
+ * Parse newline-delimited JSON — the client half of `ndjsonRoute`, and the reader for any other
20
+ * byte source: a `Response`, a `ReadableStream<Uint8Array>` (a fetch body, a Bun child's
21
+ * `stdout`) or an `AsyncIterable<Uint8Array>` (a Node child's `stdout`). A source that delivers
22
+ * bytes through a callback, such as a `Bun.listen` socket, uses `createNDJSONDecoder`.
15
23
  *
16
24
  * **Blank lines are skipped**, and that is the contract rather than a
17
25
  * convenience. A long-lived NDJSON stream has to send something while it is
@@ -26,18 +34,36 @@ export interface ParseNDJSONOptions {
26
34
  * the other end stayed alive for seconds afterwards. An aborted request reaches
27
35
  * the route's `context.signal` at once.
28
36
  */
29
- export declare function parseNDJSON<T>(response: Response, options?: ParseNDJSONOptions): AsyncGenerator<T>;
37
+ export declare function parseNDJSON<T>(source: StreamByteSource, options?: ParseNDJSONOptions): AsyncGenerator<T>;
38
+ /**
39
+ * Push-driven NDJSON for a source that hands over bytes through a callback. `push` returns the
40
+ * values its chunk completed; `end` returns the value of an unterminated final line, or throws
41
+ * `StreamTruncatedLineError` under `finalLine: 'require-newline'`.
42
+ */
43
+ export interface NDJSONDecoder<T> {
44
+ push(chunk: Uint8Array): T[];
45
+ end(): T[];
46
+ }
47
+ /**
48
+ * The same bounded, fatal-UTF-8 NDJSON reading as `parseNDJSON`, for a `Bun.listen` /
49
+ * `Bun.connect` socket's `data` handler or any other callback source. A line past
50
+ * `maxLineBytes` throws `StreamLineLimitError` as soon as it crosses the limit; invalid JSON
51
+ * goes to `onParseError` or throws. (`signal` does not apply: the caller owns the source.)
52
+ */
53
+ export declare function createNDJSONDecoder<T>(options?: Omit<ParseNDJSONOptions, 'signal'>): NDJSONDecoder<T>;
30
54
  /** Options for `parseSSE`. */
31
55
  export interface ParseSSEOptions {
32
- /** Maximum bytes retained for one SSE line. Default 1 MiB. */
56
+ /** Maximum bytes retained for one SSE line; past it, `StreamLineLimitError`. Default 1 MiB. */
33
57
  maxLineBytes?: number;
34
58
  /** Called for invalid UTF-8/JSON; without it parsing fails closed. */
35
59
  onParseError?: (raw: string, error: Error) => void;
60
+ /** Stops reading and cancels the source; the iteration rejects with the signal's reason. */
61
+ signal?: AbortSignal;
36
62
  }
37
63
  /**
38
- * Parse a Server-Sent Events `Response` body into an async generator of JSON
39
- * values — the client counterpart of `streamSSE`. Stops at the `[DONE]`
40
- * sentinel; the stream lock is released on every exit path.
64
+ * Parse Server-Sent Events into an async generator of JSON values — the client counterpart of
65
+ * `streamSSE`. Reads the same byte sources as `parseNDJSON`. Stops at the `[DONE]` sentinel;
66
+ * the source is cancelled on every exit path.
41
67
  */
42
- export declare function parseSSE<T>(response: Response, options?: ParseSSEOptions): AsyncGenerator<T>;
68
+ export declare function parseSSE<T>(source: StreamByteSource, options?: ParseSSEOptions): AsyncGenerator<T>;
43
69
  //# sourceMappingURL=stream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/browser/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAEtE,iCAAiC;AACjC,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACnD,wFAAwF;IACxF,SAAS,CAAC,EAAE,qBAAqB,CAAC;CACnC;AAYD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAuB,WAAW,CAAC,CAAC,EAClC,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,cAAc,CAAC,CAAC,CAAC,CAkBnB;AAED,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACpD;AAED;;;;GAIG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,eAAe,GACxB,cAAc,CAAC,CAAC,CAAC,CAuBnB"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/browser/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,yBAAyB,EACzB,KAAK,gBAAgB,EACrB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAEnC,2DAA2D;AAC3D,MAAM,WAAW,kBAAkB;IACjC,2FAA2F;IAC3F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACnD;;;OAGG;IACH,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAClC,4FAA4F;IAC5F,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAiBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAuB,WAAW,CAAC,CAAC,EAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,cAAc,CAAC,CAAC,CAAC,CA4BnB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,EAAE,CAAC;IAC7B,GAAG,IAAI,CAAC,EAAE,CAAC;CACZ;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,OAAO,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,QAAQ,CAAC,GAC3C,aAAa,CAAC,CAAC,CAAC,CAkClB;AAED,8BAA8B;AAC9B,MAAM,WAAW,eAAe;IAC9B,+FAA+F;IAC/F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACnD,4FAA4F;IAC5F,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAuB,QAAQ,CAAC,CAAC,EAC/B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,eAAe,GACxB,cAAc,CAAC,CAAC,CAAC,CA6BnB"}
@@ -6,9 +6,9 @@ import {
6
6
  AgentCodingToolAuthorizationSchema2,
7
7
  AgentCodingToolPathAuthorizationSchema2,
8
8
  createAgentCodingTools2
9
- } from "../../index-dwf0gymy.js";
9
+ } from "../../index-e35py42g.js";
10
10
  import"../../index-2kbysk9s.js";
11
- import"../../index-4q9jvqg7.js";
11
+ import"../../index-epg514ys.js";
12
12
  import"../../index-8ks9b85e.js";
13
13
  import"../../index-zrtrjkbf.js";
14
14
  import"../../index-636mggad.js";
@@ -8,7 +8,7 @@ import"../../index-q6crhe1n.js";
8
8
  import"../../index-fynr93w4.js";
9
9
  import {
10
10
  createAgentCodingTools2
11
- } from "../../index-dwf0gymy.js";
11
+ } from "../../index-e35py42g.js";
12
12
  import"../../index-2kbysk9s.js";
13
13
  import {
14
14
  COMMAND_CLEANUP_TIMEOUT_MS,
@@ -17,7 +17,7 @@ import {
17
17
  nativeCommandOwner,
18
18
  terminateOwnedGroup,
19
19
  startNativeCommand
20
- } from "../../index-4q9jvqg7.js";
20
+ } from "../../index-epg514ys.js";
21
21
  import"../../index-zrtrjkbf.js";
22
22
  import {
23
23
  MAX_TIMER_MS
@@ -18,10 +18,10 @@ import {
18
18
  createBoundedChannel2
19
19
  } from "../../index-w0eqdhyd.js";
20
20
  import"../../index-2kbysk9s.js";
21
- import"../../index-7r74re56.js";
21
+ import"../../index-bh2ht9y5.js";
22
22
  import {
23
23
  attemptExclusiveLock
24
- } from "../../index-bnf8s6v3.js";
24
+ } from "../../index-t2bsd0hm.js";
25
25
  import {
26
26
  BoundedFileReadError,
27
27
  openRegularFile
@@ -14,15 +14,15 @@ import {
14
14
  backoffDelay
15
15
  } from "../../index-g6a3na27.js";
16
16
  import"../../index-2kbysk9s.js";
17
- import"../../index-7r74re56.js";
18
- import"../../index-bnf8s6v3.js";
17
+ import"../../index-bh2ht9y5.js";
18
+ import"../../index-t2bsd0hm.js";
19
19
  import {
20
20
  defineManagedResource2
21
21
  } from "../../index-50ejfz75.js";
22
22
  import {
23
23
  createFileStateStore2
24
- } from "../../index-mbf4h8kp.js";
25
- import"../../index-4f37d3bg.js";
24
+ } from "../../index-nx49x0tw.js";
25
+ import"../../index-w9mqgnz9.js";
26
26
  import {
27
27
  raceAbort
28
28
  } from "../../index-b0kddvzw.js";
@@ -1,4 +1,36 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * `stitchkit upgrade` — the migration plan, from the package itself.
4
+ *
5
+ * A consumer used to recover its plan by cloning this repository and running a
6
+ * script that lives only here, or by being handed the version range in a letter.
7
+ * Both make upgrading depend on us. The changelog ships inside the package and
8
+ * this binary reads it, so `bunx stitchkit@latest upgrade` answers "what do I
9
+ * have to change" in one command, in the consumer's own project, with nobody
10
+ * told anything.
11
+ *
12
+ * Node built-ins only, and a `node` shebang: `npx` must work as well as `bunx`.
13
+ */
14
+ import { type Dirent } from 'node:fs';
15
+ import { type ProjectSource } from '../../internal/upgrade-usage.js';
16
+ /** How the scan reads the project; a test substitutes a refusal no file mode produces for root. */
17
+ export interface ProjectSourceIo {
18
+ readdir(path: string): readonly Dirent[];
19
+ readFile(path: string): string;
20
+ }
21
+ /** A directory or file the scan could not read, by path relative to the project root. */
22
+ export interface Unscanned {
23
+ readonly path: string;
24
+ readonly code: string;
25
+ }
26
+ /**
27
+ * Every source file of the project, by path relative to its root; links are not followed. A
28
+ * directory or file the process may not read is listed as unscanned rather than ending the plan.
29
+ */
30
+ export declare function projectSources(root: string, io?: ProjectSourceIo): {
31
+ sources: ProjectSource[];
32
+ unscanned: Unscanned[];
33
+ };
2
34
  export interface UpgradeCliResult {
3
35
  /** What to write to stdout. */
4
36
  readonly output: string;
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-cli.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/bin/upgrade-cli.ts"],"names":[],"mappings":";AAgEA,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CAqCvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CASrF"}
1
+ {"version":3,"file":"upgrade-cli.d.ts","sourceRoot":"","sources":["../../../src/entrypoints/bin/upgrade-cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,MAAM,EAA2C,MAAM,SAAS,CAAC;AAI/E,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,8BAA8B,CAAC;AA4BtC,mGAAmG;AACnG,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAChC;AAED,yFAAyF;AACzF,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAWD;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,EAAE,GAAE,eAGH,GACA;IAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAAC,SAAS,EAAE,SAAS,EAAE,CAAA;CAAE,CAiCtD;AAoCD,MAAM,WAAW,gBAAgB;IAC/B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,gBAAgB,CA+DvE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CASrF"}