stitchkit 0.122.2 → 0.123.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 +80 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-identity.d.ts +21 -0
- package/dist/browser/contract-identity.d.ts.map +1 -0
- package/dist/browser/unknown-operation.d.ts +3 -0
- package/dist/browser/unknown-operation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +6 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/endpoint-capabilities.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -0
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/fingerprint.d.ts +51 -0
- package/dist/contract/fingerprint.d.ts.map +1 -0
- package/dist/contract/identity.d.ts +21 -0
- package/dist/contract/identity.d.ts.map +1 -0
- package/dist/contract/stream.d.ts +32 -0
- package/dist/contract/stream.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +2 -2
- package/dist/entrypoints/agent-runtime/coding-tools.js +11 -11
- package/dist/entrypoints/agent-runtime/harness.js +12 -12
- package/dist/entrypoints/agent-runtime/openrouter.js +1 -1
- package/dist/entrypoints/agent-runtime/realtime.js +2 -2
- package/dist/entrypoints/agent-runtime/sandbox.js +11 -11
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +15 -15
- package/dist/entrypoints/agent-runtime/sqlite/node.js +15 -15
- package/dist/entrypoints/agent-runtime/testing.js +15 -15
- package/dist/entrypoints/agent-runtime.js +22 -22
- package/dist/entrypoints/application/diagnostic-journal.js +5 -5
- package/dist/entrypoints/application/directory-inbox.js +5 -5
- package/dist/entrypoints/application/grammy.js +1 -1
- package/dist/entrypoints/application.js +7 -7
- package/dist/entrypoints/cli/publish.js +5 -5
- package/dist/entrypoints/cli.d.ts +1 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +20 -17
- package/dist/entrypoints/contract.d.ts +2 -0
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +11 -5
- package/dist/entrypoints/files/packaging.d.ts +1 -0
- package/dist/entrypoints/files/packaging.d.ts.map +1 -1
- package/dist/entrypoints/files/packaging.js +230 -61
- package/dist/entrypoints/files.js +5 -5
- package/dist/entrypoints/geo.js +3 -3
- package/dist/entrypoints/http.js +3 -3
- package/dist/entrypoints/index.d.ts +1 -0
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +45 -24
- package/dist/entrypoints/live.js +2 -2
- package/dist/entrypoints/node.js +11 -11
- package/dist/entrypoints/observability.js +4 -4
- package/dist/entrypoints/primitives.js +1 -1
- package/dist/entrypoints/process/owner-loss.js +2 -2
- package/dist/entrypoints/process.d.ts +6 -1
- package/dist/entrypoints/process.d.ts.map +1 -1
- package/dist/entrypoints/process.js +370 -9
- package/dist/entrypoints/react.js +2 -2
- package/dist/entrypoints/realtime.js +3 -3
- package/dist/entrypoints/remote.js +20 -10
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +56 -20
- package/dist/entrypoints/telegram/screens.js +4 -4
- package/dist/entrypoints/telegram.js +6 -6
- package/dist/entrypoints/testing.js +10 -10
- package/dist/entrypoints/tools/agent.js +9 -9
- package/dist/entrypoints/tools/connections.js +7 -7
- package/dist/entrypoints/tools/contract.js +1 -1
- package/dist/entrypoints/tools/invoker.js +7 -7
- package/dist/entrypoints/tools/mcp.js +9 -9
- package/dist/entrypoints/tools/toolkit.js +15 -14
- package/dist/entrypoints/tools.js +17 -17
- package/dist/entrypoints/tracking/contract.js +2 -2
- package/dist/entrypoints/tracking.js +1 -1
- package/dist/files/client-artifact.d.ts +75 -0
- package/dist/files/client-artifact.d.ts.map +1 -0
- package/dist/{index-am1h8c9v.js → index-0d3sm0m9.js} +5 -5
- package/dist/{index-72xtvcvr.js → index-0ndz5r8z.js} +1 -1
- package/dist/index-0v9xb8pz.js +66 -0
- package/dist/{index-qcn84byh.js → index-0w0hxp7n.js} +4 -0
- package/dist/{index-3za04re9.js → index-1c945ten.js} +1 -1
- package/dist/{index-r6v4mc67.js → index-1d7s7da0.js} +1 -1
- package/dist/{index-zsvzhjtk.js → index-20hn8pbh.js} +1 -1
- package/dist/{index-f6pw75e1.js → index-2x2ch0bt.js} +2 -2
- package/dist/{index-61hve0ez.js → index-303qne11.js} +1 -1
- package/dist/{index-g149e9pk.js → index-3bzk2645.js} +1 -1
- package/dist/index-45dyex0j.js +119 -0
- package/dist/{index-nwm3ww60.js → index-64b2dxqz.js} +1 -1
- package/dist/{index-aqwg2dm5.js → index-6k47xdtt.js} +2 -2
- package/dist/index-7q05ag0z.js +10 -0
- package/dist/{index-kz9734jc.js → index-96yjwwgf.js} +6 -5
- package/dist/{index-ff39f9dr.js → index-993vtv1w.js} +3 -3
- package/dist/{index-4jpykzvw.js → index-99nnsz39.js} +2 -2
- package/dist/{index-pfvde2fz.js → index-9ypczvpj.js} +1 -1
- package/dist/{index-qch1vcaa.js → index-a7ebd769.js} +2 -2
- package/dist/{index-98hv3sba.js → index-aw6kx2e6.js} +1 -1
- package/dist/{index-yj6saztf.js → index-bz9cmnqq.js} +96 -14
- package/dist/{index-mtwh9hyp.js → index-cjzaj7ev.js} +1 -1
- package/dist/{index-gtx3eknx.js → index-dv7pa9w6.js} +2 -2
- package/dist/{index-sa99p98w.js → index-eabx6qjh.js} +3 -3
- package/dist/{index-8yxgcyt6.js → index-egg0yp2j.js} +1 -1
- package/dist/{index-h1j71dr1.js → index-enkc9pem.js} +1 -1
- package/dist/{index-aqmadanx.js → index-fa53vygr.js} +2 -2
- package/dist/{index-e6c2spsd.js → index-fpwbskp2.js} +1 -1
- package/dist/{index-m8a44e64.js → index-ftk3838x.js} +1 -1
- package/dist/{index-j95jp7ee.js → index-gdqawggb.js} +1 -1
- package/dist/{index-9dyd8xzf.js → index-hkw233vx.js} +2 -2
- package/dist/{index-9jfdm5tg.js → index-hkxgennw.js} +7 -1
- package/dist/{index-qaqxdbxf.js → index-j8rda9n6.js} +7 -7
- package/dist/{index-4tyt1qya.js → index-jc5xgkpk.js} +2 -2
- package/dist/{index-s9a0fjh3.js → index-kffm4r8w.js} +1 -1
- package/dist/{index-5w6t91ze.js → index-m8ddk770.js} +1 -1
- package/dist/{index-2fc1k9k2.js → index-mdyhr36s.js} +32 -122
- package/dist/{index-r7a7r7ha.js → index-mfntvj58.js} +6 -3
- package/dist/{index-gq3fnq3f.js → index-n90tkkcv.js} +2 -2
- package/dist/{index-k42ckyzx.js → index-ndjzbt2v.js} +2 -2
- package/dist/{index-ycqhyars.js → index-qc7tq0za.js} +3 -3
- package/dist/{index-9frf01t9.js → index-r0xr7y4m.js} +1 -1
- package/dist/{index-s3yxw6kt.js → index-s512scra.js} +9 -7
- package/dist/{index-1h2zv8rx.js → index-sqc6ezrb.js} +41 -1
- package/dist/{index-2bqf0a74.js → index-sqkttz7z.js} +1 -1
- package/dist/{index-rbzq0q16.js → index-t8jz0e20.js} +1 -1
- package/dist/{index-8ryydawp.js → index-tt3ej8r3.js} +1 -1
- package/dist/{index-x4p3kw1p.js → index-tynna0n4.js} +6 -6
- package/dist/{index-72r9k0av.js → index-v62cpkx3.js} +1 -1
- package/dist/{index-10rg78vf.js → index-v8xm2s9v.js} +2 -2
- package/dist/{index-y6ye582c.js → index-w0wy05gr.js} +10 -10
- package/dist/{index-kw1ws0cs.js → index-w3nv6kr8.js} +1 -1
- package/dist/{index-eeahxwvg.js → index-ww3gss55.js} +1 -1
- package/dist/{index-6j15ktag.js → index-wzqd6pen.js} +1 -1
- package/dist/{index-aswegq1r.js → index-xjb131sc.js} +367 -131
- package/dist/{index-1fyea34p.js → index-yebkpytc.js} +5 -5
- package/dist/{index-bgcwxhxh.js → index-yfpt7sxr.js} +24 -46
- package/dist/{index-69t14s4a.js → index-yt1gg11x.js} +3 -2
- package/dist/{index-jk29rwkr.js → index-zfncctjp.js} +1 -1
- package/dist/internal/stable-digest.d.ts +5 -0
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +2 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/process/operation-child.d.ts +38 -0
- package/dist/process/operation-child.d.ts.map +1 -0
- package/dist/process/operation-wire.d.ts +68 -0
- package/dist/process/operation-wire.d.ts.map +1 -0
- package/dist/process/operation.d.ts +74 -0
- package/dist/process/operation.d.ts.map +1 -0
- package/dist/server/contract-identity.d.ts +10 -0
- package/dist/server/contract-identity.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +1 -0
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/tools/cli/args-route.d.ts.map +1 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/command.d.ts +39 -18
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/help.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +3 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/io.d.ts +6 -0
- package/dist/tools/cli/io.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts +2 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +14 -0
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/run-native.d.ts.map +1 -1
- package/dist/tools/cli/run-stream.d.ts +23 -0
- package/dist/tools/cli/run-stream.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +8 -0
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/stream-surface.d.ts +17 -0
- package/dist/tools/cli/stream-surface.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +7 -1
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/llms/cli.2.txt +56 -1
- package/llms/cli.txt +68 -1
- package/llms/contract.txt +4 -1
- package/llms/files-packaging.txt +10 -0
- package/llms/process.2.txt +75 -1
- package/llms/process.txt +59 -25
- package/llms/server.4.txt +8 -4
- package/llms/server.5.txt +1 -0
- package/llms/stitchkit.2.txt +74 -0
- package/llms/stitchkit.txt +5 -5
- package/llms/tools.txt +1 -1
- package/llms/{upgrading-0.106.0-0.122.0.txt → upgrading-0.106.0-0.123.0.txt} +50 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +379 -13
- package/llms.txt +7 -7
- package/package.json +1 -1
- package/dist/index-h2fhjqy7.js +0 -19
- package/dist/index-m5m9rmvt.js +0 -44
package/llms/process.txt
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Parts of this slice:
|
|
8
8
|
- `llms/process.txt`: Guide: Native IO (docs/guide/native-io.md)
|
|
9
|
-
- `llms/process.2.txt`: API reference: `stitchkit/process` (docs/api/reference.md)
|
|
9
|
+
- `llms/process.2.txt`: Guide: Native IO (docs/guide/native-io.md) · API reference: `stitchkit/process` (docs/api/reference.md)
|
|
10
10
|
|
|
11
11
|
==============================================================================
|
|
12
12
|
# Guide: Native IO (docs/guide/native-io.md)
|
|
@@ -348,6 +348,64 @@ A command in the caller's group (`group: 'caller'`) has no group of its own: `de
|
|
|
348
348
|
refused there and nothing is stopped after its leader exits. A command whose group this package did not create (a structural
|
|
349
349
|
launcher supplied by a host) has no group to stop, and `descendants` has nothing to act on there.
|
|
350
350
|
|
|
351
|
+
## A contract operation in a process of its own
|
|
352
|
+
|
|
353
|
+
A handler that reads gigabytes holds the server's event loop while it reads, and every cheap
|
|
354
|
+
operation on that server waits behind it. `createOperationProcesses` runs such an operation in a
|
|
355
|
+
child process, one per call, on top of `runNativeCommand` and `streamNativeCommand`. What it
|
|
356
|
+
returns are ordinary contract handlers, so the operation is routed, gated and validated like any
|
|
357
|
+
other:
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
import { createOperationProcesses, runOperationProcess } from 'stitchkit/process'
|
|
361
|
+
|
|
362
|
+
// server
|
|
363
|
+
const processes = createOperationProcesses({
|
|
364
|
+
command: { executable: process.execPath, args: [cliPath, '__operation'], envPolicy: 'ambient' },
|
|
365
|
+
maxConcurrent: 2, // a third call is refused, not queued
|
|
366
|
+
maxResponseBytes: 8 * 1024 * 1024,
|
|
367
|
+
timeoutMs: 60_000,
|
|
368
|
+
})
|
|
369
|
+
const service = implement(searchContract, {
|
|
370
|
+
search: processes.unary(searchContract, 'search'),
|
|
371
|
+
follow: processes.stream(searchContract, 'follow'),
|
|
372
|
+
count: ({ input }) => countCheaply(input), // stays in process
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
// the child: the same contract, the real handlers
|
|
376
|
+
if (process.argv[2] === '__operation') {
|
|
377
|
+
process.exitCode = await runOperationProcess([implement(searchContract, realHandlers)])
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
- **The contract's schemas hold at the server.** The server validates the input before it starts
|
|
382
|
+
a process — a bad call never costs one — and validates the answer against the output schema
|
|
383
|
+
after; a stream item is validated against `stream.item` on its way out. The child receives the
|
|
384
|
+
input the server already parsed and does not parse it again.
|
|
385
|
+
- **The call and the answer cross as JSON.** A schema whose parsed value JSON cannot carry — a
|
|
386
|
+
`Date`, a `Map`, a `bigint` — cannot be an input or an output of such an operation: the value
|
|
387
|
+
arrives as its JSON form and the output check refuses it. A call may weigh up to 64 MiB; bytes
|
|
388
|
+
an operation works on belong in a file it is told the path of.
|
|
389
|
+
- **The call's end is the process's end.** The caller's abort (`ctx.signal`) stops the process
|
|
390
|
+
group under the command's `stop` policy. A unary call also ends at `timeoutMs` with
|
|
391
|
+
`REQUEST_TIMEOUT`. A stream's deadline is the contract's own `stream.lifetimeMs`: when it
|
|
392
|
+
passes, the stream ends with `STREAM_LIFETIME_EXCEEDED` and the process is stopped; without it
|
|
393
|
+
a stream lives until it ends or its reader leaves.
|
|
394
|
+
- **The answer is bounded.** `maxResponseBytes` bounds the whole answer of a unary operation and
|
|
395
|
+
each item of a stream; more is `OPERATION_RESPONSE_TOO_LARGE`. Only stdout counts: what the
|
|
396
|
+
child writes to stderr does not spend the answer's budget.
|
|
397
|
+
- **The count is bounded.** A call beyond `maxConcurrent` is refused with `503 OPERATION_BUSY`
|
|
398
|
+
(`retryable: true`) at once. There is no queue: a queue without a bound is the same memory the
|
|
399
|
+
process boundary was meant to protect. A call that cannot start gives its slot back.
|
|
400
|
+
- **A stream delivers as it produces.** `processes.stream` yields each item when the child
|
|
401
|
+
writes it.
|
|
402
|
+
|
|
403
|
+
A refusal the child's handler throws arrives as that same `AppError` — code, status, details,
|
|
404
|
+
hint and retryability — for a unary call and in the middle of a stream alike. A process that
|
|
405
|
+
dies, writes something that is not an answer, or cannot start is `OPERATION_PROCESS_FAILED`; the
|
|
406
|
+
last 16 KiB of its stderr stay in the error's cause for the log and never reach the caller.
|
|
407
|
+
`processes.active` reports the calls running now. The child reads one call from stdin and writes
|
|
408
|
+
its answer to stdout, so its handlers must not print there.
|
|
351
409
|
|
|
352
410
|
## Replacing hand-written wrappers
|
|
353
411
|
|
|
@@ -710,27 +768,3 @@ Malformed inputs, a manifest whose `formatVersion` is not 2 and other IO errors
|
|
|
710
768
|
A missing or corrupt companion at runtime yields the native `unavailable` result with the safe
|
|
711
769
|
stage and code from the observer; it never certifies a dead owner. Preserve the raw cause internally.
|
|
712
770
|
The plugin does not parse consumer JS or establish a second runtime native implementation.
|
|
713
|
-
|
|
714
|
-
## Qualification boundaries
|
|
715
|
-
|
|
716
|
-
Native command cleanup owns the child before launch subscriptions are installed. Setup
|
|
717
|
-
refusal still settles leader closure and teardown within the cleanup budget; failure to
|
|
718
|
-
prove closure reports `COMMAND_CLEANUP` with the original failure retained. Process-group
|
|
719
|
-
signaling requires evidence from the actual detached launcher, not a structural PID field.
|
|
720
|
-
The built-in sandbox transport carries that ownership across the package's split entrypoints.
|
|
721
|
-
Internal finite deadlines and Darwin retry admission use monotonic elapsed time.
|
|
722
|
-
|
|
723
|
-
Linux UID-refusal qualification is a separate privileged installed-package proof in Bun
|
|
724
|
-
and real Node; an unsupported platform or insufficient UID reports an explicit skip.
|
|
725
|
-
A generic native-owner marker does not certify the privileged case. Real Darwin CI remains
|
|
726
|
-
the qualification for native Darwin behavior.
|
|
727
|
-
|
|
728
|
-
Local filesystem tests do not attest delayed NFS visibility, shared-volume microVM or gVisor
|
|
729
|
-
ownership, actual PGID reuse, power-loss durability or macOS full-sync behavior. Those
|
|
730
|
-
require their actual topology or failure environment. No age-only observation proves a
|
|
731
|
-
process dead; the lock's owner record exists before its name does.
|
|
732
|
-
|
|
733
|
-
A sandbox admission slot is released once a direct command's pipes have closed and its owner has settled.
|
|
734
|
-
A `COMMAND_CLEANUP` outcome means the death of its group was not proven, so the slot stays
|
|
735
|
-
occupied, `stop` keeps rejecting with the cleanup error, and the sandbox session is recreated to
|
|
736
|
-
recover.
|
package/llms/server.4.txt
CHANGED
|
@@ -551,7 +551,8 @@ error round-trips without adding correlation data to the response body.
|
|
|
551
551
|
|
|
552
552
|
A `code` is a free string — your app codes (`BOT_NOT_FOUND`, …) are yours and the
|
|
553
553
|
core never models them (ADR 0002). But stitchkit itself emits a set of its own:
|
|
554
|
-
`BAD_REQUEST`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `
|
|
554
|
+
`BAD_REQUEST`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `UNKNOWN_OPERATION`,
|
|
555
|
+
`METHOD_NOT_ALLOWED`,
|
|
555
556
|
`CONFLICT`, `RATE_LIMITED`, `REQUEST_ABORTED`, `REQUEST_TIMEOUT`,
|
|
556
557
|
`VALIDATION_ERROR`, `FILE_INVALID_PATH`,
|
|
557
558
|
`FILE_OUTSIDE_ROOT`, `FILE_NOT_FOUND`, `FILE_NOT_REGULAR`,
|
|
@@ -561,7 +562,8 @@ core never models them (ADR 0002). But stitchkit itself emits a set of its own:
|
|
|
561
562
|
`WAIT_FAILED`, `CLI_COMMAND_UNAVAILABLE`, `CLI_PRESENTATION_FAILED`, `DOWNLOAD_NOT_FOUND`, `VIEW_HTTP_ERROR`,
|
|
562
563
|
`CONNECTION_TIMEOUT`, `CONNECTION_RESPONSE_TOO_LARGE`,
|
|
563
564
|
`CONNECTION_REQUEST_FAILED`, `UPSTREAM_TOOL_ERROR`,
|
|
564
|
-
`OPERATION_NOT_SUCCEEDED`, `
|
|
565
|
+
`OPERATION_NOT_SUCCEEDED`, `OPERATION_BUSY`, `OPERATION_RESPONSE_TOO_LARGE`,
|
|
566
|
+
`OPERATION_PROCESS_FAILED`, `STREAM_ITEM_INVALID`, `STREAM_FRAME_TOO_LARGE`,
|
|
565
567
|
`STREAM_TERMINAL_MISSING`, `STREAM_LIFETIME_EXCEEDED`,
|
|
566
568
|
`GRAMMY_WEBHOOK_NOT_ACCEPTING`, `SANDBOX_UNAVAILABLE`, `SANDBOX_INSUFFICIENT`,
|
|
567
569
|
`SPILL_REFERENCE_UNKNOWN`, `INTERNAL_SERVER_ERROR` — a set that grows in
|
|
@@ -589,7 +591,8 @@ envelope is a published contract, at the cost of an edit on those releases:
|
|
|
589
591
|
// a map written exhaustively stops compiling on every addition. Codes you leave
|
|
590
592
|
// out fall through to `unmappedCode`.
|
|
591
593
|
const STITCH_TO_APP: Partial<Record<StitchErrorCode, AppCode>> = {
|
|
592
|
-
NOT_FOUND: 'NOT_FOUND',
|
|
594
|
+
NOT_FOUND: 'NOT_FOUND', UNKNOWN_OPERATION: 'NOT_FOUND',
|
|
595
|
+
METHOD_NOT_ALLOWED: 'METHOD_NOT_ALLOWED',
|
|
593
596
|
BAD_REQUEST: 'VALIDATION_ERROR', VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
594
597
|
UNAUTHORIZED: 'UNAUTHORIZED', FORBIDDEN: 'FORBIDDEN', CONFLICT: 'CONFLICT',
|
|
595
598
|
RATE_LIMITED: 'RATE_LIMITED', INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR',
|
|
@@ -715,7 +718,8 @@ const onError = createErrorHook({
|
|
|
715
718
|
codeMap: {
|
|
716
719
|
BAD_REQUEST: 'bad_request', VALIDATION_ERROR: 'bad_request',
|
|
717
720
|
UNAUTHORIZED: 'unauthenticated', FORBIDDEN: 'forbidden',
|
|
718
|
-
NOT_FOUND: 'not_found',
|
|
721
|
+
NOT_FOUND: 'not_found', UNKNOWN_OPERATION: 'not_found',
|
|
722
|
+
METHOD_NOT_ALLOWED: 'not_found',
|
|
719
723
|
CONFLICT: 'conflict', RATE_LIMITED: 'rate_limited',
|
|
720
724
|
INTERNAL_SERVER_ERROR: 'internal',
|
|
721
725
|
},
|
package/llms/server.5.txt
CHANGED
|
@@ -31,6 +31,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
31
31
|
| `createServer` | function | build the router and start `Bun.serve` — [guide](../guide/server.md#createserver) |
|
|
32
32
|
| `createHandler` | function | the router as a bare `(req) => Response` — [guide](../guide/server.md#createserver) |
|
|
33
33
|
| `implement` | function | bind a contract to typed handlers — [guide](../guide/server.md#implement) |
|
|
34
|
+
| `withContractIdentity` | function | the given services plus the one answering `contractIdentityContract` with their fingerprint — the list to mount — [guide](../guide/client.md#which-contract-does-the-server-speak) |
|
|
34
35
|
| `createImplement` | function | fix the handler context type once |
|
|
35
36
|
| `createScopedImplement` | function | fix one scope→context map, then type every handler by its endpoint's effective scope; `.declare(contract)(handlers)` types without binding for the registry path, `.stream(scope, …)` covers streaming multipart — [guide](../guide/server.md#per-scope-handler-context--createscopedimplement) |
|
|
36
37
|
| `ScopedHandlers` | _type_ | handler map typed per endpoint by its effective scope |
|
package/llms/stitchkit.2.txt
CHANGED
|
@@ -245,6 +245,75 @@ seventh constructor argument remains `ErrorOptions`, including `cause`; the opti
|
|
|
245
245
|
retryability argument is eighth. Closed error/frame schemas must accept the new optional
|
|
246
246
|
field before their producer declares it.
|
|
247
247
|
|
|
248
|
+
## Which contract does the server speak
|
|
249
|
+
|
|
250
|
+
A client is built from one version of a contract and a server from another
|
|
251
|
+
whenever the two are deployed separately. Three facts then look alike unless
|
|
252
|
+
they are told apart: the server has no such operation, the operation ran and
|
|
253
|
+
found nothing, and the field is simply absent.
|
|
254
|
+
|
|
255
|
+
**An operation the server cannot route is `UNKNOWN_OPERATION`.** A server
|
|
256
|
+
answers an unmatched route with `404 UNKNOWN_OPERATION`
|
|
257
|
+
(`details: { method, path }`), never `NOT_FOUND` — that code is a handler
|
|
258
|
+
saying its object does not exist. A contract client adds the operation it was
|
|
259
|
+
calling, and reads the router's `405` for its own call the same way, because it
|
|
260
|
+
always calls with the method its contract declares. The router's `405` carries
|
|
261
|
+
`details: { method, path, allow }`; a `METHOD_NOT_ALLOWED` a handler throws
|
|
262
|
+
itself has no `allow` list and stays `METHOD_NOT_ALLOWED`.
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
try {
|
|
266
|
+
await api.search({ query })
|
|
267
|
+
} catch (error) {
|
|
268
|
+
if (error instanceof ApiError && error.code === 'UNKNOWN_OPERATION') {
|
|
269
|
+
// error.details.operation === 'records.search' — this server predates it
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**The fingerprint says so before the call.** `contractFingerprint(contracts)`
|
|
275
|
+
(`stitchkit/contract`) is a synchronous digest of the operations HTTP carries —
|
|
276
|
+
method, route and the JSON Schemas of params, input, output and stream item —
|
|
277
|
+
with one digest per operation under `operations['prefix.key']`. It is the same
|
|
278
|
+
value in every process and runtime. A server answers its own through an
|
|
279
|
+
ordinary contract it mounts by choice, and a client reads both sides in one
|
|
280
|
+
call, over HTTP or a Unix socket alike:
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
// server: the list to mount, with the identity of exactly that list
|
|
284
|
+
import { withContractIdentity } from 'stitchkit/server'
|
|
285
|
+
createServer({ services: withContractIdentity(services) })
|
|
286
|
+
|
|
287
|
+
// client
|
|
288
|
+
import { readContractIdentity } from 'stitchkit'
|
|
289
|
+
const { client, server } = await readContractIdentity(contracts, config)
|
|
290
|
+
if (server === undefined) {
|
|
291
|
+
// the server does not answer its identity: it predates it or did not mount it
|
|
292
|
+
} else if (server.operations['records.search'] === undefined) {
|
|
293
|
+
// this server has no `records.search`
|
|
294
|
+
} else if (server.operations['records.get'] !== client.operations['records.get']) {
|
|
295
|
+
// `records.get` has another schema there: a missing field may be "not sent yet"
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Both fingerprints arrive as a value; a difference never throws. Stitchkit
|
|
300
|
+
computes the two identities and compares nothing — what a mismatch means is the
|
|
301
|
+
application's decision. The client's fingerprint is computed locally and is not
|
|
302
|
+
sent to the server. The identity operation is public and lists operation names,
|
|
303
|
+
which is why it is mounted explicitly. Routing alone cannot always tell the
|
|
304
|
+
cases apart — a new `GET /records/search` reaches an older server's
|
|
305
|
+
`GET /records/:name` and comes back `NOT_FOUND` — so a client that must know
|
|
306
|
+
reads the fingerprint rather than inferring from a refusal.
|
|
307
|
+
|
|
308
|
+
What the fingerprint covers is what constrains a value. An endpoint's `desc`, a
|
|
309
|
+
field's `.describe()` or `.meta()` annotations, and the order of an object's
|
|
310
|
+
fields do not move it; a type, a constraint, a required field, a method or a
|
|
311
|
+
route does. It does not cover a stream's wire framing or format, `multipart`,
|
|
312
|
+
`rawResponse` and `contentType`, and it cannot tell apart types JSON Schema has
|
|
313
|
+
no word for — a `Date` and a `bigint` both read as "anything". Two different schemas registered
|
|
314
|
+
under one `.meta({ id })` are refused by Zod's own conversion, here as in OpenAPI. The digest
|
|
315
|
+
identifies, it does not authenticate: it is not a cryptographic hash.
|
|
316
|
+
|
|
248
317
|
## Auth events
|
|
249
318
|
|
|
250
319
|
The HTTP client emits events your app can react to globally:
|
|
@@ -652,6 +721,8 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
652
721
|
| `RegistryScope` | _type_ | contract-scope union inferred from a scoped client registry value |
|
|
653
722
|
| `createUrlBuilder` | function | build synchronous browser-native URLs for all HTTP endpoints; body methods accept URL-bound args only — [guide](../guide/client.md#contract-url-builders) |
|
|
654
723
|
| `createUrlBuilders` | function | build one exact URL builder per contract in a registry |
|
|
724
|
+
| `readContractIdentity` | function | read the server's contract fingerprint in one call and return it beside the client's own — [guide](../guide/client.md#which-contract-does-the-server-speak) |
|
|
725
|
+
| `ContractIdentity` | _type_ | `{ client, server }` fingerprints; `server` is `undefined` when the server answers no identity |
|
|
655
726
|
| `UrlBuilderConfig` | _type_ | explicit `{ baseUrl }` source for a URL builder |
|
|
656
727
|
| `ClientConfig` | _type_ | config for `createClient`'s bare-fetch mode (2nd arg, no `HttpClient`) |
|
|
657
728
|
| `ClientFetch` | _type_ | injectable Fetch-compatible transport used by framework and application-owned adapters |
|
|
@@ -704,6 +775,9 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
704
775
|
| `StreamLineLimitError` / `StreamTruncatedLineError` | class | a line past `maxLineBytes` (`limitBytes`, `lineBytes`; a `RangeError`) and a source ended inside a line under `require-newline` (`lineBytes`; a `SyntaxError`) |
|
|
705
776
|
| `resumableIterator` | function | re-open a long-lived stream from the last delivered cursor, with jittered backoff, a caller-owned terminal item and prompt abort — [guide](../guide/client.md#resumable-streams) |
|
|
706
777
|
| `createBackoff` | function | exponential backoff with subtractive jitter as a value: `next()` / `reset()` |
|
|
778
|
+
| `contractFingerprint` | function | synchronous digest of the operations HTTP carries, whole and per `prefix.key` — [guide](../guide/client.md#which-contract-does-the-server-speak) |
|
|
779
|
+
| `ContractFingerprintSchema` / `ContractFingerprint` | schema / _type_ | `{ fingerprint, operations }` — one digest for the set and one per operation |
|
|
780
|
+
| `contractIdentityContract` | contract | the operation a server answers its fingerprint with; mount it with `withContractIdentity` |
|
|
707
781
|
| `ContractStreamFrameSchema` / `ContractStreamFrame` | schema / _type_ | default on-the-wire `data` / safe `error` / `end` envelope of a contract-first stream |
|
|
708
782
|
| `ContractStreamFraming` / `ContractStreamCompletion` | _types_ | opt-in item-vs-envelope framing and terminal-vs-stream-end completion policies |
|
|
709
783
|
| `StreamFinalLinePolicy` | _type_ | permissive or newline-required final NDJSON line policy |
|
package/llms/stitchkit.txt
CHANGED
|
@@ -73,9 +73,9 @@ own, recorded as an ADR.
|
|
|
73
73
|
| `stitchkit/cli` | server | stable | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
|
|
74
74
|
| `stitchkit/cli/publish` | build and release tooling (Bun or Node, POSIX) | evolving | `publishCli` — commit a verified CLI distribution and move its public manifest last; see [CLI guide](cli.md#publishing-a-complete-version) |
|
|
75
75
|
| `stitchkit/remote` | browser **and** server | stable | peer-free `implementRemote` for thin HTTP proxy processes |
|
|
76
|
-
| `stitchkit/process` | server (Bun or Node, POSIX) | evolving | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup |
|
|
76
|
+
| `stitchkit/process` | server (Bun or Node, POSIX) | evolving | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
|
|
77
77
|
| `stitchkit/process/owner-loss` | bundled server entry (Bun, POSIX) | evolving | narrow bootstrap that keeps the process runner lazy while carrying its owner-loss guard in a single-file bundle |
|
|
78
|
-
| `stitchkit/files/packaging` | build time (Bun or Node) | evolving | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; no runtime install policy |
|
|
78
|
+
| `stitchkit/files/packaging` | build time (Bun or Node) | evolving | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; a client bundled into one self-contained, hashed and verified file; no runtime install policy |
|
|
79
79
|
| `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
|
|
80
80
|
| `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
|
|
81
81
|
| `stitchkit/telegram/grammy` | server (Bun or Node) | evolving | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left |
|
|
@@ -92,13 +92,13 @@ own, recorded as an ADR.
|
|
|
92
92
|
| `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
|
|
93
93
|
| `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
|
|
94
94
|
| `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
|
|
95
|
-
| `stitchkit/observability` | server | stable<br>_redefined in 2 of the
|
|
95
|
+
| `stitchkit/observability` | server | stable<br>_redefined in 2 of the 68 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
|
|
96
96
|
| `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
|
|
97
97
|
| `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
|
|
98
98
|
| `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
|
|
99
99
|
| `stitchkit/react/keyboard` | browser | evolving | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
|
|
100
100
|
| `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
|
|
101
|
-
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the
|
|
101
|
+
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 26 of the 68 minors since 0.56.2, most recently 0.121.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
|
|
102
102
|
| `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
|
|
103
103
|
| `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
|
|
104
104
|
| `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
|
|
@@ -110,7 +110,7 @@ own, recorded as an ADR.
|
|
|
110
110
|
| `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
|
|
111
111
|
| `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
|
|
112
112
|
| `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
|
|
113
|
-
| `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the
|
|
113
|
+
| `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 68 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
|
|
114
114
|
| `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
|
|
115
115
|
| `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
|
|
116
116
|
| `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
|
package/llms/tools.txt
CHANGED
|
@@ -135,7 +135,7 @@ presentation envelope. `invokeOrThrow` returns validated data and throws the
|
|
|
135
135
|
runner's normalized `AppError` on failure, preserving an application error's
|
|
136
136
|
code, status, message, details and hint without reconstructing it from the
|
|
137
137
|
model-safe envelope. Unexpected throws remain scrubbed. An unknown name throws
|
|
138
|
-
`AppError('
|
|
138
|
+
`AppError('UNKNOWN_OPERATION')` before the runner because there is no operation identity
|
|
139
139
|
against which hooks could run. Duplicate and provider-invalid names fail when
|
|
140
140
|
the invoker is created.
|
|
141
141
|
|
|
@@ -1,14 +1,61 @@
|
|
|
1
|
-
# Upgrading 0.106.0 → 0.
|
|
1
|
+
# Upgrading 0.106.0 → 0.123.0 — stitchkit docs slice
|
|
2
2
|
|
|
3
3
|
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
4
|
> `llms.txt` in this package.
|
|
5
5
|
|
|
6
|
-
Contains: Guide: Upgrading, 0.106.0 → 0.
|
|
6
|
+
Contains: Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
|
|
7
7
|
|
|
8
8
|
==============================================================================
|
|
9
|
-
# Guide: Upgrading, 0.106.0 → 0.
|
|
9
|
+
# Guide: Upgrading, 0.106.0 → 0.123.0 (docs/guide/upgrading.md)
|
|
10
10
|
==============================================================================
|
|
11
11
|
|
|
12
|
+
## Released migration: 0.123.0
|
|
13
|
+
|
|
14
|
+
### unknown-operation
|
|
15
|
+
|
|
16
|
+
**Who must act:** HTTP callers and `onError` code maps that read `NOT_FOUND` to mean "no such
|
|
17
|
+
route", callers of `createCliInvoker`, `--wait` and `createToolInvoker` that read `NOT_FOUND` for
|
|
18
|
+
an unknown command or tool name, and contract-client callers that branch on the router's
|
|
19
|
+
`METHOD_NOT_ALLOWED`.
|
|
20
|
+
|
|
21
|
+
A call no surface can route is answered `UNKNOWN_OPERATION`; `NOT_FOUND` is left to handlers.
|
|
22
|
+
|
|
23
|
+
- The server answers an unmatched route `404 UNKNOWN_OPERATION` with `details: { method, path }`.
|
|
24
|
+
- A contract client reports both routing refusals of its own call — that `404` and the router's
|
|
25
|
+
`405` — as `UNKNOWN_OPERATION` with `details.operation`. A `405` thrown by a handler is
|
|
26
|
+
unchanged.
|
|
27
|
+
- `createCliInvoker().invoke`, an unknown `--wait` target and `createToolInvoker` answer
|
|
28
|
+
`UNKNOWN_OPERATION` for a name they do not have. The CLI exit code for it is `4`, as it was for
|
|
29
|
+
`NOT_FOUND`.
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// before
|
|
33
|
+
if (error.code === 'NOT_FOUND') showMissingPage()
|
|
34
|
+
|
|
35
|
+
// after
|
|
36
|
+
if (error.code === 'UNKNOWN_OPERATION') showMissingPage() // no such route, command or tool
|
|
37
|
+
if (error.code === 'NOT_FOUND') showMissingRecord() // the handler's own answer
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A `createErrorHook` `codeMap` that spells `NOT_FOUND` for clients adds
|
|
41
|
+
`UNKNOWN_OPERATION: 'not_found'` to keep the previous wire code.
|
|
42
|
+
|
|
43
|
+
### cli-schema-option
|
|
44
|
+
|
|
45
|
+
**Who must act:** applications whose CLI exposes a command with an input field named `schema`.
|
|
46
|
+
|
|
47
|
+
`--schema` is a framework option that prints a command's JSON Schema, so a command field of that
|
|
48
|
+
name can no longer receive a value. A contract command declaring it fails at startup; a
|
|
49
|
+
runtime-catalogue command becomes unavailable with the reason in help. Rename the field.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
// before
|
|
53
|
+
input: z.object({ schema: z.string() }) // app export --schema public
|
|
54
|
+
|
|
55
|
+
// after
|
|
56
|
+
input: z.object({ schemaName: z.string() }) // app export --schema-name public
|
|
57
|
+
```
|
|
58
|
+
|
|
12
59
|
## Released migration: 0.122.0
|
|
13
60
|
|
|
14
61
|
### read-view-refusal
|
package/llms/upgrading.txt
CHANGED
|
@@ -11,7 +11,7 @@ Contains: Guide: Upgrading, general (docs/guide/upgrading.md)
|
|
|
11
11
|
|
|
12
12
|
Load this slice, then every range slice between your installed version and the target:
|
|
13
13
|
|
|
14
|
-
- 0.106.0 → 0.
|
|
14
|
+
- 0.106.0 → 0.123.0: `llms/upgrading-0.106.0-0.123.0.txt`
|
|
15
15
|
- 0.96.0 → 0.105.0: `llms/upgrading-0.96.0-0.105.0.txt`
|
|
16
16
|
- 0.69.0 → 0.95.0: `llms/upgrading-0.69.0-0.95.0.txt`
|
|
17
17
|
- 0.55.0 → 0.68.0: `llms/upgrading-0.55.0-0.68.0.txt`
|