stitchkit 0.135.0 → 0.136.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 +117 -0
- package/README.md +25 -11
- package/dist/agent-executor/acp/v1-session-build.d.ts +51 -0
- package/dist/agent-executor/acp/v1-session-build.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-session.d.ts +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/claude/classify.d.ts +1 -1
- package/dist/agent-executor/claude/classify.d.ts.map +1 -1
- package/dist/agent-executor/claude/events-wire.d.ts +13 -0
- package/dist/agent-executor/claude/events-wire.d.ts.map +1 -0
- package/dist/agent-executor/claude/events.d.ts +1 -11
- package/dist/agent-executor/claude/events.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +0 -143
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -1
- package/dist/agent-executor/codex/server-requests.d.ts +150 -0
- package/dist/agent-executor/codex/server-requests.d.ts.map +1 -0
- package/dist/agent-executor/image-input.d.ts +10 -3
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -1
- package/dist/agent-runtime/browser/browser-control-contract.d.ts +4 -0
- package/dist/agent-runtime/browser/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser/control-schema.d.ts +4 -0
- package/dist/agent-runtime/browser/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/browser/control-view.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +16 -3
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/loop/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/loop/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/loop/invocation-stream.d.ts +9 -1
- package/dist/agent-runtime/loop/invocation-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts +6 -0
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts +1 -1
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-approval-signature.d.ts +34 -0
- package/dist/agent-runtime/loop/run-approval-signature.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-approval.d.ts +0 -28
- package/dist/agent-runtime/loop/run-approval.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete-port.d.ts +24 -0
- package/dist/agent-runtime/loop/run-complete-port.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete-stream.d.ts +7 -2
- package/dist/agent-runtime/loop/run-complete-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete-types.d.ts +14 -1
- package/dist/agent-runtime/loop/run-complete-types.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-complete.d.ts +2 -2
- package/dist/agent-runtime/loop/run-complete.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-execution-state.d.ts +8 -0
- package/dist/agent-runtime/loop/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-model-call.d.ts +44 -0
- package/dist/agent-runtime/loop/run-model-call.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-step.d.ts +25 -28
- package/dist/agent-runtime/loop/run-model-step.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-model-steps.d.ts +6 -0
- package/dist/agent-runtime/loop/run-model-steps.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-stream.d.ts +3 -1
- package/dist/agent-runtime/loop/run-model-stream.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts +0 -2
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-step-loop.d.ts +19 -0
- package/dist/agent-runtime/loop/run-step-loop.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-port.d.ts +175 -0
- package/dist/agent-runtime/loop/run-step-port.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-stream-step-text.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts +2 -1
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-call-input.d.ts +39 -0
- package/dist/agent-runtime/loop/run-tool-call-input.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-call.d.ts +2 -31
- package/dist/agent-runtime/loop/run-tool-call.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-errors.d.ts +5 -0
- package/dist/agent-runtime/loop/run-tool-errors.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-executor.d.ts +1 -1
- package/dist/agent-runtime/loop/run-tool-executor.d.ts.map +1 -1
- package/dist/agent-runtime/loop/run-tool-slots.d.ts +2 -1
- package/dist/agent-runtime/loop/run-tool-slots.d.ts.map +1 -1
- package/dist/agent-runtime/loop/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/loop/runtime.d.ts +0 -5
- package/dist/agent-runtime/loop/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts +1 -5
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts +11 -0
- package/dist/agent-runtime/providers/ai-sdk-normalize.d.ts.map +1 -0
- package/dist/agent-runtime/providers/ai-sdk-tools.d.ts +11 -0
- package/dist/agent-runtime/providers/ai-sdk-tools.d.ts.map +1 -0
- package/dist/agent-runtime/providers/ai-sdk.d.ts +1 -9
- package/dist/agent-runtime/providers/ai-sdk.d.ts.map +1 -1
- package/dist/agent-runtime/providers/anthropic-sse.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-admission.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-audio.d.ts +164 -0
- package/dist/agent-runtime/providers/openrouter-audio.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-catalog-cache.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-catalog-query.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts +4 -2
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-client.d.ts +37 -0
- package/dist/agent-runtime/providers/openrouter-client.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-http.d.ts +120 -0
- package/dist/agent-runtime/providers/openrouter-http.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-media.d.ts +174 -0
- package/dist/agent-runtime/providers/openrouter-media.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-models.d.ts +2 -23
- package/dist/agent-runtime/providers/openrouter-models.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-options.d.ts +4 -0
- package/dist/agent-runtime/providers/openrouter-options.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-request.d.ts +23 -0
- package/dist/agent-runtime/providers/openrouter-request.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-response.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts +145 -0
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-speech.d.ts +90 -0
- package/dist/agent-runtime/providers/openrouter-speech.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-spend.d.ts +7 -3
- package/dist/agent-runtime/providers/openrouter-spend.d.ts.map +1 -1
- package/dist/agent-runtime/providers/openrouter-stream.d.ts +29 -0
- package/dist/agent-runtime/providers/openrouter-stream.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-systemone.d.ts +137 -0
- package/dist/agent-runtime/providers/openrouter-systemone.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-url.d.ts +19 -0
- package/dist/agent-runtime/providers/openrouter-url.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-wire.d.ts +45 -0
- package/dist/agent-runtime/providers/openrouter-wire.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter.d.ts +5 -4
- package/dist/agent-runtime/providers/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-http.d.ts +29 -3
- package/dist/agent-runtime/providers/provider-http.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-json-schema-strip.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-json-schema.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-openai-chat-sse.d.ts.map +1 -1
- package/dist/agent-runtime/providers/provider-openai-chat-state.d.ts +42 -0
- package/dist/agent-runtime/providers/provider-openai-chat-state.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts +9 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-args.d.ts +9 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-args.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap.d.ts +6 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-contract.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-linux.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-spec.d.ts +5 -1
- package/dist/agent-runtime/sandbox/sandbox-process-spec.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox/sandbox-process-wrapper.d.ts.map +1 -1
- package/dist/agent-runtime/stores/branch-messages.d.ts.map +1 -1
- package/dist/agent-runtime/stores/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/agent-runtime/testing/fault-bench.d.ts +5 -1
- package/dist/agent-runtime/testing/fault-bench.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/contract/define.d.ts +3 -7
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +17 -5
- package/dist/contract/normalize.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +4 -2
- package/dist/entrypoints/agent-executor/claude-sdk.js +20 -20
- package/dist/entrypoints/agent-executor/claude.js +7 -7
- package/dist/entrypoints/agent-executor/codex.d.ts +2 -1
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +129 -35
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +2 -2
- package/dist/entrypoints/agent-executor/testing.js +17 -13
- package/dist/entrypoints/agent-executor.js +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +2 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.js +10 -12
- package/dist/entrypoints/agent-runtime/anthropic.js +13 -10
- package/dist/entrypoints/agent-runtime/browser.js +8 -4
- package/dist/entrypoints/agent-runtime/harness.js +18 -19
- package/dist/entrypoints/agent-runtime/openai.js +5 -5
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +11 -2
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +1940 -496
- package/dist/entrypoints/agent-runtime/postgres.js +2 -2
- package/dist/entrypoints/agent-runtime/realtime.js +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.js +167 -139
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +3 -3
- package/dist/entrypoints/agent-runtime.js +246 -360
- package/dist/entrypoints/application.js +2 -2
- package/dist/entrypoints/cli.js +36 -15
- package/dist/entrypoints/contract.js +12 -10
- package/dist/entrypoints/geo.js +1 -1
- package/dist/entrypoints/handler.js +5 -6
- package/dist/entrypoints/http.d.ts +2 -0
- package/dist/entrypoints/http.d.ts.map +1 -1
- package/dist/entrypoints/http.js +16 -4
- package/dist/entrypoints/index.js +26 -35
- package/dist/entrypoints/live.js +3 -3
- package/dist/entrypoints/node.js +7 -7
- package/dist/entrypoints/observability.js +9 -7
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/remote.js +5 -5
- package/dist/entrypoints/server.js +29 -16
- package/dist/entrypoints/telegram/grammy.d.ts +1 -1
- package/dist/entrypoints/telegram/grammy.d.ts.map +1 -1
- package/dist/entrypoints/telegram/grammy.js +39 -5
- package/dist/entrypoints/telegram/screens.js +3 -0
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +19 -6
- package/dist/entrypoints/testing.js +10 -11
- package/dist/entrypoints/tools/agent.js +8 -9
- package/dist/entrypoints/tools/connections.js +27 -57
- package/dist/entrypoints/tools/contract.js +4 -4
- package/dist/entrypoints/tools/invoker.js +7 -8
- package/dist/entrypoints/tools/mcp.js +9 -10
- package/dist/entrypoints/tools/toolkit.js +11 -12
- package/dist/entrypoints/tools.js +20 -20
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +1 -1
- package/dist/entrypoints/tracking.js +1 -1
- package/dist/{index-3czc3ykr.js → index-08a3qfr8.js} +1 -1
- package/dist/{index-grhhsrd5.js → index-1en7k3q5.js} +2 -1
- package/dist/{index-pdcbjd6a.js → index-1yky29qg.js} +6 -3
- package/dist/{index-b4c9dpzm.js → index-252den5a.js} +10 -11
- package/dist/{index-xtby8rj3.js → index-28kbdn63.js} +5 -47
- package/dist/{index-57sbckhv.js → index-36mtj8xm.js} +2 -2
- package/dist/{index-dm84tsd5.js → index-3kb8dw48.js} +1 -1
- package/dist/index-3tb82xr7.js +11 -0
- package/dist/{index-c24bj2r1.js → index-4243301z.js} +2 -2
- package/dist/{index-nr4fhfn4.js → index-4p2zx593.js} +2 -0
- package/dist/{index-q86qnzzf.js → index-54wp467c.js} +4 -4
- package/dist/{index-mcv7b2n0.js → index-63ctzjp4.js} +497 -495
- package/dist/{index-y0a4gt1s.js → index-65p8v81y.js} +3 -2
- package/dist/{index-z72vazf5.js → index-6y3eae97.js} +27 -83
- package/dist/{index-5awtbyns.js → index-9vj869rx.js} +1 -1
- package/dist/{index-5q0qpw3v.js → index-aqm7e864.js} +23 -8
- package/dist/{index-d4at0q09.js → index-b9mj31q7.js} +90 -88
- package/dist/{index-baba8ehy.js → index-bjrcbcn2.js} +2 -2
- package/dist/{index-fsw9wxk9.js → index-c9j8441q.js} +1 -103
- package/dist/{index-wdb5jhas.js → index-d1pdv8qc.js} +1 -1
- package/dist/{index-73wq9abg.js → index-df5xr2f9.js} +13 -59
- package/dist/{index-n9358ydy.js → index-dm50x3by.js} +1 -1
- package/dist/{index-zyyerdny.js → index-dmrx8xma.js} +3 -0
- package/dist/{index-78da4g74.js → index-dwq6a6sq.js} +17 -13
- package/dist/{index-9be3tf6r.js → index-e413q2cj.js} +49 -22
- package/dist/{index-g4gstmp1.js → index-ednf2cxs.js} +1 -1
- package/dist/{index-84tp547a.js → index-edpkm3k7.js} +29 -97
- package/dist/{index-gs0jw0hy.js → index-efbzm2se.js} +3 -3
- package/dist/{index-de7b0kvz.js → index-epwvp88y.js} +1 -1
- package/dist/{index-asnd4h2k.js → index-f0dzyskg.js} +27 -4
- package/dist/{index-xbb8ysmq.js → index-fatke81t.js} +2 -2
- package/dist/{index-6nzzj7qr.js → index-gq35s3bm.js} +1 -1
- package/dist/index-gvgtmt7a.js +102 -0
- package/dist/{index-m2b49tvc.js → index-h08xqfw9.js} +20 -21
- package/dist/{index-gk6dq9ay.js → index-ha1tv70k.js} +3 -26
- package/dist/{index-wsv11dhg.js → index-hberxns4.js} +1 -1
- package/dist/{index-rkphknhx.js → index-hpzhz1vm.js} +1 -1
- package/dist/{index-npfdymav.js → index-j5vzhj3d.js} +1 -1
- package/dist/{index-d3s070eh.js → index-jperyn0c.js} +1 -1
- package/dist/{index-yhwx4fwk.js → index-kzsetgh9.js} +1 -1
- package/dist/{index-x6sp5vpa.js → index-q4tr9vnf.js} +1 -1
- package/dist/{index-hce3hbdg.js → index-qj0sq69b.js} +6 -2
- package/dist/{index-v0j22shs.js → index-rg08syp1.js} +9 -6
- package/dist/{index-8vzh5wpv.js → index-rw1caff2.js} +14 -26
- package/dist/index-s8af9jqw.js +6 -0
- package/dist/{index-bgj9hbm3.js → index-sdppfbrh.js} +30 -16
- package/dist/{index-y0mwkgkf.js → index-shte29pg.js} +1086 -1055
- package/dist/{index-fec05c9k.js → index-ta0e2daw.js} +9 -7
- package/dist/{index-zfrysr1e.js → index-tb36xawm.js} +110 -75
- package/dist/{index-c0yym4a0.js → index-w7e402wx.js} +11 -105
- package/dist/{index-bvpevwt6.js → index-xnqab06h.js} +207 -202
- package/dist/index-xrbrvn15.js +147 -0
- package/dist/{index-ac3rfec5.js → index-y6wzzk2e.js} +21 -1
- package/dist/{index-3d2c45jn.js → index-yjx5jna7.js} +2 -2
- package/dist/internal/loopback-host.d.ts +8 -0
- package/dist/internal/loopback-host.d.ts.map +1 -0
- package/dist/internal/own-member.d.ts +7 -0
- package/dist/internal/own-member.d.ts.map +1 -0
- package/dist/internal/request.d.ts +17 -8
- package/dist/internal/request.d.ts.map +1 -1
- package/dist/internal/secret-shapes.d.ts +33 -4
- package/dist/internal/secret-shapes.d.ts.map +1 -1
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/keywords.d.ts +25 -6
- package/dist/json-schema/keywords.d.ts.map +1 -1
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/live/events.d.ts.map +1 -1
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/live/watch-delta.d.ts.map +1 -1
- package/dist/observability/context.d.ts +4 -3
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/sanitize.d.ts.map +1 -1
- package/dist/observability/secret-values.d.ts +0 -9
- package/dist/observability/secret-values.d.ts.map +1 -1
- package/dist/server/context.d.ts +3 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +4 -3
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/event-bus.d.ts.map +1 -1
- package/dist/server/file.d.ts +11 -3
- package/dist/server/file.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +2 -2
- package/dist/server/handler-state.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +12 -1
- package/dist/server/middleware/jwt.d.ts.map +1 -1
- package/dist/server/middleware/trust-fence.d.ts +4 -0
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart.d.ts +2 -3
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/raw.d.ts.map +1 -1
- package/dist/server/request-body.d.ts +12 -1
- package/dist/server/request-body.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts.map +1 -1
- package/dist/server/types.d.ts +14 -9
- package/dist/server/types.d.ts.map +1 -1
- package/dist/telegram/crypto.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts +4 -4
- package/dist/telegram/init-data.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts.map +1 -1
- package/dist/telegram/screens/test-chat.d.ts.map +1 -1
- package/dist/telegram/widget-api.d.ts +85 -13
- package/dist/telegram/widget-api.d.ts.map +1 -1
- package/dist/telegram/widget.d.ts +46 -2
- package/dist/telegram/widget.d.ts.map +1 -1
- package/dist/tools/cli/args-classify.d.ts +4 -74
- package/dist/tools/cli/args-classify.d.ts.map +1 -1
- package/dist/tools/cli/args-framework.d.ts +79 -0
- package/dist/tools/cli/args-framework.d.ts.map +1 -0
- package/dist/tools/cli/args-scan.d.ts.map +1 -1
- package/dist/tools/cli/args-tokens.d.ts.map +1 -1
- package/dist/tools/cli/checkpoint.d.ts +5 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -1
- package/dist/tools/cli/stream.d.ts.map +1 -1
- package/dist/tools/connections/foreign-schema-join.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/execute-handler.d.ts +24 -0
- package/dist/tools/execute-handler.d.ts.map +1 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/mcp/round.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -1
- package/dist/tools/schema/flatten.d.ts.map +1 -1
- package/dist/tools/schema/inline-references.d.ts.map +1 -1
- package/dist/tools/schema/nesting-limit.d.ts.map +1 -1
- package/dist/tools/schema/presentation.d.ts.map +1 -1
- package/dist/tracking/privacy.d.ts.map +1 -1
- package/llms/agent-runtime-openrouter.txt +14 -5
- package/llms/agent-runtime-sandbox.txt +50 -11
- package/llms/agent-runtime-testing.txt +1 -1
- package/llms/agent-runtime.2.txt +342 -230
- package/llms/agent-runtime.3.txt +225 -380
- package/llms/agent-runtime.4.txt +387 -158
- package/llms/agent-runtime.5.txt +157 -152
- package/llms/agent-runtime.6.txt +164 -0
- package/llms/agent-runtime.txt +307 -362
- package/llms/application.txt +3 -1
- package/llms/http.txt +1 -1
- package/llms/live.txt +3 -1
- package/llms/observability.txt +16 -9
- package/llms/server.2.txt +13 -8
- package/llms/server.4.txt +23 -11
- package/llms/server.5.txt +5 -5
- package/llms/server.txt +54 -1
- package/llms/spend.txt +18 -1
- package/llms/stitchkit.2.txt +4 -2
- package/llms/stitchkit.txt +113 -93
- package/llms/telegram-grammy.txt +3 -2
- package/llms/telegram.2.txt +3 -1
- package/llms/telegram.txt +35 -10
- package/llms/upgrading-0.128.0-0.129.0.txt +175 -0
- package/llms/{upgrading-0.128.0-0.135.0.txt → upgrading-0.130.0-0.136.0.txt} +353 -169
- package/llms/upgrading.txt +2 -1
- package/llms-full.txt +1035 -208
- package/llms.txt +14 -13
- package/package.json +6 -6
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts +0 -19
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts.map +0 -1
- package/dist/agent-runtime/loop/run-complete-retry.d.ts +0 -24
- package/dist/agent-runtime/loop/run-complete-retry.d.ts.map +0 -1
- package/dist/agent-runtime/loop/run-model-attempts.d.ts +0 -6
- package/dist/agent-runtime/loop/run-model-attempts.d.ts.map +0 -1
- package/dist/index-sznqf8fx.js +0 -20
- /package/dist/{index-fthw8dwa.js → index-4gbybjg6.js} +0 -0
package/llms/agent-runtime.4.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# stitchkit/agent-runtime — stitchkit docs slice, part 4 of
|
|
1
|
+
# stitchkit/agent-runtime — stitchkit docs slice, part 4 of 6
|
|
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.
|
|
@@ -8,13 +8,397 @@ Parts of this slice:
|
|
|
8
8
|
- `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
9
9
|
- `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
10
10
|
- `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
11
|
-
- `llms/agent-runtime.4.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
12
|
-
- `llms/agent-runtime.5.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
|
|
11
|
+
- `llms/agent-runtime.4.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
12
|
+
- `llms/agent-runtime.5.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
|
|
13
|
+
- `llms/agent-runtime.6.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
|
|
13
14
|
|
|
14
15
|
==============================================================================
|
|
15
16
|
# Guide: Agent application runtime (docs/guide/agent-runtime.md) (continued)
|
|
16
17
|
==============================================================================
|
|
17
18
|
|
|
19
|
+
## Events and reconnect
|
|
20
|
+
|
|
21
|
+
A subscriber that switches over `event.type` handles one transient event
|
|
22
|
+
beyond deltas and reasoning: `attempt-reset`, published when `loop.retry`
|
|
23
|
+
repeats a failed call, meaning what that call streamed is withdrawn. Its
|
|
24
|
+
`withdrawn: { text, reasoning }` counts the characters of transient text and
|
|
25
|
+
reasoning the cut call published — the tail of what the run streamed — so a
|
|
26
|
+
subscriber drops that many from the end and keeps the rest (earlier steps, which
|
|
27
|
+
stand). Counting from the end also holds for a subscriber that joined mid-run
|
|
28
|
+
and holds only part of the run's deltas; an event without `withdrawn`
|
|
29
|
+
withdraws everything the run streamed. It is published after the retry's
|
|
30
|
+
backoff, together with the durable `retry/started`, so a run stopped during the
|
|
31
|
+
pause records neither. `reduceAgentControlEvent` does that; a hand-written reducer must,
|
|
32
|
+
or it keeps the failed attempt's partial text on screen.
|
|
33
|
+
|
|
34
|
+
`publish` receives event classes with different guarantees:
|
|
35
|
+
|
|
36
|
+
- `admission` follows a successful acceptance CAS and carries the same complete
|
|
37
|
+
projection as `ticket.admission`;
|
|
38
|
+
|
|
39
|
+
- `assistant-delta` is transient and ordered by
|
|
40
|
+
`(runId, runtimeEpoch, sequence)`;
|
|
41
|
+
- `reasoning-start`, `reasoning-delta` and `reasoning-end` are transient and
|
|
42
|
+
ordered by the same identity; delta carries only the current text fragment,
|
|
43
|
+
while provider metadata stays inside a validated canonical envelope;
|
|
44
|
+
- `assistant-checkpoint` follows a successful checkpoint CAS;
|
|
45
|
+
- `run-state` follows durable queue/acquire/interrupt transitions;
|
|
46
|
+
- `run-operation` follows a successful operation CAS. Its `operation` is the
|
|
47
|
+
durable `AgentRun.lastOperation`: `model-request` or `compaction`, with
|
|
48
|
+
`started`, `first-output`, `completed`, `failed` or `cancelled` phase and the
|
|
49
|
+
original timestamps. Concrete models use SDK call identity in an awaited model
|
|
50
|
+
middleware; global provider IDs use a runtime-generated identity during awaited
|
|
51
|
+
step preparation. Both durably admit the request before entering `doStream`, so a failed
|
|
52
|
+
write prevents the provider call. This does not claim HTTP transmission is
|
|
53
|
+
measured. First output is a
|
|
54
|
+
non-empty text/reasoning/tool-argument delta or complete tool call; metadata,
|
|
55
|
+
usage, files and sources do not count;
|
|
56
|
+
- `tool-status` is durable lifecycle presentation with JSON-safe input on
|
|
57
|
+
start and output on completion: it follows the checkpoint that holds the call
|
|
58
|
+
(or its result) and carries that checkpoint's `eventId` and `snapshotVersion`. A mounted typed failure carries the same safe
|
|
59
|
+
`{ error, retryable, details?, _hint? }` envelope as the durable result; an unknown
|
|
60
|
+
internal cause remains generic and stays in local observability only;
|
|
61
|
+
- `tool-progress` is transient: what a running tool handler reported through
|
|
62
|
+
`ctx.reportProgress` — `message`, `progress` and `total`, the fields an MCP host
|
|
63
|
+
receives — with the call's `callId` and `toolName`. It never enters the
|
|
64
|
+
model's input or the durable history. A message longer than
|
|
65
|
+
`AGENT_TOOL_PROGRESS_MESSAGE_MAX` (280) is cut, reports of one call closer
|
|
66
|
+
than 250 ms apart are dropped, and a report after the call's terminal
|
|
67
|
+
`tool-status` or after its attempt was abandoned is dropped; the terminal
|
|
68
|
+
status carries the final word. `reduceAgentControlEvent` keeps the last
|
|
69
|
+
report of each running call in `transientByRun[runId].tools[callId]` and
|
|
70
|
+
removes it on that call's `completed`, `failed` or `interrupted`. The runtime
|
|
71
|
+
hands its reporter to a call through the SDK tool context, beside its step
|
|
72
|
+
ledger; a tool that declares its own `contextSchema` keeps that contract and
|
|
73
|
+
reports nowhere;
|
|
74
|
+
- `terminal` follows the winning terminal CAS.
|
|
75
|
+
|
|
76
|
+
`loop.checkpointEveryEvents` batches ordinary stream parts (default `20`) and
|
|
77
|
+
does not batch live event delivery. Tool call/result/error/denial, approval
|
|
78
|
+
request/response and step-finish boundaries force an assistant checkpoint and
|
|
79
|
+
reset that batch. The checkpoint is awaited after the managed loop observes the
|
|
80
|
+
normalized boundary. It does **not** promise persistence before a tool side
|
|
81
|
+
effect: tool fencing supplies the real ownership checks around execution, while
|
|
82
|
+
cross-crash effect idempotency stays application-owned. The following model
|
|
83
|
+
step waits for the previous step-finish checkpoint before its own durable
|
|
84
|
+
request admission and provider invocation. → ADR 0174.
|
|
85
|
+
|
|
86
|
+
`compaction` names invocation of the configured callback, including a
|
|
87
|
+
`not_needed` context-budget check; it does not by itself say that history was
|
|
88
|
+
summarized. Operation timestamps are retained wall-clock observations and may
|
|
89
|
+
move backwards after a clock correction. Do not subtract them for duration;
|
|
90
|
+
phase order comes from durable snapshot versions/event order.
|
|
91
|
+
|
|
92
|
+
These are post-commit notifications, not a transactional outbox: a process can
|
|
93
|
+
crash between the database commit and `publish`. Reconnect should load canonical
|
|
94
|
+
state. Exactly-once external delivery remains an application-owned outbox.
|
|
95
|
+
|
|
96
|
+
### External channel ingress and delivery
|
|
97
|
+
|
|
98
|
+
The executable
|
|
99
|
+
[`external-channel-harness.ts`](../../packages/core/examples/agent-runtime/external-channel-harness.ts)
|
|
100
|
+
is the reference composition for webhooks, polling transports and local-device
|
|
101
|
+
adapters. Its generic boundary injects a runtime, durable store and delivery
|
|
102
|
+
adapter; the optional
|
|
103
|
+
[`external-channel-grammy.ts`](../../packages/core/examples/agent-runtime/external-channel-grammy.ts)
|
|
104
|
+
attaches the same ingress function to grammY polling or webhook lifecycle
|
|
105
|
+
without putting provider types in the agent runtime.
|
|
106
|
+
|
|
107
|
+
Inbound update identity, principal resolution, conversation mapping and reply
|
|
108
|
+
target are application policy. Persist and deduplicate the update before
|
|
109
|
+
`runtime.submit`, use the stored idempotency key on crash recovery, then persist
|
|
110
|
+
the admitted `runId`. A duplicate arriving after restart resolves to that same
|
|
111
|
+
mapping instead of creating another model turn.
|
|
112
|
+
|
|
113
|
+
For output, choose `terminal-only` or `streaming` explicitly. Stable durable
|
|
114
|
+
`eventId` values and transient `(runtimeEpoch, sequence)` identities become
|
|
115
|
+
outbox keys; the application store assigns causal ordinals. A bounded channel
|
|
116
|
+
is only a process-local wakeup and never the durable authority. Before sending,
|
|
117
|
+
persist one of these states:
|
|
118
|
+
|
|
119
|
+
| State | Recovery action |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `not-dispatched` | may dispatch once |
|
|
122
|
+
| `possibly-dispatched` | reconcile with the adapter or remain unresolved |
|
|
123
|
+
| `acknowledged` | deduplicate; delivery is complete |
|
|
124
|
+
|
|
125
|
+
The agent `terminal` event and the adapter's delivery receipt are intentionally
|
|
126
|
+
different records. A successful run does not prove that a reply reached its
|
|
127
|
+
channel, and a delivery failure never rewrites the canonical agent result.
|
|
128
|
+
Shutdown stops ingress, drains accepted process-local work and leaves ambiguous
|
|
129
|
+
outbox records visible for a later reconciliation pass. StitchKit does not own
|
|
130
|
+
a channel database, durable broker, provider payload schema or application
|
|
131
|
+
identity policy.
|
|
132
|
+
|
|
133
|
+
Durable event IDs are derived from run, event type and snapshot version. Use
|
|
134
|
+
`advanceAgentRuntimeEventCursor` to classify delivery.
|
|
135
|
+
|
|
136
|
+
**`gap` is reported for transient events only**, where `sequence` is a per-run
|
|
137
|
+
counter the runtime really does increment once per event. Durable events carry
|
|
138
|
+
the *conversation's* version, which advances on every mutation including the many
|
|
139
|
+
that publish nothing — checkpoints, compaction, an acceptance that has not
|
|
140
|
+
started — so two consecutive durable events are routinely several versions apart
|
|
141
|
+
and adjacency says nothing. A durable loss is not detectable from the cursor;
|
|
142
|
+
reload on reconnect, which is what a bounded fire-and-forget sink asks of you
|
|
143
|
+
anyway. `createAgentRuntimeEventSink` adds a bounded failure-isolated lifecycle and typed
|
|
144
|
+
projection/redaction hook. `onPublishError` records direct publisher failures without changing the
|
|
145
|
+
already committed run.
|
|
146
|
+
|
|
147
|
+
A named custom stop condition terminalizes with `policy_stop`; its `policyName`
|
|
148
|
+
is persisted on the run and included in the terminal event/result. `max-steps`
|
|
149
|
+
is the reserved built-in policy name. `loop.prepareStep` (and `prepareStep` on
|
|
150
|
+
`completeText` / `streamComplete` / `completeObject`) is the controlled step
|
|
151
|
+
boundary for changing active tools, driver, instructions or messages. It cannot
|
|
152
|
+
replace the managed tool set or bypass its lifecycle fence.
|
|
153
|
+
|
|
154
|
+
Override lifetimes in `prepareStep` follow two explicit rules:
|
|
155
|
+
|
|
156
|
+
- **`instructions` is sticky across the remaining steps of the run** (a provider
|
|
157
|
+
retry repeats the failed call with the instructions it was prepared with). Later steps receive the carried value in `instructions` alongside
|
|
158
|
+
the unchanged `initialInstructions`, so a step can explicitly revert with
|
|
159
|
+
`{ instructions: initialInstructions }`. One-shot `protocol.acceptTerminal`
|
|
160
|
+
continuation instructions apply only to that continuation step and do not
|
|
161
|
+
overwrite carried `prepareStep` instructions.
|
|
162
|
+
- **`driver` applies to that single step only** (matching `activeTools`,
|
|
163
|
+
`toolChoice`, `responseFormat`, `cacheControl`, `headers`, `providerOptions`
|
|
164
|
+
and call settings). Omitting `driver` on the next step reverts to the run's
|
|
165
|
+
resolved default driver (or `input.driver` in `completeText`), and
|
|
166
|
+
`prepareStep` always receives that default driver in `driver`.
|
|
167
|
+
|
|
168
|
+
Context can grow between steps as tool results and deferred schemas enter the
|
|
169
|
+
provider prompt. When application budgeting can prove that the next assembled
|
|
170
|
+
step exceeds the selected model window, refuse it by type before that provider
|
|
171
|
+
call:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
prepareStep: (step) => {
|
|
175
|
+
if (wouldExceedSelectedModelWindow(step)) {
|
|
176
|
+
throw new AgentContextOverflowError('Prepared step exceeds the selected model window')
|
|
177
|
+
}
|
|
178
|
+
return chooseProductStepOptions(step)
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
That deliberate refusal ends the run as `context_overflow` on the durable
|
|
183
|
+
record, delivery terminal and operator event. StitchKit does not inspect error
|
|
184
|
+
messages — it recognises failures by identity, not by text. A store refusing an
|
|
185
|
+
owned mutation ends the run `storage_conflict`; `protocol.acceptTerminal`
|
|
186
|
+
refusing a finished message ends it `output_rejected`; a check the SDK runs on
|
|
187
|
+
what this runtime handed it ends it `runtime_failure`. Every error the runtime
|
|
188
|
+
cannot identify as its own remains `provider_failure`, and operator-only
|
|
189
|
+
observability retains its original cause in all of them.
|
|
190
|
+
|
|
191
|
+
Completion validity belongs to the protocol and is checked before the terminal
|
|
192
|
+
CAS. Protocols that require a visible answer opt in explicitly:
|
|
193
|
+
|
|
194
|
+
```ts
|
|
195
|
+
const protocol = defineAgentProtocol({
|
|
196
|
+
context: ContextSchema,
|
|
197
|
+
inputMetadata: InputMetadataSchema,
|
|
198
|
+
terminalAcceptance: 'require-output',
|
|
199
|
+
})
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
The built-in rule accepts non-blank text, generated files, structured provider
|
|
203
|
+
parts, and a named tool-only `policy_stop`. The default is `allow-empty` for
|
|
204
|
+
protocols where an empty acknowledgement is meaningful. Pass a callback when
|
|
205
|
+
the product has a narrower definition; it receives the candidate message,
|
|
206
|
+
terminal reason and optional policy name, and runs before persistence. A false
|
|
207
|
+
result fails the candidate instead of rewriting an already committed success.
|
|
208
|
+
|
|
209
|
+
`loop.idleTimeoutMs` measures provider silence. It starts immediately before the
|
|
210
|
+
provider call, resets on stream activity, and pauses while local tools execute.
|
|
211
|
+
Resource preparation, child waits and approval waiting do not spend this budget.
|
|
212
|
+
The host gives tools their own deadlines. A stalled provider still aborts with
|
|
213
|
+
durable reason `timeout`; caller interruption and shutdown reach tools directly.
|
|
214
|
+
|
|
215
|
+
Reconnect loads the durable snapshot. Missing transient deltas do not mean the
|
|
216
|
+
canonical result was lost. Exactly-once external delivery requires the
|
|
217
|
+
application's transactional outbox or stable-ID deduplication.
|
|
218
|
+
|
|
219
|
+
## Managed tools
|
|
220
|
+
|
|
221
|
+
Durable `step` bodies return lossless JSON: finite numbers (excluding negative zero),
|
|
222
|
+
strings, booleans, null, dense arrays and plain data objects. Return `null` explicitly
|
|
223
|
+
for effect-only bodies and convert Date values to strings. Unsupported values are
|
|
224
|
+
refused after the body, so external effects still require idempotency. First results
|
|
225
|
+
and replay are detached snapshots; mutating a returned object cannot rewrite a record.
|
|
226
|
+
The optional [sandbox coding profile](sandbox.md#coding-tool-integration) reuses the
|
|
227
|
+
same tool mounting, authorization and output handling for namespace-backed commands.
|
|
228
|
+
|
|
229
|
+
Always compose `toolFenceLifecycle` into `mountAgentTools`. It checks ownership
|
|
230
|
+
before a managed side effect and again before accepting its result. Fence loss
|
|
231
|
+
uses an internal control signal: it stops the old loop and is not sent to the
|
|
232
|
+
model as a tool error.
|
|
233
|
+
|
|
234
|
+
`mountAgentTools` throws `AgentToolError` for failed runner outcomes. AgentRuntime
|
|
235
|
+
persists them with `outcome: 'error'`, publishes the same safe envelope, and replays
|
|
236
|
+
them as an error result on later turns. Classification comes from the execution
|
|
237
|
+
channel, never from inspecting output fields: a valid successful result such as
|
|
238
|
+
`{ error: 'domain value' }` remains successful. Typed `AppError` codes and safe
|
|
239
|
+
details may reach the model; arbitrary thrown causes are retained for local hooks
|
|
240
|
+
and reduced to `INTERNAL_SERVER_ERROR` outside.
|
|
241
|
+
|
|
242
|
+
The framework cannot undo an already-started non-cooperative external effect.
|
|
243
|
+
Pass the stable call/run idempotency identity into business mutations when the
|
|
244
|
+
effect must be replay-safe.
|
|
245
|
+
|
|
246
|
+
## History, provider metadata and files
|
|
247
|
+
|
|
248
|
+
`projectAgentHistory` converts canonical engine records into provider-valid
|
|
249
|
+
`AgentModelMessage[]` and pairs tool calls/results in persisted causal order. Adjacent
|
|
250
|
+
parallel calls stay in one assistant round and their adjacent results stay in
|
|
251
|
+
one tool round; a dependent call after those results starts a new assistant
|
|
252
|
+
round, and trailing final text remains after the last tool result. Provider-required metadata is kept
|
|
253
|
+
in a versioned opaque envelope and omitted from product delivery by default.
|
|
254
|
+
`projectAgentHistoryDetailed` additionally returns one inspectable decision per canonical record;
|
|
255
|
+
leading assistant records, crash drafts and unmatched tool chronology are never silently passed to
|
|
256
|
+
the provider.
|
|
257
|
+
|
|
258
|
+
`selectAgentHistory` is the non-destructive context-window selector. It removes only whole oldest
|
|
259
|
+
complete turns, protects system/summary, incomplete and configured recent turns, and reports every
|
|
260
|
+
keep/remove reason with measured/estimated/unavailable token provenance. An oversized protected turn
|
|
261
|
+
returns `oversized`; unavailable accounting returns `unavailable` without invented arithmetic.
|
|
262
|
+
|
|
263
|
+
`ComposedAgentPrompt.instructions` accepts `AgentInstructions` (a string, one
|
|
264
|
+
`AgentModelSystemMessage`, or an ordered array of `AgentModelSystemMessage`).
|
|
265
|
+
Use `adaptInstructions` when a provider needs cache control or provider options on
|
|
266
|
+
the system message:
|
|
267
|
+
|
|
268
|
+
```ts
|
|
269
|
+
prompt({
|
|
270
|
+
context,
|
|
271
|
+
signal,
|
|
272
|
+
adaptInstructions: (content) => ({
|
|
273
|
+
role: 'system',
|
|
274
|
+
content,
|
|
275
|
+
cacheControl: { type: 'ephemeral' },
|
|
276
|
+
}),
|
|
277
|
+
})
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Attachments and generated files remain application-owned. The runtime only
|
|
281
|
+
stores a reference returned by `persistGeneratedFile`; it never silently puts
|
|
282
|
+
base64 blobs into the neutral history store.
|
|
283
|
+
|
|
284
|
+
To send a stored attachment back to a multimodal model, configure
|
|
285
|
+
`history.resolveFile`. It maps the neutral file reference to tagged
|
|
286
|
+
`AgentModelFileData` (`{ type: 'data' | 'url' | 'reference' | 'text', ... }`). Without a resolver the
|
|
287
|
+
`unresolvedFile` policy applies, and it is **`omit`** by default: the file part
|
|
288
|
+
simply does not reach the provider. Choose `text` for a describing placeholder —
|
|
289
|
+
the filename or media type, never the storage reference, because that string is
|
|
290
|
+
an address inside your infrastructure and this content travels upstream — or
|
|
291
|
+
`error` to fail loudly. The `error` message does name the reference: it is
|
|
292
|
+
thrown into your process, where you are owed the whole story.
|
|
293
|
+
|
|
294
|
+
## Compaction
|
|
295
|
+
|
|
296
|
+
`structuredCompaction` summarizes complete provider-valid turn groups outside
|
|
297
|
+
the store lock, then calls `replaceCompactedRange` against the exact snapshot
|
|
298
|
+
version. A concurrent input produces `conflict`; the stale summary is not
|
|
299
|
+
applied. Summary records use the dedicated `summary` role and project to a
|
|
300
|
+
provider system message. The consumer supplies the structured summary schema
|
|
301
|
+
and prompt. Pass `previousSummary` for a direct call, or configure
|
|
302
|
+
`readPreviousSummary` for runtime-managed compaction, to merge and atomically
|
|
303
|
+
replace a leading summary on the next compaction.
|
|
304
|
+
Set `maxAttempts` to allow bounded conflict recovery. Every retry reloads the snapshot, reselects the
|
|
305
|
+
eligible range and recomputes the summary; the stale summary is never retried. Inside
|
|
306
|
+
`createAgentRuntime`, `history.compact` runs after `models.resolve` and receives the resolved
|
|
307
|
+
`model` descriptor (including `contextWindow`), `tools`, and `context`. `structuredCompaction`'s
|
|
308
|
+
`summarize` callback may return either the parsed summary directly or `{ summary, usage }` so
|
|
309
|
+
`structuredCompaction` accumulates `usage` across `maxAttempts` CAS retries and hands it directly to
|
|
310
|
+
run totals and `onStepSpend`.
|
|
311
|
+
|
|
312
|
+
### Recovering a prefix after a failed turn
|
|
313
|
+
|
|
314
|
+
The default evidence policy omits failed assistants. A failed turn therefore stops the
|
|
315
|
+
compactable prefix, including completed turns after it. A terminal failure is not an
|
|
316
|
+
unanswered tool call, but opting its partial evidence into a summary is an explicit host
|
|
317
|
+
decision. Use the existing `evidencePolicy: { failedAssistant: 'assistant-marked' }` on
|
|
318
|
+
`structuredCompaction` (or `selectCompactableHistory`) when that evidence is wanted.
|
|
319
|
+
The same policy belongs on the summarizer's history projection and on any corresponding
|
|
320
|
+
token-budget selection. Stored statuses remain unchanged.
|
|
321
|
+
|
|
322
|
+
The summarizer receives **raw** `eligibleMessages`, not provider messages and not an
|
|
323
|
+
automatic failure marker. Project them with the same policy before sending them to a
|
|
324
|
+
model, and preserve failed outcomes in the application's structured summary and prompt:
|
|
325
|
+
|
|
326
|
+
```ts
|
|
327
|
+
const evidencePolicy: AgentHistoryEvidencePolicy = {
|
|
328
|
+
failedAssistant: 'assistant-marked',
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Inside structuredCompaction({ evidencePolicy, ... }).summarize:
|
|
332
|
+
const projected = await projectAgentHistoryDetailed(eligibleMessages, {
|
|
333
|
+
evidencePolicy,
|
|
334
|
+
incompleteToolTurn: 'error',
|
|
335
|
+
})
|
|
336
|
+
const failedMessageIds = eligibleMessages
|
|
337
|
+
.filter(message => message.role === 'assistant' && message.status === 'failed')
|
|
338
|
+
.map(message => message.id)
|
|
339
|
+
// Pass projected.messages, projected.system and failedMessageIds to the host's
|
|
340
|
+
// summarizer. Its schema/prompt must retain failures and uncertain effects as
|
|
341
|
+
// such, merge previousSummary, and never describe partial output as success.
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
An opted-in failed assistant projects an explicit non-success marker even when it has
|
|
345
|
+
no text or only control parts. A dangling call, unresolved approval, invalid result
|
|
346
|
+
chronology or a user input with no assistant remains a barrier under either policy.
|
|
347
|
+
Raw whole-turn completeness does not guarantee that every record can be projected:
|
|
348
|
+
for example, a call and its result split across records may be rejected by the projector.
|
|
349
|
+
`incompleteToolTurn: 'error'` makes that rejection stop summarization; the original history
|
|
350
|
+
stays canonical. A host with such records must use a status-aware summarizer that explicitly
|
|
351
|
+
represents every relevant record, or retain the range. Do not silently summarize an omitted
|
|
352
|
+
exchange, filter the failed record out of the replacement range, rewrite its status or skip
|
|
353
|
+
over an incomplete turn. The replacement remains one contiguous prefix under snapshot CAS.
|
|
354
|
+
|
|
355
|
+
Provider chronology and external effect authority answer different questions (ADR 0269).
|
|
356
|
+
A matching `tool-result` with `outcome: 'error'` and an application code such as `UNKNOWN`
|
|
357
|
+
closes the provider exchange; it does **not** prove the external effect failed or succeeded.
|
|
358
|
+
Compaction changes the model-history projection, not the canonical event journal or the
|
|
359
|
+
retained terminal admission receipt. The `durability/effect` intent, accepted proof and
|
|
360
|
+
uncertain outcome remain available after compaction and archive restore. A reconstructed
|
|
361
|
+
`createLocalStepDurability` using the original `(conversationId, runId, effectName)` returns
|
|
362
|
+
the accepted proof, reconciles a bare intent, or returns `uncertain` without calling `run`
|
|
363
|
+
again. It does not deduplicate a new run or a newly named effect. Standalone effect callers
|
|
364
|
+
still own the exclusive execution lease; sharing a ledger is not an atomic claim.
|
|
365
|
+
An application-owned receipt outside that journal retains its own recovery rules and must
|
|
366
|
+
not be discarded because a history turn became compactable.
|
|
367
|
+
|
|
368
|
+
### Compacting without the store
|
|
369
|
+
|
|
370
|
+
The *selection* inside compaction needs no store, no version and no runtime, so
|
|
371
|
+
it is published on its own as `selectCompactableHistory` — for an application
|
|
372
|
+
that drives the model itself and keeps its own history (→ ADR 0142):
|
|
373
|
+
|
|
374
|
+
```ts
|
|
375
|
+
import { selectCompactableHistory } from 'stitchkit/agent-runtime'
|
|
376
|
+
|
|
377
|
+
const { leadingSummary, compactable, retained } = selectCompactableHistory({
|
|
378
|
+
messages,
|
|
379
|
+
keepRecentTurns: 3,
|
|
380
|
+
})
|
|
381
|
+
if (compactable.length > 0) {
|
|
382
|
+
const summary = await summarize(compactable, leadingSummary)
|
|
383
|
+
messages = [summary, ...retained] // replace the old summary, never stack one
|
|
384
|
+
}
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
`compactable` is the oldest **whole complete** turns and `retained` is
|
|
388
|
+
everything the model must still hear; together they are the input, in order. A
|
|
389
|
+
turn holding a tool call whose result never arrived is never eligible, and
|
|
390
|
+
neither is anything after it: half a turn hands the provider a call with no
|
|
391
|
+
result, which most of them refuse outright.
|
|
392
|
+
|
|
393
|
+
`structuredCompaction` calls this same function, so the published selection and
|
|
394
|
+
the runtime's cannot drift into two behaviours. What it adds is the part that
|
|
395
|
+
does need the store — writing the result back under a version check.
|
|
396
|
+
|
|
397
|
+
Deciding *when* to compact is yours: `AgentRuntimeRunContext.contextUsage`
|
|
398
|
+
carries the last step's prompt size beside the model's window, and dividing them
|
|
399
|
+
is one line where the threshold is decided. The core does not own that ratio, on
|
|
400
|
+
purpose — see ADR 0142 for what it publishes and what it declines to.
|
|
401
|
+
|
|
18
402
|
## Observability
|
|
19
403
|
|
|
20
404
|
`createAgentObservability` emits a separate operator-only `AgentRunEvent`. It
|
|
@@ -239,158 +623,3 @@ Replace direct unlogged model calls with `invocations.complete` (or `completeTex
|
|
|
239
623
|
authorization and a retained payload key, and pass the same ledger in the agent's
|
|
240
624
|
`invocations` option. Use the returned invocation ID and the paginated `read` method
|
|
241
625
|
for receipt queries; do not import runtime internals.
|
|
242
|
-
|
|
243
|
-
==============================================================================
|
|
244
|
-
# API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
|
|
245
|
-
==============================================================================
|
|
246
|
-
|
|
247
|
-
## `stitchkit/agent-runtime`
|
|
248
|
-
|
|
249
|
-
Server-only, peer-free optional application runtime. Runs models exclusively through `AgentModelDriver` (one provider call per step) with no AI SDK dependency. See the
|
|
250
|
-
[agent runtime guide](../guide/agent-runtime.md).
|
|
251
|
-
|
|
252
|
-
| Export | Kind | Summary |
|
|
253
|
-
|--------|------|---------|
|
|
254
|
-
| `createAgentRuntime` | function | compose durable acceptance, native `AgentModelDriver` step loop, tool parsing/validation, WebCrypto HMAC-SHA256 tool approvals, `beforeStepToolCalls`, bounded terminal continuations (`maxContinuations`), `onAttemptDiscarded`, `onToolInputStart`, checkpoints, coordination, managed tools and winner-only terminal publication; reconciles same-owner terminal/interrupt/head CAS races before releasing the lane |
|
|
255
|
-
| `createDeferredAgentToolSurface` | function | bounded canonical catalog search plus durable same-run activation of direct `mountAgentTools` tools; supports one immutable surface or a finite identity-specific registry |
|
|
256
|
-
| `DeferredAgentToolSearchInputSchema` / `DeferredAgentToolMatchSchema` / `DeferredAgentToolReceiptSchema` | schema | bounded search input, public match and versioned durable selection receipt |
|
|
257
|
-
| `DeferredAgentToolSurfaceConfig` / `DeferredAgentToolCommonConfig` / `DeferredAgentToolSurfaceDefinition` / `DeferredAgentToolController` | _type_ | finite catalogs, selector, pin, budget and `mount`/`prepareStep`/`repairToolCall` composition contracts |
|
|
258
|
-
| `DeferredAgentRuntimeToolDefinition` / `DeferredAgentToolMountConfig` | _type_ | peer-free Agent-only runtime definition and canonical mount configuration accepted by the controller |
|
|
259
|
-
| `DeferredAgentToolManifestEntry` / `DeferredAgentToolSearchContext` / `DeferredAgentToolReceipt` | _type_ | canonical selector input and inferred durable receipt records |
|
|
260
|
-
| `DeferredAgentToolEvent` | _type_ | PII-free search/step evidence with surface, provenance, counts, canonical schema bytes and ceilings |
|
|
261
|
-
| `defineAgentProtocol` | function | declare context, input metadata, canonical parts and optional pre-CAS terminal acceptance (`allow-empty`, `require-output` or callback returning `AgentTerminalAcceptanceDecision`) |
|
|
262
|
-
| `hasAgentTerminalOutput` | function | generic `require-output` predicate for non-blank text, generated files, structured provider parts and explicit tool-only policy stops |
|
|
263
|
-
| `carriedToolWork` | function | pure helper returning whether any completed `AgentStepResult` performed client or provider tool work |
|
|
264
|
-
| `AgentTerminalAcceptanceDecision` | _type_ | `boolean \| { action: 'accept' } \| { action: 'reject' } \| { action: 'continue', message, instructions? }` returned by `protocol.acceptTerminal` for bounded continuations (capped by `loop.maxContinuations`, default 3) |
|
|
265
|
-
| `AgentMessageSchema` / `AgentRunSchema` / `AgentSnapshotSchema` | schema | versioned canonical engine records |
|
|
266
|
-
| `AgentRunQueuePrioritySchema` | schema | durable opt-in priority for queued `interrupt-next` runs |
|
|
267
|
-
| `AgentRuntimeStore` | _type_ | aggregate CAS transaction boundary for message, run and compaction mutations |
|
|
268
|
-
| `BranchAgentConversationInputSchema` / `BranchAgentConversationInput` | schema / _type_ | strict branch request: stable request key, empty destination, settled conversation boundary or archive bytes, fresh artifact authorization, and `applicationFiles` — `{ reference, destinationReference }` pairs for file parts the application stores; an undeclared non-spill file reference refuses the branch. Spills validly retired by `spill/deleted` cross as deterministic rekeyed history (emitting an inert `runtime/branch-observation` across `throughRunId` cutoffs) while missing or inconsistent spills refuse with `integrity`. `applicationKeys` declares, once each, runtime reference names such as `messageId` or `runId` that are the application's own data inside its JSON — `sourceIdentity: 'refuse'` (default) refuses a value naming the source, `'retain'` carries a value naming the source conversation, a run or a message byte for byte as a record of the past, and `'rekey-spill'` rekeys source spill references (live or legitimately expired) while still refusing foreign spills and all other source identities (→ ADR 0300, ADR 0328) |
|
|
269
|
-
| `AgentConversationBranchRefusedError` / `AgentBranchRefusalSchema` / `AgentBranchRefusal` / `AgentBranchRefusalCodeSchema` / `AgentBranchRefusalCode` | class / schemas / _types_ | a branch refusal: a `TypeError` whose `refusals` lists every refusal a declaration or authorization lifts (up to 100, `omittedRefusals` counts the rest), each with `code` and its address — event `seq`, `eventKind`, `messageId`, `toolName`, key `path`, attachment `reference` — never a value; `integrity` stops at once |
|
|
270
|
-
| `AgentConversationBranchPlanSchema` / `AgentConversationBranchPlan` / `AgentRuntimeStore.planConversationBranch` | schema / _type_ / method | what `branchConversation` would refuse for the same input, without writing: `ready`, `refusals`, `omittedRefusals`, `applicationFiles` (every non-spill attachment reference to grant and declare), `undeclaredKeys`, `fingerprint`, `sourceArchiveDigest` |
|
|
271
|
-
| `AgentConversationBranchReceiptSchema` / `AgentConversationBranchReceipt` | schema / _type_ | durable lineage: request fingerprint, source/destination identities, source sequence/version/digest and creation time |
|
|
272
|
-
| `AgentConversationBranchResultSchema` / `AgentConversationBranchResult` | schema / _type_ | `created` or `duplicate` with the same durable receipt; `AgentRuntimeStore.branchConversation` is optional for hand-written stores |
|
|
273
|
-
| `createAgentRuntimeStore` | function | build the aggregate store from one coherent transaction driver; framework owns every state transition; the store reports `capabilities` |
|
|
274
|
-
| `AgentRuntimeStoreCapabilities` / `AgentStoreOptionalCapability` | _type_ | `store.capabilities`, frozen: `{ archive, historyRestore, purge }` — whether the driver has `archive`, `history.restore` and `conversations`; a driver whose `archive` lacks `export` or `import` is refused when the store is built |
|
|
275
|
-
| `AgentStoreUnsupportedCapabilityError` | class | a `TypeError` with `.capability` (`'archive'` or `'historyRestore'`): `importConversation`, `branchConversation` or `planConversationBranch` got a source that needs a driver member the store lacks — without `archive`, an archive carrying spills or companion projections, or a branch source carrying spills; without `history.restore`, a compacted baseline — and refused it before writing anything |
|
|
276
|
-
| `AgentRuntimeStoreDriver` | _type_ | ORM-neutral transaction over a bounded head, normalized runs/admissions, product history, a **required** `events: { append, list }` ledger table, an optional `archive: { export, import }` for driver-owned durable payloads, and indexed run recovery; optional `{ access: 'read' }` selects a coherent read transaction while absent options remain write-safe |
|
|
277
|
-
| `recordAgentRetryDecision` / `AgentRetryPolicy` | function / _type_ | `loop.retry` policy and the ledger record of a retry decision: explicit retryability and backoff at a durable provider-step boundary |
|
|
278
|
-
| `AgentRuntimeHeadSchema` | schema | constant-size conversation identity plus monotonic runtime version |
|
|
279
|
-
| `AgentStoredRunSchema` | schema | canonical normalized run with an optional retained terminal assistant |
|
|
280
|
-
| `AgentAdmissionReceiptSchema` | schema | durable idempotency receipt with canonical input and assigned run/assistant identities |
|
|
281
|
-
| `AgentHistoryMutationSchema` | schema | typed canonical message mutation applied inside the winning state transaction |
|
|
282
|
-
| `RecoverAgentRunSchema` | schema | explicit abandon/requeue recovery decision; acquired runs require replay-safe evidence |
|
|
283
|
-
| `createMemoryAgentRuntimeStore` | function | process-local reference adapter, not production durability |
|
|
284
|
-
| `purgeAgentConversation` | function | dispatch optional atomic deletion; returns `unsupported`, `active`, `conflict`, `purged` or `already_purged` |
|
|
285
|
-
| `AgentConversationPurgeInputSchema` / `AgentConversationPurgeInput` | schema / _type_ | conversation ID and optional expected snapshot version |
|
|
286
|
-
| `AgentConversationPurgeResultSchema` / `AgentConversationPurgeResult` | schema / _type_ | typed deletion/refusal outcomes; active refusal includes run IDs |
|
|
287
|
-
| `AgentConversationPurgedError` | class | runtime mutation rejected because its conversation ID is permanently purged |
|
|
288
|
-
| `AgentConversationPurgeDriver` | _type_ | optional `driver.conversations` capability: serialized tombstone read and atomic removal of all owned records |
|
|
289
|
-
| `projectAgentHistory` | function | asynchronously project canonical records and resolved multimodal files into provider-valid peer-free `AgentModelMessage[]` |
|
|
290
|
-
| `defineModelRegistry` | function | typed language-model descriptors, capabilities and `AgentModelDriverFactory` construction |
|
|
291
|
-
| `AgentModelCatalogSchema` / `AgentModelCatalog` | schema / _type_ | provider-neutral complete/partial model catalog with separately sourced popularity, metrics, prices and observation time |
|
|
292
|
-
| `AgentModelCatalogEntrySchema` / `AgentModelCatalogEntry` | schema / _type_ | one canonical provider model descriptor with optional price, popularity and metric evidence |
|
|
293
|
-
| `AgentModelPriceSchema` / `AgentModelPrice` | schema / _type_ | normalized per-token input/output pricing and source currency |
|
|
294
|
-
| `AgentModelPopularitySchema` / `AgentModelPopularity` | schema / _type_ | independently sourced ranked popularity observation with window and timestamp |
|
|
295
|
-
| `AgentModelMetricSchema` / `AgentModelMetric` | schema / _type_ | independently sourced benchmark measurement with provenance and observation time |
|
|
296
|
-
| `AgentModelCatalogProvider` | _type_ | abortable live catalog loader supplied by a provider adapter or application |
|
|
297
|
-
| `AgentModelSearchInputSchema` / `AgentModelSearchInput` | schema / _type_ | bounded catalog text query and result ceiling |
|
|
298
|
-
| `AgentModelSearchResultSchema` / `AgentModelSearchResult` | schema / _type_ | exact bounded catalog projection with total match count |
|
|
299
|
-
| `searchAgentModelCatalog` | function | deterministic bounded search over a loaded canonical catalog |
|
|
300
|
-
| `AgentModelSelectionSchema` / `AgentModelSelection` / `AgentModelSelectionStore` | schema / _type_ | durable per-conversation model choice; runtime resolvers receive run and snapshot to recover the model pinned to input metadata |
|
|
301
|
-
| `createMemoryAgentModelSelectionStore` | function | process-local selection reference adapter |
|
|
302
|
-
| `AgentConversationReader` | _type_ | optional bounded conversation-summary and message-history reader; `messages` takes `includeCompacted` and every page names its `compacted` ids; not part of the required runtime store contract |
|
|
303
|
-
| `AgentConversationSummarySchema` / `AgentConversationSummary` | schema / _type_ | bounded durable conversation list item with version, activity and preview |
|
|
304
|
-
| `AgentConversationPageSchema` / `AgentConversationPage` | schema / _type_ | cursor-paged conversation summaries |
|
|
305
|
-
| `AgentConversationMessagePageSchema` / `AgentConversationMessagePage` | schema / _type_ | cursor-paged durable message history |
|
|
306
|
-
| `composeAgentPrompt` | function | ordered prompt contributions and provenance-aware signed context budget; irreducible reservation deficits are `oversized`, not compactable history |
|
|
307
|
-
| `SeedConversationInputSchema` / `SeedConversationInput` | schema / _type_ | atomic once-seeding input; partial imported identity sets are refused |
|
|
308
|
-
| `AgentSeedReceiptSchema` / `AgentSeedReceipt` | schema / _type_ | durable seed receipt retained beyond compaction and implemented by custom store drivers |
|
|
309
|
-
| `StepRunOptions` | _type_ | per-step options of the durability engine (`stitchkit/tools`) as the runtime drives it |
|
|
310
|
-
| `DURABILITY_STEP_EVENT_KIND` | const | the ledger event kind a recorded step is written under |
|
|
311
|
-
| `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 |
|
|
312
|
-
| `structuredCompaction` | function | summarize a provider-valid snapshot range and replace it through CAS |
|
|
313
|
-
| `selectCompactableHistory` | function | which oldest whole complete turns may be summarised away — the half of compaction that needs no store (→ ADR 0142) |
|
|
314
|
-
| `SelectCompactableHistoryOptions` / `CompactableHistory` | _type_ | message list, retained-turn count and evidence policy in; `leadingSummary`, `compactable` and `retained` out |
|
|
315
|
-
| `createAgentSessionCoordinator` | function | strict process-local queue/interrupt/supersede lifecycle |
|
|
316
|
-
| `AgentRuntimeStopPolicy` | _type_ | named stop rule `AgentRuntimeStopPolicy<CONTEXT = unknown>` persisted and published on policy stop; `when` receives `AgentStepResult[]` plus the run context `prepareStep` gets (`context`, `run`, `signal`, `toolFenceLifecycle`, `contextUsage`) |
|
|
317
|
-
| `AgentRuntimePrepareStep` | _type_ | per-run controlled step callback with typed domain context and managed run signal/fence |
|
|
318
|
-
| `AgentContextOverflowError` | class | deliberate application budget refusal thrown from `loop.prepareStep`; terminalizes as `context_overflow` without classifying arbitrary error text |
|
|
319
|
-
| `AgentRuntimeRecordIds` | _type_ | optional caller-provided input, run and assistant IDs for stable application records |
|
|
320
|
-
| `AgentRuntimeAdmission` | _type_ | canonical committed input, assigned run, pending assistant projection, compatibility IDs and snapshot version |
|
|
321
|
-
| `AgentAdmissionEventSchema` | schema | post-commit admission projection; removes store rereads but does not imply exactly-once delivery |
|
|
322
|
-
| `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 |
|
|
323
|
-
| `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
|
|
324
|
-
| `AgentRuntimeAbandonInput` | _type_ | one known orphan identity, expected revision and mandatory stale-owner evidence for `runtime.abandon()` |
|
|
325
|
-
| `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
|
|
326
|
-
| `AgentRunUnsettledError` | class | rejects `result` when the store never answered: `.run` is still active with no executor, close it with `runtime.abandon()` |
|
|
327
|
-
| `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
|
|
328
|
-
| `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
|
|
329
|
-
| `AgentHistoryProjectionOptions` | _type_ | storage-neutral file resolver, explicit unresolved-file behavior, and how an interrupted turn reaches the model (`interruptedAssistant`) |
|
|
330
|
-
| `createAgentToolFenceLifecycle` | function | pre-effect and post-effect run ownership fence for `mountAgentTools` / `mountAgent`; compose beside application idempotency for [durable operations](../guide/mcp-and-agents.md#durable-application-owned-execution) |
|
|
331
|
-
| `AgentRuntimeEventSchema` | schema | transient stream lifecycle plus post-commit admission/checkpoint/run-state/run-operation/terminal projections |
|
|
332
|
-
| `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 |
|
|
333
|
-
| `RecordRunOperationSchema` / `RecordRunOperation` | schema / _type_ | owner/fencing/revision-checked mutation of `AgentRun.lastOperation` |
|
|
334
|
-
| `createAgentObservability` | function | separate agent-run sink over the shared bounded observability lifecycle |
|
|
335
|
-
| `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 |
|
|
336
|
-
| `AgentStepFinishedEventSchema` / `AgentStepFinishedEvent` | schema / _type_ | one completed provider step, abandoned retry attempt, or compaction call with required usage, optional provider response identity, `attempt`, `phase`, `provider`, and isolated `spendHookError` diagnostics |
|
|
337
|
-
| `AgentStepSpendPhaseSchema` / `AgentStepSpendPhase` | schema / _type_ | lifecycle phase (`'step' \| 'abandoned-attempt' \| 'compaction'`) that produced a billed spend fact |
|
|
338
|
-
| `AgentStepSpendSchema` / `AgentStepSpend` | schema / _type_ | canonical per-step spend fact delivered to `AgentRuntimeConfig.onStepSpend` (`conversationId`, `runId`, `step`, `attempt`, `phase`, `model?`, `provider?: { key, upstream? }`, `response?`, `usage`, `trace?`) |
|
|
339
|
-
|
|
340
|
-
### Durable capability layer
|
|
341
|
-
|
|
342
|
-
| Export | Kind | Summary |
|
|
343
|
-
|--------|------|---------|
|
|
344
|
-
| `AgentConversationArchiveSchema` / `AgentConversationArchive` / `encodeAgentConversationArchive` / `decodeAgentConversationArchive` / `canonicalAgentJson` | schema / _type_ / functions | canonical validated conversation archive (`canonicalAgentJson` is `canonicalJson` with the node and byte limits at their maximum, reading `-0` as `0` like `z.json()`) with exact ledger events, recovery projection and durable spill payloads |
|
|
345
|
-
| `AgentStoreEventEnvelopeSchema` / `AgentStoreEventEnvelope` / `AgentStoreEventKindSchema` / `AgentStoreEventKind` / `AgentStoreEventPageSchema` / `AgentStoreEventPage` | schema / _type_ | append-only event envelope, closed current vocabulary (including `provider/request` and `provider/response`) and bounded page |
|
|
346
|
-
| `AppendAgentStoreEventSchema` / `AppendAgentStoreEvent` / `ReadAgentStoreEventsSchema` / `ReadAgentStoreEvents` | schema / _type_ | required append and bounded-read store contracts |
|
|
347
|
-
| `AgentStoreTransitionSchema` / `AgentStoreTransition` / `AgentStoreEventDraft` / `AgentStoreEventDecodeAccepted` / `AgentStoreEventDecodeIgnored` / `AgentStoreEventDecodeResult` / `decodeAgentStoreEvent` | schema / _types_ / function | normalized runtime mutations, append drafts and strict current/ignorable future-event decoding outcomes |
|
|
348
|
-
| `AgentStoreTransitionRecordSchema` / `AgentStoreTransitionRecord` | schema / _type_ | persisted journal payloads: full runtime mutations or hash-only streaming checkpoint observations with numeric part/byte counts; inspection does not authorize replay |
|
|
349
|
-
| `defineAgentProjection` / `AgentProjectionDefinition` / `AgentProjectionValue` / `createAgentProjectionRegistry` / `createAgentProjectionStore` | functions / _type_ | deterministic folds with persisted version and honest `uptoSeq` checkpoints |
|
|
350
|
-
| `agentSummaryProjection` / `agentUsageProjection` / `agentOutlineProjection` | constants | built-in list summary, provenance-carrying usage and request outline projections |
|
|
351
|
-
| `agentConversationCardProjection` / `agentStateSlotsProjection` / `agentScheduleSummaryProjection` | constants | focused card, durable-state and schedule lifecycle projections |
|
|
352
|
-
| `defineStateSlot` / `AgentStateSlotDefinition` / `AgentStateSlotStore` / `AgentStateSlotValue` / `AnyAgentStateSlot` / `createAgentStateSlotStore` / `renderAgentStateSlots` | functions / _types_ | typed durable state written as ledger events and injected on every provider request |
|
|
353
|
-
| `agentGoalStateSlot` / `agentTodoStateSlot` / `createAgentStateTools` / `AgentStateToolsConfig` / `AGENT_STATE_TOOL_DESCRIPTORS` | constants / function / _type_ | built-in goal/todo state, `goal_*` / `todo_write` Agent tools bound to the conversation of the run context `tools()` receives, and their deeply frozen non-executable static catalog descriptors |
|
|
354
|
-
| `AgentProcessSandbox` | _type_ | host-provided process sandbox handle accepted by agent coding tools (probe helpers and grade/restriction schemas live in `stitchkit/agent-runtime/sandbox`) |
|
|
355
|
-
| `AgentSandboxProcess` / `AgentSandboxOutputStream` | _types_ | structural child/output interface for optional lifecycle-owned `AgentProcessSandbox.spawn`, without Node ambient type dependencies |
|
|
356
|
-
| `AgentEventSearchResultSchema` / `AgentEventSearchResult` / `createAgentEventSearch` / `createAgentEventSearchTools` / `AgentEventSearchToolsConfig` / `AGENT_EVENT_SEARCH_TOOL_DESCRIPTORS` | schema / _types_ / functions / constant | authorized event search (SQLite FTS5 or Postgres `tsvector`, ADR 0315) with exact event addresses, `session_*` tools for the conversation of the run context `tools()` receives, and their deeply frozen non-executable static catalog descriptors |
|
|
357
|
-
| `PostgresAgentEventSearchConfig` | _type_ | the Postgres index's options for `createAgentEventSearch({ postgres })` — `diacritics` (`preserve` / `unaccent`), `maxIndexedChars`, `maxSyncEvents` |
|
|
358
|
-
| `createAgentSpillStore` | function | durable content-address-checked artifact storage, bounded read/search, retention facts and archive participation |
|
|
359
|
-
| `AgentScheduleSchema` / `AgentSchedule` / `AgentScheduleService` / `AgentScheduleDeliveryOutcomeSchema` / `AgentScheduleDeliveryOutcome` / `createAgentScheduleService` / `AgentScheduleServiceConfig` / `createAgentScheduleTools` / `AgentScheduleToolsConfig` / `AGENT_SCHEDULE_TOOL_DESCRIPTORS` | schemas / _types_ / functions / constant | durable `at`/`after`/timezone-explicit `every` schedules over the store's `AgentCompanionHost`, required `maxActivePerConversation` and `minIntervalMs`, indexed retry eligibility, typed retry/terminal failure (any other returned value delivers), `maxAttempts` (default 1000) per occurrence — a one-off ends `failed`, a recurring schedule skips to its next slot — bounded dispatch and fenced stable occurrence identity (ADR 0202); the tools are bound to the conversation of the run context `tools()` receives, with deeply frozen non-executable static catalog descriptors |
|
|
360
|
-
| `AgentChildBudgetSchema` / `AgentChildBudget` / `AgentChildStateSchema` / `AgentChildState` / `AgentChildRecordSchema` / `AgentChildRecord` | schema / _type_ | durable child graph, bounded seed and measured budget state |
|
|
361
|
-
| `AgentChildBlockingKindSchema` / `AgentChildBlockingKind` / `AgentChildBlockingSourceSchema` / `AgentChildBlockingSource` / `AgentChildBlockingEventSchema` / `AgentChildBlockingEvent` / `AgentChildBlockingDecision` | schemas / _types_ | parent-owned request identities; responses discriminate approval decisions from JSON input values |
|
|
362
|
-
| `AgentChildHandle` / `AgentChildManager` / `AgentChildManagerConfig` / `AgentChildRemainingBudget` / `createAgentChildManager` / `createAgentChildTools` / `AgentChildToolsConfig` / `AGENT_CHILD_TOOL_DESCRIPTORS` / `agentChildBudgetStopPolicy` | _types_ / functions / constant | host execution port, child lifecycle with required `remainingBudget` and `maxActiveChildren`, cascade (given to `createAgentRuntime` as `children`), messaging, Agent tools bound to the parent conversation of the run context `tools()` receives (plus their deeply frozen static catalog descriptors), and the child runtime's own budget stop policy — `recordStepUsage` at every step boundary, `policy_stop` as `child-budget` when spent |
|
|
363
|
-
| `AgentCompanionHost` / `AgentCompanionScope` / `AgentSqlSession` / `AgentSqlTables` / `AgentSqlValue` | _types_ | the store's companion host — one store transaction with the purge check and the event append (`transaction(conversationId, work)`), a read transaction (`read(work)`), the companion tables — given by the SQLite and Postgres stores and taken by every companion |
|
|
364
|
-
| `AgentToolDefinition` / `AgentToolDescriptor` | _types_ | peer-neutral executable shape returned by the bound agent-only tool factories and its non-executable static catalog descriptor shape (assignable to `SurfaceRuntimeToolDefinition` without an active run) |
|
|
365
|
-
| `AgentProviderStreamCutError` / `AgentProviderStreamCutErrorOptions` | class / _type_ | explicit retryable provider stream truncation evidence and constructor options |
|
|
366
|
-
|
|
367
|
-
### Native model port, driver composition and peer-free completions
|
|
368
|
-
|
|
369
|
-
`stitchkit/agent-runtime` executes models through `AgentModelDriver` — one provider call per step,
|
|
370
|
-
no SDK retries and no tool execution inside the driver. `completeText` and `completeObject` reuse
|
|
371
|
-
the same native step execution without requiring a store. → ADR 0336.
|
|
372
|
-
|
|
373
|
-
| Export | Kind | Summary |
|
|
374
|
-
|--------|------|---------|
|
|
375
|
-
| `AgentModelDriver` / `AgentModelDriverFactory` | _type_ | single-step model port (`stream(request, signal)`) and provider factory registered in `defineModelRegistry` |
|
|
376
|
-
| `AgentModelRequest` / `AgentModelStream` / `AgentModelStreamPart` | _type_ | normalized single-step request (`instructions`, `messages`, `tools`, `toolChoice`, `responseFormat`, `cacheControl`, `settings`, `providerOptions`, `headers`, `correlation`) and ordered stream event union (including keepalive `ping`, multi-block reasoning/text/tool events with unified `toolCallId`, `file` with optional `filename`, and terminal `finish`) |
|
|
377
|
-
| `AgentModelToolSpec` / `AgentModelFunctionToolSpec` / `AgentModelProviderToolSpec` / `AgentModelJsonValue` / `AgentModelToolChoice` / `AgentModelCallSettings` / `AgentModelCorrelation` | _type_ | union of client function tool specs (JSON Schema 2020-12) and provider-native tool specs (`type: 'provider'` with `AgentModelJsonValue` config), tool-choice directive, call sampling settings and non-secret request correlation (`conversationId`, `runId`, `invocationId`, `attemptId`, `step`) |
|
|
378
|
-
| `AgentModelFinishReason` / `AgentModelResponseMetadata` / `AgentModelCostDetails` / `AgentStepTimings` / `AgentStepChunkIntervals` | _type_ | normalized step finish reason, response metadata (including server `modelId` and `timestamp`), optional provider-reported cost/BYOK breakdown (`promptCostUsd`, `outputCostUsd`, `isByok`), and measured step/response/tool/TTFT timings with optional inter-chunk interval percentiles (`min`, `p10`, `median`, `avg`, `p90`, `max`) |
|
|
379
|
-
| `wrapModelDriver` / `composeModelDrivers` | function | wrap one `AgentModelDriver` with one or an ordered outer-to-inner list of lifecycle decorators whose `onClose` runs once on finish, error, early stream cancellation, or abort |
|
|
380
|
-
| `AgentModelDriverDecorator` / `AgentModelDriverStreamOutcome` | _type_ | generic per-stream interceptor (`beforeStream`, `transformRequest`, `transformSignal`, `onPart`, `onClose`) and terminal stream outcome (`finished`, `errored`, `cancelled`) |
|
|
381
|
-
| `completeText` / `streamComplete` / `CompleteTextInput` / `CompleteTextOptions` / `CompletePromptInput` / `CompleteTextResult` / `CompleteTextStream` / `CompleteStreamPart` / `CompletePrepareStep` / `AgentCompleteStopPolicy` | functions / _types_ | peer-free single- or multi-step completion and standalone async-iterable streaming over any `AgentModelDriver` (no store required), with compile-time XOR on `prompt` vs `messages`, `retry`, `stopPolicies`, `idleTimeoutMs`, `onPart`, `headers`, tools, `prepareStep`, `repairToolCall`, timings and usage |
|
|
382
|
-
| `completeObject` / `CompleteObjectInput` / `CompleteObjectResult` | function / _types_ | peer-free structured-output completion emitting strict JSON Schema (`draft-2020-12` via `toJsonSchema(..., 'input')`), stripping strict-mode optional `null`s prior to Zod validation, and supporting multi-step tool loops |
|
|
383
|
-
| `AgentStructuredOutputError` / `AgentStructuredOutputErrorReason` / `AgentStructuredOutputErrorDetails` | class / _types_ | typed error thrown by `completeObject` with `reason` (`'truncated' \| 'tool-calls' \| 'content-filter' \| 'provider-error' \| 'interrupted' \| 'empty' \| 'invalid-json' \| 'schema-mismatch'`), `finishReason`, `rawText`, `steps`, and `usage` |
|
|
384
|
-
| `AgentRetryExhaustedError` / `AgentRetryExhaustedErrorDetails` / `AgentRetryAttemptRecord` | class / _types_ | typed error thrown when stateless completion retries exhaust `retry.maxAttempts` or `maxRetryDurationMs`, carrying every failed attempt, `lastError`, and accumulated billable `usage` |
|
|
385
|
-
| `AgentProviderError` / `AgentProviderErrorDetails` / `isAgentProviderError` | class / _type_ / function | canonical provider HTTP/envelope error carrying `provider`, `statusCode`, `code`, `errorType`, `requestId`, `retryAfterMs`, optional `retryable` (e.g. `false` when `x-should-retry: false`), `failureReason`, redacted safe message, and runtime type guard |
|
|
386
|
-
| `AgentUnknownToolError` / `AgentInvalidToolInputError` | class | PII-safe tool-dispatch errors for unknown/inactive tools and invalid JSON or Zod tool inputs |
|
|
387
|
-
| `AgentToolApprovalError` / `AgentToolApprovalErrorReason` / `AgentInvalidToolApprovalSignatureError` / `AgentToolCallNotFoundForApprovalError` | class / _type_ | typed failures and machine reason codes (`'invalid-signature' \| 'call-not-found' \| 'input-validation-failed' \| 'input-mutated' \| 'invalid-policy-decision' \| 'approval-unsupported'`) for invalid approval payloads, WebCrypto HMAC-SHA256 signature verification failure, unresolved approval call IDs, or standalone fail-closed `needsApproval` refusal |
|
|
388
|
-
| `AgentToolApprovalConfiguration` / `AgentToolApprovalDecision` / `AgentToolApprovalCallOptions` / `AgentToolApprovalToolRule` | _type_ | per-call or per-tool approval policy evaluated by the native step loop |
|
|
389
|
-
| `AgentStepToolCallBatchHook` / `AgentStepToolCallBatchInput` / `AgentStepToolCallBatchDecision` | _type_ | `loop.beforeStepToolCalls` whole-step batch policy invoked once all tool calls of a step are parsed and validated, able to refuse selected calls by `toolCallId` |
|
|
390
|
-
| `AgentToolCallRepairFunction` / `AgentToolCallRepairInput` | _type_ | first-class `repairToolCall` hook that rewrites an unknown, inactive, or invalid tool call before execution |
|
|
391
|
-
| `AgentPrepareStepInput` / `AgentPrepareStepResult` | _type_ | step-preparation input and per-step overrides (`driver`, `instructions`, `messages`, `activeTools`, `toolChoice`, `responseFormat`, `cacheControl`, sampling settings, `providerOptions`, `headers`) |
|
|
392
|
-
| `AgentStepResult` / `AgentStepContentPart` / `AgentStepToolCall` / `AgentStepToolResult` | _type_ | peer-free completed step record delivered to `prepareStep`, `stopPolicies`, and `onStepFinish` |
|
|
393
|
-
| `AgentModelMessageSchema` / `AgentModelMessage` / `AgentModelSystemMessageSchema` / `AgentModelSystemMessage` / `AgentModelUserMessageSchema` / `AgentModelUserMessage` / `AgentModelAssistantMessageSchema` / `AgentModelAssistantMessage` / `AgentModelToolMessageSchema` / `AgentModelToolMessage` / `AgentInstructions` | schemas / _types_ | canonical peer-free model-exchange message schemas and normalized instruction input |
|
|
394
|
-
| `AgentModelUserContentPartSchema` / `AgentModelUserContentPart` / `AgentModelAssistantContentPartSchema` / `AgentModelAssistantContentPart` / `AgentModelToolContentPartSchema` / `AgentModelToolContentPart` / `AgentToolModelContentPart` / `AgentToolModelOutputSchema` | schemas / _types_ | non-deprecated content part schemas (`text`, `reasoning`, `file`, `reasoning-file`, `tool-call`, `tool-result`, approvals, `custom`) and structured tool-output schema |
|
|
395
|
-
| `AgentModelFileDataSchema` / `AgentModelFileData` / `AgentGeneratedFile` / `AgentGeneratedFileData` | schema / _types_ | tagged file payload (`data`, `url`, `reference`, `text`) and generated model file (`mediaType`, `data`, optional `filename`, `url?`, lazy `base64`/`uint8Array`, `providerMetadata?`) handed to `persistGeneratedFile` |
|
|
396
|
-
| `AgentModelResponseFormatSchema` / `AgentModelResponseFormat` / `AgentCacheControlSchema` / `AgentCacheControl` / `AgentModelProviderOptionsSchema` / `AgentModelProviderOptions` / `AgentModelProviderOptionValue` | schemas / _types_ | portable structured-output format (`text`, `json-object`, `json-schema`), prompt-cache breakpoint directive (`ephemeral`, optional `'5m' \| '1h'` TTL), and namespaced provider options with recursive `AgentModelProviderOptionValue` supporting optional `undefined` keys under `exactOptionalPropertyTypes` |
|