@omnicross/core 0.1.2 → 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 (184) 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 -1
  5. package/dist/auth/GeminiCodeAssistProjectResolver.js +6 -1
  6. package/dist/chunk-3QFXFCHG.js +33 -0
  7. package/dist/chunk-4IH4EL7M.cjs +9 -0
  8. package/dist/chunk-4YINUUKQ.cjs +33 -0
  9. package/dist/chunk-5ENKBSWO.js +311 -0
  10. package/dist/chunk-6RPZADX3.cjs +92 -0
  11. package/dist/chunk-7Y47UCF2.js +142 -0
  12. package/dist/chunk-AEOZIDEB.cjs +32 -0
  13. package/dist/chunk-APYG5QD7.cjs +50 -0
  14. package/dist/{chunk-MNYKI4CI.js → chunk-BPKCU575.js} +29 -0
  15. package/dist/{chunk-SN3YWBX7.cjs → chunk-DKPXN34V.cjs} +2108 -538
  16. package/dist/{chunk-4NBS6KPV.cjs → chunk-DQ5VAYZ6.cjs} +7 -8
  17. package/dist/chunk-E3UCVHLP.cjs +142 -0
  18. package/dist/chunk-FCR77GYM.cjs +33 -0
  19. package/dist/{chunk-74TMJA7Z.js → chunk-HRRYG2AX.js} +8 -4
  20. package/dist/chunk-HUZZZ3JL.js +32 -0
  21. package/dist/{chunk-KUU2RNG6.cjs → chunk-HYN75H6G.cjs} +3 -0
  22. package/dist/{chunk-QOCNX236.js → chunk-IAXWICZU.js} +24 -1
  23. package/dist/{chunk-JO5NLTLY.js → chunk-IK3KE3AU.js} +3 -0
  24. package/dist/{chunk-V5KPWNYX.cjs → chunk-JMJBSACD.cjs} +3 -3
  25. package/dist/chunk-K5NM7VAH.js +33 -0
  26. package/dist/{chunk-N3V2J5ZO.cjs → chunk-KFI44N2R.cjs} +8 -4
  27. package/dist/chunk-L74VDN4A.cjs +32 -0
  28. package/dist/chunk-OCEUVQHW.cjs +112 -0
  29. package/dist/chunk-OE6TDIWW.js +22 -0
  30. package/dist/chunk-OZFM4X3S.js +18 -0
  31. package/dist/{chunk-LKZJEL6E.cjs → chunk-Q27JY5RG.cjs} +6 -4
  32. package/dist/{chunk-SPVWWUHX.cjs → chunk-QWBWGODS.cjs} +24 -1
  33. package/dist/{chunk-2FEVTJWG.js → chunk-QYTT6GE3.js} +1929 -359
  34. package/dist/{chunk-UYPEN5XE.cjs → chunk-RGTR7CIO.cjs} +6 -6
  35. package/dist/chunk-RPII3E6Z.cjs +145 -0
  36. package/dist/{chunk-XBSYYZIY.cjs → chunk-SNYBEXLB.cjs} +31 -2
  37. package/dist/{chunk-2DCNB7DF.cjs → chunk-SU2GCLAC.cjs} +30 -10
  38. package/dist/{chunk-5HTVET6E.js → chunk-TIER4SUC.js} +24 -4
  39. package/dist/chunk-TKJMZBAH.js +32 -0
  40. package/dist/{chunk-ZSVQT3PW.js → chunk-UBWEBKRC.js} +5 -6
  41. package/dist/chunk-UHGVBFU3.js +385 -0
  42. package/dist/chunk-UIBD2YY5.cjs +22 -0
  43. package/dist/chunk-UNEFIWXI.cjs +32 -0
  44. package/dist/chunk-VACWOIRE.cjs +385 -0
  45. package/dist/{chunk-O466Y272.js → chunk-VPBAUQ2M.js} +7 -7
  46. package/dist/chunk-VQY5W4YW.cjs +311 -0
  47. package/dist/chunk-WLYIIEAF.js +50 -0
  48. package/dist/chunk-WNY4WMRF.js +32 -0
  49. package/dist/chunk-XEKD23J5.js +9 -0
  50. package/dist/chunk-XK5CIRMQ.js +112 -0
  51. package/dist/chunk-XSVNC2UD.cjs +18 -0
  52. package/dist/chunk-XTEI64OU.js +145 -0
  53. package/dist/chunk-XX6NQJMA.js +92 -0
  54. package/dist/{chunk-745DV5FL.js → chunk-Y7FO65VT.js} +3 -3
  55. package/dist/{chunk-PXUJF5HS.js → chunk-ZY6KU6P3.js} +4 -2
  56. package/dist/completion/CompletionService.cjs +30 -17
  57. package/dist/completion/CompletionService.js +29 -16
  58. package/dist/completion/NativeSearchInjector.cjs +3 -3
  59. package/dist/completion/NativeSearchInjector.js +2 -2
  60. package/dist/completion/openrouter-headers.cjs +3 -6
  61. package/dist/completion/openrouter-headers.d.cts +9 -12
  62. package/dist/completion/openrouter-headers.d.ts +9 -12
  63. package/dist/completion/openrouter-headers.js +2 -5
  64. package/dist/completion/openrouter-models.cjs +4 -3
  65. package/dist/completion/openrouter-models.js +2 -1
  66. package/dist/completion.cjs +30 -17
  67. package/dist/completion.js +29 -16
  68. package/dist/index.cjs +151 -20
  69. package/dist/index.d.cts +44 -10
  70. package/dist/index.d.ts +44 -10
  71. package/dist/index.js +160 -29
  72. package/dist/keyPolicy-Cp0FntZl.d.cts +90 -0
  73. package/dist/keyPolicy-Cp0FntZl.d.ts +90 -0
  74. package/dist/outbound-api/auditCapture.cjs +9 -0
  75. package/dist/outbound-api/auditCapture.d.cts +52 -0
  76. package/dist/outbound-api/auditCapture.d.ts +52 -0
  77. package/dist/outbound-api/auditCapture.js +9 -0
  78. package/dist/outbound-api/auditRedact.cjs +8 -0
  79. package/dist/outbound-api/auditRedact.d.cts +30 -0
  80. package/dist/outbound-api/auditRedact.d.ts +30 -0
  81. package/dist/outbound-api/auditRedact.js +8 -0
  82. package/dist/outbound-api/billingCapture.cjs +8 -0
  83. package/dist/outbound-api/billingCapture.d.cts +61 -0
  84. package/dist/outbound-api/billingCapture.d.ts +61 -0
  85. package/dist/outbound-api/billingCapture.js +8 -0
  86. package/dist/outbound-api/quotaWarn.cjs +12 -0
  87. package/dist/outbound-api/quotaWarn.d.cts +43 -0
  88. package/dist/outbound-api/quotaWarn.d.ts +43 -0
  89. package/dist/outbound-api/quotaWarn.js +12 -0
  90. package/dist/outbound-api/routeResolver.cjs +5 -2
  91. package/dist/outbound-api/routeResolver.d.cts +9 -2
  92. package/dist/outbound-api/routeResolver.d.ts +9 -2
  93. package/dist/outbound-api/routeResolver.js +4 -1
  94. package/dist/outbound-api/types.cjs +6 -1
  95. package/dist/outbound-api/types.d.cts +12 -144
  96. package/dist/outbound-api/types.d.ts +12 -144
  97. package/dist/outbound-api/types.js +6 -0
  98. package/dist/outbound-api.cjs +144 -17
  99. package/dist/outbound-api.d.cts +655 -25
  100. package/dist/outbound-api.d.ts +655 -25
  101. package/dist/outbound-api.js +148 -21
  102. package/dist/pipeline/AuthSource.d.cts +29 -1
  103. package/dist/pipeline/AuthSource.d.ts +29 -1
  104. package/dist/pipeline/LlmConfigProviderAuth.cjs +3 -3
  105. package/dist/pipeline/LlmConfigProviderAuth.js +2 -2
  106. package/dist/pipeline/SubscriptionAccountHealth.cjs +22 -0
  107. package/dist/pipeline/SubscriptionAccountHealth.d.cts +235 -0
  108. package/dist/pipeline/SubscriptionAccountHealth.d.ts +235 -0
  109. package/dist/pipeline/SubscriptionAccountHealth.js +22 -0
  110. package/dist/pipeline/SubscriptionAuthSource.cjs +2 -2
  111. package/dist/pipeline/SubscriptionAuthSource.d.cts +3 -2
  112. package/dist/pipeline/SubscriptionAuthSource.d.ts +3 -2
  113. package/dist/pipeline/SubscriptionAuthSource.js +1 -1
  114. package/dist/pipeline/SubscriptionAuthStrategy.d.cts +30 -1
  115. package/dist/pipeline/SubscriptionAuthStrategy.d.ts +30 -1
  116. package/dist/pipeline/auditSink.cjs +14 -0
  117. package/dist/pipeline/auditSink.d.cts +48 -0
  118. package/dist/pipeline/auditSink.d.ts +48 -0
  119. package/dist/pipeline/auditSink.js +14 -0
  120. package/dist/pipeline/auditUsageStash.cjs +10 -0
  121. package/dist/pipeline/auditUsageStash.d.cts +37 -0
  122. package/dist/pipeline/auditUsageStash.d.ts +37 -0
  123. package/dist/pipeline/auditUsageStash.js +10 -0
  124. package/dist/pipeline/billingEmit.cjs +14 -0
  125. package/dist/pipeline/billingEmit.d.cts +49 -0
  126. package/dist/pipeline/billingEmit.d.ts +49 -0
  127. package/dist/pipeline/billingEmit.js +14 -0
  128. package/dist/pipeline/executeProviderCall.cjs +2 -2
  129. package/dist/pipeline/executeProviderCall.js +1 -1
  130. package/dist/pipeline/upstreamFetch.cjs +14 -0
  131. package/dist/pipeline/upstreamFetch.d.cts +83 -0
  132. package/dist/pipeline/upstreamFetch.d.ts +83 -0
  133. package/dist/pipeline/upstreamFetch.js +14 -0
  134. package/dist/pipeline/webhookEmit.cjs +10 -0
  135. package/dist/pipeline/webhookEmit.d.cts +36 -0
  136. package/dist/pipeline/webhookEmit.d.ts +36 -0
  137. package/dist/pipeline/webhookEmit.js +10 -0
  138. package/dist/ports/usage-event-store.d.cts +26 -1
  139. package/dist/ports/usage-event-store.d.ts +26 -1
  140. package/dist/ports.d.cts +8 -1
  141. package/dist/ports.d.ts +8 -1
  142. package/dist/provider-proxy/ProviderProxy.cjs +30 -17
  143. package/dist/provider-proxy/ProviderProxy.js +29 -16
  144. package/dist/provider-proxy/identity/SubscriptionIdentityStore.cjs +15 -0
  145. package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.cts +121 -0
  146. package/dist/provider-proxy/identity/SubscriptionIdentityStore.d.ts +121 -0
  147. package/dist/provider-proxy/identity/SubscriptionIdentityStore.js +15 -0
  148. package/dist/provider-proxy/identity/fingerprintHeaders.cjs +20 -0
  149. package/dist/provider-proxy/identity/fingerprintHeaders.d.cts +89 -0
  150. package/dist/provider-proxy/identity/fingerprintHeaders.d.ts +89 -0
  151. package/dist/provider-proxy/identity/fingerprintHeaders.js +20 -0
  152. package/dist/provider-proxy/ingress/providerProxyShared.cjs +30 -17
  153. package/dist/provider-proxy/ingress/providerProxyShared.d.cts +11 -2
  154. package/dist/provider-proxy/ingress/providerProxyShared.d.ts +11 -2
  155. package/dist/provider-proxy/ingress/providerProxyShared.js +29 -16
  156. package/dist/provider-proxy/matchText.cjs +4 -2
  157. package/dist/provider-proxy/matchText.d.cts +14 -1
  158. package/dist/provider-proxy/matchText.d.ts +14 -1
  159. package/dist/provider-proxy/matchText.js +3 -1
  160. package/dist/provider-proxy/types.d.cts +30 -0
  161. package/dist/provider-proxy/types.d.ts +30 -0
  162. package/dist/provider-proxy.cjs +30 -17
  163. package/dist/provider-proxy.js +29 -16
  164. package/dist/{routeResolver-HE-ZO0fO.d.ts → routeResolver-C4T7yClx.d.ts} +36 -10
  165. package/dist/{routeResolver-BrbK6ja9.d.cts → routeResolver-CB3tvJKy.d.cts} +36 -10
  166. package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +2 -2
  167. package/dist/transformer/transformers/OpenAIResponseTransformer.js +1 -1
  168. package/dist/transformer/transformers.cjs +7 -7
  169. package/dist/transformer/transformers.js +8 -8
  170. package/dist/transformer.cjs +9 -9
  171. package/dist/transformer.js +8 -8
  172. package/dist/types-B8Arpxn0.d.cts +754 -0
  173. package/dist/types-lgPYQuZS.d.ts +754 -0
  174. package/dist/usage/usage-recorder.cjs +3 -2
  175. package/dist/usage/usage-recorder.d.cts +19 -1
  176. package/dist/usage/usage-recorder.d.ts +19 -1
  177. package/dist/usage/usage-recorder.js +2 -1
  178. package/dist/usage.cjs +3 -2
  179. package/dist/usage.js +2 -1
  180. package/package.json +64 -62
  181. package/dist/chunk-3MEACFK3.js +0 -193
  182. package/dist/chunk-6VIXXLMX.cjs +0 -14
  183. package/dist/chunk-E3WHL7CO.js +0 -14
  184. package/dist/chunk-G2FUJNA2.cjs +0 -193
@@ -1,7 +1,9 @@
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/completion/openrouter-headers.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; }
2
+
3
+ var _chunkUNEFIWXIcjs = require('./chunk-UNEFIWXI.cjs');
4
+
5
+ // src/completion/openrouter-headers.ts
2
6
  var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
3
- var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
4
- var OPENROUTER_X_TITLE = "Omnicross";
5
7
  function buildOpenRouterHeaders(credentials, options = {}) {
6
8
  const apiKey = _optionalChain([credentials, 'access', _ => _.apiKey, 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]);
7
9
  if (!apiKey) {
@@ -9,8 +11,7 @@ function buildOpenRouterHeaders(credentials, options = {}) {
9
11
  }
10
12
  const headers = {
11
13
  Authorization: `Bearer ${apiKey}`,
12
- "HTTP-Referer": OPENROUTER_HTTP_REFERER,
13
- "X-Title": OPENROUTER_X_TITLE
14
+ ..._chunkUNEFIWXIcjs.OPENROUTER_APP_HEADERS
14
15
  };
15
16
  if (options.contentType !== false) {
16
17
  headers["Content-Type"] = _nullishCoalesce(options.contentType, () => ( "application/json"));
@@ -38,6 +39,4 @@ function buildOpenRouterUrl(endpoint, path) {
38
39
 
39
40
 
40
41
 
41
-
42
-
43
- exports.OPENROUTER_DEFAULT_BASE_URL = OPENROUTER_DEFAULT_BASE_URL; exports.OPENROUTER_HTTP_REFERER = OPENROUTER_HTTP_REFERER; exports.OPENROUTER_X_TITLE = OPENROUTER_X_TITLE; exports.buildOpenRouterHeaders = buildOpenRouterHeaders; exports.resolveOpenRouterBaseUrl = resolveOpenRouterBaseUrl; exports.buildOpenRouterUrl = buildOpenRouterUrl;
42
+ exports.OPENROUTER_DEFAULT_BASE_URL = OPENROUTER_DEFAULT_BASE_URL; exports.buildOpenRouterHeaders = buildOpenRouterHeaders; exports.resolveOpenRouterBaseUrl = resolveOpenRouterBaseUrl; exports.buildOpenRouterUrl = buildOpenRouterUrl;
@@ -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;
@@ -31,15 +31,19 @@ var SubscriptionAuthSource = class {
31
31
  try {
32
32
  await this.profile.authStrategy.applyHeaders(headers, {
33
33
  upstreamUrl: hints.upstreamUrl,
34
- resolvedModel: hints.model
34
+ resolvedModel: hints.model,
35
+ sessionKey: hints.sessionKey,
36
+ reportSelection: hints.reportSelection,
37
+ preferredAccountId: hints.preferredAccountId
35
38
  });
36
39
  } catch (err) {
37
40
  console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", serializeError(err));
38
41
  }
39
42
  }
40
- /** Delegate the 401-refresh decision to the bound strategy. */
41
- async onUnauthorized() {
42
- return this.profile.authStrategy.onUnauthorized();
43
+ /** Delegate the 401-refresh decision to the bound strategy, threading the
44
+ * session key so the account actually served is the one refreshed (D7). */
45
+ async onUnauthorized(sessionKey) {
46
+ return this.profile.authStrategy.onUnauthorized(sessionKey);
43
47
  }
44
48
  /** Resolve the upstream URL from the profile, when it provides one. */
45
49
  resolveUpstreamUrl(model) {
@@ -0,0 +1,32 @@
1
+ // src/openrouter.ts
2
+ function isOpenRouterProvider(provider) {
3
+ const baseUrl = (provider.api_base_url || "").toLowerCase();
4
+ return baseUrl.includes("openrouter.ai");
5
+ }
6
+ var DEFAULT_APP_IDENTITY = {
7
+ referer: "https://github.com/Dumoedss/omnicross",
8
+ title: "Omnicross"
9
+ };
10
+ var OPENROUTER_APP_HEADERS = {
11
+ "HTTP-Referer": DEFAULT_APP_IDENTITY.referer,
12
+ "X-Title": DEFAULT_APP_IDENTITY.title
13
+ };
14
+ function setOpenRouterAppIdentity(identity) {
15
+ const referer = identity.referer?.trim();
16
+ const title = identity.title?.trim();
17
+ if (referer) OPENROUTER_APP_HEADERS["HTTP-Referer"] = referer;
18
+ if (title) OPENROUTER_APP_HEADERS["X-Title"] = title;
19
+ }
20
+ function getOpenRouterAppIdentity() {
21
+ return {
22
+ referer: OPENROUTER_APP_HEADERS["HTTP-Referer"],
23
+ title: OPENROUTER_APP_HEADERS["X-Title"]
24
+ };
25
+ }
26
+
27
+ export {
28
+ isOpenRouterProvider,
29
+ OPENROUTER_APP_HEADERS,
30
+ setOpenRouterAppIdentity,
31
+ getOpenRouterAppIdentity
32
+ };
@@ -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) {
@@ -37,10 +37,33 @@ function collectMatchText(anthropicBody) {
37
37
  for (let i = recent.length - 1; i >= 0; i--) slices.push(recent[i]);
38
38
  return slices;
39
39
  }
40
+ function deriveSubscriptionSessionKey(anthropicBody) {
41
+ const system = flattenMatchText(anthropicBody.system).trim().slice(0, MATCH_TEXT_PER_MESSAGE_CAP);
42
+ const messages = Array.isArray(anthropicBody.messages) ? anthropicBody.messages : [];
43
+ let firstUser = "";
44
+ for (const message of messages) {
45
+ if (message && typeof message === "object" && message.role === "user") {
46
+ firstUser = flattenMatchText(message.content).trim().slice(0, MATCH_TEXT_PER_MESSAGE_CAP);
47
+ break;
48
+ }
49
+ }
50
+ const anchor = `${system}\0${firstUser}`;
51
+ if (!system && !firstUser) return void 0;
52
+ return fnv1a(anchor);
53
+ }
54
+ function fnv1a(str) {
55
+ let h = 2166136261;
56
+ for (let i = 0; i < str.length; i++) {
57
+ h ^= str.charCodeAt(i);
58
+ h = Math.imul(h, 16777619);
59
+ }
60
+ return (h >>> 0).toString(16).padStart(8, "0");
61
+ }
40
62
 
41
63
  export {
42
64
  MATCH_TEXT_PER_MESSAGE_CAP,
43
65
  MATCH_TEXT_RECENT_MESSAGES,
44
66
  flattenMatchText,
45
- collectMatchText
67
+ collectMatchText,
68
+ deriveSubscriptionSessionKey
46
69
  };
@@ -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) {
@@ -1,16 +1,16 @@
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 _chunk6VIXXLMXcjs = require('./chunk-6VIXXLMX.cjs');
4
3
 
5
4
 
6
5
 
6
+ var _chunkGMMT7RVNcjs = require('./chunk-GMMT7RVN.cjs');
7
7
 
8
8
 
9
- var _chunkGMMT7RVNcjs = require('./chunk-GMMT7RVN.cjs');
9
+ var _chunkUNEFIWXIcjs = require('./chunk-UNEFIWXI.cjs');
10
10
 
11
11
  // src/completion/NativeSearchInjector.ts
12
12
  function detectNativeSearch(modelId, apiFormat, provider, userExplicit) {
13
- if (_chunk6VIXXLMXcjs.isOpenRouterProvider.call(void 0, provider)) {
13
+ if (_chunkUNEFIWXIcjs.isOpenRouterProvider.call(void 0, provider)) {
14
14
  return { supported: true, nativeProvider: "openrouter" };
15
15
  }
16
16
  if (isXaiProvider(provider)) {
@@ -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
+ };
@@ -31,15 +31,19 @@ var SubscriptionAuthSource = class {
31
31
  try {
32
32
  await this.profile.authStrategy.applyHeaders(headers, {
33
33
  upstreamUrl: hints.upstreamUrl,
34
- resolvedModel: hints.model
34
+ resolvedModel: hints.model,
35
+ sessionKey: hints.sessionKey,
36
+ reportSelection: hints.reportSelection,
37
+ preferredAccountId: hints.preferredAccountId
35
38
  });
36
39
  } catch (err) {
37
40
  console.warn("[SubscriptionAuthSource] authStrategy.applyHeaders threw:", _chunkSVNDB62Dcjs.serializeError.call(void 0, err));
38
41
  }
39
42
  }
40
- /** Delegate the 401-refresh decision to the bound strategy. */
41
- async onUnauthorized() {
42
- return this.profile.authStrategy.onUnauthorized();
43
+ /** Delegate the 401-refresh decision to the bound strategy, threading the
44
+ * session key so the account actually served is the one refreshed (D7). */
45
+ async onUnauthorized(sessionKey) {
46
+ return this.profile.authStrategy.onUnauthorized(sessionKey);
43
47
  }
44
48
  /** Resolve the upstream URL from the profile, when it provides one. */
45
49
  resolveUpstreamUrl(model) {
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/pipeline/billingEmit.ts
2
+ var sink = null;
3
+ var captureConfig = null;
4
+ function setBillingSink(fn) {
5
+ sink = fn;
6
+ }
7
+ function setBillingCaptureConfig(config) {
8
+ captureConfig = config && config.enabled ? config : null;
9
+ }
10
+ function getBillingCaptureConfig() {
11
+ return captureConfig;
12
+ }
13
+ function publishBillingEvent(event) {
14
+ const active = sink;
15
+ if (!active) return;
16
+ try {
17
+ active(event);
18
+ } catch (e) {
19
+ }
20
+ }
21
+ function __resetBillingSinkForTests() {
22
+ sink = null;
23
+ captureConfig = null;
24
+ }
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+ exports.setBillingSink = setBillingSink; exports.setBillingCaptureConfig = setBillingCaptureConfig; exports.getBillingCaptureConfig = getBillingCaptureConfig; exports.publishBillingEvent = publishBillingEvent; exports.__resetBillingSinkForTests = __resetBillingSinkForTests;
@@ -0,0 +1,112 @@
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
+ var _undici = require('undici');
3
+ var _socks = require('socks');
4
+ var resolver = null;
5
+ var generation = 0;
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
+ }
22
+ function normalizeProxy(cfg) {
23
+ if ("url" in cfg) {
24
+ let u;
25
+ try {
26
+ u = new URL(cfg.url);
27
+ } catch (e2) {
28
+ return void 0;
29
+ }
30
+ const proto = u.protocol.replace(/:$/, "").toLowerCase();
31
+ const kind2 = proto === "socks5" || proto === "socks" ? "socks5" : proto === "https" ? "https" : "http";
32
+ const port = u.port ? Number(u.port) : kind2 === "https" ? 443 : kind2 === "socks5" ? 1080 : 80;
33
+ if (!u.hostname || !Number.isFinite(port)) return void 0;
34
+ return {
35
+ kind: kind2,
36
+ host: u.hostname,
37
+ port,
38
+ username: u.username ? decodeURIComponent(u.username) : void 0,
39
+ password: u.password ? decodeURIComponent(u.password) : void 0
40
+ };
41
+ }
42
+ const kind = cfg.type === "socks5" ? "socks5" : cfg.type === "https" ? "https" : "http";
43
+ if (!cfg.host || !Number.isFinite(cfg.port)) return void 0;
44
+ return {
45
+ kind,
46
+ host: cfg.host,
47
+ port: cfg.port,
48
+ username: cfg.username || void 0,
49
+ password: cfg.password || void 0
50
+ };
51
+ }
52
+ function proxyKey(p) {
53
+ return `${p.kind}://${_nullishCoalesce(p.username, () => ( ""))}:${_nullishCoalesce(p.password, () => ( ""))}@${p.host}:${p.port}`;
54
+ }
55
+ function socksConnector(p) {
56
+ const base = _undici.buildConnector.call(void 0, {});
57
+ return ((options, callback) => {
58
+ const destPort = Number(options.port) || (options.protocol === "https:" ? 443 : 80);
59
+ _socks.SocksClient.createConnection({
60
+ proxy: { host: p.host, port: p.port, type: 5, userId: p.username, password: p.password },
61
+ command: "connect",
62
+ destination: { host: options.hostname, port: destPort }
63
+ }).then(({ socket }) => {
64
+ base({ ...options, httpSocket: socket }, callback);
65
+ }).catch((err) => callback(err, null));
66
+ });
67
+ }
68
+ function buildDispatcher(p) {
69
+ if (p.kind === "socks5") {
70
+ return new (0, _undici.Agent)({ connect: socksConnector(p) });
71
+ }
72
+ const auth = p.username != null ? `${encodeURIComponent(p.username)}:${encodeURIComponent(_nullishCoalesce(p.password, () => ( "")))}@` : "";
73
+ const uri = `${p.kind}://${auth}${p.host}:${p.port}`;
74
+ return new (0, _undici.ProxyAgent)({ uri });
75
+ }
76
+ function resolveUpstreamDispatcher(ctx) {
77
+ const active = resolver;
78
+ if (!active) return void 0;
79
+ let cfg;
80
+ try {
81
+ cfg = active(ctx);
82
+ } catch (e3) {
83
+ return void 0;
84
+ }
85
+ if (!cfg) return void 0;
86
+ const norm = normalizeProxy(cfg);
87
+ if (!norm) return void 0;
88
+ const key = `${generation}\0${proxyKey(norm)}`;
89
+ let dispatcher = cache.get(key);
90
+ if (!dispatcher) {
91
+ dispatcher = buildDispatcher(norm);
92
+ cache.set(key, dispatcher);
93
+ }
94
+ return dispatcher;
95
+ }
96
+ function fetchUpstream(url, init, ctx) {
97
+ const dispatcher = resolveUpstreamDispatcher({ ..._nullishCoalesce(ctx, () => ( {})), url });
98
+ if (!dispatcher) return fetch(url, init);
99
+ return fetch(url, { ...init, dispatcher });
100
+ }
101
+ function __resetUpstreamProxyForTests() {
102
+ resolver = null;
103
+ bumpUpstreamProxyGeneration();
104
+ }
105
+
106
+
107
+
108
+
109
+
110
+
111
+
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
+ };
@@ -4,7 +4,7 @@ var _chunkA2YMUCBTcjs = require('./chunk-A2YMUCBT.cjs');
4
4
 
5
5
 
6
6
 
7
- var _chunk6VIXXLMXcjs = require('./chunk-6VIXXLMX.cjs');
7
+ var _chunkUNEFIWXIcjs = require('./chunk-UNEFIWXI.cjs');
8
8
 
9
9
  // src/completion/header-builder.ts
10
10
  function getProviderHeaders(provider, apiKey) {
@@ -14,7 +14,9 @@ function getProviderHeaders(provider, apiKey) {
14
14
  case "anthropic":
15
15
  headers = {
16
16
  "Content-Type": "application/json",
17
- "x-api-key": apiKey,
17
+ // Third-party Anthropic-Messages relays often gate on a Bearer token
18
+ // rather than x-api-key; `provider.useBearer` opts into that.
19
+ ...provider.useBearer ? { Authorization: `Bearer ${apiKey}` } : { "x-api-key": apiKey },
18
20
  "anthropic-version": "2025-01-10"
19
21
  // Required for extended thinking feature
20
22
  };
@@ -40,8 +42,8 @@ function getProviderHeaders(provider, apiKey) {
40
42
  };
41
43
  break;
42
44
  }
43
- if (_chunk6VIXXLMXcjs.isOpenRouterProvider.call(void 0, provider)) {
44
- return { ...headers, ..._chunk6VIXXLMXcjs.OPENROUTER_APP_HEADERS };
45
+ if (_chunkUNEFIWXIcjs.isOpenRouterProvider.call(void 0, provider)) {
46
+ return { ...headers, ..._chunkUNEFIWXIcjs.OPENROUTER_APP_HEADERS };
45
47
  }
46
48
  return headers;
47
49
  }
@@ -37,10 +37,33 @@ function collectMatchText(anthropicBody) {
37
37
  for (let i = recent.length - 1; i >= 0; i--) slices.push(recent[i]);
38
38
  return slices;
39
39
  }
40
+ function deriveSubscriptionSessionKey(anthropicBody) {
41
+ const system = flattenMatchText(anthropicBody.system).trim().slice(0, MATCH_TEXT_PER_MESSAGE_CAP);
42
+ const messages = Array.isArray(anthropicBody.messages) ? anthropicBody.messages : [];
43
+ let firstUser = "";
44
+ for (const message of messages) {
45
+ if (message && typeof message === "object" && message.role === "user") {
46
+ firstUser = flattenMatchText(message.content).trim().slice(0, MATCH_TEXT_PER_MESSAGE_CAP);
47
+ break;
48
+ }
49
+ }
50
+ const anchor = `${system}\0${firstUser}`;
51
+ if (!system && !firstUser) return void 0;
52
+ return fnv1a(anchor);
53
+ }
54
+ function fnv1a(str) {
55
+ let h = 2166136261;
56
+ for (let i = 0; i < str.length; i++) {
57
+ h ^= str.charCodeAt(i);
58
+ h = Math.imul(h, 16777619);
59
+ }
60
+ return (h >>> 0).toString(16).padStart(8, "0");
61
+ }
62
+
40
63
 
41
64
 
42
65
 
43
66
 
44
67
 
45
68
 
46
- exports.MATCH_TEXT_PER_MESSAGE_CAP = MATCH_TEXT_PER_MESSAGE_CAP; exports.MATCH_TEXT_RECENT_MESSAGES = MATCH_TEXT_RECENT_MESSAGES; exports.flattenMatchText = flattenMatchText; exports.collectMatchText = collectMatchText;
69
+ exports.MATCH_TEXT_PER_MESSAGE_CAP = MATCH_TEXT_PER_MESSAGE_CAP; exports.MATCH_TEXT_RECENT_MESSAGES = MATCH_TEXT_RECENT_MESSAGES; exports.flattenMatchText = flattenMatchText; exports.collectMatchText = collectMatchText; exports.deriveSubscriptionSessionKey = deriveSubscriptionSessionKey;