@bitkyc08/opencodex 2.91.0 → 2.93.0-preview.20261027
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/bin/ocx.mjs +47 -8
- package/gui/dist/assets/App-CJZoq-uF.js +58 -0
- package/gui/dist/assets/{Tray-BuLy7hL1.js → Tray-BWQPcgZn.js} +1 -1
- package/gui/dist/assets/index-DRe8Hhfz.css +1 -0
- package/gui/dist/assets/index-Xfct8owH.js +94 -0
- package/gui/dist/assets/quota-summary-DxToX1rV.js +1 -0
- package/gui/dist/index.html +2 -2
- package/gui/dist/provider-icons/workbuddy-color.svg +29 -0
- package/package.json +8 -7
- package/src/adapters/anthropic.ts +28 -5
- package/src/adapters/coding-agent/batch-dispatcher.ts +122 -0
- package/src/adapters/coding-agent/profile.ts +54 -16
- package/src/adapters/coding-agent/turn.ts +30 -2
- package/src/adapters/command-code.ts +114 -7
- package/src/adapters/cursor/native-exec-fs.ts +11 -9
- package/src/adapters/devin/live-models.ts +4 -0
- package/src/adapters/google-vertex-endpoint.ts +9 -1
- package/src/adapters/google-vertex-key-project.ts +223 -0
- package/src/adapters/google-wire-compiler.ts +1 -2
- package/src/adapters/google.ts +13 -3
- package/src/adapters/kiro/reasoning.ts +2 -0
- package/src/adapters/kiro-refusal.ts +6 -1
- package/src/adapters/kiro-wire.ts +1 -1
- package/src/adapters/openai-chat/messages.ts +8 -2
- package/src/adapters/openai-chat/passthrough.ts +35 -14
- package/src/adapters/openai-chat/reasoning-replay.ts +27 -16
- package/src/adapters/openai-chat/reasoning-wire.ts +117 -8
- package/src/adapters/openai-chat/required-tool-result.ts +64 -0
- package/src/adapters/openai-chat/tool-name-registry.ts +3 -1
- package/src/adapters/openai-chat.ts +9 -10
- package/src/adapters/openai-responses/passthrough.ts +7 -4
- package/src/adapters/openai-responses/reasoning.ts +13 -0
- package/src/adapters/openai-responses/request-strips.ts +60 -0
- package/src/adapters/qoder/adapter.ts +129 -8
- package/src/adapters/qoder/scaffold-guard.ts +5 -0
- package/src/adapters/reasoning-controls.ts +16 -0
- package/src/adapters/registry.ts +5 -0
- package/src/adapters/tool-call-id.ts +1 -3
- package/src/adapters/workbuddy-schema.ts +61 -0
- package/src/adapters/workbuddy.ts +68 -0
- package/src/bridge/errors.ts +27 -0
- package/src/bridge/response-json.ts +1 -1
- package/src/bridge/sse.ts +1 -1
- package/src/bridge.ts +1 -1
- package/src/chat/inbound.ts +4 -1
- package/src/chat/outbound.ts +20 -6
- package/src/chat/reasoning-details.ts +28 -5
- package/src/claude/desktop-first-party.ts +54 -4
- package/src/claude/desktop-picker.ts +11 -8
- package/src/claude/first-party-settings.ts +3 -1
- package/src/claude/inbound.ts +2 -1
- package/src/claude/intercept/local-ca.ts +2 -1
- package/src/claude/intercept/picker-ca-cleanup.ts +4 -2
- package/src/claude/intercept/picker-ca-startup.ts +3 -1
- package/src/claude/intercept/picker-models.ts +6 -3
- package/src/claude/intercept/picker-runtime.ts +3 -2
- package/src/claude/intercept/runtime.ts +6 -3
- package/src/claude/model-info.ts +31 -8
- package/src/cli/account-api.ts +11 -0
- package/src/cli/capabilities-agents-routing.ts +3 -3
- package/src/cli/capabilities-base.ts +7 -1
- package/src/cli/capabilities-observe-system.ts +10 -0
- package/src/cli/claude-desktop.ts +9 -8
- package/src/cli/claude.ts +3 -2
- package/src/cli/codex-cli-update.ts +8 -0
- package/src/cli/codex-shim-autorestore.ts +9 -0
- package/src/cli/combo-result.ts +13 -0
- package/src/cli/combo-stats.ts +3 -0
- package/src/cli/combo.ts +83 -41
- package/src/cli/cross-home-owner.ts +13 -1
- package/src/cli/dispatch.ts +25 -6
- package/src/cli/ensure-desired-integrations.ts +8 -6
- package/src/cli/export-command.ts +4 -1
- package/src/cli/help.ts +2 -1
- package/src/cli/index.ts +45 -45
- package/src/cli/integration-plan-dto.ts +4 -0
- package/src/cli/launcher-context.ts +49 -2
- package/src/cli/link.ts +45 -32
- package/src/cli/opencode.ts +20 -9
- package/src/cli/provider.ts +2 -1
- package/src/cli/registry.ts +6 -4
- package/src/cli/root.ts +9 -0
- package/src/cli/status.ts +59 -1
- package/src/cli/stop-restore.ts +113 -0
- package/src/cli/sync-expectation.ts +60 -0
- package/src/cli/uninstall-integrations.ts +41 -7
- package/src/cli/usage-compare.ts +68 -12
- package/src/client/connect.ts +40 -3
- package/src/client/link-home.ts +10 -1
- package/src/client/link-ingress.ts +1 -1
- package/src/client/link-readiness.ts +97 -0
- package/src/client/link-relay-transport.ts +79 -11
- package/src/client/link-relay.ts +74 -15
- package/src/client/link-tunnel.ts +45 -18
- package/src/client/machine-api.ts +3 -1
- package/src/client/machine-listener.ts +20 -2
- package/src/client/runtime.ts +20 -2
- package/src/client/sync-expectation.ts +118 -0
- package/src/clients/config-export/agent-clients.ts +96 -0
- package/src/clients/config-export/contracts.ts +25 -7
- package/src/clients/config-export/qoder.ts +38 -23
- package/src/clients/config-export/reasoning-metadata.ts +55 -8
- package/src/clients/config-export.ts +12 -0
- package/src/clients/lazycodex.ts +7 -2
- package/src/clients/reasoning-controls.ts +49 -0
- package/src/codex/account-store.ts +17 -3
- package/src/codex/app-server-restart-service.ts +6 -5
- package/src/codex/auth-api/account-identity.ts +14 -0
- package/src/codex/auth-api/account-list.ts +29 -2
- package/src/codex/auth-api/http.ts +13 -0
- package/src/codex/auth-api/main-account-probe.ts +2 -2
- package/src/codex/auth-api/pool-mode-gate.ts +16 -3
- package/src/codex/auth-api/pool-quota-probe.ts +15 -0
- package/src/codex/auth-context.ts +15 -12
- package/src/codex/catalog/build-entries.ts +22 -0
- package/src/codex/catalog/configured-tiers.ts +70 -0
- package/src/codex/catalog/effort.ts +52 -11
- package/src/codex/catalog/gather-capture.ts +5 -2
- package/src/codex/catalog/heal-observation.ts +155 -13
- package/src/codex/catalog/metadata.ts +6 -0
- package/src/codex/catalog/model-hints.ts +60 -11
- package/src/codex/catalog/model-visibility.ts +3 -2
- package/src/codex/catalog/native-models.ts +18 -3
- package/src/codex/catalog/parsing.ts +10 -8
- package/src/codex/catalog/pinned-models.ts +2 -1
- package/src/codex/catalog/provider-models.ts +18 -13
- package/src/codex/catalog/retained-sync.ts +2 -1
- package/src/codex/catalog/routed-gather.ts +19 -20
- package/src/codex/catalog/write-audit.ts +3 -2
- package/src/codex/catalog-self-heal.ts +43 -23
- package/src/codex/chatgpt-refresh-failure.ts +6 -2
- package/src/codex/cli-install-provenance.ts +418 -0
- package/src/codex/cli-installation-targets.ts +5 -1
- package/src/codex/cli-update-plan.ts +43 -16
- package/src/codex/collision-identity.ts +30 -5
- package/src/codex/convergence.ts +4 -3
- package/src/codex/data/roster-pinned-models.json +177 -1
- package/src/codex/desired-state.ts +6 -1
- package/src/codex/desktop-app/picker-freshness.ts +10 -8
- package/src/codex/desktop-compatibility/installed-build.ts +88 -12
- package/src/codex/desktop-compatibility/runtime.ts +29 -5
- package/src/codex/desktop-compatibility/usage-activation.ts +2 -1
- package/src/codex/desktop-compatibility/usage-controller.ts +9 -1
- package/src/codex/desktop-compatibility/windows-certificate-trust.ts +46 -12
- package/src/codex/inject/config-toml.ts +0 -18
- package/src/codex/inject/plan.ts +18 -3
- package/src/codex/inject/remove.ts +6 -2
- package/src/codex/inject.ts +1 -1
- package/src/codex/journal.ts +61 -1
- package/src/codex/model-entitlements.ts +1 -1
- package/src/codex/native-main-owner.ts +27 -1
- package/src/codex/native-profile-store.ts +2 -1
- package/src/codex/pool-credit-policy.ts +35 -1
- package/src/codex/pool-refresh-backoff.ts +3 -1
- package/src/codex/quota-types.ts +3 -0
- package/src/codex/quota.ts +24 -4
- package/src/codex/role-auto-assign.ts +6 -2
- package/src/codex/subagent-defaults.ts +49 -4
- package/src/codex/user-identity.ts +35 -6
- package/src/codex/windows-current-sid.ts +162 -0
- package/src/combos/failover.ts +17 -2
- package/src/combos/jev-decision-contract.ts +22 -1
- package/src/combos/jev-quota-activation.ts +5 -1
- package/src/combos/jev-quota-route.ts +1 -1
- package/src/combos/jev-quota.ts +9 -1
- package/src/combos/jev-service-exchange.ts +3 -1
- package/src/combos/jev-session-pin-config.ts +51 -0
- package/src/combos/jev.ts +101 -9
- package/src/combos/resolve.ts +45 -1
- package/src/combos/types.ts +43 -0
- package/src/config/load-degrade.ts +5 -0
- package/src/config/paths.ts +19 -3
- package/src/config/pending-teardown.ts +22 -1
- package/src/config/provider-validation.ts +22 -4
- package/src/config/removed-opencode-free.ts +11 -0
- package/src/config/schema/leaf-validators.ts +6 -0
- package/src/generated/compatibility-version.json +467 -311
- package/src/generated/model-metadata.ts +5 -5
- package/src/images/loop.ts +16 -2
- package/src/integrations/catalog-refresh.ts +1 -1
- package/src/integrations/hermes-profiles.ts +251 -0
- package/src/integrations/merge.ts +8 -0
- package/src/integrations/mutation-plan.ts +19 -4
- package/src/integrations/registry.ts +5 -0
- package/src/integrations/state.ts +36 -1
- package/src/integrations/writer.ts +18 -4
- package/src/lib/bun-path-runtime.mjs +2 -1
- package/src/lib/decision-quota-sink.ts +10 -0
- package/src/lib/errors.ts +62 -0
- package/src/lib/eventstream-decoder.ts +81 -37
- package/src/lib/opaque-proxy-tunnel.ts +32 -8
- package/src/lib/pinned-http.ts +35 -2
- package/src/lib/process-control.ts +13 -1
- package/src/lib/socks5-fetch.ts +59 -64
- package/src/lib/socks5-upload-waiter.ts +50 -0
- package/src/lib/sse-decoder.ts +7 -2
- package/src/lib/state-store-sweeper.ts +40 -14
- package/src/lib/translator-budget.ts +4 -4
- package/src/lib/upstream-retry.ts +4 -1
- package/src/lib/windows-native-principal-worker.ts +14 -0
- package/src/lib/windows-native-principal.ts +188 -0
- package/src/lib/windows-secret-acl.ts +39 -3
- package/src/lib/windows-user-principal.ts +62 -18
- package/src/link/diagnostics.ts +193 -0
- package/src/link/relay-auth.ts +6 -0
- package/src/link/ssh-config.ts +35 -3
- package/src/link/status-projection.ts +39 -0
- package/src/link/supervisor.ts +45 -12
- package/src/link/tunnel-history.ts +109 -0
- package/src/link/tunnel-state.ts +80 -17
- package/src/messaging/remote-files.ts +24 -1
- package/src/oauth/generic-account-failover.ts +91 -7
- package/src/oauth/index.ts +15 -0
- package/src/oauth/model-discovery-auth.ts +5 -0
- package/src/oauth/store.ts +4 -1
- package/src/oauth/token-guardian.ts +7 -0
- package/src/oauth/types.ts +9 -0
- package/src/oauth/workbuddy.ts +139 -0
- package/src/providers/account-quota-disk.ts +12 -4
- package/src/providers/antigravity-quota-identity.ts +37 -0
- package/src/providers/base-url-choices.ts +8 -5
- package/src/providers/codebuddy-models.ts +6 -0
- package/src/providers/codex-capacity.ts +3 -1
- package/src/providers/derive.ts +51 -3
- package/src/providers/kiro-models.ts +3 -0
- package/src/providers/mimo-thinking.ts +12 -0
- package/src/providers/model-discovery.ts +2 -0
- package/src/providers/model-rename-fields.ts +2 -0
- package/src/providers/model-rename-migration.ts +10 -0
- package/src/providers/openai-sidecar-credit.ts +2 -2
- package/src/providers/quota/account-cache.ts +3 -2
- package/src/providers/quota/antigravity.ts +25 -14
- package/src/providers/quota/report-cache.ts +13 -4
- package/src/providers/quota/vendor-probes-key.ts +60 -0
- package/src/providers/quota/workbuddy.ts +83 -0
- package/src/providers/quota-decision-antigravity.ts +64 -0
- package/src/providers/quota-decision-publication.ts +11 -0
- package/src/providers/quota-decision-snapshot.ts +21 -4
- package/src/providers/quota-types.ts +2 -0
- package/src/providers/quota.ts +3 -1
- package/src/providers/reasoning-capabilities.ts +76 -0
- package/src/providers/registry/entries-core.ts +23 -12
- package/src/providers/registry/entries-extended.ts +83 -27
- package/src/providers/registry/model-ids.ts +5 -0
- package/src/providers/registry/model-seeds.ts +120 -56
- package/src/providers/registry/types.ts +29 -2
- package/src/providers/resolved-model-policy.ts +30 -10
- package/src/providers/routed-config.ts +24 -1
- package/src/providers/stale-model-roster-migration.ts +123 -18
- package/src/providers/workbuddy-credit-balance.ts +81 -0
- package/src/providers/workbuddy-models.ts +37 -0
- package/src/providers/workbuddy.ts +60 -0
- package/src/remote-control/workspace-pi-runtime.ts +11 -6
- package/src/responses/compaction-summary.ts +45 -0
- package/src/responses/muse-tool-name-alias.ts +1 -2
- package/src/responses/parser.ts +3 -2
- package/src/responses/reasoning-replay-cache.ts +18 -14
- package/src/responses/schema.ts +1 -0
- package/src/responses/thought-signature-replay.ts +10 -2
- package/src/router.ts +2 -0
- package/src/routing/analytics.ts +2 -3
- package/src/routing/capability.ts +8 -2
- package/src/routing/fallback-policy.ts +3 -3
- package/src/routing/history/ingest.ts +28 -3
- package/src/server/auth-cors.ts +4 -2
- package/src/server/chat-completions.ts +21 -1
- package/src/server/chat-native-eligibility.ts +7 -0
- package/src/server/chat-native-reasoning.ts +24 -7
- package/src/server/chat-native.ts +13 -2
- package/src/server/claude-messages.ts +3 -0
- package/src/server/direct-local-http.ts +5 -2
- package/src/server/effort-policy.ts +5 -1
- package/src/server/index/link-relay-sessions.ts +9 -5
- package/src/server/index/live-sideband.ts +18 -15
- package/src/server/index/optional-listeners.ts +4 -0
- package/src/server/index/serve-options.ts +5 -4
- package/src/server/local-management-read-client.ts +3 -1
- package/src/server/management/agent-settings-routes.ts +27 -15
- package/src/server/management/combo-routes.ts +14 -4
- package/src/server/management/config-routes.ts +2 -2
- package/src/server/management/decision-discovery.ts +12 -2
- package/src/server/management/hermes-profile-routes.ts +156 -0
- package/src/server/management/integration-routes.ts +85 -24
- package/src/server/management/link-routes.ts +5 -2
- package/src/server/management/model-routes.ts +2 -2
- package/src/server/management/model-row-export-metadata.ts +25 -6
- package/src/server/management/model-rows.ts +15 -20
- package/src/server/management/native-integration-routes.ts +11 -8
- package/src/server/management/provider-routes.ts +1 -1
- package/src/server/management/route-registry.ts +4 -0
- package/src/server/management-api.ts +5 -0
- package/src/server/models-capabilities.ts +21 -3
- package/src/server/port-reclaim.ts +51 -9
- package/src/server/request-log-conversation.ts +49 -0
- package/src/server/request-log.ts +2 -0
- package/src/server/responses/adapter-delivery.ts +11 -1
- package/src/server/responses/adapter-dispatch.ts +2 -2
- package/src/server/responses/anthropic-thinking-recovery.ts +1 -0
- package/src/server/responses/codex-ws-exchange.ts +39 -9
- package/src/server/responses/codex-ws-session.ts +38 -4
- package/src/server/responses/codex-ws-wire.ts +6 -1
- package/src/server/responses/combo-required-tool-contract.ts +103 -0
- package/src/server/responses/combo-stream-preflight.ts +8 -1
- package/src/server/responses/compact.ts +14 -5
- package/src/server/responses/context-overflow.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +10 -0
- package/src/server/responses/core-combo.ts +74 -44
- package/src/server/responses/core-lifetime.ts +5 -2
- package/src/server/responses/core-normalize.ts +17 -4
- package/src/server/responses/core-opaque-recovery.ts +1 -0
- package/src/server/responses/core-options.ts +7 -0
- package/src/server/responses/core-replay.ts +2 -1
- package/src/server/responses/jev-combo-choice.ts +39 -0
- package/src/server/responses/jev-session-pin.ts +203 -0
- package/src/server/responses/main-hard-lock-routing.ts +60 -44
- package/src/server/responses/passthrough-delivery.ts +44 -2
- package/src/server/responses/policy-fallback.ts +6 -1
- package/src/server/responses/request-compression.ts +12 -7
- package/src/server/responses/request-prepare.ts +32 -7
- package/src/server/responses/request-sidecar-auth.ts +2 -0
- package/src/server/responses/request-transport.ts +25 -6
- package/src/server/responses/response-effects.ts +22 -10
- package/src/server/responses/run-turn-execution.ts +2 -4
- package/src/server/responses/sidecar-execution.ts +13 -7
- package/src/server/responses-phase-inference.ts +267 -0
- package/src/server/sse-payload-rewrite.ts +14 -1
- package/src/server/stop-teardown.ts +36 -1
- package/src/server/ws-bridge.ts +1 -1
- package/src/service/definition.ts +20 -8
- package/src/service/desktop-supervision.d.mts +7 -4
- package/src/service/desktop-supervision.mjs +90 -13
- package/src/service/ownership-mutation-lease.mjs +21 -7
- package/src/types/config.ts +14 -2
- package/src/types/provider.ts +29 -7
- package/src/types/request.ts +11 -0
- package/src/types/wire.ts +1 -0
- package/src/types.ts +1 -0
- package/src/update/bind-probe.ts +29 -0
- package/src/update/codex-cli-update-launch-policy.d.mts +9 -0
- package/src/update/codex-cli-update-launch-policy.mjs +30 -0
- package/src/update/job.ts +10 -29
- package/src/update/npm-install-job.ps1 +173 -0
- package/src/update/npm-install.mjs +70 -0
- package/src/update/stop-contract.d.mts +1 -0
- package/src/update/stop-contract.mjs +14 -0
- package/src/update/stop-decision.d.mts +1 -1
- package/src/update/stop-decision.mjs +13 -3
- package/src/update/teardown-handover.ts +166 -0
- package/src/update/transactional-install.d.mts +14 -3
- package/src/update/transactional-install.mjs +33 -7
- package/src/usage/expected-prices.ts +64 -31
- package/src/usage/jev-stats.ts +54 -14
- package/src/usage/timeline.ts +19 -9
- package/src/vision/eligibility.ts +15 -5
- package/src/vision/plan.ts +2 -2
- package/src/web-search/loop.ts +16 -2
- package/gui/dist/assets/App-nZ34cR5G.js +0 -58
- package/gui/dist/assets/index-DGXS51sp.js +0 -94
- package/gui/dist/assets/index-DPeB9HpV.css +0 -1
- package/gui/dist/assets/quota-summary-DO1Sx5TM.js +0 -1
|
@@ -10,20 +10,35 @@
|
|
|
10
10
|
* This rewrites one thing: a saved `models` list that is still byte-for-byte the roster
|
|
11
11
|
* this file names as `from`, on a provider that still carries the registry adapter, and
|
|
12
12
|
* only while the registry currently seeds `to`. A list the user changed does not match and
|
|
13
|
-
* is left alone. For each added id it also fills a per-model context window
|
|
14
|
-
* effort, but only inside a container the row already has: enrichment fills
|
|
15
|
-
* all-or-nothing, so creating one here would hide the rest of the registry seed.
|
|
13
|
+
* is left alone. For each added id it also fills a per-model context window, output limit
|
|
14
|
+
* and default effort, but only inside a container the row already has: enrichment fills
|
|
15
|
+
* those records all-or-nothing, so creating one here would hide the rest of the registry seed.
|
|
16
16
|
* Same shape and restraint as `stale-context-window-migration`.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { ALIBABA_INTL_TOKEN_PLAN_BASE_URL, MOONSHOT_CN_BASE_URL, MOONSHOT_INTL_BASE_URL } from "./base-url-choices";
|
|
19
|
+
import { PROVIDER_REGISTRY, normalizedProviderEndpoint } from "./registry";
|
|
19
20
|
import {
|
|
21
|
+
ALIBABA_TOKEN_PLAN_MODELS,
|
|
22
|
+
ALIBABA_INTL_TOKEN_PLAN_MODELS,
|
|
23
|
+
ALIBABA_TOKEN_PLAN_CONTEXT_WINDOWS,
|
|
24
|
+
ALIBABA_TOKEN_PLAN_MAX_OUTPUT_TOKENS,
|
|
25
|
+
KIMI_API_DEFAULT_REASONING_EFFORTS,
|
|
26
|
+
KIMI_API_MODEL_CONTEXT_WINDOWS,
|
|
27
|
+
KIMI_API_MODELS,
|
|
28
|
+
KIMI_API_MODELS_BEFORE_K31,
|
|
29
|
+
META_MODEL_API_MODELS,
|
|
30
|
+
META_MUSE_CONTEXT_WINDOW,
|
|
31
|
+
META_MUSE_MODELS,
|
|
32
|
+
META_MUSE_WONDER_MODEL,
|
|
20
33
|
MINIMAX_M31_DEFAULT_REASONING_EFFORT,
|
|
21
|
-
|
|
34
|
+
MINIMAX_M31_FLASH,
|
|
35
|
+
MINIMAX_M31_FLASH_MAX_OUTPUT_TOKENS,
|
|
22
36
|
MINIMAX_MODELS,
|
|
23
37
|
MINIMAX_MODELS_BEFORE_M31,
|
|
24
38
|
MINIMAX_MODEL_CONTEXT_WINDOWS,
|
|
25
39
|
} from "./registry/model-seeds";
|
|
26
40
|
import type { OcxConfig } from "../types";
|
|
41
|
+
import { modelRecordValue } from "../reasoning-effort";
|
|
27
42
|
|
|
28
43
|
export interface StaleModelRoster {
|
|
29
44
|
/** Registry provider id whose saved rows may carry the old roster. */
|
|
@@ -33,7 +48,18 @@ export interface StaleModelRoster {
|
|
|
33
48
|
to: readonly string[];
|
|
34
49
|
/** Per-model seed values for the added ids, written only into containers that exist. */
|
|
35
50
|
contextWindows?: Readonly<Record<string, number>>;
|
|
51
|
+
/**
|
|
52
|
+
* Custom catalog rows read the saved map directly, so an added id missing from a
|
|
53
|
+
* partial map would publish without the registry output limit.
|
|
54
|
+
*/
|
|
55
|
+
maxOutputTokens?: Readonly<Record<string, number>>;
|
|
36
56
|
defaultReasoningEfforts?: Readonly<Record<string, string>>;
|
|
57
|
+
/**
|
|
58
|
+
* For a provider whose saved URL may point elsewhere (pay-as-you-go or Custom), the
|
|
59
|
+
* destinations whose roster `to` describes. A row on any other URL keeps its list; a row
|
|
60
|
+
* with no saved URL uses the registry default and is refreshed.
|
|
61
|
+
*/
|
|
62
|
+
destinationBaseUrls?: readonly string[];
|
|
37
63
|
}
|
|
38
64
|
|
|
39
65
|
export interface StaleModelRosterProjection {
|
|
@@ -42,17 +68,72 @@ export interface StaleModelRosterProjection {
|
|
|
42
68
|
warnings: string[];
|
|
43
69
|
}
|
|
44
70
|
|
|
71
|
+
const ALIBABA_TOKEN_PLAN_MODELS_BEFORE_1017 = [
|
|
72
|
+
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-flash",
|
|
73
|
+
"deepseek-v4-pro", "deepseek-v4-flash-0731", "deepseek-v4.1-flash", "glm-5.2", "glm-5.3",
|
|
74
|
+
];
|
|
75
|
+
const ALIBABA_INTL_TOKEN_PLAN_MODELS_BEFORE_1017 = [
|
|
76
|
+
"qwen3.8-max", "qwen3.8-flash", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus", "qwen3.6-flash",
|
|
77
|
+
"deepseek-v4-pro", "deepseek-v4-pro-0813", "deepseek-v4-flash", "deepseek-v4-flash-0731", "deepseek-v4.1-flash", "deepseek-v3.2",
|
|
78
|
+
"kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5",
|
|
79
|
+
"glm-5.2", "glm-5.3", "glm-5.1", "glm-5",
|
|
80
|
+
"MiniMax-M2.5",
|
|
81
|
+
];
|
|
82
|
+
|
|
45
83
|
/**
|
|
46
|
-
* MiniMax-M3.1-Flash
|
|
47
|
-
*
|
|
84
|
+
* MiniMax-M3.1-Flash (2026-10-21). MiniMax's /v1/models roster does not list the
|
|
85
|
+
* Flash, so live discovery cannot add it; the catalog keeps it only when it is configured.
|
|
48
86
|
*/
|
|
49
|
-
export const STALE_MODEL_ROSTERS: readonly StaleModelRoster[] = [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
87
|
+
export const STALE_MODEL_ROSTERS: readonly StaleModelRoster[] = [
|
|
88
|
+
{
|
|
89
|
+
provider: "meta-model",
|
|
90
|
+
from: META_MUSE_MODELS,
|
|
91
|
+
to: META_MODEL_API_MODELS,
|
|
92
|
+
contextWindows: { [META_MUSE_WONDER_MODEL]: META_MUSE_CONTEXT_WINDOW },
|
|
93
|
+
// A Custom row may keep this id pointed at another gateway
|
|
94
|
+
// (preserveCustomDestination); only api.meta.ai publishes the roster `to` describes.
|
|
95
|
+
destinationBaseUrls: ["https://api.meta.ai/v1"],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
provider: "deepseek",
|
|
99
|
+
from: ["deepseek-chat", "deepseek-reasoner", "deepseek-flash", "deepseek-v4-flash", "deepseek-v4-flash-vision-exp"],
|
|
100
|
+
to: ["deepseek-chat", "deepseek-reasoner", "deepseek-flash", "deepseek-v4-flash", "deepseek-v4-pro", "deepseek-v4-flash-vision-exp"],
|
|
101
|
+
contextWindows: { "deepseek-v4-pro": 1_048_576 },
|
|
102
|
+
destinationBaseUrls: ["https://api.deepseek.com", "https://api.deepseek.com/v1"],
|
|
103
|
+
},
|
|
104
|
+
...["minimax", "minimax-cn"].map(provider => ({
|
|
105
|
+
provider,
|
|
106
|
+
from: MINIMAX_MODELS_BEFORE_M31,
|
|
107
|
+
to: MINIMAX_MODELS,
|
|
108
|
+
contextWindows: { [MINIMAX_M31_FLASH]: MINIMAX_MODEL_CONTEXT_WINDOWS[MINIMAX_M31_FLASH]! },
|
|
109
|
+
maxOutputTokens: { [MINIMAX_M31_FLASH]: MINIMAX_M31_FLASH_MAX_OUTPUT_TOKENS },
|
|
110
|
+
defaultReasoningEfforts: { [MINIMAX_M31_FLASH]: MINIMAX_M31_DEFAULT_REASONING_EFFORT },
|
|
111
|
+
})),
|
|
112
|
+
...[
|
|
113
|
+
{ provider: "alibaba-token-plan", from: ALIBABA_TOKEN_PLAN_MODELS_BEFORE_1017, to: ALIBABA_TOKEN_PLAN_MODELS },
|
|
114
|
+
// International honors pay-as-you-go and Custom URLs, which may still serve the retired ids.
|
|
115
|
+
// Beijing needs no guard: the router pins it to the registry Token Plan host.
|
|
116
|
+
{
|
|
117
|
+
provider: "alibaba-token-plan-intl", from: ALIBABA_INTL_TOKEN_PLAN_MODELS_BEFORE_1017, to: ALIBABA_INTL_TOKEN_PLAN_MODELS,
|
|
118
|
+
destinationBaseUrls: [ALIBABA_INTL_TOKEN_PLAN_BASE_URL],
|
|
119
|
+
},
|
|
120
|
+
].map(entry => ({
|
|
121
|
+
...entry,
|
|
122
|
+
contextWindows: ALIBABA_TOKEN_PLAN_CONTEXT_WINDOWS,
|
|
123
|
+
maxOutputTokens: ALIBABA_TOKEN_PLAN_MAX_OUTPUT_TOKENS,
|
|
124
|
+
defaultReasoningEfforts: { "deepseek-v4.1-flash-1017": "high" },
|
|
125
|
+
})),
|
|
126
|
+
// Kimi K3.1 Pro (#7653). Both the International and China platforms list kimi-k3.1-pro and
|
|
127
|
+
// -highspeed; a Custom URL may be another gateway, so it keeps its saved list.
|
|
128
|
+
{
|
|
129
|
+
provider: "moonshot",
|
|
130
|
+
from: KIMI_API_MODELS_BEFORE_K31,
|
|
131
|
+
to: KIMI_API_MODELS,
|
|
132
|
+
contextWindows: KIMI_API_MODEL_CONTEXT_WINDOWS,
|
|
133
|
+
defaultReasoningEfforts: KIMI_API_DEFAULT_REASONING_EFFORTS,
|
|
134
|
+
destinationBaseUrls: [MOONSHOT_INTL_BASE_URL, MOONSHOT_CN_BASE_URL],
|
|
135
|
+
},
|
|
136
|
+
];
|
|
56
137
|
|
|
57
138
|
function sameList(value: unknown, expected: readonly string[]): boolean {
|
|
58
139
|
return Array.isArray(value)
|
|
@@ -65,12 +146,24 @@ function registrySeeds(provider: string, adapter: unknown, roster: readonly stri
|
|
|
65
146
|
return entry !== undefined && entry.adapter === adapter && sameList(entry.models, roster);
|
|
66
147
|
}
|
|
67
148
|
|
|
68
|
-
function
|
|
69
|
-
if (!
|
|
149
|
+
function servesRoster(baseUrl: unknown, destinations: readonly string[] | undefined): boolean {
|
|
150
|
+
if (!destinations || baseUrl === undefined || baseUrl === "") return true;
|
|
151
|
+
if (typeof baseUrl !== "string") return false;
|
|
152
|
+
const saved = normalizedProviderEndpoint(baseUrl);
|
|
153
|
+
return destinations.some(url => normalizedProviderEndpoint(url) === saved);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function fillExisting<T>(container: Record<string, T> | undefined, values: Readonly<Record<string, T>> | undefined, ids: readonly string[]): boolean {
|
|
157
|
+
if (!container || !values) return false;
|
|
158
|
+
let filled = false;
|
|
70
159
|
for (const id of ids) {
|
|
71
160
|
const value = values[id];
|
|
72
|
-
if (value !== undefined &&
|
|
161
|
+
if (value !== undefined && modelRecordValue(container, id) === undefined) {
|
|
162
|
+
container[id] = value;
|
|
163
|
+
filled = true;
|
|
164
|
+
}
|
|
73
165
|
}
|
|
166
|
+
return filled;
|
|
74
167
|
}
|
|
75
168
|
|
|
76
169
|
/** Pure projection. The caller decides whether to persist. */
|
|
@@ -85,10 +178,22 @@ export function projectStaleModelRosters(
|
|
|
85
178
|
const prov = config.providers?.[entry.provider];
|
|
86
179
|
if (!prov) continue;
|
|
87
180
|
if (!registrySeeds(entry.provider, prov.adapter, entry.to)) continue;
|
|
88
|
-
if (!
|
|
181
|
+
if (!servesRoster(prov.baseUrl, entry.destinationBaseUrls)) continue;
|
|
89
182
|
const added = entry.to.filter(id => !entry.from.includes(id));
|
|
183
|
+
if (sameList(prov.models, entry.to)) {
|
|
184
|
+
// A row refreshed before output limits joined the refresh still has a partial map.
|
|
185
|
+
// Only that record is revisited: the earlier pass already filled windows and efforts,
|
|
186
|
+
// so refilling them could restore a key the operator has since removed.
|
|
187
|
+
if (fillExisting(prov.modelMaxOutputTokens, entry.maxOutputTokens, added)) {
|
|
188
|
+
changed = true;
|
|
189
|
+
warnings.push(`filled output limits for ${added.join(", ")} on the saved "${entry.provider}" row.`);
|
|
190
|
+
}
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
if (!sameList(prov.models, entry.from)) continue;
|
|
90
194
|
prov.models = [...entry.to];
|
|
91
195
|
fillExisting(prov.modelContextWindows, entry.contextWindows, added);
|
|
196
|
+
fillExisting(prov.modelMaxOutputTokens, entry.maxOutputTokens, added);
|
|
92
197
|
fillExisting(prov.modelDefaultReasoningEfforts, entry.defaultReasoningEfforts, added);
|
|
93
198
|
changed = true;
|
|
94
199
|
warnings.push(
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export interface WorkBuddyCreditAmount {
|
|
2
|
+
total: number;
|
|
3
|
+
used: number;
|
|
4
|
+
remaining: number;
|
|
5
|
+
frozen: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const WORKBUDDY_CREDIT_KINDS = ["plan_base", "plan_bonus", "addon", "benefit", "other"] as const;
|
|
9
|
+
export type WorkBuddyCreditKind = typeof WORKBUDDY_CREDIT_KINDS[number];
|
|
10
|
+
|
|
11
|
+
/** Display-only credits; they are neither USD nor provider-wide model eligibility. */
|
|
12
|
+
export interface WorkBuddyCreditBalance extends WorkBuddyCreditAmount {
|
|
13
|
+
groups: Array<WorkBuddyCreditAmount & { kind: WorkBuddyCreditKind }>;
|
|
14
|
+
expiring?: { amount: number; at: number };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function workBuddyRecord(value: unknown): Record<string, unknown> {
|
|
18
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function workBuddyCapacity(value: unknown): number | undefined {
|
|
22
|
+
if (typeof value !== "number" && !(typeof value === "string" && /^\d+(?:\.\d+)?$/.test(value))) return undefined;
|
|
23
|
+
const number = Number(value);
|
|
24
|
+
return Number.isFinite(number) && number >= 0 && number <= Number.MAX_SAFE_INTEGER ? number : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function amount(value: unknown): WorkBuddyCreditAmount | undefined {
|
|
28
|
+
const row = workBuddyRecord(value);
|
|
29
|
+
const total = workBuddyCapacity(row.total), used = workBuddyCapacity(row.used);
|
|
30
|
+
const remaining = workBuddyCapacity(row.remaining), frozen = workBuddyCapacity(row.frozen);
|
|
31
|
+
if (total === undefined || used === undefined || remaining === undefined || frozen === undefined) return undefined;
|
|
32
|
+
return { total, used, remaining, frozen };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Narrow wire/cache input before rendering, without admitting account or package identifiers. */
|
|
36
|
+
export function normalizeWorkBuddyCredits(value: unknown): WorkBuddyCreditBalance | undefined {
|
|
37
|
+
const row = workBuddyRecord(value), balance = amount(value);
|
|
38
|
+
if (!balance || !Array.isArray(row.groups) || row.groups.length > WORKBUDDY_CREDIT_KINDS.length) return undefined;
|
|
39
|
+
const groups: WorkBuddyCreditBalance["groups"] = [];
|
|
40
|
+
const seen = new Set<string>();
|
|
41
|
+
for (const raw of row.groups) {
|
|
42
|
+
const group = workBuddyRecord(raw), quantities = amount(group);
|
|
43
|
+
const kind = WORKBUDDY_CREDIT_KINDS.find(kind => kind === group.kind);
|
|
44
|
+
if (!quantities || !kind || seen.has(kind)) return undefined;
|
|
45
|
+
seen.add(kind); groups.push({ kind, ...quantities });
|
|
46
|
+
}
|
|
47
|
+
const expiring = workBuddyRecord(row.expiring), quantity = workBuddyCapacity(expiring.amount);
|
|
48
|
+
const at = typeof expiring.at === "number" && expiring.at > 0 && Number.isFinite(new Date(expiring.at).getTime()) ? expiring.at : undefined;
|
|
49
|
+
return { ...balance, groups, ...(quantity !== undefined && quantity > 0 && at !== undefined ? { expiring: { amount: quantity, at } } : {}) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function packageAmount(row: Record<string, unknown>): WorkBuddyCreditAmount | undefined {
|
|
53
|
+
const total = workBuddyCapacity(row.CycleTotalCapacity), used = workBuddyCapacity(row.CycleUsedCapacity);
|
|
54
|
+
const frozen = row.CycleFrozenCapacity === undefined ? 0 : workBuddyCapacity(row.CycleFrozenCapacity);
|
|
55
|
+
if (total === undefined || used === undefined || frozen === undefined) return undefined;
|
|
56
|
+
const remaining = row.CycleRemainCapacity === undefined ? Math.max(0, total - used - frozen) : workBuddyCapacity(row.CycleRemainCapacity);
|
|
57
|
+
return remaining === undefined ? undefined : { total, used, remaining, frozen };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function parseWorkBuddyCredits(value: unknown): WorkBuddyCreditBalance | undefined {
|
|
61
|
+
const summary = workBuddyRecord(value);
|
|
62
|
+
if (!Array.isArray(summary.Packages) || summary.Packages.length > 512) return undefined;
|
|
63
|
+
const balance: WorkBuddyCreditBalance = { total: 0, used: 0, remaining: 0, frozen: 0, groups: [] };
|
|
64
|
+
for (const raw of summary.Packages) {
|
|
65
|
+
const quantities = packageAmount(workBuddyRecord(raw));
|
|
66
|
+
if (!quantities) return undefined;
|
|
67
|
+
for (const key of ["total", "used", "remaining", "frozen"] as const) balance[key] += quantities[key];
|
|
68
|
+
}
|
|
69
|
+
// CreditGroups is a breakdown of Packages, not another balance to add to it.
|
|
70
|
+
if (Array.isArray(summary.CreditGroups) && summary.CreditGroups.length <= 16) {
|
|
71
|
+
for (const raw of summary.CreditGroups) {
|
|
72
|
+
const row = workBuddyRecord(raw), quantities = packageAmount(row);
|
|
73
|
+
if (!quantities) continue;
|
|
74
|
+
const kind = WORKBUDDY_CREDIT_KINDS.find(kind => kind === row.Kind) ?? "other";
|
|
75
|
+
const existing = balance.groups.find(group => group.kind === kind);
|
|
76
|
+
if (existing) for (const key of ["total", "used", "remaining", "frozen"] as const) existing[key] += quantities[key];
|
|
77
|
+
else balance.groups.push({ kind, ...quantities });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return normalizeWorkBuddyCredits(balance);
|
|
81
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isValidModelDiscoveryModelId } from "./model-discovery-limits";
|
|
2
|
+
import type { ProviderModelItemsResult, ProviderModelsApiItem } from "./model-discovery";
|
|
3
|
+
|
|
4
|
+
function record(value: unknown): Record<string, unknown> {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** The product catalog contains non-chat models too; only the CLI agent's roster is routable. */
|
|
9
|
+
export function extractWorkBuddyModels(value: unknown, limit: number): ProviderModelItemsResult {
|
|
10
|
+
const envelope = record(value), data = record(envelope.data);
|
|
11
|
+
if ((envelope.code !== 0 && envelope.code !== "0") || !Array.isArray(data.agents) || !Array.isArray(data.models)) return { ok: false, reason: "invalid_shape" };
|
|
12
|
+
if (data.models.length > limit || data.agents.length > limit) return { ok: false, reason: "too_many_models" };
|
|
13
|
+
const agent = data.agents.map(record).find(a => a.name === "cli");
|
|
14
|
+
if (!Array.isArray(agent?.models)) return { ok: false, reason: "invalid_shape" };
|
|
15
|
+
if (agent.models.length > limit) return { ok: false, reason: "too_many_models" };
|
|
16
|
+
const definitions = new Map(data.models.map(raw => { const row = record(raw); return [row.id, row] as const; }));
|
|
17
|
+
const items: ProviderModelsApiItem[] = [], seen = new Set<string>();
|
|
18
|
+
for (const id of agent.models) {
|
|
19
|
+
if (!isValidModelDiscoveryModelId(id)) return { ok: false, reason: "invalid_shape" };
|
|
20
|
+
if (seen.has(id)) continue;
|
|
21
|
+
seen.add(id);
|
|
22
|
+
const row = definitions.get(id) ?? {}, reasoning = record(row.reasoning);
|
|
23
|
+
const rawEfforts = Array.isArray(reasoning.supportedEfforts) ? reasoning.supportedEfforts
|
|
24
|
+
: row.supportsReasoning === true ? ["low", "high", "max"] : [];
|
|
25
|
+
const efforts = rawEfforts.filter(e => typeof e === "string" && ["low", "medium", "high", "xhigh", "max"].includes(e));
|
|
26
|
+
if (efforts.length && row.onlyReasoning !== true && reasoning.canDisableThinking !== false) efforts.unshift("none");
|
|
27
|
+
const positive = (v: unknown) => typeof v === "number" && Number.isSafeInteger(v) && v > 0 ? v : undefined;
|
|
28
|
+
items.push({
|
|
29
|
+
id, ...(typeof row.name === "string" && row.name.length <= 256 ? { name: row.name } : {}),
|
|
30
|
+
context_length: positive(row.maxInputTokens), max_input_tokens: positive(row.maxInputTokens),
|
|
31
|
+
max_output_tokens: positive(row.maxOutputTokens), reasoning_efforts: efforts,
|
|
32
|
+
// WorkBuddy AI filters images from GLM requests despite advertising supportsImages.
|
|
33
|
+
input_modalities: row.supportsImages === true && !id.startsWith("glm-") ? ["text", "image"] : ["text"],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return { ok: true, items, rawCount: agent.models.length };
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { WorkBuddyOAuthMetadata } from "../oauth/types";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
export const WORKBUDDY_ORIGIN = "https://www.workbuddy.ai";
|
|
5
|
+
export const WORKBUDDY_BASE_URL = `${WORKBUDDY_ORIGIN}/v2`;
|
|
6
|
+
export const WORKBUDDY_CONFIG_URL = `${WORKBUDDY_ORIGIN}/v3/config`;
|
|
7
|
+
export const WORKBUDDY_USER_AGENT = "WorkBuddy/5.5.6";
|
|
8
|
+
|
|
9
|
+
export function workBuddyCatalogIdentity(access: string, metadata: WorkBuddyOAuthMetadata | undefined): string {
|
|
10
|
+
return createHash("sha256").update(JSON.stringify([access, metadata])).digest("hex");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function workBuddyHeaderValue(value: unknown, max = 1024): value is string {
|
|
14
|
+
return typeof value === "string" && value.length > 0 && value.length <= max && /^[\x21-\x7e]+$/.test(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function normalizeWorkBuddyMetadata(value: unknown): WorkBuddyOAuthMetadata | undefined {
|
|
18
|
+
if (!value || typeof value !== "object") return undefined;
|
|
19
|
+
const v = value as Partial<WorkBuddyOAuthMetadata>;
|
|
20
|
+
if (!workBuddyHeaderValue(v.uid) || !workBuddyHeaderValue(v.domain)) return undefined;
|
|
21
|
+
if (v.enterpriseId !== undefined && !workBuddyHeaderValue(v.enterpriseId)) return undefined;
|
|
22
|
+
return {
|
|
23
|
+
uid: v.uid, domain: v.domain,
|
|
24
|
+
...(v.enterpriseId ? { enterpriseId: v.enterpriseId } : {}),
|
|
25
|
+
...(typeof v.refreshExpiresAt === "number" && Number.isFinite(v.refreshExpiresAt) && v.refreshExpiresAt > 0
|
|
26
|
+
? { refreshExpiresAt: v.refreshExpiresAt } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function assertWorkBuddyDestination(baseUrl: string): void {
|
|
31
|
+
const u = new URL(baseUrl);
|
|
32
|
+
if (u.origin !== WORKBUDDY_ORIGIN || u.username || u.password || u.search || u.hash
|
|
33
|
+
|| !["", "/v2", "/v2/chat/completions"].includes(u.pathname.replace(/\/+$/, ""))) {
|
|
34
|
+
throw new Error("WorkBuddy AI credentials require https://www.workbuddy.ai/v2");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function workBuddyHeaders(access: string | undefined, metadata?: WorkBuddyOAuthMetadata): Record<string, string> {
|
|
39
|
+
const headers: Record<string, string> = {
|
|
40
|
+
"User-Agent": WORKBUDDY_USER_AGENT,
|
|
41
|
+
"X-Product": "SaaS", "X-IDE-Type": "WorkBuddy", "X-IDE-Name": "WorkBuddy",
|
|
42
|
+
"X-IDE-Version": "5.5.6", "X-Requested-With": "XMLHttpRequest",
|
|
43
|
+
"X-Agent-Intent": "craft", "X-Agent-Purpose": "conversation", "X-Agent-Type": "main",
|
|
44
|
+
};
|
|
45
|
+
if (access) {
|
|
46
|
+
if (!workBuddyHeaderValue(access, 32768)) throw new Error("Invalid WorkBuddy AI access token");
|
|
47
|
+
headers.Authorization = `Bearer ${access}`;
|
|
48
|
+
}
|
|
49
|
+
if (metadata) {
|
|
50
|
+
const valid = normalizeWorkBuddyMetadata(metadata);
|
|
51
|
+
if (!valid) throw new Error("WorkBuddy AI account identity unavailable; sign in again");
|
|
52
|
+
headers["X-User-Id"] = valid.uid;
|
|
53
|
+
headers["X-Domain"] = valid.domain;
|
|
54
|
+
if (valid.enterpriseId) {
|
|
55
|
+
headers["X-Enterprise-Id"] = valid.enterpriseId;
|
|
56
|
+
headers["X-Tenant-Id"] = valid.enterpriseId;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return headers;
|
|
60
|
+
}
|
|
@@ -137,13 +137,18 @@ class PiRpcProcess {
|
|
|
137
137
|
async prompt(message: string): Promise<void> {
|
|
138
138
|
if (this.activeSettle) throw new Error("Pi Remote Workspace turn is already active");
|
|
139
139
|
const settled = new Promise<void>((resolve, reject) => { this.activeSettle = { resolve, reject }; });
|
|
140
|
+
const active = this.activeSettle;
|
|
140
141
|
try {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
await
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
// Either operation can fail first. Observe both immediately, including an
|
|
143
|
+
// extension error or child exit that arrives before the prompt response.
|
|
144
|
+
await Promise.all([
|
|
145
|
+
this.command("prompt", { message }).then(accepted => {
|
|
146
|
+
if (accepted.success !== true) throw new Error(safeError(accepted.error, "Pi rejected the prompt"));
|
|
147
|
+
}),
|
|
148
|
+
settled,
|
|
149
|
+
]);
|
|
150
|
+
} finally {
|
|
151
|
+
if (this.activeSettle === active) this.activeSettle = null;
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
154
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AdapterEvent } from "../types";
|
|
2
|
+
import { releaseTranslatedEvent, type TranslatorBudget } from "../lib/translator-budget";
|
|
3
|
+
import { isTruncatedStopReason } from "./truncated-stop-reason";
|
|
4
|
+
|
|
5
|
+
/** Keep client/hosted tool events out of a routed Anthropic summary's compaction item. */
|
|
6
|
+
export async function* guardCompactionSummary(
|
|
7
|
+
events: AsyncIterable<AdapterEvent>,
|
|
8
|
+
budget: TranslatorBudget,
|
|
9
|
+
): AsyncGenerator<AdapterEvent> {
|
|
10
|
+
let hasText = false;
|
|
11
|
+
let attemptedTool = false;
|
|
12
|
+
for await (const event of events) {
|
|
13
|
+
if (event.type === "text_delta" && !event.anthropicThinkingSignature) {
|
|
14
|
+
hasText ||= event.text.trim().length > 0;
|
|
15
|
+
yield event;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (event.type === "error" || event.type === "incomplete") {
|
|
19
|
+
yield event;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (event.type === "done") {
|
|
23
|
+
if (!isTruncatedStopReason(event.stopReason)
|
|
24
|
+
// An absent stop reason is accepted, as on every other completion path: some
|
|
25
|
+
// Anthropic-compatible endpoints omit it. An explicit non-terminal reason is not.
|
|
26
|
+
&& (attemptedTool || !hasText
|
|
27
|
+
|| (event.stopReason !== undefined && event.stopReason !== "end_turn" && event.stopReason !== "stop_sequence"))) {
|
|
28
|
+
releaseTranslatedEvent(event, budget);
|
|
29
|
+
yield {
|
|
30
|
+
type: "error", status: 502, errorType: "upstream_error",
|
|
31
|
+
code: "compaction_invalid_summary", retryable: false,
|
|
32
|
+
message: "Compaction requires a non-empty text summary without tool calls and a normal completion.",
|
|
33
|
+
usage: event.usage,
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
yield event;
|
|
37
|
+
}
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (event.type === "tool_call_start" || event.type === "tool_call_delta" || event.type === "tool_call_end"
|
|
41
|
+
|| event.type === "web_search_call_begin" || event.type === "web_search_call_end") attemptedTool = true;
|
|
42
|
+
releaseTranslatedEvent(event, budget);
|
|
43
|
+
yield { type: "heartbeat" };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
1
|
import { wireToolInnerName } from "./tool-name-aliases";
|
|
3
2
|
|
|
4
3
|
const MUSE_TOOL_NAME_MAX = 64;
|
|
@@ -53,7 +52,7 @@ function isPassThroughMuseToolName(name: string): boolean {
|
|
|
53
52
|
|
|
54
53
|
function hashSuffix(originalName: string, salt: number): string {
|
|
55
54
|
const hashInput = salt === 0 ? originalName : originalName + "#" + salt;
|
|
56
|
-
return
|
|
55
|
+
return Bun.SHA256.hash(hashInput, "hex").slice(0, MUSE_TOOL_NAME_HASH_LEN);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
/**
|
package/src/responses/parser.ts
CHANGED
|
@@ -185,8 +185,8 @@ function attachPendingReasoningToCallOwner(
|
|
|
185
185
|
|
|
186
186
|
const REASONING_EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"]);
|
|
187
187
|
|
|
188
|
-
export function hasValidatedActiveReasoningEffort(options: Pick<OcxRequestOptions, "reasoning">): boolean {
|
|
189
|
-
return options.reasoning !== undefined && options.reasoning !== "none";
|
|
188
|
+
export function hasValidatedActiveReasoningEffort(options: Pick<OcxRequestOptions, "reasoning" | "thinkingEnabled">): boolean {
|
|
189
|
+
return options.thinkingEnabled ?? (options.reasoning !== undefined && options.reasoning !== "none");
|
|
190
190
|
}
|
|
191
191
|
|
|
192
192
|
|
|
@@ -695,6 +695,7 @@ export function parseRequest(
|
|
|
695
695
|
// `reasoning_effort_for_request`), so current clients never send it — but a catalog that
|
|
696
696
|
// advertises ultra plus an older/direct caller can. Degrade it to max like upstream instead of
|
|
697
697
|
// silently dropping reasoning altogether.
|
|
698
|
+
if (data.reasoning?.enabled !== undefined) options.thinkingEnabled = data.reasoning.enabled;
|
|
698
699
|
const requestedEffort = data.reasoning?.effort === "ultra" ? "max" : data.reasoning?.effort;
|
|
699
700
|
if (requestedEffort && REASONING_EFFORTS.has(requestedEffort)) {
|
|
700
701
|
options.reasoning = requestedEffort;
|
|
@@ -143,8 +143,9 @@ function tupleForServingIdentity(
|
|
|
143
143
|
|
|
144
144
|
function keyFor(callId: string, scope: OcxReasoningReplayScopeRef | undefined): string | undefined {
|
|
145
145
|
const identity = tupleForIdentity(scope?.current);
|
|
146
|
-
if (!nonEmpty(callId) || !nonEmpty(scope?.clientThreadId) || !identity) return undefined;
|
|
146
|
+
if (!nonEmpty(callId) || !nonEmpty(scope?.clientPrincipalId) || !nonEmpty(scope.clientThreadId) || !identity) return undefined;
|
|
147
147
|
return JSON.stringify([
|
|
148
|
+
scope.clientPrincipalId,
|
|
148
149
|
scope.clientThreadId,
|
|
149
150
|
...identity,
|
|
150
151
|
callId,
|
|
@@ -166,18 +167,21 @@ function sweepExpiredServingIdentities(at: number): void {
|
|
|
166
167
|
|
|
167
168
|
function servingIdentityFor(
|
|
168
169
|
scope: OcxReasoningReplayScopeRef | undefined,
|
|
169
|
-
): {
|
|
170
|
+
): { key: string; identity: string } | undefined {
|
|
170
171
|
const threadId = scope?.clientThreadId;
|
|
171
172
|
const identityTuple = tupleForServingIdentity(scope?.current);
|
|
172
173
|
if (!nonEmpty(threadId) || !identityTuple) return undefined;
|
|
173
|
-
|
|
174
|
+
// Preserve physical safeguards for keyless callers in a separate namespace. A caller's
|
|
175
|
+
// thread name cannot select an authenticated principal's serving or rejection history.
|
|
176
|
+
const key = JSON.stringify([nonEmpty(scope?.clientPrincipalId) ? scope.clientPrincipalId : null, threadId]);
|
|
177
|
+
return { key, identity: JSON.stringify(identityTuple) };
|
|
174
178
|
}
|
|
175
179
|
|
|
176
180
|
function opaqueBlobRejectionKeyFor(
|
|
177
181
|
scope: OcxReasoningReplayScopeRef | undefined,
|
|
178
182
|
): string | undefined {
|
|
179
183
|
const current = servingIdentityFor(scope);
|
|
180
|
-
return current ? JSON.stringify([current.
|
|
184
|
+
return current ? JSON.stringify([current.key, current.identity]) : undefined;
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
function deleteOpaqueBlobRejection(key: string): void {
|
|
@@ -224,7 +228,7 @@ export function reasoningReplayServingIdentityChange(
|
|
|
224
228
|
if (!current) return undefined;
|
|
225
229
|
const at = now();
|
|
226
230
|
sweepExpiredServingIdentities(at);
|
|
227
|
-
const previous = servingIdentities.get(current.
|
|
231
|
+
const previous = servingIdentities.get(current.key);
|
|
228
232
|
if (previous === undefined || previous.identity === current.identity) return undefined;
|
|
229
233
|
const before = JSON.parse(previous.identity) as ReasoningReplayIdentityTuple;
|
|
230
234
|
const after = JSON.parse(current.identity) as ReasoningReplayIdentityTuple;
|
|
@@ -254,7 +258,7 @@ export function reasoningReplayItemStoreChanged(
|
|
|
254
258
|
if (!current) return false;
|
|
255
259
|
const at = now();
|
|
256
260
|
sweepExpiredServingIdentities(at);
|
|
257
|
-
const previous = servingIdentities.get(current.
|
|
261
|
+
const previous = servingIdentities.get(current.key);
|
|
258
262
|
if (previous === undefined || previous.identity === current.identity) return false;
|
|
259
263
|
const storeOwner = (identity: string): string => {
|
|
260
264
|
const [, destination, , , credential] = JSON.parse(identity) as ReasoningReplayIdentityTuple;
|
|
@@ -271,16 +275,16 @@ export function commitReasoningReplayServingIdentity(
|
|
|
271
275
|
if (!current) return;
|
|
272
276
|
const at = now();
|
|
273
277
|
sweepExpiredServingIdentities(at);
|
|
274
|
-
const previous = servingIdentities.get(current.
|
|
275
|
-
const {
|
|
276
|
-
const bytes = Buffer.byteLength(JSON.stringify([
|
|
278
|
+
const previous = servingIdentities.get(current.key);
|
|
279
|
+
const { key, identity } = current;
|
|
280
|
+
const bytes = Buffer.byteLength(JSON.stringify([key, identity]), "utf8");
|
|
277
281
|
if (bytes > MAX_TOTAL_BYTES) {
|
|
278
|
-
deleteServingIdentity(
|
|
282
|
+
deleteServingIdentity(key);
|
|
279
283
|
return;
|
|
280
284
|
}
|
|
281
285
|
|
|
282
|
-
if (previous) deleteServingIdentity(
|
|
283
|
-
servingIdentities.set(
|
|
286
|
+
if (previous) deleteServingIdentity(key);
|
|
287
|
+
servingIdentities.set(key, { identity, bytes, at });
|
|
284
288
|
servingIdentityTotalBytes += bytes;
|
|
285
289
|
while (
|
|
286
290
|
(servingIdentityTotalBytes > MAX_TOTAL_BYTES || servingIdentities.size > MAX_ENTRIES)
|
|
@@ -517,13 +521,13 @@ export function reasoningReplayKeyCredentialIdentity(
|
|
|
517
521
|
return reasoningReplayCredentialIdentity("key", apiKey, provider.headers);
|
|
518
522
|
}
|
|
519
523
|
|
|
520
|
-
/**
|
|
524
|
+
/** Bind physical identity independently of the principal required for plaintext cache access. */
|
|
521
525
|
export function bindReasoningReplayScope(
|
|
522
526
|
scope: OcxReasoningReplayScopeRef | undefined,
|
|
523
527
|
identity: OcxReasoningReplayIdentity | undefined,
|
|
524
528
|
): void {
|
|
525
529
|
if (!scope) return;
|
|
526
|
-
if (!identity || !
|
|
530
|
+
if (!identity || !nonEmpty(scope.clientThreadId) || !tupleForIdentity(identity)) {
|
|
527
531
|
delete scope.current;
|
|
528
532
|
return;
|
|
529
533
|
}
|
package/src/responses/schema.ts
CHANGED
|
@@ -180,6 +180,7 @@ export const toolChoiceSchema = z.union([
|
|
|
180
180
|
]);
|
|
181
181
|
|
|
182
182
|
export const reasoningConfigSchema = z.object({
|
|
183
|
+
enabled: z.boolean().optional(),
|
|
183
184
|
effort: z.string().optional(),
|
|
184
185
|
summary: z.enum(["auto", "concise", "detailed", "none"]).optional(),
|
|
185
186
|
});
|
|
@@ -64,6 +64,7 @@ let entries = new Map<string, StoredEntry>();
|
|
|
64
64
|
let totalBytes = 0;
|
|
65
65
|
let loaded = false;
|
|
66
66
|
let persistChain: Promise<void> = Promise.resolve();
|
|
67
|
+
let pendingPersist: Promise<void> | undefined;
|
|
67
68
|
|
|
68
69
|
function storePath(): string {
|
|
69
70
|
return join(getConfigDir(), STORE_FILE_NAME);
|
|
@@ -203,8 +204,12 @@ function prune(nowMs: number): void {
|
|
|
203
204
|
}
|
|
204
205
|
|
|
205
206
|
function persist(): Promise<void> {
|
|
206
|
-
|
|
207
|
+
// Mutations share a queued snapshot only until serialization starts. Arrivals during
|
|
208
|
+
// its write get a subsequent batch, without extending earlier callers' barriers.
|
|
209
|
+
if (pendingPersist) return pendingPersist;
|
|
210
|
+
const batch = persistChain
|
|
207
211
|
.then(async () => {
|
|
212
|
+
if (pendingPersist === batch) pendingPersist = undefined;
|
|
208
213
|
const snapshot = JSON.stringify({
|
|
209
214
|
version: STORE_VERSION,
|
|
210
215
|
entries: [...entries].map(([key, entry]) => ({ key, sig: entry.sig, savedAt: entry.savedAt })),
|
|
@@ -214,7 +219,9 @@ function persist(): Promise<void> {
|
|
|
214
219
|
.catch(() => {
|
|
215
220
|
// Best-effort persistence: the in-memory store still serves the running process.
|
|
216
221
|
});
|
|
217
|
-
|
|
222
|
+
pendingPersist = batch;
|
|
223
|
+
persistChain = batch;
|
|
224
|
+
return batch;
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
/**
|
|
@@ -331,6 +338,7 @@ export function resetThoughtSignatureReplayForTests(): void {
|
|
|
331
338
|
totalBytes = 0;
|
|
332
339
|
loaded = false;
|
|
333
340
|
persistChain = Promise.resolve();
|
|
341
|
+
pendingPersist = undefined;
|
|
334
342
|
cachedSalt = undefined;
|
|
335
343
|
saltLoaded = false;
|
|
336
344
|
}
|
package/src/router.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
import { decodeRoutedModelIdOrThrow, encodeRoutedModelId } from "./providers/slug-codec";
|
|
34
34
|
import { effectiveProviderAliasDecision, resolveModelAlias } from "./providers/default-aliases";
|
|
35
35
|
import { resolveBlockedModelRedirect } from "./lib/shadow-call";
|
|
36
|
+
import { workBuddyCatalogIdentity } from "./providers/workbuddy";
|
|
36
37
|
import { getRoutingCached } from "./codex/model-cache";
|
|
37
38
|
import { codexAccountNamespaceEntries } from "./codex/account-namespaces";
|
|
38
39
|
import {
|
|
@@ -177,6 +178,7 @@ export function knownModelIdsForProvider(
|
|
|
177
178
|
if (!account || account.needsReauth || !Number.isFinite(account.credential.expires)
|
|
178
179
|
|| account.credential.expires <= Date.now()) return undefined;
|
|
179
180
|
key = account.credential.access;
|
|
181
|
+
if (provName === "workbuddy-ai") return workBuddyCatalogIdentity(key, account.credential.workbuddy);
|
|
180
182
|
if (routed.adapter === "devin") destination = validateDevinApiBaseUrl(account.credential.apiBaseUrl) ?? routed.baseUrl;
|
|
181
183
|
}
|
|
182
184
|
if (!key) return undefined;
|