@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
@@ -1,9 +1,30 @@
1
+ import {
2
+ getUpstreamTracePath,
3
+ redactHeaders,
4
+ writeUpstreamTrace
5
+ } from "./chunk-SYQF7OIR.js";
6
+
1
7
  // src/pipeline/upstreamFetch.ts
2
8
  import { Agent, buildConnector, ProxyAgent } from "undici";
3
9
  import { SocksClient } from "socks";
4
10
  var resolver = null;
5
11
  var generation = 0;
6
12
  var cache = /* @__PURE__ */ new Map();
13
+ function setUpstreamProxyResolver(fn) {
14
+ resolver = fn;
15
+ bumpUpstreamProxyGeneration();
16
+ }
17
+ function bumpUpstreamProxyGeneration() {
18
+ generation += 1;
19
+ const old = cache;
20
+ cache = /* @__PURE__ */ new Map();
21
+ for (const dispatcher of old.values()) {
22
+ try {
23
+ void dispatcher.close?.();
24
+ } catch {
25
+ }
26
+ }
27
+ }
7
28
  function normalizeProxy(cfg) {
8
29
  if ("url" in cfg) {
9
30
  let u;
@@ -80,10 +101,70 @@ function resolveUpstreamDispatcher(ctx) {
80
101
  }
81
102
  function fetchUpstream(url, init, ctx) {
82
103
  const dispatcher = resolveUpstreamDispatcher({ ...ctx ?? {}, url });
83
- if (!dispatcher) return fetch(url, init);
84
- return fetch(url, { ...init, dispatcher });
104
+ const doFetch = dispatcher ? () => fetch(url, { ...init, dispatcher }) : () => fetch(url, init);
105
+ const tracePath = getUpstreamTracePath();
106
+ if (!tracePath || !ctx?.providerId) return doFetch();
107
+ const startedAt = Date.now();
108
+ const method = typeof init.method === "string" ? init.method : "GET";
109
+ const requestHeaders = redactHeaders(
110
+ init.headers
111
+ );
112
+ const requestBody = typeof init.body === "string" ? init.body : null;
113
+ const providerId = ctx.providerId;
114
+ const accountId = ctx.accountId;
115
+ return doFetch().then((res) => {
116
+ const clone = res.clone();
117
+ const status = res.status;
118
+ const statusText = res.statusText;
119
+ const responseHeaders = redactHeaders(res.headers);
120
+ void clone.text().then((body) => {
121
+ writeUpstreamTrace({
122
+ ts: startedAt,
123
+ durationMs: Date.now() - startedAt,
124
+ providerId,
125
+ accountId,
126
+ url,
127
+ method,
128
+ requestHeaders,
129
+ requestBody,
130
+ status,
131
+ statusText,
132
+ responseHeaders,
133
+ responseBody: body,
134
+ responseBytes: Buffer.byteLength(body, "utf8")
135
+ });
136
+ }).catch(() => {
137
+ });
138
+ return res;
139
+ }).catch((err) => {
140
+ const msg = err instanceof Error ? err.message : String(err);
141
+ writeUpstreamTrace({
142
+ ts: startedAt,
143
+ durationMs: Date.now() - startedAt,
144
+ providerId,
145
+ accountId,
146
+ url,
147
+ method,
148
+ requestHeaders,
149
+ requestBody,
150
+ status: 0,
151
+ statusText: "",
152
+ responseHeaders: {},
153
+ responseBody: `<UPSTREAM FETCH ERROR: ${msg}>`,
154
+ responseBytes: 0
155
+ });
156
+ throw err;
157
+ });
158
+ }
159
+ function __resetUpstreamProxyForTests() {
160
+ resolver = null;
161
+ bumpUpstreamProxyGeneration();
85
162
  }
86
163
 
87
164
  export {
88
- fetchUpstream
165
+ setUpstreamProxyResolver,
166
+ bumpUpstreamProxyGeneration,
167
+ resolveUpstreamDispatcher,
168
+ fetchUpstream,
169
+ __resetUpstreamProxyForTests
89
170
  };
@@ -3,7 +3,7 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkYGXJGRFIcjs = require('./chunk-YGXJGRFI.cjs');
6
+ var _chunkJWVTXXPXcjs = require('./chunk-JWVTXXPX.cjs');
7
7
 
8
8
  // src/transformer/transformers/GeminiCodeAssistTransformer.ts
9
9
  var DEFAULT_CODE_ASSIST_ENDPOINT = "https://cloudcode-pa.googleapis.com";
@@ -117,7 +117,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
117
117
  * openaiResponsesIngress). `undefined` is the valid fresh free-tier value.
118
118
  */
119
119
  async transformRequestIn(request, provider, _context) {
120
- const inner = _chunkYGXJGRFIcjs.buildRequestBody.call(void 0, request);
120
+ const inner = _chunkJWVTXXPXcjs.buildRequestBody.call(void 0, request);
121
121
  const envelope = {
122
122
  model: request.model,
123
123
  project: provider.geminiProject,
@@ -147,7 +147,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
147
147
  if (inner && typeof inner === "object" && !("model" in inner) && "model" in r) {
148
148
  inner.model = r.model;
149
149
  }
150
- return _chunkYGXJGRFIcjs.transformRequestOut.call(void 0, inner);
150
+ return _chunkJWVTXXPXcjs.transformRequestOut.call(void 0, inner);
151
151
  }
152
152
  /**
153
153
  * Code Assist response → OpenAI-compatible. PEEL the `.response` envelope from
@@ -155,7 +155,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
155
155
  */
156
156
  async transformResponseOut(response, _context) {
157
157
  const unwrapped = await unwrapCodeAssistResponse(response);
158
- return _chunkYGXJGRFIcjs.transformResponseOut.call(void 0, unwrapped, this.name, this.logger);
158
+ return _chunkJWVTXXPXcjs.transformResponseOut.call(void 0, unwrapped, this.name, this.logger);
159
159
  }
160
160
  /**
161
161
  * OpenAI-compatible response → Code Assist (endpoint-encode parity). Re-wraps
@@ -164,7 +164,7 @@ var GeminiCodeAssistTransformer = (_class = class {constructor() { _class.protot
164
164
  * `transformResponseOut`'s peel.
165
165
  */
166
166
  async transformResponseIn(response, _context) {
167
- const geminiResponse = await _chunkYGXJGRFIcjs.transformResponseIn.call(void 0, response, this.logger);
167
+ const geminiResponse = await _chunkJWVTXXPXcjs.transformResponseIn.call(void 0, response, this.logger);
168
168
  const contentType = _nullishCoalesce(geminiResponse.headers.get("Content-Type"), () => ( ""));
169
169
  if (contentType.includes("text/event-stream")) {
170
170
  return geminiResponse;
@@ -0,0 +1,33 @@
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 redactAuditText(text) {
22
+ if (typeof text !== "string" || text.length === 0) return _nullishCoalesce(text, () => ( ""));
23
+ let out = text;
24
+ for (const { re, replace } of RULES) {
25
+ out = out.replace(re, replace);
26
+ }
27
+ return out;
28
+ }
29
+
30
+
31
+
32
+
33
+ exports.AUDIT_REDACTED = AUDIT_REDACTED; exports.redactAuditText = redactAuditText;