page-agent-sdk 2.7.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -3
- package/README.zh-CN.md +39 -3
- package/dist/page-agent-sdk.iife.js +92 -92
- package/dist/page-agent-sdk.js +999 -891
- package/dist/page-agent-sdk.umd.cjs +40 -40
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/references/api.md +8 -0
- package/skills/page-agent-sdk-integrate/references/options.md +9 -0
- package/skills/page-agent-sdk-integrate/references/use-cases.md +32 -0
- package/types/index.d.ts +36 -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) =>
|
|
27
|
+
}, E = Object.prototype.hasOwnProperty, D = (e, t) => E.call(e, t), O = Array.isArray, k = (e) => te(e) === "[object Map]", A = (e) => te(e) === "[object Set]", j = (e) => te(e) === "[object Date]", M = (e) => typeof e == "function", N = (e) => typeof e == "string", P = (e) => typeof e == "symbol", F = (e) => typeof e == "object" && !!e, ee = (e) => (F(e) || M(e)) && M(e.then) && M(e.catch), I = Object.prototype.toString, te = (e) => I.call(e), L = (e) => te(e).slice(8, -1), R = (e) => te(e) === "[object Object]", ne = (e) => N(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, re = /* @__PURE__ */ _(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ie = /* @__PURE__ */ _("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), ae = (e) => {
|
|
28
28
|
let t = /* @__PURE__ */ Object.create(null);
|
|
29
29
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
30
|
-
},
|
|
30
|
+
}, oe = /-\w/g, z = ae((e) => e.replace(oe, (e) => e.slice(1).toUpperCase())), se = /\B([A-Z])/g, ce = ae((e) => e.replace(se, "-$1").toLowerCase()), le = ae((e) => e.charAt(0).toUpperCase() + e.slice(1)), ue = ae((e) => e ? `on${le(e)}` : ""), de = (e, t) => !Object.is(e, t), fe = (e, ...t) => {
|
|
31
31
|
for (let n = 0; n < e.length; n++) e[n](...t);
|
|
32
32
|
}, pe = (e, t, n, r = !1) => {
|
|
33
33
|
Object.defineProperty(e, t, {
|
|
@@ -43,22 +43,22 @@ var v = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), y = proc
|
|
|
43
43
|
let t = N(e) ? Number(e) : NaN;
|
|
44
44
|
return isNaN(t) ? e : t;
|
|
45
45
|
}, ge, _e = () => ge ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
|
|
46
|
-
function
|
|
46
|
+
function ve(e) {
|
|
47
47
|
if (O(e)) {
|
|
48
48
|
let t = {};
|
|
49
49
|
for (let n = 0; n < e.length; n++) {
|
|
50
|
-
let r = e[n], i = N(r) ? xe(r) :
|
|
50
|
+
let r = e[n], i = N(r) ? xe(r) : ve(r);
|
|
51
51
|
if (i) for (let e in i) t[e] = i[e];
|
|
52
52
|
}
|
|
53
53
|
return t;
|
|
54
54
|
} else if (N(e) || F(e)) return e;
|
|
55
55
|
}
|
|
56
|
-
var
|
|
56
|
+
var ye = /;(?![^(]*\))/g, B = /:([^]+)/, be = /\/\*[^]*?\*\//g;
|
|
57
57
|
function xe(e) {
|
|
58
58
|
let t = {};
|
|
59
|
-
return e.replace(be, "").split(
|
|
59
|
+
return e.replace(be, "").split(ye).forEach((e) => {
|
|
60
60
|
if (e) {
|
|
61
|
-
let n = e.split(
|
|
61
|
+
let n = e.split(B);
|
|
62
62
|
n.length > 1 && (t[n[0].trim()] = n[1].trim());
|
|
63
63
|
}
|
|
64
64
|
}), 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 ===
|
|
102
|
+
var Pe = (e) => !!(e && e.__v_isRef === !0), V = (e) => N(e) ? e : e == null ? "" : O(e) || F(e) && (e.toString === I || !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) && !R(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 && ne(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 && ne(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) && ne(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 = L(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(L(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 (R(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
|
}
|
|
@@ -1056,7 +1056,7 @@ function Rn(e, t, n, r) {
|
|
|
1056
1056
|
function zn(e, t, n, r) {
|
|
1057
1057
|
if (M(e)) {
|
|
1058
1058
|
let i = Rn(e, t, n, r);
|
|
1059
|
-
return i &&
|
|
1059
|
+
return i && ee(i) && i.catch((e) => {
|
|
1060
1060
|
Bn(e, t, n);
|
|
1061
1061
|
}), i;
|
|
1062
1062
|
}
|
|
@@ -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
|
+
ie(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;
|
|
@@ -1938,7 +1938,7 @@ function ca(e) {
|
|
|
1938
1938
|
if (i) {
|
|
1939
1939
|
process.env.NODE_ENV !== "production" && !M(i) && G("The data option must be a function. Plain object usage is no longer supported.");
|
|
1940
1940
|
let t = i.call(n, n);
|
|
1941
|
-
if (process.env.NODE_ENV !== "production" &&
|
|
1941
|
+
if (process.env.NODE_ENV !== "production" && ee(t) && G("data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>."), !F(t)) process.env.NODE_ENV !== "production" && G("data() should return an object.");
|
|
1942
1942
|
else if (e.data = /* @__PURE__ */ Qt(t), process.env.NODE_ENV !== "production") for (let e in t) P("Data", e), $i(e[0]) || Object.defineProperty(r, e, {
|
|
1943
1943
|
configurable: !0,
|
|
1944
1944
|
enumerable: !0,
|
|
@@ -1970,10 +1970,10 @@ function ca(e) {
|
|
|
1970
1970
|
});
|
|
1971
1971
|
}
|
|
1972
1972
|
u && ua(u, e, "c");
|
|
1973
|
-
function
|
|
1973
|
+
function I(e, t) {
|
|
1974
1974
|
O(t) ? t.forEach((t) => e(t.bind(n))) : t && e(t.bind(n));
|
|
1975
1975
|
}
|
|
1976
|
-
if (
|
|
1976
|
+
if (I(zi, d), I(Bi, f), I(Vi, p), I(Hi, m), I(Ni, h), I(Pi, g), I(Ji, T), I(qi, C), I(Ki, w), I(Ui, v), I(Wi, x), I(Gi, E), O(D)) if (D.length) {
|
|
1977
1977
|
let t = e.exposed ||= {};
|
|
1978
1978
|
D.forEach((e) => {
|
|
1979
1979
|
Object.defineProperty(t, 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[`${z(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 || !(ue(
|
|
2178
|
+
if (r) if (!(t in r)) (!i || !(ue(z(t)) in i)) && G(`Component emitted event "${t}" but it is neither declared in the emits option nor as an "${ue(z(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}".`));
|
|
@@ -2186,7 +2186,7 @@ function Da(e, t, ...n) {
|
|
|
2186
2186
|
let n = t.toLowerCase();
|
|
2187
2187
|
n !== t && r[ue(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 = ue(t)] || r[s = ue(
|
|
2189
|
+
let s, c = r[s = ue(t)] || r[s = ue(z(t))];
|
|
2190
2190
|
!c && a && (c = r[s = ue(ce(t))]), c && zn(c, e, 6, i);
|
|
2191
2191
|
let l = r[s + "Once"];
|
|
2192
2192
|
if (l) {
|
|
@@ -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 = z(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);
|
|
@@ -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 (re(c)) continue;
|
|
2372
2372
|
let l = t[c], u;
|
|
2373
|
-
i && D(i, u =
|
|
2373
|
+
i && D(i, u = z(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;
|
|
@@ -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 = z(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 = z(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] !== "$" && !re(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) => z(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 = L(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 = ce(e),
|
|
2580
|
+
e && !Jo(e, t) && (r = ce(e), ie(e, i, a, !0), e = null), t.patchFlag === -2 && (c = !1, t.dynamicChildren = null);
|
|
2581
2581
|
let { type: l, ref: u, shapeFlag: d } = t;
|
|
2582
2582
|
switch (l) {
|
|
2583
2583
|
case Lo:
|
|
@@ -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" && !re(e) && a(f, e, null, m[e], c, i);
|
|
2635
2635
|
"value" in m && a(f, "value", null, m.value, c), (p = m.onVnodeBeforeMount) && ls(p, i, e);
|
|
2636
2636
|
}
|
|
2637
2637
|
process.env.NODE_ENV !== "production" && (pe(f, "__vnode", e, !0), pe(f, "__vueParentComponent", i, !0)), _ && Br(e, null, i, "beforeMount");
|
|
@@ -2668,7 +2668,7 @@ function Eo(e, t) {
|
|
|
2668
2668
|
let { patchFlag: l, dynamicChildren: d, dirs: f } = t;
|
|
2669
2669
|
l |= e.patchFlag & 16;
|
|
2670
2670
|
let p = e.props || v, m = t.props || v, h;
|
|
2671
|
-
if (n && Oo(n, !1), (h = m.onVnodeBeforeUpdate) && ls(h, n, t, e), f && Br(t, e, n, "beforeUpdate"), n && Oo(n, !0), (process.env.NODE_ENV !== "production" && or || d && (!e.dynamicChildren || e.dynamicChildren.length !== d.length)) && (l = 0, s = !1, d = null), (p.innerHTML && m.innerHTML == null || p.textContent && m.textContent == null) && u(c, ""), d ? (A(e.dynamicChildren, d, c, n, r, Do(t, i), o), process.env.NODE_ENV !== "production" && Ao(e, t)) : s ||
|
|
2671
|
+
if (n && Oo(n, !1), (h = m.onVnodeBeforeUpdate) && ls(h, n, t, e), f && Br(t, e, n, "beforeUpdate"), n && Oo(n, !0), (process.env.NODE_ENV !== "production" && or || d && (!e.dynamicChildren || e.dynamicChildren.length !== d.length)) && (l = 0, s = !1, d = null), (p.innerHTML && m.innerHTML == null || p.textContent && m.textContent == null) && u(c, ""), d ? (A(e.dynamicChildren, d, c, n, r, Do(t, i), o), process.env.NODE_ENV !== "production" && Ao(e, t)) : s || te(e, t, c, null, n, r, Do(t, i), o, !1), l > 0) {
|
|
2672
2672
|
if (l & 16) j(c, p, m, n, i);
|
|
2673
2673
|
else if (l & 2 && p.class !== m.class && a(c, "class", null, m.class, i), l & 4 && a(c, "style", p.style, m.style, i), l & 8) {
|
|
2674
2674
|
let e = t.dynamicProps;
|
|
@@ -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) !re(o) && !(o in n) && a(e, o, t[o], null, i, r);
|
|
2693
2693
|
for (let o in n) {
|
|
2694
|
-
if (
|
|
2694
|
+
if (re(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
|
}
|
|
@@ -2699,33 +2699,33 @@ function Eo(e, t) {
|
|
|
2699
2699
|
}
|
|
2700
2700
|
}, M = (e, t, n, i, a, o, c, l, u) => {
|
|
2701
2701
|
let d = t.el = e ? e.el : s(""), f = t.anchor = e ? e.anchor : s(""), { patchFlag: p, dynamicChildren: m, slotScopeIds: h } = t;
|
|
2702
|
-
process.env.NODE_ENV !== "production" && (or || p & 2048) && (p = 0, u = !1, m = null), h && (l = l ? l.concat(h) : h), e == null ? (r(d, n, i), r(f, n, i), O(t.children || [], n, f, a, o, c, l, u)) : p > 0 && p & 64 && m && e.dynamicChildren && e.dynamicChildren.length === m.length ? (A(e.dynamicChildren, m, n, a, o, c, l), process.env.NODE_ENV === "production" ? (t.key != null || a && t === a.subTree) && Ao(e, t, !0) : Ao(e, t)) :
|
|
2702
|
+
process.env.NODE_ENV !== "production" && (or || p & 2048) && (p = 0, u = !1, m = null), h && (l = l ? l.concat(h) : h), e == null ? (r(d, n, i), r(f, n, i), O(t.children || [], n, f, a, o, c, l, u)) : p > 0 && p & 64 && m && e.dynamicChildren && e.dynamicChildren.length === m.length ? (A(e.dynamicChildren, m, n, a, o, c, l), process.env.NODE_ENV === "production" ? (t.key != null || a && t === a.subTree) && Ao(e, t, !0) : Ao(e, t)) : te(e, t, n, f, a, o, c, l, u);
|
|
2703
2703
|
}, N = (e, t, n, r, i, a, o, s, c) => {
|
|
2704
2704
|
t.slotScopeIds = s, e == null ? t.shapeFlag & 512 ? i.ctx.activate(t, n, r, o, c) : P(t, n, r, i, a, o, c) : F(e, t, c);
|
|
2705
2705
|
}, P = (e, t, n, r, i, a, o) => {
|
|
2706
2706
|
let s = e.component = fs(e, r, i);
|
|
2707
2707
|
if (process.env.NODE_ENV !== "production" && s.type.__hmrId && ur(s), process.env.NODE_ENV !== "production" && (On(e), bo(s, "mount")), Mi(e) && (s.ctx.renderer = de), process.env.NODE_ENV !== "production" && bo(s, "init"), Cs(s, !1, o), process.env.NODE_ENV !== "production" && xo(s, "init"), process.env.NODE_ENV !== "production" && or && (e.el = null), s.asyncDep) {
|
|
2708
|
-
if (i && i.registerDep(s,
|
|
2708
|
+
if (i && i.registerDep(s, ee, o), !e.el) {
|
|
2709
2709
|
let r = s.subTree = $o(Ro);
|
|
2710
2710
|
_(null, r, t, n), e.placeholder = r.el;
|
|
2711
2711
|
}
|
|
2712
|
-
} else
|
|
2712
|
+
} else ee(s, e, t, n, i, a, o);
|
|
2713
2713
|
process.env.NODE_ENV !== "production" && (kn(), xo(s, "mount"));
|
|
2714
2714
|
}, F = (e, t, n) => {
|
|
2715
2715
|
let r = t.component = e.component;
|
|
2716
2716
|
if (za(e, t, n)) if (r.asyncDep && !r.asyncResolved) {
|
|
2717
|
-
process.env.NODE_ENV !== "production" && On(t),
|
|
2717
|
+
process.env.NODE_ENV !== "production" && On(t), I(r, t, n), process.env.NODE_ENV !== "production" && kn();
|
|
2718
2718
|
return;
|
|
2719
2719
|
} else r.next = t, r.update();
|
|
2720
2720
|
else t.el = e.el, r.vnode = t;
|
|
2721
|
-
},
|
|
2721
|
+
}, ee = (e, t, n, r, i, a, o) => {
|
|
2722
2722
|
let s = () => {
|
|
2723
2723
|
if (e.isMounted) {
|
|
2724
2724
|
let { next: t, bu: n, u: r, parent: s, vnode: c } = e;
|
|
2725
2725
|
{
|
|
2726
2726
|
let n = Mo(e);
|
|
2727
2727
|
if (n) {
|
|
2728
|
-
t && (t.el = c.el,
|
|
2728
|
+
t && (t.el = c.el, I(e, t, o)), n.asyncDep.then(() => {
|
|
2729
2729
|
wo(() => {
|
|
2730
2730
|
e.isUnmounted || l();
|
|
2731
2731
|
}, i);
|
|
@@ -2734,7 +2734,7 @@ function Eo(e, t) {
|
|
|
2734
2734
|
}
|
|
2735
2735
|
}
|
|
2736
2736
|
let u = t, f;
|
|
2737
|
-
process.env.NODE_ENV !== "production" && On(t || e.vnode), Oo(e, !1), t ? (t.el = c.el,
|
|
2737
|
+
process.env.NODE_ENV !== "production" && On(t || e.vnode), Oo(e, !1), t ? (t.el = c.el, I(e, t, o)) : t = c, n && fe(n), (f = t.props && t.props.onVnodeBeforeUpdate) && ls(f, s, t, c), Oo(e, !0), process.env.NODE_ENV !== "production" && bo(e, "render");
|
|
2738
2738
|
let p = Na(e);
|
|
2739
2739
|
process.env.NODE_ENV !== "production" && xo(e, "render");
|
|
2740
2740
|
let m = e.subTree;
|
|
@@ -2763,23 +2763,23 @@ function Eo(e, t) {
|
|
|
2763
2763
|
e.scope.off();
|
|
2764
2764
|
let l = e.update = c.run.bind(c), u = e.job = c.runIfDirty.bind(c);
|
|
2765
2765
|
u.i = e, u.id = e.uid, c.scheduler = () => Qn(u), Oo(e, !0), process.env.NODE_ENV !== "production" && (c.onTrack = e.rtc ? (t) => fe(e.rtc, t) : void 0, c.onTrigger = e.rtg ? (t) => fe(e.rtg, t) : void 0), l();
|
|
2766
|
-
},
|
|
2766
|
+
}, I = (e, t, n) => {
|
|
2767
2767
|
t.component = e;
|
|
2768
2768
|
let r = e.vnode.props;
|
|
2769
2769
|
e.vnode = t, e.next = null, Ja(e, t.props, r, n), _o(e, t.children, n), rt(), tr(e), it();
|
|
2770
|
-
},
|
|
2770
|
+
}, te = (e, t, n, r, i, a, o, s, c = !1) => {
|
|
2771
2771
|
let l = e && e.children, d = e ? e.shapeFlag : 0, f = t.children, { patchFlag: p, shapeFlag: m } = t;
|
|
2772
2772
|
if (p > 0) {
|
|
2773
2773
|
if (p & 128) {
|
|
2774
|
-
|
|
2774
|
+
R(l, f, n, r, i, a, o, s, c);
|
|
2775
2775
|
return;
|
|
2776
2776
|
} else if (p & 256) {
|
|
2777
|
-
|
|
2777
|
+
L(l, f, n, r, i, a, o, s, c);
|
|
2778
2778
|
return;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
|
-
m & 8 ? (d & 16 && se(l, i, a), f !== l && u(n, f)) : d & 16 ? m & 16 ?
|
|
2782
|
-
},
|
|
2781
|
+
m & 8 ? (d & 16 && se(l, i, a), f !== l && u(n, f)) : d & 16 ? m & 16 ? R(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
|
+
}, L = (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++) {
|
|
@@ -2787,7 +2787,7 @@ function Eo(e, t) {
|
|
|
2787
2787
|
h(e[f], r, n, null, i, a, o, s, c);
|
|
2788
2788
|
}
|
|
2789
2789
|
l > u ? se(e, i, a, !0, !1, d) : O(t, n, r, i, a, o, s, c, d);
|
|
2790
|
-
},
|
|
2790
|
+
}, R = (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;) ie(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
|
+
ie(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 ? ie(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[_] ? ne(d, n, p, 2) : _--);
|
|
2836
2836
|
}
|
|
2837
2837
|
}
|
|
2838
|
-
},
|
|
2838
|
+
}, ne = (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
|
+
ne(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++) ne(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
|
+
}, ie = (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) z(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, de, 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 &&
|
|
2888
|
+
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n, de, 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 && ae(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
|
+
}, ae = (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) : ae(e);
|
|
2899
|
+
}) : oe(n, r);
|
|
2900
2900
|
return;
|
|
2901
2901
|
}
|
|
2902
2902
|
if (t === zo) {
|
|
@@ -2910,18 +2910,18 @@ 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
|
+
}, oe = (e, t) => {
|
|
2914
2914
|
let n;
|
|
2915
2915
|
for (; e !== t;) n = f(e), i(e), e = n;
|
|
2916
2916
|
i(t);
|
|
2917
|
-
},
|
|
2917
|
+
}, z = (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 && fe(r), i.stop(), a && (a.flags |= 8,
|
|
2920
|
+
No(c), No(l), r && fe(r), i.stop(), a && (a.flags |= 8, ie(o, e, t, n)), s && wo(s, t), wo(() => {
|
|
2921
2921
|
e.isUnmounted = !0;
|
|
2922
2922
|
}, t), process.env.NODE_ENV !== "production" && Or(e);
|
|
2923
2923
|
}, se = (e, t, n, r = !1, i = !1, a = 0) => {
|
|
2924
|
-
for (let o = a; o < e.length; o++)
|
|
2924
|
+
for (let o = a; o < e.length; o++) ie(e[o], t, n, r, i);
|
|
2925
2925
|
}, ce = (e) => {
|
|
2926
2926
|
if (e.shapeFlag & 6) return ce(e.component.subTree);
|
|
2927
2927
|
if (e.shapeFlag & 128) return e.suspense.next();
|
|
@@ -2929,15 +2929,15 @@ function Eo(e, t) {
|
|
|
2929
2929
|
return n ? f(n) : t;
|
|
2930
2930
|
}, le = !1, ue = (e, t, n) => {
|
|
2931
2931
|
let r;
|
|
2932
|
-
e == null ? t._vnode && (
|
|
2932
|
+
e == null ? t._vnode && (ie(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e, le ||= (le = !0, tr(r), nr(), !1);
|
|
2933
2933
|
}, de = {
|
|
2934
2934
|
p: h,
|
|
2935
|
-
um:
|
|
2936
|
-
m:
|
|
2937
|
-
r:
|
|
2935
|
+
um: ie,
|
|
2936
|
+
m: ne,
|
|
2937
|
+
r: ae,
|
|
2938
2938
|
mt: P,
|
|
2939
2939
|
mc: O,
|
|
2940
|
-
pc:
|
|
2940
|
+
pc: te,
|
|
2941
2941
|
pbc: A,
|
|
2942
2942
|
n: ce,
|
|
2943
2943
|
o: e
|
|
@@ -3073,7 +3073,7 @@ function es(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
3073
3073
|
if (Rs(e) && (e = e.__vccOpts), t) {
|
|
3074
3074
|
t = ts(t);
|
|
3075
3075
|
let { class: e, style: n } = t;
|
|
3076
|
-
e && !N(e) && (t.class = Se(e)), F(n) && (/* @__PURE__ */ sn(n) && !O(n) && (n = w({}, n)), t.style =
|
|
3076
|
+
e && !N(e) && (t.class = Se(e)), F(n) && (/* @__PURE__ */ sn(n) && !O(n) && (n = w({}, n)), t.style = ve(n));
|
|
3077
3077
|
}
|
|
3078
3078
|
let o = N(e) ? 1 : Fo(e) ? 128 : Zr(e) ? 64 : F(e) ? 4 : M(e) ? 2 : 0;
|
|
3079
3079
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ sn(e) && (e = /* @__PURE__ */ U(e), G("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), Y(e, t, n, r, i, o, a, !0);
|
|
@@ -3161,7 +3161,7 @@ function cs(...e) {
|
|
|
3161
3161
|
for (let n = 0; n < e.length; n++) {
|
|
3162
3162
|
let r = e[n];
|
|
3163
3163
|
for (let e in r) if (e === "class") t.class !== r.class && (t.class = Se([t.class, r.class]));
|
|
3164
|
-
else if (e === "style") t.style =
|
|
3164
|
+
else if (e === "style") t.style = ve([t.style, r.style]);
|
|
3165
3165
|
else if (S(e)) {
|
|
3166
3166
|
let n = t[e], i = r[e];
|
|
3167
3167
|
i && n !== i && !(O(n) && n.includes(i)) ? t[e] = n ? [].concat(n, i) : i : i == null && n == null && !C(e) && (t[e] = i);
|
|
@@ -3289,7 +3289,7 @@ function ws(e, t) {
|
|
|
3289
3289
|
let { setup: r } = n;
|
|
3290
3290
|
if (r) {
|
|
3291
3291
|
rt();
|
|
3292
|
-
let i = e.setupContext = r.length > 1 ? Ms(e) : null, a = _s(e), o = Rn(r, e, 0, [process.env.NODE_ENV === "production" ? e.props : /* @__PURE__ */ tn(e.props), i]), s =
|
|
3292
|
+
let i = e.setupContext = r.length > 1 ? Ms(e) : null, a = _s(e), o = Rn(r, e, 0, [process.env.NODE_ENV === "production" ? e.props : /* @__PURE__ */ tn(e.props), i]), s = ee(o);
|
|
3293
3293
|
if (it(), a(), (s || e.sp) && !ji(e) && Ti(e), s) {
|
|
3294
3294
|
if (o.then(vs, vs), t) return o.then((n) => {
|
|
3295
3295
|
Ts(e, n, t);
|
|
@@ -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 = z(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++) {
|
|
@@ -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, z(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 = z(t);
|
|
3913
|
+
return Array.isArray(n) ? n.some((e) => z(e) === r) : Object.keys(n).some((e) => z(e) === r);
|
|
3914
3914
|
}
|
|
3915
3915
|
var Qc = (e) => {
|
|
3916
3916
|
let t = e.props["onUpdate:modelValue"] || !1;
|
|
@@ -5901,7 +5901,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
5901
5901
|
end: "\"",
|
|
5902
5902
|
illegal: "\\n",
|
|
5903
5903
|
contains: [M]
|
|
5904
|
-
}, F = { begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ },
|
|
5904
|
+
}, F = { begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ }, ee = function(e, t, n = {}) {
|
|
5905
5905
|
let r = a({
|
|
5906
5906
|
scope: "comment",
|
|
5907
5907
|
begin: e,
|
|
@@ -5917,7 +5917,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
5917
5917
|
});
|
|
5918
5918
|
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,}/);
|
|
5919
5919
|
return r.contains.push({ begin: _(/[ ]+/, "(", i, /[.]?[:]?([.][ ]|[ ])/, "){3}") }), r;
|
|
5920
|
-
},
|
|
5920
|
+
}, I = ee("//", "$"), te = ee("/\\*", "\\*/"), L = ee("#", "$"), R = /*#__PURE__*/ Object.freeze({
|
|
5921
5921
|
__proto__: null,
|
|
5922
5922
|
APOS_STRING_MODE: N,
|
|
5923
5923
|
BACKSLASH_ESCAPE: M,
|
|
@@ -5927,9 +5927,9 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
5927
5927
|
relevance: 0
|
|
5928
5928
|
},
|
|
5929
5929
|
BINARY_NUMBER_RE: k,
|
|
5930
|
-
COMMENT:
|
|
5931
|
-
C_BLOCK_COMMENT_MODE:
|
|
5932
|
-
C_LINE_COMMENT_MODE:
|
|
5930
|
+
COMMENT: ee,
|
|
5931
|
+
C_BLOCK_COMMENT_MODE: te,
|
|
5932
|
+
C_LINE_COMMENT_MODE: I,
|
|
5933
5933
|
C_NUMBER_MODE: {
|
|
5934
5934
|
scope: "number",
|
|
5935
5935
|
begin: O,
|
|
@@ -5946,7 +5946,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
5946
5946
|
}
|
|
5947
5947
|
});
|
|
5948
5948
|
},
|
|
5949
|
-
HASH_COMMENT_MODE:
|
|
5949
|
+
HASH_COMMENT_MODE: L,
|
|
5950
5950
|
IDENT_RE: T,
|
|
5951
5951
|
MATCH_NOTHING_RE: w,
|
|
5952
5952
|
METHOD_GUARD: {
|
|
@@ -5986,25 +5986,25 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
5986
5986
|
relevance: 0
|
|
5987
5987
|
}
|
|
5988
5988
|
});
|
|
5989
|
-
function te(e, t) {
|
|
5990
|
-
e.input[e.index - 1] === "." && t.ignoreMatch();
|
|
5991
|
-
}
|
|
5992
5989
|
function ne(e, t) {
|
|
5993
|
-
e.
|
|
5990
|
+
e.input[e.index - 1] === "." && t.ignoreMatch();
|
|
5994
5991
|
}
|
|
5995
5992
|
function re(e, t) {
|
|
5996
|
-
|
|
5993
|
+
e.className !== void 0 && (e.scope = e.className, delete e.className);
|
|
5997
5994
|
}
|
|
5998
5995
|
function ie(e, t) {
|
|
5999
|
-
|
|
5996
|
+
t && e.beginKeywords && (e.begin = "\\b(" + e.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)", e.__beforeBegin = ne, e.keywords = e.keywords || e.beginKeywords, delete e.beginKeywords, e.relevance === void 0 && (e.relevance = 0));
|
|
6000
5997
|
}
|
|
6001
5998
|
function ae(e, t) {
|
|
5999
|
+
Array.isArray(e.illegal) && (e.illegal = y(...e.illegal));
|
|
6000
|
+
}
|
|
6001
|
+
function oe(e, t) {
|
|
6002
6002
|
if (e.match) {
|
|
6003
6003
|
if (e.begin || e.end) throw Error("begin & end are not supported with match");
|
|
6004
6004
|
e.begin = e.match, delete e.match;
|
|
6005
6005
|
}
|
|
6006
6006
|
}
|
|
6007
|
-
function
|
|
6007
|
+
function z(e, t) {
|
|
6008
6008
|
e.relevance === void 0 && (e.relevance = 1);
|
|
6009
6009
|
}
|
|
6010
6010
|
var se = (e, t) => {
|
|
@@ -6055,30 +6055,30 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6055
6055
|
}, ge = (e, t) => {
|
|
6056
6056
|
pe[`${e}/${t}`] || (console.log(`Deprecated as of ${e}. ${t}`), pe[`${e}/${t}`] = !0);
|
|
6057
6057
|
}, _e = /* @__PURE__ */ Error();
|
|
6058
|
-
function
|
|
6058
|
+
function ve(e, t, { key: n }) {
|
|
6059
6059
|
let r = 0, i = e[n], a = {}, o = {};
|
|
6060
6060
|
for (let e = 1; e <= t.length; e++) o[e + r] = i[e], a[e + r] = !0, r += b(t[e - 1]);
|
|
6061
6061
|
e[n] = o, e[n]._emit = a, e[n]._multi = !0;
|
|
6062
6062
|
}
|
|
6063
|
-
function
|
|
6063
|
+
function ye(e) {
|
|
6064
6064
|
if (Array.isArray(e.begin)) {
|
|
6065
6065
|
if (e.skip || e.excludeBegin || e.returnBegin) throw me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), _e;
|
|
6066
6066
|
if (typeof e.beginScope != "object" || e.beginScope === null) throw me("beginScope must be object"), _e;
|
|
6067
|
-
|
|
6067
|
+
ve(e, e.begin, { key: "beginScope" }), e.begin = C(e.begin, { joinWith: "" });
|
|
6068
6068
|
}
|
|
6069
6069
|
}
|
|
6070
|
-
function
|
|
6070
|
+
function B(e) {
|
|
6071
6071
|
if (Array.isArray(e.end)) {
|
|
6072
6072
|
if (e.skip || e.excludeEnd || e.returnEnd) throw me("skip, excludeEnd, returnEnd not compatible with endScope: {}"), _e;
|
|
6073
6073
|
if (typeof e.endScope != "object" || e.endScope === null) throw me("endScope must be object"), _e;
|
|
6074
|
-
|
|
6074
|
+
ve(e, e.end, { key: "endScope" }), e.end = C(e.end, { joinWith: "" });
|
|
6075
6075
|
}
|
|
6076
6076
|
}
|
|
6077
6077
|
function be(e) {
|
|
6078
6078
|
e.scope && typeof e.scope == "object" && e.scope !== null && (e.beginScope = e.scope, delete e.scope);
|
|
6079
6079
|
}
|
|
6080
6080
|
function xe(e) {
|
|
6081
|
-
be(e), typeof e.beginScope == "string" && (e.beginScope = { _wrap: e.beginScope }), typeof e.endScope == "string" && (e.endScope = { _wrap: e.endScope }),
|
|
6081
|
+
be(e), typeof e.beginScope == "string" && (e.beginScope = { _wrap: e.beginScope }), typeof e.endScope == "string" && (e.endScope = { _wrap: e.endScope }), ye(e), B(e);
|
|
6082
6082
|
}
|
|
6083
6083
|
function Se(e) {
|
|
6084
6084
|
function t(t, n) {
|
|
@@ -6144,14 +6144,14 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6144
6144
|
let a = n;
|
|
6145
6145
|
if (n.isCompiled) return a;
|
|
6146
6146
|
[
|
|
6147
|
-
|
|
6148
|
-
|
|
6147
|
+
re,
|
|
6148
|
+
oe,
|
|
6149
6149
|
xe,
|
|
6150
6150
|
se
|
|
6151
6151
|
].forEach((e) => e(n, r)), e.compilerExtensions.forEach((e) => e(n, r)), n.__beforeBegin = null, [
|
|
6152
|
-
re,
|
|
6153
6152
|
ie,
|
|
6154
|
-
|
|
6153
|
+
ae,
|
|
6154
|
+
z
|
|
6155
6155
|
].forEach((e) => e(n, r)), n.isCompiled = !0;
|
|
6156
6156
|
let s = null;
|
|
6157
6157
|
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 &&= ue(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) {
|
|
@@ -6210,9 +6210,9 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6210
6210
|
code: r,
|
|
6211
6211
|
language: i
|
|
6212
6212
|
};
|
|
6213
|
-
|
|
6213
|
+
L("before:highlight", a);
|
|
6214
6214
|
let o = a.result ? a.result : v(a.language, a.code, n);
|
|
6215
|
-
return o.code = a.code,
|
|
6215
|
+
return o.code = a.code, L("after:highlight", o), o;
|
|
6216
6216
|
}
|
|
6217
6217
|
function v(e, n, i, a) {
|
|
6218
6218
|
let c = Object.create(null);
|
|
@@ -6289,7 +6289,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6289
6289
|
if (e.endsWithParent) return _(e.parent, t, n);
|
|
6290
6290
|
}
|
|
6291
6291
|
function y(e) {
|
|
6292
|
-
return A.matcher.regexIndex === 0 ? (P += e[0], 1) : (
|
|
6292
|
+
return A.matcher.regexIndex === 0 ? (P += e[0], 1) : (te = !0, 0);
|
|
6293
6293
|
}
|
|
6294
6294
|
function b(e) {
|
|
6295
6295
|
let t = e[0], n = e.rule, i = new r(n), a = [n.__beforeBegin, n["on:begin"]];
|
|
@@ -6331,25 +6331,25 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6331
6331
|
if (e !== ke) return e;
|
|
6332
6332
|
}
|
|
6333
6333
|
if (r.type === "illegal" && a === "") return P += "\n", 1;
|
|
6334
|
-
if (
|
|
6334
|
+
if (I > 1e5 && I > r.index * 3) throw /* @__PURE__ */ Error("potential infinite loop, way more iterations than matches");
|
|
6335
6335
|
return P += a, a.length;
|
|
6336
6336
|
}
|
|
6337
6337
|
let D = N(e);
|
|
6338
6338
|
if (!D) throw me(s.replace("{}", e)), Error("Unknown language: \"" + e + "\"");
|
|
6339
6339
|
let O = Se(D), k = "", A = a || O, j = {}, M = new l.__emitter(l);
|
|
6340
6340
|
w();
|
|
6341
|
-
let P = "", F = 0,
|
|
6341
|
+
let P = "", F = 0, ee = 0, I = 0, te = !1;
|
|
6342
6342
|
try {
|
|
6343
6343
|
if (D.__emitTokens) D.__emitTokens(n, M);
|
|
6344
6344
|
else {
|
|
6345
6345
|
for (A.matcher.considerAll();;) {
|
|
6346
|
-
|
|
6346
|
+
I++, te ? te = !1 : A.matcher.considerAll(), A.matcher.lastIndex = ee;
|
|
6347
6347
|
let e = A.matcher.exec(n);
|
|
6348
6348
|
if (!e) break;
|
|
6349
|
-
let t = E(n.substring(
|
|
6350
|
-
|
|
6349
|
+
let t = E(n.substring(ee, e.index), e);
|
|
6350
|
+
ee = e.index + t;
|
|
6351
6351
|
}
|
|
6352
|
-
E(n.substring(
|
|
6352
|
+
E(n.substring(ee));
|
|
6353
6353
|
}
|
|
6354
6354
|
return M.finalize(), k = M.toHTML(), {
|
|
6355
6355
|
language: e,
|
|
@@ -6367,8 +6367,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6367
6367
|
relevance: 0,
|
|
6368
6368
|
_illegalBy: {
|
|
6369
6369
|
message: t.message,
|
|
6370
|
-
index:
|
|
6371
|
-
context: n.slice(
|
|
6370
|
+
index: ee,
|
|
6371
|
+
context: n.slice(ee - 100, ee + 100),
|
|
6372
6372
|
mode: t.mode,
|
|
6373
6373
|
resultSoFar: k
|
|
6374
6374
|
},
|
|
@@ -6417,7 +6417,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6417
6417
|
function w(e) {
|
|
6418
6418
|
let t = null, n = d(e);
|
|
6419
6419
|
if (u(n)) return;
|
|
6420
|
-
if (
|
|
6420
|
+
if (L("before:highlightElement", {
|
|
6421
6421
|
el: e,
|
|
6422
6422
|
language: n
|
|
6423
6423
|
}), e.dataset.highlighted) {
|
|
@@ -6437,7 +6437,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6437
6437
|
}, i.secondBest && (e.secondBest = {
|
|
6438
6438
|
language: i.secondBest.language,
|
|
6439
6439
|
relevance: i.secondBest.relevance
|
|
6440
|
-
}),
|
|
6440
|
+
}), L("after:highlightElement", {
|
|
6441
6441
|
el: e,
|
|
6442
6442
|
result: i,
|
|
6443
6443
|
text: r
|
|
@@ -6493,27 +6493,27 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6493
6493
|
let t = N(e);
|
|
6494
6494
|
return t && !t.disableAutodetect;
|
|
6495
6495
|
}
|
|
6496
|
-
function
|
|
6496
|
+
function ee(e) {
|
|
6497
6497
|
e["before:highlightBlock"] && !e["before:highlightElement"] && (e["before:highlightElement"] = (t) => {
|
|
6498
6498
|
e["before:highlightBlock"](Object.assign({ block: t.el }, t));
|
|
6499
6499
|
}), e["after:highlightBlock"] && !e["after:highlightElement"] && (e["after:highlightElement"] = (t) => {
|
|
6500
6500
|
e["after:highlightBlock"](Object.assign({ block: t.el }, t));
|
|
6501
6501
|
});
|
|
6502
6502
|
}
|
|
6503
|
-
function
|
|
6504
|
-
|
|
6503
|
+
function I(e) {
|
|
6504
|
+
ee(e), a.push(e);
|
|
6505
6505
|
}
|
|
6506
|
-
function
|
|
6506
|
+
function te(e) {
|
|
6507
6507
|
let t = a.indexOf(e);
|
|
6508
6508
|
t !== -1 && a.splice(t, 1);
|
|
6509
6509
|
}
|
|
6510
|
-
function
|
|
6510
|
+
function L(e, t) {
|
|
6511
6511
|
let n = e;
|
|
6512
6512
|
a.forEach(function(e) {
|
|
6513
6513
|
e[n] && e[n](t);
|
|
6514
6514
|
});
|
|
6515
6515
|
}
|
|
6516
|
-
function
|
|
6516
|
+
function ne(e) {
|
|
6517
6517
|
return ge("10.7.0", "highlightBlock will be removed entirely in v12.0"), ge("10.7.0", "Please use highlightElement now."), w(e);
|
|
6518
6518
|
}
|
|
6519
6519
|
Object.assign(e, {
|
|
@@ -6521,7 +6521,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6521
6521
|
highlightAuto: S,
|
|
6522
6522
|
highlightAll: k,
|
|
6523
6523
|
highlightElement: w,
|
|
6524
|
-
highlightBlock:
|
|
6524
|
+
highlightBlock: ne,
|
|
6525
6525
|
configure: T,
|
|
6526
6526
|
initHighlighting: E,
|
|
6527
6527
|
initHighlightingOnLoad: D,
|
|
@@ -6532,8 +6532,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6532
6532
|
registerAliases: P,
|
|
6533
6533
|
autoDetection: F,
|
|
6534
6534
|
inherit: Oe,
|
|
6535
|
-
addPlugin:
|
|
6536
|
-
removePlugin:
|
|
6535
|
+
addPlugin: I,
|
|
6536
|
+
removePlugin: te
|
|
6537
6537
|
}), e.debugMode = function() {
|
|
6538
6538
|
o = !1;
|
|
6539
6539
|
}, e.safeMode = function() {
|
|
@@ -6545,8 +6545,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6545
6545
|
optional: g,
|
|
6546
6546
|
anyNumberOfTimes: h
|
|
6547
6547
|
};
|
|
6548
|
-
for (let e in
|
|
6549
|
-
return Object.assign(e,
|
|
6548
|
+
for (let e in R) typeof R[e] == "object" && n(R[e]);
|
|
6549
|
+
return Object.assign(e, R), e;
|
|
6550
6550
|
}, Me = je({});
|
|
6551
6551
|
Me.newInstance = () => je({}), t.exports = Me, Me.HighlightJS = Me, Me.default = Me;
|
|
6552
6552
|
})), nd = /* @__PURE__ */ m(((e, t) => {
|
|
@@ -8872,7 +8872,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8872
8872
|
function F(e) {
|
|
8873
8873
|
return t.concat("(?!", e.join("|"), ")");
|
|
8874
8874
|
}
|
|
8875
|
-
let
|
|
8875
|
+
let ee = {
|
|
8876
8876
|
match: t.concat(/\b/, F([
|
|
8877
8877
|
...s,
|
|
8878
8878
|
"super",
|
|
@@ -8880,14 +8880,14 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8880
8880
|
].map((e) => `${e}\\s*\\(`)), d, t.lookahead(/\s*\(/)),
|
|
8881
8881
|
className: "title.function",
|
|
8882
8882
|
relevance: 0
|
|
8883
|
-
},
|
|
8883
|
+
}, I = {
|
|
8884
8884
|
begin: t.concat(/\./, t.lookahead(t.concat(d, /(?![0-9A-Za-z$_(])/))),
|
|
8885
8885
|
end: d,
|
|
8886
8886
|
excludeBegin: !0,
|
|
8887
8887
|
keywords: "prototype",
|
|
8888
8888
|
className: "property",
|
|
8889
8889
|
relevance: 0
|
|
8890
|
-
},
|
|
8890
|
+
}, te = {
|
|
8891
8891
|
match: [
|
|
8892
8892
|
/get|set/,
|
|
8893
8893
|
/\s+/,
|
|
@@ -8899,7 +8899,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8899
8899
|
3: "title.function"
|
|
8900
8900
|
},
|
|
8901
8901
|
contains: [{ begin: /\(\)/ }, k]
|
|
8902
|
-
},
|
|
8902
|
+
}, L = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", R = {
|
|
8903
8903
|
match: [
|
|
8904
8904
|
/const|var|let/,
|
|
8905
8905
|
/\s+/,
|
|
@@ -8907,7 +8907,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8907
8907
|
/\s*/,
|
|
8908
8908
|
/=\s*/,
|
|
8909
8909
|
/(async\s*)?/,
|
|
8910
|
-
t.lookahead(
|
|
8910
|
+
t.lookahead(L)
|
|
8911
8911
|
],
|
|
8912
8912
|
keywords: "async",
|
|
8913
8913
|
className: {
|
|
@@ -8952,7 +8952,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8952
8952
|
match: d + t.lookahead(":"),
|
|
8953
8953
|
relevance: 0
|
|
8954
8954
|
},
|
|
8955
|
-
|
|
8955
|
+
R,
|
|
8956
8956
|
{
|
|
8957
8957
|
begin: "(" + e.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
|
|
8958
8958
|
keywords: "return throw case",
|
|
@@ -8962,7 +8962,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
8962
8962
|
e.REGEXP_MODE,
|
|
8963
8963
|
{
|
|
8964
8964
|
className: "function",
|
|
8965
|
-
begin:
|
|
8965
|
+
begin: L,
|
|
8966
8966
|
returnBegin: !0,
|
|
8967
8967
|
end: "\\s*=>",
|
|
8968
8968
|
contains: [{
|
|
@@ -9034,7 +9034,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
9034
9034
|
match: /\.\.\./,
|
|
9035
9035
|
relevance: 0
|
|
9036
9036
|
},
|
|
9037
|
-
|
|
9037
|
+
I,
|
|
9038
9038
|
{
|
|
9039
9039
|
match: "\\$[A-Za-z$_][0-9A-Za-z$_]*",
|
|
9040
9040
|
relevance: 0
|
|
@@ -9044,10 +9044,10 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
9044
9044
|
className: { 1: "title.function" },
|
|
9045
9045
|
contains: [k]
|
|
9046
9046
|
},
|
|
9047
|
-
|
|
9047
|
+
ee,
|
|
9048
9048
|
P,
|
|
9049
9049
|
A,
|
|
9050
|
-
|
|
9050
|
+
te,
|
|
9051
9051
|
{ match: /\$[(.]/ }
|
|
9052
9052
|
]
|
|
9053
9053
|
};
|
|
@@ -11313,68 +11313,68 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11313
11313
|
}, F = (e = "") => ({
|
|
11314
11314
|
className: "subst",
|
|
11315
11315
|
variants: [{ match: i(/\\/, e, /[0\\tnr"']/) }, { match: i(/\\/, e, /u\{[0-9a-fA-F]{1,8}\}/) }]
|
|
11316
|
-
}),
|
|
11316
|
+
}), ee = (e = "") => ({
|
|
11317
11317
|
className: "subst",
|
|
11318
11318
|
match: i(/\\/, e, /[\t ]*(?:[\r\n]|\r\n)/)
|
|
11319
|
-
}),
|
|
11319
|
+
}), I = (e = "") => ({
|
|
11320
11320
|
className: "subst",
|
|
11321
11321
|
label: "interpol",
|
|
11322
11322
|
begin: i(/\\/, e, /\(/),
|
|
11323
11323
|
end: /\)/
|
|
11324
|
-
}),
|
|
11324
|
+
}), te = (e = "") => ({
|
|
11325
11325
|
begin: i(e, /"""/),
|
|
11326
11326
|
end: i(/"""/, e),
|
|
11327
11327
|
contains: [
|
|
11328
11328
|
F(e),
|
|
11329
|
-
|
|
11330
|
-
|
|
11329
|
+
ee(e),
|
|
11330
|
+
I(e)
|
|
11331
11331
|
]
|
|
11332
|
-
}),
|
|
11332
|
+
}), L = (e = "") => ({
|
|
11333
11333
|
begin: i(e, /"/),
|
|
11334
11334
|
end: i(/"/, e),
|
|
11335
|
-
contains: [F(e),
|
|
11336
|
-
}),
|
|
11335
|
+
contains: [F(e), I(e)]
|
|
11336
|
+
}), R = {
|
|
11337
11337
|
className: "string",
|
|
11338
11338
|
variants: [
|
|
11339
|
-
|
|
11340
|
-
|
|
11341
|
-
|
|
11342
|
-
|
|
11343
|
-
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
11339
|
+
te(),
|
|
11340
|
+
te("#"),
|
|
11341
|
+
te("##"),
|
|
11342
|
+
te("###"),
|
|
11343
|
+
L(),
|
|
11344
|
+
L("#"),
|
|
11345
|
+
L("##"),
|
|
11346
|
+
L("###")
|
|
11347
11347
|
]
|
|
11348
|
-
},
|
|
11348
|
+
}, ne = [e.BACKSLASH_ESCAPE, {
|
|
11349
11349
|
begin: /\[/,
|
|
11350
11350
|
end: /\]/,
|
|
11351
11351
|
relevance: 0,
|
|
11352
11352
|
contains: [e.BACKSLASH_ESCAPE]
|
|
11353
|
-
}],
|
|
11353
|
+
}], re = {
|
|
11354
11354
|
begin: /\/[^\s](?=[^/\n]*\/)/,
|
|
11355
11355
|
end: /\//,
|
|
11356
|
-
contains:
|
|
11357
|
-
},
|
|
11356
|
+
contains: ne
|
|
11357
|
+
}, ie = (e) => {
|
|
11358
11358
|
let t = i(e, /\//), n = i(/\//, e);
|
|
11359
11359
|
return {
|
|
11360
11360
|
begin: t,
|
|
11361
11361
|
end: n,
|
|
11362
|
-
contains: [...
|
|
11362
|
+
contains: [...ne, {
|
|
11363
11363
|
scope: "comment",
|
|
11364
11364
|
begin: `#(?!.*${n})`,
|
|
11365
11365
|
end: /$/
|
|
11366
11366
|
}]
|
|
11367
11367
|
};
|
|
11368
|
-
},
|
|
11368
|
+
}, ae = {
|
|
11369
11369
|
scope: "regexp",
|
|
11370
11370
|
variants: [
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11371
|
+
ie("###"),
|
|
11372
|
+
ie("##"),
|
|
11373
|
+
ie("#"),
|
|
11374
|
+
re
|
|
11375
11375
|
]
|
|
11376
|
-
},
|
|
11377
|
-
|
|
11376
|
+
}, oe = { match: i(/`/, x, /`/) }, z = [
|
|
11377
|
+
oe,
|
|
11378
11378
|
{
|
|
11379
11379
|
className: "variable",
|
|
11380
11380
|
match: /\$\d+/
|
|
@@ -11394,7 +11394,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11394
11394
|
contains: [
|
|
11395
11395
|
...j,
|
|
11396
11396
|
P,
|
|
11397
|
-
|
|
11397
|
+
R
|
|
11398
11398
|
]
|
|
11399
11399
|
}] }
|
|
11400
11400
|
},
|
|
@@ -11458,13 +11458,13 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11458
11458
|
relevance: 0
|
|
11459
11459
|
},
|
|
11460
11460
|
...a,
|
|
11461
|
-
|
|
11461
|
+
ae,
|
|
11462
11462
|
...O,
|
|
11463
11463
|
...k,
|
|
11464
11464
|
...j,
|
|
11465
11465
|
P,
|
|
11466
|
-
|
|
11467
|
-
...
|
|
11466
|
+
R,
|
|
11467
|
+
...z,
|
|
11468
11468
|
...se,
|
|
11469
11469
|
ce
|
|
11470
11470
|
]
|
|
@@ -11494,7 +11494,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11494
11494
|
...O,
|
|
11495
11495
|
...j,
|
|
11496
11496
|
P,
|
|
11497
|
-
|
|
11497
|
+
R,
|
|
11498
11498
|
...se,
|
|
11499
11499
|
ce,
|
|
11500
11500
|
ue
|
|
@@ -11505,7 +11505,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11505
11505
|
match: [
|
|
11506
11506
|
/(func|macro)/,
|
|
11507
11507
|
/\s+/,
|
|
11508
|
-
o(
|
|
11508
|
+
o(oe.match, x, v)
|
|
11509
11509
|
],
|
|
11510
11510
|
className: {
|
|
11511
11511
|
1: "keyword",
|
|
@@ -11562,7 +11562,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11562
11562
|
3: "keyword",
|
|
11563
11563
|
5: "title.function"
|
|
11564
11564
|
}
|
|
11565
|
-
},
|
|
11565
|
+
}, ve = {
|
|
11566
11566
|
match: [
|
|
11567
11567
|
/class\b/,
|
|
11568
11568
|
/\s+/,
|
|
@@ -11572,7 +11572,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11572
11572
|
1: "keyword",
|
|
11573
11573
|
3: "keyword"
|
|
11574
11574
|
}
|
|
11575
|
-
},
|
|
11575
|
+
}, ye = {
|
|
11576
11576
|
begin: [
|
|
11577
11577
|
/(struct|protocol|class|extension|enum|actor)/,
|
|
11578
11578
|
/\s+/,
|
|
@@ -11599,7 +11599,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11599
11599
|
}
|
|
11600
11600
|
]
|
|
11601
11601
|
};
|
|
11602
|
-
for (let e of
|
|
11602
|
+
for (let e of R.variants) {
|
|
11603
11603
|
let t = e.contains.find((e) => e.label === "interpol");
|
|
11604
11604
|
t.keywords = D;
|
|
11605
11605
|
let n = [
|
|
@@ -11607,8 +11607,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11607
11607
|
...k,
|
|
11608
11608
|
...j,
|
|
11609
11609
|
P,
|
|
11610
|
-
|
|
11611
|
-
...
|
|
11610
|
+
R,
|
|
11611
|
+
...z
|
|
11612
11612
|
];
|
|
11613
11613
|
t.contains = [...n, {
|
|
11614
11614
|
begin: /\(/,
|
|
@@ -11624,8 +11624,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11624
11624
|
pe,
|
|
11625
11625
|
me,
|
|
11626
11626
|
_e,
|
|
11627
|
-
B,
|
|
11628
11627
|
ve,
|
|
11628
|
+
ye,
|
|
11629
11629
|
he,
|
|
11630
11630
|
ge,
|
|
11631
11631
|
{
|
|
@@ -11634,13 +11634,13 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11634
11634
|
contains: [...a],
|
|
11635
11635
|
relevance: 0
|
|
11636
11636
|
},
|
|
11637
|
-
|
|
11637
|
+
ae,
|
|
11638
11638
|
...O,
|
|
11639
11639
|
...k,
|
|
11640
11640
|
...j,
|
|
11641
11641
|
P,
|
|
11642
|
-
|
|
11643
|
-
...
|
|
11642
|
+
R,
|
|
11643
|
+
...z,
|
|
11644
11644
|
...se,
|
|
11645
11645
|
ce,
|
|
11646
11646
|
ue
|
|
@@ -12045,7 +12045,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12045
12045
|
function F(e) {
|
|
12046
12046
|
return t.concat("(?!", e.join("|"), ")");
|
|
12047
12047
|
}
|
|
12048
|
-
let
|
|
12048
|
+
let ee = {
|
|
12049
12049
|
match: t.concat(/\b/, F([
|
|
12050
12050
|
...s,
|
|
12051
12051
|
"super",
|
|
@@ -12053,14 +12053,14 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12053
12053
|
].map((e) => `${e}\\s*\\(`)), d, t.lookahead(/\s*\(/)),
|
|
12054
12054
|
className: "title.function",
|
|
12055
12055
|
relevance: 0
|
|
12056
|
-
},
|
|
12056
|
+
}, I = {
|
|
12057
12057
|
begin: t.concat(/\./, t.lookahead(t.concat(d, /(?![0-9A-Za-z$_(])/))),
|
|
12058
12058
|
end: d,
|
|
12059
12059
|
excludeBegin: !0,
|
|
12060
12060
|
keywords: "prototype",
|
|
12061
12061
|
className: "property",
|
|
12062
12062
|
relevance: 0
|
|
12063
|
-
},
|
|
12063
|
+
}, te = {
|
|
12064
12064
|
match: [
|
|
12065
12065
|
/get|set/,
|
|
12066
12066
|
/\s+/,
|
|
@@ -12072,7 +12072,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12072
12072
|
3: "title.function"
|
|
12073
12073
|
},
|
|
12074
12074
|
contains: [{ begin: /\(\)/ }, k]
|
|
12075
|
-
},
|
|
12075
|
+
}, L = "(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|" + e.UNDERSCORE_IDENT_RE + ")\\s*=>", R = {
|
|
12076
12076
|
match: [
|
|
12077
12077
|
/const|var|let/,
|
|
12078
12078
|
/\s+/,
|
|
@@ -12080,7 +12080,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12080
12080
|
/\s*/,
|
|
12081
12081
|
/=\s*/,
|
|
12082
12082
|
/(async\s*)?/,
|
|
12083
|
-
t.lookahead(
|
|
12083
|
+
t.lookahead(L)
|
|
12084
12084
|
],
|
|
12085
12085
|
keywords: "async",
|
|
12086
12086
|
className: {
|
|
@@ -12125,7 +12125,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12125
12125
|
match: d + t.lookahead(":"),
|
|
12126
12126
|
relevance: 0
|
|
12127
12127
|
},
|
|
12128
|
-
|
|
12128
|
+
R,
|
|
12129
12129
|
{
|
|
12130
12130
|
begin: "(" + e.RE_STARTERS_RE + "|\\b(case|return|throw)\\b)\\s*",
|
|
12131
12131
|
keywords: "return throw case",
|
|
@@ -12135,7 +12135,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12135
12135
|
e.REGEXP_MODE,
|
|
12136
12136
|
{
|
|
12137
12137
|
className: "function",
|
|
12138
|
-
begin:
|
|
12138
|
+
begin: L,
|
|
12139
12139
|
returnBegin: !0,
|
|
12140
12140
|
end: "\\s*=>",
|
|
12141
12141
|
contains: [{
|
|
@@ -12207,7 +12207,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12207
12207
|
match: /\.\.\./,
|
|
12208
12208
|
relevance: 0
|
|
12209
12209
|
},
|
|
12210
|
-
|
|
12210
|
+
I,
|
|
12211
12211
|
{
|
|
12212
12212
|
match: "\\$[A-Za-z$_][0-9A-Za-z$_]*",
|
|
12213
12213
|
relevance: 0
|
|
@@ -12217,10 +12217,10 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
12217
12217
|
className: { 1: "title.function" },
|
|
12218
12218
|
contains: [k]
|
|
12219
12219
|
},
|
|
12220
|
-
|
|
12220
|
+
ee,
|
|
12221
12221
|
P,
|
|
12222
12222
|
A,
|
|
12223
|
-
|
|
12223
|
+
te,
|
|
12224
12224
|
{ match: /\$[(.]/ }
|
|
12225
12225
|
]
|
|
12226
12226
|
};
|
|
@@ -12956,7 +12956,7 @@ app.mount('#app');
|
|
|
12956
12956
|
y.value === "logs" ? (q(), J("div", lf, [(q(), J(K, null, Xi(s, (e, t) => Y("button", {
|
|
12957
12957
|
key: t,
|
|
12958
12958
|
class: Se(["filter-chip", { active: i.value === t }]),
|
|
12959
|
-
style:
|
|
12959
|
+
style: ve({ "--chip-color": e.color }),
|
|
12960
12960
|
onClick: (e) => i.value = t
|
|
12961
12961
|
}, [is(V(e.icon) + " " + V(e.label) + " ", 1), Y("span", df, V(u.value[t] || 0), 1)], 14, uf)), 64)), Y("button", {
|
|
12962
12962
|
class: Se(["filter-chip all", { active: i.value === "all" }]),
|
|
@@ -12969,7 +12969,7 @@ app.mount('#app');
|
|
|
12969
12969
|
Y("div", hf, [
|
|
12970
12970
|
Y("span", {
|
|
12971
12971
|
class: "log-type",
|
|
12972
|
-
style:
|
|
12972
|
+
style: ve({ background: s[e.type].color })
|
|
12973
12973
|
}, V(s[e.type].icon) + " " + V(s[e.type].label), 5),
|
|
12974
12974
|
e.source ? (q(), J("span", gf, "↳ " + V(e.source), 1)) : X("", !0),
|
|
12975
12975
|
Y("span", _f, V(d(e.timestamp)), 1)
|
|
@@ -12992,7 +12992,7 @@ app.mount('#app');
|
|
|
12992
12992
|
class: "msg-row"
|
|
12993
12993
|
}, [Y("span", {
|
|
12994
12994
|
class: "msg-role",
|
|
12995
|
-
style:
|
|
12995
|
+
style: ve({ background: g(e.type).color })
|
|
12996
12996
|
}, V(g(e.type).label), 5), Y("span", jf, V(e.content), 1)]))), 128))])
|
|
12997
12997
|
], 64)) : e.type === "llm_request" ? (q(), J(K, { key: 1 }, [Y("div", Mf, [
|
|
12998
12998
|
Y("span", Nf, "第 " + V(e.data.round) + " 轮", 1),
|
|
@@ -13008,7 +13008,7 @@ app.mount('#app');
|
|
|
13008
13008
|
class: "msg-row"
|
|
13009
13009
|
}, [Y("span", {
|
|
13010
13010
|
class: "msg-role",
|
|
13011
|
-
style:
|
|
13011
|
+
style: ve({ background: g(e.role).color })
|
|
13012
13012
|
}, V(g(e.role).label), 5), Y("div", zf, [
|
|
13013
13013
|
e.content ? (q(), J("span", Bf, V(e.content), 1)) : X("", !0),
|
|
13014
13014
|
(q(!0), J(K, null, Xi(e.tool_calls || [], (e, t) => (q(), J("div", {
|
|
@@ -13104,7 +13104,7 @@ app.mount('#app');
|
|
|
13104
13104
|
class: "info-todo"
|
|
13105
13105
|
}, [Y("span", {
|
|
13106
13106
|
class: "todo-tag",
|
|
13107
|
-
style:
|
|
13107
|
+
style: ve({ background: S[e.status] && S[e.status].color || "#9ca3af" })
|
|
13108
13108
|
}, V(C(e.status)), 5), Y("span", null, V(e.content), 1)]))), 128))])) : X("", !0),
|
|
13109
13109
|
b.value.memory ? (q(), J("div", wm, [n[28] ||= Y("div", { class: "info-title" }, "📝 持久指令 (memory)", -1), Y("pre", Tm, V(b.value.memory), 1)])) : X("", !0),
|
|
13110
13110
|
b.value.lastCompression ? (q(), J("div", Em, [n[34] ||= Y("div", { class: "info-title" }, "🗜️ 上轮压缩", -1), Y("div", Dm, [
|
|
@@ -13338,36 +13338,36 @@ app.mount('#app');
|
|
|
13338
13338
|
function F(e) {
|
|
13339
13339
|
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), P());
|
|
13340
13340
|
}
|
|
13341
|
-
function
|
|
13341
|
+
function ee(e) {
|
|
13342
13342
|
return new Date(e).toLocaleTimeString("zh-CN", {
|
|
13343
13343
|
hour: "2-digit",
|
|
13344
13344
|
minute: "2-digit"
|
|
13345
13345
|
});
|
|
13346
13346
|
}
|
|
13347
|
-
let
|
|
13347
|
+
let I = zs(() => {
|
|
13348
13348
|
let e = t.getInfo?.();
|
|
13349
13349
|
return {
|
|
13350
13350
|
mcp: e?.mcp?.servers?.length ?? 0,
|
|
13351
13351
|
tools: e?.tools?.length ?? 0
|
|
13352
13352
|
};
|
|
13353
13353
|
});
|
|
13354
|
-
function
|
|
13354
|
+
function te(e) {
|
|
13355
13355
|
Sl(e).then((e) => {
|
|
13356
|
-
e && (
|
|
13356
|
+
e && (L.value = !0, setTimeout(() => L.value = !1, 1500));
|
|
13357
13357
|
});
|
|
13358
13358
|
}
|
|
13359
|
-
let
|
|
13360
|
-
return (a,
|
|
13359
|
+
let L = /* @__PURE__ */ fn(!1);
|
|
13360
|
+
return (a, R) => (q(), J("div", { class: Se(["chat-dialog", { collapsed: !C.value }]) }, [
|
|
13361
13361
|
Y("div", zm, [Y("div", Bm, [
|
|
13362
|
-
|
|
13362
|
+
R[19] ||= Y("span", { class: "header-icon" }, "🤖", -1),
|
|
13363
13363
|
Y("span", Vm, V(e.title), 1),
|
|
13364
13364
|
W(n).loading ? (q(), J("span", Hm)) : X("", !0)
|
|
13365
13365
|
]), Y("div", Um, [
|
|
13366
13366
|
Y("button", {
|
|
13367
13367
|
class: Se(["action-btn debug-btn", { active: w.value }]),
|
|
13368
13368
|
title: "日志 / 执行流程 / Agent 信息",
|
|
13369
|
-
onClick:
|
|
13370
|
-
}, [
|
|
13369
|
+
onClick: R[0] ||= (e) => w.value = !0
|
|
13370
|
+
}, [R[20] ||= Y("svg", {
|
|
13371
13371
|
width: "16",
|
|
13372
13372
|
height: "16",
|
|
13373
13373
|
viewBox: "0 0 24 24",
|
|
@@ -13382,9 +13382,9 @@ app.mount('#app');
|
|
|
13382
13382
|
Y("button", {
|
|
13383
13383
|
class: "action-btn",
|
|
13384
13384
|
title: "清空对话",
|
|
13385
|
-
onClick:
|
|
13385
|
+
onClick: R[1] ||= (...e) => W(o) && W(o)(...e),
|
|
13386
13386
|
disabled: !E.value
|
|
13387
|
-
}, [...
|
|
13387
|
+
}, [...R[21] ||= [Y("svg", {
|
|
13388
13388
|
width: "16",
|
|
13389
13389
|
height: "16",
|
|
13390
13390
|
viewBox: "0 0 24 24",
|
|
@@ -13394,17 +13394,17 @@ app.mount('#app');
|
|
|
13394
13394
|
}, [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, Gm),
|
|
13395
13395
|
Y("button", {
|
|
13396
13396
|
class: "action-btn",
|
|
13397
|
-
onClick:
|
|
13397
|
+
onClick: R[2] ||= (e) => C.value = !C.value
|
|
13398
13398
|
}, [(q(), J("svg", Km, [C.value ? (q(), J("path", qm)) : (q(), J("path", Jm))]))])
|
|
13399
13399
|
])]),
|
|
13400
13400
|
zr(Y("div", {
|
|
13401
13401
|
class: "chat-body",
|
|
13402
13402
|
ref_key: "scrollContainer",
|
|
13403
13403
|
ref: r,
|
|
13404
|
-
onScroll:
|
|
13405
|
-
onWheel:
|
|
13404
|
+
onScroll: R[5] ||= (...e) => W(d) && W(d)(...e),
|
|
13405
|
+
onWheel: R[6] ||= (...e) => W(f) && W(f)(...e)
|
|
13406
13406
|
}, [
|
|
13407
|
-
E.value ? X("", !0) : (q(), J("div", Ym, [...
|
|
13407
|
+
E.value ? X("", !0) : (q(), J("div", Ym, [...R[22] ||= [Y("div", { class: "empty-icon" }, "💬", -1), Y("p", null, "有什么可以帮你的?", -1)]])),
|
|
13408
13408
|
(q(!0), J(K, null, Xi(W(n).messages, (t, r) => (q(), J("div", {
|
|
13409
13409
|
key: r,
|
|
13410
13410
|
class: Se(["message-row", t.role]),
|
|
@@ -13417,8 +13417,8 @@ app.mount('#app');
|
|
|
13417
13417
|
class: "reasoning-header",
|
|
13418
13418
|
onClick: (e) => k(r)
|
|
13419
13419
|
}, [
|
|
13420
|
-
|
|
13421
|
-
|
|
13420
|
+
R[23] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13421
|
+
R[24] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13422
13422
|
Y("span", eh, V(T.value[r] ? "▾" : "▸"), 1)
|
|
13423
13423
|
], 8, $m), T.value[r] ? (q(), J("div", th, V(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13424
13424
|
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", nh, [(q(!0), J(K, null, Xi(j(t.steps), (e, t) => (q(), J("div", {
|
|
@@ -13429,7 +13429,7 @@ app.mount('#app');
|
|
|
13429
13429
|
Y("span", ah, V(e.name), 1),
|
|
13430
13430
|
e.count > 1 ? (q(), J("span", oh, "×" + V(e.count), 1)) : X("", !0),
|
|
13431
13431
|
e.status === "running" ? (q(), J("span", sh, "执行中…")) : X("", !0)
|
|
13432
|
-
]), e.children && e.children.length ? (q(), J("div", ch, [
|
|
13432
|
+
]), e.children && e.children.length ? (q(), J("div", ch, [R[25] ||= Y("div", { class: "step-children-label" }, "🧬 子 agent 进度", -1), (q(!0), J(K, null, Xi(e.children, (e, t) => (q(), J("div", {
|
|
13433
13433
|
key: t,
|
|
13434
13434
|
class: "step-child"
|
|
13435
13435
|
}, [
|
|
@@ -13438,36 +13438,36 @@ app.mount('#app');
|
|
|
13438
13438
|
e.status === "running" ? (q(), J("span", dh, "…")) : X("", !0)
|
|
13439
13439
|
]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
|
|
13440
13440
|
Y("div", { class: Se(["message-bubble", { typing: N(r) }]) }, [N(r) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13441
|
+
R[26] ||= Y("span", { class: "dot" }, null, -1),
|
|
13442
|
+
R[27] ||= Y("span", { class: "dot" }, null, -1),
|
|
13443
|
+
R[28] ||= Y("span", { class: "dot" }, null, -1)
|
|
13444
13444
|
], 64)) : (q(), J("span", fh, "思考中…"))], 64)) : (q(), J(K, { key: 1 }, [t.role === "assistant" ? (q(), Ko(nf, {
|
|
13445
13445
|
key: 0,
|
|
13446
13446
|
content: t.content
|
|
13447
13447
|
}, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [is(V(t.content), 1)], 64))], 64))], 2),
|
|
13448
13448
|
t.role === "assistant" && W(n).loading && r === W(n).messages.length - 1 && t.content ? (q(), J("span", ph)) : X("", !0),
|
|
13449
|
-
Y("div", mh, V(
|
|
13449
|
+
Y("div", mh, V(ee(t.timestamp)), 1),
|
|
13450
13450
|
t.role === "assistant" && t.content && !W(n).loading && r === W(n).messages.length - 1 ? (q(), J("div", hh, [Y("button", {
|
|
13451
13451
|
class: "msg-action-btn",
|
|
13452
|
-
title:
|
|
13453
|
-
onClick: (e) =>
|
|
13454
|
-
}, V(
|
|
13452
|
+
title: L.value ? "已复制" : "复制",
|
|
13453
|
+
onClick: (e) => te(t.content)
|
|
13454
|
+
}, V(L.value ? "✓ 已复制" : "📋 复制"), 9, gh), Y("button", {
|
|
13455
13455
|
class: "msg-action-btn",
|
|
13456
13456
|
title: "重新生成",
|
|
13457
|
-
onClick:
|
|
13457
|
+
onClick: R[3] ||= (...e) => W(l) && W(l)(...e)
|
|
13458
13458
|
}, "🔄 重新生成")])) : X("", !0)
|
|
13459
13459
|
])], 10, Xm))), 128)),
|
|
13460
13460
|
W(n).loading && W(n).messages[W(n).messages.length - 1]?.role !== "assistant" ? (q(), J("div", _h, [e.showAvatar ? (q(), J("div", vh, "🤖")) : X("", !0), Y("div", yh, [Y("div", bh, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13461
|
+
R[29] ||= Y("span", { class: "dot" }, null, -1),
|
|
13462
|
+
R[30] ||= Y("span", { class: "dot" }, null, -1),
|
|
13463
|
+
R[31] ||= Y("span", { class: "dot" }, null, -1)
|
|
13464
13464
|
], 64)) : (q(), J("span", xh, "思考中…"))])])])) : X("", !0),
|
|
13465
13465
|
W(n).error ? (q(), J("div", Sh, [
|
|
13466
13466
|
Y("span", Ch, V(W(n).error), 1),
|
|
13467
13467
|
D.value ? (q(), J("button", {
|
|
13468
13468
|
key: 0,
|
|
13469
13469
|
class: "retry-btn",
|
|
13470
|
-
onClick:
|
|
13470
|
+
onClick: R[4] ||= (...e) => W(c) && W(c)(...e)
|
|
13471
13471
|
}, "重试")) : X("", !0),
|
|
13472
13472
|
b.value ? (q(), J("button", {
|
|
13473
13473
|
key: 1,
|
|
@@ -13478,13 +13478,13 @@ app.mount('#app');
|
|
|
13478
13478
|
])) : X("", !0)
|
|
13479
13479
|
], 544), [[xc, C.value]]),
|
|
13480
13480
|
W(i) ? (q(), J("div", wh, [_.value ? (q(), J(K, { key: 0 }, [
|
|
13481
|
-
|
|
13481
|
+
R[32] ||= Y("div", { class: "approval-head" }, [Y("span", { class: "approval-icon" }, "❓"), Y("span", { class: "approval-title" }, "AI 需要你确认")], -1),
|
|
13482
13482
|
W(i).args?.question ? (q(), J("div", Th, V(W(i).args.question), 1)) : X("", !0),
|
|
13483
13483
|
W(i).args?.context ? (q(), J("div", Eh, V(W(i).args.context), 1)) : X("", !0),
|
|
13484
13484
|
W(i).args?.recommendation ? (q(), J("div", Dh, "💡 推荐:" + V(W(i).args.recommendation), 1)) : X("", !0),
|
|
13485
13485
|
Y("div", Oh, [Y("button", {
|
|
13486
13486
|
class: "approval-deny",
|
|
13487
|
-
onClick:
|
|
13487
|
+
onClick: R[7] ||= (e) => W(u)(!1)
|
|
13488
13488
|
}, "拒绝"), v.value.length ? (q(!0), J(K, { key: 0 }, Xi(v.value, (e) => (q(), J("button", {
|
|
13489
13489
|
key: e,
|
|
13490
13490
|
class: "approval-opt",
|
|
@@ -13492,59 +13492,59 @@ app.mount('#app');
|
|
|
13492
13492
|
}, V(e), 9, kh))), 128)) : (q(), J("button", {
|
|
13493
13493
|
key: 1,
|
|
13494
13494
|
class: "approval-allow",
|
|
13495
|
-
onClick:
|
|
13495
|
+
onClick: R[8] ||= (e) => W(u)(!0)
|
|
13496
13496
|
}, "允许"))])
|
|
13497
13497
|
], 64)) : (q(), J(K, { key: 1 }, [
|
|
13498
13498
|
Y("div", Ah, [
|
|
13499
|
-
|
|
13500
|
-
Y("span", jh, [
|
|
13499
|
+
R[34] ||= Y("span", { class: "approval-icon" }, "✋", -1),
|
|
13500
|
+
Y("span", jh, [R[33] ||= is("需确认工具调用:", -1), Y("code", null, V(W(i).toolName), 1)]),
|
|
13501
13501
|
p.value ? (q(), J("button", {
|
|
13502
13502
|
key: 0,
|
|
13503
13503
|
class: "approval-toggle",
|
|
13504
|
-
onClick:
|
|
13504
|
+
onClick: R[9] ||= (e) => y.value = !y.value
|
|
13505
13505
|
}, V(y.value ? "收起参数" : "查看参数") + V(y.value ? " ▴" : " ▾"), 1)) : X("", !0)
|
|
13506
13506
|
]),
|
|
13507
13507
|
p.value && y.value ? (q(), J("pre", Mh, V(p.value), 1)) : X("", !0),
|
|
13508
13508
|
Y("div", Nh, [Y("button", {
|
|
13509
13509
|
class: "approval-deny",
|
|
13510
|
-
onClick:
|
|
13510
|
+
onClick: R[10] ||= (e) => W(u)(!1)
|
|
13511
13511
|
}, "拒绝"), Y("button", {
|
|
13512
13512
|
class: "approval-allow",
|
|
13513
|
-
onClick:
|
|
13513
|
+
onClick: R[11] ||= (e) => W(u)(!0)
|
|
13514
13514
|
}, "允许")])
|
|
13515
13515
|
], 64))])) : X("", !0),
|
|
13516
13516
|
t.pendingConflict ? (q(), J("div", Ph, [
|
|
13517
|
-
Y("div", Fh, [
|
|
13518
|
-
|
|
13517
|
+
Y("div", Fh, [R[37] ||= Y("span", { class: "conflict-icon" }, "⚠️", -1), Y("span", Ih, [
|
|
13518
|
+
R[35] ||= is("写入冲突:", -1),
|
|
13519
13519
|
Y("code", null, V(t.pendingConflict.path), 1),
|
|
13520
|
-
|
|
13520
|
+
R[36] ||= is(" 已被外部修改", -1)
|
|
13521
13521
|
])]),
|
|
13522
13522
|
Y("div", Lh, " AI 基于「读取时的旧值」准备" + V(t.pendingConflict.op === "delete" ? "删除" : "写入") + ",但该属性在你读取之后被外部代码/其他 agent/手动改过。 ", 1),
|
|
13523
13523
|
Y("button", {
|
|
13524
13524
|
class: "conflict-toggle",
|
|
13525
|
-
onClick:
|
|
13525
|
+
onClick: R[12] ||= (e) => g.value = !g.value
|
|
13526
13526
|
}, V(g.value ? "收起对比" : "查看值对比") + V(g.value ? " ▴" : " ▾"), 1),
|
|
13527
|
-
g.value ? (q(), J("div", Rh, [Y("div", zh, [
|
|
13527
|
+
g.value ? (q(), J("div", Rh, [Y("div", zh, [R[38] ||= Y("div", { class: "conflict-diff-label" }, "AI 想写的值", -1), Y("pre", Bh, V(m.value || "(delete 操作无值)"), 1)]), Y("div", Vh, [R[39] ||= Y("div", { class: "conflict-diff-label" }, "外部改后的当前值", -1), Y("pre", Hh, V(h.value), 1)])])) : X("", !0),
|
|
13528
13528
|
Y("div", Uh, [
|
|
13529
13529
|
Y("button", {
|
|
13530
13530
|
class: "conflict-keep",
|
|
13531
|
-
onClick:
|
|
13531
|
+
onClick: R[13] ||= (e) => t.onResolveConflict?.("keep_external"),
|
|
13532
13532
|
title: "不写入,保留外部修改后的值,AI 重新读取再改"
|
|
13533
13533
|
}, "保留外部"),
|
|
13534
13534
|
Y("button", {
|
|
13535
13535
|
class: "conflict-overwrite",
|
|
13536
|
-
onClick:
|
|
13536
|
+
onClick: R[14] ||= (e) => t.onResolveConflict?.("overwrite"),
|
|
13537
13537
|
title: "用 AI 的值覆盖外部修改"
|
|
13538
13538
|
}, "强制覆盖"),
|
|
13539
13539
|
Y("button", {
|
|
13540
13540
|
class: "conflict-restore",
|
|
13541
|
-
onClick:
|
|
13541
|
+
onClick: R[15] ||= (e) => t.onResolveConflict?.("restore"),
|
|
13542
13542
|
title: "回退到最近一次历史快照(agent 之前操作的检查点),撤销外部修改 + AI 不写入"
|
|
13543
13543
|
}, "回退")
|
|
13544
13544
|
])
|
|
13545
13545
|
])) : X("", !0),
|
|
13546
13546
|
zr(Y("div", Wh, [
|
|
13547
|
-
t.getInfo ? (q(), J("span", Gh, " 🔌" + V(
|
|
13547
|
+
t.getInfo ? (q(), J("span", Gh, " 🔌" + V(I.value.mcp) + " · 🔧" + V(I.value.tools), 1)) : X("", !0),
|
|
13548
13548
|
b.value ? (q(), J("button", {
|
|
13549
13549
|
key: 1,
|
|
13550
13550
|
class: "undo-foot-btn",
|
|
@@ -13552,7 +13552,7 @@ app.mount('#app');
|
|
|
13552
13552
|
onClick: x
|
|
13553
13553
|
}, "↩ 回退")) : X("", !0),
|
|
13554
13554
|
zr(Y("textarea", {
|
|
13555
|
-
"onUpdate:modelValue":
|
|
13555
|
+
"onUpdate:modelValue": R[16] ||= (e) => S.value = e,
|
|
13556
13556
|
class: "chat-input",
|
|
13557
13557
|
placeholder: e.placeholder,
|
|
13558
13558
|
rows: "1",
|
|
@@ -13562,14 +13562,14 @@ app.mount('#app');
|
|
|
13562
13562
|
class: Se(["send-btn", { "stop-btn": W(n).loading }]),
|
|
13563
13563
|
disabled: !W(n).loading && !S.value.trim(),
|
|
13564
13564
|
title: W(n).loading ? "停止生成" : "发送",
|
|
13565
|
-
onClick:
|
|
13566
|
-
}, [W(n).loading ? (q(), J("svg", Jh, [...
|
|
13565
|
+
onClick: R[17] ||= (e) => W(n).loading ? W(s)() : P()
|
|
13566
|
+
}, [W(n).loading ? (q(), J("svg", Jh, [...R[40] ||= [Y("rect", {
|
|
13567
13567
|
x: "6",
|
|
13568
13568
|
y: "6",
|
|
13569
13569
|
width: "12",
|
|
13570
13570
|
height: "12",
|
|
13571
13571
|
rx: "2"
|
|
13572
|
-
}, null, -1)]])) : (q(), J("svg", Yh, [...
|
|
13572
|
+
}, null, -1)]])) : (q(), J("svg", Yh, [...R[41] ||= [Y("line", {
|
|
13573
13573
|
x1: "22",
|
|
13574
13574
|
y1: "2",
|
|
13575
13575
|
x2: "11",
|
|
@@ -13578,7 +13578,7 @@ app.mount('#app');
|
|
|
13578
13578
|
], 512), [[xc, C.value]]),
|
|
13579
13579
|
$o(Rm, {
|
|
13580
13580
|
visible: w.value,
|
|
13581
|
-
"onUpdate:visible":
|
|
13581
|
+
"onUpdate:visible": R[18] ||= (e) => w.value = e,
|
|
13582
13582
|
logs: e.debugLogs,
|
|
13583
13583
|
"get-info": t.getInfo
|
|
13584
13584
|
}, null, 8, [
|
|
@@ -13592,18 +13592,23 @@ app.mount('#app');
|
|
|
13592
13592
|
function Zh(e) {
|
|
13593
13593
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13594
13594
|
}
|
|
13595
|
-
function Qh(e
|
|
13595
|
+
function Qh(e) {
|
|
13596
|
+
let t = 5381;
|
|
13597
|
+
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
13598
|
+
return (t >>> 0).toString(36);
|
|
13599
|
+
}
|
|
13600
|
+
function $h(e, t) {
|
|
13596
13601
|
let n = t.threshold ?? 6e3;
|
|
13597
13602
|
if (e.length <= n) return e;
|
|
13598
13603
|
if (t.vfsAvailable && t.files) {
|
|
13599
|
-
let n =
|
|
13600
|
-
return t.files[
|
|
13604
|
+
let n = `large_results/${t.toolName}-${Qh(e)}.txt`, r = Zh(n);
|
|
13605
|
+
return t.files[r] = {
|
|
13601
13606
|
content: e,
|
|
13602
13607
|
updatedAt: Date.now()
|
|
13603
13608
|
}, [
|
|
13604
13609
|
e.slice(0, 1e3),
|
|
13605
|
-
`…[结果过大(共 ${e.length} 字符),已转存到虚拟工作区:${
|
|
13606
|
-
`需要完整或局部数据时:用 vfs_read({ path: "${
|
|
13610
|
+
`…[结果过大(共 ${e.length} 字符),已转存到虚拟工作区:${n}]`,
|
|
13611
|
+
`需要完整或局部数据时:用 vfs_read({ path: "${n}", offset, limit }) 分页回读,或 vfs_grep({ pattern, path: "${n}" }) 局部检索。`
|
|
13607
13612
|
].join("\n");
|
|
13608
13613
|
}
|
|
13609
13614
|
let r = t.passThroughChars ?? n;
|
|
@@ -13611,7 +13616,7 @@ function Qh(e, t) {
|
|
|
13611
13616
|
}
|
|
13612
13617
|
//#endregion
|
|
13613
13618
|
//#region src/core/utils/pool.ts
|
|
13614
|
-
async function
|
|
13619
|
+
async function eg(e, t, n, r) {
|
|
13615
13620
|
let i = Array(e.length), a = Math.max(1, t);
|
|
13616
13621
|
if (a === 1) {
|
|
13617
13622
|
for (let t = 0; t < e.length && !r?.aborted; t++) i[t] = await n(e[t], t);
|
|
@@ -13628,7 +13633,7 @@ async function $h(e, t, n, r) {
|
|
|
13628
13633
|
}
|
|
13629
13634
|
//#endregion
|
|
13630
13635
|
//#region src/core/utils/modelCaps.ts
|
|
13631
|
-
var
|
|
13636
|
+
var tg = [
|
|
13632
13637
|
{
|
|
13633
13638
|
pattern: /deepseek-v4/i,
|
|
13634
13639
|
caps: {
|
|
@@ -13790,34 +13795,34 @@ var eg = [
|
|
|
13790
13795
|
maxOutputTokens: 4096
|
|
13791
13796
|
}
|
|
13792
13797
|
}
|
|
13793
|
-
],
|
|
13798
|
+
], ng = {
|
|
13794
13799
|
contextWindow: 32768,
|
|
13795
13800
|
maxOutputTokens: 4096
|
|
13796
13801
|
};
|
|
13797
|
-
function
|
|
13802
|
+
function rg(e = {}) {
|
|
13798
13803
|
let t = (() => {
|
|
13799
|
-
if (e.model) return
|
|
13804
|
+
if (e.model) return tg.find((t) => t.pattern.test(e.model))?.caps;
|
|
13800
13805
|
})();
|
|
13801
13806
|
return {
|
|
13802
|
-
contextWindow: e.contextWindow ?? t?.contextWindow ??
|
|
13803
|
-
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ??
|
|
13807
|
+
contextWindow: e.contextWindow ?? t?.contextWindow ?? ng.contextWindow,
|
|
13808
|
+
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ?? ng.maxOutputTokens
|
|
13804
13809
|
};
|
|
13805
13810
|
}
|
|
13806
|
-
function
|
|
13811
|
+
function ig(e) {
|
|
13807
13812
|
if (!e) return 0;
|
|
13808
13813
|
let t = (e.match(/[\u4e00-\u9fff]/g) || []).length, n = e.length - t;
|
|
13809
13814
|
return Math.ceil(t * 1.5 + n * .25);
|
|
13810
13815
|
}
|
|
13811
|
-
function
|
|
13816
|
+
function ag(e) {
|
|
13812
13817
|
return Math.max(2e3, Math.min(2e4, Math.round(e * .035)));
|
|
13813
13818
|
}
|
|
13814
|
-
function
|
|
13815
|
-
let t =
|
|
13819
|
+
function og(e) {
|
|
13820
|
+
let t = ag(e);
|
|
13816
13821
|
return Math.min(2e5, Math.max(t, Math.round(e * .7)));
|
|
13817
13822
|
}
|
|
13818
13823
|
//#endregion
|
|
13819
13824
|
//#region src/core/harness/state.ts
|
|
13820
|
-
function
|
|
13825
|
+
function sg() {
|
|
13821
13826
|
return {
|
|
13822
13827
|
messages: [],
|
|
13823
13828
|
todos: [],
|
|
@@ -13830,42 +13835,42 @@ function og() {
|
|
|
13830
13835
|
}
|
|
13831
13836
|
//#endregion
|
|
13832
13837
|
//#region src/core/harness/middleware.ts
|
|
13833
|
-
function
|
|
13838
|
+
function cg(e, t) {
|
|
13834
13839
|
return t ? {
|
|
13835
13840
|
...e,
|
|
13836
13841
|
...t
|
|
13837
13842
|
} : e;
|
|
13838
13843
|
}
|
|
13839
|
-
async function
|
|
13844
|
+
async function lg(e, t) {
|
|
13840
13845
|
let n = t;
|
|
13841
|
-
for (let t of e) t.beforeAgent && (n =
|
|
13846
|
+
for (let t of e) t.beforeAgent && (n = cg(n, await t.beforeAgent(n)));
|
|
13842
13847
|
return n;
|
|
13843
13848
|
}
|
|
13844
|
-
function
|
|
13849
|
+
function ug(e, t) {
|
|
13845
13850
|
let n = t.state;
|
|
13846
|
-
for (let r of e) r.beforeModel && (n =
|
|
13851
|
+
for (let r of e) r.beforeModel && (n = cg(n, r.beforeModel({
|
|
13847
13852
|
messages: t.messages,
|
|
13848
13853
|
state: n
|
|
13849
13854
|
})));
|
|
13850
13855
|
return n;
|
|
13851
13856
|
}
|
|
13852
|
-
function
|
|
13857
|
+
function dg(e, t, n) {
|
|
13853
13858
|
let r = n;
|
|
13854
13859
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
13855
13860
|
let i = e[n];
|
|
13856
|
-
i.afterModel && (r =
|
|
13861
|
+
i.afterModel && (r = cg(r, i.afterModel(t, r)));
|
|
13857
13862
|
}
|
|
13858
13863
|
return r;
|
|
13859
13864
|
}
|
|
13860
|
-
async function
|
|
13865
|
+
async function fg(e, t) {
|
|
13861
13866
|
let n = t;
|
|
13862
13867
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
13863
13868
|
let r = e[t];
|
|
13864
|
-
r.afterAgent && (n =
|
|
13869
|
+
r.afterAgent && (n = cg(n, await r.afterAgent(n)));
|
|
13865
13870
|
}
|
|
13866
13871
|
return n;
|
|
13867
13872
|
}
|
|
13868
|
-
async function
|
|
13873
|
+
async function pg(e, t) {
|
|
13869
13874
|
let n = [];
|
|
13870
13875
|
for (let r of e) {
|
|
13871
13876
|
if (!r.beforeReturn) continue;
|
|
@@ -13874,19 +13879,19 @@ async function fg(e, t) {
|
|
|
13874
13879
|
}
|
|
13875
13880
|
return n.length ? n.join("\n\n") : null;
|
|
13876
13881
|
}
|
|
13877
|
-
function
|
|
13882
|
+
function mg(e, t) {
|
|
13878
13883
|
return e.reduceRight((e, t) => (n) => t.wrapModelCall ? t.wrapModelCall(n, e) : e(n), t);
|
|
13879
13884
|
}
|
|
13880
|
-
function
|
|
13885
|
+
function hg(e, t) {
|
|
13881
13886
|
return e.reduceRight((e, t) => (n) => t.wrapToolCall ? t.wrapToolCall(n, e) : e(n), t);
|
|
13882
13887
|
}
|
|
13883
13888
|
//#endregion
|
|
13884
13889
|
//#region src/core/harness/createAgent.ts
|
|
13885
|
-
function
|
|
13890
|
+
function gg(e) {
|
|
13886
13891
|
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
13887
13892
|
}
|
|
13888
|
-
var
|
|
13889
|
-
function
|
|
13893
|
+
var _g = 10, vg = 300, yg = 6e3;
|
|
13894
|
+
function bg(e, t) {
|
|
13890
13895
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
13891
13896
|
if (n <= t) return e;
|
|
13892
13897
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -13901,29 +13906,29 @@ function yg(e, t) {
|
|
|
13901
13906
|
});
|
|
13902
13907
|
});
|
|
13903
13908
|
}
|
|
13904
|
-
function
|
|
13905
|
-
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m =
|
|
13909
|
+
function xg(e) {
|
|
13910
|
+
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = _g, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = rg({
|
|
13906
13911
|
model: c,
|
|
13907
13912
|
contextWindow: e.contextWindow,
|
|
13908
13913
|
maxOutputTokens: e.maxOutputTokens
|
|
13909
|
-
}), S = u ?? x.maxOutputTokens, C =
|
|
13914
|
+
}), S = u ?? x.maxOutputTokens, C = ag(x.contextWindow), w = og(x.contextWindow), T = /* @__PURE__ */ pn([]);
|
|
13910
13915
|
function E(e, t) {
|
|
13911
13916
|
let n = {
|
|
13912
13917
|
timestamp: Date.now(),
|
|
13913
13918
|
type: e,
|
|
13914
13919
|
data: t
|
|
13915
13920
|
};
|
|
13916
|
-
T.value.push(n), T.value.length >
|
|
13921
|
+
T.value.push(n), T.value.length > vg && T.value.splice(0, T.value.length - vg), gn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
13917
13922
|
}
|
|
13918
13923
|
let D = (e) => {
|
|
13919
|
-
T.value.push(e), T.value.length >
|
|
13924
|
+
T.value.push(e), T.value.length > vg && T.value.splice(0, T.value.length - vg), gn(T);
|
|
13920
13925
|
}, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new s({
|
|
13921
13926
|
apiKey: t,
|
|
13922
13927
|
model: c,
|
|
13923
13928
|
temperature: l,
|
|
13924
13929
|
maxTokens: S,
|
|
13925
13930
|
configuration: n ? { baseURL: n } : void 0
|
|
13926
|
-
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j =
|
|
13931
|
+
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j = sg();
|
|
13927
13932
|
function M() {
|
|
13928
13933
|
let e = [d || "你是一个智能助手。"];
|
|
13929
13934
|
for (let t of p) if (t.augmentPrompt) {
|
|
@@ -13938,7 +13943,7 @@ function bg(e) {
|
|
|
13938
13943
|
return t;
|
|
13939
13944
|
}
|
|
13940
13945
|
function P(e) {
|
|
13941
|
-
let t = e.filter((e) =>
|
|
13946
|
+
let t = e.filter((e) => I(e) !== "system");
|
|
13942
13947
|
return [new a(M()), ...t];
|
|
13943
13948
|
}
|
|
13944
13949
|
async function F(e, t, n, i) {
|
|
@@ -13990,7 +13995,7 @@ function bg(e) {
|
|
|
13990
13995
|
}
|
|
13991
13996
|
});
|
|
13992
13997
|
}
|
|
13993
|
-
async function
|
|
13998
|
+
async function ee(e) {
|
|
13994
13999
|
let t = O.find((t) => t.name === e.name);
|
|
13995
14000
|
if (!t) return {
|
|
13996
14001
|
content: `工具 "${e.name}" 不存在`,
|
|
@@ -13998,7 +14003,7 @@ function bg(e) {
|
|
|
13998
14003
|
};
|
|
13999
14004
|
try {
|
|
14000
14005
|
let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
|
|
14001
|
-
return r =
|
|
14006
|
+
return r = $h(r, {
|
|
14002
14007
|
files: e.state.files,
|
|
14003
14008
|
vfsAvailable: O.some((e) => e.name === "vfs_read"),
|
|
14004
14009
|
toolName: e.name,
|
|
@@ -14015,16 +14020,16 @@ function bg(e) {
|
|
|
14015
14020
|
};
|
|
14016
14021
|
}
|
|
14017
14022
|
}
|
|
14018
|
-
function
|
|
14023
|
+
function I(e) {
|
|
14019
14024
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
14020
14025
|
}
|
|
14021
|
-
function
|
|
14022
|
-
return
|
|
14026
|
+
function te(e, t) {
|
|
14027
|
+
return bg(e, t);
|
|
14023
14028
|
}
|
|
14024
|
-
function
|
|
14029
|
+
function L(e) {
|
|
14025
14030
|
return e.map((e) => {
|
|
14026
|
-
let t =
|
|
14027
|
-
r && (n.content = r.length >
|
|
14031
|
+
let t = I(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
14032
|
+
r && (n.content = r.length > yg ? r.slice(0, yg) + `…(截断 ${r.length - yg} 字符)` : r);
|
|
14028
14033
|
let i = e.tool_calls;
|
|
14029
14034
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
14030
14035
|
id: e.id,
|
|
@@ -14038,8 +14043,8 @@ function bg(e) {
|
|
|
14038
14043
|
return a && (n.tool_call_id = a), n;
|
|
14039
14044
|
});
|
|
14040
14045
|
}
|
|
14041
|
-
async function
|
|
14042
|
-
T.value = [], j =
|
|
14046
|
+
async function R(e, t, n) {
|
|
14047
|
+
T.value = [], j = sg(), j.messages = e, j = await lg(p, j);
|
|
14043
14048
|
let r = e;
|
|
14044
14049
|
for (let e of p) if (e.compressInput) {
|
|
14045
14050
|
let t = await e.compressInput(r);
|
|
@@ -14054,20 +14059,20 @@ function bg(e) {
|
|
|
14054
14059
|
tools: O.map((e) => e.name),
|
|
14055
14060
|
middleware: p.map((e) => e.name)
|
|
14056
14061
|
});
|
|
14057
|
-
let l =
|
|
14062
|
+
let l = mg(p, (e) => F(e, t, n)), u = hg(p, ee), d = 0, f = null, h = 0;
|
|
14058
14063
|
try {
|
|
14059
14064
|
for (; d < m && !n?.aborted;) {
|
|
14060
14065
|
t({
|
|
14061
14066
|
type: "round_start",
|
|
14062
14067
|
round: d + 1
|
|
14063
|
-
}), j =
|
|
14068
|
+
}), j = ug(p, {
|
|
14064
14069
|
messages: s,
|
|
14065
14070
|
state: j
|
|
14066
|
-
}), s = P(s), s =
|
|
14071
|
+
}), s = P(s), s = te(s, w), E("llm_request", {
|
|
14067
14072
|
round: d + 1,
|
|
14068
14073
|
model: c,
|
|
14069
14074
|
tools: O.map((e) => e.name),
|
|
14070
|
-
messages:
|
|
14075
|
+
messages: L(s)
|
|
14071
14076
|
});
|
|
14072
14077
|
let e = await l({
|
|
14073
14078
|
messages: s,
|
|
@@ -14077,12 +14082,12 @@ function bg(e) {
|
|
|
14077
14082
|
round: d + 1,
|
|
14078
14083
|
content: e.content,
|
|
14079
14084
|
toolCalls: e.toolCalls
|
|
14080
|
-
}), j =
|
|
14085
|
+
}), j = dg(p, e, j), e.aborted) return t({
|
|
14081
14086
|
type: "done",
|
|
14082
14087
|
content: e.content
|
|
14083
14088
|
}), e.content;
|
|
14084
14089
|
if (!e.toolCalls.length) {
|
|
14085
|
-
if (h < 2 &&
|
|
14090
|
+
if (h < 2 && gg(e.content)) {
|
|
14086
14091
|
h += 1, E("middleware", {
|
|
14087
14092
|
stage: "format_retry",
|
|
14088
14093
|
attempt: h,
|
|
@@ -14091,7 +14096,7 @@ function bg(e) {
|
|
|
14091
14096
|
continue;
|
|
14092
14097
|
}
|
|
14093
14098
|
if (v > 0 && j.verifyAttempts < v) {
|
|
14094
|
-
let t = await
|
|
14099
|
+
let t = await pg(p, {
|
|
14095
14100
|
messages: s,
|
|
14096
14101
|
state: j,
|
|
14097
14102
|
response: e,
|
|
@@ -14126,7 +14131,7 @@ function bg(e) {
|
|
|
14126
14131
|
logSink: D
|
|
14127
14132
|
}
|
|
14128
14133
|
};
|
|
14129
|
-
}), a = await
|
|
14134
|
+
}), a = await eg(r, _, async (e) => {
|
|
14130
14135
|
if (n?.aborted) return;
|
|
14131
14136
|
t({
|
|
14132
14137
|
type: "tool_call",
|
|
@@ -14170,13 +14175,13 @@ function bg(e) {
|
|
|
14170
14175
|
content: f
|
|
14171
14176
|
}), f;
|
|
14172
14177
|
let e = s[s.length - 1];
|
|
14173
|
-
if (e &&
|
|
14174
|
-
let e = s.filter((e) =>
|
|
14178
|
+
if (e && I(e) === "tool") {
|
|
14179
|
+
let e = s.filter((e) => I(e) !== "system"), r = [new a(M() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
14175
14180
|
E("llm_request", {
|
|
14176
14181
|
round: "wrap_up",
|
|
14177
14182
|
model: c,
|
|
14178
14183
|
tools: [],
|
|
14179
|
-
messages:
|
|
14184
|
+
messages: L(r)
|
|
14180
14185
|
});
|
|
14181
14186
|
let i = await F({
|
|
14182
14187
|
messages: r,
|
|
@@ -14197,21 +14202,21 @@ function bg(e) {
|
|
|
14197
14202
|
}), r;
|
|
14198
14203
|
} finally {
|
|
14199
14204
|
try {
|
|
14200
|
-
await
|
|
14205
|
+
await fg(p, j);
|
|
14201
14206
|
} catch (e) {
|
|
14202
14207
|
console.warn("[Agent] afterAgent 清理出错(已忽略):", e);
|
|
14203
14208
|
}
|
|
14204
14209
|
}
|
|
14205
14210
|
}
|
|
14206
|
-
async function
|
|
14211
|
+
async function ne(e, t) {
|
|
14207
14212
|
let n = "";
|
|
14208
|
-
return await
|
|
14213
|
+
return await R(e, (e) => {
|
|
14209
14214
|
e.type === "done" && (n = e.content);
|
|
14210
14215
|
}, t), n;
|
|
14211
14216
|
}
|
|
14212
14217
|
return {
|
|
14213
|
-
invoke:
|
|
14214
|
-
stream:
|
|
14218
|
+
invoke: ne,
|
|
14219
|
+
stream: R,
|
|
14215
14220
|
getState: () => j,
|
|
14216
14221
|
allTools: O,
|
|
14217
14222
|
debugLogs: T
|
|
@@ -14219,14 +14224,14 @@ function bg(e) {
|
|
|
14219
14224
|
}
|
|
14220
14225
|
//#endregion
|
|
14221
14226
|
//#region src/core/harness/todos.ts
|
|
14222
|
-
function
|
|
14227
|
+
function Sg(e) {
|
|
14223
14228
|
if (e.length) return [
|
|
14224
14229
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14225
14230
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14226
14231
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14227
14232
|
].join("\n");
|
|
14228
14233
|
}
|
|
14229
|
-
function
|
|
14234
|
+
function Cg(e = []) {
|
|
14230
14235
|
let r = e.map((e) => ({ ...e })), i = 0;
|
|
14231
14236
|
return {
|
|
14232
14237
|
name: "todos",
|
|
@@ -14244,7 +14249,7 @@ function Sg(e = []) {
|
|
|
14244
14249
|
})],
|
|
14245
14250
|
beforeAgent: () => ({ todos: r }),
|
|
14246
14251
|
beforeModel: () => (i = 0, { todos: r }),
|
|
14247
|
-
augmentPrompt: () =>
|
|
14252
|
+
augmentPrompt: () => Sg(r),
|
|
14248
14253
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14249
14254
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14250
14255
|
status: "error"
|
|
@@ -14256,18 +14261,18 @@ function Sg(e = []) {
|
|
|
14256
14261
|
}
|
|
14257
14262
|
//#endregion
|
|
14258
14263
|
//#region src/core/harness/skills.ts
|
|
14259
|
-
function
|
|
14264
|
+
function wg(e) {
|
|
14260
14265
|
return e;
|
|
14261
14266
|
}
|
|
14262
|
-
var
|
|
14263
|
-
function Tg(e) {
|
|
14264
|
-
return wg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14265
|
-
}
|
|
14267
|
+
var Tg = /^https?:\/\//i;
|
|
14266
14268
|
function Eg(e) {
|
|
14269
|
+
return Tg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14270
|
+
}
|
|
14271
|
+
function Dg(e) {
|
|
14267
14272
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14268
14273
|
}
|
|
14269
|
-
async function
|
|
14270
|
-
if (
|
|
14274
|
+
async function Og(e, t) {
|
|
14275
|
+
if (Eg(e) === "http") try {
|
|
14271
14276
|
let t = await fetch(e);
|
|
14272
14277
|
return t.ok ? {
|
|
14273
14278
|
ok: !0,
|
|
@@ -14290,7 +14295,7 @@ async function Dg(e, t) {
|
|
|
14290
14295
|
ok: !1,
|
|
14291
14296
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14292
14297
|
};
|
|
14293
|
-
let n = t(
|
|
14298
|
+
let n = t(Dg(e));
|
|
14294
14299
|
return n == null ? {
|
|
14295
14300
|
ok: !1,
|
|
14296
14301
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14299,48 +14304,66 @@ async function Dg(e, t) {
|
|
|
14299
14304
|
content: n
|
|
14300
14305
|
};
|
|
14301
14306
|
}
|
|
14302
|
-
function
|
|
14307
|
+
function kg(e) {
|
|
14303
14308
|
if (e.length) return [
|
|
14304
14309
|
"## 可用 Skills(渐进式披露)",
|
|
14305
14310
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14306
14311
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14307
14312
|
].join("\n");
|
|
14308
14313
|
}
|
|
14309
|
-
function
|
|
14310
|
-
let i = new Map(
|
|
14311
|
-
|
|
14314
|
+
function Ag(e, r) {
|
|
14315
|
+
let i = [...e], a = new Map(i.map((e) => [e.name, e])), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = {
|
|
14316
|
+
set(e) {
|
|
14317
|
+
i = [...e], a = new Map(i.map((e) => [e.name, e])), s.clear(), o.clear();
|
|
14318
|
+
},
|
|
14319
|
+
get() {
|
|
14320
|
+
return i;
|
|
14321
|
+
},
|
|
14322
|
+
invalidateCache(e) {
|
|
14323
|
+
e ? s.delete(e) : s.clear();
|
|
14324
|
+
}
|
|
14325
|
+
}, l = {
|
|
14312
14326
|
name: "skills",
|
|
14313
14327
|
tools: [n(async ({ name: e }) => {
|
|
14314
|
-
let t =
|
|
14328
|
+
let t = a.get(e);
|
|
14315
14329
|
if (!t) return `未找到 skill "${e}"。`;
|
|
14316
|
-
if (
|
|
14317
|
-
let n;
|
|
14318
|
-
if (
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14330
|
+
if (o.has(e)) return `skill "${e}" 已在本轮加载,无需重复。`;
|
|
14331
|
+
let n = s.get(e);
|
|
14332
|
+
if (n == null) {
|
|
14333
|
+
if (t.doc) {
|
|
14334
|
+
let i = await Og(t.doc, r?.readVfs);
|
|
14335
|
+
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14336
|
+
n = i.content;
|
|
14337
|
+
} else if (t.getContent) n = await t.getContent();
|
|
14338
|
+
else return `skill "${e}" 未配置内容(doc 或 getContent 任选其一)。`;
|
|
14339
|
+
s.set(e, n);
|
|
14340
|
+
}
|
|
14341
|
+
return o.add(e), `skill "${e}" 完整指令:\n\n${n}`;
|
|
14325
14342
|
}, {
|
|
14326
14343
|
name: "load_skill",
|
|
14327
14344
|
description: "加载某个 skill 的完整指令到当前上下文。先从 system prompt 的 Skills 索引选合适的 skill,再调用此工具。",
|
|
14328
14345
|
schema: t.object({ name: t.string().describe("skill 名") })
|
|
14329
14346
|
})],
|
|
14330
|
-
beforeAgent: () => ({
|
|
14331
|
-
skillsMetadata:
|
|
14347
|
+
beforeAgent: () => (o.clear(), {
|
|
14348
|
+
skillsMetadata: i.map((e) => ({
|
|
14332
14349
|
name: e.name,
|
|
14333
14350
|
description: e.description
|
|
14334
14351
|
})),
|
|
14335
14352
|
skillsLoaded: []
|
|
14336
14353
|
}),
|
|
14337
|
-
augmentPrompt: () =>
|
|
14338
|
-
afterModel: () => ({ skillsLoaded: [...
|
|
14354
|
+
augmentPrompt: () => kg(i),
|
|
14355
|
+
afterModel: () => ({ skillsLoaded: [...o] })
|
|
14339
14356
|
};
|
|
14357
|
+
return Object.defineProperty(l, "controller", {
|
|
14358
|
+
value: c,
|
|
14359
|
+
enumerable: !1,
|
|
14360
|
+
configurable: !1,
|
|
14361
|
+
writable: !1
|
|
14362
|
+
}), l;
|
|
14340
14363
|
}
|
|
14341
14364
|
//#endregion
|
|
14342
14365
|
//#region src/core/harness/memory.ts
|
|
14343
|
-
function
|
|
14366
|
+
function jg(e = "") {
|
|
14344
14367
|
let t = e;
|
|
14345
14368
|
return {
|
|
14346
14369
|
name: "memory",
|
|
@@ -14353,14 +14376,14 @@ function Ag(e = "") {
|
|
|
14353
14376
|
}
|
|
14354
14377
|
//#endregion
|
|
14355
14378
|
//#region src/core/harness/permissions.ts
|
|
14356
|
-
var
|
|
14379
|
+
var Mg = /* @__PURE__ */ new Set([
|
|
14357
14380
|
"set_data",
|
|
14358
14381
|
"edit_data",
|
|
14359
14382
|
"delete_data",
|
|
14360
14383
|
"write",
|
|
14361
14384
|
"vfs_write",
|
|
14362
14385
|
"vfs_edit"
|
|
14363
|
-
]),
|
|
14386
|
+
]), Ng = /* @__PURE__ */ new Set([
|
|
14364
14387
|
"get_data",
|
|
14365
14388
|
"describe_data",
|
|
14366
14389
|
"read",
|
|
@@ -14371,7 +14394,7 @@ var jg = /* @__PURE__ */ new Set([
|
|
|
14371
14394
|
"vfs_glob",
|
|
14372
14395
|
"vfs_grep"
|
|
14373
14396
|
]);
|
|
14374
|
-
function
|
|
14397
|
+
function Pg(e) {
|
|
14375
14398
|
let t = "";
|
|
14376
14399
|
for (let n = 0; n < e.length; n++) {
|
|
14377
14400
|
let r = e[n];
|
|
@@ -14379,16 +14402,16 @@ function Ng(e) {
|
|
|
14379
14402
|
}
|
|
14380
14403
|
return RegExp("^" + t + "$");
|
|
14381
14404
|
}
|
|
14382
|
-
function
|
|
14383
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14405
|
+
function Fg(e, t, n) {
|
|
14406
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => Pg(e).test(n))) return r.mode;
|
|
14384
14407
|
return "allow";
|
|
14385
14408
|
}
|
|
14386
|
-
function
|
|
14409
|
+
function Ig(e) {
|
|
14387
14410
|
return {
|
|
14388
14411
|
name: "permissions",
|
|
14389
14412
|
wrapToolCall: async (t, n) => {
|
|
14390
|
-
let r =
|
|
14391
|
-
return r && i &&
|
|
14413
|
+
let r = Mg.has(t.name) ? "write" : Ng.has(t.name) ? "read" : null, i = t.args?.jsonPath || t.args?.path || "";
|
|
14414
|
+
return r && i && Fg(e, r, i) === "deny" ? {
|
|
14392
14415
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14393
14416
|
status: "error"
|
|
14394
14417
|
} : n(t);
|
|
@@ -14397,7 +14420,7 @@ function Fg(e) {
|
|
|
14397
14420
|
}
|
|
14398
14421
|
//#endregion
|
|
14399
14422
|
//#region src/core/harness/approval.ts
|
|
14400
|
-
function
|
|
14423
|
+
function Lg(e = {}) {
|
|
14401
14424
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14402
14425
|
return {
|
|
14403
14426
|
name: "approval",
|
|
@@ -14431,15 +14454,15 @@ function Ig(e = {}) {
|
|
|
14431
14454
|
}
|
|
14432
14455
|
//#endregion
|
|
14433
14456
|
//#region src/core/harness/humanConfirm.ts
|
|
14434
|
-
var
|
|
14457
|
+
var Rg = "request_human_confirmation", zg = t.object({
|
|
14435
14458
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14436
14459
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14437
14460
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14438
14461
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14439
14462
|
});
|
|
14440
|
-
function
|
|
14463
|
+
function Bg() {
|
|
14441
14464
|
return n(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14442
|
-
name:
|
|
14465
|
+
name: Rg,
|
|
14443
14466
|
description: [
|
|
14444
14467
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14445
14468
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14449,10 +14472,10 @@ function zg() {
|
|
|
14449
14472
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14450
14473
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14451
14474
|
].join(""),
|
|
14452
|
-
schema:
|
|
14475
|
+
schema: zg
|
|
14453
14476
|
});
|
|
14454
14477
|
}
|
|
14455
|
-
function
|
|
14478
|
+
function Vg() {
|
|
14456
14479
|
return {
|
|
14457
14480
|
name: "humanConfirm",
|
|
14458
14481
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14484,14 +14507,14 @@ function Bg() {
|
|
|
14484
14507
|
}
|
|
14485
14508
|
//#endregion
|
|
14486
14509
|
//#region src/core/harness/checkpoint.ts
|
|
14487
|
-
function
|
|
14510
|
+
function Hg(e) {
|
|
14488
14511
|
if (typeof e != "object" || !e) return e;
|
|
14489
14512
|
if (typeof structuredClone == "function") try {
|
|
14490
14513
|
return structuredClone(e);
|
|
14491
14514
|
} catch {}
|
|
14492
14515
|
return JSON.parse(JSON.stringify(e));
|
|
14493
14516
|
}
|
|
14494
|
-
function
|
|
14517
|
+
function Ug(e, t) {
|
|
14495
14518
|
let n = t.split("."), r = e;
|
|
14496
14519
|
for (let e of n) {
|
|
14497
14520
|
if (r == null) return;
|
|
@@ -14499,12 +14522,12 @@ function Hg(e, t) {
|
|
|
14499
14522
|
}
|
|
14500
14523
|
return r;
|
|
14501
14524
|
}
|
|
14502
|
-
function
|
|
14525
|
+
function Wg(e, t, n) {
|
|
14503
14526
|
let r = t.split("."), i = e;
|
|
14504
14527
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14505
14528
|
i[r[r.length - 1]] = n;
|
|
14506
14529
|
}
|
|
14507
|
-
function
|
|
14530
|
+
function Gg(e, t) {
|
|
14508
14531
|
if (Array.isArray(e)) {
|
|
14509
14532
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14510
14533
|
return;
|
|
@@ -14513,11 +14536,11 @@ function Wg(e, t) {
|
|
|
14513
14536
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14514
14537
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14515
14538
|
}
|
|
14516
|
-
function
|
|
14517
|
-
let n =
|
|
14518
|
-
typeof n == "object" && n ?
|
|
14539
|
+
function Kg(e, t) {
|
|
14540
|
+
let n = Ug(window, e);
|
|
14541
|
+
typeof n == "object" && n ? Gg(n, t) : Wg(window, e, t);
|
|
14519
14542
|
}
|
|
14520
|
-
function
|
|
14543
|
+
function qg(e) {
|
|
14521
14544
|
let t = e.slice();
|
|
14522
14545
|
for (; t.length;) {
|
|
14523
14546
|
let e = t[t.length - 1];
|
|
@@ -14526,21 +14549,21 @@ function Kg(e) {
|
|
|
14526
14549
|
}
|
|
14527
14550
|
return t;
|
|
14528
14551
|
}
|
|
14529
|
-
function
|
|
14552
|
+
function Jg(e) {
|
|
14530
14553
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14531
14554
|
return {
|
|
14532
14555
|
save(i) {
|
|
14533
|
-
let a =
|
|
14534
|
-
if (e.getData) o[""] =
|
|
14535
|
-
else for (let t of e.slotPaths ?? []) o[t] =
|
|
14556
|
+
let a = qg(e.messages), o = {};
|
|
14557
|
+
if (e.getData) o[""] = Hg(e.getData());
|
|
14558
|
+
else for (let t of e.slotPaths ?? []) o[t] = Hg(Ug(window, t));
|
|
14536
14559
|
let s = {
|
|
14537
14560
|
id: r++,
|
|
14538
14561
|
label: i,
|
|
14539
14562
|
timestamp: Date.now(),
|
|
14540
|
-
messages:
|
|
14563
|
+
messages: Hg(a),
|
|
14541
14564
|
windowVals: o,
|
|
14542
|
-
vfs:
|
|
14543
|
-
todos:
|
|
14565
|
+
vfs: Hg(e.vfsStore.files),
|
|
14566
|
+
todos: Hg(e.getTodos()),
|
|
14544
14567
|
messageCount: a.length
|
|
14545
14568
|
};
|
|
14546
14569
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14560,20 +14583,20 @@ function qg(e) {
|
|
|
14560
14583
|
restore(n) {
|
|
14561
14584
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14562
14585
|
if (!r) return !1;
|
|
14563
|
-
if (e.messages.splice(0, e.messages.length, ...
|
|
14586
|
+
if (e.messages.splice(0, e.messages.length, ...Hg(r.messages)), e.getData) {
|
|
14564
14587
|
let t = r.windowVals[""];
|
|
14565
14588
|
if (t !== void 0) {
|
|
14566
14589
|
let n = e.getData();
|
|
14567
|
-
typeof n == "object" && n &&
|
|
14590
|
+
typeof n == "object" && n && Gg(n, Hg(t));
|
|
14568
14591
|
}
|
|
14569
|
-
} else for (let [e, t] of Object.entries(r.windowVals))
|
|
14592
|
+
} else for (let [e, t] of Object.entries(r.windowVals)) Kg(e, Hg(t));
|
|
14570
14593
|
let i = e.vfsStore.files;
|
|
14571
14594
|
for (let e of Object.keys(i)) delete i[e];
|
|
14572
|
-
return Object.assign(i,
|
|
14595
|
+
return Object.assign(i, Hg(r.vfs)), e.todosMw.reset(Hg(r.todos)), !0;
|
|
14573
14596
|
}
|
|
14574
14597
|
};
|
|
14575
14598
|
}
|
|
14576
|
-
function
|
|
14599
|
+
function Yg(e) {
|
|
14577
14600
|
let t = !1;
|
|
14578
14601
|
return {
|
|
14579
14602
|
name: "checkpoint",
|
|
@@ -14587,23 +14610,23 @@ function Jg(e) {
|
|
|
14587
14610
|
}
|
|
14588
14611
|
//#endregion
|
|
14589
14612
|
//#region src/core/harness/subagent.ts
|
|
14590
|
-
function
|
|
14613
|
+
function Xg(e) {
|
|
14591
14614
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14592
14615
|
}
|
|
14593
|
-
var
|
|
14616
|
+
var Zg = [
|
|
14594
14617
|
"describe_data",
|
|
14595
14618
|
"get_data",
|
|
14596
14619
|
"read",
|
|
14597
14620
|
"query_data",
|
|
14598
14621
|
"search_data",
|
|
14599
14622
|
"fetch_document"
|
|
14600
|
-
],
|
|
14601
|
-
async function
|
|
14602
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
14623
|
+
], Qg = 1, $g = 4, e_ = 6, t_ = ["spawn_agent", "spawn_agents"];
|
|
14624
|
+
async function n_(e, t, n, r, i) {
|
|
14625
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? Qg, s = /* @__PURE__ */ new Set([...Zg, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !t_.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [r_({
|
|
14603
14626
|
...t,
|
|
14604
14627
|
depth: a + 1
|
|
14605
|
-
})] : [], u =
|
|
14606
|
-
...
|
|
14628
|
+
})] : [], u = xg({
|
|
14629
|
+
...Xg(t.llm) ? { llm: t.llm } : {
|
|
14607
14630
|
apiKey: t.llm.apiKey,
|
|
14608
14631
|
baseUrl: t.llm.baseUrl,
|
|
14609
14632
|
model: e.model ?? t.llm.model,
|
|
@@ -14612,8 +14635,8 @@ async function t_(e, t, n, r, i) {
|
|
|
14612
14635
|
},
|
|
14613
14636
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读主数据 / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
14614
14637
|
tools: c,
|
|
14615
|
-
middleware: [...t.skills?.length ? [
|
|
14616
|
-
maxToolRounds: t.maxToolRounds ??
|
|
14638
|
+
middleware: [...t.skills?.length ? [Ag(t.skills)] : [], ...l],
|
|
14639
|
+
maxToolRounds: t.maxToolRounds ?? e_,
|
|
14617
14640
|
onLog: i,
|
|
14618
14641
|
debug: t.debug
|
|
14619
14642
|
});
|
|
@@ -14625,8 +14648,8 @@ async function t_(e, t, n, r, i) {
|
|
|
14625
14648
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
14626
14649
|
}, n);
|
|
14627
14650
|
}
|
|
14628
|
-
function
|
|
14629
|
-
let r = e.maxParallel ??
|
|
14651
|
+
function r_(e) {
|
|
14652
|
+
let r = e.maxParallel ?? $g, i, a, o, s = (e, t) => (n) => {
|
|
14630
14653
|
a && a({
|
|
14631
14654
|
type: "subagent",
|
|
14632
14655
|
taskId: e,
|
|
@@ -14645,7 +14668,7 @@ function n_(e) {
|
|
|
14645
14668
|
...e,
|
|
14646
14669
|
allowedTools: r
|
|
14647
14670
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
14648
|
-
return await
|
|
14671
|
+
return await n_({
|
|
14649
14672
|
prompt: t,
|
|
14650
14673
|
role: n,
|
|
14651
14674
|
model: a
|
|
@@ -14662,9 +14685,9 @@ function n_(e) {
|
|
|
14662
14685
|
tools: t.array(t.string()).optional().describe("子 agent 可用工具名白名单(默认只读主数据 + fetch)"),
|
|
14663
14686
|
model: t.string().optional().describe("覆盖模型(默认同主)")
|
|
14664
14687
|
})
|
|
14665
|
-
}), n(async ({ tasks: t }) => (await
|
|
14688
|
+
}), n(async ({ tasks: t }) => (await eg(t, r, async (t, n) => {
|
|
14666
14689
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
14667
|
-
return
|
|
14690
|
+
return n_(t, e, i, s(r, a), (e) => o?.({
|
|
14668
14691
|
...e,
|
|
14669
14692
|
source: `子:${a}`
|
|
14670
14693
|
}));
|
|
@@ -14679,8 +14702,8 @@ function n_(e) {
|
|
|
14679
14702
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
14680
14703
|
};
|
|
14681
14704
|
}
|
|
14682
|
-
var
|
|
14683
|
-
function
|
|
14705
|
+
var i_ = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
14706
|
+
function a_(e, t) {
|
|
14684
14707
|
let n = e.tools ?? [];
|
|
14685
14708
|
return {
|
|
14686
14709
|
llm: e.llm ?? t.llm,
|
|
@@ -14694,9 +14717,9 @@ function i_(e, t) {
|
|
|
14694
14717
|
debug: t.debug
|
|
14695
14718
|
};
|
|
14696
14719
|
}
|
|
14697
|
-
function
|
|
14720
|
+
function o_(e, r) {
|
|
14698
14721
|
let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
|
|
14699
|
-
if (!
|
|
14722
|
+
if (!i_.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
|
|
14700
14723
|
let t = `use_${e.id}`;
|
|
14701
14724
|
return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
|
|
14702
14725
|
}), o, s, c, l = (e, t) => (n) => {
|
|
@@ -14714,8 +14737,8 @@ function a_(e, r) {
|
|
|
14714
14737
|
return {
|
|
14715
14738
|
name: "subagents",
|
|
14716
14739
|
tools: a.map((e) => n(async ({ task: t }) => {
|
|
14717
|
-
let n =
|
|
14718
|
-
return
|
|
14740
|
+
let n = a_(e, r);
|
|
14741
|
+
return n_({ prompt: t }, n, o, l(`use_${e.id}`, e.id), (t) => c?.({
|
|
14719
14742
|
...t,
|
|
14720
14743
|
source: `子:${e.id}`
|
|
14721
14744
|
}));
|
|
@@ -14734,7 +14757,7 @@ function a_(e, r) {
|
|
|
14734
14757
|
}
|
|
14735
14758
|
//#endregion
|
|
14736
14759
|
//#region src/core/harness/verify.ts
|
|
14737
|
-
function
|
|
14760
|
+
function s_(e) {
|
|
14738
14761
|
return {
|
|
14739
14762
|
name: "verify",
|
|
14740
14763
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -14746,10 +14769,10 @@ function o_(e) {
|
|
|
14746
14769
|
if (e.adversarial) {
|
|
14747
14770
|
r?.("middleware", {
|
|
14748
14771
|
stage: "adversarial_start",
|
|
14749
|
-
model:
|
|
14772
|
+
model: h_(e.adversarial.llm),
|
|
14750
14773
|
tools: (e.adversarial.tools ?? []).length
|
|
14751
14774
|
});
|
|
14752
|
-
let n = await
|
|
14775
|
+
let n = await y_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
14753
14776
|
if (r?.("middleware", {
|
|
14754
14777
|
stage: "adversarial_done",
|
|
14755
14778
|
clean: n === null,
|
|
@@ -14760,18 +14783,18 @@ function o_(e) {
|
|
|
14760
14783
|
}
|
|
14761
14784
|
};
|
|
14762
14785
|
}
|
|
14763
|
-
var
|
|
14786
|
+
var c_ = /* @__PURE__ */ new Set([
|
|
14764
14787
|
"set_data",
|
|
14765
14788
|
"edit_data",
|
|
14766
14789
|
"delete_data",
|
|
14767
14790
|
"write"
|
|
14768
|
-
]),
|
|
14769
|
-
function
|
|
14791
|
+
]), l_ = /校验失败|SCHEMA_INVALID|未注册|不存在|仅支持|必须是|NOT_OBJECT|PATH_UNSAFE|VERSION_CONFLICT|WRITE_INTERCEPT/;
|
|
14792
|
+
function u_(e) {
|
|
14770
14793
|
let t = /* @__PURE__ */ new Map();
|
|
14771
14794
|
for (let n of e) {
|
|
14772
14795
|
let e = n?.tool_calls;
|
|
14773
14796
|
if (Array.isArray(e)) {
|
|
14774
|
-
for (let n of e) if (
|
|
14797
|
+
for (let n of e) if (c_.has(n.name)) {
|
|
14775
14798
|
let e = typeof n?.args?.jsonPath == "string" ? n.args.jsonPath : "";
|
|
14776
14799
|
t.set(e, {
|
|
14777
14800
|
path: e,
|
|
@@ -14783,7 +14806,7 @@ function l_(e) {
|
|
|
14783
14806
|
}
|
|
14784
14807
|
return [...t.values()];
|
|
14785
14808
|
}
|
|
14786
|
-
function
|
|
14809
|
+
function d_(e) {
|
|
14787
14810
|
let t = /* @__PURE__ */ new Map();
|
|
14788
14811
|
for (let n of e) {
|
|
14789
14812
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -14791,7 +14814,7 @@ function u_(e) {
|
|
|
14791
14814
|
}
|
|
14792
14815
|
return t;
|
|
14793
14816
|
}
|
|
14794
|
-
function
|
|
14817
|
+
function f_(e, t) {
|
|
14795
14818
|
if (t === "") return e;
|
|
14796
14819
|
if (e == null) return;
|
|
14797
14820
|
let n = e;
|
|
@@ -14801,16 +14824,16 @@ function d_(e, t) {
|
|
|
14801
14824
|
}
|
|
14802
14825
|
return n;
|
|
14803
14826
|
}
|
|
14804
|
-
function
|
|
14827
|
+
function p_(e = {}) {
|
|
14805
14828
|
let t = typeof e.root == "function" ? e.root : e.root === void 0 ? () => e.window ?? globalThis.window : () => e.root, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
|
|
14806
14829
|
return async ({ messages: e }) => {
|
|
14807
|
-
let r =
|
|
14830
|
+
let r = u_(e);
|
|
14808
14831
|
if (!r.length) return { ok: !0 };
|
|
14809
|
-
let i =
|
|
14832
|
+
let i = d_(e), a = n()[""], o = t(), s = [];
|
|
14810
14833
|
for (let { path: e, op: t, callId: n } of r) {
|
|
14811
14834
|
let r = n ? i.get(n) : void 0;
|
|
14812
|
-
if (r &&
|
|
14813
|
-
let c =
|
|
14835
|
+
if (r && l_.test(r)) continue;
|
|
14836
|
+
let c = f_(o, e);
|
|
14814
14837
|
if (t === "delete_data") c !== void 0 && s.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14815
14838
|
else if (c == null) s.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14816
14839
|
else if (a) {
|
|
@@ -14824,17 +14847,17 @@ function f_(e = {}) {
|
|
|
14824
14847
|
} : { ok: !0 };
|
|
14825
14848
|
};
|
|
14826
14849
|
}
|
|
14827
|
-
function p_(e) {
|
|
14828
|
-
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14829
|
-
}
|
|
14830
14850
|
function m_(e) {
|
|
14831
|
-
return
|
|
14851
|
+
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14832
14852
|
}
|
|
14833
|
-
|
|
14834
|
-
|
|
14835
|
-
return h_.test(e);
|
|
14853
|
+
function h_(e) {
|
|
14854
|
+
return m_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
14836
14855
|
}
|
|
14856
|
+
var g_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
14837
14857
|
function __(e) {
|
|
14858
|
+
return g_.test(e);
|
|
14859
|
+
}
|
|
14860
|
+
function v_(e) {
|
|
14838
14861
|
let t = "", n = "";
|
|
14839
14862
|
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 : "");
|
|
14840
14863
|
return {
|
|
@@ -14842,8 +14865,8 @@ function __(e) {
|
|
|
14842
14865
|
lastReply: n
|
|
14843
14866
|
};
|
|
14844
14867
|
}
|
|
14845
|
-
async function
|
|
14846
|
-
let { lastUser: i, lastReply: a } =
|
|
14868
|
+
async function y_(e, t, n, r) {
|
|
14869
|
+
let { lastUser: i, lastReply: a } = v_(e);
|
|
14847
14870
|
if (!a) return null;
|
|
14848
14871
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
14849
14872
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -14854,7 +14877,7 @@ async function v_(e, t, n, r) {
|
|
|
14854
14877
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
14855
14878
|
...e.data,
|
|
14856
14879
|
source: "adversarial"
|
|
14857
|
-
}) : void 0, u = await
|
|
14880
|
+
}) : void 0, u = await xg(m_(t) ? {
|
|
14858
14881
|
llm: t,
|
|
14859
14882
|
tools: r,
|
|
14860
14883
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -14879,17 +14902,17 @@ async function v_(e, t, n, r) {
|
|
|
14879
14902
|
stage: "adversarial_verdict",
|
|
14880
14903
|
verdict: u,
|
|
14881
14904
|
source: "adversarial"
|
|
14882
|
-
}),
|
|
14905
|
+
}), __(u) ? null : u.trim();
|
|
14883
14906
|
}
|
|
14884
14907
|
//#endregion
|
|
14885
14908
|
//#region src/core/mcp/client.ts
|
|
14886
|
-
function
|
|
14909
|
+
function b_(e) {
|
|
14887
14910
|
let t = e?.content;
|
|
14888
14911
|
if (!Array.isArray(t) || !t.length) return "";
|
|
14889
14912
|
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");
|
|
14890
14913
|
return e?.isError ? `工具错误:${n}` : n;
|
|
14891
14914
|
}
|
|
14892
|
-
async function
|
|
14915
|
+
async function x_(e) {
|
|
14893
14916
|
let t = new URL(e.url), n = e.requestInit;
|
|
14894
14917
|
if (e.transport === "http") {
|
|
14895
14918
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -14902,8 +14925,8 @@ async function b_(e) {
|
|
|
14902
14925
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
14903
14926
|
return new r(t);
|
|
14904
14927
|
}
|
|
14905
|
-
function
|
|
14906
|
-
return n(async (n) =>
|
|
14928
|
+
function S_(e, t) {
|
|
14929
|
+
return n(async (n) => b_(await t.callTool({
|
|
14907
14930
|
name: e.name,
|
|
14908
14931
|
arguments: n
|
|
14909
14932
|
})), {
|
|
@@ -14912,21 +14935,21 @@ function x_(e, t) {
|
|
|
14912
14935
|
schema: e.inputSchema
|
|
14913
14936
|
});
|
|
14914
14937
|
}
|
|
14915
|
-
async function
|
|
14916
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
14938
|
+
async function C_(e) {
|
|
14939
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await x_(e), r = new t({
|
|
14917
14940
|
name: "page-agent-sdk",
|
|
14918
14941
|
version: "1.0"
|
|
14919
14942
|
}, { capabilities: {} });
|
|
14920
14943
|
await r.connect(n);
|
|
14921
14944
|
let { tools: i } = await r.listTools();
|
|
14922
14945
|
return {
|
|
14923
|
-
tools: i.map((e) =>
|
|
14946
|
+
tools: i.map((e) => S_(e, r)),
|
|
14924
14947
|
close: () => r.close()
|
|
14925
14948
|
};
|
|
14926
14949
|
}
|
|
14927
14950
|
//#endregion
|
|
14928
14951
|
//#region src/core/utils/rounds.ts
|
|
14929
|
-
function
|
|
14952
|
+
function w_(e) {
|
|
14930
14953
|
let t = [], n = null, r = 0;
|
|
14931
14954
|
for (let i = 0; i < e.length; i++) {
|
|
14932
14955
|
let a = e[i];
|
|
@@ -14940,14 +14963,14 @@ function C_(e) {
|
|
|
14940
14963
|
}
|
|
14941
14964
|
return n && t.push(n), t;
|
|
14942
14965
|
}
|
|
14943
|
-
function
|
|
14966
|
+
function T_(e, t) {
|
|
14944
14967
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
14945
14968
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
14946
14969
|
}
|
|
14947
|
-
var
|
|
14948
|
-
function
|
|
14970
|
+
var E_ = "【更早对话摘要";
|
|
14971
|
+
function D_(e, t) {
|
|
14949
14972
|
if (t <= 0) return { trimmed: !1 };
|
|
14950
|
-
let n =
|
|
14973
|
+
let n = w_(e);
|
|
14951
14974
|
if (n.length <= t) return { trimmed: !1 };
|
|
14952
14975
|
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = "";
|
|
14953
14976
|
for (let t = 0; t < a; t++) {
|
|
@@ -14958,7 +14981,7 @@ function E_(e, t) {
|
|
|
14958
14981
|
}
|
|
14959
14982
|
}
|
|
14960
14983
|
let s = i.map((e) => {
|
|
14961
|
-
let t =
|
|
14984
|
+
let t = T_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? T_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
14962
14985
|
return `- 第${e.round}轮:${t} → ${n}`;
|
|
14963
14986
|
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
14964
14987
|
return {
|
|
@@ -14967,47 +14990,47 @@ function E_(e, t) {
|
|
|
14967
14990
|
deleteCount: r,
|
|
14968
14991
|
summary: {
|
|
14969
14992
|
role: "system",
|
|
14970
|
-
content: c ? `${
|
|
14993
|
+
content: c ? `${E_}(${i.length} 轮,含累积)】\n${c}\n【续】\n${s}` : `${E_}(${i.length} 轮)】\n${s}`,
|
|
14971
14994
|
timestamp: i[0].userMsg.timestamp
|
|
14972
14995
|
}
|
|
14973
14996
|
};
|
|
14974
14997
|
}
|
|
14975
14998
|
//#endregion
|
|
14976
14999
|
//#region src/core/composables/useContextManager.ts
|
|
14977
|
-
var
|
|
15000
|
+
var O_ = {
|
|
14978
15001
|
windowRounds: 6,
|
|
14979
15002
|
summaryThresholdRounds: 8,
|
|
14980
15003
|
toolResultMaxChars: 800,
|
|
14981
15004
|
enableRecall: !0,
|
|
14982
15005
|
recallTopK: 3,
|
|
14983
15006
|
enableLLMSummary: !1
|
|
14984
|
-
},
|
|
14985
|
-
function k_(e) {
|
|
14986
|
-
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !O_.has(e));
|
|
14987
|
-
}
|
|
15007
|
+
}, k_ = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
14988
15008
|
function A_(e) {
|
|
15009
|
+
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !k_.has(e));
|
|
15010
|
+
}
|
|
15011
|
+
function j_(e) {
|
|
14989
15012
|
let t = typeof e.content == "string" ? e.content : "";
|
|
14990
15013
|
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);
|
|
14991
|
-
return
|
|
15014
|
+
return ig(t);
|
|
14992
15015
|
}
|
|
14993
|
-
function
|
|
14994
|
-
let t =
|
|
14995
|
-
for (let n of e.assistantMsgs) t +=
|
|
15016
|
+
function M_(e) {
|
|
15017
|
+
let t = j_(e.userMsg);
|
|
15018
|
+
for (let n of e.assistantMsgs) t += j_(n);
|
|
14996
15019
|
return t;
|
|
14997
15020
|
}
|
|
14998
|
-
function
|
|
15021
|
+
function N_(e, t) {
|
|
14999
15022
|
return e.map((e) => {
|
|
15000
|
-
let n =
|
|
15023
|
+
let n = T_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? T_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
15001
15024
|
if (t && t.size) {
|
|
15002
15025
|
let n = [];
|
|
15003
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
15026
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${T_(e.result, 120)}`);
|
|
15004
15027
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
15005
15028
|
}
|
|
15006
15029
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
15007
15030
|
}).join("\n");
|
|
15008
15031
|
}
|
|
15009
|
-
function
|
|
15010
|
-
let r =
|
|
15032
|
+
function P_(e, t, n) {
|
|
15033
|
+
let r = A_(t);
|
|
15011
15034
|
return r.length === 0 ? [] : e.map((e) => {
|
|
15012
15035
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
15013
15036
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -15017,13 +15040,13 @@ function N_(e, t, n) {
|
|
|
15017
15040
|
};
|
|
15018
15041
|
}).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
|
|
15019
15042
|
}
|
|
15020
|
-
function
|
|
15043
|
+
function F_(e = {}) {
|
|
15021
15044
|
let t = {
|
|
15022
|
-
...
|
|
15045
|
+
...O_,
|
|
15023
15046
|
...e
|
|
15024
15047
|
};
|
|
15025
15048
|
async function n(e) {
|
|
15026
|
-
let n =
|
|
15049
|
+
let n = w_(e), r = e.length, i = "";
|
|
15027
15050
|
if (n.length) {
|
|
15028
15051
|
let t = n[0].startIdx;
|
|
15029
15052
|
for (let n = 0; n < t; n++) {
|
|
@@ -15047,9 +15070,9 @@ function P_(e = {}) {
|
|
|
15047
15070
|
}
|
|
15048
15071
|
}), o, s, c;
|
|
15049
15072
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
15050
|
-
if (n.reduce((e, t) => e +
|
|
15073
|
+
if (n.reduce((e, t) => e + M_(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return a("none");
|
|
15051
15074
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, i = 0;
|
|
15052
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
15075
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += M_(n[t]), r >= e) {
|
|
15053
15076
|
i = t + 1;
|
|
15054
15077
|
break;
|
|
15055
15078
|
}
|
|
@@ -15062,12 +15085,12 @@ function P_(e = {}) {
|
|
|
15062
15085
|
}
|
|
15063
15086
|
let l = [...e].reverse().find((e) => e.role === "user")?.content || "", u = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, d, f;
|
|
15064
15087
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
15065
|
-
d = await t.llmInvoke(
|
|
15088
|
+
d = await t.llmInvoke(N_(s, u)), f = c + "llm_summary";
|
|
15066
15089
|
} catch {
|
|
15067
|
-
d =
|
|
15090
|
+
d = N_(s, u), f = c + "index_summary(llm_fallback)";
|
|
15068
15091
|
}
|
|
15069
|
-
else d =
|
|
15070
|
-
let p = t.enableRecall ?
|
|
15092
|
+
else d = N_(s, u), f = c + "index_summary";
|
|
15093
|
+
let p = t.enableRecall ? P_(s, l, t.recallTopK) : [], m = p.length ? p.map((e) => `- 第${e.round}轮:${T_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? T_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", h = i ? `${d}\n【更早累积摘要】\n${i}` : d, g = [`【对话历史摘要】以下是之前 ${s.length} 轮对话的要点(最新 ${o.length} 轮已完整保留):`, h];
|
|
15071
15094
|
m && g.push("\n【与当前问题可能相关的早期对话】", m);
|
|
15072
15095
|
let _ = t.getRegisteredData ?? t.getRegisteredSlots;
|
|
15073
15096
|
if (_) try {
|
|
@@ -15104,8 +15127,8 @@ function P_(e = {}) {
|
|
|
15104
15127
|
}
|
|
15105
15128
|
//#endregion
|
|
15106
15129
|
//#region src/core/harness/summarization.ts
|
|
15107
|
-
function
|
|
15108
|
-
let t =
|
|
15130
|
+
function I_(e = {}) {
|
|
15131
|
+
let t = F_(e);
|
|
15109
15132
|
return {
|
|
15110
15133
|
name: "summarization",
|
|
15111
15134
|
compressInput: async (e) => {
|
|
@@ -15119,7 +15142,7 @@ function F_(e = {}) {
|
|
|
15119
15142
|
}
|
|
15120
15143
|
//#endregion
|
|
15121
15144
|
//#region src/core/presets.ts
|
|
15122
|
-
var
|
|
15145
|
+
var L_ = {
|
|
15123
15146
|
pageBuilder: { systemPrompt: "你是页面构建助手。按用户意图读写主数据(经 data 声明 + schema 校验),改完页面实时更新。" },
|
|
15124
15147
|
researcher: {
|
|
15125
15148
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15133,7 +15156,7 @@ var I_ = {
|
|
|
15133
15156
|
memory: !1,
|
|
15134
15157
|
subagent: !1
|
|
15135
15158
|
} }
|
|
15136
|
-
},
|
|
15159
|
+
}, R_ = { reliableWriteRules: [
|
|
15137
15160
|
"【可靠写入规则】",
|
|
15138
15161
|
"1. 改任何字段前,先用 read({ jsonPath }) 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15139
15162
|
"2. 若不确定可操作哪些字段,先 read() 不传 jsonPath 查看主数据说明 + schema 声明字段(集成方可经 sdk.setData 运行时替换 schema,以工具返回为准,勿凭旧记忆);",
|
|
@@ -15141,7 +15164,7 @@ var I_ = {
|
|
|
15141
15164
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15142
15165
|
"5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断。"
|
|
15143
15166
|
].join("\n") };
|
|
15144
|
-
function
|
|
15167
|
+
function z_(e) {
|
|
15145
15168
|
if (!e) return "";
|
|
15146
15169
|
try {
|
|
15147
15170
|
let t = e.shape ?? (e._def?.shape ? typeof e._def.shape == "function" ? e._def.shape() : e._def.shape : null);
|
|
@@ -15154,7 +15177,7 @@ function R_(e) {
|
|
|
15154
15177
|
}
|
|
15155
15178
|
//#endregion
|
|
15156
15179
|
//#region src/core/sdk/contextPreset.ts
|
|
15157
|
-
var
|
|
15180
|
+
var B_ = {
|
|
15158
15181
|
auto: {
|
|
15159
15182
|
summaryThresholdRatio: .5,
|
|
15160
15183
|
windowRatio: .4,
|
|
@@ -15176,8 +15199,8 @@ var z_ = {
|
|
|
15176
15199
|
enableLLMSummary: !0
|
|
15177
15200
|
}
|
|
15178
15201
|
};
|
|
15179
|
-
function
|
|
15180
|
-
let n =
|
|
15202
|
+
function V_(e, t) {
|
|
15203
|
+
let n = B_[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15181
15204
|
return {
|
|
15182
15205
|
...n,
|
|
15183
15206
|
...r,
|
|
@@ -15194,7 +15217,7 @@ function $(e) {
|
|
|
15194
15217
|
};
|
|
15195
15218
|
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)}`;
|
|
15196
15219
|
}
|
|
15197
|
-
function
|
|
15220
|
+
function H_(e) {
|
|
15198
15221
|
return e.slice(0, 10).map((e) => {
|
|
15199
15222
|
let t = e, n = {
|
|
15200
15223
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15203,16 +15226,16 @@ function V_(e) {
|
|
|
15203
15226
|
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;
|
|
15204
15227
|
});
|
|
15205
15228
|
}
|
|
15206
|
-
function
|
|
15229
|
+
function U_(e, t) {
|
|
15207
15230
|
return $({
|
|
15208
15231
|
code: "SCHEMA_INVALID",
|
|
15209
15232
|
path: e,
|
|
15210
15233
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15211
15234
|
hint: `用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,
|
|
15212
|
-
details:
|
|
15235
|
+
details: H_(t)
|
|
15213
15236
|
});
|
|
15214
15237
|
}
|
|
15215
|
-
function
|
|
15238
|
+
function W_(e, t, n) {
|
|
15216
15239
|
let r = n?.message || String(n);
|
|
15217
15240
|
return $({
|
|
15218
15241
|
code: "JSON_PARSE",
|
|
@@ -15221,18 +15244,18 @@ function U_(e, t, n) {
|
|
|
15221
15244
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15222
15245
|
});
|
|
15223
15246
|
}
|
|
15224
|
-
var
|
|
15225
|
-
function
|
|
15247
|
+
var G_ = .9;
|
|
15248
|
+
function K_(e, t = {}) {
|
|
15226
15249
|
let n = Object.create(null);
|
|
15227
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15250
|
+
if (e) for (let [t, r] of Object.entries(e)) n[Y_(t)] = {
|
|
15228
15251
|
content: r,
|
|
15229
|
-
updatedAt:
|
|
15252
|
+
updatedAt: Z_()
|
|
15230
15253
|
};
|
|
15231
15254
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15232
15255
|
function a() {
|
|
15233
|
-
if (
|
|
15234
|
-
let e = i *
|
|
15235
|
-
for (let [r] of t) if (delete n[r],
|
|
15256
|
+
if (J_(n) <= i) return;
|
|
15257
|
+
let e = i * G_, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15258
|
+
for (let [r] of t) if (delete n[r], J_(n) <= e) break;
|
|
15236
15259
|
}
|
|
15237
15260
|
let o = null;
|
|
15238
15261
|
function s() {
|
|
@@ -15257,7 +15280,7 @@ function G_(e, t = {}) {
|
|
|
15257
15280
|
}
|
|
15258
15281
|
}) };
|
|
15259
15282
|
return r && (l.hydrate = (e) => {
|
|
15260
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15283
|
+
for (let [t, r] of Object.entries(e)) n[Y_(t)] = r;
|
|
15261
15284
|
a();
|
|
15262
15285
|
}, l.flush = () => {
|
|
15263
15286
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15266,17 +15289,17 @@ function G_(e, t = {}) {
|
|
|
15266
15289
|
c();
|
|
15267
15290
|
}), l;
|
|
15268
15291
|
}
|
|
15269
|
-
var
|
|
15270
|
-
function
|
|
15271
|
-
|
|
15292
|
+
var q_ = null;
|
|
15293
|
+
function J_(e) {
|
|
15294
|
+
q_ ||= new TextEncoder();
|
|
15272
15295
|
let t = 0;
|
|
15273
|
-
for (let n of Object.values(e)) t +=
|
|
15296
|
+
for (let n of Object.values(e)) t += q_.encode(n.content).length;
|
|
15274
15297
|
return t;
|
|
15275
15298
|
}
|
|
15276
|
-
function
|
|
15299
|
+
function Y_(e) {
|
|
15277
15300
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15278
15301
|
}
|
|
15279
|
-
function
|
|
15302
|
+
function X_(e) {
|
|
15280
15303
|
let t = "";
|
|
15281
15304
|
for (let n = 0; n < e.length; n++) {
|
|
15282
15305
|
let r = e[n];
|
|
@@ -15284,13 +15307,13 @@ function Y_(e) {
|
|
|
15284
15307
|
}
|
|
15285
15308
|
return RegExp("^" + t + "$");
|
|
15286
15309
|
}
|
|
15287
|
-
function
|
|
15310
|
+
function Z_() {
|
|
15288
15311
|
return Date.now();
|
|
15289
15312
|
}
|
|
15290
|
-
function
|
|
15313
|
+
function Q_(e) {
|
|
15291
15314
|
return [
|
|
15292
15315
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15293
|
-
let i = e.files[
|
|
15316
|
+
let i = e.files[Y_(t)];
|
|
15294
15317
|
if (!i) return $({
|
|
15295
15318
|
code: "NOT_FOUND",
|
|
15296
15319
|
path: t,
|
|
@@ -15308,9 +15331,9 @@ function Z_(e) {
|
|
|
15308
15331
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15309
15332
|
})
|
|
15310
15333
|
}),
|
|
15311
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15334
|
+
n(async ({ path: t, content: n }) => (e.files[Y_(t)] = {
|
|
15312
15335
|
content: n,
|
|
15313
|
-
updatedAt:
|
|
15336
|
+
updatedAt: Z_()
|
|
15314
15337
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15315
15338
|
name: "vfs_write",
|
|
15316
15339
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15320,7 +15343,7 @@ function Z_(e) {
|
|
|
15320
15343
|
})
|
|
15321
15344
|
}),
|
|
15322
15345
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15323
|
-
let i =
|
|
15346
|
+
let i = Y_(t), a = e.files[i];
|
|
15324
15347
|
if (!a) return $({
|
|
15325
15348
|
code: "NOT_FOUND",
|
|
15326
15349
|
path: t,
|
|
@@ -15350,7 +15373,7 @@ function Z_(e) {
|
|
|
15350
15373
|
}
|
|
15351
15374
|
return e.files[i] = {
|
|
15352
15375
|
content: a.content.replace(n, r),
|
|
15353
|
-
updatedAt:
|
|
15376
|
+
updatedAt: Z_()
|
|
15354
15377
|
}, `已替换 ${t} 中 1 处。`;
|
|
15355
15378
|
}, {
|
|
15356
15379
|
name: "vfs_edit",
|
|
@@ -15372,7 +15395,7 @@ function Z_(e) {
|
|
|
15372
15395
|
n(async ({ pattern: t }) => {
|
|
15373
15396
|
let n;
|
|
15374
15397
|
try {
|
|
15375
|
-
n =
|
|
15398
|
+
n = X_(t);
|
|
15376
15399
|
} catch (e) {
|
|
15377
15400
|
return $({
|
|
15378
15401
|
code: "GLOB_INVALID",
|
|
@@ -15401,7 +15424,7 @@ function Z_(e) {
|
|
|
15401
15424
|
details: { pattern: t }
|
|
15402
15425
|
});
|
|
15403
15426
|
}
|
|
15404
|
-
let i = n ? [
|
|
15427
|
+
let i = n ? [Y_(n)] : Object.keys(e.files), a = [];
|
|
15405
15428
|
for (let t of i) {
|
|
15406
15429
|
let n = e.files[t];
|
|
15407
15430
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15419,17 +15442,17 @@ function Z_(e) {
|
|
|
15419
15442
|
})
|
|
15420
15443
|
];
|
|
15421
15444
|
}
|
|
15422
|
-
function
|
|
15445
|
+
function $_(e) {
|
|
15423
15446
|
return {
|
|
15424
15447
|
name: "vfs",
|
|
15425
|
-
tools:
|
|
15448
|
+
tools: Q_(e),
|
|
15426
15449
|
beforeAgent: () => ({ files: e.files })
|
|
15427
15450
|
};
|
|
15428
15451
|
}
|
|
15429
15452
|
//#endregion
|
|
15430
15453
|
//#region src/core/tools/dataSlotQuery.ts
|
|
15431
|
-
var
|
|
15432
|
-
function
|
|
15454
|
+
var ev = /[\w$-]/;
|
|
15455
|
+
function tv(e) {
|
|
15433
15456
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15434
15457
|
for (; r < n.length;) {
|
|
15435
15458
|
let e = n[r];
|
|
@@ -15440,7 +15463,7 @@ function ev(e) {
|
|
|
15440
15463
|
continue;
|
|
15441
15464
|
}
|
|
15442
15465
|
let e = "";
|
|
15443
|
-
for (; r < n.length &&
|
|
15466
|
+
for (; r < n.length && ev.test(n[r]);) e += n[r++];
|
|
15444
15467
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15445
15468
|
t.push({
|
|
15446
15469
|
type: "descendKey",
|
|
@@ -15453,7 +15476,7 @@ function ev(e) {
|
|
|
15453
15476
|
continue;
|
|
15454
15477
|
}
|
|
15455
15478
|
let e = "";
|
|
15456
|
-
for (; r < n.length &&
|
|
15479
|
+
for (; r < n.length && ev.test(n[r]);) e += n[r++];
|
|
15457
15480
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15458
15481
|
t.push({
|
|
15459
15482
|
type: "key",
|
|
@@ -15509,7 +15532,7 @@ function ev(e) {
|
|
|
15509
15532
|
}
|
|
15510
15533
|
return t;
|
|
15511
15534
|
}
|
|
15512
|
-
function
|
|
15535
|
+
function nv(e) {
|
|
15513
15536
|
let t = [], n = 0, r = e.trim();
|
|
15514
15537
|
for (; n < r.length;) {
|
|
15515
15538
|
let e = r[n];
|
|
@@ -15554,7 +15577,7 @@ function tv(e) {
|
|
|
15554
15577
|
}
|
|
15555
15578
|
return t;
|
|
15556
15579
|
}
|
|
15557
|
-
var
|
|
15580
|
+
var rv = class {
|
|
15558
15581
|
toks;
|
|
15559
15582
|
item;
|
|
15560
15583
|
pos = 0;
|
|
@@ -15590,12 +15613,12 @@ var nv = class {
|
|
|
15590
15613
|
return this.next(), e;
|
|
15591
15614
|
}
|
|
15592
15615
|
let e = this.operand(), t = this.peek();
|
|
15593
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15616
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), ov(t, e, this.operand())) : iv(e);
|
|
15594
15617
|
}
|
|
15595
15618
|
operand() {
|
|
15596
15619
|
let e = this.next();
|
|
15597
15620
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15598
|
-
if (e.startsWith("@")) return
|
|
15621
|
+
if (e.startsWith("@")) return av(e, this.item);
|
|
15599
15622
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15600
15623
|
if (e === "true") return !0;
|
|
15601
15624
|
if (e === "false") return !1;
|
|
@@ -15605,10 +15628,10 @@ var nv = class {
|
|
|
15605
15628
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15606
15629
|
}
|
|
15607
15630
|
};
|
|
15608
|
-
function
|
|
15631
|
+
function iv(e) {
|
|
15609
15632
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15610
15633
|
}
|
|
15611
|
-
function
|
|
15634
|
+
function av(e, t) {
|
|
15612
15635
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15613
15636
|
for (let e of n) {
|
|
15614
15637
|
if (typeof r != "object" || !r) return;
|
|
@@ -15616,7 +15639,7 @@ function iv(e, t) {
|
|
|
15616
15639
|
}
|
|
15617
15640
|
return r;
|
|
15618
15641
|
}
|
|
15619
|
-
function
|
|
15642
|
+
function ov(e, t, n) {
|
|
15620
15643
|
switch (e) {
|
|
15621
15644
|
case "==": return t === n;
|
|
15622
15645
|
case "!=": return t !== n;
|
|
@@ -15627,47 +15650,47 @@ function av(e, t, n) {
|
|
|
15627
15650
|
default: return !1;
|
|
15628
15651
|
}
|
|
15629
15652
|
}
|
|
15630
|
-
function ov(e, t) {
|
|
15631
|
-
return new nv(tv(e), t).parse();
|
|
15632
|
-
}
|
|
15633
15653
|
function sv(e, t) {
|
|
15634
|
-
return
|
|
15654
|
+
return new rv(nv(e), t).parse();
|
|
15635
15655
|
}
|
|
15636
15656
|
function cv(e, t) {
|
|
15657
|
+
return e ? `${e}.${t}` : String(t);
|
|
15658
|
+
}
|
|
15659
|
+
function lv(e, t) {
|
|
15637
15660
|
let n = [{
|
|
15638
15661
|
path: "",
|
|
15639
15662
|
value: e
|
|
15640
15663
|
}];
|
|
15641
|
-
for (let e of
|
|
15664
|
+
for (let e of tv(t)) {
|
|
15642
15665
|
let t = [];
|
|
15643
15666
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15644
|
-
path:
|
|
15667
|
+
path: cv(r.path, e.key),
|
|
15645
15668
|
value: r.value[e.key]
|
|
15646
15669
|
});
|
|
15647
15670
|
else if (e.type === "index") {
|
|
15648
15671
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15649
15672
|
let n = r.value[e.index];
|
|
15650
15673
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15651
|
-
path:
|
|
15674
|
+
path: cv(r.path, e.index),
|
|
15652
15675
|
value: n,
|
|
15653
15676
|
index: e.index
|
|
15654
15677
|
});
|
|
15655
15678
|
}
|
|
15656
15679
|
} else if (e.type === "wildcard") {
|
|
15657
15680
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15658
|
-
path:
|
|
15681
|
+
path: cv(e.path, r),
|
|
15659
15682
|
value: n,
|
|
15660
15683
|
index: r
|
|
15661
15684
|
}));
|
|
15662
15685
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15663
|
-
path:
|
|
15686
|
+
path: cv(e.path, n),
|
|
15664
15687
|
value: e.value[n]
|
|
15665
15688
|
});
|
|
15666
15689
|
} else if (e.type === "descendKey") {
|
|
15667
15690
|
let r = e.key, i = (e) => {
|
|
15668
15691
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15669
15692
|
let a = {
|
|
15670
|
-
path:
|
|
15693
|
+
path: cv(e.path, n),
|
|
15671
15694
|
value: e.value[n]
|
|
15672
15695
|
};
|
|
15673
15696
|
n === r && t.push(a), i(a);
|
|
@@ -15678,7 +15701,7 @@ function cv(e, t) {
|
|
|
15678
15701
|
let e = (n) => {
|
|
15679
15702
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15680
15703
|
let i = {
|
|
15681
|
-
path:
|
|
15704
|
+
path: cv(n.path, r),
|
|
15682
15705
|
value: n.value[r]
|
|
15683
15706
|
};
|
|
15684
15707
|
t.push(i), e(i);
|
|
@@ -15687,16 +15710,16 @@ function cv(e, t) {
|
|
|
15687
15710
|
for (let t of n) e(t);
|
|
15688
15711
|
} else if (e.type === "filter") {
|
|
15689
15712
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15690
|
-
|
|
15691
|
-
path:
|
|
15713
|
+
sv(e.filter, n) && t.push({
|
|
15714
|
+
path: cv(r.path, i),
|
|
15692
15715
|
value: n,
|
|
15693
15716
|
index: i
|
|
15694
15717
|
});
|
|
15695
15718
|
});
|
|
15696
15719
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15697
15720
|
let i = r.value[n];
|
|
15698
|
-
|
|
15699
|
-
path:
|
|
15721
|
+
sv(e.filter, i) && t.push({
|
|
15722
|
+
path: cv(r.path, n),
|
|
15700
15723
|
value: i
|
|
15701
15724
|
});
|
|
15702
15725
|
}
|
|
@@ -15705,7 +15728,7 @@ function cv(e, t) {
|
|
|
15705
15728
|
}
|
|
15706
15729
|
return n;
|
|
15707
15730
|
}
|
|
15708
|
-
function
|
|
15731
|
+
function uv(e, t) {
|
|
15709
15732
|
let n = e.length, r = t.length;
|
|
15710
15733
|
if (!n) return r;
|
|
15711
15734
|
if (!r) return n;
|
|
@@ -15721,7 +15744,7 @@ function lv(e, t) {
|
|
|
15721
15744
|
}
|
|
15722
15745
|
return i[r];
|
|
15723
15746
|
}
|
|
15724
|
-
function
|
|
15747
|
+
function dv(e, t, n = {}) {
|
|
15725
15748
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15726
15749
|
if (r === "regex") try {
|
|
15727
15750
|
s = new RegExp(t, "i");
|
|
@@ -15731,11 +15754,11 @@ function uv(e, t, n = {}) {
|
|
|
15731
15754
|
let c = (e, l, u) => {
|
|
15732
15755
|
if (o.length >= i || e == null) return;
|
|
15733
15756
|
if (typeof e == "object") {
|
|
15734
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15735
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
15757
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, cv(l, t), String(t)));
|
|
15758
|
+
else for (let t of Object.keys(e)) c(e[t], cv(l, t), t);
|
|
15736
15759
|
return;
|
|
15737
15760
|
}
|
|
15738
|
-
let d = String(e), f =
|
|
15761
|
+
let d = String(e), f = fv(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15739
15762
|
if (f) {
|
|
15740
15763
|
o.push({
|
|
15741
15764
|
path: l,
|
|
@@ -15746,7 +15769,7 @@ function uv(e, t, n = {}) {
|
|
|
15746
15769
|
return;
|
|
15747
15770
|
}
|
|
15748
15771
|
if (a && u) {
|
|
15749
|
-
let e =
|
|
15772
|
+
let e = fv(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15750
15773
|
e && o.push({
|
|
15751
15774
|
path: l,
|
|
15752
15775
|
key: u,
|
|
@@ -15757,18 +15780,18 @@ function uv(e, t, n = {}) {
|
|
|
15757
15780
|
};
|
|
15758
15781
|
return c(e, ""), o;
|
|
15759
15782
|
}
|
|
15760
|
-
function
|
|
15783
|
+
function fv(e, t, n, r, i) {
|
|
15761
15784
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15762
15785
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15763
15786
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15764
15787
|
if (n === "fuzzy") {
|
|
15765
15788
|
if (a.includes(o)) return 2;
|
|
15766
|
-
let e =
|
|
15789
|
+
let e = uv(a, o);
|
|
15767
15790
|
return e <= r ? r - e + 1 : null;
|
|
15768
15791
|
}
|
|
15769
15792
|
return null;
|
|
15770
15793
|
}
|
|
15771
|
-
var
|
|
15794
|
+
var pv = [
|
|
15772
15795
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15773
15796
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15774
15797
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15781,7 +15804,7 @@ var fv = [
|
|
|
15781
15804
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15782
15805
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15783
15806
|
].join("\n");
|
|
15784
|
-
function
|
|
15807
|
+
function mv(e, t, n = 3e3) {
|
|
15785
15808
|
return new Promise((r) => {
|
|
15786
15809
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15787
15810
|
if (!a) {
|
|
@@ -15794,7 +15817,7 @@ function pv(e, t, n = 3e3) {
|
|
|
15794
15817
|
elapsedMs: Date.now() - i
|
|
15795
15818
|
});
|
|
15796
15819
|
}
|
|
15797
|
-
}, s =
|
|
15820
|
+
}, s = pv + "\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;
|
|
15798
15821
|
try {
|
|
15799
15822
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15800
15823
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15829,20 +15852,20 @@ function pv(e, t, n = 3e3) {
|
|
|
15829
15852
|
}
|
|
15830
15853
|
//#endregion
|
|
15831
15854
|
//#region src/core/tools/dataOps.ts
|
|
15832
|
-
var
|
|
15855
|
+
var hv = /* @__PURE__ */ new Set([
|
|
15833
15856
|
"__proto__",
|
|
15834
15857
|
"constructor",
|
|
15835
15858
|
"prototype"
|
|
15836
15859
|
]);
|
|
15837
|
-
function
|
|
15838
|
-
return e.split(".").some((e) =>
|
|
15839
|
-
}
|
|
15840
|
-
function gv(e, t) {
|
|
15841
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) mv.has(n) || (e[n] = t[n]);
|
|
15860
|
+
function gv(e) {
|
|
15861
|
+
return e.split(".").some((e) => hv.has(e));
|
|
15842
15862
|
}
|
|
15843
15863
|
function _v(e, t) {
|
|
15864
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) hv.has(n) || (e[n] = t[n]);
|
|
15865
|
+
}
|
|
15866
|
+
function vv(e, t) {
|
|
15844
15867
|
if (!t) return e;
|
|
15845
|
-
if (
|
|
15868
|
+
if (gv(t)) return;
|
|
15846
15869
|
let n = t.split("."), r = e;
|
|
15847
15870
|
for (let e of n) {
|
|
15848
15871
|
if (r == null) return;
|
|
@@ -15850,8 +15873,8 @@ function _v(e, t) {
|
|
|
15850
15873
|
}
|
|
15851
15874
|
return r;
|
|
15852
15875
|
}
|
|
15853
|
-
function
|
|
15854
|
-
if (!t ||
|
|
15876
|
+
function yv(e, t, n) {
|
|
15877
|
+
if (!t || gv(t)) return;
|
|
15855
15878
|
let r = t.split("."), i = e;
|
|
15856
15879
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15857
15880
|
let t = r[e];
|
|
@@ -15859,8 +15882,8 @@ function vv(e, t, n) {
|
|
|
15859
15882
|
}
|
|
15860
15883
|
i[r[r.length - 1]] = n;
|
|
15861
15884
|
}
|
|
15862
|
-
function
|
|
15863
|
-
if (!t ||
|
|
15885
|
+
function bv(e, t) {
|
|
15886
|
+
if (!t || gv(t)) return !1;
|
|
15864
15887
|
let n = t.split("."), r = e;
|
|
15865
15888
|
for (let e = 0; e < n.length - 1; e++) {
|
|
15866
15889
|
if (r == null) return !1;
|
|
@@ -15869,10 +15892,10 @@ function yv(e, t) {
|
|
|
15869
15892
|
let i = n[n.length - 1];
|
|
15870
15893
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
15871
15894
|
}
|
|
15872
|
-
function
|
|
15895
|
+
function xv(e) {
|
|
15873
15896
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
15874
15897
|
}
|
|
15875
|
-
function
|
|
15898
|
+
function Sv(e) {
|
|
15876
15899
|
if (typeof e != "string") return { parsed: e };
|
|
15877
15900
|
let t = e.trim();
|
|
15878
15901
|
if (!t) return { parsed: e };
|
|
@@ -15883,23 +15906,23 @@ function xv(e) {
|
|
|
15883
15906
|
return n ? { parseError: t } : { parsed: e };
|
|
15884
15907
|
}
|
|
15885
15908
|
}
|
|
15886
|
-
function
|
|
15909
|
+
function Cv(e, t) {
|
|
15887
15910
|
if (typeof e != "object" || !e) return e;
|
|
15888
15911
|
let n = new Set(t);
|
|
15889
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
15912
|
+
if (Array.isArray(e)) return e.map((e) => Cv(e, t));
|
|
15890
15913
|
let r = {};
|
|
15891
15914
|
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
15892
15915
|
return r;
|
|
15893
15916
|
}
|
|
15894
|
-
function
|
|
15917
|
+
function wv(e, t) {
|
|
15895
15918
|
if (typeof e != "object" || !e) return e;
|
|
15896
15919
|
if (t <= 0) return Array.isArray(e) ? `[...${e.length}]` : "{...}";
|
|
15897
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
15920
|
+
if (Array.isArray(e)) return e.map((e) => wv(e, t - 1));
|
|
15898
15921
|
let n = {};
|
|
15899
|
-
for (let r of Object.keys(e)) n[r] =
|
|
15922
|
+
for (let r of Object.keys(e)) n[r] = wv(e[r], t - 1);
|
|
15900
15923
|
return n;
|
|
15901
15924
|
}
|
|
15902
|
-
function
|
|
15925
|
+
function Tv(e, t = Infinity) {
|
|
15903
15926
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
15904
15927
|
try {
|
|
15905
15928
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -15918,12 +15941,12 @@ function wv(e, t = Infinity) {
|
|
|
15918
15941
|
}
|
|
15919
15942
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
15920
15943
|
}
|
|
15921
|
-
function
|
|
15922
|
-
let t =
|
|
15944
|
+
function Ev(e) {
|
|
15945
|
+
let t = Tv(e), n = 5381;
|
|
15923
15946
|
for (let e = 0; e < t.length; e++) n = (n << 5) + n + t.charCodeAt(e) >>> 0;
|
|
15924
15947
|
return n.toString(36);
|
|
15925
15948
|
}
|
|
15926
|
-
function
|
|
15949
|
+
function Dv(e) {
|
|
15927
15950
|
let t = e;
|
|
15928
15951
|
for (let e = 0; e < 5 && t && t._def; e++) {
|
|
15929
15952
|
if (t._def.innerType) {
|
|
@@ -15940,40 +15963,40 @@ function Ev(e) {
|
|
|
15940
15963
|
return null;
|
|
15941
15964
|
}
|
|
15942
15965
|
}
|
|
15943
|
-
function
|
|
15966
|
+
function Ov(e, t) {
|
|
15944
15967
|
if (!t || !e) return !0;
|
|
15945
15968
|
let n = e.split(".")[0];
|
|
15946
15969
|
return t.includes(n);
|
|
15947
15970
|
}
|
|
15948
|
-
function
|
|
15971
|
+
function kv(e, t) {
|
|
15949
15972
|
if (!t || typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
15950
15973
|
let n = new Set(t), r = {};
|
|
15951
15974
|
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
15952
15975
|
return r;
|
|
15953
15976
|
}
|
|
15954
|
-
function
|
|
15955
|
-
if (t === "set") return n ? (
|
|
15956
|
-
if (t === "remove") return n ? (
|
|
15977
|
+
function Av(e, t, n, r) {
|
|
15978
|
+
if (t === "set") return n ? (yv(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_data)";
|
|
15979
|
+
if (t === "remove") return n ? (bv(e, n), null) : "remove 操作需要 jsonPath";
|
|
15957
15980
|
if (t === "merge") {
|
|
15958
|
-
let t = n ?
|
|
15959
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
15981
|
+
let t = n ? vv(e, n) : e;
|
|
15982
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (_v(t, r), null);
|
|
15960
15983
|
}
|
|
15961
|
-
let i = n ?
|
|
15984
|
+
let i = n ? vv(e, n) : e;
|
|
15962
15985
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
15963
15986
|
}
|
|
15964
|
-
function
|
|
15965
|
-
if (t === "set")
|
|
15966
|
-
else if (t === "remove")
|
|
15967
|
-
else if (t === "merge")
|
|
15987
|
+
function jv(e, t, n, r) {
|
|
15988
|
+
if (t === "set") yv(e, n, r);
|
|
15989
|
+
else if (t === "remove") bv(e, n);
|
|
15990
|
+
else if (t === "merge") _v(n ? vv(e, n) : e, r);
|
|
15968
15991
|
else {
|
|
15969
|
-
let t = n ?
|
|
15992
|
+
let t = n ? vv(e, n) : e;
|
|
15970
15993
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
15971
15994
|
}
|
|
15972
15995
|
}
|
|
15973
|
-
function jv(e, t) {
|
|
15974
|
-
typeof e == "object" && e && Mv(e, t);
|
|
15975
|
-
}
|
|
15976
15996
|
function Mv(e, t) {
|
|
15997
|
+
typeof e == "object" && e && Nv(e, t);
|
|
15998
|
+
}
|
|
15999
|
+
function Nv(e, t) {
|
|
15977
16000
|
if (Array.isArray(e)) {
|
|
15978
16001
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
15979
16002
|
return;
|
|
@@ -15982,25 +16005,25 @@ function Mv(e, t) {
|
|
|
15982
16005
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
15983
16006
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
15984
16007
|
}
|
|
15985
|
-
var
|
|
16008
|
+
var Pv = /* @__PURE__ */ new Set([
|
|
15986
16009
|
"describe_data",
|
|
15987
16010
|
"get_data",
|
|
15988
16011
|
"set_data",
|
|
15989
16012
|
"edit_data",
|
|
15990
16013
|
"delete_data"
|
|
15991
|
-
]),
|
|
15992
|
-
function
|
|
15993
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
16014
|
+
]), Fv = /* @__PURE__ */ new Set(["read", "write"]);
|
|
16015
|
+
function Iv(e, t = "simple") {
|
|
16016
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => Fv.has(e.name)) : e.filter((e) => !Pv.has(e.name));
|
|
15994
16017
|
}
|
|
15995
|
-
function
|
|
15996
|
-
let i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s =
|
|
16018
|
+
function Lv(e, r = {}) {
|
|
16019
|
+
let i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = Dv(i), c = [], l = r.maxSnapshots ?? 20, u, d = r.autoLock !== !1, f = {
|
|
15997
16020
|
get: () => ({
|
|
15998
16021
|
schema: i,
|
|
15999
16022
|
bind: a,
|
|
16000
16023
|
description: o
|
|
16001
16024
|
}),
|
|
16002
16025
|
set: (e) => {
|
|
16003
|
-
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s =
|
|
16026
|
+
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = Dv(i), c.length = 0, u = void 0;
|
|
16004
16027
|
},
|
|
16005
16028
|
update: (e) => {
|
|
16006
16029
|
a = e, c.length = 0, u = void 0;
|
|
@@ -16009,7 +16032,7 @@ function Iv(e, r = {}) {
|
|
|
16009
16032
|
r.onAudit?.(e);
|
|
16010
16033
|
};
|
|
16011
16034
|
function m(e, t) {
|
|
16012
|
-
let n =
|
|
16035
|
+
let n = xv(a), r = c.length ? c[c.length - 1].id + 1 : 1;
|
|
16013
16036
|
for (c.push({
|
|
16014
16037
|
id: r,
|
|
16015
16038
|
ts: Date.now(),
|
|
@@ -16021,12 +16044,12 @@ function Iv(e, r = {}) {
|
|
|
16021
16044
|
}
|
|
16022
16045
|
async function h(e, t, n) {
|
|
16023
16046
|
if (!t || t === "") return null;
|
|
16024
|
-
let i =
|
|
16047
|
+
let i = Ev(a);
|
|
16025
16048
|
if (i === t) return null;
|
|
16026
16049
|
if (!r.onConflict) return $({
|
|
16027
16050
|
code: "VERSION_CONFLICT",
|
|
16028
16051
|
message: `乐观锁冲突:expectedHash=${t} 但当前 hash=${i}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,
|
|
16029
|
-
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${
|
|
16052
|
+
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${Tv(a, 400)}`
|
|
16030
16053
|
});
|
|
16031
16054
|
let o = await r.onConflict({
|
|
16032
16055
|
op: e,
|
|
@@ -16036,11 +16059,11 @@ function Iv(e, r = {}) {
|
|
|
16036
16059
|
expectedHash: t,
|
|
16037
16060
|
snapshotId: 0
|
|
16038
16061
|
});
|
|
16039
|
-
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${
|
|
16062
|
+
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${Tv(a, 400)} (hash=${i})。请重新 read 拿最新值与 hash 再改。`;
|
|
16040
16063
|
if (o.action === "restore") {
|
|
16041
|
-
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${
|
|
16064
|
+
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${Tv(a, 400)} (hash=${i})。请重新 read 再改或选「强制覆盖」。`;
|
|
16042
16065
|
let e = c[c.length - 1];
|
|
16043
|
-
return
|
|
16066
|
+
return Mv(a, xv(e.value)), `已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${Tv(a, 400)} (hash=${Ev(a)})。请基于回退后的值重写或停止。`;
|
|
16044
16067
|
}
|
|
16045
16068
|
return null;
|
|
16046
16069
|
}
|
|
@@ -16052,15 +16075,15 @@ function Iv(e, r = {}) {
|
|
|
16052
16075
|
}),
|
|
16053
16076
|
n(async ({ jsonPath: e }) => {
|
|
16054
16077
|
let t = e || "";
|
|
16055
|
-
if (!
|
|
16078
|
+
if (!Ov(t, s)) return $({
|
|
16056
16079
|
code: "PATH_DENIED",
|
|
16057
16080
|
message: `get_data @ "${t}" 不在 schema 声明字段内(仅 schema 声明的 key 可读)`,
|
|
16058
16081
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
16059
16082
|
});
|
|
16060
|
-
let n = t ?
|
|
16061
|
-
t || (n =
|
|
16062
|
-
let r =
|
|
16063
|
-
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${
|
|
16083
|
+
let n = t ? vv(a, t) : a;
|
|
16084
|
+
t || (n = kv(n, s));
|
|
16085
|
+
let r = Ev(a);
|
|
16086
|
+
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${Tv(n)} (hash=${r})`;
|
|
16064
16087
|
}, {
|
|
16065
16088
|
name: "get_data",
|
|
16066
16089
|
description: "读取主数据的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改前先 read/get 拿 hash,写入时传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"。jsonPath 可选:读整个主数据不传,读子路径传(如 components.0.text)。",
|
|
@@ -16069,19 +16092,19 @@ function Iv(e, r = {}) {
|
|
|
16069
16092
|
n(async ({ value: e, expectedHash: t }) => {
|
|
16070
16093
|
let n = await h("set", t || (d ? u : void 0));
|
|
16071
16094
|
if (n !== null) return n;
|
|
16072
|
-
let r, o =
|
|
16073
|
-
if (o.parseError) return
|
|
16095
|
+
let r, o = Sv(e);
|
|
16096
|
+
if (o.parseError) return W_("", e, o.parseError);
|
|
16074
16097
|
r = o.parsed;
|
|
16075
16098
|
let c = i.safeParse(r);
|
|
16076
16099
|
return c.success ? typeof a != "object" || !a ? $({
|
|
16077
16100
|
code: "LEAF_BIND",
|
|
16078
16101
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),set_data 无法就地替换外部持有的值引用`,
|
|
16079
16102
|
hint: "主数据 bind 必须为对象/数组(低代码主 JSON 本就是);叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
16080
|
-
}) : (m("set"), c.data !== null && typeof c.data == "object" && (s ?
|
|
16103
|
+
}) : (m("set"), c.data !== null && typeof c.data == "object" && (s ? _v(a, c.data) : Nv(a, c.data)), p({
|
|
16081
16104
|
op: "set",
|
|
16082
16105
|
value: c.data,
|
|
16083
16106
|
timestamp: Date.now()
|
|
16084
|
-
}), u =
|
|
16107
|
+
}), u = Ev(a), `已设置主数据 = ${Tv(c.data, 600)} (新 hash=${Ev(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`) : U_("", c.error.issues);
|
|
16085
16108
|
}, {
|
|
16086
16109
|
name: "set_data",
|
|
16087
16110
|
description: "设置主数据的值(整体替换)。value 为 JSON 对象(或 JSON 字符串),需通过 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 read/get 返回的 hash,传入则启用乐观锁;不传时系统自动用你最后一次读到的 hash 比对(autoLock,默认开)。大对象/数组强烈建议改用 edit_data 增量 patch。",
|
|
@@ -16092,12 +16115,12 @@ function Iv(e, r = {}) {
|
|
|
16092
16115
|
}),
|
|
16093
16116
|
n(async ({ op: e, jsonPath: t, value: n, expectedHash: r }) => {
|
|
16094
16117
|
let o = t || "";
|
|
16095
|
-
if (
|
|
16118
|
+
if (gv(o)) return $({
|
|
16096
16119
|
code: "PATH_UNSAFE",
|
|
16097
16120
|
message: `jsonPath "${o}" 含非法段(__proto__/constructor/prototype)`,
|
|
16098
16121
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
16099
16122
|
});
|
|
16100
|
-
if (!
|
|
16123
|
+
if (!Ov(o, s)) return $({
|
|
16101
16124
|
code: "PATH_DENIED",
|
|
16102
16125
|
message: `edit_data @ "${o}" 不在 schema 声明字段内`,
|
|
16103
16126
|
hint: "仅 schema 声明的 key 可写;若需操作该字段,集成方需在 schema 中声明它"
|
|
@@ -16116,23 +16139,23 @@ function Iv(e, r = {}) {
|
|
|
16116
16139
|
message: `${e} 操作需要 value`,
|
|
16117
16140
|
hint: `op 为 ${e} 时 value 必填;删除请用 op:'remove'`
|
|
16118
16141
|
});
|
|
16119
|
-
let t =
|
|
16120
|
-
if (t.parseError) return
|
|
16142
|
+
let t = Sv(n);
|
|
16143
|
+
if (t.parseError) return W_("", n, t.parseError);
|
|
16121
16144
|
l = t.parsed;
|
|
16122
16145
|
}
|
|
16123
|
-
let f =
|
|
16146
|
+
let f = xv(a), g = Av(f, e, o, l);
|
|
16124
16147
|
if (g) return $({
|
|
16125
16148
|
code: "PATCH_FAILED",
|
|
16126
16149
|
message: g,
|
|
16127
16150
|
hint: "检查 op 与目标类型:merge 需对象,append 需数组;jsonPath 指向需存在"
|
|
16128
16151
|
});
|
|
16129
16152
|
let _ = i.safeParse(f);
|
|
16130
|
-
return _.success ? (m("edit"),
|
|
16153
|
+
return _.success ? (m("edit"), jv(a, e, o, l), p({
|
|
16131
16154
|
op: "edit",
|
|
16132
16155
|
detail: `${e}${o ? "@" + o : ""}`,
|
|
16133
16156
|
value: l,
|
|
16134
16157
|
timestamp: Date.now()
|
|
16135
|
-
}), u =
|
|
16158
|
+
}), u = Ev(a), `已 edit 主数据(${e}${o ? " @ " + o : ""})。当前值:${Tv(a, 600)} (新 hash=${Ev(a)})`) : U_("", _.error.issues);
|
|
16136
16159
|
}, {
|
|
16137
16160
|
name: "edit_data",
|
|
16138
16161
|
description: "增量编辑主数据(对象/数组),只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对主数据根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 对象(推荐直传)或 JSON 字符串。整体仍经 schema 校验,失败不写入。expectedHash(可选):改前 read/get 返回的 hash;不传时自动用你最后读到的 hash(autoLock,默认开)防\"基于过期值覆盖\"。",
|
|
@@ -16154,12 +16177,12 @@ function Iv(e, r = {}) {
|
|
|
16154
16177
|
message: "delete_data 需要 jsonPath 指定要删的子路径(主数据整体不可删,用 set_data 整体替换)",
|
|
16155
16178
|
hint: "如 jsonPath:\"components.0\" 删数组首项"
|
|
16156
16179
|
});
|
|
16157
|
-
if (
|
|
16180
|
+
if (gv(e)) return $({
|
|
16158
16181
|
code: "PATH_UNSAFE",
|
|
16159
16182
|
message: `jsonPath "${e}" 含非法段`,
|
|
16160
16183
|
hint: "使用正常属性路径"
|
|
16161
16184
|
});
|
|
16162
|
-
if (!
|
|
16185
|
+
if (!Ov(e, s)) return $({
|
|
16163
16186
|
code: "PATH_DENIED",
|
|
16164
16187
|
message: `delete_data @ "${e}" 不在 schema 声明字段内`,
|
|
16165
16188
|
hint: "仅 schema 声明的 key 可删"
|
|
@@ -16167,12 +16190,12 @@ function Iv(e, r = {}) {
|
|
|
16167
16190
|
let n = await h("delete", t || (d ? u : void 0));
|
|
16168
16191
|
if (n !== null) return n;
|
|
16169
16192
|
m("delete");
|
|
16170
|
-
let r =
|
|
16193
|
+
let r = bv(a, e);
|
|
16171
16194
|
return p({
|
|
16172
16195
|
op: "delete",
|
|
16173
16196
|
detail: e,
|
|
16174
16197
|
timestamp: Date.now()
|
|
16175
|
-
}), u =
|
|
16198
|
+
}), u = Ev(a), r ? `已删除主数据 @ ${e}` : `主数据 @ ${e} 不存在(无需删除)`;
|
|
16176
16199
|
}, {
|
|
16177
16200
|
name: "delete_data",
|
|
16178
16201
|
description: "删除主数据的某个子路径(jsonPath)。主数据整体不可删(用 set_data 整体替换)。expectedHash(可选):改前 read/get 返回的 hash;不传时自动用你最后读到的 hash(autoLock,默认开)防\"基于过期值删除\"。",
|
|
@@ -16211,15 +16234,15 @@ function Iv(e, r = {}) {
|
|
|
16211
16234
|
hint: "用 list_data_snapshots 查看可用快照序号"
|
|
16212
16235
|
});
|
|
16213
16236
|
let n = i.safeParse(t.value);
|
|
16214
|
-
return n.success ? (
|
|
16237
|
+
return n.success ? (Mv(a, xv(t.value)), p({
|
|
16215
16238
|
op: "restore",
|
|
16216
16239
|
detail: `#${t.id}`,
|
|
16217
16240
|
timestamp: Date.now()
|
|
16218
|
-
}), u =
|
|
16241
|
+
}), u = Ev(a), `已回退主数据到快照 #${t.id}[${t.op}]${t.label ? `(${t.label})` : ""}。`) : $({
|
|
16219
16242
|
code: "SNAPSHOT_SCHEMA_INVALID",
|
|
16220
16243
|
message: `快照 #${t.id} 的值不符合当前 schema,无法回退`,
|
|
16221
16244
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16222
|
-
details:
|
|
16245
|
+
details: H_(n.error.issues)
|
|
16223
16246
|
});
|
|
16224
16247
|
}, {
|
|
16225
16248
|
name: "restore_data",
|
|
@@ -16232,9 +16255,9 @@ function Iv(e, r = {}) {
|
|
|
16232
16255
|
message: `主数据不是对象/数组,无法查询(当前为 ${a === void 0 ? "undefined" : typeof a})`,
|
|
16233
16256
|
hint: "query 仅适用于对象/数组;叶子用 get_data 读"
|
|
16234
16257
|
});
|
|
16235
|
-
let n = s ?
|
|
16258
|
+
let n = s ? kv(a, s) : a, r;
|
|
16236
16259
|
try {
|
|
16237
|
-
r =
|
|
16260
|
+
r = lv(n, e);
|
|
16238
16261
|
} catch (t) {
|
|
16239
16262
|
return $({
|
|
16240
16263
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16243,7 +16266,7 @@ function Iv(e, r = {}) {
|
|
|
16243
16266
|
details: { expr: e }
|
|
16244
16267
|
});
|
|
16245
16268
|
}
|
|
16246
|
-
let i = t ?? 50, o = r.slice(0, i), c = o.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${
|
|
16269
|
+
let i = t ?? 50, o = r.slice(0, i), c = o.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${Tv(e.value)}}`);
|
|
16247
16270
|
return `{"matched":${r.length},"returned":${o.length},"truncated":${r.length > i},"results":[${c.join(",")}]}`;
|
|
16248
16271
|
}, {
|
|
16249
16272
|
name: "query_data",
|
|
@@ -16259,13 +16282,13 @@ function Iv(e, r = {}) {
|
|
|
16259
16282
|
message: "主数据为空,无可搜索内容"
|
|
16260
16283
|
});
|
|
16261
16284
|
try {
|
|
16262
|
-
let o =
|
|
16285
|
+
let o = dv(s ? kv(a, s) : a, e, {
|
|
16263
16286
|
mode: t,
|
|
16264
16287
|
fuzzyThreshold: n,
|
|
16265
16288
|
matchKey: r,
|
|
16266
16289
|
limit: i ?? 50
|
|
16267
16290
|
});
|
|
16268
|
-
return
|
|
16291
|
+
return Tv({
|
|
16269
16292
|
matched: o.length,
|
|
16270
16293
|
results: o
|
|
16271
16294
|
});
|
|
@@ -16298,7 +16321,7 @@ function Iv(e, r = {}) {
|
|
|
16298
16321
|
message: `脚本过长(${e.length} 字符,上限 8000)`,
|
|
16299
16322
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16300
16323
|
});
|
|
16301
|
-
let n = await
|
|
16324
|
+
let n = await mv(xv(s ? kv(a, s) : a), e, 3e3);
|
|
16302
16325
|
if (!n.ok) {
|
|
16303
16326
|
let t = /超时/.test(n.error || "");
|
|
16304
16327
|
return $({
|
|
@@ -16319,15 +16342,15 @@ function Iv(e, r = {}) {
|
|
|
16319
16342
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform(patches) 无法就地替换`,
|
|
16320
16343
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
16321
16344
|
});
|
|
16322
|
-
let t = e.patches, r =
|
|
16345
|
+
let t = e.patches, r = xv(a), o = [];
|
|
16323
16346
|
for (let e = 0; e < t.length; e++) {
|
|
16324
16347
|
let n = t[e], i = n.jsonPath || "";
|
|
16325
|
-
if (
|
|
16348
|
+
if (gv(i)) return $({
|
|
16326
16349
|
code: "PATH_UNSAFE",
|
|
16327
16350
|
message: `patches[${e}] jsonPath "${i}" 含非法段`,
|
|
16328
16351
|
hint: "使用正常属性路径"
|
|
16329
16352
|
});
|
|
16330
|
-
if (!
|
|
16353
|
+
if (!Ov(i, s)) return $({
|
|
16331
16354
|
code: "PATH_DENIED",
|
|
16332
16355
|
message: `patches[${e}] @ "${i}" 不在 schema 声明字段内`,
|
|
16333
16356
|
hint: "仅 schema 声明的 key 可写"
|
|
@@ -16339,11 +16362,11 @@ function Iv(e, r = {}) {
|
|
|
16339
16362
|
message: `patches[${e}] ${a} 操作需要 value`,
|
|
16340
16363
|
hint: `op 为 ${a} 时 value 必填`
|
|
16341
16364
|
});
|
|
16342
|
-
let t =
|
|
16343
|
-
if (t.parseError) return
|
|
16365
|
+
let t = Sv(n.value);
|
|
16366
|
+
if (t.parseError) return W_(`patches[${e}]`, n.value, t.parseError);
|
|
16344
16367
|
c = t.parsed;
|
|
16345
16368
|
}
|
|
16346
|
-
let l =
|
|
16369
|
+
let l = Av(r, a, i, c);
|
|
16347
16370
|
if (l) return $({
|
|
16348
16371
|
code: "PATCH_FAILED",
|
|
16349
16372
|
message: `patches[${e}]: ${l}`,
|
|
@@ -16360,33 +16383,33 @@ function Iv(e, r = {}) {
|
|
|
16360
16383
|
code: "SCHEMA_INVALID",
|
|
16361
16384
|
message: "脚本 patches 应用后整体校验失败,未写入",
|
|
16362
16385
|
hint: "确认 patches 合并后整体仍符合 schema",
|
|
16363
|
-
details:
|
|
16386
|
+
details: H_(c.error.issues)
|
|
16364
16387
|
});
|
|
16365
16388
|
m("edit", "eval_transform");
|
|
16366
|
-
for (let e of o)
|
|
16389
|
+
for (let e of o) jv(a, e.op, e.jp, e.value);
|
|
16367
16390
|
return p({
|
|
16368
16391
|
op: "edit",
|
|
16369
16392
|
detail: `eval_transform(${o.length} patches)`,
|
|
16370
16393
|
timestamp: Date.now()
|
|
16371
|
-
}), u =
|
|
16394
|
+
}), u = Ev(a), `已通过脚本 transform(patches) 更新主数据(${o.length} 个 patch,耗时 ${n.elapsedMs}ms)。当前值: ${Tv(a, 600)}`;
|
|
16372
16395
|
}
|
|
16373
16396
|
let t = i.safeParse(e);
|
|
16374
16397
|
return t.success ? typeof a != "object" || !a ? $({
|
|
16375
16398
|
code: "LEAF_BIND",
|
|
16376
16399
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform 无法就地替换外部持有的值引用`,
|
|
16377
16400
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
16378
|
-
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ?
|
|
16401
|
+
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ? _v(a, t.data) : Nv(a, t.data)), p({
|
|
16379
16402
|
op: "edit",
|
|
16380
16403
|
detail: "eval_transform",
|
|
16381
16404
|
timestamp: Date.now()
|
|
16382
|
-
}), u =
|
|
16405
|
+
}), u = Ev(a), `已通过脚本 transform 更新主数据(耗时 ${n.elapsedMs}ms)。当前值: ${Tv(a, 600)}`) : $({
|
|
16383
16406
|
code: "SCHEMA_INVALID",
|
|
16384
16407
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回主数据的完整新值且符合 schema)",
|
|
16385
16408
|
hint: "确认脚本 return 了完整新值(非部分);或返回 {patches:[...]} 走增量模式;按 describe_data() 查看格式",
|
|
16386
|
-
details:
|
|
16409
|
+
details: H_(t.error.issues)
|
|
16387
16410
|
});
|
|
16388
16411
|
}
|
|
16389
|
-
return
|
|
16412
|
+
return Tv({
|
|
16390
16413
|
ok: !0,
|
|
16391
16414
|
result: n.result,
|
|
16392
16415
|
elapsedMs: n.elapsedMs
|
|
@@ -16401,13 +16424,13 @@ function Iv(e, r = {}) {
|
|
|
16401
16424
|
}),
|
|
16402
16425
|
n(async ({ jsonPath: e, fields: t, depth: n }) => {
|
|
16403
16426
|
let i = e || "";
|
|
16404
|
-
if (!
|
|
16427
|
+
if (!Ov(i, s)) return $({
|
|
16405
16428
|
code: "PATH_DENIED",
|
|
16406
16429
|
message: `read @ "${i}" 不在 schema 声明字段内`,
|
|
16407
16430
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
16408
16431
|
});
|
|
16409
|
-
let c = i ?
|
|
16410
|
-
i || (c =
|
|
16432
|
+
let c = i ? vv(a, i) : a;
|
|
16433
|
+
i || (c = kv(c, s));
|
|
16411
16434
|
let l = c;
|
|
16412
16435
|
if (r.interceptors?.read) try {
|
|
16413
16436
|
l = r.interceptors.read(l);
|
|
@@ -16417,11 +16440,11 @@ function Iv(e, r = {}) {
|
|
|
16417
16440
|
message: `read 拦截器抛错: ${e.message}`
|
|
16418
16441
|
});
|
|
16419
16442
|
}
|
|
16420
|
-
t && t.length && (l =
|
|
16421
|
-
let d =
|
|
16443
|
+
t && t.length && (l = Cv(l, t)), n != null && (l = wv(l, n));
|
|
16444
|
+
let d = Ev(a);
|
|
16422
16445
|
u = d;
|
|
16423
16446
|
let f = t && t.length ? `(字段裁剪:${t.join(",")})` : "", p = n == null ? "" : `(深度≤${n})`, m = f || p ? ` ${f}${p}` : "", h = e ? "" : `主数据说明: ${o}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。\n\n`;
|
|
16424
|
-
return l === void 0 ? `${h}主数据${e ? ` @ ${e}` : ""}${m} = (undefined) (hash=${d})` : `${h}主数据${e ? ` @ ${e}` : ""}${m} = ${
|
|
16447
|
+
return l === void 0 ? `${h}主数据${e ? ` @ ${e}` : ""}${m} = (undefined) (hash=${d})` : `${h}主数据${e ? ` @ ${e}` : ""}${m} = ${Tv(l)} (hash=${d})`;
|
|
16425
16448
|
}, {
|
|
16426
16449
|
name: "read",
|
|
16427
16450
|
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示;传 jsonPath → 返回该子路径当前值 + hash。hash 用于乐观锁(默认 autoLock,write 时自动比对,无需手动传)。fields(可选):字段裁剪,只返回对象(及数组元素)的指定字段,减少大对象返回体积;depth(可选):嵌套深度限制(0=只根占位,1=根+子,递归截断深层),减少深层结构返回体积。两者可组合,先裁字段再截深度。集成方可能经 read 拦截器对返回值脱敏/派生。",
|
|
@@ -16462,12 +16485,12 @@ function Iv(e, r = {}) {
|
|
|
16462
16485
|
message: "delete 需要 patch.jsonPath 指定要删的子路径(主数据整体不可删,用 write(value) 整体替换)",
|
|
16463
16486
|
hint: "如 patch:{jsonPath:\"components.0\"}, del:true"
|
|
16464
16487
|
});
|
|
16465
|
-
if (
|
|
16488
|
+
if (gv(t.jsonPath)) return $({
|
|
16466
16489
|
code: "PATH_UNSAFE",
|
|
16467
16490
|
message: `jsonPath "${t.jsonPath}" 含非法段`,
|
|
16468
16491
|
hint: "使用正常属性路径"
|
|
16469
16492
|
});
|
|
16470
|
-
if (!
|
|
16493
|
+
if (!Ov(t.jsonPath, s)) return $({
|
|
16471
16494
|
code: "PATH_DENIED",
|
|
16472
16495
|
message: `write delete @ "${t.jsonPath}" 不在 schema 声明字段内`,
|
|
16473
16496
|
hint: "仅 schema 声明的 key 可删"
|
|
@@ -16475,12 +16498,12 @@ function Iv(e, r = {}) {
|
|
|
16475
16498
|
let e = await h("delete", g);
|
|
16476
16499
|
if (e !== null) return e;
|
|
16477
16500
|
m("delete");
|
|
16478
|
-
let n =
|
|
16501
|
+
let n = bv(a, t.jsonPath);
|
|
16479
16502
|
return p({
|
|
16480
16503
|
op: "delete",
|
|
16481
16504
|
detail: t.jsonPath,
|
|
16482
16505
|
timestamp: Date.now()
|
|
16483
|
-
}), u =
|
|
16506
|
+
}), u = Ev(a), n ? `已删除主数据 @ ${t.jsonPath}` : `主数据 @ ${t.jsonPath} 不存在(无需删除)`;
|
|
16484
16507
|
}
|
|
16485
16508
|
if (c === "edit") {
|
|
16486
16509
|
if (typeof a != "object" || !a) return $({
|
|
@@ -16494,15 +16517,15 @@ function Iv(e, r = {}) {
|
|
|
16494
16517
|
op: t.op,
|
|
16495
16518
|
jsonPath: t.jsonPath || "",
|
|
16496
16519
|
value: l
|
|
16497
|
-
}]), o =
|
|
16520
|
+
}]), o = xv(a), c = [];
|
|
16498
16521
|
for (let e = 0; e < r.length; e++) {
|
|
16499
16522
|
let t = r[e], n = t.jsonPath || "";
|
|
16500
|
-
if (
|
|
16523
|
+
if (gv(n)) return $({
|
|
16501
16524
|
code: "PATH_UNSAFE",
|
|
16502
16525
|
message: `patches[${e}] jsonPath "${n}" 含非法段`,
|
|
16503
16526
|
hint: "使用正常属性路径,如 components.0.text"
|
|
16504
16527
|
});
|
|
16505
|
-
if (!
|
|
16528
|
+
if (!Ov(n, s)) return $({
|
|
16506
16529
|
code: "PATH_DENIED",
|
|
16507
16530
|
message: `patches[${e}] @ "${n}" 不在 schema 声明字段内`,
|
|
16508
16531
|
hint: "仅 schema 声明的 key 可写"
|
|
@@ -16514,11 +16537,11 @@ function Iv(e, r = {}) {
|
|
|
16514
16537
|
message: `patches[${e}] ${i} 操作需要 value`,
|
|
16515
16538
|
hint: `op 为 ${i} 时 value 必填;删除请用 op:'remove'`
|
|
16516
16539
|
});
|
|
16517
|
-
let n =
|
|
16518
|
-
if (n.parseError) return
|
|
16540
|
+
let n = Sv(t.value);
|
|
16541
|
+
if (n.parseError) return W_(`patches[${e}]`, t.value, n.parseError);
|
|
16519
16542
|
a = n.parsed;
|
|
16520
16543
|
}
|
|
16521
|
-
let l =
|
|
16544
|
+
let l = Av(o, i, n, a);
|
|
16522
16545
|
if (l) return $({
|
|
16523
16546
|
code: "PATCH_FAILED",
|
|
16524
16547
|
message: `patches[${e}]: ${l}`,
|
|
@@ -16531,18 +16554,18 @@ function Iv(e, r = {}) {
|
|
|
16531
16554
|
});
|
|
16532
16555
|
}
|
|
16533
16556
|
let d = i.safeParse(o);
|
|
16534
|
-
if (!d.success) return
|
|
16557
|
+
if (!d.success) return U_("", d.error.issues);
|
|
16535
16558
|
m("edit");
|
|
16536
|
-
for (let e of c)
|
|
16559
|
+
for (let e of c) jv(a, e.op, e.jp, e.value);
|
|
16537
16560
|
return p({
|
|
16538
16561
|
op: "edit",
|
|
16539
16562
|
detail: `${c.length} 个 patch${c.length > 1 ? "(批量)" : ""}`,
|
|
16540
16563
|
value: c.map((e) => `${e.op}@${e.jp}`),
|
|
16541
16564
|
timestamp: Date.now()
|
|
16542
|
-
}), u =
|
|
16565
|
+
}), u = Ev(a), `已 write(edit) 主数据(${c.length} 个 patch)。当前值:${Tv(a, 600)} (新 hash=${Ev(a)})`;
|
|
16543
16566
|
}
|
|
16544
|
-
let _, v =
|
|
16545
|
-
if (v.parseError) return
|
|
16567
|
+
let _, v = Sv(l);
|
|
16568
|
+
if (v.parseError) return W_("", l, v.parseError);
|
|
16546
16569
|
_ = v.parsed;
|
|
16547
16570
|
let y = await h("set", g);
|
|
16548
16571
|
if (y !== null) return y;
|
|
@@ -16551,11 +16574,11 @@ function Iv(e, r = {}) {
|
|
|
16551
16574
|
code: "LEAF_BIND",
|
|
16552
16575
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),write(set) 无法就地替换外部持有的值引用`,
|
|
16553
16576
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
16554
|
-
}) : (m("set"), b.data !== null && typeof b.data == "object" && (s ?
|
|
16577
|
+
}) : (m("set"), b.data !== null && typeof b.data == "object" && (s ? _v(a, b.data) : Nv(a, b.data)), p({
|
|
16555
16578
|
op: "set",
|
|
16556
16579
|
value: b.data,
|
|
16557
16580
|
timestamp: Date.now()
|
|
16558
|
-
}), u =
|
|
16581
|
+
}), u = Ev(a), `已 write(set) 主数据 = ${Tv(b.data, 600)} (新 hash=${Ev(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`) : U_("", b.error.issues);
|
|
16559
16582
|
}, {
|
|
16560
16583
|
name: "write",
|
|
16561
16584
|
description: "写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四种意图:① 整体替换 write({ value }) value 为 JSON 对象(推荐)或字符串;② 单个增量 patch write({ value, patch:{op,jsonPath} }) op=set/remove/merge/append,jsonPath 相对主数据根(如 components.0.text),value 作为该 patch 的值;③ 批量增量 write({ patches:[{op,jsonPath,value},...] }) 一次原子应用多个 patch(任一失败整体不写入,适合一次改多处);④ 删除 write({ patch:{jsonPath}, del:true })。写入自动经 schema 校验(失败不写)+ 自动存快照(可 restore_data 回退)+ 自动乐观锁(autoLock,用你最后 read 到的 hash 比对,冲突则 VERSION_CONFLICT)。集成方可能经 write 拦截器校验/转换/拒绝(批量模式拦截器收到 {patches},返回新 patches 数组或 {error})。",
|
|
@@ -16593,8 +16616,8 @@ function Iv(e, r = {}) {
|
|
|
16593
16616
|
}
|
|
16594
16617
|
//#endregion
|
|
16595
16618
|
//#region src/core/tools/fetchDoc.ts
|
|
16596
|
-
var
|
|
16597
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16619
|
+
var Rv = 3e4, zv = [n(async ({ url: e, as: t }) => {
|
|
16620
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Rv);
|
|
16598
16621
|
try {
|
|
16599
16622
|
let r = await fetch(e, {
|
|
16600
16623
|
method: "GET",
|
|
@@ -16611,7 +16634,7 @@ var Lv = 3e4, Rv = [n(async ({ url: e, as: t }) => {
|
|
|
16611
16634
|
].join("\n");
|
|
16612
16635
|
} catch (t) {
|
|
16613
16636
|
let r = t?.message || String(t);
|
|
16614
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16637
|
+
return n.signal.aborted ? `获取失败:请求超时(${Rv}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16615
16638
|
} finally {
|
|
16616
16639
|
clearTimeout(r);
|
|
16617
16640
|
}
|
|
@@ -16622,25 +16645,25 @@ var Lv = 3e4, Rv = [n(async ({ url: e, as: t }) => {
|
|
|
16622
16645
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16623
16646
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16624
16647
|
})
|
|
16625
|
-
})],
|
|
16626
|
-
function
|
|
16627
|
-
return
|
|
16648
|
+
})], Bv = zv;
|
|
16649
|
+
function Vv(e, t) {
|
|
16650
|
+
return Lv(e, t);
|
|
16628
16651
|
}
|
|
16629
|
-
function
|
|
16652
|
+
function Hv(e, t, n) {
|
|
16630
16653
|
let r = e?.dataOps !== !1, i = e?.fetch !== !1;
|
|
16631
16654
|
return [...r ? t : [], ...i ? n : []];
|
|
16632
16655
|
}
|
|
16633
16656
|
//#endregion
|
|
16634
16657
|
//#region src/core/harness/usageHints.ts
|
|
16635
|
-
var
|
|
16636
|
-
function
|
|
16658
|
+
var Uv = .7;
|
|
16659
|
+
function Wv(e, t, n = "simple") {
|
|
16637
16660
|
let r = n !== "advanced";
|
|
16638
16661
|
return {
|
|
16639
16662
|
name: "usageHints",
|
|
16640
16663
|
augmentPrompt: () => {
|
|
16641
16664
|
let n = [];
|
|
16642
16665
|
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (r ? (n.push("读写主数据用 read/write(高层入口,自动乐观锁 + 自动快照)。read({jsonPath}) 读子路径当前值(返回含 hash,write 时自动比对,无需手动传);read() 不传读整个主数据 + 说明。write({value}) 整体替换(value 直传 JSON 对象,如 {title:\"x\"},无需 stringify);write({value, patch:{op,jsonPath}}) 增量 patch(op=set/remove/merge/append);write({patch:{jsonPath}, del:true}) 删除子路径。写入自动经 schema 校验(失败不写)+ 自动存快照(出错可用 restore_data 回退)。"), n.push("修改大对象/数组优先用 write 的 patch 增量(只发改动部分),避免整体重传被 max_tokens 截断致 JSON 不完整。"), n.push("在大数组里按条件筛选用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素 path/index;定位后用 write patch 改。找名字记不清的元素用 search_data(substring/regex/fuzzy)。批量过滤/映射/聚合/重写大数组用 eval_script(沙箱脚本,mode=query 只读/transform 落地)。")) : (n.push("改主数据前先 get_data({jsonPath}) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若主数据在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), n.push("不确定主数据字段结构时用 describe_data 查看说明。"), n.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改主数据出错时可用 restore_data 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), n.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"))), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
16643
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
16666
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= Uv || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), i = e.subagents.filter((e) => (e.temperature ?? 0) < Uv && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16644
16667
|
n.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (n.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), n.push(" 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。")), i.length && n.push(` · 严谨/易错/校验类 → 可先调 ${i.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), n.push(r ? " · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。" : " · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), n.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16645
16668
|
}
|
|
16646
16669
|
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;
|
|
@@ -16649,7 +16672,7 @@ function Uv(e, t, n = "simple") {
|
|
|
16649
16672
|
}
|
|
16650
16673
|
//#endregion
|
|
16651
16674
|
//#region src/core/utils/id.ts
|
|
16652
|
-
function
|
|
16675
|
+
function Gv() {
|
|
16653
16676
|
try {
|
|
16654
16677
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16655
16678
|
} catch {}
|
|
@@ -16657,57 +16680,57 @@ function Wv() {
|
|
|
16657
16680
|
}
|
|
16658
16681
|
//#endregion
|
|
16659
16682
|
//#region src/core/backends/storage.ts
|
|
16660
|
-
var
|
|
16683
|
+
var Kv = "chat-sdk", qv = 50 * 1024 * 1024, Jv = 4 * 1024 * 1024, Yv = 10 * 1024 * 1024, Xv = .9, Zv = 500, Qv = 300, $v = "__meta__", ey = "v:1", ty = [
|
|
16661
16684
|
"messages",
|
|
16662
16685
|
"vfs",
|
|
16663
16686
|
"todos",
|
|
16664
16687
|
"memory"
|
|
16665
16688
|
];
|
|
16666
|
-
function ty(e) {
|
|
16667
|
-
return e === "local" || e === "session" ? qv : Kv;
|
|
16668
|
-
}
|
|
16669
16689
|
function ny(e) {
|
|
16690
|
+
return e === "local" || e === "session" ? Jv : qv;
|
|
16691
|
+
}
|
|
16692
|
+
function ry(e) {
|
|
16670
16693
|
if (typeof e != "object" || !e) return !1;
|
|
16671
16694
|
let t = e;
|
|
16672
16695
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16673
16696
|
}
|
|
16674
|
-
function
|
|
16697
|
+
function iy(e, t, n, r) {
|
|
16675
16698
|
return [
|
|
16676
|
-
|
|
16699
|
+
ey,
|
|
16677
16700
|
e,
|
|
16678
16701
|
t,
|
|
16679
16702
|
n,
|
|
16680
16703
|
r
|
|
16681
16704
|
].join("::");
|
|
16682
16705
|
}
|
|
16683
|
-
function
|
|
16706
|
+
function ay(e, t, n) {
|
|
16684
16707
|
return [
|
|
16685
|
-
|
|
16708
|
+
ey,
|
|
16686
16709
|
e,
|
|
16687
16710
|
t,
|
|
16688
16711
|
n
|
|
16689
16712
|
].join("::") + "::";
|
|
16690
16713
|
}
|
|
16691
|
-
function
|
|
16714
|
+
function oy(e, t) {
|
|
16692
16715
|
return [
|
|
16693
|
-
|
|
16716
|
+
ey,
|
|
16694
16717
|
e,
|
|
16695
16718
|
t
|
|
16696
16719
|
].join("::") + "::";
|
|
16697
16720
|
}
|
|
16698
|
-
function
|
|
16699
|
-
return [
|
|
16721
|
+
function sy(e) {
|
|
16722
|
+
return [ey, e].join("::") + "::";
|
|
16700
16723
|
}
|
|
16701
|
-
var
|
|
16702
|
-
function
|
|
16703
|
-
|
|
16724
|
+
var cy = null;
|
|
16725
|
+
function ly(e) {
|
|
16726
|
+
cy ||= new TextEncoder();
|
|
16704
16727
|
try {
|
|
16705
|
-
return
|
|
16728
|
+
return cy.encode(JSON.stringify(e)).length;
|
|
16706
16729
|
} catch {
|
|
16707
16730
|
return 0;
|
|
16708
16731
|
}
|
|
16709
16732
|
}
|
|
16710
|
-
function
|
|
16733
|
+
function uy(e, t, n) {
|
|
16711
16734
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16712
16735
|
if (r <= t) return [];
|
|
16713
16736
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16717,7 +16740,7 @@ function ly(e, t, n) {
|
|
|
16717
16740
|
}
|
|
16718
16741
|
return o;
|
|
16719
16742
|
}
|
|
16720
|
-
function
|
|
16743
|
+
function dy() {
|
|
16721
16744
|
let e = /* @__PURE__ */ new Map();
|
|
16722
16745
|
return {
|
|
16723
16746
|
async get(t) {
|
|
@@ -16737,7 +16760,7 @@ function uy() {
|
|
|
16737
16760
|
}
|
|
16738
16761
|
};
|
|
16739
16762
|
}
|
|
16740
|
-
function
|
|
16763
|
+
function fy(e) {
|
|
16741
16764
|
return new Promise((t, n) => {
|
|
16742
16765
|
if (typeof indexedDB > "u") {
|
|
16743
16766
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -16798,7 +16821,7 @@ function dy(e) {
|
|
|
16798
16821
|
}, r.onerror = () => n(r.error);
|
|
16799
16822
|
});
|
|
16800
16823
|
}
|
|
16801
|
-
function
|
|
16824
|
+
function py(e) {
|
|
16802
16825
|
return {
|
|
16803
16826
|
async get(t) {
|
|
16804
16827
|
let n = e.getItem(t);
|
|
@@ -16832,12 +16855,12 @@ function fy(e) {
|
|
|
16832
16855
|
}
|
|
16833
16856
|
};
|
|
16834
16857
|
}
|
|
16835
|
-
function
|
|
16858
|
+
function my(e, t, n) {
|
|
16836
16859
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
16837
16860
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
16838
16861
|
}
|
|
16839
|
-
function
|
|
16840
|
-
let t = e.dbName ??
|
|
16862
|
+
function hy(e = {}) {
|
|
16863
|
+
let t = e.dbName ?? Kv, n = e.backend ?? "indexed", r = e.maxBytes ?? ny(n), i = e.maxBytesPerSession ?? Yv, a = e.evictionWatermark ?? Xv, o = e.debounceMs ?? Zv, s = /* @__PURE__ */ new Set();
|
|
16841
16864
|
function c(e) {
|
|
16842
16865
|
for (let t of s) try {
|
|
16843
16866
|
t(e);
|
|
@@ -16850,16 +16873,16 @@ function my(e = {}) {
|
|
|
16850
16873
|
try {
|
|
16851
16874
|
if (n === "indexed") {
|
|
16852
16875
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
16853
|
-
l = await
|
|
16876
|
+
l = await fy(t), d(!0);
|
|
16854
16877
|
} else if (n === "session") {
|
|
16855
16878
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
16856
|
-
l =
|
|
16879
|
+
l = py(sessionStorage), d(!0);
|
|
16857
16880
|
} else if (n === "local") {
|
|
16858
16881
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
16859
|
-
l =
|
|
16860
|
-
} else l =
|
|
16882
|
+
l = py(localStorage), d(!0);
|
|
16883
|
+
} else l = dy(), d(!1);
|
|
16861
16884
|
} catch (e) {
|
|
16862
|
-
l =
|
|
16885
|
+
l = dy();
|
|
16863
16886
|
let t = e instanceof Error ? e.message : String(e);
|
|
16864
16887
|
d(!1), Promise.resolve().then(() => c({
|
|
16865
16888
|
type: "degraded",
|
|
@@ -16869,10 +16892,10 @@ function my(e = {}) {
|
|
|
16869
16892
|
})();
|
|
16870
16893
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
16871
16894
|
function g(e, n, r, a) {
|
|
16872
|
-
let o =
|
|
16873
|
-
return
|
|
16895
|
+
let o = iy(t, r, a, $v);
|
|
16896
|
+
return my(h, o, async () => {
|
|
16874
16897
|
let t = async () => {
|
|
16875
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16898
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : ly(s), d = ly(n), f = (t?.bytes ?? 0) + (d - u);
|
|
16876
16899
|
if (f > i) {
|
|
16877
16900
|
c({
|
|
16878
16901
|
type: "quota",
|
|
@@ -16894,12 +16917,12 @@ function my(e = {}) {
|
|
|
16894
16917
|
try {
|
|
16895
16918
|
await t();
|
|
16896
16919
|
} catch (e) {
|
|
16897
|
-
if (
|
|
16920
|
+
if (ry(e) && !u) {
|
|
16898
16921
|
u = !0;
|
|
16899
16922
|
try {
|
|
16900
16923
|
await b();
|
|
16901
16924
|
} catch {}
|
|
16902
|
-
l =
|
|
16925
|
+
l = dy(), Promise.resolve().then(() => c({
|
|
16903
16926
|
type: "degraded",
|
|
16904
16927
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
16905
16928
|
}));
|
|
@@ -16911,7 +16934,7 @@ function my(e = {}) {
|
|
|
16911
16934
|
});
|
|
16912
16935
|
}
|
|
16913
16936
|
function _(e, n, r, i) {
|
|
16914
|
-
let a =
|
|
16937
|
+
let a = iy(t, e, n, r), s = p.get(a);
|
|
16915
16938
|
s && s.resolve();
|
|
16916
16939
|
let c = m.get(a);
|
|
16917
16940
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16938,15 +16961,15 @@ function my(e = {}) {
|
|
|
16938
16961
|
function y() {
|
|
16939
16962
|
v ||= setTimeout(() => {
|
|
16940
16963
|
v = null, b();
|
|
16941
|
-
},
|
|
16964
|
+
}, Qv);
|
|
16942
16965
|
}
|
|
16943
16966
|
async function b() {
|
|
16944
16967
|
let e = [];
|
|
16945
|
-
await l.scan(
|
|
16968
|
+
await l.scan(sy(t), (t, n) => {
|
|
16946
16969
|
t.endsWith("::__meta__") && e.push(n);
|
|
16947
16970
|
});
|
|
16948
|
-
let n =
|
|
16949
|
-
for (let e of n) await l.clearPrefix(
|
|
16971
|
+
let n = uy(e, r, a);
|
|
16972
|
+
for (let e of n) await l.clearPrefix(ay(t, e.agentId, e.sessionId)), c({
|
|
16950
16973
|
type: "evicted",
|
|
16951
16974
|
agentId: e.agentId,
|
|
16952
16975
|
sessionId: e.sessionId,
|
|
@@ -16957,13 +16980,13 @@ function my(e = {}) {
|
|
|
16957
16980
|
ready: f,
|
|
16958
16981
|
async listSessions(e) {
|
|
16959
16982
|
let n = [];
|
|
16960
|
-
return await l.scan(
|
|
16983
|
+
return await l.scan(oy(t, e), (e, t) => {
|
|
16961
16984
|
e.endsWith("::__meta__") && n.push(t);
|
|
16962
16985
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16963
16986
|
},
|
|
16964
16987
|
async load(e, n) {
|
|
16965
|
-
let r =
|
|
16966
|
-
return await
|
|
16988
|
+
let r = iy(t, e, n, $v);
|
|
16989
|
+
return await my(h, r, async () => {
|
|
16967
16990
|
let i = await l.get(r);
|
|
16968
16991
|
if (!i) return;
|
|
16969
16992
|
let a = {
|
|
@@ -16972,8 +16995,8 @@ function my(e = {}) {
|
|
|
16972
16995
|
todos: [],
|
|
16973
16996
|
memory: ""
|
|
16974
16997
|
};
|
|
16975
|
-
for (let r of
|
|
16976
|
-
let i = await l.get(
|
|
16998
|
+
for (let r of ty) {
|
|
16999
|
+
let i = await l.get(iy(t, e, n, r));
|
|
16977
17000
|
i != null && (a[r] = i);
|
|
16978
17001
|
}
|
|
16979
17002
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16981,7 +17004,7 @@ function my(e = {}) {
|
|
|
16981
17004
|
},
|
|
16982
17005
|
async save(e, t, n) {
|
|
16983
17006
|
let r = [];
|
|
16984
|
-
for (let i of
|
|
17007
|
+
for (let i of ty) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16985
17008
|
await Promise.all(r);
|
|
16986
17009
|
},
|
|
16987
17010
|
async flush() {
|
|
@@ -16995,10 +17018,10 @@ function my(e = {}) {
|
|
|
16995
17018
|
})), c({ type: "flush" }), await b();
|
|
16996
17019
|
},
|
|
16997
17020
|
async deleteSession(e, n) {
|
|
16998
|
-
await l.clearPrefix(
|
|
17021
|
+
await l.clearPrefix(ay(t, e, n));
|
|
16999
17022
|
},
|
|
17000
17023
|
async createSession(e, n, r) {
|
|
17001
|
-
let i = r ??
|
|
17024
|
+
let i = r ?? Gv(), a = Date.now(), o = {
|
|
17002
17025
|
agentId: e,
|
|
17003
17026
|
sessionId: i,
|
|
17004
17027
|
createdAt: a,
|
|
@@ -17006,7 +17029,7 @@ function my(e = {}) {
|
|
|
17006
17029
|
bytes: 0,
|
|
17007
17030
|
title: n
|
|
17008
17031
|
};
|
|
17009
|
-
return await l.set(
|
|
17032
|
+
return await l.set(iy(t, e, i, $v), o), i;
|
|
17010
17033
|
},
|
|
17011
17034
|
onEvent(e) {
|
|
17012
17035
|
s.add(e);
|
|
@@ -17021,35 +17044,35 @@ function my(e = {}) {
|
|
|
17021
17044
|
}
|
|
17022
17045
|
//#endregion
|
|
17023
17046
|
//#region src/core/sdk/createChatSdk.ts
|
|
17024
|
-
var
|
|
17047
|
+
var gy = [
|
|
17025
17048
|
"你是一个 JSON 操作助手。集成方声明了一个主数据对象(含 zod schema 校验),你通过专用工具安全地读写它来完成任务。",
|
|
17026
17049
|
"所有写操作都经范围控制(仅 schema 声明字段内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
17027
17050
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
17028
17051
|
"---",
|
|
17029
|
-
|
|
17052
|
+
R_.reliableWriteRules
|
|
17030
17053
|
].join("\n\n");
|
|
17031
|
-
function
|
|
17054
|
+
function _y(e) {
|
|
17032
17055
|
if (!e) return "";
|
|
17033
|
-
let t =
|
|
17056
|
+
let t = z_(e.schema);
|
|
17034
17057
|
return `\n\n## 可操作数据(字段以 read 工具返回的实际值为准)\n${e.description ? e.description + "\n" : ""}${t}`;
|
|
17035
17058
|
}
|
|
17036
|
-
var
|
|
17037
|
-
function vy(e) {
|
|
17038
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ? my({ backend: e }) : e.enabled === !1 ? null : my(e);
|
|
17039
|
-
}
|
|
17059
|
+
var vy = 50;
|
|
17040
17060
|
function yy(e) {
|
|
17061
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? hy({ backend: e }) : e.enabled === !1 ? null : hy(e);
|
|
17062
|
+
}
|
|
17063
|
+
function by(e) {
|
|
17041
17064
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
17042
17065
|
}
|
|
17043
|
-
var
|
|
17044
|
-
function
|
|
17066
|
+
var xy = /* @__PURE__ */ new Map();
|
|
17067
|
+
function Sy(e) {
|
|
17045
17068
|
let t = e.content;
|
|
17046
17069
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
17047
17070
|
}
|
|
17048
|
-
function
|
|
17071
|
+
function Cy(e) {
|
|
17049
17072
|
let t = e.summaryLlm ?? e.llm;
|
|
17050
17073
|
if (!t) return;
|
|
17051
17074
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
17052
|
-
if (
|
|
17075
|
+
if (by(t)) c = t;
|
|
17053
17076
|
else {
|
|
17054
17077
|
let i = t;
|
|
17055
17078
|
if (!i.apiKey) {
|
|
@@ -17067,26 +17090,47 @@ function Sy(e) {
|
|
|
17067
17090
|
return async (e) => {
|
|
17068
17091
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
17069
17092
|
try {
|
|
17070
|
-
return
|
|
17093
|
+
return Sy(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
17071
17094
|
} finally {
|
|
17072
17095
|
clearTimeout(n);
|
|
17073
17096
|
}
|
|
17074
17097
|
};
|
|
17075
17098
|
}
|
|
17076
|
-
function
|
|
17099
|
+
function wy(e, t) {
|
|
17077
17100
|
return e === "set_data" ? "set" : e === "edit_data" ? "edit" : e === "delete_data" ? "delete" : e === "restore_data" ? "restore" : e === "write" ? t?.del ? "delete" : t?.patch ? "edit" : "set" : null;
|
|
17078
17101
|
}
|
|
17079
|
-
function
|
|
17102
|
+
function Ty(e, t, n, r) {
|
|
17103
|
+
let i = 0;
|
|
17080
17104
|
return {
|
|
17081
17105
|
name: "sdk-events",
|
|
17082
17106
|
wrapToolCall: async (t, r) => {
|
|
17083
|
-
let i = await r(t), a =
|
|
17107
|
+
let i = await r(t), a = wy(t.name, t.args);
|
|
17084
17108
|
return a && e({
|
|
17085
17109
|
type: "data_change",
|
|
17086
17110
|
operation: a,
|
|
17087
17111
|
value: n()?.bind
|
|
17088
17112
|
}), i;
|
|
17089
17113
|
},
|
|
17114
|
+
afterModel: (t) => {
|
|
17115
|
+
let n = t.message.additional_kwargs || {}, a = t.message.response_metadata || {}, o = n.usage || a.usage || a.token_usage || a.tokenUsage;
|
|
17116
|
+
if (o && typeof o == "object") {
|
|
17117
|
+
let t = Number(o.prompt_tokens ?? o.promptTokens ?? 0) || 0, n = Number(o.completion_tokens ?? o.completionTokens ?? 0) || 0, a = Number(o.total_tokens ?? o.totalTokens ?? t + n) || 0, s = {
|
|
17118
|
+
prompt_tokens: t,
|
|
17119
|
+
completion_tokens: n,
|
|
17120
|
+
total_tokens: a
|
|
17121
|
+
};
|
|
17122
|
+
r.prompt_tokens = (r.prompt_tokens ?? 0) + t, r.completion_tokens = (r.completion_tokens ?? 0) + n, r.total_tokens = (r.total_tokens ?? 0) + a, i++, e({
|
|
17123
|
+
type: "usage",
|
|
17124
|
+
round: i,
|
|
17125
|
+
usage: s,
|
|
17126
|
+
cumulative: {
|
|
17127
|
+
prompt_tokens: r.prompt_tokens,
|
|
17128
|
+
completion_tokens: r.completion_tokens,
|
|
17129
|
+
total_tokens: r.total_tokens
|
|
17130
|
+
}
|
|
17131
|
+
});
|
|
17132
|
+
}
|
|
17133
|
+
},
|
|
17090
17134
|
afterAgent: async () => {
|
|
17091
17135
|
e({
|
|
17092
17136
|
type: "message_update",
|
|
@@ -17095,178 +17139,185 @@ function wy(e, t, n) {
|
|
|
17095
17139
|
}
|
|
17096
17140
|
};
|
|
17097
17141
|
}
|
|
17098
|
-
function
|
|
17099
|
-
let i =
|
|
17100
|
-
|
|
17142
|
+
function Ey(e, r) {
|
|
17143
|
+
let i = {
|
|
17144
|
+
prompt_tokens: 0,
|
|
17145
|
+
completion_tokens: 0,
|
|
17146
|
+
total_tokens: 0
|
|
17147
|
+
}, a = /* @__PURE__ */ fn(null), o = 0;
|
|
17148
|
+
function s(e) {
|
|
17101
17149
|
return new Promise((t) => {
|
|
17102
|
-
let n =
|
|
17150
|
+
let n = a.value;
|
|
17103
17151
|
n && n.resolve({ action: "keep_external" });
|
|
17104
17152
|
let r = {
|
|
17105
17153
|
...e,
|
|
17106
|
-
id: ++
|
|
17154
|
+
id: ++o,
|
|
17107
17155
|
resolve: t
|
|
17108
17156
|
};
|
|
17109
|
-
|
|
17157
|
+
a.value = r, ge({
|
|
17110
17158
|
type: "conflict",
|
|
17111
17159
|
conflict: r
|
|
17112
17160
|
});
|
|
17113
17161
|
});
|
|
17114
17162
|
}
|
|
17115
|
-
function
|
|
17116
|
-
let t =
|
|
17117
|
-
t && (
|
|
17118
|
-
}
|
|
17119
|
-
let
|
|
17120
|
-
e.debug &&
|
|
17121
|
-
let
|
|
17122
|
-
model:
|
|
17123
|
-
contextWindow: e.contextWindow ??
|
|
17124
|
-
maxOutputTokens: e.maxOutputTokens ??
|
|
17163
|
+
function c(e) {
|
|
17164
|
+
let t = a.value;
|
|
17165
|
+
t && (a.value = null, t.resolve({ action: e }));
|
|
17166
|
+
}
|
|
17167
|
+
let l = yy(e.storage);
|
|
17168
|
+
e.debug && l && l.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
17169
|
+
let u = by(e.llm) ? void 0 : e.llm, d = rg({
|
|
17170
|
+
model: u?.model,
|
|
17171
|
+
contextWindow: e.contextWindow ?? u?.contextWindow,
|
|
17172
|
+
maxOutputTokens: e.maxOutputTokens ?? u?.maxOutputTokens
|
|
17125
17173
|
});
|
|
17126
|
-
e.debug && console.log("[page-agent-sdk][modelCaps]",
|
|
17127
|
-
let
|
|
17128
|
-
e.debug && !
|
|
17129
|
-
let
|
|
17130
|
-
persist:
|
|
17131
|
-
B.sessionId &&
|
|
17174
|
+
e.debug && console.log("[page-agent-sdk][modelCaps]", d);
|
|
17175
|
+
let f = Cy(e);
|
|
17176
|
+
e.debug && !f && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
17177
|
+
let p = /* @__PURE__ */ Qt([]), m = K_(e.vfs?.initialFiles, {
|
|
17178
|
+
persist: l ? { save: (e) => {
|
|
17179
|
+
B.sessionId && l && l.save(r, B.sessionId, { vfs: e });
|
|
17132
17180
|
} } : void 0,
|
|
17133
17181
|
maxBytes: e.vfs?.maxBytes
|
|
17134
|
-
}),
|
|
17182
|
+
}), h = Cg(), g = jg(e.memory || ""), _ = { current: null }, v = e.data ? {
|
|
17135
17183
|
...e.data,
|
|
17136
17184
|
description: e.data.description ?? "主数据对象"
|
|
17137
|
-
} : void 0,
|
|
17138
|
-
getData: () =>
|
|
17139
|
-
slotPaths:
|
|
17140
|
-
vfsStore:
|
|
17141
|
-
todosMw:
|
|
17142
|
-
getTodos: () =>
|
|
17143
|
-
messages:
|
|
17144
|
-
maxCheckpoints:
|
|
17145
|
-
}) : null,
|
|
17146
|
-
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0,
|
|
17185
|
+
} : void 0, y = e.checkpoint, b = y !== void 0 && y !== !1, x = b ? Jg({
|
|
17186
|
+
getData: () => A()?.bind,
|
|
17187
|
+
slotPaths: v ? [""] : [],
|
|
17188
|
+
vfsStore: m,
|
|
17189
|
+
todosMw: h,
|
|
17190
|
+
getTodos: () => _.current?.getState?.()?.todos ?? [],
|
|
17191
|
+
messages: p,
|
|
17192
|
+
maxCheckpoints: y && typeof y == "object" ? y.maxCheckpoints : void 0
|
|
17193
|
+
}) : null, S = !y || typeof y != "object" || y.auto !== !1, C = e.capabilities, w = C?.dataOps !== !1, T = e.appendReliableWriteRules !== !1, E = (e.systemPrompt ? T ? e.systemPrompt + "\n\n---\n\n" + R_.reliableWriteRules : e.systemPrompt : gy) + _y(v), D = w && v ? Lv(v, {
|
|
17194
|
+
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
17147
17195
|
maxSnapshots: e.maxSnapshots,
|
|
17148
|
-
onConflict:
|
|
17196
|
+
onConflict: s,
|
|
17149
17197
|
autoLock: e.autoLock,
|
|
17150
17198
|
interceptors: e.interceptors
|
|
17151
|
-
}) : [],
|
|
17152
|
-
|
|
17153
|
-
let
|
|
17154
|
-
|
|
17155
|
-
let
|
|
17156
|
-
|
|
17157
|
-
let
|
|
17158
|
-
let e =
|
|
17159
|
-
return e.length ?
|
|
17199
|
+
}) : [], O = w ? Iv(D, e.toolMode) : [], k = w && v ? D.controller ?? null : null, A = () => k?.get() ?? v, j = /* @__PURE__ */ new Map(), M = Hv(C, O, zv);
|
|
17200
|
+
M.forEach((e) => j.set(e.name, "builtin"));
|
|
17201
|
+
let N = [...e.tools || []];
|
|
17202
|
+
N.forEach((e) => j.set(e.name, "user"));
|
|
17203
|
+
let P = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), F = P ? Bg() : null;
|
|
17204
|
+
F && j.set(Rg, "builtin");
|
|
17205
|
+
let ee = b && x ? [n(async () => {
|
|
17206
|
+
let e = x.list();
|
|
17207
|
+
return e.length ? x.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
17160
17208
|
}, {
|
|
17161
17209
|
name: "restore_last_checkpoint",
|
|
17162
17210
|
description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
17163
17211
|
schema: t.object({}).optional()
|
|
17164
17212
|
}), n(async () => {
|
|
17165
|
-
let e =
|
|
17213
|
+
let e = x.list();
|
|
17166
17214
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
|
|
17167
17215
|
}, {
|
|
17168
17216
|
name: "list_checkpoints",
|
|
17169
17217
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
17170
17218
|
schema: t.object({}).optional()
|
|
17171
17219
|
})] : [];
|
|
17172
|
-
|
|
17220
|
+
ee.forEach((e) => j.set(e.name, "builtin"));
|
|
17173
17221
|
let I = [
|
|
17174
|
-
...j,
|
|
17175
17222
|
...M,
|
|
17176
|
-
...
|
|
17177
|
-
...F
|
|
17178
|
-
|
|
17179
|
-
e.verify?.
|
|
17180
|
-
|
|
17181
|
-
|
|
17223
|
+
...N,
|
|
17224
|
+
...F ? [F] : [],
|
|
17225
|
+
...ee
|
|
17226
|
+
], te = C?.planning !== !1, L = C?.skills !== !1, R = C?.vfs !== !1, ne = C?.summarization !== !1, re = C?.memory !== !1, ie = C?.subagent !== !1, ae = e.verify?.maxAttempts ?? 2, oe = C?.verify === !0 && e.verify?.enabled !== !1 && ae > 0;
|
|
17227
|
+
e.verify?.check && C?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
17228
|
+
let z = e.subagent, se = z?.allowedTools ?? [], ce = !ie || z?.enabled === !1 ? void 0 : r_({
|
|
17229
|
+
llm: z?.llm ?? e.llm,
|
|
17182
17230
|
allTools: I,
|
|
17183
|
-
allowedTools:
|
|
17184
|
-
systemPrompt:
|
|
17185
|
-
temperature:
|
|
17186
|
-
maxTokens:
|
|
17187
|
-
skills:
|
|
17188
|
-
maxDepth:
|
|
17189
|
-
maxParallel:
|
|
17231
|
+
allowedTools: se.length ? se : void 0,
|
|
17232
|
+
systemPrompt: z?.systemPrompt,
|
|
17233
|
+
temperature: z?.temperature,
|
|
17234
|
+
maxTokens: z?.maxTokens,
|
|
17235
|
+
skills: z?.skills,
|
|
17236
|
+
maxDepth: z?.maxDepth,
|
|
17237
|
+
maxParallel: z?.maxParallel,
|
|
17190
17238
|
debug: e.debug
|
|
17191
|
-
}),
|
|
17239
|
+
}), le = e.subagents?.length ? o_(e.subagents, {
|
|
17192
17240
|
llm: e.llm,
|
|
17193
17241
|
allTools: I,
|
|
17194
17242
|
debug: e.debug
|
|
17195
|
-
}) : void 0,
|
|
17243
|
+
}) : void 0, ue = [
|
|
17196
17244
|
"get_data",
|
|
17197
17245
|
"describe_data",
|
|
17198
17246
|
"read",
|
|
17199
17247
|
"fetch_document"
|
|
17200
|
-
],
|
|
17201
|
-
check: e.verify.check ??
|
|
17202
|
-
schemas: () =>
|
|
17203
|
-
root: () =>
|
|
17248
|
+
], de = I.filter((e) => ue.includes(e.name)), fe = oe ? s_({
|
|
17249
|
+
check: e.verify.check ?? p_({
|
|
17250
|
+
schemas: () => A() ? { "": A().schema } : {},
|
|
17251
|
+
root: () => A()?.bind
|
|
17204
17252
|
}),
|
|
17205
17253
|
adversarial: e.verify?.adversarial ? {
|
|
17206
17254
|
llm: e.llm,
|
|
17207
|
-
tools:
|
|
17255
|
+
tools: de
|
|
17208
17256
|
} : void 0
|
|
17209
|
-
}) : void 0,
|
|
17210
|
-
...
|
|
17211
|
-
humanConfirm:
|
|
17257
|
+
}) : void 0, pe = Wv({
|
|
17258
|
+
...C,
|
|
17259
|
+
humanConfirm: P,
|
|
17212
17260
|
subagents: e.subagents?.map((e) => ({
|
|
17213
17261
|
id: e.id,
|
|
17214
17262
|
description: e.description,
|
|
17215
17263
|
temperature: e.temperature
|
|
17216
17264
|
}))
|
|
17217
|
-
},
|
|
17265
|
+
}, w && !!v, e.toolMode), me = e.onEvent, he = /* @__PURE__ */ new Set(), ge = (e) => {
|
|
17218
17266
|
if (e.type !== "approval_request") {
|
|
17219
|
-
if (
|
|
17220
|
-
|
|
17267
|
+
if (me) try {
|
|
17268
|
+
me(e);
|
|
17221
17269
|
} catch {}
|
|
17222
|
-
for (let t of
|
|
17270
|
+
for (let t of he) try {
|
|
17223
17271
|
t(e);
|
|
17224
17272
|
} catch {}
|
|
17225
17273
|
}
|
|
17226
|
-
},
|
|
17227
|
-
|
|
17228
|
-
...
|
|
17229
|
-
...
|
|
17230
|
-
...R ? [
|
|
17231
|
-
...
|
|
17232
|
-
...
|
|
17233
|
-
llmInvoke:
|
|
17234
|
-
getRegisteredData: () =>
|
|
17274
|
+
}, _e, ve = [
|
|
17275
|
+
pe,
|
|
17276
|
+
...te ? [h] : [],
|
|
17277
|
+
...L ? [_e = Ag(e.skills || [], { readVfs: R ? (e) => m.files[e]?.content : void 0 })] : [],
|
|
17278
|
+
...R ? [$_(m)] : [],
|
|
17279
|
+
...ne ? [I_({
|
|
17280
|
+
...V_(e, d.contextWindow),
|
|
17281
|
+
llmInvoke: f,
|
|
17282
|
+
getRegisteredData: () => A() ? [{ description: A().description ?? "主数据对象" }] : [],
|
|
17235
17283
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_data", "read"]
|
|
17236
17284
|
})] : [],
|
|
17237
|
-
...
|
|
17238
|
-
...e.permissions?.length ? [
|
|
17239
|
-
...
|
|
17240
|
-
...
|
|
17241
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
17242
|
-
...
|
|
17243
|
-
...se ? [se] : [],
|
|
17285
|
+
...re ? [g] : [],
|
|
17286
|
+
...e.permissions?.length ? [Ig(e.permissions)] : [],
|
|
17287
|
+
...b && S && x ? [Yg(x)] : [],
|
|
17288
|
+
...P ? [Vg()] : [],
|
|
17289
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [Lg(e.approval)] : [],
|
|
17290
|
+
...fe ? [fe] : [],
|
|
17244
17291
|
...ce ? [ce] : [],
|
|
17292
|
+
...le ? [le] : [],
|
|
17245
17293
|
...e.middleware || [],
|
|
17246
|
-
|
|
17247
|
-
],
|
|
17294
|
+
Ty(ge, p, A, i)
|
|
17295
|
+
], ye = e.maxMemoryRounds ?? vy, B = {
|
|
17248
17296
|
agentId: r,
|
|
17249
|
-
store:
|
|
17250
|
-
messages:
|
|
17251
|
-
vfsStore:
|
|
17252
|
-
listeners:
|
|
17253
|
-
todosMw:
|
|
17254
|
-
memoryMw:
|
|
17297
|
+
store: l,
|
|
17298
|
+
messages: p,
|
|
17299
|
+
vfsStore: m,
|
|
17300
|
+
listeners: he,
|
|
17301
|
+
todosMw: h,
|
|
17302
|
+
memoryMw: g,
|
|
17255
17303
|
agent: null,
|
|
17256
17304
|
initDone: Promise.resolve(),
|
|
17257
17305
|
sessionId: "",
|
|
17258
17306
|
refCount: 0,
|
|
17259
17307
|
mcpClosers: [],
|
|
17260
17308
|
mcpServers: [],
|
|
17261
|
-
checkpoint:
|
|
17262
|
-
dataOpsController:
|
|
17263
|
-
|
|
17264
|
-
|
|
17309
|
+
checkpoint: x,
|
|
17310
|
+
dataOpsController: k,
|
|
17311
|
+
skillsController: _e ? _e.controller : null,
|
|
17312
|
+
pendingConflict: a,
|
|
17313
|
+
liveData: A,
|
|
17314
|
+
usage: i,
|
|
17315
|
+
emit: ge,
|
|
17265
17316
|
applySnapshot(t) {
|
|
17266
|
-
t.messages?.length &&
|
|
17317
|
+
t.messages?.length && p.push(...t.messages), t.vfs && m.hydrate && m.hydrate(t.vfs), t.todos?.length && h.reset(t.todos), t.memory && !e.memory && g.reset(t.memory);
|
|
17267
17318
|
},
|
|
17268
17319
|
afterRound() {
|
|
17269
|
-
|
|
17320
|
+
xe(), Se();
|
|
17270
17321
|
},
|
|
17271
17322
|
async send(t) {
|
|
17272
17323
|
await B.initDone;
|
|
@@ -17275,132 +17326,144 @@ function Ty(e, r) {
|
|
|
17275
17326
|
let r = e.interceptors.input(t);
|
|
17276
17327
|
typeof r == "string" && (n = r);
|
|
17277
17328
|
} catch {}
|
|
17278
|
-
|
|
17329
|
+
p.push({
|
|
17279
17330
|
role: "user",
|
|
17280
17331
|
content: n,
|
|
17281
17332
|
timestamp: Date.now()
|
|
17282
17333
|
});
|
|
17283
17334
|
try {
|
|
17284
|
-
let t = await B.agent.invoke(
|
|
17335
|
+
let t = await B.agent.invoke(p);
|
|
17285
17336
|
if (e.interceptors?.output) try {
|
|
17286
17337
|
let n = e.interceptors.output(t);
|
|
17287
17338
|
typeof n == "string" && (t = n);
|
|
17288
17339
|
} catch {}
|
|
17289
|
-
return
|
|
17340
|
+
return p.push({
|
|
17290
17341
|
role: "assistant",
|
|
17291
17342
|
content: t,
|
|
17292
17343
|
timestamp: Date.now()
|
|
17293
|
-
}), B.afterRound(),
|
|
17344
|
+
}), B.afterRound(), l && await l.flush(), t;
|
|
17294
17345
|
} catch (e) {
|
|
17295
|
-
throw
|
|
17346
|
+
throw ge({
|
|
17296
17347
|
type: "error",
|
|
17297
17348
|
message: e?.message || String(e)
|
|
17298
17349
|
}), e;
|
|
17299
17350
|
}
|
|
17300
17351
|
},
|
|
17301
17352
|
async switchSession(t) {
|
|
17302
|
-
if (await B.initDone, !
|
|
17303
|
-
|
|
17353
|
+
if (await B.initDone, !l) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
|
|
17354
|
+
c("keep_external"), m.flush?.(), await l.flush();
|
|
17304
17355
|
let n = t ?? "", i;
|
|
17305
|
-
return n ? (i = await
|
|
17356
|
+
return n ? (i = await l.load(r, n), i || await l.createSession(r, e.session?.title, n)) : n = await l.createSession(r, e.session?.title), B.sessionId = n, p.splice(0, p.length), m.clear?.(), h.reset([]), e.memory || g.reset(""), B.agent.debugLogs.value = [], i ||= await l.load(r, n), i && (B.applySnapshot(i), ge({
|
|
17357
|
+
type: "session_restored",
|
|
17358
|
+
sessionId: n,
|
|
17359
|
+
rounds: i.messages?.length ?? 0
|
|
17360
|
+
})), e.memory && l.save(r, B.sessionId, { memory: e.memory }), n;
|
|
17306
17361
|
},
|
|
17307
17362
|
stream: (e, t, n) => {
|
|
17308
17363
|
if (!B.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
17309
|
-
let r =
|
|
17310
|
-
t?.(e),
|
|
17364
|
+
let r = me ? (e) => {
|
|
17365
|
+
t?.(e), ge(e);
|
|
17311
17366
|
} : t;
|
|
17312
17367
|
if (n) {
|
|
17313
|
-
let e = () =>
|
|
17368
|
+
let e = () => c("keep_external");
|
|
17314
17369
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
17315
17370
|
}
|
|
17316
17371
|
return B.agent.stream(e, r, n);
|
|
17317
17372
|
},
|
|
17318
17373
|
release() {
|
|
17319
17374
|
if (B.refCount--, B.refCount <= 0) {
|
|
17320
|
-
|
|
17375
|
+
l && (m.flush?.(), l.flush(), l.dispose());
|
|
17321
17376
|
let e = B.mcpClosers.splice(0);
|
|
17322
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
17377
|
+
e.length && Promise.allSettled(e.map((e) => e())), xy.delete(r);
|
|
17323
17378
|
}
|
|
17324
17379
|
},
|
|
17325
|
-
resolveConflict:
|
|
17380
|
+
resolveConflict: c,
|
|
17326
17381
|
getInfo() {
|
|
17327
17382
|
return {
|
|
17328
17383
|
id: r,
|
|
17329
|
-
model:
|
|
17330
|
-
systemPrompt:
|
|
17384
|
+
model: by(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17385
|
+
systemPrompt: E,
|
|
17331
17386
|
tools: I.map((e) => ({
|
|
17332
17387
|
name: e.name,
|
|
17333
17388
|
description: e.description,
|
|
17334
17389
|
schema: e.schema,
|
|
17335
|
-
source:
|
|
17390
|
+
source: j.get(e.name) || "user"
|
|
17336
17391
|
})),
|
|
17337
|
-
skills: (e.skills ?? []).map((e) => ({
|
|
17392
|
+
skills: (_e ? _e.controller.get() : e.skills ?? []).map((e) => ({
|
|
17338
17393
|
name: e.name,
|
|
17339
17394
|
description: e.description
|
|
17340
17395
|
})),
|
|
17341
|
-
data:
|
|
17342
|
-
description:
|
|
17343
|
-
schema:
|
|
17396
|
+
data: A() ? {
|
|
17397
|
+
description: A().description,
|
|
17398
|
+
schema: A().schema
|
|
17344
17399
|
} : void 0,
|
|
17345
17400
|
memory: e.memory ?? "",
|
|
17346
|
-
middleware:
|
|
17401
|
+
middleware: ve.map((e) => e.name),
|
|
17347
17402
|
todos: (B.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
17348
17403
|
content: e.content,
|
|
17349
17404
|
status: e.status
|
|
17350
17405
|
})),
|
|
17351
17406
|
subagent: {
|
|
17352
|
-
enabled: !!
|
|
17407
|
+
enabled: !!ce,
|
|
17353
17408
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
17354
17409
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
17355
17410
|
allowedTools: e.subagent?.allowedTools ?? []
|
|
17356
17411
|
},
|
|
17357
17412
|
verify: {
|
|
17358
|
-
enabled: !!
|
|
17359
|
-
maxAttempts:
|
|
17360
|
-
adversarial:
|
|
17413
|
+
enabled: !!fe,
|
|
17414
|
+
maxAttempts: oe ? ae : 0,
|
|
17415
|
+
adversarial: oe && !!e.verify?.adversarial
|
|
17361
17416
|
},
|
|
17362
17417
|
mcp: { servers: B.mcpServers },
|
|
17363
17418
|
lastCompression: B.agent?.getState?.()?.lastCompression,
|
|
17364
|
-
checkpoints:
|
|
17419
|
+
checkpoints: x ? {
|
|
17365
17420
|
enabled: !0,
|
|
17366
|
-
auto:
|
|
17367
|
-
list:
|
|
17421
|
+
auto: S,
|
|
17422
|
+
list: x.list()
|
|
17368
17423
|
} : void 0
|
|
17369
17424
|
};
|
|
17370
17425
|
}
|
|
17371
17426
|
};
|
|
17372
|
-
async function
|
|
17373
|
-
if (!
|
|
17374
|
-
await
|
|
17427
|
+
async function be() {
|
|
17428
|
+
if (!l) return;
|
|
17429
|
+
await l.ready;
|
|
17375
17430
|
let t = e.session || {};
|
|
17376
17431
|
if (t.id) {
|
|
17377
17432
|
B.sessionId = t.id;
|
|
17378
|
-
let e = await
|
|
17379
|
-
e ? B.applySnapshot(e)
|
|
17433
|
+
let e = await l.load(r, B.sessionId);
|
|
17434
|
+
e ? (B.applySnapshot(e), ge({
|
|
17435
|
+
type: "session_restored",
|
|
17436
|
+
sessionId: B.sessionId,
|
|
17437
|
+
rounds: e.messages?.length ?? 0
|
|
17438
|
+
})) : await l.createSession(r, t.title, B.sessionId);
|
|
17380
17439
|
} else if (t.autoResume !== !1) {
|
|
17381
|
-
let n = await
|
|
17440
|
+
let n = await l.listSessions(r);
|
|
17382
17441
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", r, n.length, n.map((e) => e.sessionId)), n.length) {
|
|
17383
17442
|
B.sessionId = n[0].sessionId;
|
|
17384
|
-
let t = await
|
|
17385
|
-
t ? (B.applySnapshot(t),
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
e.
|
|
17393
|
-
}
|
|
17394
|
-
function
|
|
17395
|
-
|
|
17396
|
-
|
|
17397
|
-
|
|
17443
|
+
let t = await l.load(r, B.sessionId);
|
|
17444
|
+
t ? (B.applySnapshot(t), ge({
|
|
17445
|
+
type: "session_restored",
|
|
17446
|
+
sessionId: B.sessionId,
|
|
17447
|
+
rounds: t.messages?.length ?? 0
|
|
17448
|
+
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", B.sessionId, `${t.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", B.sessionId);
|
|
17449
|
+
} else B.sessionId = await l.createSession(r, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", B.sessionId);
|
|
17450
|
+
} else B.sessionId = await l.createSession(r, t.title);
|
|
17451
|
+
e.memory && l.save(r, B.sessionId, { memory: e.memory });
|
|
17452
|
+
}
|
|
17453
|
+
function xe() {
|
|
17454
|
+
let e = D_(p, ye);
|
|
17455
|
+
e.trimmed && p.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17456
|
+
}
|
|
17457
|
+
function Se() {
|
|
17458
|
+
if (!B.sessionId || !l) return;
|
|
17459
|
+
let t = JSON.parse(JSON.stringify(p));
|
|
17460
|
+
l.save(r, B.sessionId, { messages: t });
|
|
17398
17461
|
let n = B.agent?.getState?.()?.todos ?? [];
|
|
17399
|
-
|
|
17462
|
+
l.save(r, B.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", B.sessionId, `${p.length} msgs`);
|
|
17400
17463
|
}
|
|
17401
17464
|
return B.initDone = (async () => {
|
|
17402
|
-
if (await
|
|
17403
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
17465
|
+
if (await be(), e.mcp?.length) {
|
|
17466
|
+
let t = await Promise.allSettled(e.mcp.map((e) => C_(e)));
|
|
17404
17467
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
17405
17468
|
let n = [];
|
|
17406
17469
|
t.forEach((t, r) => {
|
|
@@ -17409,35 +17472,35 @@ function Ty(e, r) {
|
|
|
17409
17472
|
name: a,
|
|
17410
17473
|
url: i.url,
|
|
17411
17474
|
toolCount: t.value.tools.length
|
|
17412
|
-
}), t.value.tools.forEach((e) =>
|
|
17475
|
+
}), t.value.tools.forEach((e) => j.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17413
17476
|
}), I.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
17414
17477
|
}
|
|
17415
|
-
B.agent =
|
|
17416
|
-
...
|
|
17478
|
+
B.agent = xg({
|
|
17479
|
+
...by(e.llm) ? { llm: e.llm } : {
|
|
17417
17480
|
apiKey: e.llm.apiKey,
|
|
17418
17481
|
baseUrl: e.llm.baseUrl,
|
|
17419
17482
|
model: e.llm.model,
|
|
17420
17483
|
temperature: e.llm.temperature,
|
|
17421
17484
|
maxTokens: e.llm.maxTokens
|
|
17422
17485
|
},
|
|
17423
|
-
systemPrompt:
|
|
17486
|
+
systemPrompt: E,
|
|
17424
17487
|
tools: I,
|
|
17425
|
-
middleware:
|
|
17488
|
+
middleware: ve,
|
|
17426
17489
|
maxToolRounds: e.maxToolRounds,
|
|
17427
17490
|
maxRetries: e.maxRetries,
|
|
17428
17491
|
maxParallelTools: e.maxParallelTools,
|
|
17429
|
-
contextWindow:
|
|
17430
|
-
maxOutputTokens:
|
|
17431
|
-
maxVerifyAttempts:
|
|
17492
|
+
contextWindow: d.contextWindow,
|
|
17493
|
+
maxOutputTokens: d.maxOutputTokens,
|
|
17494
|
+
maxVerifyAttempts: oe ? ae : 0,
|
|
17432
17495
|
debug: e.debug
|
|
17433
|
-
}),
|
|
17496
|
+
}), _.current = B.agent;
|
|
17434
17497
|
})(), B;
|
|
17435
17498
|
}
|
|
17436
|
-
function
|
|
17437
|
-
let t = e.id ??
|
|
17499
|
+
function Dy(e) {
|
|
17500
|
+
let t = e.id ?? Gv();
|
|
17438
17501
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
17439
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
17440
|
-
a ? i = a : (i =
|
|
17502
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? xy.get(t) : void 0;
|
|
17503
|
+
a ? i = a : (i = Ey(e, t), e.shareContext && xy.set(t, i)), i.refCount++;
|
|
17441
17504
|
let o = null, s = null, c = null;
|
|
17442
17505
|
async function l() {
|
|
17443
17506
|
if (await i.initDone, r === !1) {
|
|
@@ -17472,7 +17535,7 @@ function Ey(e) {
|
|
|
17472
17535
|
i.afterRound(), i.store && await i.store.flush();
|
|
17473
17536
|
},
|
|
17474
17537
|
onClear: () => {
|
|
17475
|
-
i.store && (i.sessionId =
|
|
17538
|
+
i.store && (i.sessionId = Gv(), 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));
|
|
17476
17539
|
},
|
|
17477
17540
|
pendingConflict: i.pendingConflict.value,
|
|
17478
17541
|
onResolveConflict: (e) => i.resolveConflict(e)
|
|
@@ -17505,13 +17568,58 @@ function Ey(e) {
|
|
|
17505
17568
|
i.dataOpsController.set(e);
|
|
17506
17569
|
},
|
|
17507
17570
|
getData: () => i.liveData(),
|
|
17571
|
+
setSkills: (e) => {
|
|
17572
|
+
let t = i.skillsController;
|
|
17573
|
+
if (!t) {
|
|
17574
|
+
console.warn("[page-agent-sdk] setSkills 忽略:skills 已关闭(capabilities.skills:false)");
|
|
17575
|
+
return;
|
|
17576
|
+
}
|
|
17577
|
+
t.set(e);
|
|
17578
|
+
},
|
|
17579
|
+
invalidateSkillCache: (e) => {
|
|
17580
|
+
let t = i.skillsController;
|
|
17581
|
+
if (!t) {
|
|
17582
|
+
console.warn("[page-agent-sdk] invalidateSkillCache 忽略:skills 已关闭(capabilities.skills:false)");
|
|
17583
|
+
return;
|
|
17584
|
+
}
|
|
17585
|
+
t.invalidateCache(e);
|
|
17586
|
+
},
|
|
17587
|
+
exportData: () => {
|
|
17588
|
+
let e = i.liveData()?.bind;
|
|
17589
|
+
return e == null ? null : JSON.parse(JSON.stringify(e));
|
|
17590
|
+
},
|
|
17591
|
+
importData: (e, t) => {
|
|
17592
|
+
let n = i.liveData();
|
|
17593
|
+
if (!n || !i.dataOpsController) return {
|
|
17594
|
+
ok: !1,
|
|
17595
|
+
error: "dataOps 未开启或无主数据"
|
|
17596
|
+
};
|
|
17597
|
+
let r = n.bind;
|
|
17598
|
+
if (typeof r != "object" || !r) return {
|
|
17599
|
+
ok: !1,
|
|
17600
|
+
error: "主数据 bind 非对象,无法就地还原(集成方应用对象包裹)"
|
|
17601
|
+
};
|
|
17602
|
+
if (t?.validate !== !1) {
|
|
17603
|
+
let t = n.schema.safeParse(e);
|
|
17604
|
+
if (!t.success) return {
|
|
17605
|
+
ok: !1,
|
|
17606
|
+
error: "schema 校验失败:" + (t.error?.message ?? "未知错误")
|
|
17607
|
+
};
|
|
17608
|
+
}
|
|
17609
|
+
return Gg(r, e), t?.emit !== !1 && i.emit({
|
|
17610
|
+
type: "data_change",
|
|
17611
|
+
operation: "set",
|
|
17612
|
+
value: r
|
|
17613
|
+
}), { ok: !0 };
|
|
17614
|
+
},
|
|
17615
|
+
usage: i.usage,
|
|
17508
17616
|
pendingConflict: i.pendingConflict,
|
|
17509
17617
|
resolveConflict: (e) => i.resolveConflict(e)
|
|
17510
17618
|
};
|
|
17511
17619
|
}
|
|
17512
17620
|
//#endregion
|
|
17513
17621
|
//#region src/core/sdk/defineTool.ts
|
|
17514
|
-
function
|
|
17622
|
+
function Oy(e) {
|
|
17515
17623
|
return n(async (t) => {
|
|
17516
17624
|
let n = await e.handler(t);
|
|
17517
17625
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17522,4 +17630,4 @@ function Dy(e) {
|
|
|
17522
17630
|
});
|
|
17523
17631
|
}
|
|
17524
17632
|
//#endregion
|
|
17525
|
-
export {
|
|
17633
|
+
export { B_ as CONTEXT_PRESETS, Xh as ChatDialog, ef as CodePreview, Rg as HUMAN_CONFIRM_TOOL_NAME, nf as MessageContent, C_ as connectMcp, Sl as copyText, xg as createAgent, Lg as createApprovalMiddleware, Dy as createChatSdk, Jg as createCheckpointManager, Yg as createCheckpointMiddleware, Lv as createDataOps, Vg as createHumanConfirmMiddleware, Bg as createHumanConfirmTool, dy as createMemoryBackend, hy as createSessionStore, r_ as createSubagentMiddleware, o_ as createSubagentsMiddleware, Wv as createUsageHintsMiddleware, s_ as createVerifyMiddleware, K_ as createVfs, py as createWebStorageBackend, p_ as createWriteBackCheck, Vv as defineDataToolset, wg as defineSkill, Oy as defineTool, gg as detectGarbledToolCall, ig as estimateTokens, z_ as extractSchemaHint, b_ as extractText, zv as fetchDocTools, Bv as fetchTools, Iv as filterByToolMode, H_ as formatZodIssues, ry as isQuotaError, lv as jpEval, W_ as jsonParseError, og as offloadPassThroughChars, ag as offloadThresholdChars, L_ as presets, V_ as resolveContextOptions, rg as resolveModelCaps, mv as runSandboxedScript, dv as searchJson, Hv as selectBuiltinTools, R_ as systemPromptHelpers, $ as toolError, xl as useChat, e as z, U_ as zodError };
|