stitchkit 0.134.0 → 0.134.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +6 -6
- package/dist/agent-executor/claude/cli-driver.d.ts +6 -0
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +9 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/engine-spawn.d.ts +18 -5
- package/dist/agent-executor/claude-sdk/engine-spawn.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-manager.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-options.d.ts +16 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +5 -5
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +13 -13
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-macos.d.ts +5 -4
- package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-spec.d.ts +6 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts +2 -1
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/sqlite-schema.d.ts +2 -2
- package/dist/agent-runtime/sqlite.d.ts +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +20 -20
- package/dist/agent-runtime/store-conformance-support.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/application/grammy.d.ts +1 -1
- package/dist/browser/contract-identity.d.ts +1 -1
- package/dist/browser/http-fetch.d.ts +1 -1
- package/dist/browser/socket-io-contract.d.ts +1 -1
- package/dist/contract/bridge-envelope.d.ts +1 -1
- package/dist/contract/client-types.d.ts +1 -1
- package/dist/contract/define.d.ts +2 -2
- package/dist/contract/errors-factory.d.ts +1 -1
- package/dist/contract/fingerprint.d.ts +1 -1
- package/dist/device-relay/hub.d.ts +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +323 -153
- package/dist/entrypoints/agent-executor/claude.js +40 -26
- package/dist/entrypoints/agent-runtime/postgres.js +3 -3
- package/dist/entrypoints/agent-runtime/sandbox.js +21 -16
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/node.js +1 -1
- package/dist/entrypoints/bin/upgrade-cli.js +1 -1
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/handler.js +2 -2
- package/dist/entrypoints/node.js +2 -2
- package/dist/entrypoints/server.js +2 -2
- package/dist/entrypoints/tools/mcp.js +3 -3
- package/dist/entrypoints/tools/toolkit.js +3 -3
- package/dist/entrypoints/tools.js +2 -2
- package/dist/files/native-packaging-layout.d.ts +1 -1
- package/dist/{index-654rhe5d.js → index-7mjsb7zv.js} +5 -1
- package/dist/{index-kdw0n92g.js → index-a09r9ff0.js} +1 -1
- package/dist/{index-epyj7ptp.js → index-a84wj6y8.js} +4 -4
- package/dist/{index-qymek778.js → index-m2b49tvc.js} +76 -22
- package/dist/{index-mrng24wq.js → index-zag9sjpd.js} +1 -1
- package/dist/internal/postgres-query.d.ts +1 -1
- package/dist/react/query-client.d.ts +1 -1
- package/dist/server/bridge-host.d.ts +1 -1
- package/dist/server/bun.d.ts +1 -1
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +3 -3
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/socket-io-config.d.ts +1 -1
- package/dist/service-host/identity.d.ts +1 -1
- package/dist/service-host/systemd-inspect.d.ts +1 -1
- package/dist/testing/manual-clock.d.ts +1 -1
- package/dist/tools/connections/types.d.ts +1 -1
- package/dist/tools/mcp/handler.d.ts +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +1 -1
- package/dist/tools/mcp/mount.d.ts +1 -1
- package/dist/tools/mcp/stdio.d.ts +1 -1
- package/llms/agent-executor-claude-sdk.txt +1 -1
- package/llms/agent-executor-claude.txt +1 -1
- package/llms/agent-runtime-browser.txt +1 -1
- package/llms/agent-runtime-sandbox.txt +12 -8
- package/llms/agent-runtime-sqlite-bun.txt +1 -1
- package/llms/agent-runtime.2.txt +1 -1
- package/llms/agent-runtime.3.txt +4 -4
- package/llms/agent-runtime.txt +3 -3
- package/llms/application.2.txt +4 -4
- package/llms/application.txt +4 -4
- package/llms/cli.2.txt +27 -6
- package/llms/cli.txt +2 -2
- package/llms/contract.txt +1 -1
- package/llms/files-packaging.txt +1 -1
- package/llms/geo.txt +1 -1
- package/llms/live.txt +1 -1
- package/llms/oauth.txt +4 -4
- package/llms/observability.txt +3 -3
- package/llms/primitives.txt +1 -1
- package/llms/process.2.txt +7 -7
- package/llms/react.txt +4 -4
- package/llms/server.2.txt +7 -7
- package/llms/server.3.txt +5 -5
- package/llms/server.4.txt +6 -6
- package/llms/server.txt +13 -5
- package/llms/stitchkit.2.txt +3 -3
- package/llms/stitchkit.3.txt +1 -1
- package/llms/stitchkit.txt +4 -4
- package/llms/telegram.txt +1 -1
- package/llms/testing.txt +4 -4
- package/llms/tools-connections.txt +1 -1
- package/llms/tools-toolkit.txt +3 -1
- package/llms/tools.2.txt +6 -6
- package/llms/tools.3.txt +8 -8
- package/llms/upgrading-0.106.0-0.126.0.txt +1 -1
- package/llms/upgrading-0.128.0-0.134.0.txt +7 -1
- package/llms/upgrading-0.37.0-0.53.0.txt +7 -7
- package/llms/upgrading-0.69.0-0.95.0.txt +1 -1
- package/llms/upgrading-0.96.0-0.105.0.txt +1 -1
- package/llms-full.txt +163 -122
- package/llms.txt +8 -8
- package/package.json +1 -1
package/llms-full.txt
CHANGED
|
@@ -274,8 +274,8 @@ below is the canonical install command.
|
|
|
274
274
|
you import — both for `stitchkit/tools/toolkit`:
|
|
275
275
|
|
|
276
276
|
```bash
|
|
277
|
-
bun add @modelcontextprotocol/server@^2 # stitchkit/tools/mcp
|
|
278
|
-
bun add ai@^7 # stitchkit/tools/agent or stitchkit/agent-runtime/ai-sdk
|
|
277
|
+
bun add @modelcontextprotocol/server@^2 # stitchkit/tools/mcp or stitchkit/tools/toolkit
|
|
278
|
+
bun add ai@^7 # stitchkit/tools/agent, stitchkit/tools/toolkit or stitchkit/agent-runtime/ai-sdk
|
|
279
279
|
```
|
|
280
280
|
|
|
281
281
|
Browser, HTTP-client and React entrypoints remain usable without either MCP
|
|
@@ -865,7 +865,7 @@ export const users = defineContract({ prefix: 'users' }, {
|
|
|
865
865
|
`HEAD` is an explicit HTTP-only operation, never an automatic alias for `GET`.
|
|
866
866
|
It must declare `rawResponse: true`; request body, `input`, multipart, `rawBody`,
|
|
867
867
|
typed `output` and tool exposure are rejected. The handler owns status and
|
|
868
|
-
headers, while
|
|
868
|
+
headers, while StitchKit guarantees an empty wire body even if the returned
|
|
869
869
|
`Response` accidentally contains one.
|
|
870
870
|
|
|
871
871
|
## `params` vs `input` vs `output`
|
|
@@ -1353,6 +1353,14 @@ When an HTTP caller sends a relative remaining budget in `x-stitchkit-timeout-ms
|
|
|
1353
1353
|
`401`/`403`; an inbound value of `0` then fails immediately with `REQUEST_TIMEOUT` (`408`) before
|
|
1354
1354
|
payload parsing, `beforeHandle`, or the handler runs. Malformed non-integer values are ignored so
|
|
1355
1355
|
the endpoint's declared timeout remains authoritative.
|
|
1356
|
+
- For a streaming endpoint (`stream: { ... }`), `timeout` and `x-stitchkit-timeout-ms` bound only
|
|
1357
|
+
the response-open phase until the handler returns its `AsyncIterable` (matching the client's open
|
|
1358
|
+
timeout). Once the stream opens, the open deadline timer is disarmed, `ctx.signal` stays bound to
|
|
1359
|
+
client disconnect (`req.signal`), managed shutdown, and `stream.lifetimeMs`, and
|
|
1360
|
+
`ctx.remainingTimeoutMs` switches to `stream.lifetimeMs` (or `undefined` when unbounded). The same
|
|
1361
|
+
open-phase boundary applies to a `rawResponse: true` endpoint returning a `Response` with a body:
|
|
1362
|
+
the open timer is disarmed once the `Response` is returned while `ctx.signal` stays subscribed to
|
|
1363
|
+
client disconnect (`req.signal`).
|
|
1356
1364
|
- Inside the handler, `ctx.remainingTimeoutMs?.(reserveMs?)` returns the live remaining integer
|
|
1357
1365
|
milliseconds (clamped to `>= 0`, subtracting optional `reserveMs` for response serialization), or
|
|
1358
1366
|
`undefined` when neither an inbound header nor an endpoint `timeout` bounds the request. Always
|
|
@@ -1620,7 +1628,7 @@ server. See [Testing & deployment](./testing-and-deployment.md).
|
|
|
1620
1628
|
| `traceId` | override per-request trace-id resolution — may return `undefined` to fall back |
|
|
1621
1629
|
| `wrapFetch` | compose wrappers around the finished handler (request context, audit) |
|
|
1622
1630
|
| `proxyOrigin` | Bun TCP ingress policy: `{ trustedPeer(socketIp) }` restores the external scheme before all composition; independent of client-IP `trustProxy` |
|
|
1623
|
-
| `socket` | full
|
|
1631
|
+
| `socket` | full StitchKit Socket.IO handle; route, default WebSocket handler and shutdown are mounted once |
|
|
1624
1632
|
| `websocket` | custom Bun WebSocket handler; with `socket`, this is the explicit composed handler |
|
|
1625
1633
|
| `development` / `bun` | passthrough to `Bun.serve` |
|
|
1626
1634
|
|
|
@@ -1827,7 +1835,7 @@ when forwarding to owned streaming routes; it is also required by native timeout
|
|
|
1827
1835
|
|
|
1828
1836
|
### Trusted HTTPS in development
|
|
1829
1837
|
|
|
1830
|
-
|
|
1838
|
+
StitchKit does not own local certificate generation or a frontend development
|
|
1831
1839
|
server. When a device or browser feature requires a secure context, generate a
|
|
1832
1840
|
trusted certificate outside the application (for example with `mkcert`) and pass
|
|
1833
1841
|
its files through the Bun server boundary:
|
|
@@ -1892,7 +1900,7 @@ request-error recorder; an `AbortError` while the request signal is still active
|
|
|
1892
1900
|
remains an internal failure. A runtime abort reason may be preserved by identity
|
|
1893
1901
|
through at most eight cycle-safe standard `cause` links; error messages and codes
|
|
1894
1902
|
are never classifiers. The same rule applies when the disconnect happens while
|
|
1895
|
-
|
|
1903
|
+
StitchKit is reading a JSON upload body: bounded reads race every pending stream
|
|
1896
1904
|
read against the request signal and never parse a cancelled partial body. `499`
|
|
1897
1905
|
is transport telemetry, not a response declared in the contract or generated
|
|
1898
1906
|
OpenAPI document.
|
|
@@ -2094,7 +2102,7 @@ That split is deliberate — see [ADR 0003](../decisions/0003-two-context-types.
|
|
|
2094
2102
|
|
|
2095
2103
|
## A host beside its own window
|
|
2096
2104
|
|
|
2097
|
-
A desktop app's host — the process beside its window — is an ordinary
|
|
2105
|
+
A desktop app's host — the process beside its window — is an ordinary StitchKit server, bound to
|
|
2098
2106
|
loopback. Calls are plain HTTP through the typed client; events travel the realtime socket with
|
|
2099
2107
|
`retain` per topic ([realtime](./realtime.md)). There is no second transport to learn.
|
|
2100
2108
|
|
|
@@ -2198,7 +2206,7 @@ Trust boundary and operational rules for the unix channel:
|
|
|
2198
2206
|
container and keep the full UTF-8 path within 103 bytes; TCC permissions remain bound to the host
|
|
2199
2207
|
process's responsible bundle.
|
|
2200
2208
|
- **Embedded agents and shell tools.** An unsandboxed agent shell running as the same OS user has full
|
|
2201
|
-
access to the socket. Inside
|
|
2209
|
+
access to the socket. Inside StitchKit's Linux Bubblewrap sandbox (`stitchkit/agent-runtime/sandbox`),
|
|
2202
2210
|
the host's `$HOME`, `/tmp`, `/run` and `XDG_RUNTIME_DIR` are not mounted (`--unshare-all --clearenv`),
|
|
2203
2211
|
so keep the socket outside the agent's mounted `workspace` directory (note that macOS has no
|
|
2204
2212
|
Bubblewrap isolation).
|
|
@@ -2589,7 +2597,7 @@ createServer({
|
|
|
2589
2597
|
`serviceName` and `action` are optional observability identity. Declare
|
|
2590
2598
|
`serviceName` when audit, logging, sampling or another cross-cutting policy
|
|
2591
2599
|
groups this raw route with a service; add `action` when the policy needs an
|
|
2592
|
-
operation within that service.
|
|
2600
|
+
operation within that service. StitchKit never derives either from `path`.
|
|
2593
2601
|
`action` without `serviceName`, and empty identity strings, fail at startup.
|
|
2594
2602
|
|
|
2595
2603
|
A path may be exact, carry `:param` segments, or end in `/*filePath` for a prefix
|
|
@@ -2598,7 +2606,7 @@ wildcard — and the two combine: `/app/:slug/*filePath` matches `/app/x/a/b` wi
|
|
|
2598
2606
|
deep-link fallback). List more specific routes before the wildcard — the first
|
|
2599
2607
|
match wins. `staticRoute()` builds a raw route that serves a directory.
|
|
2600
2608
|
|
|
2601
|
-
At startup
|
|
2609
|
+
At startup StitchKit rejects exact duplicates, equivalent parameter shapes
|
|
2602
2610
|
(`/users/:id` vs `/users/:userId`) and any later raw route completely hidden by
|
|
2603
2611
|
an earlier raw route. Partial overlap stays legal, including the recommended
|
|
2604
2612
|
specific-before-wildcard order. `GET` and `HEAD` remain independent because that
|
|
@@ -2903,7 +2911,7 @@ them.
|
|
|
2903
2911
|
|
|
2904
2912
|
For large files, set `delivery: 'stream'` and define receivers. A receiver gets
|
|
2905
2913
|
a Web `ReadableStream<Uint8Array>` and writes directly to consumer-owned
|
|
2906
|
-
storage;
|
|
2914
|
+
storage; StitchKit holds only bounded parser state:
|
|
2907
2915
|
|
|
2908
2916
|
```ts
|
|
2909
2917
|
const streamingUploads = defineContract({ prefix: 'uploads' }, {
|
|
@@ -3004,12 +3012,12 @@ createServer({ services: [users, orders], rawRoutes: [openApiRoute('/openapi.jso
|
|
|
3004
3012
|
Only HTTP-exposed methods appear (an MCP/agent-only tool is skipped).
|
|
3005
3013
|
|
|
3006
3014
|
OpenAPI 3.1 has no standard multi-segment path parameter. For a contract path
|
|
3007
|
-
ending in a named wildcard such as `/*filePath`,
|
|
3015
|
+
ending in a named wildcard such as `/*filePath`, StitchKit keeps the literal
|
|
3008
3016
|
runtime path, omits `filePath` from the
|
|
3009
3017
|
standard `in: path` parameter list, and emits
|
|
3010
3018
|
`x-stitchkit-trailing-wildcard` on the operation with its parameter name,
|
|
3011
3019
|
schema and semantics. A generic OpenAPI client therefore cannot invent
|
|
3012
|
-
catch-all expansion; use
|
|
3020
|
+
catch-all expansion; use StitchKit's typed client or teach the generator that
|
|
3013
3021
|
extension.
|
|
3014
3022
|
|
|
3015
3023
|
### Curating the spec — `includeMethod`
|
|
@@ -3211,7 +3219,7 @@ pauses its socket, and resuming preserves the exact chunked body.
|
|
|
3211
3219
|
|
|
3212
3220
|
`UnixClientTransportError` carries a stable `code` and `delivery`:
|
|
3213
3221
|
`not-dispatched`, `possibly-dispatched` or `response-received`. Only the first
|
|
3214
|
-
proves that the remote operation did not begin;
|
|
3222
|
+
proves that the remote operation did not begin; StitchKit never silently retries
|
|
3215
3223
|
an ambiguous write. Response consumption/cancellation belongs to the operation,
|
|
3216
3224
|
and `close()` interrupts active work and destroys owned connections.
|
|
3217
3225
|
|
|
@@ -3273,7 +3281,7 @@ attempt, so the default `2` permits at most three total attempts. The default
|
|
|
3273
3281
|
|
|
3274
3282
|
Inside Next.js 16 server rendering, the first attempt still uses Next's normal
|
|
3275
3283
|
request memoization. If Ky authorizes a retry after a network rejection,
|
|
3276
|
-
|
|
3284
|
+
StitchKit passes that retry's current `Request.signal` in the second fetch
|
|
3277
3285
|
argument and materializes the current Request as URL + init. Next 16.3 otherwise
|
|
3278
3286
|
merges `init` into a Request before its dedupe layer and loses the explicit
|
|
3279
3287
|
signal opt-out. The retry therefore performs a new network attempt instead of
|
|
@@ -3390,7 +3398,7 @@ contract:
|
|
|
3390
3398
|
Every endpoint callable exposes a `withOptions` method accepting required
|
|
3391
3399
|
`ClientRequestOptions`. The ordinary callable contains only contract arguments,
|
|
3392
3400
|
so it can be passed directly to callback APIs such as `react-query-kit` without
|
|
3393
|
-
mistaking their callback context for
|
|
3401
|
+
mistaking their callback context for StitchKit transport options.
|
|
3394
3402
|
|
|
3395
3403
|
**That safety has a cost worth knowing before it bites you.** `api.thing(args,
|
|
3396
3404
|
{ signal })` — the shape everyone reaches for first — is not an error: the second
|
|
@@ -3886,7 +3894,7 @@ try {
|
|
|
3886
3894
|
|
|
3887
3895
|
`traceId` is present when the server returned `x-request-id`. A network error,
|
|
3888
3896
|
timeout or abort without an HTTP response cannot carry one. Cross-origin
|
|
3889
|
-
browser code can read it through
|
|
3897
|
+
browser code can read it through StitchKit's default CORS expose list; a custom
|
|
3890
3898
|
`cors.exposeHeaders` policy must keep `x-request-id` exposed.
|
|
3891
3899
|
|
|
3892
3900
|
The error model is shared with the server — see [Auth & errors](./auth-and-errors.md).
|
|
@@ -3979,7 +3987,7 @@ if (server === undefined) {
|
|
|
3979
3987
|
}
|
|
3980
3988
|
```
|
|
3981
3989
|
|
|
3982
|
-
Both fingerprints arrive as a value; a difference never throws.
|
|
3990
|
+
Both fingerprints arrive as a value; a difference never throws. StitchKit
|
|
3983
3991
|
computes the two identities and compares nothing — what a mismatch means is the
|
|
3984
3992
|
application's decision. The client's fingerprint is computed locally and is not
|
|
3985
3993
|
sent to the server. The identity operation is public and lists operation names,
|
|
@@ -4742,7 +4750,7 @@ load balancing therefore cannot strand a client on an in-memory session.
|
|
|
4742
4750
|
The default `legacy: 'serve'` lets the official SDK negotiate either modern
|
|
4743
4751
|
`2026-07-28` or the supported legacy stateless opening on this same endpoint.
|
|
4744
4752
|
Set `legacy: 'reject'` when every host is modern. Legacy support is protocol
|
|
4745
|
-
translation inside the SDK, not a second
|
|
4753
|
+
translation inside the SDK, not a second StitchKit transport or compatibility
|
|
4746
4754
|
API. Stateful MCP and subscriptions are intentionally outside this layer.
|
|
4747
4755
|
|
|
4748
4756
|
`createMcpHttpRoute` is the framework-owned raw-route adapter. It registers
|
|
@@ -4761,7 +4769,7 @@ must not be used as authorization input.
|
|
|
4761
4769
|
|
|
4762
4770
|
### Modern discovery, routing and cache hints
|
|
4763
4771
|
|
|
4764
|
-
|
|
4772
|
+
StitchKit forwards the negotiated protocol era and validated MCP request data
|
|
4765
4773
|
to both `RequestEvent.mcp` and the current managed call's typed `context.mcp`;
|
|
4766
4774
|
untrusted routing headers never become application identity. The SDK validates
|
|
4767
4775
|
`MCP-Protocol-Version`, JSON-RPC shape and routing
|
|
@@ -4776,7 +4784,7 @@ means zero/private: neither a prepared surface nor a deterministic response is
|
|
|
4776
4784
|
silently treated as public. Unbounded auth-selected surface factories are
|
|
4777
4785
|
always forced to zero/private even when an operation policy is present; use a
|
|
4778
4786
|
finite `surfaces` registry when identities share a provably immutable surface.
|
|
4779
|
-
|
|
4787
|
+
StitchKit never advertises list-change or subscription capabilities
|
|
4780
4788
|
without an implementation.
|
|
4781
4789
|
|
|
4782
4790
|
### Knowing your catalog is stale — the catalog stamp
|
|
@@ -5106,7 +5114,7 @@ expiry-checked. Tampered, expired, cross-user or cross-tool state fails before
|
|
|
5106
5114
|
the side effect. Output validation applies only to the final result.
|
|
5107
5115
|
|
|
5108
5116
|
Every attempt re-runs auth/lifecycle and emits its own tool hooks; audit metadata
|
|
5109
|
-
contains the attempt's `mcp.outcome` and `mcp.round`.
|
|
5117
|
+
contains the attempt's `mcp.outcome` and `mcp.round`. StitchKit does not merge
|
|
5110
5118
|
separate HTTP attempts into one logical trace. Parallel
|
|
5111
5119
|
rounds have isolated context. HTTP/stdio modern hosts and the supported legacy
|
|
5112
5120
|
stdio bridge may use this declaration; Agent, CLI and ordinary HTTP invocation
|
|
@@ -5358,7 +5366,7 @@ It is **deep** because the projection walks the generated JSON Schema document,
|
|
|
5358
5366
|
including objects, arrays, tuples and schema-definition nodes. Structurally
|
|
5359
5367
|
identifiable discriminated object unions are flattened wherever they occur.
|
|
5360
5368
|
Plain unions and unions hidden behind unresolved external references remain
|
|
5361
|
-
unions because
|
|
5369
|
+
unions because StitchKit cannot soundly invent a discriminator.
|
|
5362
5370
|
|
|
5363
5371
|
Use the default `flattenUnionInput: false` when the model must see the exact
|
|
5364
5372
|
relationship between a discriminator and each branch. Joined property schemas
|
|
@@ -5368,7 +5376,7 @@ The flattened form is **lossy but never executable**. Per-variant refinements
|
|
|
5368
5376
|
and incompatible constraints are widened in the presentation document; the
|
|
5369
5377
|
original Zod contract enforces them exactly once inside `executeToolMethod`.
|
|
5370
5378
|
MCP and AI adapters forward the raw argument object unchanged, so defaults,
|
|
5371
|
-
coercions and transforms cannot run before
|
|
5379
|
+
coercions and transforms cannot run before StitchKit. Strict violations return
|
|
5372
5380
|
the normal `VALIDATION_ERROR` tool envelope and fire `beforeToolCall` /
|
|
5373
5381
|
`afterToolCall`. → [ADR 0050](../decisions/0050-presentation-schema-is-not-a-parser.md).
|
|
5374
5382
|
|
|
@@ -5681,7 +5689,7 @@ a deadline the remote client hit (`REQUEST_TIMEOUT`, `408`) follows the status l
|
|
|
5681
5689
|
When a contract endpoint or runtime tool declares `output`, its MCP tool
|
|
5682
5690
|
registers that exact schema as `outputSchema` and returns the validated value as
|
|
5683
5691
|
`structuredContent` alongside a JSON text block. Every JSON root type is kept
|
|
5684
|
-
unchanged: object, array, string, number, boolean and `null`.
|
|
5692
|
+
unchanged: object, array, string, number, boolean and `null`. StitchKit does not
|
|
5685
5693
|
wrap non-object values in `{ result }`; protocol-era adaptation belongs to the
|
|
5686
5694
|
official SDK.
|
|
5687
5695
|
|
|
@@ -5776,7 +5784,7 @@ removes keys on purpose and is not reported. → [ADR 0196](../decisions/0196-a-
|
|
|
5776
5784
|
## AI agents — `mountAgent`
|
|
5777
5785
|
|
|
5778
5786
|
`mountAgent` remains the low-level path when the application owns its own model
|
|
5779
|
-
loop and conversation state. For the optional
|
|
5787
|
+
loop and conversation state. For the optional StitchKit-owned run/history loop,
|
|
5780
5788
|
see [Agent application runtime](./agent-runtime.md).
|
|
5781
5789
|
|
|
5782
5790
|
`mountAgent` turns a service into a Vercel AI SDK `ToolSet`, ready for
|
|
@@ -5958,7 +5966,7 @@ hook/lifecycle `OperationIdentity` and the tool `RequestEvent`
|
|
|
5958
5966
|
(`serviceName`, `action`, `httpMethod`). A runtime operation has no HTTP route,
|
|
5959
5967
|
so no fake `path` is added.
|
|
5960
5968
|
|
|
5961
|
-
When `output` is declared,
|
|
5969
|
+
When `output` is declared, StitchKit validates the neutral handler result after
|
|
5962
5970
|
`afterHandle`. MCP owns `structuredContent` and `isError`: a presenter supplies
|
|
5963
5971
|
only rich `content`/metadata, while the framework inserts the validated
|
|
5964
5972
|
structured result and normalises failures. The Agent adapter uses the AI SDK's
|
|
@@ -5967,7 +5975,7 @@ neutral output while the model receives text/file content. Presentation
|
|
|
5967
5975
|
callbacks require an output schema.
|
|
5968
5976
|
|
|
5969
5977
|
The MCP registration uses an identity carrier: the SDK advertises the compiled
|
|
5970
|
-
JSON Schema but forwards the raw object into
|
|
5978
|
+
JSON Schema but forwards the raw object into StitchKit. Input failures therefore
|
|
5971
5979
|
use the same validation, lifecycle and hook path as contract tools.
|
|
5972
5980
|
|
|
5973
5981
|
### Managed wait, download, upload and view-file
|
|
@@ -6078,7 +6086,7 @@ batch operation.
|
|
|
6078
6086
|
### Async-operation protocol
|
|
6079
6087
|
|
|
6080
6088
|
For a complete long-running operation, define the linked runtime-only surface
|
|
6081
|
-
once.
|
|
6089
|
+
once. StitchKit owns transport names, validation and wait mechanics; the
|
|
6082
6090
|
application still owns storage, execution, retries and domain states:
|
|
6083
6091
|
|
|
6084
6092
|
```ts
|
|
@@ -6142,7 +6150,7 @@ prevents a stale run owner from crossing an effect boundary; the transactional
|
|
|
6142
6150
|
idempotency record makes a repeated current call converge on one operation.
|
|
6143
6151
|
Neither replaces the other.
|
|
6144
6152
|
|
|
6145
|
-
|
|
6153
|
+
StitchKit deliberately does **not** own the durable queue, operation database,
|
|
6146
6154
|
lease renewal, provider retry/reconciliation protocol, asset catalog or domain
|
|
6147
6155
|
states. The process-local application resource stops admission and drains
|
|
6148
6156
|
accepted work; unresolved durable records survive shutdown for the next
|
|
@@ -6273,7 +6281,7 @@ operations whose contract intentionally differs.
|
|
|
6273
6281
|
Deferred tool search, name snapshots and boot diagnostics accept the same
|
|
6274
6282
|
object-shaped surface as the mounts. Contract operations are followed by
|
|
6275
6283
|
runtime definitions, matching mount order; exposure filters and collisions are
|
|
6276
|
-
resolved by
|
|
6284
|
+
resolved by StitchKit rather than by consumer code:
|
|
6277
6285
|
|
|
6278
6286
|
```ts
|
|
6279
6287
|
import {
|
|
@@ -6300,7 +6308,7 @@ fails first on duplicate contract/runtime names. There is no runtime-only
|
|
|
6300
6308
|
manifest helper or public mount adapter: the framework owns merging and schema
|
|
6301
6309
|
projection.
|
|
6302
6310
|
|
|
6303
|
-
Applications using
|
|
6311
|
+
Applications using StitchKit's durable runtime can compose this manifest with
|
|
6304
6312
|
bounded per-run activation through `createDeferredAgentToolSurface` from
|
|
6305
6313
|
`stitchkit/agent-runtime`. It keeps selected calls as direct `mountAgent` tools
|
|
6306
6314
|
rather than routing them through a generic executor. Search receipts live in
|
|
@@ -6367,7 +6375,7 @@ identical. Write the handler once; it serves every surface.
|
|
|
6367
6375
|
> from `stitchkit/tools/agent` for an AI SDK loop) is the direct path.
|
|
6368
6376
|
|
|
6369
6377
|
`stitchkit/agent-runtime` is the peer-free, server-only, opinionated layer above
|
|
6370
|
-
`mountAgentTools`. Use it when the application wants
|
|
6378
|
+
`mountAgentTools`. Use it when the application wants StitchKit to own conversation
|
|
6371
6379
|
mechanics: durable acceptance, history projection, the native `AgentModelDriver`
|
|
6372
6380
|
step loop, checkpoints, keyed interruption, terminal commit and stable application
|
|
6373
6381
|
events.
|
|
@@ -6815,7 +6823,7 @@ is a reference structured control loop for `submit`, `interrupt`, `snapshot` and
|
|
|
6815
6823
|
It starts no process and chooses no framing, authentication or transport. Importing either example
|
|
6816
6824
|
has no side effect; an external supervisor owns process placement and restart.
|
|
6817
6825
|
|
|
6818
|
-
| Concern | Public
|
|
6826
|
+
| Concern | Public StitchKit composition | Boundary |
|
|
6819
6827
|
| --- | --- | --- |
|
|
6820
6828
|
| execution loop | `createAgentRuntime` | already available; do not copy a second loop |
|
|
6821
6829
|
| model choice | `defineModelRegistry` and `models.resolve` | provider credentials/discovery stay application-owned |
|
|
@@ -7103,7 +7111,7 @@ fit. Exact equality (including a zero window with zero reservations/history)
|
|
|
7103
7111
|
fits; any unavailable component keeps the decision `unavailable`.
|
|
7104
7112
|
|
|
7105
7113
|
The same opaque `tx` reaches head, run, admission and history callbacks. The adapter maps rows
|
|
7106
|
-
and supplies atomicity;
|
|
7114
|
+
and supplies atomicity; StitchKit owns transition validation and revision
|
|
7107
7115
|
arithmetic. The executable reference is
|
|
7108
7116
|
[`examples/agent-store-prisma/adapter.ts`](../../examples/agent-store-prisma/adapter.ts).
|
|
7109
7117
|
`compareAndSwap` returns either `{ outcome: 'applied' }` or
|
|
@@ -7145,7 +7153,7 @@ const sqlite = createNodeSqliteAgentRuntimeStore({ filename: './agent-runtime.sq
|
|
|
7145
7153
|
Initialization creates only `stitchkit_agent_runtime_*` tables and records
|
|
7146
7154
|
schema version 2 in `stitchkit_agent_runtime_meta`; it does not use
|
|
7147
7155
|
`PRAGMA user_version` or mutate application tables. An unknown schema version or
|
|
7148
|
-
unversioned partial
|
|
7156
|
+
unversioned partial StitchKit schema is refused. The connection is owned by the
|
|
7149
7157
|
returned handle and closes only after accepted operations drain.
|
|
7150
7158
|
|
|
7151
7159
|
Each handle serializes its transactions. Separate connections use
|
|
@@ -7688,7 +7696,7 @@ what it produced"**:
|
|
|
7688
7696
|
surface that sends nothing until the run is done never showed it at all. When
|
|
7689
7697
|
it reached nobody, it is not part of the conversation. That is `supersede`.
|
|
7690
7698
|
|
|
7691
|
-
**
|
|
7699
|
+
**StitchKit cannot answer that question for you** — delivery belongs to the
|
|
7692
7700
|
transport, and the runtime sees an abort, not a screen. Hence a declared policy
|
|
7693
7701
|
(→ ADR 0108), and hence `inputPolicy` accepting a function, so one application
|
|
7694
7702
|
can hold two surfaces with different rules without the core learning which is
|
|
@@ -7816,7 +7824,7 @@ while the predecessor still owns managed callbacks. A hung predecessor blocks
|
|
|
7816
7824
|
the lane in the first version.
|
|
7817
7825
|
|
|
7818
7826
|
Shutdown is two-phase, and both budgets carry the names they carry everywhere
|
|
7819
|
-
else in
|
|
7827
|
+
else in StitchKit:
|
|
7820
7828
|
|
|
7821
7829
|
```ts
|
|
7822
7830
|
const closed = await runtime.close({ gracePeriodMs: 30_000, forceTimeoutMs: 5_000 })
|
|
@@ -8178,7 +8186,7 @@ The agent `terminal` event and the adapter's delivery receipt are intentionally
|
|
|
8178
8186
|
different records. A successful run does not prove that a reply reached its
|
|
8179
8187
|
channel, and a delivery failure never rewrites the canonical agent result.
|
|
8180
8188
|
Shutdown stops ingress, drains accepted process-local work and leaves ambiguous
|
|
8181
|
-
outbox records visible for a later reconciliation pass.
|
|
8189
|
+
outbox records visible for a later reconciliation pass. StitchKit does not own
|
|
8182
8190
|
a channel database, durable broker, provider payload schema or application
|
|
8183
8191
|
identity policy.
|
|
8184
8192
|
|
|
@@ -8217,7 +8225,7 @@ prepareStep: (step) => {
|
|
|
8217
8225
|
```
|
|
8218
8226
|
|
|
8219
8227
|
That deliberate refusal ends the run as `context_overflow` on the durable
|
|
8220
|
-
record, delivery terminal and operator event.
|
|
8228
|
+
record, delivery terminal and operator event. StitchKit does not inspect error
|
|
8221
8229
|
messages — it recognises failures by identity, not by text. A store refusing an
|
|
8222
8230
|
owned mutation ends the run `storage_conflict`; `protocol.acceptTerminal`
|
|
8223
8231
|
refusing a finished message ends it `output_rejected`; a check the SDK runs on
|
|
@@ -8959,7 +8967,7 @@ no cost to binding first.
|
|
|
8959
8967
|
|
|
8960
8968
|
The exact resource callbacks are typed by their public configuration. The
|
|
8961
8969
|
important ownership rule is stable: the application decides what the
|
|
8962
|
-
database/server/provider objects are and how they are configured;
|
|
8970
|
+
database/server/provider objects are and how they are configured; StitchKit
|
|
8963
8971
|
orders their process-local lifecycle and decides *when* they come into
|
|
8964
8972
|
existence.
|
|
8965
8973
|
|
|
@@ -8972,9 +8980,9 @@ dependency.
|
|
|
8972
8980
|
|
|
8973
8981
|
Start and readiness are different. A connection can finish setup and return a
|
|
8974
8982
|
ready handle. A poller can return a handle immediately, settle `ready` later,
|
|
8975
|
-
and keep a long-lived `completion` promise.
|
|
8983
|
+
and keep a long-lived `completion` promise. StitchKit observes both.
|
|
8976
8984
|
|
|
8977
|
-
Once
|
|
8985
|
+
Once StitchKit invokes start/activation, cleanup is guaranteed to be attempted.
|
|
8978
8986
|
Write `close` so it is safe when setup was partial:
|
|
8979
8987
|
|
|
8980
8988
|
```ts
|
|
@@ -9122,7 +9130,7 @@ failure, and the startup error stays the `cause` of the `AggregateError` that
|
|
|
9122
9130
|
failed startup from ever reporting why it failed.
|
|
9123
9131
|
|
|
9124
9132
|
A required long-lived completion that rejects after startup makes readiness
|
|
9125
|
-
false and health unhealthy.
|
|
9133
|
+
false and health unhealthy. StitchKit records the failure but does not restart
|
|
9126
9134
|
the resource or process.
|
|
9127
9135
|
|
|
9128
9136
|
`ApplicationResourceShutdown.failures` names the phase that failed — `start`,
|
|
@@ -10210,10 +10218,11 @@ be refused explicitly by the backend.
|
|
|
10210
10218
|
|
|
10211
10219
|
## Long-lived process sandbox (`createProcessSandbox`)
|
|
10212
10220
|
|
|
10213
|
-
When isolating a long-lived streaming stdio or IPC engine process (
|
|
10214
|
-
that must keep its real host workspace path and streaming pipes, use
|
|
10215
|
-
`probeProcessSandbox`. Its `wrapCommand` method matches
|
|
10216
|
-
`CodexDriverConfig.wrapCommand`
|
|
10221
|
+
When isolating a long-lived streaming stdio or IPC engine process (Codex, ACP, Claude SDK, or
|
|
10222
|
+
Claude CLI) that must keep its real host workspace path and streaming pipes, use
|
|
10223
|
+
`createProcessSandbox` and `probeProcessSandbox`. Its `wrapCommand` method matches
|
|
10224
|
+
`AcpDriverConfig.wrapCommand`, `CodexDriverConfig.wrapCommand`, `ClaudeSdkDriverConfig.wrapCommand`,
|
|
10225
|
+
and `ClaudeCliDriverConfig.wrapCommand` structurally:
|
|
10217
10226
|
|
|
10218
10227
|
```ts
|
|
10219
10228
|
import { createProcessSandbox, probeProcessSandbox } from 'stitchkit/agent-runtime/sandbox';
|
|
@@ -10254,9 +10263,12 @@ const driver = createCodexDriver({ wrapCommand: sandbox.wrapCommand });
|
|
|
10254
10263
|
(`workspace-strict`), `homeDir`, `writableDirs`, and explicitly allowed `unixSockets` (with
|
|
10255
10264
|
`workspace` denied for writes in `workspace-readonly`, and explicit socket allows ordered after
|
|
10256
10265
|
that deny and before `denyPaths`). Reads remain permitted by default for macOS frameworks and
|
|
10257
|
-
binaries except paths listed in `denyPaths`,
|
|
10258
|
-
|
|
10259
|
-
|
|
10266
|
+
binaries except paths listed in `denyPaths`, where Seatbelt denies `file-read*`, `file-write*`,
|
|
10267
|
+
`network-outbound` (`remote unix-socket`), and `network-bind`/`network-inbound` (`local
|
|
10268
|
+
unix-socket`) across both lexical and symlink-resolved ancestor paths — even when `network` is
|
|
10269
|
+
`'allow'` — so callers on macOS must explicitly add control sockets, sibling workspaces, and
|
|
10270
|
+
host secrets to `denyPaths`. Seatbelt cannot remap Unix socket paths: supplying `mountPath !==
|
|
10271
|
+
hostPath` fails closed with `SANDBOX_UNAVAILABLE`.
|
|
10260
10272
|
|
|
10261
10273
|
|
|
10262
10274
|
==============================================================================
|
|
@@ -10968,11 +10980,11 @@ still judged alive.
|
|
|
10968
10980
|
|
|
10969
10981
|
Public leaves keep optional peers out of their import closure. Installing `stitchkit` still
|
|
10970
10982
|
installs the complete package and ky; selective imports alone do not avoid that installation.
|
|
10971
|
-
A library can use
|
|
10983
|
+
A library can use StitchKit as a build dependency, bundle its selected public native imports,
|
|
10972
10984
|
keep Zod external, and publish the resulting implementation with its library artifact.
|
|
10973
10985
|
|
|
10974
10986
|
```ts
|
|
10975
|
-
// The library's build entry; all mechanisms remain owned by
|
|
10987
|
+
// The library's build entry; all mechanisms remain owned by StitchKit.
|
|
10976
10988
|
export { canonicalJson } from 'stitchkit/primitives';
|
|
10977
10989
|
export { writeFileAtomic, withExclusiveLock } from 'stitchkit/files';
|
|
10978
10990
|
export { observeProcessInstance, probeProcessOwner, runNativeCommand } from 'stitchkit/process';
|
|
@@ -11034,7 +11046,7 @@ identity, live-owner refusal, dead-owner recovery and contained file operations
|
|
|
11034
11046
|
with the packaging plugin, and check that an unpackaged build reports the backend `unavailable`
|
|
11035
11047
|
with stage `packaging` rather than certifying a dead owner. Bun and Node package imports retain the same
|
|
11036
11048
|
lazy loader; importing a portable leaf does not load a Darwin addon on another OS. Test
|
|
11037
|
-
declarations too, and check that importing an unbundled
|
|
11049
|
+
declarations too, and check that importing an unbundled StitchKit leaf fails in a deliberately
|
|
11038
11050
|
isolated library distribution. A separate schema-only entry must not import the native entry.
|
|
11039
11051
|
|
|
11040
11052
|
If the Darwin backend cannot load, `observeProcessInstance` still returns `unavailable`.
|
|
@@ -11048,20 +11060,20 @@ failures or turn unavailable identity into proof that an owner is dead. If a run
|
|
|
11048
11060
|
no recognized native error code, the stage stays `load`; the loader never infers errno from text.
|
|
11049
11061
|
|
|
11050
11062
|
This delivery removes a runtime kernel installation; it does not remove the build-time
|
|
11051
|
-
|
|
11063
|
+
StitchKit installation or create an independent lightweight npm package.
|
|
11052
11064
|
|
|
11053
11065
|
## Public native packaging
|
|
11054
11066
|
|
|
11055
11067
|
Custom archives and installers use `stitchkit/files/packaging` at **build time**.
|
|
11056
11068
|
`createNativePackaging` resolves the installed version and target addon, reads the addon once and
|
|
11057
|
-
checks it against the size and SHA256 that
|
|
11069
|
+
checks it against the size and SHA256 that StitchKit published in its `native-assets.json` when the
|
|
11058
11070
|
package was built. A ready asset carries those verified `bytes` with the published `size` and
|
|
11059
11071
|
`sha256`; its Bun-compatible plugin integrates the same bytes with the same lazy native loader.
|
|
11060
11072
|
Each call reads and hashes the selected addons, so call it once per build and reuse the result.
|
|
11061
11073
|
The leaf is evolving. It requires no optional peer or Bun ambient declarations for Node imports.
|
|
11062
11074
|
Calling it must happen in a process that runs it from its installed package: it locates the
|
|
11063
11075
|
package's `native-assets.json` beside its own file and throws `Native packaging must run from its
|
|
11064
|
-
installed
|
|
11076
|
+
installed StitchKit package` anywhere else, such as inside an application's runtime artifact.
|
|
11065
11077
|
Importing the leaf is side-effect free (it loads no addon and reads no file), so a module that
|
|
11066
11078
|
both builds and is bundled may import it; only the call has to stay in the build step.
|
|
11067
11079
|
|
|
@@ -11108,7 +11120,7 @@ second time. An installed addon whose size or SHA256 differs from the published
|
|
|
11108
11120
|
with `mismatch` / `NATIVE_ASSET_DIGEST_MISMATCH`, so a file substituted after installation never
|
|
11109
11121
|
reaches an artifact. Archive the complete output directory with an integrity manifest that records
|
|
11110
11122
|
`asset.sha256`, unpack to a clean directory, verify the same hashes there, and run offline without
|
|
11111
|
-
the build tree or `node_modules`. The published digest ties the bytes to the package
|
|
11123
|
+
the build tree or `node_modules`. The published digest ties the bytes to the package StitchKit
|
|
11112
11124
|
built; the package itself is only as trusted as its tarball (the lockfile integrity of the install).
|
|
11113
11125
|
Signature and trust policy remain application-owned.
|
|
11114
11126
|
|
|
@@ -11436,7 +11448,7 @@ an immutable branded value; `transition()` produces the next one. `availableTran
|
|
|
11436
11448
|
|
|
11437
11449
|
`defineOwnerScope` resolves one owner from authenticated identity. Reading across owners is a
|
|
11438
11450
|
separate `acrossAllOwners(identity)` call and permission. Pass the resulting branded `OwnerScope`
|
|
11439
|
-
to the data adapter. This proves the scope was explicit;
|
|
11451
|
+
to the data adapter. This proves the scope was explicit; StitchKit cannot prove what SQL an
|
|
11440
11452
|
arbitrary adapter emits. `scanOwnerFilterRisks` maps existing caller-named manual filters before a
|
|
11441
11453
|
migration.
|
|
11442
11454
|
|
|
@@ -11595,7 +11607,7 @@ only through `stitchkit/application` exports.
|
|
|
11595
11607
|
## Database connection
|
|
11596
11608
|
|
|
11597
11609
|
Wrap connection allocation and readiness in `start`, and make `close` safe after
|
|
11598
|
-
partial setup.
|
|
11610
|
+
partial setup. StitchKit invokes cleanup for every attempted start, including a
|
|
11599
11611
|
start that allocates a client and then rejects.
|
|
11600
11612
|
|
|
11601
11613
|
```ts
|
|
@@ -11618,7 +11630,7 @@ allocation and proves one rollback close.
|
|
|
11618
11630
|
|
|
11619
11631
|
An application-owned client is an ordinary managed resource. Keep SDK creation,
|
|
11620
11632
|
credentials, authorization and reconnect policy in the application; no Telegram
|
|
11621
|
-
client SDK is required by
|
|
11633
|
+
client SDK is required by StitchKit. Create a fresh client inside each `start`,
|
|
11622
11634
|
publish it after connection/readiness succeeds, and share one memoized destroy
|
|
11623
11635
|
promise between partial-start cleanup, `close` and `force`:
|
|
11624
11636
|
|
|
@@ -11784,7 +11796,7 @@ async function handleDelivery(delivery: Delivery) {
|
|
|
11784
11796
|
}
|
|
11785
11797
|
```
|
|
11786
11798
|
|
|
11787
|
-
|
|
11799
|
+
StitchKit owns only process-local admission accounting and drain. Durable claims,
|
|
11788
11800
|
visibility timeouts, deduplication, idempotency and retry classification remain
|
|
11789
11801
|
in the queue/product layer.
|
|
11790
11802
|
|
|
@@ -11813,7 +11825,7 @@ await publisher.close()
|
|
|
11813
11825
|
```
|
|
11814
11826
|
|
|
11815
11827
|
The monitoring backend, transport retry and cross-process aggregation remain
|
|
11816
|
-
outside
|
|
11828
|
+
outside StitchKit. The executable recipe blocks revision 0, coalesces
|
|
11817
11829
|
intermediate revisions, explicitly admits the final absolute snapshot after
|
|
11818
11830
|
unsubscribe and proves that `close()` flushes revision 3. Do not rely on an
|
|
11819
11831
|
asynchronous subscriber callback racing cleanup: publish `getSnapshot()` before
|
|
@@ -12063,7 +12075,7 @@ await createCli({
|
|
|
12063
12075
|
```
|
|
12064
12076
|
|
|
12065
12077
|
`createCli({ signal })` and its wait loop honor an explicit caller
|
|
12066
|
-
`AbortSignal`.
|
|
12078
|
+
`AbortSignal`. StitchKit does not install a process-global SIGINT handler for
|
|
12067
12079
|
ordinary CLI programs: if desired, the application binds SIGINT to an
|
|
12068
12080
|
`AbortController` and passes its signal. Aborting wait stops polling only; it
|
|
12069
12081
|
does not cancel the underlying job.
|
|
@@ -12164,7 +12176,7 @@ const doctor = defineCliCommand({
|
|
|
12164
12176
|
})
|
|
12165
12177
|
```
|
|
12166
12178
|
|
|
12167
|
-
`present` returns the exact stdout bytes, which
|
|
12179
|
+
`present` returns the exact stdout bytes, which StitchKit writes once. Without
|
|
12168
12180
|
it the canonical JSON output is unchanged. `exitCode` classifies a successfully
|
|
12169
12181
|
validated result and must return an integer in `0..255`; failed `ToolResult`
|
|
12170
12182
|
envelopes and the application-wide `exitCodes` mapping remain authoritative for
|
|
@@ -12903,7 +12915,7 @@ on stdout. A native `defineCliCommand` declares none of those facts, so a failed
|
|
|
12903
12915
|
|
|
12904
12916
|
A CLI that mounts a server's tools through `defineMcpClientConnection` never sees the
|
|
12905
12917
|
method or contract `effect` — every MCP call is a `POST` — so it reads the `readOnlyHint`
|
|
12906
|
-
the server publishes. A
|
|
12918
|
+
the server publishes. A StitchKit server publishes it for every repeatable read by the
|
|
12907
12919
|
rule above ([MCP → `readOnlyHint`](./mcp-and-agents.md#saying-which-tools-only-read--readonlyhint)),
|
|
12908
12920
|
so the same command behaves the same over the contract and over MCP. The hint is the
|
|
12909
12921
|
server's word: a server that labels a write as read-only makes the CLI withhold that
|
|
@@ -13517,7 +13529,7 @@ counts raw UTF-8 body bytes, including SSE framing, regardless of `Content-Lengt
|
|
|
13517
13529
|
Pending legacy calls also count comments and wrong-id frames. `budget.maxTools`
|
|
13518
13530
|
and `budget.maxSchemaBytes` remain separate mount limits.
|
|
13519
13531
|
|
|
13520
|
-
**A stored catalog is mounted while it is current.** A
|
|
13532
|
+
**A stored catalog is mounted while it is current.** A StitchKit server sends its
|
|
13521
13533
|
[catalog stamp](./mcp-and-agents.md#knowing-your-catalog-is-stale--the-catalog-stamp) with
|
|
13522
13534
|
the `initialize` answer, as the `stitchkit-catalog` response header. Given a `catalog:
|
|
13523
13535
|
{ load, store }`, the connection compares it with the stamp of the stored `tools/list`
|
|
@@ -13528,7 +13540,7 @@ stores again. A listing is stored only when every tool in it carries the stamp t
|
|
|
13528
13540
|
`initialize` answer announced, so a rolling deploy answering the two requests from
|
|
13529
13541
|
different builds stores nothing. A server without a stamp, a surface with raw SDK tools
|
|
13530
13542
|
and a failing `load` or `store` all cost one `tools/list`, never the mount. The stamp
|
|
13531
|
-
covers what `tools/list` publishes as
|
|
13543
|
+
covers what `tools/list` publishes as StitchKit builds it; the JSON Schema text the
|
|
13532
13544
|
server's MCP SDK renders from the same schema is not hashed separately.
|
|
13533
13545
|
|
|
13534
13546
|
Only the initial `initialize` can negotiate HTTP-to-legacy fallback on 400, 404
|
|
@@ -13665,11 +13677,32 @@ A native-only CLI (only `commands`, no `services` or `runtimeTools`) takes no
|
|
|
13665
13677
|
|
|
13666
13678
|
## Typed context
|
|
13667
13679
|
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13680
|
+
For a peer-free CLI, import `createCli` directly from `stitchkit/cli` and
|
|
13681
|
+
annotate the `context` factory's return type against your app's context shape
|
|
13682
|
+
— no optional peers are loaded:
|
|
13671
13683
|
|
|
13672
13684
|
```ts
|
|
13685
|
+
import { createCli } from 'stitchkit/cli'
|
|
13686
|
+
|
|
13687
|
+
await createCli({
|
|
13688
|
+
name: 'myapp',
|
|
13689
|
+
version: '1.0.0',
|
|
13690
|
+
services,
|
|
13691
|
+
access: { gate: { beforeHandle: authHook } },
|
|
13692
|
+
context: (identity): { user: User | undefined } => ({ user: identity }),
|
|
13693
|
+
})
|
|
13694
|
+
```
|
|
13695
|
+
|
|
13696
|
+
If your application already installs both `@modelcontextprotocol/server` and
|
|
13697
|
+
`ai` and mounts MCP, AI SDK `mountAgent`, and CLI surfaces together, you can
|
|
13698
|
+
also pin the shared context type once via `createToolkit<AppContext>()` from
|
|
13699
|
+
`stitchkit/tools/toolkit` — the tool-side mirror of `createImplement`
|
|
13700
|
+
([ADR 0017](../decisions/0017-typed-tool-context.md),
|
|
13701
|
+
[ADR 0284](../decisions/0284-the-tools-barrel-loads-no-optional-peer.md)):
|
|
13702
|
+
|
|
13703
|
+
```ts
|
|
13704
|
+
import { createToolkit } from 'stitchkit/tools/toolkit'
|
|
13705
|
+
|
|
13673
13706
|
const tools = createToolkit<{ user: User }>()
|
|
13674
13707
|
await tools.createCli({
|
|
13675
13708
|
name: 'myapp',
|
|
@@ -13786,7 +13819,7 @@ try {
|
|
|
13786
13819
|
```
|
|
13787
13820
|
|
|
13788
13821
|
`path` is `'0.v'` and not `'v'` because event arguments are a tuple: index `0`
|
|
13789
|
-
is the first payload. The issues are already flattened by
|
|
13822
|
+
is the first payload. The issues are already flattened by StitchKit's own
|
|
13790
13823
|
normaliser, so telling "wrong generation" from "malformed payload" is one
|
|
13791
13824
|
comparison rather than an inspection of a `ZodError`'s internals.
|
|
13792
13825
|
|
|
@@ -13821,7 +13854,7 @@ The client sends it as `auth`, and a rejection reaches `onConnectError` with
|
|
|
13821
13854
|
deployment reads as a half-rolled deployment and not as an access problem.
|
|
13822
13855
|
|
|
13823
13856
|
What that identity *is* remains the application's decision — a build version, a
|
|
13824
|
-
contract hash, a protocol generation.
|
|
13857
|
+
contract hash, a protocol generation. StitchKit does not compare it for you
|
|
13825
13858
|
(→ ADR 0002); it gives the place where the comparison happens before any frame
|
|
13826
13859
|
is interpreted, and it makes the per-frame alternative honest by letting its
|
|
13827
13860
|
refusals be seen.
|
|
@@ -13945,7 +13978,7 @@ socket.on('note:created', (note) => { /* typed note */ })
|
|
|
13945
13978
|
socket.emit('room:join', 'general', ({ joined }) => { /* typed + validated */ })
|
|
13946
13979
|
```
|
|
13947
13980
|
|
|
13948
|
-
When an application already owns the low-level
|
|
13981
|
+
When an application already owns the low-level StitchKit transport, bind the
|
|
13949
13982
|
contract without opening a second connection:
|
|
13950
13983
|
|
|
13951
13984
|
```ts
|
|
@@ -14111,7 +14144,7 @@ classification detects duplicates—those are different policies.
|
|
|
14111
14144
|
|
|
14112
14145
|
A server process that owns such a receiver can place `start()` and `close()` in
|
|
14113
14146
|
an existing `defineManagedResource` and include it in `createApplication`.
|
|
14114
|
-
Readiness follows a successful `live` snapshot; shutdown calls `close()`.
|
|
14147
|
+
Readiness follows a successful `live` snapshot; shutdown calls `close()`. StitchKit
|
|
14115
14148
|
does not add another supervisor, reconnect loop or durable event database.
|
|
14116
14149
|
|
|
14117
14150
|
When migrating a hand-written receiver, remove only the superseded attach/snapshot
|
|
@@ -14182,7 +14215,7 @@ closed phase:
|
|
|
14182
14215
|
|-------|----------------------|
|
|
14183
14216
|
| `engine-handoff` | Engine.IO created the outbound message packet and accepted it into its write path |
|
|
14184
14217
|
| `engine-ack-received` | Engine.IO decoded the inbound acknowledgement message, before Socket.IO invokes the acknowledgement callback |
|
|
14185
|
-
| `settled` | the acknowledgement callback ran and
|
|
14218
|
+
| `settled` | the acknowledgement callback ran and StitchKit finished acknowledgement validation |
|
|
14186
14219
|
| `timeout` | the existing native acknowledgement timeout won |
|
|
14187
14220
|
| `disconnected` | the request began disconnected or an in-flight disconnect won |
|
|
14188
14221
|
|
|
@@ -14204,7 +14237,7 @@ await socket.request('room:join', 'general', {
|
|
|
14204
14237
|
|
|
14205
14238
|
The client-wide hook receives every observed request; a request hook receives
|
|
14206
14239
|
only its invocation. If the same function is supplied in both places it runs
|
|
14207
|
-
once per phase. The closure is local:
|
|
14240
|
+
once per phase. The closure is local: StitchKit does not retain `operationId`,
|
|
14208
14241
|
add it to the event or transmit it to the peer. A request hook works without a
|
|
14209
14242
|
client-wide hook, and the no-hook path installs no phase listeners.
|
|
14210
14243
|
|
|
@@ -14590,7 +14623,7 @@ question: a list takes one of them, and `createEntityCacheHandlers` refuses both
|
|
|
14590
14623
|
|
|
14591
14624
|
The helper deliberately does **not** flatten pages, infer filter semantics,
|
|
14592
14625
|
derive a sort order or replace arbitrary `setQueryData` logic. Those remain
|
|
14593
|
-
declared application policies;
|
|
14626
|
+
declared application policies; StitchKit applies their generic cache mechanics.
|
|
14594
14627
|
|
|
14595
14628
|
## Raw binary lane (Bun)
|
|
14596
14629
|
|
|
@@ -14965,7 +14998,7 @@ is where the full name is *built*, not a second name for the same topic.
|
|
|
14965
14998
|
### The wire is the socket you already run
|
|
14966
14999
|
|
|
14967
15000
|
`toRealtimeContract` projects the declaration onto `RealtimeContract`. Everything
|
|
14968
|
-
after that is the machinery
|
|
15001
|
+
after that is the machinery StitchKit already ships — validation both ways,
|
|
14969
15002
|
rejection reporting, rooms, and the client's `retain:` replay.
|
|
14970
15003
|
|
|
14971
15004
|
```ts
|
|
@@ -15413,7 +15446,7 @@ The framework attaches no meaning to the strings — `'public'`, `'user'`,
|
|
|
15413
15446
|
## `createAuthHook`
|
|
15414
15447
|
|
|
15415
15448
|
`createAuthHook` builds one scope gate that can run in both HTTP and tool
|
|
15416
|
-
lifecycles. On HTTP it belongs in `hooks.authorize`:
|
|
15449
|
+
lifecycles. On HTTP it belongs in `hooks.authorize`: StitchKit validates path
|
|
15417
15450
|
params, resolves identity and scope, and rejects `401`/`403` **before reading a
|
|
15418
15451
|
JSON or multipart body**. On MCP, agent and CLI surfaces it belongs in
|
|
15419
15452
|
`access.gate.beforeHandle` (`access: { gate: { beforeHandle: authHook } }`),
|
|
@@ -15600,7 +15633,7 @@ export const implementFor = createScopedImplement<AuthScopes<typeof auth>>()
|
|
|
15600
15633
|
|
|
15601
15634
|
Only hooks that declare the selected scope run. An unknown scope fails closed;
|
|
15602
15635
|
when several hooks own one scope, every owner must pass in declaration order.
|
|
15603
|
-
Each owner evaluates on an isolated shadow context.
|
|
15636
|
+
Each owner evaluates on an isolated shadow context. StitchKit validates all
|
|
15604
15637
|
changed fields, rejects reserved/unsafe fields and cross-owner key collisions,
|
|
15605
15638
|
then commits the combined contribution once. A rejected or cancelled composite
|
|
15606
15639
|
therefore exposes no partial fields to the handler.
|
|
@@ -15851,7 +15884,7 @@ complete: async ({ response }) => {
|
|
|
15851
15884
|
}
|
|
15852
15885
|
```
|
|
15853
15886
|
|
|
15854
|
-
Append once per cookie;
|
|
15887
|
+
Append once per cookie; StitchKit preserves separate `Set-Cookie` fields through
|
|
15855
15888
|
both Bun and Node. Cookie/session policy remains application logic.
|
|
15856
15889
|
|
|
15857
15890
|
## The error model
|
|
@@ -16005,7 +16038,7 @@ onError: (ctx, err) => {
|
|
|
16005
16038
|
|
|
16006
16039
|
## One application vocabulary and one wire map
|
|
16007
16040
|
|
|
16008
|
-
`defineErrors` can also resolve
|
|
16041
|
+
`defineErrors` can also resolve StitchKit's framework codes into the same
|
|
16009
16042
|
application vocabulary. A status fallback is explicit because several
|
|
16010
16043
|
application codes may legally share one HTTP status:
|
|
16011
16044
|
|
|
@@ -16097,7 +16130,7 @@ retained on the returned `AppError`.
|
|
|
16097
16130
|
HTTP renders the complete code/status/message/details/hint. Tool transports keep
|
|
16098
16131
|
their established model-facing projection (code/details/hint, without HTTP
|
|
16099
16132
|
status), while `invokeOrThrow` recovers the exact normalized `AppError`. The
|
|
16100
|
-
codes and schemas remain application-owned;
|
|
16133
|
+
codes and schemas remain application-owned; StitchKit stays domain-free.
|
|
16101
16134
|
|
|
16102
16135
|
### The codes an operation refuses with
|
|
16103
16136
|
|
|
@@ -16184,7 +16217,7 @@ stitchkit code you did not list travels as itself. Set `unmappedCode` to one
|
|
|
16184
16217
|
wire-code when your public vocabulary has a catch-all, or to a function such as
|
|
16185
16218
|
`(code) => code.startsWith('FILE_') ? 'storage_error' : 'framework_error'` when
|
|
16186
16219
|
framework code families need different buckets. An explicit `codeMap` entry
|
|
16187
|
-
always wins. Codes your project throws itself do not belong to
|
|
16220
|
+
always wins. Codes your project throws itself do not belong to StitchKit's
|
|
16188
16221
|
vocabulary, so they never pass through this fallback and remain unchanged.
|
|
16189
16222
|
|
|
16190
16223
|
One `satisfies` is the **opt-in** to the stricter deal:
|
|
@@ -16246,7 +16279,7 @@ onError: (ctx, err) => {
|
|
|
16246
16279
|
|
|
16247
16280
|
# Browser OAuth and Google OIDC
|
|
16248
16281
|
|
|
16249
|
-
|
|
16282
|
+
StitchKit separates the browser's Authorization Code + PKCE transaction from the server's
|
|
16250
16283
|
provider credential verification. The application still owns navigation, users, account matching
|
|
16251
16284
|
and merge policy, persistence, sessions, roles, unlink policy and UI.
|
|
16252
16285
|
|
|
@@ -16254,13 +16287,13 @@ and merge policy, persistence, sessions, roles, unlink policy and UI.
|
|
|
16254
16287
|
|
|
16255
16288
|
The current Google adapter supports one explicit profile: **web OpenID Connect Authorization Code
|
|
16256
16289
|
with PKCE**. A browser performs a top-level redirect, an application backend exchanges the
|
|
16257
|
-
one-time code, and
|
|
16290
|
+
one-time code, and StitchKit returns a verified identity. It is the redirect-based sign-in path;
|
|
16258
16291
|
it is not a generic name for every Google identity or authorization mechanism.
|
|
16259
16292
|
|
|
16260
16293
|
Keep adjacent Google capabilities separate because their credentials, lifecycle and trust
|
|
16261
16294
|
boundaries differ:
|
|
16262
16295
|
|
|
16263
|
-
| Capability | Credential/result |
|
|
16296
|
+
| Capability | Credential/result | StitchKit support |
|
|
16264
16297
|
| --- | --- | --- |
|
|
16265
16298
|
| Web OIDC Authorization Code + PKCE | verified user identity | `stitchkit/oauth` + `stitchkit/google` |
|
|
16266
16299
|
| Google Identity Services button, One Tap or FedCM | browser-delivered ID credential | not implemented |
|
|
@@ -16342,7 +16375,7 @@ const identity = await google.exchangeAuthorizationCode({
|
|
|
16342
16375
|
|
|
16343
16376
|
The redirect must match the immutable allowlist exactly before any outbound call. The token
|
|
16344
16377
|
exchange is bounded by an abort deadline; `google-auth-library` verifies the ID-token signature,
|
|
16345
|
-
issuer, audience and expiry.
|
|
16378
|
+
issuer, audience and expiry. StitchKit additionally requires `sub`, a valid verified email and an
|
|
16346
16379
|
exact nonce. Access, refresh and raw ID tokens never leave the adapter.
|
|
16347
16380
|
|
|
16348
16381
|
`GoogleOidcError.code` distinguishes `MISCONFIGURED`, `INVALID_CREDENTIAL` and
|
|
@@ -16571,7 +16604,7 @@ bound observes the same drain under its own limit rather than starting another.
|
|
|
16571
16604
|
Passing no bound keeps the previous behaviour exactly, including the identical
|
|
16572
16605
|
returned promise.
|
|
16573
16606
|
|
|
16574
|
-
|
|
16607
|
+
StitchKit manages only in-process delivery. If process-crash durability matters,
|
|
16575
16608
|
make `write` enqueue into a consumer-owned durable outbox and let that adapter
|
|
16576
16609
|
own retry, replay and storage policy:
|
|
16577
16610
|
|
|
@@ -16859,7 +16892,7 @@ locally; you do not need to change `NODE_ENV` or deploy.
|
|
|
16859
16892
|
Every response the stitchkit handler produces carries the resolved id as
|
|
16860
16893
|
**`x-request-id`**. With `cors` configured it is in the default
|
|
16861
16894
|
`Access-Control-Expose-Headers`, so a browser client can read it and quote it in
|
|
16862
|
-
a bug report.
|
|
16895
|
+
a bug report. StitchKit browser clients retain it as `ApiError.traceId` on
|
|
16863
16896
|
response-backed failures. Note the deliberate asymmetry: inbound the id may arrive as
|
|
16864
16897
|
`X-Trace-Id` *or* `X-Request-Id`; outbound there is one name and no alias.
|
|
16865
16898
|
|
|
@@ -16911,7 +16944,7 @@ cross-origin `trace: true` client works out of the box. If you set a custom
|
|
|
16911
16944
|
the preflight will reject the trace header.
|
|
16912
16945
|
|
|
16913
16946
|
MCP tools use the same context. On a modern HTTP or stdio `tools/call`, the
|
|
16914
|
-
official SDK exposes W3C propagation values from request `_meta`;
|
|
16947
|
+
official SDK exposes W3C propagation values from request `_meta`; StitchKit
|
|
16915
16948
|
continues a valid `_meta.traceparent` before validation, lifecycle and hooks.
|
|
16916
16949
|
If MCP metadata omits `traceparent`, an HTTP call keeps its ambient HTTP trace
|
|
16917
16950
|
and a stdio call starts a new root. If the key is present but malformed or
|
|
@@ -17707,7 +17740,7 @@ of defect stays invisible in development.
|
|
|
17707
17740
|
|
|
17708
17741
|
### Shipping one self-contained artifact
|
|
17709
17742
|
|
|
17710
|
-
|
|
17743
|
+
StitchKit resolves the optional Socket.IO peers through a variable, so a
|
|
17711
17744
|
consumer bundling an unrelated `stitchkit/server` export never has to resolve
|
|
17712
17745
|
them. A bundler cannot follow that, which matters if you ship **one file** to a
|
|
17713
17746
|
machine with no `node_modules`: the package never enters the artifact and the
|
|
@@ -17730,7 +17763,7 @@ const socket = await createSocketIOServer({
|
|
|
17730
17763
|
|
|
17731
17764
|
The packed Next/Webpack gate compiles the browser
|
|
17732
17765
|
`peers.client: () => import('socket.io-client')` loader and rejects Webpack's
|
|
17733
|
-
"request is an expression" warning.
|
|
17766
|
+
"request is an expression" warning. StitchKit's runtime fallback remains lazy;
|
|
17734
17767
|
its emitted import carries a count-checked ignore directive.
|
|
17735
17768
|
|
|
17736
17769
|
Omit `peers` and nothing changes: the peers stay lazy and are resolved from the
|
|
@@ -17941,7 +17974,7 @@ await binding.promise
|
|
|
17941
17974
|
|
|
17942
17975
|
The first signal starts exactly one close chain. A same-turn duplicate is
|
|
17943
17976
|
ignored; a later signal restores the default OS disposition because the
|
|
17944
|
-
official stdio close is not abortable and
|
|
17977
|
+
official stdio close is not abortable and StitchKit will not pretend otherwise.
|
|
17945
17978
|
`binding.close()` removes idle listeners and resolves the promise with
|
|
17946
17979
|
`undefined`. No listener is installed until the binder is called, and the
|
|
17947
17980
|
framework never calls `process.exit()`.
|
|
@@ -18004,7 +18037,7 @@ stitchkit serves the API. A SPA front-end is built and hosted separately — a
|
|
|
18004
18037
|
static host or CDN in production, its own dev server in development. The backend
|
|
18005
18038
|
does not serve static files (`staticRoute` exists for the occasional asset, not
|
|
18006
18039
|
a whole app). `bun create stitchkit my-app` demonstrates the supported split:
|
|
18007
|
-
an independently built Next.js frontend and Bun/
|
|
18040
|
+
an independently built Next.js frontend and Bun/StitchKit API.
|
|
18008
18041
|
|
|
18009
18042
|
### MCP
|
|
18010
18043
|
|
|
@@ -18160,12 +18193,12 @@ per-transport tenant plumbing.
|
|
|
18160
18193
|
# Frontend integrations
|
|
18161
18194
|
|
|
18162
18195
|
The official `bun create stitchkit` application uses Next.js with a separate
|
|
18163
|
-
Bun API.
|
|
18196
|
+
Bun API. StitchKit remains a Fetch-native backend and does not own frontend
|
|
18164
18197
|
routing, SSR or HMR.
|
|
18165
18198
|
|
|
18166
18199
|
## Theme boundary in the official starter
|
|
18167
18200
|
|
|
18168
|
-
The generated Next.js application uses `@wrksz/themes`, not a
|
|
18201
|
+
The generated Next.js application uses `@wrksz/themes`, not a StitchKit-owned
|
|
18169
18202
|
theme abstraction. Its root `ThemeProvider` comes from `@wrksz/themes/next` and
|
|
18170
18203
|
lives directly in the server layout so Next 16 can inject the first-paint script
|
|
18171
18204
|
through `useServerInsertedHTML`. The default `hybrid` storage reads a cookie
|
|
@@ -18205,10 +18238,10 @@ export async function action({ request }: ActionFunctionArgs) {
|
|
|
18205
18238
|
|
|
18206
18239
|
## Vite
|
|
18207
18240
|
|
|
18208
|
-
Run Vite and the
|
|
18241
|
+
Run Vite and the StitchKit API as separate development processes. Declare one
|
|
18209
18242
|
proxy for `/api`, `/mcp` and `/socket.io`; browser code still calls the typed
|
|
18210
18243
|
client with same-origin paths. Production serves the static Vite output from a
|
|
18211
|
-
static host or reverse proxy and routes those backend paths to
|
|
18244
|
+
static host or reverse proxy and routes those backend paths to StitchKit.
|
|
18212
18245
|
|
|
18213
18246
|
Do not duplicate DTOs or handwritten API wrappers in either integration. The
|
|
18214
18247
|
shared contract remains the only transport schema source.
|
|
@@ -19432,7 +19465,7 @@ of git.
|
|
|
19432
19465
|
### Injecting another transport's failure policy
|
|
19433
19466
|
|
|
19434
19467
|
`classify(error)` returns the public `TelegramBroadcastFailure` union. It lets
|
|
19435
|
-
an application use its own client without adding that SDK to
|
|
19468
|
+
an application use its own client without adding that SDK to StitchKit:
|
|
19436
19469
|
|
|
19437
19470
|
```ts
|
|
19438
19471
|
const report = await runTelegramBroadcast({
|
|
@@ -20446,7 +20479,7 @@ The previous reader closes only after its in-flight lookups finish.
|
|
|
20446
20479
|
|
|
20447
20480
|
Use `GeoIpReaderLoader` when the database is not MaxMind-compatible. `revision`
|
|
20448
20481
|
must identify the complete input generation and return `null` when it cannot be
|
|
20449
|
-
read. `open` returns a reader for exactly that revision.
|
|
20482
|
+
read. `open` returns a reader for exactly that revision. StitchKit serializes
|
|
20450
20483
|
reloads, swaps generations and owns their close lifecycle.
|
|
20451
20484
|
|
|
20452
20485
|
Download schedules, licenses, database paths, attribution persistence and
|
|
@@ -20602,7 +20635,13 @@ const runtime = createAgentRuntime({
|
|
|
20602
20635
|
- `anthropicProvider` from `stitchkit/agent-runtime/anthropic`
|
|
20603
20636
|
2. Replace `fromAiSdkTools(mountAgent(...))` with `mountAgentTools(...)` from `stitchkit/tools`, and replace custom AI SDK `tool(...)` declarations with `defineAgentTool(...)` from `stitchkit/tools`.
|
|
20604
20637
|
3. Replace direct `generateText` / `generateObject` helper calls with `completeText` / `completeObject` from `stitchkit/agent-runtime`, and replace `wrapLanguageModel` middleware with `wrapModelDriver` / `composeModelDrivers`.
|
|
20605
|
-
4.
|
|
20638
|
+
4. Check for every remaining `ai`-requiring `stitchkit` entrypoint — `stitchkit/tools/agent`, `stitchkit/tools/toolkit`, and `stitchkit/agent-runtime/ai-sdk` — before removing `ai` and `@openrouter/ai-sdk-provider` from `package.json`:
|
|
20639
|
+
- `stitchkit/tools/toolkit` (`createToolkit`) deliberately requires **both** `@modelcontextprotocol/server` and `ai` because it composes the MCP server factories and AI SDK `mountAgent` together (ADR 0284). Keeping a `stitchkit/tools/toolkit` import after removing `ai` fails clean installs and bundling (`Could not resolve: "ai"`).
|
|
20640
|
+
- If you used `createToolkit<AppContext>()` without AI SDK `mountAgent`, replace it with the narrow entrypoints directly:
|
|
20641
|
+
- MCP servers (`createMcpHandler`, `buildMcpServer`, `mountMcp`, `createStdioMcpServer`) → import from `stitchkit/tools/mcp` (requires only `@modelcontextprotocol/server`) and annotate the `context` factory return type (`context: (auth): AppContext => ({ ... })`).
|
|
20642
|
+
- Peer-free agent tools (`mountAgentTools`, `defineAgentTool`) → import from `stitchkit/tools` (zero optional peers).
|
|
20643
|
+
- CLI (`createCli`, `createCliInvoker`) → import from `stitchkit/cli` (zero optional peers; annotate `context: (auth): AppContext => ({ ... })`).
|
|
20644
|
+
- Once no imports of `stitchkit/tools/agent`, `stitchkit/tools/toolkit`, or `stitchkit/agent-runtime/ai-sdk` remain (`rg "stitchkit/(tools/agent|tools/toolkit|agent-runtime/ai-sdk)" .`), remove `ai` and `@openrouter/ai-sdk-provider` from `package.json`.
|
|
20606
20645
|
|
|
20607
20646
|
```ts
|
|
20608
20647
|
// After (Step 2: completely peer-free)
|
|
@@ -22725,7 +22764,7 @@ succeeds, its result stays on stdout, stderr names the refusal and the exit is n
|
|
|
22725
22764
|
A JS bundle uses `delivery: 'companion'`; every shape is in the [native I/O guide](./native-io.md). Search pattern:
|
|
22726
22765
|
`createCli` with a `download` option in a project that runs `bun build` for macOS.
|
|
22727
22766
|
2. On Windows, run the download through Linux or macOS, or read the URLs from the operation's
|
|
22728
|
-
JSON result and fetch them yourself.
|
|
22767
|
+
JSON result and fetch them yourself. StitchKit offers no weaker path on that platform.
|
|
22729
22768
|
3. A download now replaces a file rather than rewriting it. Give the process write permission on
|
|
22730
22769
|
the output directory, and do not point it at a bind-mounted file: that refuses with `EBUSY`. A
|
|
22731
22770
|
replaced file belongs to the process user, and a read-only file is replaced like any other.
|
|
@@ -23147,7 +23186,7 @@ pipes drain.
|
|
|
23147
23186
|
read `asset.sourcePath`, hash the addon themselves, switch over the refusal `state`/`code`, pass a
|
|
23148
23187
|
`platform` other than the literal `'darwin'`, or parse `node_modules/stitchkit/native-assets.json`.
|
|
23149
23188
|
|
|
23150
|
-
The package now publishes the `size` and SHA256 of each Darwin addon, computed when
|
|
23189
|
+
The package now publishes the `size` and SHA256 of each Darwin addon, computed when StitchKit is
|
|
23151
23190
|
built, in `native-assets.json` at `formatVersion: 2`. `createNativePackaging` reads each selected
|
|
23152
23191
|
addon once, compares it with that digest and returns the verified bytes. An installed addon that
|
|
23153
23192
|
differs refuses with `NATIVE_ASSET_DIGEST_MISMATCH`.
|
|
@@ -24422,7 +24461,7 @@ If you operate a built-in SQLite store file:
|
|
|
24422
24461
|
|
|
24423
24462
|
1. Back the file up. The first open by 0.86.0 migrates it to schema 2 in one
|
|
24424
24463
|
transaction and there is no way back: a 0.85.x package refuses a migrated
|
|
24425
|
-
file with `Unsupported
|
|
24464
|
+
file with `Unsupported StitchKit agent-runtime SQLite schema version 2`.
|
|
24426
24465
|
2. Check the build for FTS5 before deploying:
|
|
24427
24466
|
|
|
24428
24467
|
```sql
|
|
@@ -26641,7 +26680,7 @@ runtime callback arguments; only `.withOptions` reads `ClientRequestOptions`.
|
|
|
26641
26680
|
### HTTP auth moves to the pre-body `authorize` phase
|
|
26642
26681
|
|
|
26643
26682
|
Move the HTTP wiring of `createAuthHook` from `beforeHandle` to `authorize`.
|
|
26644
|
-
This lets
|
|
26683
|
+
This lets StitchKit reject an unauthorized JSON or multipart request after path
|
|
26645
26684
|
parameter validation but before reading a body chunk. Keep application
|
|
26646
26685
|
preconditions that depend on validated input in `beforeHandle`.
|
|
26647
26686
|
|
|
@@ -26784,7 +26823,7 @@ collected tool logs from stdout.
|
|
|
26784
26823
|
|
|
26785
26824
|
### MCP TypeScript SDK v2 and protocol `2026-07-28`
|
|
26786
26825
|
|
|
26787
|
-
This is a hard cut: there is one
|
|
26826
|
+
This is a hard cut: there is one StitchKit API and no v1 aliases. Applications
|
|
26788
26827
|
that expose MCP install the split server package; applications that implement an
|
|
26789
26828
|
MCP host or run client E2E install the split client package.
|
|
26790
26829
|
|
|
@@ -26860,7 +26899,7 @@ modern-only. This is not a stateful compatibility transport.
|
|
|
26860
26899
|
|
|
26861
26900
|
#### Output shape depends on the negotiated protocol era
|
|
26862
26901
|
|
|
26863
|
-
|
|
26902
|
+
StitchKit always validates the handler result against the declared output
|
|
26864
26903
|
schema. The negotiated MCP era determines only its wire representation:
|
|
26865
26904
|
|
|
26866
26905
|
| Negotiated era | Non-object `structuredContent` |
|
|
@@ -26925,7 +26964,7 @@ mountOAuthProvider({
|
|
|
26925
26964
|
A URL client id must be HTTPS and serve a document whose `client_id` exactly
|
|
26926
26965
|
matches that URL, with explicit `redirect_uris` and
|
|
26927
26966
|
`token_endpoint_auth_method: 'none'`. Do not keep a consumer-side metadata
|
|
26928
|
-
fetcher or DCR fallback;
|
|
26967
|
+
fetcher or DCR fallback; StitchKit owns SSRF-safe resolution and caching.
|
|
26929
26968
|
|
|
26930
26969
|
Multi-round input is opt-in on the operation and does not change Agent, CLI or
|
|
26931
26970
|
ordinary HTTP handlers:
|
|
@@ -27045,7 +27084,7 @@ summarizeTransports(surface)
|
|
|
27045
27084
|
`ToolNameEntry` adds `kind: 'contract' | 'runtime'`. `TransportSummary` is now
|
|
27046
27085
|
`{ contractServices, runtimeTools, totals, sources }`; replace `services` and
|
|
27047
27086
|
`perService` reads with the explicit counts and mixed-source breakdown. There
|
|
27048
|
-
is no positional overload and no `buildRuntimeToolManifest`:
|
|
27087
|
+
is no positional overload and no `buildRuntimeToolManifest`: StitchKit owns the
|
|
27049
27088
|
combined order, transport filtering, canonical presentation schema and
|
|
27050
27089
|
cross-origin collision checks.
|
|
27051
27090
|
|
|
@@ -27113,7 +27152,7 @@ createMcpHandler({
|
|
|
27113
27152
|
```
|
|
27114
27153
|
|
|
27115
27154
|
Keep direct `services(auth)` / `runtimeTools(auth)` only for genuinely
|
|
27116
|
-
unbounded definitions;
|
|
27155
|
+
unbounded definitions; StitchKit intentionally does not cache arbitrary auth
|
|
27117
27156
|
values.
|
|
27118
27157
|
|
|
27119
27158
|
Contract success bodies are now determined by the presence of `output`, not by
|
|
@@ -27286,7 +27325,7 @@ mountable.argumentSchema // executable CLI argument adapter only
|
|
|
27286
27325
|
|
|
27287
27326
|
Contract and native handlers keep their original Zod schemas; MCP and agent SDK
|
|
27288
27327
|
adapters now forward raw arguments so defaults, coercions, refinements and
|
|
27289
|
-
transforms execute exactly once inside
|
|
27328
|
+
transforms execute exactly once inside StitchKit. There are no compatibility
|
|
27290
27329
|
exports for `flattenDiscriminatedUnion`, `flattenUnionsDeep` or
|
|
27291
27330
|
`MountableTool.schema`. → ADR 0050
|
|
27292
27331
|
|
|
@@ -27760,7 +27799,7 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
27760
27799
|
| `createSocketIOClient` | function | low-level typed Socket.IO transport primitive — [guide](../guide/realtime.md#low-level-transport) |
|
|
27761
27800
|
| `defineRealtimeContract` | function | Zod-first shared Socket.IO event contract — [guide](../guide/realtime.md#zod-first-event-contract) |
|
|
27762
27801
|
| `createRealtimeClient` | function | inferred, runtime-validated Socket.IO client — [guide](../guide/realtime.md#client--createrealtimeclient) |
|
|
27763
|
-
| `bindRealtimeClient` | function | bind contract validation and typed acknowledgements to an existing
|
|
27802
|
+
| `bindRealtimeClient` | function | bind contract validation and typed acknowledgements to an existing StitchKit client transport without owning its lifecycle |
|
|
27764
27803
|
| `createLiveStateController` | function | keep typed application state current across one source-owned snapshot/event generation with finite pre-snapshot buffering, generation fencing and explicit resync — [guide](../guide/realtime.md#snapshot--event-state-synchronization) |
|
|
27765
27804
|
| `LiveStateController` | _type_ | renderer-neutral `start` / `resync` / `getSnapshot` / `subscribe` / `close` handle |
|
|
27766
27805
|
| `LiveStateControllerConfig` | _type_ | typed source, reducer, explicit event/byte bounds, event sizing and isolated error hooks |
|
|
@@ -29211,7 +29250,7 @@ protocol but exclude runtime `context`. Submit permits only strict text/file par
|
|
|
29211
29250
|
file ownership and metadata policy are checked by server authorization. The shared
|
|
29212
29251
|
`agentControlRealtimeContract` owns `agent:control` acknowledgements and `agent:delivery`.
|
|
29213
29252
|
|
|
29214
|
-
`createAgentController` / `AgentControllerConfig` take an existing
|
|
29253
|
+
`createAgentController` / `AgentControllerConfig` take an existing StitchKit
|
|
29215
29254
|
realtime `transport`, `conversationId`, `access` (`observe` or `control`), optional
|
|
29216
29255
|
`timeoutMs` (10000), `maxBufferedEvents` (256), `maxBufferedBytes` (1048576) and
|
|
29217
29256
|
`maxPendingRequests` (32). All bounds are positive safe integers. One controller owns one
|
|
@@ -29381,7 +29420,7 @@ Evolving.
|
|
|
29381
29420
|
|
|
29382
29421
|
| Export | Kind | Purpose |
|
|
29383
29422
|
|--------|------|---------|
|
|
29384
|
-
| `createClaudeCliDriver` / `ClaudeCliDriverConfig` | function / _type_ | the driver; `permissionMode` defaults to `default`, so the server decides every tool the profile does not already allow; optional `resolveFile` and `maxImageBytes` (default 5 MiB) enable ordered turn-input image attachments; `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. |
|
|
29423
|
+
| `createClaudeCliDriver` / `ClaudeCliDriverConfig` | function / _type_ | the driver; `permissionMode` defaults to `default`, so the server decides every tool the profile does not already allow; optional `wrapCommand` (command wrapper invoked before spawn, e.g. `createProcessSandbox(...).wrapCommand`, for sessions and `info()`/`status()` probes), `resolveFile` and `maxImageBytes` (default 5 MiB) enable ordered turn-input image attachments; `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. |
|
|
29385
29424
|
| `claudeFakeScenarios` | constant | the conformance scenarios in this dialect, for a scripted engine |
|
|
29386
29425
|
| `claudeTranscriptPath` / `claudeTranscriptHasUuid` / `findTranscriptInput` | functions | offline Claude transcript path resolution (resolving `realpath` of `cwd` or its nearest existing ancestor) and bounded streaming UUID lookup / reconciliation without instantiating a driver |
|
|
29387
29426
|
| `claudePlanWindows` / `claudeUsagePlanLimits` | functions | Claude's `rate_limit_event` windows and open-bucket usage / `/api/oauth/usage` `PlanLimits` mapping preserving `plan` and the reported model name as `scope` and `label` on model-scoped windows |
|
|
@@ -29402,7 +29441,7 @@ profile's transcript. Evolving.
|
|
|
29402
29441
|
|
|
29403
29442
|
| Export | Kind | Purpose |
|
|
29404
29443
|
|--------|------|---------|
|
|
29405
|
-
| `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `onProviderPid`, `onQueryExit`, `onElicitation`, `onPermissionRequest`, `onEvent`, `onTurnUsage`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), `ambient`, and `onObserverError`. `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. Exposes `probeCapabilities(input)` for isolated never-yielding capability probes, `status` over passive `rate_limit_event` or active `readUsage()`, and `forkSession(sessionId, options?)` |
|
|
29444
|
+
| `createClaudeSdkDriver` / `ClaudeSdkDriver` / `ClaudeSdkDriverConfig` | function / _types_ | the driver: `query` and `sdkVersion` required; optional `forkSession`, `model`, `permissionMode` (default `default`), `allowDangerouslySkipPermissions`, `pathToClaudeCodeExecutable`, `systemPrompt`, `settingSources`, `enableFileCheckpointing`, `supportedDialogKinds` / `onUserDialog`, `hooks`, `tools`, `allowedTools`, `disallowedTools`, `mcpServers`, `mcpServersDelivery`, `strictMcpConfig`, `plugins`, `agents`, `extraArgs`, `stderr`, `spawnClaudeCodeProcess`, `wrapCommand` (command wrapper invoked inside `spawnOwnedClaudeCode` before spawning Claude Code — compatible with `createProcessSandbox(...).wrapCommand`, preserving `providerPid`, `ownerLoss: 'terminate'`, `session.close()` wait, eager fail-closed `open()`, and `probeCapabilities()`, mutually exclusive with `spawnClaudeCodeProcess`), `onProviderPid`, `onQueryExit`, `onElicitation`, `onPermissionRequest`, `onEvent`, `onTurnUsage`, `verifyDelegation`, `resolveFile`, `maxImageBytes` (default 5 MiB), `ambient`, and `onObserverError`. `onObserverError(error, hook)` receives every failure of a host callback the driver contained, with the name of the option that failed; without it such a failure is contained and dropped. Exposes `probeCapabilities(input)` for isolated never-yielding capability probes, `status` over passive `rate_limit_event` or active `readUsage()`, and `forkSession(sessionId, options?)` |
|
|
29406
29445
|
| `ClaudeSdkSession` / `ClaudeSdkOpenInput` / `ClaudeSdkUsageRead` / `ClaudeSdkQueryExitContext` / `ClaudeSdkPermissionRequestMeta` / `ClaudeSdkFlagSettings` | _types_ | extended session returned by `open(ClaudeSdkOpenInput)` (supporting `resumeSessionAt`, `resumeDropsTurn`, and `onStartupPhase`): exposes `providerPid`, `readUsage(opts?)`, `setModel`, `setPermissionMode` (returning `SDKControlSetPermissionModeResponse \| undefined`), `applyFlagSettings(ClaudeSdkFlagSettings)`, `initializationResult`, `supportedModels`, `supportedCommands`, `accountInfo`, `getContextUsage`, `mcpServerStatus`, `toggleMcpServer`, `reconnectMcpServer`, `setMcpServers`, `stopTask`, `backgroundTasks`, and `rewindFiles`; supports `approve` with `updatedInput` for `AskUserQuestion` and emits `ClaudeSdkPermissionRequestMeta` (`input: Readonly<Record<string, JsonRpcValue>>`) to `onPermissionRequest` |
|
|
29407
29446
|
| `ClaudeRuntimeEventSchema` / `ClaudeRuntimeEvent` / `ClaudeTaskUsageSchema` / `ClaudeTaskUsage` / `ClaudeSdkTurnUsageSchema` / `ClaudeSdkTurnUsage` / `ClaudeSdkTokenPairSchema` / `ClaudeSdkTokenPair` | schemas / _types_ | structured runtime events delivered to `onEvent` during and after turns (`task_started`, `task_updated`, `task_progress`, `task_notification`, `background_tasks_changed`, `tool_progress`, `api_retry`, `elicitation_complete`) alongside `compact_boundary` → `window { reset: 'context' }`, plus per-turn additive `modelUsage` deltas and `otherUsage` delivered to `onTurnUsage` |
|
|
29408
29447
|
| `ClaudeSdkProbeCapabilitiesInput` / `ClaudeSdkCapabilitiesProbe` | _types_ | input and result shapes for `driver.probeCapabilities(input)`: runs an isolated never-yielding SDK query to inspect models, commands, account info, and optional usage, always closing the query in `finally` |
|
|
@@ -29541,7 +29580,7 @@ loaded by the neutral, browser or Node runtime surfaces.
|
|
|
29541
29580
|
| `createBunSqliteAgentRuntimeStore` | function | open an owned Bun SQLite connection, initialize/validate the schema, migrate older versions transactionally and return `{ store, conversations, host, close }` |
|
|
29542
29581
|
| `BunSqliteAgentRuntimeStoreConfig` | _type_ | database filename plus optional create and initialization policies |
|
|
29543
29582
|
| `createSqliteAgentRuntimeStore` | function | build the normalized store over an injected synchronous SQLite boundary |
|
|
29544
|
-
| `initializeAgentRuntimeSqlite` | function | initialize or validate only
|
|
29583
|
+
| `initializeAgentRuntimeSqlite` | function | initialize or validate only StitchKit's namespaced SQLite schema |
|
|
29545
29584
|
| `SqliteDatabase` / `SqliteStatement` / `SqliteValue` | _type_ | minimal runtime-neutral synchronous SQLite boundary |
|
|
29546
29585
|
| `SqliteAgentRuntimeStore` / `SqliteAgentRuntimeStoreConfig` | _type_ | durable store handle — `store`, `conversations`, `host`, `close` — owned connection lifecycle, initialization policy, and the companion host every companion takes |
|
|
29547
29586
|
|
|
@@ -30078,7 +30117,9 @@ not the MCP server SDK. → ADR 0284, ADR 0336.
|
|
|
30078
30117
|
## `stitchkit/tools/toolkit`
|
|
30079
30118
|
|
|
30080
30119
|
Server-only. One context-typed tool set served over MCP and to an AI SDK agent, so it
|
|
30081
|
-
|
|
30120
|
+
deliberately requires both the `@modelcontextprotocol/server` and `ai` peers. Applications
|
|
30121
|
+
that drop `ai` (or install neither peer) should import directly from `stitchkit/tools/mcp`,
|
|
30122
|
+
`stitchkit/tools`, or `stitchkit/cli` instead of `stitchkit/tools/toolkit`. → ADR 0284.
|
|
30082
30123
|
|
|
30083
30124
|
| Export | Kind | Summary |
|
|
30084
30125
|
|--------|------|---------|
|
|
@@ -30100,7 +30141,7 @@ and approval path.
|
|
|
30100
30141
|
| `ConnectionPhase` / `ConnectionOperation` / `ConnectionFailureContext` | _type_ | closed operation/phase vocabulary and measured read context for existing typed connection errors |
|
|
30101
30142
|
| `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 |
|
|
30102
30143
|
| `ConnectionDeadline` / `ConnectionTimeoutContext` | _type_ | `'total' \| 'idle'`, and a timeout's diagnostics with the deadline that fired (default `'total'`) |
|
|
30103
|
-
| `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
|
|
30144
|
+
| `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 |
|
|
30104
30145
|
| `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
|
|
30105
30146
|
| `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) |
|
|
30106
30147
|
| `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
|
|
@@ -31064,7 +31105,7 @@ host-only `SandboxCodingBinding`, with shared authorization, command collection
|
|
|
31064
31105
|
Its types are `AgentSandboxGrade`, `AgentSandboxRestriction`, `BubblewrapSandboxConfig`, `SandboxBackend`, `SandboxCommand`,
|
|
31065
31106
|
`SandboxCreateInput`, `SandboxDriver`, `SandboxHandle`, `SandboxNetworkPolicy`,
|
|
31066
31107
|
`SandboxPrewarmInput`, `SandboxProcess`, `SandboxRunOptions`, `SandboxSession`,
|
|
31067
|
-
and `SandboxState`. `createProcessSandbox`, `probeProcessSandbox`, and `buildSeatbeltProfile` provide a reusable fail-closed OS process sandbox wrapper for long-lived streaming stdio/IPC processes (`workspace-strict` and `workspace-readonly` profiles with real workspace paths, explicit `writableDirs`, `readOnlyPaths`, `denyPaths`, `unixSockets`, `network` policy, `envAllowlist`, `homeDir`, Linux `bwrap` and macOS Seatbelt `sandbox-exec`, throwing `SandboxError('SANDBOX_UNAVAILABLE', ...)` rather than falling back silently; its `wrapCommand` fits `AcpDriverConfig.wrapCommand` and `
|
|
31108
|
+
and `SandboxState`. `createProcessSandbox`, `probeProcessSandbox`, and `buildSeatbeltProfile` provide a reusable fail-closed OS process sandbox wrapper for long-lived streaming stdio/IPC processes (`workspace-strict` and `workspace-readonly` profiles with real workspace paths, explicit `writableDirs`, `readOnlyPaths`, `denyPaths`, `unixSockets`, `network` policy, `envAllowlist`, `homeDir`, Linux `bwrap` and macOS Seatbelt `sandbox-exec`, throwing `SandboxError('SANDBOX_UNAVAILABLE', ...)` rather than falling back silently; its `wrapCommand` fits `AcpDriverConfig.wrapCommand`, `CodexDriverConfig.wrapCommand`, `ClaudeSdkDriverConfig.wrapCommand`, and `ClaudeCliDriverConfig.wrapCommand`). Its schemas and types are `ProcessSandboxSpecSchema`, `ProcessSandboxSpec`, `ProcessSandboxProfileSchema`, `ProcessSandboxProfile`, `ProcessSandboxNetworkSchema`, `ProcessSandboxNetwork`, `ProcessSandboxBackendKindSchema`, `ProcessSandboxBackendKind`, `ProcessSandboxUnixSocketSchema`, `ProcessSandboxUnixSocket`, `ProcessSandboxProbeResultSchema`, `ProcessSandboxProbeResult`, `ProcessSandboxProbeOptions`, `ProcessSandboxCommandSpec`, and `ProcessSandbox`.
|
|
31068
31109
|
|
|
31069
31110
|
The [sandbox guide](../guide/sandbox.md) specifies lifecycle,
|
|
31070
31111
|
network enforcement, gateway credentials and platform/resource boundaries.
|
|
@@ -31147,7 +31188,7 @@ fails a build whose entry imports the default loader of another `stitchkit` inst
|
|
|
31147
31188
|
both versions and roots.
|
|
31148
31189
|
It resolves the installed package's target/version, reads each selected addon once and checks it
|
|
31149
31190
|
against the `size` and `sha256` published in the package's `native-assets.json` (`formatVersion: 2`,
|
|
31150
|
-
written when
|
|
31191
|
+
written when StitchKit is built). Call it once per build and reuse the result.
|
|
31151
31192
|
`platform`, `architecture`, `delivery`, `entryPath` and `assetPath` are the explicit inputs of
|
|
31152
31193
|
companion delivery; embedded delivery takes `platform`, one `architecture` and `delivery` only, and
|
|
31153
31194
|
refuses a path. `assetPath` accepts one template, `[hash]`, replaced by the first 16 hex digits of
|