page-agent-sdk 2.36.0 → 2.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6344,66 +6344,323 @@ function Ld(e) {
6344
6344
  };
6345
6345
  }
6346
6346
  //#endregion
6347
- //#region src/core/harness/subagent.ts
6347
+ //#region src/core/utils/rounds.ts
6348
6348
  function Rd(e) {
6349
+ let t = [], n = null, r = 0;
6350
+ for (let i = 0; i < e.length; i++) {
6351
+ let a = e[i];
6352
+ a.role === "user" ? (n && t.push(n), r++, n = {
6353
+ round: r,
6354
+ userMsg: a,
6355
+ assistantMsgs: [],
6356
+ startIdx: i,
6357
+ endIdx: i
6358
+ }) : n && (n.assistantMsgs.push(a), n.endIdx = i);
6359
+ }
6360
+ return n && t.push(n), t;
6361
+ }
6362
+ function zd(e, t) {
6363
+ let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
6364
+ return n.length > t ? n.slice(0, t) + "…" : n;
6365
+ }
6366
+ function Bd(e) {
6367
+ let t = [];
6368
+ for (let n of e.assistantMsgs) for (let e of n.steps || []) t.push(e.name);
6369
+ return t;
6370
+ }
6371
+ var Vd = "【更早对话摘要";
6372
+ function Hd(e, t) {
6373
+ return !t || !t.body ? e : {
6374
+ body: `${t.body}\n【续】\n${e.body}`,
6375
+ rounds: (t.rounds ?? 0) + (e.rounds ?? 0),
6376
+ cumulative: !0
6377
+ };
6378
+ }
6379
+ function Ud(e) {
6380
+ return typeof e != "string" || !e.startsWith("【更早对话摘要") ? null : { body: e.replace(/^【[^】]*】\n?/, "") };
6381
+ }
6382
+ function Wd(e) {
6383
+ return `${Vd}${e.cumulative ? `(${e.rounds ?? 0} 轮,含累积)` : e.rounds ? `(${e.rounds} 轮)` : ""}】\n${e.body}`;
6384
+ }
6385
+ function Gd(e, t, n) {
6386
+ return Wd(Hd({
6387
+ body: n,
6388
+ rounds: e.length
6389
+ }, t ?? void 0));
6390
+ }
6391
+ function Kd(e, t) {
6392
+ if (t <= 0) return { trimmed: !1 };
6393
+ let n = Rd(e);
6394
+ if (n.length <= t) return { trimmed: !1 };
6395
+ let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = null;
6396
+ for (let t = 0; t < a; t++) {
6397
+ let n = e[t];
6398
+ if (n.role === "system" && (o = Ud(n.content), o)) break;
6399
+ }
6400
+ return {
6401
+ trimmed: !0,
6402
+ deleteFrom: 0,
6403
+ deleteCount: r,
6404
+ summary: {
6405
+ role: "system",
6406
+ content: Wd(Hd({
6407
+ body: i.map((e) => {
6408
+ let t = zd(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? zd(e.assistantMsgs[0].content, 80) : "(无回复)";
6409
+ return `- 第${e.round}轮:${t} → ${n}`;
6410
+ }).join("\n"),
6411
+ rounds: i.length
6412
+ }, o ?? void 0)),
6413
+ timestamp: i[0].userMsg.timestamp
6414
+ },
6415
+ older: i,
6416
+ prevSeg: o
6417
+ };
6418
+ }
6419
+ //#endregion
6420
+ //#region src/core/composables/contextIndex.ts
6421
+ var qd = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
6422
+ function Jd(e) {
6423
+ return e.toLowerCase().split(/[^a-z0-9一-龥]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !qd.has(e));
6424
+ }
6425
+ function Yd(e) {
6426
+ let t = typeof e.content == "string" ? e.content : "";
6427
+ if (e.reasoning && (t += e.reasoning), e.steps) for (let n of e.steps) t += " " + (n.name || ""), n.args != null && (t += " " + (typeof n.args == "string" ? n.args : JSON.stringify(n.args))), n.result && (t += " " + n.result);
6428
+ return Bl(t);
6429
+ }
6430
+ function Xd(e) {
6431
+ let t = Yd(e.userMsg);
6432
+ for (let n of e.assistantMsgs) t += Yd(n);
6433
+ return t;
6434
+ }
6435
+ function Zd(e, t) {
6436
+ return e.map((e) => {
6437
+ let n = zd(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? zd(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
6438
+ if (t && t.size) {
6439
+ let n = [];
6440
+ for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${zd(e.result, 120)}`);
6441
+ n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
6442
+ }
6443
+ return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
6444
+ }).join("\n");
6445
+ }
6446
+ function Qd(e, t, n) {
6447
+ let r = Jd(t);
6448
+ return r.length === 0 ? [] : e.map((e) => {
6449
+ let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ") + " " + e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => zd(e.result || "", 120))).join(" ")).toLowerCase(), n = 0;
6450
+ for (let e of r) t.includes(e) && n++;
6451
+ return {
6452
+ r: e,
6453
+ score: n
6454
+ };
6455
+ }).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
6456
+ }
6457
+ function $d(e, t) {
6458
+ return t.contextWindow && t.contextWindow > 0 ? e.reduce((e, t) => e + Xd(t), 0) > t.contextWindow * (t.summaryThresholdRatio ?? .5) : e.length > (t.summaryThresholdRounds ?? 8);
6459
+ }
6460
+ //#endregion
6461
+ //#region src/core/composables/useContextManager.ts
6462
+ var ef = {
6463
+ windowRounds: 6,
6464
+ summaryThresholdRounds: 8,
6465
+ toolResultMaxChars: 800,
6466
+ enableRecall: !0,
6467
+ recallTopK: 3,
6468
+ enableLLMSummary: !1
6469
+ };
6470
+ function tf(e = {}) {
6471
+ let t = {
6472
+ ...ef,
6473
+ ...e
6474
+ };
6475
+ async function n(e, n) {
6476
+ let r = Rd(e), i = e.length, a = "";
6477
+ if (r.length) {
6478
+ let t = r[0].startIdx;
6479
+ for (let n = 0; n < t; n++) {
6480
+ let t = e[n];
6481
+ if (t.role === "system") {
6482
+ let e = Ud(t.content);
6483
+ if (e) {
6484
+ a = e.body;
6485
+ break;
6486
+ }
6487
+ }
6488
+ }
6489
+ }
6490
+ let o = (t) => ({
6491
+ messages: e,
6492
+ stats: {
6493
+ triggered: !1,
6494
+ roundsTotal: r.length,
6495
+ roundsSummarized: 0,
6496
+ roundsRecalled: 0,
6497
+ originalMessages: i,
6498
+ compressedMessages: i,
6499
+ strategy: t
6500
+ }
6501
+ });
6502
+ if (!$d(r, t)) return o("none");
6503
+ let s, c, l;
6504
+ if (t.contextWindow && t.contextWindow > 0) {
6505
+ let e = t.contextWindow * (n?.windowRatio ?? t.windowRatio ?? .4), i = 0, a = 0;
6506
+ for (let t = r.length - 1; t >= 0; t--) if (i += Xd(r[t]), i >= e) {
6507
+ a = t + 1;
6508
+ break;
6509
+ }
6510
+ if (a > r.length - 1 && (a = r.length - 1), a < 0 && (a = 0), s = r.slice(a), c = r.slice(0, a), !c.length) return o("none");
6511
+ l = "token-window+";
6512
+ } else {
6513
+ let e = n?.keepRounds ?? t.windowRounds, i = Math.min(Math.max(1, e), r.length);
6514
+ if (s = r.slice(r.length - i), c = r.slice(0, r.length - i), !c.length) return o("none");
6515
+ l = "window+";
6516
+ }
6517
+ let u = [...e].reverse().find((e) => e.role === "user")?.content || "", d = n?.summarize?.mode ?? (t.enableLLMSummary ? "llm" : "index"), f = /* @__PURE__ */ new Set([...t.preserveLastToolResults ?? [], ...n?.preserveTools ?? []]), p = f.size ? f : void 0, m, h;
6518
+ if (d === "llm" && t.llmInvoke) try {
6519
+ m = await t.llmInvoke(Zd(c, p)), h = l + "llm_summary";
6520
+ } catch {
6521
+ m = Zd(c, p), h = l + "index_summary(llm_fallback)";
6522
+ }
6523
+ else m = Zd(c, p), h = l + "index_summary";
6524
+ let g = n?.recallTopK == null ? t.enableRecall ? t.recallTopK : 0 : n.recallTopK, _ = g > 0 ? Qd(c, u, g) : [], v = _.length ? _.map((e) => `- 第${e.round}轮:${zd(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? zd(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", y = a ? `${m}\n【更早累积摘要】\n${a}` : m, b = [`【对话历史摘要】以下是之前 ${c.length} 轮对话的要点(最新 ${s.length} 轮已完整保留):`, y];
6525
+ if (n) {
6526
+ let e = t.contextWindow && t.contextWindow > 0 ? `windowRatio=${n.windowRatio ?? t.windowRatio}` : `keepRounds=${n.keepRounds ?? t.windowRounds}`;
6527
+ b.push(`\n(压缩决策:${e} · 摘要=${n.summarize.mode} · 召回=${g}${n.reason ? " · " + n.reason : ""})`);
6528
+ }
6529
+ v && b.push("\n【与当前问题可能相关的早期对话】", v);
6530
+ let x = t.getRegisteredData ?? t.getRegisteredSlots;
6531
+ if (x) try {
6532
+ let e = x();
6533
+ if (e.length) {
6534
+ let t = e.map((e) => `- ${e.path ? e.path + ": " : ""}${e.description}`).join("\n");
6535
+ b.push("\n【当前可操作数据(动态增删后的最新状态,操作前以 describe_data / read 为准)】", t);
6536
+ }
6537
+ } catch {}
6538
+ let S = {
6539
+ role: "system",
6540
+ content: b.join("\n"),
6541
+ timestamp: Date.now()
6542
+ }, C = [];
6543
+ for (let e of s) C.push(e.userMsg), C.push(...e.assistantMsgs);
6544
+ let w = [S, ...C], T = w.reduce((e, t) => e + Bl(typeof t.content == "string" ? t.content : JSON.stringify(t.content)), 0);
6545
+ return t.contextWindow && T > t.contextWindow && console.warn(`[page-agent-sdk] compress 后仍超窗口:${T} > ${t.contextWindow} tokens(单条消息超窗口,compress 无法压)`), {
6546
+ messages: w,
6547
+ stats: {
6548
+ triggered: !0,
6549
+ roundsTotal: r.length,
6550
+ roundsSummarized: c.length,
6551
+ roundsRecalled: _.length,
6552
+ originalMessages: i,
6553
+ compressedMessages: w.length,
6554
+ strategy: h,
6555
+ decision: n
6556
+ }
6557
+ };
6558
+ }
6559
+ return {
6560
+ compress: n,
6561
+ config: t
6562
+ };
6563
+ }
6564
+ //#endregion
6565
+ //#region src/core/harness/summarization.ts
6566
+ function nf(e = {}) {
6567
+ let t = tf(e);
6568
+ return Object.assign({
6569
+ name: "summarization",
6570
+ compressInput: async (n) => {
6571
+ let r;
6572
+ if (e.decideInvoke) {
6573
+ let i = Rd(n);
6574
+ if ($d(i, t.config)) {
6575
+ let a = t.config.contextWindow && t.config.contextWindow > 0 ? "token" : "rounds", o = a === "token" ? `历史 token 超阈值 ${Math.round((t.config.contextWindow ?? 0) * (t.config.summaryThresholdRatio ?? .5))}` : `轮数 ${i.length} 超阈值 ${t.config.summaryThresholdRounds}`;
6576
+ try {
6577
+ r = await e.decideInvoke({
6578
+ getMessages: () => n,
6579
+ getSnapshot: e.getSnapshot,
6580
+ contextWindow: t.config.contextWindow,
6581
+ thresholdRatio: t.config.summaryThresholdRatio,
6582
+ triggerReason: o,
6583
+ triggerMode: a
6584
+ }) ?? void 0;
6585
+ } catch {
6586
+ r = void 0;
6587
+ }
6588
+ }
6589
+ }
6590
+ let { messages: i, stats: a } = await t.compress(n, r);
6591
+ return {
6592
+ messages: i,
6593
+ stats: a
6594
+ };
6595
+ }
6596
+ }, { setContextWindow(e) {
6597
+ t.config.contextWindow = e;
6598
+ } });
6599
+ }
6600
+ //#endregion
6601
+ //#region src/core/harness/subagent.ts
6602
+ function rf(e) {
6349
6603
  return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
6350
6604
  }
6351
- var zd = [
6605
+ var af = [
6352
6606
  "describe_data",
6353
6607
  "get_data",
6354
6608
  "read",
6355
6609
  "query_data",
6356
6610
  "search_data",
6357
6611
  "fetch_document"
6358
- ], Bd = 1, Vd = 4, Hd = 6, Ud = ["spawn_agent", "spawn_agents"], Wd = [
6612
+ ], of = 1, sf = 4, cf = 6, lf = ["spawn_agent", "spawn_agents"], uf = [
6359
6613
  "write",
6360
6614
  "set_data",
6361
6615
  "edit_data",
6362
6616
  "delete_data",
6363
6617
  "draft_commit"
6364
6618
  ];
6365
- function Gd(e) {
6619
+ function df(e) {
6366
6620
  let t = [];
6367
6621
  if (typeof e.jsonPath == "string" && e.jsonPath && t.push(e.jsonPath), typeof e.path == "string" && e.path && t.push(e.path), e.patch && typeof e.patch.jsonPath == "string" && t.push(e.patch.jsonPath), Array.isArray(e.patches)) for (let n of e.patches) n && typeof n.jsonPath == "string" && t.push(n.jsonPath);
6368
6622
  return t;
6369
6623
  }
6370
- function Kd(e, t) {
6624
+ function ff(e, t) {
6371
6625
  return t.some((t) => e === t || e.startsWith(t + ".") || e.startsWith(t + "["));
6372
6626
  }
6373
- function qd(e, t) {
6627
+ function pf(e, t) {
6374
6628
  let n = e.invoke.bind(e), r = async (e) => {
6375
- let r = Gd(e);
6629
+ let r = df(e);
6376
6630
  if (!r.length) return `PATH_OUT_OF_SCOPE:子 agent 仅可增量 patch(writablePaths: ${t.join(", ")}),不能整体替换(无 jsonPath)。用 write({patch:{jsonPath,...}}) 增量改。`;
6377
- for (let e of r) if (!Kd(e, t)) return `PATH_OUT_OF_SCOPE:子 agent 写 "${e}" 越界(仅可写 ${t.join(", ")})。`;
6631
+ for (let e of r) if (!ff(e, t)) return `PATH_OUT_OF_SCOPE:子 agent 写 "${e}" 越界(仅可写 ${t.join(", ")})。`;
6378
6632
  return n(e);
6379
6633
  };
6380
6634
  return new Proxy(e, { get(e, t, n) {
6381
6635
  return t === "invoke" ? r : Reflect.get(e, t, n);
6382
6636
  } });
6383
6637
  }
6384
- async function Jd(e, t, n, r, i) {
6385
- let a = t.depth ?? 0, o = t.maxDepth ?? Bd, s = /* @__PURE__ */ new Set([...zd, ...t.allowedTools ?? []]), c = () => typeof t.allTools == "function" ? t.allTools() : t.allTools, l = [...c().filter((e) => s.has(e.name) && !Ud.includes(e.name)), ...t.extraTools ?? []];
6638
+ async function mf(e, t, n, r, i) {
6639
+ let a = t.depth ?? 0, o = t.maxDepth ?? of, s = /* @__PURE__ */ new Set([...af, ...t.allowedTools ?? []]), c = () => typeof t.allTools == "function" ? t.allTools() : t.allTools, l = [...c().filter((e) => s.has(e.name) && !lf.includes(e.name)), ...t.extraTools ?? []];
6386
6640
  if (t.writablePaths?.length) {
6387
- l = l.filter((e) => !Wd.includes(e.name));
6388
- let e = c().filter((e) => Wd.includes(e.name) && !Ud.includes(e.name)).map((e) => qd(e, t.writablePaths));
6641
+ l = l.filter((e) => !uf.includes(e.name));
6642
+ let e = c().filter((e) => uf.includes(e.name) && !lf.includes(e.name)).map((e) => pf(e, t.writablePaths));
6389
6643
  l = [...l, ...e];
6390
6644
  }
6391
- let u = a + 1 < o ? [Yd({
6645
+ let u = a + 1 < o ? [hf({
6392
6646
  ...t,
6393
6647
  depth: a + 1
6394
6648
  })] : [], d = t.getFocuses?.() ?? [], f = d.length ? Zu({
6395
6649
  getSchema: t.getSchema ?? (() => null),
6396
6650
  initialFocuses: d
6397
6651
  }) : void 0, p = zl({
6398
- model: Rd(t.llm) ? t.llm.model ?? t.llm.modelName : e.model ?? t.llm.model,
6652
+ model: rf(t.llm) ? t.llm.model ?? t.llm.modelName : e.model ?? t.llm.model,
6399
6653
  contextWindow: t.llm.contextWindow,
6400
6654
  maxOutputTokens: t.llm.maxOutputTokens
6401
6655
  });
6402
6656
  if (p.contextWindow < 2e5) throw Error(`[page-agent-sdk][subagent] 子 agent 模型上下文窗口 ${p.contextWindow} 小于最小支持 ${Rl}(需 ≥200K 窗口模型)`);
6403
- let m = hu({
6657
+ let m = t.summarization === void 0 ? void 0 : nf(typeof t.summarization == "object" ? {
6658
+ contextWindow: p.contextWindow,
6659
+ ...t.summarization
6660
+ } : { contextWindow: p.contextWindow }), h = hu({
6404
6661
  contextWindow: p.contextWindow,
6405
6662
  maxOutputTokens: p.maxOutputTokens,
6406
- ...Rd(t.llm) ? { llm: t.llm } : {
6663
+ ...rf(t.llm) ? { llm: t.llm } : {
6407
6664
  apiKey: t.llm.apiKey,
6408
6665
  baseUrl: t.llm.baseUrl,
6409
6666
  model: e.model ?? t.llm.model,
@@ -6414,14 +6671,16 @@ async function Jd(e, t, n, r, i) {
6414
6671
  tools: l,
6415
6672
  middleware: [
6416
6673
  ...t.skills?.length ? [_d(t.skills)] : [],
6674
+ ...m ? [m] : [],
6417
6675
  ...u,
6418
- ...f ? [f] : []
6676
+ ...f ? [f] : [],
6677
+ ...t.middleware ?? []
6419
6678
  ],
6420
- maxToolRounds: t.maxToolRounds ?? Hd,
6679
+ maxToolRounds: t.maxToolRounds ?? cf,
6421
6680
  onLog: i,
6422
6681
  debug: t.debug
6423
6682
  });
6424
- return t.debug && console.log(`[subagent] 启动子 agent(depth=${a},工具 ${l.length} 个)`), m.stream([{
6683
+ return t.debug && console.log(`[subagent] 启动子 agent(depth=${a},工具 ${l.length} 个)`), h.stream([{
6425
6684
  role: "user",
6426
6685
  content: e.prompt,
6427
6686
  timestamp: Date.now()
@@ -6429,8 +6688,8 @@ async function Jd(e, t, n, r, i) {
6429
6688
  r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
6430
6689
  }, n);
6431
6690
  }
6432
- function Yd(e) {
6433
- let n = e.maxParallel ?? Vd, i, a, o, s = (e, t) => (n) => {
6691
+ function hf(e) {
6692
+ let n = e.maxParallel ?? sf, i, a, o, s = (e, t) => (n) => {
6434
6693
  a && a({
6435
6694
  type: "subagent",
6436
6695
  taskId: e,
@@ -6450,7 +6709,7 @@ function Yd(e) {
6450
6709
  ...r?.length ? { allowedTools: r } : {},
6451
6710
  ...a?.length ? { writablePaths: a } : {}
6452
6711
  } : e, u = `sub-${Math.random().toString(36).slice(2, 8)}`, d = n?.trim() || "子任务";
6453
- return await Jd({
6712
+ return await mf({
6454
6713
  prompt: t,
6455
6714
  role: n,
6456
6715
  model: c
@@ -6470,7 +6729,7 @@ function Yd(e) {
6470
6729
  })
6471
6730
  }), r(async ({ tasks: t }) => (await Fl(t, n, async (t, n) => {
6472
6731
  let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
6473
- return Jd(t, e, i, s(r, a), (e) => o?.({
6732
+ return mf(t, e, i, s(r, a), (e) => o?.({
6474
6733
  ...e,
6475
6734
  source: `子:${a}`
6476
6735
  }));
@@ -6485,8 +6744,8 @@ function Yd(e) {
6485
6744
  wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
6486
6745
  };
6487
6746
  }
6488
- var Xd = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
6489
- function Zd(e, t) {
6747
+ var gf = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
6748
+ function _f(e, t) {
6490
6749
  let n = e.tools ?? [];
6491
6750
  return {
6492
6751
  llm: e.llm ?? t.llm,
@@ -6499,11 +6758,14 @@ function Zd(e, t) {
6499
6758
  maxToolRounds: e.maxToolRounds,
6500
6759
  debug: t.debug,
6501
6760
  ...e.writablePaths?.length ? { writablePaths: e.writablePaths } : {},
6761
+ ...e.allowedTools?.length ? { allowedTools: e.allowedTools } : {},
6762
+ ...e.middleware?.length ? { middleware: e.middleware } : {},
6763
+ ...e.summarization === void 0 ? {} : { summarization: e.summarization },
6502
6764
  ...t.getFocuses ? { getFocuses: t.getFocuses } : {},
6503
6765
  ...t.getSchema ? { getSchema: t.getSchema } : {}
6504
6766
  };
6505
6767
  }
6506
- function Qd(e, n) {
6768
+ function vf(e, n) {
6507
6769
  let i, a, o, s = (e, t) => (n) => {
6508
6770
  a && a({
6509
6771
  type: "subagent",
@@ -6519,7 +6781,7 @@ function Qd(e, n) {
6519
6781
  function d(e) {
6520
6782
  let a = /* @__PURE__ */ new Set(), c = [], l = [];
6521
6783
  for (let u of e) {
6522
- if (!Xd.test(u.id)) {
6784
+ if (!gf.test(u.id)) {
6523
6785
  console.warn(`[subagents] id "${u.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`);
6524
6786
  continue;
6525
6787
  }
@@ -6529,8 +6791,8 @@ function Qd(e, n) {
6529
6791
  continue;
6530
6792
  }
6531
6793
  a.add(e), c.push(u), l.push(r(async ({ task: e }) => {
6532
- let t = Zd(u, n);
6533
- return Jd({ prompt: e }, t, i, s(`use_${u.id}`, u.id), (e) => o?.({
6794
+ let t = _f(u, n);
6795
+ return mf({ prompt: e }, t, i, s(`use_${u.id}`, u.id), (e) => o?.({
6534
6796
  ...e,
6535
6797
  source: `子:${u.id}`
6536
6798
  }));
@@ -6574,7 +6836,7 @@ function Qd(e, n) {
6574
6836
  augmentPrompt: () => c.length ? [
6575
6837
  "## 可用子 agent(预声明,经专属工具委派)",
6576
6838
  ...c.map((e) => `- use_${e.id}: ${e.description}`),
6577
- "需要某子 agent 时,直接调用对应的 use_<id>({ task }) 委派,任务描述要清晰。"
6839
+ "复杂或专项任务(检索 / 生成 / 调研 / 多步等)优先委派子 agent:过程隔离不占主上下文 + 各子 agent 专项处理更优。需要时直接调 use_<id>({ task }) 委派,任务描述要清晰(含背景 + 用户观点/反馈,转述给子 agent);委派后信任子 agent 自主完成,不微操、不读其代码/中间细节(少占主上下文),只据其结论继续。简单任务(单字段改、直接读)用内置工具更快,不必委派。"
6578
6840
  ].join("\n") : void 0,
6579
6841
  wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
6580
6842
  };
@@ -6590,7 +6852,7 @@ function Qd(e, n) {
6590
6852
  }
6591
6853
  //#endregion
6592
6854
  //#region src/core/harness/verify.ts
6593
- function $d(e) {
6855
+ function yf(e) {
6594
6856
  return {
6595
6857
  name: "verify",
6596
6858
  async beforeReturn({ messages: t, state: n, log: r }) {
@@ -6602,10 +6864,10 @@ function $d(e) {
6602
6864
  if (e.adversarial) {
6603
6865
  r?.("middleware", {
6604
6866
  stage: "adversarial_start",
6605
- model: cf(e.adversarial.llm),
6867
+ model: Df(e.adversarial.llm),
6606
6868
  tools: (e.adversarial.tools ?? []).length
6607
6869
  });
6608
- let n = await ff(t, e.adversarial.llm, r, e.adversarial.tools);
6870
+ let n = await jf(t, e.adversarial.llm, r, e.adversarial.tools);
6609
6871
  if (r?.("middleware", {
6610
6872
  stage: "adversarial_done",
6611
6873
  clean: n === null,
@@ -6616,18 +6878,18 @@ function $d(e) {
6616
6878
  }
6617
6879
  };
6618
6880
  }
6619
- var ef = /* @__PURE__ */ new Set([
6881
+ var bf = /* @__PURE__ */ new Set([
6620
6882
  "set_data",
6621
6883
  "edit_data",
6622
6884
  "delete_data",
6623
6885
  "write"
6624
- ]), tf = /校验失败|SCHEMA_INVALID|未注册|不存在|仅支持|必须是|NOT_OBJECT|PATH_UNSAFE|VERSION_CONFLICT|WRITE_INTERCEPT/;
6625
- function nf(e) {
6886
+ ]), xf = /校验失败|SCHEMA_INVALID|未注册|不存在|仅支持|必须是|NOT_OBJECT|PATH_UNSAFE|VERSION_CONFLICT|WRITE_INTERCEPT/;
6887
+ function Sf(e) {
6626
6888
  let t = /* @__PURE__ */ new Map();
6627
6889
  for (let n of e) {
6628
6890
  let e = n?.tool_calls;
6629
6891
  if (Array.isArray(e)) for (let n of e) {
6630
- if (!ef.has(n.name)) continue;
6892
+ if (!bf.has(n.name)) continue;
6631
6893
  let e = n.id, r = n?.args ?? {};
6632
6894
  if (n.name === "write") if (r.del && r.patch?.jsonPath) t.set(r.patch.jsonPath, {
6633
6895
  path: r.patch.jsonPath,
@@ -6666,7 +6928,7 @@ function nf(e) {
6666
6928
  }
6667
6929
  return [...t.values()];
6668
6930
  }
6669
- function rf(e) {
6931
+ function Cf(e) {
6670
6932
  let t = /* @__PURE__ */ new Map();
6671
6933
  for (let n of e) {
6672
6934
  let e = n?.tool_call_id, r = n?.content;
@@ -6674,7 +6936,7 @@ function rf(e) {
6674
6936
  }
6675
6937
  return t;
6676
6938
  }
6677
- function af(e, t) {
6939
+ function wf(e, t) {
6678
6940
  if (t === "") return e;
6679
6941
  if (e == null) return;
6680
6942
  let n = e;
@@ -6684,16 +6946,16 @@ function af(e, t) {
6684
6946
  }
6685
6947
  return n;
6686
6948
  }
6687
- function of(e = {}) {
6949
+ function Tf(e = {}) {
6688
6950
  let t = typeof e.root == "function" ? e.root : e.root === void 0 ? () => e.window ?? globalThis.window : () => e.root, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
6689
6951
  return async ({ messages: e }) => {
6690
- let r = nf(e);
6952
+ let r = Sf(e);
6691
6953
  if (!r.length) return { ok: !0 };
6692
- let i = rf(e), a = n()[""], o = t(), s = [];
6954
+ let i = Cf(e), a = n()[""], o = t(), s = [];
6693
6955
  for (let { path: e, op: t, callId: n } of r) {
6694
6956
  let r = n ? i.get(n) : void 0;
6695
- if (r && tf.test(r)) continue;
6696
- let c = af(o, e);
6957
+ if (r && xf.test(r)) continue;
6958
+ let c = wf(o, e);
6697
6959
  if (t === "delete_data") c !== void 0 && s.push(`${e} 删除后读回仍有值,疑似未生效`);
6698
6960
  else if (c == null) s.push(`写入 ${e} 后读回为空,疑似未生效`);
6699
6961
  else if (a) {
@@ -6707,17 +6969,17 @@ function of(e = {}) {
6707
6969
  } : { ok: !0 };
6708
6970
  };
6709
6971
  }
6710
- function sf(e) {
6972
+ function Ef(e) {
6711
6973
  return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
6712
6974
  }
6713
- function cf(e) {
6714
- return sf(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
6975
+ function Df(e) {
6976
+ return Ef(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
6715
6977
  }
6716
- var lf = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
6717
- function uf(e) {
6718
- return lf.test(e);
6978
+ var Of = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
6979
+ function kf(e) {
6980
+ return Of.test(e);
6719
6981
  }
6720
- function df(e) {
6982
+ function Af(e) {
6721
6983
  let t = "", n = "";
6722
6984
  for (let r of e) r instanceof a ? t = typeof r.content == "string" ? r.content : "" : r instanceof i && !(r.tool_calls?.length > 0) && (n = typeof r.content == "string" ? r.content : "");
6723
6985
  return {
@@ -6725,8 +6987,8 @@ function df(e) {
6725
6987
  lastReply: n
6726
6988
  };
6727
6989
  }
6728
- async function ff(e, t, n, r) {
6729
- let { lastUser: i, lastReply: a } = df(e);
6990
+ async function jf(e, t, n, r) {
6991
+ let { lastUser: i, lastReply: a } = Af(e);
6730
6992
  if (!a) return null;
6731
6993
  let o = Array.isArray(r) && r.length > 0, s = [
6732
6994
  "你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
@@ -6737,7 +6999,7 @@ async function ff(e, t, n, r) {
6737
6999
  ].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
6738
7000
  ...e.data,
6739
7001
  source: "adversarial"
6740
- }) : void 0, u = await hu(sf(t) ? {
7002
+ }) : void 0, u = await hu(Ef(t) ? {
6741
7003
  llm: t,
6742
7004
  tools: r,
6743
7005
  maxToolRounds: o ? 4 : 1,
@@ -6762,11 +7024,11 @@ async function ff(e, t, n, r) {
6762
7024
  stage: "adversarial_verdict",
6763
7025
  verdict: u,
6764
7026
  source: "adversarial"
6765
- }), uf(u) ? null : u.trim();
7027
+ }), kf(u) ? null : u.trim();
6766
7028
  }
6767
7029
  //#endregion
6768
7030
  //#region src/core/utils/contextAnalysis.ts
6769
- var pf = [
7031
+ var Mf = [
6770
7032
  {
6771
7033
  prefix: "## 可操作数据",
6772
7034
  key: "dataHint"
@@ -6795,7 +7057,7 @@ var pf = [
6795
7057
  prefix: "【与当前问题可能相关的早期对话】",
6796
7058
  key: "recall"
6797
7059
  }
6798
- ], mf = [
7060
+ ], Nf = [
6799
7061
  {
6800
7062
  key: "systemPrompt",
6801
7063
  label: "系统提示词(身份/规则)"
@@ -6849,9 +7111,9 @@ var pf = [
6849
7111
  label: "其他"
6850
7112
  }
6851
7113
  ];
6852
- function hf() {
7114
+ function Pf() {
6853
7115
  let e = {};
6854
- for (let t of mf) e[t.key] = {
7116
+ for (let t of Nf) e[t.key] = {
6855
7117
  key: t.key,
6856
7118
  label: t.label,
6857
7119
  tokens: 0,
@@ -6860,16 +7122,16 @@ function hf() {
6860
7122
  };
6861
7123
  return e;
6862
7124
  }
6863
- function gf(e, t) {
7125
+ function Ff(e, t) {
6864
7126
  e.tokens += t, e.msgCount += 1;
6865
7127
  }
6866
- function _f(e) {
7128
+ function If(e) {
6867
7129
  let t = e.content;
6868
7130
  return typeof t == "string" ? t : JSON.stringify(t ?? "");
6869
7131
  }
6870
- function vf(e, t) {
7132
+ function Lf(e, t) {
6871
7133
  let n = [];
6872
- for (let t of pf) {
7134
+ for (let t of Mf) {
6873
7135
  let r = 0;
6874
7136
  for (;;) {
6875
7137
  let i = e.indexOf(t.prefix, r);
@@ -6882,35 +7144,35 @@ function vf(e, t) {
6882
7144
  }
6883
7145
  if (n.sort((e, t) => e.idx - t.idx), !n.length) {
6884
7146
  let n = e.trim();
6885
- n && gf(t.systemPrompt, Bl(n));
7147
+ n && Ff(t.systemPrompt, Bl(n));
6886
7148
  return;
6887
7149
  }
6888
7150
  if (n[0].idx > 0) {
6889
7151
  let r = e.slice(0, n[0].idx).trim();
6890
- r && gf(t.systemPrompt, Bl(r));
7152
+ r && Ff(t.systemPrompt, Bl(r));
6891
7153
  }
6892
7154
  for (let r = 0; r < n.length; r++) {
6893
7155
  let i = n[r].idx, a = r + 1 < n.length ? n[r + 1].idx : e.length, o = e.slice(i, a).trim();
6894
- o && gf(t[n[r].key], Bl(o));
7156
+ o && Ff(t[n[r].key], Bl(o));
6895
7157
  }
6896
7158
  }
6897
- function yf(e, t = {}) {
6898
- let n = hf(), r = -1;
7159
+ function Rf(e, t = {}) {
7160
+ let n = Pf(), r = -1;
6899
7161
  for (let t = e.length - 1; t >= 0; t--) if (e[t] instanceof a) {
6900
7162
  r = t;
6901
7163
  break;
6902
7164
  }
6903
7165
  for (let t = 0; t < e.length; t++) {
6904
7166
  let c = e[t];
6905
- if (c instanceof o) vf(_f(c), n);
6906
- else if (c instanceof a) gf(n[t === r ? "current" : "history"], Bl(_f(c)));
7167
+ if (c instanceof o) Lf(If(c), n);
7168
+ else if (c instanceof a) Ff(n[t === r ? "current" : "history"], Bl(If(c)));
6907
7169
  else if (c instanceof i) {
6908
7170
  let e = c.tool_calls ?? [];
6909
7171
  if (e.length) {
6910
7172
  let t = e.map((e) => JSON.stringify(e.args ?? {})).join(" ");
6911
- gf(n.toolResults, Bl(t));
6912
- } else gf(n.assistant, Bl(_f(c)));
6913
- } else c instanceof s ? gf(n.toolResults, Bl(_f(c))) : gf(n.other, Bl(_f(c)));
7173
+ Ff(n.toolResults, Bl(t));
7174
+ } else Ff(n.assistant, Bl(If(c)));
7175
+ } else c instanceof s ? Ff(n.toolResults, Bl(If(c))) : Ff(n.other, Bl(If(c)));
6914
7176
  }
6915
7177
  let c = Object.values(n).filter((e) => e.tokens > 0);
6916
7178
  c.sort((e, t) => t.tokens - e.tokens);
@@ -6927,12 +7189,12 @@ function yf(e, t = {}) {
6927
7189
  }
6928
7190
  //#endregion
6929
7191
  //#region src/core/harness/contextInspector.ts
6930
- function bf(e = {}) {
7192
+ function zf(e = {}) {
6931
7193
  let t, n = e.contextWindow;
6932
7194
  return {
6933
7195
  name: "context-inspector",
6934
7196
  async wrapModelCall(r, i) {
6935
- return t = yf(r.messages, {
7197
+ return t = Rf(r.messages, {
6936
7198
  contextWindow: n,
6937
7199
  thresholdRatio: e.thresholdRatio
6938
7200
  }), i(r);
@@ -6945,13 +7207,13 @@ function bf(e = {}) {
6945
7207
  }
6946
7208
  //#endregion
6947
7209
  //#region src/core/mcp/client.ts
6948
- function xf(e) {
7210
+ function Bf(e) {
6949
7211
  let t = e?.content;
6950
7212
  if (!Array.isArray(t) || !t.length) return "";
6951
7213
  let n = t.map((e) => e.type === "text" && e.text ? e.text : e.type === "image" && e.data ? `[image:${String(e.data).slice(0, 32)}…]` : e.type === "audio" && e.data ? "[audio]" : e.type === "resource" && e.resource ? e.resource.text ?? e.resource.blob ?? "" : "").filter(Boolean).join("\n");
6952
7214
  return e?.isError ? `工具错误:${n}` : n;
6953
7215
  }
6954
- async function Sf(e) {
7216
+ async function Vf(e) {
6955
7217
  let t = new URL(e.url), n = e.requestInit;
6956
7218
  if (e.transport === "http") {
6957
7219
  let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
@@ -6964,8 +7226,8 @@ async function Sf(e) {
6964
7226
  let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
6965
7227
  return new r(t);
6966
7228
  }
6967
- function Cf(e, t) {
6968
- return r(async (n) => xf(await t.callTool({
7229
+ function Hf(e, t) {
7230
+ return r(async (n) => Bf(await t.callTool({
6969
7231
  name: e.name,
6970
7232
  arguments: n
6971
7233
  })), {
@@ -6974,273 +7236,19 @@ function Cf(e, t) {
6974
7236
  schema: e.inputSchema
6975
7237
  });
6976
7238
  }
6977
- async function wf(e) {
6978
- let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await Sf(e), r = new t({
7239
+ async function Uf(e) {
7240
+ let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await Vf(e), r = new t({
6979
7241
  name: "page-agent-sdk",
6980
7242
  version: "1.0"
6981
7243
  }, { capabilities: {} });
6982
7244
  await r.connect(n);
6983
7245
  let { tools: i } = await r.listTools();
6984
7246
  return {
6985
- tools: i.map((e) => Cf(e, r)),
7247
+ tools: i.map((e) => Hf(e, r)),
6986
7248
  close: () => r.close()
6987
7249
  };
6988
7250
  }
6989
7251
  //#endregion
6990
- //#region src/core/utils/rounds.ts
6991
- function Tf(e) {
6992
- let t = [], n = null, r = 0;
6993
- for (let i = 0; i < e.length; i++) {
6994
- let a = e[i];
6995
- a.role === "user" ? (n && t.push(n), r++, n = {
6996
- round: r,
6997
- userMsg: a,
6998
- assistantMsgs: [],
6999
- startIdx: i,
7000
- endIdx: i
7001
- }) : n && (n.assistantMsgs.push(a), n.endIdx = i);
7002
- }
7003
- return n && t.push(n), t;
7004
- }
7005
- function Ef(e, t) {
7006
- let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
7007
- return n.length > t ? n.slice(0, t) + "…" : n;
7008
- }
7009
- function Df(e) {
7010
- let t = [];
7011
- for (let n of e.assistantMsgs) for (let e of n.steps || []) t.push(e.name);
7012
- return t;
7013
- }
7014
- var Of = "【更早对话摘要";
7015
- function kf(e, t) {
7016
- return !t || !t.body ? e : {
7017
- body: `${t.body}\n【续】\n${e.body}`,
7018
- rounds: (t.rounds ?? 0) + (e.rounds ?? 0),
7019
- cumulative: !0
7020
- };
7021
- }
7022
- function Af(e) {
7023
- return typeof e != "string" || !e.startsWith("【更早对话摘要") ? null : { body: e.replace(/^【[^】]*】\n?/, "") };
7024
- }
7025
- function jf(e) {
7026
- return `${Of}${e.cumulative ? `(${e.rounds ?? 0} 轮,含累积)` : e.rounds ? `(${e.rounds} 轮)` : ""}】\n${e.body}`;
7027
- }
7028
- function Mf(e, t, n) {
7029
- return jf(kf({
7030
- body: n,
7031
- rounds: e.length
7032
- }, t ?? void 0));
7033
- }
7034
- function Nf(e, t) {
7035
- if (t <= 0) return { trimmed: !1 };
7036
- let n = Tf(e);
7037
- if (n.length <= t) return { trimmed: !1 };
7038
- let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = null;
7039
- for (let t = 0; t < a; t++) {
7040
- let n = e[t];
7041
- if (n.role === "system" && (o = Af(n.content), o)) break;
7042
- }
7043
- return {
7044
- trimmed: !0,
7045
- deleteFrom: 0,
7046
- deleteCount: r,
7047
- summary: {
7048
- role: "system",
7049
- content: jf(kf({
7050
- body: i.map((e) => {
7051
- let t = Ef(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? Ef(e.assistantMsgs[0].content, 80) : "(无回复)";
7052
- return `- 第${e.round}轮:${t} → ${n}`;
7053
- }).join("\n"),
7054
- rounds: i.length
7055
- }, o ?? void 0)),
7056
- timestamp: i[0].userMsg.timestamp
7057
- },
7058
- older: i,
7059
- prevSeg: o
7060
- };
7061
- }
7062
- //#endregion
7063
- //#region src/core/composables/contextIndex.ts
7064
- var Pf = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
7065
- function Ff(e) {
7066
- return e.toLowerCase().split(/[^a-z0-9一-龥]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !Pf.has(e));
7067
- }
7068
- function If(e) {
7069
- let t = typeof e.content == "string" ? e.content : "";
7070
- if (e.reasoning && (t += e.reasoning), e.steps) for (let n of e.steps) t += " " + (n.name || ""), n.args != null && (t += " " + (typeof n.args == "string" ? n.args : JSON.stringify(n.args))), n.result && (t += " " + n.result);
7071
- return Bl(t);
7072
- }
7073
- function Lf(e) {
7074
- let t = If(e.userMsg);
7075
- for (let n of e.assistantMsgs) t += If(n);
7076
- return t;
7077
- }
7078
- function Rf(e, t) {
7079
- return e.map((e) => {
7080
- let n = Ef(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? Ef(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
7081
- if (t && t.size) {
7082
- let n = [];
7083
- for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${Ef(e.result, 120)}`);
7084
- n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
7085
- }
7086
- return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
7087
- }).join("\n");
7088
- }
7089
- function zf(e, t, n) {
7090
- let r = Ff(t);
7091
- return r.length === 0 ? [] : e.map((e) => {
7092
- let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ") + " " + e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => Ef(e.result || "", 120))).join(" ")).toLowerCase(), n = 0;
7093
- for (let e of r) t.includes(e) && n++;
7094
- return {
7095
- r: e,
7096
- score: n
7097
- };
7098
- }).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
7099
- }
7100
- function Bf(e, t) {
7101
- return t.contextWindow && t.contextWindow > 0 ? e.reduce((e, t) => e + Lf(t), 0) > t.contextWindow * (t.summaryThresholdRatio ?? .5) : e.length > (t.summaryThresholdRounds ?? 8);
7102
- }
7103
- //#endregion
7104
- //#region src/core/composables/useContextManager.ts
7105
- var Vf = {
7106
- windowRounds: 6,
7107
- summaryThresholdRounds: 8,
7108
- toolResultMaxChars: 800,
7109
- enableRecall: !0,
7110
- recallTopK: 3,
7111
- enableLLMSummary: !1
7112
- };
7113
- function Hf(e = {}) {
7114
- let t = {
7115
- ...Vf,
7116
- ...e
7117
- };
7118
- async function n(e, n) {
7119
- let r = Tf(e), i = e.length, a = "";
7120
- if (r.length) {
7121
- let t = r[0].startIdx;
7122
- for (let n = 0; n < t; n++) {
7123
- let t = e[n];
7124
- if (t.role === "system") {
7125
- let e = Af(t.content);
7126
- if (e) {
7127
- a = e.body;
7128
- break;
7129
- }
7130
- }
7131
- }
7132
- }
7133
- let o = (t) => ({
7134
- messages: e,
7135
- stats: {
7136
- triggered: !1,
7137
- roundsTotal: r.length,
7138
- roundsSummarized: 0,
7139
- roundsRecalled: 0,
7140
- originalMessages: i,
7141
- compressedMessages: i,
7142
- strategy: t
7143
- }
7144
- });
7145
- if (!Bf(r, t)) return o("none");
7146
- let s, c, l;
7147
- if (t.contextWindow && t.contextWindow > 0) {
7148
- let e = t.contextWindow * (n?.windowRatio ?? t.windowRatio ?? .4), i = 0, a = 0;
7149
- for (let t = r.length - 1; t >= 0; t--) if (i += Lf(r[t]), i >= e) {
7150
- a = t + 1;
7151
- break;
7152
- }
7153
- if (a > r.length - 1 && (a = r.length - 1), a < 0 && (a = 0), s = r.slice(a), c = r.slice(0, a), !c.length) return o("none");
7154
- l = "token-window+";
7155
- } else {
7156
- let e = n?.keepRounds ?? t.windowRounds, i = Math.min(Math.max(1, e), r.length);
7157
- if (s = r.slice(r.length - i), c = r.slice(0, r.length - i), !c.length) return o("none");
7158
- l = "window+";
7159
- }
7160
- let u = [...e].reverse().find((e) => e.role === "user")?.content || "", d = n?.summarize?.mode ?? (t.enableLLMSummary ? "llm" : "index"), f = /* @__PURE__ */ new Set([...t.preserveLastToolResults ?? [], ...n?.preserveTools ?? []]), p = f.size ? f : void 0, m, h;
7161
- if (d === "llm" && t.llmInvoke) try {
7162
- m = await t.llmInvoke(Rf(c, p)), h = l + "llm_summary";
7163
- } catch {
7164
- m = Rf(c, p), h = l + "index_summary(llm_fallback)";
7165
- }
7166
- else m = Rf(c, p), h = l + "index_summary";
7167
- let g = n?.recallTopK == null ? t.enableRecall ? t.recallTopK : 0 : n.recallTopK, _ = g > 0 ? zf(c, u, g) : [], v = _.length ? _.map((e) => `- 第${e.round}轮:${Ef(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? Ef(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", y = a ? `${m}\n【更早累积摘要】\n${a}` : m, b = [`【对话历史摘要】以下是之前 ${c.length} 轮对话的要点(最新 ${s.length} 轮已完整保留):`, y];
7168
- if (n) {
7169
- let e = t.contextWindow && t.contextWindow > 0 ? `windowRatio=${n.windowRatio ?? t.windowRatio}` : `keepRounds=${n.keepRounds ?? t.windowRounds}`;
7170
- b.push(`\n(压缩决策:${e} · 摘要=${n.summarize.mode} · 召回=${g}${n.reason ? " · " + n.reason : ""})`);
7171
- }
7172
- v && b.push("\n【与当前问题可能相关的早期对话】", v);
7173
- let x = t.getRegisteredData ?? t.getRegisteredSlots;
7174
- if (x) try {
7175
- let e = x();
7176
- if (e.length) {
7177
- let t = e.map((e) => `- ${e.path ? e.path + ": " : ""}${e.description}`).join("\n");
7178
- b.push("\n【当前可操作数据(动态增删后的最新状态,操作前以 describe_data / read 为准)】", t);
7179
- }
7180
- } catch {}
7181
- let S = {
7182
- role: "system",
7183
- content: b.join("\n"),
7184
- timestamp: Date.now()
7185
- }, C = [];
7186
- for (let e of s) C.push(e.userMsg), C.push(...e.assistantMsgs);
7187
- let w = [S, ...C], T = w.reduce((e, t) => e + Bl(typeof t.content == "string" ? t.content : JSON.stringify(t.content)), 0);
7188
- return t.contextWindow && T > t.contextWindow && console.warn(`[page-agent-sdk] compress 后仍超窗口:${T} > ${t.contextWindow} tokens(单条消息超窗口,compress 无法压)`), {
7189
- messages: w,
7190
- stats: {
7191
- triggered: !0,
7192
- roundsTotal: r.length,
7193
- roundsSummarized: c.length,
7194
- roundsRecalled: _.length,
7195
- originalMessages: i,
7196
- compressedMessages: w.length,
7197
- strategy: h,
7198
- decision: n
7199
- }
7200
- };
7201
- }
7202
- return {
7203
- compress: n,
7204
- config: t
7205
- };
7206
- }
7207
- //#endregion
7208
- //#region src/core/harness/summarization.ts
7209
- function Uf(e = {}) {
7210
- let t = Hf(e);
7211
- return Object.assign({
7212
- name: "summarization",
7213
- compressInput: async (n) => {
7214
- let r;
7215
- if (e.decideInvoke) {
7216
- let i = Tf(n);
7217
- if (Bf(i, t.config)) {
7218
- let a = t.config.contextWindow && t.config.contextWindow > 0 ? "token" : "rounds", o = a === "token" ? `历史 token 超阈值 ${Math.round((t.config.contextWindow ?? 0) * (t.config.summaryThresholdRatio ?? .5))}` : `轮数 ${i.length} 超阈值 ${t.config.summaryThresholdRounds}`;
7219
- try {
7220
- r = await e.decideInvoke({
7221
- getMessages: () => n,
7222
- getSnapshot: e.getSnapshot,
7223
- contextWindow: t.config.contextWindow,
7224
- thresholdRatio: t.config.summaryThresholdRatio,
7225
- triggerReason: o,
7226
- triggerMode: a
7227
- }) ?? void 0;
7228
- } catch {
7229
- r = void 0;
7230
- }
7231
- }
7232
- }
7233
- let { messages: i, stats: a } = await t.compress(n, r);
7234
- return {
7235
- messages: i,
7236
- stats: a
7237
- };
7238
- }
7239
- }, { setContextWindow(e) {
7240
- t.config.contextWindow = e;
7241
- } });
7242
- }
7243
- //#endregion
7244
7252
  //#region src/core/sdk/promptBuilder.ts
7245
7253
  var Wf = [
7246
7254
  "你是一个 JSON 操作助手。集成方声明了一个主数据对象(含 zod schema 校验),你通过专用工具安全地读写它来完成任务。",
@@ -7288,8 +7296,8 @@ function Yf(e) {
7288
7296
  description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
7289
7297
  schema: Jf,
7290
7298
  handler: (t) => {
7291
- let n = Tf(e.getMessages()), r = n.length > 50 ? n.slice(n.length - 50) : n, i = (t.limit && r.length > t.limit ? r.slice(r.length - t.limit) : r).map((e) => {
7292
- let n = Lf(e), r = Df(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = Ef(typeof i.content == "string" ? i.content : "", 60);
7299
+ let n = Rd(e.getMessages()), r = n.length > 50 ? n.slice(n.length - 50) : n, i = (t.limit && r.length > t.limit ? r.slice(r.length - t.limit) : r).map((e) => {
7300
+ let n = Xd(e), r = Bd(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = zd(typeof i.content == "string" ? i.content : "", 60);
7293
7301
  return {
7294
7302
  round: e.round,
7295
7303
  tokens: n,
@@ -11008,7 +11016,7 @@ function Kh(e, n) {
11008
11016
  e.debug && N.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
11009
11017
  let De = N.memory, Oe = N.subagent, H = e.verify?.maxAttempts ?? 2, ke = N.verify && e.verify?.enabled !== !1 && H > 0, Ae = N.contextInspector;
11010
11018
  e.verify?.check && !N.verify && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
11011
- let je = e.subagent, Me = je?.allowedTools ?? [], Ne = !Oe || je?.enabled === !1 ? void 0 : Yd({
11019
+ let je = e.subagent, Me = je?.allowedTools ?? [], Ne = !Oe || je?.enabled === !1 ? void 0 : hf({
11012
11020
  llm: je?.llm ?? e.llm,
11013
11021
  allTools: () => ve,
11014
11022
  allowedTools: Me.length ? Me : void 0,
@@ -11021,7 +11029,7 @@ function Kh(e, n) {
11021
11029
  debug: e.debug,
11022
11030
  getFocuses: () => w.getFocuses(),
11023
11031
  getSchema: () => B()?.schema ?? null
11024
- }), Pe = Oe && e.subagents !== void 0 ? Qd(e.subagents, {
11032
+ }), Pe = Oe && e.subagents !== void 0 ? vf(e.subagents, {
11025
11033
  llm: e.llm,
11026
11034
  allTools: () => ve,
11027
11035
  debug: e.debug,
@@ -11032,8 +11040,8 @@ function Kh(e, n) {
11032
11040
  "describe_data",
11033
11041
  "read",
11034
11042
  "fetch_document"
11035
- ], Le = ve.filter((e) => Ie.includes(e.name)), Re = ke ? $d({
11036
- check: e.verify.check ?? of({
11043
+ ], Le = ve.filter((e) => Ie.includes(e.name)), Re = ke ? yf({
11044
+ check: e.verify.check ?? Tf({
11037
11045
  schemas: () => B() ? { "": B().schema } : {},
11038
11046
  root: () => B()?.bind
11039
11047
  }),
@@ -11041,7 +11049,7 @@ function Kh(e, n) {
11041
11049
  llm: e.llm,
11042
11050
  tools: Le
11043
11051
  } : void 0
11044
- }) : void 0, ze = Ae ? bf({
11052
+ }) : void 0, ze = Ae ? zf({
11045
11053
  contextWindow: f.contextWindow,
11046
11054
  thresholdRatio: Vp(e, f.contextWindow).summaryThresholdRatio
11047
11055
  }) : void 0, Be = Ah({
@@ -11099,7 +11107,7 @@ function Kh(e, n) {
11099
11107
  W.infoTick.value++;
11100
11108
  }
11101
11109
  } catch {}
11102
- }, Qe = Te ? Uf({
11110
+ }, Qe = Te ? nf({
11103
11111
  ...p,
11104
11112
  llmInvoke: l,
11105
11113
  getRegisteredData: () => B() ? [{ description: B().description ?? "主数据对象" }] : [],
@@ -11582,7 +11590,7 @@ function Kh(e, n) {
11582
11590
  for (let t of e) delete y.files[t];
11583
11591
  }
11584
11592
  function st() {
11585
- let e = Nf(v, et);
11593
+ let e = Kd(v, et);
11586
11594
  if (!e.trimmed) return;
11587
11595
  let { older: t, summary: n } = e;
11588
11596
  if (We({
@@ -11600,9 +11608,9 @@ function Kh(e, n) {
11600
11608
  let n = e.summary, { prevSeg: r } = e;
11601
11609
  (async () => {
11602
11610
  try {
11603
- let e = await l(Rf(t, g)), i = v.indexOf(n);
11611
+ let e = await l(Zd(t, g)), i = v.indexOf(n);
11604
11612
  if (i < 0) return;
11605
- v[i].content = Mf(t, r, e), ut();
11613
+ v[i].content = Gd(t, r, e), ut();
11606
11614
  } catch {}
11607
11615
  })();
11608
11616
  }
@@ -11634,7 +11642,7 @@ function Kh(e, n) {
11634
11642
  }
11635
11643
  return W.initDone = (async () => {
11636
11644
  if (await rt(), await it(), e.mcp?.length) {
11637
- let t = await Promise.allSettled(e.mcp.map((e) => wf(e)));
11645
+ let t = await Promise.allSettled(e.mcp.map((e) => Uf(e)));
11638
11646
  W.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), W.mcpServers = [], t.forEach((t, n) => {
11639
11647
  let r = e.mcp[n], i = r.name ?? r.url;
11640
11648
  t.status === "fulfilled" ? (W.mcpServers.push({
@@ -11832,6 +11840,13 @@ function qh(e, t) {
11832
11840
  value: r
11833
11841
  }), { ok: !0 };
11834
11842
  },
11843
+ vfsWrite: (e, t) => {
11844
+ let n = typeof t == "string" ? t : JSON.stringify(t);
11845
+ a.vfsStore.files[hm(e)] = {
11846
+ content: n,
11847
+ updatedAt: Date.now()
11848
+ };
11849
+ },
11835
11850
  createResource: (e, t) => {
11836
11851
  let n = a.dataOpsController;
11837
11852
  if (!n?.createResource) throw Error("[page-agent-sdk] createResource 不可用:需配 data.resources + vfsStore(capabilities.vfs 默认开)");
@@ -23219,9 +23234,115 @@ function jT(e) {
23219
23234
  };
23220
23235
  }
23221
23236
  //#endregion
23237
+ //#region src/core/sdk/ragSubagent.ts
23238
+ var MT = "你是知识检索专家。可用工具:search_docs(语义检索)/ load_doc(按 source 加载)/ vfs_grep+vfs_read(搜预注入文档)/ fetch_document(公网 URL)。\n\n工作方式:\n1. 分析任务,拆出需查证的要点(如:需要哪些组件、各自的 props 约束、UI 规范要求);\n2. 多源检索:先 vfs_grep 搜预注入文档(快、静态)→ 不够用 search_docs 语义检索 → 需特定文档用 load_doc → 公网用 fetch_document;\n3. 检索结果不足时换关键词、扩大 topK、或换源重试;\n4. 综合成结构化、可执行结论(不堆原文,提炼成可直接用于决策/配置的信息);\n5. 标注关键信息来源(文档名/段落),便于溯源;检索不到明确说「未检索到」,不编造。\n\n你是只读检索角色,不要尝试修改任何数据。", NT = "# 知识检索策略(RAG)\n\n## 多源决策树\n- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查\n- search_docs:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用\n- load_doc:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档\n- fetch_document:公网 URL —— 查公开资料\n\n## 综合规范\n- 多源交叉验证(关键结论优先 ≥2 源印证,或单一权威源)\n- 标注来源(文档名 / URL / 段落),便于溯源\n- 结构化、可执行结论(组件清单 + 各自 props 约束 + 适用场景),不堆原文\n- 未检索到明确说「未检索到」,不编造;建议替代方案(改关键词 / 建议写代码组件等)\n\n## 何时用何源\n- 静态文档(组件库文档 / UI 规范):vfs_grep\n- 语义相似(「瀑布流组件」「倒计时」「拼团」):search_docs\n- 已知文档 id / URL:load_doc\n- 公开 URL(设计规范网站 / 第三方文档):fetch_document", PT = {
23239
+ name: "rag-search",
23240
+ description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
23241
+ getContent: () => NT
23242
+ };
23243
+ function FT(e, n, i) {
23244
+ return r(async ({ query: e, topK: t }) => {
23245
+ try {
23246
+ let r = await n(e, { topK: t ?? i });
23247
+ return r?.length ? r.map((e, t) => `【${t + 1}】${e.source ? `来源:${e.source}\n` : ""}${e.content}`).join("\n\n") : `未检索到与「${e}」相关的内容。可换关键词或扩大 topK 重试。`;
23248
+ } catch (e) {
23249
+ return `检索出错:${e.message}。可换关键词重试。`;
23250
+ }
23251
+ }, {
23252
+ name: e,
23253
+ description: "语义检索知识库(组件文档/UI 规范/业务规则等),返回相关片段。需要查阅文档才能回答或配置时用;可多次调用不同关键词。",
23254
+ schema: t.object({
23255
+ query: t.string().describe("检索关键词或自然语言问题"),
23256
+ topK: t.number().int().positive().optional().describe("期望召回数量(默认使用系统配置)")
23257
+ })
23258
+ });
23259
+ }
23260
+ function IT(e, n) {
23261
+ return r(async ({ source: e }) => {
23262
+ try {
23263
+ let t = await n(e), r = Array.isArray(t) ? t : [t];
23264
+ return r.length ? r.map((e, t) => `【${t + 1}】${e.source ? `来源:${e.source}\n` : ""}${e.content}`).join("\n\n") : `未加载到「${e}」。检查 source 是否正确。`;
23265
+ } catch (e) {
23266
+ return `加载出错:${e.message}。`;
23267
+ }
23268
+ }, {
23269
+ name: e,
23270
+ description: "按 source 加载指定文档(文档 id/URL/key);已知要查的具体文档用此工具精确加载。",
23271
+ schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
23272
+ });
23273
+ }
23274
+ function LT(e) {
23275
+ let { retriever: t, loader: n, useVfs: r = !0, id: i = "rag", description: a, topK: o = 5, searchToolName: s = "search_docs", loadToolName: c = "load_doc", maxToolRounds: l = 8, summarization: u, skills: d, extraTools: f } = e;
23276
+ if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
23277
+ let p = [];
23278
+ t && p.push(FT(s, t, o)), n && p.push(IT(c, n)), f && p.push(...f);
23279
+ let m = r ? [
23280
+ "vfs_grep",
23281
+ "vfs_read",
23282
+ "vfs_json_read"
23283
+ ] : void 0;
23284
+ return {
23285
+ id: i,
23286
+ description: a ?? "检索知识库(组件文档/UI 规范/业务规则),返回有依据的结构化结论。需要查阅文档才能回答或决定如何配置时委派",
23287
+ systemPrompt: MT,
23288
+ tools: p.length ? p : void 0,
23289
+ allowedTools: m,
23290
+ skills: d ?? [PT],
23291
+ maxToolRounds: l,
23292
+ ...u === void 0 ? {} : { summarization: u }
23293
+ };
23294
+ }
23295
+ //#endregion
23296
+ //#region src/core/sdk/htmlSubagent.ts
23297
+ function RT(e) {
23298
+ return `你是纯代码组件生成专家。可用工具:vfs_write / vfs_edit / vfs_rm(写/改/删代码到 vfs ${e}) / vfs_grep + vfs_read(读 vfs) / write + set(写 data 引用,writablePaths 限定) / read / write_todos + update_todo(规划)。
23299
+
23300
+ 代码存储约定(重要):
23301
+ - 代码正文写 vfs:${e}<name>.vue(如 ${e}hero.vue)
23302
+ - data 存引用:write({ patch:{ op:'set', jsonPath:'components.N', value:{ type:'custom', codeRef:'vfs://${e}<name>.vue', name, props } } })
23303
+ - 改代码:先 vfs_edit 改 vfs 文件(data 的 codeRef 引用不变,无需改 data)
23304
+
23305
+ 工作方式:
23306
+ 1. 中等任务(多组件 / 大段代码)先 write_todos 拆解:读现有结构 → 规划各组件 → 逐个生成 → read 确认;
23307
+ 2. 遵循 html-builder skill 规范(SFC 规范 / 安全底线 / 可访问性 / props 定义 / 组件库引用);
23308
+ 3. 小段代码 vfs_write 整体写;大段用 vfs_edit 增量拼(避免单次输出超限);
23309
+ 4. 生成后 read(vfs 文件 + data 引用)确认结构正确;只写 writablePaths 内 data + ${e} 下 vfs。`;
23310
+ }
23311
+ var zT = "# 纯代码组件生成规范\n\n## 代码存储约定(重要)\n- 代码正文写 vfs:html/<name>.vue(如 html/hero.vue)\n- data 存引用:{ type:'custom', codeRef:'vfs://html/<name>.vue', name, props }\n- 改代码:vfs_edit 改 vfs 文件(data 的 codeRef 引用不变)\n\n## 何时写代码组件\n- 组件库无对应类型(高度定制交互 / 一次性特效 / 特殊布局)→ 写 custom 代码组件\n- 组件库已有(按钮 / 卡片 / 列表)→ 用现有组件配置,不重造\n\n## Vue SFC 规范\n- Vue 3 <template> + <script setup>(组合式)\n- props 用 defineProps;事件用 defineEmits\n- 只渲染 UI,不做副作用(不发请求 / 不读写 storage)\n\n## props 定义\n- 代码组件 defineProps 接受外部 data 传入(集成方渲染时按 data 的 props 字段传)\n\n## 组件库引用\n- 代码内可 import 组件库组件(如 <Button>);所用依赖以集成方渲染层已注入为准,不重复造\n\n## 安全底线(必须)\n- 禁 eval / new Function / Function 构造器\n- 禁访问 window 敏感属性(document.cookie / apiKey / token)\n- 不引入外部脚本 / CDN\n\n## 可访问性 + 语义化\n- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦\n- 颜色对比达标;不只用颜色传达信息", BT = {
23312
+ name: "html-builder",
23313
+ description: "纯代码组件(custom Vue SFC)生成规范:代码存 vfs+data 引用 / SFC 规范 / 安全底线 / props / 组件库引用 / 可访问性",
23314
+ getContent: () => zT
23315
+ };
23316
+ function VT(e) {
23317
+ let { writablePaths: t, codeVfsPrefix: n = "html/", id: r = "html", description: i, planning: a = !0, summarization: o = !0, maxToolRounds: s = 12, temperature: c = .4, skills: l, extraTools: u } = e;
23318
+ if (!t?.length) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 必填(代码组件 data 区,如 [\"components\"])");
23319
+ let d = [];
23320
+ a && d.push(Iu());
23321
+ let f = u ?? [];
23322
+ return {
23323
+ id: r,
23324
+ description: i ?? "生成/修改纯代码组件(custom Vue SFC)。代码写 vfs,data 存引用;能规划(write_todos)+ 执行。需写代码组件或灵活定制时委派",
23325
+ systemPrompt: RT(n),
23326
+ writablePaths: t,
23327
+ allowedTools: [
23328
+ "vfs_write",
23329
+ "vfs_edit",
23330
+ "vfs_rm",
23331
+ "vfs_grep",
23332
+ "vfs_read"
23333
+ ],
23334
+ middleware: d.length ? d : void 0,
23335
+ summarization: o === !1 ? void 0 : o,
23336
+ temperature: c,
23337
+ skills: l ?? [BT],
23338
+ maxToolRounds: s,
23339
+ tools: f.length ? f : void 0
23340
+ };
23341
+ }
23342
+ //#endregion
23222
23343
  //#region src/core/index.ts
23223
- function MT(e) {
23344
+ function HT(e) {
23224
23345
  return qh(e, jT);
23225
23346
  }
23226
23347
  //#endregion
23227
- export { Cx as ApprovalBar, Ip as CAPABILITIES, zp as CONTEXT_PRESETS, AT as ChatDialog, fg as ChatHeader, Kx as ChatInput, Pb as CodePreview, Xf as CompressDecisionSchema, Px as ConflictBar, Wf as DEFAULT_SYSTEM_PROMPT, fT as DebugDrawer, vg as FocusBar, Ed as HUMAN_CONFIRM_TOOL_NAME, Rl as MIN_CONTEXT_WINDOW, Ib as MessageContent, ix as MessageList, Zb as MessageRow, fx as QueuedBar, Pf as STOP_WORDS, kT as SkillPanel, Wp as UNSAFE_KEYS, Ch as actionsToInspectInfo, Sh as actionsToTools, jl as agentError, yf as analyzeContext, rm as applyPatchToClone, im as applyPatchToLive, Al as asAgentError, Gf as buildDataPrompt, Kf as buildSystemPrompt, Xh as chatContextKey, nh as commitSetToBind, wf as connectMcp, x as constructLlmFromConfig, b as constructOpenLlmSync, Yh as copyText, hu as createAgent, Td as createApprovalMiddleware, Zh as createChatContext, MT as createChatSdk, Id as createCheckpointManager, Ld as createCheckpointMiddleware, cp as createConflictManager, bf as createContextInspectorMiddleware, ih as createDataOps, kd as createHumanConfirmMiddleware, Od as createHumanConfirmTool, kp as createMemoryBackend, vd as createMemoryMiddleware, y as createProxyLlm, id as createSandboxRunner, Rp as createSdkEvents, Bh as createSerialRunner, Np as createSessionStore, Ih as createSkillStore, Yd as createSubagentMiddleware, Qd as createSubagentsMiddleware, Ah as createUsageHintsMiddleware, $d as createVerifyMiddleware, dm as createVfs, jp as createWebStorageBackend, of as createWriteBackCheck, Xp as deepClone, Eh as defineDataToolset, od as defineSkill, qf as defineTool, Yp as deleteByPath, Zf as deriveTitle, Du as describeSchemaNode, au as detectGarbledToolCall, sm as diffObjects, uh as domToStructure, fh as domTools, Th as domToolsStatic, If as estimateMessageTokens, Lf as estimateRoundTokens, Bl as estimateTokens, C as extractReasoningDelta, Ku as extractSchemaHint, xf as extractText, S as extractTextDelta, w as extractUsage, oh as fetchDocTools, wh as fetchTools, th as filterByToolMode, Ou as formatConstraints, El as formatZodIssues, qp as getByPath, dh as getDomTool, hh as getEnvSummary, yu as getSchemaAtPath, gu as getSchemaTopKeys, Ul as getTraceMetrics, nm as hashValue, Rf as indexSummarize, vh as inspectEnvTool, yh as inspectTools, Qf as isChatModel, Xl as isContextLengthError, _u as isPathAllowed, xp as isQuotaError, Gp as isUnsafePath, Am as jpEval, Ol as jsonParseError, $p as limitDepth, Zp as maybeParseValue, Hl as offloadPassThroughChars, Vl as offloadThresholdChars, Vu as presets, xu as projectBySchema, bu as projectBySchemaDeep, Qp as projectFields, zf as recallRounds, ku as renderSchemaHint, Au as renderSchemaOverview, Mu as renderSchemaShallow, Lp as resolveCapabilities, Vp as resolveContextOptions, Fp as resolveDialogConfig, sp as resolveLlm, zl as resolveModelCaps, Pp as resolveStorage, om as restoreInPlace, am as restoreLive, kl as routeError, ad as runHostScript, Pm as runSandboxedScript, Kp as safeMerge, mh as safeSerialize, em as safeStringify, Mm as searchJson, Dh as selectBuiltinTools, Jp as setByPath, Bf as shouldTriggerCompression, Hu as systemPromptHelpers, Ff as tokenize, $ as toolError, vu as unwrapSchema, Jh as useChat, Qh as useChatContext, e as z, Dl as zodError };
23348
+ export { Cx as ApprovalBar, Ip as CAPABILITIES, zp as CONTEXT_PRESETS, AT as ChatDialog, fg as ChatHeader, Kx as ChatInput, Pb as CodePreview, Xf as CompressDecisionSchema, Px as ConflictBar, Wf as DEFAULT_SYSTEM_PROMPT, fT as DebugDrawer, vg as FocusBar, Ed as HUMAN_CONFIRM_TOOL_NAME, Rl as MIN_CONTEXT_WINDOW, Ib as MessageContent, ix as MessageList, Zb as MessageRow, fx as QueuedBar, qd as STOP_WORDS, kT as SkillPanel, Wp as UNSAFE_KEYS, Ch as actionsToInspectInfo, Sh as actionsToTools, jl as agentError, Rf as analyzeContext, rm as applyPatchToClone, im as applyPatchToLive, Al as asAgentError, Gf as buildDataPrompt, Kf as buildSystemPrompt, Xh as chatContextKey, nh as commitSetToBind, Uf as connectMcp, x as constructLlmFromConfig, b as constructOpenLlmSync, Yh as copyText, hu as createAgent, Td as createApprovalMiddleware, Zh as createChatContext, HT as createChatSdk, Id as createCheckpointManager, Ld as createCheckpointMiddleware, cp as createConflictManager, zf as createContextInspectorMiddleware, ih as createDataOps, VT as createHtmlSubagent, kd as createHumanConfirmMiddleware, Od as createHumanConfirmTool, kp as createMemoryBackend, vd as createMemoryMiddleware, y as createProxyLlm, LT as createRagSubagent, id as createSandboxRunner, Rp as createSdkEvents, Bh as createSerialRunner, Np as createSessionStore, Ih as createSkillStore, hf as createSubagentMiddleware, vf as createSubagentsMiddleware, Ah as createUsageHintsMiddleware, yf as createVerifyMiddleware, dm as createVfs, jp as createWebStorageBackend, Tf as createWriteBackCheck, Xp as deepClone, Eh as defineDataToolset, od as defineSkill, qf as defineTool, Yp as deleteByPath, Zf as deriveTitle, Du as describeSchemaNode, au as detectGarbledToolCall, sm as diffObjects, uh as domToStructure, fh as domTools, Th as domToolsStatic, Yd as estimateMessageTokens, Xd as estimateRoundTokens, Bl as estimateTokens, C as extractReasoningDelta, Ku as extractSchemaHint, Bf as extractText, S as extractTextDelta, w as extractUsage, oh as fetchDocTools, wh as fetchTools, th as filterByToolMode, Ou as formatConstraints, El as formatZodIssues, qp as getByPath, dh as getDomTool, hh as getEnvSummary, yu as getSchemaAtPath, gu as getSchemaTopKeys, Ul as getTraceMetrics, nm as hashValue, Zd as indexSummarize, vh as inspectEnvTool, yh as inspectTools, Qf as isChatModel, Xl as isContextLengthError, _u as isPathAllowed, xp as isQuotaError, Gp as isUnsafePath, Am as jpEval, Ol as jsonParseError, $p as limitDepth, Zp as maybeParseValue, Hl as offloadPassThroughChars, Vl as offloadThresholdChars, Vu as presets, xu as projectBySchema, bu as projectBySchemaDeep, Qp as projectFields, Qd as recallRounds, ku as renderSchemaHint, Au as renderSchemaOverview, Mu as renderSchemaShallow, Lp as resolveCapabilities, Vp as resolveContextOptions, Fp as resolveDialogConfig, sp as resolveLlm, zl as resolveModelCaps, Pp as resolveStorage, om as restoreInPlace, am as restoreLive, kl as routeError, ad as runHostScript, Pm as runSandboxedScript, Kp as safeMerge, mh as safeSerialize, em as safeStringify, Mm as searchJson, Dh as selectBuiltinTools, Jp as setByPath, $d as shouldTriggerCompression, Hu as systemPromptHelpers, Jd as tokenize, $ as toolError, vu as unwrapSchema, Jh as useChat, Qh as useChatContext, e as z, Dl as zodError };