page-agent-sdk 4.3.0 → 4.4.0
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.headless.js +183 -177
- package/dist/page-agent-sdk.iife.js +101 -101
- package/dist/page-agent-sdk.js +1565 -1559
- package/dist/page-agent-sdk.legacy.js +982 -976
- package/dist/page-agent-sdk.umd.cjs +39 -39
- package/package.json +1 -1
- package/types/headless.d.ts +4 -1
- package/types/index.d.ts +4 -1
|
@@ -11110,10 +11110,13 @@ function Kf(e, t, n) {
|
|
|
11110
11110
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
11111
11111
|
}
|
|
11112
11112
|
function qf(e = {}) {
|
|
11113
|
-
return
|
|
11113
|
+
return Yf(e, typeof e.backend == "object" && e.backend ? e.backend : void 0);
|
|
11114
11114
|
}
|
|
11115
|
-
function Jf(e
|
|
11116
|
-
|
|
11115
|
+
function Jf(e, t) {
|
|
11116
|
+
return Yf(e, t);
|
|
11117
|
+
}
|
|
11118
|
+
function Yf(e = {}, t) {
|
|
11119
|
+
let n = e.dbName ?? Cf, r = typeof e.backend == "string" ? e.backend ?? "indexed" : "indexed", i = e.maxBytes ?? Pf(r), a = e.maxBytesPerSession ?? Ef, o = e.evictionWatermark ?? Df, s = e.debounceMs ?? Of, c = /* @__PURE__ */ new Set();
|
|
11117
11120
|
function l(e) {
|
|
11118
11121
|
for (let t of c) try {
|
|
11119
11122
|
t(e);
|
|
@@ -11313,7 +11316,10 @@ function Jf(e = {}, t) {
|
|
|
11313
11316
|
bytes: 0,
|
|
11314
11317
|
title: t
|
|
11315
11318
|
};
|
|
11316
|
-
|
|
11319
|
+
try {
|
|
11320
|
+
await u.set(If(n, e, i, jf), o);
|
|
11321
|
+
} catch {}
|
|
11322
|
+
return i;
|
|
11317
11323
|
},
|
|
11318
11324
|
onEvent(e) {
|
|
11319
11325
|
c.add(e);
|
|
@@ -11328,15 +11334,15 @@ function Jf(e = {}, t) {
|
|
|
11328
11334
|
}
|
|
11329
11335
|
//#endregion
|
|
11330
11336
|
//#region src/core/sdk/optionsResolver.ts
|
|
11331
|
-
function
|
|
11337
|
+
function Xf(e) {
|
|
11332
11338
|
return e === void 0 ? qf({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? qf({ backend: e }) : e.enabled === !1 ? null : qf(e);
|
|
11333
11339
|
}
|
|
11334
|
-
function
|
|
11340
|
+
function Zf(e) {
|
|
11335
11341
|
return e.dialog ?? {};
|
|
11336
11342
|
}
|
|
11337
11343
|
//#endregion
|
|
11338
11344
|
//#region src/core/capabilities.ts
|
|
11339
|
-
var
|
|
11345
|
+
var Qf = [
|
|
11340
11346
|
{
|
|
11341
11347
|
name: "dataOps",
|
|
11342
11348
|
defaultOn: !0
|
|
@@ -11412,13 +11418,13 @@ var Zf = [
|
|
|
11412
11418
|
requires: ["summarization"]
|
|
11413
11419
|
}
|
|
11414
11420
|
];
|
|
11415
|
-
function
|
|
11421
|
+
function $f(e) {
|
|
11416
11422
|
let t = {};
|
|
11417
|
-
for (let n of
|
|
11423
|
+
for (let n of Qf) {
|
|
11418
11424
|
let r = e?.[n.name];
|
|
11419
11425
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
11420
11426
|
}
|
|
11421
|
-
for (let e of
|
|
11427
|
+
for (let e of Qf) if (e.requires && t[e.name]) {
|
|
11422
11428
|
for (let n of e.requires) if (!t[n]) {
|
|
11423
11429
|
t[e.name] = !1;
|
|
11424
11430
|
break;
|
|
@@ -11428,7 +11434,7 @@ function Qf(e) {
|
|
|
11428
11434
|
}
|
|
11429
11435
|
//#endregion
|
|
11430
11436
|
//#region src/core/sdk/events.ts
|
|
11431
|
-
function
|
|
11437
|
+
function ep(e) {
|
|
11432
11438
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
11433
11439
|
if (n.type !== "approval_request") {
|
|
11434
11440
|
if (e) try {
|
|
@@ -11454,7 +11460,7 @@ function $f(e) {
|
|
|
11454
11460
|
}
|
|
11455
11461
|
//#endregion
|
|
11456
11462
|
//#region src/core/sdk/contextPreset.ts
|
|
11457
|
-
var
|
|
11463
|
+
var tp = {
|
|
11458
11464
|
auto: {
|
|
11459
11465
|
summaryThresholdRatio: .5,
|
|
11460
11466
|
windowRatio: .4,
|
|
@@ -11482,7 +11488,7 @@ var ep = {
|
|
|
11482
11488
|
enableRecall: !0,
|
|
11483
11489
|
enableLLMSummary: !0
|
|
11484
11490
|
}
|
|
11485
|
-
},
|
|
11491
|
+
}, np = {
|
|
11486
11492
|
auto: ["describe_data", "read"],
|
|
11487
11493
|
conservative: ["describe_data"],
|
|
11488
11494
|
aggressive: ["describe_data", "read"],
|
|
@@ -11493,8 +11499,8 @@ var ep = {
|
|
|
11493
11499
|
"search_data"
|
|
11494
11500
|
]
|
|
11495
11501
|
};
|
|
11496
|
-
function
|
|
11497
|
-
let n =
|
|
11502
|
+
function rp(e, t) {
|
|
11503
|
+
let n = tp[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
11498
11504
|
return {
|
|
11499
11505
|
...n,
|
|
11500
11506
|
...r,
|
|
@@ -11504,7 +11510,7 @@ function np(e, t) {
|
|
|
11504
11510
|
}
|
|
11505
11511
|
//#endregion
|
|
11506
11512
|
//#region src/core/sdk/middlewareStack.ts
|
|
11507
|
-
var
|
|
11513
|
+
var ip = {
|
|
11508
11514
|
dataHint: 10,
|
|
11509
11515
|
usageHints: 20,
|
|
11510
11516
|
todos: 30,
|
|
@@ -11521,17 +11527,17 @@ var rp = {
|
|
|
11521
11527
|
subagents: 140,
|
|
11522
11528
|
augmentSystem: 150
|
|
11523
11529
|
};
|
|
11524
|
-
function
|
|
11530
|
+
function ap(e) {
|
|
11525
11531
|
return e.map((e, t) => ({
|
|
11526
11532
|
m: e,
|
|
11527
11533
|
i: t,
|
|
11528
|
-
p:
|
|
11534
|
+
p: ip[e.name] ?? Infinity
|
|
11529
11535
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
11530
11536
|
}
|
|
11531
11537
|
//#endregion
|
|
11532
11538
|
//#region src/core/tools/fetchDoc.ts
|
|
11533
|
-
var
|
|
11534
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
11539
|
+
var op = 3e4, sp = [r(async ({ url: e, as: t }) => {
|
|
11540
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), op);
|
|
11535
11541
|
try {
|
|
11536
11542
|
let r = await fetch(e, {
|
|
11537
11543
|
method: "GET",
|
|
@@ -11548,7 +11554,7 @@ var ap = 3e4, op = [r(async ({ url: e, as: t }) => {
|
|
|
11548
11554
|
].join("\n");
|
|
11549
11555
|
} catch (t) {
|
|
11550
11556
|
let r = t?.message || String(t);
|
|
11551
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
11557
|
+
return n.signal.aborted ? `获取失败:请求超时(${op}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
11552
11558
|
} finally {
|
|
11553
11559
|
clearTimeout(r);
|
|
11554
11560
|
}
|
|
@@ -11559,7 +11565,7 @@ var ap = 3e4, op = [r(async ({ url: e, as: t }) => {
|
|
|
11559
11565
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
11560
11566
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
11561
11567
|
})
|
|
11562
|
-
})],
|
|
11568
|
+
})], cp = [
|
|
11563
11569
|
"id",
|
|
11564
11570
|
"class",
|
|
11565
11571
|
"href",
|
|
@@ -11571,12 +11577,12 @@ var ap = 3e4, op = [r(async ({ url: e, as: t }) => {
|
|
|
11571
11577
|
"aria-label",
|
|
11572
11578
|
"name",
|
|
11573
11579
|
"type"
|
|
11574
|
-
],
|
|
11575
|
-
function
|
|
11580
|
+
], lp = /^(value|srcdoc|formaction|on\w+)$/i, up = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
11581
|
+
function dp(e, t) {
|
|
11576
11582
|
if (!e) return null;
|
|
11577
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
11583
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? cp, s = (e) => {
|
|
11578
11584
|
let t = {};
|
|
11579
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
11585
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (lp.test(n.name) || up.test(n.name) || (t[n.name] = n.value));
|
|
11580
11586
|
return t;
|
|
11581
11587
|
}, c = (e, t) => {
|
|
11582
11588
|
let n = {
|
|
@@ -11592,10 +11598,10 @@ function up(e, t) {
|
|
|
11592
11598
|
};
|
|
11593
11599
|
return c(e, n);
|
|
11594
11600
|
}
|
|
11595
|
-
var
|
|
11601
|
+
var fp = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
11596
11602
|
let i = e ? document.querySelector(e) : document.body;
|
|
11597
11603
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
11598
|
-
let a =
|
|
11604
|
+
let a = dp(i, {
|
|
11599
11605
|
depth: t ?? 3,
|
|
11600
11606
|
attrs: n,
|
|
11601
11607
|
includeText: r ?? !0
|
|
@@ -11610,22 +11616,22 @@ var dp = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
11610
11616
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
11611
11617
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
11612
11618
|
})
|
|
11613
|
-
}),
|
|
11614
|
-
function
|
|
11615
|
-
if (
|
|
11619
|
+
}), pp = [fp], mp = /* @__PURE__ */ "display.position.visibility.opacity.color.background-color.background-image.font-size.font-weight.line-height.text-align.z-index.overflow.width.height.margin.padding.border.border-radius.box-shadow.transform.transition.animation.cursor.pointer-events.flex-direction.gap.max-width.min-height".split("."), hp = /* @__PURE__ */ new WeakMap(), gp = !1;
|
|
11620
|
+
function _p() {
|
|
11621
|
+
if (gp) return;
|
|
11616
11622
|
let e = globalThis.EventTarget;
|
|
11617
11623
|
if (!e?.prototype?.addEventListener) return;
|
|
11618
|
-
|
|
11624
|
+
gp = !0;
|
|
11619
11625
|
let t = e.prototype.addEventListener, n = e.prototype.removeEventListener;
|
|
11620
11626
|
e.prototype.addEventListener = function(e, ...n) {
|
|
11621
11627
|
try {
|
|
11622
|
-
let t =
|
|
11623
|
-
t || (t = /* @__PURE__ */ new Map(),
|
|
11628
|
+
let t = hp.get(this);
|
|
11629
|
+
t || (t = /* @__PURE__ */ new Map(), hp.set(this, t)), t.set(String(e), (t.get(String(e)) ?? 0) + 1);
|
|
11624
11630
|
} catch {}
|
|
11625
11631
|
return t.call(this, e, ...n);
|
|
11626
11632
|
}, e.prototype.removeEventListener = function(e, ...t) {
|
|
11627
11633
|
try {
|
|
11628
|
-
let t =
|
|
11634
|
+
let t = hp.get(this);
|
|
11629
11635
|
if (t) {
|
|
11630
11636
|
let n = (t.get(String(e)) ?? 1) - 1;
|
|
11631
11637
|
n <= 0 ? t.delete(String(e)) : t.set(String(e), n);
|
|
@@ -11634,10 +11640,10 @@ function gp() {
|
|
|
11634
11640
|
return n.call(this, e, ...t);
|
|
11635
11641
|
};
|
|
11636
11642
|
}
|
|
11637
|
-
function
|
|
11638
|
-
return [...
|
|
11643
|
+
function vp(e) {
|
|
11644
|
+
return [...hp.get(e)?.entries() ?? []].filter(([, e]) => e > 0).map(([e]) => e);
|
|
11639
11645
|
}
|
|
11640
|
-
function
|
|
11646
|
+
function yp(e, t = 12) {
|
|
11641
11647
|
let n = [], r = e, i = 0;
|
|
11642
11648
|
for (; r && r.tagName && i < t;) {
|
|
11643
11649
|
let e = r.tagName.toLowerCase(), t = r.id;
|
|
@@ -11658,7 +11664,7 @@ function vp(e, t = 12) {
|
|
|
11658
11664
|
}
|
|
11659
11665
|
return n.join(" > ");
|
|
11660
11666
|
}
|
|
11661
|
-
function
|
|
11667
|
+
function bp(e, t, n = {}) {
|
|
11662
11668
|
if (!e) return {
|
|
11663
11669
|
hits: [],
|
|
11664
11670
|
total: 0,
|
|
@@ -11696,7 +11702,7 @@ function yp(e, t, n = {}) {
|
|
|
11696
11702
|
n = r.slice(Math.max(0, i - 20), i + t.length + 40);
|
|
11697
11703
|
}
|
|
11698
11704
|
return {
|
|
11699
|
-
selector:
|
|
11705
|
+
selector: yp(e),
|
|
11700
11706
|
tag: e.tagName.toLowerCase(),
|
|
11701
11707
|
text: n.slice(0, 120)
|
|
11702
11708
|
};
|
|
@@ -11705,7 +11711,7 @@ function yp(e, t, n = {}) {
|
|
|
11705
11711
|
truncated: a.length > o
|
|
11706
11712
|
};
|
|
11707
11713
|
}
|
|
11708
|
-
var
|
|
11714
|
+
var xp = [
|
|
11709
11715
|
"content",
|
|
11710
11716
|
"display",
|
|
11711
11717
|
"width",
|
|
@@ -11713,14 +11719,14 @@ var bp = [
|
|
|
11713
11719
|
"background-color",
|
|
11714
11720
|
"position"
|
|
11715
11721
|
];
|
|
11716
|
-
function
|
|
11722
|
+
function Sp(e, t = {}) {
|
|
11717
11723
|
if (!e) return null;
|
|
11718
11724
|
let n = {
|
|
11719
|
-
selector:
|
|
11725
|
+
selector: yp(e),
|
|
11720
11726
|
tag: e.tagName.toLowerCase(),
|
|
11721
11727
|
attrs: {}
|
|
11722
11728
|
};
|
|
11723
|
-
for (let t of Array.from(e.attributes)) !(
|
|
11729
|
+
for (let t of Array.from(e.attributes)) !(cp.includes(t.name) || t.name.startsWith("data-")) || lp.test(t.name) || up.test(t.name) || (n.attrs[t.name] = t.value);
|
|
11724
11730
|
let r = Array.from(e.childNodes).filter((e) => e.nodeType === 3).map((e) => e.textContent || "").join("").trim();
|
|
11725
11731
|
r && (n.text = r.slice(0, 400));
|
|
11726
11732
|
let i = String(e.innerText ?? e.textContent ?? "").trim();
|
|
@@ -11742,7 +11748,7 @@ function xp(e, t = {}) {
|
|
|
11742
11748
|
if (typeof a != "function") return r;
|
|
11743
11749
|
try {
|
|
11744
11750
|
let i = a(e, n ?? null);
|
|
11745
|
-
for (let e of n ?
|
|
11751
|
+
for (let e of n ? xp : t.styles ?? mp) {
|
|
11746
11752
|
let t = typeof i.getPropertyValue == "function" ? i.getPropertyValue(e) : i[e];
|
|
11747
11753
|
t && (r[e] = String(t).slice(0, 200));
|
|
11748
11754
|
}
|
|
@@ -11760,16 +11766,16 @@ function xp(e, t = {}) {
|
|
|
11760
11766
|
n.events = {
|
|
11761
11767
|
inline: t,
|
|
11762
11768
|
vue: r ? Object.keys(r).filter((e) => /^on[A-Z]/.test(e)).map((e) => e.slice(2).toLowerCase()) : [],
|
|
11763
|
-
captured:
|
|
11769
|
+
captured: vp(e)
|
|
11764
11770
|
};
|
|
11765
11771
|
}
|
|
11766
11772
|
return n;
|
|
11767
11773
|
}
|
|
11768
|
-
var
|
|
11769
|
-
|
|
11774
|
+
var Cp = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
11775
|
+
_p();
|
|
11770
11776
|
let i = r ? document.querySelector(r) : document;
|
|
11771
11777
|
if (r && !i) return `未找到 root 元素:selector="${r}"`;
|
|
11772
|
-
let a =
|
|
11778
|
+
let a = bp(i, e, {
|
|
11773
11779
|
mode: t,
|
|
11774
11780
|
limit: n
|
|
11775
11781
|
});
|
|
@@ -11786,11 +11792,11 @@ var Sp = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11786
11792
|
limit: t.number().int().min(1).max(20).optional().describe("返回上限(默认 10)"),
|
|
11787
11793
|
root: t.string().optional().describe("限定搜索范围的容器选择器(默认整页)")
|
|
11788
11794
|
})
|
|
11789
|
-
}),
|
|
11790
|
-
|
|
11795
|
+
}), wp = r(({ selector: e, styles: t, includeHtml: n, htmlLimit: r, includeEvents: i, includeRect: a, pseudo: o }) => {
|
|
11796
|
+
_p();
|
|
11791
11797
|
let s = document.querySelector(e);
|
|
11792
11798
|
if (!s) return `未找到匹配元素:selector="${e}"(可先用 dom_search 定位)`;
|
|
11793
|
-
let c =
|
|
11799
|
+
let c = Sp(s, {
|
|
11794
11800
|
styles: t,
|
|
11795
11801
|
includeHtml: n,
|
|
11796
11802
|
htmlLimit: r,
|
|
@@ -11811,7 +11817,7 @@ var Sp = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11811
11817
|
includeRect: t.boolean().optional().describe("是否含几何位置(默认 true)"),
|
|
11812
11818
|
pseudo: t.boolean().optional().describe("是否含 ::before/::after 伪元素摘要(默认 false)")
|
|
11813
11819
|
})
|
|
11814
|
-
}),
|
|
11820
|
+
}), Tp = {
|
|
11815
11821
|
name: "dom-inspect",
|
|
11816
11822
|
description: "页面 DOM 深度检视工具(dom_search 搜索元素 / dom_info 读内容·计算样式·事件绑定·几何)。定位元素、验证样式落地、排查交互绑定时加载",
|
|
11817
11823
|
getContent: () => [
|
|
@@ -11828,15 +11834,15 @@ var Sp = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11828
11834
|
"## 排障套路",
|
|
11829
11835
|
"1. dom_search(mode:\"text\", query:按钮文案) 定位 → 2. dom_info(styles:[\"display\",\"background-color\",\"pointer-events\"]) 验证样式/点击性 → 3. 不符则改数据(get_dom 看结构对照)"
|
|
11830
11836
|
].join("\n"),
|
|
11831
|
-
tools: [() => [
|
|
11837
|
+
tools: [() => [Cp, wp]]
|
|
11832
11838
|
};
|
|
11833
11839
|
//#endregion
|
|
11834
11840
|
//#region src/core/tools/envTool.ts
|
|
11835
|
-
function
|
|
11841
|
+
function Ep(e) {
|
|
11836
11842
|
let t = e;
|
|
11837
11843
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
11838
11844
|
}
|
|
11839
|
-
function
|
|
11845
|
+
function Dp(e, t = 3, n = 2e3, r, i) {
|
|
11840
11846
|
if (e == null) return e;
|
|
11841
11847
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
11842
11848
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -11845,14 +11851,14 @@ function Ep(e, t = 3, n = 2e3, r, i) {
|
|
|
11845
11851
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
11846
11852
|
if (typeof e != "object") return String(e);
|
|
11847
11853
|
let a = e;
|
|
11848
|
-
if (
|
|
11854
|
+
if (Ep(a)) {
|
|
11849
11855
|
let e = a;
|
|
11850
11856
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
11851
11857
|
}
|
|
11852
11858
|
if (r?.has(a)) return "[Circular]";
|
|
11853
11859
|
let o = r ?? /* @__PURE__ */ new WeakSet();
|
|
11854
11860
|
if (o.add(a), Array.isArray(e)) {
|
|
11855
|
-
let r = e.slice(0, 100).map((e) =>
|
|
11861
|
+
let r = e.slice(0, 100).map((e) => Dp(e, t - 1, n, o, i));
|
|
11856
11862
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
11857
11863
|
}
|
|
11858
11864
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -11865,14 +11871,14 @@ function Ep(e, t = 3, n = 2e3, r, i) {
|
|
|
11865
11871
|
}
|
|
11866
11872
|
try {
|
|
11867
11873
|
let e = a[r];
|
|
11868
|
-
i?.test(r) ? s[r] = "[REDACTED]" : s[r] =
|
|
11874
|
+
i?.test(r) ? s[r] = "[REDACTED]" : s[r] = Dp(e, t - 1, n, o, i);
|
|
11869
11875
|
} catch {
|
|
11870
11876
|
s[r] = "(getter 抛错)";
|
|
11871
11877
|
}
|
|
11872
11878
|
}
|
|
11873
11879
|
return s;
|
|
11874
11880
|
}
|
|
11875
|
-
function
|
|
11881
|
+
function Op(e) {
|
|
11876
11882
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
11877
11883
|
return {
|
|
11878
11884
|
location: {
|
|
@@ -11905,9 +11911,9 @@ function Dp(e) {
|
|
|
11905
11911
|
} : "(无 document)"
|
|
11906
11912
|
};
|
|
11907
11913
|
}
|
|
11908
|
-
var
|
|
11914
|
+
var kp = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, Ap = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, jp = r(({ key: e }) => {
|
|
11909
11915
|
if (e) {
|
|
11910
|
-
if (
|
|
11916
|
+
if (kp.test(e) || Ap.test(e)) return JSON.stringify({
|
|
11911
11917
|
key: e,
|
|
11912
11918
|
denied: !0,
|
|
11913
11919
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -11917,18 +11923,18 @@ var Op = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
11917
11923
|
key: e,
|
|
11918
11924
|
exists: t !== void 0,
|
|
11919
11925
|
type: typeof t,
|
|
11920
|
-
value:
|
|
11926
|
+
value: Dp(t, 3, 2e3, void 0, Ap)
|
|
11921
11927
|
}, null, 2);
|
|
11922
11928
|
}
|
|
11923
|
-
return JSON.stringify(
|
|
11929
|
+
return JSON.stringify(Op(), null, 2);
|
|
11924
11930
|
}, {
|
|
11925
11931
|
name: "inspect_env",
|
|
11926
11932
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
11927
11933
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
11928
|
-
}),
|
|
11934
|
+
}), Mp = [jp];
|
|
11929
11935
|
//#endregion
|
|
11930
11936
|
//#region src/core/harness/budget.ts
|
|
11931
|
-
function
|
|
11937
|
+
function Np(e, t, n) {
|
|
11932
11938
|
let r = 0;
|
|
11933
11939
|
return {
|
|
11934
11940
|
name: "budget",
|
|
@@ -11953,12 +11959,12 @@ function Mp(e, t, n) {
|
|
|
11953
11959
|
}
|
|
11954
11960
|
//#endregion
|
|
11955
11961
|
//#region src/core/sdk/actions.ts
|
|
11956
|
-
var
|
|
11957
|
-
function
|
|
11962
|
+
var Pp = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
11963
|
+
function Fp(e) {
|
|
11958
11964
|
let n = [];
|
|
11959
11965
|
for (let [i, a] of Object.entries(e)) {
|
|
11960
|
-
if (!
|
|
11961
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
11966
|
+
if (!Pp.test(i)) {
|
|
11967
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${Pp}),已跳过`);
|
|
11962
11968
|
continue;
|
|
11963
11969
|
}
|
|
11964
11970
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -11978,9 +11984,9 @@ function Pp(e) {
|
|
|
11978
11984
|
}
|
|
11979
11985
|
return n;
|
|
11980
11986
|
}
|
|
11981
|
-
function
|
|
11987
|
+
function Ip(e) {
|
|
11982
11988
|
let t = {};
|
|
11983
|
-
for (let [n, r] of Object.entries(e))
|
|
11989
|
+
for (let [n, r] of Object.entries(e)) Pp.test(n) && (t[n] = {
|
|
11984
11990
|
description: r.description,
|
|
11985
11991
|
hasParams: !!r.params
|
|
11986
11992
|
});
|
|
@@ -11988,12 +11994,12 @@ function Fp(e) {
|
|
|
11988
11994
|
}
|
|
11989
11995
|
//#endregion
|
|
11990
11996
|
//#region src/core/toolsets.ts
|
|
11991
|
-
var
|
|
11992
|
-
function
|
|
11997
|
+
var Lp = sp, Rp = pp;
|
|
11998
|
+
function zp(e, t) {
|
|
11993
11999
|
return rd(e, t);
|
|
11994
12000
|
}
|
|
11995
|
-
function
|
|
11996
|
-
let a =
|
|
12001
|
+
function Bp(e, t, n, r, i) {
|
|
12002
|
+
let a = $f(e);
|
|
11997
12003
|
return [
|
|
11998
12004
|
...a.dataOps ? t : [],
|
|
11999
12005
|
...a.fetch ? n : [],
|
|
@@ -12003,7 +12009,7 @@ function zp(e, t, n, r, i) {
|
|
|
12003
12009
|
}
|
|
12004
12010
|
//#endregion
|
|
12005
12011
|
//#region src/core/sdk/toolRegistry.ts
|
|
12006
|
-
function
|
|
12012
|
+
function Vp(e) {
|
|
12007
12013
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
12008
12014
|
for (let r of e) for (let e of r.tools) {
|
|
12009
12015
|
let i = t.get(e.name);
|
|
@@ -12023,15 +12029,15 @@ function Bp(e) {
|
|
|
12023
12029
|
}
|
|
12024
12030
|
//#endregion
|
|
12025
12031
|
//#region src/core/harness/usageHints.ts
|
|
12026
|
-
var
|
|
12027
|
-
function
|
|
12028
|
-
let r =
|
|
12032
|
+
var Hp = .7;
|
|
12033
|
+
function Up(e, t, n) {
|
|
12034
|
+
let r = $f(e);
|
|
12029
12035
|
return {
|
|
12030
12036
|
name: "usageHints",
|
|
12031
12037
|
augmentPrompt: (i) => {
|
|
12032
12038
|
let a = [];
|
|
12033
12039
|
if (r.planning && (a.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), a.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), a.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), a.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), a.push(" · update_todo 标 completed 时附 evidence: 本次实际写入的 jsonPath(如 \"components.2\"),供收口对账;工作经委派子 agent 完成等无主写路径时,如实写明完成方式(勿编造路径)。"), e?.humanConfirm ? a.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : a.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), a.push(" · 计划修订有次数上限(maxPlanRevisions,默认 5,只计 write_todos 调用、调研轮不计):勿反复改计划而不执行,规划充分后即开始 write 落地。")), t && (a.push("改主数据前先 read({jsonPath}) 读其当前真实值(返回末尾 hash=xxx 为乐观锁标识),基于真实值改,不要凭记忆。写入是否被自动校验由集成方 conflictWatchFields 声明决定:若已声明且主数据在你 read 之后被外部改过,会触发冲突——集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 read 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 read 拿最新值再改。"), a.push("不确定主数据字段结构时用 describe_data 查看说明。"), a.push("修改大对象/数组优先用 write 增量改({patch:{op,jsonPath,value}} 只发改动部分),避免 write({value}) 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), a.push("修改主数据出错时可用 restore_data 回退最近一次。"), a.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 write({patch}) 改。"), a.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), a.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), a.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), a.push("【省轮次·批量】≥2 个路径一律 read({jsonPaths:[...]}) 一次取回(路径互不相关也合批,禁止连续单路径 read);改多处用 write({patches:[{op:\"set\",jsonPath,value},...]}) 一次提交多改动(原子任一失败回滚),勿逐个 write 烧轮次预算。"), a.push("读到 <subtree Nkb keys:[…] #指纹> 或 <code Nkb> 占位 = 该子树键名/体积可见但内容未见:写入前先窄读全文(read({jsonPath:\"该子树路径\"}),结果根豁免返全文)或 set_focus 聚焦该区域;勿凭键名印象猜路径/猜值直写(直接写占位子树会被拦下要求先窄读)。"), a.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。")), r.subagent && a.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), r.inspectEnv && a.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), r.domInspect && a.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
|
|
12034
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
12040
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= Hp || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < Hp && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
12035
12041
|
a.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (a.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), a.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && a.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), a.push(" · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), a.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
12036
12042
|
}
|
|
12037
12043
|
e?.humanConfirm && (a.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), a.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), a.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), a.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), a.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), a.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
@@ -12051,7 +12057,7 @@ function Hp(e, t, n) {
|
|
|
12051
12057
|
}
|
|
12052
12058
|
//#endregion
|
|
12053
12059
|
//#region src/core/harness/resourcesPin.ts
|
|
12054
|
-
function
|
|
12060
|
+
function Wp(e) {
|
|
12055
12061
|
return {
|
|
12056
12062
|
name: "resourcesPin",
|
|
12057
12063
|
augmentPrompt: () => {
|
|
@@ -12065,15 +12071,15 @@ function Up(e) {
|
|
|
12065
12071
|
}
|
|
12066
12072
|
//#endregion
|
|
12067
12073
|
//#region src/core/backends/skillStore.ts
|
|
12068
|
-
var
|
|
12069
|
-
function
|
|
12070
|
-
return `${
|
|
12074
|
+
var Gp = "v:1::skill-store", Kp = "chat-sdk";
|
|
12075
|
+
function qp(e, t, n) {
|
|
12076
|
+
return `${Gp}::${e}::${t}::${n}`;
|
|
12071
12077
|
}
|
|
12072
|
-
function
|
|
12073
|
-
return `${
|
|
12078
|
+
function Jp(e, t) {
|
|
12079
|
+
return `${Gp}::${e}::${t}::`;
|
|
12074
12080
|
}
|
|
12075
|
-
function
|
|
12076
|
-
let t = e.dbName ??
|
|
12081
|
+
function Yp(e = {}) {
|
|
12082
|
+
let t = e.dbName ?? Kp, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
12077
12083
|
a = e;
|
|
12078
12084
|
});
|
|
12079
12085
|
return (async () => {
|
|
@@ -12095,36 +12101,36 @@ function Jp(e = {}) {
|
|
|
12095
12101
|
ready: o,
|
|
12096
12102
|
async list() {
|
|
12097
12103
|
let e = [];
|
|
12098
|
-
return await i.scan(
|
|
12104
|
+
return await i.scan(Jp(t, r), (t, n) => {
|
|
12099
12105
|
e.push(n);
|
|
12100
12106
|
}), e;
|
|
12101
12107
|
},
|
|
12102
12108
|
async get(e) {
|
|
12103
|
-
return await i.get(
|
|
12109
|
+
return await i.get(qp(t, r, e));
|
|
12104
12110
|
},
|
|
12105
12111
|
async put(e) {
|
|
12106
12112
|
try {
|
|
12107
|
-
await i.set(
|
|
12113
|
+
await i.set(qp(t, r, e.name), e);
|
|
12108
12114
|
} catch (e) {
|
|
12109
12115
|
Ff(e) && (i = Uf());
|
|
12110
12116
|
}
|
|
12111
12117
|
},
|
|
12112
12118
|
async remove(e) {
|
|
12113
|
-
let n =
|
|
12119
|
+
let n = qp(t, r, e);
|
|
12114
12120
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
12115
12121
|
},
|
|
12116
12122
|
async clear() {
|
|
12117
|
-
await i.clearPrefix(
|
|
12123
|
+
await i.clearPrefix(Jp(t, r));
|
|
12118
12124
|
},
|
|
12119
12125
|
dispose() {}
|
|
12120
12126
|
};
|
|
12121
12127
|
}
|
|
12122
|
-
var
|
|
12123
|
-
function
|
|
12128
|
+
var Xp = /large_results\/[^\s"'`),]+\.txt/g;
|
|
12129
|
+
function Zp(e) {
|
|
12124
12130
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
12125
12131
|
if (typeof e != "string" || !e) return;
|
|
12126
12132
|
let n;
|
|
12127
|
-
for (
|
|
12133
|
+
for (Xp.lastIndex = 0; (n = Xp.exec(e)) !== null;) t.add(n[0]);
|
|
12128
12134
|
};
|
|
12129
12135
|
for (let r of e) {
|
|
12130
12136
|
if (n(r.content), r.steps) for (let e of r.steps) n(e.result);
|
|
@@ -12132,14 +12138,14 @@ function Xp(e) {
|
|
|
12132
12138
|
}
|
|
12133
12139
|
return t;
|
|
12134
12140
|
}
|
|
12135
|
-
function
|
|
12141
|
+
function Qp(e, t) {
|
|
12136
12142
|
let n = [];
|
|
12137
12143
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
12138
12144
|
return n;
|
|
12139
12145
|
}
|
|
12140
12146
|
//#endregion
|
|
12141
12147
|
//#region src/core/utils/serialRunner.ts
|
|
12142
|
-
function
|
|
12148
|
+
function $p() {
|
|
12143
12149
|
let e = Promise.resolve();
|
|
12144
12150
|
return function(t) {
|
|
12145
12151
|
let n = e.then(t, t);
|
|
@@ -12148,24 +12154,24 @@ function Qp() {
|
|
|
12148
12154
|
}
|
|
12149
12155
|
//#endregion
|
|
12150
12156
|
//#region src/core/sdk/createChatSdk.ts
|
|
12151
|
-
var
|
|
12152
|
-
function
|
|
12157
|
+
var em = 30, tm = /* @__PURE__ */ new Map();
|
|
12158
|
+
function nm(e, t) {
|
|
12153
12159
|
return e === "restore_data" ? "restore" : e === "write" ? t?.del ? "delete" : t?.patch ? "edit" : "set" : null;
|
|
12154
12160
|
}
|
|
12155
|
-
function
|
|
12161
|
+
function rm(e) {
|
|
12156
12162
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
12157
12163
|
}
|
|
12158
|
-
function
|
|
12164
|
+
function im(e, t, n, r) {
|
|
12159
12165
|
let i = 0;
|
|
12160
12166
|
return {
|
|
12161
12167
|
name: "sdk-events",
|
|
12162
12168
|
wrapToolCall: async (t, r) => {
|
|
12163
|
-
let i = await r(t), a =
|
|
12169
|
+
let i = await r(t), a = nm(t.name, t.args);
|
|
12164
12170
|
return a ? e({
|
|
12165
12171
|
type: "data_change",
|
|
12166
12172
|
operation: a,
|
|
12167
12173
|
value: n()?.bind
|
|
12168
|
-
}) : i.status === "done" &&
|
|
12174
|
+
}) : i.status === "done" && rm(t.name) && e({
|
|
12169
12175
|
type: "data_change",
|
|
12170
12176
|
operation: "edit",
|
|
12171
12177
|
value: n()?.bind
|
|
@@ -12193,7 +12199,7 @@ function rm(e, t, n, r) {
|
|
|
12193
12199
|
}
|
|
12194
12200
|
};
|
|
12195
12201
|
}
|
|
12196
|
-
function
|
|
12202
|
+
function am(e, t, n, r, i) {
|
|
12197
12203
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
12198
12204
|
ok: !1,
|
|
12199
12205
|
error: "capabilities.focus 关闭"
|
|
@@ -12211,16 +12217,16 @@ function im(e, t, n, r, i) {
|
|
|
12211
12217
|
error: "当前无主数据 schema,无法聚焦"
|
|
12212
12218
|
});
|
|
12213
12219
|
}
|
|
12214
|
-
function
|
|
12220
|
+
function om(e, n) {
|
|
12215
12221
|
let i = {
|
|
12216
12222
|
prompt_tokens: 0,
|
|
12217
12223
|
completion_tokens: 0,
|
|
12218
12224
|
total_tokens: 0
|
|
12219
|
-
}, a = xf(() => J, () => e.conflictPolicy ?? "ask"), o = /* @__PURE__ */ Lt(0), s =
|
|
12225
|
+
}, a = xf(() => J, () => e.conflictPolicy ?? "ask"), o = /* @__PURE__ */ Lt(0), s = Xf(e.storage);
|
|
12220
12226
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
12221
12227
|
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } = bf(e), f = c;
|
|
12222
12228
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", f), f.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${f.contextWindow} 小于最小支持 ${p}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
12223
|
-
let h =
|
|
12229
|
+
let h = rp(e, f.contextWindow), g = h.enableLLMSummary !== !1, _ = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? np[e.contextPreset ?? "auto"], v = new Set(_), y = e.llm;
|
|
12224
12230
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
12225
12231
|
let b = /* @__PURE__ */ Et([]), x = fu(e.vfs?.initialFiles, {
|
|
12226
12232
|
persist: s ? { save: (e) => {
|
|
@@ -12276,7 +12282,7 @@ function am(e, n) {
|
|
|
12276
12282
|
let M = { current: null }, N = e.data ? {
|
|
12277
12283
|
...e.data,
|
|
12278
12284
|
description: e.data.description ?? "主数据对象"
|
|
12279
|
-
} : void 0, P = !(e.subagents ?? []).some((e) => e._codeAsset) &&
|
|
12285
|
+
} : void 0, P = !(e.subagents ?? []).some((e) => e._codeAsset) && $f(e.capabilities).subagent, ie = e.subagents;
|
|
12280
12286
|
P && N?.schema && Xo(N.schema).length && (ie = [...e.subagents ?? [], af()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
12281
12287
|
let F = (ie ?? []).filter((e) => !!e._codeAsset), I = /* @__PURE__ */ new Set();
|
|
12282
12288
|
for (let e of F) {
|
|
@@ -12293,7 +12299,7 @@ function am(e, n) {
|
|
|
12293
12299
|
getTodos: () => M.current?.getState?.()?.todos ?? [],
|
|
12294
12300
|
messages: b,
|
|
12295
12301
|
maxCheckpoints: le && typeof le == "object" ? le.maxCheckpoints : void 0
|
|
12296
|
-
}) : null, de = !le || typeof le != "object" || le.auto !== !1, z =
|
|
12302
|
+
}) : null, de = !le || typeof le != "object" || le.auto !== !1, z = $f(e.capabilities), B = z.dataOps, fe = z.draftWrite, pe = z.automation, me = cu({
|
|
12297
12303
|
...e,
|
|
12298
12304
|
locale: e.i18n?.locale
|
|
12299
12305
|
});
|
|
@@ -12310,7 +12316,7 @@ function am(e, n) {
|
|
|
12310
12316
|
vfsStore: fe || N?.resources?.length ? x : void 0,
|
|
12311
12317
|
...se.length ? { pgIdPaths: se } : {},
|
|
12312
12318
|
...ce.length ? { largeTextPaths: ce } : {}
|
|
12313
|
-
}) : [], he = B ? V : [], H = B && N ? V.controller ?? null : null, ge = B && N?.resources?.length && H?.getResourcesSnapshot ?
|
|
12319
|
+
}) : [], he = B ? V : [], H = B && N ? V.controller ?? null : null, ge = B && N?.resources?.length && H?.getResourcesSnapshot ? Wp({ getResourcesSnapshot: () => H?.getResourcesSnapshot?.() ?? [] }) : void 0, U = () => H?.get() ?? N, _e = new Set(V.map((e) => e.name)), ve = e.conflictWatchFields ?? [], ye = !ve.includes("*") && ve.length ? new Set(ve) : void 0, be = H ? Fd({
|
|
12314
12320
|
getBind: () => U()?.bind,
|
|
12315
12321
|
recomputeAll: () => H.recomputeAllBaselines?.(),
|
|
12316
12322
|
hasBaselines: () => H.hasBaselines?.() ?? !1,
|
|
@@ -12327,15 +12333,15 @@ function am(e, n) {
|
|
|
12327
12333
|
}
|
|
12328
12334
|
}), Vt(n));
|
|
12329
12335
|
}
|
|
12330
|
-
}) : void 0, W = /* @__PURE__ */ new Map(), xe =
|
|
12331
|
-
...
|
|
12332
|
-
|
|
12333
|
-
|
|
12334
|
-
] :
|
|
12336
|
+
}) : void 0, W = /* @__PURE__ */ new Map(), xe = Bp(z, he, sp, z.domInspect && !z.skills ? [
|
|
12337
|
+
...pp,
|
|
12338
|
+
Cp,
|
|
12339
|
+
wp
|
|
12340
|
+
] : pp, Mp);
|
|
12335
12341
|
xe.forEach((e) => W.set(e.name, "builtin"));
|
|
12336
12342
|
let Se = [...e.tools || []];
|
|
12337
12343
|
Se.forEach((e) => W.set(e.name, "user"));
|
|
12338
|
-
let Ce =
|
|
12344
|
+
let Ce = Fp(e.actions ?? {});
|
|
12339
12345
|
Ce.forEach((e) => W.set(e.name, "action"));
|
|
12340
12346
|
let we = [], Te = !1, Ee = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), De = Ee ? Cl() : null;
|
|
12341
12347
|
De && W.set(xl, "builtin");
|
|
@@ -12408,7 +12414,7 @@ function am(e, n) {
|
|
|
12408
12414
|
let G = [], Fe = /* @__PURE__ */ new Map(), K = Ie();
|
|
12409
12415
|
function Ie() {
|
|
12410
12416
|
ki(Se), ki(Ce), ki(G);
|
|
12411
|
-
let { tools: e, collisions: t } =
|
|
12417
|
+
let { tools: e, collisions: t } = Vp([
|
|
12412
12418
|
{
|
|
12413
12419
|
label: "builtin",
|
|
12414
12420
|
tools: xe
|
|
@@ -12556,8 +12562,8 @@ function am(e, n) {
|
|
|
12556
12562
|
} : void 0
|
|
12557
12563
|
}) : void 0, pt = Xe ? $l({
|
|
12558
12564
|
contextWindow: f.contextWindow,
|
|
12559
|
-
thresholdRatio:
|
|
12560
|
-
}) : void 0, mt =
|
|
12565
|
+
thresholdRatio: rp(e, f.contextWindow).summaryThresholdRatio
|
|
12566
|
+
}) : void 0, mt = Up({
|
|
12561
12567
|
...z,
|
|
12562
12568
|
humanConfirm: Ee,
|
|
12563
12569
|
subagents: oe?.map(lt)
|
|
@@ -12577,7 +12583,7 @@ function am(e, n) {
|
|
|
12577
12583
|
return;
|
|
12578
12584
|
}
|
|
12579
12585
|
}
|
|
12580
|
-
} : null, _t =
|
|
12586
|
+
} : null, _t = ep(e.onEvent), J = _t.emit, vt, yt = [], bt = (e) => ({
|
|
12581
12587
|
name: e.name,
|
|
12582
12588
|
description: e.description,
|
|
12583
12589
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -12585,7 +12591,7 @@ function am(e, n) {
|
|
|
12585
12591
|
name: e.name,
|
|
12586
12592
|
description: e.description,
|
|
12587
12593
|
getContent: () => e.content
|
|
12588
|
-
}), St = e.skillStorage === !1 ? null :
|
|
12594
|
+
}), St = e.skillStorage === !1 ? null : Yp({
|
|
12589
12595
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
12590
12596
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
12591
12597
|
}), Ct = () => {
|
|
@@ -12617,14 +12623,14 @@ function am(e, n) {
|
|
|
12617
12623
|
decideInvoke: d,
|
|
12618
12624
|
getSnapshot: () => pt?.getSnapshot()
|
|
12619
12625
|
} : {}
|
|
12620
|
-
}) : void 0, Dt =
|
|
12626
|
+
}) : void 0, Dt = ap([
|
|
12621
12627
|
...ht ? [ht] : [],
|
|
12622
12628
|
mt,
|
|
12623
12629
|
...Re ? [T] : [],
|
|
12624
12630
|
E,
|
|
12625
12631
|
D,
|
|
12626
12632
|
...Le ? [w] : [],
|
|
12627
|
-
...Be ? [vt = _c([...z.domInspect && !(e.skills || []).some((e) => e.name ===
|
|
12633
|
+
...Be ? [vt = _c([...z.domInspect && !(e.skills || []).some((e) => e.name === Tp.name) ? [Tp] : [], ...e.skills || []], {
|
|
12628
12634
|
readVfs: Ve ? (e) => x.files[e]?.content : void 0,
|
|
12629
12635
|
onToolsReady: (e, t) => {
|
|
12630
12636
|
for (let n of t) {
|
|
@@ -12654,12 +12660,12 @@ function am(e, n) {
|
|
|
12654
12660
|
...gt ? [gt] : [],
|
|
12655
12661
|
...pt ? [pt] : [],
|
|
12656
12662
|
...e.middleware || [],
|
|
12657
|
-
...pe ? [
|
|
12663
|
+
...pe ? [Np(i, {
|
|
12658
12664
|
tokenBudget: e.tokenBudget,
|
|
12659
12665
|
timeBudgetMs: e.timeBudgetMs
|
|
12660
12666
|
}, J)] : [],
|
|
12661
|
-
|
|
12662
|
-
]), Ot = e.maxMemoryRounds ??
|
|
12667
|
+
im(J, b, U, i)
|
|
12668
|
+
]), Ot = e.maxMemoryRounds ?? em;
|
|
12663
12669
|
function kt(e) {
|
|
12664
12670
|
return (e) => {
|
|
12665
12671
|
e.type !== "approval_request" && J(e);
|
|
@@ -12673,7 +12679,7 @@ function am(e, n) {
|
|
|
12673
12679
|
e.debug && console.warn("[page-agent-sdk][persist] refreshSessions 失败(已吞):", t);
|
|
12674
12680
|
}
|
|
12675
12681
|
}
|
|
12676
|
-
let Mt =
|
|
12682
|
+
let Mt = $p(), Nt = /* @__PURE__ */ new Set();
|
|
12677
12683
|
function Y(e) {
|
|
12678
12684
|
let t = new AbortController(), n = () => t.abort();
|
|
12679
12685
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), Nt.add(t), {
|
|
@@ -12782,7 +12788,7 @@ function am(e, n) {
|
|
|
12782
12788
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
12783
12789
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
12784
12790
|
}
|
|
12785
|
-
x?.setProtectedRefs?.(
|
|
12791
|
+
x?.setProtectedRefs?.(Zp(b));
|
|
12786
12792
|
let i = pe ? t.maxAutoRetries ?? 1 : 0, o = 0, c = !1, l = kt(t.signal);
|
|
12787
12793
|
if (t.signal) {
|
|
12788
12794
|
let e = () => a.resolve("keep_external");
|
|
@@ -12857,7 +12863,7 @@ function am(e, n) {
|
|
|
12857
12863
|
if (await X.initDone, !e.length) return [];
|
|
12858
12864
|
if (X.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
12859
12865
|
let r = [], i = kt(n);
|
|
12860
|
-
if (x?.setProtectedRefs?.(
|
|
12866
|
+
if (x?.setProtectedRefs?.(Zp(b)), n) {
|
|
12861
12867
|
let e = () => a.resolve("keep_external");
|
|
12862
12868
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
12863
12869
|
}
|
|
@@ -13004,7 +13010,7 @@ function am(e, n) {
|
|
|
13004
13010
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
13005
13011
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
13006
13012
|
}
|
|
13007
|
-
x?.setProtectedRefs?.(
|
|
13013
|
+
x?.setProtectedRefs?.(Zp(e));
|
|
13008
13014
|
let i = (e) => {
|
|
13009
13015
|
t?.(e), J(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && X.infoTick.value++;
|
|
13010
13016
|
};
|
|
@@ -13019,7 +13025,7 @@ function am(e, n) {
|
|
|
13019
13025
|
if (X.refCount--, X.refCount <= 0) {
|
|
13020
13026
|
Pt(), Te = !0, s && (x.flush?.(), s.flush(), s.dispose()), St && St.dispose();
|
|
13021
13027
|
let e = X.mcpClosers.splice(0);
|
|
13022
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
13028
|
+
e.length && Promise.allSettled(e.map((e) => e())), tm.delete(n);
|
|
13023
13029
|
}
|
|
13024
13030
|
},
|
|
13025
13031
|
resolveConflict: a.resolve,
|
|
@@ -13130,7 +13136,7 @@ function am(e, n) {
|
|
|
13130
13136
|
workingMemory: ze ? j.getWorkingMemory() : void 0,
|
|
13131
13137
|
focus: ke ? A.getFocus() : void 0,
|
|
13132
13138
|
focuses: ke ? A.getFocuses() : [],
|
|
13133
|
-
actions:
|
|
13139
|
+
actions: Ip(e.actions ?? {}),
|
|
13134
13140
|
subagent: {
|
|
13135
13141
|
enabled: !!nt,
|
|
13136
13142
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -13217,11 +13223,11 @@ function am(e, n) {
|
|
|
13217
13223
|
return ke ? A.getFocuses() : [];
|
|
13218
13224
|
},
|
|
13219
13225
|
setFocus(t) {
|
|
13220
|
-
let n =
|
|
13226
|
+
let n = am(t, "setFocus", ke, () => U()?.schema, e.debug);
|
|
13221
13227
|
return n.ok ? (A.setFocus(t), e.debug && A.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), X.infoTick.value++, { ok: !0 }) : n;
|
|
13222
13228
|
},
|
|
13223
13229
|
addFocus(t) {
|
|
13224
|
-
let n =
|
|
13230
|
+
let n = am(t, "addFocus", ke, () => U()?.schema, e.debug);
|
|
13225
13231
|
return n.ok ? A.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
13226
13232
|
ok: !1,
|
|
13227
13233
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -13271,14 +13277,14 @@ function am(e, n) {
|
|
|
13271
13277
|
}
|
|
13272
13278
|
function Rt(e) {
|
|
13273
13279
|
let t = {};
|
|
13274
|
-
for (let n of
|
|
13280
|
+
for (let n of Zp(e)) {
|
|
13275
13281
|
let e = x.files[n];
|
|
13276
13282
|
e && (t[n] = e.content);
|
|
13277
13283
|
}
|
|
13278
13284
|
return t;
|
|
13279
13285
|
}
|
|
13280
13286
|
function zt() {
|
|
13281
|
-
let e =
|
|
13287
|
+
let e = Qp(x.files, Zp(b));
|
|
13282
13288
|
for (let t of e) delete x.files[t];
|
|
13283
13289
|
}
|
|
13284
13290
|
function Bt() {
|
|
@@ -13489,12 +13495,12 @@ function am(e, n) {
|
|
|
13489
13495
|
});
|
|
13490
13496
|
})(), X;
|
|
13491
13497
|
}
|
|
13492
|
-
function
|
|
13498
|
+
function sm(e, t) {
|
|
13493
13499
|
let n = e.id ?? Sf();
|
|
13494
13500
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
13495
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
13496
|
-
o ? a = o : (a =
|
|
13497
|
-
let s = null, c =
|
|
13501
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? tm.get(n) : void 0;
|
|
13502
|
+
o ? a = o : (a = om(e, n), e.shareContext && tm.set(n, a)), a.refCount++;
|
|
13503
|
+
let s = null, c = Zf(e), l = null, u = null;
|
|
13498
13504
|
async function d(n) {
|
|
13499
13505
|
if (await a.initDone, s) {
|
|
13500
13506
|
s.show();
|
|
@@ -13713,7 +13719,7 @@ function om(e, t) {
|
|
|
13713
13719
|
}
|
|
13714
13720
|
//#endregion
|
|
13715
13721
|
//#region src/core/sdk/ragSubagent.ts
|
|
13716
|
-
function
|
|
13722
|
+
function cm(e, t, n, r, i) {
|
|
13717
13723
|
let a = [];
|
|
13718
13724
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
13719
13725
|
let o = [];
|
|
@@ -13728,7 +13734,7 @@ function sm(e, t, n, r, i) {
|
|
|
13728
13734
|
|
|
13729
13735
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
13730
13736
|
}
|
|
13731
|
-
function
|
|
13737
|
+
function lm(e, t, n, r, i) {
|
|
13732
13738
|
let a = [], o = [];
|
|
13733
13739
|
return e && (a.push("- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查"), o.push("- 静态文档(组件库文档 / UI 规范):vfs_grep")), t && (a.push(`- ${r}:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用`), o.push(`- 语义相似(「瀑布流组件」「倒计时」「拼团」):${r}`)), n && (a.push(`- ${i}:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档`), o.push(`- 已知文档 id / URL:${i}`)), a.push("- fetch_document:公网 URL —— 查公开资料"), o.push("- 公开 URL(设计规范网站 / 第三方文档):fetch_document"), `# 知识检索策略(RAG)
|
|
13734
13740
|
|
|
@@ -13745,12 +13751,12 @@ ${a.join("\n")}
|
|
|
13745
13751
|
## 何时用何源
|
|
13746
13752
|
${o.join("\n")}`;
|
|
13747
13753
|
}
|
|
13748
|
-
var
|
|
13754
|
+
var um = {
|
|
13749
13755
|
name: "rag-search",
|
|
13750
13756
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
13751
|
-
getContent: () =>
|
|
13757
|
+
getContent: () => lm(!0, !0, !0, "search_docs", "load_doc")
|
|
13752
13758
|
};
|
|
13753
|
-
function
|
|
13759
|
+
function dm(e, n, i) {
|
|
13754
13760
|
let a = r(async ({ query: e, topK: t }) => {
|
|
13755
13761
|
try {
|
|
13756
13762
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -13768,7 +13774,7 @@ function um(e, n, i) {
|
|
|
13768
13774
|
});
|
|
13769
13775
|
return ki([a]), a;
|
|
13770
13776
|
}
|
|
13771
|
-
function
|
|
13777
|
+
function fm(e, n) {
|
|
13772
13778
|
let i = r(async ({ source: e }) => {
|
|
13773
13779
|
try {
|
|
13774
13780
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -13783,19 +13789,19 @@ function dm(e, n) {
|
|
|
13783
13789
|
});
|
|
13784
13790
|
return ki([i]), i;
|
|
13785
13791
|
}
|
|
13786
|
-
function
|
|
13792
|
+
function pm(e) {
|
|
13787
13793
|
let { retriever: t, loader: n, useVfs: r = !0, id: i = "rag", description: a, topK: o = 5, searchToolName: s = "search_docs", loadToolName: c = "load_doc", maxToolRounds: l = 8, summarization: u, skills: d, extraTools: f } = e;
|
|
13788
13794
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
13789
13795
|
let p = [];
|
|
13790
|
-
t && p.push(
|
|
13796
|
+
t && p.push(dm(s, t, o)), n && p.push(fm(c, n)), f && p.push(...f);
|
|
13791
13797
|
let m = r ? [
|
|
13792
13798
|
"vfs_grep",
|
|
13793
13799
|
"vfs_read",
|
|
13794
13800
|
"vfs_json_read"
|
|
13795
|
-
] : void 0, h =
|
|
13801
|
+
] : void 0, h = cm(r, !!t, !!n, s, c), g = {
|
|
13796
13802
|
name: "rag-search",
|
|
13797
|
-
description:
|
|
13798
|
-
getContent: () =>
|
|
13803
|
+
description: um.description,
|
|
13804
|
+
getContent: () => lm(r, !!t, !!n, s, c)
|
|
13799
13805
|
};
|
|
13800
13806
|
return {
|
|
13801
13807
|
id: i,
|
|
@@ -13810,7 +13816,7 @@ function fm(e) {
|
|
|
13810
13816
|
}
|
|
13811
13817
|
//#endregion
|
|
13812
13818
|
//#region src/core/utils/clipboard.ts
|
|
13813
|
-
async function
|
|
13819
|
+
async function mm(e) {
|
|
13814
13820
|
try {
|
|
13815
13821
|
let t = globalThis.navigator?.clipboard;
|
|
13816
13822
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -13828,8 +13834,8 @@ async function pm(e) {
|
|
|
13828
13834
|
}
|
|
13829
13835
|
//#endregion
|
|
13830
13836
|
//#region src/core/composables/useChat.ts
|
|
13831
|
-
var
|
|
13832
|
-
function
|
|
13837
|
+
var hm = 4e3;
|
|
13838
|
+
function gm(e = {}) {
|
|
13833
13839
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */ Et({
|
|
13834
13840
|
messages: e.messages ?? [],
|
|
13835
13841
|
loading: !1,
|
|
@@ -13909,7 +13915,7 @@ function hm(e = {}) {
|
|
|
13909
13915
|
let t = e.delta || "";
|
|
13910
13916
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
13911
13917
|
let r = (n.subReason || "") + t;
|
|
13912
|
-
n.subReason = r.length >
|
|
13918
|
+
n.subReason = r.length > hm ? r.slice(-4e3) : r;
|
|
13913
13919
|
break;
|
|
13914
13920
|
}
|
|
13915
13921
|
n.children ||= [];
|
|
@@ -14039,7 +14045,7 @@ function hm(e = {}) {
|
|
|
14039
14045
|
}
|
|
14040
14046
|
//#endregion
|
|
14041
14047
|
//#region src/core/components/icons.ts
|
|
14042
|
-
var
|
|
14048
|
+
var _m = {
|
|
14043
14049
|
header: "🤖",
|
|
14044
14050
|
subagent: "🤖",
|
|
14045
14051
|
subagentProgress: "🧬",
|
|
@@ -14050,10 +14056,10 @@ var gm = {
|
|
|
14050
14056
|
recommend: "💡",
|
|
14051
14057
|
conflict: "⚠️"
|
|
14052
14058
|
};
|
|
14053
|
-
function
|
|
14054
|
-
let t = { ...
|
|
14059
|
+
function vm(e) {
|
|
14060
|
+
let t = { ..._m };
|
|
14055
14061
|
if (!e) return t;
|
|
14056
|
-
let n = Object.keys(
|
|
14062
|
+
let n = Object.keys(_m);
|
|
14057
14063
|
for (let r of n) {
|
|
14058
14064
|
let n = e[r];
|
|
14059
14065
|
typeof n == "string" && (t[r] = n);
|
|
@@ -14062,7 +14068,7 @@ function _m(e) {
|
|
|
14062
14068
|
}
|
|
14063
14069
|
//#endregion
|
|
14064
14070
|
//#region src/core/components/messages.ts
|
|
14065
|
-
var
|
|
14071
|
+
var ym = {
|
|
14066
14072
|
defaultTitle: "AI 助手",
|
|
14067
14073
|
inputPlaceholder: "输入消息,Enter 发送...",
|
|
14068
14074
|
newSession: "新建会话",
|
|
@@ -14286,8 +14292,8 @@ var vm = {
|
|
|
14286
14292
|
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
14287
14293
|
codeDemoButton: "按钮",
|
|
14288
14294
|
codeDemoInput: "输入框"
|
|
14289
|
-
},
|
|
14290
|
-
"zh-CN":
|
|
14295
|
+
}, bm = {
|
|
14296
|
+
"zh-CN": ym,
|
|
14291
14297
|
"en-US": {
|
|
14292
14298
|
defaultTitle: "AI Assistant",
|
|
14293
14299
|
inputPlaceholder: "Type a message, Enter to send...",
|
|
@@ -14514,10 +14520,10 @@ var vm = {
|
|
|
14514
14520
|
codeDemoInput: "Input"
|
|
14515
14521
|
}
|
|
14516
14522
|
};
|
|
14517
|
-
function
|
|
14523
|
+
function xm(e = "zh-CN", t) {
|
|
14518
14524
|
let n = {
|
|
14519
|
-
...
|
|
14520
|
-
...
|
|
14525
|
+
...ym,
|
|
14526
|
+
...bm[e]
|
|
14521
14527
|
};
|
|
14522
14528
|
if (!t) return n;
|
|
14523
14529
|
let r = { ...n };
|
|
@@ -14529,9 +14535,9 @@ function bm(e = "zh-CN", t) {
|
|
|
14529
14535
|
}
|
|
14530
14536
|
//#endregion
|
|
14531
14537
|
//#region src/core/composables/chatContext.ts
|
|
14532
|
-
var
|
|
14533
|
-
function
|
|
14534
|
-
let t =
|
|
14538
|
+
var Sm = Symbol("chatContext");
|
|
14539
|
+
function Cm(e = {}) {
|
|
14540
|
+
let t = gm({
|
|
14535
14541
|
fetchResponse: e.fetchResponse,
|
|
14536
14542
|
fetchStream: e.fetchStream,
|
|
14537
14543
|
messages: e.messages,
|
|
@@ -14553,7 +14559,7 @@ function Sm(e = {}) {
|
|
|
14553
14559
|
}, h = /* @__PURE__ */ Lt({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
14554
14560
|
h.value[e] = !g(e);
|
|
14555
14561
|
}, v = /* @__PURE__ */ Lt(!1), y = (e) => {
|
|
14556
|
-
|
|
14562
|
+
mm(e).then((e) => {
|
|
14557
14563
|
e && (v.value = !0, setTimeout(() => {
|
|
14558
14564
|
v.value = !1;
|
|
14559
14565
|
}, 1500));
|
|
@@ -14615,7 +14621,7 @@ function Sm(e = {}) {
|
|
|
14615
14621
|
e.onClearFocus?.();
|
|
14616
14622
|
}, F = (t) => {
|
|
14617
14623
|
e.onFocusChipClick?.(t);
|
|
14618
|
-
}, I =
|
|
14624
|
+
}, I = vm(e.icons), ae = e.locale ?? "zh-CN", oe = xm(ae, e.dialogMessages);
|
|
14619
14625
|
return {
|
|
14620
14626
|
chat: t,
|
|
14621
14627
|
inputText: o,
|
|
@@ -14657,15 +14663,15 @@ function Sm(e = {}) {
|
|
|
14657
14663
|
toolStepView: e.toolStepView
|
|
14658
14664
|
};
|
|
14659
14665
|
}
|
|
14660
|
-
function
|
|
14661
|
-
let e = Gn(
|
|
14666
|
+
function wm() {
|
|
14667
|
+
let e = Gn(Sm);
|
|
14662
14668
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
14663
14669
|
return e;
|
|
14664
14670
|
}
|
|
14665
14671
|
//#endregion
|
|
14666
14672
|
//#region src/core/index.headless.ts
|
|
14667
|
-
function
|
|
14668
|
-
return
|
|
14673
|
+
function Tm(e) {
|
|
14674
|
+
return sm(e);
|
|
14669
14675
|
}
|
|
14670
14676
|
//#endregion
|
|
14671
|
-
export {
|
|
14677
|
+
export { Qf as CAPABILITIES, tp as CONTEXT_PRESETS, lf as CompressDecisionSchema, mp as DEFAULT_COMPUTED_STYLES, Pc as DEFAULT_PROMPT_SOFT_CAP, au as DEFAULT_SYSTEM_PROMPT, id as HTML_VOID_TAGS, xl as HUMAN_CONFIRM_TOOL_NAME, li as ImageInputError, p as MIN_CONTEXT_WINDOW, Ki as MODEL_UNAVAILABLE_GUIDANCE, Nc as SOFT_CAP_MIN_WINDOW, Dc as STOP_WORDS, js as UNSAFE_KEYS, Ip as actionsToInspectInfo, Fp as actionsToTools, ai as agentError, Ql as analyzeContext, Ws as applyPatchToClone, qs as applyPatchToLive, Ku as applyPatchesToBind, Wo as arrayMinLength, ii as asAgentError, Wd as buildCollectorJs, yp as buildCssPath, su as buildDataPrompt, Bd as buildDiagnosticsReport, Gd as buildSandboxSrcdoc, cu as buildSystemPrompt, Sm as chatContextKey, Gu as commitSetToBind, Zd as composeStructureThenRender, bi as compressImage, iu as connectMcp, C as constructLlmFromConfig, S as constructOpenLlmSync, mm as copyText, Po as createAgent, bl as createApprovalMiddleware, Cm as createChatContext, Tm as createChatSdk, jl as createCheckpointManager, Ml as createCheckpointMiddleware, xf as createConflictManager, $l as createContextInspectorMiddleware, rd as createDataOps, tf as createHtmlFormatCheck, Xd as createHtmlRenderCheck, af as createHtmlSubagent, wl as createHumanConfirmMiddleware, Cl as createHumanConfirmTool, Uf as createMemoryBackend, pl as createMemoryMiddleware, u as createProxyLlm, pm as createRagSubagent, Qi as createSandboxRunner, ep as createSdkEvents, $p as createSerialRunner, qf as createSessionStore, Jf as createSessionStoreWithBackend, Yp as createSkillStore, il as createSubagentMiddleware, Bc as createSubagentTracker, sl as createSubagentsMiddleware, Up as createUsageHintsMiddleware, Nl as createVerifyMiddleware, fu as createVfs, Gf as createWebStorageBackend, zl as createWriteBackCheck, qi as decorateModelUnavailable, Is as deepClone, zp as defineDataToolset, rc as defineSkill, of as defineTool, Fs as deleteByPath, uf as deriveTitle, is as describeSchemaNode, bo as detectGarbledToolCall, Zs as diffObjects, wp as domInfoTool, Tp as domInspectSkill, Cp as domSearchTool, dp as domToStructure, pp as domTools, Rp as domToolsStatic, Go as elementSchemaCandidates, _p as ensureDomListenerRecorder, kc as estimateMessageTokens, Ac as estimateRoundTokens, h as estimateTokens, T as extractReasoningDelta, _s as extractSchemaHint, eu as extractText, w as extractTextDelta, E as extractUsage, sp as fetchDocTools, Lp as fetchTools, Xs as findStrippedKeys, as as formatConstraints, ei as formatZodIssues, Q as getByPath, fp as getDomTool, Sp as getElementInfo, Op as getEnvSummary, vp as getRecordedListeners, Jd as getSandboxLifecycle, Ro as getSchemaAtPath, Fo as getSchemaTopKeys, Hs as hashValue, fs as htmlOrchestratorPrompt, jc as indexSummarize, jp as inspectEnvTool, Mp as inspectTools, df as isChatModel, Wi as isContextLengthError, Gi as isModelUnavailableError, Io as isPathAllowed, Ff as isQuotaError, Ms as isUnsafePath, ca as jpEval, ni as jsonParseError, Bs as limitDepth, Rd as maskUrlCredentials, Rs as maybeParseValue, Md as measureWriteScale, Ud as normalizeRenderResult, ee as normalizeUsage, _ as offloadPassThroughChars, g as offloadThresholdChars, ds as presets, Qo as projectBySchema, Zo as projectBySchemaDeep, zs as projectFields, Mc as recallRounds, Yd as renderInSandbox, os as renderSchemaHint, ss as renderSchemaOverview, us as renderSchemaShallow, $f as resolveCapabilities, rp as resolveContextOptions, Zf as resolveDialogConfig, bf as resolveLlm, m as resolveModelCaps, Fc as resolvePromptSoftCap, Vo as resolveSchemaPath, Xf as resolveStorage, Ys as restoreInPlace, Js as restoreLive, ri as routeError, fa as runSandboxedScript, Ns as safeMerge, Dp as safeSerialize, $ as safeStringify, Uo as schemaHasRefinement, bp as searchDom, ua as searchJson, Bp as selectBuiltinTools, Ps as setByPath, Ic as shouldTriggerCompression, Vd as stringifyDiagnosticsReport, ps as systemPromptHelpers, Oc as tokenize, Z as toolError, Lo as unwrapSchema, gm as useChat, wm as useChatContext, Ho as validateAtPath, od as validateHtmlFormat, Uu as validateRootValueLocally, Wu as validateWriteLocally, Us as watchFieldsHash, e as z, ti as zodError };
|