@omnicross/core 0.1.3 → 0.1.5

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 (141) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +57 -57
  3. package/README.md +15 -15
  4. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -5
  5. package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -5
  6. package/dist/{chunk-2DCNB7DF.cjs → chunk-3Q6Z6JTO.cjs} +154 -26
  7. package/dist/chunk-3QFXFCHG.js +33 -0
  8. package/dist/chunk-3Z5BQZFM.cjs +52 -0
  9. package/dist/{chunk-4VAVYUZS.cjs → chunk-4XMYPW46.cjs} +9 -9
  10. package/dist/chunk-4YINUUKQ.cjs +33 -0
  11. package/dist/{chunk-S4WBV25P.js → chunk-6QZGDLL4.js} +106 -23
  12. package/dist/{chunk-C72S6TTV.cjs → chunk-7FEBOPJO.cjs} +5 -4
  13. package/dist/chunk-APYG5QD7.cjs +50 -0
  14. package/dist/{chunk-5HTVET6E.js → chunk-BODMAL6G.js} +143 -15
  15. package/dist/{chunk-CWM2ZDU5.js → chunk-BPKCU575.js} +3 -10
  16. package/dist/{chunk-2FMI2B6V.cjs → chunk-CGKLE6IW.cjs} +350 -461
  17. package/dist/{chunk-BO4RFWBR.js → chunk-D3TDKWRP.js} +84 -3
  18. package/dist/{chunk-RSJ3TWJQ.cjs → chunk-DDMRUL76.cjs} +5 -5
  19. package/dist/chunk-FCR77GYM.cjs +33 -0
  20. package/dist/{chunk-4DECIFU7.js → chunk-FH2P4OCD.js} +178 -289
  21. package/dist/{chunk-N5QFKSDO.js → chunk-HRRYG2AX.js} +2 -1
  22. package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
  23. package/dist/{chunk-Z7LUNECE.js → chunk-IB3FDI4O.js} +5 -4
  24. package/dist/chunk-IFXJ2BG7.js +109 -0
  25. package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
  26. package/dist/{chunk-C7PSERMH.js → chunk-IWQAX3CS.js} +1 -1
  27. package/dist/{chunk-YGXJGRFI.cjs → chunk-JWVTXXPX.cjs} +106 -23
  28. package/dist/{chunk-7YN22L2H.cjs → chunk-K52THW2C.cjs} +5 -5
  29. package/dist/chunk-K5NM7VAH.js +33 -0
  30. package/dist/{chunk-Y6OM7EV7.cjs → chunk-KFI44N2R.cjs} +2 -1
  31. package/dist/{chunk-Z7Y2NPHY.js → chunk-MFZ5437A.js} +1 -1
  32. package/dist/chunk-OE6TDIWW.js +22 -0
  33. package/dist/{chunk-MQNDWYPN.js → chunk-OQWKZCXP.js} +13 -6
  34. package/dist/chunk-OZFM4X3S.js +18 -0
  35. package/dist/chunk-PG7PS2NN.cjs +170 -0
  36. package/dist/{chunk-3QOSDDNI.cjs → chunk-SNYBEXLB.cjs} +6 -13
  37. package/dist/chunk-SYQF7OIR.js +52 -0
  38. package/dist/{chunk-CZHZGRU7.js → chunk-UHGVBFU3.js} +2 -0
  39. package/dist/chunk-UIBD2YY5.cjs +22 -0
  40. package/dist/chunk-UNWKG6EI.cjs +109 -0
  41. package/dist/{chunk-SVXC36MU.cjs → chunk-VACWOIRE.cjs} +2 -0
  42. package/dist/chunk-WLYIIEAF.js +50 -0
  43. package/dist/chunk-XSVNC2UD.cjs +18 -0
  44. package/dist/{chunk-FFALUUZZ.cjs → chunk-ZCIQ3L3R.cjs} +18 -11
  45. package/dist/completion/CompletionService.cjs +26 -19
  46. package/dist/completion/CompletionService.js +25 -18
  47. package/dist/completion.cjs +28 -21
  48. package/dist/completion.js +27 -20
  49. package/dist/index.cjs +35 -25
  50. package/dist/index.d.cts +7 -3
  51. package/dist/index.d.ts +7 -3
  52. package/dist/index.js +44 -34
  53. package/dist/keyPolicy-Cp0FntZl.d.cts +90 -0
  54. package/dist/keyPolicy-Cp0FntZl.d.ts +90 -0
  55. package/dist/outbound-api/auditCapture.cjs +9 -0
  56. package/dist/outbound-api/auditCapture.d.cts +54 -0
  57. package/dist/outbound-api/auditCapture.d.ts +54 -0
  58. package/dist/outbound-api/auditCapture.js +9 -0
  59. package/dist/outbound-api/auditRedact.cjs +8 -0
  60. package/dist/outbound-api/auditRedact.d.cts +30 -0
  61. package/dist/outbound-api/auditRedact.d.ts +30 -0
  62. package/dist/outbound-api/auditRedact.js +8 -0
  63. package/dist/outbound-api/billingCapture.cjs +8 -0
  64. package/dist/outbound-api/billingCapture.d.cts +61 -0
  65. package/dist/outbound-api/billingCapture.d.ts +61 -0
  66. package/dist/outbound-api/billingCapture.js +8 -0
  67. package/dist/outbound-api/quotaWarn.cjs +12 -0
  68. package/dist/outbound-api/quotaWarn.d.cts +43 -0
  69. package/dist/outbound-api/quotaWarn.d.ts +43 -0
  70. package/dist/outbound-api/quotaWarn.js +12 -0
  71. package/dist/outbound-api/routeResolver.cjs +2 -2
  72. package/dist/outbound-api/routeResolver.d.cts +3 -2
  73. package/dist/outbound-api/routeResolver.d.ts +3 -2
  74. package/dist/outbound-api/routeResolver.js +1 -1
  75. package/dist/outbound-api/types.d.cts +2 -1
  76. package/dist/outbound-api/types.d.ts +2 -1
  77. package/dist/outbound-api.cjs +33 -23
  78. package/dist/outbound-api.d.cts +9 -140
  79. package/dist/outbound-api.d.ts +9 -140
  80. package/dist/outbound-api.js +32 -22
  81. package/dist/pipeline/AuthSource.d.cts +6 -0
  82. package/dist/pipeline/AuthSource.d.ts +6 -0
  83. package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
  84. package/dist/pipeline/SubscriptionAuthSource.js +1 -1
  85. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +6 -0
  86. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +6 -0
  87. package/dist/pipeline/auditUsageStash.cjs +10 -0
  88. package/dist/pipeline/auditUsageStash.d.cts +37 -0
  89. package/dist/pipeline/auditUsageStash.d.ts +37 -0
  90. package/dist/pipeline/auditUsageStash.js +10 -0
  91. package/dist/pipeline/executeProviderCall.cjs +2 -2
  92. package/dist/pipeline/executeProviderCall.js +1 -1
  93. package/dist/pipeline/upstreamFetch.cjs +15 -0
  94. package/dist/pipeline/upstreamFetch.d.cts +89 -0
  95. package/dist/pipeline/upstreamFetch.d.ts +89 -0
  96. package/dist/pipeline/upstreamFetch.js +15 -0
  97. package/dist/pipeline/upstreamTrace.cjs +14 -0
  98. package/dist/pipeline/upstreamTrace.d.cts +85 -0
  99. package/dist/pipeline/upstreamTrace.d.ts +85 -0
  100. package/dist/pipeline/upstreamTrace.js +14 -0
  101. package/dist/pipeline/webhookEmit.cjs +10 -0
  102. package/dist/pipeline/webhookEmit.d.cts +36 -0
  103. package/dist/pipeline/webhookEmit.d.ts +36 -0
  104. package/dist/pipeline/webhookEmit.js +10 -0
  105. package/dist/ports.d.cts +2 -1
  106. package/dist/ports.d.ts +2 -1
  107. package/dist/provider-proxy/ProviderProxy.cjs +26 -19
  108. package/dist/provider-proxy/ProviderProxy.js +25 -18
  109. package/dist/provider-proxy/ingress/providerProxyShared.cjs +28 -19
  110. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +17 -1
  111. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +17 -1
  112. package/dist/provider-proxy/ingress/providerProxyShared.js +27 -18
  113. package/dist/provider-proxy/types.d.cts +7 -0
  114. package/dist/provider-proxy/types.d.ts +7 -0
  115. package/dist/provider-proxy.cjs +26 -19
  116. package/dist/provider-proxy.js +25 -18
  117. package/dist/{routeResolver-B1NglTfe.d.ts → routeResolver-C4T7yClx.d.ts} +1 -1
  118. package/dist/{routeResolver-CbG5uBgm.d.cts → routeResolver-CB3tvJKy.d.cts} +1 -1
  119. package/dist/transformer/transformers/AnthropicTransformer.cjs +2 -2
  120. package/dist/transformer/transformers/AnthropicTransformer.js +1 -1
  121. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +3 -3
  122. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +2 -2
  123. package/dist/transformer/transformers/GeminiTransformer.cjs +3 -3
  124. package/dist/transformer/transformers/GeminiTransformer.js +2 -2
  125. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
  126. package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
  127. package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +2 -2
  128. package/dist/transformer/transformers/OpenCodeGoTransformer.js +1 -1
  129. package/dist/transformer/transformers.cjs +8 -8
  130. package/dist/transformer/transformers.js +7 -7
  131. package/dist/transformer.cjs +8 -8
  132. package/dist/transformer.js +7 -7
  133. package/dist/{types-aBFFXoBz.d.cts → types-B8Arpxn0.d.cts} +14 -90
  134. package/dist/{types-6OUY_xfA.d.ts → types-lgPYQuZS.d.ts} +14 -90
  135. package/dist/usage/usage-recorder.cjs +3 -2
  136. package/dist/usage/usage-recorder.js +2 -1
  137. package/dist/usage.cjs +3 -2
  138. package/dist/usage.js +2 -1
  139. package/package.json +64 -64
  140. package/dist/chunk-S6JGLF3G.cjs +0 -89
  141. package/dist/{chunk-FTQ7IQUC.js → chunk-C6OV7GCC.js} +8 -8
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Sayo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sayo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE CHANGED
@@ -1,57 +1,57 @@
1
- @omnicross/core — THIRD-PARTY NOTICES
2
- ======================================
3
-
4
- This package contains code adapted from, and depends on, the following
5
- third-party works. Their respective licenses apply to those portions.
6
-
7
- --------------------------------------------------------------------------------
8
- 1. musistudio/llms (MIT License)
9
- --------------------------------------------------------------------------------
10
-
11
- The transformer subsystem (`src/transformer/`) — the unified-IR request/response
12
- transformer chain (`TransformerService`, `TransformerChainExecutor`, and the
13
- built-in transformers) — is adapted from the `musistudio/llms` project, the
14
- upstream of the transformer intermediate representation.
15
-
16
- Copyright (c) 2025 musistudio
17
- https://github.com/musistudio/llms
18
-
19
- Permission is hereby granted, free of charge, to any person obtaining a copy
20
- of this software and associated documentation files (the "Software"), to deal
21
- in the Software without restriction, including without limitation the rights
22
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
- copies of the Software, and to permit persons to whom the Software is
24
- furnished to do so, subject to the following conditions:
25
-
26
- The above copyright notice and this permission notice shall be included in
27
- all copies or substantial portions of the Software.
28
-
29
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
- SOFTWARE.
36
-
37
- --------------------------------------------------------------------------------
38
- 2. @mozilla/readability (Apache License 2.0)
39
- --------------------------------------------------------------------------------
40
-
41
- The built-in web-fetch tool (`src/completion/builtin-web-fetch.ts`) uses
42
- `@mozilla/readability` to extract readable article content from fetched HTML.
43
-
44
- Copyright Mozilla Foundation and contributors
45
- https://github.com/mozilla/readability
46
-
47
- Licensed under the Apache License, Version 2.0 (the "License"); you may not
48
- use this file except in compliance with the License. You may obtain a copy of
49
- the License at
50
-
51
- http://www.apache.org/licenses/LICENSE-2.0
52
-
53
- Unless required by applicable law or agreed to in writing, software
54
- distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
55
- WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
56
- License for the specific language governing permissions and limitations under
57
- the License.
1
+ @omnicross/core — THIRD-PARTY NOTICES
2
+ ======================================
3
+
4
+ This package contains code adapted from, and depends on, the following
5
+ third-party works. Their respective licenses apply to those portions.
6
+
7
+ --------------------------------------------------------------------------------
8
+ 1. musistudio/llms (MIT License)
9
+ --------------------------------------------------------------------------------
10
+
11
+ The transformer subsystem (`src/transformer/`) — the unified-IR request/response
12
+ transformer chain (`TransformerService`, `TransformerChainExecutor`, and the
13
+ built-in transformers) — is adapted from the `musistudio/llms` project, the
14
+ upstream of the transformer intermediate representation.
15
+
16
+ Copyright (c) 2025 musistudio
17
+ https://github.com/musistudio/llms
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining a copy
20
+ of this software and associated documentation files (the "Software"), to deal
21
+ in the Software without restriction, including without limitation the rights
22
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23
+ copies of the Software, and to permit persons to whom the Software is
24
+ furnished to do so, subject to the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be included in
27
+ all copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35
+ SOFTWARE.
36
+
37
+ --------------------------------------------------------------------------------
38
+ 2. @mozilla/readability (Apache License 2.0)
39
+ --------------------------------------------------------------------------------
40
+
41
+ The built-in web-fetch tool (`src/completion/builtin-web-fetch.ts`) uses
42
+ `@mozilla/readability` to extract readable article content from fetched HTML.
43
+
44
+ Copyright Mozilla Foundation and contributors
45
+ https://github.com/mozilla/readability
46
+
47
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not
48
+ use this file except in compliance with the License. You may obtain a copy of
49
+ the License at
50
+
51
+ http://www.apache.org/licenses/LICENSE-2.0
52
+
53
+ Unless required by applicable law or agreed to in writing, software
54
+ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
55
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
56
+ License for the specific language governing permissions and limitations under
57
+ the License.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
- # @omnicross/core
2
-
3
- The omnicross LLM serving core — provider dispatch, the completion pipeline, the transformer chain, the outbound API server, and the resident provider proxy. Embed it in any Node project, or run it via [`@omnicross/daemon`](https://www.npmjs.com/package/@omnicross/daemon).
4
-
5
- Part of the [omnicross](https://github.com/Dumoedss/omnicross) monorepo — see the root README for the full overview.
6
-
7
- ```bash
8
- npm install @omnicross/core @omnicross/contracts
9
- ```
10
-
11
- ## License
12
-
13
- [MIT](LICENSE)
14
-
15
- This package adapts third-party work under its own license — see the `NOTICE` file.
1
+ # @omnicross/core
2
+
3
+ The omnicross LLM serving core — provider dispatch, the completion pipeline, the transformer chain, the outbound API server, and the resident provider proxy. Embed it in any Node project, or run it via [`@omnicross/daemon`](https://www.npmjs.com/package/@omnicross/daemon).
4
+
5
+ Part of the [omnicross](https://github.com/Dumoedss/omnicross) monorepo — see the root README for the full overview.
6
+
7
+ ```bash
8
+ npm install @omnicross/core @omnicross/contracts
9
+ ```
10
+
11
+ ## License
12
+
13
+ [MIT](LICENSE)
14
+
15
+ This package adapts third-party work under its own license — see the `NOTICE` file.
@@ -1,11 +1,12 @@
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
- var _chunkS6JGLF3Gcjs = require('../chunk-S6JGLF3G.cjs');
4
3
 
4
+ var _chunkDDMRUL76cjs = require('../chunk-DDMRUL76.cjs');
5
+ require('../chunk-JWVTXXPX.cjs');
5
6
 
6
7
 
7
- var _chunkRSJ3TWJQcjs = require('../chunk-RSJ3TWJQ.cjs');
8
- require('../chunk-YGXJGRFI.cjs');
8
+ var _chunkPG7PS2NNcjs = require('../chunk-PG7PS2NN.cjs');
9
+ require('../chunk-3Z5BQZFM.cjs');
9
10
 
10
11
  // src/auth/GeminiCodeAssistProjectResolver.ts
11
12
  var FREE_TIER_ID = "free-tier";
@@ -25,7 +26,7 @@ var GeminiCodeAssistHandshakeError = class extends Error {
25
26
  var GeminiCodeAssistProjectResolver = (_class = class {
26
27
  // upstream-proxy: the Code Assist handshake is upstream egress → honor the
27
28
  // gemini proxy by default (still injectable for tests).
28
- constructor(fetchImpl = (url, init) => _chunkS6JGLF3Gcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
29
+ constructor(fetchImpl = (url, init) => _chunkPG7PS2NNcjs.fetchUpstream.call(void 0, url, init, { providerId: "gemini" })) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
29
30
  this.fetchImpl = fetchImpl;
30
31
  }
31
32
 
@@ -59,7 +60,7 @@ var GeminiCodeAssistProjectResolver = (_class = class {
59
60
  return run;
60
61
  }
61
62
  codeAssistUrl(method) {
62
- return `${_chunkRSJ3TWJQcjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkRSJ3TWJQcjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
63
+ return `${_chunkDDMRUL76cjs.resolveCodeAssistEndpoint.call(void 0, )}/${_chunkDDMRUL76cjs.resolveCodeAssistApiVersion.call(void 0, )}:${method}`;
63
64
  }
64
65
  /** Seed project id from env; reject a purely-numeric value (project NUMBER). */
65
66
  seedProjectId() {
@@ -1,11 +1,12 @@
1
- import {
2
- fetchUpstream
3
- } from "../chunk-BO4RFWBR.js";
4
1
  import {
5
2
  resolveCodeAssistApiVersion,
6
3
  resolveCodeAssistEndpoint
7
- } from "../chunk-Z7Y2NPHY.js";
8
- import "../chunk-S4WBV25P.js";
4
+ } from "../chunk-MFZ5437A.js";
5
+ import "../chunk-6QZGDLL4.js";
6
+ import {
7
+ fetchUpstream
8
+ } from "../chunk-D3TDKWRP.js";
9
+ import "../chunk-SYQF7OIR.js";
9
10
 
10
11
  // src/auth/GeminiCodeAssistProjectResolver.ts
11
12
  var FREE_TIER_ID = "free-tier";
@@ -25,9 +25,10 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
25
25
  const input = [];
26
26
  for (const msg of request.messages) {
27
27
  if (msg.role === "system") {
28
+ const sysText = typeof msg.content === "string" ? msg.content : flattenContent(msg.content);
28
29
  input.push({
29
30
  role: "developer",
30
- content: typeof msg.content === "string" ? msg.content : flattenContent(msg.content)
31
+ content: [{ type: "input_text", text: sysText }]
31
32
  });
32
33
  } else if (msg.role === "tool") {
33
34
  input.push({
@@ -36,17 +37,20 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
36
37
  output: typeof msg.content === "string" ? msg.content : ""
37
38
  });
38
39
  } else {
40
+ const text = typeof msg.content === "string" ? msg.content : flattenContent(msg.content);
39
41
  const entry = {
40
42
  role: msg.role,
41
- content: typeof msg.content === "string" ? msg.content : flattenContent(msg.content)
43
+ content: [{ type: msg.role === "assistant" ? "output_text" : "input_text", text }]
42
44
  };
43
45
  if (msg.role === "assistant" && _optionalChain([msg, 'access', _ => _.tool_calls, 'optionalAccess', _2 => _2.length])) {
44
46
  input.push(entry);
45
47
  for (const tc of msg.tool_calls) {
48
+ const callId = tc.id;
49
+ const itemId = callId.startsWith("fc_") ? callId : `fc_${callId.replace(/^(call_|fc_)/, "")}`;
46
50
  input.push({
47
51
  type: "function_call",
48
- id: tc.id,
49
- call_id: tc.id,
52
+ id: itemId,
53
+ call_id: callId,
50
54
  name: tc.function.name,
51
55
  arguments: tc.function.arguments
52
56
  });
@@ -59,8 +63,18 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
59
63
  const body = {
60
64
  model: request.model,
61
65
  input,
62
- stream: _nullishCoalesce(request.stream, () => ( false)),
63
- ...request.max_tokens ? { max_output_tokens: request.max_tokens } : {},
66
+ // codex's backend REQUIRES `stream:true` (it 400s with "Stream must be
67
+ // set to true" otherwise). Always force it; a non-streaming CLIENT is
68
+ // served by aggregating the SSE upstream of the wire (the ingress buffers
69
+ // it into a single message), not by asking codex for a non-streaming reply.
70
+ stream: true,
71
+ // `store:false` is required by the codex backend and accepted by the
72
+ // public Responses API (which defaults to store:true). Always set it so
73
+ // codex relays (no discoverable url token) work without configuration.
74
+ store: false,
75
+ // `max_output_tokens` is intentionally omitted: the codex backend rejects
76
+ // it, and the public API falls back to its default when absent. If a
77
+ // public provider ever needs it honored, gate that on an opt-out flag.
64
78
  ...request.temperature !== void 0 ? { temperature: request.temperature } : {}
65
79
  };
66
80
  if (_optionalChain([request, 'access', _3 => _3.reasoning, 'optionalAccess', _4 => _4.effort]) && request.reasoning.effort !== "none") {
@@ -162,7 +176,19 @@ var OpenAIResponseTransformer = (_class = class {constructor() { _class.prototyp
162
176
  */
163
177
  async transformResponseOut(response, _context) {
164
178
  const contentType = _nullishCoalesce(response.headers.get("Content-Type"), () => ( ""));
165
- if (contentType.includes("text/event-stream")) {
179
+ let isSse = contentType.includes("text/event-stream");
180
+ if (!isSse && response.body) {
181
+ const peek = response.clone();
182
+ try {
183
+ const reader = peek.body.getReader();
184
+ const { value } = await reader.read();
185
+ reader.releaseLock();
186
+ const head = value ? new TextDecoder().decode(value).trimStart() : "";
187
+ isSse = head.startsWith("event:") || head.startsWith("data:");
188
+ } catch (e2) {
189
+ }
190
+ }
191
+ if (isSse) {
166
192
  if (!response.body) {
167
193
  throw new Error("Stream response body is null");
168
194
  }
@@ -315,11 +341,12 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
315
341
  const messageId = `chatcmpl-${Date.now()}`;
316
342
  let model = "unknown";
317
343
  let hasEmittedRole = false;
344
+ let hasToolCalls = false;
318
345
  const safeEnqueue = (str) => {
319
346
  if (!isClosed) {
320
347
  try {
321
348
  controller.enqueue(encoder.encode(str));
322
- } catch (e2) {
349
+ } catch (e3) {
323
350
  isClosed = true;
324
351
  }
325
352
  }
@@ -371,29 +398,65 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
371
398
  }]);
372
399
  }
373
400
  break;
401
+ case "response.output_item.added": {
402
+ const item = event.item;
403
+ if (_optionalChain([item, 'optionalAccess', _18 => _18.type]) !== "function_call") break;
404
+ if (!hasEmittedRole) {
405
+ emitChunk([{ index: 0, delta: { role: "assistant", content: null }, finish_reason: null }]);
406
+ hasEmittedRole = true;
407
+ }
408
+ hasToolCalls = true;
409
+ emitChunk([{
410
+ index: 0,
411
+ delta: {
412
+ tool_calls: [{
413
+ index: _nullishCoalesce(event.output_index, () => ( 0)),
414
+ id: item.call_id,
415
+ type: "function",
416
+ function: { name: item.name, arguments: "" }
417
+ }]
418
+ },
419
+ finish_reason: null
420
+ }]);
421
+ break;
422
+ }
423
+ case "response.function_call_arguments.delta": {
424
+ hasToolCalls = true;
425
+ emitChunk([{
426
+ index: 0,
427
+ delta: {
428
+ tool_calls: [{
429
+ index: _nullishCoalesce(event.output_index, () => ( 0)),
430
+ function: { arguments: _nullishCoalesce(event.delta, () => ( "")) }
431
+ }]
432
+ },
433
+ finish_reason: null
434
+ }]);
435
+ break;
436
+ }
374
437
  case "response.completed": {
375
438
  const resp = event.response;
376
- const respUsage = _optionalChain([resp, 'optionalAccess', _18 => _18.usage]);
439
+ const respUsage = _optionalChain([resp, 'optionalAccess', _19 => _19.usage]);
377
440
  const usage = respUsage ? {
378
441
  prompt_tokens: respUsage.input_tokens || 0,
379
442
  completion_tokens: respUsage.output_tokens || 0,
380
443
  total_tokens: (respUsage.input_tokens || 0) + (respUsage.output_tokens || 0)
381
444
  } : void 0;
382
- emitChunk([{ index: 0, delta: {}, finish_reason: "stop" }], usage);
445
+ emitChunk([{ index: 0, delta: {}, finish_reason: hasToolCalls ? "tool_calls" : "stop" }], usage);
383
446
  safeEnqueue("data: [DONE]\n\n");
384
447
  break;
385
448
  }
386
449
  case "error":
387
450
  emitChunk([{
388
451
  index: 0,
389
- delta: { content: `[Error: ${_optionalChain([event, 'access', _19 => _19.error, 'optionalAccess', _20 => _20.message]) || "Unknown error"}]` },
452
+ delta: { content: `[Error: ${_optionalChain([event, 'access', _20 => _20.error, 'optionalAccess', _21 => _21.message]) || "Unknown error"}]` },
390
453
  finish_reason: "stop"
391
454
  }]);
392
455
  break;
393
456
  default:
394
457
  break;
395
458
  }
396
- } catch (e3) {
459
+ } catch (e4) {
397
460
  }
398
461
  }
399
462
  }
@@ -403,7 +466,7 @@ function convertResponseApiStreamToOpenAI(responseApiStream) {
403
466
  if (!isClosed) {
404
467
  try {
405
468
  controller.close();
406
- } catch (e4) {
469
+ } catch (e5) {
407
470
  }
408
471
  }
409
472
  reader.releaseLock();
@@ -422,11 +485,14 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
422
485
  let accumulatedContent = "";
423
486
  let model = "unknown";
424
487
  const responseId = `resp_${Date.now()}`;
488
+ const toolCalls = /* @__PURE__ */ new Map();
489
+ const toolOutputIndex = /* @__PURE__ */ new Map();
490
+ let nextOutputIndex = 1;
425
491
  const safeEnqueue = (str) => {
426
492
  if (!isClosed) {
427
493
  try {
428
494
  controller.enqueue(encoder.encode(str));
429
- } catch (e5) {
495
+ } catch (e6) {
430
496
  isClosed = true;
431
497
  }
432
498
  }
@@ -454,34 +520,96 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
454
520
  if (data === "[DONE]") continue;
455
521
  try {
456
522
  const chunk = JSON.parse(data);
457
- const choice = _optionalChain([chunk, 'access', _21 => _21.choices, 'optionalAccess', _22 => _22[0]]);
523
+ const choice = _optionalChain([chunk, 'access', _22 => _22.choices, 'optionalAccess', _23 => _23[0]]);
458
524
  model = chunk.model || model;
459
525
  if (!choice) continue;
460
- if (_optionalChain([choice, 'access', _23 => _23.delta, 'optionalAccess', _24 => _24.content])) {
526
+ if (_optionalChain([choice, 'access', _24 => _24.delta, 'optionalAccess', _25 => _25.content])) {
461
527
  accumulatedContent += choice.delta.content;
462
528
  emitEvent({ type: "response.output_text.delta", delta: choice.delta.content });
463
529
  }
464
- if (_optionalChain([choice, 'access', _25 => _25.delta, 'optionalAccess', _26 => _26.thinking, 'optionalAccess', _27 => _27.content])) {
530
+ if (_optionalChain([choice, 'access', _26 => _26.delta, 'optionalAccess', _27 => _27.thinking, 'optionalAccess', _28 => _28.content])) {
465
531
  emitEvent({
466
532
  type: "response.reasoning_summary_text.delta",
467
533
  delta: choice.delta.thinking.content
468
534
  });
469
535
  }
536
+ if (_optionalChain([choice, 'access', _29 => _29.delta, 'optionalAccess', _30 => _30.tool_calls])) {
537
+ for (const tc of choice.delta.tool_calls) {
538
+ const tcIndex = typeof tc["index"] === "number" ? tc["index"] : 0;
539
+ const func = _nullishCoalesce(tc["function"], () => ( {}));
540
+ let entry = toolCalls.get(tcIndex);
541
+ if (!entry) {
542
+ const callId = typeof tc["id"] === "string" ? tc["id"] : `call_${Date.now()}_${tcIndex}`;
543
+ const name = typeof func["name"] === "string" ? func["name"] : "";
544
+ entry = { callId, name, arguments: "" };
545
+ toolCalls.set(tcIndex, entry);
546
+ const outIdx = nextOutputIndex++;
547
+ toolOutputIndex.set(tcIndex, outIdx);
548
+ const itemId = callId.startsWith("fc_") ? callId : `fc_${callId.replace(/^(call_|fc_)/, "")}`;
549
+ emitEvent({
550
+ type: "response.output_item.added",
551
+ 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
+ }
560
+ });
561
+ }
562
+ const argsFragment = typeof func["arguments"] === "string" ? func["arguments"] : "";
563
+ if (argsFragment) {
564
+ entry.arguments += argsFragment;
565
+ emitEvent({
566
+ type: "response.function_call_arguments.delta",
567
+ output_index: toolOutputIndex.get(tcIndex),
568
+ delta: argsFragment
569
+ });
570
+ }
571
+ }
572
+ }
470
573
  if (choice.finish_reason) {
471
574
  emitEvent({ type: "response.output_text.done", text: accumulatedContent });
575
+ const output = [];
576
+ if (accumulatedContent) {
577
+ output.push({
578
+ type: "message",
579
+ role: "assistant",
580
+ content: [{ type: "output_text", text: accumulatedContent }]
581
+ });
582
+ }
583
+ 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
+ });
593
+ emitEvent({
594
+ 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
+ }
604
+ });
605
+ }
472
606
  emitEvent({
473
607
  type: "response.completed",
474
608
  response: {
475
609
  id: responseId,
476
610
  status: "completed",
477
611
  model,
478
- output: [
479
- {
480
- type: "message",
481
- role: "assistant",
482
- content: [{ type: "output_text", text: accumulatedContent }]
483
- }
484
- ],
612
+ output,
485
613
  usage: chunk.usage ? {
486
614
  input_tokens: chunk.usage.prompt_tokens || 0,
487
615
  output_tokens: chunk.usage.completion_tokens || 0,
@@ -490,7 +618,7 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
490
618
  }
491
619
  });
492
620
  }
493
- } catch (e6) {
621
+ } catch (e7) {
494
622
  }
495
623
  }
496
624
  }
@@ -500,7 +628,7 @@ function convertOpenAIStreamToResponseApi(openaiStream) {
500
628
  if (!isClosed) {
501
629
  try {
502
630
  controller.close();
503
- } catch (e7) {
631
+ } catch (e8) {
504
632
  }
505
633
  }
506
634
  reader.releaseLock();
@@ -0,0 +1,33 @@
1
+ // src/outbound-api/quotaWarn.ts
2
+ var WEBHOOK_QUOTA_WARN_RATIO = 0.8;
3
+ function computeQuotaWarnings(limits, spend, ratio = WEBHOOK_QUOTA_WARN_RATIO) {
4
+ const out = [];
5
+ const consider = (scope, limit, spent, windowStart) => {
6
+ if (limit == null || limit <= 0) return;
7
+ if (spent >= limit) return;
8
+ if (spent >= ratio * limit) out.push({ scope, limitUsd: limit, spentUsd: spent, windowStart });
9
+ };
10
+ consider("daily", limits.dailyUsd, spend.dailyUsd, spend.dailyWindowStart);
11
+ consider("weekly", limits.weeklyUsd, spend.weeklyUsd, spend.weeklyWindowStart);
12
+ consider("total", limits.totalUsd, spend.totalUsd, 0);
13
+ return out;
14
+ }
15
+ var WARN_GUARD_MAX = 1e4;
16
+ var warned = /* @__PURE__ */ new Set();
17
+ function markQuotaWarnedOnce(keyId, scope, windowStart) {
18
+ const key = `${keyId}\0${scope}\0${windowStart}`;
19
+ if (warned.has(key)) return false;
20
+ if (warned.size >= WARN_GUARD_MAX) warned.clear();
21
+ warned.add(key);
22
+ return true;
23
+ }
24
+ function __resetQuotaWarnGuardForTests() {
25
+ warned.clear();
26
+ }
27
+
28
+ export {
29
+ WEBHOOK_QUOTA_WARN_RATIO,
30
+ computeQuotaWarnings,
31
+ markQuotaWarnedOnce,
32
+ __resetQuotaWarnGuardForTests
33
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/pipeline/upstreamTrace.ts
2
+ var _promises = require('fs/promises');
3
+ var _path = require('path');
4
+ var tracePath = null;
5
+ var SECRET_HEADER_NAMES = /* @__PURE__ */ new Set([
6
+ "authorization",
7
+ "api-key",
8
+ "x-api-key",
9
+ "x-goog-api-key"
10
+ ]);
11
+ function setUpstreamTracePath(path) {
12
+ tracePath = typeof path === "string" && path.trim() ? path.trim() : null;
13
+ }
14
+ function getUpstreamTracePath() {
15
+ return tracePath;
16
+ }
17
+ function redactHeaders(headers) {
18
+ const out = {};
19
+ if (!headers) return out;
20
+ let entries;
21
+ if (Array.isArray(headers)) {
22
+ entries = headers;
23
+ } else if (typeof headers.entries === "function") {
24
+ entries = Array.from(headers.entries());
25
+ } else {
26
+ entries = Object.entries(headers);
27
+ }
28
+ for (const [key, value] of entries) {
29
+ out[key] = SECRET_HEADER_NAMES.has(key.toLowerCase()) ? "***REDACTED***" : String(value);
30
+ }
31
+ return out;
32
+ }
33
+ async function writeUpstreamTrace(record) {
34
+ const path = tracePath;
35
+ if (!path) return;
36
+ try {
37
+ await _promises.mkdir.call(void 0, _path.dirname.call(void 0, path), { recursive: true });
38
+ await _promises.appendFile.call(void 0, path, JSON.stringify(record) + "\n", "utf8");
39
+ } catch (e) {
40
+ }
41
+ }
42
+ function __resetUpstreamTraceForTests() {
43
+ tracePath = null;
44
+ }
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+ exports.setUpstreamTracePath = setUpstreamTracePath; exports.getUpstreamTracePath = getUpstreamTracePath; exports.redactHeaders = redactHeaders; exports.writeUpstreamTrace = writeUpstreamTrace; exports.__resetUpstreamTraceForTests = __resetUpstreamTraceForTests;