@bitkyc08/opencodex 2.65.0-preview.20260925 → 2.66.0-preview.20260925

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.
Files changed (213) hide show
  1. package/README.md +14 -0
  2. package/gui/dist/assets/App-BVjA0T6O.js +51 -0
  3. package/gui/dist/assets/App-gkoJIEOV.css +1 -0
  4. package/gui/dist/assets/{Tray-DUvc_Wul.js → Tray-BCFtiWwD.js} +1 -1
  5. package/gui/dist/assets/index-ComVsdSk.css +1 -0
  6. package/gui/dist/assets/index-vO4dgfiU.js +86 -0
  7. package/gui/dist/assets/{tray-data-f0lTZ4sF.js → tray-data-C4FiNaxk.js} +1 -1
  8. package/gui/dist/index.html +2 -2
  9. package/package.json +1 -2
  10. package/src/adapters/anthropic/beta-allowlist.ts +80 -0
  11. package/src/adapters/anthropic/passthrough.ts +221 -0
  12. package/src/adapters/anthropic-image-codec.ts +56 -19
  13. package/src/adapters/anthropic-image-normalize.ts +20 -10
  14. package/src/adapters/anthropic.ts +55 -24
  15. package/src/adapters/coding-agent/protocol.ts +29 -19
  16. package/src/adapters/cursor/live-transport.ts +18 -3
  17. package/src/adapters/cursor/native-exec-shell.ts +18 -63
  18. package/src/adapters/cursor/native-exec.ts +5 -2
  19. package/src/adapters/cursor/native-foreground-shell.ts +44 -0
  20. package/src/adapters/devin/cloud-direct/chat.ts +7 -1
  21. package/src/adapters/exec-tool-result-normalize.ts +4 -1
  22. package/src/adapters/google.ts +12 -0
  23. package/src/adapters/ollama-native.ts +32 -1
  24. package/src/adapters/openai-chat/serialized-tool-call-content.ts +131 -34
  25. package/src/adapters/openai-chat.ts +6 -4
  26. package/src/adapters/openai-responses/passthrough.ts +1 -0
  27. package/src/adapters/openai-responses/reasoning.ts +45 -1
  28. package/src/bridge/response-json.ts +10 -2
  29. package/src/chat/outbound.ts +104 -52
  30. package/src/claude/claude-code-block.ts +16 -0
  31. package/src/claude/context-windows.ts +52 -4
  32. package/src/claude/desktop-first-party.ts +25 -8
  33. package/src/claude/inbound.ts +22 -0
  34. package/src/claude/intercept/connect-proxy.ts +37 -4
  35. package/src/claude/intercept/proxy-auth.ts +166 -0
  36. package/src/claude/intercept/runtime.ts +21 -0
  37. package/src/claude/intercept/settings.ts +33 -12
  38. package/src/claude/outbound.ts +45 -27
  39. package/src/cli/account-extended.ts +47 -15
  40. package/src/cli/account-target.ts +115 -0
  41. package/src/cli/account.ts +20 -28
  42. package/src/cli/agent.ts +10 -1
  43. package/src/cli/api-protocols.ts +206 -0
  44. package/src/cli/capabilities.ts +86 -0
  45. package/src/cli/combo.ts +2 -2
  46. package/src/cli/connect.ts +127 -3
  47. package/src/cli/dispatch.ts +8 -0
  48. package/src/cli/doctor.ts +33 -0
  49. package/src/cli/help.ts +2 -0
  50. package/src/cli/link.ts +288 -0
  51. package/src/cli/registry.ts +23 -0
  52. package/src/cli/runtime-api.ts +79 -0
  53. package/src/cli/system-command.ts +21 -2
  54. package/src/client/connect.ts +125 -23
  55. package/src/client/hub-relay.ts +12 -8
  56. package/src/client/link-join.ts +323 -0
  57. package/src/client/link-relay.ts +241 -0
  58. package/src/client/link-state.ts +110 -0
  59. package/src/client/link-teardown.ts +63 -0
  60. package/src/client/link-tunnel.ts +465 -0
  61. package/src/client/machine-listener.ts +14 -5
  62. package/src/client/runtime.ts +91 -42
  63. package/src/client/state.ts +4 -0
  64. package/src/codex/catalog/build-entries.ts +4 -0
  65. package/src/codex/catalog/derive-entry.ts +5 -0
  66. package/src/codex/catalog/parsing.ts +4 -0
  67. package/src/codex/catalog/retained-sync.ts +4 -1
  68. package/src/codex/desktop-switches.ts +88 -8
  69. package/src/codex/inject/plan.ts +16 -3
  70. package/src/codex/inject.ts +3 -0
  71. package/src/codex/internal/catalog-writer.ts +13 -2
  72. package/src/combos/failover.ts +3 -2
  73. package/src/combos/index.ts +12 -0
  74. package/src/combos/jev.ts +646 -0
  75. package/src/combos/request.ts +5 -0
  76. package/src/combos/resolve.ts +17 -15
  77. package/src/combos/types.ts +47 -3
  78. package/src/config/atomic-write.ts +3 -0
  79. package/src/config/live-reconcile.ts +20 -4
  80. package/src/config/persist-unlocked.ts +20 -7
  81. package/src/config/schema/config-schema.ts +16 -0
  82. package/src/config/schema/leaf-validators.ts +38 -1
  83. package/src/generated/compatibility-version.json +416 -128
  84. package/src/integrations/omp-yaml-source.ts +109 -4
  85. package/src/lab/automation/orchestrator.ts +60 -4
  86. package/src/lab/events/limits.ts +1 -1
  87. package/src/lib/bounded-body.ts +55 -38
  88. package/src/lib/config-ownership.ts +11 -22
  89. package/src/lib/local-desktop-snapshot-capability.ts +56 -0
  90. package/src/lib/local-management-capability.ts +25 -3
  91. package/src/lib/optional-shutdown-hooks.ts +17 -0
  92. package/src/lib/state-store-registrations.ts +2 -2
  93. package/src/lib/windows-elevation.ts +62 -25
  94. package/src/lib/windows-secret-acl.ts +114 -23
  95. package/src/link/admission-wait.ts +73 -0
  96. package/src/link/compensation.ts +100 -0
  97. package/src/link/fingerprint.ts +21 -0
  98. package/src/link/paths.ts +19 -0
  99. package/src/link/ports.ts +12 -0
  100. package/src/link/routes.ts +32 -0
  101. package/src/link/ssh-argv.ts +170 -0
  102. package/src/link/ssh-config.ts +152 -0
  103. package/src/link/ssh-runner.ts +161 -0
  104. package/src/link/status-projection.ts +96 -0
  105. package/src/link/store.ts +139 -0
  106. package/src/link/supervisor.ts +404 -0
  107. package/src/link/tunnel-state.ts +91 -0
  108. package/src/protocols/baseline.ts +88 -0
  109. package/src/protocols/codecs/chat.ts +17 -0
  110. package/src/protocols/codecs/messages.ts +18 -0
  111. package/src/protocols/codecs/responses.ts +17 -0
  112. package/src/protocols/contract.ts +185 -0
  113. package/src/protocols/dto.ts +267 -0
  114. package/src/protocols/encoders/adapter-events.ts +876 -0
  115. package/src/protocols/encoders/chat.ts +243 -0
  116. package/src/protocols/encoders/messages.ts +462 -0
  117. package/src/protocols/envelope.ts +43 -0
  118. package/src/protocols/features.ts +295 -0
  119. package/src/protocols/guard.ts +33 -0
  120. package/src/protocols/opaque-state.ts +132 -0
  121. package/src/protocols/path.ts +39 -0
  122. package/src/protocols/plan-snapshot.ts +226 -0
  123. package/src/protocols/plan.ts +192 -0
  124. package/src/protocols/provider-summary.ts +101 -0
  125. package/src/protocols/settings.ts +118 -0
  126. package/src/protocols/shadow-plan.ts +36 -0
  127. package/src/protocols/shadow.ts +62 -0
  128. package/src/protocols/trace.ts +335 -0
  129. package/src/providers/model-rename-migration.ts +3 -3
  130. package/src/providers/registry/entries-core.ts +6 -1
  131. package/src/providers/registry/entries-extended.ts +15 -0
  132. package/src/providers/registry/model-ids.ts +1 -0
  133. package/src/providers/registry/types.ts +6 -0
  134. package/src/providers/registry.ts +1 -1
  135. package/src/remote-control/workspace-hub.ts +5 -4
  136. package/src/responses/apply-patch-envelope.ts +6 -1
  137. package/src/responses/code-mode-shell-input.ts +4 -2
  138. package/src/responses/freeform-wrapper-scan.ts +51 -24
  139. package/src/responses/progressive-freeform-input.ts +14 -20
  140. package/src/responses/spill-store.ts +187 -33
  141. package/src/responses/state/snapshot-select.ts +49 -0
  142. package/src/responses/state/spill-inspect.ts +46 -0
  143. package/src/responses/state/spill-queue.ts +16 -0
  144. package/src/responses/state.ts +51 -27
  145. package/src/server/audio-client.ts +8 -3
  146. package/src/server/audio-upstream.ts +9 -4
  147. package/src/server/auth-cors.ts +25 -8
  148. package/src/server/chat-completions.ts +71 -11
  149. package/src/server/chat-native-eligibility.ts +74 -0
  150. package/src/server/chat-native.ts +139 -74
  151. package/src/server/claude-messages.ts +140 -22
  152. package/src/server/hub-usage.ts +4 -3
  153. package/src/server/index/link-listener.ts +195 -0
  154. package/src/server/index/optional-listeners.ts +115 -0
  155. package/src/server/index/serve-options.ts +44 -10
  156. package/src/server/index.ts +10 -9
  157. package/src/server/inference/attempt.ts +51 -0
  158. package/src/server/inference/client-encoder-delivery.ts +235 -0
  159. package/src/server/inference/client-wire-log.ts +49 -0
  160. package/src/server/inference/client-wire.ts +69 -0
  161. package/src/server/inference/context.ts +15 -0
  162. package/src/server/inference/final-log.ts +37 -0
  163. package/src/server/local-desktop-snapshot-auth.ts +57 -0
  164. package/src/server/management/agent-settings-routes.ts +15 -13
  165. package/src/server/management/api-access.ts +11 -1
  166. package/src/server/management/config-routes.ts +3 -6
  167. package/src/server/management/context.ts +25 -0
  168. package/src/server/management/link-routes.ts +535 -0
  169. package/src/server/management/logs-usage-routes.ts +31 -1
  170. package/src/server/management/native-integration-routes.ts +6 -11
  171. package/src/server/management/oauth-account-routes.ts +42 -16
  172. package/src/server/management/protocol-routes.ts +159 -0
  173. package/src/server/management/protocol-settings-patch.ts +145 -0
  174. package/src/server/management/provider-patch-transaction.ts +61 -0
  175. package/src/server/management/provider-routes.ts +39 -18
  176. package/src/server/management/route-registry.ts +12 -0
  177. package/src/server/management/sidebar-routes.ts +8 -3
  178. package/src/server/management/system-routes.ts +18 -1
  179. package/src/server/management/usage-aggregate-cache.ts +206 -6
  180. package/src/server/management-api.ts +26 -1
  181. package/src/server/management-auth.ts +19 -5
  182. package/src/server/messages-native-eligibility.ts +161 -0
  183. package/src/server/messages-native-oauth.ts +149 -0
  184. package/src/server/messages-native.ts +790 -0
  185. package/src/server/relay.ts +9 -0
  186. package/src/server/request-log-filter.ts +92 -0
  187. package/src/server/request-log.ts +31 -70
  188. package/src/server/responses/adapter-delivery.ts +43 -16
  189. package/src/server/responses/agent-task-recovery.ts +90 -22
  190. package/src/server/responses/codex-ws-exchange.ts +4 -0
  191. package/src/server/responses/codex-ws-wire.ts +10 -1
  192. package/src/server/responses/core-combo-native.ts +323 -0
  193. package/src/server/responses/core-combo.ts +224 -13
  194. package/src/server/responses/core-options.ts +22 -0
  195. package/src/server/responses/core.ts +14 -26
  196. package/src/server/responses/request-sidecar-auth.ts +8 -3
  197. package/src/server/responses/run-turn-execution.ts +257 -63
  198. package/src/server/responses/sidecar-execution.ts +7 -4
  199. package/src/server/system-env.ts +7 -0
  200. package/src/service/diagnostics.ts +7 -1
  201. package/src/service/launchd.ts +26 -37
  202. package/src/service/windows-ops.ts +24 -20
  203. package/src/types/config.ts +58 -1
  204. package/src/types.ts +2 -0
  205. package/src/update/transactional-install.d.mts +0 -1
  206. package/src/update/transactional-install.mjs +17 -17
  207. package/src/usage/jev-stats.ts +495 -0
  208. package/src/usage/log.ts +24 -3
  209. package/src/web-search/run-turn-loop.ts +568 -0
  210. package/gui/dist/assets/App-8NMiZxT0.css +0 -1
  211. package/gui/dist/assets/App-CsYvvpr3.js +0 -50
  212. package/gui/dist/assets/index--EWgGQvZ.css +0 -1
  213. package/gui/dist/assets/index-BB0iHG8-.js +0 -86
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Anthropic OAuth on the managed native Messages lane (PF-10, behind
3
+ * `protocols.rollout.managedMessagesNativeOAuth`).
4
+ *
5
+ * Credential. The account is the one the existing OAuth selection chooses for this request, by
6
+ * the same steps the Responses pipeline's transport takes for an unpooled Anthropic OAuth route
7
+ * (`prepareResponsesTransport`): capture the committed selection, resolve the active account's
8
+ * access snapshot (refreshing it through the OAuth owner when it is due), and commit that
9
+ * proposal against the captured selection so a concurrent manual switch wins. Nothing here picks
10
+ * an account of its own, and nothing runs at planning time: the planner and eligibility read
11
+ * config only, and this module is reached from the lane's dispatch alone.
12
+ *
13
+ * Pools. A pooled account set (the opt-in Anthropic account pool, or two or more usable accounts,
14
+ * which turns on reactive 429 rotation) is declined before this lane is chosen
15
+ * (`oauth-account-pool`). Should one appear between that decision and dispatch, resolution fails
16
+ * closed rather than serve a pooled account without the pool's rotation and affinity.
17
+ *
18
+ * Tool names. An OAuth request carries client tool names under the Claude OAuth prefix, as the
19
+ * adapter sends them; the answer's `tool_use` names are mapped back here, for exactly the names
20
+ * the builder renamed.
21
+ *
22
+ * No token, account id or body content is logged or returned in an error message.
23
+ */
24
+ import { getValidAccessTokenSnapshot, type OAuthAccessSnapshot } from "../oauth";
25
+ import {
26
+ commitAnthropicSelectionRouting,
27
+ getAnthropicPoolAccessSnapshot,
28
+ hasAnthropicFailoverQuorum,
29
+ isAnthropicAccountPoolEnabled,
30
+ } from "../oauth/anthropic-routing";
31
+ import {
32
+ captureOAuthAccountSelection,
33
+ commitOAuthAccountSelection,
34
+ credentialGeneration,
35
+ getAccountCredentialWithStatus,
36
+ } from "../oauth/store";
37
+ import type { TranslatorBudget } from "../lib/translator-budget";
38
+ import type { OcxConfig } from "../types";
39
+ import { relaySseWithPayloadRewrite } from "./sse-payload-rewrite";
40
+
41
+ const PROVIDER = "anthropic";
42
+ const MAX_SELECTION_ATTEMPTS = 3;
43
+
44
+ type Selection = NonNullable<ReturnType<typeof captureOAuthAccountSelection>>;
45
+ type Rec = Record<string, unknown>;
46
+
47
+ function isRec(value: unknown): value is Rec {
48
+ return value !== null && typeof value === "object" && !Array.isArray(value);
49
+ }
50
+
51
+ /** The committed selection and the credential snapshot one native request is served with. */
52
+ export interface NativeOAuthBinding {
53
+ readonly selection: Selection;
54
+ readonly snapshot: OAuthAccessSnapshot;
55
+ }
56
+
57
+ /** The selection moved or became pooled while it was being resolved. Maps to a 409 retry. */
58
+ export class NativeOAuthSelectionChangedError extends Error {
59
+ constructor() {
60
+ super("OAuth account selection changed; retry the request");
61
+ this.name = "NativeOAuthSelectionChangedError";
62
+ }
63
+ }
64
+
65
+ function pooled(config: OcxConfig): boolean {
66
+ return isAnthropicAccountPoolEnabled(config) || hasAnthropicFailoverQuorum();
67
+ }
68
+
69
+ /**
70
+ * Resolve and commit the account for one native request. Throws the OAuth owner's own errors
71
+ * (login required, refresh failure) unchanged, and `NativeOAuthSelectionChangedError` when the
72
+ * selection could not be committed.
73
+ */
74
+ export async function resolveNativeOAuthBinding(config: OcxConfig): Promise<NativeOAuthBinding> {
75
+ if (pooled(config)) throw new NativeOAuthSelectionChangedError();
76
+ let selection: Selection | null = captureOAuthAccountSelection(PROVIDER);
77
+ let candidate = await getValidAccessTokenSnapshot(PROVIDER);
78
+ for (let attempt = 0; attempt < MAX_SELECTION_ATTEMPTS; attempt++) {
79
+ if (!selection) break;
80
+ if (candidate.accountId !== selection.accountId) {
81
+ // The active account moved between capture and resolution: serve the committed one.
82
+ selection = captureOAuthAccountSelection(PROVIDER);
83
+ if (!selection) break;
84
+ candidate = await getAnthropicPoolAccessSnapshot(selection.accountId);
85
+ }
86
+ const committed = await commitOAuthAccountSelection(PROVIDER, candidate.accountId, {
87
+ expectedSelection: selection,
88
+ expectedCredentialGeneration: candidate.generation,
89
+ requireUsableAccount: true,
90
+ });
91
+ if (committed) {
92
+ if (!commitAnthropicSelectionRouting(candidate.accountId, selection, committed, {
93
+ config,
94
+ sessionKey: null,
95
+ expectedCredentialGeneration: candidate.generation,
96
+ })) break;
97
+ if (pooled(config)) break;
98
+ return { selection: committed, snapshot: candidate };
99
+ }
100
+ // A newer manual choice wins over this request's proposal.
101
+ selection = captureOAuthAccountSelection(PROVIDER);
102
+ if (!selection) break;
103
+ candidate = await getAnthropicPoolAccessSnapshot(selection.accountId);
104
+ }
105
+ throw new NativeOAuthSelectionChangedError();
106
+ }
107
+
108
+ /**
109
+ * Whether a binding may still be sent: the same committed selection, and the same usable,
110
+ * unexpired credential generation. Checked immediately before every physical send.
111
+ */
112
+ export function nativeOAuthBindingIsCurrent(binding: NativeOAuthBinding): boolean {
113
+ const selected = captureOAuthAccountSelection(PROVIDER);
114
+ const row = getAccountCredentialWithStatus(PROVIDER, binding.snapshot.accountId);
115
+ return selected?.accountId === binding.selection.accountId
116
+ && selected?.revision === binding.selection.revision
117
+ && !!row && !row.needsReauth && row.credential.expires > Date.now()
118
+ && credentialGeneration(row.credential) === binding.snapshot.generation;
119
+ }
120
+
121
+ /** Map a `tool_use` block's wire name back to the caller's name; other blocks are untouched. */
122
+ function restoredBlock(block: unknown, names: ReadonlyMap<string, string>): unknown {
123
+ if (!isRec(block) || block.type !== "tool_use" || typeof block.name !== "string") return block;
124
+ const original = names.get(block.name);
125
+ return original === undefined ? block : { ...block, name: original };
126
+ }
127
+
128
+ /** A Messages result with renamed `tool_use` names mapped back. Returns the input when unchanged. */
129
+ export function restoreOAuthToolNamesInMessage(message: Rec, names: ReadonlyMap<string, string>): Rec {
130
+ if (names.size === 0 || !Array.isArray(message.content)) return message;
131
+ return { ...message, content: message.content.map(block => restoredBlock(block, names)) };
132
+ }
133
+
134
+ /** The upstream Messages stream with renamed `tool_use` names mapped back in `content_block_start`. */
135
+ export function restoreOAuthToolNamesInSse(
136
+ body: ReadableStream<Uint8Array>,
137
+ names: ReadonlyMap<string, string>,
138
+ translatorBudget: TranslatorBudget,
139
+ ): ReadableStream<Uint8Array> {
140
+ if (names.size === 0) return body;
141
+ return relaySseWithPayloadRewrite(body, (payload) => {
142
+ if (!payload.includes("content_block_start")) return payload;
143
+ let parsed: unknown;
144
+ try { parsed = JSON.parse(payload); } catch { return payload; }
145
+ if (!isRec(parsed) || parsed.type !== "content_block_start") return payload;
146
+ const restored = restoredBlock(parsed.content_block, names);
147
+ return restored === parsed.content_block ? payload : JSON.stringify({ ...parsed, content_block: restored });
148
+ }, translatorBudget);
149
+ }