page-agent-sdk 4.24.0 → 4.24.2

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