@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,196 +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});
|
|
19
2
|
|
|
20
|
-
// src/completion/NativeSearchInjector.ts
|
|
21
|
-
var NativeSearchInjector_exports = {};
|
|
22
|
-
__export(NativeSearchInjector_exports, {
|
|
23
|
-
applyAugmentation: () => applyAugmentation,
|
|
24
|
-
buildNativeSearchAugmentation: () => buildNativeSearchAugmentation,
|
|
25
|
-
detectNativeSearch: () => detectNativeSearch
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(NativeSearchInjector_exports);
|
|
28
3
|
|
|
29
|
-
// src/openrouter.ts
|
|
30
|
-
function isOpenRouterProvider(provider) {
|
|
31
|
-
const baseUrl = (provider.api_base_url || "").toLowerCase();
|
|
32
|
-
return baseUrl.includes("openrouter.ai");
|
|
33
|
-
}
|
|
34
4
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
|
|
39
|
-
// Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
|
|
40
|
-
anthropic: [/^claude-/],
|
|
41
|
-
google: [/^gemini-(?:2|3|flash|pro)/],
|
|
42
|
-
xai: [/^grok/],
|
|
43
|
-
openrouter: []
|
|
44
|
-
// Detected via provider, not model pattern
|
|
45
|
-
};
|
|
46
|
-
var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
|
|
47
|
-
"gpt-4o-search-preview",
|
|
48
|
-
"gpt-4o-mini-search-preview",
|
|
49
|
-
"gpt-5-search-api"
|
|
50
|
-
];
|
|
51
|
-
var NATIVE_SEARCH_EXCLUDED_MODELS = [
|
|
52
|
-
"gpt-4.1-nano"
|
|
53
|
-
];
|
|
54
|
-
var API_FORMAT_PROVIDER_MAP = {
|
|
55
|
-
"openai-response": "openai",
|
|
56
|
-
anthropic: "anthropic",
|
|
57
|
-
google: "google"
|
|
58
|
-
};
|
|
5
|
+
var _chunkV5KPWNYXcjs = require('../chunk-V5KPWNYX.cjs');
|
|
6
|
+
require('../chunk-6VIXXLMX.cjs');
|
|
7
|
+
require('../chunk-GMMT7RVN.cjs');
|
|
59
8
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
if (isXaiProvider(provider)) {
|
|
66
|
-
return { supported: true, nativeProvider: "xai" };
|
|
67
|
-
}
|
|
68
|
-
if (apiFormat === "openai" && OPENAI_CHAT_COMPLETION_SEARCH_MODELS.some((m) => modelId.startsWith(m))) {
|
|
69
|
-
return { supported: true, nativeProvider: "openai" };
|
|
70
|
-
}
|
|
71
|
-
const formatProvider = API_FORMAT_PROVIDER_MAP[apiFormat];
|
|
72
|
-
if (formatProvider) {
|
|
73
|
-
const patterns = NATIVE_SEARCH_MODEL_PATTERNS[formatProvider];
|
|
74
|
-
if (patterns.some((re) => re.test(modelId))) {
|
|
75
|
-
if (!NATIVE_SEARCH_EXCLUDED_MODELS.some((m) => modelId.startsWith(m))) {
|
|
76
|
-
return { supported: true, nativeProvider: formatProvider };
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (userExplicit && formatProvider) {
|
|
81
|
-
return { supported: true, nativeProvider: formatProvider };
|
|
82
|
-
}
|
|
83
|
-
return { supported: false, nativeProvider: null };
|
|
84
|
-
}
|
|
85
|
-
function buildNativeSearchAugmentation(nativeProvider, config, _apiFormat, modelId) {
|
|
86
|
-
if (!config.enabled) return null;
|
|
87
|
-
switch (nativeProvider) {
|
|
88
|
-
case "openai":
|
|
89
|
-
return buildOpenAIAugmentation(config, modelId);
|
|
90
|
-
case "anthropic":
|
|
91
|
-
return buildAnthropicAugmentation(config);
|
|
92
|
-
case "google":
|
|
93
|
-
return buildGoogleAugmentation(modelId);
|
|
94
|
-
case "xai":
|
|
95
|
-
return buildXaiAugmentation(config);
|
|
96
|
-
case "openrouter":
|
|
97
|
-
return buildOpenRouterAugmentation(config);
|
|
98
|
-
default:
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
function applyAugmentation(requestBody, augmentation) {
|
|
103
|
-
if (augmentation.additionalTools?.length) {
|
|
104
|
-
const existing = requestBody.tools ?? [];
|
|
105
|
-
requestBody.tools = [...existing, ...augmentation.additionalTools];
|
|
106
|
-
}
|
|
107
|
-
if (augmentation.bodyFields) {
|
|
108
|
-
Object.assign(requestBody, augmentation.bodyFields);
|
|
109
|
-
}
|
|
110
|
-
return requestBody;
|
|
111
|
-
}
|
|
112
|
-
function buildOpenAIAugmentation(config, modelId) {
|
|
113
|
-
const isChatCompletionSearch = OPENAI_CHAT_COMPLETION_SEARCH_MODELS.some(
|
|
114
|
-
(m) => modelId.startsWith(m)
|
|
115
|
-
);
|
|
116
|
-
if (isChatCompletionSearch) {
|
|
117
|
-
return {
|
|
118
|
-
bodyFields: {
|
|
119
|
-
web_search_options: {
|
|
120
|
-
search_context_size: config.maxResults ? mapMaxResultsToContextSize(config.maxResults) : "medium"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
return {
|
|
126
|
-
additionalTools: [
|
|
127
|
-
{
|
|
128
|
-
type: "web_search",
|
|
129
|
-
web_search: {
|
|
130
|
-
search_context_size: config.maxResults ? mapMaxResultsToContextSize(config.maxResults) : "medium"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
]
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function buildAnthropicAugmentation(config) {
|
|
137
|
-
const toolDef = {
|
|
138
|
-
type: "web_search_20250305",
|
|
139
|
-
name: "web_search"
|
|
140
|
-
};
|
|
141
|
-
if (config.maxResults) {
|
|
142
|
-
toolDef.max_uses = config.maxResults;
|
|
143
|
-
}
|
|
144
|
-
if (config.blockedDomains?.length) {
|
|
145
|
-
toolDef.blocked_domains = config.blockedDomains;
|
|
146
|
-
}
|
|
147
|
-
return { additionalTools: [toolDef] };
|
|
148
|
-
}
|
|
149
|
-
function buildGoogleAugmentation(modelId) {
|
|
150
|
-
const isLegacy = /gemini-1[._]/.test(modelId);
|
|
151
|
-
if (isLegacy) {
|
|
152
|
-
return {
|
|
153
|
-
additionalTools: [
|
|
154
|
-
{ googleSearchRetrieval: {} }
|
|
155
|
-
]
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
additionalTools: [
|
|
160
|
-
{ google_search: {} }
|
|
161
|
-
]
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
function buildXaiAugmentation(config) {
|
|
165
|
-
const searchParams = {
|
|
166
|
-
mode: config.searchMode ?? "auto",
|
|
167
|
-
return_citations: true,
|
|
168
|
-
max_search_results: config.maxResults ?? 5
|
|
169
|
-
};
|
|
170
|
-
if (config.sources?.length) {
|
|
171
|
-
searchParams.sources = config.sources;
|
|
172
|
-
}
|
|
173
|
-
return { bodyFields: { search_parameters: searchParams } };
|
|
174
|
-
}
|
|
175
|
-
function buildOpenRouterAugmentation(config) {
|
|
176
|
-
const plugin = { id: "web" };
|
|
177
|
-
if (config.maxResults) {
|
|
178
|
-
plugin.max_results = config.maxResults;
|
|
179
|
-
}
|
|
180
|
-
return { bodyFields: { plugins: [plugin] } };
|
|
181
|
-
}
|
|
182
|
-
function isXaiProvider(provider) {
|
|
183
|
-
const baseUrl = (provider.api_base_url || "").toLowerCase();
|
|
184
|
-
return baseUrl.includes("x.ai") || baseUrl.includes("xai.com");
|
|
185
|
-
}
|
|
186
|
-
function mapMaxResultsToContextSize(maxResults) {
|
|
187
|
-
if (maxResults <= 2) return "low";
|
|
188
|
-
if (maxResults <= 5) return "medium";
|
|
189
|
-
return "high";
|
|
190
|
-
}
|
|
191
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
-
0 && (module.exports = {
|
|
193
|
-
applyAugmentation,
|
|
194
|
-
buildNativeSearchAugmentation,
|
|
195
|
-
detectNativeSearch
|
|
196
|
-
});
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
exports.applyAugmentation = _chunkV5KPWNYXcjs.applyAugmentation; exports.buildNativeSearchAugmentation = _chunkV5KPWNYXcjs.buildNativeSearchAugmentation; exports.detectNativeSearch = _chunkV5KPWNYXcjs.detectNativeSearch;
|
|
@@ -1,165 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var NATIVE_SEARCH_MODEL_PATTERNS = {
|
|
9
|
-
openai: [/^gpt-4/, /^o[134]/, /^gpt-5/],
|
|
10
|
-
// Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
|
|
11
|
-
// Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
|
|
12
|
-
anthropic: [/^claude-/],
|
|
13
|
-
google: [/^gemini-(?:2|3|flash|pro)/],
|
|
14
|
-
xai: [/^grok/],
|
|
15
|
-
openrouter: []
|
|
16
|
-
// Detected via provider, not model pattern
|
|
17
|
-
};
|
|
18
|
-
var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
|
|
19
|
-
"gpt-4o-search-preview",
|
|
20
|
-
"gpt-4o-mini-search-preview",
|
|
21
|
-
"gpt-5-search-api"
|
|
22
|
-
];
|
|
23
|
-
var NATIVE_SEARCH_EXCLUDED_MODELS = [
|
|
24
|
-
"gpt-4.1-nano"
|
|
25
|
-
];
|
|
26
|
-
var API_FORMAT_PROVIDER_MAP = {
|
|
27
|
-
"openai-response": "openai",
|
|
28
|
-
anthropic: "anthropic",
|
|
29
|
-
google: "google"
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// src/completion/NativeSearchInjector.ts
|
|
33
|
-
function detectNativeSearch(modelId, apiFormat, provider, userExplicit) {
|
|
34
|
-
if (isOpenRouterProvider(provider)) {
|
|
35
|
-
return { supported: true, nativeProvider: "openrouter" };
|
|
36
|
-
}
|
|
37
|
-
if (isXaiProvider(provider)) {
|
|
38
|
-
return { supported: true, nativeProvider: "xai" };
|
|
39
|
-
}
|
|
40
|
-
if (apiFormat === "openai" && OPENAI_CHAT_COMPLETION_SEARCH_MODELS.some((m) => modelId.startsWith(m))) {
|
|
41
|
-
return { supported: true, nativeProvider: "openai" };
|
|
42
|
-
}
|
|
43
|
-
const formatProvider = API_FORMAT_PROVIDER_MAP[apiFormat];
|
|
44
|
-
if (formatProvider) {
|
|
45
|
-
const patterns = NATIVE_SEARCH_MODEL_PATTERNS[formatProvider];
|
|
46
|
-
if (patterns.some((re) => re.test(modelId))) {
|
|
47
|
-
if (!NATIVE_SEARCH_EXCLUDED_MODELS.some((m) => modelId.startsWith(m))) {
|
|
48
|
-
return { supported: true, nativeProvider: formatProvider };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (userExplicit && formatProvider) {
|
|
53
|
-
return { supported: true, nativeProvider: formatProvider };
|
|
54
|
-
}
|
|
55
|
-
return { supported: false, nativeProvider: null };
|
|
56
|
-
}
|
|
57
|
-
function buildNativeSearchAugmentation(nativeProvider, config, _apiFormat, modelId) {
|
|
58
|
-
if (!config.enabled) return null;
|
|
59
|
-
switch (nativeProvider) {
|
|
60
|
-
case "openai":
|
|
61
|
-
return buildOpenAIAugmentation(config, modelId);
|
|
62
|
-
case "anthropic":
|
|
63
|
-
return buildAnthropicAugmentation(config);
|
|
64
|
-
case "google":
|
|
65
|
-
return buildGoogleAugmentation(modelId);
|
|
66
|
-
case "xai":
|
|
67
|
-
return buildXaiAugmentation(config);
|
|
68
|
-
case "openrouter":
|
|
69
|
-
return buildOpenRouterAugmentation(config);
|
|
70
|
-
default:
|
|
71
|
-
return null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
function applyAugmentation(requestBody, augmentation) {
|
|
75
|
-
if (augmentation.additionalTools?.length) {
|
|
76
|
-
const existing = requestBody.tools ?? [];
|
|
77
|
-
requestBody.tools = [...existing, ...augmentation.additionalTools];
|
|
78
|
-
}
|
|
79
|
-
if (augmentation.bodyFields) {
|
|
80
|
-
Object.assign(requestBody, augmentation.bodyFields);
|
|
81
|
-
}
|
|
82
|
-
return requestBody;
|
|
83
|
-
}
|
|
84
|
-
function buildOpenAIAugmentation(config, modelId) {
|
|
85
|
-
const isChatCompletionSearch = OPENAI_CHAT_COMPLETION_SEARCH_MODELS.some(
|
|
86
|
-
(m) => modelId.startsWith(m)
|
|
87
|
-
);
|
|
88
|
-
if (isChatCompletionSearch) {
|
|
89
|
-
return {
|
|
90
|
-
bodyFields: {
|
|
91
|
-
web_search_options: {
|
|
92
|
-
search_context_size: config.maxResults ? mapMaxResultsToContextSize(config.maxResults) : "medium"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
additionalTools: [
|
|
99
|
-
{
|
|
100
|
-
type: "web_search",
|
|
101
|
-
web_search: {
|
|
102
|
-
search_context_size: config.maxResults ? mapMaxResultsToContextSize(config.maxResults) : "medium"
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
function buildAnthropicAugmentation(config) {
|
|
109
|
-
const toolDef = {
|
|
110
|
-
type: "web_search_20250305",
|
|
111
|
-
name: "web_search"
|
|
112
|
-
};
|
|
113
|
-
if (config.maxResults) {
|
|
114
|
-
toolDef.max_uses = config.maxResults;
|
|
115
|
-
}
|
|
116
|
-
if (config.blockedDomains?.length) {
|
|
117
|
-
toolDef.blocked_domains = config.blockedDomains;
|
|
118
|
-
}
|
|
119
|
-
return { additionalTools: [toolDef] };
|
|
120
|
-
}
|
|
121
|
-
function buildGoogleAugmentation(modelId) {
|
|
122
|
-
const isLegacy = /gemini-1[._]/.test(modelId);
|
|
123
|
-
if (isLegacy) {
|
|
124
|
-
return {
|
|
125
|
-
additionalTools: [
|
|
126
|
-
{ googleSearchRetrieval: {} }
|
|
127
|
-
]
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
additionalTools: [
|
|
132
|
-
{ google_search: {} }
|
|
133
|
-
]
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function buildXaiAugmentation(config) {
|
|
137
|
-
const searchParams = {
|
|
138
|
-
mode: config.searchMode ?? "auto",
|
|
139
|
-
return_citations: true,
|
|
140
|
-
max_search_results: config.maxResults ?? 5
|
|
141
|
-
};
|
|
142
|
-
if (config.sources?.length) {
|
|
143
|
-
searchParams.sources = config.sources;
|
|
144
|
-
}
|
|
145
|
-
return { bodyFields: { search_parameters: searchParams } };
|
|
146
|
-
}
|
|
147
|
-
function buildOpenRouterAugmentation(config) {
|
|
148
|
-
const plugin = { id: "web" };
|
|
149
|
-
if (config.maxResults) {
|
|
150
|
-
plugin.max_results = config.maxResults;
|
|
151
|
-
}
|
|
152
|
-
return { bodyFields: { plugins: [plugin] } };
|
|
153
|
-
}
|
|
154
|
-
function isXaiProvider(provider) {
|
|
155
|
-
const baseUrl = (provider.api_base_url || "").toLowerCase();
|
|
156
|
-
return baseUrl.includes("x.ai") || baseUrl.includes("xai.com");
|
|
157
|
-
}
|
|
158
|
-
function mapMaxResultsToContextSize(maxResults) {
|
|
159
|
-
if (maxResults <= 2) return "low";
|
|
160
|
-
if (maxResults <= 5) return "medium";
|
|
161
|
-
return "high";
|
|
162
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
applyAugmentation,
|
|
3
|
+
buildNativeSearchAugmentation,
|
|
4
|
+
detectNativeSearch
|
|
5
|
+
} from "../chunk-745DV5FL.js";
|
|
6
|
+
import "../chunk-E3WHL7CO.js";
|
|
7
|
+
import "../chunk-FMOBD2OQ.js";
|
|
163
8
|
export {
|
|
164
9
|
applyAugmentation,
|
|
165
10
|
buildNativeSearchAugmentation,
|
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
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);
|
|
19
|
-
|
|
20
|
-
// src/completion/ProviderSearchInjector.ts
|
|
21
|
-
var ProviderSearchInjector_exports = {};
|
|
22
|
-
__export(ProviderSearchInjector_exports, {
|
|
23
|
-
applyProviderSearchAugmentation: () => applyProviderSearchAugmentation,
|
|
24
|
-
buildProviderSearchAugmentation: () => buildProviderSearchAugmentation,
|
|
25
|
-
getSearchConfig: () => getSearchConfig
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(ProviderSearchInjector_exports);
|
|
28
|
-
var import_provider_presets = require("@omnicross/contracts/provider-presets");
|
|
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/ProviderSearchInjector.ts
|
|
2
|
+
var _providerpresets = require('@omnicross/contracts/provider-presets');
|
|
29
3
|
function getSearchConfig(provider) {
|
|
30
4
|
const presetId = provider.presetId || provider.id;
|
|
31
|
-
if (presetId in
|
|
32
|
-
return
|
|
5
|
+
if (presetId in _providerpresets.PROVIDER_SEARCH_CONFIGS) {
|
|
6
|
+
return _providerpresets.PROVIDER_SEARCH_CONFIGS[presetId];
|
|
33
7
|
}
|
|
34
8
|
return null;
|
|
35
9
|
}
|
|
@@ -43,7 +17,7 @@ function buildProviderSearchAugmentation(provider, modelId, hasOtherTools) {
|
|
|
43
17
|
case "model-param": {
|
|
44
18
|
const bodyFields = {};
|
|
45
19
|
if (config.paramName) {
|
|
46
|
-
bodyFields[config.paramName] = config.paramValue
|
|
20
|
+
bodyFields[config.paramName] = _nullishCoalesce(config.paramValue, () => ( true));
|
|
47
21
|
}
|
|
48
22
|
if (config.extraParams) {
|
|
49
23
|
Object.assign(bodyFields, config.extraParams);
|
|
@@ -73,15 +47,14 @@ function applyProviderSearchAugmentation(requestBody, augmentation) {
|
|
|
73
47
|
if (augmentation.bodyFields) {
|
|
74
48
|
Object.assign(requestBody, augmentation.bodyFields);
|
|
75
49
|
}
|
|
76
|
-
if (augmentation.additionalTools
|
|
77
|
-
const existing = requestBody.tools
|
|
50
|
+
if (_optionalChain([augmentation, 'access', _ => _.additionalTools, 'optionalAccess', _2 => _2.length])) {
|
|
51
|
+
const existing = _nullishCoalesce(requestBody.tools, () => ( []));
|
|
78
52
|
requestBody.tools = [...existing, ...augmentation.additionalTools];
|
|
79
53
|
}
|
|
80
54
|
return requestBody;
|
|
81
55
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
exports.applyProviderSearchAugmentation = applyProviderSearchAugmentation; exports.buildProviderSearchAugmentation = buildProviderSearchAugmentation; exports.getSearchConfig = getSearchConfig;
|
|
@@ -1,67 +1,14 @@
|
|
|
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});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Claude 3.x: claude-3-opus-*, claude-3-5-sonnet-*, etc.
|
|
33
|
-
// Claude 4.x: claude-sonnet-4-*, claude-opus-4-*, claude-haiku-4-*, etc.
|
|
34
|
-
anthropic: [/^claude-/],
|
|
35
|
-
google: [/^gemini-(?:2|3|flash|pro)/],
|
|
36
|
-
xai: [/^grok/],
|
|
37
|
-
openrouter: []
|
|
38
|
-
// Detected via provider, not model pattern
|
|
39
|
-
};
|
|
40
|
-
var OPENAI_CHAT_COMPLETION_SEARCH_MODELS = [
|
|
41
|
-
"gpt-4o-search-preview",
|
|
42
|
-
"gpt-4o-mini-search-preview",
|
|
43
|
-
"gpt-5-search-api"
|
|
44
|
-
];
|
|
45
|
-
var NATIVE_SEARCH_EXCLUDED_MODELS = [
|
|
46
|
-
"gpt-4.1-nano"
|
|
47
|
-
];
|
|
48
|
-
var NATIVE_SEARCH_TOOL_NAMES = [
|
|
49
|
-
"web_search",
|
|
50
|
-
"web_search_20250305",
|
|
51
|
-
"web_search_20260209",
|
|
52
|
-
"google_search",
|
|
53
|
-
"googleSearchRetrieval"
|
|
54
|
-
];
|
|
55
|
-
var API_FORMAT_PROVIDER_MAP = {
|
|
56
|
-
"openai-response": "openai",
|
|
57
|
-
anthropic: "anthropic",
|
|
58
|
-
google: "google"
|
|
59
|
-
};
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
API_FORMAT_PROVIDER_MAP,
|
|
63
|
-
NATIVE_SEARCH_EXCLUDED_MODELS,
|
|
64
|
-
NATIVE_SEARCH_MODEL_PATTERNS,
|
|
65
|
-
NATIVE_SEARCH_TOOL_NAMES,
|
|
66
|
-
OPENAI_CHAT_COMPLETION_SEARCH_MODELS
|
|
67
|
-
});
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkGMMT7RVNcjs = require('../chunk-GMMT7RVN.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.API_FORMAT_PROVIDER_MAP = _chunkGMMT7RVNcjs.API_FORMAT_PROVIDER_MAP; exports.NATIVE_SEARCH_EXCLUDED_MODELS = _chunkGMMT7RVNcjs.NATIVE_SEARCH_EXCLUDED_MODELS; exports.NATIVE_SEARCH_MODEL_PATTERNS = _chunkGMMT7RVNcjs.NATIVE_SEARCH_MODEL_PATTERNS; exports.NATIVE_SEARCH_TOOL_NAMES = _chunkGMMT7RVNcjs.NATIVE_SEARCH_TOOL_NAMES; exports.OPENAI_CHAT_COMPLETION_SEARCH_MODELS = _chunkGMMT7RVNcjs.OPENAI_CHAT_COMPLETION_SEARCH_MODELS;
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
API_FORMAT_PROVIDER_MAP,
|
|
3
|
+
NATIVE_SEARCH_EXCLUDED_MODELS,
|
|
4
|
+
NATIVE_SEARCH_MODEL_PATTERNS,
|
|
5
|
+
NATIVE_SEARCH_TOOL_NAMES,
|
|
6
|
+
OPENAI_CHAT_COMPLETION_SEARCH_MODELS
|
|
7
|
+
} from "../chunk-FMOBD2OQ.js";
|
|
32
8
|
export {
|
|
33
9
|
API_FORMAT_PROVIDER_MAP,
|
|
34
10
|
NATIVE_SEARCH_EXCLUDED_MODELS,
|
|
@@ -1,72 +1,16 @@
|
|
|
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});
|
|
19
2
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function buildOpenRouterHeaders(credentials, options = {}) {
|
|
35
|
-
const apiKey = credentials.apiKey?.trim();
|
|
36
|
-
if (!apiKey) {
|
|
37
|
-
throw new Error("OpenRouter API key is required");
|
|
38
|
-
}
|
|
39
|
-
const headers = {
|
|
40
|
-
Authorization: `Bearer ${apiKey}`,
|
|
41
|
-
"HTTP-Referer": OPENROUTER_HTTP_REFERER,
|
|
42
|
-
"X-Title": OPENROUTER_X_TITLE
|
|
43
|
-
};
|
|
44
|
-
if (options.contentType !== false) {
|
|
45
|
-
headers["Content-Type"] = options.contentType ?? "application/json";
|
|
46
|
-
}
|
|
47
|
-
if (options.extra) {
|
|
48
|
-
for (const [key, value] of Object.entries(options.extra)) {
|
|
49
|
-
headers[key] = value;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return headers;
|
|
53
|
-
}
|
|
54
|
-
function resolveOpenRouterBaseUrl(endpoint) {
|
|
55
|
-
const raw = endpoint?.trim();
|
|
56
|
-
const base = raw && raw.length > 0 ? raw : OPENROUTER_DEFAULT_BASE_URL;
|
|
57
|
-
return base.replace(/\/+$/, "");
|
|
58
|
-
}
|
|
59
|
-
function buildOpenRouterUrl(endpoint, path) {
|
|
60
|
-
const base = resolveOpenRouterBaseUrl(endpoint);
|
|
61
|
-
const cleanPath = path.startsWith("/") ? path : `/${path}`;
|
|
62
|
-
return `${base}${cleanPath}`;
|
|
63
|
-
}
|
|
64
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
-
0 && (module.exports = {
|
|
66
|
-
OPENROUTER_DEFAULT_BASE_URL,
|
|
67
|
-
OPENROUTER_HTTP_REFERER,
|
|
68
|
-
OPENROUTER_X_TITLE,
|
|
69
|
-
buildOpenRouterHeaders,
|
|
70
|
-
buildOpenRouterUrl,
|
|
71
|
-
resolveOpenRouterBaseUrl
|
|
72
|
-
});
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunk4NBS6KPVcjs = require('../chunk-4NBS6KPV.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.OPENROUTER_DEFAULT_BASE_URL = _chunk4NBS6KPVcjs.OPENROUTER_DEFAULT_BASE_URL; exports.OPENROUTER_HTTP_REFERER = _chunk4NBS6KPVcjs.OPENROUTER_HTTP_REFERER; exports.OPENROUTER_X_TITLE = _chunk4NBS6KPVcjs.OPENROUTER_X_TITLE; exports.buildOpenRouterHeaders = _chunk4NBS6KPVcjs.buildOpenRouterHeaders; exports.buildOpenRouterUrl = _chunk4NBS6KPVcjs.buildOpenRouterUrl; exports.resolveOpenRouterBaseUrl = _chunk4NBS6KPVcjs.resolveOpenRouterBaseUrl;
|