@bitkyc08/opencodex 2.99.0 → 2.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS_INSTALL.md +19 -1
- package/README.md +37 -33
- package/SPONSORS.md +5 -1
- package/bin/ocx.mjs +1 -1
- package/gui/dist/assets/{App-C1hGwaN1.css → App-COo8Yopd.css} +1 -1
- package/gui/dist/assets/App-CitvEefy.js +59 -0
- package/gui/dist/assets/Tray-CeKVWQyB.js +1 -0
- package/gui/dist/assets/{brand-mark-wzPe3R-J.js → brand-mark-M92UnxX2.js} +1 -1
- package/gui/dist/assets/index-BP47do6-.js +94 -0
- package/gui/dist/assets/index-DmDooSAG.css +2 -0
- package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-CcxZBnxv.js} +1 -1
- package/gui/dist/classic/assets/App-aYgIQMxI.js +58 -0
- package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-D8jfUXpQ.js} +1 -1
- package/gui/dist/classic/assets/index-CfGqHooN.js +94 -0
- package/gui/dist/classic/assets/quota-summary-R-ih7OlS.js +1 -0
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.lock +215 -0
- package/native/ocx-child/Cargo.toml +31 -0
- package/native/ocx-child/src/cli.rs +1901 -0
- package/native/ocx-child/src/codex_home.rs +429 -0
- package/native/ocx-child/src/codex_settings.rs +231 -0
- package/native/ocx-child/src/daemon.rs +363 -0
- package/native/ocx-child/src/http_wire.rs +619 -0
- package/native/ocx-child/src/journal.rs +977 -0
- package/native/ocx-child/src/lib.rs +22 -0
- package/native/ocx-child/src/main.rs +9 -0
- package/native/ocx-child/src/parity.rs +102 -0
- package/native/ocx-child/src/platform.rs +1487 -0
- package/native/ocx-child/src/relay.rs +1288 -0
- package/native/ocx-child/src/relay_auth.rs +166 -0
- package/native/ocx-child/src/routes.rs +236 -0
- package/native/ocx-child/src/state.rs +190 -0
- package/native/ocx-child/src/test_hooks.rs +58 -0
- package/native/ocx-child/src/toml_surgeon.rs +1156 -0
- package/package.json +8 -2
- package/src/adapters/anthropic.ts +28 -2
- package/src/adapters/claude-cli/adapter.ts +5 -25
- package/src/adapters/claude-cli/instruction-images.ts +31 -0
- package/src/adapters/claude-cli/stable-replay.ts +42 -14
- package/src/adapters/claude-cli/usage-admission.ts +53 -64
- package/src/adapters/coding-agent/protocol.ts +1 -1
- package/src/adapters/devin/live-models.ts +3 -0
- package/src/adapters/google-http.ts +3 -0
- package/src/adapters/google-vertex-key-project.ts +10 -2
- package/src/adapters/google.ts +40 -8
- package/src/adapters/kiro/usage.ts +3 -13
- package/src/adapters/openai-responses/passthrough.ts +5 -2
- package/src/adapters/openai-responses/request-strips.ts +32 -0
- package/src/adapters/openai-responses/tool-schema.ts +9 -4
- package/src/chat/inbound.ts +1 -1
- package/src/claude/auth-detect.ts +26 -8
- package/src/claude/inbound-content-options.ts +18 -3
- package/src/claude/inbound.ts +5 -2
- package/src/cli/bundled-bun-diagnostic.ts +91 -0
- package/src/cli/capabilities-agents-routing.ts +2 -2
- package/src/cli/capabilities-observe-system.ts +60 -0
- package/src/cli/combo-input.ts +6 -0
- package/src/cli/combo-result.ts +1 -1
- package/src/cli/combo.ts +4 -0
- package/src/cli/config-command.ts +16 -2
- package/src/cli/connect.ts +12 -10
- package/src/cli/dispatch.ts +4 -0
- package/src/cli/doctor.ts +11 -0
- package/src/cli/help.ts +1 -0
- package/src/cli/init.ts +4 -0
- package/src/cli/link-enrollment.ts +152 -25
- package/src/cli/link-local-control.ts +49 -0
- package/src/cli/link.ts +37 -10
- package/src/cli/provider-lifecycle-runtime.ts +4 -2
- package/src/cli/registry.ts +13 -0
- package/src/cli/star-prompt.ts +2 -0
- package/src/cli/status.ts +1 -1
- package/src/cli/telemetry-profile.ts +206 -0
- package/src/cli/telemetry.ts +260 -0
- package/src/client/hub-relay.ts +26 -0
- package/src/client/machine-api.ts +3 -0
- package/src/clients/config-export/t3code.ts +44 -5
- package/src/clients/omo-role-models.ts +1 -1
- package/src/codex/catalog/bundled.ts +44 -2
- package/src/codex/runtime.ts +12 -0
- package/src/codex/shim-restore-lock.ts +67 -30
- package/src/combos/types.ts +21 -1
- package/src/config/atomic-write.ts +24 -1
- package/src/config/diagnostics.ts +15 -0
- package/src/config/live-reconcile.ts +17 -0
- package/src/config/load-degrade.ts +16 -0
- package/src/config/provider-validation.ts +29 -0
- package/src/config/schema/config-schema.ts +24 -0
- package/src/config/schema/leaf-validators.ts +17 -0
- package/src/config/telemetry-carry.ts +30 -0
- package/src/config.ts +13 -1
- package/src/generated/compatibility-version.json +405 -153
- package/src/generated/model-metadata.ts +3 -3
- package/src/integrations/aside-profiles.ts +7 -1
- package/src/integrations/owned-refresh.ts +9 -2
- package/src/lab/artifacts/secure-fs.ts +12 -11
- package/src/lab/fabric/scratch.ts +11 -9
- package/src/lab/public/community.ts +2 -3
- package/src/lab/public/file-safety.ts +18 -20
- package/src/lab/public/mutation-lock.ts +109 -337
- package/src/lab/public/private-file.ts +4 -3
- package/src/lib/bun-runtime-preflight.ts +1 -1
- package/src/lib/codex-catalog-read-only.ts +122 -0
- package/src/lib/config-ownership.ts +49 -18
- package/src/lib/errors.ts +11 -0
- package/src/lib/gcp-adc.ts +167 -48
- package/src/lib/jsonc.ts +4 -2
- package/src/lib/local-control-socket.ts +88 -0
- package/src/lib/privacy.ts +15 -0
- package/src/lib/provider-client-headers.ts +3 -0
- package/src/lib/token-estimate.ts +13 -2
- package/src/link/child-binary-source.ts +228 -0
- package/src/link/ephemeral-child.ts +45 -0
- package/src/link/remote-plant.ts +306 -0
- package/src/link/remote-windows.ts +59 -5
- package/src/link/ssh-argv.ts +71 -8
- package/src/link/status-projection.ts +2 -0
- package/src/link/store.ts +5 -1
- package/src/oauth/claude-keychain-read.ts +165 -0
- package/src/oauth/local-token-detect.ts +14 -17
- package/src/protocols/envelope.ts +20 -2
- package/src/providers/api-key-selection.ts +8 -2
- package/src/providers/claude-cli-usage-state.ts +93 -0
- package/src/providers/github-copilot-auto.ts +25 -5
- package/src/providers/meta-muse-plan-refusal.ts +94 -0
- package/src/providers/model-rename-fields.ts +3 -0
- package/src/providers/quota/vendor-probes-key.ts +23 -4
- package/src/providers/quota/vendor-probes-oauth.ts +59 -0
- package/src/providers/quota/workbuddy.ts +2 -2
- package/src/providers/quota.ts +25 -18
- package/src/providers/registry/entries-core.ts +7 -4
- package/src/providers/registry/entries-extended.ts +39 -7
- package/src/providers/registry/model-seeds.ts +10 -2
- package/src/providers/resolved-model-policy.ts +4 -0
- package/src/providers/routed-config.ts +30 -3
- package/src/providers/stale-no-vision-seed-migration.ts +7 -0
- package/src/providers/vertex-environment-authority.ts +50 -0
- package/src/providers/workbuddy-credit-balance.ts +38 -6
- package/src/quota-pool/assemble.ts +14 -6
- package/src/router.ts +1 -0
- package/src/server/adapter-resolve.ts +11 -6
- package/src/server/audio-dictation.ts +21 -7
- package/src/server/auth-cors.ts +19 -0
- package/src/server/background-lifecycle.ts +71 -0
- package/src/server/chat-completions.ts +2 -0
- package/src/server/claude-messages.ts +30 -3
- package/src/server/index/live-sideband.ts +15 -1
- package/src/server/index/local-control-listener.ts +515 -0
- package/src/server/index/optional-listeners.ts +21 -1
- package/src/server/index/serve-options.ts +4 -3
- package/src/server/index/websocket-handler.ts +2 -0
- package/src/server/index.ts +3 -0
- package/src/server/management/combo-routes.ts +6 -1
- package/src/server/management/context.ts +1 -0
- package/src/server/management/link-child-preflight.ts +74 -0
- package/src/server/management/link-enrollment.ts +190 -25
- package/src/server/management/link-route-state.ts +6 -1
- package/src/server/management/link-routes.ts +27 -9
- package/src/server/management/model-rows.ts +4 -0
- package/src/server/management/oauth-account-routes.ts +9 -4
- package/src/server/management/provider-overwrite-carry.ts +9 -2
- package/src/server/management/provider-routes.ts +14 -0
- package/src/server/management/provider-thinking-display-patch.ts +54 -0
- package/src/server/management/route-registry.ts +7 -0
- package/src/server/management/session-routes.ts +4 -1
- package/src/server/management/telemetry-routes.ts +37 -0
- package/src/server/management/usage-aggregate-cache.ts +290 -67
- package/src/server/management-api.ts +11 -2
- package/src/server/messages-native-preflight.ts +166 -0
- package/src/server/messages-native.ts +143 -43
- package/src/server/messages-shared.ts +14 -0
- package/src/server/proxy-liveness.ts +99 -6
- package/src/server/request-log-conversation.ts +18 -2
- package/src/server/request-log.ts +7 -2
- package/src/server/responses/adapter-continuation.ts +1 -0
- package/src/server/responses/adapter-dispatch.ts +11 -28
- package/src/server/responses/adapter-failure-message.ts +68 -0
- package/src/server/responses/combo-stream-preflight.ts +14 -2
- package/src/server/responses/core-auth.ts +26 -5
- package/src/server/responses/core-codex-account.ts +8 -1
- package/src/server/responses/core-combo-failure.ts +6 -1
- package/src/server/responses/core-combo-native.ts +150 -37
- package/src/server/responses/core-combo.ts +15 -9
- package/src/server/responses/core-normalize.ts +1 -0
- package/src/server/responses/core-options.ts +7 -1
- package/src/server/responses/core-pipeline.ts +21 -1
- package/src/server/responses/fetch-helpers.ts +5 -0
- package/src/server/responses/opengateway-completion-guard.ts +7 -3
- package/src/server/responses/passthrough-delivery.ts +8 -1
- package/src/server/responses/passthrough-error.ts +22 -0
- package/src/server/responses/request-prepare.ts +7 -1
- package/src/server/responses/request-transport.ts +28 -5
- package/src/server/responses/run-turn-execution.ts +13 -0
- package/src/server/sse-frame-buffer.ts +5 -0
- package/src/server/ws-bridge.ts +10 -0
- package/src/service/launchd.ts +78 -4
- package/src/telemetry/aggregate.ts +348 -0
- package/src/telemetry/consent.ts +128 -0
- package/src/telemetry/contract.ts +403 -0
- package/src/telemetry/disclosure.ts +19 -0
- package/src/telemetry/install-id.ts +226 -0
- package/src/telemetry/payload.ts +129 -0
- package/src/telemetry/profile/client.ts +150 -0
- package/src/telemetry/profile/contract.ts +288 -0
- package/src/telemetry/profile/disclosure.ts +14 -0
- package/src/telemetry/profile/paths.ts +13 -0
- package/src/telemetry/profile/routes.ts +99 -0
- package/src/telemetry/profile/service.ts +234 -0
- package/src/telemetry/profile/state.ts +189 -0
- package/src/telemetry/profile/sync.ts +276 -0
- package/src/telemetry/routes.ts +183 -0
- package/src/telemetry/scheduler.ts +386 -0
- package/src/telemetry/sender.ts +97 -0
- package/src/telemetry/state.ts +334 -0
- package/src/types/combo-jev-effort-mode.ts +11 -0
- package/src/types/config.ts +3 -0
- package/src/types/provider.ts +11 -1
- package/src/types/request.ts +2 -0
- package/src/types/telemetry.ts +15 -0
- package/src/types/wire.ts +10 -0
- package/src/types.ts +5 -0
- package/src/update/index.ts +7 -1
- package/src/update/minisign.d.mts +17 -0
- package/src/update/minisign.mjs +88 -0
- package/src/update/signed-supply.d.mts +59 -0
- package/src/update/signed-supply.mjs +289 -0
- package/src/update/trust-root.json +38 -0
- package/src/update/update-bounded-json.d.mts +4 -0
- package/src/update/update-bounded-json.mjs +113 -0
- package/src/update/update-bytes.d.mts +2 -0
- package/src/update/update-bytes.mjs +23 -0
- package/src/update/update-candidate-id.d.mts +2 -0
- package/src/update/update-candidate-id.mjs +23 -0
- package/src/update/update-checkpoint-codec.d.mts +33 -0
- package/src/update/update-checkpoint-codec.mjs +217 -0
- package/src/update/update-contracts.d.mts +24 -0
- package/src/update/update-contracts.mjs +207 -0
- package/src/update/update-signature-threshold.d.mts +12 -0
- package/src/update/update-signature-threshold.mjs +47 -0
- package/src/update/update-signed-version.d.mts +5 -0
- package/src/update/update-signed-version.mjs +25 -0
- package/src/update/update-trust-anchor.d.mts +2 -0
- package/src/update/update-trust-anchor.mjs +2 -0
- package/src/usage/cache-diagnostic.ts +195 -50
- package/src/usage/expected-prices.ts +20 -2
- package/src/usage/filter-index.ts +1469 -0
- package/src/usage/ledger-scanner.ts +245 -4
- package/src/usage/source-filter.ts +10 -2
- package/src/usage/summary.ts +16 -0
- package/src/web-search/parse.ts +244 -38
- package/gui/dist/assets/App-BepstgEN.js +0 -59
- package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
- package/gui/dist/assets/index-C-9X2yaI.js +0 -94
- package/gui/dist/assets/index-bnUWypyz.css +0 -2
- package/gui/dist/classic/assets/App-DX88_GCW.js +0 -58
- package/gui/dist/classic/assets/index-fSP71pLB.js +0 -94
- package/gui/dist/classic/assets/quota-summary-y2fl0WBv.js +0 -1
package/src/adapters/google.ts
CHANGED
|
@@ -19,9 +19,10 @@ import type {
|
|
|
19
19
|
import { isAllowedToolChoice, namespacedToolName, resolveToolChoiceWireName, toolChoiceToolPredicate } from "../types";
|
|
20
20
|
import type { OcxTool } from "../types";
|
|
21
21
|
import { contentPartsToText, parseDataUrl } from "./image";
|
|
22
|
-
import { GCP_CREDENTIAL_MARKER_PREFIX, gcpCredentialMarkerAccount,
|
|
22
|
+
import { bindVertexRequestAuthority, GCP_CREDENTIAL_MARKER_PREFIX, gcpCredentialMarkerAccount, getVertexAccessTokenWithAuthority } from "../lib/gcp-adc";
|
|
23
23
|
import { fetchAntigravityWithRetry, fetchVertexWithRetry } from "./google-http";
|
|
24
24
|
import { safeAntigravityHttpErrorMessage, safeVertexHttpErrorMessage } from "./google-errors";
|
|
25
|
+
import { readDisplaySafeErrorPayloadText } from "./upstream-http-error";
|
|
25
26
|
import { isVertexTruncatedTurn, vertexTruncationErrorEvent } from "./google-truncation";
|
|
26
27
|
import { antigravitySessionAnchor, antigravityUserAgentForWireModel, antigravitySessionId, isLikelyRealThoughtSignature, sanitizeAntigravityClaudeSignatures } from "./google-antigravity-wire";
|
|
27
28
|
import { summarizeGoogleWireShape } from "./google-wire-shape";
|
|
@@ -37,6 +38,7 @@ import {
|
|
|
37
38
|
} from "./google-antigravity-replay";
|
|
38
39
|
import { canonicalAntigravityUsageModel, resolveAntigravityEffortWireModel } from "../providers/antigravity-models";
|
|
39
40
|
import { selectVertexEndpoint, vertexInferenceUrl, vertexReplayModelKey } from "./google-vertex-endpoint";
|
|
41
|
+
import { captureVertexAmbientKey, vertexAmbientKeyIsCurrent } from "../providers/vertex-environment-authority";
|
|
40
42
|
import { resolveVertexApiKeyProject, VERTEX_PROJECT_AUTO } from "./google-vertex-key-project";
|
|
41
43
|
import { forgetThoughtSignatureForReplay, lookupReplayThoughtSignature } from "../responses/thought-signature-replay";
|
|
42
44
|
import {
|
|
@@ -945,11 +947,15 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
945
947
|
// session replay cache), but durable-store eviction is intentionally narrower: it only runs
|
|
946
948
|
// when the error text explicitly mentions a signature, so a generic tool-schema
|
|
947
949
|
// INVALID_ARGUMENT does not destroy valid durable signatures.
|
|
948
|
-
|
|
950
|
+
//
|
|
951
|
+
// `httpStatus` is the real upstream status when the rejection arrived as an HTTP error. The
|
|
952
|
+
// normalized Vertex/Antigravity error text keeps only Google's message, not its status enum,
|
|
953
|
+
// so a 400 such as "bad model" would otherwise leave the poisoned session entry in place (#8054).
|
|
954
|
+
function handleSignatureRejection(errorMessage?: string, httpStatus?: number) {
|
|
949
955
|
const replayModel = provider.googleMode === "cloud-code-assist" ? antigravityModel : vertexReplayModel;
|
|
950
956
|
const replaySession = provider.googleMode === "cloud-code-assist" ? antigravitySession : vertexReplaySession;
|
|
951
957
|
const text = errorMessage ?? "";
|
|
952
|
-
const isInvalidArgument = /invalid_argument|invalid argument/i.test(text);
|
|
958
|
+
const isInvalidArgument = httpStatus === 400 || /invalid_argument|invalid argument/i.test(text);
|
|
953
959
|
const isSignatureError = /signature|thought_signature|thoughtSignature/i.test(text);
|
|
954
960
|
// The in-memory Antigravity replay cache only exists for CCA/Vertex, so clearing it stays
|
|
955
961
|
// scoped to those modes (replayModel/replaySession are undefined elsewhere anyway).
|
|
@@ -981,12 +987,23 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
981
987
|
// 429 rotation and raw error formatting.
|
|
982
988
|
...(provider.googleMode === "vertex" || provider.googleMode === "cloud-code-assist"
|
|
983
989
|
? {
|
|
984
|
-
fetchResponse: (request: AdapterRequest, ctx?: AdapterFetchContext): Promise<Response> =>
|
|
985
|
-
(provider.googleMode === "cloud-code-assist" ? fetchAntigravityWithRetry : fetchVertexWithRetry)(
|
|
990
|
+
fetchResponse: async (request: AdapterRequest, ctx?: AdapterFetchContext): Promise<Response> => {
|
|
991
|
+
const res = await (provider.googleMode === "cloud-code-assist" ? fetchAntigravityWithRetry : fetchVertexWithRetry)(
|
|
986
992
|
request,
|
|
987
993
|
ctx,
|
|
988
994
|
{ toolSchemaProfile, toolSchemaPolicy },
|
|
989
|
-
)
|
|
995
|
+
);
|
|
996
|
+
// A rejected replay usually arrives as a real HTTP 400, and the dispatcher reports a
|
|
997
|
+
// non-ok response without ever calling parseStream/parseResponse — the only other
|
|
998
|
+
// callers of clear-on-invalid. Without this, the bad signature stays cached and is
|
|
999
|
+
// replayed on every turn until the TTL expires (#8054). Read a clone so the body the
|
|
1000
|
+
// dispatcher formats is untouched, and await it so the next turn cannot race ahead of
|
|
1001
|
+
// the eviction. No resend here: payload rejection stays resend-is-futile.
|
|
1002
|
+
if (res.status === 400) {
|
|
1003
|
+
handleSignatureRejection(await readDisplaySafeErrorPayloadText(res.clone(), ctx?.abortSignal), res.status);
|
|
1004
|
+
}
|
|
1005
|
+
return res;
|
|
1006
|
+
},
|
|
990
1007
|
formatErrorBody: (status: number, _headers: Headers, payloadText: string): string =>
|
|
991
1008
|
(provider.googleMode === "cloud-code-assist" ? safeAntigravityHttpErrorMessage : safeVertexHttpErrorMessage)(status, payloadText),
|
|
992
1009
|
}
|
|
@@ -1222,10 +1239,17 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
1222
1239
|
}
|
|
1223
1240
|
|
|
1224
1241
|
if (provider.googleMode === "vertex") {
|
|
1242
|
+
if (provider.authMode === "forward") throw new Error("Vertex does not support forward authentication");
|
|
1225
1243
|
const compiled = compileGoogleWireBody(body, toolSchemaProfile, toolSchemaPolicy);
|
|
1226
1244
|
reportToolSchemaLoss(compiled.toolSchemaLossReport);
|
|
1227
1245
|
restoreGoogleToolName = compiled.restoreToolName;
|
|
1228
1246
|
const apiKey = resolveVertexApiKey(provider.apiKey);
|
|
1247
|
+
const ambientAuthority = apiKey && (!provider.apiKey || provider.apiKey.startsWith("<") || provider.apiKey === "N/A")
|
|
1248
|
+
? captureVertexAmbientKey(apiKey) : undefined;
|
|
1249
|
+
const beforeCredentialSend = () => {
|
|
1250
|
+
incoming?.beforePhysicalSend?.();
|
|
1251
|
+
if (ambientAuthority && !vertexAmbientKeyIsCurrent(ambientAuthority)) throw new Error("Vertex credential authority changed before auxiliary send");
|
|
1252
|
+
};
|
|
1229
1253
|
let vertexEndpoint = selectVertexEndpoint(provider, Boolean(apiKey));
|
|
1230
1254
|
if (apiKey && vertexEndpoint.kind === "project" && vertexEndpoint.project === VERTEX_PROJECT_AUTO) {
|
|
1231
1255
|
// Unresolved keys use express for this request so Google's status drives key failover.
|
|
@@ -1233,6 +1257,7 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
1233
1257
|
signal: incoming?.abortSignal,
|
|
1234
1258
|
provider,
|
|
1235
1259
|
providerName: incoming?.providerName,
|
|
1260
|
+
beforeSend: beforeCredentialSend,
|
|
1236
1261
|
});
|
|
1237
1262
|
vertexEndpoint = project ? { ...vertexEndpoint, project } : { kind: "express" };
|
|
1238
1263
|
}
|
|
@@ -1254,13 +1279,20 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
|
|
|
1254
1279
|
);
|
|
1255
1280
|
}
|
|
1256
1281
|
// Endpoint, location and model path were validated above, before any credential is attached.
|
|
1282
|
+
let adcAuthority: Awaited<ReturnType<typeof getVertexAccessTokenWithAuthority>> | undefined;
|
|
1257
1283
|
if (apiKey) headers["x-goog-api-key"] = apiKey;
|
|
1258
1284
|
else {
|
|
1259
1285
|
// Resolve each marker per request; never share a process-global active account.
|
|
1260
1286
|
const markerAccount = gcpCredentialMarkerAccount(provider.apiKey);
|
|
1261
|
-
|
|
1287
|
+
adcAuthority = await getVertexAccessTokenWithAuthority({ markerAccount, signal: incoming?.abortSignal, beforeSend: beforeCredentialSend });
|
|
1288
|
+
headers["Authorization"] = `Bearer ${adcAuthority.token}`;
|
|
1289
|
+
}
|
|
1290
|
+
const request = { url, method: "POST", headers, body: JSON.stringify(compiled.body) };
|
|
1291
|
+
if (adcAuthority) bindVertexRequestAuthority(request, url, headers["Authorization"]!, { source: adcAuthority.source, generation: adcAuthority.generation, markerAccount: adcAuthority.markerAccount });
|
|
1292
|
+
else if (apiKey && ambientAuthority) {
|
|
1293
|
+
bindVertexRequestAuthority(request, url, apiKey, { ambientKey: ambientAuthority });
|
|
1262
1294
|
}
|
|
1263
|
-
return
|
|
1295
|
+
return request;
|
|
1264
1296
|
}
|
|
1265
1297
|
|
|
1266
1298
|
// Go and Zen use separate guarded Gemini endpoints; AI Studio retains /v1beta.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { estimateTokens, estimateTokensFromCharacterCounts } from "../../lib/token-estimate";
|
|
1
|
+
import { countCjk, estimateTokens, estimateTokensFromCharacterCounts } from "../../lib/token-estimate";
|
|
2
2
|
import { KIRO_MODEL_CONTEXT_WINDOWS, normalizeKiroModelId } from "../../providers/kiro-models";
|
|
3
3
|
import { kiroObservedContextWindow } from "../../providers/kiro-model-catalog";
|
|
4
4
|
import { modelRecordValue } from "../../reasoning-effort";
|
|
@@ -77,18 +77,8 @@ export function estimateKiroTokens(text: string, modelId?: string): number {
|
|
|
77
77
|
return estimateTokens(text, modelId ? `kiro/${modelId}` : "kiro");
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
export
|
|
82
|
-
let cjk = 0;
|
|
83
|
-
for (let i = 0; i < text.length; i++) {
|
|
84
|
-
const c = text.charCodeAt(i);
|
|
85
|
-
if (
|
|
86
|
-
(c >= 0xac00 && c <= 0xd7a3) || (c >= 0x1100 && c <= 0x11ff) || (c >= 0x3130 && c <= 0x318f)
|
|
87
|
-
|| (c >= 0x4e00 && c <= 0x9fff) || (c >= 0x3400 && c <= 0x4dbf) || (c >= 0x3040 && c <= 0x30ff)
|
|
88
|
-
) cjk++;
|
|
89
|
-
}
|
|
90
|
-
return cjk;
|
|
91
|
-
}
|
|
80
|
+
/** The wire and shared estimates use the same UTF-16 CJK buckets. */
|
|
81
|
+
export const kiroCjkCount = countCjk;
|
|
92
82
|
|
|
93
83
|
/**
|
|
94
84
|
* Token estimate for walked payload text, with the wire expansion applied to the Latin portion
|
|
@@ -40,7 +40,7 @@ import {
|
|
|
40
40
|
emittedFastWire,
|
|
41
41
|
} from "../../providers/fastwire";
|
|
42
42
|
import { dropResponsesReasoningInputItems, mapRoutedResponsesReasoningEffort, normalizeConfiguredReasoningSummaryDelivery, sanitizeReasoningInputContent, stripDisabledReasoningSummaries, stripDisabledVerbosity, stripInternalReasoningEnabled, stripNoneReasoningSummary, stripUnsupportedReasoningSummaryDelivery } from "./reasoning";
|
|
43
|
-
import { repairUrlCitationAnnotations, scrubOcxCompactionItems, stripUnsupportedOutputInclude, stripCanonicalOnlyInputItems, stripCanonicalOnlyToolFields, stripCanonicalOnlyTopLevelFields, stripInternalChatMessageMetadataPassthrough, stripInvalidItemIds, stripItemIdsWhenUnstored, stripProviderInputItemMetadata, stripRejectedSamplingParams } from "./request-strips";
|
|
43
|
+
import { repairUrlCitationAnnotations, scrubOcxCompactionItems, stripUnsupportedOutputInclude, stripArkKimiOrphanCipher, stripCanonicalOnlyInputItems, stripCanonicalOnlyToolFields, stripCanonicalOnlyTopLevelFields, stripInternalChatMessageMetadataPassthrough, stripInvalidItemIds, stripItemIdsWhenUnstored, stripProviderInputItemMetadata, stripRejectedSamplingParams } from "./request-strips";
|
|
44
44
|
import { notePlaintextReasoningDropped } from "./plaintext-reasoning-notice";
|
|
45
45
|
import { stripCanonicalForwardPromptCacheOptions, stripDeprecatedPromptCacheRetention } from "./prompt-cache";
|
|
46
46
|
import { isPlainObject } from "./internal";
|
|
@@ -363,8 +363,10 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
|
|
|
363
363
|
// Azure also rejects this exact include entry, including on plain Responses routes.
|
|
364
364
|
const isAzureResponses = provider.adapter === "azure" || provider.adapter === "azure-openai"
|
|
365
365
|
|| new URL(url).hostname.toLowerCase().endsWith(".openai.azure.com");
|
|
366
|
+
const arkKimi = !forward && provider.arkKimiResponsesModels?.includes(parsed.modelId);
|
|
367
|
+
if (arkKimi) outBody = stripArkKimiOrphanCipher(outBody);
|
|
366
368
|
if (isXaiResponsesDestination(provider) || isMetaAiResponsesDestination(url) || isAzureResponses
|
|
367
|
-
|| isKimiCodingResponsesHttpsUrl(url)) {
|
|
369
|
+
|| isKimiCodingResponsesHttpsUrl(url) || arkKimi) {
|
|
368
370
|
outBody = stripUnsupportedOutputInclude(outBody);
|
|
369
371
|
}
|
|
370
372
|
// xAI and explicitly classified compatible gateways reject these OpenAI web_search
|
|
@@ -449,6 +451,7 @@ export function createResponsesPassthroughAdapter(provider: OcxProviderConfig):
|
|
|
449
451
|
provider.preserveResponsesInputItemIds === true,
|
|
450
452
|
),
|
|
451
453
|
isXaiSchemaTarget(provider),
|
|
454
|
+
parsed._chatCompletionsInput === true && isOpenAiOperatedResponsesDestination(provider),
|
|
452
455
|
);
|
|
453
456
|
const unnormalizedBody = stripDisabledVerbosity(
|
|
454
457
|
stripDisabledReasoningSummaries(
|
|
@@ -23,6 +23,38 @@ export function stripUnsupportedOutputInclude(body: unknown): unknown {
|
|
|
23
23
|
return { ...body, include };
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** 仅移除已验证孤立边界中无摘要、未被引用的推理项密文,保留整条历史项。 */
|
|
27
|
+
export function stripArkKimiOrphanCipher(body: unknown): unknown {
|
|
28
|
+
if (!isPlainObject(body) || !Array.isArray(body.input)) return body;
|
|
29
|
+
const input = body.input;
|
|
30
|
+
const isUser = (item: unknown) => isPlainObject(item) && item.role === "user"
|
|
31
|
+
&& (item.type === undefined || item.type === "message");
|
|
32
|
+
const referenced = new Set(input.filter(item => isPlainObject(item) && item.type === "item_reference").map(item => item.id));
|
|
33
|
+
let changed = false;
|
|
34
|
+
const next = input.map((item, i) => {
|
|
35
|
+
// A matching call/result pair is the other confirmed boundary before an orphan.
|
|
36
|
+
const call = input[i - 2], result = input[i - 1];
|
|
37
|
+
const afterTool = isPlainObject(call) && call.type === "function_call"
|
|
38
|
+
&& isPlainObject(result) && result.type === "function_call_output"
|
|
39
|
+
&& typeof call.call_id === "string" && call.call_id.length > 0 && result.call_id === call.call_id;
|
|
40
|
+
// 仅放宽已配对工具结果之后的 developer 边界,其他角色仍保留密文。
|
|
41
|
+
const following = input[i + 1];
|
|
42
|
+
const developerAfterTool = afterTool && isPlainObject(following) && following.role === "developer"
|
|
43
|
+
&& (following.type === undefined || following.type === "message");
|
|
44
|
+
if ((!isUser(result) && !afterTool) || (!isUser(following) && !developerAfterTool) || !isPlainObject(item)
|
|
45
|
+
|| item.type !== "reasoning" || !Array.isArray(item.summary) || item.summary.length
|
|
46
|
+
|| typeof item.encrypted_content !== "string" || !item.encrypted_content
|
|
47
|
+
|| (item.id !== undefined && referenced.has(item.id))
|
|
48
|
+
// Codex can explicitly serialize the absent content channel as null.
|
|
49
|
+
|| !Object.keys(item).every(key => ["type", "id", "status", "summary", "encrypted_content"].includes(key)
|
|
50
|
+
|| (key === "content" && item.content === null))) return item;
|
|
51
|
+
const { encrypted_content: _cipher, ...rest } = item;
|
|
52
|
+
changed = true;
|
|
53
|
+
return rest;
|
|
54
|
+
});
|
|
55
|
+
return changed ? { ...body, input: next } : body;
|
|
56
|
+
}
|
|
57
|
+
|
|
26
58
|
/**
|
|
27
59
|
* Provider-opaque replay metadata is client history, not an OpenAI input-item field (#7111).
|
|
28
60
|
* The caller gates this on OpenAI-operated destinations; arbitrary gateways may accept it.
|
|
@@ -10,12 +10,17 @@ import {
|
|
|
10
10
|
import { isPlainObject } from "./internal";
|
|
11
11
|
import { hasItemProvenance, isHistoricalItem } from "../../responses/item-provenance";
|
|
12
12
|
|
|
13
|
-
function normalizeFunctionToolSchema(tool: unknown, xaiTarget: boolean): unknown | undefined {
|
|
13
|
+
function normalizeFunctionToolSchema(tool: unknown, xaiTarget: boolean, chatDefaults: boolean): unknown | undefined {
|
|
14
14
|
if (!isPlainObject(tool) || tool.type !== "function") return tool;
|
|
15
15
|
// Runs for every Responses destination, forward auth included: the ChatGPT backend is where
|
|
16
16
|
// the `\p{…}` rejection was observed, and it reaches this function through the same seam.
|
|
17
17
|
const compatible = stripUnicodePropertyPatterns(tool);
|
|
18
|
-
const
|
|
18
|
+
const compatibleTool = isPlainObject(compatible) ? compatible : tool;
|
|
19
|
+
// Chat defaults to non-strict; OpenAI Responses otherwise normalizes an omitted flag to
|
|
20
|
+
// strict, making optional alternatives (such as pointer index vs coordinates) required.
|
|
21
|
+
const source = chatDefaults && compatibleTool.strict === undefined
|
|
22
|
+
? { ...compatibleTool, strict: false }
|
|
23
|
+
: compatibleTool;
|
|
19
24
|
if (xaiTarget) {
|
|
20
25
|
const parameters = normalizeXaiToolParameters(isPlainObject(source.parameters) ? source.parameters : {});
|
|
21
26
|
return parameters === undefined ? undefined : { ...source, parameters };
|
|
@@ -73,7 +78,7 @@ function reconcileToolChoiceForOmittedTools(
|
|
|
73
78
|
return body;
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
export function normalizeToolSchemas(body: unknown, xaiTarget: boolean): unknown {
|
|
81
|
+
export function normalizeToolSchemas(body: unknown, xaiTarget: boolean, chatDefaults = false): unknown {
|
|
77
82
|
if (!isPlainObject(body)) return body;
|
|
78
83
|
|
|
79
84
|
const omittedFunctionNames = new Set<string>();
|
|
@@ -81,7 +86,7 @@ export function normalizeToolSchemas(body: unknown, xaiTarget: boolean): unknown
|
|
|
81
86
|
let changed = false;
|
|
82
87
|
const normalized: unknown[] = [];
|
|
83
88
|
for (const tool of tools) {
|
|
84
|
-
const fixed = normalizeFunctionToolSchema(tool, xaiTarget);
|
|
89
|
+
const fixed = normalizeFunctionToolSchema(tool, xaiTarget, chatDefaults);
|
|
85
90
|
if (fixed === undefined) {
|
|
86
91
|
changed = true;
|
|
87
92
|
if (isPlainObject(tool) && typeof tool.name === "string") omittedFunctionNames.add(tool.name);
|
package/src/chat/inbound.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function assertChatCompletionsRoutingBody(raw: unknown): asserts raw is C
|
|
|
34
34
|
// Pi's "off" thinking level onto it (src/clients/config-export.ts). Dropping it here let a
|
|
35
35
|
// provider default re-enable thinking the caller had explicitly turned off — and for the
|
|
36
36
|
// Anthropic families that think by default, omission is not the same as disabled.
|
|
37
|
-
const OUTPUT_CONFIG_EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
37
|
+
export const OUTPUT_CONFIG_EFFORTS: ReadonlySet<string> = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max", "ultra"]);
|
|
38
38
|
const OUTPUT_CONFIG_SUMMARIES = new Set(["auto", "concise", "detailed", "none"]);
|
|
39
39
|
|
|
40
40
|
export function contentToText(content: unknown): string {
|
|
@@ -14,6 +14,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
14
14
|
import { homedir } from "node:os";
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import { spawnSync } from "node:child_process";
|
|
17
|
+
import { CLAUDE_KEYCHAIN_SERVICE, claudeKeychainReader, isSyncTimeout, type ClaudeKeychainReader } from "../oauth/claude-keychain-read";
|
|
17
18
|
|
|
18
19
|
export type AuthPresence = "present" | "absent" | "unknown";
|
|
19
20
|
|
|
@@ -34,11 +35,33 @@ export type AuthSourceId =
|
|
|
34
35
|
*/
|
|
35
36
|
export const PROXY_MARKER = "opencodex-proxy";
|
|
36
37
|
|
|
37
|
-
const KEYCHAIN_SERVICE =
|
|
38
|
+
const KEYCHAIN_SERVICE = CLAUDE_KEYCHAIN_SERVICE;
|
|
38
39
|
/** `security` exit code for "the item does not exist" — a real absent, not a failure. */
|
|
39
40
|
const KEYCHAIN_ITEM_NOT_FOUND = 44;
|
|
40
41
|
const KEYCHAIN_TIMEOUT_MS = 1_500;
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The metadata probe under the Keychain reader's admission (#8161). Its synchronous timeout still
|
|
45
|
+
* signals the child, so it does not spawn while a read is blocked or the backoff is active, and its
|
|
46
|
+
* own timeout starts that backoff: a locked keychain sees at most one such kill per window.
|
|
47
|
+
*/
|
|
48
|
+
export function probeClaudeKeychain(
|
|
49
|
+
platform: string,
|
|
50
|
+
reader: Pick<ClaudeKeychainReader, "syncReadBlocked" | "noteSyncTimeout">,
|
|
51
|
+
run: () => { status: number | null; signal: string | null; error?: Error },
|
|
52
|
+
): AuthPresence {
|
|
53
|
+
if (platform !== "darwin") return "absent";
|
|
54
|
+
if (reader.syncReadBlocked()) return "unknown";
|
|
55
|
+
const result = run();
|
|
56
|
+
if (result.error || result.signal !== null) {
|
|
57
|
+
if (isSyncTimeout(result.error ?? { signal: result.signal })) reader.noteSyncTimeout();
|
|
58
|
+
return "unknown";
|
|
59
|
+
}
|
|
60
|
+
if (result.status === 0) return "present";
|
|
61
|
+
if (result.status === KEYCHAIN_ITEM_NOT_FOUND) return "absent";
|
|
62
|
+
return "unknown";
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
export interface AuthSourceResult {
|
|
43
66
|
source: AuthSourceId;
|
|
44
67
|
presence: AuthPresence;
|
|
@@ -204,15 +227,10 @@ export function defaultAuthDetectDeps(
|
|
|
204
227
|
return existsSync(join(configDir, ".credentials.json"));
|
|
205
228
|
},
|
|
206
229
|
keychainProbe() {
|
|
207
|
-
|
|
208
|
-
const result = spawnSync("security", ["find-generic-password", "-s", KEYCHAIN_SERVICE], {
|
|
230
|
+
return probeClaudeKeychain(process.platform, claudeKeychainReader, () => spawnSync("security", ["find-generic-password", "-s", KEYCHAIN_SERVICE], {
|
|
209
231
|
timeout: KEYCHAIN_TIMEOUT_MS,
|
|
210
232
|
stdio: ["ignore", "ignore", "ignore"],
|
|
211
|
-
});
|
|
212
|
-
if (result.error || result.signal !== null) return "unknown";
|
|
213
|
-
if (result.status === 0) return "present";
|
|
214
|
-
if (result.status === KEYCHAIN_ITEM_NOT_FOUND) return "absent";
|
|
215
|
-
return "unknown";
|
|
233
|
+
}));
|
|
216
234
|
},
|
|
217
235
|
env: () => env,
|
|
218
236
|
ownTokens,
|
|
@@ -53,14 +53,17 @@ export function systemCachePrefix(system: unknown): string | undefined {
|
|
|
53
53
|
return last >= 0 && last < system.length - 1 ? systemToInstructions(system.slice(0, last + 1)) : undefined;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function isRestrictedSearch(raw: unknown): boolean {
|
|
57
|
+
return isRec(raw) && typeof raw.type === "string" && raw.type.startsWith("web_search")
|
|
58
|
+
&& ["allowed_domains", "blocked_domains", "user_location"].some(key => Object.hasOwn(raw, key));
|
|
59
|
+
}
|
|
60
|
+
|
|
56
61
|
export function toolsToResponses(tools: unknown): Rec[] | undefined {
|
|
57
62
|
if (!Array.isArray(tools) || tools.length === 0) return undefined;
|
|
58
63
|
// The shared hosted-search lane cannot enforce these constraints on every destination or
|
|
59
64
|
// sidecar backend. Omit search rather than broaden it; a duplicate declaration cannot opt out.
|
|
60
65
|
// Typed originals still travel separately to an Anthropic destination.
|
|
61
|
-
const restrictedSearch = tools.some(
|
|
62
|
-
&& raw.type.startsWith("web_search")
|
|
63
|
-
&& ["allowed_domains", "blocked_domains", "user_location"].some(key => Object.hasOwn(raw, key)));
|
|
66
|
+
const restrictedSearch = tools.some(isRestrictedSearch);
|
|
64
67
|
const out: Rec[] = [];
|
|
65
68
|
for (const raw of tools) {
|
|
66
69
|
if (!isRec(raw)) continue;
|
|
@@ -106,6 +109,18 @@ export function declaredAnthropicServerTools(raw: unknown): Rec[] | undefined {
|
|
|
106
109
|
return tools.length > 0 ? tools : undefined;
|
|
107
110
|
}
|
|
108
111
|
|
|
112
|
+
/** A declared tool the translated body drops and no out-of-body lane carries (bash_*, text_editor_*, ...). */
|
|
113
|
+
export function hasNativeOnlyTool(raw: Rec): boolean {
|
|
114
|
+
return Array.isArray(raw.tools)
|
|
115
|
+
&& raw.tools.some(tool => !toolsToResponses([tool]) && !declaredAnthropicServerTools({ tools: [tool] }));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A declared web_fetch or restricted web_search: only the out-of-body lane to first-party Anthropic carries it. */
|
|
119
|
+
export function hasAnthropicOnlyServerTool(raw: Rec): boolean {
|
|
120
|
+
return Array.isArray(raw.tools) && raw.tools.some(tool => isRestrictedSearch(tool)
|
|
121
|
+
|| (isRec(tool) && typeof tool.type === "string" && tool.type.startsWith("web_fetch_")));
|
|
122
|
+
}
|
|
123
|
+
|
|
109
124
|
/** Validate original call/result order without inventing inputs or pairing a later call backwards. */
|
|
110
125
|
function replayableServerRun(run: readonly Rec[]): boolean {
|
|
111
126
|
const pending = new Map<string, Rec>();
|
package/src/claude/inbound.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { CLAUDE_CONTEXT_OVERFLOW_MESSAGE, markProxyError } from "../lib/client-e
|
|
|
13
13
|
*/
|
|
14
14
|
import type { OcxClaudeCodeConfig } from "../types";
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
16
|
+
import { claudeSessionUserId } from "../server/request-log-conversation";
|
|
16
17
|
|
|
17
18
|
export { AnthropicRequestError, DesktopModelMappingUnavailableError } from "./inbound-records";
|
|
18
19
|
export { resolveInboundModel, effortForThinkingBudget, effortFromOutputConfig, extractOcxRouteDirective, extractOcxEffortDirective } from "./inbound-model-options";
|
|
@@ -598,8 +599,10 @@ function applyAnthropicSettings(
|
|
|
598
599
|
// their session id; without it consecutive /v1/messages turns reported
|
|
599
600
|
// cached_tokens: 0 on the ChatGPT backend — devlog 090). Claude Code's
|
|
600
601
|
// metadata.user_id embeds the session uuid, so hashing it yields a stable
|
|
601
|
-
// per-session key with a bounded length/charset.
|
|
602
|
-
|
|
602
|
+
// per-session key with a bounded length/charset. Remote Claude Code adds a per-turn
|
|
603
|
+
// attribution token (`tk`) to that blob; it is dropped, as Claude Code itself drops it,
|
|
604
|
+
// so every turn of one session keeps one key.
|
|
605
|
+
body.prompt_cache_key = createHash("sha256").update(claudeSessionUserId(raw.metadata.user_id)).digest("hex").slice(0, 32);
|
|
603
606
|
cacheKeySource = "metadata";
|
|
604
607
|
} else if (typeof cacheSystem === "string" || cacheSystem.length > 0) {
|
|
605
608
|
// Claude Desktop sends no metadata.user_id (H1, devlog 130): without any key the
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ocx doctor` check for a package install whose bundled Bun dependency never finished
|
|
3
|
+
* installing (#8361).
|
|
4
|
+
*
|
|
5
|
+
* npm 12 blocks dependency lifecycle scripts by default. The `bun` npm package downloads nothing
|
|
6
|
+
* in its tarball: its postinstall copies the selected `@oven/bun-*` executable into `bin/`. An
|
|
7
|
+
* install that skipped that script succeeds and leaves a ~450-byte placeholder, so the launcher
|
|
8
|
+
* fails later with "the `bun` dependency is not installed". Doctor is where an operator looks
|
|
9
|
+
* after that failure, so it names the state and the exact command that repairs it.
|
|
10
|
+
*
|
|
11
|
+
* The check is observe-only and never fails the doctor run: a leftover PATH Bun or an explicit
|
|
12
|
+
* `OPENCODEX_BUN_PATH` can still be serving requests, which makes this a degraded install rather
|
|
13
|
+
* than an unusable surface.
|
|
14
|
+
*/
|
|
15
|
+
import { dirname, resolve } from "node:path";
|
|
16
|
+
import { fileURLToPath } from "node:url";
|
|
17
|
+
import * as bunRuntime from "../lib/bun-runtime";
|
|
18
|
+
import * as installDetection from "../update/install-detection.mjs";
|
|
19
|
+
|
|
20
|
+
const PACKAGE_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
21
|
+
|
|
22
|
+
export const BUNDLED_BUN_MISSING_DETAIL = "the `bun` dependency is not installed";
|
|
23
|
+
export const NPM_BUN_REPAIR_COMMAND = "npm install -g --allow-scripts=bun @bitkyc08/opencodex";
|
|
24
|
+
|
|
25
|
+
type PackageInstaller = "npm" | "pnpm" | "bun" | "mise";
|
|
26
|
+
|
|
27
|
+
export type BundledBunDiagnostic =
|
|
28
|
+
| { status: "ready"; path: string }
|
|
29
|
+
| { status: "not-applicable" }
|
|
30
|
+
| { status: "missing"; installer: PackageInstaller; lines: string[] };
|
|
31
|
+
|
|
32
|
+
export interface BundledBunDiagnosticDeps {
|
|
33
|
+
platform?: NodeJS.Platform;
|
|
34
|
+
bundledPath?: () => string | null;
|
|
35
|
+
detectOwnership?: () => { installer: string; owner?: { tool: string } | null };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The command that reinstalls this package while allowing bun's postinstall. */
|
|
39
|
+
export function bundledBunRepairCommand(installer: PackageInstaller, tool?: string | null): string | null {
|
|
40
|
+
if (installer === "npm") return NPM_BUN_REPAIR_COMMAND;
|
|
41
|
+
if (installer === "pnpm") return "pnpm add -g --allow-build=bun @bitkyc08/opencodex";
|
|
42
|
+
if (installer === "bun") return "bun add -g @bitkyc08/opencodex";
|
|
43
|
+
return tool ? `mise upgrade ${tool}` : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function collectBundledBunDiagnostic(deps: BundledBunDiagnosticDeps = {}): BundledBunDiagnostic {
|
|
47
|
+
const bundled = (deps.bundledPath ?? bunRuntime.bundledBunPath)();
|
|
48
|
+
if (bundled) return { status: "ready", path: bundled };
|
|
49
|
+
|
|
50
|
+
const ownership = (deps.detectOwnership
|
|
51
|
+
?? (() => installDetection.detectInstallOwnershipFromPath(PACKAGE_ROOT)))();
|
|
52
|
+
const installer = ownership.installer;
|
|
53
|
+
// Only the mise verdict carries an owner; the others have no tool to name.
|
|
54
|
+
const ownerTool = "owner" in ownership ? ownership.owner?.tool ?? null : null;
|
|
55
|
+
// A source checkout has no bundled dependency by design, and a standalone binary carries its
|
|
56
|
+
// own runtime; neither is a skipped-postinstall symptom.
|
|
57
|
+
if (installer !== "npm" && installer !== "pnpm" && installer !== "bun" && installer !== "mise") {
|
|
58
|
+
return { status: "not-applicable" };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const repair = bundledBunRepairCommand(installer, ownerTool);
|
|
62
|
+
const windows = (deps.platform ?? process.platform) === "win32";
|
|
63
|
+
const lines = [
|
|
64
|
+
` !! ${BUNDLED_BUN_MISSING_DETAIL} (its postinstall was skipped or the dependency is incomplete)`,
|
|
65
|
+
" Allow bun's own install script; npm 12 blocks lifecycle scripts by default,",
|
|
66
|
+
" and --ignore-scripts or ignore-scripts=true in an npmrc blocks it on any npm",
|
|
67
|
+
];
|
|
68
|
+
if (!repair) {
|
|
69
|
+
lines.push(" This mise-owned installation has no verified tool name; upgrade it through mise.");
|
|
70
|
+
return { status: "missing", installer, lines };
|
|
71
|
+
}
|
|
72
|
+
if (windows && installer === "npm") {
|
|
73
|
+
// A running bun.exe holds node_modules/bun/bin open, so npm fails with EBUSY. The instruction
|
|
74
|
+
// has to stop first; `ocx update` does this itself, but a manual reinstall does not.
|
|
75
|
+
lines.push(" Stop the proxy first so Windows releases node_modules/bun/bin, then run:");
|
|
76
|
+
lines.push(" ocx stop");
|
|
77
|
+
lines.push(` ${repair}`);
|
|
78
|
+
lines.push(" Restart afterwards: ocx service restart (or ocx start when unmanaged)");
|
|
79
|
+
} else {
|
|
80
|
+
lines.push(" Fix: reinstall with the package manager that owns this install:");
|
|
81
|
+
lines.push(` ${repair}`);
|
|
82
|
+
}
|
|
83
|
+
return { status: "missing", installer, lines };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Render the doctor "Bundled Bun runtime" section lines. */
|
|
87
|
+
export function formatBundledBunDiagnosticLines(diagnostic: BundledBunDiagnostic): string[] {
|
|
88
|
+
if (diagnostic.status === "ready") return [` ok ready: ${diagnostic.path}`];
|
|
89
|
+
if (diagnostic.status === "not-applicable") return [];
|
|
90
|
+
return diagnostic.lines;
|
|
91
|
+
}
|
|
@@ -395,10 +395,10 @@ export const AGENT_ROUTING_CAPABILITIES: readonly Capability[] = [
|
|
|
395
395
|
},
|
|
396
396
|
{
|
|
397
397
|
command: ["combo","set"],
|
|
398
|
-
usage: "ocx combo set <id> [--targets <provider/model[:weight],...> | --targets-file <FILE|->] [--strategy <failover|round-robin|random|least-used|reset-window|jev>] [--sticky <1-100|->] [--cooldown-reprobe <on|off>] [--cooldown-reprobe-interval <ms>] [--effort <low|medium|high|xhigh|max|ultra|->] [--effort-mode <fallback|force|->] [--alias <name|->] [--native-alias [on|off]] [--allow-metered-targets <on|off>] [--display-name <label|->] [--description <text|->] [--decision-provider <provider|-> | --decision-model <route|->] [--decision-timeout <ms|->] [--decision-quota-signals <on|off|->] [--decision-quota-tiers <JSON|->] [--session-pin <duration|->] [--rename-from <id>] [--image-input <auto|disabled>] [--reasoning-effort-mode <strict|adaptive>] [--json]",
|
|
398
|
+
usage: "ocx combo set <id> [--targets <provider/model[:weight],...> | --targets-file <FILE|->] [--strategy <failover|round-robin|random|least-used|reset-window|jev>] [--sticky <1-100|->] [--cooldown-reprobe <on|off>] [--cooldown-reprobe-interval <ms>] [--effort <low|medium|high|xhigh|max|ultra|->] [--effort-mode <fallback|force|->] [--alias <name|->] [--native-alias [on|off]] [--allow-metered-targets <on|off>] [--display-name <label|->] [--description <text|->] [--decision-provider <provider|-> | --decision-model <route|->] [--decision-timeout <ms|->] [--decision-quota-signals <on|off|->] [--decision-quota-tiers <JSON|->] [--session-pin <duration|->] [--rename-from <id>] [--image-input <auto|disabled>] [--reasoning-effort-mode <strict|adaptive>] [--jev-effort-mode <decide|client>] [--json]",
|
|
399
399
|
summary: "Create, update or rename a combo.",
|
|
400
400
|
routes: [{"method":"GET","path":"/api/combos"},{"method":"PUT","path":"/api/combos"}],
|
|
401
|
-
flags: [{"name":"--allow-metered-targets","value":"string","summary":"on grants operator consent to metered targets only on a loopback-only proxy; off clears it."},{"name":"--targets","value":"string","summary":"Ordered provider/model[:weight] list; required for creation."},{"name":"--strategy","value":"string","summary":"Routing strategy."},{"name":"--sticky","value":"string","summary":"Round-robin limit 1-100; - resets."},{"name":"--cooldown-reprobe","value":"string","summary":"Opt into one recovery pass when all eligible targets cool; off by default."},{"name":"--cooldown-reprobe-interval","value":"string","summary":"Minimum interval between recovery passes in ms (1000..86400000); default 300000."},{"name":"--effort","value":"string","summary":"Default effort; - clears."},{"name":"--effort-mode","value":"string","summary":"fallback or force; - resets to fallback."},{"name":"--alias","value":"string","summary":"Alias; - clears."},{"name":"--display-name","value":"string","summary":"Label; - clears."},{"name":"--description","value":"string","summary":"Catalog row description; - clears."},{"name":"--decision-provider","value":"string","summary":"JEV provider; - clears."},{"name":"--decision-model","value":"string","summary":"JEV route; - clears; exclusive with provider."},{"name":"--decision-timeout","value":"string","summary":"JEV deadline 1000-120000 ms; - clears."},{"name":"--decision-quota-signals","value":"string","summary":"JEV advisory quota on/off; - clears."},{"name":"--decision-quota-tiers","value":"string","summary":"Partial JSON thresholds; - clears."},{"name":"--session-pin","value":"string","summary":"JEV session pin idle window 1m-24h (90s, 20m, 1h); - clears."},{"name":"--rename-from","value":"string","summary":"Existing combo ID to rename."},{"name":"--json","value":"boolean","summary":"Emit structured JSON."},{"name":"--native-alias","value":"string","summary":"Bare legacy flag means on; explicit on/off preserves presence, including false."},{"name":"--targets-file","value":"string","summary":"Bounded ordered target JSON array, exclusive with --targets; preserves effort/profile/last-resort metadata."},{"name":"--image-input","value":"string","summary":"auto or disabled; explicit auto clears the previous disabled choice."},{"name":"--reasoning-effort-mode","value":"string","summary":"strict or adaptive, distinct from --effort-mode fallback/force."}],
|
|
401
|
+
flags: [{"name":"--allow-metered-targets","value":"string","summary":"on grants operator consent to metered targets only on a loopback-only proxy; off clears it."},{"name":"--targets","value":"string","summary":"Ordered provider/model[:weight] list; required for creation."},{"name":"--strategy","value":"string","summary":"Routing strategy."},{"name":"--sticky","value":"string","summary":"Round-robin limit 1-100; - resets."},{"name":"--cooldown-reprobe","value":"string","summary":"Opt into one recovery pass when all eligible targets cool; off by default."},{"name":"--cooldown-reprobe-interval","value":"string","summary":"Minimum interval between recovery passes in ms (1000..86400000); default 300000."},{"name":"--effort","value":"string","summary":"Default effort; - clears."},{"name":"--effort-mode","value":"string","summary":"fallback or force; - resets to fallback."},{"name":"--alias","value":"string","summary":"Alias; - clears."},{"name":"--display-name","value":"string","summary":"Label; - clears."},{"name":"--description","value":"string","summary":"Catalog row description; - clears."},{"name":"--decision-provider","value":"string","summary":"JEV provider; - clears."},{"name":"--decision-model","value":"string","summary":"JEV route; - clears; exclusive with provider."},{"name":"--decision-timeout","value":"string","summary":"JEV deadline 1000-120000 ms; - clears."},{"name":"--decision-quota-signals","value":"string","summary":"JEV advisory quota on/off; - clears."},{"name":"--decision-quota-tiers","value":"string","summary":"Partial JSON thresholds; - clears."},{"name":"--session-pin","value":"string","summary":"JEV session pin idle window 1m-24h (90s, 20m, 1h); - clears."},{"name":"--rename-from","value":"string","summary":"Existing combo ID to rename."},{"name":"--json","value":"boolean","summary":"Emit structured JSON."},{"name":"--native-alias","value":"string","summary":"Bare legacy flag means on; explicit on/off preserves presence, including false."},{"name":"--targets-file","value":"string","summary":"Bounded ordered target JSON array, exclusive with --targets; preserves effort/profile/last-resort metadata."},{"name":"--image-input","value":"string","summary":"auto or disabled; explicit auto clears the previous disabled choice."},{"name":"--reasoning-effort-mode","value":"string","summary":"strict or adaptive, distinct from --effort-mode fallback/force."},{"name":"--jev-effort-mode","value":"string","summary":"JEV wire-effort owner: decide (default) applies the decision effort; client keeps its target and leaves effort to combo policy."}],
|
|
402
402
|
mutates: true,
|
|
403
403
|
json: "payload",
|
|
404
404
|
details: ["create and update are aliases of set. Existing fields are read before writing; --targets replaces targets. Without --strategy an existing combo keeps its stored strategy and JEV policy; a new combo defaults to failover.","force overrides valid client effort and may increase cost and latency.","Only the implemented target grammar is supported; full GUI target metadata and routing-profile writes are separate tasks.","New file/flag conflicts refuse before transport. Partial edits preserve target metadata; explicit false/default values override server carry. Turning a native alias off may also require clearing its incompatible alias.","Read/merge/write uses one target and remains an upsert without revision CAS. Saved-but-incomplete catalog outcomes return nonzero with their receipt."],
|
|
@@ -729,4 +729,64 @@ export const OBSERVE_SYSTEM_CAPABILITIES: readonly Capability[] = [
|
|
|
729
729
|
json: "payload",
|
|
730
730
|
details: ["start/end are epoch seconds. The end must match the request-time bucket or its immediate successor after an observed rollover; stale windows are refused. Empty series still includes metadata; missingMeasurements and truncated remain visible instead of implying measured complete zero traffic.","Uses existing query validation and checks applied model/provider-exclusion scope. It does not change companion settings or request inference."],
|
|
731
731
|
},
|
|
732
|
+
{
|
|
733
|
+
command: ["telemetry", "status"],
|
|
734
|
+
usage: "ocx telemetry status [--json]",
|
|
735
|
+
summary: "Inspect anonymous telemetry consent status and the daily payload preview.",
|
|
736
|
+
routes: [{"method": "GET", "path": "/api/telemetry"}],
|
|
737
|
+
flags: [{"name": "--json", "value": "boolean", "summary": "Emit the telemetry status and preview as JSON."}],
|
|
738
|
+
mutates: false,
|
|
739
|
+
json: "payload",
|
|
740
|
+
details: ["Reads live status from the running proxy and falls back to local configuration and ledger preview when the proxy is stopped.", "Previews the oldest eligible unsent day, or the latest completed day with previewEligible = false when no day is eligible. Never creates or transmits a telemetry install identifier."],
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
command: ["telemetry", "enable"],
|
|
744
|
+
usage: "ocx telemetry enable [--json]",
|
|
745
|
+
summary: "Opt in to anonymous daily usage telemetry.",
|
|
746
|
+
routes: [],
|
|
747
|
+
flags: [{"name": "--json", "value": "boolean", "summary": "Emit the updated telemetry status as JSON."}],
|
|
748
|
+
mutates: true,
|
|
749
|
+
json: "envelope",
|
|
750
|
+
details: ["Requires an interactive human terminal, prints the telemetry disclosure block, and asks for confirmation before recording telemetry.decision = accepted.", "Refuses with agent_consent_required when agent-driven and with tty_required when non-interactive or running under OCX_SERVICE."],
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
command: ["telemetry", "disable"],
|
|
754
|
+
usage: "ocx telemetry disable [--json]",
|
|
755
|
+
summary: "Opt out of anonymous daily usage telemetry and delete the local telemetry identifier.",
|
|
756
|
+
routes: [],
|
|
757
|
+
flags: [{"name": "--json", "value": "boolean", "summary": "Emit the updated telemetry status as JSON."}],
|
|
758
|
+
mutates: true,
|
|
759
|
+
json: "envelope",
|
|
760
|
+
details: ["Writes telemetry.decision = declined in local config.json and removes telemetry-id.json.", "Always permitted, including in agent-driven sessions."],
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
command: ["telemetry", "profile", "status"],
|
|
764
|
+
usage: "ocx telemetry profile status [--json]",
|
|
765
|
+
summary: "Inspect the opt-in public leaderboard profile, its next submission preview and its ranks.",
|
|
766
|
+
routes: [{"method": "GET", "path": "/api/telemetry/profile"}, {"method": "GET", "path": "/api/telemetry/profile/rank"}],
|
|
767
|
+
flags: [{"name": "--json", "value": "boolean", "summary": "Emit the profile status, preview and ranks as JSON."}],
|
|
768
|
+
mutates: false,
|
|
769
|
+
json: "payload",
|
|
770
|
+
details: ["Reads live status from the running proxy and falls back to the local profile file when the proxy is stopped.", "Never prints the profile secret."],
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
command: ["telemetry", "profile", "connect"],
|
|
774
|
+
usage: "ocx telemetry profile connect --handle <handle> [--name <display name>] [--avatar <colour>] [--json]",
|
|
775
|
+
summary: "Create an opt-in public leaderboard profile.",
|
|
776
|
+
routes: [],
|
|
777
|
+
flags: [{"name": "--handle", "value": "string", "summary": "Public handle: 3 to 24 lowercase letters, digits or hyphens."}, {"name": "--name", "value": "string", "summary": "Public display name; defaults to the handle."}, {"name": "--avatar", "value": "string", "summary": "Avatar colour from the fixed palette; default blue."}, {"name": "--json", "value": "boolean", "summary": "Emit the connected profile as JSON."}],
|
|
778
|
+
mutates: true,
|
|
779
|
+
json: "envelope",
|
|
780
|
+
details: ["Requires an interactive human terminal and anonymous telemetry turned on, prints the public-profile disclosure, and asks for confirmation (default no).", "Refuses with agent_consent_required when agent-driven and with tty_required when non-interactive or running under OCX_SERVICE."],
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
command: ["telemetry", "profile", "disconnect"],
|
|
784
|
+
usage: "ocx telemetry profile disconnect [--json]",
|
|
785
|
+
summary: "Delete the public leaderboard profile and all its data on the server.",
|
|
786
|
+
routes: [{"method": "DELETE", "path": "/api/telemetry/profile"}],
|
|
787
|
+
flags: [{"name": "--json", "value": "boolean", "summary": "Emit the disconnect outcome as JSON."}],
|
|
788
|
+
mutates: true,
|
|
789
|
+
json: "envelope",
|
|
790
|
+
details: ["Always permitted, including in agent-driven sessions and while anonymous telemetry is off.", "Uses the running proxy when available and otherwise deletes directly; an unreachable telemetry service leaves the deletion pending for the proxy to retry."],
|
|
791
|
+
},
|
|
732
792
|
];
|
package/src/cli/combo-input.ts
CHANGED
|
@@ -7,6 +7,7 @@ type ComboInput = {
|
|
|
7
7
|
targets?: Array<Record<string, unknown>>;
|
|
8
8
|
imageInput?: "auto" | "disabled";
|
|
9
9
|
reasoningEffortMode?: "strict" | "adaptive";
|
|
10
|
+
jevEffortMode?: "decide" | "client";
|
|
10
11
|
nativeAlias?: boolean;
|
|
11
12
|
allowMeteredTargets?: boolean;
|
|
12
13
|
};
|
|
@@ -73,6 +74,7 @@ export async function prepareComboInput(args: string[], deps: RuntimeApiDeps = {
|
|
|
73
74
|
const file = takeOptionWithSyntax(args, "--targets-file")?.value;
|
|
74
75
|
const image = takeOptionWithSyntax(args, "--image-input")?.value;
|
|
75
76
|
const reasoning = takeOptionWithSyntax(args, "--reasoning-effort-mode")?.value;
|
|
77
|
+
const jevEffort = takeOptionWithSyntax(args, "--jev-effort-mode")?.value;
|
|
76
78
|
const nativeAlias = takeNativeAlias(args);
|
|
77
79
|
const metered = takeOptionWithSyntax(args, "--allow-metered-targets")?.value;
|
|
78
80
|
if (metered !== undefined && metered !== "on" && metered !== "off") {
|
|
@@ -87,10 +89,14 @@ export async function prepareComboInput(args: string[], deps: RuntimeApiDeps = {
|
|
|
87
89
|
if (reasoning !== undefined && reasoning !== "strict" && reasoning !== "adaptive") {
|
|
88
90
|
throw new CliUsageError("--reasoning-effort-mode must be strict or adaptive");
|
|
89
91
|
}
|
|
92
|
+
if (jevEffort !== undefined && jevEffort !== "decide" && jevEffort !== "client") {
|
|
93
|
+
throw new CliUsageError("--jev-effort-mode must be decide or client");
|
|
94
|
+
}
|
|
90
95
|
return {
|
|
91
96
|
...(file === undefined ? {} : { targets: parseComboTargets(await readJsonInput(file, deps)) }),
|
|
92
97
|
...(image === undefined ? {} : { imageInput: image }),
|
|
93
98
|
...(reasoning === undefined ? {} : { reasoningEffortMode: reasoning }),
|
|
99
|
+
...(jevEffort === undefined ? {} : { jevEffortMode: jevEffort }),
|
|
94
100
|
...(nativeAlias === undefined ? {} : { nativeAlias }),
|
|
95
101
|
...(metered === undefined ? {} : { allowMeteredTargets: metered === "on" }),
|
|
96
102
|
};
|
package/src/cli/combo-result.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { printCatalogResult } from "./catalog-command-result";
|
|
|
6
6
|
const ENUMS: Readonly<Record<string, readonly (string | null)[]>> = {
|
|
7
7
|
strategy: ["failover", "round-robin", "random", "least-used", "reset-window", "jev"],
|
|
8
8
|
defaultEffort: [null, "low", "medium", "high", "xhigh", "max", "ultra"],
|
|
9
|
-
defaultEffortMode: ["fallback", "force"], reasoningEffortMode: ["strict", "adaptive"],
|
|
9
|
+
defaultEffortMode: ["fallback", "force"], reasoningEffortMode: ["strict", "adaptive"], jevEffortMode: ["decide", "client"],
|
|
10
10
|
imageInput: ["auto", "disabled"], cooldownWaitPolicy: ["before-last-resort"],
|
|
11
11
|
};
|
|
12
12
|
const STRINGS = new Set(["alias", "displayName", "description", "decisionProvider", "decisionModel"]);
|