omnicell-router 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -7
- package/README.zh-CN.md +18 -5
- package/backend/dist/auth/api-keys.js +11 -0
- package/backend/dist/auth/key-models.d.ts +36 -0
- package/backend/dist/auth/key-models.js +99 -0
- package/backend/dist/capture/recorder.d.ts +4 -10
- package/backend/dist/capture/recorder.js +6 -58
- package/backend/dist/cli/clients/activity.js +2 -0
- package/backend/dist/cli/clients/base.d.ts +36 -11
- package/backend/dist/cli/clients/base.js +31 -15
- package/backend/dist/cli/clients/claude.d.ts +9 -0
- package/backend/dist/cli/clients/claude.js +6 -0
- package/backend/dist/cli/clients/codex.d.ts +78 -0
- package/backend/dist/cli/clients/codex.js +475 -57
- package/backend/dist/cli/clients/core-adapters.d.ts +1 -1
- package/backend/dist/cli/clients/core-adapters.js +1 -1
- package/backend/dist/cli/clients/dsh.d.ts +8 -0
- package/backend/dist/cli/clients/dsh.js +5 -0
- package/backend/dist/cli/clients/follow-catalog-sync.d.ts +62 -0
- package/backend/dist/cli/clients/follow-catalog-sync.js +435 -0
- package/backend/dist/cli/clients/grok.d.ts +15 -1
- package/backend/dist/cli/clients/grok.js +16 -2
- package/backend/dist/cli/clients/index.d.ts +13 -1
- package/backend/dist/cli/clients/index.js +97 -19
- package/backend/dist/cli/clients/kimi.d.ts +6 -0
- package/backend/dist/cli/clients/kimi.js +3 -0
- package/backend/dist/cli/clients/launcher.d.ts +1 -1
- package/backend/dist/cli/clients/model-meta.js +6 -3
- package/backend/dist/cli/clients/omp.d.ts +6 -0
- package/backend/dist/cli/clients/omp.js +3 -0
- package/backend/dist/cli/clients/openclaw.d.ts +6 -0
- package/backend/dist/cli/clients/openclaw.js +3 -0
- package/backend/dist/cli/clients/opencode.d.ts +8 -0
- package/backend/dist/cli/clients/opencode.js +8 -2
- package/backend/dist/cli/clients/pi.d.ts +6 -0
- package/backend/dist/cli/clients/pi.js +3 -0
- package/backend/dist/cli/clients/reserved.js +2 -0
- package/backend/dist/cli/clients/update-check.d.ts +37 -0
- package/backend/dist/cli/clients/update-check.js +309 -0
- package/backend/dist/cli/clients/workbuddy.d.ts +19 -0
- package/backend/dist/cli/clients/workbuddy.js +66 -0
- package/backend/dist/cli/index.js +5 -4
- package/backend/dist/cli/paths.js +8 -0
- package/backend/dist/cli/types.d.ts +101 -16
- package/backend/dist/config/comments-en.js +34 -25
- package/backend/dist/config/comments-zh.js +33 -24
- package/backend/dist/config/defaults.d.ts +280 -22
- package/backend/dist/config/defaults.js +279 -21
- package/backend/dist/config/env.d.ts +10 -0
- package/backend/dist/config/env.js +3 -2
- package/backend/dist/config/index.d.ts +22 -1
- package/backend/dist/config/index.js +218 -43
- package/backend/dist/config/migrations/v0-to-v1.d.ts +2 -2
- package/backend/dist/config/migrations/v10-to-v11.d.ts +38 -0
- package/backend/dist/config/migrations/v10-to-v11.js +43 -0
- package/backend/dist/config/migrations/v4-to-v5.d.ts +36 -0
- package/backend/dist/config/migrations/v4-to-v5.js +42 -0
- package/backend/dist/config/migrations/v5-to-v6.d.ts +27 -0
- package/backend/dist/config/migrations/v5-to-v6.js +29 -0
- package/backend/dist/config/migrations/v6-to-v7.d.ts +45 -0
- package/backend/dist/config/migrations/v6-to-v7.js +97 -0
- package/backend/dist/config/migrations/v7-to-v8.d.ts +36 -0
- package/backend/dist/config/migrations/v7-to-v8.js +43 -0
- package/backend/dist/config/migrations/v8-to-v9.d.ts +38 -0
- package/backend/dist/config/migrations/v8-to-v9.js +43 -0
- package/backend/dist/config/migrations/v9-to-v10.d.ts +51 -0
- package/backend/dist/config/migrations/v9-to-v10.js +71 -0
- package/backend/dist/config/runtime.js +1 -1
- package/backend/dist/config/schema.d.ts +3 -3
- package/backend/dist/config/schema.js +18 -4
- package/backend/dist/config/types.d.ts +221 -41
- package/backend/dist/egress-proxy/asset-download.d.ts +54 -0
- package/backend/dist/egress-proxy/asset-download.js +420 -0
- package/backend/dist/egress-proxy/manual-node-spec.d.ts +92 -0
- package/backend/dist/egress-proxy/manual-node-spec.js +408 -0
- package/backend/dist/egress-proxy/mihomo-binary.d.ts +54 -0
- package/backend/dist/egress-proxy/mihomo-binary.js +278 -0
- package/backend/dist/egress-proxy/mihomo-client.d.ts +94 -0
- package/backend/dist/egress-proxy/mihomo-client.js +308 -0
- package/backend/dist/egress-proxy/mihomo-config.d.ts +40 -0
- package/backend/dist/egress-proxy/mihomo-config.js +161 -0
- package/backend/dist/egress-proxy/mihomo-geo.d.ts +87 -0
- package/backend/dist/egress-proxy/mihomo-geo.js +213 -0
- package/backend/dist/egress-proxy/mihomo-logs.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-logs.js +84 -0
- package/backend/dist/egress-proxy/mihomo-pac.d.ts +37 -0
- package/backend/dist/egress-proxy/mihomo-pac.js +75 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.d.ts +43 -0
- package/backend/dist/egress-proxy/mihomo-rules-import.js +193 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.d.ts +81 -0
- package/backend/dist/egress-proxy/mihomo-sidecar.js +637 -0
- package/backend/dist/forward-proxy/egress.d.ts +50 -11
- package/backend/dist/forward-proxy/egress.js +63 -17
- package/backend/dist/forward-proxy/h2-forward.js +42 -15
- package/backend/dist/forward-proxy/index.d.ts +11 -8
- package/backend/dist/forward-proxy/index.js +27 -60
- package/backend/dist/forward-proxy/interceptor.d.ts +3 -2
- package/backend/dist/forward-proxy/interceptor.js +4 -4
- package/backend/dist/forward-proxy/relay.js +3 -3
- package/backend/dist/forward-proxy/rules.d.ts +4 -4
- package/backend/dist/forward-proxy/rules.js +25 -4
- package/backend/dist/forward-proxy/server.d.ts +12 -16
- package/backend/dist/forward-proxy/server.js +237 -171
- package/backend/dist/harness/host/hosts.js +3 -2
- package/backend/dist/index.js +59 -19
- package/backend/dist/ingress-proxy/access-log.d.ts +176 -0
- package/backend/dist/ingress-proxy/access-log.js +774 -0
- package/backend/dist/ingress-proxy/ca-inventory.d.ts +106 -0
- package/backend/dist/ingress-proxy/ca-inventory.js +525 -0
- package/backend/dist/ingress-proxy/ca-trust.d.ts +96 -0
- package/backend/dist/ingress-proxy/ca-trust.js +315 -0
- package/backend/dist/ingress-proxy/ca.d.ts +104 -0
- package/backend/dist/ingress-proxy/ca.js +273 -0
- package/backend/dist/ingress-proxy/data-dir.d.ts +28 -0
- package/backend/dist/ingress-proxy/data-dir.js +45 -0
- package/backend/dist/ingress-proxy/egress.d.ts +151 -0
- package/backend/dist/ingress-proxy/egress.js +364 -0
- package/backend/dist/ingress-proxy/h2-forward.d.ts +66 -0
- package/backend/dist/ingress-proxy/h2-forward.js +561 -0
- package/backend/dist/ingress-proxy/index.d.ts +24 -0
- package/backend/dist/ingress-proxy/index.js +144 -0
- package/backend/dist/ingress-proxy/interceptor.d.ts +25 -0
- package/backend/dist/ingress-proxy/interceptor.js +52 -0
- package/backend/dist/ingress-proxy/ordered-relay.d.ts +29 -0
- package/backend/dist/ingress-proxy/ordered-relay.js +46 -0
- package/backend/dist/ingress-proxy/relay.d.ts +54 -0
- package/backend/dist/ingress-proxy/relay.js +188 -0
- package/backend/dist/ingress-proxy/rules.d.ts +195 -0
- package/backend/dist/ingress-proxy/rules.js +348 -0
- package/backend/dist/ingress-proxy/server.d.ts +153 -0
- package/backend/dist/ingress-proxy/server.js +2065 -0
- package/backend/dist/ingress-proxy/sni.d.ts +35 -0
- package/backend/dist/ingress-proxy/sni.js +124 -0
- package/backend/dist/ingress-proxy/status.d.ts +32 -0
- package/backend/dist/ingress-proxy/status.js +15 -0
- package/backend/dist/ingress-proxy/system-proxy.d.ts +112 -0
- package/backend/dist/ingress-proxy/system-proxy.js +481 -0
- package/backend/dist/ingress-proxy/traffic-delete.d.ts +21 -0
- package/backend/dist/ingress-proxy/traffic-delete.js +64 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.d.ts +44 -0
- package/backend/dist/ingress-proxy/traffic-delete.worker.js +228 -0
- package/backend/dist/ingress-proxy/traffic-files.d.ts +10 -0
- package/backend/dist/ingress-proxy/traffic-files.js +10 -0
- package/backend/dist/ingress-proxy/upstream-tls.d.ts +46 -0
- package/backend/dist/ingress-proxy/upstream-tls.js +105 -0
- package/backend/dist/ingress-proxy/ws-frames.d.ts +45 -0
- package/backend/dist/ingress-proxy/ws-frames.js +153 -0
- package/backend/dist/ir/adapters/anthropic-messages-stream.js +6 -1
- package/backend/dist/ir/adapters/anthropic-messages.js +12 -5
- package/backend/dist/ir/adapters/google-gemini-stream.js +7 -2
- package/backend/dist/ir/adapters/google-gemini.js +5 -2
- package/backend/dist/ir/adapters/openai-chat-stream.js +5 -1
- package/backend/dist/ir/adapters/openai-chat.d.ts +25 -0
- package/backend/dist/ir/adapters/openai-chat.js +50 -6
- package/backend/dist/ir/adapters/openai-responses-output.d.ts +1 -0
- package/backend/dist/ir/adapters/openai-responses-output.js +67 -21
- package/backend/dist/ir/adapters/openai-responses-stream.d.ts +13 -0
- package/backend/dist/ir/adapters/openai-responses-stream.js +34 -1
- package/backend/dist/ir/adapters/openai-responses.d.ts +92 -1
- package/backend/dist/ir/adapters/openai-responses.js +163 -12
- package/backend/dist/ir/capabilities.js +4 -0
- package/backend/dist/ir/media.d.ts +20 -0
- package/backend/dist/ir/media.js +41 -0
- package/backend/dist/ir/tool-identity.d.ts +35 -0
- package/backend/dist/ir/tool-identity.js +40 -0
- package/backend/dist/ir/types.d.ts +9 -1
- package/backend/dist/ir/validate.d.ts +24 -0
- package/backend/dist/ir/validate.js +113 -63
- package/backend/dist/local/build-jobs.d.ts +66 -0
- package/backend/dist/local/build-jobs.js +243 -0
- package/backend/dist/local/detect.d.ts +32 -0
- package/backend/dist/local/detect.js +145 -0
- package/backend/dist/local/draft-match.d.ts +58 -0
- package/backend/dist/local/draft-match.js +124 -0
- package/backend/dist/local/engine-runtime.d.ts +522 -0
- package/backend/dist/local/engine-runtime.js +1 -0
- package/backend/dist/local/engines.d.ts +241 -0
- package/backend/dist/local/engines.js +651 -0
- package/backend/dist/local/gguf.d.ts +35 -0
- package/backend/dist/local/gguf.js +314 -0
- package/backend/dist/local/hf.d.ts +120 -0
- package/backend/dist/local/hf.js +304 -0
- package/backend/dist/local/install.d.ts +90 -0
- package/backend/dist/local/install.js +421 -0
- package/backend/dist/local/llamacpp.d.ts +55 -0
- package/backend/dist/local/llamacpp.js +177 -0
- package/backend/dist/local/local-provider.d.ts +81 -0
- package/backend/dist/local/local-provider.js +301 -0
- package/backend/dist/local/machine-stats.d.ts +87 -0
- package/backend/dist/local/machine-stats.js +332 -0
- package/backend/dist/local/model-store.d.ts +347 -0
- package/backend/dist/local/model-store.js +1215 -0
- package/backend/dist/local/part-sweep.d.ts +32 -0
- package/backend/dist/local/part-sweep.js +156 -0
- package/backend/dist/local/plan.d.ts +65 -0
- package/backend/dist/local/plan.js +146 -0
- package/backend/dist/local/resources.d.ts +49 -0
- package/backend/dist/local/resources.js +64 -0
- package/backend/dist/local/run-stats.d.ts +95 -0
- package/backend/dist/local/run-stats.js +195 -0
- package/backend/dist/local/runner.d.ts +235 -0
- package/backend/dist/local/runner.js +1392 -0
- package/backend/dist/local/settings.d.ts +79 -0
- package/backend/dist/local/settings.js +180 -0
- package/backend/dist/local/strata-catalog.d.ts +30 -0
- package/backend/dist/local/strata-catalog.js +511 -0
- package/backend/dist/local/strata-drafting.d.ts +46 -0
- package/backend/dist/local/strata-drafting.js +265 -0
- package/backend/dist/local/strata.d.ts +278 -0
- package/backend/dist/local/strata.js +1392 -0
- package/backend/dist/local/tar.d.ts +20 -0
- package/backend/dist/local/tar.js +367 -0
- package/backend/dist/local/transport.d.ts +35 -0
- package/backend/dist/local/transport.js +89 -0
- package/backend/dist/local/tune.d.ts +58 -0
- package/backend/dist/local/tune.js +324 -0
- package/backend/dist/observability/http-exchange.d.ts +2 -2
- package/backend/dist/opencode/catalog/auto-pull.d.ts +14 -3
- package/backend/dist/opencode/catalog/auto-pull.js +284 -77
- package/backend/dist/opencode/catalog/ocr-store.d.ts +7 -6
- package/backend/dist/opencode/catalog/ocr-store.js +4 -2
- package/backend/dist/opencode/catalog/overrides-store.d.ts +15 -4
- package/backend/dist/opencode/catalog/overrides-store.js +28 -19
- package/backend/dist/opencode/catalog/reasoning-declaration.d.ts +35 -0
- package/backend/dist/opencode/catalog/reasoning-declaration.js +66 -0
- package/backend/dist/opencode/catalog/repository.js +28 -5
- package/backend/dist/opencode/catalog/sources/models-dev.d.ts +3 -3
- package/backend/dist/opencode/catalog/sources/models-dev.js +42 -14
- package/backend/dist/opencode/catalog/types.d.ts +42 -12
- package/backend/dist/opencode/catalog/types.js +38 -1
- package/backend/dist/opencode/credentials/def-materialize.js +27 -21
- package/backend/dist/opencode/credentials/ocr-store.js +11 -2
- package/backend/dist/opencode/credentials/sync.js +12 -3
- package/backend/dist/opencode/credentials/types.d.ts +31 -4
- package/backend/dist/opencode/credentials/types.js +25 -0
- package/backend/dist/opencode/migrate/engine.d.ts +20 -0
- package/backend/dist/opencode/migrate/engine.js +71 -0
- package/backend/dist/opencode/migrate/migrator.d.ts +11 -0
- package/backend/dist/opencode/migrate/migrator.js +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/overrides-v1-to-v2.js +31 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.d.ts +6 -0
- package/backend/dist/opencode/migrate/steps/providers-v1-to-v2.js +62 -0
- package/backend/dist/opencode/probe.d.ts +21 -4
- package/backend/dist/opencode/probe.js +34 -10
- package/backend/dist/opencode/provider-def-adapters.d.ts +12 -11
- package/backend/dist/opencode/provider-def-adapters.js +43 -27
- package/backend/dist/opencode/provider-defs.d.ts +10 -16
- package/backend/dist/opencode/provider-defs.js +45 -45
- package/backend/dist/opencode/user-config.d.ts +23 -26
- package/backend/dist/opencode/user-config.js +95 -77
- package/backend/dist/pipeline/directives.d.ts +9 -4
- package/backend/dist/pipeline/directives.js +14 -10
- package/backend/dist/pipeline/orchestrator.d.ts +42 -13
- package/backend/dist/pipeline/orchestrator.js +514 -172
- package/backend/dist/plugins/builtin/model-gateway.js +38 -12
- package/backend/dist/plugins/environment-ack.d.ts +51 -0
- package/backend/dist/plugins/environment-ack.js +81 -0
- package/backend/dist/plugins/gateways.d.ts +6 -6
- package/backend/dist/plugins/gateways.js +2 -2
- package/backend/dist/plugins/host.d.ts +100 -16
- package/backend/dist/plugins/host.js +637 -99
- package/backend/dist/plugins/install-run.d.ts +27 -0
- package/backend/dist/plugins/install-run.js +99 -0
- package/backend/dist/plugins/manifest.d.ts +84 -32
- package/backend/dist/plugins/manifest.js +149 -45
- package/backend/dist/plugins/market-install.d.ts +18 -0
- package/backend/dist/plugins/market-install.js +111 -0
- package/backend/dist/plugins/market-source.d.ts +100 -0
- package/backend/dist/plugins/market-source.js +449 -0
- package/backend/dist/plugins/market-updates.d.ts +70 -0
- package/backend/dist/plugins/market-updates.js +97 -0
- package/backend/dist/plugins/market.d.ts +677 -0
- package/backend/dist/plugins/market.js +2113 -0
- package/backend/dist/plugins/source-index.d.ts +155 -0
- package/backend/dist/plugins/source-index.js +217 -0
- package/backend/dist/plugins/types.d.ts +402 -37
- package/backend/dist/projects/worktrees.d.ts +88 -0
- package/backend/dist/projects/worktrees.js +220 -0
- package/backend/dist/providers/boot-direct.d.ts +41 -7
- package/backend/dist/providers/boot-direct.js +284 -44
- package/backend/dist/providers/compat/tool-markup-recovery.js +31 -6
- package/backend/dist/providers/dial-wire.d.ts +17 -0
- package/backend/dist/providers/dial-wire.js +49 -0
- package/backend/dist/providers/executors/dispatch.d.ts +17 -7
- package/backend/dist/providers/executors/dispatch.js +28 -9
- package/backend/dist/providers/executors/openai-chat.js +14 -2
- package/backend/dist/providers/executors/plugin-adapter.d.ts +23 -1
- package/backend/dist/providers/executors/plugin-adapter.js +59 -3
- package/backend/dist/providers/member-match.d.ts +32 -9
- package/backend/dist/providers/member-match.js +65 -21
- package/backend/dist/providers/model-resolution.d.ts +62 -0
- package/backend/dist/providers/model-resolution.js +62 -0
- package/backend/dist/providers/price-order.d.ts +51 -0
- package/backend/dist/providers/price-order.js +54 -0
- package/backend/dist/providers/protocols-field.d.ts +24 -0
- package/backend/dist/providers/protocols-field.js +66 -0
- package/backend/dist/providers/provider-takedown.d.ts +5 -2
- package/backend/dist/providers/registry.d.ts +87 -26
- package/backend/dist/providers/registry.js +232 -121
- package/backend/dist/providers/selection.d.ts +91 -0
- package/backend/dist/providers/selection.js +158 -0
- package/backend/dist/providers/virtual-meta.d.ts +33 -2
- package/backend/dist/providers/virtual-meta.js +74 -18
- package/backend/dist/quota/cli-login.d.ts +25 -4
- package/backend/dist/quota/cli-login.js +38 -6
- package/backend/dist/quota/coverage-generation.d.ts +24 -0
- package/backend/dist/quota/coverage-generation.js +29 -0
- package/backend/dist/quota/declarations.js +8 -4
- package/backend/dist/quota/engine.js +2 -2
- package/backend/dist/quota/prober.d.ts +43 -2
- package/backend/dist/quota/prober.js +97 -22
- package/backend/dist/ratelimit/rate-limiter.d.ts +1 -1
- package/backend/dist/resilience/error-classifier.js +29 -0
- package/backend/dist/router/index.d.ts +1 -1
- package/backend/dist/router/index.js +17 -1
- package/backend/dist/router/layer2-decision.d.ts +1 -1
- package/backend/dist/router/layer2-decision.js +2 -2
- package/backend/dist/routes/console.js +1043 -405
- package/backend/dist/routes/environments.js +1 -1
- package/backend/dist/routes/local-models.d.ts +2 -0
- package/backend/dist/routes/local-models.js +1414 -0
- package/backend/dist/routes/mihomo.d.ts +2 -2
- package/backend/dist/routes/mihomo.js +20 -11
- package/backend/dist/routes/projects.js +121 -0
- package/backend/dist/server.js +409 -15
- package/backend/dist/session/session-manager.d.ts +42 -5
- package/backend/dist/session/session-manager.js +64 -11
- package/backend/dist/session/session-row.d.ts +29 -8
- package/backend/dist/session/session-row.js +18 -13
- package/backend/dist/snapshot/bundle.d.ts +40 -0
- package/backend/dist/snapshot/bundle.js +177 -0
- package/backend/dist/snapshot/handoff/compress.d.ts +46 -0
- package/backend/dist/snapshot/handoff/compress.js +77 -0
- package/backend/dist/snapshot/handoff/index.d.ts +119 -0
- package/backend/dist/snapshot/handoff/index.js +160 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.d.ts +78 -0
- package/backend/dist/snapshot/handoff/jsonl-writer.js +175 -0
- package/backend/dist/snapshot/handoff/opencode-writer.d.ts +51 -0
- package/backend/dist/snapshot/handoff/opencode-writer.js +214 -0
- package/backend/dist/snapshot/handoff/summarize.d.ts +39 -0
- package/backend/dist/snapshot/handoff/summarize.js +118 -0
- package/backend/dist/snapshot/handoff/transcript.d.ts +71 -0
- package/backend/dist/snapshot/handoff/transcript.js +167 -0
- package/backend/dist/snapshot/media-fs.d.ts +10 -0
- package/backend/dist/snapshot/media-fs.js +50 -0
- package/backend/dist/snapshot/media.d.ts +32 -0
- package/backend/dist/snapshot/media.js +87 -0
- package/backend/dist/snapshot/store.d.ts +226 -0
- package/backend/dist/snapshot/store.js +887 -0
- package/backend/dist/snapshot/tree.d.ts +112 -0
- package/backend/dist/snapshot/tree.js +207 -0
- package/backend/dist/snapshot/types.d.ts +212 -0
- package/backend/dist/snapshot/types.js +14 -0
- package/backend/dist/snapshot/view.d.ts +19 -0
- package/backend/dist/snapshot/view.js +57 -0
- package/backend/dist/snapshot/write-worker.d.ts +67 -0
- package/backend/dist/snapshot/write-worker.js +129 -0
- package/backend/dist/surfaces/anthropic.js +4 -1
- package/backend/dist/surfaces/body-admission.d.ts +344 -0
- package/backend/dist/surfaces/body-admission.js +818 -0
- package/backend/dist/surfaces/chat-pipeline.js +8 -0
- package/backend/dist/surfaces/decision-pipeline.js +10 -7
- package/backend/dist/surfaces/gateway-catalog.d.ts +26 -0
- package/backend/dist/surfaces/gateway-catalog.js +202 -0
- package/backend/dist/surfaces/gateway-chat.d.ts +7 -11
- package/backend/dist/surfaces/gateway-chat.js +50 -12
- package/backend/dist/surfaces/ocr-headers.d.ts +6 -4
- package/backend/dist/surfaces/ocr-headers.js +11 -7
- package/backend/dist/surfaces/systemone.js +1 -1
- package/backend/dist/surfaces/transport-fastify.js +32 -5
- package/backend/dist/surfaces/transport-node-http.d.ts +51 -6
- package/backend/dist/surfaces/transport-node-http.js +76 -16
- package/backend/dist/surfaces/types.d.ts +11 -3
- package/backend/dist/trace/persist.js +21 -1
- package/backend/dist/trace/tracker.d.ts +35 -3
- package/backend/dist/trace/tracker.js +23 -0
- package/backend/dist/types/openai.d.ts +8 -0
- package/backend/dist/types/router.d.ts +17 -6
- package/backend/dist/types/router.js +14 -2
- package/backend/dist/utils/client-families.d.ts +66 -0
- package/backend/dist/utils/client-families.js +127 -0
- package/backend/dist/utils/event-ring.d.ts +1 -1
- package/backend/dist/utils/event-ring.js +1 -1
- package/backend/dist/utils/proxy-node.js +1 -1
- package/backend/dist/utils/proxy.d.ts +135 -11
- package/backend/dist/utils/proxy.js +144 -29
- package/backend/dist/utils/run-command.d.ts +21 -1
- package/backend/dist/utils/run-command.js +64 -4
- package/backend/dist/utils/server-liveness.d.ts +28 -0
- package/backend/dist/utils/server-liveness.js +32 -0
- package/backend/dist/utils/session-file.d.ts +28 -0
- package/backend/dist/utils/session-file.js +34 -0
- package/frontend/dist/assets/antigravity.color-DXFfVr6X.svg +39 -0
- package/frontend/dist/assets/gemini-cli.color-BfquLd1p.svg +1 -0
- package/frontend/dist/assets/index-CTZNvn1d.js +1707 -0
- package/frontend/dist/assets/{index-DxZ9MHKB.css → index-CqDSOPQ0.css} +1 -1
- package/frontend/dist/index.html +2 -2
- package/package.json +3 -1
- package/frontend/dist/assets/index-55VVwfFQ.js +0 -1521
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
+
import { RESPONSES_CALL_ID_MAX_LEN, RESPONSES_TOOL_ITEM_ID_MAX_LEN } from '../../config/defaults.js';
|
|
2
3
|
import { IrUnsupportedError } from '../errors.js';
|
|
3
4
|
import { DATA_URL_RE } from '../media.js';
|
|
4
5
|
import { assertCanonicalRequestSupported } from '../validate.js';
|
|
6
|
+
import { CALL_ID_PREFIX, upstreamToolCallId } from '../tool-identity.js';
|
|
5
7
|
const PROTOCOL = 'openai-responses';
|
|
6
8
|
function record(value) {
|
|
7
9
|
return value && typeof value === 'object' ? value : {};
|
|
@@ -110,7 +112,11 @@ export function responsesPartToWire(part, role) {
|
|
|
110
112
|
if (part.type === 'extension') {
|
|
111
113
|
if (part.protocol !== PROTOCOL)
|
|
112
114
|
throw new IrUnsupportedError('content_part', `Cannot convert ${part.protocol} content.`, PROTOCOL);
|
|
113
|
-
|
|
115
|
+
// A COPY, exactly as at item level (`openai-responses-output.ts`): rendering must never
|
|
116
|
+
// alias the canonical object the session store and capture hold, or the next field the
|
|
117
|
+
// encoder stamps onto the wire shape would edit the operator's record of the upstream
|
|
118
|
+
// body. The item copy and this one are ONE rule, not two conventions.
|
|
119
|
+
return { ...record(part.payload) };
|
|
114
120
|
}
|
|
115
121
|
if (part.type === 'text') {
|
|
116
122
|
return {
|
|
@@ -177,21 +183,157 @@ export function responsesToolToWire(tool) {
|
|
|
177
183
|
* - Injective: distinct tool-call ids MUST NOT collapse onto one item id. The
|
|
178
184
|
* chat client controls `tool_calls[].id`, so an id that is not safe both in
|
|
179
185
|
* charset and length is hashed instead of sanitized/truncated — dropping
|
|
180
|
-
* characters or a tail would silently merge two calls into one id.
|
|
186
|
+
* characters or a tail would silently merge two calls into one id. What MAY be
|
|
187
|
+
* shortened is the DIGEST (to RESPONSES_TOOL_ITEM_ID_MAX_LEN, because the
|
|
188
|
+
* item-type prefix eats the room RESPONSES_CALL_ID_MAX_LEN gives a bare
|
|
189
|
+
* correlation id), never the original string.
|
|
181
190
|
*/
|
|
191
|
+
/**
|
|
192
|
+
* The item-id namespace for a tool call (`fc_` for a function call, `ctc_` for a custom one).
|
|
193
|
+
* Declared once because the anchor mint in `openai-responses-output.ts` has to agree with it:
|
|
194
|
+
* a minted id that missed this prefix would come back double-prefixed.
|
|
195
|
+
*/
|
|
196
|
+
export function toolItemPrefix(custom) {
|
|
197
|
+
return custom ? 'ctc_' : 'fc_';
|
|
198
|
+
}
|
|
182
199
|
export function responsesToolItemId(id, custom) {
|
|
183
|
-
const prefix = custom
|
|
200
|
+
const prefix = toolItemPrefix(custom);
|
|
184
201
|
if (id.startsWith(prefix))
|
|
185
202
|
return id;
|
|
186
|
-
if (
|
|
203
|
+
if (idShape(RESPONSES_TOOL_ITEM_ID_MAX_LEN).test(id))
|
|
187
204
|
return prefix + id;
|
|
188
|
-
return prefix +
|
|
205
|
+
return prefix + idDigest(id, RESPONSES_TOOL_ITEM_ID_MAX_LEN);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The one id charset both Responses id fields share, written once so the two
|
|
209
|
+
* budgets can never grow different rules (sha256 hex is inside it, which is what
|
|
210
|
+
* makes a hashed id legal).
|
|
211
|
+
*/
|
|
212
|
+
function idShape(maxLen) {
|
|
213
|
+
return new RegExp(`^[A-Za-z0-9_-]{1,${maxLen}}$`);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* sha256 hex, shortened only as far as the destination field requires — callers
|
|
217
|
+
* subtract their own prefix (and any suffix they append) from the budget first.
|
|
218
|
+
* A budget above sha256's own 64 hex chars is satisfied by the full digest, so only
|
|
219
|
+
* the LOW side needs a guard: `slice(0, 0)` returns the whole digest and a NEGATIVE
|
|
220
|
+
* length returns `64 - n` characters, so an unguarded non-positive budget hands back
|
|
221
|
+
* a 64-char id when the caller asked for none. The floor makes a zero/negative budget
|
|
222
|
+
* yield ONE character — a caller that over-subtracts then gets an id that is still too
|
|
223
|
+
* long for its field (visible, and our own gate rewrites it), which is honest in a way
|
|
224
|
+
* a silent 64-char digest would not be.
|
|
225
|
+
*/
|
|
226
|
+
export function idDigest(id, maxLen) {
|
|
227
|
+
return crypto.createHash('sha256').update(id).digest('hex').slice(0, Math.max(maxLen, 1));
|
|
228
|
+
}
|
|
229
|
+
/** Charset + length budget for `call_id` (see RESPONSES_CALL_ID_MAX_LEN). */
|
|
230
|
+
const CALL_ID_SHAPE = idShape(RESPONSES_CALL_ID_MAX_LEN);
|
|
231
|
+
/**
|
|
232
|
+
* Whether an id is ALREADY a legal `call_id`, so any projector can keep it byte-identical.
|
|
233
|
+
* Exported because the markup-recovery mint (`providers/compat/tool-markup-recovery.ts`) has
|
|
234
|
+
* to answer the same question about a response id it is about to embed — and because
|
|
235
|
+
* `slice`/`replace` on an id is never the right answer there (sanitising a response id is
|
|
236
|
+
* lossy, so it can alias two responses onto one correlation id). One charset, one predicate.
|
|
237
|
+
*/
|
|
238
|
+
export function isCanonicalResponsesCallId(id) {
|
|
239
|
+
return CALL_ID_SHAPE.test(id);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The `call_` correlation namespace is declared once, in `ir/tool-identity.ts`, because the
|
|
243
|
+
* upstream readers mint ids there and the markup-recovery mint builds ids in the same
|
|
244
|
+
* namespace — two declarations would be two drift twins of one rule.
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* Canonical correlation id -> Responses `call_id`, with the same two invariants as
|
|
248
|
+
* `responsesToolItemId` plus the one it lacked: a FIELD BUDGET. Upstream Responses
|
|
249
|
+
* APIs validate this string's length, and a client id that arrived from another
|
|
250
|
+
* carrier (chat owns `tool_calls[].id`; the cursor-gateway loop re-injects the id a
|
|
251
|
+
* PREVIOUS upstream minted) would otherwise leave here verbatim and answer 400
|
|
252
|
+
* `Invalid 'input[N].call_id': string too long, maximum 64 characters`.
|
|
253
|
+
*
|
|
254
|
+
* THIS IS THE ONLY PROJECTION POINT, and that is load-bearing. Canonical state —
|
|
255
|
+
* `CanonicalResponse.output[].callId`, the session store a `store: true` Responses
|
|
256
|
+
* chain replays, and the capture rows — keeps the ORIGINAL id, because projecting
|
|
257
|
+
* there would break the other carriers (Anthropic `tool_use.id` has its own length
|
|
258
|
+
* rule). If the outbound RESPONSE leg projected too, a client would hold digests
|
|
259
|
+
* while the chain replays originals, and the two would meet as one history: an
|
|
260
|
+
* unpaired orphan, `repairToolCallPairing` synthesising
|
|
261
|
+
* "Tool call was cancelled before returning a result." over the client's real
|
|
262
|
+
* result, and no error anywhere. One projector on one leg keeps every plane in one
|
|
263
|
+
* naming system: a client replays the original it was handed, and this function
|
|
264
|
+
* turns it into the same digest on every turn.
|
|
265
|
+
*
|
|
266
|
+
* Four properties, all load-bearing:
|
|
267
|
+
*
|
|
268
|
+
* - Inside the field (its charset AND its length) -> BYTE-IDENTICAL. Most traffic
|
|
269
|
+
* never sees a rewrite, so carriers that key on the `call_` / `toolu_` shape keep
|
|
270
|
+
* seeing it. `call_id` needs no item-type prefix (that is why `responsesToolItemId`
|
|
271
|
+
* adds one and this does not have to), so the budget is spent entirely on the id.
|
|
272
|
+
* - Deterministic: the same history yields the same id on every turn, or the
|
|
273
|
+
* replayed prompt prefix busts the upstream prompt cache.
|
|
274
|
+
* - Injective: truncating the ORIGINAL to the budget is NOT the fallback — ids
|
|
275
|
+
* that share a 64-char prefix would silently merge, and a merged correlation id
|
|
276
|
+
* merges two tool results onto one call with no error anywhere. The replacement
|
|
277
|
+
* is a `sha256` digest (`call_` + 59 hex = 64, so 236 bits and no realistic
|
|
278
|
+
* collision), and it keeps the `call_` shape because consumers, session stores
|
|
279
|
+
* and operator greps key on it.
|
|
280
|
+
* - A PROJECTION: `responsesCallId(responsesCallId(x)) === responsesCallId(x)`,
|
|
281
|
+
* because the hashed form is itself inside the field. The correlation id
|
|
282
|
+
* flows back through the gateway (a client replays whatever id it was handed, and
|
|
283
|
+
* an extension item may carry one verbatim), so a map that is not idempotent
|
|
284
|
+
* would name the same call differently on two turns of one session.
|
|
285
|
+
*
|
|
286
|
+
* An empty id has no faithful representation — pairing is impossible without it —
|
|
287
|
+
* so it is refused in the plane's own envelope (`tool_call_id` is the machine code the
|
|
288
|
+
* client sees) rather than minted a placeholder, which would merge every unlabelled
|
|
289
|
+
* call onto one id, or relayed as `""` for the upstream to reject in a language the
|
|
290
|
+
* client cannot read. An EMPTY `call_id` counts as absent and falls back to the item
|
|
291
|
+
* id **when the caller has one to offer** — that is the tool-call branch, which passes
|
|
292
|
+
* `item.id`; a tool RESULT has no id of its own, so there the refusal above is what
|
|
293
|
+
* happens. The two carriers agree on the anchor because `chat`
|
|
294
|
+
* writes `callId = id`, and the inbound Responses reader does `call_id ?? id`; a
|
|
295
|
+
* stored turn from before the minting fix can carry `call_id: ""` beside a real item
|
|
296
|
+
* id. This is the LAST-MILE half of that contract: an empty correlation id is legal on
|
|
297
|
+
* the Chat and Anthropic outbound wires, so it is refused only when the dialed carrier
|
|
298
|
+
* requires one. The consequence is that the refusal is an `IrUnsupportedError`, which is
|
|
299
|
+
* NOT failover-eligible — correct for a malformed body every candidate would receive
|
|
300
|
+
* alike, but it means such a request ends here instead of trying the next model.
|
|
301
|
+
*/
|
|
302
|
+
export function responsesCallId(callId, fallback) {
|
|
303
|
+
const id = callId || fallback || '';
|
|
304
|
+
if (!id) {
|
|
305
|
+
throw new IrUnsupportedError('tool_call_id', 'Responses tool items require a non-empty correlation id.', PROTOCOL);
|
|
306
|
+
}
|
|
307
|
+
return isCanonicalResponsesCallId(id)
|
|
308
|
+
? id
|
|
309
|
+
: CALL_ID_PREFIX + idDigest(id, RESPONSES_CALL_ID_MAX_LEN - CALL_ID_PREFIX.length);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Passthrough is not exemption on the leg we control. A built-in Responses item
|
|
313
|
+
* (`web_search_call`, `mcp_call`, `image_generation_call`, a `computer_call` a
|
|
314
|
+
* plugin parsed as an extension) carries `call_id` too, and an over-budget one
|
|
315
|
+
* answers 400 for exactly the reason a tool item does — so an outbound extension
|
|
316
|
+
* payload's correlation id goes through the same map. The payload is COPIED, never
|
|
317
|
+
* mutated in place: the same object is what capture and the session store read, and
|
|
318
|
+
* rewriting the original there would silently edit the client's prompt and put the
|
|
319
|
+
* two naming planes out of step. A NESTED `call_id` is deliberately not walked: a foreign
|
|
320
|
+
* built-in shape is not ours to relabel, and rewriting unknown payload keys would put the
|
|
321
|
+
* map's idempotence on the vendor's structure rather than on our own field. An absent or
|
|
322
|
+
* empty `call_id` is left alone, because
|
|
323
|
+
* this payload is not ours to label — refusing a foreign built-in item over a field
|
|
324
|
+
* shape we merely inferred would reject requests that work today.
|
|
325
|
+
*/
|
|
326
|
+
function withNormalizedCallId(payload) {
|
|
327
|
+
const callId = payload.call_id;
|
|
328
|
+
if (typeof callId !== 'string' || callId === '')
|
|
329
|
+
return payload;
|
|
330
|
+
return { ...payload, call_id: responsesCallId(callId) };
|
|
189
331
|
}
|
|
190
332
|
function itemToWire(item) {
|
|
191
333
|
if (item.type === 'extension') {
|
|
192
334
|
if (item.protocol !== PROTOCOL)
|
|
193
335
|
throw new IrUnsupportedError('input_item', `Cannot convert ${item.protocol} item.`, PROTOCOL);
|
|
194
|
-
return record(item.payload);
|
|
336
|
+
return withNormalizedCallId(record(item.payload));
|
|
195
337
|
}
|
|
196
338
|
if (item.type === 'item_reference')
|
|
197
339
|
return { type: 'item_reference', id: item.id };
|
|
@@ -214,7 +356,7 @@ function itemToWire(item) {
|
|
|
214
356
|
return {
|
|
215
357
|
type: custom ? 'custom_tool_call' : 'function_call',
|
|
216
358
|
id: responsesToolItemId(item.id, custom),
|
|
217
|
-
call_id: item.callId
|
|
359
|
+
call_id: responsesCallId(item.callId, item.id),
|
|
218
360
|
name: item.name,
|
|
219
361
|
...(custom ? { input: item.arguments } : { arguments: item.arguments }),
|
|
220
362
|
...(item.status ? { status: item.status } : {}),
|
|
@@ -227,7 +369,7 @@ function itemToWire(item) {
|
|
|
227
369
|
const textOnly = parts.every((p) => p.type === 'input_text');
|
|
228
370
|
return {
|
|
229
371
|
type: item.vendor?.[PROTOCOL]?.itemType === 'custom_tool_call_output' ? 'custom_tool_call_output' : 'function_call_output',
|
|
230
|
-
call_id: item.callId,
|
|
372
|
+
call_id: responsesCallId(item.callId),
|
|
231
373
|
output: textOnly ? parts.map((p) => String(p.text ?? '')).join('\n') : parts,
|
|
232
374
|
};
|
|
233
375
|
}
|
|
@@ -495,8 +637,16 @@ export function responsesInputToIR(raw) {
|
|
|
495
637
|
}];
|
|
496
638
|
}
|
|
497
639
|
if (type === 'function_call' || type === 'custom_tool_call') {
|
|
498
|
-
|
|
499
|
-
|
|
640
|
+
// The REQUEST plane keeps the name the client sent. This is the one reader that must NOT
|
|
641
|
+
// mint: a harness resends the whole history every turn, so a random name invented here
|
|
642
|
+
// would make the canonical envelope differ per resend and the outbound prefix would
|
|
643
|
+
// change bytes on every turn — a cache miss the client can neither see nor fix. An item
|
|
644
|
+
// id is a legitimate fallback because the client wrote it. A call named by NOTHING is
|
|
645
|
+
// refused at the outbound gate (`responsesCallId`), never silently renamed here.
|
|
646
|
+
const wireCallId = typeof item.call_id === 'string' ? item.call_id : '';
|
|
647
|
+
const wireItemId = typeof item.id === 'string' ? item.id : '';
|
|
648
|
+
const callId = wireCallId || wireItemId;
|
|
649
|
+
const id = wireItemId || callId;
|
|
500
650
|
const args = type === 'custom_tool_call' ? item.input : item.arguments;
|
|
501
651
|
return [{
|
|
502
652
|
type: 'tool_call', id, callId,
|
|
@@ -652,10 +802,11 @@ export function responsesResponseToIR(data) {
|
|
|
652
802
|
});
|
|
653
803
|
}
|
|
654
804
|
else if (item.type === 'function_call' || item.type === 'custom_tool_call') {
|
|
655
|
-
const callId = typeof item.call_id === 'string' ? item.call_id
|
|
805
|
+
const callId = upstreamToolCallId(typeof item.call_id === 'string' ? item.call_id
|
|
806
|
+
: typeof item.id === 'string' ? item.id : undefined);
|
|
656
807
|
const args = item.type === 'custom_tool_call' ? item.input : item.arguments;
|
|
657
808
|
output.push({
|
|
658
|
-
type: 'tool_call', id:
|
|
809
|
+
type: 'tool_call', id: typeof item.id === 'string' && item.id ? item.id : callId, callId,
|
|
659
810
|
name: String(item.name ?? ''),
|
|
660
811
|
arguments: typeof args === 'string' ? args : JSON.stringify(args ?? {}),
|
|
661
812
|
...(item.status ? { status: item.status } : {}),
|
|
@@ -10,6 +10,10 @@ const CHAT_GENERATION = {
|
|
|
10
10
|
const OPENAI_CHAT = {
|
|
11
11
|
parts: { text: true, image: true, refusal: true },
|
|
12
12
|
sources: { image: ['url', 'base64'] },
|
|
13
|
+
// function only: this id is the portable OpenAI-compatible Chat contract.
|
|
14
|
+
// OpenAI Platform's 2025-08 Chat `custom` tools stay off the global matrix —
|
|
15
|
+
// most compat upstreams reject them; enabling here would forward OpenAI-only
|
|
16
|
+
// payloads to Xiaomi/DeepSeek/Kimi-style endpoints. Responses keeps custom/builtin.
|
|
13
17
|
toolKinds: { function: true },
|
|
14
18
|
reasoningSignature: false,
|
|
15
19
|
// The orchestrator translates a budget to reasoning_effort before this wire.
|
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
/** Inline base64 media URL shared by protocol adapters. */
|
|
2
2
|
export declare const DATA_URL_RE: RegExp;
|
|
3
|
+
/**
|
|
4
|
+
* media_type → file extension for an offloaded payload (unknown → bin).
|
|
5
|
+
* ONE table: the capture archive and the session-snapshot store both offload
|
|
6
|
+
* base64 with the same content-addressed naming, so a payload offloaded by one
|
|
7
|
+
* plane must be readable by the other's rules.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MIME_TO_EXT: Record<string, string>;
|
|
10
|
+
/** Reverse map for a read route's Content-Type. */
|
|
11
|
+
export declare const EXT_TO_MIME: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* A bare (no data-URL prefix) base64 payload worth offloading: ≥256 chars of
|
|
14
|
+
* strict alphabet. Prose, code, or paths carry spaces/punctuation and never
|
|
15
|
+
* match — the guard's false-positive class is "long base64-ish token", which is
|
|
16
|
+
* exactly what image/audio/document blobs look like.
|
|
17
|
+
*/
|
|
18
|
+
export declare const BASE64_SHAPE_RE: RegExp;
|
|
19
|
+
/** Content-addressed media file name: `<sha256>.<ext>`. */
|
|
20
|
+
export declare const MEDIA_FILE_RE: RegExp;
|
|
21
|
+
/** A hash prefix accepted by a media read route (16–64 hex). */
|
|
22
|
+
export declare const MEDIA_HASH_RE: RegExp;
|
package/backend/dist/ir/media.js
CHANGED
|
@@ -1,2 +1,43 @@
|
|
|
1
1
|
/** Inline base64 media URL shared by protocol adapters. */
|
|
2
2
|
export const DATA_URL_RE = /^data:(.+?);base64,(.*)$/;
|
|
3
|
+
/**
|
|
4
|
+
* media_type → file extension for an offloaded payload (unknown → bin).
|
|
5
|
+
* ONE table: the capture archive and the session-snapshot store both offload
|
|
6
|
+
* base64 with the same content-addressed naming, so a payload offloaded by one
|
|
7
|
+
* plane must be readable by the other's rules.
|
|
8
|
+
*/
|
|
9
|
+
export const MIME_TO_EXT = {
|
|
10
|
+
'image/png': 'png',
|
|
11
|
+
'image/jpeg': 'jpg',
|
|
12
|
+
'image/jpg': 'jpg',
|
|
13
|
+
'image/gif': 'gif',
|
|
14
|
+
'image/webp': 'webp',
|
|
15
|
+
'image/svg+xml': 'svg',
|
|
16
|
+
'image/bmp': 'bmp',
|
|
17
|
+
'image/avif': 'avif',
|
|
18
|
+
'application/pdf': 'pdf',
|
|
19
|
+
'text/plain': 'txt',
|
|
20
|
+
};
|
|
21
|
+
/** Reverse map for a read route's Content-Type. */
|
|
22
|
+
export const EXT_TO_MIME = {
|
|
23
|
+
png: 'image/png',
|
|
24
|
+
jpg: 'image/jpeg',
|
|
25
|
+
gif: 'image/gif',
|
|
26
|
+
webp: 'image/webp',
|
|
27
|
+
svg: 'image/svg+xml',
|
|
28
|
+
bmp: 'image/bmp',
|
|
29
|
+
avif: 'image/avif',
|
|
30
|
+
pdf: 'application/pdf',
|
|
31
|
+
txt: 'text/plain',
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A bare (no data-URL prefix) base64 payload worth offloading: ≥256 chars of
|
|
35
|
+
* strict alphabet. Prose, code, or paths carry spaces/punctuation and never
|
|
36
|
+
* match — the guard's false-positive class is "long base64-ish token", which is
|
|
37
|
+
* exactly what image/audio/document blobs look like.
|
|
38
|
+
*/
|
|
39
|
+
export const BASE64_SHAPE_RE = /^[A-Za-z0-9+/]{256,}={0,2}$/;
|
|
40
|
+
/** Content-addressed media file name: `<sha256>.<ext>`. */
|
|
41
|
+
export const MEDIA_FILE_RE = /^[0-9a-f]{16,64}\.[a-z0-9]{1,8}$/;
|
|
42
|
+
/** A hash prefix accepted by a media read route (16–64 hex). */
|
|
43
|
+
export const MEDIA_HASH_RE = /^[0-9a-f]{16,64}$/;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE namespace for a tool correlation id the gateway itself has to supply.
|
|
3
|
+
*
|
|
4
|
+
* Why this lives in the IR layer instead of an adapter: every upstream READER can meet a
|
|
5
|
+
* tool call that arrived with no id — a lenient OpenAI-compatible server returns
|
|
6
|
+
* `tool_calls[]` without one, a Responses server can omit both `id` and `call_id`, Gemini
|
|
7
|
+
* has no correlation field at all, and a markup-recovered call has no native id either.
|
|
8
|
+
* Each reader used to patch that differently (`call_<16hex>`, `call_<candidate>_<index>`,
|
|
9
|
+
* or nothing at all, which left `''`), and the three spellings were three drift twins of
|
|
10
|
+
* one idea — one of them positional, which collides with the SAME position of the PREVIOUS
|
|
11
|
+
* turn inside one replayed history.
|
|
12
|
+
*
|
|
13
|
+
* The id is minted in CANONICAL state, at the moment the upstream response is read, not at
|
|
14
|
+
* wire-render time. That placement is the point: canonical state is what the session store
|
|
15
|
+
* records for a `store: true` chain, what capture archives, and what every outbound carrier
|
|
16
|
+
* renders from, so the client, the operator's record and the next turn's replay all speak ONE
|
|
17
|
+
* name for one call. A render-time mint would leave the stored turn with an empty id, and the
|
|
18
|
+
* next turn would then fail on the gateway's own history (`400 tool_call_id`) or orphan the
|
|
19
|
+
* client's real tool result.
|
|
20
|
+
*
|
|
21
|
+
* 24 hex chars (12 bytes, 96 bits) keeps the id inside every carrier's field budget — the
|
|
22
|
+
* Responses correlation budget is `RESPONSES_CALL_ID_MAX_LEN` = 64 — and inside the charset
|
|
23
|
+
* `[A-Za-z0-9_-]` both Responses id fields share, so a minted id never needs the outbound
|
|
24
|
+
* projection and never truncates.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CALL_ID_PREFIX = "call_";
|
|
27
|
+
/** A fresh, carrier-legal correlation id for an upstream call that arrived unnamed. */
|
|
28
|
+
export declare function mintToolCallId(): string;
|
|
29
|
+
/**
|
|
30
|
+
* The id an upstream tool call carries, or a minted one when it carries none. An EMPTY
|
|
31
|
+
* string counts as none: a field the vendor sent as `""` names nothing, which is exactly
|
|
32
|
+
* the case this exists for. Callers assign the RESULT to both `id` and `callId` so the two
|
|
33
|
+
* slots of one call never disagree.
|
|
34
|
+
*/
|
|
35
|
+
export declare function upstreamToolCallId(id: string | undefined | null): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* The ONE namespace for a tool correlation id the gateway itself has to supply.
|
|
4
|
+
*
|
|
5
|
+
* Why this lives in the IR layer instead of an adapter: every upstream READER can meet a
|
|
6
|
+
* tool call that arrived with no id — a lenient OpenAI-compatible server returns
|
|
7
|
+
* `tool_calls[]` without one, a Responses server can omit both `id` and `call_id`, Gemini
|
|
8
|
+
* has no correlation field at all, and a markup-recovered call has no native id either.
|
|
9
|
+
* Each reader used to patch that differently (`call_<16hex>`, `call_<candidate>_<index>`,
|
|
10
|
+
* or nothing at all, which left `''`), and the three spellings were three drift twins of
|
|
11
|
+
* one idea — one of them positional, which collides with the SAME position of the PREVIOUS
|
|
12
|
+
* turn inside one replayed history.
|
|
13
|
+
*
|
|
14
|
+
* The id is minted in CANONICAL state, at the moment the upstream response is read, not at
|
|
15
|
+
* wire-render time. That placement is the point: canonical state is what the session store
|
|
16
|
+
* records for a `store: true` chain, what capture archives, and what every outbound carrier
|
|
17
|
+
* renders from, so the client, the operator's record and the next turn's replay all speak ONE
|
|
18
|
+
* name for one call. A render-time mint would leave the stored turn with an empty id, and the
|
|
19
|
+
* next turn would then fail on the gateway's own history (`400 tool_call_id`) or orphan the
|
|
20
|
+
* client's real tool result.
|
|
21
|
+
*
|
|
22
|
+
* 24 hex chars (12 bytes, 96 bits) keeps the id inside every carrier's field budget — the
|
|
23
|
+
* Responses correlation budget is `RESPONSES_CALL_ID_MAX_LEN` = 64 — and inside the charset
|
|
24
|
+
* `[A-Za-z0-9_-]` both Responses id fields share, so a minted id never needs the outbound
|
|
25
|
+
* projection and never truncates.
|
|
26
|
+
*/
|
|
27
|
+
export const CALL_ID_PREFIX = 'call_';
|
|
28
|
+
/** A fresh, carrier-legal correlation id for an upstream call that arrived unnamed. */
|
|
29
|
+
export function mintToolCallId() {
|
|
30
|
+
return `${CALL_ID_PREFIX}${crypto.randomBytes(12).toString('hex')}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The id an upstream tool call carries, or a minted one when it carries none. An EMPTY
|
|
34
|
+
* string counts as none: a field the vendor sent as `""` names nothing, which is exactly
|
|
35
|
+
* the case this exists for. Callers assign the RESULT to both `id` and `callId` so the two
|
|
36
|
+
* slots of one call never disagree.
|
|
37
|
+
*/
|
|
38
|
+
export function upstreamToolCallId(id) {
|
|
39
|
+
return id || mintToolCallId();
|
|
40
|
+
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* cannot express a component simply omit it.
|
|
17
17
|
* - Streaming is an event union with item lifecycle, not a chat chunk.
|
|
18
18
|
*/
|
|
19
|
+
import type { ReasoningEffort } from '../types/router.js';
|
|
19
20
|
/** Conversion-surface protocol ids. The core shapes are literal for readers;
|
|
20
21
|
* the plugin half is OPEN — an OCR-native bare protocol name or any wire a
|
|
21
22
|
* loaded model-service plugin declares is a valid carrier (ADR-0033
|
|
@@ -69,7 +70,7 @@ export interface TextConfig {
|
|
|
69
70
|
verbosity?: 'low' | 'medium' | 'high';
|
|
70
71
|
}
|
|
71
72
|
export interface ReasoningParams {
|
|
72
|
-
effort?:
|
|
73
|
+
effort?: ReasoningEffort;
|
|
73
74
|
/** Explicit token budget (Anthropic thinking.budget_tokens / Responses max_tokens). */
|
|
74
75
|
budgetTokens?: number;
|
|
75
76
|
include?: boolean;
|
|
@@ -370,6 +371,13 @@ export interface Usage {
|
|
|
370
371
|
audioOutputTokens?: number;
|
|
371
372
|
acceptedPredictionTokens?: number;
|
|
372
373
|
rejectedPredictionTokens?: number;
|
|
374
|
+
/**
|
|
375
|
+
* What the VENDOR says this exchange committed, in USD (stamped by a
|
|
376
|
+
* model-service plugin from the upstream's own billing). When present it
|
|
377
|
+
* wins over token-count x catalog pricing for every cost booking — a static
|
|
378
|
+
* price table is an estimate, this is the invoice.
|
|
379
|
+
*/
|
|
380
|
+
vendorCostUsd?: number;
|
|
373
381
|
}
|
|
374
382
|
export interface AssistantMessageItem {
|
|
375
383
|
type: 'message';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IrUnsupportedError } from './errors.js';
|
|
1
2
|
import type { CanonicalRequest, CanonicalResponse, ProtocolId, StreamEvent } from './types.js';
|
|
2
3
|
/** Request = southbound payload; response = northbound encoder. Same matrix,
|
|
3
4
|
* but a few carriers accept a field on one leg only (Responses signatures). */
|
|
@@ -6,6 +7,29 @@ export interface RequestValidationOptions {
|
|
|
6
7
|
/** Generic OpenAI wires deliberately strip foreign carrier cache extensions. */
|
|
7
8
|
stripCarrierExtensions?: boolean;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Client-visible unsupported_parameter body. One voice for the gate and adapters:
|
|
12
|
+
* feature + dialed protocol + actionable hint. Dial context (model / protocols[])
|
|
13
|
+
* is layered on by `withDialContext` in the registry.
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatUnsupported(protocol: ProtocolId, feature: string, hint?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Operator-facing copy when a wire rejects non-function tools.
|
|
18
|
+
* OpenAI Platform Chat Completions added `type:"custom"` in 2025-08, but OCR's
|
|
19
|
+
* `openai-chat` id is the *portable* Chat Completions contract used by Xiaomi /
|
|
20
|
+
* DeepSeek / Kimi-style compat endpoints — those accept function tools, not
|
|
21
|
+
* OpenAI's freeform/grammar custom dialect or Responses builtins.
|
|
22
|
+
*/
|
|
23
|
+
export declare function unsupportedToolKindMessage(protocol: ProtocolId, kind: string, forChoice: boolean): string;
|
|
24
|
+
/**
|
|
25
|
+
* Layer dial facts onto a gate/adapter refusal so the client sees which model
|
|
26
|
+
* and protocols[] were in play. Same code/protocol; message only.
|
|
27
|
+
*/
|
|
28
|
+
export declare function withDialContext(err: IrUnsupportedError, opts: {
|
|
29
|
+
modelId: string;
|
|
30
|
+
dialWire: string;
|
|
31
|
+
protocols?: readonly string[];
|
|
32
|
+
}): IrUnsupportedError;
|
|
9
33
|
/**
|
|
10
34
|
* Fail-visible conversion gate. It is deliberately adapter-independent: every
|
|
11
35
|
* southbound wire runs the SAME checks before it builds its payload, so adding
|