@omnicross/core 0.1.10 → 0.2.0

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 (166) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +57 -57
  3. package/README.md +22 -15
  4. package/dist/{CompletionService-kNA17cfI.d.cts → CompletionService-BiJqftc-.d.cts} +1 -1
  5. package/dist/{CompletionService-C3BX0Ovy.d.ts → CompletionService-NXN_Av5W.d.ts} +1 -1
  6. package/dist/{ProviderProxy-QdwNV6l1.d.cts → ProviderProxy-CgIcCVwk.d.cts} +1 -1
  7. package/dist/{ProviderProxy--ROec6VI.d.ts → ProviderProxy-DYoY5XoT.d.ts} +1 -1
  8. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +6 -6
  9. package/dist/auth/GeminiCodeAssistProjectResolver.js +4 -4
  10. package/dist/{chunk-QUSEZNYS.cjs → chunk-32SRZFFP.cjs} +4 -1
  11. package/dist/chunk-4JOU54M5.js +200 -0
  12. package/dist/{chunk-2UTGX6FM.js → chunk-4VVCXVB7.js} +1 -1
  13. package/dist/chunk-6DDYNS2B.cjs +384 -0
  14. package/dist/{chunk-HKB656B4.js → chunk-6OC3ORW6.js} +55 -287
  15. package/dist/{chunk-GXEZ2R3E.js → chunk-6OKXH2TW.js} +18 -7
  16. package/dist/{chunk-TIT74RIL.cjs → chunk-7B56AJBB.cjs} +6214 -2423
  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-IIRPUVPH.cjs → chunk-7ZHBN75N.cjs} +3 -1
  20. package/dist/{chunk-RJ5ZGNI3.js → chunk-CFSGYFOZ.js} +1 -1
  21. package/dist/chunk-CTKM773J.cjs +3919 -0
  22. package/dist/chunk-DEIUR2TH.js +3919 -0
  23. package/dist/{chunk-WNKWAEUR.js → chunk-EYGBM2VC.js} +3 -1
  24. package/dist/{chunk-NGYOO5TO.js → chunk-FJNKXOWE.js} +9 -9
  25. package/dist/{chunk-UWDW6PN3.cjs → chunk-FX325I5Q.cjs} +20 -9
  26. package/dist/chunk-G4CZIUIB.cjs +200 -0
  27. package/dist/chunk-HCOQQAZE.cjs +123 -0
  28. package/dist/{chunk-55FMGZ3L.js → chunk-HN74IGEO.js} +1 -1
  29. package/dist/{chunk-ZY6KU6P3.js → chunk-HOMUGKHR.js} +8 -5
  30. package/dist/{chunk-AOFWNWLT.cjs → chunk-IUL4VWNU.cjs} +22 -1
  31. package/dist/{chunk-5LNYGCIW.cjs → chunk-KIQ2HA2A.cjs} +5 -5
  32. package/dist/{chunk-MUHWHQVM.cjs → chunk-KQBLZMP6.cjs} +4 -3
  33. package/dist/chunk-LFEH7CEO.js +384 -0
  34. package/dist/chunk-N76KU6F5.js +123 -0
  35. package/dist/{chunk-CMVXX7ON.cjs → chunk-NOITAVHA.cjs} +114 -58
  36. package/dist/{chunk-Q27JY5RG.cjs → chunk-OIKREZVQ.cjs} +7 -4
  37. package/dist/{chunk-RJUONLUQ.cjs → chunk-OST5RJOJ.cjs} +1 -1
  38. package/dist/{chunk-6D4W22P4.js → chunk-QIIAMBTM.js} +4 -1
  39. package/dist/{chunk-56QD3YW6.cjs → chunk-QWNUOR7F.cjs} +11 -4
  40. package/dist/{chunk-S3DYFEBE.js → chunk-R4VCO2CB.js} +10 -1
  41. package/dist/{chunk-ZQQUD66M.cjs → chunk-SQMAEDNE.cjs} +63 -295
  42. package/dist/{chunk-4VZX5F4T.cjs → chunk-T6NWPIYZ.cjs} +5 -2
  43. package/dist/{chunk-P7EM6BND.cjs → chunk-TVYA5JSQ.cjs} +10 -10
  44. package/dist/{chunk-EBLFCNPY.js → chunk-U47LQXPB.js} +5 -2
  45. package/dist/{chunk-N7OOJI5V.js → chunk-V2UKUTJ3.js} +5 -0
  46. package/dist/{chunk-45FHEOKW.js → chunk-V53ZEFXC.js} +92 -36
  47. package/dist/{chunk-OC6DOOFX.cjs → chunk-VXRTQZF2.cjs} +5 -5
  48. package/dist/{chunk-FEBAQI5A.js → chunk-WSJE42SG.js} +4964 -1173
  49. package/dist/{chunk-RICPANBY.cjs → chunk-WX2E2G7H.cjs} +13 -4
  50. package/dist/{chunk-DE2SRBFZ.js → chunk-X335TJNS.js} +4 -3
  51. package/dist/{chunk-N2EIM2XJ.js → chunk-ZLNHPUFA.js} +22 -1
  52. package/dist/completion/CompletionService.cjs +29 -26
  53. package/dist/completion/CompletionService.d.cts +3 -2
  54. package/dist/completion/CompletionService.d.ts +3 -2
  55. package/dist/completion/CompletionService.js +28 -25
  56. package/dist/completion.cjs +37 -34
  57. package/dist/completion.d.cts +3 -2
  58. package/dist/completion.d.ts +3 -2
  59. package/dist/completion.js +36 -33
  60. package/dist/image-generation.cjs +52 -0
  61. package/dist/image-generation.d.cts +93 -0
  62. package/dist/image-generation.d.ts +93 -0
  63. package/dist/image-generation.js +52 -0
  64. package/dist/index.cjs +126 -31
  65. package/dist/index.d.cts +11 -7
  66. package/dist/index.d.ts +11 -7
  67. package/dist/index.js +142 -47
  68. package/dist/openai-operation.cjs +18 -0
  69. package/dist/openai-operation.d.cts +19 -0
  70. package/dist/openai-operation.d.ts +19 -0
  71. package/dist/openai-operation.js +18 -0
  72. package/dist/outbound-api/auditCapture.cjs +3 -3
  73. package/dist/outbound-api/auditCapture.d.cts +13 -2
  74. package/dist/outbound-api/auditCapture.d.ts +13 -2
  75. package/dist/outbound-api/auditCapture.js +2 -2
  76. package/dist/outbound-api/auditRedact.cjs +2 -2
  77. package/dist/outbound-api/auditRedact.js +1 -1
  78. package/dist/outbound-api/routeResolver.cjs +2 -2
  79. package/dist/outbound-api/routeResolver.d.cts +7 -4
  80. package/dist/outbound-api/routeResolver.d.ts +7 -4
  81. package/dist/outbound-api/routeResolver.js +1 -1
  82. package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -1
  83. package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -1
  84. package/dist/outbound-api/types.d.cts +6 -3
  85. package/dist/outbound-api/types.d.ts +6 -3
  86. package/dist/outbound-api.cjs +48 -31
  87. package/dist/outbound-api.d.cts +95 -9
  88. package/dist/outbound-api.d.ts +95 -9
  89. package/dist/outbound-api.js +47 -30
  90. package/dist/pipeline/AccountAllowanceScheduling.d.cts +18 -15
  91. package/dist/pipeline/AccountAllowanceScheduling.d.ts +18 -15
  92. package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
  93. package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
  94. package/dist/pipeline/SubscriptionAccountHealth.cjs +2 -2
  95. package/dist/pipeline/SubscriptionAccountHealth.d.cts +7 -0
  96. package/dist/pipeline/SubscriptionAccountHealth.d.ts +7 -0
  97. package/dist/pipeline/SubscriptionAccountHealth.js +1 -1
  98. package/dist/pipeline/executeProviderCall.cjs +2 -2
  99. package/dist/pipeline/executeProviderCall.d.cts +11 -6
  100. package/dist/pipeline/executeProviderCall.d.ts +11 -6
  101. package/dist/pipeline/executeProviderCall.js +1 -1
  102. package/dist/pipeline/upstreamFetch.cjs +2 -2
  103. package/dist/pipeline/upstreamFetch.d.cts +5 -0
  104. package/dist/pipeline/upstreamFetch.d.ts +5 -0
  105. package/dist/pipeline/upstreamFetch.js +1 -1
  106. package/dist/ports.d.cts +6 -3
  107. package/dist/ports.d.ts +6 -3
  108. package/dist/provider-proxy/ProviderProxy.cjs +29 -26
  109. package/dist/provider-proxy/ProviderProxy.d.cts +3 -2
  110. package/dist/provider-proxy/ProviderProxy.d.ts +3 -2
  111. package/dist/provider-proxy/ProviderProxy.js +28 -25
  112. package/dist/provider-proxy/identity/codexCliHeaders.cjs +4 -2
  113. package/dist/provider-proxy/identity/codexCliHeaders.d.cts +26 -6
  114. package/dist/provider-proxy/identity/codexCliHeaders.d.ts +26 -6
  115. package/dist/provider-proxy/identity/codexCliHeaders.js +5 -3
  116. package/dist/provider-proxy/ingress/providerProxyShared.cjs +31 -26
  117. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +21 -8
  118. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +21 -8
  119. package/dist/provider-proxy/ingress/providerProxyShared.js +30 -25
  120. package/dist/provider-proxy/types.d.cts +14 -483
  121. package/dist/provider-proxy/types.d.ts +14 -483
  122. package/dist/provider-proxy.cjs +43 -26
  123. package/dist/provider-proxy.d.cts +30 -8
  124. package/dist/provider-proxy.d.ts +30 -8
  125. package/dist/provider-proxy.js +42 -25
  126. package/dist/{routeResolver-C0mkkZaM.d.ts → routeResolver-CTCcSHWu.d.ts} +4 -2
  127. package/dist/{routeResolver-CVFE8KKe.d.cts → routeResolver-rpKQLyDO.d.cts} +4 -2
  128. package/dist/transformer/TransformerChainExecutor.cjs +2 -2
  129. package/dist/transformer/TransformerChainExecutor.d.cts +2 -2
  130. package/dist/transformer/TransformerChainExecutor.d.ts +2 -2
  131. package/dist/transformer/TransformerChainExecutor.js +1 -1
  132. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.cjs +16 -0
  133. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.cts +53 -0
  134. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.d.ts +53 -0
  135. package/dist/transformer/transformers/AnthropicOpenAIToAnthropicStream.js +16 -0
  136. package/dist/transformer/transformers/AnthropicTransformer.cjs +4 -3
  137. package/dist/transformer/transformers/AnthropicTransformer.js +3 -2
  138. package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -4
  139. package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +3 -3
  140. package/dist/transformer/transformers/GeminiTransformer.cjs +4 -4
  141. package/dist/transformer/transformers/GeminiTransformer.js +3 -3
  142. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -3
  143. package/dist/transformer/transformers/OpenAIResponseTransformer.js +2 -2
  144. package/dist/transformer/transformers/OpenAITransformer.cjs +3 -3
  145. package/dist/transformer/transformers/OpenAITransformer.js +2 -2
  146. package/dist/transformer/transformers.cjs +10 -9
  147. package/dist/transformer/transformers.js +13 -12
  148. package/dist/transformer/types.d.cts +39 -4
  149. package/dist/transformer/types.d.ts +39 -4
  150. package/dist/transformer.cjs +14 -13
  151. package/dist/transformer.js +14 -13
  152. package/dist/{types-BB8pxk_3.d.ts → types-5T223WYQ.d.ts} +183 -23
  153. package/dist/types-Bd72H4SB.d.ts +196 -0
  154. package/dist/types-CVRge76p.d.ts +1115 -0
  155. package/dist/types-CbglB73l.d.cts +196 -0
  156. package/dist/types-DsHBBk3h.d.cts +1115 -0
  157. package/dist/{types-C2MwkLah.d.cts → types-jjU24eYG.d.cts} +183 -23
  158. package/dist/usage.cjs +2 -2
  159. package/dist/usage.d.cts +6 -1
  160. package/dist/usage.d.ts +6 -1
  161. package/dist/usage.js +1 -1
  162. package/package.json +69 -64
  163. package/dist/chunk-FCR77GYM.cjs +0 -33
  164. package/dist/chunk-K5NM7VAH.js +0 -33
  165. /package/dist/{chunk-XXFYLL7R.js → chunk-ECZ3ZE2C.js} +0 -0
  166. /package/dist/{chunk-3SCOLIPT.cjs → chunk-MXI2PWIC.cjs} +0 -0
@@ -30,6 +30,7 @@ var TransformerChainExecutor = class {
30
30
  providerName: provider.name
31
31
  };
32
32
  let requestBody = request;
33
+ let endpointRequest;
33
34
  let config = {};
34
35
  let bypass = false;
35
36
  bypass = this.shouldBypassTransformers(
@@ -60,6 +61,7 @@ var TransformerChainExecutor = class {
60
61
  this.logger.error(`transformRequestOut error: ${this.getErrorMessage(error)}`);
61
62
  throw error;
62
63
  }
64
+ endpointRequest = requestBody;
63
65
  }
64
66
  if (!bypass && chain.providerTransformers.length > 0) {
65
67
  this.logger.debug(`Executing ${chain.providerTransformers.length} provider transformers`);
@@ -118,7 +120,7 @@ var TransformerChainExecutor = class {
118
120
  true
119
121
  );
120
122
  }
121
- return { requestBody, config, bypass };
123
+ return { requestBody, endpointRequest, config, bypass };
122
124
  }
123
125
  /**
124
126
  * Execute the response transformation chain
@@ -1,18 +1,18 @@
1
- import {
2
- AnthropicTransformer
3
- } from "./chunk-HKB656B4.js";
4
- import {
5
- GeminiTransformer
6
- } from "./chunk-55FMGZ3L.js";
7
1
  import {
8
2
  OpenAIResponseTransformer
9
- } from "./chunk-45FHEOKW.js";
3
+ } from "./chunk-V53ZEFXC.js";
10
4
  import {
11
5
  OpenAITransformer
12
- } from "./chunk-CCVRRJOX.js";
6
+ } from "./chunk-7PIUVCKK.js";
7
+ import {
8
+ AnthropicTransformer
9
+ } from "./chunk-6OC3ORW6.js";
10
+ import {
11
+ GeminiTransformer
12
+ } from "./chunk-HN74IGEO.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 = {
@@ -1,10 +1,10 @@
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; }
2
2
 
3
- var _chunkFCR77GYMcjs = require('./chunk-FCR77GYM.cjs');
4
3
 
4
+ var _chunkAEOZIDEBcjs = require('./chunk-AEOZIDEB.cjs');
5
5
 
6
6
 
7
- var _chunkAEOZIDEBcjs = require('./chunk-AEOZIDEB.cjs');
7
+ var _chunkHCOQQAZEcjs = require('./chunk-HCOQQAZE.cjs');
8
8
 
9
9
 
10
10
  var _chunkXSVNC2UDcjs = require('./chunk-XSVNC2UD.cjs');
@@ -195,24 +195,35 @@ function resolveClientIp(req, trustForwardedFor) {
195
195
  }
196
196
  return _nullishCoalesce(_optionalChain([req, 'access', _8 => _8.socket, 'optionalAccess', _9 => _9.remoteAddress]), () => ( void 0));
197
197
  }
198
- function beginAuditCapture(req, res, now) {
198
+ function beginAuditCapture(req, res, now, options) {
199
199
  const config = _chunkAEOZIDEBcjs.getAuditCaptureConfig.call(void 0, );
200
200
  if (!config) return null;
201
+ const captureBodies = config.captureBodies;
201
202
  let requestBody;
202
203
  const responseChunks = [];
203
204
  let responseBytes = 0;
204
205
  let responseTruncated = false;
206
+ let bodiesSuppressed = _optionalChain([options, 'optionalAccess', _10 => _10.suppressBodies]) === true;
205
207
  let finished = false;
206
208
  const ctx = {
207
209
  setRequestBody(raw) {
208
- if (config.captureBodies) {
209
- requestBody = truncateToBytes(_chunkFCR77GYMcjs.redactAuditText.call(void 0, raw), config.maxBodyBytes);
210
+ if (captureBodies && !bodiesSuppressed) {
211
+ requestBody = truncateToBytes(_chunkHCOQQAZEcjs.redactAuditText.call(void 0, raw), config.maxBodyBytes);
210
212
  }
213
+ },
214
+ suppressBodies() {
215
+ if (bodiesSuppressed) return;
216
+ bodiesSuppressed = true;
217
+ requestBody = void 0;
218
+ responseChunks.length = 0;
219
+ responseBytes = 0;
220
+ responseTruncated = false;
211
221
  }
212
222
  };
213
- if (config.captureBodies) {
223
+ if (captureBodies && !bodiesSuppressed) {
214
224
  installResponseCapture(res, {
215
225
  push(chunk) {
226
+ if (bodiesSuppressed) return;
216
227
  if (config.maxBodyBytes < 0) {
217
228
  responseChunks.push(chunk);
218
229
  responseBytes += chunk.length;
@@ -261,9 +272,9 @@ function beginAuditCapture(req, res, now) {
261
272
  if (!record.model && usage.model) record.model = usage.model;
262
273
  if (!record.provider && usage.provider) record.provider = usage.provider;
263
274
  }
264
- if (ctx.error) record.error = _chunkFCR77GYMcjs.redactAuditText.call(void 0, ctx.error);
275
+ if (ctx.error) record.error = _chunkHCOQQAZEcjs.redactAuditText.call(void 0, ctx.error);
265
276
  if (ctx.sessionKey) record.sessionKey = ctx.sessionKey;
266
- if (config.captureBodies) {
277
+ if (captureBodies && !bodiesSuppressed) {
267
278
  if (requestBody != null && requestBody.length > 0) {
268
279
  record.requestBody = requestBody;
269
280
  }
@@ -271,7 +282,7 @@ function beginAuditCapture(req, res, now) {
271
282
  const captured = Buffer.concat(responseChunks, responseBytes);
272
283
  const decoded = decodeCapturedBody(captured, responseTruncated);
273
284
  const body = config.compactStreamingBodies ? compactSseBody(decoded) : decoded;
274
- record.responseBody = truncateToBytes(_chunkFCR77GYMcjs.redactAuditText.call(void 0, body), config.maxBodyBytes);
285
+ record.responseBody = truncateToBytes(_chunkHCOQQAZEcjs.redactAuditText.call(void 0, body), config.maxBodyBytes);
275
286
  }
276
287
  if (record.requestBody !== void 0 || record.responseBody !== void 0) {
277
288
  record.hasBody = true;
@@ -0,0 +1,200 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2; var _class3;// 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 = class extends Error {
75
+ constructor(code, message) {
76
+ super(message);_class.prototype.__init.call(this);;
77
+ this.code = code;
78
+ }
79
+
80
+ __init() {this.name = "OpenAIOperationRegistrationError"}
81
+ }, _class);
82
+ var OpenAIOperationError = (_class2 = class extends Error {
83
+ __init2() {this.name = "OpenAIOperationError"}
84
+
85
+
86
+
87
+
88
+ constructor(init) {
89
+ super(init.message);_class2.prototype.__init2.call(this);;
90
+ this.status = init.status;
91
+ this.code = init.code;
92
+ this.retryable = _nullishCoalesce(init.retryable, () => ( false));
93
+ this.headers = _nullishCoalesce(init.headers, () => ( {}));
94
+ }
95
+ }, _class2);
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 = (_class3 = class {constructor() { _class3.prototype.__init3.call(this); }
128
+ __init3() {this.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
+ }, _class3);
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ exports.getOpenAIOperation = getOpenAIOperation; exports.classifyOpenAIOperation = classifyOpenAIOperation; exports.OpenAIOperationRegistrationError = OpenAIOperationRegistrationError; exports.OpenAIOperationError = OpenAIOperationError; exports.writeOpenAIOperationError = writeOpenAIOperationError; exports.unsupportedOpenAIOperation = unsupportedOpenAIOperation; exports.OpenAIOperationRegistry = OpenAIOperationRegistry;
@@ -0,0 +1,123 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/outbound-api/auditRedact.ts
2
+ var AUDIT_REDACTED = "***REDACTED***";
3
+ var RULES = [
4
+ // `sk-…` family (Anthropic sk-ant-, omnicross sk-omnicross-, OpenAI sk-proj-/sk-).
5
+ { re: /\bsk-[A-Za-z0-9_-]{6,}/g, replace: AUDIT_REDACTED },
6
+ // Google API keys.
7
+ { re: /\bAIza[A-Za-z0-9_-]{10,}/g, replace: AUDIT_REDACTED },
8
+ // `Bearer <token>` (auth headers echoed into a body / SSE error).
9
+ { re: /\bBearer\s+[A-Za-z0-9._~+/=-]{6,}/gi, replace: `Bearer ${AUDIT_REDACTED}` },
10
+ // Inline `x-api-key` / `api-key` / `authorization` label followed by a value.
11
+ {
12
+ re: /\b(x-api-key|api[_-]?key|authorization)(["']?\s*[:=]\s*["']?)[A-Za-z0-9._~+/=-]{6,}/gi,
13
+ replace: `$1$2${AUDIT_REDACTED}`
14
+ },
15
+ // `x-goog-api-key` header echoed inline.
16
+ {
17
+ re: /\b(x-goog-api-key)(["']?\s*[:=]\s*["']?)[A-Za-z0-9._~+/=-]{6,}/gi,
18
+ replace: `$1$2${AUDIT_REDACTED}`
19
+ }
20
+ ];
21
+ function redactEncryptedContentValue(value) {
22
+ if (!value || typeof value !== "object") return false;
23
+ if (Array.isArray(value)) {
24
+ let changed2 = false;
25
+ for (const item of value) changed2 = redactEncryptedContentValue(item) || changed2;
26
+ return changed2;
27
+ }
28
+ let changed = false;
29
+ const record = value;
30
+ for (const [key, nested] of Object.entries(record)) {
31
+ if (key === "encrypted_content") {
32
+ record[key] = AUDIT_REDACTED;
33
+ changed = true;
34
+ } else {
35
+ changed = redactEncryptedContentValue(nested) || changed;
36
+ }
37
+ }
38
+ return changed;
39
+ }
40
+ function redactJsonValue(text) {
41
+ try {
42
+ const parsed = JSON.parse(text);
43
+ return redactEncryptedContentValue(parsed) ? JSON.stringify(parsed) : null;
44
+ } catch (e) {
45
+ return null;
46
+ }
47
+ }
48
+ function redactEncryptedContentSse(text) {
49
+ return text.replace(/^(\s*data:\s*)([^\r\n]*)(\r?)$/gm, (line, prefix, payload, cr) => {
50
+ if (!payload || payload.trim() === "[DONE]") return line;
51
+ const redacted = redactJsonValue(payload.trim());
52
+ return redacted === null ? line : `${prefix}${redacted}${cr}`;
53
+ });
54
+ }
55
+ function findJsonLikeValueEnd(text, start) {
56
+ const first = text[start];
57
+ if (first === '"' || first === "'") {
58
+ let escaped = false;
59
+ for (let index = start + 1; index < text.length; index += 1) {
60
+ const char = text[index];
61
+ if (escaped) escaped = false;
62
+ else if (char === "\\") escaped = true;
63
+ else if (char === first) return index + 1;
64
+ }
65
+ return text.length;
66
+ }
67
+ if (first === "{" || first === "[") {
68
+ const opening = first;
69
+ const closing = first === "{" ? "}" : "]";
70
+ let depth = 0;
71
+ let quote = "";
72
+ let escaped = false;
73
+ for (let index = start; index < text.length; index += 1) {
74
+ const char = text[index];
75
+ if (quote) {
76
+ if (escaped) escaped = false;
77
+ else if (char === "\\") escaped = true;
78
+ else if (char === quote) quote = "";
79
+ continue;
80
+ }
81
+ if (char === '"' || char === "'") quote = char;
82
+ else if (char === opening) depth += 1;
83
+ else if (char === closing && --depth === 0) return index + 1;
84
+ }
85
+ return text.length;
86
+ }
87
+ let end = start;
88
+ while (end < text.length && !/[\r\n,}\]]/.test(text[end])) end += 1;
89
+ return end;
90
+ }
91
+ function redactEncryptedContentText(text) {
92
+ const key = /["']encrypted_content["']\s*:\s*/g;
93
+ let output = "";
94
+ let cursor = 0;
95
+ for (; ; ) {
96
+ const match = key.exec(text);
97
+ if (!match) break;
98
+ const valueStart = match.index + match[0].length;
99
+ const valueEnd = findJsonLikeValueEnd(text, valueStart);
100
+ output += text.slice(cursor, valueStart) + JSON.stringify(AUDIT_REDACTED);
101
+ cursor = valueEnd;
102
+ key.lastIndex = valueEnd;
103
+ }
104
+ return cursor === 0 ? text : output + text.slice(cursor);
105
+ }
106
+ function redactEncryptedContent(text) {
107
+ const completeJson = redactJsonValue(text);
108
+ if (completeJson !== null) return completeJson;
109
+ return redactEncryptedContentText(redactEncryptedContentSse(text));
110
+ }
111
+ function redactAuditText(text) {
112
+ if (typeof text !== "string" || text.length === 0) return _nullishCoalesce(text, () => ( ""));
113
+ let out = redactEncryptedContent(text);
114
+ for (const { re, replace } of RULES) {
115
+ out = out.replace(re, replace);
116
+ }
117
+ return out;
118
+ }
119
+
120
+
121
+
122
+
123
+ exports.AUDIT_REDACTED = AUDIT_REDACTED; exports.redactAuditText = redactAuditText;
@@ -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/GeminiTransformer.ts
9
9
  var GeminiTransformer = class {
@@ -1,10 +1,10 @@
1
- import {
2
- resolveApiFormat
3
- } from "./chunk-H5JUT3KV.js";
4
1
  import {
5
2
  OPENROUTER_APP_HEADERS,
6
3
  isOpenRouterProvider
7
4
  } from "./chunk-HUZZZ3JL.js";
5
+ import {
6
+ resolveApiFormat
7
+ } from "./chunk-H5JUT3KV.js";
8
8
 
9
9
  // src/completion/header-builder.ts
10
10
  function getProviderHeaders(provider, apiKey) {
@@ -17,8 +17,11 @@ function getProviderHeaders(provider, apiKey) {
17
17
  // Third-party Anthropic-Messages relays often gate on a Bearer token
18
18
  // rather than x-api-key; `provider.useBearer` opts into that.
19
19
  ...provider.useBearer ? { Authorization: `Bearer ${apiKey}` } : { "x-api-key": apiKey },
20
- "anthropic-version": "2025-01-10"
21
- // Required for extended thinking feature
20
+ // Official documented version date (claude-api-protocol-fidelity, R5);
21
+ // the former non-official future-dated value was removed. The BYO
22
+ // same-format path additionally forwards the caller's own
23
+ // `anthropic-version` verbatim when present (see `runSameFormatFetch`).
24
+ "anthropic-version": "2023-06-01"
22
25
  };
23
26
  break;
24
27
  case "google":
@@ -191,6 +191,27 @@ function resolveRequestReasoning(request, provider, options = {}) {
191
191
  return { ...intent, effort: plan.effort, enabled: plan.enabled };
192
192
  }
193
193
 
194
+ // src/transformer/transformWarnings.ts
195
+ var droppedFieldCounts = {};
196
+ var warnedOnce = /* @__PURE__ */ new Set();
197
+ function recordDroppedField(request, field, target) {
198
+ attachTransformWarnings(request).push({ field, target });
199
+ const key = `${field}\0${target}`;
200
+ droppedFieldCounts[key] = (_nullishCoalesce(droppedFieldCounts[key], () => ( 0))) + 1;
201
+ if (!warnedOnce.has(key)) {
202
+ warnedOnce.add(key);
203
+ console.warn(
204
+ `[transform] dropped_field: '${field}' has no representation on the '${target}' wire (counting; values never logged)`
205
+ );
206
+ }
207
+ }
208
+ function attachTransformWarnings(request) {
209
+ const holder = request;
210
+ holder._transformWarnings ??= [];
211
+ return holder._transformWarnings;
212
+ }
213
+
214
+
194
215
 
195
216
 
196
217
 
@@ -200,4 +221,4 @@ function resolveRequestReasoning(request, provider, options = {}) {
200
221
 
201
222
 
202
223
 
203
- exports.THINK_LEVELS = THINK_LEVELS; exports.normalizeThinkLevel = normalizeThinkLevel; exports.extractReasoningIntent = extractReasoningIntent; exports.resolveTargetModelCapabilities = resolveTargetModelCapabilities; exports.resolveReasoningEffort = resolveReasoningEffort; exports.resolveReasoningTokenLimit = resolveReasoningTokenLimit; exports.resolveReasoningPlan = resolveReasoningPlan; exports.resolveRequestReasoning = resolveRequestReasoning;
224
+ exports.THINK_LEVELS = THINK_LEVELS; exports.normalizeThinkLevel = normalizeThinkLevel; exports.extractReasoningIntent = extractReasoningIntent; exports.resolveTargetModelCapabilities = resolveTargetModelCapabilities; exports.resolveReasoningEffort = resolveReasoningEffort; exports.resolveReasoningTokenLimit = resolveReasoningTokenLimit; exports.resolveReasoningPlan = resolveReasoningPlan; exports.resolveRequestReasoning = resolveRequestReasoning; exports.recordDroppedField = recordDroppedField;
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkRICPANBYcjs = require('./chunk-RICPANBY.cjs');
6
+ var _chunkWX2E2G7Hcjs = require('./chunk-WX2E2G7H.cjs');
7
7
 
8
8
  // src/transformer/transformers/GeminiTransformer.ts
9
9
  var GeminiTransformer = (_class = class {
@@ -44,7 +44,7 @@ var GeminiTransformer = (_class = class {
44
44
  * Also builds the correct URL for the Gemini API
45
45
  */
46
46
  async transformRequestIn(request, provider, context) {
47
- const body = _chunkRICPANBYcjs.buildRequestBody.call(void 0,
47
+ const body = _chunkWX2E2G7Hcjs.buildRequestBody.call(void 0,
48
48
  request,
49
49
  provider,
50
50
  context.reasoningSourceFormat === this.name
@@ -69,7 +69,7 @@ var GeminiTransformer = (_class = class {
69
69
  * (For requests coming into the Gemini endpoint)
70
70
  */
71
71
  async transformRequestOut(request, context) {
72
- const unifiedRequest = _chunkRICPANBYcjs.transformRequestOut.call(void 0, request);
72
+ const unifiedRequest = _chunkWX2E2G7Hcjs.transformRequestOut.call(void 0, request);
73
73
  if (_optionalChain([unifiedRequest, 'access', _2 => _2.reasoning, 'optionalAccess', _3 => _3.effort])) {
74
74
  context.reasoningSourceFormat = this.name;
75
75
  }
@@ -79,14 +79,14 @@ var GeminiTransformer = (_class = class {
79
79
  * Transform Gemini response to OpenAI-compatible format
80
80
  */
81
81
  async transformResponseOut(response, _context) {
82
- return _chunkRICPANBYcjs.transformResponseOut.call(void 0, response, this.name, this.logger);
82
+ return _chunkWX2E2G7Hcjs.transformResponseOut.call(void 0, response, this.name, this.logger);
83
83
  }
84
84
  /**
85
85
  * Transform OpenAI-compatible response back to Gemini format
86
86
  * (For endpoint mode — returning Gemini-format responses to the client)
87
87
  */
88
88
  async transformResponseIn(response, _context) {
89
- return _chunkRICPANBYcjs.transformResponseIn.call(void 0, response, this.logger);
89
+ return _chunkWX2E2G7Hcjs.transformResponseIn.call(void 0, response, this.logger);
90
90
  }
91
91
  }, _class.__initStatic(), _class);
92
92
 
@@ -12,9 +12,10 @@ async function executeProviderCall(ctx) {
12
12
  prepareBody,
13
13
  fetchFn,
14
14
  runResponseChain = false,
15
- responseChainRequest
15
+ responseChainRequest,
16
+ preserveEndpointRequestForResponseChain = false
16
17
  } = ctx;
17
- const { requestBody, config } = await executor.executeRequestChain(
18
+ const { requestBody, endpointRequest, config } = await executor.executeRequestChain(
18
19
  request,
19
20
  provider,
20
21
  chain,
@@ -34,7 +35,7 @@ async function executeProviderCall(ctx) {
34
35
  // unified ingresses → their pre-transform request. The caller supplies
35
36
  // it via `responseChainRequest`; fall back to `requestBody` (the proxy
36
37
  // shape) so the contract is never silently `undefined`.
37
- _nullishCoalesce(responseChainRequest, () => ( requestBody)),
38
+ _nullishCoalesce(_nullishCoalesce(responseChainRequest, () => ( (preserveEndpointRequestForResponseChain ? endpointRequest : void 0))), () => ( requestBody)),
38
39
  fetched,
39
40
  provider,
40
41
  chain,