@bitkyc08/opencodex 2.100.2 → 2.100.3
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/README.md +1 -1
- package/bin/ocx.mjs +32 -18
- package/gui/dist/assets/{App-COo8Yopd.css → App-BGP8I0V4.css} +1 -1
- package/gui/dist/assets/App-Dnb6VMsP.js +59 -0
- package/gui/dist/assets/{Tray-BcaI-VCr.js → Tray-BV4ms9U9.js} +1 -1
- package/gui/dist/assets/{brand-mark-DU-0Vdkr.js → brand-mark-XOLJbomA.js} +1 -1
- package/gui/dist/assets/index-DCdXsMyZ.js +105 -0
- package/gui/dist/assets/{index-DJEkIDAi.css → index-DQtCRNAw.css} +1 -1
- package/gui/dist/assets/{segment-thumb-features-e9A_FogJ.js → segment-thumb-features-DXSidY6D.js} +1 -1
- package/gui/dist/classic/assets/App-DA-scMPq.js +58 -0
- package/gui/dist/classic/assets/{Tray-DT146AhS.js → Tray-BrHaVRAq.js} +1 -1
- package/gui/dist/classic/assets/index-BqOaGLf5.js +105 -0
- package/gui/dist/classic/assets/{quota-summary-CakPe9Ni.js → quota-summary-Dy5_wfTT.js} +1 -1
- package/gui/dist/classic/index.html +1 -1
- package/gui/dist/index.html +2 -2
- package/native/ocx-child/Cargo.toml +9 -0
- package/native/ocx-child/src/cli.rs +402 -20
- package/native/ocx-child/src/codex_home.rs +98 -14
- package/native/ocx-child/src/daemon.rs +2 -1
- package/native/ocx-child/src/lib.rs +3 -0
- package/native/ocx-child/src/link_ws.rs +2598 -0
- package/native/ocx-child/src/link_ws_advert.rs +346 -0
- package/native/ocx-child/src/link_ws_frame.rs +749 -0
- package/native/ocx-child/src/parity.rs +5 -1
- package/native/ocx-child/src/platform.rs +152 -6
- package/native/ocx-child/src/relay.rs +150 -19
- package/package.json +3 -3
- package/src/adapters/anthropic/advisor-tool.ts +176 -0
- package/src/adapters/anthropic/beta-body-pairs.ts +6 -0
- package/src/adapters/anthropic/client-identity.ts +3 -1
- package/src/adapters/anthropic/passthrough.ts +9 -3
- package/src/adapters/anthropic.ts +31 -14
- package/src/adapters/client-fingerprint.ts +3 -3
- package/src/adapters/cursor/discovery.ts +17 -0
- package/src/adapters/cursor/native-exec-desktop.ts +2 -1
- package/src/adapters/cursor/native-exec-shell.ts +2 -1
- package/src/adapters/cursor/protobuf-request.ts +8 -8
- package/src/adapters/cursor.ts +7 -6
- package/src/adapters/google-antigravity-wire.ts +7 -5
- package/src/adapters/google-wire-compiler.ts +2 -2
- package/src/adapters/google.ts +9 -2
- package/src/adapters/kiro/payload.ts +7 -4
- package/src/adapters/kiro/reasoning.ts +44 -1
- package/src/adapters/kiro/structured-output.ts +10 -8
- package/src/adapters/kiro-tools.ts +61 -15
- package/src/adapters/openai-chat/destination-policy.ts +16 -0
- package/src/adapters/openai-chat/reasoning-replay.ts +4 -1
- package/src/adapters/zed.ts +3 -0
- package/src/advisor/consult.ts +15 -4
- package/src/advisor/context.ts +12 -3
- package/src/advisor/runtime.ts +35 -5
- package/src/advisor/settings.ts +8 -0
- package/src/advisor/synthetic-tool.ts +21 -8
- package/src/bridge/response-json.ts +11 -2
- package/src/bridge/sse.ts +43 -8
- package/src/claude/auth-detect.ts +21 -33
- package/src/claude/desktop-3p.ts +11 -5
- package/src/claude/desktop-gateway-state.ts +2 -0
- package/src/claude/desktop-remote-store-artifact.ts +14 -3
- package/src/claude/desktop-remote-store.ts +24 -4
- package/src/claude/inbound-content-options.ts +31 -16
- package/src/claude/outbound.ts +13 -3
- package/src/cli/account-api.ts +17 -1
- package/src/cli/account-auth.ts +54 -21
- package/src/cli/account-key-quota.ts +34 -5
- package/src/cli/account.ts +4 -2
- package/src/cli/advisor.ts +7 -4
- package/src/cli/alias.ts +38 -1
- package/src/cli/capabilities-access-remote.ts +128 -3
- package/src/cli/capabilities-accounts.ts +3 -3
- package/src/cli/capabilities-agents-routing.ts +17 -10
- package/src/cli/capabilities-base.ts +41 -16
- package/src/cli/capabilities-integrations.ts +2 -2
- package/src/cli/capabilities-provider-models.ts +18 -2
- package/src/cli/capabilities-route-to.ts +43 -0
- package/src/cli/capabilities.ts +2 -0
- package/src/cli/capability-contracts.ts +1 -1
- package/src/cli/claude-desktop.ts +30 -11
- package/src/cli/claude.ts +17 -3
- package/src/cli/codex-launcher.ts +3 -1
- package/src/cli/codex-shim-autorestore.ts +5 -42
- package/src/cli/config-command.ts +14 -1
- package/src/cli/config-root-startup.ts +34 -0
- package/src/cli/connect.ts +88 -16
- package/src/cli/desktop-runtime-guidance.ts +1 -1
- package/src/cli/disconnect-runtime.ts +168 -0
- package/src/cli/dispatch.ts +54 -12
- package/src/cli/export-command.ts +1 -1
- package/src/cli/gui-pair-client.ts +6 -3
- package/src/cli/gui.ts +10 -5
- package/src/cli/help-catalog.ts +11 -0
- package/src/cli/help.ts +4 -3
- package/src/cli/index.ts +83 -92
- package/src/cli/inspect.ts +11 -2
- package/src/cli/integrations.ts +26 -1
- package/src/cli/link-capture.ts +64 -0
- package/src/cli/link-child-ops.ts +218 -40
- package/src/cli/link-cleanup.ts +8 -5
- package/src/cli/link-diagnostics.ts +67 -0
- package/src/cli/link-enrollment.ts +158 -12
- package/src/cli/link-operations.ts +52 -0
- package/src/cli/link-recover.ts +152 -0
- package/src/cli/link-routes.ts +87 -0
- package/src/cli/link-status-child.ts +44 -1
- package/src/cli/link-status-traffic.ts +34 -0
- package/src/cli/link.ts +314 -37
- package/src/cli/message-command.ts +1 -1
- package/src/cli/message-mcp-command.ts +23 -10
- package/src/cli/models-runtime.ts +3 -3
- package/src/cli/opencode.ts +3 -1
- package/src/cli/pi-sync.ts +35 -0
- package/src/cli/preflight-exemptions.ts +46 -0
- package/src/cli/registry.ts +28 -12
- package/src/cli/restart-failure.ts +5 -2
- package/src/cli/root.ts +5 -1
- package/src/cli/route-to.ts +172 -0
- package/src/cli/runtime-api.ts +5 -8
- package/src/cli/status.ts +3 -1
- package/src/cli/stop-approval.ts +66 -19
- package/src/cli/stop-report.ts +23 -0
- package/src/cli/stop-windows-checked.ts +304 -0
- package/src/cli/sync-command.ts +70 -15
- package/src/cli/sync-fanout.ts +74 -19
- package/src/cli/sync-flags.ts +40 -3
- package/src/cli/sync-link-status.ts +18 -2
- package/src/cli/sync-update-guard.ts +7 -2
- package/src/cli/system-restart-client.ts +3 -2
- package/src/cli/uninstall-plan.ts +77 -5
- package/src/cli/uninstall-stop.ts +152 -0
- package/src/cli/v2-input.ts +10 -6
- package/src/cli/v2-local-output.ts +3 -2
- package/src/cli/v2-runtime.ts +10 -3
- package/src/cli/v2.ts +22 -7
- package/src/client/connect.ts +321 -34
- package/src/client/link-home-features.ts +27 -0
- package/src/client/link-home.ts +92 -4
- package/src/client/link-ingress.ts +21 -3
- package/src/client/link-join.ts +12 -2
- package/src/client/link-parity-reporter.ts +60 -6
- package/src/client/link-relay-transport.ts +161 -36
- package/src/client/link-relay.ts +150 -6
- package/src/client/link-request-compression.ts +84 -0
- package/src/client/link-state.ts +11 -5
- package/src/client/link-status.ts +39 -1
- package/src/client/link-teardown.ts +1 -0
- package/src/client/link-tunnel.ts +56 -5
- package/src/client/link-websocket-limits.ts +89 -0
- package/src/client/link-websocket.ts +586 -0
- package/src/client/link-ws-advertisement.ts +100 -0
- package/src/client/link-ws-framer.ts +241 -0
- package/src/client/link-ws-transport.ts +177 -0
- package/src/client/machine-api.ts +13 -2
- package/src/client/machine-listener.ts +48 -7
- package/src/client/route-intent-apply.ts +293 -0
- package/src/client/route-intent-file-originals.ts +97 -0
- package/src/client/route-intent-native-originals.ts +201 -0
- package/src/client/route-intent-watch.ts +141 -0
- package/src/client/runtime-restart.ts +127 -5
- package/src/client/runtime.ts +61 -15
- package/src/client/state.ts +30 -0
- package/src/client/sync-expectation.ts +36 -2
- package/src/client/sync-runtime.ts +7 -0
- package/src/clients/config-export/alias-selectors.ts +63 -40
- package/src/clients/config-export/contracts.ts +2 -0
- package/src/clients/config-export/nested-selectors.ts +42 -0
- package/src/clients/config-export.ts +22 -3
- package/src/codex/account-store.ts +12 -3
- package/src/codex/account-usability.ts +13 -0
- package/src/codex/auth-api/account-list.ts +29 -3
- package/src/codex/auth-collision.ts +23 -22
- package/src/codex/auth-context.ts +21 -6
- package/src/codex/catalog/gather-capture.ts +8 -2
- package/src/codex/catalog/parsing.ts +7 -3
- package/src/codex/catalog/provider-models.ts +54 -15
- package/src/codex/catalog/retained-sync.ts +2 -1
- package/src/codex/catalog/routed-gather.ts +1 -1
- package/src/codex/catalog-auto-refresh.ts +11 -0
- package/src/codex/cli-update-job.ts +35 -13
- package/src/codex/convergence.ts +2 -2
- package/src/codex/desktop-compatibility/native-identity.ts +4 -8
- package/src/codex/features.ts +2 -2
- package/src/codex/history-provider.ts +31 -0
- package/src/codex/inject/multi-agent-v2.ts +9 -3
- package/src/codex/inject/paginated-openai-compat.ts +54 -1
- package/src/codex/inject/plan.ts +20 -2
- package/src/codex/inject.ts +2 -0
- package/src/codex/journal-config-restore.ts +217 -0
- package/src/codex/journal.ts +75 -6
- package/src/codex/main-account.ts +23 -30
- package/src/codex/native-main-auth-file.ts +104 -0
- package/src/codex/native-profile-manager.ts +4 -3
- package/src/codex/native-profile-store.ts +3 -61
- package/src/codex/orca-import.ts +10 -1
- package/src/codex/quota-history.ts +13 -0
- package/src/codex/quota-window-conflict.ts +103 -0
- package/src/codex/quota.ts +23 -1
- package/src/codex/subagent-model-fallback.ts +3 -1
- package/src/codex/websocket-activity.ts +171 -16
- package/src/codex/websocket-registry.ts +11 -4
- package/src/combos/cooldown-store.ts +25 -5
- package/src/combos/failover.ts +330 -2
- package/src/config/dashboard-trusted-proxy.ts +83 -0
- package/src/config/diagnostics.ts +28 -0
- package/src/config/feature-flags.ts +9 -0
- package/src/config/live-reconcile.ts +10 -1
- package/src/config/load-degrade.ts +12 -1
- package/src/config/multi-agent-surface.ts +28 -5
- package/src/config/pending-teardown.ts +60 -3
- package/src/config/process-state.ts +175 -4
- package/src/config/provider-validation.ts +4 -4
- package/src/config/schema/config-schema.ts +6 -0
- package/src/config/schema/leaf-validators.ts +9 -2
- package/src/config/windows-process-command-line.ts +107 -0
- package/src/generated/compatibility-version.json +948 -392
- package/src/generated/model-metadata.ts +1 -1
- package/src/images/loop.ts +3 -0
- package/src/integrations/model-name-guard.ts +25 -0
- package/src/integrations/route-intent-catalog.ts +26 -0
- package/src/integrations/route-intent-connected.ts +262 -0
- package/src/integrations/route-intent-contract.ts +55 -0
- package/src/integrations/route-intent-disconnect.ts +109 -0
- package/src/integrations/route-intent-initial.ts +64 -0
- package/src/integrations/route-intent-state.ts +117 -0
- package/src/integrations/route-intent-tick.ts +65 -0
- package/src/integrations/route-intent.ts +212 -0
- package/src/integrations/writer.ts +44 -11
- package/src/lib/client-retry-after.ts +29 -0
- package/src/lib/config-ownership.ts +13 -0
- package/src/lib/desktop-gui-origin.ts +28 -0
- package/src/lib/errors.ts +1 -1
- package/src/lib/gui-pair-capability.ts +2 -1
- package/src/lib/messages-error-body.ts +4 -1
- package/src/lib/outbound-credential-registry.ts +362 -4
- package/src/lib/paced-stream.ts +34 -0
- package/src/lib/passive-key-fetch-proof.ts +30 -0
- package/src/lib/passive-read.ts +5 -0
- package/src/lib/process-control.ts +76 -12
- package/src/lib/redact.ts +84 -8
- package/src/lib/state-store-registrations.ts +11 -0
- package/src/lib/state-store-sweeper.ts +4 -0
- package/src/lib/supervisor-markers.ts +18 -0
- package/src/lib/terminal-safe-text.ts +58 -0
- package/src/lib/translator-budget.ts +3 -2
- package/src/lib/upstream-retry.ts +14 -4
- package/src/link/alias-lock.ts +119 -0
- package/src/link/child-activity.ts +28 -2
- package/src/link/child-binary-cache-fill.d.mts +50 -0
- package/src/link/child-binary-cache-fill.mjs +494 -0
- package/src/link/child-binary-cache-start.ts +73 -0
- package/src/link/child-binary-source.ts +12 -5
- package/src/link/child-gated-ocx.ts +29 -11
- package/src/link/child-observations.ts +2 -1
- package/src/link/child-observe.ts +2 -2
- package/src/link/child-ops-engine.ts +159 -91
- package/src/link/child-ops-host.ts +138 -0
- package/src/link/child-ops-runners.ts +319 -0
- package/src/link/child-ops-scheduler.ts +207 -0
- package/src/link/child-ops-types.ts +89 -0
- package/src/link/child-parity.ts +23 -4
- package/src/link/child-policy.ts +93 -0
- package/src/link/child-update-contract.ts +12 -3
- package/src/link/codex-settings.ts +1 -1
- package/src/link/compatibility.ts +18 -1
- package/src/link/diagnostics-read.ts +163 -0
- package/src/link/diagnostics.ts +20 -7
- package/src/link/explicit-route.ts +209 -0
- package/src/link/link-recover.ts +113 -0
- package/src/link/management-routes.ts +3 -1
- package/src/link/operation-recovery-slot.ts +44 -0
- package/src/link/operations-journal.ts +408 -0
- package/src/link/peer-report.ts +1 -1
- package/src/link/relay-auth.ts +14 -0
- package/src/link/remote-plant.ts +152 -14
- package/src/link/remote-platform.ts +21 -10
- package/src/link/remote-probe.ts +11 -3
- package/src/link/remote-windows.ts +50 -10
- package/src/link/request-compression.ts +30 -0
- package/src/link/residual-recovery.ts +54 -0
- package/src/link/retirement.ts +128 -0
- package/src/link/route-intent-watch.ts +41 -0
- package/src/link/route-intent.ts +209 -0
- package/src/link/route-proof.ts +82 -0
- package/src/link/route-rounds.ts +579 -0
- package/src/link/route-select.ts +95 -0
- package/src/link/route-trust.ts +96 -0
- package/src/link/ssh-argv.ts +172 -24
- package/src/link/ssh-capture-redact.ts +253 -0
- package/src/link/ssh-capture.ts +497 -0
- package/src/link/ssh-runner.ts +141 -14
- package/src/link/status-projection.ts +87 -0
- package/src/link/store.ts +54 -1
- package/src/link/supervisor.ts +543 -55
- package/src/link/sync-fanout-classify.ts +16 -0
- package/src/link/sync-then-restart.ts +65 -0
- package/src/link/tombstones.ts +209 -0
- package/src/link/traffic.ts +178 -0
- package/src/link/ws-activity-holds.ts +474 -0
- package/src/local-credentials/publication-fence.ts +20 -1
- package/src/messaging/mcp-queue-rpc.ts +1 -1
- package/src/messaging/mcp-queue-server.ts +16 -1
- package/src/messaging/mcp-resume-tools.ts +25 -0
- package/src/messaging/remote-enrollment.ts +3 -3
- package/src/messaging/remote-tunnels.ts +2 -2
- package/src/messaging/resume-permissions.ts +27 -0
- package/src/messaging/rpc.ts +46 -2
- package/src/oauth/anthropic-continuity.ts +23 -7
- package/src/oauth/anthropic-routing.ts +5 -2
- package/src/oauth/anthropic.ts +22 -2
- package/src/oauth/claude-keychain-read.ts +78 -68
- package/src/oauth/index.ts +24 -6
- package/src/oauth/local-token-detect.ts +8 -29
- package/src/oauth/login-cli-errors.ts +5 -1
- package/src/oauth/login-cli.ts +33 -18
- package/src/oauth/login-flow-state.ts +26 -3
- package/src/oauth/meta-muse.ts +1 -1
- package/src/oauth/store.ts +7 -0
- package/src/oauth/xai.ts +248 -14
- package/src/protocols/contract.ts +4 -0
- package/src/protocols/encoders/messages.ts +1 -0
- package/src/providers/alias-template.ts +48 -0
- package/src/providers/anthropic-billing-ownership.ts +2 -0
- package/src/providers/anthropic-output-caps.ts +46 -0
- package/src/providers/anthropic-reset-grant-ledger.ts +9 -3
- package/src/providers/antigravity-effort-families.ts +11 -3
- package/src/providers/antigravity-models.ts +32 -9
- package/src/providers/antigravity-wire-snapshot.ts +3 -2
- package/src/providers/api-key-pause.ts +3 -0
- package/src/providers/api-key-resolve.ts +49 -7
- package/src/providers/api-key-response-ownership.ts +2 -0
- package/src/providers/api-key-selection.ts +51 -9
- package/src/providers/api-keys.ts +6 -2
- package/src/providers/cache-affinity-identity.ts +73 -0
- package/src/providers/cache-affinity.ts +256 -0
- package/src/providers/default-aliases.ts +98 -20
- package/src/providers/google-vertex-model-discovery.ts +510 -0
- package/src/providers/key-failover.ts +123 -8
- package/src/providers/key-store.ts +3 -3
- package/src/providers/kiro-models.ts +3 -5
- package/src/providers/label.ts +31 -5
- package/src/providers/mistral-transport.ts +17 -4
- package/src/providers/model-rename-fields.ts +3 -0
- package/src/providers/muse-key-quota.ts +14 -6
- package/src/providers/new-model-policy-runtime.ts +17 -4
- package/src/providers/new-model-policy.ts +30 -4
- package/src/providers/passive-key-observation.ts +252 -0
- package/src/providers/quota/account-cache.ts +2 -1
- package/src/providers/quota/anthropic-cooldown-recovery-worker.ts +121 -0
- package/src/providers/quota/passive-key-limits.ts +272 -0
- package/src/providers/quota/passive-wire-model.ts +126 -0
- package/src/providers/quota/report-cache.ts +61 -2
- package/src/providers/quota-key-accounts.ts +11 -6
- package/src/providers/quota-types.ts +18 -0
- package/src/providers/quota.ts +11 -12
- package/src/providers/registry/entries-core.ts +34 -16
- package/src/providers/registry/entries-extended.ts +32 -0
- package/src/providers/registry/model-seeds.ts +35 -0
- package/src/providers/resolved-model-policy.ts +7 -0
- package/src/providers/routed-config.ts +8 -3
- package/src/providers/xai-transport.ts +3 -0
- package/src/remote/features.ts +17 -0
- package/src/responses/anthropic-progress.ts +10 -4
- package/src/responses/citation-markers.ts +231 -0
- package/src/responses/spill-store.ts +5 -1
- package/src/responses/state/replay-input.ts +50 -0
- package/src/responses/state/replay-owner.ts +24 -0
- package/src/responses/state/snapshot-codec.ts +9 -0
- package/src/responses/state/spill-queue.ts +1 -0
- package/src/responses/state.ts +42 -60
- package/src/router.ts +2 -2
- package/src/routing/home-route-capture.ts +123 -0
- package/src/routing/home-route-intent.ts +200 -0
- package/src/routing/route-intent-state.ts +178 -0
- package/src/routing/route-to-live-settings.ts +35 -0
- package/src/routing/route-to-local.ts +145 -0
- package/src/routing/route-to-status.ts +94 -0
- package/src/routing/route-to-sync-child.ts +32 -0
- package/src/server/adapter-resolve.ts +21 -1
- package/src/server/admitted-http-turn.ts +3 -0
- package/src/server/auth-cors.ts +98 -0
- package/src/server/bare-upstream-error.ts +220 -0
- package/src/server/chat-native.ts +14 -5
- package/src/server/claude-messages.ts +6 -4
- package/src/server/codex-model-list.ts +2 -1
- package/src/server/configured-credentials.ts +37 -5
- package/src/server/gui-desktop-authorization.ts +36 -0
- package/src/server/gui-pair-delivery.ts +6 -3
- package/src/server/gui-session.ts +10 -1
- package/src/server/inbound-body-admission.ts +17 -4
- package/src/server/index/link-listener.ts +190 -12
- package/src/server/index/link-management.ts +15 -1
- package/src/server/index/link-relay-sessions.ts +87 -8
- package/src/server/index/link-websocket-limits.ts +136 -0
- package/src/server/index/link-websocket.ts +692 -0
- package/src/server/index/optional-listeners.ts +97 -7
- package/src/server/index/route-intent-watch.ts +47 -0
- package/src/server/index/serve-contract.ts +86 -0
- package/src/server/index/serve-options.ts +35 -86
- package/src/server/index/startup-warnings.ts +8 -2
- package/src/server/index/websocket-handler.ts +26 -4
- package/src/server/index.ts +12 -2
- package/src/server/inference/client-encoder-delivery.ts +2 -0
- package/src/server/inspection-tee.ts +39 -2
- package/src/server/lifecycle.ts +2 -0
- package/src/server/link-turn.ts +137 -0
- package/src/server/management/advisor-routes.ts +10 -2
- package/src/server/management/agent-settings-routes.ts +50 -16
- package/src/server/management/anthropic-reset-grant-routes.ts +1 -1
- package/src/server/management/context.ts +9 -2
- package/src/server/management/desktop-authorization.ts +41 -0
- package/src/server/management/desktop-compatibility-routes.ts +9 -8
- package/src/server/management/desktop-compatibility-runtime-routes.ts +3 -2
- package/src/server/management/desktop-compatibility-settings-routes.ts +5 -3
- package/src/server/management/home-integration-decision.ts +89 -0
- package/src/server/management/integration-routes.ts +208 -81
- package/src/server/management/link-child-ops-routes.ts +145 -43
- package/src/server/management/link-child-preflight.ts +31 -0
- package/src/server/management/link-diagnostics-route.ts +29 -0
- package/src/server/management/link-enrollment.ts +199 -47
- package/src/server/management/link-operation.ts +609 -0
- package/src/server/management/link-recover-route.ts +103 -0
- package/src/server/management/link-route-edit.ts +173 -0
- package/src/server/management/link-route-request.ts +62 -0
- package/src/server/management/link-route-state.ts +83 -7
- package/src/server/management/link-routes.ts +553 -51
- package/src/server/management/link-traffic-status.ts +13 -0
- package/src/server/management/model-routes.ts +122 -36
- package/src/server/management/model-rows.ts +2 -1
- package/src/server/management/native-integration-routes.ts +176 -70
- package/src/server/management/oauth-account-routes.ts +36 -13
- package/src/server/management/protocol-routes.ts +7 -0
- package/src/server/management/provider-completion-test.ts +4 -4
- package/src/server/management/provider-overwrite-carry.ts +11 -0
- package/src/server/management/provider-routes.ts +64 -61
- package/src/server/management/provider-routing-quota.ts +45 -0
- package/src/server/management/route-registry.ts +22 -3
- package/src/server/management/route-to-routes.ts +257 -0
- package/src/server/management/system-restart.ts +4 -2
- package/src/server/management/usage-aggregate-cache.ts +101 -66
- package/src/server/management-api.ts +17 -3
- package/src/server/management-auth.ts +13 -1
- package/src/server/messages-native-preflight.ts +27 -4
- package/src/server/messages-native.ts +17 -5
- package/src/server/persistent-gui-session.ts +6 -3
- package/src/server/proxy-liveness.ts +33 -6
- package/src/server/relay-eager.ts +36 -12
- package/src/server/relay.ts +183 -116
- package/src/server/request-body-facts.ts +48 -0
- package/src/server/request-decompress.ts +65 -2
- package/src/server/request-log-account-rotation.ts +6 -0
- package/src/server/request-log-attempt-usage.ts +69 -0
- package/src/server/request-log-cache-affinity.ts +60 -0
- package/src/server/request-log-conversation.ts +45 -2
- package/src/server/request-log-terminal-status.ts +210 -24
- package/src/server/request-log.ts +71 -79
- package/src/server/responses/adapter-continuation.ts +2 -1
- package/src/server/responses/adapter-delivery.ts +2 -0
- package/src/server/responses/adapter-dispatch.ts +5 -7
- package/src/server/responses/advisor-plan-slot.ts +33 -1
- package/src/server/responses/advisor-question.ts +21 -0
- package/src/server/responses/advisor-slot.ts +10 -3
- package/src/server/responses/bare-namespace-aliases.ts +18 -0
- package/src/server/responses/buffered-sse-json.ts +9 -3
- package/src/server/responses/code-mode-collab-surface.ts +11 -0
- package/src/server/responses/codex-tool-catalog.ts +156 -0
- package/src/server/responses/combo-required-tool-fulfillments.ts +4 -2
- package/src/server/responses/combo-stream-preflight.ts +557 -54
- package/src/server/responses/compact.ts +32 -8
- package/src/server/responses/core-codex-account.ts +17 -3
- package/src/server/responses/core-combo-failure.ts +8 -0
- package/src/server/responses/core-combo.ts +32 -4
- package/src/server/responses/core-errors.ts +5 -2
- package/src/server/responses/core-lifetime.ts +3 -2
- package/src/server/responses/core-normalize.ts +3 -1
- package/src/server/responses/core-options.ts +6 -0
- package/src/server/responses/core.ts +2 -0
- package/src/server/responses/fetch-helpers.ts +15 -10
- package/src/server/responses/native-replay-guard.ts +57 -0
- package/src/server/responses/opengateway-completion-guard.ts +10 -4
- package/src/server/responses/outbound-request-body.ts +29 -0
- package/src/server/responses/passthrough-completion.ts +105 -8
- package/src/server/responses/passthrough-delivery.ts +31 -11
- package/src/server/responses/passthrough-dispatch.ts +74 -73
- package/src/server/responses/policy-fallback.ts +13 -1
- package/src/server/responses/request-prepare.ts +50 -6
- package/src/server/responses/request-transport.ts +10 -3
- package/src/server/responses/reset-replay.ts +46 -2
- package/src/server/responses/run-turn-execution.ts +2 -0
- package/src/server/responses/sidecar-execution.ts +14 -0
- package/src/server/responses/terminal-error-redaction.ts +222 -25
- package/src/server/responses/ws-upstream.ts +2 -2
- package/src/server/sse-payload-rewrite.ts +3 -2
- package/src/server/stop-service-route.ts +85 -0
- package/src/server/system-env-shell.ts +12 -1
- package/src/server/system-env.ts +5 -3
- package/src/server/windows-tcp-drop.ts +21 -4
- package/src/server/workflow-refusal.ts +8 -0
- package/src/server/ws-bridge.ts +191 -12
- package/src/service/cli-windows-stop.ts +189 -0
- package/src/service/cli.ts +41 -12
- package/src/service/disconnected-client-restart.ts +60 -0
- package/src/service/guarded-manager-target.ts +18 -1
- package/src/service/health.ts +99 -6
- package/src/service/launchd.ts +84 -31
- package/src/service/orchestration.ts +418 -91
- package/src/service/repair.ts +223 -6
- package/src/service/restart-proxy-stop.ts +79 -0
- package/src/service/service-child-ownership.ts +6 -2
- package/src/service/windows-checked-stop-live.ts +467 -0
- package/src/service/windows-checked-stop.ts +435 -0
- package/src/service/windows-command-line-token.ts +23 -0
- package/src/service/windows-guarded-manager.ts +77 -34
- package/src/service/windows-ops.ts +38 -56
- package/src/service/windows-process-evidence.ts +292 -0
- package/src/service/windows-process-native.ts +262 -0
- package/src/service/windows-service-stop.ts +321 -0
- package/src/service/windows-stop-binding.ts +187 -0
- package/src/service/windows-stop-budget.ts +123 -0
- package/src/service/windows-stop-confirm.ts +158 -0
- package/src/service/windows-stop-deadline.ts +56 -0
- package/src/service.ts +2 -2
- package/src/types/config.ts +42 -18
- package/src/types/link.ts +20 -0
- package/src/types/multi-agent.ts +13 -0
- package/src/types/provider.ts +47 -2
- package/src/types/request.ts +4 -0
- package/src/types.ts +3 -0
- package/src/update/guarded-runtime-ops.ts +5 -7
- package/src/update/index.ts +25 -10
- package/src/update/install-detection.mjs +3 -1
- package/src/update/job-pinned-start.ts +2 -0
- package/src/update/job-windows-restart.ts +19 -32
- package/src/update/job.ts +12 -5
- package/src/update/npm-install.d.mts +11 -0
- package/src/update/npm-install.mjs +44 -7
- package/src/update/orchestrated-entry.ts +1 -1
- package/src/update/orchestrated-node-driver.mjs +3 -2
- package/src/update/orchestrated-pnpm.d.mts +4 -0
- package/src/update/orchestrated-pnpm.mjs +50 -6
- package/src/update/orchestrated-session.d.mts +3 -1
- package/src/update/orchestrated-session.mjs +21 -6
- package/src/update/pnpm-global-install.d.mts +21 -3
- package/src/update/pnpm-global-install.mjs +322 -19
- package/src/update/pnpm-store-layout.mjs +46 -0
- package/src/update/sync-update-mutex.d.mts +3 -2
- package/src/update/sync-update-mutex.mjs +57 -8
- package/src/update/transactional-install.d.mts +3 -1
- package/src/update/transactional-install.mjs +545 -12
- package/src/update/windows-installer-marker.d.mts +1 -0
- package/src/update/windows-installer-marker.mjs +44 -0
- package/src/usage/expected-prices.ts +8 -0
- package/src/usage/filter-index.ts +326 -77
- package/src/usage/ledger-scanner.ts +15 -0
- package/src/usage/link-log-fields.ts +48 -0
- package/src/usage/log.ts +43 -2
- package/src/usage/request-body.ts +37 -0
- package/src/web-search/loop.ts +3 -0
- package/gui/dist/assets/App-BpJOzw4F.js +0 -59
- package/gui/dist/assets/index-Bbor_y80.js +0 -94
- package/gui/dist/classic/assets/App-BrIlUiLc.js +0 -58
- package/gui/dist/classic/assets/index-DyJHagvT.js +0 -94
- package/src/server/management/desktop-compatibility-authorization.ts +0 -12
package/src/link/child-parity.ts
CHANGED
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { CODEX_SETTINGS_DIGEST_PATTERN } from "./codex-settings";
|
|
16
16
|
import { LINK_MANAGEMENT_PREFIX } from "./management-routes";
|
|
17
|
+
import { parseRouteClientOutcomes, ROUTE_INTENT_DIGEST_PATTERN, routeClientOutcomesForPeer, type RouteClientOutcome } from "./route-intent";
|
|
17
18
|
|
|
18
19
|
/** The one write a Child may send its Home over the link. */
|
|
19
20
|
export const LINK_CHILD_PARITY_PATH = `${LINK_MANAGEMENT_PREFIX}/child-parity`;
|
|
20
21
|
/** A report is four short fields; anything larger is refused while it is still being read. */
|
|
21
|
-
export const LINK_CHILD_PARITY_MAX_BYTES =
|
|
22
|
+
export const LINK_CHILD_PARITY_MAX_BYTES = 8192;
|
|
22
23
|
|
|
23
24
|
const LINK_ID = /^lnk_[0-9a-f]{16}$/;
|
|
24
25
|
/** 2001-09-09 .. 2286-11-20: any epoch-millisecond time a real clock reports. */
|
|
@@ -33,6 +34,8 @@ export interface LinkChildParityReport {
|
|
|
33
34
|
runtimeStartedAt: number;
|
|
34
35
|
/** `appliedCodexSettingsDigest` of the applied settings; null before any apply. */
|
|
35
36
|
appliedCodexSettingsDigest: string | null;
|
|
37
|
+
appliedRouteIntentDigest?: string | null;
|
|
38
|
+
routeClientOutcomes?: RouteClientOutcome[];
|
|
36
39
|
/**
|
|
37
40
|
* Increases with every report this runtime process sends. With `runtimeStartedAt` it orders
|
|
38
41
|
* reports, so a late POST from an older runtime or an earlier send never replaces a newer one.
|
|
@@ -45,6 +48,8 @@ export interface LinkChildParity {
|
|
|
45
48
|
lastApplyAt: number | null;
|
|
46
49
|
runtimeStartedAt: number | null;
|
|
47
50
|
appliedCodexSettingsDigest: string | null;
|
|
51
|
+
appliedRouteIntentDigest?: string | null;
|
|
52
|
+
routeClientOutcomes?: RouteClientOutcome[];
|
|
48
53
|
/** Epoch ms the Home received the report (the Home's clock; the other times are the Child's). */
|
|
49
54
|
reportedAt: number | null;
|
|
50
55
|
}
|
|
@@ -65,7 +70,9 @@ function exactKeys(value: unknown, keys: readonly string[]): value is Record<str
|
|
|
65
70
|
|
|
66
71
|
/** Strict: an unknown field, a non-integer time or a malformed digest rejects the report. */
|
|
67
72
|
export function parseLinkChildParityReport(value: unknown): LinkChildParityReport | null {
|
|
68
|
-
|
|
73
|
+
const base = ["linkId", "lastApplyAt", "runtimeStartedAt", "appliedCodexSettingsDigest", "sequence"];
|
|
74
|
+
const extended = [...base, "appliedRouteIntentDigest", "routeClientOutcomes"];
|
|
75
|
+
if (!exactKeys(value, base) && !exactKeys(value, extended)) return null;
|
|
69
76
|
const { linkId, lastApplyAt, runtimeStartedAt, appliedCodexSettingsDigest: digest, sequence } = value;
|
|
70
77
|
if (typeof linkId !== "string" || !LINK_ID.test(linkId)) return null;
|
|
71
78
|
if (lastApplyAt !== null && !isEpochMs(lastApplyAt)) return null;
|
|
@@ -74,7 +81,15 @@ export function parseLinkChildParityReport(value: unknown): LinkChildParityRepor
|
|
|
74
81
|
// An apply has both a time and a digest; before the first apply it has neither.
|
|
75
82
|
if ((lastApplyAt === null) !== (digest === null)) return null;
|
|
76
83
|
if (typeof sequence !== "number" || !Number.isSafeInteger(sequence) || sequence < 0) return null;
|
|
77
|
-
|
|
84
|
+
let route: Pick<LinkChildParityReport, "appliedRouteIntentDigest" | "routeClientOutcomes"> = {};
|
|
85
|
+
if (Object.hasOwn(value, "appliedRouteIntentDigest")) {
|
|
86
|
+
const routeDigest = value.appliedRouteIntentDigest;
|
|
87
|
+
if (routeDigest !== null && (typeof routeDigest !== "string" || !ROUTE_INTENT_DIGEST_PATTERN.test(routeDigest))) return null;
|
|
88
|
+
const outcomes = parseRouteClientOutcomes(value.routeClientOutcomes);
|
|
89
|
+
if (!outcomes) return null;
|
|
90
|
+
route = { appliedRouteIntentDigest: routeDigest, routeClientOutcomes: routeClientOutcomesForPeer(outcomes) };
|
|
91
|
+
}
|
|
92
|
+
return { linkId, lastApplyAt, runtimeStartedAt, appliedCodexSettingsDigest: digest, sequence, ...route };
|
|
78
93
|
}
|
|
79
94
|
|
|
80
95
|
export interface LinkChildParityStore {
|
|
@@ -100,6 +115,10 @@ export function createLinkChildParityStore(now: () => number = Date.now): LinkCh
|
|
|
100
115
|
lastApplyAt: report.lastApplyAt,
|
|
101
116
|
runtimeStartedAt: report.runtimeStartedAt,
|
|
102
117
|
appliedCodexSettingsDigest: report.appliedCodexSettingsDigest,
|
|
118
|
+
...(report.routeClientOutcomes === undefined ? {} : {
|
|
119
|
+
appliedRouteIntentDigest: report.appliedRouteIntentDigest ?? null,
|
|
120
|
+
routeClientOutcomes: routeClientOutcomesForPeer(report.routeClientOutcomes),
|
|
121
|
+
}),
|
|
103
122
|
reportedAt: now(),
|
|
104
123
|
sequence: report.sequence,
|
|
105
124
|
});
|
|
@@ -109,7 +128,7 @@ export function createLinkChildParityStore(now: () => number = Date.now): LinkCh
|
|
|
109
128
|
const kept = reports.get(linkId);
|
|
110
129
|
if (!kept) return { ...EMPTY_LINK_CHILD_PARITY };
|
|
111
130
|
const { sequence: _sequence, ...parity } = kept;
|
|
112
|
-
return parity;
|
|
131
|
+
return { ...parity, ...(parity.routeClientOutcomes === undefined ? {} : { routeClientOutcomes: routeClientOutcomesForPeer(parity.routeClientOutcomes) }) };
|
|
113
132
|
},
|
|
114
133
|
clear() { reports.clear(); },
|
|
115
134
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { chmodSync, mkdirSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { atomicWriteFile } from "../config/atomic-write";
|
|
4
|
+
import { withConfigMutationLockSync } from "../config/mutation-lock";
|
|
5
|
+
import { assertNotRealHomeUnderTest } from "../lib/test-home-guard";
|
|
6
|
+
import { hardenSecretDir } from "../lib/windows-secret-acl";
|
|
7
|
+
import { linkDir } from "./paths";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* How this Home keeps its Children current (050), in <configDir>/link/child-policy.json, never in config.json. Strict,
|
|
11
|
+
* unlike the observation cache: an operator's opt-out lives here, so a damaged file must not read as the defaults.
|
|
12
|
+
*/
|
|
13
|
+
export const CHILD_POLICY_SCHEMA = "ocx.link.child-policy/1" as const;
|
|
14
|
+
export const CATALOG_FANOUT = ["auto", "manual"] as const;
|
|
15
|
+
export const CHILD_CODEX_RESTART = ["never", "app-server-when-idle"] as const;
|
|
16
|
+
export const CHILD_UPDATES = ["off", "notify", "auto-when-idle"] as const;
|
|
17
|
+
export const IDLE_AFTER_MIN_MS = 60_000;
|
|
18
|
+
export const IDLE_AFTER_MAX_MS = 3_600_000;
|
|
19
|
+
|
|
20
|
+
export interface ChildPolicy {
|
|
21
|
+
catalogFanout: typeof CATALOG_FANOUT[number];
|
|
22
|
+
childCodexRestart: typeof CHILD_CODEX_RESTART[number];
|
|
23
|
+
updates: typeof CHILD_UPDATES[number];
|
|
24
|
+
idleAfterMs: number;
|
|
25
|
+
}
|
|
26
|
+
export const DEFAULT_CHILD_POLICY: Readonly<ChildPolicy> = Object.freeze({
|
|
27
|
+
catalogFanout: "auto", childCodexRestart: "never", updates: "auto-when-idle", idleAfterMs: 600_000,
|
|
28
|
+
});
|
|
29
|
+
/** Revision 4 (4529522051): what a damaged or unreadable file means. Nothing automatic runs until the operator saves. */
|
|
30
|
+
export const FAIL_CLOSED_CHILD_POLICY: Readonly<ChildPolicy> = Object.freeze({
|
|
31
|
+
catalogFanout: "manual", childCodexRestart: "never", updates: "off", idleAfterMs: 600_000,
|
|
32
|
+
});
|
|
33
|
+
export type ChildPolicyWarning = "policy-file-invalid";
|
|
34
|
+
export interface ChildPolicyRead { policy: ChildPolicy; warning: ChildPolicyWarning | null }
|
|
35
|
+
const KEYS = ["schema", "catalogFanout", "childCodexRestart", "updates", "idleAfterMs"] as const;
|
|
36
|
+
|
|
37
|
+
export function childPolicyPath(configDir?: string): string {
|
|
38
|
+
return join(linkDir(configDir), "child-policy.json");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Field-wise check shared by the file reader and PUT; returns null on any unknown key or invalid value. */
|
|
42
|
+
export function validPolicyPatch(value: Record<string, unknown>): Partial<ChildPolicy> | null {
|
|
43
|
+
const out: Partial<ChildPolicy> = {};
|
|
44
|
+
for (const [key, v] of Object.entries(value)) {
|
|
45
|
+
if (key === "catalogFanout" && (CATALOG_FANOUT as readonly unknown[]).includes(v)) out.catalogFanout = v as ChildPolicy["catalogFanout"];
|
|
46
|
+
else if (key === "childCodexRestart" && (CHILD_CODEX_RESTART as readonly unknown[]).includes(v)) out.childCodexRestart = v as ChildPolicy["childCodexRestart"];
|
|
47
|
+
else if (key === "updates" && (CHILD_UPDATES as readonly unknown[]).includes(v)) out.updates = v as ChildPolicy["updates"];
|
|
48
|
+
else if (key === "idleAfterMs" && typeof v === "number" && Number.isSafeInteger(v) && v >= IDLE_AFTER_MIN_MS && v <= IDLE_AFTER_MAX_MS) out.idleAfterMs = v;
|
|
49
|
+
else return null;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const failClosed = (): ChildPolicyRead => ({ policy: { ...FAIL_CLOSED_CHILD_POLICY }, warning: "policy-file-invalid" });
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Absent file ⇒ defaults, no warning. Unreadable, unknown key or bad value ⇒ FAIL_CLOSED_CHILD_POLICY plus a warning.
|
|
58
|
+
* A damaged file is never rewritten here: the warning stays visible until the operator saves a policy.
|
|
59
|
+
*/
|
|
60
|
+
export function readChildPolicy(path = childPolicyPath()): ChildPolicyRead {
|
|
61
|
+
let text: string;
|
|
62
|
+
try { text = readFileSync(path, "utf8"); } catch (error) {
|
|
63
|
+
return (error as NodeJS.ErrnoException).code === "ENOENT" ? { policy: { ...DEFAULT_CHILD_POLICY }, warning: null } : failClosed();
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const parsed: unknown = JSON.parse(text);
|
|
67
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return failClosed();
|
|
68
|
+
const record = parsed as Record<string, unknown>;
|
|
69
|
+
if (record.schema !== CHILD_POLICY_SCHEMA || Object.keys(record).some(key => !(KEYS as readonly string[]).includes(key))) return failClosed();
|
|
70
|
+
const { schema: _schema, ...fields } = record;
|
|
71
|
+
const patch = validPolicyPatch(fields);
|
|
72
|
+
return patch ? { policy: { ...DEFAULT_CHILD_POLICY, ...patch }, warning: null } : failClosed();
|
|
73
|
+
} catch { return failClosed(); }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Read-merge-write under the config mutation lock; the file always holds every key. Same guard, directory mode and
|
|
78
|
+
* Windows ACL hardening as updateChildObservations (child-observations.ts). Over an invalid file the patch merges onto
|
|
79
|
+
* the fail-closed policy, so the operator chooses every automatic mode again.
|
|
80
|
+
*/
|
|
81
|
+
export function updateChildPolicy(patch: Partial<ChildPolicy>, path = childPolicyPath()): ChildPolicy {
|
|
82
|
+
const dir = dirname(path), configDir = dirname(dir);
|
|
83
|
+
assertNotRealHomeUnderTest(configDir);
|
|
84
|
+
return withConfigMutationLockSync(() => {
|
|
85
|
+
const next: ChildPolicy = { ...readChildPolicy(path).policy, ...patch };
|
|
86
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
87
|
+
if (process.platform === "win32") hardenSecretDir(dir, { required: true });
|
|
88
|
+
else chmodSync(dir, 0o700);
|
|
89
|
+
atomicWriteFile(path, `${JSON.stringify({ schema: CHILD_POLICY_SCHEMA, ...next }, null, 2)}\n`);
|
|
90
|
+
if (process.platform !== "win32") chmodSync(path, 0o600);
|
|
91
|
+
return next;
|
|
92
|
+
}, configDir);
|
|
93
|
+
}
|
|
@@ -114,8 +114,12 @@ export function parseChildUpdateResult(payload: string): ContractParse<ChildUpda
|
|
|
114
114
|
|
|
115
115
|
const GOAT_PATHS = ["/.local/share/goat/opencodex/", "\\.local\\share\\goat\\opencodex\\"];
|
|
116
116
|
|
|
117
|
-
/**
|
|
118
|
-
|
|
117
|
+
/**
|
|
118
|
+
* First matching row wins (010 "classifyChildUpdatePlan"). launcher (A4) is the plan probe's report of a Node that can
|
|
119
|
+
* run the package launcher; absent or null means no report. Only an npm or pnpm plan read through a census pair uses it.
|
|
120
|
+
*/
|
|
121
|
+
export function classifyChildUpdatePlan(plan: ChildUpdatePlan, ctx: { homeVersion: string; desktopUpdateRequest: boolean; entry: "pair" | "binary" | null;
|
|
122
|
+
launcher?: "available" | "unavailable" | null }): PlanClassification {
|
|
119
123
|
const row = (installKind: InstallKind, updateRoute: UpdateRoute, updateReason: string | null): PlanClassification => ({
|
|
120
124
|
installKind, updateRoute, updateReason, installedVersion: plan.currentVersion === "unknown" ? null : plan.currentVersion,
|
|
121
125
|
targetVersion: plan.targetVersion, runtimeOwner: plan.runtimeOwner, planToken: plan.planToken, updateInFlight: plan.updateInFlight,
|
|
@@ -126,7 +130,12 @@ export function classifyChildUpdatePlan(plan: ChildUpdatePlan, ctx: { homeVersio
|
|
|
126
130
|
if (plan.installer === "unknown" && GOAT_PATHS.some(marker => path.includes(marker))) return row("goat", "owner-action", "goat");
|
|
127
131
|
if (plan.reason === "up-to-date") return row(installer, "none", "up-to-date");
|
|
128
132
|
if (plan.canApply && plan.targetVersion !== ctx.homeVersion) return row(installer, "none", "target-mismatch");
|
|
129
|
-
if (plan.canApply && (plan.installer === "npm" || plan.installer === "pnpm") && ctx.entry === "pair")
|
|
133
|
+
if (plan.canApply && (plan.installer === "npm" || plan.installer === "pnpm") && ctx.entry === "pair") {
|
|
134
|
+
// A4: the apply goes through <node> <root>/bin/ocx.mjs, so it needs the Node the plan probe found.
|
|
135
|
+
if (ctx.launcher === "available") return row(installer, "orchestrated", null);
|
|
136
|
+
if (ctx.launcher === "unavailable") return row(installer, "owner-action", "launcher-node-missing");
|
|
137
|
+
return row(installer, "owner-action", "launcher-bypassed");
|
|
138
|
+
}
|
|
130
139
|
if (plan.canApply) return row(installer, "orchestrated", null);
|
|
131
140
|
if (plan.reason === "desktop-app-owned") return row("desktop-app", ctx.desktopUpdateRequest ? "desktop-request" : "owner-action", "desktop-app-owned");
|
|
132
141
|
if (plan.reason === "mise-managed") return row("mise", "owner-action", "mise-managed");
|
|
@@ -28,7 +28,7 @@ import { hostname } from "node:os";
|
|
|
28
28
|
import type { OcxConfig } from "../types";
|
|
29
29
|
|
|
30
30
|
export const HOME_CODEX_SETTINGS_VERSION = 1;
|
|
31
|
-
const MULTI_AGENT_MODES = ["v1", "default", "v2"] as const;
|
|
31
|
+
const MULTI_AGENT_MODES = ["v1", "default", "v2", "v2-plaintext"] as const;
|
|
32
32
|
type MultiAgentMode = (typeof MULTI_AGENT_MODES)[number];
|
|
33
33
|
|
|
34
34
|
export interface HomeCodexSettings {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { LINK_RELAY_AUTH_VERSION } from "./relay-auth";
|
|
12
12
|
import { LINK_PEER_REPORT_VERSION, type LinkPeerEntry } from "./peer-report";
|
|
13
|
+
import { LINK_REQUEST_ZSTD_FEATURE } from "./request-compression";
|
|
13
14
|
|
|
14
15
|
export interface LinkProtocolRelease {
|
|
15
16
|
/** The peer feature id, as `GET /readyz` lists it. */
|
|
@@ -25,8 +26,24 @@ export const LINK_PROTOCOL_RELEASES: readonly LinkProtocolRelease[] = [
|
|
|
25
26
|
{ id: "relay-auth/2", since: "2.69.0", summary: "Connection-bound relay authentication before every relayed request." },
|
|
26
27
|
{ id: "link-management-relay", since: "2.84.0", summary: "Read-only Home management and Home Codex settings for the Child." },
|
|
27
28
|
{ id: LINK_PEER_REPORT_FEATURE, since: "2.91.0", summary: "The Child reports its version and features on the relay challenge." },
|
|
29
|
+
// The dev line's version when this landed; 2.100.x was already tagged, so the release that first
|
|
30
|
+
// ships it moves this to its own number (the test holds `since` at or below the package version).
|
|
31
|
+
{ id: LINK_REQUEST_ZSTD_FEATURE, since: "2.100.0", summary: "The Home decodes per-body zstd request bodies and the Child sends them." },
|
|
28
32
|
];
|
|
29
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Features a Child uses only when its Home names them on the link, and otherwise works without:
|
|
36
|
+
* per-body zstd falls back to identity bodies. A Child leaves them out of its peer report, because
|
|
37
|
+
* a Home that predates one counts every feature it does not serve as used and would tell the owner
|
|
38
|
+
* to upgrade it, and a Home never counts one against itself.
|
|
39
|
+
*/
|
|
40
|
+
export const LINK_OPTIONAL_CHILD_FEATURES: ReadonlySet<string> = new Set([LINK_REQUEST_ZSTD_FEATURE]);
|
|
41
|
+
|
|
42
|
+
/** The feature ids a Child reports on the relay challenge. */
|
|
43
|
+
export function linkChildReportFeatures(features: readonly string[]): string[] {
|
|
44
|
+
return features.filter(id => !LINK_OPTIONAL_CHILD_FEATURES.has(id));
|
|
45
|
+
}
|
|
46
|
+
|
|
30
47
|
export type LinkCompatibilityVerdict = "compatible" | "degraded" | "incompatible" | "unknown";
|
|
31
48
|
|
|
32
49
|
export interface LinkLocalPeer {
|
|
@@ -100,7 +117,7 @@ export function linkPeerStatus(local: LinkLocalPeer, entry: LinkPeerEntry): Link
|
|
|
100
117
|
reasons: [`relay-auth/${observed.relayAuth} matches, but the Child's ${observed.version === null && observed.features === null ? "version and feature list were" : observed.version === null ? "version was" : "feature list was"} missing or invalid, so its features cannot be checked.`],
|
|
101
118
|
};
|
|
102
119
|
}
|
|
103
|
-
const childOnly = observed.features.filter(id => !local.features.includes(id));
|
|
120
|
+
const childOnly = observed.features.filter(id => !local.features.includes(id) && !LINK_OPTIONAL_CHILD_FEATURES.has(id));
|
|
104
121
|
if (childOnly.length > 0) {
|
|
105
122
|
return {
|
|
106
123
|
...base, version: observed.version, versionRange: null, compatibility: "degraded",
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read-only view of the bounded Remote Link diagnostics file that `diagnostics.ts` writes:
|
|
3
|
+
* `<configDir>/link/diagnostics.jsonl` and its one rotated backup, `diagnostics.jsonl.1`.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here creates, hardens, truncates or rewrites anything. A file is read only when it is a
|
|
6
|
+
* regular file reached without following a symlink (the link directory included), at most its
|
|
7
|
+
* newest 256 KiB, and every line goes back through the writer's own allowlist
|
|
8
|
+
* (`linkDiagnosticMetadata`) plus the two fields the sink adds, `timestamp` and `suppressed`.
|
|
9
|
+
* The file is never trusted: a line that does not survive the allowlist is counted in `skipped`
|
|
10
|
+
* and never echoed, so a tampered file cannot inject text into a terminal or the dashboard.
|
|
11
|
+
*/
|
|
12
|
+
import { constants, type BigIntStats } from "node:fs";
|
|
13
|
+
import { lstat, open } from "node:fs/promises";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import { linkDiagnosticMetadata, type LinkDiagnosticRecord } from "./diagnostics";
|
|
16
|
+
import { linkDir } from "./paths";
|
|
17
|
+
|
|
18
|
+
export const LINK_DIAGNOSTICS_SCHEMA = "ocx.link.diagnostics/1";
|
|
19
|
+
export const LINK_DIAGNOSTICS_DEFAULT_LIMIT = 200;
|
|
20
|
+
export const LINK_DIAGNOSTICS_MAX_LIMIT = 1000;
|
|
21
|
+
/** The writer's per-file cap; a larger file has been tampered with or predates the cap. */
|
|
22
|
+
const MAX_FILE_BYTES = 256 * 1024;
|
|
23
|
+
/** A written record is well under 1 KiB; anything this long was not written by the sink. */
|
|
24
|
+
const MAX_LINE_BYTES = 4 * 1024;
|
|
25
|
+
/** The latest time a JavaScript Date can hold; a larger timestamp would throw when shown. */
|
|
26
|
+
const MAX_DATE_MS = 8_640_000_000_000_000;
|
|
27
|
+
const FILE_NAMES = ["diagnostics.jsonl.1", "diagnostics.jsonl"] as const;
|
|
28
|
+
|
|
29
|
+
export type LinkDiagnosticEntry = LinkDiagnosticRecord & { timestamp?: number; suppressed?: number };
|
|
30
|
+
export type LinkDiagnosticsFileName = typeof FILE_NAMES[number];
|
|
31
|
+
/** `refused`: a symlink, a non-regular file, or a file under a symlinked link directory. */
|
|
32
|
+
export type LinkDiagnosticsFileState = "absent" | "read" | "refused" | "unreadable";
|
|
33
|
+
export interface LinkDiagnosticsFileReport { name: LinkDiagnosticsFileName; state: LinkDiagnosticsFileState; truncated: boolean }
|
|
34
|
+
export interface LinkDiagnosticsReadResult {
|
|
35
|
+
/** Backup first, then the current file, each in line order; the newest `limit` matches. */
|
|
36
|
+
records: LinkDiagnosticEntry[];
|
|
37
|
+
/** Records that matched `since` before `limit` was applied. */
|
|
38
|
+
matched: number;
|
|
39
|
+
/** Lines that were malformed, overlong, cut by the size bound or outside the allowlist. */
|
|
40
|
+
skipped: number;
|
|
41
|
+
files: LinkDiagnosticsFileReport[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The current diagnostics file, for messages; the reader derives both paths from the link directory. */
|
|
45
|
+
export function linkDiagnosticsPath(configDir?: string): string {
|
|
46
|
+
return join(linkDir(configDir), "diagnostics.jsonl");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function isPlainRecord(value: unknown): value is Record<string, unknown> {
|
|
50
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** One parsed line through the writer's allowlist, plus the sink's `timestamp` and `suppressed`. */
|
|
54
|
+
export function sanitizeLinkDiagnosticEntry(value: unknown): LinkDiagnosticEntry | null {
|
|
55
|
+
if (!isPlainRecord(value)) return null;
|
|
56
|
+
const base = linkDiagnosticMetadata(value as unknown as LinkDiagnosticRecord);
|
|
57
|
+
if (!base) return null;
|
|
58
|
+
const entry: LinkDiagnosticEntry = base;
|
|
59
|
+
const { timestamp, suppressed } = value;
|
|
60
|
+
if (typeof timestamp === "number" && Number.isSafeInteger(timestamp) && timestamp >= 0 && timestamp <= MAX_DATE_MS) entry.timestamp = timestamp;
|
|
61
|
+
if (typeof suppressed === "number" && Number.isSafeInteger(suppressed) && suppressed >= 1) entry.suppressed = suppressed;
|
|
62
|
+
return entry;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function errorCode(error: unknown): string | undefined {
|
|
66
|
+
return error && typeof error === "object" && "code" in error && typeof error.code === "string" ? error.code : undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function sameObject(named: BigIntStats, opened: BigIntStats): boolean {
|
|
70
|
+
return opened.isFile() && named.dev === opened.dev && named.ino === opened.ino;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type FileRead = { state: LinkDiagnosticsFileState; text: string; truncated: boolean };
|
|
74
|
+
|
|
75
|
+
async function readBounded(path: string): Promise<FileRead> {
|
|
76
|
+
const none = (state: LinkDiagnosticsFileState): FileRead => ({ state, text: "", truncated: false });
|
|
77
|
+
let named: BigIntStats;
|
|
78
|
+
try { named = await lstat(path, { bigint: true }); }
|
|
79
|
+
catch (error) { return none(errorCode(error) === "ENOENT" ? "absent" : "unreadable"); }
|
|
80
|
+
if (named.isSymbolicLink() || !named.isFile()) return none("refused");
|
|
81
|
+
let handle: Awaited<ReturnType<typeof open>>;
|
|
82
|
+
try {
|
|
83
|
+
// Read-only, no-follow and non-blocking: a symlink or FIFO swapped in after lstat fails here
|
|
84
|
+
// or is caught by the identity check below, and nothing is ever created.
|
|
85
|
+
handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const code = errorCode(error);
|
|
88
|
+
return none(code === "ENOENT" ? "absent" : code === "ELOOP" ? "refused" : "unreadable");
|
|
89
|
+
}
|
|
90
|
+
try {
|
|
91
|
+
const opened = await handle.stat({ bigint: true });
|
|
92
|
+
if (!sameObject(named, opened)) return none("refused");
|
|
93
|
+
const size = Number(opened.size);
|
|
94
|
+
const length = Math.min(size, MAX_FILE_BYTES);
|
|
95
|
+
const position = size - length;
|
|
96
|
+
const buffer = Buffer.alloc(length);
|
|
97
|
+
let offset = 0;
|
|
98
|
+
while (offset < length) {
|
|
99
|
+
const { bytesRead } = await handle.read(buffer, offset, length - offset, position + offset);
|
|
100
|
+
if (bytesRead === 0) break;
|
|
101
|
+
offset += bytesRead;
|
|
102
|
+
}
|
|
103
|
+
return { state: "read", text: buffer.subarray(0, offset).toString("utf8"), truncated: position > 0 };
|
|
104
|
+
} catch {
|
|
105
|
+
return none("unreadable");
|
|
106
|
+
} finally {
|
|
107
|
+
await handle.close().catch(() => undefined);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The link directory must be a real directory; a symlinked one is not followed. */
|
|
112
|
+
async function linkDirectoryState(dir: string): Promise<"present" | "absent" | "refused" | "unreadable"> {
|
|
113
|
+
try {
|
|
114
|
+
const info = await lstat(dir);
|
|
115
|
+
return info.isDirectory() && !info.isSymbolicLink() ? "present" : "refused";
|
|
116
|
+
} catch (error) {
|
|
117
|
+
return errorCode(error) === "ENOENT" ? "absent" : "unreadable";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function clampLimit(limit: number | undefined): number {
|
|
122
|
+
if (limit === undefined || !Number.isFinite(limit)) return LINK_DIAGNOSTICS_DEFAULT_LIMIT;
|
|
123
|
+
return Math.min(LINK_DIAGNOSTICS_MAX_LIMIT, Math.max(1, Math.trunc(limit)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Read both diagnostics files without changing anything. `since` keeps records whose timestamp is
|
|
128
|
+
* at or after it (records without one are left out); `limit` keeps the newest matches and is
|
|
129
|
+
* clamped to 1..LINK_DIAGNOSTICS_MAX_LIMIT.
|
|
130
|
+
*/
|
|
131
|
+
export async function readLinkDiagnostics(
|
|
132
|
+
{ configDir, limit, since }: { configDir?: string; limit?: number; since?: number } = {},
|
|
133
|
+
): Promise<LinkDiagnosticsReadResult> {
|
|
134
|
+
const dir = linkDir(configDir);
|
|
135
|
+
const directory = await linkDirectoryState(dir);
|
|
136
|
+
const files: LinkDiagnosticsFileReport[] = [];
|
|
137
|
+
const records: LinkDiagnosticEntry[] = [];
|
|
138
|
+
let skipped = 0;
|
|
139
|
+
for (const name of FILE_NAMES) {
|
|
140
|
+
const read = directory === "present" ? await readBounded(join(dir, name))
|
|
141
|
+
: { state: directory, text: "", truncated: false } as FileRead;
|
|
142
|
+
files.push({ name, state: read.state, truncated: read.truncated });
|
|
143
|
+
if (read.state !== "read") continue;
|
|
144
|
+
const lines = read.text.split("\n");
|
|
145
|
+
// A size-bounded read starts mid-line; that fragment is not a record.
|
|
146
|
+
if (read.truncated && lines.length > 0) {
|
|
147
|
+
lines.shift();
|
|
148
|
+
skipped += 1;
|
|
149
|
+
}
|
|
150
|
+
for (const raw of lines) {
|
|
151
|
+
if (raw.trim() === "") continue;
|
|
152
|
+
if (Buffer.byteLength(raw) > MAX_LINE_BYTES) { skipped += 1; continue; }
|
|
153
|
+
let parsed: unknown;
|
|
154
|
+
try { parsed = JSON.parse(raw); } catch { skipped += 1; continue; }
|
|
155
|
+
const entry = sanitizeLinkDiagnosticEntry(parsed);
|
|
156
|
+
if (!entry) { skipped += 1; continue; }
|
|
157
|
+
if (since !== undefined && (entry.timestamp === undefined || entry.timestamp < since)) continue;
|
|
158
|
+
records.push(entry);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const kept = clampLimit(limit);
|
|
162
|
+
return { records: records.slice(-kept), matched: records.length, skipped, files };
|
|
163
|
+
}
|
package/src/link/diagnostics.ts
CHANGED
|
@@ -7,13 +7,19 @@ import { linkDir } from "./paths";
|
|
|
7
7
|
import type { TunnelState } from "./tunnel-state";
|
|
8
8
|
|
|
9
9
|
export type LinkDiagnosticRecord = {
|
|
10
|
-
event: "owner_lookup" | "relay_retry" | "relay_failure" | "relay_recovered" | "tunnel_transition"
|
|
10
|
+
event: "owner_lookup" | "relay_retry" | "relay_failure" | "relay_recovered" | "tunnel_transition"
|
|
11
|
+
// The Child's link WebSocket (src/client/link-websocket.ts): opened, closed (why), or answered for HTTP (why).
|
|
12
|
+
| "link_ws_open" | "link_ws_close" | "link_ws_fallback";
|
|
11
13
|
outcome: "match" | "mismatch" | "lookup_error" | "deadline" | "stale" | "unavailable"
|
|
12
14
|
| "identity_unknown" | "identity_mismatch" | "auth_timeout" | "auth_failed"
|
|
13
15
|
| "transport_error" | "client_abort" | "header_timeout" | "recovered"
|
|
14
16
|
// tunnel_transition: the Home's -R tunnel changed state, and why (src/link/tunnel-history.ts).
|
|
15
17
|
| "connected" | "spawned" | "stopped" | "auth" | "hostkey" | "forward" | "remote_forward_conflict"
|
|
16
|
-
| "timeout" | "network" | "unknown" | "spawn_failed" | "listener_unavailable"
|
|
18
|
+
| "timeout" | "network" | "unknown" | "spawn_failed" | "listener_unavailable"
|
|
19
|
+
// link_ws_fallback and link_ws_close reasons.
|
|
20
|
+
| "local_optout" | "origin" | "credential" | "cap" | "memory" | "tunnel_failed" | "tunnel_connecting_timeout" | "preflight"
|
|
21
|
+
| "not_advertised" | "home_refused" | "handshake" | "aborted" | "draining"
|
|
22
|
+
| "client" | "home" | "home_dropped" | "binary" | "protocol" | "overload";
|
|
17
23
|
requestId?: string;
|
|
18
24
|
checkId?: string;
|
|
19
25
|
generation?: number;
|
|
@@ -26,20 +32,27 @@ export type LinkDiagnosticRecord = {
|
|
|
26
32
|
};
|
|
27
33
|
export type LinkDiagnosticSink = (record: LinkDiagnosticRecord) => void;
|
|
28
34
|
|
|
29
|
-
const EVENTS = new Set(["owner_lookup", "relay_retry", "relay_failure", "relay_recovered", "tunnel_transition"]);
|
|
35
|
+
const EVENTS = new Set(["owner_lookup", "relay_retry", "relay_failure", "relay_recovered", "tunnel_transition", "link_ws_open", "link_ws_close", "link_ws_fallback"]);
|
|
30
36
|
const OUTCOMES = new Set([
|
|
31
37
|
"match", "mismatch", "lookup_error", "deadline", "stale", "unavailable", "identity_unknown",
|
|
32
38
|
"identity_mismatch", "auth_timeout", "auth_failed", "transport_error", "client_abort", "header_timeout", "recovered",
|
|
33
39
|
"connected", "spawned", "stopped", "auth", "hostkey", "forward", "remote_forward_conflict", "timeout", "network",
|
|
34
40
|
"unknown", "spawn_failed", "listener_unavailable",
|
|
41
|
+
"local_optout", "origin", "credential", "cap", "memory", "tunnel_failed", "tunnel_connecting_timeout", "preflight",
|
|
42
|
+
"not_advertised", "home_refused", "handshake", "aborted", "draining",
|
|
43
|
+
"client", "home", "home_dropped", "binary", "protocol", "overload",
|
|
35
44
|
]);
|
|
36
45
|
const STATES = new Set<TunnelState["kind"]>(["idle", "connecting", "connected", "reconnecting", "failed"]);
|
|
37
46
|
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
38
47
|
const MAX_BYTES = 256 * 1024;
|
|
39
48
|
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Copy only bounded enum, UUID and numeric fields; unknown fields never reach disk. The reader
|
|
51
|
+
* (`diagnostics-read.ts`) applies the same function to every line it parses, so a tampered file
|
|
52
|
+
* cannot put anything on a terminal or dashboard that this allowlist would not have written.
|
|
53
|
+
*/
|
|
54
|
+
export function linkDiagnosticMetadata(record: LinkDiagnosticRecord): LinkDiagnosticRecord | null {
|
|
55
|
+
if (!record || typeof record !== "object") return null;
|
|
43
56
|
const { event, outcome, state, previousState } = record;
|
|
44
57
|
if (!EVENTS.has(event) || !OUTCOMES.has(outcome)) return null;
|
|
45
58
|
const result: LinkDiagnosticRecord = { event, outcome };
|
|
@@ -143,7 +156,7 @@ export function createLinkDiagnosticSink(
|
|
|
143
156
|
};
|
|
144
157
|
const sink: LinkDiagnosticSink = record => {
|
|
145
158
|
try {
|
|
146
|
-
const safe =
|
|
159
|
+
const safe = linkDiagnosticMetadata(record);
|
|
147
160
|
if (!safe) return;
|
|
148
161
|
const at = now();
|
|
149
162
|
if (!Number.isSafeInteger(at) || at < 0) return;
|