stitchkit 0.123.7 → 0.124.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/dist/entrypoints/agent-runtime/coding-tools.js +1 -1
  3. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  4. package/dist/entrypoints/agent-runtime/sandbox.js +1 -1
  5. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  6. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  7. package/dist/entrypoints/agent-runtime/testing.js +3 -3
  8. package/dist/entrypoints/agent-runtime.js +3 -3
  9. package/dist/entrypoints/application/diagnostic-journal.js +3 -5
  10. package/dist/entrypoints/application/directory-inbox.js +9 -11
  11. package/dist/entrypoints/application.js +3 -3
  12. package/dist/entrypoints/cli/publish.js +6 -6
  13. package/dist/entrypoints/cli.js +7 -4
  14. package/dist/entrypoints/files.js +5 -5
  15. package/dist/entrypoints/index.js +3 -3
  16. package/dist/entrypoints/server.js +6 -6
  17. package/dist/entrypoints/telegram.js +2 -2
  18. package/dist/entrypoints/tools/connections.d.ts +2 -2
  19. package/dist/entrypoints/tools/connections.d.ts.map +1 -1
  20. package/dist/entrypoints/tools/connections.js +121 -29
  21. package/dist/entrypoints/tools/contract.d.ts +1 -1
  22. package/dist/entrypoints/tools/contract.d.ts.map +1 -1
  23. package/dist/entrypoints/tools/contract.js +3 -1
  24. package/dist/entrypoints/tools/mcp.d.ts +1 -1
  25. package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
  26. package/dist/entrypoints/tools/mcp.js +8 -6
  27. package/dist/entrypoints/tools/toolkit.js +3 -3
  28. package/dist/entrypoints/tools.d.ts +1 -1
  29. package/dist/entrypoints/tools.d.ts.map +1 -1
  30. package/dist/entrypoints/tools.js +25 -30
  31. package/dist/{index-jswst0h3.js → index-03qrr49d.js} +49 -4
  32. package/dist/{index-8yky60kq.js → index-1szhrfsf.js} +5 -7
  33. package/dist/{index-mqttte96.js → index-3ymcmpa9.js} +3 -5
  34. package/dist/{index-v8xm2s9v.js → index-7177dxjn.js} +1 -1
  35. package/dist/{index-2x2ch0bt.js → index-782qtc24.js} +1 -1
  36. package/dist/{index-j8rda9n6.js → index-8pwwd6rp.js} +3 -3
  37. package/dist/{index-m616f0yz.js → index-8x0q6yfb.js} +134 -7
  38. package/dist/{index-1a741dpf.js → index-e1x6vze4.js} +10 -4
  39. package/dist/{index-ezwvsqx9.js → index-fvd6pvw3.js} +1 -1
  40. package/dist/{index-bknzva6n.js → index-gy9x38a2.js} +4 -3
  41. package/dist/{index-w0wy05gr.js → index-jkjh7zw4.js} +50 -40
  42. package/dist/{index-ac6vvm30.js → index-jp2qd9jb.js} +1 -1
  43. package/dist/index-mm89hd8v.js +39 -0
  44. package/dist/{index-jc5xgkpk.js → index-qsm899qp.js} +1 -1
  45. package/dist/index-wqzw3qg9.js +91 -0
  46. package/dist/{index-364k2zwa.js → index-wt6rw7rf.js} +5 -7
  47. package/dist/{index-tt3ej8r3.js → index-x0769xt9.js} +217 -24
  48. package/dist/internal/deadline.d.ts +30 -0
  49. package/dist/internal/deadline.d.ts.map +1 -1
  50. package/dist/internal/pinned-http.d.ts +1 -1
  51. package/dist/internal/pinned-http.d.ts.map +1 -1
  52. package/dist/internal/secure-fetch.d.ts +8 -0
  53. package/dist/internal/secure-fetch.d.ts.map +1 -1
  54. package/dist/tools/cli/inline-files.d.ts +5 -5
  55. package/dist/tools/cli/inline-files.d.ts.map +1 -1
  56. package/dist/tools/cli/resumable-download.d.ts +18 -0
  57. package/dist/tools/cli/resumable-download.d.ts.map +1 -0
  58. package/dist/tools/cli/update.d.ts +18 -0
  59. package/dist/tools/cli/update.d.ts.map +1 -1
  60. package/dist/tools/connections/catalog-cache.d.ts +9 -0
  61. package/dist/tools/connections/catalog-cache.d.ts.map +1 -0
  62. package/dist/tools/connections/errors.d.ts +10 -1
  63. package/dist/tools/connections/errors.d.ts.map +1 -1
  64. package/dist/tools/connections/limits.d.ts +16 -4
  65. package/dist/tools/connections/limits.d.ts.map +1 -1
  66. package/dist/tools/connections/mcp-client.d.ts +10 -2
  67. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  68. package/dist/tools/connections/mcp.d.ts.map +1 -1
  69. package/dist/tools/connections/operation-limits.d.ts +12 -1
  70. package/dist/tools/connections/operation-limits.d.ts.map +1 -1
  71. package/dist/tools/connections/sse-session.d.ts +2 -2
  72. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  73. package/dist/tools/connections/types.d.ts +38 -2
  74. package/dist/tools/connections/types.d.ts.map +1 -1
  75. package/dist/tools/mcp/catalog-stamp.d.ts +47 -0
  76. package/dist/tools/mcp/catalog-stamp.d.ts.map +1 -0
  77. package/dist/tools/mcp/catalog.d.ts +1 -30
  78. package/dist/tools/mcp/catalog.d.ts.map +1 -1
  79. package/dist/tools/mcp/handler.d.ts.map +1 -1
  80. package/dist/tools/mcp/mount.d.ts +6 -1
  81. package/dist/tools/mcp/mount.d.ts.map +1 -1
  82. package/dist/tools/mcp/register.d.ts +1 -1
  83. package/dist/tools/mcp/register.d.ts.map +1 -1
  84. package/dist/tools/mcp/runtime-tools.d.ts +1 -1
  85. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  86. package/dist/tools/transfer/view-file-contract.d.ts +17 -6
  87. package/dist/tools/transfer/view-file-contract.d.ts.map +1 -1
  88. package/dist/tools/transfer/view-file.d.ts +1 -1
  89. package/dist/tools/transfer/view-file.d.ts.map +1 -1
  90. package/llms/cli.2.txt +60 -6
  91. package/llms/cli.txt +3 -2
  92. package/llms/stitchkit.txt +3 -3
  93. package/llms/tools-connections.txt +5 -3
  94. package/llms/tools-mcp.txt +5 -2
  95. package/llms/tools.2.txt +10 -4
  96. package/llms/tools.3.txt +2 -1
  97. package/llms/tools.txt +10 -3
  98. package/llms/{upgrading-0.106.0-0.123.0.txt → upgrading-0.106.0-0.124.0.txt} +39 -3
  99. package/llms/upgrading.txt +1 -1
  100. package/llms-full.txt +134 -24
  101. package/llms.txt +5 -5
  102. package/package.json +1 -1
  103. package/dist/index-9tqbxv5p.js +0 -44
  104. package/dist/index-b56nnscm.js +0 -132
package/llms-full.txt CHANGED
@@ -85,13 +85,13 @@ own, recorded as an ADR.
85
85
  | `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
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 68 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 69 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
93
  | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
94
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 68 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
94
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 69 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
95
95
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
96
96
  | `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 |
97
97
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -103,7 +103,7 @@ own, recorded as an ADR.
103
103
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
104
104
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
105
105
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
106
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 68 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
106
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 69 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
107
107
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
108
108
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
109
109
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
@@ -4287,9 +4287,16 @@ same problem and `createMcpHandler` cannot send it: it is stateless by
4287
4287
  construction, so there is no retained session to push down.
4288
4288
 
4289
4289
  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.
4290
+ schema, annotations and MCP Apps `ui` resource, and nothing else — it moves when the
4291
+ contract moves and not when a handler does. Raw SDK registrations stay consumer-owned
4292
+ and are outside it, so a handler with `rawTools` sends no stamp header.
4293
+
4294
+ `createMcpHandler` also sends the stamp of the surface each request was served from as
4295
+ the `stitchkit-catalog` response header (the same `{ digest, tools }` JSON), on the
4296
+ `initialize` answer included — the SDK assembles that result itself and leaves no
4297
+ `_meta` to fill. A client can therefore tell whether its stored catalog is current
4298
+ before it asks for `tools/list`; `defineMcpClientConnection({ catalog })` does exactly
4299
+ that ([CLI → commands discovered from a running server](./cli.md#commands-discovered-from-a-running-server)).
4293
4300
 
4294
4301
  ### Saying which tools only read — `readOnlyHint`
4295
4302
 
@@ -5413,10 +5420,16 @@ Ordinary file names containing brackets, such as `[preview].png`, remain valid.
5413
5420
  A local file with an unsupported extension is refused before reading; its
5414
5421
  per-item error identifies the caller's path and the extension it saw.
5415
5422
 
5416
- Each inline `image` and `audio` block carries `name`, the file name of its
5417
- source: a managed file keeps its own name, a URL takes its download name — the
5418
- path's base name with the body's extension. A CLI saves the block under that
5419
- name with [`--output-dir`](cli.md#saving-result-media).
5423
+ Each inline `image` and `audio` block carries the file name of its source in
5424
+ `_meta['stitchkit/fileName']` (`MCP_FILE_NAME_META_KEY`): a managed file keeps
5425
+ its own name, a URL takes its download name — the path's base name with the
5426
+ body's extension. MCP declares no file name on `ImageContent` or `AudioContent`,
5427
+ and the MCP server SDK drops an undeclared field from `content`, so the name is
5428
+ in `_meta`, the protocol's place for what a block carries beyond it. The block
5429
+ is therefore the same in the handler's output, an Agent's result,
5430
+ `structuredContent` and MCP `content`, and a host reads the name from the block
5431
+ it renders. A CLI saves the block under that name with
5432
+ [`--output-dir`](cli.md#saving-result-media).
5420
5433
 
5421
5434
  The older `mountWait`, `mountDownload`, `mountUpload` and `mountViewFile`
5422
5435
  functions remain
@@ -11104,7 +11117,7 @@ Three kinds of block hold a file, and the file may be of any type:
11104
11117
 
11105
11118
  | Block | Bytes | File name |
11106
11119
  | --- | --- | --- |
11107
- | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `name` |
11120
+ | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `_meta['stitchkit/fileName']` |
11108
11121
  | `resource` with `blob` — a PDF, a spreadsheet, an archive | standard base64 in `resource.blob` | last path segment of `resource.uri` |
11109
11122
  | `resource` with `text` — CSV, Markdown, JSON | `resource.text` as UTF-8 | last path segment of `resource.uri` |
11110
11123
 
@@ -11113,7 +11126,8 @@ rich-text node that also calls itself `image`, a `resource` without content —
11113
11126
  own data and is left alone.
11114
11127
 
11115
11128
  **Names.** A name is reduced to its basename, like a URL download name;
11116
- `defineViewFileTool` sets `name` to the file name of the source. A block that names no file
11129
+ `defineViewFileTool` and `mountViewFile` set a media block's `_meta['stitchkit/fileName']`
11130
+ (`MCP_FILE_NAME_META_KEY`) to the file name of the source. A block that names no file
11117
11131
  is `<type>-<sha256-of-its-bytes><extension>`: known media types supply the extension and
11118
11132
  the rest use `.bin`. A name is written once per batch. The same bytes under the same name
11119
11133
  are one file; different bytes under a name the batch already wrote fail that file, and the
@@ -11372,6 +11386,31 @@ Carry the build stamp inside the binary (`CliBuildStampSchema`,
11372
11386
  `formatCliBuildStamp`) so the tool can say what it is rather than leaving the
11373
11387
  reader to infer it from behaviour.
11374
11388
 
11389
+ #### A download on a slow link
11390
+
11391
+ A build is tens of megabytes, and on a slow link that is minutes. `applyCliUpdate` bounds
11392
+ the download by silence rather than length: `idleTimeoutMs` (default 30 seconds) ends it
11393
+ when nothing has arrived for that long, and `timeoutMs` (default 30 minutes) bounds the
11394
+ response headers and, separately, the body. A declared `timeoutMs` keeps meaning exactly that,
11395
+ with an idle deadline only when `idleTimeoutMs` is declared too.
11396
+
11397
+ Give it a `partialPath` in your state directory and an interrupted download continues where
11398
+ it stopped:
11399
+
11400
+ ```ts
11401
+ await applyCliUpdate({ asset: check.asset, partialPath: join(stateDir, 'update.part') })
11402
+ ```
11403
+
11404
+ Every received chunk is appended to that file, and `<partialPath>.json` records the URL, the
11405
+ build's digest and the server's validator (a strong `ETag`, else `Last-Modified`). The next
11406
+ attempt asks for the rest with `Range` and `If-Range`; `206` from the right offset continues
11407
+ the file, `200` (the build changed) replaces it, `416` with the full length means it is
11408
+ already whole. A part is never trusted: the finished transfer is decoded and checked against
11409
+ the manifest like a fresh one, and a continued file that fails — a corrupt part, a build
11410
+ re-published under the same URL — is thrown away and downloaded once more from zero. Both
11411
+ files are removed once the download is decoded, and `<partialPath>.lock` refuses a second
11412
+ update into the same part while one is running. The size ceiling counts the kept part too.
11413
+
11375
11414
  #### A manifest inside your own network
11376
11415
 
11377
11416
  The check goes through the same SSRF boundary every outbound fetch does, so a
@@ -11775,9 +11814,14 @@ const discovered = await mountConnections([
11775
11814
  token: () => key,
11776
11815
  transports: ['CLI'], // the opt-in: this server's tools are commands
11777
11816
  limits: {
11778
- discovery: { timeoutMs: 30_000, maxResponseBytes: 4 * 1024 * 1024 },
11817
+ discovery: { maxResponseBytes: 4 * 1024 * 1024 }, // 300 s total, 30 s of silence
11779
11818
  call: { timeoutMs: 120_000 },
11780
11819
  },
11820
+ // Skip tools/list while the stored catalog is the one the server serves.
11821
+ catalog: {
11822
+ load: async () => JSON.parse(await readFile(catalogPath, 'utf8')),
11823
+ store: (entry) => writeFile(catalogPath, JSON.stringify(entry)),
11824
+ },
11781
11825
  }),
11782
11826
  ])
11783
11827
  await createCli({ name: 'myapp', version, runtimeTools: discovered, commands: [...] })
@@ -11819,13 +11863,37 @@ limits. Each logical operation has one deadline, including initial transport
11819
11863
  negotiation and response-body reading. Legacy endpoint readiness has a discovery
11820
11864
  deadline; the lifetime of an established SSE stream does not.
11821
11865
 
11822
- Omitted phase fields inherit the existing connection-level `timeoutMs` and
11823
- `maxResponseBytes`, whose defaults are 30 seconds and 1 MiB. Values must be positive
11824
- safe integers; `timeoutMs` must also fit the runtime timer range. The byte ceiling
11866
+ Inside that deadline an operation may have an idle one: `idleTimeoutMs` ends it when
11867
+ nothing has arrived for that long — the response headers and every body chunk restart
11868
+ it, so a slow link that keeps delivering a large catalog is never cut off, while a
11869
+ silent one still ends with `ConnectionTimeoutError` whose `deadline` is `'idle'`. On a
11870
+ shared legacy SSE stream any byte is progress for every pending operation.
11871
+
11872
+ Omitted phase fields inherit the connection-level `timeoutMs` and `maxResponseBytes`.
11873
+ With neither set, discovery allows 300 seconds in total and 30 seconds of silence, and
11874
+ a call 30 seconds with no idle deadline — a tool may compute in silence before it
11875
+ answers, so a call's idle deadline is only what you declare. A declared `timeoutMs`
11876
+ keeps meaning exactly that deadline: discovery then has an idle deadline only when you
11877
+ declare one too. The byte default is 1 MiB.
11878
+ Values must be positive safe integers; deadlines must also fit the runtime timer range. The byte ceiling
11825
11879
  counts raw UTF-8 body bytes, including SSE framing, regardless of `Content-Length`.
11826
11880
  Pending legacy calls also count comments and wrong-id frames. `budget.maxTools`
11827
11881
  and `budget.maxSchemaBytes` remain separate mount limits.
11828
11882
 
11883
+ **A stored catalog is mounted while it is current.** A Stitchkit server sends its
11884
+ [catalog stamp](./mcp-and-agents.md#knowing-your-catalog-is-stale--the-catalog-stamp) with
11885
+ the `initialize` answer, as the `stitchkit-catalog` response header. Given a `catalog:
11886
+ { load, store }`, the connection compares it with the stamp of the stored `tools/list`
11887
+ result and mounts the stored one when they match — every stored tool must carry the same
11888
+ stamp, and there must be as many — so a start costs no catalog transfer. A different
11889
+ stamp (the server's contract moved, or the credential sees another surface) lists and
11890
+ stores again. A listing is stored only when every tool in it carries the stamp the
11891
+ `initialize` answer announced, so a rolling deploy answering the two requests from
11892
+ different builds stores nothing. A server without a stamp, a surface with raw SDK tools
11893
+ and a failing `load` or `store` all cost one `tools/list`, never the mount. The stamp
11894
+ covers what `tools/list` publishes as Stitchkit builds it; the JSON Schema text the
11895
+ server's MCP SDK renders from the same schema is not hashed separately.
11896
+
11829
11897
  Only the initial `initialize` can negotiate HTTP-to-legacy fallback on 400, 404
11830
11898
  or 405. A failed `tools/call` is not replayed. Caller cancellation preserves its
11831
11899
  original reason for in-process observers.
@@ -17878,6 +17946,42 @@ charts, no merged cells and no streaming: an application that needs them takes a
17878
17946
 
17879
17947
  # Upgrading stitchkit
17880
17948
 
17949
+ ## Released migration: 0.124.0
17950
+
17951
+ ### media-block-file-name
17952
+
17953
+ **Who must act:** code that builds or reads an `image` or `audio` block of
17954
+ `McpMediaContentSchema` with a `name` — a tool that returns such a block, or a reader of a
17955
+ `defineViewFileTool`, `mountViewFile` or `resolveMedia` result. The field exists only in 0.123.7.
17956
+
17957
+ The file name of a media block lives in the block's `_meta`, under the key
17958
+ `MCP_FILE_NAME_META_KEY` (`stitchkit/fileName`), and the block has no `name`. The block is now
17959
+ exactly what MCP declares, so the same block reaches a handler's caller, an Agent,
17960
+ `structuredContent` and MCP `content`; the `name` field never reached `content`.
17961
+
17962
+ ```ts
17963
+ import { MCP_FILE_NAME_META_KEY } from 'stitchkit/tools/contract'
17964
+
17965
+ // before
17966
+ const block = { type: 'image', data, mimeType: 'image/png', name: 'shot.png' }
17967
+ const fileName = block.name
17968
+
17969
+ // after
17970
+ const block = {
17971
+ type: 'image',
17972
+ data,
17973
+ mimeType: 'image/png',
17974
+ _meta: { [MCP_FILE_NAME_META_KEY]: 'shot.png' },
17975
+ }
17976
+ const fileName = block._meta?.[MCP_FILE_NAME_META_KEY] // unknown: check it is a string
17977
+ ```
17978
+
17979
+ A block that still carries `name` is not refused: the schema drops the field, and a CLI's
17980
+ `--output-dir` then names the file `<type>-<sha256><extension>`. An object typed
17981
+ `McpMediaContent` does not compile with `name`, which is where TypeScript code finds every
17982
+ site; search untyped code for `name:` beside `type: 'image'` or `type: 'audio'`. A test that
17983
+ compared MCP `content` with `structuredContent` minus `name` compares them whole.
17984
+
17881
17985
  ## Released migration: 0.123.0
17882
17986
 
17883
17987
  ### unknown-operation
@@ -24991,7 +25095,8 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
24991
25095
  | `ViewFileErrorSchema` | constant | Zod schema for one structured per-item view failure |
24992
25096
  | `McpAnnotations` | _type_ | MCP annotations on a media result |
24993
25097
  | `McpAnnotationsSchema` | constant | Zod schema for MCP media annotations |
24994
- | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content |
25098
+ | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content — the blocks MCP declares, field for field |
25099
+ | `MCP_FILE_NAME_META_KEY` | constant | the namespaced `_meta` key (`stitchkit/fileName`) under which an `image` or `audio` block carries the file name of its source |
24995
25100
  | `CollectToolsConfig` | _type_ | options for `collectTools` |
24996
25101
  | `findUntypedProperties` | function | every property in a JSON Schema with no `type`/`enum`/`$ref` — what a model is shown and cannot obey ([guide](../guide/mcp-and-agents.md)) |
24997
25102
  | `UntypedProperty` | _type_ | one such property — `{ path, description? }` |
@@ -25139,7 +25244,7 @@ payload. See [MCP guide](../guide/mcp-and-agents.md#mcp--createmcphandler).
25139
25244
 
25140
25245
  | Export | Kind | Purpose |
25141
25246
  |--------|------|---------|
25142
- | `createMcpHandler` | function | a stateless dual-era Streamable-HTTP MCP handler — [guide](../guide/mcp-and-agents.md#mcp--createmcphandler) |
25247
+ | `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) |
25143
25248
  | `createMcpHttpRoute` | function | framework-owned `RawRoute` adapter for an MCP HTTP handler |
25144
25249
  | `createStdioMcpServer` | function | a complete stdio MCP server — [guide](../guide/mcp-and-agents.md#mcp-over-stdio--createstdiomcpserver) |
25145
25250
  | `bindStdioProcessSignals` | function | explicitly bind OS signals to one close-only stdio handle — [guide](../guide/testing-and-deployment.md#stdio-process-signals) |
@@ -25183,7 +25288,10 @@ retained session to push `notifications/tools/list_changed` down; the stamp need
25183
25288
  Store the stamp beside the tools when you list them, compare it against the one on every
25184
25289
  result, and re-list when they differ — including on a refusal, which is exactly when a
25185
25290
  stale catalog is the likeliest explanation and the least visible one. The server side
25186
- needs no wiring: every mount stamps what it advertises.
25291
+ needs no wiring: every mount stamps what it advertises — each tool's name, description,
25292
+ schemas, annotations and `ui` resource — and `createMcpHandler` sends the same stamp as the
25293
+ `stitchkit-catalog` response header, `initialize` included, which is what a connection's
25294
+ `catalog` store is checked against before `tools/list`.
25187
25295
 
25188
25296
  | Export | Kind | Summary |
25189
25297
  |--------|------|---------|
@@ -25238,9 +25346,11 @@ and approval path.
25238
25346
  | Export | Kind | Summary |
25239
25347
  |--------|------|---------|
25240
25348
  | `defineMcpClientConnection` | function | declare one external MCP server connection over Streamable HTTP with an optional SSE fallback |
25241
- | `ConnectionOperationLimits` / `McpConnectionLimits` | _type_ | positive finite deadline/raw byte ceilings with independent discovery/call overrides; omitted fields inherit the shared bounds |
25349
+ | `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 |
25242
25350
  | `ConnectionPhase` / `ConnectionOperation` / `ConnectionFailureContext` | _type_ | closed operation/phase vocabulary and measured read context for existing typed connection errors |
25243
- | `ConnectionTimeoutError` / `ConnectionResponseTooLargeError` | class | bounded operation refusal, with phase, operation and finite observed bytes; safe tool projection retains the raw cause locally |
25351
+ | `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 |
25352
+ | `ConnectionDeadline` / `ConnectionTimeoutContext` | _type_ | `'total' \| 'idle'`, and a timeout's diagnostics with the deadline that fired (default `'total'`) |
25353
+ | `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 |
25244
25354
  | `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
25245
25355
  | `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) |
25246
25356
  | `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
@@ -25254,7 +25364,7 @@ and approval path.
25254
25364
  | `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 |
25255
25365
  | `SkippedConnectionTool` | _type_ | `{ connection, tool, reason }` — which tool was not mounted, and why |
25256
25366
  | `McpClientConnection` | _type_ | a defined MCP client connection |
25257
- | `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 |
25367
+ | `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 |
25258
25368
  | `McpConnectionTransport` | _type_ | `{ url, headers? }` for one MCP endpoint |
25259
25369
  | `McpToolFilter` | _type_ | `{ allow?, block? }` discovered-tool filter |
25260
25370
  | `OpenApiConnection` | _type_ | a defined OpenAPI connection |
@@ -25812,7 +25922,7 @@ SDK nor the `ai` peer.
25812
25922
  | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
25813
25923
  | `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) |
25814
25924
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
25815
- | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename |
25925
+ | `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 |
25816
25926
  | `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 |
25817
25927
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
25818
25928
  | `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 |
@@ -25828,7 +25938,7 @@ SDK nor the `ai` peer.
25828
25938
  | `CliBuildStampSchema` / `CliBuildStamp` | schema / _type_ | the version/commit/build time carried inside a binary |
25829
25939
  | `CliInstallerConfig` | _type_ | manifest, binary name, default install directory, and an optional `asset` — omit it for one script that selects the target by `uname` |
25830
25940
  | `CliUpdateCheckConfig` / `CliUpdateCheck` | _type_ | check inputs, and its four answers — `skipped`, `current`, `outdated`, `unknown` |
25831
- | `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 |
25941
+ | `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 |
25832
25942
  | `CliProfileStore` / `CliProfileStoreConfig` / `ResolvedCliProfile` | _type_ | the profile store, its directory/schema/hint config, and one resolution |
25833
25943
  | `CliResultView` | _type_ | the requested view — `count`, `sum`, or `records` (ordered and/or table-rendered) |
25834
25944
  | `CliViewOutput` | _type_ | a JSON value, or the one human-facing text shape |
package/llms.txt CHANGED
@@ -14,14 +14,14 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
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.0 KB → [llms/tools.3.txt](llms/tools.3.txt) 21.0 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.0 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
@@ -73,7 +73,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
73
73
 
74
74
  ## Upgrading slices
75
75
  - **Upgrading — how to move across versions**: [llms/upgrading.txt](llms/upgrading.txt) 12.7 KB
76
- - **Upgrading 0.106.0 → 0.123.0**: [llms/upgrading-0.106.0-0.123.0.txt](llms/upgrading-0.106.0-0.123.0.txt) 36.3 KB
76
+ - **Upgrading 0.106.0 → 0.124.0**: [llms/upgrading-0.106.0-0.124.0.txt](llms/upgrading-0.106.0-0.124.0.txt) 37.8 KB
77
77
  - **Upgrading 0.96.0 → 0.105.0**: [llms/upgrading-0.96.0-0.105.0.txt](llms/upgrading-0.96.0-0.105.0.txt) 45.8 KB
78
78
  - **Upgrading 0.69.0 → 0.95.0**: [llms/upgrading-0.69.0-0.95.0.txt](llms/upgrading-0.69.0-0.95.0.txt) 46.6 KB
79
79
  - **Upgrading 0.55.0 → 0.68.0**: [llms/upgrading-0.55.0-0.68.0.txt](llms/upgrading-0.55.0-0.68.0.txt) 47.0 KB
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.123.7",
3
+ "version": "0.124.1",
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",
@@ -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 };