stitchkit 0.87.1 → 0.89.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 +190 -0
- package/dist/agent-runtime/child-blocking.d.ts +17 -0
- package/dist/agent-runtime/child-blocking.d.ts.map +1 -0
- package/dist/agent-runtime/child-budget-policy.d.ts +23 -0
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -0
- package/dist/agent-runtime/children-contract.d.ts +155 -0
- package/dist/agent-runtime/children-contract.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +4 -99
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts +33 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-contract.d.ts +18 -0
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts +1 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-utf8.d.ts +28 -0
- package/dist/agent-runtime/coding-tool-utf8.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +20 -0
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/durability-contract.d.ts +176 -0
- package/dist/agent-runtime/durability-contract.d.ts.map +1 -0
- package/dist/agent-runtime/durability-json.d.ts +3 -0
- package/dist/agent-runtime/durability-json.d.ts.map +1 -0
- package/dist/agent-runtime/durability-ledger.d.ts +16 -0
- package/dist/agent-runtime/durability-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/durability-scheduler.d.ts +29 -0
- package/dist/agent-runtime/durability-scheduler.d.ts.map +1 -0
- package/dist/agent-runtime/durability.d.ts +14 -0
- package/dist/agent-runtime/durability.d.ts.map +1 -0
- package/dist/agent-runtime/event-search.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +37 -0
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +8 -0
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/models.d.ts +14 -0
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +8 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts +16 -0
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -0
- package/dist/agent-runtime/prompt.d.ts +23 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +16 -0
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +25 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-broker.d.ts +7 -0
- package/dist/agent-runtime/sandbox-broker.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts +9 -0
- package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts +22 -0
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-bubblewrap.d.ts +14 -0
- package/dist/agent-runtime/sandbox-bubblewrap.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-coding-adapter.d.ts +15 -0
- package/dist/agent-runtime/sandbox-coding-adapter.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-coding.d.ts +15 -0
- package/dist/agent-runtime/sandbox-coding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-contract.d.ts +93 -0
- package/dist/agent-runtime/sandbox-contract.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-owner.d.ts +11 -0
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process.d.ts +8 -0
- package/dist/agent-runtime/sandbox-process.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-session.d.ts +5 -0
- package/dist/agent-runtime/sandbox-session.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox.d.ts +19 -0
- package/dist/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +6 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-purge.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver.d.ts +127 -0
- package/dist/agent-runtime/store-driver.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +106 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts +14 -0
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +115 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime-browser.js +5 -3
- package/dist/agent-runtime-coding-tools.js +11 -1236
- package/dist/agent-runtime-harness.d.ts +1 -1
- package/dist/agent-runtime-harness.d.ts.map +1 -1
- package/dist/agent-runtime-harness.js +69 -19
- package/dist/agent-runtime-openrouter.d.ts +3 -12
- package/dist/agent-runtime-openrouter.d.ts.map +1 -1
- package/dist/agent-runtime-openrouter.js +22 -9
- package/dist/agent-runtime-sandbox.d.ts +5 -0
- package/dist/agent-runtime-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime-sandbox.js +797 -0
- package/dist/agent-runtime-sqlite-bun.js +5 -5
- package/dist/agent-runtime-sqlite-node.js +5 -5
- package/dist/agent-runtime.d.ts +6 -5
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +266 -69
- package/dist/application.js +26 -26
- package/dist/cli.js +8 -8
- package/dist/{index-rcgsnrr6.js → index-31jw8fjq.js} +3 -3
- package/dist/{index-9hw9eq48.js → index-7601qfg1.js} +14 -14
- package/dist/{index-3xnq72rz.js → index-7rkhw9ec.js} +14 -1
- package/dist/{index-0vfdh685.js → index-8c3a7m4g.js} +1 -1
- package/dist/{index-t7gh5w3v.js → index-bn2cjajt.js} +27 -6
- package/dist/{index-z2452tsw.js → index-bt14acb5.js} +2 -2
- package/dist/index-cp20z0n6.js +1351 -0
- package/dist/{index-9553432s.js → index-crykmqkr.js} +1 -1
- package/dist/{index-6g273pqx.js → index-fadnxwna.js} +89 -7
- package/dist/{index-p1b1y93x.js → index-gtj3zc53.js} +5 -1
- package/dist/{index-5wezxcxx.js → index-hrbajay7.js} +107 -5
- package/dist/{index-35aefxby.js → index-hw2chdvy.js} +768 -49
- package/dist/{index-0ydchz76.js → index-mnm4qp0p.js} +5 -5
- package/dist/{index-tg3m2ec5.js → index-mqv3b5rh.js} +4 -1
- package/dist/{index-1szetq6f.js → index-q3ve2d1k.js} +30 -8
- package/dist/{index-hkm6wysp.js → index-y64k3s0h.js} +1 -1
- package/dist/{index-z1m86vc8.js → index-zwkgfq1s.js} +97 -86
- package/dist/{index-wn9cb82y.js → index-zyvby92n.js} +12 -9
- package/dist/index.js +13 -13
- package/dist/server/index.js +9 -9
- package/dist/testing/agent-store-conformance.d.ts.map +1 -1
- package/dist/testing.js +69 -24
- package/dist/tool-invoker.js +6 -6
- package/dist/tools/agent.d.ts +6 -0
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/connections/define.d.ts +6 -0
- package/dist/tools/connections/define.d.ts.map +1 -0
- package/dist/tools/connections/errors.d.ts +50 -0
- package/dist/tools/connections/errors.d.ts.map +1 -0
- package/dist/tools/connections/http.d.ts +3 -0
- package/dist/tools/connections/http.d.ts.map +1 -0
- package/dist/tools/connections/index.d.ts +19 -0
- package/dist/tools/connections/index.d.ts.map +1 -0
- package/dist/tools/connections/index.js +1047 -0
- package/dist/tools/connections/instance.d.ts +3 -0
- package/dist/tools/connections/instance.d.ts.map +1 -0
- package/dist/tools/connections/json-rpc.d.ts +8 -0
- package/dist/tools/connections/json-rpc.d.ts.map +1 -0
- package/dist/tools/connections/limits.d.ts +36 -0
- package/dist/tools/connections/limits.d.ts.map +1 -0
- package/dist/tools/connections/mcp-client.d.ts +44 -0
- package/dist/tools/connections/mcp-client.d.ts.map +1 -0
- package/dist/tools/connections/mcp.d.ts +5 -0
- package/dist/tools/connections/mcp.d.ts.map +1 -0
- package/dist/tools/connections/mount.d.ts +12 -0
- package/dist/tools/connections/mount.d.ts.map +1 -0
- package/dist/tools/connections/openapi-document.d.ts +4 -0
- package/dist/tools/connections/openapi-document.d.ts.map +1 -0
- package/dist/tools/connections/openapi.d.ts +5 -0
- package/dist/tools/connections/openapi.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +29 -0
- package/dist/tools/connections/runtime.d.ts.map +1 -0
- package/dist/tools/connections/schema-budget.d.ts +8 -0
- package/dist/tools/connections/schema-budget.d.ts.map +1 -0
- package/dist/tools/connections/sse-frames.d.ts +7 -0
- package/dist/tools/connections/sse-frames.d.ts.map +1 -0
- package/dist/tools/connections/sse-session.d.ts +26 -0
- package/dist/tools/connections/sse-session.d.ts.map +1 -0
- package/dist/tools/connections/ssrf.d.ts +15 -0
- package/dist/tools/connections/ssrf.d.ts.map +1 -0
- package/dist/tools/connections/types.d.ts +60 -0
- package/dist/tools/connections/types.d.ts.map +1 -0
- package/dist/tools/durability-context.d.ts +7 -0
- package/dist/tools/durability-context.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +2 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/registry.d.ts +38 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/runtime-tool.d.ts +4 -0
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools.d.ts +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +83 -26
- package/llms-full.txt +329 -14
- package/llms.txt +1 -0
- package/package.json +9 -1
- package/dist/{index-evcnmsc3.js → index-t7fkyxcr.js} +3 -3
package/llms-full.txt
CHANGED
|
@@ -55,6 +55,7 @@ own, recorded as an ADR.
|
|
|
55
55
|
| `stitchkit/tools` | server | stable | `createMcpHandler`, `mountMcp`, `mountAgent`, the OAuth provider, native tools |
|
|
56
56
|
| `stitchkit/tools/contract` | browser + server | evolving | the shapes a tool surface speaks — async-operation contract, snapshot and cancel schemas, view-file input/output — without the runtime that serves them |
|
|
57
57
|
| `stitchkit/tools/invoker` | server | stable | peer-free `createToolInvoker` over the canonical contract tool runner |
|
|
58
|
+
| `stitchkit/tools/connections` | server (Bun or Node) | evolving | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
|
|
58
59
|
| `stitchkit/cli` | server | stable | `createCli` — the CLI transport, light (no MCP SDK / `ai`) |
|
|
59
60
|
| `stitchkit/remote` | browser **and** server | stable | peer-free `implementRemote` for thin HTTP proxy processes |
|
|
60
61
|
| `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
|
|
@@ -63,11 +64,12 @@ own, recorded as an ADR.
|
|
|
63
64
|
| `stitchkit/tracking/server` | server (Bun or Node) | evolving | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
|
|
64
65
|
| `stitchkit/release` | browser **and** server | evolving | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
|
|
65
66
|
| `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
|
|
66
|
-
| `stitchkit/observability` | server | stable<br>_redefined in 1 of the
|
|
67
|
+
| `stitchkit/observability` | server | stable<br>_redefined in 1 of the 34 minors since 0.56.2, most recently 0.83.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
|
|
67
68
|
| `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, plus the store and managed-resource conformance kits |
|
|
68
69
|
| `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
|
|
69
70
|
| `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
|
|
70
|
-
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in
|
|
71
|
+
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 20 of the 34 minors since 0.56.2, most recently 0.89.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
|
|
72
|
+
| `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
|
|
71
73
|
| `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults and deterministic race controls |
|
|
72
74
|
| `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
|
|
73
75
|
| `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
|
|
@@ -76,7 +78,7 @@ own, recorded as an ADR.
|
|
|
76
78
|
| `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
|
|
77
79
|
| `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
|
|
78
80
|
| `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
|
|
79
|
-
| `stitchkit/application` | browser + server | evolving<br>_redefined in 7 of the
|
|
81
|
+
| `stitchkit/application` | browser + server | evolving<br>_redefined in 7 of the 34 minors since 0.56.2, most recently 0.83.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
|
|
80
82
|
| `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
|
|
81
83
|
| `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
|
|
82
84
|
| `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
|
|
@@ -4742,6 +4744,11 @@ root and cwd are path boundaries, not a security sandbox: isolate the process wh
|
|
|
4742
4744
|
must not access the rest of the machine. Path admission does not constrain `run_command`; an
|
|
4743
4745
|
executable requires process isolation for that guarantee. → ADR 0172
|
|
4744
4746
|
|
|
4747
|
+
An absolute path is still refused. When it is inside the canonical workspace root, the refusal
|
|
4748
|
+
includes the exact workspace-relative `recoveryPath`; an absolute path outside the root has no
|
|
4749
|
+
suggested replacement. Applying the suggestion still passes the same descriptor-relative
|
|
4750
|
+
containment and symlink checks.
|
|
4751
|
+
|
|
4745
4752
|
`edit_file` replaces one exact snippet. `oldText` is itself the freshness guard for the region it
|
|
4746
4753
|
changes, so the digest is the optional `expectedSha256` and an edit is one call; pass the digest
|
|
4747
4754
|
`read_file` returned when you want the whole-file guarantee, and read the `sha256` it returns to
|
|
@@ -4765,7 +4772,11 @@ Host-level causes stay scrubbed to `INTERNAL_SERVER_ERROR` and name nothing outs
|
|
|
4765
4772
|
`list_directory` marks excluded directories rather than hiding them, and `glob` reports
|
|
4766
4773
|
`skippedDirectories` beside its matches: an empty result from a tree whose files all live under an
|
|
4767
4774
|
excluded directory is not "no files", and a model told only "nothing found" concludes the wrong
|
|
4768
|
-
thing. `search_files` takes `regex`, `context` lines and an `include` pattern
|
|
4775
|
+
thing. `search_files` takes `regex`, `context` lines and an anchored `include` pattern matched
|
|
4776
|
+
against the whole workspace-relative path. `*` does not cross `/`, so files in subdirectories need
|
|
4777
|
+
`**/`; `scannedFiles` counts files admitted by both that filter and host authorization. A `hint`
|
|
4778
|
+
explains the zero only when the filter produced it, rejecting every file the scan reached; an empty
|
|
4779
|
+
tree and a host refusal return the same empty result without blaming the pattern. Regex is bounded by
|
|
4769
4780
|
refusing backreferences and lookaround and capping line length rather than by a timeout, because a
|
|
4770
4781
|
JavaScript `RegExp` cannot be interrupted once it starts backtracking. With an optional `AgentCodingArtifactStore`, shell output beyond the inline
|
|
4771
4782
|
preview continues into an opaque bounded artifact and `read_output` reads slices without
|
|
@@ -4975,10 +4986,14 @@ what was published, so a cursor sees no gap on an ordinary stream.
|
|
|
4975
4986
|
|
|
4976
4987
|
### Event ledger, projections and durable capabilities
|
|
4977
4988
|
|
|
4978
|
-
`AgentRuntimeStore` exposes bounded `readEvents`, declared `appendEvent`,
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4989
|
+
`AgentRuntimeStore` exposes bounded `readEvents`, declared `appendEvent`, canonical
|
|
4990
|
+
`exportConversation` and empty-target `importConversation`. Runtime transitions, exact provider
|
|
4991
|
+
requests and completed provider response identities enter the same append-only ledger. A
|
|
4992
|
+
`provider/response` payload binds `response: { id, provider? }` to its `runId`, retry `attempt` and
|
|
4993
|
+
`stepNumber`; `step-finished.response` projects the same object to the operator sink. The optional
|
|
4994
|
+
upstream name comes from the model provider's own `resolveResponseProvider` — `openRouterProvider`
|
|
4995
|
+
supplies it — so the runtime carries the fact without learning any gateway's metadata key. The normalized
|
|
4996
|
+
head/run/message tables remain the fast operational projection.
|
|
4982
4997
|
|
|
4983
4998
|
Use `defineAgentProjection` with `createSqliteAgentProjectionStore` for a
|
|
4984
4999
|
deterministic versioned fold. Every value reports `uptoSeq`, so a caller can
|
|
@@ -5270,6 +5285,24 @@ own usage. The two channels answer to different readers — delivering a turn tw
|
|
|
5270
5285
|
problem, and omitting a run's cost is an operator's.
|
|
5271
5286
|
`runtime.stop(key)` is the process-local signal-only escape hatch.
|
|
5272
5287
|
|
|
5288
|
+
When an operator has positive evidence that another process owning one known
|
|
5289
|
+
run is gone, close that run through the runtime boundary rather than updating
|
|
5290
|
+
an adapter table or JSON payload directly:
|
|
5291
|
+
|
|
5292
|
+
```ts
|
|
5293
|
+
await runtime.abandon({
|
|
5294
|
+
conversationId,
|
|
5295
|
+
runId,
|
|
5296
|
+
expectedRevision: run.revision,
|
|
5297
|
+
staleOwner: true,
|
|
5298
|
+
})
|
|
5299
|
+
```
|
|
5300
|
+
|
|
5301
|
+
The revision protects against stale operator evidence. The mutation updates the
|
|
5302
|
+
canonical run and failed assistant atomically, removes the run from recovery
|
|
5303
|
+
indexes, and publishes the resulting `run-state`. A run that moved since it was
|
|
5304
|
+
read returns a conflict; `staleOwner: true` is mandatory evidence, not a default.
|
|
5305
|
+
|
|
5273
5306
|
## Store operations
|
|
5274
5307
|
|
|
5275
5308
|
`AgentRuntimeStore` remains the runtime-facing aggregate. Application adapters
|
|
@@ -5552,9 +5585,11 @@ the product has a narrower definition; it receives the candidate message,
|
|
|
5552
5585
|
terminal reason and optional policy name, and runs before persistence. A false
|
|
5553
5586
|
result fails the candidate instead of rewriting an already committed success.
|
|
5554
5587
|
|
|
5555
|
-
`loop.idleTimeoutMs`
|
|
5556
|
-
|
|
5557
|
-
|
|
5588
|
+
`loop.idleTimeoutMs` measures provider silence. It starts immediately before the
|
|
5589
|
+
provider call, resets on stream activity, and pauses while local tools execute.
|
|
5590
|
+
Resource preparation, child waits and approval waiting do not spend this budget.
|
|
5591
|
+
The host gives tools their own deadlines. A stalled provider still aborts with
|
|
5592
|
+
durable reason `timeout`; caller interruption and shutdown reach tools directly.
|
|
5558
5593
|
|
|
5559
5594
|
Reconnect loads the durable snapshot. Missing transient deltas do not mean the
|
|
5560
5595
|
canonical result was lost. Exactly-once external delivery requires the
|
|
@@ -5562,6 +5597,14 @@ application's transactional outbox or stable-ID deduplication.
|
|
|
5562
5597
|
|
|
5563
5598
|
## Managed tools
|
|
5564
5599
|
|
|
5600
|
+
Durable `step` bodies return lossless JSON: finite numbers (excluding negative zero),
|
|
5601
|
+
strings, booleans, null, dense arrays and plain data objects. Return `null` explicitly
|
|
5602
|
+
for effect-only bodies and convert Date values to strings. Unsupported values are
|
|
5603
|
+
refused after the body, so external effects still require idempotency. First results
|
|
5604
|
+
and replay are detached snapshots; mutating a returned object cannot rewrite a record.
|
|
5605
|
+
The optional [sandbox coding profile](sandbox.md#coding-tool-integration) reuses the
|
|
5606
|
+
same tool mounting, authorization and output handling for namespace-backed commands.
|
|
5607
|
+
|
|
5565
5608
|
Always compose `toolFenceLifecycle` into `mountAgent`. It checks ownership
|
|
5566
5609
|
before a managed side effect and again before accepting its result. Fence loss
|
|
5567
5610
|
uses an internal control signal: it stops the old loop and is not sent to the
|
|
@@ -5714,6 +5757,10 @@ spent nothing, and an omitted object could not tell you which one you had.
|
|
|
5714
5757
|
Two costs in different currencies do not add: the sum reports `unavailable`
|
|
5715
5758
|
rather than picking a label. The core records a currency and never converts one.
|
|
5716
5759
|
|
|
5760
|
+
`step-finished.response` identifies the provider response for that one step. The terminal event
|
|
5761
|
+
does not copy the last response: response identity remains per-step, while every terminal usage
|
|
5762
|
+
figure remains a `computed` aggregate.
|
|
5763
|
+
|
|
5717
5764
|
**A run's figure is durable, and that is where to read it when a channel loses
|
|
5718
5765
|
it.** `AgentRun.usage` is written at every checkpoint and again with the terminal
|
|
5719
5766
|
record, so a crashed process leaves behind what it had already spent and a
|
|
@@ -6655,6 +6702,140 @@ the store's first update. Ledger corruption may be declared reconstructable;
|
|
|
6655
6702
|
an outbox must fail closed rather than silently discard pending delivery.
|
|
6656
6703
|
|
|
6657
6704
|
|
|
6705
|
+
==============================================================================
|
|
6706
|
+
# Guide: Optional process sandbox (docs/guide/sandbox.md)
|
|
6707
|
+
==============================================================================
|
|
6708
|
+
|
|
6709
|
+
---
|
|
6710
|
+
title: Optional process sandbox
|
|
6711
|
+
description: Linux namespace isolation, durable workspaces and a host credential gateway.
|
|
6712
|
+
---
|
|
6713
|
+
|
|
6714
|
+
# Optional process sandbox
|
|
6715
|
+
|
|
6716
|
+
`stitchkit/agent-runtime/sandbox` is a server-only, evolving API. Existing coding
|
|
6717
|
+
tools and agent configuration retain their current behavior. A host explicitly
|
|
6718
|
+
creates a session and opts into `createSandboxCodingTools`; importing this
|
|
6719
|
+
entrypoint does not redirect existing coding tools.
|
|
6720
|
+
|
|
6721
|
+
```ts
|
|
6722
|
+
import { createBubblewrapSandboxBackend } from 'stitchkit/agent-runtime/sandbox';
|
|
6723
|
+
|
|
6724
|
+
const backend = await createBubblewrapSandboxBackend({
|
|
6725
|
+
stateDirectory: '/var/lib/my-app/sandboxes',
|
|
6726
|
+
maxConcurrentCommands: 8,
|
|
6727
|
+
onBrokerError: (cause) => console.error('Internal sandbox gateway error', cause),
|
|
6728
|
+
});
|
|
6729
|
+
const template = await backend.prewarm({
|
|
6730
|
+
template: 'agent-workspace',
|
|
6731
|
+
files: { 'hello.txt': new TextEncoder().encode('hello') },
|
|
6732
|
+
});
|
|
6733
|
+
const handle = await backend.create({ template: template.templateKey, network: 'deny-all' });
|
|
6734
|
+
try {
|
|
6735
|
+
const result = await handle.session.run({ executable: '/usr/bin/cat', args: ['hello.txt'] });
|
|
6736
|
+
console.log(result.stdout);
|
|
6737
|
+
const state = handle.captureState(); // Persist this descriptor in the host's store.
|
|
6738
|
+
await handle.stop();
|
|
6739
|
+
const resumed = await backend.create({ template: template.templateKey, state, network: 'deny-all' });
|
|
6740
|
+
try { console.log(await resumed.session.readTextFile('hello.txt')); }
|
|
6741
|
+
finally { await resumed.delete(); }
|
|
6742
|
+
} finally { await handle.shutdown(); }
|
|
6743
|
+
```
|
|
6744
|
+
|
|
6745
|
+
`prewarm` snapshots the supplied byte files. Its content-addressed key includes
|
|
6746
|
+
the backend name, template name and file contents. It is not a VM image or a
|
|
6747
|
+
package installer. `stop` and `shutdown` kill live commands and retain workspace
|
|
6748
|
+
files; `delete` removes session state and workspace, preserving reusable templates.
|
|
6749
|
+
Reconnect requires the same backend name and template. A live owner holds an
|
|
6750
|
+
exclusive lease: concurrent attach and deletion by an older handle fail with
|
|
6751
|
+
`SANDBOX_BUSY`. After a host crash, an operator must verify that its processes are
|
|
6752
|
+
gone before removing a stale lease; automatic crash recovery is not provided.
|
|
6753
|
+
Storage is process-durable, without a power-loss/fsync guarantee.
|
|
6754
|
+
|
|
6755
|
+
## Coding tool integration
|
|
6756
|
+
|
|
6757
|
+
```ts
|
|
6758
|
+
import { createSandboxCodingTools } from 'stitchkit/agent-runtime/sandbox';
|
|
6759
|
+
import { mountAgent } from 'stitchkit/tools';
|
|
6760
|
+
|
|
6761
|
+
const tools = mountAgent([], {
|
|
6762
|
+
runtimeTools: createSandboxCodingTools(handle, {
|
|
6763
|
+
authorize: (operation) => applicationPolicy(operation),
|
|
6764
|
+
executables: { shell: '/usr/bin/sh' },
|
|
6765
|
+
requiredRestrictions: ['network-denied', 'write-contained', 'process-contained', 'secrets-hidden'],
|
|
6766
|
+
limits: { shellTimeoutMs: 10_000, maxShellOutputBytes: 65_536 },
|
|
6767
|
+
}),
|
|
6768
|
+
});
|
|
6769
|
+
```
|
|
6770
|
+
|
|
6771
|
+
The factory uses the existing coding profile, including its authorization,
|
|
6772
|
+
path containment, UTF-8 handling, output artifacts and command limits. File tools
|
|
6773
|
+
access the same workspace through the host's contained-file implementation;
|
|
6774
|
+
commands run inside the namespace with `/workspace` as their root. The host-only
|
|
6775
|
+
`handle.coding` binding never belongs in model input or persisted state.
|
|
6776
|
+
Unsupported backends omit the binding and the factory refuses explicitly.
|
|
6777
|
+
|
|
6778
|
+
Stop also kills coding commands. Both launch paths share the configured
|
|
6779
|
+
`maxConcurrentCommands` admission limit (default 8); an occupied slot gives
|
|
6780
|
+
`SANDBOX_BUSY` before another process starts. This counts direct commands, not
|
|
6781
|
+
guest descendants. Required restrictions are checked again during preparation;
|
|
6782
|
+
a network-policy change invalidates an outstanding prepared launch. After
|
|
6783
|
+
reconnect, create the coding profile from the new handle; old tools remain stopped.
|
|
6784
|
+
|
|
6785
|
+
## Network gateway
|
|
6786
|
+
|
|
6787
|
+
`deny-all` isolates the network namespace, including DNS and loopback access to
|
|
6788
|
+
host services. `{ allow: [{ origin, headers }] }` retains that isolation and
|
|
6789
|
+
allows HTTP through a Unix-socket gateway only. Origins are exact HTTP(S) origins,
|
|
6790
|
+
including scheme and port; no wildcard, redirect, arbitrary TCP or CONNECT tunnel
|
|
6791
|
+
is allowed. For HTTPS upstreams the **host** establishes TLS. Guests speak HTTP
|
|
6792
|
+
over the socket with the upstream host in `Host`, for example:
|
|
6793
|
+
|
|
6794
|
+
```ts
|
|
6795
|
+
await handle.session.setNetworkPolicy({
|
|
6796
|
+
allow: [{ origin: 'https://api.example.com', headers: { authorization: hostCredential } }],
|
|
6797
|
+
});
|
|
6798
|
+
await handle.session.run({
|
|
6799
|
+
executable: '/usr/bin/curl',
|
|
6800
|
+
args: ['--unix-socket', '/run/stitchkit-network.sock', 'http://api.example.com/resource'],
|
|
6801
|
+
});
|
|
6802
|
+
```
|
|
6803
|
+
|
|
6804
|
+
The host obtains `hostCredential` from its credential store. Headers never enter
|
|
6805
|
+
guest environment, process arguments or persisted reconnect state. Authorized
|
|
6806
|
+
upstreams are trusted: an upstream that reflects its request headers can disclose
|
|
6807
|
+
them in its response. This gateway cannot prevent that. Header values are fixed
|
|
6808
|
+
for the policy; replace the policy to rotate credentials. Policy changes require
|
|
6809
|
+
all commands to finish or stop (`SANDBOX_BUSY` otherwise). `allow-all` explicitly
|
|
6810
|
+
shares host networking and adds no injected headers; use it only when unrestricted
|
|
6811
|
+
egress is intended. Policies are resupplied on every reconnect and are not stored.
|
|
6812
|
+
|
|
6813
|
+
## Runtime boundary
|
|
6814
|
+
|
|
6815
|
+
The reference backend requires Linux, `/usr/bin/bwrap`, usable namespaces and a
|
|
6816
|
+
conventional `/usr`, `/lib`, `/lib64` layout. Failure to establish isolation gives
|
|
6817
|
+
`SANDBOX_UNAVAILABLE`; there is no host-execution fallback. Runtime directories
|
|
6818
|
+
are read-only, the workspace is writable, environment is cleared, and host home,
|
|
6819
|
+
state storage and other host sockets are not mounted. Each command gets ephemeral
|
|
6820
|
+
`/tmp`; only `/workspace` persists. Runtime binaries and the configured state
|
|
6821
|
+
directory belong to the trusted host. See the
|
|
6822
|
+
[Bubblewrap security model](https://github.com/containers/bubblewrap#system-security).
|
|
6823
|
+
|
|
6824
|
+
This is namespace isolation over the host kernel, not a VM. It does not impose
|
|
6825
|
+
memory, CPU, disk or process-count quotas. A host running mutually untrusted workloads
|
|
6826
|
+
must supply those bounds outside the namespace (for example, a delegated cgroup and
|
|
6827
|
+
quota-controlled storage); command admission is not a substitute. Commands default to a 30-second deadline
|
|
6828
|
+
and 1 MiB combined output; callers can configure both. File I/O is bounded to
|
|
6829
|
+
1 MiB. The gateway allows 16 concurrent requests, 1 MiB request/response bodies
|
|
6830
|
+
and a 30-second deadline. Do not treat these bounds as resource containment for
|
|
6831
|
+
arbitrary hostile workloads.
|
|
6832
|
+
|
|
6833
|
+
Custom backends implement `SandboxDriver` byte I/O, `spawn` and policy enforcement;
|
|
6834
|
+
`createSandboxSession` supplies text conversion, paths and `run` once. Paths are
|
|
6835
|
+
workspace-relative or canonical `/workspace/...` paths. Unsupported policies must
|
|
6836
|
+
be refused explicitly by the backend.
|
|
6837
|
+
|
|
6838
|
+
|
|
6658
6839
|
==============================================================================
|
|
6659
6840
|
# Guide: Generic application primitives (docs/guide/primitives.md)
|
|
6660
6841
|
==============================================================================
|
|
@@ -11201,6 +11382,39 @@ analytics policy belong to the application.
|
|
|
11201
11382
|
|
|
11202
11383
|
# Upgrading stitchkit
|
|
11203
11384
|
|
|
11385
|
+
## Released migration: 0.89.0
|
|
11386
|
+
|
|
11387
|
+
1. Custom `AgentRuntimeStore` adapters implement `seedConversationInput`; custom
|
|
11388
|
+
`AgentRuntimeStoreDriver` adapters implement `seeds.load` and `seeds.create` together
|
|
11389
|
+
with atomic, ordered history insertion. Use the maintained Prisma example and run
|
|
11390
|
+
`runAgentStoreConformance` against the adapter. Built-in memory and SQLite
|
|
11391
|
+
stores already implement the contract; SQLite migrates to schema version 3.
|
|
11392
|
+
2. OpenRouter usage normalization consumes each completed SDK step's `usage`, including
|
|
11393
|
+
`raw`, rather than aggregate usage. Missing counters stay `unavailable`.
|
|
11394
|
+
|
|
11395
|
+
```ts
|
|
11396
|
+
// before: normalizeOpenRouterUsage(await result.usage, metadata)
|
|
11397
|
+
// after:
|
|
11398
|
+
for (const step of await result.steps) {
|
|
11399
|
+
const usage = normalizeOpenRouterUsage(step.usage, step.providerMetadata);
|
|
11400
|
+
// Persist the step's measured usage with its provenance.
|
|
11401
|
+
}
|
|
11402
|
+
```
|
|
11403
|
+
|
|
11404
|
+
3. Durable step bodies return lossless JSON. Convert dates explicitly, reject invalid
|
|
11405
|
+
numbers upstream, and return `null` after an effect-only operation.
|
|
11406
|
+
|
|
11407
|
+
```ts
|
|
11408
|
+
await context.step('send', async () => {
|
|
11409
|
+
await sendIdempotently();
|
|
11410
|
+
return null;
|
|
11411
|
+
});
|
|
11412
|
+
```
|
|
11413
|
+
|
|
11414
|
+
First execution, replay and concurrent callers receive detached values. Persistence
|
|
11415
|
+
does not make external effects transactional; the host retains idempotency and recovery.
|
|
11416
|
+
|
|
11417
|
+
|
|
11204
11418
|
How to move a consuming project from one stitchkit version to another — including
|
|
11205
11419
|
across many versions at once (a project frozen on an old version, then jumped
|
|
11206
11420
|
forward). The process is mechanical: stitchkit marks every breaking change in one
|
|
@@ -11229,6 +11443,37 @@ of the range if you want a different one.
|
|
|
11229
11443
|
So upgrading is: read the `### ⚠️ Breaking changes` of every version *above* your
|
|
11230
11444
|
current one *up to* your target, and apply each snippet.
|
|
11231
11445
|
|
|
11446
|
+
## Released migration: 0.88.0
|
|
11447
|
+
|
|
11448
|
+
Two mechanical edits, and only if your project builds these values rather than only reading them.
|
|
11449
|
+
|
|
11450
|
+
A completed step event now carries the provider's response identity, and the field is required:
|
|
11451
|
+
|
|
11452
|
+
```ts
|
|
11453
|
+
// before
|
|
11454
|
+
{ type: 'step-finished', step: 0, usage }
|
|
11455
|
+
|
|
11456
|
+
// after
|
|
11457
|
+
{ type: 'step-finished', step: 0, usage, response: { id: generationId } }
|
|
11458
|
+
```
|
|
11459
|
+
|
|
11460
|
+
Every event the runtime emits already has it, so a sink that only reads them needs no change. A
|
|
11461
|
+
fixture, a test double or a pipeline that re-validates events persisted by an earlier version does:
|
|
11462
|
+
give the older records a response identity, or keep parsing them with the schema they were written
|
|
11463
|
+
under.
|
|
11464
|
+
|
|
11465
|
+
If you implement the whole `AgentRuntime` interface — usually a mock — add the new method:
|
|
11466
|
+
|
|
11467
|
+
```ts
|
|
11468
|
+
// before
|
|
11469
|
+
const fake: AgentRuntime = { submit, interrupt, recover, close }
|
|
11470
|
+
|
|
11471
|
+
// after
|
|
11472
|
+
const fake: AgentRuntime = { submit, interrupt, abandon, recover, close }
|
|
11473
|
+
```
|
|
11474
|
+
|
|
11475
|
+
No data migration is involved, and nothing in the store changes shape.
|
|
11476
|
+
|
|
11232
11477
|
## Released migration: 0.87.0
|
|
11233
11478
|
|
|
11234
11479
|
Only if your project implements `AgentConversationReader` itself. A message page
|
|
@@ -15493,6 +15738,12 @@ Server-only optional application runtime. See the
|
|
|
15493
15738
|
| `AgentConversationPageSchema` / `AgentConversationPage` | schema / _type_ | cursor-paged conversation summaries |
|
|
15494
15739
|
| `AgentConversationMessagePageSchema` / `AgentConversationMessagePage` | schema / _type_ | cursor-paged durable message history |
|
|
15495
15740
|
| `composeAgentPrompt` | function | ordered prompt contributions and provenance-aware signed context budget; irreducible reservation deficits are `oversized`, not compactable history |
|
|
15741
|
+
| `SeedConversationInputSchema` / `SeedConversationInput` | schema / _type_ | atomic once-seeding input; partial imported identity sets are refused |
|
|
15742
|
+
| `AgentSeedReceiptSchema` / `AgentSeedReceipt` | schema / _type_ | durable seed receipt retained beyond compaction and implemented by custom store drivers |
|
|
15743
|
+
| `createLocalStepDurability` | function | record JSON step results and park on time/events; a replay returns recorded results, while unrecorded effects require host idempotency |
|
|
15744
|
+
| `StepDurabilityLedger` / `LocalStepDurability` / `LocalStepDurabilityOptions` / `StepRunOptions` | _type_ | the narrow ledger the port needs, the step/read surface, and its construction and per-step options |
|
|
15745
|
+
| `DURABILITY_STEP_EVENT_KIND` | const | the ledger event kind a recorded step is written under |
|
|
15746
|
+
| `StepResultDecodeError` / `StepResultNotSerializableError` / `StepAbortedError` / `ParkRecordDecodeError` / `ParkAbortedError` | class | fail-closed decode of a recorded step or park, a body whose result cannot be serialized, an aborted step, and a park collapsed around an aborted waiter |
|
|
15496
15747
|
| `structuredCompaction` | function | summarize a provider-valid snapshot range and replace it through CAS |
|
|
15497
15748
|
| `selectCompactableHistory` | function | which oldest whole complete turns may be summarised away — the half of compaction that needs no store (→ ADR 0142) |
|
|
15498
15749
|
| `SelectCompactableHistoryOptions` / `CompactableHistory` | _type_ | message list, retained-turn count and evidence policy in; `leadingSummary`, `compactable` and `retained` out |
|
|
@@ -15505,6 +15756,7 @@ Server-only optional application runtime. See the
|
|
|
15505
15756
|
| `AgentAdmissionEventSchema` | schema | post-commit admission projection; removes store rereads but does not imply exactly-once delivery |
|
|
15506
15757
|
| `AgentRunMetricsSchema` | schema | optional provenance-aware usage and timings; `partial` says the provider never reported the run finished, so the figure beside it is not a confirmed total |
|
|
15507
15758
|
| `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
|
|
15759
|
+
| `AgentRuntimeAbandonInput` | _type_ | one known orphan identity, expected revision and mandatory stale-owner evidence for `runtime.abandon()` |
|
|
15508
15760
|
| `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
|
|
15509
15761
|
| `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
|
|
15510
15762
|
| `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
|
|
@@ -15514,13 +15766,15 @@ Server-only optional application runtime. See the
|
|
|
15514
15766
|
| `AgentRunOperationKindSchema` / `AgentRunOperationPhaseSchema` / `AgentRunOperationSchema` / `AgentRunOperation` | schemas / _type_ | latest durable model-request or compaction phase with operation/step identity and original timestamps; request admission is awaited before provider invocation |
|
|
15515
15767
|
| `RecordRunOperationSchema` / `RecordRunOperation` | schema / _type_ | owner/fencing/revision-checked mutation of `AgentRun.lastOperation` |
|
|
15516
15768
|
| `createAgentObservability` | function | separate agent-run sink over the shared bounded observability lifecycle |
|
|
15769
|
+
| `AgentProviderResponseSchema` / `AgentProviderResponse` | schema / _type_ | provider-assigned response ID and the optional upstream provider the model's own adapter resolves, shared by `step-finished.response` and durable `provider/response` facts |
|
|
15770
|
+
| `AgentStepFinishedEventSchema` / `AgentStepFinishedEvent` | schema / _type_ | one completed provider step with required usage and provider response identity |
|
|
15517
15771
|
|
|
15518
15772
|
### Durable capability layer
|
|
15519
15773
|
|
|
15520
15774
|
| Export | Kind | Summary |
|
|
15521
15775
|
|--------|------|---------|
|
|
15522
15776
|
| `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive with exact ledger events, recovery projection and durable spill payloads |
|
|
15523
|
-
| `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary and bounded page |
|
|
15777
|
+
| `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary (including `provider/request` and `provider/response`) and bounded page |
|
|
15524
15778
|
| `AppendAgentStoreEventSchema` / `AppendAgentStoreEvent` / `ReadAgentStoreEventsSchema` / `ReadAgentStoreEvents` | schema / _type_ | required append and bounded-read store contracts |
|
|
15525
15779
|
| `AgentStoreTransitionSchema` / `AgentStoreTransition` / `AgentStoreEventDraft` / `AgentStoreEventDecodeAccepted` / `AgentStoreEventDecodeIgnored` / `AgentStoreEventDecodeResult` / `decodeAgentStoreEvent` | schema / _types_ / function | normalized runtime mutations, append drafts and strict current/ignorable future-event decoding outcomes |
|
|
15526
15780
|
| `defineAgentProjection` / `AgentProjectionDefinition` / `AgentProjectionValue` / `createAgentProjectionRegistry` / `createSqliteAgentProjectionStore` | functions / _type_ | deterministic folds with persisted version and honest `uptoSeq` checkpoints |
|
|
@@ -15530,10 +15784,12 @@ Server-only optional application runtime. See the
|
|
|
15530
15784
|
| `agentGoalStateSlot` / `agentTodoStateSlot` / `createAgentStateTools` | constants / function | built-in goal/todo state and bound `goal_*` / `todo_write` Agent tools |
|
|
15531
15785
|
| `AgentSandboxGradeSchema` / `AgentSandboxGrade` / `AgentSandboxRestrictionSchema` / `AgentSandboxRestriction` / `AgentProcessSandbox` | schema / _type_ | host-provided process sandbox capability and explicit restriction vocabulary |
|
|
15532
15786
|
| `probeAgentProcessSandbox` / `missingSandboxRestrictions` / `recordAgentSandboxProbe` | functions | process-cached probe, fail-closed required-gap calculation and durable probe record |
|
|
15787
|
+
| `AgentSandboxProcess` / `AgentSandboxOutputStream` | _types_ | structural child/output interface for optional lifecycle-owned `AgentProcessSandbox.spawn`, without Node ambient type dependencies |
|
|
15533
15788
|
| `AgentEventSearchResultSchema` / `AgentEventSearchResult` / `createSqliteAgentEventSearch` / `createAgentEventSearchTools` | schema / _type_ / functions | authorized FTS5 search with exact event addresses and `session_*` tools |
|
|
15534
15789
|
| `createSqliteAgentSpillStore` | function | durable content-address-checked artifact storage, bounded read/search, retention facts and archive participation |
|
|
15535
15790
|
| `AgentScheduleSchema` / `AgentSchedule` / `AgentScheduleService` / `createAgentScheduleService` / `createAgentScheduleTools` | schema / _types_ / functions | durable `at`/`after`/timezone-explicit `every`, stable dispatch identity and Agent tools |
|
|
15536
15791
|
| `AgentChildBudgetSchema` / `AgentChildBudget` / `AgentChildStateSchema` / `AgentChildState` / `AgentChildRecordSchema` / `AgentChildRecord` | schema / _type_ | durable child graph, bounded seed and measured budget state |
|
|
15792
|
+
| `AgentChildBlockingKindSchema` / `AgentChildBlockingKind` / `AgentChildBlockingSourceSchema` / `AgentChildBlockingSource` / `AgentChildBlockingEventSchema` / `AgentChildBlockingEvent` / `AgentChildBlockingDecision` | schemas / _types_ | parent-owned request identities; responses discriminate approval decisions from JSON input values |
|
|
15537
15793
|
| `AgentChildHandle` / `AgentChildManager` / `createSqliteAgentChildManager` / `createAgentChildTools` / `agentChildBudgetStopPolicy` | _type_ / functions | host execution port, child lifecycle, cascade (given to `createAgentRuntime` as `children`), messaging, Agent tools, and the child runtime's own budget stop policy — `recordStepUsage` at every step boundary, `policy_stop` as `child-budget` when spent |
|
|
15538
15794
|
| `AgentToolDefinition` | _type_ | peer-neutral shape returned by the bound agent-only state, search, schedule and child tool factories |
|
|
15539
15795
|
| `AgentProviderStreamCutError` | class | explicit retryable provider stream truncation evidence |
|
|
@@ -15543,7 +15799,7 @@ Server-only optional application runtime. See the
|
|
|
15543
15799
|
The entrypoint deliberately exports the schemas beside their inferred types so persistence and
|
|
15544
15800
|
transport adapters validate the same records. Runtime composition types are `AgentRuntime`,
|
|
15545
15801
|
`AgentRuntimeConfig`, `AgentRuntimeInput`, `AgentRuntimeProtocolInput`, `AgentRuntimeRunContext`,
|
|
15546
|
-
`AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeRecoveryInput`,
|
|
15802
|
+
`AgentRuntimeResult`, `AgentRuntimeInterruptInput`, `AgentRuntimeAbandonInput`, `AgentRuntimeRecoveryInput`,
|
|
15547
15803
|
`AgentRuntimeRecoveryDecision`, `AgentRuntimeRecoveryOutcome`, `AgentRuntimePublisher`,
|
|
15548
15804
|
`AgentInputPolicy`, `AgentStopReason`, `AgentCoordinatedRun`, `AgentRunTicket`,
|
|
15549
15805
|
`AgentSessionCoordinator`, `AgentCompactionContext`, `AgentCompactionResult` and
|
|
@@ -15561,7 +15817,11 @@ recognises a failure carried inside a *successful* tool result, in both the bare
|
|
|
15561
15817
|
|
|
15562
15818
|
`normalizeOpenRouterUsage` is the same normalisation `openRouterProvider`
|
|
15563
15819
|
applies, exported so an application calling the SDK directly gets provenance-correct numbers
|
|
15564
|
-
without adopting the runtime.
|
|
15820
|
+
without adopting the runtime. Pass each completed SDK step's usage, including `raw`.
|
|
15821
|
+
Token provenance comes from the original OpenRouter fields: missing fields remain
|
|
15822
|
+
`unavailable`, even when the SDK substitutes zero. Aggregate usage without `raw` cannot
|
|
15823
|
+
establish reported token counts. Explicit zero remains `provider-reported`; cost is never
|
|
15824
|
+
estimated from token prices.
|
|
15565
15825
|
|
|
15566
15826
|
`AgentContextUsage` reaches every step through `AgentRuntimeRunContext.contextUsage`: how full the
|
|
15567
15827
|
model's context is, as `usedTokens` (an `AgentUsageValue`, so it carries the provenance that says
|
|
@@ -15720,6 +15980,9 @@ and introduces no store, queue or model-provider implementation of its own.
|
|
|
15720
15980
|
| `AgentHarnessControlServer` / `AgentHarnessControlConnection` | _type_ | host server and detachable connection lifecycle; `deliver` is serialized, while required out-of-band `onOverflow` closes/aborts a slow transport before reconnect |
|
|
15721
15981
|
| `AgentHarnessControlServerConfig` | _type_ | explicit per-connection pending-event and server-wide concurrent attachment-snapshot bounds for failure-isolated control delivery |
|
|
15722
15982
|
| `AgentHarnessPendingApproval` / `AgentHarnessApprovalDecision` | _type_ | exact durable pending request and allow/deny successor input |
|
|
15983
|
+
| `AgentHarnessApprovalRequest` | _type_ | the pending request as a response-time policy sees it: approval id, call id, tool name and input |
|
|
15984
|
+
| `AgentHarnessApprovalAuthorization` / `AgentHarnessApprovalAuthorizationResult` | _type_ | response-time policy input (responder, conversation, request, proposed decision) and its `allowed` / `rejected` result |
|
|
15985
|
+
| `AgentHarnessApprovalRejectedError` | class | thrown when the response policy refuses a responder; the pending request is left answerable |
|
|
15723
15986
|
|
|
15724
15987
|
Resources default to at most 64 entries, 1 MiB of total UTF-8 text and 128 diagnostics. Duplicate
|
|
15725
15988
|
names and exceeded bounds fail before the provider step. Recovery remains the underlying runtime's
|
|
@@ -15760,6 +16023,13 @@ so denying `credentials` denies `credentials/token.txt` but not `credentials-bac
|
|
|
15760
16023
|
admission happens before descent and file admission before opening; `search_files.include` is also
|
|
15761
16024
|
applied before content is read. Requested paths must use `/` — a backslash is refused, because the
|
|
15762
16025
|
containment walk reads it as a separator while a callback would read it as one name.
|
|
16026
|
+
Absolute paths remain refused; an absolute path inside the canonical root carries an exact
|
|
16027
|
+
workspace-relative `recoveryPath`, while one outside the root carries no replacement. The
|
|
16028
|
+
`search_files.include` schema states that its pattern is anchored to the whole workspace-relative
|
|
16029
|
+
path, `*` does not cross `/`, and `**/` is required for nested matches. `scannedFiles` is the
|
|
16030
|
+
post-include/post-authorization comparison count. A `hint` is added only when the filter itself
|
|
16031
|
+
produced the zero — it rejected every file the scan reached — never when there was nothing to
|
|
16032
|
+
reject or the host refused it.
|
|
15763
16033
|
`run_command` is intentionally outside this guarantee because an executable needs process isolation,
|
|
15764
16034
|
not path filtering, to constrain its filesystem access. → ADR 0172.
|
|
15765
16035
|
|
|
@@ -16029,6 +16299,8 @@ payload.
|
|
|
16029
16299
|
| `RuntimeAgentModelOutput` | _type_ | AI SDK model-facing text/JSON/content output returned by `present.agent` |
|
|
16030
16300
|
| `RuntimeToolTransport` | _type_ | runtime exposure: `'MCP' \| 'AGENT' \| 'CLI'`; omission still means MCP+Agent only |
|
|
16031
16301
|
| `AgentMountConfig` | _type_ | config for `mountAgent` |
|
|
16302
|
+
| `AgentToolRegistry` / `AgentToolRegistryBuilder` / `AgentToolRegistryInput` | _type_ | the composed runtime surface and its builder: declared defaults, `replace`/`disable` by name, and the exact `{ tools, names }` a mount receives |
|
|
16303
|
+
| `defineToolRegistry` | function | compose runtime tools over one declared default set; an unknown `replace`/`disable` name is refused instead of silently leaving the default in place |
|
|
16032
16304
|
| `AgentContext` | _type_ | the context merged into agent tool handlers |
|
|
16033
16305
|
| `CliConfig` | _type_ | config for `createCli`, including program-level `defaultCommand` selection and command-scoped `optionAliases` / `positionals` policy |
|
|
16034
16306
|
| `CliPresentationPolicyConfig` | _type_ | reusable default-command, short-alias and explicit-positional policy inherited by `CliConfig` |
|
|
@@ -16191,6 +16463,36 @@ Advanced building blocks — the shared machinery the mounts are built on.
|
|
|
16191
16463
|
|
|
16192
16464
|
---
|
|
16193
16465
|
|
|
16466
|
+
## `stitchkit/tools/connections`
|
|
16467
|
+
|
|
16468
|
+
Server-only subexport that consumes external MCP servers and OpenAPI specifications
|
|
16469
|
+
as typed tools, without adding a peer dependency to `stitchkit/tools`. Foreign
|
|
16470
|
+
operations mount as the same `RuntimeToolDefinition`s our own produce, so
|
|
16471
|
+
`mountAgent({ runtimeTools })` runs them through the canonical lifecycle, hooks
|
|
16472
|
+
and approval path.
|
|
16473
|
+
|
|
16474
|
+
| Export | Kind | Summary |
|
|
16475
|
+
|--------|------|---------|
|
|
16476
|
+
| `defineMcpClientConnection` | function | declare one external MCP server connection over Streamable HTTP with an optional SSE fallback |
|
|
16477
|
+
| `defineOpenApiConnection` | function | declare one OpenAPI document (object, JSON text or JSON URL) as a tool surface |
|
|
16478
|
+
| `mountConnections` | function | discover every connection and return readonly `RuntimeToolDefinition`s for `mountAgent` |
|
|
16479
|
+
| `ConnectionAuthorizationRequiredError` | class | typed reauthorization signal raised on `401` with credentials resolved again on the next call |
|
|
16480
|
+
| `ConnectionBudgetExceededError` | class | the mount would expose more foreign tools than its declared budget |
|
|
16481
|
+
| `ConnectionRequestError` | class | any non-`2xx` connection response other than the reauthorization signal |
|
|
16482
|
+
| `ConnectionUrlError` | class | a non-http(s) URL or a request host the SSRF fence refused |
|
|
16483
|
+
| `ConnectionTokenProvider` | _type_ | `() => string \| undefined \| Promise<string \| undefined>` — the lazily resolved credential |
|
|
16484
|
+
| `ConnectionBudget` | _type_ | `{ maxTools? }` ceiling on one `mountConnections` call |
|
|
16485
|
+
| `ConnectionDefinition` | _type_ | either a defined MCP client or OpenAPI connection |
|
|
16486
|
+
| `ConnectionMountOptions` | _type_ | shared `{ lifecycle?, budget? }` mount policy |
|
|
16487
|
+
| `McpClientConnection` | _type_ | a defined MCP client connection |
|
|
16488
|
+
| `McpClientConnectionConfig` | _type_ | name, transport, tool filter, token provider, instance key and allowed hosts |
|
|
16489
|
+
| `McpConnectionTransport` | _type_ | `{ url, headers? }` for one MCP endpoint |
|
|
16490
|
+
| `McpToolFilter` | _type_ | `{ allow?, block? }` discovered-tool filter |
|
|
16491
|
+
| `OpenApiConnection` | _type_ | a defined OpenAPI connection |
|
|
16492
|
+
| `OpenApiConnectionConfig` | _type_ | name, spec, base URL, token provider, instance key and allowed hosts |
|
|
16493
|
+
|
|
16494
|
+
---
|
|
16495
|
+
|
|
16194
16496
|
## `stitchkit/testing`
|
|
16195
16497
|
|
|
16196
16498
|
Fetch-only integration helpers that preserve the real generated-client and
|
|
@@ -16563,3 +16865,16 @@ Browser- and server-render-safe React data-layer helpers. Needs the
|
|
|
16563
16865
|
For the rationale behind these APIs — why `Bun.serve` and not a framework, why
|
|
16564
16866
|
two context types, why thin wrappers — see the
|
|
16565
16867
|
[Architecture Decisions](../decisions/).
|
|
16868
|
+
|
|
16869
|
+
## `stitchkit/agent-runtime/sandbox`
|
|
16870
|
+
|
|
16871
|
+
Optional server-only namespace sandbox. Exports:
|
|
16872
|
+
`createSandboxCodingTools` composes the existing coding profile over a handle's
|
|
16873
|
+
host-only `SandboxCodingBinding`, with shared authorization, command collection and lifecycle.
|
|
16874
|
+
`createBubblewrapSandboxBackend`, `createSandboxSession`, `SandboxError`,
|
|
16875
|
+
`SandboxCommandSchema`, `SandboxNetworkPolicySchema`, `SandboxStateSchema`.
|
|
16876
|
+
Its types are `BubblewrapSandboxConfig`, `SandboxBackend`, `SandboxCommand`,
|
|
16877
|
+
`SandboxCreateInput`, `SandboxDriver`, `SandboxHandle`, `SandboxNetworkPolicy`,
|
|
16878
|
+
`SandboxPrewarmInput`, `SandboxProcess`, `SandboxRunOptions`, `SandboxSession`,
|
|
16879
|
+
and `SandboxState`. The [sandbox guide](../guide/sandbox.md) specifies lifecycle,
|
|
16880
|
+
network enforcement, gateway credentials and platform/resource boundaries.
|
package/llms.txt
CHANGED
|
@@ -14,6 +14,7 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
|
|
|
14
14
|
- [MCP & agents](https://github.com/max-listov/stitchkit/blob/master/docs/guide/mcp-and-agents.md): contracts as MCP tools (createMcpHandler) and AI-agent tools (mountAgent); tool lifecycle, extend, identity
|
|
15
15
|
- [Agent application runtime](https://github.com/max-listov/stitchkit/blob/master/docs/guide/agent-runtime.md): optional durable history, prompt/model composition, stream loop, coordination, fencing and events
|
|
16
16
|
- [Managed application kernel](https://github.com/max-listov/stitchkit/blob/master/docs/guide/application-kernel.md): process-local resources, readiness, admission, schedules, projections and optional provider adapters
|
|
17
|
+
- [Optional process sandbox](https://github.com/max-listov/stitchkit/blob/master/docs/guide/sandbox.md): Linux Bubblewrap sessions, durable workspace reconnect, network policy and host credential brokering
|
|
17
18
|
- [Generic application primitives](https://github.com/max-listov/stitchkit/blob/master/docs/guide/primitives.md): lifecycle transitions, owner scope, permissions, exact money and quantities, deadlines, audit, delivery and exports — declared, not persisted
|
|
18
19
|
- [Application migration recipes](https://github.com/max-listov/stitchkit/blob/master/docs/guide/application-migration-recipes.md): executable database, poller, queue-consumer and operational publishing cutovers
|
|
19
20
|
- [CLI](https://github.com/max-listov/stitchkit/blob/master/docs/guide/cli.md): contracts as a command-line program
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stitchkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.89.0",
|
|
4
4
|
"description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
"types": "./dist/tool-invoker.d.ts",
|
|
74
74
|
"import": "./dist/tool-invoker.js"
|
|
75
75
|
},
|
|
76
|
+
"./tools/connections": {
|
|
77
|
+
"types": "./dist/tools/connections/index.d.ts",
|
|
78
|
+
"import": "./dist/tools/connections/index.js"
|
|
79
|
+
},
|
|
76
80
|
"./cli": {
|
|
77
81
|
"types": "./dist/cli.d.ts",
|
|
78
82
|
"import": "./dist/cli.js"
|
|
@@ -153,6 +157,10 @@
|
|
|
153
157
|
"types": "./dist/testing.d.ts",
|
|
154
158
|
"import": "./dist/testing.js"
|
|
155
159
|
},
|
|
160
|
+
"./agent-runtime/sandbox": {
|
|
161
|
+
"types": "./dist/agent-runtime-sandbox.d.ts",
|
|
162
|
+
"import": "./dist/agent-runtime-sandbox.js"
|
|
163
|
+
},
|
|
156
164
|
"./files": {
|
|
157
165
|
"types": "./dist/files.d.ts",
|
|
158
166
|
"import": "./dist/files.js"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
managedResourceDependencyId
|
|
3
|
-
} from "./index-2k4yrqkc.js";
|
|
4
1
|
import {
|
|
5
2
|
ApplicationIdSchema,
|
|
6
3
|
ApplicationShutdownResultSchema,
|
|
7
4
|
ApplicationSnapshotSchema
|
|
8
5
|
} from "./index-3gye9wzb.js";
|
|
6
|
+
import {
|
|
7
|
+
managedResourceDependencyId
|
|
8
|
+
} from "./index-2k4yrqkc.js";
|
|
9
9
|
import {
|
|
10
10
|
ShutdownOptionsSchema
|
|
11
11
|
} from "./index-3z73fh2c.js";
|