@omnicross/core 0.1.1 → 0.1.2
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.
- package/dist/ApiConverter.cjs +3 -778
- package/dist/ApiConverter.js +12 -751
- package/dist/{CompletionService-DtOF_War.d.cts → CompletionService-D3a47vdU.d.cts} +2 -1
- package/dist/{CompletionService-7fCmKAP3.d.ts → CompletionService-DdWaAxq0.d.ts} +2 -1
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +27 -60
- package/dist/auth/GeminiCodeAssistProjectResolver.js +5 -9
- package/dist/builtin-web-fetch-77JZUZGM.cjs +100 -0
- package/dist/builtin-web-fetch-IGLBX2XY.js +100 -0
- package/dist/chunk-2DCNB7DF.cjs +514 -0
- package/dist/chunk-2FEVTJWG.js +4400 -0
- package/dist/chunk-3MEACFK3.js +193 -0
- package/dist/chunk-3OPYJG76.cjs +266 -0
- package/dist/chunk-46RLHI7D.js +0 -0
- package/dist/chunk-46ZIFWYG.cjs +277 -0
- package/dist/chunk-4NBS6KPV.cjs +43 -0
- package/dist/chunk-4VAVYUZS.cjs +991 -0
- package/dist/chunk-5ERIZW3D.js +44 -0
- package/dist/chunk-5HTVET6E.js +514 -0
- package/dist/chunk-5ZQBEOMD.js +764 -0
- package/dist/chunk-6VIXXLMX.cjs +14 -0
- package/dist/chunk-745DV5FL.js +147 -0
- package/dist/chunk-74TMJA7Z.js +53 -0
- package/dist/chunk-7VU7V2E4.js +0 -0
- package/dist/chunk-7YN22L2H.cjs +87 -0
- package/dist/chunk-A2YMUCBT.cjs +105 -0
- package/dist/chunk-AQ5TNQB7.js +13 -0
- package/dist/chunk-AVYJ4YBN.js +58 -0
- package/dist/chunk-C72S6TTV.cjs +49 -0
- package/dist/chunk-C7PSERMH.js +87 -0
- package/dist/chunk-CDHS2QDC.js +179 -0
- package/dist/chunk-DK4A7DLE.js +266 -0
- package/dist/chunk-DRWHTIIZ.js +13 -0
- package/dist/chunk-DWKQZ2SK.cjs +254 -0
- package/dist/chunk-E3WHL7CO.js +14 -0
- package/dist/chunk-EYZYXJTJ.cjs +1 -0
- package/dist/chunk-FMOBD2OQ.js +39 -0
- package/dist/chunk-FTQ7IQUC.js +991 -0
- package/dist/chunk-FZ46M34D.cjs +1 -0
- package/dist/chunk-G2FUJNA2.cjs +193 -0
- package/dist/chunk-G2UTNSGU.js +277 -0
- package/dist/chunk-GBHYAGX3.cjs +26 -0
- package/dist/chunk-GMMT7RVN.cjs +39 -0
- package/dist/chunk-H5JUT3KV.js +105 -0
- package/dist/chunk-HQP3K7PU.cjs +431 -0
- package/dist/chunk-JO5NLTLY.js +46 -0
- package/dist/chunk-JWC6APFQ.js +23 -0
- package/dist/chunk-KUU2RNG6.cjs +46 -0
- package/dist/chunk-LKZJEL6E.cjs +124 -0
- package/dist/chunk-MNYKI4CI.js +94 -0
- package/dist/chunk-MZNPGW5Q.js +26 -0
- package/dist/chunk-N3V2J5ZO.cjs +53 -0
- package/dist/chunk-NYUNU75A.cjs +44 -0
- package/dist/chunk-NZYN7C3P.cjs +179 -0
- package/dist/chunk-O466Y272.js +235 -0
- package/dist/chunk-PXUJF5HS.js +124 -0
- package/dist/chunk-QBZJ7P2T.cjs +13 -0
- package/dist/chunk-QOCNX236.js +46 -0
- package/dist/chunk-QXD4MV2X.cjs +23 -0
- package/dist/chunk-R3HK6R4B.cjs +13 -0
- package/dist/chunk-RSJ3TWJQ.cjs +186 -0
- package/dist/chunk-S4WBV25P.js +913 -0
- package/dist/chunk-SN3YWBX7.cjs +4400 -0
- package/dist/chunk-SPVWWUHX.cjs +46 -0
- package/dist/chunk-SUEGJ75D.cjs +764 -0
- package/dist/chunk-SVNDB62D.cjs +58 -0
- package/dist/chunk-UYPEN5XE.cjs +235 -0
- package/dist/chunk-V5KPWNYX.cjs +147 -0
- package/dist/chunk-VVEHS2LI.js +431 -0
- package/dist/chunk-XBSYYZIY.cjs +94 -0
- package/dist/chunk-YGXJGRFI.cjs +913 -0
- package/dist/chunk-YMFAJFQT.cjs +173 -0
- package/dist/chunk-Z7LUNECE.js +49 -0
- package/dist/chunk-Z7Y2NPHY.js +186 -0
- package/dist/chunk-ZJZAOKI7.js +254 -0
- package/dist/chunk-ZLX3KGXX.js +173 -0
- package/dist/chunk-ZSVQT3PW.js +43 -0
- package/dist/completion/ApiKeyPoolService.cjs +23 -48
- package/dist/completion/ApiKeyPoolService.d.cts +150 -2
- package/dist/completion/ApiKeyPoolService.d.ts +150 -2
- package/dist/completion/BuiltinToolExecutor.cjs +9 -324
- package/dist/completion/BuiltinToolExecutor.js +6 -290
- package/dist/completion/CompletionService.cjs +38 -3487
- package/dist/completion/CompletionService.d.cts +3 -2
- package/dist/completion/CompletionService.d.ts +3 -2
- package/dist/completion/CompletionService.js +34 -3457
- package/dist/completion/NativeSearchInjector.cjs +8 -192
- package/dist/completion/NativeSearchInjector.js +7 -162
- package/dist/completion/ProviderSearchInjector.cjs +12 -39
- package/dist/completion/native-search-types.cjs +13 -66
- package/dist/completion/native-search-types.js +7 -31
- package/dist/completion/openrouter-headers.cjs +15 -71
- package/dist/completion/openrouter-headers.js +8 -34
- package/dist/completion/openrouter-models.cjs +10 -67
- package/dist/completion/openrouter-models.js +4 -34
- package/dist/completion/types.cjs +1 -18
- package/dist/completion/url-builder.cjs +24 -138
- package/dist/completion/url-builder.js +12 -92
- package/dist/completion.cjs +55 -3989
- package/dist/completion.d.cts +3 -2
- package/dist/completion.d.ts +3 -2
- package/dist/completion.js +63 -3953
- package/dist/index.cjs +197 -10429
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +125 -10268
- package/dist/logger-4GvQNzhE.d.cts +22 -0
- package/dist/logger-4GvQNzhE.d.ts +22 -0
- package/dist/outbound-api/routeResolver.cjs +7 -217
- package/dist/outbound-api/routeResolver.d.cts +2 -1
- package/dist/outbound-api/routeResolver.d.ts +2 -1
- package/dist/outbound-api/routeResolver.js +6 -187
- package/dist/outbound-api/subscriptionRegistryPort.cjs +7 -37
- package/dist/outbound-api/subscriptionRegistryPort.d.cts +2 -1
- package/dist/outbound-api/subscriptionRegistryPort.d.ts +2 -1
- package/dist/outbound-api/subscriptionRegistryPort.js +4 -8
- package/dist/outbound-api/types.cjs +1 -18
- package/dist/outbound-api/types.d.cts +2 -1
- package/dist/outbound-api/types.d.ts +2 -1
- package/dist/outbound-api.cjs +35 -5221
- package/dist/outbound-api.d.cts +2 -1
- package/dist/outbound-api.d.ts +2 -1
- package/dist/outbound-api.js +54 -5194
- package/dist/pipeline/AuthSource.cjs +1 -18
- package/dist/pipeline/LlmConfigProviderAuth.cjs +5 -166
- package/dist/pipeline/LlmConfigProviderAuth.d.cts +2 -1
- package/dist/pipeline/LlmConfigProviderAuth.d.ts +2 -1
- package/dist/pipeline/LlmConfigProviderAuth.js +5 -139
- package/dist/pipeline/SubscriptionAuthSource.cjs +6 -128
- package/dist/pipeline/SubscriptionAuthSource.js +5 -99
- package/dist/pipeline/SubscriptionAuthStrategy.cjs +1 -18
- package/dist/pipeline/executeProviderCall.cjs +5 -69
- package/dist/pipeline/executeProviderCall.js +3 -42
- package/dist/pipeline/resolveProviderChain.cjs +5 -46
- package/dist/pipeline/resolveProviderChain.js +3 -19
- package/dist/pipeline/resolveSubscriptionChain.cjs +5 -67
- package/dist/pipeline/resolveSubscriptionChain.js +3 -40
- package/dist/ports/gemini-code-assist-resolver.cjs +7 -37
- package/dist/ports/gemini-code-assist-resolver.js +4 -8
- package/dist/ports/pricing-store.cjs +1 -0
- package/dist/ports/pricing-store.d.cts +50 -0
- package/dist/ports/pricing-store.d.ts +50 -0
- package/dist/ports/pricing-store.js +0 -0
- package/dist/ports/provider-config-source.cjs +1 -18
- package/dist/ports/usage-event-store.cjs +1 -0
- package/dist/ports/usage-event-store.d.cts +29 -0
- package/dist/ports/usage-event-store.d.ts +29 -0
- package/dist/ports/usage-event-store.js +0 -0
- package/dist/ports/web-search-backend.cjs +1 -18
- package/dist/ports.cjs +1 -18
- package/dist/ports.d.cts +6 -1
- package/dist/ports.d.ts +6 -1
- package/dist/provider-proxy/ProviderProxy.cjs +40 -4643
- package/dist/provider-proxy/ProviderProxy.d.cts +2 -1
- package/dist/provider-proxy/ProviderProxy.d.ts +2 -1
- package/dist/provider-proxy/ProviderProxy.js +35 -4613
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +35 -2941
- package/dist/provider-proxy/ingress/providerProxyShared.d.cts +2 -1
- package/dist/provider-proxy/ingress/providerProxyShared.d.ts +2 -1
- package/dist/provider-proxy/ingress/providerProxyShared.js +41 -2914
- package/dist/provider-proxy/matchText.cjs +11 -72
- package/dist/provider-proxy/matchText.js +6 -39
- package/dist/provider-proxy/types.cjs +1 -18
- package/dist/provider-proxy/types.d.cts +2 -1
- package/dist/provider-proxy/types.d.ts +2 -1
- package/dist/provider-proxy.cjs +35 -4655
- package/dist/provider-proxy.d.cts +2 -1
- package/dist/provider-proxy.d.ts +2 -1
- package/dist/provider-proxy.js +39 -4628
- package/dist/serializeError.cjs +5 -81
- package/dist/serializeError.js +3 -54
- package/dist/sse-parser.cjs +7 -455
- package/dist/sse-parser.js +4 -426
- package/dist/transformer/TransformerChainExecutor.cjs +4 -318
- package/dist/transformer/TransformerChainExecutor.js +4 -291
- package/dist/transformer/TransformerService.cjs +5 -289
- package/dist/transformer/TransformerService.js +3 -262
- package/dist/transformer/anthropicBetaInject.cjs +7 -50
- package/dist/transformer/anthropicBetaInject.js +4 -21
- package/dist/transformer/transformers/AnthropicTransformer.cjs +3 -1014
- package/dist/transformer/transformers/AnthropicTransformer.js +3 -987
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.cjs +4 -1106
- package/dist/transformer/transformers/GeminiCodeAssistTransformer.js +7 -1079
- package/dist/transformer/transformers/GeminiTransformer.cjs +4 -1010
- package/dist/transformer/transformers/GeminiTransformer.js +4 -983
- package/dist/transformer/transformers/OpenAIResponseTransformer.cjs +3 -535
- package/dist/transformer/transformers/OpenAIResponseTransformer.js +3 -510
- package/dist/transformer/transformers/OpenCodeGoTransformer.cjs +5 -72
- package/dist/transformer/transformers/OpenCodeGoTransformer.js +3 -45
- package/dist/transformer/transformers/ReasoningTransformer.cjs +3 -270
- package/dist/transformer/transformers/ReasoningTransformer.js +2 -249
- package/dist/transformer/transformers.cjs +10 -3177
- package/dist/transformer/transformers.js +23 -3158
- package/dist/transformer/types.cjs +1 -18
- package/dist/transformer.cjs +13 -3726
- package/dist/transformer.js +17 -3706
- package/dist/usage/pricing-engine.cjs +6 -0
- package/dist/usage/pricing-engine.d.cts +83 -0
- package/dist/usage/pricing-engine.d.ts +83 -0
- package/dist/usage/pricing-engine.js +6 -0
- package/dist/usage/usage-recorder.cjs +6 -0
- package/dist/usage/usage-recorder.d.cts +73 -0
- package/dist/usage/usage-recorder.d.ts +73 -0
- package/dist/usage/usage-recorder.js +6 -0
- package/dist/usage.cjs +11 -0
- package/dist/usage.d.cts +8 -0
- package/dist/usage.d.ts +8 -0
- package/dist/usage.js +11 -0
- package/package.json +1 -1
- package/dist/ApiKeyPoolService-BmMkau07.d.cts +0 -170
- package/dist/ApiKeyPoolService-BmMkau07.d.ts +0 -170
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,193 @@
|
|
|
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;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import {
|
|
2
|
+
injectExtendedContextBeta
|
|
3
|
+
} from "./chunk-MZNPGW5Q.js";
|
|
4
|
+
|
|
5
|
+
// src/transformer/TransformerChainExecutor.ts
|
|
6
|
+
var defaultLogger = {
|
|
7
|
+
debug: (msg, ...args) => console.debug(`[ChainExecutor] ${msg}`, ...args),
|
|
8
|
+
info: (msg, ...args) => console.info(`[ChainExecutor] ${msg}`, ...args),
|
|
9
|
+
warn: (msg, ...args) => console.warn(`[ChainExecutor] ${msg}`, ...args),
|
|
10
|
+
error: (msg, ...args) => console.error(`[ChainExecutor] ${msg}`, ...args)
|
|
11
|
+
};
|
|
12
|
+
var TransformerChainExecutor = class {
|
|
13
|
+
logger;
|
|
14
|
+
constructor(logger) {
|
|
15
|
+
this.logger = logger ?? defaultLogger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Execute the request transformation chain
|
|
19
|
+
*
|
|
20
|
+
* @param request - Original request body
|
|
21
|
+
* @param provider - LLM provider configuration
|
|
22
|
+
* @param chain - Resolved transformer chain
|
|
23
|
+
* @param options - Execution options
|
|
24
|
+
* @returns Transformed request result
|
|
25
|
+
*/
|
|
26
|
+
async executeRequestChain(request, provider, chain, options = {}) {
|
|
27
|
+
const { endpointTransformer, headers, extendedContext } = options;
|
|
28
|
+
const context = {
|
|
29
|
+
logger: this.logger,
|
|
30
|
+
providerName: provider.name
|
|
31
|
+
};
|
|
32
|
+
let requestBody = request;
|
|
33
|
+
let config = {};
|
|
34
|
+
let bypass = false;
|
|
35
|
+
bypass = this.shouldBypassTransformers(
|
|
36
|
+
chain,
|
|
37
|
+
endpointTransformer,
|
|
38
|
+
requestBody
|
|
39
|
+
);
|
|
40
|
+
if (bypass) {
|
|
41
|
+
if (headers) {
|
|
42
|
+
const cleanHeaders = this.cleanHeaders(headers);
|
|
43
|
+
config.headers = cleanHeaders;
|
|
44
|
+
}
|
|
45
|
+
this.logger.debug("Bypass mode enabled - skipping transformations");
|
|
46
|
+
}
|
|
47
|
+
if (!bypass && endpointTransformer?.transformRequestOut) {
|
|
48
|
+
this.logger.debug("Executing transformRequestOut");
|
|
49
|
+
try {
|
|
50
|
+
const transformOut = await endpointTransformer.transformRequestOut(requestBody, context);
|
|
51
|
+
if (transformOut && typeof transformOut === "object") {
|
|
52
|
+
if ("body" in transformOut) {
|
|
53
|
+
requestBody = transformOut.body;
|
|
54
|
+
config = transformOut.config ?? {};
|
|
55
|
+
} else {
|
|
56
|
+
requestBody = transformOut;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
this.logger.error(`transformRequestOut error: ${this.getErrorMessage(error)}`);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!bypass && chain.providerTransformers.length > 0) {
|
|
65
|
+
this.logger.debug(`Executing ${chain.providerTransformers.length} provider transformers`);
|
|
66
|
+
for (const transformer of chain.providerTransformers) {
|
|
67
|
+
if (transformer.transformRequestIn) {
|
|
68
|
+
try {
|
|
69
|
+
const transformIn = await transformer.transformRequestIn(
|
|
70
|
+
requestBody,
|
|
71
|
+
provider,
|
|
72
|
+
context
|
|
73
|
+
);
|
|
74
|
+
if (transformIn && typeof transformIn === "object") {
|
|
75
|
+
if ("body" in transformIn) {
|
|
76
|
+
requestBody = transformIn.body;
|
|
77
|
+
config = { ...config, ...transformIn.config };
|
|
78
|
+
} else {
|
|
79
|
+
requestBody = transformIn;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
this.logger.error(
|
|
84
|
+
`Provider transformer ${transformer.name} error: ${this.getErrorMessage(error)}`
|
|
85
|
+
);
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!bypass && chain.modelTransformers.length > 0) {
|
|
92
|
+
this.logger.debug(`Executing ${chain.modelTransformers.length} model transformers`);
|
|
93
|
+
for (const transformer of chain.modelTransformers) {
|
|
94
|
+
if (transformer.transformRequestIn) {
|
|
95
|
+
try {
|
|
96
|
+
const result = await transformer.transformRequestIn(
|
|
97
|
+
requestBody,
|
|
98
|
+
provider,
|
|
99
|
+
context
|
|
100
|
+
);
|
|
101
|
+
requestBody = result;
|
|
102
|
+
} catch (error) {
|
|
103
|
+
this.logger.error(
|
|
104
|
+
`Model transformer ${transformer.name} error: ${this.getErrorMessage(error)}`
|
|
105
|
+
);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (extendedContext?.enabled) {
|
|
112
|
+
if (!config.headers || typeof config.headers !== "object") {
|
|
113
|
+
config.headers = {};
|
|
114
|
+
}
|
|
115
|
+
injectExtendedContextBeta(
|
|
116
|
+
config.headers,
|
|
117
|
+
extendedContext.model,
|
|
118
|
+
true
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return { requestBody, config, bypass };
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Execute the response transformation chain
|
|
125
|
+
*
|
|
126
|
+
* @param request - Original request (for context)
|
|
127
|
+
* @param response - Response from provider
|
|
128
|
+
* @param provider - LLM provider configuration
|
|
129
|
+
* @param chain - Resolved transformer chain
|
|
130
|
+
* @param options - Execution options
|
|
131
|
+
* @returns Transformed response
|
|
132
|
+
*/
|
|
133
|
+
async executeResponseChain(request, response, provider, chain, options = {}) {
|
|
134
|
+
const { endpointTransformer } = options;
|
|
135
|
+
const context = {
|
|
136
|
+
logger: this.logger,
|
|
137
|
+
providerName: provider.name
|
|
138
|
+
};
|
|
139
|
+
let finalResponse = response;
|
|
140
|
+
const bypass = this.shouldBypassTransformers(chain, endpointTransformer, request);
|
|
141
|
+
if (bypass) {
|
|
142
|
+
this.logger.debug("Bypass mode - skipping response transformations");
|
|
143
|
+
return finalResponse;
|
|
144
|
+
}
|
|
145
|
+
if (chain.modelTransformers.length > 0) {
|
|
146
|
+
const reversedModelTransformers = [...chain.modelTransformers].reverse();
|
|
147
|
+
this.logger.debug(
|
|
148
|
+
`Executing ${reversedModelTransformers.length} model response transformers (reversed)`
|
|
149
|
+
);
|
|
150
|
+
for (const transformer of reversedModelTransformers) {
|
|
151
|
+
if (transformer.transformResponseOut) {
|
|
152
|
+
try {
|
|
153
|
+
finalResponse = await transformer.transformResponseOut(finalResponse, context);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
this.logger.error(
|
|
156
|
+
`Model transformer ${transformer.name} response error: ${this.getErrorMessage(error)}`
|
|
157
|
+
);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (chain.providerTransformers.length > 0) {
|
|
164
|
+
const reversedProviderTransformers = [...chain.providerTransformers].reverse();
|
|
165
|
+
this.logger.debug(
|
|
166
|
+
`Executing ${reversedProviderTransformers.length} provider response transformers (reversed)`
|
|
167
|
+
);
|
|
168
|
+
for (const transformer of reversedProviderTransformers) {
|
|
169
|
+
if (transformer.transformResponseOut) {
|
|
170
|
+
try {
|
|
171
|
+
finalResponse = await transformer.transformResponseOut(finalResponse, context);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
this.logger.error(
|
|
174
|
+
`Provider transformer ${transformer.name} response error: ${this.getErrorMessage(error)}`
|
|
175
|
+
);
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (endpointTransformer?.transformResponseIn) {
|
|
182
|
+
this.logger.debug("Executing transformResponseIn");
|
|
183
|
+
try {
|
|
184
|
+
finalResponse = await endpointTransformer.transformResponseIn(finalResponse, context);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
this.logger.error(`transformResponseIn error: ${this.getErrorMessage(error)}`);
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return finalResponse;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Execute authentication handler if available
|
|
194
|
+
*
|
|
195
|
+
* @param request - Request body
|
|
196
|
+
* @param provider - LLM provider
|
|
197
|
+
* @param endpointTransformer - Endpoint transformer with auth handler
|
|
198
|
+
* @param context - Transformer context
|
|
199
|
+
* @returns Auth result with potentially modified request and config
|
|
200
|
+
*/
|
|
201
|
+
async executeAuth(request, provider, endpointTransformer, context) {
|
|
202
|
+
let requestBody = request;
|
|
203
|
+
let config = {};
|
|
204
|
+
if (endpointTransformer?.auth) {
|
|
205
|
+
this.logger.debug("Executing auth handler");
|
|
206
|
+
try {
|
|
207
|
+
const auth = await endpointTransformer.auth(requestBody, provider, context);
|
|
208
|
+
if (auth && typeof auth === "object") {
|
|
209
|
+
if ("body" in auth) {
|
|
210
|
+
requestBody = auth.body;
|
|
211
|
+
const authConfig = auth.config;
|
|
212
|
+
if (authConfig) {
|
|
213
|
+
const headers = { ...config.headers ?? {}, ...authConfig.headers ?? {} };
|
|
214
|
+
delete headers["host"];
|
|
215
|
+
config = { ...config, ...authConfig, headers };
|
|
216
|
+
}
|
|
217
|
+
} else {
|
|
218
|
+
requestBody = auth;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} catch (error) {
|
|
222
|
+
this.logger.error(`Auth handler error: ${this.getErrorMessage(error)}`);
|
|
223
|
+
throw error;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { requestBody, config };
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Check if transformers should be bypassed (optimization)
|
|
230
|
+
*
|
|
231
|
+
* Bypass is enabled when:
|
|
232
|
+
* - Provider has only one transformer that matches the endpoint transformer
|
|
233
|
+
* - Model has no specific transformers or only the same endpoint transformer
|
|
234
|
+
*/
|
|
235
|
+
shouldBypassTransformers(chain, endpointTransformer, _request) {
|
|
236
|
+
if (!endpointTransformer?.name) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
const providerHasOnlyEndpoint = chain.providerTransformers.length === 1 && chain.providerTransformers[0]?.name === endpointTransformer.name;
|
|
240
|
+
const modelHasNoTransformers = chain.modelTransformers.length === 0;
|
|
241
|
+
const modelHasOnlyEndpoint = chain.modelTransformers.length === 1 && chain.modelTransformers[0]?.name === endpointTransformer.name;
|
|
242
|
+
return providerHasOnlyEndpoint && (modelHasNoTransformers || modelHasOnlyEndpoint);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Clean headers for pass-through
|
|
246
|
+
*/
|
|
247
|
+
cleanHeaders(headers) {
|
|
248
|
+
const result = {};
|
|
249
|
+
if (headers instanceof Headers) {
|
|
250
|
+
headers.forEach((value, key) => {
|
|
251
|
+
if (key.toLowerCase() !== "content-length") {
|
|
252
|
+
result[key] = value;
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
257
|
+
if (key.toLowerCase() !== "content-length") {
|
|
258
|
+
result[key] = value;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get error message from unknown error
|
|
266
|
+
*/
|
|
267
|
+
getErrorMessage(error) {
|
|
268
|
+
if (error instanceof Error) {
|
|
269
|
+
return error.message;
|
|
270
|
+
}
|
|
271
|
+
return String(error);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export {
|
|
276
|
+
TransformerChainExecutor
|
|
277
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/transformer/anthropicBetaInject.ts
|
|
2
|
+
var _extendedcontext = require('@omnicross/contracts/extended-context');
|
|
3
|
+
var EXTENDED_CONTEXT_BETA = "context-1m-2025-08-07";
|
|
4
|
+
var ANTHROPIC_BETA_HEADER = "anthropic-beta";
|
|
5
|
+
function injectExtendedContextBeta(headers, model, useExtendedContext) {
|
|
6
|
+
if (!useExtendedContext) return;
|
|
7
|
+
if (!_extendedcontext.isExtendedContextCapable.call(void 0, model)) return;
|
|
8
|
+
let existingValue = "";
|
|
9
|
+
for (const key of Object.keys(headers)) {
|
|
10
|
+
if (key.toLowerCase() === ANTHROPIC_BETA_HEADER) {
|
|
11
|
+
const v = headers[key];
|
|
12
|
+
if (typeof v === "string") existingValue = v;
|
|
13
|
+
if (key !== ANTHROPIC_BETA_HEADER) delete headers[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const parts = existingValue.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
17
|
+
if (!parts.includes(EXTENDED_CONTEXT_BETA)) {
|
|
18
|
+
parts.push(EXTENDED_CONTEXT_BETA);
|
|
19
|
+
}
|
|
20
|
+
headers[ANTHROPIC_BETA_HEADER] = parts.join(",");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
exports.EXTENDED_CONTEXT_BETA = EXTENDED_CONTEXT_BETA; exports.injectExtendedContextBeta = injectExtendedContextBeta;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/completion/native-search-types.ts
|
|
2
|
+
var NATIVE_SEARCH_MODEL_PATTERNS = {
|
|
3
|
+
openai: [/^gpt-4/, /^o[134]/, /^gpt-5/],
|
|
4
|
+
// Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
|
|
5
|
+
// Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
|
|
6
|
+
anthropic: [/^claude-/],
|
|
7
|
+
google: [/^gemini-(?:2|3|flash|pro)/],
|
|
8
|
+
xai: [/^grok/],
|
|
9
|
+
openrouter: []
|
|
10
|
+
// Detected via provider, not model pattern
|
|
11
|
+
};
|
|
12
|
+
var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
|
|
13
|
+
"gpt-4o-search-preview",
|
|
14
|
+
"gpt-4o-mini-search-preview",
|
|
15
|
+
"gpt-5-search-api"
|
|
16
|
+
];
|
|
17
|
+
var NATIVE_SEARCH_EXCLUDED_MODELS = [
|
|
18
|
+
"gpt-4.1-nano"
|
|
19
|
+
];
|
|
20
|
+
var NATIVE_SEARCH_TOOL_NAMES = [
|
|
21
|
+
"web_search",
|
|
22
|
+
"web_search_20250305",
|
|
23
|
+
"web_search_20260209",
|
|
24
|
+
"google_search",
|
|
25
|
+
"googleSearchRetrieval"
|
|
26
|
+
];
|
|
27
|
+
var API_FORMAT_PROVIDER_MAP = {
|
|
28
|
+
"openai-response": "openai",
|
|
29
|
+
anthropic: "anthropic",
|
|
30
|
+
google: "google"
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
exports.NATIVE_SEARCH_MODEL_PATTERNS = NATIVE_SEARCH_MODEL_PATTERNS; exports.OPENAI_CHAT_COMPLETION_SEARCH_MODELS = OPENAI_CHAT_COMPLETION_SEARCH_MODELS; exports.NATIVE_SEARCH_EXCLUDED_MODELS = NATIVE_SEARCH_EXCLUDED_MODELS; exports.NATIVE_SEARCH_TOOL_NAMES = NATIVE_SEARCH_TOOL_NAMES; exports.API_FORMAT_PROVIDER_MAP = API_FORMAT_PROVIDER_MAP;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// src/completion/url-builder.ts
|
|
2
|
+
import { resolveProviderEndpoint as resolveProviderEndpointShared } from "@omnicross/contracts/endpoint-resolver";
|
|
3
|
+
function resolveApiFormat(provider) {
|
|
4
|
+
if (provider.apiFormat) {
|
|
5
|
+
return provider.apiFormat;
|
|
6
|
+
}
|
|
7
|
+
if (provider.chatApiFormat) {
|
|
8
|
+
return provider.chatApiFormat;
|
|
9
|
+
}
|
|
10
|
+
if (provider.apiType === "claudecode" || provider.apiType === "anthropic") {
|
|
11
|
+
return "anthropic";
|
|
12
|
+
}
|
|
13
|
+
if (provider.apiType === "google") {
|
|
14
|
+
return "google";
|
|
15
|
+
}
|
|
16
|
+
return "openai";
|
|
17
|
+
}
|
|
18
|
+
function buildOpenAIApiUrl(baseUrl) {
|
|
19
|
+
const url = baseUrl.replace(/\/+$/, "");
|
|
20
|
+
if (url.endsWith("/chat/completions")) {
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
23
|
+
if (/\/v\d+$/.test(url)) {
|
|
24
|
+
return url + "/chat/completions";
|
|
25
|
+
}
|
|
26
|
+
if (url.includes("/chat/completions")) {
|
|
27
|
+
return url;
|
|
28
|
+
}
|
|
29
|
+
return url + "/v1/chat/completions";
|
|
30
|
+
}
|
|
31
|
+
function buildAnthropicApiUrl(baseUrl) {
|
|
32
|
+
const url = baseUrl.replace(/\/+$/, "");
|
|
33
|
+
if (url.endsWith("/messages")) {
|
|
34
|
+
return url;
|
|
35
|
+
}
|
|
36
|
+
if (url.includes("/messages")) {
|
|
37
|
+
return url;
|
|
38
|
+
}
|
|
39
|
+
if (/\/v\d+$/.test(url)) {
|
|
40
|
+
return url + "/messages";
|
|
41
|
+
}
|
|
42
|
+
return url + "/v1/messages";
|
|
43
|
+
}
|
|
44
|
+
function buildGeminiModelActionUrl(baseUrl, model, action) {
|
|
45
|
+
let url = baseUrl.replace(/\/+$/, "");
|
|
46
|
+
if (url.includes("/models/")) {
|
|
47
|
+
return url;
|
|
48
|
+
}
|
|
49
|
+
if (!/\/v\d+(?:beta)?(?:$|\/)/.test(url)) {
|
|
50
|
+
url += "/v1beta";
|
|
51
|
+
}
|
|
52
|
+
return `${url}/models/${model}:${action}`;
|
|
53
|
+
}
|
|
54
|
+
function buildGeminiApiUrl(baseUrl, model, stream) {
|
|
55
|
+
const action = stream ? "streamGenerateContent?alt=sse" : "generateContent";
|
|
56
|
+
return buildGeminiModelActionUrl(baseUrl, model, action);
|
|
57
|
+
}
|
|
58
|
+
function normalizeAzureEndpoint(endpoint) {
|
|
59
|
+
return endpoint.replace(/\/+$/, "").replace(/\/openai(\/v\d+)?$/, "");
|
|
60
|
+
}
|
|
61
|
+
function buildAzureOpenAIApiUrl(baseUrl, model, apiVersion) {
|
|
62
|
+
const endpoint = normalizeAzureEndpoint(baseUrl);
|
|
63
|
+
return `${endpoint}/openai/deployments/${model}/chat/completions?api-version=${apiVersion}`;
|
|
64
|
+
}
|
|
65
|
+
function buildOpenAIResponseApiUrl(baseUrl) {
|
|
66
|
+
const url = baseUrl.replace(/\/+$/, "");
|
|
67
|
+
if (url.endsWith("/responses")) {
|
|
68
|
+
return url;
|
|
69
|
+
}
|
|
70
|
+
if (/\/v\d+$/.test(url)) {
|
|
71
|
+
return url + "/responses";
|
|
72
|
+
}
|
|
73
|
+
return url + "/v1/responses";
|
|
74
|
+
}
|
|
75
|
+
var resolveProviderEndpoint = resolveProviderEndpointShared;
|
|
76
|
+
function buildProviderApiUrl(provider, options = {}) {
|
|
77
|
+
const format = resolveApiFormat(provider);
|
|
78
|
+
const { baseUrl } = resolveProviderEndpoint(provider);
|
|
79
|
+
switch (format) {
|
|
80
|
+
case "anthropic":
|
|
81
|
+
return buildAnthropicApiUrl(baseUrl);
|
|
82
|
+
case "google":
|
|
83
|
+
return buildGeminiApiUrl(baseUrl, options.model || "", options.stream || false);
|
|
84
|
+
case "azure-openai":
|
|
85
|
+
return buildAzureOpenAIApiUrl(baseUrl, options.model || "", provider.apiVersion || "2024-08-01-preview");
|
|
86
|
+
case "openai-response":
|
|
87
|
+
return buildOpenAIResponseApiUrl(baseUrl);
|
|
88
|
+
case "openai":
|
|
89
|
+
default:
|
|
90
|
+
return buildOpenAIApiUrl(baseUrl);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
resolveApiFormat,
|
|
96
|
+
buildOpenAIApiUrl,
|
|
97
|
+
buildAnthropicApiUrl,
|
|
98
|
+
buildGeminiModelActionUrl,
|
|
99
|
+
buildGeminiApiUrl,
|
|
100
|
+
normalizeAzureEndpoint,
|
|
101
|
+
buildAzureOpenAIApiUrl,
|
|
102
|
+
buildOpenAIResponseApiUrl,
|
|
103
|
+
resolveProviderEndpoint,
|
|
104
|
+
buildProviderApiUrl
|
|
105
|
+
};
|