page-agent-sdk 4.23.3 → 4.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/page-agent-sdk.headless.js +1048 -1018
- package/dist/page-agent-sdk.iife.js +13 -11
- package/dist/page-agent-sdk.js +911 -881
- package/dist/page-agent-sdk.legacy.js +612 -579
- package/dist/page-agent-sdk.umd.cjs +11 -9
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/style.css +1 -1
- package/types/headless.d.ts +6 -2
- package/types/index.d.ts +9 -2
|
@@ -885,7 +885,7 @@ var $t, en, tn, nn, rn, an, on, sn, cn, ln, un, dn, fn, pn, mn, hn, gn, _n, vn,
|
|
|
885
885
|
function ar(e, t, n) {
|
|
886
886
|
e.issues.length && t.issues.push(...Ve(n, e.issues));
|
|
887
887
|
}
|
|
888
|
-
var or, sr, cr, lr, ur, dr, fr,
|
|
888
|
+
var or, sr, cr, lr, ur, dr, fr, pr, mr, hr, gr, R, _r, vr, yr, br, xr, Sr, Cr, wr, Tr, Er, Dr, Or = s((() => {
|
|
889
889
|
x(), ir(), dt(), M(), or = /*@__PURE__*/ p("$ZodCheck", (e, t) => {
|
|
890
890
|
var n;
|
|
891
891
|
e._zod != null || (e._zod = {}), e._zod.def = t, (n = e._zod).onattach != null || (n.onattach = []);
|
|
@@ -1032,7 +1032,7 @@ var or, sr, cr, lr, ur, dr, fr, R, pr, mr, hr, gr, _r, vr, yr, br, xr, Sr, Cr, w
|
|
|
1032
1032
|
continue: !t.abort
|
|
1033
1033
|
});
|
|
1034
1034
|
};
|
|
1035
|
-
}),
|
|
1035
|
+
}), pr = /*@__PURE__*/ p("$ZodCheckMaxSize", (e, t) => {
|
|
1036
1036
|
var n;
|
|
1037
1037
|
or.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
|
|
1038
1038
|
let t = e.value;
|
|
@@ -1053,7 +1053,7 @@ var or, sr, cr, lr, ur, dr, fr, R, pr, mr, hr, gr, _r, vr, yr, br, xr, Sr, Cr, w
|
|
|
1053
1053
|
continue: !t.abort
|
|
1054
1054
|
});
|
|
1055
1055
|
};
|
|
1056
|
-
}),
|
|
1056
|
+
}), mr = /*@__PURE__*/ p("$ZodCheckMinSize", (e, t) => {
|
|
1057
1057
|
var n;
|
|
1058
1058
|
or.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
|
|
1059
1059
|
let t = e.value;
|
|
@@ -1074,7 +1074,7 @@ var or, sr, cr, lr, ur, dr, fr, R, pr, mr, hr, gr, _r, vr, yr, br, xr, Sr, Cr, w
|
|
|
1074
1074
|
continue: !t.abort
|
|
1075
1075
|
});
|
|
1076
1076
|
};
|
|
1077
|
-
}),
|
|
1077
|
+
}), hr = /*@__PURE__*/ p("$ZodCheckSizeEquals", (e, t) => {
|
|
1078
1078
|
var n;
|
|
1079
1079
|
or.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
|
|
1080
1080
|
let t = e.value;
|
|
@@ -1100,7 +1100,7 @@ var or, sr, cr, lr, ur, dr, fr, R, pr, mr, hr, gr, _r, vr, yr, br, xr, Sr, Cr, w
|
|
|
1100
1100
|
continue: !t.abort
|
|
1101
1101
|
}));
|
|
1102
1102
|
};
|
|
1103
|
-
}),
|
|
1103
|
+
}), gr = /*@__PURE__*/ p("$ZodCheckMaxLength", (e, t) => {
|
|
1104
1104
|
var n;
|
|
1105
1105
|
or.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
|
|
1106
1106
|
let t = e.value;
|
|
@@ -1123,7 +1123,7 @@ var or, sr, cr, lr, ur, dr, fr, R, pr, mr, hr, gr, _r, vr, yr, br, xr, Sr, Cr, w
|
|
|
1123
1123
|
continue: !t.abort
|
|
1124
1124
|
});
|
|
1125
1125
|
};
|
|
1126
|
-
}),
|
|
1126
|
+
}), R = /*@__PURE__*/ p("$ZodCheckMinLength", (e, t) => {
|
|
1127
1127
|
var n;
|
|
1128
1128
|
or.init(e, t), (n = e._zod.def).when != null || (n.when = (e) => {
|
|
1129
1129
|
let t = e.value;
|
|
@@ -8445,23 +8445,23 @@ function Fs(e, t) {
|
|
|
8445
8445
|
}
|
|
8446
8446
|
// @__NO_SIDE_EFFECTS__
|
|
8447
8447
|
function Is(e, t) {
|
|
8448
|
-
return new
|
|
8448
|
+
return new pr(j(j({ check: "max_size" }, L(t)), {}, { maximum: e }));
|
|
8449
8449
|
}
|
|
8450
8450
|
// @__NO_SIDE_EFFECTS__
|
|
8451
8451
|
function Ls(e, t) {
|
|
8452
|
-
return new
|
|
8452
|
+
return new mr(j(j({ check: "min_size" }, L(t)), {}, { minimum: e }));
|
|
8453
8453
|
}
|
|
8454
8454
|
// @__NO_SIDE_EFFECTS__
|
|
8455
8455
|
function Rs(e, t) {
|
|
8456
|
-
return new
|
|
8456
|
+
return new hr(j(j({ check: "size_equals" }, L(t)), {}, { size: e }));
|
|
8457
8457
|
}
|
|
8458
8458
|
// @__NO_SIDE_EFFECTS__
|
|
8459
8459
|
function zs(e, t) {
|
|
8460
|
-
return new
|
|
8460
|
+
return new gr(j(j({ check: "max_length" }, L(t)), {}, { maximum: e }));
|
|
8461
8461
|
}
|
|
8462
8462
|
// @__NO_SIDE_EFFECTS__
|
|
8463
8463
|
function Bs(e, t) {
|
|
8464
|
-
return new
|
|
8464
|
+
return new R(j(j({ check: "min_length" }, L(t)), {}, { minimum: e }));
|
|
8465
8465
|
}
|
|
8466
8466
|
// @__NO_SIDE_EFFECTS__
|
|
8467
8467
|
function Vs(e, t) {
|
|
@@ -9418,17 +9418,17 @@ var Ine, pc, mc, hc, gc, _c, vc, yc, bc, xc, Sc, Cc, wc, Tc, Ec, Dc, Oc, kc, Ac,
|
|
|
9418
9418
|
$ZodCheckLengthEquals: () => _r,
|
|
9419
9419
|
$ZodCheckLessThan: () => cr,
|
|
9420
9420
|
$ZodCheckLowerCase: () => br,
|
|
9421
|
-
$ZodCheckMaxLength: () =>
|
|
9422
|
-
$ZodCheckMaxSize: () =>
|
|
9421
|
+
$ZodCheckMaxLength: () => gr,
|
|
9422
|
+
$ZodCheckMaxSize: () => pr,
|
|
9423
9423
|
$ZodCheckMimeType: () => Er,
|
|
9424
|
-
$ZodCheckMinLength: () =>
|
|
9425
|
-
$ZodCheckMinSize: () =>
|
|
9424
|
+
$ZodCheckMinLength: () => R,
|
|
9425
|
+
$ZodCheckMinSize: () => mr,
|
|
9426
9426
|
$ZodCheckMultipleOf: () => ur,
|
|
9427
9427
|
$ZodCheckNumberFormat: () => dr,
|
|
9428
9428
|
$ZodCheckOverwrite: () => Dr,
|
|
9429
9429
|
$ZodCheckProperty: () => Tr,
|
|
9430
9430
|
$ZodCheckRegex: () => yr,
|
|
9431
|
-
$ZodCheckSizeEquals: () =>
|
|
9431
|
+
$ZodCheckSizeEquals: () => hr,
|
|
9432
9432
|
$ZodCheckStartsWith: () => Cr,
|
|
9433
9433
|
$ZodCheckStringFormat: () => vr,
|
|
9434
9434
|
$ZodCheckUpperCase: () => xr,
|
|
@@ -57619,6 +57619,36 @@ var d$ = {
|
|
|
57619
57619
|
"5. Prefer incremental write patches (send only the change, e.g. write({ value, patch:{ op, jsonPath } })) over resending the whole large JSON, which risks truncation;",
|
|
57620
57620
|
"6. If a write hits an optimistic-lock conflict (VERSION_CONFLICT returned, or the tool suspends awaiting the user decision): after the tool returns, follow its instruction (keep external → re-read then edit; overwritten/restored → continue from the result); do not abandon the task."
|
|
57621
57621
|
].join("\n"),
|
|
57622
|
+
answerLanes: [
|
|
57623
|
+
"【作答车道:先判问题形态,再选纪律】",
|
|
57624
|
+
"用户的问题分三类,判错车道是最大的答非所问:",
|
|
57625
|
+
"A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)",
|
|
57626
|
+
" → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。",
|
|
57627
|
+
"B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)",
|
|
57628
|
+
" → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,",
|
|
57629
|
+
" 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。",
|
|
57630
|
+
"C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)",
|
|
57631
|
+
" → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。",
|
|
57632
|
+
" 页面没写不构成不答的理由。",
|
|
57633
|
+
"",
|
|
57634
|
+
"出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、",
|
|
57635
|
+
"过渡句一律不标。「没找到」的说明压成一句,不报检索过程。"
|
|
57636
|
+
].join("\n"),
|
|
57637
|
+
answerLanesEn: [
|
|
57638
|
+
"[Answer lanes: classify the question first, then pick the discipline]",
|
|
57639
|
+
"User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:",
|
|
57640
|
+
"A. Asking about page content (\"what does this page say / where is it mentioned / what is the original text / what does this passage mean\")",
|
|
57641
|
+
" → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.",
|
|
57642
|
+
"B. Asking about a concept or term (\"what is X / what does it mean / how do X and Y differ\")",
|
|
57643
|
+
" → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,",
|
|
57644
|
+
" opening with one line like \"Not covered on this page — general explanation:\" — never treat \"it is not on the page\" as the answer.",
|
|
57645
|
+
"C. Asking for your opinion or experience (\"what do you think / in your experience / is it hard to match / which should I choose\")",
|
|
57646
|
+
" → Give your judgment and reasoning directly; keep the notes' stance and your own view separate (\"this page's position is ...; my take is ...\").",
|
|
57647
|
+
" The page not covering it is never a reason to refuse.",
|
|
57648
|
+
"",
|
|
57649
|
+
"Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,",
|
|
57650
|
+
"personal opinions, and transitions get none. Compress \"not found\" statements to one sentence; never narrate the search process."
|
|
57651
|
+
].join("\n"),
|
|
57622
57652
|
htmlPageOrchestrator: u$("html"),
|
|
57623
57653
|
htmlPageProposeFirst: ["【新建/创意类请求】先用简短文字给出 2~3 套方案(每套一两句风格/配色/结构要点),询问用户选哪套;选定前不要委派生成代码、不要写 components。", "【方案切换】已生成某套方案后改选另一套:不重新罗列,直接依据之前描述重新委派生成并覆盖相应组件(委派工具见编排段 use_<id>)。"].join("\n"),
|
|
57624
57654
|
htmlDirectWriteFallback: [
|
|
@@ -67893,14 +67923,14 @@ var IAe = [
|
|
|
67893
67923
|
"你是一个页面内容助手,帮助用户理解、查找与排查其当前所在的网页。",
|
|
67894
67924
|
"你可以经专用工具探查页面:read_page 读页面正文(长文按 hasMore 分页续读)、get_dom 读渲染后结构、dom_search / dom_info 定位元素与查属性" + (e ? "、take_screenshot 截图查看实际渲染效果(视觉问题优先截图,结构推断不能代替)" : "") + ";一切以工具读到的页面实料为准。",
|
|
67895
67925
|
"用户消息可能带 [引用原文] 块(其在页面上选中的文字):优先围绕引用内容作答,需要更多上下文再向外探索(所在小节 → 整页)。",
|
|
67896
|
-
|
|
67926
|
+
d$.answerLanes,
|
|
67897
67927
|
"输出从简:直接说内容,不写过程 —— 不要「我先读一下页面」这类旁白、不要「先给结论/依据是」这类包装、不要解释结论是怎么推出来的、不要「下面分三点/综上」这类套话;出处用句末括注(如「(§小节名)」)带过即可。",
|
|
67898
67928
|
RAe
|
|
67899
67929
|
].join("\n"), VAe = (e) => [
|
|
67900
67930
|
"You are a page content assistant that helps users understand, locate, and troubleshoot the web page they are on.",
|
|
67901
67931
|
"You can inspect the page through dedicated tools: read_page for page text (paginate via hasMore on long documents), get_dom for the rendered structure, dom_search / dom_info to locate elements and read attributes" + (e ? ", and take_screenshot to see the actual rendered appearance (prefer a screenshot for visual questions; structural inference is no substitute)" : "") + "; the page as read by tools is the source of truth.",
|
|
67902
67932
|
"User messages may carry a [quoted text] block (text they selected on the page): answer around the quote first, then explore outward (its section → the whole page) if more context is needed.",
|
|
67903
|
-
|
|
67933
|
+
d$.answerLanesEn,
|
|
67904
67934
|
"Be terse: state the content directly, never narrate process — no \"let me first read the page\" asides, no \"in summary / the evidence is\" packaging, no explaining how you derived the conclusion, no \"here are three points\" preambles; cite sources inline as a short parenthetical such as \"(§ section name)\".",
|
|
67905
67935
|
zAe,
|
|
67906
67936
|
"Respond in English."
|
|
@@ -75418,19 +75448,19 @@ function $Fe(e, t, n, r, i) {
|
|
|
75418
75448
|
});
|
|
75419
75449
|
}
|
|
75420
75450
|
function eIe(e, t, n) {
|
|
75421
|
-
var r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, M, ee, te, P, ne, re, ie, ae, oe, se, ce, F, le, ue, I, de, fe, pe;
|
|
75422
|
-
let
|
|
75451
|
+
var r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, M, ee, te, P, ne, re, ie, ae, oe, se, ce, F, le, ue, I, de, fe, pe, me, he;
|
|
75452
|
+
let ge = {
|
|
75423
75453
|
prompt_tokens: 0,
|
|
75424
75454
|
completion_tokens: 0,
|
|
75425
75455
|
total_tokens: 0
|
|
75426
|
-
},
|
|
75456
|
+
}, _e = jMe(() => Qn, () => {
|
|
75427
75457
|
var t;
|
|
75428
75458
|
return (t = e.conflictPolicy) == null ? "ask" : t;
|
|
75429
75459
|
}, () => {
|
|
75430
75460
|
var e;
|
|
75431
75461
|
return (e = R.agent) == null || (e = e.debugLogs) == null ? void 0 : e.value;
|
|
75432
|
-
}),
|
|
75433
|
-
|
|
75462
|
+
}), ve = /* @__PURE__ */ Iq(0), ye = XMe(e.storage);
|
|
75463
|
+
ye && (e.debug && ye.onEvent((e) => console.log("[page-agent-sdk][storage]", e)), ye.onEvent((e) => {
|
|
75434
75464
|
if (e.type === "quota") {
|
|
75435
75465
|
var t;
|
|
75436
75466
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
@@ -75444,22 +75474,22 @@ function eIe(e, t, n) {
|
|
|
75444
75474
|
});
|
|
75445
75475
|
}
|
|
75446
75476
|
}));
|
|
75447
|
-
let { modelCaps:
|
|
75448
|
-
if (e.debug && console.log("[page-agent-sdk][modelCaps]",
|
|
75477
|
+
let { modelCaps: be, summaryLlmInvoke: xe, titleLlmInvoke: Se, compressDecisionInvoke: Ce } = AMe(e), we = be;
|
|
75478
|
+
if (e.debug && console.log("[page-agent-sdk][modelCaps]", we), we.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${we.contextWindow} 小于最小支持 ${eF}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
75449
75479
|
{
|
|
75450
|
-
var
|
|
75451
|
-
let t = e.llm, n = Q6(t) ? (
|
|
75480
|
+
var Te, Ee, De, Oe, L, ke;
|
|
75481
|
+
let t = e.llm, n = Q6(t) ? (Te = (Ee = t.model) == null ? t.modelName : Ee) == null ? "" : Te : (De = t.model) == null ? "" : De, r = Q6(t) ? (Oe = t.maxTokens) == null ? we.maxOutputTokens : Oe : (L = (ke = t.maxTokens) == null ? nF(t.model) : ke) == null ? we.maxOutputTokens : L, i = iF(n || void 0, we, r);
|
|
75452
75482
|
i && console.warn(i);
|
|
75453
75483
|
}
|
|
75454
|
-
let
|
|
75455
|
-
e.debug && !
|
|
75456
|
-
let
|
|
75457
|
-
persist:
|
|
75458
|
-
|
|
75484
|
+
let Ae = f8(e, we.contextWindow), je = Ae.enableLLMSummary !== !1, Me = (r = e.contextOptions && e.contextOptions.preserveLastToolResults) == null ? nNe[(i = e.contextPreset) == null ? "auto" : i] : r, Ne = new Set(Me), Pe = e.llm;
|
|
75485
|
+
e.debug && !xe && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
75486
|
+
let Fe = /* @__PURE__ */ Tq([]), Ie = YAe((a = e.vfs) == null ? void 0 : a.initialFiles, {
|
|
75487
|
+
persist: ye ? { save: (e) => {
|
|
75488
|
+
Cr.persistSave({ vfs: e });
|
|
75459
75489
|
} } : void 0,
|
|
75460
75490
|
maxBytes: (o = e.vfs) == null ? void 0 : o.maxBytes,
|
|
75461
75491
|
poolBytes: (s = e.vfs) == null ? void 0 : s.poolBytes
|
|
75462
|
-
}),
|
|
75492
|
+
}), Le = CQ([], { maxPlanRevisions: e.maxPlanRevisions }), Re = yTe(), ze = Rwe((e) => {
|
|
75463
75493
|
var t;
|
|
75464
75494
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
75465
75495
|
timestamp: Date.now(),
|
|
@@ -75469,24 +75499,24 @@ function eIe(e, t, n) {
|
|
|
75469
75499
|
preview: e
|
|
75470
75500
|
}
|
|
75471
75501
|
});
|
|
75472
|
-
}),
|
|
75502
|
+
}), Be = xTe(() => {
|
|
75473
75503
|
var e;
|
|
75474
75504
|
(e = R.agent) == null || (e = e.debugLogs) == null || (e = e.value) == null || e.push({
|
|
75475
75505
|
timestamp: Date.now(),
|
|
75476
75506
|
type: "middleware",
|
|
75477
75507
|
data: { stage: "resume_notice" }
|
|
75478
75508
|
});
|
|
75479
|
-
}),
|
|
75480
|
-
|
|
75509
|
+
}), Ve = aNe(), He = (c = e.approval) == null ? void 0 : c.timeoutMs, Ue = He !== void 0 && Number.isFinite(He) && He > 0 ? He : He !== void 0 && (!Number.isFinite(He) || He < 0) ? 0 : 3e4, We = (e) => {
|
|
75510
|
+
Qn({
|
|
75481
75511
|
type: "error",
|
|
75482
75512
|
message: `确认请求(${e.toolName})${Math.round(e.waitedMs / 1e3)}s 无响应已自动拒绝 —— 当前路径无 UI 响应方;可传 approval.timeoutMs 调整(Infinity = 无限等)`,
|
|
75483
75513
|
severity: "observable",
|
|
75484
75514
|
code: "APPROVAL_AUTO_REJECTED",
|
|
75485
75515
|
context: e
|
|
75486
75516
|
});
|
|
75487
|
-
},
|
|
75517
|
+
}, Ge = S1((e) => {
|
|
75488
75518
|
var t;
|
|
75489
|
-
|
|
75519
|
+
Ve.lastPlanConfirmation = e, Cr.persistSave({ planConfirmation: e }), (t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
75490
75520
|
timestamp: Date.now(),
|
|
75491
75521
|
type: "middleware",
|
|
75492
75522
|
data: {
|
|
@@ -75496,97 +75526,97 @@ function eIe(e, t, n) {
|
|
|
75496
75526
|
}
|
|
75497
75527
|
});
|
|
75498
75528
|
}, {
|
|
75499
|
-
timeoutMs:
|
|
75500
|
-
onAutoReject:
|
|
75501
|
-
}),
|
|
75529
|
+
timeoutMs: Ue,
|
|
75530
|
+
onAutoReject: We
|
|
75531
|
+
}), Ke = z$({
|
|
75502
75532
|
getSchema: () => {
|
|
75503
75533
|
var e;
|
|
75504
|
-
return (e =
|
|
75534
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
75505
75535
|
},
|
|
75506
75536
|
getBind: () => {
|
|
75507
75537
|
var e;
|
|
75508
|
-
return (e =
|
|
75538
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75509
75539
|
},
|
|
75510
|
-
onChange: (e) =>
|
|
75540
|
+
onChange: (e) => Qn({
|
|
75511
75541
|
type: "focus_change",
|
|
75512
75542
|
focuses: e
|
|
75513
75543
|
})
|
|
75514
|
-
}),
|
|
75544
|
+
}), qe = (e) => {
|
|
75515
75545
|
var t;
|
|
75516
|
-
let n = TTe((t =
|
|
75546
|
+
let n = TTe((t = wt()) == null ? void 0 : t.bind, e.path);
|
|
75517
75547
|
return n ? j(j({}, e), {}, { pgId: n }) : e;
|
|
75518
|
-
},
|
|
75519
|
-
typeof e.memory == "function" &&
|
|
75520
|
-
let
|
|
75521
|
-
if (
|
|
75522
|
-
var
|
|
75523
|
-
|
|
75524
|
-
}
|
|
75525
|
-
let
|
|
75526
|
-
for (let e of
|
|
75548
|
+
}, Je = lEe(), Ye = v1(e.memory || "");
|
|
75549
|
+
typeof e.memory == "function" && Ye.refresh();
|
|
75550
|
+
let Xe = { current: null }, Ze = e.data ? j(j({}, e.data), {}, { description: (l = e.data.description) == null ? "主数据对象" : l }) : void 0, Qe = !((u = e.subagents) == null ? [] : u).some((e) => e._codeAsset) && d8(e.capabilities).subagent, $e = e.subagents;
|
|
75551
|
+
if (Qe && Ze != null && Ze.schema && e$(Ze.schema).length) {
|
|
75552
|
+
var et;
|
|
75553
|
+
$e = [...(et = e.subagents) == null ? [] : et, hMe()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)");
|
|
75554
|
+
}
|
|
75555
|
+
let tt = ((d = $e) == null ? [] : d).filter((e) => !!e._codeAsset), nt = /* @__PURE__ */ new Set();
|
|
75556
|
+
for (let e of tt) {
|
|
75527
75557
|
if (e._codeAsset.writablePaths.length) continue;
|
|
75528
|
-
let t = e$(
|
|
75558
|
+
let t = e$(Ze == null ? void 0 : Ze.schema, e._codeAsset.codeField);
|
|
75529
75559
|
if (t.length) {
|
|
75530
|
-
var
|
|
75531
|
-
e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), (
|
|
75532
|
-
} else console.warn("[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])"),
|
|
75560
|
+
var rt;
|
|
75561
|
+
e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), (rt = e._rebuildCodeAssetPaths) == null || rt.call(e, t[0]), console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map((e) => `'${e}'`).join(", ")}]`);
|
|
75562
|
+
} else console.warn("[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])"), nt.add(e);
|
|
75533
75563
|
}
|
|
75534
|
-
let
|
|
75564
|
+
let it = nt.size ? tt.filter((e) => !nt.has(e)) : tt, at = nt.size ? ((f = $e) == null ? [] : f).filter((e) => !nt.has(e)) : $e, ot = it.length > 0, st = it.flatMap((e) => e._codeAsset.writablePaths), ct = it.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), lt = e.checkpoint, ut = lt !== void 0 && lt !== !1, dt = ut ? D1({
|
|
75535
75565
|
getData: () => {
|
|
75536
75566
|
var e;
|
|
75537
|
-
return (e =
|
|
75567
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75538
75568
|
},
|
|
75539
75569
|
consumeDataDirty: () => {
|
|
75540
75570
|
var e, t;
|
|
75541
|
-
return (e =
|
|
75571
|
+
return (e = xt == null || (t = xt.consumeDataDirty) == null ? void 0 : t.call(xt)) == null || e;
|
|
75542
75572
|
},
|
|
75543
|
-
slotPaths:
|
|
75544
|
-
vfsStore:
|
|
75545
|
-
todosMw:
|
|
75573
|
+
slotPaths: Ze ? [""] : [],
|
|
75574
|
+
vfsStore: Ie,
|
|
75575
|
+
todosMw: Le,
|
|
75546
75576
|
getTodos: () => {
|
|
75547
75577
|
var e, t, n;
|
|
75548
|
-
return (e = (t =
|
|
75578
|
+
return (e = (t = Xe.current) == null || (n = t.getState) == null || (n = n.call(t)) == null ? void 0 : n.todos) == null ? [] : e;
|
|
75549
75579
|
},
|
|
75550
|
-
messages:
|
|
75551
|
-
maxCheckpoints:
|
|
75552
|
-
}) : null,
|
|
75580
|
+
messages: Fe,
|
|
75581
|
+
maxCheckpoints: lt && typeof lt == "object" ? lt.maxCheckpoints : void 0
|
|
75582
|
+
}) : null, ft = !lt || typeof lt != "object" || lt.auto !== !1, pt = d8(e.capabilities), mt = pt.dataOps, ht = pt.draftWrite, gt = pt.automation, _t = pt.domInspect && (we.vision === !0 || typeof ((p = e.images) == null ? void 0 : p.describe) == "function"), vt = WAe(j(j({}, e), {}, {
|
|
75553
75583
|
locale: (m = e.i18n) == null ? void 0 : m.locale,
|
|
75554
|
-
dataOps:
|
|
75555
|
-
domInspect:
|
|
75556
|
-
screenshot:
|
|
75584
|
+
dataOps: mt && !!Ze,
|
|
75585
|
+
domInspect: pt.domInspect === !0,
|
|
75586
|
+
screenshot: _t
|
|
75557
75587
|
}));
|
|
75558
|
-
if (
|
|
75559
|
-
let e =
|
|
75560
|
-
e && (
|
|
75561
|
-
} else
|
|
75562
|
-
let
|
|
75588
|
+
if (ot) {
|
|
75589
|
+
let e = it.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
75590
|
+
e && (vt += "\n\n" + e);
|
|
75591
|
+
} else Ze != null && Ze.schema && oTe(Ze.schema) && (vt += "\n\n" + d$.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
75592
|
+
let yt = mt && Ze ? P6(Ze, j(j({
|
|
75563
75593
|
onAudit: (h = e.onAudit) == null ? e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0 : h,
|
|
75564
75594
|
maxSnapshots: e.maxSnapshots,
|
|
75565
|
-
onConflict:
|
|
75595
|
+
onConflict: _e.set,
|
|
75566
75596
|
conflictWatchFields: e.conflictWatchFields,
|
|
75567
75597
|
maxParallelTools: e.maxParallelTools,
|
|
75568
|
-
vfsStore:
|
|
75569
|
-
},
|
|
75598
|
+
vfsStore: ht || !(Ze == null || (g = Ze.resources) == null) && g.length ? Ie : void 0
|
|
75599
|
+
}, st.length ? { pgIdPaths: st } : {}), ct.length ? { largeTextPaths: ct } : {})) : [], bt = mt ? yt : [], xt = mt && Ze ? (_ = yt.controller) == null ? null : _ : null, St = mt && Ze ? yt.previewWrite : void 0, Ct = mt && !(Ze == null || (v = Ze.resources) == null) && v.length && xt != null && xt.getResourcesSnapshot ? BFe({ getResourcesSnapshot: () => {
|
|
75570
75600
|
var e, t;
|
|
75571
|
-
return (e =
|
|
75572
|
-
} }) : void 0,
|
|
75601
|
+
return (e = xt == null || (t = xt.getResourcesSnapshot) == null ? void 0 : t.call(xt)) == null ? [] : e;
|
|
75602
|
+
} }) : void 0, wt = () => {
|
|
75573
75603
|
var e;
|
|
75574
|
-
return (e =
|
|
75575
|
-
},
|
|
75604
|
+
return (e = xt == null ? void 0 : xt.get()) == null ? Ze : e;
|
|
75605
|
+
}, Tt = new Set(yt.map((e) => e.name)), Et = (y = e.conflictWatchFields) == null ? [] : y, Dt = !Et.includes("*") && Et.length ? new Set(Et) : void 0, Ot = xt ? qje({
|
|
75576
75606
|
getBind: () => {
|
|
75577
75607
|
var e;
|
|
75578
|
-
return (e =
|
|
75608
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75579
75609
|
},
|
|
75580
75610
|
recomputeAll: () => {
|
|
75581
75611
|
var e;
|
|
75582
|
-
return (e =
|
|
75612
|
+
return (e = xt.recomputeAllBaselines) == null ? void 0 : e.call(xt);
|
|
75583
75613
|
},
|
|
75584
75614
|
hasBaselines: () => {
|
|
75585
75615
|
var e, t;
|
|
75586
|
-
return (e = (t =
|
|
75616
|
+
return (e = (t = xt.hasBaselines) == null ? void 0 : t.call(xt)) != null && e;
|
|
75587
75617
|
},
|
|
75588
|
-
isManaged: (e) =>
|
|
75589
|
-
hash: (e) =>
|
|
75618
|
+
isManaged: (e) => Tt.has(e),
|
|
75619
|
+
hash: (e) => Dt ? D$(C1(e), Dt) : E$(C1(e)),
|
|
75590
75620
|
log: (e, t) => {
|
|
75591
75621
|
var n;
|
|
75592
75622
|
let r = (n = R.agent) == null ? void 0 : n.debugLogs;
|
|
@@ -75596,34 +75626,34 @@ function eIe(e, t, n) {
|
|
|
75596
75626
|
data: j({ stage: "baseline_guard" }, t)
|
|
75597
75627
|
}), zq(r));
|
|
75598
75628
|
}
|
|
75599
|
-
}) : void 0,
|
|
75600
|
-
|
|
75601
|
-
let
|
|
75629
|
+
}) : void 0, kt = /* @__PURE__ */ new Map();
|
|
75630
|
+
pt.domInspect && !_t && console.warn("[page-agent-sdk][take_screenshot] domInspect 已开启但主模型不支持图片(vision=false)且未配 images.describe,截图工具未装载(视觉验证退回 get_dom/dom_info 结构推断;换多模态模型 / llm.vision:true / 配 images.describe 后重建 SDK 生效)");
|
|
75631
|
+
let At = [], jt = (e) => {
|
|
75602
75632
|
if (e.type === "tool_result" && e.name === "take_screenshot") {
|
|
75603
|
-
let t =
|
|
75633
|
+
let t = At.find((e) => !e.eventConsumed);
|
|
75604
75634
|
if (t) return t.eventConsumed = !0, Object.assign(e, { image: {
|
|
75605
75635
|
dataUri: t.image.dataUri,
|
|
75606
75636
|
vfsRef: t.meta.vfsRef
|
|
75607
75637
|
} });
|
|
75608
75638
|
}
|
|
75609
75639
|
return e;
|
|
75610
|
-
},
|
|
75611
|
-
getVision: () =>
|
|
75640
|
+
}, Mt = we.vision === !0 || typeof ((b = e.images) == null ? void 0 : b.describe) == "function" ? DPe({
|
|
75641
|
+
getVision: () => we.vision === !0,
|
|
75612
75642
|
describe: (x = e.images) == null ? void 0 : x.describe,
|
|
75613
75643
|
onShot: (e, t) => {
|
|
75614
|
-
|
|
75644
|
+
At.push({
|
|
75615
75645
|
image: e,
|
|
75616
75646
|
meta: t
|
|
75617
75647
|
});
|
|
75618
75648
|
}
|
|
75619
|
-
}) : void 0,
|
|
75649
|
+
}) : void 0, Nt = _t ? TPe({
|
|
75620
75650
|
render: (S = e.screenshot) == null ? void 0 : S.renderer,
|
|
75621
75651
|
getActiveFocus: () => R.getFocus(),
|
|
75622
75652
|
focusSelector: (C = e.screenshot) == null ? void 0 : C.focusSelector,
|
|
75623
75653
|
stow: (e) => {
|
|
75624
75654
|
if (e.dataUri) try {
|
|
75625
75655
|
let t = `userImages/${e.id}`;
|
|
75626
|
-
return
|
|
75656
|
+
return Ie.files[t] = {
|
|
75627
75657
|
content: e.dataUri,
|
|
75628
75658
|
updatedAt: Date.now()
|
|
75629
75659
|
}, t;
|
|
@@ -75631,30 +75661,30 @@ function eIe(e, t, n) {
|
|
|
75631
75661
|
return;
|
|
75632
75662
|
}
|
|
75633
75663
|
},
|
|
75634
|
-
getVision: () =>
|
|
75664
|
+
getVision: () => we.vision === !0,
|
|
75635
75665
|
describe: (w = e.images) == null ? void 0 : w.describe,
|
|
75636
75666
|
onShot: (e, t) => {
|
|
75637
|
-
|
|
75667
|
+
At.push({
|
|
75638
75668
|
image: e,
|
|
75639
75669
|
meta: t
|
|
75640
75670
|
});
|
|
75641
75671
|
}
|
|
75642
|
-
}) : void 0,
|
|
75672
|
+
}) : void 0, Pt = !Q6(e.llm) && ((T = e.llm.provider) == null ? "openai" : T) === "anthropic" ? "anthropic" : "openai", Ft = Nt || Mt ? {
|
|
75643
75673
|
name: "screenshotChannel",
|
|
75644
75674
|
wrapModelCall: async (e, t) => {
|
|
75645
|
-
if (
|
|
75646
|
-
let t =
|
|
75675
|
+
if (At.length) {
|
|
75676
|
+
let t = At.splice(0), n = wZ(t.map((e, t) => {
|
|
75647
75677
|
var n;
|
|
75648
75678
|
return e.meta.mode === "url" ? `[图片 ${t + 1}] 原图直投 ${(n = e.image.url) == null ? "" : n}(view_image,全分辨率非渲染态)` : `[截图 ${t + 1}] ${e.meta.mode}${e.meta.selector ? ` selector="${e.meta.selector}"` : ""}${e.meta.vfsRef ? `(原图 vfs:${e.meta.vfsRef})` : ""}`;
|
|
75649
75679
|
}).join("\n") + "\n(视觉内容如上,请结合图片回答/继续)", t.map((e) => ({
|
|
75650
75680
|
dataUri: e.image.dataUri,
|
|
75651
75681
|
url: e.image.url
|
|
75652
|
-
})),
|
|
75682
|
+
})), Pt);
|
|
75653
75683
|
n && e.messages.push(new Hy({ content: n }));
|
|
75654
75684
|
}
|
|
75655
75685
|
return t(e);
|
|
75656
75686
|
}
|
|
75657
|
-
} : null,
|
|
75687
|
+
} : null, It = !1, Lt = pt.domEdit ? zPe({
|
|
75658
75688
|
onEdit: (e) => {
|
|
75659
75689
|
var t;
|
|
75660
75690
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
@@ -75666,22 +75696,22 @@ function eIe(e, t, n) {
|
|
|
75666
75696
|
applied: e.applied,
|
|
75667
75697
|
dryRun: e.dryRun
|
|
75668
75698
|
}
|
|
75669
|
-
}), !e.dryRun && e.applied > 0 && (
|
|
75699
|
+
}), !e.dryRun && e.applied > 0 && (It = !0);
|
|
75670
75700
|
},
|
|
75671
75701
|
onRestore: (e) => {
|
|
75672
|
-
e.restored > 0 && (
|
|
75702
|
+
e.restored > 0 && (It = !0);
|
|
75673
75703
|
}
|
|
75674
|
-
}) : [],
|
|
75704
|
+
}) : [], Rt = [...MFe(pt, bt, A8, pt.domInspect ? [
|
|
75675
75705
|
...j8,
|
|
75676
|
-
...
|
|
75677
|
-
...
|
|
75678
|
-
...
|
|
75679
|
-
] : [], TFe), ...
|
|
75680
|
-
|
|
75681
|
-
let
|
|
75706
|
+
...Lt,
|
|
75707
|
+
...Nt ? [Nt] : [],
|
|
75708
|
+
...pt.skills ? [] : [F8, I8]
|
|
75709
|
+
] : [], TFe), ...Mt ? [Mt] : []];
|
|
75710
|
+
Mt && kt.set("view_image", "builtin"), Rt.forEach((e) => kt.set(e.name, "builtin"));
|
|
75711
|
+
let zt = e.proposals ? XPe(e.proposals, {
|
|
75682
75712
|
emit: (e) => {
|
|
75683
75713
|
try {
|
|
75684
|
-
|
|
75714
|
+
Qn(e);
|
|
75685
75715
|
} catch (e) {}
|
|
75686
75716
|
},
|
|
75687
75717
|
log: (e, t) => {
|
|
@@ -75695,21 +75725,21 @@ function eIe(e, t, n) {
|
|
|
75695
75725
|
}, t)
|
|
75696
75726
|
});
|
|
75697
75727
|
}
|
|
75698
|
-
}) : null,
|
|
75699
|
-
|
|
75700
|
-
let
|
|
75701
|
-
|
|
75702
|
-
let
|
|
75703
|
-
|
|
75704
|
-
let
|
|
75705
|
-
let e =
|
|
75706
|
-
return e.length ?
|
|
75728
|
+
}) : null, Bt = [...e.tools || [], ...(E = zt == null ? void 0 : zt.tools) == null ? [] : E];
|
|
75729
|
+
Bt.forEach((e) => kt.set(e.name, "user"));
|
|
75730
|
+
let Vt = DFe((D = e.actions) == null ? {} : D);
|
|
75731
|
+
Vt.forEach((e) => kt.set(e.name, "action"));
|
|
75732
|
+
let Ht = zt ? ((O = e.proposals) == null ? void 0 : O.readToolName) || "read_content" : null, Ut = zt ? ((k = e.proposals) == null ? void 0 : k.toolName) || "propose_content" : null, Wt = /* @__PURE__ */ new Set([...Object.entries((A = e.actions) == null ? {} : A).filter(([, e]) => (e == null ? void 0 : e.readsHostState) === !0).map(([e]) => e), ...Ht ? [Ht] : []]), Gt = /* @__PURE__ */ new Set([...Object.entries((M = e.actions) == null ? {} : M).filter(([, e]) => (e == null ? void 0 : e.deferredWrite) === !0).map(([e]) => e), ...Ut ? [Ut] : []]), Kt = [], qt = !1, Jt = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), Yt = Jt ? x1() : null;
|
|
75733
|
+
Yt && kt.set(b1, "builtin");
|
|
75734
|
+
let Xt = ut && dt ? [qP(async () => {
|
|
75735
|
+
let e = dt.list();
|
|
75736
|
+
return e.length ? dt.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
75707
75737
|
}, {
|
|
75708
75738
|
name: "restore_last_checkpoint",
|
|
75709
75739
|
description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
75710
75740
|
schema: B({}).optional()
|
|
75711
75741
|
}), qP(async () => {
|
|
75712
|
-
let e =
|
|
75742
|
+
let e = dt.list();
|
|
75713
75743
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => {
|
|
75714
75744
|
var t;
|
|
75715
75745
|
return `#${e.id} [${(t = e.label) == null ? "auto" : t}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`;
|
|
@@ -75719,11 +75749,11 @@ function eIe(e, t, n) {
|
|
|
75719
75749
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
75720
75750
|
schema: B({}).optional()
|
|
75721
75751
|
})] : [];
|
|
75722
|
-
|
|
75723
|
-
let
|
|
75752
|
+
Xt.forEach((e) => kt.set(e.name, "builtin"));
|
|
75753
|
+
let Zt = pt.focus, Qt = qP(async ({ path: e, label: t }) => {
|
|
75724
75754
|
var n;
|
|
75725
|
-
let r = (n =
|
|
75726
|
-
return r ? GQ(r, e) ? (
|
|
75755
|
+
let r = (n = wt()) == null ? void 0 : n.schema;
|
|
75756
|
+
return r ? GQ(r, e) ? (Ke.setFocus(qe(j({ path: e }, t ? { label: t } : {})), "agent"), `已聚焦到 ${e}${t ? `(${t})` : ""}。后续仅可写该子树(越界被拒),每轮只看到该组件结构。完成精修后调 clear_focus 退出。`) : `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。` : "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
75727
75757
|
}, {
|
|
75728
75758
|
name: "set_focus",
|
|
75729
75759
|
description: "聚焦到指定组件子树(如 components.3)精修,替换全部已有焦点(非累积;要保留已有焦点追加用 add_focus)。聚焦后:仅可写该子树(越界 PATH_DENIED)+ 每轮只看到该组件结构。多组件页面精修其中一个时用,避免改到别处。先 read 定位 path 再聚焦;完成调 clear_focus。",
|
|
@@ -75731,17 +75761,17 @@ function eIe(e, t, n) {
|
|
|
75731
75761
|
path: z().describe("要聚焦的组件 jsonPath,如 components.3"),
|
|
75732
75762
|
label: z().optional().describe("人类可读标签,如「导航栏」")
|
|
75733
75763
|
})
|
|
75734
|
-
}),
|
|
75764
|
+
}), $t = qP(async () => (Ke.clearFocus("agent"), "已清除聚焦,恢复全量可操作范围(可读写所有组件)。"), {
|
|
75735
75765
|
name: "clear_focus",
|
|
75736
75766
|
description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
|
|
75737
75767
|
schema: B({}).optional()
|
|
75738
|
-
}),
|
|
75768
|
+
}), en = qP(async ({ path: e, label: t }) => {
|
|
75739
75769
|
var n;
|
|
75740
|
-
let r = (n =
|
|
75770
|
+
let r = (n = wt()) == null ? void 0 : n.schema;
|
|
75741
75771
|
if (!r) return "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
75742
75772
|
if (!GQ(r, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
|
|
75743
|
-
|
|
75744
|
-
let i =
|
|
75773
|
+
Ke.addFocus(qe(j({ path: e }, t ? { label: t } : {})), "agent");
|
|
75774
|
+
let i = Ke.getFocuses();
|
|
75745
75775
|
return `已聚焦 ${e}${t ? `(${t})` : ""}(当前共 ${i.length} 个焦点:${i.map((e) => e.path).join(", ")})。后续仅可写这些子树之一(越界被拒)。`;
|
|
75746
75776
|
}, {
|
|
75747
75777
|
name: "add_focus",
|
|
@@ -75750,81 +75780,84 @@ function eIe(e, t, n) {
|
|
|
75750
75780
|
path: z().describe("要追加聚焦的组件 jsonPath,如 components.3"),
|
|
75751
75781
|
label: z().optional().describe("人类可读标签")
|
|
75752
75782
|
})
|
|
75753
|
-
}),
|
|
75754
|
-
let t =
|
|
75755
|
-
|
|
75756
|
-
let n =
|
|
75783
|
+
}), tn = qP(async ({ path: e }) => {
|
|
75784
|
+
let t = Ke.getFocuses().length;
|
|
75785
|
+
Ke.removeFocus(e, "agent");
|
|
75786
|
+
let n = Ke.getFocuses();
|
|
75757
75787
|
return n.length === t ? `path "${e}" 不在当前焦点列表中(当前:${n.map((e) => e.path).join(", ") || "无"})。` : n.length ? `已移除焦点 ${e}(剩余 ${n.length} 个:${n.map((e) => e.path).join(", ")})。` : `已移除焦点 ${e},聚焦已清空,恢复全量操作范围。`;
|
|
75758
75788
|
}, {
|
|
75759
75789
|
name: "remove_focus",
|
|
75760
75790
|
description: "移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。",
|
|
75761
75791
|
schema: B({ path: z().describe("要移除的焦点 jsonPath") })
|
|
75762
|
-
}),
|
|
75763
|
-
Xt,
|
|
75764
|
-
Zt,
|
|
75792
|
+
}), nn = Zt ? [
|
|
75765
75793
|
Qt,
|
|
75766
|
-
$t
|
|
75794
|
+
$t,
|
|
75795
|
+
en,
|
|
75796
|
+
tn
|
|
75767
75797
|
] : [];
|
|
75768
|
-
|
|
75769
|
-
let
|
|
75770
|
-
builtinTools: () =>
|
|
75771
|
-
userTools: () =>
|
|
75772
|
-
actionTools: () =>
|
|
75773
|
-
humanConfirmTool: () =>
|
|
75774
|
-
checkpointTools: () =>
|
|
75775
|
-
focusTools: () =>
|
|
75776
|
-
mcpTools: () =>
|
|
75777
|
-
loadedSkillTools: () =>
|
|
75778
|
-
}),
|
|
75779
|
-
if (
|
|
75780
|
-
if (
|
|
75781
|
-
var
|
|
75782
|
-
for (let e of (
|
|
75783
|
-
}
|
|
75784
|
-
let
|
|
75785
|
-
e.debug &&
|
|
75786
|
-
let
|
|
75787
|
-
|
|
75788
|
-
let
|
|
75789
|
-
|
|
75790
|
-
|
|
75791
|
-
|
|
75792
|
-
|
|
75793
|
-
|
|
75794
|
-
|
|
75795
|
-
|
|
75796
|
-
|
|
75797
|
-
|
|
75798
|
+
nn.forEach((e) => kt.set(e.name, "builtin"));
|
|
75799
|
+
let rn = [], an = /* @__PURE__ */ new Map(), on = lNe({
|
|
75800
|
+
builtinTools: () => Rt,
|
|
75801
|
+
userTools: () => Bt,
|
|
75802
|
+
actionTools: () => Vt,
|
|
75803
|
+
humanConfirmTool: () => Yt,
|
|
75804
|
+
checkpointTools: () => Xt,
|
|
75805
|
+
focusTools: () => nn,
|
|
75806
|
+
mcpTools: () => Kt,
|
|
75807
|
+
loadedSkillTools: () => rn
|
|
75808
|
+
}), sn = on(), cn = pt.planning, ln = pt.missionAnchor, un = pt.workingMemory, dn = pt.skills, fn = pt.vfs || ot;
|
|
75809
|
+
if (fn) for (let e of QAe) kt.set(e, "builtin");
|
|
75810
|
+
if (cn) {
|
|
75811
|
+
var pn;
|
|
75812
|
+
for (let e of (pn = Le.tools) == null ? [] : pn) kt.set(e.name, "builtin");
|
|
75813
|
+
}
|
|
75814
|
+
let mn = pt.summarization, hn = pt.agentCompression && !!Ce;
|
|
75815
|
+
e.debug && pt.agentCompression && !Ce && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
75816
|
+
let gn = pt.memory, _n = pt.subagent, vn = _n ? s1() : void 0, yn = (ee = (te = e.verify) == null ? void 0 : te.maxAttempts) == null ? 2 : ee, bn = !!((P = e.verify) != null && P.check || (ne = e.verify) != null && ne.maxAttempts || (re = e.verify) != null && re.adversarial), xn = ((ie = e.capabilities) == null ? void 0 : ie.verify) === !1, Sn = (pt.verify || bn && !xn) && ((ae = e.verify) == null ? void 0 : ae.enabled) !== !1 && yn > 0, Cn = pt.contextInspector;
|
|
75817
|
+
bn && !Sn && ((oe = e.verify) == null ? void 0 : oe.enabled) !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
|
|
75818
|
+
let wn = e.subagent, Tn = (se = wn == null ? void 0 : wn.allowedTools) == null ? [] : se, En = (ce = e.permissions) != null && ce.length ? hEe(e.permissions) : void 0, Dn = ((F = e.approval) == null ? void 0 : F.preview) === !0 && St ? (e, t) => e === "write" ? St(t) : null : void 0, On = (le = e.approval) != null && le.previewWrite || Dn ? (t, n) => {
|
|
75819
|
+
var r, i, a, o;
|
|
75820
|
+
return (r = (i = (a = e.approval) == null || (o = a.previewWrite) == null ? void 0 : o.call(a, t, n)) == null ? Dn == null ? void 0 : Dn(t, n) : i) == null ? null : r;
|
|
75821
|
+
} : void 0, kn = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? y1(j(j({}, e.approval), {}, {
|
|
75822
|
+
timeoutMs: (ue = e.approval.timeoutMs) == null ? Ue : ue,
|
|
75823
|
+
onAutoReject: We,
|
|
75824
|
+
previewWrite: On
|
|
75825
|
+
})) : void 0, An = [
|
|
75826
|
+
...En ? [En] : [],
|
|
75827
|
+
...kn ? [kn] : [],
|
|
75828
|
+
...Ot ? [Ot] : []
|
|
75829
|
+
], jn = !_n || (wn == null ? void 0 : wn.enabled) === !1 ? void 0 : m1(j(j({
|
|
75830
|
+
llm: (I = wn == null ? void 0 : wn.llm) == null ? e.llm : I,
|
|
75798
75831
|
allTools: () => {
|
|
75799
75832
|
var e, t;
|
|
75800
|
-
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ?
|
|
75833
|
+
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ? sn : e;
|
|
75801
75834
|
},
|
|
75802
|
-
allowedTools:
|
|
75835
|
+
allowedTools: Tn.length ? Tn : void 0
|
|
75803
75836
|
}, e.staleReadInvalidation === void 0 ? {} : { staleReadInvalidation: e.staleReadInvalidation }), {}, {
|
|
75804
|
-
systemPrompt:
|
|
75805
|
-
temperature:
|
|
75806
|
-
maxTokens:
|
|
75807
|
-
skills:
|
|
75808
|
-
maxDepth:
|
|
75809
|
-
maxParallel:
|
|
75810
|
-
thinkingMode:
|
|
75837
|
+
systemPrompt: wn == null ? void 0 : wn.systemPrompt,
|
|
75838
|
+
temperature: wn == null ? void 0 : wn.temperature,
|
|
75839
|
+
maxTokens: wn == null ? void 0 : wn.maxTokens,
|
|
75840
|
+
skills: wn == null ? void 0 : wn.skills,
|
|
75841
|
+
maxDepth: wn == null ? void 0 : wn.maxDepth,
|
|
75842
|
+
maxParallel: wn == null ? void 0 : wn.maxParallel,
|
|
75843
|
+
thinkingMode: wn == null ? void 0 : wn.thinkingMode,
|
|
75811
75844
|
debug: e.debug,
|
|
75812
|
-
getFocuses: () =>
|
|
75845
|
+
getFocuses: () => Ke.getActiveFocuses(),
|
|
75813
75846
|
getSchema: () => {
|
|
75814
75847
|
var e, t;
|
|
75815
|
-
return (e = (t =
|
|
75848
|
+
return (e = (t = wt()) == null ? void 0 : t.schema) == null ? null : e;
|
|
75816
75849
|
},
|
|
75817
|
-
tracker:
|
|
75818
|
-
guardMiddleware:
|
|
75819
|
-
getVfsFiles:
|
|
75820
|
-
enterDataScope:
|
|
75821
|
-
exitDataScope:
|
|
75850
|
+
tracker: vn,
|
|
75851
|
+
guardMiddleware: An.length ? An : void 0,
|
|
75852
|
+
getVfsFiles: fn ? () => Ie.files : void 0,
|
|
75853
|
+
enterDataScope: xt != null && xt.enterScope ? (e) => xt.enterScope(e) : void 0,
|
|
75854
|
+
exitDataScope: xt != null && xt.exitScope ? (e) => xt.exitScope(e) : void 0,
|
|
75822
75855
|
onUsage: (e) => {
|
|
75823
75856
|
var t, n, r, i, a, o, s;
|
|
75824
|
-
|
|
75857
|
+
ge.prompt_tokens = ((t = ge.prompt_tokens) == null ? 0 : t) + ((n = e.prompt_tokens) == null ? 0 : n), ge.completion_tokens = ((r = ge.completion_tokens) == null ? 0 : r) + ((i = e.completion_tokens) == null ? 0 : i), ge.total_tokens = ((a = ge.total_tokens) == null ? 0 : a) + ((o = e.total_tokens) == null ? 0 : o), e.reasoning_tokens && (ge.reasoning_tokens = ((s = ge.reasoning_tokens) == null ? 0 : s) + e.reasoning_tokens);
|
|
75825
75858
|
},
|
|
75826
|
-
timeoutMs:
|
|
75827
|
-
})),
|
|
75859
|
+
timeoutMs: wn == null ? void 0 : wn.timeoutMs
|
|
75860
|
+
})), Mn = at == null ? void 0 : at.map((e) => {
|
|
75828
75861
|
var t;
|
|
75829
75862
|
if (!e._codeAsset) return e;
|
|
75830
75863
|
let n = e._codeAsset, r = Nje({
|
|
@@ -75834,109 +75867,109 @@ function eIe(e, t, n) {
|
|
|
75834
75867
|
codeField: n.codeField,
|
|
75835
75868
|
craftNotes: n.craftNotes,
|
|
75836
75869
|
onWarning: (e) => console.warn(`[page-agent-sdk][code-asset] ${e}`),
|
|
75837
|
-
getController: () =>
|
|
75838
|
-
vfsStore:
|
|
75870
|
+
getController: () => xt,
|
|
75871
|
+
vfsStore: Ie
|
|
75839
75872
|
}), i = [...(t = e.middleware) == null ? [] : t, r];
|
|
75840
|
-
for (let e of i) e && Wwe(e) && e._setGetController(() =>
|
|
75873
|
+
for (let e of i) e && Wwe(e) && e._setGetController(() => xt);
|
|
75841
75874
|
return j(j({}, e), {}, { middleware: i });
|
|
75842
|
-
}),
|
|
75875
|
+
}), Nn = ot && _n ? Pje() : void 0, Pn = Nn ? Bje({
|
|
75843
75876
|
getBind: () => {
|
|
75844
75877
|
var e;
|
|
75845
|
-
return (e =
|
|
75878
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75846
75879
|
},
|
|
75847
|
-
writablePaths:
|
|
75848
|
-
getLocked: () =>
|
|
75849
|
-
tools:
|
|
75880
|
+
writablePaths: st,
|
|
75881
|
+
getLocked: () => Nn.locked(),
|
|
75882
|
+
tools: sn,
|
|
75850
75883
|
getCodeFieldPaths: () => {
|
|
75851
75884
|
var e;
|
|
75852
|
-
return Rje((e =
|
|
75885
|
+
return Rje((e = wt()) == null ? void 0 : e.bind, it.map((e) => ({
|
|
75853
75886
|
writablePaths: e._codeAsset.writablePaths,
|
|
75854
75887
|
codeField: e._codeAsset.codeField
|
|
75855
75888
|
})));
|
|
75856
75889
|
}
|
|
75857
|
-
}) : void 0,
|
|
75858
|
-
getSummarizedPaths: () =>
|
|
75859
|
-
clearSummarizedPaths: () =>
|
|
75860
|
-
}) : void 0,
|
|
75890
|
+
}) : void 0, Fn = xt != null && xt.getSummarizedPaths && xt.clearSummarizedPaths ? Uje({
|
|
75891
|
+
getSummarizedPaths: () => xt.getSummarizedPaths(),
|
|
75892
|
+
clearSummarizedPaths: () => xt.clearSummarizedPaths()
|
|
75893
|
+
}) : void 0, In = _n && Mn !== void 0 ? h1(Mn, j({
|
|
75861
75894
|
llm: e.llm,
|
|
75862
|
-
thinkingModeDefault: (
|
|
75895
|
+
thinkingModeDefault: (de = e.subagent) == null ? void 0 : de.thinkingMode,
|
|
75863
75896
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
75864
75897
|
allTools: () => {
|
|
75865
75898
|
var e, t;
|
|
75866
|
-
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ?
|
|
75899
|
+
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ? sn : e;
|
|
75867
75900
|
},
|
|
75868
75901
|
debug: e.debug,
|
|
75869
|
-
getFocuses: () =>
|
|
75902
|
+
getFocuses: () => Ke.getActiveFocuses(),
|
|
75870
75903
|
getSchema: () => {
|
|
75871
75904
|
var e, t;
|
|
75872
|
-
return (e = (t =
|
|
75905
|
+
return (e = (t = wt()) == null ? void 0 : t.schema) == null ? null : e;
|
|
75873
75906
|
},
|
|
75874
75907
|
getBind: () => {
|
|
75875
75908
|
var e;
|
|
75876
|
-
return (e =
|
|
75909
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75877
75910
|
},
|
|
75878
|
-
tracker:
|
|
75879
|
-
guardMiddleware:
|
|
75880
|
-
getVfsFiles:
|
|
75881
|
-
enterDataScope:
|
|
75882
|
-
exitDataScope:
|
|
75911
|
+
tracker: vn,
|
|
75912
|
+
guardMiddleware: An.length ? An : void 0,
|
|
75913
|
+
getVfsFiles: fn ? () => Ie.files : void 0,
|
|
75914
|
+
enterDataScope: xt != null && xt.enterScope ? (e) => xt.enterScope(e) : void 0,
|
|
75915
|
+
exitDataScope: xt != null && xt.exitScope ? (e) => xt.exitScope(e) : void 0,
|
|
75883
75916
|
onUsage: (e) => {
|
|
75884
75917
|
var t, n, r, i, a, o, s;
|
|
75885
|
-
|
|
75918
|
+
ge.prompt_tokens = ((t = ge.prompt_tokens) == null ? 0 : t) + ((n = e.prompt_tokens) == null ? 0 : n), ge.completion_tokens = ((r = ge.completion_tokens) == null ? 0 : r) + ((i = e.completion_tokens) == null ? 0 : i), ge.total_tokens = ((a = ge.total_tokens) == null ? 0 : a) + ((o = e.total_tokens) == null ? 0 : o), e.reasoning_tokens && (ge.reasoning_tokens = ((s = ge.reasoning_tokens) == null ? 0 : s) + e.reasoning_tokens);
|
|
75886
75919
|
},
|
|
75887
|
-
timeoutMs: (
|
|
75888
|
-
},
|
|
75889
|
-
componentLock:
|
|
75920
|
+
timeoutMs: (fe = e.subagent) == null ? void 0 : fe.timeoutMs
|
|
75921
|
+
}, Nn ? {
|
|
75922
|
+
componentLock: Nn,
|
|
75890
75923
|
resolveComponents: (e) => {
|
|
75891
75924
|
var t;
|
|
75892
|
-
return Fje(e, jje((t =
|
|
75925
|
+
return Fje(e, jje((t = wt()) == null ? void 0 : t.bind, st));
|
|
75893
75926
|
}
|
|
75894
|
-
} : {})) : void 0,
|
|
75927
|
+
} : {})) : void 0, Ln = In ? In.controller : null, Rn = (t) => {
|
|
75895
75928
|
var n, r, i;
|
|
75896
75929
|
let a = (n = t.thinkingMode) == null ? (r = e.subagent) == null ? void 0 : r.thinkingMode : n, o = a ? Q6((i = t.llm) == null ? e.llm : i) ? "instance-noop" : "applied" : "inherited";
|
|
75897
75930
|
return j(j(j({}, t), a ? { thinkingMode: a } : {}), {}, { thinkingApplied: o });
|
|
75898
|
-
},
|
|
75899
|
-
check: (
|
|
75900
|
-
schemas: () =>
|
|
75931
|
+
}, zn = ["read", "fetch_document"], Bn = sn.filter((e) => zn.includes(e.name)), Vn = Sn ? k1({
|
|
75932
|
+
check: (pe = e.verify.check) == null ? A1({
|
|
75933
|
+
schemas: () => wt() ? { "": wt().schema } : {},
|
|
75901
75934
|
root: () => {
|
|
75902
75935
|
var e;
|
|
75903
|
-
return (e =
|
|
75936
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75904
75937
|
}
|
|
75905
|
-
}) :
|
|
75906
|
-
adversarial: (
|
|
75938
|
+
}) : pe,
|
|
75939
|
+
adversarial: (me = e.verify) != null && me.adversarial ? {
|
|
75907
75940
|
llm: e.llm,
|
|
75908
|
-
tools:
|
|
75941
|
+
tools: Bn
|
|
75909
75942
|
} : void 0
|
|
75910
|
-
}) : void 0,
|
|
75911
|
-
contextWindow:
|
|
75912
|
-
thresholdRatio: f8(e,
|
|
75913
|
-
}) : void 0,
|
|
75914
|
-
humanConfirm:
|
|
75915
|
-
screenshot: !!
|
|
75916
|
-
domEdit:
|
|
75943
|
+
}) : void 0, Hn = Cn ? F1({
|
|
75944
|
+
contextWindow: we.contextWindow,
|
|
75945
|
+
thresholdRatio: f8(e, we.contextWindow).summaryThresholdRatio
|
|
75946
|
+
}) : void 0, Un = LFe(j(j({}, pt), {}, {
|
|
75947
|
+
humanConfirm: Jt,
|
|
75948
|
+
screenshot: !!Nt,
|
|
75949
|
+
domEdit: pt.domEdit,
|
|
75917
75950
|
hasActions: !!e.actions && Object.keys(e.actions).length > 0,
|
|
75918
75951
|
hasProposals: !!e.proposals,
|
|
75919
|
-
viewImage: !!
|
|
75920
|
-
subagents:
|
|
75921
|
-
}),
|
|
75952
|
+
viewImage: !!Mt,
|
|
75953
|
+
subagents: at == null ? void 0 : at.map(Rn)
|
|
75954
|
+
}), mt && !!Ze, { promptSoftCap: i1(we.contextWindow, Ae.promptSoftCapTokens) }), Wn = pt.pageContext ? zFe({
|
|
75922
75955
|
getPageInfo: () => typeof document < "u" && typeof location < "u" ? {
|
|
75923
75956
|
title: document.title || "",
|
|
75924
75957
|
url: location.href
|
|
75925
75958
|
} : null,
|
|
75926
|
-
canReadPage:
|
|
75927
|
-
}) : void 0,
|
|
75959
|
+
canReadPage: pt.domInspect === !0
|
|
75960
|
+
}) : void 0, Gn = {
|
|
75928
75961
|
epoch: 0,
|
|
75929
75962
|
notices: [],
|
|
75930
75963
|
readsInvalidated: 0
|
|
75931
|
-
},
|
|
75964
|
+
}, Kn = 0, qn = {
|
|
75932
75965
|
name: "hostNotice",
|
|
75933
75966
|
beforeAgent: () => {
|
|
75934
|
-
|
|
75967
|
+
Kn = Gn.epoch;
|
|
75935
75968
|
},
|
|
75936
75969
|
wrapModelCall: async (e, t) => {
|
|
75937
|
-
if (
|
|
75938
|
-
|
|
75939
|
-
let t = uQ(e.messages, "agent 已通过 dom_edit 修改页面,此前读取为改前状态",
|
|
75970
|
+
if (It) {
|
|
75971
|
+
It = !1;
|
|
75972
|
+
let t = uQ(e.messages, "agent 已通过 dom_edit 修改页面,此前读取为改前状态", Wt);
|
|
75940
75973
|
if (t.invalidatedCount > 0) {
|
|
75941
75974
|
var n;
|
|
75942
75975
|
for (let n = 0; n < t.messages.length; n++) e.messages[n] = t.messages[n];
|
|
@@ -75950,20 +75983,20 @@ function eIe(e, t, n) {
|
|
|
75950
75983
|
});
|
|
75951
75984
|
}
|
|
75952
75985
|
}
|
|
75953
|
-
if (
|
|
75986
|
+
if (Gn.epoch > Kn) {
|
|
75954
75987
|
var r;
|
|
75955
|
-
|
|
75956
|
-
let t = (r =
|
|
75988
|
+
Kn = Gn.epoch;
|
|
75989
|
+
let t = (r = Gn.notices[Gn.notices.length - 1]) == null ? "" : r, n = uQ(e.messages, t || void 0, Wt);
|
|
75957
75990
|
if (n.invalidatedCount > 0) {
|
|
75958
75991
|
var i;
|
|
75959
75992
|
for (let t = 0; t < n.messages.length; t++) e.messages[t] = n.messages[t];
|
|
75960
|
-
|
|
75993
|
+
Gn.readsInvalidated += n.invalidatedCount, (i = R.agent) == null || (i = i.debugLogs) == null || (i = i.value) == null || i.push({
|
|
75961
75994
|
timestamp: Date.now(),
|
|
75962
75995
|
type: "middleware",
|
|
75963
75996
|
data: {
|
|
75964
75997
|
stage: "host_read_invalidated",
|
|
75965
75998
|
count: n.invalidatedCount,
|
|
75966
|
-
epoch:
|
|
75999
|
+
epoch: Gn.epoch,
|
|
75967
76000
|
reason: t || void 0
|
|
75968
76001
|
}
|
|
75969
76002
|
});
|
|
@@ -75971,177 +76004,177 @@ function eIe(e, t, n) {
|
|
|
75971
76004
|
}
|
|
75972
76005
|
return t(e);
|
|
75973
76006
|
},
|
|
75974
|
-
augmentPrompt: () =>
|
|
76007
|
+
augmentPrompt: () => Gn.notices.length ? [
|
|
75975
76008
|
"【宿主页面已变更】",
|
|
75976
|
-
...
|
|
75977
|
-
|
|
76009
|
+
...Gn.notices.filter(Boolean).map((e) => `· ${e}`),
|
|
76010
|
+
pt.domInspect === !0 ? "此前的页面读取/截图结果已过期,回答任何关于当前页面的问题前必须重新 read_page / get_dom 读取当前页面;不要凭此前的读取结果或记忆作答。" : "页面内容可能已变化,断言页面前先核实当前状态;不要凭此前的印象作答。"
|
|
75978
76011
|
].join("\n") : void 0,
|
|
75979
76012
|
afterAgent: () => {
|
|
75980
|
-
|
|
76013
|
+
Gn.notices.length = 0;
|
|
75981
76014
|
}
|
|
75982
|
-
},
|
|
76015
|
+
}, Jn = zt ? {
|
|
75983
76016
|
name: "proposalNotice",
|
|
75984
|
-
augmentPrompt: () =>
|
|
76017
|
+
augmentPrompt: () => zt.state.notices.length ? ["【内容提案裁决结果】(以此为准,不要凭提案前状态作答)", ...zt.state.notices].join("\n") : void 0,
|
|
75985
76018
|
afterAgent: () => {
|
|
75986
|
-
|
|
76019
|
+
zt.state.notices.length = 0;
|
|
75987
76020
|
}
|
|
75988
|
-
} : null,
|
|
76021
|
+
} : null, Yn = Ze ? {
|
|
75989
76022
|
name: "dataHint",
|
|
75990
|
-
augmentPrompt: () => h6(
|
|
75991
|
-
} : null,
|
|
76023
|
+
augmentPrompt: () => h6(wt(), e.schemaHint) || void 0
|
|
76024
|
+
} : null, Xn = e.augmentSystem ? {
|
|
75992
76025
|
name: "augmentSystem",
|
|
75993
76026
|
augmentPrompt: (t) => {
|
|
75994
76027
|
try {
|
|
75995
76028
|
return e.augmentSystem({
|
|
75996
76029
|
state: t,
|
|
75997
|
-
data:
|
|
76030
|
+
data: wt()
|
|
75998
76031
|
});
|
|
75999
76032
|
} catch (t) {
|
|
76000
76033
|
e.debug && console.log("[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:", t.message);
|
|
76001
76034
|
return;
|
|
76002
76035
|
}
|
|
76003
76036
|
}
|
|
76004
|
-
} : null,
|
|
76037
|
+
} : null, Zn = eNe(e.onEvent), Qn = Zn.emit, $n, er = [], tr = (e) => ({
|
|
76005
76038
|
name: e.name,
|
|
76006
76039
|
description: e.description,
|
|
76007
76040
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
76008
|
-
}),
|
|
76041
|
+
}), nr = (e) => ({
|
|
76009
76042
|
name: e.name,
|
|
76010
76043
|
description: e.description,
|
|
76011
76044
|
getContent: () => e.content
|
|
76012
|
-
}),
|
|
76013
|
-
let t =
|
|
76045
|
+
}), rr = e.skillStorage === !1 ? null : WFe(j(j({}, typeof e.skillStorage == "object" ? e.skillStorage : {}), {}, { id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${t}` })), ir = () => {
|
|
76046
|
+
let t = $n ? $n.controller : null;
|
|
76014
76047
|
if (t) {
|
|
76015
|
-
let n = (e.skills || []).filter((e) => !
|
|
76016
|
-
t.set([...n, ...
|
|
76048
|
+
let n = (e.skills || []).filter((e) => !er.some((t) => t.name === e.name));
|
|
76049
|
+
t.set([...n, ...er]);
|
|
76017
76050
|
}
|
|
76018
76051
|
R.infoTick.value++;
|
|
76019
|
-
},
|
|
76020
|
-
if (
|
|
76021
|
-
let t = await
|
|
76052
|
+
}, ar = async () => {
|
|
76053
|
+
if (rr) try {
|
|
76054
|
+
let t = await rr.list();
|
|
76022
76055
|
if (t.length) {
|
|
76023
|
-
|
|
76024
|
-
let n =
|
|
76056
|
+
er = t.map(nr);
|
|
76057
|
+
let n = $n ? $n.controller : null;
|
|
76025
76058
|
if (n) {
|
|
76026
|
-
let t = (e.skills || []).filter((e) => !
|
|
76027
|
-
n.set([...t, ...
|
|
76059
|
+
let t = (e.skills || []).filter((e) => !er.some((t) => t.name === e.name));
|
|
76060
|
+
n.set([...t, ...er]);
|
|
76028
76061
|
}
|
|
76029
76062
|
R.infoTick.value++;
|
|
76030
76063
|
}
|
|
76031
76064
|
} catch (e) {}
|
|
76032
|
-
},
|
|
76033
|
-
llmInvoke:
|
|
76065
|
+
}, or = mn ? o1(j(j({}, Ae), {}, {
|
|
76066
|
+
llmInvoke: xe,
|
|
76034
76067
|
getRegisteredData: () => {
|
|
76035
76068
|
var e;
|
|
76036
|
-
return
|
|
76069
|
+
return wt() ? [{ description: (e = wt().description) == null ? "主数据对象" : e }] : [];
|
|
76037
76070
|
},
|
|
76038
|
-
preserveLastToolResults:
|
|
76039
|
-
},
|
|
76040
|
-
decideInvoke:
|
|
76041
|
-
getSnapshot: () =>
|
|
76042
|
-
} : {})) : void 0,
|
|
76043
|
-
...
|
|
76044
|
-
withScreenshot: !!
|
|
76045
|
-
withDomEdit:
|
|
76046
|
-
withDataOps:
|
|
76071
|
+
preserveLastToolResults: Me
|
|
76072
|
+
}, hn ? {
|
|
76073
|
+
decideInvoke: Ce,
|
|
76074
|
+
getSnapshot: () => Hn == null ? void 0 : Hn.getSnapshot()
|
|
76075
|
+
} : {})) : void 0, sr = dn ? W$([
|
|
76076
|
+
...pt.domInspect && !(e.skills || []).some((e) => e.name === "dom-inspect") ? [gFe({
|
|
76077
|
+
withScreenshot: !!Nt,
|
|
76078
|
+
withDomEdit: pt.domEdit,
|
|
76079
|
+
withDataOps: mt && !!Ze
|
|
76047
76080
|
})] : [],
|
|
76048
|
-
...
|
|
76049
|
-
withScreenshot: !!
|
|
76050
|
-
withDomEdit:
|
|
76051
|
-
withVfs:
|
|
76081
|
+
...pt.domInspect && !(e.skills || []).some((e) => e.name === "page-analysis") ? [vFe({
|
|
76082
|
+
withScreenshot: !!Nt,
|
|
76083
|
+
withDomEdit: pt.domEdit,
|
|
76084
|
+
withVfs: fn
|
|
76052
76085
|
})] : [],
|
|
76053
76086
|
...e.skills || []
|
|
76054
76087
|
], {
|
|
76055
|
-
readVfs:
|
|
76088
|
+
readVfs: fn ? (e) => {
|
|
76056
76089
|
var t;
|
|
76057
|
-
return (t =
|
|
76090
|
+
return (t = Ie.files[e]) == null ? void 0 : t.content;
|
|
76058
76091
|
} : void 0,
|
|
76059
76092
|
onToolsReady: (e, t) => {
|
|
76060
76093
|
for (let n of t) {
|
|
76061
|
-
let t =
|
|
76062
|
-
t >= 0 &&
|
|
76094
|
+
let t = rn.findIndex((e) => e.name === n.name);
|
|
76095
|
+
t >= 0 && rn.splice(t, 1), rn.push(n), an.set(n.name, e), kt.set(n.name, `skill:${e}`);
|
|
76063
76096
|
}
|
|
76064
|
-
|
|
76097
|
+
sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76065
76098
|
}
|
|
76066
76099
|
}) : void 0;
|
|
76067
|
-
|
|
76068
|
-
let
|
|
76069
|
-
...
|
|
76070
|
-
zn,
|
|
76071
|
-
...Bn ? [Bn] : [],
|
|
76100
|
+
$n = sr;
|
|
76101
|
+
let cr = iNe([
|
|
76102
|
+
...Yn ? [Yn] : [],
|
|
76072
76103
|
Un,
|
|
76073
76104
|
...Wn ? [Wn] : [],
|
|
76074
|
-
|
|
76075
|
-
|
|
76076
|
-
Re,
|
|
76077
|
-
|
|
76078
|
-
|
|
76079
|
-
...
|
|
76080
|
-
...
|
|
76081
|
-
...
|
|
76082
|
-
...
|
|
76083
|
-
...
|
|
76084
|
-
...
|
|
76085
|
-
...
|
|
76086
|
-
...
|
|
76087
|
-
...
|
|
76088
|
-
...
|
|
76089
|
-
...
|
|
76090
|
-
...
|
|
76091
|
-
...
|
|
76092
|
-
...
|
|
76093
|
-
...An ? [An] : [],
|
|
76105
|
+
qn,
|
|
76106
|
+
...Jn ? [Jn] : [],
|
|
76107
|
+
...ln ? [Re] : [],
|
|
76108
|
+
ze,
|
|
76109
|
+
Be,
|
|
76110
|
+
...cn ? [Le] : [],
|
|
76111
|
+
...sr ? [sr] : [],
|
|
76112
|
+
...fn ? [eje(Ie)] : [],
|
|
76113
|
+
...or ? [or] : [],
|
|
76114
|
+
...un ? [Je] : [],
|
|
76115
|
+
...Zt ? [Ke] : [],
|
|
76116
|
+
...Ct ? [Ct] : [],
|
|
76117
|
+
...gn ? [Ye] : [],
|
|
76118
|
+
...En ? [En] : [],
|
|
76119
|
+
...ut && ft && dt ? [O1(dt)] : [],
|
|
76120
|
+
...Jt ? [Ge] : [],
|
|
76121
|
+
...kn ? [kn] : [],
|
|
76122
|
+
...Ot ? [Ot] : [],
|
|
76123
|
+
...Vn ? [Vn] : [],
|
|
76094
76124
|
...jn ? [jn] : [],
|
|
76095
|
-
...
|
|
76125
|
+
...In ? [In] : [],
|
|
76126
|
+
...Pn ? [Pn] : [],
|
|
76127
|
+
...Fn ? [Fn] : [],
|
|
76128
|
+
...xt && _n ? [Kje({
|
|
76096
76129
|
getBind: () => {
|
|
76097
76130
|
var e;
|
|
76098
|
-
return (e =
|
|
76131
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
76099
76132
|
},
|
|
76100
76133
|
getTools: () => {
|
|
76101
76134
|
var e, t;
|
|
76102
|
-
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ?
|
|
76135
|
+
return (e = (t = R.agent) == null ? void 0 : t.allTools) == null ? sn : e;
|
|
76103
76136
|
}
|
|
76104
76137
|
})] : [],
|
|
76105
|
-
...
|
|
76106
|
-
...
|
|
76107
|
-
...
|
|
76138
|
+
...Xn ? [Xn] : [],
|
|
76139
|
+
...Hn ? [Hn] : [],
|
|
76140
|
+
...Ft ? [Ft] : [],
|
|
76108
76141
|
...e.middleware || [],
|
|
76109
|
-
...
|
|
76142
|
+
...gt ? [EFe(ge, {
|
|
76110
76143
|
tokenBudget: e.tokenBudget,
|
|
76111
76144
|
timeBudgetMs: e.timeBudgetMs
|
|
76112
|
-
},
|
|
76113
|
-
QFe(
|
|
76114
|
-
]),
|
|
76115
|
-
function
|
|
76145
|
+
}, Qn)] : [],
|
|
76146
|
+
QFe(Qn, Fe, wt, ge)
|
|
76147
|
+
]), lr = (he = e.maxMemoryRounds) == null ? YFe : he;
|
|
76148
|
+
function ur(e) {
|
|
76116
76149
|
return (e) => {
|
|
76117
|
-
e.type !== "approval_request" &&
|
|
76150
|
+
e.type !== "approval_request" && Qn(jt(e));
|
|
76118
76151
|
};
|
|
76119
76152
|
}
|
|
76120
|
-
let
|
|
76121
|
-
function
|
|
76153
|
+
let dr = /* @__PURE__ */ Iq([]), fr = qFe(), pr = /* @__PURE__ */ new Set();
|
|
76154
|
+
function mr(e) {
|
|
76122
76155
|
let t = new AbortController(), n = () => t.abort();
|
|
76123
|
-
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })),
|
|
76156
|
+
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), pr.add(t), {
|
|
76124
76157
|
controller: t,
|
|
76125
76158
|
untrack: () => {
|
|
76126
|
-
|
|
76159
|
+
pr.delete(t), e == null || e.removeEventListener("abort", n);
|
|
76127
76160
|
}
|
|
76128
76161
|
};
|
|
76129
76162
|
}
|
|
76130
|
-
function
|
|
76131
|
-
for (let e of
|
|
76132
|
-
|
|
76163
|
+
function hr() {
|
|
76164
|
+
for (let e of pr) e.abort();
|
|
76165
|
+
pr.clear();
|
|
76133
76166
|
}
|
|
76134
|
-
let
|
|
76167
|
+
let gr = /* @__PURE__ */ Iq(null), R = {
|
|
76135
76168
|
agentId: t,
|
|
76136
|
-
store:
|
|
76137
|
-
messages:
|
|
76138
|
-
vfsStore:
|
|
76139
|
-
listeners:
|
|
76140
|
-
todosMw:
|
|
76141
|
-
memoryMw:
|
|
76142
|
-
missionMw:
|
|
76143
|
-
workingMemoryMw:
|
|
76144
|
-
focusMw:
|
|
76169
|
+
store: ye,
|
|
76170
|
+
messages: Fe,
|
|
76171
|
+
vfsStore: Ie,
|
|
76172
|
+
listeners: Zn.listeners,
|
|
76173
|
+
todosMw: Le,
|
|
76174
|
+
memoryMw: Ye,
|
|
76175
|
+
missionMw: Re,
|
|
76176
|
+
workingMemoryMw: Je,
|
|
76177
|
+
focusMw: Ke,
|
|
76145
76178
|
agent: null,
|
|
76146
76179
|
initDone: Promise.resolve(),
|
|
76147
76180
|
sessionId: "",
|
|
@@ -76149,62 +76182,62 @@ function eIe(e, t, n) {
|
|
|
76149
76182
|
mcpClosers: [],
|
|
76150
76183
|
mcpServers: [],
|
|
76151
76184
|
mcpFailed: [],
|
|
76152
|
-
checkpoint:
|
|
76153
|
-
dataOpsController:
|
|
76154
|
-
skillsController:
|
|
76155
|
-
infoTick:
|
|
76156
|
-
pendingConflict:
|
|
76157
|
-
pendingQuote:
|
|
76158
|
-
sessions:
|
|
76159
|
-
refreshSessions: () =>
|
|
76160
|
-
liveData:
|
|
76161
|
-
usage:
|
|
76162
|
-
emit:
|
|
76163
|
-
runSerial:
|
|
76164
|
-
trackActive:
|
|
76165
|
-
abortAllActive:
|
|
76185
|
+
checkpoint: dt,
|
|
76186
|
+
dataOpsController: xt,
|
|
76187
|
+
skillsController: $n ? $n.controller : null,
|
|
76188
|
+
infoTick: ve,
|
|
76189
|
+
pendingConflict: _e.pendingConflict,
|
|
76190
|
+
pendingQuote: gr,
|
|
76191
|
+
sessions: dr,
|
|
76192
|
+
refreshSessions: () => Cr.refreshSessions(),
|
|
76193
|
+
liveData: wt,
|
|
76194
|
+
usage: ge,
|
|
76195
|
+
emit: Qn,
|
|
76196
|
+
runSerial: fr,
|
|
76197
|
+
trackActive: mr,
|
|
76198
|
+
abortAllActive: hr,
|
|
76166
76199
|
unloadSkillTools(e) {
|
|
76167
76200
|
if (e) {
|
|
76168
|
-
let t =
|
|
76169
|
-
if (
|
|
76201
|
+
let t = rn.length;
|
|
76202
|
+
if (rn = rn.filter((t) => an.get(t.name) === e ? (kt.delete(t.name), an.delete(t.name), !1) : !0), rn.length === t) return;
|
|
76170
76203
|
} else {
|
|
76171
|
-
if (!
|
|
76172
|
-
for (let e of
|
|
76173
|
-
|
|
76204
|
+
if (!rn.length) return;
|
|
76205
|
+
for (let e of rn) kt.delete(e.name), an.delete(e.name);
|
|
76206
|
+
rn = [];
|
|
76174
76207
|
}
|
|
76175
|
-
|
|
76208
|
+
sn = on(), R.agent && R.agent.setTools(sn);
|
|
76176
76209
|
},
|
|
76177
76210
|
applySnapshot(t) {
|
|
76178
76211
|
var n, r, i;
|
|
76179
|
-
if (t.vfs &&
|
|
76212
|
+
if (t.vfs && Ie.hydrate && Ie.hydrate(t.vfs), (n = t.messages) != null && n.length && (Fe.push(...cCe(t.messages, (e) => {
|
|
76180
76213
|
var t;
|
|
76181
76214
|
return (e ? (t = R.vfsStore) == null || (t = t.files) == null || (t = t[e]) == null ? void 0 : t.content : void 0) || void 0;
|
|
76182
|
-
})),
|
|
76215
|
+
})), Be.markResumed()), (r = t.todos) != null && r.length && Le.reset(t.todos), t.memory && !e.memory && Ye.reset(t.memory), (i = t.checkpoints) != null && i.length && dt && dt.importStack(t.checkpoints), t.usage && Object.assign(ge, t.usage), t.mission && ln && Re.setMission(t.mission), t.workingMemory && un && Je.restore(t.workingMemory), t.planConfirmation && (Ve.lastPlanConfirmation = t.planConfirmation), Zt) {
|
|
76183
76216
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
76184
76217
|
if (r.length) {
|
|
76185
76218
|
var a;
|
|
76186
|
-
let t = (a =
|
|
76187
|
-
if (n.length && (
|
|
76219
|
+
let t = (a = wt()) == null ? void 0 : a.schema, n = t ? r.filter((e) => GQ(t, e.path)) : [];
|
|
76220
|
+
if (n.length && (Ke.setFocus(null), n.forEach((e) => Ke.addFocus(qe(e)))), e.debug && n.length < r.length) {
|
|
76188
76221
|
let e = r.filter((e) => !n.includes(e)).map((e) => e.path);
|
|
76189
76222
|
console.warn("[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:", e);
|
|
76190
76223
|
}
|
|
76191
76224
|
}
|
|
76192
76225
|
}
|
|
76193
|
-
|
|
76226
|
+
br();
|
|
76194
76227
|
},
|
|
76195
76228
|
addSkill(e) {
|
|
76196
|
-
let t =
|
|
76197
|
-
t >= 0 ?
|
|
76229
|
+
let t = er.findIndex((t) => t.name === e.name);
|
|
76230
|
+
t >= 0 ? er[t] = e : er.push(e), ir(), rr && rr.put(tr(e));
|
|
76198
76231
|
},
|
|
76199
76232
|
removeSkill(e) {
|
|
76200
|
-
let t =
|
|
76201
|
-
return t < 0 ? !1 : (
|
|
76233
|
+
let t = er.findIndex((t) => t.name === e);
|
|
76234
|
+
return t < 0 ? !1 : (er.splice(t, 1), ir(), rr && rr.remove(e), !0);
|
|
76202
76235
|
},
|
|
76203
76236
|
listUserSkills() {
|
|
76204
|
-
return
|
|
76237
|
+
return er.map((e) => e.name);
|
|
76205
76238
|
},
|
|
76206
76239
|
getUserSkill(e) {
|
|
76207
|
-
let t =
|
|
76240
|
+
let t = er.find((t) => t.name === e);
|
|
76208
76241
|
if (t) return {
|
|
76209
76242
|
name: t.name,
|
|
76210
76243
|
description: t.description,
|
|
@@ -76212,32 +76245,32 @@ function eIe(e, t, n) {
|
|
|
76212
76245
|
};
|
|
76213
76246
|
},
|
|
76214
76247
|
afterRound() {
|
|
76215
|
-
|
|
76248
|
+
xr(), Cr.persistRuntime();
|
|
76216
76249
|
},
|
|
76217
76250
|
clearCodeReuse() {
|
|
76218
76251
|
var e, t;
|
|
76219
|
-
let n =
|
|
76252
|
+
let n = Ie;
|
|
76220
76253
|
(e = n.__pgPendingRetry) == null || e.clear(), (t = n.__pgLastCheckout) == null || t.clear();
|
|
76221
76254
|
},
|
|
76222
76255
|
async send(e, t) {
|
|
76223
76256
|
var n, r, i, a;
|
|
76224
76257
|
if (await R.initDone, R.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 send");
|
|
76225
|
-
t = (n = t) == null ? {} : n, t != null && t.mission &&
|
|
76258
|
+
t = (n = t) == null ? {} : n, t != null && t.mission && ln && Re.setMission(t.mission);
|
|
76226
76259
|
let o = e, s = ((r = t.images) == null ? [] : r).filter((e) => e && (e.dataUri || e.vfsRef || e.url));
|
|
76227
76260
|
if (s.length > 4) throw Error(`[page-agent-sdk] 单轮最多 4 张图片(收到 ${s.length})`);
|
|
76228
|
-
if (s.length && (await
|
|
76261
|
+
if (s.length && (await Sr.stowImages(s), await Sr.describeIfNeeded(s, o)), s.length && !we.vision && !s.every((e) => e.description)) {
|
|
76229
76262
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述(集成方识图子 agent / 自有 vision API)";
|
|
76230
|
-
throw
|
|
76263
|
+
throw Qn({
|
|
76231
76264
|
type: "error",
|
|
76232
76265
|
message: e,
|
|
76233
76266
|
severity: "recoverable",
|
|
76234
76267
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
76235
76268
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
76236
76269
|
}
|
|
76237
|
-
|
|
76238
|
-
let c =
|
|
76270
|
+
Ie == null || (i = Ie.setProtectedRefs) == null || i.call(Ie, B8(Fe));
|
|
76271
|
+
let c = gt ? (a = t.maxAutoRetries) == null ? 1 : a : 0, l = 0, u = !1, d = ur(t.signal);
|
|
76239
76272
|
if (t.signal) {
|
|
76240
|
-
let e = () =>
|
|
76273
|
+
let e = () => _e.resolve("keep_external");
|
|
76241
76274
|
t.signal.aborted ? e() : t.signal.addEventListener("abort", e, { once: !0 });
|
|
76242
76275
|
}
|
|
76243
76276
|
let f = R.sessionId;
|
|
@@ -76249,16 +76282,16 @@ function eIe(e, t, n) {
|
|
|
76249
76282
|
let n = kZ(t.quote.anchor);
|
|
76250
76283
|
e = j(j({ text: DZ(t.quote.text) }, t.quote.source ? { source: t.quote.source } : {}), n ? { anchor: n } : {});
|
|
76251
76284
|
}
|
|
76252
|
-
let n = (m = (h = e) == null ?
|
|
76253
|
-
|
|
76285
|
+
let n = (m = (h = e) == null ? gr.value : h) == null ? void 0 : m;
|
|
76286
|
+
Fe.push(j(j({
|
|
76254
76287
|
role: "user",
|
|
76255
76288
|
content: o,
|
|
76256
76289
|
timestamp: Date.now()
|
|
76257
|
-
}, s.length ? { images: s } : {}), n ? { quote: n } : {})), u = !0, !e &&
|
|
76290
|
+
}, s.length ? { images: s } : {}), n ? { quote: n } : {})), u = !0, !e && gr.value && (gr.value = null);
|
|
76258
76291
|
}
|
|
76259
76292
|
try {
|
|
76260
76293
|
var g;
|
|
76261
|
-
let e = await R.agent.invoke(
|
|
76294
|
+
let e = await R.agent.invoke(Fe, t.signal, d);
|
|
76262
76295
|
if ((g = t.signal) != null && g.aborted || R.sessionId !== f || R.refCount <= 0) {
|
|
76263
76296
|
var _, v;
|
|
76264
76297
|
return (_ = R.agent) == null || (_ = _.debugLogs) == null || (_ = _.value) == null || _.push({
|
|
@@ -76272,14 +76305,14 @@ function eIe(e, t, n) {
|
|
|
76272
76305
|
}
|
|
76273
76306
|
}), e;
|
|
76274
76307
|
}
|
|
76275
|
-
if (
|
|
76308
|
+
if (Fe.push({
|
|
76276
76309
|
role: "assistant",
|
|
76277
76310
|
content: e,
|
|
76278
76311
|
timestamp: Date.now()
|
|
76279
|
-
}), R.afterRound(),
|
|
76280
|
-
await
|
|
76312
|
+
}), R.afterRound(), ye) try {
|
|
76313
|
+
await ye.flush();
|
|
76281
76314
|
} catch (e) {
|
|
76282
|
-
|
|
76315
|
+
Qn({
|
|
76283
76316
|
type: "error",
|
|
76284
76317
|
message: `落盘失败(不影响本轮回复):${e instanceof Error ? e.message : String(e)}`,
|
|
76285
76318
|
severity: "observable",
|
|
@@ -76293,9 +76326,9 @@ function eIe(e, t, n) {
|
|
|
76293
76326
|
if (GZ(e) && (n = j(j({}, n), {}, {
|
|
76294
76327
|
code: "MODEL_UNAVAILABLE",
|
|
76295
76328
|
message: e instanceof Error ? e.message : n.message
|
|
76296
|
-
})), l < c &&
|
|
76329
|
+
})), l < c && dt != null && dt.canRestore()) {
|
|
76297
76330
|
var y;
|
|
76298
|
-
l += 1,
|
|
76331
|
+
l += 1, dt.restore(), u = !0, Qn({
|
|
76299
76332
|
type: "error",
|
|
76300
76333
|
message: `致命错误自动恢复(${l}/${c}):${n.message},已回退 checkpoint 重试`,
|
|
76301
76334
|
severity: "observable",
|
|
@@ -76307,7 +76340,7 @@ function eIe(e, t, n) {
|
|
|
76307
76340
|
});
|
|
76308
76341
|
continue;
|
|
76309
76342
|
}
|
|
76310
|
-
throw
|
|
76343
|
+
throw Qn(j(j({
|
|
76311
76344
|
type: "error",
|
|
76312
76345
|
message: n.message,
|
|
76313
76346
|
severity: n.severity
|
|
@@ -76319,9 +76352,9 @@ function eIe(e, t, n) {
|
|
|
76319
76352
|
var r;
|
|
76320
76353
|
if (await R.initDone, !e.length) return [];
|
|
76321
76354
|
if (R.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
76322
|
-
let i = [], a =
|
|
76323
|
-
if (
|
|
76324
|
-
let e = () =>
|
|
76355
|
+
let i = [], a = ur(n);
|
|
76356
|
+
if (Ie == null || (r = Ie.setProtectedRefs) == null || r.call(Ie, B8(Fe)), n) {
|
|
76357
|
+
let e = () => _e.resolve("keep_external");
|
|
76325
76358
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
76326
76359
|
}
|
|
76327
76360
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -76335,23 +76368,23 @@ function eIe(e, t, n) {
|
|
|
76335
76368
|
break;
|
|
76336
76369
|
}
|
|
76337
76370
|
let o = e[r];
|
|
76338
|
-
|
|
76339
|
-
let s =
|
|
76371
|
+
dt && dt.save(`batch:${r}`);
|
|
76372
|
+
let s = Fe.length;
|
|
76340
76373
|
try {
|
|
76341
|
-
|
|
76374
|
+
Fe.push({
|
|
76342
76375
|
role: "user",
|
|
76343
76376
|
content: o,
|
|
76344
76377
|
timestamp: Date.now()
|
|
76345
76378
|
});
|
|
76346
|
-
let s = await R.agent.invoke(
|
|
76347
|
-
if (
|
|
76379
|
+
let s = await R.agent.invoke(Fe, n, a);
|
|
76380
|
+
if (Fe.push({
|
|
76348
76381
|
role: "assistant",
|
|
76349
76382
|
content: s,
|
|
76350
76383
|
timestamp: Date.now()
|
|
76351
|
-
}), R.afterRound(),
|
|
76352
|
-
await
|
|
76384
|
+
}), R.afterRound(), ye) try {
|
|
76385
|
+
await ye.flush();
|
|
76353
76386
|
} catch (e) {
|
|
76354
|
-
|
|
76387
|
+
Qn({
|
|
76355
76388
|
type: "error",
|
|
76356
76389
|
message: `落盘失败(不影响本任务结果):${e instanceof Error ? e.message : String(e)}`,
|
|
76357
76390
|
severity: "observable",
|
|
@@ -76370,7 +76403,7 @@ function eIe(e, t, n) {
|
|
|
76370
76403
|
ok: !0
|
|
76371
76404
|
});
|
|
76372
76405
|
} catch (a) {
|
|
76373
|
-
if (
|
|
76406
|
+
if (Fe.length > s && Fe.splice(s), FZ(a, n)) {
|
|
76374
76407
|
i.push({
|
|
76375
76408
|
index: r,
|
|
76376
76409
|
task: o,
|
|
@@ -76387,7 +76420,7 @@ function eIe(e, t, n) {
|
|
|
76387
76420
|
}
|
|
76388
76421
|
GZ(a);
|
|
76389
76422
|
let c = xZ(a, "fatal");
|
|
76390
|
-
|
|
76423
|
+
Qn({
|
|
76391
76424
|
type: "error",
|
|
76392
76425
|
message: `批量任务 ${r + 1}/${e.length} 失败:${c.message}`,
|
|
76393
76426
|
severity: "observable",
|
|
@@ -76411,10 +76444,10 @@ function eIe(e, t, n) {
|
|
|
76411
76444
|
}
|
|
76412
76445
|
return i;
|
|
76413
76446
|
},
|
|
76414
|
-
switchSession: (e) =>
|
|
76415
|
-
exportSession: (e) =>
|
|
76416
|
-
importSession: (e) =>
|
|
76417
|
-
resetSession: () =>
|
|
76447
|
+
switchSession: (e) => Cr.switchSession(e),
|
|
76448
|
+
exportSession: (e) => Cr.exportSession(e),
|
|
76449
|
+
importSession: (e) => Cr.importSession(e),
|
|
76450
|
+
resetSession: () => Cr.resetSession(),
|
|
76418
76451
|
stream: async (e, t, n) => {
|
|
76419
76452
|
var r, i;
|
|
76420
76453
|
if (!R.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
@@ -76422,51 +76455,51 @@ function eIe(e, t, n) {
|
|
|
76422
76455
|
var t;
|
|
76423
76456
|
return e.role === "user" && ((t = e.images) == null ? void 0 : t.length);
|
|
76424
76457
|
});
|
|
76425
|
-
if (!(a == null || (r = a.images) == null) && r.length && (await
|
|
76458
|
+
if (!(a == null || (r = a.images) == null) && r.length && (await Sr.stowImages(a.images), await Sr.describeIfNeeded(a.images, a.content), !we.vision && !a.images.every((e) => e.description))) {
|
|
76426
76459
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述";
|
|
76427
|
-
throw
|
|
76460
|
+
throw Qn({
|
|
76428
76461
|
type: "error",
|
|
76429
76462
|
message: e,
|
|
76430
76463
|
severity: "recoverable",
|
|
76431
76464
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
76432
76465
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
76433
76466
|
}
|
|
76434
|
-
|
|
76467
|
+
Ie == null || (i = Ie.setProtectedRefs) == null || i.call(Ie, B8(e));
|
|
76435
76468
|
let o = (e) => {
|
|
76436
|
-
t == null || t(
|
|
76469
|
+
t == null || t(jt(e)), Qn(jt(e)), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && R.infoTick.value++;
|
|
76437
76470
|
};
|
|
76438
76471
|
if (n) {
|
|
76439
|
-
let e = () =>
|
|
76472
|
+
let e = () => _e.resolve("keep_external");
|
|
76440
76473
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
76441
76474
|
}
|
|
76442
|
-
let { controller: s, untrack: c } =
|
|
76475
|
+
let { controller: s, untrack: c } = mr(n);
|
|
76443
76476
|
return R.agent.stream(e, o, s.signal).finally(c);
|
|
76444
76477
|
},
|
|
76445
76478
|
release() {
|
|
76446
76479
|
if (R.refCount--, R.refCount <= 0) {
|
|
76447
|
-
if (
|
|
76480
|
+
if (hr(), qt = !0, ye) {
|
|
76448
76481
|
var e;
|
|
76449
|
-
(e =
|
|
76482
|
+
(e = Ie.flush) == null || e.call(Ie), ye.flush(), ye.dispose();
|
|
76450
76483
|
}
|
|
76451
|
-
|
|
76484
|
+
rr && rr.dispose();
|
|
76452
76485
|
let n = R.mcpClosers.splice(0);
|
|
76453
76486
|
n.length && Promise.allSettled(n.map((e) => e())), V8.delete(t);
|
|
76454
76487
|
}
|
|
76455
76488
|
},
|
|
76456
|
-
resolveConflict:
|
|
76489
|
+
resolveConflict: _e.resolve,
|
|
76457
76490
|
setTools(e) {
|
|
76458
|
-
|
|
76459
|
-
|
|
76460
|
-
}),
|
|
76491
|
+
Bt.length = 0, e.forEach((e) => {
|
|
76492
|
+
Bt.push(e), kt.set(e.name, "user");
|
|
76493
|
+
}), sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76461
76494
|
},
|
|
76462
76495
|
addTool(e) {
|
|
76463
|
-
|
|
76464
|
-
for (let t =
|
|
76465
|
-
|
|
76496
|
+
sn.some((t) => t.name === e.name) && console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);
|
|
76497
|
+
for (let t = Bt.length - 1; t >= 0; t--) Bt[t].name === e.name && Bt.splice(t, 1);
|
|
76498
|
+
Bt.push(e), kt.set(e.name, "user"), sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76466
76499
|
},
|
|
76467
76500
|
removeTool(e) {
|
|
76468
|
-
let t =
|
|
76469
|
-
return t < 0 ? !1 : (
|
|
76501
|
+
let t = Bt.findIndex((t) => t.name === e);
|
|
76502
|
+
return t < 0 ? !1 : (Bt.splice(t, 1), kt.delete(e), sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++, !0);
|
|
76470
76503
|
},
|
|
76471
76504
|
setLlm(t) {
|
|
76472
76505
|
var n, r, i, a, o, s, c;
|
|
@@ -76478,119 +76511,119 @@ function eIe(e, t, n) {
|
|
|
76478
76511
|
if (((u = e.provider) == null ? "openai" : u) === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
76479
76512
|
l = IG(e);
|
|
76480
76513
|
}
|
|
76481
|
-
typeof l.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), SMe(l, { emit:
|
|
76514
|
+
typeof l.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), SMe(l, { emit: Qn }), Pe = t;
|
|
76482
76515
|
let d = Q6(t) ? void 0 : t;
|
|
76483
|
-
if (
|
|
76516
|
+
if (we = aF({
|
|
76484
76517
|
model: (n = (r = d == null ? void 0 : d.model) == null ? t.model : r) == null ? t.modelName : n,
|
|
76485
76518
|
contextWindow: (i = e.contextWindow) == null ? d == null ? void 0 : d.contextWindow : i,
|
|
76486
76519
|
maxOutputTokens: (a = e.maxOutputTokens) == null ? d == null ? void 0 : d.maxOutputTokens : a,
|
|
76487
76520
|
vision: (o = d == null ? void 0 : d.vision) == null ? t.vision : o
|
|
76488
|
-
}),
|
|
76521
|
+
}), we.contextWindow < 2e5) throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${we.contextWindow} 小于最小支持 ${eF}(需 ≥200K 窗口模型)`);
|
|
76489
76522
|
if (R.agent) {
|
|
76490
76523
|
var f, p;
|
|
76491
|
-
R.agent.setLlm(l), (f = (p = R.agent).setModelCaps) == null || f.call(p,
|
|
76524
|
+
R.agent.setLlm(l), (f = (p = R.agent).setModelCaps) == null || f.call(p, we);
|
|
76492
76525
|
}
|
|
76493
|
-
|
|
76526
|
+
or == null || (s = or.setContextWindow) == null || s.call(or, we.contextWindow), Hn == null || (c = Hn.setContextWindow) == null || c.call(Hn, we.contextWindow), R.infoTick.value++, e.debug && console.log("[page-agent-sdk][setLlm] 重解析 modelCaps + 回灌:", we);
|
|
76494
76527
|
},
|
|
76495
76528
|
setMemory(e) {
|
|
76496
|
-
|
|
76529
|
+
Ye.reset(e), typeof e == "function" && Ye.refresh(), R.infoTick.value++;
|
|
76497
76530
|
},
|
|
76498
76531
|
refreshMemory() {
|
|
76499
|
-
return
|
|
76532
|
+
return Ye.refresh();
|
|
76500
76533
|
},
|
|
76501
76534
|
setSubagents(t) {
|
|
76502
|
-
if (!
|
|
76535
|
+
if (!Ln) {
|
|
76503
76536
|
e.debug && console.warn("[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
76504
76537
|
return;
|
|
76505
76538
|
}
|
|
76506
|
-
|
|
76539
|
+
Ln.set(t), R.infoTick.value++;
|
|
76507
76540
|
},
|
|
76508
76541
|
addSubagent(t) {
|
|
76509
|
-
if (!
|
|
76542
|
+
if (!Ln) {
|
|
76510
76543
|
e.debug && console.warn("[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
76511
76544
|
return;
|
|
76512
76545
|
}
|
|
76513
|
-
|
|
76546
|
+
Ln.add(t), R.infoTick.value++;
|
|
76514
76547
|
},
|
|
76515
76548
|
removeSubagent(t) {
|
|
76516
|
-
if (!
|
|
76517
|
-
let n =
|
|
76549
|
+
if (!Ln) return e.debug && console.warn("[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略"), !1;
|
|
76550
|
+
let n = Ln.remove(t);
|
|
76518
76551
|
return n && R.infoTick.value++, n;
|
|
76519
76552
|
},
|
|
76520
76553
|
getActiveSubagents() {
|
|
76521
76554
|
var e;
|
|
76522
|
-
return (e =
|
|
76555
|
+
return (e = vn == null ? void 0 : vn.getActive()) == null ? [] : e;
|
|
76523
76556
|
},
|
|
76524
76557
|
get subagentHistory() {
|
|
76525
76558
|
var e;
|
|
76526
|
-
return (e =
|
|
76559
|
+
return (e = vn == null ? void 0 : vn.getHistory()) == null ? [] : e;
|
|
76527
76560
|
},
|
|
76528
76561
|
getInfo() {
|
|
76529
76562
|
var r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A, M, ee, te, N, P, ne, re, ie, ae, oe, se, ce, F;
|
|
76530
76563
|
return j(j(j({
|
|
76531
76564
|
id: t,
|
|
76532
76565
|
sessionId: R.sessionId,
|
|
76533
|
-
model: Q6(
|
|
76534
|
-
systemPrompt: (i = (a = R.agent) == null || (o = a.getEffectiveSystemPrompt) == null ? void 0 : o.call(a)) == null ?
|
|
76535
|
-
tools: ((s = (c = R.agent) == null ? void 0 : c.allTools) == null ?
|
|
76566
|
+
model: Q6(Pe) ? (r = Pe.model) == null ? Pe.modelName : r : Pe.model,
|
|
76567
|
+
systemPrompt: (i = (a = R.agent) == null || (o = a.getEffectiveSystemPrompt) == null ? void 0 : o.call(a)) == null ? vt + h6(wt(), e.schemaHint) : i,
|
|
76568
|
+
tools: ((s = (c = R.agent) == null ? void 0 : c.allTools) == null ? sn : s).map((e) => ({
|
|
76536
76569
|
name: e.name,
|
|
76537
76570
|
description: e.description,
|
|
76538
76571
|
schema: e.schema,
|
|
76539
|
-
source:
|
|
76572
|
+
source: kt.get(e.name) || "user"
|
|
76540
76573
|
})),
|
|
76541
|
-
skills: (
|
|
76574
|
+
skills: ($n ? $n.controller.get() : (l = e.skills) == null ? [] : l).map((e) => ({
|
|
76542
76575
|
name: e.name,
|
|
76543
76576
|
description: e.description
|
|
76544
76577
|
})),
|
|
76545
|
-
data:
|
|
76546
|
-
description:
|
|
76547
|
-
schema:
|
|
76578
|
+
data: wt() ? {
|
|
76579
|
+
description: wt().description,
|
|
76580
|
+
schema: wt().schema
|
|
76548
76581
|
} : void 0,
|
|
76549
76582
|
contextPreset: (u = e.contextPreset) == null ? "auto" : u,
|
|
76550
76583
|
compression: {
|
|
76551
|
-
contextWindow:
|
|
76552
|
-
summaryThresholdRatio: (d =
|
|
76553
|
-
promptSoftCap: i1(
|
|
76584
|
+
contextWindow: we.contextWindow,
|
|
76585
|
+
summaryThresholdRatio: (d = Ae.summaryThresholdRatio) == null ? .5 : d,
|
|
76586
|
+
promptSoftCap: i1(we.contextWindow, Ae.promptSoftCapTokens)
|
|
76554
76587
|
},
|
|
76555
|
-
memory:
|
|
76588
|
+
memory: Ye.get(),
|
|
76556
76589
|
staleReadsInvalidated: (f = (p = R.agent) == null || (m = p.getStaleReadsInvalidated) == null ? void 0 : m.call(p)) == null ? 0 : f,
|
|
76557
|
-
hostReadsInvalidated:
|
|
76558
|
-
},
|
|
76590
|
+
hostReadsInvalidated: Gn.readsInvalidated
|
|
76591
|
+
}, zt ? { proposals: zt.snapshot() } : {}), n ? { hostWatch: j({}, n) } : {}), {}, {
|
|
76559
76592
|
llmRetries: (h = (g = R.agent) == null || (_ = g.getLlmRetries) == null ? void 0 : _.call(g)) == null ? 0 : h,
|
|
76560
76593
|
llmCallFailures: (v = (y = R.agent) == null || (b = y.getLlmCallFailures) == null ? void 0 : b.call(y)) == null ? 0 : v,
|
|
76561
76594
|
gates: (x = R.agent) == null || (S = x.getGateStats) == null ? void 0 : S.call(x),
|
|
76562
76595
|
systemSegments: (C = (w = R.agent) == null || (T = w.getLastSystemSegments) == null ? void 0 : T.call(w)) == null ? [] : C,
|
|
76563
|
-
middleware:
|
|
76596
|
+
middleware: cr.map((e) => e.name),
|
|
76564
76597
|
todos: ((E = (D = R.agent) == null || (O = D.getState) == null || (O = O.call(D)) == null ? void 0 : O.todos) == null ? [] : E).map((e) => j(j(j(j({
|
|
76565
76598
|
id: e.id,
|
|
76566
76599
|
content: e.content,
|
|
76567
76600
|
status: e.status
|
|
76568
76601
|
}, e.parentId === void 0 ? {} : { parentId: e.parentId }), e.deps === void 0 ? {} : { deps: e.deps }), e.criteria === void 0 ? {} : { criteria: e.criteria }), e.evidence === void 0 ? {} : { evidence: e.evidence })),
|
|
76569
|
-
planPhase:
|
|
76570
|
-
mission:
|
|
76571
|
-
planConfirmation:
|
|
76572
|
-
workingMemory:
|
|
76573
|
-
focus:
|
|
76574
|
-
focuses:
|
|
76602
|
+
planPhase: Le.getPlanPhase(),
|
|
76603
|
+
mission: ln ? Re.getMission() : void 0,
|
|
76604
|
+
planConfirmation: Ve.lastPlanConfirmation,
|
|
76605
|
+
workingMemory: un ? Je.getWorkingMemory() : void 0,
|
|
76606
|
+
focus: Zt ? Ke.getFocus() : void 0,
|
|
76607
|
+
focuses: Zt ? Ke.getFocuses() : [],
|
|
76575
76608
|
actions: OFe((k = e.actions) == null ? {} : k),
|
|
76576
76609
|
subagent: {
|
|
76577
|
-
enabled: !!
|
|
76610
|
+
enabled: !!jn,
|
|
76578
76611
|
maxDepth: (A = (M = e.subagent) == null ? void 0 : M.maxDepth) == null ? 1 : A,
|
|
76579
76612
|
maxParallel: (ee = (te = e.subagent) == null ? void 0 : te.maxParallel) == null ? 4 : ee,
|
|
76580
76613
|
timeoutMs: ((N = e.subagent) == null ? void 0 : N.timeoutMs) === void 0 ? 18e5 : e.subagent.timeoutMs > 0 ? e.subagent.timeoutMs : 0,
|
|
76581
76614
|
allowedTools: (P = (ne = e.subagent) == null ? void 0 : ne.allowedTools) == null ? [] : P,
|
|
76582
|
-
subagents: ((re =
|
|
76583
|
-
active: (ie =
|
|
76584
|
-
history: (ae =
|
|
76585
|
-
lockedComponents: (oe =
|
|
76615
|
+
subagents: ((re = Ln == null ? void 0 : Ln.get()) == null ? [] : re).map(Rn),
|
|
76616
|
+
active: (ie = vn == null ? void 0 : vn.getActive()) == null ? [] : ie,
|
|
76617
|
+
history: (ae = vn == null ? void 0 : vn.getHistory()) == null ? [] : ae,
|
|
76618
|
+
lockedComponents: (oe = Nn == null ? void 0 : Nn.locked()) == null ? {} : oe
|
|
76586
76619
|
},
|
|
76587
76620
|
verify: {
|
|
76588
|
-
enabled: !!
|
|
76589
|
-
maxAttempts:
|
|
76590
|
-
adversarial:
|
|
76621
|
+
enabled: !!Vn,
|
|
76622
|
+
maxAttempts: Sn ? yn : 0,
|
|
76623
|
+
adversarial: Sn && !!((se = e.verify) != null && se.adversarial)
|
|
76591
76624
|
},
|
|
76592
76625
|
context: (() => {
|
|
76593
|
-
let e =
|
|
76626
|
+
let e = Hn == null ? void 0 : Hn.getSnapshot();
|
|
76594
76627
|
if (e) {
|
|
76595
76628
|
var t, n;
|
|
76596
76629
|
let r = (t = R.agent) == null || (n = t.getState) == null || (n = n.call(t)) == null ? void 0 : n.lastCompression;
|
|
@@ -76600,10 +76633,10 @@ function eIe(e, t, n) {
|
|
|
76600
76633
|
})(),
|
|
76601
76634
|
mcp: j({ servers: R.mcpServers }, R.mcpFailed.length ? { failed: R.mcpFailed } : {}),
|
|
76602
76635
|
lastCompression: (ce = R.agent) == null || (F = ce.getState) == null || (F = F.call(ce)) == null ? void 0 : F.lastCompression,
|
|
76603
|
-
checkpoints:
|
|
76636
|
+
checkpoints: dt ? {
|
|
76604
76637
|
enabled: !0,
|
|
76605
|
-
auto:
|
|
76606
|
-
list:
|
|
76638
|
+
auto: ft,
|
|
76639
|
+
list: dt.list()
|
|
76607
76640
|
} : void 0
|
|
76608
76641
|
});
|
|
76609
76642
|
},
|
|
@@ -76644,79 +76677,79 @@ function eIe(e, t, n) {
|
|
|
76644
76677
|
}));
|
|
76645
76678
|
},
|
|
76646
76679
|
getMission() {
|
|
76647
|
-
return
|
|
76680
|
+
return ln ? Re.getMission() : void 0;
|
|
76648
76681
|
},
|
|
76649
76682
|
setMission(t) {
|
|
76650
|
-
if (!
|
|
76683
|
+
if (!ln) {
|
|
76651
76684
|
e.debug && console.warn("[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略");
|
|
76652
76685
|
return;
|
|
76653
76686
|
}
|
|
76654
|
-
|
|
76687
|
+
Re.setMission(t), R.infoTick.value++;
|
|
76655
76688
|
},
|
|
76656
76689
|
getFocus() {
|
|
76657
|
-
return
|
|
76690
|
+
return Zt ? Ke.getFocus() : void 0;
|
|
76658
76691
|
},
|
|
76659
76692
|
getFocuses() {
|
|
76660
|
-
return
|
|
76693
|
+
return Zt ? Ke.getFocuses() : [];
|
|
76661
76694
|
},
|
|
76662
76695
|
setFocus(t) {
|
|
76663
|
-
let n = $Fe(t, "setFocus",
|
|
76696
|
+
let n = $Fe(t, "setFocus", Zt, () => {
|
|
76664
76697
|
var e;
|
|
76665
|
-
return (e =
|
|
76698
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
76666
76699
|
}, e.debug);
|
|
76667
|
-
return n.ok ? (
|
|
76700
|
+
return n.ok ? (Ke.setFocus(qe(t)), e.debug && Ke.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), R.infoTick.value++, { ok: !0 }) : n;
|
|
76668
76701
|
},
|
|
76669
76702
|
addFocus(t) {
|
|
76670
|
-
let n = $Fe(t, "addFocus",
|
|
76703
|
+
let n = $Fe(t, "addFocus", Zt, () => {
|
|
76671
76704
|
var e;
|
|
76672
|
-
return (e =
|
|
76705
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
76673
76706
|
}, e.debug);
|
|
76674
|
-
return n.ok ?
|
|
76707
|
+
return n.ok ? Ke.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
76675
76708
|
ok: !1,
|
|
76676
76709
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
76677
|
-
}) : (
|
|
76710
|
+
}) : (Ke.addFocus(qe(t)), e.debug && Ke.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), R.infoTick.value++, { ok: !0 }) : n;
|
|
76678
76711
|
},
|
|
76679
76712
|
removeFocus(e) {
|
|
76680
|
-
|
|
76713
|
+
Zt && (Ke.removeFocus(e), R.infoTick.value++);
|
|
76681
76714
|
},
|
|
76682
76715
|
clearFocus() {
|
|
76683
|
-
|
|
76716
|
+
Zt && (Ke.clearFocus(), R.infoTick.value++);
|
|
76684
76717
|
},
|
|
76685
76718
|
setQuote(e, t, n) {
|
|
76686
76719
|
let r = DZ(e == null ? "" : e), i = kZ(n);
|
|
76687
|
-
|
|
76720
|
+
gr.value = r ? j(j({ text: r }, t ? { source: t } : {}), i ? { anchor: i } : {}) : null;
|
|
76688
76721
|
},
|
|
76689
76722
|
notifyHostChange(e) {
|
|
76690
76723
|
var t;
|
|
76691
76724
|
let n = typeof (e == null ? void 0 : e.reason) == "string" ? e.reason.trim().slice(0, 200) : "";
|
|
76692
|
-
|
|
76725
|
+
Gn.epoch += 1, n && !Gn.notices.includes(n) ? Gn.notices.push(n) : n || Gn.notices.push(""), Gn.notices.length > 5 && Gn.notices.splice(0, Gn.notices.length - 5), (t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
76693
76726
|
timestamp: Date.now(),
|
|
76694
76727
|
type: "middleware",
|
|
76695
76728
|
data: {
|
|
76696
76729
|
stage: "host_change_notified",
|
|
76697
|
-
epoch:
|
|
76730
|
+
epoch: Gn.epoch,
|
|
76698
76731
|
reason: n || void 0
|
|
76699
76732
|
}
|
|
76700
76733
|
}), R.infoTick.value++;
|
|
76701
76734
|
},
|
|
76702
76735
|
clearQuote() {
|
|
76703
|
-
|
|
76736
|
+
gr.value = null;
|
|
76704
76737
|
},
|
|
76705
76738
|
resolveProposal(e, t, n) {
|
|
76706
|
-
let r =
|
|
76739
|
+
let r = zt ? zt.resolve(e, t, n) : !1;
|
|
76707
76740
|
return r && R.infoTick.value++, r;
|
|
76708
76741
|
},
|
|
76709
76742
|
getProposals() {
|
|
76710
|
-
return
|
|
76743
|
+
return zt ? zt.snapshot() : null;
|
|
76711
76744
|
}
|
|
76712
76745
|
};
|
|
76713
|
-
async function
|
|
76714
|
-
if (!
|
|
76746
|
+
async function _r() {
|
|
76747
|
+
if (!ye) return;
|
|
76715
76748
|
let n = async (e) => {
|
|
76716
76749
|
try {
|
|
76717
|
-
return await
|
|
76750
|
+
return await ye.load(t, e);
|
|
76718
76751
|
} catch (t) {
|
|
76719
|
-
|
|
76752
|
+
Qn({
|
|
76720
76753
|
type: "error",
|
|
76721
76754
|
message: `会话快照读取失败,已降级空会话:${t instanceof Error ? t.message : String(t)}`,
|
|
76722
76755
|
severity: "observable",
|
|
@@ -76727,9 +76760,9 @@ function eIe(e, t, n) {
|
|
|
76727
76760
|
}
|
|
76728
76761
|
}, r = async () => {
|
|
76729
76762
|
try {
|
|
76730
|
-
return await
|
|
76763
|
+
return await ye.listSessions(t);
|
|
76731
76764
|
} catch (e) {
|
|
76732
|
-
return
|
|
76765
|
+
return Qn({
|
|
76733
76766
|
type: "error",
|
|
76734
76767
|
message: `会话列表读取失败,已降级新建会话:${e instanceof Error ? e.message : String(e)}`,
|
|
76735
76768
|
severity: "observable",
|
|
@@ -76737,7 +76770,7 @@ function eIe(e, t, n) {
|
|
|
76737
76770
|
}), [];
|
|
76738
76771
|
}
|
|
76739
76772
|
}, i = Symbol("storage-ready-timeout");
|
|
76740
|
-
await Promise.race([
|
|
76773
|
+
await Promise.race([ye.ready.then(() => "ready"), new Promise((e) => setTimeout(() => e(i), 5e3))]) === i && (console.warn("[page-agent-sdk][persist] 存储初始化 5s 未就绪(可能被其他标签页锁住),已放行;持久化暂降级内存,就绪后自动恢复"), Qn({
|
|
76741
76774
|
type: "error",
|
|
76742
76775
|
message: "存储初始化 5s 未就绪(IDB blocked?),已放行降级运行",
|
|
76743
76776
|
severity: "observable",
|
|
@@ -76749,12 +76782,12 @@ function eIe(e, t, n) {
|
|
|
76749
76782
|
let e = await n(R.sessionId);
|
|
76750
76783
|
if (e) {
|
|
76751
76784
|
var o, s;
|
|
76752
|
-
R.applySnapshot(e),
|
|
76785
|
+
R.applySnapshot(e), Qn({
|
|
76753
76786
|
type: "session_restored",
|
|
76754
76787
|
sessionId: R.sessionId,
|
|
76755
76788
|
rounds: (o = (s = e.messages) == null ? void 0 : s.length) == null ? 0 : o
|
|
76756
76789
|
});
|
|
76757
|
-
} else await
|
|
76790
|
+
} else await ye.createSession(t, a.title, R.sessionId);
|
|
76758
76791
|
} else if (a.autoResume !== !1) {
|
|
76759
76792
|
let i = await r();
|
|
76760
76793
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", t, i.length, i.map((e) => e.sessionId)), i.length) {
|
|
@@ -76762,36 +76795,36 @@ function eIe(e, t, n) {
|
|
|
76762
76795
|
let t = await n(R.sessionId);
|
|
76763
76796
|
if (t) {
|
|
76764
76797
|
var c, l, u, d;
|
|
76765
|
-
R.applySnapshot(t),
|
|
76798
|
+
R.applySnapshot(t), Qn({
|
|
76766
76799
|
type: "session_restored",
|
|
76767
76800
|
sessionId: R.sessionId,
|
|
76768
76801
|
rounds: (c = (l = t.messages) == null ? void 0 : l.length) == null ? 0 : c
|
|
76769
76802
|
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", R.sessionId, `${(u = (d = t.messages) == null ? void 0 : d.length) == null ? 0 : u} msgs`);
|
|
76770
76803
|
} else e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", R.sessionId);
|
|
76771
|
-
} else R.sessionId = await
|
|
76772
|
-
} else R.sessionId = await
|
|
76773
|
-
e.memory &&
|
|
76804
|
+
} else R.sessionId = await ye.createSession(t, a.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", R.sessionId);
|
|
76805
|
+
} else R.sessionId = await ye.createSession(t, a.title);
|
|
76806
|
+
e.memory && Cr.persistSave({ memory: Ye.get() || (typeof e.memory == "string" ? e.memory : "") }), Cr.refreshSessions();
|
|
76774
76807
|
}
|
|
76775
|
-
async function
|
|
76776
|
-
await
|
|
76808
|
+
async function vr() {
|
|
76809
|
+
await ar();
|
|
76777
76810
|
}
|
|
76778
|
-
function
|
|
76811
|
+
function yr(e) {
|
|
76779
76812
|
let t = {};
|
|
76780
76813
|
for (let n of B8(e)) {
|
|
76781
|
-
let e =
|
|
76814
|
+
let e = Ie.files[n];
|
|
76782
76815
|
e && (t[n] = e.content);
|
|
76783
76816
|
}
|
|
76784
76817
|
return t;
|
|
76785
76818
|
}
|
|
76786
|
-
function
|
|
76787
|
-
let e = KFe(
|
|
76788
|
-
for (let t of e) delete
|
|
76819
|
+
function br() {
|
|
76820
|
+
let e = KFe(Ie.files, B8(Fe));
|
|
76821
|
+
for (let t of e) delete Ie.files[t];
|
|
76789
76822
|
}
|
|
76790
|
-
function
|
|
76791
|
-
let e = BTe(
|
|
76823
|
+
function xr() {
|
|
76824
|
+
let e = BTe(Fe, lr);
|
|
76792
76825
|
if (!e.trimmed) return;
|
|
76793
76826
|
let { older: t, summary: n } = e;
|
|
76794
|
-
if (
|
|
76827
|
+
if (Qn({
|
|
76795
76828
|
type: "context_trimmed",
|
|
76796
76829
|
dropped: t.map((e) => ({
|
|
76797
76830
|
round: e.round,
|
|
@@ -76802,61 +76835,61 @@ function eIe(e, t, n) {
|
|
|
76802
76835
|
return (t = e.steps) == null ? [] : t;
|
|
76803
76836
|
})
|
|
76804
76837
|
})),
|
|
76805
|
-
vfsResults:
|
|
76838
|
+
vfsResults: yr(t.flatMap((e) => [e.userMsg, ...e.assistantMsgs])),
|
|
76806
76839
|
summary: n.content,
|
|
76807
76840
|
reason: "max_memory_rounds"
|
|
76808
|
-
}),
|
|
76841
|
+
}), Fe.splice(e.deleteFrom, e.deleteCount, n), br(), je && xe) {
|
|
76809
76842
|
let n = e.summary, { prevSeg: r } = e;
|
|
76810
76843
|
(async () => {
|
|
76811
76844
|
try {
|
|
76812
|
-
let e = await
|
|
76845
|
+
let e = await xe(t1(t, Ne)), i = Fe.indexOf(n);
|
|
76813
76846
|
if (i < 0) return;
|
|
76814
|
-
|
|
76847
|
+
Fe[i].content = zTe(t, r, e), Cr.persistRuntime();
|
|
76815
76848
|
} catch (e) {}
|
|
76816
76849
|
})();
|
|
76817
76850
|
}
|
|
76818
76851
|
}
|
|
76819
|
-
let
|
|
76852
|
+
let Sr = pCe({
|
|
76820
76853
|
getConfig: () => e.images,
|
|
76821
|
-
getVision: () =>
|
|
76822
|
-
emit:
|
|
76854
|
+
getVision: () => we.vision === !0,
|
|
76855
|
+
emit: Qn,
|
|
76823
76856
|
getVfsStore: () => R.vfsStore,
|
|
76824
|
-
noteFailure: (e, t) =>
|
|
76825
|
-
}),
|
|
76857
|
+
noteFailure: (e, t) => Cr.notePersistFailure(e, t)
|
|
76858
|
+
}), Cr = sNe({
|
|
76826
76859
|
agentId: t,
|
|
76827
76860
|
options: e,
|
|
76828
|
-
emit:
|
|
76829
|
-
getStore: () =>
|
|
76861
|
+
emit: Qn,
|
|
76862
|
+
getStore: () => ye,
|
|
76830
76863
|
core: R,
|
|
76831
|
-
sessionsRef:
|
|
76832
|
-
sessionVars:
|
|
76833
|
-
messages:
|
|
76834
|
-
getUsage: () =>
|
|
76864
|
+
sessionsRef: dr,
|
|
76865
|
+
sessionVars: Ve,
|
|
76866
|
+
messages: Fe,
|
|
76867
|
+
getUsage: () => ge,
|
|
76835
76868
|
mw: {
|
|
76836
|
-
todosMw:
|
|
76837
|
-
memoryMw:
|
|
76838
|
-
missionMw:
|
|
76839
|
-
workingMemoryMw:
|
|
76840
|
-
focusMw:
|
|
76841
|
-
summarizationMw:
|
|
76842
|
-
resumeNoticeMw:
|
|
76843
|
-
useMission:
|
|
76844
|
-
useWorkingMemory:
|
|
76845
|
-
useFocus:
|
|
76846
|
-
useAutomation:
|
|
76869
|
+
todosMw: Le,
|
|
76870
|
+
memoryMw: Ye,
|
|
76871
|
+
missionMw: Re,
|
|
76872
|
+
workingMemoryMw: Je,
|
|
76873
|
+
focusMw: Ke,
|
|
76874
|
+
summarizationMw: or,
|
|
76875
|
+
resumeNoticeMw: Be,
|
|
76876
|
+
useMission: ln,
|
|
76877
|
+
useWorkingMemory: un,
|
|
76878
|
+
useFocus: Zt,
|
|
76879
|
+
useAutomation: gt
|
|
76847
76880
|
},
|
|
76848
|
-
vfsStore:
|
|
76849
|
-
checkpointMgr:
|
|
76850
|
-
conflictResolve: (e) =>
|
|
76851
|
-
abortAllActive:
|
|
76852
|
-
titleLlmInvoke:
|
|
76881
|
+
vfsStore: Ie,
|
|
76882
|
+
checkpointMgr: dt,
|
|
76883
|
+
conflictResolve: (e) => _e.resolve(e),
|
|
76884
|
+
abortAllActive: hr,
|
|
76885
|
+
titleLlmInvoke: Se
|
|
76853
76886
|
});
|
|
76854
76887
|
return R.initDone = (async () => {
|
|
76855
76888
|
var t, n, r, i;
|
|
76856
|
-
await
|
|
76889
|
+
await _r(), await vr(), (t = e.mcp) != null && t.length && FAe({
|
|
76857
76890
|
servers: e.mcp,
|
|
76858
|
-
emit:
|
|
76859
|
-
isReleased: () =>
|
|
76891
|
+
emit: Qn,
|
|
76892
|
+
isReleased: () => qt,
|
|
76860
76893
|
core: {
|
|
76861
76894
|
mcpClosers: R.mcpClosers,
|
|
76862
76895
|
mcpServers: R.mcpServers,
|
|
@@ -76865,47 +76898,47 @@ function eIe(e, t, n) {
|
|
|
76865
76898
|
},
|
|
76866
76899
|
reservedNames: () => {
|
|
76867
76900
|
let e = /* @__PURE__ */ new Set();
|
|
76868
|
-
for (let t of
|
|
76869
|
-
let n =
|
|
76901
|
+
for (let t of sn) {
|
|
76902
|
+
let n = kt.get(t.name);
|
|
76870
76903
|
n && !n.startsWith("mcp:") && e.add(t.name);
|
|
76871
76904
|
}
|
|
76872
76905
|
return e;
|
|
76873
76906
|
},
|
|
76874
|
-
pushTool: (e, t) => (
|
|
76907
|
+
pushTool: (e, t) => (kt.set(e.name, `mcp:${t}`), Kt.push(e), !0),
|
|
76875
76908
|
rebind: () => {
|
|
76876
|
-
|
|
76909
|
+
sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76877
76910
|
},
|
|
76878
76911
|
debug: e.debug
|
|
76879
76912
|
});
|
|
76880
76913
|
let a = Q6(e.llm) ? e.llm : await RG(e.llm);
|
|
76881
|
-
SMe(a, { emit:
|
|
76914
|
+
SMe(a, { emit: Qn }), R.agent = VQ({
|
|
76882
76915
|
llm: a,
|
|
76883
|
-
systemPrompt:
|
|
76884
|
-
tools:
|
|
76885
|
-
middleware:
|
|
76916
|
+
systemPrompt: vt,
|
|
76917
|
+
tools: sn,
|
|
76918
|
+
middleware: cr,
|
|
76886
76919
|
maxToolRounds: e.maxToolRounds,
|
|
76887
|
-
hasSubagent:
|
|
76888
|
-
pageAssertionGate:
|
|
76889
|
-
pageReadTools:
|
|
76890
|
-
deferredWriteTools:
|
|
76920
|
+
hasSubagent: _n,
|
|
76921
|
+
pageAssertionGate: pt.domInspect === !0,
|
|
76922
|
+
pageReadTools: Wt.size ? Wt : void 0,
|
|
76923
|
+
deferredWriteTools: Gt.size ? Gt : void 0,
|
|
76891
76924
|
maxRetries: e.maxRetries,
|
|
76892
76925
|
stallMs: (n = e.streamStallMs) == null ? BZ : n,
|
|
76893
76926
|
streamMaxMs: (r = e.streamMaxDurationMs) == null ? BCe : r,
|
|
76894
76927
|
toolTimeoutMs: e.toolTimeoutMs,
|
|
76895
76928
|
maxParallelTools: e.maxParallelTools,
|
|
76896
|
-
contextWindow:
|
|
76897
|
-
maxOutputTokens:
|
|
76898
|
-
vision:
|
|
76899
|
-
imageContentFormat:
|
|
76900
|
-
maxVerifyAttempts:
|
|
76929
|
+
contextWindow: we.contextWindow,
|
|
76930
|
+
maxOutputTokens: we.maxOutputTokens,
|
|
76931
|
+
vision: we.vision,
|
|
76932
|
+
imageContentFormat: Pt,
|
|
76933
|
+
maxVerifyAttempts: Sn ? yn : 0,
|
|
76901
76934
|
roundTokenBudget: (i = e.roundTokenBudget) == null ? 0 : i,
|
|
76902
76935
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
76903
76936
|
onLlmChange: (e) => {
|
|
76904
|
-
|
|
76937
|
+
Pe = e;
|
|
76905
76938
|
},
|
|
76906
76939
|
debug: e.debug
|
|
76907
|
-
}),
|
|
76908
|
-
R.agent && R.agent.setTools(
|
|
76940
|
+
}), Xe.current = R.agent, In && In.setReconfigureHook(() => {
|
|
76941
|
+
R.agent && R.agent.setTools(on());
|
|
76909
76942
|
});
|
|
76910
76943
|
})(), R;
|
|
76911
76944
|
}
|
|
@@ -91214,7 +91247,7 @@ var lGe = {
|
|
|
91214
91247
|
_: 1
|
|
91215
91248
|
})]));
|
|
91216
91249
|
}
|
|
91217
|
-
}), [["__scopeId", "data-v-
|
|
91250
|
+
}), [["__scopeId", "data-v-6d9e98b4"]]), vYe = ["title"], yYe = /*#__PURE__*/ h9(/* @__PURE__ */ HJ({
|
|
91218
91251
|
__name: "SelectionMenu",
|
|
91219
91252
|
emits: ["quote"],
|
|
91220
91253
|
setup(e, { emit: t }) {
|