@omnicross/core 0.1.5 → 0.1.7

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 (231) hide show
  1. package/dist/ApiConverter.cjs +2 -2
  2. package/dist/ApiConverter.js +1 -1
  3. package/dist/{CompletionService-DdWaAxq0.d.ts → CompletionService-C3BX0Ovy.d.ts} +4 -3
  4. package/dist/{CompletionService-D3a47vdU.d.cts → CompletionService-kNA17cfI.d.cts} +4 -3
  5. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +8 -6
  6. package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -4
  7. package/dist/{chunk-3Z5BQZFM.cjs → chunk-235MXAGX.cjs} +3 -1
  8. package/dist/{chunk-HRRYG2AX.js → chunk-23S5OPIO.js} +10 -1
  9. package/dist/chunk-25GXJCEZ.cjs +40 -0
  10. package/dist/chunk-2E42SAW3.cjs +323 -0
  11. package/dist/chunk-2JYRIADS.js +40 -0
  12. package/dist/chunk-2Z4XM3H5.cjs +44 -0
  13. package/dist/{chunk-BODMAL6G.js → chunk-32O35CIF.js} +271 -91
  14. package/dist/chunk-3SCOLIPT.cjs +63 -0
  15. package/dist/{chunk-SYQF7OIR.js → chunk-3WD4HTR2.js} +2 -0
  16. package/dist/{chunk-CGKLE6IW.cjs → chunk-4BB343BI.cjs} +1489 -520
  17. package/dist/{chunk-VACWOIRE.cjs → chunk-4VZX5F4T.cjs} +39 -15
  18. package/dist/{chunk-5ZQBEOMD.js → chunk-5NJLQ6T6.js} +46 -12
  19. package/dist/chunk-5RSZYQJH.cjs +62 -0
  20. package/dist/chunk-6QQG7YG3.cjs +153 -0
  21. package/dist/{chunk-IFXJ2BG7.js → chunk-7C7DET6S.js} +51 -6
  22. package/dist/{chunk-IK3KE3AU.js → chunk-DE2SRBFZ.js} +1 -1
  23. package/dist/{chunk-FH2P4OCD.js → chunk-E3COOKUP.js} +1240 -271
  24. package/dist/{chunk-UHGVBFU3.js → chunk-EBLFCNPY.js} +38 -14
  25. package/dist/chunk-FU7EAR73.js +62 -0
  26. package/dist/chunk-FXR6N3SR.js +323 -0
  27. package/dist/{chunk-SUEGJ75D.cjs → chunk-GDIXXKF2.cjs} +46 -12
  28. package/dist/chunk-GFIZ6LQI.js +170 -0
  29. package/dist/chunk-GL6XM527.js +61 -0
  30. package/dist/chunk-HVBBDBS3.cjs +350 -0
  31. package/dist/{chunk-46ZIFWYG.cjs → chunk-IIRPUVPH.cjs} +7 -1
  32. package/dist/chunk-J3QQ6JS5.cjs +170 -0
  33. package/dist/{chunk-JWVTXXPX.cjs → chunk-KBM2W6UY.cjs} +8 -4
  34. package/dist/chunk-LB6EBS6Y.js +69 -0
  35. package/dist/{chunk-IWQAX3CS.js → chunk-LVUCAWMK.js} +1 -1
  36. package/dist/chunk-MKF46GNZ.js +350 -0
  37. package/dist/{chunk-HYN75H6G.cjs → chunk-MUHWHQVM.cjs} +1 -1
  38. package/dist/chunk-MYYR3HZL.js +44 -0
  39. package/dist/{chunk-MFZ5437A.js → chunk-N5T4M4GU.js} +1 -1
  40. package/dist/{chunk-5ENKBSWO.js → chunk-N7OOJI5V.js} +88 -8
  41. package/dist/chunk-NKVZ6Z3Y.cjs +61 -0
  42. package/dist/chunk-OF3BECU2.cjs +69 -0
  43. package/dist/{chunk-SNYBEXLB.cjs → chunk-OJGQKHN5.cjs} +3 -1
  44. package/dist/{chunk-DDMRUL76.cjs → chunk-OKMJLEXX.cjs} +5 -5
  45. package/dist/chunk-OPRS4IQZ.js +153 -0
  46. package/dist/chunk-OTZC4TNH.cjs +79 -0
  47. package/dist/{chunk-3Q6Z6JTO.cjs → chunk-OVQBNVSV.cjs} +287 -107
  48. package/dist/{chunk-4XMYPW46.cjs → chunk-OXHNSZ53.cjs} +84 -44
  49. package/dist/{chunk-C6OV7GCC.js → chunk-PEGTIPB3.js} +52 -12
  50. package/dist/chunk-PO3XB56Z.js +79 -0
  51. package/dist/{chunk-D3TDKWRP.js → chunk-RJ5ZGNI3.js} +54 -5
  52. package/dist/{chunk-PG7PS2NN.cjs → chunk-RJUONLUQ.cjs} +59 -10
  53. package/dist/{chunk-BPKCU575.js → chunk-SOO562NM.js} +3 -1
  54. package/dist/{chunk-6QZGDLL4.js → chunk-TOVPMMHM.js} +5 -1
  55. package/dist/{chunk-K52THW2C.cjs → chunk-V4TXMEJS.cjs} +5 -5
  56. package/dist/{chunk-G2UTNSGU.js → chunk-WNKWAEUR.js} +7 -1
  57. package/dist/{chunk-UNWKG6EI.cjs → chunk-XPIOJQS2.cjs} +51 -6
  58. package/dist/chunk-XXFYLL7R.js +63 -0
  59. package/dist/{chunk-KFI44N2R.cjs → chunk-YNJNTCSQ.cjs} +10 -1
  60. package/dist/{chunk-VQY5W4YW.cjs → chunk-YWL7YZWS.cjs} +90 -10
  61. package/dist/completion/ApiKeyPoolService.cjs +12 -0
  62. package/dist/completion/ApiKeyPoolService.d.cts +6 -0
  63. package/dist/completion/ApiKeyPoolService.d.ts +6 -0
  64. package/dist/completion/ApiKeyPoolService.js +12 -0
  65. package/dist/completion/CompletionService.cjs +30 -24
  66. package/dist/completion/CompletionService.d.cts +3 -1
  67. package/dist/completion/CompletionService.d.ts +3 -1
  68. package/dist/completion/CompletionService.js +29 -23
  69. package/dist/completion.cjs +32 -26
  70. package/dist/completion.d.cts +3 -1
  71. package/dist/completion.d.ts +3 -1
  72. package/dist/completion.js +31 -25
  73. package/dist/index.cjs +56 -29
  74. package/dist/index.d.cts +8 -8
  75. package/dist/index.d.ts +8 -8
  76. package/dist/index.js +61 -34
  77. package/dist/{keyPolicy-Cp0FntZl.d.cts → keyPolicy-zdWTu3CQ.d.cts} +1 -1
  78. package/dist/{keyPolicy-Cp0FntZl.d.ts → keyPolicy-zdWTu3CQ.d.ts} +1 -1
  79. package/dist/outbound-api/auditCapture.cjs +2 -2
  80. package/dist/outbound-api/auditCapture.d.cts +3 -4
  81. package/dist/outbound-api/auditCapture.d.ts +3 -4
  82. package/dist/outbound-api/auditCapture.js +1 -1
  83. package/dist/outbound-api/quotaWarn.d.cts +1 -1
  84. package/dist/outbound-api/quotaWarn.d.ts +1 -1
  85. package/dist/outbound-api/routeResolver.cjs +2 -2
  86. package/dist/outbound-api/routeResolver.d.cts +5 -3
  87. package/dist/outbound-api/routeResolver.d.ts +5 -3
  88. package/dist/outbound-api/routeResolver.js +1 -1
  89. package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -0
  90. package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -0
  91. package/dist/outbound-api/types.d.cts +4 -2
  92. package/dist/outbound-api/types.d.ts +4 -2
  93. package/dist/outbound-api.cjs +52 -25
  94. package/dist/outbound-api.d.cts +131 -87
  95. package/dist/outbound-api.d.ts +131 -87
  96. package/dist/outbound-api.js +55 -28
  97. package/dist/pipeline/AccountAllowanceScheduling.cjs +15 -0
  98. package/dist/pipeline/AccountAllowanceScheduling.d.cts +91 -0
  99. package/dist/pipeline/AccountAllowanceScheduling.d.ts +91 -0
  100. package/dist/pipeline/AccountAllowanceScheduling.js +15 -0
  101. package/dist/pipeline/AccountAllowanceStore.cjs +20 -0
  102. package/dist/pipeline/AccountAllowanceStore.d.cts +77 -0
  103. package/dist/pipeline/AccountAllowanceStore.d.ts +77 -0
  104. package/dist/pipeline/AccountAllowanceStore.js +20 -0
  105. package/dist/pipeline/AccountRouteActivity.cjs +10 -0
  106. package/dist/pipeline/AccountRouteActivity.d.cts +61 -0
  107. package/dist/pipeline/AccountRouteActivity.d.ts +61 -0
  108. package/dist/pipeline/AccountRouteActivity.js +10 -0
  109. package/dist/pipeline/AuthSource.d.cts +11 -2
  110. package/dist/pipeline/AuthSource.d.ts +11 -2
  111. package/dist/pipeline/BoundAccountSelectionError.cjs +10 -0
  112. package/dist/pipeline/BoundAccountSelectionError.d.cts +28 -0
  113. package/dist/pipeline/BoundAccountSelectionError.d.ts +28 -0
  114. package/dist/pipeline/BoundAccountSelectionError.js +10 -0
  115. package/dist/pipeline/LlmConfigProviderAuth.d.cts +1 -0
  116. package/dist/pipeline/LlmConfigProviderAuth.d.ts +1 -0
  117. package/dist/pipeline/ServerOverloadCounter.cjs +16 -0
  118. package/dist/pipeline/ServerOverloadCounter.d.cts +77 -0
  119. package/dist/pipeline/ServerOverloadCounter.d.ts +77 -0
  120. package/dist/pipeline/ServerOverloadCounter.js +16 -0
  121. package/dist/pipeline/SubscriptionAccountHealth.cjs +6 -2
  122. package/dist/pipeline/SubscriptionAccountHealth.d.cts +65 -8
  123. package/dist/pipeline/SubscriptionAccountHealth.d.ts +65 -8
  124. package/dist/pipeline/SubscriptionAccountHealth.js +5 -1
  125. package/dist/pipeline/SubscriptionAuthSource.cjs +5 -2
  126. package/dist/pipeline/SubscriptionAuthSource.d.cts +1 -0
  127. package/dist/pipeline/SubscriptionAuthSource.d.ts +1 -0
  128. package/dist/pipeline/SubscriptionAuthSource.js +4 -1
  129. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +8 -3
  130. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +8 -3
  131. package/dist/pipeline/executeProviderCall.cjs +2 -2
  132. package/dist/pipeline/executeProviderCall.d.cts +8 -3
  133. package/dist/pipeline/executeProviderCall.d.ts +8 -3
  134. package/dist/pipeline/executeProviderCall.js +1 -1
  135. package/dist/pipeline/resolveProviderChain.d.cts +2 -3
  136. package/dist/pipeline/resolveProviderChain.d.ts +2 -3
  137. package/dist/pipeline/resolveSubscriptionChain.d.cts +1 -0
  138. package/dist/pipeline/resolveSubscriptionChain.d.ts +1 -0
  139. package/dist/pipeline/upstreamFetch.cjs +5 -3
  140. package/dist/pipeline/upstreamFetch.d.cts +35 -6
  141. package/dist/pipeline/upstreamFetch.d.ts +35 -6
  142. package/dist/pipeline/upstreamFetch.js +4 -2
  143. package/dist/pipeline/upstreamTrace.cjs +4 -2
  144. package/dist/pipeline/upstreamTrace.d.cts +22 -8
  145. package/dist/pipeline/upstreamTrace.d.ts +22 -8
  146. package/dist/pipeline/upstreamTrace.js +3 -1
  147. package/dist/ports/pricing-store.d.cts +4 -3
  148. package/dist/ports/pricing-store.d.ts +4 -3
  149. package/dist/ports.d.cts +4 -3
  150. package/dist/ports.d.ts +4 -3
  151. package/dist/provider-proxy/ProviderProxy.cjs +30 -24
  152. package/dist/provider-proxy/ProviderProxy.d.cts +2 -0
  153. package/dist/provider-proxy/ProviderProxy.d.ts +2 -0
  154. package/dist/provider-proxy/ProviderProxy.js +29 -23
  155. package/dist/provider-proxy/identity/codexCliHeaders.cjs +10 -0
  156. package/dist/provider-proxy/identity/codexCliHeaders.d.cts +45 -0
  157. package/dist/provider-proxy/identity/codexCliHeaders.d.ts +45 -0
  158. package/dist/provider-proxy/identity/codexCliHeaders.js +10 -0
  159. package/dist/provider-proxy/ingress/providerProxyShared.cjs +32 -24
  160. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +44 -5
  161. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +44 -5
  162. package/dist/provider-proxy/ingress/providerProxyShared.js +31 -23
  163. package/dist/provider-proxy/matchText.cjs +4 -2
  164. package/dist/provider-proxy/matchText.d.cts +39 -6
  165. package/dist/provider-proxy/matchText.d.ts +39 -6
  166. package/dist/provider-proxy/matchText.js +3 -1
  167. package/dist/provider-proxy/types.d.cts +35 -2
  168. package/dist/provider-proxy/types.d.ts +35 -2
  169. package/dist/provider-proxy.cjs +30 -24
  170. package/dist/provider-proxy.d.cts +2 -0
  171. package/dist/provider-proxy.d.ts +2 -0
  172. package/dist/provider-proxy.js +29 -23
  173. package/dist/{routeResolver-C4T7yClx.d.ts → routeResolver-BxOfunbm.d.ts} +1 -1
  174. package/dist/{routeResolver-CB3tvJKy.d.cts → routeResolver-D5OzD0iM.d.cts} +1 -1
  175. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  176. package/dist/transformer/TransformerChainExecutor.js +1 -1
  177. package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -2
  178. package/dist/transformer/transformers/AnthropicTransformer.js +2 -1
  179. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  180. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  181. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  182. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  183. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -2
  184. package/dist/transformer/transformers/OpenAIResponseTransformer.d.cts +1 -1
  185. package/dist/transformer/transformers/OpenAIResponseTransformer.d.ts +1 -1
  186. package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -1
  187. package/dist/transformer/transformers/OpenAITransformer.cjs +6 -0
  188. package/dist/transformer/transformers/OpenAITransformer.d.cts +68 -0
  189. package/dist/transformer/transformers/OpenAITransformer.d.ts +68 -0
  190. package/dist/transformer/transformers/OpenAITransformer.js +6 -0
  191. package/dist/transformer/transformers.cjs +9 -14
  192. package/dist/transformer/transformers.d.cts +12 -48
  193. package/dist/transformer/transformers.d.ts +12 -48
  194. package/dist/transformer/transformers.js +11 -16
  195. package/dist/transformer/types.d.cts +17 -0
  196. package/dist/transformer/types.d.ts +17 -0
  197. package/dist/transformer.cjs +12 -12
  198. package/dist/transformer.d.cts +1 -2
  199. package/dist/transformer.d.ts +1 -2
  200. package/dist/transformer.js +12 -12
  201. package/dist/{types-lgPYQuZS.d.ts → types-CqZD77rS.d.ts} +173 -7
  202. package/dist/{types-B8Arpxn0.d.cts → types-gjJ5lJ5n.d.cts} +173 -7
  203. package/dist/usage/pricing-engine.cjs +2 -2
  204. package/dist/usage/pricing-engine.d.cts +29 -1
  205. package/dist/usage/pricing-engine.d.ts +29 -1
  206. package/dist/usage/pricing-engine.js +1 -1
  207. package/dist/usage/usage-recorder.cjs +2 -2
  208. package/dist/usage/usage-recorder.d.cts +5 -1
  209. package/dist/usage/usage-recorder.d.ts +5 -1
  210. package/dist/usage/usage-recorder.js +1 -1
  211. package/dist/usage.cjs +3 -3
  212. package/dist/usage.js +2 -2
  213. package/package.json +1 -1
  214. package/dist/chunk-7FEBOPJO.cjs +0 -50
  215. package/dist/chunk-DWKQZ2SK.cjs +0 -254
  216. package/dist/chunk-IAXWICZU.js +0 -69
  217. package/dist/chunk-IB3FDI4O.js +0 -50
  218. package/dist/chunk-OQWKZCXP.js +0 -242
  219. package/dist/chunk-QWBWGODS.cjs +0 -69
  220. package/dist/chunk-YMFAJFQT.cjs +0 -173
  221. package/dist/chunk-ZCIQ3L3R.cjs +0 -242
  222. package/dist/chunk-ZJZAOKI7.js +0 -254
  223. package/dist/chunk-ZLX3KGXX.js +0 -173
  224. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +0 -6
  225. package/dist/transformer/transformers/OpenCodeGoTransformer.d.cts +0 -51
  226. package/dist/transformer/transformers/OpenCodeGoTransformer.d.ts +0 -51
  227. package/dist/transformer/transformers/OpenCodeGoTransformer.js +0 -6
  228. package/dist/transformer/transformers/ReasoningTransformer.cjs +0 -6
  229. package/dist/transformer/transformers/ReasoningTransformer.d.cts +0 -47
  230. package/dist/transformer/transformers/ReasoningTransformer.d.ts +0 -47
  231. package/dist/transformer/transformers/ReasoningTransformer.js +0 -6
@@ -1,4 +1,9 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;// src/transformer/transformers/OpenAIResponseTransformer.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
+
3
+
4
+ var _chunk5RSZYQJHcjs = require('./chunk-5RSZYQJH.cjs');
5
+
6
+ // src/transformer/transformers/OpenAIResponseTransformer.ts
2
7
  var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
3
8
  static __initStatic() {this.TransformerName = "openai-response"}
4
9
  __init() {this.name = "openai-response"}
@@ -104,24 +109,37 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
104
109
  async transformRequestOut(request, _context) {
105
110
  const req = request;
106
111
  const messages = [];
112
+ let codexTools = null;
113
+ const instructions = typeof req.instructions === "string" ? req.instructions.trim() : "";
114
+ if (instructions) {
115
+ messages.push({ role: "system", content: instructions });
116
+ }
107
117
  if (req.input) {
108
118
  for (const item of req.input) {
109
119
  const entry = item;
110
- if (entry.type === "function_call_output") {
120
+ const itemType = typeof entry.type === "string" ? entry.type : void 0;
121
+ if (itemType && SKIPPED_INPUT_ITEM_TYPES.has(itemType)) continue;
122
+ if (itemType === "additional_tools") {
123
+ codexTools = collectCodexTools(entry);
124
+ continue;
125
+ }
126
+ if (itemType === "custom_tool_call_output") {
111
127
  messages.push({
112
128
  role: "tool",
113
- content: entry.output || "",
129
+ content: flattenContent(entry.output),
114
130
  tool_call_id: entry.call_id || void 0
115
131
  });
116
132
  continue;
117
133
  }
118
- if (entry.type === "function_call") {
134
+ if (itemType === "custom_tool_call") {
119
135
  const toolCall = {
120
136
  id: (_nullishCoalesce(entry.call_id, () => ( entry.id))) || "",
121
137
  type: "function",
122
138
  function: {
123
139
  name: entry.name || "",
124
- arguments: typeof entry.arguments === "string" ? entry.arguments : ""
140
+ arguments: JSON.stringify({
141
+ input: typeof entry.input === "string" ? entry.input : ""
142
+ })
125
143
  }
126
144
  };
127
145
  const last = messages[messages.length - 1];
@@ -132,17 +150,38 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
132
150
  }
133
151
  continue;
134
152
  }
135
- const role = entry.role;
136
- if (role === "developer") {
153
+ if (itemType === "function_call_output") {
137
154
  messages.push({
138
- role: "system",
139
- content: typeof entry.content === "string" ? entry.content : JSON.stringify(entry.content)
155
+ role: "tool",
156
+ content: flattenContent(entry.output),
157
+ tool_call_id: entry.call_id || void 0
140
158
  });
159
+ continue;
160
+ }
161
+ if (itemType === "function_call") {
162
+ const toolCall = {
163
+ id: (_nullishCoalesce(entry.call_id, () => ( entry.id))) || "",
164
+ type: "function",
165
+ function: {
166
+ name: entry.name || "",
167
+ arguments: typeof entry.arguments === "string" ? entry.arguments : ""
168
+ }
169
+ };
170
+ const last = messages[messages.length - 1];
171
+ if (last && last.role === "assistant") {
172
+ (last.tool_calls ??= []).push(toolCall);
173
+ } else {
174
+ messages.push({ role: "assistant", content: null, tool_calls: [toolCall] });
175
+ }
176
+ continue;
177
+ }
178
+ const role = entry.role;
179
+ const text = flattenContent(entry.content);
180
+ if (!text) continue;
181
+ if (role === "developer" || role === "system") {
182
+ messages.push({ role: "system", content: text });
141
183
  } else if (role === "user" || role === "assistant") {
142
- messages.push({
143
- role,
144
- content: typeof entry.content === "string" ? entry.content : JSON.stringify(entry.content)
145
- });
184
+ messages.push({ role, content: text });
146
185
  }
147
186
  }
148
187
  }
@@ -159,15 +198,32 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
159
198
  enabled: true
160
199
  };
161
200
  }
201
+ const tools = [];
162
202
  if (_optionalChain([req, 'access', _9 => _9.tools, 'optionalAccess', _10 => _10.length])) {
163
- result.tools = req.tools.filter((t) => t.type === "function").map((t) => ({
164
- type: "function",
165
- function: {
166
- name: t.name || "",
167
- description: t.description || "",
168
- parameters: t.parameters || {}
203
+ tools.push(
204
+ ...req.tools.filter((t) => t.type === "function").map((t) => ({
205
+ type: "function",
206
+ function: {
207
+ name: t.name || "",
208
+ description: t.description || "",
209
+ parameters: t.parameters || {}
210
+ }
211
+ }))
212
+ );
213
+ }
214
+ if (_optionalChain([codexTools, 'optionalAccess', _11 => _11.tools, 'access', _12 => _12.length])) {
215
+ const declared = new Set(tools.map((t) => t.function.name));
216
+ tools.push(...codexTools.tools.filter((t) => !declared.has(t.function.name)));
217
+ }
218
+ if (tools.length) result.tools = tools;
219
+ if (_optionalChain([codexTools, 'optionalAccess', _13 => _13.customToolNames, 'access', _14 => _14.length]) || Object.keys(_nullishCoalesce(_optionalChain([codexTools, 'optionalAccess', _15 => _15.toolNamespaces]), () => ( {}))).length) {
220
+ result.meta = {
221
+ ...result.meta,
222
+ codexTools: {
223
+ ...codexTools.customToolNames.length ? { customToolNames: codexTools.customToolNames } : {},
224
+ ...Object.keys(codexTools.toolNamespaces).length ? { toolNamespaces: codexTools.toolNamespaces } : {}
169
225
  }
170
- }));
226
+ };
171
227
  }
172
228
  return result;
173
229
  }
@@ -208,13 +264,14 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
208
264
  /**
209
265
  * Transform OpenAI CC response → Response API format
210
266
  */
211
- async transformResponseIn(response, _context) {
267
+ async transformResponseIn(response, context) {
212
268
  const contentType = _nullishCoalesce(response.headers.get("Content-Type"), () => ( ""));
269
+ const codexTools = _optionalChain([context, 'optionalAccess', _16 => _16.req, 'optionalAccess', _17 => _17.meta, 'optionalAccess', _18 => _18.codexTools]);
213
270
  if (contentType.includes("text/event-stream")) {
214
271
  if (!response.body) {
215
272
  throw new Error("Stream response body is null");
216
273
  }
217
- return new Response(convertOpenAIStreamToResponseApi(response.body), {
274
+ return new Response(convertOpenAIStreamToResponseApi(response.body, codexTools), {
218
275
  headers: {
219
276
  "Content-Type": "text/event-stream",
220
277
  "Cache-Control": "no-cache",
@@ -223,16 +280,114 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
223
280
  });
224
281
  }
225
282
  const data = await response.json();
226
- return new Response(JSON.stringify(convertOpenAIJsonToResponseApi(data)), {
283
+ return new Response(JSON.stringify(convertOpenAIJsonToResponseApi(data, codexTools)), {
227
284
  headers: { "Content-Type": "application/json" }
228
285
  });
229
286
  }
230
287
  }, _class.__initStatic(), _class);
288
+ var TEXT_PART_TYPES = /* @__PURE__ */ new Set(["text", "input_text", "output_text", "summary_text"]);
289
+ var SKIPPED_INPUT_ITEM_TYPES = /* @__PURE__ */ new Set(["reasoning", "agent_message"]);
290
+ var CUSTOM_TOOL_PARAMETERS = {
291
+ type: "object",
292
+ properties: {
293
+ input: {
294
+ type: "string",
295
+ description: "The complete free-form input for this tool, passed through verbatim."
296
+ }
297
+ },
298
+ required: ["input"]
299
+ };
300
+ function unwrapCustomToolInput(argumentsJson) {
301
+ try {
302
+ const parsed = JSON.parse(argumentsJson);
303
+ if (parsed && typeof parsed === "object" && typeof parsed.input === "string") {
304
+ return parsed.input;
305
+ }
306
+ } catch (e3) {
307
+ }
308
+ return argumentsJson;
309
+ }
310
+ function encodeToolCallItem(callId, name, argumentsJson, status, codexTools) {
311
+ const bareId = callId.replace(/^(call_|fc_|ctc_)/, "");
312
+ if (_optionalChain([codexTools, 'optionalAccess', _19 => _19.customToolNames, 'optionalAccess', _20 => _20.includes, 'call', _21 => _21(name)])) {
313
+ return {
314
+ id: `ctc_${bareId}`,
315
+ type: "custom_tool_call",
316
+ status,
317
+ call_id: callId,
318
+ name,
319
+ input: unwrapCustomToolInput(argumentsJson)
320
+ };
321
+ }
322
+ const namespace = _optionalChain([codexTools, 'optionalAccess', _22 => _22.toolNamespaces, 'optionalAccess', _23 => _23[name]]);
323
+ return {
324
+ id: callId.startsWith("fc_") ? callId : `fc_${bareId}`,
325
+ type: "function_call",
326
+ status,
327
+ call_id: callId,
328
+ name,
329
+ ...namespace ? { namespace } : {},
330
+ arguments: argumentsJson
331
+ };
332
+ }
333
+ function collectCodexTools(entry) {
334
+ const result = { tools: [], customToolNames: [], toolNamespaces: {} };
335
+ const visit = (declarations, namespace) => {
336
+ if (!Array.isArray(declarations)) return;
337
+ for (const raw of declarations) {
338
+ if (!raw || typeof raw !== "object") continue;
339
+ const tool = raw;
340
+ const name = typeof tool.name === "string" ? tool.name : "";
341
+ if (!name) continue;
342
+ const description = typeof tool.description === "string" ? tool.description : "";
343
+ if (tool.type === "namespace") {
344
+ visit(tool.tools, name);
345
+ continue;
346
+ }
347
+ if (tool.type === "custom") {
348
+ result.customToolNames.push(name);
349
+ result.tools.push({
350
+ type: "function",
351
+ function: {
352
+ name,
353
+ description,
354
+ parameters: CUSTOM_TOOL_PARAMETERS
355
+ }
356
+ });
357
+ } else if (tool.type === "function") {
358
+ result.tools.push({
359
+ type: "function",
360
+ function: {
361
+ name,
362
+ description,
363
+ parameters: tool.parameters || {}
364
+ }
365
+ });
366
+ } else {
367
+ continue;
368
+ }
369
+ if (namespace) result.toolNamespaces[name] = namespace;
370
+ }
371
+ };
372
+ visit(entry.tools);
373
+ return result;
374
+ }
231
375
  function flattenContent(content) {
232
376
  if (typeof content === "string") return content;
233
377
  if (!content) return "";
234
378
  if (Array.isArray(content)) {
235
- return content.filter((c) => c.type === "text").map((c) => c.text || "").join("\n");
379
+ return content.map((part) => {
380
+ if (typeof part === "string") return part;
381
+ if (!part || typeof part !== "object") return "";
382
+ const c = part;
383
+ if (typeof c.type === "string" && !TEXT_PART_TYPES.has(c.type)) return "";
384
+ return typeof c.text === "string" ? c.text : "";
385
+ }).filter((text) => text !== "").join("\n");
386
+ }
387
+ if (typeof content === "object") {
388
+ const obj = content;
389
+ if (typeof obj.text === "string") return obj.text;
390
+ if (Array.isArray(obj.content)) return flattenContent(obj.content);
236
391
  }
237
392
  return "";
238
393
  }
@@ -283,16 +438,12 @@ function convertResponseApiJsonToOpenAI(data) {
283
438
  finish_reason: toolCalls.length > 0 ? "tool_calls" : "stop"
284
439
  }
285
440
  ],
286
- usage: usage ? {
287
- prompt_tokens: usage.input_tokens || 0,
288
- completion_tokens: usage.output_tokens || 0,
289
- total_tokens: (usage.input_tokens || 0) + (usage.output_tokens || 0)
290
- } : void 0
441
+ usage: _chunk5RSZYQJHcjs.responsesUsageToChatUsage.call(void 0, usage)
291
442
  };
292
443
  }
293
- function convertOpenAIJsonToResponseApi(data) {
444
+ function convertOpenAIJsonToResponseApi(data, codexTools) {
294
445
  const choices = data.choices;
295
- const message = _optionalChain([choices, 'optionalAccess', _11 => _11[0], 'optionalAccess', _12 => _12.message]);
446
+ const message = _optionalChain([choices, 'optionalAccess', _24 => _24[0], 'optionalAccess', _25 => _25.message]);
296
447
  const output = [];
297
448
  if (message) {
298
449
  const contentParts = [];
@@ -303,16 +454,18 @@ function convertOpenAIJsonToResponseApi(data) {
303
454
  output.push({ type: "message", role: "assistant", content: contentParts });
304
455
  }
305
456
  const toolCalls = message.tool_calls;
306
- if (_optionalChain([toolCalls, 'optionalAccess', _13 => _13.length])) {
457
+ if (_optionalChain([toolCalls, 'optionalAccess', _26 => _26.length])) {
307
458
  for (const tc of toolCalls) {
308
459
  const func = tc.function;
309
- output.push({
310
- type: "function_call",
311
- id: tc.id,
312
- call_id: tc.id,
313
- name: _optionalChain([func, 'optionalAccess', _14 => _14.name]),
314
- arguments: _optionalChain([func, 'optionalAccess', _15 => _15.arguments])
315
- });
460
+ output.push(
461
+ encodeToolCallItem(
462
+ tc.id || "",
463
+ _optionalChain([func, 'optionalAccess', _27 => _27.name]) || "",
464
+ typeof _optionalChain([func, 'optionalAccess', _28 => _28.arguments]) === "string" ? func.arguments : "",
465
+ "completed",
466
+ codexTools
467
+ )
468
+ );
316
469
  }
317
470
  }
318
471
  }
@@ -323,11 +476,7 @@ function convertOpenAIJsonToResponseApi(data) {
323
476
  status: "completed",
324
477
  model: data.model || "unknown",
325
478
  output,
326
- usage: usage ? {
327
- input_tokens: usage.prompt_tokens || 0,
328
- output_tokens: usage.completion_tokens || 0,
329
- total_tokens: usage.total_tokens || (usage.prompt_tokens || 0) + (usage.completion_tokens || 0)
330
- } : void 0
479
+ usage: _chunk5RSZYQJHcjs.chatUsageToResponsesUsage.call(void 0, usage)
331
480
  };
332
481
  }
333
482
  function convertResponseApiStreamToOpenAI(responseApiStream) {
@@ -346,7 +495,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
346
495
  if (!isClosed) {
347
496
  try {
348
497
  controller.enqueue(encoder.encode(str));
349
- } catch (e3) {
498
+ } catch (e4) {
350
499
  isClosed = true;
351
500
  }
352
501
  }
@@ -378,7 +527,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
378
527
  if (data === "[DONE]") continue;
379
528
  try {
380
529
  const event = JSON.parse(data);
381
- model = event.model || _optionalChain([event, 'access', _16 => _16.response, 'optionalAccess', _17 => _17.model]) || model;
530
+ model = event.model || _optionalChain([event, 'access', _29 => _29.response, 'optionalAccess', _30 => _30.model]) || model;
382
531
  switch (event.type) {
383
532
  case "response.output_text.delta":
384
533
  if (event.delta) {
@@ -400,7 +549,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
400
549
  break;
401
550
  case "response.output_item.added": {
402
551
  const item = event.item;
403
- if (_optionalChain([item, 'optionalAccess', _18 => _18.type]) !== "function_call") break;
552
+ if (_optionalChain([item, 'optionalAccess', _31 => _31.type]) !== "function_call") break;
404
553
  if (!hasEmittedRole) {
405
554
  emitChunk([{ index: 0, delta: { role: "assistant", content: null }, finish_reason: null }]);
406
555
  hasEmittedRole = true;
@@ -436,12 +585,8 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
436
585
  }
437
586
  case "response.completed": {
438
587
  const resp = event.response;
439
- const respUsage = _optionalChain([resp, 'optionalAccess', _19 => _19.usage]);
440
- const usage = respUsage ? {
441
- prompt_tokens: respUsage.input_tokens || 0,
442
- completion_tokens: respUsage.output_tokens || 0,
443
- total_tokens: (respUsage.input_tokens || 0) + (respUsage.output_tokens || 0)
444
- } : void 0;
588
+ const respUsage = _optionalChain([resp, 'optionalAccess', _32 => _32.usage]);
589
+ const usage = _chunk5RSZYQJHcjs.responsesUsageToChatUsage.call(void 0, respUsage);
445
590
  emitChunk([{ index: 0, delta: {}, finish_reason: hasToolCalls ? "tool_calls" : "stop" }], usage);
446
591
  safeEnqueue("data: [DONE]\n\n");
447
592
  break;
@@ -449,14 +594,14 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
449
594
  case "error":
450
595
  emitChunk([{
451
596
  index: 0,
452
- delta: { content: `[Error: ${_optionalChain([event, 'access', _20 => _20.error, 'optionalAccess', _21 => _21.message]) || "Unknown error"}]` },
597
+ delta: { content: `[Error: ${_optionalChain([event, 'access', _33 => _33.error, 'optionalAccess', _34 => _34.message]) || "Unknown error"}]` },
453
598
  finish_reason: "stop"
454
599
  }]);
455
600
  break;
456
601
  default:
457
602
  break;
458
603
  }
459
- } catch (e4) {
604
+ } catch (e5) {
460
605
  }
461
606
  }
462
607
  }
@@ -466,7 +611,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
466
611
  if (!isClosed) {
467
612
  try {
468
613
  controller.close();
469
- } catch (e5) {
614
+ } catch (e6) {
470
615
  }
471
616
  }
472
617
  reader.releaseLock();
@@ -474,7 +619,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
474
619
  }
475
620
  });
476
621
  }
477
- function convertOpenAIStreamToResponseApi(openaiStream) {
622
+ function convertOpenAIStreamToResponseApi(openaiStream, codexTools) {
478
623
  const decoder = new TextDecoder();
479
624
  const encoder = new TextEncoder();
480
625
  return new ReadableStream({
@@ -485,6 +630,8 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
485
630
  let accumulatedContent = "";
486
631
  let model = "unknown";
487
632
  const responseId = `resp_${Date.now()}`;
633
+ const messageId = `msg_${Date.now()}`;
634
+ let messageItemAdded = false;
488
635
  const toolCalls = /* @__PURE__ */ new Map();
489
636
  const toolOutputIndex = /* @__PURE__ */ new Map();
490
637
  let nextOutputIndex = 1;
@@ -492,7 +639,7 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
492
639
  if (!isClosed) {
493
640
  try {
494
641
  controller.enqueue(encoder.encode(str));
495
- } catch (e6) {
642
+ } catch (e7) {
496
643
  isClosed = true;
497
644
  }
498
645
  }
@@ -520,20 +667,40 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
520
667
  if (data === "[DONE]") continue;
521
668
  try {
522
669
  const chunk = JSON.parse(data);
523
- const choice = _optionalChain([chunk, 'access', _22 => _22.choices, 'optionalAccess', _23 => _23[0]]);
670
+ const choice = _optionalChain([chunk, 'access', _35 => _35.choices, 'optionalAccess', _36 => _36[0]]);
524
671
  model = chunk.model || model;
525
672
  if (!choice) continue;
526
- if (_optionalChain([choice, 'access', _24 => _24.delta, 'optionalAccess', _25 => _25.content])) {
673
+ if (_optionalChain([choice, 'access', _37 => _37.delta, 'optionalAccess', _38 => _38.content])) {
674
+ if (!messageItemAdded) {
675
+ messageItemAdded = true;
676
+ emitEvent({
677
+ type: "response.output_item.added",
678
+ output_index: 0,
679
+ item: {
680
+ id: messageId,
681
+ type: "message",
682
+ role: "assistant",
683
+ status: "in_progress",
684
+ content: []
685
+ }
686
+ });
687
+ }
527
688
  accumulatedContent += choice.delta.content;
528
- emitEvent({ type: "response.output_text.delta", delta: choice.delta.content });
689
+ emitEvent({
690
+ type: "response.output_text.delta",
691
+ output_index: 0,
692
+ content_index: 0,
693
+ delta: choice.delta.content
694
+ });
529
695
  }
530
- if (_optionalChain([choice, 'access', _26 => _26.delta, 'optionalAccess', _27 => _27.thinking, 'optionalAccess', _28 => _28.content])) {
696
+ const reasoningDelta = _nullishCoalesce(_optionalChain([choice, 'access', _39 => _39.delta, 'optionalAccess', _40 => _40.thinking, 'optionalAccess', _41 => _41.content]), () => ( _optionalChain([choice, 'access', _42 => _42.delta, 'optionalAccess', _43 => _43.reasoning_content])));
697
+ if (reasoningDelta) {
531
698
  emitEvent({
532
699
  type: "response.reasoning_summary_text.delta",
533
- delta: choice.delta.thinking.content
700
+ delta: reasoningDelta
534
701
  });
535
702
  }
536
- if (_optionalChain([choice, 'access', _29 => _29.delta, 'optionalAccess', _30 => _30.tool_calls])) {
703
+ if (_optionalChain([choice, 'access', _44 => _44.delta, 'optionalAccess', _45 => _45.tool_calls])) {
537
704
  for (const tc of choice.delta.tool_calls) {
538
705
  const tcIndex = typeof tc["index"] === "number" ? tc["index"] : 0;
539
706
  const func = _nullishCoalesce(tc["function"], () => ( {}));
@@ -541,66 +708,83 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
541
708
  if (!entry) {
542
709
  const callId = typeof tc["id"] === "string" ? tc["id"] : `call_${Date.now()}_${tcIndex}`;
543
710
  const name = typeof func["name"] === "string" ? func["name"] : "";
544
- entry = { callId, name, arguments: "" };
711
+ entry = {
712
+ callId,
713
+ name,
714
+ arguments: "",
715
+ isCustom: _nullishCoalesce(_optionalChain([codexTools, 'optionalAccess', _46 => _46.customToolNames, 'optionalAccess', _47 => _47.includes, 'call', _48 => _48(name)]), () => ( false))
716
+ };
545
717
  toolCalls.set(tcIndex, entry);
546
718
  const outIdx = nextOutputIndex++;
547
719
  toolOutputIndex.set(tcIndex, outIdx);
548
- const itemId = callId.startsWith("fc_") ? callId : `fc_${callId.replace(/^(call_|fc_)/, "")}`;
549
720
  emitEvent({
550
721
  type: "response.output_item.added",
551
722
  output_index: outIdx,
552
- item: {
553
- id: itemId,
554
- type: "function_call",
555
- status: "in_progress",
556
- call_id: callId,
557
- name,
558
- arguments: ""
559
- }
723
+ item: encodeToolCallItem(callId, name, "", "in_progress", codexTools)
560
724
  });
561
725
  }
562
726
  const argsFragment = typeof func["arguments"] === "string" ? func["arguments"] : "";
563
727
  if (argsFragment) {
564
728
  entry.arguments += argsFragment;
565
- emitEvent({
566
- type: "response.function_call_arguments.delta",
567
- output_index: toolOutputIndex.get(tcIndex),
568
- delta: argsFragment
569
- });
729
+ if (!entry.isCustom) {
730
+ emitEvent({
731
+ type: "response.function_call_arguments.delta",
732
+ output_index: toolOutputIndex.get(tcIndex),
733
+ delta: argsFragment
734
+ });
735
+ }
570
736
  }
571
737
  }
572
738
  }
573
739
  if (choice.finish_reason) {
574
- emitEvent({ type: "response.output_text.done", text: accumulatedContent });
575
740
  const output = [];
576
- if (accumulatedContent) {
577
- output.push({
741
+ if (messageItemAdded) {
742
+ emitEvent({
743
+ type: "response.output_text.done",
744
+ output_index: 0,
745
+ content_index: 0,
746
+ text: accumulatedContent
747
+ });
748
+ const messageItem = {
749
+ id: messageId,
578
750
  type: "message",
579
751
  role: "assistant",
752
+ status: "completed",
580
753
  content: [{ type: "output_text", text: accumulatedContent }]
754
+ };
755
+ emitEvent({
756
+ type: "response.output_item.done",
757
+ output_index: 0,
758
+ item: messageItem
581
759
  });
760
+ output.push(messageItem);
582
761
  }
583
762
  for (const [tcIndex, entry] of toolCalls) {
584
- const itemId = entry.callId.startsWith("fc_") ? entry.callId : `fc_${entry.callId.replace(/^(call_|fc_)/, "")}`;
585
- output.push({
586
- id: itemId,
587
- type: "function_call",
588
- status: "completed",
589
- call_id: entry.callId,
590
- name: entry.name,
591
- arguments: entry.arguments
592
- });
763
+ const outIdx = toolOutputIndex.get(tcIndex);
764
+ const item = encodeToolCallItem(
765
+ entry.callId,
766
+ entry.name,
767
+ entry.arguments,
768
+ "completed",
769
+ codexTools
770
+ );
771
+ if (entry.isCustom) {
772
+ emitEvent({
773
+ type: "response.custom_tool_call_input.delta",
774
+ output_index: outIdx,
775
+ delta: item.input
776
+ });
777
+ emitEvent({
778
+ type: "response.custom_tool_call_input.done",
779
+ output_index: outIdx,
780
+ input: item.input
781
+ });
782
+ }
783
+ output.push(item);
593
784
  emitEvent({
594
785
  type: "response.output_item.done",
595
- output_index: toolOutputIndex.get(tcIndex),
596
- item: {
597
- id: itemId,
598
- type: "function_call",
599
- status: "completed",
600
- call_id: entry.callId,
601
- name: entry.name,
602
- arguments: entry.arguments
603
- }
786
+ output_index: outIdx,
787
+ item
604
788
  });
605
789
  }
606
790
  emitEvent({
@@ -610,15 +794,11 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
610
794
  status: "completed",
611
795
  model,
612
796
  output,
613
- usage: chunk.usage ? {
614
- input_tokens: chunk.usage.prompt_tokens || 0,
615
- output_tokens: chunk.usage.completion_tokens || 0,
616
- total_tokens: chunk.usage.total_tokens || 0
617
- } : void 0
797
+ usage: _chunk5RSZYQJHcjs.chatUsageToResponsesUsage.call(void 0, chunk.usage)
618
798
  }
619
799
  });
620
800
  }
621
- } catch (e7) {
801
+ } catch (e8) {
622
802
  }
623
803
  }
624
804
  }
@@ -628,7 +808,7 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
628
808
  if (!isClosed) {
629
809
  try {
630
810
  controller.close();
631
- } catch (e8) {
811
+ } catch (e9) {
632
812
  }
633
813
  }
634
814
  reader.releaseLock();