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/cli.2.txt CHANGED
@@ -64,6 +64,31 @@ Carry the build stamp inside the binary (`CliBuildStampSchema`,
64
64
  `formatCliBuildStamp`) so the tool can say what it is rather than leaving the
65
65
  reader to infer it from behaviour.
66
66
 
67
+ #### A download on a slow link
68
+
69
+ A build is tens of megabytes, and on a slow link that is minutes. `applyCliUpdate` bounds
70
+ the download by silence rather than length: `idleTimeoutMs` (default 30 seconds) ends it
71
+ when nothing has arrived for that long, and `timeoutMs` (default 30 minutes) bounds the
72
+ response headers and, separately, the body. A declared `timeoutMs` keeps meaning exactly that,
73
+ with an idle deadline only when `idleTimeoutMs` is declared too.
74
+
75
+ Give it a `partialPath` in your state directory and an interrupted download continues where
76
+ it stopped:
77
+
78
+ ```ts
79
+ await applyCliUpdate({ asset: check.asset, partialPath: join(stateDir, 'update.part') })
80
+ ```
81
+
82
+ Every received chunk is appended to that file, and `<partialPath>.json` records the URL, the
83
+ build's digest and the server's validator (a strong `ETag`, else `Last-Modified`). The next
84
+ attempt asks for the rest with `Range` and `If-Range`; `206` from the right offset continues
85
+ the file, `200` (the build changed) replaces it, `416` with the full length means it is
86
+ already whole. A part is never trusted: the finished transfer is decoded and checked against
87
+ the manifest like a fresh one, and a continued file that fails — a corrupt part, a build
88
+ re-published under the same URL — is thrown away and downloaded once more from zero. Both
89
+ files are removed once the download is decoded, and `<partialPath>.lock` refuses a second
90
+ update into the same part while one is running. The size ceiling counts the kept part too.
91
+
67
92
  #### A manifest inside your own network
68
93
 
69
94
  The check goes through the same SSRF boundary every outbound fetch does, so a
@@ -467,9 +492,14 @@ const discovered = await mountConnections([
467
492
  token: () => key,
468
493
  transports: ['CLI'], // the opt-in: this server's tools are commands
469
494
  limits: {
470
- discovery: { timeoutMs: 30_000, maxResponseBytes: 4 * 1024 * 1024 },
495
+ discovery: { maxResponseBytes: 4 * 1024 * 1024 }, // 300 s total, 30 s of silence
471
496
  call: { timeoutMs: 120_000 },
472
497
  },
498
+ // Skip tools/list while the stored catalog is the one the server serves.
499
+ catalog: {
500
+ load: async () => JSON.parse(await readFile(catalogPath, 'utf8')),
501
+ store: (entry) => writeFile(catalogPath, JSON.stringify(entry)),
502
+ },
473
503
  }),
474
504
  ])
475
505
  await createCli({ name: 'myapp', version, runtimeTools: discovered, commands: [...] })
@@ -511,13 +541,37 @@ limits. Each logical operation has one deadline, including initial transport
511
541
  negotiation and response-body reading. Legacy endpoint readiness has a discovery
512
542
  deadline; the lifetime of an established SSE stream does not.
513
543
 
514
- Omitted phase fields inherit the existing connection-level `timeoutMs` and
515
- `maxResponseBytes`, whose defaults are 30 seconds and 1 MiB. Values must be positive
516
- safe integers; `timeoutMs` must also fit the runtime timer range. The byte ceiling
544
+ Inside that deadline an operation may have an idle one: `idleTimeoutMs` ends it when
545
+ nothing has arrived for that long — the response headers and every body chunk restart
546
+ it, so a slow link that keeps delivering a large catalog is never cut off, while a
547
+ silent one still ends with `ConnectionTimeoutError` whose `deadline` is `'idle'`. On a
548
+ shared legacy SSE stream any byte is progress for every pending operation.
549
+
550
+ Omitted phase fields inherit the connection-level `timeoutMs` and `maxResponseBytes`.
551
+ With neither set, discovery allows 300 seconds in total and 30 seconds of silence, and
552
+ a call 30 seconds with no idle deadline — a tool may compute in silence before it
553
+ answers, so a call's idle deadline is only what you declare. A declared `timeoutMs`
554
+ keeps meaning exactly that deadline: discovery then has an idle deadline only when you
555
+ declare one too. The byte default is 1 MiB.
556
+ Values must be positive safe integers; deadlines must also fit the runtime timer range. The byte ceiling
517
557
  counts raw UTF-8 body bytes, including SSE framing, regardless of `Content-Length`.
518
558
  Pending legacy calls also count comments and wrong-id frames. `budget.maxTools`
519
559
  and `budget.maxSchemaBytes` remain separate mount limits.
520
560
 
561
+ **A stored catalog is mounted while it is current.** A Stitchkit server sends its
562
+ [catalog stamp](./mcp-and-agents.md#knowing-your-catalog-is-stale--the-catalog-stamp) with
563
+ the `initialize` answer, as the `stitchkit-catalog` response header. Given a `catalog:
564
+ { load, store }`, the connection compares it with the stamp of the stored `tools/list`
565
+ result and mounts the stored one when they match — every stored tool must carry the same
566
+ stamp, and there must be as many — so a start costs no catalog transfer. A different
567
+ stamp (the server's contract moved, or the credential sees another surface) lists and
568
+ stores again. A listing is stored only when every tool in it carries the stamp the
569
+ `initialize` answer announced, so a rolling deploy answering the two requests from
570
+ different builds stores nothing. A server without a stamp, a surface with raw SDK tools
571
+ and a failing `load` or `store` all cost one `tools/list`, never the mount. The stamp
572
+ covers what `tools/list` publishes as Stitchkit builds it; the JSON Schema text the
573
+ server's MCP SDK renders from the same schema is not hashed separately.
574
+
521
575
  Only the initial `initialize` can negotiate HTTP-to-legacy fallback on 400, 404
522
576
  or 405. A failed `tools/call` is not replayed. Caller cancellation preserves its
523
577
  original reason for in-process observers.
@@ -637,7 +691,7 @@ SDK nor the `ai` peer.
637
691
  | `CliProfileError` | class | an `AppError` refusing a named profile that is missing, unreadable or shared between users |
638
692
  | `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) |
639
693
  | `checkCliUpdate` | function | bounded, interval-limited, never-throwing check for a newer published build |
640
- | `applyCliUpdate` | function | download, verify the decompressed digest and replace the binary by rename |
694
+ | `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 |
641
695
  | `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 |
642
696
  | `rollbackCliUpdate` / `CliRollbackConfig` / `RolledBackCliUpdate` | function / _types_ | put the kept previous build back, digest-checked first and written by the same atomic rename the update uses |
643
697
  | `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 |
@@ -653,7 +707,7 @@ SDK nor the `ai` peer.
653
707
  | `CliBuildStampSchema` / `CliBuildStamp` | schema / _type_ | the version/commit/build time carried inside a binary |
654
708
  | `CliInstallerConfig` | _type_ | manifest, binary name, default install directory, and an optional `asset` — omit it for one script that selects the target by `uname` |
655
709
  | `CliUpdateCheckConfig` / `CliUpdateCheck` | _type_ | check inputs, and its four answers — `skipped`, `current`, `outdated`, `unknown` |
656
- | `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 |
710
+ | `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 |
657
711
  | `CliProfileStore` / `CliProfileStoreConfig` / `ResolvedCliProfile` | _type_ | the profile store, its directory/schema/hint config, and one resolution |
658
712
  | `CliResultView` | _type_ | the requested view — `count`, `sum`, or `records` (ordered and/or table-rendered) |
659
713
  | `CliViewOutput` | _type_ | a JSON value, or the one human-facing text shape |
package/llms/cli.txt CHANGED
@@ -692,7 +692,7 @@ Three kinds of block hold a file, and the file may be of any type:
692
692
 
693
693
  | Block | Bytes | File name |
694
694
  | --- | --- | --- |
695
- | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `name` |
695
+ | `image`, `audio` (`McpMediaContentSchema`) | standard base64 in `data` | `_meta['stitchkit/fileName']` |
696
696
  | `resource` with `blob` — a PDF, a spreadsheet, an archive | standard base64 in `resource.blob` | last path segment of `resource.uri` |
697
697
  | `resource` with `text` — CSV, Markdown, JSON | `resource.text` as UTF-8 | last path segment of `resource.uri` |
698
698
 
@@ -701,7 +701,8 @@ rich-text node that also calls itself `image`, a `resource` without content —
701
701
  own data and is left alone.
702
702
 
703
703
  **Names.** A name is reduced to its basename, like a URL download name;
704
- `defineViewFileTool` sets `name` to the file name of the source. A block that names no file
704
+ `defineViewFileTool` and `mountViewFile` set a media block's `_meta['stitchkit/fileName']`
705
+ (`MCP_FILE_NAME_META_KEY`) to the file name of the source. A block that names no file
705
706
  is `<type>-<sha256-of-its-bytes><extension>`: known media types supply the extension and
706
707
  the rest use `.bin`. A name is written once per batch. The same bytes under the same name
707
708
  are one file; different bytes under a name the batch already wrote fail that file, and the
@@ -94,13 +94,13 @@ own, recorded as an ADR.
94
94
  | `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
95
95
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
96
96
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
97
- | `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 |
97
+ | `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 |
98
98
  | `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 |
99
99
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
100
100
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
101
101
  | `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) |
102
102
  | `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 |
103
- | `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 |
103
+ | `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 |
104
104
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
105
105
  | `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 |
106
106
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -112,7 +112,7 @@ own, recorded as an ADR.
112
112
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
113
113
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
114
114
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
115
- | `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 |
115
+ | `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 |
116
116
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
117
117
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
118
118
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
@@ -23,9 +23,11 @@ and approval path.
23
23
  | Export | Kind | Summary |
24
24
  |--------|------|---------|
25
25
  | `defineMcpClientConnection` | function | declare one external MCP server connection over Streamable HTTP with an optional SSE fallback |
26
- | `ConnectionOperationLimits` / `McpConnectionLimits` | _type_ | positive finite deadline/raw byte ceilings with independent discovery/call overrides; omitted fields inherit the shared bounds |
26
+ | `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 |
27
27
  | `ConnectionPhase` / `ConnectionOperation` / `ConnectionFailureContext` | _type_ | closed operation/phase vocabulary and measured read context for existing typed connection errors |
28
- | `ConnectionTimeoutError` / `ConnectionResponseTooLargeError` | class | bounded operation refusal, with phase, operation and finite observed bytes; safe tool projection retains the raw cause locally |
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
+ | `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 |
29
31
  | `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
30
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) |
31
33
  | `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
@@ -39,7 +41,7 @@ and approval path.
39
41
  | `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 |
40
42
  | `SkippedConnectionTool` | _type_ | `{ connection, tool, reason }` — which tool was not mounted, and why |
41
43
  | `McpClientConnection` | _type_ | a defined MCP client connection |
42
- | `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 |
44
+ | `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 |
43
45
  | `McpConnectionTransport` | _type_ | `{ url, headers? }` for one MCP endpoint |
44
46
  | `McpToolFilter` | _type_ | `{ allow?, block? }` discovered-tool filter |
45
47
  | `OpenApiConnection` | _type_ | a defined OpenAPI connection |
@@ -25,7 +25,7 @@ payload. See [MCP guide](../guide/mcp-and-agents.md#mcp--createmcphandler).
25
25
 
26
26
  | Export | Kind | Purpose |
27
27
  |--------|------|---------|
28
- | `createMcpHandler` | function | a stateless dual-era Streamable-HTTP MCP handler — [guide](../guide/mcp-and-agents.md#mcp--createmcphandler) |
28
+ | `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) |
29
29
  | `createMcpHttpRoute` | function | framework-owned `RawRoute` adapter for an MCP HTTP handler |
30
30
  | `createStdioMcpServer` | function | a complete stdio MCP server — [guide](../guide/mcp-and-agents.md#mcp-over-stdio--createstdiomcpserver) |
31
31
  | `bindStdioProcessSignals` | function | explicitly bind OS signals to one close-only stdio handle — [guide](../guide/testing-and-deployment.md#stdio-process-signals) |
@@ -69,7 +69,10 @@ retained session to push `notifications/tools/list_changed` down; the stamp need
69
69
  Store the stamp beside the tools when you list them, compare it against the one on every
70
70
  result, and re-list when they differ — including on a refusal, which is exactly when a
71
71
  stale catalog is the likeliest explanation and the least visible one. The server side
72
- needs no wiring: every mount stamps what it advertises.
72
+ needs no wiring: every mount stamps what it advertises — each tool's name, description,
73
+ schemas, annotations and `ui` resource — and `createMcpHandler` sends the same stamp as the
74
+ `stitchkit-catalog` response header, `initialize` included, which is what a connection's
75
+ `catalog` store is checked against before `tools/list`.
73
76
 
74
77
  | Export | Kind | Summary |
75
78
  |--------|------|---------|
package/llms/tools.2.txt CHANGED
@@ -556,10 +556,16 @@ Ordinary file names containing brackets, such as `[preview].png`, remain valid.
556
556
  A local file with an unsupported extension is refused before reading; its
557
557
  per-item error identifies the caller's path and the extension it saw.
558
558
 
559
- Each inline `image` and `audio` block carries `name`, the file name of its
560
- source: a managed file keeps its own name, a URL takes its download name — the
561
- path's base name with the body's extension. A CLI saves the block under that
562
- name with [`--output-dir`](cli.md#saving-result-media).
559
+ Each inline `image` and `audio` block carries the file name of its source in
560
+ `_meta['stitchkit/fileName']` (`MCP_FILE_NAME_META_KEY`): a managed file keeps
561
+ its own name, a URL takes its download name — the path's base name with the
562
+ body's extension. MCP declares no file name on `ImageContent` or `AudioContent`,
563
+ and the MCP server SDK drops an undeclared field from `content`, so the name is
564
+ in `_meta`, the protocol's place for what a block carries beyond it. The block
565
+ is therefore the same in the handler's output, an Agent's result,
566
+ `structuredContent` and MCP `content`, and a host reads the name from the block
567
+ it renders. A CLI saves the block under that name with
568
+ [`--output-dir`](cli.md#saving-result-media).
563
569
 
564
570
  The older `mountWait`, `mountDownload`, `mountUpload` and `mountViewFile`
565
571
  functions remain
package/llms/tools.3.txt CHANGED
@@ -83,7 +83,8 @@ server SDK), [`stitchkit/tools/agent`](#stitchkittoolsagent) (the `ai` peer) and
83
83
  | `ViewFileErrorSchema` | constant | Zod schema for one structured per-item view failure |
84
84
  | `McpAnnotations` | _type_ | MCP annotations on a media result |
85
85
  | `McpAnnotationsSchema` | constant | Zod schema for MCP media annotations |
86
- | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content |
86
+ | `McpMediaContentSchema` | constant | Zod schema for text/image/audio media content — the blocks MCP declares, field for field |
87
+ | `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 |
87
88
  | `CollectToolsConfig` | _type_ | options for `collectTools` |
88
89
  | `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)) |
89
90
  | `UntypedProperty` | _type_ | one such property — `{ path, description? }` |
package/llms/tools.txt CHANGED
@@ -313,9 +313,16 @@ same problem and `createMcpHandler` cannot send it: it is stateless by
313
313
  construction, so there is no retained session to push down.
314
314
 
315
315
  The digest covers each advertised tool's name, description, input schema, output
316
- schema and annotations, and nothing else — it moves when the contract moves and
317
- not when a handler does. Raw SDK registrations stay consumer-owned and are
318
- outside it.
316
+ schema, annotations and MCP Apps `ui` resource, and nothing else — it moves when the
317
+ contract moves and not when a handler does. Raw SDK registrations stay consumer-owned
318
+ and are outside it, so a handler with `rawTools` sends no stamp header.
319
+
320
+ `createMcpHandler` also sends the stamp of the surface each request was served from as
321
+ the `stitchkit-catalog` response header (the same `{ digest, tools }` JSON), on the
322
+ `initialize` answer included — the SDK assembles that result itself and leaves no
323
+ `_meta` to fill. A client can therefore tell whether its stored catalog is current
324
+ before it asks for `tools/list`; `defineMcpClientConnection({ catalog })` does exactly
325
+ that ([CLI → commands discovered from a running server](./cli.md#commands-discovered-from-a-running-server)).
319
326
 
320
327
  ### Saying which tools only read — `readOnlyHint`
321
328
 
@@ -1,14 +1,50 @@
1
- # Upgrading 0.106.0 → 0.123.0 — stitchkit docs slice
1
+ # Upgrading 0.106.0 → 0.124.0 — stitchkit docs slice
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
5
 
6
- Contains: Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.106.0 → 0.124.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.106.0 → 0.124.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.124.0
13
+
14
+ ### media-block-file-name
15
+
16
+ **Who must act:** code that builds or reads an `image` or `audio` block of
17
+ `McpMediaContentSchema` with a `name` — a tool that returns such a block, or a reader of a
18
+ `defineViewFileTool`, `mountViewFile` or `resolveMedia` result. The field exists only in 0.123.7.
19
+
20
+ The file name of a media block lives in the block's `_meta`, under the key
21
+ `MCP_FILE_NAME_META_KEY` (`stitchkit/fileName`), and the block has no `name`. The block is now
22
+ exactly what MCP declares, so the same block reaches a handler's caller, an Agent,
23
+ `structuredContent` and MCP `content`; the `name` field never reached `content`.
24
+
25
+ ```ts
26
+ import { MCP_FILE_NAME_META_KEY } from 'stitchkit/tools/contract'
27
+
28
+ // before
29
+ const block = { type: 'image', data, mimeType: 'image/png', name: 'shot.png' }
30
+ const fileName = block.name
31
+
32
+ // after
33
+ const block = {
34
+ type: 'image',
35
+ data,
36
+ mimeType: 'image/png',
37
+ _meta: { [MCP_FILE_NAME_META_KEY]: 'shot.png' },
38
+ }
39
+ const fileName = block._meta?.[MCP_FILE_NAME_META_KEY] // unknown: check it is a string
40
+ ```
41
+
42
+ A block that still carries `name` is not refused: the schema drops the field, and a CLI's
43
+ `--output-dir` then names the file `<type>-<sha256><extension>`. An object typed
44
+ `McpMediaContent` does not compile with `name`, which is where TypeScript code finds every
45
+ site; search untyped code for `name:` beside `type: 'image'` or `type: 'audio'`. A test that
46
+ compared MCP `content` with `structuredContent` minus `name` compares them whole.
47
+
12
48
  ## Released migration: 0.123.0
13
49
 
14
50
  ### unknown-operation
@@ -11,7 +11,7 @@ Contains: Guide: Upgrading, general (docs/guide/upgrading.md)
11
11
 
12
12
  Load this slice, then every range slice between your installed version and the target:
13
13
 
14
- - 0.106.0 → 0.123.0: `llms/upgrading-0.106.0-0.123.0.txt`
14
+ - 0.106.0 → 0.124.0: `llms/upgrading-0.106.0-0.124.0.txt`
15
15
  - 0.96.0 → 0.105.0: `llms/upgrading-0.96.0-0.105.0.txt`
16
16
  - 0.69.0 → 0.95.0: `llms/upgrading-0.69.0-0.95.0.txt`
17
17
  - 0.55.0 → 0.68.0: `llms/upgrading-0.55.0-0.68.0.txt`