@cartanova/qgrid-cli 2.7.1 → 2.7.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.
Files changed (1213) hide show
  1. package/README.ko.md +3 -2
  2. package/README.md +3 -2
  3. package/bundle/dist/application/monit/monit.frame.js +27 -14
  4. package/bundle/dist/application/monit/monit.types.js +22 -13
  5. package/bundle/dist/application/qgrid/conv-routing.js +21 -11
  6. package/bundle/dist/application/qgrid/oauth.js +1 -1
  7. package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +15 -4
  8. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +18 -9
  9. package/bundle/dist/application/qgrid/qgrid.frame.js +50 -73
  10. package/bundle/dist/application/qgrid/qgrid.types.js +4 -1
  11. package/bundle/dist/application/qgrid/token-subscriber.js +5 -5
  12. package/bundle/dist/application/qgrid/tool-emulation-schema.js +13 -1
  13. package/bundle/dist/application/qgrid/tool-emulation.js +1 -1
  14. package/bundle/dist/application/queries.generated.js +3 -1
  15. package/bundle/dist/application/request-log/json-schema-type-text.js +55 -0
  16. package/bundle/dist/application/request-log/request-log.model.js +85 -3
  17. package/bundle/dist/application/request-log/request-log.types.js +3 -2
  18. package/bundle/dist/application/request-log/zod-code-format.js +71 -0
  19. package/bundle/dist/application/setting/setting.constant.js +2 -62
  20. package/bundle/dist/application/setting/setting.model.js +3 -3
  21. package/bundle/dist/application/setting/setting.store.js +2 -2
  22. package/bundle/dist/application/sonamu.generated.js +11 -4
  23. package/bundle/dist/application/sonamu.generated.sso.js +7 -3
  24. package/bundle/dist/i18n/sd.generated.js +5 -2
  25. package/bundle/dist/migrations/20260814130113_alter_request_logs_add1_alter1.js +15 -0
  26. package/bundle/dist/migrations/20260814131051_alter_request_logs_add1_alter1.js +15 -0
  27. package/bundle/dist/migrations/20260814134846_alter_request_logs_add1_alter1.js +15 -0
  28. package/bundle/dist/migrations/20260814140759_alter_request_logs_alter1.js +13 -0
  29. package/bundle/dist/node_modules/.pnpm/{vite@8.0.3_@emnapi_core@1.11.2_@emnapi_runtime@1.11.2_@types_node@25.0.7_esbuild@0.27.4_2519c2e8d8013fcbc7b443879bc9da6d → vite@8.0.3_@emnapi_core@1.11.2_@emnapi_runtime@1.11.2_@types_node@25.0.7_esbuild@0.27.4_5b35fc1fb85d2af4d105e0d74f940f50}/node_modules/vite/dist/node/module-runner.js +2 -2
  30. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +2 -2
  31. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js +2 -2
  32. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.js +3 -3
  33. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +2 -2
  34. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/index.DdgEv5B1.js +2 -2
  35. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js +2 -2
  36. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js +2 -2
  37. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js +2 -2
  38. package/bundle/dist/node_modules/.pnpm/{vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_ms_f9cfcfeddd63e656d4010c98521af26c → vitest@4.1.10_@opentelemetry_api@1.9.0_@types_node@25.0.7_@vitest_coverage-v8@4.1.10_vi_a1977b93af7bb69308bcb1dbab39b618}/node_modules/vitest/dist/index.js +2 -2
  39. package/bundle/dist/sonamu.config.js +10 -9
  40. package/bundle/dist/testing/setup-mocks.js +2 -2
  41. package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +14 -2
  42. package/bundle/dist/utils/providers/anthropic/claude-session.js +1 -1
  43. package/bundle/dist/utils/providers/anthropic/stream-json-adapter.js +1 -1
  44. package/bundle/dist/utils/providers/common/model-cost.js +1 -1
  45. package/bundle/dist/utils/providers/common/schema-validation.js +1 -1
  46. package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +144 -0
  47. package/bundle/dist/utils/providers/openai/openai-constants.js +4 -2
  48. package/bundle/dist/utils/providers/openai/openai-direct-client.js +327 -0
  49. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +358 -781
  50. package/bundle/dist/utils/providers/openai/openai-oauth.js +84 -0
  51. package/bundle/dist/utils/providers/openai/openai-quota.js +76 -5
  52. package/bundle/dist/utils/providers/openai/openai-refresh.js +3 -3
  53. package/bundle/dist/utils/providers/openai/openai-sse.js +72 -0
  54. package/bundle/dist/utils/providers/openai/openai-transport-config.js +14 -0
  55. package/bundle/src/application/monit/monit.frame.test.ts +14 -17
  56. package/bundle/src/application/monit/monit.frame.ts +23 -12
  57. package/bundle/src/application/monit/monit.types.ts +40 -11
  58. package/bundle/src/application/qgrid/conv-routing.test.ts +67 -0
  59. package/bundle/src/application/qgrid/conv-routing.ts +46 -12
  60. package/bundle/src/application/qgrid/qgrid-oauth-redirect.test.ts +92 -2
  61. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +3 -0
  62. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +15 -1
  63. package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +36 -6
  64. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +22 -9
  65. package/bundle/src/application/qgrid/qgrid.frame.ts +55 -94
  66. package/bundle/src/application/qgrid/qgrid.types.ts +11 -4
  67. package/bundle/src/application/qgrid/token-subscriber.ts +4 -4
  68. package/bundle/src/application/qgrid/tool-emulation-schema.ts +1 -1
  69. package/bundle/src/application/qgrid/tool-emulation.test.ts +1 -0
  70. package/bundle/src/application/queries.generated.ts +6 -0
  71. package/bundle/src/application/request-log/json-schema-type-text.test.ts +96 -0
  72. package/bundle/src/application/request-log/json-schema-type-text.ts +83 -0
  73. package/bundle/src/application/request-log/request-log.entity.json +147 -21
  74. package/bundle/src/application/request-log/request-log.model.ts +108 -0
  75. package/bundle/src/application/request-log/request-log.types.ts +2 -0
  76. package/bundle/src/application/request-log/zod-code-format.test.ts +31 -0
  77. package/bundle/src/application/request-log/zod-code-format.ts +73 -0
  78. package/bundle/src/application/setting/setting.constant.test.ts +22 -24
  79. package/bundle/src/application/setting/setting.constant.ts +2 -63
  80. package/bundle/src/application/setting/setting.entity.json +1 -1
  81. package/bundle/src/application/setting/setting.store.ts +1 -1
  82. package/bundle/src/application/sonamu.generated.http +20 -1
  83. package/bundle/src/application/sonamu.generated.sso.ts +4 -0
  84. package/bundle/src/application/sonamu.generated.ts +10 -0
  85. package/bundle/src/i18n/sd.generated.ts +6 -1
  86. package/bundle/src/migrations/20260814130113_alter_request_logs_add1_alter1.ts +15 -0
  87. package/bundle/src/migrations/20260814131051_alter_request_logs_add1_alter1.ts +15 -0
  88. package/bundle/src/migrations/20260814134846_alter_request_logs_add1_alter1.ts +15 -0
  89. package/bundle/src/migrations/20260814140759_alter_request_logs_alter1.ts +13 -0
  90. package/bundle/src/sonamu.config.ts +9 -13
  91. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +17 -2
  92. package/bundle/src/utils/providers/anthropic/claude-session.ts +1 -3
  93. package/bundle/src/utils/providers/anthropic/stream-json-adapter.test.ts +1 -2
  94. package/bundle/src/utils/providers/anthropic/stream-json-adapter.ts +2 -3
  95. package/bundle/src/utils/providers/common/model-cost.ts +4 -9
  96. package/bundle/src/utils/providers/common/provider-dispatcher.ts +10 -8
  97. package/bundle/src/utils/providers/common/provider-types.ts +48 -0
  98. package/bundle/src/utils/providers/common/schema-validation.ts +1 -1
  99. package/bundle/src/utils/providers/openai/openai-backend-protocol.test.ts +106 -0
  100. package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +255 -0
  101. package/bundle/src/utils/providers/openai/openai-constants.ts +2 -0
  102. package/bundle/src/utils/providers/openai/openai-direct-client.test.ts +610 -0
  103. package/bundle/src/utils/providers/openai/openai-direct-client.ts +478 -0
  104. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +336 -1723
  105. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +458 -1175
  106. package/bundle/src/utils/providers/openai/openai-oauth.test.ts +95 -0
  107. package/bundle/src/utils/providers/openai/openai-oauth.ts +141 -0
  108. package/bundle/src/utils/providers/openai/openai-quota.test.ts +80 -7
  109. package/bundle/src/utils/providers/openai/openai-quota.ts +105 -4
  110. package/bundle/src/utils/providers/openai/openai-refresh.test.ts +120 -0
  111. package/bundle/src/utils/providers/openai/openai-refresh.ts +3 -1
  112. package/bundle/src/utils/providers/openai/openai-sse.test.ts +52 -0
  113. package/bundle/src/utils/providers/openai/openai-sse.ts +79 -0
  114. package/bundle/src/utils/providers/openai/openai-transport-config.ts +17 -0
  115. package/bundle/web-dist/client/assets/index-BldeEvAK.css +1 -0
  116. package/bundle/web-dist/client/assets/index-QxWJK2qE.js +106 -0
  117. package/bundle/web-dist/client/assets/logs-DaNYzis5.js +1 -0
  118. package/bundle/web-dist/client/assets/monit-BngOoU4n.js +1 -0
  119. package/bundle/web-dist/client/assets/{routes-J4bnHVfl.js → routes-BnQE0rPF.js} +1 -1
  120. package/bundle/web-dist/client/assets/{services.generated-jGypfumC.js → services.generated-CSW8bhCP.js} +4 -4
  121. package/bundle/web-dist/client/assets/settings-CPeAjsL3.js +1 -0
  122. package/bundle/web-dist/client/assets/show-DUOfuZj1.js +2 -0
  123. package/bundle/web-dist/client/assets/{tokens-DDrATjGA.js → tokens-LHoEigmF.js} +1 -1
  124. package/bundle/web-dist/client/assets/{use-oauth-login-flow-CptleCFM.js → use-oauth-login-flow-YyU4TDzU.js} +1 -1
  125. package/bundle/web-dist/client/index.html +3 -3
  126. package/bundle/web-dist/server/assets/{lazyRouteComponent-DOc8TV-P.js → lazyRouteComponent-0y-znAfz.js} +2 -2
  127. package/bundle/web-dist/server/assets/{logs-CfF3nmLM.js → logs-CJBbHM3_.js} +35 -5
  128. package/bundle/web-dist/server/assets/{monit-BSaKhh5D.js → monit-8WAsPETB.js} +144 -51
  129. package/bundle/web-dist/server/assets/{plus-DLFUHsfx.js → plus-9das21ju.js} +1 -1
  130. package/bundle/web-dist/server/assets/{react-dom-BotjLnTK.js → react-dom-zmEq8BVp.js} +1 -1
  131. package/bundle/web-dist/server/assets/{routes-CHMxrTT0.js → routes-B6bX3o41.js} +3 -3
  132. package/bundle/web-dist/server/assets/{services.generated-D3Q3FYot.js → services.generated-DyPeBI00.js} +76 -2
  133. package/bundle/web-dist/server/assets/{settings-DOQjV28c.js → settings-D1u5WdpP.js} +2 -3
  134. package/bundle/web-dist/server/assets/{show-Cn_C6Qvl.js → show-Cr7vwR0l.js} +93 -8
  135. package/bundle/web-dist/server/assets/{tokens-c0EN3iCx.js → tokens-BumM0gnH.js} +3 -3
  136. package/bundle/web-dist/server/assets/{use-oauth-login-flow-B68AbMDE.js → use-oauth-login-flow-DmsHGOlx.js} +1 -1
  137. package/bundle/web-dist/server/entry-server.generated.js +12 -12
  138. package/dist/cli.d.ts +10 -1
  139. package/dist/cli.js +1 -6
  140. package/package.json +11 -5
  141. package/skills/qgrid/SKILL.md +5 -5
  142. package/skills/qgrid/references/ai-sdk-provider-contract.md +16 -10
  143. package/skills/qgrid/references/cli-env-and-server-boot.md +6 -13
  144. package/skills/qgrid/references/decision-rationale.md +15 -23
  145. package/skills/qgrid/references/docs-workflow.md +1 -1
  146. package/skills/qgrid/references/openai-codex-runtime.md +39 -156
  147. package/skills/qgrid/references/prompt-cache-and-usage.md +35 -71
  148. package/skills/qgrid/references/provider-runtime-differences.md +17 -17
  149. package/skills/qgrid/references/repo-map.md +2 -2
  150. package/skills/qgrid/references/request-log-run-lifecycle.md +12 -2
  151. package/skills/qgrid/references/sonamu-api-web-flow.md +4 -0
  152. package/skills/qgrid/references/token-auth-quota-lifecycle.md +14 -24
  153. package/skills/qgrid/references/tool-calling-and-multiturn.md +3 -3
  154. package/skills/qgrid/references/verification-and-debugging.md +17 -15
  155. package/bundle/dist/codex-protocol/AgentPath.js +0 -1
  156. package/bundle/dist/codex-protocol/ApplyPatchApprovalParams.js +0 -1
  157. package/bundle/dist/codex-protocol/ApplyPatchApprovalResponse.js +0 -1
  158. package/bundle/dist/codex-protocol/AuthMode.js +0 -1
  159. package/bundle/dist/codex-protocol/ClientInfo.js +0 -1
  160. package/bundle/dist/codex-protocol/ClientNotification.js +0 -1
  161. package/bundle/dist/codex-protocol/ClientRequest.js +0 -1
  162. package/bundle/dist/codex-protocol/CollaborationMode.js +0 -1
  163. package/bundle/dist/codex-protocol/ContentItem.js +0 -1
  164. package/bundle/dist/codex-protocol/ConversationGitInfo.js +0 -1
  165. package/bundle/dist/codex-protocol/ConversationSummary.js +0 -1
  166. package/bundle/dist/codex-protocol/ExecCommandApprovalParams.js +0 -1
  167. package/bundle/dist/codex-protocol/ExecCommandApprovalResponse.js +0 -1
  168. package/bundle/dist/codex-protocol/ExecPolicyAmendment.js +0 -1
  169. package/bundle/dist/codex-protocol/FileChange.js +0 -1
  170. package/bundle/dist/codex-protocol/ForcedLoginMethod.js +0 -1
  171. package/bundle/dist/codex-protocol/FunctionCallOutputBody.js +0 -1
  172. package/bundle/dist/codex-protocol/FunctionCallOutputContentItem.js +0 -1
  173. package/bundle/dist/codex-protocol/FuzzyFileSearchMatchType.js +0 -1
  174. package/bundle/dist/codex-protocol/FuzzyFileSearchParams.js +0 -1
  175. package/bundle/dist/codex-protocol/FuzzyFileSearchResponse.js +0 -1
  176. package/bundle/dist/codex-protocol/FuzzyFileSearchResult.js +0 -1
  177. package/bundle/dist/codex-protocol/FuzzyFileSearchSessionCompletedNotification.js +0 -1
  178. package/bundle/dist/codex-protocol/FuzzyFileSearchSessionUpdatedNotification.js +0 -1
  179. package/bundle/dist/codex-protocol/GetAuthStatusParams.js +0 -1
  180. package/bundle/dist/codex-protocol/GetAuthStatusResponse.js +0 -1
  181. package/bundle/dist/codex-protocol/GetConversationSummaryParams.js +0 -1
  182. package/bundle/dist/codex-protocol/GetConversationSummaryResponse.js +0 -1
  183. package/bundle/dist/codex-protocol/GitDiffToRemoteParams.js +0 -1
  184. package/bundle/dist/codex-protocol/GitDiffToRemoteResponse.js +0 -1
  185. package/bundle/dist/codex-protocol/GitSha.js +0 -1
  186. package/bundle/dist/codex-protocol/ImageDetail.js +0 -1
  187. package/bundle/dist/codex-protocol/InitializeCapabilities.js +0 -1
  188. package/bundle/dist/codex-protocol/InitializeParams.js +0 -1
  189. package/bundle/dist/codex-protocol/InitializeResponse.js +0 -1
  190. package/bundle/dist/codex-protocol/InputModality.js +0 -1
  191. package/bundle/dist/codex-protocol/InternalSessionSource.js +0 -1
  192. package/bundle/dist/codex-protocol/LocalShellAction.js +0 -1
  193. package/bundle/dist/codex-protocol/LocalShellExecAction.js +0 -1
  194. package/bundle/dist/codex-protocol/LocalShellStatus.js +0 -1
  195. package/bundle/dist/codex-protocol/MessagePhase.js +0 -1
  196. package/bundle/dist/codex-protocol/ModeKind.js +0 -1
  197. package/bundle/dist/codex-protocol/NetworkPolicyAmendment.js +0 -1
  198. package/bundle/dist/codex-protocol/NetworkPolicyRuleAction.js +0 -1
  199. package/bundle/dist/codex-protocol/ParsedCommand.js +0 -1
  200. package/bundle/dist/codex-protocol/Personality.js +0 -1
  201. package/bundle/dist/codex-protocol/PlanType.js +0 -1
  202. package/bundle/dist/codex-protocol/RealtimeConversationVersion.js +0 -1
  203. package/bundle/dist/codex-protocol/RealtimeOutputModality.js +0 -1
  204. package/bundle/dist/codex-protocol/RealtimeVoice.js +0 -1
  205. package/bundle/dist/codex-protocol/RealtimeVoicesList.js +0 -1
  206. package/bundle/dist/codex-protocol/ReasoningEffort.js +0 -1
  207. package/bundle/dist/codex-protocol/ReasoningItemContent.js +0 -1
  208. package/bundle/dist/codex-protocol/ReasoningItemReasoningSummary.js +0 -1
  209. package/bundle/dist/codex-protocol/ReasoningSummary.js +0 -1
  210. package/bundle/dist/codex-protocol/RequestId.js +0 -1
  211. package/bundle/dist/codex-protocol/Resource.js +0 -1
  212. package/bundle/dist/codex-protocol/ResourceContent.js +0 -1
  213. package/bundle/dist/codex-protocol/ResourceTemplate.js +0 -1
  214. package/bundle/dist/codex-protocol/ResponseItem.js +0 -1
  215. package/bundle/dist/codex-protocol/ReviewDecision.js +0 -1
  216. package/bundle/dist/codex-protocol/ServerNotification.js +0 -1
  217. package/bundle/dist/codex-protocol/ServerRequest.js +0 -1
  218. package/bundle/dist/codex-protocol/SessionSource.js +0 -1
  219. package/bundle/dist/codex-protocol/Settings.js +0 -1
  220. package/bundle/dist/codex-protocol/SubAgentSource.js +0 -1
  221. package/bundle/dist/codex-protocol/ThreadId.js +0 -1
  222. package/bundle/dist/codex-protocol/ThreadMemoryMode.js +0 -1
  223. package/bundle/dist/codex-protocol/Tool.js +0 -1
  224. package/bundle/dist/codex-protocol/Verbosity.js +0 -1
  225. package/bundle/dist/codex-protocol/WebSearchAction.js +0 -1
  226. package/bundle/dist/codex-protocol/WebSearchContextSize.js +0 -1
  227. package/bundle/dist/codex-protocol/WebSearchLocation.js +0 -1
  228. package/bundle/dist/codex-protocol/WebSearchMode.js +0 -1
  229. package/bundle/dist/codex-protocol/WebSearchToolConfig.js +0 -1
  230. package/bundle/dist/codex-protocol/index.js +0 -2
  231. package/bundle/dist/codex-protocol/serde_json/JsonValue.js +0 -1
  232. package/bundle/dist/codex-protocol/v2/Account.js +0 -1
  233. package/bundle/dist/codex-protocol/v2/AccountLoginCompletedNotification.js +0 -1
  234. package/bundle/dist/codex-protocol/v2/AccountRateLimitsUpdatedNotification.js +0 -1
  235. package/bundle/dist/codex-protocol/v2/AccountUpdatedNotification.js +0 -1
  236. package/bundle/dist/codex-protocol/v2/ActivePermissionProfile.js +0 -1
  237. package/bundle/dist/codex-protocol/v2/ActivePermissionProfileModification.js +0 -1
  238. package/bundle/dist/codex-protocol/v2/AddCreditsNudgeCreditType.js +0 -1
  239. package/bundle/dist/codex-protocol/v2/AddCreditsNudgeEmailStatus.js +0 -1
  240. package/bundle/dist/codex-protocol/v2/AdditionalFileSystemPermissions.js +0 -1
  241. package/bundle/dist/codex-protocol/v2/AdditionalNetworkPermissions.js +0 -1
  242. package/bundle/dist/codex-protocol/v2/AdditionalPermissionProfile.js +0 -1
  243. package/bundle/dist/codex-protocol/v2/AgentMessageDeltaNotification.js +0 -1
  244. package/bundle/dist/codex-protocol/v2/AnalyticsConfig.js +0 -1
  245. package/bundle/dist/codex-protocol/v2/AppBranding.js +0 -1
  246. package/bundle/dist/codex-protocol/v2/AppInfo.js +0 -1
  247. package/bundle/dist/codex-protocol/v2/AppListUpdatedNotification.js +0 -1
  248. package/bundle/dist/codex-protocol/v2/AppMetadata.js +0 -1
  249. package/bundle/dist/codex-protocol/v2/AppReview.js +0 -1
  250. package/bundle/dist/codex-protocol/v2/AppScreenshot.js +0 -1
  251. package/bundle/dist/codex-protocol/v2/AppSummary.js +0 -1
  252. package/bundle/dist/codex-protocol/v2/AppToolApproval.js +0 -1
  253. package/bundle/dist/codex-protocol/v2/AppToolsConfig.js +0 -1
  254. package/bundle/dist/codex-protocol/v2/ApprovalsReviewer.js +0 -1
  255. package/bundle/dist/codex-protocol/v2/AppsConfig.js +0 -1
  256. package/bundle/dist/codex-protocol/v2/AppsDefaultConfig.js +0 -1
  257. package/bundle/dist/codex-protocol/v2/AppsListParams.js +0 -1
  258. package/bundle/dist/codex-protocol/v2/AppsListResponse.js +0 -1
  259. package/bundle/dist/codex-protocol/v2/AskForApproval.js +0 -1
  260. package/bundle/dist/codex-protocol/v2/AutoReviewDecisionSource.js +0 -1
  261. package/bundle/dist/codex-protocol/v2/ByteRange.js +0 -1
  262. package/bundle/dist/codex-protocol/v2/CancelLoginAccountParams.js +0 -1
  263. package/bundle/dist/codex-protocol/v2/CancelLoginAccountResponse.js +0 -1
  264. package/bundle/dist/codex-protocol/v2/CancelLoginAccountStatus.js +0 -1
  265. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshParams.js +0 -1
  266. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshReason.js +0 -1
  267. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshResponse.js +0 -1
  268. package/bundle/dist/codex-protocol/v2/CodexErrorInfo.js +0 -1
  269. package/bundle/dist/codex-protocol/v2/CollabAgentState.js +0 -1
  270. package/bundle/dist/codex-protocol/v2/CollabAgentStatus.js +0 -1
  271. package/bundle/dist/codex-protocol/v2/CollabAgentTool.js +0 -1
  272. package/bundle/dist/codex-protocol/v2/CollabAgentToolCallStatus.js +0 -1
  273. package/bundle/dist/codex-protocol/v2/CollaborationModeMask.js +0 -1
  274. package/bundle/dist/codex-protocol/v2/CommandAction.js +0 -1
  275. package/bundle/dist/codex-protocol/v2/CommandExecOutputDeltaNotification.js +0 -1
  276. package/bundle/dist/codex-protocol/v2/CommandExecOutputStream.js +0 -1
  277. package/bundle/dist/codex-protocol/v2/CommandExecParams.js +0 -1
  278. package/bundle/dist/codex-protocol/v2/CommandExecResizeParams.js +0 -1
  279. package/bundle/dist/codex-protocol/v2/CommandExecResizeResponse.js +0 -1
  280. package/bundle/dist/codex-protocol/v2/CommandExecResponse.js +0 -1
  281. package/bundle/dist/codex-protocol/v2/CommandExecTerminalSize.js +0 -1
  282. package/bundle/dist/codex-protocol/v2/CommandExecTerminateParams.js +0 -1
  283. package/bundle/dist/codex-protocol/v2/CommandExecTerminateResponse.js +0 -1
  284. package/bundle/dist/codex-protocol/v2/CommandExecWriteParams.js +0 -1
  285. package/bundle/dist/codex-protocol/v2/CommandExecWriteResponse.js +0 -1
  286. package/bundle/dist/codex-protocol/v2/CommandExecutionApprovalDecision.js +0 -1
  287. package/bundle/dist/codex-protocol/v2/CommandExecutionOutputDeltaNotification.js +0 -1
  288. package/bundle/dist/codex-protocol/v2/CommandExecutionRequestApprovalParams.js +0 -1
  289. package/bundle/dist/codex-protocol/v2/CommandExecutionRequestApprovalResponse.js +0 -1
  290. package/bundle/dist/codex-protocol/v2/CommandExecutionSource.js +0 -1
  291. package/bundle/dist/codex-protocol/v2/CommandExecutionStatus.js +0 -1
  292. package/bundle/dist/codex-protocol/v2/CommandMigration.js +0 -1
  293. package/bundle/dist/codex-protocol/v2/Config.js +0 -1
  294. package/bundle/dist/codex-protocol/v2/ConfigBatchWriteParams.js +0 -1
  295. package/bundle/dist/codex-protocol/v2/ConfigEdit.js +0 -1
  296. package/bundle/dist/codex-protocol/v2/ConfigLayer.js +0 -1
  297. package/bundle/dist/codex-protocol/v2/ConfigLayerMetadata.js +0 -1
  298. package/bundle/dist/codex-protocol/v2/ConfigLayerSource.js +0 -1
  299. package/bundle/dist/codex-protocol/v2/ConfigReadParams.js +0 -1
  300. package/bundle/dist/codex-protocol/v2/ConfigReadResponse.js +0 -1
  301. package/bundle/dist/codex-protocol/v2/ConfigRequirements.js +0 -1
  302. package/bundle/dist/codex-protocol/v2/ConfigRequirementsReadResponse.js +0 -1
  303. package/bundle/dist/codex-protocol/v2/ConfigValueWriteParams.js +0 -1
  304. package/bundle/dist/codex-protocol/v2/ConfigWarningNotification.js +0 -1
  305. package/bundle/dist/codex-protocol/v2/ConfigWriteResponse.js +0 -1
  306. package/bundle/dist/codex-protocol/v2/ConfiguredHookHandler.js +0 -1
  307. package/bundle/dist/codex-protocol/v2/ConfiguredHookMatcherGroup.js +0 -1
  308. package/bundle/dist/codex-protocol/v2/ContextCompactedNotification.js +0 -1
  309. package/bundle/dist/codex-protocol/v2/CreditsSnapshot.js +0 -1
  310. package/bundle/dist/codex-protocol/v2/DeprecationNoticeNotification.js +0 -1
  311. package/bundle/dist/codex-protocol/v2/DynamicToolCallOutputContentItem.js +0 -1
  312. package/bundle/dist/codex-protocol/v2/DynamicToolCallParams.js +0 -1
  313. package/bundle/dist/codex-protocol/v2/DynamicToolCallResponse.js +0 -1
  314. package/bundle/dist/codex-protocol/v2/DynamicToolCallStatus.js +0 -1
  315. package/bundle/dist/codex-protocol/v2/DynamicToolSpec.js +0 -1
  316. package/bundle/dist/codex-protocol/v2/ErrorNotification.js +0 -1
  317. package/bundle/dist/codex-protocol/v2/ExecPolicyAmendment.js +0 -1
  318. package/bundle/dist/codex-protocol/v2/ExperimentalFeature.js +0 -1
  319. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureEnablementSetParams.js +0 -1
  320. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureEnablementSetResponse.js +0 -1
  321. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureListParams.js +0 -1
  322. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureListResponse.js +0 -1
  323. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureStage.js +0 -1
  324. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigDetectParams.js +0 -1
  325. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigDetectResponse.js +0 -1
  326. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportCompletedNotification.js +0 -1
  327. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportParams.js +0 -1
  328. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportResponse.js +0 -1
  329. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigMigrationItem.js +0 -1
  330. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigMigrationItemType.js +0 -1
  331. package/bundle/dist/codex-protocol/v2/FeedbackUploadParams.js +0 -1
  332. package/bundle/dist/codex-protocol/v2/FeedbackUploadResponse.js +0 -1
  333. package/bundle/dist/codex-protocol/v2/FileChangeApprovalDecision.js +0 -1
  334. package/bundle/dist/codex-protocol/v2/FileChangeOutputDeltaNotification.js +0 -1
  335. package/bundle/dist/codex-protocol/v2/FileChangePatchUpdatedNotification.js +0 -1
  336. package/bundle/dist/codex-protocol/v2/FileChangeRequestApprovalParams.js +0 -1
  337. package/bundle/dist/codex-protocol/v2/FileChangeRequestApprovalResponse.js +0 -1
  338. package/bundle/dist/codex-protocol/v2/FileSystemAccessMode.js +0 -1
  339. package/bundle/dist/codex-protocol/v2/FileSystemPath.js +0 -1
  340. package/bundle/dist/codex-protocol/v2/FileSystemSandboxEntry.js +0 -1
  341. package/bundle/dist/codex-protocol/v2/FileSystemSpecialPath.js +0 -1
  342. package/bundle/dist/codex-protocol/v2/FileUpdateChange.js +0 -1
  343. package/bundle/dist/codex-protocol/v2/FsChangedNotification.js +0 -1
  344. package/bundle/dist/codex-protocol/v2/FsCopyParams.js +0 -1
  345. package/bundle/dist/codex-protocol/v2/FsCopyResponse.js +0 -1
  346. package/bundle/dist/codex-protocol/v2/FsCreateDirectoryParams.js +0 -1
  347. package/bundle/dist/codex-protocol/v2/FsCreateDirectoryResponse.js +0 -1
  348. package/bundle/dist/codex-protocol/v2/FsGetMetadataParams.js +0 -1
  349. package/bundle/dist/codex-protocol/v2/FsGetMetadataResponse.js +0 -1
  350. package/bundle/dist/codex-protocol/v2/FsReadDirectoryEntry.js +0 -1
  351. package/bundle/dist/codex-protocol/v2/FsReadDirectoryParams.js +0 -1
  352. package/bundle/dist/codex-protocol/v2/FsReadDirectoryResponse.js +0 -1
  353. package/bundle/dist/codex-protocol/v2/FsReadFileParams.js +0 -1
  354. package/bundle/dist/codex-protocol/v2/FsReadFileResponse.js +0 -1
  355. package/bundle/dist/codex-protocol/v2/FsRemoveParams.js +0 -1
  356. package/bundle/dist/codex-protocol/v2/FsRemoveResponse.js +0 -1
  357. package/bundle/dist/codex-protocol/v2/FsUnwatchParams.js +0 -1
  358. package/bundle/dist/codex-protocol/v2/FsUnwatchResponse.js +0 -1
  359. package/bundle/dist/codex-protocol/v2/FsWatchParams.js +0 -1
  360. package/bundle/dist/codex-protocol/v2/FsWatchResponse.js +0 -1
  361. package/bundle/dist/codex-protocol/v2/FsWriteFileParams.js +0 -1
  362. package/bundle/dist/codex-protocol/v2/FsWriteFileResponse.js +0 -1
  363. package/bundle/dist/codex-protocol/v2/GetAccountParams.js +0 -1
  364. package/bundle/dist/codex-protocol/v2/GetAccountRateLimitsResponse.js +0 -1
  365. package/bundle/dist/codex-protocol/v2/GetAccountResponse.js +0 -1
  366. package/bundle/dist/codex-protocol/v2/GitInfo.js +0 -1
  367. package/bundle/dist/codex-protocol/v2/GrantedPermissionProfile.js +0 -1
  368. package/bundle/dist/codex-protocol/v2/GuardianApprovalReview.js +0 -1
  369. package/bundle/dist/codex-protocol/v2/GuardianApprovalReviewAction.js +0 -1
  370. package/bundle/dist/codex-protocol/v2/GuardianApprovalReviewStatus.js +0 -1
  371. package/bundle/dist/codex-protocol/v2/GuardianCommandSource.js +0 -1
  372. package/bundle/dist/codex-protocol/v2/GuardianRiskLevel.js +0 -1
  373. package/bundle/dist/codex-protocol/v2/GuardianUserAuthorization.js +0 -1
  374. package/bundle/dist/codex-protocol/v2/GuardianWarningNotification.js +0 -1
  375. package/bundle/dist/codex-protocol/v2/HookCompletedNotification.js +0 -1
  376. package/bundle/dist/codex-protocol/v2/HookErrorInfo.js +0 -1
  377. package/bundle/dist/codex-protocol/v2/HookEventName.js +0 -1
  378. package/bundle/dist/codex-protocol/v2/HookExecutionMode.js +0 -1
  379. package/bundle/dist/codex-protocol/v2/HookHandlerType.js +0 -1
  380. package/bundle/dist/codex-protocol/v2/HookMetadata.js +0 -1
  381. package/bundle/dist/codex-protocol/v2/HookMigration.js +0 -1
  382. package/bundle/dist/codex-protocol/v2/HookOutputEntry.js +0 -1
  383. package/bundle/dist/codex-protocol/v2/HookOutputEntryKind.js +0 -1
  384. package/bundle/dist/codex-protocol/v2/HookPromptFragment.js +0 -1
  385. package/bundle/dist/codex-protocol/v2/HookRunStatus.js +0 -1
  386. package/bundle/dist/codex-protocol/v2/HookRunSummary.js +0 -1
  387. package/bundle/dist/codex-protocol/v2/HookScope.js +0 -1
  388. package/bundle/dist/codex-protocol/v2/HookSource.js +0 -1
  389. package/bundle/dist/codex-protocol/v2/HookStartedNotification.js +0 -1
  390. package/bundle/dist/codex-protocol/v2/HookTrustStatus.js +0 -1
  391. package/bundle/dist/codex-protocol/v2/HooksListEntry.js +0 -1
  392. package/bundle/dist/codex-protocol/v2/HooksListParams.js +0 -1
  393. package/bundle/dist/codex-protocol/v2/HooksListResponse.js +0 -1
  394. package/bundle/dist/codex-protocol/v2/ItemCompletedNotification.js +0 -1
  395. package/bundle/dist/codex-protocol/v2/ItemGuardianApprovalReviewCompletedNotification.js +0 -1
  396. package/bundle/dist/codex-protocol/v2/ItemGuardianApprovalReviewStartedNotification.js +0 -1
  397. package/bundle/dist/codex-protocol/v2/ItemStartedNotification.js +0 -1
  398. package/bundle/dist/codex-protocol/v2/ListMcpServerStatusParams.js +0 -1
  399. package/bundle/dist/codex-protocol/v2/ListMcpServerStatusResponse.js +0 -1
  400. package/bundle/dist/codex-protocol/v2/LoginAccountParams.js +0 -1
  401. package/bundle/dist/codex-protocol/v2/LoginAccountResponse.js +0 -1
  402. package/bundle/dist/codex-protocol/v2/LogoutAccountResponse.js +0 -1
  403. package/bundle/dist/codex-protocol/v2/ManagedHooksRequirements.js +0 -1
  404. package/bundle/dist/codex-protocol/v2/MarketplaceAddParams.js +0 -1
  405. package/bundle/dist/codex-protocol/v2/MarketplaceAddResponse.js +0 -1
  406. package/bundle/dist/codex-protocol/v2/MarketplaceInterface.js +0 -1
  407. package/bundle/dist/codex-protocol/v2/MarketplaceLoadErrorInfo.js +0 -1
  408. package/bundle/dist/codex-protocol/v2/MarketplaceRemoveParams.js +0 -1
  409. package/bundle/dist/codex-protocol/v2/MarketplaceRemoveResponse.js +0 -1
  410. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeErrorInfo.js +0 -1
  411. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeParams.js +0 -1
  412. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeResponse.js +0 -1
  413. package/bundle/dist/codex-protocol/v2/McpAuthStatus.js +0 -1
  414. package/bundle/dist/codex-protocol/v2/McpElicitationArrayType.js +0 -1
  415. package/bundle/dist/codex-protocol/v2/McpElicitationBooleanSchema.js +0 -1
  416. package/bundle/dist/codex-protocol/v2/McpElicitationBooleanType.js +0 -1
  417. package/bundle/dist/codex-protocol/v2/McpElicitationConstOption.js +0 -1
  418. package/bundle/dist/codex-protocol/v2/McpElicitationEnumSchema.js +0 -1
  419. package/bundle/dist/codex-protocol/v2/McpElicitationLegacyTitledEnumSchema.js +0 -1
  420. package/bundle/dist/codex-protocol/v2/McpElicitationMultiSelectEnumSchema.js +0 -1
  421. package/bundle/dist/codex-protocol/v2/McpElicitationNumberSchema.js +0 -1
  422. package/bundle/dist/codex-protocol/v2/McpElicitationNumberType.js +0 -1
  423. package/bundle/dist/codex-protocol/v2/McpElicitationObjectType.js +0 -1
  424. package/bundle/dist/codex-protocol/v2/McpElicitationPrimitiveSchema.js +0 -1
  425. package/bundle/dist/codex-protocol/v2/McpElicitationSchema.js +0 -1
  426. package/bundle/dist/codex-protocol/v2/McpElicitationSingleSelectEnumSchema.js +0 -1
  427. package/bundle/dist/codex-protocol/v2/McpElicitationStringFormat.js +0 -1
  428. package/bundle/dist/codex-protocol/v2/McpElicitationStringSchema.js +0 -1
  429. package/bundle/dist/codex-protocol/v2/McpElicitationStringType.js +0 -1
  430. package/bundle/dist/codex-protocol/v2/McpElicitationTitledEnumItems.js +0 -1
  431. package/bundle/dist/codex-protocol/v2/McpElicitationTitledMultiSelectEnumSchema.js +0 -1
  432. package/bundle/dist/codex-protocol/v2/McpElicitationTitledSingleSelectEnumSchema.js +0 -1
  433. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledEnumItems.js +0 -1
  434. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledMultiSelectEnumSchema.js +0 -1
  435. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledSingleSelectEnumSchema.js +0 -1
  436. package/bundle/dist/codex-protocol/v2/McpResourceReadParams.js +0 -1
  437. package/bundle/dist/codex-protocol/v2/McpResourceReadResponse.js +0 -1
  438. package/bundle/dist/codex-protocol/v2/McpServerElicitationAction.js +0 -1
  439. package/bundle/dist/codex-protocol/v2/McpServerElicitationRequestParams.js +0 -1
  440. package/bundle/dist/codex-protocol/v2/McpServerElicitationRequestResponse.js +0 -1
  441. package/bundle/dist/codex-protocol/v2/McpServerMigration.js +0 -1
  442. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginCompletedNotification.js +0 -1
  443. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginParams.js +0 -1
  444. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginResponse.js +0 -1
  445. package/bundle/dist/codex-protocol/v2/McpServerRefreshResponse.js +0 -1
  446. package/bundle/dist/codex-protocol/v2/McpServerStartupState.js +0 -1
  447. package/bundle/dist/codex-protocol/v2/McpServerStatus.js +0 -1
  448. package/bundle/dist/codex-protocol/v2/McpServerStatusDetail.js +0 -1
  449. package/bundle/dist/codex-protocol/v2/McpServerStatusUpdatedNotification.js +0 -1
  450. package/bundle/dist/codex-protocol/v2/McpServerToolCallParams.js +0 -1
  451. package/bundle/dist/codex-protocol/v2/McpServerToolCallResponse.js +0 -1
  452. package/bundle/dist/codex-protocol/v2/McpToolCallError.js +0 -1
  453. package/bundle/dist/codex-protocol/v2/McpToolCallProgressNotification.js +0 -1
  454. package/bundle/dist/codex-protocol/v2/McpToolCallResult.js +0 -1
  455. package/bundle/dist/codex-protocol/v2/McpToolCallStatus.js +0 -1
  456. package/bundle/dist/codex-protocol/v2/MemoryCitation.js +0 -1
  457. package/bundle/dist/codex-protocol/v2/MemoryCitationEntry.js +0 -1
  458. package/bundle/dist/codex-protocol/v2/MergeStrategy.js +0 -1
  459. package/bundle/dist/codex-protocol/v2/MigrationDetails.js +0 -1
  460. package/bundle/dist/codex-protocol/v2/Model.js +0 -1
  461. package/bundle/dist/codex-protocol/v2/ModelAvailabilityNux.js +0 -1
  462. package/bundle/dist/codex-protocol/v2/ModelListParams.js +0 -1
  463. package/bundle/dist/codex-protocol/v2/ModelListResponse.js +0 -1
  464. package/bundle/dist/codex-protocol/v2/ModelProviderCapabilitiesReadParams.js +0 -1
  465. package/bundle/dist/codex-protocol/v2/ModelProviderCapabilitiesReadResponse.js +0 -1
  466. package/bundle/dist/codex-protocol/v2/ModelRerouteReason.js +0 -1
  467. package/bundle/dist/codex-protocol/v2/ModelReroutedNotification.js +0 -1
  468. package/bundle/dist/codex-protocol/v2/ModelServiceTier.js +0 -1
  469. package/bundle/dist/codex-protocol/v2/ModelUpgradeInfo.js +0 -1
  470. package/bundle/dist/codex-protocol/v2/ModelVerification.js +0 -1
  471. package/bundle/dist/codex-protocol/v2/ModelVerificationNotification.js +0 -1
  472. package/bundle/dist/codex-protocol/v2/NetworkAccess.js +0 -1
  473. package/bundle/dist/codex-protocol/v2/NetworkApprovalContext.js +0 -1
  474. package/bundle/dist/codex-protocol/v2/NetworkApprovalProtocol.js +0 -1
  475. package/bundle/dist/codex-protocol/v2/NetworkDomainPermission.js +0 -1
  476. package/bundle/dist/codex-protocol/v2/NetworkPolicyAmendment.js +0 -1
  477. package/bundle/dist/codex-protocol/v2/NetworkPolicyRuleAction.js +0 -1
  478. package/bundle/dist/codex-protocol/v2/NetworkRequirements.js +0 -1
  479. package/bundle/dist/codex-protocol/v2/NetworkUnixSocketPermission.js +0 -1
  480. package/bundle/dist/codex-protocol/v2/NonSteerableTurnKind.js +0 -1
  481. package/bundle/dist/codex-protocol/v2/OverriddenMetadata.js +0 -1
  482. package/bundle/dist/codex-protocol/v2/PatchApplyStatus.js +0 -1
  483. package/bundle/dist/codex-protocol/v2/PatchChangeKind.js +0 -1
  484. package/bundle/dist/codex-protocol/v2/PermissionGrantScope.js +0 -1
  485. package/bundle/dist/codex-protocol/v2/PermissionProfile.js +0 -1
  486. package/bundle/dist/codex-protocol/v2/PermissionProfileFileSystemPermissions.js +0 -1
  487. package/bundle/dist/codex-protocol/v2/PermissionProfileModificationParams.js +0 -1
  488. package/bundle/dist/codex-protocol/v2/PermissionProfileNetworkPermissions.js +0 -1
  489. package/bundle/dist/codex-protocol/v2/PermissionProfileSelectionParams.js +0 -1
  490. package/bundle/dist/codex-protocol/v2/PermissionsRequestApprovalParams.js +0 -1
  491. package/bundle/dist/codex-protocol/v2/PermissionsRequestApprovalResponse.js +0 -1
  492. package/bundle/dist/codex-protocol/v2/PlanDeltaNotification.js +0 -1
  493. package/bundle/dist/codex-protocol/v2/PluginAuthPolicy.js +0 -1
  494. package/bundle/dist/codex-protocol/v2/PluginAvailability.js +0 -1
  495. package/bundle/dist/codex-protocol/v2/PluginDetail.js +0 -1
  496. package/bundle/dist/codex-protocol/v2/PluginHookSummary.js +0 -1
  497. package/bundle/dist/codex-protocol/v2/PluginInstallParams.js +0 -1
  498. package/bundle/dist/codex-protocol/v2/PluginInstallPolicy.js +0 -1
  499. package/bundle/dist/codex-protocol/v2/PluginInstallResponse.js +0 -1
  500. package/bundle/dist/codex-protocol/v2/PluginInterface.js +0 -1
  501. package/bundle/dist/codex-protocol/v2/PluginListMarketplaceKind.js +0 -1
  502. package/bundle/dist/codex-protocol/v2/PluginListParams.js +0 -1
  503. package/bundle/dist/codex-protocol/v2/PluginListResponse.js +0 -1
  504. package/bundle/dist/codex-protocol/v2/PluginMarketplaceEntry.js +0 -1
  505. package/bundle/dist/codex-protocol/v2/PluginReadParams.js +0 -1
  506. package/bundle/dist/codex-protocol/v2/PluginReadResponse.js +0 -1
  507. package/bundle/dist/codex-protocol/v2/PluginShareContext.js +0 -1
  508. package/bundle/dist/codex-protocol/v2/PluginShareDeleteParams.js +0 -1
  509. package/bundle/dist/codex-protocol/v2/PluginShareDeleteResponse.js +0 -1
  510. package/bundle/dist/codex-protocol/v2/PluginShareDiscoverability.js +0 -1
  511. package/bundle/dist/codex-protocol/v2/PluginShareListItem.js +0 -1
  512. package/bundle/dist/codex-protocol/v2/PluginShareListParams.js +0 -1
  513. package/bundle/dist/codex-protocol/v2/PluginShareListResponse.js +0 -1
  514. package/bundle/dist/codex-protocol/v2/PluginSharePrincipal.js +0 -1
  515. package/bundle/dist/codex-protocol/v2/PluginSharePrincipalType.js +0 -1
  516. package/bundle/dist/codex-protocol/v2/PluginShareSaveParams.js +0 -1
  517. package/bundle/dist/codex-protocol/v2/PluginShareSaveResponse.js +0 -1
  518. package/bundle/dist/codex-protocol/v2/PluginShareTarget.js +0 -1
  519. package/bundle/dist/codex-protocol/v2/PluginShareUpdateDiscoverability.js +0 -1
  520. package/bundle/dist/codex-protocol/v2/PluginShareUpdateTargetsParams.js +0 -1
  521. package/bundle/dist/codex-protocol/v2/PluginShareUpdateTargetsResponse.js +0 -1
  522. package/bundle/dist/codex-protocol/v2/PluginSkillReadParams.js +0 -1
  523. package/bundle/dist/codex-protocol/v2/PluginSkillReadResponse.js +0 -1
  524. package/bundle/dist/codex-protocol/v2/PluginSource.js +0 -1
  525. package/bundle/dist/codex-protocol/v2/PluginSummary.js +0 -1
  526. package/bundle/dist/codex-protocol/v2/PluginUninstallParams.js +0 -1
  527. package/bundle/dist/codex-protocol/v2/PluginUninstallResponse.js +0 -1
  528. package/bundle/dist/codex-protocol/v2/PluginsMigration.js +0 -1
  529. package/bundle/dist/codex-protocol/v2/ProcessExitedNotification.js +0 -1
  530. package/bundle/dist/codex-protocol/v2/ProcessOutputDeltaNotification.js +0 -1
  531. package/bundle/dist/codex-protocol/v2/ProcessOutputStream.js +0 -1
  532. package/bundle/dist/codex-protocol/v2/ProcessTerminalSize.js +0 -1
  533. package/bundle/dist/codex-protocol/v2/ProfileV2.js +0 -1
  534. package/bundle/dist/codex-protocol/v2/RateLimitReachedType.js +0 -1
  535. package/bundle/dist/codex-protocol/v2/RateLimitSnapshot.js +0 -1
  536. package/bundle/dist/codex-protocol/v2/RateLimitWindow.js +0 -1
  537. package/bundle/dist/codex-protocol/v2/RawResponseItemCompletedNotification.js +0 -1
  538. package/bundle/dist/codex-protocol/v2/ReasoningEffortOption.js +0 -1
  539. package/bundle/dist/codex-protocol/v2/ReasoningSummaryPartAddedNotification.js +0 -1
  540. package/bundle/dist/codex-protocol/v2/ReasoningSummaryTextDeltaNotification.js +0 -1
  541. package/bundle/dist/codex-protocol/v2/ReasoningTextDeltaNotification.js +0 -1
  542. package/bundle/dist/codex-protocol/v2/RemoteControlConnectionStatus.js +0 -1
  543. package/bundle/dist/codex-protocol/v2/RemoteControlStatusChangedNotification.js +0 -1
  544. package/bundle/dist/codex-protocol/v2/RequestPermissionProfile.js +0 -1
  545. package/bundle/dist/codex-protocol/v2/ResidencyRequirement.js +0 -1
  546. package/bundle/dist/codex-protocol/v2/ReviewDelivery.js +0 -1
  547. package/bundle/dist/codex-protocol/v2/ReviewStartParams.js +0 -1
  548. package/bundle/dist/codex-protocol/v2/ReviewStartResponse.js +0 -1
  549. package/bundle/dist/codex-protocol/v2/ReviewTarget.js +0 -1
  550. package/bundle/dist/codex-protocol/v2/SandboxMode.js +0 -1
  551. package/bundle/dist/codex-protocol/v2/SandboxPolicy.js +0 -1
  552. package/bundle/dist/codex-protocol/v2/SandboxWorkspaceWrite.js +0 -1
  553. package/bundle/dist/codex-protocol/v2/SendAddCreditsNudgeEmailParams.js +0 -1
  554. package/bundle/dist/codex-protocol/v2/SendAddCreditsNudgeEmailResponse.js +0 -1
  555. package/bundle/dist/codex-protocol/v2/ServerRequestResolvedNotification.js +0 -1
  556. package/bundle/dist/codex-protocol/v2/SessionMigration.js +0 -1
  557. package/bundle/dist/codex-protocol/v2/SessionSource.js +0 -1
  558. package/bundle/dist/codex-protocol/v2/SkillDependencies.js +0 -1
  559. package/bundle/dist/codex-protocol/v2/SkillErrorInfo.js +0 -1
  560. package/bundle/dist/codex-protocol/v2/SkillInterface.js +0 -1
  561. package/bundle/dist/codex-protocol/v2/SkillMetadata.js +0 -1
  562. package/bundle/dist/codex-protocol/v2/SkillScope.js +0 -1
  563. package/bundle/dist/codex-protocol/v2/SkillSummary.js +0 -1
  564. package/bundle/dist/codex-protocol/v2/SkillToolDependency.js +0 -1
  565. package/bundle/dist/codex-protocol/v2/SkillsChangedNotification.js +0 -1
  566. package/bundle/dist/codex-protocol/v2/SkillsConfigWriteParams.js +0 -1
  567. package/bundle/dist/codex-protocol/v2/SkillsConfigWriteResponse.js +0 -1
  568. package/bundle/dist/codex-protocol/v2/SkillsListEntry.js +0 -1
  569. package/bundle/dist/codex-protocol/v2/SkillsListParams.js +0 -1
  570. package/bundle/dist/codex-protocol/v2/SkillsListResponse.js +0 -1
  571. package/bundle/dist/codex-protocol/v2/SortDirection.js +0 -1
  572. package/bundle/dist/codex-protocol/v2/SubagentMigration.js +0 -1
  573. package/bundle/dist/codex-protocol/v2/TerminalInteractionNotification.js +0 -1
  574. package/bundle/dist/codex-protocol/v2/TextElement.js +0 -1
  575. package/bundle/dist/codex-protocol/v2/TextPosition.js +0 -1
  576. package/bundle/dist/codex-protocol/v2/TextRange.js +0 -1
  577. package/bundle/dist/codex-protocol/v2/Thread.js +0 -1
  578. package/bundle/dist/codex-protocol/v2/ThreadActiveFlag.js +0 -1
  579. package/bundle/dist/codex-protocol/v2/ThreadApproveGuardianDeniedActionParams.js +0 -1
  580. package/bundle/dist/codex-protocol/v2/ThreadApproveGuardianDeniedActionResponse.js +0 -1
  581. package/bundle/dist/codex-protocol/v2/ThreadArchiveParams.js +0 -1
  582. package/bundle/dist/codex-protocol/v2/ThreadArchiveResponse.js +0 -1
  583. package/bundle/dist/codex-protocol/v2/ThreadArchivedNotification.js +0 -1
  584. package/bundle/dist/codex-protocol/v2/ThreadClosedNotification.js +0 -1
  585. package/bundle/dist/codex-protocol/v2/ThreadCompactStartParams.js +0 -1
  586. package/bundle/dist/codex-protocol/v2/ThreadCompactStartResponse.js +0 -1
  587. package/bundle/dist/codex-protocol/v2/ThreadForkParams.js +0 -1
  588. package/bundle/dist/codex-protocol/v2/ThreadForkResponse.js +0 -1
  589. package/bundle/dist/codex-protocol/v2/ThreadGoal.js +0 -1
  590. package/bundle/dist/codex-protocol/v2/ThreadGoalClearedNotification.js +0 -1
  591. package/bundle/dist/codex-protocol/v2/ThreadGoalStatus.js +0 -1
  592. package/bundle/dist/codex-protocol/v2/ThreadGoalUpdatedNotification.js +0 -1
  593. package/bundle/dist/codex-protocol/v2/ThreadInjectItemsParams.js +0 -1
  594. package/bundle/dist/codex-protocol/v2/ThreadInjectItemsResponse.js +0 -1
  595. package/bundle/dist/codex-protocol/v2/ThreadItem.js +0 -1
  596. package/bundle/dist/codex-protocol/v2/ThreadListParams.js +0 -1
  597. package/bundle/dist/codex-protocol/v2/ThreadListResponse.js +0 -1
  598. package/bundle/dist/codex-protocol/v2/ThreadLoadedListParams.js +0 -1
  599. package/bundle/dist/codex-protocol/v2/ThreadLoadedListResponse.js +0 -1
  600. package/bundle/dist/codex-protocol/v2/ThreadMetadataGitInfoUpdateParams.js +0 -1
  601. package/bundle/dist/codex-protocol/v2/ThreadMetadataUpdateParams.js +0 -1
  602. package/bundle/dist/codex-protocol/v2/ThreadMetadataUpdateResponse.js +0 -1
  603. package/bundle/dist/codex-protocol/v2/ThreadNameUpdatedNotification.js +0 -1
  604. package/bundle/dist/codex-protocol/v2/ThreadReadParams.js +0 -1
  605. package/bundle/dist/codex-protocol/v2/ThreadReadResponse.js +0 -1
  606. package/bundle/dist/codex-protocol/v2/ThreadRealtimeAudioChunk.js +0 -1
  607. package/bundle/dist/codex-protocol/v2/ThreadRealtimeClosedNotification.js +0 -1
  608. package/bundle/dist/codex-protocol/v2/ThreadRealtimeErrorNotification.js +0 -1
  609. package/bundle/dist/codex-protocol/v2/ThreadRealtimeItemAddedNotification.js +0 -1
  610. package/bundle/dist/codex-protocol/v2/ThreadRealtimeOutputAudioDeltaNotification.js +0 -1
  611. package/bundle/dist/codex-protocol/v2/ThreadRealtimeSdpNotification.js +0 -1
  612. package/bundle/dist/codex-protocol/v2/ThreadRealtimeStartTransport.js +0 -1
  613. package/bundle/dist/codex-protocol/v2/ThreadRealtimeStartedNotification.js +0 -1
  614. package/bundle/dist/codex-protocol/v2/ThreadRealtimeTranscriptDeltaNotification.js +0 -1
  615. package/bundle/dist/codex-protocol/v2/ThreadRealtimeTranscriptDoneNotification.js +0 -1
  616. package/bundle/dist/codex-protocol/v2/ThreadResumeParams.js +0 -1
  617. package/bundle/dist/codex-protocol/v2/ThreadResumeResponse.js +0 -1
  618. package/bundle/dist/codex-protocol/v2/ThreadRollbackParams.js +0 -1
  619. package/bundle/dist/codex-protocol/v2/ThreadRollbackResponse.js +0 -1
  620. package/bundle/dist/codex-protocol/v2/ThreadSetNameParams.js +0 -1
  621. package/bundle/dist/codex-protocol/v2/ThreadSetNameResponse.js +0 -1
  622. package/bundle/dist/codex-protocol/v2/ThreadShellCommandParams.js +0 -1
  623. package/bundle/dist/codex-protocol/v2/ThreadShellCommandResponse.js +0 -1
  624. package/bundle/dist/codex-protocol/v2/ThreadSortKey.js +0 -1
  625. package/bundle/dist/codex-protocol/v2/ThreadSource.js +0 -1
  626. package/bundle/dist/codex-protocol/v2/ThreadSourceKind.js +0 -1
  627. package/bundle/dist/codex-protocol/v2/ThreadStartParams.js +0 -1
  628. package/bundle/dist/codex-protocol/v2/ThreadStartResponse.js +0 -1
  629. package/bundle/dist/codex-protocol/v2/ThreadStartSource.js +0 -1
  630. package/bundle/dist/codex-protocol/v2/ThreadStartedNotification.js +0 -1
  631. package/bundle/dist/codex-protocol/v2/ThreadStatus.js +0 -1
  632. package/bundle/dist/codex-protocol/v2/ThreadStatusChangedNotification.js +0 -1
  633. package/bundle/dist/codex-protocol/v2/ThreadTokenUsage.js +0 -1
  634. package/bundle/dist/codex-protocol/v2/ThreadTokenUsageUpdatedNotification.js +0 -1
  635. package/bundle/dist/codex-protocol/v2/ThreadUnarchiveParams.js +0 -1
  636. package/bundle/dist/codex-protocol/v2/ThreadUnarchiveResponse.js +0 -1
  637. package/bundle/dist/codex-protocol/v2/ThreadUnarchivedNotification.js +0 -1
  638. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeParams.js +0 -1
  639. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeResponse.js +0 -1
  640. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeStatus.js +0 -1
  641. package/bundle/dist/codex-protocol/v2/TokenUsageBreakdown.js +0 -1
  642. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputAnswer.js +0 -1
  643. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputOption.js +0 -1
  644. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputParams.js +0 -1
  645. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputQuestion.js +0 -1
  646. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputResponse.js +0 -1
  647. package/bundle/dist/codex-protocol/v2/ToolsV2.js +0 -1
  648. package/bundle/dist/codex-protocol/v2/Turn.js +0 -1
  649. package/bundle/dist/codex-protocol/v2/TurnCompletedNotification.js +0 -1
  650. package/bundle/dist/codex-protocol/v2/TurnDiffUpdatedNotification.js +0 -1
  651. package/bundle/dist/codex-protocol/v2/TurnEnvironmentParams.js +0 -1
  652. package/bundle/dist/codex-protocol/v2/TurnError.js +0 -1
  653. package/bundle/dist/codex-protocol/v2/TurnInterruptParams.js +0 -1
  654. package/bundle/dist/codex-protocol/v2/TurnInterruptResponse.js +0 -1
  655. package/bundle/dist/codex-protocol/v2/TurnItemsView.js +0 -1
  656. package/bundle/dist/codex-protocol/v2/TurnPlanStep.js +0 -1
  657. package/bundle/dist/codex-protocol/v2/TurnPlanStepStatus.js +0 -1
  658. package/bundle/dist/codex-protocol/v2/TurnPlanUpdatedNotification.js +0 -1
  659. package/bundle/dist/codex-protocol/v2/TurnStartParams.js +0 -1
  660. package/bundle/dist/codex-protocol/v2/TurnStartResponse.js +0 -1
  661. package/bundle/dist/codex-protocol/v2/TurnStartedNotification.js +0 -1
  662. package/bundle/dist/codex-protocol/v2/TurnStatus.js +0 -1
  663. package/bundle/dist/codex-protocol/v2/TurnSteerParams.js +0 -1
  664. package/bundle/dist/codex-protocol/v2/TurnSteerResponse.js +0 -1
  665. package/bundle/dist/codex-protocol/v2/UserInput.js +0 -1
  666. package/bundle/dist/codex-protocol/v2/WarningNotification.js +0 -1
  667. package/bundle/dist/codex-protocol/v2/WebSearchAction.js +0 -1
  668. package/bundle/dist/codex-protocol/v2/WindowsSandboxReadiness.js +0 -1
  669. package/bundle/dist/codex-protocol/v2/WindowsSandboxReadinessResponse.js +0 -1
  670. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupCompletedNotification.js +0 -1
  671. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupMode.js +0 -1
  672. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupStartParams.js +0 -1
  673. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupStartResponse.js +0 -1
  674. package/bundle/dist/codex-protocol/v2/WindowsWorldWritableWarningNotification.js +0 -1
  675. package/bundle/dist/codex-protocol/v2/WriteStatus.js +0 -1
  676. package/bundle/dist/codex-protocol/v2/index.js +0 -7
  677. package/bundle/dist/utils/providers/openai/codex-rpc.js +0 -153
  678. package/bundle/dist/utils/providers/openai/codex-worker.js +0 -642
  679. package/bundle/dist/utils/providers/openai/openai-worker-pool-config.js +0 -51
  680. package/bundle/src/codex-protocol/AbsolutePathBuf.ts +0 -14
  681. package/bundle/src/codex-protocol/AgentPath.ts +0 -5
  682. package/bundle/src/codex-protocol/ApplyPatchApprovalParams.ts +0 -24
  683. package/bundle/src/codex-protocol/ApplyPatchApprovalResponse.ts +0 -6
  684. package/bundle/src/codex-protocol/AuthMode.ts +0 -8
  685. package/bundle/src/codex-protocol/ClientInfo.ts +0 -5
  686. package/bundle/src/codex-protocol/ClientNotification.ts +0 -5
  687. package/bundle/src/codex-protocol/ClientRequest.ts +0 -176
  688. package/bundle/src/codex-protocol/CollaborationMode.ts +0 -10
  689. package/bundle/src/codex-protocol/ContentItem.ts +0 -9
  690. package/bundle/src/codex-protocol/ConversationGitInfo.ts +0 -9
  691. package/bundle/src/codex-protocol/ConversationSummary.ts +0 -19
  692. package/bundle/src/codex-protocol/ExecCommandApprovalParams.ts +0 -22
  693. package/bundle/src/codex-protocol/ExecCommandApprovalResponse.ts +0 -6
  694. package/bundle/src/codex-protocol/ExecPolicyAmendment.ts +0 -12
  695. package/bundle/src/codex-protocol/FileChange.ts +0 -8
  696. package/bundle/src/codex-protocol/ForcedLoginMethod.ts +0 -5
  697. package/bundle/src/codex-protocol/FunctionCallOutputBody.ts +0 -6
  698. package/bundle/src/codex-protocol/FunctionCallOutputContentItem.ts +0 -12
  699. package/bundle/src/codex-protocol/FuzzyFileSearchMatchType.ts +0 -5
  700. package/bundle/src/codex-protocol/FuzzyFileSearchParams.ts +0 -9
  701. package/bundle/src/codex-protocol/FuzzyFileSearchResponse.ts +0 -6
  702. package/bundle/src/codex-protocol/FuzzyFileSearchResult.ts +0 -16
  703. package/bundle/src/codex-protocol/FuzzyFileSearchSessionCompletedNotification.ts +0 -5
  704. package/bundle/src/codex-protocol/FuzzyFileSearchSessionUpdatedNotification.ts +0 -10
  705. package/bundle/src/codex-protocol/GetAuthStatusParams.ts +0 -5
  706. package/bundle/src/codex-protocol/GetAuthStatusResponse.ts +0 -10
  707. package/bundle/src/codex-protocol/GetConversationSummaryParams.ts +0 -6
  708. package/bundle/src/codex-protocol/GetConversationSummaryResponse.ts +0 -6
  709. package/bundle/src/codex-protocol/GitDiffToRemoteParams.ts +0 -5
  710. package/bundle/src/codex-protocol/GitDiffToRemoteResponse.ts +0 -6
  711. package/bundle/src/codex-protocol/GitSha.ts +0 -5
  712. package/bundle/src/codex-protocol/ImageDetail.ts +0 -5
  713. package/bundle/src/codex-protocol/InitializeCapabilities.ts +0 -18
  714. package/bundle/src/codex-protocol/InitializeParams.ts +0 -10
  715. package/bundle/src/codex-protocol/InitializeResponse.ts +0 -22
  716. package/bundle/src/codex-protocol/InputModality.ts +0 -8
  717. package/bundle/src/codex-protocol/InternalSessionSource.ts +0 -5
  718. package/bundle/src/codex-protocol/LocalShellAction.ts +0 -6
  719. package/bundle/src/codex-protocol/LocalShellExecAction.ts +0 -11
  720. package/bundle/src/codex-protocol/LocalShellStatus.ts +0 -5
  721. package/bundle/src/codex-protocol/MessagePhase.ts +0 -11
  722. package/bundle/src/codex-protocol/ModeKind.ts +0 -8
  723. package/bundle/src/codex-protocol/NetworkPolicyAmendment.ts +0 -6
  724. package/bundle/src/codex-protocol/NetworkPolicyRuleAction.ts +0 -5
  725. package/bundle/src/codex-protocol/ParsedCommand.ts +0 -20
  726. package/bundle/src/codex-protocol/Personality.ts +0 -5
  727. package/bundle/src/codex-protocol/PlanType.ts +0 -17
  728. package/bundle/src/codex-protocol/RealtimeConversationVersion.ts +0 -5
  729. package/bundle/src/codex-protocol/RealtimeOutputModality.ts +0 -5
  730. package/bundle/src/codex-protocol/RealtimeVoice.ts +0 -24
  731. package/bundle/src/codex-protocol/RealtimeVoicesList.ts +0 -11
  732. package/bundle/src/codex-protocol/ReasoningEffort.ts +0 -8
  733. package/bundle/src/codex-protocol/ReasoningItemContent.ts +0 -7
  734. package/bundle/src/codex-protocol/ReasoningItemReasoningSummary.ts +0 -5
  735. package/bundle/src/codex-protocol/ReasoningSummary.ts +0 -10
  736. package/bundle/src/codex-protocol/RequestId.ts +0 -5
  737. package/bundle/src/codex-protocol/Resource.ts +0 -19
  738. package/bundle/src/codex-protocol/ResourceContent.ts +0 -27
  739. package/bundle/src/codex-protocol/ResourceTemplate.ts +0 -16
  740. package/bundle/src/codex-protocol/ResponseItem.ts +0 -63
  741. package/bundle/src/codex-protocol/ReviewDecision.ts +0 -17
  742. package/bundle/src/codex-protocol/ServerNotification.ts +0 -154
  743. package/bundle/src/codex-protocol/ServerRequest.ts +0 -47
  744. package/bundle/src/codex-protocol/SessionSource.ts +0 -15
  745. package/bundle/src/codex-protocol/Settings.ts +0 -13
  746. package/bundle/src/codex-protocol/SubAgentSource.ts +0 -20
  747. package/bundle/src/codex-protocol/ThreadId.ts +0 -5
  748. package/bundle/src/codex-protocol/ThreadMemoryMode.ts +0 -5
  749. package/bundle/src/codex-protocol/Tool.ts +0 -18
  750. package/bundle/src/codex-protocol/Verbosity.ts +0 -9
  751. package/bundle/src/codex-protocol/WebSearchAction.ts +0 -9
  752. package/bundle/src/codex-protocol/WebSearchContextSize.ts +0 -5
  753. package/bundle/src/codex-protocol/WebSearchLocation.ts +0 -10
  754. package/bundle/src/codex-protocol/WebSearchMode.ts +0 -5
  755. package/bundle/src/codex-protocol/WebSearchToolConfig.ts +0 -11
  756. package/bundle/src/codex-protocol/index.ts +0 -79
  757. package/bundle/src/codex-protocol/serde_json/JsonValue.ts +0 -11
  758. package/bundle/src/codex-protocol/v2/Account.ts +0 -9
  759. package/bundle/src/codex-protocol/v2/AccountLoginCompletedNotification.ts +0 -9
  760. package/bundle/src/codex-protocol/v2/AccountRateLimitsUpdatedNotification.ts +0 -6
  761. package/bundle/src/codex-protocol/v2/AccountUpdatedNotification.ts +0 -7
  762. package/bundle/src/codex-protocol/v2/ActivePermissionProfile.ts +0 -22
  763. package/bundle/src/codex-protocol/v2/ActivePermissionProfileModification.ts +0 -9
  764. package/bundle/src/codex-protocol/v2/AddCreditsNudgeCreditType.ts +0 -5
  765. package/bundle/src/codex-protocol/v2/AddCreditsNudgeEmailStatus.ts +0 -5
  766. package/bundle/src/codex-protocol/v2/AdditionalFileSystemPermissions.ts +0 -18
  767. package/bundle/src/codex-protocol/v2/AdditionalNetworkPermissions.ts +0 -5
  768. package/bundle/src/codex-protocol/v2/AdditionalPermissionProfile.ts +0 -13
  769. package/bundle/src/codex-protocol/v2/AgentMessageDeltaNotification.ts +0 -10
  770. package/bundle/src/codex-protocol/v2/AnalyticsConfig.ts +0 -14
  771. package/bundle/src/codex-protocol/v2/AppBranding.ts +0 -15
  772. package/bundle/src/codex-protocol/v2/AppInfo.ts +0 -32
  773. package/bundle/src/codex-protocol/v2/AppListUpdatedNotification.ts +0 -9
  774. package/bundle/src/codex-protocol/v2/AppMetadata.ts +0 -20
  775. package/bundle/src/codex-protocol/v2/AppReview.ts +0 -5
  776. package/bundle/src/codex-protocol/v2/AppScreenshot.ts +0 -5
  777. package/bundle/src/codex-protocol/v2/AppSummary.ts +0 -14
  778. package/bundle/src/codex-protocol/v2/AppToolApproval.ts +0 -5
  779. package/bundle/src/codex-protocol/v2/AppToolsConfig.ts +0 -8
  780. package/bundle/src/codex-protocol/v2/ApprovalsReviewer.ts +0 -12
  781. package/bundle/src/codex-protocol/v2/AppsConfig.ts +0 -17
  782. package/bundle/src/codex-protocol/v2/AppsDefaultConfig.ts +0 -9
  783. package/bundle/src/codex-protocol/v2/AppsListParams.ts +0 -25
  784. package/bundle/src/codex-protocol/v2/AppsListResponse.ts +0 -16
  785. package/bundle/src/codex-protocol/v2/AskForApproval.ts +0 -18
  786. package/bundle/src/codex-protocol/v2/AutoReviewDecisionSource.ts +0 -8
  787. package/bundle/src/codex-protocol/v2/ByteRange.ts +0 -5
  788. package/bundle/src/codex-protocol/v2/CancelLoginAccountParams.ts +0 -5
  789. package/bundle/src/codex-protocol/v2/CancelLoginAccountResponse.ts +0 -6
  790. package/bundle/src/codex-protocol/v2/CancelLoginAccountStatus.ts +0 -5
  791. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshParams.ts +0 -18
  792. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshReason.ts +0 -5
  793. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshResponse.ts +0 -9
  794. package/bundle/src/codex-protocol/v2/CodexErrorInfo.ts +0 -27
  795. package/bundle/src/codex-protocol/v2/CollabAgentState.ts +0 -6
  796. package/bundle/src/codex-protocol/v2/CollabAgentStatus.ts +0 -12
  797. package/bundle/src/codex-protocol/v2/CollabAgentTool.ts +0 -5
  798. package/bundle/src/codex-protocol/v2/CollabAgentToolCallStatus.ts +0 -5
  799. package/bundle/src/codex-protocol/v2/CollaborationModeMask.ts +0 -15
  800. package/bundle/src/codex-protocol/v2/CommandAction.ts +0 -10
  801. package/bundle/src/codex-protocol/v2/CommandExecOutputDeltaNotification.ts +0 -31
  802. package/bundle/src/codex-protocol/v2/CommandExecOutputStream.ts +0 -8
  803. package/bundle/src/codex-protocol/v2/CommandExecParams.ts +0 -87
  804. package/bundle/src/codex-protocol/v2/CommandExecResizeParams.ts +0 -19
  805. package/bundle/src/codex-protocol/v2/CommandExecResizeResponse.ts +0 -8
  806. package/bundle/src/codex-protocol/v2/CommandExecResponse.ts +0 -25
  807. package/bundle/src/codex-protocol/v2/CommandExecTerminalSize.ts +0 -17
  808. package/bundle/src/codex-protocol/v2/CommandExecTerminateParams.ts +0 -14
  809. package/bundle/src/codex-protocol/v2/CommandExecTerminateResponse.ts +0 -8
  810. package/bundle/src/codex-protocol/v2/CommandExecWriteParams.ts +0 -23
  811. package/bundle/src/codex-protocol/v2/CommandExecWriteResponse.ts +0 -8
  812. package/bundle/src/codex-protocol/v2/CommandExecutionApprovalDecision.ts +0 -13
  813. package/bundle/src/codex-protocol/v2/CommandExecutionOutputDeltaNotification.ts +0 -10
  814. package/bundle/src/codex-protocol/v2/CommandExecutionRequestApprovalParams.ts +0 -47
  815. package/bundle/src/codex-protocol/v2/CommandExecutionRequestApprovalResponse.ts +0 -8
  816. package/bundle/src/codex-protocol/v2/CommandExecutionSource.ts +0 -9
  817. package/bundle/src/codex-protocol/v2/CommandExecutionStatus.ts +0 -5
  818. package/bundle/src/codex-protocol/v2/CommandMigration.ts +0 -5
  819. package/bundle/src/codex-protocol/v2/Config.ts +0 -53
  820. package/bundle/src/codex-protocol/v2/ConfigBatchWriteParams.ts +0 -17
  821. package/bundle/src/codex-protocol/v2/ConfigEdit.ts +0 -7
  822. package/bundle/src/codex-protocol/v2/ConfigLayer.ts +0 -12
  823. package/bundle/src/codex-protocol/v2/ConfigLayerMetadata.ts +0 -6
  824. package/bundle/src/codex-protocol/v2/ConfigLayerSource.ts +0 -27
  825. package/bundle/src/codex-protocol/v2/ConfigReadParams.ts +0 -13
  826. package/bundle/src/codex-protocol/v2/ConfigReadResponse.ts +0 -12
  827. package/bundle/src/codex-protocol/v2/ConfigRequirements.ts +0 -15
  828. package/bundle/src/codex-protocol/v2/ConfigRequirementsReadResponse.ts +0 -11
  829. package/bundle/src/codex-protocol/v2/ConfigValueWriteParams.ts +0 -16
  830. package/bundle/src/codex-protocol/v2/ConfigWarningNotification.ts +0 -23
  831. package/bundle/src/codex-protocol/v2/ConfigWriteResponse.ts +0 -16
  832. package/bundle/src/codex-protocol/v2/ConfiguredHookHandler.ts +0 -14
  833. package/bundle/src/codex-protocol/v2/ConfiguredHookMatcherGroup.ts +0 -9
  834. package/bundle/src/codex-protocol/v2/ContextCompactedNotification.ts +0 -8
  835. package/bundle/src/codex-protocol/v2/CreditsSnapshot.ts +0 -5
  836. package/bundle/src/codex-protocol/v2/DeprecationNoticeNotification.ts +0 -14
  837. package/bundle/src/codex-protocol/v2/DynamicToolCallOutputContentItem.ts +0 -7
  838. package/bundle/src/codex-protocol/v2/DynamicToolCallParams.ts +0 -13
  839. package/bundle/src/codex-protocol/v2/DynamicToolCallResponse.ts +0 -9
  840. package/bundle/src/codex-protocol/v2/DynamicToolCallStatus.ts +0 -5
  841. package/bundle/src/codex-protocol/v2/DynamicToolSpec.ts +0 -12
  842. package/bundle/src/codex-protocol/v2/ErrorNotification.ts +0 -11
  843. package/bundle/src/codex-protocol/v2/ExecPolicyAmendment.ts +0 -5
  844. package/bundle/src/codex-protocol/v2/ExperimentalFeature.ts +0 -38
  845. package/bundle/src/codex-protocol/v2/ExperimentalFeatureEnablementSetParams.ts +0 -13
  846. package/bundle/src/codex-protocol/v2/ExperimentalFeatureEnablementSetResponse.ts +0 -10
  847. package/bundle/src/codex-protocol/v2/ExperimentalFeatureListParams.ts +0 -14
  848. package/bundle/src/codex-protocol/v2/ExperimentalFeatureListResponse.ts +0 -13
  849. package/bundle/src/codex-protocol/v2/ExperimentalFeatureStage.ts +0 -10
  850. package/bundle/src/codex-protocol/v2/ExternalAgentConfigDetectParams.ts +0 -14
  851. package/bundle/src/codex-protocol/v2/ExternalAgentConfigDetectResponse.ts +0 -6
  852. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportCompletedNotification.ts +0 -5
  853. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportParams.ts +0 -8
  854. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportResponse.ts +0 -5
  855. package/bundle/src/codex-protocol/v2/ExternalAgentConfigMigrationItem.ts +0 -15
  856. package/bundle/src/codex-protocol/v2/ExternalAgentConfigMigrationItemType.ts +0 -14
  857. package/bundle/src/codex-protocol/v2/FeedbackUploadParams.ts +0 -12
  858. package/bundle/src/codex-protocol/v2/FeedbackUploadResponse.ts +0 -5
  859. package/bundle/src/codex-protocol/v2/FileChangeApprovalDecision.ts +0 -5
  860. package/bundle/src/codex-protocol/v2/FileChangeOutputDeltaNotification.ts +0 -15
  861. package/bundle/src/codex-protocol/v2/FileChangePatchUpdatedNotification.ts +0 -11
  862. package/bundle/src/codex-protocol/v2/FileChangeRequestApprovalParams.ts +0 -22
  863. package/bundle/src/codex-protocol/v2/FileChangeRequestApprovalResponse.ts +0 -6
  864. package/bundle/src/codex-protocol/v2/FileSystemAccessMode.ts +0 -5
  865. package/bundle/src/codex-protocol/v2/FileSystemPath.ts +0 -10
  866. package/bundle/src/codex-protocol/v2/FileSystemSandboxEntry.ts +0 -7
  867. package/bundle/src/codex-protocol/v2/FileSystemSpecialPath.ts +0 -11
  868. package/bundle/src/codex-protocol/v2/FileUpdateChange.ts +0 -6
  869. package/bundle/src/codex-protocol/v2/FsChangedNotification.ts +0 -18
  870. package/bundle/src/codex-protocol/v2/FsCopyParams.ts +0 -22
  871. package/bundle/src/codex-protocol/v2/FsCopyResponse.ts +0 -8
  872. package/bundle/src/codex-protocol/v2/FsCreateDirectoryParams.ts +0 -18
  873. package/bundle/src/codex-protocol/v2/FsCreateDirectoryResponse.ts +0 -8
  874. package/bundle/src/codex-protocol/v2/FsGetMetadataParams.ts +0 -14
  875. package/bundle/src/codex-protocol/v2/FsGetMetadataResponse.ts +0 -29
  876. package/bundle/src/codex-protocol/v2/FsReadDirectoryEntry.ts +0 -21
  877. package/bundle/src/codex-protocol/v2/FsReadDirectoryParams.ts +0 -14
  878. package/bundle/src/codex-protocol/v2/FsReadDirectoryResponse.ts +0 -14
  879. package/bundle/src/codex-protocol/v2/FsReadFileParams.ts +0 -14
  880. package/bundle/src/codex-protocol/v2/FsReadFileResponse.ts +0 -13
  881. package/bundle/src/codex-protocol/v2/FsRemoveParams.ts +0 -22
  882. package/bundle/src/codex-protocol/v2/FsRemoveResponse.ts +0 -8
  883. package/bundle/src/codex-protocol/v2/FsUnwatchParams.ts +0 -13
  884. package/bundle/src/codex-protocol/v2/FsUnwatchResponse.ts +0 -8
  885. package/bundle/src/codex-protocol/v2/FsWatchParams.ts +0 -18
  886. package/bundle/src/codex-protocol/v2/FsWatchResponse.ts +0 -14
  887. package/bundle/src/codex-protocol/v2/FsWriteFileParams.ts +0 -18
  888. package/bundle/src/codex-protocol/v2/FsWriteFileResponse.ts +0 -8
  889. package/bundle/src/codex-protocol/v2/GetAccountParams.ts +0 -14
  890. package/bundle/src/codex-protocol/v2/GetAccountRateLimitsResponse.ts +0 -15
  891. package/bundle/src/codex-protocol/v2/GetAccountResponse.ts +0 -6
  892. package/bundle/src/codex-protocol/v2/GitInfo.ts +0 -5
  893. package/bundle/src/codex-protocol/v2/GrantedPermissionProfile.ts +0 -10
  894. package/bundle/src/codex-protocol/v2/GuardianApprovalReview.ts +0 -18
  895. package/bundle/src/codex-protocol/v2/GuardianApprovalReviewAction.ts +0 -34
  896. package/bundle/src/codex-protocol/v2/GuardianApprovalReviewStatus.ts +0 -13
  897. package/bundle/src/codex-protocol/v2/GuardianCommandSource.ts +0 -5
  898. package/bundle/src/codex-protocol/v2/GuardianRiskLevel.ts +0 -8
  899. package/bundle/src/codex-protocol/v2/GuardianUserAuthorization.ts +0 -8
  900. package/bundle/src/codex-protocol/v2/GuardianWarningNotification.ts +0 -14
  901. package/bundle/src/codex-protocol/v2/HookCompletedNotification.ts +0 -10
  902. package/bundle/src/codex-protocol/v2/HookErrorInfo.ts +0 -5
  903. package/bundle/src/codex-protocol/v2/HookEventName.ts +0 -13
  904. package/bundle/src/codex-protocol/v2/HookExecutionMode.ts +0 -5
  905. package/bundle/src/codex-protocol/v2/HookHandlerType.ts +0 -5
  906. package/bundle/src/codex-protocol/v2/HookMetadata.ts +0 -26
  907. package/bundle/src/codex-protocol/v2/HookMigration.ts +0 -5
  908. package/bundle/src/codex-protocol/v2/HookOutputEntry.ts +0 -6
  909. package/bundle/src/codex-protocol/v2/HookOutputEntryKind.ts +0 -5
  910. package/bundle/src/codex-protocol/v2/HookPromptFragment.ts +0 -5
  911. package/bundle/src/codex-protocol/v2/HookRunStatus.ts +0 -5
  912. package/bundle/src/codex-protocol/v2/HookRunSummary.ts +0 -28
  913. package/bundle/src/codex-protocol/v2/HookScope.ts +0 -5
  914. package/bundle/src/codex-protocol/v2/HookSource.ts +0 -15
  915. package/bundle/src/codex-protocol/v2/HookStartedNotification.ts +0 -10
  916. package/bundle/src/codex-protocol/v2/HookTrustStatus.ts +0 -5
  917. package/bundle/src/codex-protocol/v2/HooksListEntry.ts +0 -12
  918. package/bundle/src/codex-protocol/v2/HooksListParams.ts +0 -10
  919. package/bundle/src/codex-protocol/v2/HooksListResponse.ts +0 -6
  920. package/bundle/src/codex-protocol/v2/ItemCompletedNotification.ts +0 -14
  921. package/bundle/src/codex-protocol/v2/ItemGuardianApprovalReviewCompletedNotification.ts +0 -44
  922. package/bundle/src/codex-protocol/v2/ItemGuardianApprovalReviewStartedNotification.ts +0 -38
  923. package/bundle/src/codex-protocol/v2/ItemStartedNotification.ts +0 -14
  924. package/bundle/src/codex-protocol/v2/ListMcpServerStatusParams.ts +0 -20
  925. package/bundle/src/codex-protocol/v2/ListMcpServerStatusResponse.ts +0 -13
  926. package/bundle/src/codex-protocol/v2/LoginAccountParams.ts +0 -27
  927. package/bundle/src/codex-protocol/v2/LoginAccountResponse.ts +0 -27
  928. package/bundle/src/codex-protocol/v2/LogoutAccountResponse.ts +0 -5
  929. package/bundle/src/codex-protocol/v2/ManagedHooksRequirements.ts +0 -17
  930. package/bundle/src/codex-protocol/v2/MarketplaceAddParams.ts +0 -9
  931. package/bundle/src/codex-protocol/v2/MarketplaceAddResponse.ts +0 -10
  932. package/bundle/src/codex-protocol/v2/MarketplaceInterface.ts +0 -5
  933. package/bundle/src/codex-protocol/v2/MarketplaceLoadErrorInfo.ts +0 -6
  934. package/bundle/src/codex-protocol/v2/MarketplaceRemoveParams.ts +0 -5
  935. package/bundle/src/codex-protocol/v2/MarketplaceRemoveResponse.ts +0 -9
  936. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeErrorInfo.ts +0 -5
  937. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeParams.ts +0 -5
  938. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeResponse.ts +0 -11
  939. package/bundle/src/codex-protocol/v2/McpAuthStatus.ts +0 -5
  940. package/bundle/src/codex-protocol/v2/McpElicitationArrayType.ts +0 -5
  941. package/bundle/src/codex-protocol/v2/McpElicitationBooleanSchema.ts +0 -11
  942. package/bundle/src/codex-protocol/v2/McpElicitationBooleanType.ts +0 -5
  943. package/bundle/src/codex-protocol/v2/McpElicitationConstOption.ts +0 -5
  944. package/bundle/src/codex-protocol/v2/McpElicitationEnumSchema.ts +0 -11
  945. package/bundle/src/codex-protocol/v2/McpElicitationLegacyTitledEnumSchema.ts +0 -13
  946. package/bundle/src/codex-protocol/v2/McpElicitationMultiSelectEnumSchema.ts +0 -9
  947. package/bundle/src/codex-protocol/v2/McpElicitationNumberSchema.ts +0 -13
  948. package/bundle/src/codex-protocol/v2/McpElicitationNumberType.ts +0 -5
  949. package/bundle/src/codex-protocol/v2/McpElicitationObjectType.ts +0 -5
  950. package/bundle/src/codex-protocol/v2/McpElicitationPrimitiveSchema.ts +0 -13
  951. package/bundle/src/codex-protocol/v2/McpElicitationSchema.ts +0 -18
  952. package/bundle/src/codex-protocol/v2/McpElicitationSingleSelectEnumSchema.ts +0 -9
  953. package/bundle/src/codex-protocol/v2/McpElicitationStringFormat.ts +0 -5
  954. package/bundle/src/codex-protocol/v2/McpElicitationStringSchema.ts +0 -15
  955. package/bundle/src/codex-protocol/v2/McpElicitationStringType.ts +0 -5
  956. package/bundle/src/codex-protocol/v2/McpElicitationTitledEnumItems.ts +0 -6
  957. package/bundle/src/codex-protocol/v2/McpElicitationTitledMultiSelectEnumSchema.ts +0 -15
  958. package/bundle/src/codex-protocol/v2/McpElicitationTitledSingleSelectEnumSchema.ts +0 -13
  959. package/bundle/src/codex-protocol/v2/McpElicitationUntitledEnumItems.ts +0 -9
  960. package/bundle/src/codex-protocol/v2/McpElicitationUntitledMultiSelectEnumSchema.ts +0 -15
  961. package/bundle/src/codex-protocol/v2/McpElicitationUntitledSingleSelectEnumSchema.ts +0 -12
  962. package/bundle/src/codex-protocol/v2/McpResourceReadParams.ts +0 -5
  963. package/bundle/src/codex-protocol/v2/McpResourceReadResponse.ts +0 -6
  964. package/bundle/src/codex-protocol/v2/McpServerElicitationAction.ts +0 -5
  965. package/bundle/src/codex-protocol/v2/McpServerElicitationRequestParams.ts +0 -27
  966. package/bundle/src/codex-protocol/v2/McpServerElicitationRequestResponse.ts +0 -19
  967. package/bundle/src/codex-protocol/v2/McpServerMigration.ts +0 -5
  968. package/bundle/src/codex-protocol/v2/McpServerOauthLoginCompletedNotification.ts +0 -9
  969. package/bundle/src/codex-protocol/v2/McpServerOauthLoginParams.ts +0 -9
  970. package/bundle/src/codex-protocol/v2/McpServerOauthLoginResponse.ts +0 -5
  971. package/bundle/src/codex-protocol/v2/McpServerRefreshResponse.ts +0 -5
  972. package/bundle/src/codex-protocol/v2/McpServerStartupState.ts +0 -5
  973. package/bundle/src/codex-protocol/v2/McpServerStatus.ts +0 -15
  974. package/bundle/src/codex-protocol/v2/McpServerStatusDetail.ts +0 -5
  975. package/bundle/src/codex-protocol/v2/McpServerStatusUpdatedNotification.ts +0 -10
  976. package/bundle/src/codex-protocol/v2/McpServerToolCallParams.ts +0 -12
  977. package/bundle/src/codex-protocol/v2/McpServerToolCallResponse.ts +0 -11
  978. package/bundle/src/codex-protocol/v2/McpToolCallError.ts +0 -5
  979. package/bundle/src/codex-protocol/v2/McpToolCallProgressNotification.ts +0 -10
  980. package/bundle/src/codex-protocol/v2/McpToolCallResult.ts +0 -10
  981. package/bundle/src/codex-protocol/v2/McpToolCallStatus.ts +0 -5
  982. package/bundle/src/codex-protocol/v2/MemoryCitation.ts +0 -6
  983. package/bundle/src/codex-protocol/v2/MemoryCitationEntry.ts +0 -10
  984. package/bundle/src/codex-protocol/v2/MergeStrategy.ts +0 -5
  985. package/bundle/src/codex-protocol/v2/MigrationDetails.ts +0 -18
  986. package/bundle/src/codex-protocol/v2/Model.ts +0 -30
  987. package/bundle/src/codex-protocol/v2/ModelAvailabilityNux.ts +0 -5
  988. package/bundle/src/codex-protocol/v2/ModelListParams.ts +0 -18
  989. package/bundle/src/codex-protocol/v2/ModelListResponse.ts +0 -13
  990. package/bundle/src/codex-protocol/v2/ModelProviderCapabilitiesReadParams.ts +0 -5
  991. package/bundle/src/codex-protocol/v2/ModelProviderCapabilitiesReadResponse.ts +0 -9
  992. package/bundle/src/codex-protocol/v2/ModelRerouteReason.ts +0 -5
  993. package/bundle/src/codex-protocol/v2/ModelReroutedNotification.ts +0 -12
  994. package/bundle/src/codex-protocol/v2/ModelServiceTier.ts +0 -5
  995. package/bundle/src/codex-protocol/v2/ModelUpgradeInfo.ts +0 -10
  996. package/bundle/src/codex-protocol/v2/ModelVerification.ts +0 -5
  997. package/bundle/src/codex-protocol/v2/ModelVerificationNotification.ts +0 -10
  998. package/bundle/src/codex-protocol/v2/NetworkAccess.ts +0 -5
  999. package/bundle/src/codex-protocol/v2/NetworkApprovalContext.ts +0 -6
  1000. package/bundle/src/codex-protocol/v2/NetworkApprovalProtocol.ts +0 -5
  1001. package/bundle/src/codex-protocol/v2/NetworkDomainPermission.ts +0 -5
  1002. package/bundle/src/codex-protocol/v2/NetworkPolicyAmendment.ts +0 -6
  1003. package/bundle/src/codex-protocol/v2/NetworkPolicyRuleAction.ts +0 -5
  1004. package/bundle/src/codex-protocol/v2/NetworkRequirements.ts +0 -40
  1005. package/bundle/src/codex-protocol/v2/NetworkUnixSocketPermission.ts +0 -5
  1006. package/bundle/src/codex-protocol/v2/NonSteerableTurnKind.ts +0 -5
  1007. package/bundle/src/codex-protocol/v2/OverriddenMetadata.ts +0 -11
  1008. package/bundle/src/codex-protocol/v2/PatchApplyStatus.ts +0 -5
  1009. package/bundle/src/codex-protocol/v2/PatchChangeKind.ts +0 -8
  1010. package/bundle/src/codex-protocol/v2/PermissionGrantScope.ts +0 -5
  1011. package/bundle/src/codex-protocol/v2/PermissionProfile.ts +0 -14
  1012. package/bundle/src/codex-protocol/v2/PermissionProfileFileSystemPermissions.ts +0 -8
  1013. package/bundle/src/codex-protocol/v2/PermissionProfileModificationParams.ts +0 -9
  1014. package/bundle/src/codex-protocol/v2/PermissionProfileNetworkPermissions.ts +0 -5
  1015. package/bundle/src/codex-protocol/v2/PermissionProfileSelectionParams.ts +0 -10
  1016. package/bundle/src/codex-protocol/v2/PermissionsRequestApprovalParams.ts +0 -18
  1017. package/bundle/src/codex-protocol/v2/PermissionsRequestApprovalResponse.ts +0 -14
  1018. package/bundle/src/codex-protocol/v2/PlanDeltaNotification.ts +0 -14
  1019. package/bundle/src/codex-protocol/v2/PluginAuthPolicy.ts +0 -5
  1020. package/bundle/src/codex-protocol/v2/PluginAvailability.ts +0 -5
  1021. package/bundle/src/codex-protocol/v2/PluginDetail.ts +0 -19
  1022. package/bundle/src/codex-protocol/v2/PluginHookSummary.ts +0 -6
  1023. package/bundle/src/codex-protocol/v2/PluginInstallParams.ts +0 -10
  1024. package/bundle/src/codex-protocol/v2/PluginInstallPolicy.ts +0 -5
  1025. package/bundle/src/codex-protocol/v2/PluginInstallResponse.ts +0 -10
  1026. package/bundle/src/codex-protocol/v2/PluginInterface.ts +0 -46
  1027. package/bundle/src/codex-protocol/v2/PluginListMarketplaceKind.ts +0 -5
  1028. package/bundle/src/codex-protocol/v2/PluginListParams.ts +0 -18
  1029. package/bundle/src/codex-protocol/v2/PluginListResponse.ts +0 -11
  1030. package/bundle/src/codex-protocol/v2/PluginMarketplaceEntry.ts +0 -17
  1031. package/bundle/src/codex-protocol/v2/PluginReadParams.ts +0 -10
  1032. package/bundle/src/codex-protocol/v2/PluginReadResponse.ts +0 -6
  1033. package/bundle/src/codex-protocol/v2/PluginShareContext.ts +0 -12
  1034. package/bundle/src/codex-protocol/v2/PluginShareDeleteParams.ts +0 -5
  1035. package/bundle/src/codex-protocol/v2/PluginShareDeleteResponse.ts +0 -5
  1036. package/bundle/src/codex-protocol/v2/PluginShareDiscoverability.ts +0 -5
  1037. package/bundle/src/codex-protocol/v2/PluginShareListItem.ts +0 -11
  1038. package/bundle/src/codex-protocol/v2/PluginShareListParams.ts +0 -5
  1039. package/bundle/src/codex-protocol/v2/PluginShareListResponse.ts +0 -6
  1040. package/bundle/src/codex-protocol/v2/PluginSharePrincipal.ts +0 -10
  1041. package/bundle/src/codex-protocol/v2/PluginSharePrincipalType.ts +0 -5
  1042. package/bundle/src/codex-protocol/v2/PluginShareSaveParams.ts +0 -13
  1043. package/bundle/src/codex-protocol/v2/PluginShareSaveResponse.ts +0 -5
  1044. package/bundle/src/codex-protocol/v2/PluginShareTarget.ts +0 -6
  1045. package/bundle/src/codex-protocol/v2/PluginShareUpdateDiscoverability.ts +0 -5
  1046. package/bundle/src/codex-protocol/v2/PluginShareUpdateTargetsParams.ts +0 -11
  1047. package/bundle/src/codex-protocol/v2/PluginShareUpdateTargetsResponse.ts +0 -10
  1048. package/bundle/src/codex-protocol/v2/PluginSkillReadParams.ts +0 -9
  1049. package/bundle/src/codex-protocol/v2/PluginSkillReadResponse.ts +0 -5
  1050. package/bundle/src/codex-protocol/v2/PluginSource.ts +0 -9
  1051. package/bundle/src/codex-protocol/v2/PluginSummary.ts +0 -29
  1052. package/bundle/src/codex-protocol/v2/PluginUninstallParams.ts +0 -5
  1053. package/bundle/src/codex-protocol/v2/PluginUninstallResponse.ts +0 -5
  1054. package/bundle/src/codex-protocol/v2/PluginsMigration.ts +0 -5
  1055. package/bundle/src/codex-protocol/v2/ProcessExitedNotification.ts +0 -43
  1056. package/bundle/src/codex-protocol/v2/ProcessOutputDeltaNotification.ts +0 -27
  1057. package/bundle/src/codex-protocol/v2/ProcessOutputStream.ts +0 -8
  1058. package/bundle/src/codex-protocol/v2/ProcessTerminalSize.ts +0 -17
  1059. package/bundle/src/codex-protocol/v2/ProfileV2.ts +0 -37
  1060. package/bundle/src/codex-protocol/v2/RateLimitReachedType.ts +0 -10
  1061. package/bundle/src/codex-protocol/v2/RateLimitSnapshot.ts +0 -17
  1062. package/bundle/src/codex-protocol/v2/RateLimitWindow.ts +0 -9
  1063. package/bundle/src/codex-protocol/v2/RawResponseItemCompletedNotification.ts +0 -10
  1064. package/bundle/src/codex-protocol/v2/ReasoningEffortOption.ts +0 -6
  1065. package/bundle/src/codex-protocol/v2/ReasoningSummaryPartAddedNotification.ts +0 -10
  1066. package/bundle/src/codex-protocol/v2/ReasoningSummaryTextDeltaNotification.ts +0 -11
  1067. package/bundle/src/codex-protocol/v2/ReasoningTextDeltaNotification.ts +0 -11
  1068. package/bundle/src/codex-protocol/v2/RemoteControlConnectionStatus.ts +0 -5
  1069. package/bundle/src/codex-protocol/v2/RemoteControlStatusChangedNotification.ts +0 -12
  1070. package/bundle/src/codex-protocol/v2/RequestPermissionProfile.ts +0 -10
  1071. package/bundle/src/codex-protocol/v2/ResidencyRequirement.ts +0 -5
  1072. package/bundle/src/codex-protocol/v2/ReviewDelivery.ts +0 -5
  1073. package/bundle/src/codex-protocol/v2/ReviewStartParams.ts +0 -15
  1074. package/bundle/src/codex-protocol/v2/ReviewStartResponse.ts +0 -15
  1075. package/bundle/src/codex-protocol/v2/ReviewTarget.ts +0 -16
  1076. package/bundle/src/codex-protocol/v2/SandboxMode.ts +0 -5
  1077. package/bundle/src/codex-protocol/v2/SandboxPolicy.ts +0 -17
  1078. package/bundle/src/codex-protocol/v2/SandboxWorkspaceWrite.ts +0 -10
  1079. package/bundle/src/codex-protocol/v2/SendAddCreditsNudgeEmailParams.ts +0 -6
  1080. package/bundle/src/codex-protocol/v2/SendAddCreditsNudgeEmailResponse.ts +0 -6
  1081. package/bundle/src/codex-protocol/v2/ServerRequestResolvedNotification.ts +0 -6
  1082. package/bundle/src/codex-protocol/v2/SessionMigration.ts +0 -5
  1083. package/bundle/src/codex-protocol/v2/SessionSource.ts +0 -13
  1084. package/bundle/src/codex-protocol/v2/SkillDependencies.ts +0 -6
  1085. package/bundle/src/codex-protocol/v2/SkillErrorInfo.ts +0 -5
  1086. package/bundle/src/codex-protocol/v2/SkillInterface.ts +0 -13
  1087. package/bundle/src/codex-protocol/v2/SkillMetadata.ts +0 -21
  1088. package/bundle/src/codex-protocol/v2/SkillScope.ts +0 -5
  1089. package/bundle/src/codex-protocol/v2/SkillSummary.ts +0 -14
  1090. package/bundle/src/codex-protocol/v2/SkillToolDependency.ts +0 -12
  1091. package/bundle/src/codex-protocol/v2/SkillsChangedNotification.ts +0 -11
  1092. package/bundle/src/codex-protocol/v2/SkillsConfigWriteParams.ts +0 -16
  1093. package/bundle/src/codex-protocol/v2/SkillsConfigWriteResponse.ts +0 -5
  1094. package/bundle/src/codex-protocol/v2/SkillsListEntry.ts +0 -11
  1095. package/bundle/src/codex-protocol/v2/SkillsListParams.ts +0 -14
  1096. package/bundle/src/codex-protocol/v2/SkillsListResponse.ts +0 -6
  1097. package/bundle/src/codex-protocol/v2/SortDirection.ts +0 -5
  1098. package/bundle/src/codex-protocol/v2/SubagentMigration.ts +0 -5
  1099. package/bundle/src/codex-protocol/v2/TerminalInteractionNotification.ts +0 -11
  1100. package/bundle/src/codex-protocol/v2/TextElement.ts +0 -15
  1101. package/bundle/src/codex-protocol/v2/TextPosition.ts +0 -14
  1102. package/bundle/src/codex-protocol/v2/TextRange.ts +0 -6
  1103. package/bundle/src/codex-protocol/v2/Thread.ts +0 -88
  1104. package/bundle/src/codex-protocol/v2/ThreadActiveFlag.ts +0 -5
  1105. package/bundle/src/codex-protocol/v2/ThreadApproveGuardianDeniedActionParams.ts +0 -12
  1106. package/bundle/src/codex-protocol/v2/ThreadApproveGuardianDeniedActionResponse.ts +0 -5
  1107. package/bundle/src/codex-protocol/v2/ThreadArchiveParams.ts +0 -5
  1108. package/bundle/src/codex-protocol/v2/ThreadArchiveResponse.ts +0 -5
  1109. package/bundle/src/codex-protocol/v2/ThreadArchivedNotification.ts +0 -5
  1110. package/bundle/src/codex-protocol/v2/ThreadClosedNotification.ts +0 -5
  1111. package/bundle/src/codex-protocol/v2/ThreadCompactStartParams.ts +0 -5
  1112. package/bundle/src/codex-protocol/v2/ThreadCompactStartResponse.ts +0 -5
  1113. package/bundle/src/codex-protocol/v2/ThreadForkParams.ts +0 -40
  1114. package/bundle/src/codex-protocol/v2/ThreadForkResponse.ts +0 -30
  1115. package/bundle/src/codex-protocol/v2/ThreadGoal.ts +0 -15
  1116. package/bundle/src/codex-protocol/v2/ThreadGoalClearedNotification.ts +0 -5
  1117. package/bundle/src/codex-protocol/v2/ThreadGoalStatus.ts +0 -5
  1118. package/bundle/src/codex-protocol/v2/ThreadGoalUpdatedNotification.ts +0 -10
  1119. package/bundle/src/codex-protocol/v2/ThreadInjectItemsParams.ts +0 -12
  1120. package/bundle/src/codex-protocol/v2/ThreadInjectItemsResponse.ts +0 -5
  1121. package/bundle/src/codex-protocol/v2/ThreadItem.ts +0 -156
  1122. package/bundle/src/codex-protocol/v2/ThreadListParams.ts +0 -55
  1123. package/bundle/src/codex-protocol/v2/ThreadListResponse.ts +0 -20
  1124. package/bundle/src/codex-protocol/v2/ThreadLoadedListParams.ts +0 -14
  1125. package/bundle/src/codex-protocol/v2/ThreadLoadedListResponse.ts +0 -15
  1126. package/bundle/src/codex-protocol/v2/ThreadMetadataGitInfoUpdateParams.ts +0 -21
  1127. package/bundle/src/codex-protocol/v2/ThreadMetadataUpdateParams.ts +0 -14
  1128. package/bundle/src/codex-protocol/v2/ThreadMetadataUpdateResponse.ts +0 -6
  1129. package/bundle/src/codex-protocol/v2/ThreadNameUpdatedNotification.ts +0 -5
  1130. package/bundle/src/codex-protocol/v2/ThreadReadParams.ts +0 -11
  1131. package/bundle/src/codex-protocol/v2/ThreadReadResponse.ts +0 -6
  1132. package/bundle/src/codex-protocol/v2/ThreadRealtimeAudioChunk.ts +0 -14
  1133. package/bundle/src/codex-protocol/v2/ThreadRealtimeClosedNotification.ts +0 -8
  1134. package/bundle/src/codex-protocol/v2/ThreadRealtimeErrorNotification.ts +0 -8
  1135. package/bundle/src/codex-protocol/v2/ThreadRealtimeItemAddedNotification.ts +0 -9
  1136. package/bundle/src/codex-protocol/v2/ThreadRealtimeOutputAudioDeltaNotification.ts +0 -12
  1137. package/bundle/src/codex-protocol/v2/ThreadRealtimeSdpNotification.ts +0 -8
  1138. package/bundle/src/codex-protocol/v2/ThreadRealtimeStartTransport.ts +0 -17
  1139. package/bundle/src/codex-protocol/v2/ThreadRealtimeStartedNotification.ts +0 -13
  1140. package/bundle/src/codex-protocol/v2/ThreadRealtimeTranscriptDeltaNotification.ts +0 -16
  1141. package/bundle/src/codex-protocol/v2/ThreadRealtimeTranscriptDoneNotification.ts +0 -16
  1142. package/bundle/src/codex-protocol/v2/ThreadResumeParams.ts +0 -39
  1143. package/bundle/src/codex-protocol/v2/ThreadResumeResponse.ts +0 -30
  1144. package/bundle/src/codex-protocol/v2/ThreadRollbackParams.ts +0 -14
  1145. package/bundle/src/codex-protocol/v2/ThreadRollbackResponse.ts +0 -15
  1146. package/bundle/src/codex-protocol/v2/ThreadSetNameParams.ts +0 -5
  1147. package/bundle/src/codex-protocol/v2/ThreadSetNameResponse.ts +0 -5
  1148. package/bundle/src/codex-protocol/v2/ThreadShellCommandParams.ts +0 -14
  1149. package/bundle/src/codex-protocol/v2/ThreadShellCommandResponse.ts +0 -5
  1150. package/bundle/src/codex-protocol/v2/ThreadSortKey.ts +0 -5
  1151. package/bundle/src/codex-protocol/v2/ThreadSource.ts +0 -5
  1152. package/bundle/src/codex-protocol/v2/ThreadSourceKind.ts +0 -15
  1153. package/bundle/src/codex-protocol/v2/ThreadStartParams.ts +0 -33
  1154. package/bundle/src/codex-protocol/v2/ThreadStartResponse.ts +0 -30
  1155. package/bundle/src/codex-protocol/v2/ThreadStartSource.ts +0 -5
  1156. package/bundle/src/codex-protocol/v2/ThreadStartedNotification.ts +0 -6
  1157. package/bundle/src/codex-protocol/v2/ThreadStatus.ts +0 -10
  1158. package/bundle/src/codex-protocol/v2/ThreadStatusChangedNotification.ts +0 -6
  1159. package/bundle/src/codex-protocol/v2/ThreadTokenUsage.ts +0 -10
  1160. package/bundle/src/codex-protocol/v2/ThreadTokenUsageUpdatedNotification.ts +0 -10
  1161. package/bundle/src/codex-protocol/v2/ThreadUnarchiveParams.ts +0 -5
  1162. package/bundle/src/codex-protocol/v2/ThreadUnarchiveResponse.ts +0 -6
  1163. package/bundle/src/codex-protocol/v2/ThreadUnarchivedNotification.ts +0 -5
  1164. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeParams.ts +0 -5
  1165. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeResponse.ts +0 -6
  1166. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeStatus.ts +0 -5
  1167. package/bundle/src/codex-protocol/v2/TokenUsageBreakdown.ts +0 -11
  1168. package/bundle/src/codex-protocol/v2/ToolRequestUserInputAnswer.ts +0 -8
  1169. package/bundle/src/codex-protocol/v2/ToolRequestUserInputOption.ts +0 -8
  1170. package/bundle/src/codex-protocol/v2/ToolRequestUserInputParams.ts +0 -14
  1171. package/bundle/src/codex-protocol/v2/ToolRequestUserInputQuestion.ts +0 -16
  1172. package/bundle/src/codex-protocol/v2/ToolRequestUserInputResponse.ts +0 -11
  1173. package/bundle/src/codex-protocol/v2/ToolsV2.ts +0 -6
  1174. package/bundle/src/codex-protocol/v2/Turn.ts +0 -36
  1175. package/bundle/src/codex-protocol/v2/TurnCompletedNotification.ts +0 -6
  1176. package/bundle/src/codex-protocol/v2/TurnDiffUpdatedNotification.ts +0 -9
  1177. package/bundle/src/codex-protocol/v2/TurnEnvironmentParams.ts +0 -6
  1178. package/bundle/src/codex-protocol/v2/TurnError.ts +0 -10
  1179. package/bundle/src/codex-protocol/v2/TurnInterruptParams.ts +0 -5
  1180. package/bundle/src/codex-protocol/v2/TurnInterruptResponse.ts +0 -5
  1181. package/bundle/src/codex-protocol/v2/TurnItemsView.ts +0 -5
  1182. package/bundle/src/codex-protocol/v2/TurnPlanStep.ts +0 -6
  1183. package/bundle/src/codex-protocol/v2/TurnPlanStepStatus.ts +0 -5
  1184. package/bundle/src/codex-protocol/v2/TurnPlanUpdatedNotification.ts +0 -11
  1185. package/bundle/src/codex-protocol/v2/TurnStartParams.ts +0 -48
  1186. package/bundle/src/codex-protocol/v2/TurnStartResponse.ts +0 -6
  1187. package/bundle/src/codex-protocol/v2/TurnStartedNotification.ts +0 -6
  1188. package/bundle/src/codex-protocol/v2/TurnStatus.ts +0 -5
  1189. package/bundle/src/codex-protocol/v2/TurnSteerParams.ts +0 -13
  1190. package/bundle/src/codex-protocol/v2/TurnSteerResponse.ts +0 -5
  1191. package/bundle/src/codex-protocol/v2/UserInput.ts +0 -18
  1192. package/bundle/src/codex-protocol/v2/WarningNotification.ts +0 -14
  1193. package/bundle/src/codex-protocol/v2/WebSearchAction.ts +0 -9
  1194. package/bundle/src/codex-protocol/v2/WindowsSandboxReadiness.ts +0 -5
  1195. package/bundle/src/codex-protocol/v2/WindowsSandboxReadinessResponse.ts +0 -6
  1196. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupCompletedNotification.ts +0 -10
  1197. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupMode.ts +0 -5
  1198. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupStartParams.ts +0 -10
  1199. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupStartResponse.ts +0 -5
  1200. package/bundle/src/codex-protocol/v2/WindowsWorldWritableWarningNotification.ts +0 -9
  1201. package/bundle/src/codex-protocol/v2/WriteStatus.ts +0 -5
  1202. package/bundle/src/codex-protocol/v2/index.ts +0 -446
  1203. package/bundle/src/utils/providers/openai/codex-rpc.ts +0 -238
  1204. package/bundle/src/utils/providers/openai/codex-worker.test.ts +0 -1006
  1205. package/bundle/src/utils/providers/openai/codex-worker.ts +0 -927
  1206. package/bundle/src/utils/providers/openai/openai-worker-pool-config.ts +0 -112
  1207. package/bundle/web-dist/client/assets/index-C0594sjh.js +0 -106
  1208. package/bundle/web-dist/client/assets/index-CcMEpCgt.css +0 -1
  1209. package/bundle/web-dist/client/assets/logs-BotUcOEB.js +0 -1
  1210. package/bundle/web-dist/client/assets/monit-kk3vnGvu.js +0 -1
  1211. package/bundle/web-dist/client/assets/settings-CAAQSIyg.js +0 -1
  1212. package/bundle/web-dist/client/assets/show-BryNvjUT.js +0 -2
  1213. /package/bundle/dist/{codex-protocol/AbsolutePathBuf.js → utils/providers/common/provider-types.js} +0 -0
@@ -1,1775 +1,388 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
1
+ import { describe, expect, it, vi } from "vitest";
2
2
 
3
- import { QuotaThresholdExceededError } from "../../../application/qgrid/qgrid.types";
4
- import { TokenModel } from "../../../application/token/token.model";
5
- import { type OpenAICredentials } from "../../../application/token/token.types";
6
- import { type GenerateRequest, type GenerateResult } from "../common/provider-dispatcher";
7
- import { CodexAppServerWorker } from "./codex-worker";
3
+ import { type GenerateRequest } from "../common/provider-dispatcher";
8
4
  import {
9
- ImageGenerationError,
10
- makeOpenAIWorkerId,
11
- OpenAIDispatcher,
12
- } from "./openai-dispatcher";
13
- import { type OpenAIQuotaUsageResult } from "./openai-quota";
14
- import {
15
- estimateOpenAIWorkerRssGiB,
16
- MAX_OPENAI_WORKERS_PER_TOKEN,
17
- type OpenAIWorkerPoolConfig,
18
- resolveOpenAIWorkerPoolConfig,
19
- } from "./openai-worker-pool-config";
20
-
21
- const { readOpenAIQuotaUsageMock, loggerInfoMock, loggerWarnMock } = vi.hoisted(() => ({
22
- readOpenAIQuotaUsageMock: vi.fn(),
23
- loggerInfoMock: vi.fn(),
24
- loggerWarnMock: vi.fn(),
25
- }));
26
-
27
- vi.mock("@logtape/logtape", () => ({
28
- getLogger: () => ({ info: loggerInfoMock, warn: loggerWarnMock }),
29
- }));
30
-
31
- vi.mock("./openai-quota", () => ({
32
- readOpenAIQuotaUsage: readOpenAIQuotaUsageMock,
33
- }));
34
-
35
- function credentials(overrides: Partial<OpenAICredentials> = {}): OpenAICredentials {
36
- return {
37
- accessToken: "access",
38
- refreshToken: "refresh",
39
- accessTokenExpiresAt: Date.now() + 60_000,
40
- accountId: "account",
41
- planType: "plus",
42
- ...overrides,
43
- };
5
+ type OpenAINormalizedEvent,
6
+ type OpenAIResponsesOptions,
7
+ } from "./openai-backend-protocol";
8
+ import { ImageGenerationError, OpenAIDispatcher } from "./openai-dispatcher";
9
+ import { type OpenAITransportKind } from "./openai-transport-config";
10
+
11
+ const credentials = {
12
+ accessToken: "access",
13
+ refreshToken: "refresh",
14
+ accessTokenExpiresAt: 1,
15
+ accountId: "acct",
16
+ };
17
+
18
+ function config(): OpenAITransportKind {
19
+ return "https";
44
20
  }
45
21
 
46
- function quotaOk(utilizationPct: number): OpenAIQuotaUsageResult {
22
+ function request(overrides: Partial<GenerateRequest> = {}): GenerateRequest {
47
23
  return {
48
- kind: "ok",
49
- utilizationPct,
50
- cacheAgeMs: 100,
51
- windowDurationMins: 300,
52
- resetsAt: 1_782_912_345,
53
- limitId: "codex-primary",
54
- };
55
- }
56
-
57
- function quotaFail(reason = "rate limit lookup failed"): OpenAIQuotaUsageResult {
58
- return { kind: "lookup_failed", reason };
59
- }
60
-
61
- function deferred<T>(): { promise: Promise<T>; resolve: (value: T) => void } {
62
- let resolve!: (value: T) => void;
63
- const promise = new Promise<T>((done) => {
64
- resolve = done;
65
- });
66
- return { promise, resolve };
67
- }
68
-
69
- function baseReq(overrides: Partial<GenerateRequest> = {}): GenerateRequest {
70
- return {
71
- model: "gpt-5-codex",
72
- systemPrompt: "you are helpful",
73
- coldInput: [{ type: "text", text: "hi", text_elements: [] }],
24
+ model: "gpt-test",
25
+ coldHistory: [{ type: "message", role: "assistant", content: "old" }],
26
+ coldInput: [{ type: "text", text: "new", text_elements: [] }],
74
27
  ...overrides,
75
28
  };
76
29
  }
77
30
 
78
- function resultFor(worker: CodexAppServerWorker, threadId = "thread-new"): GenerateResult {
79
- return {
80
- text: "ok",
81
- tokenName: worker.tokenName,
82
- usage: {
83
- totalTokens: 1,
84
- inputTokens: 1,
85
- cachedInputTokens: 0,
86
- outputTokens: 0,
87
- reasoningOutputTokens: 0,
88
- },
89
- durationMs: 10,
90
- model: "gpt-5-codex",
91
- threadCoord: {
92
- workerId: makeOpenAIWorkerId(worker.tokenId, worker.workerIndex),
93
- threadId,
94
- epoch: worker.epoch,
95
- },
96
- };
31
+ function dispatcher(
32
+ run: (
33
+ options: OpenAIResponsesOptions,
34
+ signal?: AbortSignal,
35
+ ) => AsyncIterable<OpenAINormalizedEvent>,
36
+ ) {
37
+ return new OpenAIDispatcher(config(), { clientFactory: () => ({ responses: run }) });
97
38
  }
98
39
 
99
- function fakeWorker(
100
- reusableOrOptions:
101
- | boolean
102
- | {
103
- tokenId?: number;
104
- tokenName?: string;
105
- workerIndex?: number;
106
- reusable?: boolean;
107
- ready?: boolean;
108
- active?: boolean;
109
- busy?: boolean;
110
- threads?: string[];
111
- epoch?: number;
112
- rateLimits?: unknown;
113
- // 이미지 게이트/생성 mock. imageGateReason 이 있으면 checkImageGenerationSupport 가
114
- // 그 사유를 반환(불가), null 이면 통과. imageTurnResult 로 worker.executeTurn 반환값 지정.
115
- imageGateReason?: string | null;
116
- imageTurnResult?: { images?: Array<{ data: string; revisedPrompt: string | null }>; imageAttempted?: boolean };
117
- },
118
- ): CodexAppServerWorker {
119
- const options =
120
- typeof reusableOrOptions === "boolean" ? { reusable: reusableOrOptions } : reusableOrOptions;
121
- let busy = options.busy ?? false;
122
- const worker = {
123
- tokenId: options.tokenId ?? 1,
124
- tokenName: options.tokenName ?? "token",
125
- workerIndex: options.workerIndex ?? 0,
126
- active: options.active ?? true,
127
- epoch: options.epoch ?? 1,
128
- kill: vi.fn(async () => {}),
129
- canReuseForToken: vi.fn(() => options.reusable ?? true),
130
- updateTokenState: vi.fn(),
131
- get isReady() {
132
- return options.ready ?? true;
133
- },
134
- get hasCapacity() {
135
- return !busy;
136
- },
137
- tryAcquireTurn: vi.fn(() => {
138
- if (busy) return false;
139
- busy = true;
140
- return true;
141
- }),
142
- releaseTurn: vi.fn(() => {
143
- busy = false;
144
- }),
145
- sweepIdleThreads: vi.fn(),
146
- hasThread: vi.fn((threadId: string) => (options.threads ?? []).includes(threadId)),
147
- getRateLimits: vi.fn(
148
- async () => options.rateLimits ?? { rateLimits: {}, rateLimitsByLimitId: null },
149
- ),
150
- checkImageGenerationSupport: vi.fn(async () => options.imageGateReason ?? null),
151
- executeTurn: vi.fn(async () => ({
152
- text: "ok",
153
- usage: { totalTokens: 1, inputTokens: 1, cachedInputTokens: 0, outputTokens: 0, reasoningOutputTokens: 0 },
154
- durationMs: 10,
155
- ttftMs: null,
156
- model: "gpt-5-codex",
157
- threadId: "thread-new",
158
- images: options.imageTurnResult?.images,
159
- imageAttempted: options.imageTurnResult?.imageAttempted,
160
- })),
161
- } as unknown as CodexAppServerWorker;
162
- return worker;
163
- }
164
-
165
- beforeEach(() => {
166
- readOpenAIQuotaUsageMock.mockReset();
167
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(0));
168
- loggerInfoMock.mockReset();
169
- loggerWarnMock.mockReset();
170
- });
171
-
172
- function addWorkers(dispatcher: OpenAIDispatcher, workers: CodexAppServerWorker[]): void {
173
- const byToken = new Map<number, CodexAppServerWorker[]>();
174
- for (const worker of workers) {
175
- const group = byToken.get(worker.tokenId) ?? [];
176
- group.push(worker);
177
- byToken.set(worker.tokenId, group);
178
- }
179
- for (const [tokenId, group] of byToken) dispatcher.workerPool.set(tokenId, group);
180
- }
181
-
182
- function autoscaleConfig(
183
- overrides: Partial<OpenAIWorkerPoolConfig> = {},
184
- ): OpenAIWorkerPoolConfig {
185
- return {
186
- autoscale: true,
187
- minWorkersPerToken: 1,
188
- maxWorkersPerToken: 3,
189
- scaleIntervalMs: 5_000,
190
- scaleDownIdleMs: 600_000,
191
- maxEstimatedRssGiB: 16,
192
- minHostAvailableGiB: 20,
193
- ...overrides,
194
- };
40
+ async function* events(...values: OpenAINormalizedEvent[]) {
41
+ yield* values;
195
42
  }
196
43
 
197
- async function waitForQueue(dispatcher: OpenAIDispatcher, length = 1): Promise<void> {
198
- for (let i = 0; i < 10; i++) {
199
- await new Promise((resolve) => setTimeout(resolve, 0));
200
- if (dispatcher.queueLength === length) return;
201
- }
202
- expect(dispatcher.queueLength).toBe(length);
44
+ async function tickTimer(): Promise<void> {
45
+ await new Promise((resolve) => setTimeout(resolve, 0));
203
46
  }
204
47
 
205
- describe("OpenAIDispatcher worker capacity", () => {
206
- it("supports 20 workers per token without worker id collisions", () => {
207
- expect(MAX_OPENAI_WORKERS_PER_TOKEN).toBe(20);
208
-
209
- const tokenIds = [1, 2, 41, 47, 55, 56, 58];
210
- const workerIds = tokenIds.flatMap((tokenId) =>
211
- Array.from({ length: MAX_OPENAI_WORKERS_PER_TOKEN }, (_, workerIndex) =>
212
- makeOpenAIWorkerId(tokenId, workerIndex),
213
- ),
214
- );
215
-
216
- expect(new Set(workerIds)).toHaveLength(workerIds.length);
217
- expect(makeOpenAIWorkerId(1, 10)).not.toBe(makeOpenAIWorkerId(2, 0));
218
- });
219
-
220
- it("defaults to autoscaling from 1 to 3 workers per token", () => {
221
- // dev0 OOM 사고(SON-516) 응급처치로 기본값을 5-15 에서 1-3 으로 축소 (f6d1333).
222
- expect(resolveOpenAIWorkerPoolConfig({})).toMatchObject({
223
- autoscale: true,
224
- minWorkersPerToken: 1,
225
- maxWorkersPerToken: 3,
226
- });
227
- });
228
-
229
- it("keeps an explicit fixed worker mode for emergency rollback", () => {
230
- expect(
231
- resolveOpenAIWorkerPoolConfig({
232
- QGRID_OPENAI_MIN_WORKERS_PER_TOKEN: "5",
233
- QGRID_OPENAI_AUTOSCALE: "false",
234
- }),
235
- ).toMatchObject({
236
- autoscale: false,
237
- minWorkersPerToken: 5,
238
- maxWorkersPerToken: 5,
239
- });
240
- });
241
-
242
- it("ignores the removed QGRID_WORKERS_PER_TOKEN variable", () => {
243
- // 과거엔 min 의 폴백이었다 — dev0 사고 조사(SON-516)에서 이름과 달리 min 에만
244
- // 꽂히는 함정으로 확인되어 제거. QGRID_OPENAI_MIN_WORKERS_PER_TOKEN 하나로 통일.
245
- expect(
246
- resolveOpenAIWorkerPoolConfig({ QGRID_WORKERS_PER_TOKEN: "15" }),
247
- ).toMatchObject({ minWorkersPerToken: 1, maxWorkersPerToken: 3 });
248
- });
249
-
250
- it("estimates worker RSS from the dev0 measurement model", () => {
251
- expect(estimateOpenAIWorkerRssGiB(50)).toBeCloseTo(8.56, 2);
252
- expect(estimateOpenAIWorkerRssGiB(60)).toBeCloseTo(10.13, 2);
253
- });
254
-
255
- it("clamps memory guard inputs to the 64 GiB host policy", () => {
256
- expect(
257
- resolveOpenAIWorkerPoolConfig({
258
- QGRID_OPENAI_MAX_ESTIMATED_RSS_GIB: "999",
259
- QGRID_OPENAI_MIN_HOST_AVAILABLE_GIB: "999",
260
- }),
261
- ).toMatchObject({
262
- maxEstimatedRssGiB: 32,
263
- minHostAvailableGiB: 64,
264
- });
265
- });
266
- });
267
-
268
- describe("OpenAIDispatcher monit stats", () => {
269
- it("reports worker counts grouped by token name", () => {
270
- const dispatcher = new OpenAIDispatcher(autoscaleConfig({ autoscale: false }), () => 64);
271
- addWorkers(dispatcher, [
272
- fakeWorker({ tokenId: 1, tokenName: "openai/nk" }),
273
- fakeWorker({ tokenId: 1, tokenName: "openai/nk", workerIndex: 1 }),
274
- fakeWorker({ tokenId: 2, tokenName: "openai/haze" }),
275
- ]);
276
-
277
- expect(dispatcher.workerCountsByToken).toEqual([
278
- { name: "openai/haze", count: 1 },
279
- { name: "openai/nk", count: 2 },
280
- ]);
281
- });
282
- });
283
-
284
- describe("OpenAIDispatcher autoscaling", () => {
285
- it("runs minimum-capacity maintenance in fixed worker mode", async () => {
286
- vi.useFakeTimers();
287
- const findMany = vi.spyOn(TokenModel, "findMany").mockResolvedValue({ rows: [] } as never);
288
- const dispatcher = new OpenAIDispatcher(
289
- autoscaleConfig({
290
- autoscale: false,
291
- minWorkersPerToken: 2,
292
- maxWorkersPerToken: 2,
293
- }),
294
- () => 64,
295
- );
296
- const evaluateAutoscaling = vi
297
- .spyOn(dispatcher, "evaluateAutoscaling")
298
- .mockResolvedValue(undefined);
299
-
300
- try {
301
- await dispatcher.start();
302
- await vi.advanceTimersByTimeAsync(5_000);
303
-
304
- expect(evaluateAutoscaling).toHaveBeenCalledTimes(1);
305
- } finally {
306
- await dispatcher.stop();
307
- findMany.mockRestore();
308
- vi.useRealTimers();
309
- }
310
- });
311
-
312
- it("runs idle-thread cleanup from the fixed-mode health timer", async () => {
313
- vi.useFakeTimers();
314
- const findMany = vi.spyOn(TokenModel, "findMany").mockResolvedValue({ rows: [] } as never);
315
- const dispatcher = new OpenAIDispatcher(
316
- autoscaleConfig({
317
- autoscale: false,
318
- minWorkersPerToken: 1,
319
- maxWorkersPerToken: 1,
320
- }),
321
- () => 64,
322
- );
323
- const worker = fakeWorker({ tokenId: 1 });
324
- addWorkers(dispatcher, [worker]);
325
-
326
- try {
327
- await dispatcher.start();
328
- await vi.advanceTimersByTimeAsync(5_000);
329
-
330
- expect(worker.sweepIdleThreads).toHaveBeenCalledTimes(1);
331
- } finally {
332
- await dispatcher.stop();
333
- findMany.mockRestore();
334
- vi.useRealTimers();
335
- }
336
- });
337
-
338
- it("sweeps only ready idle workers so active turns keep their subscription", async () => {
339
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
340
- const idle = fakeWorker({ tokenId: 1, workerIndex: 0 });
341
- const busy = fakeWorker({ tokenId: 1, workerIndex: 1, busy: true });
342
- const restarting = fakeWorker({ tokenId: 1, workerIndex: 2, ready: false });
343
- addWorkers(dispatcher, [idle, busy, restarting]);
344
-
345
- await dispatcher.evaluateAutoscaling();
346
-
347
- expect(idle.sweepIdleThreads).toHaveBeenCalledTimes(1);
348
- expect(busy.sweepIdleThreads).not.toHaveBeenCalled();
349
- expect(restarting.sweepIdleThreads).not.toHaveBeenCalled();
350
- });
351
-
352
- it("repairs an absent token pool after every initial worker spawn failed", async () => {
353
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
354
- const tokenCredentials = credentials();
355
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker").mockResolvedValueOnce(null);
356
-
357
- await dispatcher.spawnWorkers(1, "token", tokenCredentials, null, 1);
358
- expect(dispatcher.workerPool.has(1)).toBe(false);
359
-
360
- const recoveredWorker = fakeWorker({ tokenId: 1, workerIndex: 0 });
361
- spawnSingleWorker.mockResolvedValueOnce(recoveredWorker);
362
- await dispatcher.evaluateAutoscaling();
363
-
364
- expect(dispatcher.workerPool.get(1)).toEqual([recoveredWorker]);
365
- expect(recoveredWorker.kill).not.toHaveBeenCalled();
366
- });
367
-
368
- it("does not race minimum repair against an in-flight token bootstrap", async () => {
369
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
370
- const pendingSpawn = deferred<CodexAppServerWorker | null>();
371
- const spawnSingleWorker = vi
372
- .spyOn(dispatcher, "spawnSingleWorker")
373
- .mockReturnValue(pendingSpawn.promise);
374
-
375
- const bootstrap = dispatcher.spawnWorkers(1, "token", credentials(), null, 1);
376
- await vi.waitFor(() => expect(spawnSingleWorker).toHaveBeenCalledTimes(1));
377
- const evaluation = dispatcher.evaluateAutoscaling();
378
-
379
- expect(spawnSingleWorker).toHaveBeenCalledTimes(1);
380
- const worker = fakeWorker({ tokenId: 1, workerIndex: 0 });
381
- pendingSpawn.resolve(worker);
382
- await Promise.all([bootstrap, evaluation]);
383
-
384
- expect(dispatcher.workerPool.get(1)).toEqual([worker]);
385
- expect(worker.kill).not.toHaveBeenCalled();
386
- });
387
-
388
- it("discards a bootstrapping worker when its token is removed mid-spawn", async () => {
389
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
390
- const pendingSpawn = deferred<CodexAppServerWorker | null>();
391
- const spawnSingleWorker = vi
392
- .spyOn(dispatcher, "spawnSingleWorker")
393
- .mockReturnValue(pendingSpawn.promise);
394
-
395
- const bootstrap = dispatcher.spawnWorkers(1, "token", credentials(), null, 1);
396
- await vi.waitFor(() => expect(spawnSingleWorker).toHaveBeenCalledTimes(1));
397
- await dispatcher.onTokenRemoved(1);
398
- const staleWorker = fakeWorker({ tokenId: 1, workerIndex: 0 });
399
- pendingSpawn.resolve(staleWorker);
400
- await bootstrap;
401
-
402
- expect(dispatcher.workerPool.has(1)).toBe(false);
403
- expect(staleWorker.kill).toHaveBeenCalledTimes(1);
404
- });
405
-
406
- it("repairs the configured minimum even when demand autoscaling is disabled", async () => {
407
- const dispatcher = new OpenAIDispatcher(
408
- autoscaleConfig({
409
- autoscale: false,
410
- minWorkersPerToken: 2,
411
- maxWorkersPerToken: 2,
48
+ describe("OpenAIDispatcher direct runtime", () => {
49
+ it("passes the resolved transport to the injectable client factory", async () => {
50
+ const factory = vi.fn(
51
+ (_options: import("./openai-direct-client").OpenAIDirectClientOptions) => ({
52
+ responses: () => events({ type: "completed", responseId: "r" }),
412
53
  }),
413
- () => 0,
414
54
  );
415
- const tokenCredentials = credentials();
416
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
417
- await dispatcher.onTokenAdded(1, "token", tokenCredentials, null, 1);
418
- const existing = fakeWorker({ tokenId: 1, workerIndex: 0 });
419
- dispatcher.workerPool.set(1, [existing]);
420
- const recovered = fakeWorker({ tokenId: 1, workerIndex: 1 });
421
- const spawnSingleWorker = vi
422
- .spyOn(dispatcher, "spawnSingleWorker")
423
- .mockResolvedValue(recovered);
424
-
425
- await dispatcher.evaluateAutoscaling();
426
-
427
- expect(spawnSingleWorker).toHaveBeenCalledWith(1, "token", tokenCredentials, 1);
428
- expect(dispatcher.workerPool.get(1)).toEqual([existing, recovered]);
429
- });
430
-
431
- it("does not retry a failed minimum spawn as demand expansion in the same evaluation", async () => {
432
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
433
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
434
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
435
- dispatcher.queue.push({} as never);
436
- const spawnSingleWorker = vi
437
- .spyOn(dispatcher, "spawnSingleWorker")
438
- .mockResolvedValue(null);
439
-
440
- await dispatcher.evaluateAutoscaling();
441
-
442
- expect(spawnSingleWorker).toHaveBeenCalledTimes(1);
443
- dispatcher.queue = [];
444
- });
445
-
446
- it("keeps scaling healthy tokens when another token minimum repair fails", async () => {
447
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
448
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
449
- await dispatcher.onTokenAdded(1, "broken", credentials(), null, 1);
450
- await dispatcher.onTokenAdded(2, "healthy", credentials(), null, 1);
451
- dispatcher.workerPool.set(2, [
452
- fakeWorker({ tokenId: 2, tokenName: "healthy", workerIndex: 0, busy: true }),
453
- ]);
454
- dispatcher.queue.push({} as never);
455
- const healthyExpansion = fakeWorker({
456
- tokenId: 2,
457
- tokenName: "healthy",
458
- workerIndex: 1,
55
+ const d = new OpenAIDispatcher("websocket", { clientFactory: factory });
56
+ await d.onTokenAdded(1, "one", credentials);
57
+ await d.generate(request());
58
+ await d.generate(request());
59
+ expect(factory.mock.calls[0]?.[0]).toMatchObject({ transportKind: "websocket" });
60
+ expect(factory).toHaveBeenCalledTimes(1);
61
+ });
62
+
63
+ it("maps complete cold context and Responses controls, then maps usage and affinity", async () => {
64
+ let mapped: OpenAIResponsesOptions | undefined;
65
+ const d = dispatcher((options) => {
66
+ mapped = options;
67
+ return events(
68
+ { type: "text-delta", text: "hello" },
69
+ {
70
+ type: "completed",
71
+ responseId: "r1",
72
+ usage: {
73
+ inputTokens: 8,
74
+ cachedInputTokens: 3,
75
+ outputTokens: 2,
76
+ reasoningTokens: 1,
77
+ totalTokens: 10,
78
+ },
79
+ },
80
+ );
459
81
  });
460
- const spawnSingleWorker = vi
461
- .spyOn(dispatcher, "spawnSingleWorker")
462
- .mockImplementation(async (tokenId) => (tokenId === 1 ? null : healthyExpansion));
463
-
464
- await dispatcher.evaluateAutoscaling();
465
-
466
- expect(spawnSingleWorker).toHaveBeenCalledTimes(2);
467
- expect(dispatcher.workerPool.get(2)).toHaveLength(2);
468
- dispatcher.queue = [];
469
- });
470
-
471
- it("does not duplicate a minimum slot while its worker is transiently restarting", async () => {
472
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
473
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
474
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
475
- dispatcher.workerPool.set(1, [
476
- fakeWorker({ tokenId: 1, workerIndex: 0, ready: false }),
477
- ]);
478
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker");
479
-
480
- await dispatcher.evaluateAutoscaling();
481
-
482
- expect(spawnSingleWorker).not.toHaveBeenCalled();
483
- expect(dispatcher.workerPool.get(1)).toHaveLength(1);
484
- });
485
-
486
- it("queues while active token metadata exists but every worker is unavailable", async () => {
487
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
488
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
489
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
490
- const evaluateAutoscaling = vi
491
- .spyOn(dispatcher, "evaluateAutoscaling")
492
- .mockResolvedValue(undefined);
493
-
494
- const queued = dispatcher.enqueue(async (worker) => worker.tokenName);
495
- await waitForQueue(dispatcher);
496
-
497
- expect(evaluateAutoscaling).toHaveBeenCalled();
498
- const recovered = fakeWorker({ tokenId: 1, workerIndex: 0 });
499
- dispatcher.workerPool.set(1, [recovered]);
500
- await dispatcher.drainQueue();
501
-
502
- await expect(queued).resolves.toBe("token");
503
- });
504
-
505
- it("still rejects immediately when no active OpenAI token metadata exists", async () => {
506
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
507
-
508
- await expect(dispatcher.enqueue(async () => "ok")).rejects.toThrow("NO_OPENAI_WORKERS");
509
- expect(dispatcher.queueLength).toBe(0);
510
- });
511
-
512
- it("keeps a recovery queue when another token is removed but an active token remains", async () => {
513
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
514
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
515
- await dispatcher.onTokenAdded(1, "removed", credentials(), null, 1);
516
- await dispatcher.onTokenAdded(2, "recovering", credentials(), null, 1);
517
-
518
- const queued = dispatcher.enqueue(async () => "ok");
519
- const rejection = expect(queued).rejects.toThrow("TEST_CLEANUP");
520
- await waitForQueue(dispatcher);
521
- await dispatcher.onTokenRemoved(1);
522
-
523
- expect(dispatcher.queueLength).toBe(1);
524
- dispatcher.rejectAllQueued("TEST_CLEANUP");
525
- await rejection;
526
- });
527
-
528
- it("keeps a recovery queue when another token is deactivated but an active token remains", async () => {
529
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
530
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
531
- await dispatcher.onTokenAdded(1, "deactivated", credentials(), null, 1);
532
- await dispatcher.onTokenAdded(2, "recovering", credentials(), null, 1);
533
-
534
- const queued = dispatcher.enqueue(async () => "ok");
535
- const rejection = expect(queued).rejects.toThrow("TEST_CLEANUP");
536
- await waitForQueue(dispatcher);
537
- dispatcher.onTokenDeactivated(1);
538
-
539
- expect(dispatcher.queueLength).toBe(1);
540
- dispatcher.rejectAllQueued("TEST_CLEANUP");
541
- await rejection;
542
- });
543
-
544
- it("drains immediately when capacity appears before a fixed-mode queue wake-up", async () => {
545
- const dispatcher = new OpenAIDispatcher(
546
- autoscaleConfig({
547
- autoscale: false,
548
- minWorkersPerToken: 1,
549
- maxWorkersPerToken: 1,
82
+ await d.onTokenAdded(7, "primary", credentials, null, 1);
83
+
84
+ const result = await d.generate(
85
+ request({
86
+ systemPrompt: "system",
87
+ effort: "high",
88
+ reasoningSummary: "none",
89
+ verbosity: "low",
90
+ serviceTier: "fast",
91
+ promptCacheKey: "cache-key",
92
+ outputSchema: { type: "object", additionalProperties: false },
550
93
  }),
551
- () => 64,
552
94
  );
553
- const worker = fakeWorker({ tokenId: 1, workerIndex: 0 });
554
- addWorkers(dispatcher, [worker]);
555
- await dispatcher.onTokenUpdated(1, "token", credentials(), null, 1);
556
-
557
- await expect(dispatcher.enqueue(async (selected) => selected.tokenName)).resolves.toBe(
558
- "token",
559
- );
560
- expect(dispatcher.queueLength).toBe(0);
561
- });
562
-
563
- it("scales six active tokens from 5 to 15 workers per token", async () => {
564
- const dispatcher = new OpenAIDispatcher(
565
- autoscaleConfig({
566
- minWorkersPerToken: 5,
567
- maxWorkersPerToken: 15,
568
- maxEstimatedRssGiB: 16,
569
- }),
570
- () => 64,
571
- );
572
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
573
-
574
- for (let tokenId = 1; tokenId <= 6; tokenId++) {
575
- await dispatcher.onTokenAdded(tokenId, `token-${tokenId}`, credentials(), null, 1);
576
- dispatcher.workerPool.set(
577
- tokenId,
578
- Array.from({ length: 5 }, (_, workerIndex) => fakeWorker({ tokenId, workerIndex })),
579
- );
580
- }
581
-
582
- vi.spyOn(dispatcher, "spawnSingleWorker").mockImplementation(
583
- async (tokenId, tokenName, _credentials, workerIndex) =>
584
- fakeWorker({ tokenId, tokenName, workerIndex }),
585
- );
586
-
587
- for (let step = 0; step < 12; step++) await dispatcher.scaleUpOneStep();
588
-
589
- expect(dispatcher.workerCount).toBe(90);
590
- expect([...dispatcher.workerPool.values()].map((workers) => workers.length)).toEqual([
591
- 15, 15, 15, 15, 15, 15,
592
- ]);
593
- expect(estimateOpenAIWorkerRssGiB(dispatcher.workerCount)).toBeLessThan(16);
594
- });
595
-
596
- it("requests a scale-up evaluation when a request enters the queue", async () => {
597
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
598
- addWorkers(dispatcher, [fakeWorker({ tokenId: 1, busy: true })]);
599
- const scaleUpOneStep = vi.spyOn(dispatcher, "scaleUpOneStep").mockResolvedValue(undefined);
600
-
601
- const queued = dispatcher.enqueue(async () => "ok");
602
- const rejection = expect(queued).rejects.toThrow("TEST_CLEANUP");
603
- await waitForQueue(dispatcher);
604
- dispatcher.rejectAllQueued("TEST_CLEANUP");
605
-
606
- await rejection;
607
- expect(scaleUpOneStep).toHaveBeenCalledTimes(1);
608
- });
609
-
610
- it("adds one worker to each active token in a scale-up step", async () => {
611
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
612
- const tokenCredentials = credentials();
613
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
614
- await dispatcher.onTokenAdded(1, "token", tokenCredentials, null, 1);
615
- dispatcher.workerPool.set(1, [fakeWorker({ tokenId: 1, workerIndex: 0 })]);
616
- const added = fakeWorker({ tokenId: 1, workerIndex: 1 });
617
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker").mockResolvedValue(added);
618
-
619
- await dispatcher.scaleUpOneStep();
620
95
 
621
- expect(spawnSingleWorker).toHaveBeenCalledWith(1, "token", tokenCredentials, 1);
622
- expect(dispatcher.workerPool.get(1)).toHaveLength(2);
623
- expect(dispatcher.workerCount).toBe(2);
624
- });
625
-
626
- it("does not add workers to a quota-blocked token", async () => {
627
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
628
- const hazeCredentials = credentials({ accountId: "haze" });
629
- const nkCredentials = credentials({ accountId: "nk" });
630
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
631
- await dispatcher.onTokenAdded(1, "openai/haze", hazeCredentials, 80, 1);
632
- await dispatcher.onTokenAdded(2, "openai/nk", nkCredentials, null, 1);
633
- dispatcher.workerPool.set(1, [
634
- fakeWorker({ tokenId: 1, tokenName: "openai/haze", workerIndex: 0 }),
635
- ]);
636
- dispatcher.workerPool.set(2, [
637
- fakeWorker({ tokenId: 2, tokenName: "openai/nk", workerIndex: 0 }),
638
- ]);
639
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(85));
640
-
641
- const selected = await dispatcher.acquireIdleWorker();
642
- expect(selected?.tokenName).toBe("openai/nk");
643
- selected?.releaseTurn();
644
-
645
- const spawnSingleWorker = vi
646
- .spyOn(dispatcher, "spawnSingleWorker")
647
- .mockImplementation(async (tokenId, tokenName, _credentials, workerIndex) =>
648
- fakeWorker({ tokenId, tokenName, workerIndex }),
649
- );
650
- await dispatcher.scaleUpOneStep();
651
-
652
- expect(spawnSingleWorker).toHaveBeenCalledTimes(1);
653
- expect(spawnSingleWorker).toHaveBeenCalledWith(2, "openai/nk", nkCredentials, 1);
654
- expect(dispatcher.workerPool.get(1)).toHaveLength(1);
655
- expect(dispatcher.workerPool.get(2)).toHaveLength(2);
656
- });
657
-
658
- it("maintains the configured minimum for a quota-blocked token", async () => {
659
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
660
- const tokenCredentials = credentials({ accountId: "haze" });
661
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
662
- await dispatcher.onTokenAdded(1, "openai/haze", tokenCredentials, 80, 1);
663
- dispatcher.workerPool.set(1, [
664
- fakeWorker({ tokenId: 1, tokenName: "openai/haze", workerIndex: 0 }),
665
- ]);
666
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(85));
667
-
668
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
669
- QuotaThresholdExceededError,
670
- );
671
- dispatcher.workerPool.delete(1);
672
- const replacement = fakeWorker({
673
- tokenId: 1,
674
- tokenName: "openai/haze",
675
- workerIndex: 0,
96
+ expect(mapped).toMatchObject({
97
+ model: "gpt-test",
98
+ instructions: "system",
99
+ reasoning: { effort: "high" },
100
+ verbosity: "low",
101
+ serviceTier: "priority",
102
+ promptCacheKey: "cache-key",
103
+ outputSchema: { schema: { type: "object", additionalProperties: false } },
676
104
  });
677
- const spawnSingleWorker = vi
678
- .spyOn(dispatcher, "spawnSingleWorker")
679
- .mockResolvedValue(replacement);
680
-
681
- await dispatcher.evaluateAutoscaling();
682
-
683
- expect(spawnSingleWorker).toHaveBeenCalledWith(
684
- 1,
685
- "openai/haze",
686
- tokenCredentials,
687
- 0,
688
- );
689
- expect(dispatcher.workerPool.get(1)).toEqual([replacement]);
690
- });
691
-
692
- it("discards a worker spawned while its token becomes quota-blocked", async () => {
693
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
694
- const tokenCredentials = credentials();
695
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
696
- await dispatcher.onTokenAdded(1, "openai/haze", tokenCredentials, 80, 1);
697
- dispatcher.workerPool.set(1, [
698
- fakeWorker({ tokenId: 1, tokenName: "openai/haze", workerIndex: 0 }),
105
+ expect(mapped?.reasoning).not.toHaveProperty("summary");
106
+ expect(mapped?.history).toEqual([
107
+ { type: "message", role: "assistant", content: "old" },
108
+ { type: "message", role: "user", content: [{ type: "input_text", text: "new" }] },
699
109
  ]);
700
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(85));
701
-
702
- let resolveSpawn!: (worker: CodexAppServerWorker) => void;
703
- const spawnedWorker = fakeWorker({
704
- tokenId: 1,
705
- tokenName: "openai/haze",
706
- workerIndex: 1,
110
+ expect(result).toMatchObject({
111
+ text: "hello",
112
+ tokenName: "primary",
113
+ usage: {
114
+ inputTokens: 8,
115
+ cachedInputTokens: 3,
116
+ outputTokens: 2,
117
+ reasoningOutputTokens: 1,
118
+ totalTokens: 10,
119
+ },
120
+ threadCoord: { workerId: 7, threadId: "cache-key", epoch: -1 },
707
121
  });
708
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker").mockImplementation(
709
- () =>
710
- new Promise<CodexAppServerWorker>((resolve) => {
711
- resolveSpawn = resolve;
712
- }),
713
- );
714
-
715
- const scaling = dispatcher.scaleUpOneStep();
716
- await vi.waitFor(() => expect(spawnSingleWorker).toHaveBeenCalledTimes(1));
717
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
718
- QuotaThresholdExceededError,
719
- );
720
- resolveSpawn(spawnedWorker);
721
- await scaling;
722
-
723
- expect(spawnedWorker.kill).toHaveBeenCalledTimes(1);
724
- expect(dispatcher.workerPool.get(1)).toHaveLength(1);
725
122
  });
726
123
 
727
- it("does not scale past the estimated RSS guard", async () => {
728
- const dispatcher = new OpenAIDispatcher(
729
- autoscaleConfig({ maxEstimatedRssGiB: 0.9 }),
730
- () => 64,
124
+ it("streams deltas and reports completion", async () => {
125
+ const d = dispatcher(() =>
126
+ events(
127
+ { type: "text-delta", text: "a" },
128
+ { type: "text-delta", text: "b" },
129
+ { type: "completed", responseId: "r" },
130
+ ),
731
131
  );
732
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
733
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
734
- dispatcher.workerPool.set(1, [fakeWorker({ tokenId: 1, workerIndex: 0 })]);
735
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker");
736
-
737
- await dispatcher.scaleUpOneStep();
738
-
739
- expect(spawnSingleWorker).not.toHaveBeenCalled();
740
- expect(dispatcher.workerCount).toBe(1);
741
- });
742
-
743
- it("does not scale when host available memory is below the floor", async () => {
744
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 10);
745
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
746
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
747
- dispatcher.workerPool.set(1, [fakeWorker({ tokenId: 1, workerIndex: 0 })]);
748
- const spawnSingleWorker = vi.spyOn(dispatcher, "spawnSingleWorker");
749
-
750
- await dispatcher.scaleUpOneStep();
751
-
752
- expect(spawnSingleWorker).not.toHaveBeenCalled();
753
- expect(dispatcher.workerCount).toBe(1);
754
- });
755
-
756
- it("removes only idle workers above the configured minimum for inactive tokens", async () => {
757
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
758
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
759
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
760
- const busy = fakeWorker({ tokenId: 1, workerIndex: 0, busy: true });
761
- const idle = fakeWorker({ tokenId: 1, workerIndex: 1 });
762
- dispatcher.workerPool.set(1, [busy, idle]);
763
- dispatcher.onTokenDeactivated(1);
764
-
765
- await dispatcher.scaleDownOneStep();
766
- await dispatcher.scaleDownOneStep();
767
-
768
- expect(idle.kill).toHaveBeenCalledTimes(1);
769
- expect(busy.kill).not.toHaveBeenCalled();
770
- expect(dispatcher.workerPool.get(1)).toEqual([busy]);
771
- });
772
-
773
- it.each([1, 2, 5])(
774
- "converges repeated idle evaluations to configured minimum %i and never below it",
775
- async (minimum) => {
776
- vi.useFakeTimers();
777
- try {
778
- vi.setSystemTime(1_000);
779
- const initialCount = minimum + 3;
780
- const dispatcher = new OpenAIDispatcher(
781
- autoscaleConfig({
782
- minWorkersPerToken: minimum,
783
- maxWorkersPerToken: initialCount,
784
- scaleDownIdleMs: 1_000,
785
- }),
786
- () => 64,
787
- );
788
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
789
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
790
- const workers = Array.from({ length: initialCount }, (_, workerIndex) =>
791
- fakeWorker({ tokenId: 1, workerIndex }),
792
- );
793
- dispatcher.workerPool.set(1, workers);
794
- vi.setSystemTime(2_001);
795
-
796
- await dispatcher.evaluateAutoscaling();
797
- expect(dispatcher.workerPool.get(1)).toHaveLength(initialCount - 1);
798
- await dispatcher.evaluateAutoscaling();
799
- expect(dispatcher.workerPool.get(1)).toHaveLength(initialCount - 2);
800
- await dispatcher.evaluateAutoscaling();
801
- expect(dispatcher.workerPool.get(1)).toHaveLength(minimum);
802
- await dispatcher.evaluateAutoscaling();
803
- expect(dispatcher.workerPool.get(1)).toHaveLength(minimum);
804
-
805
- for (let workerIndex = minimum; workerIndex < initialCount; workerIndex++) {
806
- expect(workers[workerIndex]?.kill).toHaveBeenCalledTimes(1);
807
- }
808
- for (let workerIndex = 0; workerIndex < minimum; workerIndex++) {
809
- expect(workers[workerIndex]?.kill).not.toHaveBeenCalled();
810
- }
811
- } finally {
812
- vi.useRealTimers();
813
- }
814
- },
815
- );
816
-
817
- it("still scales healthy idle pools down when another token cannot recover its minimum", async () => {
818
- vi.useFakeTimers();
819
- try {
820
- vi.setSystemTime(1_000);
821
- const dispatcher = new OpenAIDispatcher(
822
- autoscaleConfig({ scaleDownIdleMs: 1_000 }),
823
- () => 64,
824
- );
825
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
826
- await dispatcher.onTokenAdded(1, "broken", credentials(), null, 1);
827
- await dispatcher.onTokenAdded(2, "healthy", credentials(), null, 1);
828
- const healthyWorkers = [
829
- fakeWorker({ tokenId: 2, tokenName: "healthy", workerIndex: 0 }),
830
- fakeWorker({ tokenId: 2, tokenName: "healthy", workerIndex: 1 }),
831
- ];
832
- dispatcher.workerPool.set(2, healthyWorkers);
833
- vi.spyOn(dispatcher, "spawnSingleWorker").mockResolvedValue(null);
834
- vi.setSystemTime(2_001);
835
-
836
- await dispatcher.evaluateAutoscaling();
837
-
838
- expect(dispatcher.workerPool.get(2)).toEqual([healthyWorkers[0]]);
839
- expect(healthyWorkers[1]?.kill).toHaveBeenCalledTimes(1);
840
- } finally {
841
- vi.useRealTimers();
842
- }
843
- });
844
-
845
- it("removes a terminal worker by identity and requests minimum repair", async () => {
846
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
847
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
848
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
849
- const terminal = fakeWorker({ tokenId: 1, workerIndex: 0, ready: false });
850
- dispatcher.workerPool.set(1, [terminal]);
851
- const evaluateAutoscaling = vi
852
- .spyOn(dispatcher, "evaluateAutoscaling")
853
- .mockResolvedValue(undefined);
854
-
855
- await dispatcher.handleWorkerTerminalFailure(terminal);
856
-
857
- expect(dispatcher.workerPool.has(1)).toBe(false);
858
- expect(terminal.kill).toHaveBeenCalledTimes(1);
859
- expect(evaluateAutoscaling).toHaveBeenCalledTimes(1);
132
+ await d.onTokenAdded(1, "one", credentials);
133
+ const deltas: string[] = [];
134
+ const complete = vi.fn();
135
+ await d.generateStream(request(), {
136
+ onDelta: (v) => deltas.push(v),
137
+ onComplete: complete,
138
+ onError: vi.fn(),
139
+ });
140
+ expect(deltas).toEqual(["a", "b"]);
141
+ expect(complete).toHaveBeenCalledWith(expect.objectContaining({ text: "ab" }));
860
142
  });
861
143
 
862
- it("returns to the configured minimum after scale-down and terminal failure overlap", async () => {
863
- const dispatcher = new OpenAIDispatcher(
864
- autoscaleConfig({
865
- minWorkersPerToken: 2,
866
- maxWorkersPerToken: 3,
867
- scaleDownIdleMs: 0,
868
- }),
869
- () => 64,
870
- );
871
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
872
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
873
- const terminal = fakeWorker({ tokenId: 1, workerIndex: 0, ready: false });
874
- const survivor = fakeWorker({ tokenId: 1, workerIndex: 1 });
875
- const excess = fakeWorker({ tokenId: 1, workerIndex: 2 });
876
- dispatcher.workerPool.set(1, [terminal, survivor, excess]);
877
-
878
- await dispatcher.scaleDownOneStep();
879
- expect(dispatcher.workerPool.get(1)).toEqual([terminal, survivor]);
880
-
881
- const replacement = fakeWorker({ tokenId: 1, workerIndex: 0 });
882
- vi.spyOn(dispatcher, "spawnSingleWorker").mockResolvedValue(replacement);
883
- await dispatcher.handleWorkerTerminalFailure(terminal);
884
- await vi.waitFor(() =>
885
- expect(dispatcher.workerPool.get(1)).toEqual([replacement, survivor]),
144
+ it("maps images and preserves image failure classifications", async () => {
145
+ const success = dispatcher(() =>
146
+ events(
147
+ { type: "image", id: "i", base64: "png", mimeType: "image/png" },
148
+ { type: "completed", responseId: "r" },
149
+ ),
886
150
  );
887
-
888
- expect(excess.kill).toHaveBeenCalledTimes(1);
889
- expect(terminal.kill).toHaveBeenCalledTimes(1);
890
- expect(dispatcher.workerPool.get(1)).toHaveLength(2);
891
- });
892
-
893
- it("ignores a stale terminal callback after the token pool was replaced", async () => {
894
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
895
- vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
896
- await dispatcher.onTokenAdded(1, "token", credentials(), null, 1);
897
- const stale = fakeWorker({ tokenId: 1, workerIndex: 0, ready: false });
898
- const current = fakeWorker({ tokenId: 1, workerIndex: 0 });
899
- dispatcher.workerPool.set(1, [current]);
900
- const evaluateAutoscaling = vi.spyOn(dispatcher, "evaluateAutoscaling");
901
-
902
- await dispatcher.handleWorkerTerminalFailure(stale);
903
-
904
- expect(dispatcher.workerPool.get(1)).toEqual([current]);
905
- expect(current.kill).not.toHaveBeenCalled();
906
- expect(evaluateAutoscaling).not.toHaveBeenCalled();
907
- });
908
-
909
- it("wires a spawned worker terminal signal to dispatcher cleanup", async () => {
910
- const initialize = vi
911
- .spyOn(CodexAppServerWorker.prototype, "initialize")
912
- .mockResolvedValue(undefined);
913
- const kill = vi.spyOn(CodexAppServerWorker.prototype, "kill").mockResolvedValue(undefined);
914
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
915
-
916
- try {
917
- await dispatcher.spawnWorkers(1, "token", credentials(), null, 1);
918
- const worker = dispatcher.workerPool.get(1)?.[0];
919
- expect(worker).toBeDefined();
920
- const evaluateAutoscaling = vi
921
- .spyOn(dispatcher, "evaluateAutoscaling")
922
- .mockResolvedValue(undefined);
923
-
924
- worker?.onTerminalFailure?.();
925
- await vi.waitFor(() => expect(evaluateAutoscaling).toHaveBeenCalledTimes(1));
926
-
927
- expect(kill).toHaveBeenCalledTimes(1);
928
- expect(dispatcher.workerPool.has(1)).toBe(false);
929
- } finally {
930
- initialize.mockRestore();
931
- kill.mockRestore();
932
- }
933
- });
934
- });
935
-
936
- describe("OpenAIDispatcher token updates", () => {
937
- it("keeps existing workers when only OpenAI auth tokens rotate", async () => {
938
- const dispatcher = new OpenAIDispatcher();
939
- const worker = fakeWorker(true);
940
- const spawnWorkers = vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
941
- dispatcher.workerPool.set(1, [worker]);
942
-
943
- const rotated = credentials({
944
- accessToken: "new-access",
945
- refreshToken: "new-refresh",
946
- idToken: "new-id",
947
- accessTokenExpiresAt: Date.now() + 120_000,
151
+ await success.onTokenAdded(1, "one", credentials);
152
+ await expect(success.generate(request({ imageGeneration: true }))).resolves.toMatchObject({
153
+ images: [{ data: "png" }],
948
154
  });
949
- await dispatcher.onTokenUpdated(1, "renamed-token", rotated, 80);
950
-
951
- expect(worker.kill).not.toHaveBeenCalled();
952
- expect(worker.updateTokenState).toHaveBeenCalledWith("renamed-token", rotated);
953
- expect(spawnWorkers).not.toHaveBeenCalled();
954
- expect(dispatcher.workerPool.get(1)).toEqual([worker]);
955
- });
956
-
957
- it("restarts workers when the OpenAI login identity changes", async () => {
958
- const dispatcher = new OpenAIDispatcher();
959
- const worker = fakeWorker(false);
960
- const spawnWorkers = vi.spyOn(dispatcher, "spawnWorkers").mockResolvedValue(undefined);
961
- dispatcher.workerPool.set(1, [worker]);
962
155
 
963
- const changedIdentity = credentials({ accountId: "other-account" });
964
- await dispatcher.onTokenUpdated(1, "token", changedIdentity, null);
965
-
966
- expect(worker.kill).toHaveBeenCalledTimes(1);
967
- expect(spawnWorkers).toHaveBeenCalledWith(1, "token", changedIdentity, null, 1);
968
- });
969
-
970
- it("uses tokenId keyed rate-limit cache", async () => {
971
- const dispatcher = new OpenAIDispatcher();
972
- const rateLimitsA = { rateLimits: { primary: { usedPercent: 10 } }, rateLimitsByLimitId: null };
973
- const rateLimitsB = { rateLimits: { primary: { usedPercent: 20 } }, rateLimitsByLimitId: null };
974
- const workerA = fakeWorker({ tokenId: 1, tokenName: "same-name", rateLimits: rateLimitsA });
975
- const workerB = fakeWorker({ tokenId: 2, tokenName: "same-name", rateLimits: rateLimitsB });
976
- addWorkers(dispatcher, [workerA, workerB]);
977
-
978
- await expect(dispatcher.getRateLimitsByTokenId(1)).resolves.toMatchObject({
979
- data: rateLimitsA,
156
+ const notCalled = dispatcher(() => events({ type: "completed", responseId: "r" }));
157
+ await notCalled.onTokenAdded(1, "one", credentials);
158
+ await expect(notCalled.generate(request({ imageGeneration: true }))).rejects.toMatchObject({
159
+ kind: "not_called",
980
160
  });
981
- await expect(dispatcher.getRateLimitsByTokenId(1)).resolves.toMatchObject({
982
- data: rateLimitsA,
983
- });
984
- await expect(dispatcher.getRateLimitsByTokenId(2)).resolves.toMatchObject({
985
- data: rateLimitsB,
986
- });
987
-
988
- expect(workerA.getRateLimits).toHaveBeenCalledTimes(1);
989
- expect(workerB.getRateLimits).toHaveBeenCalledTimes(1);
161
+ await expect(
162
+ notCalled.generateStream(request({ imageGeneration: true }), {
163
+ onDelta: vi.fn(),
164
+ onComplete: vi.fn(),
165
+ onError: vi.fn(),
166
+ }),
167
+ ).rejects.toEqual(expect.any(ImageGenerationError));
990
168
  });
991
169
 
992
- it("keeps fresh rate-limit cache across routing-only token updates", async () => {
993
- const dispatcher = new OpenAIDispatcher();
994
- const rateLimits = {
995
- rateLimits: { primary: { usedPercent: 85 } },
996
- rateLimitsByLimitId: null,
997
- };
998
- const worker = fakeWorker({
999
- tokenId: 1,
1000
- tokenName: "openai/haze",
1001
- rateLimits,
170
+ it("uses weighted routing, while preferred affinity does not advance weighted state", async () => {
171
+ const names: string[] = [];
172
+ const d = dispatcher(() => events({ type: "completed", responseId: "r" }));
173
+ await d.onTokenAdded(1, "one", credentials, null, 1);
174
+ await d.onTokenAdded(2, "two", { ...credentials, accountId: "acct2" }, null, 2);
175
+ for (let i = 0; i < 6; i++) names.push((await d.generate(request())).tokenName);
176
+ expect(names.filter((n) => n === "two")).toHaveLength(4);
177
+ expect((await d.generate(request({ preferredTokenId: 1 }))).tokenName).toBe("one");
178
+ expect((await d.generate(request())).tokenName).toBe("two");
179
+ });
180
+
181
+ it("runs concurrent requests without queueing and tracks in-flight counts", async () => {
182
+ const releases: Array<() => void> = [];
183
+ const d = dispatcher(() => ({
184
+ async *[Symbol.asyncIterator]() {
185
+ await new Promise<void>((resolve) => releases.push(resolve));
186
+ yield { type: "completed", responseId: "r" } as const;
187
+ },
188
+ }));
189
+ await d.onTokenAdded(1, "one", credentials);
190
+
191
+ // 동시성 상한이 없다: 토큰 하나에 세 요청이 즉시 모두 시작된다.
192
+ const first = d.generate(request());
193
+ const second = d.generate(request());
194
+ const third = d.generate(request());
195
+ await vi.waitFor(() => expect(releases).toHaveLength(3));
196
+ expect(d.inFlight).toBe(3);
197
+
198
+ for (const release of releases.splice(0)) release();
199
+ await Promise.all([first, second, third]);
200
+ expect(d.inFlight).toBe(0);
201
+ });
202
+
203
+ it("aborts active transport work through the caller signal", async () => {
204
+ const d = dispatcher((_options, signal) => ({
205
+ async *[Symbol.asyncIterator]() {
206
+ await new Promise<void>((_resolve, reject) => {
207
+ signal?.addEventListener(
208
+ "abort",
209
+ () => reject(new DOMException("Aborted", "AbortError")),
210
+ { once: true },
211
+ );
212
+ });
213
+ yield { type: "completed", responseId: "r" } as const;
214
+ },
215
+ }));
216
+ await d.onTokenAdded(1, "one", credentials);
217
+ const controller = new AbortController();
218
+ const pending = d.generate(request({ abortSignal: controller.signal }));
219
+ await tickTimer();
220
+ controller.abort();
221
+ await expect(pending).rejects.toMatchObject({ name: "AbortError" });
222
+ expect(d.inFlight).toBe(0);
223
+ });
224
+
225
+ it("rechecks abort after delayed quota selection and does not start the request", async () => {
226
+ let releaseQuota!: () => void;
227
+ const started = vi.fn(() => events({ type: "completed", responseId: "r" }));
228
+ const d = new OpenAIDispatcher(config(), {
229
+ clientFactory: () => ({ responses: started }),
230
+ fetch: async () => {
231
+ await new Promise<void>((resolve) => (releaseQuota = resolve));
232
+ return new Response(
233
+ JSON.stringify({
234
+ rate_limits: { primary_window: { used_percent: 1 } },
235
+ }),
236
+ { status: 200 },
237
+ );
238
+ },
1002
239
  });
1003
- addWorkers(dispatcher, [worker]);
1004
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80, 1);
1005
-
1006
- await dispatcher.getRateLimitsByTokenId(1);
1007
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80, 2);
1008
- await expect(dispatcher.getRateLimitsByTokenId(1)).resolves.toMatchObject({
1009
- data: rateLimits,
240
+ await d.onTokenAdded(1, "one", credentials, 80);
241
+ const controller = new AbortController();
242
+ const pending = d.generate(request({ abortSignal: controller.signal }));
243
+ await vi.waitFor(() => expect(releaseQuota).toBeTypeOf("function"));
244
+ controller.abort();
245
+ releaseQuota();
246
+ await expect(pending).rejects.toMatchObject({ name: "AbortError" });
247
+ expect(started).not.toHaveBeenCalled();
248
+ await expect(d.generate(request())).resolves.toMatchObject({ tokenName: "one" });
249
+ });
250
+
251
+ it("enforces timeout during an active response stream", async () => {
252
+ let calls = 0;
253
+ const d = dispatcher((_options, signal) => ({
254
+ async *[Symbol.asyncIterator]() {
255
+ calls++;
256
+ if (calls === 1) {
257
+ await new Promise<void>((_resolve, reject) =>
258
+ signal?.addEventListener("abort", () => reject(signal.reason), { once: true }),
259
+ );
260
+ }
261
+ yield { type: "completed", responseId: "r" } as const;
262
+ },
263
+ }));
264
+ await d.onTokenAdded(1, "one", credentials);
265
+ await expect(d.generate(request({ timeoutMs: 5 }))).rejects.toMatchObject({
266
+ name: "TimeoutError",
1010
267
  });
1011
-
1012
- expect(worker.getRateLimits).toHaveBeenCalledTimes(1);
268
+ await expect(d.generate(request())).resolves.toMatchObject({ tokenName: "one" });
1013
269
  });
1014
270
 
1015
- it("does not cache a response from an outdated provider identity", async () => {
1016
- const dispatcher = new OpenAIDispatcher();
1017
- const oldRateLimits = {
1018
- rateLimits: { primary: { usedPercent: 85 } },
1019
- rateLimitsByLimitId: null,
1020
- };
1021
- const currentRateLimits = {
1022
- rateLimits: { primary: { usedPercent: 10 } },
1023
- rateLimitsByLimitId: null,
1024
- };
1025
- const oldWorker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1026
- const currentWorker = fakeWorker({
1027
- tokenId: 1,
1028
- tokenName: "openai/haze",
1029
- rateLimits: currentRateLimits,
1030
- });
1031
- addWorkers(dispatcher, [oldWorker]);
1032
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1033
- const pendingRateLimits = deferred<unknown>();
1034
- vi.mocked(oldWorker.getRateLimits).mockImplementationOnce(() => pendingRateLimits.promise);
1035
- vi.mocked(oldWorker.canReuseForToken).mockReturnValue(false);
1036
- vi.spyOn(dispatcher, "spawnWorkers").mockImplementation(async () => {
1037
- dispatcher.workerPool.set(1, [currentWorker]);
271
+ it("applies credential metadata updates while requests are active", async () => {
272
+ let release!: () => void;
273
+ let call = 0;
274
+ const d = dispatcher(() => ({
275
+ async *[Symbol.asyncIterator]() {
276
+ call++;
277
+ if (call === 1) await new Promise<void>((resolve) => (release = resolve));
278
+ yield { type: "completed", responseId: "r" } as const;
279
+ },
280
+ }));
281
+ await d.onTokenAdded(1, "old", credentials);
282
+ const active = d.generate(request());
283
+ await vi.waitFor(() => expect(call).toBe(1));
284
+ await d.onTokenUpdated(1, "new", { ...credentials, accessToken: "replacement" });
285
+ release();
286
+ await active;
287
+ await expect(d.generate(request())).resolves.toMatchObject({ tokenName: "new" });
288
+ });
289
+
290
+ it("retires a replaced client only after its in-flight requests finish", async () => {
291
+ let release!: () => void;
292
+ let call = 0;
293
+ const close = vi.fn();
294
+ const d = new OpenAIDispatcher(config(), {
295
+ clientFactory: () => ({
296
+ responses: () => ({
297
+ async *[Symbol.asyncIterator]() {
298
+ call++;
299
+ if (call === 1) await new Promise<void>((resolve) => (release = resolve));
300
+ yield { type: "completed", responseId: "r" } as const;
301
+ },
302
+ }),
303
+ close,
304
+ }),
1038
305
  });
1039
-
1040
- const outdatedRead = dispatcher.getRateLimitsByTokenId(1);
1041
- await vi.waitFor(() => expect(oldWorker.getRateLimits).toHaveBeenCalledTimes(1));
1042
- await dispatcher.onTokenUpdated(
1043
- 1,
1044
- "openai/haze",
1045
- credentials({ accountId: "new-account" }),
1046
- 80,
1047
- );
1048
- pendingRateLimits.resolve(oldRateLimits);
1049
-
1050
- await expect(outdatedRead).resolves.toMatchObject({ data: oldRateLimits });
1051
- await expect(dispatcher.getRateLimitsByTokenId(1)).resolves.toMatchObject({
1052
- data: currentRateLimits,
306
+ await d.onTokenAdded(1, "old", credentials);
307
+ const active = d.generate(request());
308
+ await vi.waitFor(() => expect(call).toBe(1));
309
+
310
+ await d.onTokenUpdated(1, "new", { ...credentials, accessToken: "replacement" });
311
+ // 세대 교체는 새 요청이 새 client 를 만들 뿐, 진행 중인 client 를 끊지 않는다.
312
+ await expect(d.generate(request())).resolves.toMatchObject({ tokenName: "new" });
313
+ expect(close).not.toHaveBeenCalled();
314
+
315
+ release();
316
+ await expect(active).resolves.toMatchObject({ tokenName: "new" });
317
+ expect(close).toHaveBeenCalledTimes(1);
318
+ });
319
+
320
+ it("cancels a hung quota lookup when the caller aborts", async () => {
321
+ const started = vi.fn(() => events({ type: "completed", responseId: "r" }));
322
+ const d = new OpenAIDispatcher(config(), {
323
+ clientFactory: () => ({ responses: started }),
324
+ fetch: async (_input, init) =>
325
+ new Promise<Response>((_resolve, reject) => {
326
+ const signal = (init as RequestInit | undefined)?.signal;
327
+ if (!signal) return;
328
+ signal.addEventListener("abort", () => reject(signal.reason), { once: true });
329
+ }),
1053
330
  });
1054
- expect(currentWorker.getRateLimits).toHaveBeenCalledTimes(1);
1055
- });
1056
-
1057
- it("replaceTokens removes absent OpenAI workers and updates threshold metadata", async () => {
1058
- const dispatcher = new OpenAIDispatcher();
1059
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A" });
1060
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B" });
1061
- addWorkers(dispatcher, [workerA, workerB]);
1062
-
1063
- await dispatcher.replaceTokens([
1064
- { id: 1, name: "tok-A", credentials: credentials(), quotaThreshold: 80, weight: 1 },
1065
- ]);
1066
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(85));
1067
-
1068
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1069
- QuotaThresholdExceededError,
1070
- );
1071
- expect(workerB.kill).toHaveBeenCalledTimes(1);
331
+ await d.onTokenAdded(1, "one", credentials, 80);
332
+ const controller = new AbortController();
333
+ const pending = d.generate(request({ abortSignal: controller.signal }));
334
+ await tickTimer();
335
+ controller.abort();
336
+ await expect(pending).rejects.toMatchObject({ name: "AbortError" });
337
+ expect(started).not.toHaveBeenCalled();
1072
338
  });
1073
- });
1074
-
1075
- describe("OpenAIDispatcher weighted routing", () => {
1076
- it("routes cold OpenAI requests by token weight instead of worker count", async () => {
1077
- const dispatcher = new OpenAIDispatcher();
1078
- const a0 = fakeWorker({ tokenId: 1, tokenName: "tok-A", workerIndex: 0 });
1079
- const a1 = fakeWorker({ tokenId: 1, tokenName: "tok-A", workerIndex: 1 });
1080
- const b0 = fakeWorker({ tokenId: 2, tokenName: "tok-B", workerIndex: 0 });
1081
- addWorkers(dispatcher, [a0, a1, b0]);
1082
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 3);
1083
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null, 1);
1084
339
 
340
+ it("routes past an over-threshold token instead of treating it as capacity", async () => {
1085
341
  const names: string[] = [];
1086
- for (let i = 0; i < 4; i++) {
1087
- const worker = await dispatcher.acquireIdleWorker();
1088
- names.push(worker!.tokenName);
1089
- worker!.releaseTurn();
1090
- }
1091
-
1092
- expect(names.filter((name) => name === "tok-A")).toHaveLength(3);
1093
- expect(names.filter((name) => name === "tok-B")).toHaveLength(1);
1094
- });
1095
-
1096
- it("does not give a token extra cold turns for having more workers", async () => {
1097
- const dispatcher = new OpenAIDispatcher();
1098
- addWorkers(dispatcher, [
1099
- fakeWorker({ tokenId: 1, tokenName: "tok-A", workerIndex: 0 }),
1100
- fakeWorker({ tokenId: 1, tokenName: "tok-A", workerIndex: 1 }),
1101
- fakeWorker({ tokenId: 2, tokenName: "tok-B", workerIndex: 0 }),
1102
- ]);
1103
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 1);
1104
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null, 1);
1105
-
1106
- const names: string[] = [];
1107
- for (let i = 0; i < 4; i++) {
1108
- const worker = await dispatcher.acquireIdleWorker();
1109
- names.push(worker!.tokenName);
1110
- worker!.releaseTurn();
1111
- }
1112
-
1113
- expect(names).toEqual(["tok-A", "tok-B", "tok-A", "tok-B"]);
1114
- });
1115
-
1116
- it("skips a high-weight token when all of its workers are busy", async () => {
1117
- const dispatcher = new OpenAIDispatcher();
1118
- addWorkers(dispatcher, [
1119
- fakeWorker({ tokenId: 1, tokenName: "tok-A", busy: true }),
1120
- fakeWorker({ tokenId: 2, tokenName: "tok-B" }),
1121
- ]);
1122
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 100);
1123
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null, 1);
1124
-
1125
- await expect(dispatcher.acquireIdleWorker()).resolves.toMatchObject({ tokenName: "tok-B" });
1126
- });
1127
-
1128
- it("uses weighted selection when draining after a worker release", async () => {
1129
- const dispatcher = new OpenAIDispatcher();
1130
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A", busy: true });
1131
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B", busy: true });
1132
- addWorkers(dispatcher, [workerA, workerB]);
1133
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 1);
1134
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null, 3);
1135
-
1136
- const queued = dispatcher.enqueue(async (worker) => worker.tokenName);
1137
- await waitForQueue(dispatcher);
1138
- workerA.releaseTurn();
1139
- workerB.releaseTurn();
1140
-
1141
- await dispatcher.drainQueue();
1142
- await expect(queued).resolves.toBe("tok-B");
1143
- });
1144
-
1145
- it("does not advance weighted state for successful thread reuse", async () => {
1146
- const dispatcher = new OpenAIDispatcher();
1147
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A" });
1148
- const workerB = fakeWorker({
1149
- tokenId: 2,
1150
- tokenName: "tok-B",
1151
- threads: ["thread-B"],
1152
- });
1153
- addWorkers(dispatcher, [workerA, workerB]);
1154
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 1);
1155
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null, 1);
1156
- vi.spyOn(dispatcher, "executeTurn").mockImplementation(
1157
- async (worker, _req, reuseThreadId) =>
1158
- resultFor(worker, reuseThreadId ?? "thread-new"),
1159
- );
1160
-
1161
- const cold1 = await dispatcher.generate(baseReq());
1162
- const reused = await dispatcher.generate(
1163
- baseReq({
1164
- reuse: { workerId: makeOpenAIWorkerId(2, 0), threadId: "thread-B", epoch: 1 },
1165
- }),
1166
- );
1167
- const cold2 = await dispatcher.generate(baseReq());
1168
-
1169
- expect([cold1.tokenName, cold2.tokenName]).toEqual(["tok-A", "tok-B"]);
1170
- expect(reused).toMatchObject({
1171
- tokenName: "tok-B",
1172
- threadCoord: { threadId: "thread-B" },
342
+ const d = new OpenAIDispatcher(config(), {
343
+ clientFactory: () => ({ responses: () => events({ type: "completed", responseId: "r" }) }),
344
+ fetch: async () =>
345
+ new Response(
346
+ JSON.stringify({ rate_limits: { primary_window: { used_percent: 90 } } }),
347
+ { status: 200, headers: { "content-type": "application/json" } },
348
+ ),
1173
349
  });
350
+ // one: threshold 없음(항상 eligible), two: threshold 초과 → 항상 one 으로 라우팅된다.
351
+ await d.onTokenAdded(1, "one", credentials, null);
352
+ await d.onTokenAdded(2, "two", { ...credentials, accountId: "acct2" }, 80);
353
+ for (let i = 0; i < 4; i++) names.push((await d.generate(request())).tokenName);
354
+ expect(names).toEqual(["one", "one", "one", "one"]);
1174
355
  });
1175
- });
1176
-
1177
- describe("OpenAIDispatcher quota threshold gate", () => {
1178
- it("excludes over-threshold tokenIds before idle selection", async () => {
1179
- const dispatcher = new OpenAIDispatcher();
1180
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A" });
1181
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B" });
1182
- addWorkers(dispatcher, [workerA, workerB]);
1183
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1184
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), 80);
1185
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(85)).mockResolvedValueOnce(quotaOk(10));
1186
-
1187
- const worker = await dispatcher.acquireIdleWorker();
1188
-
1189
- expect(worker?.tokenName).toBe("tok-B");
1190
- expect(workerA.tryAcquireTurn).not.toHaveBeenCalled();
1191
- expect(loggerInfoMock).toHaveBeenCalledWith(
1192
- expect.stringContaining("over_threshold"),
1193
- expect.objectContaining({
1194
- tokenId: 1,
1195
- tokenName: "tok-A",
1196
- provider: "openai",
1197
- threshold: 80,
1198
- cachedUtilization: 85,
1199
- windowDurationMins: 300,
1200
- resetsAt: 1_782_912_345,
1201
- limitId: "codex-primary",
1202
- reason: "over_threshold",
1203
- }),
1204
- );
1205
- });
1206
-
1207
- it("logs over-threshold and recovery only when the token gate state changes", async () => {
1208
- const dispatcher = new OpenAIDispatcher();
1209
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1210
- addWorkers(dispatcher, [worker]);
1211
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1212
- readOpenAIQuotaUsageMock
1213
- .mockResolvedValueOnce(quotaOk(85))
1214
- .mockResolvedValueOnce(quotaOk(85))
1215
- .mockResolvedValueOnce(quotaOk(10))
1216
- .mockResolvedValueOnce(quotaOk(10));
1217
-
1218
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1219
- QuotaThresholdExceededError,
1220
- );
1221
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1222
- QuotaThresholdExceededError,
1223
- );
1224
- const recoveredWorker = await dispatcher.acquireIdleWorker();
1225
- recoveredWorker?.releaseTurn();
1226
- const stillEligibleWorker = await dispatcher.acquireIdleWorker();
1227
- stillEligibleWorker?.releaseTurn();
1228
-
1229
- const overThresholdLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1230
- String(message).includes("quota_threshold gate: over_threshold"),
1231
- );
1232
- const recoveredLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1233
- String(message).includes("quota_threshold gate: recovered"),
1234
- );
1235
- expect(overThresholdLogs).toHaveLength(1);
1236
- expect(overThresholdLogs[0]).toEqual([
1237
- "quota_threshold gate: over_threshold openai/haze[1] (85% >= 80%)",
1238
- expect.objectContaining({
1239
- tokenId: 1,
1240
- tokenName: "openai/haze",
1241
- threshold: 80,
1242
- cachedUtilization: 85,
1243
- reason: "over_threshold",
1244
- }),
1245
- ]);
1246
- expect(recoveredLogs).toHaveLength(1);
1247
- expect(recoveredLogs[0]).toEqual([
1248
- "quota_threshold gate: recovered openai/haze[1] (10% < 80%)",
1249
- expect.objectContaining({
1250
- tokenId: 1,
1251
- tokenName: "openai/haze",
1252
- threshold: 80,
1253
- cachedUtilization: 10,
1254
- reason: "recovered",
1255
- }),
1256
- ]);
1257
- });
1258
-
1259
- it("clears the runtime quota block when a lookup fails open", async () => {
1260
- const dispatcher = new OpenAIDispatcher();
1261
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1262
- addWorkers(dispatcher, [worker]);
1263
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1264
- readOpenAIQuotaUsageMock
1265
- .mockResolvedValueOnce(quotaOk(85))
1266
- .mockResolvedValueOnce(quotaFail("rpc timeout"))
1267
- .mockResolvedValueOnce(quotaOk(85));
1268
-
1269
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1270
- QuotaThresholdExceededError,
1271
- );
1272
- const failOpenWorker = await dispatcher.acquireIdleWorker();
1273
- failOpenWorker?.releaseTurn();
1274
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1275
- QuotaThresholdExceededError,
1276
- );
1277
-
1278
- const overThresholdLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1279
- String(message).includes("quota_threshold gate: over_threshold"),
1280
- );
1281
- expect(overThresholdLogs).toHaveLength(2);
1282
- expect(loggerWarnMock).toHaveBeenCalledWith(
1283
- expect.stringContaining("lookup_fail_open"),
1284
- expect.objectContaining({ tokenId: 1, reason: "lookup_fail_open" }),
1285
- );
1286
- });
1287
-
1288
- it("starts a new quota-block transition after the threshold changes", async () => {
1289
- const dispatcher = new OpenAIDispatcher();
1290
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1291
- addWorkers(dispatcher, [worker]);
1292
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1293
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(85));
1294
-
1295
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1296
- QuotaThresholdExceededError,
1297
- );
1298
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 70);
1299
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1300
- QuotaThresholdExceededError,
1301
- );
1302
-
1303
- const overThresholdLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1304
- String(message).includes("quota_threshold gate: over_threshold"),
1305
- );
1306
- expect(overThresholdLogs).toHaveLength(2);
1307
- expect(overThresholdLogs[1]?.[0]).toBe(
1308
- "quota_threshold gate: over_threshold openai/haze[1] (85% >= 70%)",
1309
- );
1310
- });
1311
-
1312
- it("starts a new quota-block transition after deactivation and reactivation", async () => {
1313
- const dispatcher = new OpenAIDispatcher();
1314
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1315
- addWorkers(dispatcher, [worker]);
1316
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1317
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(85));
1318
-
1319
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1320
- QuotaThresholdExceededError,
1321
- );
1322
- dispatcher.onTokenDeactivated(1);
1323
- dispatcher.onTokenActivated(1);
1324
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1325
- QuotaThresholdExceededError,
1326
- );
1327
-
1328
- const overThresholdLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1329
- String(message).includes("quota_threshold gate: over_threshold"),
1330
- );
1331
- expect(overThresholdLogs).toHaveLength(2);
1332
- });
1333
-
1334
- it("discards an over-threshold result when the threshold changes during lookup", async () => {
1335
- const dispatcher = new OpenAIDispatcher();
1336
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1337
- addWorkers(dispatcher, [worker]);
1338
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1339
- const pendingQuota = deferred<OpenAIQuotaUsageResult>();
1340
- readOpenAIQuotaUsageMock
1341
- .mockImplementationOnce(() => pendingQuota.promise)
1342
- .mockResolvedValueOnce(quotaOk(85))
1343
- .mockResolvedValueOnce(quotaOk(95));
1344
-
1345
- const pendingAcquire = dispatcher.acquireIdleWorker();
1346
- await vi.waitFor(() => expect(readOpenAIQuotaUsageMock).toHaveBeenCalledTimes(1));
1347
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 90);
1348
- pendingQuota.resolve(quotaOk(85));
1349
-
1350
- const eligibleWorker = await pendingAcquire;
1351
- expect(eligibleWorker).toBe(worker);
1352
- eligibleWorker?.releaseTurn();
1353
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1354
- QuotaThresholdExceededError,
1355
- );
1356
-
1357
- const overThresholdLogs = loggerInfoMock.mock.calls.filter(([message]) =>
1358
- String(message).includes("quota_threshold gate: over_threshold"),
1359
- );
1360
- expect(overThresholdLogs).toEqual([
1361
- [
1362
- "quota_threshold gate: over_threshold openai/haze[1] (95% >= 90%)",
1363
- expect.objectContaining({
1364
- tokenId: 1,
1365
- threshold: 90,
1366
- cachedUtilization: 95,
1367
- }),
1368
- ],
1369
- ]);
1370
- });
1371
-
1372
- it("does not re-block autoscaling when the threshold is removed during lookup", async () => {
1373
- const dispatcher = new OpenAIDispatcher(autoscaleConfig(), () => 64);
1374
- const worker = fakeWorker({
1375
- tokenId: 1,
1376
- tokenName: "openai/haze",
1377
- workerIndex: 0,
1378
- });
1379
- addWorkers(dispatcher, [worker]);
1380
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1381
- const pendingQuota = deferred<OpenAIQuotaUsageResult>();
1382
- readOpenAIQuotaUsageMock.mockImplementationOnce(() => pendingQuota.promise);
1383
-
1384
- const pendingAcquire = dispatcher.acquireIdleWorker();
1385
- await vi.waitFor(() => expect(readOpenAIQuotaUsageMock).toHaveBeenCalledTimes(1));
1386
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), null);
1387
- pendingQuota.resolve(quotaOk(85));
1388
-
1389
- const eligibleWorker = await pendingAcquire;
1390
- expect(eligibleWorker).toBe(worker);
1391
- eligibleWorker?.releaseTurn();
1392
- expect(
1393
- loggerInfoMock.mock.calls.filter(([message]) =>
1394
- String(message).includes("quota_threshold gate:"),
1395
- ),
1396
- ).toHaveLength(0);
1397
356
 
1398
- const spawnedWorker = fakeWorker({
1399
- tokenId: 1,
1400
- tokenName: "openai/haze",
1401
- workerIndex: 1,
357
+ it("fails quota lookup open, gates all exceeded tokens, and recovers after lifecycle update", async () => {
358
+ const completeClient = () => ({
359
+ responses: () => events({ type: "completed", responseId: "r" }),
1402
360
  });
1403
- const spawnSingleWorker = vi
1404
- .spyOn(dispatcher, "spawnSingleWorker")
1405
- .mockResolvedValue(spawnedWorker);
1406
- await dispatcher.scaleUpOneStep();
1407
-
1408
- expect(spawnSingleWorker).toHaveBeenCalledTimes(1);
1409
- expect(dispatcher.workerPool.get(1)).toEqual([worker, spawnedWorker]);
1410
- });
1411
-
1412
- it("does not restore a quota block when the token is deactivated during lookup", async () => {
1413
- const dispatcher = new OpenAIDispatcher();
1414
- const worker = fakeWorker({ tokenId: 1, tokenName: "openai/haze" });
1415
- addWorkers(dispatcher, [worker]);
1416
- await dispatcher.onTokenUpdated(1, "openai/haze", credentials(), 80);
1417
- const pendingQuota = deferred<OpenAIQuotaUsageResult>();
1418
- readOpenAIQuotaUsageMock
1419
- .mockImplementationOnce(() => pendingQuota.promise)
1420
- .mockResolvedValueOnce(quotaOk(85));
1421
-
1422
- const pendingAcquire = dispatcher.acquireIdleWorker();
1423
- await vi.waitFor(() => expect(readOpenAIQuotaUsageMock).toHaveBeenCalledTimes(1));
1424
- dispatcher.onTokenDeactivated(1);
1425
- pendingQuota.resolve(quotaOk(85));
1426
-
1427
- await expect(pendingAcquire).resolves.toBeNull();
1428
- expect(
1429
- loggerInfoMock.mock.calls.filter(([message]) =>
1430
- String(message).includes("quota_threshold gate:"),
1431
- ),
1432
- ).toHaveLength(0);
1433
-
1434
- dispatcher.onTokenActivated(1);
1435
- await expect(dispatcher.acquireIdleWorker()).rejects.toBeInstanceOf(
1436
- QuotaThresholdExceededError,
1437
- );
1438
- expect(
1439
- loggerInfoMock.mock.calls.filter(([message]) =>
1440
- String(message).includes("quota_threshold gate: over_threshold"),
1441
- ),
1442
- ).toHaveLength(1);
1443
- });
1444
-
1445
- it("keeps eligible busy workers queued instead of throwing quota errors", async () => {
1446
- const dispatcher = new OpenAIDispatcher();
1447
- const worker = fakeWorker({ tokenId: 1, tokenName: "tok-A", busy: true });
1448
- addWorkers(dispatcher, [worker]);
1449
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1450
- readOpenAIQuotaUsageMock.mockResolvedValue(quotaOk(10));
1451
-
1452
- await expect(dispatcher.acquireIdleWorker()).resolves.toBeNull();
1453
- const queued = dispatcher.enqueue(async (w) => w.tokenName);
1454
- await waitForQueue(dispatcher);
1455
-
1456
- worker.releaseTurn();
1457
- await dispatcher.drainQueue();
1458
- await expect(queued).resolves.toBe("tok-A");
1459
- });
1460
-
1461
- it("throws typed error when no active ready tokenId passes threshold", async () => {
1462
- const dispatcher = new OpenAIDispatcher();
1463
- addWorkers(dispatcher, [fakeWorker({ tokenId: 1, tokenName: "tok-A" })]);
1464
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1465
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(90));
1466
-
1467
- const error = await dispatcher.acquireIdleWorker().catch((e) => e);
1468
-
1469
- expect(error).toBeInstanceOf(QuotaThresholdExceededError);
1470
- expect(error).toMatchObject({ code: "QUOTA_THRESHOLD_EXCEEDED" });
1471
- expect(error.message).toBe(
1472
- "All openai tokens exceeded quota threshold: tok-A (threshold 80%)",
1473
- );
1474
- });
1475
-
1476
- it("rechecks threshold at drain time before assigning the released worker", async () => {
1477
- const dispatcher = new OpenAIDispatcher();
1478
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A", busy: true });
1479
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B", busy: true });
1480
- addWorkers(dispatcher, [workerA, workerB]);
1481
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1482
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), 80);
1483
- const queued = dispatcher.enqueue(async (w) => w.tokenName);
1484
- await waitForQueue(dispatcher);
1485
- readOpenAIQuotaUsageMock.mockReset();
1486
- readOpenAIQuotaUsageMock
1487
- .mockResolvedValueOnce(quotaOk(90))
1488
- .mockResolvedValueOnce(quotaOk(10));
1489
- workerA.releaseTurn();
1490
- workerB.releaseTurn();
1491
-
1492
- await dispatcher.drainQueue();
1493
-
1494
- await expect(queued).resolves.toBe("tok-B");
1495
- });
1496
-
1497
- it("serializes concurrent drain calls so a queue item is not assigned twice", async () => {
1498
- const dispatcher = new OpenAIDispatcher();
1499
- const worker = fakeWorker({ tokenId: 1, tokenName: "tok-A", busy: true });
1500
- addWorkers(dispatcher, [worker]);
1501
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), null, 1);
1502
- const execute = vi.fn(async (w: CodexAppServerWorker) => w.tokenName);
1503
- const queued = dispatcher.enqueue(execute);
1504
- await waitForQueue(dispatcher);
1505
- worker.releaseTurn();
1506
-
1507
- await Promise.all([dispatcher.drainQueue(), dispatcher.drainQueue()]);
1508
-
1509
- await expect(queued).resolves.toBe("tok-A");
1510
- expect(execute).toHaveBeenCalledTimes(1);
1511
- });
1512
-
1513
- it("treats quota lookup failure as fail-open", async () => {
1514
- const dispatcher = new OpenAIDispatcher();
1515
- addWorkers(dispatcher, [fakeWorker({ tokenId: 1, tokenName: "tok-A" })]);
1516
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1517
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaFail("rpc timeout"));
1518
-
1519
- await expect(dispatcher.acquireIdleWorker()).resolves.toMatchObject({ tokenName: "tok-A" });
1520
- expect(loggerWarnMock).toHaveBeenCalledWith(
1521
- expect.stringContaining("lookup_fail_open"),
1522
- expect.objectContaining({
1523
- tokenId: 1,
1524
- tokenName: "tok-A",
1525
- provider: "openai",
1526
- threshold: 80,
1527
- reason: "lookup_fail_open",
1528
- }),
1529
- );
1530
- });
1531
-
1532
- it("falls back from over-threshold reuse to cold on another tokenId", async () => {
1533
- const dispatcher = new OpenAIDispatcher();
1534
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A", threads: ["thread-1"] });
1535
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B" });
1536
- addWorkers(dispatcher, [workerA, workerB]);
1537
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1538
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), 80);
1539
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(85)).mockResolvedValueOnce(quotaOk(10));
1540
- const executeTurn = vi
1541
- .spyOn(dispatcher, "executeTurn")
1542
- .mockImplementation(async (worker, _req, reuseThreadId) =>
1543
- resultFor(worker, reuseThreadId ?? "thread-new"),
1544
- );
1545
-
1546
- const result = await dispatcher.generate(
1547
- baseReq({
1548
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "thread-1", epoch: 1 },
1549
- }),
1550
- );
1551
-
1552
- expect(result.tokenName).toBe("tok-B");
1553
- expect(executeTurn.mock.calls[0]?.[0]).toBe(workerB);
1554
- expect(executeTurn.mock.calls[0]?.[2]).toBeUndefined();
1555
- expect(workerA.tryAcquireTurn).not.toHaveBeenCalled();
1556
- });
1557
-
1558
- it("keeps reuse when the reused token is under threshold", async () => {
1559
- const dispatcher = new OpenAIDispatcher();
1560
- const worker = fakeWorker({ tokenId: 1, tokenName: "tok-A", threads: ["thread-1"] });
1561
- addWorkers(dispatcher, [worker]);
1562
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1563
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(10));
1564
- const executeTurn = vi
1565
- .spyOn(dispatcher, "executeTurn")
1566
- .mockImplementation(async (selected, _req, reuseThreadId) =>
1567
- resultFor(selected, reuseThreadId ?? "thread-new"),
1568
- );
1569
-
1570
- const result = await dispatcher.generate(
1571
- baseReq({
1572
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "thread-1", epoch: 1 },
1573
- }),
1574
- );
1575
-
1576
- expect(result.tokenName).toBe("tok-A");
1577
- expect(executeTurn).toHaveBeenCalledWith(worker, expect.anything(), "thread-1");
1578
- });
1579
-
1580
- it("falls back from reuse when the token is deactivated during quota lookup", async () => {
1581
- const dispatcher = new OpenAIDispatcher();
1582
- const workerA = fakeWorker({ tokenId: 1, tokenName: "tok-A", threads: ["thread-1"] });
1583
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B" });
1584
- addWorkers(dispatcher, [workerA, workerB]);
1585
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1586
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null);
1587
- const pendingQuota = deferred<OpenAIQuotaUsageResult>();
1588
- readOpenAIQuotaUsageMock.mockImplementationOnce(() => pendingQuota.promise);
1589
- const executeTurn = vi
1590
- .spyOn(dispatcher, "executeTurn")
1591
- .mockImplementation(async (worker, _req, reuseThreadId) =>
1592
- resultFor(worker, reuseThreadId ?? "thread-new"),
1593
- );
1594
-
1595
- const pendingGenerate = dispatcher.generate(
1596
- baseReq({
1597
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "thread-1", epoch: 1 },
1598
- }),
1599
- );
1600
- await vi.waitFor(() => expect(readOpenAIQuotaUsageMock).toHaveBeenCalledTimes(1));
1601
- dispatcher.onTokenDeactivated(1);
1602
- pendingQuota.resolve(quotaOk(10));
1603
-
1604
- await expect(pendingGenerate).resolves.toMatchObject({ tokenName: "tok-B" });
1605
- expect(workerA.tryAcquireTurn).not.toHaveBeenCalled();
1606
- expect(executeTurn).toHaveBeenCalledWith(workerB, expect.anything());
1607
- });
1608
-
1609
- it("falls back from busy reuse when its quota metadata changes", async () => {
1610
- const dispatcher = new OpenAIDispatcher();
1611
- const workerA = fakeWorker({
1612
- tokenId: 1,
1613
- tokenName: "tok-A",
1614
- threads: ["thread-1"],
1615
- busy: true,
361
+ const failOpen = new OpenAIDispatcher(config(), {
362
+ clientFactory: completeClient,
363
+ fetch: async () => new Response("down", { status: 503 }),
1616
364
  });
1617
- const workerB = fakeWorker({ tokenId: 2, tokenName: "tok-B" });
1618
- addWorkers(dispatcher, [workerA, workerB]);
1619
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1620
- await dispatcher.onTokenUpdated(2, "tok-B", credentials(), null);
1621
- readOpenAIQuotaUsageMock
1622
- .mockResolvedValueOnce(quotaOk(10))
1623
- .mockResolvedValueOnce(quotaOk(10));
1624
- const executeTurn = vi
1625
- .spyOn(dispatcher, "executeTurn")
1626
- .mockImplementation(async (worker, _req, reuseThreadId) =>
1627
- resultFor(worker, reuseThreadId ?? "thread-new"),
1628
- );
1629
-
1630
- const pendingGenerate = dispatcher.generate(
1631
- baseReq({
1632
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "thread-1", epoch: 1 },
1633
- }),
1634
- );
1635
- await vi.waitFor(() => expect(workerA.tryAcquireTurn).toHaveBeenCalledTimes(1));
1636
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 5);
1637
-
1638
- await expect(pendingGenerate).resolves.toMatchObject({ tokenName: "tok-B" });
1639
- expect(executeTurn).toHaveBeenCalledWith(workerB, expect.anything());
1640
- });
1641
-
1642
- it("passes worker ttftMs into GenerateResult", async () => {
1643
- const dispatcher = new OpenAIDispatcher();
1644
- const worker = fakeWorker({ tokenId: 1, tokenName: "tok-A" });
1645
- const usage = {
1646
- totalTokens: 12,
1647
- inputTokens: 5,
1648
- cachedInputTokens: 0,
1649
- outputTokens: 7,
1650
- reasoningOutputTokens: 0,
1651
- };
1652
- (
1653
- worker as unknown as {
1654
- executeTurn: () => Promise<{
1655
- text: string;
1656
- usage: typeof usage;
1657
- durationMs: number;
1658
- ttftMs: number | null;
1659
- model: string;
1660
- threadId: string;
1661
- }>;
1662
- }
1663
- ).executeTurn = vi.fn(async () => ({
1664
- text: "ok",
1665
- usage,
1666
- durationMs: 80,
1667
- ttftMs: 11,
1668
- model: "gpt-5-codex",
1669
- threadId: "thread-1",
1670
- }));
1671
-
1672
- const result = await dispatcher.executeTurn(worker, baseReq());
1673
-
1674
- expect(result.ttftMs).toBe(11);
1675
- expect(result.threadCoord?.threadId).toBe("thread-1");
1676
- });
1677
-
1678
- it("throws typed error when reuse is over threshold and no cold tokenId is eligible", async () => {
1679
- const dispatcher = new OpenAIDispatcher();
1680
- const worker = fakeWorker({ tokenId: 1, tokenName: "tok-A", threads: ["thread-1"] });
1681
- addWorkers(dispatcher, [worker]);
1682
- await dispatcher.onTokenUpdated(1, "tok-A", credentials(), 80);
1683
- readOpenAIQuotaUsageMock.mockResolvedValueOnce(quotaOk(85));
1684
-
1685
- await expect(
1686
- dispatcher.generate(
1687
- baseReq({
1688
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "thread-1", epoch: 1 },
1689
- }),
1690
- ),
1691
- ).rejects.toBeInstanceOf(QuotaThresholdExceededError);
1692
- });
1693
- });
1694
-
1695
- describe("OpenAIDispatcher image generation gate and failure classification", () => {
1696
- it("throws a gate error without running the turn when capability is unsupported", async () => {
1697
- const dispatcher = new OpenAIDispatcher();
1698
- const worker = fakeWorker({ imageGateReason: "provider does not support image generation" });
1699
-
1700
- await expect(
1701
- dispatcher.executeTurn(worker, baseReq({ imageGeneration: true })),
1702
- ).rejects.toMatchObject({ kind: "gate" });
1703
- // 게이트 실패 시 turn 은 실행되지 않는다.
1704
- expect((worker as unknown as { executeTurn: ReturnType<typeof vi.fn> }).executeTurn).not.toHaveBeenCalled();
1705
- });
1706
-
1707
- it("throws a gate error for a non-multimodal model", async () => {
1708
- const dispatcher = new OpenAIDispatcher();
1709
- const worker = fakeWorker({ imageGateReason: "model gpt-x is not multimodal (no image input modality)" });
1710
-
1711
- await expect(
1712
- dispatcher.executeTurn(worker, baseReq({ imageGeneration: true, model: "gpt-x" })),
1713
- ).rejects.toBeInstanceOf(ImageGenerationError);
1714
- });
1715
-
1716
- it("classifies zero images with no tool call as not_called (retry futile)", async () => {
1717
- const dispatcher = new OpenAIDispatcher();
1718
- const worker = fakeWorker({ imageGateReason: null, imageTurnResult: { imageAttempted: false } });
1719
-
1720
- await expect(
1721
- dispatcher.executeTurn(worker, baseReq({ imageGeneration: true })),
1722
- ).rejects.toMatchObject({ kind: "not_called" });
1723
- });
1724
-
1725
- it("classifies zero images after an attempt as incomplete (retry candidate)", async () => {
1726
- const dispatcher = new OpenAIDispatcher();
1727
- const worker = fakeWorker({ imageGateReason: null, imageTurnResult: { imageAttempted: true } });
1728
-
1729
- await expect(
1730
- dispatcher.executeTurn(worker, baseReq({ imageGeneration: true })),
1731
- ).rejects.toMatchObject({ kind: "incomplete" });
1732
- });
1733
-
1734
- it("passes an image result through without gating a valid request", async () => {
1735
- const dispatcher = new OpenAIDispatcher();
1736
- const worker = fakeWorker({
1737
- imageGateReason: null,
1738
- imageTurnResult: { images: [{ data: "iVBORw0KGgoBAgM", revisedPrompt: "a cat" }], imageAttempted: true },
365
+ await failOpen.onTokenAdded(1, "one", credentials, 80);
366
+ await expect(failOpen.generate(request())).resolves.toMatchObject({ tokenName: "one" });
367
+
368
+ const blocked = new OpenAIDispatcher(config(), {
369
+ clientFactory: completeClient,
370
+ fetch: async () =>
371
+ new Response(
372
+ JSON.stringify({
373
+ rate_limits: {
374
+ limit_id: "codex",
375
+ primary_window: { used_percent: 90, window_minutes: 300, reset_at: 123 },
376
+ },
377
+ }),
378
+ { status: 200, headers: { "content-type": "application/json" } },
379
+ ),
1739
380
  });
1740
-
1741
- const result = await dispatcher.executeTurn(worker, baseReq({ imageGeneration: true }));
1742
- expect(result.images).toHaveLength(1);
1743
- expect(result.images?.[0]?.revisedPrompt).toBe("a cat");
1744
- });
1745
-
1746
- it("does not gate or classify a normal text request", async () => {
1747
- const dispatcher = new OpenAIDispatcher();
1748
- const worker = fakeWorker({ imageTurnResult: {} });
1749
-
1750
- const result = await dispatcher.executeTurn(worker, baseReq());
1751
- expect(result.text).toBe("ok");
1752
- expect((worker as unknown as { checkImageGenerationSupport: ReturnType<typeof vi.fn> }).checkImageGenerationSupport).not.toHaveBeenCalled();
1753
- });
1754
- });
1755
-
1756
- describe("OpenAIDispatcher image generation routing", () => {
1757
- it("rejects image requests on the streaming path", async () => {
1758
- const dispatcher = new OpenAIDispatcher();
1759
- const cb = { onDelta: vi.fn(), onComplete: vi.fn(), onError: vi.fn() };
1760
- await expect(
1761
- dispatcher.generateStream(baseReq({ imageGeneration: true }), cb),
1762
- ).rejects.toBeInstanceOf(ImageGenerationError);
1763
- });
1764
-
1765
- it("forces cold thread for image requests even when a reuse coordinate is present", async () => {
1766
- const dispatcher = new OpenAIDispatcher();
1767
- const worker = await dispatcher.acquireReuseWorker(
1768
- baseReq({
1769
- imageGeneration: true,
1770
- reuse: { workerId: makeOpenAIWorkerId(1, 0), threadId: "t1", epoch: 1 },
1771
- }),
1772
- );
1773
- expect(worker).toBeNull();
381
+ await blocked.onTokenAdded(1, "one", credentials, 80);
382
+ await expect(blocked.generate(request())).rejects.toBeInstanceOf(Error);
383
+ await blocked.onTokenUpdated(1, "one", credentials, null, 1);
384
+ await expect(blocked.generate(request())).resolves.toMatchObject({ tokenName: "one" });
385
+ blocked.onTokenDeactivated(1);
386
+ await expect(blocked.generate(request())).rejects.toThrow("NO_OPENAI_WORKERS");
1774
387
  });
1775
388
  });