@bitkyc08/opencodex 2.99.0 → 2.100.1
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-g3Cm2xhZ.js +59 -0
- package/gui/dist/assets/Tray-BMDkAiXy.js +1 -0
- package/gui/dist/assets/brand-mark-nr3ziR-T.js +1 -0
- package/gui/dist/assets/index-Bziu8gTy.css +2 -0
- package/gui/dist/assets/index-OYzhQUNP.js +94 -0
- package/gui/dist/assets/{segment-thumb-features-fYEMxBaW.js → segment-thumb-features-DKCVUUTi.js} +1 -1
- package/gui/dist/classic/assets/App-CgPBKUP-.js +58 -0
- package/gui/dist/classic/assets/{Tray-BqZueZOx.js → Tray-BedmOsE7.js} +1 -1
- package/gui/dist/classic/assets/index-BR-HhNrp.js +94 -0
- package/gui/dist/classic/assets/quota-summary-CXKhvSmQ.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-image-normalize.ts +1 -1
- 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/client-fingerprint.ts +1 -1
- 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-chat/mistral-image-limit.ts +28 -15
- package/src/adapters/openai-chat-images.ts +100 -0
- package/src/adapters/openai-chat.ts +6 -9
- 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 +422 -170
- 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 +56 -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/anthropic-model-quota.ts +12 -0
- package/src/oauth/anthropic-routing.ts +11 -4
- package/src/oauth/claude-keychain-read.ts +165 -0
- package/src/oauth/kiro-iam-identity-center.ts +4 -1
- 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-identity.ts +9 -3
- package/src/providers/claude-cli-usage-state.ts +93 -0
- package/src/providers/claude-cli-usage.ts +3 -2
- 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/anthropic-family-headers.ts +8 -1
- package/src/providers/quota/anthropic-usage-windows.ts +49 -2
- 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-types.ts +7 -0
- package/src/providers/quota.ts +25 -18
- package/src/providers/registry/entries-core.ts +7 -4
- package/src/providers/registry/entries-extended.ts +42 -8
- package/src/providers/registry/model-ids.ts +1 -0
- package/src/providers/registry/model-seeds.ts +10 -2
- package/src/providers/registry/types.ts +6 -0
- 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/responses/retained-compaction.ts +31 -5
- 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/compact.ts +13 -1
- 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 +265 -38
- package/gui/dist/assets/App-BepstgEN.js +0 -59
- package/gui/dist/assets/Tray-BinxbEZo.js +0 -1
- package/gui/dist/assets/brand-mark-wzPe3R-J.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
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { createInterface } from "node:readline/promises";
|
|
2
|
+
import { plantUnavailableGuidance } from "../link/child-binary-source";
|
|
2
3
|
import { assertSshAlias } from "../link/ssh-argv";
|
|
3
|
-
import { CliUsageError, RuntimeApiError, runtimeBaseUrl, rejectArgs, takeJsonFlag, takeOption, printData } from "./runtime-api";
|
|
4
|
+
import { CliUsageError, RuntimeApiError, runtimeBaseUrl, rejectArgs, takeFlag, takeJsonFlag, takeOption, printData } from "./runtime-api";
|
|
4
5
|
import type { LinkCliDeps } from "./link";
|
|
5
6
|
|
|
6
7
|
const FINGERPRINT = /^SHA256:[A-Za-z0-9+/]{16,88}={0,2}$/;
|
|
8
|
+
const SEMVER = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]{1,128})?$/;
|
|
7
9
|
const ENROLLMENT_DEADLINE_MS = 360_000;
|
|
8
10
|
const PHASES: Record<string, string> = {
|
|
9
11
|
remote_port_failed: "remote port selection", remote_port_timeout: "remote port selection",
|
|
12
|
+
remote_plant_failed: "remote ocx-child planting", remote_plant_timeout: "remote ocx-child planting",
|
|
13
|
+
remote_plant_unavailable: "local ocx-child binary resolution",
|
|
10
14
|
child_preflight_failed: "Child preflight", child_preflight_timeout: "Child preflight",
|
|
15
|
+
child_port_busy: "Child port availability preflight",
|
|
16
|
+
child_external_provider_conflict: "Child Codex config ownership check",
|
|
11
17
|
child_restart_unsupported: "Child restart preflight", child_curl_missing: "Child curl preflight",
|
|
12
18
|
home_setup_failed: "Home setup", home_setup_timeout: "Home setup",
|
|
13
19
|
remote_connect_failed: "Child enrollment", remote_connect_timeout: "Child enrollment",
|
|
@@ -16,28 +22,110 @@ const PHASES: Record<string, string> = {
|
|
|
16
22
|
child_runtime_not_client: "Child runtime role verification",
|
|
17
23
|
remote_platform_unsupported: "remote platform verification", remote_ocx_missing: "remote OpenCodex discovery",
|
|
18
24
|
};
|
|
19
|
-
const
|
|
25
|
+
const RECOVERY_FULL = "Run ocx disconnect and ocx restart on the Child before retrying.";
|
|
26
|
+
const RECOVERY_EPHEMERAL = "Run ~/.cache/opencodex/bin/ocx-child detach on the Child before retrying.";
|
|
20
27
|
type LinkRequest = <T>(path: string, init: RequestInit, deps: LinkCliDeps) => Promise<T>;
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
interface ParsedProbeOffer {
|
|
30
|
+
alias: string;
|
|
31
|
+
fingerprint: string;
|
|
32
|
+
keyType: string;
|
|
33
|
+
ocxVersion: string | null;
|
|
34
|
+
runtimeKind?: "full" | "ephemeral" | "missing";
|
|
35
|
+
targetTriple?: string | null;
|
|
36
|
+
plantable?: boolean;
|
|
37
|
+
binarySizeBytes?: number;
|
|
38
|
+
plantUnavailableReason?: string;
|
|
39
|
+
legacyExact: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function record(value: unknown): value is Record<string, unknown> {
|
|
43
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const PROBE_ALLOWED_KEYS = new Set([
|
|
47
|
+
"alias", "fingerprint", "keyType", "ocxVersion",
|
|
48
|
+
"runtimeKind", "targetTriple", "plantable", "binarySizeBytes", "plantUnavailableReason",
|
|
49
|
+
]);
|
|
50
|
+
const CONFIRM_ALLOWED_KEYS = new Set([
|
|
51
|
+
"alias", "fingerprint", "ocxVersion",
|
|
52
|
+
"runtimeKind", "targetTriple", "plantable", "binarySizeBytes", "plantUnavailableReason",
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
function parseOffered(value: unknown, allowMissing: boolean): ParsedProbeOffer {
|
|
56
|
+
if (!record(value)) throw new Error("Invalid host probe response");
|
|
57
|
+
const keys = Object.keys(value);
|
|
58
|
+
if (keys.some(k => !PROBE_ALLOWED_KEYS.has(k))) throw new Error("Invalid host probe response");
|
|
59
|
+
if (typeof value.alias !== "string" || typeof value.fingerprint !== "string" || !FINGERPRINT.test(value.fingerprint)
|
|
60
|
+
|| typeof value.keyType !== "string" || !/^[A-Za-z0-9@._+-]{1,64}$/.test(value.keyType)) {
|
|
61
|
+
throw new Error("Invalid host probe response");
|
|
62
|
+
}
|
|
63
|
+
const legacyExact = keys.slice().sort().join(",") === "alias,fingerprint,keyType,ocxVersion";
|
|
64
|
+
if (!allowMissing && !legacyExact) throw new Error("Invalid host probe response");
|
|
65
|
+
if (value.ocxVersion === null) {
|
|
66
|
+
if (!allowMissing || value.runtimeKind !== "missing") throw new Error("Invalid host version response");
|
|
67
|
+
} else if (typeof value.ocxVersion !== "string" || !SEMVER.test(value.ocxVersion)) {
|
|
68
|
+
throw new Error("Invalid host version response");
|
|
69
|
+
}
|
|
70
|
+
if (value.runtimeKind !== undefined && value.runtimeKind !== "full" && value.runtimeKind !== "ephemeral" && value.runtimeKind !== "missing") {
|
|
71
|
+
throw new Error("Invalid host probe response");
|
|
72
|
+
}
|
|
73
|
+
if (value.targetTriple !== undefined && value.targetTriple !== null && (typeof value.targetTriple !== "string" || value.targetTriple.length > 64)) {
|
|
74
|
+
throw new Error("Invalid host probe response");
|
|
75
|
+
}
|
|
76
|
+
if (value.plantable !== undefined && typeof value.plantable !== "boolean") throw new Error("Invalid host probe response");
|
|
77
|
+
if (value.binarySizeBytes !== undefined && (typeof value.binarySizeBytes !== "number" || !Number.isSafeInteger(value.binarySizeBytes) || value.binarySizeBytes <= 0)) {
|
|
78
|
+
throw new Error("Invalid host probe response");
|
|
79
|
+
}
|
|
80
|
+
if (value.plantUnavailableReason !== undefined && typeof value.plantUnavailableReason !== "string") {
|
|
81
|
+
throw new Error("Invalid host probe response");
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
alias: value.alias,
|
|
85
|
+
fingerprint: value.fingerprint,
|
|
86
|
+
keyType: value.keyType,
|
|
87
|
+
ocxVersion: value.ocxVersion,
|
|
88
|
+
...(value.runtimeKind !== undefined ? { runtimeKind: value.runtimeKind } : {}),
|
|
89
|
+
...(value.targetTriple !== undefined ? { targetTriple: value.targetTriple } : {}),
|
|
90
|
+
...(value.plantable !== undefined ? { plantable: value.plantable } : {}),
|
|
91
|
+
...(value.binarySizeBytes !== undefined ? { binarySizeBytes: value.binarySizeBytes } : {}),
|
|
92
|
+
...(value.plantUnavailableReason !== undefined ? { plantUnavailableReason: value.plantUnavailableReason } : {}),
|
|
93
|
+
legacyExact,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function validateConfirmed(value: unknown, alias: string, fingerprint: string, allowMissing: boolean): void {
|
|
98
|
+
if (!record(value)) throw new Error("Invalid host confirmation response");
|
|
99
|
+
const keys = Object.keys(value);
|
|
100
|
+
if (keys.some(k => !CONFIRM_ALLOWED_KEYS.has(k))) throw new Error("Invalid host confirmation response");
|
|
101
|
+
if (value.alias !== alias || value.fingerprint !== fingerprint) throw new Error("Invalid host confirmation response");
|
|
102
|
+
const legacyExact = keys.slice().sort().join(",") === "alias,fingerprint,ocxVersion";
|
|
103
|
+
if (!allowMissing && !legacyExact) throw new Error("Invalid host confirmation response");
|
|
104
|
+
if (value.ocxVersion === null) {
|
|
105
|
+
if (!allowMissing || value.runtimeKind !== "missing") throw new Error("Invalid host confirmation response");
|
|
106
|
+
} else if (typeof value.ocxVersion !== "string" || !SEMVER.test(value.ocxVersion)) {
|
|
107
|
+
throw new Error("Invalid host confirmation response");
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function formatSizeMb(bytes?: number): string {
|
|
112
|
+
if (!bytes || !Number.isFinite(bytes) || bytes <= 0) return "~0.9 MB";
|
|
113
|
+
return `~${Math.max(0.1, bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
29
114
|
}
|
|
30
115
|
|
|
31
116
|
export async function runLinkEnrollment(command: "probe" | "add", args: string[], deps: LinkCliDeps, request: LinkRequest, usage: string): Promise<void> {
|
|
32
117
|
const wantsJson = takeJsonFlag(args);
|
|
118
|
+
const plantFlag = takeFlag(args, "--plant");
|
|
33
119
|
const expected = takeOption(args, "--expect-fingerprint");
|
|
34
120
|
const alias = args.shift();
|
|
35
121
|
if (!alias) throw new CliUsageError(command + " requires an SSH alias", usage);
|
|
36
122
|
try { assertSshAlias(alias); } catch { throw new CliUsageError("Invalid SSH alias", usage); }
|
|
37
123
|
rejectArgs(args, usage);
|
|
38
124
|
if (command === "probe" && expected !== undefined) throw new CliUsageError("--expect-fingerprint is only for link add", usage);
|
|
125
|
+
if (command === "probe" && plantFlag) throw new CliUsageError("--plant is only for link add", usage);
|
|
39
126
|
if (expected !== undefined && !FINGERPRINT.test(expected)) throw new CliUsageError("Expected a SHA256 SSH fingerprint", usage);
|
|
40
|
-
|
|
127
|
+
const isTTY = Boolean((deps.stdinImpl ?? process.stdin).isTTY);
|
|
128
|
+
if (command === "add" && !expected && !isTTY) {
|
|
41
129
|
throw new CliUsageError("Non-interactive link add requires --expect-fingerprint", usage);
|
|
42
130
|
}
|
|
43
131
|
const timeout = deps.enrollmentTimeoutMs ?? ENROLLMENT_DEADLINE_MS;
|
|
@@ -48,6 +136,7 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
|
|
|
48
136
|
timer = setTimeout(() => { controller.abort(); reject(new Error("Link enrollment timed out; its outcome is uncertain. Run ocx link status on the Home and ocx connect status on the Child before retrying.")); }, timeout);
|
|
49
137
|
});
|
|
50
138
|
let boundDeps = deps;
|
|
139
|
+
let ephemeralFlow = false;
|
|
51
140
|
const post = async <T>(path: string, body: unknown): Promise<T> => {
|
|
52
141
|
controller.signal.throwIfAborted();
|
|
53
142
|
const result = await request<T>(path, { method: "POST", redirect: "error", signal: controller.signal, headers: { "content-type": "application/json" }, body: JSON.stringify(body) }, boundDeps);
|
|
@@ -55,38 +144,75 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
|
|
|
55
144
|
return result;
|
|
56
145
|
};
|
|
57
146
|
let rl: ReturnType<typeof createInterface> | undefined;
|
|
147
|
+
const askYes = async (promptText: string): Promise<boolean> => {
|
|
148
|
+
rl ??= createInterface({ input: deps.stdinImpl ?? process.stdin, output: process.stderr });
|
|
149
|
+
return (await rl.question(promptText, { signal: controller.signal })).trim() === "yes";
|
|
150
|
+
};
|
|
58
151
|
const work = async () => {
|
|
59
152
|
boundDeps = { ...deps, baseUrl: await runtimeBaseUrl(deps) };
|
|
60
153
|
controller.signal.throwIfAborted();
|
|
61
|
-
const
|
|
154
|
+
const probeReq = command === "add" ? { alias, includeVersion: true, allowMissing: true } : { alias, includeVersion: true };
|
|
155
|
+
const probe = parseOffered(await post<unknown>("/api/link/probe", probeReq), command === "add");
|
|
62
156
|
if (probe.alias !== alias) throw new Error("Host probe alias did not match");
|
|
63
|
-
if (command === "probe") {
|
|
157
|
+
if (command === "probe") {
|
|
158
|
+
const payload = { alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: probe.ocxVersion! };
|
|
159
|
+
printData(payload, wantsJson, [probe.alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion]);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
64
162
|
if (expected && expected !== probe.fingerprint) throw new CliUsageError("The offered host fingerprint does not match --expect-fingerprint");
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
163
|
+
let shouldPlant = false;
|
|
164
|
+
ephemeralFlow = probe.runtimeKind === "ephemeral" || probe.runtimeKind === "missing";
|
|
165
|
+
if (probe.runtimeKind === "missing") {
|
|
166
|
+
if (probe.plantable !== true) {
|
|
167
|
+
throw new Error("ocx was not found on " + alias + ". " + plantUnavailableGuidance(probe.plantUnavailableReason, probe.targetTriple ?? null));
|
|
168
|
+
}
|
|
169
|
+
if (!isTTY && !plantFlag) {
|
|
170
|
+
throw new CliUsageError("Remote host has no OpenCodex runtime; pass --plant alongside --expect-fingerprint to plant lightweight ocx-child.", usage);
|
|
71
171
|
}
|
|
172
|
+
const sizeLabel = formatSizeMb(probe.binarySizeBytes);
|
|
173
|
+
if (!expected) {
|
|
174
|
+
const approved = deps.confirmFingerprint
|
|
175
|
+
? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: null, runtimeKind: "missing", binarySizeBytes: probe.binarySizeBytes })
|
|
176
|
+
: await askYes(`Confirm ${alias} ${probe.keyType} ${probe.fingerprint} — plant lightweight ocx-child (${sizeLabel}) and connect? (type yes): `);
|
|
177
|
+
controller.signal.throwIfAborted();
|
|
178
|
+
if (!approved) throw new CliUsageError("Host fingerprint and ocx-child plant were not confirmed");
|
|
179
|
+
} else if (!plantFlag) {
|
|
180
|
+
const approved = deps.confirmFingerprint
|
|
181
|
+
? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ocxVersion: null, runtimeKind: "missing", binarySizeBytes: probe.binarySizeBytes })
|
|
182
|
+
: await askYes(`Plant lightweight ocx-child (${sizeLabel}) on ${alias} and connect? (type yes): `);
|
|
183
|
+
controller.signal.throwIfAborted();
|
|
184
|
+
if (!approved) throw new CliUsageError("Planting ocx-child was not confirmed");
|
|
185
|
+
}
|
|
186
|
+
shouldPlant = true;
|
|
187
|
+
} else if (!expected) {
|
|
188
|
+
const approved = deps.confirmFingerprint
|
|
189
|
+
? await deps.confirmFingerprint({ alias: probe.alias, fingerprint: probe.fingerprint, keyType: probe.keyType, ...(probe.ocxVersion !== null ? { ocxVersion: probe.ocxVersion } : {}) })
|
|
190
|
+
: await askYes("Confirm " + alias + " " + probe.keyType + " " + probe.fingerprint + " opencodex " + probe.ocxVersion + " (type yes): ");
|
|
72
191
|
controller.signal.throwIfAborted();
|
|
73
192
|
if (!approved) throw new CliUsageError("Host fingerprint was not confirmed");
|
|
74
193
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const result = await post<unknown>("/api/link/apply", { alias, fingerprint: probe.fingerprint });
|
|
194
|
+
const sendAllowMissing = shouldPlant || probe.runtimeKind === "missing";
|
|
195
|
+
const confirm = await post<unknown>("/api/link/confirm-host", { alias, fingerprint: probe.fingerprint, ...(sendAllowMissing ? { allowMissing: true } : {}) });
|
|
196
|
+
validateConfirmed(confirm, alias, probe.fingerprint, sendAllowMissing);
|
|
197
|
+
const result = await post<unknown>("/api/link/apply", { alias, fingerprint: probe.fingerprint, ...(shouldPlant ? { plant: true } : {}) });
|
|
79
198
|
if (!record(result) || Object.keys(result).join(",") !== "linkId" || typeof result.linkId !== "string" || !/^lnk_[0-9a-f]{16}$/.test(result.linkId)) throw new Error("Invalid link apply response");
|
|
80
|
-
printData({ linkId: result.linkId, alias, state: "connected", childRole: "client" }, wantsJson, ["Connected " + alias + " as a Child (" + result.linkId + ")."]);
|
|
199
|
+
printData({ linkId: result.linkId, alias, state: "connected", childRole: "client", ...(shouldPlant ? { planted: true } : {}) }, wantsJson, ["Connected " + alias + " as a Child (" + result.linkId + ")."]);
|
|
81
200
|
};
|
|
82
201
|
try { await Promise.race([work(), expiry]); }
|
|
83
202
|
catch (error) {
|
|
84
203
|
if (error instanceof RuntimeApiError && record(error.body)) {
|
|
85
204
|
const code = record(error.body.error) ? error.body.error.code : undefined;
|
|
86
205
|
if (code === "remote_platform_unsupported" && error.body.residual !== true) throw new Error("The remote shell cannot run this Remote Link workflow. Update OpenCodex on Home and check PowerShell on the Child.");
|
|
206
|
+
if (code === "child_port_busy") throw new Error("The target port on the Child is already in use by another process; no Child files were modified.");
|
|
207
|
+
if (code === "child_preflight_output_limit") throw new Error("The Child's ocx config show --json output exceeded the Remote Link preflight limit; trim the Child's saved configuration and retry.");
|
|
208
|
+
if (code === "child_external_provider_conflict") throw new Error("The Child's ~/.codex/config.toml is already managed by another model provider or custom base URL; no Child files were modified.");
|
|
87
209
|
const phase = typeof code === "string" && Object.hasOwn(PHASES, code) ? PHASES[code] : undefined;
|
|
88
|
-
|
|
89
|
-
|
|
210
|
+
// The server's hint is the Child's own bounded, redacted reason (#8357); a phase name
|
|
211
|
+
// alone left every failure to SSH reproduction and source reading.
|
|
212
|
+
const hint = record(error.body.error) && typeof error.body.error.hint === "string" ? error.body.error.hint : "";
|
|
213
|
+
const message = phase ? "Remote Link failed during " + phase + (hint ? ": " + hint : "") : error.message;
|
|
214
|
+
const recovery = ephemeralFlow ? RECOVERY_EPHEMERAL : RECOVERY_FULL;
|
|
215
|
+
if (phase || error.body.residual === true) throw new Error(message + (error.body.residual === true ? ". " + recovery : ""));
|
|
90
216
|
}
|
|
91
217
|
throw error;
|
|
92
218
|
} finally {
|
|
@@ -95,3 +221,4 @@ export async function runLinkEnrollment(command: "probe" | "add", args: string[]
|
|
|
95
221
|
rl?.close();
|
|
96
222
|
}
|
|
97
223
|
}
|
|
224
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { usableLocalControlSocket } from "../lib/local-control-socket";
|
|
2
|
+
import type { RuntimeApiDeps } from "./runtime-api";
|
|
3
|
+
|
|
4
|
+
export interface LocalControlDeps {
|
|
5
|
+
/** Test seam: the socket a live runtime on this port exposes, or null. */
|
|
6
|
+
localControlSocket?: (port: number) => string | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Send one `ocx link status` read over the runtime's local control socket when it has one (#8184).
|
|
11
|
+
* A hub whose public listener is not loopback refuses the admin token on its TCP listeners, and the
|
|
12
|
+
* socket is the ingress that may accept it. A runtime without the socket (Windows, a loopback bind,
|
|
13
|
+
* an older version), or one whose socket cannot be reached, is asked over TCP exactly as before.
|
|
14
|
+
*/
|
|
15
|
+
export async function viaLocalControlSocket<T, D extends RuntimeApiDeps & LocalControlDeps>(
|
|
16
|
+
baseUrl: string,
|
|
17
|
+
deps: D,
|
|
18
|
+
request: (deps: D) => Promise<T>,
|
|
19
|
+
): Promise<T> {
|
|
20
|
+
const tcp = { ...deps, baseUrl };
|
|
21
|
+
if (deps.baseUrl) return request(tcp);
|
|
22
|
+
let port: number;
|
|
23
|
+
try { port = Number(new URL(baseUrl).port); } catch { return request(tcp); }
|
|
24
|
+
const socket = (deps.localControlSocket ?? usableLocalControlSocket)(port);
|
|
25
|
+
if (!socket) return request(tcp);
|
|
26
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
27
|
+
// The marker is set by the transport itself, never inferred from the answer. A runtime that
|
|
28
|
+
// answers 503 with an empty or non-JSON body is still answering, and replacing that answer with
|
|
29
|
+
// the TCP listener's 403 would be a worse report than the one the socket gave.
|
|
30
|
+
let unreachable = false;
|
|
31
|
+
try {
|
|
32
|
+
return await request({
|
|
33
|
+
...deps,
|
|
34
|
+
baseUrl: "http://localhost",
|
|
35
|
+
fetchImpl: (async (url: string | URL | Request, init?: RequestInit) => {
|
|
36
|
+
try {
|
|
37
|
+
return await fetchImpl(url, { ...init, unix: socket } as RequestInit);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
unreachable = true;
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}) as typeof fetch,
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
// Only a transport failure falls back: an answer from the socket is the runtime's answer.
|
|
46
|
+
if (unreachable) return request(tcp);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/cli/link.ts
CHANGED
|
@@ -11,10 +11,13 @@ import type { LinkLocalPeer, LinkPeerStatus } from "../link/compatibility";
|
|
|
11
11
|
import { runLinkEnrollment } from "./link-enrollment";
|
|
12
12
|
import { runLinkCleanup, type LinkCleanupDeps } from "./link-cleanup";
|
|
13
13
|
import { assertSshAlias } from "../link/ssh-argv";
|
|
14
|
+
import { boundHint } from "../link/ssh-runner";
|
|
14
15
|
import { linkStorePath } from "../link/paths";
|
|
15
16
|
import { isLinkPort } from "../link/ports";
|
|
16
17
|
import { readLinkStore, type LinkDirection, type LinkStore } from "../link/store";
|
|
18
|
+
import type { LinkChildKind } from "../link/store";
|
|
17
19
|
import { findAvailablePort } from "../server/ports";
|
|
20
|
+
import { viaLocalControlSocket, type LocalControlDeps } from "./link-local-control";
|
|
18
21
|
import {
|
|
19
22
|
CliUsageError,
|
|
20
23
|
RuntimeApiError,
|
|
@@ -32,11 +35,11 @@ import {
|
|
|
32
35
|
|
|
33
36
|
export const LINK_USAGE = `Usage:
|
|
34
37
|
ocx link probe <alias> [--json]
|
|
35
|
-
ocx link add <alias> [--expect-fingerprint SHA256:…] [--json]
|
|
38
|
+
ocx link add <alias> [--plant] [--expect-fingerprint SHA256:…] [--json]
|
|
36
39
|
ocx link port [--json]
|
|
37
40
|
ocx link issue --alias <alias> --tunnel-port <port> [--json]
|
|
38
41
|
ocx link status [--json]
|
|
39
|
-
ocx link revoke --link-id <id> [--force --yes] [--json]
|
|
42
|
+
ocx link revoke --link-id <id> [--purge] [--force --yes] [--json]
|
|
40
43
|
ocx link reconnect --link-id <id> [--json]
|
|
41
44
|
ocx link cleanup [--link-id <id>] [--json]
|
|
42
45
|
|
|
@@ -56,14 +59,14 @@ export interface LinkIssuePayload {
|
|
|
56
59
|
listenerPort: number;
|
|
57
60
|
}
|
|
58
61
|
|
|
59
|
-
export interface LinkCliDeps extends RuntimeApiDeps, Omit<LinkCleanupDeps, "readStore"> {
|
|
62
|
+
export interface LinkCliDeps extends RuntimeApiDeps, LocalControlDeps, Omit<LinkCleanupDeps, "readStore"> {
|
|
60
63
|
/** Test seam can shorten, never extend, the whole enrollment deadline. */
|
|
61
64
|
enrollmentTimeoutMs?: number;
|
|
62
65
|
choosePort?: () => Promise<number>;
|
|
63
66
|
readConfig?: () => LinkStatusConfig;
|
|
64
67
|
readClientLinkIdentity?: (linkId: string) => ClientLinkIdentity | null;
|
|
65
68
|
readChildStatus?: () => LinkStatusDto["child"];
|
|
66
|
-
confirmFingerprint?: (host: { alias: string; fingerprint: string; keyType: string }) => Promise<boolean>;
|
|
69
|
+
confirmFingerprint?: (host: { alias: string; fingerprint: string; keyType: string; ocxVersion?: string | null; runtimeKind?: "full" | "ephemeral" | "missing"; binarySizeBytes?: number }) => Promise<boolean>;
|
|
67
70
|
readStore?: () => LinkStore;
|
|
68
71
|
readAdminToken?: () => string | null;
|
|
69
72
|
}
|
|
@@ -153,11 +156,12 @@ export function validateStatus(value: unknown): LinkStatusPayload {
|
|
|
153
156
|
if (!isRecord(candidate)) throw new Error(`invalid link API response: link ${index}`);
|
|
154
157
|
// The OCX-6 parity fields are optional on the wire (an older runtime omits them) and always
|
|
155
158
|
// present in this output, null when absent.
|
|
156
|
-
assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer", "tunnel"], `link ${index}`);
|
|
159
|
+
assertKeys(candidate, ["id", "alias", "direction", "state", "since", "reason", "tunnelPort"], [...PARITY_KEYS, "peer", "tunnel", "childKind"], `link ${index}`);
|
|
157
160
|
const parity = validateParity(candidate, index);
|
|
158
161
|
if (typeof candidate.id !== "string" || !LINK_ID.test(candidate.id)
|
|
159
162
|
|| !validString(candidate.alias) || (candidate.direction !== "hub-initiated" && candidate.direction !== "client-initiated")
|
|
160
163
|
|| (candidate.state !== "connecting" && candidate.state !== "connected" && candidate.state !== "reconnecting" && candidate.state !== "failed" && candidate.state !== "idle")
|
|
164
|
+
|| (candidate.childKind !== undefined && candidate.childKind !== "full" && candidate.childKind !== "ephemeral")
|
|
161
165
|
|| !validString(candidate.since) || !validNullableString(candidate.reason) || !isLinkPort(candidate.tunnelPort)) {
|
|
162
166
|
throw new Error(`invalid link API response: link ${index} fields`);
|
|
163
167
|
}
|
|
@@ -169,6 +173,7 @@ export function validateStatus(value: unknown): LinkStatusPayload {
|
|
|
169
173
|
since: candidate.since,
|
|
170
174
|
reason: candidate.reason,
|
|
171
175
|
tunnelPort: candidate.tunnelPort,
|
|
176
|
+
...(candidate.childKind !== undefined ? { childKind: candidate.childKind as LinkChildKind } : {}),
|
|
172
177
|
...parity,
|
|
173
178
|
...(candidate.peer !== undefined ? { peer: validatePeer(candidate.peer, index) } : {}),
|
|
174
179
|
...(candidate.tunnel !== undefined ? { tunnel: validateTunnel(candidate.tunnel, index) } : {}),
|
|
@@ -242,17 +247,22 @@ async function linkRequest<T>(path: string, init: RequestInit, deps: LinkCliDeps
|
|
|
242
247
|
} catch (error) {
|
|
243
248
|
if (error instanceof RuntimeApiError) {
|
|
244
249
|
// Never echo an API error body: issue responses contain a one-time data key. Only the error
|
|
245
|
-
// code
|
|
250
|
+
// code, the server's already-bounded hint and the residual flag survive (errorCodeBody).
|
|
246
251
|
throw new RuntimeApiError(`Link management request failed (${error.status})`, error.status, errorCodeBody(error.body));
|
|
247
252
|
}
|
|
248
253
|
throw error;
|
|
249
254
|
}
|
|
250
255
|
}
|
|
251
256
|
|
|
252
|
-
function errorCodeBody(body: unknown): { error: { code: string }; residual?: true } | null {
|
|
257
|
+
function errorCodeBody(body: unknown): { error: { code: string; hint?: string }; residual?: true } | null {
|
|
253
258
|
if (!isRecord(body) || !isRecord(body.error)) return null;
|
|
254
259
|
const code = body.error.code;
|
|
255
|
-
|
|
260
|
+
if (typeof code !== "string" || !/^[a-z_]{1,64}$/.test(code)) return null;
|
|
261
|
+
// The hint is the only other field kept (#8357): the server builds it from a Child's last stderr
|
|
262
|
+
// line, already bounded and redacted, and it is bounded and redacted again here. The rest of
|
|
263
|
+
// the body is still never echoed.
|
|
264
|
+
const hint = typeof body.error.hint === "string" ? boundHint(body.error.hint) : undefined;
|
|
265
|
+
return { error: { code, ...(hint ? { hint } : {}) }, ...(body.residual === true ? { residual: true as const } : {}) };
|
|
256
266
|
}
|
|
257
267
|
|
|
258
268
|
async function runPort(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
@@ -297,19 +307,29 @@ async function runStatus(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
|
297
307
|
}
|
|
298
308
|
// A proxy older than the compatibility report or the tunnel diagnostics ignores the query and
|
|
299
309
|
// answers without those fields.
|
|
300
|
-
const result = validateStatus(await
|
|
310
|
+
const result = validateStatus(await viaLocalControlSocket(baseUrl, deps,
|
|
311
|
+
statusDeps => linkRequest<unknown>("/api/link/status?compatibility=1&diagnostics=1", {}, statusDeps)));
|
|
301
312
|
console.log(JSON.stringify(result));
|
|
302
313
|
}
|
|
303
314
|
|
|
304
315
|
async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
305
316
|
const wantsJson = takeJsonFlag(args);
|
|
317
|
+
const purge = takeFlag(args, "--purge");
|
|
306
318
|
const force = takeFlag(args, "--force");
|
|
307
319
|
const confirmed = takeFlag(args, "--yes");
|
|
308
320
|
const linkId = takeOption(args, "--link-id");
|
|
309
321
|
if (!linkId || !LINK_ID.test(linkId)) throw new CliUsageError("revoke requires a valid --link-id", LINK_USAGE);
|
|
310
322
|
rejectArgs(args, LINK_USAGE);
|
|
323
|
+
if (purge && force) throw new CliUsageError("--purge cannot be combined with --force", LINK_USAGE);
|
|
311
324
|
if (force && !confirmed) throw new CliUsageError("forced revoke skips remote cleanup; pass --yes to confirm", LINK_USAGE);
|
|
312
325
|
if (confirmed && !force) throw new CliUsageError("--yes requires --force", LINK_USAGE);
|
|
326
|
+
let wasEphemeral = false;
|
|
327
|
+
if (force) {
|
|
328
|
+
try {
|
|
329
|
+
const store = (deps.readStore ?? (() => readLinkStore(linkStorePath())))();
|
|
330
|
+
wasEphemeral = store.links.find(l => l.id === linkId)?.childKind === "ephemeral";
|
|
331
|
+
} catch { /* fallback to standard recovery message when store is unavailable */ }
|
|
332
|
+
}
|
|
313
333
|
let remoteCleanup: "skipped" | "unverified" = "skipped";
|
|
314
334
|
try {
|
|
315
335
|
const response = await linkRequest<unknown>(`/api/link/${encodeURIComponent(linkId)}`, force ? {
|
|
@@ -317,6 +337,11 @@ async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
|
317
337
|
redirect: "error",
|
|
318
338
|
headers: { "content-type": "application/json" },
|
|
319
339
|
body: JSON.stringify({ force: true }),
|
|
340
|
+
} : purge ? {
|
|
341
|
+
method: "DELETE",
|
|
342
|
+
redirect: "error",
|
|
343
|
+
headers: { "content-type": "application/json" },
|
|
344
|
+
body: JSON.stringify({ purge: true }),
|
|
320
345
|
} : { method: "DELETE" }, deps);
|
|
321
346
|
// Legacy revoke accepts an empty response; a forced receipt needs observed identity.
|
|
322
347
|
if (force && response === null) throw new Error("invalid link API response: revoke object");
|
|
@@ -333,7 +358,9 @@ async function runRevoke(args: string[], deps: LinkCliDeps): Promise<void> {
|
|
|
333
358
|
remoteCleanup = "unverified";
|
|
334
359
|
}
|
|
335
360
|
if (force) {
|
|
336
|
-
const recovery =
|
|
361
|
+
const recovery = wasEphemeral
|
|
362
|
+
? "Run ~/.cache/opencodex/bin/ocx-child detach on the remote client."
|
|
363
|
+
: "Run ocx disconnect on the remote client.";
|
|
337
364
|
printData({ linkId, remoteCleanup, recovery }, wantsJson, [
|
|
338
365
|
remoteCleanup === "skipped" ? `Revoked ${linkId}; remote cleanup was skipped.` : `Link ${linkId} is already absent; remote cleanup is unverified.`,
|
|
339
366
|
recovery,
|
|
@@ -108,6 +108,7 @@ function presetSeed(name: string, payload: unknown): Record<string, unknown> | u
|
|
|
108
108
|
return seed;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
/** Live add: an unoffered preset without --adapter/--base-url is a usage error (exit 2) before any write. */
|
|
111
112
|
async function add(name: string, options: ReturnType<typeof parseAdd>, wantsJson: boolean, deps: RuntimeApiDeps): Promise<number> {
|
|
112
113
|
const roster = await runtimeRequest<unknown>("/api/providers", { redirect: "error" }, deps);
|
|
113
114
|
if (!Array.isArray(roster) || roster.some(row => !record(row) || typeof row.name !== "string" || !isValidProviderName(row.name))) {
|
|
@@ -119,8 +120,9 @@ async function add(name: string, options: ReturnType<typeof parseAdd>, wantsJson
|
|
|
119
120
|
}
|
|
120
121
|
const presets = await runtimeRequest("/api/provider-presets", { redirect: "error" }, deps);
|
|
121
122
|
const seed = presetSeed(name, presets);
|
|
122
|
-
if (!seed &&
|
|
123
|
-
|
|
123
|
+
if (!seed && name === "openai") invalid("The selected target does not offer the canonical openai preset.");
|
|
124
|
+
if (!seed && (!options.fields.adapter || !options.fields.baseUrl)) {
|
|
125
|
+
invalid(`The selected target does not offer a "${name}" preset. Custom providers require --adapter and --base-url.`);
|
|
124
126
|
}
|
|
125
127
|
const provider = { ...seed, ...options.fields };
|
|
126
128
|
if (provider.googleToolSchemaPolicy !== undefined && provider.adapter !== "google") {
|
package/src/cli/registry.ts
CHANGED
|
@@ -834,6 +834,19 @@ export const CLI_COMMANDS: CliCommandEntry[] = [
|
|
|
834
834
|
usage: "ocx __gui-update-worker <jobId> [channel] [restart]",
|
|
835
835
|
summary: "Hidden internal: run the GUI update worker.",
|
|
836
836
|
},
|
|
837
|
+
{
|
|
838
|
+
name: "telemetry",
|
|
839
|
+
usage: "ocx telemetry <status|enable|disable|profile> [--json]",
|
|
840
|
+
summary: "Inspect or change anonymous daily usage telemetry consent and preview the payload.",
|
|
841
|
+
details: [
|
|
842
|
+
"status [--json] Show effective state, reason, install channel, last sent day, and exact preview payload.",
|
|
843
|
+
"enable [--json] Confirm and opt in to anonymous telemetry in an interactive terminal (refused with agent_consent_required or tty_required otherwise).",
|
|
844
|
+
"disable [--json] Opt out of anonymous telemetry and delete telemetry-id.json.",
|
|
845
|
+
"profile [status] [--json] Show the opt-in public leaderboard profile, the next day it would send, and its ranks.",
|
|
846
|
+
"profile connect --handle <h> [--name <n>] [--avatar <colour>] [--json] Create a public profile in an interactive terminal (refused with agent_consent_required or tty_required otherwise).",
|
|
847
|
+
"profile disconnect [--json] Delete the public profile and all its data on the server; always permitted.",
|
|
848
|
+
],
|
|
849
|
+
},
|
|
837
850
|
];
|
|
838
851
|
|
|
839
852
|
export function findCommand(name: string): CliCommandEntry | undefined {
|
package/src/cli/star-prompt.ts
CHANGED
|
@@ -177,6 +177,8 @@ function printAgentDeferral(): void {
|
|
|
177
177
|
*/
|
|
178
178
|
export async function maybeShowStarPrompt(): Promise<void> {
|
|
179
179
|
try {
|
|
180
|
+
const { maybeShowTelemetryPrompt } = await import("./telemetry");
|
|
181
|
+
await maybeShowTelemetryPrompt();
|
|
180
182
|
let isTty = false;
|
|
181
183
|
try {
|
|
182
184
|
isTty = depsForTests?.isTty ? depsForTests.isTty() : isatty(0) && isatty(1);
|
package/src/cli/status.ts
CHANGED
|
@@ -912,7 +912,7 @@ export async function collectStatus(options: { mainAccountPolicy?: boolean } = {
|
|
|
912
912
|
}
|
|
913
913
|
})();
|
|
914
914
|
const clientConnection = collectClientConnectionStatus(Date.now(), undefined, {
|
|
915
|
-
|
|
915
|
+
selectedCodexRuntime: resolvedRuntime.runtime,
|
|
916
916
|
});
|
|
917
917
|
// Asked before the local probes below so a connected client's report is hub-sourced from its
|
|
918
918
|
// first line. Bounded and failure-tolerant: an offline hub degrades the remoteHub block, it
|