@omnicross/core 0.1.3 → 0.1.4

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 (114) hide show
  1. package/LICENSE +21 -21
  2. package/NOTICE +57 -57
  3. package/README.md +15 -15
  4. package/dist/auth/GeminiCodeAssistProjectResolver.cjs +4 -4
  5. package/dist/auth/GeminiCodeAssistProjectResolver.js +3 -3
  6. package/dist/chunk-3QFXFCHG.js +33 -0
  7. package/dist/chunk-4YINUUKQ.cjs +33 -0
  8. package/dist/chunk-7Y47UCF2.js +142 -0
  9. package/dist/chunk-APYG5QD7.cjs +50 -0
  10. package/dist/{chunk-CWM2ZDU5.js → chunk-BPKCU575.js} +3 -10
  11. package/dist/{chunk-2FMI2B6V.cjs → chunk-DKPXN34V.cjs} +222 -448
  12. package/dist/chunk-E3UCVHLP.cjs +142 -0
  13. package/dist/chunk-FCR77GYM.cjs +33 -0
  14. package/dist/{chunk-N5QFKSDO.js → chunk-HRRYG2AX.js} +2 -1
  15. package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
  16. package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
  17. package/dist/chunk-K5NM7VAH.js +33 -0
  18. package/dist/{chunk-Y6OM7EV7.cjs → chunk-KFI44N2R.cjs} +2 -1
  19. package/dist/{chunk-S6JGLF3G.cjs → chunk-OCEUVQHW.cjs} +27 -4
  20. package/dist/chunk-OE6TDIWW.js +22 -0
  21. package/dist/chunk-OZFM4X3S.js +18 -0
  22. package/dist/{chunk-4DECIFU7.js → chunk-QYTT6GE3.js} +62 -288
  23. package/dist/{chunk-FFALUUZZ.cjs → chunk-RGTR7CIO.cjs} +5 -5
  24. package/dist/{chunk-3QOSDDNI.cjs → chunk-SNYBEXLB.cjs} +6 -13
  25. package/dist/{chunk-2DCNB7DF.cjs → chunk-SU2GCLAC.cjs} +30 -10
  26. package/dist/{chunk-5HTVET6E.js → chunk-TIER4SUC.js} +24 -4
  27. package/dist/{chunk-CZHZGRU7.js → chunk-UHGVBFU3.js} +2 -0
  28. package/dist/chunk-UIBD2YY5.cjs +22 -0
  29. package/dist/{chunk-SVXC36MU.cjs → chunk-VACWOIRE.cjs} +2 -0
  30. package/dist/{chunk-MQNDWYPN.js → chunk-VPBAUQ2M.js} +4 -4
  31. package/dist/chunk-WLYIIEAF.js +50 -0
  32. package/dist/{chunk-BO4RFWBR.js → chunk-XK5CIRMQ.js} +24 -1
  33. package/dist/chunk-XSVNC2UD.cjs +18 -0
  34. package/dist/completion/CompletionService.cjs +22 -16
  35. package/dist/completion/CompletionService.js +21 -15
  36. package/dist/completion.cjs +24 -18
  37. package/dist/completion.js +23 -17
  38. package/dist/index.cjs +33 -24
  39. package/dist/index.d.cts +7 -3
  40. package/dist/index.d.ts +7 -3
  41. package/dist/index.js +42 -33
  42. package/dist/keyPolicy-Cp0FntZl.d.cts +90 -0
  43. package/dist/keyPolicy-Cp0FntZl.d.ts +90 -0
  44. package/dist/outbound-api/auditCapture.cjs +9 -0
  45. package/dist/outbound-api/auditCapture.d.cts +52 -0
  46. package/dist/outbound-api/auditCapture.d.ts +52 -0
  47. package/dist/outbound-api/auditCapture.js +9 -0
  48. package/dist/outbound-api/auditRedact.cjs +8 -0
  49. package/dist/outbound-api/auditRedact.d.cts +30 -0
  50. package/dist/outbound-api/auditRedact.d.ts +30 -0
  51. package/dist/outbound-api/auditRedact.js +8 -0
  52. package/dist/outbound-api/billingCapture.cjs +8 -0
  53. package/dist/outbound-api/billingCapture.d.cts +61 -0
  54. package/dist/outbound-api/billingCapture.d.ts +61 -0
  55. package/dist/outbound-api/billingCapture.js +8 -0
  56. package/dist/outbound-api/quotaWarn.cjs +12 -0
  57. package/dist/outbound-api/quotaWarn.d.cts +43 -0
  58. package/dist/outbound-api/quotaWarn.d.ts +43 -0
  59. package/dist/outbound-api/quotaWarn.js +12 -0
  60. package/dist/outbound-api/routeResolver.cjs +2 -2
  61. package/dist/outbound-api/routeResolver.d.cts +3 -2
  62. package/dist/outbound-api/routeResolver.d.ts +3 -2
  63. package/dist/outbound-api/routeResolver.js +1 -1
  64. package/dist/outbound-api/types.d.cts +2 -1
  65. package/dist/outbound-api/types.d.ts +2 -1
  66. package/dist/outbound-api.cjs +29 -20
  67. package/dist/outbound-api.d.cts +9 -140
  68. package/dist/outbound-api.d.ts +9 -140
  69. package/dist/outbound-api.js +28 -19
  70. package/dist/pipeline/AuthSource.d.cts +6 -0
  71. package/dist/pipeline/AuthSource.d.ts +6 -0
  72. package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
  73. package/dist/pipeline/SubscriptionAuthSource.js +1 -1
  74. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +6 -0
  75. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +6 -0
  76. package/dist/pipeline/auditUsageStash.cjs +10 -0
  77. package/dist/pipeline/auditUsageStash.d.cts +37 -0
  78. package/dist/pipeline/auditUsageStash.d.ts +37 -0
  79. package/dist/pipeline/auditUsageStash.js +10 -0
  80. package/dist/pipeline/executeProviderCall.cjs +2 -2
  81. package/dist/pipeline/executeProviderCall.js +1 -1
  82. package/dist/pipeline/upstreamFetch.cjs +14 -0
  83. package/dist/pipeline/upstreamFetch.d.cts +83 -0
  84. package/dist/pipeline/upstreamFetch.d.ts +83 -0
  85. package/dist/pipeline/upstreamFetch.js +14 -0
  86. package/dist/pipeline/webhookEmit.cjs +10 -0
  87. package/dist/pipeline/webhookEmit.d.cts +36 -0
  88. package/dist/pipeline/webhookEmit.d.ts +36 -0
  89. package/dist/pipeline/webhookEmit.js +10 -0
  90. package/dist/ports.d.cts +2 -1
  91. package/dist/ports.d.ts +2 -1
  92. package/dist/provider-proxy/ProviderProxy.cjs +22 -16
  93. package/dist/provider-proxy/ProviderProxy.js +21 -15
  94. package/dist/provider-proxy/ingress/providerProxyShared.cjs +22 -16
  95. package/dist/provider-proxy/ingress/providerProxyShared.js +21 -15
  96. package/dist/provider-proxy/types.d.cts +7 -0
  97. package/dist/provider-proxy/types.d.ts +7 -0
  98. package/dist/provider-proxy.cjs +22 -16
  99. package/dist/provider-proxy.js +21 -15
  100. package/dist/{routeResolver-B1NglTfe.d.ts → routeResolver-C4T7yClx.d.ts} +1 -1
  101. package/dist/{routeResolver-CbG5uBgm.d.cts → routeResolver-CB3tvJKy.d.cts} +1 -1
  102. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
  103. package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
  104. package/dist/transformer/transformers.cjs +6 -6
  105. package/dist/transformer/transformers.js +5 -5
  106. package/dist/transformer.cjs +7 -7
  107. package/dist/transformer.js +6 -6
  108. package/dist/{types-aBFFXoBz.d.cts → types-B8Arpxn0.d.cts} +14 -90
  109. package/dist/{types-6OUY_xfA.d.ts → types-lgPYQuZS.d.ts} +14 -90
  110. package/dist/usage/usage-recorder.cjs +3 -2
  111. package/dist/usage/usage-recorder.js +2 -1
  112. package/dist/usage.cjs +3 -2
  113. package/dist/usage.js +2 -1
  114. package/package.json +64 -64
@@ -0,0 +1,142 @@
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
+
3
+ var _chunkFCR77GYMcjs = require('./chunk-FCR77GYM.cjs');
4
+
5
+
6
+
7
+ var _chunkAEOZIDEBcjs = require('./chunk-AEOZIDEB.cjs');
8
+
9
+
10
+ var _chunkXSVNC2UDcjs = require('./chunk-XSVNC2UD.cjs');
11
+
12
+ // src/outbound-api/auditCapture.ts
13
+ var _crypto = require('crypto');
14
+ function isStreamingContentType(res) {
15
+ const ct = res.getHeader("content-type");
16
+ const value = Array.isArray(ct) ? ct.join(";") : String(_nullishCoalesce(ct, () => ( "")));
17
+ return value.toLowerCase().includes("text/event-stream");
18
+ }
19
+ function resolveClientIp(req, trustForwardedFor) {
20
+ if (trustForwardedFor) {
21
+ const xff = req.headers["x-forwarded-for"];
22
+ const raw = Array.isArray(xff) ? xff[0] : xff;
23
+ if (typeof raw === "string" && raw.trim()) {
24
+ const first = _optionalChain([raw, 'access', _ => _.split, 'call', _2 => _2(","), 'access', _3 => _3[0], 'optionalAccess', _4 => _4.trim, 'call', _5 => _5()]);
25
+ if (first) return first;
26
+ }
27
+ }
28
+ return _nullishCoalesce(_optionalChain([req, 'access', _6 => _6.socket, 'optionalAccess', _7 => _7.remoteAddress]), () => ( void 0));
29
+ }
30
+ function truncateToBytes(text, maxBytes) {
31
+ const buf = Buffer.from(text, "utf8");
32
+ if (buf.length <= maxBytes) return text;
33
+ return buf.subarray(0, maxBytes).toString("utf8");
34
+ }
35
+ function beginAuditCapture(req, res, now) {
36
+ const config = _chunkAEOZIDEBcjs.getAuditCaptureConfig.call(void 0, );
37
+ if (!config) return null;
38
+ let rawRequestBody;
39
+ const responseChunks = [];
40
+ let responseBytes = 0;
41
+ let streamDetected = false;
42
+ let finished = false;
43
+ const ctx = {
44
+ setRequestBody(raw) {
45
+ if (config.captureBodies) rawRequestBody = raw;
46
+ }
47
+ };
48
+ if (config.captureBodies) {
49
+ installResponseCapture(res, config.maxBodyBytes, {
50
+ push(chunk) {
51
+ responseBytes += chunk.length;
52
+ responseChunks.push(chunk);
53
+ },
54
+ get bytes() {
55
+ return responseBytes;
56
+ },
57
+ markStream() {
58
+ streamDetected = true;
59
+ },
60
+ get isStream() {
61
+ return streamDetected;
62
+ }
63
+ });
64
+ }
65
+ const finalize = () => {
66
+ if (finished) return;
67
+ finished = true;
68
+ try {
69
+ const record = {
70
+ id: _crypto.randomUUID.call(void 0, ),
71
+ ts: now,
72
+ method: _nullishCoalesce(req.method, () => ( "")),
73
+ path: _nullishCoalesce((_nullishCoalesce(req.url, () => ( ""))).split("?")[0], () => ( "")),
74
+ status: res.statusCode,
75
+ latencyMs: Math.max(0, Date.now() - now)
76
+ };
77
+ if (ctx.keyId != null) record.keyId = ctx.keyId;
78
+ const ip = resolveClientIp(req, config.trustForwardedFor);
79
+ if (ip) record.ip = ip;
80
+ const ua = req.headers["user-agent"];
81
+ if (typeof ua === "string" && ua) record.ua = ua;
82
+ if (ctx.model) record.model = ctx.model;
83
+ if (ctx.provider) record.provider = ctx.provider;
84
+ const usage = _chunkXSVNC2UDcjs.readAuditUsage.call(void 0, res);
85
+ if (usage) {
86
+ if (typeof usage.inputTokens === "number") record.inputTokens = usage.inputTokens;
87
+ if (typeof usage.outputTokens === "number") record.outputTokens = usage.outputTokens;
88
+ if (typeof usage.costUsd === "number") record.costUsd = usage.costUsd;
89
+ if (!record.model && usage.model) record.model = usage.model;
90
+ if (!record.provider && usage.provider) record.provider = usage.provider;
91
+ }
92
+ if (ctx.error) record.error = _chunkFCR77GYMcjs.redactAuditText.call(void 0, ctx.error);
93
+ if (config.captureBodies) {
94
+ if (rawRequestBody != null && rawRequestBody.length > 0) {
95
+ record.requestBody = _chunkFCR77GYMcjs.redactAuditText.call(void 0, truncateToBytes(rawRequestBody, config.maxBodyBytes));
96
+ }
97
+ if (!streamDetected && responseChunks.length > 0) {
98
+ const body = Buffer.concat(responseChunks).toString("utf8");
99
+ record.responseBody = _chunkFCR77GYMcjs.redactAuditText.call(void 0, body);
100
+ }
101
+ }
102
+ _chunkAEOZIDEBcjs.recordAudit.call(void 0, record);
103
+ } catch (e) {
104
+ }
105
+ };
106
+ res.once("close", finalize);
107
+ return ctx;
108
+ }
109
+ function installResponseCapture(res, maxBodyBytes, sink) {
110
+ let contentTypeChecked = false;
111
+ const capture = (chunk) => {
112
+ if (sink.isStream) return;
113
+ if (!contentTypeChecked) {
114
+ contentTypeChecked = true;
115
+ if (isStreamingContentType(res)) {
116
+ sink.markStream();
117
+ return;
118
+ }
119
+ }
120
+ if (sink.bytes >= maxBodyBytes) return;
121
+ let buf = null;
122
+ if (Buffer.isBuffer(chunk)) buf = chunk;
123
+ else if (typeof chunk === "string") buf = Buffer.from(chunk, "utf8");
124
+ if (!buf || buf.length === 0) return;
125
+ const remaining = maxBodyBytes - sink.bytes;
126
+ sink.push(buf.length > remaining ? buf.subarray(0, remaining) : buf);
127
+ };
128
+ const originalWrite = res.write.bind(res);
129
+ const originalEnd = res.end.bind(res);
130
+ res.write = ((chunk, ...args) => {
131
+ if (chunk != null) capture(chunk);
132
+ return originalWrite(chunk, ...args);
133
+ });
134
+ res.end = ((chunk, ...args) => {
135
+ if (chunk != null && typeof chunk !== "function") capture(chunk);
136
+ return originalEnd(chunk, ...args);
137
+ });
138
+ }
139
+
140
+
141
+
142
+ exports.beginAuditCapture = beginAuditCapture;
@@ -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;
@@ -33,7 +33,8 @@ var SubscriptionAuthSource = class {
33
33
  upstreamUrl: hints.upstreamUrl,
34
34
  resolvedModel: hints.model,
35
35
  sessionKey: hints.sessionKey,
36
- reportSelection: hints.reportSelection
36
+ reportSelection: hints.reportSelection,
37
+ preferredAccountId: hints.preferredAccountId
37
38
  });
38
39
  } catch (err) {
39
40
  console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", serializeError(err));
@@ -23,6 +23,9 @@ async function executeProviderCall(ctx) {
23
23
  const finalBody = prepareBody ? await prepareBody(requestBody, config) : requestBody;
24
24
  const url = resolveUrl(config);
25
25
  const headers = buildHeaders(config);
26
+ if (!headers["content-type"] && !headers["Content-Type"]) {
27
+ headers["content-type"] = "application/json";
28
+ }
26
29
  const fetched = await fetchFn(url, headers, finalBody);
27
30
  let response = fetched;
28
31
  if (runResponseChain) {
@@ -23,6 +23,9 @@ async function executeProviderCall(ctx) {
23
23
  const finalBody = prepareBody ? await prepareBody(requestBody, config) : requestBody;
24
24
  const url = resolveUrl(config);
25
25
  const headers = buildHeaders(config);
26
+ if (!headers["content-type"] && !headers["Content-Type"]) {
27
+ headers["content-type"] = "application/json";
28
+ }
26
29
  const fetched = await fetchFn(url, headers, finalBody);
27
30
  let response = fetched;
28
31
  if (runResponseChain) {
@@ -0,0 +1,33 @@
1
+ // 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 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
+ export {
31
+ AUDIT_REDACTED,
32
+ redactAuditText
33
+ };
@@ -33,7 +33,8 @@ var SubscriptionAuthSource = class {
33
33
  upstreamUrl: hints.upstreamUrl,
34
34
  resolvedModel: hints.model,
35
35
  sessionKey: hints.sessionKey,
36
- reportSelection: hints.reportSelection
36
+ reportSelection: hints.reportSelection,
37
+ preferredAccountId: hints.preferredAccountId
37
38
  });
38
39
  } catch (err) {
39
40
  console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", _chunkSVNDB62Dcjs.serializeError.call(void 0, err));
@@ -1,15 +1,30 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/pipeline/upstreamFetch.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/pipeline/upstreamFetch.ts
2
2
  var _undici = require('undici');
3
3
  var _socks = require('socks');
4
4
  var resolver = null;
5
5
  var generation = 0;
6
6
  var cache = /* @__PURE__ */ new Map();
7
+ function setUpstreamProxyResolver(fn) {
8
+ resolver = fn;
9
+ bumpUpstreamProxyGeneration();
10
+ }
11
+ function bumpUpstreamProxyGeneration() {
12
+ generation += 1;
13
+ const old = cache;
14
+ cache = /* @__PURE__ */ new Map();
15
+ for (const dispatcher of old.values()) {
16
+ try {
17
+ void _optionalChain([dispatcher, 'access', _ => _.close, 'optionalCall', _2 => _2()]);
18
+ } catch (e) {
19
+ }
20
+ }
21
+ }
7
22
  function normalizeProxy(cfg) {
8
23
  if ("url" in cfg) {
9
24
  let u;
10
25
  try {
11
26
  u = new URL(cfg.url);
12
- } catch (e) {
27
+ } catch (e2) {
13
28
  return void 0;
14
29
  }
15
30
  const proto = u.protocol.replace(/:$/, "").toLowerCase();
@@ -64,7 +79,7 @@ function resolveUpstreamDispatcher(ctx) {
64
79
  let cfg;
65
80
  try {
66
81
  cfg = active(ctx);
67
- } catch (e2) {
82
+ } catch (e3) {
68
83
  return void 0;
69
84
  }
70
85
  if (!cfg) return void 0;
@@ -83,7 +98,15 @@ function fetchUpstream(url, init, ctx) {
83
98
  if (!dispatcher) return fetch(url, init);
84
99
  return fetch(url, { ...init, dispatcher });
85
100
  }
101
+ function __resetUpstreamProxyForTests() {
102
+ resolver = null;
103
+ bumpUpstreamProxyGeneration();
104
+ }
105
+
106
+
107
+
108
+
86
109
 
87
110
 
88
111
 
89
- exports.fetchUpstream = fetchUpstream;
112
+ exports.setUpstreamProxyResolver = setUpstreamProxyResolver; exports.bumpUpstreamProxyGeneration = bumpUpstreamProxyGeneration; exports.resolveUpstreamDispatcher = resolveUpstreamDispatcher; exports.fetchUpstream = fetchUpstream; exports.__resetUpstreamProxyForTests = __resetUpstreamProxyForTests;
@@ -0,0 +1,22 @@
1
+ // src/pipeline/webhookEmit.ts
2
+ var sink = null;
3
+ function setWebhookSink(fn) {
4
+ sink = fn;
5
+ }
6
+ function emitWebhookEvent(event) {
7
+ const active = sink;
8
+ if (!active) return;
9
+ try {
10
+ active(event);
11
+ } catch {
12
+ }
13
+ }
14
+ function __resetWebhookSinkForTests() {
15
+ sink = null;
16
+ }
17
+
18
+ export {
19
+ setWebhookSink,
20
+ emitWebhookEvent,
21
+ __resetWebhookSinkForTests
22
+ };
@@ -0,0 +1,18 @@
1
+ // src/pipeline/auditUsageStash.ts
2
+ var stash = /* @__PURE__ */ new WeakMap();
3
+ function stashAuditUsage(key, detail) {
4
+ const existing = stash.get(key);
5
+ stash.set(key, existing ? { ...existing, ...detail } : { ...detail });
6
+ }
7
+ function readAuditUsage(key) {
8
+ return stash.get(key);
9
+ }
10
+ function __clearAuditUsageForTests(key) {
11
+ stash.delete(key);
12
+ }
13
+
14
+ export {
15
+ stashAuditUsage,
16
+ readAuditUsage,
17
+ __clearAuditUsageForTests
18
+ };