@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
@@ -1,7 +1,7 @@
1
1
  import { decodeEventStream } from "../lib/eventstream-decoder";
2
2
  import { estimateTokens } from "../lib/token-estimate";
3
3
  import { debugProviderDiagnostic } from "../lib/debug";
4
- import { resolveKiroApiRegion, resolveKiroProfileArn } from "../oauth/kiro";
4
+ import { resolveKiroApiRegion, resolveKiroRequestProfile } from "../oauth/kiro";
5
5
  import { KIRO_MODEL_CONTEXT_WINDOWS, normalizeKiroModelId } from "../providers/kiro-models";
6
6
  import { modelRecordValue } from "../reasoning-effort";
7
7
  import { parseKiroEvent } from "./kiro-events";
@@ -33,6 +33,7 @@ import type {
33
33
  OcxTextContent,
34
34
  OcxToolCall,
35
35
  OcxToolResultMessage,
36
+ OcxTool,
36
37
  OcxUsage,
37
38
  } from "../types";
38
39
  import type { ProviderAdapter } from "./base";
@@ -42,7 +43,7 @@ import { sniffImageDimensions } from "./anthropic-image-guard";
42
43
  import { fetchKiroWithRetry, noteKiroTransientThrottle } from "./kiro-retry";
43
44
  import { convertKiroToolContext } from "./kiro-tools";
44
45
  import { identifyRoutedModel } from "./identity";
45
- import { buildNonOpenAIToolCatalogNudgeFromNames } from "./tool-catalog-nudge";
46
+ import { buildNonOpenAIToolCatalogNudgeFromNames, isBareShellBridgeTool, isCodexCodeModeExecTool } from "./tool-catalog-nudge";
46
47
  import {
47
48
  KIRO_COMPLETION_INSTRUCTIONS,
48
49
  KIRO_COMPLETION_RETRY_MESSAGE,
@@ -321,9 +322,23 @@ function validateKiroCapabilities(parsed: OcxParsedRequest): void {
321
322
  if (parsed.options.serviceTier !== undefined) {
322
323
  throw new Error("Kiro does not support service tiers");
323
324
  }
324
- const raw = parsed._rawBody as Record<string, unknown> | undefined;
325
- if (parsed._structuredOutput || raw?.text !== undefined) {
326
- throw new Error("Kiro does not support Responses text controls or structured output");
325
+ // Structured output is a real contract Kiro cannot honour: the wire has no
326
+ // schema-constrained response mode, so a caller expecting parseable JSON would receive
327
+ // prose and fail downstream. Refuse it.
328
+ //
329
+ // The rest of the Responses `text` object is not that. `text.verbosity` is a length
330
+ // preference and `text.format: {type:"text"}` is ordinary prose — the default output
331
+ // mode, which no capability flag governs and every correct client may send. Testing
332
+ // `_rawBody.text !== undefined` refused those turns for the mere PRESENCE of the key,
333
+ // the same mistake db040e70f removed one condition earlier where a permissive
334
+ // `parallel_tool_calls` hint was read as a requirement.
335
+ //
336
+ // Nothing needs stripping the way openai-responses strips a no-op verbosity:
337
+ // buildKiroPayload composes conversationState field by field from `parsed` and never
338
+ // spreads `_rawBody`, so a tolerated control is dropped by construction. The test
339
+ // asserts that absence so it stays true.
340
+ if (parsed._structuredOutput) {
341
+ throw new Error("Kiro does not support Responses structured output");
327
342
  }
328
343
  }
329
344
 
@@ -460,9 +475,32 @@ export function buildKiroPayload(
460
475
  // name for a tool that was never advertised and pollute the collision domain.
461
476
  const advertisedAlias = new Map<string, string>();
462
477
  for (const [alias, wireName] of registry.nameMap) advertisedAlias.set(wireName, alias);
478
+ // Code mode is decided on the EMITTED catalog, not the requested list.
479
+ //
480
+ // `freeform` only exists on the requested tool objects -- `kiroToolWireNames` has already
481
+ // reduced the emitted catalog to strings -- so the predicates must read the objects. But the
482
+ // SHAPE that matters is the one the model receives: the count/byte budget can drop a requested
483
+ // `exec_command` while `exec` survives, and scanning the requested list would then find a shell
484
+ // bridge the model cannot call and suppress code mode for a catalog that is code-mode-shaped.
485
+ // Intersecting the two keeps `tool_choice: "none"` and budget omission correct for free: both
486
+ // empty the emitted set, so nothing can be named.
487
+ const emittedToolNames = new Set(kiroToolWireNames(kiroTools));
488
+ const emittedAlias = (tool: OcxTool): string | undefined => {
489
+ const wireName = namespacedToolName(tool.namespace, tool.name);
490
+ // Read the recorded mapping; `registry.alias()` would REGISTER a name here.
491
+ const alias = advertisedAlias.get(wireName) ?? wireName;
492
+ return emittedToolNames.has(alias) ? alias : undefined;
493
+ };
494
+ const requestedTools = parsed.context.tools ?? [];
495
+ const emittedCodeModeExec = requestedTools.find(tool => isCodexCodeModeExecTool(tool) && emittedAlias(tool));
496
+ const emittedShellBridge = requestedTools.some(tool => isBareShellBridgeTool(tool) && emittedAlias(tool));
497
+ const codeModeExecName = emittedCodeModeExec && !emittedShellBridge
498
+ ? emittedAlias(emittedCodeModeExec)
499
+ : undefined;
463
500
  const toolCatalogNudge = buildNonOpenAIToolCatalogNudgeFromNames(
464
501
  kiroToolWireNames(kiroTools),
465
502
  name => advertisedAlias.get(name) ?? name,
503
+ codeModeExecName,
466
504
  );
467
505
  const boundedNudge = toolCatalogNudge ? boundedInjectedInstruction(toolCatalogNudge, injectedChars) : undefined;
468
506
  if (boundedNudge) systemParts.push(boundedNudge);
@@ -1723,12 +1761,19 @@ export function createKiroAdapter(provider: OcxProviderConfig): ProviderAdapter
1723
1761
  throw new Error("kiro token missing — run ocx login kiro");
1724
1762
  }
1725
1763
  const region = resolveKiroApiRegion(parsed._kiroAuthContext);
1726
- const resolvedProfileArn = resolveKiroProfileArn(parsed._kiroAuthContext);
1764
+ // Request-scoped: an AWS Builder ID account has no profile of its own and resolves to Kiro's
1765
+ // fixed service profile here, without that value ever becoming the account's stored identity.
1766
+ const requestProfile = resolveKiroRequestProfile(parsed._kiroAuthContext);
1767
+ const resolvedProfileArn = requestProfile.profileArn;
1727
1768
  const isApiKey = provider.apiKey.trim().startsWith("ksk_");
1728
1769
  const profileArn = isApiKey ? undefined : resolvedProfileArn;
1729
- // Builder ID and Kiro API keys have no profile ARN and are accepted only on Kiro's CLI
1730
- // request path. Enterprise profiles retain the existing IDE-shaped request.
1731
- const wireClient: KiroWireClient = isApiKey || !profileArn ? "cli" : "ide";
1770
+ // Builder ID and Kiro API keys are accepted only on Kiro's CLI request path; enterprise
1771
+ // profiles retain the IDE-shaped request. Builder ID now carries a profile ARN, so a truthy
1772
+ // `profileArn` no longer implies "enterprise". The wire path reads the resolver's own verdict
1773
+ // rather than re-deriving it, so the accountless path — where the auth type comes from the
1774
+ // local import, not the request context — cannot send the fallback inside an IDE-shaped call.
1775
+ const isBuilderId = requestProfile.builderIdFallback;
1776
+ const wireClient: KiroWireClient = isApiKey || isBuilderId || !profileArn ? "cli" : "ide";
1732
1777
  const fp = fingerprint().slice(0, 64);
1733
1778
  const headers: Record<string, string> = wireClient === "cli" ? {
1734
1779
  authorization: `Bearer ${provider.apiKey}`,