unbrowse 10.1.6 → 10.1.8
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 +39 -26
- package/runtime/mcp.js +45 -28
package/package.json
CHANGED
package/runtime/cli.js
CHANGED
|
@@ -63674,6 +63674,22 @@ async function indexContractRows(rows, embed, store) {
|
|
|
63674
63674
|
}
|
|
63675
63675
|
return n;
|
|
63676
63676
|
}
|
|
63677
|
+
function hashEmbedder(dim = 256) {
|
|
63678
|
+
return {
|
|
63679
|
+
async embed(text) {
|
|
63680
|
+
const v = new Array(dim).fill(0);
|
|
63681
|
+
for (const tok of text.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)) {
|
|
63682
|
+
let h = 2166136261;
|
|
63683
|
+
for (let i = 0;i < tok.length; i++) {
|
|
63684
|
+
h ^= tok.charCodeAt(i);
|
|
63685
|
+
h = Math.imul(h, 16777619);
|
|
63686
|
+
}
|
|
63687
|
+
v[(h >>> 0) % dim] += 1;
|
|
63688
|
+
}
|
|
63689
|
+
return v;
|
|
63690
|
+
}
|
|
63691
|
+
};
|
|
63692
|
+
}
|
|
63677
63693
|
function openAiEmbedder(env = process.env) {
|
|
63678
63694
|
const key = env.OPENAI_API_KEY?.trim();
|
|
63679
63695
|
if (!key)
|
|
@@ -63805,6 +63821,12 @@ async function resolveLiveEmbedder(env = process.env) {
|
|
|
63805
63821
|
|
|
63806
63822
|
// .tmp-runtime-src/values/contract-everything.ts
|
|
63807
63823
|
import { createHash as createHash4 } from "node:crypto";
|
|
63824
|
+
async function embedderForIndexing(env = process.env) {
|
|
63825
|
+
const live = await resolveLiveEmbedder(env);
|
|
63826
|
+
if (live)
|
|
63827
|
+
return live;
|
|
63828
|
+
return { embed: hashEmbedder(1536), provider: "embedded-hash-1536" };
|
|
63829
|
+
}
|
|
63808
63830
|
function emergentKey() {
|
|
63809
63831
|
const k = (typeof process !== "undefined" ? process.env?.EMERGENTDB_API_KEY : undefined)?.trim();
|
|
63810
63832
|
if (!k)
|
|
@@ -63897,19 +63919,13 @@ async function persistContract(c, opts = {}) {
|
|
|
63897
63919
|
try {
|
|
63898
63920
|
let embed = opts.embedder;
|
|
63899
63921
|
if (!embed) {
|
|
63900
|
-
const
|
|
63901
|
-
|
|
63902
|
-
|
|
63903
|
-
out.embedder = live.provider;
|
|
63904
|
-
}
|
|
63905
|
-
}
|
|
63906
|
-
if (!embed) {
|
|
63907
|
-
out.notes.push("rag: no 1536-dim embedder available (contract-native llama.cpp / OPENAI_API_KEY / Nebius) — skipped");
|
|
63908
|
-
} else {
|
|
63909
|
-
const row = { id: c.id, text: c.text };
|
|
63910
|
-
await indexContractRows([row], embed, emergentVectorStore(namespace));
|
|
63911
|
-
out.rag = true;
|
|
63922
|
+
const chosen = await embedderForIndexing(process.env);
|
|
63923
|
+
embed = chosen.embed;
|
|
63924
|
+
out.embedder = chosen.provider;
|
|
63912
63925
|
}
|
|
63926
|
+
const row = { id: c.id, text: c.text };
|
|
63927
|
+
await indexContractRows([row], embed, emergentVectorStore(namespace));
|
|
63928
|
+
out.rag = true;
|
|
63913
63929
|
} catch (e) {
|
|
63914
63930
|
out.notes.push(`rag: ${e instanceof Error ? e.message : String(e)}`);
|
|
63915
63931
|
}
|
|
@@ -63931,17 +63947,10 @@ async function mirrorToEmergent(id, text, value, opts = {}) {
|
|
|
63931
63947
|
}
|
|
63932
63948
|
try {
|
|
63933
63949
|
let embed = opts.embedder;
|
|
63934
|
-
if (!embed)
|
|
63935
|
-
|
|
63936
|
-
|
|
63937
|
-
|
|
63938
|
-
}
|
|
63939
|
-
if (!embed) {
|
|
63940
|
-
r.notes.push("rag: no embedder available — skipped");
|
|
63941
|
-
} else {
|
|
63942
|
-
await indexContractRows([{ id, text }], embed, emergentVectorStore(namespace));
|
|
63943
|
-
r.rag = true;
|
|
63944
|
-
}
|
|
63950
|
+
if (!embed)
|
|
63951
|
+
embed = (await embedderForIndexing(process.env)).embed;
|
|
63952
|
+
await indexContractRows([{ id, text }], embed, emergentVectorStore(namespace));
|
|
63953
|
+
r.rag = true;
|
|
63945
63954
|
} catch (e) {
|
|
63946
63955
|
r.notes.push(`rag: ${e instanceof Error ? e.message : String(e)}`);
|
|
63947
63956
|
}
|
|
@@ -64923,7 +64932,7 @@ var init_telemetry = __esm(() => {
|
|
|
64923
64932
|
});
|
|
64924
64933
|
|
|
64925
64934
|
// .tmp-runtime-src/build-info.generated.ts
|
|
64926
|
-
var BUILD_RELEASE_VERSION = "10.1.
|
|
64935
|
+
var BUILD_RELEASE_VERSION = "10.1.8", BUILD_GIT_SHA = "19288fa59909", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMS44IiwiZ2l0X3NoYSI6IjE5Mjg4ZmE1OTkwOSIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAMTkyODhmYTU5OTA5IiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yM1QxMjozOTowMC41NTRaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "sOsI7qC2tg6Pbtm69qJt58JRVAVS4IozNeI50MGo4NI", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
|
|
64927
64936
|
|
|
64928
64937
|
// .tmp-runtime-src/version.ts
|
|
64929
64938
|
import { createHash as createHash8 } from "crypto";
|
|
@@ -196349,14 +196358,17 @@ function normalizeRouteContext(url) {
|
|
|
196349
196358
|
function buildResolveCacheKey(domain, intent, url) {
|
|
196350
196359
|
return `${domain || "global"}:${intent.trim().toLowerCase()}:${normalizeRouteContext(url)}`;
|
|
196351
196360
|
}
|
|
196352
|
-
function mirrorCapturedRouteToContract(cacheKey2, skill, endpointId, ledgerOverride) {
|
|
196361
|
+
function mirrorCapturedRouteToContract(cacheKey2, skill, endpointId, ledgerOverride, emergentOverride) {
|
|
196353
196362
|
if (!localCachesEnabled() || ISOLATED_SKILL_SNAPSHOT_MODE)
|
|
196354
196363
|
return;
|
|
196355
196364
|
try {
|
|
196356
196365
|
const urlTemplate = skill.endpoints?.find((e) => e.endpoint_id === endpointId)?.url_template ?? skill.endpoints?.[0]?.url_template ?? "";
|
|
196357
196366
|
const pointer = `route:${createHash20("sha256").update(`${skill.skill_id}|${endpointId ?? ""}|${urlTemplate}`).digest("hex").slice(0, 32)}`;
|
|
196358
|
-
console.error(`[contract-index] route ${cacheKey2} → /contract ledger (mirror fired)`);
|
|
196367
|
+
console.error(`[contract-index] route ${cacheKey2} → /contract ledger + emergent kv/rag (mirror fired)`);
|
|
196359
196368
|
mirrorResolutionToChain2(cacheKey2, pointer, ledgerOverride ?? {}).catch(() => {});
|
|
196369
|
+
const emergentText = `${skill.domain ?? ""} ${skill.skill_id} ${urlTemplate}`.trim();
|
|
196370
|
+
const emergentValue = { skillId: skill.skill_id, endpointId, urlTemplate, pointer };
|
|
196371
|
+
(emergentOverride ?? mirrorToEmergent)(pointer, emergentText, emergentValue).catch(() => {});
|
|
196360
196372
|
} catch {}
|
|
196361
196373
|
}
|
|
196362
196374
|
function promoteLearnedSkill(scope, cacheKey2, skill, endpointId, contextUrl) {
|
|
@@ -201439,6 +201451,7 @@ var init_orchestrator = __esm(async () => {
|
|
|
201439
201451
|
init_search_forms();
|
|
201440
201452
|
init_ddg_search();
|
|
201441
201453
|
init_cached_resolution2();
|
|
201454
|
+
init_contract_everything();
|
|
201442
201455
|
init_cardinality2();
|
|
201443
201456
|
init_cardinality2();
|
|
201444
201457
|
init_principal_scope();
|
package/runtime/mcp.js
CHANGED
|
@@ -94766,6 +94766,22 @@ async function indexContractRows(rows, embed, store) {
|
|
|
94766
94766
|
}
|
|
94767
94767
|
return n;
|
|
94768
94768
|
}
|
|
94769
|
+
function hashEmbedder(dim = 256) {
|
|
94770
|
+
return {
|
|
94771
|
+
async embed(text) {
|
|
94772
|
+
const v = new Array(dim).fill(0);
|
|
94773
|
+
for (const tok of text.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)) {
|
|
94774
|
+
let h = 2166136261;
|
|
94775
|
+
for (let i = 0;i < tok.length; i++) {
|
|
94776
|
+
h ^= tok.charCodeAt(i);
|
|
94777
|
+
h = Math.imul(h, 16777619);
|
|
94778
|
+
}
|
|
94779
|
+
v[(h >>> 0) % dim] += 1;
|
|
94780
|
+
}
|
|
94781
|
+
return v;
|
|
94782
|
+
}
|
|
94783
|
+
};
|
|
94784
|
+
}
|
|
94769
94785
|
function openAiEmbedder(env = process.env) {
|
|
94770
94786
|
const key = env.OPENAI_API_KEY?.trim();
|
|
94771
94787
|
if (!key)
|
|
@@ -94897,6 +94913,12 @@ async function resolveLiveEmbedder(env = process.env) {
|
|
|
94897
94913
|
|
|
94898
94914
|
// .tmp-runtime-src/values/contract-everything.ts
|
|
94899
94915
|
import { createHash as createHash4 } from "node:crypto";
|
|
94916
|
+
async function embedderForIndexing(env = process.env) {
|
|
94917
|
+
const live = await resolveLiveEmbedder(env);
|
|
94918
|
+
if (live)
|
|
94919
|
+
return live;
|
|
94920
|
+
return { embed: hashEmbedder(1536), provider: "embedded-hash-1536" };
|
|
94921
|
+
}
|
|
94900
94922
|
function emergentKey() {
|
|
94901
94923
|
const k = (typeof process !== "undefined" ? process.env?.EMERGENTDB_API_KEY : undefined)?.trim();
|
|
94902
94924
|
if (!k)
|
|
@@ -94989,19 +95011,13 @@ async function persistContract(c, opts = {}) {
|
|
|
94989
95011
|
try {
|
|
94990
95012
|
let embed = opts.embedder;
|
|
94991
95013
|
if (!embed) {
|
|
94992
|
-
const
|
|
94993
|
-
|
|
94994
|
-
|
|
94995
|
-
out.embedder = live.provider;
|
|
94996
|
-
}
|
|
94997
|
-
}
|
|
94998
|
-
if (!embed) {
|
|
94999
|
-
out.notes.push("rag: no 1536-dim embedder available (contract-native llama.cpp / OPENAI_API_KEY / Nebius) — skipped");
|
|
95000
|
-
} else {
|
|
95001
|
-
const row = { id: c.id, text: c.text };
|
|
95002
|
-
await indexContractRows([row], embed, emergentVectorStore(namespace));
|
|
95003
|
-
out.rag = true;
|
|
95014
|
+
const chosen = await embedderForIndexing(process.env);
|
|
95015
|
+
embed = chosen.embed;
|
|
95016
|
+
out.embedder = chosen.provider;
|
|
95004
95017
|
}
|
|
95018
|
+
const row = { id: c.id, text: c.text };
|
|
95019
|
+
await indexContractRows([row], embed, emergentVectorStore(namespace));
|
|
95020
|
+
out.rag = true;
|
|
95005
95021
|
} catch (e) {
|
|
95006
95022
|
out.notes.push(`rag: ${e instanceof Error ? e.message : String(e)}`);
|
|
95007
95023
|
}
|
|
@@ -95023,17 +95039,10 @@ async function mirrorToEmergent(id, text, value, opts = {}) {
|
|
|
95023
95039
|
}
|
|
95024
95040
|
try {
|
|
95025
95041
|
let embed = opts.embedder;
|
|
95026
|
-
if (!embed)
|
|
95027
|
-
|
|
95028
|
-
|
|
95029
|
-
|
|
95030
|
-
}
|
|
95031
|
-
if (!embed) {
|
|
95032
|
-
r.notes.push("rag: no embedder available — skipped");
|
|
95033
|
-
} else {
|
|
95034
|
-
await indexContractRows([{ id, text }], embed, emergentVectorStore(namespace));
|
|
95035
|
-
r.rag = true;
|
|
95036
|
-
}
|
|
95042
|
+
if (!embed)
|
|
95043
|
+
embed = (await embedderForIndexing(process.env)).embed;
|
|
95044
|
+
await indexContractRows([{ id, text }], embed, emergentVectorStore(namespace));
|
|
95045
|
+
r.rag = true;
|
|
95037
95046
|
} catch (e) {
|
|
95038
95047
|
r.notes.push(`rag: ${e instanceof Error ? e.message : String(e)}`);
|
|
95039
95048
|
}
|
|
@@ -101443,7 +101452,7 @@ async function mergedAuthHeaders(key, signer) {
|
|
|
101443
101452
|
var AUTH_DOMAIN = "unbrowse-auth:v1";
|
|
101444
101453
|
|
|
101445
101454
|
// .tmp-runtime-src/build-info.generated.ts
|
|
101446
|
-
var BUILD_RELEASE_VERSION = "10.1.
|
|
101455
|
+
var BUILD_RELEASE_VERSION = "10.1.8", BUILD_GIT_SHA = "19288fa59909", BUILD_CODE_HASH = "5d9ebf619c61", BUILD_RELEASE_MANIFEST_BASE64 = "eyJzY2hlbWFfdmVyc2lvbiI6MSwicmVsZWFzZV92ZXJzaW9uIjoiMTAuMS44IiwiZ2l0X3NoYSI6IjE5Mjg4ZmE1OTkwOSIsImNvZGVfaGFzaCI6IjVkOWViZjYxOWM2MSIsInRyYWNlX3ZlcnNpb24iOiI1ZDllYmY2MTljNjFAMTkyODhmYTU5OTA5IiwiaXNzdWVkX2F0IjoiMjAyNi0wNi0yM1QxMjozOTowMC41NTRaIn0", BUILD_RELEASE_MANIFEST_SIGNATURE = "sOsI7qC2tg6Pbtm69qJt58JRVAVS4IozNeI50MGo4NI", BUILD_DEFAULT_BACKEND_URL = "https://beta-api.unbrowse.ai", BUILD_DEFAULT_PROFILE = "";
|
|
101447
101456
|
|
|
101448
101457
|
// .tmp-runtime-src/version.ts
|
|
101449
101458
|
import { createHash as createHash6 } from "crypto";
|
|
@@ -193486,14 +193495,17 @@ function normalizeRouteContext(url) {
|
|
|
193486
193495
|
function buildResolveCacheKey(domain, intent, url) {
|
|
193487
193496
|
return `${domain || "global"}:${intent.trim().toLowerCase()}:${normalizeRouteContext(url)}`;
|
|
193488
193497
|
}
|
|
193489
|
-
function mirrorCapturedRouteToContract(cacheKey2, skill, endpointId, ledgerOverride) {
|
|
193498
|
+
function mirrorCapturedRouteToContract(cacheKey2, skill, endpointId, ledgerOverride, emergentOverride) {
|
|
193490
193499
|
if (!localCachesEnabled() || ISOLATED_SKILL_SNAPSHOT_MODE)
|
|
193491
193500
|
return;
|
|
193492
193501
|
try {
|
|
193493
193502
|
const urlTemplate = skill.endpoints?.find((e) => e.endpoint_id === endpointId)?.url_template ?? skill.endpoints?.[0]?.url_template ?? "";
|
|
193494
193503
|
const pointer = `route:${createHash15("sha256").update(`${skill.skill_id}|${endpointId ?? ""}|${urlTemplate}`).digest("hex").slice(0, 32)}`;
|
|
193495
|
-
console.error(`[contract-index] route ${cacheKey2} → /contract ledger (mirror fired)`);
|
|
193504
|
+
console.error(`[contract-index] route ${cacheKey2} → /contract ledger + emergent kv/rag (mirror fired)`);
|
|
193496
193505
|
mirrorResolutionToChain(cacheKey2, pointer, ledgerOverride ?? {}).catch(() => {});
|
|
193506
|
+
const emergentText = `${skill.domain ?? ""} ${skill.skill_id} ${urlTemplate}`.trim();
|
|
193507
|
+
const emergentValue = { skillId: skill.skill_id, endpointId, urlTemplate, pointer };
|
|
193508
|
+
(emergentOverride ?? mirrorToEmergent)(pointer, emergentText, emergentValue).catch(() => {});
|
|
193497
193509
|
} catch {}
|
|
193498
193510
|
}
|
|
193499
193511
|
function promoteLearnedSkill(scope, cacheKey2, skill, endpointId, contextUrl) {
|
|
@@ -198576,6 +198588,7 @@ var init_orchestrator = __esm(async () => {
|
|
|
198576
198588
|
init_search_forms();
|
|
198577
198589
|
init_ddg_search();
|
|
198578
198590
|
init_cached_resolution();
|
|
198591
|
+
init_contract_everything();
|
|
198579
198592
|
init_cardinality();
|
|
198580
198593
|
init_cardinality();
|
|
198581
198594
|
init_principal_scope();
|
|
@@ -300852,14 +300865,17 @@ function normalizeRouteContext2(url) {
|
|
|
300852
300865
|
function buildResolveCacheKey2(domain, intent, url) {
|
|
300853
300866
|
return `${domain || "global"}:${intent.trim().toLowerCase()}:${normalizeRouteContext2(url)}`;
|
|
300854
300867
|
}
|
|
300855
|
-
function mirrorCapturedRouteToContract2(cacheKey2, skill, endpointId, ledgerOverride) {
|
|
300868
|
+
function mirrorCapturedRouteToContract2(cacheKey2, skill, endpointId, ledgerOverride, emergentOverride) {
|
|
300856
300869
|
if (!localCachesEnabled2() || ISOLATED_SKILL_SNAPSHOT_MODE2)
|
|
300857
300870
|
return;
|
|
300858
300871
|
try {
|
|
300859
300872
|
const urlTemplate = skill.endpoints?.find((e) => e.endpoint_id === endpointId)?.url_template ?? skill.endpoints?.[0]?.url_template ?? "";
|
|
300860
300873
|
const pointer = `route:${createHash51("sha256").update(`${skill.skill_id}|${endpointId ?? ""}|${urlTemplate}`).digest("hex").slice(0, 32)}`;
|
|
300861
|
-
console.error(`[contract-index] route ${cacheKey2} → /contract ledger (mirror fired)`);
|
|
300874
|
+
console.error(`[contract-index] route ${cacheKey2} → /contract ledger + emergent kv/rag (mirror fired)`);
|
|
300862
300875
|
mirrorResolutionToChain(cacheKey2, pointer, ledgerOverride ?? {}).catch(() => {});
|
|
300876
|
+
const emergentText = `${skill.domain ?? ""} ${skill.skill_id} ${urlTemplate}`.trim();
|
|
300877
|
+
const emergentValue = { skillId: skill.skill_id, endpointId, urlTemplate, pointer };
|
|
300878
|
+
(emergentOverride ?? mirrorToEmergent)(pointer, emergentText, emergentValue).catch(() => {});
|
|
300863
300879
|
} catch {}
|
|
300864
300880
|
}
|
|
300865
300881
|
function promoteLearnedSkill2(scope, cacheKey2, skill, endpointId, contextUrl) {
|
|
@@ -305947,6 +305963,7 @@ var init_orchestrator2 = __esm(async () => {
|
|
|
305947
305963
|
init_search_forms();
|
|
305948
305964
|
init_ddg_search();
|
|
305949
305965
|
init_cached_resolution();
|
|
305966
|
+
init_contract_everything();
|
|
305950
305967
|
init_cardinality();
|
|
305951
305968
|
init_cardinality();
|
|
305952
305969
|
init_principal_scope();
|