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,15 +1,65 @@
|
|
|
1
1
|
import { ClientAdapter } from './base.js';
|
|
2
2
|
import { ClientHookStatus } from '../types.js';
|
|
3
|
+
/** One Codex-native catalog row (stock OpenAI entry or synthetic OCR id). */
|
|
4
|
+
export type CodexStockModel = Record<string, unknown> & {
|
|
5
|
+
slug: string;
|
|
6
|
+
};
|
|
7
|
+
/** Injectable stock-catalog loader — CI must not require a live `codex` binary. */
|
|
8
|
+
export type CodexStockCatalogLoader = () => CodexStockModel[];
|
|
9
|
+
/**
|
|
10
|
+
* Default loader: `codex debug models` in a throwaway CODEX_HOME with only
|
|
11
|
+
* the built-in openai provider. Failures surface as an empty list so setup
|
|
12
|
+
* still writes the OCR block (stock is best-effort).
|
|
13
|
+
*/
|
|
14
|
+
export declare function loadCodexStockCatalog(): CodexStockModel[];
|
|
15
|
+
/**
|
|
16
|
+
* Hook target: OpenAI Codex CLI and ChatGPT Desktop — both read
|
|
17
|
+
* `~/.codex/config.toml`. One write shape for both:
|
|
18
|
+
*
|
|
19
|
+
* - keep built-in `model_provider = "openai"`
|
|
20
|
+
* - point `openai_base_url` at the gateway
|
|
21
|
+
* - pin `model_catalog_json` = OCR selection first, then remaining stock
|
|
22
|
+
* OpenAI entries (Desktop’s allowlist still shows stock slugs; CLI `/model`
|
|
23
|
+
* shows the full merged list)
|
|
24
|
+
* - gateway key in `auth.json` (`OPENAI_API_KEY`)
|
|
25
|
+
*
|
|
26
|
+
* Legacy `omnicell-router` provider marks are stripped on setup/teardown so a
|
|
27
|
+
* previous CLI-only hook does not linger. TOML has no comment-preserving
|
|
28
|
+
* rewrite; the pre-write backup is the safety net.
|
|
29
|
+
*/
|
|
3
30
|
export declare class CodexClientAdapter implements ClientAdapter {
|
|
4
31
|
name: "codex";
|
|
5
32
|
hookKind: "config";
|
|
33
|
+
/** One hook covers Codex CLI and ChatGPT Desktop (shared ~/.codex). */
|
|
6
34
|
displayName: string;
|
|
35
|
+
shortName: string;
|
|
36
|
+
/** `codex --version` prints `codex-cli 0.166.0` on stdout (its arg0
|
|
37
|
+
* cleanup warning goes to stderr, so the banner's first token is the CLI's). */
|
|
38
|
+
versionCmd: string[];
|
|
39
|
+
/** The Codex CLI's published releases. */
|
|
40
|
+
updateSource: {
|
|
41
|
+
readonly kind: "npm";
|
|
42
|
+
readonly package: "@openai/codex";
|
|
43
|
+
};
|
|
44
|
+
/** Retired custom-provider id — still stripped for upgrade cleanliness. */
|
|
45
|
+
private static readonly LEGACY_PROVIDER_ID;
|
|
46
|
+
private static readonly PROFILE_PREFIX;
|
|
47
|
+
private static readonly CATALOG_FILE;
|
|
48
|
+
/** Previous Desktop-only catalog name — cleared on setup/teardown. */
|
|
49
|
+
private static readonly LEGACY_DESKTOP_CATALOG;
|
|
50
|
+
private static readonly AUTH_MODE_API;
|
|
51
|
+
private static readonly CATALOG_INSTRUCTIONS;
|
|
52
|
+
/** Override in tests to supply a fixture stock catalog. */
|
|
53
|
+
stockCatalogLoader: CodexStockCatalogLoader;
|
|
7
54
|
getConfigPath(): string;
|
|
55
|
+
private authPath;
|
|
8
56
|
getStatus(): Promise<Omit<ClientHookStatus, 'hookKind'>>;
|
|
9
57
|
setup(options?: {
|
|
10
58
|
port?: number;
|
|
11
59
|
models?: Record<string, string>;
|
|
12
60
|
apiKey?: string;
|
|
61
|
+
extraModels?: string[];
|
|
62
|
+
virtualModels?: string[];
|
|
13
63
|
}): Promise<{
|
|
14
64
|
success: boolean;
|
|
15
65
|
message: string;
|
|
@@ -18,4 +68,32 @@ export declare class CodexClientAdapter implements ClientAdapter {
|
|
|
18
68
|
success: boolean;
|
|
19
69
|
message: string;
|
|
20
70
|
}>;
|
|
71
|
+
private detectHook;
|
|
72
|
+
private detectLegacyProvider;
|
|
73
|
+
private strip;
|
|
74
|
+
private clearLegacyProvider;
|
|
75
|
+
private clearLegacyProviderKeys;
|
|
76
|
+
/**
|
|
77
|
+
* Picker catalog: OCR-selected ids first (cloned stock template when the id
|
|
78
|
+
* is official, else a synthetic row), then every remaining stock OpenAI
|
|
79
|
+
* entry so Desktop’s allowlist and CLI `/model` both stay populated.
|
|
80
|
+
*/
|
|
81
|
+
private writeMergedCatalog;
|
|
82
|
+
private syntheticCatalogEntry;
|
|
83
|
+
private writeAuthApiKey;
|
|
84
|
+
private restoreAuthBackup;
|
|
85
|
+
private rewriteManagedProfiles;
|
|
86
|
+
private clearManagedProfiles;
|
|
87
|
+
/**
|
|
88
|
+
* Profiles this adapter owns: `ocr-*.config.toml` whose body points at
|
|
89
|
+
* openai (unified) or the retired omnicell-router provider.
|
|
90
|
+
*/
|
|
91
|
+
private listManagedProfiles;
|
|
92
|
+
private uniqueProfileStem;
|
|
93
|
+
private clearCatalog;
|
|
94
|
+
private clearLegacyDesktopCatalog;
|
|
95
|
+
private catalogPath;
|
|
96
|
+
private isOurCatalogPath;
|
|
97
|
+
private readToml;
|
|
98
|
+
private writeToml;
|
|
21
99
|
}
|
|
@@ -1,39 +1,123 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
|
-
import {
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import TOML from '@iarna/toml';
|
|
6
|
+
import { createBackup, describeBackup, restoreBackup, defaultGatewayPort, } from './base.js';
|
|
7
|
+
import { renameWithRetry } from '../../utils/atomic-write.js';
|
|
8
|
+
import { VIRTUAL_AUTO_IDS } from '../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Default loader: `codex debug models` in a throwaway CODEX_HOME with only
|
|
11
|
+
* the built-in openai provider. Failures surface as an empty list so setup
|
|
12
|
+
* still writes the OCR block (stock is best-effort).
|
|
13
|
+
*/
|
|
14
|
+
export function loadCodexStockCatalog() {
|
|
15
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'ocr-codex-stock-'));
|
|
16
|
+
try {
|
|
17
|
+
fs.writeFileSync(path.join(tmp, 'config.toml'), ['model = "gpt-5.4"', 'model_provider = "openai"', ''].join('\n'));
|
|
18
|
+
const res = spawnSync('codex', ['debug', 'models'], {
|
|
19
|
+
encoding: 'utf8',
|
|
20
|
+
env: { ...process.env, CODEX_HOME: tmp },
|
|
21
|
+
maxBuffer: 20 * 1024 * 1024,
|
|
22
|
+
windowsHide: true,
|
|
23
|
+
});
|
|
24
|
+
if (res.status !== 0 || !res.stdout)
|
|
25
|
+
return [];
|
|
26
|
+
const parsed = JSON.parse(res.stdout);
|
|
27
|
+
return Array.isArray(parsed.models)
|
|
28
|
+
? parsed.models.filter((m) => typeof m?.slug === 'string' && m.slug)
|
|
29
|
+
: [];
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
try {
|
|
36
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
/* ignore */
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Hook target: OpenAI Codex CLI and ChatGPT Desktop — both read
|
|
45
|
+
* `~/.codex/config.toml`. One write shape for both:
|
|
46
|
+
*
|
|
47
|
+
* - keep built-in `model_provider = "openai"`
|
|
48
|
+
* - point `openai_base_url` at the gateway
|
|
49
|
+
* - pin `model_catalog_json` = OCR selection first, then remaining stock
|
|
50
|
+
* OpenAI entries (Desktop’s allowlist still shows stock slugs; CLI `/model`
|
|
51
|
+
* shows the full merged list)
|
|
52
|
+
* - gateway key in `auth.json` (`OPENAI_API_KEY`)
|
|
53
|
+
*
|
|
54
|
+
* Legacy `omnicell-router` provider marks are stripped on setup/teardown so a
|
|
55
|
+
* previous CLI-only hook does not linger. TOML has no comment-preserving
|
|
56
|
+
* rewrite; the pre-write backup is the safety net.
|
|
57
|
+
*/
|
|
5
58
|
export class CodexClientAdapter {
|
|
6
59
|
name = 'codex';
|
|
7
60
|
hookKind = 'config';
|
|
8
|
-
|
|
61
|
+
/** One hook covers Codex CLI and ChatGPT Desktop (shared ~/.codex). */
|
|
62
|
+
displayName = 'Codex / ChatGPT';
|
|
63
|
+
shortName = 'Codex / ChatGPT';
|
|
64
|
+
/** `codex --version` prints `codex-cli 0.166.0` on stdout (its arg0
|
|
65
|
+
* cleanup warning goes to stderr, so the banner's first token is the CLI's). */
|
|
66
|
+
versionCmd = ['codex', '--version'];
|
|
67
|
+
/** The Codex CLI's published releases. */
|
|
68
|
+
updateSource = { kind: 'npm', package: '@openai/codex' };
|
|
69
|
+
/** Retired custom-provider id — still stripped for upgrade cleanliness. */
|
|
70
|
+
static LEGACY_PROVIDER_ID = 'omnicell-router';
|
|
71
|
+
static PROFILE_PREFIX = 'ocr-';
|
|
72
|
+
static CATALOG_FILE = 'omnicell-router-models.json';
|
|
73
|
+
/** Previous Desktop-only catalog name — cleared on setup/teardown. */
|
|
74
|
+
static LEGACY_DESKTOP_CATALOG = 'chatgpt-ocr-models.json';
|
|
75
|
+
static AUTH_MODE_API = 'apikey';
|
|
76
|
+
static CATALOG_INSTRUCTIONS = 'You are a coding agent running in the Codex CLI, a terminal-based coding assistant. You help the user with software engineering tasks.';
|
|
77
|
+
/** Override in tests to supply a fixture stock catalog. */
|
|
78
|
+
stockCatalogLoader = loadCodexStockCatalog;
|
|
9
79
|
getConfigPath() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return candidateCodex;
|
|
15
|
-
if (fs.existsSync(candidateOpenAi))
|
|
16
|
-
return candidateOpenAi;
|
|
17
|
-
return candidateCodex;
|
|
80
|
+
return path.join(os.homedir(), '.codex', 'config.toml');
|
|
81
|
+
}
|
|
82
|
+
authPath() {
|
|
83
|
+
return path.join(path.dirname(this.getConfigPath()), 'auth.json');
|
|
18
84
|
}
|
|
19
85
|
async getStatus() {
|
|
20
86
|
const configPath = this.getConfigPath();
|
|
87
|
+
const configDir = path.dirname(configPath);
|
|
21
88
|
const exists = fs.existsSync(configPath);
|
|
22
89
|
const backupExists = fs.existsSync(`${configPath}.bak.ocr`);
|
|
23
90
|
let hooked = false;
|
|
24
|
-
let details = 'Direct OpenAI
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
91
|
+
let details = 'Direct OpenAI / ChatGPT connection';
|
|
92
|
+
let mainValue;
|
|
93
|
+
let extras;
|
|
94
|
+
if (exists) {
|
|
95
|
+
const data = this.readToml(configPath);
|
|
96
|
+
if (data) {
|
|
97
|
+
const gwPort = defaultGatewayPort();
|
|
98
|
+
if (this.detectHook(data, configDir, gwPort)) {
|
|
99
|
+
hooked = true;
|
|
100
|
+
details = `Routed to OmniCellRouter gateway (:${gwPort}/v1 via openai_base_url)`;
|
|
101
|
+
mainValue = typeof data.model === 'string' ? data.model : undefined;
|
|
102
|
+
// Extras echo from managed profiles ONLY. The merged catalog also
|
|
103
|
+
// carries remaining stock OpenAI rows (Desktop allowlist / CLI
|
|
104
|
+
// `/model`), and reading those as extras made the Clients "自定义"
|
|
105
|
+
// chip wall claim the operator had selected every gpt-* slug.
|
|
106
|
+
// Profiles are rewritten on setup as [...virtuals, ...extras];
|
|
107
|
+
// virtual ids are stripped below so the console sees the real pick.
|
|
108
|
+
extras = [
|
|
109
|
+
...new Set(this.listManagedProfiles(configDir)
|
|
110
|
+
.map((p) => p.model)
|
|
111
|
+
.filter((id) => id && id !== mainValue && !VIRTUAL_AUTO_IDS.has(id))),
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
details = 'Config exists but could not be parsed as TOML — fix it manually, then re-apply';
|
|
33
117
|
}
|
|
34
118
|
}
|
|
35
119
|
else {
|
|
36
|
-
details = 'No Codex
|
|
120
|
+
details = 'No Codex config file detected';
|
|
37
121
|
}
|
|
38
122
|
return {
|
|
39
123
|
name: this.name,
|
|
@@ -43,67 +127,401 @@ export class CodexClientAdapter {
|
|
|
43
127
|
hooked,
|
|
44
128
|
backupExists,
|
|
45
129
|
details,
|
|
46
|
-
modelSlots: [{ key: 'main', value: hooked
|
|
130
|
+
modelSlots: [{ key: 'main', value: hooked ? mainValue : undefined, default: 'auto' }],
|
|
131
|
+
extraModels: extras,
|
|
47
132
|
};
|
|
48
133
|
}
|
|
49
134
|
async setup(options) {
|
|
50
135
|
const configPath = this.getConfigPath();
|
|
136
|
+
const configDir = path.dirname(configPath);
|
|
51
137
|
const port = options?.port || defaultGatewayPort();
|
|
52
138
|
const targetUrl = `http://127.0.0.1:${port}/v1`;
|
|
53
|
-
|
|
139
|
+
const apiKey = options?.apiKey?.trim();
|
|
140
|
+
if (!apiKey) {
|
|
141
|
+
return {
|
|
142
|
+
success: false,
|
|
143
|
+
message: 'Codex takeover requires a gateway API key (written into auth.json as OPENAI_API_KEY for the OCR hop)',
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
let data = {};
|
|
54
147
|
if (fs.existsSync(configPath)) {
|
|
148
|
+
const parsed = this.readToml(configPath);
|
|
149
|
+
if (parsed === null) {
|
|
150
|
+
return { success: false, message: `Could not parse TOML at ${configPath}; refusing to overwrite` };
|
|
151
|
+
}
|
|
152
|
+
data = parsed;
|
|
55
153
|
createBackup(configPath);
|
|
56
154
|
}
|
|
57
|
-
|
|
58
|
-
|
|
155
|
+
const main = options?.models?.main?.trim() || 'auto';
|
|
156
|
+
const extras = (options?.extraModels || [])
|
|
157
|
+
.map((id) => (id || '').trim())
|
|
158
|
+
.filter((id) => id && id !== main && !VIRTUAL_AUTO_IDS.has(id));
|
|
159
|
+
const virtuals = Array.isArray(options?.virtualModels)
|
|
160
|
+
? [...VIRTUAL_AUTO_IDS].filter((id) => options.virtualModels.includes(id) && id !== main)
|
|
161
|
+
: [...VIRTUAL_AUTO_IDS].filter((id) => id !== main);
|
|
162
|
+
this.clearLegacyProvider(data, configDir);
|
|
163
|
+
if (typeof data.openai_base_url === 'string' && data.openai_base_url && !data._ocr_previous_openai_base_url) {
|
|
164
|
+
data._ocr_previous_openai_base_url = data.openai_base_url;
|
|
59
165
|
}
|
|
60
|
-
data.
|
|
61
|
-
data.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
166
|
+
data.openai_base_url = targetUrl;
|
|
167
|
+
data.model_provider = 'openai';
|
|
168
|
+
data.model = main;
|
|
169
|
+
delete data.profile;
|
|
170
|
+
if (data.profiles)
|
|
171
|
+
delete data.profiles;
|
|
172
|
+
const ocrIds = [main, ...virtuals, ...extras];
|
|
173
|
+
const { path: catalogPath, count: catalogCount } = this.writeMergedCatalog(configDir, ocrIds);
|
|
174
|
+
data.model_catalog_json = catalogPath.replace(/\\/g, '/');
|
|
175
|
+
const authNote = this.writeAuthApiKey(apiKey);
|
|
176
|
+
this.writeToml(configPath, data);
|
|
177
|
+
this.rewriteManagedProfiles(configDir, [...virtuals, ...extras]);
|
|
71
178
|
return {
|
|
72
179
|
success: true,
|
|
73
|
-
message: `Codex configured to route via OCR (${targetUrl}, model: ${
|
|
180
|
+
message: `Codex configured to route via OCR (${targetUrl}, openai_base_url, ${catalogCount} picker entr${catalogCount === 1 ? 'y' : 'ies'} = OCR + stock OpenAI, model: ${main}). Fully quit and relaunch Codex CLI / ChatGPT Desktop so the picker reloads.${describeBackup(configPath)}${authNote}`,
|
|
74
181
|
};
|
|
75
182
|
}
|
|
76
183
|
async teardown() {
|
|
77
184
|
const configPath = this.getConfigPath();
|
|
78
|
-
|
|
185
|
+
const configDir = path.dirname(configPath);
|
|
186
|
+
const authPath = this.authPath();
|
|
187
|
+
if (!fs.existsSync(configPath) &&
|
|
188
|
+
this.listManagedProfiles(configDir).length === 0 &&
|
|
189
|
+
!fs.existsSync(this.catalogPath(configDir)) &&
|
|
190
|
+
!fs.existsSync(path.join(configDir, CodexClientAdapter.LEGACY_DESKTOP_CATALOG)) &&
|
|
191
|
+
!fs.existsSync(`${authPath}.bak.ocr`)) {
|
|
79
192
|
return { success: false, message: `Configuration file not found at ${configPath}` };
|
|
80
193
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
194
|
+
const restored = fs.existsSync(configPath) ? restoreBackup(configPath) : false;
|
|
195
|
+
if (fs.existsSync(configPath)) {
|
|
196
|
+
const data = this.readToml(configPath);
|
|
197
|
+
if (data === null) {
|
|
198
|
+
return { success: false, message: `Could not parse Codex config at ${configPath}` };
|
|
199
|
+
}
|
|
200
|
+
this.strip(data, configDir);
|
|
201
|
+
this.writeToml(configPath, data);
|
|
202
|
+
}
|
|
203
|
+
this.clearManagedProfiles(configDir);
|
|
204
|
+
this.clearCatalog(configDir);
|
|
205
|
+
this.clearLegacyDesktopCatalog(configDir);
|
|
206
|
+
const authRestored = this.restoreAuthBackup();
|
|
207
|
+
return {
|
|
208
|
+
success: true,
|
|
209
|
+
message: restored
|
|
210
|
+
? `Codex configuration restored from backup (${configPath}.bak.ocr)${authRestored ? '; auth.json restored' : ''}`
|
|
211
|
+
: `Codex configuration decoupled from OCR.${authRestored ? ' auth.json restored.' : ''}`,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
detectHook(data, configDir, gwPort) {
|
|
215
|
+
const base = typeof data.openai_base_url === 'string' ? data.openai_base_url : '';
|
|
216
|
+
const viaBase = base.includes(`127.0.0.1:${gwPort}`) &&
|
|
217
|
+
(data.model_provider === 'openai' || data.model_provider == null);
|
|
218
|
+
const catalogPinned = this.isOurCatalogPath(data.model_catalog_json, configDir);
|
|
219
|
+
// Legacy CLI hook (pre-unification) still counts as hooked until re-setup.
|
|
220
|
+
const legacy = this.detectLegacyProvider(data, gwPort);
|
|
221
|
+
return viaBase || catalogPinned || legacy;
|
|
222
|
+
}
|
|
223
|
+
detectLegacyProvider(data, gwPort) {
|
|
224
|
+
const provider = data.model_providers?.[CodexClientAdapter.LEGACY_PROVIDER_ID];
|
|
225
|
+
const providerRouted = typeof provider?.base_url === 'string' && provider.base_url.includes(`127.0.0.1:${gwPort}`);
|
|
226
|
+
return providerRouted || data.model_provider === CodexClientAdapter.LEGACY_PROVIDER_ID;
|
|
227
|
+
}
|
|
228
|
+
strip(data, configDir) {
|
|
229
|
+
this.clearLegacyProviderKeys(data);
|
|
230
|
+
const previous = data._ocr_previous_openai_base_url;
|
|
231
|
+
if (typeof previous === 'string' && previous) {
|
|
232
|
+
data.openai_base_url = previous;
|
|
86
233
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return { success: false, message: `Could not parse Codex config at ${configPath}` };
|
|
234
|
+
else if (typeof data.openai_base_url === 'string' && data.openai_base_url.includes('127.0.0.1:')) {
|
|
235
|
+
delete data.openai_base_url;
|
|
90
236
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
delete data._ocr_previous_base_url;
|
|
237
|
+
delete data._ocr_previous_openai_base_url;
|
|
238
|
+
if (this.isOurCatalogPath(data.model_catalog_json, configDir)) {
|
|
239
|
+
delete data.model_catalog_json;
|
|
95
240
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
241
|
+
const legacyCat = path.join(configDir, CodexClientAdapter.LEGACY_DESKTOP_CATALOG);
|
|
242
|
+
if (typeof data.model_catalog_json === 'string') {
|
|
243
|
+
const norm = (p) => path.normalize(p.replace(/\//g, path.sep)).toLowerCase();
|
|
244
|
+
if (norm(data.model_catalog_json) === norm(legacyCat))
|
|
245
|
+
delete data.model_catalog_json;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
clearLegacyProvider(data, configDir) {
|
|
249
|
+
this.clearLegacyProviderKeys(data);
|
|
250
|
+
this.clearLegacyDesktopCatalog(configDir);
|
|
251
|
+
// Drop leftover helper profiles from the old Desktop-only prefix.
|
|
252
|
+
if (fs.existsSync(configDir)) {
|
|
253
|
+
let names;
|
|
254
|
+
try {
|
|
255
|
+
names = fs.readdirSync(configDir);
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
names = [];
|
|
259
|
+
}
|
|
260
|
+
for (const name of names) {
|
|
261
|
+
if (!name.startsWith('chatgpt-') || !name.endsWith('.config.toml'))
|
|
262
|
+
continue;
|
|
263
|
+
try {
|
|
264
|
+
fs.unlinkSync(path.join(configDir, name));
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
/* ignore */
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
clearLegacyProviderKeys(data) {
|
|
273
|
+
const providers = data.model_providers;
|
|
274
|
+
if (providers?.[CodexClientAdapter.LEGACY_PROVIDER_ID]) {
|
|
275
|
+
delete providers[CodexClientAdapter.LEGACY_PROVIDER_ID];
|
|
276
|
+
if (Object.keys(providers).length === 0)
|
|
277
|
+
delete data.model_providers;
|
|
278
|
+
}
|
|
279
|
+
if (data.model_provider === CodexClientAdapter.LEGACY_PROVIDER_ID) {
|
|
280
|
+
data.model_provider = 'openai';
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Picker catalog: OCR-selected ids first (cloned stock template when the id
|
|
285
|
+
* is official, else a synthetic row), then every remaining stock OpenAI
|
|
286
|
+
* entry so Desktop’s allowlist and CLI `/model` both stay populated.
|
|
287
|
+
*/
|
|
288
|
+
writeMergedCatalog(configDir, ocrIds) {
|
|
289
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
290
|
+
const filePath = this.catalogPath(configDir);
|
|
291
|
+
const stock = this.stockCatalogLoader();
|
|
292
|
+
const stockBySlug = new Map(stock.map((m) => [String(m.slug), m]));
|
|
293
|
+
const models = [];
|
|
294
|
+
const seen = new Set();
|
|
295
|
+
let priority = 0;
|
|
296
|
+
for (const slug of ocrIds) {
|
|
297
|
+
if (!slug || seen.has(slug))
|
|
298
|
+
continue;
|
|
299
|
+
seen.add(slug);
|
|
300
|
+
const template = stockBySlug.get(slug);
|
|
301
|
+
if (template) {
|
|
302
|
+
models.push({
|
|
303
|
+
...template,
|
|
304
|
+
priority: priority++,
|
|
305
|
+
visibility: 'list',
|
|
306
|
+
hidden: false,
|
|
307
|
+
supported_in_api: true,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
models.push(this.syntheticCatalogEntry(slug, priority++));
|
|
312
|
+
}
|
|
99
313
|
}
|
|
100
|
-
|
|
101
|
-
|
|
314
|
+
for (const row of stock) {
|
|
315
|
+
const slug = String(row.slug);
|
|
316
|
+
if (!slug || seen.has(slug))
|
|
317
|
+
continue;
|
|
318
|
+
if (row.visibility != null && row.visibility !== 'list')
|
|
319
|
+
continue;
|
|
320
|
+
seen.add(slug);
|
|
321
|
+
models.push({
|
|
322
|
+
...row,
|
|
323
|
+
priority: priority++,
|
|
324
|
+
visibility: 'list',
|
|
325
|
+
hidden: false,
|
|
326
|
+
supported_in_api: true,
|
|
327
|
+
});
|
|
102
328
|
}
|
|
103
|
-
|
|
329
|
+
const tmp = `${filePath}.tmp.ocr`;
|
|
330
|
+
fs.writeFileSync(tmp, JSON.stringify({ models }, null, 2));
|
|
331
|
+
renameWithRetry(tmp, filePath);
|
|
332
|
+
this.clearLegacyDesktopCatalog(configDir);
|
|
333
|
+
return { path: filePath, count: models.length };
|
|
334
|
+
}
|
|
335
|
+
syntheticCatalogEntry(slug, priority) {
|
|
104
336
|
return {
|
|
105
|
-
|
|
106
|
-
|
|
337
|
+
slug,
|
|
338
|
+
display_name: slug,
|
|
339
|
+
description: `OmniCellRouter: ${slug}`,
|
|
340
|
+
supported_reasoning_levels: [
|
|
341
|
+
{ effort: 'low', description: 'Fast responses with lighter reasoning' },
|
|
342
|
+
{ effort: 'medium', description: 'Balances speed and reasoning depth' },
|
|
343
|
+
{ effort: 'high', description: 'Greater reasoning depth for complex problems' },
|
|
344
|
+
],
|
|
345
|
+
shell_type: 'shell_command',
|
|
346
|
+
visibility: 'list',
|
|
347
|
+
hidden: false,
|
|
348
|
+
supported_in_api: true,
|
|
349
|
+
priority,
|
|
350
|
+
availability_nux: null,
|
|
351
|
+
upgrade: null,
|
|
352
|
+
base_instructions: CodexClientAdapter.CATALOG_INSTRUCTIONS,
|
|
353
|
+
supports_reasoning_summaries: true,
|
|
354
|
+
support_verbosity: false,
|
|
355
|
+
default_verbosity: null,
|
|
356
|
+
apply_patch_tool_type: 'freeform',
|
|
357
|
+
truncation_policy: { mode: 'bytes', limit: 10_000 },
|
|
358
|
+
supports_parallel_tool_calls: true,
|
|
359
|
+
experimental_supported_tools: [],
|
|
360
|
+
context_window: 262_144,
|
|
361
|
+
max_context_window: 262_144,
|
|
362
|
+
input_modalities: ['text', 'image'],
|
|
107
363
|
};
|
|
108
364
|
}
|
|
365
|
+
writeAuthApiKey(apiKey) {
|
|
366
|
+
const authPath = this.authPath();
|
|
367
|
+
const backupPath = `${authPath}.bak.ocr`;
|
|
368
|
+
let data = {};
|
|
369
|
+
if (fs.existsSync(authPath)) {
|
|
370
|
+
try {
|
|
371
|
+
data = JSON.parse(fs.readFileSync(authPath, 'utf8'));
|
|
372
|
+
}
|
|
373
|
+
catch {
|
|
374
|
+
return ' (auth.json unreadable — gateway key not written; set OPENAI_API_KEY manually)';
|
|
375
|
+
}
|
|
376
|
+
if (!fs.existsSync(backupPath)) {
|
|
377
|
+
try {
|
|
378
|
+
fs.copyFileSync(authPath, backupPath);
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
/* ignore */
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
data.OPENAI_API_KEY = apiKey;
|
|
386
|
+
data.auth_mode = CodexClientAdapter.AUTH_MODE_API;
|
|
387
|
+
delete data.tokens;
|
|
388
|
+
try {
|
|
389
|
+
fs.mkdirSync(path.dirname(authPath), { recursive: true });
|
|
390
|
+
const tmp = `${authPath}.tmp.ocr`;
|
|
391
|
+
fs.writeFileSync(tmp, JSON.stringify(data, null, 2));
|
|
392
|
+
renameWithRetry(tmp, authPath);
|
|
393
|
+
return fs.existsSync(backupPath) ? ` auth.json updated (backup ${backupPath}).` : ' auth.json updated.';
|
|
394
|
+
}
|
|
395
|
+
catch (err) {
|
|
396
|
+
return ` (auth.json write failed: ${err instanceof Error ? err.message : String(err)})`;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
restoreAuthBackup() {
|
|
400
|
+
const authPath = this.authPath();
|
|
401
|
+
const backupPath = `${authPath}.bak.ocr`;
|
|
402
|
+
if (!fs.existsSync(backupPath))
|
|
403
|
+
return false;
|
|
404
|
+
try {
|
|
405
|
+
fs.copyFileSync(backupPath, authPath);
|
|
406
|
+
fs.unlinkSync(backupPath);
|
|
407
|
+
return true;
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
rewriteManagedProfiles(configDir, modelIds) {
|
|
414
|
+
this.clearManagedProfiles(configDir);
|
|
415
|
+
if (modelIds.length === 0)
|
|
416
|
+
return;
|
|
417
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
418
|
+
const used = new Set();
|
|
419
|
+
for (const modelId of modelIds) {
|
|
420
|
+
const stem = this.uniqueProfileStem(modelId, used);
|
|
421
|
+
used.add(stem);
|
|
422
|
+
const filePath = path.join(configDir, `${stem}.config.toml`);
|
|
423
|
+
const body = {
|
|
424
|
+
model: modelId,
|
|
425
|
+
model_provider: 'openai',
|
|
426
|
+
};
|
|
427
|
+
const tmp = `${filePath}.tmp.ocr`;
|
|
428
|
+
fs.writeFileSync(tmp, TOML.stringify(body));
|
|
429
|
+
renameWithRetry(tmp, filePath);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
clearManagedProfiles(configDir) {
|
|
433
|
+
for (const entry of this.listManagedProfiles(configDir)) {
|
|
434
|
+
try {
|
|
435
|
+
fs.unlinkSync(entry.filePath);
|
|
436
|
+
}
|
|
437
|
+
catch {
|
|
438
|
+
/* ignore */
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Profiles this adapter owns: `ocr-*.config.toml` whose body points at
|
|
444
|
+
* openai (unified) or the retired omnicell-router provider.
|
|
445
|
+
*/
|
|
446
|
+
listManagedProfiles(configDir) {
|
|
447
|
+
if (!fs.existsSync(configDir))
|
|
448
|
+
return [];
|
|
449
|
+
let names;
|
|
450
|
+
try {
|
|
451
|
+
names = fs.readdirSync(configDir);
|
|
452
|
+
}
|
|
453
|
+
catch {
|
|
454
|
+
return [];
|
|
455
|
+
}
|
|
456
|
+
const out = [];
|
|
457
|
+
for (const name of names) {
|
|
458
|
+
if (!name.startsWith(CodexClientAdapter.PROFILE_PREFIX) || !name.endsWith('.config.toml'))
|
|
459
|
+
continue;
|
|
460
|
+
const filePath = path.join(configDir, name);
|
|
461
|
+
const data = this.readToml(filePath);
|
|
462
|
+
if (!data)
|
|
463
|
+
continue;
|
|
464
|
+
if (data.model_provider !== 'openai' &&
|
|
465
|
+
data.model_provider !== CodexClientAdapter.LEGACY_PROVIDER_ID) {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (typeof data.model !== 'string' || !data.model)
|
|
469
|
+
continue;
|
|
470
|
+
out.push({ filePath, model: data.model });
|
|
471
|
+
}
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
474
|
+
uniqueProfileStem(modelId, used) {
|
|
475
|
+
const safe = modelId.replace(/[^a-zA-Z0-9_-]+/g, '_').replace(/^_+|_+$/g, '') || 'model';
|
|
476
|
+
let stem = `${CodexClientAdapter.PROFILE_PREFIX}${safe}`;
|
|
477
|
+
if (!used.has(stem))
|
|
478
|
+
return stem;
|
|
479
|
+
let n = 2;
|
|
480
|
+
while (used.has(`${stem}-${n}`))
|
|
481
|
+
n += 1;
|
|
482
|
+
return `${stem}-${n}`;
|
|
483
|
+
}
|
|
484
|
+
clearCatalog(configDir) {
|
|
485
|
+
try {
|
|
486
|
+
const p = this.catalogPath(configDir);
|
|
487
|
+
if (fs.existsSync(p))
|
|
488
|
+
fs.unlinkSync(p);
|
|
489
|
+
}
|
|
490
|
+
catch {
|
|
491
|
+
/* ignore */
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
clearLegacyDesktopCatalog(configDir) {
|
|
495
|
+
try {
|
|
496
|
+
const p = path.join(configDir, CodexClientAdapter.LEGACY_DESKTOP_CATALOG);
|
|
497
|
+
if (fs.existsSync(p))
|
|
498
|
+
fs.unlinkSync(p);
|
|
499
|
+
}
|
|
500
|
+
catch {
|
|
501
|
+
/* ignore */
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
catalogPath(configDir) {
|
|
505
|
+
return path.join(configDir, CodexClientAdapter.CATALOG_FILE);
|
|
506
|
+
}
|
|
507
|
+
isOurCatalogPath(value, configDir) {
|
|
508
|
+
if (typeof value !== 'string' || !value)
|
|
509
|
+
return false;
|
|
510
|
+
const norm = (p) => path.normalize(p.replace(/\//g, path.sep)).toLowerCase();
|
|
511
|
+
return norm(value) === norm(this.catalogPath(configDir));
|
|
512
|
+
}
|
|
513
|
+
readToml(configPath) {
|
|
514
|
+
try {
|
|
515
|
+
return TOML.parse(fs.readFileSync(configPath, 'utf8'));
|
|
516
|
+
}
|
|
517
|
+
catch {
|
|
518
|
+
return null;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
writeToml(configPath, data) {
|
|
522
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
523
|
+
const tmp = `${configPath}.tmp.ocr`;
|
|
524
|
+
fs.writeFileSync(tmp, TOML.stringify(data));
|
|
525
|
+
renameWithRetry(tmp, configPath);
|
|
526
|
+
}
|
|
109
527
|
}
|