@cartanova/qgrid-cli 2.7.1 → 2.7.2

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 (1212) 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/{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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/evaluatedModules.Dg1zASAC.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/index.Chj8NDwU.js +2 -2
  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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/index.DdgEv5B1.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/rpc.MzXet3jl.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/test.DNmyFkvJ.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.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_3892b4338df694f79f7d384fad23d930}/node_modules/vitest/dist/index.js +1 -1
  38. package/bundle/dist/sonamu.config.js +10 -9
  39. package/bundle/dist/testing/setup-mocks.js +2 -2
  40. package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +14 -2
  41. package/bundle/dist/utils/providers/anthropic/claude-session.js +1 -1
  42. package/bundle/dist/utils/providers/anthropic/stream-json-adapter.js +1 -1
  43. package/bundle/dist/utils/providers/common/model-cost.js +1 -1
  44. package/bundle/dist/utils/providers/common/schema-validation.js +1 -1
  45. package/bundle/dist/utils/providers/openai/openai-backend-protocol.js +144 -0
  46. package/bundle/dist/utils/providers/openai/openai-constants.js +4 -2
  47. package/bundle/dist/utils/providers/openai/openai-direct-client.js +327 -0
  48. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +358 -781
  49. package/bundle/dist/utils/providers/openai/openai-oauth.js +84 -0
  50. package/bundle/dist/utils/providers/openai/openai-quota.js +76 -5
  51. package/bundle/dist/utils/providers/openai/openai-refresh.js +3 -3
  52. package/bundle/dist/utils/providers/openai/openai-sse.js +72 -0
  53. package/bundle/dist/utils/providers/openai/openai-transport-config.js +14 -0
  54. package/bundle/src/application/monit/monit.frame.test.ts +14 -17
  55. package/bundle/src/application/monit/monit.frame.ts +23 -12
  56. package/bundle/src/application/monit/monit.types.ts +40 -11
  57. package/bundle/src/application/qgrid/conv-routing.test.ts +67 -0
  58. package/bundle/src/application/qgrid/conv-routing.ts +46 -12
  59. package/bundle/src/application/qgrid/qgrid-oauth-redirect.test.ts +92 -2
  60. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +3 -0
  61. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +15 -1
  62. package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +36 -6
  63. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +22 -9
  64. package/bundle/src/application/qgrid/qgrid.frame.ts +55 -94
  65. package/bundle/src/application/qgrid/qgrid.types.ts +11 -4
  66. package/bundle/src/application/qgrid/token-subscriber.ts +4 -4
  67. package/bundle/src/application/qgrid/tool-emulation-schema.ts +1 -1
  68. package/bundle/src/application/qgrid/tool-emulation.test.ts +1 -0
  69. package/bundle/src/application/queries.generated.ts +6 -0
  70. package/bundle/src/application/request-log/json-schema-type-text.test.ts +96 -0
  71. package/bundle/src/application/request-log/json-schema-type-text.ts +83 -0
  72. package/bundle/src/application/request-log/request-log.entity.json +147 -21
  73. package/bundle/src/application/request-log/request-log.model.ts +108 -0
  74. package/bundle/src/application/request-log/request-log.types.ts +2 -0
  75. package/bundle/src/application/request-log/zod-code-format.test.ts +31 -0
  76. package/bundle/src/application/request-log/zod-code-format.ts +73 -0
  77. package/bundle/src/application/setting/setting.constant.test.ts +22 -24
  78. package/bundle/src/application/setting/setting.constant.ts +2 -63
  79. package/bundle/src/application/setting/setting.entity.json +1 -1
  80. package/bundle/src/application/setting/setting.store.ts +1 -1
  81. package/bundle/src/application/sonamu.generated.http +20 -1
  82. package/bundle/src/application/sonamu.generated.sso.ts +4 -0
  83. package/bundle/src/application/sonamu.generated.ts +10 -0
  84. package/bundle/src/i18n/sd.generated.ts +6 -1
  85. package/bundle/src/migrations/20260814130113_alter_request_logs_add1_alter1.ts +15 -0
  86. package/bundle/src/migrations/20260814131051_alter_request_logs_add1_alter1.ts +15 -0
  87. package/bundle/src/migrations/20260814134846_alter_request_logs_add1_alter1.ts +15 -0
  88. package/bundle/src/migrations/20260814140759_alter_request_logs_alter1.ts +13 -0
  89. package/bundle/src/sonamu.config.ts +9 -13
  90. package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +17 -2
  91. package/bundle/src/utils/providers/anthropic/claude-session.ts +1 -3
  92. package/bundle/src/utils/providers/anthropic/stream-json-adapter.test.ts +1 -2
  93. package/bundle/src/utils/providers/anthropic/stream-json-adapter.ts +2 -3
  94. package/bundle/src/utils/providers/common/model-cost.ts +4 -9
  95. package/bundle/src/utils/providers/common/provider-dispatcher.ts +10 -8
  96. package/bundle/src/utils/providers/common/provider-types.ts +48 -0
  97. package/bundle/src/utils/providers/common/schema-validation.ts +1 -1
  98. package/bundle/src/utils/providers/openai/openai-backend-protocol.test.ts +106 -0
  99. package/bundle/src/utils/providers/openai/openai-backend-protocol.ts +255 -0
  100. package/bundle/src/utils/providers/openai/openai-constants.ts +2 -0
  101. package/bundle/src/utils/providers/openai/openai-direct-client.test.ts +610 -0
  102. package/bundle/src/utils/providers/openai/openai-direct-client.ts +478 -0
  103. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +336 -1723
  104. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +458 -1175
  105. package/bundle/src/utils/providers/openai/openai-oauth.test.ts +95 -0
  106. package/bundle/src/utils/providers/openai/openai-oauth.ts +141 -0
  107. package/bundle/src/utils/providers/openai/openai-quota.test.ts +80 -7
  108. package/bundle/src/utils/providers/openai/openai-quota.ts +105 -4
  109. package/bundle/src/utils/providers/openai/openai-refresh.test.ts +120 -0
  110. package/bundle/src/utils/providers/openai/openai-refresh.ts +3 -1
  111. package/bundle/src/utils/providers/openai/openai-sse.test.ts +52 -0
  112. package/bundle/src/utils/providers/openai/openai-sse.ts +79 -0
  113. package/bundle/src/utils/providers/openai/openai-transport-config.ts +17 -0
  114. package/bundle/web-dist/client/assets/index-BldeEvAK.css +1 -0
  115. package/bundle/web-dist/client/assets/index-DkAXPF9q.js +106 -0
  116. package/bundle/web-dist/client/assets/logs-DlI6OojL.js +1 -0
  117. package/bundle/web-dist/client/assets/monit-qap66dhi.js +1 -0
  118. package/bundle/web-dist/client/assets/{routes-J4bnHVfl.js → routes-CV07Pzde.js} +1 -1
  119. package/bundle/web-dist/client/assets/{services.generated-jGypfumC.js → services.generated-CSW8bhCP.js} +4 -4
  120. package/bundle/web-dist/client/assets/settings-CdYub4yo.js +1 -0
  121. package/bundle/web-dist/client/assets/show-DA1L8DVD.js +2 -0
  122. package/bundle/web-dist/client/assets/{tokens-DDrATjGA.js → tokens-Dt3gfkwP.js} +1 -1
  123. package/bundle/web-dist/client/assets/{use-oauth-login-flow-CptleCFM.js → use-oauth-login-flow-Cwi0HtJY.js} +1 -1
  124. package/bundle/web-dist/client/index.html +3 -3
  125. package/bundle/web-dist/server/assets/{lazyRouteComponent-DOc8TV-P.js → lazyRouteComponent-0y-znAfz.js} +2 -2
  126. package/bundle/web-dist/server/assets/{logs-CfF3nmLM.js → logs-CJBbHM3_.js} +35 -5
  127. package/bundle/web-dist/server/assets/{monit-BSaKhh5D.js → monit-8WAsPETB.js} +144 -51
  128. package/bundle/web-dist/server/assets/{plus-DLFUHsfx.js → plus-9das21ju.js} +1 -1
  129. package/bundle/web-dist/server/assets/{react-dom-BotjLnTK.js → react-dom-zmEq8BVp.js} +1 -1
  130. package/bundle/web-dist/server/assets/{routes-CHMxrTT0.js → routes-B6bX3o41.js} +3 -3
  131. package/bundle/web-dist/server/assets/{services.generated-D3Q3FYot.js → services.generated-DyPeBI00.js} +76 -2
  132. package/bundle/web-dist/server/assets/{settings-DOQjV28c.js → settings-D1u5WdpP.js} +2 -3
  133. package/bundle/web-dist/server/assets/{show-Cn_C6Qvl.js → show-Cr7vwR0l.js} +93 -8
  134. package/bundle/web-dist/server/assets/{tokens-c0EN3iCx.js → tokens-BumM0gnH.js} +3 -3
  135. package/bundle/web-dist/server/assets/{use-oauth-login-flow-B68AbMDE.js → use-oauth-login-flow-DmsHGOlx.js} +1 -1
  136. package/bundle/web-dist/server/entry-server.generated.js +12 -12
  137. package/dist/cli.d.ts +10 -1
  138. package/dist/cli.js +1 -6
  139. package/package.json +3 -2
  140. package/skills/qgrid/SKILL.md +5 -5
  141. package/skills/qgrid/references/ai-sdk-provider-contract.md +16 -10
  142. package/skills/qgrid/references/cli-env-and-server-boot.md +6 -13
  143. package/skills/qgrid/references/decision-rationale.md +15 -23
  144. package/skills/qgrid/references/docs-workflow.md +1 -1
  145. package/skills/qgrid/references/openai-codex-runtime.md +39 -156
  146. package/skills/qgrid/references/prompt-cache-and-usage.md +35 -71
  147. package/skills/qgrid/references/provider-runtime-differences.md +17 -17
  148. package/skills/qgrid/references/repo-map.md +2 -2
  149. package/skills/qgrid/references/request-log-run-lifecycle.md +12 -2
  150. package/skills/qgrid/references/sonamu-api-web-flow.md +4 -0
  151. package/skills/qgrid/references/token-auth-quota-lifecycle.md +14 -24
  152. package/skills/qgrid/references/tool-calling-and-multiturn.md +3 -3
  153. package/skills/qgrid/references/verification-and-debugging.md +17 -15
  154. package/bundle/dist/codex-protocol/AgentPath.js +0 -1
  155. package/bundle/dist/codex-protocol/ApplyPatchApprovalParams.js +0 -1
  156. package/bundle/dist/codex-protocol/ApplyPatchApprovalResponse.js +0 -1
  157. package/bundle/dist/codex-protocol/AuthMode.js +0 -1
  158. package/bundle/dist/codex-protocol/ClientInfo.js +0 -1
  159. package/bundle/dist/codex-protocol/ClientNotification.js +0 -1
  160. package/bundle/dist/codex-protocol/ClientRequest.js +0 -1
  161. package/bundle/dist/codex-protocol/CollaborationMode.js +0 -1
  162. package/bundle/dist/codex-protocol/ContentItem.js +0 -1
  163. package/bundle/dist/codex-protocol/ConversationGitInfo.js +0 -1
  164. package/bundle/dist/codex-protocol/ConversationSummary.js +0 -1
  165. package/bundle/dist/codex-protocol/ExecCommandApprovalParams.js +0 -1
  166. package/bundle/dist/codex-protocol/ExecCommandApprovalResponse.js +0 -1
  167. package/bundle/dist/codex-protocol/ExecPolicyAmendment.js +0 -1
  168. package/bundle/dist/codex-protocol/FileChange.js +0 -1
  169. package/bundle/dist/codex-protocol/ForcedLoginMethod.js +0 -1
  170. package/bundle/dist/codex-protocol/FunctionCallOutputBody.js +0 -1
  171. package/bundle/dist/codex-protocol/FunctionCallOutputContentItem.js +0 -1
  172. package/bundle/dist/codex-protocol/FuzzyFileSearchMatchType.js +0 -1
  173. package/bundle/dist/codex-protocol/FuzzyFileSearchParams.js +0 -1
  174. package/bundle/dist/codex-protocol/FuzzyFileSearchResponse.js +0 -1
  175. package/bundle/dist/codex-protocol/FuzzyFileSearchResult.js +0 -1
  176. package/bundle/dist/codex-protocol/FuzzyFileSearchSessionCompletedNotification.js +0 -1
  177. package/bundle/dist/codex-protocol/FuzzyFileSearchSessionUpdatedNotification.js +0 -1
  178. package/bundle/dist/codex-protocol/GetAuthStatusParams.js +0 -1
  179. package/bundle/dist/codex-protocol/GetAuthStatusResponse.js +0 -1
  180. package/bundle/dist/codex-protocol/GetConversationSummaryParams.js +0 -1
  181. package/bundle/dist/codex-protocol/GetConversationSummaryResponse.js +0 -1
  182. package/bundle/dist/codex-protocol/GitDiffToRemoteParams.js +0 -1
  183. package/bundle/dist/codex-protocol/GitDiffToRemoteResponse.js +0 -1
  184. package/bundle/dist/codex-protocol/GitSha.js +0 -1
  185. package/bundle/dist/codex-protocol/ImageDetail.js +0 -1
  186. package/bundle/dist/codex-protocol/InitializeCapabilities.js +0 -1
  187. package/bundle/dist/codex-protocol/InitializeParams.js +0 -1
  188. package/bundle/dist/codex-protocol/InitializeResponse.js +0 -1
  189. package/bundle/dist/codex-protocol/InputModality.js +0 -1
  190. package/bundle/dist/codex-protocol/InternalSessionSource.js +0 -1
  191. package/bundle/dist/codex-protocol/LocalShellAction.js +0 -1
  192. package/bundle/dist/codex-protocol/LocalShellExecAction.js +0 -1
  193. package/bundle/dist/codex-protocol/LocalShellStatus.js +0 -1
  194. package/bundle/dist/codex-protocol/MessagePhase.js +0 -1
  195. package/bundle/dist/codex-protocol/ModeKind.js +0 -1
  196. package/bundle/dist/codex-protocol/NetworkPolicyAmendment.js +0 -1
  197. package/bundle/dist/codex-protocol/NetworkPolicyRuleAction.js +0 -1
  198. package/bundle/dist/codex-protocol/ParsedCommand.js +0 -1
  199. package/bundle/dist/codex-protocol/Personality.js +0 -1
  200. package/bundle/dist/codex-protocol/PlanType.js +0 -1
  201. package/bundle/dist/codex-protocol/RealtimeConversationVersion.js +0 -1
  202. package/bundle/dist/codex-protocol/RealtimeOutputModality.js +0 -1
  203. package/bundle/dist/codex-protocol/RealtimeVoice.js +0 -1
  204. package/bundle/dist/codex-protocol/RealtimeVoicesList.js +0 -1
  205. package/bundle/dist/codex-protocol/ReasoningEffort.js +0 -1
  206. package/bundle/dist/codex-protocol/ReasoningItemContent.js +0 -1
  207. package/bundle/dist/codex-protocol/ReasoningItemReasoningSummary.js +0 -1
  208. package/bundle/dist/codex-protocol/ReasoningSummary.js +0 -1
  209. package/bundle/dist/codex-protocol/RequestId.js +0 -1
  210. package/bundle/dist/codex-protocol/Resource.js +0 -1
  211. package/bundle/dist/codex-protocol/ResourceContent.js +0 -1
  212. package/bundle/dist/codex-protocol/ResourceTemplate.js +0 -1
  213. package/bundle/dist/codex-protocol/ResponseItem.js +0 -1
  214. package/bundle/dist/codex-protocol/ReviewDecision.js +0 -1
  215. package/bundle/dist/codex-protocol/ServerNotification.js +0 -1
  216. package/bundle/dist/codex-protocol/ServerRequest.js +0 -1
  217. package/bundle/dist/codex-protocol/SessionSource.js +0 -1
  218. package/bundle/dist/codex-protocol/Settings.js +0 -1
  219. package/bundle/dist/codex-protocol/SubAgentSource.js +0 -1
  220. package/bundle/dist/codex-protocol/ThreadId.js +0 -1
  221. package/bundle/dist/codex-protocol/ThreadMemoryMode.js +0 -1
  222. package/bundle/dist/codex-protocol/Tool.js +0 -1
  223. package/bundle/dist/codex-protocol/Verbosity.js +0 -1
  224. package/bundle/dist/codex-protocol/WebSearchAction.js +0 -1
  225. package/bundle/dist/codex-protocol/WebSearchContextSize.js +0 -1
  226. package/bundle/dist/codex-protocol/WebSearchLocation.js +0 -1
  227. package/bundle/dist/codex-protocol/WebSearchMode.js +0 -1
  228. package/bundle/dist/codex-protocol/WebSearchToolConfig.js +0 -1
  229. package/bundle/dist/codex-protocol/index.js +0 -2
  230. package/bundle/dist/codex-protocol/serde_json/JsonValue.js +0 -1
  231. package/bundle/dist/codex-protocol/v2/Account.js +0 -1
  232. package/bundle/dist/codex-protocol/v2/AccountLoginCompletedNotification.js +0 -1
  233. package/bundle/dist/codex-protocol/v2/AccountRateLimitsUpdatedNotification.js +0 -1
  234. package/bundle/dist/codex-protocol/v2/AccountUpdatedNotification.js +0 -1
  235. package/bundle/dist/codex-protocol/v2/ActivePermissionProfile.js +0 -1
  236. package/bundle/dist/codex-protocol/v2/ActivePermissionProfileModification.js +0 -1
  237. package/bundle/dist/codex-protocol/v2/AddCreditsNudgeCreditType.js +0 -1
  238. package/bundle/dist/codex-protocol/v2/AddCreditsNudgeEmailStatus.js +0 -1
  239. package/bundle/dist/codex-protocol/v2/AdditionalFileSystemPermissions.js +0 -1
  240. package/bundle/dist/codex-protocol/v2/AdditionalNetworkPermissions.js +0 -1
  241. package/bundle/dist/codex-protocol/v2/AdditionalPermissionProfile.js +0 -1
  242. package/bundle/dist/codex-protocol/v2/AgentMessageDeltaNotification.js +0 -1
  243. package/bundle/dist/codex-protocol/v2/AnalyticsConfig.js +0 -1
  244. package/bundle/dist/codex-protocol/v2/AppBranding.js +0 -1
  245. package/bundle/dist/codex-protocol/v2/AppInfo.js +0 -1
  246. package/bundle/dist/codex-protocol/v2/AppListUpdatedNotification.js +0 -1
  247. package/bundle/dist/codex-protocol/v2/AppMetadata.js +0 -1
  248. package/bundle/dist/codex-protocol/v2/AppReview.js +0 -1
  249. package/bundle/dist/codex-protocol/v2/AppScreenshot.js +0 -1
  250. package/bundle/dist/codex-protocol/v2/AppSummary.js +0 -1
  251. package/bundle/dist/codex-protocol/v2/AppToolApproval.js +0 -1
  252. package/bundle/dist/codex-protocol/v2/AppToolsConfig.js +0 -1
  253. package/bundle/dist/codex-protocol/v2/ApprovalsReviewer.js +0 -1
  254. package/bundle/dist/codex-protocol/v2/AppsConfig.js +0 -1
  255. package/bundle/dist/codex-protocol/v2/AppsDefaultConfig.js +0 -1
  256. package/bundle/dist/codex-protocol/v2/AppsListParams.js +0 -1
  257. package/bundle/dist/codex-protocol/v2/AppsListResponse.js +0 -1
  258. package/bundle/dist/codex-protocol/v2/AskForApproval.js +0 -1
  259. package/bundle/dist/codex-protocol/v2/AutoReviewDecisionSource.js +0 -1
  260. package/bundle/dist/codex-protocol/v2/ByteRange.js +0 -1
  261. package/bundle/dist/codex-protocol/v2/CancelLoginAccountParams.js +0 -1
  262. package/bundle/dist/codex-protocol/v2/CancelLoginAccountResponse.js +0 -1
  263. package/bundle/dist/codex-protocol/v2/CancelLoginAccountStatus.js +0 -1
  264. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshParams.js +0 -1
  265. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshReason.js +0 -1
  266. package/bundle/dist/codex-protocol/v2/ChatgptAuthTokensRefreshResponse.js +0 -1
  267. package/bundle/dist/codex-protocol/v2/CodexErrorInfo.js +0 -1
  268. package/bundle/dist/codex-protocol/v2/CollabAgentState.js +0 -1
  269. package/bundle/dist/codex-protocol/v2/CollabAgentStatus.js +0 -1
  270. package/bundle/dist/codex-protocol/v2/CollabAgentTool.js +0 -1
  271. package/bundle/dist/codex-protocol/v2/CollabAgentToolCallStatus.js +0 -1
  272. package/bundle/dist/codex-protocol/v2/CollaborationModeMask.js +0 -1
  273. package/bundle/dist/codex-protocol/v2/CommandAction.js +0 -1
  274. package/bundle/dist/codex-protocol/v2/CommandExecOutputDeltaNotification.js +0 -1
  275. package/bundle/dist/codex-protocol/v2/CommandExecOutputStream.js +0 -1
  276. package/bundle/dist/codex-protocol/v2/CommandExecParams.js +0 -1
  277. package/bundle/dist/codex-protocol/v2/CommandExecResizeParams.js +0 -1
  278. package/bundle/dist/codex-protocol/v2/CommandExecResizeResponse.js +0 -1
  279. package/bundle/dist/codex-protocol/v2/CommandExecResponse.js +0 -1
  280. package/bundle/dist/codex-protocol/v2/CommandExecTerminalSize.js +0 -1
  281. package/bundle/dist/codex-protocol/v2/CommandExecTerminateParams.js +0 -1
  282. package/bundle/dist/codex-protocol/v2/CommandExecTerminateResponse.js +0 -1
  283. package/bundle/dist/codex-protocol/v2/CommandExecWriteParams.js +0 -1
  284. package/bundle/dist/codex-protocol/v2/CommandExecWriteResponse.js +0 -1
  285. package/bundle/dist/codex-protocol/v2/CommandExecutionApprovalDecision.js +0 -1
  286. package/bundle/dist/codex-protocol/v2/CommandExecutionOutputDeltaNotification.js +0 -1
  287. package/bundle/dist/codex-protocol/v2/CommandExecutionRequestApprovalParams.js +0 -1
  288. package/bundle/dist/codex-protocol/v2/CommandExecutionRequestApprovalResponse.js +0 -1
  289. package/bundle/dist/codex-protocol/v2/CommandExecutionSource.js +0 -1
  290. package/bundle/dist/codex-protocol/v2/CommandExecutionStatus.js +0 -1
  291. package/bundle/dist/codex-protocol/v2/CommandMigration.js +0 -1
  292. package/bundle/dist/codex-protocol/v2/Config.js +0 -1
  293. package/bundle/dist/codex-protocol/v2/ConfigBatchWriteParams.js +0 -1
  294. package/bundle/dist/codex-protocol/v2/ConfigEdit.js +0 -1
  295. package/bundle/dist/codex-protocol/v2/ConfigLayer.js +0 -1
  296. package/bundle/dist/codex-protocol/v2/ConfigLayerMetadata.js +0 -1
  297. package/bundle/dist/codex-protocol/v2/ConfigLayerSource.js +0 -1
  298. package/bundle/dist/codex-protocol/v2/ConfigReadParams.js +0 -1
  299. package/bundle/dist/codex-protocol/v2/ConfigReadResponse.js +0 -1
  300. package/bundle/dist/codex-protocol/v2/ConfigRequirements.js +0 -1
  301. package/bundle/dist/codex-protocol/v2/ConfigRequirementsReadResponse.js +0 -1
  302. package/bundle/dist/codex-protocol/v2/ConfigValueWriteParams.js +0 -1
  303. package/bundle/dist/codex-protocol/v2/ConfigWarningNotification.js +0 -1
  304. package/bundle/dist/codex-protocol/v2/ConfigWriteResponse.js +0 -1
  305. package/bundle/dist/codex-protocol/v2/ConfiguredHookHandler.js +0 -1
  306. package/bundle/dist/codex-protocol/v2/ConfiguredHookMatcherGroup.js +0 -1
  307. package/bundle/dist/codex-protocol/v2/ContextCompactedNotification.js +0 -1
  308. package/bundle/dist/codex-protocol/v2/CreditsSnapshot.js +0 -1
  309. package/bundle/dist/codex-protocol/v2/DeprecationNoticeNotification.js +0 -1
  310. package/bundle/dist/codex-protocol/v2/DynamicToolCallOutputContentItem.js +0 -1
  311. package/bundle/dist/codex-protocol/v2/DynamicToolCallParams.js +0 -1
  312. package/bundle/dist/codex-protocol/v2/DynamicToolCallResponse.js +0 -1
  313. package/bundle/dist/codex-protocol/v2/DynamicToolCallStatus.js +0 -1
  314. package/bundle/dist/codex-protocol/v2/DynamicToolSpec.js +0 -1
  315. package/bundle/dist/codex-protocol/v2/ErrorNotification.js +0 -1
  316. package/bundle/dist/codex-protocol/v2/ExecPolicyAmendment.js +0 -1
  317. package/bundle/dist/codex-protocol/v2/ExperimentalFeature.js +0 -1
  318. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureEnablementSetParams.js +0 -1
  319. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureEnablementSetResponse.js +0 -1
  320. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureListParams.js +0 -1
  321. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureListResponse.js +0 -1
  322. package/bundle/dist/codex-protocol/v2/ExperimentalFeatureStage.js +0 -1
  323. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigDetectParams.js +0 -1
  324. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigDetectResponse.js +0 -1
  325. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportCompletedNotification.js +0 -1
  326. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportParams.js +0 -1
  327. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigImportResponse.js +0 -1
  328. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigMigrationItem.js +0 -1
  329. package/bundle/dist/codex-protocol/v2/ExternalAgentConfigMigrationItemType.js +0 -1
  330. package/bundle/dist/codex-protocol/v2/FeedbackUploadParams.js +0 -1
  331. package/bundle/dist/codex-protocol/v2/FeedbackUploadResponse.js +0 -1
  332. package/bundle/dist/codex-protocol/v2/FileChangeApprovalDecision.js +0 -1
  333. package/bundle/dist/codex-protocol/v2/FileChangeOutputDeltaNotification.js +0 -1
  334. package/bundle/dist/codex-protocol/v2/FileChangePatchUpdatedNotification.js +0 -1
  335. package/bundle/dist/codex-protocol/v2/FileChangeRequestApprovalParams.js +0 -1
  336. package/bundle/dist/codex-protocol/v2/FileChangeRequestApprovalResponse.js +0 -1
  337. package/bundle/dist/codex-protocol/v2/FileSystemAccessMode.js +0 -1
  338. package/bundle/dist/codex-protocol/v2/FileSystemPath.js +0 -1
  339. package/bundle/dist/codex-protocol/v2/FileSystemSandboxEntry.js +0 -1
  340. package/bundle/dist/codex-protocol/v2/FileSystemSpecialPath.js +0 -1
  341. package/bundle/dist/codex-protocol/v2/FileUpdateChange.js +0 -1
  342. package/bundle/dist/codex-protocol/v2/FsChangedNotification.js +0 -1
  343. package/bundle/dist/codex-protocol/v2/FsCopyParams.js +0 -1
  344. package/bundle/dist/codex-protocol/v2/FsCopyResponse.js +0 -1
  345. package/bundle/dist/codex-protocol/v2/FsCreateDirectoryParams.js +0 -1
  346. package/bundle/dist/codex-protocol/v2/FsCreateDirectoryResponse.js +0 -1
  347. package/bundle/dist/codex-protocol/v2/FsGetMetadataParams.js +0 -1
  348. package/bundle/dist/codex-protocol/v2/FsGetMetadataResponse.js +0 -1
  349. package/bundle/dist/codex-protocol/v2/FsReadDirectoryEntry.js +0 -1
  350. package/bundle/dist/codex-protocol/v2/FsReadDirectoryParams.js +0 -1
  351. package/bundle/dist/codex-protocol/v2/FsReadDirectoryResponse.js +0 -1
  352. package/bundle/dist/codex-protocol/v2/FsReadFileParams.js +0 -1
  353. package/bundle/dist/codex-protocol/v2/FsReadFileResponse.js +0 -1
  354. package/bundle/dist/codex-protocol/v2/FsRemoveParams.js +0 -1
  355. package/bundle/dist/codex-protocol/v2/FsRemoveResponse.js +0 -1
  356. package/bundle/dist/codex-protocol/v2/FsUnwatchParams.js +0 -1
  357. package/bundle/dist/codex-protocol/v2/FsUnwatchResponse.js +0 -1
  358. package/bundle/dist/codex-protocol/v2/FsWatchParams.js +0 -1
  359. package/bundle/dist/codex-protocol/v2/FsWatchResponse.js +0 -1
  360. package/bundle/dist/codex-protocol/v2/FsWriteFileParams.js +0 -1
  361. package/bundle/dist/codex-protocol/v2/FsWriteFileResponse.js +0 -1
  362. package/bundle/dist/codex-protocol/v2/GetAccountParams.js +0 -1
  363. package/bundle/dist/codex-protocol/v2/GetAccountRateLimitsResponse.js +0 -1
  364. package/bundle/dist/codex-protocol/v2/GetAccountResponse.js +0 -1
  365. package/bundle/dist/codex-protocol/v2/GitInfo.js +0 -1
  366. package/bundle/dist/codex-protocol/v2/GrantedPermissionProfile.js +0 -1
  367. package/bundle/dist/codex-protocol/v2/GuardianApprovalReview.js +0 -1
  368. package/bundle/dist/codex-protocol/v2/GuardianApprovalReviewAction.js +0 -1
  369. package/bundle/dist/codex-protocol/v2/GuardianApprovalReviewStatus.js +0 -1
  370. package/bundle/dist/codex-protocol/v2/GuardianCommandSource.js +0 -1
  371. package/bundle/dist/codex-protocol/v2/GuardianRiskLevel.js +0 -1
  372. package/bundle/dist/codex-protocol/v2/GuardianUserAuthorization.js +0 -1
  373. package/bundle/dist/codex-protocol/v2/GuardianWarningNotification.js +0 -1
  374. package/bundle/dist/codex-protocol/v2/HookCompletedNotification.js +0 -1
  375. package/bundle/dist/codex-protocol/v2/HookErrorInfo.js +0 -1
  376. package/bundle/dist/codex-protocol/v2/HookEventName.js +0 -1
  377. package/bundle/dist/codex-protocol/v2/HookExecutionMode.js +0 -1
  378. package/bundle/dist/codex-protocol/v2/HookHandlerType.js +0 -1
  379. package/bundle/dist/codex-protocol/v2/HookMetadata.js +0 -1
  380. package/bundle/dist/codex-protocol/v2/HookMigration.js +0 -1
  381. package/bundle/dist/codex-protocol/v2/HookOutputEntry.js +0 -1
  382. package/bundle/dist/codex-protocol/v2/HookOutputEntryKind.js +0 -1
  383. package/bundle/dist/codex-protocol/v2/HookPromptFragment.js +0 -1
  384. package/bundle/dist/codex-protocol/v2/HookRunStatus.js +0 -1
  385. package/bundle/dist/codex-protocol/v2/HookRunSummary.js +0 -1
  386. package/bundle/dist/codex-protocol/v2/HookScope.js +0 -1
  387. package/bundle/dist/codex-protocol/v2/HookSource.js +0 -1
  388. package/bundle/dist/codex-protocol/v2/HookStartedNotification.js +0 -1
  389. package/bundle/dist/codex-protocol/v2/HookTrustStatus.js +0 -1
  390. package/bundle/dist/codex-protocol/v2/HooksListEntry.js +0 -1
  391. package/bundle/dist/codex-protocol/v2/HooksListParams.js +0 -1
  392. package/bundle/dist/codex-protocol/v2/HooksListResponse.js +0 -1
  393. package/bundle/dist/codex-protocol/v2/ItemCompletedNotification.js +0 -1
  394. package/bundle/dist/codex-protocol/v2/ItemGuardianApprovalReviewCompletedNotification.js +0 -1
  395. package/bundle/dist/codex-protocol/v2/ItemGuardianApprovalReviewStartedNotification.js +0 -1
  396. package/bundle/dist/codex-protocol/v2/ItemStartedNotification.js +0 -1
  397. package/bundle/dist/codex-protocol/v2/ListMcpServerStatusParams.js +0 -1
  398. package/bundle/dist/codex-protocol/v2/ListMcpServerStatusResponse.js +0 -1
  399. package/bundle/dist/codex-protocol/v2/LoginAccountParams.js +0 -1
  400. package/bundle/dist/codex-protocol/v2/LoginAccountResponse.js +0 -1
  401. package/bundle/dist/codex-protocol/v2/LogoutAccountResponse.js +0 -1
  402. package/bundle/dist/codex-protocol/v2/ManagedHooksRequirements.js +0 -1
  403. package/bundle/dist/codex-protocol/v2/MarketplaceAddParams.js +0 -1
  404. package/bundle/dist/codex-protocol/v2/MarketplaceAddResponse.js +0 -1
  405. package/bundle/dist/codex-protocol/v2/MarketplaceInterface.js +0 -1
  406. package/bundle/dist/codex-protocol/v2/MarketplaceLoadErrorInfo.js +0 -1
  407. package/bundle/dist/codex-protocol/v2/MarketplaceRemoveParams.js +0 -1
  408. package/bundle/dist/codex-protocol/v2/MarketplaceRemoveResponse.js +0 -1
  409. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeErrorInfo.js +0 -1
  410. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeParams.js +0 -1
  411. package/bundle/dist/codex-protocol/v2/MarketplaceUpgradeResponse.js +0 -1
  412. package/bundle/dist/codex-protocol/v2/McpAuthStatus.js +0 -1
  413. package/bundle/dist/codex-protocol/v2/McpElicitationArrayType.js +0 -1
  414. package/bundle/dist/codex-protocol/v2/McpElicitationBooleanSchema.js +0 -1
  415. package/bundle/dist/codex-protocol/v2/McpElicitationBooleanType.js +0 -1
  416. package/bundle/dist/codex-protocol/v2/McpElicitationConstOption.js +0 -1
  417. package/bundle/dist/codex-protocol/v2/McpElicitationEnumSchema.js +0 -1
  418. package/bundle/dist/codex-protocol/v2/McpElicitationLegacyTitledEnumSchema.js +0 -1
  419. package/bundle/dist/codex-protocol/v2/McpElicitationMultiSelectEnumSchema.js +0 -1
  420. package/bundle/dist/codex-protocol/v2/McpElicitationNumberSchema.js +0 -1
  421. package/bundle/dist/codex-protocol/v2/McpElicitationNumberType.js +0 -1
  422. package/bundle/dist/codex-protocol/v2/McpElicitationObjectType.js +0 -1
  423. package/bundle/dist/codex-protocol/v2/McpElicitationPrimitiveSchema.js +0 -1
  424. package/bundle/dist/codex-protocol/v2/McpElicitationSchema.js +0 -1
  425. package/bundle/dist/codex-protocol/v2/McpElicitationSingleSelectEnumSchema.js +0 -1
  426. package/bundle/dist/codex-protocol/v2/McpElicitationStringFormat.js +0 -1
  427. package/bundle/dist/codex-protocol/v2/McpElicitationStringSchema.js +0 -1
  428. package/bundle/dist/codex-protocol/v2/McpElicitationStringType.js +0 -1
  429. package/bundle/dist/codex-protocol/v2/McpElicitationTitledEnumItems.js +0 -1
  430. package/bundle/dist/codex-protocol/v2/McpElicitationTitledMultiSelectEnumSchema.js +0 -1
  431. package/bundle/dist/codex-protocol/v2/McpElicitationTitledSingleSelectEnumSchema.js +0 -1
  432. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledEnumItems.js +0 -1
  433. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledMultiSelectEnumSchema.js +0 -1
  434. package/bundle/dist/codex-protocol/v2/McpElicitationUntitledSingleSelectEnumSchema.js +0 -1
  435. package/bundle/dist/codex-protocol/v2/McpResourceReadParams.js +0 -1
  436. package/bundle/dist/codex-protocol/v2/McpResourceReadResponse.js +0 -1
  437. package/bundle/dist/codex-protocol/v2/McpServerElicitationAction.js +0 -1
  438. package/bundle/dist/codex-protocol/v2/McpServerElicitationRequestParams.js +0 -1
  439. package/bundle/dist/codex-protocol/v2/McpServerElicitationRequestResponse.js +0 -1
  440. package/bundle/dist/codex-protocol/v2/McpServerMigration.js +0 -1
  441. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginCompletedNotification.js +0 -1
  442. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginParams.js +0 -1
  443. package/bundle/dist/codex-protocol/v2/McpServerOauthLoginResponse.js +0 -1
  444. package/bundle/dist/codex-protocol/v2/McpServerRefreshResponse.js +0 -1
  445. package/bundle/dist/codex-protocol/v2/McpServerStartupState.js +0 -1
  446. package/bundle/dist/codex-protocol/v2/McpServerStatus.js +0 -1
  447. package/bundle/dist/codex-protocol/v2/McpServerStatusDetail.js +0 -1
  448. package/bundle/dist/codex-protocol/v2/McpServerStatusUpdatedNotification.js +0 -1
  449. package/bundle/dist/codex-protocol/v2/McpServerToolCallParams.js +0 -1
  450. package/bundle/dist/codex-protocol/v2/McpServerToolCallResponse.js +0 -1
  451. package/bundle/dist/codex-protocol/v2/McpToolCallError.js +0 -1
  452. package/bundle/dist/codex-protocol/v2/McpToolCallProgressNotification.js +0 -1
  453. package/bundle/dist/codex-protocol/v2/McpToolCallResult.js +0 -1
  454. package/bundle/dist/codex-protocol/v2/McpToolCallStatus.js +0 -1
  455. package/bundle/dist/codex-protocol/v2/MemoryCitation.js +0 -1
  456. package/bundle/dist/codex-protocol/v2/MemoryCitationEntry.js +0 -1
  457. package/bundle/dist/codex-protocol/v2/MergeStrategy.js +0 -1
  458. package/bundle/dist/codex-protocol/v2/MigrationDetails.js +0 -1
  459. package/bundle/dist/codex-protocol/v2/Model.js +0 -1
  460. package/bundle/dist/codex-protocol/v2/ModelAvailabilityNux.js +0 -1
  461. package/bundle/dist/codex-protocol/v2/ModelListParams.js +0 -1
  462. package/bundle/dist/codex-protocol/v2/ModelListResponse.js +0 -1
  463. package/bundle/dist/codex-protocol/v2/ModelProviderCapabilitiesReadParams.js +0 -1
  464. package/bundle/dist/codex-protocol/v2/ModelProviderCapabilitiesReadResponse.js +0 -1
  465. package/bundle/dist/codex-protocol/v2/ModelRerouteReason.js +0 -1
  466. package/bundle/dist/codex-protocol/v2/ModelReroutedNotification.js +0 -1
  467. package/bundle/dist/codex-protocol/v2/ModelServiceTier.js +0 -1
  468. package/bundle/dist/codex-protocol/v2/ModelUpgradeInfo.js +0 -1
  469. package/bundle/dist/codex-protocol/v2/ModelVerification.js +0 -1
  470. package/bundle/dist/codex-protocol/v2/ModelVerificationNotification.js +0 -1
  471. package/bundle/dist/codex-protocol/v2/NetworkAccess.js +0 -1
  472. package/bundle/dist/codex-protocol/v2/NetworkApprovalContext.js +0 -1
  473. package/bundle/dist/codex-protocol/v2/NetworkApprovalProtocol.js +0 -1
  474. package/bundle/dist/codex-protocol/v2/NetworkDomainPermission.js +0 -1
  475. package/bundle/dist/codex-protocol/v2/NetworkPolicyAmendment.js +0 -1
  476. package/bundle/dist/codex-protocol/v2/NetworkPolicyRuleAction.js +0 -1
  477. package/bundle/dist/codex-protocol/v2/NetworkRequirements.js +0 -1
  478. package/bundle/dist/codex-protocol/v2/NetworkUnixSocketPermission.js +0 -1
  479. package/bundle/dist/codex-protocol/v2/NonSteerableTurnKind.js +0 -1
  480. package/bundle/dist/codex-protocol/v2/OverriddenMetadata.js +0 -1
  481. package/bundle/dist/codex-protocol/v2/PatchApplyStatus.js +0 -1
  482. package/bundle/dist/codex-protocol/v2/PatchChangeKind.js +0 -1
  483. package/bundle/dist/codex-protocol/v2/PermissionGrantScope.js +0 -1
  484. package/bundle/dist/codex-protocol/v2/PermissionProfile.js +0 -1
  485. package/bundle/dist/codex-protocol/v2/PermissionProfileFileSystemPermissions.js +0 -1
  486. package/bundle/dist/codex-protocol/v2/PermissionProfileModificationParams.js +0 -1
  487. package/bundle/dist/codex-protocol/v2/PermissionProfileNetworkPermissions.js +0 -1
  488. package/bundle/dist/codex-protocol/v2/PermissionProfileSelectionParams.js +0 -1
  489. package/bundle/dist/codex-protocol/v2/PermissionsRequestApprovalParams.js +0 -1
  490. package/bundle/dist/codex-protocol/v2/PermissionsRequestApprovalResponse.js +0 -1
  491. package/bundle/dist/codex-protocol/v2/PlanDeltaNotification.js +0 -1
  492. package/bundle/dist/codex-protocol/v2/PluginAuthPolicy.js +0 -1
  493. package/bundle/dist/codex-protocol/v2/PluginAvailability.js +0 -1
  494. package/bundle/dist/codex-protocol/v2/PluginDetail.js +0 -1
  495. package/bundle/dist/codex-protocol/v2/PluginHookSummary.js +0 -1
  496. package/bundle/dist/codex-protocol/v2/PluginInstallParams.js +0 -1
  497. package/bundle/dist/codex-protocol/v2/PluginInstallPolicy.js +0 -1
  498. package/bundle/dist/codex-protocol/v2/PluginInstallResponse.js +0 -1
  499. package/bundle/dist/codex-protocol/v2/PluginInterface.js +0 -1
  500. package/bundle/dist/codex-protocol/v2/PluginListMarketplaceKind.js +0 -1
  501. package/bundle/dist/codex-protocol/v2/PluginListParams.js +0 -1
  502. package/bundle/dist/codex-protocol/v2/PluginListResponse.js +0 -1
  503. package/bundle/dist/codex-protocol/v2/PluginMarketplaceEntry.js +0 -1
  504. package/bundle/dist/codex-protocol/v2/PluginReadParams.js +0 -1
  505. package/bundle/dist/codex-protocol/v2/PluginReadResponse.js +0 -1
  506. package/bundle/dist/codex-protocol/v2/PluginShareContext.js +0 -1
  507. package/bundle/dist/codex-protocol/v2/PluginShareDeleteParams.js +0 -1
  508. package/bundle/dist/codex-protocol/v2/PluginShareDeleteResponse.js +0 -1
  509. package/bundle/dist/codex-protocol/v2/PluginShareDiscoverability.js +0 -1
  510. package/bundle/dist/codex-protocol/v2/PluginShareListItem.js +0 -1
  511. package/bundle/dist/codex-protocol/v2/PluginShareListParams.js +0 -1
  512. package/bundle/dist/codex-protocol/v2/PluginShareListResponse.js +0 -1
  513. package/bundle/dist/codex-protocol/v2/PluginSharePrincipal.js +0 -1
  514. package/bundle/dist/codex-protocol/v2/PluginSharePrincipalType.js +0 -1
  515. package/bundle/dist/codex-protocol/v2/PluginShareSaveParams.js +0 -1
  516. package/bundle/dist/codex-protocol/v2/PluginShareSaveResponse.js +0 -1
  517. package/bundle/dist/codex-protocol/v2/PluginShareTarget.js +0 -1
  518. package/bundle/dist/codex-protocol/v2/PluginShareUpdateDiscoverability.js +0 -1
  519. package/bundle/dist/codex-protocol/v2/PluginShareUpdateTargetsParams.js +0 -1
  520. package/bundle/dist/codex-protocol/v2/PluginShareUpdateTargetsResponse.js +0 -1
  521. package/bundle/dist/codex-protocol/v2/PluginSkillReadParams.js +0 -1
  522. package/bundle/dist/codex-protocol/v2/PluginSkillReadResponse.js +0 -1
  523. package/bundle/dist/codex-protocol/v2/PluginSource.js +0 -1
  524. package/bundle/dist/codex-protocol/v2/PluginSummary.js +0 -1
  525. package/bundle/dist/codex-protocol/v2/PluginUninstallParams.js +0 -1
  526. package/bundle/dist/codex-protocol/v2/PluginUninstallResponse.js +0 -1
  527. package/bundle/dist/codex-protocol/v2/PluginsMigration.js +0 -1
  528. package/bundle/dist/codex-protocol/v2/ProcessExitedNotification.js +0 -1
  529. package/bundle/dist/codex-protocol/v2/ProcessOutputDeltaNotification.js +0 -1
  530. package/bundle/dist/codex-protocol/v2/ProcessOutputStream.js +0 -1
  531. package/bundle/dist/codex-protocol/v2/ProcessTerminalSize.js +0 -1
  532. package/bundle/dist/codex-protocol/v2/ProfileV2.js +0 -1
  533. package/bundle/dist/codex-protocol/v2/RateLimitReachedType.js +0 -1
  534. package/bundle/dist/codex-protocol/v2/RateLimitSnapshot.js +0 -1
  535. package/bundle/dist/codex-protocol/v2/RateLimitWindow.js +0 -1
  536. package/bundle/dist/codex-protocol/v2/RawResponseItemCompletedNotification.js +0 -1
  537. package/bundle/dist/codex-protocol/v2/ReasoningEffortOption.js +0 -1
  538. package/bundle/dist/codex-protocol/v2/ReasoningSummaryPartAddedNotification.js +0 -1
  539. package/bundle/dist/codex-protocol/v2/ReasoningSummaryTextDeltaNotification.js +0 -1
  540. package/bundle/dist/codex-protocol/v2/ReasoningTextDeltaNotification.js +0 -1
  541. package/bundle/dist/codex-protocol/v2/RemoteControlConnectionStatus.js +0 -1
  542. package/bundle/dist/codex-protocol/v2/RemoteControlStatusChangedNotification.js +0 -1
  543. package/bundle/dist/codex-protocol/v2/RequestPermissionProfile.js +0 -1
  544. package/bundle/dist/codex-protocol/v2/ResidencyRequirement.js +0 -1
  545. package/bundle/dist/codex-protocol/v2/ReviewDelivery.js +0 -1
  546. package/bundle/dist/codex-protocol/v2/ReviewStartParams.js +0 -1
  547. package/bundle/dist/codex-protocol/v2/ReviewStartResponse.js +0 -1
  548. package/bundle/dist/codex-protocol/v2/ReviewTarget.js +0 -1
  549. package/bundle/dist/codex-protocol/v2/SandboxMode.js +0 -1
  550. package/bundle/dist/codex-protocol/v2/SandboxPolicy.js +0 -1
  551. package/bundle/dist/codex-protocol/v2/SandboxWorkspaceWrite.js +0 -1
  552. package/bundle/dist/codex-protocol/v2/SendAddCreditsNudgeEmailParams.js +0 -1
  553. package/bundle/dist/codex-protocol/v2/SendAddCreditsNudgeEmailResponse.js +0 -1
  554. package/bundle/dist/codex-protocol/v2/ServerRequestResolvedNotification.js +0 -1
  555. package/bundle/dist/codex-protocol/v2/SessionMigration.js +0 -1
  556. package/bundle/dist/codex-protocol/v2/SessionSource.js +0 -1
  557. package/bundle/dist/codex-protocol/v2/SkillDependencies.js +0 -1
  558. package/bundle/dist/codex-protocol/v2/SkillErrorInfo.js +0 -1
  559. package/bundle/dist/codex-protocol/v2/SkillInterface.js +0 -1
  560. package/bundle/dist/codex-protocol/v2/SkillMetadata.js +0 -1
  561. package/bundle/dist/codex-protocol/v2/SkillScope.js +0 -1
  562. package/bundle/dist/codex-protocol/v2/SkillSummary.js +0 -1
  563. package/bundle/dist/codex-protocol/v2/SkillToolDependency.js +0 -1
  564. package/bundle/dist/codex-protocol/v2/SkillsChangedNotification.js +0 -1
  565. package/bundle/dist/codex-protocol/v2/SkillsConfigWriteParams.js +0 -1
  566. package/bundle/dist/codex-protocol/v2/SkillsConfigWriteResponse.js +0 -1
  567. package/bundle/dist/codex-protocol/v2/SkillsListEntry.js +0 -1
  568. package/bundle/dist/codex-protocol/v2/SkillsListParams.js +0 -1
  569. package/bundle/dist/codex-protocol/v2/SkillsListResponse.js +0 -1
  570. package/bundle/dist/codex-protocol/v2/SortDirection.js +0 -1
  571. package/bundle/dist/codex-protocol/v2/SubagentMigration.js +0 -1
  572. package/bundle/dist/codex-protocol/v2/TerminalInteractionNotification.js +0 -1
  573. package/bundle/dist/codex-protocol/v2/TextElement.js +0 -1
  574. package/bundle/dist/codex-protocol/v2/TextPosition.js +0 -1
  575. package/bundle/dist/codex-protocol/v2/TextRange.js +0 -1
  576. package/bundle/dist/codex-protocol/v2/Thread.js +0 -1
  577. package/bundle/dist/codex-protocol/v2/ThreadActiveFlag.js +0 -1
  578. package/bundle/dist/codex-protocol/v2/ThreadApproveGuardianDeniedActionParams.js +0 -1
  579. package/bundle/dist/codex-protocol/v2/ThreadApproveGuardianDeniedActionResponse.js +0 -1
  580. package/bundle/dist/codex-protocol/v2/ThreadArchiveParams.js +0 -1
  581. package/bundle/dist/codex-protocol/v2/ThreadArchiveResponse.js +0 -1
  582. package/bundle/dist/codex-protocol/v2/ThreadArchivedNotification.js +0 -1
  583. package/bundle/dist/codex-protocol/v2/ThreadClosedNotification.js +0 -1
  584. package/bundle/dist/codex-protocol/v2/ThreadCompactStartParams.js +0 -1
  585. package/bundle/dist/codex-protocol/v2/ThreadCompactStartResponse.js +0 -1
  586. package/bundle/dist/codex-protocol/v2/ThreadForkParams.js +0 -1
  587. package/bundle/dist/codex-protocol/v2/ThreadForkResponse.js +0 -1
  588. package/bundle/dist/codex-protocol/v2/ThreadGoal.js +0 -1
  589. package/bundle/dist/codex-protocol/v2/ThreadGoalClearedNotification.js +0 -1
  590. package/bundle/dist/codex-protocol/v2/ThreadGoalStatus.js +0 -1
  591. package/bundle/dist/codex-protocol/v2/ThreadGoalUpdatedNotification.js +0 -1
  592. package/bundle/dist/codex-protocol/v2/ThreadInjectItemsParams.js +0 -1
  593. package/bundle/dist/codex-protocol/v2/ThreadInjectItemsResponse.js +0 -1
  594. package/bundle/dist/codex-protocol/v2/ThreadItem.js +0 -1
  595. package/bundle/dist/codex-protocol/v2/ThreadListParams.js +0 -1
  596. package/bundle/dist/codex-protocol/v2/ThreadListResponse.js +0 -1
  597. package/bundle/dist/codex-protocol/v2/ThreadLoadedListParams.js +0 -1
  598. package/bundle/dist/codex-protocol/v2/ThreadLoadedListResponse.js +0 -1
  599. package/bundle/dist/codex-protocol/v2/ThreadMetadataGitInfoUpdateParams.js +0 -1
  600. package/bundle/dist/codex-protocol/v2/ThreadMetadataUpdateParams.js +0 -1
  601. package/bundle/dist/codex-protocol/v2/ThreadMetadataUpdateResponse.js +0 -1
  602. package/bundle/dist/codex-protocol/v2/ThreadNameUpdatedNotification.js +0 -1
  603. package/bundle/dist/codex-protocol/v2/ThreadReadParams.js +0 -1
  604. package/bundle/dist/codex-protocol/v2/ThreadReadResponse.js +0 -1
  605. package/bundle/dist/codex-protocol/v2/ThreadRealtimeAudioChunk.js +0 -1
  606. package/bundle/dist/codex-protocol/v2/ThreadRealtimeClosedNotification.js +0 -1
  607. package/bundle/dist/codex-protocol/v2/ThreadRealtimeErrorNotification.js +0 -1
  608. package/bundle/dist/codex-protocol/v2/ThreadRealtimeItemAddedNotification.js +0 -1
  609. package/bundle/dist/codex-protocol/v2/ThreadRealtimeOutputAudioDeltaNotification.js +0 -1
  610. package/bundle/dist/codex-protocol/v2/ThreadRealtimeSdpNotification.js +0 -1
  611. package/bundle/dist/codex-protocol/v2/ThreadRealtimeStartTransport.js +0 -1
  612. package/bundle/dist/codex-protocol/v2/ThreadRealtimeStartedNotification.js +0 -1
  613. package/bundle/dist/codex-protocol/v2/ThreadRealtimeTranscriptDeltaNotification.js +0 -1
  614. package/bundle/dist/codex-protocol/v2/ThreadRealtimeTranscriptDoneNotification.js +0 -1
  615. package/bundle/dist/codex-protocol/v2/ThreadResumeParams.js +0 -1
  616. package/bundle/dist/codex-protocol/v2/ThreadResumeResponse.js +0 -1
  617. package/bundle/dist/codex-protocol/v2/ThreadRollbackParams.js +0 -1
  618. package/bundle/dist/codex-protocol/v2/ThreadRollbackResponse.js +0 -1
  619. package/bundle/dist/codex-protocol/v2/ThreadSetNameParams.js +0 -1
  620. package/bundle/dist/codex-protocol/v2/ThreadSetNameResponse.js +0 -1
  621. package/bundle/dist/codex-protocol/v2/ThreadShellCommandParams.js +0 -1
  622. package/bundle/dist/codex-protocol/v2/ThreadShellCommandResponse.js +0 -1
  623. package/bundle/dist/codex-protocol/v2/ThreadSortKey.js +0 -1
  624. package/bundle/dist/codex-protocol/v2/ThreadSource.js +0 -1
  625. package/bundle/dist/codex-protocol/v2/ThreadSourceKind.js +0 -1
  626. package/bundle/dist/codex-protocol/v2/ThreadStartParams.js +0 -1
  627. package/bundle/dist/codex-protocol/v2/ThreadStartResponse.js +0 -1
  628. package/bundle/dist/codex-protocol/v2/ThreadStartSource.js +0 -1
  629. package/bundle/dist/codex-protocol/v2/ThreadStartedNotification.js +0 -1
  630. package/bundle/dist/codex-protocol/v2/ThreadStatus.js +0 -1
  631. package/bundle/dist/codex-protocol/v2/ThreadStatusChangedNotification.js +0 -1
  632. package/bundle/dist/codex-protocol/v2/ThreadTokenUsage.js +0 -1
  633. package/bundle/dist/codex-protocol/v2/ThreadTokenUsageUpdatedNotification.js +0 -1
  634. package/bundle/dist/codex-protocol/v2/ThreadUnarchiveParams.js +0 -1
  635. package/bundle/dist/codex-protocol/v2/ThreadUnarchiveResponse.js +0 -1
  636. package/bundle/dist/codex-protocol/v2/ThreadUnarchivedNotification.js +0 -1
  637. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeParams.js +0 -1
  638. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeResponse.js +0 -1
  639. package/bundle/dist/codex-protocol/v2/ThreadUnsubscribeStatus.js +0 -1
  640. package/bundle/dist/codex-protocol/v2/TokenUsageBreakdown.js +0 -1
  641. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputAnswer.js +0 -1
  642. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputOption.js +0 -1
  643. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputParams.js +0 -1
  644. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputQuestion.js +0 -1
  645. package/bundle/dist/codex-protocol/v2/ToolRequestUserInputResponse.js +0 -1
  646. package/bundle/dist/codex-protocol/v2/ToolsV2.js +0 -1
  647. package/bundle/dist/codex-protocol/v2/Turn.js +0 -1
  648. package/bundle/dist/codex-protocol/v2/TurnCompletedNotification.js +0 -1
  649. package/bundle/dist/codex-protocol/v2/TurnDiffUpdatedNotification.js +0 -1
  650. package/bundle/dist/codex-protocol/v2/TurnEnvironmentParams.js +0 -1
  651. package/bundle/dist/codex-protocol/v2/TurnError.js +0 -1
  652. package/bundle/dist/codex-protocol/v2/TurnInterruptParams.js +0 -1
  653. package/bundle/dist/codex-protocol/v2/TurnInterruptResponse.js +0 -1
  654. package/bundle/dist/codex-protocol/v2/TurnItemsView.js +0 -1
  655. package/bundle/dist/codex-protocol/v2/TurnPlanStep.js +0 -1
  656. package/bundle/dist/codex-protocol/v2/TurnPlanStepStatus.js +0 -1
  657. package/bundle/dist/codex-protocol/v2/TurnPlanUpdatedNotification.js +0 -1
  658. package/bundle/dist/codex-protocol/v2/TurnStartParams.js +0 -1
  659. package/bundle/dist/codex-protocol/v2/TurnStartResponse.js +0 -1
  660. package/bundle/dist/codex-protocol/v2/TurnStartedNotification.js +0 -1
  661. package/bundle/dist/codex-protocol/v2/TurnStatus.js +0 -1
  662. package/bundle/dist/codex-protocol/v2/TurnSteerParams.js +0 -1
  663. package/bundle/dist/codex-protocol/v2/TurnSteerResponse.js +0 -1
  664. package/bundle/dist/codex-protocol/v2/UserInput.js +0 -1
  665. package/bundle/dist/codex-protocol/v2/WarningNotification.js +0 -1
  666. package/bundle/dist/codex-protocol/v2/WebSearchAction.js +0 -1
  667. package/bundle/dist/codex-protocol/v2/WindowsSandboxReadiness.js +0 -1
  668. package/bundle/dist/codex-protocol/v2/WindowsSandboxReadinessResponse.js +0 -1
  669. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupCompletedNotification.js +0 -1
  670. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupMode.js +0 -1
  671. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupStartParams.js +0 -1
  672. package/bundle/dist/codex-protocol/v2/WindowsSandboxSetupStartResponse.js +0 -1
  673. package/bundle/dist/codex-protocol/v2/WindowsWorldWritableWarningNotification.js +0 -1
  674. package/bundle/dist/codex-protocol/v2/WriteStatus.js +0 -1
  675. package/bundle/dist/codex-protocol/v2/index.js +0 -7
  676. package/bundle/dist/utils/providers/openai/codex-rpc.js +0 -153
  677. package/bundle/dist/utils/providers/openai/codex-worker.js +0 -642
  678. package/bundle/dist/utils/providers/openai/openai-worker-pool-config.js +0 -51
  679. package/bundle/src/codex-protocol/AbsolutePathBuf.ts +0 -14
  680. package/bundle/src/codex-protocol/AgentPath.ts +0 -5
  681. package/bundle/src/codex-protocol/ApplyPatchApprovalParams.ts +0 -24
  682. package/bundle/src/codex-protocol/ApplyPatchApprovalResponse.ts +0 -6
  683. package/bundle/src/codex-protocol/AuthMode.ts +0 -8
  684. package/bundle/src/codex-protocol/ClientInfo.ts +0 -5
  685. package/bundle/src/codex-protocol/ClientNotification.ts +0 -5
  686. package/bundle/src/codex-protocol/ClientRequest.ts +0 -176
  687. package/bundle/src/codex-protocol/CollaborationMode.ts +0 -10
  688. package/bundle/src/codex-protocol/ContentItem.ts +0 -9
  689. package/bundle/src/codex-protocol/ConversationGitInfo.ts +0 -9
  690. package/bundle/src/codex-protocol/ConversationSummary.ts +0 -19
  691. package/bundle/src/codex-protocol/ExecCommandApprovalParams.ts +0 -22
  692. package/bundle/src/codex-protocol/ExecCommandApprovalResponse.ts +0 -6
  693. package/bundle/src/codex-protocol/ExecPolicyAmendment.ts +0 -12
  694. package/bundle/src/codex-protocol/FileChange.ts +0 -8
  695. package/bundle/src/codex-protocol/ForcedLoginMethod.ts +0 -5
  696. package/bundle/src/codex-protocol/FunctionCallOutputBody.ts +0 -6
  697. package/bundle/src/codex-protocol/FunctionCallOutputContentItem.ts +0 -12
  698. package/bundle/src/codex-protocol/FuzzyFileSearchMatchType.ts +0 -5
  699. package/bundle/src/codex-protocol/FuzzyFileSearchParams.ts +0 -9
  700. package/bundle/src/codex-protocol/FuzzyFileSearchResponse.ts +0 -6
  701. package/bundle/src/codex-protocol/FuzzyFileSearchResult.ts +0 -16
  702. package/bundle/src/codex-protocol/FuzzyFileSearchSessionCompletedNotification.ts +0 -5
  703. package/bundle/src/codex-protocol/FuzzyFileSearchSessionUpdatedNotification.ts +0 -10
  704. package/bundle/src/codex-protocol/GetAuthStatusParams.ts +0 -5
  705. package/bundle/src/codex-protocol/GetAuthStatusResponse.ts +0 -10
  706. package/bundle/src/codex-protocol/GetConversationSummaryParams.ts +0 -6
  707. package/bundle/src/codex-protocol/GetConversationSummaryResponse.ts +0 -6
  708. package/bundle/src/codex-protocol/GitDiffToRemoteParams.ts +0 -5
  709. package/bundle/src/codex-protocol/GitDiffToRemoteResponse.ts +0 -6
  710. package/bundle/src/codex-protocol/GitSha.ts +0 -5
  711. package/bundle/src/codex-protocol/ImageDetail.ts +0 -5
  712. package/bundle/src/codex-protocol/InitializeCapabilities.ts +0 -18
  713. package/bundle/src/codex-protocol/InitializeParams.ts +0 -10
  714. package/bundle/src/codex-protocol/InitializeResponse.ts +0 -22
  715. package/bundle/src/codex-protocol/InputModality.ts +0 -8
  716. package/bundle/src/codex-protocol/InternalSessionSource.ts +0 -5
  717. package/bundle/src/codex-protocol/LocalShellAction.ts +0 -6
  718. package/bundle/src/codex-protocol/LocalShellExecAction.ts +0 -11
  719. package/bundle/src/codex-protocol/LocalShellStatus.ts +0 -5
  720. package/bundle/src/codex-protocol/MessagePhase.ts +0 -11
  721. package/bundle/src/codex-protocol/ModeKind.ts +0 -8
  722. package/bundle/src/codex-protocol/NetworkPolicyAmendment.ts +0 -6
  723. package/bundle/src/codex-protocol/NetworkPolicyRuleAction.ts +0 -5
  724. package/bundle/src/codex-protocol/ParsedCommand.ts +0 -20
  725. package/bundle/src/codex-protocol/Personality.ts +0 -5
  726. package/bundle/src/codex-protocol/PlanType.ts +0 -17
  727. package/bundle/src/codex-protocol/RealtimeConversationVersion.ts +0 -5
  728. package/bundle/src/codex-protocol/RealtimeOutputModality.ts +0 -5
  729. package/bundle/src/codex-protocol/RealtimeVoice.ts +0 -24
  730. package/bundle/src/codex-protocol/RealtimeVoicesList.ts +0 -11
  731. package/bundle/src/codex-protocol/ReasoningEffort.ts +0 -8
  732. package/bundle/src/codex-protocol/ReasoningItemContent.ts +0 -7
  733. package/bundle/src/codex-protocol/ReasoningItemReasoningSummary.ts +0 -5
  734. package/bundle/src/codex-protocol/ReasoningSummary.ts +0 -10
  735. package/bundle/src/codex-protocol/RequestId.ts +0 -5
  736. package/bundle/src/codex-protocol/Resource.ts +0 -19
  737. package/bundle/src/codex-protocol/ResourceContent.ts +0 -27
  738. package/bundle/src/codex-protocol/ResourceTemplate.ts +0 -16
  739. package/bundle/src/codex-protocol/ResponseItem.ts +0 -63
  740. package/bundle/src/codex-protocol/ReviewDecision.ts +0 -17
  741. package/bundle/src/codex-protocol/ServerNotification.ts +0 -154
  742. package/bundle/src/codex-protocol/ServerRequest.ts +0 -47
  743. package/bundle/src/codex-protocol/SessionSource.ts +0 -15
  744. package/bundle/src/codex-protocol/Settings.ts +0 -13
  745. package/bundle/src/codex-protocol/SubAgentSource.ts +0 -20
  746. package/bundle/src/codex-protocol/ThreadId.ts +0 -5
  747. package/bundle/src/codex-protocol/ThreadMemoryMode.ts +0 -5
  748. package/bundle/src/codex-protocol/Tool.ts +0 -18
  749. package/bundle/src/codex-protocol/Verbosity.ts +0 -9
  750. package/bundle/src/codex-protocol/WebSearchAction.ts +0 -9
  751. package/bundle/src/codex-protocol/WebSearchContextSize.ts +0 -5
  752. package/bundle/src/codex-protocol/WebSearchLocation.ts +0 -10
  753. package/bundle/src/codex-protocol/WebSearchMode.ts +0 -5
  754. package/bundle/src/codex-protocol/WebSearchToolConfig.ts +0 -11
  755. package/bundle/src/codex-protocol/index.ts +0 -79
  756. package/bundle/src/codex-protocol/serde_json/JsonValue.ts +0 -11
  757. package/bundle/src/codex-protocol/v2/Account.ts +0 -9
  758. package/bundle/src/codex-protocol/v2/AccountLoginCompletedNotification.ts +0 -9
  759. package/bundle/src/codex-protocol/v2/AccountRateLimitsUpdatedNotification.ts +0 -6
  760. package/bundle/src/codex-protocol/v2/AccountUpdatedNotification.ts +0 -7
  761. package/bundle/src/codex-protocol/v2/ActivePermissionProfile.ts +0 -22
  762. package/bundle/src/codex-protocol/v2/ActivePermissionProfileModification.ts +0 -9
  763. package/bundle/src/codex-protocol/v2/AddCreditsNudgeCreditType.ts +0 -5
  764. package/bundle/src/codex-protocol/v2/AddCreditsNudgeEmailStatus.ts +0 -5
  765. package/bundle/src/codex-protocol/v2/AdditionalFileSystemPermissions.ts +0 -18
  766. package/bundle/src/codex-protocol/v2/AdditionalNetworkPermissions.ts +0 -5
  767. package/bundle/src/codex-protocol/v2/AdditionalPermissionProfile.ts +0 -13
  768. package/bundle/src/codex-protocol/v2/AgentMessageDeltaNotification.ts +0 -10
  769. package/bundle/src/codex-protocol/v2/AnalyticsConfig.ts +0 -14
  770. package/bundle/src/codex-protocol/v2/AppBranding.ts +0 -15
  771. package/bundle/src/codex-protocol/v2/AppInfo.ts +0 -32
  772. package/bundle/src/codex-protocol/v2/AppListUpdatedNotification.ts +0 -9
  773. package/bundle/src/codex-protocol/v2/AppMetadata.ts +0 -20
  774. package/bundle/src/codex-protocol/v2/AppReview.ts +0 -5
  775. package/bundle/src/codex-protocol/v2/AppScreenshot.ts +0 -5
  776. package/bundle/src/codex-protocol/v2/AppSummary.ts +0 -14
  777. package/bundle/src/codex-protocol/v2/AppToolApproval.ts +0 -5
  778. package/bundle/src/codex-protocol/v2/AppToolsConfig.ts +0 -8
  779. package/bundle/src/codex-protocol/v2/ApprovalsReviewer.ts +0 -12
  780. package/bundle/src/codex-protocol/v2/AppsConfig.ts +0 -17
  781. package/bundle/src/codex-protocol/v2/AppsDefaultConfig.ts +0 -9
  782. package/bundle/src/codex-protocol/v2/AppsListParams.ts +0 -25
  783. package/bundle/src/codex-protocol/v2/AppsListResponse.ts +0 -16
  784. package/bundle/src/codex-protocol/v2/AskForApproval.ts +0 -18
  785. package/bundle/src/codex-protocol/v2/AutoReviewDecisionSource.ts +0 -8
  786. package/bundle/src/codex-protocol/v2/ByteRange.ts +0 -5
  787. package/bundle/src/codex-protocol/v2/CancelLoginAccountParams.ts +0 -5
  788. package/bundle/src/codex-protocol/v2/CancelLoginAccountResponse.ts +0 -6
  789. package/bundle/src/codex-protocol/v2/CancelLoginAccountStatus.ts +0 -5
  790. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshParams.ts +0 -18
  791. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshReason.ts +0 -5
  792. package/bundle/src/codex-protocol/v2/ChatgptAuthTokensRefreshResponse.ts +0 -9
  793. package/bundle/src/codex-protocol/v2/CodexErrorInfo.ts +0 -27
  794. package/bundle/src/codex-protocol/v2/CollabAgentState.ts +0 -6
  795. package/bundle/src/codex-protocol/v2/CollabAgentStatus.ts +0 -12
  796. package/bundle/src/codex-protocol/v2/CollabAgentTool.ts +0 -5
  797. package/bundle/src/codex-protocol/v2/CollabAgentToolCallStatus.ts +0 -5
  798. package/bundle/src/codex-protocol/v2/CollaborationModeMask.ts +0 -15
  799. package/bundle/src/codex-protocol/v2/CommandAction.ts +0 -10
  800. package/bundle/src/codex-protocol/v2/CommandExecOutputDeltaNotification.ts +0 -31
  801. package/bundle/src/codex-protocol/v2/CommandExecOutputStream.ts +0 -8
  802. package/bundle/src/codex-protocol/v2/CommandExecParams.ts +0 -87
  803. package/bundle/src/codex-protocol/v2/CommandExecResizeParams.ts +0 -19
  804. package/bundle/src/codex-protocol/v2/CommandExecResizeResponse.ts +0 -8
  805. package/bundle/src/codex-protocol/v2/CommandExecResponse.ts +0 -25
  806. package/bundle/src/codex-protocol/v2/CommandExecTerminalSize.ts +0 -17
  807. package/bundle/src/codex-protocol/v2/CommandExecTerminateParams.ts +0 -14
  808. package/bundle/src/codex-protocol/v2/CommandExecTerminateResponse.ts +0 -8
  809. package/bundle/src/codex-protocol/v2/CommandExecWriteParams.ts +0 -23
  810. package/bundle/src/codex-protocol/v2/CommandExecWriteResponse.ts +0 -8
  811. package/bundle/src/codex-protocol/v2/CommandExecutionApprovalDecision.ts +0 -13
  812. package/bundle/src/codex-protocol/v2/CommandExecutionOutputDeltaNotification.ts +0 -10
  813. package/bundle/src/codex-protocol/v2/CommandExecutionRequestApprovalParams.ts +0 -47
  814. package/bundle/src/codex-protocol/v2/CommandExecutionRequestApprovalResponse.ts +0 -8
  815. package/bundle/src/codex-protocol/v2/CommandExecutionSource.ts +0 -9
  816. package/bundle/src/codex-protocol/v2/CommandExecutionStatus.ts +0 -5
  817. package/bundle/src/codex-protocol/v2/CommandMigration.ts +0 -5
  818. package/bundle/src/codex-protocol/v2/Config.ts +0 -53
  819. package/bundle/src/codex-protocol/v2/ConfigBatchWriteParams.ts +0 -17
  820. package/bundle/src/codex-protocol/v2/ConfigEdit.ts +0 -7
  821. package/bundle/src/codex-protocol/v2/ConfigLayer.ts +0 -12
  822. package/bundle/src/codex-protocol/v2/ConfigLayerMetadata.ts +0 -6
  823. package/bundle/src/codex-protocol/v2/ConfigLayerSource.ts +0 -27
  824. package/bundle/src/codex-protocol/v2/ConfigReadParams.ts +0 -13
  825. package/bundle/src/codex-protocol/v2/ConfigReadResponse.ts +0 -12
  826. package/bundle/src/codex-protocol/v2/ConfigRequirements.ts +0 -15
  827. package/bundle/src/codex-protocol/v2/ConfigRequirementsReadResponse.ts +0 -11
  828. package/bundle/src/codex-protocol/v2/ConfigValueWriteParams.ts +0 -16
  829. package/bundle/src/codex-protocol/v2/ConfigWarningNotification.ts +0 -23
  830. package/bundle/src/codex-protocol/v2/ConfigWriteResponse.ts +0 -16
  831. package/bundle/src/codex-protocol/v2/ConfiguredHookHandler.ts +0 -14
  832. package/bundle/src/codex-protocol/v2/ConfiguredHookMatcherGroup.ts +0 -9
  833. package/bundle/src/codex-protocol/v2/ContextCompactedNotification.ts +0 -8
  834. package/bundle/src/codex-protocol/v2/CreditsSnapshot.ts +0 -5
  835. package/bundle/src/codex-protocol/v2/DeprecationNoticeNotification.ts +0 -14
  836. package/bundle/src/codex-protocol/v2/DynamicToolCallOutputContentItem.ts +0 -7
  837. package/bundle/src/codex-protocol/v2/DynamicToolCallParams.ts +0 -13
  838. package/bundle/src/codex-protocol/v2/DynamicToolCallResponse.ts +0 -9
  839. package/bundle/src/codex-protocol/v2/DynamicToolCallStatus.ts +0 -5
  840. package/bundle/src/codex-protocol/v2/DynamicToolSpec.ts +0 -12
  841. package/bundle/src/codex-protocol/v2/ErrorNotification.ts +0 -11
  842. package/bundle/src/codex-protocol/v2/ExecPolicyAmendment.ts +0 -5
  843. package/bundle/src/codex-protocol/v2/ExperimentalFeature.ts +0 -38
  844. package/bundle/src/codex-protocol/v2/ExperimentalFeatureEnablementSetParams.ts +0 -13
  845. package/bundle/src/codex-protocol/v2/ExperimentalFeatureEnablementSetResponse.ts +0 -10
  846. package/bundle/src/codex-protocol/v2/ExperimentalFeatureListParams.ts +0 -14
  847. package/bundle/src/codex-protocol/v2/ExperimentalFeatureListResponse.ts +0 -13
  848. package/bundle/src/codex-protocol/v2/ExperimentalFeatureStage.ts +0 -10
  849. package/bundle/src/codex-protocol/v2/ExternalAgentConfigDetectParams.ts +0 -14
  850. package/bundle/src/codex-protocol/v2/ExternalAgentConfigDetectResponse.ts +0 -6
  851. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportCompletedNotification.ts +0 -5
  852. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportParams.ts +0 -8
  853. package/bundle/src/codex-protocol/v2/ExternalAgentConfigImportResponse.ts +0 -5
  854. package/bundle/src/codex-protocol/v2/ExternalAgentConfigMigrationItem.ts +0 -15
  855. package/bundle/src/codex-protocol/v2/ExternalAgentConfigMigrationItemType.ts +0 -14
  856. package/bundle/src/codex-protocol/v2/FeedbackUploadParams.ts +0 -12
  857. package/bundle/src/codex-protocol/v2/FeedbackUploadResponse.ts +0 -5
  858. package/bundle/src/codex-protocol/v2/FileChangeApprovalDecision.ts +0 -5
  859. package/bundle/src/codex-protocol/v2/FileChangeOutputDeltaNotification.ts +0 -15
  860. package/bundle/src/codex-protocol/v2/FileChangePatchUpdatedNotification.ts +0 -11
  861. package/bundle/src/codex-protocol/v2/FileChangeRequestApprovalParams.ts +0 -22
  862. package/bundle/src/codex-protocol/v2/FileChangeRequestApprovalResponse.ts +0 -6
  863. package/bundle/src/codex-protocol/v2/FileSystemAccessMode.ts +0 -5
  864. package/bundle/src/codex-protocol/v2/FileSystemPath.ts +0 -10
  865. package/bundle/src/codex-protocol/v2/FileSystemSandboxEntry.ts +0 -7
  866. package/bundle/src/codex-protocol/v2/FileSystemSpecialPath.ts +0 -11
  867. package/bundle/src/codex-protocol/v2/FileUpdateChange.ts +0 -6
  868. package/bundle/src/codex-protocol/v2/FsChangedNotification.ts +0 -18
  869. package/bundle/src/codex-protocol/v2/FsCopyParams.ts +0 -22
  870. package/bundle/src/codex-protocol/v2/FsCopyResponse.ts +0 -8
  871. package/bundle/src/codex-protocol/v2/FsCreateDirectoryParams.ts +0 -18
  872. package/bundle/src/codex-protocol/v2/FsCreateDirectoryResponse.ts +0 -8
  873. package/bundle/src/codex-protocol/v2/FsGetMetadataParams.ts +0 -14
  874. package/bundle/src/codex-protocol/v2/FsGetMetadataResponse.ts +0 -29
  875. package/bundle/src/codex-protocol/v2/FsReadDirectoryEntry.ts +0 -21
  876. package/bundle/src/codex-protocol/v2/FsReadDirectoryParams.ts +0 -14
  877. package/bundle/src/codex-protocol/v2/FsReadDirectoryResponse.ts +0 -14
  878. package/bundle/src/codex-protocol/v2/FsReadFileParams.ts +0 -14
  879. package/bundle/src/codex-protocol/v2/FsReadFileResponse.ts +0 -13
  880. package/bundle/src/codex-protocol/v2/FsRemoveParams.ts +0 -22
  881. package/bundle/src/codex-protocol/v2/FsRemoveResponse.ts +0 -8
  882. package/bundle/src/codex-protocol/v2/FsUnwatchParams.ts +0 -13
  883. package/bundle/src/codex-protocol/v2/FsUnwatchResponse.ts +0 -8
  884. package/bundle/src/codex-protocol/v2/FsWatchParams.ts +0 -18
  885. package/bundle/src/codex-protocol/v2/FsWatchResponse.ts +0 -14
  886. package/bundle/src/codex-protocol/v2/FsWriteFileParams.ts +0 -18
  887. package/bundle/src/codex-protocol/v2/FsWriteFileResponse.ts +0 -8
  888. package/bundle/src/codex-protocol/v2/GetAccountParams.ts +0 -14
  889. package/bundle/src/codex-protocol/v2/GetAccountRateLimitsResponse.ts +0 -15
  890. package/bundle/src/codex-protocol/v2/GetAccountResponse.ts +0 -6
  891. package/bundle/src/codex-protocol/v2/GitInfo.ts +0 -5
  892. package/bundle/src/codex-protocol/v2/GrantedPermissionProfile.ts +0 -10
  893. package/bundle/src/codex-protocol/v2/GuardianApprovalReview.ts +0 -18
  894. package/bundle/src/codex-protocol/v2/GuardianApprovalReviewAction.ts +0 -34
  895. package/bundle/src/codex-protocol/v2/GuardianApprovalReviewStatus.ts +0 -13
  896. package/bundle/src/codex-protocol/v2/GuardianCommandSource.ts +0 -5
  897. package/bundle/src/codex-protocol/v2/GuardianRiskLevel.ts +0 -8
  898. package/bundle/src/codex-protocol/v2/GuardianUserAuthorization.ts +0 -8
  899. package/bundle/src/codex-protocol/v2/GuardianWarningNotification.ts +0 -14
  900. package/bundle/src/codex-protocol/v2/HookCompletedNotification.ts +0 -10
  901. package/bundle/src/codex-protocol/v2/HookErrorInfo.ts +0 -5
  902. package/bundle/src/codex-protocol/v2/HookEventName.ts +0 -13
  903. package/bundle/src/codex-protocol/v2/HookExecutionMode.ts +0 -5
  904. package/bundle/src/codex-protocol/v2/HookHandlerType.ts +0 -5
  905. package/bundle/src/codex-protocol/v2/HookMetadata.ts +0 -26
  906. package/bundle/src/codex-protocol/v2/HookMigration.ts +0 -5
  907. package/bundle/src/codex-protocol/v2/HookOutputEntry.ts +0 -6
  908. package/bundle/src/codex-protocol/v2/HookOutputEntryKind.ts +0 -5
  909. package/bundle/src/codex-protocol/v2/HookPromptFragment.ts +0 -5
  910. package/bundle/src/codex-protocol/v2/HookRunStatus.ts +0 -5
  911. package/bundle/src/codex-protocol/v2/HookRunSummary.ts +0 -28
  912. package/bundle/src/codex-protocol/v2/HookScope.ts +0 -5
  913. package/bundle/src/codex-protocol/v2/HookSource.ts +0 -15
  914. package/bundle/src/codex-protocol/v2/HookStartedNotification.ts +0 -10
  915. package/bundle/src/codex-protocol/v2/HookTrustStatus.ts +0 -5
  916. package/bundle/src/codex-protocol/v2/HooksListEntry.ts +0 -12
  917. package/bundle/src/codex-protocol/v2/HooksListParams.ts +0 -10
  918. package/bundle/src/codex-protocol/v2/HooksListResponse.ts +0 -6
  919. package/bundle/src/codex-protocol/v2/ItemCompletedNotification.ts +0 -14
  920. package/bundle/src/codex-protocol/v2/ItemGuardianApprovalReviewCompletedNotification.ts +0 -44
  921. package/bundle/src/codex-protocol/v2/ItemGuardianApprovalReviewStartedNotification.ts +0 -38
  922. package/bundle/src/codex-protocol/v2/ItemStartedNotification.ts +0 -14
  923. package/bundle/src/codex-protocol/v2/ListMcpServerStatusParams.ts +0 -20
  924. package/bundle/src/codex-protocol/v2/ListMcpServerStatusResponse.ts +0 -13
  925. package/bundle/src/codex-protocol/v2/LoginAccountParams.ts +0 -27
  926. package/bundle/src/codex-protocol/v2/LoginAccountResponse.ts +0 -27
  927. package/bundle/src/codex-protocol/v2/LogoutAccountResponse.ts +0 -5
  928. package/bundle/src/codex-protocol/v2/ManagedHooksRequirements.ts +0 -17
  929. package/bundle/src/codex-protocol/v2/MarketplaceAddParams.ts +0 -9
  930. package/bundle/src/codex-protocol/v2/MarketplaceAddResponse.ts +0 -10
  931. package/bundle/src/codex-protocol/v2/MarketplaceInterface.ts +0 -5
  932. package/bundle/src/codex-protocol/v2/MarketplaceLoadErrorInfo.ts +0 -6
  933. package/bundle/src/codex-protocol/v2/MarketplaceRemoveParams.ts +0 -5
  934. package/bundle/src/codex-protocol/v2/MarketplaceRemoveResponse.ts +0 -9
  935. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeErrorInfo.ts +0 -5
  936. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeParams.ts +0 -5
  937. package/bundle/src/codex-protocol/v2/MarketplaceUpgradeResponse.ts +0 -11
  938. package/bundle/src/codex-protocol/v2/McpAuthStatus.ts +0 -5
  939. package/bundle/src/codex-protocol/v2/McpElicitationArrayType.ts +0 -5
  940. package/bundle/src/codex-protocol/v2/McpElicitationBooleanSchema.ts +0 -11
  941. package/bundle/src/codex-protocol/v2/McpElicitationBooleanType.ts +0 -5
  942. package/bundle/src/codex-protocol/v2/McpElicitationConstOption.ts +0 -5
  943. package/bundle/src/codex-protocol/v2/McpElicitationEnumSchema.ts +0 -11
  944. package/bundle/src/codex-protocol/v2/McpElicitationLegacyTitledEnumSchema.ts +0 -13
  945. package/bundle/src/codex-protocol/v2/McpElicitationMultiSelectEnumSchema.ts +0 -9
  946. package/bundle/src/codex-protocol/v2/McpElicitationNumberSchema.ts +0 -13
  947. package/bundle/src/codex-protocol/v2/McpElicitationNumberType.ts +0 -5
  948. package/bundle/src/codex-protocol/v2/McpElicitationObjectType.ts +0 -5
  949. package/bundle/src/codex-protocol/v2/McpElicitationPrimitiveSchema.ts +0 -13
  950. package/bundle/src/codex-protocol/v2/McpElicitationSchema.ts +0 -18
  951. package/bundle/src/codex-protocol/v2/McpElicitationSingleSelectEnumSchema.ts +0 -9
  952. package/bundle/src/codex-protocol/v2/McpElicitationStringFormat.ts +0 -5
  953. package/bundle/src/codex-protocol/v2/McpElicitationStringSchema.ts +0 -15
  954. package/bundle/src/codex-protocol/v2/McpElicitationStringType.ts +0 -5
  955. package/bundle/src/codex-protocol/v2/McpElicitationTitledEnumItems.ts +0 -6
  956. package/bundle/src/codex-protocol/v2/McpElicitationTitledMultiSelectEnumSchema.ts +0 -15
  957. package/bundle/src/codex-protocol/v2/McpElicitationTitledSingleSelectEnumSchema.ts +0 -13
  958. package/bundle/src/codex-protocol/v2/McpElicitationUntitledEnumItems.ts +0 -9
  959. package/bundle/src/codex-protocol/v2/McpElicitationUntitledMultiSelectEnumSchema.ts +0 -15
  960. package/bundle/src/codex-protocol/v2/McpElicitationUntitledSingleSelectEnumSchema.ts +0 -12
  961. package/bundle/src/codex-protocol/v2/McpResourceReadParams.ts +0 -5
  962. package/bundle/src/codex-protocol/v2/McpResourceReadResponse.ts +0 -6
  963. package/bundle/src/codex-protocol/v2/McpServerElicitationAction.ts +0 -5
  964. package/bundle/src/codex-protocol/v2/McpServerElicitationRequestParams.ts +0 -27
  965. package/bundle/src/codex-protocol/v2/McpServerElicitationRequestResponse.ts +0 -19
  966. package/bundle/src/codex-protocol/v2/McpServerMigration.ts +0 -5
  967. package/bundle/src/codex-protocol/v2/McpServerOauthLoginCompletedNotification.ts +0 -9
  968. package/bundle/src/codex-protocol/v2/McpServerOauthLoginParams.ts +0 -9
  969. package/bundle/src/codex-protocol/v2/McpServerOauthLoginResponse.ts +0 -5
  970. package/bundle/src/codex-protocol/v2/McpServerRefreshResponse.ts +0 -5
  971. package/bundle/src/codex-protocol/v2/McpServerStartupState.ts +0 -5
  972. package/bundle/src/codex-protocol/v2/McpServerStatus.ts +0 -15
  973. package/bundle/src/codex-protocol/v2/McpServerStatusDetail.ts +0 -5
  974. package/bundle/src/codex-protocol/v2/McpServerStatusUpdatedNotification.ts +0 -10
  975. package/bundle/src/codex-protocol/v2/McpServerToolCallParams.ts +0 -12
  976. package/bundle/src/codex-protocol/v2/McpServerToolCallResponse.ts +0 -11
  977. package/bundle/src/codex-protocol/v2/McpToolCallError.ts +0 -5
  978. package/bundle/src/codex-protocol/v2/McpToolCallProgressNotification.ts +0 -10
  979. package/bundle/src/codex-protocol/v2/McpToolCallResult.ts +0 -10
  980. package/bundle/src/codex-protocol/v2/McpToolCallStatus.ts +0 -5
  981. package/bundle/src/codex-protocol/v2/MemoryCitation.ts +0 -6
  982. package/bundle/src/codex-protocol/v2/MemoryCitationEntry.ts +0 -10
  983. package/bundle/src/codex-protocol/v2/MergeStrategy.ts +0 -5
  984. package/bundle/src/codex-protocol/v2/MigrationDetails.ts +0 -18
  985. package/bundle/src/codex-protocol/v2/Model.ts +0 -30
  986. package/bundle/src/codex-protocol/v2/ModelAvailabilityNux.ts +0 -5
  987. package/bundle/src/codex-protocol/v2/ModelListParams.ts +0 -18
  988. package/bundle/src/codex-protocol/v2/ModelListResponse.ts +0 -13
  989. package/bundle/src/codex-protocol/v2/ModelProviderCapabilitiesReadParams.ts +0 -5
  990. package/bundle/src/codex-protocol/v2/ModelProviderCapabilitiesReadResponse.ts +0 -9
  991. package/bundle/src/codex-protocol/v2/ModelRerouteReason.ts +0 -5
  992. package/bundle/src/codex-protocol/v2/ModelReroutedNotification.ts +0 -12
  993. package/bundle/src/codex-protocol/v2/ModelServiceTier.ts +0 -5
  994. package/bundle/src/codex-protocol/v2/ModelUpgradeInfo.ts +0 -10
  995. package/bundle/src/codex-protocol/v2/ModelVerification.ts +0 -5
  996. package/bundle/src/codex-protocol/v2/ModelVerificationNotification.ts +0 -10
  997. package/bundle/src/codex-protocol/v2/NetworkAccess.ts +0 -5
  998. package/bundle/src/codex-protocol/v2/NetworkApprovalContext.ts +0 -6
  999. package/bundle/src/codex-protocol/v2/NetworkApprovalProtocol.ts +0 -5
  1000. package/bundle/src/codex-protocol/v2/NetworkDomainPermission.ts +0 -5
  1001. package/bundle/src/codex-protocol/v2/NetworkPolicyAmendment.ts +0 -6
  1002. package/bundle/src/codex-protocol/v2/NetworkPolicyRuleAction.ts +0 -5
  1003. package/bundle/src/codex-protocol/v2/NetworkRequirements.ts +0 -40
  1004. package/bundle/src/codex-protocol/v2/NetworkUnixSocketPermission.ts +0 -5
  1005. package/bundle/src/codex-protocol/v2/NonSteerableTurnKind.ts +0 -5
  1006. package/bundle/src/codex-protocol/v2/OverriddenMetadata.ts +0 -11
  1007. package/bundle/src/codex-protocol/v2/PatchApplyStatus.ts +0 -5
  1008. package/bundle/src/codex-protocol/v2/PatchChangeKind.ts +0 -8
  1009. package/bundle/src/codex-protocol/v2/PermissionGrantScope.ts +0 -5
  1010. package/bundle/src/codex-protocol/v2/PermissionProfile.ts +0 -14
  1011. package/bundle/src/codex-protocol/v2/PermissionProfileFileSystemPermissions.ts +0 -8
  1012. package/bundle/src/codex-protocol/v2/PermissionProfileModificationParams.ts +0 -9
  1013. package/bundle/src/codex-protocol/v2/PermissionProfileNetworkPermissions.ts +0 -5
  1014. package/bundle/src/codex-protocol/v2/PermissionProfileSelectionParams.ts +0 -10
  1015. package/bundle/src/codex-protocol/v2/PermissionsRequestApprovalParams.ts +0 -18
  1016. package/bundle/src/codex-protocol/v2/PermissionsRequestApprovalResponse.ts +0 -14
  1017. package/bundle/src/codex-protocol/v2/PlanDeltaNotification.ts +0 -14
  1018. package/bundle/src/codex-protocol/v2/PluginAuthPolicy.ts +0 -5
  1019. package/bundle/src/codex-protocol/v2/PluginAvailability.ts +0 -5
  1020. package/bundle/src/codex-protocol/v2/PluginDetail.ts +0 -19
  1021. package/bundle/src/codex-protocol/v2/PluginHookSummary.ts +0 -6
  1022. package/bundle/src/codex-protocol/v2/PluginInstallParams.ts +0 -10
  1023. package/bundle/src/codex-protocol/v2/PluginInstallPolicy.ts +0 -5
  1024. package/bundle/src/codex-protocol/v2/PluginInstallResponse.ts +0 -10
  1025. package/bundle/src/codex-protocol/v2/PluginInterface.ts +0 -46
  1026. package/bundle/src/codex-protocol/v2/PluginListMarketplaceKind.ts +0 -5
  1027. package/bundle/src/codex-protocol/v2/PluginListParams.ts +0 -18
  1028. package/bundle/src/codex-protocol/v2/PluginListResponse.ts +0 -11
  1029. package/bundle/src/codex-protocol/v2/PluginMarketplaceEntry.ts +0 -17
  1030. package/bundle/src/codex-protocol/v2/PluginReadParams.ts +0 -10
  1031. package/bundle/src/codex-protocol/v2/PluginReadResponse.ts +0 -6
  1032. package/bundle/src/codex-protocol/v2/PluginShareContext.ts +0 -12
  1033. package/bundle/src/codex-protocol/v2/PluginShareDeleteParams.ts +0 -5
  1034. package/bundle/src/codex-protocol/v2/PluginShareDeleteResponse.ts +0 -5
  1035. package/bundle/src/codex-protocol/v2/PluginShareDiscoverability.ts +0 -5
  1036. package/bundle/src/codex-protocol/v2/PluginShareListItem.ts +0 -11
  1037. package/bundle/src/codex-protocol/v2/PluginShareListParams.ts +0 -5
  1038. package/bundle/src/codex-protocol/v2/PluginShareListResponse.ts +0 -6
  1039. package/bundle/src/codex-protocol/v2/PluginSharePrincipal.ts +0 -10
  1040. package/bundle/src/codex-protocol/v2/PluginSharePrincipalType.ts +0 -5
  1041. package/bundle/src/codex-protocol/v2/PluginShareSaveParams.ts +0 -13
  1042. package/bundle/src/codex-protocol/v2/PluginShareSaveResponse.ts +0 -5
  1043. package/bundle/src/codex-protocol/v2/PluginShareTarget.ts +0 -6
  1044. package/bundle/src/codex-protocol/v2/PluginShareUpdateDiscoverability.ts +0 -5
  1045. package/bundle/src/codex-protocol/v2/PluginShareUpdateTargetsParams.ts +0 -11
  1046. package/bundle/src/codex-protocol/v2/PluginShareUpdateTargetsResponse.ts +0 -10
  1047. package/bundle/src/codex-protocol/v2/PluginSkillReadParams.ts +0 -9
  1048. package/bundle/src/codex-protocol/v2/PluginSkillReadResponse.ts +0 -5
  1049. package/bundle/src/codex-protocol/v2/PluginSource.ts +0 -9
  1050. package/bundle/src/codex-protocol/v2/PluginSummary.ts +0 -29
  1051. package/bundle/src/codex-protocol/v2/PluginUninstallParams.ts +0 -5
  1052. package/bundle/src/codex-protocol/v2/PluginUninstallResponse.ts +0 -5
  1053. package/bundle/src/codex-protocol/v2/PluginsMigration.ts +0 -5
  1054. package/bundle/src/codex-protocol/v2/ProcessExitedNotification.ts +0 -43
  1055. package/bundle/src/codex-protocol/v2/ProcessOutputDeltaNotification.ts +0 -27
  1056. package/bundle/src/codex-protocol/v2/ProcessOutputStream.ts +0 -8
  1057. package/bundle/src/codex-protocol/v2/ProcessTerminalSize.ts +0 -17
  1058. package/bundle/src/codex-protocol/v2/ProfileV2.ts +0 -37
  1059. package/bundle/src/codex-protocol/v2/RateLimitReachedType.ts +0 -10
  1060. package/bundle/src/codex-protocol/v2/RateLimitSnapshot.ts +0 -17
  1061. package/bundle/src/codex-protocol/v2/RateLimitWindow.ts +0 -9
  1062. package/bundle/src/codex-protocol/v2/RawResponseItemCompletedNotification.ts +0 -10
  1063. package/bundle/src/codex-protocol/v2/ReasoningEffortOption.ts +0 -6
  1064. package/bundle/src/codex-protocol/v2/ReasoningSummaryPartAddedNotification.ts +0 -10
  1065. package/bundle/src/codex-protocol/v2/ReasoningSummaryTextDeltaNotification.ts +0 -11
  1066. package/bundle/src/codex-protocol/v2/ReasoningTextDeltaNotification.ts +0 -11
  1067. package/bundle/src/codex-protocol/v2/RemoteControlConnectionStatus.ts +0 -5
  1068. package/bundle/src/codex-protocol/v2/RemoteControlStatusChangedNotification.ts +0 -12
  1069. package/bundle/src/codex-protocol/v2/RequestPermissionProfile.ts +0 -10
  1070. package/bundle/src/codex-protocol/v2/ResidencyRequirement.ts +0 -5
  1071. package/bundle/src/codex-protocol/v2/ReviewDelivery.ts +0 -5
  1072. package/bundle/src/codex-protocol/v2/ReviewStartParams.ts +0 -15
  1073. package/bundle/src/codex-protocol/v2/ReviewStartResponse.ts +0 -15
  1074. package/bundle/src/codex-protocol/v2/ReviewTarget.ts +0 -16
  1075. package/bundle/src/codex-protocol/v2/SandboxMode.ts +0 -5
  1076. package/bundle/src/codex-protocol/v2/SandboxPolicy.ts +0 -17
  1077. package/bundle/src/codex-protocol/v2/SandboxWorkspaceWrite.ts +0 -10
  1078. package/bundle/src/codex-protocol/v2/SendAddCreditsNudgeEmailParams.ts +0 -6
  1079. package/bundle/src/codex-protocol/v2/SendAddCreditsNudgeEmailResponse.ts +0 -6
  1080. package/bundle/src/codex-protocol/v2/ServerRequestResolvedNotification.ts +0 -6
  1081. package/bundle/src/codex-protocol/v2/SessionMigration.ts +0 -5
  1082. package/bundle/src/codex-protocol/v2/SessionSource.ts +0 -13
  1083. package/bundle/src/codex-protocol/v2/SkillDependencies.ts +0 -6
  1084. package/bundle/src/codex-protocol/v2/SkillErrorInfo.ts +0 -5
  1085. package/bundle/src/codex-protocol/v2/SkillInterface.ts +0 -13
  1086. package/bundle/src/codex-protocol/v2/SkillMetadata.ts +0 -21
  1087. package/bundle/src/codex-protocol/v2/SkillScope.ts +0 -5
  1088. package/bundle/src/codex-protocol/v2/SkillSummary.ts +0 -14
  1089. package/bundle/src/codex-protocol/v2/SkillToolDependency.ts +0 -12
  1090. package/bundle/src/codex-protocol/v2/SkillsChangedNotification.ts +0 -11
  1091. package/bundle/src/codex-protocol/v2/SkillsConfigWriteParams.ts +0 -16
  1092. package/bundle/src/codex-protocol/v2/SkillsConfigWriteResponse.ts +0 -5
  1093. package/bundle/src/codex-protocol/v2/SkillsListEntry.ts +0 -11
  1094. package/bundle/src/codex-protocol/v2/SkillsListParams.ts +0 -14
  1095. package/bundle/src/codex-protocol/v2/SkillsListResponse.ts +0 -6
  1096. package/bundle/src/codex-protocol/v2/SortDirection.ts +0 -5
  1097. package/bundle/src/codex-protocol/v2/SubagentMigration.ts +0 -5
  1098. package/bundle/src/codex-protocol/v2/TerminalInteractionNotification.ts +0 -11
  1099. package/bundle/src/codex-protocol/v2/TextElement.ts +0 -15
  1100. package/bundle/src/codex-protocol/v2/TextPosition.ts +0 -14
  1101. package/bundle/src/codex-protocol/v2/TextRange.ts +0 -6
  1102. package/bundle/src/codex-protocol/v2/Thread.ts +0 -88
  1103. package/bundle/src/codex-protocol/v2/ThreadActiveFlag.ts +0 -5
  1104. package/bundle/src/codex-protocol/v2/ThreadApproveGuardianDeniedActionParams.ts +0 -12
  1105. package/bundle/src/codex-protocol/v2/ThreadApproveGuardianDeniedActionResponse.ts +0 -5
  1106. package/bundle/src/codex-protocol/v2/ThreadArchiveParams.ts +0 -5
  1107. package/bundle/src/codex-protocol/v2/ThreadArchiveResponse.ts +0 -5
  1108. package/bundle/src/codex-protocol/v2/ThreadArchivedNotification.ts +0 -5
  1109. package/bundle/src/codex-protocol/v2/ThreadClosedNotification.ts +0 -5
  1110. package/bundle/src/codex-protocol/v2/ThreadCompactStartParams.ts +0 -5
  1111. package/bundle/src/codex-protocol/v2/ThreadCompactStartResponse.ts +0 -5
  1112. package/bundle/src/codex-protocol/v2/ThreadForkParams.ts +0 -40
  1113. package/bundle/src/codex-protocol/v2/ThreadForkResponse.ts +0 -30
  1114. package/bundle/src/codex-protocol/v2/ThreadGoal.ts +0 -15
  1115. package/bundle/src/codex-protocol/v2/ThreadGoalClearedNotification.ts +0 -5
  1116. package/bundle/src/codex-protocol/v2/ThreadGoalStatus.ts +0 -5
  1117. package/bundle/src/codex-protocol/v2/ThreadGoalUpdatedNotification.ts +0 -10
  1118. package/bundle/src/codex-protocol/v2/ThreadInjectItemsParams.ts +0 -12
  1119. package/bundle/src/codex-protocol/v2/ThreadInjectItemsResponse.ts +0 -5
  1120. package/bundle/src/codex-protocol/v2/ThreadItem.ts +0 -156
  1121. package/bundle/src/codex-protocol/v2/ThreadListParams.ts +0 -55
  1122. package/bundle/src/codex-protocol/v2/ThreadListResponse.ts +0 -20
  1123. package/bundle/src/codex-protocol/v2/ThreadLoadedListParams.ts +0 -14
  1124. package/bundle/src/codex-protocol/v2/ThreadLoadedListResponse.ts +0 -15
  1125. package/bundle/src/codex-protocol/v2/ThreadMetadataGitInfoUpdateParams.ts +0 -21
  1126. package/bundle/src/codex-protocol/v2/ThreadMetadataUpdateParams.ts +0 -14
  1127. package/bundle/src/codex-protocol/v2/ThreadMetadataUpdateResponse.ts +0 -6
  1128. package/bundle/src/codex-protocol/v2/ThreadNameUpdatedNotification.ts +0 -5
  1129. package/bundle/src/codex-protocol/v2/ThreadReadParams.ts +0 -11
  1130. package/bundle/src/codex-protocol/v2/ThreadReadResponse.ts +0 -6
  1131. package/bundle/src/codex-protocol/v2/ThreadRealtimeAudioChunk.ts +0 -14
  1132. package/bundle/src/codex-protocol/v2/ThreadRealtimeClosedNotification.ts +0 -8
  1133. package/bundle/src/codex-protocol/v2/ThreadRealtimeErrorNotification.ts +0 -8
  1134. package/bundle/src/codex-protocol/v2/ThreadRealtimeItemAddedNotification.ts +0 -9
  1135. package/bundle/src/codex-protocol/v2/ThreadRealtimeOutputAudioDeltaNotification.ts +0 -12
  1136. package/bundle/src/codex-protocol/v2/ThreadRealtimeSdpNotification.ts +0 -8
  1137. package/bundle/src/codex-protocol/v2/ThreadRealtimeStartTransport.ts +0 -17
  1138. package/bundle/src/codex-protocol/v2/ThreadRealtimeStartedNotification.ts +0 -13
  1139. package/bundle/src/codex-protocol/v2/ThreadRealtimeTranscriptDeltaNotification.ts +0 -16
  1140. package/bundle/src/codex-protocol/v2/ThreadRealtimeTranscriptDoneNotification.ts +0 -16
  1141. package/bundle/src/codex-protocol/v2/ThreadResumeParams.ts +0 -39
  1142. package/bundle/src/codex-protocol/v2/ThreadResumeResponse.ts +0 -30
  1143. package/bundle/src/codex-protocol/v2/ThreadRollbackParams.ts +0 -14
  1144. package/bundle/src/codex-protocol/v2/ThreadRollbackResponse.ts +0 -15
  1145. package/bundle/src/codex-protocol/v2/ThreadSetNameParams.ts +0 -5
  1146. package/bundle/src/codex-protocol/v2/ThreadSetNameResponse.ts +0 -5
  1147. package/bundle/src/codex-protocol/v2/ThreadShellCommandParams.ts +0 -14
  1148. package/bundle/src/codex-protocol/v2/ThreadShellCommandResponse.ts +0 -5
  1149. package/bundle/src/codex-protocol/v2/ThreadSortKey.ts +0 -5
  1150. package/bundle/src/codex-protocol/v2/ThreadSource.ts +0 -5
  1151. package/bundle/src/codex-protocol/v2/ThreadSourceKind.ts +0 -15
  1152. package/bundle/src/codex-protocol/v2/ThreadStartParams.ts +0 -33
  1153. package/bundle/src/codex-protocol/v2/ThreadStartResponse.ts +0 -30
  1154. package/bundle/src/codex-protocol/v2/ThreadStartSource.ts +0 -5
  1155. package/bundle/src/codex-protocol/v2/ThreadStartedNotification.ts +0 -6
  1156. package/bundle/src/codex-protocol/v2/ThreadStatus.ts +0 -10
  1157. package/bundle/src/codex-protocol/v2/ThreadStatusChangedNotification.ts +0 -6
  1158. package/bundle/src/codex-protocol/v2/ThreadTokenUsage.ts +0 -10
  1159. package/bundle/src/codex-protocol/v2/ThreadTokenUsageUpdatedNotification.ts +0 -10
  1160. package/bundle/src/codex-protocol/v2/ThreadUnarchiveParams.ts +0 -5
  1161. package/bundle/src/codex-protocol/v2/ThreadUnarchiveResponse.ts +0 -6
  1162. package/bundle/src/codex-protocol/v2/ThreadUnarchivedNotification.ts +0 -5
  1163. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeParams.ts +0 -5
  1164. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeResponse.ts +0 -6
  1165. package/bundle/src/codex-protocol/v2/ThreadUnsubscribeStatus.ts +0 -5
  1166. package/bundle/src/codex-protocol/v2/TokenUsageBreakdown.ts +0 -11
  1167. package/bundle/src/codex-protocol/v2/ToolRequestUserInputAnswer.ts +0 -8
  1168. package/bundle/src/codex-protocol/v2/ToolRequestUserInputOption.ts +0 -8
  1169. package/bundle/src/codex-protocol/v2/ToolRequestUserInputParams.ts +0 -14
  1170. package/bundle/src/codex-protocol/v2/ToolRequestUserInputQuestion.ts +0 -16
  1171. package/bundle/src/codex-protocol/v2/ToolRequestUserInputResponse.ts +0 -11
  1172. package/bundle/src/codex-protocol/v2/ToolsV2.ts +0 -6
  1173. package/bundle/src/codex-protocol/v2/Turn.ts +0 -36
  1174. package/bundle/src/codex-protocol/v2/TurnCompletedNotification.ts +0 -6
  1175. package/bundle/src/codex-protocol/v2/TurnDiffUpdatedNotification.ts +0 -9
  1176. package/bundle/src/codex-protocol/v2/TurnEnvironmentParams.ts +0 -6
  1177. package/bundle/src/codex-protocol/v2/TurnError.ts +0 -10
  1178. package/bundle/src/codex-protocol/v2/TurnInterruptParams.ts +0 -5
  1179. package/bundle/src/codex-protocol/v2/TurnInterruptResponse.ts +0 -5
  1180. package/bundle/src/codex-protocol/v2/TurnItemsView.ts +0 -5
  1181. package/bundle/src/codex-protocol/v2/TurnPlanStep.ts +0 -6
  1182. package/bundle/src/codex-protocol/v2/TurnPlanStepStatus.ts +0 -5
  1183. package/bundle/src/codex-protocol/v2/TurnPlanUpdatedNotification.ts +0 -11
  1184. package/bundle/src/codex-protocol/v2/TurnStartParams.ts +0 -48
  1185. package/bundle/src/codex-protocol/v2/TurnStartResponse.ts +0 -6
  1186. package/bundle/src/codex-protocol/v2/TurnStartedNotification.ts +0 -6
  1187. package/bundle/src/codex-protocol/v2/TurnStatus.ts +0 -5
  1188. package/bundle/src/codex-protocol/v2/TurnSteerParams.ts +0 -13
  1189. package/bundle/src/codex-protocol/v2/TurnSteerResponse.ts +0 -5
  1190. package/bundle/src/codex-protocol/v2/UserInput.ts +0 -18
  1191. package/bundle/src/codex-protocol/v2/WarningNotification.ts +0 -14
  1192. package/bundle/src/codex-protocol/v2/WebSearchAction.ts +0 -9
  1193. package/bundle/src/codex-protocol/v2/WindowsSandboxReadiness.ts +0 -5
  1194. package/bundle/src/codex-protocol/v2/WindowsSandboxReadinessResponse.ts +0 -6
  1195. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupCompletedNotification.ts +0 -10
  1196. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupMode.ts +0 -5
  1197. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupStartParams.ts +0 -10
  1198. package/bundle/src/codex-protocol/v2/WindowsSandboxSetupStartResponse.ts +0 -5
  1199. package/bundle/src/codex-protocol/v2/WindowsWorldWritableWarningNotification.ts +0 -9
  1200. package/bundle/src/codex-protocol/v2/WriteStatus.ts +0 -5
  1201. package/bundle/src/codex-protocol/v2/index.ts +0 -446
  1202. package/bundle/src/utils/providers/openai/codex-rpc.ts +0 -238
  1203. package/bundle/src/utils/providers/openai/codex-worker.test.ts +0 -1006
  1204. package/bundle/src/utils/providers/openai/codex-worker.ts +0 -927
  1205. package/bundle/src/utils/providers/openai/openai-worker-pool-config.ts +0 -112
  1206. package/bundle/web-dist/client/assets/index-C0594sjh.js +0 -106
  1207. package/bundle/web-dist/client/assets/index-CcMEpCgt.css +0 -1
  1208. package/bundle/web-dist/client/assets/logs-BotUcOEB.js +0 -1
  1209. package/bundle/web-dist/client/assets/monit-kk3vnGvu.js +0 -1
  1210. package/bundle/web-dist/client/assets/settings-CAAQSIyg.js +0 -1
  1211. package/bundle/web-dist/client/assets/show-BryNvjUT.js +0 -2
  1212. /package/bundle/dist/{codex-protocol/AbsolutePathBuf.js → utils/providers/common/provider-types.js} +0 -0
@@ -1,46 +1,31 @@
1
- /**
2
- * OpenAIDispatcher — codex app-server worker pool + 토큰 라우팅.
3
- *
4
- * - 토큰당 CodexAppServerWorker 자동 확장 (기본 1~3, hard cap 20)
5
- * - idle worker round-robin 선택 + 큐 대기 (전부 busy 시)
6
- * - TokenSubscriber 이벤트로 worker pool 동기화
7
- * - backpressure: 큐 full 또는 timeout 시 SERVER_BUSY
8
- */
9
- import { readFileSync } from "node:fs";
10
- import { freemem } from "node:os";
11
-
12
1
  import { getLogger } from "@logtape/logtape";
13
2
 
14
3
  import { QuotaThresholdExceededError } from "../../../application/qgrid/qgrid.types";
15
4
  import { TokenModel } from "../../../application/token/token.model";
16
5
  import { type OpenAICredentials } from "../../../application/token/token.types";
17
- import { type GetAccountRateLimitsResponse } from "../../../codex-protocol/v2/GetAccountRateLimitsResponse";
18
6
  import {
19
7
  type GenerateRequest,
20
8
  type GenerateResult,
21
9
  type GenerateStreamCallbacks,
10
+ type GeneratedImage,
22
11
  type ProviderDispatcher,
23
12
  } from "../common/provider-dispatcher";
24
13
  import { SmoothWeightedRoundRobin } from "../common/smooth-weighted-round-robin";
25
- import { CodexAppServerWorker, type StreamCallbacks, type TurnRequest } from "./codex-worker";
26
14
  import {
27
- readOpenAIQuotaUsage,
28
- type OpenAIQuotaUsageResult,
29
- type OpenAIRateLimitsWithMeta,
30
- } from "./openai-quota";
15
+ type JsonValue,
16
+ type OpenAIResponseItem,
17
+ type OpenAIResponsesOptions,
18
+ } from "./openai-backend-protocol";
19
+ import { OpenAIDirectClient, type OpenAIDirectClientOptions } from "./openai-direct-client";
20
+ import { readOpenAIQuotaUsage, type OpenAIRateLimitsWithMeta } from "./openai-quota";
31
21
  import { handleChatgptAuthTokensRefresh } from "./openai-refresh";
32
- import {
33
- estimateOpenAIWorkerRssGiB,
34
- type OpenAIWorkerPoolConfig,
35
- resolveOpenAIWorkerPoolConfig,
36
- } from "./openai-worker-pool-config";
22
+ import { type OpenAITransportKind, resolveOpenAITransportKind } from "./openai-transport-config";
37
23
 
38
24
  const logger = getLogger(["qgrid", "openai-dispatcher"]);
25
+ // 교체된 codex worker 가 강제하던 watchdog. 호출자가 timeoutMs 를 생략해도 요청이
26
+ // 영원히 매달리지 않도록 direct transport 도 유한한 기본 상한을 유지한다.
27
+ const DEFAULT_REQUEST_TIMEOUT_MS = 600_000;
39
28
 
40
- // 이미지 생성 요청이 게이트/생성에 실패했을 때의 구분자.
41
- // - "gate": 사전 검증 실패(capability/모델 멀티모달 불충족) — turn 미실행.
42
- // - "not_called": turn 은 성공했으나 모델이 image tool 을 호출 안 함 — 재시도 무익(프롬프트 문제).
43
- // - "incomplete": tool 시도됐으나 완성 이미지 미도착 — 재시도 후보(서버측 실패/거부).
44
29
  export type ImageFailureKind = "gate" | "not_called" | "incomplete";
45
30
 
46
31
  export class ImageGenerationError extends Error {
@@ -53,154 +38,159 @@ export class ImageGenerationError extends Error {
53
38
  }
54
39
  }
55
40
 
56
- const DEFAULT_EFFORT = "low";
57
- const QUEUE_TIMEOUT_MS = 60_000;
58
- const MAX_QUEUE_SIZE = 50;
59
- const SPAWN_INTERVAL_MS = 500;
41
+ type TokenMetadata = {
42
+ name: string;
43
+ credentials: OpenAICredentials;
44
+ quotaThreshold?: number | null;
45
+ weight: number;
46
+ active: boolean;
47
+ generation: number;
48
+ };
49
+
50
+ type TokenSelection = { tokenId: number; metadata: TokenMetadata };
60
51
 
61
- function readHostAvailableGiB(): number {
62
- try {
63
- const match = readFileSync("/proc/meminfo", "utf8").match(/^MemAvailable:\s+(\d+)\s+kB$/m);
64
- if (match?.[1]) return Number(match[1]) / 1024 / 1024;
65
- } catch {}
66
- return freemem() / 1024 / 1024 / 1024;
67
- }
52
+ export type OpenAIDirectClientFactory = (
53
+ options: OpenAIDirectClientOptions,
54
+ tokenId: number,
55
+ ) => Pick<OpenAIDirectClient, "responses"> & { close?: () => void };
68
56
 
69
- // thread 재사용(prompt cache 고정). 끄면 기존 "매 turn 새 thread + history inject" 동작.
70
- const THREAD_REUSE_ENABLED = process.env.QGRID_OPENAI_THREAD_REUSE !== "false";
71
- // 좌표 worker 가 busy 일 때 free 를 기다리는 최대 시간. 초과 시 새 thread 로 폴백.
72
- const REUSE_WORKER_WAIT_MS = 5_000;
73
- const REUSE_WORKER_POLL_MS = 50;
57
+ type ClientEntry = {
58
+ generation: number;
59
+ client: Pick<OpenAIDirectClient, "responses"> & { close?: () => void };
60
+ inFlight: number;
61
+ retired: boolean;
62
+ };
74
63
 
75
- // workerId 합성: tokenId 와 workerIndex(0..19) 를 하나의 안정 숫자로 인코딩.
76
- const OPENAI_WORKER_ID_STRIDE = 100;
77
- export function makeOpenAIWorkerId(tokenId: number, workerIndex: number): number {
78
- return tokenId * OPENAI_WORKER_ID_STRIDE + workerIndex;
64
+ export interface OpenAIDispatcherDependencies {
65
+ clientFactory?: OpenAIDirectClientFactory;
66
+ fetch?: typeof fetch;
79
67
  }
80
68
 
81
- function sleep(ms: number): Promise<void> {
82
- return new Promise((resolve) => setTimeout(resolve, ms));
69
+ function abortError(signal: AbortSignal): Error {
70
+ const reason = signal.reason;
71
+ return reason instanceof Error ? reason : new DOMException("Aborted", "AbortError");
83
72
  }
84
73
 
85
- function quotaThresholdExceededMessage(
86
- provider: string,
87
- tokens: Array<{ tokenName: string; threshold: number }>,
88
- ): string {
89
- const details = tokens
90
- .map((token) => `${token.tokenName} (threshold ${token.threshold}%)`)
91
- .join(", ");
92
- return details.length > 0
93
- ? `All ${provider} tokens exceeded quota threshold: ${details}`
94
- : `All ${provider} tokens exceeded quota threshold`;
74
+ function activeSignal(signal?: AbortSignal, timeoutMs?: number): AbortSignal {
75
+ const timeout = AbortSignal.timeout(timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS);
76
+ return signal ? AbortSignal.any([signal, timeout]) : timeout;
95
77
  }
96
78
 
97
- type QueueItem = {
98
- resolve: (worker: CodexAppServerWorker) => void;
99
- reject: (error: Error) => void;
100
- timer: ReturnType<typeof setTimeout>;
101
- abortCleanup?: () => void;
102
- excludedTokenIds: Set<number>;
103
- };
79
+ function quotaMessage(entries: Array<{ name: string; threshold: number }>): string {
80
+ const detail = entries.map((e) => `${e.name} (threshold ${e.threshold}%)`).join(", ");
81
+ return detail
82
+ ? `All openai tokens exceeded quota threshold: ${detail}`
83
+ : "All openai tokens exceeded quota threshold";
84
+ }
104
85
 
105
- type TokenMetadata = {
106
- name: string;
107
- credentials: OpenAICredentials;
108
- quotaThreshold?: number | null;
109
- weight: number;
110
- active: boolean;
111
- };
86
+ function inputItems(req: GenerateRequest): OpenAIResponseItem[] {
87
+ const history = (req.coldHistory ?? []) as OpenAIResponseItem[];
88
+ const content: OpenAIResponseItem[] = req.coldInput.map((input) => {
89
+ if (input.type === "text") return { type: "input_text", text: input.text };
90
+ if (input.type === "image") return { type: "input_image", image_url: input.url };
91
+ if (input.type === "localImage") return { type: "input_image", image_url: input.path };
92
+ return { type: "input_text", text: `${input.name}: ${input.path}` };
93
+ });
94
+ return [...history, { type: "message", role: "user", content }];
95
+ }
112
96
 
113
- type TokenEligibility = {
114
- readyActiveTokenIds: Set<number>;
115
- eligibleTokenIds: Set<number>;
116
- overThresholdTokens: Array<{ tokenName: string; threshold: number }>;
117
- thresholdedTokenCount: number;
118
- };
97
+ function asReasoning(req: GenerateRequest): OpenAIResponsesOptions["reasoning"] | undefined {
98
+ const summary =
99
+ req.reasoningSummary && req.reasoningSummary !== "none" ? req.reasoningSummary : undefined;
100
+ if (!req.effort && !summary) return undefined;
101
+ return {
102
+ ...(req.effort
103
+ ? { effort: req.effort as NonNullable<OpenAIResponsesOptions["reasoning"]>["effort"] }
104
+ : {}),
105
+ ...(summary
106
+ ? {
107
+ summary: summary as NonNullable<OpenAIResponsesOptions["reasoning"]>["summary"],
108
+ }
109
+ : {}),
110
+ };
111
+ }
119
112
 
120
- type RateLimitsCacheEntry = OpenAIRateLimitsWithMeta & {
121
- generation: number;
122
- };
113
+ function requestOptions(req: GenerateRequest): OpenAIResponsesOptions {
114
+ return {
115
+ model: req.model ?? "",
116
+ ...(req.systemPrompt ? { instructions: req.systemPrompt } : {}),
117
+ history: inputItems(req),
118
+ ...(asReasoning(req) ? { reasoning: asReasoning(req) } : {}),
119
+ ...(req.verbosity ? { verbosity: req.verbosity as OpenAIResponsesOptions["verbosity"] } : {}),
120
+ ...(req.serviceTier
121
+ ? { serviceTier: req.serviceTier === "fast" ? "priority" : req.serviceTier }
122
+ : {}),
123
+ ...(req.promptCacheKey ? { promptCacheKey: req.promptCacheKey } : {}),
124
+ ...(req.outputSchema ? { outputSchema: { schema: req.outputSchema as JsonValue } } : {}),
125
+ ...(req.imageGeneration
126
+ ? { imageGeneration: req.imageGenerationOptions ? { ...req.imageGenerationOptions } : true }
127
+ : {}),
128
+ };
129
+ }
123
130
 
131
+ /**
132
+ * Direct OpenAI dispatcher — Anthropic 과 동일한 stateless 실행 모델.
133
+ *
134
+ * 요청 = 토큰 선택(quota gate + weighted round-robin + cache affinity 선호) → HTTPS/WS
135
+ * 전송. permit/큐 같은 동시성 상한은 두지 않는다: 전송은 fetch 한 번이라 로컬 자원이
136
+ * 희소하지 않고, 상류 제한은 백엔드의 응답(429 등)이 진실이다. worker pool 시절의
137
+ * 큐 의미론(SERVER_BUSY, 큐 타임아웃)은 이 전환으로 제거됐다.
138
+ */
124
139
  export class OpenAIDispatcher implements ProviderDispatcher {
125
- workerPool = new Map<number, CodexAppServerWorker[]>();
126
- tokenMetadata = new Map<number, TokenMetadata>();
127
- queue: QueueItem[] = [];
128
- readonly poolConfig: OpenAIWorkerPoolConfig;
129
- private readonly quotaBlockedTokenIds = new Set<number>();
130
- private readonly startingTokenIds = new Set<number>();
131
- private readonly rateLimitsGenerationByToken = new Map<number, number>();
132
- private readonly weightedSelector = new SmoothWeightedRoundRobin();
133
- private readonly workerCursorByToken = new Map<number, number>();
134
- private readonly getHostAvailableGiB: () => number;
135
- private draining = false;
136
- private drainAgain = false;
137
- private scalerTimer: ReturnType<typeof setInterval> | null = null;
138
- private scalingPromise: Promise<void> | null = null;
139
- private lastRequestAt = Date.now();
140
- private stopped = false;
140
+ readonly tokenMetadata = new Map<number, TokenMetadata>();
141
+ readonly transportKind: OpenAITransportKind;
142
+ readonly rateLimitsCache = new Map<number, OpenAIRateLimitsWithMeta & { generation: number }>();
143
+ private readonly pendingRateLimits = new Map<
144
+ number,
145
+ Promise<OpenAIRateLimitsWithMeta & { generation: number }>
146
+ >();
147
+ private readonly clients = new Map<number, ClientEntry>();
148
+ private readonly retiredClients = new Set<ClientEntry>();
149
+ static readonly RATE_LIMITS_CACHE_TTL = 60_000;
150
+
151
+ private readonly selector = new SmoothWeightedRoundRobin();
152
+ private readonly clientFactory: OpenAIDirectClientFactory;
153
+ private readonly fetchImpl: typeof fetch;
154
+ private readonly quotaBlocked = new Set<number>();
155
+ private inFlightCount = 0;
141
156
 
142
157
  constructor(
143
- poolConfig: OpenAIWorkerPoolConfig = resolveOpenAIWorkerPoolConfig(),
144
- getHostAvailableGiB: () => number = readHostAvailableGiB,
158
+ transportKind: OpenAITransportKind = resolveOpenAITransportKind(),
159
+ dependencies: OpenAIDispatcherDependencies = {},
145
160
  ) {
146
- this.poolConfig = poolConfig;
147
- this.getHostAvailableGiB = getHostAvailableGiB;
161
+ this.transportKind = transportKind;
162
+ this.clientFactory =
163
+ dependencies.clientFactory ?? ((options) => new OpenAIDirectClient(options));
164
+ this.fetchImpl = dependencies.fetch ?? fetch;
148
165
  }
149
166
 
150
167
  async start(): Promise<void> {
151
- this.stopped = false;
152
168
  const { rows } = await TokenModel.findMany("A");
153
- const openaiTokens = rows.filter((t) => t.provider === "openai");
154
- logger.info(
155
- this.poolConfig.autoscale
156
- ? `starting ${openaiTokens.length} openai tokens (${this.poolConfig.minWorkersPerToken}-${this.poolConfig.maxWorkersPerToken} workers each, autoscale)`
157
- : `starting ${openaiTokens.length} openai tokens (${this.poolConfig.minWorkersPerToken} workers each)`,
158
- );
159
-
160
- await Promise.allSettled(
161
- openaiTokens.map(async (t) => {
162
- await this.spawnWorkers(
163
- t.id,
164
- t.name,
165
- t.credentials as OpenAICredentials,
166
- t.quota_threshold,
167
- t.weight,
168
- );
169
- if (!t.active) this.onTokenDeactivated(t.id);
170
- }),
171
- );
172
-
173
- // autoscale off도 fixed min의 health maintenance는 계속 필요하다.
174
- this.scalerTimer = setInterval(
175
- () => this.requestAutoscaleEvaluation(),
176
- this.poolConfig.scaleIntervalMs,
177
- );
178
- this.scalerTimer.unref?.();
169
+ for (const row of rows) {
170
+ if (row.provider !== "openai") continue;
171
+ this.setToken(
172
+ row.id,
173
+ row.name,
174
+ row.credentials as OpenAICredentials,
175
+ row.quota_threshold,
176
+ row.weight,
177
+ row.active,
178
+ );
179
+ }
180
+ logger.info(`started direct OpenAI runtime with ${this.tokenMetadata.size} tokens`);
179
181
  }
180
182
 
181
183
  async stop(): Promise<void> {
182
- this.stopped = true;
183
- if (this.scalerTimer) {
184
- clearInterval(this.scalerTimer);
185
- this.scalerTimer = null;
186
- }
187
- await this.scalingPromise?.catch(() => {});
188
- this.rejectAllQueued("DISPATCHER_SHUTDOWN");
189
- const kills = [...this.workerPool.values()].flat().map((w) => w.kill());
190
- await Promise.allSettled(kills);
191
- for (const id of this.tokenMetadata.keys()) this.weightedSelector.removeToken(id);
192
- this.workerPool.clear();
184
+ for (const { client } of this.clients.values()) client.close?.();
185
+ this.clients.clear();
186
+ for (const entry of this.retiredClients) entry.client.close?.();
187
+ this.retiredClients.clear();
193
188
  this.tokenMetadata.clear();
194
- this.workerCursorByToken.clear();
195
- this.weightedSelector.resetScores();
196
189
  this.rateLimitsCache.clear();
197
- this.rateLimitsGenerationByToken.clear();
198
- this.quotaBlockedTokenIds.clear();
199
- this.startingTokenIds.clear();
190
+ this.quotaBlocked.clear();
191
+ this.selector.resetScores();
200
192
  }
201
193
 
202
- // ── Token events (from TokenSubscriber) ─────────────────────────
203
-
204
194
  async onTokenAdded(
205
195
  id: number,
206
196
  name: string,
@@ -208,30 +198,7 @@ export class OpenAIDispatcher implements ProviderDispatcher {
208
198
  quotaThreshold?: number | null,
209
199
  weight = 1,
210
200
  ): Promise<void> {
211
- this.quotaBlockedTokenIds.delete(id);
212
- this.invalidateRateLimitsCache(id);
213
- this.setTokenMetadata(id, name, credentials, quotaThreshold, weight);
214
- if (this.workerPool.has(id)) return;
215
- await this.spawnWorkers(id, name, credentials, quotaThreshold, weight);
216
- }
217
-
218
- async onTokenRemoved(id: number): Promise<void> {
219
- const workers = this.workerPool.get(id) ?? [];
220
- const tokenName = workers[0]?.tokenName;
221
- this.workerPool.delete(id);
222
- this.tokenMetadata.delete(id);
223
- this.weightedSelector.removeToken(id);
224
- this.workerCursorByToken.delete(id);
225
- this.invalidateRateLimitsCache(id);
226
- this.quotaBlockedTokenIds.delete(id);
227
- await Promise.allSettled(workers.map((w) => w.kill()));
228
- if (!this.hasActiveTokenCandidate(new Set())) {
229
- this.rejectAllQueued("NO_OPENAI_WORKERS");
230
- }
231
- if (workers.length > 0) {
232
- const label = tokenName ?? `token ${id}`;
233
- logger.info(`workers removed: ${label} (${workers.length})`);
234
- }
201
+ this.setToken(id, name, credentials, quotaThreshold, weight, true);
235
202
  }
236
203
 
237
204
  async onTokenUpdated(
@@ -241,62 +208,28 @@ export class OpenAIDispatcher implements ProviderDispatcher {
241
208
  quotaThreshold?: number | null,
242
209
  weight = 1,
243
210
  ): Promise<void> {
244
- const existing = this.workerPool.get(id) ?? [];
245
- const thresholdChanged = this.getQuotaThreshold(id) !== quotaThreshold;
246
- if (thresholdChanged) this.quotaBlockedTokenIds.delete(id);
247
- this.setTokenMetadata(id, name, credentials, quotaThreshold, weight);
248
-
249
- if (existing.length === 0) {
250
- this.invalidateRateLimitsCache(id);
251
- await this.spawnWorkers(id, name, credentials, quotaThreshold, weight);
252
- return;
253
- }
254
-
255
- if (existing.every((w) => w.canReuseForToken(name, credentials))) {
256
- existing.forEach((w) => w.updateTokenState(name, credentials));
257
- logger.info(`workers updated in-place: ${name}`);
258
- this.requestDrainQueue();
259
- return;
260
- }
211
+ const old = this.tokenMetadata.get(id);
212
+ this.setToken(id, name, credentials, quotaThreshold, weight, old?.active ?? true);
213
+ }
261
214
 
262
- this.workerPool.delete(id);
215
+ async onTokenRemoved(id: number): Promise<void> {
216
+ this.retireClient(id);
217
+ this.tokenMetadata.delete(id);
218
+ this.selector.removeToken(id);
263
219
  this.invalidateRateLimitsCache(id);
264
- this.quotaBlockedTokenIds.delete(id);
265
- await Promise.allSettled(existing.map((w) => w.kill()));
266
- await this.spawnWorkers(id, name, credentials, quotaThreshold, weight);
220
+ this.quotaBlocked.delete(id);
267
221
  }
268
222
 
269
223
  onTokenDeactivated(id: number): void {
270
- const workers = this.workerPool.get(id) ?? [];
271
- const tokenName = workers[0]?.tokenName;
272
- const metadata = this.tokenMetadata.get(id);
273
- if (metadata?.active) this.tokenMetadata.set(id, { ...metadata, active: false });
274
- this.quotaBlockedTokenIds.delete(id);
275
- const changed = workers.some((worker) => worker.active);
276
- workers.forEach((w) => {
277
- w.active = false;
278
- });
279
- if (changed) this.weightedSelector.resetScores();
280
- if (!this.hasActiveTokenCandidate(new Set())) {
281
- this.rejectAllQueued("NO_ACTIVE_WORKERS");
282
- }
283
- const label = tokenName ?? `token ${id}`;
284
- logger.info(`workers deactivated: ${label}`);
224
+ const token = this.tokenMetadata.get(id);
225
+ if (token) token.active = false;
226
+ this.selector.resetScores();
285
227
  }
286
228
 
287
229
  onTokenActivated(id: number): void {
288
- const workers = this.workerPool.get(id) ?? [];
289
- const tokenName = workers[0]?.tokenName;
290
- const metadata = this.tokenMetadata.get(id);
291
- if (metadata && !metadata.active) this.tokenMetadata.set(id, { ...metadata, active: true });
292
- const changed = workers.some((worker) => !worker.active);
293
- workers.forEach((w) => {
294
- w.active = true;
295
- });
296
- if (changed) this.weightedSelector.resetScores();
297
- this.requestDrainQueue();
298
- const label = tokenName ?? `token ${id}`;
299
- logger.info(`workers activated: ${label}`);
230
+ const token = this.tokenMetadata.get(id);
231
+ if (token) token.active = true;
232
+ this.selector.resetScores();
300
233
  }
301
234
 
302
235
  async replaceTokens(
@@ -308,1024 +241,374 @@ export class OpenAIDispatcher implements ProviderDispatcher {
308
241
  weight: number;
309
242
  }>,
310
243
  ): Promise<void> {
311
- const next = new Set(rows.map((r) => r.id));
312
- for (const id of Array.from(this.workerPool.keys())) {
313
- if (!next.has(id)) await this.onTokenRemoved(id);
314
- }
315
-
316
- for (const row of rows) {
317
- if (this.workerPool.has(row.id)) {
318
- await this.onTokenUpdated(
319
- row.id,
320
- row.name,
321
- row.credentials,
322
- row.quotaThreshold,
323
- row.weight,
324
- );
325
- } else {
326
- await this.onTokenAdded(row.id, row.name, row.credentials, row.quotaThreshold, row.weight);
327
- }
328
- this.onTokenActivated(row.id);
329
- }
244
+ const ids = new Set(rows.map((r) => r.id));
245
+ for (const id of this.tokenMetadata.keys()) if (!ids.has(id)) await this.onTokenRemoved(id);
246
+ for (const row of rows)
247
+ await this.onTokenUpdated(row.id, row.name, row.credentials, row.quotaThreshold, row.weight);
330
248
  }
331
249
 
332
- // ── Generate ────────────────────────────────────────────────────
333
-
334
250
  async generate(req: GenerateRequest): Promise<GenerateResult> {
335
- this.lastRequestAt = Date.now();
336
- const excludedTokenIds = new Set<number>();
337
- // thread 재사용 경로: 좌표 worker 를 점유해 기존 thread 에 turn 만 실행.
338
- const reuseWorker = await this.acquireReuseWorker(req, excludedTokenIds);
339
- if (reuseWorker) {
340
- logger.info(
341
- `↻ ${reuseWorker.tokenName}[${reuseWorker.tokenId}] (reuse thread, ${req.model})`,
342
- );
343
- return this.executeAndRelease(reuseWorker, (w) =>
344
- this.executeTurn(w, req, req.reuse!.threadId),
345
- );
346
- }
347
-
348
- const worker = await this.acquireIdleWorker(excludedTokenIds);
349
- if (worker) {
350
- logger.info(`→ ${worker.tokenName}[${worker.tokenId}] (model: ${req.model})`);
351
- return this.executeAndRelease(worker, (w) => this.executeTurn(w, req));
352
- }
353
- return this.enqueue((w) => {
354
- logger.info(`→ ${w.tokenName}[${w.tokenId}] (model: ${req.model}, queued)`);
355
- return this.executeTurn(w, req);
356
- }, excludedTokenIds);
251
+ return this.run(req);
357
252
  }
358
253
 
359
254
  async generateStream(req: GenerateRequest, cb: GenerateStreamCallbacks): Promise<void> {
360
- this.lastRequestAt = Date.now();
361
- // 이미지 생성은 non-stream 전용(R2): codex 가 이미지 델타를 주지 않고 완성 base64 를
362
- // 한 번에 준다. 스트리밍 경로로 이미지 요청이 오면 명시적 에러.
363
- if (req.imageGeneration) {
255
+ if (req.imageGeneration)
364
256
  throw new ImageGenerationError(
365
257
  "gate",
366
258
  "image generation is not supported on the streaming path",
367
259
  );
368
- }
369
- const excludedTokenIds = new Set<number>();
370
- const reuseWorker = await this.acquireReuseWorker(req, excludedTokenIds);
371
- if (reuseWorker) {
372
- logger.info(`↻ ${reuseWorker.tokenName}[${reuseWorker.tokenId}] (reuse thread, [stream])`);
373
- return this.executeAndRelease(reuseWorker, (w) =>
374
- this.executeStreamTurn(w, req, cb, req.reuse!.threadId),
375
- );
376
- }
377
-
378
- const worker = await this.acquireIdleWorker(excludedTokenIds);
379
- if (worker) {
380
- logger.info(`→ ${worker.tokenName}[${worker.tokenId}] (model: ${req.model}, [stream])`);
381
- return this.executeAndRelease(worker, (w) => this.executeStreamTurn(w, req, cb));
382
- }
383
- return this.enqueue((w) => {
384
- logger.info(`→ ${w.tokenName}[${w.tokenId}] (model: ${req.model}, [stream], queued)`);
385
- return this.executeStreamTurn(w, req, cb);
386
- }, excludedTokenIds);
387
- }
388
-
389
- // reuse 좌표가 유효하면 그 worker 를 busy 점유해 반환. 없거나 폴백 대상이면 null.
390
- // 폴백 사유: 기능 off / 좌표 없음 / worker 부재·죽음 / epoch 불일치(restart) / thread 소멸 /
391
- // busy 대기 타임아웃. null 반환 시 호출부는 새 thread 경로로 진행.
392
- async acquireReuseWorker(
393
- req: GenerateRequest,
394
- excludedTokenIds = new Set<number>(),
395
- ): Promise<CodexAppServerWorker | null> {
396
- // 이미지 요청은 항상 cold thread(R8): 재사용 좌표가 있어도 건너뛴다.
397
- // base64 가 thread 메모리·캐시 prefix 에 상주하는 것을 막는다.
398
- if (req.imageGeneration) return null;
399
- if (!THREAD_REUSE_ENABLED || !req.reuse) return null;
400
- const { workerId, threadId, epoch } = req.reuse;
401
-
402
- const worker = this.findWorkerById(workerId);
403
- if (!worker || !worker.isReady || !worker.active) return null;
404
- if (worker.epoch !== epoch) return null;
405
- if (!worker.hasThread(threadId)) return null;
406
- const quotaMetadata = this.tokenMetadata.get(worker.tokenId);
407
- if (!(await this.isTokenQuotaEligible(worker.tokenId, worker.tokenName, excludedTokenIds))) {
408
- return null;
409
- }
410
- if (
411
- !worker.isReady ||
412
- !worker.active ||
413
- this.tokenMetadata.get(worker.tokenId) !== quotaMetadata ||
414
- this.quotaBlockedTokenIds.has(worker.tokenId)
415
- ) {
416
- if (this.quotaBlockedTokenIds.has(worker.tokenId)) {
417
- excludedTokenIds.add(worker.tokenId);
418
- }
419
- return null;
420
- }
421
-
422
- const deadline = Date.now() + REUSE_WORKER_WAIT_MS;
423
- for (;;) {
424
- // restart(epoch 변경) / thread 소멸이 대기 중에 발생하면 폴백.
425
- if (
426
- !worker.isReady ||
427
- !worker.active ||
428
- worker.epoch !== epoch ||
429
- !worker.hasThread(threadId) ||
430
- this.tokenMetadata.get(worker.tokenId) !== quotaMetadata ||
431
- this.quotaBlockedTokenIds.has(worker.tokenId)
432
- ) {
433
- if (this.quotaBlockedTokenIds.has(worker.tokenId)) {
434
- excludedTokenIds.add(worker.tokenId);
435
- }
436
- return null;
437
- }
438
- if (worker.tryAcquireTurn()) return worker;
439
- if (Date.now() >= deadline) return null;
440
- await sleep(REUSE_WORKER_POLL_MS);
441
- }
442
- }
443
-
444
- findWorkerById(workerId: number): CodexAppServerWorker | null {
445
- for (const workers of this.workerPool.values()) {
446
- for (const w of workers) {
447
- if (makeOpenAIWorkerId(w.tokenId, w.workerIndex) === workerId) return w;
448
- }
449
- }
450
- return null;
451
- }
452
-
453
- async interruptWorkerTurn(threadId: string, turnId: string): Promise<void> {
454
- const allWorkers = [...this.workerPool.values()].flat().filter((w) => w.isReady);
455
- await Promise.allSettled(allWorkers.map((w) => w.interruptTurn(threadId, turnId)));
456
- }
457
-
458
- // ── Worker selection ────────────────────────────────────────────
459
- // Quota-eligible idle token을 weight로 고른 뒤, 그 token 안에서 worker를 순환한다.
460
- async acquireIdleWorker(
461
- excludedTokenIds = new Set<number>(),
462
- ): Promise<CodexAppServerWorker | null> {
463
- const eligibility = await this.resolveTokenEligibility(excludedTokenIds);
464
- if (eligibility.readyActiveTokenIds.size === 0) return null;
465
- if (eligibility.eligibleTokenIds.size === 0) this.throwQuotaThresholdExceeded(eligibility);
466
-
467
- const workersByToken = new Map<number, CodexAppServerWorker[]>();
468
- for (const worker of this.getAllReadyActiveWorkers()) {
469
- if (!eligibility.eligibleTokenIds.has(worker.tokenId) || !worker.hasCapacity) continue;
470
- const workers = workersByToken.get(worker.tokenId) ?? [];
471
- workers.push(worker);
472
- workersByToken.set(worker.tokenId, workers);
473
- }
474
-
475
- const selectedTokenId = this.weightedSelector.select(new Set(workersByToken.keys()));
476
- if (selectedTokenId === null) return null;
477
- const workers = workersByToken.get(selectedTokenId)!;
478
- const cursor = this.workerCursorByToken.get(selectedTokenId) ?? 0;
479
- for (let offset = 0; offset < workers.length; offset++) {
480
- const index = (cursor + offset) % workers.length;
481
- const worker = workers[index]!;
482
- if (worker.tryAcquireTurn()) {
483
- this.workerCursorByToken.set(selectedTokenId, (index + 1) % workers.length);
484
- return worker;
485
- }
486
- }
487
- throw new Error(
488
- `weighted token ${selectedTokenId} lost idle capacity during synchronous acquire`,
489
- );
490
- }
491
-
492
- getAllReadyActiveWorkers(): CodexAppServerWorker[] {
493
- return [...this.workerPool.values()].flat().filter((w) => w.isReady && w.active);
494
- }
495
-
496
- // ── Queue ───────────────────────────────────────────────────────
497
-
498
- async enqueue<T>(
499
- execute: (worker: CodexAppServerWorker) => Promise<T>,
500
- excludedTokenIds = new Set<number>(),
501
- ): Promise<T> {
502
- const eligibility = await this.resolveTokenEligibility(excludedTokenIds);
503
- if (
504
- eligibility.readyActiveTokenIds.size === 0 &&
505
- !this.hasActiveTokenCandidate(excludedTokenIds)
506
- ) {
507
- throw new Error("NO_OPENAI_WORKERS");
508
- }
509
- if (eligibility.readyActiveTokenIds.size > 0 && eligibility.eligibleTokenIds.size === 0) {
510
- this.throwQuotaThresholdExceeded(eligibility);
511
- }
512
- if (this.queue.length >= MAX_QUEUE_SIZE) {
513
- throw new Error("SERVER_BUSY");
514
- }
515
-
516
- return new Promise<T>((resolve, reject) => {
517
- const item: QueueItem = {
518
- resolve: (worker) => {
519
- clearTimeout(item.timer);
520
- item.abortCleanup?.();
521
- Promise.resolve()
522
- .then(() => this.executeAndRelease(worker, execute))
523
- .then(resolve, reject);
524
- },
525
- reject: (err) => {
526
- clearTimeout(item.timer);
527
- item.abortCleanup?.();
528
- reject(err);
529
- },
530
- timer: setTimeout(() => {
531
- this.removeFromQueue(item);
532
- reject(new Error("SERVER_BUSY"));
533
- }, QUEUE_TIMEOUT_MS),
534
- excludedTokenIds: new Set(excludedTokenIds),
535
- };
536
-
537
- this.queue.push(item);
538
- // eligibility 확인과 queue 삽입 사이에 worker가 ready/idle이 된 경우의 lost wake-up을
539
- // 닫는다. fixed mode에서도 idle worker가 즉시 queue를 가져가야 한다.
540
- this.requestDrainQueue();
541
- this.requestAutoscaleEvaluation();
542
- });
543
- }
544
-
545
- removeFromQueue(item: QueueItem): void {
546
- clearTimeout(item.timer);
547
- item.abortCleanup?.();
548
- const idx = this.queue.indexOf(item);
549
- if (idx !== -1) this.queue.splice(idx, 1);
550
- }
551
-
552
- rejectAllQueued(reason: string): void {
553
- const err = new Error(reason);
554
- this.queue.forEach((item) => {
555
- clearTimeout(item.timer);
556
- item.abortCleanup?.();
557
- item.reject(err);
558
- });
559
- this.queue = [];
560
- }
561
-
562
- async drainQueue(): Promise<void> {
563
- if (this.draining) {
564
- this.drainAgain = true;
565
- return;
566
- }
567
-
568
- this.draining = true;
569
260
  try {
570
- do {
571
- this.drainAgain = false;
572
- await this.drainQueueOnce();
573
- } while (this.drainAgain);
574
- } catch (e) {
575
- logger.warn(`drainQueue failed: ${(e as Error).message}`);
576
- } finally {
577
- this.draining = false;
261
+ cb.onComplete(await this.run(req, cb.onDelta));
262
+ } catch (error) {
263
+ cb.onError(error as Error);
264
+ throw error;
578
265
  }
579
266
  }
580
267
 
581
- private async drainQueueOnce(): Promise<void> {
582
- while (this.queue.length > 0) {
583
- const next = this.queue[0]!;
584
- let worker: CodexAppServerWorker | null;
585
- try {
586
- worker = await this.acquireIdleWorker(next.excludedTokenIds);
587
- } catch (e) {
588
- if (e instanceof QuotaThresholdExceededError) {
589
- this.queue.shift();
590
- next.reject(e);
591
- continue;
592
- }
593
- throw e;
594
- }
595
- if (!worker) break;
596
- this.queue.shift();
597
- next.resolve(worker);
598
- }
599
- }
600
-
601
- // ── Execution ───────────────────────────────────────────────────
602
-
603
- async executeAndRelease<T>(
604
- worker: CodexAppServerWorker,
605
- execute: (worker: CodexAppServerWorker) => Promise<T>,
606
- ): Promise<T> {
268
+ // generate/generateStream 공통 실행 — 토큰 선택과 in-flight 집계를 한 곳에 둔다.
269
+ private async run(
270
+ req: GenerateRequest,
271
+ onDelta?: (text: string) => void,
272
+ ): Promise<GenerateResult> {
273
+ const signal = activeSignal(req.abortSignal, req.timeoutMs);
274
+ if (signal.aborted) throw abortError(signal);
275
+ const selection = await this.selectToken(req.preferredTokenId, signal);
276
+ this.inFlightCount++;
607
277
  try {
608
- return await execute(worker);
278
+ if (signal.aborted) throw abortError(signal);
279
+ return await this.runDirect(selection, { ...req, abortSignal: signal }, onDelta);
609
280
  } finally {
610
- worker.releaseTurn();
611
- this.requestDrainQueue();
281
+ this.inFlightCount--;
612
282
  }
613
283
  }
614
284
 
615
- // reuseThreadId 가 있으면 기존 thread 에 delta(reuseInput)만, 없으면 새 thread 에 전체
616
- // prompt(coldInput) + history inject. reuse 가 dispatcher 단에서 폴백되면 후자로 떨어진다.
617
- private buildTurnRequest(req: GenerateRequest, reuseThreadId?: string): TurnRequest {
618
- const reusing = reuseThreadId !== undefined;
619
- return {
620
- input: reusing && req.reuseInput ? req.reuseInput : req.coldInput,
621
- history: reusing ? undefined : req.coldHistory,
622
- developerInstructions: req.systemPrompt,
623
- outputSchema: req.outputSchema,
624
- effort: req.effort ?? DEFAULT_EFFORT,
625
- model: req.model,
626
- verbosity: req.verbosity,
627
- reasoningSummary: req.reasoningSummary,
628
- serviceTier: req.serviceTier,
629
- imageGeneration: req.imageGeneration,
630
- imageGenerationOptions: req.imageGenerationOptions,
631
- };
632
- }
633
-
634
- async executeTurn(
635
- worker: CodexAppServerWorker,
285
+ private async runDirect(
286
+ selection: TokenSelection,
636
287
  req: GenerateRequest,
637
- reuseThreadId?: string,
288
+ onDelta?: (text: string) => void,
638
289
  ): Promise<GenerateResult> {
639
- // 이미지 요청 사전 게이트(R5): 배정된 worker 의 capability + 적용 모델 멀티모달.
640
- // 불충족이면 turn 을 실행하지 않고 명시적 에러.
641
- if (req.imageGeneration) {
642
- const reason = await worker.checkImageGenerationSupport(req.model);
643
- if (reason) throw new ImageGenerationError("gate", reason);
644
- }
645
-
646
- const turnReq = this.buildTurnRequest(req, reuseThreadId);
647
- const result = await worker.executeTurn(turnReq, reuseThreadId);
648
-
649
- // 이미지 0개 실패 분류(R6): tool 미호출(재시도 무익) vs 시도 후 미완성(재시도 후보).
650
- if (req.imageGeneration && (!result.images || result.images.length === 0)) {
651
- throw result.imageAttempted
652
- ? new ImageGenerationError("incomplete", "image tool ran but produced no completed image")
653
- : new ImageGenerationError("not_called", "model did not call the image_generation tool");
654
- }
655
-
656
- return {
657
- text: result.text,
658
- tokenName: worker.tokenName,
659
- usage: result.usage,
660
- durationMs: result.durationMs,
661
- ttftMs: result.ttftMs,
662
- model: result.model,
663
- threadCoord: {
664
- workerId: makeOpenAIWorkerId(worker.tokenId, worker.workerIndex),
665
- threadId: result.threadId,
666
- epoch: worker.epoch,
667
- },
668
- images: result.images,
290
+ const startedAt = Date.now();
291
+ let firstDeltaAt: number | undefined;
292
+ let text = "";
293
+ let usage = {
294
+ totalTokens: 0,
295
+ inputTokens: 0,
296
+ outputTokens: 0,
297
+ cachedInputTokens: 0,
298
+ reasoningOutputTokens: 0,
669
299
  };
670
- }
671
-
672
- async executeStreamTurn(
673
- worker: CodexAppServerWorker,
674
- req: GenerateRequest,
675
- cb: GenerateStreamCallbacks,
676
- reuseThreadId?: string,
677
- ): Promise<void> {
678
- const turnReq = this.buildTurnRequest(req, reuseThreadId);
679
- // worker 의 TurnResult 에 tokenName/threadCoord 를 붙여 상위(GenerateResult)로 올린다.
680
- // threadId 는 새 thread 면 onThreadId 로 확정되므로 미리 보관해 두고 onComplete 때 읽는다.
681
- let resolvedThreadId = reuseThreadId ?? "";
682
- const wrappedCb: StreamCallbacks = {
683
- ...cb,
684
- onThreadId: (threadId) => {
685
- resolvedThreadId = threadId;
686
- cb.onThreadId?.(threadId);
687
- },
688
- onComplete: (result) => {
689
- cb.onComplete({
690
- ...result,
691
- tokenName: worker.tokenName,
692
- threadCoord: {
693
- workerId: makeOpenAIWorkerId(worker.tokenId, worker.workerIndex),
694
- threadId: resolvedThreadId,
695
- epoch: worker.epoch,
696
- },
697
- });
698
- },
699
- };
700
- await worker.executeTurnStream(turnReq, wrappedCb, reuseThreadId);
701
- }
702
-
703
- // ── Spawn ───────────────────────────────────────────────────────
704
-
705
- async spawnWorkers(
706
- tokenId: number,
707
- tokenName: string,
708
- credentials: OpenAICredentials,
709
- quotaThreshold?: number | null,
710
- weight = 1,
711
- ): Promise<void> {
712
- if (this.startingTokenIds.has(tokenId)) return;
713
- this.startingTokenIds.add(tokenId);
714
- this.setTokenMetadata(tokenId, tokenName, credentials, quotaThreshold, weight);
715
- const expectedMetadata = this.tokenMetadata.get(tokenId);
716
- const workers: CodexAppServerWorker[] = [];
300
+ const images: GeneratedImage[] = [];
301
+ let imageAttempted = false;
302
+ let servingModel = req.model ?? "";
303
+ const metadata = selection.metadata;
304
+ const clientEntry = this.acquireClient(selection);
717
305
  try {
718
- for (let i = 0; i < this.poolConfig.minWorkersPerToken; i++) {
719
- if (i > 0) await sleep(SPAWN_INTERVAL_MS);
720
- const worker = await this.spawnSingleWorker(tokenId, tokenName, credentials, i);
721
- if (worker) workers.push(worker);
722
- }
723
-
724
- if (
725
- !this.stopped &&
726
- expectedMetadata?.active &&
727
- this.tokenMetadata.get(tokenId) === expectedMetadata &&
728
- !this.workerPool.has(tokenId)
729
- ) {
730
- if (workers.length > 0) this.workerPool.set(tokenId, workers);
731
- } else {
732
- await Promise.allSettled(workers.map((worker) => worker.kill()));
306
+ for await (const event of clientEntry.client.responses(
307
+ requestOptions(req),
308
+ req.abortSignal,
309
+ )) {
310
+ if (event.type === "text-delta") {
311
+ firstDeltaAt ??= Date.now();
312
+ text += event.text;
313
+ onDelta?.(event.text);
314
+ } else if (event.type === "image") {
315
+ imageAttempted = true;
316
+ images.push({ data: event.base64, revisedPrompt: event.revisedPrompt ?? null });
317
+ } else if (event.type === "output-item" && event.item.type === "image_generation_call") {
318
+ imageAttempted = true;
319
+ } else if (event.type === "completed" && event.usage) {
320
+ servingModel = event.model ?? servingModel;
321
+ usage = {
322
+ totalTokens: event.usage.totalTokens,
323
+ inputTokens: event.usage.inputTokens,
324
+ outputTokens: event.usage.outputTokens,
325
+ cachedInputTokens: event.usage.cachedInputTokens,
326
+ reasoningOutputTokens: event.usage.reasoningTokens,
327
+ };
328
+ } else if (event.type === "completed") {
329
+ servingModel = event.model ?? servingModel;
330
+ } else if (event.type === "error") {
331
+ if (req.imageGeneration)
332
+ throw new ImageGenerationError("incomplete", event.error.message);
333
+ throw event.error;
334
+ }
733
335
  }
734
336
  } finally {
735
- this.startingTokenIds.delete(tokenId);
337
+ this.releaseClient(clientEntry);
736
338
  }
737
- }
738
-
739
- async spawnSingleWorker(
740
- tokenId: number,
741
- tokenName: string,
742
- credentials: OpenAICredentials,
743
- workerIndex: number,
744
- ): Promise<CodexAppServerWorker | null> {
745
- const worker = new CodexAppServerWorker({
746
- tokenId,
747
- tokenName,
748
- accessToken: credentials.accessToken,
749
- accountId: credentials.accountId,
750
- planType: credentials.planType,
751
- workerIndex,
752
- });
753
-
754
- worker.onReady = () => this.requestDrainQueue();
755
- worker.onTerminalFailure = () => {
756
- void this.handleWorkerTerminalFailure(worker).catch((e) =>
757
- logger.warn(
758
- `terminal worker cleanup failed: ${tokenName}[${workerIndex}]: ${(e as Error).message}`,
759
- ),
339
+ if (req.imageGeneration && images.length === 0) {
340
+ throw new ImageGenerationError(
341
+ imageAttempted ? "incomplete" : "not_called",
342
+ imageAttempted
343
+ ? "image generation did not complete"
344
+ : "model did not call image generation",
760
345
  );
761
- };
762
-
763
- worker.setServerRequestHandler(async (method) => {
764
- if (method === "account/chatgptAuthTokens/refresh") {
765
- return handleChatgptAuthTokensRefresh(tokenId);
766
- }
767
- throw new Error(`unhandled server-request: ${method}`);
768
- });
769
-
770
- try {
771
- await worker.initialize();
772
- logger.info(`worker spawned: ${tokenName}[${workerIndex}]`);
773
- return worker;
774
- } catch (e) {
775
- logger.warn(`worker spawn failed: ${tokenName}[${workerIndex}]: ${(e as Error).message}`);
776
- await worker.kill().catch(() => {});
777
- return null;
778
346
  }
347
+ return {
348
+ text,
349
+ tokenName: metadata.name,
350
+ usage,
351
+ durationMs: Date.now() - startedAt,
352
+ ttftMs: firstDeltaAt === undefined ? null : firstDeltaAt - startedAt,
353
+ model: servingModel,
354
+ threadCoord: { workerId: selection.tokenId, threadId: req.promptCacheKey ?? "", epoch: -1 },
355
+ ...(images.length ? { images } : {}),
356
+ };
779
357
  }
780
358
 
781
- async evaluateAutoscaling(): Promise<void> {
782
- if (this.stopped) return;
783
- this.sweepIdleWorkerThreads();
784
- const minimumDeficitTokenIds = await this.ensureMinimumWorkersOneStep();
785
- if (!this.poolConfig.autoscale || this.stopped) return;
786
- if (this.queue.length > 0) {
787
- // baseline 복구를 시도한 token만 같은 evaluation의 demand expansion에서 제외한다.
788
- // 다른 정상 token의 확장까지 막지는 않는다.
789
- await this.scaleUpOneStep(minimumDeficitTokenIds);
790
- return;
791
- }
792
- if (Date.now() - this.lastRequestAt >= this.poolConfig.scaleDownIdleMs) {
793
- await this.scaleDownOneStep();
794
- }
795
- }
796
-
797
- async scaleUpOneStep(excludedTokenIds = new Set<number>()): Promise<void> {
798
- if (!this.poolConfig.autoscale || this.stopped) return;
799
- await this.runScaling(async () => {
800
- const candidates = [...this.tokenMetadata.entries()].filter(([tokenId, metadata]) => {
801
- if (
802
- !metadata.active ||
803
- this.startingTokenIds.has(tokenId) ||
804
- excludedTokenIds.has(tokenId) ||
805
- this.quotaBlockedTokenIds.has(tokenId)
806
- ) {
807
- return false;
808
- }
809
- return (this.workerPool.get(tokenId)?.length ?? 0) < this.poolConfig.maxWorkersPerToken;
810
- });
811
- if (candidates.length === 0) return;
812
-
813
- const projectedWorkerCount = this.workerCount + candidates.length;
814
- const projectedRssGiB = estimateOpenAIWorkerRssGiB(projectedWorkerCount);
815
- if (projectedRssGiB > this.poolConfig.maxEstimatedRssGiB) {
816
- logger.warn(
817
- `openai autoscale blocked: estimated RSS ${projectedRssGiB.toFixed(2)}GiB exceeds ${this.poolConfig.maxEstimatedRssGiB.toFixed(2)}GiB`,
818
- );
819
- return;
820
- }
821
-
822
- const hostAvailableGiB = this.getHostAvailableGiB();
823
- if (hostAvailableGiB < this.poolConfig.minHostAvailableGiB) {
824
- logger.warn(
825
- `openai autoscale blocked: host available ${hostAvailableGiB.toFixed(2)}GiB below ${this.poolConfig.minHostAvailableGiB.toFixed(2)}GiB`,
826
- );
827
- return;
828
- }
829
-
830
- const spawned = await Promise.all(
831
- candidates.map(([tokenId, metadata]) => this.spawnAndCommitWorker(tokenId, metadata, true)),
832
- );
833
-
834
- const added = spawned.filter((worker) => worker !== null).length;
835
- if (added > 0) {
836
- logger.info(
837
- `openai autoscale up: +${added} workers (${this.workerCount} total, queue ${this.queue.length})`,
838
- );
839
- this.requestDrainQueue();
840
- if (this.queue.length > 0) {
841
- const timer = setTimeout(
842
- () => this.requestAutoscaleEvaluation(),
843
- Math.min(this.poolConfig.scaleIntervalMs, 1_000),
844
- );
845
- timer.unref?.();
846
- }
847
- }
848
- });
849
- }
850
-
851
- async ensureMinimumWorkersOneStep(): Promise<Set<number>> {
852
- const minimumDeficitTokenIds = new Set<number>();
853
- if (this.stopped) return minimumDeficitTokenIds;
854
- await this.runScaling(async () => {
855
- const candidates = [...this.tokenMetadata.entries()].filter(([tokenId, metadata]) => {
856
- if (!metadata.active || this.startingTokenIds.has(tokenId)) return false;
857
- return (this.workerPool.get(tokenId)?.length ?? 0) < this.poolConfig.minWorkersPerToken;
858
- });
859
- if (candidates.length === 0) return;
860
- candidates.forEach(([tokenId]) => minimumDeficitTokenIds.add(tokenId));
861
-
862
- const spawned = await Promise.all(
863
- candidates.map(([tokenId, metadata]) =>
864
- this.spawnAndCommitWorker(tokenId, metadata, false),
865
- ),
359
+ /** 세대가 바뀐 client 는 사용 중인 요청이 끝난 뒤에 닫는다. */
360
+ private acquireClient(selection: TokenSelection): ClientEntry {
361
+ const metadata = selection.metadata;
362
+ let entry = this.clients.get(selection.tokenId);
363
+ if (entry && entry.generation !== metadata.generation) {
364
+ this.retireClient(selection.tokenId);
365
+ entry = undefined;
366
+ }
367
+ if (!entry) {
368
+ const client = this.clientFactory(
369
+ {
370
+ credentials: {
371
+ accessToken: metadata.credentials.accessToken,
372
+ accountId: metadata.credentials.accountId,
373
+ },
374
+ transportKind: this.transportKind,
375
+ fetch: this.fetchImpl,
376
+ refreshCredentials: async () => {
377
+ const refreshed = await handleChatgptAuthTokensRefresh(selection.tokenId);
378
+ const current = this.tokenMetadata.get(selection.tokenId);
379
+ if (current)
380
+ current.credentials = {
381
+ ...current.credentials,
382
+ accessToken: refreshed.accessToken,
383
+ accountId: refreshed.chatgptAccountId,
384
+ };
385
+ return { accessToken: refreshed.accessToken, accountId: refreshed.chatgptAccountId };
386
+ },
387
+ },
388
+ selection.tokenId,
866
389
  );
867
- const added = spawned.filter((worker) => worker !== null).length;
868
- if (added > 0) {
869
- logger.info(`openai worker pool repaired: +${added} workers (${this.workerCount} total)`);
870
- this.requestDrainQueue();
871
- if (this.queue.length > 0) {
872
- const timer = setTimeout(
873
- () => this.requestAutoscaleEvaluation(),
874
- Math.min(this.poolConfig.scaleIntervalMs, 1_000),
875
- );
876
- timer.unref?.();
877
- }
878
- }
879
- });
880
- return minimumDeficitTokenIds;
881
- }
882
-
883
- async scaleDownOneStep(): Promise<void> {
884
- if (!this.poolConfig.autoscale || this.stopped) return;
885
- await this.runScaling(async () => {
886
- const removed: CodexAppServerWorker[] = [];
887
- for (const tokenId of this.tokenMetadata.keys()) {
888
- const workers = this.workerPool.get(tokenId) ?? [];
889
- if (workers.length <= this.poolConfig.minWorkersPerToken) continue;
890
-
891
- const worker = workers
892
- .toSorted((a, b) => b.workerIndex - a.workerIndex)
893
- .find((entry) => entry.hasCapacity);
894
- if (!worker) continue;
895
-
896
- this.workerPool.set(
897
- tokenId,
898
- workers.filter((entry) => entry !== worker),
899
- );
900
- removed.push(worker);
390
+ entry = { generation: metadata.generation, client, inFlight: 0, retired: false };
391
+ this.clients.set(selection.tokenId, entry);
392
+ }
393
+ entry.inFlight++;
394
+ return entry;
395
+ }
396
+
397
+ private releaseClient(entry: ClientEntry): void {
398
+ entry.inFlight = Math.max(0, entry.inFlight - 1);
399
+ if (entry.retired && entry.inFlight === 0) {
400
+ this.retiredClients.delete(entry);
401
+ entry.client.close?.();
402
+ }
403
+ }
404
+
405
+ /** map 에서 떼어내고, 진행 중인 요청이 없을 때만 즉시 닫는다. */
406
+ private retireClient(tokenId: number): void {
407
+ const entry = this.clients.get(tokenId);
408
+ if (!entry) return;
409
+ this.clients.delete(tokenId);
410
+ entry.retired = true;
411
+ if (entry.inFlight === 0) entry.client.close?.();
412
+ else this.retiredClients.add(entry);
413
+ }
414
+
415
+ /**
416
+ * 토큰 선택 — quota gate 를 통과한 active 토큰 중에서 고른다. cache affinity 선호
417
+ * 토큰이 eligible 하면 그 판정만으로 즉시 결정하고(전체 sweep 생략, weighted 상태
418
+ * 비변경), 아니면 병렬 quota 판정 후 smooth weighted round-robin. 동시성 상한이
419
+ * 없으므로 "빈 자리" 개념도 없다 — 선택 즉시 실행이다.
420
+ */
421
+ private async selectToken(
422
+ preferredTokenId: number | undefined,
423
+ signal: AbortSignal,
424
+ ): Promise<TokenSelection> {
425
+ if (preferredTokenId !== undefined) {
426
+ const preferred = this.tokenMetadata.get(preferredTokenId);
427
+ if (preferred?.active && (await this.isQuotaEligible(preferredTokenId, preferred, signal))) {
428
+ return { tokenId: preferredTokenId, metadata: preferred };
901
429
  }
902
-
903
- if (removed.length === 0) return;
904
- await Promise.allSettled(removed.map((worker) => worker.kill()));
905
- logger.info(`openai autoscale down: -${removed.length} workers (${this.workerCount} total)`);
906
- });
907
- }
908
-
909
- private nextAvailableWorkerIndex(workers: CodexAppServerWorker[]): number {
910
- const used = new Set(workers.map((worker) => worker.workerIndex));
911
- for (let index = 0; index < this.poolConfig.maxWorkersPerToken; index++) {
912
- if (!used.has(index)) return index;
913
- }
914
- return this.poolConfig.maxWorkersPerToken;
915
- }
916
-
917
- private sweepIdleWorkerThreads(): void {
918
- for (const worker of [...this.workerPool.values()].flat()) {
919
- // turn 중 unsubscribe하면 해당 connection으로 notification이 더 오지 않아
920
- // 실행 중 요청이 timeout될 수 있다. ready + idle worker만 sweep한다.
921
- if (worker.isReady && worker.hasCapacity) worker.sweepIdleThreads();
922
430
  }
923
- }
924
431
 
925
- private async spawnAndCommitWorker(
926
- tokenId: number,
927
- metadata: TokenMetadata,
928
- respectQuotaBlock: boolean,
929
- ): Promise<CodexAppServerWorker | null> {
930
- const expectedWorkers = this.workerPool.get(tokenId);
931
- const workerIndex = this.nextAvailableWorkerIndex(expectedWorkers ?? []);
932
- if (workerIndex >= this.poolConfig.maxWorkersPerToken) return null;
933
-
934
- const worker = await this.spawnSingleWorker(
935
- tokenId,
936
- metadata.name,
937
- metadata.credentials,
938
- workerIndex,
432
+ // 토큰별 quota 판정은 서로 독립이라 병렬로 — 직렬 대기는 콜드 캐시에서
433
+ // 토큰 수 × 조회 지연만큼 요청 시작을 늦춘다.
434
+ const checks = await Promise.all(
435
+ [...this.tokenMetadata.entries()]
436
+ .filter(([, token]) => token.active)
437
+ .map(async ([id, token]) => ({
438
+ id,
439
+ token,
440
+ eligible: await this.isQuotaEligible(id, token, signal),
441
+ })),
939
442
  );
940
- if (!worker) return null;
941
-
942
- const currentMetadata = this.tokenMetadata.get(tokenId);
943
- const currentWorkers = this.workerPool.get(tokenId);
944
- if (
945
- !currentMetadata?.active ||
946
- currentMetadata !== metadata ||
947
- currentWorkers !== expectedWorkers ||
948
- (respectQuotaBlock && this.quotaBlockedTokenIds.has(tokenId)) ||
949
- currentWorkers?.some((entry) => entry.workerIndex === workerIndex)
950
- ) {
951
- await worker.kill().catch(() => {});
952
- return null;
443
+ const eligible = new Set(checks.filter((c) => c.eligible).map((c) => c.id));
444
+ if (eligible.size === 0) {
445
+ const over = checks
446
+ .filter(
447
+ (c) =>
448
+ !c.eligible && c.token.quotaThreshold !== null && c.token.quotaThreshold !== undefined,
449
+ )
450
+ .map((c) => ({ name: c.token.name, threshold: c.token.quotaThreshold as number }));
451
+ if (over.length) {
452
+ logger.warn("quota_threshold gate: all_exceeded", {
453
+ provider: "openai",
454
+ overThresholdTokens: over,
455
+ });
456
+ throw new QuotaThresholdExceededError(quotaMessage(over));
457
+ }
458
+ throw new Error("NO_OPENAI_WORKERS");
953
459
  }
954
-
955
- const nextWorkers = currentWorkers ?? [];
956
- nextWorkers.push(worker);
957
- nextWorkers.sort((a, b) => a.workerIndex - b.workerIndex);
958
- if (!currentWorkers) this.workerPool.set(tokenId, nextWorkers);
959
- return worker;
460
+ const selected = this.selector.select(eligible);
461
+ const metadata = selected !== null ? this.tokenMetadata.get(selected) : undefined;
462
+ if (selected === null || !metadata) throw new Error("NO_OPENAI_WORKERS");
463
+ return { tokenId: selected, metadata };
960
464
  }
961
465
 
962
- async handleWorkerTerminalFailure(worker: CodexAppServerWorker): Promise<void> {
963
- const workers = this.workerPool.get(worker.tokenId);
964
- if (!workers?.includes(worker)) return;
965
-
966
- await worker.kill().catch(() => {});
967
-
968
- const currentWorkers = this.workerPool.get(worker.tokenId);
969
- if (!currentWorkers?.includes(worker)) return;
970
- const remaining = currentWorkers.filter((entry) => entry !== worker);
971
- if (remaining.length > 0) {
972
- this.workerPool.set(worker.tokenId, remaining);
466
+ private setToken(
467
+ id: number,
468
+ name: string,
469
+ credentials: OpenAICredentials,
470
+ quotaThreshold: number | null | undefined,
471
+ weight: number,
472
+ active: boolean,
473
+ ): void {
474
+ const old = this.tokenMetadata.get(id);
475
+ if (old) {
476
+ Object.assign(old, {
477
+ name,
478
+ credentials,
479
+ quotaThreshold,
480
+ weight,
481
+ active,
482
+ generation: old.generation + 1,
483
+ });
973
484
  } else {
974
- this.workerPool.delete(worker.tokenId);
975
- }
976
- logger.warn(
977
- `terminal worker removed: ${worker.tokenName}[${worker.workerIndex}] (${remaining.length} remaining)`,
978
- );
979
- this.requestAutoscaleEvaluation();
980
- }
981
-
982
- private requestAutoscaleEvaluation(): void {
983
- if (this.stopped) return;
984
- void this.evaluateAutoscaling().catch((e) =>
985
- logger.warn(`openai autoscale evaluation failed: ${(e as Error).message}`),
986
- );
987
- }
988
-
989
- private async runScaling(task: () => Promise<void>): Promise<void> {
990
- if (this.scalingPromise) {
991
- await this.scalingPromise;
992
- return;
485
+ this.tokenMetadata.set(id, {
486
+ name,
487
+ credentials,
488
+ quotaThreshold,
489
+ weight,
490
+ active,
491
+ generation: 1,
492
+ });
993
493
  }
994
- const scaling = task().finally(() => {
995
- if (this.scalingPromise === scaling) this.scalingPromise = null;
996
- });
997
- this.scalingPromise = scaling;
998
- await scaling;
494
+ this.selector.setToken(id, weight);
495
+ this.invalidateRateLimitsCache(id);
496
+ this.quotaBlocked.delete(id);
999
497
  }
1000
498
 
1001
- // ── Rate limits ─────────────────────────────────────────────────
1002
-
1003
- rateLimitsCache = new Map<number, RateLimitsCacheEntry>();
1004
- static readonly RATE_LIMITS_CACHE_TTL = 60_000;
1005
-
1006
- async getRateLimitsByTokenId(tokenId: number): Promise<OpenAIRateLimitsWithMeta> {
1007
- const generation = this.rateLimitsGenerationByToken.get(tokenId) ?? 0;
499
+ async getRateLimitsByTokenId(
500
+ tokenId: number,
501
+ signal?: AbortSignal,
502
+ ): Promise<OpenAIRateLimitsWithMeta> {
503
+ const token = this.tokenMetadata.get(tokenId);
504
+ if (!token) throw new Error(`openai token ${tokenId} not found`);
1008
505
  const cached = this.rateLimitsCache.get(tokenId);
1009
506
  if (
1010
507
  cached &&
1011
- cached.generation === generation &&
508
+ cached.generation === token.generation &&
1012
509
  Date.now() - cached.cachedAt < OpenAIDispatcher.RATE_LIMITS_CACHE_TTL
1013
- ) {
1014
- return { data: cached.data, cachedAt: cached.cachedAt };
1015
- }
1016
-
1017
- const worker = (this.workerPool.get(tokenId) ?? []).find((w) => w.isReady);
1018
- if (!worker) throw new Error("no ready openai workers");
1019
- const data = (await worker.getRateLimits()) as GetAccountRateLimitsResponse;
1020
- const entry: RateLimitsCacheEntry = { data, cachedAt: Date.now(), generation };
1021
- if ((this.rateLimitsGenerationByToken.get(tokenId) ?? 0) === generation) {
1022
- this.rateLimitsCache.set(tokenId, entry);
1023
- }
1024
- return { data: entry.data, cachedAt: entry.cachedAt };
1025
- }
1026
-
1027
- private requestDrainQueue(): void {
1028
- void this.drainQueue().catch((e) => logger.warn(`drainQueue failed: ${(e as Error).message}`));
1029
- }
1030
-
1031
- private invalidateRateLimitsCache(tokenId: number): void {
1032
- this.rateLimitsCache.delete(tokenId);
1033
- this.rateLimitsGenerationByToken.set(
1034
- tokenId,
1035
- (this.rateLimitsGenerationByToken.get(tokenId) ?? 0) + 1,
1036
- );
510
+ )
511
+ return cached;
512
+
513
+ // single-flight: 동시성 상한이 없어진 뒤로 TTL 만료 순간 동시 요청 수만큼 같은
514
+ // 조회가 몰릴 수 있다 — 진행 중인 fetch 를 공유한다. 최초 호출자의 abort 로
515
+ // 공유 조회가 실패해도 소비처(isQuotaEligible)가 fail-open 으로 처리한다.
516
+ const pending = this.pendingRateLimits.get(tokenId);
517
+ if (pending) return pending;
518
+ const fetchPromise = (async () => {
519
+ const result = await readOpenAIQuotaUsage({
520
+ credentials: token.credentials,
521
+ fetch: this.fetchImpl,
522
+ ...(signal ? { signal } : {}),
523
+ });
524
+ if (result.kind === "lookup_failed") throw new Error(result.reason);
525
+ if (!result.raw) throw new Error("OpenAI quota response missing raw rate limits");
526
+ const entry = { data: result.raw, cachedAt: Date.now(), generation: token.generation };
527
+ if (this.tokenMetadata.get(tokenId) === token) this.rateLimitsCache.set(tokenId, entry);
528
+ return entry;
529
+ })().finally(() => this.pendingRateLimits.delete(tokenId));
530
+ this.pendingRateLimits.set(tokenId, fetchPromise);
531
+ return fetchPromise;
1037
532
  }
1038
533
 
1039
- private setTokenMetadata(
534
+ private async isQuotaEligible(
1040
535
  id: number,
1041
- name: string,
1042
- credentials: OpenAICredentials,
1043
- quotaThreshold: number | null | undefined,
1044
- weight: number,
1045
- ): void {
1046
- this.tokenMetadata.set(id, {
1047
- name,
1048
- credentials,
1049
- quotaThreshold,
1050
- weight,
1051
- active: this.tokenMetadata.get(id)?.active ?? true,
1052
- });
1053
- this.weightedSelector.setToken(id, weight);
1054
- }
1055
-
1056
- private hasActiveTokenCandidate(excludedTokenIds: Set<number>): boolean {
1057
- return [...this.tokenMetadata.entries()].some(
1058
- ([tokenId, metadata]) => metadata.active && !excludedTokenIds.has(tokenId),
1059
- );
1060
- }
1061
-
1062
- private getQuotaThreshold(tokenId: number): number | null | undefined {
1063
- return this.tokenMetadata.get(tokenId)?.quotaThreshold;
1064
- }
1065
-
1066
- private hasQuotaThreshold(tokenId: number): boolean {
1067
- const threshold = this.getQuotaThreshold(tokenId);
1068
- return threshold !== undefined && threshold !== null;
1069
- }
1070
-
1071
- private async resolveTokenEligibility(excludedTokenIds: Set<number>): Promise<TokenEligibility> {
1072
- const workers = this.getAllReadyActiveWorkers();
1073
- const byToken = new Map<number, string>();
1074
- for (const worker of workers) {
1075
- if (!byToken.has(worker.tokenId)) byToken.set(worker.tokenId, worker.tokenName);
1076
- }
1077
-
1078
- const readyActiveTokenIds = new Set(byToken.keys());
1079
- const eligibleTokenIds = new Set<number>();
1080
- const overThresholdTokens: Array<{ tokenName: string; threshold: number }> = [];
1081
- let thresholdedTokenCount = 0;
1082
-
1083
- const entries = Array.from(byToken.entries());
1084
- const checks = await Promise.allSettled(
1085
- entries.map(async ([tokenId, tokenName]) => {
1086
- if (excludedTokenIds.has(tokenId)) {
1087
- thresholdedTokenCount++;
1088
- return { tokenId, tokenName, eligible: false };
1089
- }
1090
- if (!this.hasQuotaThreshold(tokenId)) {
1091
- return { tokenId, tokenName, eligible: true };
1092
- }
1093
- thresholdedTokenCount++;
1094
- return {
1095
- tokenId,
1096
- tokenName,
1097
- eligible: await this.isTokenQuotaEligible(tokenId, tokenName),
1098
- };
1099
- }),
1100
- );
1101
-
1102
- checks.forEach((check, index) => {
1103
- if (check.status === "fulfilled") {
1104
- if (check.value.eligible) {
1105
- eligibleTokenIds.add(check.value.tokenId);
1106
- } else {
1107
- const threshold = this.getQuotaThreshold(check.value.tokenId);
1108
- if (threshold !== undefined && threshold !== null) {
1109
- overThresholdTokens.push({ tokenName: check.value.tokenName, threshold });
1110
- }
1111
- }
1112
- return;
1113
- }
1114
-
1115
- const entry = entries[index];
1116
- if (entry) {
1117
- const [tokenId, tokenName] = entry;
1118
- this.logQuotaLookupFailOpen(tokenId, tokenName, String(check.reason));
1119
- eligibleTokenIds.add(tokenId);
1120
- }
1121
- });
1122
-
1123
- return { readyActiveTokenIds, eligibleTokenIds, overThresholdTokens, thresholdedTokenCount };
1124
- }
1125
-
1126
- private async isTokenQuotaEligible(
1127
- tokenId: number,
1128
- tokenName: string,
1129
- excludedTokenIds?: Set<number>,
536
+ token: TokenMetadata,
537
+ signal?: AbortSignal,
1130
538
  ): Promise<boolean> {
1131
- for (;;) {
1132
- const tokenMetadata = this.tokenMetadata.get(tokenId);
1133
- const threshold = tokenMetadata?.quotaThreshold;
1134
- if (!tokenMetadata?.active || threshold === undefined || threshold === null) {
1135
- this.quotaBlockedTokenIds.delete(tokenId);
1136
- return true;
1137
- }
1138
-
1139
- let result: OpenAIQuotaUsageResult;
1140
- try {
1141
- result = await readOpenAIQuotaUsage(() => this.getRateLimitsByTokenId(tokenId));
1142
- } catch (e) {
1143
- if (this.tokenMetadata.get(tokenId) !== tokenMetadata) continue;
1144
- this.quotaBlockedTokenIds.delete(tokenId);
1145
- this.logQuotaLookupFailOpen(tokenId, tokenMetadata.name ?? tokenName, (e as Error).message);
1146
- return true;
1147
- }
1148
-
1149
- if (this.tokenMetadata.get(tokenId) !== tokenMetadata) continue;
1150
-
1151
- if (result.kind === "lookup_failed") {
1152
- this.quotaBlockedTokenIds.delete(tokenId);
1153
- this.logQuotaLookupFailOpen(tokenId, tokenMetadata.name ?? tokenName, result.reason);
1154
- return true;
1155
- }
1156
-
1157
- if (result.utilizationPct >= threshold) {
1158
- const transitioned = !this.quotaBlockedTokenIds.has(tokenId);
1159
- this.quotaBlockedTokenIds.add(tokenId);
1160
- if (transitioned) {
1161
- this.logQuotaOverThreshold(tokenId, tokenMetadata.name ?? tokenName, threshold, result);
1162
- }
1163
- excludedTokenIds?.add(tokenId);
1164
- return false;
1165
- }
1166
-
1167
- if (this.quotaBlockedTokenIds.delete(tokenId)) {
1168
- this.logQuotaRecovered(tokenId, tokenMetadata.name ?? tokenName, threshold, result);
1169
- }
539
+ if (token.quotaThreshold === null || token.quotaThreshold === undefined) return true;
540
+ const generation = token.generation;
541
+ const result = await readOpenAIQuotaUsage(async () => this.getRateLimitsByTokenId(id, signal));
542
+ if (this.tokenMetadata.get(id) !== token || token.generation !== generation) return false;
543
+ if (result.kind === "lookup_failed") {
544
+ this.quotaBlocked.delete(id);
545
+ logger.warn("quota_threshold gate: lookup_fail_open", {
546
+ tokenId: id,
547
+ tokenName: token.name,
548
+ lookupReason: result.reason,
549
+ });
1170
550
  return true;
1171
551
  }
552
+ if (result.utilizationPct >= token.quotaThreshold) {
553
+ if (!this.quotaBlocked.has(id))
554
+ logger.info(
555
+ `quota_threshold gate: over_threshold ${token.name}[${id}] (${result.utilizationPct}% >= ${token.quotaThreshold}%)`,
556
+ );
557
+ this.quotaBlocked.add(id);
558
+ return false;
559
+ }
560
+ if (this.quotaBlocked.delete(id))
561
+ logger.info(
562
+ `quota_threshold gate: recovered ${token.name}[${id}] (${result.utilizationPct}% < ${token.quotaThreshold}%)`,
563
+ );
564
+ return true;
1172
565
  }
1173
566
 
1174
- private logQuotaOverThreshold(
1175
- tokenId: number,
1176
- tokenName: string,
1177
- threshold: number,
1178
- result: Extract<OpenAIQuotaUsageResult, { kind: "ok" }>,
1179
- ): void {
1180
- logger.info(
1181
- `quota_threshold gate: over_threshold ${tokenName}[${tokenId}] (${result.utilizationPct}% >= ${threshold}%)`,
1182
- {
1183
- tokenId,
1184
- tokenName,
1185
- provider: "openai",
1186
- threshold,
1187
- cachedUtilization: result.utilizationPct,
1188
- cacheAge: result.cacheAgeMs,
1189
- windowDurationMins: result.windowDurationMins,
1190
- resetsAt: result.resetsAt,
1191
- limitId: result.limitId,
1192
- reason: "over_threshold",
1193
- },
1194
- );
1195
- }
1196
-
1197
- private logQuotaRecovered(
1198
- tokenId: number,
1199
- tokenName: string,
1200
- threshold: number,
1201
- result: Extract<OpenAIQuotaUsageResult, { kind: "ok" }>,
1202
- ): void {
1203
- logger.info(
1204
- `quota_threshold gate: recovered ${tokenName}[${tokenId}] (${result.utilizationPct}% < ${threshold}%)`,
1205
- {
1206
- tokenId,
1207
- tokenName,
1208
- provider: "openai",
1209
- threshold,
1210
- cachedUtilization: result.utilizationPct,
1211
- cacheAge: result.cacheAgeMs,
1212
- windowDurationMins: result.windowDurationMins,
1213
- resetsAt: result.resetsAt,
1214
- limitId: result.limitId,
1215
- reason: "recovered",
1216
- },
1217
- );
567
+ private invalidateRateLimitsCache(id: number): void {
568
+ this.rateLimitsCache.delete(id);
1218
569
  }
1219
570
 
1220
- private logQuotaLookupFailOpen(tokenId: number, tokenName: string, reason: string): void {
1221
- const threshold = this.getQuotaThreshold(tokenId);
1222
- logger.warn("quota_threshold gate: lookup_fail_open", {
1223
- tokenId,
1224
- tokenName,
1225
- provider: "openai",
1226
- threshold,
1227
- reason: "lookup_fail_open",
1228
- lookupReason: reason,
1229
- });
571
+ get tokenCount(): number {
572
+ return [...this.tokenMetadata.values()].filter((t) => t.active).length;
1230
573
  }
1231
-
1232
- private throwQuotaThresholdExceeded(eligibility: TokenEligibility): never {
1233
- logger.warn("quota_threshold gate: all_exceeded", {
1234
- provider: "openai",
1235
- tokenCount: eligibility.readyActiveTokenIds.size,
1236
- thresholdedTokenCount: eligibility.thresholdedTokenCount,
1237
- overThresholdTokens: eligibility.overThresholdTokens,
1238
- reason: "all_exceeded",
1239
- });
1240
- throw new QuotaThresholdExceededError(
1241
- quotaThresholdExceededMessage("openai", eligibility.overThresholdTokens),
1242
- );
574
+ get inFlight(): number {
575
+ return this.inFlightCount;
1243
576
  }
1244
577
 
1245
- // ── Browser login flow ───────────────────────────────────────────
1246
-
1247
- pendingLogin: {
1248
- worker: CodexAppServerWorker;
578
+ /**
579
+ * 토큰별 쿼터 스냅샷 — 신선한(rate limits TTL 내) 캐시만 읽고 절대 fetch 하지 않는다.
580
+ * monit vitals 는 로그 폴링에 편승하는 값이라 여기서 네트워크를 타면 안 된다.
581
+ * threshold 미설정 토큰은 쿼터 판정을 돌지 않아 usedPercent 가 null 로 남을 수 있다.
582
+ */
583
+ get quotaByToken(): Array<{
1249
584
  name: string;
1250
- timer: ReturnType<typeof setTimeout>;
1251
- } | null = null;
1252
-
1253
- async startBrowserLogin(name: string): Promise<{ authUrl: string }> {
1254
- if (this.pendingLogin) {
1255
- this.pendingLogin.worker.kill().catch(() => {});
1256
- clearTimeout(this.pendingLogin.timer);
1257
- this.pendingLogin = null;
1258
- }
1259
-
1260
- const tempId = Date.now();
1261
- const worker = new CodexAppServerWorker({
1262
- tokenId: tempId,
1263
- tokenName: name,
1264
- accessToken: "",
1265
- accountId: "",
1266
- });
1267
-
1268
- const authUrl = await worker.startBrowserLogin();
1269
-
1270
- const timer = setTimeout(() => {
1271
- if (this.pendingLogin?.worker === worker) {
1272
- logger.warn(`browser login timeout for ${name}, killing worker`);
1273
- worker.kill().catch(() => {});
1274
- this.pendingLogin = null;
1275
- }
1276
- }, 300_000);
1277
-
1278
- this.pendingLogin = { worker, name, timer };
1279
- return { authUrl };
1280
- }
1281
-
1282
- get pendingLoginName(): string | null {
1283
- return this.pendingLogin?.name ?? null;
1284
- }
1285
-
1286
- async completeBrowserLogin(): Promise<{
1287
- accessToken: string;
1288
- refreshToken: string;
1289
- idToken?: string;
1290
- accountId: string;
585
+ usedPercent: number | null;
586
+ threshold: number | null;
587
+ blocked: boolean;
588
+ resetsAt: number | null;
1291
589
  }> {
1292
- if (!this.pendingLogin) throw new Error("no pending login");
1293
- const { worker, timer } = this.pendingLogin;
1294
-
1295
- try {
1296
- await worker.waitForBrowserLoginComplete();
1297
- const creds = await worker.readManagedCredentials();
1298
- if (!creds) throw new Error("failed to read credentials after login");
1299
- return creds;
1300
- } finally {
1301
- clearTimeout(timer);
1302
- this.pendingLogin = null;
1303
- await worker.kill().catch(() => {});
1304
- }
1305
- }
1306
-
1307
- // ── Stats ───────────────────────────────────────────────────────
1308
-
1309
- get workerCount(): number {
1310
- return [...this.workerPool.values()].flat().length;
1311
- }
1312
-
1313
- get readyWorkerCount(): number {
1314
- return [...this.workerPool.values()].flat().filter((w) => w.isReady).length;
1315
- }
1316
-
1317
- get queueLength(): number {
1318
- return this.queue.length;
1319
- }
1320
-
1321
- // Monit 표시용 — 토큰별 현재 워커 수 스냅샷 (이름순 정렬)
1322
- get workerCountsByToken(): Array<{ name: string; count: number }> {
1323
- return [...this.workerPool.entries()]
1324
- .map(([tokenId, workers]) => ({
1325
- name: workers[0]?.tokenName ?? `token ${tokenId}`,
1326
- count: workers.length,
1327
- }))
1328
- .filter((entry) => entry.count > 0)
590
+ const now = Date.now();
591
+ return [...this.tokenMetadata.entries()]
592
+ .map(([id, t]) => {
593
+ const cached = this.rateLimitsCache.get(id);
594
+ const fresh =
595
+ cached !== undefined &&
596
+ cached.generation === t.generation &&
597
+ now - cached.cachedAt < OpenAIDispatcher.RATE_LIMITS_CACHE_TTL;
598
+ const primary = fresh ? cached.data.rateLimits?.primary : undefined;
599
+ return {
600
+ name: t.name,
601
+ usedPercent: primary?.usedPercent ?? null,
602
+ threshold: t.quotaThreshold ?? null,
603
+ blocked: this.quotaBlocked.has(id),
604
+ // wham 의 resetsAt 은 unix 초 단위다(qgrid.frame unixSecondsToIso 와 동일 규약).
605
+ // 소비처가 단위를 추측하지 않도록 여기서 ms epoch 으로 정규화한다.
606
+ resetsAt:
607
+ primary?.resetsAt !== null && primary?.resetsAt !== undefined
608
+ ? primary.resetsAt * 1000
609
+ : null,
610
+ };
611
+ })
1329
612
  .toSorted((a, b) => a.name.localeCompare(b.name));
1330
613
  }
1331
614
  }