@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,193 +0,0 @@
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 _chunkQBZJ7P2Tcjs = require('./chunk-QBZJ7P2T.cjs');
4
-
5
- // src/outbound-api/subscriptionSupport.ts
6
- var SUBSCRIPTION_PROVIDER_IDS = [
7
- "claude",
8
- "codex",
9
- "gemini",
10
- "opencodego"
11
- ];
12
- var SUBSCRIPTION_ID_SET = new Set(SUBSCRIPTION_PROVIDER_IDS);
13
- function isSubscriptionProviderId(providerId) {
14
- if (SUBSCRIPTION_ID_SET.has(providerId)) return true;
15
- const registry = _chunkQBZJ7P2Tcjs.getSubscriptionRegistryForOutbound.call(void 0, );
16
- return _optionalChain([registry, 'optionalAccess', _ => _.getProfile, 'call', _2 => _2(providerId)]) != null;
17
- }
18
- var SUBSCRIPTION_SUPPORTED_ENDPOINTS = /* @__PURE__ */ new Set([
19
- "messages",
20
- "responses"
21
- ]);
22
- function endpointSupportsSubscription(endpoint) {
23
- return SUBSCRIPTION_SUPPORTED_ENDPOINTS.has(endpoint);
24
- }
25
-
26
- // src/outbound-api/routeResolver.ts
27
- function parseModelRef(ref) {
28
- if (!ref) return null;
29
- const idx = ref.indexOf(",");
30
- if (idx <= 0) return null;
31
- const providerId = ref.slice(0, idx).trim();
32
- const modelId = ref.slice(idx + 1).trim();
33
- if (!providerId || !modelId) return null;
34
- return { providerId, modelId };
35
- }
36
- function pickModelRefForRole(config, role) {
37
- if (role === "vision") {
38
- if (config.visionModel && config.visionModel.trim()) {
39
- return { ref: config.visionModel, effectiveRole: "vision" };
40
- }
41
- return { ref: config.defaultModel, effectiveRole: "default" };
42
- }
43
- if (role === "background") {
44
- return { ref: config.backgroundModel, effectiveRole: "background" };
45
- }
46
- return { ref: config.defaultModel, effectiveRole: "default" };
47
- }
48
- async function resolveRoute(args) {
49
- const { config, role, ingressFormat, llmConfig } = args;
50
- const sessionId = _nullishCoalesce(args.sessionId, () => ( null));
51
- const { ref, effectiveRole } = pickModelRefForRole(config, role);
52
- if (!ref || !ref.trim()) {
53
- return {
54
- ok: false,
55
- error: {
56
- status: 503,
57
- message: `endpoint '${config.endpoint}' has no ${effectiveRole} model configured`
58
- }
59
- };
60
- }
61
- const parsed = parseModelRef(ref);
62
- if (!parsed) {
63
- return {
64
- ok: false,
65
- error: {
66
- status: 503,
67
- message: `endpoint '${config.endpoint}' ${effectiveRole} model ref is malformed: '${ref}'`
68
- }
69
- };
70
- }
71
- const { providerId, modelId } = parsed;
72
- const provider = await llmConfig.getProvider(providerId);
73
- if (!provider) {
74
- if (isSubscriptionProviderId(providerId)) {
75
- return await resolveSubscriptionRoute({
76
- config,
77
- providerId,
78
- modelId,
79
- ingressFormat,
80
- sessionId,
81
- effectiveRole
82
- });
83
- }
84
- return {
85
- ok: false,
86
- error: {
87
- status: 503,
88
- message: `provider '${providerId}' not found for endpoint '${config.endpoint}'`
89
- }
90
- };
91
- }
92
- const isOfficialProvider = provider.isOfficial === true || provider.id === "anthropic";
93
- const targetProviderFormat = isOfficialProvider ? "anthropic" : "transform";
94
- let anthropicSdkHints = null;
95
- if (ingressFormat === "anthropic-messages") {
96
- anthropicSdkHints = {
97
- apiKey: resolveApiKey(provider.api_key),
98
- isOfficialProvider,
99
- passThrough: false,
100
- attribution: { sessionId, apiKeyId: null }
101
- };
102
- }
103
- const route = {
104
- sessionId,
105
- targetProviderFormat,
106
- model: modelId,
107
- ingressFormat,
108
- authMode: "byo",
109
- providerId,
110
- anthropicSdkHints
111
- };
112
- return { ok: true, route, usedRole: effectiveRole };
113
- }
114
- async function resolveSubscriptionRoute(args) {
115
- const { config, providerId, modelId, ingressFormat, sessionId, effectiveRole } = args;
116
- if (!config.useSubscription) {
117
- return {
118
- ok: false,
119
- error: {
120
- status: 503,
121
- message: `subscription routing disabled for endpoint '${config.endpoint}'`
122
- }
123
- };
124
- }
125
- if (!endpointSupportsSubscription(config.endpoint)) {
126
- return {
127
- ok: false,
128
- error: {
129
- status: 503,
130
- message: `subscription routing is not supported on the '${config.endpoint}' endpoint; use a BYO API-key provider, or the /v1/messages or /v1/responses endpoint`
131
- }
132
- };
133
- }
134
- const registry = _chunkQBZJ7P2Tcjs.getSubscriptionRegistryForOutbound.call(void 0, );
135
- const profile = _nullishCoalesce(_optionalChain([registry, 'optionalAccess', _3 => _3.getProfile, 'call', _4 => _4(providerId)]), () => ( null));
136
- if (!profile) {
137
- return {
138
- ok: false,
139
- error: {
140
- status: 503,
141
- message: `subscription provider '${providerId}' is not available`
142
- }
143
- };
144
- }
145
- const hints = {
146
- apiKey: "",
147
- isOfficialProvider: false,
148
- passThrough: false,
149
- subscriptionProfile: profile,
150
- attribution: { sessionId, apiKeyId: null }
151
- };
152
- const subscriptionConfig = providerId === "opencodego" ? await _optionalChain([registry, 'optionalAccess', _5 => _5.getOpenCodeGoConfig, 'optionalCall', _6 => _6()]) : void 0;
153
- const route = {
154
- sessionId,
155
- targetProviderFormat: "transform",
156
- model: modelId,
157
- ingressFormat,
158
- authMode: "subscription",
159
- providerId,
160
- // Anthropic delegation carries the dispatch profile inside
161
- // `anthropicSdkHints.subscriptionProfile`. The Responses ingress reads the
162
- // TOP-LEVEL `route.subscriptionProfile`, and so does the built-in
163
- // (factory-absent) `/v1/messages` subscription path (RT2.1) — the registry's
164
- // `SubscriptionDispatchProfile` structurally satisfies `SubscriptionAuthProfile`
165
- // ({ authStrategy, resolveUpstreamUrl, providerTransformerNames }), so set it
166
- // for BOTH. This is INERT when an Anthropic ingress factory is present: that
167
- // delegation reads the hint-bundle field above (and uses a different
168
- // route-minting path), never the top-level field. (chat/gemini never reach
169
- // here — Gate 2 rejected them.)
170
- subscriptionProfile: ingressFormat === "openai-responses" || ingressFormat === "anthropic-messages" ? profile : void 0,
171
- // Opaque per-account config (opencodego-only; `undefined` otherwise). Read by
172
- // the built-in `/v1/messages` plan builder; INERT for the factory-present
173
- // delegation path + non-opencodego.
174
- subscriptionConfig,
175
- anthropicSdkHints: hints
176
- };
177
- return { ok: true, route, usedRole: effectiveRole };
178
- }
179
- function resolveApiKey(apiKey) {
180
- if (!apiKey) return "";
181
- if (apiKey.startsWith("$")) {
182
- return process.env[apiKey.slice(1)] || "";
183
- }
184
- return apiKey;
185
- }
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
- exports.SUBSCRIPTION_PROVIDER_IDS = SUBSCRIPTION_PROVIDER_IDS; exports.isSubscriptionProviderId = isSubscriptionProviderId; exports.endpointSupportsSubscription = endpointSupportsSubscription; exports.parseModelRef = parseModelRef; exports.resolveRoute = resolveRoute;