@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
|
@@ -1,37 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const headers = {
|
|
11
|
-
Authorization: `Bearer ${apiKey}`,
|
|
12
|
-
"HTTP-Referer": OPENROUTER_HTTP_REFERER,
|
|
13
|
-
"X-Title": OPENROUTER_X_TITLE
|
|
14
|
-
};
|
|
15
|
-
if (options.contentType !== false) {
|
|
16
|
-
headers["Content-Type"] = options.contentType ?? "application/json";
|
|
17
|
-
}
|
|
18
|
-
if (options.extra) {
|
|
19
|
-
for (const [key, value] of Object.entries(options.extra)) {
|
|
20
|
-
headers[key] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return headers;
|
|
24
|
-
}
|
|
25
|
-
function resolveOpenRouterBaseUrl(endpoint) {
|
|
26
|
-
const raw = endpoint?.trim();
|
|
27
|
-
const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
|
|
28
|
-
return base.replace(/\/+$/, "");
|
|
29
|
-
}
|
|
30
|
-
function buildOpenRouterUrl(endpoint, path) {
|
|
31
|
-
const base = resolveOpenRouterBaseUrl(endpoint);
|
|
32
|
-
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
33
|
-
return `${base}${cleanPath}`;
|
|
34
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
OPENROUTER_DEFAULT_BASE_URL,
|
|
3
|
+
OPENROUTER_HTTP_REFERER,
|
|
4
|
+
OPENROUTER_X_TITLE,
|
|
5
|
+
buildOpenRouterHeaders,
|
|
6
|
+
buildOpenRouterUrl,
|
|
7
|
+
resolveOpenRouterBaseUrl
|
|
8
|
+
} from "../chunk-ZSVQT3PW.js";
|
|
35
9
|
export {
|
|
36
10
|
OPENROUTER_DEFAULT_BASE_URL,
|
|
37
11
|
OPENROUTER_HTTP_REFERER,
|
|
@@ -1,68 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
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; }
|
|
19
2
|
|
|
20
|
-
// src/completion/openrouter-models.ts
|
|
21
|
-
var openrouter_models_exports = {};
|
|
22
|
-
__export(openrouter_models_exports, {
|
|
23
|
-
fetchOpenRouterModels: () => fetchOpenRouterModels
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(openrouter_models_exports);
|
|
26
3
|
|
|
27
|
-
|
|
28
|
-
var OPENROUTER_DEFAULT_BASE_URL = "https://openrouter.ai/api/v1";
|
|
29
|
-
var OPENROUTER_HTTP_REFERER = "https://omnicross.dev";
|
|
30
|
-
var OPENROUTER_X_TITLE = "Omnicross";
|
|
31
|
-
function buildOpenRouterHeaders(credentials, options = {}) {
|
|
32
|
-
const apiKey = credentials.apiKey?.trim();
|
|
33
|
-
if (!apiKey) {
|
|
34
|
-
throw new Error("OpenRouter API key is required");
|
|
35
|
-
}
|
|
36
|
-
const headers = {
|
|
37
|
-
Authorization: `Bearer ${apiKey}`,
|
|
38
|
-
"HTTP-Referer": OPENROUTER_HTTP_REFERER,
|
|
39
|
-
"X-Title": OPENROUTER_X_TITLE
|
|
40
|
-
};
|
|
41
|
-
if (options.contentType !== false) {
|
|
42
|
-
headers["Content-Type"] = options.contentType ?? "application/json";
|
|
43
|
-
}
|
|
44
|
-
if (options.extra) {
|
|
45
|
-
for (const [key, value] of Object.entries(options.extra)) {
|
|
46
|
-
headers[key] = value;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return headers;
|
|
50
|
-
}
|
|
51
|
-
function resolveOpenRouterBaseUrl(endpoint) {
|
|
52
|
-
const raw = endpoint?.trim();
|
|
53
|
-
const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
|
|
54
|
-
return base.replace(/\/+$/, "");
|
|
55
|
-
}
|
|
56
|
-
function buildOpenRouterUrl(endpoint, path) {
|
|
57
|
-
const base = resolveOpenRouterBaseUrl(endpoint);
|
|
58
|
-
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
59
|
-
return `${base}${cleanPath}`;
|
|
60
|
-
}
|
|
4
|
+
var _chunk4NBS6KPVcjs = require('../chunk-4NBS6KPV.cjs');
|
|
61
5
|
|
|
62
6
|
// src/completion/openrouter-models.ts
|
|
63
7
|
async function fetchOpenRouterModels(credentials, outputModality) {
|
|
64
|
-
const headers = buildOpenRouterHeaders(credentials);
|
|
65
|
-
const url = buildOpenRouterUrl(
|
|
8
|
+
const headers = _chunk4NBS6KPVcjs.buildOpenRouterHeaders.call(void 0, credentials);
|
|
9
|
+
const url = _chunk4NBS6KPVcjs.buildOpenRouterUrl.call(void 0,
|
|
66
10
|
credentials.endpoint,
|
|
67
11
|
`/models?output_modalities=${encodeURIComponent(outputModality)}`
|
|
68
12
|
);
|
|
@@ -72,15 +16,14 @@ async function fetchOpenRouterModels(credentials, outputModality) {
|
|
|
72
16
|
let message = text.slice(0, 300);
|
|
73
17
|
try {
|
|
74
18
|
const parsed = JSON.parse(text);
|
|
75
|
-
message = parsed
|
|
76
|
-
} catch {
|
|
19
|
+
message = _optionalChain([parsed, 'optionalAccess', _ => _.error, 'optionalAccess', _2 => _2.message]) || _optionalChain([parsed, 'optionalAccess', _3 => _3.message]) || message;
|
|
20
|
+
} catch (e) {
|
|
77
21
|
}
|
|
78
22
|
throw new Error(`OpenRouter /models failed (${response.status}): ${message}`);
|
|
79
23
|
}
|
|
80
24
|
const data = await response.json();
|
|
81
|
-
return data
|
|
25
|
+
return _nullishCoalesce(_optionalChain([data, 'optionalAccess', _4 => _4.data]), () => ( []));
|
|
82
26
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
exports.fetchOpenRouterModels = fetchOpenRouterModels;
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function buildOpenRouterHeaders(credentials, options = {}) {
|
|
6
|
-
const apiKey = credentials.apiKey?.trim();
|
|
7
|
-
if (!apiKey) {
|
|
8
|
-
throw new Error("OpenRouter API key is required");
|
|
9
|
-
}
|
|
10
|
-
const headers = {
|
|
11
|
-
Authorization: `Bearer ${apiKey}`,
|
|
12
|
-
"HTTP-Referer": OPENROUTER_HTTP_REFERER,
|
|
13
|
-
"X-Title": OPENROUTER_X_TITLE
|
|
14
|
-
};
|
|
15
|
-
if (options.contentType !== false) {
|
|
16
|
-
headers["Content-Type"] = options.contentType ?? "application/json";
|
|
17
|
-
}
|
|
18
|
-
if (options.extra) {
|
|
19
|
-
for (const [key, value] of Object.entries(options.extra)) {
|
|
20
|
-
headers[key] = value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return headers;
|
|
24
|
-
}
|
|
25
|
-
function resolveOpenRouterBaseUrl(endpoint) {
|
|
26
|
-
const raw = endpoint?.trim();
|
|
27
|
-
const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
|
|
28
|
-
return base.replace(/\/+$/, "");
|
|
29
|
-
}
|
|
30
|
-
function buildOpenRouterUrl(endpoint, path) {
|
|
31
|
-
const base = resolveOpenRouterBaseUrl(endpoint);
|
|
32
|
-
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
33
|
-
return `${base}${cleanPath}`;
|
|
34
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
buildOpenRouterHeaders,
|
|
3
|
+
buildOpenRouterUrl
|
|
4
|
+
} from "../chunk-ZSVQT3PW.js";
|
|
35
5
|
|
|
36
6
|
// src/completion/openrouter-models.ts
|
|
37
7
|
async function fetchOpenRouterModels(credentials, outputModality) {
|
|
@@ -1,18 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
|
|
16
|
-
// src/completion/types.ts
|
|
17
|
-
var types_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(types_exports);
|
|
1
|
+
"use strict";
|
|
@@ -1,138 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
buildGeminiApiUrl: () => buildGeminiApiUrl,
|
|
26
|
-
buildGeminiModelActionUrl: () => buildGeminiModelActionUrl,
|
|
27
|
-
buildOpenAIApiUrl: () => buildOpenAIApiUrl,
|
|
28
|
-
buildOpenAIResponseApiUrl: () => buildOpenAIResponseApiUrl,
|
|
29
|
-
buildProviderApiUrl: () => buildProviderApiUrl,
|
|
30
|
-
normalizeAzureEndpoint: () => normalizeAzureEndpoint,
|
|
31
|
-
resolveApiFormat: () => resolveApiFormat,
|
|
32
|
-
resolveProviderEndpoint: () => resolveProviderEndpoint
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(url_builder_exports);
|
|
35
|
-
var import_endpoint_resolver = require("@omnicross/contracts/endpoint-resolver");
|
|
36
|
-
function resolveApiFormat(provider) {
|
|
37
|
-
if (provider.apiFormat) {
|
|
38
|
-
return provider.apiFormat;
|
|
39
|
-
}
|
|
40
|
-
if (provider.chatApiFormat) {
|
|
41
|
-
return provider.chatApiFormat;
|
|
42
|
-
}
|
|
43
|
-
if (provider.apiType === "claudecode" || provider.apiType === "anthropic") {
|
|
44
|
-
return "anthropic";
|
|
45
|
-
}
|
|
46
|
-
if (provider.apiType === "google") {
|
|
47
|
-
return "google";
|
|
48
|
-
}
|
|
49
|
-
return "openai";
|
|
50
|
-
}
|
|
51
|
-
function buildOpenAIApiUrl(baseUrl) {
|
|
52
|
-
const url = baseUrl.replace(/\/+$/, "");
|
|
53
|
-
if (url.endsWith("/chat/completions")) {
|
|
54
|
-
return url;
|
|
55
|
-
}
|
|
56
|
-
if (/\/v\d+$/.test(url)) {
|
|
57
|
-
return url + "/chat/completions";
|
|
58
|
-
}
|
|
59
|
-
if (url.includes("/chat/completions")) {
|
|
60
|
-
return url;
|
|
61
|
-
}
|
|
62
|
-
return url + "/v1/chat/completions";
|
|
63
|
-
}
|
|
64
|
-
function buildAnthropicApiUrl(baseUrl) {
|
|
65
|
-
const url = baseUrl.replace(/\/+$/, "");
|
|
66
|
-
if (url.endsWith("/messages")) {
|
|
67
|
-
return url;
|
|
68
|
-
}
|
|
69
|
-
if (url.includes("/messages")) {
|
|
70
|
-
return url;
|
|
71
|
-
}
|
|
72
|
-
if (/\/v\d+$/.test(url)) {
|
|
73
|
-
return url + "/messages";
|
|
74
|
-
}
|
|
75
|
-
return url + "/v1/messages";
|
|
76
|
-
}
|
|
77
|
-
function buildGeminiModelActionUrl(baseUrl, model, action) {
|
|
78
|
-
let url = baseUrl.replace(/\/+$/, "");
|
|
79
|
-
if (url.includes("/models/")) {
|
|
80
|
-
return url;
|
|
81
|
-
}
|
|
82
|
-
if (!/\/v\d+(?:beta)?(?:$|\/)/.test(url)) {
|
|
83
|
-
url += "/v1beta";
|
|
84
|
-
}
|
|
85
|
-
return `${url}/models/${model}:${action}`;
|
|
86
|
-
}
|
|
87
|
-
function buildGeminiApiUrl(baseUrl, model, stream) {
|
|
88
|
-
const action = stream ? "streamGenerateContent?alt=sse" : "generateContent";
|
|
89
|
-
return buildGeminiModelActionUrl(baseUrl, model, action);
|
|
90
|
-
}
|
|
91
|
-
function normalizeAzureEndpoint(endpoint) {
|
|
92
|
-
return endpoint.replace(/\/+$/, "").replace(/\/openai(\/v\d+)?$/, "");
|
|
93
|
-
}
|
|
94
|
-
function buildAzureOpenAIApiUrl(baseUrl, model, apiVersion) {
|
|
95
|
-
const endpoint = normalizeAzureEndpoint(baseUrl);
|
|
96
|
-
return `${endpoint}/openai/deployments/${model}/chat/completions?api-version=${apiVersion}`;
|
|
97
|
-
}
|
|
98
|
-
function buildOpenAIResponseApiUrl(baseUrl) {
|
|
99
|
-
const url = baseUrl.replace(/\/+$/, "");
|
|
100
|
-
if (url.endsWith("/responses")) {
|
|
101
|
-
return url;
|
|
102
|
-
}
|
|
103
|
-
if (/\/v\d+$/.test(url)) {
|
|
104
|
-
return url + "/responses";
|
|
105
|
-
}
|
|
106
|
-
return url + "/v1/responses";
|
|
107
|
-
}
|
|
108
|
-
var resolveProviderEndpoint = import_endpoint_resolver.resolveProviderEndpoint;
|
|
109
|
-
function buildProviderApiUrl(provider, options = {}) {
|
|
110
|
-
const format = resolveApiFormat(provider);
|
|
111
|
-
const { baseUrl } = resolveProviderEndpoint(provider);
|
|
112
|
-
switch (format) {
|
|
113
|
-
case "anthropic":
|
|
114
|
-
return buildAnthropicApiUrl(baseUrl);
|
|
115
|
-
case "google":
|
|
116
|
-
return buildGeminiApiUrl(baseUrl, options.model || "", options.stream || false);
|
|
117
|
-
case "azure-openai":
|
|
118
|
-
return buildAzureOpenAIApiUrl(baseUrl, options.model || "", provider.apiVersion || "2024-08-01-preview");
|
|
119
|
-
case "openai-response":
|
|
120
|
-
return buildOpenAIResponseApiUrl(baseUrl);
|
|
121
|
-
case "openai":
|
|
122
|
-
default:
|
|
123
|
-
return buildOpenAIApiUrl(baseUrl);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
-
0 && (module.exports = {
|
|
128
|
-
buildAnthropicApiUrl,
|
|
129
|
-
buildAzureOpenAIApiUrl,
|
|
130
|
-
buildGeminiApiUrl,
|
|
131
|
-
buildGeminiModelActionUrl,
|
|
132
|
-
buildOpenAIApiUrl,
|
|
133
|
-
buildOpenAIResponseApiUrl,
|
|
134
|
-
buildProviderApiUrl,
|
|
135
|
-
normalizeAzureEndpoint,
|
|
136
|
-
resolveApiFormat,
|
|
137
|
-
resolveProviderEndpoint
|
|
138
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkA2YMUCBTcjs = require('../chunk-A2YMUCBT.cjs');
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.buildAnthropicApiUrl = _chunkA2YMUCBTcjs.buildAnthropicApiUrl; exports.buildAzureOpenAIApiUrl = _chunkA2YMUCBTcjs.buildAzureOpenAIApiUrl; exports.buildGeminiApiUrl = _chunkA2YMUCBTcjs.buildGeminiApiUrl; exports.buildGeminiModelActionUrl = _chunkA2YMUCBTcjs.buildGeminiModelActionUrl; exports.buildOpenAIApiUrl = _chunkA2YMUCBTcjs.buildOpenAIApiUrl; exports.buildOpenAIResponseApiUrl = _chunkA2YMUCBTcjs.buildOpenAIResponseApiUrl; exports.buildProviderApiUrl = _chunkA2YMUCBTcjs.buildProviderApiUrl; exports.normalizeAzureEndpoint = _chunkA2YMUCBTcjs.normalizeAzureEndpoint; exports.resolveApiFormat = _chunkA2YMUCBTcjs.resolveApiFormat; exports.resolveProviderEndpoint = _chunkA2YMUCBTcjs.resolveProviderEndpoint;
|
|
@@ -1,95 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
buildAnthropicApiUrl,
|
|
3
|
+
buildAzureOpenAIApiUrl,
|
|
4
|
+
buildGeminiApiUrl,
|
|
5
|
+
buildGeminiModelActionUrl,
|
|
6
|
+
buildOpenAIApiUrl,
|
|
7
|
+
buildOpenAIResponseApiUrl,
|
|
8
|
+
buildProviderApiUrl,
|
|
9
|
+
normalizeAzureEndpoint,
|
|
10
|
+
resolveApiFormat,
|
|
11
|
+
resolveProviderEndpoint
|
|
12
|
+
} from "../chunk-H5JUT3KV.js";
|
|
93
13
|
export {
|
|
94
14
|
buildAnthropicApiUrl,
|
|
95
15
|
buildAzureOpenAIApiUrl,
|