@openllmsh/sdk 2.10.12-alpha.1 → 2.10.12
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/README.md +27 -7
- package/dist/client/chat.d.ts +38 -0
- package/dist/client/chat.js +77 -0
- package/dist/client/devices.d.ts +70 -0
- package/dist/client/devices.js +172 -0
- package/dist/client/http.d.ts +24 -0
- package/dist/client/http.js +34 -0
- package/dist/client/index.d.ts +43 -0
- package/dist/client/index.js +57 -0
- package/dist/client/relay-mux.d.ts +71 -0
- package/dist/client/relay-mux.js +394 -0
- package/dist/client/types.d.ts +47 -0
- package/dist/client/types.js +5 -0
- package/dist/client/vault.d.ts +68 -0
- package/dist/client/vault.js +113 -0
- package/dist/connect/chat.d.ts +24 -0
- package/dist/connect/chat.js +25 -0
- package/dist/connect/client.d.ts +50 -0
- package/dist/connect/client.js +141 -0
- package/dist/connect/config.d.ts +22 -0
- package/dist/connect/config.js +22 -0
- package/dist/connect/errors.d.ts +32 -0
- package/dist/connect/errors.js +85 -0
- package/{connect/index.ts → dist/connect/index.d.ts} +7 -7
- package/dist/connect/index.js +23 -0
- package/dist/connect/oauth.d.ts +51 -0
- package/dist/connect/oauth.js +150 -0
- package/dist/connect/routes.d.ts +38 -0
- package/dist/connect/routes.js +175 -0
- package/dist/connect/store.d.ts +26 -0
- package/dist/connect/store.js +65 -0
- package/dist/mcp/handle.d.ts +6 -0
- package/dist/mcp/handle.js +6 -0
- package/dist/mcp/index.d.ts +15 -0
- package/dist/mcp/index.js +10 -0
- package/dist/mcp/server.d.ts +84 -0
- package/dist/mcp/server.js +168 -0
- package/dist/mcp/tools/marketplace.d.ts +94 -0
- package/dist/mcp/tools/marketplace.js +303 -0
- package/dist/mcp/tools/memory-client.d.ts +109 -0
- package/dist/mcp/tools/memory-client.js +200 -0
- package/dist/mcp/tools/memory-config.d.ts +29 -0
- package/dist/mcp/tools/memory-config.js +12 -0
- package/dist/mcp/tools/memory.d.ts +92 -0
- package/dist/mcp/tools/memory.js +312 -0
- package/dist/mcp/tools/model-priority.d.ts +16 -0
- package/dist/mcp/tools/model-priority.js +87 -0
- package/dist/mcp/tools/openllm.d.ts +75 -0
- package/dist/mcp/tools/openllm.js +715 -0
- package/dist/mcp/types.d.ts +25 -0
- package/dist/mcp/types.js +7 -0
- package/dist/openapi/call.d.ts +26 -0
- package/dist/openapi/call.js +56 -0
- package/dist/openapi/index.d.ts +2 -0
- package/dist/openapi/index.js +2 -0
- package/dist/openapi/openapi.json +80213 -0
- package/dist/openapi/operations.d.ts +14 -0
- package/dist/openapi/operations.js +2060 -0
- package/dist/protocol/access.d.ts +81 -0
- package/dist/protocol/access.js +125 -0
- package/dist/protocol/agent-prompt-text.d.ts +15 -0
- package/{protocol/agent-prompt-text.ts → dist/protocol/agent-prompt-text.js} +9 -14
- package/dist/protocol/agent.d.ts +1487 -0
- package/dist/protocol/agent.js +787 -0
- package/dist/protocol/api-key-syntax.d.ts +58 -0
- package/dist/protocol/api-key-syntax.js +73 -0
- package/dist/protocol/audio.d.ts +18 -0
- package/dist/protocol/audio.js +21 -0
- package/dist/protocol/auth.d.ts +126 -0
- package/dist/protocol/auth.js +119 -0
- package/dist/protocol/changelog.d.ts +69 -0
- package/dist/protocol/changelog.js +107 -0
- package/dist/protocol/chat.d.ts +789 -0
- package/dist/protocol/chat.js +394 -0
- package/dist/protocol/client-registry.d.ts +151 -0
- package/dist/protocol/client-registry.js +238 -0
- package/dist/protocol/config.d.ts +508 -0
- package/dist/protocol/config.js +289 -0
- package/dist/protocol/control-channel.d.ts +102 -0
- package/{protocol/control-channel.ts → dist/protocol/control-channel.js} +33 -61
- package/dist/protocol/cooldown-reason.d.ts +30 -0
- package/dist/protocol/cooldown-reason.js +44 -0
- package/dist/protocol/cost.d.ts +9 -0
- package/dist/protocol/cost.js +8 -0
- package/dist/protocol/daemon-port.d.ts +2 -0
- package/dist/protocol/daemon-port.js +28 -0
- package/dist/protocol/daemon.d.ts +2034 -0
- package/dist/protocol/daemon.js +1286 -0
- package/dist/protocol/default-chains.d.ts +15 -0
- package/dist/protocol/default-chains.js +21 -0
- package/dist/protocol/device-state.d.ts +223 -0
- package/dist/protocol/device-state.js +52 -0
- package/dist/protocol/doctor-report-local.d.ts +105 -0
- package/{protocol/doctor-report-local.ts → dist/protocol/doctor-report-local.js} +92 -196
- package/dist/protocol/doctor-report-policy.d.ts +62 -0
- package/{protocol/doctor-report-policy.ts → dist/protocol/doctor-report-policy.js} +23 -76
- package/dist/protocol/doctor-report.d.ts +406 -0
- package/dist/protocol/doctor-report.js +645 -0
- package/dist/protocol/errors.d.ts +17 -0
- package/dist/protocol/errors.js +10 -0
- package/dist/protocol/execution-selection.d.ts +92 -0
- package/{protocol/execution-selection.ts → dist/protocol/execution-selection.js} +38 -63
- package/dist/protocol/hop-grant.d.ts +28 -0
- package/{protocol/hop-grant.ts → dist/protocol/hop-grant.js} +7 -13
- package/dist/protocol/image-edit-parse.d.ts +25 -0
- package/dist/protocol/image-edit-parse.js +196 -0
- package/dist/protocol/images.d.ts +288 -0
- package/dist/protocol/images.js +229 -0
- package/dist/protocol/index.d.ts +69 -0
- package/dist/protocol/index.js +74 -0
- package/dist/protocol/inference-headers.d.ts +3 -0
- package/dist/protocol/keepalive.d.ts +36 -0
- package/dist/protocol/keepalive.js +51 -0
- package/dist/protocol/local-auth.d.ts +125 -0
- package/dist/protocol/local-auth.js +227 -0
- package/dist/protocol/local-device-control.d.ts +108 -0
- package/{protocol/local-device-control.ts → dist/protocol/local-device-control.js} +40 -70
- package/dist/protocol/local-provider.d.ts +105 -0
- package/dist/protocol/local-provider.js +213 -0
- package/dist/protocol/local-session.d.ts +70 -0
- package/dist/protocol/local-session.js +87 -0
- package/dist/protocol/marketplace.d.ts +190 -0
- package/dist/protocol/marketplace.js +140 -0
- package/{protocol/media-attempt.ts → dist/protocol/media-attempt.d.ts} +11 -50
- package/dist/protocol/media-attempt.js +50 -0
- package/dist/protocol/media-bytes.d.ts +8 -0
- package/dist/protocol/media-bytes.js +21 -0
- package/dist/protocol/media-default.d.ts +56 -0
- package/dist/protocol/media-default.js +302 -0
- package/{protocol/media-dimensions.ts → dist/protocol/media-dimensions.d.ts} +11 -78
- package/dist/protocol/media-dimensions.js +90 -0
- package/dist/protocol/media-input.d.ts +20 -0
- package/dist/protocol/media-input.js +29 -0
- package/dist/protocol/media-model.d.ts +77 -0
- package/dist/protocol/media-model.js +89 -0
- package/{protocol/media-option-issue.ts → dist/protocol/media-option-issue.d.ts} +25 -53
- package/dist/protocol/media-option-issue.js +50 -0
- package/dist/protocol/media-types.d.ts +14 -0
- package/dist/protocol/media-types.js +61 -0
- package/dist/protocol/model-match.d.ts +254 -0
- package/dist/protocol/model-match.js +760 -0
- package/dist/protocol/model-settings.d.ts +153 -0
- package/dist/protocol/model-settings.js +246 -0
- package/dist/protocol/models.d.ts +1065 -0
- package/dist/protocol/models.js +638 -0
- package/dist/protocol/mux.d.ts +350 -0
- package/dist/protocol/mux.js +595 -0
- package/{protocol/plan-surface.ts → dist/protocol/plan-surface.d.ts} +12 -26
- package/dist/protocol/plan-surface.js +39 -0
- package/dist/protocol/provider-models.d.ts +8 -0
- package/{protocol/provider-models.ts → dist/protocol/provider-models.js} +7 -9
- package/dist/protocol/provider-status.d.ts +59 -0
- package/dist/protocol/provider-status.js +142 -0
- package/dist/protocol/provider-tier.d.ts +34 -0
- package/{protocol/provider-tier.ts → dist/protocol/provider-tier.js} +9 -34
- package/dist/protocol/provider-usage.d.ts +230 -0
- package/dist/protocol/provider-usage.js +214 -0
- package/dist/protocol/providers.d.ts +2496 -0
- package/dist/protocol/providers.js +723 -0
- package/dist/protocol/public-usage-index.d.ts +449 -0
- package/dist/protocol/public-usage-index.js +279 -0
- package/dist/protocol/realtime-generated.d.ts +29 -0
- package/{protocol/realtime-generated.ts → dist/protocol/realtime-generated.js} +3 -5
- package/dist/protocol/realtime.d.ts +241 -0
- package/{protocol/realtime.ts → dist/protocol/realtime.js} +88 -155
- package/dist/protocol/registry-pointer.d.ts +24 -0
- package/dist/protocol/registry-pointer.js +78 -0
- package/dist/protocol/relay.d.ts +1152 -0
- package/{protocol/relay.ts → dist/protocol/relay.js} +237 -370
- package/dist/protocol/replay-session.d.ts +4 -0
- package/{protocol/replay-session.ts → dist/protocol/replay-session.js} +1 -8
- package/dist/protocol/responses.d.ts +303 -0
- package/dist/protocol/responses.js +240 -0
- package/dist/protocol/semver.d.ts +59 -0
- package/dist/protocol/semver.js +171 -0
- package/{protocol/setup-mode.ts → dist/protocol/setup-mode.d.ts} +4 -12
- package/dist/protocol/setup-mode.js +18 -0
- package/dist/protocol/sha256-hex.d.ts +2 -0
- package/dist/protocol/sha256-hex.js +93 -0
- package/dist/protocol/stats.d.ts +711 -0
- package/dist/protocol/stats.js +353 -0
- package/dist/protocol/streaming.d.ts +16 -0
- package/dist/protocol/streaming.js +15 -0
- package/{protocol/subscription-daemon-floors.ts → dist/protocol/subscription-daemon-floors.d.ts} +8 -14
- package/dist/protocol/subscription-daemon-floors.js +4 -0
- package/dist/protocol/subscription-provider-compat.d.ts +44 -0
- package/dist/protocol/subscription-provider-compat.js +67 -0
- package/dist/protocol/subscription-provider.d.ts +15 -0
- package/dist/protocol/subscription-provider.js +17 -0
- package/dist/protocol/team-grant.d.ts +14 -0
- package/{protocol/team-grant.ts → dist/protocol/team-grant.js} +0 -3
- package/dist/protocol/team-shareable.d.ts +6 -0
- package/{protocol/team-shareable.ts → dist/protocol/team-shareable.js} +29 -33
- package/dist/protocol/transcription-encoding.d.ts +25 -0
- package/dist/protocol/transcription-encoding.js +47 -0
- package/{protocol/url-locality-dns.ts → dist/protocol/url-locality-dns.d.ts} +1 -23
- package/dist/protocol/url-locality-dns.js +33 -0
- package/dist/protocol/url-locality.d.ts +45 -0
- package/dist/protocol/url-locality.js +288 -0
- package/dist/protocol/usage-snapshots.d.ts +8 -0
- package/{protocol/usage-snapshots.ts → dist/protocol/usage-snapshots.js} +1 -2
- package/dist/protocol/vendor-cli-install.d.ts +20 -0
- package/{protocol/vendor-cli-install.ts → dist/protocol/vendor-cli-install.js} +10 -15
- package/dist/protocol/video-job-plan.d.ts +18 -0
- package/dist/protocol/video-job-plan.js +44 -0
- package/dist/protocol/videos.d.ts +107 -0
- package/dist/protocol/videos.js +154 -0
- package/dist/tunnel/channel-envelope.d.ts +53 -0
- package/dist/tunnel/channel-envelope.js +100 -0
- package/dist/tunnel/codec.d.ts +71 -0
- package/dist/tunnel/codec.js +151 -0
- package/dist/tunnel/device-anchor.d.ts +62 -0
- package/dist/tunnel/device-anchor.js +168 -0
- package/dist/tunnel/device-control.d.ts +50 -0
- package/dist/tunnel/device-control.js +88 -0
- package/dist/tunnel/device-grant.d.ts +91 -0
- package/dist/tunnel/device-grant.js +105 -0
- package/dist/tunnel/fleet.d.ts +28 -0
- package/dist/tunnel/fleet.js +41 -0
- package/dist/tunnel/index.d.ts +22 -0
- package/dist/tunnel/index.js +22 -0
- package/dist/tunnel/mux.d.ts +64 -0
- package/dist/tunnel/mux.js +449 -0
- package/dist/tunnel/peer-link.d.ts +88 -0
- package/dist/tunnel/peer-link.js +271 -0
- package/dist/tunnel/rtc-auth.d.ts +159 -0
- package/dist/tunnel/rtc-auth.js +340 -0
- package/dist/tunnel/rtc-duplex.d.ts +52 -0
- package/dist/tunnel/rtc-duplex.js +148 -0
- package/dist/tunnel/rtc-ice.d.ts +55 -0
- package/dist/tunnel/rtc-ice.js +100 -0
- package/dist/tunnel/secure.d.ts +179 -0
- package/dist/tunnel/secure.js +936 -0
- package/dist/tunnel/stream-reset-error.d.ts +6 -0
- package/dist/tunnel/stream-reset-error.js +9 -0
- package/dist/tunnel/streams.d.ts +244 -0
- package/dist/tunnel/streams.js +1071 -0
- package/dist/tunnel/team-grant.d.ts +90 -0
- package/dist/tunnel/team-grant.js +226 -0
- package/dist/tunnel/wire-bytes.d.ts +32 -0
- package/dist/tunnel/wire-bytes.js +90 -0
- package/dist/vault/api-key.d.ts +71 -0
- package/dist/vault/api-key.js +130 -0
- package/{vault/argon2.ts → dist/vault/argon2.d.ts} +18 -53
- package/dist/vault/argon2.js +82 -0
- package/dist/vault/cli-auth-seal.d.ts +35 -0
- package/dist/vault/cli-auth-seal.js +78 -0
- package/dist/vault/cred-seal.d.ts +18 -0
- package/dist/vault/cred-seal.js +86 -0
- package/dist/vault/credential.d.ts +21 -0
- package/dist/vault/credential.js +26 -0
- package/dist/vault/crypto.d.ts +51 -0
- package/dist/vault/crypto.js +156 -0
- package/dist/vault/daemon-attest.d.ts +68 -0
- package/dist/vault/daemon-attest.js +147 -0
- package/dist/vault/derive.d.ts +34 -0
- package/dist/vault/derive.js +84 -0
- package/dist/vault/device-access.d.ts +17 -0
- package/dist/vault/device-access.js +77 -0
- package/dist/vault/device-anchor.d.ts +42 -0
- package/dist/vault/device-anchor.js +90 -0
- package/dist/vault/device-control.d.ts +80 -0
- package/{vault/device-control.ts → dist/vault/device-control.js} +46 -104
- package/dist/vault/handoff.d.ts +102 -0
- package/dist/vault/handoff.js +236 -0
- package/dist/vault/index.d.ts +21 -0
- package/dist/vault/index.js +21 -0
- package/dist/vault/passkey.d.ts +82 -0
- package/{vault/passkey.ts → dist/vault/passkey.js} +63 -153
- package/dist/vault/phrase.d.ts +40 -0
- package/{vault/phrase.ts → dist/vault/phrase.js} +17 -23
- package/dist/vault/pin.d.ts +46 -0
- package/dist/vault/pin.js +92 -0
- package/dist/vault/public-key-seal.d.ts +17 -0
- package/dist/vault/public-key-seal.js +59 -0
- package/dist/vault/seed.d.ts +96 -0
- package/dist/vault/seed.js +179 -0
- package/dist/vault/team.d.ts +134 -0
- package/dist/vault/team.js +217 -0
- package/dist/vault/vault-item.d.ts +45 -0
- package/dist/vault/vault-item.js +62 -0
- package/dist/vault/vault-migrate-digest.d.ts +10 -0
- package/dist/vault/vault-migrate-digest.js +22 -0
- package/dist/vault/wrapped.d.ts +19 -0
- package/dist/vault/wrapped.js +52 -0
- package/dist/wire/adapters/messages/anthropic-map.d.ts +8 -0
- package/dist/wire/adapters/messages/anthropic-map.js +32 -0
- package/dist/wire/adapters/messages/index.d.ts +7 -0
- package/dist/wire/adapters/messages/index.js +7 -0
- package/dist/wire/adapters/messages/reasoning-from-items.d.ts +14 -0
- package/dist/wire/adapters/messages/reasoning-from-items.js +39 -0
- package/dist/wire/adapters/messages/reasoning-signature.d.ts +81 -0
- package/dist/wire/adapters/messages/reasoning-signature.js +180 -0
- package/dist/wire/adapters/messages/request.d.ts +28 -0
- package/dist/wire/adapters/messages/request.js +490 -0
- package/dist/wire/adapters/messages/response.d.ts +10 -0
- package/dist/wire/adapters/messages/response.js +177 -0
- package/dist/wire/adapters/messages/streaming.d.ts +134 -0
- package/dist/wire/adapters/messages/streaming.js +791 -0
- package/dist/wire/adapters/messages/usage.d.ts +20 -0
- package/dist/wire/adapters/messages/usage.js +10 -0
- package/dist/wire/adapters/responses/index.d.ts +3 -0
- package/dist/wire/adapters/responses/index.js +3 -0
- package/dist/wire/adapters/responses/request.d.ts +2 -0
- package/dist/wire/adapters/responses/request.js +287 -0
- package/dist/wire/adapters/responses/response.d.ts +11 -0
- package/dist/wire/adapters/responses/response.js +69 -0
- package/dist/wire/adapters/responses/streaming.d.ts +2 -0
- package/dist/wire/adapters/responses/streaming.js +267 -0
- package/dist/wire/features/account-rank.d.ts +61 -0
- package/dist/wire/features/account-rank.js +109 -0
- package/dist/wire/features/compaction/compact-request.d.ts +69 -0
- package/dist/wire/features/compaction/compact-request.js +667 -0
- package/dist/wire/features/compaction/compaction-text.d.ts +17 -0
- package/dist/wire/features/compaction/compaction-text.js +29 -0
- package/dist/wire/features/context-demote.d.ts +15 -0
- package/dist/wire/features/context-demote.js +45 -0
- package/dist/wire/features/context-overflow-strategy.d.ts +12 -0
- package/dist/wire/features/context-overflow-strategy.js +8 -0
- package/dist/wire/features/context-skip.d.ts +120 -0
- package/{wire/features/context-skip.ts → dist/wire/features/context-skip.js} +23 -57
- package/dist/wire/features/conversation-affinity.d.ts +49 -0
- package/dist/wire/features/conversation-affinity.js +121 -0
- package/dist/wire/features/max-tokens-backfill.d.ts +50 -0
- package/dist/wire/features/max-tokens-backfill.js +118 -0
- package/dist/wire/features/model-caps.d.ts +7 -0
- package/dist/wire/features/model-caps.js +40 -0
- package/dist/wire/features/model-settings.d.ts +3 -0
- package/dist/wire/features/model-settings.js +13 -0
- package/dist/wire/features/output-limit-clamp.d.ts +14 -0
- package/dist/wire/features/output-limit-clamp.js +36 -0
- package/dist/wire/features/quota-gate.d.ts +16 -0
- package/dist/wire/features/quota-gate.js +48 -0
- package/dist/wire/index.d.ts +44 -0
- package/dist/wire/index.js +44 -0
- package/dist/wire/lib/attempt-outcome.d.ts +19 -0
- package/dist/wire/lib/attempt-outcome.js +18 -0
- package/{wire/lib/canonical/content-part.ts → dist/wire/lib/canonical/content-part.d.ts} +12 -18
- package/dist/wire/lib/canonical/content-part.js +11 -0
- package/dist/wire/lib/canonical/count-tokens-capability.d.ts +52 -0
- package/dist/wire/lib/canonical/count-tokens-capability.js +109 -0
- package/{wire/lib/canonical/encoding-select.ts → dist/wire/lib/canonical/encoding-select.d.ts} +7 -24
- package/dist/wire/lib/canonical/encoding-select.js +26 -0
- package/dist/wire/lib/canonical/image-signature.d.ts +20 -0
- package/dist/wire/lib/canonical/image-signature.js +184 -0
- package/dist/wire/lib/canonical/image-sse.d.ts +88 -0
- package/dist/wire/lib/canonical/image-sse.js +173 -0
- package/{wire/lib/canonical/message.ts → dist/wire/lib/canonical/message.d.ts} +2 -20
- package/dist/wire/lib/canonical/message.js +31 -0
- package/dist/wire/lib/canonical/token-estimate.d.ts +98 -0
- package/dist/wire/lib/canonical/token-estimate.js +230 -0
- package/dist/wire/lib/encrypted-content.d.ts +22 -0
- package/dist/wire/lib/encrypted-content.js +55 -0
- package/dist/wire/lib/error-class.d.ts +57 -0
- package/dist/wire/lib/error-class.js +97 -0
- package/dist/wire/lib/error-envelope.d.ts +20 -0
- package/dist/wire/lib/error-envelope.js +53 -0
- package/dist/wire/lib/forwarded-headers.d.ts +16 -0
- package/{wire/lib/forwarded-headers.ts → dist/wire/lib/forwarded-headers.js} +62 -72
- package/dist/wire/lib/provider-error-rules.d.ts +21 -0
- package/dist/wire/lib/provider-error-rules.js +20 -0
- package/{wire/lib/refusal.ts → dist/wire/lib/refusal.d.ts} +3 -13
- package/dist/wire/lib/refusal.js +27 -0
- package/dist/wire/lib/responses-apply-patch.d.ts +57 -0
- package/dist/wire/lib/responses-apply-patch.js +81 -0
- package/dist/wire/lib/responses-namespace.d.ts +27 -0
- package/{wire/lib/responses-namespace.ts → dist/wire/lib/responses-namespace.js} +16 -32
- package/dist/wire/lib/secret-scrub.d.ts +23 -0
- package/dist/wire/lib/secret-scrub.js +72 -0
- package/dist/wire/lib/streaming/accumulate.d.ts +12 -0
- package/dist/wire/lib/streaming/accumulate.js +187 -0
- package/dist/wire/lib/streaming/finish-reason.d.ts +20 -0
- package/dist/wire/lib/streaming/finish-reason.js +15 -0
- package/{wire/lib/streaming/peek.ts → dist/wire/lib/streaming/peek.d.ts} +13 -82
- package/dist/wire/lib/streaming/peek.js +100 -0
- package/dist/wire/lib/streaming/provider-decode.d.ts +57 -0
- package/dist/wire/lib/streaming/provider-decode.js +210 -0
- package/dist/wire/lib/streaming/response-stream.d.ts +16 -0
- package/dist/wire/lib/streaming/response-stream.js +64 -0
- package/dist/wire/lib/streaming/sse.d.ts +130 -0
- package/dist/wire/lib/streaming/sse.js +600 -0
- package/dist/wire/lib/streaming/strip-tool-calls.d.ts +14 -0
- package/dist/wire/lib/streaming/strip-tool-calls.js +75 -0
- package/dist/wire/lib/streaming/upstream-error.d.ts +32 -0
- package/dist/wire/lib/streaming/upstream-error.js +45 -0
- package/dist/wire/lib/strip-subagent-isolation.d.ts +16 -0
- package/dist/wire/lib/strip-subagent-isolation.js +240 -0
- package/dist/wire/lib/thinking-signature.d.ts +56 -0
- package/{wire/lib/thinking-signature.ts → dist/wire/lib/thinking-signature.js} +77 -84
- package/dist/wire/lib/token-ruler/bpe-core.d.ts +105 -0
- package/dist/wire/lib/token-ruler/bpe-core.js +398 -0
- package/dist/wire/lib/token-ruler/index.d.ts +2 -0
- package/dist/wire/lib/token-ruler/index.js +2 -0
- package/dist/wire/lib/token-ruler/ruler.d.ts +36 -0
- package/dist/wire/lib/token-ruler/ruler.js +50 -0
- package/dist/wire/lib/token-ruler/vocab/claude-ranks.d.ts +14 -0
- package/dist/wire/lib/token-ruler/vocab/claude-ranks.js +16 -0
- package/{wire/lib/token-ruler/vocab/claude.ts → dist/wire/lib/token-ruler/vocab/claude.d.ts} +2 -12
- package/dist/wire/lib/token-ruler/vocab/claude.js +8 -0
- package/dist/wire/lib/token-ruler/vocab/o200k-ranks.d.ts +3 -0
- package/dist/wire/lib/token-ruler/vocab/o200k-ranks.js +18 -0
- package/dist/wire/lib/token-ruler/vocab/o200k.d.ts +11 -0
- package/dist/wire/lib/token-ruler/vocab/o200k.js +6 -0
- package/dist/wire/lib/tool-name-map.d.ts +44 -0
- package/dist/wire/lib/tool-name-map.js +186 -0
- package/dist/wire/lib/tool-schema.d.ts +15 -0
- package/dist/wire/lib/tool-schema.js +307 -0
- package/dist/wire/lib/usage-observer.d.ts +9 -0
- package/dist/wire/lib/usage-observer.js +108 -0
- package/dist/wire/providers/anthropic/adaptive-thinking.d.ts +125 -0
- package/dist/wire/providers/anthropic/adaptive-thinking.js +221 -0
- package/dist/wire/providers/anthropic/beta-headers.d.ts +44 -0
- package/{wire/providers/anthropic/beta-headers.ts → dist/wire/providers/anthropic/beta-headers.js} +57 -79
- package/dist/wire/providers/anthropic/index.d.ts +6 -0
- package/{wire/providers/anthropic/index.ts → dist/wire/providers/anthropic/index.js} +6 -6
- package/dist/wire/providers/anthropic/request.d.ts +12 -0
- package/dist/wire/providers/anthropic/request.js +456 -0
- package/dist/wire/providers/anthropic/response.d.ts +3 -0
- package/dist/wire/providers/anthropic/response.js +126 -0
- package/dist/wire/providers/anthropic/streaming.d.ts +28 -0
- package/dist/wire/providers/anthropic/streaming.js +268 -0
- package/dist/wire/providers/anthropic/web-search-domains.d.ts +7 -0
- package/dist/wire/providers/anthropic/web-search-domains.js +36 -0
- package/dist/wire/providers/chatgpt/common.d.ts +27 -0
- package/{wire/providers/chatgpt/common.ts → dist/wire/providers/chatgpt/common.js} +69 -89
- package/dist/wire/providers/chatgpt/index.d.ts +4 -0
- package/{wire/providers/chatgpt/index.ts → dist/wire/providers/chatgpt/index.js} +4 -4
- package/dist/wire/providers/chatgpt/request.d.ts +132 -0
- package/dist/wire/providers/chatgpt/request.js +696 -0
- package/dist/wire/providers/chatgpt/streaming.d.ts +69 -0
- package/dist/wire/providers/chatgpt/streaming.js +761 -0
- package/dist/wire/providers/chatgpt/web-search.d.ts +19 -0
- package/dist/wire/providers/chatgpt/web-search.js +55 -0
- package/dist/wire/providers/grok/web-search.d.ts +23 -0
- package/dist/wire/providers/grok/web-search.js +74 -0
- package/dist/wire/providers/kimi/web-search.d.ts +48 -0
- package/dist/wire/providers/kimi/web-search.js +106 -0
- package/dist/wire/providers/upstream-deny.d.ts +61 -0
- package/dist/wire/providers/upstream-deny.js +293 -0
- package/dist/wire/providers/upstream-request.d.ts +104 -0
- package/dist/wire/providers/upstream-request.js +411 -0
- package/package.json +105 -23
- package/ARCHITECTURE.md +0 -43
- package/client/chat.ts +0 -140
- package/client/devices.ts +0 -269
- package/client/http.ts +0 -72
- package/client/index.ts +0 -129
- package/client/relay-mux.ts +0 -547
- package/client/types.ts +0 -51
- package/client/vault.ts +0 -239
- package/connect/chat.ts +0 -58
- package/connect/client.ts +0 -240
- package/connect/config.ts +0 -47
- package/connect/errors.ts +0 -121
- package/connect/oauth.ts +0 -265
- package/connect/routes.ts +0 -234
- package/connect/store.ts +0 -107
- package/mcp/handle.ts +0 -24
- package/mcp/index.ts +0 -76
- package/mcp/server.ts +0 -319
- package/mcp/tools/marketplace.ts +0 -439
- package/mcp/tools/memory-client.ts +0 -297
- package/mcp/tools/memory-config.ts +0 -32
- package/mcp/tools/memory.ts +0 -369
- package/mcp/tools/model-priority.ts +0 -88
- package/mcp/tools/openllm.ts +0 -883
- package/mcp/types.ts +0 -28
- package/openapi/call.ts +0 -90
- package/openapi/index.ts +0 -8
- package/openapi/openapi.json +0 -80213
- package/openapi/operations.ts +0 -2075
- package/protocol/CONTRIBUTING.md +0 -21
- package/protocol/README.md +0 -134
- package/protocol/access.ts +0 -186
- package/protocol/agent.ts +0 -991
- package/protocol/api-key-syntax.ts +0 -105
- package/protocol/assets/openllm-light.svg +0 -18
- package/protocol/assets/openllm.svg +0 -18
- package/protocol/audio.ts +0 -29
- package/protocol/auth.ts +0 -142
- package/protocol/changelog.ts +0 -155
- package/protocol/chat.ts +0 -458
- package/protocol/client-registry.ts +0 -356
- package/protocol/config.ts +0 -345
- package/protocol/cooldown-reason.ts +0 -78
- package/protocol/cost.ts +0 -10
- package/protocol/daemon-port.ts +0 -31
- package/protocol/daemon.ts +0 -1524
- package/protocol/default-chains.ts +0 -66
- package/protocol/device-state.ts +0 -85
- package/protocol/doctor-report.ts +0 -947
- package/protocol/errors.ts +0 -14
- package/protocol/image-edit-parse.ts +0 -263
- package/protocol/images.ts +0 -298
- package/protocol/index.ts +0 -74
- package/protocol/keepalive.ts +0 -69
- package/protocol/local-auth.ts +0 -300
- package/protocol/local-provider.ts +0 -288
- package/protocol/local-session.ts +0 -118
- package/protocol/marketplace.ts +0 -187
- package/protocol/media-bytes.ts +0 -28
- package/protocol/media-default.ts +0 -357
- package/protocol/media-input.ts +0 -61
- package/protocol/media-model.ts +0 -142
- package/protocol/media-types.ts +0 -70
- package/protocol/model-match.ts +0 -1051
- package/protocol/model-settings.ts +0 -327
- package/protocol/models.ts +0 -767
- package/protocol/mux.ts +0 -722
- package/protocol/provider-status.ts +0 -206
- package/protocol/provider-usage.ts +0 -263
- package/protocol/providers.ts +0 -901
- package/protocol/public-usage-index.ts +0 -354
- package/protocol/registry-pointer.ts +0 -118
- package/protocol/responses.ts +0 -280
- package/protocol/semver.ts +0 -182
- package/protocol/sha256-hex.ts +0 -98
- package/protocol/stats.ts +0 -406
- package/protocol/streaming.ts +0 -19
- package/protocol/subscription-provider-compat.ts +0 -104
- package/protocol/subscription-provider.ts +0 -32
- package/protocol/transcription-encoding.ts +0 -76
- package/protocol/url-locality.ts +0 -288
- package/protocol/video-job-plan.ts +0 -50
- package/protocol/videos.ts +0 -227
- package/tsconfig.json +0 -14
- package/tunnel/ARCHITECTURE.md +0 -111
- package/tunnel/assets/openllm-light.svg +0 -18
- package/tunnel/assets/openllm.svg +0 -18
- package/tunnel/channel-envelope.ts +0 -139
- package/tunnel/codec.ts +0 -191
- package/tunnel/device-anchor.ts +0 -229
- package/tunnel/device-control.ts +0 -118
- package/tunnel/device-grant.ts +0 -173
- package/tunnel/fleet.ts +0 -77
- package/tunnel/index.ts +0 -22
- package/tunnel/mux.ts +0 -580
- package/tunnel/peer-link.ts +0 -390
- package/tunnel/rtc-auth.ts +0 -415
- package/tunnel/rtc-duplex.ts +0 -187
- package/tunnel/rtc-ice.ts +0 -136
- package/tunnel/secure.ts +0 -1298
- package/tunnel/stream-reset-error.ts +0 -14
- package/tunnel/streams.ts +0 -1430
- package/tunnel/team-grant.ts +0 -302
- package/tunnel/wire-bytes.ts +0 -102
- package/vault/ARCHITECTURE.md +0 -470
- package/vault/api-key.ts +0 -190
- package/vault/cli-auth-seal.ts +0 -157
- package/vault/cred-seal.ts +0 -146
- package/vault/credential.ts +0 -55
- package/vault/crypto.ts +0 -210
- package/vault/daemon-attest.ts +0 -229
- package/vault/derive.ts +0 -113
- package/vault/device-access.ts +0 -87
- package/vault/device-anchor.ts +0 -185
- package/vault/handoff.ts +0 -396
- package/vault/index.ts +0 -21
- package/vault/pin.ts +0 -153
- package/vault/public-key-seal.ts +0 -131
- package/vault/seed.ts +0 -272
- package/vault/team.ts +0 -355
- package/vault/vault-item.ts +0 -131
- package/vault/vault-migrate-digest.ts +0 -29
- package/vault/wrapped.ts +0 -77
- package/wire/ARCHITECTURE.md +0 -90
- package/wire/CONTRIBUTING.md +0 -19
- package/wire/adapters/messages/anthropic-map.ts +0 -37
- package/wire/adapters/messages/index.ts +0 -7
- package/wire/adapters/messages/reasoning-from-items.ts +0 -38
- package/wire/adapters/messages/reasoning-signature.ts +0 -243
- package/wire/adapters/messages/request.ts +0 -574
- package/wire/adapters/messages/response.ts +0 -215
- package/wire/adapters/messages/streaming.ts +0 -1027
- package/wire/adapters/messages/usage.ts +0 -43
- package/wire/adapters/responses/index.ts +0 -3
- package/wire/adapters/responses/request.ts +0 -395
- package/wire/adapters/responses/response.ts +0 -88
- package/wire/adapters/responses/streaming.ts +0 -344
- package/wire/assets/openllm-light.svg +0 -18
- package/wire/assets/openllm.svg +0 -18
- package/wire/features/account-rank.ts +0 -166
- package/wire/features/compaction/compact-request.ts +0 -862
- package/wire/features/compaction/compaction-text.ts +0 -43
- package/wire/features/context-demote.ts +0 -47
- package/wire/features/context-overflow-strategy.ts +0 -26
- package/wire/features/conversation-affinity.ts +0 -144
- package/wire/features/max-tokens-backfill.ts +0 -141
- package/wire/features/model-caps.ts +0 -53
- package/wire/features/model-settings.ts +0 -24
- package/wire/features/output-limit-clamp.ts +0 -64
- package/wire/features/quota-gate.ts +0 -85
- package/wire/index.ts +0 -44
- package/wire/lib/attempt-outcome.ts +0 -43
- package/wire/lib/canonical/count-tokens-capability.ts +0 -138
- package/wire/lib/canonical/image-signature.ts +0 -202
- package/wire/lib/canonical/image-sse.ts +0 -216
- package/wire/lib/canonical/token-estimate.ts +0 -266
- package/wire/lib/encrypted-content.ts +0 -66
- package/wire/lib/error-class.ts +0 -154
- package/wire/lib/error-envelope.ts +0 -56
- package/wire/lib/provider-error-rules.ts +0 -48
- package/wire/lib/responses-apply-patch.ts +0 -104
- package/wire/lib/secret-scrub.ts +0 -101
- package/wire/lib/streaming/accumulate.ts +0 -221
- package/wire/lib/streaming/finish-reason.ts +0 -33
- package/wire/lib/streaming/provider-decode.ts +0 -259
- package/wire/lib/streaming/response-stream.ts +0 -71
- package/wire/lib/streaming/sse.ts +0 -699
- package/wire/lib/streaming/strip-tool-calls.ts +0 -95
- package/wire/lib/streaming/upstream-error.ts +0 -58
- package/wire/lib/strip-subagent-isolation.ts +0 -284
- package/wire/lib/token-ruler/bpe-core.ts +0 -426
- package/wire/lib/token-ruler/index.ts +0 -2
- package/wire/lib/token-ruler/ruler.ts +0 -79
- package/wire/lib/token-ruler/vocab/claude-ranks.ts +0 -16
- package/wire/lib/token-ruler/vocab/o200k-ranks.ts +0 -18
- package/wire/lib/token-ruler/vocab/o200k.ts +0 -19
- package/wire/lib/tool-name-map.ts +0 -271
- package/wire/lib/tool-schema.ts +0 -353
- package/wire/lib/usage-observer.ts +0 -125
- package/wire/providers/anthropic/adaptive-thinking.ts +0 -291
- package/wire/providers/anthropic/request.ts +0 -607
- package/wire/providers/anthropic/response.ts +0 -155
- package/wire/providers/anthropic/streaming.ts +0 -315
- package/wire/providers/anthropic/web-search-domains.ts +0 -49
- package/wire/providers/chatgpt/request.ts +0 -959
- package/wire/providers/chatgpt/streaming.ts +0 -1007
- package/wire/providers/chatgpt/web-search.ts +0 -63
- package/wire/providers/grok/web-search.ts +0 -87
- package/wire/providers/kimi/web-search.ts +0 -145
- package/wire/providers/upstream-deny.ts +0 -355
- package/wire/providers/upstream-request.ts +0 -619
- /package/{protocol/inference-headers.ts → dist/protocol/inference-headers.js} +0 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import { Schema as S } from "effect";
|
|
2
|
+
import { ModelCaps } from "./models.js";
|
|
3
|
+
// ─── OpenAI provider options ─────────────────────────────────────────────────
|
|
4
|
+
export const OpenAIProviderOptions = S.Struct({
|
|
5
|
+
providerModelId: S.String,
|
|
6
|
+
});
|
|
7
|
+
export const OpenAIEndpointKind = S.Literals([
|
|
8
|
+
"chat",
|
|
9
|
+
"embeddings",
|
|
10
|
+
"images",
|
|
11
|
+
"videos",
|
|
12
|
+
"audio_transcription",
|
|
13
|
+
"audio_speech",
|
|
14
|
+
]);
|
|
15
|
+
// ─── Anthropic tool shape (request side) ─────────────────────────────────────
|
|
16
|
+
export const AnthropicTool = S.Struct({
|
|
17
|
+
name: S.String,
|
|
18
|
+
description: S.optional(S.String),
|
|
19
|
+
// `input_schema` is required for custom tools but optional for the
|
|
20
|
+
// native server-side tools (`web_search_20250305`, `computer_20241022`,
|
|
21
|
+
// `bash_20241022`, etc.) which Anthropic identifies by `type` instead.
|
|
22
|
+
input_schema: S.optional(S.Unknown),
|
|
23
|
+
type: S.optional(S.String),
|
|
24
|
+
// A breakpoint on a tool makes the whole tool catalogue a cacheable
|
|
25
|
+
// prefix — Claude Code marks the last tool. LiteLLM:
|
|
26
|
+
// `llms/anthropic/chat/transformation.py` (~L783-799).
|
|
27
|
+
cache_control: S.optional(S.NullOr(S.Struct({ type: S.Literal("ephemeral") }))),
|
|
28
|
+
});
|
|
29
|
+
// ─── Anthropic wire types — request ──────────────────────────────────────────
|
|
30
|
+
const AnthropicCacheControl = S.Struct({ type: S.Literal("ephemeral") });
|
|
31
|
+
const AnthropicTextBlock = S.Struct({
|
|
32
|
+
type: S.Literal("text"),
|
|
33
|
+
text: S.String,
|
|
34
|
+
// Citation-bearing text blocks (returned when a document block has
|
|
35
|
+
// `citations.enabled` and replayed verbatim as assistant history).
|
|
36
|
+
// Kept opaque — the gateway never re-parses citations downstream, but
|
|
37
|
+
// without this field the parsed-body re-serialize path (dispatch-chain
|
|
38
|
+
// mutation branch) would silently strip them.
|
|
39
|
+
citations: S.optional(S.Unknown),
|
|
40
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
41
|
+
});
|
|
42
|
+
const AnthropicImageSource = S.Union([
|
|
43
|
+
S.Struct({
|
|
44
|
+
type: S.Literal("base64"),
|
|
45
|
+
media_type: S.String,
|
|
46
|
+
data: S.String,
|
|
47
|
+
}),
|
|
48
|
+
S.Struct({ type: S.Literal("url"), url: S.String }),
|
|
49
|
+
// Files API reference (beta `files-api-2025-04-14`).
|
|
50
|
+
S.Struct({ type: S.Literal("file"), file_id: S.String }),
|
|
51
|
+
]);
|
|
52
|
+
const AnthropicImageBlock = S.Struct({
|
|
53
|
+
type: S.Literal("image"),
|
|
54
|
+
source: AnthropicImageSource,
|
|
55
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
56
|
+
});
|
|
57
|
+
/** PDF / plain-text / custom-content document attachments. */
|
|
58
|
+
const AnthropicDocumentSource = S.Union([
|
|
59
|
+
S.Struct({
|
|
60
|
+
type: S.Literal("base64"),
|
|
61
|
+
media_type: S.String,
|
|
62
|
+
data: S.String,
|
|
63
|
+
}),
|
|
64
|
+
S.Struct({ type: S.Literal("url"), url: S.String }),
|
|
65
|
+
S.Struct({
|
|
66
|
+
type: S.Literal("text"),
|
|
67
|
+
media_type: S.String,
|
|
68
|
+
data: S.String,
|
|
69
|
+
}),
|
|
70
|
+
// Custom-content documents — kept opaque: the gateway never
|
|
71
|
+
// re-parses the inner block list downstream.
|
|
72
|
+
S.Struct({ type: S.Literal("content"), content: S.Unknown }),
|
|
73
|
+
// Files API reference (beta `files-api-2025-04-14`).
|
|
74
|
+
S.Struct({ type: S.Literal("file"), file_id: S.String }),
|
|
75
|
+
]);
|
|
76
|
+
const AnthropicDocumentBlock = S.Struct({
|
|
77
|
+
type: S.Literal("document"),
|
|
78
|
+
source: AnthropicDocumentSource,
|
|
79
|
+
title: S.optional(S.NullOr(S.String)),
|
|
80
|
+
context: S.optional(S.NullOr(S.String)),
|
|
81
|
+
citations: S.optional(S.Struct({ enabled: S.Boolean })),
|
|
82
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
83
|
+
});
|
|
84
|
+
/** RAG search-result blocks (citable sources supplied by the client). */
|
|
85
|
+
const AnthropicSearchResultBlock = S.Struct({
|
|
86
|
+
type: S.Literal("search_result"),
|
|
87
|
+
source: S.String,
|
|
88
|
+
title: S.String,
|
|
89
|
+
content: S.Array(AnthropicTextBlock),
|
|
90
|
+
citations: S.optional(S.Unknown),
|
|
91
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* Tool-search reference to a tool definition the model may call. Declared
|
|
95
|
+
* ahead of `AnthropicToolResultBlock` because it is one of the block types
|
|
96
|
+
* a `tool_result` may legally carry.
|
|
97
|
+
*/
|
|
98
|
+
const AnthropicToolReferenceBlock = S.Struct({
|
|
99
|
+
type: S.Literal("tool_reference"),
|
|
100
|
+
tool_name: S.String,
|
|
101
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
102
|
+
});
|
|
103
|
+
/** Code-execution container file reference (Files API upload). */
|
|
104
|
+
const AnthropicContainerUploadBlock = S.Struct({
|
|
105
|
+
type: S.Literal("container_upload"),
|
|
106
|
+
file_id: S.String,
|
|
107
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
108
|
+
});
|
|
109
|
+
const AnthropicToolUseBlock = S.Struct({
|
|
110
|
+
type: S.Literal("tool_use"),
|
|
111
|
+
id: S.String,
|
|
112
|
+
name: S.String,
|
|
113
|
+
input: S.Unknown,
|
|
114
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
115
|
+
});
|
|
116
|
+
const AnthropicToolResultBlock = S.Struct({
|
|
117
|
+
type: S.Literal("tool_result"),
|
|
118
|
+
tool_use_id: S.String,
|
|
119
|
+
// A tool_result may carry image / document / search_result blocks
|
|
120
|
+
// alongside text (e.g. a tool returning a screenshot or a retrieved
|
|
121
|
+
// document) — all normal, documented Anthropic shapes.
|
|
122
|
+
content: S.Union([
|
|
123
|
+
S.String,
|
|
124
|
+
S.Array(S.Union([
|
|
125
|
+
AnthropicTextBlock,
|
|
126
|
+
AnthropicImageBlock,
|
|
127
|
+
AnthropicDocumentBlock,
|
|
128
|
+
AnthropicSearchResultBlock,
|
|
129
|
+
AnthropicToolReferenceBlock,
|
|
130
|
+
])),
|
|
131
|
+
]),
|
|
132
|
+
is_error: S.optional(S.Boolean),
|
|
133
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
134
|
+
});
|
|
135
|
+
const AnthropicThinkingBlock = S.Struct({
|
|
136
|
+
type: S.Literal("thinking"),
|
|
137
|
+
thinking: S.String,
|
|
138
|
+
signature: S.optional(S.String),
|
|
139
|
+
});
|
|
140
|
+
/** Server-side context compaction summary blocks (Anthropic streaming + JSON responses). */
|
|
141
|
+
const AnthropicCompactionBlock = S.Struct({
|
|
142
|
+
type: S.Literal("compaction"),
|
|
143
|
+
content: S.optional(S.Unknown),
|
|
144
|
+
});
|
|
145
|
+
// ── Assistant-history block types the gateway itself emits ──────────────────
|
|
146
|
+
// Clients (e.g. Claude Code) replay the previous assistant turn verbatim as
|
|
147
|
+
// history on the next request, so every block type we (or native Anthropic
|
|
148
|
+
// passthrough) put in a response must also decode on the way back in —
|
|
149
|
+
// otherwise the routing-time parse 400s the gateway's own output (#181).
|
|
150
|
+
/** Native server-side tool call returned by genuine Anthropic passthrough. */
|
|
151
|
+
const AnthropicServerToolUseBlock = S.Struct({
|
|
152
|
+
type: S.Literal("server_tool_use"),
|
|
153
|
+
id: S.String,
|
|
154
|
+
name: S.String,
|
|
155
|
+
input: S.Unknown,
|
|
156
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
157
|
+
});
|
|
158
|
+
/** Result of a native server-side web search. `content` is the result
|
|
159
|
+
* array or a `web_search_tool_result_error` object — kept opaque: the
|
|
160
|
+
* gateway never re-parses it downstream. */
|
|
161
|
+
const AnthropicWebSearchToolResultBlock = S.Struct({
|
|
162
|
+
type: S.Literal("web_search_tool_result"),
|
|
163
|
+
tool_use_id: S.String,
|
|
164
|
+
content: S.Unknown,
|
|
165
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
166
|
+
});
|
|
167
|
+
/**
|
|
168
|
+
* Result of a native server-side tool OTHER than web search. Each of these
|
|
169
|
+
* is a block Anthropic RETURNS, which means an Anthropic-format client
|
|
170
|
+
* replays it verbatim as assistant history on the next turn — so the
|
|
171
|
+
* inbound decoder must accept every one or the gateway 400s its own
|
|
172
|
+
* upstream's output (the `server_tool_use` regression, #181, again).
|
|
173
|
+
*
|
|
174
|
+
* `content` stays OPAQUE (`S.Unknown`) exactly like
|
|
175
|
+
* `AnthropicWebSearchToolResultBlock`: the gateway never re-parses a
|
|
176
|
+
* server-tool result, and the passthrough forwards the raw body, so
|
|
177
|
+
* modelling the payload would buy nothing and could only go stale.
|
|
178
|
+
*/
|
|
179
|
+
const AnthropicWebFetchToolResultBlock = S.Struct({
|
|
180
|
+
type: S.Literal("web_fetch_tool_result"),
|
|
181
|
+
tool_use_id: S.String,
|
|
182
|
+
content: S.Unknown,
|
|
183
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
184
|
+
});
|
|
185
|
+
const AnthropicCodeExecutionToolResultBlock = S.Struct({
|
|
186
|
+
type: S.Literal("code_execution_tool_result"),
|
|
187
|
+
tool_use_id: S.String,
|
|
188
|
+
content: S.Unknown,
|
|
189
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
190
|
+
});
|
|
191
|
+
const AnthropicBashCodeExecutionToolResultBlock = S.Struct({
|
|
192
|
+
type: S.Literal("bash_code_execution_tool_result"),
|
|
193
|
+
tool_use_id: S.String,
|
|
194
|
+
content: S.Unknown,
|
|
195
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
196
|
+
});
|
|
197
|
+
const AnthropicTextEditorCodeExecutionToolResultBlock = S.Struct({
|
|
198
|
+
type: S.Literal("text_editor_code_execution_tool_result"),
|
|
199
|
+
tool_use_id: S.String,
|
|
200
|
+
content: S.Unknown,
|
|
201
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
202
|
+
});
|
|
203
|
+
const AnthropicToolSearchToolResultBlock = S.Struct({
|
|
204
|
+
type: S.Literal("tool_search_tool_result"),
|
|
205
|
+
tool_use_id: S.String,
|
|
206
|
+
content: S.Unknown,
|
|
207
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
208
|
+
});
|
|
209
|
+
const AnthropicMcpToolResultBlock = S.Struct({
|
|
210
|
+
type: S.Literal("mcp_tool_result"),
|
|
211
|
+
tool_use_id: S.String,
|
|
212
|
+
content: S.Unknown,
|
|
213
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
214
|
+
});
|
|
215
|
+
/** MCP-connector tool invocation (beta). Shaped like `tool_use` + a server name. */
|
|
216
|
+
const AnthropicMcpToolUseBlock = S.Struct({
|
|
217
|
+
type: S.Literal("mcp_tool_use"),
|
|
218
|
+
id: S.String,
|
|
219
|
+
name: S.String,
|
|
220
|
+
server_name: S.optional(S.String),
|
|
221
|
+
input: S.Unknown,
|
|
222
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
223
|
+
});
|
|
224
|
+
/** Browser tab/state snapshot emitted by the browser-use server tool. */
|
|
225
|
+
const AnthropicBrowserStateBlock = S.Struct({
|
|
226
|
+
type: S.Literal("browser_state"),
|
|
227
|
+
content: S.optional(S.Unknown),
|
|
228
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* A tool definition added mid-conversation (`inline-tools-2026-09-15` beta):
|
|
232
|
+
* Claude Code sends one per newly-available tool (e.g. an MCP server that
|
|
233
|
+
* connected late) inside a `role: "system"` turn. `tool` stays opaque — the
|
|
234
|
+
* passthrough forwards the raw body; nothing downstream re-parses it.
|
|
235
|
+
*/
|
|
236
|
+
const AnthropicToolAdditionBlock = S.Struct({
|
|
237
|
+
type: S.Literal("tool_addition"),
|
|
238
|
+
tool: S.Unknown,
|
|
239
|
+
cache_control: S.optional(S.NullOr(AnthropicCacheControl)),
|
|
240
|
+
});
|
|
241
|
+
/** Encrypted thinking returned by native Anthropic passthrough. */
|
|
242
|
+
const AnthropicRedactedThinkingBlock = S.Struct({
|
|
243
|
+
type: S.Literal("redacted_thinking"),
|
|
244
|
+
data: S.String,
|
|
245
|
+
});
|
|
246
|
+
export const AnthropicContentBlock = S.Union([
|
|
247
|
+
AnthropicTextBlock,
|
|
248
|
+
AnthropicImageBlock,
|
|
249
|
+
AnthropicDocumentBlock,
|
|
250
|
+
AnthropicSearchResultBlock,
|
|
251
|
+
AnthropicContainerUploadBlock,
|
|
252
|
+
AnthropicToolUseBlock,
|
|
253
|
+
AnthropicToolResultBlock,
|
|
254
|
+
AnthropicThinkingBlock,
|
|
255
|
+
AnthropicCompactionBlock,
|
|
256
|
+
AnthropicServerToolUseBlock,
|
|
257
|
+
AnthropicWebSearchToolResultBlock,
|
|
258
|
+
AnthropicWebFetchToolResultBlock,
|
|
259
|
+
AnthropicCodeExecutionToolResultBlock,
|
|
260
|
+
AnthropicBashCodeExecutionToolResultBlock,
|
|
261
|
+
AnthropicTextEditorCodeExecutionToolResultBlock,
|
|
262
|
+
AnthropicToolSearchToolResultBlock,
|
|
263
|
+
AnthropicMcpToolUseBlock,
|
|
264
|
+
AnthropicMcpToolResultBlock,
|
|
265
|
+
AnthropicToolReferenceBlock,
|
|
266
|
+
AnthropicBrowserStateBlock,
|
|
267
|
+
AnthropicToolAdditionBlock,
|
|
268
|
+
AnthropicRedactedThinkingBlock,
|
|
269
|
+
]);
|
|
270
|
+
export const AnthropicMessage = S.Struct({
|
|
271
|
+
// `system` joins `user`/`assistant` as of the Claude 4.8-era clients
|
|
272
|
+
// (Claude Code v2.1.157+), which inline a system turn in `messages[]`
|
|
273
|
+
// when the `mid-conversation-system-2026-04-07` beta is active —
|
|
274
|
+
// exactly the beta we started forwarding correctly in PR #12. Anthropic
|
|
275
|
+
// ACCEPTS that shape under the beta, so the routing-time parse must
|
|
276
|
+
// accept it too or `/v1/messages` 400s before we can forward.
|
|
277
|
+
// - Passthrough (anthropic / claude_code first hop): the raw body
|
|
278
|
+
// is forwarded verbatim with the beta header, and Anthropic
|
|
279
|
+
// honours the inline system turn — this literal just stops our
|
|
280
|
+
// own parse from rejecting it.
|
|
281
|
+
// - Cross-provider fallback hop: `splitAnthropicMessage` in
|
|
282
|
+
// `adapters/messages/request.ts` maps the inline system turn to
|
|
283
|
+
// the canonical `system` role for the non-Anthropic upstream.
|
|
284
|
+
role: S.Literals(["user", "assistant", "system"]),
|
|
285
|
+
content: S.Union([S.String, S.Array(AnthropicContentBlock)]),
|
|
286
|
+
});
|
|
287
|
+
const AnthropicSystemBlock = S.Union([S.String, S.Array(AnthropicTextBlock)]);
|
|
288
|
+
// `disable_parallel_tool_use` is documented on auto / any / tool (never on
|
|
289
|
+
// `none`). Modelled rather than merely tolerated because it is the one
|
|
290
|
+
// tool_choice field with a canonical counterpart — OpenAI's
|
|
291
|
+
// `parallel_tool_calls` — so the adapters map it in both directions
|
|
292
|
+
// instead of silently discarding the client's intent on a cross-wire hop.
|
|
293
|
+
const AnthropicToolChoice = S.Union([
|
|
294
|
+
S.Struct({
|
|
295
|
+
type: S.Literal("auto"),
|
|
296
|
+
disable_parallel_tool_use: S.optional(S.Boolean),
|
|
297
|
+
}),
|
|
298
|
+
S.Struct({
|
|
299
|
+
type: S.Literal("any"),
|
|
300
|
+
disable_parallel_tool_use: S.optional(S.Boolean),
|
|
301
|
+
}),
|
|
302
|
+
S.Struct({
|
|
303
|
+
type: S.Literal("tool"),
|
|
304
|
+
name: S.String,
|
|
305
|
+
disable_parallel_tool_use: S.optional(S.Boolean),
|
|
306
|
+
}),
|
|
307
|
+
S.Struct({ type: S.Literal("none") }),
|
|
308
|
+
]);
|
|
309
|
+
/**
|
|
310
|
+
* Extended-thinking knob. `enabled` carries an explicit budget;
|
|
311
|
+
* `adaptive` lets Claude 4.6+ decide the budget itself (paired with
|
|
312
|
+
* `output_config.effort` to set the target effort level).
|
|
313
|
+
*/
|
|
314
|
+
export const AnthropicThinking = S.Union([
|
|
315
|
+
S.Struct({
|
|
316
|
+
type: S.Literal("enabled"),
|
|
317
|
+
budget_tokens: S.Number,
|
|
318
|
+
}),
|
|
319
|
+
S.Struct({ type: S.Literal("adaptive") }),
|
|
320
|
+
// `disabled` is accepted by every model that is not "always on"
|
|
321
|
+
// (Opus 4.8 / Opus 5 / Sonnet 5 / the 4.6 and 4.5 generations). Omitting
|
|
322
|
+
// it from this union did not make the gateway lenient — it made the
|
|
323
|
+
// gateway 400 a supported configuration before dispatch, on both the
|
|
324
|
+
// cloud handler and the daemon listener.
|
|
325
|
+
S.Struct({ type: S.Literal("disabled") }),
|
|
326
|
+
]);
|
|
327
|
+
/**
|
|
328
|
+
* Adaptive-thinking effort levels Anthropic accepts on
|
|
329
|
+
* `output_config.effort`. Only honoured by Claude 4.6+; other models
|
|
330
|
+
* 400 if this is set (see `providers/anthropic/adaptive-thinking.ts`).
|
|
331
|
+
*/
|
|
332
|
+
export const AnthropicEffort = S.Literals([
|
|
333
|
+
"minimal",
|
|
334
|
+
"low",
|
|
335
|
+
"medium",
|
|
336
|
+
"high",
|
|
337
|
+
"xhigh",
|
|
338
|
+
"max",
|
|
339
|
+
]);
|
|
340
|
+
export const AnthropicOutputConfig = S.Struct({
|
|
341
|
+
effort: S.optional(AnthropicEffort),
|
|
342
|
+
});
|
|
343
|
+
export const AnthropicRequest = S.Struct({
|
|
344
|
+
model: S.String,
|
|
345
|
+
messages: S.Array(AnthropicMessage),
|
|
346
|
+
max_tokens: S.Number,
|
|
347
|
+
system: S.optional(AnthropicSystemBlock),
|
|
348
|
+
temperature: S.optional(S.Number),
|
|
349
|
+
top_p: S.optional(S.Number),
|
|
350
|
+
top_k: S.optional(S.Number),
|
|
351
|
+
stop_sequences: S.optional(S.Array(S.String)),
|
|
352
|
+
stream: S.optional(S.Boolean),
|
|
353
|
+
tools: S.optional(S.Array(AnthropicTool)),
|
|
354
|
+
tool_choice: S.optional(AnthropicToolChoice),
|
|
355
|
+
metadata: S.optional(S.Struct({ user_id: S.optional(S.String) })),
|
|
356
|
+
thinking: S.optional(AnthropicThinking),
|
|
357
|
+
output_config: S.optional(AnthropicOutputConfig),
|
|
358
|
+
});
|
|
359
|
+
/**
|
|
360
|
+
* `POST /v1/messages/count_tokens` — the Messages request with `max_tokens`
|
|
361
|
+
* OPTIONAL. The count endpoint has no output budget, so a real Claude Code
|
|
362
|
+
* preflight omits it; validating those bodies against `AnthropicRequest` would
|
|
363
|
+
* 400 every one of them.
|
|
364
|
+
*/
|
|
365
|
+
export const AnthropicCountTokensRequest = S.Struct({
|
|
366
|
+
...AnthropicRequest.fields,
|
|
367
|
+
max_tokens: S.optional(S.Number),
|
|
368
|
+
});
|
|
369
|
+
// ─── Anthropic wire types — response ─────────────────────────────────────────
|
|
370
|
+
export const AnthropicStopReason = S.Literals([
|
|
371
|
+
"end_turn",
|
|
372
|
+
"max_tokens",
|
|
373
|
+
"stop_sequence",
|
|
374
|
+
"tool_use",
|
|
375
|
+
"pause_turn",
|
|
376
|
+
"refusal",
|
|
377
|
+
// The response filled the model's context window. Absent from this
|
|
378
|
+
// union, the terminal `message_delta` carrying it failed decode and was
|
|
379
|
+
// DROPPED by `decodeProviderEventStream` — taking the finish reason and
|
|
380
|
+
// the whole usage trailer with it, so a cross-wire stream ended with no
|
|
381
|
+
// stop reason and zero tokens.
|
|
382
|
+
"model_context_window_exceeded",
|
|
383
|
+
]);
|
|
384
|
+
/** Server-tool activity counters. Clients (Claude Code's WebSearch) read
|
|
385
|
+
* `web_search_requests` to count searches — set both by genuine Anthropic
|
|
386
|
+
* passthrough and by the gateway's cross-wire re-encode of provider-hosted
|
|
387
|
+
* search (`server_search_calls`). ONE definition shared by the response
|
|
388
|
+
* usage and the terminal `message_delta` usage so the two can't drift. */
|
|
389
|
+
const AnthropicServerToolUseUsage = S.Struct({
|
|
390
|
+
web_search_requests: S.optional(S.Number),
|
|
391
|
+
});
|
|
392
|
+
export const AnthropicUsage = S.Struct({
|
|
393
|
+
input_tokens: S.Number,
|
|
394
|
+
output_tokens: S.Number,
|
|
395
|
+
cache_creation_input_tokens: S.optional(S.NullOr(S.Number)),
|
|
396
|
+
cache_read_input_tokens: S.optional(S.NullOr(S.Number)),
|
|
397
|
+
server_tool_use: S.optional(S.NullOr(AnthropicServerToolUseUsage)),
|
|
398
|
+
});
|
|
399
|
+
export const AnthropicResponse = S.Struct({
|
|
400
|
+
id: S.String,
|
|
401
|
+
type: S.Literal("message"),
|
|
402
|
+
role: S.Literal("assistant"),
|
|
403
|
+
model: S.String,
|
|
404
|
+
content: S.Array(AnthropicContentBlock),
|
|
405
|
+
stop_reason: S.NullOr(AnthropicStopReason),
|
|
406
|
+
stop_sequence: S.NullOr(S.String),
|
|
407
|
+
usage: AnthropicUsage,
|
|
408
|
+
});
|
|
409
|
+
// ─── Anthropic wire types — streaming events ─────────────────────────────────
|
|
410
|
+
const AnthropicMessageStartEvent = S.Struct({
|
|
411
|
+
type: S.Literal("message_start"),
|
|
412
|
+
message: S.Struct({
|
|
413
|
+
id: S.String,
|
|
414
|
+
type: S.Literal("message"),
|
|
415
|
+
role: S.Literal("assistant"),
|
|
416
|
+
model: S.String,
|
|
417
|
+
content: S.Array(AnthropicContentBlock),
|
|
418
|
+
stop_reason: S.NullOr(AnthropicStopReason),
|
|
419
|
+
stop_sequence: S.NullOr(S.String),
|
|
420
|
+
usage: AnthropicUsage,
|
|
421
|
+
}),
|
|
422
|
+
});
|
|
423
|
+
const AnthropicContentBlockStartEvent = S.Struct({
|
|
424
|
+
type: S.Literal("content_block_start"),
|
|
425
|
+
index: S.Number,
|
|
426
|
+
content_block: AnthropicContentBlock,
|
|
427
|
+
});
|
|
428
|
+
const AnthropicTextDelta = S.Struct({
|
|
429
|
+
type: S.Literal("text_delta"),
|
|
430
|
+
text: S.String,
|
|
431
|
+
});
|
|
432
|
+
const AnthropicInputJsonDelta = S.Struct({
|
|
433
|
+
type: S.Literal("input_json_delta"),
|
|
434
|
+
partial_json: S.String,
|
|
435
|
+
});
|
|
436
|
+
const AnthropicThinkingDelta = S.Struct({
|
|
437
|
+
type: S.Literal("thinking_delta"),
|
|
438
|
+
thinking: S.String,
|
|
439
|
+
});
|
|
440
|
+
const AnthropicSignatureDelta = S.Struct({
|
|
441
|
+
type: S.Literal("signature_delta"),
|
|
442
|
+
signature: S.String,
|
|
443
|
+
});
|
|
444
|
+
const AnthropicCompactionDelta = S.Struct({
|
|
445
|
+
type: S.Literal("compaction_delta"),
|
|
446
|
+
content: S.optional(S.Unknown),
|
|
447
|
+
});
|
|
448
|
+
/** Streamed citation attachment for a text block (document citations
|
|
449
|
+
* enabled) — kept opaque; only decoded (non-passthrough) streams see it. */
|
|
450
|
+
const AnthropicCitationsDelta = S.Struct({
|
|
451
|
+
type: S.Literal("citations_delta"),
|
|
452
|
+
citation: S.Unknown,
|
|
453
|
+
});
|
|
454
|
+
const AnthropicContentBlockDeltaEvent = S.Struct({
|
|
455
|
+
type: S.Literal("content_block_delta"),
|
|
456
|
+
index: S.Number,
|
|
457
|
+
delta: S.Union([
|
|
458
|
+
AnthropicTextDelta,
|
|
459
|
+
AnthropicInputJsonDelta,
|
|
460
|
+
AnthropicThinkingDelta,
|
|
461
|
+
AnthropicSignatureDelta,
|
|
462
|
+
AnthropicCompactionDelta,
|
|
463
|
+
AnthropicCitationsDelta,
|
|
464
|
+
]),
|
|
465
|
+
});
|
|
466
|
+
const AnthropicContentBlockStopEvent = S.Struct({
|
|
467
|
+
type: S.Literal("content_block_stop"),
|
|
468
|
+
index: S.Number,
|
|
469
|
+
});
|
|
470
|
+
const AnthropicMessageDeltaEvent = S.Struct({
|
|
471
|
+
type: S.Literal("message_delta"),
|
|
472
|
+
delta: S.Struct({
|
|
473
|
+
stop_reason: S.NullOr(AnthropicStopReason),
|
|
474
|
+
stop_sequence: S.NullOr(S.String),
|
|
475
|
+
}),
|
|
476
|
+
usage: S.Struct({
|
|
477
|
+
output_tokens: S.Number,
|
|
478
|
+
input_tokens: S.optional(S.NullOr(S.Number)),
|
|
479
|
+
cache_creation_input_tokens: S.optional(S.NullOr(S.Number)),
|
|
480
|
+
cache_read_input_tokens: S.optional(S.NullOr(S.Number)),
|
|
481
|
+
/** Server-tool counters on the terminal delta (mirrors `AnthropicUsage`). */
|
|
482
|
+
server_tool_use: S.optional(S.NullOr(AnthropicServerToolUseUsage)),
|
|
483
|
+
}),
|
|
484
|
+
});
|
|
485
|
+
const AnthropicMessageStopEvent = S.Struct({
|
|
486
|
+
type: S.Literal("message_stop"),
|
|
487
|
+
});
|
|
488
|
+
const AnthropicPingEvent = S.Struct({ type: S.Literal("ping") });
|
|
489
|
+
const AnthropicErrorEvent = S.Struct({
|
|
490
|
+
type: S.Literal("error"),
|
|
491
|
+
error: S.Struct({ type: S.String, message: S.String }),
|
|
492
|
+
});
|
|
493
|
+
export const AnthropicStreamEvent = S.Union([
|
|
494
|
+
AnthropicMessageStartEvent,
|
|
495
|
+
AnthropicContentBlockStartEvent,
|
|
496
|
+
AnthropicContentBlockDeltaEvent,
|
|
497
|
+
AnthropicContentBlockStopEvent,
|
|
498
|
+
AnthropicMessageDeltaEvent,
|
|
499
|
+
AnthropicMessageStopEvent,
|
|
500
|
+
AnthropicPingEvent,
|
|
501
|
+
AnthropicErrorEvent,
|
|
502
|
+
]);
|
|
503
|
+
// ─── Anthropic provider options ──────────────────────────────────────────────
|
|
504
|
+
export const AnthropicProviderOptions = S.Struct({
|
|
505
|
+
providerModelId: S.String,
|
|
506
|
+
apiVersion: S.optional(S.String),
|
|
507
|
+
defaultMaxTokens: S.optional(S.Number),
|
|
508
|
+
/**
|
|
509
|
+
* The resolved model card's caps. Carries `thinkingModes`, which is how
|
|
510
|
+
* the encoder learns which thinking mode this model accepts WITHOUT the
|
|
511
|
+
* wire package knowing any model names. Absent = unknown = permissive.
|
|
512
|
+
*/
|
|
513
|
+
caps: S.optional(ModelCaps),
|
|
514
|
+
});
|
|
515
|
+
// ─── Google AI Studio — image generation (Nano Banana / Imagen) ──────────────
|
|
516
|
+
// generativelanguage.googleapis.com/v1beta returns image bytes inline.
|
|
517
|
+
const GoogleImageInlineData = S.Struct({
|
|
518
|
+
mime_type: S.optional(S.String),
|
|
519
|
+
mimeType: S.optional(S.String),
|
|
520
|
+
data: S.String,
|
|
521
|
+
});
|
|
522
|
+
const GoogleImagePart = S.Union([
|
|
523
|
+
S.Struct({ text: S.String }),
|
|
524
|
+
S.Struct({ inlineData: GoogleImageInlineData }),
|
|
525
|
+
]);
|
|
526
|
+
const GoogleImageCandidate = S.Struct({
|
|
527
|
+
content: S.optional(S.Struct({
|
|
528
|
+
parts: S.optional(S.Array(GoogleImagePart)),
|
|
529
|
+
role: S.optional(S.String),
|
|
530
|
+
})),
|
|
531
|
+
finishReason: S.optional(S.NullOr(S.String)),
|
|
532
|
+
});
|
|
533
|
+
export const GoogleImageRequest = S.Struct({
|
|
534
|
+
contents: S.Array(S.Struct({
|
|
535
|
+
parts: S.Array(S.Struct({ text: S.String })),
|
|
536
|
+
})),
|
|
537
|
+
generationConfig: S.Struct({
|
|
538
|
+
response_modalities: S.Array(S.String),
|
|
539
|
+
// Gemini's generateContent nests aspect ratio under `imageConfig`;
|
|
540
|
+
// there is no `sampleCount` (it returns one image per call). Sending
|
|
541
|
+
// `sampleCount`/`aspectRatio` at the generationConfig top level 400s
|
|
542
|
+
// with "Unknown name ... at 'generation_config'".
|
|
543
|
+
imageConfig: S.optional(S.Struct({
|
|
544
|
+
aspectRatio: S.optional(S.String),
|
|
545
|
+
})),
|
|
546
|
+
}),
|
|
547
|
+
});
|
|
548
|
+
const GoogleImageUsageMetadata = S.Struct({
|
|
549
|
+
promptTokenCount: S.optional(S.NullOr(S.Number)),
|
|
550
|
+
candidatesTokenCount: S.optional(S.NullOr(S.Number)),
|
|
551
|
+
totalTokenCount: S.optional(S.NullOr(S.Number)),
|
|
552
|
+
cachedContentTokenCount: S.optional(S.NullOr(S.Number)),
|
|
553
|
+
});
|
|
554
|
+
export const GoogleImageResponse = S.Struct({
|
|
555
|
+
candidates: S.optional(S.Array(GoogleImageCandidate)),
|
|
556
|
+
usageMetadata: S.optional(GoogleImageUsageMetadata),
|
|
557
|
+
});
|
|
558
|
+
export const GoogleImageProviderOptions = S.Struct({
|
|
559
|
+
providerModelId: S.String,
|
|
560
|
+
/**
|
|
561
|
+
* Catalog-resolved facts for THIS model. Absent means unknown, and an
|
|
562
|
+
* unknown limit never manufactures a refusal.
|
|
563
|
+
*/
|
|
564
|
+
caps: S.optional(ModelCaps),
|
|
565
|
+
});
|
|
566
|
+
// ─── OpenAI — video generation (Sora, async job surface) ─────────────────────
|
|
567
|
+
// The upstream video job object returned by POST /v1/videos and
|
|
568
|
+
// GET /v1/videos/{id}. Kept lenient — `status` stays a plain string so
|
|
569
|
+
// an unrecognized upstream state degrades to `in_progress` in the
|
|
570
|
+
// provider's fromBody instead of failing schema decode.
|
|
571
|
+
export const OpenAIVideoJob = S.Struct({
|
|
572
|
+
id: S.String,
|
|
573
|
+
status: S.String,
|
|
574
|
+
created_at: S.optional(S.Number),
|
|
575
|
+
progress: S.optional(S.NullOr(S.Number)),
|
|
576
|
+
seconds: S.optional(S.Union([S.String, S.Number])),
|
|
577
|
+
size: S.optional(S.String),
|
|
578
|
+
error: S.optional(S.NullOr(S.Struct({
|
|
579
|
+
code: S.optional(S.String),
|
|
580
|
+
message: S.optional(S.String),
|
|
581
|
+
}))),
|
|
582
|
+
});
|
|
583
|
+
export const OpenAIVideoProviderOptions = S.Struct({
|
|
584
|
+
providerModelId: S.String,
|
|
585
|
+
});
|
|
586
|
+
// ─── Google AI Studio — video generation (Veo, predictLongRunning) ──────────
|
|
587
|
+
/**
|
|
588
|
+
* Veo's `predictLongRunning` image shape on the Gemini DEVELOPER API.
|
|
589
|
+
*
|
|
590
|
+
* Source of truth is Google's own client, not the REST snippets in the
|
|
591
|
+
* Veo guide (which show `inlineData` and are contradicted by the live
|
|
592
|
+
* surface — it answers 400 INVALID_ARGUMENT "`inlineData` isn't
|
|
593
|
+
* supported by this model"). `googleapis/python-genai` v2.24.0,
|
|
594
|
+
* `google/genai/models.py::_Image_to_mldev`, serializes
|
|
595
|
+
* `Image.image_bytes` → `bytesBase64Encoded` and `Image.mime_type` →
|
|
596
|
+
* `mimeType` for Developer-API mode (`gcs_uri` raises there), and
|
|
597
|
+
* `_GenerateVideosParameters_to_mldev` places that object at
|
|
598
|
+
* `instances[0].image`, with `_VideoGenerationReferenceImage_to_mldev`
|
|
599
|
+
* reusing it for `instances[0].referenceImages[].image`.
|
|
600
|
+
*/
|
|
601
|
+
export const GoogleVideoImage = S.Struct({
|
|
602
|
+
bytesBase64Encoded: S.String,
|
|
603
|
+
mimeType: S.String,
|
|
604
|
+
});
|
|
605
|
+
export const GoogleVideoCreateRequest = S.Struct({
|
|
606
|
+
instances: S.Array(S.Struct({
|
|
607
|
+
prompt: S.String,
|
|
608
|
+
image: S.optional(GoogleVideoImage),
|
|
609
|
+
referenceImages: S.optional(S.Array(S.Struct({
|
|
610
|
+
image: GoogleVideoImage,
|
|
611
|
+
referenceType: S.Literal("asset"),
|
|
612
|
+
}))),
|
|
613
|
+
})),
|
|
614
|
+
parameters: S.Struct({
|
|
615
|
+
aspectRatio: S.optional(S.String),
|
|
616
|
+
resolution: S.optional(S.String),
|
|
617
|
+
durationSeconds: S.optional(S.Number),
|
|
618
|
+
}),
|
|
619
|
+
});
|
|
620
|
+
// predictLongRunning returns a bare long-running-operation handle.
|
|
621
|
+
export const GoogleVideoOperationRef = S.Struct({
|
|
622
|
+
name: S.String,
|
|
623
|
+
});
|
|
624
|
+
// GET /v1beta/{operation.name} — the poll envelope. `response` is left
|
|
625
|
+
// opaque; the provider extracts the generated video URI with a typed
|
|
626
|
+
// walker (`generateVideoResponse.generatedSamples[0].video.uri`, with a
|
|
627
|
+
// `generatedVideos` fallback some Veo revisions use).
|
|
628
|
+
export const GoogleVideoOperation = S.Struct({
|
|
629
|
+
name: S.optional(S.String),
|
|
630
|
+
done: S.optional(S.Boolean),
|
|
631
|
+
error: S.optional(S.Struct({
|
|
632
|
+
code: S.optional(S.Number),
|
|
633
|
+
message: S.optional(S.String),
|
|
634
|
+
})),
|
|
635
|
+
response: S.optional(S.Unknown),
|
|
636
|
+
});
|
|
637
|
+
export const GoogleVideoProviderOptions = S.Struct({
|
|
638
|
+
providerModelId: S.String,
|
|
639
|
+
/**
|
|
640
|
+
* Catalog-resolved facts for THIS model (accepted durations, ratios,
|
|
641
|
+
* resolutions, reference limits). Absent means unknown, and an
|
|
642
|
+
* unknown limit never manufactures a refusal.
|
|
643
|
+
*/
|
|
644
|
+
caps: S.optional(ModelCaps),
|
|
645
|
+
});
|
|
646
|
+
// ─── Bedrock — Amazon Titan v2 embeddings ────────────────────────────────────
|
|
647
|
+
export const BedrockTitanV2Request = S.Struct({
|
|
648
|
+
inputText: S.String,
|
|
649
|
+
dimensions: S.optional(S.Number),
|
|
650
|
+
normalize: S.optional(S.Boolean),
|
|
651
|
+
embeddingTypes: S.optional(S.Array(S.Literals(["float", "binary"]))),
|
|
652
|
+
});
|
|
653
|
+
const BedrockTitanV2EmbeddingsByType = S.Struct({
|
|
654
|
+
float: S.optional(S.Array(S.Number)),
|
|
655
|
+
binary: S.optional(S.Array(S.Number)),
|
|
656
|
+
});
|
|
657
|
+
export const BedrockTitanV2Response = S.Struct({
|
|
658
|
+
embedding: S.optional(S.Array(S.Number)),
|
|
659
|
+
embeddingsByType: S.optional(BedrockTitanV2EmbeddingsByType),
|
|
660
|
+
inputTextTokenCount: S.Number,
|
|
661
|
+
});
|
|
662
|
+
export const BedrockEmbedProviderOptions = S.Struct({
|
|
663
|
+
providerModelId: S.String,
|
|
664
|
+
region: S.String,
|
|
665
|
+
accessKeyId: S.String,
|
|
666
|
+
secretAccessKey: S.String,
|
|
667
|
+
sessionToken: S.optional(S.String),
|
|
668
|
+
dimensions: S.optional(S.Number),
|
|
669
|
+
normalize: S.optional(S.Boolean),
|
|
670
|
+
});
|
|
671
|
+
// ─── ChatGPT (Codex / Responses) provider options ────────────────────────────
|
|
672
|
+
/**
|
|
673
|
+
* Options for the `chatgpt` provider — chatgpt.com/backend-api/codex.
|
|
674
|
+
*
|
|
675
|
+
* `accountId` / `sessionId` ride in outbound headers per the Codex CLI
|
|
676
|
+
* convention; both are pulled from the decrypted OAuth blob's `extras`.
|
|
677
|
+
* `originator` and `userAgent` are server-tunable via environment
|
|
678
|
+
* variables; defaults match the reference Python implementation.
|
|
679
|
+
*/
|
|
680
|
+
export const ChatGptProviderOptions = S.Struct({
|
|
681
|
+
providerModelId: S.String,
|
|
682
|
+
accountId: S.optional(S.String),
|
|
683
|
+
sessionId: S.optional(S.String),
|
|
684
|
+
originator: S.optional(S.String),
|
|
685
|
+
userAgent: S.optional(S.String),
|
|
686
|
+
/**
|
|
687
|
+
* Select Codex-specific Responses-wire behavior. When `false` for a
|
|
688
|
+
* non-Codex provider that shares the wire (xAI Grok),
|
|
689
|
+
* `max_output_tokens` is forwarded; ChatGPT/Codex rejects that field.
|
|
690
|
+
* System messages always become `developer` input items and never alter
|
|
691
|
+
* top-level `instructions`, regardless of this flag. Defaults to TRUE when
|
|
692
|
+
* omitted; the daemon walker passes `false` for non-`chatgpt`
|
|
693
|
+
* Responses-wire providers.
|
|
694
|
+
*/
|
|
695
|
+
codexInstructions: S.optional(S.Boolean),
|
|
696
|
+
/**
|
|
697
|
+
* The resolved model card's caps. Carries `reasoningContexts`, which is how
|
|
698
|
+
* the encoder learns that a model rejects `reasoning.context: "all_turns"`
|
|
699
|
+
* — a fact it used to derive from a `spark` suffix on the model id. Absent
|
|
700
|
+
* = unknown = permissive.
|
|
701
|
+
*/
|
|
702
|
+
caps: S.optional(ModelCaps),
|
|
703
|
+
});
|
|
704
|
+
// ─── Kimi Code provider options ──────────────────────────────────────────────
|
|
705
|
+
//
|
|
706
|
+
// Identity fields are populated by the LOCAL DAEMON from the official
|
|
707
|
+
// Kimi CLI's own headers (User-Agent + X-Msh-*), so upstream calls carry
|
|
708
|
+
// the real client identity rather than a synthesized one. All optional —
|
|
709
|
+
// absent on any non-daemon caller, in which case `kimiCodeAuthHeaders`
|
|
710
|
+
// sends only auth + content headers (no fabricated X-Msh-* device fields).
|
|
711
|
+
export const KimiCodeProviderOptions = S.Struct({
|
|
712
|
+
providerModelId: S.String,
|
|
713
|
+
userAgent: S.optional(S.String),
|
|
714
|
+
platform: S.optional(S.String),
|
|
715
|
+
version: S.optional(S.String),
|
|
716
|
+
deviceId: S.optional(S.String),
|
|
717
|
+
deviceName: S.optional(S.String),
|
|
718
|
+
deviceModel: S.optional(S.String),
|
|
719
|
+
osVersion: S.optional(S.String),
|
|
720
|
+
});
|
|
721
|
+
// (ChatGPT device-code OAuth wire types removed — subscription sign-in is
|
|
722
|
+
// the official Codex CLI's job, delegated by the local daemon; the gateway
|
|
723
|
+
// no longer runs any OAuth/device-code/token-exchange flow.)
|