stitchkit 0.113.2 → 0.114.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/contract/errors.d.ts +1 -0
  3. package/dist/contract/errors.d.ts.map +1 -1
  4. package/dist/entrypoints/agent-runtime/browser.js +2 -2
  5. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  6. package/dist/entrypoints/agent-runtime/harness.js +5 -5
  7. package/dist/entrypoints/agent-runtime/realtime.js +2 -2
  8. package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
  9. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  10. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  11. package/dist/entrypoints/agent-runtime/testing.js +6 -6
  12. package/dist/entrypoints/agent-runtime.js +11 -11
  13. package/dist/entrypoints/application/grammy.js +1 -1
  14. package/dist/entrypoints/application.js +2 -2
  15. package/dist/entrypoints/cli.js +8 -8
  16. package/dist/entrypoints/contract.js +2 -2
  17. package/dist/entrypoints/files.js +1 -1
  18. package/dist/entrypoints/index.js +5 -5
  19. package/dist/entrypoints/node.js +7 -7
  20. package/dist/entrypoints/observability.js +1 -1
  21. package/dist/entrypoints/realtime.js +3 -3
  22. package/dist/entrypoints/remote.js +1 -1
  23. package/dist/entrypoints/server.js +8 -8
  24. package/dist/entrypoints/telegram/screens.js +1 -1
  25. package/dist/entrypoints/telegram.d.ts +1 -0
  26. package/dist/entrypoints/telegram.d.ts.map +1 -1
  27. package/dist/entrypoints/telegram.js +241 -1
  28. package/dist/entrypoints/testing.js +3 -3
  29. package/dist/entrypoints/tools/connections.js +5 -5
  30. package/dist/entrypoints/tools/invoker.js +5 -5
  31. package/dist/entrypoints/tools/mcp.js +7 -7
  32. package/dist/entrypoints/tools.js +13 -13
  33. package/dist/{index-cn7xenet.js → index-095ya5hm.js} +5 -5
  34. package/dist/{index-6ez1r4j2.js → index-1csp1hwm.js} +4 -4
  35. package/dist/{index-sps9s3aj.js → index-2bqf0a74.js} +1 -1
  36. package/dist/{index-grn4brx1.js → index-3za04re9.js} +1 -1
  37. package/dist/{index-09dyy94r.js → index-523tq7y4.js} +1 -1
  38. package/dist/{index-8swt2h9y.js → index-7fc0c2np.js} +1 -1
  39. package/dist/{index-2s7wv547.js → index-86nbfysb.js} +3 -3
  40. package/dist/{index-5gmrx6sc.js → index-98hv3sba.js} +1 -1
  41. package/dist/{index-4e36ts8b.js → index-9dyd8xzf.js} +1 -1
  42. package/dist/{index-zbs0g0v2.js → index-aykhzcnf.js} +1 -1
  43. package/dist/{index-0pfk3c1p.js → index-bjcjqj46.js} +1 -1
  44. package/dist/{index-vgtzdykw.js → index-cqmqyjax.js} +1 -1
  45. package/dist/{index-bv51s0f4.js → index-ega3yz4c.js} +1 -1
  46. package/dist/{index-awbed0mk.js → index-fy4av0hq.js} +1 -1
  47. package/dist/{index-xvj9h8yh.js → index-hs35ss3p.js} +11 -3
  48. package/dist/{index-0gbn42hr.js → index-htxh46ej.js} +3 -3
  49. package/dist/{index-shg5xc9t.js → index-jk29rwkr.js} +1 -1
  50. package/dist/{index-e40rzw1m.js → index-k42ckyzx.js} +1 -1
  51. package/dist/{index-xtc8k5n9.js → index-k7z3j3hr.js} +47 -16
  52. package/dist/{index-pd578538.js → index-qcn84byh.js} +1 -0
  53. package/dist/{index-vf9c59t3.js → index-rhzkndr5.js} +2 -2
  54. package/dist/{index-z8fnfj42.js → index-tpwbct8j.js} +1 -1
  55. package/dist/{index-7ysby53h.js → index-v1tswj0z.js} +1 -1
  56. package/dist/{index-a31p9ekx.js → index-v6vb5qx8.js} +4 -4
  57. package/dist/{index-5zxe0f3h.js → index-vtann8bz.js} +3 -3
  58. package/dist/{index-kvga921h.js → index-vwhrnp67.js} +4 -4
  59. package/dist/{index-ptjx84pr.js → index-zktz242w.js} +2 -2
  60. package/dist/telegram/outbound-budget.d.ts +99 -0
  61. package/dist/telegram/outbound-budget.d.ts.map +1 -0
  62. package/dist/telegram/send-failure.d.ts +6 -1
  63. package/dist/telegram/send-failure.d.ts.map +1 -1
  64. package/dist/tools/cli/command.d.ts +2 -1
  65. package/dist/tools/cli/command.d.ts.map +1 -1
  66. package/dist/tools/cli/format.d.ts +5 -1
  67. package/dist/tools/cli/format.d.ts.map +1 -1
  68. package/dist/tools/cli/run-native.d.ts.map +1 -1
  69. package/llms/cli.2.txt +281 -0
  70. package/llms/cli.txt +18 -285
  71. package/llms/server.4.txt +6 -1
  72. package/llms/stitchkit.txt +4 -4
  73. package/llms/telegram.txt +64 -2
  74. package/llms/{upgrading-0.103.13-0.113.0.txt → upgrading-0.104.0-0.114.0.txt} +45 -84
  75. package/llms/upgrading-0.37.0-0.44.0.txt +444 -0
  76. package/llms/{upgrading-0.44.0-0.60.0.txt → upgrading-0.44.0-0.61.0.txt} +140 -271
  77. package/llms/{upgrading-0.61.0-0.74.0.txt → upgrading-0.62.0-0.78.0.txt} +137 -140
  78. package/llms/{upgrading-0.75.0-0.103.0.txt → upgrading-0.79.0-0.103.13.txt} +84 -137
  79. package/llms/upgrading.txt +5 -5
  80. package/llms-full.txt +134 -11
  81. package/llms.txt +9 -9
  82. package/package.json +1 -1
  83. package/llms/upgrading-0.37.0.txt +0 -176
@@ -75,7 +75,7 @@ own, recorded as an ADR.
75
75
  | `stitchkit/process/owner-loss` | bundled server entry (Bun, POSIX) | evolving | narrow bootstrap that keeps the process runner lazy while carrying its owner-loss guard in a single-file bundle |
76
76
  | `stitchkit/files/packaging` | build time (Bun or Node) | evolving | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; no runtime install policy |
77
77
  | `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
78
- | `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
78
+ | `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and shared 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
79
79
  | `stitchkit/telegram/html` | browser and server | evolving | Telegram's HTML as a tree — clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
80
80
  | `stitchkit/telegram/screens` | server (Bun or Node) | evolving | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
81
81
  | `stitchkit/tracking` | browser **and** server | evolving | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
@@ -85,12 +85,12 @@ own, recorded as an ADR.
85
85
  | `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
86
86
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
87
87
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
88
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 58 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
88
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 59 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
89
89
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
90
90
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
91
91
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
92
92
  | `stitchkit/react/keyboard` | browser | evolving | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
93
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 24 of the 58 minors since 0.56.2, most recently 0.113.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
93
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 24 of the 59 minors since 0.56.2, most recently 0.113.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
94
94
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
95
95
  | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
96
96
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -102,7 +102,7 @@ own, recorded as an ADR.
102
102
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
103
103
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
104
104
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
105
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 58 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
105
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 59 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
106
106
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
107
107
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
108
108
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
package/llms/telegram.txt CHANGED
@@ -86,6 +86,67 @@ The error line contract, for whatever recognises a failure from the journal: a
86
86
  line whose `level` is `50` or more is an error. There is no separate `fatal`;
87
87
  an unrecoverable end is an `error` line followed by a non-zero exit.
88
88
 
89
+ ## One token, one outbound budget
90
+
91
+ Telegram counts a bot's bulk messages per token, not per campaign, handler or
92
+ module. `telegramOutboundBudget` is that budget once: every alias of one token
93
+ in the process gets the same object, another token gets another, and every send
94
+ through it spends its weight. → [ADR 0274](../decisions/0274-a-telegram-token-has-one-outbound-budget.md).
95
+
96
+ ```ts
97
+ import { telegramOutboundBudget } from 'stitchkit/telegram'
98
+
99
+ const budget = telegramOutboundBudget({
100
+ token: env.BOT_TOKEN,
101
+ messagesPerSecond: 24,
102
+ })
103
+
104
+ // The one transformer of the bot's client. No second limiter, no second
105
+ // scheduler: campaigns, replies and every other send of this token share it.
106
+ api.config.use((previous, method, payload, signal) =>
107
+ budget.run(method, payload, signal, () => previous(method, payload, signal)),
108
+ )
109
+ ```
110
+
111
+ - **The token is the identity, not the sender.** Two bot objects built from one
112
+ token share the budget; two different tokens do not. The registry keeps a
113
+ 128-bit identity, never the credential, and `stats()` contains no token.
114
+ - **A message is the unit.** `sendMediaGroup` and `sendPaidMedia` cost their
115
+ media length, `copyMessages` and `forwardMessages` cost their message ids, and
116
+ a follow-up call to action after an album costs one more. Reads and edits
117
+ (`getMe`, `getFile`, `editMessage*`, `deleteMessage`, `sendChatAction`) do not
118
+ spend the budget.
119
+ - **The first send after idle is immediate; the rest are spaced.** This is a
120
+ strict budget, not a bucket that saves a burst: at 24/s the next send is due
121
+ one interval later. A 429 pauses the whole token; when it resumes, one send
122
+ is released at the deadline and the queue continues one interval at a time,
123
+ never as a stampede.
124
+ - **It paces; it does not retry.** `run` calls the send once. A 429 pauses the
125
+ token for Telegram's `retry_after` (or `retryAfterFallbackMs` when Telegram
126
+ gave none) and rethrows; the caller's retry policy decides what happens next.
127
+ A 429 from an edit or a read is still a fact about the token and pauses later
128
+ sends too. A network failure is rethrown unchanged and stays `unknown`; a 5xx
129
+ is rethrown unchanged and stays `server-error`. Neither is retried by the
130
+ budget or pauses the token — repeating a send whose outcome is unknown is a
131
+ decision, not a primitive's silent guess.
132
+ - **A wait can be cancelled.** `run`/`acquire` take an `AbortSignal`; a
133
+ cancelled waiter spends no slot and calls no provider. A granted send that is
134
+ then aborted is not evidence that Telegram did not accept it — keep the
135
+ outcome unknown rather than retrying it as a definite failure.
136
+ - **Non-send retries wait without spending.** An edit or delete retry that got
137
+ a 429 first records the pause with `budget.pauseAfter(error)` (the `run` path
138
+ does this itself), then uses `await budget.waitUntilResumed(signal)`; it shares
139
+ the token's pause but does not take a message slot.
140
+
141
+ `telegramBroadcastSender` and `telegramOperatorSender` still send through
142
+ `callTelegramBotApi`; they are not a second budget. Their returned function does
143
+ not expose the method and payload, so a product that uses one wraps the concrete
144
+ `sendMessage`/`copyMessage` call in `budget.run` where it knows both, or passes
145
+ its own sender. There is no generic wrapper around the opaque sender.
146
+ `runTelegramBroadcast` keeps its per-run `ratePerSecond` and the operator
147
+ channel keeps its per-chat `minIntervalMs`; those are caps of their own jobs,
148
+ not another token quota. The token budget is the binding shared cap.
149
+
89
150
  ## The operator channel
90
151
 
91
152
  The chat where people read about new users, payments and failures is not the
@@ -519,7 +580,7 @@ can read its media.
519
580
  Peer-free server-only Telegram platform primitives — the Bot API's own
520
581
  protocols and the jobs every bot rewrote around them. Importing this resolves no
521
582
  bot library; `stitchkit/application/grammy` remains the lifecycle adapter for an
522
- injected grammY bot. → ADR 0143, ADR 0201 — [guide](../guide/telegram.md)
583
+ injected grammY bot. → ADR 0143, ADR 0201, ADR 0274 — [guide](../guide/telegram.md)
523
584
 
524
585
  | Export | Kind | Summary |
525
586
  |--------|------|---------|
@@ -534,7 +595,8 @@ injected grammY bot. → ADR 0143, ADR 0201 — [guide](../guide/telegram.md)
534
595
  | `createTelegramBotTransport` / `TelegramBotTransportOptions` | function / _type_ | a `fetch` for the Bot API senders that connects before it writes, so a failure before the first byte is `TelegramNotDispatchedError`; connection attempt and budget, answer timeout and size, injectable resolver and socket factory — [guide](../guide/telegram.md#a-transport-that-knows-whether-a-request-left) |
535
596
  | `TelegramFetch` / `TelegramBotTransportOpen` / `TelegramBotTransportResolve` / `TelegramBotTransportSocket` | _types_ | the `(url, init) => Promise<Response>` the senders take; the transport's socket factory, resolver and the structural socket it needs (a Node `net.Socket` or `tls.TLSSocket` fits) |
536
597
  | `TelegramNotDispatchedError` / `TelegramNotDispatchedStage` | class / _type_ | a request that provably never left (`lookup`, `connect` or `request`), so repeating it cannot duplicate a message |
537
- | `TelegramSendFailureReason` / `TELEGRAM_SEND_FAILURE_REASONS` | _type_ / constant | `blocked-by-user` / `user-deactivated` / `chat-not-found` / `not-started` / `rate-limited` / `message-invalid` / `server-error` / `not-dispatched` / `unknown`, and the same as a list; a `Record<TelegramSendFailureReason, …>` over them fails to compile when a reason is added |
598
+ | `TelegramSendFailureReason` / `TELEGRAM_SEND_FAILURE_REASONS` | _type_ / constant | `blocked-by-user` / `user-deactivated` / `chat-not-found` / `not-started` / `bot-to-bot-disabled` / `rate-limited` / `message-invalid` / `server-error` / `not-dispatched` / `unknown`, and the same as a list; a `Record<TelegramSendFailureReason, …>` over them fails to compile when a reason is added |
599
+ | `telegramOutboundBudget` / `TelegramOutboundBudget` / `TelegramOutboundBudgetConfig` / `TelegramOutboundBudgetStats` | function / _type_ | one token-wide outbound budget: one object per token in the process, strict 24 messages/s by default, weighted albums and multi-message copies, `run(method, payload, signal, send)` as the transformer adapter, `pause`/`pauseAfter` for 429, `waitUntilResumed` for non-send retries and `stats`; it paces and never retries, and no public value carries the token |
538
600
  | `runTelegramBroadcast` | function | a resumable broadcast by `name` under a state `directory`: audience and journal durably recorded, pacing at `ratePerSecond` (25), exact retry delays within the finite declared budget, injected classifier, uncertain send outcomes never replayed, `dryRun`, one fenced runner per name |
539
601
  | `TelegramBroadcastConfig` / `TelegramBroadcastSend` / `TelegramBroadcastReport` / `TelegramBroadcastRunOutcome` / `TelegramBroadcastOutcome` / `TelegramBroadcastRecipient` | _type_ | `name`, `directory`, `recipients()`, `send({ recipient, attempt })`, `maxAttempts`, `signal`, `onProgress`; counts `delivered` / `unreachable` / `failed` / `uncertain` / `pending` and `finished` / `stopped` / `halted` / `dry-run` |
540
602
  | `TelegramBroadcastFailureSchema` / `TelegramBroadcastFailure` | schema / _type_ | injected `classify` answers retry-after/transient/permanent/ambiguous; exact provider delay is bounded by `maxRetryDelayMs` without shortening, unknown outcome remains uncertain and is never replayed |
@@ -1,14 +1,56 @@
1
- # Upgrading 0.103.13 → 0.113.0 — stitchkit docs slice
1
+ # Upgrading 0.104.0 → 0.114.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.103.13 → 0.113.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.104.0 → 0.114.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.103.13 → 0.113.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.104.0 → 0.114.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.114.0
13
+
14
+ **Who must act:** code with an exhaustive `switch` or `Record` over
15
+ `TelegramSendFailureReason` or `TELEGRAM_SEND_FAILURE_REASONS`. Code that only
16
+ reads `retryable` and `recipientUnreachable` needs no change.
17
+
18
+ `classifyTelegramSendFailure` now returns `reason: 'bot-to-bot-disabled'` for a
19
+ `400 USER_BOT_TO_BOT_DISABLED` ([ADR 0274](../decisions/0274-a-telegram-token-has-one-outbound-budget.md)).
20
+ It is permanent for that send, so it is not retried; it is **not**
21
+ `recipientUnreachable`, because Telegram disables bot-to-bot messaging when
22
+ either bot has not enabled its Bot to Bot setting, and the missing setting may
23
+ be the sender's.
24
+
25
+ 1. Add the reason to every exhaustive mapping:
26
+
27
+ ```ts
28
+ // before
29
+ const code: Record<TelegramSendFailureReason, string> = { /* … */ unknown: 'E_UNKNOWN' }
30
+ // after
31
+ const code: Record<TelegramSendFailureReason, string> = {
32
+ /* … */ 'bot-to-bot-disabled': 'E_BOT_TO_BOT', unknown: 'E_UNKNOWN',
33
+ }
34
+ ```
35
+
36
+ Search pattern: `TelegramSendFailureReason`, `TELEGRAM_SEND_FAILURE_REASONS`
37
+ and every `switch` over a send-failure reason.
38
+ 2. Type-check: the exhaustive table without the new member fails to compile.
39
+ 3. If the application wants one outbound budget per bot token, opt in at the
40
+ one transformer that already owns its Bot API calls:
41
+
42
+ ```ts
43
+ import { telegramOutboundBudget } from 'stitchkit/telegram'
44
+
45
+ const budget = telegramOutboundBudget({ token: env.BOT_TOKEN })
46
+ api.config.use((previous, method, payload, signal) =>
47
+ budget.run(method, payload, signal, () => previous(method, payload, signal)),
48
+ )
49
+ ```
50
+
51
+ Remove the old limiter rather than running it beside this one. See the
52
+ [Telegram guide](telegram.md#one-token-one-outbound-budget).
53
+
12
54
  ## Released migration: 0.113.0
13
55
 
14
56
  **Who must act:** custom `AgentRuntimeStoreDriver` adapters and custom `AgentRuntimeStore` implementations of `seedConversationInput`. The built-in memory and SQLite stores already implement the contract.
@@ -814,84 +856,3 @@ signals to `createCli` / `createCliInvoker` and cooperative handlers observe `ct
814
856
  `REQUEST_ABORTED` is nonretryable and exits 130. A disconnected caller does not prove that
815
857
  an origin ignoring cancellation or an external provider stopped; keep resource leases until
816
858
  that work actually completes.
817
-
818
- ## Released migration: 0.103.13
819
-
820
- ### Darwin native assets in JS distributions
821
-
822
- **Who must act:** Bun builds that import `stitchkit/server`, `stitchkit/files` or
823
- `stitchkit/process` (Linux-only server apps included) and use `--outfile`, copy only
824
- `outputs[0]`, or package a single file; custom single-file/archive packagers and installers
825
- delivering native process/files capabilities.
826
- First affected publication: **0.103.13**, through **0.104.2**. It shipped as a patch; its
827
- changed delivery graph requires this migration despite unchanged API signatures.
828
-
829
- In those versions every Bun bundle that reaches the lock or process-identity code,
830
- `stitchkit/server` included, carries both Darwin `.node` addons as extra outputs on every
831
- operating system. `bun build --outfile` then fails with
832
- `cannot write multiple output files without an output directory`, and `--outdir` writes the
833
- addons next to a Linux artifact. Releases after 0.104.2 resolve the default loader at run time,
834
- so these bundles are one JS file with no `.node` output again. The static loader exists only
835
- in a build that uses the `stitchkit/files/packaging` plugin.
836
-
837
- ```sh
838
- # Before: one JS file was assumed to be the entire distribution.
839
- bun build src/native.ts --target=bun --outfile=dist/native.js
840
- # After: retain every output, with its relative path.
841
- bun build src/native.ts --target=bun --outdir=dist --entry-naming=native.js
842
- ```
843
-
844
- For `Bun.build`, copy **all** `result.outputs`, not just the JS entry or `outputs[0]`.
845
- A single-file JS distribution cannot embed a native `.node` addon automatically.
846
- An archive may contain JS plus companion assets, materialized together before execution.
847
- Custom output layout uses the evolving build-only packaging contract in the
848
- [native IO guide](native-io.md#public-native-packaging).
849
-
850
- Three deliveries have different rules: an ordinary npm install retains the package's
851
- native assets; a JS distribution must ship its complete output graph; a Bun compiled
852
- executable embeds the matching addon and may still use `--outfile`. In 0.103.13–0.104.2 a plain
853
- `bun build` carries the addon without a plugin. Later releases load it from a bundle only when
854
- the build uses `createNativePackaging` (`delivery: 'companion'` for JS, `'embedded'` for a
855
- compiled executable). Without the plugin, Bun may still copy the addon's bytes into a compiled
856
- executable, but the loader never uses them, so their presence proves nothing.
857
-
858
- What an unpackaged bundle does depends on the release:
859
-
860
- - **0.105.0–0.106.1:** the bundle carries the absolute path of the package on the build machine,
861
- because the loader read `__dirname`. It looks for the addon there, so it works only on that
862
- machine, and the path itself leaks into a distributed artifact. Rebuild with a later release.
863
- - **0.107.0 and later:** no build path is in the artifact, and the first call that needs the
864
- addon reports the Darwin backend `unavailable` with stage `packaging`.
865
-
866
- Only macOS is affected, and only process identity (`observeProcessInstance`,
867
- `probeProcessOwner`), exclusive locks and contained Agent file operations load the addon. The
868
- managed file boundary, atomic writes and the chunk spool never do. The
869
- [native IO guide](native-io.md#libraries-with-a-zod-only-runtime) is the canonical recipe and
870
- shows how to check an artifact by its loader without running it on a Mac. Check the resulting
871
- artifact offline outside the build tree and `node_modules`, including process identity,
872
- live-owner lock refusal, dead-owner recovery and contained IO. A missing or corrupt addon
873
- remains `unavailable`, never evidence that an owner died.
874
-
875
- ### CLI: repeated options are refused
876
-
877
- **Who must act:** wrappers, aliases and scripts that append `--json`, `--profile X` or an
878
- application global to arguments the user may already have given, and anything that passes the
879
- same global twice.
880
- First affected publication: **0.103.13**. It shipped as a patch; the change in grammar needs
881
- this migration.
882
-
883
- A repeated option that is not an array field is an argument error:
884
- `--json --json` and `--profile a --profile b` fail with `--json was passed 2 times`. Before
885
- 0.103.13 the last value won, for framework globals, application globals and repeated
886
- `kind: 'other'` fields alike. Array fields, and untyped passthrough fields that keep their
887
- raw-list grammar, still repeat.
888
-
889
- ```sh
890
- # Before: a wrapper appended its default and the last value won.
891
- mytool deploy --profile staging "$@" --profile production
892
- # After: build the argument list once, so each option appears once.
893
- mytool deploy --profile "${PROFILE:-production}" "$@"
894
- ```
895
-
896
- Dotted leaves such as `--filter.name` follow the same rule as their parent field. Declare a
897
- field as an array when repetition is meant.