@yansigit/opencodex 2.33.0 → 2.35.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.
Files changed (196) hide show
  1. package/README.md +3 -3
  2. package/gui/dist/assets/index-BjCaHxdz.js +112 -0
  3. package/gui/dist/assets/index-DLkXOXLC.css +1 -0
  4. package/gui/dist/index.html +2 -2
  5. package/package.json +1 -1
  6. package/src/adapters/anthropic.ts +79 -2
  7. package/src/adapters/command-code.ts +141 -23
  8. package/src/adapters/cursor/call-id.ts +44 -0
  9. package/src/adapters/cursor/checkpoint-store.ts +15 -10
  10. package/src/adapters/cursor/discovery.ts +60 -2
  11. package/src/adapters/cursor/effort-map.ts +79 -1
  12. package/src/adapters/cursor/envelope-echo.ts +162 -0
  13. package/src/adapters/cursor/live-models.ts +7 -2
  14. package/src/adapters/cursor/live-transport.ts +17 -1
  15. package/src/adapters/cursor/message-mapper.ts +4 -1
  16. package/src/adapters/cursor/native-exec-fs.ts +13 -12
  17. package/src/adapters/cursor/native-exec-network.ts +3 -5
  18. package/src/adapters/cursor/native-exec-policy.ts +47 -0
  19. package/src/adapters/cursor/native-exec-shell.ts +116 -31
  20. package/src/adapters/cursor/native-exec.ts +38 -10
  21. package/src/adapters/cursor/protobuf-events.ts +28 -2
  22. package/src/adapters/cursor/protobuf-request.ts +93 -41
  23. package/src/adapters/cursor/request-builder.ts +39 -10
  24. package/src/adapters/cursor/tool-definitions.ts +27 -3
  25. package/src/adapters/cursor/tool-result-normalize.ts +51 -6
  26. package/src/adapters/cursor/types.ts +23 -4
  27. package/src/adapters/cursor.ts +170 -29
  28. package/src/adapters/google-aistudio-parser.ts +49 -0
  29. package/src/adapters/google-antigravity-replay.ts +105 -25
  30. package/src/adapters/google-antigravity-wire.ts +5 -0
  31. package/src/adapters/google-errors.ts +41 -12
  32. package/src/adapters/google-http.ts +12 -11
  33. package/src/adapters/google.ts +219 -36
  34. package/src/adapters/image.ts +1 -1
  35. package/src/adapters/kiro-constants.ts +15 -0
  36. package/src/adapters/kiro-tools.ts +43 -15
  37. package/src/adapters/kiro.ts +54 -9
  38. package/src/adapters/openai-chat.ts +286 -242
  39. package/src/adapters/openai-responses.ts +335 -24
  40. package/src/adapters/run-turn-queue.ts +36 -1
  41. package/src/adapters/tool-catalog-nudge.ts +2 -2
  42. package/src/adapters/xai-tool-schema.ts +436 -0
  43. package/src/bridge.ts +67 -26
  44. package/src/chat/inbound.ts +29 -1
  45. package/src/chat/outbound.ts +15 -7
  46. package/src/claude/agents-inject.ts +8 -1
  47. package/src/claude/outbound.ts +10 -8
  48. package/src/cli/account-api.ts +27 -7
  49. package/src/cli/account-extended.ts +10 -3
  50. package/src/cli/account.ts +29 -5
  51. package/src/cli/alias.ts +66 -0
  52. package/src/cli/claude.ts +26 -1
  53. package/src/cli/dispatch.ts +13 -1
  54. package/src/cli/help.ts +1 -0
  55. package/src/cli/index.ts +6 -1
  56. package/src/cli/init.ts +1 -0
  57. package/src/cli/models-runtime.ts +95 -0
  58. package/src/cli/models.ts +13 -7
  59. package/src/cli/provider-runtime.ts +16 -2
  60. package/src/cli/registry.ts +6 -1
  61. package/src/cli/telemetry-commands.ts +25 -0
  62. package/src/cli/v2.ts +34 -10
  63. package/src/codex/account-pause.ts +2 -1
  64. package/src/codex/account-priority.ts +3 -2
  65. package/src/codex/app-server-processes.ts +80 -6
  66. package/src/codex/auth-api.ts +48 -8
  67. package/src/codex/auth-context.ts +21 -18
  68. package/src/codex/catalog/aggregation.ts +6 -0
  69. package/src/codex/catalog/model-metadata.ts +13 -1
  70. package/src/codex/catalog/native-models.ts +5 -2
  71. package/src/codex/catalog/parsing.ts +16 -0
  72. package/src/codex/catalog/provider-fetch.ts +20 -3
  73. package/src/codex/catalog/sync.ts +127 -2
  74. package/src/codex/catalog.ts +1 -1
  75. package/src/codex/codex-write-lock.ts +3 -1
  76. package/src/codex/convergence-types.ts +1 -1
  77. package/src/codex/convergence.ts +22 -2
  78. package/src/codex/desired-state.ts +2 -2
  79. package/src/codex/desktop-app-restart.ts +18 -5
  80. package/src/codex/inject-coordination.ts +83 -0
  81. package/src/codex/inject.ts +14 -1
  82. package/src/codex/log-guard/inspect.ts +22 -4
  83. package/src/codex/model-entitlements.ts +9 -2
  84. package/src/codex/prompt-layers.ts +371 -25
  85. package/src/codex/prompt-text-probe.ts +238 -0
  86. package/src/codex/quota.ts +123 -18
  87. package/src/codex/routing.ts +9 -0
  88. package/src/codex/subagent-model-fallback.ts +198 -27
  89. package/src/codex/transition-state.ts +107 -8
  90. package/src/combos/types.ts +10 -0
  91. package/src/compatibility/openai-responses.ts +33 -1
  92. package/src/config/autonomous-remediation.ts +21 -0
  93. package/src/config/provider-validation.ts +14 -0
  94. package/src/config/rebase-provenance.ts +68 -0
  95. package/src/config.ts +191 -17
  96. package/src/generated/compatibility-version.json +279 -159
  97. package/src/generated/model-metadata.ts +3 -0
  98. package/src/images/loop.ts +5 -4
  99. package/src/lab/conformance/fixtures/protocol-v1-cases.json +1 -1
  100. package/src/lab/fabric/producer-child.ts +1 -1
  101. package/src/lib/config-ownership.ts +20 -0
  102. package/src/lib/errors.ts +11 -2
  103. package/src/lib/package-tree-integrity.ts +101 -0
  104. package/src/oauth/aistudio-credentials.ts +65 -0
  105. package/src/oauth/aistudio-native-daemon.ts +116 -0
  106. package/src/oauth/aistudio-session-sync.ts +95 -0
  107. package/src/oauth/generic-account-failover.ts +231 -0
  108. package/src/oauth/google-aistudio-auth.ts +98 -0
  109. package/src/oauth/index.ts +57 -5
  110. package/src/oauth/key-providers.ts +18 -1
  111. package/src/oauth/kiro.ts +45 -0
  112. package/src/oauth/login-cli.ts +65 -1
  113. package/src/oauth/types.ts +15 -0
  114. package/src/providers/codex-capacity.ts +5 -2
  115. package/src/providers/command-code-efforts.ts +38 -6
  116. package/src/providers/context-cap.ts +4 -3
  117. package/src/providers/default-aliases.ts +65 -0
  118. package/src/providers/derive.ts +29 -1
  119. package/src/providers/fastwire.ts +7 -1
  120. package/src/providers/model-presets.ts +119 -0
  121. package/src/providers/new-model-policy.ts +146 -0
  122. package/src/providers/provider-id-rewrite.ts +2 -1
  123. package/src/providers/quota.ts +157 -46
  124. package/src/providers/registry.ts +184 -71
  125. package/src/providers/slug-codec.ts +52 -0
  126. package/src/responses/code-mode-helper-compat.ts +50 -0
  127. package/src/responses/custom-tool-compat.ts +34 -10
  128. package/src/responses/parser.ts +4 -0
  129. package/src/responses/schema.ts +5 -1
  130. package/src/responses/thought-signature-replay.ts +17 -0
  131. package/src/router.ts +43 -2
  132. package/src/routing/account-pool/cooldown.ts +8 -0
  133. package/src/routing/account-pool/index.ts +1 -0
  134. package/src/routing/analytics.ts +1 -0
  135. package/src/routing/quota.ts +10 -0
  136. package/src/server/auth-cors.ts +24 -0
  137. package/src/server/chat-completions.ts +26 -16
  138. package/src/server/chat-native-sse.ts +3 -3
  139. package/src/server/chat-native.ts +30 -11
  140. package/src/server/claude-messages.ts +1 -1
  141. package/src/server/effort-policy.ts +16 -0
  142. package/src/server/index.ts +180 -14
  143. package/src/server/lifecycle.ts +52 -1
  144. package/src/server/management/agent-settings-routes.ts +31 -15
  145. package/src/server/management/codex-prompt-routes.ts +570 -0
  146. package/src/server/management/combo-routes.ts +2 -1
  147. package/src/server/management/config-routes.ts +27 -9
  148. package/src/server/management/context.ts +9 -0
  149. package/src/server/management/logs-usage-routes.ts +11 -5
  150. package/src/server/management/model-routes.ts +266 -0
  151. package/src/server/management/oauth-account-routes.ts +13 -3
  152. package/src/server/management/provider-routes.ts +137 -3
  153. package/src/server/management/routing-profile-routes.ts +2 -2
  154. package/src/server/management-api.ts +2 -0
  155. package/src/server/port-reclaim.ts +19 -1
  156. package/src/server/relay-eager.ts +147 -20
  157. package/src/server/relay.ts +251 -19
  158. package/src/server/request-log-conversation.ts +33 -0
  159. package/src/server/request-log.ts +48 -21
  160. package/src/server/responses/collaboration.ts +42 -5
  161. package/src/server/responses/combo-stream-preflight.ts +10 -3
  162. package/src/server/responses/core.ts +575 -140
  163. package/src/server/responses/empty-completion-guard.ts +35 -0
  164. package/src/server/responses/fetch-helpers.ts +14 -6
  165. package/src/server/responses/input-admission.ts +3 -1
  166. package/src/server/responses/passthrough-error.ts +33 -9
  167. package/src/server/responses/policy-fallback.ts +1 -1
  168. package/src/server/responses/responses-field-backfill.ts +105 -13
  169. package/src/server/responses/ws-upstream.ts +35 -5
  170. package/src/server/responses-custom-tool-repair.ts +52 -7
  171. package/src/server/responses-terminal-repair.ts +25 -4
  172. package/src/server/sse-frame-buffer.ts +31 -4
  173. package/src/server/ws-bridge.ts +14 -2
  174. package/src/smoke/fingerprint-cache.ts +133 -0
  175. package/src/smoke/live-scenarios.ts +33 -0
  176. package/src/smoke/runner.ts +119 -0
  177. package/src/telemetry/dispatcher.ts +44 -0
  178. package/src/telemetry/fingerprint.ts +24 -0
  179. package/src/telemetry/hook.ts +43 -0
  180. package/src/telemetry/ledger.ts +54 -0
  181. package/src/telemetry/types.ts +23 -0
  182. package/src/types/config.ts +66 -14
  183. package/src/types/provider.ts +79 -1
  184. package/src/types/request.ts +18 -10
  185. package/src/types/tools.ts +30 -11
  186. package/src/types.ts +1 -0
  187. package/src/usage/command-code-manifest.ts +116 -0
  188. package/src/usage/cost.ts +2 -2
  189. package/src/usage/expected-prices.ts +126 -24
  190. package/src/usage/log.ts +18 -8
  191. package/src/usage/summary.ts +34 -12
  192. package/src/web-search/exa-executor.ts +40 -9
  193. package/src/web-search/index.ts +16 -8
  194. package/src/web-search/loop.ts +5 -4
  195. package/gui/dist/assets/index-DKLr4LTE.js +0 -102
  196. package/gui/dist/assets/index-DrSQdTRd.css +0 -1
@@ -19,6 +19,7 @@ import {
19
19
  CodexWriteConflictError,
20
20
  DEFAULT_INJECT_LOCK_TIMEOUT_MS,
21
21
  recomputeInjectWitness,
22
+ recordCodexNativeTransactionProvenance,
22
23
  restoreCodexPreImages,
23
24
  } from "./inject-coordination";
24
25
  import { readIntegrationRecord } from "./integration-record";
@@ -966,6 +967,7 @@ export async function injectCodexConfig(
966
967
  const coordinated = await withCodexWriteLock(
967
968
  {
968
969
  timeoutMs: options.lockTimeoutMs ?? DEFAULT_INJECT_LOCK_TIMEOUT_MS,
970
+ ...(eligibility.kind === "adopt" ? { adoption: { direction: "apply" as const } } : {}),
969
971
  admitted: { authoritySnapshotId: witness.comparisonId },
970
972
  readAdmissionUnderLock: () => ({
971
973
  authoritySnapshotId: recomputeInjectWitness({
@@ -1032,6 +1034,7 @@ export async function injectCodexConfig(
1032
1034
  }
1033
1035
  return {
1034
1036
  kind: "applied" as const,
1037
+ preImages,
1035
1038
  /*
1036
1039
  * The receipt the terminal update matches on. The transition commits
1037
1040
  * when the callback returns, so this pair is what the post-job
@@ -1049,6 +1052,10 @@ export async function injectCodexConfig(
1049
1052
  if (coordinated.status !== "acquired") {
1050
1053
  return codexInjectLockOutcome(coordinated);
1051
1054
  }
1055
+ recordCodexNativeTransactionProvenance(
1056
+ coordinated.value.preImages,
1057
+ coordinated.value.receipt.currentTxId,
1058
+ );
1052
1059
  transitionReceipt = coordinated.value.receipt;
1053
1060
  }
1054
1061
  // Legacy mode still forward-tags history so re-tagged threads stay listable. Design B needs
@@ -1560,13 +1567,14 @@ export async function restoreNativeCodexAsync(
1560
1567
  let config: CodexRestoreConfigResult;
1561
1568
  let transitionReceipt: { nativeGeneration: number; currentTxId: string } | undefined;
1562
1569
 
1563
- if (eligibility.kind === "coordinated") {
1570
+ if (eligibility.kind === "coordinated" || eligibility.kind === "adopt") {
1564
1571
  // The restore has no candidate bytes to witness; freshness comes from the
1565
1572
  // filesystem reads and the desired-state re-read performed under the lock.
1566
1573
  const witness = { authoritySnapshotId: "codex-native-restore" };
1567
1574
  const coordinated = await withCodexWriteLock(
1568
1575
  {
1569
1576
  timeoutMs: DEFAULT_INJECT_LOCK_TIMEOUT_MS,
1577
+ ...(eligibility.kind === "adopt" ? { adoption: { direction: "remove" as const } } : {}),
1570
1578
  admitted: witness,
1571
1579
  readAdmissionUnderLock: () => witness,
1572
1580
  },
@@ -1602,6 +1610,7 @@ export async function restoreNativeCodexAsync(
1602
1610
  }
1603
1611
  return {
1604
1612
  config: restored,
1613
+ preImages,
1605
1614
  receipt: {
1606
1615
  nativeGeneration: ctx.expectation.nativeAfter,
1607
1616
  currentTxId: ctx.expectation.txId,
@@ -1620,6 +1629,10 @@ export async function restoreNativeCodexAsync(
1620
1629
  : `Codex configuration was not restored: ${coordinated.message}`,
1621
1630
  };
1622
1631
  } else {
1632
+ recordCodexNativeTransactionProvenance(
1633
+ coordinated.value.preImages,
1634
+ coordinated.value.receipt.currentTxId,
1635
+ );
1623
1636
  config = coordinated.value.config;
1624
1637
  transitionReceipt = coordinated.value.receipt;
1625
1638
  }
@@ -11,6 +11,9 @@ import {
11
11
 
12
12
  const IMMUTABLE_READONLY_FLAGS = constants.SQLITE_OPEN_READONLY | constants.SQLITE_OPEN_URI;
13
13
  const KNOWN_LOG_LEVELS = new Set(["TRACE", "DEBUG", "INFO", "WARN", "ERROR"]);
14
+ // The issue reporter measured a ~1 GB database taking 17.3s for GROUP BY level
15
+ // alone; skipping all row aggregates above 64 MiB reduced /api/storage to 628ms.
16
+ const MAX_SYNCHRONOUS_METRICS_DATABASE_BYTES = 64 * 1024 * 1024;
14
17
 
15
18
  interface CurrentLogColumn {
16
19
  name: string;
@@ -115,6 +118,10 @@ export interface CodexLogGuardInspection {
115
118
  reclaim: CodexLogGuardCapability;
116
119
  };
117
120
  metrics: CodexLogGuardMetrics | null;
121
+ metricsSkipped: null | {
122
+ reason: "database_too_large";
123
+ thresholdBytes: number;
124
+ };
118
125
  }
119
126
 
120
127
  interface ColumnRow {
@@ -167,9 +174,8 @@ function fileSize(path: string): number {
167
174
  * repeated stalls without ever serving stale numbers: any write changes the WAL
168
175
  * and invalidates the entry.
169
176
  *
170
- * This bounds the repeat cost, not the first one. A cold inspection of a huge
171
- * database still blocks; moving that work off-thread needs a Worker and is
172
- * tracked separately.
177
+ * Memoization bounds repeat cost. The database-size gate below separately bounds
178
+ * cold request-thread work by omitting these aggregates for large databases.
173
179
  */
174
180
  type InspectionCacheEntry = {
175
181
  key: string;
@@ -233,6 +239,7 @@ function unavailableInspection(): CodexLogGuardInspection {
233
239
  reclaim: unavailable,
234
240
  },
235
241
  metrics: null,
242
+ metricsSkipped: null,
236
243
  };
237
244
  }
238
245
 
@@ -425,6 +432,7 @@ function inspectCodexLogsUncached(deps: CodexSqliteHomeDeps = {}): CodexLogGuard
425
432
  ...common,
426
433
  schema,
427
434
  metrics: null,
435
+ metricsSkipped: null,
428
436
  capabilities: {
429
437
  inspection: { state: "supported" },
430
438
  protection: mutation,
@@ -440,6 +448,7 @@ function inspectCodexLogsUncached(deps: CodexSqliteHomeDeps = {}): CodexLogGuard
440
448
  ...common,
441
449
  schema,
442
450
  metrics: null,
451
+ metricsSkipped: null,
443
452
  capabilities: {
444
453
  inspection: { state: "supported" },
445
454
  protection: mutation,
@@ -458,6 +467,7 @@ function inspectCodexLogsUncached(deps: CodexSqliteHomeDeps = {}): CodexLogGuard
458
467
  ...common,
459
468
  schema,
460
469
  metrics: null,
470
+ metricsSkipped: null,
461
471
  capabilities: {
462
472
  inspection: { state: "supported" },
463
473
  protection: mutation,
@@ -476,10 +486,17 @@ function inspectCodexLogsUncached(deps: CodexSqliteHomeDeps = {}): CodexLogGuard
476
486
  ? { state: "compatible" }
477
487
  : { state: "unsupported", reason: "unknown_schema" };
478
488
  const mutation = capabilityFor(schema);
489
+ const metricsSkipped = files.databaseBytes > MAX_SYNCHRONOUS_METRICS_DATABASE_BYTES
490
+ ? {
491
+ reason: "database_too_large" as const,
492
+ thresholdBytes: MAX_SYNCHRONOUS_METRICS_DATABASE_BYTES,
493
+ }
494
+ : null;
479
495
  return {
480
496
  ...common,
481
497
  schema,
482
- metrics: readMetrics(db, columns),
498
+ metrics: metricsSkipped === null ? readMetrics(db, columns) : null,
499
+ metricsSkipped,
483
500
  capabilities: {
484
501
  inspection: { state: "supported" },
485
502
  protection: mutation,
@@ -496,6 +513,7 @@ function inspectCodexLogsUncached(deps: CodexSqliteHomeDeps = {}): CodexLogGuard
496
513
  ...common,
497
514
  schema,
498
515
  metrics: null,
516
+ metricsSkipped: null,
499
517
  capabilities: {
500
518
  inspection: { state: "supported" },
501
519
  protection: mutation,
@@ -40,6 +40,10 @@ export interface CodexModelEntitlementResolveOptions {
40
40
  readonly now?: number;
41
41
  /** Test-only credential seam; production callers enumerate local main + Pool credentials. */
42
42
  readonly credentials?: readonly CodexModelEntitlementCredentialSnapshot[];
43
+ /** Test-only seam for proving lifecycle exclusions happen before credential reads. */
44
+ readonly credentialSnapshot?: typeof accountCredentialSnapshot;
45
+ /** Accounts whose credentials must not be read while another lifecycle owns them. */
46
+ readonly excludeAccountIds?: ReadonlySet<string>;
43
47
  }
44
48
 
45
49
  const accountModelsCache = new Map<string, CachedAccountModels>();
@@ -252,9 +256,12 @@ export async function resolveCodexModelEntitlements(
252
256
  ): Promise<CodexModelEntitlementSnapshot> {
253
257
  const now = options.now ?? Date.now();
254
258
  const fetcher = options.fetcher ?? fetch;
259
+ const allowedAccountIds = candidateAccountIds(config)
260
+ .filter(accountId => !options.excludeAccountIds?.has(accountId));
261
+ const credentialSnapshot = options.credentialSnapshot ?? accountCredentialSnapshot;
255
262
  const credentials = options.credentials
256
- ? [...options.credentials]
257
- : (await Promise.all(candidateAccountIds(config).map(accountCredentialSnapshot)))
263
+ ? [...options.credentials].filter(credential => !options.excludeAccountIds?.has(credential.accountId))
264
+ : (await Promise.all(allowedAccountIds.map(credentialSnapshot)))
258
265
  .filter((value): value is CodexModelEntitlementCredentialSnapshot => value !== null);
259
266
  const results = await Promise.all(credentials.map(async credential => ({
260
267
  credential,