unbrowse 10.1.2 → 10.1.3
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/package.json +1 -1
- package/runtime/cli.js +104 -4
- package/runtime/mcp.js +130 -6
package/package.json
CHANGED
package/runtime/cli.js
CHANGED
|
@@ -64268,6 +64268,52 @@ function cardinalityMatches(intent, subject, opts) {
|
|
|
64268
64268
|
function resolutionCardinalityMatches(intent, data) {
|
|
64269
64269
|
return cardinalityMatches(intent, { kind: "value", value: data });
|
|
64270
64270
|
}
|
|
64271
|
+
function registrableHostOf(input) {
|
|
64272
|
+
if (!input)
|
|
64273
|
+
return null;
|
|
64274
|
+
const host = (() => {
|
|
64275
|
+
try {
|
|
64276
|
+
return new URL(input).hostname;
|
|
64277
|
+
} catch {}
|
|
64278
|
+
try {
|
|
64279
|
+
return new URL(`https://${input}`).hostname;
|
|
64280
|
+
} catch {
|
|
64281
|
+
return null;
|
|
64282
|
+
}
|
|
64283
|
+
})();
|
|
64284
|
+
if (!host)
|
|
64285
|
+
return null;
|
|
64286
|
+
return host.replace(/^www\./, "").split(".").slice(-2).join(".") || null;
|
|
64287
|
+
}
|
|
64288
|
+
function collectRecordHosts(data) {
|
|
64289
|
+
const out = [];
|
|
64290
|
+
const push = (rec) => {
|
|
64291
|
+
if (!rec || typeof rec !== "object")
|
|
64292
|
+
return;
|
|
64293
|
+
const r = rec;
|
|
64294
|
+
for (const k of ["url", "link", "href", "source_url"]) {
|
|
64295
|
+
const v = r[k];
|
|
64296
|
+
const h = typeof v === "string" ? registrableHostOf(v) : null;
|
|
64297
|
+
if (h)
|
|
64298
|
+
out.push(h);
|
|
64299
|
+
}
|
|
64300
|
+
};
|
|
64301
|
+
if (Array.isArray(data))
|
|
64302
|
+
for (const rec of data.slice(0, 20))
|
|
64303
|
+
push(rec);
|
|
64304
|
+
else
|
|
64305
|
+
push(data);
|
|
64306
|
+
return out;
|
|
64307
|
+
}
|
|
64308
|
+
function resolutionHostMatches(url, data) {
|
|
64309
|
+
const reqHost = registrableHostOf(url);
|
|
64310
|
+
if (!reqHost)
|
|
64311
|
+
return true;
|
|
64312
|
+
const hosts = collectRecordHosts(data);
|
|
64313
|
+
if (hosts.length === 0)
|
|
64314
|
+
return true;
|
|
64315
|
+
return hosts.some((h) => h === reqHost);
|
|
64316
|
+
}
|
|
64271
64317
|
var LIST_INTENT_RE, ITEM_SCHEMA_TYPES, COLLECTION_KEYS;
|
|
64272
64318
|
var init_cardinality = __esm(() => {
|
|
64273
64319
|
LIST_INTENT_RE = /\b(search|find|lookup|browse|discover|list(?:ings?)?|feed|catalog(?:ue)?)\b/i;
|
|
@@ -64800,7 +64846,7 @@ var init_telemetry = __esm(() => {
|
|
|
64800
64846
|
});
|
|
64801
64847
|
|
|
64802
64848
|
// .tmp-runtime-src/build-info.generated.ts
|
|
64803
|
-
var BUILD_RELEASE_VERSION = "10.1.
|
|
64849
|
+
var BUILD_RELEASE_VERSION = "10.1.3", BUILD_GIT_SHA = "de11df6cf838", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMS4zIiwiZ2l0X3NoYSI6ImRlMTFkZjZjZjgzOCIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAZGUxMWRmNmNmODM4IiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yM1QwOTowMzoyNC4wODlaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "tQDAYXIj-Q4C-i2E4CTsKtHaEiTFy7uzrDQDxDjqO6o", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
|
|
64804
64850
|
|
|
64805
64851
|
// .tmp-runtime-src/version.ts
|
|
64806
64852
|
import { createHash as createHash8 } from "crypto";
|
|
@@ -195657,7 +195703,9 @@ function shouldAutoWalk(requestedUrl, topUrl, topScore, minScore = 0.8) {
|
|
|
195657
195703
|
return false;
|
|
195658
195704
|
const reqReg = registrableHost(requestedUrl);
|
|
195659
195705
|
const topReg = registrableHost(topUrl);
|
|
195660
|
-
|
|
195706
|
+
if (reqReg)
|
|
195707
|
+
return reqReg === topReg;
|
|
195708
|
+
return (topScore ?? 0) >= minScore;
|
|
195661
195709
|
}
|
|
195662
195710
|
function pickWalkTarget(requestedUrl, ranked, minScore = 0.8) {
|
|
195663
195711
|
const eligible = ranked.filter((c) => c?.url && shouldAutoWalk(requestedUrl, c.url, c.score, minScore));
|
|
@@ -196114,6 +196162,17 @@ function endpointMatchesContextOrigin(endpoint, contextUrl) {
|
|
|
196114
196162
|
return true;
|
|
196115
196163
|
}
|
|
196116
196164
|
}
|
|
196165
|
+
function cachedSkillHostMatchesContext(skillDomain, contextUrl) {
|
|
196166
|
+
if (!contextUrl)
|
|
196167
|
+
return true;
|
|
196168
|
+
const ctxReg = registrableHost(contextUrl);
|
|
196169
|
+
if (!ctxReg)
|
|
196170
|
+
return true;
|
|
196171
|
+
const skillReg = registrableHost(skillDomain) ?? registrableHost(`https://${skillDomain ?? ""}`);
|
|
196172
|
+
if (!skillReg)
|
|
196173
|
+
return true;
|
|
196174
|
+
return skillReg === ctxReg;
|
|
196175
|
+
}
|
|
196117
196176
|
function endpointTargetsMismatchedLocalReplayHost(endpoint, contextUrl) {
|
|
196118
196177
|
if (!contextUrl)
|
|
196119
196178
|
return false;
|
|
@@ -199091,7 +199150,7 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
199091
199150
|
if (!forceCapture && !agentChoseEndpoint) {
|
|
199092
199151
|
const cachedResult = routeResultCache.get(cacheKey2);
|
|
199093
199152
|
if (cachedResult) {
|
|
199094
|
-
if (!shouldReuseRouteResultSnapshot(cachedResult, queryIntent, context?.url)) {
|
|
199153
|
+
if (!cachedSkillHostMatchesContext(cachedResult.skill.domain, context?.url) || !shouldReuseRouteResultSnapshot(cachedResult, queryIntent, context?.url)) {
|
|
199095
199154
|
routeResultCache.delete(cacheKey2);
|
|
199096
199155
|
} else {
|
|
199097
199156
|
timing.cache_hit = true;
|
|
@@ -199128,6 +199187,11 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
199128
199187
|
persistRouteCache();
|
|
199129
199188
|
continue;
|
|
199130
199189
|
}
|
|
199190
|
+
if (!cachedSkillHostMatchesContext(cached5.domain, context?.url)) {
|
|
199191
|
+
skillRouteCache.delete(scopedKey);
|
|
199192
|
+
persistRouteCache();
|
|
199193
|
+
continue;
|
|
199194
|
+
}
|
|
199131
199195
|
const skill = readSkillSnapshot(cached5.localSkillPath) ?? await getSkillWithTimeout(cached5.skillId, clientScope);
|
|
199132
199196
|
if (!skill || !isCachedSkillRelevantForIntent(skill, queryIntent, context?.url)) {
|
|
199133
199197
|
skillRouteCache.delete(scopedKey);
|
|
@@ -199230,6 +199294,11 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
199230
199294
|
persistRouteCache();
|
|
199231
199295
|
continue;
|
|
199232
199296
|
}
|
|
199297
|
+
if (!cachedSkillHostMatchesContext(cached6.domain, context?.url)) {
|
|
199298
|
+
skillRouteCache.delete(scopedKey);
|
|
199299
|
+
persistRouteCache();
|
|
199300
|
+
continue;
|
|
199301
|
+
}
|
|
199233
199302
|
const skill = readSkillSnapshot(cached6.localSkillPath) ?? await getSkillWithTimeout(cached6.skillId, clientScope);
|
|
199234
199303
|
if (!skill)
|
|
199235
199304
|
continue;
|
|
@@ -293679,6 +293748,7 @@ async function handler14(parsed, opts) {
|
|
|
293679
293748
|
const wsEndpoint = typeof parsed.flags.ws === "string" ? parsed.flags.ws : undefined;
|
|
293680
293749
|
const conn = wsEndpoint ? await attach(wsEndpoint) : await spawnChrome({ headless: true, perContextProxy: false, persist: true });
|
|
293681
293750
|
const target = await createTarget(conn, url, {});
|
|
293751
|
+
let cookiesInjected = 0;
|
|
293682
293752
|
try {
|
|
293683
293753
|
const { shouldImportBrowserCookies: shouldImportBrowserCookies2 } = await init_auth().then(() => exports_auth);
|
|
293684
293754
|
if (shouldImportBrowserCookies2()) {
|
|
@@ -293709,6 +293779,7 @@ async function handler14(parsed, opts) {
|
|
|
293709
293779
|
});
|
|
293710
293780
|
await conn.call("Network.setCookies", { cookies: cdpCookies }, target.sessionId);
|
|
293711
293781
|
await conn.call("Page.navigate", { url }, target.sessionId);
|
|
293782
|
+
cookiesInjected = cdpCookies.length;
|
|
293712
293783
|
process.stderr.write(`[auth] act go: injected ${cdpCookies.length} cookie(s) for ${host}, re-navigated authenticated
|
|
293713
293784
|
`);
|
|
293714
293785
|
} else {
|
|
@@ -293718,6 +293789,24 @@ async function handler14(parsed, opts) {
|
|
|
293718
293789
|
}
|
|
293719
293790
|
} catch (cookieErr) {
|
|
293720
293791
|
process.stderr.write(`[auth] act go: cookie injection skipped: ${cookieErr instanceof Error ? cookieErr.message : String(cookieErr)}
|
|
293792
|
+
`);
|
|
293793
|
+
}
|
|
293794
|
+
let pageText = null;
|
|
293795
|
+
try {
|
|
293796
|
+
await conn.call("Runtime.enable", {}, target.sessionId);
|
|
293797
|
+
const deadline = Date.now() + 6000;
|
|
293798
|
+
while (Date.now() < deadline) {
|
|
293799
|
+
const rs = await conn.call("Runtime.evaluate", { expression: "document.readyState", returnByValue: true }, target.sessionId);
|
|
293800
|
+
if (rs?.result?.value === "complete")
|
|
293801
|
+
break;
|
|
293802
|
+
await new Promise((res) => setTimeout(res, 200));
|
|
293803
|
+
}
|
|
293804
|
+
const body = await conn.call("Runtime.evaluate", { expression: "document.body ? document.body.innerText : ''", returnByValue: true }, target.sessionId);
|
|
293805
|
+
const v = body?.result?.value;
|
|
293806
|
+
if (typeof v === "string" && v.length > 0)
|
|
293807
|
+
pageText = v.slice(0, 200000);
|
|
293808
|
+
} catch (readErr) {
|
|
293809
|
+
process.stderr.write(`[page] act go: body read skipped: ${readErr instanceof Error ? readErr.message : String(readErr)}
|
|
293721
293810
|
`);
|
|
293722
293811
|
}
|
|
293723
293812
|
let captcha;
|
|
@@ -293750,6 +293839,8 @@ async function handler14(parsed, opts) {
|
|
|
293750
293839
|
context_id: "",
|
|
293751
293840
|
chrome_ws_url: conn.endpoint,
|
|
293752
293841
|
url,
|
|
293842
|
+
cookies_injected: cookiesInjected,
|
|
293843
|
+
...pageText !== null ? { page: { text: pageText } } : {},
|
|
293753
293844
|
...captcha ? { captcha } : {},
|
|
293754
293845
|
audit: {
|
|
293755
293846
|
ok: navAudit.ok,
|
|
@@ -303939,7 +304030,8 @@ async function cmdResolve(flags) {
|
|
|
303939
304030
|
}
|
|
303940
304031
|
if (resolveCacheSafe(flags)) {
|
|
303941
304032
|
const cachedHit = peekResolution(resolveCacheKeyFor(flags, intent), resolveCacheTtlMs());
|
|
303942
|
-
|
|
304033
|
+
const cachedData = cachedHit ? cachedHit.result ?? cachedHit.data : undefined;
|
|
304034
|
+
if (cachedHit && resolutionCardinalityMatches(intent, cachedData) && resolutionHostMatches(typeof flags.url === "string" ? flags.url : undefined, cachedData)) {
|
|
303943
304035
|
const replay = markResolveCacheReplay(cachedHit);
|
|
303944
304036
|
const hostType2 = detectTelemetryHostType2();
|
|
303945
304037
|
if (process.env.UNBROWSE_LANDING_TOKEN || process.env.UNBROWSE_ATTRIBUTION_B64) {
|
|
@@ -304236,6 +304328,14 @@ function parseCmdHoleIntentArgs(args, flags, verb) {
|
|
|
304236
304328
|
return { error: `usage: unbrowse ${verb} <url> "task"` };
|
|
304237
304329
|
return { url: args[0], intent: intent2 };
|
|
304238
304330
|
}
|
|
304331
|
+
const urlArgs = args.filter(looksLikeUrl);
|
|
304332
|
+
if (urlArgs.length === 1) {
|
|
304333
|
+
const rest = args.filter((a) => a !== urlArgs[0]);
|
|
304334
|
+
const intent2 = flagIntent ?? (rest.length > 0 ? rest.join(" ") : undefined);
|
|
304335
|
+
if (!intent2)
|
|
304336
|
+
return { error: `usage: unbrowse ${verb} <url> "task"` };
|
|
304337
|
+
return { url: urlArgs[0], intent: intent2 };
|
|
304338
|
+
}
|
|
304239
304339
|
const intent = flagIntent ?? (args.length > 0 ? args.join(" ") : undefined);
|
|
304240
304340
|
if (!intent)
|
|
304241
304341
|
return { error: `usage: unbrowse ${verb} "task" [--url <url>]` };
|
package/runtime/mcp.js
CHANGED
|
@@ -101443,7 +101443,7 @@ async function mergedAuthHeaders(key, signer) {
|
|
|
101443
101443
|
var AUTH_DOMAIN = "unbrowse-auth:v1";
|
|
101444
101444
|
|
|
101445
101445
|
// .tmp-runtime-src/build-info.generated.ts
|
|
101446
|
-
var BUILD_RELEASE_VERSION = "10.1.
|
|
101446
|
+
var BUILD_RELEASE_VERSION = "10.1.3", BUILD_GIT_SHA = "de11df6cf838", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMS4zIiwiZ2l0X3NoYSI6ImRlMTFkZjZjZjgzOCIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAZGUxMWRmNmNmODM4IiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yM1QwOTowMzoyNC4wODlaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "tQDAYXIj-Q4C-i2E4CTsKtHaEiTFy7uzrDQDxDjqO6o", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
|
|
101447
101447
|
|
|
101448
101448
|
// .tmp-runtime-src/version.ts
|
|
101449
101449
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -104929,6 +104929,52 @@ function cardinalityMatches(intent, subject, opts) {
|
|
|
104929
104929
|
function resolutionCardinalityMatches(intent, data) {
|
|
104930
104930
|
return cardinalityMatches(intent, { kind: "value", value: data });
|
|
104931
104931
|
}
|
|
104932
|
+
function registrableHostOf(input) {
|
|
104933
|
+
if (!input)
|
|
104934
|
+
return null;
|
|
104935
|
+
const host = (() => {
|
|
104936
|
+
try {
|
|
104937
|
+
return new URL(input).hostname;
|
|
104938
|
+
} catch {}
|
|
104939
|
+
try {
|
|
104940
|
+
return new URL(`https://${input}`).hostname;
|
|
104941
|
+
} catch {
|
|
104942
|
+
return null;
|
|
104943
|
+
}
|
|
104944
|
+
})();
|
|
104945
|
+
if (!host)
|
|
104946
|
+
return null;
|
|
104947
|
+
return host.replace(/^www\./, "").split(".").slice(-2).join(".") || null;
|
|
104948
|
+
}
|
|
104949
|
+
function collectRecordHosts(data) {
|
|
104950
|
+
const out = [];
|
|
104951
|
+
const push = (rec) => {
|
|
104952
|
+
if (!rec || typeof rec !== "object")
|
|
104953
|
+
return;
|
|
104954
|
+
const r = rec;
|
|
104955
|
+
for (const k of ["url", "link", "href", "source_url"]) {
|
|
104956
|
+
const v = r[k];
|
|
104957
|
+
const h = typeof v === "string" ? registrableHostOf(v) : null;
|
|
104958
|
+
if (h)
|
|
104959
|
+
out.push(h);
|
|
104960
|
+
}
|
|
104961
|
+
};
|
|
104962
|
+
if (Array.isArray(data))
|
|
104963
|
+
for (const rec of data.slice(0, 20))
|
|
104964
|
+
push(rec);
|
|
104965
|
+
else
|
|
104966
|
+
push(data);
|
|
104967
|
+
return out;
|
|
104968
|
+
}
|
|
104969
|
+
function resolutionHostMatches(url, data) {
|
|
104970
|
+
const reqHost = registrableHostOf(url);
|
|
104971
|
+
if (!reqHost)
|
|
104972
|
+
return true;
|
|
104973
|
+
const hosts = collectRecordHosts(data);
|
|
104974
|
+
if (hosts.length === 0)
|
|
104975
|
+
return true;
|
|
104976
|
+
return hosts.some((h) => h === reqHost);
|
|
104977
|
+
}
|
|
104932
104978
|
var LIST_INTENT_RE, ITEM_SCHEMA_TYPES, COLLECTION_KEYS;
|
|
104933
104979
|
var init_cardinality = __esm(() => {
|
|
104934
104980
|
LIST_INTENT_RE = /\b(search|find|lookup|browse|discover|list(?:ings?)?|feed|catalog(?:ue)?)\b/i;
|
|
@@ -192838,7 +192884,9 @@ function shouldAutoWalk(requestedUrl, topUrl, topScore, minScore = 0.8) {
|
|
|
192838
192884
|
return false;
|
|
192839
192885
|
const reqReg = registrableHost(requestedUrl);
|
|
192840
192886
|
const topReg = registrableHost(topUrl);
|
|
192841
|
-
|
|
192887
|
+
if (reqReg)
|
|
192888
|
+
return reqReg === topReg;
|
|
192889
|
+
return (topScore ?? 0) >= minScore;
|
|
192842
192890
|
}
|
|
192843
192891
|
function pickWalkTarget(requestedUrl, ranked, minScore = 0.8) {
|
|
192844
192892
|
const eligible = ranked.filter((c) => c?.url && shouldAutoWalk(requestedUrl, c.url, c.score, minScore));
|
|
@@ -193295,6 +193343,17 @@ function endpointMatchesContextOrigin(endpoint, contextUrl) {
|
|
|
193295
193343
|
return true;
|
|
193296
193344
|
}
|
|
193297
193345
|
}
|
|
193346
|
+
function cachedSkillHostMatchesContext(skillDomain, contextUrl) {
|
|
193347
|
+
if (!contextUrl)
|
|
193348
|
+
return true;
|
|
193349
|
+
const ctxReg = registrableHost(contextUrl);
|
|
193350
|
+
if (!ctxReg)
|
|
193351
|
+
return true;
|
|
193352
|
+
const skillReg = registrableHost(skillDomain) ?? registrableHost(`https://${skillDomain ?? ""}`);
|
|
193353
|
+
if (!skillReg)
|
|
193354
|
+
return true;
|
|
193355
|
+
return skillReg === ctxReg;
|
|
193356
|
+
}
|
|
193298
193357
|
function endpointTargetsMismatchedLocalReplayHost(endpoint, contextUrl) {
|
|
193299
193358
|
if (!contextUrl)
|
|
193300
193359
|
return false;
|
|
@@ -196272,7 +196331,7 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
196272
196331
|
if (!forceCapture && !agentChoseEndpoint) {
|
|
196273
196332
|
const cachedResult = routeResultCache.get(cacheKey2);
|
|
196274
196333
|
if (cachedResult) {
|
|
196275
|
-
if (!shouldReuseRouteResultSnapshot(cachedResult, queryIntent, context?.url)) {
|
|
196334
|
+
if (!cachedSkillHostMatchesContext(cachedResult.skill.domain, context?.url) || !shouldReuseRouteResultSnapshot(cachedResult, queryIntent, context?.url)) {
|
|
196276
196335
|
routeResultCache.delete(cacheKey2);
|
|
196277
196336
|
} else {
|
|
196278
196337
|
timing.cache_hit = true;
|
|
@@ -196309,6 +196368,11 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
196309
196368
|
persistRouteCache();
|
|
196310
196369
|
continue;
|
|
196311
196370
|
}
|
|
196371
|
+
if (!cachedSkillHostMatchesContext(cached5.domain, context?.url)) {
|
|
196372
|
+
skillRouteCache.delete(scopedKey);
|
|
196373
|
+
persistRouteCache();
|
|
196374
|
+
continue;
|
|
196375
|
+
}
|
|
196312
196376
|
const skill = readSkillSnapshot(cached5.localSkillPath) ?? await getSkillWithTimeout(cached5.skillId, clientScope);
|
|
196313
196377
|
if (!skill || !isCachedSkillRelevantForIntent(skill, queryIntent, context?.url)) {
|
|
196314
196378
|
skillRouteCache.delete(scopedKey);
|
|
@@ -196411,6 +196475,11 @@ async function resolveAndExecute(intent, params = {}, context, projection, optio
|
|
|
196411
196475
|
persistRouteCache();
|
|
196412
196476
|
continue;
|
|
196413
196477
|
}
|
|
196478
|
+
if (!cachedSkillHostMatchesContext(cached6.domain, context?.url)) {
|
|
196479
|
+
skillRouteCache.delete(scopedKey);
|
|
196480
|
+
persistRouteCache();
|
|
196481
|
+
continue;
|
|
196482
|
+
}
|
|
196414
196483
|
const skill = readSkillSnapshot(cached6.localSkillPath) ?? await getSkillWithTimeout(cached6.skillId, clientScope);
|
|
196415
196484
|
if (!skill)
|
|
196416
196485
|
continue;
|
|
@@ -285751,6 +285820,7 @@ async function handler14(parsed, opts) {
|
|
|
285751
285820
|
const wsEndpoint = typeof parsed.flags.ws === "string" ? parsed.flags.ws : undefined;
|
|
285752
285821
|
const conn = wsEndpoint ? await attach(wsEndpoint) : await spawnChrome({ headless: true, perContextProxy: false, persist: true });
|
|
285753
285822
|
const target = await createTarget(conn, url, {});
|
|
285823
|
+
let cookiesInjected = 0;
|
|
285754
285824
|
try {
|
|
285755
285825
|
const { shouldImportBrowserCookies: shouldImportBrowserCookies2 } = await init_auth().then(() => exports_auth);
|
|
285756
285826
|
if (shouldImportBrowserCookies2()) {
|
|
@@ -285781,6 +285851,7 @@ async function handler14(parsed, opts) {
|
|
|
285781
285851
|
});
|
|
285782
285852
|
await conn.call("Network.setCookies", { cookies: cdpCookies }, target.sessionId);
|
|
285783
285853
|
await conn.call("Page.navigate", { url }, target.sessionId);
|
|
285854
|
+
cookiesInjected = cdpCookies.length;
|
|
285784
285855
|
process.stderr.write(`[auth] act go: injected ${cdpCookies.length} cookie(s) for ${host}, re-navigated authenticated
|
|
285785
285856
|
`);
|
|
285786
285857
|
} else {
|
|
@@ -285790,6 +285861,24 @@ async function handler14(parsed, opts) {
|
|
|
285790
285861
|
}
|
|
285791
285862
|
} catch (cookieErr) {
|
|
285792
285863
|
process.stderr.write(`[auth] act go: cookie injection skipped: ${cookieErr instanceof Error ? cookieErr.message : String(cookieErr)}
|
|
285864
|
+
`);
|
|
285865
|
+
}
|
|
285866
|
+
let pageText = null;
|
|
285867
|
+
try {
|
|
285868
|
+
await conn.call("Runtime.enable", {}, target.sessionId);
|
|
285869
|
+
const deadline = Date.now() + 6000;
|
|
285870
|
+
while (Date.now() < deadline) {
|
|
285871
|
+
const rs = await conn.call("Runtime.evaluate", { expression: "document.readyState", returnByValue: true }, target.sessionId);
|
|
285872
|
+
if (rs?.result?.value === "complete")
|
|
285873
|
+
break;
|
|
285874
|
+
await new Promise((res) => setTimeout(res, 200));
|
|
285875
|
+
}
|
|
285876
|
+
const body = await conn.call("Runtime.evaluate", { expression: "document.body ? document.body.innerText : ''", returnByValue: true }, target.sessionId);
|
|
285877
|
+
const v = body?.result?.value;
|
|
285878
|
+
if (typeof v === "string" && v.length > 0)
|
|
285879
|
+
pageText = v.slice(0, 200000);
|
|
285880
|
+
} catch (readErr) {
|
|
285881
|
+
process.stderr.write(`[page] act go: body read skipped: ${readErr instanceof Error ? readErr.message : String(readErr)}
|
|
285793
285882
|
`);
|
|
285794
285883
|
}
|
|
285795
285884
|
let captcha;
|
|
@@ -285822,6 +285911,8 @@ async function handler14(parsed, opts) {
|
|
|
285822
285911
|
context_id: "",
|
|
285823
285912
|
chrome_ws_url: conn.endpoint,
|
|
285824
285913
|
url,
|
|
285914
|
+
cookies_injected: cookiesInjected,
|
|
285915
|
+
...pageText !== null ? { page: { text: pageText } } : {},
|
|
285825
285916
|
...captcha ? { captcha } : {},
|
|
285826
285917
|
audit: {
|
|
285827
285918
|
ok: navAudit.ok,
|
|
@@ -296188,7 +296279,8 @@ async function cmdResolve(flags) {
|
|
|
296188
296279
|
}
|
|
296189
296280
|
if (resolveCacheSafe(flags)) {
|
|
296190
296281
|
const cachedHit = peekResolution(resolveCacheKeyFor(flags, intent), resolveCacheTtlMs());
|
|
296191
|
-
|
|
296282
|
+
const cachedData = cachedHit ? cachedHit.result ?? cachedHit.data : undefined;
|
|
296283
|
+
if (cachedHit && resolutionCardinalityMatches(intent, cachedData) && resolutionHostMatches(typeof flags.url === "string" ? flags.url : undefined, cachedData)) {
|
|
296192
296284
|
const replay = markResolveCacheReplay(cachedHit);
|
|
296193
296285
|
const hostType2 = detectTelemetryHostType();
|
|
296194
296286
|
if (process.env.UNBROWSE_LANDING_TOKEN || process.env.UNBROWSE_ATTRIBUTION_B64) {
|
|
@@ -296474,6 +296566,14 @@ function parseCmdHoleIntentArgs(args, flags, verb) {
|
|
|
296474
296566
|
return { error: `usage: unbrowse ${verb} <url> "task"` };
|
|
296475
296567
|
return { url: args[0], intent: intent2 };
|
|
296476
296568
|
}
|
|
296569
|
+
const urlArgs = args.filter(looksLikeUrl);
|
|
296570
|
+
if (urlArgs.length === 1) {
|
|
296571
|
+
const rest = args.filter((a) => a !== urlArgs[0]);
|
|
296572
|
+
const intent2 = flagIntent ?? (rest.length > 0 ? rest.join(" ") : undefined);
|
|
296573
|
+
if (!intent2)
|
|
296574
|
+
return { error: `usage: unbrowse ${verb} <url> "task"` };
|
|
296575
|
+
return { url: urlArgs[0], intent: intent2 };
|
|
296576
|
+
}
|
|
296477
296577
|
const intent = flagIntent ?? (args.length > 0 ? args.join(" ") : undefined);
|
|
296478
296578
|
if (!intent)
|
|
296479
296579
|
return { error: `usage: unbrowse ${verb} "task" [--url <url>]` };
|
|
@@ -299908,6 +300008,7 @@ __export(exports_orchestrator, {
|
|
|
299908
300008
|
compositeContentId: () => compositeContentId2,
|
|
299909
300009
|
compositeAddress: () => compositeAddress2,
|
|
299910
300010
|
chooseBestRouteCacheCandidate: () => chooseBestRouteCacheCandidate2,
|
|
300011
|
+
cachedSkillHostMatchesContext: () => cachedSkillHostMatchesContext2,
|
|
299911
300012
|
buildResolveCacheKey: () => buildResolveCacheKey2,
|
|
299912
300013
|
buildCompositeEdges: () => buildCompositeEdges2,
|
|
299913
300014
|
attachCompositeToSkill: () => attachCompositeToSkill2,
|
|
@@ -299940,7 +300041,9 @@ function shouldAutoWalk2(requestedUrl, topUrl, topScore, minScore = 0.8) {
|
|
|
299940
300041
|
return false;
|
|
299941
300042
|
const reqReg = registrableHost2(requestedUrl);
|
|
299942
300043
|
const topReg = registrableHost2(topUrl);
|
|
299943
|
-
|
|
300044
|
+
if (reqReg)
|
|
300045
|
+
return reqReg === topReg;
|
|
300046
|
+
return (topScore ?? 0) >= minScore;
|
|
299944
300047
|
}
|
|
299945
300048
|
function pickWalkTarget2(requestedUrl, ranked, minScore = 0.8) {
|
|
299946
300049
|
const eligible = ranked.filter((c) => c?.url && shouldAutoWalk2(requestedUrl, c.url, c.score, minScore));
|
|
@@ -300397,6 +300500,17 @@ function endpointMatchesContextOrigin2(endpoint, contextUrl) {
|
|
|
300397
300500
|
return true;
|
|
300398
300501
|
}
|
|
300399
300502
|
}
|
|
300503
|
+
function cachedSkillHostMatchesContext2(skillDomain, contextUrl) {
|
|
300504
|
+
if (!contextUrl)
|
|
300505
|
+
return true;
|
|
300506
|
+
const ctxReg = registrableHost2(contextUrl);
|
|
300507
|
+
if (!ctxReg)
|
|
300508
|
+
return true;
|
|
300509
|
+
const skillReg = registrableHost2(skillDomain) ?? registrableHost2(`https://${skillDomain ?? ""}`);
|
|
300510
|
+
if (!skillReg)
|
|
300511
|
+
return true;
|
|
300512
|
+
return skillReg === ctxReg;
|
|
300513
|
+
}
|
|
300400
300514
|
function endpointTargetsMismatchedLocalReplayHost2(endpoint, contextUrl) {
|
|
300401
300515
|
if (!contextUrl)
|
|
300402
300516
|
return false;
|
|
@@ -303382,7 +303496,7 @@ async function resolveAndExecute2(intent, params = {}, context, projection, opti
|
|
|
303382
303496
|
if (!forceCapture && !agentChoseEndpoint) {
|
|
303383
303497
|
const cachedResult = routeResultCache2.get(cacheKey2);
|
|
303384
303498
|
if (cachedResult) {
|
|
303385
|
-
if (!shouldReuseRouteResultSnapshot2(cachedResult, queryIntent, context?.url)) {
|
|
303499
|
+
if (!cachedSkillHostMatchesContext2(cachedResult.skill.domain, context?.url) || !shouldReuseRouteResultSnapshot2(cachedResult, queryIntent, context?.url)) {
|
|
303386
303500
|
routeResultCache2.delete(cacheKey2);
|
|
303387
303501
|
} else {
|
|
303388
303502
|
timing.cache_hit = true;
|
|
@@ -303419,6 +303533,11 @@ async function resolveAndExecute2(intent, params = {}, context, projection, opti
|
|
|
303419
303533
|
persistRouteCache2();
|
|
303420
303534
|
continue;
|
|
303421
303535
|
}
|
|
303536
|
+
if (!cachedSkillHostMatchesContext2(cached6.domain, context?.url)) {
|
|
303537
|
+
skillRouteCache2.delete(scopedKey2);
|
|
303538
|
+
persistRouteCache2();
|
|
303539
|
+
continue;
|
|
303540
|
+
}
|
|
303422
303541
|
const skill = readSkillSnapshot2(cached6.localSkillPath) ?? await getSkillWithTimeout2(cached6.skillId, clientScope);
|
|
303423
303542
|
if (!skill || !isCachedSkillRelevantForIntent2(skill, queryIntent, context?.url)) {
|
|
303424
303543
|
skillRouteCache2.delete(scopedKey2);
|
|
@@ -303521,6 +303640,11 @@ async function resolveAndExecute2(intent, params = {}, context, projection, opti
|
|
|
303521
303640
|
persistRouteCache2();
|
|
303522
303641
|
continue;
|
|
303523
303642
|
}
|
|
303643
|
+
if (!cachedSkillHostMatchesContext2(cached7.domain, context?.url)) {
|
|
303644
|
+
skillRouteCache2.delete(scopedKey2);
|
|
303645
|
+
persistRouteCache2();
|
|
303646
|
+
continue;
|
|
303647
|
+
}
|
|
303524
303648
|
const skill = readSkillSnapshot2(cached7.localSkillPath) ?? await getSkillWithTimeout2(cached7.skillId, clientScope);
|
|
303525
303649
|
if (!skill)
|
|
303526
303650
|
continue;
|