page-agent-sdk 1.3.12 → 1.4.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.
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +120 -118
- package/dist/page-agent-sdk.js +1005 -848
- package/dist/page-agent-sdk.umd.cjs +65 -63
- package/package.json +1 -1
- package/types/index.d.ts +37 -0
package/dist/page-agent-sdk.js
CHANGED
|
@@ -24,19 +24,19 @@ function _(e) {
|
|
|
24
24
|
var v = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), y = process.env.NODE_ENV === "production" ? [] : Object.freeze([]), b = () => {}, x = () => !1, S = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), C = (e) => e.startsWith("onUpdate:"), w = Object.assign, T = (e, t) => {
|
|
25
25
|
let n = e.indexOf(t);
|
|
26
26
|
n > -1 && e.splice(n, 1);
|
|
27
|
-
}, E = Object.prototype.hasOwnProperty, D = (e, t) => E.call(e, t), O = Array.isArray, k = (e) =>
|
|
27
|
+
}, E = Object.prototype.hasOwnProperty, D = (e, t) => E.call(e, t), O = Array.isArray, k = (e) => ee(e) === "[object Map]", A = (e) => ee(e) === "[object Set]", j = (e) => ee(e) === "[object Date]", M = (e) => typeof e == "function", N = (e) => typeof e == "string", P = (e) => typeof e == "symbol", F = (e) => typeof e == "object" && !!e, I = (e) => (F(e) || M(e)) && M(e.then) && M(e.catch), L = Object.prototype.toString, ee = (e) => L.call(e), R = (e) => ee(e).slice(8, -1), te = (e) => ee(e) === "[object Object]", ne = (e) => N(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, re = /* @__PURE__ */ _(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ie = /* @__PURE__ */ _("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), ae = (e) => {
|
|
28
28
|
let t = /* @__PURE__ */ Object.create(null);
|
|
29
29
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
30
|
-
}, oe = /-\w/g, se = ae((e) => e.replace(oe, (e) => e.slice(1).toUpperCase())), ce = /\B([A-Z])/g,
|
|
30
|
+
}, oe = /-\w/g, se = ae((e) => e.replace(oe, (e) => e.slice(1).toUpperCase())), ce = /\B([A-Z])/g, le = ae((e) => e.replace(ce, "-$1").toLowerCase()), ue = ae((e) => e.charAt(0).toUpperCase() + e.slice(1)), de = ae((e) => e ? `on${ue(e)}` : ""), z = (e, t) => !Object.is(e, t), fe = (e, ...t) => {
|
|
31
31
|
for (let n = 0; n < e.length; n++) e[n](...t);
|
|
32
|
-
},
|
|
32
|
+
}, pe = (e, t, n, r = !1) => {
|
|
33
33
|
Object.defineProperty(e, t, {
|
|
34
34
|
configurable: !0,
|
|
35
35
|
enumerable: !1,
|
|
36
36
|
writable: r,
|
|
37
37
|
value: n
|
|
38
38
|
});
|
|
39
|
-
},
|
|
39
|
+
}, B = (e) => {
|
|
40
40
|
let t = parseFloat(e);
|
|
41
41
|
return isNaN(t) ? e : t;
|
|
42
42
|
}, me = (e) => {
|
|
@@ -275,7 +275,7 @@ function Qe(e) {
|
|
|
275
275
|
try {
|
|
276
276
|
Ye(e);
|
|
277
277
|
let n = e.fn(e._value);
|
|
278
|
-
(t.version === 0 ||
|
|
278
|
+
(t.version === 0 || z(n, e._value)) && (e.flags |= 128, e._value = n, t.version++);
|
|
279
279
|
} catch (e) {
|
|
280
280
|
throw t.version++, e;
|
|
281
281
|
} finally {
|
|
@@ -587,7 +587,7 @@ var kt = class {
|
|
|
587
587
|
if (!/* @__PURE__ */ on(n) && !/* @__PURE__ */ an(n) && (i = /* @__PURE__ */ U(i), n = /* @__PURE__ */ U(n)), !a && /* @__PURE__ */ dn(i) && !/* @__PURE__ */ dn(n)) return r ? (process.env.NODE_ENV !== "production" && Le(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
|
|
588
588
|
}
|
|
589
589
|
let o = a ? Number(t) < e.length : D(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ dn(e) ? e : r);
|
|
590
|
-
return e === /* @__PURE__ */ U(r) && s && (o ?
|
|
590
|
+
return e === /* @__PURE__ */ U(r) && s && (o ? z(n, i) && ht(e, "set", t, n, i) : ht(e, "add", t, n)), s;
|
|
591
591
|
}
|
|
592
592
|
deleteProperty(e, t) {
|
|
593
593
|
let n = D(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
|
|
@@ -630,7 +630,7 @@ function zt(e) {
|
|
|
630
630
|
return function(...t) {
|
|
631
631
|
if (process.env.NODE_ENV !== "production") {
|
|
632
632
|
let n = t[0] ? `on key "${t[0]}" ` : "";
|
|
633
|
-
Le(`${
|
|
633
|
+
Le(`${ue(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ U(this));
|
|
634
634
|
}
|
|
635
635
|
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
|
|
636
636
|
};
|
|
@@ -639,7 +639,7 @@ function Bt(e, t) {
|
|
|
639
639
|
let n = {
|
|
640
640
|
get(n) {
|
|
641
641
|
let r = this.__v_raw, i = /* @__PURE__ */ U(r), a = /* @__PURE__ */ U(n);
|
|
642
|
-
e || (
|
|
642
|
+
e || (z(n, a) && mt(i, "get", n), mt(i, "get", a));
|
|
643
643
|
let { has: o } = Lt(i), s = t ? It : e ? un : ln;
|
|
644
644
|
if (o.call(i, n)) return s(r.get(n));
|
|
645
645
|
if (o.call(i, a)) return s(r.get(a));
|
|
@@ -651,7 +651,7 @@ function Bt(e, t) {
|
|
|
651
651
|
},
|
|
652
652
|
has(t) {
|
|
653
653
|
let n = this.__v_raw, r = /* @__PURE__ */ U(n), i = /* @__PURE__ */ U(t);
|
|
654
|
-
return e || (
|
|
654
|
+
return e || (z(t, i) && mt(r, "has", t), mt(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
|
|
655
655
|
},
|
|
656
656
|
forEach(n, r) {
|
|
657
657
|
let i = this, a = i.__v_raw, o = /* @__PURE__ */ U(a), s = t ? It : e ? un : ln;
|
|
@@ -666,14 +666,14 @@ function Bt(e, t) {
|
|
|
666
666
|
} : {
|
|
667
667
|
add(e) {
|
|
668
668
|
let n = /* @__PURE__ */ U(this), r = Lt(n), i = /* @__PURE__ */ U(e), a = !t && !/* @__PURE__ */ on(e) && !/* @__PURE__ */ an(e) ? i : e;
|
|
669
|
-
return r.has.call(n, a) ||
|
|
669
|
+
return r.has.call(n, a) || z(e, a) && r.has.call(n, e) || z(i, a) && r.has.call(n, i) || (n.add(a), ht(n, "add", a, a)), this;
|
|
670
670
|
},
|
|
671
671
|
set(e, n) {
|
|
672
672
|
!t && !/* @__PURE__ */ on(n) && !/* @__PURE__ */ an(n) && (n = /* @__PURE__ */ U(n));
|
|
673
673
|
let r = /* @__PURE__ */ U(this), { has: i, get: a } = Lt(r), o = i.call(r, e);
|
|
674
674
|
o ? process.env.NODE_ENV !== "production" && Kt(r, i, e) : (e = /* @__PURE__ */ U(e), o = i.call(r, e));
|
|
675
675
|
let s = a.call(r, e);
|
|
676
|
-
return r.set(e, n), o ?
|
|
676
|
+
return r.set(e, n), o ? z(n, s) && ht(r, "set", e, n, s) : ht(r, "add", e, n), this;
|
|
677
677
|
},
|
|
678
678
|
delete(e) {
|
|
679
679
|
let t = /* @__PURE__ */ U(this), { has: n, get: r } = Lt(t), i = n.call(t, e);
|
|
@@ -702,7 +702,7 @@ var Ht = { get: /* @__PURE__ */ Vt(!1, !1) }, Ut = { get: /* @__PURE__ */ Vt(!1,
|
|
|
702
702
|
function Kt(e, t, n) {
|
|
703
703
|
let r = /* @__PURE__ */ U(n);
|
|
704
704
|
if (r !== n && t.call(e, r)) {
|
|
705
|
-
let t =
|
|
705
|
+
let t = R(e);
|
|
706
706
|
Le(`Reactive ${t} contains both the raw and reactive versions of the same object${t === "Map" ? " as keys" : ""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
|
|
707
707
|
}
|
|
708
708
|
}
|
|
@@ -739,7 +739,7 @@ function nn(e, t, n, r, i) {
|
|
|
739
739
|
if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
|
|
740
740
|
let a = i.get(e);
|
|
741
741
|
if (a) return a;
|
|
742
|
-
let o = Zt(
|
|
742
|
+
let o = Zt(R(e));
|
|
743
743
|
if (o === 0) return e;
|
|
744
744
|
let s = new Proxy(e, o === 2 ? r : n);
|
|
745
745
|
return i.set(e, s), s;
|
|
@@ -766,7 +766,7 @@ function U(e) {
|
|
|
766
766
|
return t ? /* @__PURE__ */ U(t) : e;
|
|
767
767
|
}
|
|
768
768
|
function cn(e) {
|
|
769
|
-
return !D(e, "__v_skip") && Object.isExtensible(e) &&
|
|
769
|
+
return !D(e, "__v_skip") && Object.isExtensible(e) && pe(e, "__v_skip", !0), e;
|
|
770
770
|
}
|
|
771
771
|
var ln = (e) => F(e) ? /* @__PURE__ */ Qt(e) : e, un = (e) => F(e) ? /* @__PURE__ */ en(e) : e;
|
|
772
772
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -797,7 +797,7 @@ var hn = class {
|
|
|
797
797
|
}
|
|
798
798
|
set value(e) {
|
|
799
799
|
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ on(e) || /* @__PURE__ */ an(e);
|
|
800
|
-
e = n ? e : /* @__PURE__ */ U(e),
|
|
800
|
+
e = n ? e : /* @__PURE__ */ U(e), z(e, t) && (this._rawValue = e, this._value = n ? e : ln(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
|
|
801
801
|
target: this,
|
|
802
802
|
type: "set",
|
|
803
803
|
key: "value",
|
|
@@ -903,7 +903,7 @@ function Tn(e, t, n = v) {
|
|
|
903
903
|
let x = g ? Array(e.length).fill(xn) : xn, S = (e) => {
|
|
904
904
|
if (!(!(d.flags & 1) || !d.dirty && !e)) if (t) {
|
|
905
905
|
let n = d.run();
|
|
906
|
-
if (e || i || h || (g ? n.some((e, t) =>
|
|
906
|
+
if (e || i || h || (g ? n.some((e, t) => z(e, x[t])) : z(n, x))) {
|
|
907
907
|
p && p();
|
|
908
908
|
let e = Cn;
|
|
909
909
|
Cn = d;
|
|
@@ -1772,7 +1772,7 @@ function Li(e, t, n = ps, r = !1) {
|
|
|
1772
1772
|
return i(), it(), a;
|
|
1773
1773
|
};
|
|
1774
1774
|
return r ? i.unshift(a) : i.push(a), a;
|
|
1775
|
-
} else process.env.NODE_ENV !== "production" && G(`${
|
|
1775
|
+
} else process.env.NODE_ENV !== "production" && G(`${de(Ln[e].replace(/ hook$/, ""))} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
|
|
1776
1776
|
}
|
|
1777
1777
|
var Ri = (e) => (t, n = ps) => {
|
|
1778
1778
|
(!Ss || e === "sp") && Li(e, (...e) => t(...e), n);
|
|
@@ -2169,25 +2169,25 @@ function wa(e, t) {
|
|
|
2169
2169
|
return c;
|
|
2170
2170
|
};
|
|
2171
2171
|
}
|
|
2172
|
-
var Ta = null, Ea = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${se(t)}Modifiers`] || e[`${
|
|
2172
|
+
var Ta = null, Ea = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${se(t)}Modifiers`] || e[`${le(t)}Modifiers`];
|
|
2173
2173
|
function Da(e, t, ...n) {
|
|
2174
2174
|
if (e.isUnmounted) return;
|
|
2175
2175
|
let r = e.vnode.props || v;
|
|
2176
2176
|
if (process.env.NODE_ENV !== "production") {
|
|
2177
2177
|
let { emitsOptions: r, propsOptions: [i] } = e;
|
|
2178
|
-
if (r) if (!(t in r)) (!i || !(
|
|
2178
|
+
if (r) if (!(t in r)) (!i || !(de(se(t)) in i)) && G(`Component emitted event "${t}" but it is neither declared in the emits option nor as an "${de(se(t))}" prop.`);
|
|
2179
2179
|
else {
|
|
2180
2180
|
let e = r[t];
|
|
2181
2181
|
M(e) && (e(...n) || G(`Invalid event arguments: event validation failed for event "${t}".`));
|
|
2182
2182
|
}
|
|
2183
2183
|
}
|
|
2184
2184
|
let i = n, a = t.startsWith("update:"), o = a && Ea(r, t.slice(7));
|
|
2185
|
-
if (o && (o.trim && (i = n.map((e) => N(e) ? e.trim() : e)), o.number && (i = n.map(
|
|
2185
|
+
if (o && (o.trim && (i = n.map((e) => N(e) ? e.trim() : e)), o.number && (i = n.map(B))), process.env.NODE_ENV !== "production" && Nr(e, t, i), process.env.NODE_ENV !== "production") {
|
|
2186
2186
|
let n = t.toLowerCase();
|
|
2187
|
-
n !== t && r[
|
|
2187
|
+
n !== t && r[de(n)] && G(`Event "${n}" is emitted in component ${Ls(e, e.type)} but the handler is registered for "${t}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${le(t)}" instead of "${t}".`);
|
|
2188
2188
|
}
|
|
2189
|
-
let s, c = r[s =
|
|
2190
|
-
!c && a && (c = r[s =
|
|
2189
|
+
let s, c = r[s = de(t)] || r[s = de(se(t))];
|
|
2190
|
+
!c && a && (c = r[s = de(le(t))]), c && zn(c, e, 6, i);
|
|
2191
2191
|
let l = r[s + "Once"];
|
|
2192
2192
|
if (l) {
|
|
2193
2193
|
if (!e.emitted) e.emitted = {};
|
|
@@ -2210,7 +2210,7 @@ function ka(e, t, n = !1) {
|
|
|
2210
2210
|
return !a && !s ? (F(e) && r.set(e, null), null) : (O(a) ? a.forEach((e) => o[e] = null) : w(o, a), F(e) && r.set(e, o), o);
|
|
2211
2211
|
}
|
|
2212
2212
|
function Aa(e, t) {
|
|
2213
|
-
return !e || !S(t) ? !1 : (t = t.slice(2), t = t === "Once" ? t : t.replace(/Once$/, ""), D(e, t[0].toLowerCase() + t.slice(1)) || D(e,
|
|
2213
|
+
return !e || !S(t) ? !1 : (t = t.slice(2), t = t === "Once" ? t : t.replace(/Once$/, ""), D(e, t[0].toLowerCase() + t.slice(1)) || D(e, le(t)) || D(e, t));
|
|
2214
2214
|
}
|
|
2215
2215
|
var ja = !1;
|
|
2216
2216
|
function Ma() {
|
|
@@ -2360,7 +2360,7 @@ function Ja(e, t, n, r) {
|
|
|
2360
2360
|
} else {
|
|
2361
2361
|
Ya(e, t, i, a) && (l = !0);
|
|
2362
2362
|
let r;
|
|
2363
|
-
for (let a in s) (!t || !D(t, a) && ((r =
|
|
2363
|
+
for (let a in s) (!t || !D(t, a) && ((r = le(a)) === a || !D(t, r))) && (c ? n && (n[a] !== void 0 || n[r] !== void 0) && (i[a] = Xa(c, s, a, void 0, e, !0)) : delete i[a]);
|
|
2364
2364
|
if (a !== s) for (let e in a) (!t || !D(t, e)) && (delete a[e], l = !0);
|
|
2365
2365
|
}
|
|
2366
2366
|
l && ht(e.attrs, "set", ""), process.env.NODE_ENV !== "production" && to(t || {}, i, e);
|
|
@@ -2397,7 +2397,7 @@ function Xa(e, t, n, r, i, a) {
|
|
|
2397
2397
|
} else r = e;
|
|
2398
2398
|
i.ce && i.ce._setProp(n, r);
|
|
2399
2399
|
}
|
|
2400
|
-
o[0] && (a && !e ? r = !1 : o[1] && (r === "" || r ===
|
|
2400
|
+
o[0] && (a && !e ? r = !1 : o[1] && (r === "" || r === le(n)) && (r = !0));
|
|
2401
2401
|
}
|
|
2402
2402
|
return r;
|
|
2403
2403
|
}
|
|
@@ -2490,7 +2490,7 @@ function io(e, t) {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
function ao(e, t, n) {
|
|
2492
2492
|
if (n.length === 0) return `Prop type [] for prop "${e}" won't match anything. Did you mean to use type Array instead?`;
|
|
2493
|
-
let r = `Invalid prop: type check failed for prop "${e}". Expected ${n.map(
|
|
2493
|
+
let r = `Invalid prop: type check failed for prop "${e}". Expected ${n.map(ue).join(" | ")}`, i = n[0], a = R(t), o = oo(t, i), s = oo(t, a);
|
|
2494
2494
|
return n.length === 1 && so(i) && co(i, a) && (r += ` with value ${o}`), r += `, got ${a} `, so(a) && (r += `with value ${s}.`), r;
|
|
2495
2495
|
}
|
|
2496
2496
|
function oo(e, t) {
|
|
@@ -2535,7 +2535,7 @@ var lo = (e) => e === "_" || e === "_ctx" || e === "$stable", uo = (e) => O(e) ?
|
|
|
2535
2535
|
let r = e.slots = Wa();
|
|
2536
2536
|
if (e.vnode.shapeFlag & 32) {
|
|
2537
2537
|
let e = t._;
|
|
2538
|
-
e ? (ho(r, t, n), n &&
|
|
2538
|
+
e ? (ho(r, t, n), n && pe(r, "_", e, !0)) : po(t, r);
|
|
2539
2539
|
} else t && mo(e, t);
|
|
2540
2540
|
}, _o = (e, t, n) => {
|
|
2541
2541
|
let { vnode: r, slots: i } = e, a = !0, o = v;
|
|
@@ -2577,7 +2577,7 @@ function Eo(e, t) {
|
|
|
2577
2577
|
n.__VUE__ = !0, process.env.NODE_ENV !== "production" && Sr(n.__VUE_DEVTOOLS_GLOBAL_HOOK__, n);
|
|
2578
2578
|
let { insert: r, remove: i, patchProp: a, createElement: o, createText: s, createComment: c, setText: l, setElementText: u, parentNode: d, nextSibling: f, setScopeId: p = b, insertStaticContent: m } = e, h = (e, t, n, r = null, i = null, a = null, o = void 0, s = null, c = process.env.NODE_ENV !== "production" && or ? !1 : !!t.dynamicChildren) => {
|
|
2579
2579
|
if (e === t) return;
|
|
2580
|
-
e && !Jo(e, t) && (r =
|
|
2580
|
+
e && !Jo(e, t) && (r = le(e), ie(e, i, a, !0), e = null), t.patchFlag === -2 && (c = !1, t.dynamicChildren = null);
|
|
2581
2581
|
let { type: l, ref: u, shapeFlag: d } = t;
|
|
2582
2582
|
switch (l) {
|
|
2583
2583
|
case Lo:
|
|
@@ -2592,7 +2592,7 @@ function Eo(e, t) {
|
|
|
2592
2592
|
case K:
|
|
2593
2593
|
M(e, t, n, r, i, a, o, s, c);
|
|
2594
2594
|
break;
|
|
2595
|
-
default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ? N(e, t, n, r, i, a, o, s, c) : d & 64 || d & 128 ? l.process(e, t, n, r, i, a, o, s, c,
|
|
2595
|
+
default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ? N(e, t, n, r, i, a, o, s, c) : d & 64 || d & 128 ? l.process(e, t, n, r, i, a, o, s, c, z) : process.env.NODE_ENV !== "production" && G("Invalid VNode type:", l, `(${typeof l})`);
|
|
2596
2596
|
}
|
|
2597
2597
|
u != null && i ? ki(u, e && e.ref, a, t || e, !t) : u == null && e && e.ref != null && ki(e.ref, null, a, e, !0);
|
|
2598
2598
|
}, g = (e, t, n, i) => {
|
|
@@ -2634,7 +2634,7 @@ function Eo(e, t) {
|
|
|
2634
2634
|
for (let e in m) e !== "value" && !re(e) && a(f, e, null, m[e], c, i);
|
|
2635
2635
|
"value" in m && a(f, "value", null, m.value, c), (p = m.onVnodeBeforeMount) && ls(p, i, e);
|
|
2636
2636
|
}
|
|
2637
|
-
process.env.NODE_ENV !== "production" && (
|
|
2637
|
+
process.env.NODE_ENV !== "production" && (pe(f, "__vnode", e, !0), pe(f, "__vueParentComponent", i, !0)), _ && Br(e, null, i, "beforeMount");
|
|
2638
2638
|
let v = ko(s, g);
|
|
2639
2639
|
if (v && g.beforeEnter(f), r(f, t, n), (p = m && m.onVnodeMounted) || v || _) {
|
|
2640
2640
|
let t = process.env.NODE_ENV !== "production" && or;
|
|
@@ -2668,7 +2668,7 @@ function Eo(e, t) {
|
|
|
2668
2668
|
let { patchFlag: l, dynamicChildren: d, dirs: f } = t;
|
|
2669
2669
|
l |= e.patchFlag & 16;
|
|
2670
2670
|
let p = e.props || v, m = t.props || v, h;
|
|
2671
|
-
if (n && Oo(n, !1), (h = m.onVnodeBeforeUpdate) && ls(h, n, t, e), f && Br(t, e, n, "beforeUpdate"), n && Oo(n, !0), (process.env.NODE_ENV !== "production" && or || 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, Do(t, i), o), process.env.NODE_ENV !== "production" && Ao(e, t)) : s ||
|
|
2671
|
+
if (n && Oo(n, !1), (h = m.onVnodeBeforeUpdate) && ls(h, n, t, e), f && Br(t, e, n, "beforeUpdate"), n && Oo(n, !0), (process.env.NODE_ENV !== "production" && or || 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, Do(t, i), o), process.env.NODE_ENV !== "production" && Ao(e, t)) : s || ee(e, t, c, null, n, r, Do(t, i), o, !1), l > 0) {
|
|
2672
2672
|
if (l & 16) j(c, p, m, n, i);
|
|
2673
2673
|
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) {
|
|
2674
2674
|
let e = t.dynamicProps;
|
|
@@ -2699,12 +2699,12 @@ function Eo(e, t) {
|
|
|
2699
2699
|
}
|
|
2700
2700
|
}, M = (e, t, n, i, a, o, c, l, u) => {
|
|
2701
2701
|
let d = t.el = e ? e.el : s(""), f = t.anchor = e ? e.anchor : s(""), { patchFlag: p, dynamicChildren: m, slotScopeIds: h } = t;
|
|
2702
|
-
process.env.NODE_ENV !== "production" && (or || 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) && Ao(e, t, !0) : Ao(e, t)) :
|
|
2702
|
+
process.env.NODE_ENV !== "production" && (or || 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) && Ao(e, t, !0) : Ao(e, t)) : ee(e, t, n, f, a, o, c, l, u);
|
|
2703
2703
|
}, N = (e, t, n, r, i, a, o, s, c) => {
|
|
2704
2704
|
t.slotScopeIds = s, e == null ? t.shapeFlag & 512 ? i.ctx.activate(t, n, r, o, c) : P(t, n, r, i, a, o, c) : F(e, t, c);
|
|
2705
2705
|
}, P = (e, t, n, r, i, a, o) => {
|
|
2706
2706
|
let s = e.component = fs(e, r, i);
|
|
2707
|
-
if (process.env.NODE_ENV !== "production" && s.type.__hmrId && ur(s), process.env.NODE_ENV !== "production" && (On(e), bo(s, "mount")), Mi(e) && (s.ctx.renderer =
|
|
2707
|
+
if (process.env.NODE_ENV !== "production" && s.type.__hmrId && ur(s), process.env.NODE_ENV !== "production" && (On(e), bo(s, "mount")), Mi(e) && (s.ctx.renderer = z), process.env.NODE_ENV !== "production" && bo(s, "init"), Cs(s, !1, o), process.env.NODE_ENV !== "production" && xo(s, "init"), process.env.NODE_ENV !== "production" && or && (e.el = null), s.asyncDep) {
|
|
2708
2708
|
if (i && i.registerDep(s, I, o), !e.el) {
|
|
2709
2709
|
let r = s.subTree = $o(Ro);
|
|
2710
2710
|
_(null, r, t, n), e.placeholder = r.el;
|
|
@@ -2734,14 +2734,14 @@ function Eo(e, t) {
|
|
|
2734
2734
|
}
|
|
2735
2735
|
}
|
|
2736
2736
|
let u = t, f;
|
|
2737
|
-
process.env.NODE_ENV !== "production" && On(t || e.vnode), Oo(e, !1), t ? (t.el = c.el, L(e, t, o)) : t = c, n &&
|
|
2737
|
+
process.env.NODE_ENV !== "production" && On(t || e.vnode), Oo(e, !1), t ? (t.el = c.el, L(e, t, o)) : t = c, n && fe(n), (f = t.props && t.props.onVnodeBeforeUpdate) && ls(f, s, t, c), Oo(e, !0), process.env.NODE_ENV !== "production" && bo(e, "render");
|
|
2738
2738
|
let p = Na(e);
|
|
2739
2739
|
process.env.NODE_ENV !== "production" && xo(e, "render");
|
|
2740
2740
|
let m = e.subTree;
|
|
2741
|
-
e.subTree = p, process.env.NODE_ENV !== "production" && bo(e, "patch"), h(m, p, d(m.el),
|
|
2741
|
+
e.subTree = p, process.env.NODE_ENV !== "production" && bo(e, "patch"), h(m, p, d(m.el), le(m), e, i, a), process.env.NODE_ENV !== "production" && xo(e, "patch"), t.el = p.el, u === null && Ha(e, p.el), r && wo(r, i), (f = t.props && t.props.onVnodeUpdated) && wo(() => ls(f, s, t, c), i), process.env.NODE_ENV !== "production" && Er(e), process.env.NODE_ENV !== "production" && kn();
|
|
2742
2742
|
} else {
|
|
2743
2743
|
let o, { el: s, props: c } = t, { bm: l, m: u, parent: d, root: f, type: p } = e, m = ji(t);
|
|
2744
|
-
if (Oo(e, !1), l &&
|
|
2744
|
+
if (Oo(e, !1), l && fe(l), !m && (o = c && c.onVnodeBeforeMount) && ls(o, d, t), Oo(e, !0), s && me) {
|
|
2745
2745
|
let t = () => {
|
|
2746
2746
|
process.env.NODE_ENV !== "production" && bo(e, "render"), e.subTree = Na(e), process.env.NODE_ENV !== "production" && xo(e, "render"), process.env.NODE_ENV !== "production" && bo(e, "hydrate"), me(s, e.subTree, e, i, null), process.env.NODE_ENV !== "production" && xo(e, "hydrate");
|
|
2747
2747
|
};
|
|
@@ -2762,24 +2762,24 @@ function Eo(e, t) {
|
|
|
2762
2762
|
let c = e.effect = new He(s);
|
|
2763
2763
|
e.scope.off();
|
|
2764
2764
|
let l = e.update = c.run.bind(c), u = e.job = c.runIfDirty.bind(c);
|
|
2765
|
-
u.i = e, u.id = e.uid, c.scheduler = () => Qn(u), Oo(e, !0), process.env.NODE_ENV !== "production" && (c.onTrack = e.rtc ? (t) =>
|
|
2765
|
+
u.i = e, u.id = e.uid, c.scheduler = () => Qn(u), Oo(e, !0), process.env.NODE_ENV !== "production" && (c.onTrack = e.rtc ? (t) => fe(e.rtc, t) : void 0, c.onTrigger = e.rtg ? (t) => fe(e.rtg, t) : void 0), l();
|
|
2766
2766
|
}, L = (e, t, n) => {
|
|
2767
2767
|
t.component = e;
|
|
2768
2768
|
let r = e.vnode.props;
|
|
2769
2769
|
e.vnode = t, e.next = null, Ja(e, t.props, r, n), _o(e, t.children, n), rt(), tr(e), it();
|
|
2770
|
-
},
|
|
2770
|
+
}, ee = (e, t, n, r, i, a, o, s, c = !1) => {
|
|
2771
2771
|
let l = e && e.children, d = e ? e.shapeFlag : 0, f = t.children, { patchFlag: p, shapeFlag: m } = t;
|
|
2772
2772
|
if (p > 0) {
|
|
2773
2773
|
if (p & 128) {
|
|
2774
2774
|
te(l, f, n, r, i, a, o, s, c);
|
|
2775
2775
|
return;
|
|
2776
2776
|
} else if (p & 256) {
|
|
2777
|
-
|
|
2777
|
+
R(l, f, n, r, i, a, o, s, c);
|
|
2778
2778
|
return;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
2781
|
m & 8 ? (d & 16 && ce(l, i, a), f !== l && u(n, f)) : d & 16 ? m & 16 ? te(l, f, n, r, i, a, o, s, c) : ce(l, i, a, !0) : (d & 8 && u(n, ""), m & 16 && O(f, n, r, i, a, o, s, c));
|
|
2782
|
-
},
|
|
2782
|
+
}, R = (e, t, n, r, i, a, o, s, c) => {
|
|
2783
2783
|
e ||= y, t ||= y;
|
|
2784
2784
|
let l = e.length, u = t.length, d = Math.min(l, u), f;
|
|
2785
2785
|
for (f = 0; f < d; f++) {
|
|
@@ -2846,7 +2846,7 @@ function Eo(e, t) {
|
|
|
2846
2846
|
return;
|
|
2847
2847
|
}
|
|
2848
2848
|
if (d & 64) {
|
|
2849
|
-
c.move(e, t, n,
|
|
2849
|
+
c.move(e, t, n, z);
|
|
2850
2850
|
return;
|
|
2851
2851
|
}
|
|
2852
2852
|
if (c === K) {
|
|
@@ -2885,7 +2885,7 @@ function Eo(e, t) {
|
|
|
2885
2885
|
e.suspense.unmount(n, r);
|
|
2886
2886
|
return;
|
|
2887
2887
|
}
|
|
2888
|
-
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n,
|
|
2888
|
+
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n, z, r) : l && !l.hasOnce && (a !== K || d > 0 && d & 64) ? ce(l, t, n, !1, !0) : (a === K && d & 384 || !i && u & 16) && ce(c, t, n), r && ae(e);
|
|
2889
2889
|
}
|
|
2890
2890
|
let v = m != null && p == null;
|
|
2891
2891
|
(g && (_ = o && o.onVnodeUnmounted) || h || v) && wo(() => {
|
|
@@ -2917,35 +2917,35 @@ function Eo(e, t) {
|
|
|
2917
2917
|
}, se = (e, t, n) => {
|
|
2918
2918
|
process.env.NODE_ENV !== "production" && e.type.__hmrId && dr(e);
|
|
2919
2919
|
let { bum: r, scope: i, job: a, subTree: o, um: s, m: c, a: l } = e;
|
|
2920
|
-
No(c), No(l), r &&
|
|
2920
|
+
No(c), No(l), r && fe(r), i.stop(), a && (a.flags |= 8, ie(o, e, t, n)), s && wo(s, t), wo(() => {
|
|
2921
2921
|
e.isUnmounted = !0;
|
|
2922
2922
|
}, t), process.env.NODE_ENV !== "production" && Or(e);
|
|
2923
2923
|
}, ce = (e, t, n, r = !1, i = !1, a = 0) => {
|
|
2924
2924
|
for (let o = a; o < e.length; o++) ie(e[o], t, n, r, i);
|
|
2925
|
-
},
|
|
2926
|
-
if (e.shapeFlag & 6) return
|
|
2925
|
+
}, le = (e) => {
|
|
2926
|
+
if (e.shapeFlag & 6) return le(e.component.subTree);
|
|
2927
2927
|
if (e.shapeFlag & 128) return e.suspense.next();
|
|
2928
2928
|
let t = f(e.anchor || e.el), n = t && t[Xr];
|
|
2929
2929
|
return n ? f(n) : t;
|
|
2930
|
-
},
|
|
2930
|
+
}, ue = !1, de = (e, t, n) => {
|
|
2931
2931
|
let r;
|
|
2932
|
-
e == null ? t._vnode && (ie(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e,
|
|
2933
|
-
},
|
|
2932
|
+
e == null ? t._vnode && (ie(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e, ue ||= (ue = !0, tr(r), nr(), !1);
|
|
2933
|
+
}, z = {
|
|
2934
2934
|
p: h,
|
|
2935
2935
|
um: ie,
|
|
2936
2936
|
m: ne,
|
|
2937
2937
|
r: ae,
|
|
2938
2938
|
mt: P,
|
|
2939
2939
|
mc: O,
|
|
2940
|
-
pc:
|
|
2940
|
+
pc: ee,
|
|
2941
2941
|
pbc: A,
|
|
2942
|
-
n:
|
|
2942
|
+
n: le,
|
|
2943
2943
|
o: e
|
|
2944
|
-
},
|
|
2945
|
-
return t && ([
|
|
2946
|
-
render:
|
|
2947
|
-
hydrate:
|
|
2948
|
-
createApp: wa(
|
|
2944
|
+
}, B, me;
|
|
2945
|
+
return t && ([B, me] = t(z)), {
|
|
2946
|
+
render: de,
|
|
2947
|
+
hydrate: B,
|
|
2948
|
+
createApp: wa(de, B)
|
|
2949
2949
|
};
|
|
2950
2950
|
}
|
|
2951
2951
|
function Do({ type: e, props: t }, n) {
|
|
@@ -3798,7 +3798,7 @@ function Oc(e, t, n) {
|
|
|
3798
3798
|
else if (n ??= "", process.env.NODE_ENV !== "production" && Ec.test(n) && Us(`Unexpected semicolon at the end of '${t}' style value: '${n}'`), t.startsWith("--")) e.setProperty(t, n);
|
|
3799
3799
|
else {
|
|
3800
3800
|
let r = jc(e, t);
|
|
3801
|
-
Dc.test(n) ? e.setProperty(
|
|
3801
|
+
Dc.test(n) ? e.setProperty(le(r), n.replace(Dc, ""), "important") : e[r] = n;
|
|
3802
3802
|
}
|
|
3803
3803
|
}
|
|
3804
3804
|
var kc = [
|
|
@@ -3811,7 +3811,7 @@ function jc(e, t) {
|
|
|
3811
3811
|
if (n) return n;
|
|
3812
3812
|
let r = se(t);
|
|
3813
3813
|
if (r !== "filter" && r in e) return Ac[t] = r;
|
|
3814
|
-
r =
|
|
3814
|
+
r = ue(r);
|
|
3815
3815
|
for (let n = 0; n < kc.length; n++) {
|
|
3816
3816
|
let i = kc[n] + r;
|
|
3817
3817
|
if (i in e) return Ac[t] = i;
|
|
@@ -3867,7 +3867,7 @@ var Bc = /(Once|Passive|Capture)$/, Vc = /^on:?(?:Once|Passive|Capture)$/;
|
|
|
3867
3867
|
function Hc(e) {
|
|
3868
3868
|
let t, n;
|
|
3869
3869
|
for (; (n = e.match(Bc)) && !Vc.test(e);) t ||= {}, e = e.slice(0, e.length - n[1].length), t[n[1].toLowerCase()] = !0;
|
|
3870
|
-
return [e[2] === ":" ? e.slice(3) :
|
|
3870
|
+
return [e[2] === ":" ? e.slice(3) : le(e.slice(2)), t];
|
|
3871
3871
|
}
|
|
3872
3872
|
var Uc = 0, Wc = /* @__PURE__ */ Promise.resolve(), Gc = () => Uc ||= (Wc.then(() => Uc = 0), Date.now());
|
|
3873
3873
|
function Kc(e, t) {
|
|
@@ -3914,7 +3914,7 @@ function Zc(e, t) {
|
|
|
3914
3914
|
}
|
|
3915
3915
|
var Qc = (e) => {
|
|
3916
3916
|
let t = e.props["onUpdate:modelValue"] || !1;
|
|
3917
|
-
return O(t) ? (e) =>
|
|
3917
|
+
return O(t) ? (e) => fe(t, e) : t;
|
|
3918
3918
|
};
|
|
3919
3919
|
function $c(e) {
|
|
3920
3920
|
e.target.composing = !0;
|
|
@@ -3925,7 +3925,7 @@ function el(e) {
|
|
|
3925
3925
|
}
|
|
3926
3926
|
var tl = /* @__PURE__ */ Symbol("_assign");
|
|
3927
3927
|
function nl(e, t, n) {
|
|
3928
|
-
return t && (e = e.trim()), n && (e =
|
|
3928
|
+
return t && (e = e.trim()), n && (e = B(e)), e;
|
|
3929
3929
|
}
|
|
3930
3930
|
var rl = {
|
|
3931
3931
|
created(e, { modifiers: { lazy: t, trim: n, number: r } }, i) {
|
|
@@ -3942,7 +3942,7 @@ var rl = {
|
|
|
3942
3942
|
},
|
|
3943
3943
|
beforeUpdate(e, { value: t, oldValue: n, modifiers: { lazy: r, trim: i, number: a } }, o) {
|
|
3944
3944
|
if (e[tl] = Qc(o), e.composing) return;
|
|
3945
|
-
let s = (a || e.type === "number") && !/^0\d/.test(e.value) ?
|
|
3945
|
+
let s = (a || e.type === "number") && !/^0\d/.test(e.value) ? B(e.value) : e.value, c = t ?? "";
|
|
3946
3946
|
if (s === c) return;
|
|
3947
3947
|
let l = e.getRootNode();
|
|
3948
3948
|
(l instanceof Document || l instanceof ShadowRoot) && l.activeElement === e && e.type !== "range" && (r && t === n || i && e.value.trim() === c) || (e.value = c);
|
|
@@ -4090,19 +4090,23 @@ function xl(e = {}) {
|
|
|
4090
4090
|
let e = o.value;
|
|
4091
4091
|
e && (s.value = e.scrollHeight - e.scrollTop - e.clientHeight < 64);
|
|
4092
4092
|
}
|
|
4093
|
-
function d() {
|
|
4094
|
-
|
|
4095
|
-
|
|
4093
|
+
function d(e) {
|
|
4094
|
+
e.deltaY < 0 && (s.value = !1);
|
|
4095
|
+
}
|
|
4096
|
+
function f() {
|
|
4097
|
+
o.value && requestAnimationFrame(() => {
|
|
4098
|
+
let e = o.value;
|
|
4099
|
+
!e || !s.value || (e.scrollTop = e.scrollHeight);
|
|
4096
4100
|
});
|
|
4097
4101
|
}
|
|
4098
|
-
function
|
|
4102
|
+
function p(e, t) {
|
|
4099
4103
|
a.messages.push({
|
|
4100
4104
|
role: e,
|
|
4101
4105
|
content: t,
|
|
4102
4106
|
timestamp: Date.now()
|
|
4103
|
-
}), s.value = !0,
|
|
4107
|
+
}), s.value = !0, f();
|
|
4104
4108
|
}
|
|
4105
|
-
async function
|
|
4109
|
+
async function m(e) {
|
|
4106
4110
|
if (s.value = !0, n) {
|
|
4107
4111
|
let t = /* @__PURE__ */ Qt({
|
|
4108
4112
|
role: "assistant",
|
|
@@ -4161,7 +4165,7 @@ function xl(e = {}) {
|
|
|
4161
4165
|
};
|
|
4162
4166
|
break;
|
|
4163
4167
|
}
|
|
4164
|
-
|
|
4168
|
+
f();
|
|
4165
4169
|
}, e);
|
|
4166
4170
|
} catch (n) {
|
|
4167
4171
|
if (gl(n, e) || (a.error = n.message || "请求失败,请重试"), !t.content && !t.reasoning) {
|
|
@@ -4174,39 +4178,39 @@ function xl(e = {}) {
|
|
|
4174
4178
|
return;
|
|
4175
4179
|
}
|
|
4176
4180
|
try {
|
|
4177
|
-
|
|
4181
|
+
p("assistant", await (t || _)(a.messages, e));
|
|
4178
4182
|
} catch (t) {
|
|
4179
4183
|
gl(t, e) || (a.error = t.message || "请求失败,请重试");
|
|
4180
4184
|
} finally {
|
|
4181
4185
|
await r?.(a.messages), a.loading = !1, c = null;
|
|
4182
4186
|
}
|
|
4183
4187
|
}
|
|
4184
|
-
async function
|
|
4185
|
-
!e.trim() || a.loading || (
|
|
4188
|
+
async function h(e) {
|
|
4189
|
+
!e.trim() || a.loading || (p("user", e.trim()), a.loading = !0, a.error = null, c = new AbortController(), await m(c.signal));
|
|
4186
4190
|
}
|
|
4187
|
-
async function
|
|
4191
|
+
async function g() {
|
|
4188
4192
|
if (a.loading) return;
|
|
4189
4193
|
let e = a.messages;
|
|
4190
4194
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].role === "assistant") {
|
|
4191
4195
|
e.splice(t);
|
|
4192
4196
|
break;
|
|
4193
4197
|
}
|
|
4194
|
-
e.some((e) => e.role === "user") && (a.loading = !0, a.error = null, c = new AbortController(), await
|
|
4198
|
+
e.some((e) => e.role === "user") && (a.loading = !0, a.error = null, c = new AbortController(), await m(c.signal));
|
|
4195
4199
|
}
|
|
4196
|
-
async function
|
|
4200
|
+
async function _(e) {
|
|
4197
4201
|
return await new Promise((e) => setTimeout(e, 800 + Math.random() * 1200)), `收到你的消息:"${e.filter((e) => e.role === "user").pop()?.content}"。这是一个模拟回复,请接入实际的 AI API。`;
|
|
4198
4202
|
}
|
|
4199
|
-
function
|
|
4203
|
+
function v() {
|
|
4200
4204
|
i?.(), a.messages.splice(0, a.messages.length), a.error = null;
|
|
4201
4205
|
}
|
|
4202
|
-
function
|
|
4206
|
+
function y() {
|
|
4203
4207
|
c?.abort();
|
|
4204
4208
|
}
|
|
4205
|
-
function
|
|
4209
|
+
function b(e) {
|
|
4206
4210
|
let t = l.value;
|
|
4207
4211
|
t && (l.value = null, t.resolve(e));
|
|
4208
4212
|
}
|
|
4209
|
-
async function
|
|
4213
|
+
async function x() {
|
|
4210
4214
|
if (!a.error) return;
|
|
4211
4215
|
let e = a.messages, t = -1;
|
|
4212
4216
|
for (let n = e.length - 1; n >= 0; n--) if (e[n].role === "user") {
|
|
@@ -4215,19 +4219,20 @@ function xl(e = {}) {
|
|
|
4215
4219
|
}
|
|
4216
4220
|
if (t < 0) return;
|
|
4217
4221
|
let n = e[t].content;
|
|
4218
|
-
e.splice(t), a.error = null, await
|
|
4222
|
+
e.splice(t), a.error = null, await h(n);
|
|
4219
4223
|
}
|
|
4220
4224
|
return {
|
|
4221
4225
|
state: a,
|
|
4222
4226
|
scrollContainer: o,
|
|
4223
4227
|
pendingApproval: l,
|
|
4224
|
-
sendMessage:
|
|
4225
|
-
clearMessages:
|
|
4226
|
-
stop:
|
|
4227
|
-
retry:
|
|
4228
|
-
regenerate:
|
|
4229
|
-
resolveApproval:
|
|
4230
|
-
onScroll: u
|
|
4228
|
+
sendMessage: h,
|
|
4229
|
+
clearMessages: v,
|
|
4230
|
+
stop: y,
|
|
4231
|
+
retry: x,
|
|
4232
|
+
regenerate: g,
|
|
4233
|
+
resolveApproval: b,
|
|
4234
|
+
onScroll: u,
|
|
4235
|
+
onWheel: d
|
|
4231
4236
|
};
|
|
4232
4237
|
}
|
|
4233
4238
|
//#endregion
|
|
@@ -5894,7 +5899,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5894
5899
|
});
|
|
5895
5900
|
let i = y("I", "a", "is", "so", "us", "to", "at", "if", "in", "it", "on", /[A-Za-z]+['](d|ve|re|ll|t|s|n)/, /[A-Za-z]+[-][a-z]+/, /[A-Za-z][a-z]{2,}/);
|
|
5896
5901
|
return r.contains.push({ begin: _(/[ ]+/, "(", i, /[.]?[:]?([.][ ]|[ ])/, "){3}") }), r;
|
|
5897
|
-
}, L = I("//", "$"),
|
|
5902
|
+
}, L = I("//", "$"), ee = I("/\\*", "\\*/"), R = I("#", "$"), te = /*#__PURE__*/ Object.freeze({
|
|
5898
5903
|
__proto__: null,
|
|
5899
5904
|
APOS_STRING_MODE: N,
|
|
5900
5905
|
BACKSLASH_ESCAPE: M,
|
|
@@ -5905,7 +5910,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5905
5910
|
},
|
|
5906
5911
|
BINARY_NUMBER_RE: k,
|
|
5907
5912
|
COMMENT: I,
|
|
5908
|
-
C_BLOCK_COMMENT_MODE:
|
|
5913
|
+
C_BLOCK_COMMENT_MODE: ee,
|
|
5909
5914
|
C_LINE_COMMENT_MODE: L,
|
|
5910
5915
|
C_NUMBER_MODE: {
|
|
5911
5916
|
scope: "number",
|
|
@@ -5923,7 +5928,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5923
5928
|
}
|
|
5924
5929
|
});
|
|
5925
5930
|
},
|
|
5926
|
-
HASH_COMMENT_MODE:
|
|
5931
|
+
HASH_COMMENT_MODE: R,
|
|
5927
5932
|
IDENT_RE: T,
|
|
5928
5933
|
MATCH_NOTHING_RE: w,
|
|
5929
5934
|
METHOD_GUARD: {
|
|
@@ -5994,7 +5999,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5994
5999
|
relevance: 0,
|
|
5995
6000
|
contains: [Object.assign(n, { endsParent: !0 })]
|
|
5996
6001
|
}, e.relevance = 0, delete n.beforeMatch;
|
|
5997
|
-
},
|
|
6002
|
+
}, le = [
|
|
5998
6003
|
"of",
|
|
5999
6004
|
"and",
|
|
6000
6005
|
"for",
|
|
@@ -6006,31 +6011,31 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6006
6011
|
"parent",
|
|
6007
6012
|
"list",
|
|
6008
6013
|
"value"
|
|
6009
|
-
],
|
|
6010
|
-
function
|
|
6014
|
+
], ue = "keyword";
|
|
6015
|
+
function de(e, t, n = ue) {
|
|
6011
6016
|
let r = Object.create(null);
|
|
6012
6017
|
return typeof e == "string" ? i(n, e.split(" ")) : Array.isArray(e) ? i(n, e) : Object.keys(e).forEach(function(n) {
|
|
6013
|
-
Object.assign(r,
|
|
6018
|
+
Object.assign(r, de(e[n], t, n));
|
|
6014
6019
|
}), r;
|
|
6015
6020
|
function i(e, n) {
|
|
6016
6021
|
t && (n = n.map((e) => e.toLowerCase())), n.forEach(function(t) {
|
|
6017
6022
|
let n = t.split("|");
|
|
6018
|
-
r[n[0]] = [e,
|
|
6023
|
+
r[n[0]] = [e, z(n[0], n[1])];
|
|
6019
6024
|
});
|
|
6020
6025
|
}
|
|
6021
6026
|
}
|
|
6022
|
-
function
|
|
6023
|
-
return t ? Number(t) : +!
|
|
6027
|
+
function z(e, t) {
|
|
6028
|
+
return t ? Number(t) : +!fe(e);
|
|
6024
6029
|
}
|
|
6025
|
-
function
|
|
6026
|
-
return
|
|
6030
|
+
function fe(e) {
|
|
6031
|
+
return le.includes(e.toLowerCase());
|
|
6027
6032
|
}
|
|
6028
|
-
var
|
|
6033
|
+
var pe = {}, B = (e) => {
|
|
6029
6034
|
console.error(e);
|
|
6030
6035
|
}, me = (e, ...t) => {
|
|
6031
6036
|
console.log(`WARN: ${e}`, ...t);
|
|
6032
6037
|
}, he = (e, t) => {
|
|
6033
|
-
|
|
6038
|
+
pe[`${e}/${t}`] || (console.log(`Deprecated as of ${e}. ${t}`), pe[`${e}/${t}`] = !0);
|
|
6034
6039
|
}, ge = /* @__PURE__ */ Error();
|
|
6035
6040
|
function _e(e, t, { key: n }) {
|
|
6036
6041
|
let r = 0, i = e[n], a = {}, o = {};
|
|
@@ -6039,15 +6044,15 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6039
6044
|
}
|
|
6040
6045
|
function ve(e) {
|
|
6041
6046
|
if (Array.isArray(e.begin)) {
|
|
6042
|
-
if (e.skip || e.excludeBegin || e.returnBegin) throw
|
|
6043
|
-
if (typeof e.beginScope != "object" || e.beginScope === null) throw
|
|
6047
|
+
if (e.skip || e.excludeBegin || e.returnBegin) throw B("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), ge;
|
|
6048
|
+
if (typeof e.beginScope != "object" || e.beginScope === null) throw B("beginScope must be object"), ge;
|
|
6044
6049
|
_e(e, e.begin, { key: "beginScope" }), e.begin = C(e.begin, { joinWith: "" });
|
|
6045
6050
|
}
|
|
6046
6051
|
}
|
|
6047
6052
|
function ye(e) {
|
|
6048
6053
|
if (Array.isArray(e.end)) {
|
|
6049
|
-
if (e.skip || e.excludeEnd || e.returnEnd) throw
|
|
6050
|
-
if (typeof e.endScope != "object" || e.endScope === null) throw
|
|
6054
|
+
if (e.skip || e.excludeEnd || e.returnEnd) throw B("skip, excludeEnd, returnEnd not compatible with endScope: {}"), ge;
|
|
6055
|
+
if (typeof e.endScope != "object" || e.endScope === null) throw B("endScope must be object"), ge;
|
|
6051
6056
|
_e(e, e.end, { key: "endScope" }), e.end = C(e.end, { joinWith: "" });
|
|
6052
6057
|
}
|
|
6053
6058
|
}
|
|
@@ -6131,7 +6136,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6131
6136
|
se
|
|
6132
6137
|
].forEach((e) => e(n, r)), n.isCompiled = !0;
|
|
6133
6138
|
let s = null;
|
|
6134
|
-
return typeof n.keywords == "object" && n.keywords.$pattern && (n.keywords = Object.assign({}, n.keywords), s = n.keywords.$pattern, delete n.keywords.$pattern), s ||= /\w+/, n.keywords &&=
|
|
6139
|
+
return typeof n.keywords == "object" && n.keywords.$pattern && (n.keywords = Object.assign({}, n.keywords), s = n.keywords.$pattern, delete n.keywords.$pattern), s ||= /\w+/, n.keywords &&= de(n.keywords, e.case_insensitive), a.keywordPatternRe = t(s, !0), r && (n.begin ||= /\B|\b/, a.beginRe = t(a.begin), !n.end && !n.endsWithParent && (n.end = /\B|\b/), n.end && (a.endRe = t(a.end)), a.terminatorEnd = p(a.end) || "", n.endsWithParent && r.terminatorEnd && (a.terminatorEnd += (n.end ? "|" : "") + r.terminatorEnd)), n.illegal && (a.illegalRe = t(n.illegal)), n.contains ||= [], n.contains = [].concat(...n.contains.map(function(e) {
|
|
6135
6140
|
return we(e === "self" ? n : e);
|
|
6136
6141
|
})), n.contains.forEach(function(e) {
|
|
6137
6142
|
o(e, a);
|
|
@@ -6187,9 +6192,9 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6187
6192
|
code: r,
|
|
6188
6193
|
language: i
|
|
6189
6194
|
};
|
|
6190
|
-
|
|
6195
|
+
R("before:highlight", a);
|
|
6191
6196
|
let o = a.result ? a.result : v(a.language, a.code, n);
|
|
6192
|
-
return o.code = a.code,
|
|
6197
|
+
return o.code = a.code, R("after:highlight", o), o;
|
|
6193
6198
|
}
|
|
6194
6199
|
function v(e, n, i, a) {
|
|
6195
6200
|
let c = Object.create(null);
|
|
@@ -6266,7 +6271,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6266
6271
|
if (e.endsWithParent) return _(e.parent, t, n);
|
|
6267
6272
|
}
|
|
6268
6273
|
function y(e) {
|
|
6269
|
-
return A.matcher.regexIndex === 0 ? (P += e[0], 1) : (
|
|
6274
|
+
return A.matcher.regexIndex === 0 ? (P += e[0], 1) : (ee = !0, 0);
|
|
6270
6275
|
}
|
|
6271
6276
|
function b(e) {
|
|
6272
6277
|
let t = e[0], n = e.rule, i = new r(n), a = [n.__beforeBegin, n["on:begin"]];
|
|
@@ -6312,15 +6317,15 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6312
6317
|
return P += a, a.length;
|
|
6313
6318
|
}
|
|
6314
6319
|
let D = N(e);
|
|
6315
|
-
if (!D) throw
|
|
6320
|
+
if (!D) throw B(s.replace("{}", e)), Error("Unknown language: \"" + e + "\"");
|
|
6316
6321
|
let O = Se(D), k = "", A = a || O, j = {}, M = new l.__emitter(l);
|
|
6317
6322
|
w();
|
|
6318
|
-
let P = "", F = 0, I = 0, L = 0,
|
|
6323
|
+
let P = "", F = 0, I = 0, L = 0, ee = !1;
|
|
6319
6324
|
try {
|
|
6320
6325
|
if (D.__emitTokens) D.__emitTokens(n, M);
|
|
6321
6326
|
else {
|
|
6322
6327
|
for (A.matcher.considerAll();;) {
|
|
6323
|
-
L++,
|
|
6328
|
+
L++, ee ? ee = !1 : A.matcher.considerAll(), A.matcher.lastIndex = I;
|
|
6324
6329
|
let e = A.matcher.exec(n);
|
|
6325
6330
|
if (!e) break;
|
|
6326
6331
|
let t = E(n.substring(I, e.index), e);
|
|
@@ -6394,7 +6399,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6394
6399
|
function w(e) {
|
|
6395
6400
|
let t = null, n = d(e);
|
|
6396
6401
|
if (u(n)) return;
|
|
6397
|
-
if (
|
|
6402
|
+
if (R("before:highlightElement", {
|
|
6398
6403
|
el: e,
|
|
6399
6404
|
language: n
|
|
6400
6405
|
}), e.dataset.highlighted) {
|
|
@@ -6414,7 +6419,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6414
6419
|
}, i.secondBest && (e.secondBest = {
|
|
6415
6420
|
language: i.secondBest.language,
|
|
6416
6421
|
relevance: i.secondBest.relevance
|
|
6417
|
-
}),
|
|
6422
|
+
}), R("after:highlightElement", {
|
|
6418
6423
|
el: e,
|
|
6419
6424
|
result: i,
|
|
6420
6425
|
text: r
|
|
@@ -6445,7 +6450,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6445
6450
|
try {
|
|
6446
6451
|
i = r(e);
|
|
6447
6452
|
} catch (e) {
|
|
6448
|
-
if (
|
|
6453
|
+
if (B("Language definition for '{}' could not be registered.".replace("{}", n)), o) B(e);
|
|
6449
6454
|
else throw e;
|
|
6450
6455
|
i = c;
|
|
6451
6456
|
}
|
|
@@ -6480,11 +6485,11 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6480
6485
|
function L(e) {
|
|
6481
6486
|
I(e), a.push(e);
|
|
6482
6487
|
}
|
|
6483
|
-
function
|
|
6488
|
+
function ee(e) {
|
|
6484
6489
|
let t = a.indexOf(e);
|
|
6485
6490
|
t !== -1 && a.splice(t, 1);
|
|
6486
6491
|
}
|
|
6487
|
-
function
|
|
6492
|
+
function R(e, t) {
|
|
6488
6493
|
let n = e;
|
|
6489
6494
|
a.forEach(function(e) {
|
|
6490
6495
|
e[n] && e[n](t);
|
|
@@ -6510,7 +6515,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6510
6515
|
autoDetection: F,
|
|
6511
6516
|
inherit: Oe,
|
|
6512
6517
|
addPlugin: L,
|
|
6513
|
-
removePlugin:
|
|
6518
|
+
removePlugin: ee
|
|
6514
6519
|
}), e.debugMode = function() {
|
|
6515
6520
|
o = !1;
|
|
6516
6521
|
}, e.safeMode = function() {
|
|
@@ -8864,7 +8869,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8864
8869
|
keywords: "prototype",
|
|
8865
8870
|
className: "property",
|
|
8866
8871
|
relevance: 0
|
|
8867
|
-
},
|
|
8872
|
+
}, ee = {
|
|
8868
8873
|
match: [
|
|
8869
8874
|
/get|set/,
|
|
8870
8875
|
/\s+/,
|
|
@@ -8876,7 +8881,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8876
8881
|
3: "title.function"
|
|
8877
8882
|
},
|
|
8878
8883
|
contains: [{ begin: /\(\)/ }, k]
|
|
8879
|
-
},
|
|
8884
|
+
}, R = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", te = {
|
|
8880
8885
|
match: [
|
|
8881
8886
|
/const|var|let/,
|
|
8882
8887
|
/\s+/,
|
|
@@ -8884,7 +8889,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8884
8889
|
/\s*/,
|
|
8885
8890
|
/=\s*/,
|
|
8886
8891
|
/(async\s*)?/,
|
|
8887
|
-
t.lookahead(
|
|
8892
|
+
t.lookahead(R)
|
|
8888
8893
|
],
|
|
8889
8894
|
keywords: "async",
|
|
8890
8895
|
className: {
|
|
@@ -8939,7 +8944,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8939
8944
|
e.REGEXP_MODE,
|
|
8940
8945
|
{
|
|
8941
8946
|
className: "function",
|
|
8942
|
-
begin:
|
|
8947
|
+
begin: R,
|
|
8943
8948
|
returnBegin: !0,
|
|
8944
8949
|
end: "\\s*=>",
|
|
8945
8950
|
contains: [{
|
|
@@ -9024,7 +9029,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
9024
9029
|
I,
|
|
9025
9030
|
P,
|
|
9026
9031
|
A,
|
|
9027
|
-
|
|
9032
|
+
ee,
|
|
9028
9033
|
{ match: /\$[(.]/ }
|
|
9029
9034
|
]
|
|
9030
9035
|
};
|
|
@@ -11298,7 +11303,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11298
11303
|
label: "interpol",
|
|
11299
11304
|
begin: i(/\\/, e, /\(/),
|
|
11300
11305
|
end: /\)/
|
|
11301
|
-
}),
|
|
11306
|
+
}), ee = (e = "") => ({
|
|
11302
11307
|
begin: i(e, /"""/),
|
|
11303
11308
|
end: i(/"""/, e),
|
|
11304
11309
|
contains: [
|
|
@@ -11306,21 +11311,21 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11306
11311
|
I(e),
|
|
11307
11312
|
L(e)
|
|
11308
11313
|
]
|
|
11309
|
-
}),
|
|
11314
|
+
}), R = (e = "") => ({
|
|
11310
11315
|
begin: i(e, /"/),
|
|
11311
11316
|
end: i(/"/, e),
|
|
11312
11317
|
contains: [F(e), L(e)]
|
|
11313
11318
|
}), te = {
|
|
11314
11319
|
className: "string",
|
|
11315
11320
|
variants: [
|
|
11316
|
-
R(),
|
|
11317
|
-
R("#"),
|
|
11318
|
-
R("##"),
|
|
11319
|
-
R("###"),
|
|
11320
11321
|
ee(),
|
|
11321
11322
|
ee("#"),
|
|
11322
11323
|
ee("##"),
|
|
11323
|
-
ee("###")
|
|
11324
|
+
ee("###"),
|
|
11325
|
+
R(),
|
|
11326
|
+
R("#"),
|
|
11327
|
+
R("##"),
|
|
11328
|
+
R("###")
|
|
11324
11329
|
]
|
|
11325
11330
|
}, ne = [e.BACKSLASH_ESCAPE, {
|
|
11326
11331
|
begin: /\[/,
|
|
@@ -11383,7 +11388,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11383
11388
|
scope: "meta",
|
|
11384
11389
|
match: i(/@/, x)
|
|
11385
11390
|
}
|
|
11386
|
-
],
|
|
11391
|
+
], le = {
|
|
11387
11392
|
match: r(/\b[A-Z]/),
|
|
11388
11393
|
relevance: 0,
|
|
11389
11394
|
contains: [
|
|
@@ -11409,7 +11414,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11409
11414
|
relevance: 0
|
|
11410
11415
|
}
|
|
11411
11416
|
]
|
|
11412
|
-
},
|
|
11417
|
+
}, ue = {
|
|
11413
11418
|
begin: /</,
|
|
11414
11419
|
end: />/,
|
|
11415
11420
|
keywords: D,
|
|
@@ -11418,11 +11423,11 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11418
11423
|
...O,
|
|
11419
11424
|
...ce,
|
|
11420
11425
|
A,
|
|
11421
|
-
|
|
11426
|
+
le
|
|
11422
11427
|
]
|
|
11423
11428
|
};
|
|
11424
|
-
|
|
11425
|
-
let
|
|
11429
|
+
le.contains.push(ue);
|
|
11430
|
+
let de = {
|
|
11426
11431
|
begin: /\(/,
|
|
11427
11432
|
end: /\)/,
|
|
11428
11433
|
relevance: 0,
|
|
@@ -11443,14 +11448,14 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11443
11448
|
te,
|
|
11444
11449
|
...se,
|
|
11445
11450
|
...ce,
|
|
11446
|
-
|
|
11451
|
+
le
|
|
11447
11452
|
]
|
|
11448
|
-
},
|
|
11453
|
+
}, z = {
|
|
11449
11454
|
begin: /</,
|
|
11450
11455
|
end: />/,
|
|
11451
11456
|
keywords: "repeat each",
|
|
11452
|
-
contains: [...a,
|
|
11453
|
-
},
|
|
11457
|
+
contains: [...a, le]
|
|
11458
|
+
}, fe = {
|
|
11454
11459
|
begin: /\(/,
|
|
11455
11460
|
end: /\)/,
|
|
11456
11461
|
keywords: D,
|
|
@@ -11473,12 +11478,12 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11473
11478
|
P,
|
|
11474
11479
|
te,
|
|
11475
11480
|
...ce,
|
|
11476
|
-
|
|
11477
|
-
|
|
11481
|
+
le,
|
|
11482
|
+
de
|
|
11478
11483
|
],
|
|
11479
11484
|
endsParent: !0,
|
|
11480
11485
|
illegal: /["']/
|
|
11481
|
-
},
|
|
11486
|
+
}, pe = {
|
|
11482
11487
|
match: [
|
|
11483
11488
|
/(func|macro)/,
|
|
11484
11489
|
/\s+/,
|
|
@@ -11489,17 +11494,17 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11489
11494
|
3: "title.function"
|
|
11490
11495
|
},
|
|
11491
11496
|
contains: [
|
|
11492
|
-
|
|
11493
|
-
|
|
11497
|
+
z,
|
|
11498
|
+
fe,
|
|
11494
11499
|
t
|
|
11495
11500
|
],
|
|
11496
11501
|
illegal: [/\[/, /%/]
|
|
11497
|
-
},
|
|
11502
|
+
}, B = {
|
|
11498
11503
|
match: [/\b(?:subscript|init[?!]?)/, /\s*(?=[<(])/],
|
|
11499
11504
|
className: { 1: "keyword" },
|
|
11500
11505
|
contains: [
|
|
11501
|
-
|
|
11502
|
-
|
|
11506
|
+
z,
|
|
11507
|
+
fe,
|
|
11503
11508
|
t
|
|
11504
11509
|
],
|
|
11505
11510
|
illegal: /\[|%/
|
|
@@ -11523,7 +11528,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11523
11528
|
1: "keyword",
|
|
11524
11529
|
3: "title"
|
|
11525
11530
|
},
|
|
11526
|
-
contains: [
|
|
11531
|
+
contains: [le],
|
|
11527
11532
|
keywords: [...p, ...f],
|
|
11528
11533
|
end: /}/
|
|
11529
11534
|
}, ge = {
|
|
@@ -11562,7 +11567,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11562
11567
|
},
|
|
11563
11568
|
keywords: D,
|
|
11564
11569
|
contains: [
|
|
11565
|
-
|
|
11570
|
+
z,
|
|
11566
11571
|
...O,
|
|
11567
11572
|
{
|
|
11568
11573
|
begin: /:/,
|
|
@@ -11598,8 +11603,8 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11598
11603
|
keywords: D,
|
|
11599
11604
|
contains: [
|
|
11600
11605
|
...a,
|
|
11601
|
-
fe,
|
|
11602
11606
|
pe,
|
|
11607
|
+
B,
|
|
11603
11608
|
ge,
|
|
11604
11609
|
_e,
|
|
11605
11610
|
ve,
|
|
@@ -11619,8 +11624,8 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11619
11624
|
te,
|
|
11620
11625
|
...se,
|
|
11621
11626
|
...ce,
|
|
11622
|
-
|
|
11623
|
-
|
|
11627
|
+
le,
|
|
11628
|
+
de
|
|
11624
11629
|
]
|
|
11625
11630
|
};
|
|
11626
11631
|
}
|
|
@@ -12037,7 +12042,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12037
12042
|
keywords: "prototype",
|
|
12038
12043
|
className: "property",
|
|
12039
12044
|
relevance: 0
|
|
12040
|
-
},
|
|
12045
|
+
}, ee = {
|
|
12041
12046
|
match: [
|
|
12042
12047
|
/get|set/,
|
|
12043
12048
|
/\s+/,
|
|
@@ -12049,7 +12054,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12049
12054
|
3: "title.function"
|
|
12050
12055
|
},
|
|
12051
12056
|
contains: [{ begin: /\(\)/ }, k]
|
|
12052
|
-
},
|
|
12057
|
+
}, R = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", te = {
|
|
12053
12058
|
match: [
|
|
12054
12059
|
/const|var|let/,
|
|
12055
12060
|
/\s+/,
|
|
@@ -12057,7 +12062,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12057
12062
|
/\s*/,
|
|
12058
12063
|
/=\s*/,
|
|
12059
12064
|
/(async\s*)?/,
|
|
12060
|
-
t.lookahead(
|
|
12065
|
+
t.lookahead(R)
|
|
12061
12066
|
],
|
|
12062
12067
|
keywords: "async",
|
|
12063
12068
|
className: {
|
|
@@ -12112,7 +12117,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12112
12117
|
e.REGEXP_MODE,
|
|
12113
12118
|
{
|
|
12114
12119
|
className: "function",
|
|
12115
|
-
begin:
|
|
12120
|
+
begin: R,
|
|
12116
12121
|
returnBegin: !0,
|
|
12117
12122
|
end: "\\s*=>",
|
|
12118
12123
|
contains: [{
|
|
@@ -12197,7 +12202,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12197
12202
|
I,
|
|
12198
12203
|
P,
|
|
12199
12204
|
A,
|
|
12200
|
-
|
|
12205
|
+
ee,
|
|
12201
12206
|
{ match: /\$[(.]/ }
|
|
12202
12207
|
]
|
|
12203
12208
|
};
|
|
@@ -13181,17 +13186,23 @@ app.mount('#app');
|
|
|
13181
13186
|
}, Eh = { class: "approval-actions" }, Dh = ["onClick"], Oh = { class: "approval-head" }, kh = { class: "approval-title" }, Ah = {
|
|
13182
13187
|
key: 0,
|
|
13183
13188
|
class: "approval-args"
|
|
13184
|
-
}, jh = { class: "approval-actions" }, Mh = {
|
|
13189
|
+
}, jh = { class: "approval-actions" }, Mh = {
|
|
13190
|
+
key: 1,
|
|
13191
|
+
class: "conflict-bar"
|
|
13192
|
+
}, Nh = { class: "conflict-head" }, Ph = { class: "conflict-title" }, Fh = { class: "conflict-detail" }, Ih = {
|
|
13193
|
+
key: 0,
|
|
13194
|
+
class: "conflict-diff"
|
|
13195
|
+
}, Lh = { class: "conflict-diff-col" }, Rh = { class: "conflict-diff-pre" }, zh = { class: "conflict-diff-col" }, Bh = { class: "conflict-diff-pre" }, Vh = { class: "conflict-actions" }, Hh = { class: "chat-footer" }, Uh = {
|
|
13185
13196
|
key: 0,
|
|
13186
13197
|
class: "cap-badge",
|
|
13187
13198
|
title: "能力概览(MCP / 工具数)"
|
|
13188
|
-
},
|
|
13199
|
+
}, Wh = ["placeholder"], Gh = ["disabled", "title"], Kh = {
|
|
13189
13200
|
key: 0,
|
|
13190
13201
|
width: "16",
|
|
13191
13202
|
height: "16",
|
|
13192
13203
|
viewBox: "0 0 24 24",
|
|
13193
13204
|
fill: "currentColor"
|
|
13194
|
-
},
|
|
13205
|
+
}, qh = {
|
|
13195
13206
|
key: 1,
|
|
13196
13207
|
width: "18",
|
|
13197
13208
|
height: "18",
|
|
@@ -13199,7 +13210,7 @@ app.mount('#app');
|
|
|
13199
13210
|
fill: "none",
|
|
13200
13211
|
stroke: "currentColor",
|
|
13201
13212
|
"stroke-width": "2"
|
|
13202
|
-
},
|
|
13213
|
+
}, Jh = /*#__PURE__*/ Zd(/* @__PURE__ */ wi({
|
|
13203
13214
|
__name: "ChatDialog",
|
|
13204
13215
|
props: {
|
|
13205
13216
|
fetchResponse: {},
|
|
@@ -13220,16 +13231,18 @@ app.mount('#app');
|
|
|
13220
13231
|
showTyping: {
|
|
13221
13232
|
type: Boolean,
|
|
13222
13233
|
default: !0
|
|
13223
|
-
}
|
|
13234
|
+
},
|
|
13235
|
+
pendingConflict: {},
|
|
13236
|
+
onResolveConflict: {}
|
|
13224
13237
|
},
|
|
13225
13238
|
setup(e) {
|
|
13226
|
-
let t = e, { state: n, scrollContainer: r, pendingApproval: i, sendMessage: a, clearMessages: o, stop: s, retry: c, regenerate: l, resolveApproval: u, onScroll: d } = xl({
|
|
13239
|
+
let t = e, { state: n, scrollContainer: r, pendingApproval: i, sendMessage: a, clearMessages: o, stop: s, retry: c, regenerate: l, resolveApproval: u, onScroll: d, onWheel: f } = xl({
|
|
13227
13240
|
fetchResponse: t.fetchResponse,
|
|
13228
13241
|
fetchStream: t.fetchStream,
|
|
13229
13242
|
messages: t.initialMessages,
|
|
13230
13243
|
onPersist: t.onPersist,
|
|
13231
13244
|
onClear: t.onClear
|
|
13232
|
-
}),
|
|
13245
|
+
}), p = zs(() => {
|
|
13233
13246
|
let e = i.value?.args;
|
|
13234
13247
|
if (e == null) return "";
|
|
13235
13248
|
try {
|
|
@@ -13238,25 +13251,47 @@ app.mount('#app');
|
|
|
13238
13251
|
} catch {
|
|
13239
13252
|
return String(e);
|
|
13240
13253
|
}
|
|
13241
|
-
}),
|
|
13254
|
+
}), m = zs(() => {
|
|
13255
|
+
let e = t.pendingConflict?.agentValue;
|
|
13256
|
+
if (e === void 0) return "";
|
|
13257
|
+
try {
|
|
13258
|
+
let t = JSON.stringify(e, null, 2);
|
|
13259
|
+
return t.length > 400 ? t.slice(0, 400) + "\n…(已截断)" : t;
|
|
13260
|
+
} catch {
|
|
13261
|
+
return String(e);
|
|
13262
|
+
}
|
|
13263
|
+
}), h = zs(() => {
|
|
13264
|
+
let e = t.pendingConflict?.currentValue;
|
|
13265
|
+
if (e == null) return "";
|
|
13266
|
+
try {
|
|
13267
|
+
let t = JSON.stringify(e, null, 2);
|
|
13268
|
+
return t.length > 400 ? t.slice(0, 400) + "\n…(已截断)" : t;
|
|
13269
|
+
} catch {
|
|
13270
|
+
return String(e);
|
|
13271
|
+
}
|
|
13272
|
+
}), g = /* @__PURE__ */ fn(!1);
|
|
13273
|
+
Gr(() => t.pendingConflict, () => {
|
|
13274
|
+
g.value = !1;
|
|
13275
|
+
});
|
|
13276
|
+
let _ = zs(() => i.value?.toolName === "request_human_confirmation"), v = zs(() => {
|
|
13242
13277
|
let e = i.value?.args?.options;
|
|
13243
13278
|
return Array.isArray(e) ? e.map(String) : [];
|
|
13244
|
-
}),
|
|
13279
|
+
}), y = /* @__PURE__ */ fn(!1);
|
|
13245
13280
|
Gr(i, () => {
|
|
13246
|
-
|
|
13281
|
+
y.value = !1;
|
|
13247
13282
|
});
|
|
13248
|
-
let
|
|
13249
|
-
function
|
|
13283
|
+
let b = zs(() => typeof t.canUndo == "function" && !!t.canUndo());
|
|
13284
|
+
function x() {
|
|
13250
13285
|
t.onUndo?.() && (n.error = null);
|
|
13251
13286
|
}
|
|
13252
|
-
let
|
|
13253
|
-
function
|
|
13254
|
-
|
|
13287
|
+
let S = /* @__PURE__ */ fn(""), C = /* @__PURE__ */ fn(!0), w = /* @__PURE__ */ fn(!1), T = /* @__PURE__ */ fn({}), E = zs(() => n.messages.length > 0), D = zs(() => n.messages.some((e) => e.role === "user")), O = zs(() => (t.debugLogs?.length ?? 0) > 0);
|
|
13288
|
+
function k(e) {
|
|
13289
|
+
T.value[e] = !T.value[e];
|
|
13255
13290
|
}
|
|
13256
|
-
function
|
|
13291
|
+
function A(e) {
|
|
13257
13292
|
return e.status === "running" ? "⏳" : e.status === "error" ? "❌" : "✅";
|
|
13258
13293
|
}
|
|
13259
|
-
function
|
|
13294
|
+
function j(e) {
|
|
13260
13295
|
let t = [];
|
|
13261
13296
|
for (let n of e) {
|
|
13262
13297
|
let e = t.length ? t[t.length - 1] : null;
|
|
@@ -13275,46 +13310,46 @@ app.mount('#app');
|
|
|
13275
13310
|
children: e.children
|
|
13276
13311
|
}));
|
|
13277
13312
|
}
|
|
13278
|
-
function
|
|
13313
|
+
function M(e) {
|
|
13279
13314
|
return e === "running" ? "⏳" : e === "error" ? "❌" : "✅";
|
|
13280
13315
|
}
|
|
13281
|
-
function
|
|
13316
|
+
function N(e) {
|
|
13282
13317
|
let t = n.messages[e];
|
|
13283
13318
|
return !!t && t.role === "assistant" && n.loading && e === n.messages.length - 1 && !t.content && !t.reasoning;
|
|
13284
13319
|
}
|
|
13285
|
-
function
|
|
13286
|
-
|
|
13320
|
+
function P() {
|
|
13321
|
+
S.value.trim() && (a(S.value), S.value = "");
|
|
13287
13322
|
}
|
|
13288
|
-
function
|
|
13289
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
13323
|
+
function F(e) {
|
|
13324
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), P());
|
|
13290
13325
|
}
|
|
13291
|
-
function
|
|
13326
|
+
function I(e) {
|
|
13292
13327
|
return new Date(e).toLocaleTimeString("zh-CN", {
|
|
13293
13328
|
hour: "2-digit",
|
|
13294
13329
|
minute: "2-digit"
|
|
13295
13330
|
});
|
|
13296
13331
|
}
|
|
13297
|
-
let
|
|
13332
|
+
let L = zs(() => {
|
|
13298
13333
|
let e = t.getInfo?.();
|
|
13299
13334
|
return {
|
|
13300
13335
|
mcp: e?.mcp?.servers?.length ?? 0,
|
|
13301
13336
|
tools: e?.tools?.length ?? 0
|
|
13302
13337
|
};
|
|
13303
13338
|
});
|
|
13304
|
-
function
|
|
13339
|
+
function ee(e) {
|
|
13305
13340
|
navigator.clipboard.writeText(e);
|
|
13306
13341
|
}
|
|
13307
|
-
return (a,
|
|
13342
|
+
return (a, R) => (q(), J("div", { class: Se(["chat-dialog", { collapsed: !C.value }]) }, [
|
|
13308
13343
|
Y("div", Lm, [Y("div", Rm, [
|
|
13309
|
-
|
|
13344
|
+
R[19] ||= Y("span", { class: "header-icon" }, "🤖", -1),
|
|
13310
13345
|
Y("span", zm, V(e.title), 1),
|
|
13311
13346
|
W(n).loading ? (q(), J("span", Bm)) : X("", !0)
|
|
13312
13347
|
]), Y("div", Vm, [
|
|
13313
13348
|
Y("button", {
|
|
13314
|
-
class: Se(["action-btn debug-btn", { active:
|
|
13349
|
+
class: Se(["action-btn debug-btn", { active: w.value }]),
|
|
13315
13350
|
title: "日志 / 执行流程 / Agent 信息",
|
|
13316
|
-
onClick:
|
|
13317
|
-
}, [
|
|
13351
|
+
onClick: R[0] ||= (e) => w.value = !0
|
|
13352
|
+
}, [R[20] ||= Y("svg", {
|
|
13318
13353
|
width: "16",
|
|
13319
13354
|
height: "16",
|
|
13320
13355
|
viewBox: "0 0 24 24",
|
|
@@ -13325,13 +13360,13 @@ app.mount('#app');
|
|
|
13325
13360
|
Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
|
|
13326
13361
|
Y("path", { d: "M9 2h6" }),
|
|
13327
13362
|
Y("path", { d: "M9 18h6" })
|
|
13328
|
-
], -1),
|
|
13363
|
+
], -1), O.value ? (q(), J("span", Hm, V(e.debugLogs?.length), 1)) : X("", !0)], 2),
|
|
13329
13364
|
Y("button", {
|
|
13330
13365
|
class: "action-btn",
|
|
13331
13366
|
title: "清空对话",
|
|
13332
|
-
onClick:
|
|
13333
|
-
disabled: !
|
|
13334
|
-
}, [...
|
|
13367
|
+
onClick: R[1] ||= (...e) => W(o) && W(o)(...e),
|
|
13368
|
+
disabled: !E.value
|
|
13369
|
+
}, [...R[21] ||= [Y("svg", {
|
|
13335
13370
|
width: "16",
|
|
13336
13371
|
height: "16",
|
|
13337
13372
|
viewBox: "0 0 24 24",
|
|
@@ -13341,16 +13376,17 @@ app.mount('#app');
|
|
|
13341
13376
|
}, [Y("polyline", { points: "3 6 5 6 21 6" }), Y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })], -1)]], 8, Um),
|
|
13342
13377
|
Y("button", {
|
|
13343
13378
|
class: "action-btn",
|
|
13344
|
-
onClick:
|
|
13345
|
-
}, [(q(), J("svg", Wm, [
|
|
13379
|
+
onClick: R[2] ||= (e) => C.value = !C.value
|
|
13380
|
+
}, [(q(), J("svg", Wm, [C.value ? (q(), J("path", Gm)) : (q(), J("path", Km))]))])
|
|
13346
13381
|
])]),
|
|
13347
13382
|
zr(Y("div", {
|
|
13348
13383
|
class: "chat-body",
|
|
13349
13384
|
ref_key: "scrollContainer",
|
|
13350
13385
|
ref: r,
|
|
13351
|
-
onScroll:
|
|
13386
|
+
onScroll: R[5] ||= (...e) => W(d) && W(d)(...e),
|
|
13387
|
+
onWheel: R[6] ||= (...e) => W(f) && W(f)(...e)
|
|
13352
13388
|
}, [
|
|
13353
|
-
|
|
13389
|
+
E.value ? X("", !0) : (q(), J("div", qm, [...R[22] ||= [Y("div", { class: "empty-icon" }, "💬", -1), Y("p", null, "有什么可以帮你的?", -1)]])),
|
|
13354
13390
|
(q(!0), J(K, null, Xi(W(n).messages, (t, r) => (q(), J("div", {
|
|
13355
13391
|
key: r,
|
|
13356
13392
|
class: Se(["message-row", t.role]),
|
|
@@ -13358,143 +13394,173 @@ app.mount('#app');
|
|
|
13358
13394
|
}, [e.showAvatar ? (q(), J("div", Ym, V(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", Xm, [
|
|
13359
13395
|
t.role === "assistant" && t.reasoning ? (q(), J("div", {
|
|
13360
13396
|
key: 0,
|
|
13361
|
-
class: Se(["reasoning-block", { expanded:
|
|
13397
|
+
class: Se(["reasoning-block", { expanded: T.value[r] }])
|
|
13362
13398
|
}, [Y("div", {
|
|
13363
13399
|
class: "reasoning-header",
|
|
13364
|
-
onClick: (e) =>
|
|
13400
|
+
onClick: (e) => k(r)
|
|
13365
13401
|
}, [
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
Y("span", Qm, V(
|
|
13369
|
-
], 8, Zm),
|
|
13370
|
-
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", eh, [(q(!0), J(K, null, Xi(
|
|
13402
|
+
R[23] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13403
|
+
R[24] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13404
|
+
Y("span", Qm, V(T.value[r] ? "▾" : "▸"), 1)
|
|
13405
|
+
], 8, Zm), T.value[r] ? (q(), J("div", $m, V(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13406
|
+
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", eh, [(q(!0), J(K, null, Xi(j(t.steps), (e, t) => (q(), J("div", {
|
|
13371
13407
|
key: t,
|
|
13372
13408
|
class: "step-item"
|
|
13373
13409
|
}, [Y("div", th, [
|
|
13374
|
-
Y("span", nh, V(
|
|
13410
|
+
Y("span", nh, V(M(e.status)), 1),
|
|
13375
13411
|
Y("span", rh, V(e.name), 1),
|
|
13376
13412
|
e.count > 1 ? (q(), J("span", ih, "×" + V(e.count), 1)) : X("", !0),
|
|
13377
13413
|
e.status === "running" ? (q(), J("span", ah, "执行中…")) : X("", !0)
|
|
13378
|
-
]), e.children && e.children.length ? (q(), J("div", oh, [
|
|
13414
|
+
]), e.children && e.children.length ? (q(), J("div", oh, [R[25] ||= Y("div", { class: "step-children-label" }, "🧬 子 agent 进度", -1), (q(!0), J(K, null, Xi(e.children, (e, t) => (q(), J("div", {
|
|
13379
13415
|
key: t,
|
|
13380
13416
|
class: "step-child"
|
|
13381
13417
|
}, [
|
|
13382
|
-
Y("span", sh, V(
|
|
13418
|
+
Y("span", sh, V(A(e)), 1),
|
|
13383
13419
|
Y("span", ch, V(e.name), 1),
|
|
13384
13420
|
e.status === "running" ? (q(), J("span", lh, "…")) : X("", !0)
|
|
13385
13421
|
]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
|
|
13386
|
-
Y("div", { class: Se(["message-bubble", { typing:
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13422
|
+
Y("div", { class: Se(["message-bubble", { typing: N(r) }]) }, [N(r) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13423
|
+
R[26] ||= Y("span", { class: "dot" }, null, -1),
|
|
13424
|
+
R[27] ||= Y("span", { class: "dot" }, null, -1),
|
|
13425
|
+
R[28] ||= Y("span", { class: "dot" }, null, -1)
|
|
13390
13426
|
], 64)) : (q(), J("span", uh, "思考中…"))], 64)) : (q(), J(K, { key: 1 }, [t.role === "assistant" ? (q(), Ko(ef, {
|
|
13391
13427
|
key: 0,
|
|
13392
13428
|
content: t.content
|
|
13393
13429
|
}, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [is(V(t.content), 1)], 64))], 64))], 2),
|
|
13394
13430
|
t.role === "assistant" && W(n).loading && r === W(n).messages.length - 1 && t.content ? (q(), J("span", dh)) : X("", !0),
|
|
13395
|
-
Y("div", fh, V(
|
|
13431
|
+
Y("div", fh, V(I(t.timestamp)), 1),
|
|
13396
13432
|
t.role === "assistant" && t.content && !W(n).loading && r === W(n).messages.length - 1 ? (q(), J("div", ph, [Y("button", {
|
|
13397
13433
|
class: "msg-action-btn",
|
|
13398
13434
|
title: "复制",
|
|
13399
|
-
onClick: (e) =>
|
|
13435
|
+
onClick: (e) => ee(t.content)
|
|
13400
13436
|
}, "📋 复制", 8, mh), Y("button", {
|
|
13401
13437
|
class: "msg-action-btn",
|
|
13402
13438
|
title: "重新生成",
|
|
13403
|
-
onClick:
|
|
13439
|
+
onClick: R[3] ||= (...e) => W(l) && W(l)(...e)
|
|
13404
13440
|
}, "🔄 重新生成")])) : X("", !0)
|
|
13405
13441
|
])], 10, Jm))), 128)),
|
|
13406
13442
|
W(n).loading && W(n).messages[W(n).messages.length - 1]?.role !== "assistant" ? (q(), J("div", hh, [e.showAvatar ? (q(), J("div", gh, "🤖")) : X("", !0), Y("div", _h, [Y("div", vh, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13443
|
+
R[29] ||= Y("span", { class: "dot" }, null, -1),
|
|
13444
|
+
R[30] ||= Y("span", { class: "dot" }, null, -1),
|
|
13445
|
+
R[31] ||= Y("span", { class: "dot" }, null, -1)
|
|
13410
13446
|
], 64)) : (q(), J("span", yh, "思考中…"))])])])) : X("", !0),
|
|
13411
13447
|
W(n).error ? (q(), J("div", bh, [
|
|
13412
13448
|
Y("span", xh, V(W(n).error), 1),
|
|
13413
|
-
|
|
13449
|
+
D.value ? (q(), J("button", {
|
|
13414
13450
|
key: 0,
|
|
13415
13451
|
class: "retry-btn",
|
|
13416
|
-
onClick:
|
|
13452
|
+
onClick: R[4] ||= (...e) => W(c) && W(c)(...e)
|
|
13417
13453
|
}, "重试")) : X("", !0),
|
|
13418
|
-
|
|
13454
|
+
b.value ? (q(), J("button", {
|
|
13419
13455
|
key: 1,
|
|
13420
13456
|
class: "undo-btn",
|
|
13421
13457
|
title: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
13422
|
-
onClick:
|
|
13458
|
+
onClick: x
|
|
13423
13459
|
}, "↩ 回退")) : X("", !0)
|
|
13424
13460
|
])) : X("", !0)
|
|
13425
|
-
], 544), [[xc,
|
|
13426
|
-
W(i) ? (q(), J("div", Sh, [
|
|
13427
|
-
|
|
13461
|
+
], 544), [[xc, C.value]]),
|
|
13462
|
+
W(i) ? (q(), J("div", Sh, [_.value ? (q(), J(K, { key: 0 }, [
|
|
13463
|
+
R[32] ||= Y("div", { class: "approval-head" }, [Y("span", { class: "approval-icon" }, "❓"), Y("span", { class: "approval-title" }, "AI 需要你确认")], -1),
|
|
13428
13464
|
W(i).args?.question ? (q(), J("div", Ch, V(W(i).args.question), 1)) : X("", !0),
|
|
13429
13465
|
W(i).args?.context ? (q(), J("div", wh, V(W(i).args.context), 1)) : X("", !0),
|
|
13430
13466
|
W(i).args?.recommendation ? (q(), J("div", Th, "💡 推荐:" + V(W(i).args.recommendation), 1)) : X("", !0),
|
|
13431
13467
|
Y("div", Eh, [Y("button", {
|
|
13432
13468
|
class: "approval-deny",
|
|
13433
|
-
onClick:
|
|
13434
|
-
}, "拒绝"),
|
|
13469
|
+
onClick: R[7] ||= (e) => W(u)(!1)
|
|
13470
|
+
}, "拒绝"), v.value.length ? (q(!0), J(K, { key: 0 }, Xi(v.value, (e) => (q(), J("button", {
|
|
13435
13471
|
key: e,
|
|
13436
13472
|
class: "approval-opt",
|
|
13437
13473
|
onClick: (t) => W(u)(e)
|
|
13438
13474
|
}, V(e), 9, Dh))), 128)) : (q(), J("button", {
|
|
13439
13475
|
key: 1,
|
|
13440
13476
|
class: "approval-allow",
|
|
13441
|
-
onClick:
|
|
13477
|
+
onClick: R[8] ||= (e) => W(u)(!0)
|
|
13442
13478
|
}, "允许"))])
|
|
13443
13479
|
], 64)) : (q(), J(K, { key: 1 }, [
|
|
13444
13480
|
Y("div", Oh, [
|
|
13445
|
-
|
|
13446
|
-
Y("span", kh, [
|
|
13447
|
-
|
|
13481
|
+
R[34] ||= Y("span", { class: "approval-icon" }, "✋", -1),
|
|
13482
|
+
Y("span", kh, [R[33] ||= is("需确认工具调用:", -1), Y("code", null, V(W(i).toolName), 1)]),
|
|
13483
|
+
p.value ? (q(), J("button", {
|
|
13448
13484
|
key: 0,
|
|
13449
13485
|
class: "approval-toggle",
|
|
13450
|
-
onClick:
|
|
13451
|
-
}, V(
|
|
13486
|
+
onClick: R[9] ||= (e) => y.value = !y.value
|
|
13487
|
+
}, V(y.value ? "收起参数" : "查看参数") + V(y.value ? " ▴" : " ▾"), 1)) : X("", !0)
|
|
13452
13488
|
]),
|
|
13453
|
-
|
|
13489
|
+
p.value && y.value ? (q(), J("pre", Ah, V(p.value), 1)) : X("", !0),
|
|
13454
13490
|
Y("div", jh, [Y("button", {
|
|
13455
13491
|
class: "approval-deny",
|
|
13456
|
-
onClick:
|
|
13492
|
+
onClick: R[10] ||= (e) => W(u)(!1)
|
|
13457
13493
|
}, "拒绝"), Y("button", {
|
|
13458
13494
|
class: "approval-allow",
|
|
13459
|
-
onClick:
|
|
13495
|
+
onClick: R[11] ||= (e) => W(u)(!0)
|
|
13460
13496
|
}, "允许")])
|
|
13461
13497
|
], 64))])) : X("", !0),
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13498
|
+
t.pendingConflict ? (q(), J("div", Mh, [
|
|
13499
|
+
Y("div", Nh, [R[37] ||= Y("span", { class: "conflict-icon" }, "⚠️", -1), Y("span", Ph, [
|
|
13500
|
+
R[35] ||= is("写入冲突:", -1),
|
|
13501
|
+
Y("code", null, V(t.pendingConflict.path), 1),
|
|
13502
|
+
R[36] ||= is(" 已被外部修改", -1)
|
|
13503
|
+
])]),
|
|
13504
|
+
Y("div", Fh, " AI 基于「读取时的旧值」准备" + V(t.pendingConflict.op === "delete" ? "删除" : "写入") + ",但该属性在你读取之后被外部代码/其他 agent/手动改过。 ", 1),
|
|
13505
|
+
Y("button", {
|
|
13506
|
+
class: "conflict-toggle",
|
|
13507
|
+
onClick: R[12] ||= (e) => g.value = !g.value
|
|
13508
|
+
}, V(g.value ? "收起对比" : "查看值对比") + V(g.value ? " ▴" : " ▾"), 1),
|
|
13509
|
+
g.value ? (q(), J("div", Ih, [Y("div", Lh, [R[38] ||= Y("div", { class: "conflict-diff-label" }, "AI 想写的值", -1), Y("pre", Rh, V(m.value || "(delete 操作无值)"), 1)]), Y("div", zh, [R[39] ||= Y("div", { class: "conflict-diff-label" }, "外部改后的当前值", -1), Y("pre", Bh, V(h.value), 1)])])) : X("", !0),
|
|
13510
|
+
Y("div", Vh, [
|
|
13511
|
+
Y("button", {
|
|
13512
|
+
class: "conflict-keep",
|
|
13513
|
+
onClick: R[13] ||= (e) => t.onResolveConflict?.("keep_external"),
|
|
13514
|
+
title: "不写入,保留外部修改后的值,AI 重新读取再改"
|
|
13515
|
+
}, "保留外部"),
|
|
13516
|
+
Y("button", {
|
|
13517
|
+
class: "conflict-overwrite",
|
|
13518
|
+
onClick: R[14] ||= (e) => t.onResolveConflict?.("overwrite"),
|
|
13519
|
+
title: "用 AI 的值覆盖外部修改"
|
|
13520
|
+
}, "强制覆盖"),
|
|
13521
|
+
Y("button", {
|
|
13522
|
+
class: "conflict-restore",
|
|
13523
|
+
onClick: R[15] ||= (e) => t.onResolveConflict?.("restore"),
|
|
13524
|
+
title: "回退到最近一次历史快照(agent 之前操作的检查点),撤销外部修改 + AI 不写入"
|
|
13525
|
+
}, "回退")
|
|
13526
|
+
])
|
|
13527
|
+
])) : X("", !0),
|
|
13528
|
+
zr(Y("div", Hh, [
|
|
13529
|
+
t.getInfo ? (q(), J("span", Uh, " 🔌" + V(L.value.mcp) + " · 🔧" + V(L.value.tools), 1)) : X("", !0),
|
|
13530
|
+
b.value ? (q(), J("button", {
|
|
13465
13531
|
key: 1,
|
|
13466
13532
|
class: "undo-foot-btn",
|
|
13467
13533
|
title: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
13468
|
-
onClick:
|
|
13534
|
+
onClick: x
|
|
13469
13535
|
}, "↩ 回退")) : X("", !0),
|
|
13470
13536
|
zr(Y("textarea", {
|
|
13471
|
-
"onUpdate:modelValue":
|
|
13537
|
+
"onUpdate:modelValue": R[16] ||= (e) => S.value = e,
|
|
13472
13538
|
class: "chat-input",
|
|
13473
13539
|
placeholder: e.placeholder,
|
|
13474
13540
|
rows: "1",
|
|
13475
|
-
onKeydown:
|
|
13476
|
-
}, null, 40,
|
|
13541
|
+
onKeydown: F
|
|
13542
|
+
}, null, 40, Wh), [[rl, S.value]]),
|
|
13477
13543
|
Y("button", {
|
|
13478
13544
|
class: Se(["send-btn", { "stop-btn": W(n).loading }]),
|
|
13479
|
-
disabled: !W(n).loading && !
|
|
13545
|
+
disabled: !W(n).loading && !S.value.trim(),
|
|
13480
13546
|
title: W(n).loading ? "停止生成" : "发送",
|
|
13481
|
-
onClick:
|
|
13482
|
-
}, [W(n).loading ? (q(), J("svg",
|
|
13547
|
+
onClick: R[17] ||= (e) => W(n).loading ? W(s)() : P()
|
|
13548
|
+
}, [W(n).loading ? (q(), J("svg", Kh, [...R[40] ||= [Y("rect", {
|
|
13483
13549
|
x: "6",
|
|
13484
13550
|
y: "6",
|
|
13485
13551
|
width: "12",
|
|
13486
13552
|
height: "12",
|
|
13487
13553
|
rx: "2"
|
|
13488
|
-
}, null, -1)]])) : (q(), J("svg",
|
|
13554
|
+
}, null, -1)]])) : (q(), J("svg", qh, [...R[41] ||= [Y("line", {
|
|
13489
13555
|
x1: "22",
|
|
13490
13556
|
y1: "2",
|
|
13491
13557
|
x2: "11",
|
|
13492
13558
|
y2: "13"
|
|
13493
|
-
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10,
|
|
13494
|
-
], 512), [[xc,
|
|
13559
|
+
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10, Gh)
|
|
13560
|
+
], 512), [[xc, C.value]]),
|
|
13495
13561
|
$o(Im, {
|
|
13496
|
-
visible:
|
|
13497
|
-
"onUpdate:visible":
|
|
13562
|
+
visible: w.value,
|
|
13563
|
+
"onUpdate:visible": R[18] ||= (e) => w.value = e,
|
|
13498
13564
|
logs: e.debugLogs,
|
|
13499
13565
|
"get-info": t.getInfo
|
|
13500
13566
|
}, null, 8, [
|
|
@@ -13504,15 +13570,15 @@ app.mount('#app');
|
|
|
13504
13570
|
])
|
|
13505
13571
|
], 2));
|
|
13506
13572
|
}
|
|
13507
|
-
}), [["__scopeId", "data-v-
|
|
13508
|
-
function
|
|
13573
|
+
}), [["__scopeId", "data-v-fef90945"]]);
|
|
13574
|
+
function Yh(e) {
|
|
13509
13575
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13510
13576
|
}
|
|
13511
|
-
function
|
|
13577
|
+
function Xh(e, t) {
|
|
13512
13578
|
let n = t.threshold ?? 6e3;
|
|
13513
13579
|
if (e.length <= n) return e;
|
|
13514
13580
|
if (t.vfsAvailable && t.files) {
|
|
13515
|
-
let n = Math.random().toString(36).slice(2, 10), r = `large_results/${t.toolName}-${n}.txt`, i =
|
|
13581
|
+
let n = Math.random().toString(36).slice(2, 10), r = `large_results/${t.toolName}-${n}.txt`, i = Yh(r);
|
|
13516
13582
|
return t.files[i] = {
|
|
13517
13583
|
content: e,
|
|
13518
13584
|
updatedAt: Date.now()
|
|
@@ -13527,7 +13593,7 @@ function Bh(e, t) {
|
|
|
13527
13593
|
}
|
|
13528
13594
|
//#endregion
|
|
13529
13595
|
//#region src/core/utils/pool.ts
|
|
13530
|
-
async function
|
|
13596
|
+
async function Zh(e, t, n, r) {
|
|
13531
13597
|
let i = Array(e.length), a = Math.max(1, t);
|
|
13532
13598
|
if (a === 1) {
|
|
13533
13599
|
for (let t = 0; t < e.length && !r?.aborted; t++) i[t] = await n(e[t], t);
|
|
@@ -13544,7 +13610,7 @@ async function Vh(e, t, n, r) {
|
|
|
13544
13610
|
}
|
|
13545
13611
|
//#endregion
|
|
13546
13612
|
//#region src/core/utils/modelCaps.ts
|
|
13547
|
-
var
|
|
13613
|
+
var Qh = [
|
|
13548
13614
|
{
|
|
13549
13615
|
pattern: /deepseek-v4/i,
|
|
13550
13616
|
caps: {
|
|
@@ -13706,34 +13772,34 @@ var Hh = [
|
|
|
13706
13772
|
maxOutputTokens: 4096
|
|
13707
13773
|
}
|
|
13708
13774
|
}
|
|
13709
|
-
],
|
|
13775
|
+
], $h = {
|
|
13710
13776
|
contextWindow: 32768,
|
|
13711
13777
|
maxOutputTokens: 4096
|
|
13712
13778
|
};
|
|
13713
|
-
function
|
|
13779
|
+
function eg(e = {}) {
|
|
13714
13780
|
let t = (() => {
|
|
13715
|
-
if (e.model) return
|
|
13781
|
+
if (e.model) return Qh.find((t) => t.pattern.test(e.model))?.caps;
|
|
13716
13782
|
})();
|
|
13717
13783
|
return {
|
|
13718
|
-
contextWindow: e.contextWindow ?? t?.contextWindow ??
|
|
13719
|
-
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ??
|
|
13784
|
+
contextWindow: e.contextWindow ?? t?.contextWindow ?? $h.contextWindow,
|
|
13785
|
+
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ?? $h.maxOutputTokens
|
|
13720
13786
|
};
|
|
13721
13787
|
}
|
|
13722
|
-
function
|
|
13788
|
+
function tg(e) {
|
|
13723
13789
|
if (!e) return 0;
|
|
13724
13790
|
let t = (e.match(/[\u4e00-\u9fff]/g) || []).length, n = e.length - t;
|
|
13725
13791
|
return Math.ceil(t * 1.5 + n * .25);
|
|
13726
13792
|
}
|
|
13727
|
-
function
|
|
13793
|
+
function ng(e) {
|
|
13728
13794
|
return Math.max(2e3, Math.min(2e4, Math.round(e * .035)));
|
|
13729
13795
|
}
|
|
13730
|
-
function
|
|
13731
|
-
let t =
|
|
13796
|
+
function rg(e) {
|
|
13797
|
+
let t = ng(e);
|
|
13732
13798
|
return Math.min(2e5, Math.max(t, Math.round(e * .7)));
|
|
13733
13799
|
}
|
|
13734
13800
|
//#endregion
|
|
13735
13801
|
//#region src/core/harness/state.ts
|
|
13736
|
-
function
|
|
13802
|
+
function ig() {
|
|
13737
13803
|
return {
|
|
13738
13804
|
messages: [],
|
|
13739
13805
|
todos: [],
|
|
@@ -13746,42 +13812,42 @@ function Jh() {
|
|
|
13746
13812
|
}
|
|
13747
13813
|
//#endregion
|
|
13748
13814
|
//#region src/core/harness/middleware.ts
|
|
13749
|
-
function
|
|
13815
|
+
function ag(e, t) {
|
|
13750
13816
|
return t ? {
|
|
13751
13817
|
...e,
|
|
13752
13818
|
...t
|
|
13753
13819
|
} : e;
|
|
13754
13820
|
}
|
|
13755
|
-
async function
|
|
13821
|
+
async function og(e, t) {
|
|
13756
13822
|
let n = t;
|
|
13757
|
-
for (let t of e) t.beforeAgent && (n =
|
|
13823
|
+
for (let t of e) t.beforeAgent && (n = ag(n, await t.beforeAgent(n)));
|
|
13758
13824
|
return n;
|
|
13759
13825
|
}
|
|
13760
|
-
function
|
|
13826
|
+
function sg(e, t) {
|
|
13761
13827
|
let n = t.state;
|
|
13762
|
-
for (let r of e) r.beforeModel && (n =
|
|
13828
|
+
for (let r of e) r.beforeModel && (n = ag(n, r.beforeModel({
|
|
13763
13829
|
messages: t.messages,
|
|
13764
13830
|
state: n
|
|
13765
13831
|
})));
|
|
13766
13832
|
return n;
|
|
13767
13833
|
}
|
|
13768
|
-
function
|
|
13834
|
+
function cg(e, t, n) {
|
|
13769
13835
|
let r = n;
|
|
13770
13836
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
13771
13837
|
let i = e[n];
|
|
13772
|
-
i.afterModel && (r =
|
|
13838
|
+
i.afterModel && (r = ag(r, i.afterModel(t, r)));
|
|
13773
13839
|
}
|
|
13774
13840
|
return r;
|
|
13775
13841
|
}
|
|
13776
|
-
async function
|
|
13842
|
+
async function lg(e, t) {
|
|
13777
13843
|
let n = t;
|
|
13778
13844
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
13779
13845
|
let r = e[t];
|
|
13780
|
-
r.afterAgent && (n =
|
|
13846
|
+
r.afterAgent && (n = ag(n, await r.afterAgent(n)));
|
|
13781
13847
|
}
|
|
13782
13848
|
return n;
|
|
13783
13849
|
}
|
|
13784
|
-
async function
|
|
13850
|
+
async function ug(e, t) {
|
|
13785
13851
|
let n = [];
|
|
13786
13852
|
for (let r of e) {
|
|
13787
13853
|
if (!r.beforeReturn) continue;
|
|
@@ -13790,16 +13856,19 @@ async function eg(e, t) {
|
|
|
13790
13856
|
}
|
|
13791
13857
|
return n.length ? n.join("\n\n") : null;
|
|
13792
13858
|
}
|
|
13793
|
-
function
|
|
13859
|
+
function dg(e, t) {
|
|
13794
13860
|
return e.reduceRight((e, t) => (n) => t.wrapModelCall ? t.wrapModelCall(n, e) : e(n), t);
|
|
13795
13861
|
}
|
|
13796
|
-
function
|
|
13862
|
+
function fg(e, t) {
|
|
13797
13863
|
return e.reduceRight((e, t) => (n) => t.wrapToolCall ? t.wrapToolCall(n, e) : e(n), t);
|
|
13798
13864
|
}
|
|
13799
13865
|
//#endregion
|
|
13800
13866
|
//#region src/core/harness/createAgent.ts
|
|
13801
|
-
|
|
13802
|
-
|
|
13867
|
+
function pg(e) {
|
|
13868
|
+
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
13869
|
+
}
|
|
13870
|
+
var mg = 10, hg = 300, gg = 6e3;
|
|
13871
|
+
function _g(e, t) {
|
|
13803
13872
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
13804
13873
|
if (n <= t) return e;
|
|
13805
13874
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -13814,29 +13883,29 @@ function og(e, t) {
|
|
|
13814
13883
|
});
|
|
13815
13884
|
});
|
|
13816
13885
|
}
|
|
13817
|
-
function
|
|
13818
|
-
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m =
|
|
13886
|
+
function vg(e) {
|
|
13887
|
+
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = mg, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = eg({
|
|
13819
13888
|
model: c,
|
|
13820
13889
|
contextWindow: e.contextWindow,
|
|
13821
13890
|
maxOutputTokens: e.maxOutputTokens
|
|
13822
|
-
}), S = u ?? x.maxOutputTokens, C =
|
|
13891
|
+
}), S = u ?? x.maxOutputTokens, C = ng(x.contextWindow), w = rg(x.contextWindow), T = /* @__PURE__ */ pn([]);
|
|
13823
13892
|
function E(e, t) {
|
|
13824
13893
|
let n = {
|
|
13825
13894
|
timestamp: Date.now(),
|
|
13826
13895
|
type: e,
|
|
13827
13896
|
data: t
|
|
13828
13897
|
};
|
|
13829
|
-
T.value.push(n), T.value.length >
|
|
13898
|
+
T.value.push(n), T.value.length > hg && T.value.splice(0, T.value.length - hg), gn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
13830
13899
|
}
|
|
13831
13900
|
let D = (e) => {
|
|
13832
|
-
T.value.push(e), T.value.length >
|
|
13901
|
+
T.value.push(e), T.value.length > hg && T.value.splice(0, T.value.length - hg), gn(T);
|
|
13833
13902
|
}, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new s({
|
|
13834
13903
|
apiKey: t,
|
|
13835
13904
|
model: c,
|
|
13836
13905
|
temperature: l,
|
|
13837
13906
|
maxTokens: S,
|
|
13838
13907
|
configuration: n ? { baseURL: n } : void 0
|
|
13839
|
-
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j =
|
|
13908
|
+
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j = ig();
|
|
13840
13909
|
function M() {
|
|
13841
13910
|
let e = [d || "你是一个智能助手。"];
|
|
13842
13911
|
for (let t of p) if (t.augmentPrompt) {
|
|
@@ -13911,7 +13980,7 @@ function sg(e) {
|
|
|
13911
13980
|
};
|
|
13912
13981
|
try {
|
|
13913
13982
|
let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
|
|
13914
|
-
return r =
|
|
13983
|
+
return r = Xh(r, {
|
|
13915
13984
|
files: e.state.files,
|
|
13916
13985
|
vfsAvailable: O.some((e) => e.name === "vfs_read"),
|
|
13917
13986
|
toolName: e.name,
|
|
@@ -13931,13 +14000,13 @@ function sg(e) {
|
|
|
13931
14000
|
function L(e) {
|
|
13932
14001
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
13933
14002
|
}
|
|
13934
|
-
function
|
|
13935
|
-
return
|
|
14003
|
+
function ee(e, t) {
|
|
14004
|
+
return _g(e, t);
|
|
13936
14005
|
}
|
|
13937
|
-
function
|
|
14006
|
+
function R(e) {
|
|
13938
14007
|
return e.map((e) => {
|
|
13939
14008
|
let t = L(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
13940
|
-
r && (n.content = r.length >
|
|
14009
|
+
r && (n.content = r.length > gg ? r.slice(0, gg) + `…(截断 ${r.length - gg} 字符)` : r);
|
|
13941
14010
|
let i = e.tool_calls;
|
|
13942
14011
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
13943
14012
|
id: e.id,
|
|
@@ -13952,7 +14021,7 @@ function sg(e) {
|
|
|
13952
14021
|
});
|
|
13953
14022
|
}
|
|
13954
14023
|
async function te(e, t, n) {
|
|
13955
|
-
T.value = [], j =
|
|
14024
|
+
T.value = [], j = ig(), j.messages = e, j = await og(p, j);
|
|
13956
14025
|
let r = e;
|
|
13957
14026
|
for (let e of p) if (e.compressInput) {
|
|
13958
14027
|
let t = await e.compressInput(r);
|
|
@@ -13967,20 +14036,20 @@ function sg(e) {
|
|
|
13967
14036
|
tools: O.map((e) => e.name),
|
|
13968
14037
|
middleware: p.map((e) => e.name)
|
|
13969
14038
|
});
|
|
13970
|
-
let l =
|
|
14039
|
+
let l = dg(p, (e) => F(e, t, n)), u = fg(p, I), d = 0, f = null, h = 0;
|
|
13971
14040
|
try {
|
|
13972
14041
|
for (; d < m && !n?.aborted;) {
|
|
13973
14042
|
t({
|
|
13974
14043
|
type: "round_start",
|
|
13975
14044
|
round: d + 1
|
|
13976
|
-
}), j =
|
|
14045
|
+
}), j = sg(p, {
|
|
13977
14046
|
messages: s,
|
|
13978
14047
|
state: j
|
|
13979
|
-
}), s = P(s), s =
|
|
14048
|
+
}), s = P(s), s = ee(s, w), E("llm_request", {
|
|
13980
14049
|
round: d + 1,
|
|
13981
14050
|
model: c,
|
|
13982
14051
|
tools: O.map((e) => e.name),
|
|
13983
|
-
messages:
|
|
14052
|
+
messages: R(s)
|
|
13984
14053
|
});
|
|
13985
14054
|
let e = await l({
|
|
13986
14055
|
messages: s,
|
|
@@ -13990,13 +14059,21 @@ function sg(e) {
|
|
|
13990
14059
|
round: d + 1,
|
|
13991
14060
|
content: e.content,
|
|
13992
14061
|
toolCalls: e.toolCalls
|
|
13993
|
-
}), j =
|
|
14062
|
+
}), j = cg(p, e, j), e.aborted) return t({
|
|
13994
14063
|
type: "done",
|
|
13995
14064
|
content: e.content
|
|
13996
14065
|
}), e.content;
|
|
13997
14066
|
if (!e.toolCalls.length) {
|
|
14067
|
+
if (h < 2 && pg(e.content)) {
|
|
14068
|
+
h += 1, E("middleware", {
|
|
14069
|
+
stage: "format_retry",
|
|
14070
|
+
attempt: h,
|
|
14071
|
+
content: e.content.slice(0, 200)
|
|
14072
|
+
}), s.push(new i("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签,如 <|tool_calls|>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。")), d += 1;
|
|
14073
|
+
continue;
|
|
14074
|
+
}
|
|
13998
14075
|
if (v > 0 && j.verifyAttempts < v) {
|
|
13999
|
-
let t = await
|
|
14076
|
+
let t = await ug(p, {
|
|
14000
14077
|
messages: s,
|
|
14001
14078
|
state: j,
|
|
14002
14079
|
response: e,
|
|
@@ -14031,7 +14108,7 @@ function sg(e) {
|
|
|
14031
14108
|
logSink: D
|
|
14032
14109
|
}
|
|
14033
14110
|
};
|
|
14034
|
-
}), a = await
|
|
14111
|
+
}), a = await Zh(r, _, async (e) => {
|
|
14035
14112
|
if (n?.aborted) return;
|
|
14036
14113
|
t({
|
|
14037
14114
|
type: "tool_call",
|
|
@@ -14081,7 +14158,7 @@ function sg(e) {
|
|
|
14081
14158
|
round: "wrap_up",
|
|
14082
14159
|
model: c,
|
|
14083
14160
|
tools: [],
|
|
14084
|
-
messages:
|
|
14161
|
+
messages: R(r)
|
|
14085
14162
|
});
|
|
14086
14163
|
let i = await F({
|
|
14087
14164
|
messages: r,
|
|
@@ -14102,7 +14179,7 @@ function sg(e) {
|
|
|
14102
14179
|
}), r;
|
|
14103
14180
|
} finally {
|
|
14104
14181
|
try {
|
|
14105
|
-
await
|
|
14182
|
+
await lg(p, j);
|
|
14106
14183
|
} catch (e) {
|
|
14107
14184
|
console.warn("[Agent] afterAgent 清理出错(已忽略):", e);
|
|
14108
14185
|
}
|
|
@@ -14124,14 +14201,14 @@ function sg(e) {
|
|
|
14124
14201
|
}
|
|
14125
14202
|
//#endregion
|
|
14126
14203
|
//#region src/core/harness/todos.ts
|
|
14127
|
-
function
|
|
14204
|
+
function yg(e) {
|
|
14128
14205
|
if (e.length) return [
|
|
14129
14206
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14130
14207
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14131
14208
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14132
14209
|
].join("\n");
|
|
14133
14210
|
}
|
|
14134
|
-
function
|
|
14211
|
+
function bg(e = []) {
|
|
14135
14212
|
let r = e.map((e) => ({ ...e })), i = 0;
|
|
14136
14213
|
return {
|
|
14137
14214
|
name: "todos",
|
|
@@ -14149,7 +14226,7 @@ function lg(e = []) {
|
|
|
14149
14226
|
})],
|
|
14150
14227
|
beforeAgent: () => ({ todos: r }),
|
|
14151
14228
|
beforeModel: () => (i = 0, { todos: r }),
|
|
14152
|
-
augmentPrompt: () =>
|
|
14229
|
+
augmentPrompt: () => yg(r),
|
|
14153
14230
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14154
14231
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14155
14232
|
status: "error"
|
|
@@ -14161,18 +14238,18 @@ function lg(e = []) {
|
|
|
14161
14238
|
}
|
|
14162
14239
|
//#endregion
|
|
14163
14240
|
//#region src/core/harness/skills.ts
|
|
14164
|
-
function
|
|
14241
|
+
function xg(e) {
|
|
14165
14242
|
return e;
|
|
14166
14243
|
}
|
|
14167
|
-
var
|
|
14168
|
-
function
|
|
14169
|
-
return
|
|
14244
|
+
var Sg = /^https?:\/\//i;
|
|
14245
|
+
function Cg(e) {
|
|
14246
|
+
return Sg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14170
14247
|
}
|
|
14171
|
-
function
|
|
14248
|
+
function wg(e) {
|
|
14172
14249
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14173
14250
|
}
|
|
14174
|
-
async function
|
|
14175
|
-
if (
|
|
14251
|
+
async function Tg(e, t) {
|
|
14252
|
+
if (Cg(e) === "http") try {
|
|
14176
14253
|
let t = await fetch(e);
|
|
14177
14254
|
return t.ok ? {
|
|
14178
14255
|
ok: !0,
|
|
@@ -14195,7 +14272,7 @@ async function mg(e, t) {
|
|
|
14195
14272
|
ok: !1,
|
|
14196
14273
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14197
14274
|
};
|
|
14198
|
-
let n = t(
|
|
14275
|
+
let n = t(wg(e));
|
|
14199
14276
|
return n == null ? {
|
|
14200
14277
|
ok: !1,
|
|
14201
14278
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14204,14 +14281,14 @@ async function mg(e, t) {
|
|
|
14204
14281
|
content: n
|
|
14205
14282
|
};
|
|
14206
14283
|
}
|
|
14207
|
-
function
|
|
14284
|
+
function Eg(e) {
|
|
14208
14285
|
if (e.length) return [
|
|
14209
14286
|
"## 可用 Skills(渐进式披露)",
|
|
14210
14287
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14211
14288
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14212
14289
|
].join("\n");
|
|
14213
14290
|
}
|
|
14214
|
-
function
|
|
14291
|
+
function Dg(e, r) {
|
|
14215
14292
|
let i = new Map(e.map((e) => [e.name, e])), a = /* @__PURE__ */ new Set();
|
|
14216
14293
|
return {
|
|
14217
14294
|
name: "skills",
|
|
@@ -14221,7 +14298,7 @@ function gg(e, r) {
|
|
|
14221
14298
|
if (a.has(e)) return `skill "${e}" 已在本轮加载,无需重复。`;
|
|
14222
14299
|
let n;
|
|
14223
14300
|
if (t.doc) {
|
|
14224
|
-
let i = await
|
|
14301
|
+
let i = await Tg(t.doc, r?.readVfs);
|
|
14225
14302
|
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14226
14303
|
n = i.content;
|
|
14227
14304
|
} else if (t.getContent) n = await t.getContent();
|
|
@@ -14239,13 +14316,13 @@ function gg(e, r) {
|
|
|
14239
14316
|
})),
|
|
14240
14317
|
skillsLoaded: []
|
|
14241
14318
|
}),
|
|
14242
|
-
augmentPrompt: () =>
|
|
14319
|
+
augmentPrompt: () => Eg(e),
|
|
14243
14320
|
afterModel: () => ({ skillsLoaded: [...a] })
|
|
14244
14321
|
};
|
|
14245
14322
|
}
|
|
14246
14323
|
//#endregion
|
|
14247
14324
|
//#region src/core/harness/memory.ts
|
|
14248
|
-
function
|
|
14325
|
+
function Og(e = "") {
|
|
14249
14326
|
let t = e;
|
|
14250
14327
|
return {
|
|
14251
14328
|
name: "memory",
|
|
@@ -14258,12 +14335,12 @@ function _g(e = "") {
|
|
|
14258
14335
|
}
|
|
14259
14336
|
//#endregion
|
|
14260
14337
|
//#region src/core/harness/permissions.ts
|
|
14261
|
-
var
|
|
14338
|
+
var kg = /* @__PURE__ */ new Set([
|
|
14262
14339
|
"set_window_prop",
|
|
14263
14340
|
"delete_window_prop",
|
|
14264
14341
|
"vfs_write",
|
|
14265
14342
|
"vfs_edit"
|
|
14266
|
-
]),
|
|
14343
|
+
]), Ag = /* @__PURE__ */ new Set([
|
|
14267
14344
|
"get_window_prop",
|
|
14268
14345
|
"describe_window_prop",
|
|
14269
14346
|
"list_window_props",
|
|
@@ -14272,7 +14349,7 @@ var vg = /* @__PURE__ */ new Set([
|
|
|
14272
14349
|
"vfs_glob",
|
|
14273
14350
|
"vfs_grep"
|
|
14274
14351
|
]);
|
|
14275
|
-
function
|
|
14352
|
+
function jg(e) {
|
|
14276
14353
|
let t = "";
|
|
14277
14354
|
for (let n = 0; n < e.length; n++) {
|
|
14278
14355
|
let r = e[n];
|
|
@@ -14280,16 +14357,16 @@ function bg(e) {
|
|
|
14280
14357
|
}
|
|
14281
14358
|
return RegExp("^" + t + "$");
|
|
14282
14359
|
}
|
|
14283
|
-
function
|
|
14284
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14360
|
+
function Mg(e, t, n) {
|
|
14361
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => jg(e).test(n))) return r.mode;
|
|
14285
14362
|
return "allow";
|
|
14286
14363
|
}
|
|
14287
|
-
function
|
|
14364
|
+
function Ng(e) {
|
|
14288
14365
|
return {
|
|
14289
14366
|
name: "permissions",
|
|
14290
14367
|
wrapToolCall: async (t, n) => {
|
|
14291
|
-
let r =
|
|
14292
|
-
return r && i &&
|
|
14368
|
+
let r = kg.has(t.name) ? "write" : Ag.has(t.name) ? "read" : null, i = t.args?.path || "";
|
|
14369
|
+
return r && i && Mg(e, r, i) === "deny" ? {
|
|
14293
14370
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14294
14371
|
status: "error"
|
|
14295
14372
|
} : n(t);
|
|
@@ -14298,7 +14375,7 @@ function Sg(e) {
|
|
|
14298
14375
|
}
|
|
14299
14376
|
//#endregion
|
|
14300
14377
|
//#region src/core/harness/approval.ts
|
|
14301
|
-
function
|
|
14378
|
+
function Pg(e = {}) {
|
|
14302
14379
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14303
14380
|
return {
|
|
14304
14381
|
name: "approval",
|
|
@@ -14332,15 +14409,15 @@ function Cg(e = {}) {
|
|
|
14332
14409
|
}
|
|
14333
14410
|
//#endregion
|
|
14334
14411
|
//#region src/core/harness/humanConfirm.ts
|
|
14335
|
-
var
|
|
14412
|
+
var Fg = "request_human_confirmation", Ig = t.object({
|
|
14336
14413
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14337
14414
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14338
14415
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14339
14416
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14340
14417
|
});
|
|
14341
|
-
function
|
|
14418
|
+
function Lg() {
|
|
14342
14419
|
return n(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14343
|
-
name:
|
|
14420
|
+
name: Fg,
|
|
14344
14421
|
description: [
|
|
14345
14422
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14346
14423
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14350,10 +14427,10 @@ function Eg() {
|
|
|
14350
14427
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14351
14428
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14352
14429
|
].join(""),
|
|
14353
|
-
schema:
|
|
14430
|
+
schema: Ig
|
|
14354
14431
|
});
|
|
14355
14432
|
}
|
|
14356
|
-
function
|
|
14433
|
+
function Rg() {
|
|
14357
14434
|
return {
|
|
14358
14435
|
name: "humanConfirm",
|
|
14359
14436
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14385,14 +14462,14 @@ function Dg() {
|
|
|
14385
14462
|
}
|
|
14386
14463
|
//#endregion
|
|
14387
14464
|
//#region src/core/harness/checkpoint.ts
|
|
14388
|
-
function
|
|
14465
|
+
function zg(e) {
|
|
14389
14466
|
if (typeof e != "object" || !e) return e;
|
|
14390
14467
|
if (typeof structuredClone == "function") try {
|
|
14391
14468
|
return structuredClone(e);
|
|
14392
14469
|
} catch {}
|
|
14393
14470
|
return JSON.parse(JSON.stringify(e));
|
|
14394
14471
|
}
|
|
14395
|
-
function
|
|
14472
|
+
function Bg(e, t) {
|
|
14396
14473
|
let n = t.split("."), r = e;
|
|
14397
14474
|
for (let e of n) {
|
|
14398
14475
|
if (r == null) return;
|
|
@@ -14400,12 +14477,12 @@ function kg(e, t) {
|
|
|
14400
14477
|
}
|
|
14401
14478
|
return r;
|
|
14402
14479
|
}
|
|
14403
|
-
function
|
|
14480
|
+
function Vg(e, t, n) {
|
|
14404
14481
|
let r = t.split("."), i = e;
|
|
14405
14482
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14406
14483
|
i[r[r.length - 1]] = n;
|
|
14407
14484
|
}
|
|
14408
|
-
function
|
|
14485
|
+
function Hg(e, t) {
|
|
14409
14486
|
if (Array.isArray(e)) {
|
|
14410
14487
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14411
14488
|
return;
|
|
@@ -14414,11 +14491,11 @@ function jg(e, t) {
|
|
|
14414
14491
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14415
14492
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14416
14493
|
}
|
|
14417
|
-
function
|
|
14418
|
-
let n =
|
|
14419
|
-
typeof n == "object" && n ?
|
|
14494
|
+
function Ug(e, t) {
|
|
14495
|
+
let n = Bg(window, e);
|
|
14496
|
+
typeof n == "object" && n ? Hg(n, t) : Vg(window, e, t);
|
|
14420
14497
|
}
|
|
14421
|
-
function
|
|
14498
|
+
function Wg(e) {
|
|
14422
14499
|
let t = e.slice();
|
|
14423
14500
|
for (; t.length;) {
|
|
14424
14501
|
let e = t[t.length - 1];
|
|
@@ -14427,20 +14504,20 @@ function Ng(e) {
|
|
|
14427
14504
|
}
|
|
14428
14505
|
return t;
|
|
14429
14506
|
}
|
|
14430
|
-
function
|
|
14507
|
+
function Gg(e) {
|
|
14431
14508
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14432
14509
|
return {
|
|
14433
14510
|
save(i) {
|
|
14434
|
-
let a =
|
|
14435
|
-
for (let t of e.windowPaths) o[t] =
|
|
14511
|
+
let a = Wg(e.messages), o = {};
|
|
14512
|
+
for (let t of e.windowPaths) o[t] = zg(Bg(window, t));
|
|
14436
14513
|
let s = {
|
|
14437
14514
|
id: r++,
|
|
14438
14515
|
label: i,
|
|
14439
14516
|
timestamp: Date.now(),
|
|
14440
|
-
messages:
|
|
14517
|
+
messages: zg(a),
|
|
14441
14518
|
windowVals: o,
|
|
14442
|
-
vfs:
|
|
14443
|
-
todos:
|
|
14519
|
+
vfs: zg(e.vfsStore.files),
|
|
14520
|
+
todos: zg(e.getTodos()),
|
|
14444
14521
|
messageCount: a.length
|
|
14445
14522
|
};
|
|
14446
14523
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14460,15 +14537,15 @@ function Pg(e) {
|
|
|
14460
14537
|
restore(n) {
|
|
14461
14538
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14462
14539
|
if (!r) return !1;
|
|
14463
|
-
e.messages.splice(0, e.messages.length, ...
|
|
14464
|
-
for (let [e, t] of Object.entries(r.windowVals))
|
|
14540
|
+
e.messages.splice(0, e.messages.length, ...zg(r.messages));
|
|
14541
|
+
for (let [e, t] of Object.entries(r.windowVals)) Ug(e, zg(t));
|
|
14465
14542
|
let i = e.vfsStore.files;
|
|
14466
14543
|
for (let e of Object.keys(i)) delete i[e];
|
|
14467
|
-
return Object.assign(i,
|
|
14544
|
+
return Object.assign(i, zg(r.vfs)), e.todosMw.reset(zg(r.todos)), !0;
|
|
14468
14545
|
}
|
|
14469
14546
|
};
|
|
14470
14547
|
}
|
|
14471
|
-
function
|
|
14548
|
+
function Kg(e) {
|
|
14472
14549
|
let t = !1;
|
|
14473
14550
|
return {
|
|
14474
14551
|
name: "checkpoint",
|
|
@@ -14482,22 +14559,22 @@ function Fg(e) {
|
|
|
14482
14559
|
}
|
|
14483
14560
|
//#endregion
|
|
14484
14561
|
//#region src/core/harness/subagent.ts
|
|
14485
|
-
function
|
|
14562
|
+
function qg(e) {
|
|
14486
14563
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14487
14564
|
}
|
|
14488
|
-
var
|
|
14565
|
+
var Jg = [
|
|
14489
14566
|
"get_window_prop",
|
|
14490
14567
|
"get_window_paths",
|
|
14491
14568
|
"list_window_props",
|
|
14492
14569
|
"describe_window_prop",
|
|
14493
14570
|
"fetch_document"
|
|
14494
|
-
],
|
|
14495
|
-
async function
|
|
14496
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
14571
|
+
], Yg = 1, Xg = 4, Zg = 6, Qg = ["spawn_agent", "spawn_agents"];
|
|
14572
|
+
async function $g(e, t, n, r, i) {
|
|
14573
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? Yg, s = /* @__PURE__ */ new Set([...Jg, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !Qg.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [e_({
|
|
14497
14574
|
...t,
|
|
14498
14575
|
depth: a + 1
|
|
14499
|
-
})] : [], u =
|
|
14500
|
-
...
|
|
14576
|
+
})] : [], u = vg({
|
|
14577
|
+
...qg(t.llm) ? { llm: t.llm } : {
|
|
14501
14578
|
apiKey: t.llm.apiKey,
|
|
14502
14579
|
baseUrl: t.llm.baseUrl,
|
|
14503
14580
|
model: e.model ?? t.llm.model,
|
|
@@ -14506,8 +14583,8 @@ async function Hg(e, t, n, r, i) {
|
|
|
14506
14583
|
},
|
|
14507
14584
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读 window / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
14508
14585
|
tools: c,
|
|
14509
|
-
middleware: [...t.skills?.length ? [
|
|
14510
|
-
maxToolRounds: t.maxToolRounds ??
|
|
14586
|
+
middleware: [...t.skills?.length ? [Dg(t.skills)] : [], ...l],
|
|
14587
|
+
maxToolRounds: t.maxToolRounds ?? Zg,
|
|
14511
14588
|
onLog: i,
|
|
14512
14589
|
debug: t.debug
|
|
14513
14590
|
});
|
|
@@ -14519,8 +14596,8 @@ async function Hg(e, t, n, r, i) {
|
|
|
14519
14596
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
14520
14597
|
}, n);
|
|
14521
14598
|
}
|
|
14522
|
-
function
|
|
14523
|
-
let r = e.maxParallel ??
|
|
14599
|
+
function e_(e) {
|
|
14600
|
+
let r = e.maxParallel ?? Xg, i, a, o, s = (e, t) => (n) => {
|
|
14524
14601
|
a && a({
|
|
14525
14602
|
type: "subagent",
|
|
14526
14603
|
taskId: e,
|
|
@@ -14539,7 +14616,7 @@ function Ug(e) {
|
|
|
14539
14616
|
...e,
|
|
14540
14617
|
allowedTools: r
|
|
14541
14618
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
14542
|
-
return await
|
|
14619
|
+
return await $g({
|
|
14543
14620
|
prompt: t,
|
|
14544
14621
|
role: n,
|
|
14545
14622
|
model: a
|
|
@@ -14556,9 +14633,9 @@ function Ug(e) {
|
|
|
14556
14633
|
tools: t.array(t.string()).optional().describe("子 agent 可用工具名白名单(默认只读 window + fetch)"),
|
|
14557
14634
|
model: t.string().optional().describe("覆盖模型(默认同主)")
|
|
14558
14635
|
})
|
|
14559
|
-
}), n(async ({ tasks: t }) => (await
|
|
14636
|
+
}), n(async ({ tasks: t }) => (await Zh(t, r, async (t, n) => {
|
|
14560
14637
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
14561
|
-
return
|
|
14638
|
+
return $g(t, e, i, s(r, a), (e) => o?.({
|
|
14562
14639
|
...e,
|
|
14563
14640
|
source: `子:${a}`
|
|
14564
14641
|
}));
|
|
@@ -14573,8 +14650,8 @@ function Ug(e) {
|
|
|
14573
14650
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
14574
14651
|
};
|
|
14575
14652
|
}
|
|
14576
|
-
var
|
|
14577
|
-
function
|
|
14653
|
+
var t_ = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
14654
|
+
function n_(e, t) {
|
|
14578
14655
|
let n = e.tools ?? [];
|
|
14579
14656
|
return {
|
|
14580
14657
|
llm: e.llm ?? t.llm,
|
|
@@ -14588,9 +14665,9 @@ function Gg(e, t) {
|
|
|
14588
14665
|
debug: t.debug
|
|
14589
14666
|
};
|
|
14590
14667
|
}
|
|
14591
|
-
function
|
|
14668
|
+
function r_(e, r) {
|
|
14592
14669
|
let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
|
|
14593
|
-
if (!
|
|
14670
|
+
if (!t_.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
|
|
14594
14671
|
let t = `use_${e.id}`;
|
|
14595
14672
|
return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
|
|
14596
14673
|
}), o, s, c, l = (e, t) => (n) => {
|
|
@@ -14608,8 +14685,8 @@ function Kg(e, r) {
|
|
|
14608
14685
|
return {
|
|
14609
14686
|
name: "subagents",
|
|
14610
14687
|
tools: a.map((e) => n(async ({ task: t }) => {
|
|
14611
|
-
let n =
|
|
14612
|
-
return
|
|
14688
|
+
let n = n_(e, r);
|
|
14689
|
+
return $g({ prompt: t }, n, o, l(`use_${e.id}`, e.id), (t) => c?.({
|
|
14613
14690
|
...t,
|
|
14614
14691
|
source: `子:${e.id}`
|
|
14615
14692
|
}));
|
|
@@ -14628,7 +14705,7 @@ function Kg(e, r) {
|
|
|
14628
14705
|
}
|
|
14629
14706
|
//#endregion
|
|
14630
14707
|
//#region src/core/harness/verify.ts
|
|
14631
|
-
function
|
|
14708
|
+
function i_(e) {
|
|
14632
14709
|
return {
|
|
14633
14710
|
name: "verify",
|
|
14634
14711
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -14640,10 +14717,10 @@ function qg(e) {
|
|
|
14640
14717
|
if (e.adversarial) {
|
|
14641
14718
|
r?.("middleware", {
|
|
14642
14719
|
stage: "adversarial_start",
|
|
14643
|
-
model:
|
|
14720
|
+
model: f_(e.adversarial.llm),
|
|
14644
14721
|
tools: (e.adversarial.tools ?? []).length
|
|
14645
14722
|
});
|
|
14646
|
-
let n = await
|
|
14723
|
+
let n = await g_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
14647
14724
|
if (r?.("middleware", {
|
|
14648
14725
|
stage: "adversarial_done",
|
|
14649
14726
|
clean: n === null,
|
|
@@ -14654,16 +14731,16 @@ function qg(e) {
|
|
|
14654
14731
|
}
|
|
14655
14732
|
};
|
|
14656
14733
|
}
|
|
14657
|
-
var
|
|
14734
|
+
var a_ = /* @__PURE__ */ new Set([
|
|
14658
14735
|
"set_window_prop",
|
|
14659
14736
|
"edit_window_prop",
|
|
14660
14737
|
"delete_window_prop"
|
|
14661
|
-
]),
|
|
14662
|
-
function
|
|
14738
|
+
]), o_ = /校验失败|未在注册表中声明|未注册|不存在|仅支持|必须是/;
|
|
14739
|
+
function s_(e) {
|
|
14663
14740
|
let t = /* @__PURE__ */ new Map();
|
|
14664
14741
|
for (let n of e) {
|
|
14665
14742
|
let e = n?.tool_calls;
|
|
14666
|
-
if (Array.isArray(e)) for (let n of e)
|
|
14743
|
+
if (Array.isArray(e)) for (let n of e) a_.has(n.name) && typeof n?.args?.path == "string" && t.set(n.args.path, {
|
|
14667
14744
|
path: n.args.path,
|
|
14668
14745
|
op: n.name,
|
|
14669
14746
|
callId: n.id
|
|
@@ -14671,7 +14748,7 @@ function Xg(e) {
|
|
|
14671
14748
|
}
|
|
14672
14749
|
return [...t.values()];
|
|
14673
14750
|
}
|
|
14674
|
-
function
|
|
14751
|
+
function c_(e) {
|
|
14675
14752
|
let t = /* @__PURE__ */ new Map();
|
|
14676
14753
|
for (let n of e) {
|
|
14677
14754
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -14679,7 +14756,7 @@ function Zg(e) {
|
|
|
14679
14756
|
}
|
|
14680
14757
|
return t;
|
|
14681
14758
|
}
|
|
14682
|
-
function
|
|
14759
|
+
function l_(e, t) {
|
|
14683
14760
|
if (e == null) return;
|
|
14684
14761
|
let n = e;
|
|
14685
14762
|
for (let e of t.split(".")) {
|
|
@@ -14688,16 +14765,16 @@ function Qg(e, t) {
|
|
|
14688
14765
|
}
|
|
14689
14766
|
return n;
|
|
14690
14767
|
}
|
|
14691
|
-
function
|
|
14768
|
+
function u_(e = {}) {
|
|
14692
14769
|
let t = e.window ?? globalThis.window, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
|
|
14693
14770
|
return async ({ messages: e }) => {
|
|
14694
|
-
let r =
|
|
14771
|
+
let r = s_(e);
|
|
14695
14772
|
if (!r.length) return { ok: !0 };
|
|
14696
|
-
let i =
|
|
14773
|
+
let i = c_(e), a = n(), o = [];
|
|
14697
14774
|
for (let { path: e, op: n, callId: s } of r) {
|
|
14698
14775
|
let r = s ? i.get(s) : void 0;
|
|
14699
|
-
if (r &&
|
|
14700
|
-
let c =
|
|
14776
|
+
if (r && o_.test(r)) continue;
|
|
14777
|
+
let c = l_(t, e);
|
|
14701
14778
|
if (n === "delete_window_prop") c !== void 0 && o.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14702
14779
|
else if (c == null) o.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14703
14780
|
else if (a[e]) {
|
|
@@ -14711,17 +14788,17 @@ function $g(e = {}) {
|
|
|
14711
14788
|
} : { ok: !0 };
|
|
14712
14789
|
};
|
|
14713
14790
|
}
|
|
14714
|
-
function
|
|
14791
|
+
function d_(e) {
|
|
14715
14792
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14716
14793
|
}
|
|
14717
|
-
function
|
|
14718
|
-
return
|
|
14794
|
+
function f_(e) {
|
|
14795
|
+
return d_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
14719
14796
|
}
|
|
14720
|
-
var
|
|
14721
|
-
function
|
|
14722
|
-
return
|
|
14797
|
+
var p_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
14798
|
+
function m_(e) {
|
|
14799
|
+
return p_.test(e);
|
|
14723
14800
|
}
|
|
14724
|
-
function
|
|
14801
|
+
function h_(e) {
|
|
14725
14802
|
let t = "", n = "";
|
|
14726
14803
|
for (let a of e) a instanceof i ? t = typeof a.content == "string" ? a.content : "" : a instanceof r && !(a.tool_calls?.length > 0) && (n = typeof a.content == "string" ? a.content : "");
|
|
14727
14804
|
return {
|
|
@@ -14729,8 +14806,8 @@ function i_(e) {
|
|
|
14729
14806
|
lastReply: n
|
|
14730
14807
|
};
|
|
14731
14808
|
}
|
|
14732
|
-
async function
|
|
14733
|
-
let { lastUser: i, lastReply: a } =
|
|
14809
|
+
async function g_(e, t, n, r) {
|
|
14810
|
+
let { lastUser: i, lastReply: a } = h_(e);
|
|
14734
14811
|
if (!a) return null;
|
|
14735
14812
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
14736
14813
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -14741,7 +14818,7 @@ async function a_(e, t, n, r) {
|
|
|
14741
14818
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
14742
14819
|
...e.data,
|
|
14743
14820
|
source: "adversarial"
|
|
14744
|
-
}) : void 0, u = await
|
|
14821
|
+
}) : void 0, u = await vg(d_(t) ? {
|
|
14745
14822
|
llm: t,
|
|
14746
14823
|
tools: r,
|
|
14747
14824
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -14766,17 +14843,17 @@ async function a_(e, t, n, r) {
|
|
|
14766
14843
|
stage: "adversarial_verdict",
|
|
14767
14844
|
verdict: u,
|
|
14768
14845
|
source: "adversarial"
|
|
14769
|
-
}),
|
|
14846
|
+
}), m_(u) ? null : u.trim();
|
|
14770
14847
|
}
|
|
14771
14848
|
//#endregion
|
|
14772
14849
|
//#region src/core/mcp/client.ts
|
|
14773
|
-
function
|
|
14850
|
+
function __(e) {
|
|
14774
14851
|
let t = e?.content;
|
|
14775
14852
|
if (!Array.isArray(t) || !t.length) return "";
|
|
14776
14853
|
let n = t.map((e) => e.type === "text" && e.text ? e.text : e.type === "image" && e.data ? `[image:${String(e.data).slice(0, 32)}…]` : e.type === "audio" && e.data ? "[audio]" : e.type === "resource" && e.resource ? e.resource.text ?? e.resource.blob ?? "" : "").filter(Boolean).join("\n");
|
|
14777
14854
|
return e?.isError ? `工具错误:${n}` : n;
|
|
14778
14855
|
}
|
|
14779
|
-
async function
|
|
14856
|
+
async function v_(e) {
|
|
14780
14857
|
let t = new URL(e.url), n = e.requestInit;
|
|
14781
14858
|
if (e.transport === "http") {
|
|
14782
14859
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -14789,8 +14866,8 @@ async function s_(e) {
|
|
|
14789
14866
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
14790
14867
|
return new r(t);
|
|
14791
14868
|
}
|
|
14792
|
-
function
|
|
14793
|
-
return n(async (n) =>
|
|
14869
|
+
function y_(e, t) {
|
|
14870
|
+
return n(async (n) => __(await t.callTool({
|
|
14794
14871
|
name: e.name,
|
|
14795
14872
|
arguments: n
|
|
14796
14873
|
})), {
|
|
@@ -14799,21 +14876,21 @@ function c_(e, t) {
|
|
|
14799
14876
|
schema: e.inputSchema
|
|
14800
14877
|
});
|
|
14801
14878
|
}
|
|
14802
|
-
async function
|
|
14803
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
14879
|
+
async function b_(e) {
|
|
14880
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await v_(e), r = new t({
|
|
14804
14881
|
name: "page-agent-sdk",
|
|
14805
14882
|
version: "1.0"
|
|
14806
14883
|
}, { capabilities: {} });
|
|
14807
14884
|
await r.connect(n);
|
|
14808
14885
|
let { tools: i } = await r.listTools();
|
|
14809
14886
|
return {
|
|
14810
|
-
tools: i.map((e) =>
|
|
14887
|
+
tools: i.map((e) => y_(e, r)),
|
|
14811
14888
|
close: () => r.close()
|
|
14812
14889
|
};
|
|
14813
14890
|
}
|
|
14814
14891
|
//#endregion
|
|
14815
14892
|
//#region src/core/utils/rounds.ts
|
|
14816
|
-
function
|
|
14893
|
+
function x_(e) {
|
|
14817
14894
|
let t = [], n = null, r = 0;
|
|
14818
14895
|
for (let i = 0; i < e.length; i++) {
|
|
14819
14896
|
let a = e[i];
|
|
@@ -14827,14 +14904,14 @@ function u_(e) {
|
|
|
14827
14904
|
}
|
|
14828
14905
|
return n && t.push(n), t;
|
|
14829
14906
|
}
|
|
14830
|
-
function
|
|
14907
|
+
function S_(e, t) {
|
|
14831
14908
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
14832
14909
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
14833
14910
|
}
|
|
14834
|
-
var
|
|
14835
|
-
function
|
|
14911
|
+
var C_ = "【更早对话摘要";
|
|
14912
|
+
function w_(e, t) {
|
|
14836
14913
|
if (t <= 0) return { trimmed: !1 };
|
|
14837
|
-
let n =
|
|
14914
|
+
let n = x_(e);
|
|
14838
14915
|
if (n.length <= t) return { trimmed: !1 };
|
|
14839
14916
|
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = "";
|
|
14840
14917
|
for (let t = 0; t < a; t++) {
|
|
@@ -14845,7 +14922,7 @@ function p_(e, t) {
|
|
|
14845
14922
|
}
|
|
14846
14923
|
}
|
|
14847
14924
|
let s = i.map((e) => {
|
|
14848
|
-
let t =
|
|
14925
|
+
let t = S_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? S_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
14849
14926
|
return `- 第${e.round}轮:${t} → ${n}`;
|
|
14850
14927
|
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
14851
14928
|
return {
|
|
@@ -14854,47 +14931,47 @@ function p_(e, t) {
|
|
|
14854
14931
|
deleteCount: r,
|
|
14855
14932
|
summary: {
|
|
14856
14933
|
role: "system",
|
|
14857
|
-
content: c ? `${
|
|
14934
|
+
content: c ? `${C_}(${i.length} 轮,含累积)】\n${c}\n【续】\n${s}` : `${C_}(${i.length} 轮)】\n${s}`,
|
|
14858
14935
|
timestamp: i[0].userMsg.timestamp
|
|
14859
14936
|
}
|
|
14860
14937
|
};
|
|
14861
14938
|
}
|
|
14862
14939
|
//#endregion
|
|
14863
14940
|
//#region src/core/composables/useContextManager.ts
|
|
14864
|
-
var
|
|
14941
|
+
var T_ = {
|
|
14865
14942
|
windowRounds: 6,
|
|
14866
14943
|
summaryThresholdRounds: 8,
|
|
14867
14944
|
toolResultMaxChars: 800,
|
|
14868
14945
|
enableRecall: !0,
|
|
14869
14946
|
recallTopK: 3,
|
|
14870
14947
|
enableLLMSummary: !1
|
|
14871
|
-
},
|
|
14872
|
-
function
|
|
14873
|
-
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !
|
|
14948
|
+
}, E_ = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
14949
|
+
function D_(e) {
|
|
14950
|
+
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !E_.has(e));
|
|
14874
14951
|
}
|
|
14875
|
-
function
|
|
14952
|
+
function O_(e) {
|
|
14876
14953
|
let t = typeof e.content == "string" ? e.content : "";
|
|
14877
14954
|
if (e.reasoning && (t += e.reasoning), e.steps) for (let n of e.steps) t += " " + (n.name || ""), n.args != null && (t += " " + (typeof n.args == "string" ? n.args : JSON.stringify(n.args))), n.result && (t += " " + n.result);
|
|
14878
|
-
return
|
|
14955
|
+
return tg(t);
|
|
14879
14956
|
}
|
|
14880
|
-
function
|
|
14881
|
-
let t =
|
|
14882
|
-
for (let n of e.assistantMsgs) t +=
|
|
14957
|
+
function k_(e) {
|
|
14958
|
+
let t = O_(e.userMsg);
|
|
14959
|
+
for (let n of e.assistantMsgs) t += O_(n);
|
|
14883
14960
|
return t;
|
|
14884
14961
|
}
|
|
14885
|
-
function
|
|
14962
|
+
function A_(e, t) {
|
|
14886
14963
|
return e.map((e) => {
|
|
14887
|
-
let n =
|
|
14964
|
+
let n = S_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? S_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
14888
14965
|
if (t && t.size) {
|
|
14889
14966
|
let n = [];
|
|
14890
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
14967
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${S_(e.result, 120)}`);
|
|
14891
14968
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
14892
14969
|
}
|
|
14893
14970
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
14894
14971
|
}).join("\n");
|
|
14895
14972
|
}
|
|
14896
|
-
function
|
|
14897
|
-
let r =
|
|
14973
|
+
function j_(e, t, n) {
|
|
14974
|
+
let r = D_(t);
|
|
14898
14975
|
return r.length === 0 ? [] : e.map((e) => {
|
|
14899
14976
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
14900
14977
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -14904,13 +14981,13 @@ function b_(e, t, n) {
|
|
|
14904
14981
|
};
|
|
14905
14982
|
}).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
|
|
14906
14983
|
}
|
|
14907
|
-
function
|
|
14984
|
+
function M_(e = {}) {
|
|
14908
14985
|
let t = {
|
|
14909
|
-
...
|
|
14986
|
+
...T_,
|
|
14910
14987
|
...e
|
|
14911
14988
|
};
|
|
14912
14989
|
async function n(e) {
|
|
14913
|
-
let n =
|
|
14990
|
+
let n = x_(e), r = e.length, i = (t) => ({
|
|
14914
14991
|
messages: e,
|
|
14915
14992
|
stats: {
|
|
14916
14993
|
triggered: !1,
|
|
@@ -14923,9 +15000,9 @@ function x_(e = {}) {
|
|
|
14923
15000
|
}
|
|
14924
15001
|
}), a, o, s;
|
|
14925
15002
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
14926
|
-
if (n.reduce((e, t) => e +
|
|
15003
|
+
if (n.reduce((e, t) => e + k_(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return i("none");
|
|
14927
15004
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, c = 0;
|
|
14928
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
15005
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += k_(n[t]), r >= e) {
|
|
14929
15006
|
c = t + 1;
|
|
14930
15007
|
break;
|
|
14931
15008
|
}
|
|
@@ -14938,12 +15015,12 @@ function x_(e = {}) {
|
|
|
14938
15015
|
}
|
|
14939
15016
|
let c = [...e].reverse().find((e) => e.role === "user")?.content || "", l = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, u, d;
|
|
14940
15017
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
14941
|
-
u = await t.llmInvoke(
|
|
15018
|
+
u = await t.llmInvoke(A_(o, l)), d = s + "llm_summary";
|
|
14942
15019
|
} catch {
|
|
14943
|
-
u =
|
|
15020
|
+
u = A_(o, l), d = s + "index_summary(llm_fallback)";
|
|
14944
15021
|
}
|
|
14945
|
-
else u =
|
|
14946
|
-
let f = t.enableRecall ?
|
|
15022
|
+
else u = A_(o, l), d = s + "index_summary";
|
|
15023
|
+
let f = t.enableRecall ? j_(o, c, t.recallTopK) : [], p = f.length ? f.map((e) => `- 第${e.round}轮:${S_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? S_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", m = [`【对话历史摘要】以下是之前 ${o.length} 轮对话的要点(最新 ${a.length} 轮已完整保留):`, u];
|
|
14947
15024
|
if (p && m.push("\n【与当前问题可能相关的早期对话】", p), t.getRegisteredProps) try {
|
|
14948
15025
|
let e = t.getRegisteredProps();
|
|
14949
15026
|
if (e.length) {
|
|
@@ -14974,10 +15051,10 @@ function x_(e = {}) {
|
|
|
14974
15051
|
return {
|
|
14975
15052
|
compress: n,
|
|
14976
15053
|
config: t,
|
|
14977
|
-
trimToolResults:
|
|
15054
|
+
trimToolResults: N_
|
|
14978
15055
|
};
|
|
14979
15056
|
}
|
|
14980
|
-
function
|
|
15057
|
+
function N_(e, t) {
|
|
14981
15058
|
let n = [];
|
|
14982
15059
|
if (e.forEach((e, t) => {
|
|
14983
15060
|
e instanceof o && n.push(t);
|
|
@@ -14996,8 +15073,8 @@ function S_(e, t) {
|
|
|
14996
15073
|
}
|
|
14997
15074
|
//#endregion
|
|
14998
15075
|
//#region src/core/harness/summarization.ts
|
|
14999
|
-
function
|
|
15000
|
-
let t =
|
|
15076
|
+
function P_(e = {}) {
|
|
15077
|
+
let t = M_(e);
|
|
15001
15078
|
return {
|
|
15002
15079
|
name: "summarization",
|
|
15003
15080
|
compressInput: async (e) => {
|
|
@@ -15011,7 +15088,7 @@ function C_(e = {}) {
|
|
|
15011
15088
|
}
|
|
15012
15089
|
//#endregion
|
|
15013
15090
|
//#region src/core/presets.ts
|
|
15014
|
-
var
|
|
15091
|
+
var F_ = {
|
|
15015
15092
|
pageBuilder: { systemPrompt: "你是页面构建助手。流程:get_window_prop 读取当前页面结构 → set_window_prop / edit_window_prop 修改属性 → 页面实时更新。多步任务先用 write_todos 拆解,逐步推进。" },
|
|
15016
15093
|
researcher: {
|
|
15017
15094
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15025,14 +15102,14 @@ var w_ = {
|
|
|
15025
15102
|
memory: !1,
|
|
15026
15103
|
subagent: !1
|
|
15027
15104
|
} }
|
|
15028
|
-
},
|
|
15105
|
+
}, I_ = { reliableWriteRules: [
|
|
15029
15106
|
"【可靠写入规则】",
|
|
15030
15107
|
"1. 改任何属性前,先用 get_window_prop 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15031
15108
|
"2. 若不确定可操作哪些属性,先 list_window_props 查看当前注册项(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);",
|
|
15032
15109
|
"3. 不确定某属性字段结构时,先 describe_window_prop 看其说明,字段以 describe 返回为准;",
|
|
15033
15110
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15034
15111
|
"5. 优先用 edit_window_prop 增量 patch(只发改动),避免 set 整体重传大 JSON 被截断。"
|
|
15035
|
-
].join("\n") },
|
|
15112
|
+
].join("\n") }, L_ = {
|
|
15036
15113
|
auto: {
|
|
15037
15114
|
summaryThresholdRatio: .5,
|
|
15038
15115
|
windowRatio: .4,
|
|
@@ -15054,8 +15131,8 @@ var w_ = {
|
|
|
15054
15131
|
enableLLMSummary: !0
|
|
15055
15132
|
}
|
|
15056
15133
|
};
|
|
15057
|
-
function
|
|
15058
|
-
let n =
|
|
15134
|
+
function R_(e, t) {
|
|
15135
|
+
let n = L_[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15059
15136
|
return {
|
|
15060
15137
|
...n,
|
|
15061
15138
|
...r,
|
|
@@ -15072,7 +15149,7 @@ function $(e) {
|
|
|
15072
15149
|
};
|
|
15073
15150
|
return e.path !== void 0 && (t.path = e.path), e.hint && (t.hint = e.hint), e.details !== void 0 && (t.details = e.details), `ERROR: ${JSON.stringify(t)}`;
|
|
15074
15151
|
}
|
|
15075
|
-
function
|
|
15152
|
+
function z_(e) {
|
|
15076
15153
|
return e.slice(0, 10).map((e) => {
|
|
15077
15154
|
let t = e, n = {
|
|
15078
15155
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15081,16 +15158,16 @@ function O_(e) {
|
|
|
15081
15158
|
return t.expected !== void 0 && (n.expected = t.expected), t.received !== void 0 && (n.received = t.received), t.code !== void 0 && (n.code = t.code), n;
|
|
15082
15159
|
});
|
|
15083
15160
|
}
|
|
15084
|
-
function
|
|
15161
|
+
function B_(e, t) {
|
|
15085
15162
|
return $({
|
|
15086
15163
|
code: "SCHEMA_INVALID",
|
|
15087
15164
|
path: e,
|
|
15088
15165
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15089
15166
|
hint: `按 describe_window_prop("${e}") 查看格式,修正后重试;改大对象优先用 edit_window_prop 增量 patch(只发改动部分)`,
|
|
15090
|
-
details:
|
|
15167
|
+
details: z_(t)
|
|
15091
15168
|
});
|
|
15092
15169
|
}
|
|
15093
|
-
function
|
|
15170
|
+
function V_(e, t, n) {
|
|
15094
15171
|
let r = n?.message || String(n);
|
|
15095
15172
|
return $({
|
|
15096
15173
|
code: "JSON_PARSE",
|
|
@@ -15099,18 +15176,18 @@ function A_(e, t, n) {
|
|
|
15099
15176
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15100
15177
|
});
|
|
15101
15178
|
}
|
|
15102
|
-
var
|
|
15103
|
-
function
|
|
15179
|
+
var H_ = .9;
|
|
15180
|
+
function U_(e, t = {}) {
|
|
15104
15181
|
let n = Object.create(null);
|
|
15105
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15182
|
+
if (e) for (let [t, r] of Object.entries(e)) n[K_(t)] = {
|
|
15106
15183
|
content: r,
|
|
15107
|
-
updatedAt:
|
|
15184
|
+
updatedAt: J_()
|
|
15108
15185
|
};
|
|
15109
15186
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15110
15187
|
function a() {
|
|
15111
|
-
if (
|
|
15112
|
-
let e = i *
|
|
15113
|
-
for (let [r] of t) if (delete n[r],
|
|
15188
|
+
if (G_(n) <= i) return;
|
|
15189
|
+
let e = i * H_, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15190
|
+
for (let [r] of t) if (delete n[r], G_(n) <= e) break;
|
|
15114
15191
|
}
|
|
15115
15192
|
let o = null;
|
|
15116
15193
|
function s() {
|
|
@@ -15135,7 +15212,7 @@ function M_(e, t = {}) {
|
|
|
15135
15212
|
}
|
|
15136
15213
|
}) };
|
|
15137
15214
|
return r && (l.hydrate = (e) => {
|
|
15138
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15215
|
+
for (let [t, r] of Object.entries(e)) n[K_(t)] = r;
|
|
15139
15216
|
a();
|
|
15140
15217
|
}, l.flush = () => {
|
|
15141
15218
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15144,17 +15221,17 @@ function M_(e, t = {}) {
|
|
|
15144
15221
|
c();
|
|
15145
15222
|
}), l;
|
|
15146
15223
|
}
|
|
15147
|
-
var
|
|
15148
|
-
function
|
|
15149
|
-
|
|
15224
|
+
var W_ = null;
|
|
15225
|
+
function G_(e) {
|
|
15226
|
+
W_ ||= new TextEncoder();
|
|
15150
15227
|
let t = 0;
|
|
15151
|
-
for (let n of Object.values(e)) t +=
|
|
15228
|
+
for (let n of Object.values(e)) t += W_.encode(n.content).length;
|
|
15152
15229
|
return t;
|
|
15153
15230
|
}
|
|
15154
|
-
function
|
|
15231
|
+
function K_(e) {
|
|
15155
15232
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15156
15233
|
}
|
|
15157
|
-
function
|
|
15234
|
+
function q_(e) {
|
|
15158
15235
|
let t = "";
|
|
15159
15236
|
for (let n = 0; n < e.length; n++) {
|
|
15160
15237
|
let r = e[n];
|
|
@@ -15162,13 +15239,13 @@ function I_(e) {
|
|
|
15162
15239
|
}
|
|
15163
15240
|
return RegExp("^" + t + "$");
|
|
15164
15241
|
}
|
|
15165
|
-
function
|
|
15242
|
+
function J_() {
|
|
15166
15243
|
return Date.now();
|
|
15167
15244
|
}
|
|
15168
|
-
function
|
|
15245
|
+
function Y_(e) {
|
|
15169
15246
|
return [
|
|
15170
15247
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15171
|
-
let i = e.files[
|
|
15248
|
+
let i = e.files[K_(t)];
|
|
15172
15249
|
if (!i) return $({
|
|
15173
15250
|
code: "NOT_FOUND",
|
|
15174
15251
|
path: t,
|
|
@@ -15186,9 +15263,9 @@ function R_(e) {
|
|
|
15186
15263
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15187
15264
|
})
|
|
15188
15265
|
}),
|
|
15189
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15266
|
+
n(async ({ path: t, content: n }) => (e.files[K_(t)] = {
|
|
15190
15267
|
content: n,
|
|
15191
|
-
updatedAt:
|
|
15268
|
+
updatedAt: J_()
|
|
15192
15269
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15193
15270
|
name: "vfs_write",
|
|
15194
15271
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15198,7 +15275,7 @@ function R_(e) {
|
|
|
15198
15275
|
})
|
|
15199
15276
|
}),
|
|
15200
15277
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15201
|
-
let i =
|
|
15278
|
+
let i = K_(t), a = e.files[i];
|
|
15202
15279
|
if (!a) return $({
|
|
15203
15280
|
code: "NOT_FOUND",
|
|
15204
15281
|
path: t,
|
|
@@ -15228,7 +15305,7 @@ function R_(e) {
|
|
|
15228
15305
|
}
|
|
15229
15306
|
return e.files[i] = {
|
|
15230
15307
|
content: a.content.replace(n, r),
|
|
15231
|
-
updatedAt:
|
|
15308
|
+
updatedAt: J_()
|
|
15232
15309
|
}, `已替换 ${t} 中 1 处。`;
|
|
15233
15310
|
}, {
|
|
15234
15311
|
name: "vfs_edit",
|
|
@@ -15250,7 +15327,7 @@ function R_(e) {
|
|
|
15250
15327
|
n(async ({ pattern: t }) => {
|
|
15251
15328
|
let n;
|
|
15252
15329
|
try {
|
|
15253
|
-
n =
|
|
15330
|
+
n = q_(t);
|
|
15254
15331
|
} catch (e) {
|
|
15255
15332
|
return $({
|
|
15256
15333
|
code: "GLOB_INVALID",
|
|
@@ -15279,7 +15356,7 @@ function R_(e) {
|
|
|
15279
15356
|
details: { pattern: t }
|
|
15280
15357
|
});
|
|
15281
15358
|
}
|
|
15282
|
-
let i = n ? [
|
|
15359
|
+
let i = n ? [K_(n)] : Object.keys(e.files), a = [];
|
|
15283
15360
|
for (let t of i) {
|
|
15284
15361
|
let n = e.files[t];
|
|
15285
15362
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15297,17 +15374,17 @@ function R_(e) {
|
|
|
15297
15374
|
})
|
|
15298
15375
|
];
|
|
15299
15376
|
}
|
|
15300
|
-
function
|
|
15377
|
+
function X_(e) {
|
|
15301
15378
|
return {
|
|
15302
15379
|
name: "vfs",
|
|
15303
|
-
tools:
|
|
15380
|
+
tools: Y_(e),
|
|
15304
15381
|
beforeAgent: () => ({ files: e.files })
|
|
15305
15382
|
};
|
|
15306
15383
|
}
|
|
15307
15384
|
//#endregion
|
|
15308
15385
|
//#region src/core/tools/windowQuery.ts
|
|
15309
|
-
var
|
|
15310
|
-
function
|
|
15386
|
+
var Z_ = /[\w$-]/;
|
|
15387
|
+
function Q_(e) {
|
|
15311
15388
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15312
15389
|
for (; r < n.length;) {
|
|
15313
15390
|
let e = n[r];
|
|
@@ -15318,7 +15395,7 @@ function V_(e) {
|
|
|
15318
15395
|
continue;
|
|
15319
15396
|
}
|
|
15320
15397
|
let e = "";
|
|
15321
|
-
for (; r < n.length &&
|
|
15398
|
+
for (; r < n.length && Z_.test(n[r]);) e += n[r++];
|
|
15322
15399
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15323
15400
|
t.push({
|
|
15324
15401
|
type: "descendKey",
|
|
@@ -15331,7 +15408,7 @@ function V_(e) {
|
|
|
15331
15408
|
continue;
|
|
15332
15409
|
}
|
|
15333
15410
|
let e = "";
|
|
15334
|
-
for (; r < n.length &&
|
|
15411
|
+
for (; r < n.length && Z_.test(n[r]);) e += n[r++];
|
|
15335
15412
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15336
15413
|
t.push({
|
|
15337
15414
|
type: "key",
|
|
@@ -15387,7 +15464,7 @@ function V_(e) {
|
|
|
15387
15464
|
}
|
|
15388
15465
|
return t;
|
|
15389
15466
|
}
|
|
15390
|
-
function
|
|
15467
|
+
function $_(e) {
|
|
15391
15468
|
let t = [], n = 0, r = e.trim();
|
|
15392
15469
|
for (; n < r.length;) {
|
|
15393
15470
|
let e = r[n];
|
|
@@ -15432,7 +15509,7 @@ function H_(e) {
|
|
|
15432
15509
|
}
|
|
15433
15510
|
return t;
|
|
15434
15511
|
}
|
|
15435
|
-
var
|
|
15512
|
+
var ev = class {
|
|
15436
15513
|
toks;
|
|
15437
15514
|
item;
|
|
15438
15515
|
pos = 0;
|
|
@@ -15468,12 +15545,12 @@ var U_ = class {
|
|
|
15468
15545
|
return this.next(), e;
|
|
15469
15546
|
}
|
|
15470
15547
|
let e = this.operand(), t = this.peek();
|
|
15471
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15548
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), rv(t, e, this.operand())) : tv(e);
|
|
15472
15549
|
}
|
|
15473
15550
|
operand() {
|
|
15474
15551
|
let e = this.next();
|
|
15475
15552
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15476
|
-
if (e.startsWith("@")) return
|
|
15553
|
+
if (e.startsWith("@")) return nv(e, this.item);
|
|
15477
15554
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15478
15555
|
if (e === "true") return !0;
|
|
15479
15556
|
if (e === "false") return !1;
|
|
@@ -15483,10 +15560,10 @@ var U_ = class {
|
|
|
15483
15560
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15484
15561
|
}
|
|
15485
15562
|
};
|
|
15486
|
-
function
|
|
15563
|
+
function tv(e) {
|
|
15487
15564
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15488
15565
|
}
|
|
15489
|
-
function
|
|
15566
|
+
function nv(e, t) {
|
|
15490
15567
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15491
15568
|
for (let e of n) {
|
|
15492
15569
|
if (typeof r != "object" || !r) return;
|
|
@@ -15494,7 +15571,7 @@ function G_(e, t) {
|
|
|
15494
15571
|
}
|
|
15495
15572
|
return r;
|
|
15496
15573
|
}
|
|
15497
|
-
function
|
|
15574
|
+
function rv(e, t, n) {
|
|
15498
15575
|
switch (e) {
|
|
15499
15576
|
case "==": return t === n;
|
|
15500
15577
|
case "!=": return t !== n;
|
|
@@ -15505,47 +15582,47 @@ function K_(e, t, n) {
|
|
|
15505
15582
|
default: return !1;
|
|
15506
15583
|
}
|
|
15507
15584
|
}
|
|
15508
|
-
function
|
|
15509
|
-
return new
|
|
15585
|
+
function iv(e, t) {
|
|
15586
|
+
return new ev($_(e), t).parse();
|
|
15510
15587
|
}
|
|
15511
|
-
function
|
|
15588
|
+
function av(e, t) {
|
|
15512
15589
|
return e ? `${e}.${t}` : String(t);
|
|
15513
15590
|
}
|
|
15514
|
-
function
|
|
15591
|
+
function ov(e, t) {
|
|
15515
15592
|
let n = [{
|
|
15516
15593
|
path: "",
|
|
15517
15594
|
value: e
|
|
15518
15595
|
}];
|
|
15519
|
-
for (let e of
|
|
15596
|
+
for (let e of Q_(t)) {
|
|
15520
15597
|
let t = [];
|
|
15521
15598
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15522
|
-
path:
|
|
15599
|
+
path: av(r.path, e.key),
|
|
15523
15600
|
value: r.value[e.key]
|
|
15524
15601
|
});
|
|
15525
15602
|
else if (e.type === "index") {
|
|
15526
15603
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15527
15604
|
let n = r.value[e.index];
|
|
15528
15605
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15529
|
-
path:
|
|
15606
|
+
path: av(r.path, e.index),
|
|
15530
15607
|
value: n,
|
|
15531
15608
|
index: e.index
|
|
15532
15609
|
});
|
|
15533
15610
|
}
|
|
15534
15611
|
} else if (e.type === "wildcard") {
|
|
15535
15612
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15536
|
-
path:
|
|
15613
|
+
path: av(e.path, r),
|
|
15537
15614
|
value: n,
|
|
15538
15615
|
index: r
|
|
15539
15616
|
}));
|
|
15540
15617
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15541
|
-
path:
|
|
15618
|
+
path: av(e.path, n),
|
|
15542
15619
|
value: e.value[n]
|
|
15543
15620
|
});
|
|
15544
15621
|
} else if (e.type === "descendKey") {
|
|
15545
15622
|
let r = e.key, i = (e) => {
|
|
15546
15623
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15547
15624
|
let a = {
|
|
15548
|
-
path:
|
|
15625
|
+
path: av(e.path, n),
|
|
15549
15626
|
value: e.value[n]
|
|
15550
15627
|
};
|
|
15551
15628
|
n === r && t.push(a), i(a);
|
|
@@ -15556,7 +15633,7 @@ function Y_(e, t) {
|
|
|
15556
15633
|
let e = (n) => {
|
|
15557
15634
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15558
15635
|
let i = {
|
|
15559
|
-
path:
|
|
15636
|
+
path: av(n.path, r),
|
|
15560
15637
|
value: n.value[r]
|
|
15561
15638
|
};
|
|
15562
15639
|
t.push(i), e(i);
|
|
@@ -15565,16 +15642,16 @@ function Y_(e, t) {
|
|
|
15565
15642
|
for (let t of n) e(t);
|
|
15566
15643
|
} else if (e.type === "filter") {
|
|
15567
15644
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15568
|
-
|
|
15569
|
-
path:
|
|
15645
|
+
iv(e.filter, n) && t.push({
|
|
15646
|
+
path: av(r.path, i),
|
|
15570
15647
|
value: n,
|
|
15571
15648
|
index: i
|
|
15572
15649
|
});
|
|
15573
15650
|
});
|
|
15574
15651
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15575
15652
|
let i = r.value[n];
|
|
15576
|
-
|
|
15577
|
-
path:
|
|
15653
|
+
iv(e.filter, i) && t.push({
|
|
15654
|
+
path: av(r.path, n),
|
|
15578
15655
|
value: i
|
|
15579
15656
|
});
|
|
15580
15657
|
}
|
|
@@ -15583,7 +15660,7 @@ function Y_(e, t) {
|
|
|
15583
15660
|
}
|
|
15584
15661
|
return n;
|
|
15585
15662
|
}
|
|
15586
|
-
function
|
|
15663
|
+
function sv(e, t) {
|
|
15587
15664
|
let n = e.length, r = t.length;
|
|
15588
15665
|
if (!n) return r;
|
|
15589
15666
|
if (!r) return n;
|
|
@@ -15599,7 +15676,7 @@ function X_(e, t) {
|
|
|
15599
15676
|
}
|
|
15600
15677
|
return i[r];
|
|
15601
15678
|
}
|
|
15602
|
-
function
|
|
15679
|
+
function cv(e, t, n = {}) {
|
|
15603
15680
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15604
15681
|
if (r === "regex") try {
|
|
15605
15682
|
s = new RegExp(t, "i");
|
|
@@ -15609,11 +15686,11 @@ function Z_(e, t, n = {}) {
|
|
|
15609
15686
|
let c = (e, l, u) => {
|
|
15610
15687
|
if (o.length >= i || e == null) return;
|
|
15611
15688
|
if (typeof e == "object") {
|
|
15612
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15613
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
15689
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, av(l, t), String(t)));
|
|
15690
|
+
else for (let t of Object.keys(e)) c(e[t], av(l, t), t);
|
|
15614
15691
|
return;
|
|
15615
15692
|
}
|
|
15616
|
-
let d = String(e), f =
|
|
15693
|
+
let d = String(e), f = lv(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15617
15694
|
if (f) {
|
|
15618
15695
|
o.push({
|
|
15619
15696
|
path: l,
|
|
@@ -15624,7 +15701,7 @@ function Z_(e, t, n = {}) {
|
|
|
15624
15701
|
return;
|
|
15625
15702
|
}
|
|
15626
15703
|
if (a && u) {
|
|
15627
|
-
let e =
|
|
15704
|
+
let e = lv(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15628
15705
|
e && o.push({
|
|
15629
15706
|
path: l,
|
|
15630
15707
|
key: u,
|
|
@@ -15635,18 +15712,18 @@ function Z_(e, t, n = {}) {
|
|
|
15635
15712
|
};
|
|
15636
15713
|
return c(e, ""), o;
|
|
15637
15714
|
}
|
|
15638
|
-
function
|
|
15715
|
+
function lv(e, t, n, r, i) {
|
|
15639
15716
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15640
15717
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15641
15718
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15642
15719
|
if (n === "fuzzy") {
|
|
15643
15720
|
if (a.includes(o)) return 2;
|
|
15644
|
-
let e =
|
|
15721
|
+
let e = sv(a, o);
|
|
15645
15722
|
return e <= r ? r - e + 1 : null;
|
|
15646
15723
|
}
|
|
15647
15724
|
return null;
|
|
15648
15725
|
}
|
|
15649
|
-
var
|
|
15726
|
+
var uv = [
|
|
15650
15727
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15651
15728
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15652
15729
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15659,7 +15736,7 @@ var $_ = [
|
|
|
15659
15736
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15660
15737
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15661
15738
|
].join("\n");
|
|
15662
|
-
function
|
|
15739
|
+
function dv(e, t, n = 3e3) {
|
|
15663
15740
|
return new Promise((r) => {
|
|
15664
15741
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15665
15742
|
if (!a) {
|
|
@@ -15672,7 +15749,7 @@ function ev(e, t, n = 3e3) {
|
|
|
15672
15749
|
elapsedMs: Date.now() - i
|
|
15673
15750
|
});
|
|
15674
15751
|
}
|
|
15675
|
-
}, s =
|
|
15752
|
+
}, s = uv + "\nself.onmessage = async (e) => {\n try {\n const fn = new Function(\"data\", e.data.script);\n let result = fn(e.data.data);\n if (result && typeof result.then === \"function\") result = await result;\n self.postMessage({ ok: true, result });\n } catch (err) {\n self.postMessage({ ok: false, error: String((err && err.message) || err) });\n }\n};", c, l;
|
|
15676
15753
|
try {
|
|
15677
15754
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15678
15755
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15707,19 +15784,19 @@ function ev(e, t, n = 3e3) {
|
|
|
15707
15784
|
}
|
|
15708
15785
|
//#endregion
|
|
15709
15786
|
//#region src/core/tools/windowOps.ts
|
|
15710
|
-
var
|
|
15787
|
+
var fv = /* @__PURE__ */ new Set([
|
|
15711
15788
|
"__proto__",
|
|
15712
15789
|
"constructor",
|
|
15713
15790
|
"prototype"
|
|
15714
15791
|
]);
|
|
15715
|
-
function
|
|
15716
|
-
return e.split(".").some((e) =>
|
|
15792
|
+
function pv(e) {
|
|
15793
|
+
return e.split(".").some((e) => fv.has(e));
|
|
15717
15794
|
}
|
|
15718
|
-
function
|
|
15719
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t))
|
|
15795
|
+
function mv(e, t) {
|
|
15796
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) fv.has(n) || (e[n] = t[n]);
|
|
15720
15797
|
}
|
|
15721
|
-
function
|
|
15722
|
-
if (
|
|
15798
|
+
function hv(e, t) {
|
|
15799
|
+
if (pv(t)) return;
|
|
15723
15800
|
let n = t.split("."), r = e;
|
|
15724
15801
|
for (let e of n) {
|
|
15725
15802
|
if (r == null) return;
|
|
@@ -15727,8 +15804,8 @@ function iv(e, t) {
|
|
|
15727
15804
|
}
|
|
15728
15805
|
return r;
|
|
15729
15806
|
}
|
|
15730
|
-
function
|
|
15731
|
-
if (
|
|
15807
|
+
function gv(e, t, n) {
|
|
15808
|
+
if (pv(t)) return;
|
|
15732
15809
|
let r = t.split("."), i = e;
|
|
15733
15810
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15734
15811
|
let t = r[e];
|
|
@@ -15736,8 +15813,8 @@ function av(e, t, n) {
|
|
|
15736
15813
|
}
|
|
15737
15814
|
i[r[r.length - 1]] = n;
|
|
15738
15815
|
}
|
|
15739
|
-
function
|
|
15740
|
-
if (
|
|
15816
|
+
function _v(e, t) {
|
|
15817
|
+
if (pv(t)) return !1;
|
|
15741
15818
|
let n = t.split("."), r = e;
|
|
15742
15819
|
for (let e = 0; e < n.length - 1; e++) {
|
|
15743
15820
|
if (r == null) return !1;
|
|
@@ -15746,10 +15823,10 @@ function ov(e, t) {
|
|
|
15746
15823
|
let i = n[n.length - 1];
|
|
15747
15824
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
15748
15825
|
}
|
|
15749
|
-
function
|
|
15826
|
+
function vv(e) {
|
|
15750
15827
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
15751
15828
|
}
|
|
15752
|
-
function
|
|
15829
|
+
function yv(e, t = Infinity) {
|
|
15753
15830
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
15754
15831
|
try {
|
|
15755
15832
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -15768,30 +15845,35 @@ function cv(e, t = Infinity) {
|
|
|
15768
15845
|
}
|
|
15769
15846
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
15770
15847
|
}
|
|
15771
|
-
function
|
|
15772
|
-
|
|
15773
|
-
|
|
15848
|
+
function bv(e) {
|
|
15849
|
+
let t = yv(e), n = 5381;
|
|
15850
|
+
for (let e = 0; e < t.length; e++) n = (n << 5) + n + t.charCodeAt(e) >>> 0;
|
|
15851
|
+
return n.toString(36);
|
|
15852
|
+
}
|
|
15853
|
+
function xv(e, t, n, r) {
|
|
15854
|
+
if (t === "set") return n ? (gv(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_window_prop)";
|
|
15855
|
+
if (t === "remove") return n ? (_v(e, n), null) : "remove 操作需要 jsonPath";
|
|
15774
15856
|
if (t === "merge") {
|
|
15775
|
-
let t = n ?
|
|
15776
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
15857
|
+
let t = n ? hv(e, n) : e;
|
|
15858
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (mv(t, r), null);
|
|
15777
15859
|
}
|
|
15778
|
-
let i = n ?
|
|
15860
|
+
let i = n ? hv(e, n) : e;
|
|
15779
15861
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
15780
15862
|
}
|
|
15781
|
-
function
|
|
15782
|
-
if (t === "set")
|
|
15783
|
-
else if (t === "remove")
|
|
15784
|
-
else if (t === "merge")
|
|
15863
|
+
function Sv(e, t, n, r) {
|
|
15864
|
+
if (t === "set") gv(window, `${e}.${n}`, r);
|
|
15865
|
+
else if (t === "remove") _v(window, `${e}.${n}`);
|
|
15866
|
+
else if (t === "merge") mv(n ? hv(window, `${e}.${n}`) : hv(window, e), r);
|
|
15785
15867
|
else {
|
|
15786
|
-
let t = n ?
|
|
15868
|
+
let t = n ? hv(window, `${e}.${n}`) : hv(window, e);
|
|
15787
15869
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
15788
15870
|
}
|
|
15789
15871
|
}
|
|
15790
|
-
function
|
|
15791
|
-
let n =
|
|
15792
|
-
typeof n == "object" && n ?
|
|
15872
|
+
function Cv(e, t) {
|
|
15873
|
+
let n = hv(window, e);
|
|
15874
|
+
typeof n == "object" && n ? wv(n, t) : gv(window, e, t);
|
|
15793
15875
|
}
|
|
15794
|
-
function
|
|
15876
|
+
function wv(e, t) {
|
|
15795
15877
|
if (Array.isArray(e)) {
|
|
15796
15878
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
15797
15879
|
return;
|
|
@@ -15800,7 +15882,7 @@ function fv(e, t) {
|
|
|
15800
15882
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
15801
15883
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
15802
15884
|
}
|
|
15803
|
-
function
|
|
15885
|
+
function Tv(e, r = {}) {
|
|
15804
15886
|
let i = /* @__PURE__ */ new Map();
|
|
15805
15887
|
for (let t of e) i.set(t.path, t);
|
|
15806
15888
|
let a = /* @__PURE__ */ new Map(), o = r.maxSnapshots ?? 20, s = {
|
|
@@ -15827,7 +15909,7 @@ function pv(e, r = {}) {
|
|
|
15827
15909
|
return r.allowRawRead ? !0 : [...i.keys()].some((t) => e === t || e.startsWith(t + ".") || u && t.startsWith(e + "."));
|
|
15828
15910
|
}
|
|
15829
15911
|
function f(e, t, n) {
|
|
15830
|
-
let r =
|
|
15912
|
+
let r = vv(hv(window, e)), i = a.get(e) || [], s = i.length ? i[i.length - 1].id + 1 : 1;
|
|
15831
15913
|
for (i.push({
|
|
15832
15914
|
id: s,
|
|
15833
15915
|
ts: Date.now(),
|
|
@@ -15837,7 +15919,37 @@ function pv(e, r = {}) {
|
|
|
15837
15919
|
}); i.length > o;) i.shift();
|
|
15838
15920
|
return a.set(e, i), s;
|
|
15839
15921
|
}
|
|
15840
|
-
|
|
15922
|
+
async function p(e, t, n, i) {
|
|
15923
|
+
if (!n || n === "") return null;
|
|
15924
|
+
let o = hv(window, e), s = bv(o);
|
|
15925
|
+
if (s === n) return null;
|
|
15926
|
+
if (!r.onConflict) return $({
|
|
15927
|
+
code: "VERSION_CONFLICT",
|
|
15928
|
+
path: e,
|
|
15929
|
+
message: `乐观锁冲突:expectedHash=${n} 但当前 hash=${s}。属性 "${e}" 在你 get 之后已被修改(外部代码/其他 agent/用户手动改)。`,
|
|
15930
|
+
hint: `重新 get_window_prop("${e}") 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${yv(o, 400)}`
|
|
15931
|
+
});
|
|
15932
|
+
let c = await r.onConflict({
|
|
15933
|
+
path: e,
|
|
15934
|
+
op: t,
|
|
15935
|
+
agentValue: i,
|
|
15936
|
+
currentValue: o,
|
|
15937
|
+
currentHash: s,
|
|
15938
|
+
expectedHash: n,
|
|
15939
|
+
snapshotId: 0
|
|
15940
|
+
});
|
|
15941
|
+
if (c.action === "keep_external") return `已保留外部修改(未写入)。当前值:${yv(o, 400)} (hash=${s})。请重新 get_window_prop("${e}") 拿最新值与 hash 再改。`;
|
|
15942
|
+
if (c.action === "restore") {
|
|
15943
|
+
let t = a.get(e) || [];
|
|
15944
|
+
if (!t.length) return `无历史快照可回退(本次为首次操作)。当前值:${yv(o, 400)} (hash=${s})。请重新 get 再改或选「强制覆盖」。`;
|
|
15945
|
+
let n = t[t.length - 1];
|
|
15946
|
+
Cv(e, vv(n.value));
|
|
15947
|
+
let r = hv(window, e);
|
|
15948
|
+
return `已回退 ${e} 到历史快照 #${n.id}[${n.op}]。当前值:${yv(r, 400)} (hash=${bv(r)})。请基于回退后的值重写或停止。`;
|
|
15949
|
+
}
|
|
15950
|
+
return null;
|
|
15951
|
+
}
|
|
15952
|
+
let m = n(async () => {
|
|
15841
15953
|
if (!i.size) return "当前没有已注册的可操作 window 属性。";
|
|
15842
15954
|
let e = [...i.values()].map((e) => `- ${e.path}: ${e.description}`);
|
|
15843
15955
|
return `可操作的 window 属性(共 ${i.size} 项):\n${e.join("\n")}`;
|
|
@@ -15845,7 +15957,7 @@ function pv(e, r = {}) {
|
|
|
15845
15957
|
name: "list_window_props",
|
|
15846
15958
|
description: "列出所有已注册、可操作的 window 属性(path + 说明)。操作 window 前先调用此工具了解可用范围。",
|
|
15847
15959
|
schema: t.object({})
|
|
15848
|
-
}),
|
|
15960
|
+
}), h = n(async ({ path: e }) => {
|
|
15849
15961
|
let t = i.get(e);
|
|
15850
15962
|
return t ? [
|
|
15851
15963
|
`路径: ${t.path}`,
|
|
@@ -15861,66 +15973,77 @@ function pv(e, r = {}) {
|
|
|
15861
15973
|
name: "describe_window_prop",
|
|
15862
15974
|
description: "获取单个已注册 window 属性的说明与格式要求。",
|
|
15863
15975
|
schema: t.object({ path: t.string().describe("属性路径,如 app.theme") })
|
|
15864
|
-
}),
|
|
15976
|
+
}), g = n(async ({ path: e }) => {
|
|
15865
15977
|
if (!d(e)) return $({
|
|
15866
15978
|
code: "NOT_REGISTERED",
|
|
15867
15979
|
path: e,
|
|
15868
15980
|
message: `属性 "${e}" 不可读取(未注册,且非已注册路径的后代)`,
|
|
15869
15981
|
hint: "用 list_window_props 查看可操作字段;字段白名单读模式下未注册的祖先(整体大 JSON)不暴露,需读其声明子路径"
|
|
15870
15982
|
});
|
|
15871
|
-
let t =
|
|
15872
|
-
return t === void 0 ? `${e} = (undefined)` : `${e} = ${
|
|
15983
|
+
let t = hv(window, e);
|
|
15984
|
+
return t === void 0 ? `${e} = (undefined)` : `${e} = ${yv(t)} (hash=${bv(t)})`;
|
|
15873
15985
|
}, {
|
|
15874
15986
|
name: "get_window_prop",
|
|
15875
|
-
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
15987
|
+
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改属性前先 get 拿 hash,写入时(set/edit/delete)传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"(外部代码/其他 agent/用户手动改过会 CONFLICT,需重新 get 再改)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
15876
15988
|
schema: t.object({ path: t.string().describe("已注册的属性路径或其后代") })
|
|
15877
|
-
}),
|
|
15878
|
-
let
|
|
15879
|
-
if (!
|
|
15989
|
+
}), _ = n(async ({ path: e, value: t, expectedHash: n }) => {
|
|
15990
|
+
let r = i.get(e);
|
|
15991
|
+
if (!r) return $({
|
|
15880
15992
|
code: "NOT_REGISTERED",
|
|
15881
15993
|
path: e,
|
|
15882
15994
|
message: `属性 "${e}" 未在注册表中声明,不可写`,
|
|
15883
15995
|
hint: "用 list_window_props 查看可用属性;集成方需先在 windowProps 声明该 path"
|
|
15884
15996
|
});
|
|
15885
|
-
let
|
|
15997
|
+
let a = await p(e, "set", n);
|
|
15998
|
+
if (a !== null) return a;
|
|
15999
|
+
let o;
|
|
15886
16000
|
try {
|
|
15887
|
-
|
|
16001
|
+
o = JSON.parse(t);
|
|
15888
16002
|
} catch (n) {
|
|
15889
|
-
return
|
|
16003
|
+
return V_(e, t, n);
|
|
15890
16004
|
}
|
|
15891
|
-
let
|
|
15892
|
-
if (!
|
|
16005
|
+
let s = r.schema.safeParse(o);
|
|
16006
|
+
if (!s.success) return B_(e, s.error.issues);
|
|
15893
16007
|
f(e, "set");
|
|
15894
|
-
let
|
|
15895
|
-
return typeof
|
|
16008
|
+
let u = hv(window, e);
|
|
16009
|
+
return typeof u == "object" && u && s.data !== null && typeof s.data == "object" ? wv(u, s.data) : gv(window, e, s.data), c({
|
|
15896
16010
|
op: "set",
|
|
15897
16011
|
path: e,
|
|
15898
|
-
value:
|
|
16012
|
+
value: s.data,
|
|
15899
16013
|
timestamp: Date.now()
|
|
15900
|
-
}), `已设置 ${e} = ${
|
|
16014
|
+
}), `已设置 ${e} = ${yv(s.data, 600)} (新 hash=${bv(hv(window, e))})${l()}`;
|
|
15901
16015
|
}, {
|
|
15902
16016
|
name: "set_window_prop",
|
|
15903
|
-
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema
|
|
16017
|
+
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 get_window_prop 返回的 hash,传入则启用乐观锁——若属性已被改过(外部代码/其他 agent/用户手动)则返回 VERSION_CONFLICT 不写入,需重新 get 再改,防\"基于过期值覆盖\"。大对象/数组强烈建议改用 edit_window_prop 增量 patch。",
|
|
15904
16018
|
schema: t.object({
|
|
15905
16019
|
path: t.string().describe("已注册的属性路径"),
|
|
15906
|
-
value: t.string().describe("JSON 字符串形式的值,需符合该属性 schema")
|
|
16020
|
+
value: t.string().describe("JSON 字符串形式的值,需符合该属性 schema"),
|
|
16021
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝写入防覆盖")
|
|
15907
16022
|
})
|
|
15908
|
-
}),
|
|
15909
|
-
let
|
|
15910
|
-
if (!
|
|
16023
|
+
}), v = n(async ({ path: e, op: t, jsonPath: n, value: r, expectedHash: a }) => {
|
|
16024
|
+
let o = i.get(e);
|
|
16025
|
+
if (!o) return $({
|
|
15911
16026
|
code: "NOT_REGISTERED",
|
|
15912
16027
|
path: e,
|
|
15913
16028
|
message: `属性 "${e}" 未在注册表中声明,不可写`,
|
|
15914
16029
|
hint: "用 list_window_props 查看可用属性"
|
|
15915
16030
|
});
|
|
15916
|
-
let
|
|
15917
|
-
if (
|
|
16031
|
+
let s = n || "";
|
|
16032
|
+
if (pv(s)) return $({
|
|
15918
16033
|
code: "PATH_UNSAFE",
|
|
15919
16034
|
path: e,
|
|
15920
|
-
message: `jsonPath "${
|
|
16035
|
+
message: `jsonPath "${s}" 含非法段(__proto__/constructor/prototype)`,
|
|
15921
16036
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
15922
16037
|
});
|
|
15923
|
-
let
|
|
16038
|
+
let u = hv(window, e), d = await p(e, "edit", a);
|
|
16039
|
+
if (d !== null) return d;
|
|
16040
|
+
if (typeof u != "object" || !u) return $({
|
|
16041
|
+
code: "NOT_OBJECT",
|
|
16042
|
+
path: e,
|
|
16043
|
+
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${u === void 0 ? "undefined" : typeof u}`,
|
|
16044
|
+
hint: "叶子属性(原始类型)请用 set_window_prop 整体设置"
|
|
16045
|
+
});
|
|
16046
|
+
let m;
|
|
15924
16047
|
if (t !== "remove") {
|
|
15925
16048
|
if (r === void 0 || r === "") return $({
|
|
15926
16049
|
code: "MISSING_VALUE",
|
|
@@ -15929,36 +16052,29 @@ function pv(e, r = {}) {
|
|
|
15929
16052
|
hint: `op 为 ${t} 时 value 必填;若想删除请用 op:'remove'`
|
|
15930
16053
|
});
|
|
15931
16054
|
try {
|
|
15932
|
-
|
|
16055
|
+
m = JSON.parse(r);
|
|
15933
16056
|
} catch (t) {
|
|
15934
|
-
return
|
|
16057
|
+
return V_(e, r, t);
|
|
15935
16058
|
}
|
|
15936
16059
|
}
|
|
15937
|
-
let u =
|
|
15938
|
-
if (
|
|
15939
|
-
code: "NOT_OBJECT",
|
|
15940
|
-
path: e,
|
|
15941
|
-
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${u === void 0 ? "undefined" : typeof u}`,
|
|
15942
|
-
hint: "叶子属性(原始类型)请用 set_window_prop 整体设置"
|
|
15943
|
-
});
|
|
15944
|
-
let d = sv(u), p = lv(d, t, o, s);
|
|
15945
|
-
if (p) return $({
|
|
16060
|
+
let h = vv(u), g = xv(h, t, s, m);
|
|
16061
|
+
if (g) return $({
|
|
15946
16062
|
code: "PATCH_FAILED",
|
|
15947
16063
|
path: e,
|
|
15948
|
-
message:
|
|
16064
|
+
message: g,
|
|
15949
16065
|
hint: "检查 op 与目标类型:merge 需目标为对象,append 需目标为数组;jsonPath 指向需存在"
|
|
15950
16066
|
});
|
|
15951
|
-
let
|
|
15952
|
-
return
|
|
16067
|
+
let _ = o.schema.safeParse(h);
|
|
16068
|
+
return _.success ? (f(e, "edit"), Sv(e, t, s, m), c({
|
|
15953
16069
|
op: "edit",
|
|
15954
16070
|
path: e,
|
|
15955
|
-
detail: `${t}${
|
|
15956
|
-
value:
|
|
16071
|
+
detail: `${t}${s ? "@" + s : ""}`,
|
|
16072
|
+
value: m,
|
|
15957
16073
|
timestamp: Date.now()
|
|
15958
|
-
}), `已 edit ${e}(${t}${
|
|
16074
|
+
}), `已 edit ${e}(${t}${s ? " @ " + s : ""})。当前值:${yv(hv(window, e), 600)} (新 hash=${bv(hv(window, e))})${l()}`) : B_(e, _.error.issues);
|
|
15959
16075
|
}, {
|
|
15960
16076
|
name: "edit_window_prop",
|
|
15961
|
-
description: "增量编辑一个已注册的「对象/数组」window 属性,只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对属性根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 字符串。整体仍经 schema 校验,失败不写入。",
|
|
16077
|
+
description: "增量编辑一个已注册的「对象/数组」window 属性,只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对属性根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 字符串。整体仍经 schema 校验,失败不写入。expectedHash(可选):改前 get_window_prop 返回的 hash,传入启用乐观锁防\"基于过期值覆盖\"。",
|
|
15962
16078
|
schema: t.object({
|
|
15963
16079
|
path: t.string().describe("已注册的对象/数组属性路径"),
|
|
15964
16080
|
op: t.enum([
|
|
@@ -15968,27 +16084,33 @@ function pv(e, r = {}) {
|
|
|
15968
16084
|
"append"
|
|
15969
16085
|
]),
|
|
15970
16086
|
jsonPath: t.string().optional().describe("相对属性根的点号路径(数组索引用数字,如 components.0.text)。set/remove 必填;merge/append 不填则作用于根"),
|
|
15971
|
-
value: t.string().optional().describe("JSON 字符串(set/merge/append 必填)")
|
|
16087
|
+
value: t.string().optional().describe("JSON 字符串(set/merge/append 必填)"),
|
|
16088
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝写入防覆盖")
|
|
15972
16089
|
})
|
|
15973
|
-
}),
|
|
16090
|
+
}), y = n(async ({ path: e, expectedHash: t }) => {
|
|
15974
16091
|
if (!i.has(e)) return $({
|
|
15975
16092
|
code: "NOT_REGISTERED",
|
|
15976
16093
|
path: e,
|
|
15977
16094
|
message: `属性 "${e}" 未在注册表中声明,不可删除`,
|
|
15978
16095
|
hint: "用 list_window_props 查看可用属性"
|
|
15979
16096
|
});
|
|
16097
|
+
let n = await p(e, "delete", t);
|
|
16098
|
+
if (n !== null) return n;
|
|
15980
16099
|
f(e, "delete");
|
|
15981
|
-
let
|
|
16100
|
+
let r = _v(window, e);
|
|
15982
16101
|
return c({
|
|
15983
16102
|
op: "delete",
|
|
15984
16103
|
path: e,
|
|
15985
16104
|
timestamp: Date.now()
|
|
15986
|
-
}),
|
|
16105
|
+
}), r ? `已删除 ${e}${l()}` : `${e} 不存在(无需删除)${l()}`;
|
|
15987
16106
|
}, {
|
|
15988
16107
|
name: "delete_window_prop",
|
|
15989
|
-
description: "删除一个已注册 window 属性。",
|
|
15990
|
-
schema: t.object({
|
|
15991
|
-
|
|
16108
|
+
description: "删除一个已注册 window 属性。expectedHash(可选):改前 get_window_prop 返回的 hash,传入启用乐观锁防\"基于过期值删除\"。",
|
|
16109
|
+
schema: t.object({
|
|
16110
|
+
path: t.string().describe("已注册的属性路径"),
|
|
16111
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝删除防覆盖")
|
|
16112
|
+
})
|
|
16113
|
+
}), b = n(async ({ path: e, label: t }) => i.has(e) ? `已为 ${e} 创建快照 #${f(e, "manual", t)}${t ? `(${t})` : ""}。可用 list_window_snapshots 查看、restore_window_snapshot 回退。` : $({
|
|
15992
16114
|
code: "NOT_REGISTERED",
|
|
15993
16115
|
path: e,
|
|
15994
16116
|
message: `属性 "${e}" 未注册,无法打快照`,
|
|
@@ -16000,7 +16122,7 @@ function pv(e, r = {}) {
|
|
|
16000
16122
|
path: t.string().describe("已注册的属性路径"),
|
|
16001
16123
|
label: t.string().optional().describe("可选的快照标签,便于识别")
|
|
16002
16124
|
})
|
|
16003
|
-
}),
|
|
16125
|
+
}), x = n(async ({ path: e }) => {
|
|
16004
16126
|
let t = e ? [e] : [...i.keys()];
|
|
16005
16127
|
if (e && !i.has(e)) return $({
|
|
16006
16128
|
code: "NOT_REGISTERED",
|
|
@@ -16026,7 +16148,7 @@ function pv(e, r = {}) {
|
|
|
16026
16148
|
name: "list_window_snapshots",
|
|
16027
16149
|
description: "列出 window 属性的快照时间线(序号、操作类型、标签、大小)。不传 path 列出所有属性。",
|
|
16028
16150
|
schema: t.object({ path: t.string().optional().describe("限定单个属性,不传则列出全部") })
|
|
16029
|
-
}),
|
|
16151
|
+
}), S = n(async ({ path: e, id: t }) => {
|
|
16030
16152
|
let n = i.get(e);
|
|
16031
16153
|
if (!n) return $({
|
|
16032
16154
|
code: "NOT_REGISTERED",
|
|
@@ -16049,7 +16171,7 @@ function pv(e, r = {}) {
|
|
|
16049
16171
|
hint: "用 list_window_snapshots 查看可用快照序号"
|
|
16050
16172
|
});
|
|
16051
16173
|
let s = n.schema.safeParse(o.value);
|
|
16052
|
-
return s.success ? (
|
|
16174
|
+
return s.success ? (Cv(e, vv(o.value)), c({
|
|
16053
16175
|
op: "restore",
|
|
16054
16176
|
path: e,
|
|
16055
16177
|
detail: `#${o.id}`,
|
|
@@ -16059,7 +16181,7 @@ function pv(e, r = {}) {
|
|
|
16059
16181
|
path: e,
|
|
16060
16182
|
message: `快照 #${o.id} 的值不符合当前 schema,无法回退`,
|
|
16061
16183
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16062
|
-
details:
|
|
16184
|
+
details: z_(s.error.issues)
|
|
16063
16185
|
});
|
|
16064
16186
|
}, {
|
|
16065
16187
|
name: "restore_window_snapshot",
|
|
@@ -16068,10 +16190,10 @@ function pv(e, r = {}) {
|
|
|
16068
16190
|
path: t.string().describe("已注册的属性路径"),
|
|
16069
16191
|
id: t.number().int().optional().describe("指定快照序号;不传则回退最近一次")
|
|
16070
16192
|
})
|
|
16071
|
-
}),
|
|
16072
|
-
p,
|
|
16193
|
+
}), C = [
|
|
16073
16194
|
m,
|
|
16074
16195
|
h,
|
|
16196
|
+
g,
|
|
16075
16197
|
n(async ({ paths: e }) => {
|
|
16076
16198
|
let t = [];
|
|
16077
16199
|
for (let n of e) {
|
|
@@ -16084,8 +16206,8 @@ function pv(e, r = {}) {
|
|
|
16084
16206
|
})}`);
|
|
16085
16207
|
continue;
|
|
16086
16208
|
}
|
|
16087
|
-
let e =
|
|
16088
|
-
t.push(`- ${n} = ${e === void 0 ? "(undefined)" :
|
|
16209
|
+
let e = hv(window, n);
|
|
16210
|
+
t.push(`- ${n} = ${e === void 0 ? "(undefined)" : yv(e)}`);
|
|
16089
16211
|
}
|
|
16090
16212
|
return t.join("\n");
|
|
16091
16213
|
}, {
|
|
@@ -16093,12 +16215,12 @@ function pv(e, r = {}) {
|
|
|
16093
16215
|
description: "批量按路径读取 window 属性的局部或多个字段(避免对大 JSON 整体读取)。paths 支持注册属性的任意后代路径(如 page.components.0.text)、自身。字段白名单读模式(默认)下未注册祖先不可读。逐行返回 path = value;单个值过大仍由系统自动外存 vfs。",
|
|
16094
16216
|
schema: t.object({ paths: t.array(t.string().describe("路径,如 page.components.0.text")).min(1).max(20) })
|
|
16095
16217
|
}),
|
|
16096
|
-
g,
|
|
16097
16218
|
_,
|
|
16098
16219
|
v,
|
|
16099
16220
|
y,
|
|
16100
16221
|
b,
|
|
16101
16222
|
x,
|
|
16223
|
+
S,
|
|
16102
16224
|
n(async ({ path: e, expr: t, limit: n }) => {
|
|
16103
16225
|
if (!i.get(e)) return $({
|
|
16104
16226
|
code: "NOT_REGISTERED",
|
|
@@ -16106,7 +16228,7 @@ function pv(e, r = {}) {
|
|
|
16106
16228
|
message: `属性 "${e}" 未注册`,
|
|
16107
16229
|
hint: "用 list_window_props 查看可用属性"
|
|
16108
16230
|
});
|
|
16109
|
-
let r =
|
|
16231
|
+
let r = hv(window, e);
|
|
16110
16232
|
if (typeof r != "object" || !r) return $({
|
|
16111
16233
|
code: "NOT_OBJECT",
|
|
16112
16234
|
path: e,
|
|
@@ -16115,7 +16237,7 @@ function pv(e, r = {}) {
|
|
|
16115
16237
|
});
|
|
16116
16238
|
let a;
|
|
16117
16239
|
try {
|
|
16118
|
-
a =
|
|
16240
|
+
a = ov(r, t);
|
|
16119
16241
|
} catch (n) {
|
|
16120
16242
|
return $({
|
|
16121
16243
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16125,7 +16247,7 @@ function pv(e, r = {}) {
|
|
|
16125
16247
|
details: { expr: t }
|
|
16126
16248
|
});
|
|
16127
16249
|
}
|
|
16128
|
-
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${
|
|
16250
|
+
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${yv(e.value)}}`);
|
|
16129
16251
|
return `{"matched":${a.length},"returned":${s.length},"truncated":${a.length > o},"results":[${c.join(",")}]}`;
|
|
16130
16252
|
}, {
|
|
16131
16253
|
name: "query_window_prop",
|
|
@@ -16143,20 +16265,20 @@ function pv(e, r = {}) {
|
|
|
16143
16265
|
message: `属性 "${e}" 未注册`,
|
|
16144
16266
|
hint: "用 list_window_props 查看可用属性"
|
|
16145
16267
|
});
|
|
16146
|
-
let s =
|
|
16268
|
+
let s = hv(window, e);
|
|
16147
16269
|
if (s == null) return $({
|
|
16148
16270
|
code: "EMPTY",
|
|
16149
16271
|
path: e,
|
|
16150
16272
|
message: `"${e}" 为空,无可搜索内容`
|
|
16151
16273
|
});
|
|
16152
16274
|
try {
|
|
16153
|
-
let e =
|
|
16275
|
+
let e = cv(s, t, {
|
|
16154
16276
|
mode: n,
|
|
16155
16277
|
fuzzyThreshold: r,
|
|
16156
16278
|
matchKey: a,
|
|
16157
16279
|
limit: o ?? 50
|
|
16158
16280
|
});
|
|
16159
|
-
return
|
|
16281
|
+
return yv({
|
|
16160
16282
|
matched: e.length,
|
|
16161
16283
|
results: e
|
|
16162
16284
|
});
|
|
@@ -16199,7 +16321,7 @@ function pv(e, r = {}) {
|
|
|
16199
16321
|
message: `脚本过长(${t.length} 字符,上限 8000)`,
|
|
16200
16322
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16201
16323
|
});
|
|
16202
|
-
let a = await
|
|
16324
|
+
let a = await dv(vv(hv(window, e)), t, 3e3);
|
|
16203
16325
|
if (!a.ok) {
|
|
16204
16326
|
let n = /超时/.test(a.error || "");
|
|
16205
16327
|
return $({
|
|
@@ -16220,18 +16342,18 @@ function pv(e, r = {}) {
|
|
|
16220
16342
|
path: e,
|
|
16221
16343
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回该属性的完整新值且符合 schema)",
|
|
16222
16344
|
hint: `确认脚本 return 了完整新值(非部分);按 describe_window_prop("${e}") 查看格式`,
|
|
16223
|
-
details:
|
|
16345
|
+
details: z_(t.error.issues)
|
|
16224
16346
|
});
|
|
16225
16347
|
f(e, "edit", "eval_transform");
|
|
16226
|
-
let n =
|
|
16227
|
-
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ?
|
|
16348
|
+
let n = hv(window, e);
|
|
16349
|
+
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ? wv(n, t.data) : gv(window, e, t.data), c({
|
|
16228
16350
|
op: "edit",
|
|
16229
16351
|
path: e,
|
|
16230
16352
|
detail: "eval_transform",
|
|
16231
16353
|
timestamp: Date.now()
|
|
16232
|
-
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${
|
|
16354
|
+
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${yv(hv(window, e), 600)}`;
|
|
16233
16355
|
}
|
|
16234
|
-
return
|
|
16356
|
+
return yv({
|
|
16235
16357
|
ok: !0,
|
|
16236
16358
|
result: a.result,
|
|
16237
16359
|
elapsedMs: a.elapsedMs
|
|
@@ -16246,17 +16368,17 @@ function pv(e, r = {}) {
|
|
|
16246
16368
|
})
|
|
16247
16369
|
})
|
|
16248
16370
|
];
|
|
16249
|
-
return Object.defineProperty(
|
|
16371
|
+
return Object.defineProperty(C, "controller", {
|
|
16250
16372
|
value: s,
|
|
16251
16373
|
enumerable: !1,
|
|
16252
16374
|
configurable: !1,
|
|
16253
16375
|
writable: !1
|
|
16254
|
-
}),
|
|
16376
|
+
}), C;
|
|
16255
16377
|
}
|
|
16256
16378
|
//#endregion
|
|
16257
16379
|
//#region src/core/tools/fetchDoc.ts
|
|
16258
|
-
var
|
|
16259
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16380
|
+
var Ev = 3e4, Dv = [n(async ({ url: e, as: t }) => {
|
|
16381
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Ev);
|
|
16260
16382
|
try {
|
|
16261
16383
|
let r = await fetch(e, {
|
|
16262
16384
|
method: "GET",
|
|
@@ -16273,7 +16395,7 @@ var mv = 3e4, hv = [n(async ({ url: e, as: t }) => {
|
|
|
16273
16395
|
].join("\n");
|
|
16274
16396
|
} catch (t) {
|
|
16275
16397
|
let r = t?.message || String(t);
|
|
16276
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16398
|
+
return n.signal.aborted ? `获取失败:请求超时(${Ev}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16277
16399
|
} finally {
|
|
16278
16400
|
clearTimeout(r);
|
|
16279
16401
|
}
|
|
@@ -16284,33 +16406,33 @@ var mv = 3e4, hv = [n(async ({ url: e, as: t }) => {
|
|
|
16284
16406
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16285
16407
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16286
16408
|
})
|
|
16287
|
-
})],
|
|
16288
|
-
function
|
|
16289
|
-
return
|
|
16409
|
+
})], Ov = Dv;
|
|
16410
|
+
function kv(e, t) {
|
|
16411
|
+
return Tv(e, t);
|
|
16290
16412
|
}
|
|
16291
|
-
function
|
|
16413
|
+
function Av(e, t, n) {
|
|
16292
16414
|
let r = e?.windowOps !== !1, i = e?.fetch !== !1;
|
|
16293
16415
|
return [...r ? t : [], ...i ? n : []];
|
|
16294
16416
|
}
|
|
16295
16417
|
//#endregion
|
|
16296
16418
|
//#region src/core/harness/usageHints.ts
|
|
16297
|
-
var
|
|
16298
|
-
function
|
|
16419
|
+
var jv = .7;
|
|
16420
|
+
function Mv(e, t) {
|
|
16299
16421
|
return {
|
|
16300
16422
|
name: "usageHints",
|
|
16301
16423
|
augmentPrompt: () => {
|
|
16302
16424
|
let n = [];
|
|
16303
|
-
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("
|
|
16304
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
16425
|
+
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("改属性前先 get_window_prop(path) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若属性在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), n.push("不确定可操作哪些属性时用 list_window_props 查看(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);不确定某属性字段结构时用 describe_window_prop。"), n.push("修改大对象/数组属性优先用 edit_window_prop 增量 patch(只发改动部分),避免 set 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改属性出错时可用 restore_window_snapshot(path) 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_window_prop(JSONPath,如 $[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_window_prop 改。"), n.push("找名字记不清的元素用 search_window_prop(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_window_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。")), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
16426
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= jv || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), r = e.subagents.filter((e) => (e.temperature ?? 0) < jv && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16305
16427
|
n.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (n.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), n.push(" 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。")), r.length && n.push(` · 严谨/易错/校验类 → 可先调 ${r.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), n.push(" · 方案定稿后,由你(主 agent)用 edit_window_prop 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), n.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16306
16428
|
}
|
|
16307
|
-
return e?.humanConfirm && (n.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), n.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), n.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), n.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), n.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。")), n.length ? "## 能力使用提示\n" + n.join("\n") : void 0;
|
|
16429
|
+
return e?.humanConfirm && (n.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), n.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), n.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), n.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), n.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。")), n.length && n.unshift("调用工具务必用标准 function calling(工具调用)格式发起,不要在回复正文里输出伪 XML/标签(如 deepseek 的 tool_calls 标签、invoke、function_call、tool_call 等)或 JSON 文本——那不会被识别为工具调用,会被当普通文字,工具不执行。"), n.length ? "## 能力使用提示\n" + n.join("\n") : void 0;
|
|
16308
16430
|
}
|
|
16309
16431
|
};
|
|
16310
16432
|
}
|
|
16311
16433
|
//#endregion
|
|
16312
16434
|
//#region src/core/utils/id.ts
|
|
16313
|
-
function
|
|
16435
|
+
function Nv() {
|
|
16314
16436
|
try {
|
|
16315
16437
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16316
16438
|
} catch {}
|
|
@@ -16318,57 +16440,57 @@ function xv() {
|
|
|
16318
16440
|
}
|
|
16319
16441
|
//#endregion
|
|
16320
16442
|
//#region src/core/backends/storage.ts
|
|
16321
|
-
var
|
|
16443
|
+
var Pv = "chat-sdk", Fv = 50 * 1024 * 1024, Iv = 4 * 1024 * 1024, Lv = 10 * 1024 * 1024, Rv = .9, zv = 500, Bv = 300, Vv = "__meta__", Hv = "v:1", Uv = [
|
|
16322
16444
|
"messages",
|
|
16323
16445
|
"vfs",
|
|
16324
16446
|
"todos",
|
|
16325
16447
|
"memory"
|
|
16326
16448
|
];
|
|
16327
|
-
function
|
|
16328
|
-
return e === "local" || e === "session" ?
|
|
16449
|
+
function Wv(e) {
|
|
16450
|
+
return e === "local" || e === "session" ? Iv : Fv;
|
|
16329
16451
|
}
|
|
16330
|
-
function
|
|
16452
|
+
function Gv(e) {
|
|
16331
16453
|
if (typeof e != "object" || !e) return !1;
|
|
16332
16454
|
let t = e;
|
|
16333
16455
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16334
16456
|
}
|
|
16335
|
-
function
|
|
16457
|
+
function Kv(e, t, n, r) {
|
|
16336
16458
|
return [
|
|
16337
|
-
|
|
16459
|
+
Hv,
|
|
16338
16460
|
e,
|
|
16339
16461
|
t,
|
|
16340
16462
|
n,
|
|
16341
16463
|
r
|
|
16342
16464
|
].join("::");
|
|
16343
16465
|
}
|
|
16344
|
-
function
|
|
16466
|
+
function qv(e, t, n) {
|
|
16345
16467
|
return [
|
|
16346
|
-
|
|
16468
|
+
Hv,
|
|
16347
16469
|
e,
|
|
16348
16470
|
t,
|
|
16349
16471
|
n
|
|
16350
16472
|
].join("::") + "::";
|
|
16351
16473
|
}
|
|
16352
|
-
function
|
|
16474
|
+
function Jv(e, t) {
|
|
16353
16475
|
return [
|
|
16354
|
-
|
|
16476
|
+
Hv,
|
|
16355
16477
|
e,
|
|
16356
16478
|
t
|
|
16357
16479
|
].join("::") + "::";
|
|
16358
16480
|
}
|
|
16359
|
-
function
|
|
16360
|
-
return [
|
|
16481
|
+
function Yv(e) {
|
|
16482
|
+
return [Hv, e].join("::") + "::";
|
|
16361
16483
|
}
|
|
16362
|
-
var
|
|
16363
|
-
function
|
|
16364
|
-
|
|
16484
|
+
var Xv = null;
|
|
16485
|
+
function Zv(e) {
|
|
16486
|
+
Xv ||= new TextEncoder();
|
|
16365
16487
|
try {
|
|
16366
|
-
return
|
|
16488
|
+
return Xv.encode(JSON.stringify(e)).length;
|
|
16367
16489
|
} catch {
|
|
16368
16490
|
return 0;
|
|
16369
16491
|
}
|
|
16370
16492
|
}
|
|
16371
|
-
function
|
|
16493
|
+
function Qv(e, t, n) {
|
|
16372
16494
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16373
16495
|
if (r <= t) return [];
|
|
16374
16496
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16378,7 +16500,7 @@ function Bv(e, t, n) {
|
|
|
16378
16500
|
}
|
|
16379
16501
|
return o;
|
|
16380
16502
|
}
|
|
16381
|
-
function
|
|
16503
|
+
function $v() {
|
|
16382
16504
|
let e = /* @__PURE__ */ new Map();
|
|
16383
16505
|
return {
|
|
16384
16506
|
async get(t) {
|
|
@@ -16398,7 +16520,7 @@ function Vv() {
|
|
|
16398
16520
|
}
|
|
16399
16521
|
};
|
|
16400
16522
|
}
|
|
16401
|
-
function
|
|
16523
|
+
function ey(e) {
|
|
16402
16524
|
return new Promise((t, n) => {
|
|
16403
16525
|
if (typeof indexedDB > "u") {
|
|
16404
16526
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -16459,7 +16581,7 @@ function Hv(e) {
|
|
|
16459
16581
|
}, r.onerror = () => n(r.error);
|
|
16460
16582
|
});
|
|
16461
16583
|
}
|
|
16462
|
-
function
|
|
16584
|
+
function ty(e) {
|
|
16463
16585
|
return {
|
|
16464
16586
|
async get(t) {
|
|
16465
16587
|
let n = e.getItem(t);
|
|
@@ -16493,12 +16615,12 @@ function Uv(e) {
|
|
|
16493
16615
|
}
|
|
16494
16616
|
};
|
|
16495
16617
|
}
|
|
16496
|
-
function
|
|
16618
|
+
function ny(e, t, n) {
|
|
16497
16619
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
16498
16620
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
16499
16621
|
}
|
|
16500
|
-
function
|
|
16501
|
-
let t = e.dbName ??
|
|
16622
|
+
function ry(e = {}) {
|
|
16623
|
+
let t = e.dbName ?? Pv, n = e.backend ?? "indexed", r = e.maxBytes ?? Wv(n), i = e.maxBytesPerSession ?? Lv, a = e.evictionWatermark ?? Rv, o = e.debounceMs ?? zv, s = /* @__PURE__ */ new Set();
|
|
16502
16624
|
function c(e) {
|
|
16503
16625
|
for (let t of s) try {
|
|
16504
16626
|
t(e);
|
|
@@ -16511,16 +16633,16 @@ function Gv(e = {}) {
|
|
|
16511
16633
|
try {
|
|
16512
16634
|
if (n === "indexed") {
|
|
16513
16635
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
16514
|
-
l = await
|
|
16636
|
+
l = await ey(t), d(!0);
|
|
16515
16637
|
} else if (n === "session") {
|
|
16516
16638
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
16517
|
-
l =
|
|
16639
|
+
l = ty(sessionStorage), d(!0);
|
|
16518
16640
|
} else if (n === "local") {
|
|
16519
16641
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
16520
|
-
l =
|
|
16521
|
-
} else l =
|
|
16642
|
+
l = ty(localStorage), d(!0);
|
|
16643
|
+
} else l = $v(), d(!1);
|
|
16522
16644
|
} catch (e) {
|
|
16523
|
-
l =
|
|
16645
|
+
l = $v();
|
|
16524
16646
|
let t = e instanceof Error ? e.message : String(e);
|
|
16525
16647
|
d(!1), Promise.resolve().then(() => c({
|
|
16526
16648
|
type: "degraded",
|
|
@@ -16530,10 +16652,10 @@ function Gv(e = {}) {
|
|
|
16530
16652
|
})();
|
|
16531
16653
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
16532
16654
|
function g(e, n, r, a) {
|
|
16533
|
-
let o =
|
|
16534
|
-
return
|
|
16655
|
+
let o = Kv(t, r, a, Vv);
|
|
16656
|
+
return ny(h, o, async () => {
|
|
16535
16657
|
let t = async () => {
|
|
16536
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16658
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : Zv(s), d = Zv(n), f = (t?.bytes ?? 0) + (d - u);
|
|
16537
16659
|
if (f > i) {
|
|
16538
16660
|
c({
|
|
16539
16661
|
type: "quota",
|
|
@@ -16555,12 +16677,12 @@ function Gv(e = {}) {
|
|
|
16555
16677
|
try {
|
|
16556
16678
|
await t();
|
|
16557
16679
|
} catch (e) {
|
|
16558
|
-
if (
|
|
16680
|
+
if (Gv(e) && !u) {
|
|
16559
16681
|
u = !0;
|
|
16560
16682
|
try {
|
|
16561
16683
|
await b();
|
|
16562
16684
|
} catch {}
|
|
16563
|
-
l =
|
|
16685
|
+
l = $v(), Promise.resolve().then(() => c({
|
|
16564
16686
|
type: "degraded",
|
|
16565
16687
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
16566
16688
|
}));
|
|
@@ -16572,7 +16694,7 @@ function Gv(e = {}) {
|
|
|
16572
16694
|
});
|
|
16573
16695
|
}
|
|
16574
16696
|
function _(e, n, r, i) {
|
|
16575
|
-
let a =
|
|
16697
|
+
let a = Kv(t, e, n, r), s = p.get(a);
|
|
16576
16698
|
s && s.resolve();
|
|
16577
16699
|
let c = m.get(a);
|
|
16578
16700
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16599,15 +16721,15 @@ function Gv(e = {}) {
|
|
|
16599
16721
|
function y() {
|
|
16600
16722
|
v ||= setTimeout(() => {
|
|
16601
16723
|
v = null, b();
|
|
16602
|
-
},
|
|
16724
|
+
}, Bv);
|
|
16603
16725
|
}
|
|
16604
16726
|
async function b() {
|
|
16605
16727
|
let e = [];
|
|
16606
|
-
await l.scan(
|
|
16728
|
+
await l.scan(Yv(t), (t, n) => {
|
|
16607
16729
|
t.endsWith("::__meta__") && e.push(n);
|
|
16608
16730
|
});
|
|
16609
|
-
let n =
|
|
16610
|
-
for (let e of n) await l.clearPrefix(
|
|
16731
|
+
let n = Qv(e, r, a);
|
|
16732
|
+
for (let e of n) await l.clearPrefix(qv(t, e.agentId, e.sessionId)), c({
|
|
16611
16733
|
type: "evicted",
|
|
16612
16734
|
agentId: e.agentId,
|
|
16613
16735
|
sessionId: e.sessionId,
|
|
@@ -16618,13 +16740,13 @@ function Gv(e = {}) {
|
|
|
16618
16740
|
ready: f,
|
|
16619
16741
|
async listSessions(e) {
|
|
16620
16742
|
let n = [];
|
|
16621
|
-
return await l.scan(
|
|
16743
|
+
return await l.scan(Jv(t, e), (e, t) => {
|
|
16622
16744
|
e.endsWith("::__meta__") && n.push(t);
|
|
16623
16745
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16624
16746
|
},
|
|
16625
16747
|
async load(e, n) {
|
|
16626
|
-
let r =
|
|
16627
|
-
return await
|
|
16748
|
+
let r = Kv(t, e, n, Vv);
|
|
16749
|
+
return await ny(h, r, async () => {
|
|
16628
16750
|
let i = await l.get(r);
|
|
16629
16751
|
if (!i) return;
|
|
16630
16752
|
let a = {
|
|
@@ -16633,8 +16755,8 @@ function Gv(e = {}) {
|
|
|
16633
16755
|
todos: [],
|
|
16634
16756
|
memory: ""
|
|
16635
16757
|
};
|
|
16636
|
-
for (let r of
|
|
16637
|
-
let i = await l.get(
|
|
16758
|
+
for (let r of Uv) {
|
|
16759
|
+
let i = await l.get(Kv(t, e, n, r));
|
|
16638
16760
|
i != null && (a[r] = i);
|
|
16639
16761
|
}
|
|
16640
16762
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16642,7 +16764,7 @@ function Gv(e = {}) {
|
|
|
16642
16764
|
},
|
|
16643
16765
|
async save(e, t, n) {
|
|
16644
16766
|
let r = [];
|
|
16645
|
-
for (let i of
|
|
16767
|
+
for (let i of Uv) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16646
16768
|
await Promise.all(r);
|
|
16647
16769
|
},
|
|
16648
16770
|
async flush() {
|
|
@@ -16656,10 +16778,10 @@ function Gv(e = {}) {
|
|
|
16656
16778
|
})), c({ type: "flush" }), await b();
|
|
16657
16779
|
},
|
|
16658
16780
|
async deleteSession(e, n) {
|
|
16659
|
-
await l.clearPrefix(
|
|
16781
|
+
await l.clearPrefix(qv(t, e, n));
|
|
16660
16782
|
},
|
|
16661
16783
|
async createSession(e, n, r) {
|
|
16662
|
-
let i = r ??
|
|
16784
|
+
let i = r ?? Nv(), a = Date.now(), o = {
|
|
16663
16785
|
agentId: e,
|
|
16664
16786
|
sessionId: i,
|
|
16665
16787
|
createdAt: a,
|
|
@@ -16667,7 +16789,7 @@ function Gv(e = {}) {
|
|
|
16667
16789
|
bytes: 0,
|
|
16668
16790
|
title: n
|
|
16669
16791
|
};
|
|
16670
|
-
return await l.set(
|
|
16792
|
+
return await l.set(Kv(t, e, i, Vv), o), i;
|
|
16671
16793
|
},
|
|
16672
16794
|
onEvent(e) {
|
|
16673
16795
|
s.add(e);
|
|
@@ -16682,28 +16804,28 @@ function Gv(e = {}) {
|
|
|
16682
16804
|
}
|
|
16683
16805
|
//#endregion
|
|
16684
16806
|
//#region src/core/sdk/createChatSdk.ts
|
|
16685
|
-
var
|
|
16807
|
+
var iy = [
|
|
16686
16808
|
"你是一个页面操作助手。宿主页面在 window 对象上注册了可操作的属性,你通过专用工具安全地读写这些属性来操作页面。",
|
|
16687
16809
|
"所有写操作都经范围控制(仅注册表内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
16688
16810
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
16689
|
-
|
|
16690
|
-
].join("\n\n"),
|
|
16691
|
-
function
|
|
16692
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ?
|
|
16811
|
+
I_.reliableWriteRules
|
|
16812
|
+
].join("\n\n"), ay = 50;
|
|
16813
|
+
function oy(e) {
|
|
16814
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? ry({ backend: e }) : e.enabled === !1 ? null : ry(e);
|
|
16693
16815
|
}
|
|
16694
|
-
function
|
|
16816
|
+
function sy(e) {
|
|
16695
16817
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
16696
16818
|
}
|
|
16697
|
-
var
|
|
16698
|
-
function
|
|
16819
|
+
var cy = /* @__PURE__ */ new Map();
|
|
16820
|
+
function ly(e) {
|
|
16699
16821
|
let t = e.content;
|
|
16700
16822
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
16701
16823
|
}
|
|
16702
|
-
function
|
|
16824
|
+
function uy(e) {
|
|
16703
16825
|
let t = e.summaryLlm ?? e.llm;
|
|
16704
16826
|
if (!t) return;
|
|
16705
16827
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
16706
|
-
if (
|
|
16828
|
+
if (sy(t)) c = t;
|
|
16707
16829
|
else {
|
|
16708
16830
|
let i = t;
|
|
16709
16831
|
if (!i.apiKey) {
|
|
@@ -16721,16 +16843,16 @@ function Qv(e) {
|
|
|
16721
16843
|
return async (e) => {
|
|
16722
16844
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
16723
16845
|
try {
|
|
16724
|
-
return
|
|
16846
|
+
return ly(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
16725
16847
|
} finally {
|
|
16726
16848
|
clearTimeout(n);
|
|
16727
16849
|
}
|
|
16728
16850
|
};
|
|
16729
16851
|
}
|
|
16730
|
-
function
|
|
16852
|
+
function dy(e) {
|
|
16731
16853
|
return e === "set_window_prop" ? "set" : e === "edit_window_prop" ? "edit" : e === "delete_window_prop" ? "delete" : e === "restore_window_snapshot" ? "restore" : null;
|
|
16732
16854
|
}
|
|
16733
|
-
function
|
|
16855
|
+
function fy(e) {
|
|
16734
16856
|
let t = e.split("."), n = globalThis.window;
|
|
16735
16857
|
for (let e of t) {
|
|
16736
16858
|
if (n == null) return;
|
|
@@ -16738,18 +16860,18 @@ function ey(e) {
|
|
|
16738
16860
|
}
|
|
16739
16861
|
return n;
|
|
16740
16862
|
}
|
|
16741
|
-
function
|
|
16863
|
+
function py(e, t) {
|
|
16742
16864
|
return {
|
|
16743
16865
|
name: "sdk-events",
|
|
16744
16866
|
wrapToolCall: async (t, n) => {
|
|
16745
|
-
let r = await n(t), i =
|
|
16867
|
+
let r = await n(t), i = dy(t.name);
|
|
16746
16868
|
if (i) {
|
|
16747
16869
|
let n = String(t.args?.path ?? "");
|
|
16748
16870
|
e({
|
|
16749
16871
|
type: "window_prop_change",
|
|
16750
16872
|
path: n,
|
|
16751
16873
|
operation: i,
|
|
16752
|
-
value: n ?
|
|
16874
|
+
value: n ? fy(n) : void 0
|
|
16753
16875
|
});
|
|
16754
16876
|
}
|
|
16755
16877
|
return r;
|
|
@@ -16762,271 +16884,296 @@ function ty(e, t) {
|
|
|
16762
16884
|
}
|
|
16763
16885
|
};
|
|
16764
16886
|
}
|
|
16765
|
-
function
|
|
16766
|
-
let i =
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
|
|
16771
|
-
|
|
16887
|
+
function my(e, r) {
|
|
16888
|
+
let i = /* @__PURE__ */ fn(null), a = 0;
|
|
16889
|
+
function o(e) {
|
|
16890
|
+
return new Promise((t) => {
|
|
16891
|
+
let n = {
|
|
16892
|
+
...e,
|
|
16893
|
+
id: ++a,
|
|
16894
|
+
resolve: t
|
|
16895
|
+
};
|
|
16896
|
+
i.value = n, z({
|
|
16897
|
+
type: "conflict",
|
|
16898
|
+
conflict: n
|
|
16899
|
+
});
|
|
16900
|
+
});
|
|
16901
|
+
}
|
|
16902
|
+
function s(e) {
|
|
16903
|
+
let t = i.value;
|
|
16904
|
+
t && (i.value = null, t.resolve({ action: e }));
|
|
16905
|
+
}
|
|
16906
|
+
let c = oy(e.storage);
|
|
16907
|
+
e.debug && c && c.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
16908
|
+
let l = sy(e.llm) ? void 0 : e.llm, u = eg({
|
|
16909
|
+
model: l?.model,
|
|
16910
|
+
contextWindow: e.contextWindow ?? l?.contextWindow,
|
|
16911
|
+
maxOutputTokens: e.maxOutputTokens ?? l?.maxOutputTokens
|
|
16772
16912
|
});
|
|
16773
|
-
e.debug && console.log("[page-agent-sdk][modelCaps]",
|
|
16774
|
-
let
|
|
16775
|
-
e.debug && !
|
|
16776
|
-
let
|
|
16777
|
-
persist:
|
|
16778
|
-
B.sessionId &&
|
|
16913
|
+
e.debug && console.log("[page-agent-sdk][modelCaps]", u);
|
|
16914
|
+
let d = uy(e);
|
|
16915
|
+
e.debug && !d && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
16916
|
+
let f = /* @__PURE__ */ Qt([]), p = U_(e.vfs?.initialFiles, {
|
|
16917
|
+
persist: c ? { save: (e) => {
|
|
16918
|
+
B.sessionId && c && c.save(r, B.sessionId, { vfs: e });
|
|
16779
16919
|
} } : void 0,
|
|
16780
16920
|
maxBytes: e.vfs?.maxBytes
|
|
16781
|
-
}),
|
|
16921
|
+
}), m = bg(), h = Og(e.memory || ""), g = { current: null }, _ = e.checkpoint, v = _ !== void 0 && _ !== !1, y = v ? Gg({
|
|
16782
16922
|
windowPaths: (e.windowProps ?? []).map((e) => e.path),
|
|
16783
|
-
vfsStore:
|
|
16784
|
-
todosMw:
|
|
16785
|
-
getTodos: () =>
|
|
16786
|
-
messages:
|
|
16787
|
-
maxCheckpoints:
|
|
16788
|
-
}) : null,
|
|
16923
|
+
vfsStore: p,
|
|
16924
|
+
todosMw: m,
|
|
16925
|
+
getTodos: () => g.current?.getState?.()?.todos ?? [],
|
|
16926
|
+
messages: f,
|
|
16927
|
+
maxCheckpoints: _ && typeof _ == "object" ? _.maxCheckpoints : void 0
|
|
16928
|
+
}) : null, b = !_ || typeof _ != "object" || _.auto !== !1, x = e.capabilities, S = x?.windowOps !== !1, C = S ? Tv(e.windowProps || [], {
|
|
16789
16929
|
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][window audit]", e) : void 0,
|
|
16790
|
-
maxSnapshots: e.maxSnapshots
|
|
16791
|
-
|
|
16792
|
-
C.
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16930
|
+
maxSnapshots: e.maxSnapshots,
|
|
16931
|
+
onConflict: o
|
|
16932
|
+
}) : [], w = S ? C.controller ?? null : null, T = () => w?.list() ?? e.windowProps ?? [], E = /* @__PURE__ */ new Map(), D = Av(x, C, Dv);
|
|
16933
|
+
D.forEach((e) => E.set(e.name, "builtin"));
|
|
16934
|
+
let O = [...e.tools || []];
|
|
16935
|
+
O.forEach((e) => E.set(e.name, "user"));
|
|
16936
|
+
let k = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), A = k ? Lg() : null;
|
|
16937
|
+
A && E.set(Fg, "builtin");
|
|
16938
|
+
let j = v && y ? [n(async () => {
|
|
16939
|
+
let e = y.list();
|
|
16940
|
+
return e.length ? y.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、window 注册属性、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
16800
16941
|
}, {
|
|
16801
16942
|
name: "restore_last_checkpoint",
|
|
16802
16943
|
description: "回退到最近一次正常状态(整体还原对话历史 + window 注册属性 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
16803
16944
|
schema: t.object({}).optional()
|
|
16804
16945
|
}), n(async () => {
|
|
16805
|
-
let e =
|
|
16946
|
+
let e = y.list();
|
|
16806
16947
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
|
|
16807
16948
|
}, {
|
|
16808
16949
|
name: "list_checkpoints",
|
|
16809
16950
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
16810
16951
|
schema: t.object({}).optional()
|
|
16811
16952
|
})] : [];
|
|
16812
|
-
|
|
16813
|
-
let
|
|
16814
|
-
...
|
|
16815
|
-
...
|
|
16816
|
-
...
|
|
16817
|
-
...
|
|
16818
|
-
],
|
|
16819
|
-
e.verify?.check &&
|
|
16820
|
-
let
|
|
16821
|
-
llm:
|
|
16822
|
-
allTools:
|
|
16823
|
-
allowedTools:
|
|
16824
|
-
systemPrompt:
|
|
16825
|
-
temperature:
|
|
16826
|
-
maxTokens:
|
|
16827
|
-
skills:
|
|
16828
|
-
maxDepth:
|
|
16829
|
-
maxParallel:
|
|
16953
|
+
j.forEach((e) => E.set(e.name, "builtin"));
|
|
16954
|
+
let M = [
|
|
16955
|
+
...D,
|
|
16956
|
+
...O,
|
|
16957
|
+
...A ? [A] : [],
|
|
16958
|
+
...j
|
|
16959
|
+
], N = x?.planning !== !1, P = x?.skills !== !1, F = x?.vfs !== !1, I = x?.summarization !== !1, L = x?.memory !== !1, ee = x?.subagent !== !1, R = e.verify?.maxAttempts ?? 2, te = x?.verify === !0 && e.verify?.enabled !== !1 && R > 0;
|
|
16960
|
+
e.verify?.check && x?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
16961
|
+
let ne = e.subagent, re = ne?.allowedTools ?? [], ie = !ee || ne?.enabled === !1 ? void 0 : e_({
|
|
16962
|
+
llm: ne?.llm ?? e.llm,
|
|
16963
|
+
allTools: M,
|
|
16964
|
+
allowedTools: re.length ? re : void 0,
|
|
16965
|
+
systemPrompt: ne?.systemPrompt,
|
|
16966
|
+
temperature: ne?.temperature,
|
|
16967
|
+
maxTokens: ne?.maxTokens,
|
|
16968
|
+
skills: ne?.skills,
|
|
16969
|
+
maxDepth: ne?.maxDepth,
|
|
16970
|
+
maxParallel: ne?.maxParallel,
|
|
16830
16971
|
debug: e.debug
|
|
16831
|
-
}),
|
|
16972
|
+
}), ae = e.subagents?.length ? r_(e.subagents, {
|
|
16832
16973
|
llm: e.llm,
|
|
16833
|
-
allTools:
|
|
16974
|
+
allTools: M,
|
|
16834
16975
|
debug: e.debug
|
|
16835
|
-
}) : void 0,
|
|
16976
|
+
}) : void 0, oe = [
|
|
16836
16977
|
"get_window_prop",
|
|
16837
16978
|
"get_window_paths",
|
|
16838
16979
|
"list_window_props",
|
|
16839
16980
|
"describe_window_prop",
|
|
16840
16981
|
"fetch_document"
|
|
16841
|
-
],
|
|
16842
|
-
check: e.verify.check ??
|
|
16982
|
+
], se = M.filter((e) => oe.includes(e.name)), ce = te ? i_({
|
|
16983
|
+
check: e.verify.check ?? u_({ schemas: () => Object.fromEntries(T().map((e) => [e.path, e.schema])) }),
|
|
16843
16984
|
adversarial: e.verify?.adversarial ? {
|
|
16844
16985
|
llm: e.llm,
|
|
16845
|
-
tools:
|
|
16986
|
+
tools: se
|
|
16846
16987
|
} : void 0
|
|
16847
|
-
}) : void 0,
|
|
16848
|
-
...
|
|
16849
|
-
humanConfirm:
|
|
16988
|
+
}) : void 0, le = Mv({
|
|
16989
|
+
...x,
|
|
16990
|
+
humanConfirm: k,
|
|
16850
16991
|
subagents: e.subagents?.map((e) => ({
|
|
16851
16992
|
id: e.id,
|
|
16852
16993
|
description: e.description,
|
|
16853
16994
|
temperature: e.temperature
|
|
16854
16995
|
}))
|
|
16855
|
-
},
|
|
16996
|
+
}, S && !!e.windowProps?.length), ue = e.onEvent, de = /* @__PURE__ */ new Set(), z = (e) => {
|
|
16856
16997
|
if (e.type !== "approval_request") {
|
|
16857
|
-
if (
|
|
16858
|
-
|
|
16998
|
+
if (ue) try {
|
|
16999
|
+
ue(e);
|
|
16859
17000
|
} catch {}
|
|
16860
|
-
for (let t of
|
|
17001
|
+
for (let t of de) try {
|
|
16861
17002
|
t(e);
|
|
16862
17003
|
} catch {}
|
|
16863
17004
|
}
|
|
16864
|
-
},
|
|
16865
|
-
|
|
16866
|
-
...
|
|
16867
|
-
...
|
|
16868
|
-
...
|
|
16869
|
-
...
|
|
16870
|
-
...
|
|
16871
|
-
llmInvoke:
|
|
16872
|
-
getRegisteredProps: () =>
|
|
17005
|
+
}, fe = [
|
|
17006
|
+
le,
|
|
17007
|
+
...N ? [m] : [],
|
|
17008
|
+
...P ? [Dg(e.skills || [], { readVfs: F ? (e) => p.files[e]?.content : void 0 })] : [],
|
|
17009
|
+
...F ? [X_(p)] : [],
|
|
17010
|
+
...I ? [P_({
|
|
17011
|
+
...R_(e, u.contextWindow),
|
|
17012
|
+
llmInvoke: d,
|
|
17013
|
+
getRegisteredProps: () => T().map((e) => ({
|
|
16873
17014
|
path: e.path,
|
|
16874
17015
|
description: e.description
|
|
16875
17016
|
})),
|
|
16876
17017
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_window_prop", "list_window_props"]
|
|
16877
17018
|
})] : [],
|
|
16878
|
-
...
|
|
16879
|
-
...e.permissions?.length ? [
|
|
16880
|
-
...
|
|
16881
|
-
...
|
|
16882
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
17019
|
+
...L ? [h] : [],
|
|
17020
|
+
...e.permissions?.length ? [Ng(e.permissions)] : [],
|
|
17021
|
+
...v && b && y ? [Kg(y)] : [],
|
|
17022
|
+
...k ? [Rg()] : [],
|
|
17023
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [Pg(e.approval)] : [],
|
|
17024
|
+
...ce ? [ce] : [],
|
|
16883
17025
|
...ie ? [ie] : [],
|
|
16884
|
-
...
|
|
16885
|
-
...te ? [te] : [],
|
|
17026
|
+
...ae ? [ae] : [],
|
|
16886
17027
|
...e.middleware || [],
|
|
16887
|
-
|
|
16888
|
-
],
|
|
17028
|
+
py(z, f)
|
|
17029
|
+
], pe = e.maxMemoryRounds ?? ay, B = {
|
|
16889
17030
|
agentId: r,
|
|
16890
|
-
store:
|
|
16891
|
-
messages:
|
|
16892
|
-
vfsStore:
|
|
16893
|
-
listeners:
|
|
16894
|
-
todosMw:
|
|
16895
|
-
memoryMw:
|
|
17031
|
+
store: c,
|
|
17032
|
+
messages: f,
|
|
17033
|
+
vfsStore: p,
|
|
17034
|
+
listeners: de,
|
|
17035
|
+
todosMw: m,
|
|
17036
|
+
memoryMw: h,
|
|
16896
17037
|
agent: null,
|
|
16897
17038
|
initDone: Promise.resolve(),
|
|
16898
17039
|
sessionId: "",
|
|
16899
17040
|
refCount: 0,
|
|
16900
17041
|
mcpClosers: [],
|
|
16901
17042
|
mcpServers: [],
|
|
16902
|
-
checkpoint:
|
|
16903
|
-
windowOpsController:
|
|
16904
|
-
|
|
17043
|
+
checkpoint: y,
|
|
17044
|
+
windowOpsController: w,
|
|
17045
|
+
pendingConflict: i,
|
|
17046
|
+
liveWindowProps: T,
|
|
16905
17047
|
applySnapshot(t) {
|
|
16906
|
-
t.messages?.length &&
|
|
17048
|
+
t.messages?.length && f.push(...t.messages), t.vfs && p.hydrate && p.hydrate(t.vfs), t.todos?.length && m.reset(t.todos), t.memory && !e.memory && h.reset(t.memory);
|
|
16907
17049
|
},
|
|
16908
17050
|
afterRound() {
|
|
16909
|
-
|
|
17051
|
+
he(), ge();
|
|
16910
17052
|
},
|
|
16911
17053
|
async send(e) {
|
|
16912
|
-
await B.initDone,
|
|
17054
|
+
await B.initDone, f.push({
|
|
16913
17055
|
role: "user",
|
|
16914
17056
|
content: e,
|
|
16915
17057
|
timestamp: Date.now()
|
|
16916
17058
|
});
|
|
16917
17059
|
try {
|
|
16918
|
-
let e = await B.agent.invoke(
|
|
16919
|
-
return
|
|
17060
|
+
let e = await B.agent.invoke(f);
|
|
17061
|
+
return f.push({
|
|
16920
17062
|
role: "assistant",
|
|
16921
17063
|
content: e,
|
|
16922
17064
|
timestamp: Date.now()
|
|
16923
|
-
}), B.afterRound(),
|
|
17065
|
+
}), B.afterRound(), c && await c.flush(), e;
|
|
16924
17066
|
} catch (e) {
|
|
16925
|
-
throw
|
|
17067
|
+
throw z({
|
|
16926
17068
|
type: "error",
|
|
16927
17069
|
message: e?.message || String(e)
|
|
16928
17070
|
}), e;
|
|
16929
17071
|
}
|
|
16930
17072
|
},
|
|
16931
17073
|
async switchSession(t) {
|
|
16932
|
-
if (await B.initDone, !
|
|
16933
|
-
|
|
16934
|
-
let n = t ?? "",
|
|
16935
|
-
return n ? (
|
|
17074
|
+
if (await B.initDone, !c) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
|
|
17075
|
+
s("keep_external"), p.flush?.(), await c.flush();
|
|
17076
|
+
let n = t ?? "", i;
|
|
17077
|
+
return n ? (i = await c.load(r, n), i || await c.createSession(r, e.session?.title, n)) : n = await c.createSession(r, e.session?.title), B.sessionId = n, f.splice(0, f.length), p.clear?.(), m.reset([]), e.memory || h.reset(""), B.agent.debugLogs.value = [], i ||= await c.load(r, n), i && B.applySnapshot(i), e.memory && c.save(r, B.sessionId, { memory: e.memory }), n;
|
|
16936
17078
|
},
|
|
16937
17079
|
stream: (e, t, n) => {
|
|
16938
17080
|
if (!B.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
16939
|
-
let r =
|
|
16940
|
-
t?.(e),
|
|
17081
|
+
let r = ue ? (e) => {
|
|
17082
|
+
t?.(e), z(e);
|
|
16941
17083
|
} : t;
|
|
17084
|
+
if (n) {
|
|
17085
|
+
let e = () => s("keep_external");
|
|
17086
|
+
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
17087
|
+
}
|
|
16942
17088
|
return B.agent.stream(e, r, n);
|
|
16943
17089
|
},
|
|
16944
17090
|
release() {
|
|
16945
17091
|
if (B.refCount--, B.refCount <= 0) {
|
|
16946
|
-
|
|
17092
|
+
c && (p.flush?.(), c.flush(), c.dispose());
|
|
16947
17093
|
let e = B.mcpClosers.splice(0);
|
|
16948
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
17094
|
+
e.length && Promise.allSettled(e.map((e) => e())), cy.delete(r);
|
|
16949
17095
|
}
|
|
16950
17096
|
},
|
|
17097
|
+
resolveConflict: s,
|
|
16951
17098
|
getInfo() {
|
|
16952
17099
|
return {
|
|
16953
17100
|
id: r,
|
|
16954
|
-
model:
|
|
16955
|
-
systemPrompt: e.systemPrompt ??
|
|
16956
|
-
tools:
|
|
17101
|
+
model: sy(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17102
|
+
systemPrompt: e.systemPrompt ?? iy,
|
|
17103
|
+
tools: M.map((e) => ({
|
|
16957
17104
|
name: e.name,
|
|
16958
17105
|
description: e.description,
|
|
16959
17106
|
schema: e.schema,
|
|
16960
|
-
source:
|
|
17107
|
+
source: E.get(e.name) || "user"
|
|
16961
17108
|
})),
|
|
16962
17109
|
skills: (e.skills ?? []).map((e) => ({
|
|
16963
17110
|
name: e.name,
|
|
16964
17111
|
description: e.description
|
|
16965
17112
|
})),
|
|
16966
|
-
windowProps:
|
|
17113
|
+
windowProps: T().map((e) => ({
|
|
16967
17114
|
path: e.path,
|
|
16968
17115
|
description: e.description,
|
|
16969
17116
|
schema: e.schema
|
|
16970
17117
|
})),
|
|
16971
17118
|
memory: e.memory ?? "",
|
|
16972
|
-
middleware:
|
|
17119
|
+
middleware: fe.map((e) => e.name),
|
|
16973
17120
|
todos: (B.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
16974
17121
|
content: e.content,
|
|
16975
17122
|
status: e.status
|
|
16976
17123
|
})),
|
|
16977
17124
|
subagent: {
|
|
16978
|
-
enabled: !!
|
|
17125
|
+
enabled: !!ie,
|
|
16979
17126
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
16980
17127
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
16981
17128
|
allowedTools: e.subagent?.allowedTools ?? []
|
|
16982
17129
|
},
|
|
16983
17130
|
verify: {
|
|
16984
|
-
enabled: !!
|
|
16985
|
-
maxAttempts:
|
|
16986
|
-
adversarial:
|
|
17131
|
+
enabled: !!ce,
|
|
17132
|
+
maxAttempts: te ? R : 0,
|
|
17133
|
+
adversarial: te && !!e.verify?.adversarial
|
|
16987
17134
|
},
|
|
16988
17135
|
mcp: { servers: B.mcpServers },
|
|
16989
17136
|
lastCompression: B.agent?.getState?.()?.lastCompression,
|
|
16990
|
-
checkpoints:
|
|
17137
|
+
checkpoints: y ? {
|
|
16991
17138
|
enabled: !0,
|
|
16992
|
-
auto:
|
|
16993
|
-
list:
|
|
17139
|
+
auto: b,
|
|
17140
|
+
list: y.list()
|
|
16994
17141
|
} : void 0
|
|
16995
17142
|
};
|
|
16996
17143
|
}
|
|
16997
17144
|
};
|
|
16998
|
-
async function
|
|
16999
|
-
if (!
|
|
17000
|
-
await
|
|
17145
|
+
async function me() {
|
|
17146
|
+
if (!c) return;
|
|
17147
|
+
await c.ready;
|
|
17001
17148
|
let t = e.session || {};
|
|
17002
17149
|
if (t.id) {
|
|
17003
17150
|
B.sessionId = t.id;
|
|
17004
|
-
let e = await
|
|
17005
|
-
e ? B.applySnapshot(e) : await
|
|
17151
|
+
let e = await c.load(r, B.sessionId);
|
|
17152
|
+
e ? B.applySnapshot(e) : await c.createSession(r, t.title, B.sessionId);
|
|
17006
17153
|
} else if (t.autoResume !== !1) {
|
|
17007
|
-
let n = await
|
|
17154
|
+
let n = await c.listSessions(r);
|
|
17008
17155
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", r, n.length, n.map((e) => e.sessionId)), n.length) {
|
|
17009
17156
|
B.sessionId = n[0].sessionId;
|
|
17010
|
-
let t = await
|
|
17157
|
+
let t = await c.load(r, B.sessionId);
|
|
17011
17158
|
t ? (B.applySnapshot(t), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", B.sessionId, `${t.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", B.sessionId);
|
|
17012
|
-
} else B.sessionId = await
|
|
17013
|
-
} else B.sessionId = await
|
|
17014
|
-
e.memory &&
|
|
17015
|
-
}
|
|
17016
|
-
function
|
|
17017
|
-
let e =
|
|
17018
|
-
e.trimmed &&
|
|
17019
|
-
}
|
|
17020
|
-
function
|
|
17021
|
-
if (!B.sessionId || !
|
|
17022
|
-
let t = JSON.parse(JSON.stringify(
|
|
17023
|
-
|
|
17159
|
+
} else B.sessionId = await c.createSession(r, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", B.sessionId);
|
|
17160
|
+
} else B.sessionId = await c.createSession(r, t.title);
|
|
17161
|
+
e.memory && c.save(r, B.sessionId, { memory: e.memory });
|
|
17162
|
+
}
|
|
17163
|
+
function he() {
|
|
17164
|
+
let e = w_(f, pe);
|
|
17165
|
+
e.trimmed && f.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17166
|
+
}
|
|
17167
|
+
function ge() {
|
|
17168
|
+
if (!B.sessionId || !c) return;
|
|
17169
|
+
let t = JSON.parse(JSON.stringify(f));
|
|
17170
|
+
c.save(r, B.sessionId, { messages: t });
|
|
17024
17171
|
let n = B.agent?.getState?.()?.todos ?? [];
|
|
17025
|
-
|
|
17172
|
+
c.save(r, B.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", B.sessionId, `${f.length} msgs`);
|
|
17026
17173
|
}
|
|
17027
17174
|
return B.initDone = (async () => {
|
|
17028
|
-
if (await
|
|
17029
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
17175
|
+
if (await me(), e.mcp?.length) {
|
|
17176
|
+
let t = await Promise.allSettled(e.mcp.map((e) => b_(e)));
|
|
17030
17177
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
17031
17178
|
let n = [];
|
|
17032
17179
|
t.forEach((t, r) => {
|
|
@@ -17035,35 +17182,35 @@ function ny(e, r) {
|
|
|
17035
17182
|
name: a,
|
|
17036
17183
|
url: i.url,
|
|
17037
17184
|
toolCount: t.value.tools.length
|
|
17038
|
-
}), t.value.tools.forEach((e) =>
|
|
17039
|
-
}),
|
|
17185
|
+
}), t.value.tools.forEach((e) => E.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17186
|
+
}), M.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
17040
17187
|
}
|
|
17041
|
-
B.agent =
|
|
17042
|
-
...
|
|
17188
|
+
B.agent = vg({
|
|
17189
|
+
...sy(e.llm) ? { llm: e.llm } : {
|
|
17043
17190
|
apiKey: e.llm.apiKey,
|
|
17044
17191
|
baseUrl: e.llm.baseUrl,
|
|
17045
17192
|
model: e.llm.model,
|
|
17046
17193
|
temperature: e.llm.temperature,
|
|
17047
17194
|
maxTokens: e.llm.maxTokens
|
|
17048
17195
|
},
|
|
17049
|
-
systemPrompt: e.systemPrompt ??
|
|
17050
|
-
tools:
|
|
17051
|
-
middleware:
|
|
17196
|
+
systemPrompt: e.systemPrompt ?? iy,
|
|
17197
|
+
tools: M,
|
|
17198
|
+
middleware: fe,
|
|
17052
17199
|
maxToolRounds: e.maxToolRounds,
|
|
17053
17200
|
maxRetries: e.maxRetries,
|
|
17054
17201
|
maxParallelTools: e.maxParallelTools,
|
|
17055
|
-
contextWindow:
|
|
17056
|
-
maxOutputTokens:
|
|
17057
|
-
maxVerifyAttempts:
|
|
17202
|
+
contextWindow: u.contextWindow,
|
|
17203
|
+
maxOutputTokens: u.maxOutputTokens,
|
|
17204
|
+
maxVerifyAttempts: te ? R : 0,
|
|
17058
17205
|
debug: e.debug
|
|
17059
|
-
}),
|
|
17206
|
+
}), g.current = B.agent;
|
|
17060
17207
|
})(), B;
|
|
17061
17208
|
}
|
|
17062
|
-
function
|
|
17063
|
-
let t = e.id ??
|
|
17209
|
+
function hy(e) {
|
|
17210
|
+
let t = e.id ?? Nv();
|
|
17064
17211
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
17065
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
17066
|
-
a ? i = a : (i =
|
|
17212
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? cy.get(t) : void 0;
|
|
17213
|
+
a ? i = a : (i = my(e, t), e.shareContext && cy.set(t, i)), i.refCount++;
|
|
17067
17214
|
let o = null, s = null, c = null;
|
|
17068
17215
|
async function l() {
|
|
17069
17216
|
if (await i.initDone, r === !1) {
|
|
@@ -17078,9 +17225,15 @@ function ry(e) {
|
|
|
17078
17225
|
if (!t) throw Error(`createChatSdk: 挂载点未找到(${e.container})`);
|
|
17079
17226
|
let a = i.agent.debugLogs;
|
|
17080
17227
|
o = ul(/* @__PURE__ */ wi({ setup() {
|
|
17081
|
-
return () => Bs(
|
|
17228
|
+
return () => Bs(Jh, {
|
|
17082
17229
|
fetchStream: n ? i.agent.stream : void 0,
|
|
17083
|
-
fetchResponse: n ? void 0 : (e, t) =>
|
|
17230
|
+
fetchResponse: n ? void 0 : (e, t) => {
|
|
17231
|
+
if (t) {
|
|
17232
|
+
let e = () => i.resolveConflict("keep_external");
|
|
17233
|
+
t.aborted ? e() : t.addEventListener("abort", e, { once: !0 });
|
|
17234
|
+
}
|
|
17235
|
+
return i.agent.invoke(e, t);
|
|
17236
|
+
},
|
|
17084
17237
|
title: e.title,
|
|
17085
17238
|
placeholder: e.placeholder,
|
|
17086
17239
|
debugLogs: a.value,
|
|
@@ -17092,8 +17245,10 @@ function ry(e) {
|
|
|
17092
17245
|
i.afterRound(), i.store && await i.store.flush();
|
|
17093
17246
|
},
|
|
17094
17247
|
onClear: () => {
|
|
17095
|
-
i.store && (i.sessionId =
|
|
17096
|
-
}
|
|
17248
|
+
i.store && (i.sessionId = Nv(), i.vfsStore.clear?.(), i.todosMw.reset([]), e.memory || i.memoryMw.reset(""), i.agent.debugLogs.value = [], i.store.createSession(i.agentId, e.session?.title, i.sessionId));
|
|
17249
|
+
},
|
|
17250
|
+
pendingConflict: i.pendingConflict.value,
|
|
17251
|
+
onResolveConflict: (e) => i.resolveConflict(e)
|
|
17097
17252
|
});
|
|
17098
17253
|
} })), o.mount(t), i.store && (s = () => {
|
|
17099
17254
|
i.vfsStore.flush?.(), i.store.flush();
|
|
@@ -17102,7 +17257,7 @@ function ry(e) {
|
|
|
17102
17257
|
}, typeof window < "u" && window.addEventListener("pagehide", s), typeof document < "u" && document.addEventListener("visibilitychange", c));
|
|
17103
17258
|
}
|
|
17104
17259
|
function u() {
|
|
17105
|
-
s && typeof window < "u" && window.removeEventListener("pagehide", s), c && typeof document < "u" && document.removeEventListener("visibilitychange", c), s = null, c = null, o?.unmount(), o = null, i.release();
|
|
17260
|
+
i.resolveConflict("keep_external"), s && typeof window < "u" && window.removeEventListener("pagehide", s), c && typeof document < "u" && document.removeEventListener("visibilitychange", c), s = null, c = null, o?.unmount(), o = null, i.release();
|
|
17106
17261
|
}
|
|
17107
17262
|
return {
|
|
17108
17263
|
mount: l,
|
|
@@ -17123,12 +17278,14 @@ function ry(e) {
|
|
|
17123
17278
|
i.windowOpsController.add(e);
|
|
17124
17279
|
},
|
|
17125
17280
|
removeWindowProp: (e) => i.windowOpsController ? i.windowOpsController.remove(e) : !1,
|
|
17126
|
-
listWindowProps: () => i.liveWindowProps()
|
|
17281
|
+
listWindowProps: () => i.liveWindowProps(),
|
|
17282
|
+
pendingConflict: i.pendingConflict,
|
|
17283
|
+
resolveConflict: (e) => i.resolveConflict(e)
|
|
17127
17284
|
};
|
|
17128
17285
|
}
|
|
17129
17286
|
//#endregion
|
|
17130
17287
|
//#region src/core/sdk/defineTool.ts
|
|
17131
|
-
function
|
|
17288
|
+
function gy(e) {
|
|
17132
17289
|
return n(async (t) => {
|
|
17133
17290
|
let n = await e.handler(t);
|
|
17134
17291
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17139,4 +17296,4 @@ function iy(e) {
|
|
|
17139
17296
|
});
|
|
17140
17297
|
}
|
|
17141
17298
|
//#endregion
|
|
17142
|
-
export {
|
|
17299
|
+
export { L_ as CONTEXT_PRESETS, Jh as ChatDialog, Qd as CodePreview, Fg as HUMAN_CONFIRM_TOOL_NAME, ef as MessageContent, b_ as connectMcp, vg as createAgent, Pg as createApprovalMiddleware, hy as createChatSdk, Gg as createCheckpointManager, Kg as createCheckpointMiddleware, Rg as createHumanConfirmMiddleware, Lg as createHumanConfirmTool, $v as createMemoryBackend, ry as createSessionStore, e_ as createSubagentMiddleware, r_ as createSubagentsMiddleware, Mv as createUsageHintsMiddleware, i_ as createVerifyMiddleware, U_ as createVfs, ty as createWebStorageBackend, Tv as createWindowOps, u_ as createWriteBackCheck, xg as defineSkill, gy as defineTool, kv as defineWindowToolset, pg as detectGarbledToolCall, tg as estimateTokens, __ as extractText, Dv as fetchDocTools, Ov as fetchTools, z_ as formatZodIssues, Gv as isQuotaError, ov as jpEval, V_ as jsonParseError, rg as offloadPassThroughChars, ng as offloadThresholdChars, F_ as presets, R_ as resolveContextOptions, eg as resolveModelCaps, dv as runSandboxedScript, cv as searchJson, Av as selectBuiltinTools, I_ as systemPromptHelpers, $ as toolError, xl as useChat, e as z, B_ as zodError };
|