stitchkit 0.133.2 → 0.134.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 +115 -0
- package/README.md +14 -11
- package/dist/agent-executor/acp/v1-connect.d.ts +3 -0
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-map.d.ts +13 -3
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-protocol.d.ts +59 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +2 -0
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/driver.d.ts +3 -0
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/contract.d.ts +42 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +20 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +42 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +30 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +4 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/vocabulary.d.ts +100 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-parts/model.d.ts +1559 -0
- package/dist/agent-parts/model.d.ts.map +1 -0
- package/dist/agent-parts/parts.d.ts +21 -0
- package/dist/agent-parts/parts.d.ts.map +1 -1
- package/dist/agent-runtime/ai-sdk-convert.d.ts +15 -0
- package/dist/agent-runtime/ai-sdk-convert.d.ts.map +1 -0
- package/dist/agent-runtime/ai-sdk.d.ts +31 -0
- package/dist/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-media.d.ts +11 -0
- package/dist/agent-runtime/anthropic-media.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-messages.d.ts +24 -0
- package/dist/agent-runtime/anthropic-messages.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-options.d.ts +79 -0
- package/dist/agent-runtime/anthropic-options.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-response.d.ts +19 -0
- package/dist/agent-runtime/anthropic-response.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic-sse.d.ts +4 -0
- package/dist/agent-runtime/anthropic-sse.d.ts.map +1 -0
- package/dist/agent-runtime/anthropic.d.ts +27 -0
- package/dist/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/agent-runtime/branch-observations.d.ts +25 -25
- package/dist/agent-runtime/branch-provider.d.ts +86 -0
- package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
- package/dist/agent-runtime/branch-replay.d.ts +30 -0
- package/dist/agent-runtime/branch-replay.d.ts.map +1 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +204 -0
- package/dist/agent-runtime/browser-control-contract.d.ts.map +1 -1
- package/dist/agent-runtime/browser-controller-view.d.ts +44 -0
- package/dist/agent-runtime/browser-controller-view.d.ts.map +1 -0
- package/dist/agent-runtime/browser-controller.d.ts +12 -8
- package/dist/agent-runtime/browser-controller.d.ts.map +1 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +2 -3
- package/dist/agent-runtime/child-budget-policy.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts +27 -10
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/control-interaction-schema.d.ts +157 -0
- package/dist/agent-runtime/control-interaction-schema.d.ts.map +1 -0
- package/dist/agent-runtime/control-schema.d.ts +183 -27
- package/dist/agent-runtime/control-schema.d.ts.map +1 -1
- package/dist/agent-runtime/control-view.d.ts +64 -0
- package/dist/agent-runtime/control-view.d.ts.map +1 -0
- package/dist/agent-runtime/conversations.d.ts +10 -0
- package/dist/agent-runtime/conversations.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-selection.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +8 -11
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tools.d.ts.map +1 -1
- package/dist/agent-runtime/event-schema.d.ts +80 -0
- package/dist/agent-runtime/event-schema.d.ts.map +1 -1
- package/dist/agent-runtime/harness-contract.d.ts +2 -2
- package/dist/agent-runtime/harness-contract.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness-realtime.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +2 -2
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/history.d.ts +25 -16
- package/dist/agent-runtime/history.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +7 -3
- package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-payload.d.ts +13 -7
- package/dist/agent-runtime/invocation-payload.d.ts.map +1 -1
- package/dist/agent-runtime/invocation-stream.d.ts +20 -0
- package/dist/agent-runtime/invocation-stream.d.ts.map +1 -0
- package/dist/agent-runtime/invocations.d.ts +2 -2
- package/dist/agent-runtime/invocations.d.ts.map +1 -1
- package/dist/agent-runtime/models-driver-step.d.ts +212 -0
- package/dist/agent-runtime/models-driver-step.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts +42 -0
- package/dist/agent-runtime/models-driver-telemetry.d.ts.map +1 -0
- package/dist/agent-runtime/models-driver.d.ts +235 -0
- package/dist/agent-runtime/models-driver.d.ts.map +1 -0
- package/dist/agent-runtime/models.d.ts +3 -26
- package/dist/agent-runtime/models.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +64 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openai-messages.d.ts +11 -0
- package/dist/agent-runtime/openai-messages.d.ts.map +1 -0
- package/dist/agent-runtime/openai-options.d.ts +91 -0
- package/dist/agent-runtime/openai-options.d.ts.map +1 -0
- package/dist/agent-runtime/openai-response.d.ts +77 -0
- package/dist/agent-runtime/openai-response.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse-state.d.ts +54 -0
- package/dist/agent-runtime/openai-sse-state.d.ts.map +1 -0
- package/dist/agent-runtime/openai-sse.d.ts +4 -0
- package/dist/agent-runtime/openai-sse.d.ts.map +1 -0
- package/dist/agent-runtime/openai.d.ts +31 -0
- package/dist/agent-runtime/openai.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-admission.d.ts +3 -0
- package/dist/agent-runtime/openrouter-admission.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-benchmarks.d.ts +17 -0
- package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts +70 -0
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts +57 -0
- package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter-catalog.d.ts +189 -14
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-models.d.ts +168 -31
- package/dist/agent-runtime/openrouter-models.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-options.d.ts +45 -15
- package/dist/agent-runtime/openrouter-options.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter-response.d.ts +22 -0
- package/dist/agent-runtime/openrouter-response.d.ts.map +1 -0
- package/dist/agent-runtime/openrouter.d.ts +21 -24
- package/dist/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts +4 -4
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +1 -1
- package/dist/agent-runtime/prompt.d.ts +3 -3
- package/dist/agent-runtime/prompt.d.ts.map +1 -1
- package/dist/agent-runtime/protocol.d.ts +28 -3
- package/dist/agent-runtime/protocol.d.ts.map +1 -1
- package/dist/agent-runtime/provider-cache.d.ts +30 -0
- package/dist/agent-runtime/provider-cache.d.ts.map +1 -0
- package/dist/agent-runtime/provider-content.d.ts +147 -0
- package/dist/agent-runtime/provider-content.d.ts.map +1 -1
- package/dist/agent-runtime/provider-failure.d.ts +51 -26
- package/dist/agent-runtime/provider-failure.d.ts.map +1 -1
- package/dist/agent-runtime/provider-history.d.ts +13 -0
- package/dist/agent-runtime/provider-history.d.ts.map +1 -0
- package/dist/agent-runtime/provider-http.d.ts +68 -0
- package/dist/agent-runtime/provider-http.d.ts.map +1 -0
- package/dist/agent-runtime/provider-journal.d.ts +149 -0
- package/dist/agent-runtime/provider-journal.d.ts.map +1 -1
- package/dist/agent-runtime/provider-json-schema-strip.d.ts +8 -0
- package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +1 -0
- package/dist/agent-runtime/provider-json-schema.d.ts +28 -0
- package/dist/agent-runtime/provider-json-schema.d.ts.map +1 -0
- package/dist/agent-runtime/provider-media.d.ts +49 -0
- package/dist/agent-runtime/provider-media.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts +25 -0
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts +27 -0
- package/dist/agent-runtime/provider-openai-chat.d.ts.map +1 -0
- package/dist/agent-runtime/provider-origin.d.ts +3 -12
- package/dist/agent-runtime/provider-origin.d.ts.map +1 -1
- package/dist/agent-runtime/provider-sse.d.ts +30 -0
- package/dist/agent-runtime/provider-sse.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts +5 -0
- package/dist/agent-runtime/provider-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts +63 -0
- package/dist/agent-runtime/provider-stream-segments.d.ts.map +1 -0
- package/dist/agent-runtime/provider-usage.d.ts +24 -0
- package/dist/agent-runtime/provider-usage.d.ts.map +1 -0
- package/dist/agent-runtime/retry-policy.d.ts +19 -3
- package/dist/agent-runtime/retry-policy.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +4 -4
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-approval.d.ts +82 -0
- package/dist/agent-runtime/run-approval.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-retry.d.ts +24 -0
- package/dist/agent-runtime/run-complete-retry.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-stream.d.ts +9 -0
- package/dist/agent-runtime/run-complete-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-tools.d.ts +21 -0
- package/dist/agent-runtime/run-complete-tools.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete-types.d.ts +168 -0
- package/dist/agent-runtime/run-complete-types.d.ts.map +1 -0
- package/dist/agent-runtime/run-complete.d.ts +25 -0
- package/dist/agent-runtime/run-complete.d.ts.map +1 -0
- package/dist/agent-runtime/run-driver-compose.d.ts +21 -0
- package/dist/agent-runtime/run-driver-compose.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +23 -10
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +2 -2
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +2 -2
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-history-parts.d.ts +14 -0
- package/dist/agent-runtime/run-history-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-loop-events.d.ts +126 -0
- package/dist/agent-runtime/run-loop-events.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +2 -2
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
- package/dist/agent-runtime/run-model-messages.d.ts +9 -0
- package/dist/agent-runtime/run-model-messages.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-step.d.ts +43 -0
- package/dist/agent-runtime/run-model-step.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-stream.d.ts +27 -0
- package/dist/agent-runtime/run-model-stream.d.ts.map +1 -0
- package/dist/agent-runtime/run-operation-lifecycle.d.ts +8 -4
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/run-prompt-history.d.ts +8 -13
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +7 -4
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +58 -16
- package/dist/agent-runtime/run-step-barriers.d.ts.map +1 -1
- package/dist/agent-runtime/run-step-helpers.d.ts +49 -0
- package/dist/agent-runtime/run-step-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-prepare.d.ts +34 -0
- package/dist/agent-runtime/run-step-prepare.d.ts.map +1 -0
- package/dist/agent-runtime/run-step-spend.d.ts +85 -10
- package/dist/agent-runtime/run-step-spend.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-parts.d.ts +13 -9
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -1
- package/dist/agent-runtime/run-stream-recorded.d.ts +8 -0
- package/dist/agent-runtime/run-stream-recorded.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts +29 -0
- package/dist/agent-runtime/run-stream-step-text.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +3 -3
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
- package/dist/agent-runtime/run-tool-approval-flow.d.ts +36 -0
- package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts +24 -0
- package/dist/agent-runtime/run-tool-approval-records.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-call.d.ts +73 -0
- package/dist/agent-runtime/run-tool-call.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-errors.d.ts +29 -0
- package/dist/agent-runtime/run-tool-errors.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-executor.d.ts +34 -0
- package/dist/agent-runtime/run-tool-executor.d.ts.map +1 -0
- package/dist/agent-runtime/run-tool-progress.d.ts +2 -2
- package/dist/agent-runtime/run-tool-progress.d.ts.map +1 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts +7 -6
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -1
- package/dist/agent-runtime/run-unacquired.d.ts +2 -2
- package/dist/agent-runtime/run-unacquired.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-control.d.ts +4 -4
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-internals.d.ts +35 -44
- package/dist/agent-runtime/runtime-internals.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-recovery.d.ts +3 -3
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-state.d.ts +3 -3
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -1
- package/dist/agent-runtime/runtime-submit.d.ts +2 -2
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +51 -16
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-linux.d.ts +8 -0
- package/dist/agent-runtime/sandbox-process-linux.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts +21 -0
- package/dist/agent-runtime/sandbox-process-macos.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts +114 -0
- package/dist/agent-runtime/sandbox-process-spec.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts +19 -0
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-message.d.ts +10 -0
- package/dist/agent-runtime/schemas-message.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-provider.d.ts +2 -0
- package/dist/agent-runtime/schemas-provider.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-run.d.ts +10 -0
- package/dist/agent-runtime/schemas-run.d.ts.map +1 -1
- package/dist/agent-runtime/schemas-usage-state.d.ts +6 -0
- package/dist/agent-runtime/schemas-usage-state.d.ts.map +1 -0
- package/dist/agent-runtime/schemas-usage.d.ts +8 -0
- package/dist/agent-runtime/schemas-usage.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +20 -10
- package/dist/agent-runtime/sql-rows.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +40 -20
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -1
- package/dist/agent-runtime/store-conformance-support.d.ts +20 -10
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +70 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/store-events.d.ts +120 -0
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store.d.ts +140 -0
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +10 -0
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/testing.d.ts +20 -0
- package/dist/agent-runtime/testing.d.ts.map +1 -1
- package/dist/browser/client-call-arguments.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/browser/client.d.ts +6 -0
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/device-presence-client.d.ts +42 -0
- package/dist/browser/device-presence-client.d.ts.map +1 -0
- package/dist/browser/device-presence-ops.d.ts +47 -0
- package/dist/browser/device-presence-ops.d.ts.map +1 -0
- package/dist/browser/device-presence-relay-adapter.d.ts +37 -0
- package/dist/browser/device-presence-relay-adapter.d.ts.map +1 -0
- package/dist/browser/http-fetch.d.ts +7 -2
- package/dist/browser/http-fetch.d.ts.map +1 -1
- package/dist/browser/http-helpers.d.ts +15 -0
- package/dist/browser/http-helpers.d.ts.map +1 -0
- package/dist/browser/http.d.ts +8 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +8 -0
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/contract/runtime-context.d.ts +13 -1
- package/dist/contract/runtime-context.d.ts.map +1 -1
- package/dist/device-relay/agent-handlers.d.ts +45 -0
- package/dist/device-relay/agent-handlers.d.ts.map +1 -0
- package/dist/device-relay/agent.d.ts +80 -0
- package/dist/device-relay/agent.d.ts.map +1 -0
- package/dist/device-relay/broker.d.ts +49 -0
- package/dist/device-relay/broker.d.ts.map +1 -0
- package/dist/device-relay/contract.d.ts +614 -0
- package/dist/device-relay/contract.d.ts.map +1 -0
- package/dist/device-relay/encoding.d.ts +30 -0
- package/dist/device-relay/encoding.d.ts.map +1 -0
- package/dist/device-relay/hub-connection.d.ts +43 -0
- package/dist/device-relay/hub-connection.d.ts.map +1 -0
- package/dist/device-relay/hub-dispatch.d.ts +19 -0
- package/dist/device-relay/hub-dispatch.d.ts.map +1 -0
- package/dist/device-relay/hub-handshake.d.ts +20 -0
- package/dist/device-relay/hub-handshake.d.ts.map +1 -0
- package/dist/device-relay/hub-shared-streams.d.ts +24 -0
- package/dist/device-relay/hub-shared-streams.d.ts.map +1 -0
- package/dist/device-relay/hub-streams.d.ts +57 -0
- package/dist/device-relay/hub-streams.d.ts.map +1 -0
- package/dist/device-relay/hub.d.ts +117 -0
- package/dist/device-relay/hub.d.ts.map +1 -0
- package/dist/entrypoints/agent-executor/acp.d.ts +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +183 -29
- package/dist/entrypoints/agent-executor/claude-sdk.js +15 -15
- package/dist/entrypoints/agent-executor/claude.js +13 -15
- package/dist/entrypoints/agent-executor/codex.js +88 -48
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +5 -5
- package/dist/entrypoints/agent-executor/testing.js +31 -30
- package/dist/entrypoints/agent-executor.d.ts +2 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +23 -17
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +9 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/ai-sdk.js +821 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/anthropic.js +1260 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +4 -1
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +449 -50
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +24 -19
- package/dist/entrypoints/agent-runtime/openai.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openai.js +1246 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +5 -2
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +2355 -371
- package/dist/entrypoints/agent-runtime/postgres.js +12 -10
- package/dist/entrypoints/agent-runtime/realtime.js +11 -10
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +3 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +530 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +13 -11
- package/dist/entrypoints/agent-runtime/sqlite/node.js +13 -11
- package/dist/entrypoints/agent-runtime/testing.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +56 -15
- package/dist/entrypoints/agent-runtime.d.ts +14 -6
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +1412 -115
- package/dist/entrypoints/application/diagnostic-journal.js +6 -6
- package/dist/entrypoints/application/directory-inbox.js +6 -6
- package/dist/entrypoints/application/opentelemetry.js +3 -3
- package/dist/entrypoints/application.js +17 -17
- package/dist/entrypoints/cli/publish.js +8 -8
- package/dist/entrypoints/cli.js +14 -15
- package/dist/entrypoints/contract.d.ts +1 -0
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +13 -9
- package/dist/entrypoints/device-relay.d.ts +10 -0
- package/dist/entrypoints/device-relay.d.ts.map +1 -0
- package/dist/entrypoints/device-relay.js +2517 -0
- package/dist/entrypoints/files/packaging.js +3 -3
- package/dist/entrypoints/files.js +11 -11
- package/dist/entrypoints/geo.js +5 -5
- package/dist/entrypoints/google.js +1 -1
- package/dist/entrypoints/handler.js +6 -6
- package/dist/entrypoints/http.js +9 -9
- package/dist/entrypoints/index.js +21 -17
- package/dist/entrypoints/live.js +4 -4
- package/dist/entrypoints/node.js +13 -13
- package/dist/entrypoints/observability.js +9 -9
- package/dist/entrypoints/process/bootstrap.js +1 -1
- package/dist/entrypoints/process.js +5 -5
- package/dist/entrypoints/react.js +4 -4
- package/dist/entrypoints/realtime.d.ts +3 -0
- package/dist/entrypoints/realtime.d.ts.map +1 -1
- package/dist/entrypoints/realtime.js +413 -4
- package/dist/entrypoints/release.js +1 -1
- package/dist/entrypoints/remote.js +10 -10
- package/dist/entrypoints/server.d.ts +1 -0
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +546 -40
- package/dist/entrypoints/service-host/macos.js +10 -10
- package/dist/entrypoints/service-host/work.js +7 -7
- package/dist/entrypoints/service-host.js +15 -15
- package/dist/entrypoints/spend.js +3 -3
- package/dist/entrypoints/sync.js +4 -4
- package/dist/entrypoints/telegram/screens.js +6 -6
- package/dist/entrypoints/telegram.js +20 -20
- package/dist/entrypoints/testing.js +14 -14
- package/dist/entrypoints/tools/agent.d.ts +2 -1
- package/dist/entrypoints/tools/agent.d.ts.map +1 -1
- package/dist/entrypoints/tools/agent.js +8 -7
- package/dist/entrypoints/tools/connections.js +5 -5
- package/dist/entrypoints/tools/invoker.js +3 -4
- package/dist/entrypoints/tools/mcp.js +8 -9
- package/dist/entrypoints/tools/toolkit.js +32 -13
- package/dist/entrypoints/tools.d.ts +3 -1
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +37 -35
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/tracking/performance.js +4 -4
- package/dist/entrypoints/tracking.js +3 -3
- package/dist/{index-09f7w2qq.js → index-02kdtrcd.js} +1 -1
- package/dist/{index-y53cqwke.js → index-033tyx59.js} +1 -1
- package/dist/{index-9ft4n9j1.js → index-05b65gj4.js} +2 -2
- package/dist/{index-d04w81fz.js → index-0sxj3y45.js} +1 -1
- package/dist/{index-dm6nxkn1.js → index-18pf56dq.js} +4 -6
- package/dist/index-1gmgwfn3.js +439 -0
- package/dist/index-23wn8sgf.js +47 -0
- package/dist/{index-tqjamnax.js → index-27srek2g.js} +15 -13
- package/dist/{index-2nwvn7m2.js → index-29v1p1f4.js} +2 -2
- package/dist/index-36dmtzjr.js +194 -0
- package/dist/{index-ycr4pk0z.js → index-42n9jycn.js} +3 -3
- package/dist/{index-ke02kxsr.js → index-43k180c2.js} +1 -1
- package/dist/{index-pbekeqzm.js → index-5c4m8zdf.js} +2 -2
- package/dist/{index-qggqqja2.js → index-5dxgx3yj.js} +1 -1
- package/dist/{index-x5ayy5bn.js → index-5gdexvke.js} +3 -1
- package/dist/{index-t1a2jrg7.js → index-5xsxvk2x.js} +1 -1
- package/dist/{index-mbd92r1w.js → index-654rhe5d.js} +1 -1
- package/dist/{index-2dzc7mv9.js → index-67pnt4bh.js} +1 -1
- package/dist/index-6kpwkpgx.js +415 -0
- package/dist/{index-s43tr4my.js → index-6kwdfb9m.js} +18 -3
- package/dist/{index-1qwd54n3.js → index-6nzzj7qr.js} +1 -1
- package/dist/{index-rkjfzs0a.js → index-6p5pshcd.js} +2 -2
- package/dist/{index-118aebbg.js → index-6t4c98gr.js} +1 -1
- package/dist/{index-pws5c3x6.js → index-6xw1wf4m.js} +51 -32
- package/dist/{index-kwsr7j5k.js → index-6yb4stq3.js} +1 -1
- package/dist/{index-8jf4bt7v.js → index-76yhxa41.js} +8 -8
- package/dist/{index-7416mhyh.js → index-79vqbjcz.js} +1 -1
- package/dist/{index-13wmzpa6.js → index-7an2fs5h.js} +1 -1
- package/dist/index-7qza24g1.js +14 -0
- package/dist/{index-gtaaxe9d.js → index-8cek82ar.js} +1 -1
- package/dist/index-9f60gnfn.js +393 -0
- package/dist/{index-stpy56r3.js → index-aacwkve4.js} +209 -10
- package/dist/{index-rpyn7geq.js → index-ac3rfec5.js} +2 -2
- package/dist/{index-d2drhb9c.js → index-b0mh2t9x.js} +2 -2
- package/dist/index-b23s6e2c.js +158 -0
- package/dist/{index-an7vcmwf.js → index-bvpevwt6.js} +5 -5
- package/dist/{index-msxf2r8x.js → index-by8w2461.js} +1 -1
- package/dist/{index-8t9dr41h.js → index-c0yym4a0.js} +4 -4
- package/dist/{index-wddcfbng.js → index-c7fj4yw9.js} +1 -1
- package/dist/{index-tf70nm22.js → index-cb4nnvfr.js} +8 -6
- package/dist/{index-205456mf.js → index-d3s070eh.js} +2 -2
- package/dist/{index-apf5g7y9.js → index-dz6tstcp.js} +2 -2
- package/dist/{index-agy5fqgf.js → index-e1y74yra.js} +15 -8
- package/dist/index-edtg4tak.js +55 -0
- package/dist/{index-pq6g1k9t.js → index-ek9w11r0.js} +2 -2
- package/dist/{index-x46y9z26.js → index-epyj7ptp.js} +7 -5
- package/dist/{index-6kmjcm81.js → index-er483f3w.js} +93 -4
- package/dist/{index-827bgv33.js → index-f16b7rze.js} +1 -1
- package/dist/{index-gbhj370g.js → index-fec05c9k.js} +21 -21
- package/dist/{index-9wdrwx3b.js → index-fjac2w5e.js} +20 -22
- package/dist/{index-6918kxbf.js → index-fthw8dwa.js} +1 -0
- package/dist/{index-2mz8hj58.js → index-g04hszcm.js} +1 -1
- package/dist/{index-rw8ze745.js → index-ga6avd48.js} +1 -1
- package/dist/{index-paff5y0r.js → index-grhhsrd5.js} +9 -7
- package/dist/{index-mxt0wfjy.js → index-h20qcyh5.js} +5 -2
- package/dist/index-j3r7r1mh.js +150 -0
- package/dist/{index-vgytj9wp.js → index-jmaw365j.js} +1 -1
- package/dist/{index-cjytermm.js → index-jzdbkanz.js} +3 -3
- package/dist/index-k137ezb6.js +79 -0
- package/dist/{index-tazm4dxf.js → index-kdw0n92g.js} +1 -1
- package/dist/{index-wh70tmpd.js → index-ke6jtxkd.js} +1 -1
- package/dist/index-kgj8j7bv.js +83 -0
- package/dist/{index-9kpxz49v.js → index-kgkevngs.js} +1 -1
- package/dist/{index-hab790s6.js → index-kp1j7cc8.js} +4 -4
- package/dist/{index-jcge9tx3.js → index-krekhmp7.js} +142 -123
- package/dist/{index-3y2tzhr8.js → index-ky79wwgs.js} +4 -4
- package/dist/{index-39rmc00v.js → index-mfe9a266.js} +1 -1
- package/dist/{index-qpzyahe3.js → index-mgr0mdqp.js} +5 -2
- package/dist/{index-n20tybgk.js → index-mh3jdb25.js} +2 -2
- package/dist/{index-g5fgeb6v.js → index-mkmep637.js} +1 -1
- package/dist/{index-02r5sq9p.js → index-mrng24wq.js} +19 -21
- package/dist/index-mx2gya05.js +465 -0
- package/dist/{index-8yt3rwe7.js → index-n2t87ggz.js} +5 -5
- package/dist/index-nfeafbzh.js +7379 -0
- package/dist/{index-j0ef04jw.js → index-nfm15ej7.js} +4 -4
- package/dist/index-pd9e8rz4.js +193 -0
- package/dist/{index-zwgwyvdt.js → index-pdcbjd6a.js} +1 -1
- package/dist/{index-q427q23r.js → index-pjjh91vw.js} +2 -2
- package/dist/{index-gnjgkecx.js → index-q46b16xz.js} +1 -1
- package/dist/{index-9xr44d2g.js → index-qv5v6w9c.js} +330 -106
- package/dist/{index-tmv3ez1h.js → index-qymek778.js} +69 -12
- package/dist/{index-yrr3n391.js → index-ry8m2mhg.js} +2 -2
- package/dist/{index-93n6jwy0.js → index-s0n0nnz5.js} +3 -3
- package/dist/{index-1p8q0yrt.js → index-t5zp1jjj.js} +5 -7
- package/dist/{index-2rf33y2h.js → index-tav72wz5.js} +4 -2
- package/dist/{index-jpecjm30.js → index-tgehj4bp.js} +1 -1
- package/dist/{index-ma26mfnt.js → index-v5hmyef8.js} +1 -1
- package/dist/index-vebzvse6.js +230 -0
- package/dist/index-vv0hxrmy.js +295 -0
- package/dist/index-vxm0ya3f.js +707 -0
- package/dist/{index-t3qcac2a.js → index-w3s79kcb.js} +1 -1
- package/dist/{index-r97ppg0g.js → index-x1r7kxzd.js} +1 -1
- package/dist/{index-kynwa08q.js → index-xrsryvd2.js} +2 -2
- package/dist/{index-3mcbr8sx.js → index-xtxxt87z.js} +1 -1
- package/dist/index-zk839vzf.js +231 -0
- package/dist/{index-9c76vfxf.js → index-zyyerdny.js} +4 -4
- package/dist/internal/base64.d.ts +9 -0
- package/dist/internal/base64.d.ts.map +1 -0
- package/dist/internal/deadline-budget.d.ts +57 -0
- package/dist/internal/deadline-budget.d.ts.map +1 -0
- package/dist/internal/deadline.d.ts.map +1 -1
- package/dist/internal/timers.d.ts +2 -0
- package/dist/internal/timers.d.ts.map +1 -1
- package/dist/realtime/device-presence-contract.d.ts +194 -0
- package/dist/realtime/device-presence-contract.d.ts.map +1 -0
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/server/device-presence-handlers.d.ts +54 -0
- package/dist/server/device-presence-handlers.d.ts.map +1 -0
- package/dist/server/device-presence-registry.d.ts +35 -0
- package/dist/server/device-presence-registry.d.ts.map +1 -0
- package/dist/server/device-presence.d.ts +45 -0
- package/dist/server/device-presence.d.ts.map +1 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +3 -1
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/types.d.ts +4 -11
- package/dist/server/types.d.ts.map +1 -1
- package/dist/service-host/systemd-render-shared.d.ts.map +1 -1
- package/dist/tools/agent-messages.d.ts +6 -0
- package/dist/tools/agent-messages.d.ts.map +1 -0
- package/dist/tools/agent-tool-error.d.ts +2 -2
- package/dist/tools/agent-tools.d.ts +153 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent.d.ts +6 -56
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +3 -1
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +2 -2
- package/llms/agent-executor-codex.txt +1 -1
- package/llms/agent-executor.txt +7 -3
- package/llms/agent-runtime-ai-sdk.txt +26 -0
- package/llms/agent-runtime-anthropic.txt +33 -0
- package/llms/agent-runtime-browser.txt +22 -8
- package/llms/agent-runtime-harness.txt +2 -2
- package/llms/agent-runtime-openai.txt +31 -0
- package/llms/agent-runtime-openrouter.txt +17 -7
- package/llms/agent-runtime-sandbox.txt +53 -1
- package/llms/agent-runtime-testing.txt +4 -2
- package/llms/agent-runtime.2.txt +158 -271
- package/llms/agent-runtime.3.txt +289 -243
- package/llms/agent-runtime.4.txt +273 -216
- package/llms/agent-runtime.5.txt +209 -2
- package/llms/agent-runtime.txt +238 -181
- package/llms/contract.txt +2 -1
- package/llms/device-relay.txt +34 -0
- package/llms/realtime.txt +20 -0
- package/llms/server.2.txt +125 -1
- package/llms/server.3.txt +111 -122
- package/llms/server.4.txt +1 -1
- package/llms/server.5.txt +3 -1
- package/llms/server.txt +31 -1
- package/llms/spend.txt +11 -6
- package/llms/stitchkit.2.txt +21 -43
- package/llms/stitchkit.3.txt +43 -0
- package/llms/stitchkit.txt +93 -84
- package/llms/tools-agent.txt +7 -5
- package/llms/tools-toolkit.txt +1 -1
- package/llms/tools.4.txt +7 -2
- package/llms/{upgrading-0.128.0-0.133.0.txt → upgrading-0.128.0-0.134.0.txt} +173 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +981 -210
- package/llms.txt +21 -17
- package/package.json +18 -7
- package/dist/index-0p0s5hrj.js +0 -249
- package/dist/index-1dn2wjq6.js +0 -135
- package/dist/index-1psbyyhj.js +0 -21
- package/dist/index-34k82crg.js +0 -3961
- package/dist/index-5n3a8hd8.js +0 -102
- package/dist/index-97rp94ff.js +0 -8
- package/dist/index-bn2baakz.js +0 -336
- package/dist/index-eh71zr32.js +0 -14
- package/dist/index-emgrmavr.js +0 -1193
- package/dist/index-fzd477xk.js +0 -135
- package/dist/index-vgzhw2zk.js +0 -304
- package/dist/internal/ai-sdk-typed.d.ts +0 -14
- package/dist/internal/ai-sdk-typed.d.ts.map +0 -1
- package/dist/tools/runtime-call-context.d.ts +0 -15
- package/dist/tools/runtime-call-context.d.ts.map +0 -1
- package/dist/{index-vmbxj75t.js → index-jwtmw39p.js} +0 -0
- package/dist/{index-877e9y8r.js → index-sk03xe0n.js} +3 -3
- package/dist/{index-21cfxc4z.js → index-vh4291qh.js} +3 -3
package/llms/agent-runtime.txt
CHANGED
|
@@ -8,8 +8,8 @@ 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`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
|
|
12
|
-
- `llms/agent-runtime.5.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
|
|
11
|
+
- `llms/agent-runtime.4.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
|
|
12
|
+
- `llms/agent-runtime.5.txt`: API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
|
|
13
13
|
|
|
14
14
|
==============================================================================
|
|
15
15
|
# Guide: Agent application runtime (docs/guide/agent-runtime.md)
|
|
@@ -20,17 +20,21 @@ Parts of this slice:
|
|
|
20
20
|
> **Maturity: evolving.** This surface is still finding its shape and may be
|
|
21
21
|
> redefined in any minor release — always with a `### ⚠️ Breaking changes` entry
|
|
22
22
|
> and a migration section, never silently. If your application already owns the
|
|
23
|
-
> conversation loop, `
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
> conversation loop, `mountAgentTools` from `stitchkit/tools` (or `mountAgent`
|
|
24
|
+
> from `stitchkit/tools/agent` for an AI SDK loop) is the direct path.
|
|
25
|
+
|
|
26
|
+
`stitchkit/agent-runtime` is the peer-free, server-only, opinionated layer above
|
|
27
|
+
`mountAgentTools`. Use it when the application wants Stitchkit to own conversation
|
|
28
|
+
mechanics: durable acceptance, history projection, the native `AgentModelDriver`
|
|
29
|
+
step loop, checkpoints, keyed interruption, terminal commit and stable application
|
|
30
|
+
events.
|
|
31
|
+
|
|
32
|
+
If the application already owns that loop, import `mountAgentTools` from
|
|
33
|
+
`stitchkit/tools` (peer-free) or `mountAgent` from `stitchkit/tools/agent` (AI SDK
|
|
34
|
+
adapter). Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on this
|
|
35
|
+
entrypoint; this entrypoint uses the tool executor, pulls no MCP peer and no AI SDK
|
|
36
|
+
peer, and runs directly against three native providers (`openrouter`, `openai`,
|
|
37
|
+
`anthropic`) or any custom `AgentModelDriver`.
|
|
34
38
|
|
|
35
39
|
UI and shared DTO code must import canonical records and delivery validation from
|
|
36
40
|
`stitchkit/agent-runtime/browser`, not from the server runtime barrel:
|
|
@@ -50,16 +54,22 @@ persistence, event sinks and every Node context dependency.
|
|
|
50
54
|
## Install
|
|
51
55
|
|
|
52
56
|
```sh
|
|
53
|
-
bun add stitchkit
|
|
57
|
+
bun add stitchkit zod
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
`
|
|
57
|
-
|
|
60
|
+
`stitchkit/agent-runtime`, `stitchkit/agent-runtime/harness`,
|
|
61
|
+
`stitchkit/agent-runtime/testing`, `stitchkit/tools` (`mountAgentTools`,
|
|
62
|
+
`defineAgentTool`), and all three native providers
|
|
63
|
+
(`stitchkit/agent-runtime/openrouter`, `stitchkit/agent-runtime/openai`,
|
|
64
|
+
`stitchkit/agent-runtime/anthropic`) are completely peer-free beyond `zod`.
|
|
58
65
|
|
|
59
|
-
|
|
66
|
+
Install `ai` only when bridging an existing AI SDK v4 `LanguageModel` or `ToolSet`
|
|
67
|
+
through the thin optional-peer adapter `stitchkit/agent-runtime/ai-sdk`
|
|
68
|
+
(`fromAiSdkModel`, `fromAiSdkTools`) or mounting an AI SDK `ToolSet` through
|
|
69
|
+
`stitchkit/tools/agent` (`mountAgent`):
|
|
60
70
|
|
|
61
71
|
```sh
|
|
62
|
-
bun add
|
|
72
|
+
bun add ai@^7
|
|
63
73
|
```
|
|
64
74
|
|
|
65
75
|
## Minimal composition
|
|
@@ -75,8 +85,7 @@ import {
|
|
|
75
85
|
defineModelRegistry,
|
|
76
86
|
} from 'stitchkit/agent-runtime'
|
|
77
87
|
import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter'
|
|
78
|
-
import { composeToolLifecycle } from 'stitchkit/tools'
|
|
79
|
-
import { mountAgent } from 'stitchkit/tools/agent'
|
|
88
|
+
import { composeToolLifecycle, mountAgentTools } from 'stitchkit/tools'
|
|
80
89
|
|
|
81
90
|
const protocol = defineAgentProtocol({
|
|
82
91
|
context: z.object({ userId: z.string() }),
|
|
@@ -125,7 +134,7 @@ const runtime = createAgentRuntime({
|
|
|
125
134
|
},
|
|
126
135
|
}),
|
|
127
136
|
tools: ({ context, toolFenceLifecycle }) =>
|
|
128
|
-
|
|
137
|
+
mountAgentTools(service, {
|
|
129
138
|
context,
|
|
130
139
|
access: { gate: composeToolLifecycle(authLifecycle, toolFenceLifecycle) },
|
|
131
140
|
}),
|
|
@@ -164,11 +173,205 @@ await ticket.accepted
|
|
|
164
173
|
const terminal = await ticket.result
|
|
165
174
|
```
|
|
166
175
|
|
|
167
|
-
A stop policy's `when` receives the steps so far together with the
|
|
168
|
-
`prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and
|
|
169
|
-
typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt
|
|
170
|
-
run's request, a per-tenant limit) reads it there; it needs no map of its own keyed
|
|
171
|
-
The first policy to return `true` ends the run as `policy_stop` with its `name` as
|
|
176
|
+
A stop policy's `when` receives the completed `AgentStepResult[]` steps so far together with the
|
|
177
|
+
same run context `prepareStep` gets — `context`, `run`, `signal`, `toolFenceLifecycle` and
|
|
178
|
+
`contextUsage` — typed by the runtime's `CONTEXT`. A rule that depends on its own run (a receipt
|
|
179
|
+
bound to the run's request, a per-tenant limit) reads it there; it needs no map of its own keyed
|
|
180
|
+
by `runId`. The first policy to return `true` ends the run as `policy_stop` with its `name` as
|
|
181
|
+
`policyName`.
|
|
182
|
+
|
|
183
|
+
## Native model port, providers and driver composition
|
|
184
|
+
|
|
185
|
+
Every model call crosses one single-step port — `AgentModelDriver.stream(request, signal)` — with
|
|
186
|
+
no SDK retries and no tool execution inside the driver (ADR 0336). Any throw out of `stream()` or
|
|
187
|
+
while reading `parts` is provider-origin by construction; HTTP and stream failures surface as
|
|
188
|
+
`AgentProviderError` (guard with `isAgentProviderError`) or `AgentProviderStreamCutError`.
|
|
189
|
+
`AgentModelRequest.headers` merges per-request headers (such as `traceparent` or deadline headers)
|
|
190
|
+
without allowing `content-type: application/json` to be overwritten. `AgentModelToolSpec` also
|
|
191
|
+
reserves an additive `{ type: 'provider', id, name, config? }` union branch for provider-hosted
|
|
192
|
+
tools; drivers that do not implement a declared provider tool fail fast with `TypeError`.
|
|
193
|
+
|
|
194
|
+
Three peer-free native providers implement `AgentModelDriverFactory` over Web `fetch` and SSE,
|
|
195
|
+
all accepting either a static string or a dynamic `apiKey: () => string | Promise<string>` resolved
|
|
196
|
+
freshly per stream call and reporting server `response.timestamp` alongside `modelId`:
|
|
197
|
+
|
|
198
|
+
- **`stitchkit/agent-runtime/openrouter`** (`openRouterProvider`): OpenRouter Chat Completions SSE
|
|
199
|
+
with camelCase `baseUrl` and `providerApiKeys`, `looseTools` (sending `strict: false` while
|
|
200
|
+
preserving explicit per-tool `strict: true`), `reasoning.effort: 'max'`, `sessionPerConversation`
|
|
201
|
+
derived from `request.correlation.conversationId` without requiring `invocations`,
|
|
202
|
+
`reasoning_details` and Gemini `thought_signature` round-trip, ≤ 4 cache breakpoints, BYOK
|
|
203
|
+
`costDetails` (`cost + upstream_inference_cost`), and `native_finish_reason` abnormal-stop guards.
|
|
204
|
+
- **`stitchkit/agent-runtime/openai`** (`openAiProvider`): OpenAI Responses API
|
|
205
|
+
(`POST /v1/responses`) defaulting to stateless `store: false` with automatic
|
|
206
|
+
`include: ['reasoning.encrypted_content']` round-trip, `role: 'developer'` instructions,
|
|
207
|
+
`strict: false` default tool schemas, `item_id` (`fc_*`) vs `call_id` separation, `text.format`
|
|
208
|
+
structured outputs, `cachePerConversation` (`prompt_cache_key`), and fail-fast `TypeError`
|
|
209
|
+
refusal of unsupported call settings.
|
|
210
|
+
- **`stitchkit/agent-runtime/anthropic`** (`anthropicProvider`): Anthropic Messages API
|
|
211
|
+
(`POST /v1/messages`) with mandatory `maxOutputTokens` and
|
|
212
|
+
`maxOutputTokens > thinking.budgetTokens` fail-fast validation, verbatim multi-block
|
|
213
|
+
`thinking` + `signature` and `redacted_thinking` preservation, `computed` total `inputTokens`
|
|
214
|
+
when cache counters are positive (ADR 0109), image splitting out of `is_error` tool results,
|
|
215
|
+
≤ 4 cache breakpoints with TTL-order checks, `output_config.format` JSON Schema (refusing
|
|
216
|
+
schemaless `json-object`), and retryable `529 overloaded_error` classification.
|
|
217
|
+
|
|
218
|
+
For an existing AI SDK v4 model or `ToolSet`, import `fromAiSdkModel` and `fromAiSdkTools` from
|
|
219
|
+
`stitchkit/agent-runtime/ai-sdk`. Both adapt directly onto `AgentModelDriver` and `AgentToolSet`
|
|
220
|
+
(driving `model.doStream()` without importing `streamText` or `generateText`) and normalize legacy
|
|
221
|
+
deprecated tool outputs into canonical `{ type: 'file', data, mediaType }` parts.
|
|
222
|
+
|
|
223
|
+
Wrap any driver with `wrapModelDriver` or `composeModelDrivers` for admission holds, credit
|
|
224
|
+
reservations, request transforms, signal tightening (`transformSignal`, which links a tighter
|
|
225
|
+
`AbortSignal` without ever loosening the caller's signal), or per-part telemetry. `onClose` runs
|
|
226
|
+
once per stream on finish, error, early consumer break, or signal abort:
|
|
227
|
+
|
|
228
|
+
```ts
|
|
229
|
+
import { composeModelDrivers } from 'stitchkit/agent-runtime'
|
|
230
|
+
import { openAiProvider } from 'stitchkit/agent-runtime/openai'
|
|
231
|
+
|
|
232
|
+
const base = openAiProvider({ apiKey: env.OPENAI_API_KEY }).create('gpt-5')
|
|
233
|
+
const guarded = composeModelDrivers(base, [admissionDecorator, telemetryDecorator])
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### OpenRouter catalog snapshots, pricing ceilings, and cache
|
|
237
|
+
|
|
238
|
+
`stitchkit/agent-runtime/openrouter` also provides a peer-free, Web Fetch-clean catalog layer for
|
|
239
|
+
discovering models, checking pricing ceilings, and keeping a cached catalog in sync across requests:
|
|
240
|
+
|
|
241
|
+
- `loadOpenRouterCatalogSnapshot` fetches `/models` (and optional per-model `/endpoints`) with
|
|
242
|
+
unauthenticated public access or a static/dynamic `apiKey`, extracting `canonicalSlug`,
|
|
243
|
+
`description`, `createdAt`, `aliasTarget`, `inputModalities`, `outputModalities`, `tokenizer`,
|
|
244
|
+
`topProviderContextLength`, `maxCompletionTokens`, `reasoning`, per-unit/cache/conditional
|
|
245
|
+
`pricingTiers`, and endpoint telemetry (`latencyP50Ms`, `throughputP50`, `uptime1d`, `tag`).
|
|
246
|
+
- `resolveOpenRouterModelCeiling` returns the worst-case per-unit rates across base pricing and
|
|
247
|
+
conditional tiers without understating unknown tiers; `summarizeOpenRouterEndpoints` aggregates
|
|
248
|
+
distinct provider counts, median latency/throughput, and 1-day uptime.
|
|
249
|
+
- `findOpenRouterModel` looks up a model by exact `id` or `canonicalSlug`, and
|
|
250
|
+
`listOpenRouterModels` filters snapshots by `tools`, `reasoning`, modalities, `minContextLength`,
|
|
251
|
+
price bounds, `freeOnly`, and `author`.
|
|
252
|
+
- `createOpenRouterCatalogCache` wraps snapshot refreshes with single-flight coalescing, per-caller
|
|
253
|
+
`AbortSignal` isolation, `freshMs` TTL, `retryBackoffMs` stale fallback, and an optional
|
|
254
|
+
pluggable `OpenRouterCatalogStore` for durable hydration and persistence. `catalog.read()` returns
|
|
255
|
+
a discriminated union (`status: 'current' | 'stale' | 'unavailable'`) so admission and billing
|
|
256
|
+
callers can narrow on `res.status !== 'unavailable'` and observe stale or unavailable catalog
|
|
257
|
+
state explicitly; the convenience helpers `getModel` and `listModels` map `'unavailable'` to
|
|
258
|
+
`undefined` and `[]`.
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
import {
|
|
262
|
+
createOpenRouterCatalogCache,
|
|
263
|
+
evaluateOpenRouterModelAdmission,
|
|
264
|
+
findOpenRouterModel,
|
|
265
|
+
listOpenRouterModels,
|
|
266
|
+
resolveOpenRouterModelCeiling,
|
|
267
|
+
summarizeOpenRouterEndpoints,
|
|
268
|
+
} from 'stitchkit/agent-runtime/openrouter'
|
|
269
|
+
|
|
270
|
+
const catalog = createOpenRouterCatalogCache({
|
|
271
|
+
freshMs: 15 * 60_000,
|
|
272
|
+
retryBackoffMs: 60_000,
|
|
273
|
+
endpointsFor: ['anthropic/claude-sonnet-4.6'],
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
// Admission and billing paths use catalog.read() to observe 'current', 'stale', and 'unavailable'.
|
|
277
|
+
const res = await catalog.read()
|
|
278
|
+
if (res.status !== 'unavailable') {
|
|
279
|
+
const admission = evaluateOpenRouterModelAdmission({
|
|
280
|
+
snapshot: res.snapshot,
|
|
281
|
+
modelId: 'anthropic/claude-sonnet-4.6',
|
|
282
|
+
policy: { maxSnapshotAgeMs: 30 * 60_000, requiredParameters: ['tools'] },
|
|
283
|
+
})
|
|
284
|
+
const reasoningTools = listOpenRouterModels(res.snapshot, { tools: true, reasoning: true })
|
|
285
|
+
const sonnet = findOpenRouterModel(res.snapshot, 'anthropic/claude-sonnet-4.6')
|
|
286
|
+
const ceiling = sonnet ? resolveOpenRouterModelCeiling(sonnet) : undefined
|
|
287
|
+
const endpoints = sonnet?.endpoints ? summarizeOpenRouterEndpoints(sonnet.endpoints) : undefined
|
|
288
|
+
void [admission, reasoningTools, ceiling, endpoints]
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Peer-free tools and stateless completions
|
|
293
|
+
|
|
294
|
+
Build standalone peer-free tools with `defineAgentTool` or project contracts and runtime tools
|
|
295
|
+
with `mountAgentTools` from `stitchkit/tools` (including the single-argument
|
|
296
|
+
`mountAgentTools({ runtimeTools, access })` form when no HTTP service contracts are mounted). Both
|
|
297
|
+
return `AgentTool` / `AgentToolSet` carrying JSON Schema 2020-12 `inputSchema`, Zod `parseInput`,
|
|
298
|
+
optional `needsApproval`, `onInputAvailable`, and `toModelOutput` returning `AgentToolModelOutput`.
|
|
299
|
+
|
|
300
|
+
When an operation needs one or a few model steps without a durable conversation store — structured
|
|
301
|
+
extraction, classification, a bounded tool loop, or standalone streaming — call `completeText`,
|
|
302
|
+
`streamComplete`, or `completeObject` from `stitchkit/agent-runtime`:
|
|
303
|
+
|
|
304
|
+
- Compile-time XOR enforces passing either `prompt` or `messages` (never both or neither).
|
|
305
|
+
- Pass `onPart` on `completeText` / `completeObject` or use `streamComplete` to consume
|
|
306
|
+
`text-delta`, `reasoning-delta`, `tool-input-start`, `tool-call`, `tool-result` (preliminary and
|
|
307
|
+
final), `tool-error`, `attempt-reset`, `finish-step`, and `finish` events over a bounded async
|
|
308
|
+
iterable without a store.
|
|
309
|
+
- Standalone completions have no durable approval loop, so any tool with `needsApproval: true` (or
|
|
310
|
+
a `needsApproval` predicate returning `true`) fails closed before execution with
|
|
311
|
+
`AgentToolApprovalError` (`reason: 'approval-unsupported'`); a predicate returning `false` lets
|
|
312
|
+
the safe call proceed.
|
|
313
|
+
- Pass `retry` (`AgentRetryPolicy`) and optional `onAttemptDiscarded` for stateless retry with
|
|
314
|
+
`Retry-After` handling; exhausting retries throws `AgentRetryExhaustedError` carrying every failed
|
|
315
|
+
attempt, `lastError`, and accumulated billable `usage`.
|
|
316
|
+
- Pass `stopPolicies` (`AgentCompleteStopPolicy[]`) and `idleTimeoutMs` to bound multi-step loops
|
|
317
|
+
and stalled streams (suspending the idle timer during local tool execution).
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
import { z } from 'zod'
|
|
321
|
+
import { AgentStructuredOutputError, completeObject } from 'stitchkit/agent-runtime'
|
|
322
|
+
import { anthropicProvider } from 'stitchkit/agent-runtime/anthropic'
|
|
323
|
+
import { defineAgentTool } from 'stitchkit/tools'
|
|
324
|
+
|
|
325
|
+
const driver = anthropicProvider(
|
|
326
|
+
{ apiKey: env.ANTHROPIC_API_KEY },
|
|
327
|
+
{ defaultPolicy: { maxOutputTokens: 2048 } },
|
|
328
|
+
).create('claude-sonnet-4-5')
|
|
329
|
+
|
|
330
|
+
const lookup = defineAgentTool({
|
|
331
|
+
description: 'Fetch record summary',
|
|
332
|
+
input: z.object({ id: z.string() }),
|
|
333
|
+
execute: async ({ id }) => db.findSummary(id),
|
|
334
|
+
})
|
|
335
|
+
|
|
336
|
+
const { object, usage, steps } = await completeObject({
|
|
337
|
+
driver,
|
|
338
|
+
instructions: 'Return the normalized verdict.',
|
|
339
|
+
prompt: 'Classify ticket T-42',
|
|
340
|
+
tools: { lookup },
|
|
341
|
+
schema: z.object({ severity: z.enum(['low', 'high']), summary: z.string() }),
|
|
342
|
+
})
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
`completeObject` projects the Zod schema through `toJsonSchema(schema, 'input')` (supporting
|
|
346
|
+
`.transform()` and `.default()`), strips strict-mode synthesized `null`s on optional non-nullable
|
|
347
|
+
fields before `schema.safeParse`, validates `schemaName` through `AgentModelResponseFormatSchema`,
|
|
348
|
+
and throws `AgentStructuredOutputError` (`reason: 'truncated' | 'tool-calls' | 'content-filter' |
|
|
349
|
+
'provider-error' | 'interrupted' | 'empty' | 'invalid-json' | 'schema-mismatch'`, with
|
|
350
|
+
`finishReason`, `rawText`, `steps`, and `usage`) when the response cannot satisfy the schema.
|
|
351
|
+
|
|
352
|
+
For durable runs, the native loop also exposes:
|
|
353
|
+
|
|
354
|
+
- `loop.maxDurationMs` — hard wall-clock run deadline (`number | null`) that never pauses during
|
|
355
|
+
tool execution or resets on provider deltas, distinct from `loop.idleTimeoutMs`.
|
|
356
|
+
- `loop.beforeStepToolCalls` — a whole-step batch policy invoked once all tool calls of a step are
|
|
357
|
+
parsed and validated, returning `{ refuse: Map<toolCallId, Error> }` for any call to reject.
|
|
358
|
+
- `loop.stepBarriers.onMaxReasoningChars: 'abort' | 'finish-length'` — `'abort'` (default) ends the
|
|
359
|
+
run as `policy_stop`; `'finish-length'` cuts only the current step cleanly with
|
|
360
|
+
`finishReason: 'length'` so `protocol.acceptTerminal` can run a recovery continuation.
|
|
361
|
+
- `loop.stepBarriers.onPredecessorFailure: 'refuse'` — fail-cascades dependent calls waiting on
|
|
362
|
+
the same entity with `STEP_PREDECESSOR_FAILED` when an earlier call fails execution, fails input
|
|
363
|
+
validation, is refused by `beforeStepToolCalls`, or returns a payload matching
|
|
364
|
+
`isToolResultFailure(output)`.
|
|
365
|
+
- `loop.stepBarriers.stepText: 'after-tools'` with optional `stepTextOnInterrupt: 'drop' | 'flush'`
|
|
366
|
+
and `filterStepText(text, { step, interrupted, finishReason, toolCalls, toolResults })` — holds
|
|
367
|
+
premature step text when any tool fails (including `isToolResultFailure`) or requests approval,
|
|
368
|
+
and lets callers flush or transform held text cleanly.
|
|
369
|
+
- `loop.toolApproval` per-tool rule maps infer each tool's typed `input` from `TOOLS[K]`.
|
|
370
|
+
- `protocol.acceptTerminal` returning `{ action: 'continue', message, instructions? }` — runs a
|
|
371
|
+
bounded continuation step capped by `loop.maxContinuations` (default 3); use `carriedToolWork`
|
|
372
|
+
to inspect whether earlier steps executed tools.
|
|
373
|
+
- `loop.onAttemptDiscarded` and `loop.onToolInputStart` — observe discarded retry attempts (with
|
|
374
|
+
failure reason and billed usage) and streamed tool-input starts.
|
|
172
375
|
|
|
173
376
|
## Bounded deferred tool catalogs
|
|
174
377
|
|
|
@@ -274,7 +477,7 @@ has no side effect; an external supervisor owns process placement and restart.
|
|
|
274
477
|
| execution loop | `createAgentRuntime` | already available; do not copy a second loop |
|
|
275
478
|
| model choice | `defineModelRegistry` and `models.resolve` | provider credentials/discovery stay application-owned |
|
|
276
479
|
| resources | `createHeadlessAgentHarness` → `composeAgentPrompt` | paths, trust, precedence and watching stay application-owned |
|
|
277
|
-
| tools | `
|
|
480
|
+
| tools | `mountAgentTools` + `createAgentToolFenceLifecycle` | auth and domain effects stay application-owned |
|
|
278
481
|
| follow-up | `runs.inputPolicy: 'queue'` | durable FIFO after the current run |
|
|
279
482
|
| interrupt | `interrupt` or `interrupt-next` | `interrupt-next` terminates the active run and gives the new durable admission next priority |
|
|
280
483
|
| recovery | `runtime.recover` + `scanRecoverable` | replay safety and context reconstruction are explicit callbacks |
|
|
@@ -293,13 +496,14 @@ and requests a fresh snapshot. It never writes a second frame concurrently with
|
|
|
293
496
|
`reduceAgentControlSnapshot` and `reduceAgentControlEvent`; the reducer owns no renderer and marks a
|
|
294
497
|
conversation `resyncRequired` after a transient sequence gap.
|
|
295
498
|
|
|
296
|
-
Configure `loop.toolApproval`
|
|
297
|
-
`loop.toolApprovalSecret` to
|
|
298
|
-
before any effect. `pendingApprovals()` derives unresolved
|
|
299
|
-
`respondToApproval()` writes one tool-role approval response and
|
|
300
|
-
revalidates the signature/tool call/input before
|
|
301
|
-
|
|
302
|
-
cross-crash exactly-once
|
|
499
|
+
Configure `loop.toolApproval` for the runtime's native approval policy and
|
|
500
|
+
`loop.toolApprovalSecret` to bind exact requests with WebCrypto HMAC-SHA256 signatures. A request
|
|
501
|
+
is stored on the terminal assistant before any effect. `pendingApprovals()` derives unresolved
|
|
502
|
+
requests from canonical messages; `respondToApproval()` writes one tool-role approval response and
|
|
503
|
+
queues a successor. The native loop revalidates the signature/tool call/input once before any
|
|
504
|
+
retry attempts and before the original direct tool reaches its existing fence. Reconnect and SQLite
|
|
505
|
+
reopen require no promise registry. Remembered policy and a stronger cross-crash exactly-once
|
|
506
|
+
guarantee remain application concerns.
|
|
303
507
|
|
|
304
508
|
Approval requests suspend a call; they do not settle its result. History carries exact call and
|
|
305
509
|
approval identity across assistant/tool records, so an approved result can precede the next signed
|
|
@@ -571,150 +775,3 @@ schema version, conversation identity and monotonic version. Runs and admission
|
|
|
571
775
|
recovery queries active run states directly instead of maintaining a second projection.
|
|
572
776
|
An admission receipt retains its canonical input, and a terminal run retains its canonical
|
|
573
777
|
assistant, so physical product-history compaction cannot break idempotent retries.
|
|
574
|
-
|
|
575
|
-
### Built-in SQLite persistence
|
|
576
|
-
|
|
577
|
-
Use the runtime-specific leaf; the neutral agent runtime never imports either
|
|
578
|
-
SQLite built-in:
|
|
579
|
-
|
|
580
|
-
```ts
|
|
581
|
-
// Bun
|
|
582
|
-
import { createBunSqliteAgentRuntimeStore } from 'stitchkit/agent-runtime/sqlite/bun'
|
|
583
|
-
|
|
584
|
-
const sqlite = createBunSqliteAgentRuntimeStore({ filename: './agent-runtime.sqlite' })
|
|
585
|
-
const runtime = createAgentRuntime({ ...config, store: sqlite.store })
|
|
586
|
-
|
|
587
|
-
await runtime.close()
|
|
588
|
-
await sqlite.close()
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
```ts
|
|
592
|
-
// Node 22.5+
|
|
593
|
-
import { createNodeSqliteAgentRuntimeStore } from 'stitchkit/agent-runtime/sqlite/node'
|
|
594
|
-
|
|
595
|
-
const sqlite = createNodeSqliteAgentRuntimeStore({ filename: './agent-runtime.sqlite' })
|
|
596
|
-
```
|
|
597
|
-
|
|
598
|
-
Initialization creates only `stitchkit_agent_runtime_*` tables and records
|
|
599
|
-
schema version 2 in `stitchkit_agent_runtime_meta`; it does not use
|
|
600
|
-
`PRAGMA user_version` or mutate application tables. An unknown schema version or
|
|
601
|
-
unversioned partial Stitchkit schema is refused. The connection is owned by the
|
|
602
|
-
returned handle and closes only after accepted operations drain.
|
|
603
|
-
|
|
604
|
-
Each handle serializes its transactions. Separate connections use
|
|
605
|
-
`busy_timeout = 0`: a competing synchronous writer fails promptly with
|
|
606
|
-
SQLite's lock error, so an awaited transaction can resume and commit or roll
|
|
607
|
-
back. Retry that explicit error with an application-owned bounded policy; do
|
|
608
|
-
not configure a blocking busy timeout on the same JavaScript thread.
|
|
609
|
-
|
|
610
|
-
Aggregate reads and catalog pages use `BEGIN`, so a WAL writer may remain active
|
|
611
|
-
while the reader sees one committed snapshot. Mutations and purge use
|
|
612
|
-
`BEGIN IMMEDIATE`: they reserve the writer slot before reading state for CAS and
|
|
613
|
-
never attempt a deferred read-to-write upgrade. A custom driver may inspect the
|
|
614
|
-
additive `transaction` option `{ access: 'read' }`; ignoring it preserves the
|
|
615
|
-
previous write-safe behavior.
|
|
616
|
-
|
|
617
|
-
The adapter proves canonical durability across reopen and process restart. It
|
|
618
|
-
does not make external tool effects exactly once, join application projections
|
|
619
|
-
atomically or replace an application outbox. If a product row must commit with
|
|
620
|
-
an agent transition, implement `AgentRuntimeStoreDriver` over the application's
|
|
621
|
-
own transaction boundary instead.
|
|
622
|
-
|
|
623
|
-
Opening a version 1 store migrates it in one transaction, forward only — back
|
|
624
|
-
the file up first, a 0.85.x package refuses a migrated file. Existing
|
|
625
|
-
normalized state becomes one `runtime/baseline` event per conversation, dated
|
|
626
|
-
when the migration ran and carrying `asOf` for the last message it describes;
|
|
627
|
-
search and projections address that pre-migration history as one snapshot at
|
|
628
|
-
`seq 1`. New transitions continue the monotonic conversation sequence. Version
|
|
629
|
-
2 requires SQLite FTS5 because event search is an advertised capability, so a
|
|
630
|
-
build without FTS5 is a startup error (`requires FTS5 support`) rather than an
|
|
631
|
-
empty search result; check with
|
|
632
|
-
`SELECT sqlite_compileoption_used('ENABLE_FTS5')`.
|
|
633
|
-
|
|
634
|
-
The handle returned by `createBunSqliteAgentRuntimeStore` /
|
|
635
|
-
`createNodeSqliteAgentRuntimeStore` is `{ store, conversations, host, close }`.
|
|
636
|
-
`host` is where the companions keep their rows — `createAgentProjectionStore`,
|
|
637
|
-
`createAgentSpillStore`, `createAgentChildManager`,
|
|
638
|
-
`createAgentScheduleService` and `createAgentEventSearch` take it (the child
|
|
639
|
-
manager and the projection store `{ store, host }`). `host.transaction(conversationId, work)`
|
|
640
|
-
is one write transaction of the store: it refuses a purged conversation, and
|
|
641
|
-
the companion's row and its event commit together or not at all.
|
|
642
|
-
`host.read(work)` is a read transaction. Companions exist on the SQLite and
|
|
643
|
-
Postgres stores; the memory store and a hand-written driver have none. The
|
|
644
|
-
event search uses FTS5 on SQLite and a `tsvector` index on Postgres.
|
|
645
|
-
|
|
646
|
-
### On Postgres
|
|
647
|
-
|
|
648
|
-
`stitchkit/agent-runtime/postgres` is the same store on Postgres, over the
|
|
649
|
-
application's own client:
|
|
650
|
-
|
|
651
|
-
```ts
|
|
652
|
-
import { SQL } from 'bun'
|
|
653
|
-
import { createPostgresAgentRuntimeStore } from 'stitchkit/agent-runtime/postgres'
|
|
654
|
-
|
|
655
|
-
const sql = new SQL(process.env.DATABASE_URL)
|
|
656
|
-
const { store, conversations, host } = createPostgresAgentRuntimeStore<SQL>({
|
|
657
|
-
transaction: (work) => sql.begin((tx) => work(tx)),
|
|
658
|
-
query: (tx, text, parameters) => tx.unsafe(text, [...parameters]),
|
|
659
|
-
})
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
With Prisma, `transaction: (work) => prisma.$transaction(work)` and
|
|
663
|
-
`query: (tx, text, parameters) => tx.$queryRawUnsafe(text, ...parameters)`.
|
|
664
|
-
|
|
665
|
-
The store owns its transactions, unlike the sync store, which writes inside
|
|
666
|
-
the application's transaction so a change commits with the application's own
|
|
667
|
-
rows. Every write runs SERIALIZABLE, and a serialization conflict — on any
|
|
668
|
-
statement, or on `COMMIT` — is cured only by running the whole unit again,
|
|
669
|
-
which only the code that opened the transaction can do. So `transaction` must
|
|
670
|
-
open a fresh transaction on every call, and the store's isolation statement is
|
|
671
|
-
the first in it; a transaction the application already used is refused in
|
|
672
|
-
words. Retrying is the driver's duty: `withStoreRetries` around a store call
|
|
673
|
-
does not replace it.
|
|
674
|
-
|
|
675
|
-
The schema is versioned and created on first use under an advisory lock, so
|
|
676
|
-
processes starting at once agree on it; a schema of another version or with
|
|
677
|
-
tables missing is refused, not repaired. When migrations own the schema, pass
|
|
678
|
-
`createTables: false` and put `postgresAgentRuntimeStoreDdl(prefix)` in one;
|
|
679
|
-
the version is still checked. `prefix` (default `stitchkit_agent_runtime`)
|
|
680
|
-
keeps two stores in one database apart. Identifiers and timestamps are stored
|
|
681
|
-
as written, byte for byte, so an archive exported from Postgres imports into
|
|
682
|
-
SQLite and back unchanged.
|
|
683
|
-
|
|
684
|
-
`conversations.messages` pages the model's history: what compaction removed is
|
|
685
|
-
not in it, which is the point of compaction. A person reading back their own
|
|
686
|
-
conversation needs the other view, and asks for it explicitly:
|
|
687
|
-
|
|
688
|
-
```ts
|
|
689
|
-
const page = await conversations.messages({
|
|
690
|
-
conversationId,
|
|
691
|
-
limit: 50,
|
|
692
|
-
direction: 'after',
|
|
693
|
-
includeCompacted: true,
|
|
694
|
-
})
|
|
695
|
-
const removed = new Set(page.compacted)
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
`items` stays one sequence in the order it happened, and `compacted` names the
|
|
699
|
-
ids inside it that the model no longer sees — the boundary is a mark on the
|
|
700
|
-
conversation, not a second list. A compaction summary sits at the position of
|
|
701
|
-
the last message it replaced, so the block reads through and the summary
|
|
702
|
-
arrives after it, where it was written; in the model's history, where every
|
|
703
|
-
replaced message is gone, it occupies the block's place either way. Without
|
|
704
|
-
the flag the page is exactly what it was, `compacted`
|
|
705
|
-
empty. The v1 → v2 migration baseline records the same thing: the whole
|
|
706
|
-
sequence, with `compacted` naming what had been folded away. A file migrated
|
|
707
|
-
by 0.86.0 has a baseline built from the active history only — the messages
|
|
708
|
-
themselves are still in the store and this read reaches them, but that one
|
|
709
|
-
event cannot be rewritten after the fact.
|
|
710
|
-
|
|
711
|
-
### Retried provider streams
|
|
712
|
-
|
|
713
|
-
With `loop.retry` set, a provider stream that fails before any tool call in the
|
|
714
|
-
attempt is retried at the step boundary. Subscribers see `attempt-reset` for the
|
|
715
|
-
run before the next attempt's first delta and drop what the failed attempt
|
|
716
|
-
streamed; the durable draft is checkpointed after that output is discarded; an
|
|
717
|
-
input injected into the failed attempt is taken again by the retry; and the
|
|
718
|
-
failed attempt's reported usage stays in the run's spend. Transient events —
|
|
719
|
-
deltas, reasoning, `attempt-reset` — are numbered from 1 per run, counting only
|
|
720
|
-
what was published, so a cursor sees no gap on an ordinary stream.
|
package/llms/contract.txt
CHANGED
|
@@ -542,7 +542,8 @@ from the root `stitchkit`.
|
|
|
542
542
|
| `ContractDef` | _type_ | a defined contract |
|
|
543
543
|
| `PathParams` | _type_ | infer named `:segments` and a terminal `*wildcard` from a path literal as string params |
|
|
544
544
|
| `ContractMeta` | _type_ | a contract's `prefix` + optional `scope` and `meta` (a default every endpoint shallow-merges over) |
|
|
545
|
-
| `EndpointDef` | _type_ | a single endpoint definition; `output` declares JSON response presence (`null` is data, `undefined` is invalid); optional `effect?: OperationEffect` declares `'read' \| 'write'` side effects; `safelistedBody: true` admits the JSON body as `text/plain` from an allow-listed `Origin` — [guide](../guide/server.md#safelisted-request-bodies-beacons) |
|
|
545
|
+
| `EndpointDef` | _type_ | a single endpoint definition; `output` declares JSON response presence (`null` is data, `undefined` is invalid); optional `timeout` bounds both client calls and server-side deadline clamping; optional `effect?: OperationEffect` declares `'read' \| 'write'` side effects; `safelistedBody: true` admits the JSON body as `text/plain` from an allow-listed `Origin` — [guide](../guide/server.md#safelisted-request-bodies-beacons) |
|
|
546
|
+
| `DEADLINE_BUDGET_HEADER` | constant | `'x-stitchkit-timeout-ms'` — relative remaining call budget in integer milliseconds propagated across HTTP hops (`createHttpClient` / `createClient` outbound, `createHandler` / `createServer` inbound with contract-ceiling clamping, `408 REQUEST_TIMEOUT` on `'0'`, linked `ctx.signal`, and `ctx.remainingTimeoutMs(reserveMs?)`) |
|
|
546
547
|
| `OperationEffect` / `OperationEffectSchema` | _type_ / schema | closed `'read' \| 'write'` side-effect classification declared on contract endpoints |
|
|
547
548
|
| `contractOperationEffects` / `requireContractOperationEffects` | function | project declared endpoint `effect` tags from a contract; `requireContractOperationEffects` fails closed and lists every operation missing `effect` |
|
|
548
549
|
| `withToolView` | function | declare an endpoint's call and answer on the tool surface (MCP, AGENT, CLI): input `defaults`, and optionally a view `output` and a `project`, typed against the endpoint's own schemas; HTTP keeps the full answer — [guide](../guide/mcp-and-agents.md#a-different-answer-for-tools--withtoolview) |
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# stitchkit/device-relay — stitchkit docs slice
|
|
2
|
+
|
|
3
|
+
> Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
|
|
4
|
+
> `llms.txt` in this package.
|
|
5
|
+
|
|
6
|
+
Contains: API reference: `stitchkit/device-relay` (docs/api/reference.md)
|
|
7
|
+
|
|
8
|
+
Also read:
|
|
9
|
+
- see `llms/server.txt` for the Realtime guide
|
|
10
|
+
|
|
11
|
+
==============================================================================
|
|
12
|
+
# API reference: `stitchkit/device-relay` (docs/api/reference.md)
|
|
13
|
+
==============================================================================
|
|
14
|
+
|
|
15
|
+
## `stitchkit/device-relay`
|
|
16
|
+
|
|
17
|
+
Peer-free, browser- and Hermes-safe User Device Relay over realtime. Multiplexes unary Fetch RPCs
|
|
18
|
+
and credit-paced resumable cursor streams over a single outbound realtime connection from a user's
|
|
19
|
+
desktop machine to a multi-tenant backend hub.
|
|
20
|
+
|
|
21
|
+
| Export | Kind | Summary |
|
|
22
|
+
|--------|------|---------|
|
|
23
|
+
| `createDeviceRelayHub` / `DeviceRelayHub` / `DeviceRelayHubConfig` / `DeviceRelayFetchOptions` / `DeviceRelayStreamOpenOptions` | function / _types_ | backend hub binding authenticated `(accountId, deviceId)` sockets with conservative heartbeat leases, strict owner-only default access (`FORBIDDEN` for foreign accounts), Fetch-compatible `createRelayFetch`, and `openRelayStream` (with optional `share: true` fan-out that closes upstream when the last subscriber leaves) |
|
|
24
|
+
| `DeviceRelayRealtimeServer` / `DeviceRelayServerConnection` / `DeviceRelayRawSocket` / `DeviceRelayDeviceAuthInput` / `DeviceRelayAuthenticatedDevice` / `DeviceRelayAccessRequest` | _types_ | peer-free structural server contracts satisfied directly by `bindRealtimeServer(deviceRelayRealtimeContract, io)` |
|
|
25
|
+
| `createDeviceRelayAgent` / `DeviceRelayAgent` / `DeviceRelayAgentConfig` / `DeviceRelayAgentState` / `DeviceRelayRpcAllowRule` / `DeviceRelayAgentStreamInput` / `DeviceRelayUpstreamFrame` | function / _types_ | desktop-side relay agent with default-deny local allowlists (`allowRpc`, `allowStreamTopics`), credit-paced stream pumping, bounded payloads, and non-retryable auth refusal handling |
|
|
26
|
+
| `createMemoryRelayBroker` / `RelayBrokerPort` / `RelayBrokerInstanceHandler` / `RelayBrokerStreamHandle` / `RelayBrokerStreamSink` | function / _types_ | multi-replica routing port (`RelayBrokerPort`) and in-memory default broker (`createMemoryRelayBroker`) |
|
|
27
|
+
| `DeviceRelayStream` / `DeviceRelayStreamFrame` | _types_ | async-iterable cursor stream handle and yielded frame shape |
|
|
28
|
+
| `deviceRelayRealtimeContract` | const | namespaced Zod-validated `RealtimeContract` (`stitchkit.relay.*` hello, heartbeat, unary RPC and cursor stream frames) |
|
|
29
|
+
| `DeviceRelayError` / `DeviceRelayErrorCodeSchema` / `DeviceRelayErrorCode` / `DeviceRelayDeliveryStateSchema` / `DeviceRelayDeliveryState` / `isDeviceRelayRetryableCode` / `isRetryableDeviceRelayError` | class / schemas / functions | typed relay error vocabulary separating retryable transport/offline faults from non-retryable refusals and carrying honest `delivery` (`not-sent`, `unknown`, `delivered`) |
|
|
30
|
+
| `DeviceRelayStateSchema` / `DeviceRelayState` / `DeviceRelayStatusSchema` / `DeviceRelayStatus` / `DeviceRelayOfflineReasonSchema` / `DeviceRelayOfflineReason` | schemas / _types_ | live presence snapshot, status (`online`, `offline`) and offline transition reasons (`disconnected`, `lease-expired`, `replaced`, `closed`) |
|
|
31
|
+
| `DeviceRelayHelloSchema` / `DeviceRelayHello` / `DeviceRelayHelloAckSchema` / `DeviceRelayHelloAck` / `DeviceRelayHeartbeatSchema` / `DeviceRelayHeartbeat` / `DeviceRelayHeartbeatAckSchema` / `DeviceRelayHeartbeatAck` | schemas / _types_ | handshake registration and lease renewal wire frames |
|
|
32
|
+
| `DeviceRelayRpcRequestSchema` / `DeviceRelayRpcRequest` / `DeviceRelayRpcCancelSchema` / `DeviceRelayRpcCancel` / `DeviceRelayRpcResponseSchema` / `DeviceRelayRpcResponse` / `DeviceRelayHeaderEntrySchema` / `DeviceRelayHeaderEntry` / `DeviceRelayBodyEncodingSchema` / `DeviceRelayBodyEncoding` | schemas / _types_ | unary HTTP-over-realtime request, cancel and response wire frames |
|
|
33
|
+
| `DeviceRelayStreamOpenSchema` / `DeviceRelayStreamOpen` / `DeviceRelayStreamOpenAckSchema` / `DeviceRelayStreamOpenAck` / `DeviceRelayStreamCreditSchema` / `DeviceRelayStreamCredit` / `DeviceRelayStreamCloseSchema` / `DeviceRelayStreamClose` / `DeviceRelayStreamEventSchema` / `DeviceRelayStreamEvent` / `DeviceRelayJsonValueSchema` / `DeviceRelayJsonValue` | schemas / _types_ | cursor stream open, ack, credit, close and event wire frames |
|
|
34
|
+
| `DEVICE_RELAY_ORIGIN` / `DEFAULT_DEVICE_RELAY_LEASE_TTL_MS` / `DEFAULT_DEVICE_RELAY_HEARTBEAT_INTERVAL_MS` / `DEFAULT_DEVICE_RELAY_RPC_TIMEOUT_MS` / `DEFAULT_DEVICE_RELAY_MAX_REQUEST_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_RESPONSE_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_STREAM_FRAME_BYTES` / `DEFAULT_DEVICE_RELAY_MAX_IN_FLIGHT_RPCS` / `DEFAULT_DEVICE_RELAY_MAX_CONCURRENT_STREAMS` / `DEFAULT_DEVICE_RELAY_MAX_BUFFERED_FRAMES` | consts | declared default bounds and synthetic path-parsing origin |
|
package/llms/realtime.txt
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
|
|
6
6
|
Contains: API reference: `stitchkit/realtime` (docs/api/reference.md)
|
|
7
7
|
|
|
8
|
+
Also read:
|
|
9
|
+
- see `llms/server.txt` for the Realtime guide
|
|
10
|
+
|
|
8
11
|
==============================================================================
|
|
9
12
|
# API reference: `stitchkit/realtime` (docs/api/reference.md)
|
|
10
13
|
==============================================================================
|
|
@@ -40,3 +43,20 @@ Native consumers import HTTP factories, `ApiError`, `createUrlBuilder`,
|
|
|
40
43
|
`RealtimeClient`, `defineRealtimeContract`, `InferRealtimeEventMap`, `createRetainedTopics`
|
|
41
44
|
and `RetainedTopics` from `stitchkit/realtime`. `createQueryClientFactory` remains in
|
|
42
45
|
`stitchkit/react`. Shared modules must use the same public leaves throughout their graph.
|
|
46
|
+
|
|
47
|
+
### Account device presence and remote command bus
|
|
48
|
+
|
|
49
|
+
Share one realtime connection across account-scoped online device presence, live capability state
|
|
50
|
+
slots (media playback, active reading, relay status) and targeted remote commands with structured
|
|
51
|
+
acknowledgements (`ok`, `DEVICE_OFFLINE`, `FORBIDDEN`, `TIMEOUT`, `UNSUPPORTED_CAPABILITY`,
|
|
52
|
+
`HANDLER_ERROR`, `INVALID_COMMAND`, `DISCONNECTED`). Mount the server side with
|
|
53
|
+
`bindDevicePresence` from `stitchkit/server`.
|
|
54
|
+
|
|
55
|
+
| Export | Kind | Summary |
|
|
56
|
+
|--------|------|---------|
|
|
57
|
+
| `createDevicePresenceContract` / `DevicePresenceContract` / `DevicePresenceContractOptions` / `DevicePresenceCapabilityDef` / `DevicePresenceCapabilityMap` / `DevicePresenceCapabilityKey` / `DevicePresenceCapabilityResult` / `DevicePresenceEventNames` / `DevicePresenceSchemas` | function / _types_ | capability-driven strict Zod contract (`{ [capability]: { state, command, result? } }`) generating namespaced wire events and schemas |
|
|
58
|
+
| `createDevicePresenceClient` / `DevicePresenceClient` / `DevicePresenceClientConfig` / `DevicePresenceSubscriber` / `DevicePresenceSendCommandInput` / `DevicePresenceCommandHandler` / `DevicePresenceCommandContext` | function / _types_ | typed browser / native client over `RealtimeClientTransport` with `subscribe`, `publishState`, `sendCommand`, `onCommand`, automatic re-announce and local state republication after reconnect |
|
|
59
|
+
| `createDevicePresenceRelayAdapter` / `DevicePresenceRelayAdapter` / `DevicePresenceRelayAdapterConfig` / `DevicePresenceRelayStateSource` / `DevicePresenceRelayStateSchema` / `DevicePresenceRelayState` | function / schema / _types_ | connects a desktop or mobile relay host's lifecycle state to a presence capability slot over the shared socket |
|
|
60
|
+
| `DevicePresenceIdentitySchema` / `DevicePresenceIdentity` / `DevicePresenceErrorCodeSchema` / `DevicePresenceErrorCode` | schemas / _types_ | strict device identity metadata and closed error code vocabulary |
|
|
61
|
+
| `DevicePresenceDevice` / `DevicePresenceSnapshot` / `DevicePresenceStates` / `DevicePresenceStatesInput` / `DevicePresenceAnnouncePayload` / `DevicePresenceAnnounceAck` / `DevicePresenceStateUpdatePayload` / `DevicePresenceStateUpdateAck` / `DevicePresenceCommandRequest` / `DevicePresenceCommandDelivery` / `DevicePresenceCommandResult` | _types_ | inferred account presence snapshot, state update and targeted remote command wire payloads |
|
|
62
|
+
| `DEFAULT_DEVICE_PRESENCE_PREFIX` / `DEFAULT_DEVICE_PRESENCE_COMMAND_TIMEOUT_MS` / `DEFAULT_DEVICE_PRESENCE_REQUEST_TIMEOUT_MS` | consts | default event namespace prefix and timeout bounds |
|