page-agent-sdk 3.43.0 → 3.43.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.
@@ -205,42 +205,42 @@ process.env.NODE_ENV === "production" || Object.freeze([]);
205
205
  var C = () => {}, w = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), T = (e) => e.startsWith("onUpdate:"), E = Object.assign, D = (e, t) => {
206
206
  let n = e.indexOf(t);
207
207
  n > -1 && e.splice(n, 1);
208
- }, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray, j = (e) => L(e) === "[object Map]", M = (e) => L(e) === "[object Set]", N = (e) => typeof e == "function", P = (e) => typeof e == "string", ee = (e) => typeof e == "symbol", F = (e) => typeof e == "object" && !!e, te = (e) => (F(e) || N(e)) && N(e.then) && N(e.catch), I = Object.prototype.toString, L = (e) => I.call(e), ne = (e) => L(e).slice(8, -1), re = (e) => L(e) === "[object Object]", ie = (e) => P(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, ae = ((e) => {
208
+ }, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray, j = (e) => I(e) === "[object Map]", M = (e) => I(e) === "[object Set]", N = (e) => typeof e == "function", P = (e) => typeof e == "string", ee = (e) => typeof e == "symbol", F = (e) => typeof e == "object" && !!e, te = (e) => (F(e) || N(e)) && N(e.then) && N(e.catch), ne = Object.prototype.toString, I = (e) => ne.call(e), re = (e) => I(e).slice(8, -1), ie = (e) => I(e) === "[object Object]", ae = (e) => P(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, oe = ((e) => {
209
209
  let t = /* @__PURE__ */ Object.create(null);
210
210
  return ((n) => t[n] || (t[n] = e(n)));
211
- })((e) => e.charAt(0).toUpperCase() + e.slice(1)), R = (e, t) => !Object.is(e, t), oe = (e, t, n, r = !1) => {
211
+ })((e) => e.charAt(0).toUpperCase() + e.slice(1)), L = (e, t) => !Object.is(e, t), se = (e, t, n, r = !1) => {
212
212
  Object.defineProperty(e, t, {
213
213
  configurable: !0,
214
214
  enumerable: !1,
215
215
  writable: r,
216
216
  value: n
217
217
  });
218
- }, z, se = () => z ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
219
- function ce(e) {
218
+ }, R, ce = () => R ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
219
+ function le(e) {
220
220
  if (A(e)) {
221
221
  let t = {};
222
222
  for (let n = 0; n < e.length; n++) {
223
- let r = e[n], i = P(r) ? fe(r) : ce(r);
223
+ let r = e[n], i = P(r) ? pe(r) : le(r);
224
224
  if (i) for (let e in i) t[e] = i[e];
225
225
  }
226
226
  return t;
227
227
  } else if (P(e) || F(e)) return e;
228
228
  }
229
- var le = /;(?![^(]*\))/g, ue = /:([^]+)/, de = /\/\*[^]*?\*\//g;
230
- function fe(e) {
229
+ var ue = /;(?![^(]*\))/g, de = /:([^]+)/, fe = /\/\*[^]*?\*\//g;
230
+ function pe(e) {
231
231
  let t = {};
232
- return e.replace(de, "").split(le).forEach((e) => {
232
+ return e.replace(fe, "").split(ue).forEach((e) => {
233
233
  if (e) {
234
- let n = e.split(ue);
234
+ let n = e.split(de);
235
235
  n.length > 1 && (t[n[0].trim()] = n[1].trim());
236
236
  }
237
237
  }), t;
238
238
  }
239
- function pe(e) {
239
+ function me(e) {
240
240
  let t = "";
241
241
  if (P(e)) t = e;
242
242
  else if (A(e)) for (let n = 0; n < e.length; n++) {
243
- let r = pe(e[n]);
243
+ let r = me(e[n]);
244
244
  r && (t += r + " ");
245
245
  }
246
246
  else if (F(e)) for (let n in e) e[n] && (t += n + " ");
@@ -248,22 +248,22 @@ function pe(e) {
248
248
  }
249
249
  //#endregion
250
250
  //#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
251
- function B(e, ...t) {
251
+ function z(e, ...t) {
252
252
  console.warn(`[Vue warn] ${e}`, ...t);
253
253
  }
254
- var me;
255
- function V() {
256
- return me;
254
+ var he;
255
+ function B() {
256
+ return he;
257
257
  }
258
- var H, he = /* @__PURE__ */ new WeakSet(), ge = class {
258
+ var V, H = /* @__PURE__ */ new WeakSet(), ge = class {
259
259
  constructor(e) {
260
- this.fn = e, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0, me && (me.active ? me.effects.push(this) : this.flags &= -2);
260
+ this.fn = e, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0, he && (he.active ? he.effects.push(this) : this.flags &= -2);
261
261
  }
262
262
  pause() {
263
263
  this.flags |= 64;
264
264
  }
265
265
  resume() {
266
- this.flags & 64 && (this.flags &= -65, he.has(this) && (he.delete(this), this.trigger()));
266
+ this.flags & 64 && (this.flags &= -65, H.has(this) && (H.delete(this), this.trigger()));
267
267
  }
268
268
  notify() {
269
269
  this.flags & 2 && !(this.flags & 32) || this.flags & 8 || ye(this);
@@ -271,12 +271,12 @@ var H, he = /* @__PURE__ */ new WeakSet(), ge = class {
271
271
  run() {
272
272
  if (!(this.flags & 1)) return this.fn();
273
273
  this.flags |= 2, Me(this), Se(this);
274
- let e = H, t = Oe;
275
- H = this, Oe = !0;
274
+ let e = V, t = Oe;
275
+ V = this, Oe = !0;
276
276
  try {
277
277
  return this.fn();
278
278
  } finally {
279
- process.env.NODE_ENV !== "production" && H !== this && B("Active effect was not restored correctly - this is likely a Vue internal bug."), Ce(this), H = e, Oe = t, this.flags &= -3;
279
+ process.env.NODE_ENV !== "production" && V !== this && z("Active effect was not restored correctly - this is likely a Vue internal bug."), Ce(this), V = e, Oe = t, this.flags &= -3;
280
280
  }
281
281
  }
282
282
  stop() {
@@ -286,7 +286,7 @@ var H, he = /* @__PURE__ */ new WeakSet(), ge = class {
286
286
  }
287
287
  }
288
288
  trigger() {
289
- this.flags & 64 ? he.add(this) : this.scheduler ? this.scheduler() : this.runIfDirty();
289
+ this.flags & 64 ? H.add(this) : this.scheduler ? this.scheduler() : this.runIfDirty();
290
290
  }
291
291
  runIfDirty() {
292
292
  we(this) && this.run();
@@ -347,16 +347,16 @@ function we(e) {
347
347
  function Te(e) {
348
348
  if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === Ne) || (e.globalVersion = Ne, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !we(e)))) return;
349
349
  e.flags |= 2;
350
- let t = e.dep, n = H, r = Oe;
351
- H = e, Oe = !0;
350
+ let t = e.dep, n = V, r = Oe;
351
+ V = e, Oe = !0;
352
352
  try {
353
353
  Se(e);
354
354
  let n = e.fn(e._value);
355
- (t.version === 0 || R(n, e._value)) && (e.flags |= 128, e._value = n, t.version++);
355
+ (t.version === 0 || L(n, e._value)) && (e.flags |= 128, e._value = n, t.version++);
356
356
  } catch (e) {
357
357
  throw t.version++, e;
358
358
  } finally {
359
- H = n, Oe = r, Ce(e), e.flags &= -3;
359
+ V = n, Oe = r, Ce(e), e.flags &= -3;
360
360
  }
361
361
  }
362
362
  function Ee(e, t = !1) {
@@ -382,12 +382,12 @@ function je() {
382
382
  function Me(e) {
383
383
  let { cleanup: t } = e;
384
384
  if (e.cleanup = void 0, t) {
385
- let e = H;
386
- H = void 0;
385
+ let e = V;
386
+ V = void 0;
387
387
  try {
388
388
  t();
389
389
  } finally {
390
- H = e;
390
+ V = e;
391
391
  }
392
392
  }
393
393
  }
@@ -400,14 +400,14 @@ var Ne = 0, W = class {
400
400
  this.computed = e, this.version = 0, this.activeLink = void 0, this.subs = void 0, this.map = void 0, this.key = void 0, this.sc = 0, this.__v_skip = !0, process.env.NODE_ENV !== "production" && (this.subsHead = void 0);
401
401
  }
402
402
  track(e) {
403
- if (!H || !Oe || H === this.computed) return;
403
+ if (!V || !Oe || V === this.computed) return;
404
404
  let t = this.activeLink;
405
- if (t === void 0 || t.sub !== H) t = this.activeLink = new W(H, this), H.deps ? (t.prevDep = H.depsTail, H.depsTail.nextDep = t, H.depsTail = t) : H.deps = H.depsTail = t, Fe(t);
405
+ if (t === void 0 || t.sub !== V) t = this.activeLink = new W(V, this), V.deps ? (t.prevDep = V.depsTail, V.depsTail.nextDep = t, V.depsTail = t) : V.deps = V.depsTail = t, Fe(t);
406
406
  else if (t.version === -1 && (t.version = this.version, t.nextDep)) {
407
407
  let e = t.nextDep;
408
- e.prevDep = t.prevDep, t.prevDep && (t.prevDep.nextDep = e), t.prevDep = H.depsTail, t.nextDep = void 0, H.depsTail.nextDep = t, H.depsTail = t, H.deps === t && (H.deps = e);
408
+ e.prevDep = t.prevDep, t.prevDep && (t.prevDep.nextDep = e), t.prevDep = V.depsTail, t.nextDep = void 0, V.depsTail.nextDep = t, V.depsTail = t, V.deps === t && (V.deps = e);
409
409
  }
410
- return process.env.NODE_ENV !== "production" && H.onTrack && H.onTrack(E({ effect: H }, e)), t;
410
+ return process.env.NODE_ENV !== "production" && V.onTrack && V.onTrack(E({ effect: V }, e)), t;
411
411
  }
412
412
  trigger(e) {
413
413
  this.version++, Ne++, this.notify(e);
@@ -435,7 +435,7 @@ function Fe(e) {
435
435
  }
436
436
  var Ie = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Object iterate"), Re = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Map keys iterate"), ze = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Array iterate");
437
437
  function Be(e, t, n) {
438
- if (Oe && H) {
438
+ if (Oe && V) {
439
439
  let r = Ie.get(e);
440
440
  r || Ie.set(e, r = /* @__PURE__ */ new Map());
441
441
  let i = r.get(n);
@@ -464,7 +464,7 @@ function Ve(e, t, n, r, i, a) {
464
464
  };
465
465
  if (be(), t === "clear") o.forEach(s);
466
466
  else {
467
- let i = A(e), a = i && ie(n);
467
+ let i = A(e), a = i && ae(n);
468
468
  if (i && n === "length") {
469
469
  let e = Number(r);
470
470
  o.forEach((t, n) => {
@@ -648,7 +648,7 @@ var tt = class {
648
648
  let o = Reflect.get(e, t, /* @__PURE__ */ jt(e) ? e : n);
649
649
  if ((ee(t) ? $e.has(t) : Qe(t)) || (r || Be(e, "get", t), i)) return o;
650
650
  if (/* @__PURE__ */ jt(o)) {
651
- let e = a && ie(t) ? o : o.value;
651
+ let e = a && ae(t) ? o : o.value;
652
652
  return r && F(e) ? /* @__PURE__ */ St(e) : e;
653
653
  }
654
654
  return F(o) ? r ? /* @__PURE__ */ St(o) : /* @__PURE__ */ xt(o) : o;
@@ -658,13 +658,13 @@ var tt = class {
658
658
  super(!1, e);
659
659
  }
660
660
  set(e, t, n, r) {
661
- let i = e[t], a = A(e) && ie(t);
661
+ let i = e[t], a = A(e) && ae(t);
662
662
  if (!this._isShallow) {
663
663
  let r = /* @__PURE__ */ K(i);
664
- if (!/* @__PURE__ */ Et(n) && !/* @__PURE__ */ K(n) && (i = /* @__PURE__ */ q(i), n = /* @__PURE__ */ q(n)), !a && /* @__PURE__ */ jt(i) && !/* @__PURE__ */ jt(n)) return r ? (process.env.NODE_ENV !== "production" && B(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
664
+ if (!/* @__PURE__ */ Et(n) && !/* @__PURE__ */ K(n) && (i = /* @__PURE__ */ q(i), n = /* @__PURE__ */ q(n)), !a && /* @__PURE__ */ jt(i) && !/* @__PURE__ */ jt(n)) return r ? (process.env.NODE_ENV !== "production" && z(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
665
665
  }
666
666
  let o = a ? Number(t) < e.length : k(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ jt(e) ? e : r);
667
- return e === /* @__PURE__ */ q(r) && s && (o ? R(n, i) && Ve(e, "set", t, n, i) : Ve(e, "add", t, n)), s;
667
+ return e === /* @__PURE__ */ q(r) && s && (o ? L(n, i) && Ve(e, "set", t, n, i) : Ve(e, "add", t, n)), s;
668
668
  }
669
669
  deleteProperty(e, t) {
670
670
  let n = k(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
@@ -682,10 +682,10 @@ var tt = class {
682
682
  super(!0, e);
683
683
  }
684
684
  set(e, t) {
685
- return process.env.NODE_ENV !== "production" && B(`Set operation on key "${String(t)}" failed: target is readonly.`, e), !0;
685
+ return process.env.NODE_ENV !== "production" && z(`Set operation on key "${String(t)}" failed: target is readonly.`, e), !0;
686
686
  }
687
687
  deleteProperty(e, t) {
688
- return process.env.NODE_ENV !== "production" && B(`Delete operation on key "${String(t)}" failed: target is readonly.`, e), !0;
688
+ return process.env.NODE_ENV !== "production" && z(`Delete operation on key "${String(t)}" failed: target is readonly.`, e), !0;
689
689
  }
690
690
  }, it = /* @__PURE__ */ new nt(), at = /* @__PURE__ */ new rt(), ot = /* @__PURE__ */ new rt(!0), st = (e) => e, ct = (e) => Reflect.getPrototypeOf(e);
691
691
  function lt(e, t, n) {
@@ -707,7 +707,7 @@ function ut(e) {
707
707
  return function(...t) {
708
708
  if (process.env.NODE_ENV !== "production") {
709
709
  let n = t[0] ? `on key "${t[0]}" ` : "";
710
- B(`${ae(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ q(this));
710
+ z(`${oe(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ q(this));
711
711
  }
712
712
  return e === "delete" ? !1 : e === "clear" ? void 0 : this;
713
713
  };
@@ -716,7 +716,7 @@ function dt(e, t) {
716
716
  let n = {
717
717
  get(n) {
718
718
  let r = this.__v_raw, i = /* @__PURE__ */ q(r), a = /* @__PURE__ */ q(n);
719
- e || (R(n, a) && Be(i, "get", n), Be(i, "get", a));
719
+ e || (L(n, a) && Be(i, "get", n), Be(i, "get", a));
720
720
  let { has: o } = ct(i), s = t ? st : e ? At : kt;
721
721
  if (o.call(i, n)) return s(r.get(n));
722
722
  if (o.call(i, a)) return s(r.get(a));
@@ -728,7 +728,7 @@ function dt(e, t) {
728
728
  },
729
729
  has(t) {
730
730
  let n = this.__v_raw, r = /* @__PURE__ */ q(n), i = /* @__PURE__ */ q(t);
731
- return e || (R(t, i) && Be(r, "has", t), Be(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
731
+ return e || (L(t, i) && Be(r, "has", t), Be(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
732
732
  },
733
733
  forEach(n, r) {
734
734
  let i = this, a = i.__v_raw, o = /* @__PURE__ */ q(a), s = t ? st : e ? At : kt;
@@ -743,14 +743,14 @@ function dt(e, t) {
743
743
  } : {
744
744
  add(e) {
745
745
  let n = /* @__PURE__ */ q(this), r = ct(n), i = /* @__PURE__ */ q(e), a = !t && !/* @__PURE__ */ Et(e) && !/* @__PURE__ */ K(e) ? i : e;
746
- return r.has.call(n, a) || R(e, a) && r.has.call(n, e) || R(i, a) && r.has.call(n, i) || (n.add(a), Ve(n, "add", a, a)), this;
746
+ return r.has.call(n, a) || L(e, a) && r.has.call(n, e) || L(i, a) && r.has.call(n, i) || (n.add(a), Ve(n, "add", a, a)), this;
747
747
  },
748
748
  set(e, n) {
749
749
  !t && !/* @__PURE__ */ Et(n) && !/* @__PURE__ */ K(n) && (n = /* @__PURE__ */ q(n));
750
750
  let r = /* @__PURE__ */ q(this), { has: i, get: a } = ct(r), o = i.call(r, e);
751
751
  o ? process.env.NODE_ENV !== "production" && gt(r, i, e) : (e = /* @__PURE__ */ q(e), o = i.call(r, e));
752
752
  let s = a.call(r, e);
753
- return r.set(e, n), o ? R(n, s) && Ve(r, "set", e, n, s) : Ve(r, "add", e, n), this;
753
+ return r.set(e, n), o ? L(n, s) && Ve(r, "set", e, n, s) : Ve(r, "add", e, n), this;
754
754
  },
755
755
  delete(e) {
756
756
  let t = /* @__PURE__ */ q(this), { has: n, get: r } = ct(t), i = n.call(t, e);
@@ -779,8 +779,8 @@ var pt = { get: /* @__PURE__ */ ft(!1, !1) }, mt = { get: /* @__PURE__ */ ft(!0,
779
779
  function gt(e, t, n) {
780
780
  let r = /* @__PURE__ */ q(n);
781
781
  if (r !== n && t.call(e, r)) {
782
- let t = ne(e);
783
- B(`Reactive ${t} contains both the raw and reactive versions of the same object${t === "Map" ? " as keys" : ""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
782
+ let t = re(e);
783
+ z(`Reactive ${t} contains both the raw and reactive versions of the same object${t === "Map" ? " as keys" : ""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
784
784
  }
785
785
  }
786
786
  var _t = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), yt = /* @__PURE__ */ new WeakMap();
@@ -808,11 +808,11 @@ function Ct(e) {
808
808
  return wt(e, !0, ot, ht, yt);
809
809
  }
810
810
  function wt(e, t, n, r, i) {
811
- if (!F(e)) return process.env.NODE_ENV !== "production" && B(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
811
+ if (!F(e)) return process.env.NODE_ENV !== "production" && z(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
812
812
  if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
813
813
  let a = i.get(e);
814
814
  if (a) return a;
815
- let o = bt(ne(e));
815
+ let o = bt(re(e));
816
816
  if (o === 0) return e;
817
817
  let s = new Proxy(e, o === 2 ? r : n);
818
818
  return i.set(e, s), s;
@@ -839,7 +839,7 @@ function q(e) {
839
839
  return t ? /* @__PURE__ */ q(t) : e;
840
840
  }
841
841
  function Ot(e) {
842
- return !k(e, "__v_skip") && Object.isExtensible(e) && oe(e, "__v_skip", !0), e;
842
+ return !k(e, "__v_skip") && Object.isExtensible(e) && se(e, "__v_skip", !0), e;
843
843
  }
844
844
  var kt = (e) => F(e) ? /* @__PURE__ */ xt(e) : e, At = (e) => F(e) ? /* @__PURE__ */ St(e) : e;
845
845
  // @__NO_SIDE_EFFECTS__
@@ -870,7 +870,7 @@ var Ft = class {
870
870
  }
871
871
  set value(e) {
872
872
  let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ Et(e) || /* @__PURE__ */ K(e);
873
- e = n ? e : /* @__PURE__ */ q(e), R(e, t) && (this._rawValue = e, this._value = n ? e : kt(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
873
+ e = n ? e : /* @__PURE__ */ q(e), L(e, t) && (this._rawValue = e, this._value = n ? e : kt(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
874
874
  target: this,
875
875
  type: "set",
876
876
  key: "value",
@@ -905,7 +905,7 @@ var Bt = class {
905
905
  this.fn = e, this.setter = t, this._value = void 0, this.dep = new Pe(this), this.__v_isRef = !0, this.deps = void 0, this.depsTail = void 0, this.flags = 16, this.globalVersion = Ne - 1, this.next = void 0, this.effect = this, this.__v_isReadonly = !t, this.isSSR = n;
906
906
  }
907
907
  notify() {
908
- if (this.flags |= 16, !(this.flags & 8) && H !== this) return ye(this, !0), !0;
908
+ if (this.flags |= 16, !(this.flags & 8) && V !== this) return ye(this, !0), !0;
909
909
  process.env.NODE_ENV;
910
910
  }
911
911
  get value() {
@@ -917,7 +917,7 @@ var Bt = class {
917
917
  return Te(this), e && (e.version = this.dep.version), this._value;
918
918
  }
919
919
  set value(e) {
920
- this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" && B("Write operation failed: computed value is readonly");
920
+ this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" && z("Write operation failed: computed value is readonly");
921
921
  }
922
922
  };
923
923
  // @__NO_SIDE_EFFECTS__
@@ -932,11 +932,11 @@ function Wt(e, t = !1, n = Ut) {
932
932
  if (n) {
933
933
  let t = Ht.get(n);
934
934
  t || Ht.set(n, t = []), t.push(e);
935
- } else process.env.NODE_ENV !== "production" && !t && B("onWatcherCleanup() was called when there was no active watcher to associate with.");
935
+ } else process.env.NODE_ENV !== "production" && !t && z("onWatcherCleanup() was called when there was no active watcher to associate with.");
936
936
  }
937
937
  function Gt(e, t, n = S) {
938
938
  let { immediate: r, deep: i, once: a, scheduler: o, augmentJob: s, call: c } = n, l = (e) => {
939
- (n.onWarn || B)("Invalid watch source: ", e, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
939
+ (n.onWarn || z)("Invalid watch source: ", e, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
940
940
  }, u = (e) => i ? e : /* @__PURE__ */ Et(e) || i === !1 || i === 0 ? Kt(e, 1) : Kt(e), d, f, p, m, h = !1, g = !1;
941
941
  if (/* @__PURE__ */ jt(e) ? (f = () => e.value, h = /* @__PURE__ */ Et(e)) : /* @__PURE__ */ Tt(e) ? (f = () => u(e), h = !0) : A(e) ? (g = !0, h = e.some((e) => /* @__PURE__ */ Tt(e) || /* @__PURE__ */ Et(e)), f = () => e.map((e) => {
942
942
  if (/* @__PURE__ */ jt(e)) return e.value;
@@ -963,7 +963,7 @@ function Gt(e, t, n = S) {
963
963
  let e = f, t = i === !0 ? Infinity : i;
964
964
  f = () => Kt(e(), t);
965
965
  }
966
- let _ = V(), v = () => {
966
+ let _ = B(), v = () => {
967
967
  d.stop(), _ && _.active && D(_.effects, d);
968
968
  };
969
969
  if (a && t) {
@@ -976,7 +976,7 @@ function Gt(e, t, n = S) {
976
976
  let y = g ? Array(e.length).fill(J) : J, b = (e) => {
977
977
  if (!(!(d.flags & 1) || !d.dirty && !e)) if (t) {
978
978
  let n = d.run();
979
- if (e || i || h || (g ? n.some((e, t) => R(e, y[t])) : R(n, y))) {
979
+ if (e || i || h || (g ? n.some((e, t) => L(e, y[t])) : L(n, y))) {
980
980
  p && p();
981
981
  let e = Ut;
982
982
  Ut = d;
@@ -1009,7 +1009,7 @@ function Kt(e, t = Infinity, n) {
1009
1009
  else if (M(e) || j(e)) e.forEach((e) => {
1010
1010
  Kt(e, t, n);
1011
1011
  });
1012
- else if (re(e)) {
1012
+ else if (ie(e)) {
1013
1013
  for (let r in e) Kt(e[r], t, n);
1014
1014
  for (let r of Object.getOwnPropertySymbols(e)) Object.prototype.propertyIsEnumerable.call(e, r) && Kt(e[r], t, n);
1015
1015
  }
@@ -1234,7 +1234,7 @@ function Tn(e, t) {
1234
1234
  return e.set(t, n + 1), !1;
1235
1235
  }
1236
1236
  var En = /* @__PURE__ */ new Map();
1237
- process.env.NODE_ENV !== "production" && (se().__VUE_HMR_RUNTIME__ = {
1237
+ process.env.NODE_ENV !== "production" && (ce().__VUE_HMR_RUNTIME__ = {
1238
1238
  createRecord: Nn(On),
1239
1239
  rerender: Nn(An),
1240
1240
  reload: Nn(jn)
@@ -1353,7 +1353,7 @@ var Gn = (e) => e.__isTeleport;
1353
1353
  function Kn(e, t) {
1354
1354
  e.shapeFlag & 6 && e.component ? (e.transition = t, Kn(e.component.subTree, t)) : e.shapeFlag & 128 ? (e.ssContent.transition = t.clone(e.ssContent), e.ssFallback.transition = t.clone(e.ssFallback)) : e.transition = t;
1355
1355
  }
1356
- se().requestIdleCallback, se().cancelIdleCallback;
1356
+ ce().requestIdleCallback, ce().cancelIdleCallback;
1357
1357
  var qn = /* @__PURE__ */ Symbol.for("v-ndc"), Jn = (e) => e ? Lr(e) ? zr(e) : Jn(e.parent) : null, Yn = /* @__PURE__ */ E(/* @__PURE__ */ Object.create(null), {
1358
1358
  $: (e) => e,
1359
1359
  $el: (e) => e.vnode.el,
@@ -1546,7 +1546,7 @@ function Er(e, t = null, n = null, r = 0, i = null, a = !1) {
1546
1546
  if (Wr(e) && (e = e.__vccOpts), t) {
1547
1547
  t = Dr(t);
1548
1548
  let { class: e, style: n } = t;
1549
- e && !P(e) && (t.class = pe(e)), F(n) && (/* @__PURE__ */ Dt(n) && !A(n) && (n = E({}, n)), t.style = ce(n));
1549
+ e && !P(e) && (t.class = me(e)), F(n) && (/* @__PURE__ */ Dt(n) && !A(n) && (n = E({}, n)), t.style = le(n));
1550
1550
  }
1551
1551
  let o = P(e) ? 1 : mr(e) ? 128 : Gn(e) ? 64 : F(e) ? 4 : N(e) ? 2 : 0;
1552
1552
  return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ Dt(e) && (e = /* @__PURE__ */ q(e), Zt("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), wr(e, t, n, r, i, o, a, !0);
@@ -1620,8 +1620,8 @@ function Mr(...e) {
1620
1620
  let t = {};
1621
1621
  for (let n = 0; n < e.length; n++) {
1622
1622
  let r = e[n];
1623
- for (let e in r) if (e === "class") t.class !== r.class && (t.class = pe([t.class, r.class]));
1624
- else if (e === "style") t.style = ce([t.style, r.style]);
1623
+ for (let e in r) if (e === "class") t.class !== r.class && (t.class = me([t.class, r.class]));
1624
+ else if (e === "style") t.style = le([t.style, r.style]);
1625
1625
  else if (w(e)) {
1626
1626
  let n = t[e], i = r[e];
1627
1627
  i && n !== i && !(A(n) && n.includes(i)) ? t[e] = n ? [].concat(n, i) : i : i == null && n == null && !T(e) && (t[e] = i);
@@ -1631,7 +1631,7 @@ function Mr(...e) {
1631
1631
  }
1632
1632
  var Nr = null, Pr = () => Nr || Ln, Fr;
1633
1633
  {
1634
- let e = se(), t = (t, n) => {
1634
+ let e = ce(), t = (t, n) => {
1635
1635
  let r;
1636
1636
  return (r = e[t]) || (r = e[t] = []), r.push(n), (e) => {
1637
1637
  r.length > 1 ? r.forEach((t) => t(e)) : r[0](e);
@@ -2518,7 +2518,7 @@ function Ki(e = [], n = {}) {
2518
2518
  name: "todos",
2519
2519
  tools: [r(async ({ todos: e }) => {
2520
2520
  if (!s) s = !0, c = 1;
2521
- else if (c > l) return `规划阶段已达上限(${l} 轮,现在已是第 ${c} 版计划)。停止调研/修订,基于当前清单开始执行(用 write 落地;advanced 模式亦可用 set_data/edit_data)。当前清单:\n${i.map((e, t) => `${t + 1}. #${e.id} [${e.status}] ${e.content}`).join("\n") || "(空)"}`;
2521
+ else if (c++, c > l) return `规划阶段已达上限(${l} 次修订,现在已是第 ${c} 版计划)。停止修订,基于当前清单开始执行(用 write 落地;advanced 模式亦可用 set_data/edit_data)。当前清单:\n${i.map((e, t) => `${t + 1}. #${e.id} [${e.status}] ${e.content}`).join("\n") || "(空)"}`;
2522
2522
  return i = Hi(e), `已更新任务清单:${i.length} 项\n${i.map((e, t) => `${t + 1}. #${e.id} [${e.status}] ${e.content}`).join("\n")}`;
2523
2523
  }, {
2524
2524
  name: "write_todos",
@@ -2537,7 +2537,7 @@ function Ki(e = [], n = {}) {
2537
2537
  evidence: t.string().optional().describe("完成证据(可选)")
2538
2538
  })).describe("完整的任务清单(整表替换)") })
2539
2539
  }), r(async ({ id: e, content: t, status: n, parentId: r, deps: a, criteria: o, evidence: u }) => {
2540
- if (s && c > l) return `规划阶段已达上限(${l} 轮,现在已是第 ${c} 版计划)。停止修订,基于当前清单开始执行。当前任务 id:${i.map((e) => e.id).join(", ") || "(空)"}`;
2540
+ if (s && c > l && (t !== void 0 || r !== void 0 || a !== void 0 || o !== void 0)) return `规划阶段已达上限(${l} 次修订,现在已是第 ${c} 版计划)。停止修订计划内容(改任务文本/层级/依赖);status/evidence 进度跟踪可继续,或基于当前清单开始执行。当前任务 id:${i.map((e) => e.id).join(", ") || "(空)"}`;
2541
2541
  let d = i.findIndex((t) => t.id === e);
2542
2542
  return d < 0 ? `错误:找不到 id="${e}" 的任务(TODO_NOT_FOUND)。当前任务 id:${i.map((e) => e.id).join(", ") || "(空)"}` : (t !== void 0 && (i[d].content = t), n !== void 0 && (i[d].status = n), r !== void 0 && (i[d].parentId = r), a !== void 0 && (i[d].deps = a), o !== void 0 && (i[d].criteria = o), u !== void 0 && (i[d].evidence = u), `已更新任务 #${e}:[${i[d].status}] ${i[d].content}`);
2543
2543
  }, {
@@ -2558,7 +2558,7 @@ function Ki(e = [], n = {}) {
2558
2558
  })
2559
2559
  })],
2560
2560
  beforeAgent: () => ({ todos: i }),
2561
- beforeModel: () => (a = 0, o = 0, s && c++, { todos: i }),
2561
+ beforeModel: () => (a = 0, o = 0, { todos: i }),
2562
2562
  augmentPrompt: () => Ui(i),
2563
2563
  wrapToolCall: async (e, t) => {
2564
2564
  if (e.name === "write_todos" || e.name === "update_todo") {
@@ -3431,33 +3431,33 @@ function go(e) {
3431
3431
  return Array.isArray(r) && r.length && r[0] && typeof r[0].jsonPath == "string" ? r[0].jsonPath : "";
3432
3432
  }
3433
3433
  function _o(e) {
3434
- let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, extraBody: d, extraConfig: m, systemPrompt: h, tools: y = [], middleware: x = [], maxToolRounds: S, maxIterations: C, maxRetries: w = 2, retryDelayMs: T = 500, stallMs: E = Ii, streamMaxMs: D = Ri, maxParallelTools: O = 1, maxVerifyAttempts: k = 0, roundTokenBudget: A = 0, onLog: j, onSpan: M, onTrace: N, onLlmChange: P, imageContentFormat: ee = "openai", staleReadInvalidation: F = !0, debug: te = !1 } = e, I = S ?? co;
3435
- (!Number.isFinite(I) || I < 1) && (console.warn(`[page-agent-sdk] maxToolRounds=${I} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`), I = 1), O > 1 && console.warn(`[page-agent-sdk] maxParallelTools=${O}:并发工具下 dataOps 写工具不互锁(同轮并发两写都在 await handleConflict 让出前取旧基线 → 均通过乐观锁 → 后写覆盖前写,无 VERSION_CONFLICT 回灌);并发写不互锁,如需冲突保护保持 maxParallelTools=1 并声明 conflictWatchFields`);
3436
- let L = wi({
3434
+ let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, extraBody: d, extraConfig: m, systemPrompt: h, tools: y = [], middleware: x = [], maxToolRounds: S, maxIterations: C, maxRetries: w = 2, retryDelayMs: T = 500, stallMs: E = Ii, streamMaxMs: D = Ri, maxParallelTools: O = 1, maxVerifyAttempts: k = 0, roundTokenBudget: A = 0, onLog: j, onSpan: M, onTrace: N, onLlmChange: P, imageContentFormat: ee = "openai", staleReadInvalidation: F = !0, debug: te = !1 } = e, ne = S ?? co;
3435
+ (!Number.isFinite(ne) || ne < 1) && (console.warn(`[page-agent-sdk] maxToolRounds=${ne} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`), ne = 1), O > 1 && console.warn(`[page-agent-sdk] maxParallelTools=${O}:并发工具下 dataOps 写工具不互锁(同轮并发两写都在 await handleConflict 让出前取旧基线 → 均通过乐观锁 → 后写覆盖前写,无 VERSION_CONFLICT 回灌);并发写不互锁,如需冲突保护保持 maxParallelTools=1 并声明 conflictWatchFields`);
3436
+ let I = wi({
3437
3437
  model: c,
3438
3438
  contextWindow: e.contextWindow,
3439
3439
  maxOutputTokens: e.maxOutputTokens,
3440
3440
  vision: e.vision
3441
- }), ne = u ?? L.maxOutputTokens, re = Ti(L.contextWindow), ie = Ei(L.contextWindow);
3442
- function ae(e) {
3443
- L = e, re = Ti(L.contextWindow), ie = Ei(L.contextWindow);
3441
+ }), re = u ?? I.maxOutputTokens, ie = Ti(I.contextWindow), ae = Ei(I.contextWindow);
3442
+ function oe(e) {
3443
+ I = e, ie = Ti(I.contextWindow), ae = Ei(I.contextWindow);
3444
3444
  }
3445
- let R = /* @__PURE__ */ Nt([]), oe = 0;
3446
- function z(e, t) {
3445
+ let L = /* @__PURE__ */ Nt([]), se = 0;
3446
+ function R(e, t) {
3447
3447
  let n = {
3448
3448
  timestamp: Date.now(),
3449
3449
  type: e,
3450
3450
  data: t
3451
3451
  };
3452
- R.value.push(n), R.value.length > lo && R.value.splice(0, R.value.length - lo), It(R), j?.(n), te && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
3452
+ L.value.push(n), L.value.length > lo && L.value.splice(0, L.value.length - lo), It(L), j?.(n), te && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
3453
3453
  }
3454
- let se = (e) => {
3455
- R.value.push(e), R.value.length > lo && R.value.splice(0, R.value.length - lo), It(R);
3456
- }, ce = /* @__PURE__ */ Nt([]), le = 0, ue = !!M || !!N;
3457
- function de(e, t, n, r = {}) {
3458
- if (!ue) return null;
3454
+ let ce = (e) => {
3455
+ L.value.push(e), L.value.length > lo && L.value.splice(0, L.value.length - lo), It(L);
3456
+ }, le = /* @__PURE__ */ Nt([]), ue = 0, de = !!M || !!N;
3457
+ function fe(e, t, n, r = {}) {
3458
+ if (!de) return null;
3459
3459
  let i = {
3460
- id: `span-${++le}`,
3460
+ id: `span-${++ue}`,
3461
3461
  parentId: e,
3462
3462
  name: n,
3463
3463
  type: t,
@@ -3465,35 +3465,38 @@ function _o(e) {
3465
3465
  status: "ok",
3466
3466
  attributes: r
3467
3467
  };
3468
- return ce.value.push(i), ce.value.length > lo && ce.value.splice(0, ce.value.length - lo), It(ce), i;
3468
+ return le.value.push(i), le.value.length > lo && le.value.splice(0, le.value.length - lo), It(le), i;
3469
3469
  }
3470
- function fe(e, t = "ok", n) {
3471
- !e || !ue || (e.endTs = Date.now(), e.durationMs = e.endTs - e.startTs, e.status = t, n && Object.assign(e.attributes, n), It(ce), M?.(e));
3470
+ function pe(e, t = "ok", n) {
3471
+ !e || !de || (e.endTs = Date.now(), e.durationMs = e.endTs - e.startTs, e.status = t, n && Object.assign(e.attributes, n), It(le), M?.(e));
3472
3472
  }
3473
- let pe = [...x.flatMap((e) => e.tools || []), ...y], B = e.llm ?? new n({
3473
+ let me = [...x.flatMap((e) => e.tools || []), ...y], z = e.llm ?? new n({
3474
3474
  apiKey: t,
3475
3475
  model: c,
3476
3476
  temperature: l,
3477
- maxTokens: ne,
3477
+ maxTokens: re,
3478
3478
  configuration: {
3479
3479
  ...r ? { baseURL: p(r) } : {},
3480
3480
  fetch: f,
3481
3481
  ...m
3482
3482
  },
3483
3483
  ...d ? { modelKwargs: d } : {}
3484
- }), me = pe.length > 0 ? B.bindTools?.(pe) ?? B : B;
3484
+ }), he = me.length > 0 ? z.bindTools?.(me) ?? z : z, B = () => {
3485
+ let e = z;
3486
+ return (typeof e.model == "string" && e.model ? e.model : typeof e.modelName == "string" && e.modelName ? e.modelName : "") || c;
3487
+ };
3485
3488
  function V() {
3486
- me = pe.length > 0 ? B.bindTools?.(pe) ?? B : B;
3489
+ he = me.length > 0 ? z.bindTools?.(me) ?? z : z;
3487
3490
  }
3488
3491
  let H = Oi();
3489
3492
  e.__pgIsSubagent && (H.__pgIsSubagent = !0);
3490
- let he = .25, ge = /* @__PURE__ */ new Set([
3493
+ let ge = .25, _e = /* @__PURE__ */ new Set([
3491
3494
  "mission",
3492
3495
  "workingMemory",
3493
3496
  "intentGuard",
3494
3497
  "resumeNotice"
3495
3498
  ]);
3496
- function _e() {
3499
+ function U() {
3497
3500
  let e = h || "你是一个智能助手。", t = [];
3498
3501
  for (let e of x) if (e.augmentPrompt) {
3499
3502
  let n = e.augmentPrompt(H);
@@ -3501,40 +3504,40 @@ function _o(e) {
3501
3504
  name: e.name,
3502
3505
  text: n,
3503
3506
  tokens: X(n),
3504
- pin: ge.has(e.name)
3507
+ pin: _e.has(e.name)
3505
3508
  });
3506
3509
  }
3507
- let n = Math.max(2e3, Math.round(L.contextWindow * he)), r = X(e) + t.reduce((e, t) => e + t.tokens, 0);
3510
+ let n = Math.max(2e3, Math.round(I.contextWindow * ge)), r = X(e) + t.reduce((e, t) => e + t.tokens, 0);
3508
3511
  if (r > n) {
3509
3512
  let e = r, i = [];
3510
3513
  for (let e of t.filter((e) => !e.pin).sort((e, t) => t.tokens - e.tokens)) {
3511
3514
  if (r <= n) break;
3512
3515
  i.push(`${e.name}(${e.tokens})`), r -= e.tokens, e.text = "";
3513
3516
  }
3514
- i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${L.contextWindow} 的 ${he * 100}%),drop 非核心段:${i.join(", ")}(保 base/mission/workingMemory)`);
3517
+ i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${I.contextWindow} 的 ${ge * 100}%),drop 非核心段:${i.join(", ")}(保 base/mission/workingMemory)`);
3515
3518
  }
3516
3519
  return [e, ...t.filter((e) => e.text).map((e) => e.text)].join("\n\n");
3517
3520
  }
3518
- function U(e) {
3519
- let t = [new o(_e())];
3521
+ function ve(e) {
3522
+ let t = [new o(U())];
3520
3523
  for (let n of e) if (n.role === "user") {
3521
- let e = L.vision && n.images?.length ? si(n.content, n.images, ee) : null;
3524
+ let e = I.vision && n.images?.length ? si(n.content, n.images, ee) : null;
3522
3525
  e ? t.push(new a({ content: e })) : n.images?.some((e) => e.description) ? t.push(new a(ci(n.content, n.images))) : t.push(new a(n.content));
3523
3526
  } else n.role === "assistant" ? t.push(new i(n.content)) : n.role === "system" && t.push(new o(n.content));
3524
3527
  return t;
3525
3528
  }
3526
- function ve(e, t) {
3527
- let n = e[0] && xe(e[0]) === "system" ? e.slice(1) : e.slice(), r = _e();
3529
+ function ye(e, t) {
3530
+ let n = e[0] && Se(e[0]) === "system" ? e.slice(1) : e.slice(), r = U();
3528
3531
  return [new o(t ? `${r}\n\n${t}` : r), ...n];
3529
3532
  }
3530
- async function ye(e, t, n, r) {
3531
- let a = r ?? me, o = {
3533
+ async function be(e, t, n, r) {
3534
+ let a = r ?? he, o = {
3532
3535
  signal: n,
3533
3536
  maxRetries: w,
3534
3537
  baseDelayMs: T,
3535
3538
  onRetry: ({ attempt: e, error: t, waitMs: n }) => {
3536
3539
  let r = t?.message ?? String(t);
3537
- z("error", {
3540
+ R("error", {
3538
3541
  stage: "model_retry",
3539
3542
  attempt: e,
3540
3543
  waitMs: n,
@@ -3566,14 +3569,14 @@ function _o(e) {
3566
3569
  };
3567
3570
  if (Bi(a) && !e._ctxRetry) {
3568
3571
  e._ctxRetry = !0;
3569
- let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = Se(e.messages, Math.round(L.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
3570
- return z("error", {
3572
+ let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = Ce(e.messages, Math.round(I.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
3573
+ return R("error", {
3571
3574
  stage: "context_overflow_retry",
3572
3575
  at: "launch",
3573
3576
  beforeTokens: a,
3574
3577
  afterTokens: s,
3575
- window: L.contextWindow
3576
- }), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`), ye({
3578
+ window: I.contextWindow
3579
+ }), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`), be({
3577
3580
  ...e,
3578
3581
  messages: o
3579
3582
  }, t, n, r);
@@ -3602,7 +3605,7 @@ function _o(e) {
3602
3605
  });
3603
3606
  }
3604
3607
  } catch (a) {
3605
- if (a instanceof Pi) throw s.abort(), z("error", {
3608
+ if (a instanceof Pi) throw s.abort(), R("error", {
3606
3609
  stage: a instanceof Fi ? "stream_max_duration" : "stream_stalled",
3607
3610
  waitedMs: a.waitedMs,
3608
3611
  stallMs: E,
@@ -3616,13 +3619,13 @@ function _o(e) {
3616
3619
  };
3617
3620
  if (Bi(a) && l === null && u === "" && !e._ctxRetry) {
3618
3621
  e._ctxRetry = !0;
3619
- let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = Se(e.messages, Math.round(L.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
3620
- return z("error", {
3622
+ let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = Ce(e.messages, Math.round(I.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
3623
+ return R("error", {
3621
3624
  stage: "context_overflow_retry",
3622
3625
  beforeTokens: a,
3623
3626
  afterTokens: s,
3624
- window: L.contextWindow
3625
- }), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${L.contextWindow})`), ye({
3627
+ window: I.contextWindow
3628
+ }), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${I.contextWindow})`), be({
3626
3629
  ...e,
3627
3630
  messages: o
3628
3631
  }, t, n, r);
@@ -3630,11 +3633,11 @@ function _o(e) {
3630
3633
  throw a;
3631
3634
  }
3632
3635
  if (l === null) {
3633
- if (!e._emptyRetry) return e._emptyRetry = !0, z("error", {
3636
+ if (!e._emptyRetry) return e._emptyRetry = !0, R("error", {
3634
3637
  stage: "empty_llm_response_retry",
3635
3638
  hint: "流正常结束但零 chunk(网关 200+错误体形态),自动重试 1 次"
3636
- }), ye(e, t, n, r);
3637
- throw z("error", {
3639
+ }), be(e, t, n, r);
3640
+ throw R("error", {
3638
3641
  stage: "empty_llm_response",
3639
3642
  retried: !0,
3640
3643
  hint: "重试后仍零 chunk,抛 EmptyLLMResponseError 显式报错"
@@ -3647,8 +3650,8 @@ function _o(e) {
3647
3650
  content: u
3648
3651
  };
3649
3652
  }
3650
- async function be(e) {
3651
- let t = pe.find((t) => t.name === e.name);
3653
+ async function xe(e) {
3654
+ let t = me.find((t) => t.name === e.name);
3652
3655
  if (!t) return {
3653
3656
  content: `工具 "${e.name}" 不存在`,
3654
3657
  status: "error"
@@ -3657,13 +3660,13 @@ function _o(e) {
3657
3660
  let n = {
3658
3661
  __pgDataScope: "",
3659
3662
  ...e.callConfig ?? {}
3660
- }, r = await t.invoke(e.args, { configurable: n }), i = typeof r == "string" ? r : JSON.stringify(r), a = pe.some((e) => e.name === "vfs_read");
3663
+ }, r = await t.invoke(e.args, { configurable: n }), i = typeof r == "string" ? r : JSON.stringify(r), a = me.some((e) => e.name === "vfs_read");
3661
3664
  return i = yi(i, {
3662
3665
  files: e.state.files,
3663
3666
  vfsAvailable: !!e.state.files && a,
3664
3667
  toolName: e.name,
3665
- threshold: re,
3666
- passThroughChars: ie
3668
+ threshold: ie,
3669
+ passThroughChars: ae
3667
3670
  }).content, {
3668
3671
  content: i,
3669
3672
  status: "done"
@@ -3675,15 +3678,15 @@ function _o(e) {
3675
3678
  };
3676
3679
  }
3677
3680
  }
3678
- function xe(e) {
3681
+ function Se(e) {
3679
3682
  return e instanceof a ? "human" : e instanceof i ? "ai" : e instanceof o ? "system" : e instanceof s ? "tool" : "unknown";
3680
3683
  }
3681
- function Se(e, t) {
3684
+ function Ce(e, t) {
3682
3685
  return fo(e, t);
3683
3686
  }
3684
- function Ce(e) {
3687
+ function we(e) {
3685
3688
  return !te && !j ? [] : e.map((e) => {
3686
- let t = xe(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
3689
+ let t = Se(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
3687
3690
  r && (n.content = r.length > uo ? r.slice(0, uo) + `…(截断 ${r.length - uo} 字符)` : r);
3688
3691
  let i = e.tool_calls;
3689
3692
  Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
@@ -3698,20 +3701,20 @@ function _o(e) {
3698
3701
  return a && (n.tool_call_id = a), n;
3699
3702
  });
3700
3703
  }
3701
- async function we(t, n, r) {
3702
- ce.value = [], le = 0, H = Oi(), e.__pgIsSubagent && (H.__pgIsSubagent = !0), H.messages = t, H = await Ua(x, H);
3704
+ async function Te(t, n, r) {
3705
+ le.value = [], ue = 0, H = Oi(), e.__pgIsSubagent && (H.__pgIsSubagent = !0), H.messages = t, H = await Ua(x, H);
3703
3706
  let i = t;
3704
3707
  for (let e of x) if (e.compressInput) {
3705
- let t = de(void 0, "compression", `compress:${e.name}`, {}), n = await e.compressInput(i);
3708
+ let t = fe(void 0, "compression", `compress:${e.name}`, {}), n = await e.compressInput(i);
3706
3709
  i = Array.isArray(n) ? n : n.messages, n && !Array.isArray(n) && n.stats ? (H = {
3707
3710
  ...H,
3708
3711
  lastCompression: n.stats
3709
- }, fe(t, "ok", { stats: n.stats })) : fe(t);
3712
+ }, pe(t, "ok", { stats: n.stats })) : pe(t);
3710
3713
  }
3711
3714
  {
3712
- let e = X(h || "你是一个智能助手。"), t = Math.max(2e3, Math.round(L.contextWindow * he));
3715
+ let e = X(h || "你是一个智能助手。"), t = Math.max(2e3, Math.round(I.contextWindow * ge));
3713
3716
  if (e > t) {
3714
- let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${L.contextWindow} 的 ${he * 100}%);请缩减 systemPrompt 或换更大窗口模型`;
3717
+ let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${I.contextWindow} 的 ${ge * 100}%);请缩减 systemPrompt 或换更大窗口模型`;
3715
3718
  return console.error(r), n({
3716
3719
  type: "error",
3717
3720
  message: r,
@@ -3723,15 +3726,15 @@ function _o(e) {
3723
3726
  }), "";
3724
3727
  }
3725
3728
  }
3726
- let l = U(i);
3727
- z("context", {
3728
- model: c,
3729
- tools: pe.map((e) => e.name),
3729
+ let c = ve(i);
3730
+ R("context", {
3731
+ model: B(),
3732
+ tools: me.map((e) => e.name),
3730
3733
  middleware: x.map((e) => e.name)
3731
3734
  });
3732
- let u = Ja(x, (e) => ye(e, n, r)), d = Ya(x, be), f = {
3735
+ let l = Ja(x, (e) => be(e, n, r)), u = Ya(x, xe), d = {
3733
3736
  rounds: 0,
3734
- maxToolRounds: I,
3737
+ maxToolRounds: ne,
3735
3738
  invokeUsage: {
3736
3739
  prompt_tokens: 0,
3737
3740
  completion_tokens: 0,
@@ -3740,31 +3743,31 @@ function _o(e) {
3740
3743
  writeFailures: {},
3741
3744
  budgetHinted: !1
3742
3745
  };
3743
- H.loopProgress = f;
3744
- let p = {
3746
+ H.loopProgress = d;
3747
+ let f = {
3745
3748
  counts: {},
3746
3749
  writePaths: [],
3747
3750
  failures: 0
3748
- }, m = 0, g = (e) => {
3749
- let t = pe.find((t) => t.name === e);
3751
+ }, p = 0, m = (e) => {
3752
+ let t = me.find((t) => t.name === e);
3750
3753
  return t && "writeCapable" in t ? typeof t.writeCapable == "function" || t.writeCapable === !0 : ho.has(e);
3751
- }, _ = 0, y = 0, S = po(I, C), w = null, T = 0, E = !1, D = 0, j = 0;
3754
+ }, g = 0, _ = 0, y = po(ne, C), S = null, w = 0, T = !1, E = 0, D = 0;
3752
3755
  try {
3753
- for (; (_ < I || E) && y < S && (y++, !r?.aborted);) {
3754
- if (A > 0 && f.invokeUsage.total_tokens > A) {
3755
- let e = `本轮 token 预算(约 ${A})已用尽:任务在 ${_} 轮工具调用后中断,已完成的部分均保留。可继续对话,指定下一步(如「继续完成」/「只改 X」/「提高预算重试」)。`;
3756
- return z("error", {
3756
+ for (; (g < ne || T) && _ < y && (_++, !r?.aborted);) {
3757
+ if (A > 0 && d.invokeUsage.total_tokens > A) {
3758
+ let e = `本轮 token 预算(约 ${A})已用尽:任务在 ${g} 轮工具调用后中断,已完成的部分均保留。可继续对话,指定下一步(如「继续完成」/「只改 X」/「提高预算重试」)。`;
3759
+ return R("error", {
3757
3760
  stage: "round_token_budget_exceeded",
3758
- used: f.invokeUsage.total_tokens,
3761
+ used: d.invokeUsage.total_tokens,
3759
3762
  budget: A,
3760
- rounds: _
3763
+ rounds: g
3761
3764
  }), n({
3762
3765
  type: "error",
3763
3766
  message: e,
3764
3767
  severity: "observable",
3765
3768
  code: "ROUND_TOKEN_BUDGET_EXCEEDED",
3766
3769
  context: {
3767
- used: f.invokeUsage.total_tokens,
3770
+ used: d.invokeUsage.total_tokens,
3768
3771
  budget: A
3769
3772
  }
3770
3773
  }), n({
@@ -3772,36 +3775,36 @@ function _o(e) {
3772
3775
  content: e
3773
3776
  }), e;
3774
3777
  }
3775
- let e = de(void 0, "round", `round ${y}`, { round: y })?.id;
3778
+ let e = fe(void 0, "round", `round ${_}`, { round: _ })?.id;
3776
3779
  n({
3777
3780
  type: "round_start",
3778
- round: y
3781
+ round: _
3779
3782
  }), H = Wa(x, {
3780
- messages: l,
3783
+ messages: c,
3781
3784
  state: H
3782
- }), l = ve(l, mo(_, I)), l = Se(l, Math.round(L.contextWindow * .6));
3783
- let t = de(e, "model", c, {
3784
- round: _ + 1,
3785
- tools: pe.map((e) => e.name)
3785
+ }), c = ye(c, mo(g, ne)), c = Ce(c, Math.round(I.contextWindow * .6));
3786
+ let t = fe(e, "model", B(), {
3787
+ round: g + 1,
3788
+ tools: me.map((e) => e.name)
3786
3789
  });
3787
- z("llm_request", {
3788
- round: _ + 1,
3789
- model: c,
3790
- tools: pe.map((e) => e.name),
3791
- messages: Ce(l)
3790
+ R("llm_request", {
3791
+ round: g + 1,
3792
+ model: B(),
3793
+ tools: me.map((e) => e.name),
3794
+ messages: we(c)
3792
3795
  });
3793
- let i = await u({
3794
- messages: l,
3796
+ let i = await l({
3797
+ messages: c,
3795
3798
  state: H
3796
3799
  });
3797
- l.push(i.message), z("llm_response", {
3798
- round: _ + 1,
3800
+ c.push(i.message), R("llm_response", {
3801
+ round: g + 1,
3799
3802
  content: i.content,
3800
3803
  toolCalls: i.toolCalls
3801
- }), fe(t, i.aborted ? "timeout" : "ok", { usage: v(i.message) });
3804
+ }), pe(t, i.aborted ? "timeout" : "ok", { usage: v(i.message) });
3802
3805
  {
3803
3806
  let e = b(i.message);
3804
- e && (f.invokeUsage.prompt_tokens += e.prompt_tokens ?? 0, f.invokeUsage.completion_tokens += e.completion_tokens ?? 0, f.invokeUsage.total_tokens += e.total_tokens ?? 0);
3807
+ e && (d.invokeUsage.prompt_tokens += e.prompt_tokens ?? 0, d.invokeUsage.completion_tokens += e.completion_tokens ?? 0, d.invokeUsage.total_tokens += e.total_tokens ?? 0);
3805
3808
  }
3806
3809
  if (H = Ga(x, i, H), i.aborted) return n({
3807
3810
  type: "done",
@@ -3817,23 +3820,23 @@ function _o(e) {
3817
3820
  name: e.name,
3818
3821
  args: e.args,
3819
3822
  type: "tool_call"
3820
- }))), z("middleware", {
3823
+ }))), R("middleware", {
3821
3824
  stage: "dsml_parsed",
3822
3825
  count: t.length,
3823
3826
  names: t.map((e) => e.name)
3824
3827
  });
3825
3828
  } else {
3826
- if (e && T < 2) {
3827
- T += 1, E = !0, z("middleware", {
3829
+ if (e && w < 2) {
3830
+ w += 1, T = !0, R("middleware", {
3828
3831
  stage: "format_retry",
3829
- attempt: T,
3832
+ attempt: w,
3830
3833
  content: i.content.slice(0, 200)
3831
- }), l.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签/DSML 标记,如 <|tool_calls|>、<||DSML||>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。"));
3834
+ }), c.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签/DSML 标记,如 <|tool_calls|>、<||DSML||>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。"));
3832
3835
  continue;
3833
3836
  }
3834
- e && (z("error", {
3837
+ e && (R("error", {
3835
3838
  stage: "garbled_exhausted",
3836
- retries: T,
3839
+ retries: w,
3837
3840
  content: i.content.slice(0, 200)
3838
3841
  }), n({
3839
3842
  type: "error",
@@ -3842,65 +3845,65 @@ function _o(e) {
3842
3845
  code: "GARBLED_TOOL_CALL_EXHAUSTED",
3843
3846
  context: { content: i.content.slice(0, 200) }
3844
3847
  }));
3845
- let t = _ > 0 ? eo(i.content) : ro(i.content);
3846
- if (!e && D < 2 && t) {
3847
- D += 1, E = !0, z("middleware", {
3848
+ let t = g > 0 ? eo(i.content) : ro(i.content);
3849
+ if (!e && E < 2 && t) {
3850
+ E += 1, T = !0, R("middleware", {
3848
3851
  stage: "transitional_retry",
3849
- attempt: D,
3850
- rounds: _,
3852
+ attempt: E,
3853
+ rounds: g,
3851
3854
  content: i.content.slice(0, 160)
3852
- }), l.push(new a("⚠️ 你刚才只输出了计划/行动叙述(如「我先看看」「开始添加」),没有发起任何工具调用,因此什么都未执行。请立即用标准 function calling 调用所需工具把任务做完,全部完成后再给出总结回复。"));
3855
+ }), c.push(new a("⚠️ 你刚才只输出了计划/行动叙述(如「我先看看」「开始添加」),没有发起任何工具调用,因此什么都未执行。请立即用标准 function calling 调用所需工具把任务做完,全部完成后再给出总结回复。"));
3853
3856
  continue;
3854
3857
  }
3855
- if (!e && _ > 0 && j < 2 && Wi(H.todos, i.content)) {
3856
- j += 1, E = !0, z("middleware", {
3858
+ if (!e && g > 0 && D < 2 && Wi(H.todos, i.content)) {
3859
+ D += 1, T = !0, R("middleware", {
3857
3860
  stage: "completion_gate",
3858
- attempt: j,
3861
+ attempt: D,
3859
3862
  pending: H.todos.filter((e) => e.status !== "completed").map((e) => e.id),
3860
3863
  content: i.content.slice(0, 160)
3861
- }), l.push(new a(Gi(H.todos)));
3864
+ }), c.push(new a(Gi(H.todos)));
3862
3865
  continue;
3863
3866
  }
3864
3867
  let r = (() => {
3865
- for (let e = l.length - 1; e >= 0; e--) {
3866
- let t = l[e];
3868
+ for (let e = c.length - 1; e >= 0; e--) {
3869
+ let t = c[e];
3867
3870
  if (t._getType?.() === "human") return String(t.content ?? "");
3868
3871
  }
3869
3872
  return "";
3870
3873
  })();
3871
- if (!e && !H.__pgIsSubagent && m < 2 && Qi(p, g) && Zi(r) && !na(i.content) && !/[??]\s*$/.test(i.content.trim())) {
3872
- m += 1, E = !0, z("middleware", {
3874
+ if (!e && !H.__pgIsSubagent && p < 2 && Qi(f, m) && Zi(r) && !na(i.content) && !/[??]\s*$/.test(i.content.trim())) {
3875
+ p += 1, T = !0, R("middleware", {
3873
3876
  stage: "zero_tool_gate",
3874
- attempt: m,
3875
- factSheet: $i(p, H.todos, g),
3877
+ attempt: p,
3878
+ factSheet: $i(f, H.todos, m),
3876
3879
  content: i.content.slice(0, 160)
3877
- }), l.push(new a(ta($i(p, H.todos, g))));
3880
+ }), c.push(new a(ta($i(f, H.todos, m))));
3878
3881
  continue;
3879
3882
  }
3880
- if (!e && !H.__pgIsSubagent && m < 2 && sa(p) && aa(r) && oa(i.content)) {
3881
- m += 1, E = !0, z("middleware", {
3883
+ if (!e && !H.__pgIsSubagent && p < 2 && sa(f) && aa(r) && oa(i.content)) {
3884
+ p += 1, T = !0, R("middleware", {
3882
3885
  stage: "status_query_gate",
3883
- attempt: m,
3884
- factSheet: $i(p, H.todos, g),
3886
+ attempt: p,
3887
+ factSheet: $i(f, H.todos, m),
3885
3888
  content: i.content.slice(0, 160)
3886
- }), l.push(new a(ca($i(p, H.todos, g))));
3889
+ }), c.push(new a(ca($i(f, H.todos, m))));
3887
3890
  continue;
3888
3891
  }
3889
- if (!e && !H.__pgIsSubagent && m >= 2 && Qi(p, g) && Zi(r) && n({
3892
+ if (!e && !H.__pgIsSubagent && p >= 2 && Qi(f, m) && Zi(r) && n({
3890
3893
  type: "error",
3891
3894
  message: "操作指令经 2 次回灌后仍以零工具纯文本收尾(疑似谎报完成),已放行;最终回复可能不实",
3892
3895
  severity: "observable",
3893
3896
  code: "ZERO_TOOL_GATE_EXHAUSTED",
3894
- context: { factSheet: $i(p, H.todos, g) }
3897
+ context: { factSheet: $i(f, H.todos, m) }
3895
3898
  }), !e && k > 0 && H.verifyAttempts < k) {
3896
3899
  let e = await qa(x, {
3897
- messages: l,
3900
+ messages: c,
3898
3901
  state: H,
3899
3902
  response: i,
3900
- log: (e, t) => z(e, t)
3903
+ log: (e, t) => R(e, t)
3901
3904
  });
3902
3905
  if (e) {
3903
- w = i.content, H.verifyAttempts += 1, l.push(new a(`⚠️ 验证未通过,请修正:${e}`)), z("middleware", {
3906
+ S = i.content, H.verifyAttempts += 1, c.push(new a(`⚠️ 验证未通过,请修正:${e}`)), R("middleware", {
3904
3907
  stage: "verify_retry",
3905
3908
  attempt: H.verifyAttempts,
3906
3909
  feedback: e
@@ -3908,7 +3911,7 @@ function _o(e) {
3908
3911
  continue;
3909
3912
  }
3910
3913
  }
3911
- E = !1;
3914
+ T = !1;
3912
3915
  let o = i.content;
3913
3916
  if (e) {
3914
3917
  let e = Za(o);
@@ -3920,7 +3923,7 @@ function _o(e) {
3920
3923
  }), o;
3921
3924
  }
3922
3925
  }
3923
- E = !1;
3926
+ T = !1;
3924
3927
  let o = i.toolCalls.map((e) => {
3925
3928
  let t = e.id || `call_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
3926
3929
  return {
@@ -3933,26 +3936,26 @@ function _o(e) {
3933
3936
  state: H,
3934
3937
  signal: r,
3935
3938
  emit: n,
3936
- logSink: se
3939
+ logSink: ce
3937
3940
  }
3938
3941
  };
3939
3942
  }), h = await bi(o, O, async (t) => {
3940
3943
  if (r?.aborted) return;
3941
- let i = de(e, "tool", t.call.name, { name: t.call.name }), a = Date.now();
3944
+ let i = fe(e, "tool", t.call.name, { name: t.call.name }), a = Date.now();
3942
3945
  n({
3943
3946
  type: "tool_call",
3944
3947
  name: t.call.name,
3945
3948
  args: t.call.args,
3946
3949
  id: t.id
3947
- }), z("tool_call", {
3948
- round: _ + 1,
3950
+ }), R("tool_call", {
3951
+ round: g + 1,
3949
3952
  name: t.call.name,
3950
3953
  args: t.call.args,
3951
3954
  id: t.id
3952
3955
  });
3953
3956
  let o;
3954
3957
  try {
3955
- o = await d(t.ctx);
3958
+ o = await u(t.ctx);
3956
3959
  } catch (e) {
3957
3960
  if (ki(e, r)) throw e;
3958
3961
  o = {
@@ -3968,17 +3971,17 @@ function _o(e) {
3968
3971
  status: o.status,
3969
3972
  durationMs: s,
3970
3973
  id: t.id
3971
- }), z("tool_result", {
3972
- round: _ + 1,
3974
+ }), R("tool_result", {
3975
+ round: g + 1,
3973
3976
  name: t.call.name,
3974
3977
  result: o.content,
3975
3978
  status: o.status,
3976
3979
  durationMs: s
3977
- }), fe(i, o.status === "error" ? "error" : "ok", { resultSnippet: String(o.content).slice(0, 100) }), o;
3980
+ }), pe(i, o.status === "error" ? "error" : "ok", { resultSnippet: String(o.content).slice(0, 100) }), o;
3978
3981
  }, r);
3979
3982
  for (let e = 0; e < o.length; e++) {
3980
3983
  let t = h[e];
3981
- t && l.push(new s({
3984
+ t && c.push(new s({
3982
3985
  tool_call_id: o[e].id,
3983
3986
  content: t.content
3984
3987
  }));
@@ -3987,80 +3990,80 @@ function _o(e) {
3987
3990
  let t = h[e];
3988
3991
  if (!t || !ho.has(o[e].call.name)) continue;
3989
3992
  let n = go(o[e].call.args);
3990
- t.status === "error" ? f.writeFailures[n] = (f.writeFailures[n] ?? 0) + 1 : delete f.writeFailures[n];
3993
+ t.status === "error" ? d.writeFailures[n] = (d.writeFailures[n] ?? 0) + 1 : delete d.writeFailures[n];
3991
3994
  }
3992
- let S = [];
3995
+ let y = [];
3993
3996
  for (let e = 0; e < o.length; e++) {
3994
3997
  let t = h[e];
3995
3998
  if (!t) continue;
3996
3999
  let n = o[e].call.name;
3997
- if (p.counts[n] = (p.counts[n] ?? 0) + 1, t.status === "error" && (p.failures += 1), la(pe.find((e) => e.name === n), o[e].call.args, t)) {
4000
+ if (f.counts[n] = (f.counts[n] ?? 0) + 1, t.status === "error" && (f.failures += 1), la(me.find((e) => e.name === n), o[e].call.args, t)) {
3998
4001
  let t = go(o[e].call.args);
3999
- p.writePaths.push(t || "(整体)"), S.push({
4002
+ f.writePaths.push(t || "(整体)"), y.push({
4000
4003
  name: n,
4001
4004
  args: o[e].call.args,
4002
4005
  callIndex: e
4003
4006
  });
4004
4007
  }
4005
4008
  }
4006
- if (F && S.length) {
4007
- let e = Va(l, S, {
4008
- round: _ + 1,
4009
+ if (F && y.length) {
4010
+ let e = Va(c, y, {
4011
+ round: g + 1,
4009
4012
  maxParallelTools: O
4010
4013
  });
4011
- e.invalidatedCount > 0 && (l = e.messages, oe += e.invalidatedCount, z("middleware", {
4014
+ e.invalidatedCount > 0 && (c = e.messages, se += e.invalidatedCount, R("middleware", {
4012
4015
  stage: "stale_read_invalidated",
4013
- round: _ + 1,
4014
- writtenPaths: S.map((e) => go(e.args) || "(整体)"),
4016
+ round: g + 1,
4017
+ writtenPaths: y.map((e) => go(e.args) || "(整体)"),
4015
4018
  invalidatedCount: e.invalidatedCount
4016
4019
  }));
4017
4020
  }
4018
4021
  if (r?.aborted) break;
4019
- _++, f.rounds = _;
4022
+ g++, d.rounds = g;
4020
4023
  }
4021
4024
  if (r?.aborted) return n({
4022
4025
  type: "done",
4023
4026
  content: ""
4024
4027
  }), "";
4025
- let e = `\n\n(提示:工具调用次数已达上限(${I} 轮 / ${S} 次迭代),以上为基于已完成操作的阶段性结果,任务可能未完成。回复「继续」或告诉我下一步重点,即可接着做。)`;
4026
- if (z("error", {
4028
+ let e = `\n\n(提示:工具调用次数已达上限(${ne} 轮 / ${y} 次迭代),以上为基于已完成操作的阶段性结果,任务可能未完成。回复「继续」或告诉我下一步重点,即可接着做。)`;
4029
+ if (R("error", {
4027
4030
  stage: "react_call_limit_exceeded",
4028
- rounds: _,
4029
- maxToolRounds: I,
4030
- iterations: y,
4031
- maxIterations: S
4031
+ rounds: g,
4032
+ maxToolRounds: ne,
4033
+ iterations: _,
4034
+ maxIterations: y
4032
4035
  }), n({
4033
4036
  type: "error",
4034
- message: `ReAct 循环达到调用上限(rounds=${_}/${I},iterations=${y}/${S}),已强制收口,可回复「继续」。`,
4037
+ message: `ReAct 循环达到调用上限(rounds=${g}/${ne},iterations=${_}/${y}),已强制收口,可回复「继续」。`,
4035
4038
  severity: "observable",
4036
4039
  code: "REACT_CALL_LIMIT_EXCEEDED",
4037
4040
  context: {
4038
- rounds: _,
4039
- maxToolRounds: I,
4040
- iterations: y,
4041
- maxIterations: S
4041
+ rounds: g,
4042
+ maxToolRounds: ne,
4043
+ iterations: _,
4044
+ maxIterations: y
4042
4045
  }
4043
- }), w != null) {
4044
- let t = w + e;
4046
+ }), S != null) {
4047
+ let t = S + e;
4045
4048
  return n({
4046
4049
  type: "done",
4047
4050
  content: t
4048
4051
  }), t;
4049
4052
  }
4050
- let t = l[l.length - 1];
4051
- if (t && xe(t) === "tool") {
4052
- let t = l[0] && xe(l[0]) === "system" ? l.slice(1) : l.slice(), i = [new o(_e() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...t];
4053
- z("llm_request", {
4053
+ let t = c[c.length - 1];
4054
+ if (t && Se(t) === "tool") {
4055
+ let t = c[0] && Se(c[0]) === "system" ? c.slice(1) : c.slice(), i = [new o(U() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...t];
4056
+ R("llm_request", {
4054
4057
  round: "wrap_up",
4055
- model: c,
4058
+ model: B(),
4056
4059
  tools: [],
4057
- messages: Ce(i)
4060
+ messages: we(i)
4058
4061
  });
4059
- let a = await Ja(x, (e) => ye(e, n, r, B))({
4062
+ let a = await Ja(x, (e) => be(e, n, r, z))({
4060
4063
  messages: i,
4061
4064
  state: H
4062
4065
  });
4063
- if (H = Ga(x, a, H), z("llm_response", {
4066
+ if (H = Ga(x, a, H), R("llm_response", {
4064
4067
  round: "wrap_up",
4065
4068
  content: a.content
4066
4069
  }), a.aborted) return n({
@@ -4071,7 +4074,7 @@ function _o(e) {
4071
4074
  let t = a.content;
4072
4075
  if (Xa(t)) {
4073
4076
  let e = Za(t);
4074
- z("error", {
4077
+ R("error", {
4075
4078
  stage: "garbled_wrapup",
4076
4079
  content: t.slice(0, 200)
4077
4080
  }), n({
@@ -4100,40 +4103,40 @@ function _o(e) {
4100
4103
  let t = Qr(e, "observable");
4101
4104
  console.warn("[Agent] afterAgent 清理出错(observable,已忽略):", t.message);
4102
4105
  }
4103
- if (ue && N) try {
4104
- N(ce.value, Di(ce.value));
4106
+ if (de && N) try {
4107
+ N(le.value, Di(le.value));
4105
4108
  } catch {}
4106
4109
  }
4107
4110
  }
4108
- async function Te(e, t, n) {
4111
+ async function Ee(e, t, n) {
4109
4112
  let r = "";
4110
- return await we(e, (e) => {
4113
+ return await Te(e, (e) => {
4111
4114
  e.type === "done" && (r = e.content), n?.(e);
4112
4115
  }, t), r;
4113
4116
  }
4114
- function Ee(e) {
4115
- pe = [...x.flatMap((e) => e.tools || []), ...e], V();
4116
- }
4117
4117
  function De(e) {
4118
- B = e, V(), P?.(e);
4118
+ me = [...x.flatMap((e) => e.tools || []), ...e], V();
4119
+ }
4120
+ function Oe(e) {
4121
+ z = e, V(), P?.(e);
4119
4122
  }
4120
4123
  return {
4121
- invoke: Te,
4122
- stream: we,
4124
+ invoke: Ee,
4125
+ stream: Te,
4123
4126
  getState: () => H,
4124
4127
  get allTools() {
4125
- return pe;
4128
+ return me;
4126
4129
  },
4127
- getStaleReadsInvalidated: () => oe,
4130
+ getStaleReadsInvalidated: () => se,
4128
4131
  resetStaleReadsInvalidated: () => {
4129
- oe = 0;
4132
+ se = 0;
4130
4133
  },
4131
- setTools: Ee,
4132
- setLlm: De,
4133
- setModelCaps: ae,
4134
- debugLogs: R,
4135
- spans: ce,
4136
- getEffectiveSystemPrompt: () => _e()
4134
+ setTools: De,
4135
+ setLlm: Oe,
4136
+ setModelCaps: oe,
4137
+ debugLogs: L,
4138
+ spans: le,
4139
+ getEffectiveSystemPrompt: () => U()
4137
4140
  };
4138
4141
  }
4139
4142
  //#endregion
@@ -8462,7 +8465,7 @@ function Mu(e, n = {}) {
8462
8465
  schema: t.object({ value: t.unknown().describe("JSON 对象(推荐直传,如 {title:\"x\"}),或 JSON 字符串;需符合 schema") })
8463
8466
  });
8464
8467
  P(te);
8465
- let I = r(async (e, t) => {
8468
+ let ne = r(async (e, t) => {
8466
8469
  let n = v(t), r = e.op ?? e.patch?.op, i = e.jsonPath ?? e.patch?.jsonPath, c = e.value ?? e.patch?.value;
8467
8470
  if (!r) return Y({
8468
8471
  code: "MISSING_VALUE",
@@ -8538,8 +8541,8 @@ function Mu(e, n = {}) {
8538
8541
  }).optional().describe("容错:误传 write 的 {patch:{op,jsonPath,value}} 形式时从此取值(顶层优先)。正常用顶层 op/jsonPath/value 即可")
8539
8542
  })
8540
8543
  });
8541
- P(I);
8542
- let L = r(async ({ jsonPath: e }, t) => {
8544
+ P(ne);
8545
+ let I = r(async ({ jsonPath: e }, t) => {
8543
8546
  let n = v(t);
8544
8547
  if (!e) return Y({
8545
8548
  code: "MISSING_VALUE",
@@ -8578,8 +8581,8 @@ function Mu(e, n = {}) {
8578
8581
  description: "删除主数据的某个子路径(jsonPath)。主数据整体不可删(用 set_data 整体替换)。",
8579
8582
  schema: t.object({ jsonPath: t.string().describe("要删除的子路径(相对主数据根,如 components.0)") })
8580
8583
  });
8581
- P(L);
8582
- let ne = r(async ({ id: e }, t) => {
8584
+ P(I);
8585
+ let re = r(async ({ id: e }, t) => {
8583
8586
  let n = v(t);
8584
8587
  if (!m.length) return Y({
8585
8588
  code: "NO_SNAPSHOT",
@@ -8608,8 +8611,8 @@ function Mu(e, n = {}) {
8608
8611
  description: "把主数据回退到某个快照(就地还原,保留响应式)。不传 id 则回退最近一次(快速回退)。可用 history_data({list:true}) 查看快照列表。",
8609
8612
  schema: t.object({ id: t.number().int().optional().describe("指定快照序号;不传则回退最近一次") })
8610
8613
  });
8611
- P(ne);
8612
- let re = r(async ({ id: e, jsonPath: t, list: n }) => {
8614
+ P(re);
8615
+ let ie = r(async ({ id: e, jsonPath: t, list: n }) => {
8613
8616
  if (n) {
8614
8617
  if (!m.length) return "无快照。set/edit/delete 会自动存快照。";
8615
8618
  let e = m.map((e) => {
@@ -8654,7 +8657,7 @@ function Mu(e, n = {}) {
8654
8657
  jsonPath: t.string().optional().describe("只看快照的某子路径(相对主数据根);不传则整个快照"),
8655
8658
  list: t.boolean().optional().describe("true 则列出快照时间线元信息(序号/操作/标签/时间/大小);不传则查看单条快照内容")
8656
8659
  })
8657
- }), ie = r(async ({ expr: e, limit: t }, n) => {
8660
+ }), ae = r(async ({ expr: e, limit: t }, n) => {
8658
8661
  let r = v(n);
8659
8662
  if (typeof s != "object" || !s) return Y({
8660
8663
  code: "NOT_OBJECT",
@@ -8681,7 +8684,7 @@ function Mu(e, n = {}) {
8681
8684
  expr: t.string().describe("JSONPath 表达式,如 $.components[?(@.type==\"card\" && @.price<100)] 或 $..title(递归找所有 title)"),
8682
8685
  limit: t.number().int().min(1).max(200).optional().describe("返回结果上限,默认 50")
8683
8686
  })
8684
- }), ae = r(async ({ query: e, mode: t, fuzzyThreshold: n, matchKey: r, limit: i }) => {
8687
+ }), oe = r(async ({ query: e, mode: t, fuzzyThreshold: n, matchKey: r, limit: i }) => {
8685
8688
  if (s == null) return Y({
8686
8689
  code: "EMPTY",
8687
8690
  message: "主数据为空,无可搜索内容"
@@ -8719,7 +8722,7 @@ function Mu(e, n = {}) {
8719
8722
  matchKey: t.boolean().optional().describe("是否同时匹配 key 名,默认 true"),
8720
8723
  limit: t.number().int().min(1).max(200).optional().describe("返回上限,默认 50")
8721
8724
  })
8722
- }), R = r(async ({ script: e, mode: t, jsonPath: n }, r) => {
8725
+ }), L = r(async ({ script: e, mode: t, jsonPath: n }, r) => {
8723
8726
  let i = v(r);
8724
8727
  if (e.length > 8e3) return Y({
8725
8728
  code: "SCRIPT_TOO_LARGE",
@@ -8847,8 +8850,8 @@ function Mu(e, n = {}) {
8847
8850
  jsonPath: t.string().optional().describe("子树模式:仅对 jsonPath 指向的子树执行(降低大 JSON 成本);transform 时返回值作为该子树新值")
8848
8851
  })
8849
8852
  });
8850
- P(R, (e) => e?.mode === "transform");
8851
- let oe = r(async ({ jsonPath: e, jsonPaths: t, fields: n, depth: r, offset: i, limit: a }, u) => {
8853
+ P(L, (e) => e?.mode === "transform");
8854
+ let se = r(async ({ jsonPath: e, jsonPaths: t, fields: n, depth: r, offset: i, limit: a }, u) => {
8852
8855
  let d = v(u), f = w();
8853
8856
  if (t && t.length) {
8854
8857
  let e = !1, i = t.map((t) => {
@@ -8912,7 +8915,7 @@ function Mu(e, n = {}) {
8912
8915
  offset: t.number().int().min(0).optional().describe("数组分页起始偏移(仅当读取目标是数组时生效,默认 0),配合 limit 分页读大数组"),
8913
8916
  limit: t.number().int().min(1).max(200).optional().describe("数组分页每页条数(默认 50,上限 200;仅数组时生效),返回切片 + total/hasMore")
8914
8917
  })
8915
- }), z = r(async ({ value: e, patch: t, patches: n, del: r, dryRun: i }, c) => {
8918
+ }), R = r(async ({ value: e, patch: t, patches: n, del: r, dryRun: i }, c) => {
8916
8919
  let u = v(c), d = "set";
8917
8920
  r ? d = "delete" : (n && n.length || t) && (d = "edit");
8918
8921
  let f = t?.value === void 0 ? e : t.value, g = C ? y(u) : void 0;
@@ -9051,8 +9054,8 @@ function Mu(e, n = {}) {
9051
9054
  dryRun: t.boolean().optional().describe("预检模式:走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘、不入快照,返回预览。四意图(value/patch/patches/del)均支持;乐观锁冲突照常检测(返回 VERSION_CONFLICT 不挂起)")
9052
9055
  })
9053
9056
  });
9054
- P(z);
9055
- let se = r(async ({ jsonPath: e }) => {
9057
+ P(R);
9058
+ let ce = r(async ({ jsonPath: e }) => {
9056
9059
  let t = e || "", n = t ? bo(o, t) : o;
9057
9060
  return n ? `schema${t ? ` @ ${t}` : ""} = ${$(Bo(n))}` : Y({
9058
9061
  code: "PATH_DENIED",
@@ -9063,7 +9066,7 @@ function Mu(e, n = {}) {
9063
9066
  name: "schema_data",
9064
9067
  description: "查看主数据(或子路径)的字段约束:类型/min/max/enum/必填/默认值/嵌套 shape。写前查约束,避免写错重试。不传 jsonPath 查根;传子路径(如 components.0)查该位置约束。",
9065
9068
  schema: t.object({ jsonPath: t.string().optional().describe("要查约束的子路径;不传查根 schema") })
9066
- }), ce = r(async ({ snapshotId: e, against: t }) => {
9069
+ }), le = r(async ({ snapshotId: e, against: t }) => {
9067
9070
  let n = t != null, r, i;
9068
9071
  if (n) {
9069
9072
  let e = t;
@@ -9095,7 +9098,7 @@ function Mu(e, n = {}) {
9095
9098
  snapshotId: t.number().int().optional().describe("对比的快照序号;不传则最近一次"),
9096
9099
  against: t.unknown().optional().describe("对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)")
9097
9100
  })
9098
- }), le = [];
9101
+ }), ue = [];
9099
9102
  if (n.vfsStore) {
9100
9103
  let e = n.vfsStore, i = (e) => `drafts/${e}.json`, c = r(({ draftId: t, chunk: n, mode: r }) => {
9101
9104
  let a = i(t), o = e.files[a], s = r === "append" && o, c = s ? o.content + n : n;
@@ -9158,9 +9161,9 @@ function Mu(e, n = {}) {
9158
9161
  description: "把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。",
9159
9162
  schema: t.object({ draftId: t.string().describe("要提交的草稿标识(对应 draft_write 的 draftId)") })
9160
9163
  });
9161
- P(u), le.push(c, u);
9164
+ P(u), ue.push(c, u);
9162
9165
  }
9163
- let ue = [];
9166
+ let de = [];
9164
9167
  if (e.resources?.length && d) {
9165
9168
  let e = r(async ({ path: e, handle: t }) => {
9166
9169
  let n = e;
@@ -9264,38 +9267,38 @@ function Mu(e, n = {}) {
9264
9267
  handle: t.string().optional().describe("占位符句柄(与 path 二选一)")
9265
9268
  })
9266
9269
  });
9267
- P(a), ue.push(e, n, i, a);
9270
+ P(a), de.push(e, n, i, a);
9268
9271
  }
9269
- let de = [
9272
+ let fe = [
9270
9273
  ee,
9271
9274
  F,
9272
9275
  te,
9273
- I,
9274
- L,
9275
9276
  ne,
9277
+ I,
9276
9278
  re,
9277
9279
  ie,
9278
9280
  ae,
9279
- R,
9280
9281
  oe,
9281
- z,
9282
+ L,
9282
9283
  se,
9284
+ R,
9283
9285
  ce,
9284
- ...le,
9285
- ...ue
9286
+ le,
9287
+ ...ue,
9288
+ ...de
9286
9289
  ];
9287
- Object.defineProperty(de, "controller", {
9290
+ Object.defineProperty(fe, "controller", {
9288
9291
  value: A,
9289
9292
  enumerable: !1,
9290
9293
  configurable: !1,
9291
9294
  writable: !1
9292
9295
  });
9293
- for (let e of de) Object.defineProperty(e, "__dataOpsScoped", {
9296
+ for (let e of fe) Object.defineProperty(e, "__dataOpsScoped", {
9294
9297
  value: !0,
9295
9298
  enumerable: !1,
9296
9299
  configurable: !1
9297
9300
  });
9298
- return de;
9301
+ return fe;
9299
9302
  }
9300
9303
  //#endregion
9301
9304
  //#region src/core/tools/htmlValidate.ts
@@ -11427,7 +11430,7 @@ function $f(e, t, n) {
11427
11430
  name: "usageHints",
11428
11431
  augmentPrompt: (i) => {
11429
11432
  let a = [];
11430
- if (r.planning && (a.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), a.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), a.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), a.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), e?.humanConfirm ? a.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : a.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), a.push(" · 规划阶段有轮次预算(maxPlanRevisions,默认 5):勿反复调研/改计划而不执行,规划充分后即开始 write 落地。")), t && (a.push("改主数据前先 get_data({jsonPath}) 读其当前真实值(返回末尾 hash=xxx 为乐观锁标识),基于真实值改,不要凭记忆。写入是否被自动校验由集成方 conflictWatchFields 声明决定:若已声明且主数据在你 read 之后被外部改过,会触发冲突——集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值再改。"), a.push("不确定主数据字段结构时用 describe_data 查看说明。"), a.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), a.push("修改主数据出错时可用 restore_data 回退最近一次。"), a.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), a.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), a.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), a.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), a.push("【省轮次·批量】读多个同构子路径(如各组件 props)用 read({jsonPaths:[...]}) 一次取回,勿发多个独立 read;改多处用 write({patches:[{op:\"set\",jsonPath,value},...]}) 一次提交多改动(原子任一失败回滚),勿逐个 edit_data/write 烧轮次预算。"), a.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。")), r.subagent && a.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), r.inspectEnv && a.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), r.domInspect && a.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.todoDeps && a.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
11433
+ if (r.planning && (a.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), a.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), a.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), a.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), e?.humanConfirm ? a.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : a.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), a.push(" · 计划修订有次数上限(maxPlanRevisions,默认 5,只计 write_todos 调用、调研轮不计):勿反复改计划而不执行,规划充分后即开始 write 落地。")), t && (a.push("改主数据前先 get_data({jsonPath}) 读其当前真实值(返回末尾 hash=xxx 为乐观锁标识),基于真实值改,不要凭记忆。写入是否被自动校验由集成方 conflictWatchFields 声明决定:若已声明且主数据在你 read 之后被外部改过,会触发冲突——集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值再改。"), a.push("不确定主数据字段结构时用 describe_data 查看说明。"), a.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), a.push("修改主数据出错时可用 restore_data 回退最近一次。"), a.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), a.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), a.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), a.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), a.push("【省轮次·批量】读多个同构子路径(如各组件 props)用 read({jsonPaths:[...]}) 一次取回,勿发多个独立 read;改多处用 write({patches:[{op:\"set\",jsonPath,value},...]}) 一次提交多改动(原子任一失败回滚),勿逐个 edit_data/write 烧轮次预算。"), a.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。")), r.subagent && a.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), r.inspectEnv && a.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), r.domInspect && a.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.todoDeps && a.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
11431
11434
  let t = e.subagents.filter((e) => (e.temperature ?? 0) >= Qf || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < Qf && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
11432
11435
  a.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (a.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), a.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && a.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), a.push(" · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), a.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
11433
11436
  }
@@ -11862,8 +11865,8 @@ function Pp(e, n) {
11862
11865
  }
11863
11866
  });
11864
11867
  }), O = Ls({
11865
- getSchema: () => V()?.schema,
11866
- getBind: () => V()?.bind,
11868
+ getSchema: () => B()?.schema,
11869
+ getBind: () => B()?.bind,
11867
11870
  onChange: (e) => G({
11868
11871
  type: "focus_change",
11869
11872
  focuses: e
@@ -11881,36 +11884,36 @@ function Pp(e, n) {
11881
11884
  let t = Mo(M?.schema, e._codeAsset.codeField);
11882
11885
  t.length ? (e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), e._rebuildCodeAssetPaths?.(t[0]), console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map((e) => `'${e}'`).join(", ")}]`)) : (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'])"), F.add(e));
11883
11886
  }
11884
- let te = F.size ? ee.filter((e) => !F.has(e)) : ee, I = F.size ? (P ?? []).filter((e) => !F.has(e)) : P, L = te.length > 0, ne = te.flatMap((e) => e._codeAsset.writablePaths), re = te.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), ie = e.checkpoint, ae = ie !== void 0 && ie !== !1, R = ae ? pl({
11885
- getData: () => V()?.bind,
11886
- consumeDataDirty: () => B?.consumeDataDirty?.() ?? !0,
11887
+ let te = F.size ? ee.filter((e) => !F.has(e)) : ee, ne = F.size ? (P ?? []).filter((e) => !F.has(e)) : P, I = te.length > 0, re = te.flatMap((e) => e._codeAsset.writablePaths), ie = te.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), ae = e.checkpoint, oe = ae !== void 0 && ae !== !1, L = oe ? pl({
11888
+ getData: () => B()?.bind,
11889
+ consumeDataDirty: () => z?.consumeDataDirty?.() ?? !0,
11887
11890
  slotPaths: M ? [""] : [],
11888
11891
  vfsStore: x,
11889
11892
  todosMw: S,
11890
11893
  getTodos: () => j.current?.getState?.()?.todos ?? [],
11891
11894
  messages: b,
11892
- maxCheckpoints: ie && typeof ie == "object" ? ie.maxCheckpoints : void 0
11893
- }) : null, oe = !ie || typeof ie != "object" || ie.auto !== !1, z = lf(e.capabilities), se = z.dataOps, ce = z.draftWrite, le = z.tracing, ue = z.automation, de = Wl({
11895
+ maxCheckpoints: ae && typeof ae == "object" ? ae.maxCheckpoints : void 0
11896
+ }) : null, se = !ae || typeof ae != "object" || ae.auto !== !1, R = lf(e.capabilities), ce = R.dataOps, le = R.draftWrite, ue = R.tracing, de = R.automation, fe = Wl({
11894
11897
  ...e,
11895
11898
  locale: e.i18n?.locale
11896
11899
  });
11897
- if (L) {
11900
+ if (I) {
11898
11901
  let e = te.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
11899
- e && (de += "\n\n" + e);
11900
- } else M?.schema && jo(M.schema) && (de += "\n\n" + Yo.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
11901
- let fe = se && M ? Mu(M, {
11902
+ e && (fe += "\n\n" + e);
11903
+ } else M?.schema && jo(M.schema) && (fe += "\n\n" + Yo.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
11904
+ let pe = ce && M ? Mu(M, {
11902
11905
  onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
11903
11906
  maxSnapshots: e.maxSnapshots,
11904
11907
  onConflict: a.set,
11905
11908
  conflictWatchFields: e.conflictWatchFields,
11906
- vfsStore: ce || M?.resources?.length ? x : void 0,
11907
- ...ne.length ? { pgIdPaths: ne } : {},
11908
- ...re.length ? { largeTextPaths: re } : {}
11909
- }) : [], pe = se ? fe : [], B = se && M ? fe.controller ?? null : null, me = se && M?.resources?.length && B?.getResourcesSnapshot ? ep({ getResourcesSnapshot: () => B?.getResourcesSnapshot?.() ?? [] }) : void 0, V = () => B?.get() ?? M, H = new Set(fe.map((e) => e.name)), he = e.conflictWatchFields ?? [], ge = !he.includes("*") && he.length ? new Set(he) : void 0, _e = B ? id({
11910
- getBind: () => V()?.bind,
11911
- recomputeAll: () => B.recomputeAllBaselines?.(),
11912
- hasBaselines: () => B.hasBaselines?.() ?? !1,
11913
- isManaged: (e) => H.has(e),
11909
+ vfsStore: le || M?.resources?.length ? x : void 0,
11910
+ ...re.length ? { pgIdPaths: re } : {},
11911
+ ...ie.length ? { largeTextPaths: ie } : {}
11912
+ }) : [], me = ce ? pe : [], z = ce && M ? pe.controller ?? null : null, he = ce && M?.resources?.length && z?.getResourcesSnapshot ? ep({ getResourcesSnapshot: () => z?.getResourcesSnapshot?.() ?? [] }) : void 0, B = () => z?.get() ?? M, V = new Set(pe.map((e) => e.name)), H = e.conflictWatchFields ?? [], ge = !H.includes("*") && H.length ? new Set(H) : void 0, _e = z ? id({
11913
+ getBind: () => B()?.bind,
11914
+ recomputeAll: () => z.recomputeAllBaselines?.(),
11915
+ hasBaselines: () => z.hasBaselines?.() ?? !1,
11916
+ isManaged: (e) => V.has(e),
11914
11917
  hash: (e) => ge ? ws(e, ge) : Cs(e),
11915
11918
  log: (e, t) => {
11916
11919
  let n = J.agent?.debugLogs;
@@ -11923,7 +11926,7 @@ function Pp(e, n) {
11923
11926
  }
11924
11927
  }), It(n));
11925
11928
  }
11926
- }) : void 0, U = /* @__PURE__ */ new Map(), ve = Xf(z, pe, _f, z.domInspect && !z.skills ? [
11929
+ }) : void 0, U = /* @__PURE__ */ new Map(), ve = Xf(R, me, _f, R.domInspect && !R.skills ? [
11927
11930
  ...Cf,
11928
11931
  Nf,
11929
11932
  Pf
@@ -11935,15 +11938,15 @@ function Pp(e, n) {
11935
11938
  be.forEach((e) => U.set(e.name, "action"));
11936
11939
  let xe = [], Se = !1, Ce = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), we = Ce ? rl() : null;
11937
11940
  we && U.set(tl, "builtin");
11938
- let Te = ae && R ? [r(async () => {
11939
- let e = R.list();
11940
- return e.length ? R.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
11941
+ let Te = oe && L ? [r(async () => {
11942
+ let e = L.list();
11943
+ return e.length ? L.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
11941
11944
  }, {
11942
11945
  name: "restore_last_checkpoint",
11943
11946
  description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
11944
11947
  schema: t.object({}).optional()
11945
11948
  }), r(async () => {
11946
- let e = R.list();
11949
+ let e = L.list();
11947
11950
  return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
11948
11951
  }, {
11949
11952
  name: "list_checkpoints",
@@ -11951,8 +11954,8 @@ function Pp(e, n) {
11951
11954
  schema: t.object({}).optional()
11952
11955
  })] : [];
11953
11956
  Te.forEach((e) => U.set(e.name, "builtin"));
11954
- let Ee = z.focus, De = r(async ({ path: e, label: t }) => {
11955
- let n = V()?.schema;
11957
+ let Ee = R.focus, De = r(async ({ path: e, label: t }) => {
11958
+ let n = B()?.schema;
11956
11959
  return n ? bo(n, e) ? (O.setFocus({
11957
11960
  path: e,
11958
11961
  ...t ? { label: t } : {}
@@ -11969,7 +11972,7 @@ function Pp(e, n) {
11969
11972
  description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
11970
11973
  schema: t.object({}).optional()
11971
11974
  }), ke = r(async ({ path: e, label: t }) => {
11972
- let n = V()?.schema;
11975
+ let n = B()?.schema;
11973
11976
  if (!n) return "聚焦失败:当前无主数据 schema,无法聚焦。";
11974
11977
  if (!bo(n, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
11975
11978
  O.addFocus({
@@ -12039,12 +12042,12 @@ function Pp(e, n) {
12039
12042
  ]);
12040
12043
  return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
12041
12044
  }
12042
- let Fe = z.planning, Ie = z.missionAnchor, Le = z.workingMemory, Re = z.skills, ze = z.vfs || L;
12045
+ let Fe = R.planning, Ie = R.missionAnchor, Le = R.workingMemory, Re = R.skills, ze = R.vfs || I;
12043
12046
  if (ze) for (let e of tu) U.set(e, "builtin");
12044
12047
  if (Fe) for (let e of S.tools ?? []) U.set(e.name, "builtin");
12045
- let Be = z.summarization, Ve = z.agentCompression && !!d;
12046
- e.debug && z.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
12047
- let He = z.memory, Ue = z.subagent, We = Ue ? xc() : void 0, Ge = e.verify?.maxAttempts ?? 2, Ke = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), qe = e.capabilities?.verify === !1, Je = (z.verify || Ke && !qe) && e.verify?.enabled !== !1 && Ge > 0, Ye = z.contextInspector;
12048
+ let Be = R.summarization, Ve = R.agentCompression && !!d;
12049
+ e.debug && R.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
12050
+ let He = R.memory, Ue = R.subagent, We = Ue ? xc() : void 0, Ge = e.verify?.maxAttempts ?? 2, Ke = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), qe = e.capabilities?.verify === !1, Je = (R.verify || Ke && !qe) && e.verify?.enabled !== !1 && Ge > 0, Ye = R.contextInspector;
12048
12051
  Ke && !Je && e.verify?.enabled !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
12049
12052
  let Xe = e.subagent, Ze = Xe?.allowedTools ?? [], Qe = e.permissions?.length ? $c(e.permissions) : void 0, $e = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? el(e.approval) : void 0, et = [
12050
12053
  ...Qe ? [Qe] : [],
@@ -12064,17 +12067,17 @@ function Pp(e, n) {
12064
12067
  thinkingMode: Xe?.thinkingMode,
12065
12068
  debug: e.debug,
12066
12069
  getFocuses: () => O.getFocuses(),
12067
- getSchema: () => V()?.schema ?? null,
12070
+ getSchema: () => B()?.schema ?? null,
12068
12071
  tracker: We,
12069
12072
  guardMiddleware: et.length ? et : void 0,
12070
12073
  getVfsFiles: ze ? () => x.files : void 0,
12071
- enterDataScope: B?.enterScope ? (e) => B.enterScope(e) : void 0,
12072
- exitDataScope: B?.exitScope ? (e) => B.exitScope(e) : void 0,
12074
+ enterDataScope: z?.enterScope ? (e) => z.enterScope(e) : void 0,
12075
+ exitDataScope: z?.exitScope ? (e) => z.exitScope(e) : void 0,
12073
12076
  onUsage: (e) => {
12074
12077
  i.prompt_tokens = (i.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), i.completion_tokens = (i.completion_tokens ?? 0) + (e.completion_tokens ?? 0), i.total_tokens = (i.total_tokens ?? 0) + (e.total_tokens ?? 0);
12075
12078
  },
12076
12079
  timeoutMs: Xe?.timeoutMs
12077
- }), nt = I?.map((e) => {
12080
+ }), nt = ne?.map((e) => {
12078
12081
  if (!e._codeAsset) return e;
12079
12082
  let t = e._codeAsset, n = Yu({
12080
12083
  writablePaths: t.writablePaths,
@@ -12083,20 +12086,20 @@ function Pp(e, n) {
12083
12086
  codeField: t.codeField,
12084
12087
  craftNotes: t.craftNotes,
12085
12088
  onWarning: (e) => console.warn(`[page-agent-sdk][code-asset] ${e}`),
12086
- getController: () => B,
12089
+ getController: () => z,
12087
12090
  vfsStore: x
12088
12091
  }), r = [...e.middleware ?? [], n];
12089
- for (let e of r) e && typeof e == "object" && typeof e._setGetController == "function" && e._setGetController(() => B);
12092
+ for (let e of r) e && typeof e == "object" && typeof e._setGetController == "function" && e._setGetController(() => z);
12090
12093
  return {
12091
12094
  ...e,
12092
12095
  middleware: r
12093
12096
  };
12094
- }), rt = L && Ue ? Xu() : void 0, it = rt ? rd({
12095
- getBind: () => V()?.bind,
12096
- writablePaths: ne,
12097
+ }), rt = I && Ue ? Xu() : void 0, it = rt ? rd({
12098
+ getBind: () => B()?.bind,
12099
+ writablePaths: re,
12097
12100
  getLocked: () => rt.locked(),
12098
12101
  tools: W,
12099
- getCodeFieldPaths: () => td(V()?.bind, te.map((e) => ({
12102
+ getCodeFieldPaths: () => td(B()?.bind, te.map((e) => ({
12100
12103
  writablePaths: e._codeAsset.writablePaths,
12101
12104
  codeField: e._codeAsset.codeField
12102
12105
  })))
@@ -12107,24 +12110,24 @@ function Pp(e, n) {
12107
12110
  allTools: () => J.agent?.allTools ?? W,
12108
12111
  debug: e.debug,
12109
12112
  getFocuses: () => O.getFocuses(),
12110
- getSchema: () => V()?.schema ?? null,
12111
- getBind: () => V()?.bind,
12113
+ getSchema: () => B()?.schema ?? null,
12114
+ getBind: () => B()?.bind,
12112
12115
  tracker: We,
12113
12116
  guardMiddleware: et.length ? et : void 0,
12114
12117
  getVfsFiles: ze ? () => x.files : void 0,
12115
- enterDataScope: B?.enterScope ? (e) => B.enterScope(e) : void 0,
12116
- exitDataScope: B?.exitScope ? (e) => B.exitScope(e) : void 0,
12118
+ enterDataScope: z?.enterScope ? (e) => z.enterScope(e) : void 0,
12119
+ exitDataScope: z?.exitScope ? (e) => z.exitScope(e) : void 0,
12117
12120
  onUsage: (e) => {
12118
12121
  i.prompt_tokens = (i.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), i.completion_tokens = (i.completion_tokens ?? 0) + (e.completion_tokens ?? 0), i.total_tokens = (i.total_tokens ?? 0) + (e.total_tokens ?? 0);
12119
12122
  },
12120
12123
  timeoutMs: e.subagent?.timeoutMs,
12121
12124
  ...rt ? {
12122
12125
  componentLock: rt,
12123
- resolveComponents: (e) => Zu(e, Gu(V()?.bind, ne))
12126
+ resolveComponents: (e) => Zu(e, Gu(B()?.bind, re))
12124
12127
  } : {}
12125
12128
  }) : void 0, ot = !!e.capabilities?.bulkGuard && !!$e, st = ot ? ol({
12126
12129
  ...e.bulkGuard ?? {},
12127
- getBind: () => V()?.bind,
12130
+ getBind: () => B()?.bind,
12128
12131
  tools: W,
12129
12132
  getPlanConfirmation: () => E,
12130
12133
  onEvent: (e) => {
@@ -12150,8 +12153,8 @@ function Pp(e, n) {
12150
12153
  "fetch_document"
12151
12154
  ], dt = W.filter((e) => ut.includes(e.name)), ft = Je ? hl({
12152
12155
  check: e.verify.check ?? xl({
12153
- schemas: () => V() ? { "": V().schema } : {},
12154
- root: () => V()?.bind
12156
+ schemas: () => B() ? { "": B().schema } : {},
12157
+ root: () => B()?.bind
12155
12158
  }),
12156
12159
  adversarial: e.verify?.adversarial ? {
12157
12160
  llm: e.llm,
@@ -12161,19 +12164,19 @@ function Pp(e, n) {
12161
12164
  contextWindow: f.contextWindow,
12162
12165
  thresholdRatio: pf(e, f.contextWindow).summaryThresholdRatio
12163
12166
  }) : void 0, mt = $f({
12164
- ...z,
12167
+ ...R,
12165
12168
  humanConfirm: Ce,
12166
- subagents: I?.map(lt)
12167
- }, se && !!M, { promptSoftCap: gc(f.contextWindow, p.promptSoftCapTokens) }), ht = M ? {
12169
+ subagents: ne?.map(lt)
12170
+ }, ce && !!M, { promptSoftCap: gc(f.contextWindow, p.promptSoftCapTokens) }), ht = M ? {
12168
12171
  name: "dataHint",
12169
- augmentPrompt: () => Ul(V(), e.schemaHint) || void 0
12172
+ augmentPrompt: () => Ul(B(), e.schemaHint) || void 0
12170
12173
  } : null, gt = e.augmentSystem ? {
12171
12174
  name: "augmentSystem",
12172
12175
  augmentPrompt: (t) => {
12173
12176
  try {
12174
12177
  return e.augmentSystem({
12175
12178
  state: t,
12176
- data: V()
12179
+ data: B()
12177
12180
  });
12178
12181
  } catch (t) {
12179
12182
  e.debug && console.log("[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:", t.message);
@@ -12191,7 +12194,7 @@ function Pp(e, n) {
12191
12194
  }), Ct = e.skillStorage === !1 ? null : ap({
12192
12195
  ...typeof e.skillStorage == "object" ? e.skillStorage : {},
12193
12196
  id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
12194
- }), wt = z.preferences, Tt = wt && e.preferenceStorage !== !1 ? fp({
12197
+ }), wt = R.preferences, Tt = wt && e.preferenceStorage !== !1 ? fp({
12195
12198
  ...typeof e.preferenceStorage == "object" ? e.preferenceStorage : {},
12196
12199
  id: e.preferenceStorage && typeof e.preferenceStorage == "object" && e.preferenceStorage.id ? e.preferenceStorage.id : `agent::${n}`
12197
12200
  }) : null, K = Tt ? Cp({
@@ -12229,7 +12232,7 @@ function Pp(e, n) {
12229
12232
  }, q = Be ? bc({
12230
12233
  ...p,
12231
12234
  llmInvoke: l,
12232
- getRegisteredData: () => V() ? [{ description: V().description ?? "主数据对象" }] : [],
12235
+ getRegisteredData: () => B() ? [{ description: B().description ?? "主数据对象" }] : [],
12233
12236
  preserveLastToolResults: _,
12234
12237
  ...Ve ? {
12235
12238
  decideInvoke: d,
@@ -12243,9 +12246,9 @@ function Pp(e, n) {
12243
12246
  T,
12244
12247
  ...K ? [K] : [],
12245
12248
  ...Fe ? [S] : [],
12246
- ...Re ? [vt = Qs([...z.domInspect && !(e.skills || []).some((e) => e.name === Ff.name) ? [Ff] : [], ...e.skills || []], {
12249
+ ...Re ? [vt = Qs([...R.domInspect && !(e.skills || []).some((e) => e.name === Ff.name) ? [Ff] : [], ...e.skills || []], {
12247
12250
  readVfs: ze ? (e) => x.files[e]?.content : void 0,
12248
- hostScriptEnabled: z.skillHostScript,
12251
+ hostScriptEnabled: R.skillHostScript,
12249
12252
  onToolsReady: (e, t) => {
12250
12253
  for (let n of t) {
12251
12254
  let t = Me.findIndex((e) => e.name === n.name);
@@ -12258,10 +12261,10 @@ function Pp(e, n) {
12258
12261
  ...q ? [q] : [],
12259
12262
  ...Le ? [k] : [],
12260
12263
  ...Ee ? [O] : [],
12261
- ...me ? [me] : [],
12264
+ ...he ? [he] : [],
12262
12265
  ...He ? [A] : [],
12263
12266
  ...Qe ? [Qe] : [],
12264
- ...ae && oe && R ? [ml(R)] : [],
12267
+ ...oe && se && L ? [ml(L)] : [],
12265
12268
  ...Ce ? [D] : [],
12266
12269
  ...$e ? [$e] : [],
12267
12270
  ..._e ? [_e] : [],
@@ -12273,11 +12276,11 @@ function Pp(e, n) {
12273
12276
  ...gt ? [gt] : [],
12274
12277
  ...pt ? [pt] : [],
12275
12278
  ...e.middleware || [],
12276
- ...ue ? [Uf(i, {
12279
+ ...de ? [Uf(i, {
12277
12280
  tokenBudget: e.tokenBudget,
12278
12281
  timeBudgetMs: e.timeBudgetMs
12279
12282
  }, G)] : [],
12280
- Mp(G, b, V, i)
12283
+ Mp(G, b, B, i)
12281
12284
  ]), kt = e.maxMemoryRounds ?? Op, At = e.approval?.timeoutMs, jt = At === void 0 || At === 0 ? 3e4 : !Number.isFinite(At) || At < 0 ? 0 : At;
12282
12285
  function Nt(e) {
12283
12286
  if (jt) return (t) => {
@@ -12343,14 +12346,14 @@ function Pp(e, n) {
12343
12346
  mcpClosers: [],
12344
12347
  mcpServers: [],
12345
12348
  mcpFailed: [],
12346
- checkpoint: R,
12347
- dataOpsController: B,
12349
+ checkpoint: L,
12350
+ dataOpsController: z,
12348
12351
  skillsController: vt ? vt.controller : null,
12349
12352
  infoTick: o,
12350
12353
  pendingConflict: a.pendingConflict,
12351
12354
  sessions: Ft,
12352
12355
  refreshSessions: Lt,
12353
- liveData: V,
12356
+ liveData: B,
12354
12357
  usage: i,
12355
12358
  emit: G,
12356
12359
  runSerial: Rt,
@@ -12368,10 +12371,10 @@ function Pp(e, n) {
12368
12371
  W = Pe(), J.agent && J.agent.setTools(W);
12369
12372
  },
12370
12373
  applySnapshot(t) {
12371
- if (t.vfs && x.hydrate && x.hydrate(t.vfs), t.messages?.length && (b.push(...di(t.messages, (e) => (e ? J.vfsStore?.files?.[e]?.content : void 0) || void 0)), T.markResumed()), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && A.reset(t.memory), t.checkpoints?.length && R && R.importStack(t.checkpoints), t.usage && Object.assign(i, t.usage), t.mission && Ie && C.setMission(t.mission), t.workingMemory && Le && k.restore(t.workingMemory), t.planConfirmation && (E = t.planConfirmation), Ee) {
12374
+ if (t.vfs && x.hydrate && x.hydrate(t.vfs), t.messages?.length && (b.push(...di(t.messages, (e) => (e ? J.vfsStore?.files?.[e]?.content : void 0) || void 0)), T.markResumed()), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && A.reset(t.memory), t.checkpoints?.length && L && L.importStack(t.checkpoints), t.usage && Object.assign(i, t.usage), t.mission && Ie && C.setMission(t.mission), t.workingMemory && Le && k.restore(t.workingMemory), t.planConfirmation && (E = t.planConfirmation), Ee) {
12372
12375
  let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
12373
12376
  if (r.length) {
12374
- let t = V()?.schema, n = t ? r.filter((e) => bo(t, e.path)) : [];
12377
+ let t = B()?.schema, n = t ? r.filter((e) => bo(t, e.path)) : [];
12375
12378
  if (n.length && (O.setFocus(null), n.forEach((e) => O.addFocus(e))), e.debug && n.length < r.length) {
12376
12379
  let e = r.filter((e) => !n.includes(e)).map((e) => e.path);
12377
12380
  console.warn("[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:", e);
@@ -12420,7 +12423,7 @@ function Pp(e, n) {
12420
12423
  code: "IMAGE_UNSUPPORTED_MODEL"
12421
12424
  }), Error(`[page-agent-sdk] ${e}`);
12422
12425
  }
12423
- let i = ue ? t.maxAutoRetries ?? 1 : 0, a = 0, o = !1, c = Pt(t.signal), l = J.sessionId;
12426
+ let i = de ? t.maxAutoRetries ?? 1 : 0, a = 0, o = !1, c = Pt(t.signal), l = J.sessionId;
12424
12427
  for (;;) {
12425
12428
  o ||= (b.push({
12426
12429
  role: "user",
@@ -12447,8 +12450,8 @@ function Pp(e, n) {
12447
12450
  } catch (e) {
12448
12451
  if (ki(e, t.signal)) throw e;
12449
12452
  let n = Qr(e, "fatal");
12450
- if (a < i && R?.canRestore()) {
12451
- a += 1, R.restore(), o = !0, G({
12453
+ if (a < i && L?.canRestore()) {
12454
+ a += 1, L.restore(), o = !0, G({
12452
12455
  type: "error",
12453
12456
  message: `致命错误自动恢复(${a}/${i}):${n.message},已回退 checkpoint 重试`,
12454
12457
  severity: "observable",
@@ -12485,7 +12488,7 @@ function Pp(e, n) {
12485
12488
  break;
12486
12489
  }
12487
12490
  let o = e[a];
12488
- R && R.save(`batch:${a}`);
12491
+ L && L.save(`batch:${a}`);
12489
12492
  let c = b.length;
12490
12493
  try {
12491
12494
  b.push({
@@ -12568,14 +12571,14 @@ function Pp(e, n) {
12568
12571
  }
12569
12572
  x.flush?.(), await s.flush();
12570
12573
  let r = t ?? "", i;
12571
- return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title), J.sessionId = r, b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || A.reset(""), C.reset(), k.reset(), O.reset(), T.reset(), E = void 0, st?.state.reset(), K?.resetScanCursor(), R && R.importStack([]), J.agent.debugLogs.value = [], J.agent.resetStaleReadsInvalidated?.(), i ||= await s.load(n, r), i && (J.applySnapshot(i), G({
12574
+ return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title), J.sessionId = r, b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || A.reset(""), C.reset(), k.reset(), O.reset(), T.reset(), E = void 0, st?.state.reset(), K?.resetScanCursor(), L && L.importStack([]), J.agent.debugLogs.value = [], J.agent.resetStaleReadsInvalidated?.(), i ||= await s.load(n, r), i && (J.applySnapshot(i), G({
12572
12575
  type: "session_restored",
12573
12576
  sessionId: r,
12574
12577
  rounds: i.messages?.length ?? 0
12575
12578
  })), e.memory && Xt({ memory: A.get() || (typeof e.memory == "string" ? e.memory : "") }), Lt(), qt = void 0, Jt = !1, J.infoTick.value++, r;
12576
12579
  },
12577
12580
  resetSession: () => {
12578
- Vt(), a.resolve("keep_external"), J.sessionId = Pd(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || A.reset(""), C.reset(), k.reset(), O.reset(), T.reset(), E = void 0, st?.state.reset(), K?.resetScanCursor(), R && R.importStack([]), J.agent && (J.agent.debugLogs.value = [], J.agent.resetStaleReadsInvalidated?.()), s && s.createSession(J.agentId, e.session?.title, J.sessionId).catch((t) => {
12581
+ Vt(), a.resolve("keep_external"), J.sessionId = Pd(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || A.reset(""), C.reset(), k.reset(), O.reset(), T.reset(), E = void 0, st?.state.reset(), K?.resetScanCursor(), L && L.importStack([]), J.agent && (J.agent.debugLogs.value = [], J.agent.resetStaleReadsInvalidated?.()), s && s.createSession(J.agentId, e.session?.title, J.sessionId).catch((t) => {
12579
12582
  e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
12580
12583
  }), G({
12581
12584
  type: "session_restored",
@@ -12682,7 +12685,7 @@ function Pp(e, n) {
12682
12685
  id: n,
12683
12686
  sessionId: J.sessionId,
12684
12687
  model: Cd(y) ? y.model ?? y.modelName : y.model,
12685
- systemPrompt: J.agent?.getEffectiveSystemPrompt?.() ?? de + Ul(V(), e.schemaHint),
12688
+ systemPrompt: J.agent?.getEffectiveSystemPrompt?.() ?? fe + Ul(B(), e.schemaHint),
12686
12689
  tools: (J.agent?.allTools ?? W).map((e) => ({
12687
12690
  name: e.name,
12688
12691
  description: e.description,
@@ -12693,9 +12696,9 @@ function Pp(e, n) {
12693
12696
  name: e.name,
12694
12697
  description: e.description
12695
12698
  })),
12696
- data: V() ? {
12697
- description: V().description,
12698
- schema: V().schema
12699
+ data: B() ? {
12700
+ description: B().description,
12701
+ schema: B().schema
12699
12702
  } : void 0,
12700
12703
  contextPreset: e.contextPreset ?? "auto",
12701
12704
  compression: {
@@ -12728,7 +12731,7 @@ function Pp(e, n) {
12728
12731
  workingMemory: Le ? k.getWorkingMemory() : void 0,
12729
12732
  focus: Ee ? O.getFocus() : void 0,
12730
12733
  focuses: Ee ? O.getFocuses() : [],
12731
- trace: le && J.agent?.spans ? {
12734
+ trace: ue && J.agent?.spans ? {
12732
12735
  spans: J.agent.spans.value,
12733
12736
  metrics: Di(J.agent.spans.value)
12734
12737
  } : void 0,
@@ -12761,10 +12764,10 @@ function Pp(e, n) {
12761
12764
  ...J.mcpFailed.length ? { failed: J.mcpFailed } : {}
12762
12765
  },
12763
12766
  lastCompression: J.agent?.getState?.()?.lastCompression,
12764
- checkpoints: R ? {
12767
+ checkpoints: L ? {
12765
12768
  enabled: !0,
12766
- auto: oe,
12767
- list: R.list()
12769
+ auto: se,
12770
+ list: L.list()
12768
12771
  } : void 0
12769
12772
  };
12770
12773
  },
@@ -12829,11 +12832,11 @@ function Pp(e, n) {
12829
12832
  return Ee ? O.getFocuses() : [];
12830
12833
  },
12831
12834
  setFocus(t) {
12832
- let n = Np(t, "setFocus", Ee, () => V()?.schema, e.debug);
12835
+ let n = Np(t, "setFocus", Ee, () => B()?.schema, e.debug);
12833
12836
  return n.ok ? (O.setFocus(t), J.infoTick.value++, { ok: !0 }) : n;
12834
12837
  },
12835
12838
  addFocus(t) {
12836
- let n = Np(t, "addFocus", Ee, () => V()?.schema, e.debug);
12839
+ let n = Np(t, "addFocus", Ee, () => B()?.schema, e.debug);
12837
12840
  return n.ok ? O.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
12838
12841
  ok: !1,
12839
12842
  error: "焦点数上限 8(避免 system prompt 撑爆)"
@@ -12987,7 +12990,7 @@ function Pp(e, n) {
12987
12990
  let e = O.getFocuses();
12988
12991
  Xt({ focus: e.length ? e : null });
12989
12992
  }
12990
- ue && R && (Xt({ checkpoints: R.exportStack() }), Xt({ usage: i }));
12993
+ de && L && (Xt({ checkpoints: L.exportStack() }), Xt({ usage: i }));
12991
12994
  let t = Sd(b);
12992
12995
  if (t && t !== qt && (qt = t, Zt(J.sessionId, t)), e.autoTitle !== !1 && u && !Jt && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant")) {
12993
12996
  Jt = !0;
@@ -13069,7 +13072,7 @@ function Pp(e, n) {
13069
13072
  let t = Cd(e.llm) ? e.llm : await h(e.llm);
13070
13073
  J.agent = _o({
13071
13074
  llm: t,
13072
- systemPrompt: de,
13075
+ systemPrompt: fe,
13073
13076
  tools: W,
13074
13077
  middleware: Ot,
13075
13078
  maxToolRounds: e.maxToolRounds,
@@ -13087,7 +13090,7 @@ function Pp(e, n) {
13087
13090
  onLlmChange: (e) => {
13088
13091
  y = e;
13089
13092
  },
13090
- onTrace: le ? (e, t) => {
13093
+ onTrace: ue ? (e, t) => {
13091
13094
  try {
13092
13095
  G({
13093
13096
  type: "trace",
@@ -14208,7 +14211,7 @@ function Zp(e = {}) {
14208
14211
  };
14209
14212
  }), x = Gr(() => (n.messages.length, typeof e.canUndo == "function" && !!e.canUndo())), S = () => {
14210
14213
  e.onUndo?.() && (n.error = null);
14211
- }, C = (e) => new Date(e).toLocaleTimeString(ie, {
14214
+ }, C = (e) => new Date(e).toLocaleTimeString(ae, {
14212
14215
  hour: "2-digit",
14213
14216
  minute: "2-digit"
14214
14217
  }), w = () => {
@@ -14223,16 +14226,16 @@ function Zp(e = {}) {
14223
14226
  if (!t.length) return;
14224
14227
  let n = 4 - T.value.length;
14225
14228
  if (n <= 0) {
14226
- k(`${ae.imageCountLimitPrefix}4${ae.imageCountLimitSuffix}`);
14229
+ k(`${oe.imageCountLimitPrefix}4${oe.imageCountLimitSuffix}`);
14227
14230
  return;
14228
14231
  }
14229
- t.length > n && k(`${ae.imageCountLimitPrefix}4${ae.imageCountLimitSuffix}`), D.value = !0;
14232
+ t.length > n && k(`${oe.imageCountLimitPrefix}4${oe.imageCountLimitSuffix}`), D.value = !0;
14230
14233
  try {
14231
14234
  for (let e of t.slice(0, n)) try {
14232
14235
  let t = await mi(e, { name: e.name });
14233
14236
  T.value.push(t);
14234
14237
  } catch (e) {
14235
- k(e instanceof ri ? `${e.message}` : ae.imageInvalid);
14238
+ k(e instanceof ri ? `${e.message}` : oe.imageInvalid);
14236
14239
  }
14237
14240
  } finally {
14238
14241
  D.value = !1;
@@ -14251,13 +14254,13 @@ function Zp(e = {}) {
14251
14254
  }, ee = Gr(() => (e.infoTick?.value, e.getFocuses?.() ?? [])), F = Gr(() => (e.infoTick?.value, e.getInfo?.()?.planConfirmation)), te = (t) => e.onAddFocus ? e.onAddFocus(t) : {
14252
14255
  ok: !1,
14253
14256
  error: "focus 未启用"
14254
- }, I = (t) => {
14257
+ }, ne = (t) => {
14255
14258
  e.onRemoveFocus?.(t);
14256
- }, L = () => {
14259
+ }, I = () => {
14257
14260
  e.onClearFocus?.();
14258
- }, ne = (t) => {
14261
+ }, re = (t) => {
14259
14262
  e.onFocusChipClick?.(t);
14260
- }, re = Kp(e.icons), ie = e.locale ?? "zh-CN", ae = Yp(ie, e.dialogMessages);
14263
+ }, ie = Kp(e.icons), ae = e.locale ?? "zh-CN", oe = Yp(ae, e.dialogMessages);
14261
14264
  return {
14262
14265
  chat: t,
14263
14266
  inputText: o,
@@ -14290,12 +14293,12 @@ function Zp(e = {}) {
14290
14293
  focuses: ee,
14291
14294
  planConfirmation: F,
14292
14295
  addFocus: te,
14293
- removeFocus: I,
14294
- clearFocus: L,
14295
- focusChipClick: ne,
14296
- icons: re,
14297
- locale: ie,
14298
- messages: ae
14296
+ removeFocus: ne,
14297
+ clearFocus: I,
14298
+ focusChipClick: re,
14299
+ icons: ie,
14300
+ locale: ae,
14301
+ messages: oe
14299
14302
  };
14300
14303
  }
14301
14304
  function Qp() {