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,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { IrUpstreamError } from '../errors.js';
|
|
3
3
|
import { googleUsageFromWire } from './google-gemini.js';
|
|
4
|
+
import { upstreamToolCallId } from '../tool-identity.js';
|
|
4
5
|
function record(value) {
|
|
5
6
|
return value && typeof value === 'object' ? value : {};
|
|
6
7
|
}
|
|
@@ -70,8 +71,12 @@ export class GoogleGeminiStreamDecoder {
|
|
|
70
71
|
if (part.functionCall) {
|
|
71
72
|
const call = record(part.functionCall);
|
|
72
73
|
const itemIndex = state.nextItem++;
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// One mint namespace with the buffered Gemini reader (`google-gemini.ts`), which also
|
|
75
|
+
// has no correlation field to read. A response-scoped composite (`<id>:call:<c>:<i>`)
|
|
76
|
+
// was a fourth spelling of the same idea, and its `:` is outside the charset both
|
|
77
|
+
// Responses id fields share, so a Gemini call converted to Responses was rewritten by
|
|
78
|
+
// the digest instead of passing through.
|
|
79
|
+
const id = upstreamToolCallId(typeof call.id === 'string' ? call.id : undefined);
|
|
75
80
|
const item = {
|
|
76
81
|
type: 'tool_call', id, callId: id,
|
|
77
82
|
name: String(call.name ?? ''), arguments: JSON.stringify(call.args ?? {}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
1
|
import { EFFORT_TO_BUDGET } from '../../types/router.js';
|
|
3
2
|
import { IrUnsupportedError } from '../errors.js';
|
|
3
|
+
import { upstreamToolCallId } from '../tool-identity.js';
|
|
4
4
|
import { assertCanonicalRequestSupported } from '../validate.js';
|
|
5
5
|
const PROTOCOL = 'google-gemini';
|
|
6
6
|
function record(value) {
|
|
@@ -192,7 +192,10 @@ function partFromWire(raw) {
|
|
|
192
192
|
const value = record(raw);
|
|
193
193
|
if (value.functionCall) {
|
|
194
194
|
const call = record(value.functionCall);
|
|
195
|
-
|
|
195
|
+
// A vendor id wins when the schema carries one (newer Gemini v1beta has `functionCall.id`);
|
|
196
|
+
// otherwise the call is named here, in the ONE mint namespace, so the outbound carriers get
|
|
197
|
+
// a correlation id that is already inside their shape budget.
|
|
198
|
+
const id = upstreamToolCallId(typeof call.id === 'string' ? call.id : undefined);
|
|
196
199
|
return {
|
|
197
200
|
call: {
|
|
198
201
|
type: 'tool_call', id, callId: id,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { extractChatReasoningText, usageToIR } from './openai-chat.js';
|
|
2
2
|
import { IrUnsupportedError } from '../errors.js';
|
|
3
|
+
import { upstreamToolCallId } from '../tool-identity.js';
|
|
3
4
|
import { assertCanonicalResponseSupported, assertCanonicalStreamEventSupported } from '../validate.js';
|
|
4
5
|
/** Decode an OpenAI Chat SSE stream into canonical item events, once per chunk. */
|
|
5
6
|
export class ChatStreamDecoder {
|
|
@@ -96,7 +97,10 @@ export class ChatStreamDecoder {
|
|
|
96
97
|
const wireIndex = typeof fragment.index === 'number' ? fragment.index : position;
|
|
97
98
|
let call = state.tools.get(wireIndex);
|
|
98
99
|
if (!call) {
|
|
99
|
-
|
|
100
|
+
// Minted, not positional: `call_<candidate>_<index>` repeats the SAME id for the
|
|
101
|
+
// same position of EVERY response, so two turns of one session would carry two
|
|
102
|
+
// calls under one correlation id and the upstream would merge their results.
|
|
103
|
+
const id = upstreamToolCallId(fragment.id);
|
|
100
104
|
call = {
|
|
101
105
|
index: state.nextItem++,
|
|
102
106
|
emitted: false,
|
|
@@ -4,12 +4,37 @@ import type { CanonicalRequest, CanonicalResponse, ContentPart, Usage } from '..
|
|
|
4
4
|
export interface ChatAdapterOptions {
|
|
5
5
|
/** Keep Anthropic/Responses-only cache markers. Generic chat wires disable this. */
|
|
6
6
|
carrierExtensions?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* How this upstream expresses "don't think" / a thinking level. When set, a
|
|
9
|
+
* `reasoning_effort` value is TRANSLATED into the declared request field
|
|
10
|
+
* instead of being emitted as `reasoning_effort` — the fix for a
|
|
11
|
+
* DeepSeek/Qwen/Kimi host that reads `enable_thinking` / `thinking.type` and
|
|
12
|
+
* would otherwise ignore or 400 the OpenAI spelling.
|
|
13
|
+
*/
|
|
14
|
+
compatibility?: {
|
|
15
|
+
reasoningField?: string;
|
|
16
|
+
suppressReasoningEffort?: boolean;
|
|
17
|
+
};
|
|
7
18
|
}
|
|
8
19
|
export declare function partsFromChat(content: ChatMessage['content'] | null): ContentPart[];
|
|
9
20
|
export declare function chatContentFromParts(parts: ContentPart[], protocol?: string, options?: ChatAdapterOptions): string | ChatMessageContentPart[] | null;
|
|
10
21
|
/** Extract reasoning text across OpenAI-compatible dialects (`reasoning_content`, `reasoning`, `reasoning_details`). */
|
|
11
22
|
export declare function extractChatReasoningText(raw: unknown): string | undefined;
|
|
12
23
|
export declare function chatRequestToIR(req: ChatCompletionRequest): CanonicalRequest;
|
|
24
|
+
/**
|
|
25
|
+
* Translate a ladder level into the value an upstream's declared
|
|
26
|
+
* `compatibility.reasoningField` expects. Three field families exist in the
|
|
27
|
+
* wild:
|
|
28
|
+
* - a BOOLEAN switch (`enable_thinking`, `thinking.enabled`) → true unless the
|
|
29
|
+
* level is `none`;
|
|
30
|
+
* - the on/off STATE enum `thinking.type` (DeepSeek, Kimi) → `'enabled'`
|
|
31
|
+
* unless the level is `none`, then `'disabled'` — it is NOT an effort
|
|
32
|
+
* vocabulary and rejects a level token;
|
|
33
|
+
* - anything else (`reasoning.effort`, …) → the level token itself.
|
|
34
|
+
* Nested paths (`thinking.type`, `reasoning.effort`) are written as nested
|
|
35
|
+
* objects so those hosts work without a second knob.
|
|
36
|
+
*/
|
|
37
|
+
export declare function applyReasoningField(out: Record<string, unknown>, field: string, level: string): void;
|
|
13
38
|
/** IR → the legacy execution request / OpenAI-chat request. */
|
|
14
39
|
export declare function irToChatRequest(ir: CanonicalRequest, model: string, options?: ChatAdapterOptions): ChatCompletionRequest;
|
|
15
40
|
export declare function usageToIR(usage: ChatCompletionResponse['usage']): Usage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { IrUnsupportedError } from '../errors.js';
|
|
2
2
|
import { DATA_URL_RE } from '../media.js';
|
|
3
|
-
import {
|
|
3
|
+
import { upstreamToolCallId } from '../tool-identity.js';
|
|
4
|
+
import { assertCanonicalRequestSupported, assertCanonicalResponseSupported, unsupportedToolKindMessage, } from '../validate.js';
|
|
4
5
|
function unsupported(code, message) {
|
|
5
6
|
throw new IrUnsupportedError(code, message, 'openai-chat');
|
|
6
7
|
}
|
|
@@ -306,6 +307,37 @@ function appendAssistantContent(current, addition) {
|
|
|
306
307
|
: addition;
|
|
307
308
|
current.content = [...left, ...right];
|
|
308
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Translate a ladder level into the value an upstream's declared
|
|
312
|
+
* `compatibility.reasoningField` expects. Three field families exist in the
|
|
313
|
+
* wild:
|
|
314
|
+
* - a BOOLEAN switch (`enable_thinking`, `thinking.enabled`) → true unless the
|
|
315
|
+
* level is `none`;
|
|
316
|
+
* - the on/off STATE enum `thinking.type` (DeepSeek, Kimi) → `'enabled'`
|
|
317
|
+
* unless the level is `none`, then `'disabled'` — it is NOT an effort
|
|
318
|
+
* vocabulary and rejects a level token;
|
|
319
|
+
* - anything else (`reasoning.effort`, …) → the level token itself.
|
|
320
|
+
* Nested paths (`thinking.type`, `reasoning.effort`) are written as nested
|
|
321
|
+
* objects so those hosts work without a second knob.
|
|
322
|
+
*/
|
|
323
|
+
export function applyReasoningField(out, field, level) {
|
|
324
|
+
const isBooleanField = /^(enable_thinking|thinking\.enabled|reasoning\.enabled)$/.test(field);
|
|
325
|
+
const isStateEnumField = /^thinking\.type$/.test(field);
|
|
326
|
+
const value = isBooleanField
|
|
327
|
+
? level !== 'none'
|
|
328
|
+
: isStateEnumField
|
|
329
|
+
? level === 'none' ? 'disabled' : 'enabled'
|
|
330
|
+
: level;
|
|
331
|
+
const segs = field.split('.');
|
|
332
|
+
let node = out;
|
|
333
|
+
for (let i = 0; i < segs.length - 1; i++) {
|
|
334
|
+
const k = segs[i];
|
|
335
|
+
if (!node[k] || typeof node[k] !== 'object' || Array.isArray(node[k]))
|
|
336
|
+
node[k] = {};
|
|
337
|
+
node = node[k];
|
|
338
|
+
}
|
|
339
|
+
node[segs[segs.length - 1]] = value;
|
|
340
|
+
}
|
|
309
341
|
/** IR → the legacy execution request / OpenAI-chat request. */
|
|
310
342
|
export function irToChatRequest(ir, model, options = {}) {
|
|
311
343
|
assertCanonicalRequestSupported(ir, 'openai-chat', {
|
|
@@ -424,7 +456,7 @@ export function irToChatRequest(ir, model, options = {}) {
|
|
|
424
456
|
const gen = ir.generation;
|
|
425
457
|
const tools = ir.tools?.map((t) => {
|
|
426
458
|
if (t.type !== 'function') {
|
|
427
|
-
unsupported('tool_type',
|
|
459
|
+
unsupported('tool_type', unsupportedToolKindMessage('openai-chat', t.type, false));
|
|
428
460
|
}
|
|
429
461
|
return {
|
|
430
462
|
type: 'function',
|
|
@@ -444,7 +476,9 @@ export function irToChatRequest(ir, model, options = {}) {
|
|
|
444
476
|
? { type: 'function', function: { name: ir.toolChoice.name } }
|
|
445
477
|
: ir.toolChoice.type === 'auto' || ir.toolChoice.type === 'none' || ir.toolChoice.type === 'required'
|
|
446
478
|
? ir.toolChoice.type
|
|
447
|
-
:
|
|
479
|
+
: ir.toolChoice.type === 'custom'
|
|
480
|
+
? unsupported('tool_choice', unsupportedToolKindMessage('openai-chat', 'custom', true))
|
|
481
|
+
: unsupported('tool_choice', unsupportedToolKindMessage('openai-chat', String(ir.toolChoice.type), true))
|
|
448
482
|
: undefined;
|
|
449
483
|
if (ir.text?.verbosity)
|
|
450
484
|
unsupported('text_verbosity', 'Chat cannot represent text.verbosity on this execution bridge.');
|
|
@@ -495,7 +529,9 @@ export function irToChatRequest(ir, model, options = {}) {
|
|
|
495
529
|
: { type: ir.text.format.type },
|
|
496
530
|
}
|
|
497
531
|
: {}),
|
|
498
|
-
...(ir.reasoning?.effort
|
|
532
|
+
...(ir.reasoning?.effort && !options.compatibility?.suppressReasoningEffort && !options.compatibility?.reasoningField
|
|
533
|
+
? { reasoning_effort: ir.reasoning.effort }
|
|
534
|
+
: {}),
|
|
499
535
|
...(options.carrierExtensions !== false && ir.reasoning?.budgetTokens !== undefined
|
|
500
536
|
? { max_thinking_tokens: ir.reasoning.budgetTokens }
|
|
501
537
|
: {}),
|
|
@@ -538,6 +574,11 @@ export function usageToIR(usage) {
|
|
|
538
574
|
...(usage?.completion_tokens_details?.rejected_prediction_tokens !== undefined
|
|
539
575
|
? { rejectedPredictionTokens: usage.completion_tokens_details.rejected_prediction_tokens }
|
|
540
576
|
: {}),
|
|
577
|
+
// Vendor-reported committed cost (plugin extension on the chat usage
|
|
578
|
+
// frame). Passed through so bookings use the invoice, not a price table.
|
|
579
|
+
...(typeof usage?.cost_usd === 'number' && Number.isFinite(usage.cost_usd)
|
|
580
|
+
? { vendorCostUsd: usage.cost_usd }
|
|
581
|
+
: {}),
|
|
541
582
|
};
|
|
542
583
|
}
|
|
543
584
|
function choiceToCandidate(choice) {
|
|
@@ -552,10 +593,13 @@ function choiceToCandidate(choice) {
|
|
|
552
593
|
output.push({ type: 'message', role: 'assistant', content: [{ type: 'refusal', text: choice.message.refusal }] });
|
|
553
594
|
}
|
|
554
595
|
for (const call of choice.message.tool_calls ?? []) {
|
|
596
|
+
// A lenient OpenAI-compatible server can return `tool_calls[]` with NO id. Mint it HERE, in canonical
|
|
597
|
+
// state, so the session store, capture and every carrier see one name for one call.
|
|
598
|
+
const id = upstreamToolCallId(call.id);
|
|
555
599
|
output.push({
|
|
556
600
|
type: 'tool_call',
|
|
557
|
-
id
|
|
558
|
-
callId:
|
|
601
|
+
id,
|
|
602
|
+
callId: id,
|
|
559
603
|
name: call.function.name,
|
|
560
604
|
arguments: call.function.arguments ?? '{}',
|
|
561
605
|
});
|
|
@@ -28,6 +28,7 @@ export declare function newResponseMessageId(): string;
|
|
|
28
28
|
export declare function canonicalToResponsesObject(response: CanonicalResponse, ids: {
|
|
29
29
|
respId: string;
|
|
30
30
|
messageId?: string;
|
|
31
|
+
anchorFor?: (index: number) => string | undefined;
|
|
31
32
|
}, model: string, store?: boolean, echo?: ResponsesEcho): Record<string, unknown>;
|
|
32
33
|
export declare function responsesEventFrame(payload: Record<string, unknown>): string;
|
|
33
34
|
/** One stateful encoder per Responses client stream. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { IrUnsupportedError } from '../errors.js';
|
|
3
3
|
import { assertCanonicalResponseSupported, assertCanonicalStreamEventSupported } from '../validate.js';
|
|
4
|
-
import { responsesPartToWire, responsesToolItemId } from './openai-responses.js';
|
|
4
|
+
import { responsesPartToWire, responsesToolItemId, toolItemPrefix } from './openai-responses.js';
|
|
5
5
|
const PROTOCOL = 'openai-responses';
|
|
6
6
|
function shortId(prefix) {
|
|
7
7
|
return prefix + crypto.randomBytes(12).toString('hex');
|
|
@@ -57,11 +57,31 @@ function responsesUsage(usage) {
|
|
|
57
57
|
function outputPartToWire(part) {
|
|
58
58
|
return responsesPartToWire(part, 'assistant');
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* An `extension` item's payload has to be a plain object BEFORE anything else touches the
|
|
62
|
+
* item: the streaming encoder caches an anchor for the output index first and renders the
|
|
63
|
+
* wire shape second, so a payload checked only at render time would leave a cached name
|
|
64
|
+
* behind for a request that is already failing. One check, called from both places.
|
|
65
|
+
*/
|
|
66
|
+
function extensionPayloadOf(item) {
|
|
67
|
+
const payload = item.type === 'extension' ? item.payload : undefined;
|
|
68
|
+
if (typeof payload !== 'object' || payload === null || Array.isArray(payload)) {
|
|
69
|
+
throw new IrUnsupportedError('output_item', 'A Responses extension output item must carry an object payload.', PROTOCOL);
|
|
70
|
+
}
|
|
71
|
+
return payload;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* `anchor` is the id the CALLER has settled on for THIS item — the streaming encoder passes
|
|
75
|
+
* its cached value, so an item never changes name between `output_item.added`, the terminal
|
|
76
|
+
* response, and a later replay, on ANY item type. A mint inside a branch below is therefore
|
|
77
|
+
* a fallback of last resort, not a second namespace. An EMPTY id counts as absent on every
|
|
78
|
+
* branch — the stream leg treats it the same way, and the two legs must not disagree.
|
|
79
|
+
*/
|
|
80
|
+
function outputItemToWire(item, anchor) {
|
|
61
81
|
if (item.type === 'message') {
|
|
62
82
|
return {
|
|
63
83
|
type: 'message',
|
|
64
|
-
id: item.id
|
|
84
|
+
id: item.id || anchor || shortId('msg_'),
|
|
65
85
|
status: item.status ?? 'completed',
|
|
66
86
|
role: 'assistant',
|
|
67
87
|
content: item.content.map(outputPartToWire),
|
|
@@ -69,10 +89,21 @@ function outputItemToWire(item, messageId) {
|
|
|
69
89
|
}
|
|
70
90
|
if (item.type === 'tool_call') {
|
|
71
91
|
const custom = item.vendor?.[PROTOCOL]?.itemType === 'custom_tool_call';
|
|
92
|
+
// A lenient upstream can hand back a tool call with NEITHER id (OpenAI-compat
|
|
93
|
+
// servers that return `tool_calls[]` without an `id`, which the chat adapter records
|
|
94
|
+
// as `''`). Both slots still have to carry something a client can address a tool
|
|
95
|
+
// result with, so they fall back to ONE anchor. Never `responsesToolItemId('')` — the
|
|
96
|
+
// digest of the empty string is CONSTANT, so every id-less call in one response
|
|
97
|
+
// collapsed onto the same item id and a client could not tell two `function_call`
|
|
98
|
+
// items apart — and never `call_id: ''`, which names nothing on any plane and which
|
|
99
|
+
// the outbound budget then refuses when the client replays it. A minted anchor is
|
|
100
|
+
// short, inside `CALL_ID_SHAPE`, and stable for the life of the stream. An id the
|
|
101
|
+
// item or the call already carries always wins, so a present `call_id` is untouched.
|
|
102
|
+
const anchorId = item.id || item.callId || anchor || shortId(toolItemPrefix(custom));
|
|
72
103
|
return {
|
|
73
104
|
type: custom ? 'custom_tool_call' : 'function_call',
|
|
74
|
-
id: responsesToolItemId(
|
|
75
|
-
call_id: item.callId
|
|
105
|
+
id: responsesToolItemId(anchorId, custom),
|
|
106
|
+
call_id: item.callId || anchorId,
|
|
76
107
|
name: item.name,
|
|
77
108
|
...(custom ? { input: item.arguments } : { arguments: item.arguments }),
|
|
78
109
|
status: item.status ?? 'completed',
|
|
@@ -81,7 +112,7 @@ function outputItemToWire(item, messageId) {
|
|
|
81
112
|
if (item.type === 'reasoning') {
|
|
82
113
|
return {
|
|
83
114
|
type: 'reasoning',
|
|
84
|
-
id: item.id
|
|
115
|
+
id: item.id || anchor || shortId('rs_'),
|
|
85
116
|
status: item.status ?? 'completed',
|
|
86
117
|
summary: item.summary?.map((text) => ({ type: 'summary_text', text })) ?? [],
|
|
87
118
|
...(item.text ? { content: [{ type: 'reasoning_text', text: item.text }] } : {}),
|
|
@@ -92,7 +123,15 @@ function outputItemToWire(item, messageId) {
|
|
|
92
123
|
if (item.protocol !== PROTOCOL) {
|
|
93
124
|
throw new IrUnsupportedError('output_item', `Cannot convert ${item.protocol} output to Responses.`, PROTOCOL);
|
|
94
125
|
}
|
|
95
|
-
|
|
126
|
+
// A same-protocol built-in item passes through with its own shape, but as a COPY: the
|
|
127
|
+
// canonical item is the very object capture and the session store read, and stamping a
|
|
128
|
+
// minted name into the payload would edit the operator's record of the upstream response.
|
|
129
|
+
// Its name still has to be present on BOTH legs: the stream mints an `item_` anchor for a
|
|
130
|
+
// payload with none, so the buffered leg mints the same shape instead of omitting the field
|
|
131
|
+
// (AGENTS.md: a field present on only one leg is a bug).
|
|
132
|
+
const payload = extensionPayloadOf(item);
|
|
133
|
+
const payloadId = typeof payload.id === 'string' && payload.id ? payload.id : undefined;
|
|
134
|
+
return { ...payload, id: payloadId ?? anchor ?? shortId('item_') };
|
|
96
135
|
}
|
|
97
136
|
export function canonicalToResponsesObject(response, ids, model, store = true, echo = defaultResponsesEcho()) {
|
|
98
137
|
assertCanonicalResponseSupported(response, PROTOCOL);
|
|
@@ -109,7 +148,7 @@ export function canonicalToResponsesObject(response, ids, model, store = true, e
|
|
|
109
148
|
instructions: echo.instructions,
|
|
110
149
|
metadata: echo.metadata,
|
|
111
150
|
model,
|
|
112
|
-
output: response.output.map((item, index) => outputItemToWire(item, index === 0 ? ids.messageId : undefined)),
|
|
151
|
+
output: response.output.map((item, index) => outputItemToWire(item, ids.anchorFor?.(index) ?? (index === 0 ? ids.messageId : undefined))),
|
|
113
152
|
parallel_tool_calls: echo.parallel_tool_calls,
|
|
114
153
|
temperature: echo.temperature,
|
|
115
154
|
tool_choice: echo.tool_choice,
|
|
@@ -295,13 +334,26 @@ export class OpenAIResponsesEventEncoder {
|
|
|
295
334
|
if (!item) {
|
|
296
335
|
throw new IrUnsupportedError('stream_lifecycle', `Responses stream references unopened output item ${index}.`, PROTOCOL);
|
|
297
336
|
}
|
|
298
|
-
|
|
337
|
+
// An EMPTY id is absent, not a name: `responsesToolItemId('')` digests the empty
|
|
338
|
+
// string, a constant, so id-less tool calls merged onto one item id, and a message
|
|
339
|
+
// with `id: ''` streamed out with an empty one.
|
|
340
|
+
const sourceId = 'id' in item && typeof item.id === 'string' && item.id ? item.id : undefined;
|
|
341
|
+
// An extension item keeps its name INSIDE the payload (`web_search_call` arrives as
|
|
342
|
+
// `{ id: 'ws_…', … }`), and `'id' in item` is false for the wrapper — so reading only the
|
|
343
|
+
// wrapper made the stream mint a name the buffered leg never shows. The payload is
|
|
344
|
+
// validated HERE, before the anchor is cached: checking it only at render time left a
|
|
345
|
+
// cached name behind for an item that then failed mid-stream, so a retry of the same
|
|
346
|
+
// output index could inherit an id from a request that never completed.
|
|
347
|
+
const payloadId = item.type === 'extension' ? extensionPayloadOf(item).id : undefined;
|
|
299
348
|
const custom = item.type === 'tool_call' && item.vendor?.[PROTOCOL]?.itemType === 'custom_tool_call';
|
|
300
|
-
const
|
|
301
|
-
?
|
|
302
|
-
:
|
|
303
|
-
|
|
304
|
-
|
|
349
|
+
const callAnchor = item.type === 'tool_call'
|
|
350
|
+
? (typeof item.callId === 'string' && item.callId ? item.callId : undefined)
|
|
351
|
+
: undefined;
|
|
352
|
+
const id = item.type === 'tool_call'
|
|
353
|
+
? responsesToolItemId(sourceId ?? callAnchor ?? shortId(toolItemPrefix(custom)), custom)
|
|
354
|
+
: sourceId ?? (typeof payloadId === 'string' && payloadId ? payloadId : undefined)
|
|
355
|
+
?? (item.type === 'message' && index === 0 ? this.messageId : undefined)
|
|
356
|
+
?? shortId(item.type === 'message' ? 'msg_' : item.type === 'reasoning' ? 'rs_' : 'item_');
|
|
305
357
|
this.itemIds.set(index, id);
|
|
306
358
|
return id;
|
|
307
359
|
}
|
|
@@ -337,17 +389,11 @@ export class OpenAIResponsesEventEncoder {
|
|
|
337
389
|
};
|
|
338
390
|
const object = canonicalToResponsesObject(base, {
|
|
339
391
|
respId: this.respId, messageId: this.messageId,
|
|
392
|
+
anchorFor: (index) => this.itemIds.get(index),
|
|
340
393
|
}, model, this.store, this.echo);
|
|
341
394
|
object.status = status;
|
|
342
395
|
if (opening)
|
|
343
396
|
object.output = [];
|
|
344
|
-
else if (Array.isArray(object.output)) {
|
|
345
|
-
object.output.forEach((item, index) => {
|
|
346
|
-
const id = this.itemIds.get(index);
|
|
347
|
-
if (id)
|
|
348
|
-
item.id = id;
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
397
|
return object;
|
|
352
398
|
}
|
|
353
399
|
sequenced(payload) {
|
|
@@ -5,7 +5,20 @@ export declare class OpenAIResponsesStreamDecoder {
|
|
|
5
5
|
private terminalSent;
|
|
6
6
|
private createdSent;
|
|
7
7
|
private readonly annotations;
|
|
8
|
+
/**
|
|
9
|
+
* Names this decoder invented for items the wire left unnamed, keyed by output index. An
|
|
10
|
+
* id-less `function_call` arrives as BOTH `output_item.added` and `output_item.done`, and
|
|
11
|
+
* each frame is read on its own, so a plain read-time mint would give one item two canonical
|
|
12
|
+
* ids. The accumulator replaces the added item with the done item (`ir/stream.ts`), so the
|
|
13
|
+
* LAST name wins: without this memo the id a client was handed while streaming is not the
|
|
14
|
+
* one its tool result pairs against, and the buffered and streaming legs of one accounting
|
|
15
|
+
* plane disagree. First name seen wins here, and it is reused for every later frame of the
|
|
16
|
+
* same index; an id the upstream DID send is never touched.
|
|
17
|
+
*/
|
|
18
|
+
private readonly mintedIds;
|
|
8
19
|
get terminated(): boolean;
|
|
20
|
+
/** Read one wire item, reusing this decoder's name for an item the wire left unnamed. */
|
|
21
|
+
private namedItem;
|
|
9
22
|
push(raw: unknown): StreamEvent[];
|
|
10
23
|
finish(): StreamEvent[];
|
|
11
24
|
private key;
|
|
@@ -12,6 +12,14 @@ function itemFromWire(raw) {
|
|
|
12
12
|
invalid('output_item did not contain an item.');
|
|
13
13
|
return item;
|
|
14
14
|
}
|
|
15
|
+
/** A wire tool item that carries NO name of its own (`id` and `call_id` both absent or empty). */
|
|
16
|
+
function wireNamesToolCall(raw) {
|
|
17
|
+
const item = record(raw);
|
|
18
|
+
if (item.type !== 'function_call' && item.type !== 'custom_tool_call')
|
|
19
|
+
return true;
|
|
20
|
+
return (typeof item.call_id === 'string' && item.call_id !== '')
|
|
21
|
+
|| (typeof item.id === 'string' && item.id !== '');
|
|
22
|
+
}
|
|
15
23
|
const BUILTIN_TOOL_PROGRESS_RE = /^response\.(?:web_search_call|file_search_call|code_interpreter_call|code_interpreter_call_code|mcp_call|mcp_call_arguments|mcp_list_tools|image_generation_call)\.(?:in_progress|searching|interpreting|generating|partial_image|delta|done|completed|failed)$/;
|
|
16
24
|
/** Stateful OpenAI Responses SSE → canonical item lifecycle decoder. */
|
|
17
25
|
export class OpenAIResponsesStreamDecoder {
|
|
@@ -19,9 +27,34 @@ export class OpenAIResponsesStreamDecoder {
|
|
|
19
27
|
terminalSent = false;
|
|
20
28
|
createdSent = false;
|
|
21
29
|
annotations = new Map();
|
|
30
|
+
/**
|
|
31
|
+
* Names this decoder invented for items the wire left unnamed, keyed by output index. An
|
|
32
|
+
* id-less `function_call` arrives as BOTH `output_item.added` and `output_item.done`, and
|
|
33
|
+
* each frame is read on its own, so a plain read-time mint would give one item two canonical
|
|
34
|
+
* ids. The accumulator replaces the added item with the done item (`ir/stream.ts`), so the
|
|
35
|
+
* LAST name wins: without this memo the id a client was handed while streaming is not the
|
|
36
|
+
* one its tool result pairs against, and the buffered and streaming legs of one accounting
|
|
37
|
+
* plane disagree. First name seen wins here, and it is reused for every later frame of the
|
|
38
|
+
* same index; an id the upstream DID send is never touched.
|
|
39
|
+
*/
|
|
40
|
+
mintedIds = new Map();
|
|
22
41
|
get terminated() {
|
|
23
42
|
return this.nativeTerminal;
|
|
24
43
|
}
|
|
44
|
+
/** Read one wire item, reusing this decoder's name for an item the wire left unnamed. */
|
|
45
|
+
namedItem(index, raw) {
|
|
46
|
+
const item = itemFromWire(raw);
|
|
47
|
+
if (item.type !== 'tool_call' || wireNamesToolCall(raw))
|
|
48
|
+
return item;
|
|
49
|
+
const seen = this.mintedIds.get(index);
|
|
50
|
+
if (seen) {
|
|
51
|
+
item.id = seen;
|
|
52
|
+
item.callId = seen;
|
|
53
|
+
return item;
|
|
54
|
+
}
|
|
55
|
+
this.mintedIds.set(index, item.id ?? '');
|
|
56
|
+
return item;
|
|
57
|
+
}
|
|
25
58
|
push(raw) {
|
|
26
59
|
const frame = record(raw);
|
|
27
60
|
const type = String(frame.type ?? '');
|
|
@@ -42,7 +75,7 @@ export class OpenAIResponsesStreamDecoder {
|
|
|
42
75
|
return [{
|
|
43
76
|
type: type === 'response.output_item.added' ? 'response.output_item.added' : 'response.output_item.done',
|
|
44
77
|
index,
|
|
45
|
-
item:
|
|
78
|
+
item: this.namedItem(index, frame.item),
|
|
46
79
|
}];
|
|
47
80
|
}
|
|
48
81
|
if (type === 'response.content_part.added' || type === 'response.content_part.done') {
|
|
@@ -16,9 +16,100 @@ export declare function responsesToolToWire(tool: ToolDef): Record<string, unkno
|
|
|
16
16
|
* - Injective: distinct tool-call ids MUST NOT collapse onto one item id. The
|
|
17
17
|
* chat client controls `tool_calls[].id`, so an id that is not safe both in
|
|
18
18
|
* charset and length is hashed instead of sanitized/truncated — dropping
|
|
19
|
-
* characters or a tail would silently merge two calls into one id.
|
|
19
|
+
* characters or a tail would silently merge two calls into one id. What MAY be
|
|
20
|
+
* shortened is the DIGEST (to RESPONSES_TOOL_ITEM_ID_MAX_LEN, because the
|
|
21
|
+
* item-type prefix eats the room RESPONSES_CALL_ID_MAX_LEN gives a bare
|
|
22
|
+
* correlation id), never the original string.
|
|
20
23
|
*/
|
|
24
|
+
/**
|
|
25
|
+
* The item-id namespace for a tool call (`fc_` for a function call, `ctc_` for a custom one).
|
|
26
|
+
* Declared once because the anchor mint in `openai-responses-output.ts` has to agree with it:
|
|
27
|
+
* a minted id that missed this prefix would come back double-prefixed.
|
|
28
|
+
*/
|
|
29
|
+
export declare function toolItemPrefix(custom: boolean): string;
|
|
21
30
|
export declare function responsesToolItemId(id: string, custom: boolean): string;
|
|
31
|
+
/**
|
|
32
|
+
* sha256 hex, shortened only as far as the destination field requires — callers
|
|
33
|
+
* subtract their own prefix (and any suffix they append) from the budget first.
|
|
34
|
+
* A budget above sha256's own 64 hex chars is satisfied by the full digest, so only
|
|
35
|
+
* the LOW side needs a guard: `slice(0, 0)` returns the whole digest and a NEGATIVE
|
|
36
|
+
* length returns `64 - n` characters, so an unguarded non-positive budget hands back
|
|
37
|
+
* a 64-char id when the caller asked for none. The floor makes a zero/negative budget
|
|
38
|
+
* yield ONE character — a caller that over-subtracts then gets an id that is still too
|
|
39
|
+
* long for its field (visible, and our own gate rewrites it), which is honest in a way
|
|
40
|
+
* a silent 64-char digest would not be.
|
|
41
|
+
*/
|
|
42
|
+
export declare function idDigest(id: string, maxLen: number): string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether an id is ALREADY a legal `call_id`, so any projector can keep it byte-identical.
|
|
45
|
+
* Exported because the markup-recovery mint (`providers/compat/tool-markup-recovery.ts`) has
|
|
46
|
+
* to answer the same question about a response id it is about to embed — and because
|
|
47
|
+
* `slice`/`replace` on an id is never the right answer there (sanitising a response id is
|
|
48
|
+
* lossy, so it can alias two responses onto one correlation id). One charset, one predicate.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isCanonicalResponsesCallId(id: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The `call_` correlation namespace is declared once, in `ir/tool-identity.ts`, because the
|
|
53
|
+
* upstream readers mint ids there and the markup-recovery mint builds ids in the same
|
|
54
|
+
* namespace — two declarations would be two drift twins of one rule.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Canonical correlation id -> Responses `call_id`, with the same two invariants as
|
|
58
|
+
* `responsesToolItemId` plus the one it lacked: a FIELD BUDGET. Upstream Responses
|
|
59
|
+
* APIs validate this string's length, and a client id that arrived from another
|
|
60
|
+
* carrier (chat owns `tool_calls[].id`; the cursor-gateway loop re-injects the id a
|
|
61
|
+
* PREVIOUS upstream minted) would otherwise leave here verbatim and answer 400
|
|
62
|
+
* `Invalid 'input[N].call_id': string too long, maximum 64 characters`.
|
|
63
|
+
*
|
|
64
|
+
* THIS IS THE ONLY PROJECTION POINT, and that is load-bearing. Canonical state —
|
|
65
|
+
* `CanonicalResponse.output[].callId`, the session store a `store: true` Responses
|
|
66
|
+
* chain replays, and the capture rows — keeps the ORIGINAL id, because projecting
|
|
67
|
+
* there would break the other carriers (Anthropic `tool_use.id` has its own length
|
|
68
|
+
* rule). If the outbound RESPONSE leg projected too, a client would hold digests
|
|
69
|
+
* while the chain replays originals, and the two would meet as one history: an
|
|
70
|
+
* unpaired orphan, `repairToolCallPairing` synthesising
|
|
71
|
+
* "Tool call was cancelled before returning a result." over the client's real
|
|
72
|
+
* result, and no error anywhere. One projector on one leg keeps every plane in one
|
|
73
|
+
* naming system: a client replays the original it was handed, and this function
|
|
74
|
+
* turns it into the same digest on every turn.
|
|
75
|
+
*
|
|
76
|
+
* Four properties, all load-bearing:
|
|
77
|
+
*
|
|
78
|
+
* - Inside the field (its charset AND its length) -> BYTE-IDENTICAL. Most traffic
|
|
79
|
+
* never sees a rewrite, so carriers that key on the `call_` / `toolu_` shape keep
|
|
80
|
+
* seeing it. `call_id` needs no item-type prefix (that is why `responsesToolItemId`
|
|
81
|
+
* adds one and this does not have to), so the budget is spent entirely on the id.
|
|
82
|
+
* - Deterministic: the same history yields the same id on every turn, or the
|
|
83
|
+
* replayed prompt prefix busts the upstream prompt cache.
|
|
84
|
+
* - Injective: truncating the ORIGINAL to the budget is NOT the fallback — ids
|
|
85
|
+
* that share a 64-char prefix would silently merge, and a merged correlation id
|
|
86
|
+
* merges two tool results onto one call with no error anywhere. The replacement
|
|
87
|
+
* is a `sha256` digest (`call_` + 59 hex = 64, so 236 bits and no realistic
|
|
88
|
+
* collision), and it keeps the `call_` shape because consumers, session stores
|
|
89
|
+
* and operator greps key on it.
|
|
90
|
+
* - A PROJECTION: `responsesCallId(responsesCallId(x)) === responsesCallId(x)`,
|
|
91
|
+
* because the hashed form is itself inside the field. The correlation id
|
|
92
|
+
* flows back through the gateway (a client replays whatever id it was handed, and
|
|
93
|
+
* an extension item may carry one verbatim), so a map that is not idempotent
|
|
94
|
+
* would name the same call differently on two turns of one session.
|
|
95
|
+
*
|
|
96
|
+
* An empty id has no faithful representation — pairing is impossible without it —
|
|
97
|
+
* so it is refused in the plane's own envelope (`tool_call_id` is the machine code the
|
|
98
|
+
* client sees) rather than minted a placeholder, which would merge every unlabelled
|
|
99
|
+
* call onto one id, or relayed as `""` for the upstream to reject in a language the
|
|
100
|
+
* client cannot read. An EMPTY `call_id` counts as absent and falls back to the item
|
|
101
|
+
* id **when the caller has one to offer** — that is the tool-call branch, which passes
|
|
102
|
+
* `item.id`; a tool RESULT has no id of its own, so there the refusal above is what
|
|
103
|
+
* happens. The two carriers agree on the anchor because `chat`
|
|
104
|
+
* writes `callId = id`, and the inbound Responses reader does `call_id ?? id`; a
|
|
105
|
+
* stored turn from before the minting fix can carry `call_id: ""` beside a real item
|
|
106
|
+
* id. This is the LAST-MILE half of that contract: an empty correlation id is legal on
|
|
107
|
+
* the Chat and Anthropic outbound wires, so it is refused only when the dialed carrier
|
|
108
|
+
* requires one. The consequence is that the refusal is an `IrUnsupportedError`, which is
|
|
109
|
+
* NOT failover-eligible — correct for a malformed body every candidate would receive
|
|
110
|
+
* alike, but it means such a request ends here instead of trying the next model.
|
|
111
|
+
*/
|
|
112
|
+
export declare function responsesCallId(callId: string | undefined, fallback?: string): string;
|
|
22
113
|
/** Canonical IR → OpenAI Responses request. No request-object spreading. */
|
|
23
114
|
export declare function canonicalToResponsesPayload(ir: CanonicalRequest, model: ModelRegistration, stream?: boolean): Record<string, any>;
|
|
24
115
|
export declare function responsesInputToIR(raw: unknown): InputItem[];
|