page-agent-sdk 1.3.11 → 1.3.13
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/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +114 -114
- package/dist/page-agent-sdk.js +767 -707
- package/dist/page-agent-sdk.umd.cjs +62 -62
- package/package.json +1 -1
- package/types/index.d.ts +2 -0
package/dist/page-agent-sdk.js
CHANGED
|
@@ -24,10 +24,10 @@ 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) => R(e) === "[object Map]", A = (e) => R(e) === "[object Set]", j = (e) => R(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, R = (e) => L.call(e),
|
|
27
|
+
}, E = Object.prototype.hasOwnProperty, D = (e, t) => E.call(e, t), O = Array.isArray, k = (e) => R(e) === "[object Map]", A = (e) => R(e) === "[object Set]", j = (e) => R(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, R = (e) => L.call(e), z = (e) => R(e).slice(8, -1), ee = (e) => R(e) === "[object Object]", te = (e) => N(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, ne = /* @__PURE__ */ _(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), re = /* @__PURE__ */ _("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), ie = (e) => {
|
|
28
28
|
let t = /* @__PURE__ */ Object.create(null);
|
|
29
29
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
30
|
-
},
|
|
30
|
+
}, ae = /-\w/g, oe = ie((e) => e.replace(ae, (e) => e.slice(1).toUpperCase())), se = /\B([A-Z])/g, ce = ie((e) => e.replace(se, "-$1").toLowerCase()), le = ie((e) => e.charAt(0).toUpperCase() + e.slice(1)), B = ie((e) => e ? `on${le(e)}` : ""), ue = (e, t) => !Object.is(e, t), de = (e, ...t) => {
|
|
31
31
|
for (let n = 0; n < e.length; n++) e[n](...t);
|
|
32
32
|
}, fe = (e, t, n, r = !1) => {
|
|
33
33
|
Object.defineProperty(e, t, {
|
|
@@ -99,7 +99,7 @@ function Ne(e, t) {
|
|
|
99
99
|
}
|
|
100
100
|
return String(e) === String(t);
|
|
101
101
|
}
|
|
102
|
-
var Pe = (e) => !!(e && e.__v_isRef === !0), V = (e) => N(e) ? e : e == null ? "" : O(e) || F(e) && (e.toString === L || !M(e.toString)) ? Pe(e) ? V(e.value) : JSON.stringify(e, Fe, 2) : String(e), Fe = (e, t) => Pe(t) ? Fe(e, t.value) : k(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((e, [t, n], r) => (e[Ie(t, r) + " =>"] = n, e), {}) } : A(t) ? { [`Set(${t.size})`]: [...t.values()].map((e) => Ie(e)) } : P(t) ? Ie(t) : F(t) && !O(t) && !
|
|
102
|
+
var Pe = (e) => !!(e && e.__v_isRef === !0), V = (e) => N(e) ? e : e == null ? "" : O(e) || F(e) && (e.toString === L || !M(e.toString)) ? Pe(e) ? V(e.value) : JSON.stringify(e, Fe, 2) : String(e), Fe = (e, t) => Pe(t) ? Fe(e, t.value) : k(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((e, [t, n], r) => (e[Ie(t, r) + " =>"] = n, e), {}) } : A(t) ? { [`Set(${t.size})`]: [...t.values()].map((e) => Ie(e)) } : P(t) ? Ie(t) : F(t) && !O(t) && !ee(t) ? String(t) : t, Ie = (e, t = "") => P(e) ? `Symbol(${e.description ?? t})` : e;
|
|
103
103
|
//#endregion
|
|
104
104
|
//#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
105
105
|
function Le(e, ...t) {
|
|
@@ -387,7 +387,7 @@ function ht(e, t, n, r, i, a) {
|
|
|
387
387
|
};
|
|
388
388
|
if (qe(), t === "clear") o.forEach(s);
|
|
389
389
|
else {
|
|
390
|
-
let i = O(e), a = i &&
|
|
390
|
+
let i = O(e), a = i && te(n);
|
|
391
391
|
if (i && n === "length") {
|
|
392
392
|
let e = Number(r);
|
|
393
393
|
o.forEach((t, n) => {
|
|
@@ -571,7 +571,7 @@ var kt = class {
|
|
|
571
571
|
let o = Reflect.get(e, t, /* @__PURE__ */ dn(e) ? e : n);
|
|
572
572
|
if ((P(t) ? Dt.has(t) : Et(t)) || (r || mt(e, "get", t), i)) return o;
|
|
573
573
|
if (/* @__PURE__ */ dn(o)) {
|
|
574
|
-
let e = a &&
|
|
574
|
+
let e = a && te(t) ? o : o.value;
|
|
575
575
|
return r && F(e) ? /* @__PURE__ */ en(e) : e;
|
|
576
576
|
}
|
|
577
577
|
return F(o) ? r ? /* @__PURE__ */ en(o) : /* @__PURE__ */ Qt(o) : o;
|
|
@@ -581,7 +581,7 @@ var kt = class {
|
|
|
581
581
|
super(!1, e);
|
|
582
582
|
}
|
|
583
583
|
set(e, t, n, r) {
|
|
584
|
-
let i = e[t], a = O(e) &&
|
|
584
|
+
let i = e[t], a = O(e) && te(t);
|
|
585
585
|
if (!this._isShallow) {
|
|
586
586
|
let r = /* @__PURE__ */ an(i);
|
|
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);
|
|
@@ -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 = z(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(z(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;
|
|
@@ -936,7 +936,7 @@ function En(e, t = Infinity, n) {
|
|
|
936
936
|
else if (A(e) || k(e)) e.forEach((e) => {
|
|
937
937
|
En(e, t, n);
|
|
938
938
|
});
|
|
939
|
-
else if (
|
|
939
|
+
else if (ee(e)) {
|
|
940
940
|
for (let r in e) En(e[r], t, n);
|
|
941
941
|
for (let r of Object.getOwnPropertySymbols(e)) Object.prototype.propertyIsEnumerable.call(e, r) && En(e[r], t, n);
|
|
942
942
|
}
|
|
@@ -1298,7 +1298,7 @@ function Lr(e, t = Pr, n) {
|
|
|
1298
1298
|
return r._n = !0, r._c = !0, r._d = !0, r;
|
|
1299
1299
|
}
|
|
1300
1300
|
function Rr(e) {
|
|
1301
|
-
|
|
1301
|
+
re(e) && G("Do not use built-in directive ids as custom directive id: " + e);
|
|
1302
1302
|
}
|
|
1303
1303
|
function zr(e, t) {
|
|
1304
1304
|
if (Pr === null) return process.env.NODE_ENV !== "production" && G("withDirectives can only be used inside render functions."), e;
|
|
@@ -2169,13 +2169,13 @@ 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[`${
|
|
2172
|
+
var Ta = null, Ea = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${oe(t)}Modifiers`] || e[`${ce(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 || !(B(
|
|
2178
|
+
if (r) if (!(t in r)) (!i || !(B(oe(t)) in i)) && G(`Component emitted event "${t}" but it is neither declared in the emits option nor as an "${B(oe(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}".`));
|
|
@@ -2184,10 +2184,10 @@ function Da(e, t, ...n) {
|
|
|
2184
2184
|
let i = n, a = t.startsWith("update:"), o = a && Ea(r, t.slice(7));
|
|
2185
2185
|
if (o && (o.trim && (i = n.map((e) => N(e) ? e.trim() : e)), o.number && (i = n.map(pe))), process.env.NODE_ENV !== "production" && Nr(e, t, i), process.env.NODE_ENV !== "production") {
|
|
2186
2186
|
let n = t.toLowerCase();
|
|
2187
|
-
n !== t && r[B(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 "${
|
|
2187
|
+
n !== t && r[B(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 "${ce(t)}" instead of "${t}".`);
|
|
2188
2188
|
}
|
|
2189
|
-
let s, c = r[s = B(t)] || r[s = B(
|
|
2190
|
-
!c && a && (c = r[s = B(
|
|
2189
|
+
let s, c = r[s = B(t)] || r[s = B(oe(t))];
|
|
2190
|
+
!c && a && (c = r[s = B(ce(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, ce(t)) || D(e, t));
|
|
2214
2214
|
}
|
|
2215
2215
|
var ja = !1;
|
|
2216
2216
|
function Ma() {
|
|
@@ -2351,7 +2351,7 @@ function Ja(e, t, n, r) {
|
|
|
2351
2351
|
let u = t[o];
|
|
2352
2352
|
if (c) if (D(a, o)) u !== a[o] && (a[o] = u, l = !0);
|
|
2353
2353
|
else {
|
|
2354
|
-
let t =
|
|
2354
|
+
let t = oe(o);
|
|
2355
2355
|
i[t] = Xa(c, s, t, u, e, !1);
|
|
2356
2356
|
}
|
|
2357
2357
|
else u !== a[o] && (a[o] = u, l = !0);
|
|
@@ -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 = ce(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);
|
|
@@ -2368,9 +2368,9 @@ function Ja(e, t, n, r) {
|
|
|
2368
2368
|
function Ya(e, t, n, r) {
|
|
2369
2369
|
let [i, a] = e.propsOptions, o = !1, s;
|
|
2370
2370
|
if (t) for (let c in t) {
|
|
2371
|
-
if (
|
|
2371
|
+
if (ne(c)) continue;
|
|
2372
2372
|
let l = t[c], u;
|
|
2373
|
-
i && D(i, u =
|
|
2373
|
+
i && D(i, u = oe(c)) ? !a || !a.includes(u) ? n[u] = l : (s ||= {})[u] = l : Aa(e.emitsOptions, c) || (!(c in r) || l !== r[c]) && (r[c] = l, o = !0);
|
|
2374
2374
|
}
|
|
2375
2375
|
if (a) {
|
|
2376
2376
|
let t = /* @__PURE__ */ U(n), r = s || v;
|
|
@@ -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 === ce(n)) && (r = !0));
|
|
2401
2401
|
}
|
|
2402
2402
|
return r;
|
|
2403
2403
|
}
|
|
@@ -2417,13 +2417,13 @@ function Qa(e, t, n = !1) {
|
|
|
2417
2417
|
if (!a && !c) return F(e) && r.set(e, y), y;
|
|
2418
2418
|
if (O(a)) for (let e = 0; e < a.length; e++) {
|
|
2419
2419
|
process.env.NODE_ENV !== "production" && !N(a[e]) && G("props must be strings when using array syntax.", a[e]);
|
|
2420
|
-
let t =
|
|
2420
|
+
let t = oe(a[e]);
|
|
2421
2421
|
$a(t) && (o[t] = v);
|
|
2422
2422
|
}
|
|
2423
2423
|
else if (a) {
|
|
2424
2424
|
process.env.NODE_ENV !== "production" && !F(a) && G("invalid props options", a);
|
|
2425
2425
|
for (let e in a) {
|
|
2426
|
-
let t =
|
|
2426
|
+
let t = oe(e);
|
|
2427
2427
|
if ($a(t)) {
|
|
2428
2428
|
let n = a[e], r = o[t] = O(n) || M(n) ? { type: n } : w({}, n), i = r.type, c = !1, l = !0;
|
|
2429
2429
|
if (O(i)) for (let e = 0; e < i.length; ++e) {
|
|
@@ -2442,13 +2442,13 @@ function Qa(e, t, n = !1) {
|
|
|
2442
2442
|
return F(e) && r.set(e, l), l;
|
|
2443
2443
|
}
|
|
2444
2444
|
function $a(e) {
|
|
2445
|
-
return e[0] !== "$" && !
|
|
2445
|
+
return e[0] !== "$" && !ne(e) ? !0 : (process.env.NODE_ENV !== "production" && G(`Invalid prop name: "${e}" is a reserved property.`), !1);
|
|
2446
2446
|
}
|
|
2447
2447
|
function eo(e) {
|
|
2448
2448
|
return e === null ? "null" : typeof e == "function" ? e.name || "" : typeof e == "object" && e.constructor && e.constructor.name || "";
|
|
2449
2449
|
}
|
|
2450
2450
|
function to(e, t, n) {
|
|
2451
|
-
let r = /* @__PURE__ */ U(t), i = n.propsOptions[0], a = Object.keys(e).map((e) =>
|
|
2451
|
+
let r = /* @__PURE__ */ U(t), i = n.propsOptions[0], a = Object.keys(e).map((e) => oe(e));
|
|
2452
2452
|
for (let e in i) {
|
|
2453
2453
|
let t = i[e];
|
|
2454
2454
|
t != null && no(e, r[e], t, process.env.NODE_ENV === "production" ? r : /* @__PURE__ */ tn(r), !a.includes(e));
|
|
@@ -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(le).join(" | ")}`, i = n[0], a =
|
|
2493
|
+
let r = `Invalid prop: type check failed for prop "${e}". Expected ${n.map(le).join(" | ")}`, i = n[0], a = z(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) {
|
|
@@ -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 = ce(e), re(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:
|
|
@@ -2631,7 +2631,7 @@ function Eo(e, t) {
|
|
|
2631
2631
|
}, E = (e, t, n, i, s, c, l, d) => {
|
|
2632
2632
|
let f, p, { props: m, shapeFlag: h, transition: g, dirs: _ } = e;
|
|
2633
2633
|
if (f = e.el = o(e.type, c, m && m.is, m), h & 8 ? u(f, e.children) : h & 16 && O(e.children, f, null, i, s, Do(e, c), l, d), _ && Br(e, null, i, "created"), D(f, e, e.scopeId, l, i), m) {
|
|
2634
|
-
for (let e in m) e !== "value" && !
|
|
2634
|
+
for (let e in m) e !== "value" && !ne(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
2637
|
process.env.NODE_ENV !== "production" && (fe(f, "__vnode", e, !0), fe(f, "__vueParentComponent", i, !0)), _ && Br(e, null, i, "beforeMount");
|
|
@@ -2689,9 +2689,9 @@ function Eo(e, t) {
|
|
|
2689
2689
|
}
|
|
2690
2690
|
}, j = (e, t, n, r, i) => {
|
|
2691
2691
|
if (t !== n) {
|
|
2692
|
-
if (t !== v) for (let o in t) !
|
|
2692
|
+
if (t !== v) for (let o in t) !ne(o) && !(o in n) && a(e, o, t[o], null, i, r);
|
|
2693
2693
|
for (let o in n) {
|
|
2694
|
-
if (
|
|
2694
|
+
if (ne(o)) continue;
|
|
2695
2695
|
let s = n[o], c = t[o];
|
|
2696
2696
|
s !== c && o !== "value" && a(e, o, c, s, i, r);
|
|
2697
2697
|
}
|
|
@@ -2738,7 +2738,7 @@ function Eo(e, t) {
|
|
|
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), ce(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
2744
|
if (Oo(e, !1), l && de(l), !m && (o = c && c.onVnodeBeforeMount) && ls(o, d, t), Oo(e, !0), s && me) {
|
|
@@ -2771,23 +2771,23 @@ function Eo(e, t) {
|
|
|
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
|
+
ee(l, f, n, r, i, a, o, s, c);
|
|
2775
2775
|
return;
|
|
2776
2776
|
} else if (p & 256) {
|
|
2777
|
-
|
|
2777
|
+
z(l, f, n, r, i, a, o, s, c);
|
|
2778
2778
|
return;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
|
-
m & 8 ? (d & 16 &&
|
|
2782
|
-
},
|
|
2781
|
+
m & 8 ? (d & 16 && se(l, i, a), f !== l && u(n, f)) : d & 16 ? m & 16 ? ee(l, f, n, r, i, a, o, s, c) : se(l, i, a, !0) : (d & 8 && u(n, ""), m & 16 && O(f, n, r, i, a, o, s, c));
|
|
2782
|
+
}, z = (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++) {
|
|
2786
2786
|
let r = t[f] = c ? os(t[f]) : as(t[f]);
|
|
2787
2787
|
h(e[f], r, n, null, i, a, o, s, c);
|
|
2788
2788
|
}
|
|
2789
|
-
l > u ?
|
|
2790
|
-
},
|
|
2789
|
+
l > u ? se(e, i, a, !0, !1, d) : O(t, n, r, i, a, o, s, c, d);
|
|
2790
|
+
}, ee = (e, t, n, r, i, a, o, s, c) => {
|
|
2791
2791
|
let l = 0, u = t.length, d = e.length - 1, f = u - 1;
|
|
2792
2792
|
for (; l <= d && l <= f;) {
|
|
2793
2793
|
let r = e[l], u = t[l] = c ? os(t[l]) : as(t[l]);
|
|
@@ -2806,7 +2806,7 @@ function Eo(e, t) {
|
|
|
2806
2806
|
let e = f + 1, d = e < u ? t[e].el : r;
|
|
2807
2807
|
for (; l <= f;) h(null, t[l] = c ? os(t[l]) : as(t[l]), n, d, i, a, o, s, c), l++;
|
|
2808
2808
|
}
|
|
2809
|
-
} else if (l > f) for (; l <= d;)
|
|
2809
|
+
} else if (l > f) for (; l <= d;) re(e[l], i, a, !0), l++;
|
|
2810
2810
|
else {
|
|
2811
2811
|
let p = l, m = l, g = /* @__PURE__ */ new Map();
|
|
2812
2812
|
for (l = m; l <= f; l++) {
|
|
@@ -2818,7 +2818,7 @@ function Eo(e, t) {
|
|
|
2818
2818
|
for (l = p; l <= d; l++) {
|
|
2819
2819
|
let r = e[l];
|
|
2820
2820
|
if (v >= b) {
|
|
2821
|
-
|
|
2821
|
+
re(r, i, a, !0);
|
|
2822
2822
|
continue;
|
|
2823
2823
|
}
|
|
2824
2824
|
let u;
|
|
@@ -2827,18 +2827,18 @@ function Eo(e, t) {
|
|
|
2827
2827
|
u = _;
|
|
2828
2828
|
break;
|
|
2829
2829
|
}
|
|
2830
|
-
u === void 0 ?
|
|
2830
|
+
u === void 0 ? re(r, i, a, !0) : (C[u - m] = l + 1, u >= S ? S = u : x = !0, h(r, t[u], n, null, i, a, o, s, c), v++);
|
|
2831
2831
|
}
|
|
2832
2832
|
let w = x ? jo(C) : y;
|
|
2833
2833
|
for (_ = w.length - 1, l = b - 1; l >= 0; l--) {
|
|
2834
2834
|
let e = m + l, d = t[e], f = t[e + 1], p = e + 1 < u ? f.el || Po(f) : r;
|
|
2835
|
-
C[l] === 0 ? h(null, d, n, p, i, a, o, s, c) : x && (_ < 0 || l !== w[_] ?
|
|
2835
|
+
C[l] === 0 ? h(null, d, n, p, i, a, o, s, c) : x && (_ < 0 || l !== w[_] ? te(d, n, p, 2) : _--);
|
|
2836
2836
|
}
|
|
2837
2837
|
}
|
|
2838
|
-
},
|
|
2838
|
+
}, te = (e, t, n, a, o = null) => {
|
|
2839
2839
|
let { el: s, type: c, transition: l, children: u, shapeFlag: d } = e;
|
|
2840
2840
|
if (d & 6) {
|
|
2841
|
-
|
|
2841
|
+
te(e.component.subTree, t, n, a);
|
|
2842
2842
|
return;
|
|
2843
2843
|
}
|
|
2844
2844
|
if (d & 128) {
|
|
@@ -2851,7 +2851,7 @@ function Eo(e, t) {
|
|
|
2851
2851
|
}
|
|
2852
2852
|
if (c === K) {
|
|
2853
2853
|
r(s, t, n);
|
|
2854
|
-
for (let e = 0; e < u.length; e++)
|
|
2854
|
+
for (let e = 0; e < u.length; e++) te(u[e], t, n, a);
|
|
2855
2855
|
r(e.anchor, t, n);
|
|
2856
2856
|
return;
|
|
2857
2857
|
}
|
|
@@ -2872,31 +2872,31 @@ function Eo(e, t) {
|
|
|
2872
2872
|
o ? o(s, u, d) : d();
|
|
2873
2873
|
}
|
|
2874
2874
|
else r(s, t, n);
|
|
2875
|
-
},
|
|
2875
|
+
}, re = (e, t, n, r = !1, i = !1) => {
|
|
2876
2876
|
let { type: a, props: o, ref: s, children: c, dynamicChildren: l, shapeFlag: u, patchFlag: d, dirs: f, cacheIndex: p, memo: m } = e;
|
|
2877
2877
|
if (d === -2 && (i = !1), s != null && (rt(), ki(s, null, n, e, !0), it()), p != null && (t.renderCache[p] = void 0), u & 256) {
|
|
2878
2878
|
t.ctx.deactivate(e);
|
|
2879
2879
|
return;
|
|
2880
2880
|
}
|
|
2881
2881
|
let h = u & 1 && f, g = !ji(e), _;
|
|
2882
|
-
if (g && (_ = o && o.onVnodeBeforeUnmount) && ls(_, t, e), u & 6)
|
|
2882
|
+
if (g && (_ = o && o.onVnodeBeforeUnmount) && ls(_, t, e), u & 6) oe(e.component, n, r);
|
|
2883
2883
|
else {
|
|
2884
2884
|
if (u & 128) {
|
|
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, ue, r) : l && !l.hasOnce && (a !== K || d > 0 && d & 64) ?
|
|
2888
|
+
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n, ue, r) : l && !l.hasOnce && (a !== K || d > 0 && d & 64) ? se(l, t, n, !1, !0) : (a === K && d & 384 || !i && u & 16) && se(c, t, n), r && ie(e);
|
|
2889
2889
|
}
|
|
2890
2890
|
let v = m != null && p == null;
|
|
2891
2891
|
(g && (_ = o && o.onVnodeUnmounted) || h || v) && wo(() => {
|
|
2892
2892
|
_ && ls(_, t, e), h && Br(e, null, t, "unmounted"), v && (e.el = null);
|
|
2893
2893
|
}, n);
|
|
2894
|
-
},
|
|
2894
|
+
}, ie = (e) => {
|
|
2895
2895
|
let { type: t, el: n, anchor: r, transition: a } = e;
|
|
2896
2896
|
if (t === K) {
|
|
2897
2897
|
process.env.NODE_ENV !== "production" && e.patchFlag > 0 && e.patchFlag & 2048 && a && !a.persisted ? e.children.forEach((e) => {
|
|
2898
|
-
e.type === Ro ? i(e.el) :
|
|
2899
|
-
}) :
|
|
2898
|
+
e.type === Ro ? i(e.el) : ie(e);
|
|
2899
|
+
}) : ae(n, r);
|
|
2900
2900
|
return;
|
|
2901
2901
|
}
|
|
2902
2902
|
if (t === zo) {
|
|
@@ -2910,36 +2910,36 @@ function Eo(e, t) {
|
|
|
2910
2910
|
let { leave: t, delayLeave: r } = a, i = () => t(n, o);
|
|
2911
2911
|
r ? r(e.el, o, i) : i();
|
|
2912
2912
|
} else o();
|
|
2913
|
-
},
|
|
2913
|
+
}, ae = (e, t) => {
|
|
2914
2914
|
let n;
|
|
2915
2915
|
for (; e !== t;) n = f(e), i(e), e = n;
|
|
2916
2916
|
i(t);
|
|
2917
|
-
},
|
|
2917
|
+
}, oe = (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 && de(r), i.stop(), a && (a.flags |= 8,
|
|
2920
|
+
No(c), No(l), r && de(r), i.stop(), a && (a.flags |= 8, re(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
|
-
},
|
|
2924
|
-
for (let o = a; o < e.length; o++)
|
|
2925
|
-
},
|
|
2926
|
-
if (e.shapeFlag & 6) return
|
|
2923
|
+
}, se = (e, t, n, r = !1, i = !1, a = 0) => {
|
|
2924
|
+
for (let o = a; o < e.length; o++) re(e[o], t, n, r, i);
|
|
2925
|
+
}, ce = (e) => {
|
|
2926
|
+
if (e.shapeFlag & 6) return ce(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
|
}, le = !1, B = (e, t, n) => {
|
|
2931
2931
|
let r;
|
|
2932
|
-
e == null ? t._vnode && (
|
|
2932
|
+
e == null ? t._vnode && (re(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e, le ||= (le = !0, tr(r), nr(), !1);
|
|
2933
2933
|
}, ue = {
|
|
2934
2934
|
p: h,
|
|
2935
|
-
um:
|
|
2936
|
-
m:
|
|
2937
|
-
r:
|
|
2935
|
+
um: re,
|
|
2936
|
+
m: te,
|
|
2937
|
+
r: ie,
|
|
2938
2938
|
mt: P,
|
|
2939
2939
|
mc: O,
|
|
2940
2940
|
pc: R,
|
|
2941
2941
|
pbc: A,
|
|
2942
|
-
n:
|
|
2942
|
+
n: ce,
|
|
2943
2943
|
o: e
|
|
2944
2944
|
}, pe, me;
|
|
2945
2945
|
return t && ([pe, me] = t(ue)), {
|
|
@@ -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(ce(r), n.replace(Dc, ""), "important") : e[r] = n;
|
|
3802
3802
|
}
|
|
3803
3803
|
}
|
|
3804
3804
|
var kc = [
|
|
@@ -3809,7 +3809,7 @@ var kc = [
|
|
|
3809
3809
|
function jc(e, t) {
|
|
3810
3810
|
let n = Ac[t];
|
|
3811
3811
|
if (n) return n;
|
|
3812
|
-
let r =
|
|
3812
|
+
let r = oe(t);
|
|
3813
3813
|
if (r !== "filter" && r in e) return Ac[t] = r;
|
|
3814
3814
|
r = le(r);
|
|
3815
3815
|
for (let n = 0; n < kc.length; n++) {
|
|
@@ -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) : ce(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) {
|
|
@@ -3895,7 +3895,7 @@ Expected function or array of functions, received type ${typeof e}.`), b);
|
|
|
3895
3895
|
}
|
|
3896
3896
|
var Jc = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && e.charCodeAt(2) > 96 && e.charCodeAt(2) < 123, Yc = (e, t, n, r, i, a) => {
|
|
3897
3897
|
let o = i === "svg";
|
|
3898
|
-
t === "class" ? vc(e, r, o) : t === "style" ? Tc(e, n, r) : S(t) ? C(t) || zc(e, t, n, r, a) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Xc(e, t, r, o)) ? (Fc(e, t, r), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && Pc(e, t, r, o, a, t !== "value")) : e._isVueCE && (Zc(e, t) || e._def.__asyncLoader && (/[A-Z]/.test(t) || !N(r))) ? Fc(e,
|
|
3898
|
+
t === "class" ? vc(e, r, o) : t === "style" ? Tc(e, n, r) : S(t) ? C(t) || zc(e, t, n, r, a) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Xc(e, t, r, o)) ? (Fc(e, t, r), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && Pc(e, t, r, o, a, t !== "value")) : e._isVueCE && (Zc(e, t) || e._def.__asyncLoader && (/[A-Z]/.test(t) || !N(r))) ? Fc(e, oe(t), r, a, t) : (t === "true-value" ? e._trueValue = r : t === "false-value" && (e._falseValue = r), Pc(e, t, r, o));
|
|
3899
3899
|
};
|
|
3900
3900
|
function Xc(e, t, n, r) {
|
|
3901
3901
|
if (r) return !!(t === "innerHTML" || t === "textContent" || t in e && Jc(t) && M(n));
|
|
@@ -3909,8 +3909,8 @@ function Xc(e, t, n, r) {
|
|
|
3909
3909
|
function Zc(e, t) {
|
|
3910
3910
|
let n = e._def.props;
|
|
3911
3911
|
if (!n) return !1;
|
|
3912
|
-
let r =
|
|
3913
|
-
return Array.isArray(n) ? n.some((e) =>
|
|
3912
|
+
let r = oe(t);
|
|
3913
|
+
return Array.isArray(n) ? n.some((e) => oe(e) === r) : Object.keys(n).some((e) => oe(e) === r);
|
|
3914
3914
|
}
|
|
3915
3915
|
var Qc = (e) => {
|
|
3916
3916
|
let t = e.props["onUpdate:modelValue"] || !1;
|
|
@@ -4085,21 +4085,29 @@ function xl(e = {}) {
|
|
|
4085
4085
|
messages: e.messages ?? [],
|
|
4086
4086
|
loading: !1,
|
|
4087
4087
|
error: null
|
|
4088
|
-
}), o = /* @__PURE__ */ fn(null), s = /* @__PURE__ */ fn(
|
|
4089
|
-
function
|
|
4090
|
-
|
|
4091
|
-
|
|
4088
|
+
}), o = /* @__PURE__ */ fn(null), s = /* @__PURE__ */ fn(!0), c = null, l = /* @__PURE__ */ fn(null);
|
|
4089
|
+
function u() {
|
|
4090
|
+
let e = o.value;
|
|
4091
|
+
e && (s.value = e.scrollHeight - e.scrollTop - e.clientHeight < 64);
|
|
4092
|
+
}
|
|
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);
|
|
4092
4100
|
});
|
|
4093
4101
|
}
|
|
4094
|
-
function
|
|
4102
|
+
function p(e, t) {
|
|
4095
4103
|
a.messages.push({
|
|
4096
4104
|
role: e,
|
|
4097
4105
|
content: t,
|
|
4098
4106
|
timestamp: Date.now()
|
|
4099
|
-
}),
|
|
4107
|
+
}), s.value = !0, f();
|
|
4100
4108
|
}
|
|
4101
|
-
async function
|
|
4102
|
-
if (n) {
|
|
4109
|
+
async function m(e) {
|
|
4110
|
+
if (s.value = !0, n) {
|
|
4103
4111
|
let t = /* @__PURE__ */ Qt({
|
|
4104
4112
|
role: "assistant",
|
|
4105
4113
|
content: "",
|
|
@@ -4150,14 +4158,14 @@ function xl(e = {}) {
|
|
|
4150
4158
|
break;
|
|
4151
4159
|
}
|
|
4152
4160
|
case "approval_request":
|
|
4153
|
-
|
|
4161
|
+
l.value = {
|
|
4154
4162
|
toolName: e.toolName,
|
|
4155
4163
|
args: e.args,
|
|
4156
4164
|
resolve: e.resolve
|
|
4157
4165
|
};
|
|
4158
4166
|
break;
|
|
4159
4167
|
}
|
|
4160
|
-
|
|
4168
|
+
f();
|
|
4161
4169
|
}, e);
|
|
4162
4170
|
} catch (n) {
|
|
4163
4171
|
if (gl(n, e) || (a.error = n.message || "请求失败,请重试"), !t.content && !t.reasoning) {
|
|
@@ -4170,39 +4178,39 @@ function xl(e = {}) {
|
|
|
4170
4178
|
return;
|
|
4171
4179
|
}
|
|
4172
4180
|
try {
|
|
4173
|
-
|
|
4181
|
+
p("assistant", await (t || _)(a.messages, e));
|
|
4174
4182
|
} catch (t) {
|
|
4175
4183
|
gl(t, e) || (a.error = t.message || "请求失败,请重试");
|
|
4176
4184
|
} finally {
|
|
4177
4185
|
await r?.(a.messages), a.loading = !1, c = null;
|
|
4178
4186
|
}
|
|
4179
4187
|
}
|
|
4180
|
-
async function
|
|
4181
|
-
!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));
|
|
4182
4190
|
}
|
|
4183
|
-
async function
|
|
4191
|
+
async function g() {
|
|
4184
4192
|
if (a.loading) return;
|
|
4185
4193
|
let e = a.messages;
|
|
4186
4194
|
for (let t = e.length - 1; t >= 0; t--) if (e[t].role === "assistant") {
|
|
4187
4195
|
e.splice(t);
|
|
4188
4196
|
break;
|
|
4189
4197
|
}
|
|
4190
|
-
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));
|
|
4191
4199
|
}
|
|
4192
|
-
async function
|
|
4200
|
+
async function _(e) {
|
|
4193
4201
|
return await new Promise((e) => setTimeout(e, 800 + Math.random() * 1200)), `收到你的消息:"${e.filter((e) => e.role === "user").pop()?.content}"。这是一个模拟回复,请接入实际的 AI API。`;
|
|
4194
4202
|
}
|
|
4195
|
-
function
|
|
4203
|
+
function v() {
|
|
4196
4204
|
i?.(), a.messages.splice(0, a.messages.length), a.error = null;
|
|
4197
4205
|
}
|
|
4198
|
-
function
|
|
4206
|
+
function y() {
|
|
4199
4207
|
c?.abort();
|
|
4200
4208
|
}
|
|
4201
|
-
function
|
|
4202
|
-
let t =
|
|
4203
|
-
t && (
|
|
4209
|
+
function b(e) {
|
|
4210
|
+
let t = l.value;
|
|
4211
|
+
t && (l.value = null, t.resolve(e));
|
|
4204
4212
|
}
|
|
4205
|
-
async function
|
|
4213
|
+
async function x() {
|
|
4206
4214
|
if (!a.error) return;
|
|
4207
4215
|
let e = a.messages, t = -1;
|
|
4208
4216
|
for (let n = e.length - 1; n >= 0; n--) if (e[n].role === "user") {
|
|
@@ -4211,18 +4219,20 @@ function xl(e = {}) {
|
|
|
4211
4219
|
}
|
|
4212
4220
|
if (t < 0) return;
|
|
4213
4221
|
let n = e[t].content;
|
|
4214
|
-
e.splice(t), a.error = null, await
|
|
4222
|
+
e.splice(t), a.error = null, await h(n);
|
|
4215
4223
|
}
|
|
4216
4224
|
return {
|
|
4217
4225
|
state: a,
|
|
4218
4226
|
scrollContainer: o,
|
|
4219
|
-
pendingApproval:
|
|
4220
|
-
sendMessage:
|
|
4221
|
-
clearMessages:
|
|
4222
|
-
stop:
|
|
4223
|
-
retry:
|
|
4224
|
-
regenerate:
|
|
4225
|
-
resolveApproval:
|
|
4227
|
+
pendingApproval: l,
|
|
4228
|
+
sendMessage: h,
|
|
4229
|
+
clearMessages: v,
|
|
4230
|
+
stop: y,
|
|
4231
|
+
retry: x,
|
|
4232
|
+
regenerate: g,
|
|
4233
|
+
resolveApproval: b,
|
|
4234
|
+
onScroll: u,
|
|
4235
|
+
onWheel: d
|
|
4226
4236
|
};
|
|
4227
4237
|
}
|
|
4228
4238
|
//#endregion
|
|
@@ -5889,7 +5899,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5889
5899
|
});
|
|
5890
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,}/);
|
|
5891
5901
|
return r.contains.push({ begin: _(/[ ]+/, "(", i, /[.]?[:]?([.][ ]|[ ])/, "){3}") }), r;
|
|
5892
|
-
}, L = I("//", "$"), R = I("/\\*", "\\*/"),
|
|
5902
|
+
}, L = I("//", "$"), R = I("/\\*", "\\*/"), z = I("#", "$"), ee = /*#__PURE__*/ Object.freeze({
|
|
5893
5903
|
__proto__: null,
|
|
5894
5904
|
APOS_STRING_MODE: N,
|
|
5895
5905
|
BACKSLASH_ESCAPE: M,
|
|
@@ -5918,7 +5928,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5918
5928
|
}
|
|
5919
5929
|
});
|
|
5920
5930
|
},
|
|
5921
|
-
HASH_COMMENT_MODE:
|
|
5931
|
+
HASH_COMMENT_MODE: z,
|
|
5922
5932
|
IDENT_RE: T,
|
|
5923
5933
|
MATCH_NOTHING_RE: w,
|
|
5924
5934
|
METHOD_GUARD: {
|
|
@@ -5958,28 +5968,28 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5958
5968
|
relevance: 0
|
|
5959
5969
|
}
|
|
5960
5970
|
});
|
|
5961
|
-
function
|
|
5971
|
+
function te(e, t) {
|
|
5962
5972
|
e.input[e.index - 1] === "." && t.ignoreMatch();
|
|
5963
5973
|
}
|
|
5964
|
-
function
|
|
5974
|
+
function ne(e, t) {
|
|
5965
5975
|
e.className !== void 0 && (e.scope = e.className, delete e.className);
|
|
5966
5976
|
}
|
|
5967
|
-
function
|
|
5968
|
-
t && e.beginKeywords && (e.begin = "\\b(" + e.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", e.__beforeBegin =
|
|
5977
|
+
function re(e, t) {
|
|
5978
|
+
t && e.beginKeywords && (e.begin = "\\b(" + e.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", e.__beforeBegin = te, e.keywords = e.keywords || e.beginKeywords, delete e.beginKeywords, e.relevance === void 0 && (e.relevance = 0));
|
|
5969
5979
|
}
|
|
5970
|
-
function
|
|
5980
|
+
function ie(e, t) {
|
|
5971
5981
|
Array.isArray(e.illegal) && (e.illegal = y(...e.illegal));
|
|
5972
5982
|
}
|
|
5973
|
-
function
|
|
5983
|
+
function ae(e, t) {
|
|
5974
5984
|
if (e.match) {
|
|
5975
5985
|
if (e.begin || e.end) throw Error("begin & end are not supported with match");
|
|
5976
5986
|
e.begin = e.match, delete e.match;
|
|
5977
5987
|
}
|
|
5978
5988
|
}
|
|
5979
|
-
function
|
|
5989
|
+
function oe(e, t) {
|
|
5980
5990
|
e.relevance === void 0 && (e.relevance = 1);
|
|
5981
5991
|
}
|
|
5982
|
-
var
|
|
5992
|
+
var se = (e, t) => {
|
|
5983
5993
|
if (!e.beforeMatch) return;
|
|
5984
5994
|
if (e.starts) throw Error("beforeMatch cannot be used with starts");
|
|
5985
5995
|
let n = Object.assign({}, e);
|
|
@@ -5989,7 +5999,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5989
5999
|
relevance: 0,
|
|
5990
6000
|
contains: [Object.assign(n, { endsParent: !0 })]
|
|
5991
6001
|
}, e.relevance = 0, delete n.beforeMatch;
|
|
5992
|
-
},
|
|
6002
|
+
}, ce = [
|
|
5993
6003
|
"of",
|
|
5994
6004
|
"and",
|
|
5995
6005
|
"for",
|
|
@@ -6018,7 +6028,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6018
6028
|
return t ? Number(t) : +!de(e);
|
|
6019
6029
|
}
|
|
6020
6030
|
function de(e) {
|
|
6021
|
-
return
|
|
6031
|
+
return ce.includes(e.toLowerCase());
|
|
6022
6032
|
}
|
|
6023
6033
|
var fe = {}, pe = (e) => {
|
|
6024
6034
|
console.error(e);
|
|
@@ -6116,14 +6126,14 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6116
6126
|
let a = n;
|
|
6117
6127
|
if (n.isCompiled) return a;
|
|
6118
6128
|
[
|
|
6119
|
-
|
|
6120
|
-
|
|
6129
|
+
ne,
|
|
6130
|
+
ae,
|
|
6121
6131
|
xe,
|
|
6122
|
-
|
|
6132
|
+
se
|
|
6123
6133
|
].forEach((e) => e(n, r)), e.compilerExtensions.forEach((e) => e(n, r)), n.__beforeBegin = null, [
|
|
6134
|
+
re,
|
|
6124
6135
|
ie,
|
|
6125
|
-
|
|
6126
|
-
se
|
|
6136
|
+
oe
|
|
6127
6137
|
].forEach((e) => e(n, r)), n.isCompiled = !0;
|
|
6128
6138
|
let s = null;
|
|
6129
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 &&= B(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) {
|
|
@@ -6182,9 +6192,9 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6182
6192
|
code: r,
|
|
6183
6193
|
language: i
|
|
6184
6194
|
};
|
|
6185
|
-
|
|
6195
|
+
z("before:highlight", a);
|
|
6186
6196
|
let o = a.result ? a.result : v(a.language, a.code, n);
|
|
6187
|
-
return o.code = a.code,
|
|
6197
|
+
return o.code = a.code, z("after:highlight", o), o;
|
|
6188
6198
|
}
|
|
6189
6199
|
function v(e, n, i, a) {
|
|
6190
6200
|
let c = Object.create(null);
|
|
@@ -6389,7 +6399,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6389
6399
|
function w(e) {
|
|
6390
6400
|
let t = null, n = d(e);
|
|
6391
6401
|
if (u(n)) return;
|
|
6392
|
-
if (
|
|
6402
|
+
if (z("before:highlightElement", {
|
|
6393
6403
|
el: e,
|
|
6394
6404
|
language: n
|
|
6395
6405
|
}), e.dataset.highlighted) {
|
|
@@ -6409,7 +6419,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6409
6419
|
}, i.secondBest && (e.secondBest = {
|
|
6410
6420
|
language: i.secondBest.language,
|
|
6411
6421
|
relevance: i.secondBest.relevance
|
|
6412
|
-
}),
|
|
6422
|
+
}), z("after:highlightElement", {
|
|
6413
6423
|
el: e,
|
|
6414
6424
|
result: i,
|
|
6415
6425
|
text: r
|
|
@@ -6479,13 +6489,13 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6479
6489
|
let t = a.indexOf(e);
|
|
6480
6490
|
t !== -1 && a.splice(t, 1);
|
|
6481
6491
|
}
|
|
6482
|
-
function
|
|
6492
|
+
function z(e, t) {
|
|
6483
6493
|
let n = e;
|
|
6484
6494
|
a.forEach(function(e) {
|
|
6485
6495
|
e[n] && e[n](t);
|
|
6486
6496
|
});
|
|
6487
6497
|
}
|
|
6488
|
-
function
|
|
6498
|
+
function te(e) {
|
|
6489
6499
|
return he("10.7.0", "highlightBlock will be removed entirely in v12.0"), he("10.7.0", "Please use highlightElement now."), w(e);
|
|
6490
6500
|
}
|
|
6491
6501
|
Object.assign(e, {
|
|
@@ -6493,7 +6503,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6493
6503
|
highlightAuto: S,
|
|
6494
6504
|
highlightAll: k,
|
|
6495
6505
|
highlightElement: w,
|
|
6496
|
-
highlightBlock:
|
|
6506
|
+
highlightBlock: te,
|
|
6497
6507
|
configure: T,
|
|
6498
6508
|
initHighlighting: E,
|
|
6499
6509
|
initHighlightingOnLoad: D,
|
|
@@ -6517,8 +6527,8 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6517
6527
|
optional: g,
|
|
6518
6528
|
anyNumberOfTimes: h
|
|
6519
6529
|
};
|
|
6520
|
-
for (let e in
|
|
6521
|
-
return Object.assign(e,
|
|
6530
|
+
for (let e in ee) typeof ee[e] == "object" && n(ee[e]);
|
|
6531
|
+
return Object.assign(e, ee), e;
|
|
6522
6532
|
}, Me = je({});
|
|
6523
6533
|
Me.newInstance = () => je({}), t.exports = Me, Me.HighlightJS = Me, Me.default = Me;
|
|
6524
6534
|
})), td = /* @__PURE__ */ m(((e, t) => {
|
|
@@ -8871,7 +8881,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8871
8881
|
3: "title.function"
|
|
8872
8882
|
},
|
|
8873
8883
|
contains: [{ begin: /\(\)/ }, k]
|
|
8874
|
-
},
|
|
8884
|
+
}, z = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", ee = {
|
|
8875
8885
|
match: [
|
|
8876
8886
|
/const|var|let/,
|
|
8877
8887
|
/\s+/,
|
|
@@ -8879,7 +8889,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8879
8889
|
/\s*/,
|
|
8880
8890
|
/=\s*/,
|
|
8881
8891
|
/(async\s*)?/,
|
|
8882
|
-
t.lookahead(
|
|
8892
|
+
t.lookahead(z)
|
|
8883
8893
|
],
|
|
8884
8894
|
keywords: "async",
|
|
8885
8895
|
className: {
|
|
@@ -8924,7 +8934,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8924
8934
|
match: d + t.lookahead(":"),
|
|
8925
8935
|
relevance: 0
|
|
8926
8936
|
},
|
|
8927
|
-
|
|
8937
|
+
ee,
|
|
8928
8938
|
{
|
|
8929
8939
|
begin: "(" + e.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
|
|
8930
8940
|
keywords: "return throw case",
|
|
@@ -8934,7 +8944,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
8934
8944
|
e.REGEXP_MODE,
|
|
8935
8945
|
{
|
|
8936
8946
|
className: "function",
|
|
8937
|
-
begin:
|
|
8947
|
+
begin: z,
|
|
8938
8948
|
returnBegin: !0,
|
|
8939
8949
|
end: "\\s*=>",
|
|
8940
8950
|
contains: [{
|
|
@@ -11301,52 +11311,52 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11301
11311
|
I(e),
|
|
11302
11312
|
L(e)
|
|
11303
11313
|
]
|
|
11304
|
-
}),
|
|
11314
|
+
}), z = (e = "") => ({
|
|
11305
11315
|
begin: i(e, /"/),
|
|
11306
11316
|
end: i(/"/, e),
|
|
11307
11317
|
contains: [F(e), L(e)]
|
|
11308
|
-
}),
|
|
11318
|
+
}), ee = {
|
|
11309
11319
|
className: "string",
|
|
11310
11320
|
variants: [
|
|
11311
11321
|
R(),
|
|
11312
11322
|
R("#"),
|
|
11313
11323
|
R("##"),
|
|
11314
11324
|
R("###"),
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11325
|
+
z(),
|
|
11326
|
+
z("#"),
|
|
11327
|
+
z("##"),
|
|
11328
|
+
z("###")
|
|
11319
11329
|
]
|
|
11320
|
-
},
|
|
11330
|
+
}, te = [e.BACKSLASH_ESCAPE, {
|
|
11321
11331
|
begin: /\[/,
|
|
11322
11332
|
end: /\]/,
|
|
11323
11333
|
relevance: 0,
|
|
11324
11334
|
contains: [e.BACKSLASH_ESCAPE]
|
|
11325
|
-
}],
|
|
11335
|
+
}], ne = {
|
|
11326
11336
|
begin: /\/[^\s](?=[^/\n]*\/)/,
|
|
11327
11337
|
end: /\//,
|
|
11328
|
-
contains:
|
|
11329
|
-
},
|
|
11338
|
+
contains: te
|
|
11339
|
+
}, re = (e) => {
|
|
11330
11340
|
let t = i(e, /\//), n = i(/\//, e);
|
|
11331
11341
|
return {
|
|
11332
11342
|
begin: t,
|
|
11333
11343
|
end: n,
|
|
11334
|
-
contains: [...
|
|
11344
|
+
contains: [...te, {
|
|
11335
11345
|
scope: "comment",
|
|
11336
11346
|
begin: `#(?!.*${n})`,
|
|
11337
11347
|
end: /$/
|
|
11338
11348
|
}]
|
|
11339
11349
|
};
|
|
11340
|
-
},
|
|
11350
|
+
}, ie = {
|
|
11341
11351
|
scope: "regexp",
|
|
11342
11352
|
variants: [
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11353
|
+
re("###"),
|
|
11354
|
+
re("##"),
|
|
11355
|
+
re("#"),
|
|
11356
|
+
ne
|
|
11347
11357
|
]
|
|
11348
|
-
},
|
|
11349
|
-
|
|
11358
|
+
}, ae = { match: i(/`/, x, /`/) }, oe = [
|
|
11359
|
+
ae,
|
|
11350
11360
|
{
|
|
11351
11361
|
className: "variable",
|
|
11352
11362
|
match: /\$\d+/
|
|
@@ -11355,7 +11365,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11355
11365
|
className: "variable",
|
|
11356
11366
|
match: `\\$${b}+`
|
|
11357
11367
|
}
|
|
11358
|
-
],
|
|
11368
|
+
], se = [
|
|
11359
11369
|
{
|
|
11360
11370
|
match: /(@|#(un)?)available/,
|
|
11361
11371
|
scope: "keyword",
|
|
@@ -11366,7 +11376,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11366
11376
|
contains: [
|
|
11367
11377
|
...j,
|
|
11368
11378
|
P,
|
|
11369
|
-
|
|
11379
|
+
ee
|
|
11370
11380
|
]
|
|
11371
11381
|
}] }
|
|
11372
11382
|
},
|
|
@@ -11378,7 +11388,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11378
11388
|
scope: "meta",
|
|
11379
11389
|
match: i(/@/, x)
|
|
11380
11390
|
}
|
|
11381
|
-
],
|
|
11391
|
+
], ce = {
|
|
11382
11392
|
match: r(/\b[A-Z]/),
|
|
11383
11393
|
relevance: 0,
|
|
11384
11394
|
contains: [
|
|
@@ -11411,12 +11421,12 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11411
11421
|
contains: [
|
|
11412
11422
|
...a,
|
|
11413
11423
|
...O,
|
|
11414
|
-
...
|
|
11424
|
+
...se,
|
|
11415
11425
|
A,
|
|
11416
|
-
|
|
11426
|
+
ce
|
|
11417
11427
|
]
|
|
11418
11428
|
};
|
|
11419
|
-
|
|
11429
|
+
ce.contains.push(le);
|
|
11420
11430
|
let B = {
|
|
11421
11431
|
begin: /\(/,
|
|
11422
11432
|
end: /\)/,
|
|
@@ -11430,21 +11440,21 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11430
11440
|
relevance: 0
|
|
11431
11441
|
},
|
|
11432
11442
|
...a,
|
|
11433
|
-
|
|
11443
|
+
ie,
|
|
11434
11444
|
...O,
|
|
11435
11445
|
...k,
|
|
11436
11446
|
...j,
|
|
11437
11447
|
P,
|
|
11438
|
-
|
|
11448
|
+
ee,
|
|
11449
|
+
...oe,
|
|
11439
11450
|
...se,
|
|
11440
|
-
|
|
11441
|
-
z
|
|
11451
|
+
ce
|
|
11442
11452
|
]
|
|
11443
11453
|
}, ue = {
|
|
11444
11454
|
begin: /</,
|
|
11445
11455
|
end: />/,
|
|
11446
11456
|
keywords: "repeat each",
|
|
11447
|
-
contains: [...a,
|
|
11457
|
+
contains: [...a, ce]
|
|
11448
11458
|
}, de = {
|
|
11449
11459
|
begin: /\(/,
|
|
11450
11460
|
end: /\)/,
|
|
@@ -11466,9 +11476,9 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11466
11476
|
...O,
|
|
11467
11477
|
...j,
|
|
11468
11478
|
P,
|
|
11469
|
-
|
|
11470
|
-
...
|
|
11471
|
-
|
|
11479
|
+
ee,
|
|
11480
|
+
...se,
|
|
11481
|
+
ce,
|
|
11472
11482
|
B
|
|
11473
11483
|
],
|
|
11474
11484
|
endsParent: !0,
|
|
@@ -11477,7 +11487,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11477
11487
|
match: [
|
|
11478
11488
|
/(func|macro)/,
|
|
11479
11489
|
/\s+/,
|
|
11480
|
-
o(
|
|
11490
|
+
o(ae.match, x, v)
|
|
11481
11491
|
],
|
|
11482
11492
|
className: {
|
|
11483
11493
|
1: "keyword",
|
|
@@ -11518,7 +11528,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11518
11528
|
1: "keyword",
|
|
11519
11529
|
3: "title"
|
|
11520
11530
|
},
|
|
11521
|
-
contains: [
|
|
11531
|
+
contains: [ce],
|
|
11522
11532
|
keywords: [...p, ...f],
|
|
11523
11533
|
end: /}/
|
|
11524
11534
|
}, ge = {
|
|
@@ -11571,7 +11581,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11571
11581
|
}
|
|
11572
11582
|
]
|
|
11573
11583
|
};
|
|
11574
|
-
for (let e of
|
|
11584
|
+
for (let e of ee.variants) {
|
|
11575
11585
|
let t = e.contains.find((e) => e.label === "interpol");
|
|
11576
11586
|
t.keywords = D;
|
|
11577
11587
|
let n = [
|
|
@@ -11579,8 +11589,8 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11579
11589
|
...k,
|
|
11580
11590
|
...j,
|
|
11581
11591
|
P,
|
|
11582
|
-
|
|
11583
|
-
...
|
|
11592
|
+
ee,
|
|
11593
|
+
...oe
|
|
11584
11594
|
];
|
|
11585
11595
|
t.contains = [...n, {
|
|
11586
11596
|
begin: /\(/,
|
|
@@ -11606,15 +11616,15 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11606
11616
|
contains: [...a],
|
|
11607
11617
|
relevance: 0
|
|
11608
11618
|
},
|
|
11609
|
-
|
|
11619
|
+
ie,
|
|
11610
11620
|
...O,
|
|
11611
11621
|
...k,
|
|
11612
11622
|
...j,
|
|
11613
11623
|
P,
|
|
11614
|
-
|
|
11624
|
+
ee,
|
|
11625
|
+
...oe,
|
|
11615
11626
|
...se,
|
|
11616
|
-
|
|
11617
|
-
z,
|
|
11627
|
+
ce,
|
|
11618
11628
|
B
|
|
11619
11629
|
]
|
|
11620
11630
|
};
|
|
@@ -12044,7 +12054,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12044
12054
|
3: "title.function"
|
|
12045
12055
|
},
|
|
12046
12056
|
contains: [{ begin: /\(\)/ }, k]
|
|
12047
|
-
},
|
|
12057
|
+
}, z = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", ee = {
|
|
12048
12058
|
match: [
|
|
12049
12059
|
/const|var|let/,
|
|
12050
12060
|
/\s+/,
|
|
@@ -12052,7 +12062,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12052
12062
|
/\s*/,
|
|
12053
12063
|
/=\s*/,
|
|
12054
12064
|
/(async\s*)?/,
|
|
12055
|
-
t.lookahead(
|
|
12065
|
+
t.lookahead(z)
|
|
12056
12066
|
],
|
|
12057
12067
|
keywords: "async",
|
|
12058
12068
|
className: {
|
|
@@ -12097,7 +12107,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12097
12107
|
match: d + t.lookahead(":"),
|
|
12098
12108
|
relevance: 0
|
|
12099
12109
|
},
|
|
12100
|
-
|
|
12110
|
+
ee,
|
|
12101
12111
|
{
|
|
12102
12112
|
begin: "(" + e.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
|
|
12103
12113
|
keywords: "return throw case",
|
|
@@ -12107,7 +12117,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
12107
12117
|
e.REGEXP_MODE,
|
|
12108
12118
|
{
|
|
12109
12119
|
className: "function",
|
|
12110
|
-
begin:
|
|
12120
|
+
begin: z,
|
|
12111
12121
|
returnBegin: !0,
|
|
12112
12122
|
end: "\\s*=>",
|
|
12113
12123
|
contains: [{
|
|
@@ -13218,13 +13228,13 @@ app.mount('#app');
|
|
|
13218
13228
|
}
|
|
13219
13229
|
},
|
|
13220
13230
|
setup(e) {
|
|
13221
|
-
let t = e, { state: n, scrollContainer: r, pendingApproval: i, sendMessage: a, clearMessages: o, stop: s, retry: c, regenerate: l, resolveApproval: u } = xl({
|
|
13231
|
+
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({
|
|
13222
13232
|
fetchResponse: t.fetchResponse,
|
|
13223
13233
|
fetchStream: t.fetchStream,
|
|
13224
13234
|
messages: t.initialMessages,
|
|
13225
13235
|
onPersist: t.onPersist,
|
|
13226
13236
|
onClear: t.onClear
|
|
13227
|
-
}),
|
|
13237
|
+
}), p = zs(() => {
|
|
13228
13238
|
let e = i.value?.args;
|
|
13229
13239
|
if (e == null) return "";
|
|
13230
13240
|
try {
|
|
@@ -13233,25 +13243,25 @@ app.mount('#app');
|
|
|
13233
13243
|
} catch {
|
|
13234
13244
|
return String(e);
|
|
13235
13245
|
}
|
|
13236
|
-
}),
|
|
13246
|
+
}), m = zs(() => i.value?.toolName === "request_human_confirmation"), h = zs(() => {
|
|
13237
13247
|
let e = i.value?.args?.options;
|
|
13238
13248
|
return Array.isArray(e) ? e.map(String) : [];
|
|
13239
|
-
}),
|
|
13249
|
+
}), g = /* @__PURE__ */ fn(!1);
|
|
13240
13250
|
Gr(i, () => {
|
|
13241
|
-
|
|
13251
|
+
g.value = !1;
|
|
13242
13252
|
});
|
|
13243
|
-
let
|
|
13244
|
-
function
|
|
13253
|
+
let _ = zs(() => typeof t.canUndo == "function" && !!t.canUndo());
|
|
13254
|
+
function v() {
|
|
13245
13255
|
t.onUndo?.() && (n.error = null);
|
|
13246
13256
|
}
|
|
13247
|
-
let
|
|
13248
|
-
function
|
|
13249
|
-
|
|
13257
|
+
let y = /* @__PURE__ */ fn(""), b = /* @__PURE__ */ fn(!0), x = /* @__PURE__ */ fn(!1), S = /* @__PURE__ */ fn({}), C = zs(() => n.messages.length > 0), w = zs(() => n.messages.some((e) => e.role === "user")), T = zs(() => (t.debugLogs?.length ?? 0) > 0);
|
|
13258
|
+
function E(e) {
|
|
13259
|
+
S.value[e] = !S.value[e];
|
|
13250
13260
|
}
|
|
13251
|
-
function
|
|
13261
|
+
function D(e) {
|
|
13252
13262
|
return e.status === "running" ? "⏳" : e.status === "error" ? "❌" : "✅";
|
|
13253
13263
|
}
|
|
13254
|
-
function
|
|
13264
|
+
function O(e) {
|
|
13255
13265
|
let t = [];
|
|
13256
13266
|
for (let n of e) {
|
|
13257
13267
|
let e = t.length ? t[t.length - 1] : null;
|
|
@@ -13270,46 +13280,46 @@ app.mount('#app');
|
|
|
13270
13280
|
children: e.children
|
|
13271
13281
|
}));
|
|
13272
13282
|
}
|
|
13273
|
-
function
|
|
13283
|
+
function k(e) {
|
|
13274
13284
|
return e === "running" ? "⏳" : e === "error" ? "❌" : "✅";
|
|
13275
13285
|
}
|
|
13276
|
-
function
|
|
13286
|
+
function A(e) {
|
|
13277
13287
|
let t = n.messages[e];
|
|
13278
13288
|
return !!t && t.role === "assistant" && n.loading && e === n.messages.length - 1 && !t.content && !t.reasoning;
|
|
13279
13289
|
}
|
|
13280
|
-
function
|
|
13281
|
-
|
|
13290
|
+
function j() {
|
|
13291
|
+
y.value.trim() && (a(y.value), y.value = "");
|
|
13282
13292
|
}
|
|
13283
|
-
function
|
|
13284
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(),
|
|
13293
|
+
function M(e) {
|
|
13294
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), j());
|
|
13285
13295
|
}
|
|
13286
|
-
function
|
|
13296
|
+
function N(e) {
|
|
13287
13297
|
return new Date(e).toLocaleTimeString("zh-CN", {
|
|
13288
13298
|
hour: "2-digit",
|
|
13289
13299
|
minute: "2-digit"
|
|
13290
13300
|
});
|
|
13291
13301
|
}
|
|
13292
|
-
let
|
|
13302
|
+
let P = zs(() => {
|
|
13293
13303
|
let e = t.getInfo?.();
|
|
13294
13304
|
return {
|
|
13295
13305
|
mcp: e?.mcp?.servers?.length ?? 0,
|
|
13296
13306
|
tools: e?.tools?.length ?? 0
|
|
13297
13307
|
};
|
|
13298
13308
|
});
|
|
13299
|
-
function
|
|
13309
|
+
function F(e) {
|
|
13300
13310
|
navigator.clipboard.writeText(e);
|
|
13301
13311
|
}
|
|
13302
|
-
return (a,
|
|
13312
|
+
return (a, I) => (q(), J("div", { class: Se(["chat-dialog", { collapsed: !b.value }]) }, [
|
|
13303
13313
|
Y("div", Lm, [Y("div", Rm, [
|
|
13304
|
-
|
|
13314
|
+
I[15] ||= Y("span", { class: "header-icon" }, "🤖", -1),
|
|
13305
13315
|
Y("span", zm, V(e.title), 1),
|
|
13306
13316
|
W(n).loading ? (q(), J("span", Bm)) : X("", !0)
|
|
13307
13317
|
]), Y("div", Vm, [
|
|
13308
13318
|
Y("button", {
|
|
13309
|
-
class: Se(["action-btn debug-btn", { active:
|
|
13319
|
+
class: Se(["action-btn debug-btn", { active: x.value }]),
|
|
13310
13320
|
title: "日志 / 执行流程 / Agent 信息",
|
|
13311
|
-
onClick:
|
|
13312
|
-
}, [
|
|
13321
|
+
onClick: I[0] ||= (e) => x.value = !0
|
|
13322
|
+
}, [I[16] ||= Y("svg", {
|
|
13313
13323
|
width: "16",
|
|
13314
13324
|
height: "16",
|
|
13315
13325
|
viewBox: "0 0 24 24",
|
|
@@ -13320,13 +13330,13 @@ app.mount('#app');
|
|
|
13320
13330
|
Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
|
|
13321
13331
|
Y("path", { d: "M9 2h6" }),
|
|
13322
13332
|
Y("path", { d: "M9 18h6" })
|
|
13323
|
-
], -1),
|
|
13333
|
+
], -1), T.value ? (q(), J("span", Hm, V(e.debugLogs?.length), 1)) : X("", !0)], 2),
|
|
13324
13334
|
Y("button", {
|
|
13325
13335
|
class: "action-btn",
|
|
13326
13336
|
title: "清空对话",
|
|
13327
|
-
onClick:
|
|
13328
|
-
disabled: !
|
|
13329
|
-
}, [...
|
|
13337
|
+
onClick: I[1] ||= (...e) => W(o) && W(o)(...e),
|
|
13338
|
+
disabled: !C.value
|
|
13339
|
+
}, [...I[17] ||= [Y("svg", {
|
|
13330
13340
|
width: "16",
|
|
13331
13341
|
height: "16",
|
|
13332
13342
|
viewBox: "0 0 24 24",
|
|
@@ -13336,15 +13346,17 @@ app.mount('#app');
|
|
|
13336
13346
|
}, [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),
|
|
13337
13347
|
Y("button", {
|
|
13338
13348
|
class: "action-btn",
|
|
13339
|
-
onClick:
|
|
13340
|
-
}, [(q(), J("svg", Wm, [
|
|
13349
|
+
onClick: I[2] ||= (e) => b.value = !b.value
|
|
13350
|
+
}, [(q(), J("svg", Wm, [b.value ? (q(), J("path", Gm)) : (q(), J("path", Km))]))])
|
|
13341
13351
|
])]),
|
|
13342
13352
|
zr(Y("div", {
|
|
13343
13353
|
class: "chat-body",
|
|
13344
13354
|
ref_key: "scrollContainer",
|
|
13345
|
-
ref: r
|
|
13355
|
+
ref: r,
|
|
13356
|
+
onScroll: I[5] ||= (...e) => W(d) && W(d)(...e),
|
|
13357
|
+
onWheel: I[6] ||= (...e) => W(f) && W(f)(...e)
|
|
13346
13358
|
}, [
|
|
13347
|
-
|
|
13359
|
+
C.value ? X("", !0) : (q(), J("div", qm, [...I[18] ||= [Y("div", { class: "empty-icon" }, "💬", -1), Y("p", null, "有什么可以帮你的?", -1)]])),
|
|
13348
13360
|
(q(!0), J(K, null, Xi(W(n).messages, (t, r) => (q(), J("div", {
|
|
13349
13361
|
key: r,
|
|
13350
13362
|
class: Se(["message-row", t.role]),
|
|
@@ -13352,143 +13364,143 @@ app.mount('#app');
|
|
|
13352
13364
|
}, [e.showAvatar ? (q(), J("div", Ym, V(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", Xm, [
|
|
13353
13365
|
t.role === "assistant" && t.reasoning ? (q(), J("div", {
|
|
13354
13366
|
key: 0,
|
|
13355
|
-
class: Se(["reasoning-block", { expanded:
|
|
13367
|
+
class: Se(["reasoning-block", { expanded: S.value[r] }])
|
|
13356
13368
|
}, [Y("div", {
|
|
13357
13369
|
class: "reasoning-header",
|
|
13358
|
-
onClick: (e) =>
|
|
13370
|
+
onClick: (e) => E(r)
|
|
13359
13371
|
}, [
|
|
13360
|
-
|
|
13361
|
-
|
|
13362
|
-
Y("span", Qm, V(
|
|
13363
|
-
], 8, Zm),
|
|
13364
|
-
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", eh, [(q(!0), J(K, null, Xi(
|
|
13372
|
+
I[19] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13373
|
+
I[20] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13374
|
+
Y("span", Qm, V(S.value[r] ? "▾" : "▸"), 1)
|
|
13375
|
+
], 8, Zm), S.value[r] ? (q(), J("div", $m, V(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13376
|
+
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", eh, [(q(!0), J(K, null, Xi(O(t.steps), (e, t) => (q(), J("div", {
|
|
13365
13377
|
key: t,
|
|
13366
13378
|
class: "step-item"
|
|
13367
13379
|
}, [Y("div", th, [
|
|
13368
|
-
Y("span", nh, V(
|
|
13380
|
+
Y("span", nh, V(k(e.status)), 1),
|
|
13369
13381
|
Y("span", rh, V(e.name), 1),
|
|
13370
13382
|
e.count > 1 ? (q(), J("span", ih, "×" + V(e.count), 1)) : X("", !0),
|
|
13371
13383
|
e.status === "running" ? (q(), J("span", ah, "执行中…")) : X("", !0)
|
|
13372
|
-
]), e.children && e.children.length ? (q(), J("div", oh, [
|
|
13384
|
+
]), e.children && e.children.length ? (q(), J("div", oh, [I[21] ||= Y("div", { class: "step-children-label" }, "🧬 子 agent 进度", -1), (q(!0), J(K, null, Xi(e.children, (e, t) => (q(), J("div", {
|
|
13373
13385
|
key: t,
|
|
13374
13386
|
class: "step-child"
|
|
13375
13387
|
}, [
|
|
13376
|
-
Y("span", sh, V(
|
|
13388
|
+
Y("span", sh, V(D(e)), 1),
|
|
13377
13389
|
Y("span", ch, V(e.name), 1),
|
|
13378
13390
|
e.status === "running" ? (q(), J("span", lh, "…")) : X("", !0)
|
|
13379
13391
|
]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
|
|
13380
|
-
Y("div", { class: Se(["message-bubble", { typing:
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13392
|
+
Y("div", { class: Se(["message-bubble", { typing: A(r) }]) }, [A(r) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13393
|
+
I[22] ||= Y("span", { class: "dot" }, null, -1),
|
|
13394
|
+
I[23] ||= Y("span", { class: "dot" }, null, -1),
|
|
13395
|
+
I[24] ||= Y("span", { class: "dot" }, null, -1)
|
|
13384
13396
|
], 64)) : (q(), J("span", uh, "思考中…"))], 64)) : (q(), J(K, { key: 1 }, [t.role === "assistant" ? (q(), Ko(ef, {
|
|
13385
13397
|
key: 0,
|
|
13386
13398
|
content: t.content
|
|
13387
13399
|
}, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [is(V(t.content), 1)], 64))], 64))], 2),
|
|
13388
13400
|
t.role === "assistant" && W(n).loading && r === W(n).messages.length - 1 && t.content ? (q(), J("span", dh)) : X("", !0),
|
|
13389
|
-
Y("div", fh, V(
|
|
13401
|
+
Y("div", fh, V(N(t.timestamp)), 1),
|
|
13390
13402
|
t.role === "assistant" && t.content && !W(n).loading && r === W(n).messages.length - 1 ? (q(), J("div", ph, [Y("button", {
|
|
13391
13403
|
class: "msg-action-btn",
|
|
13392
13404
|
title: "复制",
|
|
13393
|
-
onClick: (e) =>
|
|
13405
|
+
onClick: (e) => F(t.content)
|
|
13394
13406
|
}, "📋 复制", 8, mh), Y("button", {
|
|
13395
13407
|
class: "msg-action-btn",
|
|
13396
13408
|
title: "重新生成",
|
|
13397
|
-
onClick:
|
|
13409
|
+
onClick: I[3] ||= (...e) => W(l) && W(l)(...e)
|
|
13398
13410
|
}, "🔄 重新生成")])) : X("", !0)
|
|
13399
13411
|
])], 10, Jm))), 128)),
|
|
13400
13412
|
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 }, [
|
|
13401
|
-
|
|
13402
|
-
|
|
13403
|
-
|
|
13413
|
+
I[25] ||= Y("span", { class: "dot" }, null, -1),
|
|
13414
|
+
I[26] ||= Y("span", { class: "dot" }, null, -1),
|
|
13415
|
+
I[27] ||= Y("span", { class: "dot" }, null, -1)
|
|
13404
13416
|
], 64)) : (q(), J("span", yh, "思考中…"))])])])) : X("", !0),
|
|
13405
13417
|
W(n).error ? (q(), J("div", bh, [
|
|
13406
13418
|
Y("span", xh, V(W(n).error), 1),
|
|
13407
|
-
|
|
13419
|
+
w.value ? (q(), J("button", {
|
|
13408
13420
|
key: 0,
|
|
13409
13421
|
class: "retry-btn",
|
|
13410
|
-
onClick:
|
|
13422
|
+
onClick: I[4] ||= (...e) => W(c) && W(c)(...e)
|
|
13411
13423
|
}, "重试")) : X("", !0),
|
|
13412
|
-
|
|
13424
|
+
_.value ? (q(), J("button", {
|
|
13413
13425
|
key: 1,
|
|
13414
13426
|
class: "undo-btn",
|
|
13415
13427
|
title: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
13416
|
-
onClick:
|
|
13428
|
+
onClick: v
|
|
13417
13429
|
}, "↩ 回退")) : X("", !0)
|
|
13418
13430
|
])) : X("", !0)
|
|
13419
|
-
],
|
|
13420
|
-
W(i) ? (q(), J("div", Sh, [
|
|
13421
|
-
|
|
13431
|
+
], 544), [[xc, b.value]]),
|
|
13432
|
+
W(i) ? (q(), J("div", Sh, [m.value ? (q(), J(K, { key: 0 }, [
|
|
13433
|
+
I[28] ||= Y("div", { class: "approval-head" }, [Y("span", { class: "approval-icon" }, "❓"), Y("span", { class: "approval-title" }, "AI 需要你确认")], -1),
|
|
13422
13434
|
W(i).args?.question ? (q(), J("div", Ch, V(W(i).args.question), 1)) : X("", !0),
|
|
13423
13435
|
W(i).args?.context ? (q(), J("div", wh, V(W(i).args.context), 1)) : X("", !0),
|
|
13424
13436
|
W(i).args?.recommendation ? (q(), J("div", Th, "💡 推荐:" + V(W(i).args.recommendation), 1)) : X("", !0),
|
|
13425
13437
|
Y("div", Eh, [Y("button", {
|
|
13426
13438
|
class: "approval-deny",
|
|
13427
|
-
onClick:
|
|
13428
|
-
}, "拒绝"),
|
|
13439
|
+
onClick: I[7] ||= (e) => W(u)(!1)
|
|
13440
|
+
}, "拒绝"), h.value.length ? (q(!0), J(K, { key: 0 }, Xi(h.value, (e) => (q(), J("button", {
|
|
13429
13441
|
key: e,
|
|
13430
13442
|
class: "approval-opt",
|
|
13431
13443
|
onClick: (t) => W(u)(e)
|
|
13432
13444
|
}, V(e), 9, Dh))), 128)) : (q(), J("button", {
|
|
13433
13445
|
key: 1,
|
|
13434
13446
|
class: "approval-allow",
|
|
13435
|
-
onClick:
|
|
13447
|
+
onClick: I[8] ||= (e) => W(u)(!0)
|
|
13436
13448
|
}, "允许"))])
|
|
13437
13449
|
], 64)) : (q(), J(K, { key: 1 }, [
|
|
13438
13450
|
Y("div", Oh, [
|
|
13439
|
-
|
|
13440
|
-
Y("span", kh, [
|
|
13441
|
-
|
|
13451
|
+
I[30] ||= Y("span", { class: "approval-icon" }, "✋", -1),
|
|
13452
|
+
Y("span", kh, [I[29] ||= is("需确认工具调用:", -1), Y("code", null, V(W(i).toolName), 1)]),
|
|
13453
|
+
p.value ? (q(), J("button", {
|
|
13442
13454
|
key: 0,
|
|
13443
13455
|
class: "approval-toggle",
|
|
13444
|
-
onClick:
|
|
13445
|
-
}, V(
|
|
13456
|
+
onClick: I[9] ||= (e) => g.value = !g.value
|
|
13457
|
+
}, V(g.value ? "收起参数" : "查看参数") + V(g.value ? " ▴" : " ▾"), 1)) : X("", !0)
|
|
13446
13458
|
]),
|
|
13447
|
-
|
|
13459
|
+
p.value && g.value ? (q(), J("pre", Ah, V(p.value), 1)) : X("", !0),
|
|
13448
13460
|
Y("div", jh, [Y("button", {
|
|
13449
13461
|
class: "approval-deny",
|
|
13450
|
-
onClick:
|
|
13462
|
+
onClick: I[10] ||= (e) => W(u)(!1)
|
|
13451
13463
|
}, "拒绝"), Y("button", {
|
|
13452
13464
|
class: "approval-allow",
|
|
13453
|
-
onClick:
|
|
13465
|
+
onClick: I[11] ||= (e) => W(u)(!0)
|
|
13454
13466
|
}, "允许")])
|
|
13455
13467
|
], 64))])) : X("", !0),
|
|
13456
13468
|
zr(Y("div", Mh, [
|
|
13457
|
-
t.getInfo ? (q(), J("span", Nh, " 🔌" + V(
|
|
13458
|
-
|
|
13469
|
+
t.getInfo ? (q(), J("span", Nh, " 🔌" + V(P.value.mcp) + " · 🔧" + V(P.value.tools), 1)) : X("", !0),
|
|
13470
|
+
_.value ? (q(), J("button", {
|
|
13459
13471
|
key: 1,
|
|
13460
13472
|
class: "undo-foot-btn",
|
|
13461
13473
|
title: "回退到上次正常状态(还原对话历史 + 页面属性 + 工作区)",
|
|
13462
|
-
onClick:
|
|
13474
|
+
onClick: v
|
|
13463
13475
|
}, "↩ 回退")) : X("", !0),
|
|
13464
13476
|
zr(Y("textarea", {
|
|
13465
|
-
"onUpdate:modelValue":
|
|
13477
|
+
"onUpdate:modelValue": I[12] ||= (e) => y.value = e,
|
|
13466
13478
|
class: "chat-input",
|
|
13467
13479
|
placeholder: e.placeholder,
|
|
13468
13480
|
rows: "1",
|
|
13469
|
-
onKeydown:
|
|
13470
|
-
}, null, 40, Ph), [[rl,
|
|
13481
|
+
onKeydown: M
|
|
13482
|
+
}, null, 40, Ph), [[rl, y.value]]),
|
|
13471
13483
|
Y("button", {
|
|
13472
13484
|
class: Se(["send-btn", { "stop-btn": W(n).loading }]),
|
|
13473
|
-
disabled: !W(n).loading && !
|
|
13485
|
+
disabled: !W(n).loading && !y.value.trim(),
|
|
13474
13486
|
title: W(n).loading ? "停止生成" : "发送",
|
|
13475
|
-
onClick:
|
|
13476
|
-
}, [W(n).loading ? (q(), J("svg", Ih, [...
|
|
13487
|
+
onClick: I[13] ||= (e) => W(n).loading ? W(s)() : j()
|
|
13488
|
+
}, [W(n).loading ? (q(), J("svg", Ih, [...I[31] ||= [Y("rect", {
|
|
13477
13489
|
x: "6",
|
|
13478
13490
|
y: "6",
|
|
13479
13491
|
width: "12",
|
|
13480
13492
|
height: "12",
|
|
13481
13493
|
rx: "2"
|
|
13482
|
-
}, null, -1)]])) : (q(), J("svg", Lh, [...
|
|
13494
|
+
}, null, -1)]])) : (q(), J("svg", Lh, [...I[32] ||= [Y("line", {
|
|
13483
13495
|
x1: "22",
|
|
13484
13496
|
y1: "2",
|
|
13485
13497
|
x2: "11",
|
|
13486
13498
|
y2: "13"
|
|
13487
13499
|
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10, Fh)
|
|
13488
|
-
], 512), [[xc,
|
|
13500
|
+
], 512), [[xc, b.value]]),
|
|
13489
13501
|
$o(Im, {
|
|
13490
|
-
visible:
|
|
13491
|
-
"onUpdate:visible":
|
|
13502
|
+
visible: x.value,
|
|
13503
|
+
"onUpdate:visible": I[14] ||= (e) => x.value = e,
|
|
13492
13504
|
logs: e.debugLogs,
|
|
13493
13505
|
"get-info": t.getInfo
|
|
13494
13506
|
}, null, 8, [
|
|
@@ -13498,7 +13510,7 @@ app.mount('#app');
|
|
|
13498
13510
|
])
|
|
13499
13511
|
], 2));
|
|
13500
13512
|
}
|
|
13501
|
-
}), [["__scopeId", "data-v-
|
|
13513
|
+
}), [["__scopeId", "data-v-10d2a0a3"]]);
|
|
13502
13514
|
function zh(e) {
|
|
13503
13515
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13504
13516
|
}
|
|
@@ -13792,8 +13804,11 @@ function ng(e, t) {
|
|
|
13792
13804
|
}
|
|
13793
13805
|
//#endregion
|
|
13794
13806
|
//#region src/core/harness/createAgent.ts
|
|
13795
|
-
|
|
13796
|
-
|
|
13807
|
+
function rg(e) {
|
|
13808
|
+
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
13809
|
+
}
|
|
13810
|
+
var ig = 10, ag = 300, og = 6e3;
|
|
13811
|
+
function sg(e, t) {
|
|
13797
13812
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
13798
13813
|
if (n <= t) return e;
|
|
13799
13814
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -13808,8 +13823,8 @@ function og(e, t) {
|
|
|
13808
13823
|
});
|
|
13809
13824
|
});
|
|
13810
13825
|
}
|
|
13811
|
-
function
|
|
13812
|
-
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m =
|
|
13826
|
+
function cg(e) {
|
|
13827
|
+
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = ig, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = Wh({
|
|
13813
13828
|
model: c,
|
|
13814
13829
|
contextWindow: e.contextWindow,
|
|
13815
13830
|
maxOutputTokens: e.maxOutputTokens
|
|
@@ -13820,10 +13835,10 @@ function sg(e) {
|
|
|
13820
13835
|
type: e,
|
|
13821
13836
|
data: t
|
|
13822
13837
|
};
|
|
13823
|
-
T.value.push(n), T.value.length >
|
|
13838
|
+
T.value.push(n), T.value.length > ag && T.value.splice(0, T.value.length - ag), gn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
13824
13839
|
}
|
|
13825
13840
|
let D = (e) => {
|
|
13826
|
-
T.value.push(e), T.value.length >
|
|
13841
|
+
T.value.push(e), T.value.length > ag && T.value.splice(0, T.value.length - ag), gn(T);
|
|
13827
13842
|
}, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new s({
|
|
13828
13843
|
apiKey: t,
|
|
13829
13844
|
model: c,
|
|
@@ -13926,12 +13941,12 @@ function sg(e) {
|
|
|
13926
13941
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
13927
13942
|
}
|
|
13928
13943
|
function R(e, t) {
|
|
13929
|
-
return
|
|
13944
|
+
return sg(e, t);
|
|
13930
13945
|
}
|
|
13931
|
-
function
|
|
13946
|
+
function z(e) {
|
|
13932
13947
|
return e.map((e) => {
|
|
13933
13948
|
let t = L(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
13934
|
-
r && (n.content = r.length >
|
|
13949
|
+
r && (n.content = r.length > og ? r.slice(0, og) + `…(截断 ${r.length - og} 字符)` : r);
|
|
13935
13950
|
let i = e.tool_calls;
|
|
13936
13951
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
13937
13952
|
id: e.id,
|
|
@@ -13945,7 +13960,7 @@ function sg(e) {
|
|
|
13945
13960
|
return a && (n.tool_call_id = a), n;
|
|
13946
13961
|
});
|
|
13947
13962
|
}
|
|
13948
|
-
async function
|
|
13963
|
+
async function ee(e, t, n) {
|
|
13949
13964
|
T.value = [], j = Jh(), j.messages = e, j = await Xh(p, j);
|
|
13950
13965
|
let r = e;
|
|
13951
13966
|
for (let e of p) if (e.compressInput) {
|
|
@@ -13961,7 +13976,7 @@ function sg(e) {
|
|
|
13961
13976
|
tools: O.map((e) => e.name),
|
|
13962
13977
|
middleware: p.map((e) => e.name)
|
|
13963
13978
|
});
|
|
13964
|
-
let l = tg(p, (e) => F(e, t, n)), u = ng(p, I), d = 0, f = null;
|
|
13979
|
+
let l = tg(p, (e) => F(e, t, n)), u = ng(p, I), d = 0, f = null, h = 0;
|
|
13965
13980
|
try {
|
|
13966
13981
|
for (; d < m && !n?.aborted;) {
|
|
13967
13982
|
t({
|
|
@@ -13974,7 +13989,7 @@ function sg(e) {
|
|
|
13974
13989
|
round: d + 1,
|
|
13975
13990
|
model: c,
|
|
13976
13991
|
tools: O.map((e) => e.name),
|
|
13977
|
-
messages:
|
|
13992
|
+
messages: z(s)
|
|
13978
13993
|
});
|
|
13979
13994
|
let e = await l({
|
|
13980
13995
|
messages: s,
|
|
@@ -13989,6 +14004,14 @@ function sg(e) {
|
|
|
13989
14004
|
content: e.content
|
|
13990
14005
|
}), e.content;
|
|
13991
14006
|
if (!e.toolCalls.length) {
|
|
14007
|
+
if (h < 2 && rg(e.content)) {
|
|
14008
|
+
h += 1, E("middleware", {
|
|
14009
|
+
stage: "format_retry",
|
|
14010
|
+
attempt: h,
|
|
14011
|
+
content: e.content.slice(0, 200)
|
|
14012
|
+
}), s.push(new i("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签,如 <|tool_calls|>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。")), d += 1;
|
|
14013
|
+
continue;
|
|
14014
|
+
}
|
|
13992
14015
|
if (v > 0 && j.verifyAttempts < v) {
|
|
13993
14016
|
let t = await eg(p, {
|
|
13994
14017
|
messages: s,
|
|
@@ -14075,7 +14098,7 @@ function sg(e) {
|
|
|
14075
14098
|
round: "wrap_up",
|
|
14076
14099
|
model: c,
|
|
14077
14100
|
tools: [],
|
|
14078
|
-
messages:
|
|
14101
|
+
messages: z(r)
|
|
14079
14102
|
});
|
|
14080
14103
|
let i = await F({
|
|
14081
14104
|
messages: r,
|
|
@@ -14102,15 +14125,15 @@ function sg(e) {
|
|
|
14102
14125
|
}
|
|
14103
14126
|
}
|
|
14104
14127
|
}
|
|
14105
|
-
async function
|
|
14128
|
+
async function te(e, t) {
|
|
14106
14129
|
let n = "";
|
|
14107
|
-
return await
|
|
14130
|
+
return await ee(e, (e) => {
|
|
14108
14131
|
e.type === "done" && (n = e.content);
|
|
14109
14132
|
}, t), n;
|
|
14110
14133
|
}
|
|
14111
14134
|
return {
|
|
14112
|
-
invoke:
|
|
14113
|
-
stream:
|
|
14135
|
+
invoke: te,
|
|
14136
|
+
stream: ee,
|
|
14114
14137
|
getState: () => j,
|
|
14115
14138
|
allTools: O,
|
|
14116
14139
|
debugLogs: T
|
|
@@ -14118,14 +14141,14 @@ function sg(e) {
|
|
|
14118
14141
|
}
|
|
14119
14142
|
//#endregion
|
|
14120
14143
|
//#region src/core/harness/todos.ts
|
|
14121
|
-
function
|
|
14144
|
+
function lg(e) {
|
|
14122
14145
|
if (e.length) return [
|
|
14123
14146
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14124
14147
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14125
14148
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14126
14149
|
].join("\n");
|
|
14127
14150
|
}
|
|
14128
|
-
function
|
|
14151
|
+
function ug(e = []) {
|
|
14129
14152
|
let r = e.map((e) => ({ ...e })), i = 0;
|
|
14130
14153
|
return {
|
|
14131
14154
|
name: "todos",
|
|
@@ -14143,7 +14166,7 @@ function lg(e = []) {
|
|
|
14143
14166
|
})],
|
|
14144
14167
|
beforeAgent: () => ({ todos: r }),
|
|
14145
14168
|
beforeModel: () => (i = 0, { todos: r }),
|
|
14146
|
-
augmentPrompt: () =>
|
|
14169
|
+
augmentPrompt: () => lg(r),
|
|
14147
14170
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14148
14171
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14149
14172
|
status: "error"
|
|
@@ -14155,18 +14178,18 @@ function lg(e = []) {
|
|
|
14155
14178
|
}
|
|
14156
14179
|
//#endregion
|
|
14157
14180
|
//#region src/core/harness/skills.ts
|
|
14158
|
-
function
|
|
14181
|
+
function dg(e) {
|
|
14159
14182
|
return e;
|
|
14160
14183
|
}
|
|
14161
|
-
var
|
|
14162
|
-
function fg(e) {
|
|
14163
|
-
return dg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14164
|
-
}
|
|
14184
|
+
var fg = /^https?:\/\//i;
|
|
14165
14185
|
function pg(e) {
|
|
14186
|
+
return fg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14187
|
+
}
|
|
14188
|
+
function mg(e) {
|
|
14166
14189
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14167
14190
|
}
|
|
14168
|
-
async function
|
|
14169
|
-
if (
|
|
14191
|
+
async function hg(e, t) {
|
|
14192
|
+
if (pg(e) === "http") try {
|
|
14170
14193
|
let t = await fetch(e);
|
|
14171
14194
|
return t.ok ? {
|
|
14172
14195
|
ok: !0,
|
|
@@ -14189,7 +14212,7 @@ async function mg(e, t) {
|
|
|
14189
14212
|
ok: !1,
|
|
14190
14213
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14191
14214
|
};
|
|
14192
|
-
let n = t(
|
|
14215
|
+
let n = t(mg(e));
|
|
14193
14216
|
return n == null ? {
|
|
14194
14217
|
ok: !1,
|
|
14195
14218
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14198,14 +14221,14 @@ async function mg(e, t) {
|
|
|
14198
14221
|
content: n
|
|
14199
14222
|
};
|
|
14200
14223
|
}
|
|
14201
|
-
function
|
|
14224
|
+
function gg(e) {
|
|
14202
14225
|
if (e.length) return [
|
|
14203
14226
|
"## 可用 Skills(渐进式披露)",
|
|
14204
14227
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14205
14228
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14206
14229
|
].join("\n");
|
|
14207
14230
|
}
|
|
14208
|
-
function
|
|
14231
|
+
function _g(e, r) {
|
|
14209
14232
|
let i = new Map(e.map((e) => [e.name, e])), a = /* @__PURE__ */ new Set();
|
|
14210
14233
|
return {
|
|
14211
14234
|
name: "skills",
|
|
@@ -14215,7 +14238,7 @@ function gg(e, r) {
|
|
|
14215
14238
|
if (a.has(e)) return `skill "${e}" 已在本轮加载,无需重复。`;
|
|
14216
14239
|
let n;
|
|
14217
14240
|
if (t.doc) {
|
|
14218
|
-
let i = await
|
|
14241
|
+
let i = await hg(t.doc, r?.readVfs);
|
|
14219
14242
|
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14220
14243
|
n = i.content;
|
|
14221
14244
|
} else if (t.getContent) n = await t.getContent();
|
|
@@ -14233,13 +14256,13 @@ function gg(e, r) {
|
|
|
14233
14256
|
})),
|
|
14234
14257
|
skillsLoaded: []
|
|
14235
14258
|
}),
|
|
14236
|
-
augmentPrompt: () =>
|
|
14259
|
+
augmentPrompt: () => gg(e),
|
|
14237
14260
|
afterModel: () => ({ skillsLoaded: [...a] })
|
|
14238
14261
|
};
|
|
14239
14262
|
}
|
|
14240
14263
|
//#endregion
|
|
14241
14264
|
//#region src/core/harness/memory.ts
|
|
14242
|
-
function
|
|
14265
|
+
function vg(e = "") {
|
|
14243
14266
|
let t = e;
|
|
14244
14267
|
return {
|
|
14245
14268
|
name: "memory",
|
|
@@ -14252,12 +14275,12 @@ function _g(e = "") {
|
|
|
14252
14275
|
}
|
|
14253
14276
|
//#endregion
|
|
14254
14277
|
//#region src/core/harness/permissions.ts
|
|
14255
|
-
var
|
|
14278
|
+
var yg = /* @__PURE__ */ new Set([
|
|
14256
14279
|
"set_window_prop",
|
|
14257
14280
|
"delete_window_prop",
|
|
14258
14281
|
"vfs_write",
|
|
14259
14282
|
"vfs_edit"
|
|
14260
|
-
]),
|
|
14283
|
+
]), bg = /* @__PURE__ */ new Set([
|
|
14261
14284
|
"get_window_prop",
|
|
14262
14285
|
"describe_window_prop",
|
|
14263
14286
|
"list_window_props",
|
|
@@ -14266,7 +14289,7 @@ var vg = /* @__PURE__ */ new Set([
|
|
|
14266
14289
|
"vfs_glob",
|
|
14267
14290
|
"vfs_grep"
|
|
14268
14291
|
]);
|
|
14269
|
-
function
|
|
14292
|
+
function xg(e) {
|
|
14270
14293
|
let t = "";
|
|
14271
14294
|
for (let n = 0; n < e.length; n++) {
|
|
14272
14295
|
let r = e[n];
|
|
@@ -14274,16 +14297,16 @@ function bg(e) {
|
|
|
14274
14297
|
}
|
|
14275
14298
|
return RegExp("^" + t + "$");
|
|
14276
14299
|
}
|
|
14277
|
-
function
|
|
14278
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14300
|
+
function Sg(e, t, n) {
|
|
14301
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => xg(e).test(n))) return r.mode;
|
|
14279
14302
|
return "allow";
|
|
14280
14303
|
}
|
|
14281
|
-
function
|
|
14304
|
+
function Cg(e) {
|
|
14282
14305
|
return {
|
|
14283
14306
|
name: "permissions",
|
|
14284
14307
|
wrapToolCall: async (t, n) => {
|
|
14285
|
-
let r =
|
|
14286
|
-
return r && i &&
|
|
14308
|
+
let r = yg.has(t.name) ? "write" : bg.has(t.name) ? "read" : null, i = t.args?.path || "";
|
|
14309
|
+
return r && i && Sg(e, r, i) === "deny" ? {
|
|
14287
14310
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14288
14311
|
status: "error"
|
|
14289
14312
|
} : n(t);
|
|
@@ -14292,7 +14315,7 @@ function Sg(e) {
|
|
|
14292
14315
|
}
|
|
14293
14316
|
//#endregion
|
|
14294
14317
|
//#region src/core/harness/approval.ts
|
|
14295
|
-
function
|
|
14318
|
+
function wg(e = {}) {
|
|
14296
14319
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14297
14320
|
return {
|
|
14298
14321
|
name: "approval",
|
|
@@ -14326,15 +14349,15 @@ function Cg(e = {}) {
|
|
|
14326
14349
|
}
|
|
14327
14350
|
//#endregion
|
|
14328
14351
|
//#region src/core/harness/humanConfirm.ts
|
|
14329
|
-
var
|
|
14352
|
+
var Tg = "request_human_confirmation", Eg = t.object({
|
|
14330
14353
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14331
14354
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14332
14355
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14333
14356
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14334
14357
|
});
|
|
14335
|
-
function
|
|
14358
|
+
function Dg() {
|
|
14336
14359
|
return n(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14337
|
-
name:
|
|
14360
|
+
name: Tg,
|
|
14338
14361
|
description: [
|
|
14339
14362
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14340
14363
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14344,10 +14367,10 @@ function Eg() {
|
|
|
14344
14367
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14345
14368
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14346
14369
|
].join(""),
|
|
14347
|
-
schema:
|
|
14370
|
+
schema: Eg
|
|
14348
14371
|
});
|
|
14349
14372
|
}
|
|
14350
|
-
function
|
|
14373
|
+
function Og() {
|
|
14351
14374
|
return {
|
|
14352
14375
|
name: "humanConfirm",
|
|
14353
14376
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14379,14 +14402,14 @@ function Dg() {
|
|
|
14379
14402
|
}
|
|
14380
14403
|
//#endregion
|
|
14381
14404
|
//#region src/core/harness/checkpoint.ts
|
|
14382
|
-
function
|
|
14405
|
+
function kg(e) {
|
|
14383
14406
|
if (typeof e != "object" || !e) return e;
|
|
14384
14407
|
if (typeof structuredClone == "function") try {
|
|
14385
14408
|
return structuredClone(e);
|
|
14386
14409
|
} catch {}
|
|
14387
14410
|
return JSON.parse(JSON.stringify(e));
|
|
14388
14411
|
}
|
|
14389
|
-
function
|
|
14412
|
+
function Ag(e, t) {
|
|
14390
14413
|
let n = t.split("."), r = e;
|
|
14391
14414
|
for (let e of n) {
|
|
14392
14415
|
if (r == null) return;
|
|
@@ -14394,12 +14417,12 @@ function kg(e, t) {
|
|
|
14394
14417
|
}
|
|
14395
14418
|
return r;
|
|
14396
14419
|
}
|
|
14397
|
-
function
|
|
14420
|
+
function jg(e, t, n) {
|
|
14398
14421
|
let r = t.split("."), i = e;
|
|
14399
14422
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14400
14423
|
i[r[r.length - 1]] = n;
|
|
14401
14424
|
}
|
|
14402
|
-
function
|
|
14425
|
+
function Mg(e, t) {
|
|
14403
14426
|
if (Array.isArray(e)) {
|
|
14404
14427
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14405
14428
|
return;
|
|
@@ -14408,11 +14431,11 @@ function jg(e, t) {
|
|
|
14408
14431
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14409
14432
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14410
14433
|
}
|
|
14411
|
-
function
|
|
14412
|
-
let n =
|
|
14413
|
-
typeof n == "object" && n ?
|
|
14434
|
+
function Ng(e, t) {
|
|
14435
|
+
let n = Ag(window, e);
|
|
14436
|
+
typeof n == "object" && n ? Mg(n, t) : jg(window, e, t);
|
|
14414
14437
|
}
|
|
14415
|
-
function
|
|
14438
|
+
function Pg(e) {
|
|
14416
14439
|
let t = e.slice();
|
|
14417
14440
|
for (; t.length;) {
|
|
14418
14441
|
let e = t[t.length - 1];
|
|
@@ -14421,20 +14444,20 @@ function Ng(e) {
|
|
|
14421
14444
|
}
|
|
14422
14445
|
return t;
|
|
14423
14446
|
}
|
|
14424
|
-
function
|
|
14447
|
+
function Fg(e) {
|
|
14425
14448
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14426
14449
|
return {
|
|
14427
14450
|
save(i) {
|
|
14428
|
-
let a =
|
|
14429
|
-
for (let t of e.windowPaths) o[t] =
|
|
14451
|
+
let a = Pg(e.messages), o = {};
|
|
14452
|
+
for (let t of e.windowPaths) o[t] = kg(Ag(window, t));
|
|
14430
14453
|
let s = {
|
|
14431
14454
|
id: r++,
|
|
14432
14455
|
label: i,
|
|
14433
14456
|
timestamp: Date.now(),
|
|
14434
|
-
messages:
|
|
14457
|
+
messages: kg(a),
|
|
14435
14458
|
windowVals: o,
|
|
14436
|
-
vfs:
|
|
14437
|
-
todos:
|
|
14459
|
+
vfs: kg(e.vfsStore.files),
|
|
14460
|
+
todos: kg(e.getTodos()),
|
|
14438
14461
|
messageCount: a.length
|
|
14439
14462
|
};
|
|
14440
14463
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14454,15 +14477,15 @@ function Pg(e) {
|
|
|
14454
14477
|
restore(n) {
|
|
14455
14478
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14456
14479
|
if (!r) return !1;
|
|
14457
|
-
e.messages.splice(0, e.messages.length, ...
|
|
14458
|
-
for (let [e, t] of Object.entries(r.windowVals))
|
|
14480
|
+
e.messages.splice(0, e.messages.length, ...kg(r.messages));
|
|
14481
|
+
for (let [e, t] of Object.entries(r.windowVals)) Ng(e, kg(t));
|
|
14459
14482
|
let i = e.vfsStore.files;
|
|
14460
14483
|
for (let e of Object.keys(i)) delete i[e];
|
|
14461
|
-
return Object.assign(i,
|
|
14484
|
+
return Object.assign(i, kg(r.vfs)), e.todosMw.reset(kg(r.todos)), !0;
|
|
14462
14485
|
}
|
|
14463
14486
|
};
|
|
14464
14487
|
}
|
|
14465
|
-
function
|
|
14488
|
+
function Ig(e) {
|
|
14466
14489
|
let t = !1;
|
|
14467
14490
|
return {
|
|
14468
14491
|
name: "checkpoint",
|
|
@@ -14476,22 +14499,22 @@ function Fg(e) {
|
|
|
14476
14499
|
}
|
|
14477
14500
|
//#endregion
|
|
14478
14501
|
//#region src/core/harness/subagent.ts
|
|
14479
|
-
function
|
|
14502
|
+
function Lg(e) {
|
|
14480
14503
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14481
14504
|
}
|
|
14482
|
-
var
|
|
14505
|
+
var Rg = [
|
|
14483
14506
|
"get_window_prop",
|
|
14484
14507
|
"get_window_paths",
|
|
14485
14508
|
"list_window_props",
|
|
14486
14509
|
"describe_window_prop",
|
|
14487
14510
|
"fetch_document"
|
|
14488
|
-
],
|
|
14489
|
-
async function
|
|
14490
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
14511
|
+
], zg = 1, Bg = 4, Vg = 6, Hg = ["spawn_agent", "spawn_agents"];
|
|
14512
|
+
async function Ug(e, t, n, r, i) {
|
|
14513
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? zg, s = /* @__PURE__ */ new Set([...Rg, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !Hg.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [Wg({
|
|
14491
14514
|
...t,
|
|
14492
14515
|
depth: a + 1
|
|
14493
|
-
})] : [], u =
|
|
14494
|
-
...
|
|
14516
|
+
})] : [], u = cg({
|
|
14517
|
+
...Lg(t.llm) ? { llm: t.llm } : {
|
|
14495
14518
|
apiKey: t.llm.apiKey,
|
|
14496
14519
|
baseUrl: t.llm.baseUrl,
|
|
14497
14520
|
model: e.model ?? t.llm.model,
|
|
@@ -14500,8 +14523,8 @@ async function Hg(e, t, n, r, i) {
|
|
|
14500
14523
|
},
|
|
14501
14524
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读 window / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
14502
14525
|
tools: c,
|
|
14503
|
-
middleware: [...t.skills?.length ? [
|
|
14504
|
-
maxToolRounds: t.maxToolRounds ??
|
|
14526
|
+
middleware: [...t.skills?.length ? [_g(t.skills)] : [], ...l],
|
|
14527
|
+
maxToolRounds: t.maxToolRounds ?? Vg,
|
|
14505
14528
|
onLog: i,
|
|
14506
14529
|
debug: t.debug
|
|
14507
14530
|
});
|
|
@@ -14513,8 +14536,8 @@ async function Hg(e, t, n, r, i) {
|
|
|
14513
14536
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
14514
14537
|
}, n);
|
|
14515
14538
|
}
|
|
14516
|
-
function
|
|
14517
|
-
let r = e.maxParallel ??
|
|
14539
|
+
function Wg(e) {
|
|
14540
|
+
let r = e.maxParallel ?? Bg, i, a, o, s = (e, t) => (n) => {
|
|
14518
14541
|
a && a({
|
|
14519
14542
|
type: "subagent",
|
|
14520
14543
|
taskId: e,
|
|
@@ -14533,7 +14556,7 @@ function Ug(e) {
|
|
|
14533
14556
|
...e,
|
|
14534
14557
|
allowedTools: r
|
|
14535
14558
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
14536
|
-
return await
|
|
14559
|
+
return await Ug({
|
|
14537
14560
|
prompt: t,
|
|
14538
14561
|
role: n,
|
|
14539
14562
|
model: a
|
|
@@ -14552,7 +14575,7 @@ function Ug(e) {
|
|
|
14552
14575
|
})
|
|
14553
14576
|
}), n(async ({ tasks: t }) => (await Vh(t, r, async (t, n) => {
|
|
14554
14577
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
14555
|
-
return
|
|
14578
|
+
return Ug(t, e, i, s(r, a), (e) => o?.({
|
|
14556
14579
|
...e,
|
|
14557
14580
|
source: `子:${a}`
|
|
14558
14581
|
}));
|
|
@@ -14567,8 +14590,8 @@ function Ug(e) {
|
|
|
14567
14590
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
14568
14591
|
};
|
|
14569
14592
|
}
|
|
14570
|
-
var
|
|
14571
|
-
function
|
|
14593
|
+
var Gg = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
14594
|
+
function Kg(e, t) {
|
|
14572
14595
|
let n = e.tools ?? [];
|
|
14573
14596
|
return {
|
|
14574
14597
|
llm: e.llm ?? t.llm,
|
|
@@ -14582,9 +14605,9 @@ function Gg(e, t) {
|
|
|
14582
14605
|
debug: t.debug
|
|
14583
14606
|
};
|
|
14584
14607
|
}
|
|
14585
|
-
function
|
|
14608
|
+
function qg(e, r) {
|
|
14586
14609
|
let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
|
|
14587
|
-
if (!
|
|
14610
|
+
if (!Gg.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
|
|
14588
14611
|
let t = `use_${e.id}`;
|
|
14589
14612
|
return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
|
|
14590
14613
|
}), o, s, c, l = (e, t) => (n) => {
|
|
@@ -14602,8 +14625,8 @@ function Kg(e, r) {
|
|
|
14602
14625
|
return {
|
|
14603
14626
|
name: "subagents",
|
|
14604
14627
|
tools: a.map((e) => n(async ({ task: t }) => {
|
|
14605
|
-
let n =
|
|
14606
|
-
return
|
|
14628
|
+
let n = Kg(e, r);
|
|
14629
|
+
return Ug({ prompt: t }, n, o, l(`use_${e.id}`, e.id), (t) => c?.({
|
|
14607
14630
|
...t,
|
|
14608
14631
|
source: `子:${e.id}`
|
|
14609
14632
|
}));
|
|
@@ -14622,7 +14645,7 @@ function Kg(e, r) {
|
|
|
14622
14645
|
}
|
|
14623
14646
|
//#endregion
|
|
14624
14647
|
//#region src/core/harness/verify.ts
|
|
14625
|
-
function
|
|
14648
|
+
function Jg(e) {
|
|
14626
14649
|
return {
|
|
14627
14650
|
name: "verify",
|
|
14628
14651
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -14634,10 +14657,10 @@ function qg(e) {
|
|
|
14634
14657
|
if (e.adversarial) {
|
|
14635
14658
|
r?.("middleware", {
|
|
14636
14659
|
stage: "adversarial_start",
|
|
14637
|
-
model:
|
|
14660
|
+
model: n_(e.adversarial.llm),
|
|
14638
14661
|
tools: (e.adversarial.tools ?? []).length
|
|
14639
14662
|
});
|
|
14640
|
-
let n = await
|
|
14663
|
+
let n = await o_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
14641
14664
|
if (r?.("middleware", {
|
|
14642
14665
|
stage: "adversarial_done",
|
|
14643
14666
|
clean: n === null,
|
|
@@ -14648,16 +14671,16 @@ function qg(e) {
|
|
|
14648
14671
|
}
|
|
14649
14672
|
};
|
|
14650
14673
|
}
|
|
14651
|
-
var
|
|
14674
|
+
var Yg = /* @__PURE__ */ new Set([
|
|
14652
14675
|
"set_window_prop",
|
|
14653
14676
|
"edit_window_prop",
|
|
14654
14677
|
"delete_window_prop"
|
|
14655
|
-
]),
|
|
14656
|
-
function
|
|
14678
|
+
]), Xg = /校验失败|未在注册表中声明|未注册|不存在|仅支持|必须是/;
|
|
14679
|
+
function Zg(e) {
|
|
14657
14680
|
let t = /* @__PURE__ */ new Map();
|
|
14658
14681
|
for (let n of e) {
|
|
14659
14682
|
let e = n?.tool_calls;
|
|
14660
|
-
if (Array.isArray(e)) for (let n of e)
|
|
14683
|
+
if (Array.isArray(e)) for (let n of e) Yg.has(n.name) && typeof n?.args?.path == "string" && t.set(n.args.path, {
|
|
14661
14684
|
path: n.args.path,
|
|
14662
14685
|
op: n.name,
|
|
14663
14686
|
callId: n.id
|
|
@@ -14665,7 +14688,7 @@ function Xg(e) {
|
|
|
14665
14688
|
}
|
|
14666
14689
|
return [...t.values()];
|
|
14667
14690
|
}
|
|
14668
|
-
function
|
|
14691
|
+
function Qg(e) {
|
|
14669
14692
|
let t = /* @__PURE__ */ new Map();
|
|
14670
14693
|
for (let n of e) {
|
|
14671
14694
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -14673,7 +14696,7 @@ function Zg(e) {
|
|
|
14673
14696
|
}
|
|
14674
14697
|
return t;
|
|
14675
14698
|
}
|
|
14676
|
-
function
|
|
14699
|
+
function $g(e, t) {
|
|
14677
14700
|
if (e == null) return;
|
|
14678
14701
|
let n = e;
|
|
14679
14702
|
for (let e of t.split(".")) {
|
|
@@ -14682,16 +14705,16 @@ function Qg(e, t) {
|
|
|
14682
14705
|
}
|
|
14683
14706
|
return n;
|
|
14684
14707
|
}
|
|
14685
|
-
function
|
|
14708
|
+
function e_(e = {}) {
|
|
14686
14709
|
let t = e.window ?? globalThis.window, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
|
|
14687
14710
|
return async ({ messages: e }) => {
|
|
14688
|
-
let r =
|
|
14711
|
+
let r = Zg(e);
|
|
14689
14712
|
if (!r.length) return { ok: !0 };
|
|
14690
|
-
let i =
|
|
14713
|
+
let i = Qg(e), a = n(), o = [];
|
|
14691
14714
|
for (let { path: e, op: n, callId: s } of r) {
|
|
14692
14715
|
let r = s ? i.get(s) : void 0;
|
|
14693
|
-
if (r &&
|
|
14694
|
-
let c =
|
|
14716
|
+
if (r && Xg.test(r)) continue;
|
|
14717
|
+
let c = $g(t, e);
|
|
14695
14718
|
if (n === "delete_window_prop") c !== void 0 && o.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14696
14719
|
else if (c == null) o.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14697
14720
|
else if (a[e]) {
|
|
@@ -14705,17 +14728,17 @@ function $g(e = {}) {
|
|
|
14705
14728
|
} : { ok: !0 };
|
|
14706
14729
|
};
|
|
14707
14730
|
}
|
|
14708
|
-
function e_(e) {
|
|
14709
|
-
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14710
|
-
}
|
|
14711
14731
|
function t_(e) {
|
|
14712
|
-
return
|
|
14732
|
+
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14713
14733
|
}
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
return n_.test(e);
|
|
14734
|
+
function n_(e) {
|
|
14735
|
+
return t_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
14717
14736
|
}
|
|
14737
|
+
var r_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
14718
14738
|
function i_(e) {
|
|
14739
|
+
return r_.test(e);
|
|
14740
|
+
}
|
|
14741
|
+
function a_(e) {
|
|
14719
14742
|
let t = "", n = "";
|
|
14720
14743
|
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 : "");
|
|
14721
14744
|
return {
|
|
@@ -14723,8 +14746,8 @@ function i_(e) {
|
|
|
14723
14746
|
lastReply: n
|
|
14724
14747
|
};
|
|
14725
14748
|
}
|
|
14726
|
-
async function
|
|
14727
|
-
let { lastUser: i, lastReply: a } =
|
|
14749
|
+
async function o_(e, t, n, r) {
|
|
14750
|
+
let { lastUser: i, lastReply: a } = a_(e);
|
|
14728
14751
|
if (!a) return null;
|
|
14729
14752
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
14730
14753
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -14735,7 +14758,7 @@ async function a_(e, t, n, r) {
|
|
|
14735
14758
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
14736
14759
|
...e.data,
|
|
14737
14760
|
source: "adversarial"
|
|
14738
|
-
}) : void 0, u = await
|
|
14761
|
+
}) : void 0, u = await cg(t_(t) ? {
|
|
14739
14762
|
llm: t,
|
|
14740
14763
|
tools: r,
|
|
14741
14764
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -14760,17 +14783,17 @@ async function a_(e, t, n, r) {
|
|
|
14760
14783
|
stage: "adversarial_verdict",
|
|
14761
14784
|
verdict: u,
|
|
14762
14785
|
source: "adversarial"
|
|
14763
|
-
}),
|
|
14786
|
+
}), i_(u) ? null : u.trim();
|
|
14764
14787
|
}
|
|
14765
14788
|
//#endregion
|
|
14766
14789
|
//#region src/core/mcp/client.ts
|
|
14767
|
-
function
|
|
14790
|
+
function s_(e) {
|
|
14768
14791
|
let t = e?.content;
|
|
14769
14792
|
if (!Array.isArray(t) || !t.length) return "";
|
|
14770
14793
|
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");
|
|
14771
14794
|
return e?.isError ? `工具错误:${n}` : n;
|
|
14772
14795
|
}
|
|
14773
|
-
async function
|
|
14796
|
+
async function c_(e) {
|
|
14774
14797
|
let t = new URL(e.url), n = e.requestInit;
|
|
14775
14798
|
if (e.transport === "http") {
|
|
14776
14799
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -14783,8 +14806,8 @@ async function s_(e) {
|
|
|
14783
14806
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
14784
14807
|
return new r(t);
|
|
14785
14808
|
}
|
|
14786
|
-
function
|
|
14787
|
-
return n(async (n) =>
|
|
14809
|
+
function l_(e, t) {
|
|
14810
|
+
return n(async (n) => s_(await t.callTool({
|
|
14788
14811
|
name: e.name,
|
|
14789
14812
|
arguments: n
|
|
14790
14813
|
})), {
|
|
@@ -14793,21 +14816,21 @@ function c_(e, t) {
|
|
|
14793
14816
|
schema: e.inputSchema
|
|
14794
14817
|
});
|
|
14795
14818
|
}
|
|
14796
|
-
async function
|
|
14797
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
14819
|
+
async function u_(e) {
|
|
14820
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await c_(e), r = new t({
|
|
14798
14821
|
name: "page-agent-sdk",
|
|
14799
14822
|
version: "1.0"
|
|
14800
14823
|
}, { capabilities: {} });
|
|
14801
14824
|
await r.connect(n);
|
|
14802
14825
|
let { tools: i } = await r.listTools();
|
|
14803
14826
|
return {
|
|
14804
|
-
tools: i.map((e) =>
|
|
14827
|
+
tools: i.map((e) => l_(e, r)),
|
|
14805
14828
|
close: () => r.close()
|
|
14806
14829
|
};
|
|
14807
14830
|
}
|
|
14808
14831
|
//#endregion
|
|
14809
14832
|
//#region src/core/utils/rounds.ts
|
|
14810
|
-
function
|
|
14833
|
+
function d_(e) {
|
|
14811
14834
|
let t = [], n = null, r = 0;
|
|
14812
14835
|
for (let i = 0; i < e.length; i++) {
|
|
14813
14836
|
let a = e[i];
|
|
@@ -14821,14 +14844,14 @@ function u_(e) {
|
|
|
14821
14844
|
}
|
|
14822
14845
|
return n && t.push(n), t;
|
|
14823
14846
|
}
|
|
14824
|
-
function
|
|
14847
|
+
function f_(e, t) {
|
|
14825
14848
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
14826
14849
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
14827
14850
|
}
|
|
14828
|
-
var
|
|
14829
|
-
function
|
|
14851
|
+
var p_ = "【更早对话摘要";
|
|
14852
|
+
function m_(e, t) {
|
|
14830
14853
|
if (t <= 0) return { trimmed: !1 };
|
|
14831
|
-
let n =
|
|
14854
|
+
let n = d_(e);
|
|
14832
14855
|
if (n.length <= t) return { trimmed: !1 };
|
|
14833
14856
|
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = "";
|
|
14834
14857
|
for (let t = 0; t < a; t++) {
|
|
@@ -14839,7 +14862,7 @@ function p_(e, t) {
|
|
|
14839
14862
|
}
|
|
14840
14863
|
}
|
|
14841
14864
|
let s = i.map((e) => {
|
|
14842
|
-
let t =
|
|
14865
|
+
let t = f_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? f_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
14843
14866
|
return `- 第${e.round}轮:${t} → ${n}`;
|
|
14844
14867
|
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
14845
14868
|
return {
|
|
@@ -14848,47 +14871,47 @@ function p_(e, t) {
|
|
|
14848
14871
|
deleteCount: r,
|
|
14849
14872
|
summary: {
|
|
14850
14873
|
role: "system",
|
|
14851
|
-
content: c ? `${
|
|
14874
|
+
content: c ? `${p_}(${i.length} 轮,含累积)】\n${c}\n【续】\n${s}` : `${p_}(${i.length} 轮)】\n${s}`,
|
|
14852
14875
|
timestamp: i[0].userMsg.timestamp
|
|
14853
14876
|
}
|
|
14854
14877
|
};
|
|
14855
14878
|
}
|
|
14856
14879
|
//#endregion
|
|
14857
14880
|
//#region src/core/composables/useContextManager.ts
|
|
14858
|
-
var
|
|
14881
|
+
var h_ = {
|
|
14859
14882
|
windowRounds: 6,
|
|
14860
14883
|
summaryThresholdRounds: 8,
|
|
14861
14884
|
toolResultMaxChars: 800,
|
|
14862
14885
|
enableRecall: !0,
|
|
14863
14886
|
recallTopK: 3,
|
|
14864
14887
|
enableLLMSummary: !1
|
|
14865
|
-
},
|
|
14866
|
-
function g_(e) {
|
|
14867
|
-
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !h_.has(e));
|
|
14868
|
-
}
|
|
14888
|
+
}, g_ = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
14869
14889
|
function __(e) {
|
|
14890
|
+
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !g_.has(e));
|
|
14891
|
+
}
|
|
14892
|
+
function v_(e) {
|
|
14870
14893
|
let t = typeof e.content == "string" ? e.content : "";
|
|
14871
14894
|
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);
|
|
14872
14895
|
return Gh(t);
|
|
14873
14896
|
}
|
|
14874
|
-
function
|
|
14875
|
-
let t =
|
|
14876
|
-
for (let n of e.assistantMsgs) t +=
|
|
14897
|
+
function y_(e) {
|
|
14898
|
+
let t = v_(e.userMsg);
|
|
14899
|
+
for (let n of e.assistantMsgs) t += v_(n);
|
|
14877
14900
|
return t;
|
|
14878
14901
|
}
|
|
14879
|
-
function
|
|
14902
|
+
function b_(e, t) {
|
|
14880
14903
|
return e.map((e) => {
|
|
14881
|
-
let n =
|
|
14904
|
+
let n = f_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? f_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
14882
14905
|
if (t && t.size) {
|
|
14883
14906
|
let n = [];
|
|
14884
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
14907
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${f_(e.result, 120)}`);
|
|
14885
14908
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
14886
14909
|
}
|
|
14887
14910
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
14888
14911
|
}).join("\n");
|
|
14889
14912
|
}
|
|
14890
|
-
function
|
|
14891
|
-
let r =
|
|
14913
|
+
function x_(e, t, n) {
|
|
14914
|
+
let r = __(t);
|
|
14892
14915
|
return r.length === 0 ? [] : e.map((e) => {
|
|
14893
14916
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
14894
14917
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -14898,13 +14921,13 @@ function b_(e, t, n) {
|
|
|
14898
14921
|
};
|
|
14899
14922
|
}).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
|
|
14900
14923
|
}
|
|
14901
|
-
function
|
|
14924
|
+
function S_(e = {}) {
|
|
14902
14925
|
let t = {
|
|
14903
|
-
...
|
|
14926
|
+
...h_,
|
|
14904
14927
|
...e
|
|
14905
14928
|
};
|
|
14906
14929
|
async function n(e) {
|
|
14907
|
-
let n =
|
|
14930
|
+
let n = d_(e), r = e.length, i = (t) => ({
|
|
14908
14931
|
messages: e,
|
|
14909
14932
|
stats: {
|
|
14910
14933
|
triggered: !1,
|
|
@@ -14917,9 +14940,9 @@ function x_(e = {}) {
|
|
|
14917
14940
|
}
|
|
14918
14941
|
}), a, o, s;
|
|
14919
14942
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
14920
|
-
if (n.reduce((e, t) => e +
|
|
14943
|
+
if (n.reduce((e, t) => e + y_(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return i("none");
|
|
14921
14944
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, c = 0;
|
|
14922
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
14945
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += y_(n[t]), r >= e) {
|
|
14923
14946
|
c = t + 1;
|
|
14924
14947
|
break;
|
|
14925
14948
|
}
|
|
@@ -14932,12 +14955,12 @@ function x_(e = {}) {
|
|
|
14932
14955
|
}
|
|
14933
14956
|
let c = [...e].reverse().find((e) => e.role === "user")?.content || "", l = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, u, d;
|
|
14934
14957
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
14935
|
-
u = await t.llmInvoke(
|
|
14958
|
+
u = await t.llmInvoke(b_(o, l)), d = s + "llm_summary";
|
|
14936
14959
|
} catch {
|
|
14937
|
-
u =
|
|
14960
|
+
u = b_(o, l), d = s + "index_summary(llm_fallback)";
|
|
14938
14961
|
}
|
|
14939
|
-
else u =
|
|
14940
|
-
let f = t.enableRecall ?
|
|
14962
|
+
else u = b_(o, l), d = s + "index_summary";
|
|
14963
|
+
let f = t.enableRecall ? x_(o, c, t.recallTopK) : [], p = f.length ? f.map((e) => `- 第${e.round}轮:${f_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? f_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", m = [`【对话历史摘要】以下是之前 ${o.length} 轮对话的要点(最新 ${a.length} 轮已完整保留):`, u];
|
|
14941
14964
|
if (p && m.push("\n【与当前问题可能相关的早期对话】", p), t.getRegisteredProps) try {
|
|
14942
14965
|
let e = t.getRegisteredProps();
|
|
14943
14966
|
if (e.length) {
|
|
@@ -14968,10 +14991,10 @@ function x_(e = {}) {
|
|
|
14968
14991
|
return {
|
|
14969
14992
|
compress: n,
|
|
14970
14993
|
config: t,
|
|
14971
|
-
trimToolResults:
|
|
14994
|
+
trimToolResults: C_
|
|
14972
14995
|
};
|
|
14973
14996
|
}
|
|
14974
|
-
function
|
|
14997
|
+
function C_(e, t) {
|
|
14975
14998
|
let n = [];
|
|
14976
14999
|
if (e.forEach((e, t) => {
|
|
14977
15000
|
e instanceof o && n.push(t);
|
|
@@ -14990,8 +15013,8 @@ function S_(e, t) {
|
|
|
14990
15013
|
}
|
|
14991
15014
|
//#endregion
|
|
14992
15015
|
//#region src/core/harness/summarization.ts
|
|
14993
|
-
function
|
|
14994
|
-
let t =
|
|
15016
|
+
function w_(e = {}) {
|
|
15017
|
+
let t = S_(e);
|
|
14995
15018
|
return {
|
|
14996
15019
|
name: "summarization",
|
|
14997
15020
|
compressInput: async (e) => {
|
|
@@ -15005,7 +15028,7 @@ function C_(e = {}) {
|
|
|
15005
15028
|
}
|
|
15006
15029
|
//#endregion
|
|
15007
15030
|
//#region src/core/presets.ts
|
|
15008
|
-
var
|
|
15031
|
+
var T_ = {
|
|
15009
15032
|
pageBuilder: { systemPrompt: "你是页面构建助手。流程:get_window_prop 读取当前页面结构 → set_window_prop / edit_window_prop 修改属性 → 页面实时更新。多步任务先用 write_todos 拆解,逐步推进。" },
|
|
15010
15033
|
researcher: {
|
|
15011
15034
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15019,14 +15042,14 @@ var w_ = {
|
|
|
15019
15042
|
memory: !1,
|
|
15020
15043
|
subagent: !1
|
|
15021
15044
|
} }
|
|
15022
|
-
},
|
|
15045
|
+
}, E_ = { reliableWriteRules: [
|
|
15023
15046
|
"【可靠写入规则】",
|
|
15024
15047
|
"1. 改任何属性前,先用 get_window_prop 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15025
15048
|
"2. 若不确定可操作哪些属性,先 list_window_props 查看当前注册项(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);",
|
|
15026
15049
|
"3. 不确定某属性字段结构时,先 describe_window_prop 看其说明,字段以 describe 返回为准;",
|
|
15027
15050
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15028
15051
|
"5. 优先用 edit_window_prop 增量 patch(只发改动),避免 set 整体重传大 JSON 被截断。"
|
|
15029
|
-
].join("\n") },
|
|
15052
|
+
].join("\n") }, D_ = {
|
|
15030
15053
|
auto: {
|
|
15031
15054
|
summaryThresholdRatio: .5,
|
|
15032
15055
|
windowRatio: .4,
|
|
@@ -15048,8 +15071,8 @@ var w_ = {
|
|
|
15048
15071
|
enableLLMSummary: !0
|
|
15049
15072
|
}
|
|
15050
15073
|
};
|
|
15051
|
-
function
|
|
15052
|
-
let n =
|
|
15074
|
+
function O_(e, t) {
|
|
15075
|
+
let n = D_[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15053
15076
|
return {
|
|
15054
15077
|
...n,
|
|
15055
15078
|
...r,
|
|
@@ -15066,7 +15089,7 @@ function $(e) {
|
|
|
15066
15089
|
};
|
|
15067
15090
|
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)}`;
|
|
15068
15091
|
}
|
|
15069
|
-
function
|
|
15092
|
+
function k_(e) {
|
|
15070
15093
|
return e.slice(0, 10).map((e) => {
|
|
15071
15094
|
let t = e, n = {
|
|
15072
15095
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15075,16 +15098,16 @@ function O_(e) {
|
|
|
15075
15098
|
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;
|
|
15076
15099
|
});
|
|
15077
15100
|
}
|
|
15078
|
-
function
|
|
15101
|
+
function A_(e, t) {
|
|
15079
15102
|
return $({
|
|
15080
15103
|
code: "SCHEMA_INVALID",
|
|
15081
15104
|
path: e,
|
|
15082
15105
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15083
15106
|
hint: `按 describe_window_prop("${e}") 查看格式,修正后重试;改大对象优先用 edit_window_prop 增量 patch(只发改动部分)`,
|
|
15084
|
-
details:
|
|
15107
|
+
details: k_(t)
|
|
15085
15108
|
});
|
|
15086
15109
|
}
|
|
15087
|
-
function
|
|
15110
|
+
function j_(e, t, n) {
|
|
15088
15111
|
let r = n?.message || String(n);
|
|
15089
15112
|
return $({
|
|
15090
15113
|
code: "JSON_PARSE",
|
|
@@ -15093,18 +15116,18 @@ function A_(e, t, n) {
|
|
|
15093
15116
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15094
15117
|
});
|
|
15095
15118
|
}
|
|
15096
|
-
var
|
|
15097
|
-
function
|
|
15119
|
+
var M_ = .9;
|
|
15120
|
+
function N_(e, t = {}) {
|
|
15098
15121
|
let n = Object.create(null);
|
|
15099
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15122
|
+
if (e) for (let [t, r] of Object.entries(e)) n[I_(t)] = {
|
|
15100
15123
|
content: r,
|
|
15101
|
-
updatedAt:
|
|
15124
|
+
updatedAt: R_()
|
|
15102
15125
|
};
|
|
15103
15126
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15104
15127
|
function a() {
|
|
15105
|
-
if (
|
|
15106
|
-
let e = i *
|
|
15107
|
-
for (let [r] of t) if (delete n[r],
|
|
15128
|
+
if (F_(n) <= i) return;
|
|
15129
|
+
let e = i * M_, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15130
|
+
for (let [r] of t) if (delete n[r], F_(n) <= e) break;
|
|
15108
15131
|
}
|
|
15109
15132
|
let o = null;
|
|
15110
15133
|
function s() {
|
|
@@ -15129,7 +15152,7 @@ function M_(e, t = {}) {
|
|
|
15129
15152
|
}
|
|
15130
15153
|
}) };
|
|
15131
15154
|
return r && (l.hydrate = (e) => {
|
|
15132
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15155
|
+
for (let [t, r] of Object.entries(e)) n[I_(t)] = r;
|
|
15133
15156
|
a();
|
|
15134
15157
|
}, l.flush = () => {
|
|
15135
15158
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15138,17 +15161,17 @@ function M_(e, t = {}) {
|
|
|
15138
15161
|
c();
|
|
15139
15162
|
}), l;
|
|
15140
15163
|
}
|
|
15141
|
-
var
|
|
15142
|
-
function
|
|
15143
|
-
|
|
15164
|
+
var P_ = null;
|
|
15165
|
+
function F_(e) {
|
|
15166
|
+
P_ ||= new TextEncoder();
|
|
15144
15167
|
let t = 0;
|
|
15145
|
-
for (let n of Object.values(e)) t +=
|
|
15168
|
+
for (let n of Object.values(e)) t += P_.encode(n.content).length;
|
|
15146
15169
|
return t;
|
|
15147
15170
|
}
|
|
15148
|
-
function
|
|
15171
|
+
function I_(e) {
|
|
15149
15172
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15150
15173
|
}
|
|
15151
|
-
function
|
|
15174
|
+
function L_(e) {
|
|
15152
15175
|
let t = "";
|
|
15153
15176
|
for (let n = 0; n < e.length; n++) {
|
|
15154
15177
|
let r = e[n];
|
|
@@ -15156,13 +15179,13 @@ function I_(e) {
|
|
|
15156
15179
|
}
|
|
15157
15180
|
return RegExp("^" + t + "$");
|
|
15158
15181
|
}
|
|
15159
|
-
function
|
|
15182
|
+
function R_() {
|
|
15160
15183
|
return Date.now();
|
|
15161
15184
|
}
|
|
15162
|
-
function
|
|
15185
|
+
function z_(e) {
|
|
15163
15186
|
return [
|
|
15164
15187
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15165
|
-
let i = e.files[
|
|
15188
|
+
let i = e.files[I_(t)];
|
|
15166
15189
|
if (!i) return $({
|
|
15167
15190
|
code: "NOT_FOUND",
|
|
15168
15191
|
path: t,
|
|
@@ -15180,9 +15203,9 @@ function R_(e) {
|
|
|
15180
15203
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15181
15204
|
})
|
|
15182
15205
|
}),
|
|
15183
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15206
|
+
n(async ({ path: t, content: n }) => (e.files[I_(t)] = {
|
|
15184
15207
|
content: n,
|
|
15185
|
-
updatedAt:
|
|
15208
|
+
updatedAt: R_()
|
|
15186
15209
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15187
15210
|
name: "vfs_write",
|
|
15188
15211
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15192,7 +15215,7 @@ function R_(e) {
|
|
|
15192
15215
|
})
|
|
15193
15216
|
}),
|
|
15194
15217
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15195
|
-
let i =
|
|
15218
|
+
let i = I_(t), a = e.files[i];
|
|
15196
15219
|
if (!a) return $({
|
|
15197
15220
|
code: "NOT_FOUND",
|
|
15198
15221
|
path: t,
|
|
@@ -15222,7 +15245,7 @@ function R_(e) {
|
|
|
15222
15245
|
}
|
|
15223
15246
|
return e.files[i] = {
|
|
15224
15247
|
content: a.content.replace(n, r),
|
|
15225
|
-
updatedAt:
|
|
15248
|
+
updatedAt: R_()
|
|
15226
15249
|
}, `已替换 ${t} 中 1 处。`;
|
|
15227
15250
|
}, {
|
|
15228
15251
|
name: "vfs_edit",
|
|
@@ -15244,7 +15267,7 @@ function R_(e) {
|
|
|
15244
15267
|
n(async ({ pattern: t }) => {
|
|
15245
15268
|
let n;
|
|
15246
15269
|
try {
|
|
15247
|
-
n =
|
|
15270
|
+
n = L_(t);
|
|
15248
15271
|
} catch (e) {
|
|
15249
15272
|
return $({
|
|
15250
15273
|
code: "GLOB_INVALID",
|
|
@@ -15273,7 +15296,7 @@ function R_(e) {
|
|
|
15273
15296
|
details: { pattern: t }
|
|
15274
15297
|
});
|
|
15275
15298
|
}
|
|
15276
|
-
let i = n ? [
|
|
15299
|
+
let i = n ? [I_(n)] : Object.keys(e.files), a = [];
|
|
15277
15300
|
for (let t of i) {
|
|
15278
15301
|
let n = e.files[t];
|
|
15279
15302
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15291,17 +15314,17 @@ function R_(e) {
|
|
|
15291
15314
|
})
|
|
15292
15315
|
];
|
|
15293
15316
|
}
|
|
15294
|
-
function
|
|
15317
|
+
function B_(e) {
|
|
15295
15318
|
return {
|
|
15296
15319
|
name: "vfs",
|
|
15297
|
-
tools:
|
|
15320
|
+
tools: z_(e),
|
|
15298
15321
|
beforeAgent: () => ({ files: e.files })
|
|
15299
15322
|
};
|
|
15300
15323
|
}
|
|
15301
15324
|
//#endregion
|
|
15302
15325
|
//#region src/core/tools/windowQuery.ts
|
|
15303
|
-
var
|
|
15304
|
-
function
|
|
15326
|
+
var V_ = /[\w$-]/;
|
|
15327
|
+
function H_(e) {
|
|
15305
15328
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15306
15329
|
for (; r < n.length;) {
|
|
15307
15330
|
let e = n[r];
|
|
@@ -15312,7 +15335,7 @@ function V_(e) {
|
|
|
15312
15335
|
continue;
|
|
15313
15336
|
}
|
|
15314
15337
|
let e = "";
|
|
15315
|
-
for (; r < n.length &&
|
|
15338
|
+
for (; r < n.length && V_.test(n[r]);) e += n[r++];
|
|
15316
15339
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15317
15340
|
t.push({
|
|
15318
15341
|
type: "descendKey",
|
|
@@ -15325,7 +15348,7 @@ function V_(e) {
|
|
|
15325
15348
|
continue;
|
|
15326
15349
|
}
|
|
15327
15350
|
let e = "";
|
|
15328
|
-
for (; r < n.length &&
|
|
15351
|
+
for (; r < n.length && V_.test(n[r]);) e += n[r++];
|
|
15329
15352
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15330
15353
|
t.push({
|
|
15331
15354
|
type: "key",
|
|
@@ -15381,7 +15404,7 @@ function V_(e) {
|
|
|
15381
15404
|
}
|
|
15382
15405
|
return t;
|
|
15383
15406
|
}
|
|
15384
|
-
function
|
|
15407
|
+
function U_(e) {
|
|
15385
15408
|
let t = [], n = 0, r = e.trim();
|
|
15386
15409
|
for (; n < r.length;) {
|
|
15387
15410
|
let e = r[n];
|
|
@@ -15426,7 +15449,7 @@ function H_(e) {
|
|
|
15426
15449
|
}
|
|
15427
15450
|
return t;
|
|
15428
15451
|
}
|
|
15429
|
-
var
|
|
15452
|
+
var W_ = class {
|
|
15430
15453
|
toks;
|
|
15431
15454
|
item;
|
|
15432
15455
|
pos = 0;
|
|
@@ -15462,12 +15485,12 @@ var U_ = class {
|
|
|
15462
15485
|
return this.next(), e;
|
|
15463
15486
|
}
|
|
15464
15487
|
let e = this.operand(), t = this.peek();
|
|
15465
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15488
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), q_(t, e, this.operand())) : G_(e);
|
|
15466
15489
|
}
|
|
15467
15490
|
operand() {
|
|
15468
15491
|
let e = this.next();
|
|
15469
15492
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15470
|
-
if (e.startsWith("@")) return
|
|
15493
|
+
if (e.startsWith("@")) return K_(e, this.item);
|
|
15471
15494
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15472
15495
|
if (e === "true") return !0;
|
|
15473
15496
|
if (e === "false") return !1;
|
|
@@ -15477,10 +15500,10 @@ var U_ = class {
|
|
|
15477
15500
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15478
15501
|
}
|
|
15479
15502
|
};
|
|
15480
|
-
function
|
|
15503
|
+
function G_(e) {
|
|
15481
15504
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15482
15505
|
}
|
|
15483
|
-
function
|
|
15506
|
+
function K_(e, t) {
|
|
15484
15507
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15485
15508
|
for (let e of n) {
|
|
15486
15509
|
if (typeof r != "object" || !r) return;
|
|
@@ -15488,7 +15511,7 @@ function G_(e, t) {
|
|
|
15488
15511
|
}
|
|
15489
15512
|
return r;
|
|
15490
15513
|
}
|
|
15491
|
-
function
|
|
15514
|
+
function q_(e, t, n) {
|
|
15492
15515
|
switch (e) {
|
|
15493
15516
|
case "==": return t === n;
|
|
15494
15517
|
case "!=": return t !== n;
|
|
@@ -15499,47 +15522,47 @@ function K_(e, t, n) {
|
|
|
15499
15522
|
default: return !1;
|
|
15500
15523
|
}
|
|
15501
15524
|
}
|
|
15502
|
-
function q_(e, t) {
|
|
15503
|
-
return new U_(H_(e), t).parse();
|
|
15504
|
-
}
|
|
15505
15525
|
function J_(e, t) {
|
|
15506
|
-
return
|
|
15526
|
+
return new W_(U_(e), t).parse();
|
|
15507
15527
|
}
|
|
15508
15528
|
function Y_(e, t) {
|
|
15529
|
+
return e ? `${e}.${t}` : String(t);
|
|
15530
|
+
}
|
|
15531
|
+
function X_(e, t) {
|
|
15509
15532
|
let n = [{
|
|
15510
15533
|
path: "",
|
|
15511
15534
|
value: e
|
|
15512
15535
|
}];
|
|
15513
|
-
for (let e of
|
|
15536
|
+
for (let e of H_(t)) {
|
|
15514
15537
|
let t = [];
|
|
15515
15538
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15516
|
-
path:
|
|
15539
|
+
path: Y_(r.path, e.key),
|
|
15517
15540
|
value: r.value[e.key]
|
|
15518
15541
|
});
|
|
15519
15542
|
else if (e.type === "index") {
|
|
15520
15543
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15521
15544
|
let n = r.value[e.index];
|
|
15522
15545
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15523
|
-
path:
|
|
15546
|
+
path: Y_(r.path, e.index),
|
|
15524
15547
|
value: n,
|
|
15525
15548
|
index: e.index
|
|
15526
15549
|
});
|
|
15527
15550
|
}
|
|
15528
15551
|
} else if (e.type === "wildcard") {
|
|
15529
15552
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15530
|
-
path:
|
|
15553
|
+
path: Y_(e.path, r),
|
|
15531
15554
|
value: n,
|
|
15532
15555
|
index: r
|
|
15533
15556
|
}));
|
|
15534
15557
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15535
|
-
path:
|
|
15558
|
+
path: Y_(e.path, n),
|
|
15536
15559
|
value: e.value[n]
|
|
15537
15560
|
});
|
|
15538
15561
|
} else if (e.type === "descendKey") {
|
|
15539
15562
|
let r = e.key, i = (e) => {
|
|
15540
15563
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15541
15564
|
let a = {
|
|
15542
|
-
path:
|
|
15565
|
+
path: Y_(e.path, n),
|
|
15543
15566
|
value: e.value[n]
|
|
15544
15567
|
};
|
|
15545
15568
|
n === r && t.push(a), i(a);
|
|
@@ -15550,7 +15573,7 @@ function Y_(e, t) {
|
|
|
15550
15573
|
let e = (n) => {
|
|
15551
15574
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15552
15575
|
let i = {
|
|
15553
|
-
path:
|
|
15576
|
+
path: Y_(n.path, r),
|
|
15554
15577
|
value: n.value[r]
|
|
15555
15578
|
};
|
|
15556
15579
|
t.push(i), e(i);
|
|
@@ -15559,16 +15582,16 @@ function Y_(e, t) {
|
|
|
15559
15582
|
for (let t of n) e(t);
|
|
15560
15583
|
} else if (e.type === "filter") {
|
|
15561
15584
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15562
|
-
|
|
15563
|
-
path:
|
|
15585
|
+
J_(e.filter, n) && t.push({
|
|
15586
|
+
path: Y_(r.path, i),
|
|
15564
15587
|
value: n,
|
|
15565
15588
|
index: i
|
|
15566
15589
|
});
|
|
15567
15590
|
});
|
|
15568
15591
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15569
15592
|
let i = r.value[n];
|
|
15570
|
-
|
|
15571
|
-
path:
|
|
15593
|
+
J_(e.filter, i) && t.push({
|
|
15594
|
+
path: Y_(r.path, n),
|
|
15572
15595
|
value: i
|
|
15573
15596
|
});
|
|
15574
15597
|
}
|
|
@@ -15577,7 +15600,7 @@ function Y_(e, t) {
|
|
|
15577
15600
|
}
|
|
15578
15601
|
return n;
|
|
15579
15602
|
}
|
|
15580
|
-
function
|
|
15603
|
+
function Z_(e, t) {
|
|
15581
15604
|
let n = e.length, r = t.length;
|
|
15582
15605
|
if (!n) return r;
|
|
15583
15606
|
if (!r) return n;
|
|
@@ -15593,7 +15616,7 @@ function X_(e, t) {
|
|
|
15593
15616
|
}
|
|
15594
15617
|
return i[r];
|
|
15595
15618
|
}
|
|
15596
|
-
function
|
|
15619
|
+
function Q_(e, t, n = {}) {
|
|
15597
15620
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15598
15621
|
if (r === "regex") try {
|
|
15599
15622
|
s = new RegExp(t, "i");
|
|
@@ -15603,11 +15626,11 @@ function Z_(e, t, n = {}) {
|
|
|
15603
15626
|
let c = (e, l, u) => {
|
|
15604
15627
|
if (o.length >= i || e == null) return;
|
|
15605
15628
|
if (typeof e == "object") {
|
|
15606
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15607
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
15629
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, Y_(l, t), String(t)));
|
|
15630
|
+
else for (let t of Object.keys(e)) c(e[t], Y_(l, t), t);
|
|
15608
15631
|
return;
|
|
15609
15632
|
}
|
|
15610
|
-
let d = String(e), f =
|
|
15633
|
+
let d = String(e), f = $_(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15611
15634
|
if (f) {
|
|
15612
15635
|
o.push({
|
|
15613
15636
|
path: l,
|
|
@@ -15618,7 +15641,7 @@ function Z_(e, t, n = {}) {
|
|
|
15618
15641
|
return;
|
|
15619
15642
|
}
|
|
15620
15643
|
if (a && u) {
|
|
15621
|
-
let e =
|
|
15644
|
+
let e = $_(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15622
15645
|
e && o.push({
|
|
15623
15646
|
path: l,
|
|
15624
15647
|
key: u,
|
|
@@ -15629,18 +15652,18 @@ function Z_(e, t, n = {}) {
|
|
|
15629
15652
|
};
|
|
15630
15653
|
return c(e, ""), o;
|
|
15631
15654
|
}
|
|
15632
|
-
function
|
|
15655
|
+
function $_(e, t, n, r, i) {
|
|
15633
15656
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15634
15657
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15635
15658
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15636
15659
|
if (n === "fuzzy") {
|
|
15637
15660
|
if (a.includes(o)) return 2;
|
|
15638
|
-
let e =
|
|
15661
|
+
let e = Z_(a, o);
|
|
15639
15662
|
return e <= r ? r - e + 1 : null;
|
|
15640
15663
|
}
|
|
15641
15664
|
return null;
|
|
15642
15665
|
}
|
|
15643
|
-
var
|
|
15666
|
+
var ev = [
|
|
15644
15667
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15645
15668
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15646
15669
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15653,7 +15676,7 @@ var $_ = [
|
|
|
15653
15676
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15654
15677
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15655
15678
|
].join("\n");
|
|
15656
|
-
function
|
|
15679
|
+
function tv(e, t, n = 3e3) {
|
|
15657
15680
|
return new Promise((r) => {
|
|
15658
15681
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15659
15682
|
if (!a) {
|
|
@@ -15666,7 +15689,7 @@ function ev(e, t, n = 3e3) {
|
|
|
15666
15689
|
elapsedMs: Date.now() - i
|
|
15667
15690
|
});
|
|
15668
15691
|
}
|
|
15669
|
-
}, s =
|
|
15692
|
+
}, s = ev + "\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;
|
|
15670
15693
|
try {
|
|
15671
15694
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15672
15695
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15701,19 +15724,19 @@ function ev(e, t, n = 3e3) {
|
|
|
15701
15724
|
}
|
|
15702
15725
|
//#endregion
|
|
15703
15726
|
//#region src/core/tools/windowOps.ts
|
|
15704
|
-
var
|
|
15727
|
+
var nv = /* @__PURE__ */ new Set([
|
|
15705
15728
|
"__proto__",
|
|
15706
15729
|
"constructor",
|
|
15707
15730
|
"prototype"
|
|
15708
15731
|
]);
|
|
15709
|
-
function
|
|
15710
|
-
return e.split(".").some((e) =>
|
|
15711
|
-
}
|
|
15712
|
-
function rv(e, t) {
|
|
15713
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) tv.has(n) || (e[n] = t[n]);
|
|
15732
|
+
function rv(e) {
|
|
15733
|
+
return e.split(".").some((e) => nv.has(e));
|
|
15714
15734
|
}
|
|
15715
15735
|
function iv(e, t) {
|
|
15716
|
-
if (
|
|
15736
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) nv.has(n) || (e[n] = t[n]);
|
|
15737
|
+
}
|
|
15738
|
+
function av(e, t) {
|
|
15739
|
+
if (rv(t)) return;
|
|
15717
15740
|
let n = t.split("."), r = e;
|
|
15718
15741
|
for (let e of n) {
|
|
15719
15742
|
if (r == null) return;
|
|
@@ -15721,8 +15744,8 @@ function iv(e, t) {
|
|
|
15721
15744
|
}
|
|
15722
15745
|
return r;
|
|
15723
15746
|
}
|
|
15724
|
-
function
|
|
15725
|
-
if (
|
|
15747
|
+
function ov(e, t, n) {
|
|
15748
|
+
if (rv(t)) return;
|
|
15726
15749
|
let r = t.split("."), i = e;
|
|
15727
15750
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15728
15751
|
let t = r[e];
|
|
@@ -15730,8 +15753,8 @@ function av(e, t, n) {
|
|
|
15730
15753
|
}
|
|
15731
15754
|
i[r[r.length - 1]] = n;
|
|
15732
15755
|
}
|
|
15733
|
-
function
|
|
15734
|
-
if (
|
|
15756
|
+
function sv(e, t) {
|
|
15757
|
+
if (rv(t)) return !1;
|
|
15735
15758
|
let n = t.split("."), r = e;
|
|
15736
15759
|
for (let e = 0; e < n.length - 1; e++) {
|
|
15737
15760
|
if (r == null) return !1;
|
|
@@ -15740,10 +15763,10 @@ function ov(e, t) {
|
|
|
15740
15763
|
let i = n[n.length - 1];
|
|
15741
15764
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
15742
15765
|
}
|
|
15743
|
-
function
|
|
15766
|
+
function cv(e) {
|
|
15744
15767
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
15745
15768
|
}
|
|
15746
|
-
function
|
|
15769
|
+
function lv(e, t = Infinity) {
|
|
15747
15770
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
15748
15771
|
try {
|
|
15749
15772
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -15762,30 +15785,35 @@ function cv(e, t = Infinity) {
|
|
|
15762
15785
|
}
|
|
15763
15786
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
15764
15787
|
}
|
|
15765
|
-
function
|
|
15766
|
-
|
|
15767
|
-
|
|
15788
|
+
function uv(e) {
|
|
15789
|
+
let t = lv(e), n = 5381;
|
|
15790
|
+
for (let e = 0; e < t.length; e++) n = (n << 5) + n + t.charCodeAt(e) >>> 0;
|
|
15791
|
+
return n.toString(36);
|
|
15792
|
+
}
|
|
15793
|
+
function dv(e, t, n, r) {
|
|
15794
|
+
if (t === "set") return n ? (ov(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_window_prop)";
|
|
15795
|
+
if (t === "remove") return n ? (sv(e, n), null) : "remove 操作需要 jsonPath";
|
|
15768
15796
|
if (t === "merge") {
|
|
15769
|
-
let t = n ?
|
|
15770
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
15797
|
+
let t = n ? av(e, n) : e;
|
|
15798
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (iv(t, r), null);
|
|
15771
15799
|
}
|
|
15772
|
-
let i = n ?
|
|
15800
|
+
let i = n ? av(e, n) : e;
|
|
15773
15801
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
15774
15802
|
}
|
|
15775
|
-
function
|
|
15776
|
-
if (t === "set")
|
|
15777
|
-
else if (t === "remove")
|
|
15778
|
-
else if (t === "merge")
|
|
15803
|
+
function fv(e, t, n, r) {
|
|
15804
|
+
if (t === "set") ov(window, `${e}.${n}`, r);
|
|
15805
|
+
else if (t === "remove") sv(window, `${e}.${n}`);
|
|
15806
|
+
else if (t === "merge") iv(n ? av(window, `${e}.${n}`) : av(window, e), r);
|
|
15779
15807
|
else {
|
|
15780
|
-
let t = n ?
|
|
15808
|
+
let t = n ? av(window, `${e}.${n}`) : av(window, e);
|
|
15781
15809
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
15782
15810
|
}
|
|
15783
15811
|
}
|
|
15784
|
-
function
|
|
15785
|
-
let n =
|
|
15786
|
-
typeof n == "object" && n ?
|
|
15812
|
+
function pv(e, t) {
|
|
15813
|
+
let n = av(window, e);
|
|
15814
|
+
typeof n == "object" && n ? mv(n, t) : ov(window, e, t);
|
|
15787
15815
|
}
|
|
15788
|
-
function
|
|
15816
|
+
function mv(e, t) {
|
|
15789
15817
|
if (Array.isArray(e)) {
|
|
15790
15818
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
15791
15819
|
return;
|
|
@@ -15794,7 +15822,7 @@ function fv(e, t) {
|
|
|
15794
15822
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
15795
15823
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
15796
15824
|
}
|
|
15797
|
-
function
|
|
15825
|
+
function hv(e, r = {}) {
|
|
15798
15826
|
let i = /* @__PURE__ */ new Map();
|
|
15799
15827
|
for (let t of e) i.set(t.path, t);
|
|
15800
15828
|
let a = /* @__PURE__ */ new Map(), o = r.maxSnapshots ?? 20, s = {
|
|
@@ -15821,7 +15849,7 @@ function pv(e, r = {}) {
|
|
|
15821
15849
|
return r.allowRawRead ? !0 : [...i.keys()].some((t) => e === t || e.startsWith(t + ".") || u && t.startsWith(e + "."));
|
|
15822
15850
|
}
|
|
15823
15851
|
function f(e, t, n) {
|
|
15824
|
-
let r =
|
|
15852
|
+
let r = cv(av(window, e)), i = a.get(e) || [], s = i.length ? i[i.length - 1].id + 1 : 1;
|
|
15825
15853
|
for (i.push({
|
|
15826
15854
|
id: s,
|
|
15827
15855
|
ts: Date.now(),
|
|
@@ -15862,59 +15890,85 @@ function pv(e, r = {}) {
|
|
|
15862
15890
|
message: `属性 "${e}" 不可读取(未注册,且非已注册路径的后代)`,
|
|
15863
15891
|
hint: "用 list_window_props 查看可操作字段;字段白名单读模式下未注册的祖先(整体大 JSON)不暴露,需读其声明子路径"
|
|
15864
15892
|
});
|
|
15865
|
-
let t =
|
|
15866
|
-
return t === void 0 ? `${e} = (undefined)` : `${e} = ${
|
|
15893
|
+
let t = av(window, e);
|
|
15894
|
+
return t === void 0 ? `${e} = (undefined)` : `${e} = ${lv(t)} (hash=${uv(t)})`;
|
|
15867
15895
|
}, {
|
|
15868
15896
|
name: "get_window_prop",
|
|
15869
|
-
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
15897
|
+
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改属性前先 get 拿 hash,写入时(set/edit/delete)传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"(外部代码/其他 agent/用户手动改过会 CONFLICT,需重新 get 再改)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
15870
15898
|
schema: t.object({ path: t.string().describe("已注册的属性路径或其后代") })
|
|
15871
|
-
}), g = n(async ({ path: e, value: t }) => {
|
|
15872
|
-
let
|
|
15873
|
-
if (!
|
|
15899
|
+
}), g = n(async ({ path: e, value: t, expectedHash: n }) => {
|
|
15900
|
+
let r = i.get(e);
|
|
15901
|
+
if (!r) return $({
|
|
15874
15902
|
code: "NOT_REGISTERED",
|
|
15875
15903
|
path: e,
|
|
15876
15904
|
message: `属性 "${e}" 未在注册表中声明,不可写`,
|
|
15877
15905
|
hint: "用 list_window_props 查看可用属性;集成方需先在 windowProps 声明该 path"
|
|
15878
15906
|
});
|
|
15879
|
-
|
|
15907
|
+
if (n !== void 0 && n !== "") {
|
|
15908
|
+
let t = av(window, e), r = uv(t);
|
|
15909
|
+
if (r !== n) return $({
|
|
15910
|
+
code: "VERSION_CONFLICT",
|
|
15911
|
+
path: e,
|
|
15912
|
+
message: `乐观锁冲突:expectedHash=${n} 但当前 hash=${r},属性 "${e}" 在你 get 之后已被修改(外部代码/其他 agent/用户手动改)`,
|
|
15913
|
+
hint: `重新 get_window_prop("${e}") 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${lv(t, 400)}`
|
|
15914
|
+
});
|
|
15915
|
+
}
|
|
15916
|
+
let a;
|
|
15880
15917
|
try {
|
|
15881
|
-
|
|
15918
|
+
a = JSON.parse(t);
|
|
15882
15919
|
} catch (n) {
|
|
15883
|
-
return
|
|
15920
|
+
return j_(e, t, n);
|
|
15884
15921
|
}
|
|
15885
|
-
let
|
|
15886
|
-
if (!
|
|
15922
|
+
let o = r.schema.safeParse(a);
|
|
15923
|
+
if (!o.success) return A_(e, o.error.issues);
|
|
15887
15924
|
f(e, "set");
|
|
15888
|
-
let
|
|
15889
|
-
return typeof
|
|
15925
|
+
let s = av(window, e);
|
|
15926
|
+
return typeof s == "object" && s && o.data !== null && typeof o.data == "object" ? mv(s, o.data) : ov(window, e, o.data), c({
|
|
15890
15927
|
op: "set",
|
|
15891
15928
|
path: e,
|
|
15892
|
-
value:
|
|
15929
|
+
value: o.data,
|
|
15893
15930
|
timestamp: Date.now()
|
|
15894
|
-
}), `已设置 ${e} = ${
|
|
15931
|
+
}), `已设置 ${e} = ${lv(o.data, 600)} (新 hash=${uv(av(window, e))})${l()}`;
|
|
15895
15932
|
}, {
|
|
15896
15933
|
name: "set_window_prop",
|
|
15897
|
-
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema
|
|
15934
|
+
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 get_window_prop 返回的 hash,传入则启用乐观锁——若属性已被改过(外部代码/其他 agent/用户手动)则返回 VERSION_CONFLICT 不写入,需重新 get 再改,防\"基于过期值覆盖\"。大对象/数组强烈建议改用 edit_window_prop 增量 patch。",
|
|
15898
15935
|
schema: t.object({
|
|
15899
15936
|
path: t.string().describe("已注册的属性路径"),
|
|
15900
|
-
value: t.string().describe("JSON 字符串形式的值,需符合该属性 schema")
|
|
15937
|
+
value: t.string().describe("JSON 字符串形式的值,需符合该属性 schema"),
|
|
15938
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝写入防覆盖")
|
|
15901
15939
|
})
|
|
15902
|
-
}), _ = n(async ({ path: e, op: t, jsonPath: n, value: r }) => {
|
|
15903
|
-
let
|
|
15904
|
-
if (!
|
|
15940
|
+
}), _ = n(async ({ path: e, op: t, jsonPath: n, value: r, expectedHash: a }) => {
|
|
15941
|
+
let o = i.get(e);
|
|
15942
|
+
if (!o) return $({
|
|
15905
15943
|
code: "NOT_REGISTERED",
|
|
15906
15944
|
path: e,
|
|
15907
15945
|
message: `属性 "${e}" 未在注册表中声明,不可写`,
|
|
15908
15946
|
hint: "用 list_window_props 查看可用属性"
|
|
15909
15947
|
});
|
|
15910
|
-
let
|
|
15911
|
-
if (
|
|
15948
|
+
let s = n || "";
|
|
15949
|
+
if (rv(s)) return $({
|
|
15912
15950
|
code: "PATH_UNSAFE",
|
|
15913
15951
|
path: e,
|
|
15914
|
-
message: `jsonPath "${
|
|
15952
|
+
message: `jsonPath "${s}" 含非法段(__proto__/constructor/prototype)`,
|
|
15915
15953
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
15916
15954
|
});
|
|
15917
|
-
let
|
|
15955
|
+
let u = av(window, e);
|
|
15956
|
+
if (a !== void 0 && a !== "") {
|
|
15957
|
+
let t = uv(u);
|
|
15958
|
+
if (t !== a) return $({
|
|
15959
|
+
code: "VERSION_CONFLICT",
|
|
15960
|
+
path: e,
|
|
15961
|
+
message: `乐观锁冲突:expectedHash=${a} 但当前 hash=${t},属性 "${e}" 在你 get 之后已被修改(外部代码/其他 agent/用户手动改)`,
|
|
15962
|
+
hint: `重新 get_window_prop("${e}") 拿最新值与 hash,基于最新值修改后再 edit(传新的 expectedHash)。当前值:${lv(u, 400)}`
|
|
15963
|
+
});
|
|
15964
|
+
}
|
|
15965
|
+
if (typeof u != "object" || !u) return $({
|
|
15966
|
+
code: "NOT_OBJECT",
|
|
15967
|
+
path: e,
|
|
15968
|
+
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${u === void 0 ? "undefined" : typeof u}`,
|
|
15969
|
+
hint: "叶子属性(原始类型)请用 set_window_prop 整体设置"
|
|
15970
|
+
});
|
|
15971
|
+
let d;
|
|
15918
15972
|
if (t !== "remove") {
|
|
15919
15973
|
if (r === void 0 || r === "") return $({
|
|
15920
15974
|
code: "MISSING_VALUE",
|
|
@@ -15923,36 +15977,29 @@ function pv(e, r = {}) {
|
|
|
15923
15977
|
hint: `op 为 ${t} 时 value 必填;若想删除请用 op:'remove'`
|
|
15924
15978
|
});
|
|
15925
15979
|
try {
|
|
15926
|
-
|
|
15980
|
+
d = JSON.parse(r);
|
|
15927
15981
|
} catch (t) {
|
|
15928
|
-
return
|
|
15982
|
+
return j_(e, r, t);
|
|
15929
15983
|
}
|
|
15930
15984
|
}
|
|
15931
|
-
let u =
|
|
15932
|
-
if (
|
|
15933
|
-
code: "NOT_OBJECT",
|
|
15934
|
-
path: e,
|
|
15935
|
-
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${u === void 0 ? "undefined" : typeof u}`,
|
|
15936
|
-
hint: "叶子属性(原始类型)请用 set_window_prop 整体设置"
|
|
15937
|
-
});
|
|
15938
|
-
let d = sv(u), p = lv(d, t, o, s);
|
|
15939
|
-
if (p) return $({
|
|
15985
|
+
let p = cv(u), m = dv(p, t, s, d);
|
|
15986
|
+
if (m) return $({
|
|
15940
15987
|
code: "PATCH_FAILED",
|
|
15941
15988
|
path: e,
|
|
15942
|
-
message:
|
|
15989
|
+
message: m,
|
|
15943
15990
|
hint: "检查 op 与目标类型:merge 需目标为对象,append 需目标为数组;jsonPath 指向需存在"
|
|
15944
15991
|
});
|
|
15945
|
-
let
|
|
15946
|
-
return
|
|
15992
|
+
let h = o.schema.safeParse(p);
|
|
15993
|
+
return h.success ? (f(e, "edit"), fv(e, t, s, d), c({
|
|
15947
15994
|
op: "edit",
|
|
15948
15995
|
path: e,
|
|
15949
|
-
detail: `${t}${
|
|
15950
|
-
value:
|
|
15996
|
+
detail: `${t}${s ? "@" + s : ""}`,
|
|
15997
|
+
value: d,
|
|
15951
15998
|
timestamp: Date.now()
|
|
15952
|
-
}), `已 edit ${e}(${t}${
|
|
15999
|
+
}), `已 edit ${e}(${t}${s ? " @ " + s : ""})。当前值:${lv(av(window, e), 600)} (新 hash=${uv(av(window, e))})${l()}`) : A_(e, h.error.issues);
|
|
15953
16000
|
}, {
|
|
15954
16001
|
name: "edit_window_prop",
|
|
15955
|
-
description: "增量编辑一个已注册的「对象/数组」window 属性,只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对属性根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 字符串。整体仍经 schema 校验,失败不写入。",
|
|
16002
|
+
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,传入启用乐观锁防\"基于过期值覆盖\"。",
|
|
15956
16003
|
schema: t.object({
|
|
15957
16004
|
path: t.string().describe("已注册的对象/数组属性路径"),
|
|
15958
16005
|
op: t.enum([
|
|
@@ -15962,26 +16009,39 @@ function pv(e, r = {}) {
|
|
|
15962
16009
|
"append"
|
|
15963
16010
|
]),
|
|
15964
16011
|
jsonPath: t.string().optional().describe("相对属性根的点号路径(数组索引用数字,如 components.0.text)。set/remove 必填;merge/append 不填则作用于根"),
|
|
15965
|
-
value: t.string().optional().describe("JSON 字符串(set/merge/append 必填)")
|
|
16012
|
+
value: t.string().optional().describe("JSON 字符串(set/merge/append 必填)"),
|
|
16013
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝写入防覆盖")
|
|
15966
16014
|
})
|
|
15967
|
-
}), v = n(async ({ path: e }) => {
|
|
16015
|
+
}), v = n(async ({ path: e, expectedHash: t }) => {
|
|
15968
16016
|
if (!i.has(e)) return $({
|
|
15969
16017
|
code: "NOT_REGISTERED",
|
|
15970
16018
|
path: e,
|
|
15971
16019
|
message: `属性 "${e}" 未在注册表中声明,不可删除`,
|
|
15972
16020
|
hint: "用 list_window_props 查看可用属性"
|
|
15973
16021
|
});
|
|
16022
|
+
if (t !== void 0 && t !== "") {
|
|
16023
|
+
let n = av(window, e), r = uv(n);
|
|
16024
|
+
if (r !== t) return $({
|
|
16025
|
+
code: "VERSION_CONFLICT",
|
|
16026
|
+
path: e,
|
|
16027
|
+
message: `乐观锁冲突:expectedHash=${t} 但当前 hash=${r},属性 "${e}" 在你 get 之后已被修改`,
|
|
16028
|
+
hint: `重新 get_window_prop("${e}") 拿最新值与 hash 再决定是否删除。当前值:${lv(n, 400)}`
|
|
16029
|
+
});
|
|
16030
|
+
}
|
|
15974
16031
|
f(e, "delete");
|
|
15975
|
-
let
|
|
16032
|
+
let n = sv(window, e);
|
|
15976
16033
|
return c({
|
|
15977
16034
|
op: "delete",
|
|
15978
16035
|
path: e,
|
|
15979
16036
|
timestamp: Date.now()
|
|
15980
|
-
}),
|
|
16037
|
+
}), n ? `已删除 ${e}${l()}` : `${e} 不存在(无需删除)${l()}`;
|
|
15981
16038
|
}, {
|
|
15982
16039
|
name: "delete_window_prop",
|
|
15983
|
-
description: "删除一个已注册 window 属性。",
|
|
15984
|
-
schema: t.object({
|
|
16040
|
+
description: "删除一个已注册 window 属性。expectedHash(可选):改前 get_window_prop 返回的 hash,传入启用乐观锁防\"基于过期值删除\"。",
|
|
16041
|
+
schema: t.object({
|
|
16042
|
+
path: t.string().describe("已注册的属性路径"),
|
|
16043
|
+
expectedHash: t.string().optional().describe("乐观锁:改前 get_window_prop 返回的 hash;传入则校验,不一致拒绝删除防覆盖")
|
|
16044
|
+
})
|
|
15985
16045
|
}), y = n(async ({ path: e, label: t }) => i.has(e) ? `已为 ${e} 创建快照 #${f(e, "manual", t)}${t ? `(${t})` : ""}。可用 list_window_snapshots 查看、restore_window_snapshot 回退。` : $({
|
|
15986
16046
|
code: "NOT_REGISTERED",
|
|
15987
16047
|
path: e,
|
|
@@ -16043,7 +16103,7 @@ function pv(e, r = {}) {
|
|
|
16043
16103
|
hint: "用 list_window_snapshots 查看可用快照序号"
|
|
16044
16104
|
});
|
|
16045
16105
|
let s = n.schema.safeParse(o.value);
|
|
16046
|
-
return s.success ? (
|
|
16106
|
+
return s.success ? (pv(e, cv(o.value)), c({
|
|
16047
16107
|
op: "restore",
|
|
16048
16108
|
path: e,
|
|
16049
16109
|
detail: `#${o.id}`,
|
|
@@ -16053,7 +16113,7 @@ function pv(e, r = {}) {
|
|
|
16053
16113
|
path: e,
|
|
16054
16114
|
message: `快照 #${o.id} 的值不符合当前 schema,无法回退`,
|
|
16055
16115
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16056
|
-
details:
|
|
16116
|
+
details: k_(s.error.issues)
|
|
16057
16117
|
});
|
|
16058
16118
|
}, {
|
|
16059
16119
|
name: "restore_window_snapshot",
|
|
@@ -16078,8 +16138,8 @@ function pv(e, r = {}) {
|
|
|
16078
16138
|
})}`);
|
|
16079
16139
|
continue;
|
|
16080
16140
|
}
|
|
16081
|
-
let e =
|
|
16082
|
-
t.push(`- ${n} = ${e === void 0 ? "(undefined)" :
|
|
16141
|
+
let e = av(window, n);
|
|
16142
|
+
t.push(`- ${n} = ${e === void 0 ? "(undefined)" : lv(e)}`);
|
|
16083
16143
|
}
|
|
16084
16144
|
return t.join("\n");
|
|
16085
16145
|
}, {
|
|
@@ -16100,7 +16160,7 @@ function pv(e, r = {}) {
|
|
|
16100
16160
|
message: `属性 "${e}" 未注册`,
|
|
16101
16161
|
hint: "用 list_window_props 查看可用属性"
|
|
16102
16162
|
});
|
|
16103
|
-
let r =
|
|
16163
|
+
let r = av(window, e);
|
|
16104
16164
|
if (typeof r != "object" || !r) return $({
|
|
16105
16165
|
code: "NOT_OBJECT",
|
|
16106
16166
|
path: e,
|
|
@@ -16109,7 +16169,7 @@ function pv(e, r = {}) {
|
|
|
16109
16169
|
});
|
|
16110
16170
|
let a;
|
|
16111
16171
|
try {
|
|
16112
|
-
a =
|
|
16172
|
+
a = X_(r, t);
|
|
16113
16173
|
} catch (n) {
|
|
16114
16174
|
return $({
|
|
16115
16175
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16119,7 +16179,7 @@ function pv(e, r = {}) {
|
|
|
16119
16179
|
details: { expr: t }
|
|
16120
16180
|
});
|
|
16121
16181
|
}
|
|
16122
|
-
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":${
|
|
16182
|
+
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":${lv(e.value)}}`);
|
|
16123
16183
|
return `{"matched":${a.length},"returned":${s.length},"truncated":${a.length > o},"results":[${c.join(",")}]}`;
|
|
16124
16184
|
}, {
|
|
16125
16185
|
name: "query_window_prop",
|
|
@@ -16137,20 +16197,20 @@ function pv(e, r = {}) {
|
|
|
16137
16197
|
message: `属性 "${e}" 未注册`,
|
|
16138
16198
|
hint: "用 list_window_props 查看可用属性"
|
|
16139
16199
|
});
|
|
16140
|
-
let s =
|
|
16200
|
+
let s = av(window, e);
|
|
16141
16201
|
if (s == null) return $({
|
|
16142
16202
|
code: "EMPTY",
|
|
16143
16203
|
path: e,
|
|
16144
16204
|
message: `"${e}" 为空,无可搜索内容`
|
|
16145
16205
|
});
|
|
16146
16206
|
try {
|
|
16147
|
-
let e =
|
|
16207
|
+
let e = Q_(s, t, {
|
|
16148
16208
|
mode: n,
|
|
16149
16209
|
fuzzyThreshold: r,
|
|
16150
16210
|
matchKey: a,
|
|
16151
16211
|
limit: o ?? 50
|
|
16152
16212
|
});
|
|
16153
|
-
return
|
|
16213
|
+
return lv({
|
|
16154
16214
|
matched: e.length,
|
|
16155
16215
|
results: e
|
|
16156
16216
|
});
|
|
@@ -16193,7 +16253,7 @@ function pv(e, r = {}) {
|
|
|
16193
16253
|
message: `脚本过长(${t.length} 字符,上限 8000)`,
|
|
16194
16254
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16195
16255
|
});
|
|
16196
|
-
let a = await
|
|
16256
|
+
let a = await tv(cv(av(window, e)), t, 3e3);
|
|
16197
16257
|
if (!a.ok) {
|
|
16198
16258
|
let n = /超时/.test(a.error || "");
|
|
16199
16259
|
return $({
|
|
@@ -16214,18 +16274,18 @@ function pv(e, r = {}) {
|
|
|
16214
16274
|
path: e,
|
|
16215
16275
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回该属性的完整新值且符合 schema)",
|
|
16216
16276
|
hint: `确认脚本 return 了完整新值(非部分);按 describe_window_prop("${e}") 查看格式`,
|
|
16217
|
-
details:
|
|
16277
|
+
details: k_(t.error.issues)
|
|
16218
16278
|
});
|
|
16219
16279
|
f(e, "edit", "eval_transform");
|
|
16220
|
-
let n =
|
|
16221
|
-
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ?
|
|
16280
|
+
let n = av(window, e);
|
|
16281
|
+
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ? mv(n, t.data) : ov(window, e, t.data), c({
|
|
16222
16282
|
op: "edit",
|
|
16223
16283
|
path: e,
|
|
16224
16284
|
detail: "eval_transform",
|
|
16225
16285
|
timestamp: Date.now()
|
|
16226
|
-
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${
|
|
16286
|
+
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${lv(av(window, e), 600)}`;
|
|
16227
16287
|
}
|
|
16228
|
-
return
|
|
16288
|
+
return lv({
|
|
16229
16289
|
ok: !0,
|
|
16230
16290
|
result: a.result,
|
|
16231
16291
|
elapsedMs: a.elapsedMs
|
|
@@ -16249,8 +16309,8 @@ function pv(e, r = {}) {
|
|
|
16249
16309
|
}
|
|
16250
16310
|
//#endregion
|
|
16251
16311
|
//#region src/core/tools/fetchDoc.ts
|
|
16252
|
-
var
|
|
16253
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16312
|
+
var gv = 3e4, _v = [n(async ({ url: e, as: t }) => {
|
|
16313
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), gv);
|
|
16254
16314
|
try {
|
|
16255
16315
|
let r = await fetch(e, {
|
|
16256
16316
|
method: "GET",
|
|
@@ -16267,7 +16327,7 @@ var mv = 3e4, hv = [n(async ({ url: e, as: t }) => {
|
|
|
16267
16327
|
].join("\n");
|
|
16268
16328
|
} catch (t) {
|
|
16269
16329
|
let r = t?.message || String(t);
|
|
16270
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16330
|
+
return n.signal.aborted ? `获取失败:请求超时(${gv}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16271
16331
|
} finally {
|
|
16272
16332
|
clearTimeout(r);
|
|
16273
16333
|
}
|
|
@@ -16278,33 +16338,33 @@ var mv = 3e4, hv = [n(async ({ url: e, as: t }) => {
|
|
|
16278
16338
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16279
16339
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16280
16340
|
})
|
|
16281
|
-
})],
|
|
16282
|
-
function
|
|
16283
|
-
return
|
|
16341
|
+
})], vv = _v;
|
|
16342
|
+
function yv(e, t) {
|
|
16343
|
+
return hv(e, t);
|
|
16284
16344
|
}
|
|
16285
|
-
function
|
|
16345
|
+
function bv(e, t, n) {
|
|
16286
16346
|
let r = e?.windowOps !== !1, i = e?.fetch !== !1;
|
|
16287
16347
|
return [...r ? t : [], ...i ? n : []];
|
|
16288
16348
|
}
|
|
16289
16349
|
//#endregion
|
|
16290
16350
|
//#region src/core/harness/usageHints.ts
|
|
16291
|
-
var
|
|
16292
|
-
function
|
|
16351
|
+
var xv = .7;
|
|
16352
|
+
function Sv(e, t) {
|
|
16293
16353
|
return {
|
|
16294
16354
|
name: "usageHints",
|
|
16295
16355
|
augmentPrompt: () => {
|
|
16296
16356
|
let n = [];
|
|
16297
|
-
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("
|
|
16298
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
16357
|
+
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/用户手动改过,会返回 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) {
|
|
16358
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= xv || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), r = e.subagents.filter((e) => (e.temperature ?? 0) < xv && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16299
16359
|
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(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16300
16360
|
}
|
|
16301
|
-
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;
|
|
16361
|
+
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;
|
|
16302
16362
|
}
|
|
16303
16363
|
};
|
|
16304
16364
|
}
|
|
16305
16365
|
//#endregion
|
|
16306
16366
|
//#region src/core/utils/id.ts
|
|
16307
|
-
function
|
|
16367
|
+
function Cv() {
|
|
16308
16368
|
try {
|
|
16309
16369
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16310
16370
|
} catch {}
|
|
@@ -16312,57 +16372,57 @@ function xv() {
|
|
|
16312
16372
|
}
|
|
16313
16373
|
//#endregion
|
|
16314
16374
|
//#region src/core/backends/storage.ts
|
|
16315
|
-
var
|
|
16375
|
+
var wv = "chat-sdk", Tv = 50 * 1024 * 1024, Ev = 4 * 1024 * 1024, Dv = 10 * 1024 * 1024, Ov = .9, kv = 500, Av = 300, jv = "__meta__", Mv = "v:1", Nv = [
|
|
16316
16376
|
"messages",
|
|
16317
16377
|
"vfs",
|
|
16318
16378
|
"todos",
|
|
16319
16379
|
"memory"
|
|
16320
16380
|
];
|
|
16321
|
-
function
|
|
16322
|
-
return e === "local" || e === "session" ?
|
|
16381
|
+
function Pv(e) {
|
|
16382
|
+
return e === "local" || e === "session" ? Ev : Tv;
|
|
16323
16383
|
}
|
|
16324
|
-
function
|
|
16384
|
+
function Fv(e) {
|
|
16325
16385
|
if (typeof e != "object" || !e) return !1;
|
|
16326
16386
|
let t = e;
|
|
16327
16387
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16328
16388
|
}
|
|
16329
|
-
function
|
|
16389
|
+
function Iv(e, t, n, r) {
|
|
16330
16390
|
return [
|
|
16331
|
-
|
|
16391
|
+
Mv,
|
|
16332
16392
|
e,
|
|
16333
16393
|
t,
|
|
16334
16394
|
n,
|
|
16335
16395
|
r
|
|
16336
16396
|
].join("::");
|
|
16337
16397
|
}
|
|
16338
|
-
function
|
|
16398
|
+
function Lv(e, t, n) {
|
|
16339
16399
|
return [
|
|
16340
|
-
|
|
16400
|
+
Mv,
|
|
16341
16401
|
e,
|
|
16342
16402
|
t,
|
|
16343
16403
|
n
|
|
16344
16404
|
].join("::") + "::";
|
|
16345
16405
|
}
|
|
16346
|
-
function
|
|
16406
|
+
function Rv(e, t) {
|
|
16347
16407
|
return [
|
|
16348
|
-
|
|
16408
|
+
Mv,
|
|
16349
16409
|
e,
|
|
16350
16410
|
t
|
|
16351
16411
|
].join("::") + "::";
|
|
16352
16412
|
}
|
|
16353
|
-
function Lv(e) {
|
|
16354
|
-
return [Av, e].join("::") + "::";
|
|
16355
|
-
}
|
|
16356
|
-
var Rv = null;
|
|
16357
16413
|
function zv(e) {
|
|
16358
|
-
|
|
16414
|
+
return [Mv, e].join("::") + "::";
|
|
16415
|
+
}
|
|
16416
|
+
var Bv = null;
|
|
16417
|
+
function Vv(e) {
|
|
16418
|
+
Bv ||= new TextEncoder();
|
|
16359
16419
|
try {
|
|
16360
|
-
return
|
|
16420
|
+
return Bv.encode(JSON.stringify(e)).length;
|
|
16361
16421
|
} catch {
|
|
16362
16422
|
return 0;
|
|
16363
16423
|
}
|
|
16364
16424
|
}
|
|
16365
|
-
function
|
|
16425
|
+
function Hv(e, t, n) {
|
|
16366
16426
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16367
16427
|
if (r <= t) return [];
|
|
16368
16428
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16372,7 +16432,7 @@ function Bv(e, t, n) {
|
|
|
16372
16432
|
}
|
|
16373
16433
|
return o;
|
|
16374
16434
|
}
|
|
16375
|
-
function
|
|
16435
|
+
function Uv() {
|
|
16376
16436
|
let e = /* @__PURE__ */ new Map();
|
|
16377
16437
|
return {
|
|
16378
16438
|
async get(t) {
|
|
@@ -16392,7 +16452,7 @@ function Vv() {
|
|
|
16392
16452
|
}
|
|
16393
16453
|
};
|
|
16394
16454
|
}
|
|
16395
|
-
function
|
|
16455
|
+
function Wv(e) {
|
|
16396
16456
|
return new Promise((t, n) => {
|
|
16397
16457
|
if (typeof indexedDB > "u") {
|
|
16398
16458
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -16453,7 +16513,7 @@ function Hv(e) {
|
|
|
16453
16513
|
}, r.onerror = () => n(r.error);
|
|
16454
16514
|
});
|
|
16455
16515
|
}
|
|
16456
|
-
function
|
|
16516
|
+
function Gv(e) {
|
|
16457
16517
|
return {
|
|
16458
16518
|
async get(t) {
|
|
16459
16519
|
let n = e.getItem(t);
|
|
@@ -16487,12 +16547,12 @@ function Uv(e) {
|
|
|
16487
16547
|
}
|
|
16488
16548
|
};
|
|
16489
16549
|
}
|
|
16490
|
-
function
|
|
16550
|
+
function Kv(e, t, n) {
|
|
16491
16551
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
16492
16552
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
16493
16553
|
}
|
|
16494
|
-
function
|
|
16495
|
-
let t = e.dbName ??
|
|
16554
|
+
function qv(e = {}) {
|
|
16555
|
+
let t = e.dbName ?? wv, n = e.backend ?? "indexed", r = e.maxBytes ?? Pv(n), i = e.maxBytesPerSession ?? Dv, a = e.evictionWatermark ?? Ov, o = e.debounceMs ?? kv, s = /* @__PURE__ */ new Set();
|
|
16496
16556
|
function c(e) {
|
|
16497
16557
|
for (let t of s) try {
|
|
16498
16558
|
t(e);
|
|
@@ -16505,16 +16565,16 @@ function Gv(e = {}) {
|
|
|
16505
16565
|
try {
|
|
16506
16566
|
if (n === "indexed") {
|
|
16507
16567
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
16508
|
-
l = await
|
|
16568
|
+
l = await Wv(t), d(!0);
|
|
16509
16569
|
} else if (n === "session") {
|
|
16510
16570
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
16511
|
-
l =
|
|
16571
|
+
l = Gv(sessionStorage), d(!0);
|
|
16512
16572
|
} else if (n === "local") {
|
|
16513
16573
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
16514
|
-
l =
|
|
16515
|
-
} else l =
|
|
16574
|
+
l = Gv(localStorage), d(!0);
|
|
16575
|
+
} else l = Uv(), d(!1);
|
|
16516
16576
|
} catch (e) {
|
|
16517
|
-
l =
|
|
16577
|
+
l = Uv();
|
|
16518
16578
|
let t = e instanceof Error ? e.message : String(e);
|
|
16519
16579
|
d(!1), Promise.resolve().then(() => c({
|
|
16520
16580
|
type: "degraded",
|
|
@@ -16524,10 +16584,10 @@ function Gv(e = {}) {
|
|
|
16524
16584
|
})();
|
|
16525
16585
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
16526
16586
|
function g(e, n, r, a) {
|
|
16527
|
-
let o =
|
|
16528
|
-
return
|
|
16587
|
+
let o = Iv(t, r, a, jv);
|
|
16588
|
+
return Kv(h, o, async () => {
|
|
16529
16589
|
let t = async () => {
|
|
16530
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16590
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : Vv(s), d = Vv(n), f = (t?.bytes ?? 0) + (d - u);
|
|
16531
16591
|
if (f > i) {
|
|
16532
16592
|
c({
|
|
16533
16593
|
type: "quota",
|
|
@@ -16549,12 +16609,12 @@ function Gv(e = {}) {
|
|
|
16549
16609
|
try {
|
|
16550
16610
|
await t();
|
|
16551
16611
|
} catch (e) {
|
|
16552
|
-
if (
|
|
16612
|
+
if (Fv(e) && !u) {
|
|
16553
16613
|
u = !0;
|
|
16554
16614
|
try {
|
|
16555
16615
|
await b();
|
|
16556
16616
|
} catch {}
|
|
16557
|
-
l =
|
|
16617
|
+
l = Uv(), Promise.resolve().then(() => c({
|
|
16558
16618
|
type: "degraded",
|
|
16559
16619
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
16560
16620
|
}));
|
|
@@ -16566,7 +16626,7 @@ function Gv(e = {}) {
|
|
|
16566
16626
|
});
|
|
16567
16627
|
}
|
|
16568
16628
|
function _(e, n, r, i) {
|
|
16569
|
-
let a =
|
|
16629
|
+
let a = Iv(t, e, n, r), s = p.get(a);
|
|
16570
16630
|
s && s.resolve();
|
|
16571
16631
|
let c = m.get(a);
|
|
16572
16632
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16593,15 +16653,15 @@ function Gv(e = {}) {
|
|
|
16593
16653
|
function y() {
|
|
16594
16654
|
v ||= setTimeout(() => {
|
|
16595
16655
|
v = null, b();
|
|
16596
|
-
},
|
|
16656
|
+
}, Av);
|
|
16597
16657
|
}
|
|
16598
16658
|
async function b() {
|
|
16599
16659
|
let e = [];
|
|
16600
|
-
await l.scan(
|
|
16660
|
+
await l.scan(zv(t), (t, n) => {
|
|
16601
16661
|
t.endsWith("::__meta__") && e.push(n);
|
|
16602
16662
|
});
|
|
16603
|
-
let n =
|
|
16604
|
-
for (let e of n) await l.clearPrefix(
|
|
16663
|
+
let n = Hv(e, r, a);
|
|
16664
|
+
for (let e of n) await l.clearPrefix(Lv(t, e.agentId, e.sessionId)), c({
|
|
16605
16665
|
type: "evicted",
|
|
16606
16666
|
agentId: e.agentId,
|
|
16607
16667
|
sessionId: e.sessionId,
|
|
@@ -16612,13 +16672,13 @@ function Gv(e = {}) {
|
|
|
16612
16672
|
ready: f,
|
|
16613
16673
|
async listSessions(e) {
|
|
16614
16674
|
let n = [];
|
|
16615
|
-
return await l.scan(
|
|
16675
|
+
return await l.scan(Rv(t, e), (e, t) => {
|
|
16616
16676
|
e.endsWith("::__meta__") && n.push(t);
|
|
16617
16677
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16618
16678
|
},
|
|
16619
16679
|
async load(e, n) {
|
|
16620
|
-
let r =
|
|
16621
|
-
return await
|
|
16680
|
+
let r = Iv(t, e, n, jv);
|
|
16681
|
+
return await Kv(h, r, async () => {
|
|
16622
16682
|
let i = await l.get(r);
|
|
16623
16683
|
if (!i) return;
|
|
16624
16684
|
let a = {
|
|
@@ -16627,8 +16687,8 @@ function Gv(e = {}) {
|
|
|
16627
16687
|
todos: [],
|
|
16628
16688
|
memory: ""
|
|
16629
16689
|
};
|
|
16630
|
-
for (let r of
|
|
16631
|
-
let i = await l.get(
|
|
16690
|
+
for (let r of Nv) {
|
|
16691
|
+
let i = await l.get(Iv(t, e, n, r));
|
|
16632
16692
|
i != null && (a[r] = i);
|
|
16633
16693
|
}
|
|
16634
16694
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16636,7 +16696,7 @@ function Gv(e = {}) {
|
|
|
16636
16696
|
},
|
|
16637
16697
|
async save(e, t, n) {
|
|
16638
16698
|
let r = [];
|
|
16639
|
-
for (let i of
|
|
16699
|
+
for (let i of Nv) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16640
16700
|
await Promise.all(r);
|
|
16641
16701
|
},
|
|
16642
16702
|
async flush() {
|
|
@@ -16650,10 +16710,10 @@ function Gv(e = {}) {
|
|
|
16650
16710
|
})), c({ type: "flush" }), await b();
|
|
16651
16711
|
},
|
|
16652
16712
|
async deleteSession(e, n) {
|
|
16653
|
-
await l.clearPrefix(
|
|
16713
|
+
await l.clearPrefix(Lv(t, e, n));
|
|
16654
16714
|
},
|
|
16655
16715
|
async createSession(e, n, r) {
|
|
16656
|
-
let i = r ??
|
|
16716
|
+
let i = r ?? Cv(), a = Date.now(), o = {
|
|
16657
16717
|
agentId: e,
|
|
16658
16718
|
sessionId: i,
|
|
16659
16719
|
createdAt: a,
|
|
@@ -16661,7 +16721,7 @@ function Gv(e = {}) {
|
|
|
16661
16721
|
bytes: 0,
|
|
16662
16722
|
title: n
|
|
16663
16723
|
};
|
|
16664
|
-
return await l.set(
|
|
16724
|
+
return await l.set(Iv(t, e, i, jv), o), i;
|
|
16665
16725
|
},
|
|
16666
16726
|
onEvent(e) {
|
|
16667
16727
|
s.add(e);
|
|
@@ -16676,28 +16736,28 @@ function Gv(e = {}) {
|
|
|
16676
16736
|
}
|
|
16677
16737
|
//#endregion
|
|
16678
16738
|
//#region src/core/sdk/createChatSdk.ts
|
|
16679
|
-
var
|
|
16739
|
+
var Jv = [
|
|
16680
16740
|
"你是一个页面操作助手。宿主页面在 window 对象上注册了可操作的属性,你通过专用工具安全地读写这些属性来操作页面。",
|
|
16681
16741
|
"所有写操作都经范围控制(仅注册表内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
16682
16742
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
16683
|
-
|
|
16684
|
-
].join("\n\n"),
|
|
16685
|
-
function
|
|
16686
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ?
|
|
16743
|
+
E_.reliableWriteRules
|
|
16744
|
+
].join("\n\n"), Yv = 50;
|
|
16745
|
+
function Xv(e) {
|
|
16746
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? qv({ backend: e }) : e.enabled === !1 ? null : qv(e);
|
|
16687
16747
|
}
|
|
16688
|
-
function
|
|
16748
|
+
function Zv(e) {
|
|
16689
16749
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
16690
16750
|
}
|
|
16691
|
-
var
|
|
16692
|
-
function
|
|
16751
|
+
var Qv = /* @__PURE__ */ new Map();
|
|
16752
|
+
function $v(e) {
|
|
16693
16753
|
let t = e.content;
|
|
16694
16754
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
16695
16755
|
}
|
|
16696
|
-
function
|
|
16756
|
+
function ey(e) {
|
|
16697
16757
|
let t = e.summaryLlm ?? e.llm;
|
|
16698
16758
|
if (!t) return;
|
|
16699
16759
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
16700
|
-
if (
|
|
16760
|
+
if (Zv(t)) c = t;
|
|
16701
16761
|
else {
|
|
16702
16762
|
let i = t;
|
|
16703
16763
|
if (!i.apiKey) {
|
|
@@ -16715,16 +16775,16 @@ function Qv(e) {
|
|
|
16715
16775
|
return async (e) => {
|
|
16716
16776
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
16717
16777
|
try {
|
|
16718
|
-
return
|
|
16778
|
+
return $v(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
16719
16779
|
} finally {
|
|
16720
16780
|
clearTimeout(n);
|
|
16721
16781
|
}
|
|
16722
16782
|
};
|
|
16723
16783
|
}
|
|
16724
|
-
function
|
|
16784
|
+
function ty(e) {
|
|
16725
16785
|
return e === "set_window_prop" ? "set" : e === "edit_window_prop" ? "edit" : e === "delete_window_prop" ? "delete" : e === "restore_window_snapshot" ? "restore" : null;
|
|
16726
16786
|
}
|
|
16727
|
-
function
|
|
16787
|
+
function ny(e) {
|
|
16728
16788
|
let t = e.split("."), n = globalThis.window;
|
|
16729
16789
|
for (let e of t) {
|
|
16730
16790
|
if (n == null) return;
|
|
@@ -16732,18 +16792,18 @@ function ey(e) {
|
|
|
16732
16792
|
}
|
|
16733
16793
|
return n;
|
|
16734
16794
|
}
|
|
16735
|
-
function
|
|
16795
|
+
function ry(e, t) {
|
|
16736
16796
|
return {
|
|
16737
16797
|
name: "sdk-events",
|
|
16738
16798
|
wrapToolCall: async (t, n) => {
|
|
16739
|
-
let r = await n(t), i =
|
|
16799
|
+
let r = await n(t), i = ty(t.name);
|
|
16740
16800
|
if (i) {
|
|
16741
16801
|
let n = String(t.args?.path ?? "");
|
|
16742
16802
|
e({
|
|
16743
16803
|
type: "window_prop_change",
|
|
16744
16804
|
path: n,
|
|
16745
16805
|
operation: i,
|
|
16746
|
-
value: n ?
|
|
16806
|
+
value: n ? ny(n) : void 0
|
|
16747
16807
|
});
|
|
16748
16808
|
}
|
|
16749
16809
|
return r;
|
|
@@ -16756,38 +16816,38 @@ function ty(e, t) {
|
|
|
16756
16816
|
}
|
|
16757
16817
|
};
|
|
16758
16818
|
}
|
|
16759
|
-
function
|
|
16760
|
-
let i =
|
|
16819
|
+
function iy(e, r) {
|
|
16820
|
+
let i = Xv(e.storage);
|
|
16761
16821
|
e.debug && i && i.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
16762
|
-
let a =
|
|
16822
|
+
let a = Zv(e.llm) ? void 0 : e.llm, o = Wh({
|
|
16763
16823
|
model: a?.model,
|
|
16764
16824
|
contextWindow: e.contextWindow ?? a?.contextWindow,
|
|
16765
16825
|
maxOutputTokens: e.maxOutputTokens ?? a?.maxOutputTokens
|
|
16766
16826
|
});
|
|
16767
16827
|
e.debug && console.log("[page-agent-sdk][modelCaps]", o);
|
|
16768
|
-
let s =
|
|
16828
|
+
let s = ey(e);
|
|
16769
16829
|
e.debug && !s && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
16770
|
-
let c = /* @__PURE__ */ Qt([]), l =
|
|
16830
|
+
let c = /* @__PURE__ */ Qt([]), l = N_(e.vfs?.initialFiles, {
|
|
16771
16831
|
persist: i ? { save: (e) => {
|
|
16772
16832
|
B.sessionId && i && i.save(r, B.sessionId, { vfs: e });
|
|
16773
16833
|
} } : void 0,
|
|
16774
16834
|
maxBytes: e.vfs?.maxBytes
|
|
16775
|
-
}), u =
|
|
16835
|
+
}), u = ug(), d = vg(e.memory || ""), f = { current: null }, p = e.checkpoint, m = p !== void 0 && p !== !1, h = m ? Fg({
|
|
16776
16836
|
windowPaths: (e.windowProps ?? []).map((e) => e.path),
|
|
16777
16837
|
vfsStore: l,
|
|
16778
16838
|
todosMw: u,
|
|
16779
16839
|
getTodos: () => f.current?.getState?.()?.todos ?? [],
|
|
16780
16840
|
messages: c,
|
|
16781
16841
|
maxCheckpoints: p && typeof p == "object" ? p.maxCheckpoints : void 0
|
|
16782
|
-
}) : null, g = !p || typeof p != "object" || p.auto !== !1, _ = e.capabilities, v = _?.windowOps !== !1, y = v ?
|
|
16842
|
+
}) : null, g = !p || typeof p != "object" || p.auto !== !1, _ = e.capabilities, v = _?.windowOps !== !1, y = v ? hv(e.windowProps || [], {
|
|
16783
16843
|
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][window audit]", e) : void 0,
|
|
16784
16844
|
maxSnapshots: e.maxSnapshots
|
|
16785
|
-
}) : [], b = v ? y.controller ?? null : null, x = () => b?.list() ?? e.windowProps ?? [], S = /* @__PURE__ */ new Map(), C =
|
|
16845
|
+
}) : [], b = v ? y.controller ?? null : null, x = () => b?.list() ?? e.windowProps ?? [], S = /* @__PURE__ */ new Map(), C = bv(_, y, _v);
|
|
16786
16846
|
C.forEach((e) => S.set(e.name, "builtin"));
|
|
16787
16847
|
let w = [...e.tools || []];
|
|
16788
16848
|
w.forEach((e) => S.set(e.name, "user"));
|
|
16789
|
-
let T = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), E = T ?
|
|
16790
|
-
E && S.set(
|
|
16849
|
+
let T = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), E = T ? Dg() : null;
|
|
16850
|
+
E && S.set(Tg, "builtin");
|
|
16791
16851
|
let D = m && h ? [n(async () => {
|
|
16792
16852
|
let e = h.list();
|
|
16793
16853
|
return e.length ? h.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、window 注册属性、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
@@ -16811,7 +16871,7 @@ function ny(e, r) {
|
|
|
16811
16871
|
...D
|
|
16812
16872
|
], k = _?.planning !== !1, A = _?.skills !== !1, j = _?.vfs !== !1, M = _?.summarization !== !1, N = _?.memory !== !1, P = _?.subagent !== !1, F = e.verify?.maxAttempts ?? 2, I = _?.verify === !0 && e.verify?.enabled !== !1 && F > 0;
|
|
16813
16873
|
e.verify?.check && _?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
16814
|
-
let L = e.subagent, R = L?.allowedTools ?? [],
|
|
16874
|
+
let L = e.subagent, R = L?.allowedTools ?? [], z = !P || L?.enabled === !1 ? void 0 : Wg({
|
|
16815
16875
|
llm: L?.llm ?? e.llm,
|
|
16816
16876
|
allTools: O,
|
|
16817
16877
|
allowedTools: R.length ? R : void 0,
|
|
@@ -16822,23 +16882,23 @@ function ny(e, r) {
|
|
|
16822
16882
|
maxDepth: L?.maxDepth,
|
|
16823
16883
|
maxParallel: L?.maxParallel,
|
|
16824
16884
|
debug: e.debug
|
|
16825
|
-
}),
|
|
16885
|
+
}), ee = e.subagents?.length ? qg(e.subagents, {
|
|
16826
16886
|
llm: e.llm,
|
|
16827
16887
|
allTools: O,
|
|
16828
16888
|
debug: e.debug
|
|
16829
|
-
}) : void 0,
|
|
16889
|
+
}) : void 0, te = [
|
|
16830
16890
|
"get_window_prop",
|
|
16831
16891
|
"get_window_paths",
|
|
16832
16892
|
"list_window_props",
|
|
16833
16893
|
"describe_window_prop",
|
|
16834
16894
|
"fetch_document"
|
|
16835
|
-
],
|
|
16836
|
-
check: e.verify.check ??
|
|
16895
|
+
], ne = O.filter((e) => te.includes(e.name)), re = I ? Jg({
|
|
16896
|
+
check: e.verify.check ?? e_({ schemas: () => Object.fromEntries(x().map((e) => [e.path, e.schema])) }),
|
|
16837
16897
|
adversarial: e.verify?.adversarial ? {
|
|
16838
16898
|
llm: e.llm,
|
|
16839
|
-
tools:
|
|
16899
|
+
tools: ne
|
|
16840
16900
|
} : void 0
|
|
16841
|
-
}) : void 0,
|
|
16901
|
+
}) : void 0, ie = Sv({
|
|
16842
16902
|
..._,
|
|
16843
16903
|
humanConfirm: T,
|
|
16844
16904
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -16846,22 +16906,22 @@ function ny(e, r) {
|
|
|
16846
16906
|
description: e.description,
|
|
16847
16907
|
temperature: e.temperature
|
|
16848
16908
|
}))
|
|
16849
|
-
}, v && !!e.windowProps?.length),
|
|
16909
|
+
}, v && !!e.windowProps?.length), ae = e.onEvent, oe = /* @__PURE__ */ new Set(), se = (e) => {
|
|
16850
16910
|
if (e.type !== "approval_request") {
|
|
16851
|
-
if (
|
|
16852
|
-
|
|
16911
|
+
if (ae) try {
|
|
16912
|
+
ae(e);
|
|
16853
16913
|
} catch {}
|
|
16854
|
-
for (let t of
|
|
16914
|
+
for (let t of oe) try {
|
|
16855
16915
|
t(e);
|
|
16856
16916
|
} catch {}
|
|
16857
16917
|
}
|
|
16858
|
-
},
|
|
16859
|
-
|
|
16918
|
+
}, ce = [
|
|
16919
|
+
ie,
|
|
16860
16920
|
...k ? [u] : [],
|
|
16861
|
-
...A ? [
|
|
16862
|
-
...j ? [
|
|
16863
|
-
...M ? [
|
|
16864
|
-
...
|
|
16921
|
+
...A ? [_g(e.skills || [], { readVfs: j ? (e) => l.files[e]?.content : void 0 })] : [],
|
|
16922
|
+
...j ? [B_(l)] : [],
|
|
16923
|
+
...M ? [w_({
|
|
16924
|
+
...O_(e, o.contextWindow),
|
|
16865
16925
|
llmInvoke: s,
|
|
16866
16926
|
getRegisteredProps: () => x().map((e) => ({
|
|
16867
16927
|
path: e.path,
|
|
@@ -16870,21 +16930,21 @@ function ny(e, r) {
|
|
|
16870
16930
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_window_prop", "list_window_props"]
|
|
16871
16931
|
})] : [],
|
|
16872
16932
|
...N ? [d] : [],
|
|
16873
|
-
...e.permissions?.length ? [
|
|
16874
|
-
...m && g && h ? [
|
|
16875
|
-
...T ? [
|
|
16876
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
16877
|
-
...
|
|
16933
|
+
...e.permissions?.length ? [Cg(e.permissions)] : [],
|
|
16934
|
+
...m && g && h ? [Ig(h)] : [],
|
|
16935
|
+
...T ? [Og()] : [],
|
|
16936
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [wg(e.approval)] : [],
|
|
16937
|
+
...re ? [re] : [],
|
|
16938
|
+
...z ? [z] : [],
|
|
16878
16939
|
...ee ? [ee] : [],
|
|
16879
|
-
...te ? [te] : [],
|
|
16880
16940
|
...e.middleware || [],
|
|
16881
|
-
|
|
16882
|
-
], le = e.maxMemoryRounds ??
|
|
16941
|
+
ry(se, c)
|
|
16942
|
+
], le = e.maxMemoryRounds ?? Yv, B = {
|
|
16883
16943
|
agentId: r,
|
|
16884
16944
|
store: i,
|
|
16885
16945
|
messages: c,
|
|
16886
16946
|
vfsStore: l,
|
|
16887
|
-
listeners:
|
|
16947
|
+
listeners: oe,
|
|
16888
16948
|
todosMw: u,
|
|
16889
16949
|
memoryMw: d,
|
|
16890
16950
|
agent: null,
|
|
@@ -16916,7 +16976,7 @@ function ny(e, r) {
|
|
|
16916
16976
|
timestamp: Date.now()
|
|
16917
16977
|
}), B.afterRound(), i && await i.flush(), e;
|
|
16918
16978
|
} catch (e) {
|
|
16919
|
-
throw
|
|
16979
|
+
throw se({
|
|
16920
16980
|
type: "error",
|
|
16921
16981
|
message: e?.message || String(e)
|
|
16922
16982
|
}), e;
|
|
@@ -16930,8 +16990,8 @@ function ny(e, r) {
|
|
|
16930
16990
|
},
|
|
16931
16991
|
stream: (e, t, n) => {
|
|
16932
16992
|
if (!B.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
16933
|
-
let r =
|
|
16934
|
-
t?.(e),
|
|
16993
|
+
let r = ae ? (e) => {
|
|
16994
|
+
t?.(e), se(e);
|
|
16935
16995
|
} : t;
|
|
16936
16996
|
return B.agent.stream(e, r, n);
|
|
16937
16997
|
},
|
|
@@ -16939,14 +16999,14 @@ function ny(e, r) {
|
|
|
16939
16999
|
if (B.refCount--, B.refCount <= 0) {
|
|
16940
17000
|
i && (l.flush?.(), i.flush(), i.dispose());
|
|
16941
17001
|
let e = B.mcpClosers.splice(0);
|
|
16942
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
17002
|
+
e.length && Promise.allSettled(e.map((e) => e())), Qv.delete(r);
|
|
16943
17003
|
}
|
|
16944
17004
|
},
|
|
16945
17005
|
getInfo() {
|
|
16946
17006
|
return {
|
|
16947
17007
|
id: r,
|
|
16948
|
-
model:
|
|
16949
|
-
systemPrompt: e.systemPrompt ??
|
|
17008
|
+
model: Zv(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17009
|
+
systemPrompt: e.systemPrompt ?? Jv,
|
|
16950
17010
|
tools: O.map((e) => ({
|
|
16951
17011
|
name: e.name,
|
|
16952
17012
|
description: e.description,
|
|
@@ -16963,19 +17023,19 @@ function ny(e, r) {
|
|
|
16963
17023
|
schema: e.schema
|
|
16964
17024
|
})),
|
|
16965
17025
|
memory: e.memory ?? "",
|
|
16966
|
-
middleware:
|
|
17026
|
+
middleware: ce.map((e) => e.name),
|
|
16967
17027
|
todos: (B.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
16968
17028
|
content: e.content,
|
|
16969
17029
|
status: e.status
|
|
16970
17030
|
})),
|
|
16971
17031
|
subagent: {
|
|
16972
|
-
enabled: !!
|
|
17032
|
+
enabled: !!z,
|
|
16973
17033
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
16974
17034
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
16975
17035
|
allowedTools: e.subagent?.allowedTools ?? []
|
|
16976
17036
|
},
|
|
16977
17037
|
verify: {
|
|
16978
|
-
enabled: !!
|
|
17038
|
+
enabled: !!re,
|
|
16979
17039
|
maxAttempts: I ? F : 0,
|
|
16980
17040
|
adversarial: I && !!e.verify?.adversarial
|
|
16981
17041
|
},
|
|
@@ -17008,7 +17068,7 @@ function ny(e, r) {
|
|
|
17008
17068
|
e.memory && i.save(r, B.sessionId, { memory: e.memory });
|
|
17009
17069
|
}
|
|
17010
17070
|
function de() {
|
|
17011
|
-
let e =
|
|
17071
|
+
let e = m_(c, le);
|
|
17012
17072
|
e.trimmed && c.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17013
17073
|
}
|
|
17014
17074
|
function fe() {
|
|
@@ -17020,7 +17080,7 @@ function ny(e, r) {
|
|
|
17020
17080
|
}
|
|
17021
17081
|
return B.initDone = (async () => {
|
|
17022
17082
|
if (await ue(), e.mcp?.length) {
|
|
17023
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
17083
|
+
let t = await Promise.allSettled(e.mcp.map((e) => u_(e)));
|
|
17024
17084
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
17025
17085
|
let n = [];
|
|
17026
17086
|
t.forEach((t, r) => {
|
|
@@ -17032,17 +17092,17 @@ function ny(e, r) {
|
|
|
17032
17092
|
}), t.value.tools.forEach((e) => S.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17033
17093
|
}), O.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
17034
17094
|
}
|
|
17035
|
-
B.agent =
|
|
17036
|
-
...
|
|
17095
|
+
B.agent = cg({
|
|
17096
|
+
...Zv(e.llm) ? { llm: e.llm } : {
|
|
17037
17097
|
apiKey: e.llm.apiKey,
|
|
17038
17098
|
baseUrl: e.llm.baseUrl,
|
|
17039
17099
|
model: e.llm.model,
|
|
17040
17100
|
temperature: e.llm.temperature,
|
|
17041
17101
|
maxTokens: e.llm.maxTokens
|
|
17042
17102
|
},
|
|
17043
|
-
systemPrompt: e.systemPrompt ??
|
|
17103
|
+
systemPrompt: e.systemPrompt ?? Jv,
|
|
17044
17104
|
tools: O,
|
|
17045
|
-
middleware:
|
|
17105
|
+
middleware: ce,
|
|
17046
17106
|
maxToolRounds: e.maxToolRounds,
|
|
17047
17107
|
maxRetries: e.maxRetries,
|
|
17048
17108
|
maxParallelTools: e.maxParallelTools,
|
|
@@ -17053,11 +17113,11 @@ function ny(e, r) {
|
|
|
17053
17113
|
}), f.current = B.agent;
|
|
17054
17114
|
})(), B;
|
|
17055
17115
|
}
|
|
17056
|
-
function
|
|
17057
|
-
let t = e.id ??
|
|
17116
|
+
function ay(e) {
|
|
17117
|
+
let t = e.id ?? Cv();
|
|
17058
17118
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
17059
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
17060
|
-
a ? i = a : (i =
|
|
17119
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? Qv.get(t) : void 0;
|
|
17120
|
+
a ? i = a : (i = iy(e, t), e.shareContext && Qv.set(t, i)), i.refCount++;
|
|
17061
17121
|
let o = null, s = null, c = null;
|
|
17062
17122
|
async function l() {
|
|
17063
17123
|
if (await i.initDone, r === !1) {
|
|
@@ -17086,7 +17146,7 @@ function ry(e) {
|
|
|
17086
17146
|
i.afterRound(), i.store && await i.store.flush();
|
|
17087
17147
|
},
|
|
17088
17148
|
onClear: () => {
|
|
17089
|
-
i.store && (i.sessionId =
|
|
17149
|
+
i.store && (i.sessionId = Cv(), 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));
|
|
17090
17150
|
}
|
|
17091
17151
|
});
|
|
17092
17152
|
} })), o.mount(t), i.store && (s = () => {
|
|
@@ -17122,7 +17182,7 @@ function ry(e) {
|
|
|
17122
17182
|
}
|
|
17123
17183
|
//#endregion
|
|
17124
17184
|
//#region src/core/sdk/defineTool.ts
|
|
17125
|
-
function
|
|
17185
|
+
function oy(e) {
|
|
17126
17186
|
return n(async (t) => {
|
|
17127
17187
|
let n = await e.handler(t);
|
|
17128
17188
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17133,4 +17193,4 @@ function iy(e) {
|
|
|
17133
17193
|
});
|
|
17134
17194
|
}
|
|
17135
17195
|
//#endregion
|
|
17136
|
-
export {
|
|
17196
|
+
export { D_ as CONTEXT_PRESETS, Rh as ChatDialog, Qd as CodePreview, Tg as HUMAN_CONFIRM_TOOL_NAME, ef as MessageContent, u_ as connectMcp, cg as createAgent, wg as createApprovalMiddleware, ay as createChatSdk, Fg as createCheckpointManager, Ig as createCheckpointMiddleware, Og as createHumanConfirmMiddleware, Dg as createHumanConfirmTool, Uv as createMemoryBackend, qv as createSessionStore, Wg as createSubagentMiddleware, qg as createSubagentsMiddleware, Sv as createUsageHintsMiddleware, Jg as createVerifyMiddleware, N_ as createVfs, Gv as createWebStorageBackend, hv as createWindowOps, e_ as createWriteBackCheck, dg as defineSkill, oy as defineTool, yv as defineWindowToolset, rg as detectGarbledToolCall, Gh as estimateTokens, s_ as extractText, _v as fetchDocTools, vv as fetchTools, k_ as formatZodIssues, Fv as isQuotaError, X_ as jpEval, j_ as jsonParseError, qh as offloadPassThroughChars, Kh as offloadThresholdChars, T_ as presets, O_ as resolveContextOptions, Wh as resolveModelCaps, tv as runSandboxedScript, Q_ as searchJson, bv as selectBuiltinTools, E_ as systemPromptHelpers, $ as toolError, xl as useChat, e as z, A_ as zodError };
|