page-agent-sdk 4.24.0 → 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/dist/page-agent-sdk.headless.js +1138 -1138
- package/dist/page-agent-sdk.iife.js +8 -8
- package/dist/page-agent-sdk.js +878 -878
- package/dist/page-agent-sdk.legacy.js +579 -576
- package/dist/page-agent-sdk.umd.cjs +6 -6
- package/package.json +1 -1
- package/types/headless.d.ts +2 -2
- package/types/index.d.ts +5 -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,
|
|
@@ -75448,19 +75448,19 @@ function $Fe(e, t, n, r, i) {
|
|
|
75448
75448
|
});
|
|
75449
75449
|
}
|
|
75450
75450
|
function eIe(e, t, n) {
|
|
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;
|
|
75452
|
-
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 = {
|
|
75453
75453
|
prompt_tokens: 0,
|
|
75454
75454
|
completion_tokens: 0,
|
|
75455
75455
|
total_tokens: 0
|
|
75456
|
-
},
|
|
75456
|
+
}, _e = jMe(() => Qn, () => {
|
|
75457
75457
|
var t;
|
|
75458
75458
|
return (t = e.conflictPolicy) == null ? "ask" : t;
|
|
75459
75459
|
}, () => {
|
|
75460
75460
|
var e;
|
|
75461
75461
|
return (e = R.agent) == null || (e = e.debugLogs) == null ? void 0 : e.value;
|
|
75462
|
-
}),
|
|
75463
|
-
|
|
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) => {
|
|
75464
75464
|
if (e.type === "quota") {
|
|
75465
75465
|
var t;
|
|
75466
75466
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
@@ -75474,22 +75474,22 @@ function eIe(e, t, n) {
|
|
|
75474
75474
|
});
|
|
75475
75475
|
}
|
|
75476
75476
|
}));
|
|
75477
|
-
let { modelCaps:
|
|
75478
|
-
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)`);
|
|
75479
75479
|
{
|
|
75480
|
-
var
|
|
75481
|
-
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);
|
|
75482
75482
|
i && console.warn(i);
|
|
75483
75483
|
}
|
|
75484
|
-
let
|
|
75485
|
-
e.debug && !
|
|
75486
|
-
let
|
|
75487
|
-
persist:
|
|
75488
|
-
|
|
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 });
|
|
75489
75489
|
} } : void 0,
|
|
75490
75490
|
maxBytes: (o = e.vfs) == null ? void 0 : o.maxBytes,
|
|
75491
75491
|
poolBytes: (s = e.vfs) == null ? void 0 : s.poolBytes
|
|
75492
|
-
}),
|
|
75492
|
+
}), Le = CQ([], { maxPlanRevisions: e.maxPlanRevisions }), Re = yTe(), ze = Rwe((e) => {
|
|
75493
75493
|
var t;
|
|
75494
75494
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
75495
75495
|
timestamp: Date.now(),
|
|
@@ -75499,24 +75499,24 @@ function eIe(e, t, n) {
|
|
|
75499
75499
|
preview: e
|
|
75500
75500
|
}
|
|
75501
75501
|
});
|
|
75502
|
-
}),
|
|
75502
|
+
}), Be = xTe(() => {
|
|
75503
75503
|
var e;
|
|
75504
75504
|
(e = R.agent) == null || (e = e.debugLogs) == null || (e = e.value) == null || e.push({
|
|
75505
75505
|
timestamp: Date.now(),
|
|
75506
75506
|
type: "middleware",
|
|
75507
75507
|
data: { stage: "resume_notice" }
|
|
75508
75508
|
});
|
|
75509
|
-
}),
|
|
75510
|
-
|
|
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({
|
|
75511
75511
|
type: "error",
|
|
75512
75512
|
message: `确认请求(${e.toolName})${Math.round(e.waitedMs / 1e3)}s 无响应已自动拒绝 —— 当前路径无 UI 响应方;可传 approval.timeoutMs 调整(Infinity = 无限等)`,
|
|
75513
75513
|
severity: "observable",
|
|
75514
75514
|
code: "APPROVAL_AUTO_REJECTED",
|
|
75515
75515
|
context: e
|
|
75516
75516
|
});
|
|
75517
|
-
},
|
|
75517
|
+
}, Ge = S1((e) => {
|
|
75518
75518
|
var t;
|
|
75519
|
-
|
|
75519
|
+
Ve.lastPlanConfirmation = e, Cr.persistSave({ planConfirmation: e }), (t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
75520
75520
|
timestamp: Date.now(),
|
|
75521
75521
|
type: "middleware",
|
|
75522
75522
|
data: {
|
|
@@ -75526,97 +75526,97 @@ function eIe(e, t, n) {
|
|
|
75526
75526
|
}
|
|
75527
75527
|
});
|
|
75528
75528
|
}, {
|
|
75529
|
-
timeoutMs:
|
|
75530
|
-
onAutoReject:
|
|
75531
|
-
}),
|
|
75529
|
+
timeoutMs: Ue,
|
|
75530
|
+
onAutoReject: We
|
|
75531
|
+
}), Ke = z$({
|
|
75532
75532
|
getSchema: () => {
|
|
75533
75533
|
var e;
|
|
75534
|
-
return (e =
|
|
75534
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
75535
75535
|
},
|
|
75536
75536
|
getBind: () => {
|
|
75537
75537
|
var e;
|
|
75538
|
-
return (e =
|
|
75538
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75539
75539
|
},
|
|
75540
|
-
onChange: (e) =>
|
|
75540
|
+
onChange: (e) => Qn({
|
|
75541
75541
|
type: "focus_change",
|
|
75542
75542
|
focuses: e
|
|
75543
75543
|
})
|
|
75544
|
-
}),
|
|
75544
|
+
}), qe = (e) => {
|
|
75545
75545
|
var t;
|
|
75546
|
-
let n = TTe((t =
|
|
75546
|
+
let n = TTe((t = wt()) == null ? void 0 : t.bind, e.path);
|
|
75547
75547
|
return n ? j(j({}, e), {}, { pgId: n }) : e;
|
|
75548
|
-
},
|
|
75549
|
-
typeof e.memory == "function" &&
|
|
75550
|
-
let
|
|
75551
|
-
if (
|
|
75552
|
-
var
|
|
75553
|
-
|
|
75554
|
-
}
|
|
75555
|
-
let
|
|
75556
|
-
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) {
|
|
75557
75557
|
if (e._codeAsset.writablePaths.length) continue;
|
|
75558
|
-
let t = e$(
|
|
75558
|
+
let t = e$(Ze == null ? void 0 : Ze.schema, e._codeAsset.codeField);
|
|
75559
75559
|
if (t.length) {
|
|
75560
|
-
var
|
|
75561
|
-
e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), (
|
|
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'])"),
|
|
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);
|
|
75563
75563
|
}
|
|
75564
|
-
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({
|
|
75565
75565
|
getData: () => {
|
|
75566
75566
|
var e;
|
|
75567
|
-
return (e =
|
|
75567
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75568
75568
|
},
|
|
75569
75569
|
consumeDataDirty: () => {
|
|
75570
75570
|
var e, t;
|
|
75571
|
-
return (e =
|
|
75571
|
+
return (e = xt == null || (t = xt.consumeDataDirty) == null ? void 0 : t.call(xt)) == null || e;
|
|
75572
75572
|
},
|
|
75573
|
-
slotPaths:
|
|
75574
|
-
vfsStore:
|
|
75575
|
-
todosMw:
|
|
75573
|
+
slotPaths: Ze ? [""] : [],
|
|
75574
|
+
vfsStore: Ie,
|
|
75575
|
+
todosMw: Le,
|
|
75576
75576
|
getTodos: () => {
|
|
75577
75577
|
var e, t, n;
|
|
75578
|
-
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;
|
|
75579
75579
|
},
|
|
75580
|
-
messages:
|
|
75581
|
-
maxCheckpoints:
|
|
75582
|
-
}) : 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), {}, {
|
|
75583
75583
|
locale: (m = e.i18n) == null ? void 0 : m.locale,
|
|
75584
|
-
dataOps:
|
|
75585
|
-
domInspect:
|
|
75586
|
-
screenshot:
|
|
75584
|
+
dataOps: mt && !!Ze,
|
|
75585
|
+
domInspect: pt.domInspect === !0,
|
|
75586
|
+
screenshot: _t
|
|
75587
75587
|
}));
|
|
75588
|
-
if (
|
|
75589
|
-
let e =
|
|
75590
|
-
e && (
|
|
75591
|
-
} else
|
|
75592
|
-
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({
|
|
75593
75593
|
onAudit: (h = e.onAudit) == null ? e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0 : h,
|
|
75594
75594
|
maxSnapshots: e.maxSnapshots,
|
|
75595
|
-
onConflict:
|
|
75595
|
+
onConflict: _e.set,
|
|
75596
75596
|
conflictWatchFields: e.conflictWatchFields,
|
|
75597
75597
|
maxParallelTools: e.maxParallelTools,
|
|
75598
|
-
vfsStore:
|
|
75599
|
-
},
|
|
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: () => {
|
|
75600
75600
|
var e, t;
|
|
75601
|
-
return (e =
|
|
75602
|
-
} }) : void 0,
|
|
75601
|
+
return (e = xt == null || (t = xt.getResourcesSnapshot) == null ? void 0 : t.call(xt)) == null ? [] : e;
|
|
75602
|
+
} }) : void 0, wt = () => {
|
|
75603
75603
|
var e;
|
|
75604
|
-
return (e =
|
|
75605
|
-
},
|
|
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({
|
|
75606
75606
|
getBind: () => {
|
|
75607
75607
|
var e;
|
|
75608
|
-
return (e =
|
|
75608
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75609
75609
|
},
|
|
75610
75610
|
recomputeAll: () => {
|
|
75611
75611
|
var e;
|
|
75612
|
-
return (e =
|
|
75612
|
+
return (e = xt.recomputeAllBaselines) == null ? void 0 : e.call(xt);
|
|
75613
75613
|
},
|
|
75614
75614
|
hasBaselines: () => {
|
|
75615
75615
|
var e, t;
|
|
75616
|
-
return (e = (t =
|
|
75616
|
+
return (e = (t = xt.hasBaselines) == null ? void 0 : t.call(xt)) != null && e;
|
|
75617
75617
|
},
|
|
75618
|
-
isManaged: (e) =>
|
|
75619
|
-
hash: (e) =>
|
|
75618
|
+
isManaged: (e) => Tt.has(e),
|
|
75619
|
+
hash: (e) => Dt ? D$(C1(e), Dt) : E$(C1(e)),
|
|
75620
75620
|
log: (e, t) => {
|
|
75621
75621
|
var n;
|
|
75622
75622
|
let r = (n = R.agent) == null ? void 0 : n.debugLogs;
|
|
@@ -75626,34 +75626,34 @@ function eIe(e, t, n) {
|
|
|
75626
75626
|
data: j({ stage: "baseline_guard" }, t)
|
|
75627
75627
|
}), zq(r));
|
|
75628
75628
|
}
|
|
75629
|
-
}) : void 0,
|
|
75630
|
-
|
|
75631
|
-
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) => {
|
|
75632
75632
|
if (e.type === "tool_result" && e.name === "take_screenshot") {
|
|
75633
|
-
let t =
|
|
75633
|
+
let t = At.find((e) => !e.eventConsumed);
|
|
75634
75634
|
if (t) return t.eventConsumed = !0, Object.assign(e, { image: {
|
|
75635
75635
|
dataUri: t.image.dataUri,
|
|
75636
75636
|
vfsRef: t.meta.vfsRef
|
|
75637
75637
|
} });
|
|
75638
75638
|
}
|
|
75639
75639
|
return e;
|
|
75640
|
-
},
|
|
75641
|
-
getVision: () =>
|
|
75640
|
+
}, Mt = we.vision === !0 || typeof ((b = e.images) == null ? void 0 : b.describe) == "function" ? DPe({
|
|
75641
|
+
getVision: () => we.vision === !0,
|
|
75642
75642
|
describe: (x = e.images) == null ? void 0 : x.describe,
|
|
75643
75643
|
onShot: (e, t) => {
|
|
75644
|
-
|
|
75644
|
+
At.push({
|
|
75645
75645
|
image: e,
|
|
75646
75646
|
meta: t
|
|
75647
75647
|
});
|
|
75648
75648
|
}
|
|
75649
|
-
}) : void 0,
|
|
75649
|
+
}) : void 0, Nt = _t ? TPe({
|
|
75650
75650
|
render: (S = e.screenshot) == null ? void 0 : S.renderer,
|
|
75651
75651
|
getActiveFocus: () => R.getFocus(),
|
|
75652
75652
|
focusSelector: (C = e.screenshot) == null ? void 0 : C.focusSelector,
|
|
75653
75653
|
stow: (e) => {
|
|
75654
75654
|
if (e.dataUri) try {
|
|
75655
75655
|
let t = `userImages/${e.id}`;
|
|
75656
|
-
return
|
|
75656
|
+
return Ie.files[t] = {
|
|
75657
75657
|
content: e.dataUri,
|
|
75658
75658
|
updatedAt: Date.now()
|
|
75659
75659
|
}, t;
|
|
@@ -75661,30 +75661,30 @@ function eIe(e, t, n) {
|
|
|
75661
75661
|
return;
|
|
75662
75662
|
}
|
|
75663
75663
|
},
|
|
75664
|
-
getVision: () =>
|
|
75664
|
+
getVision: () => we.vision === !0,
|
|
75665
75665
|
describe: (w = e.images) == null ? void 0 : w.describe,
|
|
75666
75666
|
onShot: (e, t) => {
|
|
75667
|
-
|
|
75667
|
+
At.push({
|
|
75668
75668
|
image: e,
|
|
75669
75669
|
meta: t
|
|
75670
75670
|
});
|
|
75671
75671
|
}
|
|
75672
|
-
}) : void 0,
|
|
75672
|
+
}) : void 0, Pt = !Q6(e.llm) && ((T = e.llm.provider) == null ? "openai" : T) === "anthropic" ? "anthropic" : "openai", Ft = Nt || Mt ? {
|
|
75673
75673
|
name: "screenshotChannel",
|
|
75674
75674
|
wrapModelCall: async (e, t) => {
|
|
75675
|
-
if (
|
|
75676
|
-
let t =
|
|
75675
|
+
if (At.length) {
|
|
75676
|
+
let t = At.splice(0), n = wZ(t.map((e, t) => {
|
|
75677
75677
|
var n;
|
|
75678
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})` : ""}`;
|
|
75679
75679
|
}).join("\n") + "\n(视觉内容如上,请结合图片回答/继续)", t.map((e) => ({
|
|
75680
75680
|
dataUri: e.image.dataUri,
|
|
75681
75681
|
url: e.image.url
|
|
75682
|
-
})),
|
|
75682
|
+
})), Pt);
|
|
75683
75683
|
n && e.messages.push(new Hy({ content: n }));
|
|
75684
75684
|
}
|
|
75685
75685
|
return t(e);
|
|
75686
75686
|
}
|
|
75687
|
-
} : null,
|
|
75687
|
+
} : null, It = !1, Lt = pt.domEdit ? zPe({
|
|
75688
75688
|
onEdit: (e) => {
|
|
75689
75689
|
var t;
|
|
75690
75690
|
(t = R.agent) == null || (t = t.debugLogs) == null || (t = t.value) == null || t.push({
|
|
@@ -75696,22 +75696,22 @@ function eIe(e, t, n) {
|
|
|
75696
75696
|
applied: e.applied,
|
|
75697
75697
|
dryRun: e.dryRun
|
|
75698
75698
|
}
|
|
75699
|
-
}), !e.dryRun && e.applied > 0 && (
|
|
75699
|
+
}), !e.dryRun && e.applied > 0 && (It = !0);
|
|
75700
75700
|
},
|
|
75701
75701
|
onRestore: (e) => {
|
|
75702
|
-
e.restored > 0 && (
|
|
75702
|
+
e.restored > 0 && (It = !0);
|
|
75703
75703
|
}
|
|
75704
|
-
}) : [],
|
|
75704
|
+
}) : [], Rt = [...MFe(pt, bt, A8, pt.domInspect ? [
|
|
75705
75705
|
...j8,
|
|
75706
|
-
...
|
|
75707
|
-
...
|
|
75708
|
-
...
|
|
75709
|
-
] : [], TFe), ...
|
|
75710
|
-
|
|
75711
|
-
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, {
|
|
75712
75712
|
emit: (e) => {
|
|
75713
75713
|
try {
|
|
75714
|
-
|
|
75714
|
+
Qn(e);
|
|
75715
75715
|
} catch (e) {}
|
|
75716
75716
|
},
|
|
75717
75717
|
log: (e, t) => {
|
|
@@ -75725,21 +75725,21 @@ function eIe(e, t, n) {
|
|
|
75725
75725
|
}, t)
|
|
75726
75726
|
});
|
|
75727
75727
|
}
|
|
75728
|
-
}) : null,
|
|
75729
|
-
|
|
75730
|
-
let
|
|
75731
|
-
|
|
75732
|
-
let
|
|
75733
|
-
|
|
75734
|
-
let
|
|
75735
|
-
let e =
|
|
75736
|
-
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,无法回退。";
|
|
75737
75737
|
}, {
|
|
75738
75738
|
name: "restore_last_checkpoint",
|
|
75739
75739
|
description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
75740
75740
|
schema: B({}).optional()
|
|
75741
75741
|
}), qP(async () => {
|
|
75742
|
-
let e =
|
|
75742
|
+
let e = dt.list();
|
|
75743
75743
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => {
|
|
75744
75744
|
var t;
|
|
75745
75745
|
return `#${e.id} [${(t = e.label) == null ? "auto" : t}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`;
|
|
@@ -75749,11 +75749,11 @@ function eIe(e, t, n) {
|
|
|
75749
75749
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
75750
75750
|
schema: B({}).optional()
|
|
75751
75751
|
})] : [];
|
|
75752
|
-
|
|
75753
|
-
let
|
|
75752
|
+
Xt.forEach((e) => kt.set(e.name, "builtin"));
|
|
75753
|
+
let Zt = pt.focus, Qt = qP(async ({ path: e, label: t }) => {
|
|
75754
75754
|
var n;
|
|
75755
|
-
let r = (n =
|
|
75756
|
-
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,无法聚焦。";
|
|
75757
75757
|
}, {
|
|
75758
75758
|
name: "set_focus",
|
|
75759
75759
|
description: "聚焦到指定组件子树(如 components.3)精修,替换全部已有焦点(非累积;要保留已有焦点追加用 add_focus)。聚焦后:仅可写该子树(越界 PATH_DENIED)+ 每轮只看到该组件结构。多组件页面精修其中一个时用,避免改到别处。先 read 定位 path 再聚焦;完成调 clear_focus。",
|
|
@@ -75761,17 +75761,17 @@ function eIe(e, t, n) {
|
|
|
75761
75761
|
path: z().describe("要聚焦的组件 jsonPath,如 components.3"),
|
|
75762
75762
|
label: z().optional().describe("人类可读标签,如「导航栏」")
|
|
75763
75763
|
})
|
|
75764
|
-
}),
|
|
75764
|
+
}), $t = qP(async () => (Ke.clearFocus("agent"), "已清除聚焦,恢复全量可操作范围(可读写所有组件)。"), {
|
|
75765
75765
|
name: "clear_focus",
|
|
75766
75766
|
description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
|
|
75767
75767
|
schema: B({}).optional()
|
|
75768
|
-
}),
|
|
75768
|
+
}), en = qP(async ({ path: e, label: t }) => {
|
|
75769
75769
|
var n;
|
|
75770
|
-
let r = (n =
|
|
75770
|
+
let r = (n = wt()) == null ? void 0 : n.schema;
|
|
75771
75771
|
if (!r) return "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
75772
75772
|
if (!GQ(r, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
|
|
75773
|
-
|
|
75774
|
-
let i =
|
|
75773
|
+
Ke.addFocus(qe(j({ path: e }, t ? { label: t } : {})), "agent");
|
|
75774
|
+
let i = Ke.getFocuses();
|
|
75775
75775
|
return `已聚焦 ${e}${t ? `(${t})` : ""}(当前共 ${i.length} 个焦点:${i.map((e) => e.path).join(", ")})。后续仅可写这些子树之一(越界被拒)。`;
|
|
75776
75776
|
}, {
|
|
75777
75777
|
name: "add_focus",
|
|
@@ -75780,81 +75780,84 @@ function eIe(e, t, n) {
|
|
|
75780
75780
|
path: z().describe("要追加聚焦的组件 jsonPath,如 components.3"),
|
|
75781
75781
|
label: z().optional().describe("人类可读标签")
|
|
75782
75782
|
})
|
|
75783
|
-
}),
|
|
75784
|
-
let t =
|
|
75785
|
-
|
|
75786
|
-
let n =
|
|
75783
|
+
}), tn = qP(async ({ path: e }) => {
|
|
75784
|
+
let t = Ke.getFocuses().length;
|
|
75785
|
+
Ke.removeFocus(e, "agent");
|
|
75786
|
+
let n = Ke.getFocuses();
|
|
75787
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},聚焦已清空,恢复全量操作范围。`;
|
|
75788
75788
|
}, {
|
|
75789
75789
|
name: "remove_focus",
|
|
75790
75790
|
description: "移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。",
|
|
75791
75791
|
schema: B({ path: z().describe("要移除的焦点 jsonPath") })
|
|
75792
|
-
}),
|
|
75793
|
-
Xt,
|
|
75794
|
-
Zt,
|
|
75792
|
+
}), nn = Zt ? [
|
|
75795
75793
|
Qt,
|
|
75796
|
-
$t
|
|
75794
|
+
$t,
|
|
75795
|
+
en,
|
|
75796
|
+
tn
|
|
75797
75797
|
] : [];
|
|
75798
|
-
|
|
75799
|
-
let
|
|
75800
|
-
builtinTools: () =>
|
|
75801
|
-
userTools: () =>
|
|
75802
|
-
actionTools: () =>
|
|
75803
|
-
humanConfirmTool: () =>
|
|
75804
|
-
checkpointTools: () =>
|
|
75805
|
-
focusTools: () =>
|
|
75806
|
-
mcpTools: () =>
|
|
75807
|
-
loadedSkillTools: () =>
|
|
75808
|
-
}),
|
|
75809
|
-
if (
|
|
75810
|
-
if (
|
|
75811
|
-
var
|
|
75812
|
-
for (let e of (
|
|
75813
|
-
}
|
|
75814
|
-
let
|
|
75815
|
-
e.debug &&
|
|
75816
|
-
let
|
|
75817
|
-
|
|
75818
|
-
let
|
|
75819
|
-
|
|
75820
|
-
|
|
75821
|
-
|
|
75822
|
-
|
|
75823
|
-
|
|
75824
|
-
|
|
75825
|
-
|
|
75826
|
-
|
|
75827
|
-
|
|
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,
|
|
75828
75831
|
allTools: () => {
|
|
75829
75832
|
var e, t;
|
|
75830
|
-
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;
|
|
75831
75834
|
},
|
|
75832
|
-
allowedTools:
|
|
75835
|
+
allowedTools: Tn.length ? Tn : void 0
|
|
75833
75836
|
}, e.staleReadInvalidation === void 0 ? {} : { staleReadInvalidation: e.staleReadInvalidation }), {}, {
|
|
75834
|
-
systemPrompt:
|
|
75835
|
-
temperature:
|
|
75836
|
-
maxTokens:
|
|
75837
|
-
skills:
|
|
75838
|
-
maxDepth:
|
|
75839
|
-
maxParallel:
|
|
75840
|
-
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,
|
|
75841
75844
|
debug: e.debug,
|
|
75842
|
-
getFocuses: () =>
|
|
75845
|
+
getFocuses: () => Ke.getActiveFocuses(),
|
|
75843
75846
|
getSchema: () => {
|
|
75844
75847
|
var e, t;
|
|
75845
|
-
return (e = (t =
|
|
75848
|
+
return (e = (t = wt()) == null ? void 0 : t.schema) == null ? null : e;
|
|
75846
75849
|
},
|
|
75847
|
-
tracker:
|
|
75848
|
-
guardMiddleware:
|
|
75849
|
-
getVfsFiles:
|
|
75850
|
-
enterDataScope:
|
|
75851
|
-
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,
|
|
75852
75855
|
onUsage: (e) => {
|
|
75853
75856
|
var t, n, r, i, a, o, s;
|
|
75854
|
-
|
|
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);
|
|
75855
75858
|
},
|
|
75856
|
-
timeoutMs:
|
|
75857
|
-
})),
|
|
75859
|
+
timeoutMs: wn == null ? void 0 : wn.timeoutMs
|
|
75860
|
+
})), Mn = at == null ? void 0 : at.map((e) => {
|
|
75858
75861
|
var t;
|
|
75859
75862
|
if (!e._codeAsset) return e;
|
|
75860
75863
|
let n = e._codeAsset, r = Nje({
|
|
@@ -75864,109 +75867,109 @@ function eIe(e, t, n) {
|
|
|
75864
75867
|
codeField: n.codeField,
|
|
75865
75868
|
craftNotes: n.craftNotes,
|
|
75866
75869
|
onWarning: (e) => console.warn(`[page-agent-sdk][code-asset] ${e}`),
|
|
75867
|
-
getController: () =>
|
|
75868
|
-
vfsStore:
|
|
75870
|
+
getController: () => xt,
|
|
75871
|
+
vfsStore: Ie
|
|
75869
75872
|
}), i = [...(t = e.middleware) == null ? [] : t, r];
|
|
75870
|
-
for (let e of i) e && Wwe(e) && e._setGetController(() =>
|
|
75873
|
+
for (let e of i) e && Wwe(e) && e._setGetController(() => xt);
|
|
75871
75874
|
return j(j({}, e), {}, { middleware: i });
|
|
75872
|
-
}),
|
|
75875
|
+
}), Nn = ot && _n ? Pje() : void 0, Pn = Nn ? Bje({
|
|
75873
75876
|
getBind: () => {
|
|
75874
75877
|
var e;
|
|
75875
|
-
return (e =
|
|
75878
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75876
75879
|
},
|
|
75877
|
-
writablePaths:
|
|
75878
|
-
getLocked: () =>
|
|
75879
|
-
tools:
|
|
75880
|
+
writablePaths: st,
|
|
75881
|
+
getLocked: () => Nn.locked(),
|
|
75882
|
+
tools: sn,
|
|
75880
75883
|
getCodeFieldPaths: () => {
|
|
75881
75884
|
var e;
|
|
75882
|
-
return Rje((e =
|
|
75885
|
+
return Rje((e = wt()) == null ? void 0 : e.bind, it.map((e) => ({
|
|
75883
75886
|
writablePaths: e._codeAsset.writablePaths,
|
|
75884
75887
|
codeField: e._codeAsset.codeField
|
|
75885
75888
|
})));
|
|
75886
75889
|
}
|
|
75887
|
-
}) : void 0,
|
|
75888
|
-
getSummarizedPaths: () =>
|
|
75889
|
-
clearSummarizedPaths: () =>
|
|
75890
|
-
}) : 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({
|
|
75891
75894
|
llm: e.llm,
|
|
75892
|
-
thinkingModeDefault: (
|
|
75895
|
+
thinkingModeDefault: (de = e.subagent) == null ? void 0 : de.thinkingMode,
|
|
75893
75896
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
75894
75897
|
allTools: () => {
|
|
75895
75898
|
var e, t;
|
|
75896
|
-
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;
|
|
75897
75900
|
},
|
|
75898
75901
|
debug: e.debug,
|
|
75899
|
-
getFocuses: () =>
|
|
75902
|
+
getFocuses: () => Ke.getActiveFocuses(),
|
|
75900
75903
|
getSchema: () => {
|
|
75901
75904
|
var e, t;
|
|
75902
|
-
return (e = (t =
|
|
75905
|
+
return (e = (t = wt()) == null ? void 0 : t.schema) == null ? null : e;
|
|
75903
75906
|
},
|
|
75904
75907
|
getBind: () => {
|
|
75905
75908
|
var e;
|
|
75906
|
-
return (e =
|
|
75909
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75907
75910
|
},
|
|
75908
|
-
tracker:
|
|
75909
|
-
guardMiddleware:
|
|
75910
|
-
getVfsFiles:
|
|
75911
|
-
enterDataScope:
|
|
75912
|
-
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,
|
|
75913
75916
|
onUsage: (e) => {
|
|
75914
75917
|
var t, n, r, i, a, o, s;
|
|
75915
|
-
|
|
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);
|
|
75916
75919
|
},
|
|
75917
|
-
timeoutMs: (
|
|
75918
|
-
},
|
|
75919
|
-
componentLock:
|
|
75920
|
+
timeoutMs: (fe = e.subagent) == null ? void 0 : fe.timeoutMs
|
|
75921
|
+
}, Nn ? {
|
|
75922
|
+
componentLock: Nn,
|
|
75920
75923
|
resolveComponents: (e) => {
|
|
75921
75924
|
var t;
|
|
75922
|
-
return Fje(e, jje((t =
|
|
75925
|
+
return Fje(e, jje((t = wt()) == null ? void 0 : t.bind, st));
|
|
75923
75926
|
}
|
|
75924
|
-
} : {})) : void 0,
|
|
75927
|
+
} : {})) : void 0, Ln = In ? In.controller : null, Rn = (t) => {
|
|
75925
75928
|
var n, r, i;
|
|
75926
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";
|
|
75927
75930
|
return j(j(j({}, t), a ? { thinkingMode: a } : {}), {}, { thinkingApplied: o });
|
|
75928
|
-
},
|
|
75929
|
-
check: (
|
|
75930
|
-
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 } : {},
|
|
75931
75934
|
root: () => {
|
|
75932
75935
|
var e;
|
|
75933
|
-
return (e =
|
|
75936
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
75934
75937
|
}
|
|
75935
|
-
}) :
|
|
75936
|
-
adversarial: (
|
|
75938
|
+
}) : pe,
|
|
75939
|
+
adversarial: (me = e.verify) != null && me.adversarial ? {
|
|
75937
75940
|
llm: e.llm,
|
|
75938
|
-
tools:
|
|
75941
|
+
tools: Bn
|
|
75939
75942
|
} : void 0
|
|
75940
|
-
}) : void 0,
|
|
75941
|
-
contextWindow:
|
|
75942
|
-
thresholdRatio: f8(e,
|
|
75943
|
-
}) : void 0,
|
|
75944
|
-
humanConfirm:
|
|
75945
|
-
screenshot: !!
|
|
75946
|
-
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,
|
|
75947
75950
|
hasActions: !!e.actions && Object.keys(e.actions).length > 0,
|
|
75948
75951
|
hasProposals: !!e.proposals,
|
|
75949
|
-
viewImage: !!
|
|
75950
|
-
subagents:
|
|
75951
|
-
}),
|
|
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({
|
|
75952
75955
|
getPageInfo: () => typeof document < "u" && typeof location < "u" ? {
|
|
75953
75956
|
title: document.title || "",
|
|
75954
75957
|
url: location.href
|
|
75955
75958
|
} : null,
|
|
75956
|
-
canReadPage:
|
|
75957
|
-
}) : void 0,
|
|
75959
|
+
canReadPage: pt.domInspect === !0
|
|
75960
|
+
}) : void 0, Gn = {
|
|
75958
75961
|
epoch: 0,
|
|
75959
75962
|
notices: [],
|
|
75960
75963
|
readsInvalidated: 0
|
|
75961
|
-
},
|
|
75964
|
+
}, Kn = 0, qn = {
|
|
75962
75965
|
name: "hostNotice",
|
|
75963
75966
|
beforeAgent: () => {
|
|
75964
|
-
|
|
75967
|
+
Kn = Gn.epoch;
|
|
75965
75968
|
},
|
|
75966
75969
|
wrapModelCall: async (e, t) => {
|
|
75967
|
-
if (
|
|
75968
|
-
|
|
75969
|
-
let t = uQ(e.messages, "agent 已通过 dom_edit 修改页面,此前读取为改前状态",
|
|
75970
|
+
if (It) {
|
|
75971
|
+
It = !1;
|
|
75972
|
+
let t = uQ(e.messages, "agent 已通过 dom_edit 修改页面,此前读取为改前状态", Wt);
|
|
75970
75973
|
if (t.invalidatedCount > 0) {
|
|
75971
75974
|
var n;
|
|
75972
75975
|
for (let n = 0; n < t.messages.length; n++) e.messages[n] = t.messages[n];
|
|
@@ -75980,20 +75983,20 @@ function eIe(e, t, n) {
|
|
|
75980
75983
|
});
|
|
75981
75984
|
}
|
|
75982
75985
|
}
|
|
75983
|
-
if (
|
|
75986
|
+
if (Gn.epoch > Kn) {
|
|
75984
75987
|
var r;
|
|
75985
|
-
|
|
75986
|
-
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);
|
|
75987
75990
|
if (n.invalidatedCount > 0) {
|
|
75988
75991
|
var i;
|
|
75989
75992
|
for (let t = 0; t < n.messages.length; t++) e.messages[t] = n.messages[t];
|
|
75990
|
-
|
|
75993
|
+
Gn.readsInvalidated += n.invalidatedCount, (i = R.agent) == null || (i = i.debugLogs) == null || (i = i.value) == null || i.push({
|
|
75991
75994
|
timestamp: Date.now(),
|
|
75992
75995
|
type: "middleware",
|
|
75993
75996
|
data: {
|
|
75994
75997
|
stage: "host_read_invalidated",
|
|
75995
75998
|
count: n.invalidatedCount,
|
|
75996
|
-
epoch:
|
|
75999
|
+
epoch: Gn.epoch,
|
|
75997
76000
|
reason: t || void 0
|
|
75998
76001
|
}
|
|
75999
76002
|
});
|
|
@@ -76001,177 +76004,177 @@ function eIe(e, t, n) {
|
|
|
76001
76004
|
}
|
|
76002
76005
|
return t(e);
|
|
76003
76006
|
},
|
|
76004
|
-
augmentPrompt: () =>
|
|
76007
|
+
augmentPrompt: () => Gn.notices.length ? [
|
|
76005
76008
|
"【宿主页面已变更】",
|
|
76006
|
-
...
|
|
76007
|
-
|
|
76009
|
+
...Gn.notices.filter(Boolean).map((e) => `· ${e}`),
|
|
76010
|
+
pt.domInspect === !0 ? "此前的页面读取/截图结果已过期,回答任何关于当前页面的问题前必须重新 read_page / get_dom 读取当前页面;不要凭此前的读取结果或记忆作答。" : "页面内容可能已变化,断言页面前先核实当前状态;不要凭此前的印象作答。"
|
|
76008
76011
|
].join("\n") : void 0,
|
|
76009
76012
|
afterAgent: () => {
|
|
76010
|
-
|
|
76013
|
+
Gn.notices.length = 0;
|
|
76011
76014
|
}
|
|
76012
|
-
},
|
|
76015
|
+
}, Jn = zt ? {
|
|
76013
76016
|
name: "proposalNotice",
|
|
76014
|
-
augmentPrompt: () =>
|
|
76017
|
+
augmentPrompt: () => zt.state.notices.length ? ["【内容提案裁决结果】(以此为准,不要凭提案前状态作答)", ...zt.state.notices].join("\n") : void 0,
|
|
76015
76018
|
afterAgent: () => {
|
|
76016
|
-
|
|
76019
|
+
zt.state.notices.length = 0;
|
|
76017
76020
|
}
|
|
76018
|
-
} : null,
|
|
76021
|
+
} : null, Yn = Ze ? {
|
|
76019
76022
|
name: "dataHint",
|
|
76020
|
-
augmentPrompt: () => h6(
|
|
76021
|
-
} : null,
|
|
76023
|
+
augmentPrompt: () => h6(wt(), e.schemaHint) || void 0
|
|
76024
|
+
} : null, Xn = e.augmentSystem ? {
|
|
76022
76025
|
name: "augmentSystem",
|
|
76023
76026
|
augmentPrompt: (t) => {
|
|
76024
76027
|
try {
|
|
76025
76028
|
return e.augmentSystem({
|
|
76026
76029
|
state: t,
|
|
76027
|
-
data:
|
|
76030
|
+
data: wt()
|
|
76028
76031
|
});
|
|
76029
76032
|
} catch (t) {
|
|
76030
76033
|
e.debug && console.log("[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:", t.message);
|
|
76031
76034
|
return;
|
|
76032
76035
|
}
|
|
76033
76036
|
}
|
|
76034
|
-
} : null,
|
|
76037
|
+
} : null, Zn = eNe(e.onEvent), Qn = Zn.emit, $n, er = [], tr = (e) => ({
|
|
76035
76038
|
name: e.name,
|
|
76036
76039
|
description: e.description,
|
|
76037
76040
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
76038
|
-
}),
|
|
76041
|
+
}), nr = (e) => ({
|
|
76039
76042
|
name: e.name,
|
|
76040
76043
|
description: e.description,
|
|
76041
76044
|
getContent: () => e.content
|
|
76042
|
-
}),
|
|
76043
|
-
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;
|
|
76044
76047
|
if (t) {
|
|
76045
|
-
let n = (e.skills || []).filter((e) => !
|
|
76046
|
-
t.set([...n, ...
|
|
76048
|
+
let n = (e.skills || []).filter((e) => !er.some((t) => t.name === e.name));
|
|
76049
|
+
t.set([...n, ...er]);
|
|
76047
76050
|
}
|
|
76048
76051
|
R.infoTick.value++;
|
|
76049
|
-
},
|
|
76050
|
-
if (
|
|
76051
|
-
let t = await
|
|
76052
|
+
}, ar = async () => {
|
|
76053
|
+
if (rr) try {
|
|
76054
|
+
let t = await rr.list();
|
|
76052
76055
|
if (t.length) {
|
|
76053
|
-
|
|
76054
|
-
let n =
|
|
76056
|
+
er = t.map(nr);
|
|
76057
|
+
let n = $n ? $n.controller : null;
|
|
76055
76058
|
if (n) {
|
|
76056
|
-
let t = (e.skills || []).filter((e) => !
|
|
76057
|
-
n.set([...t, ...
|
|
76059
|
+
let t = (e.skills || []).filter((e) => !er.some((t) => t.name === e.name));
|
|
76060
|
+
n.set([...t, ...er]);
|
|
76058
76061
|
}
|
|
76059
76062
|
R.infoTick.value++;
|
|
76060
76063
|
}
|
|
76061
76064
|
} catch (e) {}
|
|
76062
|
-
},
|
|
76063
|
-
llmInvoke:
|
|
76065
|
+
}, or = mn ? o1(j(j({}, Ae), {}, {
|
|
76066
|
+
llmInvoke: xe,
|
|
76064
76067
|
getRegisteredData: () => {
|
|
76065
76068
|
var e;
|
|
76066
|
-
return
|
|
76069
|
+
return wt() ? [{ description: (e = wt().description) == null ? "主数据对象" : e }] : [];
|
|
76067
76070
|
},
|
|
76068
|
-
preserveLastToolResults:
|
|
76069
|
-
},
|
|
76070
|
-
decideInvoke:
|
|
76071
|
-
getSnapshot: () =>
|
|
76072
|
-
} : {})) : void 0,
|
|
76073
|
-
...
|
|
76074
|
-
withScreenshot: !!
|
|
76075
|
-
withDomEdit:
|
|
76076
|
-
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
|
|
76077
76080
|
})] : [],
|
|
76078
|
-
...
|
|
76079
|
-
withScreenshot: !!
|
|
76080
|
-
withDomEdit:
|
|
76081
|
-
withVfs:
|
|
76081
|
+
...pt.domInspect && !(e.skills || []).some((e) => e.name === "page-analysis") ? [vFe({
|
|
76082
|
+
withScreenshot: !!Nt,
|
|
76083
|
+
withDomEdit: pt.domEdit,
|
|
76084
|
+
withVfs: fn
|
|
76082
76085
|
})] : [],
|
|
76083
76086
|
...e.skills || []
|
|
76084
76087
|
], {
|
|
76085
|
-
readVfs:
|
|
76088
|
+
readVfs: fn ? (e) => {
|
|
76086
76089
|
var t;
|
|
76087
|
-
return (t =
|
|
76090
|
+
return (t = Ie.files[e]) == null ? void 0 : t.content;
|
|
76088
76091
|
} : void 0,
|
|
76089
76092
|
onToolsReady: (e, t) => {
|
|
76090
76093
|
for (let n of t) {
|
|
76091
|
-
let t =
|
|
76092
|
-
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}`);
|
|
76093
76096
|
}
|
|
76094
|
-
|
|
76097
|
+
sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76095
76098
|
}
|
|
76096
76099
|
}) : void 0;
|
|
76097
|
-
|
|
76098
|
-
let
|
|
76099
|
-
...
|
|
76100
|
-
zn,
|
|
76101
|
-
...Bn ? [Bn] : [],
|
|
76100
|
+
$n = sr;
|
|
76101
|
+
let cr = iNe([
|
|
76102
|
+
...Yn ? [Yn] : [],
|
|
76102
76103
|
Un,
|
|
76103
76104
|
...Wn ? [Wn] : [],
|
|
76104
|
-
|
|
76105
|
-
|
|
76106
|
-
Re,
|
|
76107
|
-
|
|
76108
|
-
|
|
76109
|
-
...
|
|
76110
|
-
...
|
|
76111
|
-
...
|
|
76112
|
-
...
|
|
76113
|
-
...
|
|
76114
|
-
...
|
|
76115
|
-
...
|
|
76116
|
-
...
|
|
76117
|
-
...
|
|
76118
|
-
...
|
|
76119
|
-
...
|
|
76120
|
-
...
|
|
76121
|
-
...
|
|
76122
|
-
...
|
|
76123
|
-
...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] : [],
|
|
76124
76124
|
...jn ? [jn] : [],
|
|
76125
|
-
...
|
|
76125
|
+
...In ? [In] : [],
|
|
76126
|
+
...Pn ? [Pn] : [],
|
|
76127
|
+
...Fn ? [Fn] : [],
|
|
76128
|
+
...xt && _n ? [Kje({
|
|
76126
76129
|
getBind: () => {
|
|
76127
76130
|
var e;
|
|
76128
|
-
return (e =
|
|
76131
|
+
return (e = wt()) == null ? void 0 : e.bind;
|
|
76129
76132
|
},
|
|
76130
76133
|
getTools: () => {
|
|
76131
76134
|
var e, t;
|
|
76132
|
-
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;
|
|
76133
76136
|
}
|
|
76134
76137
|
})] : [],
|
|
76135
|
-
...
|
|
76136
|
-
...
|
|
76137
|
-
...
|
|
76138
|
+
...Xn ? [Xn] : [],
|
|
76139
|
+
...Hn ? [Hn] : [],
|
|
76140
|
+
...Ft ? [Ft] : [],
|
|
76138
76141
|
...e.middleware || [],
|
|
76139
|
-
...
|
|
76142
|
+
...gt ? [EFe(ge, {
|
|
76140
76143
|
tokenBudget: e.tokenBudget,
|
|
76141
76144
|
timeBudgetMs: e.timeBudgetMs
|
|
76142
|
-
},
|
|
76143
|
-
QFe(
|
|
76144
|
-
]),
|
|
76145
|
-
function
|
|
76145
|
+
}, Qn)] : [],
|
|
76146
|
+
QFe(Qn, Fe, wt, ge)
|
|
76147
|
+
]), lr = (he = e.maxMemoryRounds) == null ? YFe : he;
|
|
76148
|
+
function ur(e) {
|
|
76146
76149
|
return (e) => {
|
|
76147
|
-
e.type !== "approval_request" &&
|
|
76150
|
+
e.type !== "approval_request" && Qn(jt(e));
|
|
76148
76151
|
};
|
|
76149
76152
|
}
|
|
76150
|
-
let
|
|
76151
|
-
function
|
|
76153
|
+
let dr = /* @__PURE__ */ Iq([]), fr = qFe(), pr = /* @__PURE__ */ new Set();
|
|
76154
|
+
function mr(e) {
|
|
76152
76155
|
let t = new AbortController(), n = () => t.abort();
|
|
76153
|
-
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), {
|
|
76154
76157
|
controller: t,
|
|
76155
76158
|
untrack: () => {
|
|
76156
|
-
|
|
76159
|
+
pr.delete(t), e == null || e.removeEventListener("abort", n);
|
|
76157
76160
|
}
|
|
76158
76161
|
};
|
|
76159
76162
|
}
|
|
76160
|
-
function
|
|
76161
|
-
for (let e of
|
|
76162
|
-
|
|
76163
|
+
function hr() {
|
|
76164
|
+
for (let e of pr) e.abort();
|
|
76165
|
+
pr.clear();
|
|
76163
76166
|
}
|
|
76164
|
-
let
|
|
76167
|
+
let gr = /* @__PURE__ */ Iq(null), R = {
|
|
76165
76168
|
agentId: t,
|
|
76166
|
-
store:
|
|
76167
|
-
messages:
|
|
76168
|
-
vfsStore:
|
|
76169
|
-
listeners:
|
|
76170
|
-
todosMw:
|
|
76171
|
-
memoryMw:
|
|
76172
|
-
missionMw:
|
|
76173
|
-
workingMemoryMw:
|
|
76174
|
-
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,
|
|
76175
76178
|
agent: null,
|
|
76176
76179
|
initDone: Promise.resolve(),
|
|
76177
76180
|
sessionId: "",
|
|
@@ -76179,62 +76182,62 @@ function eIe(e, t, n) {
|
|
|
76179
76182
|
mcpClosers: [],
|
|
76180
76183
|
mcpServers: [],
|
|
76181
76184
|
mcpFailed: [],
|
|
76182
|
-
checkpoint:
|
|
76183
|
-
dataOpsController:
|
|
76184
|
-
skillsController:
|
|
76185
|
-
infoTick:
|
|
76186
|
-
pendingConflict:
|
|
76187
|
-
pendingQuote:
|
|
76188
|
-
sessions:
|
|
76189
|
-
refreshSessions: () =>
|
|
76190
|
-
liveData:
|
|
76191
|
-
usage:
|
|
76192
|
-
emit:
|
|
76193
|
-
runSerial:
|
|
76194
|
-
trackActive:
|
|
76195
|
-
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,
|
|
76196
76199
|
unloadSkillTools(e) {
|
|
76197
76200
|
if (e) {
|
|
76198
|
-
let t =
|
|
76199
|
-
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;
|
|
76200
76203
|
} else {
|
|
76201
|
-
if (!
|
|
76202
|
-
for (let e of
|
|
76203
|
-
|
|
76204
|
+
if (!rn.length) return;
|
|
76205
|
+
for (let e of rn) kt.delete(e.name), an.delete(e.name);
|
|
76206
|
+
rn = [];
|
|
76204
76207
|
}
|
|
76205
|
-
|
|
76208
|
+
sn = on(), R.agent && R.agent.setTools(sn);
|
|
76206
76209
|
},
|
|
76207
76210
|
applySnapshot(t) {
|
|
76208
76211
|
var n, r, i;
|
|
76209
|
-
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) => {
|
|
76210
76213
|
var t;
|
|
76211
76214
|
return (e ? (t = R.vfsStore) == null || (t = t.files) == null || (t = t[e]) == null ? void 0 : t.content : void 0) || void 0;
|
|
76212
|
-
})),
|
|
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) {
|
|
76213
76216
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
76214
76217
|
if (r.length) {
|
|
76215
76218
|
var a;
|
|
76216
|
-
let t = (a =
|
|
76217
|
-
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) {
|
|
76218
76221
|
let e = r.filter((e) => !n.includes(e)).map((e) => e.path);
|
|
76219
76222
|
console.warn("[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:", e);
|
|
76220
76223
|
}
|
|
76221
76224
|
}
|
|
76222
76225
|
}
|
|
76223
|
-
|
|
76226
|
+
br();
|
|
76224
76227
|
},
|
|
76225
76228
|
addSkill(e) {
|
|
76226
|
-
let t =
|
|
76227
|
-
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));
|
|
76228
76231
|
},
|
|
76229
76232
|
removeSkill(e) {
|
|
76230
|
-
let t =
|
|
76231
|
-
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);
|
|
76232
76235
|
},
|
|
76233
76236
|
listUserSkills() {
|
|
76234
|
-
return
|
|
76237
|
+
return er.map((e) => e.name);
|
|
76235
76238
|
},
|
|
76236
76239
|
getUserSkill(e) {
|
|
76237
|
-
let t =
|
|
76240
|
+
let t = er.find((t) => t.name === e);
|
|
76238
76241
|
if (t) return {
|
|
76239
76242
|
name: t.name,
|
|
76240
76243
|
description: t.description,
|
|
@@ -76242,32 +76245,32 @@ function eIe(e, t, n) {
|
|
|
76242
76245
|
};
|
|
76243
76246
|
},
|
|
76244
76247
|
afterRound() {
|
|
76245
|
-
|
|
76248
|
+
xr(), Cr.persistRuntime();
|
|
76246
76249
|
},
|
|
76247
76250
|
clearCodeReuse() {
|
|
76248
76251
|
var e, t;
|
|
76249
|
-
let n =
|
|
76252
|
+
let n = Ie;
|
|
76250
76253
|
(e = n.__pgPendingRetry) == null || e.clear(), (t = n.__pgLastCheckout) == null || t.clear();
|
|
76251
76254
|
},
|
|
76252
76255
|
async send(e, t) {
|
|
76253
76256
|
var n, r, i, a;
|
|
76254
76257
|
if (await R.initDone, R.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 send");
|
|
76255
|
-
t = (n = t) == null ? {} : n, t != null && t.mission &&
|
|
76258
|
+
t = (n = t) == null ? {} : n, t != null && t.mission && ln && Re.setMission(t.mission);
|
|
76256
76259
|
let o = e, s = ((r = t.images) == null ? [] : r).filter((e) => e && (e.dataUri || e.vfsRef || e.url));
|
|
76257
76260
|
if (s.length > 4) throw Error(`[page-agent-sdk] 单轮最多 4 张图片(收到 ${s.length})`);
|
|
76258
|
-
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)) {
|
|
76259
76262
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述(集成方识图子 agent / 自有 vision API)";
|
|
76260
|
-
throw
|
|
76263
|
+
throw Qn({
|
|
76261
76264
|
type: "error",
|
|
76262
76265
|
message: e,
|
|
76263
76266
|
severity: "recoverable",
|
|
76264
76267
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
76265
76268
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
76266
76269
|
}
|
|
76267
|
-
|
|
76268
|
-
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);
|
|
76269
76272
|
if (t.signal) {
|
|
76270
|
-
let e = () =>
|
|
76273
|
+
let e = () => _e.resolve("keep_external");
|
|
76271
76274
|
t.signal.aborted ? e() : t.signal.addEventListener("abort", e, { once: !0 });
|
|
76272
76275
|
}
|
|
76273
76276
|
let f = R.sessionId;
|
|
@@ -76279,16 +76282,16 @@ function eIe(e, t, n) {
|
|
|
76279
76282
|
let n = kZ(t.quote.anchor);
|
|
76280
76283
|
e = j(j({ text: DZ(t.quote.text) }, t.quote.source ? { source: t.quote.source } : {}), n ? { anchor: n } : {});
|
|
76281
76284
|
}
|
|
76282
|
-
let n = (m = (h = e) == null ?
|
|
76283
|
-
|
|
76285
|
+
let n = (m = (h = e) == null ? gr.value : h) == null ? void 0 : m;
|
|
76286
|
+
Fe.push(j(j({
|
|
76284
76287
|
role: "user",
|
|
76285
76288
|
content: o,
|
|
76286
76289
|
timestamp: Date.now()
|
|
76287
|
-
}, 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);
|
|
76288
76291
|
}
|
|
76289
76292
|
try {
|
|
76290
76293
|
var g;
|
|
76291
|
-
let e = await R.agent.invoke(
|
|
76294
|
+
let e = await R.agent.invoke(Fe, t.signal, d);
|
|
76292
76295
|
if ((g = t.signal) != null && g.aborted || R.sessionId !== f || R.refCount <= 0) {
|
|
76293
76296
|
var _, v;
|
|
76294
76297
|
return (_ = R.agent) == null || (_ = _.debugLogs) == null || (_ = _.value) == null || _.push({
|
|
@@ -76302,14 +76305,14 @@ function eIe(e, t, n) {
|
|
|
76302
76305
|
}
|
|
76303
76306
|
}), e;
|
|
76304
76307
|
}
|
|
76305
|
-
if (
|
|
76308
|
+
if (Fe.push({
|
|
76306
76309
|
role: "assistant",
|
|
76307
76310
|
content: e,
|
|
76308
76311
|
timestamp: Date.now()
|
|
76309
|
-
}), R.afterRound(),
|
|
76310
|
-
await
|
|
76312
|
+
}), R.afterRound(), ye) try {
|
|
76313
|
+
await ye.flush();
|
|
76311
76314
|
} catch (e) {
|
|
76312
|
-
|
|
76315
|
+
Qn({
|
|
76313
76316
|
type: "error",
|
|
76314
76317
|
message: `落盘失败(不影响本轮回复):${e instanceof Error ? e.message : String(e)}`,
|
|
76315
76318
|
severity: "observable",
|
|
@@ -76323,9 +76326,9 @@ function eIe(e, t, n) {
|
|
|
76323
76326
|
if (GZ(e) && (n = j(j({}, n), {}, {
|
|
76324
76327
|
code: "MODEL_UNAVAILABLE",
|
|
76325
76328
|
message: e instanceof Error ? e.message : n.message
|
|
76326
|
-
})), l < c &&
|
|
76329
|
+
})), l < c && dt != null && dt.canRestore()) {
|
|
76327
76330
|
var y;
|
|
76328
|
-
l += 1,
|
|
76331
|
+
l += 1, dt.restore(), u = !0, Qn({
|
|
76329
76332
|
type: "error",
|
|
76330
76333
|
message: `致命错误自动恢复(${l}/${c}):${n.message},已回退 checkpoint 重试`,
|
|
76331
76334
|
severity: "observable",
|
|
@@ -76337,7 +76340,7 @@ function eIe(e, t, n) {
|
|
|
76337
76340
|
});
|
|
76338
76341
|
continue;
|
|
76339
76342
|
}
|
|
76340
|
-
throw
|
|
76343
|
+
throw Qn(j(j({
|
|
76341
76344
|
type: "error",
|
|
76342
76345
|
message: n.message,
|
|
76343
76346
|
severity: n.severity
|
|
@@ -76349,9 +76352,9 @@ function eIe(e, t, n) {
|
|
|
76349
76352
|
var r;
|
|
76350
76353
|
if (await R.initDone, !e.length) return [];
|
|
76351
76354
|
if (R.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
76352
|
-
let i = [], a =
|
|
76353
|
-
if (
|
|
76354
|
-
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");
|
|
76355
76358
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
76356
76359
|
}
|
|
76357
76360
|
for (let r = 0; r < e.length; r++) {
|
|
@@ -76365,23 +76368,23 @@ function eIe(e, t, n) {
|
|
|
76365
76368
|
break;
|
|
76366
76369
|
}
|
|
76367
76370
|
let o = e[r];
|
|
76368
|
-
|
|
76369
|
-
let s =
|
|
76371
|
+
dt && dt.save(`batch:${r}`);
|
|
76372
|
+
let s = Fe.length;
|
|
76370
76373
|
try {
|
|
76371
|
-
|
|
76374
|
+
Fe.push({
|
|
76372
76375
|
role: "user",
|
|
76373
76376
|
content: o,
|
|
76374
76377
|
timestamp: Date.now()
|
|
76375
76378
|
});
|
|
76376
|
-
let s = await R.agent.invoke(
|
|
76377
|
-
if (
|
|
76379
|
+
let s = await R.agent.invoke(Fe, n, a);
|
|
76380
|
+
if (Fe.push({
|
|
76378
76381
|
role: "assistant",
|
|
76379
76382
|
content: s,
|
|
76380
76383
|
timestamp: Date.now()
|
|
76381
|
-
}), R.afterRound(),
|
|
76382
|
-
await
|
|
76384
|
+
}), R.afterRound(), ye) try {
|
|
76385
|
+
await ye.flush();
|
|
76383
76386
|
} catch (e) {
|
|
76384
|
-
|
|
76387
|
+
Qn({
|
|
76385
76388
|
type: "error",
|
|
76386
76389
|
message: `落盘失败(不影响本任务结果):${e instanceof Error ? e.message : String(e)}`,
|
|
76387
76390
|
severity: "observable",
|
|
@@ -76400,7 +76403,7 @@ function eIe(e, t, n) {
|
|
|
76400
76403
|
ok: !0
|
|
76401
76404
|
});
|
|
76402
76405
|
} catch (a) {
|
|
76403
|
-
if (
|
|
76406
|
+
if (Fe.length > s && Fe.splice(s), FZ(a, n)) {
|
|
76404
76407
|
i.push({
|
|
76405
76408
|
index: r,
|
|
76406
76409
|
task: o,
|
|
@@ -76417,7 +76420,7 @@ function eIe(e, t, n) {
|
|
|
76417
76420
|
}
|
|
76418
76421
|
GZ(a);
|
|
76419
76422
|
let c = xZ(a, "fatal");
|
|
76420
|
-
|
|
76423
|
+
Qn({
|
|
76421
76424
|
type: "error",
|
|
76422
76425
|
message: `批量任务 ${r + 1}/${e.length} 失败:${c.message}`,
|
|
76423
76426
|
severity: "observable",
|
|
@@ -76441,10 +76444,10 @@ function eIe(e, t, n) {
|
|
|
76441
76444
|
}
|
|
76442
76445
|
return i;
|
|
76443
76446
|
},
|
|
76444
|
-
switchSession: (e) =>
|
|
76445
|
-
exportSession: (e) =>
|
|
76446
|
-
importSession: (e) =>
|
|
76447
|
-
resetSession: () =>
|
|
76447
|
+
switchSession: (e) => Cr.switchSession(e),
|
|
76448
|
+
exportSession: (e) => Cr.exportSession(e),
|
|
76449
|
+
importSession: (e) => Cr.importSession(e),
|
|
76450
|
+
resetSession: () => Cr.resetSession(),
|
|
76448
76451
|
stream: async (e, t, n) => {
|
|
76449
76452
|
var r, i;
|
|
76450
76453
|
if (!R.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
@@ -76452,51 +76455,51 @@ function eIe(e, t, n) {
|
|
|
76452
76455
|
var t;
|
|
76453
76456
|
return e.role === "user" && ((t = e.images) == null ? void 0 : t.length);
|
|
76454
76457
|
});
|
|
76455
|
-
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))) {
|
|
76456
76459
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述";
|
|
76457
|
-
throw
|
|
76460
|
+
throw Qn({
|
|
76458
76461
|
type: "error",
|
|
76459
76462
|
message: e,
|
|
76460
76463
|
severity: "recoverable",
|
|
76461
76464
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
76462
76465
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
76463
76466
|
}
|
|
76464
|
-
|
|
76467
|
+
Ie == null || (i = Ie.setProtectedRefs) == null || i.call(Ie, B8(e));
|
|
76465
76468
|
let o = (e) => {
|
|
76466
|
-
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++;
|
|
76467
76470
|
};
|
|
76468
76471
|
if (n) {
|
|
76469
|
-
let e = () =>
|
|
76472
|
+
let e = () => _e.resolve("keep_external");
|
|
76470
76473
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
76471
76474
|
}
|
|
76472
|
-
let { controller: s, untrack: c } =
|
|
76475
|
+
let { controller: s, untrack: c } = mr(n);
|
|
76473
76476
|
return R.agent.stream(e, o, s.signal).finally(c);
|
|
76474
76477
|
},
|
|
76475
76478
|
release() {
|
|
76476
76479
|
if (R.refCount--, R.refCount <= 0) {
|
|
76477
|
-
if (
|
|
76480
|
+
if (hr(), qt = !0, ye) {
|
|
76478
76481
|
var e;
|
|
76479
|
-
(e =
|
|
76482
|
+
(e = Ie.flush) == null || e.call(Ie), ye.flush(), ye.dispose();
|
|
76480
76483
|
}
|
|
76481
|
-
|
|
76484
|
+
rr && rr.dispose();
|
|
76482
76485
|
let n = R.mcpClosers.splice(0);
|
|
76483
76486
|
n.length && Promise.allSettled(n.map((e) => e())), V8.delete(t);
|
|
76484
76487
|
}
|
|
76485
76488
|
},
|
|
76486
|
-
resolveConflict:
|
|
76489
|
+
resolveConflict: _e.resolve,
|
|
76487
76490
|
setTools(e) {
|
|
76488
|
-
|
|
76489
|
-
|
|
76490
|
-
}),
|
|
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++;
|
|
76491
76494
|
},
|
|
76492
76495
|
addTool(e) {
|
|
76493
|
-
|
|
76494
|
-
for (let t =
|
|
76495
|
-
|
|
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++;
|
|
76496
76499
|
},
|
|
76497
76500
|
removeTool(e) {
|
|
76498
|
-
let t =
|
|
76499
|
-
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);
|
|
76500
76503
|
},
|
|
76501
76504
|
setLlm(t) {
|
|
76502
76505
|
var n, r, i, a, o, s, c;
|
|
@@ -76508,119 +76511,119 @@ function eIe(e, t, n) {
|
|
|
76508
76511
|
if (((u = e.provider) == null ? "openai" : u) === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
76509
76512
|
l = IG(e);
|
|
76510
76513
|
}
|
|
76511
|
-
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;
|
|
76512
76515
|
let d = Q6(t) ? void 0 : t;
|
|
76513
|
-
if (
|
|
76516
|
+
if (we = aF({
|
|
76514
76517
|
model: (n = (r = d == null ? void 0 : d.model) == null ? t.model : r) == null ? t.modelName : n,
|
|
76515
76518
|
contextWindow: (i = e.contextWindow) == null ? d == null ? void 0 : d.contextWindow : i,
|
|
76516
76519
|
maxOutputTokens: (a = e.maxOutputTokens) == null ? d == null ? void 0 : d.maxOutputTokens : a,
|
|
76517
76520
|
vision: (o = d == null ? void 0 : d.vision) == null ? t.vision : o
|
|
76518
|
-
}),
|
|
76521
|
+
}), we.contextWindow < 2e5) throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${we.contextWindow} 小于最小支持 ${eF}(需 ≥200K 窗口模型)`);
|
|
76519
76522
|
if (R.agent) {
|
|
76520
76523
|
var f, p;
|
|
76521
|
-
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);
|
|
76522
76525
|
}
|
|
76523
|
-
|
|
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);
|
|
76524
76527
|
},
|
|
76525
76528
|
setMemory(e) {
|
|
76526
|
-
|
|
76529
|
+
Ye.reset(e), typeof e == "function" && Ye.refresh(), R.infoTick.value++;
|
|
76527
76530
|
},
|
|
76528
76531
|
refreshMemory() {
|
|
76529
|
-
return
|
|
76532
|
+
return Ye.refresh();
|
|
76530
76533
|
},
|
|
76531
76534
|
setSubagents(t) {
|
|
76532
|
-
if (!
|
|
76535
|
+
if (!Ln) {
|
|
76533
76536
|
e.debug && console.warn("[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
76534
76537
|
return;
|
|
76535
76538
|
}
|
|
76536
|
-
|
|
76539
|
+
Ln.set(t), R.infoTick.value++;
|
|
76537
76540
|
},
|
|
76538
76541
|
addSubagent(t) {
|
|
76539
|
-
if (!
|
|
76542
|
+
if (!Ln) {
|
|
76540
76543
|
e.debug && console.warn("[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
76541
76544
|
return;
|
|
76542
76545
|
}
|
|
76543
|
-
|
|
76546
|
+
Ln.add(t), R.infoTick.value++;
|
|
76544
76547
|
},
|
|
76545
76548
|
removeSubagent(t) {
|
|
76546
|
-
if (!
|
|
76547
|
-
let n =
|
|
76549
|
+
if (!Ln) return e.debug && console.warn("[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略"), !1;
|
|
76550
|
+
let n = Ln.remove(t);
|
|
76548
76551
|
return n && R.infoTick.value++, n;
|
|
76549
76552
|
},
|
|
76550
76553
|
getActiveSubagents() {
|
|
76551
76554
|
var e;
|
|
76552
|
-
return (e =
|
|
76555
|
+
return (e = vn == null ? void 0 : vn.getActive()) == null ? [] : e;
|
|
76553
76556
|
},
|
|
76554
76557
|
get subagentHistory() {
|
|
76555
76558
|
var e;
|
|
76556
|
-
return (e =
|
|
76559
|
+
return (e = vn == null ? void 0 : vn.getHistory()) == null ? [] : e;
|
|
76557
76560
|
},
|
|
76558
76561
|
getInfo() {
|
|
76559
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;
|
|
76560
76563
|
return j(j(j({
|
|
76561
76564
|
id: t,
|
|
76562
76565
|
sessionId: R.sessionId,
|
|
76563
|
-
model: Q6(
|
|
76564
|
-
systemPrompt: (i = (a = R.agent) == null || (o = a.getEffectiveSystemPrompt) == null ? void 0 : o.call(a)) == null ?
|
|
76565
|
-
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) => ({
|
|
76566
76569
|
name: e.name,
|
|
76567
76570
|
description: e.description,
|
|
76568
76571
|
schema: e.schema,
|
|
76569
|
-
source:
|
|
76572
|
+
source: kt.get(e.name) || "user"
|
|
76570
76573
|
})),
|
|
76571
|
-
skills: (
|
|
76574
|
+
skills: ($n ? $n.controller.get() : (l = e.skills) == null ? [] : l).map((e) => ({
|
|
76572
76575
|
name: e.name,
|
|
76573
76576
|
description: e.description
|
|
76574
76577
|
})),
|
|
76575
|
-
data:
|
|
76576
|
-
description:
|
|
76577
|
-
schema:
|
|
76578
|
+
data: wt() ? {
|
|
76579
|
+
description: wt().description,
|
|
76580
|
+
schema: wt().schema
|
|
76578
76581
|
} : void 0,
|
|
76579
76582
|
contextPreset: (u = e.contextPreset) == null ? "auto" : u,
|
|
76580
76583
|
compression: {
|
|
76581
|
-
contextWindow:
|
|
76582
|
-
summaryThresholdRatio: (d =
|
|
76583
|
-
promptSoftCap: i1(
|
|
76584
|
+
contextWindow: we.contextWindow,
|
|
76585
|
+
summaryThresholdRatio: (d = Ae.summaryThresholdRatio) == null ? .5 : d,
|
|
76586
|
+
promptSoftCap: i1(we.contextWindow, Ae.promptSoftCapTokens)
|
|
76584
76587
|
},
|
|
76585
|
-
memory:
|
|
76588
|
+
memory: Ye.get(),
|
|
76586
76589
|
staleReadsInvalidated: (f = (p = R.agent) == null || (m = p.getStaleReadsInvalidated) == null ? void 0 : m.call(p)) == null ? 0 : f,
|
|
76587
|
-
hostReadsInvalidated:
|
|
76588
|
-
},
|
|
76590
|
+
hostReadsInvalidated: Gn.readsInvalidated
|
|
76591
|
+
}, zt ? { proposals: zt.snapshot() } : {}), n ? { hostWatch: j({}, n) } : {}), {}, {
|
|
76589
76592
|
llmRetries: (h = (g = R.agent) == null || (_ = g.getLlmRetries) == null ? void 0 : _.call(g)) == null ? 0 : h,
|
|
76590
76593
|
llmCallFailures: (v = (y = R.agent) == null || (b = y.getLlmCallFailures) == null ? void 0 : b.call(y)) == null ? 0 : v,
|
|
76591
76594
|
gates: (x = R.agent) == null || (S = x.getGateStats) == null ? void 0 : S.call(x),
|
|
76592
76595
|
systemSegments: (C = (w = R.agent) == null || (T = w.getLastSystemSegments) == null ? void 0 : T.call(w)) == null ? [] : C,
|
|
76593
|
-
middleware:
|
|
76596
|
+
middleware: cr.map((e) => e.name),
|
|
76594
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({
|
|
76595
76598
|
id: e.id,
|
|
76596
76599
|
content: e.content,
|
|
76597
76600
|
status: e.status
|
|
76598
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 })),
|
|
76599
|
-
planPhase:
|
|
76600
|
-
mission:
|
|
76601
|
-
planConfirmation:
|
|
76602
|
-
workingMemory:
|
|
76603
|
-
focus:
|
|
76604
|
-
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() : [],
|
|
76605
76608
|
actions: OFe((k = e.actions) == null ? {} : k),
|
|
76606
76609
|
subagent: {
|
|
76607
|
-
enabled: !!
|
|
76610
|
+
enabled: !!jn,
|
|
76608
76611
|
maxDepth: (A = (M = e.subagent) == null ? void 0 : M.maxDepth) == null ? 1 : A,
|
|
76609
76612
|
maxParallel: (ee = (te = e.subagent) == null ? void 0 : te.maxParallel) == null ? 4 : ee,
|
|
76610
76613
|
timeoutMs: ((N = e.subagent) == null ? void 0 : N.timeoutMs) === void 0 ? 18e5 : e.subagent.timeoutMs > 0 ? e.subagent.timeoutMs : 0,
|
|
76611
76614
|
allowedTools: (P = (ne = e.subagent) == null ? void 0 : ne.allowedTools) == null ? [] : P,
|
|
76612
|
-
subagents: ((re =
|
|
76613
|
-
active: (ie =
|
|
76614
|
-
history: (ae =
|
|
76615
|
-
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
|
|
76616
76619
|
},
|
|
76617
76620
|
verify: {
|
|
76618
|
-
enabled: !!
|
|
76619
|
-
maxAttempts:
|
|
76620
|
-
adversarial:
|
|
76621
|
+
enabled: !!Vn,
|
|
76622
|
+
maxAttempts: Sn ? yn : 0,
|
|
76623
|
+
adversarial: Sn && !!((se = e.verify) != null && se.adversarial)
|
|
76621
76624
|
},
|
|
76622
76625
|
context: (() => {
|
|
76623
|
-
let e =
|
|
76626
|
+
let e = Hn == null ? void 0 : Hn.getSnapshot();
|
|
76624
76627
|
if (e) {
|
|
76625
76628
|
var t, n;
|
|
76626
76629
|
let r = (t = R.agent) == null || (n = t.getState) == null || (n = n.call(t)) == null ? void 0 : n.lastCompression;
|
|
@@ -76630,10 +76633,10 @@ function eIe(e, t, n) {
|
|
|
76630
76633
|
})(),
|
|
76631
76634
|
mcp: j({ servers: R.mcpServers }, R.mcpFailed.length ? { failed: R.mcpFailed } : {}),
|
|
76632
76635
|
lastCompression: (ce = R.agent) == null || (F = ce.getState) == null || (F = F.call(ce)) == null ? void 0 : F.lastCompression,
|
|
76633
|
-
checkpoints:
|
|
76636
|
+
checkpoints: dt ? {
|
|
76634
76637
|
enabled: !0,
|
|
76635
|
-
auto:
|
|
76636
|
-
list:
|
|
76638
|
+
auto: ft,
|
|
76639
|
+
list: dt.list()
|
|
76637
76640
|
} : void 0
|
|
76638
76641
|
});
|
|
76639
76642
|
},
|
|
@@ -76674,79 +76677,79 @@ function eIe(e, t, n) {
|
|
|
76674
76677
|
}));
|
|
76675
76678
|
},
|
|
76676
76679
|
getMission() {
|
|
76677
|
-
return
|
|
76680
|
+
return ln ? Re.getMission() : void 0;
|
|
76678
76681
|
},
|
|
76679
76682
|
setMission(t) {
|
|
76680
|
-
if (!
|
|
76683
|
+
if (!ln) {
|
|
76681
76684
|
e.debug && console.warn("[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略");
|
|
76682
76685
|
return;
|
|
76683
76686
|
}
|
|
76684
|
-
|
|
76687
|
+
Re.setMission(t), R.infoTick.value++;
|
|
76685
76688
|
},
|
|
76686
76689
|
getFocus() {
|
|
76687
|
-
return
|
|
76690
|
+
return Zt ? Ke.getFocus() : void 0;
|
|
76688
76691
|
},
|
|
76689
76692
|
getFocuses() {
|
|
76690
|
-
return
|
|
76693
|
+
return Zt ? Ke.getFocuses() : [];
|
|
76691
76694
|
},
|
|
76692
76695
|
setFocus(t) {
|
|
76693
|
-
let n = $Fe(t, "setFocus",
|
|
76696
|
+
let n = $Fe(t, "setFocus", Zt, () => {
|
|
76694
76697
|
var e;
|
|
76695
|
-
return (e =
|
|
76698
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
76696
76699
|
}, e.debug);
|
|
76697
|
-
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;
|
|
76698
76701
|
},
|
|
76699
76702
|
addFocus(t) {
|
|
76700
|
-
let n = $Fe(t, "addFocus",
|
|
76703
|
+
let n = $Fe(t, "addFocus", Zt, () => {
|
|
76701
76704
|
var e;
|
|
76702
|
-
return (e =
|
|
76705
|
+
return (e = wt()) == null ? void 0 : e.schema;
|
|
76703
76706
|
}, e.debug);
|
|
76704
|
-
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 超预算)"), {
|
|
76705
76708
|
ok: !1,
|
|
76706
76709
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
76707
|
-
}) : (
|
|
76710
|
+
}) : (Ke.addFocus(qe(t)), e.debug && Ke.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), R.infoTick.value++, { ok: !0 }) : n;
|
|
76708
76711
|
},
|
|
76709
76712
|
removeFocus(e) {
|
|
76710
|
-
|
|
76713
|
+
Zt && (Ke.removeFocus(e), R.infoTick.value++);
|
|
76711
76714
|
},
|
|
76712
76715
|
clearFocus() {
|
|
76713
|
-
|
|
76716
|
+
Zt && (Ke.clearFocus(), R.infoTick.value++);
|
|
76714
76717
|
},
|
|
76715
76718
|
setQuote(e, t, n) {
|
|
76716
76719
|
let r = DZ(e == null ? "" : e), i = kZ(n);
|
|
76717
|
-
|
|
76720
|
+
gr.value = r ? j(j({ text: r }, t ? { source: t } : {}), i ? { anchor: i } : {}) : null;
|
|
76718
76721
|
},
|
|
76719
76722
|
notifyHostChange(e) {
|
|
76720
76723
|
var t;
|
|
76721
76724
|
let n = typeof (e == null ? void 0 : e.reason) == "string" ? e.reason.trim().slice(0, 200) : "";
|
|
76722
|
-
|
|
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({
|
|
76723
76726
|
timestamp: Date.now(),
|
|
76724
76727
|
type: "middleware",
|
|
76725
76728
|
data: {
|
|
76726
76729
|
stage: "host_change_notified",
|
|
76727
|
-
epoch:
|
|
76730
|
+
epoch: Gn.epoch,
|
|
76728
76731
|
reason: n || void 0
|
|
76729
76732
|
}
|
|
76730
76733
|
}), R.infoTick.value++;
|
|
76731
76734
|
},
|
|
76732
76735
|
clearQuote() {
|
|
76733
|
-
|
|
76736
|
+
gr.value = null;
|
|
76734
76737
|
},
|
|
76735
76738
|
resolveProposal(e, t, n) {
|
|
76736
|
-
let r =
|
|
76739
|
+
let r = zt ? zt.resolve(e, t, n) : !1;
|
|
76737
76740
|
return r && R.infoTick.value++, r;
|
|
76738
76741
|
},
|
|
76739
76742
|
getProposals() {
|
|
76740
|
-
return
|
|
76743
|
+
return zt ? zt.snapshot() : null;
|
|
76741
76744
|
}
|
|
76742
76745
|
};
|
|
76743
|
-
async function
|
|
76744
|
-
if (!
|
|
76746
|
+
async function _r() {
|
|
76747
|
+
if (!ye) return;
|
|
76745
76748
|
let n = async (e) => {
|
|
76746
76749
|
try {
|
|
76747
|
-
return await
|
|
76750
|
+
return await ye.load(t, e);
|
|
76748
76751
|
} catch (t) {
|
|
76749
|
-
|
|
76752
|
+
Qn({
|
|
76750
76753
|
type: "error",
|
|
76751
76754
|
message: `会话快照读取失败,已降级空会话:${t instanceof Error ? t.message : String(t)}`,
|
|
76752
76755
|
severity: "observable",
|
|
@@ -76757,9 +76760,9 @@ function eIe(e, t, n) {
|
|
|
76757
76760
|
}
|
|
76758
76761
|
}, r = async () => {
|
|
76759
76762
|
try {
|
|
76760
|
-
return await
|
|
76763
|
+
return await ye.listSessions(t);
|
|
76761
76764
|
} catch (e) {
|
|
76762
|
-
return
|
|
76765
|
+
return Qn({
|
|
76763
76766
|
type: "error",
|
|
76764
76767
|
message: `会话列表读取失败,已降级新建会话:${e instanceof Error ? e.message : String(e)}`,
|
|
76765
76768
|
severity: "observable",
|
|
@@ -76767,7 +76770,7 @@ function eIe(e, t, n) {
|
|
|
76767
76770
|
}), [];
|
|
76768
76771
|
}
|
|
76769
76772
|
}, i = Symbol("storage-ready-timeout");
|
|
76770
|
-
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({
|
|
76771
76774
|
type: "error",
|
|
76772
76775
|
message: "存储初始化 5s 未就绪(IDB blocked?),已放行降级运行",
|
|
76773
76776
|
severity: "observable",
|
|
@@ -76779,12 +76782,12 @@ function eIe(e, t, n) {
|
|
|
76779
76782
|
let e = await n(R.sessionId);
|
|
76780
76783
|
if (e) {
|
|
76781
76784
|
var o, s;
|
|
76782
|
-
R.applySnapshot(e),
|
|
76785
|
+
R.applySnapshot(e), Qn({
|
|
76783
76786
|
type: "session_restored",
|
|
76784
76787
|
sessionId: R.sessionId,
|
|
76785
76788
|
rounds: (o = (s = e.messages) == null ? void 0 : s.length) == null ? 0 : o
|
|
76786
76789
|
});
|
|
76787
|
-
} else await
|
|
76790
|
+
} else await ye.createSession(t, a.title, R.sessionId);
|
|
76788
76791
|
} else if (a.autoResume !== !1) {
|
|
76789
76792
|
let i = await r();
|
|
76790
76793
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", t, i.length, i.map((e) => e.sessionId)), i.length) {
|
|
@@ -76792,36 +76795,36 @@ function eIe(e, t, n) {
|
|
|
76792
76795
|
let t = await n(R.sessionId);
|
|
76793
76796
|
if (t) {
|
|
76794
76797
|
var c, l, u, d;
|
|
76795
|
-
R.applySnapshot(t),
|
|
76798
|
+
R.applySnapshot(t), Qn({
|
|
76796
76799
|
type: "session_restored",
|
|
76797
76800
|
sessionId: R.sessionId,
|
|
76798
76801
|
rounds: (c = (l = t.messages) == null ? void 0 : l.length) == null ? 0 : c
|
|
76799
76802
|
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", R.sessionId, `${(u = (d = t.messages) == null ? void 0 : d.length) == null ? 0 : u} msgs`);
|
|
76800
76803
|
} else e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", R.sessionId);
|
|
76801
|
-
} else R.sessionId = await
|
|
76802
|
-
} else R.sessionId = await
|
|
76803
|
-
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();
|
|
76804
76807
|
}
|
|
76805
|
-
async function
|
|
76806
|
-
await
|
|
76808
|
+
async function vr() {
|
|
76809
|
+
await ar();
|
|
76807
76810
|
}
|
|
76808
|
-
function
|
|
76811
|
+
function yr(e) {
|
|
76809
76812
|
let t = {};
|
|
76810
76813
|
for (let n of B8(e)) {
|
|
76811
|
-
let e =
|
|
76814
|
+
let e = Ie.files[n];
|
|
76812
76815
|
e && (t[n] = e.content);
|
|
76813
76816
|
}
|
|
76814
76817
|
return t;
|
|
76815
76818
|
}
|
|
76816
|
-
function
|
|
76817
|
-
let e = KFe(
|
|
76818
|
-
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];
|
|
76819
76822
|
}
|
|
76820
|
-
function
|
|
76821
|
-
let e = BTe(
|
|
76823
|
+
function xr() {
|
|
76824
|
+
let e = BTe(Fe, lr);
|
|
76822
76825
|
if (!e.trimmed) return;
|
|
76823
76826
|
let { older: t, summary: n } = e;
|
|
76824
|
-
if (
|
|
76827
|
+
if (Qn({
|
|
76825
76828
|
type: "context_trimmed",
|
|
76826
76829
|
dropped: t.map((e) => ({
|
|
76827
76830
|
round: e.round,
|
|
@@ -76832,61 +76835,61 @@ function eIe(e, t, n) {
|
|
|
76832
76835
|
return (t = e.steps) == null ? [] : t;
|
|
76833
76836
|
})
|
|
76834
76837
|
})),
|
|
76835
|
-
vfsResults:
|
|
76838
|
+
vfsResults: yr(t.flatMap((e) => [e.userMsg, ...e.assistantMsgs])),
|
|
76836
76839
|
summary: n.content,
|
|
76837
76840
|
reason: "max_memory_rounds"
|
|
76838
|
-
}),
|
|
76841
|
+
}), Fe.splice(e.deleteFrom, e.deleteCount, n), br(), je && xe) {
|
|
76839
76842
|
let n = e.summary, { prevSeg: r } = e;
|
|
76840
76843
|
(async () => {
|
|
76841
76844
|
try {
|
|
76842
|
-
let e = await
|
|
76845
|
+
let e = await xe(t1(t, Ne)), i = Fe.indexOf(n);
|
|
76843
76846
|
if (i < 0) return;
|
|
76844
|
-
|
|
76847
|
+
Fe[i].content = zTe(t, r, e), Cr.persistRuntime();
|
|
76845
76848
|
} catch (e) {}
|
|
76846
76849
|
})();
|
|
76847
76850
|
}
|
|
76848
76851
|
}
|
|
76849
|
-
let
|
|
76852
|
+
let Sr = pCe({
|
|
76850
76853
|
getConfig: () => e.images,
|
|
76851
|
-
getVision: () =>
|
|
76852
|
-
emit:
|
|
76854
|
+
getVision: () => we.vision === !0,
|
|
76855
|
+
emit: Qn,
|
|
76853
76856
|
getVfsStore: () => R.vfsStore,
|
|
76854
|
-
noteFailure: (e, t) =>
|
|
76855
|
-
}),
|
|
76857
|
+
noteFailure: (e, t) => Cr.notePersistFailure(e, t)
|
|
76858
|
+
}), Cr = sNe({
|
|
76856
76859
|
agentId: t,
|
|
76857
76860
|
options: e,
|
|
76858
|
-
emit:
|
|
76859
|
-
getStore: () =>
|
|
76861
|
+
emit: Qn,
|
|
76862
|
+
getStore: () => ye,
|
|
76860
76863
|
core: R,
|
|
76861
|
-
sessionsRef:
|
|
76862
|
-
sessionVars:
|
|
76863
|
-
messages:
|
|
76864
|
-
getUsage: () =>
|
|
76864
|
+
sessionsRef: dr,
|
|
76865
|
+
sessionVars: Ve,
|
|
76866
|
+
messages: Fe,
|
|
76867
|
+
getUsage: () => ge,
|
|
76865
76868
|
mw: {
|
|
76866
|
-
todosMw:
|
|
76867
|
-
memoryMw:
|
|
76868
|
-
missionMw:
|
|
76869
|
-
workingMemoryMw:
|
|
76870
|
-
focusMw:
|
|
76871
|
-
summarizationMw:
|
|
76872
|
-
resumeNoticeMw:
|
|
76873
|
-
useMission:
|
|
76874
|
-
useWorkingMemory:
|
|
76875
|
-
useFocus:
|
|
76876
|
-
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
|
|
76877
76880
|
},
|
|
76878
|
-
vfsStore:
|
|
76879
|
-
checkpointMgr:
|
|
76880
|
-
conflictResolve: (e) =>
|
|
76881
|
-
abortAllActive:
|
|
76882
|
-
titleLlmInvoke:
|
|
76881
|
+
vfsStore: Ie,
|
|
76882
|
+
checkpointMgr: dt,
|
|
76883
|
+
conflictResolve: (e) => _e.resolve(e),
|
|
76884
|
+
abortAllActive: hr,
|
|
76885
|
+
titleLlmInvoke: Se
|
|
76883
76886
|
});
|
|
76884
76887
|
return R.initDone = (async () => {
|
|
76885
76888
|
var t, n, r, i;
|
|
76886
|
-
await
|
|
76889
|
+
await _r(), await vr(), (t = e.mcp) != null && t.length && FAe({
|
|
76887
76890
|
servers: e.mcp,
|
|
76888
|
-
emit:
|
|
76889
|
-
isReleased: () =>
|
|
76891
|
+
emit: Qn,
|
|
76892
|
+
isReleased: () => qt,
|
|
76890
76893
|
core: {
|
|
76891
76894
|
mcpClosers: R.mcpClosers,
|
|
76892
76895
|
mcpServers: R.mcpServers,
|
|
@@ -76895,47 +76898,47 @@ function eIe(e, t, n) {
|
|
|
76895
76898
|
},
|
|
76896
76899
|
reservedNames: () => {
|
|
76897
76900
|
let e = /* @__PURE__ */ new Set();
|
|
76898
|
-
for (let t of
|
|
76899
|
-
let n =
|
|
76901
|
+
for (let t of sn) {
|
|
76902
|
+
let n = kt.get(t.name);
|
|
76900
76903
|
n && !n.startsWith("mcp:") && e.add(t.name);
|
|
76901
76904
|
}
|
|
76902
76905
|
return e;
|
|
76903
76906
|
},
|
|
76904
|
-
pushTool: (e, t) => (
|
|
76907
|
+
pushTool: (e, t) => (kt.set(e.name, `mcp:${t}`), Kt.push(e), !0),
|
|
76905
76908
|
rebind: () => {
|
|
76906
|
-
|
|
76909
|
+
sn = on(), R.agent && R.agent.setTools(sn), R.infoTick.value++;
|
|
76907
76910
|
},
|
|
76908
76911
|
debug: e.debug
|
|
76909
76912
|
});
|
|
76910
76913
|
let a = Q6(e.llm) ? e.llm : await RG(e.llm);
|
|
76911
|
-
SMe(a, { emit:
|
|
76914
|
+
SMe(a, { emit: Qn }), R.agent = VQ({
|
|
76912
76915
|
llm: a,
|
|
76913
|
-
systemPrompt:
|
|
76914
|
-
tools:
|
|
76915
|
-
middleware:
|
|
76916
|
+
systemPrompt: vt,
|
|
76917
|
+
tools: sn,
|
|
76918
|
+
middleware: cr,
|
|
76916
76919
|
maxToolRounds: e.maxToolRounds,
|
|
76917
|
-
hasSubagent:
|
|
76918
|
-
pageAssertionGate:
|
|
76919
|
-
pageReadTools:
|
|
76920
|
-
deferredWriteTools:
|
|
76920
|
+
hasSubagent: _n,
|
|
76921
|
+
pageAssertionGate: pt.domInspect === !0,
|
|
76922
|
+
pageReadTools: Wt.size ? Wt : void 0,
|
|
76923
|
+
deferredWriteTools: Gt.size ? Gt : void 0,
|
|
76921
76924
|
maxRetries: e.maxRetries,
|
|
76922
76925
|
stallMs: (n = e.streamStallMs) == null ? BZ : n,
|
|
76923
76926
|
streamMaxMs: (r = e.streamMaxDurationMs) == null ? BCe : r,
|
|
76924
76927
|
toolTimeoutMs: e.toolTimeoutMs,
|
|
76925
76928
|
maxParallelTools: e.maxParallelTools,
|
|
76926
|
-
contextWindow:
|
|
76927
|
-
maxOutputTokens:
|
|
76928
|
-
vision:
|
|
76929
|
-
imageContentFormat:
|
|
76930
|
-
maxVerifyAttempts:
|
|
76929
|
+
contextWindow: we.contextWindow,
|
|
76930
|
+
maxOutputTokens: we.maxOutputTokens,
|
|
76931
|
+
vision: we.vision,
|
|
76932
|
+
imageContentFormat: Pt,
|
|
76933
|
+
maxVerifyAttempts: Sn ? yn : 0,
|
|
76931
76934
|
roundTokenBudget: (i = e.roundTokenBudget) == null ? 0 : i,
|
|
76932
76935
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
76933
76936
|
onLlmChange: (e) => {
|
|
76934
|
-
|
|
76937
|
+
Pe = e;
|
|
76935
76938
|
},
|
|
76936
76939
|
debug: e.debug
|
|
76937
|
-
}),
|
|
76938
|
-
R.agent && R.agent.setTools(
|
|
76940
|
+
}), Xe.current = R.agent, In && In.setReconfigureHook(() => {
|
|
76941
|
+
R.agent && R.agent.setTools(on());
|
|
76939
76942
|
});
|
|
76940
76943
|
})(), R;
|
|
76941
76944
|
}
|