@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
package/src/server/ws-bridge.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface WsData {
|
|
|
64
64
|
liveUpstreamHandoff?: LiveSidebandUpstreamHandoff;
|
|
65
65
|
/** Once teardown starts, ignore new client frames until the upstream closes. */
|
|
66
66
|
liveClosing?: boolean;
|
|
67
|
-
/**
|
|
67
|
+
/** Terminates a stalled close without releasing ownership before transport closure. */
|
|
68
68
|
liveCloseFallback?: ReturnType<typeof setTimeout>;
|
|
69
69
|
/** Turn/account ownership retained for the complete sideband socket lifetime. */
|
|
70
70
|
liveTurnAdmissionLease?: AdmissionLease;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* route back through them (see `installedServiceListenPort` in `health.ts`, which
|
|
8
8
|
* intentionally stays behind because it asks every backend).
|
|
9
9
|
*/
|
|
10
|
-
import { loadConfig } from "../config";
|
|
10
|
+
import { getConfigDir, loadConfig } from "../config";
|
|
11
|
+
import { readClaudeInterceptProxyToken } from "../claude/intercept/proxy-auth";
|
|
11
12
|
import { serviceApiTokenFilePath } from "../lib/service-secrets";
|
|
12
13
|
import { PROXY_ENV_KEYS } from "../lib/proxy-env";
|
|
13
14
|
|
|
@@ -87,19 +88,30 @@ export function parseBakedListenPort(read: () => string): number | null {
|
|
|
87
88
|
* own `applyProxyEnv` already treats both cases as equivalent. Only the canonical
|
|
88
89
|
* upper-case name is baked, so a definition never carries two spellings of one setting.
|
|
89
90
|
*/
|
|
90
|
-
export function resolvedProxyEnv(
|
|
91
|
+
export function resolvedProxyEnv(
|
|
92
|
+
env: NodeJS.ProcessEnv = process.env,
|
|
93
|
+
ownClaudeInterceptProxy?: string | null,
|
|
94
|
+
): { name: string; value: string }[] {
|
|
95
|
+
const token = ownClaudeInterceptProxy === undefined ? readClaudeInterceptProxyToken(getConfigDir()) : null;
|
|
91
96
|
const resolved: { name: string; value: string }[] = [];
|
|
92
97
|
for (const key of PROXY_ENV_KEYS) {
|
|
93
|
-
const value = [env[key]?.trim(), env[key.toLowerCase()]?.trim()].find(v => v &&
|
|
98
|
+
const value = [env[key]?.trim(), env[key.toLowerCase()]?.trim()].find(v => v && (
|
|
99
|
+
ownClaudeInterceptProxy === undefined ? !isOwnedClaudeInterceptProxy(v, token) : v !== ownClaudeInterceptProxy
|
|
100
|
+
));
|
|
94
101
|
if (value) resolved.push({ name: key, value });
|
|
95
102
|
}
|
|
96
103
|
return resolved;
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* is matched: a plain `http://127.0.0.1:<port>` is a user's local proxy client and is kept.
|
|
107
|
+
* Match this installation's credential and exact URL components without creating a token.
|
|
108
|
+
* An inherited URL can still use an old bound port after the persisted config changes.
|
|
109
|
+
* Shape alone cannot establish ownership: a user proxy may also use an `opencodex` username.
|
|
104
110
|
*/
|
|
105
|
-
|
|
111
|
+
function isOwnedClaudeInterceptProxy(value: string, token: string | null): boolean {
|
|
112
|
+
if (!token) return false;
|
|
113
|
+
const prefix = `http://opencodex:${encodeURIComponent(token)}@127.0.0.1:`;
|
|
114
|
+
if (!value.startsWith(prefix)) return false;
|
|
115
|
+
const port = value.slice(prefix.length).replace(/\/$/, "");
|
|
116
|
+
return /^\d{1,5}$/.test(port) && Number(port) > 0 && Number(port) <= 65535;
|
|
117
|
+
}
|
|
@@ -27,18 +27,18 @@ export interface WindowsProcessReadOptions {
|
|
|
27
27
|
/** Called with the parent image before row validation, so partial Desktop evidence keeps its veto. */
|
|
28
28
|
onExecutable?: (path: string) => void;
|
|
29
29
|
timeoutMs?: number;
|
|
30
|
-
|
|
30
|
+
resolveSystemDirectory?: () => string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface DesktopSupervisionDeps {
|
|
34
34
|
targetPid?: number;
|
|
35
35
|
platform?: NodeJS.Platform;
|
|
36
|
-
run?: (command: string, args: string[], timeoutMs?: number) => string;
|
|
36
|
+
run?: (command: string, args: string[], timeoutMs?: number, env?: NodeJS.ProcessEnv) => string;
|
|
37
37
|
proc?: ProcReader;
|
|
38
38
|
readPid?: () => number | null;
|
|
39
39
|
readRuntimePortPid?: () => number | null;
|
|
40
40
|
windowsProcesses?: (pid: number, options: Pick<WindowsProcessReadOptions, "onExecutable" | "timeoutMs">) => WindowsProcessPair | null;
|
|
41
|
-
|
|
41
|
+
resolveWindowsSystemDirectory?: () => string;
|
|
42
42
|
now?: () => number;
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -46,7 +46,10 @@ export function desktopSupervisionPaths(): { pid: string; runtimePort: string };
|
|
|
46
46
|
export const procfs: ProcReader;
|
|
47
47
|
export function processIdentity(pid: number, execute?: DesktopSupervisionDeps["run"], onExecutable?: (path: string) => void):
|
|
48
48
|
{ parent: number; executable: string } | null;
|
|
49
|
-
export function windowsPowerShellPath(
|
|
49
|
+
export function windowsPowerShellPath(resolveSystemDirectory?: () => string): string;
|
|
50
|
+
/** Pure consistency check over loaded-module paths; throws unless exactly one well-formed
|
|
51
|
+
* namesake per KnownDLL shares one parent directory. Exported for tests. */
|
|
52
|
+
export function windowsSystemDirectoryFromSharedObjects(loaded: unknown): string;
|
|
50
53
|
export function windowsProcessPair(pid: number, execute?: DesktopSupervisionDeps["run"], options?: WindowsProcessReadOptions): WindowsProcessPair;
|
|
51
54
|
export function inspectDesktopSupervision(deps?: DesktopSupervisionDeps): SupervisionEvidence;
|
|
52
55
|
export function createSupervisionLatch(): { observe(evidence: SupervisionEvidence): boolean };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { accessSync, constants, readFileSync, readlinkSync, realpathSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import { homedir } from "node:os";
|
|
4
5
|
import { basename, dirname, join, resolve, win32 } from "node:path";
|
|
5
6
|
|
|
6
7
|
// Node >=18 also imports this module from bin/ocx.mjs; do not import TS or Bun APIs.
|
|
7
|
-
function run(command, args, timeout = 750) {
|
|
8
|
+
function run(command, args, timeout = 750, env) {
|
|
8
9
|
return execFileSync(command, args, {
|
|
9
|
-
encoding: "utf8", timeout, maxBuffer: 128 * 1024,
|
|
10
|
+
encoding: "utf8", timeout, env, maxBuffer: 128 * 1024,
|
|
11
|
+
stdio: ["ignore", "pipe", "pipe"], windowsHide: true,
|
|
10
12
|
}).trim();
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -80,22 +82,95 @@ const WINDOWS_ACQUISITION_TIMEOUT_MS = 3_000;
|
|
|
80
82
|
const WINDOWS_MIN_ACQUISITION_MS = 250;
|
|
81
83
|
const WINDOWS_DESKTOP_IMAGE = "opencodex-desktop.exe";
|
|
82
84
|
|
|
83
|
-
/**
|
|
84
|
-
export function windowsPowerShellPath(
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
/** Bun resolves the system directory via FFI; the Node lane derives it from loaded KnownDLL paths. */
|
|
86
|
+
export function windowsPowerShellPath(resolveSystemDirectory = resolveWindowsSystemDirectory) {
|
|
87
|
+
const system = resolveSystemDirectory();
|
|
88
|
+
return win32.join(system, "WindowsPowerShell", "v1.0", "powershell.exe");
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const WINDOWS_REPORT_PATH_LIMIT = 260; // Node's module-name buffer is WCHAR[MAX_PATH] (src/debug_utils.cc).
|
|
92
|
+
const WINDOWS_KNOWN_DLLS = ["kernel32.dll", "ntdll.dll"];
|
|
93
|
+
|
|
94
|
+
// A resolved system directory is stable for the process lifetime; only success is
|
|
95
|
+
// memoized, so failures keep the existing retry-on-next-call recovery contract.
|
|
96
|
+
let windowsSystemDirectoryCache = null;
|
|
97
|
+
|
|
98
|
+
function resolveWindowsSystemDirectory() {
|
|
99
|
+
if (process.platform !== "win32") throw new Error("trusted Windows resolver unavailable");
|
|
100
|
+
if (windowsSystemDirectoryCache !== null) return windowsSystemDirectoryCache;
|
|
101
|
+
const directory = process.versions.bun ? resolveWindowsSystemDirectoryViaFfi() : resolveWindowsSystemDirectoryViaSharedObjects();
|
|
102
|
+
return (windowsSystemDirectoryCache = directory);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function resolveWindowsSystemDirectoryViaFfi() {
|
|
106
|
+
const { dlopen, ptr } = createRequire(import.meta.url)("bun:ffi");
|
|
107
|
+
const lib = dlopen("kernel32.dll", { GetSystemDirectoryW: { args: ["ptr", "u32"], returns: "u32" } });
|
|
108
|
+
try {
|
|
109
|
+
let size = 260;
|
|
110
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
111
|
+
const buffer = new Uint16Array(size);
|
|
112
|
+
const written = lib.symbols.GetSystemDirectoryW(ptr(buffer.buffer), size);
|
|
113
|
+
if (written === 0) throw new Error("GetSystemDirectoryW failed");
|
|
114
|
+
if (written >= size) { size = written + 1; continue; }
|
|
115
|
+
return String.fromCharCode(...buffer.subarray(0, written)).replace(/[/\\]+$/, "");
|
|
116
|
+
}
|
|
117
|
+
throw new Error("Windows system directory is too long");
|
|
118
|
+
} finally {
|
|
119
|
+
lib.close();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Pure consistency check over loaded-module paths — no env, no filesystem. Exported for tests. */
|
|
124
|
+
export function windowsSystemDirectoryFromSharedObjects(loaded) {
|
|
125
|
+
if (!Array.isArray(loaded)) throw new Error("trusted Windows resolver unavailable");
|
|
126
|
+
const parents = new Map(); // lowercased -> first-seen casing (kernel32 is processed first)
|
|
127
|
+
for (const known of WINDOWS_KNOWN_DLLS) {
|
|
128
|
+
// Collect every raw namesake first: a malformed or truncated namesake must
|
|
129
|
+
// cause rejection, not disappear behind a format filter.
|
|
130
|
+
const namesakes = loaded.filter(path => typeof path === "string" && win32.basename(path).toLowerCase() === known);
|
|
131
|
+
for (const candidate of namesakes) {
|
|
132
|
+
if (candidate.length >= WINDOWS_REPORT_PATH_LIMIT || !/^[A-Za-z]:[\\/]/.test(candidate))
|
|
133
|
+
throw new Error("trusted Windows resolver unavailable");
|
|
134
|
+
}
|
|
135
|
+
if (namesakes.length !== 1) throw new Error("trusted Windows resolver unavailable");
|
|
136
|
+
const parent = win32.dirname(win32.normalize(namesakes[0]));
|
|
137
|
+
if (!parents.has(parent.toLowerCase())) parents.set(parent.toLowerCase(), parent);
|
|
138
|
+
}
|
|
139
|
+
if (parents.size !== 1) throw new Error("trusted Windows resolver unavailable");
|
|
140
|
+
return [...parents.values()][0];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// The report object carries environment secrets: read .sharedObjects only — never
|
|
144
|
+
// log, serialize, store or pass it on. Existence checks stay outside the pure validator.
|
|
145
|
+
// An unavailable or ambiguous report stays the bounded unknown residual.
|
|
146
|
+
function resolveWindowsSystemDirectoryViaSharedObjects() {
|
|
147
|
+
const loaded = process.report?.getReport?.()?.sharedObjects;
|
|
148
|
+
const directory = windowsSystemDirectoryFromSharedObjects(loaded);
|
|
149
|
+
for (const required of [...WINDOWS_KNOWN_DLLS, win32.join("WindowsPowerShell", "v1.0", "powershell.exe")]) {
|
|
150
|
+
try { accessSync(win32.join(directory, required), constants.F_OK); }
|
|
151
|
+
catch { throw new Error("trusted Windows resolver unavailable"); }
|
|
152
|
+
}
|
|
153
|
+
return directory;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function windowsPowerShellEnv(systemDirectory) {
|
|
157
|
+
const root = win32.dirname(systemDirectory);
|
|
158
|
+
return { SystemRoot: root, WINDIR: root, PATH: systemDirectory, PATHEXT: ".COM;.EXE;.BAT;.CMD" };
|
|
88
159
|
}
|
|
89
160
|
|
|
90
161
|
function windowsProcessScript(pid) {
|
|
91
162
|
// pid is a validated safe integer; it only ever reaches a numeric WQL filter.
|
|
92
163
|
return [
|
|
93
164
|
"$ErrorActionPreference='Stop'",
|
|
165
|
+
"$PSModuleAutoLoadingPreference='None'",
|
|
166
|
+
// Utility loads first: the CimCmdlets manifest needs Set-Alias, which autoload 'None' cannot supply.
|
|
167
|
+
"Import-Module ([IO.Path]::Combine($PSHOME,'Modules','Microsoft.PowerShell.Utility','Microsoft.PowerShell.Utility.psd1')) -Force",
|
|
168
|
+
"Import-Module ([IO.Path]::Combine($PSHOME,'Modules','CimCmdlets','CimCmdlets.psd1')) -Force",
|
|
94
169
|
"function Row($p) { if ($null -eq $p) { return $null }; [ordered]@{ pid=[string]$p.ProcessId; parent=[string]$p.ParentProcessId; exe=$p.ExecutablePath; session=[string]$p.SessionId; created=$(if ($p.CreationDate) { [string]$p.CreationDate.ToUniversalTime().Ticks } else { $null }) } }",
|
|
95
|
-
`$c=Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId=${pid}'`,
|
|
170
|
+
`$c=CimCmdlets\\Get-CimInstance -ClassName Win32_Process -Filter 'ProcessId=${pid}'`,
|
|
96
171
|
"$p=$null",
|
|
97
|
-
"if ($c -and [uint32]$c.ParentProcessId -gt 0) { $p=Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + [uint32]$c.ParentProcessId) }",
|
|
98
|
-
"[ordered]@{ child=(Row $c); parent=(Row $p) } | ConvertTo-Json -Compress",
|
|
172
|
+
"if ($c -and [uint32]$c.ParentProcessId -gt 0) { $p=CimCmdlets\\Get-CimInstance -ClassName Win32_Process -Filter ('ProcessId=' + [uint32]$c.ParentProcessId) }",
|
|
173
|
+
"[ordered]@{ child=(Row $c); parent=(Row $p) } | Microsoft.PowerShell.Utility\\ConvertTo-Json -Compress",
|
|
99
174
|
].join("; ");
|
|
100
175
|
}
|
|
101
176
|
|
|
@@ -120,9 +195,11 @@ function windowsRow(row) {
|
|
|
120
195
|
/** One bounded Win32_Process read of a process and its parent. */
|
|
121
196
|
export function windowsProcessPair(pid, execute = run, options = {}) {
|
|
122
197
|
if (!validPid(pid)) throw new Error("invalid pid");
|
|
123
|
-
const
|
|
198
|
+
const resolveSystemDirectory = options.resolveSystemDirectory ?? resolveWindowsSystemDirectory;
|
|
199
|
+
const systemDirectory = resolveSystemDirectory();
|
|
200
|
+
const output = execute(windowsPowerShellPath(() => systemDirectory), [
|
|
124
201
|
"-NoProfile", "-NoLogo", "-NonInteractive", "-Command", windowsProcessScript(pid),
|
|
125
|
-
], options.timeoutMs ?? WINDOWS_ACQUISITION_TIMEOUT_MS);
|
|
202
|
+
], options.timeoutMs ?? WINDOWS_ACQUISITION_TIMEOUT_MS, windowsPowerShellEnv(systemDirectory));
|
|
126
203
|
const raw = JSON.parse(output);
|
|
127
204
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw new Error("invalid process pair");
|
|
128
205
|
// A Desktop parent seen before a later field fails validation must keep its veto.
|
|
@@ -154,7 +231,7 @@ export function inspectDesktopSupervision(deps = {}) {
|
|
|
154
231
|
const now = deps.now ?? Date.now;
|
|
155
232
|
const deadline = now() + WINDOWS_INSPECTION_BUDGET_MS;
|
|
156
233
|
const readWindowsPair = deps.windowsProcesses
|
|
157
|
-
?? ((pid, options) => windowsProcessPair(pid, execute, { ...options,
|
|
234
|
+
?? ((pid, options) => windowsProcessPair(pid, execute, { ...options, resolveSystemDirectory: deps.resolveWindowsSystemDirectory }));
|
|
158
235
|
function identity(pid, parent = false) {
|
|
159
236
|
if (platform === "darwin") return processIdentity(pid, execute, parent ? seen : undefined);
|
|
160
237
|
const executable = proc.exe(pid);
|
|
@@ -174,6 +174,18 @@ export function ownershipMutationLeaseStatusLine(statePaths, options = {}) {
|
|
|
174
174
|
+ `opencodex waits for it to start or change service state, and ${RECLAIM_HINT}.`;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
+
function createLeaseHandle(path, generation, token, options) {
|
|
178
|
+
let released = false;
|
|
179
|
+
return {
|
|
180
|
+
token,
|
|
181
|
+
release: () => {
|
|
182
|
+
if (released) return;
|
|
183
|
+
released = true;
|
|
184
|
+
release(path, generation, options);
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
177
189
|
function reclaim(path, now, alive) {
|
|
178
190
|
const observed = readOwner(path);
|
|
179
191
|
const incomplete = observed ? null : readIncompleteOwner(path);
|
|
@@ -201,7 +213,7 @@ export function acquireOwnershipMutationLease(
|
|
|
201
213
|
const nested = held.get(path);
|
|
202
214
|
if (nested) {
|
|
203
215
|
nested.depth += 1;
|
|
204
|
-
return
|
|
216
|
+
return createLeaseHandle(path, nested.generation, nested.snapshot.record.token, options);
|
|
205
217
|
}
|
|
206
218
|
const now = options.now ?? Date.now;
|
|
207
219
|
const alive = options.processAlive ?? processAlive;
|
|
@@ -213,8 +225,9 @@ export function acquireOwnershipMutationLease(
|
|
|
213
225
|
if (owner?.record.token === joinToken && alive(owner.record.pid)) {
|
|
214
226
|
delegatedTokens.set(path, joinToken);
|
|
215
227
|
if (envJoinToken === joinToken) delete process.env[OWNERSHIP_MUTATION_LEASE_TOKEN_ENV];
|
|
216
|
-
|
|
217
|
-
|
|
228
|
+
const generation = {};
|
|
229
|
+
held.set(path, { depth: 1, snapshot: owner, delegated: true, generation });
|
|
230
|
+
return createLeaseHandle(path, generation, joinToken, options);
|
|
218
231
|
}
|
|
219
232
|
delegatedTokens.delete(path);
|
|
220
233
|
if (envJoinToken === joinToken) delete process.env[OWNERSHIP_MUTATION_LEASE_TOKEN_ENV];
|
|
@@ -238,8 +251,9 @@ export function acquireOwnershipMutationLease(
|
|
|
238
251
|
descriptor = null;
|
|
239
252
|
const snapshot = readOwner(path);
|
|
240
253
|
if (!snapshot || snapshot.record.token !== record.token) throw new Error("ownership mutation lease could not be verified");
|
|
241
|
-
|
|
242
|
-
|
|
254
|
+
const generation = {};
|
|
255
|
+
held.set(path, { depth: 1, snapshot, delegated: false, generation });
|
|
256
|
+
return createLeaseHandle(path, generation, record.token, options);
|
|
243
257
|
} catch (error) {
|
|
244
258
|
if (descriptor !== null) { try { closeSync(descriptor); } catch { /* stale recovery owns uncertain cleanup */ } }
|
|
245
259
|
if (madeDirectory) {
|
|
@@ -261,9 +275,9 @@ export function acquireOwnershipMutationLease(
|
|
|
261
275
|
}
|
|
262
276
|
}
|
|
263
277
|
|
|
264
|
-
function release(path, options) {
|
|
278
|
+
function release(path, generation, options) {
|
|
265
279
|
const currentHeld = held.get(path);
|
|
266
|
-
if (!currentHeld) return;
|
|
280
|
+
if (!currentHeld || currentHeld.generation !== generation) return;
|
|
267
281
|
currentHeld.depth -= 1;
|
|
268
282
|
if (currentHeld.depth > 0) return;
|
|
269
283
|
held.delete(path);
|
package/src/types/config.ts
CHANGED
|
@@ -234,9 +234,9 @@ export interface OcxClaudeCodeConfig {
|
|
|
234
234
|
/** Optional roster-style model forced on subagents at the next routed Claude Code launch. */
|
|
235
235
|
subagentModelForce?: string;
|
|
236
236
|
/** Claude-originated web-search override. Unset fields inherit the global sidecar settings. */
|
|
237
|
-
webSearchSidecar?: { backend?: "openai" | "anthropic" | "xai" | "gemini" | "exa"; model?: string; anthropicInstance?: AnthropicInstanceId };
|
|
237
|
+
webSearchSidecar?: { enabled?: boolean; backend?: "openai" | "anthropic" | "xai" | "gemini" | "exa"; model?: string; anthropicInstance?: AnthropicInstanceId };
|
|
238
238
|
/** Claude-originated vision override. Unset fields inherit the global sidecar settings. */
|
|
239
|
-
visionSidecar?: { backend?: "openai" | "anthropic" | "routed"; model?: string; anthropicInstance?: AnthropicInstanceId };
|
|
239
|
+
visionSidecar?: { enabled?: boolean; backend?: "openai" | "anthropic" | "routed"; model?: string; anthropicInstance?: AnthropicInstanceId };
|
|
240
240
|
/** Persisted Claude Desktop four-family routing profile. */
|
|
241
241
|
desktopProfile?: OcxClaudeDesktopProfile;
|
|
242
242
|
/**
|
|
@@ -1435,6 +1435,12 @@ export interface OcxComboConfig {
|
|
|
1435
1435
|
cooldownMs?: number;
|
|
1436
1436
|
/** Maximum wait for an eligible target cooldown to expire before failing closed. Default 0; range 0..600000, per selection attempt. */
|
|
1437
1437
|
waitForCooldownMs?: number;
|
|
1438
|
+
/** Opt-in retry pass when all otherwise eligible targets are cooling. Disabled by default. */
|
|
1439
|
+
cooldownReprobe?: {
|
|
1440
|
+
enabled: boolean;
|
|
1441
|
+
/** Minimum interval between recovery passes, in milliseconds. Default 300000; range 1000..86400000. */
|
|
1442
|
+
intervalMs?: number;
|
|
1443
|
+
};
|
|
1438
1444
|
/**
|
|
1439
1445
|
* `before-last-resort` defers targets marked `lastResort` while a normal
|
|
1440
1446
|
* target is merely cooling and that cooldown can be waited out inside
|
|
@@ -1496,6 +1502,12 @@ export interface OcxComboConfig {
|
|
|
1496
1502
|
decisionQuotaSignals?: boolean | null;
|
|
1497
1503
|
/** Partial 0..100 tier overrides; defaults limited 70/nearlyExhausted 90. null clears. */
|
|
1498
1504
|
decisionQuotaTiers?: import("../combos/jev-quota-config").JevQuotaTiers | null;
|
|
1505
|
+
/**
|
|
1506
|
+
* `strategy: "jev"` only, default off: keep an explicit client session on the target JEV chose
|
|
1507
|
+
* for it while the session stays active, so the provider prompt cache stays warm (#7525).
|
|
1508
|
+
* `ttlMs` is the idle window after the last successful turn (60000..86400000). null clears.
|
|
1509
|
+
*/
|
|
1510
|
+
sessionPin?: import("../combos/jev-session-pin-config").JevSessionPinConfig | null;
|
|
1499
1511
|
}
|
|
1500
1512
|
|
|
1501
1513
|
export type OcxRoutingUnknownEvidenceMode = "allow" | "penalize" | "exclude";
|
package/src/types/provider.ts
CHANGED
|
@@ -278,12 +278,16 @@ export type TierDecision =
|
|
|
278
278
|
| { readonly kind: "drop" }
|
|
279
279
|
| { readonly kind: "set"; readonly value: string };
|
|
280
280
|
|
|
281
|
-
/**
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
281
|
+
/** Independent reasoning axes. Absence means unknown, not an explicit denial. */
|
|
282
|
+
export interface ReasoningCapabilities {
|
|
283
|
+
supportsReasoning?: boolean;
|
|
284
|
+
supportsThinkingToggle?: boolean;
|
|
285
|
+
supportsReasoningEffort?: boolean;
|
|
286
|
+
defaultThinkingEnabled?: boolean;
|
|
287
|
+
}
|
|
288
|
+
|
|
285
289
|
/** Explicit per-model operator declarations; absent axes keep legacy behavior. */
|
|
286
|
-
export interface ModelCapabilities {
|
|
290
|
+
export interface ModelCapabilities extends ReasoningCapabilities {
|
|
287
291
|
inputModalities?: Array<"text" | "image" | "audio" | "video">;
|
|
288
292
|
/** Requested tier only; does not imply an upstream window or activate an unverified wire. */
|
|
289
293
|
contextTier?: "default" | "long_context";
|
|
@@ -292,6 +296,10 @@ export interface ModelCapabilities {
|
|
|
292
296
|
deepseekImageFiles?: boolean;
|
|
293
297
|
}
|
|
294
298
|
|
|
299
|
+
/**
|
|
300
|
+
* One configured provider entry. `authMode` (default `"key"`) decides whether same-target 429
|
|
301
|
+
* retries are allowed; OAuth/forward credentials and local runtimes are never replayed.
|
|
302
|
+
*/
|
|
295
303
|
export interface OcxProviderConfig {
|
|
296
304
|
/** Explicit builtin Pool 2 provenance; endpoints never imply ownership. */
|
|
297
305
|
anthropicOAuthInstance?: "anthropic2";
|
|
@@ -661,6 +669,12 @@ export interface OcxProviderConfig {
|
|
|
661
669
|
modelContextTiers?: Record<string, "default" | "long_context">;
|
|
662
670
|
/** Model-specific Codex catalog input modalities, e.g. ["text"] or ["text", "image"]. */
|
|
663
671
|
modelInputModalities?: Record<string, string[]>;
|
|
672
|
+
/**
|
|
673
|
+
* Provider-wide input modalities, applied to models `modelInputModalities` does not enumerate
|
|
674
|
+
* (a live-discovered id, for example). The registry's value is applied at runtime only, for the
|
|
675
|
+
* preset's own destination, and never persisted; a per-model declaration still wins.
|
|
676
|
+
*/
|
|
677
|
+
inputModalities?: string[];
|
|
664
678
|
modelCapabilities?: Record<string, ModelCapabilities>;
|
|
665
679
|
/** Model-specific max input token limits. Values cap auto_compact_token_limit. */
|
|
666
680
|
modelMaxInputTokens?: Record<string, number>;
|
|
@@ -871,6 +885,14 @@ export interface OcxProviderConfig {
|
|
|
871
885
|
* SSE/JSON; raw inspection state remains authoritative.
|
|
872
886
|
*/
|
|
873
887
|
responsesSnapshotRepair?: boolean;
|
|
888
|
+
/**
|
|
889
|
+
* Infer the commentary/final_answer phase on assistant messages for Responses passthrough
|
|
890
|
+
* providers whose upstream omits it (e.g. third-party gateways). Codex desktop collapses
|
|
891
|
+
* commentary into progress rows; without this every narration renders fully expanded.
|
|
892
|
+
* Disabled by default. Applies in the client-facing SSE rewrite chain, including
|
|
893
|
+
* buffered JSON reconstructed from upstream SSE; ordinary upstream JSON is unchanged.
|
|
894
|
+
*/
|
|
895
|
+
messagePhaseInference?: boolean;
|
|
874
896
|
/**
|
|
875
897
|
* Opt-in hosted-web-search bridge for this KEY-auth Responses passthrough provider (#3761).
|
|
876
898
|
* Absent or disabled leaves the passthrough byte-identical to today.
|
|
@@ -892,7 +914,7 @@ export interface OcxProviderConfig {
|
|
|
892
914
|
* `reasoningEffortMap`, resolved per model first.
|
|
893
915
|
*/
|
|
894
916
|
modelReasoningEffortMap?: Record<string, Record<string, string>>;
|
|
895
|
-
/**
|
|
917
|
+
/** Chat gateway reasoning object; also opts custom Responses wires into `reasoning.enabled`. */
|
|
896
918
|
reasoningWireFormat?: "gateway-object";
|
|
897
919
|
/**
|
|
898
920
|
* Model ids that do NOT support a reasoning/thinking parameter. The openai-chat adapter drops
|
|
@@ -1116,7 +1138,7 @@ export interface OcxProviderConfig {
|
|
|
1116
1138
|
googleMode?: "ai-studio" | "vertex" | "cloud-code-assist";
|
|
1117
1139
|
/** Google tool-schema compatibility policy. Omitted preserves compatible report-only behavior. */
|
|
1118
1140
|
googleToolSchemaPolicy?: "compatible" | "reject-lossy";
|
|
1119
|
-
/** Vertex AI GCP project id. API keys use it to select the project endpoint; ADC falls back to GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env. */
|
|
1141
|
+
/** Vertex AI GCP project id. API keys use it to select the project endpoint; "auto" resolves each API key's own project. ADC falls back to GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT env. */
|
|
1120
1142
|
project?: string;
|
|
1121
1143
|
/** Vertex AI location, e.g. "us-central1" or "global". API-key project endpoints default to "global"; ADC falls back to GOOGLE_CLOUD_LOCATION env. */
|
|
1122
1144
|
location?: string;
|
package/src/types/request.ts
CHANGED
|
@@ -76,6 +76,11 @@ export interface OcxParsedRequest {
|
|
|
76
76
|
* them, and only for api.anthropic.com; every other destination never sees them.
|
|
77
77
|
*/
|
|
78
78
|
_anthropicServerTools?: readonly Record<string, unknown>[];
|
|
79
|
+
/**
|
|
80
|
+
* Routed Anthropic compaction summary: build tools and system exactly as the ordinary request
|
|
81
|
+
* would (prompt-cache prefix), then send tool_choice none so no client or hosted tool runs.
|
|
82
|
+
*/
|
|
83
|
+
_summaryProhibitsToolCalls?: boolean;
|
|
79
84
|
/**
|
|
80
85
|
* Completed server-tool exchanges from the Claude client's history, keyed by the block that
|
|
81
86
|
* followed them (`call:<tool_use id>` / `text:<text>`). Same audience as `_anthropicServerTools`.
|
|
@@ -148,6 +153,7 @@ export interface OcxParsedRequest {
|
|
|
148
153
|
_kiroAuthContext?: Pick<KiroOAuthMetadata, "profileArn" | "apiRegion" | "ssoRegion" | "authType">;
|
|
149
154
|
/** Account-scoped Zed user identity paired with the long-lived access token. */
|
|
150
155
|
_zedAuthContext?: { userId: string };
|
|
156
|
+
_workbuddyAuthContext?: import("../oauth/types").WorkBuddyOAuthMetadata;
|
|
151
157
|
/** Provider-private continuation metadata resolved from the Responses previous_response_id chain. */
|
|
152
158
|
_providerContinuation?: OcxProviderContinuationState;
|
|
153
159
|
/** Persisted continuation considered only after the final physical route is known. */
|
|
@@ -386,6 +392,11 @@ export interface OcxRequestOptions {
|
|
|
386
392
|
toolChoice?: OcxToolChoice;
|
|
387
393
|
parallelToolCalls?: boolean;
|
|
388
394
|
reasoning?: string;
|
|
395
|
+
/**
|
|
396
|
+
* Independent reasoning toggle resolved at client-compatibility ingress. This is distinct from
|
|
397
|
+
* the strength-like `reasoning` effort: toggle-only models consume this value as `thinking.type`.
|
|
398
|
+
*/
|
|
399
|
+
thinkingEnabled?: boolean;
|
|
389
400
|
hideThinkingSummary?: boolean;
|
|
390
401
|
/** Provider policy: suppress raw content-channel reasoning while summaries stay visible. */
|
|
391
402
|
hideRawReasoning?: boolean;
|
package/src/types/wire.ts
CHANGED
|
@@ -101,6 +101,7 @@ function normalizedEndpoint(value: unknown): string | undefined {
|
|
|
101
101
|
* URL. The empty prefix covers every model id.
|
|
102
102
|
*/
|
|
103
103
|
const CREDENTIAL_PINNED_ADAPTERS: Readonly<Record<string, Readonly<Record<string, string>>>> = Object.freeze({
|
|
104
|
+
"workbuddy-ai": Object.freeze({ "": "workbuddy-ai" }),
|
|
104
105
|
"dsh-account": Object.freeze({ "": "dsh-account" }),
|
|
105
106
|
});
|
|
106
107
|
|
package/src/types.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Strict bind script: exit 0 only after listen+close. Any listen error (including
|
|
5
|
+
* Windows ghost-TCB failures under Bun) is busy — matches published `ocx start`
|
|
6
|
+
* probes that treat every listen error as unavailable.
|
|
7
|
+
*/
|
|
8
|
+
export function strictBindProbeScript(port: number, hostname: string): string {
|
|
9
|
+
return [
|
|
10
|
+
"const net=require('net');",
|
|
11
|
+
"const s=net.createServer();",
|
|
12
|
+
"s.once('error',()=>process.exit(2));",
|
|
13
|
+
`s.listen(${Math.trunc(port)},${JSON.stringify(hostname)},()=>s.close(()=>process.exit(0)));`,
|
|
14
|
+
"setTimeout(()=>process.exit(3),2500);",
|
|
15
|
+
].join("");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function spawnBindProbe(bin: string, script: string): boolean {
|
|
19
|
+
try {
|
|
20
|
+
const r = spawnSync(bin, ["-e", script], {
|
|
21
|
+
windowsHide: true,
|
|
22
|
+
timeout: 4000,
|
|
23
|
+
stdio: "ignore",
|
|
24
|
+
});
|
|
25
|
+
return r.status === 0;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -16,3 +16,12 @@ export const CODEX_CLI_VERSION_MANAGER_ROOT_ENV_SLOTS: readonly [
|
|
|
16
16
|
"VOLTA_HOME",
|
|
17
17
|
];
|
|
18
18
|
export function isCodexCliUpdateInspectionArgv(argv: readonly string[]): boolean;
|
|
19
|
+
export const NODE_LAUNCH_CONTEXT_MAX_CHARS: number;
|
|
20
|
+
export function codexCliInspectionLookupSeeds(
|
|
21
|
+
platform: string,
|
|
22
|
+
home: string | null,
|
|
23
|
+
nodePath: string | null,
|
|
24
|
+
serializedContextChars: number,
|
|
25
|
+
): { home: string | null; nodePath: string | null };
|
|
26
|
+
export const CODEX_CLI_TRANSPORT_ENV_KEYS: readonly string[];
|
|
27
|
+
export function captureCodexCliTransportEnv(env: Readonly<NodeJS.ProcessEnv>): Record<string, string>;
|
|
@@ -16,6 +16,16 @@ export const CODEX_CLI_VERSION_MANAGER_ROOT_ENV_SLOTS = Object.freeze([
|
|
|
16
16
|
"VOLTA_HOME",
|
|
17
17
|
]);
|
|
18
18
|
|
|
19
|
+
export const CODEX_CLI_TRANSPORT_ENV_KEYS = Object.freeze([
|
|
20
|
+
"http_proxy", "https_proxy", "all_proxy", "no_proxy", "node_extra_ca_certs",
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
/** Preserve spelling, aliases and empty values before Bun loads project dotenv. */
|
|
24
|
+
export function captureCodexCliTransportEnv(env) {
|
|
25
|
+
return Object.fromEntries(Object.entries(env).filter(([name, value]) =>
|
|
26
|
+
CODEX_CLI_TRANSPORT_ENV_KEYS.includes(name.toLowerCase()) && typeof value === "string"));
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
/**
|
|
20
30
|
* Detect the read-only Codex CLI updater inspection namespace before Bun loads.
|
|
21
31
|
* Keep this exact and argument-position based: malformed actions still inherit
|
|
@@ -28,3 +38,23 @@ export function isCodexCliUpdateInspectionArgv(argv) {
|
|
|
28
38
|
const args = argv.slice(2).filter(value => !value.startsWith("--ocx-internal-launch-proof="));
|
|
29
39
|
return args[0] === "system" && args[1] === "codex-cli-update";
|
|
30
40
|
}
|
|
41
|
+
|
|
42
|
+
/** Serialized OCX_NODE_LAUNCH_CONTEXT ceiling; src/cli/launcher-context.ts refuses above it. */
|
|
43
|
+
export const NODE_LAUNCH_CONTEXT_MAX_CHARS = 64 * 1024;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The HOME/NODE_PATH seeds the update inspection's modeled Node lookup needs,
|
|
47
|
+
* bounded against the launch-context budget. They are POSIX-only: a Windows
|
|
48
|
+
* inspection never models the global lookup, so the seeds are not sent at all
|
|
49
|
+
* (and their env copies stay inherited for the child's own use). If carrying
|
|
50
|
+
* them would push the serialized context past the reader's limit they are
|
|
51
|
+
* dropped instead of taking the whole snapshot down with them — absent seeds
|
|
52
|
+
* leave only the global lane unverifiable, which fails the content
|
|
53
|
+
* observation closed while the selection context survives.
|
|
54
|
+
*/
|
|
55
|
+
export function codexCliInspectionLookupSeeds(platform, home, nodePath, serializedContextChars) {
|
|
56
|
+
if (platform === "win32" || serializedContextChars > NODE_LAUNCH_CONTEXT_MAX_CHARS) {
|
|
57
|
+
return { home: null, nodePath: null };
|
|
58
|
+
}
|
|
59
|
+
return { home: home ?? null, nodePath: nodePath ?? null };
|
|
60
|
+
}
|
package/src/update/job.ts
CHANGED
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
} from "./npm-cache-preflight.mjs";
|
|
54
54
|
import { guiUpdateWorkerCommand } from "./worker-launch";
|
|
55
55
|
import { withoutSiblingMarker } from "../codex/sibling-start";
|
|
56
|
+
import { spawnBindProbe, strictBindProbeScript } from "./bind-probe";
|
|
57
|
+
import { withoutUpdateTeardownHandover, withUpdateTeardownHandover } from "./teardown-handover";
|
|
56
58
|
import type { WorkerLaunchContext } from "./worker-launch";
|
|
57
59
|
|
|
58
60
|
const RELEASE_NOTES_URL = "https://github.com/lidge-jun/opencodex/releases/latest";
|
|
@@ -140,34 +142,6 @@ function usesNodeLauncher(installer: Installer): boolean {
|
|
|
140
142
|
return installer === "npm" || installer === "pnpm";
|
|
141
143
|
}
|
|
142
144
|
|
|
143
|
-
/**
|
|
144
|
-
* Strict bind script: exit 0 only after listen+close. Any listen error (including
|
|
145
|
-
* Windows ghost-TCB failures under Bun) is busy — matches published `ocx start`
|
|
146
|
-
* probes that treat every listen error as unavailable.
|
|
147
|
-
*/
|
|
148
|
-
function strictBindProbeScript(port: number, hostname: string): string {
|
|
149
|
-
return [
|
|
150
|
-
"const net=require('net');",
|
|
151
|
-
"const s=net.createServer();",
|
|
152
|
-
"s.once('error',()=>process.exit(2));",
|
|
153
|
-
`s.listen(${Math.trunc(port)},${JSON.stringify(hostname)},()=>s.close(()=>process.exit(0)));`,
|
|
154
|
-
"setTimeout(()=>process.exit(3),2500);",
|
|
155
|
-
].join("");
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function spawnBindProbe(bin: string, script: string): boolean {
|
|
159
|
-
try {
|
|
160
|
-
const r = spawnSync(bin, ["-e", script], {
|
|
161
|
-
windowsHide: true,
|
|
162
|
-
timeout: 4000,
|
|
163
|
-
stdio: "ignore",
|
|
164
|
-
});
|
|
165
|
-
return r.status === 0;
|
|
166
|
-
} catch {
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
145
|
/**
|
|
172
146
|
* Live global package Bun — not the npm rename tree the update worker may still
|
|
173
147
|
* be executing from (`@bitkyc08/.opencodex-*`). Reject the tiny postinstall
|
|
@@ -700,12 +674,14 @@ function runLoggedCommand(
|
|
|
700
674
|
bin: string,
|
|
701
675
|
args: string[],
|
|
702
676
|
timeout: number,
|
|
677
|
+
env?: NodeJS.ProcessEnv,
|
|
703
678
|
): { status: number | null; signal: NodeJS.Signals | null; timedOut: boolean } {
|
|
704
679
|
job = updateJob(job, {}, `$ ${formatCommand(bin, args)}`);
|
|
705
680
|
const result = spawnSync(bin, args, {
|
|
706
681
|
encoding: "utf8",
|
|
707
682
|
timeout,
|
|
708
683
|
windowsHide: true,
|
|
684
|
+
...(env ? { env } : {}),
|
|
709
685
|
});
|
|
710
686
|
const stdout = typeof result.stdout === "string" ? result.stdout.trim() : "";
|
|
711
687
|
const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
|
|
@@ -1812,6 +1788,7 @@ export interface GuiUpdateWorkerIo {
|
|
|
1812
1788
|
bin: string,
|
|
1813
1789
|
args: string[],
|
|
1814
1790
|
timeout: number,
|
|
1791
|
+
env?: NodeJS.ProcessEnv,
|
|
1815
1792
|
) => { status: number | null; signal: NodeJS.Signals | null };
|
|
1816
1793
|
}
|
|
1817
1794
|
|
|
@@ -1933,7 +1910,11 @@ export async function runGuiUpdateWorker(
|
|
|
1933
1910
|
- 대안 분석: (1) 서버에서 runUpdate 직접 호출: process.exit/stdio/실행 파일 교체 위험. (2) GUI에서 CLI 명령 안내만 제공: 자동 업데이트 UX 부족. (3) 숨은 worker가 Node launcher/Bun 전역 명령을 실행: 상태 추적과 안전한 재시작이 가능.
|
|
1934
1911
|
- 선택 근거: 현재 CLI의 package-manager self-update 우회를 재사용하면서도 GUI 서버 요청 생명주기와 설치 작업을 분리할 수 있어 가장 안정적이다.
|
|
1935
1912
|
*/
|
|
1936
|
-
|
|
1913
|
+
// #7423: this job restarts the proxy itself, so the update's stop hands Codex routing
|
|
1914
|
+
// and the routed catalog to the replacement instead of restoring native Codex for the
|
|
1915
|
+
// seconds in between. Without a restart the stop restores, even under an inherited marker.
|
|
1916
|
+
const updateEnv = restart ? withUpdateTeardownHandover(process.env) : withoutUpdateTeardownHandover(process.env);
|
|
1917
|
+
const result = (io.runCommandFn ?? runLoggedCommand)(job, cmd.bin, cmd.args, UPDATE_TIMEOUT_MS, updateEnv);
|
|
1937
1918
|
if (result.status !== 0) {
|
|
1938
1919
|
if (check.installer === "pnpm") {
|
|
1939
1920
|
const verifiedLauncher = pnpmOwner
|