stitchkit 0.134.1 → 0.134.2

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 (90) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +6 -6
  3. package/dist/agent-runtime/sql-rows.d.ts +10 -10
  4. package/dist/agent-runtime/sqlite-schema.d.ts +2 -2
  5. package/dist/agent-runtime/sqlite.d.ts +1 -1
  6. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
  7. package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
  8. package/dist/agent-runtime/terminal-commit.d.ts +10 -10
  9. package/dist/application/grammy.d.ts +1 -1
  10. package/dist/browser/contract-identity.d.ts +1 -1
  11. package/dist/browser/http-fetch.d.ts +1 -1
  12. package/dist/browser/socket-io-contract.d.ts +1 -1
  13. package/dist/contract/bridge-envelope.d.ts +1 -1
  14. package/dist/contract/client-types.d.ts +1 -1
  15. package/dist/contract/define.d.ts +2 -2
  16. package/dist/contract/errors-factory.d.ts +1 -1
  17. package/dist/contract/fingerprint.d.ts +1 -1
  18. package/dist/device-relay/hub.d.ts +1 -1
  19. package/dist/entrypoints/agent-runtime/postgres.js +3 -3
  20. package/dist/entrypoints/agent-runtime/sqlite/bun.js +1 -1
  21. package/dist/entrypoints/agent-runtime/sqlite/node.js +1 -1
  22. package/dist/entrypoints/bin/upgrade-cli.js +1 -1
  23. package/dist/entrypoints/files/packaging.js +2 -2
  24. package/dist/entrypoints/handler.js +2 -2
  25. package/dist/entrypoints/node.js +2 -2
  26. package/dist/entrypoints/server.js +2 -2
  27. package/dist/entrypoints/tools/mcp.js +3 -3
  28. package/dist/entrypoints/tools/toolkit.js +3 -3
  29. package/dist/entrypoints/tools.js +2 -2
  30. package/dist/files/native-packaging-layout.d.ts +1 -1
  31. package/dist/{index-654rhe5d.js → index-7mjsb7zv.js} +5 -1
  32. package/dist/{index-kdw0n92g.js → index-a09r9ff0.js} +1 -1
  33. package/dist/{index-epyj7ptp.js → index-a84wj6y8.js} +4 -4
  34. package/dist/{index-qymek778.js → index-m2b49tvc.js} +76 -22
  35. package/dist/{index-mrng24wq.js → index-zag9sjpd.js} +1 -1
  36. package/dist/internal/postgres-query.d.ts +1 -1
  37. package/dist/react/query-client.d.ts +1 -1
  38. package/dist/server/bridge-host.d.ts +1 -1
  39. package/dist/server/bun.d.ts +1 -1
  40. package/dist/server/endpoint-dispatch.d.ts.map +1 -1
  41. package/dist/server/middleware/cors.d.ts +3 -3
  42. package/dist/server/middleware/cors.d.ts.map +1 -1
  43. package/dist/server/socket-io-config.d.ts +1 -1
  44. package/dist/service-host/identity.d.ts +1 -1
  45. package/dist/service-host/systemd-inspect.d.ts +1 -1
  46. package/dist/testing/manual-clock.d.ts +1 -1
  47. package/dist/tools/connections/types.d.ts +1 -1
  48. package/dist/tools/mcp/handler.d.ts +1 -1
  49. package/dist/tools/mcp/lazy-discovery.d.ts +1 -1
  50. package/dist/tools/mcp/mount.d.ts +1 -1
  51. package/dist/tools/mcp/stdio.d.ts +1 -1
  52. package/llms/agent-runtime-browser.txt +1 -1
  53. package/llms/agent-runtime-sqlite-bun.txt +1 -1
  54. package/llms/agent-runtime.2.txt +1 -1
  55. package/llms/agent-runtime.3.txt +4 -4
  56. package/llms/agent-runtime.txt +3 -3
  57. package/llms/application.2.txt +4 -4
  58. package/llms/application.txt +4 -4
  59. package/llms/cli.2.txt +27 -6
  60. package/llms/cli.txt +2 -2
  61. package/llms/contract.txt +1 -1
  62. package/llms/files-packaging.txt +1 -1
  63. package/llms/geo.txt +1 -1
  64. package/llms/live.txt +1 -1
  65. package/llms/oauth.txt +4 -4
  66. package/llms/observability.txt +3 -3
  67. package/llms/primitives.txt +1 -1
  68. package/llms/process.2.txt +7 -7
  69. package/llms/react.txt +4 -4
  70. package/llms/server.2.txt +7 -7
  71. package/llms/server.3.txt +5 -5
  72. package/llms/server.4.txt +6 -6
  73. package/llms/server.txt +13 -5
  74. package/llms/stitchkit.2.txt +3 -3
  75. package/llms/stitchkit.3.txt +1 -1
  76. package/llms/stitchkit.txt +4 -4
  77. package/llms/telegram.txt +1 -1
  78. package/llms/testing.txt +4 -4
  79. package/llms/tools-connections.txt +1 -1
  80. package/llms/tools-toolkit.txt +3 -1
  81. package/llms/tools.2.txt +6 -6
  82. package/llms/tools.3.txt +8 -8
  83. package/llms/upgrading-0.106.0-0.126.0.txt +1 -1
  84. package/llms/upgrading-0.128.0-0.134.0.txt +7 -1
  85. package/llms/upgrading-0.37.0-0.53.0.txt +7 -7
  86. package/llms/upgrading-0.69.0-0.95.0.txt +1 -1
  87. package/llms/upgrading-0.96.0-0.105.0.txt +1 -1
  88. package/llms-full.txt +149 -112
  89. package/llms.txt +5 -5
  90. package/package.json +1 -1
package/llms/geo.txt CHANGED
@@ -117,7 +117,7 @@ The previous reader closes only after its in-flight lookups finish.
117
117
 
118
118
  Use `GeoIpReaderLoader` when the database is not MaxMind-compatible. `revision`
119
119
  must identify the complete input generation and return `null` when it cannot be
120
- read. `open` returns a reader for exactly that revision. Stitchkit serializes
120
+ read. `open` returns a reader for exactly that revision. StitchKit serializes
121
121
  reloads, swaps generations and owns their close lifecycle.
122
122
 
123
123
  Download schedules, licenses, database paths, attribution persistence and
package/llms/live.txt CHANGED
@@ -53,7 +53,7 @@ is where the full name is *built*, not a second name for the same topic.
53
53
  ### The wire is the socket you already run
54
54
 
55
55
  `toRealtimeContract` projects the declaration onto `RealtimeContract`. Everything
56
- after that is the machinery Stitchkit already ships — validation both ways,
56
+ after that is the machinery StitchKit already ships — validation both ways,
57
57
  rejection reporting, rooms, and the client's `retain:` replay.
58
58
 
59
59
  ```ts
package/llms/oauth.txt CHANGED
@@ -11,7 +11,7 @@ Contains: Guide: OAuth & OpenID Connect (docs/guide/oauth.md) · API reference:
11
11
 
12
12
  # Browser OAuth and Google OIDC
13
13
 
14
- Stitchkit separates the browser's Authorization Code + PKCE transaction from the server's
14
+ StitchKit separates the browser's Authorization Code + PKCE transaction from the server's
15
15
  provider credential verification. The application still owns navigation, users, account matching
16
16
  and merge policy, persistence, sessions, roles, unlink policy and UI.
17
17
 
@@ -19,13 +19,13 @@ and merge policy, persistence, sessions, roles, unlink policy and UI.
19
19
 
20
20
  The current Google adapter supports one explicit profile: **web OpenID Connect Authorization Code
21
21
  with PKCE**. A browser performs a top-level redirect, an application backend exchanges the
22
- one-time code, and Stitchkit returns a verified identity. It is the redirect-based sign-in path;
22
+ one-time code, and StitchKit returns a verified identity. It is the redirect-based sign-in path;
23
23
  it is not a generic name for every Google identity or authorization mechanism.
24
24
 
25
25
  Keep adjacent Google capabilities separate because their credentials, lifecycle and trust
26
26
  boundaries differ:
27
27
 
28
- | Capability | Credential/result | Stitchkit support |
28
+ | Capability | Credential/result | StitchKit support |
29
29
  | --- | --- | --- |
30
30
  | Web OIDC Authorization Code + PKCE | verified user identity | `stitchkit/oauth` + `stitchkit/google` |
31
31
  | Google Identity Services button, One Tap or FedCM | browser-delivered ID credential | not implemented |
@@ -107,7 +107,7 @@ const identity = await google.exchangeAuthorizationCode({
107
107
 
108
108
  The redirect must match the immutable allowlist exactly before any outbound call. The token
109
109
  exchange is bounded by an abort deadline; `google-auth-library` verifies the ID-token signature,
110
- issuer, audience and expiry. Stitchkit additionally requires `sub`, a valid verified email and an
110
+ issuer, audience and expiry. StitchKit additionally requires `sub`, a valid verified email and an
111
111
  exact nonce. Access, refresh and raw ID tokens never leave the adapter.
112
112
 
113
113
  `GoogleOidcError.code` distinguishes `MISCONFIGURED`, `INVALID_CREDENTIAL` and
@@ -230,7 +230,7 @@ bound observes the same drain under its own limit rather than starting another.
230
230
  Passing no bound keeps the previous behaviour exactly, including the identical
231
231
  returned promise.
232
232
 
233
- Stitchkit manages only in-process delivery. If process-crash durability matters,
233
+ StitchKit manages only in-process delivery. If process-crash durability matters,
234
234
  make `write` enqueue into a consumer-owned durable outbox and let that adapter
235
235
  own retry, replay and storage policy:
236
236
 
@@ -518,7 +518,7 @@ locally; you do not need to change `NODE_ENV` or deploy.
518
518
  Every response the stitchkit handler produces carries the resolved id as
519
519
  **`x-request-id`**. With `cors` configured it is in the default
520
520
  `Access-Control-Expose-Headers`, so a browser client can read it and quote it in
521
- a bug report. Stitchkit browser clients retain it as `ApiError.traceId` on
521
+ a bug report. StitchKit browser clients retain it as `ApiError.traceId` on
522
522
  response-backed failures. Note the deliberate asymmetry: inbound the id may arrive as
523
523
  `X-Trace-Id` *or* `X-Request-Id`; outbound there is one name and no alias.
524
524
 
@@ -570,7 +570,7 @@ cross-origin `trace: true` client works out of the box. If you set a custom
570
570
  the preflight will reject the trace header.
571
571
 
572
572
  MCP tools use the same context. On a modern HTTP or stdio `tools/call`, the
573
- official SDK exposes W3C propagation values from request `_meta`; Stitchkit
573
+ official SDK exposes W3C propagation values from request `_meta`; StitchKit
574
574
  continues a valid `_meta.traceparent` before validation, lifecycle and hooks.
575
575
  If MCP metadata omits `traceparent`, an HTTP call keeps its ambient HTTP trace
576
576
  and a stdio call starts a new root. If the key is present but malformed or
@@ -50,7 +50,7 @@ an immutable branded value; `transition()` produces the next one. `availableTran
50
50
 
51
51
  `defineOwnerScope` resolves one owner from authenticated identity. Reading across owners is a
52
52
  separate `acrossAllOwners(identity)` call and permission. Pass the resulting branded `OwnerScope`
53
- to the data adapter. This proves the scope was explicit; Stitchkit cannot prove what SQL an
53
+ to the data adapter. This proves the scope was explicit; StitchKit cannot prove what SQL an
54
54
  arbitrary adapter emits. `scanOwnerFilterRisks` maps existing caller-named manual filters before a
55
55
  migration.
56
56
 
@@ -15,11 +15,11 @@ Parts of this slice:
15
15
 
16
16
  Public leaves keep optional peers out of their import closure. Installing `stitchkit` still
17
17
  installs the complete package and ky; selective imports alone do not avoid that installation.
18
- A library can use Stitchkit as a build dependency, bundle its selected public native imports,
18
+ A library can use StitchKit as a build dependency, bundle its selected public native imports,
19
19
  keep Zod external, and publish the resulting implementation with its library artifact.
20
20
 
21
21
  ```ts
22
- // The library's build entry; all mechanisms remain owned by Stitchkit.
22
+ // The library's build entry; all mechanisms remain owned by StitchKit.
23
23
  export { canonicalJson } from 'stitchkit/primitives';
24
24
  export { writeFileAtomic, withExclusiveLock } from 'stitchkit/files';
25
25
  export { observeProcessInstance, probeProcessOwner, runNativeCommand } from 'stitchkit/process';
@@ -81,7 +81,7 @@ identity, live-owner refusal, dead-owner recovery and contained file operations
81
81
  with the packaging plugin, and check that an unpackaged build reports the backend `unavailable`
82
82
  with stage `packaging` rather than certifying a dead owner. Bun and Node package imports retain the same
83
83
  lazy loader; importing a portable leaf does not load a Darwin addon on another OS. Test
84
- declarations too, and check that importing an unbundled Stitchkit leaf fails in a deliberately
84
+ declarations too, and check that importing an unbundled StitchKit leaf fails in a deliberately
85
85
  isolated library distribution. A separate schema-only entry must not import the native entry.
86
86
 
87
87
  If the Darwin backend cannot load, `observeProcessInstance` still returns `unavailable`.
@@ -95,20 +95,20 @@ failures or turn unavailable identity into proof that an owner is dead. If a run
95
95
  no recognized native error code, the stage stays `load`; the loader never infers errno from text.
96
96
 
97
97
  This delivery removes a runtime kernel installation; it does not remove the build-time
98
- Stitchkit installation or create an independent lightweight npm package.
98
+ StitchKit installation or create an independent lightweight npm package.
99
99
 
100
100
  ## Public native packaging
101
101
 
102
102
  Custom archives and installers use `stitchkit/files/packaging` at **build time**.
103
103
  `createNativePackaging` resolves the installed version and target addon, reads the addon once and
104
- checks it against the size and SHA256 that Stitchkit published in its `native-assets.json` when the
104
+ checks it against the size and SHA256 that StitchKit published in its `native-assets.json` when the
105
105
  package was built. A ready asset carries those verified `bytes` with the published `size` and
106
106
  `sha256`; its Bun-compatible plugin integrates the same bytes with the same lazy native loader.
107
107
  Each call reads and hashes the selected addons, so call it once per build and reuse the result.
108
108
  The leaf is evolving. It requires no optional peer or Bun ambient declarations for Node imports.
109
109
  Calling it must happen in a process that runs it from its installed package: it locates the
110
110
  package's `native-assets.json` beside its own file and throws `Native packaging must run from its
111
- installed Stitchkit package` anywhere else, such as inside an application's runtime artifact.
111
+ installed StitchKit package` anywhere else, such as inside an application's runtime artifact.
112
112
  Importing the leaf is side-effect free (it loads no addon and reads no file), so a module that
113
113
  both builds and is bundled may import it; only the call has to stay in the build step.
114
114
 
@@ -155,7 +155,7 @@ second time. An installed addon whose size or SHA256 differs from the published
155
155
  with `mismatch` / `NATIVE_ASSET_DIGEST_MISMATCH`, so a file substituted after installation never
156
156
  reaches an artifact. Archive the complete output directory with an integrity manifest that records
157
157
  `asset.sha256`, unpack to a clean directory, verify the same hashes there, and run offline without
158
- the build tree or `node_modules`. The published digest ties the bytes to the package Stitchkit
158
+ the build tree or `node_modules`. The published digest ties the bytes to the package StitchKit
159
159
  built; the package itself is only as trusted as its tarball (the lockfile integrity of the install).
160
160
  Signature and trust policy remain application-owned.
161
161
 
package/llms/react.txt CHANGED
@@ -15,12 +15,12 @@ Also read:
15
15
  # Frontend integrations
16
16
 
17
17
  The official `bun create stitchkit` application uses Next.js with a separate
18
- Bun API. Stitchkit remains a Fetch-native backend and does not own frontend
18
+ Bun API. StitchKit remains a Fetch-native backend and does not own frontend
19
19
  routing, SSR or HMR.
20
20
 
21
21
  ## Theme boundary in the official starter
22
22
 
23
- The generated Next.js application uses `@wrksz/themes`, not a Stitchkit-owned
23
+ The generated Next.js application uses `@wrksz/themes`, not a StitchKit-owned
24
24
  theme abstraction. Its root `ThemeProvider` comes from `@wrksz/themes/next` and
25
25
  lives directly in the server layout so Next 16 can inject the first-paint script
26
26
  through `useServerInsertedHTML`. The default `hybrid` storage reads a cookie
@@ -60,10 +60,10 @@ export async function action({ request }: ActionFunctionArgs) {
60
60
 
61
61
  ## Vite
62
62
 
63
- Run Vite and the Stitchkit API as separate development processes. Declare one
63
+ Run Vite and the StitchKit API as separate development processes. Declare one
64
64
  proxy for `/api`, `/mcp` and `/socket.io`; browser code still calls the typed
65
65
  client with same-origin paths. Production serves the static Vite output from a
66
- static host or reverse proxy and routes those backend paths to Stitchkit.
66
+ static host or reverse proxy and routes those backend paths to StitchKit.
67
67
 
68
68
  Do not duplicate DTOs or handwritten API wrappers in either integration. The
69
69
  shared contract remains the only transport schema source.
package/llms/server.2.txt CHANGED
@@ -404,7 +404,7 @@ createServer({
404
404
  `serviceName` and `action` are optional observability identity. Declare
405
405
  `serviceName` when audit, logging, sampling or another cross-cutting policy
406
406
  groups this raw route with a service; add `action` when the policy needs an
407
- operation within that service. Stitchkit never derives either from `path`.
407
+ operation within that service. StitchKit never derives either from `path`.
408
408
  `action` without `serviceName`, and empty identity strings, fail at startup.
409
409
 
410
410
  A path may be exact, carry `:param` segments, or end in `/*filePath` for a prefix
@@ -413,7 +413,7 @@ wildcard — and the two combine: `/app/:slug/*filePath` matches `/app/x/a/b` wi
413
413
  deep-link fallback). List more specific routes before the wildcard — the first
414
414
  match wins. `staticRoute()` builds a raw route that serves a directory.
415
415
 
416
- At startup Stitchkit rejects exact duplicates, equivalent parameter shapes
416
+ At startup StitchKit rejects exact duplicates, equivalent parameter shapes
417
417
  (`/users/:id` vs `/users/:userId`) and any later raw route completely hidden by
418
418
  an earlier raw route. Partial overlap stays legal, including the recommended
419
419
  specific-before-wildcard order. `GET` and `HEAD` remain independent because that
@@ -718,7 +718,7 @@ them.
718
718
 
719
719
  For large files, set `delivery: 'stream'` and define receivers. A receiver gets
720
720
  a Web `ReadableStream<Uint8Array>` and writes directly to consumer-owned
721
- storage; Stitchkit holds only bounded parser state:
721
+ storage; StitchKit holds only bounded parser state:
722
722
 
723
723
  ```ts
724
724
  const streamingUploads = defineContract({ prefix: 'uploads' }, {
@@ -819,12 +819,12 @@ createServer({ services: [users, orders], rawRoutes: [openApiRoute('/openapi.jso
819
819
  Only HTTP-exposed methods appear (an MCP/agent-only tool is skipped).
820
820
 
821
821
  OpenAPI 3.1 has no standard multi-segment path parameter. For a contract path
822
- ending in a named wildcard such as `/*filePath`, Stitchkit keeps the literal
822
+ ending in a named wildcard such as `/*filePath`, StitchKit keeps the literal
823
823
  runtime path, omits `filePath` from the
824
824
  standard `in: path` parameter list, and emits
825
825
  `x-stitchkit-trailing-wildcard` on the operation with its parameter name,
826
826
  schema and semantics. A generic OpenAPI client therefore cannot invent
827
- catch-all expansion; use Stitchkit's typed client or teach the generator that
827
+ catch-all expansion; use StitchKit's typed client or teach the generator that
828
828
  extension.
829
829
 
830
830
  ### Curating the spec — `includeMethod`
@@ -995,7 +995,7 @@ try {
995
995
  ```
996
996
 
997
997
  `path` is `'0.v'` and not `'v'` because event arguments are a tuple: index `0`
998
- is the first payload. The issues are already flattened by Stitchkit's own
998
+ is the first payload. The issues are already flattened by StitchKit's own
999
999
  normaliser, so telling "wrong generation" from "malformed payload" is one
1000
1000
  comparison rather than an inspection of a `ZodError`'s internals.
1001
1001
 
@@ -1030,7 +1030,7 @@ The client sends it as `auth`, and a rejection reaches `onConnectError` with
1030
1030
  deployment reads as a half-rolled deployment and not as an access problem.
1031
1031
 
1032
1032
  What that identity *is* remains the application's decision — a build version, a
1033
- contract hash, a protocol generation. Stitchkit does not compare it for you
1033
+ contract hash, a protocol generation. StitchKit does not compare it for you
1034
1034
  (→ ADR 0002); it gives the place where the comparison happens before any frame
1035
1035
  is interpreted, and it makes the per-frame alternative honest by letting its
1036
1036
  refusals be seen.
package/llms/server.3.txt CHANGED
@@ -137,7 +137,7 @@ socket.on('note:created', (note) => { /* typed note */ })
137
137
  socket.emit('room:join', 'general', ({ joined }) => { /* typed + validated */ })
138
138
  ```
139
139
 
140
- When an application already owns the low-level Stitchkit transport, bind the
140
+ When an application already owns the low-level StitchKit transport, bind the
141
141
  contract without opening a second connection:
142
142
 
143
143
  ```ts
@@ -303,7 +303,7 @@ classification detects duplicates—those are different policies.
303
303
 
304
304
  A server process that owns such a receiver can place `start()` and `close()` in
305
305
  an existing `defineManagedResource` and include it in `createApplication`.
306
- Readiness follows a successful `live` snapshot; shutdown calls `close()`. Stitchkit
306
+ Readiness follows a successful `live` snapshot; shutdown calls `close()`. StitchKit
307
307
  does not add another supervisor, reconnect loop or durable event database.
308
308
 
309
309
  When migrating a hand-written receiver, remove only the superseded attach/snapshot
@@ -374,7 +374,7 @@ closed phase:
374
374
  |-------|----------------------|
375
375
  | `engine-handoff` | Engine.IO created the outbound message packet and accepted it into its write path |
376
376
  | `engine-ack-received` | Engine.IO decoded the inbound acknowledgement message, before Socket.IO invokes the acknowledgement callback |
377
- | `settled` | the acknowledgement callback ran and Stitchkit finished acknowledgement validation |
377
+ | `settled` | the acknowledgement callback ran and StitchKit finished acknowledgement validation |
378
378
  | `timeout` | the existing native acknowledgement timeout won |
379
379
  | `disconnected` | the request began disconnected or an in-flight disconnect won |
380
380
 
@@ -396,7 +396,7 @@ await socket.request('room:join', 'general', {
396
396
 
397
397
  The client-wide hook receives every observed request; a request hook receives
398
398
  only its invocation. If the same function is supplied in both places it runs
399
- once per phase. The closure is local: Stitchkit does not retain `operationId`,
399
+ once per phase. The closure is local: StitchKit does not retain `operationId`,
400
400
  add it to the event or transmit it to the peer. A request hook works without a
401
401
  client-wide hook, and the no-hook path installs no phase listeners.
402
402
 
@@ -782,7 +782,7 @@ question: a list takes one of them, and `createEntityCacheHandlers` refuses both
782
782
 
783
783
  The helper deliberately does **not** flatten pages, infer filter semantics,
784
784
  derive a sort order or replace arbitrary `setQueryData` logic. Those remain
785
- declared application policies; Stitchkit applies their generic cache mechanics.
785
+ declared application policies; StitchKit applies their generic cache mechanics.
786
786
 
787
787
  ## Raw binary lane (Bun)
788
788
 
package/llms/server.4.txt CHANGED
@@ -59,7 +59,7 @@ The framework attaches no meaning to the strings — `'public'`, `'user'`,
59
59
  ## `createAuthHook`
60
60
 
61
61
  `createAuthHook` builds one scope gate that can run in both HTTP and tool
62
- lifecycles. On HTTP it belongs in `hooks.authorize`: Stitchkit validates path
62
+ lifecycles. On HTTP it belongs in `hooks.authorize`: StitchKit validates path
63
63
  params, resolves identity and scope, and rejects `401`/`403` **before reading a
64
64
  JSON or multipart body**. On MCP, agent and CLI surfaces it belongs in
65
65
  `access.gate.beforeHandle` (`access: { gate: { beforeHandle: authHook } }`),
@@ -246,7 +246,7 @@ export const implementFor = createScopedImplement<AuthScopes<typeof auth>>()
246
246
 
247
247
  Only hooks that declare the selected scope run. An unknown scope fails closed;
248
248
  when several hooks own one scope, every owner must pass in declaration order.
249
- Each owner evaluates on an isolated shadow context. Stitchkit validates all
249
+ Each owner evaluates on an isolated shadow context. StitchKit validates all
250
250
  changed fields, rejects reserved/unsafe fields and cross-owner key collisions,
251
251
  then commits the combined contribution once. A rejected or cancelled composite
252
252
  therefore exposes no partial fields to the handler.
@@ -497,7 +497,7 @@ complete: async ({ response }) => {
497
497
  }
498
498
  ```
499
499
 
500
- Append once per cookie; Stitchkit preserves separate `Set-Cookie` fields through
500
+ Append once per cookie; StitchKit preserves separate `Set-Cookie` fields through
501
501
  both Bun and Node. Cookie/session policy remains application logic.
502
502
 
503
503
  ## The error model
@@ -651,7 +651,7 @@ onError: (ctx, err) => {
651
651
 
652
652
  ## One application vocabulary and one wire map
653
653
 
654
- `defineErrors` can also resolve Stitchkit's framework codes into the same
654
+ `defineErrors` can also resolve StitchKit's framework codes into the same
655
655
  application vocabulary. A status fallback is explicit because several
656
656
  application codes may legally share one HTTP status:
657
657
 
@@ -743,7 +743,7 @@ retained on the returned `AppError`.
743
743
  HTTP renders the complete code/status/message/details/hint. Tool transports keep
744
744
  their established model-facing projection (code/details/hint, without HTTP
745
745
  status), while `invokeOrThrow` recovers the exact normalized `AppError`. The
746
- codes and schemas remain application-owned; Stitchkit stays domain-free.
746
+ codes and schemas remain application-owned; StitchKit stays domain-free.
747
747
 
748
748
  ### The codes an operation refuses with
749
749
 
@@ -830,7 +830,7 @@ stitchkit code you did not list travels as itself. Set `unmappedCode` to one
830
830
  wire-code when your public vocabulary has a catch-all, or to a function such as
831
831
  `(code) => code.startsWith('FILE_') ? 'storage_error' : 'framework_error'` when
832
832
  framework code families need different buckets. An explicit `codeMap` entry
833
- always wins. Codes your project throws itself do not belong to Stitchkit's
833
+ always wins. Codes your project throws itself do not belong to StitchKit's
834
834
  vocabulary, so they never pass through this fallback and remain unchanged.
835
835
 
836
836
  One `satisfies` is the **opt-in** to the stricter deal:
package/llms/server.txt CHANGED
@@ -74,6 +74,14 @@ When an HTTP caller sends a relative remaining budget in `x-stitchkit-timeout-ms
74
74
  `401`/`403`; an inbound value of `0` then fails immediately with `REQUEST_TIMEOUT` (`408`) before
75
75
  payload parsing, `beforeHandle`, or the handler runs. Malformed non-integer values are ignored so
76
76
  the endpoint's declared timeout remains authoritative.
77
+ - For a streaming endpoint (`stream: { ... }`), `timeout` and `x-stitchkit-timeout-ms` bound only
78
+ the response-open phase until the handler returns its `AsyncIterable` (matching the client's open
79
+ timeout). Once the stream opens, the open deadline timer is disarmed, `ctx.signal` stays bound to
80
+ client disconnect (`req.signal`), managed shutdown, and `stream.lifetimeMs`, and
81
+ `ctx.remainingTimeoutMs` switches to `stream.lifetimeMs` (or `undefined` when unbounded). The same
82
+ open-phase boundary applies to a `rawResponse: true` endpoint returning a `Response` with a body:
83
+ the open timer is disarmed once the `Response` is returned while `ctx.signal` stays subscribed to
84
+ client disconnect (`req.signal`).
77
85
  - Inside the handler, `ctx.remainingTimeoutMs?.(reserveMs?)` returns the live remaining integer
78
86
  milliseconds (clamped to `>= 0`, subtracting optional `reserveMs` for response serialization), or
79
87
  `undefined` when neither an inbound header nor an endpoint `timeout` bounds the request. Always
@@ -341,7 +349,7 @@ server. See [Testing & deployment](./testing-and-deployment.md).
341
349
  | `traceId` | override per-request trace-id resolution — may return `undefined` to fall back |
342
350
  | `wrapFetch` | compose wrappers around the finished handler (request context, audit) |
343
351
  | `proxyOrigin` | Bun TCP ingress policy: `{ trustedPeer(socketIp) }` restores the external scheme before all composition; independent of client-IP `trustProxy` |
344
- | `socket` | full Stitchkit Socket.IO handle; route, default WebSocket handler and shutdown are mounted once |
352
+ | `socket` | full StitchKit Socket.IO handle; route, default WebSocket handler and shutdown are mounted once |
345
353
  | `websocket` | custom Bun WebSocket handler; with `socket`, this is the explicit composed handler |
346
354
  | `development` / `bun` | passthrough to `Bun.serve` |
347
355
 
@@ -548,7 +556,7 @@ when forwarding to owned streaming routes; it is also required by native timeout
548
556
 
549
557
  ### Trusted HTTPS in development
550
558
 
551
- Stitchkit does not own local certificate generation or a frontend development
559
+ StitchKit does not own local certificate generation or a frontend development
552
560
  server. When a device or browser feature requires a secure context, generate a
553
561
  trusted certificate outside the application (for example with `mkcert`) and pass
554
562
  its files through the Bun server boundary:
@@ -613,7 +621,7 @@ request-error recorder; an `AbortError` while the request signal is still active
613
621
  remains an internal failure. A runtime abort reason may be preserved by identity
614
622
  through at most eight cycle-safe standard `cause` links; error messages and codes
615
623
  are never classifiers. The same rule applies when the disconnect happens while
616
- Stitchkit is reading a JSON upload body: bounded reads race every pending stream
624
+ StitchKit is reading a JSON upload body: bounded reads race every pending stream
617
625
  read against the request signal and never parse a cancelled partial body. `499`
618
626
  is transport telemetry, not a response declared in the contract or generated
619
627
  OpenAPI document.
@@ -815,7 +823,7 @@ That split is deliberate — see [ADR 0003](../decisions/0003-two-context-types.
815
823
 
816
824
  ## A host beside its own window
817
825
 
818
- A desktop app's host — the process beside its window — is an ordinary Stitchkit server, bound to
826
+ A desktop app's host — the process beside its window — is an ordinary StitchKit server, bound to
819
827
  loopback. Calls are plain HTTP through the typed client; events travel the realtime socket with
820
828
  `retain` per topic ([realtime](./realtime.md)). There is no second transport to learn.
821
829
 
@@ -919,7 +927,7 @@ Trust boundary and operational rules for the unix channel:
919
927
  container and keep the full UTF-8 path within 103 bytes; TCC permissions remain bound to the host
920
928
  process's responsible bundle.
921
929
  - **Embedded agents and shell tools.** An unsandboxed agent shell running as the same OS user has full
922
- access to the socket. Inside Stitchkit's Linux Bubblewrap sandbox (`stitchkit/agent-runtime/sandbox`),
930
+ access to the socket. Inside StitchKit's Linux Bubblewrap sandbox (`stitchkit/agent-runtime/sandbox`),
923
931
  the host's `$HOME`, `/tmp`, `/run` and `XDG_RUNTIME_DIR` are not mounted (`--unshare-all --clearenv`),
924
932
  so keep the socket outside the agent's mounted `workspace` directory (note that macOS has no
925
933
  Bubblewrap isolation).
@@ -128,7 +128,7 @@ contract:
128
128
  Every endpoint callable exposes a `withOptions` method accepting required
129
129
  `ClientRequestOptions`. The ordinary callable contains only contract arguments,
130
130
  so it can be passed directly to callback APIs such as `react-query-kit` without
131
- mistaking their callback context for Stitchkit transport options.
131
+ mistaking their callback context for StitchKit transport options.
132
132
 
133
133
  **That safety has a cost worth knowing before it bites you.** `api.thing(args,
134
134
  { signal })` — the shape everyone reaches for first — is not an error: the second
@@ -624,7 +624,7 @@ try {
624
624
 
625
625
  `traceId` is present when the server returned `x-request-id`. A network error,
626
626
  timeout or abort without an HTTP response cannot carry one. Cross-origin
627
- browser code can read it through Stitchkit's default CORS expose list; a custom
627
+ browser code can read it through StitchKit's default CORS expose list; a custom
628
628
  `cors.exposeHeaders` policy must keep `x-request-id` exposed.
629
629
 
630
630
  The error model is shared with the server — see [Auth & errors](./auth-and-errors.md).
@@ -717,7 +717,7 @@ if (server === undefined) {
717
717
  }
718
718
  ```
719
719
 
720
- Both fingerprints arrive as a value; a difference never throws. Stitchkit
720
+ Both fingerprints arrive as a value; a difference never throws. StitchKit
721
721
  computes the two identities and compares nothing — what a mismatch means is the
722
722
  application's decision. The client's fingerprint is computed locally and is not
723
723
  sent to the server. The identity operation is public and lists operation names,
@@ -244,7 +244,7 @@ The browser-and-server entrypoint. Re-exports everything from
244
244
  | `createSocketIOClient` | function | low-level typed Socket.IO transport primitive — [guide](../guide/realtime.md#low-level-transport) |
245
245
  | `defineRealtimeContract` | function | Zod-first shared Socket.IO event contract — [guide](../guide/realtime.md#zod-first-event-contract) |
246
246
  | `createRealtimeClient` | function | inferred, runtime-validated Socket.IO client — [guide](../guide/realtime.md#client--createrealtimeclient) |
247
- | `bindRealtimeClient` | function | bind contract validation and typed acknowledgements to an existing Stitchkit client transport without owning its lifecycle |
247
+ | `bindRealtimeClient` | function | bind contract validation and typed acknowledgements to an existing StitchKit client transport without owning its lifecycle |
248
248
  | `createLiveStateController` | function | keep typed application state current across one source-owned snapshot/event generation with finite pre-snapshot buffering, generation fencing and explicit resync — [guide](../guide/realtime.md#snapshot--event-state-synchronization) |
249
249
  | `LiveStateController` | _type_ | renderer-neutral `start` / `resync` / `getSnapshot` / `subscribe` / `close` handle |
250
250
  | `LiveStateControllerConfig` | _type_ | typed source, reducer, explicit event/byte bounds, event sizing and isolated error hooks |
@@ -283,8 +283,8 @@ below is the canonical install command.
283
283
  you import — both for `stitchkit/tools/toolkit`:
284
284
 
285
285
  ```bash
286
- bun add @modelcontextprotocol/server@^2 # stitchkit/tools/mcp
287
- bun add ai@^7 # stitchkit/tools/agent or stitchkit/agent-runtime/ai-sdk
286
+ bun add @modelcontextprotocol/server@^2 # stitchkit/tools/mcp or stitchkit/tools/toolkit
287
+ bun add ai@^7 # stitchkit/tools/agent, stitchkit/tools/toolkit or stitchkit/agent-runtime/ai-sdk
288
288
  ```
289
289
 
290
290
  Browser, HTTP-client and React entrypoints remain usable without either MCP
@@ -433,7 +433,7 @@ pauses its socket, and resuming preserves the exact chunked body.
433
433
 
434
434
  `UnixClientTransportError` carries a stable `code` and `delivery`:
435
435
  `not-dispatched`, `possibly-dispatched` or `response-received`. Only the first
436
- proves that the remote operation did not begin; Stitchkit never silently retries
436
+ proves that the remote operation did not begin; StitchKit never silently retries
437
437
  an ambiguous write. Response consumption/cancellation belongs to the operation,
438
438
  and `close()` interrupts active work and destroys owned connections.
439
439
 
@@ -495,7 +495,7 @@ attempt, so the default `2` permits at most three total attempts. The default
495
495
 
496
496
  Inside Next.js 16 server rendering, the first attempt still uses Next's normal
497
497
  request memoization. If Ky authorizes a retry after a network rejection,
498
- Stitchkit passes that retry's current `Request.signal` in the second fetch
498
+ StitchKit passes that retry's current `Request.signal` in the second fetch
499
499
  argument and materializes the current Request as URL + init. Next 16.3 otherwise
500
500
  merges `init` into a Request before its dedupe layer and loses the explicit
501
501
  signal opt-out. The retry therefore performs a new network attempt instead of
package/llms/telegram.txt CHANGED
@@ -313,7 +313,7 @@ of git.
313
313
  ### Injecting another transport's failure policy
314
314
 
315
315
  `classify(error)` returns the public `TelegramBroadcastFailure` union. It lets
316
- an application use its own client without adding that SDK to Stitchkit:
316
+ an application use its own client without adding that SDK to StitchKit:
317
317
 
318
318
  ```ts
319
319
  const report = await runTelegramBroadcast({
package/llms/testing.txt CHANGED
@@ -340,7 +340,7 @@ of defect stays invisible in development.
340
340
 
341
341
  ### Shipping one self-contained artifact
342
342
 
343
- Stitchkit resolves the optional Socket.IO peers through a variable, so a
343
+ StitchKit resolves the optional Socket.IO peers through a variable, so a
344
344
  consumer bundling an unrelated `stitchkit/server` export never has to resolve
345
345
  them. A bundler cannot follow that, which matters if you ship **one file** to a
346
346
  machine with no `node_modules`: the package never enters the artifact and the
@@ -363,7 +363,7 @@ const socket = await createSocketIOServer({
363
363
 
364
364
  The packed Next/Webpack gate compiles the browser
365
365
  `peers.client: () => import('socket.io-client')` loader and rejects Webpack's
366
- "request is an expression" warning. Stitchkit's runtime fallback remains lazy;
366
+ "request is an expression" warning. StitchKit's runtime fallback remains lazy;
367
367
  its emitted import carries a count-checked ignore directive.
368
368
 
369
369
  Omit `peers` and nothing changes: the peers stay lazy and are resolved from the
@@ -574,7 +574,7 @@ await binding.promise
574
574
 
575
575
  The first signal starts exactly one close chain. A same-turn duplicate is
576
576
  ignored; a later signal restores the default OS disposition because the
577
- official stdio close is not abortable and Stitchkit will not pretend otherwise.
577
+ official stdio close is not abortable and StitchKit will not pretend otherwise.
578
578
  `binding.close()` removes idle listeners and resolves the promise with
579
579
  `undefined`. No listener is installed until the binder is called, and the
580
580
  framework never calls `process.exit()`.
@@ -637,7 +637,7 @@ stitchkit serves the API. A SPA front-end is built and hosted separately — a
637
637
  static host or CDN in production, its own dev server in development. The backend
638
638
  does not serve static files (`staticRoute` exists for the occasional asset, not
639
639
  a whole app). `bun create stitchkit my-app` demonstrates the supported split:
640
- an independently built Next.js frontend and Bun/Stitchkit API.
640
+ an independently built Next.js frontend and Bun/StitchKit API.
641
641
 
642
642
  ### MCP
643
643
 
@@ -27,7 +27,7 @@ and approval path.
27
27
  | `ConnectionPhase` / `ConnectionOperation` / `ConnectionFailureContext` | _type_ | closed operation/phase vocabulary and measured read context for existing typed connection errors |
28
28
  | `ConnectionTimeoutError` / `ConnectionResponseTooLargeError` | class | bounded operation refusal, with phase, operation and finite observed bytes — a timeout also says which `deadline` fired (`'total'` or `'idle'`, with `timeoutMs` the limit that fired); safe tool projection retains the raw cause locally |
29
29
  | `ConnectionDeadline` / `ConnectionTimeoutContext` | _type_ | `'total' \| 'idle'`, and a timeout's diagnostics with the deadline that fired (default `'total'`) |
30
- | `McpConnectionCatalogStore` / `McpConnectionCatalogEntry` | _type_ | `{ load, store }` the application gives a connection's `catalog`, and the `{ stamp, result }` it keeps: when the server's `initialize` answer carries a catalog stamp (a Stitchkit server's does), a stored `tools/list` result whose stamp — and every tool's — matches is mounted without listing; anything else lists and stores again, and a failing store is a miss |
30
+ | `McpConnectionCatalogStore` / `McpConnectionCatalogEntry` | _type_ | `{ load, store }` the application gives a connection's `catalog`, and the `{ stamp, result }` it keeps: when the server's `initialize` answer carries a catalog stamp (a StitchKit server's does), a stored `tools/list` result whose stamp — and every tool's — matches is mounted without listing; anything else lists and stores again, and a failing store is a miss |
31
31
  | `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
32
32
  | `mountConnections` | function | discover every connection and return readonly `RuntimeToolDefinition`s for `mountAgent`; reported structural failures and bounds stay local, while unions and string-format/pattern refusals (including inside record keys) are judged by the server that owns the original schema (ADR 0266, ADR 0272) |
33
33
  | `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
@@ -15,7 +15,9 @@ Also read:
15
15
  ## `stitchkit/tools/toolkit`
16
16
 
17
17
  Server-only. One context-typed tool set served over MCP and to an AI SDK agent, so it
18
- needs both the `@modelcontextprotocol/server` and `ai` peers. → ADR 0284.
18
+ deliberately requires both the `@modelcontextprotocol/server` and `ai` peers. Applications
19
+ that drop `ai` (or install neither peer) should import directly from `stitchkit/tools/mcp`,
20
+ `stitchkit/tools`, or `stitchkit/cli` instead of `stitchkit/tools/toolkit`. → ADR 0284.
19
21
 
20
22
  | Export | Kind | Summary |
21
23
  |--------|------|---------|
package/llms/tools.2.txt CHANGED
@@ -117,7 +117,7 @@ load balancing therefore cannot strand a client on an in-memory session.
117
117
  The default `legacy: 'serve'` lets the official SDK negotiate either modern
118
118
  `2026-07-28` or the supported legacy stateless opening on this same endpoint.
119
119
  Set `legacy: 'reject'` when every host is modern. Legacy support is protocol
120
- translation inside the SDK, not a second Stitchkit transport or compatibility
120
+ translation inside the SDK, not a second StitchKit transport or compatibility
121
121
  API. Stateful MCP and subscriptions are intentionally outside this layer.
122
122
 
123
123
  `createMcpHttpRoute` is the framework-owned raw-route adapter. It registers
@@ -136,7 +136,7 @@ must not be used as authorization input.
136
136
 
137
137
  ### Modern discovery, routing and cache hints
138
138
 
139
- Stitchkit forwards the negotiated protocol era and validated MCP request data
139
+ StitchKit forwards the negotiated protocol era and validated MCP request data
140
140
  to both `RequestEvent.mcp` and the current managed call's typed `context.mcp`;
141
141
  untrusted routing headers never become application identity. The SDK validates
142
142
  `MCP-Protocol-Version`, JSON-RPC shape and routing
@@ -151,7 +151,7 @@ means zero/private: neither a prepared surface nor a deterministic response is
151
151
  silently treated as public. Unbounded auth-selected surface factories are
152
152
  always forced to zero/private even when an operation policy is present; use a
153
153
  finite `surfaces` registry when identities share a provably immutable surface.
154
- Stitchkit never advertises list-change or subscription capabilities
154
+ StitchKit never advertises list-change or subscription capabilities
155
155
  without an implementation.
156
156
 
157
157
  ### Knowing your catalog is stale — the catalog stamp
@@ -481,7 +481,7 @@ expiry-checked. Tampered, expired, cross-user or cross-tool state fails before
481
481
  the side effect. Output validation applies only to the final result.
482
482
 
483
483
  Every attempt re-runs auth/lifecycle and emits its own tool hooks; audit metadata
484
- contains the attempt's `mcp.outcome` and `mcp.round`. Stitchkit does not merge
484
+ contains the attempt's `mcp.outcome` and `mcp.round`. StitchKit does not merge
485
485
  separate HTTP attempts into one logical trace. Parallel
486
486
  rounds have isolated context. HTTP/stdio modern hosts and the supported legacy
487
487
  stdio bridge may use this declaration; Agent, CLI and ordinary HTTP invocation
@@ -733,7 +733,7 @@ It is **deep** because the projection walks the generated JSON Schema document,
733
733
  including objects, arrays, tuples and schema-definition nodes. Structurally
734
734
  identifiable discriminated object unions are flattened wherever they occur.
735
735
  Plain unions and unions hidden behind unresolved external references remain
736
- unions because Stitchkit cannot soundly invent a discriminator.
736
+ unions because StitchKit cannot soundly invent a discriminator.
737
737
 
738
738
  Use the default `flattenUnionInput: false` when the model must see the exact
739
739
  relationship between a discriminator and each branch. Joined property schemas
@@ -743,7 +743,7 @@ The flattened form is **lossy but never executable**. Per-variant refinements
743
743
  and incompatible constraints are widened in the presentation document; the
744
744
  original Zod contract enforces them exactly once inside `executeToolMethod`.
745
745
  MCP and AI adapters forward the raw argument object unchanged, so defaults,
746
- coercions and transforms cannot run before Stitchkit. Strict violations return
746
+ coercions and transforms cannot run before StitchKit. Strict violations return
747
747
  the normal `VALIDATION_ERROR` tool envelope and fire `beforeToolCall` /
748
748
  `afterToolCall`. → [ADR 0050](../decisions/0050-presentation-schema-is-not-a-parser.md).
749
749