stitchkit 0.103.12 → 0.104.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/darwin-native.cjs +12 -0
- package/darwin-native.d.cts +2 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
- package/dist/application/directory-inbox-accept.d.ts +13 -0
- package/dist/application/directory-inbox-accept.d.ts.map +1 -0
- package/dist/application/directory-inbox-contract.d.ts +42 -5
- package/dist/application/directory-inbox-contract.d.ts.map +1 -1
- package/dist/application/directory-inbox-delivery.d.ts +14 -0
- package/dist/application/directory-inbox-delivery.d.ts.map +1 -0
- package/dist/application/directory-inbox-files.d.ts +28 -0
- package/dist/application/directory-inbox-files.d.ts.map +1 -0
- package/dist/application/directory-inbox-state.d.ts +14 -0
- package/dist/application/directory-inbox-state.d.ts.map +1 -0
- package/dist/application/directory-inbox.d.ts +2 -1
- package/dist/application/directory-inbox.d.ts.map +1 -1
- package/dist/application/file-state-store.d.ts +2 -8
- package/dist/application/file-state-store.d.ts.map +1 -1
- package/dist/application/state-store.d.ts +6 -1
- package/dist/application/state-store.d.ts.map +1 -1
- package/dist/browser/client-arguments.d.ts +4 -0
- package/dist/browser/client-arguments.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http.d.ts +2 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/native-fetch.d.ts +8 -0
- package/dist/browser/native-fetch.d.ts.map +1 -0
- package/dist/contract/errors.d.ts +16 -12
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +5 -1
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/contract/stream.d.ts +1 -0
- package/dist/contract/stream.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +3 -3
- package/dist/entrypoints/agent-runtime/coding-tools.js +8 -6
- package/dist/entrypoints/agent-runtime/harness-tools.js +8 -8
- package/dist/entrypoints/agent-runtime/harness.js +12 -11
- package/dist/entrypoints/agent-runtime/realtime.js +3 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +8 -6
- package/dist/entrypoints/agent-runtime.js +13 -13
- package/dist/entrypoints/application/diagnostic-journal.js +3 -2
- package/dist/entrypoints/application/directory-inbox.js +424 -119
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application.d.ts +2 -2
- package/dist/entrypoints/application.d.ts.map +1 -1
- package/dist/entrypoints/application.js +7 -3
- package/dist/entrypoints/cli.d.ts +2 -0
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +757 -136
- package/dist/entrypoints/contract.js +3 -3
- package/dist/entrypoints/files.js +11 -107
- package/dist/entrypoints/index.js +7 -7
- package/dist/entrypoints/node.js +8 -8
- package/dist/entrypoints/observability.js +2 -2
- package/dist/entrypoints/process.js +2 -1
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +19 -6
- package/dist/entrypoints/server.d.ts +1 -1
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +20 -14
- package/dist/entrypoints/telegram.d.ts +1 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +214 -98
- package/dist/entrypoints/testing.js +7 -7
- package/dist/entrypoints/tools/connections.d.ts +2 -2
- package/dist/entrypoints/tools/connections.d.ts.map +1 -1
- package/dist/entrypoints/tools/connections.js +427 -294
- package/dist/entrypoints/tools/invoker.js +6 -6
- package/dist/entrypoints/tools/mcp.d.ts +12 -0
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -0
- package/dist/entrypoints/tools/mcp.js +45 -0
- package/dist/entrypoints/tools.d.ts +1 -0
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +82 -1147
- package/dist/entrypoints/tracking.js +1 -1
- package/dist/files/boundary.d.ts +2 -8
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +0 -5
- package/dist/files/file-io.d.ts.map +1 -1
- package/dist/files/read.d.ts +2 -2
- package/dist/files/read.d.ts.map +1 -1
- package/dist/index-1a6jtnd9.js +88 -0
- package/dist/{index-fyphpknh.js → index-22rhg58f.js} +1 -1
- package/dist/index-269zqj8m.js +77 -0
- package/dist/{index-r34mvse1.js → index-27a2pj09.js} +1 -1
- package/dist/{index-r956rndn.js → index-2hyavjjj.js} +3 -3
- package/dist/{index-m2xqkv55.js → index-2vnh05w4.js} +83 -14
- package/dist/{index-pw99k9h5.js → index-43p08g7t.js} +1 -1
- package/dist/{index-xwq9j1sf.js → index-4e0ah203.js} +9 -7
- package/dist/{index-nybn2err.js → index-5csmzesf.js} +1 -1
- package/dist/{index-qapzv4p5.js → index-5z6jn897.js} +1 -1
- package/dist/{index-ahvsksw5.js → index-6d9xaxw1.js} +1 -1
- package/dist/{index-ahtnte39.js → index-6drst9sg.js} +46 -35
- package/dist/{index-x87j7csh.js → index-77nxk6ay.js} +2 -2
- package/dist/{index-dnn9z96q.js → index-a0zzh8ak.js} +3 -3
- package/dist/{index-kmpzj1cq.js → index-a3wma1hk.js} +1 -1
- package/dist/{index-j8aw2c0e.js → index-bakgedh8.js} +35 -7
- package/dist/index-bhb950qs.js +1145 -0
- package/dist/{index-tgzhq07n.js → index-cvda079a.js} +1 -1
- package/dist/{index-n2gre124.js → index-fa4wg312.js} +4 -4
- package/dist/{index-zp4jpkp0.js → index-fk18k56k.js} +2 -2
- package/dist/{index-afjvjyck.js → index-g2j7pnak.js} +2 -134
- package/dist/index-g95fk660.js +116 -0
- package/dist/{index-ej331hah.js → index-gxm9rc97.js} +1 -1
- package/dist/{index-r5c4fedv.js → index-h2fhjqy7.js} +2 -1
- package/dist/{index-sybedc8b.js → index-hbd32c6a.js} +23 -94
- package/dist/index-jd470k6q.js +109 -0
- package/dist/{index-b2bz0kdm.js → index-kb8styz3.js} +4 -3
- package/dist/{index-0c419yx7.js → index-kemm0ej5.js} +12 -9
- package/dist/{index-806d5phm.js → index-ptn0g0gj.js} +7 -7
- package/dist/{index-w575evhq.js → index-r4r70zmh.js} +1 -1
- package/dist/{index-12m2v2a9.js → index-s4evrmp5.js} +1 -1
- package/dist/{index-1khy8y7n.js → index-t1sr4aks.js} +3 -3
- package/dist/index-v5ee8ath.js +88 -0
- package/dist/{index-45tdvqa3.js → index-wh0ecvyk.js} +1 -1
- package/dist/{index-n53mswt3.js → index-x928baz2.js} +8 -1
- package/dist/index-yk4g8805.js +133 -0
- package/dist/{index-ygkka6zn.js → index-ywppsaby.js} +28 -5
- package/dist/{index-xvdd2rbb.js → index-za6j7nwy.js} +19 -5
- package/dist/internal/bounded-file-read.d.ts +41 -0
- package/dist/internal/bounded-file-read.d.ts.map +1 -0
- package/dist/internal/darwin-binding-error.d.ts +24 -0
- package/dist/internal/darwin-binding-error.d.ts.map +1 -0
- package/dist/internal/darwin-binding.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +2 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +4 -2
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/telegram/broadcast-delivery.d.ts +23 -0
- package/dist/telegram/broadcast-delivery.d.ts.map +1 -0
- package/dist/telegram/broadcast-failure.d.ts +22 -0
- package/dist/telegram/broadcast-failure.d.ts.map +1 -0
- package/dist/telegram/broadcast-state.d.ts +6 -3
- package/dist/telegram/broadcast-state.d.ts.map +1 -1
- package/dist/telegram/broadcast.d.ts +10 -5
- package/dist/telegram/broadcast.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +2 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -1
- package/dist/tools/cli/args.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -2
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/publication-assets.d.ts +10 -0
- package/dist/tools/cli/publication-assets.d.ts.map +1 -0
- package/dist/tools/cli/publication-contract.d.ts +75 -0
- package/dist/tools/cli/publication-contract.d.ts.map +1 -0
- package/dist/tools/cli/publication-control.d.ts +4 -0
- package/dist/tools/cli/publication-control.d.ts.map +1 -0
- package/dist/tools/cli/publication-storage.d.ts +32 -0
- package/dist/tools/cli/publication-storage.d.ts.map +1 -0
- package/dist/tools/cli/publication.d.ts +35 -0
- package/dist/tools/cli/publication.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts.map +1 -1
- package/dist/tools/connections/error-projection.d.ts +4 -0
- package/dist/tools/connections/error-projection.d.ts.map +1 -0
- package/dist/tools/connections/errors.d.ts +24 -8
- package/dist/tools/connections/errors.d.ts.map +1 -1
- package/dist/tools/connections/limits.d.ts +11 -31
- package/dist/tools/connections/limits.d.ts.map +1 -1
- package/dist/tools/connections/mcp-client.d.ts +6 -4
- package/dist/tools/connections/mcp-client.d.ts.map +1 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/operation-limits.d.ts +25 -0
- package/dist/tools/connections/operation-limits.d.ts.map +1 -0
- package/dist/tools/connections/sse-frames.d.ts +11 -2
- package/dist/tools/connections/sse-frames.d.ts.map +1 -1
- package/dist/tools/connections/sse-session.d.ts +15 -2
- package/dist/tools/connections/sse-session.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +19 -1
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/execute-result.d.ts.map +1 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/observe-hook.d.ts +3 -0
- package/dist/tools/internal/observe-hook.d.ts.map +1 -0
- package/dist/tools/internal/surface-projector.d.ts +2 -1
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/mcp/mount.d.ts +2 -2
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +4 -5
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +4 -1
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool-execution.d.ts +65 -0
- package/dist/tools/runtime-tool-execution.d.ts.map +1 -0
- package/dist/tools/runtime-tool-mcp.d.ts +27 -0
- package/dist/tools/runtime-tool-mcp.d.ts.map +1 -0
- package/dist/tools/runtime-tool.d.ts +9 -60
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/surface.d.ts +12 -14
- package/dist/tools/surface.d.ts.map +1 -1
- package/llms/application.2.txt +221 -44
- package/llms/application.3.txt +3 -1
- package/llms/application.txt +1 -1
- package/llms/cli.2.txt +144 -1
- package/llms/cli.txt +133 -104
- package/llms/contract.txt +1 -1
- package/llms/process.txt +34 -5
- package/llms/server.4.txt +4 -1
- package/llms/server.5.txt +1 -0
- package/llms/stitchkit.2.txt +14 -0
- package/llms/stitchkit.txt +5 -4
- package/llms/telegram.txt +64 -2
- package/llms/tools-connections.txt +3 -0
- package/llms/tools-mcp.txt +29 -0
- package/llms/tools.2.txt +59 -0
- package/llms/tools.3.txt +1 -0
- package/llms/tools.txt +11 -52
- package/llms/upgrading-0.37.0-0.44.0.txt +444 -0
- package/llms/{upgrading-0.44.0-0.60.0.txt → upgrading-0.44.0-0.61.0.txt} +140 -271
- package/llms/{upgrading-0.61.0-0.74.0.txt → upgrading-0.62.0-0.79.0.txt} +171 -140
- package/llms/{upgrading-0.75.0-0.103.0.txt → upgrading-0.80.0-0.104.0.txt} +120 -171
- package/llms/upgrading.txt +4 -4
- package/llms-full.txt +677 -64
- package/llms.txt +13 -12
- package/package.json +10 -1
- package/dist/index-d4pa2bgs.js +0 -42
- package/dist/index-wykebpn9.js +0 -221
- package/llms/upgrading-0.37.0.txt +0 -176
- package/dist/{index-69nvze1q.js → index-pptyv13k.js} +3 -3
package/llms/telegram.txt
CHANGED
|
@@ -184,7 +184,8 @@ const report = await runTelegramBroadcast({
|
|
|
184
184
|
`retry_after` and sends the same recipient again; a server error is retried
|
|
185
185
|
with backoff up to `maxAttempts`, then `failed`. A message Telegram cannot
|
|
186
186
|
parse is not the recipient's fault: the run **halts** with them still pending,
|
|
187
|
-
so the run after the fix reaches them.
|
|
187
|
+
so the run after the fix reaches them. An unknown transport outcome becomes
|
|
188
|
+
`uncertain` immediately and halts the run; resume never sends to that recipient again.
|
|
188
189
|
- **Pacing** is `ratePerSecond`, 25 by default. `dryRun` counts and writes
|
|
189
190
|
nothing. One runner per name: a second concurrent run is refused.
|
|
190
191
|
|
|
@@ -193,6 +194,66 @@ application (the application's signal, with admission held by the caller).
|
|
|
193
194
|
The recipient state contains Telegram ids: keep it in the state directory, out
|
|
194
195
|
of git.
|
|
195
196
|
|
|
197
|
+
### Injecting another transport's failure policy
|
|
198
|
+
|
|
199
|
+
`classify(error)` returns the public `TelegramBroadcastFailure` union. It lets
|
|
200
|
+
an application use its own client without adding that SDK to Stitchkit:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
const report = await runTelegramBroadcast({
|
|
204
|
+
name: 'announcement',
|
|
205
|
+
directory: env.STATE_DIRECTORY,
|
|
206
|
+
recipients: () => audience.activeSubscribers(),
|
|
207
|
+
send: ({ recipient }) => client.sendMessage(recipient, message),
|
|
208
|
+
classify(error) {
|
|
209
|
+
if (isFloodWait(error))
|
|
210
|
+
return { kind: 'retry-after', retryAfterMs: error.seconds * 1000,
|
|
211
|
+
reason: 'provider-rate-limit' }
|
|
212
|
+
if (isRecipientGone(error))
|
|
213
|
+
return { kind: 'permanent', recipientUnreachable: true,
|
|
214
|
+
reason: 'recipient-gone' }
|
|
215
|
+
return { kind: 'ambiguous', reason: 'unknown-provider-outcome' }
|
|
216
|
+
},
|
|
217
|
+
maxRetryDelayMs: 60_000,
|
|
218
|
+
signal: stop.signal,
|
|
219
|
+
})
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The four variants are `retry-after` (exact `retryAfterMs`), `transient` (bounded
|
|
223
|
+
backoff), `permanent` (optionally `recipientUnreachable` or `stopBroadcast`), and
|
|
224
|
+
`ambiguous`. Retry variants certify that the failed attempt had no external
|
|
225
|
+
effect. Lack of an HTTP status does not establish that fact: a server may have
|
|
226
|
+
accepted the message before the connection failed. `ambiguous` durably records
|
|
227
|
+
`uncertain`, then halts; resuming the name skips that recipient.
|
|
228
|
+
|
|
229
|
+
`maxRetryDelayMs` defaults to 60 seconds. A provider wait above it halts with the
|
|
230
|
+
recipient pending; it is never shortened to send early. `maxAttempts` is an
|
|
231
|
+
integer from 1 to 100, `maxRetryDelayMs` is an integer from 0 to 2,147,483,647,
|
|
232
|
+
and pacing/progress intervals must fit native timers. The optional
|
|
233
|
+
`sleep(milliseconds, signal)` receives cancellation; the runner also stops waiting
|
|
234
|
+
when the signal aborts if a custom sleeper ignores it. A send already in flight
|
|
235
|
+
finishes and is recorded before stopping.
|
|
236
|
+
|
|
237
|
+
Without `classify`, known Bot API 429, unreachable-recipient, malformed-message
|
|
238
|
+
and server-error behavior remains. Unknown/no-status failures now halt as
|
|
239
|
+
uncertain, rather than being automatically retried. Existing custom `send`
|
|
240
|
+
implementations that relied on those retries must supply an explicit classifier
|
|
241
|
+
for proven pre-effect failures. `report.halt` now carries
|
|
242
|
+
`TelegramBroadcastFailure`; inspect `halt.kind` instead of the old send-failure
|
|
243
|
+
`scope`/`retryable` fields.
|
|
244
|
+
|
|
245
|
+
The runner uses the shared process-instance lock and checks its generation before
|
|
246
|
+
sends and journal writes. The audience and initial journal directory entry are
|
|
247
|
+
synced before sending. Lost ownership cannot write a stale delivered receipt or
|
|
248
|
+
start another send; the persisted intent becomes uncertain on recovery. Old
|
|
249
|
+
pid-only broadcast locks have unknown ownership and require recovery after their
|
|
250
|
+
writers are verified stopped, rather than automatic age-based deletion.
|
|
251
|
+
|
|
252
|
+
The installed
|
|
253
|
+
[`telegram-broadcast-classifier.mjs`](../../packages/core/scripts/consumer-lane/fixtures/minimal/src/telegram-broadcast-classifier.mjs)
|
|
254
|
+
fixture checks injected rate limits, ambiguity/no resend, wait budgets and abort
|
|
255
|
+
on Bun and Node without a client SDK.
|
|
256
|
+
|
|
196
257
|
## Message markup
|
|
197
258
|
|
|
198
259
|
`stitchkit/telegram/html` is Telegram's HTML parse mode as a tree, with no peer
|
|
@@ -393,8 +454,9 @@ injected grammY bot. → ADR 0143, ADR 0201 — [guide](../guide/telegram.md)
|
|
|
393
454
|
| `classifyTelegramSendFailure` | function | name a refused Bot API send and separate "retry this send" from "stop addressing this recipient" |
|
|
394
455
|
| `TelegramSendFailure` | _type_ | reason, `status`, Telegram-stated `retryAfterSeconds`, `retryable`, `recipientUnreachable` and which evidence produced the answer |
|
|
395
456
|
| `TelegramSendFailureReason` / `TELEGRAM_SEND_FAILURE_REASONS` | _type_ / constant | `blocked-by-user` / `user-deactivated` / `chat-not-found` / `not-started` / `rate-limited` / `message-invalid` / `server-error` / `unknown`, and the same as a list; a `Record<TelegramSendFailureReason, …>` over them fails to compile when a reason is added |
|
|
396
|
-
| `runTelegramBroadcast` | function | a resumable broadcast by `name` under a state `directory`: audience
|
|
457
|
+
| `runTelegramBroadcast` | function | a resumable broadcast by `name` under a state `directory`: audience and journal durably recorded, pacing at `ratePerSecond` (25), exact retry delays within the finite declared budget, injected classifier, uncertain send outcomes never replayed, `dryRun`, one fenced runner per name |
|
|
397
458
|
| `TelegramBroadcastConfig` / `TelegramBroadcastSend` / `TelegramBroadcastReport` / `TelegramBroadcastRunOutcome` / `TelegramBroadcastOutcome` / `TelegramBroadcastRecipient` | _type_ | `name`, `directory`, `recipients()`, `send({ recipient, attempt })`, `maxAttempts`, `signal`, `onProgress`; counts `delivered` / `unreachable` / `failed` / `uncertain` / `pending` and `finished` / `stopped` / `halted` / `dry-run` |
|
|
459
|
+
| `TelegramBroadcastFailureSchema` / `TelegramBroadcastFailure` | schema / _type_ | injected `classify` answers retry-after/transient/permanent/ambiguous; exact provider delay is bounded by `maxRetryDelayMs` without shortening, unknown outcome remains uncertain and is never replayed |
|
|
398
460
|
| `telegramBroadcastSender` / `TelegramBroadcastSenderConfig` / `TelegramBroadcastMessage` | function / _type_ | the standard `send`: `sendMessage` with a text or `copyMessage` of a prepared message, through the Bot API |
|
|
399
461
|
| `createTelegramOperatorChannel` | function | the operator chat, apart from the journal: `post(text, topic?)` returns at once and never throws; paced sends into forum topics, 429 honoured, oldest dropped on overflow, `drain(signal)` and `close()` for the way down |
|
|
400
462
|
| `TelegramOperatorChannelConfig` / `TelegramOperatorChannel` / `TelegramOperatorMessage` / `TelegramOperatorDrop` / `TelegramChatId` | _type_ | `chatId`, `topics`, `send`, `maxQueued`, `minIntervalMs`, `maxAttempts`, `onDropped`, `sensitivePatterns` and `sensitiveValues` (a bot token is always masked), `dedupe`; a drop is `overflow` / `refused` / `attempts` / `closed` / `repeated` / `over-budget` with its classification |
|
|
@@ -23,6 +23,9 @@ 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 |
|
|
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 |
|
|
26
29
|
| `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
|
|
27
30
|
| `mountConnections` | function | discover every connection and return readonly `RuntimeToolDefinition`s for `mountAgent` |
|
|
28
31
|
| `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# stitchkit/tools/mcp — stitchkit docs slice
|
|
2
|
+
|
|
3
|
+
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
|
+
> `llms.txt` in this package.
|
|
5
|
+
|
|
6
|
+
Contains: API reference: `stitchkit/tools/mcp` (docs/api/reference.md)
|
|
7
|
+
|
|
8
|
+
Also read:
|
|
9
|
+
- see `llms/tools.txt` for the MCP & agents guide
|
|
10
|
+
|
|
11
|
+
==============================================================================
|
|
12
|
+
# API reference: `stitchkit/tools/mcp` (docs/api/reference.md)
|
|
13
|
+
==============================================================================
|
|
14
|
+
|
|
15
|
+
## `stitchkit/tools/mcp`
|
|
16
|
+
|
|
17
|
+
A server-only leaf over the same MCP owner as `stitchkit/tools`. Its runtime and strict
|
|
18
|
+
NodeNext declarations require Zod and `@modelcontextprotocol/server`, with no AI SDK peer.
|
|
19
|
+
HTTP/stdio factories, mounts, schema policy, catalog and resource helpers keep their canonical
|
|
20
|
+
behavior and names. See [MCP guide](../guide/mcp-and-agents.md#mcp--createmcphandler).
|
|
21
|
+
|
|
22
|
+
| Export | Kind | Purpose |
|
|
23
|
+
|--------|------|---------|
|
|
24
|
+
| `createMcpHandler` / `createMcpHttpRoute` / `buildMcpServer` / `mountMcp` | function | the shared authenticated HTTP handler, raw-route adapter, SDK server and contract mount |
|
|
25
|
+
| `createStdioMcpServer` / `bindStdioProcessSignals` | function | the shared stdio server and bounded process cleanup |
|
|
26
|
+
| `RuntimeMcpToolDefinitionWithOutput` | _type_ | schema-aware MCP-only construction with concrete handler output and presenter input |
|
|
27
|
+
| `RuntimeMcpToolDefinition` | _type_ | heterogeneous MCP registration; the canonical runner validates input/output before invocation |
|
|
28
|
+
| `RuntimeMcpToolPresenters` / `RuntimeMcpPresentation` | _type_ | official SDK content without framework-owned `structuredContent` or `isError`; one presenter owner shared with the full SDK surface |
|
|
29
|
+
| `RuntimeToolDefinitionWithoutOutput` | _type_ | the shared neutral void definition |
|
package/llms/tools.2.txt
CHANGED
|
@@ -13,6 +13,65 @@ Parts of this slice:
|
|
|
13
13
|
# Guide: MCP & agents (docs/guide/mcp-and-agents.md) (continued)
|
|
14
14
|
==============================================================================
|
|
15
15
|
|
|
16
|
+
## Proxying a remote API — `implementRemote`
|
|
17
|
+
|
|
18
|
+
`implement` binds a contract to local handlers. `implementRemote` binds it to a
|
|
19
|
+
remote HTTP API instead — every handler forwards the call to a deployed server
|
|
20
|
+
through the contract's typed client:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createHttpClient } from 'stitchkit'
|
|
24
|
+
import { implementRemote } from 'stitchkit/remote'
|
|
25
|
+
import { createStdioMcpServer } from 'stitchkit/tools/mcp'
|
|
26
|
+
|
|
27
|
+
const http = createHttpClient({
|
|
28
|
+
baseUrl: 'https://api.example.com',
|
|
29
|
+
headers: () => ({ Authorization: `Bearer ${apiKey}` }),
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const stdio = await createStdioMcpServer({
|
|
33
|
+
serverInfo: { name: 'my-app', version: '1.0.0' },
|
|
34
|
+
auth: null,
|
|
35
|
+
services: contracts.map((c) => implementRemote(c, http)),
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
// During graceful shutdown:
|
|
39
|
+
await stdio.close()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This is how you ship a thin **local** MCP server for an API that already runs in
|
|
43
|
+
the cloud: the local process owns only the transport and any filesystem-facing
|
|
44
|
+
native tools, while every contract tool proxies to the remote API. One contract,
|
|
45
|
+
no duplicated business logic.
|
|
46
|
+
|
|
47
|
+
`implementRemote(contract, http, { transformArgs })` takes an optional
|
|
48
|
+
`transformArgs` hook that rewrites a call's arguments before they are forwarded
|
|
49
|
+
— e.g. to upload a local file referenced in the args and swap in its URL.
|
|
50
|
+
|
|
51
|
+
The call's signal reaches the existing typed HTTP client's request options, for endpoints
|
|
52
|
+
with or without arguments. An already cancelled call, including cancellation while an async
|
|
53
|
+
argument transform runs, dispatches no request. Bind your process signal to `createCli` or
|
|
54
|
+
`createCliInvoker`; `REQUEST_ABORTED` is a safe nonretryable failure with CLI exit130.
|
|
55
|
+
Cooperative origins observe `ctx.signal` and release resources when their work ends. An
|
|
56
|
+
origin or provider ignoring cancellation may continue after the local wait stops.
|
|
57
|
+
|
|
58
|
+
An explicit `AppError.retryable` boolean also survives this remote hop. `false` on502 and
|
|
59
|
+
`true` on409 remain the application's recommendation through HTTP, CLI, MCP and AI tools.
|
|
60
|
+
Absent metadata keeps the previous defaults and does not alter HTTP transport retries.
|
|
61
|
+
|
|
62
|
+
## Structured output
|
|
63
|
+
|
|
64
|
+
When a contract endpoint or runtime tool declares `output`, its MCP tool
|
|
65
|
+
registers that exact schema as `outputSchema` and returns the validated value as
|
|
66
|
+
`structuredContent` alongside a JSON text block. Every JSON root type is kept
|
|
67
|
+
unchanged: object, array, string, number, boolean and `null`. Stitchkit does not
|
|
68
|
+
wrap non-object values in `{ result }`; protocol-era adaptation belongs to the
|
|
69
|
+
official SDK.
|
|
70
|
+
|
|
71
|
+
A tool without an output contract advertises no `outputSchema` and returns no
|
|
72
|
+
invented structured value. Its successful MCP result has an empty `content`
|
|
73
|
+
list.
|
|
74
|
+
|
|
16
75
|
## A different answer for tools — `withToolView`
|
|
17
76
|
|
|
18
77
|
An admin page wants the full record; a model wants a card. Every byte of a
|
package/llms/tools.3.txt
CHANGED
|
@@ -278,6 +278,7 @@ Advanced building blocks — the shared machinery the mounts are built on.
|
|
|
278
278
|
| `TransportSummary` | _type_ | `{ contractServices, runtimeTools, totals, sources }` from `summarizeTransports` |
|
|
279
279
|
| `TransportCounts` | _type_ | per-transport counts (`{ HTTP, MCP, AGENT, CLI }`) |
|
|
280
280
|
| `ToolSurfaceDefinition` | _type_ | shared object-shaped `{ services?, runtimeTools? }` introspection surface |
|
|
281
|
+
| `ToolSurfaceProjection` | _type_ | one readonly services/runtime container shared by full and MCP-only surfaces; executable mounts specialize the runtime definition without pulling in another adapter's peers |
|
|
281
282
|
| `ToolManifestConfig` | _type_ | mixed surface plus required model-facing `transport` and presentation options |
|
|
282
283
|
| `coerceJsonArgs` | function | coerce JSON-stringified array/object tool arguments |
|
|
283
284
|
| `flattenToolJsonSchema` | function | project structurally identifiable discriminated unions into conservative object joins; scalar collisions retain provable types, object/array collisions retain structural alternatives, and field descriptions retain discriminator labels plus availability/requiredness hints; the projection never executes validation |
|
package/llms/tools.txt
CHANGED
|
@@ -147,13 +147,20 @@ get the view's defaults and projected answer, which is what `collectTools` and
|
|
|
147
147
|
|
|
148
148
|
## MCP — `createMcpHandler`
|
|
149
149
|
|
|
150
|
+
An MCP-only server imports `stitchkit/tools/mcp` and installs
|
|
151
|
+
`stitchkit`, `zod` and `@modelcontextprotocol/server`. The leaf's runtime and strict
|
|
152
|
+
NodeNext declarations require no `ai`. It exports the existing HTTP/stdio server,
|
|
153
|
+
schema policy, catalog and resource helpers; their implementation and security are shared
|
|
154
|
+
with the full `stitchkit/tools` barrel. Use that full barrel when the application also
|
|
155
|
+
needs its AI SDK features.
|
|
156
|
+
|
|
150
157
|
`createMcpHandler` builds a complete stateless Streamable-HTTP MCP endpoint on
|
|
151
158
|
the official TypeScript SDK v2 server package. It owns server creation,
|
|
152
159
|
protocol-era negotiation and shutdown; application code does not import the SDK
|
|
153
160
|
to mount a normal endpoint.
|
|
154
161
|
|
|
155
162
|
```ts
|
|
156
|
-
import { createMcpHandler, createMcpHttpRoute } from 'stitchkit/tools'
|
|
163
|
+
import { createMcpHandler, createMcpHttpRoute } from 'stitchkit/tools/mcp'
|
|
157
164
|
import { createServer } from 'stitchkit/server'
|
|
158
165
|
|
|
159
166
|
const mcp = createMcpHandler({
|
|
@@ -287,7 +294,7 @@ Every advertised tool and every tool result therefore carries the fingerprint of
|
|
|
287
294
|
the catalog it came from:
|
|
288
295
|
|
|
289
296
|
```ts
|
|
290
|
-
import { readMcpCatalogStamp } from 'stitchkit/tools';
|
|
297
|
+
import { readMcpCatalogStamp } from 'stitchkit/tools/mcp';
|
|
291
298
|
|
|
292
299
|
const listed = await client.listTools();
|
|
293
300
|
let known = readMcpCatalogStamp(listed.tools[0]?._meta); // { digest, tools }
|
|
@@ -792,7 +799,7 @@ If you already run an `McpServer` from the SDK, `mountMcp` adds contract tools
|
|
|
792
799
|
to it instead of owning the lifecycle:
|
|
793
800
|
|
|
794
801
|
```ts
|
|
795
|
-
import { mountMcp } from 'stitchkit/tools'
|
|
802
|
+
import { mountMcp } from 'stitchkit/tools/mcp'
|
|
796
803
|
|
|
797
804
|
mountMcp(mcpServer, [usersService], { context: { source: 'mcp' } })
|
|
798
805
|
```
|
|
@@ -808,7 +815,7 @@ client (Claude Desktop, Claude Code, Cursor, Codex), on the user's machine, so
|
|
|
808
815
|
it can reach the local filesystem.
|
|
809
816
|
|
|
810
817
|
```ts
|
|
811
|
-
import { bindStdioProcessSignals, createStdioMcpServer } from 'stitchkit/tools'
|
|
818
|
+
import { bindStdioProcessSignals, createStdioMcpServer } from 'stitchkit/tools/mcp'
|
|
812
819
|
|
|
813
820
|
const stdio = await createStdioMcpServer({
|
|
814
821
|
serverInfo: { name: 'my-app', version: '1.0.0' },
|
|
@@ -953,51 +960,3 @@ successes cannot reset a failing client's backoff.
|
|
|
953
960
|
> Dynamic Client Registration is an explicit interoperability mode, not the
|
|
954
961
|
> default. Enabling it changes public discovery and adds `/register`; keep it off
|
|
955
962
|
> unless a client that cannot publish CIMD requires it.
|
|
956
|
-
|
|
957
|
-
## Proxying a remote API — `implementRemote`
|
|
958
|
-
|
|
959
|
-
`implement` binds a contract to local handlers. `implementRemote` binds it to a
|
|
960
|
-
remote HTTP API instead — every handler forwards the call to a deployed server
|
|
961
|
-
through the contract's typed client:
|
|
962
|
-
|
|
963
|
-
```ts
|
|
964
|
-
import { createHttpClient } from 'stitchkit'
|
|
965
|
-
import { implementRemote } from 'stitchkit/remote'
|
|
966
|
-
import { createStdioMcpServer } from 'stitchkit/tools'
|
|
967
|
-
|
|
968
|
-
const http = createHttpClient({
|
|
969
|
-
baseUrl: 'https://api.example.com',
|
|
970
|
-
headers: () => ({ Authorization: `Bearer ${apiKey}` }),
|
|
971
|
-
})
|
|
972
|
-
|
|
973
|
-
const stdio = await createStdioMcpServer({
|
|
974
|
-
serverInfo: { name: 'my-app', version: '1.0.0' },
|
|
975
|
-
auth: null,
|
|
976
|
-
services: contracts.map((c) => implementRemote(c, http)),
|
|
977
|
-
})
|
|
978
|
-
|
|
979
|
-
// During graceful shutdown:
|
|
980
|
-
await stdio.close()
|
|
981
|
-
```
|
|
982
|
-
|
|
983
|
-
This is how you ship a thin **local** MCP server for an API that already runs in
|
|
984
|
-
the cloud: the local process owns only the transport and any filesystem-facing
|
|
985
|
-
native tools, while every contract tool proxies to the remote API. One contract,
|
|
986
|
-
no duplicated business logic.
|
|
987
|
-
|
|
988
|
-
`implementRemote(contract, http, { transformArgs })` takes an optional
|
|
989
|
-
`transformArgs` hook that rewrites a call's arguments before they are forwarded
|
|
990
|
-
— e.g. to upload a local file referenced in the args and swap in its URL.
|
|
991
|
-
|
|
992
|
-
## Structured output
|
|
993
|
-
|
|
994
|
-
When a contract endpoint or runtime tool declares `output`, its MCP tool
|
|
995
|
-
registers that exact schema as `outputSchema` and returns the validated value as
|
|
996
|
-
`structuredContent` alongside a JSON text block. Every JSON root type is kept
|
|
997
|
-
unchanged: object, array, string, number, boolean and `null`. Stitchkit does not
|
|
998
|
-
wrap non-object values in `{ result }`; protocol-era adaptation belongs to the
|
|
999
|
-
official SDK.
|
|
1000
|
-
|
|
1001
|
-
A tool without an output contract advertises no `outputSchema` and returns no
|
|
1002
|
-
invented structured value. Its successful MCP result has an empty `content`
|
|
1003
|
-
list.
|