@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/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
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { isatty } from "node:tty";
|
|
2
|
+
import { PROFILE_AVATARS, isProfileAvatar, type ProfileRankV1 } from "../telemetry/profile/contract";
|
|
3
|
+
import { PROFILE_DISCLOSURE_HEADING, PROFILE_DISCLOSURE_POINTS } from "../telemetry/profile/disclosure";
|
|
4
|
+
import {
|
|
5
|
+
ProfileActionError,
|
|
6
|
+
buildProfileStatusSnapshot,
|
|
7
|
+
connectTelemetryProfile,
|
|
8
|
+
disconnectTelemetryProfile,
|
|
9
|
+
fetchConnectedProfileRank,
|
|
10
|
+
type ProfileStatusSnapshot,
|
|
11
|
+
} from "../telemetry/profile/service";
|
|
12
|
+
import { isAgentDriven } from "./agent-driven";
|
|
13
|
+
import { interactiveConfirm } from "./interactive-confirm";
|
|
14
|
+
import {
|
|
15
|
+
CliUsageError,
|
|
16
|
+
RuntimeApiError,
|
|
17
|
+
printData,
|
|
18
|
+
rejectArgs,
|
|
19
|
+
runCliAction,
|
|
20
|
+
runtimeRequest,
|
|
21
|
+
takeOption,
|
|
22
|
+
type RuntimeApiDeps,
|
|
23
|
+
} from "./runtime-api";
|
|
24
|
+
|
|
25
|
+
export const TELEMETRY_PROFILE_USAGE = `Usage:
|
|
26
|
+
ocx telemetry profile [status] [--json]
|
|
27
|
+
ocx telemetry profile connect --handle <handle> [--name <display name>] [--avatar <${PROFILE_AVATARS.join("|")}>] [--json]
|
|
28
|
+
ocx telemetry profile disconnect [--json]`;
|
|
29
|
+
|
|
30
|
+
export const PROFILE_CLI_DISCLOSURE_LINES = Object.freeze([
|
|
31
|
+
` ${PROFILE_DISCLOSURE_HEADING}`,
|
|
32
|
+
...PROFILE_DISCLOSURE_POINTS.map(point => ` • ${point}`),
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
export interface TelemetryProfileCliTestDeps {
|
|
36
|
+
interactiveConfirm?: typeof interactiveConfirm;
|
|
37
|
+
isTty?: () => boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let testDeps: TelemetryProfileCliTestDeps | null = null;
|
|
41
|
+
|
|
42
|
+
export function setTelemetryProfileCliDepsForTests(deps: TelemetryProfileCliTestDeps | null): void {
|
|
43
|
+
testDeps = deps;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isInteractiveTty(): boolean {
|
|
47
|
+
try {
|
|
48
|
+
return testDeps?.isTty ? testDeps.isTty() : Boolean(isatty(0) && isatty(1));
|
|
49
|
+
} catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function refuse(code: string, error: string, wantsJson: boolean): number {
|
|
55
|
+
if (wantsJson) console.log(JSON.stringify({ ok: false, code, error }, null, 2));
|
|
56
|
+
else console.error(`${code}: ${error}`);
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function rankLines(rank: ProfileRankV1 | null): string[] {
|
|
61
|
+
if (!rank) return [];
|
|
62
|
+
return (["day", "week", "month"] as const).map(period => {
|
|
63
|
+
const entry = rank.periods[period];
|
|
64
|
+
const position = entry.rank === null ? "not ranked yet" : `#${entry.rank} of ${entry.of}`;
|
|
65
|
+
return ` ${period.padEnd(5)} ${position} · ${entry.tokens.toLocaleString("en-US")} tokens · ${entry.requests.toLocaleString("en-US")} requests`;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function statusLines(snapshot: ProfileStatusSnapshot, rank: ProfileRankV1 | null): string[] {
|
|
70
|
+
if (snapshot.unreadable) {
|
|
71
|
+
return ["Public profile: the local profile file cannot be read; nothing is sent. Run 'ocx telemetry profile disconnect' for details."];
|
|
72
|
+
}
|
|
73
|
+
if (!snapshot.profile) {
|
|
74
|
+
return [
|
|
75
|
+
"Public profile: not connected.",
|
|
76
|
+
snapshot.telemetryEffective
|
|
77
|
+
? "Connect one with 'ocx telemetry profile connect --handle <handle>' or from the dashboard Home."
|
|
78
|
+
: "Anonymous telemetry is off; a public profile needs it on.",
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
const profile = snapshot.profile;
|
|
82
|
+
const state = profile.pendingDelete
|
|
83
|
+
? "deletion pending (retried by the proxy)"
|
|
84
|
+
: profile.revoked
|
|
85
|
+
? "revoked by the server; disconnect and connect again"
|
|
86
|
+
: snapshot.telemetryEffective
|
|
87
|
+
? "connected"
|
|
88
|
+
: "paused while anonymous telemetry is off";
|
|
89
|
+
return [
|
|
90
|
+
`Public profile: @${profile.handle} (${profile.displayName}) — ${state}`,
|
|
91
|
+
`Connected: ${profile.connectedAt}; last sent day: ${profile.lastSentDay ?? "none yet"}`,
|
|
92
|
+
snapshot.preview
|
|
93
|
+
? `Next submission (${snapshot.preview.day}): ${snapshot.preview.requests} requests, ${snapshot.preview.families.map(row => `${row.family} ${row.tokens} tokens`).join(", ")}; --json shows the exact payload`
|
|
94
|
+
: `Next submission: none due (${snapshot.nextDayReason})`,
|
|
95
|
+
...rankLines(rank),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function readSnapshot(deps: RuntimeApiDeps): Promise<ProfileStatusSnapshot> {
|
|
100
|
+
try {
|
|
101
|
+
return await runtimeRequest<ProfileStatusSnapshot>("/api/telemetry/profile", {}, deps);
|
|
102
|
+
} catch {
|
|
103
|
+
return await buildProfileStatusSnapshot();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function readRank(deps: RuntimeApiDeps): Promise<ProfileRankV1 | null> {
|
|
108
|
+
try {
|
|
109
|
+
const live = await runtimeRequest<{ rank?: ProfileRankV1 }>("/api/telemetry/profile/rank", {}, deps);
|
|
110
|
+
return live.rank ?? null;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof RuntimeApiError && error.status !== 503) return null;
|
|
113
|
+
const local = await fetchConnectedProfileRank();
|
|
114
|
+
return local.ok ? local.rank : null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function disconnect(deps: RuntimeApiDeps): Promise<{ status: string }> {
|
|
119
|
+
try {
|
|
120
|
+
return await runtimeRequest<{ status: string }>("/api/telemetry/profile", { method: "DELETE" }, deps);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
// Only a stopped or unreachable proxy falls back; a refusal from a running proxy is reported.
|
|
123
|
+
if (error instanceof RuntimeApiError && error.status !== 503) throw error;
|
|
124
|
+
return await disconnectTelemetryProfile();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function handleTelemetryProfileCommand(argv: string[], wantsJson: boolean, deps: RuntimeApiDeps = {}): Promise<number> {
|
|
129
|
+
const args = [...argv];
|
|
130
|
+
const sub = (args.shift() ?? "status").toLowerCase();
|
|
131
|
+
if (sub === "connect") {
|
|
132
|
+
if (isAgentDriven()) {
|
|
133
|
+
return refuse(
|
|
134
|
+
"agent_consent_required",
|
|
135
|
+
"Refused: a public profile must be connected by a human user in their own interactive terminal or in the dashboard Home.",
|
|
136
|
+
wantsJson,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (Boolean(process.env.OCX_SERVICE) || !isInteractiveTty()) {
|
|
140
|
+
return refuse(
|
|
141
|
+
"tty_required",
|
|
142
|
+
"Refused: 'ocx telemetry profile connect' requires an interactive human terminal (TTY stdin and stdout, not OCX_SERVICE). Connect in an interactive terminal or from the dashboard Home.",
|
|
143
|
+
wantsJson,
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return runCliAction(async () => {
|
|
148
|
+
if (sub === "status") {
|
|
149
|
+
rejectArgs(args, TELEMETRY_PROFILE_USAGE);
|
|
150
|
+
const snapshot = await readSnapshot(deps);
|
|
151
|
+
const rank = snapshot.profile && !snapshot.profile.pendingDelete ? await readRank(deps) : null;
|
|
152
|
+
printData({ ...snapshot, rank }, wantsJson, statusLines(snapshot, rank));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (sub === "connect") {
|
|
156
|
+
const handle = takeOption(args, "--handle");
|
|
157
|
+
const name = takeOption(args, "--name");
|
|
158
|
+
const avatar = takeOption(args, "--avatar") ?? "blue";
|
|
159
|
+
rejectArgs(args, TELEMETRY_PROFILE_USAGE);
|
|
160
|
+
if (!handle) throw new CliUsageError("--handle is required", TELEMETRY_PROFILE_USAGE);
|
|
161
|
+
if (!isProfileAvatar(avatar)) throw new CliUsageError(`--avatar must be one of ${PROFILE_AVATARS.join(", ")}`, TELEMETRY_PROFILE_USAGE);
|
|
162
|
+
// Refuse before asking anything when the connect could not succeed.
|
|
163
|
+
const before = await buildProfileStatusSnapshot();
|
|
164
|
+
if (!before.telemetryEffective) {
|
|
165
|
+
throw new Error("telemetry_off: A public profile needs anonymous telemetry to be on: its totals come from the same daily aggregate.");
|
|
166
|
+
}
|
|
167
|
+
console.log(PROFILE_CLI_DISCLOSURE_LINES.join("\n"));
|
|
168
|
+
const ask = testDeps?.interactiveConfirm ?? interactiveConfirm;
|
|
169
|
+
const yes = await ask({ question: "\n Create this public profile? [y/N]", defaultYes: false });
|
|
170
|
+
if (!yes) throw new Error("Profile connect cancelled: confirmation was declined. Nothing was sent.");
|
|
171
|
+
try {
|
|
172
|
+
const profile = await connectTelemetryProfile({ handle, displayName: name ?? handle, avatar });
|
|
173
|
+
// A running proxy starts its profile loop when it next reads the profile status.
|
|
174
|
+
await runtimeRequest("/api/telemetry/profile", {}, deps).catch(() => undefined);
|
|
175
|
+
printData({ ok: true, profile }, wantsJson, [
|
|
176
|
+
`Public profile @${profile.handle} connected. Your first rank appears after the next completed UTC day.`,
|
|
177
|
+
]);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (error instanceof ProfileActionError) throw new Error(`${error.code}: ${error.message}`);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (sub === "disconnect") {
|
|
185
|
+
rejectArgs(args, TELEMETRY_PROFILE_USAGE);
|
|
186
|
+
let outcome: { status: string };
|
|
187
|
+
try {
|
|
188
|
+
outcome = await disconnect(deps);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
if (error instanceof ProfileActionError) throw new Error(`${error.code}: ${error.message}`);
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
const line = outcome.status === "deleted"
|
|
194
|
+
? "Public profile deleted on the server and disconnected."
|
|
195
|
+
: outcome.status === "not_connected"
|
|
196
|
+
? "No public profile is connected."
|
|
197
|
+
: outcome.status === "local_removed"
|
|
198
|
+
? "The unreadable local profile file was removed. Its secret could not be read, so the server profile was not deleted; it stops receiving data and is pruned after 400 days without submissions."
|
|
199
|
+
: "deletion_pending: the telemetry service could not be reached. Nothing more is sent; the proxy retries the deletion on every tick and on its next start.";
|
|
200
|
+
printData({ ok: true, ...outcome }, wantsJson, [line]);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
throw new CliUsageError(`unknown telemetry profile command ${sub}`, TELEMETRY_PROFILE_USAGE);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|