@omnicross/core 0.2.1 → 0.3.1
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/LICENSE +21 -21
- package/NOTICE +57 -57
- package/README.md +22 -22
- package/dist/auth/GeminiCodeAssistProjectResolver.cjs +3 -3
- package/dist/auth/GeminiCodeAssistProjectResolver.js +2 -2
- package/dist/{chunk-MPXOKQJP.cjs → chunk-2RCCLQYV.cjs} +1 -1
- package/dist/{chunk-Y4CRNHJO.js → chunk-4PFWFODB.js} +1 -1
- package/dist/{chunk-T6NWPIYZ.cjs → chunk-AKIOOFY3.cjs} +2 -1
- package/dist/{chunk-HL2YSPL7.cjs → chunk-BTBEJRGL.cjs} +140 -32
- package/dist/{chunk-NLUOTJWB.js → chunk-DXWFBBSK.js} +125 -17
- package/dist/{chunk-VSYQ6XYN.cjs → chunk-EY3S7NJ3.cjs} +498 -424
- package/dist/{chunk-HVBBDBS3.cjs → chunk-FHXDUHVE.cjs} +96 -9
- package/dist/{chunk-LFPQ2OVH.js → chunk-L7O2YQ5O.js} +1 -1
- package/dist/{chunk-VL5TUDTM.js → chunk-N5Q5PBV5.js} +6 -1
- package/dist/{chunk-MKF46GNZ.js → chunk-NJS2DZE6.js} +91 -4
- package/dist/{chunk-U47LQXPB.js → chunk-NRYLPGQB.js} +2 -1
- package/dist/{chunk-D4WNI6BR.cjs → chunk-PTU7SXM3.cjs} +2 -2
- package/dist/{chunk-4Z3ZLLC2.cjs → chunk-RS773ZL3.cjs} +13 -8
- package/dist/{chunk-LKDAN4D7.js → chunk-STENJNJU.js} +111 -37
- package/dist/{chunk-23S5OPIO.js → chunk-T2VIZQT4.js} +1 -1
- package/dist/{chunk-6QQG7YG3.cjs → chunk-T55Z77BR.cjs} +3 -3
- package/dist/{chunk-YNJNTCSQ.cjs → chunk-XGVPGH7V.cjs} +2 -2
- package/dist/{chunk-OPRS4IQZ.js → chunk-YVBHFVTF.js} +2 -2
- package/dist/completion/BuiltinToolExecutor.cjs +2 -2
- package/dist/completion/BuiltinToolExecutor.js +1 -1
- package/dist/completion/CompletionService.cjs +8 -8
- package/dist/completion/CompletionService.js +7 -7
- package/dist/completion.cjs +8 -8
- package/dist/completion.js +7 -7
- package/dist/index.cjs +8 -8
- package/dist/index.js +7 -7
- package/dist/outbound-api/routeResolver.cjs +2 -2
- package/dist/outbound-api/routeResolver.js +1 -1
- package/dist/outbound-api.cjs +8 -8
- package/dist/outbound-api.js +7 -7
- package/dist/pipeline/AccountAllowanceScheduling.cjs +3 -3
- package/dist/pipeline/AccountAllowanceScheduling.js +2 -2
- package/dist/pipeline/AccountAllowanceStore.cjs +6 -2
- package/dist/pipeline/AccountAllowanceStore.d.cts +41 -1
- package/dist/pipeline/AccountAllowanceStore.d.ts +41 -1
- package/dist/pipeline/AccountAllowanceStore.js +5 -1
- package/dist/pipeline/SubscriptionAuthSource.cjs +4 -4
- package/dist/pipeline/SubscriptionAuthSource.js +3 -3
- package/dist/pipeline/upstreamFetch.cjs +3 -3
- package/dist/pipeline/upstreamFetch.js +2 -2
- package/dist/provider-proxy/ProviderProxy.cjs +8 -8
- package/dist/provider-proxy/ProviderProxy.js +7 -7
- package/dist/provider-proxy/ingress/providerProxyShared.cjs +8 -8
- package/dist/provider-proxy/ingress/providerProxyShared.js +7 -7
- package/dist/provider-proxy.cjs +8 -8
- package/dist/provider-proxy.js +7 -7
- package/dist/runtime-5NCT3J3T.cjs +8 -0
- package/dist/{runtime-M5WXLD2R.js → runtime-JTHUWCBM.js} +2 -2
- package/dist/search/api.cjs +13 -8
- package/dist/search/api.d.cts +16 -1
- package/dist/search/api.d.ts +16 -1
- package/dist/search/api.js +10 -5
- package/dist/search/http.cjs +2 -2
- package/dist/search/http.d.cts +63 -9
- package/dist/search/http.d.ts +63 -9
- package/dist/search/http.js +1 -1
- package/dist/search.cjs +3 -3
- package/dist/search.js +2 -2
- package/package.json +3 -2
- package/dist/runtime-6QXNU526.cjs +0 -8
|
@@ -20,7 +20,11 @@ function searchHttpError(code, message, init) {
|
|
|
20
20
|
retryable: init.retryable,
|
|
21
21
|
cause: init.cause,
|
|
22
22
|
// transport/stage last so a caller-supplied `details` can never shadow them.
|
|
23
|
-
details: {
|
|
23
|
+
details: {
|
|
24
|
+
...init.details,
|
|
25
|
+
transport: init.transport ?? SEARCH_HTTP_TRANSPORT_ID,
|
|
26
|
+
stage: init.stage
|
|
27
|
+
}
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
function asSearchProviderError(value, providerId, fallbackStage) {
|
|
@@ -223,18 +227,25 @@ function bingTrustError(query, html) {
|
|
|
223
227
|
if (links.length === 0) return null;
|
|
224
228
|
const terms = meaningfulQueryTerms(query);
|
|
225
229
|
if (terms.length === 0) return null;
|
|
226
|
-
const titleSearchable =
|
|
230
|
+
const titleSearchable = separatorFree(
|
|
231
|
+
links.map((link) => link.textContent ?? "").join(" ").normalize("NFKC").toLocaleLowerCase()
|
|
232
|
+
);
|
|
227
233
|
if (!terms.some((term) => titleSearchable.includes(term))) {
|
|
228
234
|
return "Bing returned an untrusted search result page with zero query-term hits in result titles; refusing to return possible bot-decoy content.";
|
|
229
235
|
}
|
|
230
|
-
const searchable =
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
const searchable = separatorFree(
|
|
237
|
+
links.map((link) => {
|
|
238
|
+
const container = link.closest("li.b_algo, .b_algo");
|
|
239
|
+
return `${link.textContent ?? ""} ${link.getAttribute("href") ?? ""} ${container?.querySelector(".b_caption p, .b_algoSlug, p")?.textContent ?? ""}`;
|
|
240
|
+
}).join(" ").normalize("NFKC").toLocaleLowerCase()
|
|
241
|
+
);
|
|
234
242
|
const coveredTerms = terms.filter((term) => searchable.includes(term));
|
|
235
243
|
const requiredCoverage = terms.length === 1 ? 1 : 2;
|
|
236
244
|
return new Set(coveredTerms).size >= requiredCoverage ? null : "Bing returned an untrusted search result page; refusing to return possible bot-decoy content.";
|
|
237
245
|
}
|
|
246
|
+
function separatorFree(text) {
|
|
247
|
+
return text.replace(/[^\p{L}\p{N}\s]/gu, "");
|
|
248
|
+
}
|
|
238
249
|
function meaningfulQueryTerms(query) {
|
|
239
250
|
const terms = query.normalize("NFKC").toLocaleLowerCase().match(/[\p{L}\p{N}]{2,}/gu) ?? [];
|
|
240
251
|
const expanded = terms.flatMap((term) => {
|
|
@@ -285,8 +296,8 @@ function decoderFor(label) {
|
|
|
285
296
|
}
|
|
286
297
|
|
|
287
298
|
// src/search/http/headers.ts
|
|
288
|
-
var CHROME_VERSION = "
|
|
289
|
-
var CHROME_MAJOR = CHROME_VERSION.split(".")[0];
|
|
299
|
+
var CHROME_VERSION = process.versions.chrome ?? "152.0.7977.65";
|
|
300
|
+
var CHROME_MAJOR = CHROME_VERSION.split(".")[0] || "152";
|
|
290
301
|
var SEARCH_BROWSER_HEADERS = Object.freeze({
|
|
291
302
|
"User-Agent": `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${CHROME_VERSION} Safari/537.36`,
|
|
292
303
|
Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
|
|
@@ -306,13 +317,82 @@ function searchBrowserHeaders() {
|
|
|
306
317
|
return { ...SEARCH_BROWSER_HEADERS };
|
|
307
318
|
}
|
|
308
319
|
|
|
320
|
+
// src/search/http/impit.ts
|
|
321
|
+
var IMPIT_BROWSER = "chrome151";
|
|
322
|
+
var IMPERSONATED_HEADERS = [
|
|
323
|
+
"sec-ch-ua",
|
|
324
|
+
"sec-ch-ua-mobile",
|
|
325
|
+
"sec-ch-ua-platform",
|
|
326
|
+
"user-agent"
|
|
327
|
+
];
|
|
328
|
+
var TRANSPORT_KIND = /* @__PURE__ */ Symbol("searchFetchKind");
|
|
329
|
+
function tagFetchKind(error, kind) {
|
|
330
|
+
if (error instanceof Error) {
|
|
331
|
+
error[TRANSPORT_KIND] = kind;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
function fetchKindOf(error) {
|
|
335
|
+
return error?.[TRANSPORT_KIND];
|
|
336
|
+
}
|
|
337
|
+
var impitConstructorPromise;
|
|
338
|
+
var impitClients = /* @__PURE__ */ new Map();
|
|
339
|
+
function loadImpitConstructor() {
|
|
340
|
+
impitConstructorPromise ??= import("impit").then((module) => module.Impit).catch(() => void 0);
|
|
341
|
+
return impitConstructorPromise;
|
|
342
|
+
}
|
|
343
|
+
async function getImpitClient(proxyUrl, load = loadImpitConstructor) {
|
|
344
|
+
const ImpitClient = await load();
|
|
345
|
+
if (!ImpitClient) return void 0;
|
|
346
|
+
const key = proxyUrl ?? "<direct>";
|
|
347
|
+
const cached = impitClients.get(key);
|
|
348
|
+
if (cached) return cached;
|
|
349
|
+
const client = new ImpitClient({
|
|
350
|
+
browser: IMPIT_BROWSER,
|
|
351
|
+
followRedirects: false,
|
|
352
|
+
vanillaFallback: false,
|
|
353
|
+
...proxyUrl ? { proxyUrl } : {}
|
|
354
|
+
});
|
|
355
|
+
impitClients.set(key, client);
|
|
356
|
+
return client;
|
|
357
|
+
}
|
|
358
|
+
function withImpersonatedHeaders(init) {
|
|
359
|
+
const headers = new Headers(init.headers);
|
|
360
|
+
for (const name of IMPERSONATED_HEADERS) headers.delete(name);
|
|
361
|
+
return { ...init, headers };
|
|
362
|
+
}
|
|
363
|
+
function proxyConfigToUrl(config) {
|
|
364
|
+
if ("url" in config) {
|
|
365
|
+
try {
|
|
366
|
+
const protocol = new URL(config.url).protocol;
|
|
367
|
+
if (protocol === "http:" || protocol === "https:") return config.url;
|
|
368
|
+
if (protocol === "socks5:" || protocol === "socks5h:") {
|
|
369
|
+
return `socks5h://${config.url.slice(protocol.length + 2)}`;
|
|
370
|
+
}
|
|
371
|
+
return void 0;
|
|
372
|
+
} catch {
|
|
373
|
+
return void 0;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (!config.host || !Number.isFinite(config.port)) return void 0;
|
|
377
|
+
const auth = config.username ? `${encodeURIComponent(config.username)}:${encodeURIComponent(config.password ?? "")}@` : "";
|
|
378
|
+
if (config.type !== "http" && config.type !== "https" && config.type !== "socks5") {
|
|
379
|
+
return void 0;
|
|
380
|
+
}
|
|
381
|
+
const scheme = config.type === "socks5" ? "socks5h" : config.type;
|
|
382
|
+
return `${scheme}://${auth}${config.host}:${config.port}`;
|
|
383
|
+
}
|
|
384
|
+
function impitProxyUrlFrom(resolve, url) {
|
|
385
|
+
const config = resolve?.(url);
|
|
386
|
+
return config ? proxyConfigToUrl(config) : void 0;
|
|
387
|
+
}
|
|
388
|
+
|
|
309
389
|
// src/search/http/transport.ts
|
|
310
390
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
311
391
|
var DEFAULT_MAX_RESPONSE_BYTES = 5 * 1024 * 1024;
|
|
312
392
|
var MAX_REDIRECTS = 5;
|
|
313
393
|
var REFUSED_STATUSES = /* @__PURE__ */ new Set([401, 403, 407, 429]);
|
|
314
394
|
function createSearchHttpTransport(options = {}) {
|
|
315
|
-
const fetchImpl = options.fetch ??
|
|
395
|
+
const fetchImpl = options.fetch ?? createProductionSearchFetch(options);
|
|
316
396
|
const maxRedirects = options.maxRedirects ?? MAX_REDIRECTS;
|
|
317
397
|
const egressPolicy = options.egressPolicy;
|
|
318
398
|
return async (url, request) => {
|
|
@@ -365,6 +445,7 @@ function createSearchHttpTransport(options = {}) {
|
|
|
365
445
|
providerId: context.providerId,
|
|
366
446
|
retryable: true,
|
|
367
447
|
cause: error,
|
|
448
|
+
transport: fetchKindOf(error),
|
|
368
449
|
details: { host: context.host }
|
|
369
450
|
});
|
|
370
451
|
}
|
|
@@ -376,17 +457,43 @@ function createSearchHttpTransport(options = {}) {
|
|
|
376
457
|
};
|
|
377
458
|
}
|
|
378
459
|
var defaultSearchHttpTransport = createSearchHttpTransport();
|
|
379
|
-
function
|
|
460
|
+
function createProductionSearchFetch(options) {
|
|
380
461
|
return async (url, init) => {
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
462
|
+
const client = await getImpitClient(
|
|
463
|
+
impitProxyUrlFrom(options.resolveProxyConfig, url),
|
|
464
|
+
options.loadImpit
|
|
465
|
+
).catch(() => void 0);
|
|
466
|
+
if (client) {
|
|
467
|
+
try {
|
|
468
|
+
return await client.fetch(
|
|
469
|
+
url,
|
|
470
|
+
withImpersonatedHeaders(init)
|
|
471
|
+
);
|
|
472
|
+
} catch (error) {
|
|
473
|
+
tagFetchKind(error, "impit");
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
try {
|
|
478
|
+
const dispatcher = selectHttpDispatcher(options.env, url, options.resolveProxyDispatcher);
|
|
479
|
+
const requestInit = dispatcher ? { ...init, dispatcher } : init;
|
|
480
|
+
return await undiciFetch(
|
|
481
|
+
url,
|
|
482
|
+
requestInit
|
|
483
|
+
);
|
|
484
|
+
} catch (error) {
|
|
485
|
+
tagFetchKind(error, "undici");
|
|
486
|
+
throw error;
|
|
487
|
+
}
|
|
388
488
|
};
|
|
389
489
|
}
|
|
490
|
+
function selectHttpDispatcher(env, url, resolveProxyDispatcher) {
|
|
491
|
+
return resolveProxyDispatcher?.(url) ?? envProxyDispatcher(env);
|
|
492
|
+
}
|
|
493
|
+
function envProxyDispatcher(env) {
|
|
494
|
+
const proxy = resolveSearchProxySettings(env);
|
|
495
|
+
return proxy ? getSearchProxyDispatcher(proxy) : void 0;
|
|
496
|
+
}
|
|
390
497
|
async function fetchWithRedirectLimit(fetchImpl, url, signal, maxRedirects, context, egressPolicy) {
|
|
391
498
|
let currentUrl = url;
|
|
392
499
|
assertEgressAllowed(currentUrl, egressPolicy, "connect", context);
|
|
@@ -406,6 +513,7 @@ async function fetchWithRedirectLimit(fetchImpl, url, signal, maxRedirects, cont
|
|
|
406
513
|
providerId: context.providerId,
|
|
407
514
|
retryable: true,
|
|
408
515
|
cause: error,
|
|
516
|
+
transport: fetchKindOf(error),
|
|
409
517
|
details: { host: context.host }
|
|
410
518
|
});
|
|
411
519
|
}
|