page-agent-sdk 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,7 +79,7 @@ function y(e) {
79
79
  var b = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), x = process.env.NODE_ENV === "production" ? [] : Object.freeze([]), S = () => {}, C = () => !1, 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) => {
80
80
  let n = e.indexOf(t);
81
81
  n > -1 && e.splice(n, 1);
82
- }, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray, j = (e) => re(e) === "[object Map]", M = (e) => re(e) === "[object Set]", ee = (e) => re(e) === "[object Date]", N = (e) => typeof e == "function", P = (e) => typeof e == "string", F = (e) => typeof e == "symbol", I = (e) => typeof e == "object" && !!e, te = (e) => (I(e) || N(e)) && N(e.then) && N(e.catch), ne = Object.prototype.toString, re = (e) => ne.call(e), ie = (e) => re(e).slice(8, -1), ae = (e) => re(e) === "[object Object]", oe = (e) => P(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, se = /* @__PURE__ */ y(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ce = /* @__PURE__ */ y("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), le = (e) => {
82
+ }, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray, ee = (e) => re(e) === "[object Map]", j = (e) => re(e) === "[object Set]", M = (e) => re(e) === "[object Date]", N = (e) => typeof e == "function", P = (e) => typeof e == "string", F = (e) => typeof e == "symbol", I = (e) => typeof e == "object" && !!e, te = (e) => (I(e) || N(e)) && N(e.then) && N(e.catch), ne = Object.prototype.toString, re = (e) => ne.call(e), ie = (e) => re(e).slice(8, -1), ae = (e) => re(e) === "[object Object]", oe = (e) => P(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, se = /* @__PURE__ */ y(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ce = /* @__PURE__ */ y("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), le = (e) => {
83
83
  let t = /* @__PURE__ */ Object.create(null);
84
84
  return ((n) => t[n] || (t[n] = e(n)));
85
85
  }, ue = /-\w/g, L = le((e) => e.replace(ue, (e) => e.slice(1).toUpperCase())), de = /\B([A-Z])/g, fe = le((e) => e.replace(de, "-$1").toLowerCase()), pe = le((e) => e.charAt(0).toUpperCase() + e.slice(1)), me = le((e) => e ? `on${pe(e)}` : ""), he = (e, t) => !Object.is(e, t), ge = (e, ...t) => {
@@ -128,9 +128,9 @@ function R(e) {
128
128
  else if (I(e)) for (let n in e) e[n] && (t += n + " ");
129
129
  return t.trim();
130
130
  }
131
- var De = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", z = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view", Oe = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics", ke = /* @__PURE__ */ y(De), Ae = /* @__PURE__ */ y(z), je = /* @__PURE__ */ y(Oe), Me = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", Ne = /* @__PURE__ */ y(Me);
132
- Me + "";
133
- function Pe(e) {
131
+ var De = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", Oe = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view", ke = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics", Ae = /* @__PURE__ */ y(De), je = /* @__PURE__ */ y(Oe), Me = /* @__PURE__ */ y(ke), Ne = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", Pe = /* @__PURE__ */ y(Ne);
132
+ Ne + "";
133
+ function z(e) {
134
134
  return !!e || e === "";
135
135
  }
136
136
  function Fe(e, t) {
@@ -141,7 +141,7 @@ function Fe(e, t) {
141
141
  }
142
142
  function Ie(e, t) {
143
143
  if (e === t) return !0;
144
- let n = ee(e), r = ee(t);
144
+ let n = M(e), r = M(t);
145
145
  if (n || r) return n && r ? e.getTime() === t.getTime() : !1;
146
146
  if (n = F(e), r = F(t), n || r) return e === t;
147
147
  if (n = A(e), r = A(t), n || r) return n && r ? Fe(e, t) : !1;
@@ -154,7 +154,7 @@ function Ie(e, t) {
154
154
  }
155
155
  return String(e) === String(t);
156
156
  }
157
- var Le = (e) => !!(e && e.__v_isRef === !0), B = (e) => P(e) ? e : e == null ? "" : A(e) || I(e) && (e.toString === ne || !N(e.toString)) ? Le(e) ? B(e.value) : JSON.stringify(e, Re, 2) : String(e), Re = (e, t) => Le(t) ? Re(e, t.value) : j(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((e, [t, n], r) => (e[ze(t, r) + " =>"] = n, e), {}) } : M(t) ? { [`Set(${t.size})`]: [...t.values()].map((e) => ze(e)) } : F(t) ? ze(t) : I(t) && !A(t) && !ae(t) ? String(t) : t, ze = (e, t = "") => F(e) ? `Symbol(${e.description ?? t})` : e;
157
+ var Le = (e) => !!(e && e.__v_isRef === !0), B = (e) => P(e) ? e : e == null ? "" : A(e) || I(e) && (e.toString === ne || !N(e.toString)) ? Le(e) ? B(e.value) : JSON.stringify(e, Re, 2) : String(e), Re = (e, t) => Le(t) ? Re(e, t.value) : ee(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((e, [t, n], r) => (e[ze(t, r) + " =>"] = n, e), {}) } : j(t) ? { [`Set(${t.size})`]: [...t.values()].map((e) => ze(e)) } : F(t) ? ze(t) : I(t) && !A(t) && !ae(t) ? String(t) : t, ze = (e, t = "") => F(e) ? `Symbol(${e.description ?? t})` : e;
158
158
  //#endregion
159
159
  //#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
160
160
  function Be(e, ...t) {
@@ -450,13 +450,13 @@ function vt(e, t, n, r, i, a) {
450
450
  });
451
451
  } else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(gt)), t) {
452
452
  case "add":
453
- i ? a && s(o.get("length")) : (s(o.get(mt)), j(e) && s(o.get(ht)));
453
+ i ? a && s(o.get("length")) : (s(o.get(mt)), ee(e) && s(o.get(ht)));
454
454
  break;
455
455
  case "delete":
456
- i || (s(o.get(mt)), j(e) && s(o.get(ht)));
456
+ i || (s(o.get(mt)), ee(e) && s(o.get(ht)));
457
457
  break;
458
458
  case "set":
459
- j(e) && s(o.get(mt));
459
+ ee(e) && s(o.get(mt));
460
460
  break;
461
461
  }
462
462
  }
@@ -668,7 +668,7 @@ var Mt = class {
668
668
  }, Ft = /* @__PURE__ */ new Nt(), It = /* @__PURE__ */ new Pt(), Lt = /* @__PURE__ */ new Nt(!0), Rt = /* @__PURE__ */ new Pt(!0), zt = (e) => e, Bt = (e) => Reflect.getPrototypeOf(e);
669
669
  function Vt(e, t, n) {
670
670
  return function(...r) {
671
- let i = this.__v_raw, a = /* @__PURE__ */ H(i), o = j(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? zt : t ? pn : fn;
671
+ let i = this.__v_raw, a = /* @__PURE__ */ H(i), o = ee(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? zt : t ? pn : fn;
672
672
  return !t && _t(a, "iterate", c ? ht : mt), E(Object.create(l), { next() {
673
673
  let { value: e, done: t } = l.next();
674
674
  return t ? {
@@ -737,7 +737,7 @@ function Ut(e, t) {
737
737
  return i && vt(t, "delete", e, void 0, a), o;
738
738
  },
739
739
  clear() {
740
- let e = /* @__PURE__ */ H(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : j(e) ? new Map(e) : new Set(e), r = e.clear();
740
+ let e = /* @__PURE__ */ H(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : ee(e) ? new Map(e) : new Set(e), r = e.clear();
741
741
  return t && vt(e, "clear", void 0, void 0, n), r;
742
742
  }
743
743
  }), [
@@ -988,7 +988,7 @@ function On(e, t = Infinity, n) {
988
988
  if (t <= 0 || !I(e) || e.__v_skip || (n ||= /* @__PURE__ */ new Map(), (n.get(e) || 0) >= t)) return e;
989
989
  if (n.set(e, t), t--, /* @__PURE__ */ mn(e)) On(e.value, t, n);
990
990
  else if (A(e)) for (let r = 0; r < e.length; r++) On(e[r], t, n);
991
- else if (M(e) || j(e)) e.forEach((e) => {
991
+ else if (j(e) || ee(e)) e.forEach((e) => {
992
992
  On(e, t, n);
993
993
  });
994
994
  else if (ae(e)) {
@@ -1976,25 +1976,25 @@ var la = !0;
1976
1976
  function ua(e) {
1977
1977
  let t = ma(e), n = e.proxy, r = e.ctx;
1978
1978
  la = !1, t.beforeCreate && fa(t.beforeCreate, e, "bc");
1979
- let { data: i, computed: a, methods: o, watch: s, provide: c, inject: l, created: u, beforeMount: d, mounted: f, beforeUpdate: p, updated: m, activated: h, deactivated: g, beforeDestroy: _, beforeUnmount: v, destroyed: y, unmounted: b, render: x, renderTracked: C, renderTriggered: w, errorCaptured: T, serverPrefetch: E, expose: D, inheritAttrs: O, components: k, directives: j, filters: M } = t, ee = process.env.NODE_ENV === "production" ? null : ca();
1979
+ let { data: i, computed: a, methods: o, watch: s, provide: c, inject: l, created: u, beforeMount: d, mounted: f, beforeUpdate: p, updated: m, activated: h, deactivated: g, beforeDestroy: _, beforeUnmount: v, destroyed: y, unmounted: b, render: x, renderTracked: C, renderTriggered: w, errorCaptured: T, serverPrefetch: E, expose: D, inheritAttrs: O, components: k, directives: ee, filters: j } = t, M = process.env.NODE_ENV === "production" ? null : ca();
1980
1980
  if (process.env.NODE_ENV !== "production") {
1981
1981
  let [t] = e.propsOptions;
1982
- if (t) for (let e in t) ee("Props", e);
1982
+ if (t) for (let e in t) M("Props", e);
1983
1983
  }
1984
- if (l && da(l, r, ee), o) for (let e in o) {
1984
+ if (l && da(l, r, M), o) for (let e in o) {
1985
1985
  let t = o[e];
1986
1986
  N(t) ? (process.env.NODE_ENV === "production" ? r[e] = t.bind(n) : Object.defineProperty(r, e, {
1987
1987
  value: t.bind(n),
1988
1988
  configurable: !0,
1989
1989
  enumerable: !0,
1990
1990
  writable: !0
1991
- }), process.env.NODE_ENV !== "production" && ee("Methods", e)) : process.env.NODE_ENV !== "production" && G(`Method "${e}" has type "${typeof t}" in the component definition. Did you reference the function correctly?`);
1991
+ }), process.env.NODE_ENV !== "production" && M("Methods", e)) : process.env.NODE_ENV !== "production" && G(`Method "${e}" has type "${typeof t}" in the component definition. Did you reference the function correctly?`);
1992
1992
  }
1993
1993
  if (i) {
1994
1994
  process.env.NODE_ENV !== "production" && !N(i) && G("The data option must be a function. Plain object usage is no longer supported.");
1995
1995
  let t = i.call(n, n);
1996
1996
  if (process.env.NODE_ENV !== "production" && te(t) && G("data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>."), !I(t)) process.env.NODE_ENV !== "production" && G("data() should return an object.");
1997
- else if (e.data = /* @__PURE__ */ tn(t), process.env.NODE_ENV !== "production") for (let e in t) ee("Data", e), ta(e[0]) || Object.defineProperty(r, e, {
1997
+ else if (e.data = /* @__PURE__ */ tn(t), process.env.NODE_ENV !== "production") for (let e in t) M("Data", e), ta(e[0]) || Object.defineProperty(r, e, {
1998
1998
  configurable: !0,
1999
1999
  enumerable: !0,
2000
2000
  get: () => t[e],
@@ -2015,7 +2015,7 @@ function ua(e) {
2015
2015
  configurable: !0,
2016
2016
  get: () => o.value,
2017
2017
  set: (e) => o.value = e
2018
- }), process.env.NODE_ENV !== "production" && ee("Computed", e);
2018
+ }), process.env.NODE_ENV !== "production" && M("Computed", e);
2019
2019
  }
2020
2020
  if (s) for (let e in s) pa(s[e], r, n, e);
2021
2021
  if (c) {
@@ -2038,7 +2038,7 @@ function ua(e) {
2038
2038
  });
2039
2039
  });
2040
2040
  } else e.exposed ||= {};
2041
- x && e.render === S && (e.render = x), O != null && (e.inheritAttrs = O), k && (e.components = k), j && (e.directives = j), E && Di(e);
2041
+ x && e.render === S && (e.render = x), O != null && (e.inheritAttrs = O), k && (e.components = k), ee && (e.directives = ee), E && Di(e);
2042
2042
  }
2043
2043
  function da(e, t, n = S) {
2044
2044
  A(e) && (e = ya(e));
@@ -2645,9 +2645,9 @@ function Oo(e, t) {
2645
2645
  e == null ? v(t, n, r, o) : process.env.NODE_ENV !== "production" && y(e, t, n, o);
2646
2646
  break;
2647
2647
  case K:
2648
- M(e, t, n, r, i, a, o, s, c);
2648
+ j(e, t, n, r, i, a, o, s, c);
2649
2649
  break;
2650
- default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ? ee(e, t, n, r, i, a, o, s, c) : d & 64 || d & 128 ? l.process(e, t, n, r, i, a, o, s, c, pe) : process.env.NODE_ENV !== "production" && G("Invalid VNode type:", l, `(${typeof l})`);
2650
+ default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ? M(e, t, n, r, i, a, o, s, c) : d & 64 || d & 128 ? l.process(e, t, n, r, i, a, o, s, c, pe) : process.env.NODE_ENV !== "production" && G("Invalid VNode type:", l, `(${typeof l})`);
2651
2651
  }
2652
2652
  u != null && i ? ji(u, e && e.ref, a, t || e, !t) : u == null && e && e.ref != null && ji(e.ref, null, a, e, !0);
2653
2653
  }, g = (e, t, n, i) => {
@@ -2724,7 +2724,7 @@ function Oo(e, t) {
2724
2724
  l |= e.patchFlag & 16;
2725
2725
  let p = e.props || b, m = t.props || b, h;
2726
2726
  if (n && Ao(n, !1), (h = m.onVnodeBeforeUpdate) && ds(h, n, t, e), f && Hr(t, e, n, "beforeUpdate"), n && Ao(n, !0), (process.env.NODE_ENV !== "production" && cr || d && (!e.dynamicChildren || e.dynamicChildren.length !== d.length)) && (l = 0, s = !1, d = null), (p.innerHTML && m.innerHTML == null || p.textContent && m.textContent == null) && u(c, ""), d ? (A(e.dynamicChildren, d, c, n, r, ko(t, i), o), process.env.NODE_ENV !== "production" && Mo(e, t)) : s || te(e, t, c, null, n, r, ko(t, i), o, !1), l > 0) {
2727
- if (l & 16) j(c, p, m, n, i);
2727
+ if (l & 16) ee(c, p, m, n, i);
2728
2728
  else if (l & 2 && p.class !== m.class && a(c, "class", null, m.class, i), l & 4 && a(c, "style", p.style, m.style, i), l & 8) {
2729
2729
  let e = t.dynamicProps;
2730
2730
  for (let t = 0; t < e.length; t++) {
@@ -2733,7 +2733,7 @@ function Oo(e, t) {
2733
2733
  }
2734
2734
  }
2735
2735
  l & 1 && e.children !== t.children && u(c, t.children);
2736
- } else !s && d == null && j(c, p, m, n, i);
2736
+ } else !s && d == null && ee(c, p, m, n, i);
2737
2737
  ((h = m.onVnodeUpdated) || f) && Eo(() => {
2738
2738
  h && ds(h, n, t, e), f && Hr(t, e, n, "updated");
2739
2739
  }, r);
@@ -2742,7 +2742,7 @@ function Oo(e, t) {
2742
2742
  let c = e[s], l = t[s], u = c.el && (c.type === K || !Xo(c, l) || c.shapeFlag & 198) ? d(c.el) : n;
2743
2743
  h(c, l, u, null, r, i, a, o, !0);
2744
2744
  }
2745
- }, j = (e, t, n, r, i) => {
2745
+ }, ee = (e, t, n, r, i) => {
2746
2746
  if (t !== n) {
2747
2747
  if (t !== b) for (let o in t) !se(o) && !(o in n) && a(e, o, t[o], null, i, r);
2748
2748
  for (let o in n) {
@@ -2752,10 +2752,10 @@ function Oo(e, t) {
2752
2752
  }
2753
2753
  "value" in n && a(e, "value", t.value, n.value, i);
2754
2754
  }
2755
- }, M = (e, t, n, i, a, o, c, l, u) => {
2755
+ }, j = (e, t, n, i, a, o, c, l, u) => {
2756
2756
  let d = t.el = e ? e.el : s(""), f = t.anchor = e ? e.anchor : s(""), { patchFlag: p, dynamicChildren: m, slotScopeIds: h } = t;
2757
2757
  process.env.NODE_ENV !== "production" && (cr || p & 2048) && (p = 0, u = !1, m = null), h && (l = l ? l.concat(h) : h), e == null ? (r(d, n, i), r(f, n, i), O(t.children || [], n, f, a, o, c, l, u)) : p > 0 && p & 64 && m && e.dynamicChildren && e.dynamicChildren.length === m.length ? (A(e.dynamicChildren, m, n, a, o, c, l), process.env.NODE_ENV === "production" ? (t.key != null || a && t === a.subTree) && Mo(e, t, !0) : Mo(e, t)) : te(e, t, n, f, a, o, c, l, u);
2758
- }, ee = (e, t, n, r, i, a, o, s, c) => {
2758
+ }, M = (e, t, n, r, i, a, o, s, c) => {
2759
2759
  t.slotScopeIds = s, e == null ? t.shapeFlag & 512 ? i.ctx.activate(t, n, r, o, c) : N(t, n, r, i, a, o, c) : P(e, t, c);
2760
2760
  }, N = (e, t, n, r, i, a, o) => {
2761
2761
  let s = e.component = ms(e, r, i);
@@ -3877,8 +3877,8 @@ function Pc(e, t, n, r) {
3877
3877
  return e.tagName === "TEXTAREA" && (t === "width" || t === "height") && P(r) && n === r;
3878
3878
  }
3879
3879
  var Fc = "http://www.w3.org/1999/xlink";
3880
- function Ic(e, t, n, r, i, a = Ne(t)) {
3881
- r && t.startsWith("xlink:") ? n == null ? e.removeAttributeNS(Fc, t.slice(6, t.length)) : e.setAttributeNS(Fc, t, n) : n == null || a && !Pe(n) ? e.removeAttribute(t) : e.setAttribute(t, a ? "" : F(n) ? String(n) : n);
3880
+ function Ic(e, t, n, r, i, a = Pe(t)) {
3881
+ r && t.startsWith("xlink:") ? n == null ? e.removeAttributeNS(Fc, t.slice(6, t.length)) : e.setAttributeNS(Fc, t, n) : n == null || a && !z(n) ? e.removeAttribute(t) : e.setAttribute(t, a ? "" : F(n) ? String(n) : n);
3882
3882
  }
3883
3883
  function Lc(e, t, n, r, i) {
3884
3884
  if (t === "innerHTML" || t === "textContent") {
@@ -3894,7 +3894,7 @@ function Lc(e, t, n, r, i) {
3894
3894
  let o = !1;
3895
3895
  if (n === "" || n == null) {
3896
3896
  let r = typeof e[t];
3897
- r === "boolean" ? n = Pe(n) : n == null && r === "string" ? (n = "", o = !0) : r === "number" && (n = 0, o = !0);
3897
+ r === "boolean" ? n = z(n) : n == null && r === "string" ? (n = "", o = !0) : r === "number" && (n = 0, o = !0);
3898
3898
  }
3899
3899
  try {
3900
3900
  e[t] = n;
@@ -4052,7 +4052,7 @@ function pl(e) {
4052
4052
  }
4053
4053
  function ml(e) {
4054
4054
  Object.defineProperty(e.config, "isNativeTag", {
4055
- value: (e) => ke(e) || Ae(e) || je(e),
4055
+ value: (e) => Ae(e) || je(e) || Me(e),
4056
4056
  writable: !1
4057
4057
  });
4058
4058
  }
@@ -5930,7 +5930,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
5930
5930
  return i;
5931
5931
  }).map((e) => `(${e})`).join(t);
5932
5932
  }
5933
- var w = /\b\B/, T = "[a-zA-Z]\\w*", E = "[a-zA-Z_]\\w*", D = "\\b\\d+(\\.\\d+)?", O = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", k = "\\b(0b[01]+)", A = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", j = (e = {}) => {
5933
+ var w = /\b\B/, T = "[a-zA-Z]\\w*", E = "[a-zA-Z_]\\w*", D = "\\b\\d+(\\.\\d+)?", O = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", k = "\\b(0b[01]+)", A = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", ee = (e = {}) => {
5934
5934
  let t = /^#![ ]*\//;
5935
5935
  return e.binary && (e.begin = _(t, /.*\b/, e.binary, /\b.*/)), a({
5936
5936
  scope: "meta",
@@ -5941,21 +5941,21 @@ var rd = /* @__PURE__ */ m(((e, t) => {
5941
5941
  e.index !== 0 && t.ignoreMatch();
5942
5942
  }
5943
5943
  }, e);
5944
- }, M = {
5944
+ }, j = {
5945
5945
  begin: "\\\\[\\s\\S]",
5946
5946
  relevance: 0
5947
- }, ee = {
5947
+ }, M = {
5948
5948
  scope: "string",
5949
5949
  begin: "'",
5950
5950
  end: "'",
5951
5951
  illegal: "\\n",
5952
- contains: [M]
5952
+ contains: [j]
5953
5953
  }, N = {
5954
5954
  scope: "string",
5955
5955
  begin: "\"",
5956
5956
  end: "\"",
5957
5957
  illegal: "\\n",
5958
- contains: [M]
5958
+ contains: [j]
5959
5959
  }, P = { begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ }, F = function(e, t, n = {}) {
5960
5960
  let r = a({
5961
5961
  scope: "comment",
@@ -5974,8 +5974,8 @@ var rd = /* @__PURE__ */ m(((e, t) => {
5974
5974
  return r.contains.push({ begin: _(/[ ]+/, "(", i, /[.]?[:]?([.][ ]|[ ])/, "){3}") }), r;
5975
5975
  }, I = F("//", "$"), te = F("/\\*", "\\*/"), ne = F("#", "$"), re = /*#__PURE__*/ Object.freeze({
5976
5976
  __proto__: null,
5977
- APOS_STRING_MODE: ee,
5978
- BACKSLASH_ESCAPE: M,
5977
+ APOS_STRING_MODE: M,
5978
+ BACKSLASH_ESCAPE: j,
5979
5979
  BINARY_NUMBER_MODE: {
5980
5980
  scope: "number",
5981
5981
  begin: k,
@@ -6020,15 +6020,15 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6020
6020
  scope: "regexp",
6021
6021
  begin: /\/(?=[^/\n]*\/)/,
6022
6022
  end: /\/[gimuy]*/,
6023
- contains: [M, {
6023
+ contains: [j, {
6024
6024
  begin: /\[/,
6025
6025
  end: /\]/,
6026
6026
  relevance: 0,
6027
- contains: [M]
6027
+ contains: [j]
6028
6028
  }]
6029
6029
  },
6030
6030
  RE_STARTERS_RE: A,
6031
- SHEBANG: j,
6031
+ SHEBANG: ee,
6032
6032
  TITLE_MODE: {
6033
6033
  scope: "title",
6034
6034
  begin: T,
@@ -6226,11 +6226,11 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6226
6226
  return a(e, { variants: null }, t);
6227
6227
  })), e.cachedVariants ? e.cachedVariants : Ee(e) ? a(e, { starts: e.starts ? a(e.starts) : null }) : Object.isFrozen(e) ? a(e) : e;
6228
6228
  }
6229
- var De = "11.11.1", z = class extends Error {
6229
+ var De = "11.11.1", Oe = class extends Error {
6230
6230
  constructor(e, t) {
6231
6231
  super(e), this.name = "HTMLInjectionError", this.html = t;
6232
6232
  }
6233
- }, Oe = i, ke = a, Ae = Symbol("nomatch"), je = 7, Me = function(e) {
6233
+ }, ke = i, Ae = a, je = Symbol("nomatch"), Me = 7, Ne = function(e) {
6234
6234
  let t = Object.create(null), i = Object.create(null), a = [], o = !0, s = "Could not find the language '{}', did you forget to load/include a language module?", c = {
6235
6235
  disableAutodetect: !0,
6236
6236
  name: "Plain text",
@@ -6253,10 +6253,10 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6253
6253
  t += e.parentNode ? e.parentNode.className : "";
6254
6254
  let n = l.languageDetectRe.exec(t);
6255
6255
  if (n) {
6256
- let t = ee(n[1]);
6256
+ let t = M(n[1]);
6257
6257
  return t || (_e(s.replace("{}", n[1])), _e("Falling back to no-highlight mode for this block.", e)), t ? n[1] : "no-highlight";
6258
6258
  }
6259
- return t.split(/\s+/).find((e) => u(e) || ee(e));
6259
+ return t.split(/\s+/).find((e) => u(e) || M(e));
6260
6260
  }
6261
6261
  function p(e, t, n) {
6262
6262
  let r = "", i = "";
@@ -6276,7 +6276,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6276
6276
  }
6277
6277
  function d() {
6278
6278
  if (!A.keywords) {
6279
- M.addText(N);
6279
+ j.addText(N);
6280
6280
  return;
6281
6281
  }
6282
6282
  let e = 0;
@@ -6287,7 +6287,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6287
6287
  let r = D.case_insensitive ? t[0].toLowerCase() : t[0], i = u(A, r);
6288
6288
  if (i) {
6289
6289
  let [e, a] = i;
6290
- if (M.addText(n), n = "", c[r] = (c[r] || 0) + 1, c[r] <= je && (P += a), e.startsWith("_")) n += t[0];
6290
+ if (j.addText(n), n = "", c[r] = (c[r] || 0) + 1, c[r] <= Me && (P += a), e.startsWith("_")) n += t[0];
6291
6291
  else {
6292
6292
  let n = D.classNameAliases[e] || e;
6293
6293
  m(t[0], n);
@@ -6295,25 +6295,25 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6295
6295
  } else n += t[0];
6296
6296
  e = A.keywordPatternRe.lastIndex, t = A.keywordPatternRe.exec(N);
6297
6297
  }
6298
- n += N.substring(e), M.addText(n);
6298
+ n += N.substring(e), j.addText(n);
6299
6299
  }
6300
6300
  function f() {
6301
6301
  if (N === "") return;
6302
6302
  let e = null;
6303
6303
  if (typeof A.subLanguage == "string") {
6304
6304
  if (!t[A.subLanguage]) {
6305
- M.addText(N);
6305
+ j.addText(N);
6306
6306
  return;
6307
6307
  }
6308
- e = v(A.subLanguage, N, !0, j[A.subLanguage]), j[A.subLanguage] = e._top;
6308
+ e = v(A.subLanguage, N, !0, ee[A.subLanguage]), ee[A.subLanguage] = e._top;
6309
6309
  } else e = S(N, A.subLanguage.length ? A.subLanguage : null);
6310
- A.relevance > 0 && (P += e.relevance), M.__addSublanguage(e._emitter, e.language);
6310
+ A.relevance > 0 && (P += e.relevance), j.__addSublanguage(e._emitter, e.language);
6311
6311
  }
6312
6312
  function p() {
6313
6313
  A.subLanguage == null ? d() : f(), N = "";
6314
6314
  }
6315
6315
  function m(e, t) {
6316
- e !== "" && (M.startScope(t), M.addText(e), M.endScope());
6316
+ e !== "" && (j.startScope(t), j.addText(e), j.endScope());
6317
6317
  }
6318
6318
  function h(e, t) {
6319
6319
  let n = 1, r = t.length - 1;
@@ -6327,7 +6327,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6327
6327
  }
6328
6328
  }
6329
6329
  function g(e, t) {
6330
- return e.scope && typeof e.scope == "string" && M.openNode(D.classNameAliases[e.scope] || e.scope), e.beginScope && (e.beginScope._wrap ? (m(N, D.classNameAliases[e.beginScope._wrap] || e.beginScope._wrap), N = "") : e.beginScope._multi && (h(e.beginScope, t), N = "")), A = Object.create(e, { parent: { value: A } }), A;
6330
+ return e.scope && typeof e.scope == "string" && j.openNode(D.classNameAliases[e.scope] || e.scope), e.beginScope && (e.beginScope._wrap ? (m(N, D.classNameAliases[e.beginScope._wrap] || e.beginScope._wrap), N = "") : e.beginScope._multi && (h(e.beginScope, t), N = "")), A = Object.create(e, { parent: { value: A } }), A;
6331
6331
  }
6332
6332
  function _(e, t, n) {
6333
6333
  let i = x(e.endRe, n);
@@ -6353,18 +6353,18 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6353
6353
  }
6354
6354
  function C(e) {
6355
6355
  let t = e[0], r = n.substring(e.index), i = _(A, e, r);
6356
- if (!i) return Ae;
6356
+ if (!i) return je;
6357
6357
  let a = A;
6358
6358
  A.endScope && A.endScope._wrap ? (p(), m(t, A.endScope._wrap)) : A.endScope && A.endScope._multi ? (p(), h(A.endScope, e)) : a.skip ? N += t : (a.returnEnd || a.excludeEnd || (N += t), p(), a.excludeEnd && (N = t));
6359
6359
  do
6360
- A.scope && M.closeNode(), !A.skip && !A.subLanguage && (P += A.relevance), A = A.parent;
6360
+ A.scope && j.closeNode(), !A.skip && !A.subLanguage && (P += A.relevance), A = A.parent;
6361
6361
  while (A !== i.parent);
6362
6362
  return i.starts && g(i.starts, e), a.returnEnd ? 0 : t.length;
6363
6363
  }
6364
6364
  function w() {
6365
6365
  let e = [];
6366
6366
  for (let t = A; t !== D; t = t.parent) t.scope && e.unshift(t.scope);
6367
- e.forEach((e) => M.openNode(e));
6367
+ e.forEach((e) => j.openNode(e));
6368
6368
  }
6369
6369
  let T = {};
6370
6370
  function E(t, r) {
@@ -6383,19 +6383,19 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6383
6383
  throw e.mode = A, e;
6384
6384
  } else if (r.type === "end") {
6385
6385
  let e = C(r);
6386
- if (e !== Ae) return e;
6386
+ if (e !== je) return e;
6387
6387
  }
6388
6388
  if (r.type === "illegal" && a === "") return N += "\n", 1;
6389
6389
  if (I > 1e5 && I > r.index * 3) throw /* @__PURE__ */ Error("potential infinite loop, way more iterations than matches");
6390
6390
  return N += a, a.length;
6391
6391
  }
6392
- let D = ee(e);
6392
+ let D = M(e);
6393
6393
  if (!D) throw ge(s.replace("{}", e)), Error("Unknown language: \"" + e + "\"");
6394
- let O = Te(D), k = "", A = a || O, j = {}, M = new l.__emitter(l);
6394
+ let O = Te(D), k = "", A = a || O, ee = {}, j = new l.__emitter(l);
6395
6395
  w();
6396
6396
  let N = "", P = 0, F = 0, I = 0, te = !1;
6397
6397
  try {
6398
- if (D.__emitTokens) D.__emitTokens(n, M);
6398
+ if (D.__emitTokens) D.__emitTokens(n, j);
6399
6399
  else {
6400
6400
  for (A.matcher.considerAll();;) {
6401
6401
  I++, te ? te = !1 : A.matcher.considerAll(), A.matcher.lastIndex = F;
@@ -6406,18 +6406,18 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6406
6406
  }
6407
6407
  E(n.substring(F));
6408
6408
  }
6409
- return M.finalize(), k = M.toHTML(), {
6409
+ return j.finalize(), k = j.toHTML(), {
6410
6410
  language: e,
6411
6411
  value: k,
6412
6412
  relevance: P,
6413
6413
  illegal: !1,
6414
- _emitter: M,
6414
+ _emitter: j,
6415
6415
  _top: A
6416
6416
  };
6417
6417
  } catch (t) {
6418
6418
  if (t.message && t.message.includes("Illegal")) return {
6419
6419
  language: e,
6420
- value: Oe(n),
6420
+ value: ke(n),
6421
6421
  illegal: !0,
6422
6422
  relevance: 0,
6423
6423
  _illegalBy: {
@@ -6427,15 +6427,15 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6427
6427
  mode: t.mode,
6428
6428
  resultSoFar: k
6429
6429
  },
6430
- _emitter: M
6430
+ _emitter: j
6431
6431
  };
6432
6432
  if (o) return {
6433
6433
  language: e,
6434
- value: Oe(n),
6434
+ value: ke(n),
6435
6435
  illegal: !1,
6436
6436
  relevance: 0,
6437
6437
  errorRaised: t,
6438
- _emitter: M,
6438
+ _emitter: j,
6439
6439
  _top: A
6440
6440
  };
6441
6441
  throw t;
@@ -6443,7 +6443,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6443
6443
  }
6444
6444
  function b(e) {
6445
6445
  let t = {
6446
- value: Oe(e),
6446
+ value: ke(e),
6447
6447
  illegal: !1,
6448
6448
  relevance: 0,
6449
6449
  _top: c,
@@ -6453,13 +6453,13 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6453
6453
  }
6454
6454
  function S(e, n) {
6455
6455
  n = n || l.languages || Object.keys(t);
6456
- let r = b(e), i = n.filter(ee).filter(P).map((t) => v(t, e, !1));
6456
+ let r = b(e), i = n.filter(M).filter(P).map((t) => v(t, e, !1));
6457
6457
  i.unshift(r);
6458
6458
  let [a, o] = i.sort((e, t) => {
6459
6459
  if (e.relevance !== t.relevance) return t.relevance - e.relevance;
6460
6460
  if (e.language && t.language) {
6461
- if (ee(e.language).supersetOf === t.language) return 1;
6462
- if (ee(t.language).supersetOf === e.language) return -1;
6461
+ if (M(e.language).supersetOf === t.language) return 1;
6462
+ if (M(t.language).supersetOf === e.language) return -1;
6463
6463
  }
6464
6464
  return 0;
6465
6465
  }), s = a;
@@ -6479,7 +6479,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6479
6479
  console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", e);
6480
6480
  return;
6481
6481
  }
6482
- if (e.children.length > 0 && (l.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(e)), l.throwUnescapedHTML)) throw new z("One of your code blocks includes unescaped HTML.", e.innerHTML);
6482
+ if (e.children.length > 0 && (l.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(e)), l.throwUnescapedHTML)) throw new Oe("One of your code blocks includes unescaped HTML.", e.innerHTML);
6483
6483
  t = e;
6484
6484
  let r = t.textContent, i = n ? p(r, {
6485
6485
  language: n,
@@ -6499,7 +6499,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6499
6499
  });
6500
6500
  }
6501
6501
  function T(e) {
6502
- l = ke(l, e);
6502
+ l = Ae(l, e);
6503
6503
  }
6504
6504
  let E = () => {
6505
6505
  k(), ve("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
@@ -6529,14 +6529,14 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6529
6529
  }
6530
6530
  i.name ||= n, t[n] = i, i.rawDefinition = r.bind(null, e), i.aliases && N(i.aliases, { languageName: n });
6531
6531
  }
6532
- function j(e) {
6532
+ function ee(e) {
6533
6533
  delete t[e];
6534
6534
  for (let t of Object.keys(i)) i[t] === e && delete i[t];
6535
6535
  }
6536
- function M() {
6536
+ function j() {
6537
6537
  return Object.keys(t);
6538
6538
  }
6539
- function ee(e) {
6539
+ function M(e) {
6540
6540
  return e = (e || "").toLowerCase(), t[e] || t[i[e]];
6541
6541
  }
6542
6542
  function N(e, { languageName: t }) {
@@ -6545,7 +6545,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6545
6545
  });
6546
6546
  }
6547
6547
  function P(e) {
6548
- let t = ee(e);
6548
+ let t = M(e);
6549
6549
  return t && !t.disableAutodetect;
6550
6550
  }
6551
6551
  function F(e) {
@@ -6581,12 +6581,12 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6581
6581
  initHighlighting: E,
6582
6582
  initHighlightingOnLoad: D,
6583
6583
  registerLanguage: A,
6584
- unregisterLanguage: j,
6585
- listLanguages: M,
6586
- getLanguage: ee,
6584
+ unregisterLanguage: ee,
6585
+ listLanguages: j,
6586
+ getLanguage: M,
6587
6587
  registerAliases: N,
6588
6588
  autoDetection: P,
6589
- inherit: ke,
6589
+ inherit: Ae,
6590
6590
  addPlugin: I,
6591
6591
  removePlugin: te
6592
6592
  }), e.debugMode = function() {
@@ -6602,8 +6602,8 @@ var rd = /* @__PURE__ */ m(((e, t) => {
6602
6602
  };
6603
6603
  for (let e in re) typeof re[e] == "object" && n(re[e]);
6604
6604
  return Object.assign(e, re), e;
6605
- }, Ne = Me({});
6606
- Ne.newInstance = () => Me({}), t.exports = Ne, Ne.HighlightJS = Ne, Ne.default = Ne;
6605
+ }, Pe = Ne({});
6606
+ Pe.newInstance = () => Ne({}), t.exports = Pe, Pe.HighlightJS = Pe, Pe.default = Pe;
6607
6607
  })), id = /* @__PURE__ */ m(((e, t) => {
6608
6608
  function n(e) {
6609
6609
  let t = e.regex, n = t.concat(/[\p{L}_]/u, t.optional(/[\p{L}0-9_.-]*:/u), /[\p{L}0-9_.-]*/u), r = /[\p{L}0-9._:-]+/u, i = {
@@ -8895,17 +8895,17 @@ var rd = /* @__PURE__ */ m(((e, t) => {
8895
8895
  1: "keyword",
8896
8896
  3: "title.class"
8897
8897
  }
8898
- }] }, j = {
8898
+ }] }, ee = {
8899
8899
  relevance: 0,
8900
8900
  match: t.either(/\bJSON/, /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
8901
8901
  className: "title.class",
8902
8902
  keywords: { _: [...a, ...o] }
8903
- }, M = {
8903
+ }, j = {
8904
8904
  label: "use_strict",
8905
8905
  className: "meta",
8906
8906
  relevance: 10,
8907
8907
  begin: /^\s*['"]use (strict|asm)['"]/
8908
- }, ee = {
8908
+ }, M = {
8909
8909
  variants: [{ match: [
8910
8910
  /function/,
8911
8911
  /\s+/,
@@ -8982,7 +8982,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
8982
8982
  keywords: h,
8983
8983
  exports: {
8984
8984
  PARAMS_CONTAINS: O,
8985
- CLASS_REFERENCE: j
8985
+ CLASS_REFERENCE: ee
8986
8986
  },
8987
8987
  illegal: /#(?![$_A-z])/,
8988
8988
  contains: [
@@ -8991,7 +8991,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
8991
8991
  binary: "node",
8992
8992
  relevance: 5
8993
8993
  }),
8994
- M,
8994
+ j,
8995
8995
  e.APOS_STRING_MODE,
8996
8996
  e.QUOTE_STRING_MODE,
8997
8997
  x,
@@ -9001,7 +9001,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
9001
9001
  T,
9002
9002
  { match: /\$\d+/ },
9003
9003
  y,
9004
- j,
9004
+ ee,
9005
9005
  {
9006
9006
  scope: "attr",
9007
9007
  match: d + t.lookahead(":"),
@@ -9074,7 +9074,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
9074
9074
  }
9075
9075
  ]
9076
9076
  },
9077
- ee,
9077
+ M,
9078
9078
  { beginKeywords: "while if switch catch for" },
9079
9079
  {
9080
9080
  begin: "\\b(?!function)" + e.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
@@ -11352,16 +11352,16 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11352
11352
  }], A = {
11353
11353
  match: /->/,
11354
11354
  relevance: 0
11355
- }, j = [A, {
11355
+ }, ee = [A, {
11356
11356
  className: "operator",
11357
11357
  relevance: 0,
11358
11358
  variants: [{ match: v }, { match: `\\.(\\.|${_})+` }]
11359
- }], M = "([0-9]_*)+", ee = "([0-9a-fA-F]_*)+", N = {
11359
+ }], j = "([0-9]_*)+", M = "([0-9a-fA-F]_*)+", N = {
11360
11360
  className: "number",
11361
11361
  relevance: 0,
11362
11362
  variants: [
11363
- { match: `\\b(${M})(\\.(${M}))?([eE][+-]?(${M}))?\\b` },
11364
- { match: `\\b0x(${ee})(\\.(${ee}))?([pP][+-]?(${M}))?\\b` },
11363
+ { match: `\\b(${j})(\\.(${j}))?([eE][+-]?(${j}))?\\b` },
11364
+ { match: `\\b0x(${M})(\\.(${M}))?([pP][+-]?(${j}))?\\b` },
11365
11365
  { match: /\b0o([0-7]_*)+\b/ },
11366
11366
  { match: /\b0b([01]_*)+\b/ }
11367
11367
  ]
@@ -11447,7 +11447,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11447
11447
  end: /\)/,
11448
11448
  keywords: w,
11449
11449
  contains: [
11450
- ...j,
11450
+ ...ee,
11451
11451
  N,
11452
11452
  re
11453
11453
  ]
@@ -11516,7 +11516,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11516
11516
  se,
11517
11517
  ...O,
11518
11518
  ...k,
11519
- ...j,
11519
+ ...ee,
11520
11520
  N,
11521
11521
  re,
11522
11522
  ...le,
@@ -11547,7 +11547,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11547
11547
  },
11548
11548
  ...a,
11549
11549
  ...O,
11550
- ...j,
11550
+ ...ee,
11551
11551
  N,
11552
11552
  re,
11553
11553
  ...ue,
@@ -11660,7 +11660,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11660
11660
  let n = [
11661
11661
  ...O,
11662
11662
  ...k,
11663
- ...j,
11663
+ ...ee,
11664
11664
  N,
11665
11665
  re,
11666
11666
  ...le
@@ -11692,7 +11692,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
11692
11692
  se,
11693
11693
  ...O,
11694
11694
  ...k,
11695
- ...j,
11695
+ ...ee,
11696
11696
  N,
11697
11697
  re,
11698
11698
  ...le,
@@ -12068,17 +12068,17 @@ var rd = /* @__PURE__ */ m(((e, t) => {
12068
12068
  1: "keyword",
12069
12069
  3: "title.class"
12070
12070
  }
12071
- }] }, j = {
12071
+ }] }, ee = {
12072
12072
  relevance: 0,
12073
12073
  match: t.either(/\bJSON/, /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
12074
12074
  className: "title.class",
12075
12075
  keywords: { _: [...a, ...o] }
12076
- }, M = {
12076
+ }, j = {
12077
12077
  label: "use_strict",
12078
12078
  className: "meta",
12079
12079
  relevance: 10,
12080
12080
  begin: /^\s*['"]use (strict|asm)['"]/
12081
- }, ee = {
12081
+ }, M = {
12082
12082
  variants: [{ match: [
12083
12083
  /function/,
12084
12084
  /\s+/,
@@ -12155,7 +12155,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
12155
12155
  keywords: h,
12156
12156
  exports: {
12157
12157
  PARAMS_CONTAINS: O,
12158
- CLASS_REFERENCE: j
12158
+ CLASS_REFERENCE: ee
12159
12159
  },
12160
12160
  illegal: /#(?![$_A-z])/,
12161
12161
  contains: [
@@ -12164,7 +12164,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
12164
12164
  binary: "node",
12165
12165
  relevance: 5
12166
12166
  }),
12167
- M,
12167
+ j,
12168
12168
  e.APOS_STRING_MODE,
12169
12169
  e.QUOTE_STRING_MODE,
12170
12170
  x,
@@ -12174,7 +12174,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
12174
12174
  T,
12175
12175
  { match: /\$\d+/ },
12176
12176
  y,
12177
- j,
12177
+ ee,
12178
12178
  {
12179
12179
  scope: "attr",
12180
12180
  match: d + t.lookahead(":"),
@@ -12247,7 +12247,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
12247
12247
  }
12248
12248
  ]
12249
12249
  },
12250
- ee,
12250
+ M,
12251
12251
  { beginKeywords: "while if switch catch for" },
12252
12252
  {
12253
12253
  begin: "\\b(?!function)" + e.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
@@ -13558,14 +13558,17 @@ app.mount('#app');
13558
13558
  function C() {
13559
13559
  n.onUndo?.() && (i.error = null);
13560
13560
  }
13561
- let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U(!1), O = /* @__PURE__ */ U({}), k = Vs(() => i.messages.length > 0), A = Vs(() => i.messages.some((e) => e.role === "user")), j = Vs(() => (n.debugLogs?.length ?? 0) > 0);
13561
+ let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U(!1), O = /* @__PURE__ */ U({}), k = Vs(() => i.messages.length > 0), A = Vs(() => i.messages.some((e) => e.role === "user")), ee = Vs(() => (n.debugLogs?.length ?? 0) > 0);
13562
+ function j(e) {
13563
+ return O.value[e] !== !1;
13564
+ }
13562
13565
  function M(e) {
13563
- O.value[e] = !O.value[e];
13566
+ O.value[e] = !j(e);
13564
13567
  }
13565
- function ee(e) {
13568
+ function N(e) {
13566
13569
  return e.status === "running" ? "⏳" : e.status === "error" ? "❌" : "✅";
13567
13570
  }
13568
- function N(e) {
13571
+ function P(e) {
13569
13572
  let t = [];
13570
13573
  for (let n of e) {
13571
13574
  let e = t.length ? t[t.length - 1] : null;
@@ -13584,38 +13587,38 @@ app.mount('#app');
13584
13587
  children: e.children
13585
13588
  }));
13586
13589
  }
13587
- function P(e) {
13590
+ function F(e) {
13588
13591
  return e === "running" ? "⏳" : e === "error" ? "❌" : "✅";
13589
13592
  }
13590
- function F(e) {
13593
+ function I(e) {
13591
13594
  let t = i.messages[e];
13592
13595
  return !!t && t.role === "assistant" && i.loading && e === i.messages.length - 1 && !t.content && !t.reasoning;
13593
13596
  }
13594
- function I() {
13597
+ function te() {
13595
13598
  w.value.trim() && (s(w.value), w.value = "");
13596
13599
  }
13597
- function te(e) {
13598
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), I());
13599
- }
13600
13600
  function ne(e) {
13601
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), te());
13602
+ }
13603
+ function re(e) {
13601
13604
  return new Date(e).toLocaleTimeString("zh-CN", {
13602
13605
  hour: "2-digit",
13603
13606
  minute: "2-digit"
13604
13607
  });
13605
13608
  }
13606
- let re = Vs(() => {
13609
+ let ie = Vs(() => {
13607
13610
  let e = n.getInfo?.();
13608
13611
  return {
13609
13612
  mcp: e?.mcp?.servers?.length ?? 0,
13610
13613
  tools: e?.tools?.length ?? 0
13611
13614
  };
13612
13615
  });
13613
- function ie(e) {
13616
+ function ae(e) {
13614
13617
  wl(e).then((e) => {
13615
- e && (ae.value = !0, setTimeout(() => ae.value = !1, 1500));
13618
+ e && (oe.value = !0, setTimeout(() => oe.value = !1, 1500));
13616
13619
  });
13617
13620
  }
13618
- let ae = /* @__PURE__ */ U(!1), oe = Vs(() => {
13621
+ let oe = /* @__PURE__ */ U(!1), se = Vs(() => {
13619
13622
  if (!n.drawer || n.drawerWidth == null) return null;
13620
13623
  let e = n.drawerWidth;
13621
13624
  return typeof e == "number" ? `${e}px` : e;
@@ -13629,9 +13632,9 @@ app.mount('#app');
13629
13632
  collapsed: !T.value && !e.drawer,
13630
13633
  drawer: e.drawer
13631
13634
  }]),
13632
- style: Se(oe.value ? {
13633
- width: oe.value,
13634
- maxWidth: oe.value
13635
+ style: Se(se.value ? {
13636
+ width: se.value,
13637
+ maxWidth: se.value
13635
13638
  } : null)
13636
13639
  }, [
13637
13640
  Y("div", ch, [Y("div", lh, [
@@ -13654,7 +13657,7 @@ app.mount('#app');
13654
13657
  Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
13655
13658
  Y("path", { d: "M9 2h6" }),
13656
13659
  Y("path", { d: "M9 18h6" })
13657
- ], -1), j.value ? (q(), J("span", ph, B(e.debugLogs?.length), 1)) : X("", !0)], 2),
13660
+ ], -1), ee.value ? (q(), J("span", ph, B(e.debugLogs?.length), 1)) : X("", !0)], 2),
13658
13661
  n.onAddSkill ? (q(), J("button", {
13659
13662
  key: 0,
13660
13663
  class: R(["action-btn", { active: D.value }]),
@@ -13715,20 +13718,20 @@ app.mount('#app');
13715
13718
  }, [e.showAvatar ? (q(), J("div", bh, B(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", xh, [
13716
13719
  t.role === "assistant" && t.reasoning ? (q(), J("div", {
13717
13720
  key: 0,
13718
- class: R(["reasoning-block", { expanded: O.value[n] }])
13721
+ class: R(["reasoning-block", { expanded: j(n) }])
13719
13722
  }, [Y("div", {
13720
13723
  class: "reasoning-header",
13721
13724
  onClick: (e) => M(n)
13722
13725
  }, [
13723
13726
  s[29] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
13724
13727
  s[30] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
13725
- Y("span", Ch, B(O.value[n] ? "▾" : "▸"), 1)
13726
- ], 8, Sh), O.value[n] ? (q(), J("div", wh, B(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
13727
- t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", Th, [(q(!0), J(K, null, Qi(N(t.steps), (e, t) => (q(), J("div", {
13728
+ Y("span", Ch, B(j(n) ? "▾" : "▸"), 1)
13729
+ ], 8, Sh), j(n) ? (q(), J("div", wh, B(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
13730
+ t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", Th, [(q(!0), J(K, null, Qi(P(t.steps), (e, t) => (q(), J("div", {
13728
13731
  key: t,
13729
13732
  class: "step-item"
13730
13733
  }, [Y("div", Eh, [
13731
- Y("span", Dh, B(P(e.status)), 1),
13734
+ Y("span", Dh, B(F(e.status)), 1),
13732
13735
  Y("span", Oh, B(e.name), 1),
13733
13736
  e.count > 1 ? (q(), J("span", kh, "×" + B(e.count), 1)) : X("", !0),
13734
13737
  e.status === "running" ? (q(), J("span", Ah, "执行中…")) : X("", !0)
@@ -13736,11 +13739,11 @@ app.mount('#app');
13736
13739
  key: t,
13737
13740
  class: "step-child"
13738
13741
  }, [
13739
- Y("span", Mh, B(ee(e)), 1),
13742
+ Y("span", Mh, B(N(e)), 1),
13740
13743
  Y("span", Nh, B(e.name), 1),
13741
13744
  e.status === "running" ? (q(), J("span", Ph, "…")) : X("", !0)
13742
13745
  ]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
13743
- Y("div", { class: R(["message-bubble", { typing: F(n) }]) }, [F(n) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
13746
+ Y("div", { class: R(["message-bubble", { typing: I(n) }]) }, [I(n) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
13744
13747
  s[32] ||= Y("span", { class: "dot" }, null, -1),
13745
13748
  s[33] ||= Y("span", { class: "dot" }, null, -1),
13746
13749
  s[34] ||= Y("span", { class: "dot" }, null, -1)
@@ -13749,12 +13752,12 @@ app.mount('#app');
13749
13752
  content: t.content
13750
13753
  }, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [os(B(t.content), 1)], 64))], 64))], 2),
13751
13754
  t.role === "assistant" && W(i).loading && n === W(i).messages.length - 1 && t.content ? (q(), J("span", Ih)) : X("", !0),
13752
- Y("div", Lh, B(ne(t.timestamp)), 1),
13755
+ Y("div", Lh, B(re(t.timestamp)), 1),
13753
13756
  t.role === "assistant" && t.content && !W(i).loading && n === W(i).messages.length - 1 ? (q(), J("div", Rh, [Y("button", {
13754
13757
  class: "msg-action-btn",
13755
- title: ae.value ? "已复制" : "复制",
13756
- onClick: (e) => ie(t.content)
13757
- }, B(ae.value ? "✓ 已复制" : "📋 复制"), 9, zh), Y("button", {
13758
+ title: oe.value ? "已复制" : "复制",
13759
+ onClick: (e) => ae(t.content)
13760
+ }, B(oe.value ? "✓ 已复制" : "📋 复制"), 9, zh), Y("button", {
13758
13761
  class: "msg-action-btn",
13759
13762
  title: "重新生成",
13760
13763
  onClick: s[6] ||= (...e) => W(d) && W(d)(...e)
@@ -13850,7 +13853,7 @@ app.mount('#app');
13850
13853
  ])) : X("", !0),
13851
13854
  ts(ac, { name: "cs-slide" }, {
13852
13855
  default: zr(() => [Vr(Y("div", pg, [
13853
- n.getInfo ? (q(), J("span", mg, " 🔌" + B(re.value.mcp) + " · 🔧" + B(re.value.tools), 1)) : X("", !0),
13856
+ n.getInfo ? (q(), J("span", mg, " 🔌" + B(ie.value.mcp) + " · 🔧" + B(ie.value.tools), 1)) : X("", !0),
13854
13857
  S.value ? (q(), J("button", {
13855
13858
  key: 1,
13856
13859
  class: "undo-foot-btn",
@@ -13862,13 +13865,13 @@ app.mount('#app');
13862
13865
  class: "chat-input",
13863
13866
  placeholder: e.placeholder,
13864
13867
  rows: n.inputRows,
13865
- onKeydown: te
13868
+ onKeydown: ne
13866
13869
  }, null, 40, hg), [[al, w.value]]),
13867
13870
  Y("button", {
13868
13871
  class: R(["send-btn", { "stop-btn": W(i).loading }]),
13869
13872
  disabled: !W(i).loading && !w.value.trim(),
13870
13873
  title: W(i).loading ? "停止生成" : "发送",
13871
- onClick: s[20] ||= (e) => W(i).loading ? W(l)() : I()
13874
+ onClick: s[20] ||= (e) => W(i).loading ? W(l)() : te()
13872
13875
  }, [W(i).loading ? (q(), J("svg", _g, [...s[46] ||= [Y("rect", {
13873
13876
  x: "6",
13874
13877
  y: "6",
@@ -13914,7 +13917,7 @@ app.mount('#app');
13914
13917
  ])
13915
13918
  ], 6)], 64));
13916
13919
  }
13917
- }), [["__scopeId", "data-v-d3eca61c"]]);
13920
+ }), [["__scopeId", "data-v-58dec249"]]);
13918
13921
  function bg(e) {
13919
13922
  return e.replace(/^\/+/, "").replace(/\/+/g, "/");
13920
13923
  }
@@ -14233,47 +14236,51 @@ function Ug(e, t) {
14233
14236
  });
14234
14237
  }
14235
14238
  function Wg(e) {
14236
- let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = Bg, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = Eg({
14239
+ let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = Bg, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, onLlmChange: b, debug: x = !1 } = e, S = Eg({
14237
14240
  model: c,
14238
14241
  contextWindow: e.contextWindow,
14239
14242
  maxOutputTokens: e.maxOutputTokens
14240
- }), S = u ?? x.maxOutputTokens, C = Og(x.contextWindow), w = kg(x.contextWindow), T = /* @__PURE__ */ hn([]);
14241
- function E(e, t) {
14243
+ }), C = u ?? S.maxOutputTokens, w = Og(S.contextWindow), T = kg(S.contextWindow), E = /* @__PURE__ */ hn([]);
14244
+ function D(e, t) {
14242
14245
  let n = {
14243
14246
  timestamp: Date.now(),
14244
14247
  type: e,
14245
14248
  data: t
14246
14249
  };
14247
- T.value.push(n), T.value.length > Vg && T.value.splice(0, T.value.length - Vg), vn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
14250
+ E.value.push(n), E.value.length > Vg && E.value.splice(0, E.value.length - Vg), vn(E), y?.(n), x && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
14248
14251
  }
14249
- let D = (e) => {
14250
- T.value.push(e), T.value.length > Vg && T.value.splice(0, T.value.length - Vg), vn(T);
14251
- }, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new n({
14252
+ let O = (e) => {
14253
+ E.value.push(e), E.value.length > Vg && E.value.splice(0, E.value.length - Vg), vn(E);
14254
+ }, k = [...p.flatMap((e) => e.tools || []), ...f], A = e.llm ?? new n({
14252
14255
  apiKey: t,
14253
14256
  model: c,
14254
14257
  temperature: l,
14255
- maxTokens: S,
14258
+ maxTokens: C,
14256
14259
  configuration: r ? { baseURL: r } : void 0
14257
- }), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j = Ag();
14258
- function M() {
14260
+ }), ee = k.length > 0 ? A.bindTools?.(k) ?? A : A;
14261
+ function j() {
14262
+ ee = k.length > 0 ? A.bindTools?.(k) ?? A : A;
14263
+ }
14264
+ let M = Ag();
14265
+ function N() {
14259
14266
  let e = [d || "你是一个智能助手。"];
14260
14267
  for (let t of p) if (t.augmentPrompt) {
14261
- let n = t.augmentPrompt(j);
14268
+ let n = t.augmentPrompt(M);
14262
14269
  n && e.push(n);
14263
14270
  }
14264
14271
  return e.join("\n\n");
14265
14272
  }
14266
- function ee(e) {
14267
- let t = [new o(M())];
14273
+ function P(e) {
14274
+ let t = [new o(N())];
14268
14275
  for (let n of e) n.role === "user" ? t.push(new a(n.content)) : n.role === "assistant" ? t.push(new i(n.content)) : n.role === "system" && t.push(new o(n.content));
14269
14276
  return t;
14270
14277
  }
14271
- function N(e) {
14272
- let t = e.filter((e) => I(e) !== "system");
14273
- return [new o(M()), ...t];
14278
+ function F(e) {
14279
+ let t = e.filter((e) => ne(e) !== "system");
14280
+ return [new o(N()), ...t];
14274
14281
  }
14275
- async function P(e, t, n, r) {
14276
- let a = r ?? A;
14282
+ async function I(e, t, n, r) {
14283
+ let a = r ?? ee;
14277
14284
  return Sl(async () => {
14278
14285
  let r = null, o = "";
14279
14286
  try {
@@ -14312,7 +14319,7 @@ function Wg(e) {
14312
14319
  baseDelayMs: g,
14313
14320
  onRetry: ({ attempt: e, error: t, waitMs: n }) => {
14314
14321
  let r = t?.message ?? String(t);
14315
- E("error", {
14322
+ D("error", {
14316
14323
  stage: "model_retry",
14317
14324
  attempt: e,
14318
14325
  waitMs: n,
@@ -14321,8 +14328,8 @@ function Wg(e) {
14321
14328
  }
14322
14329
  });
14323
14330
  }
14324
- async function F(e) {
14325
- let t = O.find((t) => t.name === e.name);
14331
+ async function te(e) {
14332
+ let t = k.find((t) => t.name === e.name);
14326
14333
  if (!t) return {
14327
14334
  content: `工具 "${e.name}" 不存在`,
14328
14335
  status: "error"
@@ -14331,10 +14338,10 @@ function Wg(e) {
14331
14338
  let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
14332
14339
  return r = Sg(r, {
14333
14340
  files: e.state.files,
14334
- vfsAvailable: O.some((e) => e.name === "vfs_read"),
14341
+ vfsAvailable: k.some((e) => e.name === "vfs_read"),
14335
14342
  toolName: e.name,
14336
- threshold: C,
14337
- passThroughChars: w
14343
+ threshold: w,
14344
+ passThroughChars: T
14338
14345
  }), {
14339
14346
  content: r,
14340
14347
  status: "done"
@@ -14346,15 +14353,15 @@ function Wg(e) {
14346
14353
  };
14347
14354
  }
14348
14355
  }
14349
- function I(e) {
14356
+ function ne(e) {
14350
14357
  return e instanceof a ? "human" : e instanceof i ? "ai" : e instanceof o ? "system" : e instanceof s ? "tool" : "unknown";
14351
14358
  }
14352
- function te(e, t) {
14359
+ function re(e, t) {
14353
14360
  return Ug(e, t);
14354
14361
  }
14355
- function ne(e) {
14362
+ function ie(e) {
14356
14363
  return e.map((e) => {
14357
- let t = I(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
14364
+ let t = ne(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
14358
14365
  r && (n.content = r.length > Hg ? r.slice(0, Hg) + `…(截断 ${r.length - Hg} 字符)` : r);
14359
14366
  let i = e.tool_calls;
14360
14367
  Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
@@ -14369,69 +14376,69 @@ function Wg(e) {
14369
14376
  return a && (n.tool_call_id = a), n;
14370
14377
  });
14371
14378
  }
14372
- async function re(e, t, n) {
14373
- T.value = [], j = Ag(), j.messages = e, j = await Mg(p, j);
14379
+ async function ae(e, t, n) {
14380
+ E.value = [], M = Ag(), M.messages = e, M = await Mg(p, M);
14374
14381
  let r = e;
14375
14382
  for (let e of p) if (e.compressInput) {
14376
14383
  let t = await e.compressInput(r);
14377
- r = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (j = {
14378
- ...j,
14384
+ r = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (M = {
14385
+ ...M,
14379
14386
  lastCompression: t.stats
14380
14387
  });
14381
14388
  }
14382
- let i = ee(r);
14383
- E("context", {
14389
+ let i = P(r);
14390
+ D("context", {
14384
14391
  model: c,
14385
- tools: O.map((e) => e.name),
14392
+ tools: k.map((e) => e.name),
14386
14393
  middleware: p.map((e) => e.name)
14387
14394
  });
14388
- let l = Lg(p, (e) => P(e, t, n)), u = Rg(p, F), d = 0, f = null, h = 0;
14395
+ let l = Lg(p, (e) => I(e, t, n)), u = Rg(p, te), d = 0, f = null, h = 0;
14389
14396
  try {
14390
14397
  for (; d < m && !n?.aborted;) {
14391
14398
  t({
14392
14399
  type: "round_start",
14393
14400
  round: d + 1
14394
- }), j = Ng(p, {
14401
+ }), M = Ng(p, {
14395
14402
  messages: i,
14396
- state: j
14397
- }), i = N(i), i = te(i, w), E("llm_request", {
14403
+ state: M
14404
+ }), i = F(i), i = re(i, T), D("llm_request", {
14398
14405
  round: d + 1,
14399
14406
  model: c,
14400
- tools: O.map((e) => e.name),
14401
- messages: ne(i)
14407
+ tools: k.map((e) => e.name),
14408
+ messages: ie(i)
14402
14409
  });
14403
14410
  let e = await l({
14404
14411
  messages: i,
14405
- state: j
14412
+ state: M
14406
14413
  });
14407
- if (i.push(e.message), E("llm_response", {
14414
+ if (i.push(e.message), D("llm_response", {
14408
14415
  round: d + 1,
14409
14416
  content: e.content,
14410
14417
  toolCalls: e.toolCalls
14411
- }), j = Pg(p, e, j), e.aborted) return t({
14418
+ }), M = Pg(p, e, M), e.aborted) return t({
14412
14419
  type: "done",
14413
14420
  content: e.content
14414
14421
  }), e.content;
14415
14422
  if (!e.toolCalls.length) {
14416
14423
  if (h < 2 && zg(e.content)) {
14417
- h += 1, E("middleware", {
14424
+ h += 1, D("middleware", {
14418
14425
  stage: "format_retry",
14419
14426
  attempt: h,
14420
14427
  content: e.content.slice(0, 200)
14421
14428
  }), i.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签,如 <|tool_calls|>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。")), d += 1;
14422
14429
  continue;
14423
14430
  }
14424
- if (v > 0 && j.verifyAttempts < v) {
14431
+ if (v > 0 && M.verifyAttempts < v) {
14425
14432
  let t = await Ig(p, {
14426
14433
  messages: i,
14427
- state: j,
14434
+ state: M,
14428
14435
  response: e,
14429
- log: (e, t) => E(e, t)
14436
+ log: (e, t) => D(e, t)
14430
14437
  });
14431
14438
  if (t) {
14432
- f = e.content, j.verifyAttempts += 1, i.push(new a(`⚠️ 验证未通过,请修正:${t}`)), E("middleware", {
14439
+ f = e.content, M.verifyAttempts += 1, i.push(new a(`⚠️ 验证未通过,请修正:${t}`)), D("middleware", {
14433
14440
  stage: "verify_retry",
14434
- attempt: j.verifyAttempts,
14441
+ attempt: M.verifyAttempts,
14435
14442
  feedback: t
14436
14443
  }), d += 1;
14437
14444
  continue;
@@ -14451,10 +14458,10 @@ function Wg(e) {
14451
14458
  id: r,
14452
14459
  name: e.name,
14453
14460
  args: e.args,
14454
- state: j,
14461
+ state: M,
14455
14462
  signal: n,
14456
14463
  emit: t,
14457
- logSink: D
14464
+ logSink: O
14458
14465
  }
14459
14466
  };
14460
14467
  }), o = await Cg(r, _, async (e) => {
@@ -14463,7 +14470,7 @@ function Wg(e) {
14463
14470
  type: "tool_call",
14464
14471
  name: e.call.name,
14465
14472
  args: e.call.args
14466
- }), E("tool_call", {
14473
+ }), D("tool_call", {
14467
14474
  round: d + 1,
14468
14475
  name: e.call.name,
14469
14476
  args: e.call.args,
@@ -14475,7 +14482,7 @@ function Wg(e) {
14475
14482
  name: e.call.name,
14476
14483
  result: r.content,
14477
14484
  status: r.status
14478
- }), E("tool_result", {
14485
+ }), D("tool_result", {
14479
14486
  round: d + 1,
14480
14487
  name: e.call.name,
14481
14488
  result: r.content,
@@ -14501,19 +14508,19 @@ function Wg(e) {
14501
14508
  content: f
14502
14509
  }), f;
14503
14510
  let e = i[i.length - 1];
14504
- if (e && I(e) === "tool") {
14505
- let e = i.filter((e) => I(e) !== "system"), r = [new o(M() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
14506
- E("llm_request", {
14511
+ if (e && ne(e) === "tool") {
14512
+ let e = i.filter((e) => ne(e) !== "system"), r = [new o(N() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
14513
+ D("llm_request", {
14507
14514
  round: "wrap_up",
14508
14515
  model: c,
14509
14516
  tools: [],
14510
- messages: ne(r)
14517
+ messages: ie(r)
14511
14518
  });
14512
- let a = await P({
14519
+ let a = await I({
14513
14520
  messages: r,
14514
- state: j
14515
- }, t, n, k);
14516
- if (E("llm_response", {
14521
+ state: M
14522
+ }, t, n, A);
14523
+ if (D("llm_response", {
14517
14524
  round: "wrap_up",
14518
14525
  content: a.content
14519
14526
  }), a.aborted || a.content) return t({
@@ -14528,24 +14535,34 @@ function Wg(e) {
14528
14535
  }), r;
14529
14536
  } finally {
14530
14537
  try {
14531
- await Fg(p, j);
14538
+ await Fg(p, M);
14532
14539
  } catch (e) {
14533
14540
  console.warn("[Agent] afterAgent 清理出错(已忽略):", e);
14534
14541
  }
14535
14542
  }
14536
14543
  }
14537
- async function ie(e, t) {
14544
+ async function oe(e, t) {
14538
14545
  let n = "";
14539
- return await re(e, (e) => {
14546
+ return await ae(e, (e) => {
14540
14547
  e.type === "done" && (n = e.content);
14541
14548
  }, t), n;
14542
14549
  }
14550
+ function se(e) {
14551
+ k = [...p.flatMap((e) => e.tools || []), ...e], j();
14552
+ }
14553
+ function ce(e) {
14554
+ A = e, j(), b?.(e);
14555
+ }
14543
14556
  return {
14544
- invoke: ie,
14545
- stream: re,
14546
- getState: () => j,
14547
- allTools: O,
14548
- debugLogs: T
14557
+ invoke: oe,
14558
+ stream: ae,
14559
+ getState: () => M,
14560
+ get allTools() {
14561
+ return k;
14562
+ },
14563
+ setTools: se,
14564
+ setLlm: ce,
14565
+ debugLogs: E
14549
14566
  };
14550
14567
  }
14551
14568
  //#endregion
@@ -14710,7 +14727,8 @@ function e_(e = "") {
14710
14727
  augmentPrompt: (e) => e.memory ? `## 持久指令(Memory)\n${e.memory}` : void 0,
14711
14728
  reset: (e) => {
14712
14729
  t = e;
14713
- }
14730
+ },
14731
+ get: () => t
14714
14732
  };
14715
14733
  }
14716
14734
  //#endregion
@@ -15057,12 +15075,8 @@ function O_(e, t) {
15057
15075
  };
15058
15076
  }
15059
15077
  function k_(e, n) {
15060
- let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
15061
- if (!D_.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
15062
- let t = `use_${e.id}`;
15063
- return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
15064
- }), o, s, c, l = (e, t) => (n) => {
15065
- s && s({
15078
+ let i, a, o, s = (e, t) => (n) => {
15079
+ a && a({
15066
15080
  type: "subagent",
15067
15081
  taskId: e,
15068
15082
  label: t,
@@ -15072,27 +15086,78 @@ function k_(e, n) {
15072
15086
  result: n.type === "tool_result" ? n.result : void 0,
15073
15087
  status: n.type === "tool_result" ? n.status : void 0
15074
15088
  });
15075
- };
15076
- return {
15077
- name: "subagents",
15078
- tools: a.map((e) => r(async ({ task: t }) => {
15079
- let r = O_(e, n);
15080
- return T_({ prompt: t }, r, o, l(`use_${e.id}`, e.id), (t) => c?.({
15081
- ...t,
15082
- source: `子:${e.id}`
15089
+ }, c = [], l = [], u;
15090
+ function d(e) {
15091
+ let a = /* @__PURE__ */ new Set(), c = [], l = [];
15092
+ for (let u of e) {
15093
+ if (!D_.test(u.id)) {
15094
+ console.warn(`[subagents] id "${u.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`);
15095
+ continue;
15096
+ }
15097
+ let e = `use_${u.id}`;
15098
+ if (a.has(e)) {
15099
+ console.warn(`[subagents] id "${u.id}" 重复,已跳过`);
15100
+ continue;
15101
+ }
15102
+ a.add(e), c.push(u), l.push(r(async ({ task: e }) => {
15103
+ let t = O_(u, n);
15104
+ return T_({ prompt: e }, t, i, s(`use_${u.id}`, u.id), (e) => o?.({
15105
+ ...e,
15106
+ source: `子:${u.id}`
15107
+ }));
15108
+ }, {
15109
+ name: `use_${u.id}`,
15110
+ description: `委派给「${u.description}」子 agent 执行任务,返回其结论(过程隔离,不占主上下文)。`,
15111
+ schema: t.object({ task: t.string().describe("委派给该子 agent 的任务描述") })
15083
15112
  }));
15084
- }, {
15085
- name: `use_${e.id}`,
15086
- description: `委派给「${e.description}」子 agent 执行任务,返回其结论(过程隔离,不占主上下文)。`,
15087
- schema: t.object({ task: t.string().describe("委派给该子 agent 的任务描述") })
15088
- })),
15089
- augmentPrompt: () => a.length ? [
15113
+ }
15114
+ return {
15115
+ valid: c,
15116
+ tools: l
15117
+ };
15118
+ }
15119
+ let f = d(e);
15120
+ c = f.valid, l = f.tools;
15121
+ let p = {
15122
+ set(e) {
15123
+ let t = d(e);
15124
+ c = t.valid, l = t.tools, u?.();
15125
+ },
15126
+ add(e) {
15127
+ if (c.some((t) => t.id === e.id)) {
15128
+ console.warn(`[subagents] add: id "${e.id}" 已存在,已跳过`);
15129
+ return;
15130
+ }
15131
+ let t = d([...c, e]);
15132
+ c = t.valid, l = t.tools, u?.();
15133
+ },
15134
+ remove(e) {
15135
+ if (c.findIndex((t) => t.id === e) < 0) return !1;
15136
+ let t = d(c.filter((t) => t.id !== e));
15137
+ return c = t.valid, l = t.tools, u?.(), !0;
15138
+ },
15139
+ get: () => [...c]
15140
+ }, m = {
15141
+ name: "subagents",
15142
+ get tools() {
15143
+ return l;
15144
+ },
15145
+ augmentPrompt: () => c.length ? [
15090
15146
  "## 可用子 agent(预声明,经专属工具委派)",
15091
- ...a.map((e) => `- use_${e.id}: ${e.description}`),
15147
+ ...c.map((e) => `- use_${e.id}: ${e.description}`),
15092
15148
  "需要某子 agent 时,直接调用对应的 use_<id>({ task }) 委派,任务描述要清晰。"
15093
15149
  ].join("\n") : void 0,
15094
- wrapToolCall: async (e, t) => (e.signal && (o = e.signal), e.emit && (s = e.emit), e.logSink && (c = e.logSink), t(e))
15150
+ wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
15095
15151
  };
15152
+ return Object.defineProperty(m, "controller", {
15153
+ value: p,
15154
+ enumerable: !1
15155
+ }), Object.defineProperty(m, "setReconfigureHook", {
15156
+ value: (e) => {
15157
+ u = e;
15158
+ },
15159
+ enumerable: !1
15160
+ }), m;
15096
15161
  }
15097
15162
  //#endregion
15098
15163
  //#region src/core/harness/verify.ts
@@ -17613,228 +17678,256 @@ function rb(e, t, n, r) {
17613
17678
  }
17614
17679
  };
17615
17680
  }
17616
- function ib(e, n) {
17617
- let i = {
17681
+ function ib(e, i) {
17682
+ let a = {
17618
17683
  prompt_tokens: 0,
17619
17684
  completion_tokens: 0,
17620
17685
  total_tokens: 0
17621
- }, a = /* @__PURE__ */ U(null), o = /* @__PURE__ */ U(0), s = 0;
17622
- function c(e) {
17686
+ }, o = /* @__PURE__ */ U(null), s = /* @__PURE__ */ U(0), c = 0;
17687
+ function l(e) {
17623
17688
  return new Promise((t) => {
17624
- let n = a.value;
17689
+ let n = o.value;
17625
17690
  n && n.resolve({ action: "keep_external" });
17626
17691
  let r = {
17627
17692
  ...e,
17628
- id: ++s,
17693
+ id: ++c,
17629
17694
  resolve: t
17630
17695
  };
17631
- a.value = r, ye({
17696
+ o.value = r, Ee({
17632
17697
  type: "conflict",
17633
17698
  conflict: r
17634
17699
  });
17635
17700
  });
17636
17701
  }
17637
- function l(e) {
17638
- let t = a.value;
17639
- t && (a.value = null, t.resolve({ action: e }));
17640
- }
17641
- let u = Xy(e.storage);
17642
- e.debug && u && u.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
17643
- let d = Qy(e.llm) ? void 0 : e.llm, f = Eg({
17644
- model: d?.model,
17645
- contextWindow: e.contextWindow ?? d?.contextWindow,
17646
- maxOutputTokens: e.maxOutputTokens ?? d?.maxOutputTokens
17702
+ function u(e) {
17703
+ let t = o.value;
17704
+ t && (o.value = null, t.resolve({ action: e }));
17705
+ }
17706
+ let d = Xy(e.storage);
17707
+ e.debug && d && d.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
17708
+ let f = Qy(e.llm) ? void 0 : e.llm, p = Eg({
17709
+ model: f?.model,
17710
+ contextWindow: e.contextWindow ?? f?.contextWindow,
17711
+ maxOutputTokens: e.maxOutputTokens ?? f?.maxOutputTokens
17647
17712
  });
17648
- e.debug && console.log("[page-agent-sdk][modelCaps]", f);
17649
- let p = tb(e);
17650
- e.debug && !p && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
17651
- let m = /* @__PURE__ */ tn([]), h = hv(e.vfs?.initialFiles, {
17652
- persist: u ? { save: (e) => {
17653
- z.sessionId && u && u.save(n, z.sessionId, { vfs: e });
17713
+ e.debug && console.log("[page-agent-sdk][modelCaps]", p);
17714
+ let m = e.llm, h = tb(e);
17715
+ e.debug && !h && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
17716
+ let g = /* @__PURE__ */ tn([]), _ = hv(e.vfs?.initialFiles, {
17717
+ persist: d ? { save: (e) => {
17718
+ z.sessionId && d && d.save(i, z.sessionId, { vfs: e });
17654
17719
  } } : void 0,
17655
17720
  maxBytes: e.vfs?.maxBytes
17656
- }), g = Kg(), _ = e_(e.memory || ""), v = { current: null }, y = e.data ? {
17721
+ }), v = Kg(), y = e_(e.memory || ""), b = { current: null }, x = e.data ? {
17657
17722
  ...e.data,
17658
17723
  description: e.data.description ?? "主数据对象"
17659
- } : void 0, b = e.checkpoint, x = b !== void 0 && b !== !1, S = x ? __({
17660
- getData: () => j()?.bind,
17661
- slotPaths: y ? [""] : [],
17662
- vfsStore: h,
17663
- todosMw: g,
17664
- getTodos: () => v.current?.getState?.()?.todos ?? [],
17665
- messages: m,
17666
- maxCheckpoints: b && typeof b == "object" ? b.maxCheckpoints : void 0
17667
- }) : null, C = !b || typeof b != "object" || b.auto !== !1, w = e.capabilities, T = w?.dataOps !== !1, E = e.appendReliableWriteRules !== !1, D = (e.systemPrompt ? E ? e.systemPrompt + "\n\n---\n\n" + sv.reliableWriteRules : e.systemPrompt : qy) + Jy(y), O = T && y ? ly(y, {
17724
+ } : void 0, S = e.checkpoint, C = S !== void 0 && S !== !1, w = C ? __({
17725
+ getData: () => M()?.bind,
17726
+ slotPaths: x ? [""] : [],
17727
+ vfsStore: _,
17728
+ todosMw: v,
17729
+ getTodos: () => b.current?.getState?.()?.todos ?? [],
17730
+ messages: g,
17731
+ maxCheckpoints: S && typeof S == "object" ? S.maxCheckpoints : void 0
17732
+ }) : null, T = !S || typeof S != "object" || S.auto !== !1, E = e.capabilities, D = E?.dataOps !== !1, O = e.appendReliableWriteRules !== !1, k = e.systemPrompt ? O ? e.systemPrompt + "\n\n---\n\n" + sv.reliableWriteRules : e.systemPrompt : qy, A = D && x ? ly(x, {
17668
17733
  onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
17669
17734
  maxSnapshots: e.maxSnapshots,
17670
- onConflict: c,
17735
+ onConflict: l,
17671
17736
  autoLock: e.autoLock,
17672
17737
  interceptors: e.interceptors
17673
- }) : [], k = T ? cy(O, e.toolMode) : [], A = T && y ? O.controller ?? null : null, j = () => A?.get() ?? y, M = /* @__PURE__ */ new Map(), ee = my(w, k, dy);
17674
- ee.forEach((e) => M.set(e.name, "builtin"));
17675
- let N = [...e.tools || []];
17676
- N.forEach((e) => M.set(e.name, "user"));
17677
- let P = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), F = P ? l_() : null;
17678
- F && M.set(s_, "builtin");
17679
- let I = x && S ? [r(async () => {
17680
- let e = S.list();
17681
- return e.length ? S.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
17738
+ }) : [], ee = D ? cy(A, e.toolMode) : [], j = D && x ? A.controller ?? null : null, M = () => j?.get() ?? x, N = /* @__PURE__ */ new Map(), P = my(E, ee, dy);
17739
+ P.forEach((e) => N.set(e.name, "builtin"));
17740
+ let F = [...e.tools || []];
17741
+ F.forEach((e) => N.set(e.name, "user"));
17742
+ let I = [], te = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), ne = te ? l_() : null;
17743
+ ne && N.set(s_, "builtin");
17744
+ let re = C && w ? [r(async () => {
17745
+ let e = w.list();
17746
+ return e.length ? w.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
17682
17747
  }, {
17683
17748
  name: "restore_last_checkpoint",
17684
17749
  description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
17685
17750
  schema: t.object({}).optional()
17686
17751
  }), r(async () => {
17687
- let e = S.list();
17752
+ let e = w.list();
17688
17753
  return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
17689
17754
  }, {
17690
17755
  name: "list_checkpoints",
17691
17756
  description: "列出可用会话 checkpoint(回退点)。",
17692
17757
  schema: t.object({}).optional()
17693
17758
  })] : [];
17694
- I.forEach((e) => M.set(e.name, "builtin"));
17695
- let te = [
17696
- ...ee,
17697
- ...N,
17698
- ...F ? [F] : [],
17699
- ...I
17700
- ], ne = w?.planning !== !1, re = w?.skills !== !1, ie = w?.vfs !== !1, ae = w?.summarization !== !1, oe = w?.memory !== !1, se = w?.subagent !== !1, ce = e.verify?.maxAttempts ?? 2, le = w?.verify === !0 && e.verify?.enabled !== !1 && ce > 0;
17701
- e.verify?.check && w?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
17702
- let ue = e.subagent, L = ue?.allowedTools ?? [], de = !se || ue?.enabled === !1 ? void 0 : E_({
17703
- llm: ue?.llm ?? e.llm,
17704
- allTools: te,
17705
- allowedTools: L.length ? L : void 0,
17706
- systemPrompt: ue?.systemPrompt,
17707
- temperature: ue?.temperature,
17708
- maxTokens: ue?.maxTokens,
17709
- skills: ue?.skills,
17710
- maxDepth: ue?.maxDepth,
17711
- maxParallel: ue?.maxParallel,
17759
+ re.forEach((e) => N.set(e.name, "builtin"));
17760
+ let ie = [
17761
+ ...P,
17762
+ ...F,
17763
+ ...ne ? [ne] : [],
17764
+ ...re
17765
+ ];
17766
+ function ae() {
17767
+ return [
17768
+ ...P,
17769
+ ...F,
17770
+ ...ne ? [ne] : [],
17771
+ ...re,
17772
+ ...I
17773
+ ];
17774
+ }
17775
+ let oe = E?.planning !== !1, se = E?.skills !== !1, ce = E?.vfs !== !1, le = E?.summarization !== !1, ue = E?.memory !== !1, L = E?.subagent !== !1, de = e.verify?.maxAttempts ?? 2, fe = E?.verify === !0 && e.verify?.enabled !== !1 && de > 0;
17776
+ e.verify?.check && E?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
17777
+ let pe = e.subagent, me = pe?.allowedTools ?? [], he = !L || pe?.enabled === !1 ? void 0 : E_({
17778
+ llm: pe?.llm ?? e.llm,
17779
+ allTools: ie,
17780
+ allowedTools: me.length ? me : void 0,
17781
+ systemPrompt: pe?.systemPrompt,
17782
+ temperature: pe?.temperature,
17783
+ maxTokens: pe?.maxTokens,
17784
+ skills: pe?.skills,
17785
+ maxDepth: pe?.maxDepth,
17786
+ maxParallel: pe?.maxParallel,
17712
17787
  debug: e.debug
17713
- }), fe = e.subagents?.length ? k_(e.subagents, {
17788
+ }), ge = L && e.subagents !== void 0 ? k_(e.subagents, {
17714
17789
  llm: e.llm,
17715
- allTools: te,
17790
+ allTools: ie,
17716
17791
  debug: e.debug
17717
- }) : void 0, pe = [
17792
+ }) : void 0, _e = ge ? ge.controller : null, ve = [
17718
17793
  "get_data",
17719
17794
  "describe_data",
17720
17795
  "read",
17721
17796
  "fetch_document"
17722
- ], me = te.filter((e) => pe.includes(e.name)), he = le ? A_({
17797
+ ], ye = ie.filter((e) => ve.includes(e.name)), be = fe ? A_({
17723
17798
  check: e.verify.check ?? I_({
17724
- schemas: () => j() ? { "": j().schema } : {},
17725
- root: () => j()?.bind
17799
+ schemas: () => M() ? { "": M().schema } : {},
17800
+ root: () => M()?.bind
17726
17801
  }),
17727
17802
  adversarial: e.verify?.adversarial ? {
17728
17803
  llm: e.llm,
17729
- tools: me
17804
+ tools: ye
17730
17805
  } : void 0
17731
- }) : void 0, ge = gy({
17732
- ...w,
17733
- humanConfirm: P,
17806
+ }) : void 0, xe = gy({
17807
+ ...E,
17808
+ humanConfirm: te,
17734
17809
  subagents: e.subagents?.map((e) => ({
17735
17810
  id: e.id,
17736
17811
  description: e.description,
17737
17812
  temperature: e.temperature
17738
17813
  }))
17739
- }, T && !!y, e.toolMode), _e = e.onEvent, ve = /* @__PURE__ */ new Set(), ye = (e) => {
17814
+ }, D && !!x, e.toolMode), Se = x ? {
17815
+ name: "dataHint",
17816
+ augmentPrompt: () => Jy(M()) || void 0
17817
+ } : null, Ce = e.augmentSystem ? {
17818
+ name: "augmentSystem",
17819
+ augmentPrompt: (t) => {
17820
+ try {
17821
+ return e.augmentSystem({
17822
+ state: t,
17823
+ data: M()
17824
+ });
17825
+ } catch (t) {
17826
+ e.debug && console.log("[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:", t.message);
17827
+ return;
17828
+ }
17829
+ }
17830
+ } : null, we = e.onEvent, Te = /* @__PURE__ */ new Set(), Ee = (e) => {
17740
17831
  if (e.type !== "approval_request") {
17741
- if (_e) try {
17742
- _e(e);
17832
+ if (we) try {
17833
+ we(e);
17743
17834
  } catch {}
17744
- for (let t of ve) try {
17835
+ for (let t of Te) try {
17745
17836
  t(e);
17746
17837
  } catch {}
17747
17838
  }
17748
- }, be, xe = [], Se = (e) => ({
17839
+ }, R, De = [], Oe = (e) => ({
17749
17840
  name: e.name,
17750
17841
  description: e.description,
17751
17842
  content: typeof e.getContent == "function" ? e.getContent() : ""
17752
- }), Ce = (e) => ({
17843
+ }), ke = (e) => ({
17753
17844
  name: e.name,
17754
17845
  description: e.description,
17755
17846
  getContent: () => e.content
17756
- }), we = e.skillStorage === !1 ? null : Ky({
17847
+ }), Ae = e.skillStorage === !1 ? null : Ky({
17757
17848
  ...typeof e.skillStorage == "object" ? e.skillStorage : {},
17758
- id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
17759
- }), Te = () => {
17760
- let t = be ? be.controller : null;
17849
+ id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${i}`
17850
+ }), je = () => {
17851
+ let t = R ? R.controller : null;
17761
17852
  if (t) {
17762
- let n = (e.skills || []).filter((e) => !xe.some((t) => t.name === e.name));
17763
- t.set([...n, ...xe]);
17853
+ let n = (e.skills || []).filter((e) => !De.some((t) => t.name === e.name));
17854
+ t.set([...n, ...De]);
17764
17855
  }
17765
17856
  z.infoTick.value++;
17766
- }, Ee = async () => {
17767
- if (we) try {
17768
- let t = await we.list();
17857
+ }, Me = async () => {
17858
+ if (Ae) try {
17859
+ let t = await Ae.list();
17769
17860
  if (t.length) {
17770
- xe = t.map(Ce);
17771
- let n = be ? be.controller : null;
17861
+ De = t.map(ke);
17862
+ let n = R ? R.controller : null;
17772
17863
  if (n) {
17773
- let t = (e.skills || []).filter((e) => !xe.some((t) => t.name === e.name));
17774
- n.set([...t, ...xe]);
17864
+ let t = (e.skills || []).filter((e) => !De.some((t) => t.name === e.name));
17865
+ n.set([...t, ...De]);
17775
17866
  }
17776
17867
  z.infoTick.value++;
17777
17868
  }
17778
17869
  } catch {}
17779
- }, R = [
17780
- ge,
17781
- ...ne ? [g] : [],
17782
- ...re ? [be = $g(e.skills || [], { readVfs: ie ? (e) => h.files[e]?.content : void 0 })] : [],
17783
- ...ie ? [Sv(h)] : [],
17784
- ...ae ? [av({
17785
- ...uv(e, f.contextWindow),
17786
- llmInvoke: p,
17787
- getRegisteredData: () => j() ? [{ description: j().description ?? "主数据对象" }] : [],
17870
+ }, Ne = [
17871
+ ...Se ? [Se] : [],
17872
+ xe,
17873
+ ...oe ? [v] : [],
17874
+ ...se ? [R = $g(e.skills || [], { readVfs: ce ? (e) => _.files[e]?.content : void 0 })] : [],
17875
+ ...ce ? [Sv(_)] : [],
17876
+ ...le ? [av({
17877
+ ...uv(e, p.contextWindow),
17878
+ llmInvoke: h,
17879
+ getRegisteredData: () => M() ? [{ description: M().description ?? "主数据对象" }] : [],
17788
17880
  preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_data", "read"]
17789
17881
  })] : [],
17790
- ...oe ? [_] : [],
17882
+ ...ue ? [y] : [],
17791
17883
  ...e.permissions?.length ? [a_(e.permissions)] : [],
17792
- ...x && C && S ? [v_(S)] : [],
17793
- ...P ? [u_()] : [],
17884
+ ...C && T && w ? [v_(w)] : [],
17885
+ ...te ? [u_()] : [],
17794
17886
  ...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [o_(e.approval)] : [],
17887
+ ...be ? [be] : [],
17795
17888
  ...he ? [he] : [],
17796
- ...de ? [de] : [],
17797
- ...fe ? [fe] : [],
17889
+ ...ge ? [ge] : [],
17890
+ ...Ce ? [Ce] : [],
17798
17891
  ...e.middleware || [],
17799
- rb(ye, m, j, i)
17800
- ], De = e.maxMemoryRounds ?? Yy, z = {
17801
- agentId: n,
17802
- store: u,
17803
- messages: m,
17804
- vfsStore: h,
17805
- listeners: ve,
17806
- todosMw: g,
17807
- memoryMw: _,
17892
+ rb(Ee, g, M, a)
17893
+ ], Pe = e.maxMemoryRounds ?? Yy, z = {
17894
+ agentId: i,
17895
+ store: d,
17896
+ messages: g,
17897
+ vfsStore: _,
17898
+ listeners: Te,
17899
+ todosMw: v,
17900
+ memoryMw: y,
17808
17901
  agent: null,
17809
17902
  initDone: Promise.resolve(),
17810
17903
  sessionId: "",
17811
17904
  refCount: 0,
17812
17905
  mcpClosers: [],
17813
17906
  mcpServers: [],
17814
- checkpoint: S,
17815
- dataOpsController: A,
17816
- skillsController: be ? be.controller : null,
17817
- infoTick: o,
17818
- pendingConflict: a,
17819
- liveData: j,
17820
- usage: i,
17821
- emit: ye,
17907
+ checkpoint: w,
17908
+ dataOpsController: j,
17909
+ skillsController: R ? R.controller : null,
17910
+ infoTick: s,
17911
+ pendingConflict: o,
17912
+ liveData: M,
17913
+ usage: a,
17914
+ emit: Ee,
17822
17915
  applySnapshot(t) {
17823
- t.messages?.length && m.push(...t.messages), t.vfs && h.hydrate && h.hydrate(t.vfs), t.todos?.length && g.reset(t.todos), t.memory && !e.memory && _.reset(t.memory);
17916
+ t.messages?.length && g.push(...t.messages), t.vfs && _.hydrate && _.hydrate(t.vfs), t.todos?.length && v.reset(t.todos), t.memory && !e.memory && y.reset(t.memory);
17824
17917
  },
17825
17918
  addSkill(e) {
17826
- let t = xe.findIndex((t) => t.name === e.name);
17827
- t >= 0 ? xe[t] = e : xe.push(e), Te(), we && we.put(Se(e));
17919
+ let t = De.findIndex((t) => t.name === e.name);
17920
+ t >= 0 ? De[t] = e : De.push(e), je(), Ae && Ae.put(Oe(e));
17828
17921
  },
17829
17922
  removeSkill(e) {
17830
- let t = xe.findIndex((t) => t.name === e);
17831
- return t < 0 ? !1 : (xe.splice(t, 1), Te(), we && we.remove(e), !0);
17923
+ let t = De.findIndex((t) => t.name === e);
17924
+ return t < 0 ? !1 : (De.splice(t, 1), je(), Ae && Ae.remove(e), !0);
17832
17925
  },
17833
17926
  listUserSkills() {
17834
- return xe.map((e) => e.name);
17927
+ return De.map((e) => e.name);
17835
17928
  },
17836
17929
  getUserSkill(e) {
17837
- let t = xe.find((t) => t.name === e);
17930
+ let t = De.find((t) => t.name === e);
17838
17931
  if (t) return {
17839
17932
  name: t.name,
17840
17933
  description: t.description,
@@ -17842,7 +17935,7 @@ function ib(e, n) {
17842
17935
  };
17843
17936
  },
17844
17937
  afterRound() {
17845
- Ae(), je();
17938
+ Le(), B();
17846
17939
  },
17847
17940
  async send(t) {
17848
17941
  await z.initDone;
@@ -17851,146 +17944,191 @@ function ib(e, n) {
17851
17944
  let r = e.interceptors.input(t);
17852
17945
  typeof r == "string" && (n = r);
17853
17946
  } catch {}
17854
- m.push({
17947
+ g.push({
17855
17948
  role: "user",
17856
17949
  content: n,
17857
17950
  timestamp: Date.now()
17858
17951
  });
17859
17952
  try {
17860
- let t = await z.agent.invoke(m);
17953
+ let t = await z.agent.invoke(g);
17861
17954
  if (e.interceptors?.output) try {
17862
17955
  let n = e.interceptors.output(t);
17863
17956
  typeof n == "string" && (t = n);
17864
17957
  } catch {}
17865
- return m.push({
17958
+ return g.push({
17866
17959
  role: "assistant",
17867
17960
  content: t,
17868
17961
  timestamp: Date.now()
17869
- }), z.afterRound(), u && await u.flush(), t;
17962
+ }), z.afterRound(), d && await d.flush(), t;
17870
17963
  } catch (e) {
17871
- throw ye({
17964
+ throw Ee({
17872
17965
  type: "error",
17873
17966
  message: e?.message || String(e)
17874
17967
  }), e;
17875
17968
  }
17876
17969
  },
17877
17970
  async switchSession(t) {
17878
- if (await z.initDone, !u) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
17879
- l("keep_external"), h.flush?.(), await u.flush();
17880
- let r = t ?? "", i;
17881
- return r ? (i = await u.load(n, r), i || await u.createSession(n, e.session?.title, r)) : r = await u.createSession(n, e.session?.title), z.sessionId = r, m.splice(0, m.length), h.clear?.(), g.reset([]), e.memory || _.reset(""), z.agent.debugLogs.value = [], i ||= await u.load(n, r), i && (z.applySnapshot(i), ye({
17971
+ if (await z.initDone, !d) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
17972
+ u("keep_external"), _.flush?.(), await d.flush();
17973
+ let n = t ?? "", r;
17974
+ return n ? (r = await d.load(i, n), r || await d.createSession(i, e.session?.title, n)) : n = await d.createSession(i, e.session?.title), z.sessionId = n, g.splice(0, g.length), _.clear?.(), v.reset([]), e.memory || y.reset(""), z.agent.debugLogs.value = [], r ||= await d.load(i, n), r && (z.applySnapshot(r), Ee({
17882
17975
  type: "session_restored",
17883
- sessionId: r,
17884
- rounds: i.messages?.length ?? 0
17885
- })), e.memory && u.save(n, z.sessionId, { memory: e.memory }), r;
17976
+ sessionId: n,
17977
+ rounds: r.messages?.length ?? 0
17978
+ })), e.memory && d.save(i, z.sessionId, { memory: e.memory }), n;
17886
17979
  },
17887
17980
  stream: (e, t, n) => {
17888
17981
  if (!z.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
17889
- let r = _e ? (e) => {
17890
- t?.(e), ye(e);
17982
+ let r = we ? (e) => {
17983
+ t?.(e), Ee(e);
17891
17984
  } : t;
17892
17985
  if (n) {
17893
- let e = () => l("keep_external");
17986
+ let e = () => u("keep_external");
17894
17987
  n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
17895
17988
  }
17896
17989
  return z.agent.stream(e, r, n);
17897
17990
  },
17898
17991
  release() {
17899
17992
  if (z.refCount--, z.refCount <= 0) {
17900
- u && (h.flush?.(), u.flush(), u.dispose()), we && we.dispose();
17993
+ d && (_.flush?.(), d.flush(), d.dispose()), Ae && Ae.dispose();
17901
17994
  let e = z.mcpClosers.splice(0);
17902
- e.length && Promise.allSettled(e.map((e) => e())), $y.delete(n);
17995
+ e.length && Promise.allSettled(e.map((e) => e())), $y.delete(i);
17996
+ }
17997
+ },
17998
+ resolveConflict: u,
17999
+ setTools(e) {
18000
+ F.length = 0, e.forEach((e) => {
18001
+ F.push(e), N.set(e.name, "user");
18002
+ }), ie = ae(), z.agent && z.agent.setTools(ie), z.infoTick.value++;
18003
+ },
18004
+ addTool(e) {
18005
+ F.some((t) => t.name === e.name) || (F.push(e), N.set(e.name, "user"), ie = ae(), z.agent && z.agent.setTools(ie), z.infoTick.value++);
18006
+ },
18007
+ removeTool(e) {
18008
+ let t = F.findIndex((t) => t.name === e);
18009
+ return t < 0 ? !1 : (F.splice(t, 1), ie = ae(), z.agent && z.agent.setTools(ie), z.infoTick.value++, !0);
18010
+ },
18011
+ setLlm(t) {
18012
+ let r = Qy(t) ? t : new n({
18013
+ apiKey: t.apiKey,
18014
+ model: t.model,
18015
+ temperature: t.temperature,
18016
+ maxTokens: t.maxTokens,
18017
+ configuration: t.baseUrl ? { baseURL: t.baseUrl } : void 0
18018
+ });
18019
+ typeof r.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), m = t, z.agent && z.agent.setLlm(r), z.infoTick.value++;
18020
+ },
18021
+ setMemory(e) {
18022
+ y.reset(e), z.infoTick.value++;
18023
+ },
18024
+ setSubagents(t) {
18025
+ if (!_e) {
18026
+ e.debug && console.warn("[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
18027
+ return;
17903
18028
  }
18029
+ _e.set(t), z.infoTick.value++;
18030
+ },
18031
+ addSubagent(t) {
18032
+ if (!_e) {
18033
+ e.debug && console.warn("[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
18034
+ return;
18035
+ }
18036
+ _e.add(t), z.infoTick.value++;
18037
+ },
18038
+ removeSubagent(t) {
18039
+ if (!_e) return e.debug && console.warn("[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略"), !1;
18040
+ let n = _e.remove(t);
18041
+ return n && z.infoTick.value++, n;
17904
18042
  },
17905
- resolveConflict: l,
17906
18043
  getInfo() {
17907
18044
  return {
17908
- id: n,
17909
- model: Qy(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
17910
- systemPrompt: D,
17911
- tools: te.map((e) => ({
18045
+ id: i,
18046
+ model: Qy(m) ? m.model ?? m.modelName : m.model,
18047
+ systemPrompt: k + Jy(M()) + (Ce && Ce.augmentPrompt(z.agent?.getState?.() ?? Ag()) || ""),
18048
+ tools: (z.agent?.allTools ?? ie).map((e) => ({
17912
18049
  name: e.name,
17913
18050
  description: e.description,
17914
18051
  schema: e.schema,
17915
- source: M.get(e.name) || "user"
18052
+ source: N.get(e.name) || "user"
17916
18053
  })),
17917
- skills: (be ? be.controller.get() : e.skills ?? []).map((e) => ({
18054
+ skills: (R ? R.controller.get() : e.skills ?? []).map((e) => ({
17918
18055
  name: e.name,
17919
18056
  description: e.description
17920
18057
  })),
17921
- data: j() ? {
17922
- description: j().description,
17923
- schema: j().schema
18058
+ data: M() ? {
18059
+ description: M().description,
18060
+ schema: M().schema
17924
18061
  } : void 0,
17925
- memory: e.memory ?? "",
17926
- middleware: R.map((e) => e.name),
18062
+ memory: y.get(),
18063
+ middleware: Ne.map((e) => e.name),
17927
18064
  todos: (z.agent?.getState?.()?.todos ?? []).map((e) => ({
17928
18065
  content: e.content,
17929
18066
  status: e.status
17930
18067
  })),
17931
18068
  subagent: {
17932
- enabled: !!de,
18069
+ enabled: !!he,
17933
18070
  maxDepth: e.subagent?.maxDepth ?? 1,
17934
18071
  maxParallel: e.subagent?.maxParallel ?? 4,
17935
- allowedTools: e.subagent?.allowedTools ?? []
18072
+ allowedTools: e.subagent?.allowedTools ?? [],
18073
+ subagents: _e?.get() ?? []
17936
18074
  },
17937
18075
  verify: {
17938
- enabled: !!he,
17939
- maxAttempts: le ? ce : 0,
17940
- adversarial: le && !!e.verify?.adversarial
18076
+ enabled: !!be,
18077
+ maxAttempts: fe ? de : 0,
18078
+ adversarial: fe && !!e.verify?.adversarial
17941
18079
  },
17942
18080
  mcp: { servers: z.mcpServers },
17943
18081
  lastCompression: z.agent?.getState?.()?.lastCompression,
17944
- checkpoints: S ? {
18082
+ checkpoints: w ? {
17945
18083
  enabled: !0,
17946
- auto: C,
17947
- list: S.list()
18084
+ auto: T,
18085
+ list: w.list()
17948
18086
  } : void 0
17949
18087
  };
17950
18088
  }
17951
18089
  };
17952
- async function Oe() {
17953
- if (!u) return;
17954
- await u.ready;
18090
+ async function Fe() {
18091
+ if (!d) return;
18092
+ await d.ready;
17955
18093
  let t = e.session || {};
17956
18094
  if (t.id) {
17957
18095
  z.sessionId = t.id;
17958
- let e = await u.load(n, z.sessionId);
17959
- e ? (z.applySnapshot(e), ye({
18096
+ let e = await d.load(i, z.sessionId);
18097
+ e ? (z.applySnapshot(e), Ee({
17960
18098
  type: "session_restored",
17961
18099
  sessionId: z.sessionId,
17962
18100
  rounds: e.messages?.length ?? 0
17963
- })) : await u.createSession(n, t.title, z.sessionId);
18101
+ })) : await d.createSession(i, t.title, z.sessionId);
17964
18102
  } else if (t.autoResume !== !1) {
17965
- let r = await u.listSessions(n);
17966
- if (e.debug && console.log("[page-agent-sdk][restore] listSessions", n, r.length, r.map((e) => e.sessionId)), r.length) {
17967
- z.sessionId = r[0].sessionId;
17968
- let t = await u.load(n, z.sessionId);
17969
- t ? (z.applySnapshot(t), ye({
18103
+ let n = await d.listSessions(i);
18104
+ if (e.debug && console.log("[page-agent-sdk][restore] listSessions", i, n.length, n.map((e) => e.sessionId)), n.length) {
18105
+ z.sessionId = n[0].sessionId;
18106
+ let t = await d.load(i, z.sessionId);
18107
+ t ? (z.applySnapshot(t), Ee({
17970
18108
  type: "session_restored",
17971
18109
  sessionId: z.sessionId,
17972
18110
  rounds: t.messages?.length ?? 0
17973
18111
  }), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", z.sessionId, `${t.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", z.sessionId);
17974
- } else z.sessionId = await u.createSession(n, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", z.sessionId);
17975
- } else z.sessionId = await u.createSession(n, t.title);
17976
- e.memory && u.save(n, z.sessionId, { memory: e.memory });
18112
+ } else z.sessionId = await d.createSession(i, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", z.sessionId);
18113
+ } else z.sessionId = await d.createSession(i, t.title);
18114
+ e.memory && d.save(i, z.sessionId, { memory: e.memory });
17977
18115
  }
17978
- async function ke() {
17979
- await Ee();
18116
+ async function Ie() {
18117
+ await Me();
17980
18118
  }
17981
- function Ae() {
17982
- let e = X_(m, De);
17983
- e.trimmed && m.splice(e.deleteFrom, e.deleteCount, e.summary);
18119
+ function Le() {
18120
+ let e = X_(g, Pe);
18121
+ e.trimmed && g.splice(e.deleteFrom, e.deleteCount, e.summary);
17984
18122
  }
17985
- function je() {
17986
- if (!z.sessionId || !u) return;
17987
- let t = JSON.parse(JSON.stringify(m));
17988
- u.save(n, z.sessionId, { messages: t });
17989
- let r = z.agent?.getState?.()?.todos ?? [];
17990
- u.save(n, z.sessionId, { todos: r }), e.debug && console.log("[page-agent-sdk][persist] save", z.sessionId, `${m.length} msgs`);
18123
+ function B() {
18124
+ if (!z.sessionId || !d) return;
18125
+ let t = JSON.parse(JSON.stringify(g));
18126
+ d.save(i, z.sessionId, { messages: t });
18127
+ let n = z.agent?.getState?.()?.todos ?? [];
18128
+ d.save(i, z.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", z.sessionId, `${g.length} msgs`);
17991
18129
  }
17992
18130
  return z.initDone = (async () => {
17993
- if (await Oe(), await ke(), e.mcp?.length) {
18131
+ if (await Fe(), await Ie(), e.mcp?.length) {
17994
18132
  let t = await Promise.allSettled(e.mcp.map((e) => K_(e)));
17995
18133
  z.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), z.mcpServers = [];
17996
18134
  let n = [];
@@ -18000,8 +18138,8 @@ function ib(e, n) {
18000
18138
  name: a,
18001
18139
  url: i.url,
18002
18140
  toolCount: t.value.tools.length
18003
- }), t.value.tools.forEach((e) => M.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
18004
- }), te.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${z.mcpServers.length} 个 server`);
18141
+ }), t.value.tools.forEach((e) => N.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
18142
+ }), ie = ae(), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${z.mcpServers.length} 个 server`);
18005
18143
  }
18006
18144
  z.agent = Wg({
18007
18145
  ...Qy(e.llm) ? { llm: e.llm } : {
@@ -18011,17 +18149,27 @@ function ib(e, n) {
18011
18149
  temperature: e.llm.temperature,
18012
18150
  maxTokens: e.llm.maxTokens
18013
18151
  },
18014
- systemPrompt: D,
18015
- tools: te,
18016
- middleware: R,
18152
+ systemPrompt: k,
18153
+ tools: ie,
18154
+ middleware: Ne,
18017
18155
  maxToolRounds: e.maxToolRounds,
18018
18156
  maxRetries: e.maxRetries,
18019
18157
  maxParallelTools: e.maxParallelTools,
18020
- contextWindow: f.contextWindow,
18021
- maxOutputTokens: f.maxOutputTokens,
18022
- maxVerifyAttempts: le ? ce : 0,
18158
+ contextWindow: p.contextWindow,
18159
+ maxOutputTokens: p.maxOutputTokens,
18160
+ maxVerifyAttempts: fe ? de : 0,
18161
+ onLlmChange: (t) => {
18162
+ let n = Qy(t) ? void 0 : t;
18163
+ p = Eg({
18164
+ model: n?.model ?? t.model ?? t.modelName,
18165
+ contextWindow: e.contextWindow ?? n?.contextWindow,
18166
+ maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens
18167
+ }), m = t, e.debug && console.log("[page-agent-sdk][setLlm] 重解析 modelCaps:", p);
18168
+ },
18023
18169
  debug: e.debug
18024
- }), v.current = z.agent;
18170
+ }), b.current = z.agent, ge && ge.setReconfigureHook && ge.setReconfigureHook(() => {
18171
+ z.agent && z.agent.setTools(ae());
18172
+ });
18025
18173
  })(), z;
18026
18174
  }
18027
18175
  function ab(e) {
@@ -18192,7 +18340,15 @@ function ab(e) {
18192
18340
  },
18193
18341
  usage: i.usage,
18194
18342
  pendingConflict: i.pendingConflict,
18195
- resolveConflict: (e) => i.resolveConflict(e)
18343
+ resolveConflict: (e) => i.resolveConflict(e),
18344
+ setTools: (e) => i.setTools(e),
18345
+ addTool: (e) => i.addTool(e),
18346
+ removeTool: (e) => i.removeTool(e),
18347
+ setLlm: (e) => i.setLlm(e),
18348
+ setMemory: (e) => i.setMemory(e),
18349
+ setSubagents: (e) => i.setSubagents(e),
18350
+ addSubagent: (e) => i.addSubagent(e),
18351
+ removeSubagent: (e) => i.removeSubagent(e)
18196
18352
  };
18197
18353
  }
18198
18354
  //#endregion