stitchkit 0.134.2 → 0.135.1
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 +42 -0
- package/README.md +1 -1
- package/dist/agent-executor/acp/v1-connect.d.ts +1 -1
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- 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/json-rpc-peer.d.ts +1 -1
- package/dist/agent-executor/json-rpc-peer.d.ts.map +1 -1
- package/dist/agent-runtime/browser/browser-control-contract.d.ts +1364 -0
- package/dist/agent-runtime/browser/browser-control-contract.d.ts.map +1 -0
- package/dist/agent-runtime/browser/browser-controller-view.d.ts +44 -0
- package/dist/agent-runtime/browser/browser-controller-view.d.ts.map +1 -0
- package/dist/agent-runtime/browser/browser-controller.d.ts +53 -0
- package/dist/agent-runtime/browser/browser-controller.d.ts.map +1 -0
- package/dist/agent-runtime/browser/control-interaction-schema.d.ts.map +1 -0
- package/dist/agent-runtime/browser/control-schema.d.ts +1378 -0
- package/dist/agent-runtime/browser/control-schema.d.ts.map +1 -0
- package/dist/agent-runtime/browser/control-view.d.ts +64 -0
- package/dist/agent-runtime/browser/control-view.d.ts.map +1 -0
- package/dist/agent-runtime/browser/react.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-discovery.d.ts +25 -0
- package/dist/agent-runtime/coding/coding-discovery.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-sandbox.d.ts +8 -0
- package/dist/agent-runtime/coding/coding-sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-automaton.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-case-fold.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-class-ranges.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-contract.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-limits.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-matcher.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-output.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-regex-syntax.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-search-unit-classes.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-shell-process.d.ts +36 -0
- package/dist/agent-runtime/coding/coding-shell-process.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-contract.d.ts +261 -0
- package/dist/agent-runtime/coding/coding-tool-contract.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-files.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-listing.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-paths.d.ts +53 -0
- package/dist/agent-runtime/coding/coding-tool-paths.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-refusals.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-search-patch.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-search.d.ts +113 -0
- package/dist/agent-runtime/coding/coding-tool-search.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-shell.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tool-utf8.d.ts.map +1 -0
- package/dist/agent-runtime/coding/coding-tools.d.ts.map +1 -0
- package/dist/agent-runtime/coding/contained-scan-budget.d.ts.map +1 -0
- package/dist/agent-runtime/coding/contained-scan-contract.d.ts.map +1 -0
- package/dist/agent-runtime/coding/contained-scan.d.ts +56 -0
- package/dist/agent-runtime/coding/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/coding/workspace-glob.d.ts.map +1 -0
- package/dist/agent-runtime/context-issue.d.ts +1 -1
- package/dist/agent-runtime/context-issue.d.ts.map +1 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts +3 -1
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/harness/harness-contract.d.ts +206 -0
- package/dist/agent-runtime/harness/harness-contract.d.ts.map +1 -0
- package/dist/agent-runtime/harness/harness-control.d.ts +34 -0
- package/dist/agent-runtime/harness/harness-control.d.ts.map +1 -0
- package/dist/agent-runtime/harness/harness-file-resources.d.ts +33 -0
- package/dist/agent-runtime/harness/harness-file-resources.d.ts.map +1 -0
- package/dist/agent-runtime/harness/harness-resources.d.ts.map +1 -0
- package/dist/agent-runtime/harness/harness.d.ts +15 -0
- package/dist/agent-runtime/harness/harness.d.ts.map +1 -0
- package/dist/agent-runtime/history/compaction.d.ts +103 -0
- package/dist/agent-runtime/history/compaction.d.ts.map +1 -0
- package/dist/agent-runtime/history/history.d.ts +93 -0
- package/dist/agent-runtime/history/history.d.ts.map +1 -0
- package/dist/agent-runtime/history/run-history-parts.d.ts +14 -0
- package/dist/agent-runtime/history/run-history-parts.d.ts.map +1 -0
- package/dist/agent-runtime/loop/admission-lanes.d.ts +35 -0
- package/dist/agent-runtime/loop/admission-lanes.d.ts.map +1 -0
- package/dist/agent-runtime/loop/coordinator.d.ts.map +1 -0
- package/dist/agent-runtime/loop/deferred-tool-search.d.ts +9 -0
- package/dist/agent-runtime/loop/deferred-tool-search.d.ts.map +1 -0
- package/dist/agent-runtime/loop/deferred-tool-selection.d.ts +32 -0
- package/dist/agent-runtime/loop/deferred-tool-selection.d.ts.map +1 -0
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts +19 -0
- package/dist/agent-runtime/loop/deferred-tools-internal.d.ts.map +1 -0
- package/dist/agent-runtime/loop/deferred-tools.d.ts +4 -0
- package/dist/agent-runtime/loop/deferred-tools.d.ts.map +1 -0
- package/dist/agent-runtime/loop/injection.d.ts +28 -0
- package/dist/agent-runtime/loop/injection.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-attempt.d.ts +32 -0
- package/dist/agent-runtime/loop/invocation-attempt.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-failure.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-payload.d.ts +38 -0
- package/dist/agent-runtime/loop/invocation-payload.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-read.d.ts +134 -0
- package/dist/agent-runtime/loop/invocation-read.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-spend.d.ts +9 -0
- package/dist/agent-runtime/loop/invocation-spend.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocation-stream.d.ts +20 -0
- package/dist/agent-runtime/loop/invocation-stream.d.ts.map +1 -0
- package/dist/agent-runtime/loop/invocations.d.ts +63 -0
- package/dist/agent-runtime/loop/invocations.d.ts.map +1 -0
- package/dist/agent-runtime/loop/managed-tools.d.ts +20 -0
- package/dist/agent-runtime/loop/managed-tools.d.ts.map +1 -0
- package/dist/agent-runtime/loop/observability.d.ts +579 -0
- package/dist/agent-runtime/loop/observability.d.ts.map +1 -0
- package/dist/agent-runtime/loop/owned-provider-stream.d.ts.map +1 -0
- package/dist/agent-runtime/loop/provider-origin.d.ts +17 -0
- package/dist/agent-runtime/loop/provider-origin.d.ts.map +1 -0
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts +5 -0
- package/dist/agent-runtime/loop/provider-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts +63 -0
- package/dist/agent-runtime/loop/provider-stream-segments.d.ts.map +1 -0
- package/dist/agent-runtime/loop/retry-policy.d.ts +49 -0
- package/dist/agent-runtime/loop/retry-policy.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-acquisition.d.ts +24 -0
- package/dist/agent-runtime/loop/run-acquisition.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-approval.d.ts +82 -0
- package/dist/agent-runtime/loop/run-approval.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete-retry.d.ts +24 -0
- package/dist/agent-runtime/loop/run-complete-retry.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete-stream.d.ts +9 -0
- package/dist/agent-runtime/loop/run-complete-stream.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete-types.d.ts +171 -0
- package/dist/agent-runtime/loop/run-complete-types.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-complete.d.ts +25 -0
- package/dist/agent-runtime/loop/run-complete.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-driver-compose.d.ts +21 -0
- package/dist/agent-runtime/loop/run-driver-compose.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-execution-state.d.ts +177 -0
- package/dist/agent-runtime/loop/run-execution-state.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-execution.d.ts +22 -0
- package/dist/agent-runtime/loop/run-execution.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-failure.d.ts +21 -0
- package/dist/agent-runtime/loop/run-failure.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-loop-events.d.ts +126 -0
- package/dist/agent-runtime/loop/run-loop-events.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-attempts.d.ts +6 -0
- package/dist/agent-runtime/loop/run-model-attempts.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-messages.d.ts +9 -0
- package/dist/agent-runtime/loop/run-model-messages.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-step.d.ts +43 -0
- package/dist/agent-runtime/loop/run-model-step.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-model-stream.d.ts +27 -0
- package/dist/agent-runtime/loop/run-model-stream.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts +32 -0
- package/dist/agent-runtime/loop/run-operation-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-prompt-history.d.ts +53 -0
- package/dist/agent-runtime/loop/run-prompt-history.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-provider-ledger.d.ts +32 -0
- package/dist/agent-runtime/loop/run-provider-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-barriers.d.ts +120 -0
- package/dist/agent-runtime/loop/run-step-barriers.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-helpers.d.ts +50 -0
- package/dist/agent-runtime/loop/run-step-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-prepare.d.ts +34 -0
- package/dist/agent-runtime/loop/run-step-prepare.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-step-spend.d.ts +394 -0
- package/dist/agent-runtime/loop/run-step-spend.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-stream-parts.d.ts +34 -0
- package/dist/agent-runtime/loop/run-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-stream-recorded.d.ts +8 -0
- package/dist/agent-runtime/loop/run-stream-recorded.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-stream-step-text.d.ts +47 -0
- package/dist/agent-runtime/loop/run-stream-step-text.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-terminal.d.ts +11 -0
- package/dist/agent-runtime/loop/run-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts +36 -0
- package/dist/agent-runtime/loop/run-tool-approval-flow.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-approval-records.d.ts +24 -0
- package/dist/agent-runtime/loop/run-tool-approval-records.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-call.d.ts +119 -0
- package/dist/agent-runtime/loop/run-tool-call.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-errors.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-executor.d.ts +42 -0
- package/dist/agent-runtime/loop/run-tool-executor.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-progress.d.ts +21 -0
- package/dist/agent-runtime/loop/run-tool-progress.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-tool-slots.d.ts +114 -0
- package/dist/agent-runtime/loop/run-tool-slots.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-turn-preparation.d.ts +25 -0
- package/dist/agent-runtime/loop/run-turn-preparation.d.ts.map +1 -0
- package/dist/agent-runtime/loop/run-unacquired.d.ts +19 -0
- package/dist/agent-runtime/loop/run-unacquired.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime-admission-gate.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime-control.d.ts +9 -0
- package/dist/agent-runtime/loop/runtime-control.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime-recovery.d.ts +10 -0
- package/dist/agent-runtime/loop/runtime-recovery.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime-state.d.ts +36 -0
- package/dist/agent-runtime/loop/runtime-state.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime-submit.d.ts +5 -0
- package/dist/agent-runtime/loop/runtime-submit.d.ts.map +1 -0
- package/dist/agent-runtime/loop/runtime.d.ts +352 -0
- package/dist/agent-runtime/loop/runtime.d.ts.map +1 -0
- package/dist/agent-runtime/loop/state-slots.d.ts +48 -0
- package/dist/agent-runtime/loop/state-slots.d.ts.map +1 -0
- package/dist/agent-runtime/loop/state-tools.d.ts +117 -0
- package/dist/agent-runtime/loop/state-tools.d.ts.map +1 -0
- package/dist/agent-runtime/protocol.d.ts +1 -1
- package/dist/agent-runtime/protocol.d.ts.map +1 -1
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts +15 -0
- package/dist/agent-runtime/providers/ai-sdk-convert.d.ts.map +1 -0
- package/dist/agent-runtime/providers/ai-sdk.d.ts +31 -0
- package/dist/agent-runtime/providers/ai-sdk.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic-media.d.ts +11 -0
- package/dist/agent-runtime/providers/anthropic-media.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic-messages.d.ts +25 -0
- package/dist/agent-runtime/providers/anthropic-messages.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic-options.d.ts +80 -0
- package/dist/agent-runtime/providers/anthropic-options.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic-response.d.ts +19 -0
- package/dist/agent-runtime/providers/anthropic-response.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic-sse.d.ts.map +1 -0
- package/dist/agent-runtime/providers/anthropic.d.ts.map +1 -0
- package/dist/agent-runtime/providers/models-driver-step.d.ts +212 -0
- package/dist/agent-runtime/providers/models-driver-step.d.ts.map +1 -0
- package/dist/agent-runtime/providers/models-driver-telemetry.d.ts.map +1 -0
- package/dist/agent-runtime/providers/models-driver.d.ts +235 -0
- package/dist/agent-runtime/providers/models-driver.d.ts.map +1 -0
- package/dist/agent-runtime/providers/models.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai-messages.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai-options.d.ts +91 -0
- package/dist/agent-runtime/providers/openai-options.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai-response.d.ts +77 -0
- package/dist/agent-runtime/providers/openai-response.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai-sse-state.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai-sse.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openai.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-admission.d.ts +85 -0
- package/dist/agent-runtime/providers/openrouter-admission.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-audio.d.ts +122 -0
- package/dist/agent-runtime/providers/openrouter-audio.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-benchmarks.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-catalog-cache.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-catalog-query.d.ts +82 -0
- package/dist/agent-runtime/providers/openrouter-catalog-query.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts +260 -0
- package/dist/agent-runtime/providers/openrouter-catalog.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-http.d.ts +100 -0
- package/dist/agent-runtime/providers/openrouter-http.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-media.d.ts +160 -0
- package/dist/agent-runtime/providers/openrouter-media.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-models.d.ts +203 -0
- package/dist/agent-runtime/providers/openrouter-models.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-options.d.ts +138 -0
- package/dist/agent-runtime/providers/openrouter-options.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-response.d.ts +22 -0
- package/dist/agent-runtime/providers/openrouter-response.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts +114 -0
- package/dist/agent-runtime/providers/openrouter-retrieval.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-route.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-spend.d.ts +28 -0
- package/dist/agent-runtime/providers/openrouter-spend.d.ts.map +1 -0
- 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 +82 -0
- package/dist/agent-runtime/providers/openrouter-systemone.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter-url.d.ts +13 -0
- package/dist/agent-runtime/providers/openrouter-url.d.ts.map +1 -0
- package/dist/agent-runtime/providers/openrouter.d.ts +50 -0
- package/dist/agent-runtime/providers/openrouter.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-cache.d.ts +30 -0
- package/dist/agent-runtime/providers/provider-cache.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-content.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-failure.d.ts +97 -0
- package/dist/agent-runtime/providers/provider-failure.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-history.d.ts +13 -0
- package/dist/agent-runtime/providers/provider-history.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-http.d.ts +82 -0
- package/dist/agent-runtime/providers/provider-http.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-journal.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-json-schema-strip.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-json-schema.d.ts +31 -0
- package/dist/agent-runtime/providers/provider-json-schema.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-media.d.ts +49 -0
- package/dist/agent-runtime/providers/provider-media.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-openai-chat-helpers.d.ts +27 -0
- package/dist/agent-runtime/providers/provider-openai-chat-helpers.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-openai-chat-sse.d.ts +25 -0
- package/dist/agent-runtime/providers/provider-openai-chat-sse.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-openai-chat.d.ts +27 -0
- package/dist/agent-runtime/providers/provider-openai-chat.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-sse.d.ts.map +1 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts +24 -0
- package/dist/agent-runtime/providers/provider-usage.d.ts.map +1 -0
- package/dist/agent-runtime/realtime/harness-realtime.d.ts +53 -0
- package/dist/agent-runtime/realtime/harness-realtime.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-binding.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-broker.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-args.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap-storage.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-bubblewrap.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-coding-adapter.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-contract.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process-linux.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process-macos.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process-owner.d.ts +19 -0
- package/dist/agent-runtime/sandbox/sandbox-process-owner.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process-spec.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process-wrapper.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-process.d.ts +8 -0
- package/dist/agent-runtime/sandbox/sandbox-process.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox-session.d.ts.map +1 -0
- package/dist/agent-runtime/sandbox/sandbox.d.ts +125 -0
- package/dist/agent-runtime/sandbox/sandbox.d.ts.map +1 -0
- package/dist/agent-runtime/stores/archive-projection.d.ts.map +1 -0
- package/dist/agent-runtime/stores/archive-spill.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-contract.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-events.d.ts +25 -0
- package/dist/agent-runtime/stores/branch-events.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-identities.d.ts +75 -0
- package/dist/agent-runtime/stores/branch-identities.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-messages.d.ts +21 -0
- package/dist/agent-runtime/stores/branch-messages.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-observations.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-provider.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-refusal.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-replay.d.ts +456 -0
- package/dist/agent-runtime/stores/branch-replay.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-runtime-tools.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-source.d.ts +33 -0
- package/dist/agent-runtime/stores/branch-source.d.ts.map +1 -0
- package/dist/agent-runtime/stores/branch-transitions.d.ts.map +1 -0
- package/dist/agent-runtime/stores/child-blocking.d.ts.map +1 -0
- package/dist/agent-runtime/stores/child-budget-policy.d.ts +17 -0
- package/dist/agent-runtime/stores/child-budget-policy.d.ts.map +1 -0
- package/dist/agent-runtime/stores/child-tools.d.ts +144 -0
- package/dist/agent-runtime/stores/child-tools.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children-contract.d.ts +236 -0
- package/dist/agent-runtime/stores/children-contract.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children-control.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children-spawn.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children-state.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children-usage.d.ts.map +1 -0
- package/dist/agent-runtime/stores/children.d.ts.map +1 -0
- package/dist/agent-runtime/stores/companion-host.d.ts +38 -0
- package/dist/agent-runtime/stores/companion-host.d.ts.map +1 -0
- package/dist/agent-runtime/stores/conversations.d.ts.map +1 -0
- package/dist/agent-runtime/stores/event-search-postgres.d.ts.map +1 -0
- package/dist/agent-runtime/stores/event-search-terms.d.ts.map +1 -0
- package/dist/agent-runtime/stores/event-search-tools.d.ts +190 -0
- package/dist/agent-runtime/stores/event-search-tools.d.ts.map +1 -0
- package/dist/agent-runtime/stores/event-search.d.ts.map +1 -0
- package/dist/agent-runtime/stores/postgres-schema.d.ts.map +1 -0
- package/dist/agent-runtime/stores/postgres-transactions.d.ts +54 -0
- package/dist/agent-runtime/stores/postgres-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/stores/postgres.d.ts +72 -0
- package/dist/agent-runtime/stores/postgres.d.ts.map +1 -0
- package/dist/agent-runtime/stores/projections.d.ts +109 -0
- package/dist/agent-runtime/stores/projections.d.ts.map +1 -0
- package/dist/agent-runtime/stores/purge.d.ts.map +1 -0
- package/dist/agent-runtime/stores/schedule-contract.d.ts.map +1 -0
- package/dist/agent-runtime/stores/schedule-dispatch.d.ts.map +1 -0
- package/dist/agent-runtime/stores/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/stores/schedule-tools.d.ts +76 -0
- package/dist/agent-runtime/stores/schedule-tools.d.ts.map +1 -0
- package/dist/agent-runtime/stores/schedules.d.ts.map +1 -0
- package/dist/agent-runtime/stores/spill.d.ts +26 -0
- package/dist/agent-runtime/stores/spill.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-events.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-history.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-purge.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-reads.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-rows.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sql-session.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite-bun.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite-node.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite-purge.d.ts +6 -0
- package/dist/agent-runtime/stores/sqlite-purge.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite-schema.d.ts +7 -0
- package/dist/agent-runtime/stores/sqlite-schema.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite-transactions.d.ts +29 -0
- package/dist/agent-runtime/stores/sqlite-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/stores/sqlite.d.ts +33 -0
- package/dist/agent-runtime/stores/sqlite.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-archive.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-branch.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-create.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-driver-contract.d.ts +1016 -0
- package/dist/agent-runtime/stores/store-driver-contract.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-event-once.d.ts +37 -0
- package/dist/agent-runtime/stores/store-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-events.d.ts +2231 -0
- package/dist/agent-runtime/stores/store-events.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-memory-archive.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-memory-events.d.ts +7 -0
- package/dist/agent-runtime/stores/store-memory-events.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-memory.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-migrations/v1-to-v2.d.ts +6 -0
- package/dist/agent-runtime/stores/store-migrations/v1-to-v2.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-migrations/v2-to-v3.d.ts +14 -0
- package/dist/agent-runtime/stores/store-migrations/v2-to-v3.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-migrations/v3-to-v4.d.ts +4 -0
- package/dist/agent-runtime/stores/store-migrations/v3-to-v4.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-mutate.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-purge.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reads.d.ts +29 -0
- package/dist/agent-runtime/stores/store-reads.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reduce-history.d.ts +10 -0
- package/dist/agent-runtime/stores/store-reduce-history.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reduce-run.d.ts +14 -0
- package/dist/agent-runtime/stores/store-reduce-run.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reduce-shared.d.ts +78 -0
- package/dist/agent-runtime/stores/store-reduce-shared.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reduce-terminal.d.ts +6 -0
- package/dist/agent-runtime/stores/store-reduce-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-reducer.d.ts +24 -0
- package/dist/agent-runtime/stores/store-reducer.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-replay.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store-snapshot.d.ts +19 -0
- package/dist/agent-runtime/stores/store-snapshot.d.ts.map +1 -0
- package/dist/agent-runtime/stores/store.d.ts +3032 -0
- package/dist/agent-runtime/stores/store.d.ts.map +1 -0
- package/dist/agent-runtime/terminal-commit.d.ts +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/agent-runtime/testing/fault-bench.d.ts.map +1 -0
- package/dist/agent-runtime/testing/run-assertions.d.ts +63 -0
- package/dist/agent-runtime/testing/run-assertions.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-branch.d.ts +7 -0
- package/dist/agent-runtime/testing/store-conformance-branch.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-capabilities.d.ts +6 -0
- package/dist/agent-runtime/testing/store-conformance-capabilities.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-event-once.d.ts +12 -0
- package/dist/agent-runtime/testing/store-conformance-event-once.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts +454 -0
- package/dist/agent-runtime/testing/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/testing/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-seed.d.ts +8 -0
- package/dist/agent-runtime/testing/store-conformance-seed.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-support.d.ts +140 -0
- package/dist/agent-runtime/testing/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/testing/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/testing/store-conformance.d.ts +71 -0
- package/dist/agent-runtime/testing/store-conformance.d.ts.map +1 -0
- package/dist/agent-runtime/testing/testing.d.ts +46 -0
- package/dist/agent-runtime/testing/testing.d.ts.map +1 -0
- package/dist/browser/client-executors.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +6 -3
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +4 -3
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +38 -12
- package/dist/entrypoints/agent-executor/claude-sdk.js +1 -1
- package/dist/entrypoints/agent-executor/codex.js +2 -2
- package/dist/entrypoints/agent-executor/testing/claude-sdk.js +3 -3
- package/dist/entrypoints/agent-executor/testing.js +3 -3
- package/dist/entrypoints/agent-executor.js +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts +3 -3
- package/dist/entrypoints/agent-runtime/ai-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/ai-sdk.js +9 -8
- package/dist/entrypoints/agent-runtime/anthropic.d.ts +3 -3
- package/dist/entrypoints/agent-runtime/anthropic.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/anthropic.js +72 -18
- package/dist/entrypoints/agent-runtime/browser.d.ts +6 -6
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/browser.js +39 -39
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/harness.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/harness.js +27 -28
- package/dist/entrypoints/agent-runtime/openai.d.ts +3 -3
- package/dist/entrypoints/agent-runtime/openai.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openai.js +9 -9
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +17 -10
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/openrouter.js +1657 -400
- package/dist/entrypoints/agent-runtime/postgres.d.ts +2 -2
- package/dist/entrypoints/agent-runtime/postgres.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/postgres.js +8 -8
- package/dist/entrypoints/agent-runtime/react.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/react.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/react.js +1 -1
- package/dist/entrypoints/agent-runtime/realtime.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/realtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/realtime.js +5 -5
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +9 -9
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +220 -93
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +8 -8
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/sqlite/node.js +8 -8
- package/dist/entrypoints/agent-runtime/testing.d.ts +4 -4
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/testing.js +21 -21
- package/dist/entrypoints/agent-runtime.d.ts +50 -50
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +2853 -3107
- package/dist/entrypoints/cli.js +8 -9
- package/dist/entrypoints/http.js +2 -2
- package/dist/entrypoints/index.js +2 -2
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/server.js +2 -2
- package/dist/entrypoints/testing.js +7 -9
- package/dist/entrypoints/tools/agent.js +476 -13
- package/dist/entrypoints/tools/connections.js +9 -7
- package/dist/entrypoints/tools/contract.js +4 -4
- package/dist/entrypoints/tools/invoker.js +7 -8
- package/dist/entrypoints/tools/mcp.js +9 -11
- package/dist/entrypoints/tools/toolkit.d.ts +6 -4
- package/dist/entrypoints/tools/toolkit.d.ts.map +1 -1
- package/dist/entrypoints/tools/toolkit.js +11 -18
- package/dist/entrypoints/tools.js +12 -13
- package/dist/index-125ks2ec.js +17 -0
- package/dist/index-1w69rj9f.js +224 -0
- package/dist/index-1zy31r3b.js +26 -0
- package/dist/index-3czc3ykr.js +53 -0
- package/dist/index-3d2c45jn.js +77 -0
- package/dist/index-57sbckhv.js +271 -0
- package/dist/index-64t6pheq.js +2872 -0
- package/dist/index-73wq9abg.js +367 -0
- package/dist/index-84tp547a.js +981 -0
- package/dist/index-9be3tf6r.js +196 -0
- package/dist/index-asnd4h2k.js +969 -0
- package/dist/index-b4c9dpzm.js +1210 -0
- package/dist/index-baba8ehy.js +53 -0
- package/dist/index-c24bj2r1.js +510 -0
- package/dist/index-cgjtj8zh.js +707 -0
- package/dist/index-d4at0q09.js +601 -0
- package/dist/index-de7b0kvz.js +215 -0
- package/dist/index-dm84tsd5.js +164 -0
- package/dist/index-fsw9wxk9.js +349 -0
- package/dist/index-gk6dq9ay.js +124 -0
- package/dist/index-gs0jw0hy.js +174 -0
- package/dist/index-hce3hbdg.js +121 -0
- package/dist/index-ht71v1ag.js +730 -0
- package/dist/index-mcv7b2n0.js +3545 -0
- package/dist/index-n9358ydy.js +63 -0
- package/dist/index-npfdymav.js +409 -0
- package/dist/index-p9cab61p.js +305 -0
- package/dist/index-q86qnzzf.js +231 -0
- package/dist/index-qcy8et93.js +698 -0
- package/dist/index-refgnzy0.js +158 -0
- package/dist/index-rkphknhx.js +40 -0
- package/dist/index-v0j22shs.js +3781 -0
- package/dist/index-vse7x1qt.js +460 -0
- package/dist/index-wdb5jhas.js +51 -0
- package/dist/index-ws0awmzq.js +47 -0
- package/dist/index-wsv11dhg.js +725 -0
- package/dist/index-xbb8ysmq.js +40 -0
- package/dist/index-y0mwkgkf.js +7812 -0
- package/dist/index-yhwx4fwk.js +295 -0
- package/dist/index-z72vazf5.js +502 -0
- package/dist/json-schema/dialect.d.ts.map +1 -1
- package/dist/json-schema/string-format.d.ts.map +1 -1
- package/dist/tools/agent-call-context.d.ts +23 -0
- package/dist/tools/agent-call-context.d.ts.map +1 -0
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/schema/flatten.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +8 -6
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/llms/agent-runtime-ai-sdk.txt +2 -2
- package/llms/agent-runtime-anthropic.txt +8 -4
- package/llms/agent-runtime-openrouter.txt +14 -6
- package/llms/agent-runtime-sandbox.txt +20 -7
- package/llms/agent-runtime.2.txt +333 -224
- package/llms/agent-runtime.3.txt +225 -364
- package/llms/agent-runtime.4.txt +381 -158
- package/llms/agent-runtime.5.txt +157 -152
- package/llms/agent-runtime.6.txt +164 -0
- package/llms/agent-runtime.txt +50 -339
- package/llms/cli.2.txt +8 -5
- package/llms/contract.txt +1 -1
- package/llms/server.txt +10 -6
- package/llms/spend.txt +17 -1
- package/llms/stitchkit.2.txt +18 -11
- package/llms/stitchkit.txt +85 -85
- package/llms/tools-toolkit.txt +3 -6
- package/llms/tools.4.txt +3 -3
- package/llms/upgrading-0.128.0-0.135.0.txt +700 -0
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +317 -149
- package/llms.txt +13 -13
- package/package.json +1 -1
- package/dist/agent-runtime/admission-lanes.d.ts +0 -35
- package/dist/agent-runtime/admission-lanes.d.ts.map +0 -1
- package/dist/agent-runtime/ai-sdk-convert.d.ts +0 -15
- package/dist/agent-runtime/ai-sdk-convert.d.ts.map +0 -1
- package/dist/agent-runtime/ai-sdk.d.ts +0 -31
- package/dist/agent-runtime/ai-sdk.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic-media.d.ts +0 -11
- package/dist/agent-runtime/anthropic-media.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic-messages.d.ts +0 -24
- package/dist/agent-runtime/anthropic-messages.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic-options.d.ts +0 -79
- package/dist/agent-runtime/anthropic-options.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic-response.d.ts +0 -19
- package/dist/agent-runtime/anthropic-response.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic-sse.d.ts.map +0 -1
- package/dist/agent-runtime/anthropic.d.ts.map +0 -1
- package/dist/agent-runtime/archive-projection.d.ts.map +0 -1
- package/dist/agent-runtime/archive-spill.d.ts.map +0 -1
- package/dist/agent-runtime/branch-contract.d.ts.map +0 -1
- package/dist/agent-runtime/branch-events.d.ts +0 -25
- package/dist/agent-runtime/branch-events.d.ts.map +0 -1
- package/dist/agent-runtime/branch-identities.d.ts +0 -75
- package/dist/agent-runtime/branch-identities.d.ts.map +0 -1
- package/dist/agent-runtime/branch-messages.d.ts +0 -21
- package/dist/agent-runtime/branch-messages.d.ts.map +0 -1
- package/dist/agent-runtime/branch-observations.d.ts.map +0 -1
- package/dist/agent-runtime/branch-provider.d.ts.map +0 -1
- package/dist/agent-runtime/branch-refusal.d.ts.map +0 -1
- package/dist/agent-runtime/branch-replay.d.ts +0 -456
- package/dist/agent-runtime/branch-replay.d.ts.map +0 -1
- package/dist/agent-runtime/branch-runtime-tools.d.ts.map +0 -1
- package/dist/agent-runtime/branch-source.d.ts +0 -33
- package/dist/agent-runtime/branch-source.d.ts.map +0 -1
- package/dist/agent-runtime/branch-transitions.d.ts.map +0 -1
- package/dist/agent-runtime/browser-control-contract.d.ts +0 -1364
- package/dist/agent-runtime/browser-control-contract.d.ts.map +0 -1
- package/dist/agent-runtime/browser-controller-view.d.ts +0 -44
- package/dist/agent-runtime/browser-controller-view.d.ts.map +0 -1
- package/dist/agent-runtime/browser-controller.d.ts +0 -53
- package/dist/agent-runtime/browser-controller.d.ts.map +0 -1
- package/dist/agent-runtime/child-blocking.d.ts.map +0 -1
- package/dist/agent-runtime/child-budget-policy.d.ts +0 -17
- package/dist/agent-runtime/child-budget-policy.d.ts.map +0 -1
- package/dist/agent-runtime/child-tools.d.ts +0 -144
- package/dist/agent-runtime/child-tools.d.ts.map +0 -1
- package/dist/agent-runtime/children-contract.d.ts +0 -236
- package/dist/agent-runtime/children-contract.d.ts.map +0 -1
- package/dist/agent-runtime/children-control.d.ts.map +0 -1
- package/dist/agent-runtime/children-spawn.d.ts.map +0 -1
- package/dist/agent-runtime/children-state.d.ts.map +0 -1
- package/dist/agent-runtime/children-usage.d.ts.map +0 -1
- package/dist/agent-runtime/children.d.ts.map +0 -1
- package/dist/agent-runtime/coding-discovery.d.ts +0 -25
- package/dist/agent-runtime/coding-discovery.d.ts.map +0 -1
- package/dist/agent-runtime/coding-sandbox.d.ts +0 -8
- package/dist/agent-runtime/coding-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-automaton.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-case-fold.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-class-ranges.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-contract.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-limits.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-matcher.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-output.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-regex-syntax.d.ts.map +0 -1
- package/dist/agent-runtime/coding-search-unit-classes.d.ts.map +0 -1
- package/dist/agent-runtime/coding-shell-process.d.ts +0 -36
- package/dist/agent-runtime/coding-shell-process.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +0 -261
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-paths.d.ts +0 -53
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-refusals.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-search.d.ts +0 -113
- package/dist/agent-runtime/coding-tool-search.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-shell.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tool-utf8.d.ts.map +0 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime/compaction.d.ts +0 -103
- package/dist/agent-runtime/compaction.d.ts.map +0 -1
- package/dist/agent-runtime/companion-host.d.ts +0 -38
- package/dist/agent-runtime/companion-host.d.ts.map +0 -1
- package/dist/agent-runtime/contained-scan-budget.d.ts.map +0 -1
- package/dist/agent-runtime/contained-scan-contract.d.ts.map +0 -1
- package/dist/agent-runtime/contained-scan.d.ts +0 -56
- package/dist/agent-runtime/contained-scan.d.ts.map +0 -1
- package/dist/agent-runtime/control-interaction-schema.d.ts.map +0 -1
- package/dist/agent-runtime/control-schema.d.ts +0 -1378
- package/dist/agent-runtime/control-schema.d.ts.map +0 -1
- package/dist/agent-runtime/control-view.d.ts +0 -64
- package/dist/agent-runtime/control-view.d.ts.map +0 -1
- package/dist/agent-runtime/conversations.d.ts.map +0 -1
- package/dist/agent-runtime/coordinator.d.ts.map +0 -1
- package/dist/agent-runtime/deferred-tool-search.d.ts +0 -9
- package/dist/agent-runtime/deferred-tool-search.d.ts.map +0 -1
- package/dist/agent-runtime/deferred-tool-selection.d.ts +0 -32
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +0 -1
- package/dist/agent-runtime/deferred-tools-internal.d.ts +0 -9
- package/dist/agent-runtime/deferred-tools-internal.d.ts.map +0 -1
- package/dist/agent-runtime/deferred-tools.d.ts +0 -4
- package/dist/agent-runtime/deferred-tools.d.ts.map +0 -1
- package/dist/agent-runtime/event-search-postgres.d.ts.map +0 -1
- package/dist/agent-runtime/event-search-terms.d.ts.map +0 -1
- package/dist/agent-runtime/event-search-tools.d.ts +0 -190
- package/dist/agent-runtime/event-search-tools.d.ts.map +0 -1
- package/dist/agent-runtime/event-search.d.ts.map +0 -1
- package/dist/agent-runtime/fault-bench.d.ts.map +0 -1
- package/dist/agent-runtime/harness-contract.d.ts +0 -206
- package/dist/agent-runtime/harness-contract.d.ts.map +0 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -34
- package/dist/agent-runtime/harness-control.d.ts.map +0 -1
- package/dist/agent-runtime/harness-file-resources.d.ts +0 -33
- package/dist/agent-runtime/harness-file-resources.d.ts.map +0 -1
- package/dist/agent-runtime/harness-realtime.d.ts +0 -53
- package/dist/agent-runtime/harness-realtime.d.ts.map +0 -1
- package/dist/agent-runtime/harness-resources.d.ts.map +0 -1
- package/dist/agent-runtime/harness.d.ts +0 -15
- package/dist/agent-runtime/harness.d.ts.map +0 -1
- package/dist/agent-runtime/history.d.ts +0 -93
- package/dist/agent-runtime/history.d.ts.map +0 -1
- package/dist/agent-runtime/injection.d.ts +0 -28
- package/dist/agent-runtime/injection.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-attempt.d.ts +0 -32
- package/dist/agent-runtime/invocation-attempt.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-failure.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-payload.d.ts +0 -38
- package/dist/agent-runtime/invocation-payload.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-read.d.ts +0 -134
- package/dist/agent-runtime/invocation-read.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-spend.d.ts +0 -9
- package/dist/agent-runtime/invocation-spend.d.ts.map +0 -1
- package/dist/agent-runtime/invocation-stream.d.ts +0 -20
- package/dist/agent-runtime/invocation-stream.d.ts.map +0 -1
- package/dist/agent-runtime/invocations.d.ts +0 -63
- package/dist/agent-runtime/invocations.d.ts.map +0 -1
- package/dist/agent-runtime/managed-tools.d.ts +0 -20
- package/dist/agent-runtime/managed-tools.d.ts.map +0 -1
- package/dist/agent-runtime/models-driver-step.d.ts +0 -212
- package/dist/agent-runtime/models-driver-step.d.ts.map +0 -1
- package/dist/agent-runtime/models-driver-telemetry.d.ts.map +0 -1
- package/dist/agent-runtime/models-driver.d.ts +0 -235
- package/dist/agent-runtime/models-driver.d.ts.map +0 -1
- package/dist/agent-runtime/models.d.ts.map +0 -1
- package/dist/agent-runtime/observability.d.ts +0 -579
- package/dist/agent-runtime/observability.d.ts.map +0 -1
- package/dist/agent-runtime/openai-messages.d.ts.map +0 -1
- package/dist/agent-runtime/openai-options.d.ts +0 -91
- package/dist/agent-runtime/openai-options.d.ts.map +0 -1
- package/dist/agent-runtime/openai-response.d.ts +0 -77
- package/dist/agent-runtime/openai-response.d.ts.map +0 -1
- package/dist/agent-runtime/openai-sse-state.d.ts.map +0 -1
- package/dist/agent-runtime/openai-sse.d.ts.map +0 -1
- package/dist/agent-runtime/openai.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-admission.d.ts +0 -84
- package/dist/agent-runtime/openrouter-admission.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-benchmarks.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-catalog-cache.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-catalog-query.d.ts +0 -57
- package/dist/agent-runtime/openrouter-catalog-query.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-catalog.d.ts +0 -258
- package/dist/agent-runtime/openrouter-catalog.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-models.d.ts +0 -203
- package/dist/agent-runtime/openrouter-models.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-options.d.ts +0 -136
- package/dist/agent-runtime/openrouter-options.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-response.d.ts +0 -22
- package/dist/agent-runtime/openrouter-response.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-route.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter-spend.d.ts +0 -24
- package/dist/agent-runtime/openrouter-spend.d.ts.map +0 -1
- package/dist/agent-runtime/openrouter.d.ts +0 -47
- package/dist/agent-runtime/openrouter.d.ts.map +0 -1
- package/dist/agent-runtime/owned-provider-stream.d.ts.map +0 -1
- package/dist/agent-runtime/postgres-schema.d.ts.map +0 -1
- package/dist/agent-runtime/postgres-transactions.d.ts +0 -54
- package/dist/agent-runtime/postgres-transactions.d.ts.map +0 -1
- package/dist/agent-runtime/postgres.d.ts +0 -72
- package/dist/agent-runtime/postgres.d.ts.map +0 -1
- package/dist/agent-runtime/projections.d.ts +0 -109
- package/dist/agent-runtime/projections.d.ts.map +0 -1
- package/dist/agent-runtime/provider-cache.d.ts +0 -30
- package/dist/agent-runtime/provider-cache.d.ts.map +0 -1
- package/dist/agent-runtime/provider-content.d.ts.map +0 -1
- package/dist/agent-runtime/provider-failure.d.ts +0 -95
- package/dist/agent-runtime/provider-failure.d.ts.map +0 -1
- package/dist/agent-runtime/provider-history.d.ts +0 -13
- package/dist/agent-runtime/provider-history.d.ts.map +0 -1
- package/dist/agent-runtime/provider-http.d.ts +0 -68
- package/dist/agent-runtime/provider-http.d.ts.map +0 -1
- package/dist/agent-runtime/provider-journal.d.ts.map +0 -1
- package/dist/agent-runtime/provider-json-schema-strip.d.ts.map +0 -1
- package/dist/agent-runtime/provider-json-schema.d.ts +0 -28
- package/dist/agent-runtime/provider-json-schema.d.ts.map +0 -1
- package/dist/agent-runtime/provider-media.d.ts +0 -49
- package/dist/agent-runtime/provider-media.d.ts.map +0 -1
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts +0 -27
- package/dist/agent-runtime/provider-openai-chat-helpers.d.ts.map +0 -1
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts +0 -25
- package/dist/agent-runtime/provider-openai-chat-sse.d.ts.map +0 -1
- package/dist/agent-runtime/provider-openai-chat.d.ts +0 -27
- package/dist/agent-runtime/provider-openai-chat.d.ts.map +0 -1
- package/dist/agent-runtime/provider-origin.d.ts +0 -10
- package/dist/agent-runtime/provider-origin.d.ts.map +0 -1
- package/dist/agent-runtime/provider-sse.d.ts.map +0 -1
- package/dist/agent-runtime/provider-stream-parts.d.ts +0 -5
- package/dist/agent-runtime/provider-stream-parts.d.ts.map +0 -1
- package/dist/agent-runtime/provider-stream-segments.d.ts +0 -63
- package/dist/agent-runtime/provider-stream-segments.d.ts.map +0 -1
- package/dist/agent-runtime/provider-usage.d.ts +0 -24
- package/dist/agent-runtime/provider-usage.d.ts.map +0 -1
- package/dist/agent-runtime/purge.d.ts.map +0 -1
- package/dist/agent-runtime/react.d.ts.map +0 -1
- package/dist/agent-runtime/retry-policy.d.ts +0 -49
- package/dist/agent-runtime/retry-policy.d.ts.map +0 -1
- package/dist/agent-runtime/run-acquisition.d.ts +0 -24
- package/dist/agent-runtime/run-acquisition.d.ts.map +0 -1
- package/dist/agent-runtime/run-approval.d.ts +0 -82
- package/dist/agent-runtime/run-approval.d.ts.map +0 -1
- package/dist/agent-runtime/run-assertions.d.ts +0 -63
- package/dist/agent-runtime/run-assertions.d.ts.map +0 -1
- package/dist/agent-runtime/run-complete-retry.d.ts +0 -24
- package/dist/agent-runtime/run-complete-retry.d.ts.map +0 -1
- package/dist/agent-runtime/run-complete-stream.d.ts +0 -9
- package/dist/agent-runtime/run-complete-stream.d.ts.map +0 -1
- package/dist/agent-runtime/run-complete-tools.d.ts +0 -21
- package/dist/agent-runtime/run-complete-tools.d.ts.map +0 -1
- package/dist/agent-runtime/run-complete-types.d.ts +0 -168
- package/dist/agent-runtime/run-complete-types.d.ts.map +0 -1
- package/dist/agent-runtime/run-complete.d.ts +0 -25
- package/dist/agent-runtime/run-complete.d.ts.map +0 -1
- package/dist/agent-runtime/run-driver-compose.d.ts +0 -21
- package/dist/agent-runtime/run-driver-compose.d.ts.map +0 -1
- package/dist/agent-runtime/run-execution-state.d.ts +0 -178
- package/dist/agent-runtime/run-execution-state.d.ts.map +0 -1
- package/dist/agent-runtime/run-execution.d.ts +0 -22
- package/dist/agent-runtime/run-execution.d.ts.map +0 -1
- package/dist/agent-runtime/run-failure.d.ts +0 -21
- package/dist/agent-runtime/run-failure.d.ts.map +0 -1
- package/dist/agent-runtime/run-history-parts.d.ts +0 -14
- package/dist/agent-runtime/run-history-parts.d.ts.map +0 -1
- package/dist/agent-runtime/run-loop-events.d.ts +0 -126
- package/dist/agent-runtime/run-loop-events.d.ts.map +0 -1
- package/dist/agent-runtime/run-model-attempts.d.ts +0 -6
- package/dist/agent-runtime/run-model-attempts.d.ts.map +0 -1
- package/dist/agent-runtime/run-model-messages.d.ts +0 -9
- package/dist/agent-runtime/run-model-messages.d.ts.map +0 -1
- package/dist/agent-runtime/run-model-step.d.ts +0 -43
- package/dist/agent-runtime/run-model-step.d.ts.map +0 -1
- package/dist/agent-runtime/run-model-stream.d.ts +0 -27
- package/dist/agent-runtime/run-model-stream.d.ts.map +0 -1
- package/dist/agent-runtime/run-operation-lifecycle.d.ts +0 -32
- package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +0 -1
- package/dist/agent-runtime/run-prompt-history.d.ts +0 -53
- package/dist/agent-runtime/run-prompt-history.d.ts.map +0 -1
- package/dist/agent-runtime/run-provider-ledger.d.ts +0 -32
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/run-step-barriers.d.ts +0 -114
- package/dist/agent-runtime/run-step-barriers.d.ts.map +0 -1
- package/dist/agent-runtime/run-step-helpers.d.ts +0 -49
- package/dist/agent-runtime/run-step-helpers.d.ts.map +0 -1
- package/dist/agent-runtime/run-step-prepare.d.ts +0 -34
- package/dist/agent-runtime/run-step-prepare.d.ts.map +0 -1
- package/dist/agent-runtime/run-step-spend.d.ts +0 -394
- package/dist/agent-runtime/run-step-spend.d.ts.map +0 -1
- package/dist/agent-runtime/run-stream-parts.d.ts +0 -34
- package/dist/agent-runtime/run-stream-parts.d.ts.map +0 -1
- package/dist/agent-runtime/run-stream-recorded.d.ts +0 -8
- package/dist/agent-runtime/run-stream-recorded.d.ts.map +0 -1
- package/dist/agent-runtime/run-stream-step-text.d.ts +0 -29
- package/dist/agent-runtime/run-stream-step-text.d.ts.map +0 -1
- package/dist/agent-runtime/run-terminal.d.ts +0 -11
- package/dist/agent-runtime/run-terminal.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-approval-flow.d.ts +0 -36
- package/dist/agent-runtime/run-tool-approval-flow.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-approval-records.d.ts +0 -24
- package/dist/agent-runtime/run-tool-approval-records.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-call.d.ts +0 -73
- package/dist/agent-runtime/run-tool-call.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-errors.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-executor.d.ts +0 -34
- package/dist/agent-runtime/run-tool-executor.d.ts.map +0 -1
- package/dist/agent-runtime/run-tool-progress.d.ts +0 -21
- package/dist/agent-runtime/run-tool-progress.d.ts.map +0 -1
- package/dist/agent-runtime/run-turn-preparation.d.ts +0 -25
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +0 -1
- package/dist/agent-runtime/run-unacquired.d.ts +0 -19
- package/dist/agent-runtime/run-unacquired.d.ts.map +0 -1
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +0 -1
- package/dist/agent-runtime/runtime-control.d.ts +0 -9
- package/dist/agent-runtime/runtime-control.d.ts.map +0 -1
- package/dist/agent-runtime/runtime-recovery.d.ts +0 -10
- package/dist/agent-runtime/runtime-recovery.d.ts.map +0 -1
- package/dist/agent-runtime/runtime-state.d.ts +0 -36
- package/dist/agent-runtime/runtime-state.d.ts.map +0 -1
- package/dist/agent-runtime/runtime-submit.d.ts +0 -5
- package/dist/agent-runtime/runtime-submit.d.ts.map +0 -1
- package/dist/agent-runtime/runtime.d.ts +0 -352
- package/dist/agent-runtime/runtime.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-binding.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-broker.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-bubblewrap-args.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-bubblewrap-storage.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-bubblewrap.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-coding-adapter.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-contract.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process-linux.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process-macos.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts +0 -19
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process-spec.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process-wrapper.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-process.d.ts +0 -8
- package/dist/agent-runtime/sandbox-process.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox-session.d.ts.map +0 -1
- package/dist/agent-runtime/sandbox.d.ts +0 -125
- package/dist/agent-runtime/sandbox.d.ts.map +0 -1
- package/dist/agent-runtime/schedule-contract.d.ts.map +0 -1
- package/dist/agent-runtime/schedule-dispatch.d.ts.map +0 -1
- package/dist/agent-runtime/schedule-records.d.ts.map +0 -1
- package/dist/agent-runtime/schedule-tools.d.ts +0 -76
- package/dist/agent-runtime/schedule-tools.d.ts.map +0 -1
- package/dist/agent-runtime/schedules.d.ts.map +0 -1
- package/dist/agent-runtime/spill.d.ts +0 -26
- package/dist/agent-runtime/spill.d.ts.map +0 -1
- package/dist/agent-runtime/sql-events.d.ts.map +0 -1
- package/dist/agent-runtime/sql-history.d.ts.map +0 -1
- package/dist/agent-runtime/sql-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/sql-purge.d.ts.map +0 -1
- package/dist/agent-runtime/sql-reads.d.ts.map +0 -1
- package/dist/agent-runtime/sql-rows.d.ts.map +0 -1
- package/dist/agent-runtime/sql-session.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-node.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-purge.d.ts +0 -6
- package/dist/agent-runtime/sqlite-purge.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-schema.d.ts +0 -7
- package/dist/agent-runtime/sqlite-schema.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite-transactions.d.ts +0 -29
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +0 -1
- package/dist/agent-runtime/sqlite.d.ts +0 -33
- package/dist/agent-runtime/sqlite.d.ts.map +0 -1
- package/dist/agent-runtime/state-slots.d.ts +0 -48
- package/dist/agent-runtime/state-slots.d.ts.map +0 -1
- package/dist/agent-runtime/state-tools.d.ts +0 -117
- package/dist/agent-runtime/state-tools.d.ts.map +0 -1
- package/dist/agent-runtime/store-archive.d.ts.map +0 -1
- package/dist/agent-runtime/store-branch.d.ts.map +0 -1
- package/dist/agent-runtime/store-capabilities.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-branch.d.ts +0 -7
- package/dist/agent-runtime/store-conformance-branch.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-capabilities.d.ts +0 -6
- package/dist/agent-runtime/store-conformance-capabilities.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-event-once.d.ts +0 -12
- package/dist/agent-runtime/store-conformance-event-once.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +0 -454
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-ordering.d.ts +0 -18
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-seed.d.ts +0 -8
- package/dist/agent-runtime/store-conformance-seed.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-support.d.ts +0 -140
- package/dist/agent-runtime/store-conformance-support.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance-terminal.d.ts +0 -12
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +0 -1
- package/dist/agent-runtime/store-conformance.d.ts +0 -71
- package/dist/agent-runtime/store-conformance.d.ts.map +0 -1
- package/dist/agent-runtime/store-create.d.ts.map +0 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +0 -1016
- package/dist/agent-runtime/store-driver-contract.d.ts.map +0 -1
- package/dist/agent-runtime/store-event-once.d.ts +0 -37
- package/dist/agent-runtime/store-event-once.d.ts.map +0 -1
- package/dist/agent-runtime/store-events.d.ts +0 -2231
- package/dist/agent-runtime/store-events.d.ts.map +0 -1
- package/dist/agent-runtime/store-memory-archive.d.ts.map +0 -1
- package/dist/agent-runtime/store-memory-events.d.ts +0 -7
- package/dist/agent-runtime/store-memory-events.d.ts.map +0 -1
- package/dist/agent-runtime/store-memory.d.ts.map +0 -1
- package/dist/agent-runtime/store-migrations/v1-to-v2.d.ts +0 -6
- package/dist/agent-runtime/store-migrations/v1-to-v2.d.ts.map +0 -1
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts +0 -14
- package/dist/agent-runtime/store-migrations/v2-to-v3.d.ts.map +0 -1
- package/dist/agent-runtime/store-migrations/v3-to-v4.d.ts +0 -4
- package/dist/agent-runtime/store-migrations/v3-to-v4.d.ts.map +0 -1
- package/dist/agent-runtime/store-mutate.d.ts.map +0 -1
- package/dist/agent-runtime/store-purge.d.ts.map +0 -1
- package/dist/agent-runtime/store-reads.d.ts +0 -29
- package/dist/agent-runtime/store-reads.d.ts.map +0 -1
- package/dist/agent-runtime/store-reduce-history.d.ts +0 -10
- package/dist/agent-runtime/store-reduce-history.d.ts.map +0 -1
- package/dist/agent-runtime/store-reduce-run.d.ts +0 -14
- package/dist/agent-runtime/store-reduce-run.d.ts.map +0 -1
- package/dist/agent-runtime/store-reduce-shared.d.ts +0 -78
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +0 -1
- package/dist/agent-runtime/store-reduce-terminal.d.ts +0 -6
- package/dist/agent-runtime/store-reduce-terminal.d.ts.map +0 -1
- package/dist/agent-runtime/store-reducer.d.ts +0 -24
- package/dist/agent-runtime/store-reducer.d.ts.map +0 -1
- package/dist/agent-runtime/store-replay.d.ts.map +0 -1
- package/dist/agent-runtime/store-snapshot.d.ts +0 -19
- package/dist/agent-runtime/store-snapshot.d.ts.map +0 -1
- package/dist/agent-runtime/store.d.ts +0 -3032
- package/dist/agent-runtime/store.d.ts.map +0 -1
- package/dist/agent-runtime/testing.d.ts +0 -46
- package/dist/agent-runtime/testing.d.ts.map +0 -1
- package/dist/agent-runtime/workspace-glob.d.ts.map +0 -1
- package/dist/index-18pf56dq.js +0 -409
- package/dist/index-1gmgwfn3.js +0 -439
- package/dist/index-23wn8sgf.js +0 -47
- package/dist/index-27hck3z2.js +0 -307
- package/dist/index-27srek2g.js +0 -3781
- package/dist/index-360j58vb.js +0 -63
- package/dist/index-67pnt4bh.js +0 -174
- package/dist/index-6kpwkpgx.js +0 -415
- package/dist/index-6xw1wf4m.js +0 -969
- package/dist/index-6yb4stq3.js +0 -224
- package/dist/index-76yhxa41.js +0 -725
- package/dist/index-79vqbjcz.js +0 -26
- package/dist/index-a84wj6y8.js +0 -510
- package/dist/index-b23s6e2c.js +0 -158
- package/dist/index-cb4nnvfr.js +0 -40
- package/dist/index-ek9w11r0.js +0 -40
- package/dist/index-er483f3w.js +0 -601
- package/dist/index-fjac2w5e.js +0 -3543
- package/dist/index-ga6avd48.js +0 -53
- package/dist/index-hy4653g4.js +0 -345
- package/dist/index-j903yhp4.js +0 -121
- package/dist/index-jzdbkanz.js +0 -215
- package/dist/index-k9g061ma.js +0 -164
- package/dist/index-krekhmp7.js +0 -707
- package/dist/index-ky79wwgs.js +0 -2872
- package/dist/index-mgr0mdqp.js +0 -271
- package/dist/index-mx2gya05.js +0 -465
- package/dist/index-nfeafbzh.js +0 -7379
- package/dist/index-ngwf1s3c.js +0 -51
- package/dist/index-pjjh91vw.js +0 -53
- package/dist/index-qv5v6w9c.js +0 -696
- package/dist/index-rj32hkkp.js +0 -305
- package/dist/index-t5zp1jjj.js +0 -77
- package/dist/index-v5hmyef8.js +0 -951
- package/dist/index-vv0hxrmy.js +0 -295
- package/dist/index-vxm0ya3f.js +0 -707
- package/dist/index-xtxxt87z.js +0 -349
- package/dist/index-zag9sjpd.js +0 -1210
- package/dist/index-zk839vzf.js +0 -231
- package/llms/upgrading-0.128.0-0.134.0.txt +0 -639
- /package/dist/agent-runtime/{control-interaction-schema.d.ts → browser/control-interaction-schema.d.ts} +0 -0
- /package/dist/agent-runtime/{react.d.ts → browser/react.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-automaton.d.ts → coding/coding-search-automaton.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-case-fold.d.ts → coding/coding-search-case-fold.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-class-ranges.d.ts → coding/coding-search-class-ranges.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-contract.d.ts → coding/coding-search-contract.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-limits.d.ts → coding/coding-search-limits.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-matcher.d.ts → coding/coding-search-matcher.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-output.d.ts → coding/coding-search-output.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-regex-syntax.d.ts → coding/coding-search-regex-syntax.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-search-unit-classes.d.ts → coding/coding-search-unit-classes.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-files.d.ts → coding/coding-tool-files.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-listing.d.ts → coding/coding-tool-listing.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-refusals.d.ts → coding/coding-tool-refusals.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-search-patch.d.ts → coding/coding-tool-search-patch.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-shell.d.ts → coding/coding-tool-shell.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tool-utf8.d.ts → coding/coding-tool-utf8.d.ts} +0 -0
- /package/dist/agent-runtime/{coding-tools.d.ts → coding/coding-tools.d.ts} +0 -0
- /package/dist/agent-runtime/{contained-scan-budget.d.ts → coding/contained-scan-budget.d.ts} +0 -0
- /package/dist/agent-runtime/{contained-scan-contract.d.ts → coding/contained-scan-contract.d.ts} +0 -0
- /package/dist/agent-runtime/{workspace-glob.d.ts → coding/workspace-glob.d.ts} +0 -0
- /package/dist/agent-runtime/{harness-resources.d.ts → harness/harness-resources.d.ts} +0 -0
- /package/dist/agent-runtime/{coordinator.d.ts → loop/coordinator.d.ts} +0 -0
- /package/dist/agent-runtime/{invocation-failure.d.ts → loop/invocation-failure.d.ts} +0 -0
- /package/dist/agent-runtime/{owned-provider-stream.d.ts → loop/owned-provider-stream.d.ts} +0 -0
- /package/dist/agent-runtime/{run-tool-errors.d.ts → loop/run-tool-errors.d.ts} +0 -0
- /package/dist/agent-runtime/{runtime-admission-gate.d.ts → loop/runtime-admission-gate.d.ts} +0 -0
- /package/dist/agent-runtime/{anthropic-sse.d.ts → providers/anthropic-sse.d.ts} +0 -0
- /package/dist/agent-runtime/{anthropic.d.ts → providers/anthropic.d.ts} +0 -0
- /package/dist/agent-runtime/{models-driver-telemetry.d.ts → providers/models-driver-telemetry.d.ts} +0 -0
- /package/dist/agent-runtime/{models.d.ts → providers/models.d.ts} +0 -0
- /package/dist/agent-runtime/{openai-messages.d.ts → providers/openai-messages.d.ts} +0 -0
- /package/dist/agent-runtime/{openai-sse-state.d.ts → providers/openai-sse-state.d.ts} +0 -0
- /package/dist/agent-runtime/{openai-sse.d.ts → providers/openai-sse.d.ts} +0 -0
- /package/dist/agent-runtime/{openai.d.ts → providers/openai.d.ts} +0 -0
- /package/dist/agent-runtime/{openrouter-benchmarks.d.ts → providers/openrouter-benchmarks.d.ts} +0 -0
- /package/dist/agent-runtime/{openrouter-catalog-cache.d.ts → providers/openrouter-catalog-cache.d.ts} +0 -0
- /package/dist/agent-runtime/{openrouter-route.d.ts → providers/openrouter-route.d.ts} +0 -0
- /package/dist/agent-runtime/{provider-content.d.ts → providers/provider-content.d.ts} +0 -0
- /package/dist/agent-runtime/{provider-journal.d.ts → providers/provider-journal.d.ts} +0 -0
- /package/dist/agent-runtime/{provider-json-schema-strip.d.ts → providers/provider-json-schema-strip.d.ts} +0 -0
- /package/dist/agent-runtime/{provider-sse.d.ts → providers/provider-sse.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-binding.d.ts → sandbox/sandbox-binding.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-broker.d.ts → sandbox/sandbox-broker.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-bubblewrap-args.d.ts → sandbox/sandbox-bubblewrap-args.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-bubblewrap-storage.d.ts → sandbox/sandbox-bubblewrap-storage.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-bubblewrap.d.ts → sandbox/sandbox-bubblewrap.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-coding-adapter.d.ts → sandbox/sandbox-coding-adapter.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-contract.d.ts → sandbox/sandbox-contract.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-process-linux.d.ts → sandbox/sandbox-process-linux.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-process-macos.d.ts → sandbox/sandbox-process-macos.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-process-spec.d.ts → sandbox/sandbox-process-spec.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-process-wrapper.d.ts → sandbox/sandbox-process-wrapper.d.ts} +0 -0
- /package/dist/agent-runtime/{sandbox-session.d.ts → sandbox/sandbox-session.d.ts} +0 -0
- /package/dist/agent-runtime/{archive-projection.d.ts → stores/archive-projection.d.ts} +0 -0
- /package/dist/agent-runtime/{archive-spill.d.ts → stores/archive-spill.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-contract.d.ts → stores/branch-contract.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-observations.d.ts → stores/branch-observations.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-provider.d.ts → stores/branch-provider.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-refusal.d.ts → stores/branch-refusal.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-runtime-tools.d.ts → stores/branch-runtime-tools.d.ts} +0 -0
- /package/dist/agent-runtime/{branch-transitions.d.ts → stores/branch-transitions.d.ts} +0 -0
- /package/dist/agent-runtime/{child-blocking.d.ts → stores/child-blocking.d.ts} +0 -0
- /package/dist/agent-runtime/{children-control.d.ts → stores/children-control.d.ts} +0 -0
- /package/dist/agent-runtime/{children-spawn.d.ts → stores/children-spawn.d.ts} +0 -0
- /package/dist/agent-runtime/{children-state.d.ts → stores/children-state.d.ts} +0 -0
- /package/dist/agent-runtime/{children-usage.d.ts → stores/children-usage.d.ts} +0 -0
- /package/dist/agent-runtime/{children.d.ts → stores/children.d.ts} +0 -0
- /package/dist/agent-runtime/{conversations.d.ts → stores/conversations.d.ts} +0 -0
- /package/dist/agent-runtime/{event-search-postgres.d.ts → stores/event-search-postgres.d.ts} +0 -0
- /package/dist/agent-runtime/{event-search-terms.d.ts → stores/event-search-terms.d.ts} +0 -0
- /package/dist/agent-runtime/{event-search.d.ts → stores/event-search.d.ts} +0 -0
- /package/dist/agent-runtime/{postgres-schema.d.ts → stores/postgres-schema.d.ts} +0 -0
- /package/dist/agent-runtime/{purge.d.ts → stores/purge.d.ts} +0 -0
- /package/dist/agent-runtime/{schedule-contract.d.ts → stores/schedule-contract.d.ts} +0 -0
- /package/dist/agent-runtime/{schedule-dispatch.d.ts → stores/schedule-dispatch.d.ts} +0 -0
- /package/dist/agent-runtime/{schedule-records.d.ts → stores/schedule-records.d.ts} +0 -0
- /package/dist/agent-runtime/{schedules.d.ts → stores/schedules.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-events.d.ts → stores/sql-events.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-history.d.ts → stores/sql-history.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-ledger.d.ts → stores/sql-ledger.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-purge.d.ts → stores/sql-purge.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-reads.d.ts → stores/sql-reads.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-rows.d.ts → stores/sql-rows.d.ts} +0 -0
- /package/dist/agent-runtime/{sql-session.d.ts → stores/sql-session.d.ts} +0 -0
- /package/dist/agent-runtime/{sqlite-bun.d.ts → stores/sqlite-bun.d.ts} +0 -0
- /package/dist/agent-runtime/{sqlite-node.d.ts → stores/sqlite-node.d.ts} +0 -0
- /package/dist/agent-runtime/{store-archive.d.ts → stores/store-archive.d.ts} +0 -0
- /package/dist/agent-runtime/{store-branch.d.ts → stores/store-branch.d.ts} +0 -0
- /package/dist/agent-runtime/{store-capabilities.d.ts → stores/store-capabilities.d.ts} +0 -0
- /package/dist/agent-runtime/{store-create.d.ts → stores/store-create.d.ts} +0 -0
- /package/dist/agent-runtime/{store-memory-archive.d.ts → stores/store-memory-archive.d.ts} +0 -0
- /package/dist/agent-runtime/{store-memory.d.ts → stores/store-memory.d.ts} +0 -0
- /package/dist/agent-runtime/{store-mutate.d.ts → stores/store-mutate.d.ts} +0 -0
- /package/dist/agent-runtime/{store-purge.d.ts → stores/store-purge.d.ts} +0 -0
- /package/dist/agent-runtime/{store-replay.d.ts → stores/store-replay.d.ts} +0 -0
- /package/dist/agent-runtime/{fault-bench.d.ts → testing/fault-bench.d.ts} +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentModelCatalogSchema2
|
|
3
|
-
} from "../../index-
|
|
4
|
-
import {
|
|
5
|
-
AgentCacheControlSchema2
|
|
6
|
-
} from "../../index-vebzvse6.js";
|
|
3
|
+
} from "../../index-refgnzy0.js";
|
|
7
4
|
import {
|
|
5
|
+
DEFAULT_MAX_ERROR_BODY_BYTES,
|
|
6
|
+
DEFAULT_MAX_JSON_BODY_BYTES,
|
|
8
7
|
redactProviderFailureText,
|
|
8
|
+
headersToRecord,
|
|
9
9
|
joinProviderUrl,
|
|
10
10
|
assertNoExtraBodyClash,
|
|
11
11
|
resolveProviderApiKey,
|
|
12
|
+
extractProviderRequestId,
|
|
13
|
+
buildProviderHttpError,
|
|
12
14
|
postProviderStream,
|
|
13
15
|
nonEmptyString2,
|
|
14
16
|
recordField,
|
|
@@ -21,7 +23,10 @@ import {
|
|
|
21
23
|
historyHasToolTraffic,
|
|
22
24
|
parseSseStream,
|
|
23
25
|
parseSseJson
|
|
24
|
-
} from "../../index-
|
|
26
|
+
} from "../../index-ht71v1ag.js";
|
|
27
|
+
import {
|
|
28
|
+
AgentCacheControlSchema2
|
|
29
|
+
} from "../../index-vebzvse6.js";
|
|
25
30
|
import {
|
|
26
31
|
openAiCompatibleUsage2
|
|
27
32
|
} from "../../index-6t4c98gr.js";
|
|
@@ -31,10 +36,10 @@ import {
|
|
|
31
36
|
toWireCacheControl,
|
|
32
37
|
assertValidCacheTtlOrder,
|
|
33
38
|
budgetCacheBreakpoints
|
|
34
|
-
} from "../../index-
|
|
39
|
+
} from "../../index-ws0awmzq.js";
|
|
35
40
|
import {
|
|
36
41
|
normalizeOpenAiJsonSchema
|
|
37
|
-
} from "../../index-
|
|
42
|
+
} from "../../index-z72vazf5.js";
|
|
38
43
|
import {
|
|
39
44
|
sanitizeSurrogates,
|
|
40
45
|
deterministicJson,
|
|
@@ -44,16 +49,18 @@ import {
|
|
|
44
49
|
readPortableCacheControl,
|
|
45
50
|
AgentProviderError2,
|
|
46
51
|
AgentProviderStreamCutError2
|
|
47
|
-
} from "../../index-
|
|
52
|
+
} from "../../index-vse7x1qt.js";
|
|
48
53
|
import {
|
|
49
|
-
readBoundedBody2
|
|
54
|
+
readBoundedBody2,
|
|
55
|
+
readBoundedText
|
|
50
56
|
} from "../../index-f16b7rze.js";
|
|
51
57
|
import {
|
|
52
58
|
isPositiveSafeInteger,
|
|
53
59
|
assertPositiveSafeInteger
|
|
54
60
|
} from "../../index-gr0kxymw.js";
|
|
55
61
|
import {
|
|
56
|
-
assertTimerMs
|
|
62
|
+
assertTimerMs,
|
|
63
|
+
withSignalDeadline
|
|
57
64
|
} from "../../index-e1y74yra.js";
|
|
58
65
|
import {
|
|
59
66
|
abortReason,
|
|
@@ -61,11 +68,14 @@ import {
|
|
|
61
68
|
linkAbortSignals,
|
|
62
69
|
withLinkedAbortSignals
|
|
63
70
|
} from "../../index-rptj3qnc.js";
|
|
71
|
+
import {
|
|
72
|
+
abortError
|
|
73
|
+
} from "../../index-wz392jyz.js";
|
|
64
74
|
import {
|
|
65
75
|
isRecord
|
|
66
76
|
} from "../../index-ps3djm8d.js";
|
|
67
77
|
|
|
68
|
-
// src/agent-runtime/openrouter-benchmarks.ts
|
|
78
|
+
// src/agent-runtime/providers/openrouter-benchmarks.ts
|
|
69
79
|
import { z } from "zod";
|
|
70
80
|
var OpenRouterBenchmarkMetaSchema = z.object({ as_of: z.iso.datetime({ offset: true }) }).loose();
|
|
71
81
|
var OpenRouterArtificialAnalysisRowSchema = z.object({
|
|
@@ -183,8 +193,92 @@ function collectOpenRouterBenchmarks(artificialResult, designResult) {
|
|
|
183
193
|
return { metrics, diagnostics };
|
|
184
194
|
}
|
|
185
195
|
|
|
186
|
-
// src/agent-runtime/openrouter-models.ts
|
|
196
|
+
// src/agent-runtime/providers/openrouter-models.ts
|
|
187
197
|
import { z as z2 } from "zod";
|
|
198
|
+
|
|
199
|
+
// src/agent-runtime/providers/openrouter-url.ts
|
|
200
|
+
var OPENROUTER_API_BASE_URL = "https://openrouter.ai/api/v1";
|
|
201
|
+
var SCHEME_PREFIX = /^[a-z][a-z0-9+.-]*:/iu;
|
|
202
|
+
var ENCODED_TRAVERSAL = /%(?:2e|2f|5c)/iu;
|
|
203
|
+
function hasControlOrWhitespace(value) {
|
|
204
|
+
for (let i = 0;i < value.length; i += 1) {
|
|
205
|
+
const code = value.charCodeAt(i);
|
|
206
|
+
if (code <= 32 || code === 127)
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
function validateOpenRouterBaseUrl(raw) {
|
|
212
|
+
const candidate = raw ?? OPENROUTER_API_BASE_URL;
|
|
213
|
+
if (typeof candidate !== "string" || candidate.trim().length === 0 || !URL.canParse(candidate)) {
|
|
214
|
+
throw new TypeError("Invalid OpenRouter baseUrl");
|
|
215
|
+
}
|
|
216
|
+
const url = new URL(candidate);
|
|
217
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
218
|
+
throw new TypeError(`OpenRouter baseUrl must use http: or https: protocol (received "${url.protocol}")`);
|
|
219
|
+
}
|
|
220
|
+
if (url.username.length > 0 || url.password.length > 0) {
|
|
221
|
+
throw new TypeError("OpenRouter baseUrl must not contain embedded credentials");
|
|
222
|
+
}
|
|
223
|
+
if (url.hash.length > 0) {
|
|
224
|
+
throw new TypeError("OpenRouter baseUrl must not contain a URL fragment");
|
|
225
|
+
}
|
|
226
|
+
return url;
|
|
227
|
+
}
|
|
228
|
+
function assertOpenRouterHttpUrl(name, value) {
|
|
229
|
+
if (typeof value !== "string" || value.trim().length === 0 || !URL.canParse(value)) {
|
|
230
|
+
throw new TypeError(`${name} must be a valid http: or https: URL`);
|
|
231
|
+
}
|
|
232
|
+
const url = new URL(value);
|
|
233
|
+
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
234
|
+
throw new TypeError(`${name} must use http: or https: protocol`);
|
|
235
|
+
}
|
|
236
|
+
if (url.username.length > 0 || url.password.length > 0) {
|
|
237
|
+
throw new TypeError(`${name} must not contain embedded credentials`);
|
|
238
|
+
}
|
|
239
|
+
return value.trim();
|
|
240
|
+
}
|
|
241
|
+
function assertOpenRouterPathSegment(name, value) {
|
|
242
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
243
|
+
if (trimmed.length === 0 || trimmed === "." || trimmed === ".." || trimmed.includes("/") || trimmed.includes("\\") || trimmed.includes("?") || trimmed.includes("#") || hasControlOrWhitespace(trimmed) || ENCODED_TRAVERSAL.test(trimmed)) {
|
|
244
|
+
throw new TypeError(`Invalid OpenRouter ${name}`);
|
|
245
|
+
}
|
|
246
|
+
return trimmed;
|
|
247
|
+
}
|
|
248
|
+
function resolveOpenRouterUrl(baseUrl, path, query) {
|
|
249
|
+
const base = validateOpenRouterBaseUrl(baseUrl);
|
|
250
|
+
if (typeof path !== "string" || path.length === 0 || SCHEME_PREFIX.test(path) || path.startsWith("//") || path.includes("\\") || path.includes("?") || path.includes("#") || hasControlOrWhitespace(path) || ENCODED_TRAVERSAL.test(path)) {
|
|
251
|
+
throw new TypeError("OpenRouter path must be a relative endpoint path without scheme or query");
|
|
252
|
+
}
|
|
253
|
+
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
254
|
+
const segments = normalized.slice(1).split("/");
|
|
255
|
+
if (segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) {
|
|
256
|
+
throw new TypeError("OpenRouter path must not contain empty or traversal segments");
|
|
257
|
+
}
|
|
258
|
+
const basePath = base.pathname.replace(/\/+$/u, "");
|
|
259
|
+
const resolved = new URL(base.toString());
|
|
260
|
+
resolved.pathname = `${basePath}${normalized}`;
|
|
261
|
+
if (resolved.origin !== base.origin || basePath.length > 0 && !resolved.pathname.startsWith(`${basePath}/`)) {
|
|
262
|
+
throw new TypeError("OpenRouter path escaped baseUrl scope");
|
|
263
|
+
}
|
|
264
|
+
if (query instanceof URLSearchParams) {
|
|
265
|
+
for (const [key, value] of query.entries()) {
|
|
266
|
+
resolved.searchParams.append(key, value);
|
|
267
|
+
}
|
|
268
|
+
} else if (query !== undefined) {
|
|
269
|
+
for (const [key, value] of Object.entries(query)) {
|
|
270
|
+
if (value === undefined)
|
|
271
|
+
continue;
|
|
272
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
273
|
+
throw new TypeError(`OpenRouter query parameter "${key}" must be a finite number`);
|
|
274
|
+
}
|
|
275
|
+
resolved.searchParams.set(key, String(value));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return resolved;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// src/agent-runtime/providers/openrouter-models.ts
|
|
188
282
|
var OpenRouterModelSchema = z2.object({
|
|
189
283
|
id: z2.string().min(1),
|
|
190
284
|
canonical_slug: z2.string().min(1).nullish(),
|
|
@@ -327,12 +421,12 @@ function usd(value) {
|
|
|
327
421
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
|
|
328
422
|
}
|
|
329
423
|
var MODEL_ID = /^~?[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._:-]*$/i;
|
|
330
|
-
function openRouterEndpointsUrl(modelId) {
|
|
424
|
+
function openRouterEndpointsUrl(modelId, baseUrl) {
|
|
331
425
|
if (!MODEL_ID.test(modelId) || modelId.includes("..")) {
|
|
332
426
|
throw new TypeError(`Not an OpenRouter model id: ${modelId}`);
|
|
333
427
|
}
|
|
334
428
|
const [author = "", slug = ""] = modelId.split("/");
|
|
335
|
-
return
|
|
429
|
+
return resolveOpenRouterUrl(baseUrl, `/models/${encodeURIComponent(author)}/${encodeURIComponent(slug)}/endpoints`);
|
|
336
430
|
}
|
|
337
431
|
function assertValidOpenRouterEndpointsFor(endpointsFor) {
|
|
338
432
|
if (endpointsFor === undefined)
|
|
@@ -500,196 +594,7 @@ function parseOpenRouterWirePricing(pricing) {
|
|
|
500
594
|
};
|
|
501
595
|
}
|
|
502
596
|
|
|
503
|
-
// src/agent-runtime/openrouter-
|
|
504
|
-
import { z as z3 } from "zod";
|
|
505
|
-
var OPENROUTER_POLICY_KEYS = [
|
|
506
|
-
"provider",
|
|
507
|
-
"reasoning",
|
|
508
|
-
"session_id",
|
|
509
|
-
"usage",
|
|
510
|
-
"cache_control",
|
|
511
|
-
"model",
|
|
512
|
-
"stream",
|
|
513
|
-
"messages",
|
|
514
|
-
"response_format",
|
|
515
|
-
"tools",
|
|
516
|
-
"tool_choice",
|
|
517
|
-
"max_tokens",
|
|
518
|
-
"temperature",
|
|
519
|
-
"top_p",
|
|
520
|
-
"top_k",
|
|
521
|
-
"presence_penalty",
|
|
522
|
-
"frequency_penalty",
|
|
523
|
-
"seed",
|
|
524
|
-
"stop"
|
|
525
|
-
];
|
|
526
|
-
var OpenRouterReasoningEffortSchema = z3.enum([
|
|
527
|
-
"none",
|
|
528
|
-
"minimal",
|
|
529
|
-
"low",
|
|
530
|
-
"medium",
|
|
531
|
-
"high",
|
|
532
|
-
"xhigh",
|
|
533
|
-
"max"
|
|
534
|
-
]);
|
|
535
|
-
var Usd = z3.number().nonnegative();
|
|
536
|
-
var OpenRouterMaxPriceSchema = z3.strictObject({
|
|
537
|
-
promptUsdPerMillion: Usd.optional(),
|
|
538
|
-
completionUsdPerMillion: Usd.optional(),
|
|
539
|
-
requestUsd: Usd.optional(),
|
|
540
|
-
imageUsd: Usd.optional()
|
|
541
|
-
});
|
|
542
|
-
var Slug = z3.string().min(1).max(128);
|
|
543
|
-
var OpenRouterProviderRoutingSchema = z3.strictObject({
|
|
544
|
-
order: z3.array(Slug).min(1).optional(),
|
|
545
|
-
only: z3.array(Slug).min(1).optional(),
|
|
546
|
-
ignore: z3.array(Slug).min(1).optional(),
|
|
547
|
-
allowFallbacks: z3.boolean().optional(),
|
|
548
|
-
requireParameters: z3.boolean().optional(),
|
|
549
|
-
dataCollection: z3.enum(["allow", "deny"]).optional(),
|
|
550
|
-
zdr: z3.boolean().optional(),
|
|
551
|
-
sort: z3.enum(["price", "throughput", "latency"]).optional(),
|
|
552
|
-
quantizations: z3.array(z3.string().min(1).max(16)).min(1).optional()
|
|
553
|
-
});
|
|
554
|
-
var OpenRouterReasoningPolicySchema = z3.strictObject({
|
|
555
|
-
effort: OpenRouterReasoningEffortSchema.optional(),
|
|
556
|
-
maxTokens: z3.int().positive().optional(),
|
|
557
|
-
enabled: z3.boolean().optional(),
|
|
558
|
-
exclude: z3.boolean().optional()
|
|
559
|
-
}).superRefine((reasoning, context) => {
|
|
560
|
-
if (reasoning.effort !== undefined && reasoning.maxTokens !== undefined) {
|
|
561
|
-
context.addIssue({
|
|
562
|
-
code: "custom",
|
|
563
|
-
path: ["maxTokens"],
|
|
564
|
-
message: "Specify reasoning.effort or reasoning.maxTokens, not both"
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
if (reasoning.effort === undefined && reasoning.maxTokens === undefined && reasoning.enabled === undefined) {
|
|
568
|
-
context.addIssue({
|
|
569
|
-
code: "custom",
|
|
570
|
-
path: ["effort"],
|
|
571
|
-
message: "Specify at least one of reasoning.effort, reasoning.maxTokens, or reasoning.enabled"
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
var OpenRouterRequestPolicySchema = z3.strictObject({
|
|
576
|
-
sessionId: z3.string().min(1).max(256).optional(),
|
|
577
|
-
reasoning: OpenRouterReasoningPolicySchema.optional(),
|
|
578
|
-
provider: OpenRouterProviderRoutingSchema.optional(),
|
|
579
|
-
maxPrice: OpenRouterMaxPriceSchema.optional(),
|
|
580
|
-
looseTools: z3.boolean().optional(),
|
|
581
|
-
cacheControl: AgentCacheControlSchema2.optional()
|
|
582
|
-
}).superRefine((policy, context) => {
|
|
583
|
-
if (policy.sessionId !== undefined && policy.provider?.order !== undefined)
|
|
584
|
-
context.addIssue({
|
|
585
|
-
code: "custom",
|
|
586
|
-
path: ["provider", "order"],
|
|
587
|
-
message: "A request pins its route by sessionId or by provider.order, not both"
|
|
588
|
-
});
|
|
589
|
-
});
|
|
590
|
-
function resolveOpenRouterWirePolicy(raw) {
|
|
591
|
-
const policy = OpenRouterRequestPolicySchema.parse(raw);
|
|
592
|
-
const routing = policy.provider;
|
|
593
|
-
const price = policy.maxPrice;
|
|
594
|
-
const maxPrice = price && {
|
|
595
|
-
...price.promptUsdPerMillion !== undefined && { prompt: price.promptUsdPerMillion },
|
|
596
|
-
...price.completionUsdPerMillion !== undefined && {
|
|
597
|
-
completion: price.completionUsdPerMillion
|
|
598
|
-
},
|
|
599
|
-
...price.requestUsd !== undefined && { request: price.requestUsd },
|
|
600
|
-
...price.imageUsd !== undefined && { image: price.imageUsd }
|
|
601
|
-
};
|
|
602
|
-
const provider = routing || maxPrice ? {
|
|
603
|
-
...routing?.order && { order: routing.order },
|
|
604
|
-
...routing?.only && { only: routing.only },
|
|
605
|
-
...routing?.ignore && { ignore: routing.ignore },
|
|
606
|
-
...routing?.allowFallbacks !== undefined && {
|
|
607
|
-
allow_fallbacks: routing.allowFallbacks
|
|
608
|
-
},
|
|
609
|
-
...routing?.requireParameters !== undefined && {
|
|
610
|
-
require_parameters: routing.requireParameters
|
|
611
|
-
},
|
|
612
|
-
...routing?.dataCollection && { data_collection: routing.dataCollection },
|
|
613
|
-
...routing?.zdr !== undefined && { zdr: routing.zdr },
|
|
614
|
-
...routing?.sort && { sort: routing.sort },
|
|
615
|
-
...routing?.quantizations && { quantizations: routing.quantizations },
|
|
616
|
-
...maxPrice && Object.keys(maxPrice).length > 0 && { max_price: maxPrice }
|
|
617
|
-
} : undefined;
|
|
618
|
-
return {
|
|
619
|
-
...provider && Object.keys(provider).length > 0 && { provider },
|
|
620
|
-
...policy.reasoning && {
|
|
621
|
-
reasoning: {
|
|
622
|
-
...policy.reasoning.effort !== undefined && { effort: policy.reasoning.effort },
|
|
623
|
-
...policy.reasoning.maxTokens !== undefined && {
|
|
624
|
-
max_tokens: policy.reasoning.maxTokens
|
|
625
|
-
},
|
|
626
|
-
...policy.reasoning.enabled !== undefined && { enabled: policy.reasoning.enabled },
|
|
627
|
-
...policy.reasoning.exclude !== undefined && { exclude: policy.reasoning.exclude }
|
|
628
|
-
}
|
|
629
|
-
},
|
|
630
|
-
...policy.sessionId !== undefined && { sessionId: policy.sessionId },
|
|
631
|
-
looseTools: policy.looseTools === true,
|
|
632
|
-
...policy.cacheControl !== undefined && { cacheControl: policy.cacheControl }
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
function mergeOpenRouterStepPolicy(base, providerOptions) {
|
|
636
|
-
const reqOr = recordField(providerOptions, "openrouter");
|
|
637
|
-
if (!reqOr || Object.keys(reqOr).length === 0) {
|
|
638
|
-
return {
|
|
639
|
-
...base.provider !== undefined && { provider: base.provider },
|
|
640
|
-
...base.reasoning !== undefined && { reasoning: base.reasoning },
|
|
641
|
-
...base.sessionId !== undefined && { baseSessionId: base.sessionId },
|
|
642
|
-
looseTools: base.looseTools,
|
|
643
|
-
...base.cacheControl !== undefined && { baseCacheControl: base.cacheControl }
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
let stepExtraBody;
|
|
647
|
-
const policyInput = {};
|
|
648
|
-
for (const [key, value] of Object.entries(reqOr)) {
|
|
649
|
-
if (key === "extraBody") {
|
|
650
|
-
if (value !== undefined) {
|
|
651
|
-
if (!isRecord(value)) {
|
|
652
|
-
throw new TypeError("openRouterProvider: providerOptions.openrouter.extraBody must be a plain object");
|
|
653
|
-
}
|
|
654
|
-
assertNoExtraBodyClash("openRouterProvider", value, OPENROUTER_POLICY_KEYS);
|
|
655
|
-
stepExtraBody = value;
|
|
656
|
-
}
|
|
657
|
-
continue;
|
|
658
|
-
}
|
|
659
|
-
policyInput[key] = value;
|
|
660
|
-
}
|
|
661
|
-
const parsedStep = OpenRouterRequestPolicySchema.parse(policyInput);
|
|
662
|
-
const stepWire = resolveOpenRouterWirePolicy(parsedStep);
|
|
663
|
-
let mergedProvider;
|
|
664
|
-
if (base.provider || stepWire.provider) {
|
|
665
|
-
const baseProvider = stepWire.sessionId !== undefined && base.provider ? Object.fromEntries(Object.entries(base.provider).filter(([k]) => k !== "order")) : base.provider;
|
|
666
|
-
const baseMaxPrice = isRecord(baseProvider?.max_price) ? baseProvider.max_price : null;
|
|
667
|
-
const stepMaxPrice = isRecord(stepWire.provider?.max_price) ? stepWire.provider.max_price : null;
|
|
668
|
-
const combined = {
|
|
669
|
-
...baseProvider,
|
|
670
|
-
...stepWire.provider,
|
|
671
|
-
...baseMaxPrice && stepMaxPrice && { max_price: { ...baseMaxPrice, ...stepMaxPrice } }
|
|
672
|
-
};
|
|
673
|
-
if (Object.keys(combined).length > 0)
|
|
674
|
-
mergedProvider = combined;
|
|
675
|
-
}
|
|
676
|
-
return {
|
|
677
|
-
...mergedProvider !== undefined && { provider: mergedProvider },
|
|
678
|
-
...(stepWire.reasoning ?? base.reasoning) !== undefined && {
|
|
679
|
-
reasoning: stepWire.reasoning ?? base.reasoning
|
|
680
|
-
},
|
|
681
|
-
...stepWire.sessionId !== undefined && { stepSessionId: stepWire.sessionId },
|
|
682
|
-
...base.sessionId !== undefined && { baseSessionId: base.sessionId },
|
|
683
|
-
looseTools: parsedStep.looseTools !== undefined ? stepWire.looseTools : base.looseTools,
|
|
684
|
-
...stepWire.cacheControl !== undefined && {
|
|
685
|
-
explicitCacheControl: stepWire.cacheControl
|
|
686
|
-
},
|
|
687
|
-
...base.cacheControl !== undefined && { baseCacheControl: base.cacheControl },
|
|
688
|
-
...stepExtraBody !== undefined && { stepExtraBody }
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
// src/agent-runtime/openrouter-response.ts
|
|
597
|
+
// src/agent-runtime/providers/openrouter-response.ts
|
|
693
598
|
var GENERIC_ERROR_MESSAGES = new Set([
|
|
694
599
|
"OpenRouter request failed",
|
|
695
600
|
"Provider returned error"
|
|
@@ -722,8 +627,8 @@ function readBooleanField(record, key) {
|
|
|
722
627
|
function normalizeOpenRouterUsageDetails(usage, metadata) {
|
|
723
628
|
const source = isRecord(usage) ? recordField(usage, "raw") ?? usage : {};
|
|
724
629
|
const metaUsage = readMetadataUsageRecord(metadata);
|
|
725
|
-
const prompt = recordField(source, "prompt_tokens_details") ?? {};
|
|
726
|
-
const completion = recordField(source, "completion_tokens_details") ?? {};
|
|
630
|
+
const prompt = recordField(source, "prompt_tokens_details") ?? recordField(source, "input_tokens_details") ?? {};
|
|
631
|
+
const completion = recordField(source, "completion_tokens_details") ?? recordField(source, "output_tokens_details") ?? {};
|
|
727
632
|
const rawCostDetails = recordField(source, "cost_details") ?? (metaUsage ? recordField(metaUsage, "cost_details") : undefined);
|
|
728
633
|
const isByok = readBooleanField(source, "is_byok") ?? readBooleanField(metaUsage, "is_byok");
|
|
729
634
|
const promptCostUsd = nonNegativeNumber(rawCostDetails?.upstream_inference_prompt_cost) ?? nonNegativeNumber(rawCostDetails?.prompt_cost);
|
|
@@ -738,8 +643,8 @@ function normalizeOpenRouterUsageDetails(usage, metadata) {
|
|
|
738
643
|
cost = reportedUsd(baseCost);
|
|
739
644
|
}
|
|
740
645
|
const normalizedUsage = buildProviderUsage({
|
|
741
|
-
inputTokens: reportedInt(source.prompt_tokens),
|
|
742
|
-
outputTokens: reportedInt(source.completion_tokens),
|
|
646
|
+
inputTokens: reportedInt(source.prompt_tokens ?? source.input_tokens),
|
|
647
|
+
outputTokens: reportedInt(source.completion_tokens ?? source.output_tokens),
|
|
743
648
|
reasoningTokens: reportedInt(completion.reasoning_tokens),
|
|
744
649
|
cacheReadTokens: reportedInt(prompt.cached_tokens),
|
|
745
650
|
cacheWriteTokens: reportedInt(prompt.cache_write_tokens),
|
|
@@ -850,47 +755,519 @@ function parseOpenRouterError(payload, rawText = "", status) {
|
|
|
850
755
|
};
|
|
851
756
|
}
|
|
852
757
|
|
|
853
|
-
// src/agent-runtime/openrouter-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
assertPositiveSafeInteger("ttlMs", ttlMs);
|
|
865
|
-
const now = options.now ?? Date.now;
|
|
866
|
-
const pins = new Map;
|
|
758
|
+
// src/agent-runtime/providers/openrouter-http.ts
|
|
759
|
+
var DEFAULT_OPENROUTER_REQUEST_TIMEOUT_MS = 30000;
|
|
760
|
+
var JSON_CONTENT_TYPE = /^application\/(?:[a-z0-9.+-]+\+)?json(?:\s*;|$)/iu;
|
|
761
|
+
function assertNonEmptyOpenRouterField(caller, name, value) {
|
|
762
|
+
const trimmed = typeof value === "string" ? value.trim() : "";
|
|
763
|
+
if (trimmed.length === 0) {
|
|
764
|
+
throw new TypeError(`${caller}: ${name} must be a non-empty string`);
|
|
765
|
+
}
|
|
766
|
+
return trimmed;
|
|
767
|
+
}
|
|
768
|
+
function pickOpenRouterTransport(input) {
|
|
867
769
|
return {
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
},
|
|
878
|
-
|
|
879
|
-
pins.delete(key);
|
|
880
|
-
while (pins.size >= maxEntries) {
|
|
881
|
-
const oldest = pins.keys().next().value;
|
|
882
|
-
if (oldest === undefined)
|
|
883
|
-
break;
|
|
884
|
-
pins.delete(oldest);
|
|
885
|
-
}
|
|
886
|
-
pins.set(key, { pin: OpenRouterRoutePinSchema.parse(pin), expiresAt: now() + ttlMs });
|
|
887
|
-
}
|
|
770
|
+
...input.apiKey !== undefined && { apiKey: input.apiKey },
|
|
771
|
+
...input.baseUrl !== undefined && { baseUrl: input.baseUrl },
|
|
772
|
+
...input.headers !== undefined && { headers: input.headers },
|
|
773
|
+
...input.appName !== undefined && { appName: input.appName },
|
|
774
|
+
...input.appUrl !== undefined && { appUrl: input.appUrl },
|
|
775
|
+
...input.providerApiKeys !== undefined && { providerApiKeys: input.providerApiKeys },
|
|
776
|
+
...input.fetch !== undefined && { fetch: input.fetch },
|
|
777
|
+
...input.signal !== undefined && { signal: input.signal },
|
|
778
|
+
...input.timeoutMs !== undefined && { timeoutMs: input.timeoutMs },
|
|
779
|
+
...input.maxErrorBytes !== undefined && { maxErrorBytes: input.maxErrorBytes },
|
|
780
|
+
...input.maxResponseBytes !== undefined && { maxResponseBytes: input.maxResponseBytes }
|
|
888
781
|
};
|
|
889
782
|
}
|
|
890
|
-
function
|
|
891
|
-
|
|
783
|
+
function validateApiKeyString(raw) {
|
|
784
|
+
if (typeof raw !== "string") {
|
|
785
|
+
throw new TypeError("OpenRouter apiKey must resolve to a non-empty string");
|
|
786
|
+
}
|
|
787
|
+
if (/[\r\n]/u.test(raw)) {
|
|
788
|
+
throw new TypeError("OpenRouter apiKey must not contain CR or LF characters");
|
|
789
|
+
}
|
|
790
|
+
const trimmed = raw.trim();
|
|
791
|
+
if (trimmed.length === 0) {
|
|
792
|
+
throw new TypeError("OpenRouter apiKey must be a non-empty string when provided");
|
|
793
|
+
}
|
|
794
|
+
return trimmed;
|
|
892
795
|
}
|
|
893
|
-
function
|
|
796
|
+
function assertValidOpenRouterApiKey(apiKey) {
|
|
797
|
+
if (apiKey === undefined || typeof apiKey === "function")
|
|
798
|
+
return;
|
|
799
|
+
validateApiKeyString(apiKey);
|
|
800
|
+
}
|
|
801
|
+
async function resolveOptionalOpenRouterApiKey2(apiKey) {
|
|
802
|
+
if (apiKey === undefined)
|
|
803
|
+
return;
|
|
804
|
+
const resolved = typeof apiKey === "function" ? await apiKey() : apiKey;
|
|
805
|
+
return validateApiKeyString(resolved);
|
|
806
|
+
}
|
|
807
|
+
function hasHeaderIgnoreCase(headers, targetLower) {
|
|
808
|
+
if (!headers)
|
|
809
|
+
return false;
|
|
810
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === targetLower);
|
|
811
|
+
}
|
|
812
|
+
function assertOpenRouterDirectAuth(input) {
|
|
813
|
+
if (input.apiKey === undefined && input.fetch === undefined && input.baseUrl === undefined && !hasHeaderIgnoreCase(input.headers, "authorization")) {
|
|
814
|
+
throw new TypeError("OpenRouter apiKey is required unless a custom fetch transport or baseUrl is provided");
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
function buildOpenRouterBaseHeaders(settings, apiKey) {
|
|
818
|
+
return {
|
|
819
|
+
...apiKey !== undefined && { authorization: `Bearer ${apiKey}` },
|
|
820
|
+
...settings.appUrl !== undefined && { "HTTP-Referer": settings.appUrl },
|
|
821
|
+
...settings.appName !== undefined && { "X-OpenRouter-Title": settings.appName },
|
|
822
|
+
...settings.providerApiKeys !== undefined && {
|
|
823
|
+
"X-Provider-API-Keys": JSON.stringify(settings.providerApiKeys)
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
function prepareOpenRouterRequest(input) {
|
|
828
|
+
const url = resolveOpenRouterUrl(input.baseUrl, input.path, input.query).toString();
|
|
829
|
+
const method = input.method ?? (input.body !== undefined ? "POST" : "GET");
|
|
830
|
+
if (method === "GET" && input.body !== undefined) {
|
|
831
|
+
throw new TypeError("OpenRouter GET request must not include a request body");
|
|
832
|
+
}
|
|
833
|
+
assertValidOpenRouterApiKey(input.apiKey);
|
|
834
|
+
if (input.apiKey !== undefined && hasHeaderIgnoreCase(input.headers, "authorization")) {
|
|
835
|
+
throw new TypeError("OpenRouter request cannot specify both apiKey and Authorization header");
|
|
836
|
+
}
|
|
837
|
+
const isFormData = typeof FormData === "function" && input.body instanceof FormData;
|
|
838
|
+
if (isFormData && hasHeaderIgnoreCase(input.headers, "content-type")) {
|
|
839
|
+
throw new TypeError("OpenRouter FormData request must not specify a Content-Type header (multipart boundary is generated automatically)");
|
|
840
|
+
}
|
|
841
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_OPENROUTER_REQUEST_TIMEOUT_MS;
|
|
842
|
+
assertTimerMs("timeoutMs", timeoutMs);
|
|
843
|
+
const maxErrorBytes = input.maxErrorBytes ?? DEFAULT_MAX_ERROR_BODY_BYTES;
|
|
844
|
+
assertPositiveSafeInteger("maxErrorBytes", maxErrorBytes);
|
|
845
|
+
let serializedBody;
|
|
846
|
+
if (input.body !== undefined) {
|
|
847
|
+
if (isFormData) {
|
|
848
|
+
serializedBody = input.body;
|
|
849
|
+
} else {
|
|
850
|
+
const encoded = JSON.stringify(input.body);
|
|
851
|
+
if (encoded === undefined) {
|
|
852
|
+
throw new TypeError("OpenRouter request body is not JSON-serializable");
|
|
853
|
+
}
|
|
854
|
+
serializedBody = encoded;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return {
|
|
858
|
+
url,
|
|
859
|
+
method,
|
|
860
|
+
isFormData,
|
|
861
|
+
...serializedBody !== undefined && { serializedBody },
|
|
862
|
+
timeoutMs,
|
|
863
|
+
maxErrorBytes,
|
|
864
|
+
fetcher: input.fetch ?? fetch
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function assembleOpenRouterRequestHeaders(input, prepared, apiKey, defaultAccept) {
|
|
868
|
+
const headers = new Headers;
|
|
869
|
+
if (defaultAccept !== undefined)
|
|
870
|
+
headers.set("accept", defaultAccept);
|
|
871
|
+
if (prepared.serializedBody !== undefined && !prepared.isFormData) {
|
|
872
|
+
headers.set("content-type", "application/json");
|
|
873
|
+
}
|
|
874
|
+
for (const [k, v] of Object.entries(buildOpenRouterBaseHeaders(input, apiKey))) {
|
|
875
|
+
headers.set(k, v);
|
|
876
|
+
}
|
|
877
|
+
if (input.headers) {
|
|
878
|
+
for (const [k, v] of Object.entries(input.headers)) {
|
|
879
|
+
headers.set(k, v);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return headers;
|
|
883
|
+
}
|
|
884
|
+
async function assertNotRedirectedResponse(response) {
|
|
885
|
+
if (response.redirected || response.type === "opaqueredirect" || response.status >= 300 && response.status < 400) {
|
|
886
|
+
await response.body?.cancel().catch(() => {
|
|
887
|
+
return;
|
|
888
|
+
});
|
|
889
|
+
throw new AgentProviderError2(`OpenRouter redirected response refused (HTTP ${response.status})`, {
|
|
890
|
+
provider: "openrouter",
|
|
891
|
+
statusCode: response.status,
|
|
892
|
+
retryable: false,
|
|
893
|
+
responseHeaders: headersToRecord(response.headers)
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function extractOpenRouterGenerationId(headers, parsedBody) {
|
|
898
|
+
const fromHeader = nonEmptyTrimmed(headers.get("x-generation-id"));
|
|
899
|
+
if (fromHeader !== undefined)
|
|
900
|
+
return fromHeader;
|
|
901
|
+
if (!isRecord(parsedBody))
|
|
902
|
+
return;
|
|
903
|
+
const genId = nonEmptyTrimmed(typeof parsedBody.generation_id === "string" ? parsedBody.generation_id : undefined);
|
|
904
|
+
if (genId !== undefined)
|
|
905
|
+
return genId;
|
|
906
|
+
const bodyId = nonEmptyTrimmed(typeof parsedBody.id === "string" ? parsedBody.id : undefined);
|
|
907
|
+
return bodyId?.startsWith("gen-") ? bodyId : undefined;
|
|
908
|
+
}
|
|
909
|
+
function extractCostUsd(parsedBody) {
|
|
910
|
+
if (!isRecord(parsedBody))
|
|
911
|
+
return;
|
|
912
|
+
const cost = normalizeOpenRouterUsageDetails(parsedBody.usage).usage.cost;
|
|
913
|
+
return cost?.value;
|
|
914
|
+
}
|
|
915
|
+
async function openRouterRequestJson(input) {
|
|
916
|
+
const prepared = prepareOpenRouterRequest(input);
|
|
917
|
+
const maxResponseBytes = input.maxResponseBytes ?? DEFAULT_MAX_JSON_BODY_BYTES;
|
|
918
|
+
assertPositiveSafeInteger("maxResponseBytes", maxResponseBytes);
|
|
919
|
+
input.signal?.throwIfAborted();
|
|
920
|
+
const apiKey = await resolveOptionalOpenRouterApiKey2(input.apiKey);
|
|
921
|
+
input.signal?.throwIfAborted();
|
|
922
|
+
return withSignalDeadline(prepared.timeoutMs, input.signal, () => abortError(`OpenRouter request ${input.path} timed out after ${prepared.timeoutMs} ms`, "TimeoutError"), async (signal) => {
|
|
923
|
+
const headers = assembleOpenRouterRequestHeaders(input, prepared, apiKey, "application/json");
|
|
924
|
+
const response = await raceAbort(prepared.fetcher(prepared.url, {
|
|
925
|
+
method: prepared.method,
|
|
926
|
+
headers,
|
|
927
|
+
...prepared.serializedBody !== undefined && { body: prepared.serializedBody },
|
|
928
|
+
redirect: "error",
|
|
929
|
+
signal
|
|
930
|
+
}), signal, (late) => {
|
|
931
|
+
late.body?.cancel(abortReason(signal)).catch(() => {
|
|
932
|
+
return;
|
|
933
|
+
});
|
|
934
|
+
});
|
|
935
|
+
if (signal.aborted) {
|
|
936
|
+
await response.body?.cancel(abortReason(signal)).catch(() => {
|
|
937
|
+
return;
|
|
938
|
+
});
|
|
939
|
+
signal.throwIfAborted();
|
|
940
|
+
}
|
|
941
|
+
await assertNotRedirectedResponse(response);
|
|
942
|
+
if (!response.ok) {
|
|
943
|
+
throw await buildProviderHttpError({
|
|
944
|
+
provider: "openrouter",
|
|
945
|
+
response,
|
|
946
|
+
signal,
|
|
947
|
+
parseError: parseOpenRouterError,
|
|
948
|
+
maxErrorBytes: prepared.maxErrorBytes
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
const requestId = extractProviderRequestId(response.headers);
|
|
952
|
+
const responseHeaders = headersToRecord(response.headers);
|
|
953
|
+
const contentType = response.headers.get("content-type")?.trim() ?? "";
|
|
954
|
+
if (contentType.length > 0 && !JSON_CONTENT_TYPE.test(contentType)) {
|
|
955
|
+
const preview = await readBoundedText(response, { maxBytes: 4096, signal }).catch(() => ({
|
|
956
|
+
kind: "complete",
|
|
957
|
+
text: ""
|
|
958
|
+
}));
|
|
959
|
+
if (signal.aborted)
|
|
960
|
+
signal.throwIfAborted();
|
|
961
|
+
const snippet = preview.kind === "complete" && preview.text.length > 0 ? `: ${redactProviderFailureText(preview.text, 256)}` : "";
|
|
962
|
+
throw new AgentProviderError2(`OpenRouter returned unexpected content-type "${redactProviderFailureText(contentType, 128)}"${snippet}`, {
|
|
963
|
+
provider: "openrouter",
|
|
964
|
+
statusCode: response.status,
|
|
965
|
+
retryable: false,
|
|
966
|
+
...requestId !== undefined && { requestId },
|
|
967
|
+
responseHeaders
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
const bodyResult = await readBoundedText(response, {
|
|
971
|
+
maxBytes: maxResponseBytes,
|
|
972
|
+
signal,
|
|
973
|
+
checkContentLength: true
|
|
974
|
+
});
|
|
975
|
+
if (signal.aborted)
|
|
976
|
+
signal.throwIfAborted();
|
|
977
|
+
if (bodyResult.kind === "over-limit") {
|
|
978
|
+
throw new AgentProviderError2(`OpenRouter JSON response exceeded ${maxResponseBytes} byte limit`, {
|
|
979
|
+
provider: "openrouter",
|
|
980
|
+
statusCode: response.status,
|
|
981
|
+
retryable: false,
|
|
982
|
+
...requestId !== undefined && { requestId },
|
|
983
|
+
responseHeaders
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
if (bodyResult.text.trim().length === 0) {
|
|
987
|
+
throw new AgentProviderError2("OpenRouter returned an empty JSON response body", {
|
|
988
|
+
provider: "openrouter",
|
|
989
|
+
statusCode: response.status,
|
|
990
|
+
retryable: false,
|
|
991
|
+
...requestId !== undefined && { requestId },
|
|
992
|
+
responseHeaders
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
let parsed;
|
|
996
|
+
try {
|
|
997
|
+
parsed = JSON.parse(bodyResult.text);
|
|
998
|
+
} catch (error) {
|
|
999
|
+
throw new AgentProviderError2(`OpenRouter returned invalid JSON body: ${redactProviderFailureText(bodyResult.text, 256)}`, {
|
|
1000
|
+
provider: "openrouter",
|
|
1001
|
+
statusCode: response.status,
|
|
1002
|
+
retryable: false,
|
|
1003
|
+
...requestId !== undefined && { requestId },
|
|
1004
|
+
responseHeaders,
|
|
1005
|
+
cause: error
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
let data = parsed;
|
|
1009
|
+
if (input.schema !== undefined) {
|
|
1010
|
+
const validated = input.schema.safeParse(parsed);
|
|
1011
|
+
if (!validated.success) {
|
|
1012
|
+
throw new AgentProviderError2(`OpenRouter response failed schema validation: ${redactProviderFailureText(validated.error.message, 512)}`, {
|
|
1013
|
+
provider: "openrouter",
|
|
1014
|
+
statusCode: response.status,
|
|
1015
|
+
retryable: false,
|
|
1016
|
+
...requestId !== undefined && { requestId },
|
|
1017
|
+
responseHeaders,
|
|
1018
|
+
cause: validated.error
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
data = validated.data;
|
|
1022
|
+
}
|
|
1023
|
+
const generationId = extractOpenRouterGenerationId(response.headers, parsed);
|
|
1024
|
+
const costUsd = extractCostUsd(parsed);
|
|
1025
|
+
return {
|
|
1026
|
+
data,
|
|
1027
|
+
status: response.status,
|
|
1028
|
+
...generationId !== undefined && { generationId },
|
|
1029
|
+
...requestId !== undefined && { requestId },
|
|
1030
|
+
...costUsd !== undefined && { costUsd },
|
|
1031
|
+
headers: responseHeaders
|
|
1032
|
+
};
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
// src/agent-runtime/providers/openrouter-options.ts
|
|
1037
|
+
import { z as z3 } from "zod";
|
|
1038
|
+
var OPENROUTER_POLICY_KEYS = [
|
|
1039
|
+
"provider",
|
|
1040
|
+
"reasoning",
|
|
1041
|
+
"session_id",
|
|
1042
|
+
"usage",
|
|
1043
|
+
"cache_control",
|
|
1044
|
+
"model",
|
|
1045
|
+
"stream",
|
|
1046
|
+
"messages",
|
|
1047
|
+
"response_format",
|
|
1048
|
+
"tools",
|
|
1049
|
+
"tool_choice",
|
|
1050
|
+
"max_tokens",
|
|
1051
|
+
"temperature",
|
|
1052
|
+
"top_p",
|
|
1053
|
+
"top_k",
|
|
1054
|
+
"presence_penalty",
|
|
1055
|
+
"frequency_penalty",
|
|
1056
|
+
"seed",
|
|
1057
|
+
"stop"
|
|
1058
|
+
];
|
|
1059
|
+
var OpenRouterReasoningEffortSchema = z3.enum([
|
|
1060
|
+
"none",
|
|
1061
|
+
"minimal",
|
|
1062
|
+
"low",
|
|
1063
|
+
"medium",
|
|
1064
|
+
"high",
|
|
1065
|
+
"xhigh",
|
|
1066
|
+
"max"
|
|
1067
|
+
]);
|
|
1068
|
+
var Usd = z3.number().nonnegative();
|
|
1069
|
+
var OpenRouterMaxPriceSchema = z3.strictObject({
|
|
1070
|
+
promptUsdPerMillion: Usd.optional(),
|
|
1071
|
+
completionUsdPerMillion: Usd.optional(),
|
|
1072
|
+
requestUsd: Usd.optional(),
|
|
1073
|
+
imageUsd: Usd.optional()
|
|
1074
|
+
});
|
|
1075
|
+
var Slug = z3.string().min(1).max(128);
|
|
1076
|
+
var OpenRouterProviderRoutingSchema = z3.strictObject({
|
|
1077
|
+
order: z3.array(Slug).min(1).optional(),
|
|
1078
|
+
only: z3.array(Slug).min(1).optional(),
|
|
1079
|
+
ignore: z3.array(Slug).min(1).optional(),
|
|
1080
|
+
allowFallbacks: z3.boolean().optional(),
|
|
1081
|
+
requireParameters: z3.boolean().optional(),
|
|
1082
|
+
dataCollection: z3.enum(["allow", "deny"]).optional(),
|
|
1083
|
+
zdr: z3.boolean().optional(),
|
|
1084
|
+
sort: z3.enum(["price", "throughput", "latency"]).optional(),
|
|
1085
|
+
quantizations: z3.array(z3.string().min(1).max(16)).min(1).optional()
|
|
1086
|
+
});
|
|
1087
|
+
var OpenRouterReasoningPolicySchema = z3.strictObject({
|
|
1088
|
+
effort: OpenRouterReasoningEffortSchema.optional(),
|
|
1089
|
+
maxTokens: z3.int().positive().optional(),
|
|
1090
|
+
enabled: z3.boolean().optional(),
|
|
1091
|
+
exclude: z3.boolean().optional()
|
|
1092
|
+
}).superRefine((reasoning, context) => {
|
|
1093
|
+
if (reasoning.effort !== undefined && reasoning.maxTokens !== undefined) {
|
|
1094
|
+
context.addIssue({
|
|
1095
|
+
code: "custom",
|
|
1096
|
+
path: ["maxTokens"],
|
|
1097
|
+
message: "Specify reasoning.effort or reasoning.maxTokens, not both"
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
if (reasoning.effort === undefined && reasoning.maxTokens === undefined && reasoning.enabled === undefined) {
|
|
1101
|
+
context.addIssue({
|
|
1102
|
+
code: "custom",
|
|
1103
|
+
path: ["effort"],
|
|
1104
|
+
message: "Specify at least one of reasoning.effort, reasoning.maxTokens, or reasoning.enabled"
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
});
|
|
1108
|
+
var OpenRouterRequestPolicySchema = z3.strictObject({
|
|
1109
|
+
sessionId: z3.string().min(1).max(256).optional(),
|
|
1110
|
+
reasoning: OpenRouterReasoningPolicySchema.optional(),
|
|
1111
|
+
provider: OpenRouterProviderRoutingSchema.optional(),
|
|
1112
|
+
maxPrice: OpenRouterMaxPriceSchema.optional(),
|
|
1113
|
+
looseTools: z3.boolean().optional(),
|
|
1114
|
+
cacheControl: AgentCacheControlSchema2.optional()
|
|
1115
|
+
}).superRefine((policy, context) => {
|
|
1116
|
+
if (policy.sessionId !== undefined && policy.provider?.order !== undefined)
|
|
1117
|
+
context.addIssue({
|
|
1118
|
+
code: "custom",
|
|
1119
|
+
path: ["provider", "order"],
|
|
1120
|
+
message: "A request pins its route by sessionId or by provider.order, not both"
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
function serializeOpenRouterProviderRouting(raw) {
|
|
1124
|
+
const routing = OpenRouterProviderRoutingSchema.parse(raw);
|
|
1125
|
+
const wire = {
|
|
1126
|
+
...routing.order && { order: routing.order },
|
|
1127
|
+
...routing.only && { only: routing.only },
|
|
1128
|
+
...routing.ignore && { ignore: routing.ignore },
|
|
1129
|
+
...routing.allowFallbacks !== undefined && { allow_fallbacks: routing.allowFallbacks },
|
|
1130
|
+
...routing.requireParameters !== undefined && {
|
|
1131
|
+
require_parameters: routing.requireParameters
|
|
1132
|
+
},
|
|
1133
|
+
...routing.dataCollection && { data_collection: routing.dataCollection },
|
|
1134
|
+
...routing.zdr !== undefined && { zdr: routing.zdr },
|
|
1135
|
+
...routing.sort && { sort: routing.sort },
|
|
1136
|
+
...routing.quantizations && { quantizations: routing.quantizations }
|
|
1137
|
+
};
|
|
1138
|
+
return Object.keys(wire).length > 0 ? wire : undefined;
|
|
1139
|
+
}
|
|
1140
|
+
function resolveOpenRouterWirePolicy(raw) {
|
|
1141
|
+
const policy = OpenRouterRequestPolicySchema.parse(raw);
|
|
1142
|
+
const routing = policy.provider ? serializeOpenRouterProviderRouting(policy.provider) : undefined;
|
|
1143
|
+
const price = policy.maxPrice;
|
|
1144
|
+
const maxPrice = price && {
|
|
1145
|
+
...price.promptUsdPerMillion !== undefined && { prompt: price.promptUsdPerMillion },
|
|
1146
|
+
...price.completionUsdPerMillion !== undefined && {
|
|
1147
|
+
completion: price.completionUsdPerMillion
|
|
1148
|
+
},
|
|
1149
|
+
...price.requestUsd !== undefined && { request: price.requestUsd },
|
|
1150
|
+
...price.imageUsd !== undefined && { image: price.imageUsd }
|
|
1151
|
+
};
|
|
1152
|
+
const provider = routing || maxPrice && Object.keys(maxPrice).length > 0 ? {
|
|
1153
|
+
...routing,
|
|
1154
|
+
...maxPrice && Object.keys(maxPrice).length > 0 && { max_price: maxPrice }
|
|
1155
|
+
} : undefined;
|
|
1156
|
+
return {
|
|
1157
|
+
...provider && Object.keys(provider).length > 0 && { provider },
|
|
1158
|
+
...policy.reasoning && {
|
|
1159
|
+
reasoning: {
|
|
1160
|
+
...policy.reasoning.effort !== undefined && { effort: policy.reasoning.effort },
|
|
1161
|
+
...policy.reasoning.maxTokens !== undefined && {
|
|
1162
|
+
max_tokens: policy.reasoning.maxTokens
|
|
1163
|
+
},
|
|
1164
|
+
...policy.reasoning.enabled !== undefined && { enabled: policy.reasoning.enabled },
|
|
1165
|
+
...policy.reasoning.exclude !== undefined && { exclude: policy.reasoning.exclude }
|
|
1166
|
+
}
|
|
1167
|
+
},
|
|
1168
|
+
...policy.sessionId !== undefined && { sessionId: policy.sessionId },
|
|
1169
|
+
looseTools: policy.looseTools === true,
|
|
1170
|
+
...policy.cacheControl !== undefined && { cacheControl: policy.cacheControl }
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
function mergeOpenRouterStepPolicy(base, providerOptions) {
|
|
1174
|
+
const reqOr = recordField(providerOptions, "openrouter");
|
|
1175
|
+
if (!reqOr || Object.keys(reqOr).length === 0) {
|
|
1176
|
+
return {
|
|
1177
|
+
...base.provider !== undefined && { provider: base.provider },
|
|
1178
|
+
...base.reasoning !== undefined && { reasoning: base.reasoning },
|
|
1179
|
+
...base.sessionId !== undefined && { baseSessionId: base.sessionId },
|
|
1180
|
+
looseTools: base.looseTools,
|
|
1181
|
+
...base.cacheControl !== undefined && { baseCacheControl: base.cacheControl }
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
let stepExtraBody;
|
|
1185
|
+
const policyInput = {};
|
|
1186
|
+
for (const [key, value] of Object.entries(reqOr)) {
|
|
1187
|
+
if (key === "extraBody") {
|
|
1188
|
+
if (value !== undefined) {
|
|
1189
|
+
if (!isRecord(value)) {
|
|
1190
|
+
throw new TypeError("openRouterProvider: providerOptions.openrouter.extraBody must be a plain object");
|
|
1191
|
+
}
|
|
1192
|
+
assertNoExtraBodyClash("openRouterProvider", value, OPENROUTER_POLICY_KEYS);
|
|
1193
|
+
stepExtraBody = value;
|
|
1194
|
+
}
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
policyInput[key] = value;
|
|
1198
|
+
}
|
|
1199
|
+
const parsedStep = OpenRouterRequestPolicySchema.parse(policyInput);
|
|
1200
|
+
const stepWire = resolveOpenRouterWirePolicy(parsedStep);
|
|
1201
|
+
let mergedProvider;
|
|
1202
|
+
if (base.provider || stepWire.provider) {
|
|
1203
|
+
const baseProvider = stepWire.sessionId !== undefined && base.provider ? Object.fromEntries(Object.entries(base.provider).filter(([k]) => k !== "order")) : base.provider;
|
|
1204
|
+
const baseMaxPrice = isRecord(baseProvider?.max_price) ? baseProvider.max_price : null;
|
|
1205
|
+
const stepMaxPrice = isRecord(stepWire.provider?.max_price) ? stepWire.provider.max_price : null;
|
|
1206
|
+
const combined = {
|
|
1207
|
+
...baseProvider,
|
|
1208
|
+
...stepWire.provider,
|
|
1209
|
+
...baseMaxPrice && stepMaxPrice && { max_price: { ...baseMaxPrice, ...stepMaxPrice } }
|
|
1210
|
+
};
|
|
1211
|
+
if (Object.keys(combined).length > 0)
|
|
1212
|
+
mergedProvider = combined;
|
|
1213
|
+
}
|
|
1214
|
+
return {
|
|
1215
|
+
...mergedProvider !== undefined && { provider: mergedProvider },
|
|
1216
|
+
...(stepWire.reasoning ?? base.reasoning) !== undefined && {
|
|
1217
|
+
reasoning: stepWire.reasoning ?? base.reasoning
|
|
1218
|
+
},
|
|
1219
|
+
...stepWire.sessionId !== undefined && { stepSessionId: stepWire.sessionId },
|
|
1220
|
+
...base.sessionId !== undefined && { baseSessionId: base.sessionId },
|
|
1221
|
+
looseTools: parsedStep.looseTools !== undefined ? stepWire.looseTools : base.looseTools,
|
|
1222
|
+
...stepWire.cacheControl !== undefined && {
|
|
1223
|
+
explicitCacheControl: stepWire.cacheControl
|
|
1224
|
+
},
|
|
1225
|
+
...base.cacheControl !== undefined && { baseCacheControl: base.cacheControl },
|
|
1226
|
+
...stepExtraBody !== undefined && { stepExtraBody }
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// src/agent-runtime/providers/openrouter-route.ts
|
|
1231
|
+
import { createHash } from "node:crypto";
|
|
1232
|
+
import { z as z4 } from "zod";
|
|
1233
|
+
var OpenRouterRoutePinSchema = z4.discriminatedUnion("kind", [
|
|
1234
|
+
z4.strictObject({ kind: z4.literal("session-sticky"), sessionId: z4.string().min(1).max(256) }),
|
|
1235
|
+
z4.strictObject({ kind: z4.literal("provider-order"), provider: z4.string().min(1).max(128) })
|
|
1236
|
+
]);
|
|
1237
|
+
function createMemoryOpenRouterRouteStore(options = {}) {
|
|
1238
|
+
const maxEntries = options.maxEntries ?? 1e4;
|
|
1239
|
+
const ttlMs = options.ttlMs ?? 6 * 60 * 60 * 1000;
|
|
1240
|
+
assertPositiveSafeInteger("maxEntries", maxEntries);
|
|
1241
|
+
assertPositiveSafeInteger("ttlMs", ttlMs);
|
|
1242
|
+
const now = options.now ?? Date.now;
|
|
1243
|
+
const pins = new Map;
|
|
1244
|
+
return {
|
|
1245
|
+
async get(key) {
|
|
1246
|
+
const entry = pins.get(key);
|
|
1247
|
+
if (!entry)
|
|
1248
|
+
return;
|
|
1249
|
+
pins.delete(key);
|
|
1250
|
+
if (entry.expiresAt <= now())
|
|
1251
|
+
return;
|
|
1252
|
+
pins.set(key, entry);
|
|
1253
|
+
return entry.pin;
|
|
1254
|
+
},
|
|
1255
|
+
async set(key, pin) {
|
|
1256
|
+
pins.delete(key);
|
|
1257
|
+
while (pins.size >= maxEntries) {
|
|
1258
|
+
const oldest = pins.keys().next().value;
|
|
1259
|
+
if (oldest === undefined)
|
|
1260
|
+
break;
|
|
1261
|
+
pins.delete(oldest);
|
|
1262
|
+
}
|
|
1263
|
+
pins.set(key, { pin: OpenRouterRoutePinSchema.parse(pin), expiresAt: now() + ttlMs });
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
function openRouterSessionKey(key) {
|
|
1268
|
+
return key.length <= 256 ? key : createHash("sha256").update(key).digest("hex");
|
|
1269
|
+
}
|
|
1270
|
+
function createOpenRouterRouteResolver(options) {
|
|
894
1271
|
const { store, strategy } = options;
|
|
895
1272
|
return {
|
|
896
1273
|
async policyFor(key, rawBase = {}) {
|
|
@@ -925,7 +1302,7 @@ function createOpenRouterRouteResolver(options) {
|
|
|
925
1302
|
};
|
|
926
1303
|
}
|
|
927
1304
|
|
|
928
|
-
// src/agent-runtime/provider-openai-chat-helpers.ts
|
|
1305
|
+
// src/agent-runtime/providers/provider-openai-chat-helpers.ts
|
|
929
1306
|
var AUDIO_FORMAT_ALIASES = {
|
|
930
1307
|
"audio/wave": "wav",
|
|
931
1308
|
"audio/x-wav": "wav",
|
|
@@ -1104,7 +1481,7 @@ function* decodeChatMediaAndSources(delta, onOutput) {
|
|
|
1104
1481
|
}
|
|
1105
1482
|
}
|
|
1106
1483
|
|
|
1107
|
-
// src/agent-runtime/provider-openai-chat.ts
|
|
1484
|
+
// src/agent-runtime/providers/provider-openai-chat.ts
|
|
1108
1485
|
class EncodeContext {
|
|
1109
1486
|
hooks;
|
|
1110
1487
|
planned = [];
|
|
@@ -1396,7 +1773,7 @@ function buildOpenAiChatRequestBody(input) {
|
|
|
1396
1773
|
return body;
|
|
1397
1774
|
}
|
|
1398
1775
|
|
|
1399
|
-
// src/agent-runtime/provider-openai-chat-sse.ts
|
|
1776
|
+
// src/agent-runtime/providers/provider-openai-chat-sse.ts
|
|
1400
1777
|
var MAX_TOOL_CALLS = 256;
|
|
1401
1778
|
|
|
1402
1779
|
class DecodeState {
|
|
@@ -1645,7 +2022,7 @@ function finishPart(s, finishReason, ur, env) {
|
|
|
1645
2022
|
};
|
|
1646
2023
|
}
|
|
1647
2024
|
function* flushState(s, opts) {
|
|
1648
|
-
if (!s.sawDone && !s.
|
|
2025
|
+
if (!s.sawDone && !s.sawError && (!s.sawFinish || s.rawUsage === undefined)) {
|
|
1649
2026
|
throw new AgentProviderStreamCutError2(`${opts.provider} SSE stream ended before completion`, { provider: opts.provider });
|
|
1650
2027
|
}
|
|
1651
2028
|
const meta = s.explicitUsageMeta ?? { [opts.provider]: { usage: s.rawUsage } };
|
|
@@ -1752,8 +2129,7 @@ async function* decodeOpenAiChatJsonResponse(body, options) {
|
|
|
1752
2129
|
yield* flushState(state, options);
|
|
1753
2130
|
}
|
|
1754
2131
|
|
|
1755
|
-
// src/agent-runtime/openrouter.ts
|
|
1756
|
-
var DEFAULT_OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
2132
|
+
// src/agent-runtime/providers/openrouter.ts
|
|
1757
2133
|
var EMPTY_WIRE_POLICY = { looseTools: false };
|
|
1758
2134
|
function catalogJson(fetcher, url, apiKey, signal) {
|
|
1759
2135
|
return openRouterJson({
|
|
@@ -1771,17 +2147,21 @@ function openRouterModelCatalog(options = {}) {
|
|
|
1771
2147
|
const timeoutMs = options.timeoutMs ?? 1e4;
|
|
1772
2148
|
assertTimerMs("timeoutMs", timeoutMs);
|
|
1773
2149
|
assertValidStaticOpenRouterApiKey(options.apiKey);
|
|
2150
|
+
validateOpenRouterBaseUrl(options.baseUrl);
|
|
1774
2151
|
return {
|
|
1775
2152
|
async load(input = {}) {
|
|
1776
|
-
const modelsUrl =
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
artificialUrl.
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
designUrl.
|
|
2153
|
+
const modelsUrl = resolveOpenRouterUrl(options.baseUrl, "/models", {
|
|
2154
|
+
supported_parameters: "tools",
|
|
2155
|
+
output_modalities: "text",
|
|
2156
|
+
sort: "top-weekly"
|
|
2157
|
+
});
|
|
2158
|
+
const artificialUrl = resolveOpenRouterUrl(options.baseUrl, "/benchmarks", {
|
|
2159
|
+
source: "artificial-analysis"
|
|
2160
|
+
});
|
|
2161
|
+
const designUrl = resolveOpenRouterUrl(options.baseUrl, "/benchmarks", {
|
|
2162
|
+
source: "design-arena",
|
|
2163
|
+
arena: "agents"
|
|
2164
|
+
});
|
|
1785
2165
|
const [modelsRaw, artificialResult, designResult] = await withOpenRouterTimeout(timeoutMs, input.signal, (signal) => Promise.all([
|
|
1786
2166
|
catalogJson(fetcher, modelsUrl, options.apiKey, signal),
|
|
1787
2167
|
benchmarkOutcome(fetcher, artificialUrl, options.apiKey, signal),
|
|
@@ -1839,16 +2219,6 @@ function openRouterModelCatalog(options = {}) {
|
|
|
1839
2219
|
}
|
|
1840
2220
|
};
|
|
1841
2221
|
}
|
|
1842
|
-
function buildBaseHeaders(settings, apiKey) {
|
|
1843
|
-
return {
|
|
1844
|
-
authorization: `Bearer ${apiKey}`,
|
|
1845
|
-
...settings.appUrl !== undefined && { "HTTP-Referer": settings.appUrl },
|
|
1846
|
-
...settings.appName !== undefined && { "X-OpenRouter-Title": settings.appName },
|
|
1847
|
-
...settings.providerApiKeys !== undefined && {
|
|
1848
|
-
"X-Provider-API-Keys": JSON.stringify(settings.providerApiKeys)
|
|
1849
|
-
}
|
|
1850
|
-
};
|
|
1851
|
-
}
|
|
1852
2222
|
function buildOpenRouterRequestBody(input) {
|
|
1853
2223
|
const { modelId, request, policy, sessionPerConversation, extraBody } = input;
|
|
1854
2224
|
const merged = mergeOpenRouterStepPolicy(policy, request.providerOptions);
|
|
@@ -1888,7 +2258,7 @@ function buildOpenRouterRequestBody(input) {
|
|
|
1888
2258
|
function openRouterProvider(settings, access = {}) {
|
|
1889
2259
|
assertNoExtraBodyClash("openRouterProvider", settings.extraBody, OPENROUTER_POLICY_KEYS);
|
|
1890
2260
|
const defaultPolicy = access.defaultPolicy !== undefined ? resolveOpenRouterWirePolicy(access.defaultPolicy) : EMPTY_WIRE_POLICY;
|
|
1891
|
-
const endpoint = joinProviderUrl(settings.baseUrl ??
|
|
2261
|
+
const endpoint = joinProviderUrl(settings.baseUrl ?? OPENROUTER_API_BASE_URL, "/chat/completions");
|
|
1892
2262
|
const policyOf = (modelId) => {
|
|
1893
2263
|
const resolved = access.resolvePolicy?.(modelId);
|
|
1894
2264
|
return resolved !== undefined ? resolveOpenRouterWirePolicy(resolved) : defaultPolicy;
|
|
@@ -1911,7 +2281,7 @@ function openRouterProvider(settings, access = {}) {
|
|
|
1911
2281
|
const response = await postProviderStream({
|
|
1912
2282
|
provider: "openrouter",
|
|
1913
2283
|
url: endpoint,
|
|
1914
|
-
headers:
|
|
2284
|
+
headers: buildOpenRouterBaseHeaders(settings, apiKey),
|
|
1915
2285
|
...settings.headers !== undefined && { extraHeaders: settings.headers },
|
|
1916
2286
|
...request.headers !== undefined && { requestHeaders: request.headers },
|
|
1917
2287
|
body,
|
|
@@ -1933,10 +2303,10 @@ function openRouterProvider(settings, access = {}) {
|
|
|
1933
2303
|
}
|
|
1934
2304
|
};
|
|
1935
2305
|
}
|
|
1936
|
-
// src/agent-runtime/openrouter-admission.ts
|
|
2306
|
+
// src/agent-runtime/providers/openrouter-admission.ts
|
|
1937
2307
|
import { z as z7 } from "zod";
|
|
1938
2308
|
|
|
1939
|
-
// src/agent-runtime/openrouter-catalog.ts
|
|
2309
|
+
// src/agent-runtime/providers/openrouter-catalog.ts
|
|
1940
2310
|
import { z as z5 } from "zod";
|
|
1941
2311
|
var Price = z5.number().nonnegative();
|
|
1942
2312
|
var NonNegativeMetric = z5.number().nonnegative();
|
|
@@ -2076,7 +2446,8 @@ function mapSnapshotModel(model, endpoints) {
|
|
|
2076
2446
|
}
|
|
2077
2447
|
async function fetchOpenRouterModelEndpoints(modelId, options = {}) {
|
|
2078
2448
|
assertValidStaticOpenRouterApiKey(options.apiKey);
|
|
2079
|
-
|
|
2449
|
+
validateOpenRouterBaseUrl(options.baseUrl);
|
|
2450
|
+
const url = openRouterEndpointsUrl(modelId, options.baseUrl);
|
|
2080
2451
|
const parsed = OpenRouterEndpointsResponseSchema.parse(await withOpenRouterTimeout(options.timeoutMs ?? 1e4, options.signal, (signal) => openRouterJson({
|
|
2081
2452
|
fetcher: options.fetcher ?? fetch,
|
|
2082
2453
|
url,
|
|
@@ -2119,11 +2490,12 @@ async function loadOpenRouterCatalogSnapshot(options = {}) {
|
|
|
2119
2490
|
if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 16)
|
|
2120
2491
|
throw new RangeError("concurrency must be an integer from 1 to 16");
|
|
2121
2492
|
assertValidStaticOpenRouterApiKey(options.apiKey);
|
|
2493
|
+
validateOpenRouterBaseUrl(options.baseUrl);
|
|
2122
2494
|
assertValidOpenRouterEndpointsFor(options.endpointsFor);
|
|
2123
2495
|
const observedAt = (options.now?.() ?? new Date).toISOString();
|
|
2124
2496
|
const listing = OpenRouterModelsResponseSchema.parse(await withOpenRouterTimeout(options.timeoutMs ?? 1e4, options.signal, (signal) => openRouterJson({
|
|
2125
2497
|
fetcher: options.fetcher ?? fetch,
|
|
2126
|
-
url:
|
|
2498
|
+
url: resolveOpenRouterUrl(options.baseUrl, "/models"),
|
|
2127
2499
|
...options.apiKey !== undefined && { apiKey: options.apiKey },
|
|
2128
2500
|
signal,
|
|
2129
2501
|
...options.maxResponseBytes !== undefined && { maxBytes: options.maxResponseBytes }
|
|
@@ -2159,7 +2531,7 @@ async function loadOpenRouterCatalogSnapshot(options = {}) {
|
|
|
2159
2531
|
});
|
|
2160
2532
|
}
|
|
2161
2533
|
|
|
2162
|
-
// src/agent-runtime/openrouter-catalog-query.ts
|
|
2534
|
+
// src/agent-runtime/providers/openrouter-catalog-query.ts
|
|
2163
2535
|
import { z as z6 } from "zod";
|
|
2164
2536
|
var Price2 = z6.number().nonnegative();
|
|
2165
2537
|
var NonNegativeMetric2 = z6.number().nonnegative();
|
|
@@ -2167,6 +2539,7 @@ var Percentage2 = z6.number().min(0).max(100);
|
|
|
2167
2539
|
var OpenRouterModelPricingCeilingSchema = z6.strictObject({
|
|
2168
2540
|
promptUsdPerMillion: Price2.optional(),
|
|
2169
2541
|
completionUsdPerMillion: Price2.optional(),
|
|
2542
|
+
cacheWriteUsdPerMillion: Price2.optional(),
|
|
2170
2543
|
requestUsd: Price2.optional()
|
|
2171
2544
|
});
|
|
2172
2545
|
var OpenRouterEndpointSummarySchema = z6.strictObject({
|
|
@@ -2205,43 +2578,38 @@ function summarizeOpenRouterEndpoints(endpoints) {
|
|
|
2205
2578
|
...uptime1d !== undefined && { uptime1d }
|
|
2206
2579
|
};
|
|
2207
2580
|
}
|
|
2208
|
-
function
|
|
2581
|
+
function collectUnknownPricingFields(model) {
|
|
2582
|
+
const unknown = new Set(model.unknownPricingFields ?? []);
|
|
2583
|
+
for (const tier of model.pricingTiers ?? []) {
|
|
2584
|
+
for (const field of tier.unknownPricingFields ?? [])
|
|
2585
|
+
unknown.add(field);
|
|
2586
|
+
}
|
|
2587
|
+
return unknown;
|
|
2588
|
+
}
|
|
2589
|
+
function hasOpaqueConditionalPricing(model) {
|
|
2209
2590
|
if (model.hasUnverifiedPricingOverrides === true)
|
|
2210
|
-
return
|
|
2591
|
+
return true;
|
|
2211
2592
|
const tiers = model.pricingTiers ?? [];
|
|
2212
2593
|
const conditionalCeiling = model.conditionalPricingCeiling;
|
|
2213
2594
|
const conditional = model.hasConditionalPricing === true || tiers.length > 0 || conditionalCeiling !== undefined;
|
|
2214
|
-
|
|
2595
|
+
return conditional && tiers.length === 0 && conditionalCeiling === undefined;
|
|
2596
|
+
}
|
|
2597
|
+
function resolveOpenRouterModelCeiling(model) {
|
|
2598
|
+
if (hasOpaqueConditionalPricing(model))
|
|
2215
2599
|
return {};
|
|
2216
|
-
const
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
unknown.add(field);
|
|
2220
|
-
}
|
|
2600
|
+
const tiers = model.pricingTiers ?? [];
|
|
2601
|
+
const conditionalCeiling = model.conditionalPricingCeiling;
|
|
2602
|
+
const unknown = collectUnknownPricingFields(model);
|
|
2221
2603
|
let promptCeiling;
|
|
2222
|
-
if (model.promptUsdPerMillion !== undefined && !unknown.has("prompt")
|
|
2223
|
-
let current =
|
|
2604
|
+
if (model.promptUsdPerMillion !== undefined && !unknown.has("prompt")) {
|
|
2605
|
+
let current = model.promptUsdPerMillion;
|
|
2224
2606
|
for (const tier of tiers) {
|
|
2225
2607
|
if (tier.promptUsdPerMillion !== undefined) {
|
|
2226
2608
|
current = Math.max(current, tier.promptUsdPerMillion);
|
|
2227
2609
|
}
|
|
2228
|
-
if (tier.cacheWriteUsdPerMillion !== undefined) {
|
|
2229
|
-
current = Math.max(current, tier.cacheWriteUsdPerMillion);
|
|
2230
|
-
}
|
|
2231
|
-
if (tier.cacheWrite1hUsdPerMillion !== undefined) {
|
|
2232
|
-
current = Math.max(current, tier.cacheWrite1hUsdPerMillion);
|
|
2233
|
-
}
|
|
2234
2610
|
}
|
|
2235
|
-
if (conditionalCeiling !== undefined) {
|
|
2236
|
-
|
|
2237
|
-
current = Math.max(current, conditionalCeiling.promptUsdPerMillion);
|
|
2238
|
-
}
|
|
2239
|
-
if (conditionalCeiling.cacheWriteUsdPerMillion !== undefined) {
|
|
2240
|
-
current = Math.max(current, conditionalCeiling.cacheWriteUsdPerMillion);
|
|
2241
|
-
}
|
|
2242
|
-
if (conditionalCeiling.cacheWrite1hUsdPerMillion !== undefined) {
|
|
2243
|
-
current = Math.max(current, conditionalCeiling.cacheWrite1hUsdPerMillion);
|
|
2244
|
-
}
|
|
2611
|
+
if (conditionalCeiling?.promptUsdPerMillion !== undefined) {
|
|
2612
|
+
current = Math.max(current, conditionalCeiling.promptUsdPerMillion);
|
|
2245
2613
|
}
|
|
2246
2614
|
promptCeiling = current;
|
|
2247
2615
|
}
|
|
@@ -2256,26 +2624,140 @@ function resolveOpenRouterModelCeiling(model) {
|
|
|
2256
2624
|
if (conditionalCeiling?.completionUsdPerMillion !== undefined) {
|
|
2257
2625
|
current = Math.max(current, conditionalCeiling.completionUsdPerMillion);
|
|
2258
2626
|
}
|
|
2259
|
-
completionCeiling = current;
|
|
2260
|
-
}
|
|
2261
|
-
let
|
|
2262
|
-
if (!unknown.has("
|
|
2263
|
-
let current
|
|
2264
|
-
|
|
2265
|
-
if (
|
|
2266
|
-
current = current === undefined ?
|
|
2627
|
+
completionCeiling = current;
|
|
2628
|
+
}
|
|
2629
|
+
let cacheWriteCeiling;
|
|
2630
|
+
if (!unknown.has("cacheWrite") && !unknown.has("cacheWrite1h")) {
|
|
2631
|
+
let current;
|
|
2632
|
+
const include = (value) => {
|
|
2633
|
+
if (value !== undefined) {
|
|
2634
|
+
current = current === undefined ? value : Math.max(current, value);
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
include(model.cacheWriteUsdPerMillion);
|
|
2638
|
+
include(model.cacheWrite1hUsdPerMillion);
|
|
2639
|
+
for (const tier of tiers) {
|
|
2640
|
+
include(tier.cacheWriteUsdPerMillion);
|
|
2641
|
+
include(tier.cacheWrite1hUsdPerMillion);
|
|
2642
|
+
}
|
|
2643
|
+
include(conditionalCeiling?.cacheWriteUsdPerMillion);
|
|
2644
|
+
include(conditionalCeiling?.cacheWrite1hUsdPerMillion);
|
|
2645
|
+
cacheWriteCeiling = current;
|
|
2646
|
+
}
|
|
2647
|
+
let requestCeiling;
|
|
2648
|
+
if (!unknown.has("request")) {
|
|
2649
|
+
let current = model.requestUsd;
|
|
2650
|
+
for (const tier of tiers) {
|
|
2651
|
+
if (tier.requestUsd !== undefined) {
|
|
2652
|
+
current = current === undefined ? tier.requestUsd : Math.max(current, tier.requestUsd);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (conditionalCeiling?.requestUsd !== undefined) {
|
|
2656
|
+
current = current === undefined ? conditionalCeiling.requestUsd : Math.max(current, conditionalCeiling.requestUsd);
|
|
2657
|
+
}
|
|
2658
|
+
requestCeiling = current;
|
|
2659
|
+
}
|
|
2660
|
+
return {
|
|
2661
|
+
...promptCeiling !== undefined && { promptUsdPerMillion: promptCeiling },
|
|
2662
|
+
...completionCeiling !== undefined && { completionUsdPerMillion: completionCeiling },
|
|
2663
|
+
...cacheWriteCeiling !== undefined && { cacheWriteUsdPerMillion: cacheWriteCeiling },
|
|
2664
|
+
...requestCeiling !== undefined && { requestUsd: requestCeiling }
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
function highestObservedPrice(model, side) {
|
|
2668
|
+
let best;
|
|
2669
|
+
const consider = (value, label) => {
|
|
2670
|
+
if (value === undefined)
|
|
2671
|
+
return;
|
|
2672
|
+
if (best === undefined || value > best.price) {
|
|
2673
|
+
best = { price: value, label };
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
if (side === "prompt") {
|
|
2677
|
+
consider(model.promptUsdPerMillion, "prompt");
|
|
2678
|
+
for (const tier of model.pricingTiers ?? []) {
|
|
2679
|
+
consider(tier.promptUsdPerMillion, "prompt");
|
|
2680
|
+
}
|
|
2681
|
+
consider(model.conditionalPricingCeiling?.promptUsdPerMillion, "prompt");
|
|
2682
|
+
} else if (side === "completion") {
|
|
2683
|
+
consider(model.completionUsdPerMillion, "completion");
|
|
2684
|
+
for (const tier of model.pricingTiers ?? []) {
|
|
2685
|
+
consider(tier.completionUsdPerMillion, "completion");
|
|
2686
|
+
}
|
|
2687
|
+
consider(model.conditionalPricingCeiling?.completionUsdPerMillion, "completion");
|
|
2688
|
+
} else {
|
|
2689
|
+
consider(model.cacheWriteUsdPerMillion, "cache-write");
|
|
2690
|
+
consider(model.cacheWrite1hUsdPerMillion, "cache-write-1h");
|
|
2691
|
+
for (const tier of model.pricingTiers ?? []) {
|
|
2692
|
+
consider(tier.cacheWriteUsdPerMillion, "cache-write");
|
|
2693
|
+
consider(tier.cacheWrite1hUsdPerMillion, "cache-write-1h");
|
|
2694
|
+
}
|
|
2695
|
+
consider(model.conditionalPricingCeiling?.cacheWriteUsdPerMillion, "cache-write");
|
|
2696
|
+
consider(model.conditionalPricingCeiling?.cacheWrite1hUsdPerMillion, "cache-write-1h");
|
|
2697
|
+
}
|
|
2698
|
+
return best;
|
|
2699
|
+
}
|
|
2700
|
+
function evaluateOpenRouterPriceLimits(model, limits) {
|
|
2701
|
+
const ceiling = resolveOpenRouterModelCeiling(model);
|
|
2702
|
+
const unknownFields = collectUnknownPricingFields(model);
|
|
2703
|
+
const opaqueConditional = hasOpaqueConditionalPricing(model);
|
|
2704
|
+
let unknown;
|
|
2705
|
+
const checks = [
|
|
2706
|
+
[limits.maxPromptUsdPerMillion, "prompt"],
|
|
2707
|
+
[limits.maxCompletionUsdPerMillion, "completion"],
|
|
2708
|
+
[limits.maxCacheWriteUsdPerMillion, "cache-write"]
|
|
2709
|
+
];
|
|
2710
|
+
for (const [limit, side] of checks) {
|
|
2711
|
+
if (limit === undefined)
|
|
2712
|
+
continue;
|
|
2713
|
+
const observed = highestObservedPrice(model, side);
|
|
2714
|
+
if (observed !== undefined && observed.price > limit) {
|
|
2715
|
+
return {
|
|
2716
|
+
state: "rejected",
|
|
2717
|
+
reason: "over-price",
|
|
2718
|
+
detail: `the ${observed.label} price ${observed.price} USD per million exceeds ${limit}`
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
if (side === "cache-write") {
|
|
2722
|
+
if (opaqueConditional || unknownFields.has("cacheWrite") || unknownFields.has("cacheWrite1h")) {
|
|
2723
|
+
unknown ??= {
|
|
2724
|
+
state: "unverified",
|
|
2725
|
+
reason: "price-unknown",
|
|
2726
|
+
detail: "the cache-write price ceiling is not stated"
|
|
2727
|
+
};
|
|
2728
|
+
} else if (ceiling.cacheWriteUsdPerMillion !== undefined) {
|
|
2729
|
+
if (ceiling.cacheWriteUsdPerMillion > limit) {
|
|
2730
|
+
return {
|
|
2731
|
+
state: "rejected",
|
|
2732
|
+
reason: "over-price",
|
|
2733
|
+
detail: `the ${observed?.label ?? "cache-write"} price ${ceiling.cacheWriteUsdPerMillion} USD per million exceeds ${limit}`
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2736
|
+
} else if (ceiling.promptUsdPerMillion === undefined) {
|
|
2737
|
+
unknown ??= {
|
|
2738
|
+
state: "unverified",
|
|
2739
|
+
reason: "price-unknown",
|
|
2740
|
+
detail: "the cache-write price ceiling is not stated"
|
|
2741
|
+
};
|
|
2267
2742
|
}
|
|
2743
|
+
continue;
|
|
2268
2744
|
}
|
|
2269
|
-
|
|
2270
|
-
|
|
2745
|
+
const ceilingPrice = side === "prompt" ? ceiling.promptUsdPerMillion : ceiling.completionUsdPerMillion;
|
|
2746
|
+
if (ceilingPrice === undefined) {
|
|
2747
|
+
unknown ??= {
|
|
2748
|
+
state: "unverified",
|
|
2749
|
+
reason: "price-unknown",
|
|
2750
|
+
detail: `the ${side} price ceiling is not stated`
|
|
2751
|
+
};
|
|
2752
|
+
} else if (ceilingPrice > limit) {
|
|
2753
|
+
return {
|
|
2754
|
+
state: "rejected",
|
|
2755
|
+
reason: "over-price",
|
|
2756
|
+
detail: `the ${side} price ${ceilingPrice} USD per million exceeds ${limit}`
|
|
2757
|
+
};
|
|
2271
2758
|
}
|
|
2272
|
-
requestCeiling = current;
|
|
2273
2759
|
}
|
|
2274
|
-
return {
|
|
2275
|
-
...promptCeiling !== undefined && { promptUsdPerMillion: promptCeiling },
|
|
2276
|
-
...completionCeiling !== undefined && { completionUsdPerMillion: completionCeiling },
|
|
2277
|
-
...requestCeiling !== undefined && { requestUsd: requestCeiling }
|
|
2278
|
-
};
|
|
2760
|
+
return unknown ?? { state: "ok" };
|
|
2279
2761
|
}
|
|
2280
2762
|
function hasNonZeroRate(rates) {
|
|
2281
2763
|
return (rates.promptUsdPerMillion ?? 0) > 0 || (rates.completionUsdPerMillion ?? 0) > 0 || (rates.cacheReadUsdPerMillion ?? 0) > 0 || (rates.cacheWriteUsdPerMillion ?? 0) > 0 || (rates.cacheWrite1hUsdPerMillion ?? 0) > 0 || (rates.requestUsd ?? 0) > 0 || (rates.imageUsd ?? 0) > 0;
|
|
@@ -2303,7 +2785,7 @@ function isFreeModel(model) {
|
|
|
2303
2785
|
if (conditionalCeiling !== undefined && hasNonZeroRate(conditionalCeiling))
|
|
2304
2786
|
return false;
|
|
2305
2787
|
const ceiling = resolveOpenRouterModelCeiling(model);
|
|
2306
|
-
return ceiling.promptUsdPerMillion === 0 && ceiling.completionUsdPerMillion === 0 && (ceiling.requestUsd ?? 0) === 0;
|
|
2788
|
+
return ceiling.promptUsdPerMillion === 0 && ceiling.completionUsdPerMillion === 0 && (ceiling.cacheWriteUsdPerMillion ?? 0) === 0 && (ceiling.requestUsd ?? 0) === 0;
|
|
2307
2789
|
}
|
|
2308
2790
|
function validateOpenRouterModelFilter(filter) {
|
|
2309
2791
|
if (!filter)
|
|
@@ -2311,7 +2793,8 @@ function validateOpenRouterModelFilter(filter) {
|
|
|
2311
2793
|
const checks = [
|
|
2312
2794
|
["minContextLength", filter.minContextLength],
|
|
2313
2795
|
["maxPromptUsdPerMillion", filter.maxPromptUsdPerMillion],
|
|
2314
|
-
["maxCompletionUsdPerMillion", filter.maxCompletionUsdPerMillion]
|
|
2796
|
+
["maxCompletionUsdPerMillion", filter.maxCompletionUsdPerMillion],
|
|
2797
|
+
["maxCacheWriteUsdPerMillion", filter.maxCacheWriteUsdPerMillion]
|
|
2315
2798
|
];
|
|
2316
2799
|
for (const [name, value] of checks) {
|
|
2317
2800
|
if (value === undefined)
|
|
@@ -2343,11 +2826,9 @@ function matchesFilter(model, filter) {
|
|
|
2343
2826
|
if (contextLength === undefined || !(contextLength >= filter.minContextLength))
|
|
2344
2827
|
return false;
|
|
2345
2828
|
}
|
|
2346
|
-
if (filter.maxPromptUsdPerMillion !== undefined
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
if (filter.maxCompletionUsdPerMillion !== undefined && (model.completionUsdPerMillion === undefined || !(model.completionUsdPerMillion <= filter.maxCompletionUsdPerMillion))) {
|
|
2350
|
-
return false;
|
|
2829
|
+
if (filter.maxPromptUsdPerMillion !== undefined || filter.maxCompletionUsdPerMillion !== undefined || filter.maxCacheWriteUsdPerMillion !== undefined) {
|
|
2830
|
+
if (evaluateOpenRouterPriceLimits(model, filter).state !== "ok")
|
|
2831
|
+
return false;
|
|
2351
2832
|
}
|
|
2352
2833
|
if (filter.freeOnly === true && !isFreeModel(model))
|
|
2353
2834
|
return false;
|
|
@@ -2369,7 +2850,7 @@ function listOpenRouterModels(snapshot, filter) {
|
|
|
2369
2850
|
return snapshot.models.filter((model) => matchesFilter(model, filter));
|
|
2370
2851
|
}
|
|
2371
2852
|
|
|
2372
|
-
// src/agent-runtime/openrouter-admission.ts
|
|
2853
|
+
// src/agent-runtime/providers/openrouter-admission.ts
|
|
2373
2854
|
var Usd2 = z7.number().nonnegative();
|
|
2374
2855
|
var OpenRouterAdmissionPolicySchema = z7.strictObject({
|
|
2375
2856
|
maxSnapshotAgeMs: z7.int().positive(),
|
|
@@ -2378,6 +2859,7 @@ var OpenRouterAdmissionPolicySchema = z7.strictObject({
|
|
|
2378
2859
|
minContextLength: z7.int().nonnegative().optional(),
|
|
2379
2860
|
maxPromptUsdPerMillion: Usd2.optional(),
|
|
2380
2861
|
maxCompletionUsdPerMillion: Usd2.optional(),
|
|
2862
|
+
maxCacheWriteUsdPerMillion: Usd2.optional(),
|
|
2381
2863
|
requireLiveEndpoint: z7.boolean().default(false)
|
|
2382
2864
|
});
|
|
2383
2865
|
var OpenRouterAdmissionReasonSchema = z7.enum([
|
|
@@ -2419,65 +2901,9 @@ function floatingAlias(modelId) {
|
|
|
2419
2901
|
return "a `stealth/` model has no stated identity";
|
|
2420
2902
|
return;
|
|
2421
2903
|
}
|
|
2422
|
-
function highestObservedPrice(model, side) {
|
|
2423
|
-
const values = [];
|
|
2424
|
-
const add = (value) => {
|
|
2425
|
-
if (value !== undefined)
|
|
2426
|
-
values.push(value);
|
|
2427
|
-
};
|
|
2428
|
-
if (side === "prompt") {
|
|
2429
|
-
add(model.promptUsdPerMillion);
|
|
2430
|
-
add(model.cacheWriteUsdPerMillion);
|
|
2431
|
-
add(model.cacheWrite1hUsdPerMillion);
|
|
2432
|
-
for (const tier of model.pricingTiers ?? []) {
|
|
2433
|
-
add(tier.promptUsdPerMillion);
|
|
2434
|
-
add(tier.cacheWriteUsdPerMillion);
|
|
2435
|
-
add(tier.cacheWrite1hUsdPerMillion);
|
|
2436
|
-
}
|
|
2437
|
-
add(model.conditionalPricingCeiling?.promptUsdPerMillion);
|
|
2438
|
-
add(model.conditionalPricingCeiling?.cacheWriteUsdPerMillion);
|
|
2439
|
-
add(model.conditionalPricingCeiling?.cacheWrite1hUsdPerMillion);
|
|
2440
|
-
} else {
|
|
2441
|
-
add(model.completionUsdPerMillion);
|
|
2442
|
-
for (const tier of model.pricingTiers ?? [])
|
|
2443
|
-
add(tier.completionUsdPerMillion);
|
|
2444
|
-
add(model.conditionalPricingCeiling?.completionUsdPerMillion);
|
|
2445
|
-
}
|
|
2446
|
-
return values.length > 0 ? Math.max(...values) : undefined;
|
|
2447
|
-
}
|
|
2448
2904
|
function priceCheck(model, policy) {
|
|
2449
|
-
const
|
|
2450
|
-
|
|
2451
|
-
const checks = [
|
|
2452
|
-
[policy.maxPromptUsdPerMillion, ceiling.promptUsdPerMillion, "prompt"],
|
|
2453
|
-
[policy.maxCompletionUsdPerMillion, ceiling.completionUsdPerMillion, "completion"]
|
|
2454
|
-
];
|
|
2455
|
-
for (const [limit, ceilingPrice, side] of checks) {
|
|
2456
|
-
if (limit === undefined)
|
|
2457
|
-
continue;
|
|
2458
|
-
const observed = highestObservedPrice(model, side);
|
|
2459
|
-
if (observed !== undefined && observed > limit) {
|
|
2460
|
-
return {
|
|
2461
|
-
state: "rejected",
|
|
2462
|
-
reason: "over-price",
|
|
2463
|
-
detail: `the ${side} price ${observed} USD per million exceeds ${limit}`
|
|
2464
|
-
};
|
|
2465
|
-
}
|
|
2466
|
-
if (ceilingPrice === undefined) {
|
|
2467
|
-
unknown ??= {
|
|
2468
|
-
state: "unverified",
|
|
2469
|
-
reason: "price-unknown",
|
|
2470
|
-
detail: `the ${side} price ceiling is not stated`
|
|
2471
|
-
};
|
|
2472
|
-
} else if (ceilingPrice > limit) {
|
|
2473
|
-
return {
|
|
2474
|
-
state: "rejected",
|
|
2475
|
-
reason: "over-price",
|
|
2476
|
-
detail: `the ${side} price ${ceilingPrice} USD per million exceeds ${limit}`
|
|
2477
|
-
};
|
|
2478
|
-
}
|
|
2479
|
-
}
|
|
2480
|
-
return unknown;
|
|
2905
|
+
const outcome = evaluateOpenRouterPriceLimits(model, policy);
|
|
2906
|
+
return outcome.state === "ok" ? undefined : outcome;
|
|
2481
2907
|
}
|
|
2482
2908
|
function evaluateOpenRouterModelAdmission(input) {
|
|
2483
2909
|
const alias = floatingAlias(input.modelId);
|
|
@@ -2555,7 +2981,369 @@ function evaluateOpenRouterModelAdmission(input) {
|
|
|
2555
2981
|
}
|
|
2556
2982
|
return { state: "admitted" };
|
|
2557
2983
|
}
|
|
2558
|
-
// src/agent-runtime/openrouter-
|
|
2984
|
+
// src/agent-runtime/providers/openrouter-audio.ts
|
|
2985
|
+
import { z as z8 } from "zod";
|
|
2986
|
+
|
|
2987
|
+
// src/agent-runtime/providers/openrouter-stream.ts
|
|
2988
|
+
function wrapStreamWithCallerAbort(source, callerSignal, onRelease) {
|
|
2989
|
+
if (!callerSignal) {
|
|
2990
|
+
onRelease();
|
|
2991
|
+
return source;
|
|
2992
|
+
}
|
|
2993
|
+
const reader = source.getReader();
|
|
2994
|
+
let settled = false;
|
|
2995
|
+
const detach = () => {
|
|
2996
|
+
if (settled)
|
|
2997
|
+
return;
|
|
2998
|
+
settled = true;
|
|
2999
|
+
callerSignal.removeEventListener("abort", onAbort);
|
|
3000
|
+
onRelease();
|
|
3001
|
+
};
|
|
3002
|
+
const onAbort = () => {
|
|
3003
|
+
detach();
|
|
3004
|
+
reader.cancel(abortReason(callerSignal)).catch(() => {
|
|
3005
|
+
return;
|
|
3006
|
+
});
|
|
3007
|
+
};
|
|
3008
|
+
if (callerSignal.aborted) {
|
|
3009
|
+
onAbort();
|
|
3010
|
+
} else {
|
|
3011
|
+
callerSignal.addEventListener("abort", onAbort, { once: true });
|
|
3012
|
+
reader.closed.then(detach, detach);
|
|
3013
|
+
}
|
|
3014
|
+
return new ReadableStream({
|
|
3015
|
+
async pull(controller) {
|
|
3016
|
+
if (callerSignal.aborted) {
|
|
3017
|
+
detach();
|
|
3018
|
+
await reader.cancel(abortReason(callerSignal)).catch(() => {
|
|
3019
|
+
return;
|
|
3020
|
+
});
|
|
3021
|
+
controller.error(abortReason(callerSignal));
|
|
3022
|
+
return;
|
|
3023
|
+
}
|
|
3024
|
+
try {
|
|
3025
|
+
const chunk = await raceAbort(reader.read(), callerSignal);
|
|
3026
|
+
if (chunk.done) {
|
|
3027
|
+
detach();
|
|
3028
|
+
reader.releaseLock();
|
|
3029
|
+
controller.close();
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
3032
|
+
controller.enqueue(chunk.value);
|
|
3033
|
+
} catch (error) {
|
|
3034
|
+
detach();
|
|
3035
|
+
await reader.cancel(error).catch(() => {
|
|
3036
|
+
return;
|
|
3037
|
+
});
|
|
3038
|
+
controller.error(error);
|
|
3039
|
+
}
|
|
3040
|
+
},
|
|
3041
|
+
async cancel(reason) {
|
|
3042
|
+
detach();
|
|
3043
|
+
await reader.cancel(reason).catch(() => {
|
|
3044
|
+
return;
|
|
3045
|
+
});
|
|
3046
|
+
}
|
|
3047
|
+
});
|
|
3048
|
+
}
|
|
3049
|
+
async function openRouterRequestStream(input) {
|
|
3050
|
+
const prepared = prepareOpenRouterRequest(input);
|
|
3051
|
+
input.signal?.throwIfAborted();
|
|
3052
|
+
const apiKey = await resolveOptionalOpenRouterApiKey2(input.apiKey);
|
|
3053
|
+
input.signal?.throwIfAborted();
|
|
3054
|
+
const deadline = new AbortController;
|
|
3055
|
+
const timer = setTimeout(() => deadline.abort(abortError(`OpenRouter stream ${input.path} timed out after ${prepared.timeoutMs} ms`, "TimeoutError")), prepared.timeoutMs);
|
|
3056
|
+
const openLink = linkAbortSignals(input.signal, deadline.signal);
|
|
3057
|
+
const disarmOpenPhase = () => {
|
|
3058
|
+
clearTimeout(timer);
|
|
3059
|
+
openLink.release();
|
|
3060
|
+
};
|
|
3061
|
+
let response;
|
|
3062
|
+
try {
|
|
3063
|
+
const headers = assembleOpenRouterRequestHeaders(input, prepared, apiKey, undefined);
|
|
3064
|
+
response = await raceAbort(prepared.fetcher(prepared.url, {
|
|
3065
|
+
method: prepared.method,
|
|
3066
|
+
headers,
|
|
3067
|
+
...prepared.serializedBody !== undefined && { body: prepared.serializedBody },
|
|
3068
|
+
redirect: "error",
|
|
3069
|
+
signal: openLink.signal
|
|
3070
|
+
}), openLink.signal, (late) => {
|
|
3071
|
+
late.body?.cancel(abortReason(openLink.signal)).catch(() => {
|
|
3072
|
+
return;
|
|
3073
|
+
});
|
|
3074
|
+
});
|
|
3075
|
+
if (openLink.signal.aborted) {
|
|
3076
|
+
await response.body?.cancel(abortReason(openLink.signal)).catch(() => {
|
|
3077
|
+
return;
|
|
3078
|
+
});
|
|
3079
|
+
openLink.signal.throwIfAborted();
|
|
3080
|
+
}
|
|
3081
|
+
await assertNotRedirectedResponse(response);
|
|
3082
|
+
if (!response.ok) {
|
|
3083
|
+
throw await buildProviderHttpError({
|
|
3084
|
+
provider: "openrouter",
|
|
3085
|
+
response,
|
|
3086
|
+
signal: openLink.signal,
|
|
3087
|
+
parseError: parseOpenRouterError,
|
|
3088
|
+
maxErrorBytes: prepared.maxErrorBytes
|
|
3089
|
+
});
|
|
3090
|
+
}
|
|
3091
|
+
} catch (error) {
|
|
3092
|
+
disarmOpenPhase();
|
|
3093
|
+
throw error;
|
|
3094
|
+
}
|
|
3095
|
+
clearTimeout(timer);
|
|
3096
|
+
const requestId = extractProviderRequestId(response.headers);
|
|
3097
|
+
const responseHeaders = headersToRecord(response.headers);
|
|
3098
|
+
if (!response.body) {
|
|
3099
|
+
openLink.release();
|
|
3100
|
+
throw new AgentProviderError2("OpenRouter returned an empty streaming response body", {
|
|
3101
|
+
provider: "openrouter",
|
|
3102
|
+
statusCode: response.status,
|
|
3103
|
+
retryable: false,
|
|
3104
|
+
...requestId !== undefined && { requestId },
|
|
3105
|
+
responseHeaders
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
const generationId = extractOpenRouterGenerationId(response.headers);
|
|
3109
|
+
const contentType = response.headers.get("content-type")?.trim() || "application/octet-stream";
|
|
3110
|
+
return {
|
|
3111
|
+
body: wrapStreamWithCallerAbort(response.body, input.signal, openLink.release),
|
|
3112
|
+
contentType,
|
|
3113
|
+
status: response.status,
|
|
3114
|
+
...generationId !== undefined && { generationId },
|
|
3115
|
+
...requestId !== undefined && { requestId },
|
|
3116
|
+
headers: responseHeaders
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// src/agent-runtime/providers/openrouter-audio.ts
|
|
3121
|
+
var STT_OWNED_KEYS = [
|
|
3122
|
+
"model",
|
|
3123
|
+
"file",
|
|
3124
|
+
"input_audio",
|
|
3125
|
+
"source_url",
|
|
3126
|
+
"language",
|
|
3127
|
+
"prompt",
|
|
3128
|
+
"temperature",
|
|
3129
|
+
"response_format",
|
|
3130
|
+
"timestamp_granularities",
|
|
3131
|
+
"timestamp_granularities[]",
|
|
3132
|
+
"diarize",
|
|
3133
|
+
"provider"
|
|
3134
|
+
];
|
|
3135
|
+
var TTS_OWNED_KEYS = [
|
|
3136
|
+
"model",
|
|
3137
|
+
"input",
|
|
3138
|
+
"voice",
|
|
3139
|
+
"response_format",
|
|
3140
|
+
"speed",
|
|
3141
|
+
"output_delivery",
|
|
3142
|
+
"provider"
|
|
3143
|
+
];
|
|
3144
|
+
var NonNegativeNum = z8.number().nonnegative();
|
|
3145
|
+
var NonNegativeInt = z8.int().nonnegative();
|
|
3146
|
+
var TranscriptionSegmentSchema = z8.object({
|
|
3147
|
+
id: z8.int().nonnegative().optional(),
|
|
3148
|
+
start: NonNegativeNum,
|
|
3149
|
+
end: NonNegativeNum,
|
|
3150
|
+
text: z8.string(),
|
|
3151
|
+
speaker: z8.string().optional()
|
|
3152
|
+
}).loose();
|
|
3153
|
+
var TranscriptionWordSchema = z8.object({
|
|
3154
|
+
word: z8.string(),
|
|
3155
|
+
start: NonNegativeNum,
|
|
3156
|
+
end: NonNegativeNum,
|
|
3157
|
+
speaker: z8.string().optional()
|
|
3158
|
+
}).loose();
|
|
3159
|
+
var TranscriptionUsageSchema = z8.object({
|
|
3160
|
+
seconds: NonNegativeNum.optional(),
|
|
3161
|
+
total_tokens: NonNegativeInt.optional(),
|
|
3162
|
+
input_tokens: NonNegativeInt.optional(),
|
|
3163
|
+
output_tokens: NonNegativeInt.optional(),
|
|
3164
|
+
prompt_tokens: NonNegativeInt.optional(),
|
|
3165
|
+
completion_tokens: NonNegativeInt.optional(),
|
|
3166
|
+
cost: NonNegativeNum.optional()
|
|
3167
|
+
}).loose();
|
|
3168
|
+
var OpenRouterAudioTranscriptionResponseSchema = z8.object({
|
|
3169
|
+
text: z8.string(),
|
|
3170
|
+
task: z8.string().optional(),
|
|
3171
|
+
language: z8.string().optional(),
|
|
3172
|
+
duration: NonNegativeNum.optional(),
|
|
3173
|
+
segments: z8.array(TranscriptionSegmentSchema).optional(),
|
|
3174
|
+
words: z8.array(TranscriptionWordSchema).optional(),
|
|
3175
|
+
usage: TranscriptionUsageSchema.optional()
|
|
3176
|
+
}).loose();
|
|
3177
|
+
function toSafeBlob(data, mimeType) {
|
|
3178
|
+
if (data instanceof Blob) {
|
|
3179
|
+
return mimeType !== undefined && data.type !== mimeType ? new Blob([data], { type: mimeType }) : data;
|
|
3180
|
+
}
|
|
3181
|
+
const source = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
3182
|
+
const copy = new Uint8Array(source.byteLength);
|
|
3183
|
+
copy.set(source);
|
|
3184
|
+
return mimeType !== undefined ? new Blob([copy], { type: mimeType }) : new Blob([copy]);
|
|
3185
|
+
}
|
|
3186
|
+
function hasUnsafeFilenameChar(value) {
|
|
3187
|
+
for (let i = 0;i < value.length; i += 1) {
|
|
3188
|
+
const code = value.charCodeAt(i);
|
|
3189
|
+
const ch = value[i];
|
|
3190
|
+
if (code < 32 || code === 127 || ch === '"' || ch === "\\" || ch === "/")
|
|
3191
|
+
return true;
|
|
3192
|
+
}
|
|
3193
|
+
return false;
|
|
3194
|
+
}
|
|
3195
|
+
function validateFilename(filename) {
|
|
3196
|
+
const trimmed = filename.trim();
|
|
3197
|
+
if (trimmed.length === 0 || hasUnsafeFilenameChar(trimmed)) {
|
|
3198
|
+
throw new TypeError("openRouterAudioTranscription: filename must be non-empty and free of path separators, quotes, or control characters");
|
|
3199
|
+
}
|
|
3200
|
+
return trimmed;
|
|
3201
|
+
}
|
|
3202
|
+
function appendFormExtraBody(form, extraBody) {
|
|
3203
|
+
for (const [key, value] of Object.entries(extraBody)) {
|
|
3204
|
+
if (value === undefined)
|
|
3205
|
+
continue;
|
|
3206
|
+
if (value === null || typeof value === "function" || typeof value === "symbol") {
|
|
3207
|
+
throw new TypeError(`openRouterAudioTranscription: unsupported multipart extraBody value for "${key}"`);
|
|
3208
|
+
}
|
|
3209
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
3210
|
+
throw new TypeError(`openRouterAudioTranscription: extraBody["${key}"] must be a finite number`);
|
|
3211
|
+
}
|
|
3212
|
+
if (value instanceof Blob) {
|
|
3213
|
+
form.append(key, value);
|
|
3214
|
+
} else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
3215
|
+
form.append(key, String(value));
|
|
3216
|
+
} else if (Array.isArray(value) || isRecord(value)) {
|
|
3217
|
+
form.append(key, JSON.stringify(value));
|
|
3218
|
+
} else {
|
|
3219
|
+
throw new TypeError(`openRouterAudioTranscription: unsupported multipart extraBody value for "${key}"`);
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
function buildTranscriptionBody(input, model, provider) {
|
|
3224
|
+
if (input.audio.kind === "file") {
|
|
3225
|
+
const form = new FormData;
|
|
3226
|
+
const defaultName = typeof File === "function" && input.audio.data instanceof File && input.audio.data.name ? input.audio.data.name : "audio";
|
|
3227
|
+
const filename = validateFilename(input.audio.filename ?? defaultName);
|
|
3228
|
+
form.append("file", toSafeBlob(input.audio.data, input.audio.mimeType), filename);
|
|
3229
|
+
form.append("model", model);
|
|
3230
|
+
if (input.language !== undefined)
|
|
3231
|
+
form.append("language", input.language);
|
|
3232
|
+
if (input.prompt !== undefined)
|
|
3233
|
+
form.append("prompt", input.prompt);
|
|
3234
|
+
if (input.temperature !== undefined)
|
|
3235
|
+
form.append("temperature", String(input.temperature));
|
|
3236
|
+
if (input.responseFormat !== undefined)
|
|
3237
|
+
form.append("response_format", input.responseFormat);
|
|
3238
|
+
if (input.timestampGranularities !== undefined) {
|
|
3239
|
+
for (const granularity of input.timestampGranularities) {
|
|
3240
|
+
form.append("timestamp_granularities[]", granularity);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
if (input.diarize !== undefined)
|
|
3244
|
+
form.append("diarize", String(input.diarize));
|
|
3245
|
+
if (provider !== undefined)
|
|
3246
|
+
form.append("provider", JSON.stringify(provider));
|
|
3247
|
+
if (input.extraBody !== undefined)
|
|
3248
|
+
appendFormExtraBody(form, input.extraBody);
|
|
3249
|
+
return form;
|
|
3250
|
+
}
|
|
3251
|
+
const audioFields = input.audio.kind === "base64" ? {
|
|
3252
|
+
input_audio: {
|
|
3253
|
+
data: input.audio.data,
|
|
3254
|
+
format: input.audio.format
|
|
3255
|
+
}
|
|
3256
|
+
} : { source_url: assertOpenRouterHttpUrl("audio.url", input.audio.url) };
|
|
3257
|
+
return {
|
|
3258
|
+
...input.extraBody ?? {},
|
|
3259
|
+
model,
|
|
3260
|
+
...audioFields,
|
|
3261
|
+
...input.language !== undefined && { language: input.language },
|
|
3262
|
+
...input.prompt !== undefined && { prompt: input.prompt },
|
|
3263
|
+
...input.temperature !== undefined && { temperature: input.temperature },
|
|
3264
|
+
...input.responseFormat !== undefined && { response_format: input.responseFormat },
|
|
3265
|
+
...input.timestampGranularities !== undefined && {
|
|
3266
|
+
timestamp_granularities: [...input.timestampGranularities]
|
|
3267
|
+
},
|
|
3268
|
+
...input.diarize !== undefined && { diarize: input.diarize },
|
|
3269
|
+
...provider !== undefined && { provider }
|
|
3270
|
+
};
|
|
3271
|
+
}
|
|
3272
|
+
async function openRouterAudioTranscription(input) {
|
|
3273
|
+
assertOpenRouterDirectAuth(input);
|
|
3274
|
+
const model = assertNonEmptyOpenRouterField("openRouterAudioTranscription", "model", input.model);
|
|
3275
|
+
if (input.audio.kind === "base64") {
|
|
3276
|
+
if (input.audio.data.trim().length === 0 || input.audio.format.trim().length === 0) {
|
|
3277
|
+
throw new TypeError("openRouterAudioTranscription: base64 audio requires non-empty data and format");
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
if (input.temperature !== undefined && (!Number.isFinite(input.temperature) || input.temperature < 0 || input.temperature > 1)) {
|
|
3281
|
+
throw new RangeError("openRouterAudioTranscription: temperature must be between 0 and 1");
|
|
3282
|
+
}
|
|
3283
|
+
if (input.diarize === true && input.responseFormat !== "verbose_json") {
|
|
3284
|
+
throw new TypeError('openRouterAudioTranscription: diarize requires responseFormat: "verbose_json"');
|
|
3285
|
+
}
|
|
3286
|
+
assertNoExtraBodyClash("openRouterAudioTranscription", input.extraBody, STT_OWNED_KEYS);
|
|
3287
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3288
|
+
const body = buildTranscriptionBody(input, model, provider);
|
|
3289
|
+
const response = await openRouterRequestJson({
|
|
3290
|
+
...pickOpenRouterTransport(input),
|
|
3291
|
+
path: "/audio/transcriptions",
|
|
3292
|
+
method: "POST",
|
|
3293
|
+
body,
|
|
3294
|
+
schema: OpenRouterAudioTranscriptionResponseSchema
|
|
3295
|
+
});
|
|
3296
|
+
return {
|
|
3297
|
+
text: response.data.text,
|
|
3298
|
+
...response.data.task !== undefined && { task: response.data.task },
|
|
3299
|
+
...response.data.language !== undefined && { language: response.data.language },
|
|
3300
|
+
...response.data.duration !== undefined && { duration: response.data.duration },
|
|
3301
|
+
...response.data.segments !== undefined && { segments: response.data.segments },
|
|
3302
|
+
...response.data.words !== undefined && { words: response.data.words },
|
|
3303
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
3304
|
+
raw: response.data,
|
|
3305
|
+
status: response.status,
|
|
3306
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3307
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3308
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3309
|
+
headers: response.headers
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
async function openRouterAudioSpeech(input) {
|
|
3313
|
+
assertOpenRouterDirectAuth(input);
|
|
3314
|
+
const model = assertNonEmptyOpenRouterField("openRouterAudioSpeech", "model", input.model);
|
|
3315
|
+
assertNonEmptyOpenRouterField("openRouterAudioSpeech", "input", input.input);
|
|
3316
|
+
const voice = assertNonEmptyOpenRouterField("openRouterAudioSpeech", "voice", input.voice);
|
|
3317
|
+
if (input.speed !== undefined && (!Number.isFinite(input.speed) || input.speed <= 0)) {
|
|
3318
|
+
throw new RangeError("openRouterAudioSpeech: speed must be a positive finite number");
|
|
3319
|
+
}
|
|
3320
|
+
assertNoExtraBodyClash("openRouterAudioSpeech", input.extraBody, TTS_OWNED_KEYS);
|
|
3321
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3322
|
+
const body = {
|
|
3323
|
+
...input.extraBody ?? {},
|
|
3324
|
+
model,
|
|
3325
|
+
input: input.input,
|
|
3326
|
+
voice,
|
|
3327
|
+
...input.responseFormat !== undefined && { response_format: input.responseFormat },
|
|
3328
|
+
...input.speed !== undefined && { speed: input.speed },
|
|
3329
|
+
...provider !== undefined && { provider }
|
|
3330
|
+
};
|
|
3331
|
+
const response = await openRouterRequestStream({
|
|
3332
|
+
...pickOpenRouterTransport(input),
|
|
3333
|
+
path: "/audio/speech",
|
|
3334
|
+
method: "POST",
|
|
3335
|
+
body
|
|
3336
|
+
});
|
|
3337
|
+
return {
|
|
3338
|
+
audio: response.body,
|
|
3339
|
+
contentType: response.contentType,
|
|
3340
|
+
status: response.status,
|
|
3341
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3342
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3343
|
+
headers: response.headers
|
|
3344
|
+
};
|
|
3345
|
+
}
|
|
3346
|
+
// src/agent-runtime/providers/openrouter-catalog-cache.ts
|
|
2559
3347
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
2560
3348
|
var DEFAULT_FRESH_MS = 15 * 60000;
|
|
2561
3349
|
var DEFAULT_RETRY_BACKOFF_MS = 60000;
|
|
@@ -2620,6 +3408,7 @@ function validateCacheOptions(options) {
|
|
|
2620
3408
|
assertPositiveSafeInteger("maxResponseBytes", options.maxResponseBytes, RangeError);
|
|
2621
3409
|
}
|
|
2622
3410
|
assertValidStaticOpenRouterApiKey(options.apiKey);
|
|
3411
|
+
validateOpenRouterBaseUrl(options.baseUrl);
|
|
2623
3412
|
assertValidOpenRouterEndpointsFor(options.endpointsFor);
|
|
2624
3413
|
return {
|
|
2625
3414
|
timeoutMs,
|
|
@@ -2791,36 +3580,381 @@ function createOpenRouterCatalogCache(options = {}) {
|
|
|
2791
3580
|
}
|
|
2792
3581
|
};
|
|
2793
3582
|
}
|
|
2794
|
-
// src/agent-runtime/openrouter-
|
|
2795
|
-
import { z as
|
|
3583
|
+
// src/agent-runtime/providers/openrouter-media.ts
|
|
3584
|
+
import { z as z9 } from "zod";
|
|
3585
|
+
var NonNegativeInt2 = z9.int().nonnegative();
|
|
3586
|
+
var NonNegativeNum2 = z9.number().nonnegative();
|
|
3587
|
+
var IMAGE_OWNED_KEYS = [
|
|
3588
|
+
"model",
|
|
3589
|
+
"prompt",
|
|
3590
|
+
"n",
|
|
3591
|
+
"aspect_ratio",
|
|
3592
|
+
"resolution",
|
|
3593
|
+
"response_format",
|
|
3594
|
+
"input_references",
|
|
3595
|
+
"provider"
|
|
3596
|
+
];
|
|
3597
|
+
var VIDEO_OWNED_KEYS = [
|
|
3598
|
+
"model",
|
|
3599
|
+
"prompt",
|
|
3600
|
+
"duration",
|
|
3601
|
+
"aspect_ratio",
|
|
3602
|
+
"resolution",
|
|
3603
|
+
"generate_audio",
|
|
3604
|
+
"frame_images",
|
|
3605
|
+
"input_references",
|
|
3606
|
+
"callback_url",
|
|
3607
|
+
"provider"
|
|
3608
|
+
];
|
|
3609
|
+
var ImageItemSchema = z9.object({
|
|
3610
|
+
b64_json: z9.string().optional(),
|
|
3611
|
+
url: z9.string().optional(),
|
|
3612
|
+
media_type: z9.string().optional()
|
|
3613
|
+
}).loose();
|
|
3614
|
+
var MediaUsageSchema = z9.object({
|
|
3615
|
+
prompt_tokens: NonNegativeInt2.optional(),
|
|
3616
|
+
completion_tokens: NonNegativeInt2.optional(),
|
|
3617
|
+
input_tokens: NonNegativeInt2.optional(),
|
|
3618
|
+
output_tokens: NonNegativeInt2.optional(),
|
|
3619
|
+
total_tokens: NonNegativeInt2.optional(),
|
|
3620
|
+
cost: NonNegativeNum2.optional(),
|
|
3621
|
+
is_byok: z9.boolean().optional()
|
|
3622
|
+
}).loose();
|
|
3623
|
+
var OpenRouterImageGenerationResponseSchema = z9.object({
|
|
3624
|
+
created: z9.int().nonnegative().optional(),
|
|
3625
|
+
data: z9.array(ImageItemSchema),
|
|
3626
|
+
expires_at: z9.int().nonnegative().optional(),
|
|
3627
|
+
usage: MediaUsageSchema.optional()
|
|
3628
|
+
}).loose();
|
|
3629
|
+
async function openRouterGenerateImages(input) {
|
|
3630
|
+
assertOpenRouterDirectAuth(input);
|
|
3631
|
+
const model = assertNonEmptyOpenRouterField("openRouterGenerateImages", "model", input.model);
|
|
3632
|
+
assertNonEmptyOpenRouterField("openRouterGenerateImages", "prompt", input.prompt);
|
|
3633
|
+
if (input.n !== undefined)
|
|
3634
|
+
assertPositiveSafeInteger("n", input.n);
|
|
3635
|
+
assertNoExtraBodyClash("openRouterGenerateImages", input.extraBody, IMAGE_OWNED_KEYS);
|
|
3636
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3637
|
+
const body = {
|
|
3638
|
+
...input.extraBody ?? {},
|
|
3639
|
+
model,
|
|
3640
|
+
prompt: input.prompt,
|
|
3641
|
+
...input.n !== undefined && { n: input.n },
|
|
3642
|
+
...input.aspectRatio !== undefined && { aspect_ratio: input.aspectRatio },
|
|
3643
|
+
...input.resolution !== undefined && { resolution: input.resolution },
|
|
3644
|
+
...input.responseFormat !== undefined && { response_format: input.responseFormat },
|
|
3645
|
+
...input.inputReferences !== undefined && {
|
|
3646
|
+
input_references: [...input.inputReferences]
|
|
3647
|
+
},
|
|
3648
|
+
...provider !== undefined && { provider }
|
|
3649
|
+
};
|
|
3650
|
+
const response = await openRouterRequestJson({
|
|
3651
|
+
...pickOpenRouterTransport(input),
|
|
3652
|
+
path: "/images",
|
|
3653
|
+
method: "POST",
|
|
3654
|
+
body,
|
|
3655
|
+
schema: OpenRouterImageGenerationResponseSchema
|
|
3656
|
+
});
|
|
3657
|
+
return {
|
|
3658
|
+
...response.data.created !== undefined && { created: response.data.created },
|
|
3659
|
+
images: response.data.data,
|
|
3660
|
+
...response.data.expires_at !== undefined && { expiresAt: response.data.expires_at },
|
|
3661
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
3662
|
+
raw: response.data,
|
|
3663
|
+
status: response.status,
|
|
3664
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3665
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3666
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3667
|
+
headers: response.headers
|
|
3668
|
+
};
|
|
3669
|
+
}
|
|
3670
|
+
var VideoSubmitResponseSchema = z9.object({
|
|
3671
|
+
id: z9.string().min(1),
|
|
3672
|
+
status: z9.string().min(1),
|
|
3673
|
+
polling_url: z9.string().min(1).optional()
|
|
3674
|
+
}).loose();
|
|
3675
|
+
var VideoStatusResponseSchema = z9.object({
|
|
3676
|
+
id: z9.string().min(1),
|
|
3677
|
+
status: z9.string().min(1),
|
|
3678
|
+
generation_id: z9.string().min(1).optional(),
|
|
3679
|
+
urls: z9.array(z9.string()).optional(),
|
|
3680
|
+
unsigned_urls: z9.array(z9.string()).optional(),
|
|
3681
|
+
expires_at: z9.int().nonnegative().optional(),
|
|
3682
|
+
usage: MediaUsageSchema.optional(),
|
|
3683
|
+
error: z9.unknown().optional()
|
|
3684
|
+
}).loose();
|
|
3685
|
+
async function openRouterSubmitVideo(input) {
|
|
3686
|
+
assertOpenRouterDirectAuth(input);
|
|
3687
|
+
const model = assertNonEmptyOpenRouterField("openRouterSubmitVideo", "model", input.model);
|
|
3688
|
+
assertNonEmptyOpenRouterField("openRouterSubmitVideo", "prompt", input.prompt);
|
|
3689
|
+
if (input.duration !== undefined && (!Number.isFinite(input.duration) || input.duration <= 0)) {
|
|
3690
|
+
throw new RangeError("openRouterSubmitVideo: duration must be a positive finite number");
|
|
3691
|
+
}
|
|
3692
|
+
const callbackUrl = input.callbackUrl !== undefined ? assertOpenRouterHttpUrl("callbackUrl", input.callbackUrl) : undefined;
|
|
3693
|
+
assertNoExtraBodyClash("openRouterSubmitVideo", input.extraBody, VIDEO_OWNED_KEYS);
|
|
3694
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3695
|
+
const body = {
|
|
3696
|
+
...input.extraBody ?? {},
|
|
3697
|
+
model,
|
|
3698
|
+
prompt: input.prompt,
|
|
3699
|
+
...input.duration !== undefined && { duration: input.duration },
|
|
3700
|
+
...input.aspectRatio !== undefined && { aspect_ratio: input.aspectRatio },
|
|
3701
|
+
...input.resolution !== undefined && { resolution: input.resolution },
|
|
3702
|
+
...input.generateAudio !== undefined && { generate_audio: input.generateAudio },
|
|
3703
|
+
...input.frameImages !== undefined && { frame_images: [...input.frameImages] },
|
|
3704
|
+
...input.inputReferences !== undefined && {
|
|
3705
|
+
input_references: [...input.inputReferences]
|
|
3706
|
+
},
|
|
3707
|
+
...callbackUrl !== undefined && { callback_url: callbackUrl },
|
|
3708
|
+
...provider !== undefined && { provider }
|
|
3709
|
+
};
|
|
3710
|
+
const response = await openRouterRequestJson({
|
|
3711
|
+
...pickOpenRouterTransport(input),
|
|
3712
|
+
path: "/videos",
|
|
3713
|
+
method: "POST",
|
|
3714
|
+
body,
|
|
3715
|
+
schema: VideoSubmitResponseSchema
|
|
3716
|
+
});
|
|
3717
|
+
return {
|
|
3718
|
+
id: response.data.id,
|
|
3719
|
+
jobStatus: response.data.status,
|
|
3720
|
+
...response.data.polling_url !== undefined && { pollingUrl: response.data.polling_url },
|
|
3721
|
+
raw: response.data,
|
|
3722
|
+
status: response.status,
|
|
3723
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3724
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3725
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3726
|
+
headers: response.headers
|
|
3727
|
+
};
|
|
3728
|
+
}
|
|
3729
|
+
async function openRouterGetVideo(input) {
|
|
3730
|
+
assertOpenRouterDirectAuth(input);
|
|
3731
|
+
const jobId = assertOpenRouterPathSegment("jobId", input.jobId);
|
|
3732
|
+
const response = await openRouterRequestJson({
|
|
3733
|
+
...pickOpenRouterTransport(input),
|
|
3734
|
+
path: `/videos/${encodeURIComponent(jobId)}`,
|
|
3735
|
+
method: "GET",
|
|
3736
|
+
schema: VideoStatusResponseSchema
|
|
3737
|
+
});
|
|
3738
|
+
return {
|
|
3739
|
+
id: response.data.id,
|
|
3740
|
+
jobStatus: response.data.status,
|
|
3741
|
+
...response.data.urls !== undefined && { urls: response.data.urls },
|
|
3742
|
+
...response.data.unsigned_urls !== undefined && {
|
|
3743
|
+
unsignedUrls: response.data.unsigned_urls
|
|
3744
|
+
},
|
|
3745
|
+
...response.data.expires_at !== undefined && { expiresAt: response.data.expires_at },
|
|
3746
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
3747
|
+
...response.data.error !== undefined && { error: response.data.error },
|
|
3748
|
+
raw: response.data,
|
|
3749
|
+
status: response.status,
|
|
3750
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3751
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3752
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3753
|
+
headers: response.headers
|
|
3754
|
+
};
|
|
3755
|
+
}
|
|
3756
|
+
async function openRouterDownloadVideo(input) {
|
|
3757
|
+
assertOpenRouterDirectAuth(input);
|
|
3758
|
+
const jobId = assertOpenRouterPathSegment("jobId", input.jobId);
|
|
3759
|
+
return openRouterRequestStream({
|
|
3760
|
+
...pickOpenRouterTransport(input),
|
|
3761
|
+
path: `/videos/${encodeURIComponent(jobId)}/content`,
|
|
3762
|
+
method: "GET"
|
|
3763
|
+
});
|
|
3764
|
+
}
|
|
3765
|
+
// src/agent-runtime/providers/openrouter-retrieval.ts
|
|
3766
|
+
import { z as z10 } from "zod";
|
|
3767
|
+
var NonNegativeInt3 = z10.int().nonnegative();
|
|
3768
|
+
var NonNegativeNum3 = z10.number().nonnegative();
|
|
3769
|
+
var EMBEDDINGS_OWNED_KEYS = [
|
|
3770
|
+
"model",
|
|
3771
|
+
"input",
|
|
3772
|
+
"encoding_format",
|
|
3773
|
+
"dimensions",
|
|
3774
|
+
"user",
|
|
3775
|
+
"provider"
|
|
3776
|
+
];
|
|
3777
|
+
var RERANK_OWNED_KEYS = ["model", "query", "documents", "top_n", "provider"];
|
|
3778
|
+
var RetrievalUsageSchema = z10.object({
|
|
3779
|
+
prompt_tokens: NonNegativeInt3.optional(),
|
|
3780
|
+
completion_tokens: NonNegativeInt3.optional(),
|
|
3781
|
+
input_tokens: NonNegativeInt3.optional(),
|
|
3782
|
+
output_tokens: NonNegativeInt3.optional(),
|
|
3783
|
+
total_tokens: NonNegativeInt3.optional(),
|
|
3784
|
+
cost: NonNegativeNum3.optional(),
|
|
3785
|
+
is_byok: z10.boolean().optional()
|
|
3786
|
+
}).loose();
|
|
3787
|
+
var EmbeddingDatumSchema = z10.object({
|
|
3788
|
+
index: NonNegativeInt3,
|
|
3789
|
+
embedding: z10.union([z10.array(z10.number()), z10.string()])
|
|
3790
|
+
}).loose();
|
|
3791
|
+
var EmbeddingsResponseSchema = z10.object({
|
|
3792
|
+
model: z10.string().min(1).optional(),
|
|
3793
|
+
data: z10.array(EmbeddingDatumSchema),
|
|
3794
|
+
usage: RetrievalUsageSchema.optional()
|
|
3795
|
+
}).loose();
|
|
3796
|
+
async function openRouterEmbeddings(input) {
|
|
3797
|
+
assertOpenRouterDirectAuth(input);
|
|
3798
|
+
const model = assertNonEmptyOpenRouterField("openRouterEmbeddings", "model", input.model);
|
|
3799
|
+
if (Array.isArray(input.input) && input.input.length === 0) {
|
|
3800
|
+
throw new TypeError("openRouterEmbeddings: input array must not be empty");
|
|
3801
|
+
}
|
|
3802
|
+
if (input.dimensions !== undefined)
|
|
3803
|
+
assertPositiveSafeInteger("dimensions", input.dimensions);
|
|
3804
|
+
assertNoExtraBodyClash("openRouterEmbeddings", input.extraBody, EMBEDDINGS_OWNED_KEYS);
|
|
3805
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3806
|
+
const body = {
|
|
3807
|
+
...input.extraBody ?? {},
|
|
3808
|
+
model,
|
|
3809
|
+
input: Array.isArray(input.input) ? [...input.input] : input.input,
|
|
3810
|
+
...input.encodingFormat !== undefined && { encoding_format: input.encodingFormat },
|
|
3811
|
+
...input.dimensions !== undefined && { dimensions: input.dimensions },
|
|
3812
|
+
...input.user !== undefined && { user: input.user },
|
|
3813
|
+
...provider !== undefined && { provider }
|
|
3814
|
+
};
|
|
3815
|
+
const response = await openRouterRequestJson({
|
|
3816
|
+
...pickOpenRouterTransport(input),
|
|
3817
|
+
path: "/embeddings",
|
|
3818
|
+
method: "POST",
|
|
3819
|
+
body,
|
|
3820
|
+
schema: EmbeddingsResponseSchema
|
|
3821
|
+
});
|
|
3822
|
+
return {
|
|
3823
|
+
...response.data.model !== undefined && { model: response.data.model },
|
|
3824
|
+
data: response.data.data,
|
|
3825
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
3826
|
+
raw: response.data,
|
|
3827
|
+
status: response.status,
|
|
3828
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3829
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3830
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3831
|
+
headers: response.headers
|
|
3832
|
+
};
|
|
3833
|
+
}
|
|
3834
|
+
var RerankResultItemSchema = z10.object({
|
|
3835
|
+
index: NonNegativeInt3,
|
|
3836
|
+
relevance_score: z10.number().finite(),
|
|
3837
|
+
document: z10.object({ text: z10.string() }).loose().optional()
|
|
3838
|
+
}).loose();
|
|
3839
|
+
var RerankResponseSchema = z10.object({
|
|
3840
|
+
results: z10.array(RerankResultItemSchema),
|
|
3841
|
+
meta: z10.record(z10.string(), z10.unknown()).optional(),
|
|
3842
|
+
usage: RetrievalUsageSchema.optional()
|
|
3843
|
+
}).loose();
|
|
3844
|
+
async function openRouterRerank(input) {
|
|
3845
|
+
assertOpenRouterDirectAuth(input);
|
|
3846
|
+
const model = assertNonEmptyOpenRouterField("openRouterRerank", "model", input.model);
|
|
3847
|
+
assertNonEmptyOpenRouterField("openRouterRerank", "query", input.query);
|
|
3848
|
+
if (input.documents.length === 0) {
|
|
3849
|
+
throw new TypeError("openRouterRerank: documents must be a non-empty array");
|
|
3850
|
+
}
|
|
3851
|
+
if (input.topN !== undefined)
|
|
3852
|
+
assertPositiveSafeInteger("topN", input.topN);
|
|
3853
|
+
assertNoExtraBodyClash("openRouterRerank", input.extraBody, RERANK_OWNED_KEYS);
|
|
3854
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
3855
|
+
const body = {
|
|
3856
|
+
...input.extraBody ?? {},
|
|
3857
|
+
model,
|
|
3858
|
+
query: input.query,
|
|
3859
|
+
documents: [...input.documents],
|
|
3860
|
+
...input.topN !== undefined && { top_n: input.topN },
|
|
3861
|
+
...provider !== undefined && { provider }
|
|
3862
|
+
};
|
|
3863
|
+
const response = await openRouterRequestJson({
|
|
3864
|
+
...pickOpenRouterTransport(input),
|
|
3865
|
+
path: "/rerank",
|
|
3866
|
+
method: "POST",
|
|
3867
|
+
body,
|
|
3868
|
+
schema: RerankResponseSchema
|
|
3869
|
+
});
|
|
3870
|
+
return {
|
|
3871
|
+
results: response.data.results.map((item) => ({
|
|
3872
|
+
index: item.index,
|
|
3873
|
+
relevanceScore: item.relevance_score,
|
|
3874
|
+
...item.document !== undefined && { document: item.document }
|
|
3875
|
+
})),
|
|
3876
|
+
...response.data.meta !== undefined && { meta: response.data.meta },
|
|
3877
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
3878
|
+
raw: response.data,
|
|
3879
|
+
status: response.status,
|
|
3880
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
3881
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
3882
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
3883
|
+
headers: response.headers
|
|
3884
|
+
};
|
|
3885
|
+
}
|
|
3886
|
+
// src/agent-runtime/providers/openrouter-spend.ts
|
|
3887
|
+
import { z as z11 } from "zod";
|
|
3888
|
+
var Count = z11.int().nonnegative();
|
|
3889
|
+
var NonNegativeFinite = z11.number().nonnegative();
|
|
3890
|
+
function readOptional(schema, value) {
|
|
3891
|
+
if (value === undefined || value === null)
|
|
3892
|
+
return;
|
|
3893
|
+
const parsed = schema.safeParse(value);
|
|
3894
|
+
return parsed.success ? parsed.data : undefined;
|
|
3895
|
+
}
|
|
3896
|
+
var openRouterSpendFacts = {
|
|
3897
|
+
headers(headers) {
|
|
3898
|
+
const generationId = nonEmptyTrimmed(headers.get("x-generation-id"));
|
|
3899
|
+
return generationId !== undefined ? { providerRequestId: generationId } : {};
|
|
3900
|
+
},
|
|
3901
|
+
event(value) {
|
|
3902
|
+
const base = openAiCompatibleUsage2.event?.(value) ?? {};
|
|
3903
|
+
const { providerRequestId: rawId, ...restBase } = base;
|
|
3904
|
+
if (!isRecord(value))
|
|
3905
|
+
return restBase;
|
|
3906
|
+
const trimmedRawId = nonEmptyTrimmed(rawId);
|
|
3907
|
+
const generationId = nonEmptyTrimmed(typeof value.generation_id === "string" ? value.generation_id : undefined) ?? (trimmedRawId?.startsWith("gen-") ? trimmedRawId : undefined);
|
|
3908
|
+
const usage = isRecord(value.usage) ? value.usage : undefined;
|
|
3909
|
+
const inputDetails = usage && isRecord(usage.input_tokens_details) ? usage.input_tokens_details : undefined;
|
|
3910
|
+
const outputDetails = usage && isRecord(usage.output_tokens_details) ? usage.output_tokens_details : undefined;
|
|
3911
|
+
const inputTokens = restBase.inputTokens ?? readOptional(Count, usage?.input_tokens);
|
|
3912
|
+
const outputTokens = restBase.outputTokens ?? readOptional(Count, usage?.output_tokens);
|
|
3913
|
+
const cacheReadTokens = restBase.cacheReadTokens ?? readOptional(Count, inputDetails?.cached_tokens);
|
|
3914
|
+
const cacheWriteTokens = restBase.cacheWriteTokens ?? readOptional(Count, inputDetails?.cache_write_tokens);
|
|
3915
|
+
const reasoningTokens = restBase.reasoningTokens ?? readOptional(Count, outputDetails?.reasoning_tokens);
|
|
3916
|
+
const seconds = readOptional(NonNegativeFinite, usage?.seconds);
|
|
3917
|
+
return {
|
|
3918
|
+
...restBase,
|
|
3919
|
+
...generationId !== undefined && { providerRequestId: generationId },
|
|
3920
|
+
...inputTokens !== undefined && { inputTokens },
|
|
3921
|
+
...outputTokens !== undefined && { outputTokens },
|
|
3922
|
+
...cacheReadTokens !== undefined && { cacheReadTokens },
|
|
3923
|
+
...cacheWriteTokens !== undefined && { cacheWriteTokens },
|
|
3924
|
+
...reasoningTokens !== undefined && { reasoningTokens },
|
|
3925
|
+
...seconds !== undefined && { workUnit: "seconds", workAmount: seconds }
|
|
3926
|
+
};
|
|
3927
|
+
}
|
|
3928
|
+
};
|
|
2796
3929
|
function openRouterSpendProvider(options) {
|
|
3930
|
+
const origin = validateOpenRouterBaseUrl(options.baseUrl).origin;
|
|
2797
3931
|
return {
|
|
2798
3932
|
name: "openrouter",
|
|
2799
|
-
origin
|
|
3933
|
+
origin,
|
|
2800
3934
|
headers: async () => ({ authorization: `Bearer ${await options.apiKey()}` }),
|
|
2801
|
-
facts:
|
|
3935
|
+
facts: openRouterSpendFacts
|
|
2802
3936
|
};
|
|
2803
3937
|
}
|
|
2804
|
-
var GenerationSchema =
|
|
2805
|
-
data:
|
|
2806
|
-
total_cost:
|
|
2807
|
-
provider_name:
|
|
2808
|
-
model:
|
|
2809
|
-
native_tokens_prompt:
|
|
2810
|
-
native_tokens_completion:
|
|
2811
|
-
native_tokens_reasoning:
|
|
3938
|
+
var GenerationSchema = z11.object({
|
|
3939
|
+
data: z11.object({
|
|
3940
|
+
total_cost: z11.number().nonnegative().nullish(),
|
|
3941
|
+
provider_name: z11.string().min(1).nullish(),
|
|
3942
|
+
model: z11.string().min(1).nullish(),
|
|
3943
|
+
native_tokens_prompt: z11.int().nonnegative().nullish(),
|
|
3944
|
+
native_tokens_completion: z11.int().nonnegative().nullish(),
|
|
3945
|
+
native_tokens_reasoning: z11.int().nonnegative().nullish()
|
|
2812
3946
|
}).loose()
|
|
2813
3947
|
});
|
|
2814
3948
|
function createOpenRouterSpendReconciler(options) {
|
|
2815
3949
|
const fetcher = options.fetcher ?? fetch;
|
|
2816
3950
|
const timeoutMs = options.timeoutMs ?? 1e4;
|
|
2817
3951
|
assertTimerMs("timeoutMs", timeoutMs);
|
|
3952
|
+
validateOpenRouterBaseUrl(options.baseUrl);
|
|
2818
3953
|
return async (record) => {
|
|
2819
3954
|
const id = record.receipt?.facts.providerRequestId;
|
|
2820
3955
|
if (id === undefined)
|
|
2821
3956
|
return { costStatus: "unknown", failureCode: "no-generation-id" };
|
|
2822
|
-
const url =
|
|
2823
|
-
url.searchParams.set("id", id);
|
|
3957
|
+
const url = resolveOpenRouterUrl(options.baseUrl, "/generation", { id });
|
|
2824
3958
|
let body;
|
|
2825
3959
|
try {
|
|
2826
3960
|
const apiKey = typeof options.apiKey === "string" ? options.apiKey : await options.apiKey(record);
|
|
@@ -2848,13 +3982,124 @@ function createOpenRouterSpendReconciler(options) {
|
|
|
2848
3982
|
};
|
|
2849
3983
|
};
|
|
2850
3984
|
}
|
|
3985
|
+
// src/agent-runtime/providers/openrouter-systemone.ts
|
|
3986
|
+
import { z as z12 } from "zod";
|
|
3987
|
+
var SYSTEMONE_OWNED_KEYS = [
|
|
3988
|
+
"model",
|
|
3989
|
+
"state",
|
|
3990
|
+
"questions",
|
|
3991
|
+
"provider",
|
|
3992
|
+
"response_format"
|
|
3993
|
+
];
|
|
3994
|
+
var ProbabilitySchema = z12.number().min(0).max(1);
|
|
3995
|
+
var NonNegativeInt4 = z12.int().nonnegative();
|
|
3996
|
+
var NonNegativeNum4 = z12.number().nonnegative();
|
|
3997
|
+
var SystemOneNoulQuestionSchema = z12.strictObject({
|
|
3998
|
+
type: z12.literal("noul"),
|
|
3999
|
+
instructions: z12.string().min(1),
|
|
4000
|
+
criteria: z12.object({
|
|
4001
|
+
true: z12.string().nullable().optional(),
|
|
4002
|
+
false: z12.string().nullable().optional()
|
|
4003
|
+
}).loose().optional()
|
|
4004
|
+
});
|
|
4005
|
+
var SystemOneChoiceQuestionSchema = z12.strictObject({
|
|
4006
|
+
type: z12.literal("choice"),
|
|
4007
|
+
instructions: z12.string().min(1),
|
|
4008
|
+
criteria: z12.record(z12.string().min(1), z12.string().nullable()).refine((value) => Object.keys(value).length >= 2, {
|
|
4009
|
+
message: "System One choice question requires at least 2 criteria entries"
|
|
4010
|
+
})
|
|
4011
|
+
});
|
|
4012
|
+
var SystemOneScoreQuestionSchema = z12.strictObject({
|
|
4013
|
+
type: z12.literal("score"),
|
|
4014
|
+
instructions: z12.string().min(1),
|
|
4015
|
+
criteria: z12.array(z12.string().min(1)).min(2)
|
|
4016
|
+
});
|
|
4017
|
+
var SystemOneQuestionSchema = z12.discriminatedUnion("type", [
|
|
4018
|
+
SystemOneNoulQuestionSchema,
|
|
4019
|
+
SystemOneChoiceQuestionSchema,
|
|
4020
|
+
SystemOneScoreQuestionSchema
|
|
4021
|
+
]);
|
|
4022
|
+
var SystemOneNoulAnswerSchema = z12.object({
|
|
4023
|
+
type: z12.literal("noul"),
|
|
4024
|
+
noul: ProbabilitySchema
|
|
4025
|
+
}).loose();
|
|
4026
|
+
var SystemOneChoiceAnswerSchema = z12.object({
|
|
4027
|
+
type: z12.literal("choice"),
|
|
4028
|
+
choice: z12.string(),
|
|
4029
|
+
confidence: ProbabilitySchema.optional(),
|
|
4030
|
+
probabilities: z12.record(z12.string(), ProbabilitySchema).optional()
|
|
4031
|
+
}).loose();
|
|
4032
|
+
var SystemOneScoreAnswerSchema = z12.object({
|
|
4033
|
+
type: z12.literal("score"),
|
|
4034
|
+
score: z12.number().finite(),
|
|
4035
|
+
confidence: ProbabilitySchema.optional(),
|
|
4036
|
+
legend: z12.union([z12.array(z12.string()), z12.record(z12.string(), z12.string())]).optional(),
|
|
4037
|
+
probabilities: z12.record(z12.string(), ProbabilitySchema).optional()
|
|
4038
|
+
}).loose();
|
|
4039
|
+
var SystemOneAnswerSchema = z12.discriminatedUnion("type", [
|
|
4040
|
+
SystemOneNoulAnswerSchema,
|
|
4041
|
+
SystemOneChoiceAnswerSchema,
|
|
4042
|
+
SystemOneScoreAnswerSchema
|
|
4043
|
+
]);
|
|
4044
|
+
var SystemOneUsageSchema = z12.object({
|
|
4045
|
+
input_tokens: NonNegativeInt4.optional(),
|
|
4046
|
+
output_tokens: NonNegativeInt4.optional(),
|
|
4047
|
+
prompt_tokens: NonNegativeInt4.optional(),
|
|
4048
|
+
completion_tokens: NonNegativeInt4.optional(),
|
|
4049
|
+
total_tokens: NonNegativeInt4.optional(),
|
|
4050
|
+
cost: NonNegativeNum4.optional()
|
|
4051
|
+
}).loose();
|
|
4052
|
+
var OpenRouterSystemOneResponseSchema = z12.object({
|
|
4053
|
+
id: z12.string().min(1).optional(),
|
|
4054
|
+
model: z12.string().min(1).optional(),
|
|
4055
|
+
answers: z12.record(z12.string(), SystemOneAnswerSchema),
|
|
4056
|
+
usage: SystemOneUsageSchema.optional()
|
|
4057
|
+
}).loose();
|
|
4058
|
+
var SystemOneQuestionsMapSchema = z12.record(z12.string().min(1), SystemOneQuestionSchema).refine((value) => Object.keys(value).length > 0, {
|
|
4059
|
+
message: "openRouterSystemOne requires at least one question"
|
|
4060
|
+
});
|
|
4061
|
+
async function openRouterSystemOne(input) {
|
|
4062
|
+
assertOpenRouterDirectAuth(input);
|
|
4063
|
+
const model = assertNonEmptyOpenRouterField("openRouterSystemOne", "model", input.model);
|
|
4064
|
+
const questions = SystemOneQuestionsMapSchema.parse(input.questions);
|
|
4065
|
+
assertNoExtraBodyClash("openRouterSystemOne", input.extraBody, SYSTEMONE_OWNED_KEYS);
|
|
4066
|
+
const provider = input.provider !== undefined ? serializeOpenRouterProviderRouting(input.provider) : undefined;
|
|
4067
|
+
const body = {
|
|
4068
|
+
...input.extraBody ?? {},
|
|
4069
|
+
model,
|
|
4070
|
+
state: input.state,
|
|
4071
|
+
questions,
|
|
4072
|
+
...provider !== undefined && { provider }
|
|
4073
|
+
};
|
|
4074
|
+
const response = await openRouterRequestJson({
|
|
4075
|
+
...pickOpenRouterTransport(input),
|
|
4076
|
+
path: "/systemone",
|
|
4077
|
+
method: "POST",
|
|
4078
|
+
body,
|
|
4079
|
+
schema: OpenRouterSystemOneResponseSchema
|
|
4080
|
+
});
|
|
4081
|
+
return {
|
|
4082
|
+
...response.data.model !== undefined && { model: response.data.model },
|
|
4083
|
+
answers: response.data.answers,
|
|
4084
|
+
...response.data.usage !== undefined && { usage: response.data.usage },
|
|
4085
|
+
raw: response.data,
|
|
4086
|
+
status: response.status,
|
|
4087
|
+
...response.generationId !== undefined && { generationId: response.generationId },
|
|
4088
|
+
...response.requestId !== undefined && { requestId: response.requestId },
|
|
4089
|
+
...response.costUsd !== undefined && { costUsd: response.costUsd },
|
|
4090
|
+
headers: response.headers
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
2851
4093
|
export {
|
|
4094
|
+
OPENROUTER_API_BASE_URL,
|
|
2852
4095
|
OpenRouterAdmissionPolicySchema,
|
|
2853
4096
|
OpenRouterAdmissionReasonSchema,
|
|
4097
|
+
OpenRouterAudioTranscriptionResponseSchema,
|
|
2854
4098
|
OpenRouterCatalogSnapshotSchema,
|
|
2855
4099
|
OpenRouterEndpointSchema,
|
|
2856
4100
|
OpenRouterEndpointSummarySchema,
|
|
2857
4101
|
OpenRouterHttpError,
|
|
4102
|
+
OpenRouterImageGenerationResponseSchema,
|
|
2858
4103
|
OpenRouterMaxPriceSchema,
|
|
2859
4104
|
OpenRouterModelAdmissionSchema,
|
|
2860
4105
|
OpenRouterModelAliasTargetSchema,
|
|
@@ -2866,6 +4111,7 @@ export {
|
|
|
2866
4111
|
OpenRouterRequestPolicySchema,
|
|
2867
4112
|
OpenRouterRoutePinSchema,
|
|
2868
4113
|
OpenRouterSnapshotModelSchema,
|
|
4114
|
+
OpenRouterSystemOneResponseSchema,
|
|
2869
4115
|
createMemoryOpenRouterRouteStore,
|
|
2870
4116
|
createOpenRouterCatalogCache,
|
|
2871
4117
|
createOpenRouterRouteResolver,
|
|
@@ -2876,9 +4122,20 @@ export {
|
|
|
2876
4122
|
listOpenRouterModels,
|
|
2877
4123
|
loadOpenRouterCatalogSnapshot,
|
|
2878
4124
|
normalizeOpenRouterUsage,
|
|
4125
|
+
openRouterAudioSpeech,
|
|
4126
|
+
openRouterAudioTranscription,
|
|
4127
|
+
openRouterDownloadVideo,
|
|
4128
|
+
openRouterEmbeddings,
|
|
4129
|
+
openRouterGenerateImages,
|
|
4130
|
+
openRouterGetVideo,
|
|
2879
4131
|
openRouterModelCatalog,
|
|
2880
4132
|
openRouterProvider,
|
|
4133
|
+
openRouterRequestJson,
|
|
4134
|
+
openRouterRequestStream,
|
|
4135
|
+
openRouterRerank,
|
|
2881
4136
|
openRouterSpendProvider,
|
|
4137
|
+
openRouterSubmitVideo,
|
|
4138
|
+
openRouterSystemOne,
|
|
2882
4139
|
resolveOpenRouterModelCeiling,
|
|
2883
4140
|
summarizeOpenRouterEndpoints
|
|
2884
4141
|
};
|