stitchkit 0.124.0 → 0.124.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 (103) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/dist/browser/client-executors.d.ts.map +1 -1
  3. package/dist/browser/contract-stream.d.ts +7 -2
  4. package/dist/browser/contract-stream.d.ts.map +1 -1
  5. package/dist/entrypoints/agent-runtime/coding-tools.js +1 -1
  6. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  7. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  8. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  9. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  10. package/dist/entrypoints/agent-runtime/testing.js +3 -3
  11. package/dist/entrypoints/agent-runtime.js +3 -3
  12. package/dist/entrypoints/application/diagnostic-journal.js +3 -5
  13. package/dist/entrypoints/application/directory-inbox.js +9 -11
  14. package/dist/entrypoints/application.js +3 -3
  15. package/dist/entrypoints/cli/publish.js +6 -6
  16. package/dist/entrypoints/cli.js +6 -3
  17. package/dist/entrypoints/files.js +5 -5
  18. package/dist/entrypoints/http.js +2 -2
  19. package/dist/entrypoints/index.js +6 -6
  20. package/dist/entrypoints/node.js +1 -1
  21. package/dist/entrypoints/process.js +1 -1
  22. package/dist/entrypoints/remote.js +1 -1
  23. package/dist/entrypoints/server.js +8 -8
  24. package/dist/entrypoints/telegram.js +2 -2
  25. package/dist/entrypoints/testing.js +1 -1
  26. package/dist/entrypoints/tools/connections.d.ts +2 -2
  27. package/dist/entrypoints/tools/connections.d.ts.map +1 -1
  28. package/dist/entrypoints/tools/connections.js +122 -30
  29. package/dist/entrypoints/tools/mcp.d.ts +1 -1
  30. package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
  31. package/dist/entrypoints/tools/mcp.js +8 -6
  32. package/dist/entrypoints/tools/toolkit.js +2 -2
  33. package/dist/entrypoints/tools.js +3 -3
  34. package/dist/{index-8yky60kq.js → index-1szhrfsf.js} +5 -7
  35. package/dist/{index-mqttte96.js → index-3ymcmpa9.js} +3 -5
  36. package/dist/{index-v8xm2s9v.js → index-7177dxjn.js} +1 -1
  37. package/dist/{index-2x2ch0bt.js → index-782qtc24.js} +1 -1
  38. package/dist/{index-j8rda9n6.js → index-8pwwd6rp.js} +3 -3
  39. package/dist/{index-m616f0yz.js → index-8x0q6yfb.js} +134 -7
  40. package/dist/{index-jswst0h3.js → index-b2sey031.js} +50 -5
  41. package/dist/{index-tt3ej8r3.js → index-btjwc7xr.js} +217 -24
  42. package/dist/{index-ezwvsqx9.js → index-fvd6pvw3.js} +1 -1
  43. package/dist/{index-6qrspvxp.js → index-gbj964dt.js} +1 -1
  44. package/dist/{index-q89kd1xc.js → index-hzk4ydpy.js} +1 -1
  45. package/dist/{index-w0wy05gr.js → index-jkjh7zw4.js} +50 -40
  46. package/dist/{index-ac6vvm30.js → index-jp2qd9jb.js} +1 -1
  47. package/dist/{index-45dyex0j.js → index-m9hb9wnk.js} +1 -1
  48. package/dist/index-mm89hd8v.js +39 -0
  49. package/dist/{index-zbzagr9k.js → index-ne4j9998.js} +16 -15
  50. package/dist/{index-jc5xgkpk.js → index-qsm899qp.js} +1 -1
  51. package/dist/{index-cjbn98zt.js → index-ss67fxhj.js} +21 -3
  52. package/dist/index-wqzw3qg9.js +91 -0
  53. package/dist/{index-364k2zwa.js → index-wt6rw7rf.js} +5 -7
  54. package/dist/{index-5efrpfmj.js → index-wxadzdb7.js} +1 -1
  55. package/dist/internal/deadline.d.ts +30 -0
  56. package/dist/internal/deadline.d.ts.map +1 -1
  57. package/dist/internal/pinned-http.d.ts +1 -1
  58. package/dist/internal/pinned-http.d.ts.map +1 -1
  59. package/dist/internal/secure-fetch.d.ts +8 -0
  60. package/dist/internal/secure-fetch.d.ts.map +1 -1
  61. package/dist/internal/stream-chunks.d.ts +10 -0
  62. package/dist/internal/stream-chunks.d.ts.map +1 -1
  63. package/dist/tools/cli/resumable-download.d.ts +18 -0
  64. package/dist/tools/cli/resumable-download.d.ts.map +1 -0
  65. package/dist/tools/cli/update.d.ts +18 -0
  66. package/dist/tools/cli/update.d.ts.map +1 -1
  67. package/dist/tools/connections/catalog-cache.d.ts +9 -0
  68. package/dist/tools/connections/catalog-cache.d.ts.map +1 -0
  69. package/dist/tools/connections/errors.d.ts +10 -1
  70. package/dist/tools/connections/errors.d.ts.map +1 -1
  71. package/dist/tools/connections/limits.d.ts +16 -4
  72. package/dist/tools/connections/limits.d.ts.map +1 -1
  73. package/dist/tools/connections/mcp-client.d.ts +10 -2
  74. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  75. package/dist/tools/connections/mcp.d.ts.map +1 -1
  76. package/dist/tools/connections/operation-limits.d.ts +12 -1
  77. package/dist/tools/connections/operation-limits.d.ts.map +1 -1
  78. package/dist/tools/connections/sse-session.d.ts +2 -2
  79. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  80. package/dist/tools/connections/types.d.ts +38 -2
  81. package/dist/tools/connections/types.d.ts.map +1 -1
  82. package/dist/tools/mcp/catalog-stamp.d.ts +47 -0
  83. package/dist/tools/mcp/catalog-stamp.d.ts.map +1 -0
  84. package/dist/tools/mcp/catalog.d.ts +1 -30
  85. package/dist/tools/mcp/catalog.d.ts.map +1 -1
  86. package/dist/tools/mcp/handler.d.ts.map +1 -1
  87. package/dist/tools/mcp/mount.d.ts +6 -1
  88. package/dist/tools/mcp/mount.d.ts.map +1 -1
  89. package/dist/tools/mcp/register.d.ts +1 -1
  90. package/dist/tools/mcp/register.d.ts.map +1 -1
  91. package/dist/tools/mcp/runtime-tools.d.ts +1 -1
  92. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  93. package/llms/cli.2.txt +60 -6
  94. package/llms/stitchkit.2.txt +6 -0
  95. package/llms/stitchkit.3.txt +1 -1
  96. package/llms/tools-connections.txt +5 -3
  97. package/llms/tools-mcp.txt +5 -2
  98. package/llms/tools.txt +10 -3
  99. package/llms-full.txt +87 -15
  100. package/llms.txt +5 -5
  101. package/package.json +6 -6
  102. package/dist/index-9tqbxv5p.js +0 -44
  103. package/dist/index-b56nnscm.js +0 -132
package/llms-full.txt CHANGED
@@ -3753,6 +3753,12 @@ body until it ends or is cancelled. This is the same for a Fetch-config client,
3753
3753
  Unix transport. Cancelling a quiet stream therefore releases its server source
3754
3754
  and transport connection instead of only settling the local iterator.
3755
3755
 
3756
+ A stream is read from any response whose `body` has `getReader()`, not only from
3757
+ the global `Response` class: a `fetch` of another runtime — `expo/fetch` in
3758
+ React Native, which answers with its own `FetchResponse` — streams the same way.
3759
+ A response without a readable body is refused with `Streaming endpoint did not
3760
+ return a Response`.
3761
+
3756
3762
  An established NDJSON protocol may keep its item schema as the complete wire
3757
3763
  frame. This mode requires a terminal item because an unwrapped response has no
3758
3764
  separate safe error/end envelope:
@@ -4287,9 +4293,16 @@ same problem and `createMcpHandler` cannot send it: it is stateless by
4287
4293
  construction, so there is no retained session to push down.
4288
4294
 
4289
4295
  The digest covers each advertised tool's name, description, input schema, output
4290
- schema and annotations, and nothing else — it moves when the contract moves and
4291
- not when a handler does. Raw SDK registrations stay consumer-owned and are
4292
- outside it.
4296
+ schema, annotations and MCP Apps `ui` resource, and nothing else — it moves when the
4297
+ contract moves and not when a handler does. Raw SDK registrations stay consumer-owned
4298
+ and are outside it, so a handler with `rawTools` sends no stamp header.
4299
+
4300
+ `createMcpHandler` also sends the stamp of the surface each request was served from as
4301
+ the `stitchkit-catalog` response header (the same `{ digest, tools }` JSON), on the
4302
+ `initialize` answer included — the SDK assembles that result itself and leaves no
4303
+ `_meta` to fill. A client can therefore tell whether its stored catalog is current
4304
+ before it asks for `tools/list`; `defineMcpClientConnection({ catalog })` does exactly
4305
+ that ([CLI → commands discovered from a running server](./cli.md#commands-discovered-from-a-running-server)).
4293
4306
 
4294
4307
  ### Saying which tools only read — `readOnlyHint`
4295
4308
 
@@ -11379,6 +11392,31 @@ Carry the build stamp inside the binary (`CliBuildStampSchema`,
11379
11392
  `formatCliBuildStamp`) so the tool can say what it is rather than leaving the
11380
11393
  reader to infer it from behaviour.
11381
11394
 
11395
+ #### A download on a slow link
11396
+
11397
+ A build is tens of megabytes, and on a slow link that is minutes. `applyCliUpdate` bounds
11398
+ the download by silence rather than length: `idleTimeoutMs` (default 30 seconds) ends it
11399
+ when nothing has arrived for that long, and `timeoutMs` (default 30 minutes) bounds the
11400
+ response headers and, separately, the body. A declared `timeoutMs` keeps meaning exactly that,
11401
+ with an idle deadline only when `idleTimeoutMs` is declared too.
11402
+
11403
+ Give it a `partialPath` in your state directory and an interrupted download continues where
11404
+ it stopped:
11405
+
11406
+ ```ts
11407
+ await applyCliUpdate({ asset: check.asset, partialPath: join(stateDir, 'update.part') })
11408
+ ```
11409
+
11410
+ Every received chunk is appended to that file, and `<partialPath>.json` records the URL, the
11411
+ build's digest and the server's validator (a strong `ETag`, else `Last-Modified`). The next
11412
+ attempt asks for the rest with `Range` and `If-Range`; `206` from the right offset continues
11413
+ the file, `200` (the build changed) replaces it, `416` with the full length means it is
11414
+ already whole. A part is never trusted: the finished transfer is decoded and checked against
11415
+ the manifest like a fresh one, and a continued file that fails — a corrupt part, a build
11416
+ re-published under the same URL — is thrown away and downloaded once more from zero. Both
11417
+ files are removed once the download is decoded, and `<partialPath>.lock` refuses a second
11418
+ update into the same part while one is running. The size ceiling counts the kept part too.
11419
+
11382
11420
  #### A manifest inside your own network
11383
11421
 
11384
11422
  The check goes through the same SSRF boundary every outbound fetch does, so a
@@ -11782,9 +11820,14 @@ const discovered = await mountConnections([
11782
11820
  token: () => key,
11783
11821
  transports: ['CLI'], // the opt-in: this server's tools are commands
11784
11822
  limits: {
11785
- discovery: { timeoutMs: 30_000, maxResponseBytes: 4 * 1024 * 1024 },
11823
+ discovery: { maxResponseBytes: 4 * 1024 * 1024 }, // 300 s total, 30 s of silence
11786
11824
  call: { timeoutMs: 120_000 },
11787
11825
  },
11826
+ // Skip tools/list while the stored catalog is the one the server serves.
11827
+ catalog: {
11828
+ load: async () => JSON.parse(await readFile(catalogPath, 'utf8')),
11829
+ store: (entry) => writeFile(catalogPath, JSON.stringify(entry)),
11830
+ },
11788
11831
  }),
11789
11832
  ])
11790
11833
  await createCli({ name: 'myapp', version, runtimeTools: discovered, commands: [...] })
@@ -11826,13 +11869,37 @@ limits. Each logical operation has one deadline, including initial transport
11826
11869
  negotiation and response-body reading. Legacy endpoint readiness has a discovery
11827
11870
  deadline; the lifetime of an established SSE stream does not.
11828
11871
 
11829
- Omitted phase fields inherit the existing connection-level `timeoutMs` and
11830
- `maxResponseBytes`, whose defaults are 30 seconds and 1 MiB. Values must be positive
11831
- safe integers; `timeoutMs` must also fit the runtime timer range. The byte ceiling
11872
+ Inside that deadline an operation may have an idle one: `idleTimeoutMs` ends it when
11873
+ nothing has arrived for that long — the response headers and every body chunk restart
11874
+ it, so a slow link that keeps delivering a large catalog is never cut off, while a
11875
+ silent one still ends with `ConnectionTimeoutError` whose `deadline` is `'idle'`. On a
11876
+ shared legacy SSE stream any byte is progress for every pending operation.
11877
+
11878
+ Omitted phase fields inherit the connection-level `timeoutMs` and `maxResponseBytes`.
11879
+ With neither set, discovery allows 300 seconds in total and 30 seconds of silence, and
11880
+ a call 30 seconds with no idle deadline — a tool may compute in silence before it
11881
+ answers, so a call's idle deadline is only what you declare. A declared `timeoutMs`
11882
+ keeps meaning exactly that deadline: discovery then has an idle deadline only when you
11883
+ declare one too. The byte default is 1 MiB.
11884
+ Values must be positive safe integers; deadlines must also fit the runtime timer range. The byte ceiling
11832
11885
  counts raw UTF-8 body bytes, including SSE framing, regardless of `Content-Length`.
11833
11886
  Pending legacy calls also count comments and wrong-id frames. `budget.maxTools`
11834
11887
  and `budget.maxSchemaBytes` remain separate mount limits.
11835
11888
 
11889
+ **A stored catalog is mounted while it is current.** A Stitchkit server sends its
11890
+ [catalog stamp](./mcp-and-agents.md#knowing-your-catalog-is-stale--the-catalog-stamp) with
11891
+ the `initialize` answer, as the `stitchkit-catalog` response header. Given a `catalog:
11892
+ { load, store }`, the connection compares it with the stamp of the stored `tools/list`
11893
+ result and mounts the stored one when they match — every stored tool must carry the same
11894
+ stamp, and there must be as many — so a start costs no catalog transfer. A different
11895
+ stamp (the server's contract moved, or the credential sees another surface) lists and
11896
+ stores again. A listing is stored only when every tool in it carries the stamp the
11897
+ `initialize` answer announced, so a rolling deploy answering the two requests from
11898
+ different builds stores nothing. A server without a stamp, a surface with raw SDK tools
11899
+ and a failing `load` or `store` all cost one `tools/list`, never the mount. The stamp
11900
+ covers what `tools/list` publishes as Stitchkit builds it; the JSON Schema text the
11901
+ server's MCP SDK renders from the same schema is not hashed separately.
11902
+
11836
11903
  Only the initial `initialize` can negotiate HTTP-to-legacy fallback on 400, 404
11837
11904
  or 405. A failed `tools/call` is not replayed. Caller cancellation preserves its
11838
11905
  original reason for in-process observers.
@@ -23379,7 +23446,7 @@ The browser-and-server entrypoint. Re-exports everything from
23379
23446
  | `parseNDJSON` | function | parse bounded fatal-UTF-8 NDJSON from a `Response`, a `ReadableStream<Uint8Array>` or an `AsyncIterable<Uint8Array>` (a child's stdout); blank keep-alives are skipped, `finalLine: 'require-newline'` makes the delimiter mandatory and `signal` cancels the source — [guide](../guide/client.md#any-byte-source) |
23380
23447
  | `createNDJSONDecoder` / `NDJSONDecoder` | function / _type_ | the same bounded NDJSON reading driven by `push(chunk)` / `end()`, for a socket `data` callback |
23381
23448
  | `readBoundedBody` / `BoundedBodyOptions` | function / _type_ | the whole body of a `ReadableStream<Uint8Array>` or async byte iterable as bytes, never reading past `maxBytes` plus one chunk; `limitError(observedBytes)` and `abortError(reason)` choose the two errors, the source is cancelled on both, a `null` body is empty — [guide](../guide/client.md#reading-a-body-up-to-a-byte-limit) |
23382
- | `StreamByteSource` | _type_ | `Response \| ReadableStream<Uint8Array> \| AsyncIterable<Uint8Array>`, what the NDJSON and SSE readers accept |
23449
+ | `StreamByteSource` | _type_ | `Response \| ReadableStream<Uint8Array> \| AsyncIterable<Uint8Array>`, what the NDJSON and SSE readers accept; each is recognised by its shape, not its class — a reader, `Symbol.asyncIterator`, else the response's `body` — so another runtime's fetch response (`expo/fetch`) reads like the global `Response` |
23383
23450
  | `StreamLineLimitError` / `StreamTruncatedLineError` | class | a line past `maxLineBytes` (`limitBytes`, `lineBytes`; a `RangeError`) and a source ended inside a line under `require-newline` (`lineBytes`; a `SyntaxError`) |
23384
23451
  | `resumableIterator` | function | re-open a long-lived stream from the last delivered cursor, with jittered backoff, a caller-owned terminal item and prompt abort — [guide](../guide/client.md#resumable-streams) |
23385
23452
  | `createBackoff` | function | exponential backoff with subtractive jitter as a value: `next()` / `reset()` |
@@ -25183,7 +25250,7 @@ payload. See [MCP guide](../guide/mcp-and-agents.md#mcp--createmcphandler).
25183
25250
 
25184
25251
  | Export | Kind | Purpose |
25185
25252
  |--------|------|---------|
25186
- | `createMcpHandler` | function | a stateless dual-era Streamable-HTTP MCP handler — [guide](../guide/mcp-and-agents.md#mcp--createmcphandler) |
25253
+ | `createMcpHandler` | function | a stateless dual-era Streamable-HTTP MCP handler; each response carries the served surface's catalog stamp as the `stitchkit-catalog` header (none with `rawTools`) — [guide](../guide/mcp-and-agents.md#mcp--createmcphandler) |
25187
25254
  | `createMcpHttpRoute` | function | framework-owned `RawRoute` adapter for an MCP HTTP handler |
25188
25255
  | `createStdioMcpServer` | function | a complete stdio MCP server — [guide](../guide/mcp-and-agents.md#mcp-over-stdio--createstdiomcpserver) |
25189
25256
  | `bindStdioProcessSignals` | function | explicitly bind OS signals to one close-only stdio handle — [guide](../guide/testing-and-deployment.md#stdio-process-signals) |
@@ -25227,7 +25294,10 @@ retained session to push `notifications/tools/list_changed` down; the stamp need
25227
25294
  Store the stamp beside the tools when you list them, compare it against the one on every
25228
25295
  result, and re-list when they differ — including on a refusal, which is exactly when a
25229
25296
  stale catalog is the likeliest explanation and the least visible one. The server side
25230
- needs no wiring: every mount stamps what it advertises.
25297
+ needs no wiring: every mount stamps what it advertises — each tool's name, description,
25298
+ schemas, annotations and `ui` resource — and `createMcpHandler` sends the same stamp as the
25299
+ `stitchkit-catalog` response header, `initialize` included, which is what a connection's
25300
+ `catalog` store is checked against before `tools/list`.
25231
25301
 
25232
25302
  | Export | Kind | Summary |
25233
25303
  |--------|------|---------|
@@ -25282,9 +25352,11 @@ and approval path.
25282
25352
  | Export | Kind | Summary |
25283
25353
  |--------|------|---------|
25284
25354
  | `defineMcpClientConnection` | function | declare one external MCP server connection over Streamable HTTP with an optional SSE fallback |
25285
- | `ConnectionOperationLimits` / `McpConnectionLimits` | _type_ | positive finite deadline/raw byte ceilings with independent discovery/call overrides; omitted fields inherit the shared bounds |
25355
+ | `ConnectionOperationLimits` / `McpConnectionLimits` | _type_ | positive finite deadline, idle deadline (`idleTimeoutMs`: nothing arrived for that long — headers and every chunk restart it) and raw byte ceilings with independent discovery/call overrides; omitted fields inherit the shared bounds, and discovery with no declared `timeoutMs` allows 300 s in total and 30 s of silence while a call keeps 30 s and no idle deadline; a declared `timeoutMs` has an idle deadline only when one is declared too |
25286
25356
  | `ConnectionPhase` / `ConnectionOperation` / `ConnectionFailureContext` | _type_ | closed operation/phase vocabulary and measured read context for existing typed connection errors |
25287
- | `ConnectionTimeoutError` / `ConnectionResponseTooLargeError` | class | bounded operation refusal, with phase, operation and finite observed bytes; safe tool projection retains the raw cause locally |
25357
+ | `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 |
25358
+ | `ConnectionDeadline` / `ConnectionTimeoutContext` | _type_ | `'total' \| 'idle'`, and a timeout's diagnostics with the deadline that fired (default `'total'`) |
25359
+ | `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 |
25288
25360
  | `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
25289
25361
  | `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) |
25290
25362
  | `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
@@ -25298,7 +25370,7 @@ and approval path.
25298
25370
  | `ConnectionToolSkipReporter` | _type_ | `(skipped) => void` — called per discovered tool the mount could not build; defaults to a stderr line, and the rest of the surface still mounts |
25299
25371
  | `SkippedConnectionTool` | _type_ | `{ connection, tool, reason }` — which tool was not mounted, and why |
25300
25372
  | `McpClientConnection` | _type_ | a defined MCP client connection |
25301
- | `McpClientConnectionConfig` | _type_ | name, transport, tool filter, token provider, instance key, allowed hosts and `transports` — naming `['CLI']` makes the whole server's discovered tools commands, with no per-definition rewriting |
25373
+ | `McpClientConnectionConfig` | _type_ | name, transport, tool filter, token provider, instance key, allowed hosts, bounds, `catalog` store and `transports` — naming `['CLI']` makes the whole server's discovered tools commands, with no per-definition rewriting |
25302
25374
  | `McpConnectionTransport` | _type_ | `{ url, headers? }` for one MCP endpoint |
25303
25375
  | `McpToolFilter` | _type_ | `{ allow?, block? }` discovered-tool filter |
25304
25376
  | `OpenApiConnection` | _type_ | a defined OpenAPI connection |
@@ -25856,7 +25928,7 @@ SDK nor the `ai` peer.
25856
25928
  | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
25857
25929
  | `renderCliInstaller` | function | generate the one-line installer from a build manifest, with the URL and digest substituted — [guide](../guide/cli.md#distribution-and-self-update) |
25858
25930
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
25859
- | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename |
25931
+ | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename; with `partialPath` an interrupted download continues with `Range`/`If-Range`, and a continued file that fails its checks is downloaded once more from zero |
25860
25932
  | `assertCliPublishable` | function | refuse republishing one version from a different commit — takes one manifest or every manifest already published, because the promise a version makes does not stop at a channel boundary |
25861
25933
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
25862
25934
  | `signCliManifest` / `verifyCliManifest` / `cliManifestSigningPayload` | function | Ed25519 over `{name, version, commit, builtAt, assets[]}` — every asset's digest included, so the chain closes on the file that executes |
@@ -25872,7 +25944,7 @@ SDK nor the `ai` peer.
25872
25944
  | `CliBuildStampSchema` / `CliBuildStamp` | schema / _type_ | the version/commit/build time carried inside a binary |
25873
25945
  | `CliInstallerConfig` | _type_ | manifest, binary name, default install directory, and an optional `asset` — omit it for one script that selects the target by `uname` |
25874
25946
  | `CliUpdateCheckConfig` / `CliUpdateCheck` | _type_ | check inputs, and its four answers — `skipped`, `current`, `outdated`, `unknown` |
25875
- | `CliUpdateApplyConfig` / `AppliedCliUpdate` | _type_ | apply inputs — including `verify`, run on an executable candidate beside the target before the backup and the replacement, within `verifyTimeoutMs` — and the replaced path, byte count and digest |
25947
+ | `CliUpdateApplyConfig` / `AppliedCliUpdate` | _type_ | apply inputs — including `verify`, run on an executable candidate beside the target before the backup and the replacement, within `verifyTimeoutMs`; `timeoutMs` (default 30 minutes) and `idleTimeoutMs` (default 30 s of silence when `timeoutMs` is not declared); `partialPath` for a resumable download — and the replaced path, byte count and digest |
25876
25948
  | `CliProfileStore` / `CliProfileStoreConfig` / `ResolvedCliProfile` | _type_ | the profile store, its directory/schema/hint config, and one resolution |
25877
25949
  | `CliResultView` | _type_ | the requested view — `count`, `sum`, or `records` (ordered and/or table-rendered) |
25878
25950
  | `CliViewOutput` | _type_ | a JSON value, or the one human-facing text shape |
package/llms.txt CHANGED
@@ -9,19 +9,19 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
9
9
  Load the slice for each entrypoint your code imports — `import … from 'stitchkit/server'` → `llms/server.txt`; the root `stitchkit` import → `llms/stitchkit.txt`. A slice holds that entrypoint's API reference section and the guide pages whose home it is; every guide lives in exactly one slice, and a slice that needs another's guide names it under "Also read". Each file is at most 50.0 KB; a longer one continues in numbered parts, each naming the next at its top. Moving across versions: load `llms/upgrading.txt` and the range slices it lists between your version and the target. `llms-full.txt` inlines everything; it is far larger than a context window, so do not read it whole.
10
10
 
11
11
  ## Entrypoint slices
12
- - **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 45.2 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt) 30.9 KB → [llms/stitchkit.3.txt](llms/stitchkit.3.txt) 19.1 KB
12
+ - **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 45.2 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt) 31.2 KB → [llms/stitchkit.3.txt](llms/stitchkit.3.txt) 19.3 KB
13
13
  - **stitchkit/live**: [llms/live.txt](llms/live.txt) 21.2 KB
14
14
  - **stitchkit/react**: [llms/react.txt](llms/react.txt) 8.7 KB
15
15
  - **stitchkit/react/keyboard**: [llms/react-keyboard.txt](llms/react-keyboard.txt) 22.7 KB
16
16
  - **stitchkit/react/keyboard/testing**: [llms/react-keyboard-testing.txt](llms/react-keyboard-testing.txt) 1.9 KB
17
- - **stitchkit/tools**: [llms/tools.txt](llms/tools.txt) 43.2 KB → [llms/tools.2.txt](llms/tools.2.txt) 36.5 KB → [llms/tools.3.txt](llms/tools.3.txt) 21.2 KB
18
- - **stitchkit/tools/mcp**: [llms/tools-mcp.txt](llms/tools-mcp.txt) 6.6 KB
17
+ - **stitchkit/tools**: [llms/tools.txt](llms/tools.txt) 43.8 KB → [llms/tools.2.txt](llms/tools.2.txt) 36.5 KB → [llms/tools.3.txt](llms/tools.3.txt) 21.2 KB
18
+ - **stitchkit/tools/mcp**: [llms/tools-mcp.txt](llms/tools-mcp.txt) 7.0 KB
19
19
  - **stitchkit/tools/agent**: [llms/tools-agent.txt](llms/tools-agent.txt) 1.1 KB
20
20
  - **stitchkit/tools/toolkit**: [llms/tools-toolkit.txt](llms/tools-toolkit.txt) 0.9 KB
21
21
  - **stitchkit/tools/contract**: [llms/tools-contract.txt](llms/tools-contract.txt) 0.2 KB
22
22
  - **stitchkit/tools/invoker**: [llms/tools-invoker.txt](llms/tools-invoker.txt) 0.2 KB
23
- - **stitchkit/tools/connections**: [llms/tools-connections.txt](llms/tools-connections.txt) 3.9 KB
24
- - **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.1 KB → [llms/cli.2.txt](llms/cli.2.txt) 39.0 KB
23
+ - **stitchkit/tools/connections**: [llms/tools-connections.txt](llms/tools-connections.txt) 4.9 KB
24
+ - **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.1 KB → [llms/cli.2.txt](llms/cli.2.txt) 42.9 KB
25
25
  - **stitchkit/cli/publish**: [llms/cli-publish.txt](llms/cli-publish.txt) 1.5 KB
26
26
  - **stitchkit/remote**: [llms/remote.txt](llms/remote.txt) 1.0 KB
27
27
  - **stitchkit/contract**: [llms/contract.txt](llms/contract.txt) 34.1 KB
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.124.0",
3
+ "version": "0.124.2",
4
4
  "description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
5
5
  "keywords": [
6
6
  "bun",
@@ -409,20 +409,20 @@
409
409
  "@modelcontextprotocol/server": "^2.4.0",
410
410
  "@openrouter/ai-sdk-provider": "^3.1.0",
411
411
  "@opentelemetry/api": "^1.10.0",
412
- "@seriousme/openapi-schema-validator": "^2.11.0",
412
+ "@seriousme/openapi-schema-validator": "^2.12.0",
413
413
  "@socket.io/bun-engine": "^0.1.2",
414
414
  "@socket.io/component-emitter": "^3.1.2",
415
- "@tanstack/react-query": "5.105.3",
415
+ "@tanstack/react-query": "5.108.0",
416
416
  "@types/bun": "^1.4.4",
417
417
  "@types/json-schema": "^7.0.15",
418
418
  "@types/react": "^19.3.0",
419
419
  "@types/react-dom": "^19.3.0",
420
420
  "@typescript/typescript6": "^6.0.2",
421
- "ai": "^7.0.162",
421
+ "ai": "^7.0.173",
422
422
  "ajv": "^8.20.0",
423
423
  "exceljs": "^4.4.0",
424
- "fake-indexeddb": "^6.2.7",
425
- "google-auth-library": "^11.3.3",
424
+ "fake-indexeddb": "^6.2.8",
425
+ "google-auth-library": "^11.3.4",
426
426
  "grammy": "^1.46.0",
427
427
  "react": "^19.3.1",
428
428
  "react-dom": "^19.3.1",
@@ -1,44 +0,0 @@
1
- import {
2
- MAX_TIMER_MS
3
- } from "./index-eemvahkc.js";
4
- import {
5
- assertPositiveSafeInteger
6
- } from "./index-0s4xebbg.js";
7
-
8
- // src/internal/deadline.ts
9
- async function withDeadline(value, timeoutMs) {
10
- if (!(value instanceof Promise))
11
- return { settled: true, value };
12
- let timer;
13
- const expiry = new Promise((resolve) => {
14
- timer = setTimeout(() => resolve({ settled: false }), timeoutMs);
15
- });
16
- try {
17
- return await Promise.race([
18
- value.then((settledValue) => ({
19
- settled: true,
20
- value: settledValue
21
- })),
22
- expiry
23
- ]);
24
- } finally {
25
- if (timer !== undefined)
26
- clearTimeout(timer);
27
- }
28
- }
29
- async function withSignalDeadline(timeoutMs, caller, makeReason, body) {
30
- assertPositiveSafeInteger("Deadline timeoutMs", timeoutMs, RangeError);
31
- if (timeoutMs > MAX_TIMER_MS)
32
- throw new RangeError("Deadline timeoutMs exceeds the timer range");
33
- caller?.throwIfAborted();
34
- const deadline = new AbortController;
35
- const timer = setTimeout(() => deadline.abort(makeReason()), timeoutMs);
36
- const signal = caller ? AbortSignal.any([caller, deadline.signal]) : deadline.signal;
37
- try {
38
- return await body(signal);
39
- } finally {
40
- clearTimeout(timer);
41
- }
42
- }
43
-
44
- export { withDeadline, withSignalDeadline };
@@ -1,132 +0,0 @@
1
- // src/internal/atomic-publication.ts
2
- import { closeSync, fsyncSync, linkSync, openSync, renameSync, unlinkSync } from "node:fs";
3
- import { link, open, rename, unlink } from "node:fs/promises";
4
- import { dirname } from "node:path";
5
-
6
- // src/internal/close-after.ts
7
- async function closeAfter(handle, run) {
8
- let result;
9
- try {
10
- result = await run();
11
- } catch (error) {
12
- await handle.close().catch(() => {
13
- return;
14
- });
15
- throw error;
16
- }
17
- await handle.close();
18
- return result;
19
- }
20
- function closeAfterSync(close, run) {
21
- let result;
22
- try {
23
- result = run();
24
- } catch (error) {
25
- try {
26
- close();
27
- } catch {}
28
- throw error;
29
- }
30
- close();
31
- return result;
32
- }
33
-
34
- // src/internal/atomic-publication.ts
35
- class AtomicFilePublicationError2 extends Error {
36
- phase;
37
- published = true;
38
- constructor(phase, cause) {
39
- super(`File published but ${phase} failed`, { cause });
40
- this.phase = phase;
41
- this.name = "AtomicFilePublicationError";
42
- }
43
- }
44
- var native = { rename, link, unlink, open };
45
- var nativeSync = {
46
- rename: renameSync,
47
- link: linkSync,
48
- unlink: unlinkSync,
49
- open(path, flags) {
50
- const descriptor = openSync(path, flags);
51
- return { sync: () => fsyncSync(descriptor), close: () => closeSync(descriptor) };
52
- }
53
- };
54
- function assertDirectoryDurability() {
55
- if (process.platform === "win32")
56
- throw new Error("Directory durability is unsupported on Windows");
57
- }
58
- async function syncDirectory(path, io = native) {
59
- assertDirectoryDurability();
60
- const directory = await io.open(path, "r");
61
- await closeAfter(directory, () => directory.sync());
62
- }
63
- async function publishAtomicFile(staged, target, { replace, durability }, io = native) {
64
- const directorySync = durability === "directory";
65
- if (directorySync)
66
- assertDirectoryDurability();
67
- const directory = directorySync ? await io.open(dirname(target), "r") : undefined;
68
- const publish = async () => {
69
- if (replace)
70
- await io.rename(staged, target);
71
- else {
72
- await io.link(staged, target);
73
- try {
74
- await io.unlink(staged);
75
- } catch (error) {
76
- throw new AtomicFilePublicationError2("cleanup", error);
77
- }
78
- }
79
- try {
80
- await directory?.sync();
81
- } catch (error) {
82
- throw new AtomicFilePublicationError2("directory-sync", error);
83
- }
84
- };
85
- if (directory === undefined)
86
- return publish();
87
- await closeAfter({
88
- close: async () => {
89
- try {
90
- await directory.close();
91
- } catch (error) {
92
- throw new AtomicFilePublicationError2("directory-close", error);
93
- }
94
- }
95
- }, publish);
96
- }
97
- function publishAtomicFileSync(staged, target, { replace, durability }, io = nativeSync) {
98
- const directorySync = durability === "directory";
99
- if (directorySync)
100
- assertDirectoryDurability();
101
- const directory = directorySync ? io.open(dirname(target), "r") : undefined;
102
- const publish = () => {
103
- if (replace)
104
- io.rename(staged, target);
105
- else {
106
- io.link(staged, target);
107
- try {
108
- io.unlink(staged);
109
- } catch (error) {
110
- throw new AtomicFilePublicationError2("cleanup", error);
111
- }
112
- }
113
- try {
114
- directory?.sync();
115
- } catch (error) {
116
- throw new AtomicFilePublicationError2("directory-sync", error);
117
- }
118
- };
119
- if (directory === undefined) {
120
- publish();
121
- return;
122
- }
123
- closeAfterSync(() => {
124
- try {
125
- directory.close();
126
- } catch (error) {
127
- throw new AtomicFilePublicationError2("directory-close", error);
128
- }
129
- }, publish);
130
- }
131
-
132
- export { closeAfter, closeAfterSync, AtomicFilePublicationError2, assertDirectoryDurability, syncDirectory, publishAtomicFile, publishAtomicFileSync };