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/application.txt
CHANGED
|
@@ -872,7 +872,9 @@ bot.catch(({ error }) => logger.error('Telegram handler failed', { error }))
|
|
|
872
872
|
const telegram = grammyBotResources({
|
|
873
873
|
bot,
|
|
874
874
|
dependsOn: [database, http], // what handlers need before the first update
|
|
875
|
-
configure: () =>
|
|
875
|
+
configure: async () => {
|
|
876
|
+
await bot.api.setMyCommands([{ command: 'start', description: 'Start' }])
|
|
877
|
+
},
|
|
876
878
|
onEnded: ({ error }) => stopProcess(error), // see below
|
|
877
879
|
})
|
|
878
880
|
|
package/llms/http.txt
CHANGED
|
@@ -14,7 +14,7 @@ Also read:
|
|
|
14
14
|
|
|
15
15
|
## `stitchkit/http`
|
|
16
16
|
|
|
17
|
-
An HTTP-only entrypoint for browsers, React Native/Hermes and servers. It exports the same `createClient`, `createClients`, `createHttpClient`, URL builders, client configuration types and `
|
|
17
|
+
An HTTP-only entrypoint for browsers, React Native/Hermes and servers. It exports the same `createClient`, `createClients`, `createHttpClient`, URL builders, client configuration types, `ApiError`, `readContractIdentity` (with its `ContractIdentity` result) and the stream line errors `StreamLineLimitError` / `StreamTruncatedLineError` as the root, without loading its optional Socket.IO graph, plus the `postMessage` bridge `ClientFetch` adapter and envelope schemas. Import shared contracts from `stitchkit/contract`.
|
|
18
18
|
|
|
19
19
|
```ts
|
|
20
20
|
import { createClients, createHttpClient } from 'stitchkit/http';
|
package/llms/live.txt
CHANGED
|
@@ -432,7 +432,9 @@ never runs.
|
|
|
432
432
|
- **It does not gate operations.** "Only from this machine" is a property of an
|
|
433
433
|
operation, and an operation is known after routing, not before it. Write it as
|
|
434
434
|
an auth rule over `ctx.ipAddress` — `isLoopbackAddress` is exported for
|
|
435
|
-
exactly that — where it composes with your other rules.
|
|
435
|
+
exactly that — where it composes with your other rules. Behind a proxy on the
|
|
436
|
+
same host every peer is loopback: resolve the visitor with `trustProxy` first
|
|
437
|
+
([server guide](./server.md#client-ip-behind-a-proxy)).
|
|
436
438
|
- **It does not re-check an open connection.** Both lanes check at admission.
|
|
437
439
|
- **It does not see an `OPTIONS` preflight** when `cors` is configured; that is
|
|
438
440
|
answered earlier. The preflight carries no operation and no body, and the
|
package/llms/observability.txt
CHANGED
|
@@ -601,18 +601,25 @@ each request.
|
|
|
601
601
|
A payload goes into an audit row only after `sanitizePayload`:
|
|
602
602
|
|
|
603
603
|
- **secret-named keys are masked** — a key whose words include a secret term is
|
|
604
|
-
redacted (`password`, `sessionToken`, `X-Api-Key`, `
|
|
605
|
-
…),
|
|
606
|
-
`
|
|
604
|
+
redacted (`password`, `passphrase`, `sessionToken`, `X-Api-Key`, `accessKey`,
|
|
605
|
+
`authorization`, `cookie`, …), a key written as one lowercase run that ends in
|
|
606
|
+
one (`newpassword`, `accesstoken`), and a key that ENDS in `auth`, `signature`,
|
|
607
|
+
`jwt`, `otp`, `pin` or `dsn` (`basicAuth`, `webhookSignature`, `SENTRY_DSN`),
|
|
608
|
+
while identifiers that merely contain one (`authorId`, `sessionCount`,
|
|
609
|
+
`tokenizer`, `pinned`) or only describe it (`signatureVersion`, `auth_date`,
|
|
610
|
+
a model token count such as `maxTokens` or `usage.total_tokens`)
|
|
611
|
+
survive. This applies wherever a key exists — an object field and
|
|
607
612
|
a `Map` entry alike, at any depth. A `Set` member has no key, so nothing there
|
|
608
613
|
is masked by name;
|
|
609
614
|
- **secrets are masked by their shape** in every string, whatever key holds
|
|
610
615
|
it — the secret half of a Telegram bot token (`123456:[redacted]`: the bot's
|
|
611
616
|
id stays, it tells two bots apart), the password in
|
|
612
|
-
`postgresql://user:password@host` (user, host and path stay),
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
617
|
+
`postgresql://user:password@host` (user, host and path stay), the user of an
|
|
618
|
+
`http(s)` / `ws(s)` address with no password (a Sentry DSN's key — a database
|
|
619
|
+
or SSH user stays), the credential after `Bearer`, a provider key (`sk-…`, `or-v1-…`, `AIza…`), a
|
|
620
|
+
JSON Web Token (`eyJ….eyJ….…`), and the value of a query parameter named as a
|
|
621
|
+
secret (`?access_token=`, `?api-key=`, `?key=`, `?sig=`). A URL in an error
|
|
622
|
+
message or a request log line is the usual way a token reaches a journal;
|
|
616
623
|
- **an error keeps what it says about itself** — its own fields (`error_code`,
|
|
617
624
|
`parameters`, a provider's `status`) are written beside `name`, `message`,
|
|
618
625
|
`stack` and `cause`, masked by the same rules; a field holding a class
|
|
@@ -791,8 +798,8 @@ use; future optional fields do not change callback arity.
|
|
|
791
798
|
|
|
792
799
|
`createObservability({ tools })` uses it already. Where the envelope was scrubbed to
|
|
793
800
|
`INTERNAL_SERVER_ERROR`, the row's `errorMessage` becomes the real message
|
|
794
|
-
instead of the placeholder
|
|
795
|
-
`
|
|
801
|
+
instead of the placeholder (a `ZodError` from handler code is one of these); a
|
|
802
|
+
truthful envelope (a thrown `AppError`, invalid input) is left alone, `errorCode` and `errorDetail` are untouched, and the
|
|
796
803
|
stack is not written — that is `onToolError`'s job, for a tracker that wants it.
|
|
797
804
|
The caller still receives the scrubbed envelope in every case: the raw text
|
|
798
805
|
reaches your server-side record, never the response. → ADR 0042
|
package/llms/server.2.txt
CHANGED
|
@@ -103,7 +103,7 @@ Runtime requirements and boundaries:
|
|
|
103
103
|
- **Origin trust and navigation lock-down.** A `postMessage` bridge has no loopback `Host` header,
|
|
104
104
|
so `createLocalHostGuard` does not apply. `serveBridge` validates the native container-reported
|
|
105
105
|
`origin` against the exact `origins` allow-list, strips `host`, `origin`, `x-forwarded-for`,
|
|
106
|
-
`x-real-ip` and `forwarded` from every frame, refuses a handler with `trustProxy
|
|
106
|
+
`x-real-ip` and `forwarded` from every frame, refuses a handler configured with `trustProxy`, and
|
|
107
107
|
optionally verifies a per-start `secret` in constant time. Refusal reasons are logged on the host
|
|
108
108
|
and never disclosed to the window. Because any page a WebView navigates to receives
|
|
109
109
|
`window.ReactNativeWebView`, always lock navigation down in the WebView itself
|
|
@@ -147,8 +147,8 @@ This endpoint is HTTP-only and cannot be multipart or exposed as a tool. The
|
|
|
147
147
|
router sets `ctx.rawBody` before JSON/Zod validation, so `onError` can inspect it
|
|
148
148
|
after malformed JSON or a schema failure. Endpoints without `rawBody: true` do
|
|
149
149
|
not retain the text. `maxJsonBodyBytes` may also be set once on `createServer` /
|
|
150
|
-
`createHandler`; a route value wins.
|
|
151
|
-
oversized stream before it is fully buffered. → ADR 0051
|
|
150
|
+
`createHandler`; a route value wins. Without either the ceiling is 1 MiB; every
|
|
151
|
+
limit aborts an oversized stream before it is fully buffered. → ADR 0051, ADR 0340
|
|
152
152
|
|
|
153
153
|
## Safelisted request bodies (beacons)
|
|
154
154
|
|
|
@@ -452,11 +452,16 @@ contract route does.
|
|
|
452
452
|
|
|
453
453
|
### Serving files & Range requests
|
|
454
454
|
|
|
455
|
-
`staticRoute(prefix, dir, { cacheControl })` serves a directory:
|
|
456
|
-
containment, then answers the file through `serveFile`, so a static
|
|
457
|
-
video carries `ETag`, `Last-Modified` and `Accept-Ranges`, revalidates
|
|
458
|
-
and seeks with `206`. `cacheControl` sets `Cache-Control` on every
|
|
459
|
-
default none is sent.
|
|
455
|
+
`staticRoute(prefix, dir, { cacheControl, allowedDotNames })` serves a directory:
|
|
456
|
+
it checks containment, then answers the file through `serveFile`, so a static
|
|
457
|
+
image or video carries `ETag`, `Last-Modified` and `Accept-Ranges`, revalidates
|
|
458
|
+
to `304` and seeks with `206`. `cacheControl` sets `Cache-Control` on every
|
|
459
|
+
answer; by default none is sent.
|
|
460
|
+
|
|
461
|
+
A path with a segment that starts with a dot — `/.env`, `/.git/config`,
|
|
462
|
+
`/assets/.npmrc` — answers `404`, so a hidden file that ends up in the served
|
|
463
|
+
directory never leaves it. Name the ones you mean to publish:
|
|
464
|
+
`allowedDotNames: ['.well-known']`.
|
|
460
465
|
|
|
461
466
|
```ts
|
|
462
467
|
import { createServer, staticRoute } from 'stitchkit/server'
|
package/llms/server.4.txt
CHANGED
|
@@ -311,7 +311,11 @@ Use it as `createMcpHandler`'s `auth`, or inside `createAuthHook`'s `resolve`.
|
|
|
311
311
|
|
|
312
312
|
`verifyJwt(token, secret)` verifies an HS256 JWT and returns its payload, or
|
|
313
313
|
throws `unauthorized`. It pins the algorithm (the token's own `alg` can never
|
|
314
|
-
pick the scheme),
|
|
314
|
+
pick the scheme), checks `exp` and `nbf`, and **requires `exp`**: a token
|
|
315
|
+
without one would stay valid for as long as the secret does. Pass
|
|
316
|
+
`expiration: 'optional'` only for tokens whose lifetime you bound elsewhere (a
|
|
317
|
+
session row, a revocation list); a present `exp` is still enforced. Sign with
|
|
318
|
+
`signJwt(payload, secret, { expiresInSec })`.
|
|
315
319
|
|
|
316
320
|
```ts
|
|
317
321
|
import { verifyJwt, extractToken } from 'stitchkit/server'
|
|
@@ -378,7 +382,7 @@ import { env } from './env'
|
|
|
378
382
|
const result = await verifyTelegramInitData({
|
|
379
383
|
initData,
|
|
380
384
|
botToken: env.BOT_TOKEN,
|
|
381
|
-
maxAgeSeconds: 3600, //
|
|
385
|
+
maxAgeSeconds: 3600, // default: one day
|
|
382
386
|
})
|
|
383
387
|
if (!result.valid) {
|
|
384
388
|
// 'missing-hash' | 'signature-mismatch' | 'malformed' | 'expired'
|
|
@@ -401,9 +405,10 @@ A bot meets the same person as grammY's `ctx.from`, in Telegram's `snake_case`;
|
|
|
401
405
|
`parseTelegramUser(ctx.from)` gives the same `TelegramUser`, so one
|
|
402
406
|
`ensureAccount(user)` serves the Mini App and the chat.
|
|
403
407
|
|
|
404
|
-
`maxAgeSeconds`
|
|
405
|
-
|
|
406
|
-
|
|
408
|
+
`maxAgeSeconds` defaults to one day (`86400`): a signed string is otherwise a
|
|
409
|
+
credential that never expires, so there is no unbounded mode. Set the lifetime
|
|
410
|
+
your session is worth — shorter for a sign-in exchange, longer for a Mini App
|
|
411
|
+
kept open for days.
|
|
407
412
|
|
|
408
413
|
The module is server-only and pulls in no bot library — the token never belongs
|
|
409
414
|
in a browser bundle. `stitchkit/application/grammy` remains the lifecycle
|
|
@@ -866,21 +871,28 @@ const onError = createErrorHook({
|
|
|
866
871
|
Synchronous callbacks and renderers that declare fewer parameters continue to
|
|
867
872
|
work normally.
|
|
868
873
|
|
|
869
|
-
|
|
870
|
-
|
|
874
|
+
Input that fails the contract's `params` / `input` schema reaches `render` as
|
|
875
|
+
`VALIDATION_ERROR` 400 — a client fault is an honest 400, not a 500 — and the
|
|
871
876
|
offending fields arrive as structured `info.details.issues`, so your `render`
|
|
872
877
|
can surface them to a machine client without parsing the message.
|
|
873
878
|
|
|
879
|
+
Only the contract boundary produces `VALIDATION_ERROR`. A `ZodError` your
|
|
880
|
+
handler throws — parsing an upstream answer, a database row, a config value —
|
|
881
|
+
is the server's own schema failing: it is answered as `INTERNAL_SERVER_ERROR`
|
|
882
|
+
500 with the generic message, and the `ZodError` text goes to the log and the
|
|
883
|
+
audit row, never to the caller. To refuse the caller's input from inside a
|
|
884
|
+
handler, throw `badRequest(message, details)` (or an `AppError`) yourself.
|
|
885
|
+
|
|
874
886
|
If you write a **bespoke** `onError` instead of using `createErrorHook`, run the
|
|
875
|
-
thrown value through the exported `normalizeError` to get the same classification
|
|
876
|
-
|
|
877
|
-
|
|
887
|
+
thrown value through the exported `normalizeError` to get the same classification.
|
|
888
|
+
Invalid input reaches your hook as an `AppError` with code `VALIDATION_ERROR`,
|
|
889
|
+
its `details.issues` and the `ZodError` as `cause`:
|
|
878
890
|
|
|
879
891
|
```ts
|
|
880
892
|
import { normalizeError } from 'stitchkit/server'
|
|
881
893
|
|
|
882
894
|
onError: (ctx, err) => {
|
|
883
|
-
const e = normalizeError(err) //
|
|
895
|
+
const e = normalizeError(err) // AppError as is (VALIDATION_ERROR 400 for input), else generic 500
|
|
884
896
|
return jsonError(e.code, e.status, e.message)
|
|
885
897
|
}
|
|
886
898
|
```
|
package/llms/server.5.txt
CHANGED
|
@@ -52,7 +52,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
52
52
|
| `RegistryHandlers` | _type_ | exact backend handler registry inferred from a contract registry |
|
|
53
53
|
| `ExactRegistryHandlers` | _type_ | fail-first handler shape that rejects extra registry and endpoint keys |
|
|
54
54
|
| `staticRoute` | function | a raw route that serves a contained directory through `serveFile` (`Range` / `304` / validators) |
|
|
55
|
-
| `StaticRouteOptions` | _type_ | `{ cacheControl }` — what `staticRoute` adds to every file it serves |
|
|
55
|
+
| `StaticRouteOptions` | _type_ | `{ cacheControl, allowedDotNames }` — what `staticRoute` adds to every file it serves, and which dot-segment names it serves (none by default) |
|
|
56
56
|
| `serveFile` | function | serve a file with `Range` / `304` / `HEAD` — [guide](../guide/server.md#serving-files--range-requests) |
|
|
57
57
|
| `parseByteRange` | function | parse a single `Range` header → range / `unsatisfiable` / `null` |
|
|
58
58
|
| `isWithinDir` | function | path containment — `(root, resolvedTarget) => boolean`; call it before `serveFile` on any URL-derived path |
|
|
@@ -61,7 +61,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
61
61
|
| `ByteRange` | _type_ | an inclusive `{ start, end }` byte range |
|
|
62
62
|
| `respondJson` | function | a raw route's JSON response (`204` for null/undefined) |
|
|
63
63
|
| `errorResponse` | function | any thrown value → the framework error envelope + `x-request-id` |
|
|
64
|
-
| `normalizeError` | function | any thrown value → an `AppError` (`
|
|
64
|
+
| `normalizeError` | function | any thrown value → an `AppError` (an `AppError` as is — contract input failures arrive as `VALIDATION_ERROR` 400 with structured `details.issues`; anything else, a `ZodError` from handler code included, generic 500) — the framework's canonical classification, for a bespoke `onError` |
|
|
65
65
|
| `NormalizeErrorOptions` | _type_ | `logUnexpected` defaults to logging the raw server-side cause; tool adapters disable process dumps while their existing observers retain that cause |
|
|
66
66
|
| `errorCode` | function | the stable error code for a thrown value (side-effect-free — for log attribution) |
|
|
67
67
|
| `formatZodError` | function | a `ZodError` → a readable, field-summarised string |
|
|
@@ -110,7 +110,7 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
110
110
|
| `ResolvedError` | _type_ | the normalised error handed to `createErrorHook`'s `render` |
|
|
111
111
|
| `createBearerResolver` | function | a bearer-token identity resolver |
|
|
112
112
|
| `signJwt` | function | sign an HS256 JWT |
|
|
113
|
-
| `VerifyJwtOptions` | _type_ | options for `verifyJwt` |
|
|
113
|
+
| `VerifyJwtOptions` | _type_ | options for `verifyJwt` — `leewaySeconds`, `issuer`, `audience`, `expiration` (`'required'` by default) |
|
|
114
114
|
| `verifyJwt` | function | verify an HS256 JWT |
|
|
115
115
|
| `signLink` / `SignLinkOptions` | function / _type_ | a short-lived link for a request that cannot carry a header (`<audio src>`, `<img src>`): appends `expires` and an HMAC-SHA-256 `signature` over the method, path and every query parameter — [guide](../guide/auth-and-errors.md#signed-links) |
|
|
116
116
|
| `verifySignedLink` / `VerifySignedLinkOptions` | function / _type_ | check a request against its link (signature compared with a constant-time comparison, then expiry); call it from `createAuthHook`'s `resolve` or a raw route |
|
|
@@ -221,11 +221,11 @@ Also re-exports the error helpers from `stitchkit/contract`.
|
|
|
221
221
|
| `resolveTraceId` | function | the default per-request trace-id resolver |
|
|
222
222
|
| `extractIp` | function | the caller IP from a request |
|
|
223
223
|
| `isPublicIp` | function | whether an address belongs to the public internet; anything unparseable is not |
|
|
224
|
-
| `resolveSocketIp` | function | the
|
|
224
|
+
| `resolveSocketIp` | function | the real socket peer IP from the runtime (`server.requestIP` on Bun, `req.ip` under `srvx`); headers are not read |
|
|
225
225
|
| `getClientInfo` | function | caller IP + user-agent |
|
|
226
226
|
| `EventBus` | _type_ | the `createEventBus` handle |
|
|
227
227
|
| `RateLimitConfig` | _type_ | config for `createRateLimiter` |
|
|
228
|
-
| `ClientIpOptions` | _type_ | trusted-proxy config for `extractIp` / `
|
|
228
|
+
| `ClientIpOptions` | _type_ | socket peer and trusted-proxy config for `extractIp` / `getClientInfo` |
|
|
229
229
|
| `StreamingRouteOptions` | _type_ | options for `streamingRoute` / `ndjsonRoute` / `sseRoute` |
|
|
230
230
|
| `StreamingSourceContext` | _type_ | what a streaming source is given, including the cancellation `signal` |
|
|
231
231
|
| `StreamingFormat` | _type_ | `'ndjson' \| 'sse'` |
|
package/llms/server.txt
CHANGED
|
@@ -151,8 +151,10 @@ To type `ctx` with your app's extras (the user an auth hook injects), fix the
|
|
|
151
151
|
context type once:
|
|
152
152
|
|
|
153
153
|
```ts
|
|
154
|
+
import type { RuntimeContext } from 'stitchkit'
|
|
154
155
|
import { createImplement } from 'stitchkit/server'
|
|
155
156
|
|
|
157
|
+
interface User { id: string; name: string }
|
|
156
158
|
interface AppContext extends RuntimeContext { user: User | null }
|
|
157
159
|
|
|
158
160
|
export const implement = createImplement<AppContext>()
|
|
@@ -168,7 +170,20 @@ there. `createScopedImplement` types each handler by its endpoint's **effective*
|
|
|
168
170
|
scope instead — the endpoint's own `scope`, else the contract's:
|
|
169
171
|
|
|
170
172
|
```ts
|
|
173
|
+
import { defineContract } from 'stitchkit'
|
|
171
174
|
import { createScopedImplement } from 'stitchkit/server'
|
|
175
|
+
import { z } from 'zod'
|
|
176
|
+
|
|
177
|
+
const Post = z.object({ id: z.string(), title: z.string() })
|
|
178
|
+
|
|
179
|
+
const postsContract = defineContract({ prefix: 'posts', scope: 'user' }, {
|
|
180
|
+
list: { method: 'GET', path: '/', desc: 'List my posts', output: z.array(Post) },
|
|
181
|
+
purge: { method: 'DELETE', path: '/', desc: 'Purge all posts', scope: 'admin', output: z.array(Post) },
|
|
182
|
+
ping: { method: 'GET', path: '/ping', desc: 'Health check', scope: 'public', output: z.object({ ok: z.boolean() }) },
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
declare function listPosts(userId: string): Array<z.infer<typeof Post>>
|
|
186
|
+
declare function purge(): Array<z.infer<typeof Post>>
|
|
172
187
|
|
|
173
188
|
export const implementFor = createScopedImplement<{
|
|
174
189
|
public: object // no extra fields
|
|
@@ -344,7 +359,7 @@ server. See [Testing & deployment](./testing-and-deployment.md).
|
|
|
344
359
|
| `groups` | route groups — a shared path prefix and hooks (see below) |
|
|
345
360
|
| `scopePrefixes` | `scope → path prefix` map — mount `services` by `service.scope` (see below) |
|
|
346
361
|
| `rawRoutes` | non-contract routes (see below) |
|
|
347
|
-
| `maxJsonBodyBytes` |
|
|
362
|
+
| `maxJsonBodyBytes` | JSON body cap in bytes, **1 MiB by default**; a per-route value overrides it; a larger body is refused with `400 BAD_REQUEST` before it is buffered or parsed |
|
|
348
363
|
| `port` / `hostname` | listen address — port defaults to `3000` |
|
|
349
364
|
| `unix` | listen on a unix domain socket instead of TCP — `'/run/app.sock'` or `{ path, mode }` (see below) |
|
|
350
365
|
| `cors` | CORS policy — `{ origin, credentials, methods, headers, exposeHeaders }`. `origin` is **required** when `cors` is present: pass an explicit origin (or list), or `'*'` to deliberately allow every origin — an origin-less config is a construction error, never a silent wildcard. `origin` may also be a function that answers each request origin with or without credentials ([below](#cors-decided-per-request)). Omit `cors` entirely to emit no CORS headers. |
|
|
@@ -352,6 +367,7 @@ server. See [Testing & deployment](./testing-and-deployment.md).
|
|
|
352
367
|
| `logging` | `true` for built-in request logs, or a `LoggingConfig` (see below) |
|
|
353
368
|
| `traceId` | override per-request trace-id resolution — may return `undefined` to fall back |
|
|
354
369
|
| `wrapFetch` | compose wrappers around the finished handler (request context, audit) |
|
|
370
|
+
| `trustProxy` | client IP behind proxies you run: `{ trustedPeer(address) }`; `x-forwarded-for` is read right to left from a trusted socket peer ([below](#client-ip-behind-a-proxy)); unset, `ctx.ipAddress` is the socket peer |
|
|
355
371
|
| `proxyOrigin` | Bun TCP ingress policy: `{ trustedPeer(socketIp) }` restores the external scheme before all composition; independent of client-IP `trustProxy` |
|
|
356
372
|
| `socket` | full StitchKit Socket.IO handle; route, default WebSocket handler and shutdown are mounted once |
|
|
357
373
|
| `websocket` | custom Bun WebSocket handler; with `socket`, this is the explicit composed handler |
|
|
@@ -402,6 +418,43 @@ createServer({
|
|
|
402
418
|
- A `safelistedBody` endpoint reads a `text/plain` body only from an origin
|
|
403
419
|
granted with credentials ([below](#safelisted-request-bodies-beacons)).
|
|
404
420
|
|
|
421
|
+
### Client IP behind a proxy
|
|
422
|
+
|
|
423
|
+
Without `trustProxy`, `ctx.ipAddress` is the real socket peer and no header can
|
|
424
|
+
change it. Behind a reverse proxy that peer is the proxy, so name the proxies you
|
|
425
|
+
run:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
import { createServer, isLoopbackAddress } from 'stitchkit/server'
|
|
429
|
+
|
|
430
|
+
const server = createServer({
|
|
431
|
+
hostname: '127.0.0.1',
|
|
432
|
+
trustProxy: { trustedPeer: isLoopbackAddress }, // nginx on this host
|
|
433
|
+
services,
|
|
434
|
+
})
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
`x-forwarded-for` is read only when the socket peer is a trusted proxy, and then
|
|
438
|
+
from the **right**: each proxy appends the address it received the request from,
|
|
439
|
+
so the rightmost entries are written by your proxies and the leftmost by the
|
|
440
|
+
client. The first address `trustedPeer` does not accept is the client; when every
|
|
441
|
+
hop is trusted, the leftmost one is. A hop that is not an IP address makes the
|
|
442
|
+
client unknown (`ctx.ipAddress` is `undefined`), never a guess. `x-real-ip` is
|
|
443
|
+
not read — it carries no chain to check.
|
|
444
|
+
|
|
445
|
+
The proxy must **append** (nginx: `proxy_set_header X-Forwarded-For
|
|
446
|
+
$proxy_add_x_forwarded_for;`). For a chain of proxies, `trustedPeer` accepts each
|
|
447
|
+
of them — a CIDR check for an internal network, for example. The same option
|
|
448
|
+
exists on `wrapInRequestContext` and on `extractIp` / `getClientInfo`, which also
|
|
449
|
+
need the real peer: pass `socketIp: resolveSocketIp(req, server)`; without it the
|
|
450
|
+
header is ignored and the answer is `''`.
|
|
451
|
+
|
|
452
|
+
⚠️ **A proxy on the same host makes every request loopback.** Without
|
|
453
|
+
`trustProxy`, a server behind nginx on `127.0.0.1` sees `127.0.0.1` as the peer of
|
|
454
|
+
every visitor, so a rule like `isLoopbackAddress(ctx.ipAddress)` admits the whole
|
|
455
|
+
internet. Either configure `trustProxy` so the visitor's address is resolved, or
|
|
456
|
+
listen where the proxy cannot forward the privileged operation.
|
|
457
|
+
|
|
405
458
|
### External origin behind a trusted proxy
|
|
406
459
|
|
|
407
460
|
An HTTPS ingress often forwards plain HTTP to Bun. `trustProxy` trusts client-IP
|
package/llms/spend.txt
CHANGED
|
@@ -138,7 +138,24 @@ test('every model call goes through the spend gateway', async () => {
|
|
|
138
138
|
root: 'src',
|
|
139
139
|
policy: {
|
|
140
140
|
modules: [
|
|
141
|
-
{
|
|
141
|
+
{
|
|
142
|
+
module: 'stitchkit/agent-runtime/openrouter',
|
|
143
|
+
symbols: [
|
|
144
|
+
'openRouterProvider',
|
|
145
|
+
'createOpenRouterClient',
|
|
146
|
+
'openRouterRequestJson',
|
|
147
|
+
'openRouterRequestStream',
|
|
148
|
+
'openRouterSystemOne',
|
|
149
|
+
'openRouterAudioTranscription',
|
|
150
|
+
'openRouterAudioSpeech',
|
|
151
|
+
'openRouterGenerateImages',
|
|
152
|
+
'openRouterSubmitVideo',
|
|
153
|
+
'openRouterGetVideo',
|
|
154
|
+
'openRouterDownloadVideo',
|
|
155
|
+
'openRouterEmbeddings',
|
|
156
|
+
'openRouterRerank',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
142
159
|
{ module: 'stitchkit/agent-runtime/openai', symbols: ['openAiProvider'] },
|
|
143
160
|
{ module: 'stitchkit/agent-runtime/anthropic', symbols: ['anthropicProvider'] },
|
|
144
161
|
],
|
package/llms/stitchkit.2.txt
CHANGED
|
@@ -712,7 +712,7 @@ call, over HTTP or a Unix socket alike:
|
|
|
712
712
|
import { withContractIdentity } from 'stitchkit/server'
|
|
713
713
|
createServer({ services: withContractIdentity(services) })
|
|
714
714
|
|
|
715
|
-
// client
|
|
715
|
+
// client (`stitchkit/http` exports the same function for React Native/Hermes)
|
|
716
716
|
import { readContractIdentity } from 'stitchkit'
|
|
717
717
|
const { client, server } = await readContractIdentity(contracts, config)
|
|
718
718
|
if (server === undefined) {
|
|
@@ -1049,7 +1049,9 @@ character split across chunks is never torn. A line that crosses `maxLineBytes`
|
|
|
1049
1049
|
retains at most the limit, however long the line. With `finalLine: 'require-newline'`, a source
|
|
1050
1050
|
that ends inside a line throws `StreamTruncatedLineError` (`lineBytes`) instead of yielding the
|
|
1051
1051
|
fragment as a value — the right policy for a socket or a child process, where a missing newline
|
|
1052
|
-
means the writer died. Both errors extend the `RangeError` / `SyntaxError` they replace
|
|
1052
|
+
means the writer died. Both errors extend the `RangeError` / `SyntaxError` they replace, and
|
|
1053
|
+
both are exported from `stitchkit` and `stitchkit/http`, so a React Native client checks a contract
|
|
1054
|
+
stream's failure without importing the root entry.
|
|
1053
1055
|
|
|
1054
1056
|
## Reading a body up to a byte limit
|
|
1055
1057
|
|