@omnicross/core 0.1.10 → 0.2.1

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 (204) hide show
  1. package/README.md +7 -0
  2. package/dist/{BuiltinToolExecutor-CS2WpXhM.d.cts → BuiltinToolExecutor-BHgH-EaZ.d.cts} +25 -2
  3. package/dist/{BuiltinToolExecutor-BluWyeob.d.ts → BuiltinToolExecutor-Bi1LmiTP.d.ts} +25 -2
  4. package/dist/{CompletionService-kNA17cfI.d.cts → CompletionService-BniP7j88.d.cts} +2 -2
  5. package/dist/{CompletionService-C3BX0Ovy.d.ts → CompletionService-BqrKPwfA.d.ts} +2 -2
  6. package/dist/{ProviderProxy-QdwNV6l1.d.cts → ProviderProxy-Bz_nkOwq.d.cts} +1 -1
  7. package/dist/{ProviderProxy--ROec6VI.d.ts → ProviderProxy-Ckr6oTrE.d.ts} +1 -1
  8. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -6
  9. package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -4
  10. package/dist/{chunk-NGYOO5TO.js → chunk-2C3TTBS7.js} +7 -7
  11. package/dist/{chunk-QUSEZNYS.cjs → chunk-32SRZFFP.cjs} +4 -1
  12. package/dist/chunk-4JOU54M5.js +200 -0
  13. package/dist/{chunk-2UTGX6FM.js → chunk-4VVCXVB7.js} +1 -1
  14. package/dist/{chunk-RJUONLUQ.cjs → chunk-4Z3ZLLC2.cjs} +14 -8
  15. package/dist/chunk-6DDYNS2B.cjs +384 -0
  16. package/dist/{chunk-GXEZ2R3E.js → chunk-6OKXH2TW.js} +18 -7
  17. package/dist/{chunk-YWL7YZWS.cjs → chunk-7LRTPNFL.cjs} +5 -0
  18. package/dist/{chunk-CCVRRJOX.js → chunk-7PIUVCKK.js} +9 -2
  19. package/dist/chunk-7RJI3NDI.cjs +236 -0
  20. package/dist/{chunk-IIRPUVPH.cjs → chunk-7ZHBN75N.cjs} +3 -1
  21. package/dist/chunk-D4WNI6BR.cjs +386 -0
  22. package/dist/chunk-DBBR6RHF.js +236 -0
  23. package/dist/chunk-E4QHVXV5.cjs +118 -0
  24. package/dist/{chunk-HKB656B4.js → chunk-EUZRH544.js} +55 -287
  25. package/dist/{chunk-WNKWAEUR.js → chunk-EYGBM2VC.js} +3 -1
  26. package/dist/{chunk-UWDW6PN3.cjs → chunk-FX325I5Q.cjs} +20 -9
  27. package/dist/chunk-G4CZIUIB.cjs +200 -0
  28. package/dist/chunk-HCOQQAZE.cjs +123 -0
  29. package/dist/chunk-HL2YSPL7.cjs +673 -0
  30. package/dist/{chunk-55FMGZ3L.js → chunk-HN74IGEO.js} +1 -1
  31. package/dist/{chunk-ZY6KU6P3.js → chunk-HOMUGKHR.js} +8 -5
  32. package/dist/{chunk-AOFWNWLT.cjs → chunk-IUL4VWNU.cjs} +22 -1
  33. package/dist/{chunk-5LNYGCIW.cjs → chunk-KIQ2HA2A.cjs} +5 -5
  34. package/dist/{chunk-MUHWHQVM.cjs → chunk-KQBLZMP6.cjs} +4 -3
  35. package/dist/chunk-LFEH7CEO.js +384 -0
  36. package/dist/chunk-LFPQ2OVH.js +386 -0
  37. package/dist/{chunk-FEBAQI5A.js → chunk-LKDAN4D7.js} +6363 -1350
  38. package/dist/chunk-LQYS2N47.js +3923 -0
  39. package/dist/{chunk-NZYN7C3P.cjs → chunk-MPXOKQJP.cjs} +53 -53
  40. package/dist/chunk-MZEGQSKQ.js +118 -0
  41. package/dist/chunk-N76KU6F5.js +123 -0
  42. package/dist/chunk-NLUOTJWB.js +673 -0
  43. package/dist/{chunk-CMVXX7ON.cjs → chunk-NOITAVHA.cjs} +114 -58
  44. package/dist/{chunk-Q27JY5RG.cjs → chunk-OIKREZVQ.cjs} +7 -4
  45. package/dist/{chunk-ZQQUD66M.cjs → chunk-POUTD5AM.cjs} +63 -295
  46. package/dist/{chunk-6D4W22P4.js → chunk-QIIAMBTM.js} +4 -1
  47. package/dist/{chunk-56QD3YW6.cjs → chunk-QWNUOR7F.cjs} +11 -4
  48. package/dist/{chunk-S3DYFEBE.js → chunk-R4VCO2CB.js} +10 -1
  49. package/dist/{chunk-4VZX5F4T.cjs → chunk-T6NWPIYZ.cjs} +5 -2
  50. package/dist/{chunk-EBLFCNPY.js → chunk-U47LQXPB.js} +5 -2
  51. package/dist/chunk-UPQIWJIE.cjs +3923 -0
  52. package/dist/{chunk-N7OOJI5V.js → chunk-V2UKUTJ3.js} +5 -0
  53. package/dist/{chunk-45FHEOKW.js → chunk-V53ZEFXC.js} +92 -36
  54. package/dist/{chunk-RJ5ZGNI3.js → chunk-VL5TUDTM.js} +8 -2
  55. package/dist/{chunk-TIT74RIL.cjs → chunk-VSYQ6XYN.cjs} +6837 -1824
  56. package/dist/{chunk-OC6DOOFX.cjs → chunk-VXRTQZF2.cjs} +5 -5
  57. package/dist/{chunk-RICPANBY.cjs → chunk-WX2E2G7H.cjs} +13 -4
  58. package/dist/{chunk-DE2SRBFZ.js → chunk-X335TJNS.js} +4 -3
  59. package/dist/{chunk-CDHS2QDC.js → chunk-Y4CRNHJO.js} +53 -53
  60. package/dist/{chunk-P7EM6BND.cjs → chunk-ZAPN7XA6.cjs} +10 -10
  61. package/dist/{chunk-N2EIM2XJ.js → chunk-ZLNHPUFA.js} +22 -1
  62. package/dist/completion/BuiltinToolExecutor.cjs +2 -2
  63. package/dist/completion/BuiltinToolExecutor.d.cts +3 -1
  64. package/dist/completion/BuiltinToolExecutor.d.ts +3 -1
  65. package/dist/completion/BuiltinToolExecutor.js +1 -1
  66. package/dist/completion/CompletionService.cjs +32 -28
  67. package/dist/completion/CompletionService.d.cts +7 -3
  68. package/dist/completion/CompletionService.d.ts +7 -3
  69. package/dist/completion/CompletionService.js +31 -27
  70. package/dist/completion.cjs +40 -36
  71. package/dist/completion.d.cts +7 -3
  72. package/dist/completion.d.ts +7 -3
  73. package/dist/completion.js +39 -35
  74. package/dist/egress-I46O_p5L.d.cts +126 -0
  75. package/dist/egress-I46O_p5L.d.ts +126 -0
  76. package/dist/frontends-Doz0RaWu.d.cts +97 -0
  77. package/dist/frontends-Doz0RaWu.d.ts +97 -0
  78. package/dist/image-generation.cjs +52 -0
  79. package/dist/image-generation.d.cts +96 -0
  80. package/dist/image-generation.d.ts +96 -0
  81. package/dist/image-generation.js +52 -0
  82. package/dist/index.cjs +142 -32
  83. package/dist/index.d.cts +16 -8
  84. package/dist/index.d.ts +16 -8
  85. package/dist/index.js +159 -49
  86. package/dist/openai-operation.cjs +18 -0
  87. package/dist/openai-operation.d.cts +22 -0
  88. package/dist/openai-operation.d.ts +22 -0
  89. package/dist/openai-operation.js +18 -0
  90. package/dist/outbound-api/auditCapture.cjs +3 -3
  91. package/dist/outbound-api/auditCapture.d.cts +13 -2
  92. package/dist/outbound-api/auditCapture.d.ts +13 -2
  93. package/dist/outbound-api/auditCapture.js +2 -2
  94. package/dist/outbound-api/auditRedact.cjs +2 -2
  95. package/dist/outbound-api/auditRedact.js +1 -1
  96. package/dist/outbound-api/routeResolver.cjs +2 -2
  97. package/dist/outbound-api/routeResolver.d.cts +11 -4
  98. package/dist/outbound-api/routeResolver.d.ts +11 -4
  99. package/dist/outbound-api/routeResolver.js +1 -1
  100. package/dist/outbound-api/subscriptionRegistryPort.d.cts +5 -1
  101. package/dist/outbound-api/subscriptionRegistryPort.d.ts +5 -1
  102. package/dist/outbound-api/types.d.cts +10 -3
  103. package/dist/outbound-api/types.d.ts +10 -3
  104. package/dist/outbound-api.cjs +65 -33
  105. package/dist/outbound-api.d.cts +205 -10
  106. package/dist/outbound-api.d.ts +205 -10
  107. package/dist/outbound-api.js +64 -32
  108. package/dist/pipeline/AccountAllowanceScheduling.d.cts +22 -15
  109. package/dist/pipeline/AccountAllowanceScheduling.d.ts +22 -15
  110. package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
  111. package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
  112. package/dist/pipeline/SubscriptionAccountHealth.cjs +2 -2
  113. package/dist/pipeline/SubscriptionAccountHealth.d.cts +7 -0
  114. package/dist/pipeline/SubscriptionAccountHealth.d.ts +7 -0
  115. package/dist/pipeline/SubscriptionAccountHealth.js +1 -1
  116. package/dist/pipeline/executeProviderCall.cjs +2 -2
  117. package/dist/pipeline/executeProviderCall.d.cts +11 -6
  118. package/dist/pipeline/executeProviderCall.d.ts +11 -6
  119. package/dist/pipeline/executeProviderCall.js +1 -1
  120. package/dist/pipeline/upstreamFetch.cjs +2 -2
  121. package/dist/pipeline/upstreamFetch.d.cts +5 -0
  122. package/dist/pipeline/upstreamFetch.d.ts +5 -0
  123. package/dist/pipeline/upstreamFetch.js +1 -1
  124. package/dist/ports.d.cts +10 -3
  125. package/dist/ports.d.ts +10 -3
  126. package/dist/provider-proxy/ProviderProxy.cjs +32 -28
  127. package/dist/provider-proxy/ProviderProxy.d.cts +6 -2
  128. package/dist/provider-proxy/ProviderProxy.d.ts +6 -2
  129. package/dist/provider-proxy/ProviderProxy.js +31 -27
  130. package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
  131. package/dist/provider-proxy/identity/codexCliHeaders.d.cts +26 -6
  132. package/dist/provider-proxy/identity/codexCliHeaders.d.ts +26 -6
  133. package/dist/provider-proxy/identity/codexCliHeaders.js +5 -3
  134. package/dist/provider-proxy/ingress/providerProxyShared.cjs +36 -28
  135. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +41 -9
  136. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +41 -9
  137. package/dist/provider-proxy/ingress/providerProxyShared.js +35 -27
  138. package/dist/provider-proxy/types.d.cts +17 -483
  139. package/dist/provider-proxy/types.d.ts +17 -483
  140. package/dist/provider-proxy.cjs +46 -28
  141. package/dist/provider-proxy.d.cts +34 -8
  142. package/dist/provider-proxy.d.ts +34 -8
  143. package/dist/provider-proxy.js +45 -27
  144. package/dist/proxy-UZTtjPZx.d.cts +18 -0
  145. package/dist/proxy-UZTtjPZx.d.ts +18 -0
  146. package/dist/{routeResolver-CVFE8KKe.d.cts → routeResolver-Da0yvkL1.d.cts} +4 -2
  147. package/dist/{routeResolver-C0mkkZaM.d.ts → routeResolver-STwMz_G4.d.ts} +4 -2
  148. package/dist/runtime-6QXNU526.cjs +8 -0
  149. package/dist/runtime-M5WXLD2R.js +8 -0
  150. package/dist/runtime-t8AZacFF.d.cts +233 -0
  151. package/dist/runtime-t8AZacFF.d.ts +233 -0
  152. package/dist/search/api.cjs +761 -0
  153. package/dist/search/api.d.cts +370 -0
  154. package/dist/search/api.d.ts +370 -0
  155. package/dist/search/api.js +761 -0
  156. package/dist/search/http.cjs +37 -0
  157. package/dist/search/http.d.cts +269 -0
  158. package/dist/search/http.d.ts +269 -0
  159. package/dist/search/http.js +37 -0
  160. package/dist/search.cjs +57 -0
  161. package/dist/search.d.cts +113 -0
  162. package/dist/search.d.ts +113 -0
  163. package/dist/search.js +57 -0
  164. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  165. package/dist/transformer/TransformerChainExecutor.d.cts +2 -2
  166. package/dist/transformer/TransformerChainExecutor.d.ts +2 -2
  167. package/dist/transformer/TransformerChainExecutor.js +1 -1
  168. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +16 -0
  169. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.cts +53 -0
  170. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.ts +53 -0
  171. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +16 -0
  172. package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -3
  173. package/dist/transformer/transformers/AnthropicTransformer.js +3 -2
  174. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -4
  175. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +3 -3
  176. package/dist/transformer/transformers/GeminiTransformer.cjs +4 -4
  177. package/dist/transformer/transformers/GeminiTransformer.js +3 -3
  178. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -3
  179. package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -2
  180. package/dist/transformer/transformers/OpenAITransformer.cjs +3 -3
  181. package/dist/transformer/transformers/OpenAITransformer.js +2 -2
  182. package/dist/transformer/transformers.cjs +11 -10
  183. package/dist/transformer/transformers.js +12 -11
  184. package/dist/transformer/types.d.cts +39 -4
  185. package/dist/transformer/types.d.ts +39 -4
  186. package/dist/transformer.cjs +14 -13
  187. package/dist/transformer.js +13 -12
  188. package/dist/types-BSIJdsyl.d.cts +1130 -0
  189. package/dist/types-Be-yt_6T.d.cts +196 -0
  190. package/dist/types-By9Tg6-I.d.ts +1130 -0
  191. package/dist/types-CbCZqLGg.d.cts +127 -0
  192. package/dist/types-CbCZqLGg.d.ts +127 -0
  193. package/dist/{types-C2MwkLah.d.cts → types-D-oHYusb.d.cts} +250 -21
  194. package/dist/types-Dm4_36V4.d.ts +196 -0
  195. package/dist/{types-BB8pxk_3.d.ts → types-Dvlpjn0d.d.ts} +250 -21
  196. package/dist/usage.cjs +2 -2
  197. package/dist/usage.d.cts +6 -1
  198. package/dist/usage.d.ts +6 -1
  199. package/dist/usage.js +1 -1
  200. package/package.json +71 -64
  201. package/dist/chunk-FCR77GYM.cjs +0 -33
  202. package/dist/chunk-K5NM7VAH.js +0 -33
  203. /package/dist/{chunk-XXFYLL7R.js → chunk-ECZ3ZE2C.js} +0 -0
  204. /package/dist/{chunk-3SCOLIPT.cjs → chunk-MXI2PWIC.cjs} +0 -0
package/README.md CHANGED
@@ -8,6 +8,13 @@ Part of the [omnicross](https://github.com/Dumoedss/omnicross) monorepo — see
8
8
  npm install @omnicross/core @omnicross/contracts
9
9
  ```
10
10
 
11
+ The published core runtime remains supported on Node.js `>=20.9`. The monorepo's
12
+ official OpenAI JavaScript SDK contract suite is contributor tooling, uses
13
+ `openai@7.8.x`, and requires Node.js 22 or newer. Run it from the repository root
14
+ with `npm run test:images-sdk-contract`; the command checks the Node major before
15
+ loading the SDK. The SDK is intentionally not a runtime or package-local
16
+ development dependency of `@omnicross/core`.
17
+
11
18
  ## License
12
19
 
13
20
  [MIT](LICENSE)
@@ -1,5 +1,6 @@
1
1
  import { MCPCallToolResponse, MCPTool } from '@omnicross/contracts/mcp-types';
2
2
  import { WebSearchBackend } from './ports/web-search-backend.cjs';
3
+ import { S as SearchRuntime } from './runtime-t8AZacFF.cjs';
3
4
 
4
5
  /**
5
6
  * Core-owned tool-shape types.
@@ -65,10 +66,32 @@ interface McpToolProvider {
65
66
 
66
67
  declare class BuiltinToolExecutor {
67
68
  private webSearch;
68
- constructor(webSearch: WebSearchBackend);
69
+ private runtime?;
70
+ /**
71
+ * @param webSearch - the legacy port, still the `web_fetch` URL reader.
72
+ * @param runtime - the search runtime `web_search` delegates to. Optional so
73
+ * the single-argument construction hosts already use keeps compiling; when
74
+ * omitted, a default runtime over the builtin HTTP providers is built on
75
+ * first use.
76
+ */
77
+ constructor(webSearch: WebSearchBackend, runtime?: SearchRuntime | undefined);
69
78
  execute(toolName: string, args: Record<string, unknown>): Promise<MCPCallToolResponse>;
70
79
  private executeWebSearch;
71
- private resolveProviderChain;
80
+ /** Memoized lazy construction, so concurrent first calls share one runtime. */
81
+ private runtimeInit?;
82
+ /**
83
+ * The runtime `web_search` delegates to.
84
+ *
85
+ * Imported lazily so the search stack's transport and HTML parsing stay out
86
+ * of the module graph of every consumer that only wants the tool definitions
87
+ * — the same reason `builtin-web-fetch` is loaded on demand below.
88
+ *
89
+ * The PROMISE is memoized, not just its result: two concurrent first searches
90
+ * would otherwise each build a runtime and the later one would win. Harmless
91
+ * while the default runtime is stateless, but it stops being harmless the
92
+ * moment one holds a connection pool or a cache.
93
+ */
94
+ private getRuntime;
72
95
  private executeWebFetch;
73
96
  }
74
97
  /** Get the built-in MCPTool definitions for web search tools. */
@@ -1,5 +1,6 @@
1
1
  import { MCPCallToolResponse, MCPTool } from '@omnicross/contracts/mcp-types';
2
2
  import { WebSearchBackend } from './ports/web-search-backend.js';
3
+ import { S as SearchRuntime } from './runtime-t8AZacFF.js';
3
4
 
4
5
  /**
5
6
  * Core-owned tool-shape types.
@@ -65,10 +66,32 @@ interface McpToolProvider {
65
66
 
66
67
  declare class BuiltinToolExecutor {
67
68
  private webSearch;
68
- constructor(webSearch: WebSearchBackend);
69
+ private runtime?;
70
+ /**
71
+ * @param webSearch - the legacy port, still the `web_fetch` URL reader.
72
+ * @param runtime - the search runtime `web_search` delegates to. Optional so
73
+ * the single-argument construction hosts already use keeps compiling; when
74
+ * omitted, a default runtime over the builtin HTTP providers is built on
75
+ * first use.
76
+ */
77
+ constructor(webSearch: WebSearchBackend, runtime?: SearchRuntime | undefined);
69
78
  execute(toolName: string, args: Record<string, unknown>): Promise<MCPCallToolResponse>;
70
79
  private executeWebSearch;
71
- private resolveProviderChain;
80
+ /** Memoized lazy construction, so concurrent first calls share one runtime. */
81
+ private runtimeInit?;
82
+ /**
83
+ * The runtime `web_search` delegates to.
84
+ *
85
+ * Imported lazily so the search stack's transport and HTML parsing stay out
86
+ * of the module graph of every consumer that only wants the tool definitions
87
+ * — the same reason `builtin-web-fetch` is loaded on demand below.
88
+ *
89
+ * The PROMISE is memoized, not just its result: two concurrent first searches
90
+ * would otherwise each build a runtime and the later one would win. Harmless
91
+ * while the default runtime is stateless, but it stops being harmless the
92
+ * moment one holds a connection pool or a cache.
93
+ */
94
+ private getRuntime;
72
95
  private executeWebFetch;
73
96
  }
74
97
  /** Get the built-in MCPTool definitions for web search tools. */
@@ -3,8 +3,8 @@ import { LLMProvider } from '@omnicross/contracts/llm-config';
3
3
  import { C as CorePaths, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.cjs';
4
4
  import { L as Logger } from './logger-4GvQNzhE.cjs';
5
5
  import { ProviderConfigSource } from './ports/provider-config-source.cjs';
6
- import { UsageRecorderImport } from './provider-proxy/types.cjs';
7
- import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-CS2WpXhM.cjs';
6
+ import { U as UsageRecorderImport } from './types-BSIJdsyl.cjs';
7
+ import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-BHgH-EaZ.cjs';
8
8
  import { C as CompletionOptions, S as StreamCallbacks, a as CompletionResult } from './types-BScIHmPr.cjs';
9
9
  import { ApiKeyPoolService } from './completion/ApiKeyPoolService.cjs';
10
10
  import { MCPTool } from '@omnicross/contracts/mcp-types';
@@ -3,8 +3,8 @@ import { LLMProvider } from '@omnicross/contracts/llm-config';
3
3
  import { C as CorePaths, U as UsageEventSink } from './usage-event-sink-BX7FE1NL.js';
4
4
  import { L as Logger } from './logger-4GvQNzhE.js';
5
5
  import { ProviderConfigSource } from './ports/provider-config-source.js';
6
- import { UsageRecorderImport } from './provider-proxy/types.js';
7
- import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-BluWyeob.js';
6
+ import { U as UsageRecorderImport } from './types-By9Tg6-I.js';
7
+ import { O as OpenAITool, A as AnthropicTool, G as GeminiTools, M as McpToolProvider, B as BuiltinToolExecutor } from './BuiltinToolExecutor-Bi1LmiTP.js';
8
8
  import { C as CompletionOptions, S as StreamCallbacks, a as CompletionResult } from './types-BScIHmPr.js';
9
9
  import { ApiKeyPoolService } from './completion/ApiKeyPoolService.js';
10
10
  import { MCPTool } from '@omnicross/contracts/mcp-types';
@@ -1,4 +1,4 @@
1
- import { RouteContext, ProviderProxyDeps } from './provider-proxy/types.cjs';
1
+ import { aD as RouteContext, W as ProviderProxyDeps } from './types-BSIJdsyl.cjs';
2
2
 
3
3
  /**
4
4
  * ProviderProxyRouteMap — the per-run `Map<token, RouteContext>` with crypto
@@ -1,4 +1,4 @@
1
- import { RouteContext, ProviderProxyDeps } from './provider-proxy/types.js';
1
+ import { aD as RouteContext, W as ProviderProxyDeps } from './types-By9Tg6-I.js';
2
2
 
3
3
  /**
4
4
  * ProviderProxyRouteMap — the per-run `Map<token, RouteContext>` with crypto
@@ -1,13 +1,13 @@
1
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
2
 
3
3
 
4
- var _chunkOC6DOOFXcjs = require('../chunk-OC6DOOFX.cjs');
5
- require('../chunk-RICPANBY.cjs');
4
+ var _chunkVXRTQZF2cjs = require('../chunk-VXRTQZF2.cjs');
5
+ require('../chunk-WX2E2G7H.cjs');
6
6
  require('../chunk-77USGNRW.cjs');
7
- require('../chunk-AOFWNWLT.cjs');
7
+ require('../chunk-IUL4VWNU.cjs');
8
8
 
9
9
 
10
- var _chunkRJUONLUQcjs = require('../chunk-RJUONLUQ.cjs');
10
+ var _chunk4Z3ZLLC2cjs = require('../chunk-4Z3ZLLC2.cjs');
11
11
  require('../chunk-235MXAGX.cjs');
12
12
  require('../chunk-HVBBDBS3.cjs');
13
13
  require('../chunk-NKVZ6Z3Y.cjs');
@@ -30,7 +30,7 @@ var GeminiCodeAssistHandshakeError = class extends Error {
30
30
  var GeminiCodeAssistProjectResolver = (_class = class {
31
31
  // upstream-proxy: the Code Assist handshake is upstream egress → honor the
32
32
  // gemini proxy by default (still injectable for tests).
33
- constructor(fetchImpl = (url, init) => _chunkRJUONLUQcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
33
+ constructor(fetchImpl = (url, init) => _chunk4Z3ZLLC2cjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
34
34
  this.fetchImpl = fetchImpl;
35
35
  }
36
36
 
@@ -64,7 +64,7 @@ var GeminiCodeAssistProjectResolver = (_class = class {
64
64
  return run;
65
65
  }
66
66
  codeAssistUrl(method) {
67
- return `${_chunkOC6DOOFXcjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkOC6DOOFXcjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
67
+ return `${_chunkVXRTQZF2cjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkVXRTQZF2cjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
68
68
  }
69
69
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
70
70
  seedProjectId() {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  resolveCodeAssistApiVersion,
3
3
  resolveCodeAssistEndpoint
4
- } from "../chunk-2UTGX6FM.js";
5
- import "../chunk-S3DYFEBE.js";
4
+ } from "../chunk-4VVCXVB7.js";
5
+ import "../chunk-R4VCO2CB.js";
6
6
  import "../chunk-WYVGULTQ.js";
7
- import "../chunk-N2EIM2XJ.js";
7
+ import "../chunk-ZLNHPUFA.js";
8
8
  import {
9
9
  fetchUpstream
10
- } from "../chunk-RJ5ZGNI3.js";
10
+ } from "../chunk-VL5TUDTM.js";
11
11
  import "../chunk-3WD4HTR2.js";
12
12
  import "../chunk-MKF46GNZ.js";
13
13
  import "../chunk-GL6XM527.js";
@@ -1,18 +1,18 @@
1
- import {
2
- AnthropicTransformer
3
- } from "./chunk-HKB656B4.js";
4
1
  import {
5
2
  GeminiTransformer
6
- } from "./chunk-55FMGZ3L.js";
3
+ } from "./chunk-HN74IGEO.js";
7
4
  import {
8
5
  OpenAIResponseTransformer
9
- } from "./chunk-45FHEOKW.js";
6
+ } from "./chunk-V53ZEFXC.js";
10
7
  import {
11
8
  OpenAITransformer
12
- } from "./chunk-CCVRRJOX.js";
9
+ } from "./chunk-7PIUVCKK.js";
10
+ import {
11
+ AnthropicTransformer
12
+ } from "./chunk-EUZRH544.js";
13
13
  import {
14
14
  GeminiCodeAssistTransformer
15
- } from "./chunk-2UTGX6FM.js";
15
+ } from "./chunk-4VVCXVB7.js";
16
16
 
17
17
  // src/transformer/transformers/index.ts
18
18
  var BuiltinTransformers = {
@@ -84,6 +84,7 @@ var UsageThroughputTracker = (_class = class {
84
84
  tokensPerMinute: 0,
85
85
  inputTokensPerMinute: 0,
86
86
  outputTokensPerMinute: 0,
87
+ cacheTokensPerMinute: 0,
87
88
  costUsdPerMinute: 0,
88
89
  complete: this.evictedThroughTs === null || this.evictedThroughTs < startTs
89
90
  };
@@ -104,6 +105,7 @@ var UsageThroughputTracker = (_class = class {
104
105
  row.tokensPerMinute = row.totalTokens / minutes;
105
106
  row.inputTokensPerMinute = row.inputTokens / minutes;
106
107
  row.outputTokensPerMinute = row.outputTokens / minutes;
108
+ row.cacheTokensPerMinute = (row.cacheReadTokens + row.cacheCreationTokens) / minutes;
107
109
  row.costUsdPerMinute = row.costUsd / minutes;
108
110
  return row;
109
111
  }
@@ -113,7 +115,7 @@ var UsageThroughputTracker = (_class = class {
113
115
  const startTs = endTs - THROUGHPUT_RETENTION_MS;
114
116
  const out = [];
115
117
  for (let i = 0; i < THROUGHPUT_BUCKET_COUNT; i += 1) {
116
- out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0 });
118
+ out.push({ startTs: startTs + i * bucketMs, requests: 0, tokens: 0, outputTokens: 0 });
117
119
  }
118
120
  for (let i = this.head; i < this.samples.length; i += 1) {
119
121
  const sample = this.samples[i];
@@ -121,6 +123,7 @@ var UsageThroughputTracker = (_class = class {
121
123
  const bucket = out[Math.floor((sample.ts - startTs) / bucketMs)];
122
124
  if (!bucket) continue;
123
125
  bucket.requests += 1;
126
+ bucket.outputTokens += sample.outputTokens;
124
127
  bucket.tokens += sample.inputTokens + sample.outputTokens + sample.cacheReadTokens + sample.cacheCreationTokens;
125
128
  }
126
129
  return out;
@@ -0,0 +1,200 @@
1
+ // src/openai-operation/openAIOperation.ts
2
+ var OPERATIONS = {
3
+ "chat.completions.create": {
4
+ id: "chat.completions.create",
5
+ policyFamily: "chat",
6
+ routeFamily: "chat",
7
+ owner: "builtin",
8
+ bodyKind: "json",
9
+ requestedModelSource: "request"
10
+ },
11
+ "responses.create": {
12
+ id: "responses.create",
13
+ policyFamily: "responses",
14
+ routeFamily: "responses",
15
+ owner: "builtin",
16
+ bodyKind: "json",
17
+ requestedModelSource: "request"
18
+ },
19
+ "responses.compact": {
20
+ id: "responses.compact",
21
+ policyFamily: "responses",
22
+ routeFamily: "responses",
23
+ owner: "extension",
24
+ bodyKind: "json",
25
+ requestedModelSource: "request"
26
+ },
27
+ "images.generate": {
28
+ id: "images.generate",
29
+ policyFamily: "images",
30
+ routeFamily: "images",
31
+ owner: "extension",
32
+ bodyKind: "json",
33
+ requestedModelSource: "configured"
34
+ },
35
+ "images.edit": {
36
+ id: "images.edit",
37
+ policyFamily: "images",
38
+ routeFamily: "images",
39
+ owner: "extension",
40
+ bodyKind: "multipart",
41
+ requestedModelSource: "configured"
42
+ }
43
+ };
44
+ var MATCH_ORDER = [
45
+ { id: "responses.compact", suffix: ["responses", "compact"] },
46
+ { id: "images.generate", suffix: ["images", "generations"] },
47
+ { id: "images.edit", suffix: ["images", "edits"] },
48
+ { id: "chat.completions.create", suffix: ["chat", "completions"] },
49
+ { id: "responses.create", suffix: ["responses"] }
50
+ ];
51
+ function getOpenAIOperation(id) {
52
+ return OPERATIONS[id];
53
+ }
54
+ function pathSegments(url) {
55
+ const queryIndex = url.indexOf("?");
56
+ const path = queryIndex >= 0 ? url.slice(0, queryIndex) : url;
57
+ return path.split("/").filter(Boolean);
58
+ }
59
+ function hasExactSuffix(segments, suffix) {
60
+ if (segments.length < suffix.length) return false;
61
+ const offset = segments.length - suffix.length;
62
+ return suffix.every((segment, index) => segments[offset + index] === segment);
63
+ }
64
+ function classifyOpenAIOperation(method, url) {
65
+ if (method !== "POST" || !url) return null;
66
+ const segments = pathSegments(url);
67
+ for (const candidate of MATCH_ORDER) {
68
+ if (hasExactSuffix(segments, candidate.suffix)) return OPERATIONS[candidate.id];
69
+ }
70
+ return null;
71
+ }
72
+
73
+ // src/openai-operation/openAIOperationRegistry.ts
74
+ var OpenAIOperationRegistrationError = class extends Error {
75
+ constructor(code, message) {
76
+ super(message);
77
+ this.code = code;
78
+ }
79
+ code;
80
+ name = "OpenAIOperationRegistrationError";
81
+ };
82
+ var OpenAIOperationError = class extends Error {
83
+ name = "OpenAIOperationError";
84
+ status;
85
+ code;
86
+ retryable;
87
+ headers;
88
+ constructor(init) {
89
+ super(init.message);
90
+ this.status = init.status;
91
+ this.code = init.code;
92
+ this.retryable = init.retryable ?? false;
93
+ this.headers = init.headers ?? {};
94
+ }
95
+ };
96
+ var SAFE_LOCAL_ERROR_HEADERS = /* @__PURE__ */ new Set(["retry-after", "x-request-id"]);
97
+ function safeErrorHeaders(headers) {
98
+ const safe = {};
99
+ for (const [name, value] of Object.entries(headers)) {
100
+ if (SAFE_LOCAL_ERROR_HEADERS.has(name.toLowerCase())) safe[name] = value;
101
+ }
102
+ return safe;
103
+ }
104
+ function writeOpenAIOperationError(res, error) {
105
+ if (res.headersSent || res.writableEnded) return false;
106
+ res.writeHead(error.status, {
107
+ "Content-Type": "application/json",
108
+ ...safeErrorHeaders(error.headers)
109
+ });
110
+ res.end(JSON.stringify({
111
+ error: {
112
+ type: "openai_operation_error",
113
+ code: error.code,
114
+ message: error.message,
115
+ retryable: error.retryable
116
+ }
117
+ }));
118
+ return true;
119
+ }
120
+ function unsupportedOpenAIOperation(operation) {
121
+ return new OpenAIOperationError({
122
+ status: 501,
123
+ code: "unsupported_capability",
124
+ message: `Operation '${operation.id}' is not available`
125
+ });
126
+ }
127
+ var OpenAIOperationRegistry = class {
128
+ handlers = /* @__PURE__ */ new Map();
129
+ register(operationId, handler) {
130
+ const operation = getOpenAIOperation(operationId);
131
+ if (operation.owner !== "extension") {
132
+ throw new OpenAIOperationRegistrationError(
133
+ "builtin_operation",
134
+ `Operation '${operationId}' is owned by a built-in ingress`
135
+ );
136
+ }
137
+ if (this.handlers.has(operationId)) {
138
+ throw new OpenAIOperationRegistrationError(
139
+ "duplicate_operation_handler",
140
+ `Operation '${operationId}' already has a handler`
141
+ );
142
+ }
143
+ this.handlers.set(operationId, handler);
144
+ let disposed = false;
145
+ return () => {
146
+ if (disposed) return;
147
+ disposed = true;
148
+ if (this.handlers.get(operationId) === handler) this.handlers.delete(operationId);
149
+ };
150
+ }
151
+ has(operationId) {
152
+ return this.handlers.has(operationId);
153
+ }
154
+ async dispatch(context) {
155
+ const handler = this.handlers.get(context.operation.id);
156
+ if (!handler) return false;
157
+ const controller = new AbortController();
158
+ const abort = () => {
159
+ if (!controller.signal.aborted) controller.abort();
160
+ };
161
+ const onRequestClose = () => {
162
+ if (context.request.aborted || !context.request.complete) abort();
163
+ };
164
+ const onResponseClose = () => {
165
+ if (!context.response.writableEnded) abort();
166
+ };
167
+ context.request.once("aborted", abort);
168
+ context.request.once("close", onRequestClose);
169
+ context.response.once("close", onResponseClose);
170
+ if (context.request.aborted || context.response.destroyed) abort();
171
+ try {
172
+ await handler({ ...context, signal: controller.signal });
173
+ return true;
174
+ } catch (error) {
175
+ const publicError = error instanceof OpenAIOperationError ? error : new OpenAIOperationError({
176
+ status: 500,
177
+ code: "operation_handler_failed",
178
+ message: `Operation '${context.operation.id}' handler failed`
179
+ });
180
+ if (!writeOpenAIOperationError(context.response, publicError)) {
181
+ throw new Error(publicError.message);
182
+ }
183
+ return true;
184
+ } finally {
185
+ context.request.removeListener("aborted", abort);
186
+ context.request.removeListener("close", onRequestClose);
187
+ context.response.removeListener("close", onResponseClose);
188
+ }
189
+ }
190
+ };
191
+
192
+ export {
193
+ getOpenAIOperation,
194
+ classifyOpenAIOperation,
195
+ OpenAIOperationRegistrationError,
196
+ OpenAIOperationError,
197
+ writeOpenAIOperationError,
198
+ unsupportedOpenAIOperation,
199
+ OpenAIOperationRegistry
200
+ };
@@ -3,7 +3,7 @@ import {
3
3
  transformRequestOut,
4
4
  transformResponseIn,
5
5
  transformResponseOut
6
- } from "./chunk-S3DYFEBE.js";
6
+ } from "./chunk-R4VCO2CB.js";
7
7
 
8
8
  // src/transformer/transformers/GeminiCodeAssistTransformer.ts
9
9
  var DEFAULT_CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
@@ -32,6 +32,12 @@ function bumpUpstreamProxyGeneration() {
32
32
  }
33
33
  }
34
34
  }
35
+ function isClientDisconnectAbort(signal) {
36
+ if (!_optionalChain([signal, 'optionalAccess', _3 => _3.aborted])) return false;
37
+ const reason = signal.reason;
38
+ if (!reason || typeof reason !== "object") return false;
39
+ return reason.code === "client_disconnect";
40
+ }
35
41
  function normalizeProxy(cfg) {
36
42
  if ("url" in cfg) {
37
43
  let u;
@@ -110,7 +116,7 @@ function fetchUpstream(url, init, ctx) {
110
116
  const dispatcher = resolveUpstreamDispatcher({ ..._nullishCoalesce(ctx, () => ( {})), url });
111
117
  const doFetch = dispatcher ? () => fetch(url, { ...init, dispatcher }) : () => fetch(url, init);
112
118
  const doFetchWithAllowanceTap = () => doFetch().then((response) => {
113
- if (_optionalChain([ctx, 'optionalAccess', _3 => _3.providerId]) === "codex" && ctx.accountId) {
119
+ if (_optionalChain([ctx, 'optionalAccess', _4 => _4.providerId]) === "codex" && ctx.accountId) {
114
120
  try {
115
121
  _chunkHVBBDBS3cjs.getSharedAccountAllowanceStore.call(void 0, ).recordCodexHeaders(ctx.accountId, response.headers);
116
122
  } catch (e4) {
@@ -118,10 +124,10 @@ function fetchUpstream(url, init, ctx) {
118
124
  }
119
125
  return response;
120
126
  });
121
- const activity = _optionalChain([ctx, 'optionalAccess', _4 => _4.routeActivity]);
122
- const activityStartedAt = activity && _optionalChain([ctx, 'optionalAccess', _5 => _5.providerId]) && ctx.accountId ? Date.now() : 0;
127
+ const activity = _optionalChain([ctx, 'optionalAccess', _5 => _5.routeActivity]);
128
+ const activityStartedAt = activity && _optionalChain([ctx, 'optionalAccess', _6 => _6.providerId]) && ctx.accountId ? Date.now() : 0;
123
129
  const recordActivity = (status) => {
124
- if (!activity || !_optionalChain([ctx, 'optionalAccess', _6 => _6.providerId]) || !ctx.accountId) return;
130
+ if (!activity || !_optionalChain([ctx, 'optionalAccess', _7 => _7.providerId]) || !ctx.accountId) return;
125
131
  const record = _chunkNKVZ6Z3Ycjs.getSharedAccountRouteActivity.call(void 0, ).record({
126
132
  providerId: ctx.providerId,
127
133
  accountId: ctx.accountId,
@@ -134,7 +140,7 @@ function fetchUpstream(url, init, ctx) {
134
140
  ts: activityStartedAt
135
141
  });
136
142
  try {
137
- _optionalChain([activity, 'access', _7 => _7.onRecorded, 'optionalCall', _8 => _8(record)]);
143
+ _optionalChain([activity, 'access', _8 => _8.onRecorded, 'optionalCall', _9 => _9(record)]);
138
144
  } catch (e5) {
139
145
  }
140
146
  };
@@ -144,12 +150,12 @@ function fetchUpstream(url, init, ctx) {
144
150
  return response;
145
151
  },
146
152
  (error) => {
147
- recordActivity(0);
153
+ if (!isClientDisconnectAbort(init.signal)) recordActivity(0);
148
154
  throw error;
149
155
  }
150
156
  );
151
157
  const tracePath = _chunk235MXAGXcjs.getUpstreamTracePath.call(void 0, );
152
- if (!tracePath || !_optionalChain([ctx, 'optionalAccess', _9 => _9.providerId])) return doFetchWithActivity();
158
+ if (!tracePath || !_optionalChain([ctx, 'optionalAccess', _10 => _10.providerId])) return doFetchWithActivity();
153
159
  const startedAt = Date.now();
154
160
  const method = typeof init.method === "string" ? init.method : "GET";
155
161
  const requestHeaders = _chunk235MXAGXcjs.redactHeaders.call(void 0,
@@ -158,7 +164,7 @@ function fetchUpstream(url, init, ctx) {
158
164
  const redactBodies = ctx.redactBodies === true;
159
165
  const requestBody = redactBodies ? _chunk235MXAGXcjs.REDACTED_BODY : typeof init.body === "string" ? init.body : null;
160
166
  const providerId = ctx.providerId;
161
- const accountId = ctx.accountId;
167
+ const accountId = _nullishCoalesce(ctx.traceAccountFingerprint, () => ( ctx.accountId));
162
168
  return doFetchWithActivity().then((res) => {
163
169
  const clone = res.clone();
164
170
  const status = res.status;