page-agent-sdk 2.16.0 → 2.17.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 +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/page-agent-sdk.iife.js +124 -122
- package/dist/page-agent-sdk.js +1298 -922
- package/dist/page-agent-sdk.umd.cjs +45 -43
- package/package.json +1 -1
- package/types/index.d.ts +48 -1
package/dist/page-agent-sdk.js
CHANGED
|
@@ -79,7 +79,7 @@ function y(e) {
|
|
|
79
79
|
var b = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), x = process.env.NODE_ENV === "production" ? [] : Object.freeze([]), S = () => {}, C = () => !1, w = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), T = (e) => e.startsWith("onUpdate:"), E = Object.assign, D = (e, t) => {
|
|
80
80
|
let n = e.indexOf(t);
|
|
81
81
|
n > -1 && e.splice(n, 1);
|
|
82
|
-
}, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray,
|
|
82
|
+
}, O = Object.prototype.hasOwnProperty, k = (e, t) => O.call(e, t), A = Array.isArray, ee = (e) => re(e) === "[object Map]", j = (e) => re(e) === "[object Set]", M = (e) => re(e) === "[object Date]", N = (e) => typeof e == "function", P = (e) => typeof e == "string", F = (e) => typeof e == "symbol", I = (e) => typeof e == "object" && !!e, te = (e) => (I(e) || N(e)) && N(e.then) && N(e.catch), ne = Object.prototype.toString, re = (e) => ne.call(e), ie = (e) => re(e).slice(8, -1), ae = (e) => re(e) === "[object Object]", oe = (e) => P(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, se = /* @__PURE__ */ y(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ce = /* @__PURE__ */ y("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), le = (e) => {
|
|
83
83
|
let t = /* @__PURE__ */ Object.create(null);
|
|
84
84
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
85
85
|
}, ue = /-\w/g, L = le((e) => e.replace(ue, (e) => e.slice(1).toUpperCase())), de = /\B([A-Z])/g, fe = le((e) => e.replace(de, "-$1").toLowerCase()), pe = le((e) => e.charAt(0).toUpperCase() + e.slice(1)), me = le((e) => e ? `on${pe(e)}` : ""), he = (e, t) => !Object.is(e, t), ge = (e, ...t) => {
|
|
@@ -142,7 +142,7 @@ function Fe(e, t) {
|
|
|
142
142
|
}
|
|
143
143
|
function Ie(e, t) {
|
|
144
144
|
if (e === t) return !0;
|
|
145
|
-
let n =
|
|
145
|
+
let n = M(e), r = M(t);
|
|
146
146
|
if (n || r) return n && r ? e.getTime() === t.getTime() : !1;
|
|
147
147
|
if (n = F(e), r = F(t), n || r) return e === t;
|
|
148
148
|
if (n = A(e), r = A(t), n || r) return n && r ? Fe(e, t) : !1;
|
|
@@ -155,7 +155,7 @@ function Ie(e, t) {
|
|
|
155
155
|
}
|
|
156
156
|
return String(e) === String(t);
|
|
157
157
|
}
|
|
158
|
-
var Le = (e) => !!(e && e.__v_isRef === !0), B = (e) => P(e) ? e : e == null ? "" : A(e) || I(e) && (e.toString === ne || !N(e.toString)) ? Le(e) ? B(e.value) : JSON.stringify(e, Re, 2) : String(e), Re = (e, t) => Le(t) ? Re(e, t.value) :
|
|
158
|
+
var Le = (e) => !!(e && e.__v_isRef === !0), B = (e) => P(e) ? e : e == null ? "" : A(e) || I(e) && (e.toString === ne || !N(e.toString)) ? Le(e) ? B(e.value) : JSON.stringify(e, Re, 2) : String(e), Re = (e, t) => Le(t) ? Re(e, t.value) : ee(t) ? { [`Map(${t.size})`]: [...t.entries()].reduce((e, [t, n], r) => (e[ze(t, r) + " =>"] = n, e), {}) } : j(t) ? { [`Set(${t.size})`]: [...t.values()].map((e) => ze(e)) } : F(t) ? ze(t) : I(t) && !A(t) && !ae(t) ? String(t) : t, ze = (e, t = "") => F(e) ? `Symbol(${e.description ?? t})` : e;
|
|
159
159
|
//#endregion
|
|
160
160
|
//#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
161
161
|
function Be(e, ...t) {
|
|
@@ -460,12 +460,12 @@ function vt(e, t, n, r, i, a) {
|
|
|
460
460
|
});
|
|
461
461
|
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(gt)), t) {
|
|
462
462
|
case "add":
|
|
463
|
-
i ? a && s(o.get("length")) : (s(o.get(mt)),
|
|
463
|
+
i ? a && s(o.get("length")) : (s(o.get(mt)), ee(e) && s(o.get(ht)));
|
|
464
464
|
break;
|
|
465
465
|
case "delete":
|
|
466
|
-
i || (s(o.get(mt)),
|
|
466
|
+
i || (s(o.get(mt)), ee(e) && s(o.get(ht)));
|
|
467
467
|
break;
|
|
468
|
-
case "set":
|
|
468
|
+
case "set": ee(e) && s(o.get(mt));
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
Ze();
|
|
@@ -676,7 +676,7 @@ var Mt = class {
|
|
|
676
676
|
}, Ft = /* @__PURE__ */ new Nt(), It = /* @__PURE__ */ new Pt(), Lt = /* @__PURE__ */ new Nt(!0), Rt = /* @__PURE__ */ new Pt(!0), zt = (e) => e, Bt = (e) => Reflect.getPrototypeOf(e);
|
|
677
677
|
function Vt(e, t, n) {
|
|
678
678
|
return function(...r) {
|
|
679
|
-
let i = this.__v_raw, a = /* @__PURE__ */ H(i), o =
|
|
679
|
+
let i = this.__v_raw, a = /* @__PURE__ */ H(i), o = ee(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? zt : t ? pn : fn;
|
|
680
680
|
return !t && _t(a, "iterate", c ? ht : mt), E(Object.create(l), { next() {
|
|
681
681
|
let { value: e, done: t } = l.next();
|
|
682
682
|
return t ? {
|
|
@@ -745,7 +745,7 @@ function Ut(e, t) {
|
|
|
745
745
|
return i && vt(t, "delete", e, void 0, a), o;
|
|
746
746
|
},
|
|
747
747
|
clear() {
|
|
748
|
-
let e = /* @__PURE__ */ H(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 :
|
|
748
|
+
let e = /* @__PURE__ */ H(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : ee(e) ? new Map(e) : new Set(e), r = e.clear();
|
|
749
749
|
return t && vt(e, "clear", void 0, void 0, n), r;
|
|
750
750
|
}
|
|
751
751
|
}), [
|
|
@@ -996,7 +996,7 @@ function On(e, t = Infinity, n) {
|
|
|
996
996
|
if (t <= 0 || !I(e) || e.__v_skip || (n ||= /* @__PURE__ */ new Map(), (n.get(e) || 0) >= t)) return e;
|
|
997
997
|
if (n.set(e, t), t--, /* @__PURE__ */ mn(e)) On(e.value, t, n);
|
|
998
998
|
else if (A(e)) for (let r = 0; r < e.length; r++) On(e[r], t, n);
|
|
999
|
-
else if (
|
|
999
|
+
else if (j(e) || ee(e)) e.forEach((e) => {
|
|
1000
1000
|
On(e, t, n);
|
|
1001
1001
|
});
|
|
1002
1002
|
else if (ae(e)) {
|
|
@@ -1981,25 +1981,25 @@ var la = !0;
|
|
|
1981
1981
|
function ua(e) {
|
|
1982
1982
|
let t = ma(e), n = e.proxy, r = e.ctx;
|
|
1983
1983
|
la = !1, t.beforeCreate && fa(t.beforeCreate, e, "bc");
|
|
1984
|
-
let { data: i, computed: a, methods: o, watch: s, provide: c, inject: l, created: u, beforeMount: d, mounted: f, beforeUpdate: p, updated: m, activated: h, deactivated: g, beforeDestroy: _, beforeUnmount: v, destroyed: y, unmounted: b, render: x, renderTracked: C, renderTriggered: w, errorCaptured: T, serverPrefetch: E, expose: D, inheritAttrs: O, components: k, directives:
|
|
1984
|
+
let { data: i, computed: a, methods: o, watch: s, provide: c, inject: l, created: u, beforeMount: d, mounted: f, beforeUpdate: p, updated: m, activated: h, deactivated: g, beforeDestroy: _, beforeUnmount: v, destroyed: y, unmounted: b, render: x, renderTracked: C, renderTriggered: w, errorCaptured: T, serverPrefetch: E, expose: D, inheritAttrs: O, components: k, directives: ee, filters: j } = t, M = process.env.NODE_ENV === "production" ? null : ca();
|
|
1985
1985
|
if (process.env.NODE_ENV !== "production") {
|
|
1986
1986
|
let [t] = e.propsOptions;
|
|
1987
|
-
if (t) for (let e in t)
|
|
1987
|
+
if (t) for (let e in t) M("Props", e);
|
|
1988
1988
|
}
|
|
1989
|
-
if (l && da(l, r,
|
|
1989
|
+
if (l && da(l, r, M), o) for (let e in o) {
|
|
1990
1990
|
let t = o[e];
|
|
1991
1991
|
N(t) ? (process.env.NODE_ENV === "production" ? r[e] = t.bind(n) : Object.defineProperty(r, e, {
|
|
1992
1992
|
value: t.bind(n),
|
|
1993
1993
|
configurable: !0,
|
|
1994
1994
|
enumerable: !0,
|
|
1995
1995
|
writable: !0
|
|
1996
|
-
}), process.env.NODE_ENV !== "production" &&
|
|
1996
|
+
}), process.env.NODE_ENV !== "production" && M("Methods", e)) : process.env.NODE_ENV !== "production" && G(`Method "${e}" has type "${typeof t}" in the component definition. Did you reference the function correctly?`);
|
|
1997
1997
|
}
|
|
1998
1998
|
if (i) {
|
|
1999
1999
|
process.env.NODE_ENV !== "production" && !N(i) && G("The data option must be a function. Plain object usage is no longer supported.");
|
|
2000
2000
|
let t = i.call(n, n);
|
|
2001
2001
|
if (process.env.NODE_ENV !== "production" && te(t) && G("data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>."), !I(t)) process.env.NODE_ENV !== "production" && G("data() should return an object.");
|
|
2002
|
-
else if (e.data = /* @__PURE__ */ tn(t), process.env.NODE_ENV !== "production") for (let e in t)
|
|
2002
|
+
else if (e.data = /* @__PURE__ */ tn(t), process.env.NODE_ENV !== "production") for (let e in t) M("Data", e), ta(e[0]) || Object.defineProperty(r, e, {
|
|
2003
2003
|
configurable: !0,
|
|
2004
2004
|
enumerable: !0,
|
|
2005
2005
|
get: () => t[e],
|
|
@@ -2020,7 +2020,7 @@ function ua(e) {
|
|
|
2020
2020
|
configurable: !0,
|
|
2021
2021
|
get: () => o.value,
|
|
2022
2022
|
set: (e) => o.value = e
|
|
2023
|
-
}), process.env.NODE_ENV !== "production" &&
|
|
2023
|
+
}), process.env.NODE_ENV !== "production" && M("Computed", e);
|
|
2024
2024
|
}
|
|
2025
2025
|
if (s) for (let e in s) pa(s[e], r, n, e);
|
|
2026
2026
|
if (c) {
|
|
@@ -2043,7 +2043,7 @@ function ua(e) {
|
|
|
2043
2043
|
});
|
|
2044
2044
|
});
|
|
2045
2045
|
} else e.exposed ||= {};
|
|
2046
|
-
x && e.render === S && (e.render = x), O != null && (e.inheritAttrs = O), k && (e.components = k),
|
|
2046
|
+
x && e.render === S && (e.render = x), O != null && (e.inheritAttrs = O), k && (e.components = k), ee && (e.directives = ee), E && Di(e);
|
|
2047
2047
|
}
|
|
2048
2048
|
function da(e, t, n = S) {
|
|
2049
2049
|
A(e) && (e = ya(e));
|
|
@@ -2651,9 +2651,9 @@ function Oo(e, t) {
|
|
|
2651
2651
|
e == null ? v(t, n, r, o) : process.env.NODE_ENV !== "production" && y(e, t, n, o);
|
|
2652
2652
|
break;
|
|
2653
2653
|
case K:
|
|
2654
|
-
|
|
2654
|
+
j(e, t, n, r, i, a, o, s, c);
|
|
2655
2655
|
break;
|
|
2656
|
-
default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ?
|
|
2656
|
+
default: d & 1 ? T(e, t, n, r, i, a, o, s, c) : d & 6 ? M(e, t, n, r, i, a, o, s, c) : d & 64 || d & 128 ? l.process(e, t, n, r, i, a, o, s, c, pe) : process.env.NODE_ENV !== "production" && G("Invalid VNode type:", l, `(${typeof l})`);
|
|
2657
2657
|
}
|
|
2658
2658
|
u != null && i ? ji(u, e && e.ref, a, t || e, !t) : u == null && e && e.ref != null && ji(e.ref, null, a, e, !0);
|
|
2659
2659
|
}, g = (e, t, n, i) => {
|
|
@@ -2730,7 +2730,7 @@ function Oo(e, t) {
|
|
|
2730
2730
|
l |= e.patchFlag & 16;
|
|
2731
2731
|
let p = e.props || b, m = t.props || b, h;
|
|
2732
2732
|
if (n && Ao(n, !1), (h = m.onVnodeBeforeUpdate) && ds(h, n, t, e), f && Hr(t, e, n, "beforeUpdate"), n && Ao(n, !0), (process.env.NODE_ENV !== "production" && cr || d && (!e.dynamicChildren || e.dynamicChildren.length !== d.length)) && (l = 0, s = !1, d = null), (p.innerHTML && m.innerHTML == null || p.textContent && m.textContent == null) && u(c, ""), d ? (A(e.dynamicChildren, d, c, n, r, ko(t, i), o), process.env.NODE_ENV !== "production" && Mo(e, t)) : s || te(e, t, c, null, n, r, ko(t, i), o, !1), l > 0) {
|
|
2733
|
-
if (l & 16)
|
|
2733
|
+
if (l & 16) ee(c, p, m, n, i);
|
|
2734
2734
|
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) {
|
|
2735
2735
|
let e = t.dynamicProps;
|
|
2736
2736
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -2739,7 +2739,7 @@ function Oo(e, t) {
|
|
|
2739
2739
|
}
|
|
2740
2740
|
}
|
|
2741
2741
|
l & 1 && e.children !== t.children && u(c, t.children);
|
|
2742
|
-
} else !s && d == null &&
|
|
2742
|
+
} else !s && d == null && ee(c, p, m, n, i);
|
|
2743
2743
|
((h = m.onVnodeUpdated) || f) && Eo(() => {
|
|
2744
2744
|
h && ds(h, n, t, e), f && Hr(t, e, n, "updated");
|
|
2745
2745
|
}, r);
|
|
@@ -2748,7 +2748,7 @@ function Oo(e, t) {
|
|
|
2748
2748
|
let c = e[s], l = t[s], u = c.el && (c.type === K || !Xo(c, l) || c.shapeFlag & 198) ? d(c.el) : n;
|
|
2749
2749
|
h(c, l, u, null, r, i, a, o, !0);
|
|
2750
2750
|
}
|
|
2751
|
-
},
|
|
2751
|
+
}, ee = (e, t, n, r, i) => {
|
|
2752
2752
|
if (t !== n) {
|
|
2753
2753
|
if (t !== b) for (let o in t) !se(o) && !(o in n) && a(e, o, t[o], null, i, r);
|
|
2754
2754
|
for (let o in n) {
|
|
@@ -2758,10 +2758,10 @@ function Oo(e, t) {
|
|
|
2758
2758
|
}
|
|
2759
2759
|
"value" in n && a(e, "value", t.value, n.value, i);
|
|
2760
2760
|
}
|
|
2761
|
-
},
|
|
2761
|
+
}, j = (e, t, n, i, a, o, c, l, u) => {
|
|
2762
2762
|
let d = t.el = e ? e.el : s(""), f = t.anchor = e ? e.anchor : s(""), { patchFlag: p, dynamicChildren: m, slotScopeIds: h } = t;
|
|
2763
2763
|
process.env.NODE_ENV !== "production" && (cr || p & 2048) && (p = 0, u = !1, m = null), h && (l = l ? l.concat(h) : h), e == null ? (r(d, n, i), r(f, n, i), O(t.children || [], n, f, a, o, c, l, u)) : p > 0 && p & 64 && m && e.dynamicChildren && e.dynamicChildren.length === m.length ? (A(e.dynamicChildren, m, n, a, o, c, l), process.env.NODE_ENV === "production" ? (t.key != null || a && t === a.subTree) && Mo(e, t, !0) : Mo(e, t)) : te(e, t, n, f, a, o, c, l, u);
|
|
2764
|
-
},
|
|
2764
|
+
}, M = (e, t, n, r, i, a, o, s, c) => {
|
|
2765
2765
|
t.slotScopeIds = s, e == null ? t.shapeFlag & 512 ? i.ctx.activate(t, n, r, o, c) : N(t, n, r, i, a, o, c) : P(e, t, c);
|
|
2766
2766
|
}, N = (e, t, n, r, i, a, o) => {
|
|
2767
2767
|
let s = e.component = ms(e, r, i);
|
|
@@ -5937,7 +5937,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
5937
5937
|
return i;
|
|
5938
5938
|
}).map((e) => `(${e})`).join(t);
|
|
5939
5939
|
}
|
|
5940
|
-
var w = /\b\B/, T = "[a-zA-Z]\\w*", E = "[a-zA-Z_]\\w*", D = "\\b\\d+(\\.\\d+)?", O = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", k = "\\b(0b[01]+)", A = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",
|
|
5940
|
+
var w = /\b\B/, T = "[a-zA-Z]\\w*", E = "[a-zA-Z_]\\w*", D = "\\b\\d+(\\.\\d+)?", O = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)", k = "\\b(0b[01]+)", A = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~", ee = (e = {}) => {
|
|
5941
5941
|
let t = /^#![ ]*\//;
|
|
5942
5942
|
return e.binary && (e.begin = _(t, /.*\b/, e.binary, /\b.*/)), a({
|
|
5943
5943
|
scope: "meta",
|
|
@@ -5948,21 +5948,21 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
5948
5948
|
e.index !== 0 && t.ignoreMatch();
|
|
5949
5949
|
}
|
|
5950
5950
|
}, e);
|
|
5951
|
-
},
|
|
5951
|
+
}, j = {
|
|
5952
5952
|
begin: "\\\\[\\s\\S]",
|
|
5953
5953
|
relevance: 0
|
|
5954
|
-
},
|
|
5954
|
+
}, M = {
|
|
5955
5955
|
scope: "string",
|
|
5956
5956
|
begin: "'",
|
|
5957
5957
|
end: "'",
|
|
5958
5958
|
illegal: "\\n",
|
|
5959
|
-
contains: [
|
|
5959
|
+
contains: [j]
|
|
5960
5960
|
}, N = {
|
|
5961
5961
|
scope: "string",
|
|
5962
5962
|
begin: "\"",
|
|
5963
5963
|
end: "\"",
|
|
5964
5964
|
illegal: "\\n",
|
|
5965
|
-
contains: [
|
|
5965
|
+
contains: [j]
|
|
5966
5966
|
}, P = { begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/ }, F = function(e, t, n = {}) {
|
|
5967
5967
|
let r = a({
|
|
5968
5968
|
scope: "comment",
|
|
@@ -5981,8 +5981,8 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
5981
5981
|
return r.contains.push({ begin: _(/[ ]+/, "(", i, /[.]?[:]?([.][ ]|[ ])/, "){3}") }), r;
|
|
5982
5982
|
}, I = F("//", "$"), te = F("/\\*", "\\*/"), ne = F("#", "$"), re = /*#__PURE__*/ Object.freeze({
|
|
5983
5983
|
__proto__: null,
|
|
5984
|
-
APOS_STRING_MODE:
|
|
5985
|
-
BACKSLASH_ESCAPE:
|
|
5984
|
+
APOS_STRING_MODE: M,
|
|
5985
|
+
BACKSLASH_ESCAPE: j,
|
|
5986
5986
|
BINARY_NUMBER_MODE: {
|
|
5987
5987
|
scope: "number",
|
|
5988
5988
|
begin: k,
|
|
@@ -6027,15 +6027,15 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6027
6027
|
scope: "regexp",
|
|
6028
6028
|
begin: /\/(?=[^/\n]*\/)/,
|
|
6029
6029
|
end: /\/[gimuy]*/,
|
|
6030
|
-
contains: [
|
|
6030
|
+
contains: [j, {
|
|
6031
6031
|
begin: /\[/,
|
|
6032
6032
|
end: /\]/,
|
|
6033
6033
|
relevance: 0,
|
|
6034
|
-
contains: [
|
|
6034
|
+
contains: [j]
|
|
6035
6035
|
}]
|
|
6036
6036
|
},
|
|
6037
6037
|
RE_STARTERS_RE: A,
|
|
6038
|
-
SHEBANG:
|
|
6038
|
+
SHEBANG: ee,
|
|
6039
6039
|
TITLE_MODE: {
|
|
6040
6040
|
scope: "title",
|
|
6041
6041
|
begin: T,
|
|
@@ -6260,10 +6260,10 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6260
6260
|
t += e.parentNode ? e.parentNode.className : "";
|
|
6261
6261
|
let n = l.languageDetectRe.exec(t);
|
|
6262
6262
|
if (n) {
|
|
6263
|
-
let t =
|
|
6263
|
+
let t = M(n[1]);
|
|
6264
6264
|
return t || (_e(s.replace("{}", n[1])), _e("Falling back to no-highlight mode for this block.", e)), t ? n[1] : "no-highlight";
|
|
6265
6265
|
}
|
|
6266
|
-
return t.split(/\s+/).find((e) => u(e) ||
|
|
6266
|
+
return t.split(/\s+/).find((e) => u(e) || M(e));
|
|
6267
6267
|
}
|
|
6268
6268
|
function p(e, t, n) {
|
|
6269
6269
|
let r = "", i = "";
|
|
@@ -6283,7 +6283,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6283
6283
|
}
|
|
6284
6284
|
function d() {
|
|
6285
6285
|
if (!A.keywords) {
|
|
6286
|
-
|
|
6286
|
+
j.addText(N);
|
|
6287
6287
|
return;
|
|
6288
6288
|
}
|
|
6289
6289
|
let e = 0;
|
|
@@ -6294,7 +6294,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6294
6294
|
let r = D.case_insensitive ? t[0].toLowerCase() : t[0], i = u(A, r);
|
|
6295
6295
|
if (i) {
|
|
6296
6296
|
let [e, a] = i;
|
|
6297
|
-
if (
|
|
6297
|
+
if (j.addText(n), n = "", c[r] = (c[r] || 0) + 1, c[r] <= je && (P += a), e.startsWith("_")) n += t[0];
|
|
6298
6298
|
else {
|
|
6299
6299
|
let n = D.classNameAliases[e] || e;
|
|
6300
6300
|
m(t[0], n);
|
|
@@ -6302,25 +6302,25 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6302
6302
|
} else n += t[0];
|
|
6303
6303
|
e = A.keywordPatternRe.lastIndex, t = A.keywordPatternRe.exec(N);
|
|
6304
6304
|
}
|
|
6305
|
-
n += N.substring(e),
|
|
6305
|
+
n += N.substring(e), j.addText(n);
|
|
6306
6306
|
}
|
|
6307
6307
|
function f() {
|
|
6308
6308
|
if (N === "") return;
|
|
6309
6309
|
let e = null;
|
|
6310
6310
|
if (typeof A.subLanguage == "string") {
|
|
6311
6311
|
if (!t[A.subLanguage]) {
|
|
6312
|
-
|
|
6312
|
+
j.addText(N);
|
|
6313
6313
|
return;
|
|
6314
6314
|
}
|
|
6315
|
-
e = v(A.subLanguage, N, !0,
|
|
6315
|
+
e = v(A.subLanguage, N, !0, ee[A.subLanguage]), ee[A.subLanguage] = e._top;
|
|
6316
6316
|
} else e = S(N, A.subLanguage.length ? A.subLanguage : null);
|
|
6317
|
-
A.relevance > 0 && (P += e.relevance),
|
|
6317
|
+
A.relevance > 0 && (P += e.relevance), j.__addSublanguage(e._emitter, e.language);
|
|
6318
6318
|
}
|
|
6319
6319
|
function p() {
|
|
6320
6320
|
A.subLanguage == null ? d() : f(), N = "";
|
|
6321
6321
|
}
|
|
6322
6322
|
function m(e, t) {
|
|
6323
|
-
e !== "" && (
|
|
6323
|
+
e !== "" && (j.startScope(t), j.addText(e), j.endScope());
|
|
6324
6324
|
}
|
|
6325
6325
|
function h(e, t) {
|
|
6326
6326
|
let n = 1, r = t.length - 1;
|
|
@@ -6334,7 +6334,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6334
6334
|
}
|
|
6335
6335
|
}
|
|
6336
6336
|
function g(e, t) {
|
|
6337
|
-
return e.scope && typeof e.scope == "string" &&
|
|
6337
|
+
return e.scope && typeof e.scope == "string" && j.openNode(D.classNameAliases[e.scope] || e.scope), e.beginScope && (e.beginScope._wrap ? (m(N, D.classNameAliases[e.beginScope._wrap] || e.beginScope._wrap), N = "") : e.beginScope._multi && (h(e.beginScope, t), N = "")), A = Object.create(e, { parent: { value: A } }), A;
|
|
6338
6338
|
}
|
|
6339
6339
|
function _(e, t, n) {
|
|
6340
6340
|
let i = x(e.endRe, n);
|
|
@@ -6364,14 +6364,14 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6364
6364
|
let a = A;
|
|
6365
6365
|
A.endScope && A.endScope._wrap ? (p(), m(t, A.endScope._wrap)) : A.endScope && A.endScope._multi ? (p(), h(A.endScope, e)) : a.skip ? N += t : (a.returnEnd || a.excludeEnd || (N += t), p(), a.excludeEnd && (N = t));
|
|
6366
6366
|
do
|
|
6367
|
-
A.scope &&
|
|
6367
|
+
A.scope && j.closeNode(), !A.skip && !A.subLanguage && (P += A.relevance), A = A.parent;
|
|
6368
6368
|
while (A !== i.parent);
|
|
6369
6369
|
return i.starts && g(i.starts, e), a.returnEnd ? 0 : t.length;
|
|
6370
6370
|
}
|
|
6371
6371
|
function w() {
|
|
6372
6372
|
let e = [];
|
|
6373
6373
|
for (let t = A; t !== D; t = t.parent) t.scope && e.unshift(t.scope);
|
|
6374
|
-
e.forEach((e) =>
|
|
6374
|
+
e.forEach((e) => j.openNode(e));
|
|
6375
6375
|
}
|
|
6376
6376
|
let T = {};
|
|
6377
6377
|
function E(t, r) {
|
|
@@ -6397,13 +6397,13 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6397
6397
|
if (I > 1e5 && I > r.index * 3) throw /* @__PURE__ */ Error("potential infinite loop, way more iterations than matches");
|
|
6398
6398
|
return N += a, a.length;
|
|
6399
6399
|
}
|
|
6400
|
-
let D =
|
|
6400
|
+
let D = M(e);
|
|
6401
6401
|
if (!D) throw ge(s.replace("{}", e)), Error("Unknown language: \"" + e + "\"");
|
|
6402
|
-
let O = Te(D), k = "", A = a || O,
|
|
6402
|
+
let O = Te(D), k = "", A = a || O, ee = {}, j = new l.__emitter(l);
|
|
6403
6403
|
w();
|
|
6404
6404
|
let N = "", P = 0, F = 0, I = 0, te = !1;
|
|
6405
6405
|
try {
|
|
6406
|
-
if (D.__emitTokens) D.__emitTokens(n,
|
|
6406
|
+
if (D.__emitTokens) D.__emitTokens(n, j);
|
|
6407
6407
|
else {
|
|
6408
6408
|
for (A.matcher.considerAll();;) {
|
|
6409
6409
|
I++, te ? te = !1 : A.matcher.considerAll(), A.matcher.lastIndex = F;
|
|
@@ -6414,12 +6414,12 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6414
6414
|
}
|
|
6415
6415
|
E(n.substring(F));
|
|
6416
6416
|
}
|
|
6417
|
-
return
|
|
6417
|
+
return j.finalize(), k = j.toHTML(), {
|
|
6418
6418
|
language: e,
|
|
6419
6419
|
value: k,
|
|
6420
6420
|
relevance: P,
|
|
6421
6421
|
illegal: !1,
|
|
6422
|
-
_emitter:
|
|
6422
|
+
_emitter: j,
|
|
6423
6423
|
_top: A
|
|
6424
6424
|
};
|
|
6425
6425
|
} catch (t) {
|
|
@@ -6435,7 +6435,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6435
6435
|
mode: t.mode,
|
|
6436
6436
|
resultSoFar: k
|
|
6437
6437
|
},
|
|
6438
|
-
_emitter:
|
|
6438
|
+
_emitter: j
|
|
6439
6439
|
};
|
|
6440
6440
|
if (o) return {
|
|
6441
6441
|
language: e,
|
|
@@ -6443,7 +6443,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6443
6443
|
illegal: !1,
|
|
6444
6444
|
relevance: 0,
|
|
6445
6445
|
errorRaised: t,
|
|
6446
|
-
_emitter:
|
|
6446
|
+
_emitter: j,
|
|
6447
6447
|
_top: A
|
|
6448
6448
|
};
|
|
6449
6449
|
throw t;
|
|
@@ -6461,13 +6461,13 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6461
6461
|
}
|
|
6462
6462
|
function S(e, n) {
|
|
6463
6463
|
n = n || l.languages || Object.keys(t);
|
|
6464
|
-
let r = b(e), i = n.filter(
|
|
6464
|
+
let r = b(e), i = n.filter(M).filter(P).map((t) => v(t, e, !1));
|
|
6465
6465
|
i.unshift(r);
|
|
6466
6466
|
let [a, o] = i.sort((e, t) => {
|
|
6467
6467
|
if (e.relevance !== t.relevance) return t.relevance - e.relevance;
|
|
6468
6468
|
if (e.language && t.language) {
|
|
6469
|
-
if (
|
|
6470
|
-
if (
|
|
6469
|
+
if (M(e.language).supersetOf === t.language) return 1;
|
|
6470
|
+
if (M(t.language).supersetOf === e.language) return -1;
|
|
6471
6471
|
}
|
|
6472
6472
|
return 0;
|
|
6473
6473
|
}), s = a;
|
|
@@ -6537,14 +6537,14 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6537
6537
|
}
|
|
6538
6538
|
i.name || (i.name = n), t[n] = i, i.rawDefinition = r.bind(null, e), i.aliases && N(i.aliases, { languageName: n });
|
|
6539
6539
|
}
|
|
6540
|
-
function
|
|
6540
|
+
function ee(e) {
|
|
6541
6541
|
delete t[e];
|
|
6542
6542
|
for (let t of Object.keys(i)) i[t] === e && delete i[t];
|
|
6543
6543
|
}
|
|
6544
|
-
function
|
|
6544
|
+
function j() {
|
|
6545
6545
|
return Object.keys(t);
|
|
6546
6546
|
}
|
|
6547
|
-
function
|
|
6547
|
+
function M(e) {
|
|
6548
6548
|
return e = (e || "").toLowerCase(), t[e] || t[i[e]];
|
|
6549
6549
|
}
|
|
6550
6550
|
function N(e, { languageName: t }) {
|
|
@@ -6553,7 +6553,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6553
6553
|
});
|
|
6554
6554
|
}
|
|
6555
6555
|
function P(e) {
|
|
6556
|
-
let t =
|
|
6556
|
+
let t = M(e);
|
|
6557
6557
|
return t && !t.disableAutodetect;
|
|
6558
6558
|
}
|
|
6559
6559
|
function F(e) {
|
|
@@ -6589,9 +6589,9 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
6589
6589
|
initHighlighting: E,
|
|
6590
6590
|
initHighlightingOnLoad: D,
|
|
6591
6591
|
registerLanguage: A,
|
|
6592
|
-
unregisterLanguage:
|
|
6593
|
-
listLanguages:
|
|
6594
|
-
getLanguage:
|
|
6592
|
+
unregisterLanguage: ee,
|
|
6593
|
+
listLanguages: j,
|
|
6594
|
+
getLanguage: M,
|
|
6595
6595
|
registerAliases: N,
|
|
6596
6596
|
autoDetection: P,
|
|
6597
6597
|
inherit: Ae,
|
|
@@ -8903,17 +8903,17 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
8903
8903
|
1: "keyword",
|
|
8904
8904
|
3: "title.class"
|
|
8905
8905
|
}
|
|
8906
|
-
}] },
|
|
8906
|
+
}] }, ee = {
|
|
8907
8907
|
relevance: 0,
|
|
8908
8908
|
match: t.either(/\bJSON/, /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
|
|
8909
8909
|
className: "title.class",
|
|
8910
8910
|
keywords: { _: [...a, ...o] }
|
|
8911
|
-
},
|
|
8911
|
+
}, j = {
|
|
8912
8912
|
label: "use_strict",
|
|
8913
8913
|
className: "meta",
|
|
8914
8914
|
relevance: 10,
|
|
8915
8915
|
begin: /^\s*['"]use (strict|asm)['"]/
|
|
8916
|
-
},
|
|
8916
|
+
}, M = {
|
|
8917
8917
|
variants: [{ match: [
|
|
8918
8918
|
/function/,
|
|
8919
8919
|
/\s+/,
|
|
@@ -8990,7 +8990,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
8990
8990
|
keywords: h,
|
|
8991
8991
|
exports: {
|
|
8992
8992
|
PARAMS_CONTAINS: O,
|
|
8993
|
-
CLASS_REFERENCE:
|
|
8993
|
+
CLASS_REFERENCE: ee
|
|
8994
8994
|
},
|
|
8995
8995
|
illegal: /#(?![$_A-z])/,
|
|
8996
8996
|
contains: [
|
|
@@ -8999,7 +8999,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
8999
8999
|
binary: "node",
|
|
9000
9000
|
relevance: 5
|
|
9001
9001
|
}),
|
|
9002
|
-
|
|
9002
|
+
j,
|
|
9003
9003
|
e.APOS_STRING_MODE,
|
|
9004
9004
|
e.QUOTE_STRING_MODE,
|
|
9005
9005
|
x,
|
|
@@ -9009,7 +9009,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
9009
9009
|
T,
|
|
9010
9010
|
{ match: /\$\d+/ },
|
|
9011
9011
|
y,
|
|
9012
|
-
|
|
9012
|
+
ee,
|
|
9013
9013
|
{
|
|
9014
9014
|
scope: "attr",
|
|
9015
9015
|
match: d + t.lookahead(":"),
|
|
@@ -9082,7 +9082,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
9082
9082
|
}
|
|
9083
9083
|
]
|
|
9084
9084
|
},
|
|
9085
|
-
|
|
9085
|
+
M,
|
|
9086
9086
|
{ beginKeywords: "while if switch catch for" },
|
|
9087
9087
|
{
|
|
9088
9088
|
begin: "\\b(?!function)" + e.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
|
|
@@ -11360,16 +11360,16 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11360
11360
|
}], A = {
|
|
11361
11361
|
match: /->/,
|
|
11362
11362
|
relevance: 0
|
|
11363
|
-
},
|
|
11363
|
+
}, ee = [A, {
|
|
11364
11364
|
className: "operator",
|
|
11365
11365
|
relevance: 0,
|
|
11366
11366
|
variants: [{ match: v }, { match: `\\.(\\.|${_})+` }]
|
|
11367
|
-
}],
|
|
11367
|
+
}], j = "([0-9]_*)+", M = "([0-9a-fA-F]_*)+", N = {
|
|
11368
11368
|
className: "number",
|
|
11369
11369
|
relevance: 0,
|
|
11370
11370
|
variants: [
|
|
11371
|
-
{ match: `\\b(${
|
|
11372
|
-
{ match: `\\b0x(${
|
|
11371
|
+
{ match: `\\b(${j})(\\.(${j}))?([eE][+-]?(${j}))?\\b` },
|
|
11372
|
+
{ match: `\\b0x(${M})(\\.(${M}))?([pP][+-]?(${j}))?\\b` },
|
|
11373
11373
|
{ match: /\b0o([0-7]_*)+\b/ },
|
|
11374
11374
|
{ match: /\b0b([01]_*)+\b/ }
|
|
11375
11375
|
]
|
|
@@ -11455,7 +11455,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11455
11455
|
end: /\)/,
|
|
11456
11456
|
keywords: w,
|
|
11457
11457
|
contains: [
|
|
11458
|
-
...
|
|
11458
|
+
...ee,
|
|
11459
11459
|
N,
|
|
11460
11460
|
re
|
|
11461
11461
|
]
|
|
@@ -11524,7 +11524,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11524
11524
|
se,
|
|
11525
11525
|
...O,
|
|
11526
11526
|
...k,
|
|
11527
|
-
...
|
|
11527
|
+
...ee,
|
|
11528
11528
|
N,
|
|
11529
11529
|
re,
|
|
11530
11530
|
...le,
|
|
@@ -11555,7 +11555,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11555
11555
|
},
|
|
11556
11556
|
...a,
|
|
11557
11557
|
...O,
|
|
11558
|
-
...
|
|
11558
|
+
...ee,
|
|
11559
11559
|
N,
|
|
11560
11560
|
re,
|
|
11561
11561
|
...ue,
|
|
@@ -11668,7 +11668,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11668
11668
|
let n = [
|
|
11669
11669
|
...O,
|
|
11670
11670
|
...k,
|
|
11671
|
-
...
|
|
11671
|
+
...ee,
|
|
11672
11672
|
N,
|
|
11673
11673
|
re,
|
|
11674
11674
|
...le
|
|
@@ -11700,7 +11700,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
11700
11700
|
se,
|
|
11701
11701
|
...O,
|
|
11702
11702
|
...k,
|
|
11703
|
-
...
|
|
11703
|
+
...ee,
|
|
11704
11704
|
N,
|
|
11705
11705
|
re,
|
|
11706
11706
|
...le,
|
|
@@ -12076,17 +12076,17 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
12076
12076
|
1: "keyword",
|
|
12077
12077
|
3: "title.class"
|
|
12078
12078
|
}
|
|
12079
|
-
}] },
|
|
12079
|
+
}] }, ee = {
|
|
12080
12080
|
relevance: 0,
|
|
12081
12081
|
match: t.either(/\bJSON/, /\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/, /\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/, /\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),
|
|
12082
12082
|
className: "title.class",
|
|
12083
12083
|
keywords: { _: [...a, ...o] }
|
|
12084
|
-
},
|
|
12084
|
+
}, j = {
|
|
12085
12085
|
label: "use_strict",
|
|
12086
12086
|
className: "meta",
|
|
12087
12087
|
relevance: 10,
|
|
12088
12088
|
begin: /^\s*['"]use (strict|asm)['"]/
|
|
12089
|
-
},
|
|
12089
|
+
}, M = {
|
|
12090
12090
|
variants: [{ match: [
|
|
12091
12091
|
/function/,
|
|
12092
12092
|
/\s+/,
|
|
@@ -12163,7 +12163,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
12163
12163
|
keywords: h,
|
|
12164
12164
|
exports: {
|
|
12165
12165
|
PARAMS_CONTAINS: O,
|
|
12166
|
-
CLASS_REFERENCE:
|
|
12166
|
+
CLASS_REFERENCE: ee
|
|
12167
12167
|
},
|
|
12168
12168
|
illegal: /#(?![$_A-z])/,
|
|
12169
12169
|
contains: [
|
|
@@ -12172,7 +12172,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
12172
12172
|
binary: "node",
|
|
12173
12173
|
relevance: 5
|
|
12174
12174
|
}),
|
|
12175
|
-
|
|
12175
|
+
j,
|
|
12176
12176
|
e.APOS_STRING_MODE,
|
|
12177
12177
|
e.QUOTE_STRING_MODE,
|
|
12178
12178
|
x,
|
|
@@ -12182,7 +12182,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
12182
12182
|
T,
|
|
12183
12183
|
{ match: /\$\d+/ },
|
|
12184
12184
|
y,
|
|
12185
|
-
|
|
12185
|
+
ee,
|
|
12186
12186
|
{
|
|
12187
12187
|
scope: "attr",
|
|
12188
12188
|
match: d + t.lookahead(":"),
|
|
@@ -12255,7 +12255,7 @@ var rd = /* @__PURE__ */ m(((e, t) => {
|
|
|
12255
12255
|
}
|
|
12256
12256
|
]
|
|
12257
12257
|
},
|
|
12258
|
-
|
|
12258
|
+
M,
|
|
12259
12259
|
{ beginKeywords: "while if switch catch for" },
|
|
12260
12260
|
{
|
|
12261
12261
|
begin: "\\b(?!function)" + e.UNDERSCORE_IDENT_RE + "\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",
|
|
@@ -13566,12 +13566,12 @@ app.mount('#app');
|
|
|
13566
13566
|
function C() {
|
|
13567
13567
|
n.onUndo?.() && (i.error = null);
|
|
13568
13568
|
}
|
|
13569
|
-
let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U(!1), O = /* @__PURE__ */ U({}), k = Vs(() => i.messages.length > 0), A = Vs(() => i.messages.some((e) => e.role === "user")),
|
|
13570
|
-
function
|
|
13569
|
+
let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U(!1), O = /* @__PURE__ */ U({}), k = Vs(() => i.messages.length > 0), A = Vs(() => i.messages.some((e) => e.role === "user")), ee = Vs(() => (n.debugLogs?.length ?? 0) > 0);
|
|
13570
|
+
function j(e) {
|
|
13571
13571
|
return O.value[e] !== !1;
|
|
13572
13572
|
}
|
|
13573
|
-
function
|
|
13574
|
-
O.value[e] = !
|
|
13573
|
+
function M(e) {
|
|
13574
|
+
O.value[e] = !j(e);
|
|
13575
13575
|
}
|
|
13576
13576
|
function N(e) {
|
|
13577
13577
|
return e.status === "running" ? "⏳" : e.status === "error" ? "❌" : "✅";
|
|
@@ -13665,7 +13665,7 @@ app.mount('#app');
|
|
|
13665
13665
|
Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
|
|
13666
13666
|
Y("path", { d: "M9 2h6" }),
|
|
13667
13667
|
Y("path", { d: "M9 18h6" })
|
|
13668
|
-
], -1),
|
|
13668
|
+
], -1), ee.value ? (q(), J("span", ph, B(e.debugLogs?.length), 1)) : X("", !0)], 2),
|
|
13669
13669
|
n.onAddSkill ? (q(), J("button", {
|
|
13670
13670
|
key: 0,
|
|
13671
13671
|
class: R(["action-btn", { active: D.value }]),
|
|
@@ -13726,15 +13726,15 @@ app.mount('#app');
|
|
|
13726
13726
|
}, [e.showAvatar ? (q(), J("div", bh, B(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", xh, [
|
|
13727
13727
|
t.role === "assistant" && t.reasoning ? (q(), J("div", {
|
|
13728
13728
|
key: 0,
|
|
13729
|
-
class: R(["reasoning-block", { expanded:
|
|
13729
|
+
class: R(["reasoning-block", { expanded: j(n) }])
|
|
13730
13730
|
}, [Y("div", {
|
|
13731
13731
|
class: "reasoning-header",
|
|
13732
|
-
onClick: (e) =>
|
|
13732
|
+
onClick: (e) => M(n)
|
|
13733
13733
|
}, [
|
|
13734
13734
|
s[29] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13735
13735
|
s[30] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13736
|
-
Y("span", Ch, B(
|
|
13737
|
-
], 8, Sh),
|
|
13736
|
+
Y("span", Ch, B(j(n) ? "▾" : "▸"), 1)
|
|
13737
|
+
], 8, Sh), j(n) ? (q(), J("div", wh, B(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13738
13738
|
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", Th, [(q(!0), J(K, null, Qi(P(t.steps), (e, t) => (q(), J("div", {
|
|
13739
13739
|
key: t,
|
|
13740
13740
|
class: "step-item"
|
|
@@ -13926,19 +13926,73 @@ app.mount('#app');
|
|
|
13926
13926
|
], 6)], 64));
|
|
13927
13927
|
}
|
|
13928
13928
|
}), [["__scopeId", "data-v-58dec249"]]);
|
|
13929
|
+
//#endregion
|
|
13930
|
+
//#region src/core/tools/toolError.ts
|
|
13931
|
+
function $(e) {
|
|
13932
|
+
let t = {
|
|
13933
|
+
error: e.code,
|
|
13934
|
+
message: e.message
|
|
13935
|
+
};
|
|
13936
|
+
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)}`;
|
|
13937
|
+
}
|
|
13929
13938
|
function bg(e) {
|
|
13939
|
+
return e.slice(0, 10).map((e) => {
|
|
13940
|
+
let t = e, n = {
|
|
13941
|
+
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
13942
|
+
message: t.message
|
|
13943
|
+
};
|
|
13944
|
+
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;
|
|
13945
|
+
});
|
|
13946
|
+
}
|
|
13947
|
+
function xg(e, t) {
|
|
13948
|
+
return $({
|
|
13949
|
+
code: "SCHEMA_INVALID",
|
|
13950
|
+
path: e,
|
|
13951
|
+
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
13952
|
+
hint: `用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,
|
|
13953
|
+
details: bg(t)
|
|
13954
|
+
});
|
|
13955
|
+
}
|
|
13956
|
+
function Sg(e, t, n) {
|
|
13957
|
+
let r = n?.message || String(n);
|
|
13958
|
+
return $({
|
|
13959
|
+
code: "JSON_PARSE",
|
|
13960
|
+
...e === void 0 ? {} : { path: e },
|
|
13961
|
+
message: `value 不是合法 JSON:${r}`,
|
|
13962
|
+
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
13963
|
+
});
|
|
13964
|
+
}
|
|
13965
|
+
function Cg(e) {
|
|
13966
|
+
return e.severity === "recoverable" ? "feedback" : e.severity === "fatal" ? "abort" : "log";
|
|
13967
|
+
}
|
|
13968
|
+
function wg(e, t = "fatal") {
|
|
13969
|
+
return e && typeof e == "object" && "severity" in e && typeof e.severity == "string" && "message" in e ? e : {
|
|
13970
|
+
severity: t,
|
|
13971
|
+
message: e instanceof Error ? e.message : String(e),
|
|
13972
|
+
context: e
|
|
13973
|
+
};
|
|
13974
|
+
}
|
|
13975
|
+
function Tg(e, t, n, r) {
|
|
13976
|
+
return {
|
|
13977
|
+
severity: e,
|
|
13978
|
+
message: t,
|
|
13979
|
+
code: n,
|
|
13980
|
+
context: r
|
|
13981
|
+
};
|
|
13982
|
+
}
|
|
13983
|
+
function Eg(e) {
|
|
13930
13984
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13931
13985
|
}
|
|
13932
|
-
function
|
|
13986
|
+
function Dg(e) {
|
|
13933
13987
|
let t = 5381;
|
|
13934
13988
|
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
13935
13989
|
return (t >>> 0).toString(36);
|
|
13936
13990
|
}
|
|
13937
|
-
function
|
|
13991
|
+
function Og(e, t) {
|
|
13938
13992
|
let n = t.threshold ?? 6e3;
|
|
13939
13993
|
if (e.length <= n) return { content: e };
|
|
13940
13994
|
if (t.vfsAvailable && t.files) {
|
|
13941
|
-
let n = `large_results/${t.toolName}-${
|
|
13995
|
+
let n = `large_results/${t.toolName}-${Dg(e)}.txt`, r = Eg(n);
|
|
13942
13996
|
t.files[r] = {
|
|
13943
13997
|
content: e,
|
|
13944
13998
|
updatedAt: Date.now()
|
|
@@ -13967,7 +14021,7 @@ function Sg(e, t) {
|
|
|
13967
14021
|
}
|
|
13968
14022
|
//#endregion
|
|
13969
14023
|
//#region src/core/utils/pool.ts
|
|
13970
|
-
async function
|
|
14024
|
+
async function kg(e, t, n, r) {
|
|
13971
14025
|
let i = Array(e.length), a = Math.max(1, t);
|
|
13972
14026
|
if (a === 1) {
|
|
13973
14027
|
for (let t = 0; t < e.length && !r?.aborted; t++) i[t] = await n(e[t], t);
|
|
@@ -13984,7 +14038,7 @@ async function Cg(e, t, n, r) {
|
|
|
13984
14038
|
}
|
|
13985
14039
|
//#endregion
|
|
13986
14040
|
//#region src/core/utils/modelCaps.ts
|
|
13987
|
-
var
|
|
14041
|
+
var Ag = [
|
|
13988
14042
|
{
|
|
13989
14043
|
pattern: /deepseek-v4/i,
|
|
13990
14044
|
caps: {
|
|
@@ -14146,34 +14200,42 @@ var wg = [
|
|
|
14146
14200
|
maxOutputTokens: 4096
|
|
14147
14201
|
}
|
|
14148
14202
|
}
|
|
14149
|
-
],
|
|
14203
|
+
], jg = {
|
|
14150
14204
|
contextWindow: 32768,
|
|
14151
14205
|
maxOutputTokens: 4096
|
|
14152
14206
|
};
|
|
14153
|
-
function
|
|
14207
|
+
function Mg(e = {}) {
|
|
14154
14208
|
let t = (() => {
|
|
14155
|
-
if (e.model) return
|
|
14209
|
+
if (!e.model) return;
|
|
14210
|
+
let t = Ag.map((t) => {
|
|
14211
|
+
let n = t.pattern.exec(e.model);
|
|
14212
|
+
return n ? {
|
|
14213
|
+
caps: t.caps,
|
|
14214
|
+
matchedLen: n[0].length
|
|
14215
|
+
} : null;
|
|
14216
|
+
}).filter((e) => e !== null);
|
|
14217
|
+
if (t.length) return t.sort((e, t) => t.matchedLen - e.matchedLen), t[0].caps;
|
|
14156
14218
|
})();
|
|
14157
14219
|
return {
|
|
14158
|
-
contextWindow: e.contextWindow ?? t?.contextWindow ??
|
|
14159
|
-
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ??
|
|
14220
|
+
contextWindow: e.contextWindow ?? t?.contextWindow ?? jg.contextWindow,
|
|
14221
|
+
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ?? jg.maxOutputTokens
|
|
14160
14222
|
};
|
|
14161
14223
|
}
|
|
14162
|
-
function
|
|
14224
|
+
function Ng(e) {
|
|
14163
14225
|
if (!e) return 0;
|
|
14164
14226
|
let t = (e.match(/[\u4e00-\u9fff]/g) || []).length, n = e.length - t;
|
|
14165
14227
|
return Math.ceil(t * 1.5 + n * .25);
|
|
14166
14228
|
}
|
|
14167
|
-
function
|
|
14229
|
+
function Pg(e) {
|
|
14168
14230
|
return Math.max(2e3, Math.min(2e4, Math.round(e * .035)));
|
|
14169
14231
|
}
|
|
14170
|
-
function
|
|
14171
|
-
let t =
|
|
14232
|
+
function Fg(e) {
|
|
14233
|
+
let t = Pg(e);
|
|
14172
14234
|
return Math.min(2e5, Math.max(t, Math.round(e * .7)));
|
|
14173
14235
|
}
|
|
14174
14236
|
//#endregion
|
|
14175
14237
|
//#region src/core/harness/state.ts
|
|
14176
|
-
function
|
|
14238
|
+
function Ig() {
|
|
14177
14239
|
return {
|
|
14178
14240
|
messages: [],
|
|
14179
14241
|
todos: [],
|
|
@@ -14186,42 +14248,42 @@ function Ag() {
|
|
|
14186
14248
|
}
|
|
14187
14249
|
//#endregion
|
|
14188
14250
|
//#region src/core/harness/middleware.ts
|
|
14189
|
-
function
|
|
14251
|
+
function Lg(e, t) {
|
|
14190
14252
|
return t ? {
|
|
14191
14253
|
...e,
|
|
14192
14254
|
...t
|
|
14193
14255
|
} : e;
|
|
14194
14256
|
}
|
|
14195
|
-
async function
|
|
14257
|
+
async function Rg(e, t) {
|
|
14196
14258
|
let n = t;
|
|
14197
|
-
for (let t of e) t.beforeAgent && (n =
|
|
14259
|
+
for (let t of e) t.beforeAgent && (n = Lg(n, await t.beforeAgent(n)));
|
|
14198
14260
|
return n;
|
|
14199
14261
|
}
|
|
14200
|
-
function
|
|
14262
|
+
function zg(e, t) {
|
|
14201
14263
|
let n = t.state;
|
|
14202
|
-
for (let r of e) r.beforeModel && (n =
|
|
14264
|
+
for (let r of e) r.beforeModel && (n = Lg(n, r.beforeModel({
|
|
14203
14265
|
messages: t.messages,
|
|
14204
14266
|
state: n
|
|
14205
14267
|
})));
|
|
14206
14268
|
return n;
|
|
14207
14269
|
}
|
|
14208
|
-
function
|
|
14270
|
+
function Bg(e, t, n) {
|
|
14209
14271
|
let r = n;
|
|
14210
14272
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
14211
14273
|
let i = e[n];
|
|
14212
|
-
i.afterModel && (r =
|
|
14274
|
+
i.afterModel && (r = Lg(r, i.afterModel(t, r)));
|
|
14213
14275
|
}
|
|
14214
14276
|
return r;
|
|
14215
14277
|
}
|
|
14216
|
-
async function
|
|
14278
|
+
async function Vg(e, t) {
|
|
14217
14279
|
let n = t;
|
|
14218
14280
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
14219
14281
|
let r = e[t];
|
|
14220
|
-
r.afterAgent && (n =
|
|
14282
|
+
r.afterAgent && (n = Lg(n, await r.afterAgent(n)));
|
|
14221
14283
|
}
|
|
14222
14284
|
return n;
|
|
14223
14285
|
}
|
|
14224
|
-
async function
|
|
14286
|
+
async function Hg(e, t) {
|
|
14225
14287
|
let n = [];
|
|
14226
14288
|
for (let r of e) {
|
|
14227
14289
|
if (!r.beforeReturn) continue;
|
|
@@ -14230,19 +14292,19 @@ async function Ig(e, t) {
|
|
|
14230
14292
|
}
|
|
14231
14293
|
return n.length ? n.join("\n\n") : null;
|
|
14232
14294
|
}
|
|
14233
|
-
function
|
|
14295
|
+
function Ug(e, t) {
|
|
14234
14296
|
return e.reduceRight((e, t) => (n) => t.wrapModelCall ? t.wrapModelCall(n, e) : e(n), t);
|
|
14235
14297
|
}
|
|
14236
|
-
function
|
|
14298
|
+
function Wg(e, t) {
|
|
14237
14299
|
return e.reduceRight((e, t) => (n) => t.wrapToolCall ? t.wrapToolCall(n, e) : e(n), t);
|
|
14238
14300
|
}
|
|
14239
14301
|
//#endregion
|
|
14240
14302
|
//#region src/core/harness/createAgent.ts
|
|
14241
|
-
function
|
|
14303
|
+
function Gg(e) {
|
|
14242
14304
|
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
14243
14305
|
}
|
|
14244
|
-
var
|
|
14245
|
-
function
|
|
14306
|
+
var Kg = 10, qg = 300, Jg = 6e3;
|
|
14307
|
+
function Yg(e, t) {
|
|
14246
14308
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
14247
14309
|
if (n <= t) return e;
|
|
14248
14310
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -14257,56 +14319,59 @@ function Ug(e, t) {
|
|
|
14257
14319
|
});
|
|
14258
14320
|
});
|
|
14259
14321
|
}
|
|
14260
|
-
function
|
|
14261
|
-
|
|
14322
|
+
function Xg(e, t) {
|
|
14323
|
+
return t ?? Math.max(e * 3, 30);
|
|
14324
|
+
}
|
|
14325
|
+
function Zg(e) {
|
|
14326
|
+
let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, extraBody: d, extraConfig: f, systemPrompt: p, tools: m = [], middleware: h = [], maxToolRounds: g = Kg, maxIterations: _, maxRetries: v = 2, retryDelayMs: y = 500, maxParallelTools: b = 1, maxVerifyAttempts: x = 0, onLog: S, onLlmChange: C, debug: w = !1 } = e, T = Mg({
|
|
14262
14327
|
model: c,
|
|
14263
14328
|
contextWindow: e.contextWindow,
|
|
14264
14329
|
maxOutputTokens: e.maxOutputTokens
|
|
14265
|
-
}),
|
|
14266
|
-
function
|
|
14330
|
+
}), E = u ?? T.maxOutputTokens, D = Pg(T.contextWindow), O = Fg(T.contextWindow), k = /* @__PURE__ */ hn([]);
|
|
14331
|
+
function A(e, t) {
|
|
14267
14332
|
let n = {
|
|
14268
14333
|
timestamp: Date.now(),
|
|
14269
14334
|
type: e,
|
|
14270
14335
|
data: t
|
|
14271
14336
|
};
|
|
14272
|
-
|
|
14337
|
+
k.value.push(n), k.value.length > qg && k.value.splice(0, k.value.length - qg), vn(k), S?.(n), w && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
14273
14338
|
}
|
|
14274
|
-
let
|
|
14275
|
-
|
|
14339
|
+
let ee = (e) => {
|
|
14340
|
+
k.value.push(e), k.value.length > qg && k.value.splice(0, k.value.length - qg), vn(k);
|
|
14276
14341
|
}, j = [...h.flatMap((e) => e.tools || []), ...m], M = e.llm ?? new n({
|
|
14277
14342
|
apiKey: t,
|
|
14278
14343
|
model: c,
|
|
14279
14344
|
temperature: l,
|
|
14280
|
-
maxTokens:
|
|
14345
|
+
maxTokens: E,
|
|
14281
14346
|
configuration: {
|
|
14282
14347
|
...r ? { baseURL: r } : {},
|
|
14283
14348
|
...f
|
|
14284
14349
|
},
|
|
14285
14350
|
...d ? { modelKwargs: d } : {}
|
|
14286
|
-
}),
|
|
14287
|
-
function
|
|
14288
|
-
|
|
14351
|
+
}), N = j.length > 0 ? M.bindTools?.(j) ?? M : M;
|
|
14352
|
+
function P() {
|
|
14353
|
+
N = j.length > 0 ? M.bindTools?.(j) ?? M : M;
|
|
14289
14354
|
}
|
|
14290
|
-
let
|
|
14291
|
-
function
|
|
14355
|
+
let F = Ig();
|
|
14356
|
+
function I() {
|
|
14292
14357
|
let e = [p || "你是一个智能助手。"];
|
|
14293
14358
|
for (let t of h) if (t.augmentPrompt) {
|
|
14294
|
-
let n = t.augmentPrompt(
|
|
14359
|
+
let n = t.augmentPrompt(F);
|
|
14295
14360
|
n && e.push(n);
|
|
14296
14361
|
}
|
|
14297
14362
|
return e.join("\n\n");
|
|
14298
14363
|
}
|
|
14299
|
-
function
|
|
14300
|
-
let t = [new o(
|
|
14364
|
+
function te(e) {
|
|
14365
|
+
let t = [new o(I())];
|
|
14301
14366
|
for (let n of e) n.role === "user" ? t.push(new a(n.content)) : n.role === "assistant" ? t.push(new i(n.content)) : n.role === "system" && t.push(new o(n.content));
|
|
14302
14367
|
return t;
|
|
14303
14368
|
}
|
|
14304
|
-
function
|
|
14305
|
-
let t = e.filter((e) =>
|
|
14306
|
-
return [new o(
|
|
14369
|
+
function ne(e) {
|
|
14370
|
+
let t = e.filter((e) => ae(e) !== "system");
|
|
14371
|
+
return [new o(I()), ...t];
|
|
14307
14372
|
}
|
|
14308
|
-
async function
|
|
14309
|
-
let a = r ??
|
|
14373
|
+
async function re(e, t, n, r) {
|
|
14374
|
+
let a = r ?? N;
|
|
14310
14375
|
return Sl(async () => {
|
|
14311
14376
|
let r = null, o = "";
|
|
14312
14377
|
try {
|
|
@@ -14341,20 +14406,20 @@ function Wg(e) {
|
|
|
14341
14406
|
};
|
|
14342
14407
|
}, {
|
|
14343
14408
|
signal: n,
|
|
14344
|
-
maxRetries:
|
|
14345
|
-
baseDelayMs:
|
|
14409
|
+
maxRetries: v,
|
|
14410
|
+
baseDelayMs: y,
|
|
14346
14411
|
onRetry: ({ attempt: e, error: t, waitMs: n }) => {
|
|
14347
14412
|
let r = t?.message ?? String(t);
|
|
14348
|
-
|
|
14413
|
+
A("error", {
|
|
14349
14414
|
stage: "model_retry",
|
|
14350
14415
|
attempt: e,
|
|
14351
14416
|
waitMs: n,
|
|
14352
14417
|
error: r
|
|
14353
|
-
}), console.warn(`[Agent] 模型调用失败,第 ${e}/${
|
|
14418
|
+
}), console.warn(`[Agent] 模型调用失败,第 ${e}/${v} 次重试(等 ${n}ms):${r}`);
|
|
14354
14419
|
}
|
|
14355
14420
|
});
|
|
14356
14421
|
}
|
|
14357
|
-
async function
|
|
14422
|
+
async function ie(e) {
|
|
14358
14423
|
let t = j.find((t) => t.name === e.name);
|
|
14359
14424
|
if (!t) return {
|
|
14360
14425
|
content: `工具 "${e.name}" 不存在`,
|
|
@@ -14362,33 +14427,33 @@ function Wg(e) {
|
|
|
14362
14427
|
};
|
|
14363
14428
|
try {
|
|
14364
14429
|
let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
|
|
14365
|
-
return r =
|
|
14430
|
+
return r = Og(r, {
|
|
14366
14431
|
files: e.state.files,
|
|
14367
14432
|
vfsAvailable: j.some((e) => e.name === "vfs_read"),
|
|
14368
14433
|
toolName: e.name,
|
|
14369
|
-
threshold:
|
|
14370
|
-
passThroughChars:
|
|
14434
|
+
threshold: D,
|
|
14435
|
+
passThroughChars: O
|
|
14371
14436
|
}).content, {
|
|
14372
14437
|
content: r,
|
|
14373
14438
|
status: "done"
|
|
14374
14439
|
};
|
|
14375
14440
|
} catch (e) {
|
|
14376
14441
|
return {
|
|
14377
|
-
content: `工具执行出错:${e.message}`,
|
|
14442
|
+
content: `工具执行出错:${wg(e, "recoverable").message}`,
|
|
14378
14443
|
status: "error"
|
|
14379
14444
|
};
|
|
14380
14445
|
}
|
|
14381
14446
|
}
|
|
14382
|
-
function
|
|
14447
|
+
function ae(e) {
|
|
14383
14448
|
return e instanceof a ? "human" : e instanceof i ? "ai" : e instanceof o ? "system" : e instanceof s ? "tool" : "unknown";
|
|
14384
14449
|
}
|
|
14385
|
-
function
|
|
14386
|
-
return
|
|
14450
|
+
function oe(e, t) {
|
|
14451
|
+
return Yg(e, t);
|
|
14387
14452
|
}
|
|
14388
|
-
function
|
|
14453
|
+
function se(e) {
|
|
14389
14454
|
return e.map((e) => {
|
|
14390
|
-
let t =
|
|
14391
|
-
r && (n.content = r.length >
|
|
14455
|
+
let t = ae(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
14456
|
+
r && (n.content = r.length > Jg ? r.slice(0, Jg) + `…(截断 ${r.length - Jg} 字符)` : r);
|
|
14392
14457
|
let i = e.tool_calls;
|
|
14393
14458
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
14394
14459
|
id: e.id,
|
|
@@ -14402,71 +14467,71 @@ function Wg(e) {
|
|
|
14402
14467
|
return a && (n.tool_call_id = a), n;
|
|
14403
14468
|
});
|
|
14404
14469
|
}
|
|
14405
|
-
async function
|
|
14406
|
-
|
|
14470
|
+
async function ce(e, t, n) {
|
|
14471
|
+
k.value = [], F = Ig(), F.messages = e, F = await Rg(h, F);
|
|
14407
14472
|
let r = e;
|
|
14408
14473
|
for (let e of h) if (e.compressInput) {
|
|
14409
14474
|
let t = await e.compressInput(r);
|
|
14410
|
-
r = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (
|
|
14411
|
-
...
|
|
14475
|
+
r = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (F = {
|
|
14476
|
+
...F,
|
|
14412
14477
|
lastCompression: t.stats
|
|
14413
14478
|
});
|
|
14414
14479
|
}
|
|
14415
|
-
let i =
|
|
14416
|
-
|
|
14480
|
+
let i = te(r);
|
|
14481
|
+
A("context", {
|
|
14417
14482
|
model: c,
|
|
14418
14483
|
tools: j.map((e) => e.name),
|
|
14419
14484
|
middleware: h.map((e) => e.name)
|
|
14420
14485
|
});
|
|
14421
|
-
let l =
|
|
14486
|
+
let l = Ug(h, (e) => re(e, t, n)), u = Wg(h, ie), d = 0, f = 0, p = Xg(g, _), m = null, v = 0;
|
|
14422
14487
|
try {
|
|
14423
|
-
for (; d < g && !n?.aborted;) {
|
|
14488
|
+
for (; d < g && f < p && (f++, !n?.aborted);) {
|
|
14424
14489
|
t({
|
|
14425
14490
|
type: "round_start",
|
|
14426
|
-
round:
|
|
14427
|
-
}),
|
|
14491
|
+
round: f
|
|
14492
|
+
}), F = zg(h, {
|
|
14428
14493
|
messages: i,
|
|
14429
|
-
state:
|
|
14430
|
-
}), i =
|
|
14494
|
+
state: F
|
|
14495
|
+
}), i = ne(i), i = oe(i, O), A("llm_request", {
|
|
14431
14496
|
round: d + 1,
|
|
14432
14497
|
model: c,
|
|
14433
14498
|
tools: j.map((e) => e.name),
|
|
14434
|
-
messages:
|
|
14499
|
+
messages: se(i)
|
|
14435
14500
|
});
|
|
14436
14501
|
let e = await l({
|
|
14437
14502
|
messages: i,
|
|
14438
|
-
state:
|
|
14503
|
+
state: F
|
|
14439
14504
|
});
|
|
14440
|
-
if (i.push(e.message),
|
|
14505
|
+
if (i.push(e.message), A("llm_response", {
|
|
14441
14506
|
round: d + 1,
|
|
14442
14507
|
content: e.content,
|
|
14443
14508
|
toolCalls: e.toolCalls
|
|
14444
|
-
}),
|
|
14509
|
+
}), F = Bg(h, e, F), e.aborted) return t({
|
|
14445
14510
|
type: "done",
|
|
14446
14511
|
content: e.content
|
|
14447
14512
|
}), e.content;
|
|
14448
14513
|
if (!e.toolCalls.length) {
|
|
14449
|
-
if (
|
|
14450
|
-
|
|
14514
|
+
if (v < 2 && Gg(e.content)) {
|
|
14515
|
+
v += 1, A("middleware", {
|
|
14451
14516
|
stage: "format_retry",
|
|
14452
|
-
attempt:
|
|
14517
|
+
attempt: v,
|
|
14453
14518
|
content: e.content.slice(0, 200)
|
|
14454
|
-
}), i.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签,如 <|tool_calls|>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。"))
|
|
14519
|
+
}), i.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签,如 <|tool_calls|>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。"));
|
|
14455
14520
|
continue;
|
|
14456
14521
|
}
|
|
14457
|
-
if (
|
|
14458
|
-
let t = await
|
|
14522
|
+
if (x > 0 && F.verifyAttempts < x) {
|
|
14523
|
+
let t = await Hg(h, {
|
|
14459
14524
|
messages: i,
|
|
14460
|
-
state:
|
|
14525
|
+
state: F,
|
|
14461
14526
|
response: e,
|
|
14462
|
-
log: (e, t) =>
|
|
14527
|
+
log: (e, t) => A(e, t)
|
|
14463
14528
|
});
|
|
14464
14529
|
if (t) {
|
|
14465
|
-
|
|
14530
|
+
m = e.content, F.verifyAttempts += 1, i.push(new a(`⚠️ 验证未通过,请修正:${t}`)), A("middleware", {
|
|
14466
14531
|
stage: "verify_retry",
|
|
14467
|
-
attempt:
|
|
14532
|
+
attempt: F.verifyAttempts,
|
|
14468
14533
|
feedback: t
|
|
14469
|
-
})
|
|
14534
|
+
});
|
|
14470
14535
|
continue;
|
|
14471
14536
|
}
|
|
14472
14537
|
}
|
|
@@ -14484,19 +14549,19 @@ function Wg(e) {
|
|
|
14484
14549
|
id: r,
|
|
14485
14550
|
name: e.name,
|
|
14486
14551
|
args: e.args,
|
|
14487
|
-
state:
|
|
14552
|
+
state: F,
|
|
14488
14553
|
signal: n,
|
|
14489
14554
|
emit: t,
|
|
14490
|
-
logSink:
|
|
14555
|
+
logSink: ee
|
|
14491
14556
|
}
|
|
14492
14557
|
};
|
|
14493
|
-
}), o = await
|
|
14558
|
+
}), o = await kg(r, b, async (e) => {
|
|
14494
14559
|
if (n?.aborted) return;
|
|
14495
14560
|
t({
|
|
14496
14561
|
type: "tool_call",
|
|
14497
14562
|
name: e.call.name,
|
|
14498
14563
|
args: e.call.args
|
|
14499
|
-
}),
|
|
14564
|
+
}), A("tool_call", {
|
|
14500
14565
|
round: d + 1,
|
|
14501
14566
|
name: e.call.name,
|
|
14502
14567
|
args: e.call.args,
|
|
@@ -14508,7 +14573,7 @@ function Wg(e) {
|
|
|
14508
14573
|
name: e.call.name,
|
|
14509
14574
|
result: r.content,
|
|
14510
14575
|
status: r.status
|
|
14511
|
-
}),
|
|
14576
|
+
}), A("tool_result", {
|
|
14512
14577
|
round: d + 1,
|
|
14513
14578
|
name: e.call.name,
|
|
14514
14579
|
result: r.content,
|
|
@@ -14529,24 +14594,24 @@ function Wg(e) {
|
|
|
14529
14594
|
type: "done",
|
|
14530
14595
|
content: ""
|
|
14531
14596
|
}), "";
|
|
14532
|
-
if (
|
|
14597
|
+
if (m != null) return t({
|
|
14533
14598
|
type: "done",
|
|
14534
|
-
content:
|
|
14535
|
-
}),
|
|
14599
|
+
content: m
|
|
14600
|
+
}), m;
|
|
14536
14601
|
let e = i[i.length - 1];
|
|
14537
|
-
if (e &&
|
|
14538
|
-
let e = i.filter((e) =>
|
|
14539
|
-
|
|
14602
|
+
if (e && ae(e) === "tool") {
|
|
14603
|
+
let e = i.filter((e) => ae(e) !== "system"), r = [new o(I() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
14604
|
+
A("llm_request", {
|
|
14540
14605
|
round: "wrap_up",
|
|
14541
14606
|
model: c,
|
|
14542
14607
|
tools: [],
|
|
14543
|
-
messages:
|
|
14608
|
+
messages: se(r)
|
|
14544
14609
|
});
|
|
14545
|
-
let a = await
|
|
14610
|
+
let a = await re({
|
|
14546
14611
|
messages: r,
|
|
14547
|
-
state:
|
|
14612
|
+
state: F
|
|
14548
14613
|
}, t, n, M);
|
|
14549
|
-
if (
|
|
14614
|
+
if (A("llm_response", {
|
|
14550
14615
|
round: "wrap_up",
|
|
14551
14616
|
content: a.content
|
|
14552
14617
|
}), a.aborted || a.content) return t({
|
|
@@ -14554,53 +14619,55 @@ function Wg(e) {
|
|
|
14554
14619
|
content: a.content
|
|
14555
14620
|
}), a.content;
|
|
14556
14621
|
}
|
|
14557
|
-
let r = "
|
|
14622
|
+
let r = "我已完成本轮能做的操作,但未能综合出最终结论。请基于上方已完成的工具操作结果继续,或告诉我下一步重点。";
|
|
14558
14623
|
return t({
|
|
14559
14624
|
type: "done",
|
|
14560
14625
|
content: r
|
|
14561
14626
|
}), r;
|
|
14562
14627
|
} finally {
|
|
14563
14628
|
try {
|
|
14564
|
-
await
|
|
14629
|
+
await Vg(h, F);
|
|
14565
14630
|
} catch (e) {
|
|
14566
|
-
|
|
14631
|
+
let t = wg(e, "observable");
|
|
14632
|
+
console.warn("[Agent] afterAgent 清理出错(observable,已忽略):", t.message);
|
|
14567
14633
|
}
|
|
14568
14634
|
}
|
|
14569
14635
|
}
|
|
14570
|
-
async function
|
|
14636
|
+
async function le(e, t) {
|
|
14571
14637
|
let n = "";
|
|
14572
|
-
return await
|
|
14638
|
+
return await ce(e, (e) => {
|
|
14573
14639
|
e.type === "done" && (n = e.content);
|
|
14574
14640
|
}, t), n;
|
|
14575
14641
|
}
|
|
14576
|
-
function le(e) {
|
|
14577
|
-
j = [...h.flatMap((e) => e.tools || []), ...e], N();
|
|
14578
|
-
}
|
|
14579
14642
|
function ue(e) {
|
|
14580
|
-
|
|
14643
|
+
j = [...h.flatMap((e) => e.tools || []), ...e], P();
|
|
14644
|
+
}
|
|
14645
|
+
function L(e) {
|
|
14646
|
+
M = e, P(), C?.(e);
|
|
14581
14647
|
}
|
|
14582
14648
|
return {
|
|
14583
|
-
invoke:
|
|
14584
|
-
stream:
|
|
14585
|
-
getState: () =>
|
|
14649
|
+
invoke: le,
|
|
14650
|
+
stream: ce,
|
|
14651
|
+
getState: () => F,
|
|
14586
14652
|
get allTools() {
|
|
14587
14653
|
return j;
|
|
14588
14654
|
},
|
|
14589
|
-
setTools:
|
|
14590
|
-
setLlm:
|
|
14591
|
-
debugLogs:
|
|
14655
|
+
setTools: ue,
|
|
14656
|
+
setLlm: L,
|
|
14657
|
+
debugLogs: k,
|
|
14658
|
+
getEffectiveSystemPrompt: () => I()
|
|
14592
14659
|
};
|
|
14593
14660
|
}
|
|
14594
14661
|
//#endregion
|
|
14595
14662
|
//#region src/core/harness/todos.ts
|
|
14596
|
-
function
|
|
14663
|
+
function Qg(e) {
|
|
14597
14664
|
if (e.length) return [
|
|
14598
14665
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14599
14666
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14600
14667
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14601
14668
|
].join("\n");
|
|
14602
14669
|
}
|
|
14603
|
-
function
|
|
14670
|
+
function $g(e = []) {
|
|
14604
14671
|
let n = e.map((e) => ({ ...e })), i = 0;
|
|
14605
14672
|
return {
|
|
14606
14673
|
name: "todos",
|
|
@@ -14618,7 +14685,7 @@ function Kg(e = []) {
|
|
|
14618
14685
|
})],
|
|
14619
14686
|
beforeAgent: () => ({ todos: n }),
|
|
14620
14687
|
beforeModel: () => (i = 0, { todos: n }),
|
|
14621
|
-
augmentPrompt: () =>
|
|
14688
|
+
augmentPrompt: () => Qg(n),
|
|
14622
14689
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14623
14690
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14624
14691
|
status: "error"
|
|
@@ -14630,18 +14697,18 @@ function Kg(e = []) {
|
|
|
14630
14697
|
}
|
|
14631
14698
|
//#endregion
|
|
14632
14699
|
//#region src/core/harness/skills.ts
|
|
14633
|
-
function
|
|
14700
|
+
function e_(e) {
|
|
14634
14701
|
return e;
|
|
14635
14702
|
}
|
|
14636
|
-
var
|
|
14637
|
-
function
|
|
14638
|
-
return
|
|
14703
|
+
var t_ = /^https?:\/\//i;
|
|
14704
|
+
function n_(e) {
|
|
14705
|
+
return t_.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14639
14706
|
}
|
|
14640
|
-
function
|
|
14707
|
+
function r_(e) {
|
|
14641
14708
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14642
14709
|
}
|
|
14643
|
-
async function
|
|
14644
|
-
if (
|
|
14710
|
+
async function i_(e, t) {
|
|
14711
|
+
if (n_(e) === "http") try {
|
|
14645
14712
|
let t = await fetch(e);
|
|
14646
14713
|
return t.ok ? {
|
|
14647
14714
|
ok: !0,
|
|
@@ -14664,7 +14731,7 @@ async function Zg(e, t) {
|
|
|
14664
14731
|
ok: !1,
|
|
14665
14732
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14666
14733
|
};
|
|
14667
|
-
let n = t(
|
|
14734
|
+
let n = t(r_(e));
|
|
14668
14735
|
return n == null ? {
|
|
14669
14736
|
ok: !1,
|
|
14670
14737
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14673,14 +14740,14 @@ async function Zg(e, t) {
|
|
|
14673
14740
|
content: n
|
|
14674
14741
|
};
|
|
14675
14742
|
}
|
|
14676
|
-
function
|
|
14743
|
+
function a_(e) {
|
|
14677
14744
|
if (e.length) return [
|
|
14678
14745
|
"## 可用 Skills(渐进式披露)",
|
|
14679
14746
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14680
14747
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14681
14748
|
].join("\n");
|
|
14682
14749
|
}
|
|
14683
|
-
function
|
|
14750
|
+
function o_(e, n) {
|
|
14684
14751
|
let i = [...e], a = new Map(i.map((e) => [e.name, e])), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = {
|
|
14685
14752
|
set(e) {
|
|
14686
14753
|
i = [...e], a = new Map(i.map((e) => [e.name, e])), s.clear(), o.clear();
|
|
@@ -14697,7 +14764,7 @@ function $g(e, n) {
|
|
|
14697
14764
|
let r = s.get(e);
|
|
14698
14765
|
if (r != null) return r;
|
|
14699
14766
|
if (t.doc) {
|
|
14700
|
-
let e = await
|
|
14767
|
+
let e = await i_(t.doc, n?.readVfs);
|
|
14701
14768
|
if (!e.ok) return null;
|
|
14702
14769
|
r = e.content;
|
|
14703
14770
|
} else if (t.getContent) r = await t.getContent();
|
|
@@ -14713,7 +14780,7 @@ function $g(e, n) {
|
|
|
14713
14780
|
let r = s.get(e);
|
|
14714
14781
|
if (r == null) {
|
|
14715
14782
|
if (t.doc) {
|
|
14716
|
-
let i = await
|
|
14783
|
+
let i = await i_(t.doc, n?.readVfs);
|
|
14717
14784
|
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14718
14785
|
r = i.content;
|
|
14719
14786
|
} else if (t.getContent) r = await t.getContent();
|
|
@@ -14733,7 +14800,7 @@ function $g(e, n) {
|
|
|
14733
14800
|
})),
|
|
14734
14801
|
skillsLoaded: []
|
|
14735
14802
|
}),
|
|
14736
|
-
augmentPrompt: () =>
|
|
14803
|
+
augmentPrompt: () => a_(i),
|
|
14737
14804
|
afterModel: () => ({ skillsLoaded: [...o] })
|
|
14738
14805
|
};
|
|
14739
14806
|
return Object.defineProperty(l, "controller", {
|
|
@@ -14745,7 +14812,7 @@ function $g(e, n) {
|
|
|
14745
14812
|
}
|
|
14746
14813
|
//#endregion
|
|
14747
14814
|
//#region src/core/harness/memory.ts
|
|
14748
|
-
function
|
|
14815
|
+
function s_(e = "") {
|
|
14749
14816
|
let t = e, n = typeof e == "string" ? e : void 0;
|
|
14750
14817
|
async function r() {
|
|
14751
14818
|
if (typeof t == "string") return n = t, t;
|
|
@@ -14769,14 +14836,14 @@ function e_(e = "") {
|
|
|
14769
14836
|
}
|
|
14770
14837
|
//#endregion
|
|
14771
14838
|
//#region src/core/harness/permissions.ts
|
|
14772
|
-
var
|
|
14839
|
+
var c_ = /* @__PURE__ */ new Set([
|
|
14773
14840
|
"set_data",
|
|
14774
14841
|
"edit_data",
|
|
14775
14842
|
"delete_data",
|
|
14776
14843
|
"write",
|
|
14777
14844
|
"vfs_write",
|
|
14778
14845
|
"vfs_edit"
|
|
14779
|
-
]),
|
|
14846
|
+
]), l_ = /* @__PURE__ */ new Set([
|
|
14780
14847
|
"get_data",
|
|
14781
14848
|
"describe_data",
|
|
14782
14849
|
"read",
|
|
@@ -14787,7 +14854,7 @@ var t_ = /* @__PURE__ */ new Set([
|
|
|
14787
14854
|
"vfs_glob",
|
|
14788
14855
|
"vfs_grep"
|
|
14789
14856
|
]);
|
|
14790
|
-
function
|
|
14857
|
+
function u_(e) {
|
|
14791
14858
|
let t = "";
|
|
14792
14859
|
for (let n = 0; n < e.length; n++) {
|
|
14793
14860
|
let r = e[n];
|
|
@@ -14795,16 +14862,16 @@ function r_(e) {
|
|
|
14795
14862
|
}
|
|
14796
14863
|
return RegExp("^" + t + "$");
|
|
14797
14864
|
}
|
|
14798
|
-
function
|
|
14799
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14865
|
+
function d_(e, t, n) {
|
|
14866
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => u_(e).test(n))) return r.mode;
|
|
14800
14867
|
return "allow";
|
|
14801
14868
|
}
|
|
14802
|
-
function
|
|
14869
|
+
function f_(e) {
|
|
14803
14870
|
return {
|
|
14804
14871
|
name: "permissions",
|
|
14805
14872
|
wrapToolCall: async (t, n) => {
|
|
14806
|
-
let r =
|
|
14807
|
-
return r && i &&
|
|
14873
|
+
let r = c_.has(t.name) ? "write" : l_.has(t.name) ? "read" : null, i = t.args?.jsonPath || t.args?.path || "";
|
|
14874
|
+
return r && i && d_(e, r, i) === "deny" ? {
|
|
14808
14875
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14809
14876
|
status: "error"
|
|
14810
14877
|
} : n(t);
|
|
@@ -14813,7 +14880,7 @@ function a_(e) {
|
|
|
14813
14880
|
}
|
|
14814
14881
|
//#endregion
|
|
14815
14882
|
//#region src/core/harness/approval.ts
|
|
14816
|
-
function
|
|
14883
|
+
function p_(e = {}) {
|
|
14817
14884
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14818
14885
|
return {
|
|
14819
14886
|
name: "approval",
|
|
@@ -14847,15 +14914,15 @@ function o_(e = {}) {
|
|
|
14847
14914
|
}
|
|
14848
14915
|
//#endregion
|
|
14849
14916
|
//#region src/core/harness/humanConfirm.ts
|
|
14850
|
-
var
|
|
14917
|
+
var m_ = "request_human_confirmation", h_ = t.object({
|
|
14851
14918
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14852
14919
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14853
14920
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14854
14921
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14855
14922
|
});
|
|
14856
|
-
function
|
|
14923
|
+
function g_() {
|
|
14857
14924
|
return r(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14858
|
-
name:
|
|
14925
|
+
name: m_,
|
|
14859
14926
|
description: [
|
|
14860
14927
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14861
14928
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14865,10 +14932,10 @@ function l_() {
|
|
|
14865
14932
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14866
14933
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14867
14934
|
].join(""),
|
|
14868
|
-
schema:
|
|
14935
|
+
schema: h_
|
|
14869
14936
|
});
|
|
14870
14937
|
}
|
|
14871
|
-
function
|
|
14938
|
+
function __() {
|
|
14872
14939
|
return {
|
|
14873
14940
|
name: "humanConfirm",
|
|
14874
14941
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14900,14 +14967,14 @@ function u_() {
|
|
|
14900
14967
|
}
|
|
14901
14968
|
//#endregion
|
|
14902
14969
|
//#region src/core/harness/checkpoint.ts
|
|
14903
|
-
function
|
|
14970
|
+
function v_(e) {
|
|
14904
14971
|
if (typeof e != "object" || !e) return e;
|
|
14905
14972
|
if (typeof structuredClone == "function") try {
|
|
14906
14973
|
return structuredClone(e);
|
|
14907
14974
|
} catch {}
|
|
14908
14975
|
return JSON.parse(JSON.stringify(e));
|
|
14909
14976
|
}
|
|
14910
|
-
function
|
|
14977
|
+
function y_(e, t) {
|
|
14911
14978
|
let n = t.split("."), r = e;
|
|
14912
14979
|
for (let e of n) {
|
|
14913
14980
|
if (r == null) return;
|
|
@@ -14915,12 +14982,12 @@ function f_(e, t) {
|
|
|
14915
14982
|
}
|
|
14916
14983
|
return r;
|
|
14917
14984
|
}
|
|
14918
|
-
function
|
|
14985
|
+
function b_(e, t, n) {
|
|
14919
14986
|
let r = t.split("."), i = e;
|
|
14920
14987
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14921
14988
|
i[r[r.length - 1]] = n;
|
|
14922
14989
|
}
|
|
14923
|
-
function
|
|
14990
|
+
function x_(e, t) {
|
|
14924
14991
|
if (Array.isArray(e)) {
|
|
14925
14992
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14926
14993
|
return;
|
|
@@ -14929,11 +14996,11 @@ function m_(e, t) {
|
|
|
14929
14996
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14930
14997
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14931
14998
|
}
|
|
14932
|
-
function
|
|
14933
|
-
let n =
|
|
14934
|
-
typeof n == "object" && n ?
|
|
14999
|
+
function S_(e, t) {
|
|
15000
|
+
let n = y_(window, e);
|
|
15001
|
+
typeof n == "object" && n ? x_(n, t) : b_(window, e, t);
|
|
14935
15002
|
}
|
|
14936
|
-
function
|
|
15003
|
+
function C_(e) {
|
|
14937
15004
|
let t = e.slice();
|
|
14938
15005
|
for (; t.length;) {
|
|
14939
15006
|
let e = t[t.length - 1];
|
|
@@ -14942,21 +15009,21 @@ function g_(e) {
|
|
|
14942
15009
|
}
|
|
14943
15010
|
return t;
|
|
14944
15011
|
}
|
|
14945
|
-
function
|
|
15012
|
+
function w_(e) {
|
|
14946
15013
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14947
15014
|
return {
|
|
14948
15015
|
save(i) {
|
|
14949
|
-
let a =
|
|
14950
|
-
if (e.getData) o[""] =
|
|
14951
|
-
else for (let t of e.slotPaths ?? []) o[t] =
|
|
15016
|
+
let a = C_(e.messages), o = {};
|
|
15017
|
+
if (e.getData) o[""] = v_(e.getData());
|
|
15018
|
+
else for (let t of e.slotPaths ?? []) o[t] = v_(y_(window, t));
|
|
14952
15019
|
let s = {
|
|
14953
15020
|
id: r++,
|
|
14954
15021
|
label: i,
|
|
14955
15022
|
timestamp: Date.now(),
|
|
14956
|
-
messages:
|
|
15023
|
+
messages: v_(a),
|
|
14957
15024
|
windowVals: o,
|
|
14958
|
-
vfs:
|
|
14959
|
-
todos:
|
|
15025
|
+
vfs: v_(e.vfsStore.files),
|
|
15026
|
+
todos: v_(e.getTodos()),
|
|
14960
15027
|
messageCount: a.length
|
|
14961
15028
|
};
|
|
14962
15029
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14976,20 +15043,20 @@ function __(e) {
|
|
|
14976
15043
|
restore(n) {
|
|
14977
15044
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14978
15045
|
if (!r) return !1;
|
|
14979
|
-
if (e.messages.splice(0, e.messages.length, ...
|
|
15046
|
+
if (e.messages.splice(0, e.messages.length, ...v_(r.messages)), e.getData) {
|
|
14980
15047
|
let t = r.windowVals[""];
|
|
14981
15048
|
if (t !== void 0) {
|
|
14982
15049
|
let n = e.getData();
|
|
14983
|
-
typeof n == "object" && n &&
|
|
15050
|
+
typeof n == "object" && n && x_(n, v_(t));
|
|
14984
15051
|
}
|
|
14985
|
-
} else for (let [e, t] of Object.entries(r.windowVals))
|
|
15052
|
+
} else for (let [e, t] of Object.entries(r.windowVals)) S_(e, v_(t));
|
|
14986
15053
|
let i = e.vfsStore.files;
|
|
14987
15054
|
for (let e of Object.keys(i)) delete i[e];
|
|
14988
|
-
return Object.assign(i,
|
|
15055
|
+
return Object.assign(i, v_(r.vfs)), e.todosMw.reset(v_(r.todos)), !0;
|
|
14989
15056
|
}
|
|
14990
15057
|
};
|
|
14991
15058
|
}
|
|
14992
|
-
function
|
|
15059
|
+
function T_(e) {
|
|
14993
15060
|
let t = !1;
|
|
14994
15061
|
return {
|
|
14995
15062
|
name: "checkpoint",
|
|
@@ -15003,23 +15070,23 @@ function v_(e) {
|
|
|
15003
15070
|
}
|
|
15004
15071
|
//#endregion
|
|
15005
15072
|
//#region src/core/harness/subagent.ts
|
|
15006
|
-
function
|
|
15073
|
+
function E_(e) {
|
|
15007
15074
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
15008
15075
|
}
|
|
15009
|
-
var
|
|
15076
|
+
var D_ = [
|
|
15010
15077
|
"describe_data",
|
|
15011
15078
|
"get_data",
|
|
15012
15079
|
"read",
|
|
15013
15080
|
"query_data",
|
|
15014
15081
|
"search_data",
|
|
15015
15082
|
"fetch_document"
|
|
15016
|
-
],
|
|
15017
|
-
async function
|
|
15018
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
15083
|
+
], O_ = 1, k_ = 4, A_ = 6, j_ = ["spawn_agent", "spawn_agents"];
|
|
15084
|
+
async function M_(e, t, n, r, i) {
|
|
15085
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? O_, s = /* @__PURE__ */ new Set([...D_, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !j_.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [N_({
|
|
15019
15086
|
...t,
|
|
15020
15087
|
depth: a + 1
|
|
15021
|
-
})] : [], u =
|
|
15022
|
-
...
|
|
15088
|
+
})] : [], u = Zg({
|
|
15089
|
+
...E_(t.llm) ? { llm: t.llm } : {
|
|
15023
15090
|
apiKey: t.llm.apiKey,
|
|
15024
15091
|
baseUrl: t.llm.baseUrl,
|
|
15025
15092
|
model: e.model ?? t.llm.model,
|
|
@@ -15028,8 +15095,8 @@ async function T_(e, t, n, r, i) {
|
|
|
15028
15095
|
},
|
|
15029
15096
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读主数据 / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
15030
15097
|
tools: c,
|
|
15031
|
-
middleware: [...t.skills?.length ? [
|
|
15032
|
-
maxToolRounds: t.maxToolRounds ??
|
|
15098
|
+
middleware: [...t.skills?.length ? [o_(t.skills)] : [], ...l],
|
|
15099
|
+
maxToolRounds: t.maxToolRounds ?? A_,
|
|
15033
15100
|
onLog: i,
|
|
15034
15101
|
debug: t.debug
|
|
15035
15102
|
});
|
|
@@ -15041,8 +15108,8 @@ async function T_(e, t, n, r, i) {
|
|
|
15041
15108
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
15042
15109
|
}, n);
|
|
15043
15110
|
}
|
|
15044
|
-
function
|
|
15045
|
-
let n = e.maxParallel ??
|
|
15111
|
+
function N_(e) {
|
|
15112
|
+
let n = e.maxParallel ?? k_, i, a, o, s = (e, t) => (n) => {
|
|
15046
15113
|
a && a({
|
|
15047
15114
|
type: "subagent",
|
|
15048
15115
|
taskId: e,
|
|
@@ -15061,7 +15128,7 @@ function E_(e) {
|
|
|
15061
15128
|
...e,
|
|
15062
15129
|
allowedTools: r
|
|
15063
15130
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
15064
|
-
return await
|
|
15131
|
+
return await M_({
|
|
15065
15132
|
prompt: t,
|
|
15066
15133
|
role: n,
|
|
15067
15134
|
model: a
|
|
@@ -15078,9 +15145,9 @@ function E_(e) {
|
|
|
15078
15145
|
tools: t.array(t.string()).optional().describe("子 agent 可用工具名白名单(默认只读主数据 + fetch)"),
|
|
15079
15146
|
model: t.string().optional().describe("覆盖模型(默认同主)")
|
|
15080
15147
|
})
|
|
15081
|
-
}), r(async ({ tasks: t }) => (await
|
|
15148
|
+
}), r(async ({ tasks: t }) => (await kg(t, n, async (t, n) => {
|
|
15082
15149
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
15083
|
-
return
|
|
15150
|
+
return M_(t, e, i, s(r, a), (e) => o?.({
|
|
15084
15151
|
...e,
|
|
15085
15152
|
source: `子:${a}`
|
|
15086
15153
|
}));
|
|
@@ -15095,8 +15162,8 @@ function E_(e) {
|
|
|
15095
15162
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
15096
15163
|
};
|
|
15097
15164
|
}
|
|
15098
|
-
var
|
|
15099
|
-
function
|
|
15165
|
+
var P_ = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
15166
|
+
function F_(e, t) {
|
|
15100
15167
|
let n = e.tools ?? [];
|
|
15101
15168
|
return {
|
|
15102
15169
|
llm: e.llm ?? t.llm,
|
|
@@ -15110,7 +15177,7 @@ function O_(e, t) {
|
|
|
15110
15177
|
debug: t.debug
|
|
15111
15178
|
};
|
|
15112
15179
|
}
|
|
15113
|
-
function
|
|
15180
|
+
function I_(e, n) {
|
|
15114
15181
|
let i, a, o, s = (e, t) => (n) => {
|
|
15115
15182
|
a && a({
|
|
15116
15183
|
type: "subagent",
|
|
@@ -15126,7 +15193,7 @@ function k_(e, n) {
|
|
|
15126
15193
|
function d(e) {
|
|
15127
15194
|
let a = /* @__PURE__ */ new Set(), c = [], l = [];
|
|
15128
15195
|
for (let u of e) {
|
|
15129
|
-
if (!
|
|
15196
|
+
if (!P_.test(u.id)) {
|
|
15130
15197
|
console.warn(`[subagents] id "${u.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`);
|
|
15131
15198
|
continue;
|
|
15132
15199
|
}
|
|
@@ -15136,8 +15203,8 @@ function k_(e, n) {
|
|
|
15136
15203
|
continue;
|
|
15137
15204
|
}
|
|
15138
15205
|
a.add(e), c.push(u), l.push(r(async ({ task: e }) => {
|
|
15139
|
-
let t =
|
|
15140
|
-
return
|
|
15206
|
+
let t = F_(u, n);
|
|
15207
|
+
return M_({ prompt: e }, t, i, s(`use_${u.id}`, u.id), (e) => o?.({
|
|
15141
15208
|
...e,
|
|
15142
15209
|
source: `子:${u.id}`
|
|
15143
15210
|
}));
|
|
@@ -15197,7 +15264,7 @@ function k_(e, n) {
|
|
|
15197
15264
|
}
|
|
15198
15265
|
//#endregion
|
|
15199
15266
|
//#region src/core/harness/verify.ts
|
|
15200
|
-
function
|
|
15267
|
+
function L_(e) {
|
|
15201
15268
|
return {
|
|
15202
15269
|
name: "verify",
|
|
15203
15270
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -15209,10 +15276,10 @@ function A_(e) {
|
|
|
15209
15276
|
if (e.adversarial) {
|
|
15210
15277
|
r?.("middleware", {
|
|
15211
15278
|
stage: "adversarial_start",
|
|
15212
|
-
model:
|
|
15279
|
+
model: G_(e.adversarial.llm),
|
|
15213
15280
|
tools: (e.adversarial.tools ?? []).length
|
|
15214
15281
|
});
|
|
15215
|
-
let n = await
|
|
15282
|
+
let n = await Y_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
15216
15283
|
if (r?.("middleware", {
|
|
15217
15284
|
stage: "adversarial_done",
|
|
15218
15285
|
clean: n === null,
|
|
@@ -15223,18 +15290,18 @@ function A_(e) {
|
|
|
15223
15290
|
}
|
|
15224
15291
|
};
|
|
15225
15292
|
}
|
|
15226
|
-
var
|
|
15293
|
+
var R_ = /* @__PURE__ */ new Set([
|
|
15227
15294
|
"set_data",
|
|
15228
15295
|
"edit_data",
|
|
15229
15296
|
"delete_data",
|
|
15230
15297
|
"write"
|
|
15231
|
-
]),
|
|
15232
|
-
function
|
|
15298
|
+
]), z_ = /校验失败|SCHEMA_INVALID|未注册|不存在|仅支持|必须是|NOT_OBJECT|PATH_UNSAFE|VERSION_CONFLICT|WRITE_INTERCEPT/;
|
|
15299
|
+
function B_(e) {
|
|
15233
15300
|
let t = /* @__PURE__ */ new Map();
|
|
15234
15301
|
for (let n of e) {
|
|
15235
15302
|
let e = n?.tool_calls;
|
|
15236
15303
|
if (Array.isArray(e)) {
|
|
15237
|
-
for (let n of e) if (
|
|
15304
|
+
for (let n of e) if (R_.has(n.name)) {
|
|
15238
15305
|
let e = typeof n?.args?.jsonPath == "string" ? n.args.jsonPath : "";
|
|
15239
15306
|
t.set(e, {
|
|
15240
15307
|
path: e,
|
|
@@ -15246,7 +15313,7 @@ function N_(e) {
|
|
|
15246
15313
|
}
|
|
15247
15314
|
return [...t.values()];
|
|
15248
15315
|
}
|
|
15249
|
-
function
|
|
15316
|
+
function V_(e) {
|
|
15250
15317
|
let t = /* @__PURE__ */ new Map();
|
|
15251
15318
|
for (let n of e) {
|
|
15252
15319
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -15254,7 +15321,7 @@ function P_(e) {
|
|
|
15254
15321
|
}
|
|
15255
15322
|
return t;
|
|
15256
15323
|
}
|
|
15257
|
-
function
|
|
15324
|
+
function H_(e, t) {
|
|
15258
15325
|
if (t === "") return e;
|
|
15259
15326
|
if (e == null) return;
|
|
15260
15327
|
let n = e;
|
|
@@ -15264,16 +15331,16 @@ function F_(e, t) {
|
|
|
15264
15331
|
}
|
|
15265
15332
|
return n;
|
|
15266
15333
|
}
|
|
15267
|
-
function
|
|
15334
|
+
function U_(e = {}) {
|
|
15268
15335
|
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 ?? {};
|
|
15269
15336
|
return async ({ messages: e }) => {
|
|
15270
|
-
let r =
|
|
15337
|
+
let r = B_(e);
|
|
15271
15338
|
if (!r.length) return { ok: !0 };
|
|
15272
|
-
let i =
|
|
15339
|
+
let i = V_(e), a = n()[""], o = t(), s = [];
|
|
15273
15340
|
for (let { path: e, op: t, callId: n } of r) {
|
|
15274
15341
|
let r = n ? i.get(n) : void 0;
|
|
15275
|
-
if (r &&
|
|
15276
|
-
let c =
|
|
15342
|
+
if (r && z_.test(r)) continue;
|
|
15343
|
+
let c = H_(o, e);
|
|
15277
15344
|
if (t === "delete_data") c !== void 0 && s.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
15278
15345
|
else if (c == null) s.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
15279
15346
|
else if (a) {
|
|
@@ -15287,17 +15354,17 @@ function I_(e = {}) {
|
|
|
15287
15354
|
} : { ok: !0 };
|
|
15288
15355
|
};
|
|
15289
15356
|
}
|
|
15290
|
-
function
|
|
15357
|
+
function W_(e) {
|
|
15291
15358
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
15292
15359
|
}
|
|
15293
|
-
function
|
|
15294
|
-
return
|
|
15360
|
+
function G_(e) {
|
|
15361
|
+
return W_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
15295
15362
|
}
|
|
15296
|
-
var
|
|
15297
|
-
function
|
|
15298
|
-
return
|
|
15363
|
+
var K_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
15364
|
+
function q_(e) {
|
|
15365
|
+
return K_.test(e);
|
|
15299
15366
|
}
|
|
15300
|
-
function
|
|
15367
|
+
function J_(e) {
|
|
15301
15368
|
let t = "", n = "";
|
|
15302
15369
|
for (let r of e) r instanceof a ? t = typeof r.content == "string" ? r.content : "" : r instanceof i && !(r.tool_calls?.length > 0) && (n = typeof r.content == "string" ? r.content : "");
|
|
15303
15370
|
return {
|
|
@@ -15305,8 +15372,8 @@ function V_(e) {
|
|
|
15305
15372
|
lastReply: n
|
|
15306
15373
|
};
|
|
15307
15374
|
}
|
|
15308
|
-
async function
|
|
15309
|
-
let { lastUser: i, lastReply: a } =
|
|
15375
|
+
async function Y_(e, t, n, r) {
|
|
15376
|
+
let { lastUser: i, lastReply: a } = J_(e);
|
|
15310
15377
|
if (!a) return null;
|
|
15311
15378
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
15312
15379
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -15317,7 +15384,7 @@ async function H_(e, t, n, r) {
|
|
|
15317
15384
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
15318
15385
|
...e.data,
|
|
15319
15386
|
source: "adversarial"
|
|
15320
|
-
}) : void 0, u = await
|
|
15387
|
+
}) : void 0, u = await Zg(W_(t) ? {
|
|
15321
15388
|
llm: t,
|
|
15322
15389
|
tools: r,
|
|
15323
15390
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -15342,17 +15409,17 @@ async function H_(e, t, n, r) {
|
|
|
15342
15409
|
stage: "adversarial_verdict",
|
|
15343
15410
|
verdict: u,
|
|
15344
15411
|
source: "adversarial"
|
|
15345
|
-
}),
|
|
15412
|
+
}), q_(u) ? null : u.trim();
|
|
15346
15413
|
}
|
|
15347
15414
|
//#endregion
|
|
15348
15415
|
//#region src/core/mcp/client.ts
|
|
15349
|
-
function
|
|
15416
|
+
function X_(e) {
|
|
15350
15417
|
let t = e?.content;
|
|
15351
15418
|
if (!Array.isArray(t) || !t.length) return "";
|
|
15352
15419
|
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");
|
|
15353
15420
|
return e?.isError ? `工具错误:${n}` : n;
|
|
15354
15421
|
}
|
|
15355
|
-
async function
|
|
15422
|
+
async function Z_(e) {
|
|
15356
15423
|
let t = new URL(e.url), n = e.requestInit;
|
|
15357
15424
|
if (e.transport === "http") {
|
|
15358
15425
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -15365,8 +15432,8 @@ async function W_(e) {
|
|
|
15365
15432
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
15366
15433
|
return new r(t);
|
|
15367
15434
|
}
|
|
15368
|
-
function
|
|
15369
|
-
return r(async (n) =>
|
|
15435
|
+
function Q_(e, t) {
|
|
15436
|
+
return r(async (n) => X_(await t.callTool({
|
|
15370
15437
|
name: e.name,
|
|
15371
15438
|
arguments: n
|
|
15372
15439
|
})), {
|
|
@@ -15375,21 +15442,21 @@ function G_(e, t) {
|
|
|
15375
15442
|
schema: e.inputSchema
|
|
15376
15443
|
});
|
|
15377
15444
|
}
|
|
15378
|
-
async function
|
|
15379
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
15445
|
+
async function $_(e) {
|
|
15446
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await Z_(e), r = new t({
|
|
15380
15447
|
name: "page-agent-sdk",
|
|
15381
15448
|
version: "1.0"
|
|
15382
15449
|
}, { capabilities: {} });
|
|
15383
15450
|
await r.connect(n);
|
|
15384
15451
|
let { tools: i } = await r.listTools();
|
|
15385
15452
|
return {
|
|
15386
|
-
tools: i.map((e) =>
|
|
15453
|
+
tools: i.map((e) => Q_(e, r)),
|
|
15387
15454
|
close: () => r.close()
|
|
15388
15455
|
};
|
|
15389
15456
|
}
|
|
15390
15457
|
//#endregion
|
|
15391
15458
|
//#region src/core/utils/rounds.ts
|
|
15392
|
-
function
|
|
15459
|
+
function ev(e) {
|
|
15393
15460
|
let t = [], n = null, r = 0;
|
|
15394
15461
|
for (let i = 0; i < e.length; i++) {
|
|
15395
15462
|
let a = e[i];
|
|
@@ -15403,67 +15470,79 @@ function q_(e) {
|
|
|
15403
15470
|
}
|
|
15404
15471
|
return n && t.push(n), t;
|
|
15405
15472
|
}
|
|
15406
|
-
function
|
|
15473
|
+
function tv(e, t) {
|
|
15407
15474
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
15408
15475
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
15409
15476
|
}
|
|
15410
|
-
var
|
|
15411
|
-
function
|
|
15477
|
+
var nv = "【更早对话摘要";
|
|
15478
|
+
function rv(e, t) {
|
|
15479
|
+
return !t || !t.body ? e : {
|
|
15480
|
+
body: `${t.body}\n【续】\n${e.body}`,
|
|
15481
|
+
rounds: (t.rounds ?? 0) + (e.rounds ?? 0),
|
|
15482
|
+
cumulative: !0
|
|
15483
|
+
};
|
|
15484
|
+
}
|
|
15485
|
+
function iv(e) {
|
|
15486
|
+
return typeof e != "string" || !e.startsWith("【更早对话摘要") ? null : { body: e.replace(/^【[^】]*】\n?/, "") };
|
|
15487
|
+
}
|
|
15488
|
+
function av(e) {
|
|
15489
|
+
return `${nv}${e.cumulative ? `(${e.rounds ?? 0} 轮,含累积)` : e.rounds ? `(${e.rounds} 轮)` : ""}】\n${e.body}`;
|
|
15490
|
+
}
|
|
15491
|
+
function ov(e, t) {
|
|
15412
15492
|
if (t <= 0) return { trimmed: !1 };
|
|
15413
|
-
let n =
|
|
15493
|
+
let n = ev(e);
|
|
15414
15494
|
if (n.length <= t) return { trimmed: !1 };
|
|
15415
|
-
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o =
|
|
15495
|
+
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = null;
|
|
15416
15496
|
for (let t = 0; t < a; t++) {
|
|
15417
15497
|
let n = e[t];
|
|
15418
|
-
if (n.role === "system" &&
|
|
15419
|
-
o = n.content;
|
|
15420
|
-
break;
|
|
15421
|
-
}
|
|
15498
|
+
if (n.role === "system" && (o = iv(n.content), o)) break;
|
|
15422
15499
|
}
|
|
15423
|
-
let s = i.map((e) => {
|
|
15424
|
-
let t = J_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? J_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
15425
|
-
return `- 第${e.round}轮:${t} → ${n}`;
|
|
15426
|
-
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
15427
15500
|
return {
|
|
15428
15501
|
trimmed: !0,
|
|
15429
15502
|
deleteFrom: 0,
|
|
15430
15503
|
deleteCount: r,
|
|
15431
15504
|
summary: {
|
|
15432
15505
|
role: "system",
|
|
15433
|
-
content:
|
|
15506
|
+
content: av(rv({
|
|
15507
|
+
body: i.map((e) => {
|
|
15508
|
+
let t = tv(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? tv(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
15509
|
+
return `- 第${e.round}轮:${t} → ${n}`;
|
|
15510
|
+
}).join("\n"),
|
|
15511
|
+
rounds: i.length
|
|
15512
|
+
}, o ?? void 0)),
|
|
15434
15513
|
timestamp: i[0].userMsg.timestamp
|
|
15435
15514
|
}
|
|
15436
15515
|
};
|
|
15437
15516
|
}
|
|
15438
15517
|
//#endregion
|
|
15439
15518
|
//#region src/core/composables/contextIndex.ts
|
|
15440
|
-
var
|
|
15441
|
-
function
|
|
15442
|
-
return e.toLowerCase().split(/[^a-z0-9一-龥]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !
|
|
15519
|
+
var sv = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
15520
|
+
function cv(e) {
|
|
15521
|
+
return e.toLowerCase().split(/[^a-z0-9一-龥]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !sv.has(e));
|
|
15443
15522
|
}
|
|
15444
|
-
function
|
|
15523
|
+
function lv(e) {
|
|
15445
15524
|
let t = typeof e.content == "string" ? e.content : "";
|
|
15446
15525
|
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);
|
|
15447
|
-
return
|
|
15526
|
+
return Ng(t);
|
|
15448
15527
|
}
|
|
15449
|
-
function
|
|
15450
|
-
let t =
|
|
15451
|
-
for (let n of e.assistantMsgs) t +=
|
|
15528
|
+
function uv(e) {
|
|
15529
|
+
let t = lv(e.userMsg);
|
|
15530
|
+
for (let n of e.assistantMsgs) t += lv(n);
|
|
15452
15531
|
return t;
|
|
15453
15532
|
}
|
|
15454
|
-
function
|
|
15533
|
+
function dv(e, t) {
|
|
15455
15534
|
return e.map((e) => {
|
|
15456
|
-
let n =
|
|
15535
|
+
let n = tv(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? tv(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
15457
15536
|
if (t && t.size) {
|
|
15458
15537
|
let n = [];
|
|
15459
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
15538
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${tv(e.result, 120)}`);
|
|
15460
15539
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
15461
15540
|
}
|
|
15462
15541
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
15463
15542
|
}).join("\n");
|
|
15464
15543
|
}
|
|
15465
|
-
function
|
|
15466
|
-
let r =
|
|
15544
|
+
function fv(e, t, n) {
|
|
15545
|
+
let r = cv(t);
|
|
15467
15546
|
return r.length === 0 ? [] : e.map((e) => {
|
|
15468
15547
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
15469
15548
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -15475,7 +15554,7 @@ function nv(e, t, n) {
|
|
|
15475
15554
|
}
|
|
15476
15555
|
//#endregion
|
|
15477
15556
|
//#region src/core/composables/useContextManager.ts
|
|
15478
|
-
var
|
|
15557
|
+
var pv = {
|
|
15479
15558
|
windowRounds: 6,
|
|
15480
15559
|
summaryThresholdRounds: 8,
|
|
15481
15560
|
toolResultMaxChars: 800,
|
|
@@ -15483,20 +15562,23 @@ var rv = {
|
|
|
15483
15562
|
recallTopK: 3,
|
|
15484
15563
|
enableLLMSummary: !1
|
|
15485
15564
|
};
|
|
15486
|
-
function
|
|
15565
|
+
function mv(e = {}) {
|
|
15487
15566
|
let t = {
|
|
15488
|
-
...
|
|
15567
|
+
...pv,
|
|
15489
15568
|
...e
|
|
15490
15569
|
};
|
|
15491
15570
|
async function n(e) {
|
|
15492
|
-
let n =
|
|
15571
|
+
let n = ev(e), r = e.length, i = "";
|
|
15493
15572
|
if (n.length) {
|
|
15494
15573
|
let t = n[0].startIdx;
|
|
15495
15574
|
for (let n = 0; n < t; n++) {
|
|
15496
15575
|
let t = e[n];
|
|
15497
|
-
if (t.role === "system"
|
|
15498
|
-
|
|
15499
|
-
|
|
15576
|
+
if (t.role === "system") {
|
|
15577
|
+
let e = iv(t.content);
|
|
15578
|
+
if (e) {
|
|
15579
|
+
i = e.body;
|
|
15580
|
+
break;
|
|
15581
|
+
}
|
|
15500
15582
|
}
|
|
15501
15583
|
}
|
|
15502
15584
|
}
|
|
@@ -15513,9 +15595,9 @@ function iv(e = {}) {
|
|
|
15513
15595
|
}
|
|
15514
15596
|
}), o, s, c;
|
|
15515
15597
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
15516
|
-
if (n.reduce((e, t) => e +
|
|
15598
|
+
if (n.reduce((e, t) => e + uv(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return a("none");
|
|
15517
15599
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, i = 0;
|
|
15518
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
15600
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += uv(n[t]), r >= e) {
|
|
15519
15601
|
i = t + 1;
|
|
15520
15602
|
break;
|
|
15521
15603
|
}
|
|
@@ -15528,12 +15610,12 @@ function iv(e = {}) {
|
|
|
15528
15610
|
}
|
|
15529
15611
|
let l = [...e].reverse().find((e) => e.role === "user")?.content || "", u = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, d, f;
|
|
15530
15612
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
15531
|
-
d = await t.llmInvoke(
|
|
15613
|
+
d = await t.llmInvoke(dv(s, u)), f = c + "llm_summary";
|
|
15532
15614
|
} catch {
|
|
15533
|
-
d =
|
|
15615
|
+
d = dv(s, u), f = c + "index_summary(llm_fallback)";
|
|
15534
15616
|
}
|
|
15535
|
-
else d =
|
|
15536
|
-
let p = t.enableRecall ?
|
|
15617
|
+
else d = dv(s, u), f = c + "index_summary";
|
|
15618
|
+
let p = t.enableRecall ? fv(s, l, t.recallTopK) : [], m = p.length ? p.map((e) => `- 第${e.round}轮:${tv(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? tv(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", h = i ? `${d}\n【更早累积摘要】\n${i}` : d, g = [`【对话历史摘要】以下是之前 ${s.length} 轮对话的要点(最新 ${o.length} 轮已完整保留):`, h];
|
|
15537
15619
|
m && g.push("\n【与当前问题可能相关的早期对话】", m);
|
|
15538
15620
|
let _ = t.getRegisteredData ?? t.getRegisteredSlots;
|
|
15539
15621
|
if (_) try {
|
|
@@ -15570,8 +15652,8 @@ function iv(e = {}) {
|
|
|
15570
15652
|
}
|
|
15571
15653
|
//#endregion
|
|
15572
15654
|
//#region src/core/harness/summarization.ts
|
|
15573
|
-
function
|
|
15574
|
-
let t =
|
|
15655
|
+
function hv(e = {}) {
|
|
15656
|
+
let t = mv(e);
|
|
15575
15657
|
return {
|
|
15576
15658
|
name: "summarization",
|
|
15577
15659
|
compressInput: async (e) => {
|
|
@@ -15584,8 +15666,207 @@ function av(e = {}) {
|
|
|
15584
15666
|
};
|
|
15585
15667
|
}
|
|
15586
15668
|
//#endregion
|
|
15669
|
+
//#region src/core/tools/schemaUtils.ts
|
|
15670
|
+
function gv(e) {
|
|
15671
|
+
let t = e;
|
|
15672
|
+
for (let e = 0; e < 5 && t && t._def; e++) {
|
|
15673
|
+
if (t._def.innerType) {
|
|
15674
|
+
t = t._def.innerType;
|
|
15675
|
+
continue;
|
|
15676
|
+
}
|
|
15677
|
+
break;
|
|
15678
|
+
}
|
|
15679
|
+
if (!t || !t.shape || typeof t.shape != "object") return null;
|
|
15680
|
+
try {
|
|
15681
|
+
let e = typeof t.shape == "function" ? t.shape() : t.shape;
|
|
15682
|
+
return Object.keys(e);
|
|
15683
|
+
} catch {
|
|
15684
|
+
return null;
|
|
15685
|
+
}
|
|
15686
|
+
}
|
|
15687
|
+
function _v(e, t, n) {
|
|
15688
|
+
if (!n || !e) return !0;
|
|
15689
|
+
let r = vv(t);
|
|
15690
|
+
for (let t of e.split(".")) {
|
|
15691
|
+
if (!r) return !1;
|
|
15692
|
+
if (r = vv(r), r && r.shape && typeof r.shape == "object") {
|
|
15693
|
+
let e = typeof r.shape == "function" ? r.shape() : r.shape;
|
|
15694
|
+
if (!(t in e)) return !1;
|
|
15695
|
+
r = e[t];
|
|
15696
|
+
} else if (r && (r._def?.type === "array" || r.constructor?.name === "ZodArray")) r = r.element;
|
|
15697
|
+
else if (r && (r._def?.type === "union" || r._def?.type === "discriminatedUnion" || Array.isArray(r.options))) return !0;
|
|
15698
|
+
else return !1;
|
|
15699
|
+
}
|
|
15700
|
+
return !0;
|
|
15701
|
+
}
|
|
15702
|
+
function vv(e) {
|
|
15703
|
+
let t = e;
|
|
15704
|
+
for (let e = 0; e < 8 && t && t._def; e++) {
|
|
15705
|
+
if (t._def.innerType) {
|
|
15706
|
+
t = t._def.innerType;
|
|
15707
|
+
continue;
|
|
15708
|
+
}
|
|
15709
|
+
if (t._def.schema) {
|
|
15710
|
+
t = t._def.schema;
|
|
15711
|
+
continue;
|
|
15712
|
+
}
|
|
15713
|
+
if (t._def.getter) {
|
|
15714
|
+
t = t._def.getter();
|
|
15715
|
+
continue;
|
|
15716
|
+
}
|
|
15717
|
+
break;
|
|
15718
|
+
}
|
|
15719
|
+
return t;
|
|
15720
|
+
}
|
|
15721
|
+
function yv(e, t) {
|
|
15722
|
+
if (!t) return e;
|
|
15723
|
+
let n = vv(e), r = t.split(".");
|
|
15724
|
+
for (let e of r) {
|
|
15725
|
+
if (!n) return null;
|
|
15726
|
+
if (n = vv(n), n && n.shape && typeof n.shape == "object") n = (typeof n.shape == "function" ? n.shape() : n.shape)[e];
|
|
15727
|
+
else if (n && (n._def?.type === "array" || n.constructor?.name === "ZodArray")) n = n.element;
|
|
15728
|
+
else if (n && (n._def?.type === "union" || n._def?.type === "discriminatedUnion" || Array.isArray(n.options))) return null;
|
|
15729
|
+
else return null;
|
|
15730
|
+
}
|
|
15731
|
+
return n ?? null;
|
|
15732
|
+
}
|
|
15733
|
+
function bv(e, t) {
|
|
15734
|
+
if (typeof e != "object" || !e || !t) return e;
|
|
15735
|
+
let n = vv(t);
|
|
15736
|
+
if (!n || !n.shape) {
|
|
15737
|
+
if (Array.isArray(e) && (n?._def?.type || n?.element)) {
|
|
15738
|
+
let t = n.element ?? n._def?.type;
|
|
15739
|
+
return e.map((e) => bv(e, t));
|
|
15740
|
+
}
|
|
15741
|
+
return e;
|
|
15742
|
+
}
|
|
15743
|
+
let r = typeof n.shape == "function" ? n.shape() : n.shape, i = {};
|
|
15744
|
+
for (let t of Object.keys(e)) if (t in r) {
|
|
15745
|
+
let n = e[t];
|
|
15746
|
+
i[t] = bv(n, r[t]);
|
|
15747
|
+
}
|
|
15748
|
+
return i;
|
|
15749
|
+
}
|
|
15750
|
+
function xv(e, t) {
|
|
15751
|
+
if (!t || typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
15752
|
+
let n = new Set(t), r = {};
|
|
15753
|
+
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
15754
|
+
return r;
|
|
15755
|
+
}
|
|
15756
|
+
var Sv = !1;
|
|
15757
|
+
function Cv() {
|
|
15758
|
+
Sv ||= !0;
|
|
15759
|
+
}
|
|
15760
|
+
function wv(e) {
|
|
15761
|
+
let t = e?._def?.checks;
|
|
15762
|
+
if (!Array.isArray(t)) return [];
|
|
15763
|
+
let n = [];
|
|
15764
|
+
for (let e of t) e?._zod?.def && n.push(e._zod.def);
|
|
15765
|
+
return n;
|
|
15766
|
+
}
|
|
15767
|
+
function Tv(e) {
|
|
15768
|
+
return e === -(2 ** 53 - 1) || e === -Infinity;
|
|
15769
|
+
}
|
|
15770
|
+
function Ev(e) {
|
|
15771
|
+
return e === 2 ** 53 - 1 || e === Infinity;
|
|
15772
|
+
}
|
|
15773
|
+
function Dv(e) {
|
|
15774
|
+
let t = !1, n = !1, r = !1, i, a = e;
|
|
15775
|
+
for (let e = 0; e < 8 && a && a._def; e++) {
|
|
15776
|
+
let e = a._def.type;
|
|
15777
|
+
if (e === "optional" || e === "default" || e === "nullable" || e === "catch" || e === "readonly" || e === "prefault") {
|
|
15778
|
+
e === "optional" ? t = !0 : e === "nullable" ? n = !0 : (e === "default" || e === "prefault") && (r = !0, i = a._def.defaultValue), a = a._def.innerType;
|
|
15779
|
+
continue;
|
|
15780
|
+
}
|
|
15781
|
+
if (e === "lazy") {
|
|
15782
|
+
a = a._def.getter ? a._def.getter() : a._def.schema;
|
|
15783
|
+
continue;
|
|
15784
|
+
}
|
|
15785
|
+
if (e === "pipe") {
|
|
15786
|
+
a = a._def.in ?? a._def.innerType;
|
|
15787
|
+
continue;
|
|
15788
|
+
}
|
|
15789
|
+
break;
|
|
15790
|
+
}
|
|
15791
|
+
let o = a?._def?.type || "unknown";
|
|
15792
|
+
a?._def || Cv();
|
|
15793
|
+
let s = { type: o };
|
|
15794
|
+
t && (s.optional = !0), n && (s.nullable = !0), r && (s.default = i), a?.description && (s.description = a.description);
|
|
15795
|
+
let c = {};
|
|
15796
|
+
switch (o) {
|
|
15797
|
+
case "string": {
|
|
15798
|
+
a.minLength != null && (c.minLength = a.minLength), a.maxLength != null && (c.maxLength = a.maxLength);
|
|
15799
|
+
let e = wv(a).filter((e) => e.check === "string_format").map((e) => e.format).filter(Boolean);
|
|
15800
|
+
e.length && (c.format = e.length === 1 ? e[0] : e);
|
|
15801
|
+
break;
|
|
15802
|
+
}
|
|
15803
|
+
case "number":
|
|
15804
|
+
a.minValue != null && !Tv(a.minValue) && (c.min = a.minValue), a.maxValue != null && !Ev(a.maxValue) && (c.max = a.maxValue), a.isInt && (c.int = !0), a.format && a.format !== "number" && (c.format = a.format);
|
|
15805
|
+
break;
|
|
15806
|
+
case "enum":
|
|
15807
|
+
c.values = a.options;
|
|
15808
|
+
break;
|
|
15809
|
+
case "literal": {
|
|
15810
|
+
let e = a._def?.values ?? (a._def?.value === void 0 ? [] : [a._def.value]);
|
|
15811
|
+
c.value = e.length === 1 ? e[0] : e;
|
|
15812
|
+
break;
|
|
15813
|
+
}
|
|
15814
|
+
case "array":
|
|
15815
|
+
c.item = Dv(a.element);
|
|
15816
|
+
for (let e of wv(a)) e.check === "min_length" ? c.minLength = e.minimum : e.check === "max_length" ? c.maxLength = e.maximum : e.check === "length_equals" && (c.length = e.length);
|
|
15817
|
+
break;
|
|
15818
|
+
case "object": {
|
|
15819
|
+
let e = typeof a.shape == "function" ? a.shape() : a.shape;
|
|
15820
|
+
c.shape = Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, Dv(t)]));
|
|
15821
|
+
break;
|
|
15822
|
+
}
|
|
15823
|
+
case "union": {
|
|
15824
|
+
let e = (a._def?.options || []).map((e) => Dv(e));
|
|
15825
|
+
e.length && (c.anyOf = e);
|
|
15826
|
+
break;
|
|
15827
|
+
}
|
|
15828
|
+
case "record": a._def?.valueType && (c.valueType = Dv(a._def.valueType));
|
|
15829
|
+
}
|
|
15830
|
+
return Object.keys(c).length && (s.constraints = c), s;
|
|
15831
|
+
}
|
|
15832
|
+
function Ov(e) {
|
|
15833
|
+
let t = [];
|
|
15834
|
+
return e.minLength !== void 0 && t.push(`minLen=${e.minLength}`), e.maxLength !== void 0 && t.push(`maxLen=${e.maxLength}`), e.length !== void 0 && t.push(`len=${e.length}`), e.min !== void 0 && t.push(`min=${e.min}`), e.max !== void 0 && t.push(`max=${e.max}`), e.int && t.push("int"), e.format && t.push(`format=${Array.isArray(e.format) ? e.format.join("|") : e.format}`), e.values && t.push(`enum=[${e.values.map((e) => String(e)).join("|")}]`), e.value !== void 0 && t.push(`=${JSON.stringify(e.value)}`), t.join(", ");
|
|
15835
|
+
}
|
|
15836
|
+
function kv(e, t) {
|
|
15837
|
+
let n = t.constraints ? Ov(t.constraints) : "", r = n ? `[${n}]` : "", i = t.optional ? "?" : "", a = t.description ? `: ${t.description}` : "";
|
|
15838
|
+
return `- ${e} (${t.type}${i})${r}${a}`;
|
|
15839
|
+
}
|
|
15840
|
+
function Av(e) {
|
|
15841
|
+
if (!e) return "";
|
|
15842
|
+
try {
|
|
15843
|
+
let t = e;
|
|
15844
|
+
for (let e = 0; e < 8 && t && t._def; e++) {
|
|
15845
|
+
if (t._def.innerType) {
|
|
15846
|
+
t = t._def.innerType;
|
|
15847
|
+
continue;
|
|
15848
|
+
}
|
|
15849
|
+
if (t._def.getter) {
|
|
15850
|
+
t = t._def.getter();
|
|
15851
|
+
continue;
|
|
15852
|
+
}
|
|
15853
|
+
if (t._def.schema) {
|
|
15854
|
+
t = t._def.schema;
|
|
15855
|
+
continue;
|
|
15856
|
+
}
|
|
15857
|
+
break;
|
|
15858
|
+
}
|
|
15859
|
+
let n = t?.shape ? typeof t.shape == "function" ? t.shape() : t.shape : null;
|
|
15860
|
+
if (n && typeof n == "object" && Object.keys(n).length) return Object.entries(n).map(([e, t]) => kv(e, Dv(t))).join("\n");
|
|
15861
|
+
} catch {}
|
|
15862
|
+
try {
|
|
15863
|
+
return kv("(root)", Dv(e));
|
|
15864
|
+
} catch {}
|
|
15865
|
+
return "";
|
|
15866
|
+
}
|
|
15867
|
+
//#endregion
|
|
15587
15868
|
//#region src/core/presets.ts
|
|
15588
|
-
var
|
|
15869
|
+
var jv = {
|
|
15589
15870
|
pageBuilder: { systemPrompt: "你是页面构建助手。按用户意图读写主数据(经 data 声明 + schema 校验),改完页面实时更新。" },
|
|
15590
15871
|
researcher: {
|
|
15591
15872
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15599,7 +15880,7 @@ var ov = {
|
|
|
15599
15880
|
memory: !1,
|
|
15600
15881
|
subagent: !1
|
|
15601
15882
|
} }
|
|
15602
|
-
},
|
|
15883
|
+
}, Mv = { reliableWriteRules: [
|
|
15603
15884
|
"【可靠写入规则】",
|
|
15604
15885
|
"1. 改任何字段前,先用 read({ jsonPath }) 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15605
15886
|
"2. 若不确定可操作哪些字段,先 read() 不传 jsonPath 查看主数据说明 + schema 声明字段(集成方可经 sdk.setData 运行时替换 schema,以工具返回为准,勿凭旧记忆);",
|
|
@@ -15607,49 +15888,41 @@ var ov = {
|
|
|
15607
15888
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15608
15889
|
"5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断。"
|
|
15609
15890
|
].join("\n") };
|
|
15610
|
-
function
|
|
15611
|
-
|
|
15612
|
-
try {
|
|
15613
|
-
let t = e.shape ?? (e._def?.shape ? typeof e._def.shape == "function" ? e._def.shape() : e._def.shape : null);
|
|
15614
|
-
if (t && typeof t == "object") return Object.entries(t).map(([e, t]) => {
|
|
15615
|
-
let n = t?.description || "", r = t?._def?.typeName || "";
|
|
15616
|
-
return `- ${e}${n ? `: ${n}` : r ? ` (${r})` : ""}`;
|
|
15617
|
-
}).join("\n");
|
|
15618
|
-
} catch {}
|
|
15619
|
-
return e?.description || "(用 read 查看实际形状)";
|
|
15891
|
+
function Nv(e) {
|
|
15892
|
+
return e ? Av(e) || e?.description || "(用 read 查看实际形状)" : "";
|
|
15620
15893
|
}
|
|
15621
15894
|
//#endregion
|
|
15622
15895
|
//#region src/core/sdk/promptBuilder.ts
|
|
15623
|
-
var
|
|
15896
|
+
var Pv = [
|
|
15624
15897
|
"你是一个 JSON 操作助手。集成方声明了一个主数据对象(含 zod schema 校验),你通过专用工具安全地读写它来完成任务。",
|
|
15625
15898
|
"所有写操作都经范围控制(仅 schema 声明字段内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
15626
15899
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
15627
15900
|
"---",
|
|
15628
|
-
|
|
15901
|
+
Mv.reliableWriteRules
|
|
15629
15902
|
].join("\n\n");
|
|
15630
|
-
function
|
|
15903
|
+
function Fv(e) {
|
|
15631
15904
|
if (!e) return "";
|
|
15632
|
-
let t =
|
|
15905
|
+
let t = Nv(e.schema);
|
|
15633
15906
|
return `\n\n## 可操作数据(字段以 read 工具返回的实际值为准)\n${e.description ? e.description + "\n" : ""}${t}`;
|
|
15634
15907
|
}
|
|
15635
|
-
function
|
|
15908
|
+
function Iv(e) {
|
|
15636
15909
|
let t = e.appendReliableWriteRules !== !1;
|
|
15637
|
-
return e.systemPrompt ? t ? e.systemPrompt + "\n\n---\n\n" +
|
|
15910
|
+
return e.systemPrompt ? t ? e.systemPrompt + "\n\n---\n\n" + Mv.reliableWriteRules : e.systemPrompt : Pv;
|
|
15638
15911
|
}
|
|
15639
15912
|
//#endregion
|
|
15640
15913
|
//#region src/core/sdk/llmResolver.ts
|
|
15641
|
-
function
|
|
15914
|
+
function Lv(e) {
|
|
15642
15915
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
15643
15916
|
}
|
|
15644
|
-
function
|
|
15917
|
+
function Rv(e) {
|
|
15645
15918
|
let t = e.content;
|
|
15646
15919
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
15647
15920
|
}
|
|
15648
|
-
function
|
|
15921
|
+
function zv(e) {
|
|
15649
15922
|
let t = e.summaryLlm ?? e.llm;
|
|
15650
15923
|
if (!t) return;
|
|
15651
15924
|
let r = e.summaryTemperature ?? .3, i = e.summaryMaxTokens ?? 1024, s = e.summaryTimeoutMs ?? 15e3, c;
|
|
15652
|
-
if (
|
|
15925
|
+
if (Lv(t)) c = t;
|
|
15653
15926
|
else {
|
|
15654
15927
|
let a = t;
|
|
15655
15928
|
if (!a.apiKey) {
|
|
@@ -15671,26 +15944,26 @@ function mv(e) {
|
|
|
15671
15944
|
return async (e) => {
|
|
15672
15945
|
let t = new AbortController(), n = setTimeout(() => t.abort(), s);
|
|
15673
15946
|
try {
|
|
15674
|
-
return
|
|
15947
|
+
return Rv(await c.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
15675
15948
|
} finally {
|
|
15676
15949
|
clearTimeout(n);
|
|
15677
15950
|
}
|
|
15678
15951
|
};
|
|
15679
15952
|
}
|
|
15680
|
-
function
|
|
15681
|
-
let t =
|
|
15953
|
+
function Bv(e) {
|
|
15954
|
+
let t = Lv(e.llm) ? void 0 : e.llm;
|
|
15682
15955
|
return {
|
|
15683
|
-
modelCaps:
|
|
15956
|
+
modelCaps: Mg({
|
|
15684
15957
|
model: t?.model,
|
|
15685
15958
|
contextWindow: e.contextWindow ?? t?.contextWindow,
|
|
15686
15959
|
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens
|
|
15687
15960
|
}),
|
|
15688
|
-
summaryLlmInvoke:
|
|
15961
|
+
summaryLlmInvoke: zv(e)
|
|
15689
15962
|
};
|
|
15690
15963
|
}
|
|
15691
15964
|
//#endregion
|
|
15692
15965
|
//#region src/core/sdk/conflictManager.ts
|
|
15693
|
-
function
|
|
15966
|
+
function Vv(e) {
|
|
15694
15967
|
let t = /* @__PURE__ */ U(null), n = 0;
|
|
15695
15968
|
function r(r) {
|
|
15696
15969
|
return new Promise((i) => {
|
|
@@ -15719,7 +15992,7 @@ function gv(e) {
|
|
|
15719
15992
|
}
|
|
15720
15993
|
//#endregion
|
|
15721
15994
|
//#region src/core/utils/id.ts
|
|
15722
|
-
function
|
|
15995
|
+
function Hv() {
|
|
15723
15996
|
try {
|
|
15724
15997
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
15725
15998
|
} catch {}
|
|
@@ -15727,57 +16000,57 @@ function _v() {
|
|
|
15727
16000
|
}
|
|
15728
16001
|
//#endregion
|
|
15729
16002
|
//#region src/core/backends/storage.ts
|
|
15730
|
-
var
|
|
16003
|
+
var Uv = "chat-sdk", Wv = 52428800, Gv = 4194304, Kv = 10485760, qv = .9, Jv = 500, Yv = 300, Xv = "__meta__", Zv = "v:1", Qv = [
|
|
15731
16004
|
"messages",
|
|
15732
16005
|
"vfs",
|
|
15733
16006
|
"todos",
|
|
15734
16007
|
"memory"
|
|
15735
16008
|
];
|
|
15736
|
-
function
|
|
15737
|
-
return e === "local" || e === "session" ?
|
|
16009
|
+
function $v(e) {
|
|
16010
|
+
return e === "local" || e === "session" ? Gv : Wv;
|
|
15738
16011
|
}
|
|
15739
|
-
function
|
|
16012
|
+
function ey(e) {
|
|
15740
16013
|
if (typeof e != "object" || !e) return !1;
|
|
15741
16014
|
let t = e;
|
|
15742
16015
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
15743
16016
|
}
|
|
15744
|
-
function
|
|
16017
|
+
function ty(e, t, n, r) {
|
|
15745
16018
|
return [
|
|
15746
|
-
|
|
16019
|
+
Zv,
|
|
15747
16020
|
e,
|
|
15748
16021
|
t,
|
|
15749
16022
|
n,
|
|
15750
16023
|
r
|
|
15751
16024
|
].join("::");
|
|
15752
16025
|
}
|
|
15753
|
-
function
|
|
16026
|
+
function ny(e, t, n) {
|
|
15754
16027
|
return [
|
|
15755
|
-
|
|
16028
|
+
Zv,
|
|
15756
16029
|
e,
|
|
15757
16030
|
t,
|
|
15758
16031
|
n
|
|
15759
16032
|
].join("::") + "::";
|
|
15760
16033
|
}
|
|
15761
|
-
function
|
|
16034
|
+
function ry(e, t) {
|
|
15762
16035
|
return [
|
|
15763
|
-
|
|
16036
|
+
Zv,
|
|
15764
16037
|
e,
|
|
15765
16038
|
t
|
|
15766
16039
|
].join("::") + "::";
|
|
15767
16040
|
}
|
|
15768
|
-
function
|
|
15769
|
-
return [
|
|
16041
|
+
function iy(e) {
|
|
16042
|
+
return [Zv, e].join("::") + "::";
|
|
15770
16043
|
}
|
|
15771
|
-
var
|
|
15772
|
-
function
|
|
15773
|
-
|
|
16044
|
+
var ay = null;
|
|
16045
|
+
function oy(e) {
|
|
16046
|
+
ay ||= new TextEncoder();
|
|
15774
16047
|
try {
|
|
15775
|
-
return
|
|
16048
|
+
return ay.encode(JSON.stringify(e)).length;
|
|
15776
16049
|
} catch {
|
|
15777
16050
|
return 0;
|
|
15778
16051
|
}
|
|
15779
16052
|
}
|
|
15780
|
-
function
|
|
16053
|
+
function sy(e, t, n) {
|
|
15781
16054
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
15782
16055
|
if (r <= t) return [];
|
|
15783
16056
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -15787,7 +16060,7 @@ function Iv(e, t, n) {
|
|
|
15787
16060
|
}
|
|
15788
16061
|
return o;
|
|
15789
16062
|
}
|
|
15790
|
-
function
|
|
16063
|
+
function cy() {
|
|
15791
16064
|
let e = /* @__PURE__ */ new Map();
|
|
15792
16065
|
return {
|
|
15793
16066
|
async get(t) {
|
|
@@ -15807,7 +16080,7 @@ function Lv() {
|
|
|
15807
16080
|
}
|
|
15808
16081
|
};
|
|
15809
16082
|
}
|
|
15810
|
-
function
|
|
16083
|
+
function ly(e) {
|
|
15811
16084
|
return new Promise((t, n) => {
|
|
15812
16085
|
if (typeof indexedDB > "u") {
|
|
15813
16086
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -15868,7 +16141,7 @@ function Rv(e) {
|
|
|
15868
16141
|
}, r.onerror = () => n(r.error);
|
|
15869
16142
|
});
|
|
15870
16143
|
}
|
|
15871
|
-
function
|
|
16144
|
+
function uy(e) {
|
|
15872
16145
|
return {
|
|
15873
16146
|
async get(t) {
|
|
15874
16147
|
let n = e.getItem(t);
|
|
@@ -15902,12 +16175,12 @@ function zv(e) {
|
|
|
15902
16175
|
}
|
|
15903
16176
|
};
|
|
15904
16177
|
}
|
|
15905
|
-
function
|
|
16178
|
+
function dy(e, t, n) {
|
|
15906
16179
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
15907
16180
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
15908
16181
|
}
|
|
15909
|
-
function
|
|
15910
|
-
let t = e.dbName ??
|
|
16182
|
+
function fy(e = {}) {
|
|
16183
|
+
let t = e.dbName ?? Uv, n = e.backend ?? "indexed", r = e.maxBytes ?? $v(n), i = e.maxBytesPerSession ?? Kv, a = e.evictionWatermark ?? qv, o = e.debounceMs ?? Jv, s = /* @__PURE__ */ new Set();
|
|
15911
16184
|
function c(e) {
|
|
15912
16185
|
for (let t of s) try {
|
|
15913
16186
|
t(e);
|
|
@@ -15920,16 +16193,16 @@ function Vv(e = {}) {
|
|
|
15920
16193
|
try {
|
|
15921
16194
|
if (n === "indexed") {
|
|
15922
16195
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
15923
|
-
l = await
|
|
16196
|
+
l = await ly(t), d(!0);
|
|
15924
16197
|
} else if (n === "session") {
|
|
15925
16198
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
15926
|
-
l =
|
|
16199
|
+
l = uy(sessionStorage), d(!0);
|
|
15927
16200
|
} else if (n === "local") {
|
|
15928
16201
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
15929
|
-
l =
|
|
15930
|
-
} else l =
|
|
16202
|
+
l = uy(localStorage), d(!0);
|
|
16203
|
+
} else l = cy(), d(!1);
|
|
15931
16204
|
} catch (e) {
|
|
15932
|
-
l =
|
|
16205
|
+
l = cy();
|
|
15933
16206
|
let t = e instanceof Error ? e.message : String(e);
|
|
15934
16207
|
d(!1), Promise.resolve().then(() => c({
|
|
15935
16208
|
type: "degraded",
|
|
@@ -15939,10 +16212,10 @@ function Vv(e = {}) {
|
|
|
15939
16212
|
})();
|
|
15940
16213
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
15941
16214
|
function g(e, n, r, a) {
|
|
15942
|
-
let o =
|
|
15943
|
-
return
|
|
16215
|
+
let o = ty(t, r, a, Xv);
|
|
16216
|
+
return dy(h, o, async () => {
|
|
15944
16217
|
let t = async () => {
|
|
15945
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16218
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : oy(s), d = oy(n), f = (t?.bytes ?? 0) + (d - u);
|
|
15946
16219
|
if (f > i) {
|
|
15947
16220
|
c({
|
|
15948
16221
|
type: "quota",
|
|
@@ -15964,12 +16237,12 @@ function Vv(e = {}) {
|
|
|
15964
16237
|
try {
|
|
15965
16238
|
await t();
|
|
15966
16239
|
} catch (e) {
|
|
15967
|
-
if (
|
|
16240
|
+
if (ey(e) && !u) {
|
|
15968
16241
|
u = !0;
|
|
15969
16242
|
try {
|
|
15970
16243
|
await b();
|
|
15971
16244
|
} catch {}
|
|
15972
|
-
l =
|
|
16245
|
+
l = cy(), Promise.resolve().then(() => c({
|
|
15973
16246
|
type: "degraded",
|
|
15974
16247
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
15975
16248
|
}));
|
|
@@ -15981,7 +16254,7 @@ function Vv(e = {}) {
|
|
|
15981
16254
|
});
|
|
15982
16255
|
}
|
|
15983
16256
|
function _(e, n, r, i) {
|
|
15984
|
-
let a =
|
|
16257
|
+
let a = ty(t, e, n, r), s = p.get(a);
|
|
15985
16258
|
s && s.resolve();
|
|
15986
16259
|
let c = m.get(a);
|
|
15987
16260
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16008,15 +16281,15 @@ function Vv(e = {}) {
|
|
|
16008
16281
|
function y() {
|
|
16009
16282
|
v ||= setTimeout(() => {
|
|
16010
16283
|
v = null, b();
|
|
16011
|
-
},
|
|
16284
|
+
}, Yv);
|
|
16012
16285
|
}
|
|
16013
16286
|
async function b() {
|
|
16014
16287
|
let e = [];
|
|
16015
|
-
await l.scan(
|
|
16288
|
+
await l.scan(iy(t), (t, n) => {
|
|
16016
16289
|
t.endsWith("::__meta__") && e.push(n);
|
|
16017
16290
|
});
|
|
16018
|
-
let n =
|
|
16019
|
-
for (let e of n) await l.clearPrefix(
|
|
16291
|
+
let n = sy(e, r, a);
|
|
16292
|
+
for (let e of n) await l.clearPrefix(ny(t, e.agentId, e.sessionId)), c({
|
|
16020
16293
|
type: "evicted",
|
|
16021
16294
|
agentId: e.agentId,
|
|
16022
16295
|
sessionId: e.sessionId,
|
|
@@ -16027,13 +16300,13 @@ function Vv(e = {}) {
|
|
|
16027
16300
|
ready: f,
|
|
16028
16301
|
async listSessions(e) {
|
|
16029
16302
|
let n = [];
|
|
16030
|
-
return await l.scan(
|
|
16303
|
+
return await l.scan(ry(t, e), (e, t) => {
|
|
16031
16304
|
e.endsWith("::__meta__") && n.push(t);
|
|
16032
16305
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16033
16306
|
},
|
|
16034
16307
|
async load(e, n) {
|
|
16035
|
-
let r =
|
|
16036
|
-
return await
|
|
16308
|
+
let r = ty(t, e, n, Xv);
|
|
16309
|
+
return await dy(h, r, async () => {
|
|
16037
16310
|
let i = await l.get(r);
|
|
16038
16311
|
if (!i) return;
|
|
16039
16312
|
let a = {
|
|
@@ -16042,8 +16315,8 @@ function Vv(e = {}) {
|
|
|
16042
16315
|
todos: [],
|
|
16043
16316
|
memory: ""
|
|
16044
16317
|
};
|
|
16045
|
-
for (let r of
|
|
16046
|
-
let i = await l.get(
|
|
16318
|
+
for (let r of Qv) {
|
|
16319
|
+
let i = await l.get(ty(t, e, n, r));
|
|
16047
16320
|
i != null && (a[r] = i);
|
|
16048
16321
|
}
|
|
16049
16322
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16051,7 +16324,7 @@ function Vv(e = {}) {
|
|
|
16051
16324
|
},
|
|
16052
16325
|
async save(e, t, n) {
|
|
16053
16326
|
let r = [];
|
|
16054
|
-
for (let i of
|
|
16327
|
+
for (let i of Qv) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16055
16328
|
await Promise.all(r);
|
|
16056
16329
|
},
|
|
16057
16330
|
async flush() {
|
|
@@ -16065,10 +16338,10 @@ function Vv(e = {}) {
|
|
|
16065
16338
|
})), c({ type: "flush" }), await b();
|
|
16066
16339
|
},
|
|
16067
16340
|
async deleteSession(e, n) {
|
|
16068
|
-
await l.clearPrefix(
|
|
16341
|
+
await l.clearPrefix(ny(t, e, n));
|
|
16069
16342
|
},
|
|
16070
16343
|
async createSession(e, n, r) {
|
|
16071
|
-
let i = r ??
|
|
16344
|
+
let i = r ?? Hv(), a = Date.now(), o = {
|
|
16072
16345
|
agentId: e,
|
|
16073
16346
|
sessionId: i,
|
|
16074
16347
|
createdAt: a,
|
|
@@ -16076,7 +16349,7 @@ function Vv(e = {}) {
|
|
|
16076
16349
|
bytes: 0,
|
|
16077
16350
|
title: n
|
|
16078
16351
|
};
|
|
16079
|
-
return await l.set(
|
|
16352
|
+
return await l.set(ty(t, e, i, Xv), o), i;
|
|
16080
16353
|
},
|
|
16081
16354
|
onEvent(e) {
|
|
16082
16355
|
s.add(e);
|
|
@@ -16091,23 +16364,27 @@ function Vv(e = {}) {
|
|
|
16091
16364
|
}
|
|
16092
16365
|
//#endregion
|
|
16093
16366
|
//#region src/core/sdk/optionsResolver.ts
|
|
16094
|
-
function
|
|
16095
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ?
|
|
16367
|
+
function py(e) {
|
|
16368
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? fy({ backend: e }) : e.enabled === !1 ? null : fy(e);
|
|
16096
16369
|
}
|
|
16097
|
-
function
|
|
16370
|
+
function my(e) {
|
|
16098
16371
|
return e.dialog ?? {};
|
|
16099
16372
|
}
|
|
16100
16373
|
//#endregion
|
|
16101
16374
|
//#region src/core/sdk/events.ts
|
|
16102
|
-
function
|
|
16375
|
+
function hy(e) {
|
|
16103
16376
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
16104
16377
|
if (n.type !== "approval_request") {
|
|
16105
16378
|
if (e) try {
|
|
16106
16379
|
e(n);
|
|
16107
|
-
} catch {
|
|
16380
|
+
} catch (e) {
|
|
16381
|
+
console.warn("[page-agent-sdk] onEvent 回调出错(observable,已忽略):", wg(e, "observable").message);
|
|
16382
|
+
}
|
|
16108
16383
|
for (let e of t) try {
|
|
16109
16384
|
e(n);
|
|
16110
|
-
} catch {
|
|
16385
|
+
} catch (e) {
|
|
16386
|
+
console.warn("[page-agent-sdk] 事件监听器出错(observable,已忽略):", wg(e, "observable").message);
|
|
16387
|
+
}
|
|
16111
16388
|
}
|
|
16112
16389
|
};
|
|
16113
16390
|
function r(e) {
|
|
@@ -16121,7 +16398,7 @@ function Wv(e) {
|
|
|
16121
16398
|
}
|
|
16122
16399
|
//#endregion
|
|
16123
16400
|
//#region src/core/sdk/contextPreset.ts
|
|
16124
|
-
var
|
|
16401
|
+
var gy = {
|
|
16125
16402
|
auto: {
|
|
16126
16403
|
summaryThresholdRatio: .5,
|
|
16127
16404
|
windowRatio: .4,
|
|
@@ -16149,7 +16426,7 @@ var Gv = {
|
|
|
16149
16426
|
enableRecall: !0,
|
|
16150
16427
|
enableLLMSummary: !0
|
|
16151
16428
|
}
|
|
16152
|
-
},
|
|
16429
|
+
}, _y = {
|
|
16153
16430
|
auto: ["describe_data", "read"],
|
|
16154
16431
|
conservative: ["describe_data"],
|
|
16155
16432
|
aggressive: ["describe_data", "read"],
|
|
@@ -16160,8 +16437,8 @@ var Gv = {
|
|
|
16160
16437
|
"search_data"
|
|
16161
16438
|
]
|
|
16162
16439
|
};
|
|
16163
|
-
function
|
|
16164
|
-
let n =
|
|
16440
|
+
function vy(e, t) {
|
|
16441
|
+
let n = gy[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
16165
16442
|
return {
|
|
16166
16443
|
...n,
|
|
16167
16444
|
...r,
|
|
@@ -16170,57 +16447,47 @@ function qv(e, t) {
|
|
|
16170
16447
|
};
|
|
16171
16448
|
}
|
|
16172
16449
|
//#endregion
|
|
16173
|
-
//#region src/core/
|
|
16174
|
-
|
|
16175
|
-
|
|
16176
|
-
|
|
16177
|
-
|
|
16178
|
-
|
|
16179
|
-
|
|
16180
|
-
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16184
|
-
|
|
16185
|
-
|
|
16186
|
-
|
|
16187
|
-
|
|
16188
|
-
|
|
16189
|
-
|
|
16190
|
-
|
|
16191
|
-
|
|
16192
|
-
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
});
|
|
16198
|
-
}
|
|
16199
|
-
function Xv(e, t, n) {
|
|
16200
|
-
let r = n?.message || String(n);
|
|
16201
|
-
return $({
|
|
16202
|
-
code: "JSON_PARSE",
|
|
16203
|
-
...e === void 0 ? {} : { path: e },
|
|
16204
|
-
message: `value 不是合法 JSON:${r}`,
|
|
16205
|
-
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
16206
|
-
});
|
|
16450
|
+
//#region src/core/sdk/middlewareStack.ts
|
|
16451
|
+
var yy = {
|
|
16452
|
+
dataHint: 10,
|
|
16453
|
+
usageHints: 20,
|
|
16454
|
+
todos: 30,
|
|
16455
|
+
skills: 40,
|
|
16456
|
+
vfs: 50,
|
|
16457
|
+
summarization: 60,
|
|
16458
|
+
memory: 70,
|
|
16459
|
+
permissions: 80,
|
|
16460
|
+
checkpoint: 90,
|
|
16461
|
+
humanConfirm: 100,
|
|
16462
|
+
approval: 110,
|
|
16463
|
+
verify: 120,
|
|
16464
|
+
subagent: 130,
|
|
16465
|
+
subagents: 140,
|
|
16466
|
+
augmentSystem: 150
|
|
16467
|
+
};
|
|
16468
|
+
function by(e) {
|
|
16469
|
+
return e.map((e, t) => ({
|
|
16470
|
+
m: e,
|
|
16471
|
+
i: t,
|
|
16472
|
+
p: yy[e.name] ?? Infinity
|
|
16473
|
+
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
16207
16474
|
}
|
|
16208
16475
|
//#endregion
|
|
16209
16476
|
//#region src/core/tools/jsonUtils.ts
|
|
16210
|
-
var
|
|
16477
|
+
var xy = /* @__PURE__ */ new Set([
|
|
16211
16478
|
"__proto__",
|
|
16212
16479
|
"constructor",
|
|
16213
16480
|
"prototype"
|
|
16214
16481
|
]);
|
|
16215
|
-
function
|
|
16216
|
-
return e.split(".").some((e) =>
|
|
16482
|
+
function Sy(e) {
|
|
16483
|
+
return e.split(".").some((e) => xy.has(e));
|
|
16217
16484
|
}
|
|
16218
|
-
function
|
|
16219
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t))
|
|
16485
|
+
function Cy(e, t) {
|
|
16486
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) xy.has(n) || (e[n] = t[n]);
|
|
16220
16487
|
}
|
|
16221
|
-
function
|
|
16488
|
+
function wy(e, t) {
|
|
16222
16489
|
if (!t) return e;
|
|
16223
|
-
if (
|
|
16490
|
+
if (Sy(t)) return;
|
|
16224
16491
|
let n = t.split("."), r = e;
|
|
16225
16492
|
for (let e of n) {
|
|
16226
16493
|
if (r == null) return;
|
|
@@ -16228,8 +16495,8 @@ function ey(e, t) {
|
|
|
16228
16495
|
}
|
|
16229
16496
|
return r;
|
|
16230
16497
|
}
|
|
16231
|
-
function
|
|
16232
|
-
if (!t ||
|
|
16498
|
+
function Ty(e, t, n) {
|
|
16499
|
+
if (!t || Sy(t)) return;
|
|
16233
16500
|
let r = t.split("."), i = e;
|
|
16234
16501
|
for (let e = 0; e < r.length - 1; e++) {
|
|
16235
16502
|
let t = r[e];
|
|
@@ -16237,8 +16504,8 @@ function ty(e, t, n) {
|
|
|
16237
16504
|
}
|
|
16238
16505
|
i[r[r.length - 1]] = n;
|
|
16239
16506
|
}
|
|
16240
|
-
function
|
|
16241
|
-
if (!t ||
|
|
16507
|
+
function Ey(e, t) {
|
|
16508
|
+
if (!t || Sy(t)) return !1;
|
|
16242
16509
|
let n = t.split("."), r = e;
|
|
16243
16510
|
for (let e = 0; e < n.length - 1; e++) {
|
|
16244
16511
|
if (r == null) return !1;
|
|
@@ -16247,10 +16514,10 @@ function ny(e, t) {
|
|
|
16247
16514
|
let i = n[n.length - 1];
|
|
16248
16515
|
return r == null || !(i in r) ? !1 : (Array.isArray(r) && /^\d+$/.test(i) ? r.splice(Number(i), 1) : delete r[i], !0);
|
|
16249
16516
|
}
|
|
16250
|
-
function
|
|
16517
|
+
function Dy(e) {
|
|
16251
16518
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
16252
16519
|
}
|
|
16253
|
-
function
|
|
16520
|
+
function Oy(e) {
|
|
16254
16521
|
if (typeof e != "string") return { parsed: e };
|
|
16255
16522
|
let t = e.trim();
|
|
16256
16523
|
if (!t) return { parsed: e };
|
|
@@ -16261,23 +16528,23 @@ function iy(e) {
|
|
|
16261
16528
|
return n ? { parseError: t } : { parsed: e };
|
|
16262
16529
|
}
|
|
16263
16530
|
}
|
|
16264
|
-
function
|
|
16531
|
+
function ky(e, t) {
|
|
16265
16532
|
if (typeof e != "object" || !e) return e;
|
|
16266
16533
|
let n = new Set(t);
|
|
16267
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
16534
|
+
if (Array.isArray(e)) return e.map((e) => ky(e, t));
|
|
16268
16535
|
let r = {};
|
|
16269
16536
|
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
16270
16537
|
return r;
|
|
16271
16538
|
}
|
|
16272
|
-
function
|
|
16539
|
+
function Ay(e, t) {
|
|
16273
16540
|
if (typeof e != "object" || !e) return e;
|
|
16274
16541
|
if (t <= 0) return Array.isArray(e) ? `[...${e.length}]` : "{...}";
|
|
16275
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
16542
|
+
if (Array.isArray(e)) return e.map((e) => Ay(e, t - 1));
|
|
16276
16543
|
let n = {};
|
|
16277
|
-
for (let r of Object.keys(e)) n[r] =
|
|
16544
|
+
for (let r of Object.keys(e)) n[r] = Ay(e[r], t - 1);
|
|
16278
16545
|
return n;
|
|
16279
16546
|
}
|
|
16280
|
-
function
|
|
16547
|
+
function jy(e, t = Infinity) {
|
|
16281
16548
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
16282
16549
|
try {
|
|
16283
16550
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -16296,34 +16563,40 @@ function sy(e, t = Infinity) {
|
|
|
16296
16563
|
}
|
|
16297
16564
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
16298
16565
|
}
|
|
16299
|
-
function
|
|
16300
|
-
let
|
|
16301
|
-
for (let
|
|
16302
|
-
|
|
16566
|
+
function My(e, t = 0) {
|
|
16567
|
+
let n = 3735928559 ^ t, r = 1103547991 ^ t;
|
|
16568
|
+
for (let t = 0; t < e.length; t++) {
|
|
16569
|
+
let i = e.charCodeAt(t);
|
|
16570
|
+
n = Math.imul(n ^ i, 2654435761), r = Math.imul(r ^ i, 1597334677);
|
|
16571
|
+
}
|
|
16572
|
+
return n = Math.imul(n ^ n >>> 16, 2246822507) ^ Math.imul(r ^ r >>> 13, 3266489909), r = Math.imul(r ^ r >>> 16, 2246822507) ^ Math.imul(n ^ n >>> 13, 3266489909), 4294967296 * (2097151 & r) + (n >>> 0);
|
|
16573
|
+
}
|
|
16574
|
+
function Ny(e) {
|
|
16575
|
+
return My(jy(e)).toString(36);
|
|
16303
16576
|
}
|
|
16304
|
-
function
|
|
16305
|
-
if (t === "set") return n ? (
|
|
16306
|
-
if (t === "remove") return n ? (
|
|
16577
|
+
function Py(e, t, n, r) {
|
|
16578
|
+
if (t === "set") return n ? (Ty(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_data)";
|
|
16579
|
+
if (t === "remove") return n ? (Ey(e, n), null) : "remove 操作需要 jsonPath";
|
|
16307
16580
|
if (t === "merge") {
|
|
16308
|
-
let t = n ?
|
|
16309
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
16581
|
+
let t = n ? wy(e, n) : e;
|
|
16582
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (Cy(t, r), null);
|
|
16310
16583
|
}
|
|
16311
|
-
let i = n ?
|
|
16584
|
+
let i = n ? wy(e, n) : e;
|
|
16312
16585
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
16313
16586
|
}
|
|
16314
|
-
function
|
|
16315
|
-
if (t === "set")
|
|
16316
|
-
else if (t === "remove")
|
|
16317
|
-
else if (t === "merge")
|
|
16587
|
+
function Fy(e, t, n, r) {
|
|
16588
|
+
if (t === "set") Ty(e, n, r);
|
|
16589
|
+
else if (t === "remove") Ey(e, n);
|
|
16590
|
+
else if (t === "merge") Cy(n ? wy(e, n) : e, r);
|
|
16318
16591
|
else {
|
|
16319
|
-
let t = n ?
|
|
16592
|
+
let t = n ? wy(e, n) : e;
|
|
16320
16593
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
16321
16594
|
}
|
|
16322
16595
|
}
|
|
16323
|
-
function
|
|
16324
|
-
typeof e == "object" && e &&
|
|
16596
|
+
function Iy(e, t) {
|
|
16597
|
+
typeof e == "object" && e && Ly(e, t);
|
|
16325
16598
|
}
|
|
16326
|
-
function
|
|
16599
|
+
function Ly(e, t) {
|
|
16327
16600
|
if (Array.isArray(e)) {
|
|
16328
16601
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
16329
16602
|
return;
|
|
@@ -16332,44 +16605,82 @@ function fy(e, t) {
|
|
|
16332
16605
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
16333
16606
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
16334
16607
|
}
|
|
16335
|
-
|
|
16608
|
+
function Ry(e, t, n = "") {
|
|
16609
|
+
let r = [];
|
|
16610
|
+
if (!(typeof e == "object" && e) || !(typeof t == "object" && t) || Array.isArray(e) !== Array.isArray(t)) return e !== t && r.push({
|
|
16611
|
+
path: n || "(root)",
|
|
16612
|
+
from: e,
|
|
16613
|
+
to: t
|
|
16614
|
+
}), r;
|
|
16615
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
16616
|
+
let i = Math.max(e.length, t.length);
|
|
16617
|
+
for (let a = 0; a < i; a++) {
|
|
16618
|
+
let i = n ? `${n}.${a}` : `${a}`;
|
|
16619
|
+
a >= e.length ? r.push({
|
|
16620
|
+
path: i,
|
|
16621
|
+
from: void 0,
|
|
16622
|
+
to: t[a]
|
|
16623
|
+
}) : a >= t.length ? r.push({
|
|
16624
|
+
path: i,
|
|
16625
|
+
from: e[a],
|
|
16626
|
+
to: void 0
|
|
16627
|
+
}) : r.push(...Ry(e[a], t[a], i));
|
|
16628
|
+
}
|
|
16629
|
+
return r;
|
|
16630
|
+
}
|
|
16631
|
+
let i = e, a = t, o = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(a)]);
|
|
16632
|
+
for (let e of o) {
|
|
16633
|
+
let t = n ? `${n}.${e}` : e;
|
|
16634
|
+
e in i ? e in a ? r.push(...Ry(i[e], a[e], t)) : r.push({
|
|
16635
|
+
path: t,
|
|
16636
|
+
from: i[e],
|
|
16637
|
+
to: void 0
|
|
16638
|
+
}) : r.push({
|
|
16639
|
+
path: t,
|
|
16640
|
+
from: void 0,
|
|
16641
|
+
to: a[e]
|
|
16642
|
+
});
|
|
16643
|
+
}
|
|
16644
|
+
return r;
|
|
16645
|
+
}
|
|
16646
|
+
var zy = {
|
|
16336
16647
|
largeResults: 4194304,
|
|
16337
16648
|
drafts: 2097152,
|
|
16338
16649
|
userFiles: 2097152
|
|
16339
|
-
},
|
|
16650
|
+
}, By = [
|
|
16340
16651
|
"largeResults",
|
|
16341
16652
|
"drafts",
|
|
16342
16653
|
"userFiles"
|
|
16343
|
-
],
|
|
16344
|
-
function
|
|
16654
|
+
], Vy = .9;
|
|
16655
|
+
function Hy(e, t = {}) {
|
|
16345
16656
|
let n = Object.create(null);
|
|
16346
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
16657
|
+
if (e) for (let [t, r] of Object.entries(e)) n[Ky(t)] = {
|
|
16347
16658
|
content: r,
|
|
16348
|
-
updatedAt:
|
|
16659
|
+
updatedAt: Jy()
|
|
16349
16660
|
};
|
|
16350
16661
|
let { persist: r } = t, i = t.maxBytes ?? 8388608, a = {
|
|
16351
|
-
...
|
|
16662
|
+
...zy,
|
|
16352
16663
|
...t.poolBytes ?? {}
|
|
16353
16664
|
};
|
|
16354
16665
|
function o(e) {
|
|
16355
|
-
let t =
|
|
16666
|
+
let t = Ky(e);
|
|
16356
16667
|
return t.startsWith("large_results/") ? "largeResults" : t.startsWith("drafts/") ? "drafts" : "userFiles";
|
|
16357
16668
|
}
|
|
16358
16669
|
function s(e) {
|
|
16359
16670
|
let t = 0;
|
|
16360
|
-
for (let [r, i] of Object.entries(n)) o(r) === e && (t +=
|
|
16671
|
+
for (let [r, i] of Object.entries(n)) o(r) === e && (t += Wy(i.content));
|
|
16361
16672
|
return t;
|
|
16362
16673
|
}
|
|
16363
16674
|
function c() {
|
|
16364
|
-
for (let e of
|
|
16675
|
+
for (let e of By) {
|
|
16365
16676
|
let t = a[e];
|
|
16366
16677
|
if (s(e) <= t) continue;
|
|
16367
|
-
let r = t *
|
|
16678
|
+
let r = t * Vy, i = Object.entries(n).filter(([t]) => o(t) === e).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
16368
16679
|
for (let [t] of i) if (delete n[t], s(e) <= r) break;
|
|
16369
16680
|
}
|
|
16370
|
-
if (
|
|
16371
|
-
let e = i *
|
|
16372
|
-
for (let [r] of t) if (delete n[r],
|
|
16681
|
+
if (Gy(n) > i) {
|
|
16682
|
+
let e = i * Vy, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
16683
|
+
for (let [r] of t) if (delete n[r], Gy(n) <= e) break;
|
|
16373
16684
|
}
|
|
16374
16685
|
}
|
|
16375
16686
|
let l = null;
|
|
@@ -16395,7 +16706,7 @@ function gy(e, t = {}) {
|
|
|
16395
16706
|
}
|
|
16396
16707
|
}) };
|
|
16397
16708
|
return r && (f.hydrate = (e) => {
|
|
16398
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
16709
|
+
for (let [t, r] of Object.entries(e)) n[Ky(t)] = r;
|
|
16399
16710
|
c();
|
|
16400
16711
|
}, f.flush = () => {
|
|
16401
16712
|
l &&= (clearTimeout(l), null), u();
|
|
@@ -16404,19 +16715,19 @@ function gy(e, t = {}) {
|
|
|
16404
16715
|
d();
|
|
16405
16716
|
}), f;
|
|
16406
16717
|
}
|
|
16407
|
-
var
|
|
16408
|
-
function
|
|
16409
|
-
return
|
|
16718
|
+
var Uy = null;
|
|
16719
|
+
function Wy(e) {
|
|
16720
|
+
return Uy ||= new TextEncoder(), Uy.encode(e).length;
|
|
16410
16721
|
}
|
|
16411
|
-
function
|
|
16722
|
+
function Gy(e) {
|
|
16412
16723
|
let t = 0;
|
|
16413
|
-
for (let n of Object.values(e)) t +=
|
|
16724
|
+
for (let n of Object.values(e)) t += Wy(n.content);
|
|
16414
16725
|
return t;
|
|
16415
16726
|
}
|
|
16416
|
-
function
|
|
16727
|
+
function Ky(e) {
|
|
16417
16728
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
16418
16729
|
}
|
|
16419
|
-
function
|
|
16730
|
+
function qy(e) {
|
|
16420
16731
|
let t = "";
|
|
16421
16732
|
for (let n = 0; n < e.length; n++) {
|
|
16422
16733
|
let r = e[n];
|
|
@@ -16424,10 +16735,10 @@ function xy(e) {
|
|
|
16424
16735
|
}
|
|
16425
16736
|
return RegExp("^" + t + "$");
|
|
16426
16737
|
}
|
|
16427
|
-
function
|
|
16738
|
+
function Jy() {
|
|
16428
16739
|
return Date.now();
|
|
16429
16740
|
}
|
|
16430
|
-
var
|
|
16741
|
+
var Yy = [
|
|
16431
16742
|
"vfs_read",
|
|
16432
16743
|
"vfs_write",
|
|
16433
16744
|
"vfs_edit",
|
|
@@ -16437,10 +16748,10 @@ var Cy = [
|
|
|
16437
16748
|
"vfs_json_read",
|
|
16438
16749
|
"vfs_json_patch"
|
|
16439
16750
|
];
|
|
16440
|
-
function
|
|
16751
|
+
function Xy(e) {
|
|
16441
16752
|
return [
|
|
16442
16753
|
r(async ({ path: t, offset: n, limit: r }) => {
|
|
16443
|
-
let i = e.files[
|
|
16754
|
+
let i = e.files[Ky(t)];
|
|
16444
16755
|
if (!i) return $({
|
|
16445
16756
|
code: "NOT_FOUND",
|
|
16446
16757
|
path: t,
|
|
@@ -16469,9 +16780,9 @@ function wy(e) {
|
|
|
16469
16780
|
hint: "jsonString=true 要求 content 是合法 JSON;检查引号/逗号/括号配对;或省略 jsonString 写纯文本"
|
|
16470
16781
|
});
|
|
16471
16782
|
}
|
|
16472
|
-
return e.files[
|
|
16783
|
+
return e.files[Ky(t)] = {
|
|
16473
16784
|
content: n,
|
|
16474
|
-
updatedAt:
|
|
16785
|
+
updatedAt: Jy()
|
|
16475
16786
|
}, `已写入 ${t}(${n.length} 字符)${r ? "(JSON 校验通过)" : ""}`;
|
|
16476
16787
|
}, {
|
|
16477
16788
|
name: "vfs_write",
|
|
@@ -16483,7 +16794,7 @@ function wy(e) {
|
|
|
16483
16794
|
})
|
|
16484
16795
|
}),
|
|
16485
16796
|
r(async ({ path: t, oldString: n, newString: r }) => {
|
|
16486
|
-
let i =
|
|
16797
|
+
let i = Ky(t), a = e.files[i];
|
|
16487
16798
|
if (!a) return $({
|
|
16488
16799
|
code: "NOT_FOUND",
|
|
16489
16800
|
path: t,
|
|
@@ -16513,7 +16824,7 @@ function wy(e) {
|
|
|
16513
16824
|
}
|
|
16514
16825
|
return e.files[i] = {
|
|
16515
16826
|
content: a.content.replace(n, r),
|
|
16516
|
-
updatedAt:
|
|
16827
|
+
updatedAt: Jy()
|
|
16517
16828
|
}, `已替换 ${t} 中 1 处。`;
|
|
16518
16829
|
}, {
|
|
16519
16830
|
name: "vfs_edit",
|
|
@@ -16535,7 +16846,7 @@ function wy(e) {
|
|
|
16535
16846
|
r(async ({ pattern: t }) => {
|
|
16536
16847
|
let n;
|
|
16537
16848
|
try {
|
|
16538
|
-
n =
|
|
16849
|
+
n = qy(t);
|
|
16539
16850
|
} catch (e) {
|
|
16540
16851
|
return $({
|
|
16541
16852
|
code: "GLOB_INVALID",
|
|
@@ -16564,7 +16875,7 @@ function wy(e) {
|
|
|
16564
16875
|
details: { pattern: t }
|
|
16565
16876
|
});
|
|
16566
16877
|
}
|
|
16567
|
-
let i = n ? [
|
|
16878
|
+
let i = n ? [Ky(n)] : Object.keys(e.files), a = [];
|
|
16568
16879
|
for (let t of i) {
|
|
16569
16880
|
let n = e.files[t];
|
|
16570
16881
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -16581,7 +16892,7 @@ function wy(e) {
|
|
|
16581
16892
|
})
|
|
16582
16893
|
}),
|
|
16583
16894
|
r(async ({ path: t, jsonPath: n }) => {
|
|
16584
|
-
let r =
|
|
16895
|
+
let r = Ky(t), i = e.files[r];
|
|
16585
16896
|
if (!i) return $({
|
|
16586
16897
|
code: "NOT_FOUND",
|
|
16587
16898
|
path: t,
|
|
@@ -16600,7 +16911,7 @@ function wy(e) {
|
|
|
16600
16911
|
});
|
|
16601
16912
|
}
|
|
16602
16913
|
if (n) {
|
|
16603
|
-
let e =
|
|
16914
|
+
let e = wy(a, n);
|
|
16604
16915
|
return e === void 0 ? $({
|
|
16605
16916
|
code: "VFS_PATH_NOT_FOUND",
|
|
16606
16917
|
path: t,
|
|
@@ -16618,7 +16929,7 @@ function wy(e) {
|
|
|
16618
16929
|
})
|
|
16619
16930
|
}),
|
|
16620
16931
|
r(async ({ path: t, patches: n }) => {
|
|
16621
|
-
let r =
|
|
16932
|
+
let r = Ky(t), i = e.files[r];
|
|
16622
16933
|
if (!i) return $({
|
|
16623
16934
|
code: "NOT_FOUND",
|
|
16624
16935
|
path: t,
|
|
@@ -16636,9 +16947,9 @@ function wy(e) {
|
|
|
16636
16947
|
hint: "vfs_json_patch 要求文件内容是合法 JSON"
|
|
16637
16948
|
});
|
|
16638
16949
|
}
|
|
16639
|
-
let o =
|
|
16950
|
+
let o = Dy(a), s = [];
|
|
16640
16951
|
for (let e of n) {
|
|
16641
|
-
let n =
|
|
16952
|
+
let n = Py(o, e.op, e.jsonPath, e.value);
|
|
16642
16953
|
if (n) return $({
|
|
16643
16954
|
code: "PATCH_FAILED",
|
|
16644
16955
|
path: t,
|
|
@@ -16651,7 +16962,7 @@ function wy(e) {
|
|
|
16651
16962
|
let c = JSON.stringify(o);
|
|
16652
16963
|
return e.files[r] = {
|
|
16653
16964
|
content: c,
|
|
16654
|
-
updatedAt:
|
|
16965
|
+
updatedAt: Jy()
|
|
16655
16966
|
}, `已对 ${t} 应用 ${n.length} 个 patch(影响 ${s.length} 处:${s.join(", ")}),文件现 ${c.length} 字符`;
|
|
16656
16967
|
}, {
|
|
16657
16968
|
name: "vfs_json_patch",
|
|
@@ -16672,17 +16983,17 @@ function wy(e) {
|
|
|
16672
16983
|
})
|
|
16673
16984
|
];
|
|
16674
16985
|
}
|
|
16675
|
-
function
|
|
16986
|
+
function Zy(e) {
|
|
16676
16987
|
return {
|
|
16677
16988
|
name: "vfs",
|
|
16678
|
-
tools:
|
|
16989
|
+
tools: Xy(e),
|
|
16679
16990
|
beforeAgent: () => ({ files: e.files })
|
|
16680
16991
|
};
|
|
16681
16992
|
}
|
|
16682
16993
|
//#endregion
|
|
16683
16994
|
//#region src/core/tools/dataSlotQuery.ts
|
|
16684
|
-
var
|
|
16685
|
-
function
|
|
16995
|
+
var Qy = /[\w$-]/;
|
|
16996
|
+
function $y(e) {
|
|
16686
16997
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
16687
16998
|
for (; r < n.length;) {
|
|
16688
16999
|
let e = n[r];
|
|
@@ -16693,7 +17004,7 @@ function Dy(e) {
|
|
|
16693
17004
|
continue;
|
|
16694
17005
|
}
|
|
16695
17006
|
let e = "";
|
|
16696
|
-
for (; r < n.length &&
|
|
17007
|
+
for (; r < n.length && Qy.test(n[r]);) e += n[r++];
|
|
16697
17008
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
16698
17009
|
t.push({
|
|
16699
17010
|
type: "descendKey",
|
|
@@ -16706,7 +17017,7 @@ function Dy(e) {
|
|
|
16706
17017
|
continue;
|
|
16707
17018
|
}
|
|
16708
17019
|
let e = "";
|
|
16709
|
-
for (; r < n.length &&
|
|
17020
|
+
for (; r < n.length && Qy.test(n[r]);) e += n[r++];
|
|
16710
17021
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
16711
17022
|
t.push({
|
|
16712
17023
|
type: "key",
|
|
@@ -16762,7 +17073,7 @@ function Dy(e) {
|
|
|
16762
17073
|
}
|
|
16763
17074
|
return t;
|
|
16764
17075
|
}
|
|
16765
|
-
function
|
|
17076
|
+
function eb(e) {
|
|
16766
17077
|
let t = [], n = 0, r = e.trim();
|
|
16767
17078
|
for (; n < r.length;) {
|
|
16768
17079
|
let e = r[n];
|
|
@@ -16807,7 +17118,7 @@ function Oy(e) {
|
|
|
16807
17118
|
}
|
|
16808
17119
|
return t;
|
|
16809
17120
|
}
|
|
16810
|
-
var
|
|
17121
|
+
var tb = class {
|
|
16811
17122
|
toks;
|
|
16812
17123
|
item;
|
|
16813
17124
|
pos = 0;
|
|
@@ -16843,12 +17154,12 @@ var ky = class {
|
|
|
16843
17154
|
return this.next(), e;
|
|
16844
17155
|
}
|
|
16845
17156
|
let e = this.operand(), t = this.peek();
|
|
16846
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
17157
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), ib(t, e, this.operand())) : nb(e);
|
|
16847
17158
|
}
|
|
16848
17159
|
operand() {
|
|
16849
17160
|
let e = this.next();
|
|
16850
17161
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
16851
|
-
if (e.startsWith("@")) return
|
|
17162
|
+
if (e.startsWith("@")) return rb(e, this.item);
|
|
16852
17163
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
16853
17164
|
if (e === "true") return !0;
|
|
16854
17165
|
if (e === "false") return !1;
|
|
@@ -16858,10 +17169,10 @@ var ky = class {
|
|
|
16858
17169
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
16859
17170
|
}
|
|
16860
17171
|
};
|
|
16861
|
-
function
|
|
17172
|
+
function nb(e) {
|
|
16862
17173
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
16863
17174
|
}
|
|
16864
|
-
function
|
|
17175
|
+
function rb(e, t) {
|
|
16865
17176
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
16866
17177
|
for (let e of n) {
|
|
16867
17178
|
if (typeof r != "object" || !r) return;
|
|
@@ -16869,7 +17180,7 @@ function jy(e, t) {
|
|
|
16869
17180
|
}
|
|
16870
17181
|
return r;
|
|
16871
17182
|
}
|
|
16872
|
-
function
|
|
17183
|
+
function ib(e, t, n) {
|
|
16873
17184
|
switch (e) {
|
|
16874
17185
|
case "==": return t === n;
|
|
16875
17186
|
case "!=": return t !== n;
|
|
@@ -16880,47 +17191,47 @@ function My(e, t, n) {
|
|
|
16880
17191
|
default: return !1;
|
|
16881
17192
|
}
|
|
16882
17193
|
}
|
|
16883
|
-
function
|
|
16884
|
-
return new
|
|
17194
|
+
function ab(e, t) {
|
|
17195
|
+
return new tb(eb(e), t).parse();
|
|
16885
17196
|
}
|
|
16886
|
-
function
|
|
17197
|
+
function ob(e, t) {
|
|
16887
17198
|
return e ? `${e}.${t}` : String(t);
|
|
16888
17199
|
}
|
|
16889
|
-
function
|
|
17200
|
+
function sb(e, t) {
|
|
16890
17201
|
let n = [{
|
|
16891
17202
|
path: "",
|
|
16892
17203
|
value: e
|
|
16893
17204
|
}];
|
|
16894
|
-
for (let e of
|
|
17205
|
+
for (let e of $y(t)) {
|
|
16895
17206
|
let t = [];
|
|
16896
17207
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
16897
|
-
path:
|
|
17208
|
+
path: ob(r.path, e.key),
|
|
16898
17209
|
value: r.value[e.key]
|
|
16899
17210
|
});
|
|
16900
17211
|
else if (e.type === "index") {
|
|
16901
17212
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
16902
17213
|
let n = r.value[e.index];
|
|
16903
17214
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
16904
|
-
path:
|
|
17215
|
+
path: ob(r.path, e.index),
|
|
16905
17216
|
value: n,
|
|
16906
17217
|
index: e.index
|
|
16907
17218
|
});
|
|
16908
17219
|
}
|
|
16909
17220
|
} else if (e.type === "wildcard") {
|
|
16910
17221
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
16911
|
-
path:
|
|
17222
|
+
path: ob(e.path, r),
|
|
16912
17223
|
value: n,
|
|
16913
17224
|
index: r
|
|
16914
17225
|
}));
|
|
16915
17226
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
16916
|
-
path:
|
|
17227
|
+
path: ob(e.path, n),
|
|
16917
17228
|
value: e.value[n]
|
|
16918
17229
|
});
|
|
16919
17230
|
} else if (e.type === "descendKey") {
|
|
16920
17231
|
let r = e.key, i = (e) => {
|
|
16921
17232
|
if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) {
|
|
16922
17233
|
let a = {
|
|
16923
|
-
path:
|
|
17234
|
+
path: ob(e.path, n),
|
|
16924
17235
|
value: e.value[n]
|
|
16925
17236
|
};
|
|
16926
17237
|
n === r && t.push(a), i(a);
|
|
@@ -16931,7 +17242,7 @@ function Fy(e, t) {
|
|
|
16931
17242
|
let e = (n) => {
|
|
16932
17243
|
if (n.value != null && typeof n.value == "object") for (let r of Object.keys(n.value)) {
|
|
16933
17244
|
let i = {
|
|
16934
|
-
path:
|
|
17245
|
+
path: ob(n.path, r),
|
|
16935
17246
|
value: n.value[r]
|
|
16936
17247
|
};
|
|
16937
17248
|
t.push(i), e(i);
|
|
@@ -16940,16 +17251,16 @@ function Fy(e, t) {
|
|
|
16940
17251
|
for (let t of n) e(t);
|
|
16941
17252
|
} else if (e.type === "filter") {
|
|
16942
17253
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
16943
|
-
|
|
16944
|
-
path:
|
|
17254
|
+
ab(e.filter, n) && t.push({
|
|
17255
|
+
path: ob(r.path, i),
|
|
16945
17256
|
value: n,
|
|
16946
17257
|
index: i
|
|
16947
17258
|
});
|
|
16948
17259
|
});
|
|
16949
17260
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
16950
17261
|
let i = r.value[n];
|
|
16951
|
-
|
|
16952
|
-
path:
|
|
17262
|
+
ab(e.filter, i) && t.push({
|
|
17263
|
+
path: ob(r.path, n),
|
|
16953
17264
|
value: i
|
|
16954
17265
|
});
|
|
16955
17266
|
}
|
|
@@ -16958,7 +17269,7 @@ function Fy(e, t) {
|
|
|
16958
17269
|
}
|
|
16959
17270
|
return n;
|
|
16960
17271
|
}
|
|
16961
|
-
function
|
|
17272
|
+
function cb(e, t) {
|
|
16962
17273
|
let n = e.length, r = t.length;
|
|
16963
17274
|
if (!n) return r;
|
|
16964
17275
|
if (!r) return n;
|
|
@@ -16974,7 +17285,7 @@ function Iy(e, t) {
|
|
|
16974
17285
|
}
|
|
16975
17286
|
return i[r];
|
|
16976
17287
|
}
|
|
16977
|
-
function
|
|
17288
|
+
function lb(e, t, n = {}) {
|
|
16978
17289
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
16979
17290
|
if (r === "regex") try {
|
|
16980
17291
|
s = new RegExp(t, "i");
|
|
@@ -16984,11 +17295,11 @@ function Ly(e, t, n = {}) {
|
|
|
16984
17295
|
let c = (e, l, u) => {
|
|
16985
17296
|
if (o.length >= i || e == null) return;
|
|
16986
17297
|
if (typeof e == "object") {
|
|
16987
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
16988
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
17298
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, ob(l, t), String(t)));
|
|
17299
|
+
else for (let t of Object.keys(e)) c(e[t], ob(l, t), t);
|
|
16989
17300
|
return;
|
|
16990
17301
|
}
|
|
16991
|
-
let d = String(e), f =
|
|
17302
|
+
let d = String(e), f = ub(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
16992
17303
|
if (f) {
|
|
16993
17304
|
o.push({
|
|
16994
17305
|
path: l,
|
|
@@ -16999,7 +17310,7 @@ function Ly(e, t, n = {}) {
|
|
|
16999
17310
|
return;
|
|
17000
17311
|
}
|
|
17001
17312
|
if (a && u) {
|
|
17002
|
-
let e =
|
|
17313
|
+
let e = ub(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
17003
17314
|
e && o.push({
|
|
17004
17315
|
path: l,
|
|
17005
17316
|
key: u,
|
|
@@ -17010,18 +17321,18 @@ function Ly(e, t, n = {}) {
|
|
|
17010
17321
|
};
|
|
17011
17322
|
return c(e, ""), o;
|
|
17012
17323
|
}
|
|
17013
|
-
function
|
|
17324
|
+
function ub(e, t, n, r, i) {
|
|
17014
17325
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
17015
17326
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
17016
17327
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
17017
17328
|
if (n === "fuzzy") {
|
|
17018
17329
|
if (a.includes(o)) return 2;
|
|
17019
|
-
let e =
|
|
17330
|
+
let e = cb(a, o);
|
|
17020
17331
|
return e <= r ? r - e + 1 : null;
|
|
17021
17332
|
}
|
|
17022
17333
|
return null;
|
|
17023
17334
|
}
|
|
17024
|
-
var
|
|
17335
|
+
var db = [
|
|
17025
17336
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
17026
17337
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
17027
17338
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -17034,7 +17345,7 @@ var zy = [
|
|
|
17034
17345
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
17035
17346
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
17036
17347
|
].join("\n");
|
|
17037
|
-
function
|
|
17348
|
+
function fb(e, t, n = 3e3) {
|
|
17038
17349
|
return new Promise((r) => {
|
|
17039
17350
|
let i = Date.now(), a = !1, o = (e) => {
|
|
17040
17351
|
if (!a) {
|
|
@@ -17047,7 +17358,7 @@ function By(e, t, n = 3e3) {
|
|
|
17047
17358
|
elapsedMs: Date.now() - i
|
|
17048
17359
|
});
|
|
17049
17360
|
}
|
|
17050
|
-
}, s =
|
|
17361
|
+
}, s = db + "\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;
|
|
17051
17362
|
try {
|
|
17052
17363
|
let e = new Blob([s], { type: "application/javascript" });
|
|
17053
17364
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -17081,112 +17392,30 @@ function By(e, t, n = 3e3) {
|
|
|
17081
17392
|
});
|
|
17082
17393
|
}
|
|
17083
17394
|
//#endregion
|
|
17084
|
-
//#region src/core/tools/schemaUtils.ts
|
|
17085
|
-
function Vy(e) {
|
|
17086
|
-
let t = e;
|
|
17087
|
-
for (let e = 0; e < 5 && t && t._def; e++) {
|
|
17088
|
-
if (t._def.innerType) {
|
|
17089
|
-
t = t._def.innerType;
|
|
17090
|
-
continue;
|
|
17091
|
-
}
|
|
17092
|
-
break;
|
|
17093
|
-
}
|
|
17094
|
-
if (!t || !t.shape || typeof t.shape != "object") return null;
|
|
17095
|
-
try {
|
|
17096
|
-
let e = typeof t.shape == "function" ? t.shape() : t.shape;
|
|
17097
|
-
return Object.keys(e);
|
|
17098
|
-
} catch {
|
|
17099
|
-
return null;
|
|
17100
|
-
}
|
|
17101
|
-
}
|
|
17102
|
-
function Hy(e, t, n) {
|
|
17103
|
-
if (!n || !e) return !0;
|
|
17104
|
-
let r = Uy(t);
|
|
17105
|
-
for (let t of e.split(".")) {
|
|
17106
|
-
if (!r) return !1;
|
|
17107
|
-
if (r = Uy(r), r && r.shape && typeof r.shape == "object") {
|
|
17108
|
-
let e = typeof r.shape == "function" ? r.shape() : r.shape;
|
|
17109
|
-
if (!(t in e)) return !1;
|
|
17110
|
-
r = e[t];
|
|
17111
|
-
} else if (r && (r._def?.type || r.element)) r = r.element ?? r._def?.type;
|
|
17112
|
-
else return !1;
|
|
17113
|
-
}
|
|
17114
|
-
return !0;
|
|
17115
|
-
}
|
|
17116
|
-
function Uy(e) {
|
|
17117
|
-
let t = e;
|
|
17118
|
-
for (let e = 0; e < 8 && t && t._def; e++) {
|
|
17119
|
-
if (t._def.innerType) {
|
|
17120
|
-
t = t._def.innerType;
|
|
17121
|
-
continue;
|
|
17122
|
-
}
|
|
17123
|
-
if (t._def.schema) {
|
|
17124
|
-
t = t._def.schema;
|
|
17125
|
-
continue;
|
|
17126
|
-
}
|
|
17127
|
-
if (t._def.getter) {
|
|
17128
|
-
t = t._def.getter();
|
|
17129
|
-
continue;
|
|
17130
|
-
}
|
|
17131
|
-
break;
|
|
17132
|
-
}
|
|
17133
|
-
return t;
|
|
17134
|
-
}
|
|
17135
|
-
function Wy(e, t) {
|
|
17136
|
-
if (!t) return e;
|
|
17137
|
-
let n = Uy(e), r = t.split(".");
|
|
17138
|
-
for (let e of r) {
|
|
17139
|
-
if (!n) return null;
|
|
17140
|
-
if (n = Uy(n), n && n.shape && typeof n.shape == "object") n = (typeof n.shape == "function" ? n.shape() : n.shape)[e];
|
|
17141
|
-
else if (n && (n._def?.type || n.element)) n = n.element ?? n._def?.type;
|
|
17142
|
-
else return null;
|
|
17143
|
-
}
|
|
17144
|
-
return n ?? null;
|
|
17145
|
-
}
|
|
17146
|
-
function Gy(e, t) {
|
|
17147
|
-
if (typeof e != "object" || !e || !t) return e;
|
|
17148
|
-
let n = Uy(t);
|
|
17149
|
-
if (!n || !n.shape) {
|
|
17150
|
-
if (Array.isArray(e) && (n?._def?.type || n?.element)) {
|
|
17151
|
-
let t = n.element ?? n._def?.type;
|
|
17152
|
-
return e.map((e) => Gy(e, t));
|
|
17153
|
-
}
|
|
17154
|
-
return e;
|
|
17155
|
-
}
|
|
17156
|
-
let r = typeof n.shape == "function" ? n.shape() : n.shape, i = {};
|
|
17157
|
-
for (let t of Object.keys(e)) if (t in r) {
|
|
17158
|
-
let n = e[t];
|
|
17159
|
-
i[t] = Gy(n, r[t]);
|
|
17160
|
-
}
|
|
17161
|
-
return i;
|
|
17162
|
-
}
|
|
17163
|
-
function Ky(e, t) {
|
|
17164
|
-
if (!t || typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
17165
|
-
let n = new Set(t), r = {};
|
|
17166
|
-
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
17167
|
-
return r;
|
|
17168
|
-
}
|
|
17169
|
-
//#endregion
|
|
17170
17395
|
//#region src/core/tools/dataOps.ts
|
|
17171
|
-
var
|
|
17396
|
+
var pb = /* @__PURE__ */ new Set([
|
|
17172
17397
|
"describe_data",
|
|
17173
17398
|
"get_data",
|
|
17174
17399
|
"set_data",
|
|
17175
17400
|
"edit_data",
|
|
17176
|
-
"delete_data"
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
|
|
17182
|
-
|
|
17401
|
+
"delete_data",
|
|
17402
|
+
"schema_data",
|
|
17403
|
+
"snapshot_data",
|
|
17404
|
+
"list_data_snapshots",
|
|
17405
|
+
"diff_data"
|
|
17406
|
+
]), mb = /* @__PURE__ */ new Set(["read", "write"]);
|
|
17407
|
+
function hb(e, t = "simple") {
|
|
17408
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => mb.has(e.name)) : e.filter((e) => !pb.has(e.name));
|
|
17409
|
+
}
|
|
17410
|
+
function gb(e, n = {}) {
|
|
17411
|
+
let i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = gv(i), c = [], l = n.maxSnapshots ?? 20, u, d = n.autoLock !== !1, f = {
|
|
17183
17412
|
get: () => ({
|
|
17184
17413
|
schema: i,
|
|
17185
17414
|
bind: a,
|
|
17186
17415
|
description: o
|
|
17187
17416
|
}),
|
|
17188
17417
|
set: (e) => {
|
|
17189
|
-
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s =
|
|
17418
|
+
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = gv(i), c.length = 0, u = void 0;
|
|
17190
17419
|
},
|
|
17191
17420
|
update: (e) => {
|
|
17192
17421
|
a = e, c.length = 0, u = void 0;
|
|
@@ -17195,7 +17424,7 @@ function Xy(e, n = {}) {
|
|
|
17195
17424
|
n.onAudit?.(e);
|
|
17196
17425
|
};
|
|
17197
17426
|
function m(e, t) {
|
|
17198
|
-
let n =
|
|
17427
|
+
let n = Dy(a), r = c.length ? c[c.length - 1].id + 1 : 1;
|
|
17199
17428
|
for (c.push({
|
|
17200
17429
|
id: r,
|
|
17201
17430
|
ts: Date.now(),
|
|
@@ -17207,12 +17436,12 @@ function Xy(e, n = {}) {
|
|
|
17207
17436
|
}
|
|
17208
17437
|
async function h(e, t, r) {
|
|
17209
17438
|
if (!t || t === "") return null;
|
|
17210
|
-
let i =
|
|
17439
|
+
let i = Ny(a);
|
|
17211
17440
|
if (i === t) return null;
|
|
17212
17441
|
if (!n.onConflict) return $({
|
|
17213
17442
|
code: "VERSION_CONFLICT",
|
|
17214
17443
|
message: `乐观锁冲突:expectedHash=${t} 但当前 hash=${i}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,
|
|
17215
|
-
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${
|
|
17444
|
+
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${jy(a, 400)}`
|
|
17216
17445
|
});
|
|
17217
17446
|
let o = await n.onConflict({
|
|
17218
17447
|
op: e,
|
|
@@ -17222,11 +17451,11 @@ function Xy(e, n = {}) {
|
|
|
17222
17451
|
expectedHash: t,
|
|
17223
17452
|
snapshotId: 0
|
|
17224
17453
|
});
|
|
17225
|
-
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${
|
|
17454
|
+
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${jy(a, 400)} (hash=${i})。请重新 read 拿最新值与 hash 再改。`;
|
|
17226
17455
|
if (o.action === "restore") {
|
|
17227
|
-
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${
|
|
17456
|
+
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${jy(a, 400)} (hash=${i})。请重新 read 再改或选「强制覆盖」。`;
|
|
17228
17457
|
let e = c[c.length - 1];
|
|
17229
|
-
return
|
|
17458
|
+
return Iy(a, Dy(e.value)), `已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${jy(a, 400)} (hash=${Ny(a)})。请基于回退后的值重写或停止。`;
|
|
17230
17459
|
}
|
|
17231
17460
|
return null;
|
|
17232
17461
|
}
|
|
@@ -17238,15 +17467,15 @@ function Xy(e, n = {}) {
|
|
|
17238
17467
|
}),
|
|
17239
17468
|
r(async ({ jsonPath: e }) => {
|
|
17240
17469
|
let t = e || "";
|
|
17241
|
-
if (!
|
|
17470
|
+
if (!_v(t, i, s)) return $({
|
|
17242
17471
|
code: "PATH_DENIED",
|
|
17243
17472
|
message: `get_data @ "${t}" 不在 schema 声明字段内(仅 schema 声明的 key 可读)`,
|
|
17244
17473
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
17245
17474
|
});
|
|
17246
|
-
let n = t ?
|
|
17247
|
-
t || (n =
|
|
17248
|
-
let r =
|
|
17249
|
-
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${
|
|
17475
|
+
let n = t ? wy(a, t) : a;
|
|
17476
|
+
t || (n = xv(n, s));
|
|
17477
|
+
let r = Ny(a);
|
|
17478
|
+
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${jy(n)} (hash=${r})`;
|
|
17250
17479
|
}, {
|
|
17251
17480
|
name: "get_data",
|
|
17252
17481
|
description: "读取主数据的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改前先 read/get 拿 hash,写入时传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"。jsonPath 可选:读整个主数据不传,读子路径传(如 components.0.text)。",
|
|
@@ -17255,19 +17484,19 @@ function Xy(e, n = {}) {
|
|
|
17255
17484
|
r(async ({ value: e, expectedHash: t }) => {
|
|
17256
17485
|
let n = await h("set", t || (d ? u : void 0));
|
|
17257
17486
|
if (n !== null) return n;
|
|
17258
|
-
let r, o =
|
|
17259
|
-
if (o.parseError) return
|
|
17487
|
+
let r, o = Oy(e);
|
|
17488
|
+
if (o.parseError) return Sg("", e, o.parseError);
|
|
17260
17489
|
r = o.parsed;
|
|
17261
17490
|
let c = i.safeParse(r);
|
|
17262
17491
|
return c.success ? typeof a != "object" || !a ? $({
|
|
17263
17492
|
code: "LEAF_BIND",
|
|
17264
17493
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),set_data 无法就地替换外部持有的值引用`,
|
|
17265
17494
|
hint: "主数据 bind 必须为对象/数组(低代码主 JSON 本就是);叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
17266
|
-
}) : (m("set"), c.data !== null && typeof c.data == "object" && (s ?
|
|
17495
|
+
}) : (m("set"), c.data !== null && typeof c.data == "object" && (s ? Cy(a, c.data) : Ly(a, c.data)), p({
|
|
17267
17496
|
op: "set",
|
|
17268
17497
|
value: c.data,
|
|
17269
17498
|
timestamp: Date.now()
|
|
17270
|
-
}), u =
|
|
17499
|
+
}), u = Ny(a), `已设置主数据 = ${jy(c.data, 600)} (新 hash=${Ny(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`) : xg("", c.error.issues);
|
|
17271
17500
|
}, {
|
|
17272
17501
|
name: "set_data",
|
|
17273
17502
|
description: "设置主数据的值(整体替换)。value 为 JSON 对象(或 JSON 字符串),需通过 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 read/get 返回的 hash,传入则启用乐观锁;不传时系统自动用你最后一次读到的 hash 比对(autoLock,默认开)。大对象/数组强烈建议改用 edit_data 增量 patch。",
|
|
@@ -17278,12 +17507,12 @@ function Xy(e, n = {}) {
|
|
|
17278
17507
|
}),
|
|
17279
17508
|
r(async ({ op: e, jsonPath: t, value: n, expectedHash: r }) => {
|
|
17280
17509
|
let o = t || "";
|
|
17281
|
-
if (
|
|
17510
|
+
if (Sy(o)) return $({
|
|
17282
17511
|
code: "PATH_UNSAFE",
|
|
17283
17512
|
message: `jsonPath "${o}" 含非法段(__proto__/constructor/prototype)`,
|
|
17284
17513
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
17285
17514
|
});
|
|
17286
|
-
if (!
|
|
17515
|
+
if (!_v(o, i, s)) return $({
|
|
17287
17516
|
code: "PATH_DENIED",
|
|
17288
17517
|
message: `edit_data @ "${o}" 不在 schema 声明字段内`,
|
|
17289
17518
|
hint: "仅 schema 声明的 key 可写;若需操作该字段,集成方需在 schema 中声明它"
|
|
@@ -17302,23 +17531,23 @@ function Xy(e, n = {}) {
|
|
|
17302
17531
|
message: `${e} 操作需要 value`,
|
|
17303
17532
|
hint: `op 为 ${e} 时 value 必填;删除请用 op:'remove'`
|
|
17304
17533
|
});
|
|
17305
|
-
let t =
|
|
17306
|
-
if (t.parseError) return
|
|
17534
|
+
let t = Oy(n);
|
|
17535
|
+
if (t.parseError) return Sg("", n, t.parseError);
|
|
17307
17536
|
l = t.parsed;
|
|
17308
17537
|
}
|
|
17309
|
-
let f =
|
|
17538
|
+
let f = Dy(a), g = Py(f, e, o, l);
|
|
17310
17539
|
if (g) return $({
|
|
17311
17540
|
code: "PATCH_FAILED",
|
|
17312
17541
|
message: g,
|
|
17313
17542
|
hint: "检查 op 与目标类型:merge 需对象,append 需数组;jsonPath 指向需存在"
|
|
17314
17543
|
});
|
|
17315
17544
|
let _ = i.safeParse(f);
|
|
17316
|
-
return _.success ? (m("edit"),
|
|
17545
|
+
return _.success ? (m("edit"), Fy(a, e, o, l), p({
|
|
17317
17546
|
op: "edit",
|
|
17318
17547
|
detail: `${e}${o ? "@" + o : ""}`,
|
|
17319
17548
|
value: l,
|
|
17320
17549
|
timestamp: Date.now()
|
|
17321
|
-
}), u =
|
|
17550
|
+
}), u = Ny(a), `已 edit 主数据(${e}${o ? " @ " + o : ""})。当前值:${jy(a, 600)} (新 hash=${Ny(a)})`) : xg("", _.error.issues);
|
|
17322
17551
|
}, {
|
|
17323
17552
|
name: "edit_data",
|
|
17324
17553
|
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,默认开)防\"基于过期值覆盖\"。",
|
|
@@ -17340,12 +17569,12 @@ function Xy(e, n = {}) {
|
|
|
17340
17569
|
message: "delete_data 需要 jsonPath 指定要删的子路径(主数据整体不可删,用 set_data 整体替换)",
|
|
17341
17570
|
hint: "如 jsonPath:\"components.0\" 删数组首项"
|
|
17342
17571
|
});
|
|
17343
|
-
if (
|
|
17572
|
+
if (Sy(e)) return $({
|
|
17344
17573
|
code: "PATH_UNSAFE",
|
|
17345
17574
|
message: `jsonPath "${e}" 含非法段`,
|
|
17346
17575
|
hint: "使用正常属性路径"
|
|
17347
17576
|
});
|
|
17348
|
-
if (!
|
|
17577
|
+
if (!_v(e, i, s)) return $({
|
|
17349
17578
|
code: "PATH_DENIED",
|
|
17350
17579
|
message: `delete_data @ "${e}" 不在 schema 声明字段内`,
|
|
17351
17580
|
hint: "仅 schema 声明的 key 可删"
|
|
@@ -17353,12 +17582,12 @@ function Xy(e, n = {}) {
|
|
|
17353
17582
|
let n = await h("delete", t || (d ? u : void 0));
|
|
17354
17583
|
if (n !== null) return n;
|
|
17355
17584
|
m("delete");
|
|
17356
|
-
let r =
|
|
17585
|
+
let r = Ey(a, e);
|
|
17357
17586
|
return p({
|
|
17358
17587
|
op: "delete",
|
|
17359
17588
|
detail: e,
|
|
17360
17589
|
timestamp: Date.now()
|
|
17361
|
-
}), u =
|
|
17590
|
+
}), u = Ny(a), r ? `已删除主数据 @ ${e}` : `主数据 @ ${e} 不存在(无需删除)`;
|
|
17362
17591
|
}, {
|
|
17363
17592
|
name: "delete_data",
|
|
17364
17593
|
description: "删除主数据的某个子路径(jsonPath)。主数据整体不可删(用 set_data 整体替换)。expectedHash(可选):改前 read/get 返回的 hash;不传时自动用你最后读到的 hash(autoLock,默认开)防\"基于过期值删除\"。",
|
|
@@ -17397,30 +17626,62 @@ function Xy(e, n = {}) {
|
|
|
17397
17626
|
hint: "用 list_data_snapshots 查看可用快照序号"
|
|
17398
17627
|
});
|
|
17399
17628
|
let n = i.safeParse(t.value);
|
|
17400
|
-
return n.success ? (
|
|
17629
|
+
return n.success ? (Iy(a, Dy(t.value)), p({
|
|
17401
17630
|
op: "restore",
|
|
17402
17631
|
detail: `#${t.id}`,
|
|
17403
17632
|
timestamp: Date.now()
|
|
17404
|
-
}), u =
|
|
17633
|
+
}), u = Ny(a), `已回退主数据到快照 #${t.id}[${t.op}]${t.label ? `(${t.label})` : ""}。`) : $({
|
|
17405
17634
|
code: "SNAPSHOT_SCHEMA_INVALID",
|
|
17406
17635
|
message: `快照 #${t.id} 的值不符合当前 schema,无法回退`,
|
|
17407
17636
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
17408
|
-
details:
|
|
17637
|
+
details: bg(n.error.issues)
|
|
17409
17638
|
});
|
|
17410
17639
|
}, {
|
|
17411
17640
|
name: "restore_data",
|
|
17412
17641
|
description: "把主数据回退到某个快照(就地还原,保留响应式)。不传 id 则回退最近一次(快速回退)。可用 list_data_snapshots 查看快照列表。",
|
|
17413
17642
|
schema: t.object({ id: t.number().int().optional().describe("指定快照序号;不传则回退最近一次") })
|
|
17414
17643
|
}),
|
|
17644
|
+
r(async ({ id: e, jsonPath: t }) => {
|
|
17645
|
+
if (!c.length) return $({
|
|
17646
|
+
code: "NO_SNAPSHOT",
|
|
17647
|
+
message: "无历史快照可查看",
|
|
17648
|
+
hint: "set/edit/delete 会自动存快照;也可先 snapshot_data 手动创建检查点"
|
|
17649
|
+
});
|
|
17650
|
+
let n = e === void 0 ? c[c.length - 1] : c.find((t) => t.id === e);
|
|
17651
|
+
if (!n) return $({
|
|
17652
|
+
code: "SNAPSHOT_NOT_FOUND",
|
|
17653
|
+
message: `未找到快照 #${e}`,
|
|
17654
|
+
hint: "不传 id 查看最近一次;或用 list_data_snapshots(advanced) 查看可用序号"
|
|
17655
|
+
});
|
|
17656
|
+
let r = Dy(n.value), a = t || "";
|
|
17657
|
+
if (a) {
|
|
17658
|
+
if (!_v(a, i, s)) return $({
|
|
17659
|
+
code: "PATH_DENIED",
|
|
17660
|
+
message: `history_data @ "${a}" 不在 schema 声明字段内`,
|
|
17661
|
+
hint: "仅 schema 声明的 key 可读"
|
|
17662
|
+
});
|
|
17663
|
+
r = wy(r, a);
|
|
17664
|
+
let e = yv(i, a);
|
|
17665
|
+
e && (r = bv(r, e));
|
|
17666
|
+
} else s && (r = bv(r, i));
|
|
17667
|
+
return `快照 #${n.id}[${n.op}]${n.label ? `(${n.label})` : ""}${a ? ` @ ${a}` : ""} = ${jy(r)}`;
|
|
17668
|
+
}, {
|
|
17669
|
+
name: "history_data",
|
|
17670
|
+
description: "只读查看某次快照(默认最近一次)的内容,不回退当前主数据。看上一版长啥样而不影响当前(冲突诊断/verify 自纠/用户问\"刚才改了啥\")。可选 id 指定快照序号、jsonPath 只看子路径(按 schema 投影)。",
|
|
17671
|
+
schema: t.object({
|
|
17672
|
+
id: t.number().int().optional().describe("快照序号;不传则最近一次"),
|
|
17673
|
+
jsonPath: t.string().optional().describe("只看快照的某子路径(相对主数据根);不传则整个快照")
|
|
17674
|
+
})
|
|
17675
|
+
}),
|
|
17415
17676
|
r(async ({ expr: e, limit: t }) => {
|
|
17416
17677
|
if (typeof a != "object" || !a) return $({
|
|
17417
17678
|
code: "NOT_OBJECT",
|
|
17418
17679
|
message: `主数据不是对象/数组,无法查询(当前为 ${a === void 0 ? "undefined" : typeof a})`,
|
|
17419
17680
|
hint: "query 仅适用于对象/数组;叶子用 get_data 读"
|
|
17420
17681
|
});
|
|
17421
|
-
let n = s ?
|
|
17682
|
+
let n = s ? xv(a, s) : a, r;
|
|
17422
17683
|
try {
|
|
17423
|
-
r =
|
|
17684
|
+
r = sb(n, e);
|
|
17424
17685
|
} catch (t) {
|
|
17425
17686
|
return $({
|
|
17426
17687
|
code: "JSONPATH_SYNTAX",
|
|
@@ -17429,7 +17690,7 @@ function Xy(e, n = {}) {
|
|
|
17429
17690
|
details: { expr: e }
|
|
17430
17691
|
});
|
|
17431
17692
|
}
|
|
17432
|
-
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":${
|
|
17693
|
+
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":${jy(e.value)}}`);
|
|
17433
17694
|
return `{"matched":${r.length},"returned":${o.length},"truncated":${r.length > i},"results":[${c.join(",")}]}`;
|
|
17434
17695
|
}, {
|
|
17435
17696
|
name: "query_data",
|
|
@@ -17445,13 +17706,13 @@ function Xy(e, n = {}) {
|
|
|
17445
17706
|
message: "主数据为空,无可搜索内容"
|
|
17446
17707
|
});
|
|
17447
17708
|
try {
|
|
17448
|
-
let o =
|
|
17709
|
+
let o = lb(s ? xv(a, s) : a, e, {
|
|
17449
17710
|
mode: t,
|
|
17450
17711
|
fuzzyThreshold: n,
|
|
17451
17712
|
matchKey: r,
|
|
17452
17713
|
limit: i ?? 50
|
|
17453
17714
|
});
|
|
17454
|
-
return
|
|
17715
|
+
return jy({
|
|
17455
17716
|
matched: o.length,
|
|
17456
17717
|
results: o
|
|
17457
17718
|
});
|
|
@@ -17478,158 +17739,216 @@ function Xy(e, n = {}) {
|
|
|
17478
17739
|
limit: t.number().int().min(1).max(200).optional().describe("返回上限,默认 50")
|
|
17479
17740
|
})
|
|
17480
17741
|
}),
|
|
17481
|
-
r(async ({ script: e, mode: t }) => {
|
|
17742
|
+
r(async ({ script: e, mode: t, jsonPath: n }) => {
|
|
17482
17743
|
if (e.length > 8e3) return $({
|
|
17483
17744
|
code: "SCRIPT_TOO_LARGE",
|
|
17484
17745
|
message: `脚本过长(${e.length} 字符,上限 8000)`,
|
|
17485
17746
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
17486
17747
|
});
|
|
17487
|
-
let
|
|
17488
|
-
if (
|
|
17489
|
-
|
|
17748
|
+
let r = n || "", o;
|
|
17749
|
+
if (r) {
|
|
17750
|
+
if (!_v(r, i, s)) return $({
|
|
17751
|
+
code: "PATH_DENIED",
|
|
17752
|
+
message: `eval_script @ "${r}" 不在 schema 声明字段内`,
|
|
17753
|
+
hint: "仅 schema 声明的 key 可作为子树"
|
|
17754
|
+
});
|
|
17755
|
+
if (o = wy(a, r), s) {
|
|
17756
|
+
let e = yv(i, r);
|
|
17757
|
+
e && (o = bv(o, e));
|
|
17758
|
+
}
|
|
17759
|
+
} else o = s ? xv(a, s) : a;
|
|
17760
|
+
let c = Dy(o), l = await fb(c, e, r && JSON.stringify(c).length > 1e5 ? 8e3 : 3e3);
|
|
17761
|
+
if (!l.ok) {
|
|
17762
|
+
let t = /超时/.test(l.error || "");
|
|
17490
17763
|
return $({
|
|
17491
17764
|
code: t ? "SCRIPT_TIMEOUT" : "SCRIPT_ERROR",
|
|
17492
|
-
message: `脚本执行失败: ${
|
|
17765
|
+
message: `脚本执行失败: ${l.error}`,
|
|
17493
17766
|
hint: t ? "脚本可能有死循环或过重计算;加边界检查/分批;transform 返回完整新值勿返回巨大中间结果" : "检查脚本语法与运行时错误;入参为 data(主数据深拷贝),沙箱内禁用 fetch/XHR/WebSocket",
|
|
17494
17767
|
details: {
|
|
17495
|
-
elapsedMs:
|
|
17768
|
+
elapsedMs: l.elapsedMs,
|
|
17496
17769
|
scriptLen: e.length
|
|
17497
17770
|
}
|
|
17498
17771
|
});
|
|
17499
17772
|
}
|
|
17500
17773
|
if (t === "transform") {
|
|
17501
|
-
let e =
|
|
17774
|
+
let e = l.result;
|
|
17775
|
+
if (r) {
|
|
17776
|
+
let t = Dy(a), n = Py(t, "set", r, e);
|
|
17777
|
+
if (n) return $({
|
|
17778
|
+
code: "PATCH_FAILED",
|
|
17779
|
+
message: `eval 子树 transform @ "${r}" 失败: ${n}`,
|
|
17780
|
+
hint: "检查子路径:set 需父为对象/数组"
|
|
17781
|
+
});
|
|
17782
|
+
let o = i.safeParse(t);
|
|
17783
|
+
return o.success ? (m("edit", "eval_transform_subtree"), Fy(a, "set", r, e), p({
|
|
17784
|
+
op: "edit",
|
|
17785
|
+
detail: `eval_transform_subtree @ ${r}`,
|
|
17786
|
+
timestamp: Date.now()
|
|
17787
|
+
}), u = Ny(a), `已通过脚本 transform 子树 @ ${r} 更新(耗时 ${l.elapsedMs}ms)。当前值: ${jy(a, 600)}`) : $({
|
|
17788
|
+
code: "SCHEMA_INVALID",
|
|
17789
|
+
message: `脚本返回值作为子树 @ "${r}" 后整体校验失败,未写入`,
|
|
17790
|
+
hint: `确认返回值符合 ${r} 处的子 schema`,
|
|
17791
|
+
details: bg(o.error.issues)
|
|
17792
|
+
});
|
|
17793
|
+
}
|
|
17502
17794
|
if (e && typeof e == "object" && !Array.isArray(e) && "patches" in e && Array.isArray(e.patches)) {
|
|
17503
17795
|
if (typeof a != "object" || !a) return $({
|
|
17504
17796
|
code: "LEAF_BIND",
|
|
17505
17797
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform(patches) 无法就地替换`,
|
|
17506
17798
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
17507
17799
|
});
|
|
17508
|
-
let t = e.patches,
|
|
17800
|
+
let t = e.patches, n = Dy(a), r = [];
|
|
17509
17801
|
for (let e = 0; e < t.length; e++) {
|
|
17510
|
-
let
|
|
17511
|
-
if (
|
|
17802
|
+
let a = t[e], o = a.jsonPath || "";
|
|
17803
|
+
if (Sy(o)) return $({
|
|
17512
17804
|
code: "PATH_UNSAFE",
|
|
17513
|
-
message: `patches[${e}] jsonPath "${
|
|
17805
|
+
message: `patches[${e}] jsonPath "${o}" 含非法段`,
|
|
17514
17806
|
hint: "使用正常属性路径"
|
|
17515
17807
|
});
|
|
17516
|
-
if (!
|
|
17808
|
+
if (!_v(o, i, s)) return $({
|
|
17517
17809
|
code: "PATH_DENIED",
|
|
17518
|
-
message: `patches[${e}] @ "${
|
|
17810
|
+
message: `patches[${e}] @ "${o}" 不在 schema 声明字段内`,
|
|
17519
17811
|
hint: "仅 schema 声明的 key 可写"
|
|
17520
17812
|
});
|
|
17521
|
-
let c =
|
|
17813
|
+
let c = a.op, l;
|
|
17522
17814
|
if (c !== "remove") {
|
|
17523
|
-
if (
|
|
17815
|
+
if (a.value === void 0 || a.value === "") return $({
|
|
17524
17816
|
code: "MISSING_VALUE",
|
|
17525
17817
|
message: `patches[${e}] ${c} 操作需要 value`,
|
|
17526
17818
|
hint: `op 为 ${c} 时 value 必填`
|
|
17527
17819
|
});
|
|
17528
|
-
let t =
|
|
17529
|
-
if (t.parseError) return
|
|
17820
|
+
let t = Oy(a.value);
|
|
17821
|
+
if (t.parseError) return Sg(`patches[${e}]`, a.value, t.parseError);
|
|
17530
17822
|
l = t.parsed;
|
|
17531
17823
|
}
|
|
17532
|
-
let u =
|
|
17824
|
+
let u = Py(n, c, o, l);
|
|
17533
17825
|
if (u) return $({
|
|
17534
17826
|
code: "PATCH_FAILED",
|
|
17535
17827
|
message: `patches[${e}]: ${u}`,
|
|
17536
17828
|
hint: "检查 op 与目标类型:merge 需对象,append 需数组"
|
|
17537
17829
|
});
|
|
17538
|
-
|
|
17830
|
+
r.push({
|
|
17539
17831
|
op: c,
|
|
17540
|
-
jp:
|
|
17832
|
+
jp: o,
|
|
17541
17833
|
value: l
|
|
17542
17834
|
});
|
|
17543
17835
|
}
|
|
17544
|
-
let
|
|
17545
|
-
if (!
|
|
17836
|
+
let o = i.safeParse(n);
|
|
17837
|
+
if (!o.success) return $({
|
|
17546
17838
|
code: "SCHEMA_INVALID",
|
|
17547
17839
|
message: "脚本 patches 应用后整体校验失败,未写入",
|
|
17548
17840
|
hint: "确认 patches 合并后整体仍符合 schema",
|
|
17549
|
-
details:
|
|
17841
|
+
details: bg(o.error.issues)
|
|
17550
17842
|
});
|
|
17551
17843
|
m("edit", "eval_transform");
|
|
17552
|
-
for (let e of
|
|
17844
|
+
for (let e of r) Fy(a, e.op, e.jp, e.value);
|
|
17553
17845
|
return p({
|
|
17554
17846
|
op: "edit",
|
|
17555
|
-
detail: `eval_transform(${
|
|
17847
|
+
detail: `eval_transform(${r.length} patches)`,
|
|
17556
17848
|
timestamp: Date.now()
|
|
17557
|
-
}), u =
|
|
17849
|
+
}), u = Ny(a), `已通过脚本 transform(patches) 更新主数据(${r.length} 个 patch,耗时 ${l.elapsedMs}ms)。当前值: ${jy(a, 600)}`;
|
|
17558
17850
|
}
|
|
17559
17851
|
let t = i.safeParse(e);
|
|
17560
17852
|
return t.success ? typeof a != "object" || !a ? $({
|
|
17561
17853
|
code: "LEAF_BIND",
|
|
17562
17854
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform 无法就地替换外部持有的值引用`,
|
|
17563
17855
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
17564
|
-
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ?
|
|
17856
|
+
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ? Cy(a, t.data) : Ly(a, t.data)), p({
|
|
17565
17857
|
op: "edit",
|
|
17566
17858
|
detail: "eval_transform",
|
|
17567
17859
|
timestamp: Date.now()
|
|
17568
|
-
}), u =
|
|
17860
|
+
}), u = Ny(a), `已通过脚本 transform 更新主数据(耗时 ${l.elapsedMs}ms)。当前值: ${jy(a, 600)}`) : $({
|
|
17569
17861
|
code: "SCHEMA_INVALID",
|
|
17570
17862
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回主数据的完整新值且符合 schema)",
|
|
17571
17863
|
hint: "确认脚本 return 了完整新值(非部分);或返回 {patches:[...]} 走增量模式;按 describe_data() 查看格式",
|
|
17572
|
-
details:
|
|
17864
|
+
details: bg(t.error.issues)
|
|
17573
17865
|
});
|
|
17574
17866
|
}
|
|
17575
|
-
return
|
|
17867
|
+
return jy({
|
|
17576
17868
|
ok: !0,
|
|
17577
|
-
result:
|
|
17578
|
-
elapsedMs:
|
|
17869
|
+
result: l.result,
|
|
17870
|
+
elapsedMs: l.elapsedMs
|
|
17579
17871
|
});
|
|
17580
17872
|
}, {
|
|
17581
17873
|
name: "eval_script",
|
|
17582
|
-
description: "在隔离的 Web Worker 沙箱里对主数据跑自定义 JS 脚本(无 window/document 访问,fetch/XHR/WebSocket/importScripts 已禁用,超时 3s 可终止)。脚本以 `data` 为入参(主数据的深拷贝),返回值即结果。mode:query(默认,只读,把返回值回给 LLM,适合过滤/映射/聚合/统计大数组)、transform(把返回值作为主数据的新整体值,经 schema 校验后就地落地,适合批量重写)。transform 支持两种返回形式:① 完整新值(整体替换);② {patches:[{op,jsonPath,value},...]} 增量 patch(按 patch 应用,避免大对象整体重传,任一 patch 失败或整体 schema 校验失败则不写入)。query 不改主数据。脚本内可用标准 JS(Array/Object/JSON/Math 等)与 async/await。",
|
|
17874
|
+
description: "在隔离的 Web Worker 沙箱里对主数据跑自定义 JS 脚本(无 window/document 访问,fetch/XHR/WebSocket/importScripts 已禁用,超时 3s 可终止)。脚本以 `data` 为入参(主数据的深拷贝),返回值即结果。mode:query(默认,只读,把返回值回给 LLM,适合过滤/映射/聚合/统计大数组)、transform(把返回值作为主数据的新整体值,经 schema 校验后就地落地,适合批量重写)。transform 支持两种返回形式:① 完整新值(整体替换);② {patches:[{op,jsonPath,value},...]} 增量 patch(按 patch 应用,避免大对象整体重传,任一 patch 失败或整体 schema 校验失败则不写入)。query 不改主数据。脚本内可用标准 JS(Array/Object/JSON/Math 等)与 async/await。jsonPath(可选,子树模式):仅对 jsonPath 指向的子树执行(降低大 JSON 深拷贝/执行成本),transform 时返回值作为该子树的新值。",
|
|
17583
17875
|
schema: t.object({
|
|
17584
17876
|
script: t.string().describe("JS 脚本体,如 data.filter(c=>c.stock>0).map(c=>c.id);入参名 data;末尾表达式或 return 即返回值"),
|
|
17585
|
-
mode: t.enum(["query", "transform"]).optional().describe("query=只读返回结果(默认),transform=校验后落地为新值")
|
|
17877
|
+
mode: t.enum(["query", "transform"]).optional().describe("query=只读返回结果(默认),transform=校验后落地为新值"),
|
|
17878
|
+
jsonPath: t.string().optional().describe("子树模式:仅对 jsonPath 指向的子树执行(降低大 JSON 成本);transform 时返回值作为该子树新值")
|
|
17586
17879
|
})
|
|
17587
17880
|
}),
|
|
17588
|
-
r(async ({ jsonPath: e,
|
|
17589
|
-
let
|
|
17590
|
-
if (
|
|
17881
|
+
r(async ({ jsonPath: e, jsonPaths: t, fields: r, depth: c, offset: l, limit: d }) => {
|
|
17882
|
+
let f = Ny(a);
|
|
17883
|
+
if (u = f, t && t.length) {
|
|
17884
|
+
let e = t.map((e) => {
|
|
17885
|
+
let t = e || "";
|
|
17886
|
+
if (!_v(t, i, s)) return `- ${t || "(根)"}: [PATH_DENIED: 不在 schema 声明字段内]`;
|
|
17887
|
+
let o = t ? wy(a, t) : a;
|
|
17888
|
+
if (!t) o = xv(o, s);
|
|
17889
|
+
else if (s) {
|
|
17890
|
+
let e = yv(i, t);
|
|
17891
|
+
e && (o = bv(o, e));
|
|
17892
|
+
}
|
|
17893
|
+
let l = o;
|
|
17894
|
+
if (n.interceptors?.read) try {
|
|
17895
|
+
l = n.interceptors.read(l);
|
|
17896
|
+
} catch (e) {
|
|
17897
|
+
return `- ${t}: [READ_INTERCEPT: ${e.message}]`;
|
|
17898
|
+
}
|
|
17899
|
+
return r && r.length && (l = ky(l, r)), c != null && (l = Ay(l, c)), l === void 0 ? `- ${t} = (undefined)` : `- ${t} = ${jy(l)}`;
|
|
17900
|
+
});
|
|
17901
|
+
return `多路径读取(共 ${t.length} 项,hash=${f}):\n${e.join("\n")}`;
|
|
17902
|
+
}
|
|
17903
|
+
let p = e || "";
|
|
17904
|
+
if (!_v(p, i, s)) return $({
|
|
17591
17905
|
code: "PATH_DENIED",
|
|
17592
|
-
message: `read @ "${
|
|
17906
|
+
message: `read @ "${p}" 不在 schema 声明字段内`,
|
|
17593
17907
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
17594
17908
|
});
|
|
17595
|
-
let
|
|
17596
|
-
if (!
|
|
17909
|
+
let m = p ? wy(a, p) : a;
|
|
17910
|
+
if (!p) m = xv(m, s);
|
|
17597
17911
|
else if (s) {
|
|
17598
|
-
let e =
|
|
17599
|
-
e && (
|
|
17912
|
+
let e = yv(i, p);
|
|
17913
|
+
e && (m = bv(m, e));
|
|
17600
17914
|
}
|
|
17601
|
-
let
|
|
17915
|
+
let h = m;
|
|
17602
17916
|
if (n.interceptors?.read) try {
|
|
17603
|
-
|
|
17917
|
+
h = n.interceptors.read(h);
|
|
17604
17918
|
} catch (e) {
|
|
17605
17919
|
return $({
|
|
17606
17920
|
code: "READ_INTERCEPT",
|
|
17607
17921
|
message: `read 拦截器抛错: ${e.message}`
|
|
17608
17922
|
});
|
|
17609
17923
|
}
|
|
17610
|
-
|
|
17611
|
-
let
|
|
17612
|
-
|
|
17613
|
-
|
|
17614
|
-
|
|
17924
|
+
r && r.length && (h = ky(h, r)), c != null && (h = Ay(h, c));
|
|
17925
|
+
let g = e ? "" : `主数据说明: ${o}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, _ = r && r.length ? `(字段裁剪:${r.join(",")})` : "", v = c == null ? "" : `(深度≤${c})`, y = _ || v ? ` ${_}${v}` : "";
|
|
17926
|
+
if ((l !== void 0 || d !== void 0) && Array.isArray(h)) {
|
|
17927
|
+
let e = h.length, t = Math.max(0, l ?? 0), n = Math.min(200, Math.max(1, d ?? 50)), r = h.slice(t, t + n), i = t + n < e;
|
|
17928
|
+
return `${g}主数据${p ? ` @ ${p}` : ""} 数组分页[offset=${t},limit=${n}]${y} = ${jy(r)} (total=${e}, hasMore=${i}) (hash=${f})`;
|
|
17929
|
+
}
|
|
17930
|
+
return h === void 0 ? `${g}主数据${p ? ` @ ${p}` : ""}${y} = (undefined) (hash=${f})` : `${g}主数据${p ? ` @ ${p}` : ""}${y} = ${jy(h)} (hash=${f})`;
|
|
17615
17931
|
}, {
|
|
17616
17932
|
name: "read",
|
|
17617
|
-
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 +
|
|
17933
|
+
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(默认 autoLock,write 时自动比对,无需手动传)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。集成方可能经 read 拦截器对返回值脱敏/派生。",
|
|
17618
17934
|
schema: t.object({
|
|
17619
17935
|
jsonPath: t.string().optional().describe("要读的子路径(相对主数据根,如 components.0.text);不传则读整个主数据并返回说明"),
|
|
17936
|
+
jsonPaths: t.array(t.string()).optional().describe("多路径读取:一次读多个不相关子路径(与 jsonPath 互斥,优先于 jsonPath);返回各路径值,非法路径单项标错不整批失败"),
|
|
17620
17937
|
fields: t.array(t.string()).optional().describe("字段裁剪:只返回指定字段(对对象/数组元素投影),减少返回体积,如 [\"id\",\"title\"]"),
|
|
17621
|
-
depth: t.number().int().min(0).optional().describe("嵌套深度限制:0=只根占位,1=根+子,递归到 depth 层后用 {...}/[...] 占位截断,减少深层返回体积")
|
|
17938
|
+
depth: t.number().int().min(0).optional().describe("嵌套深度限制:0=只根占位,1=根+子,递归到 depth 层后用 {...}/[...] 占位截断,减少深层返回体积"),
|
|
17939
|
+
offset: t.number().int().min(0).optional().describe("数组分页起始偏移(仅当读取目标是数组时生效,默认 0),配合 limit 分页读大数组"),
|
|
17940
|
+
limit: t.number().int().min(1).max(200).optional().describe("数组分页每页条数(默认 50,上限 200;仅数组时生效),返回切片 + total/hasMore")
|
|
17622
17941
|
})
|
|
17623
17942
|
}),
|
|
17624
|
-
r(async ({ value: e, patch: t, patches: r, del: o }) => {
|
|
17625
|
-
let
|
|
17626
|
-
o ?
|
|
17627
|
-
let
|
|
17943
|
+
r(async ({ value: e, patch: t, patches: r, del: o, dryRun: c }) => {
|
|
17944
|
+
let l = "set";
|
|
17945
|
+
o ? l = "delete" : (r && r.length || t) && (l = "edit");
|
|
17946
|
+
let f = e, g;
|
|
17628
17947
|
if (n.interceptors?.write) try {
|
|
17629
|
-
let i =
|
|
17948
|
+
let i = l === "delete" ? {
|
|
17630
17949
|
del: !0,
|
|
17631
17950
|
jsonPath: t?.jsonPath
|
|
17632
|
-
} :
|
|
17951
|
+
} : l === "edit" && r && r.length ? { patches: r } : l === "edit" ? {
|
|
17633
17952
|
op: t.op,
|
|
17634
17953
|
jsonPath: t.jsonPath || "",
|
|
17635
17954
|
value: e
|
|
@@ -17638,122 +17957,135 @@ function Xy(e, n = {}) {
|
|
|
17638
17957
|
code: "WRITE_INTERCEPT",
|
|
17639
17958
|
message: `write 拦截器拒绝: ${o.error}`
|
|
17640
17959
|
});
|
|
17641
|
-
if (
|
|
17642
|
-
else if (
|
|
17960
|
+
if (l !== "delete") if (l === "edit" && r && r.length) g = o && Array.isArray(o) ? o : r;
|
|
17961
|
+
else if (l === "edit") if (o && typeof o == "object" && "op" in o && "jsonPath" in o) {
|
|
17643
17962
|
let e = o;
|
|
17644
|
-
e.op && (t.op = e.op), e.jsonPath !== void 0 && (t.jsonPath = e.jsonPath),
|
|
17645
|
-
} else
|
|
17646
|
-
else
|
|
17963
|
+
e.op && (t.op = e.op), e.jsonPath !== void 0 && (t.jsonPath = e.jsonPath), f = e.value;
|
|
17964
|
+
} else f = o;
|
|
17965
|
+
else f = o;
|
|
17647
17966
|
} catch (e) {
|
|
17648
17967
|
return $({
|
|
17649
17968
|
code: "WRITE_INTERCEPT",
|
|
17650
17969
|
message: `write 拦截器抛错: ${e.message}`
|
|
17651
17970
|
});
|
|
17652
17971
|
}
|
|
17653
|
-
let
|
|
17654
|
-
if (c
|
|
17972
|
+
let _ = d ? u : void 0;
|
|
17973
|
+
if (c && _ !== void 0) {
|
|
17974
|
+
let e = Ny(a);
|
|
17975
|
+
if (e !== _) return $({
|
|
17976
|
+
code: "VERSION_CONFLICT",
|
|
17977
|
+
message: `dryRun 预检发现乐观锁冲突: expectedHash=${_} 当前 hash=${e}(主数据在你 read 后被改)`,
|
|
17978
|
+
hint: "重新 read 拿最新 hash 再预检/写"
|
|
17979
|
+
});
|
|
17980
|
+
}
|
|
17981
|
+
if (l === "delete") {
|
|
17655
17982
|
if (!t?.jsonPath) return $({
|
|
17656
17983
|
code: "MISSING_VALUE",
|
|
17657
17984
|
message: "delete 需要 patch.jsonPath 指定要删的子路径(主数据整体不可删,用 write(value) 整体替换)",
|
|
17658
17985
|
hint: "如 patch:{jsonPath:\"components.0\"}, del:true"
|
|
17659
17986
|
});
|
|
17660
|
-
if (
|
|
17987
|
+
if (Sy(t.jsonPath)) return $({
|
|
17661
17988
|
code: "PATH_UNSAFE",
|
|
17662
17989
|
message: `jsonPath "${t.jsonPath}" 含非法段`,
|
|
17663
17990
|
hint: "使用正常属性路径"
|
|
17664
17991
|
});
|
|
17665
|
-
if (!
|
|
17992
|
+
if (!_v(t.jsonPath, i, s)) return $({
|
|
17666
17993
|
code: "PATH_DENIED",
|
|
17667
17994
|
message: `write delete @ "${t.jsonPath}" 不在 schema 声明字段内`,
|
|
17668
17995
|
hint: "仅 schema 声明的 key 可删"
|
|
17669
17996
|
});
|
|
17670
|
-
let e = await h("delete",
|
|
17997
|
+
let e = await h("delete", _);
|
|
17671
17998
|
if (e !== null) return e;
|
|
17999
|
+
if (c) {
|
|
18000
|
+
let e = Dy(a);
|
|
18001
|
+
return Ey(e, t.jsonPath) ? `dryRun(delete): 将删除 @ ${t.jsonPath}。预览剩余:${jy(e, 600)}。未实际写入、未入快照。` : `dryRun(delete): @ ${t.jsonPath} 不存在(无需删除)。未实际写入。`;
|
|
18002
|
+
}
|
|
17672
18003
|
m("delete");
|
|
17673
|
-
let n =
|
|
18004
|
+
let n = Ey(a, t.jsonPath);
|
|
17674
18005
|
return p({
|
|
17675
18006
|
op: "delete",
|
|
17676
18007
|
detail: t.jsonPath,
|
|
17677
18008
|
timestamp: Date.now()
|
|
17678
|
-
}), u =
|
|
18009
|
+
}), u = Ny(a), n ? `已删除主数据 @ ${t.jsonPath}` : `主数据 @ ${t.jsonPath} 不存在(无需删除)`;
|
|
17679
18010
|
}
|
|
17680
|
-
if (
|
|
18011
|
+
if (l === "edit") {
|
|
17681
18012
|
if (typeof a != "object" || !a) return $({
|
|
17682
18013
|
code: "NOT_OBJECT",
|
|
17683
18014
|
message: `edit 仅适用于对象/数组主数据,当前是 ${a === void 0 ? "undefined" : typeof a}`,
|
|
17684
18015
|
hint: "叶子用 write(value) 整体设置"
|
|
17685
18016
|
});
|
|
17686
|
-
let e = await h("edit",
|
|
18017
|
+
let e = await h("edit", _);
|
|
17687
18018
|
if (e !== null) return e;
|
|
17688
|
-
let n =
|
|
18019
|
+
let n = g || (r && r.length ? r : [{
|
|
17689
18020
|
op: t.op,
|
|
17690
18021
|
jsonPath: t.jsonPath || "",
|
|
17691
|
-
value:
|
|
17692
|
-
}]), o =
|
|
18022
|
+
value: f
|
|
18023
|
+
}]), o = Dy(a), l = [];
|
|
17693
18024
|
for (let e = 0; e < n.length; e++) {
|
|
17694
18025
|
let t = n[e], r = t.jsonPath || "";
|
|
17695
|
-
if (
|
|
18026
|
+
if (Sy(r)) return $({
|
|
17696
18027
|
code: "PATH_UNSAFE",
|
|
17697
18028
|
message: `patches[${e}] jsonPath "${r}" 含非法段`,
|
|
17698
18029
|
hint: "使用正常属性路径,如 components.0.text"
|
|
17699
18030
|
});
|
|
17700
|
-
if (!
|
|
18031
|
+
if (!_v(r, i, s)) return $({
|
|
17701
18032
|
code: "PATH_DENIED",
|
|
17702
18033
|
message: `patches[${e}] @ "${r}" 不在 schema 声明字段内`,
|
|
17703
18034
|
hint: "仅 schema 声明的 key 可写"
|
|
17704
18035
|
});
|
|
17705
|
-
let a = t.op,
|
|
18036
|
+
let a = t.op, c;
|
|
17706
18037
|
if (a !== "remove") {
|
|
17707
18038
|
if (t.value === void 0 || t.value === "") return $({
|
|
17708
18039
|
code: "MISSING_VALUE",
|
|
17709
18040
|
message: `patches[${e}] ${a} 操作需要 value`,
|
|
17710
18041
|
hint: `op 为 ${a} 时 value 必填;删除请用 op:'remove'`
|
|
17711
18042
|
});
|
|
17712
|
-
let n =
|
|
17713
|
-
if (n.parseError) return
|
|
17714
|
-
|
|
18043
|
+
let n = Oy(t.value);
|
|
18044
|
+
if (n.parseError) return Sg(`patches[${e}]`, t.value, n.parseError);
|
|
18045
|
+
c = n.parsed;
|
|
17715
18046
|
}
|
|
17716
|
-
let u =
|
|
18047
|
+
let u = Py(o, a, r, c);
|
|
17717
18048
|
if (u) return $({
|
|
17718
18049
|
code: "PATCH_FAILED",
|
|
17719
18050
|
message: `patches[${e}]: ${u}`,
|
|
17720
18051
|
hint: "检查 op 与目标类型:merge 需对象,append 需数组"
|
|
17721
18052
|
});
|
|
17722
|
-
|
|
18053
|
+
l.push({
|
|
17723
18054
|
op: a,
|
|
17724
18055
|
jp: r,
|
|
17725
|
-
value:
|
|
18056
|
+
value: c
|
|
17726
18057
|
});
|
|
17727
18058
|
}
|
|
17728
18059
|
let d = i.safeParse(o);
|
|
17729
|
-
if (!d.success) return
|
|
18060
|
+
if (!d.success) return xg("", d.error.issues);
|
|
18061
|
+
if (c) return `dryRun(edit): ${l.length} 个 patch 预检通过(schema 校验 OK)。预览结果:${jy(o, 600)}。未实际写入、未入快照。`;
|
|
17730
18062
|
m("edit");
|
|
17731
|
-
for (let e of
|
|
18063
|
+
for (let e of l) Fy(a, e.op, e.jp, e.value);
|
|
17732
18064
|
return p({
|
|
17733
18065
|
op: "edit",
|
|
17734
|
-
detail: `${
|
|
17735
|
-
value:
|
|
18066
|
+
detail: `${l.length} 个 patch${l.length > 1 ? "(批量)" : ""}`,
|
|
18067
|
+
value: l.map((e) => `${e.op}@${e.jp}`),
|
|
17736
18068
|
timestamp: Date.now()
|
|
17737
|
-
}), u =
|
|
17738
|
-
}
|
|
17739
|
-
let
|
|
17740
|
-
if (
|
|
17741
|
-
|
|
17742
|
-
let
|
|
17743
|
-
if (
|
|
17744
|
-
let
|
|
17745
|
-
return
|
|
18069
|
+
}), u = Ny(a), `已 write(edit) 主数据(${l.length} 个 patch)。当前值:${jy(a, 600)} (新 hash=${Ny(a)})`;
|
|
18070
|
+
}
|
|
18071
|
+
let v, y = Oy(f);
|
|
18072
|
+
if (y.parseError) return Sg("", f, y.parseError);
|
|
18073
|
+
v = y.parsed;
|
|
18074
|
+
let b = await h("set", _);
|
|
18075
|
+
if (b !== null) return b;
|
|
18076
|
+
let x = i.safeParse(v);
|
|
18077
|
+
return x.success ? c ? `dryRun(set): schema 校验通过。预览新值:${jy(x.data, 600)}。未实际写入、未入快照。` : typeof a != "object" || !a ? $({
|
|
17746
18078
|
code: "LEAF_BIND",
|
|
17747
18079
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),write(set) 无法就地替换外部持有的值引用`,
|
|
17748
18080
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
17749
|
-
}) : (m("set"),
|
|
18081
|
+
}) : (m("set"), x.data !== null && typeof x.data == "object" && (s ? Cy(a, x.data) : Ly(a, x.data)), p({
|
|
17750
18082
|
op: "set",
|
|
17751
|
-
value:
|
|
18083
|
+
value: x.data,
|
|
17752
18084
|
timestamp: Date.now()
|
|
17753
|
-
}), u =
|
|
18085
|
+
}), u = Ny(a), `已 write(set) 主数据 = ${jy(x.data, 600)} (新 hash=${Ny(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`) : xg("", x.error.issues);
|
|
17754
18086
|
}, {
|
|
17755
18087
|
name: "write",
|
|
17756
|
-
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})。",
|
|
18088
|
+
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})。dryRun(可选):预检模式,走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘/入快照,返回预览(四意图均支持,复杂改动先看会改成啥、能否过 schema)。",
|
|
17757
18089
|
schema: t.object({
|
|
17758
18090
|
value: t.unknown().optional().describe("JSON 对象(推荐,如 {title:\"x\"})或 JSON 字符串;set 整体或单个 patch 的 set/merge/append 必填"),
|
|
17759
18091
|
patch: t.object({
|
|
@@ -17775,7 +18107,47 @@ function Xy(e, n = {}) {
|
|
|
17775
18107
|
jsonPath: t.string().optional().describe("相对主数据根的点号路径;set/remove 必填,merge/append 不填则作用于根"),
|
|
17776
18108
|
value: t.unknown().optional().describe("JSON 值(推荐直传)或 JSON 字符串;set/merge/append 必填,remove 不需")
|
|
17777
18109
|
})).optional().describe("批量增量编辑:一次原子应用多个 patch(任一失败则整体不写入,clone 试跑全部 + schema 校验通过才落 live)。适合一次改多处,减少多轮往返"),
|
|
17778
|
-
del: t.boolean().optional().describe("true 则删除 patch.jsonPath 指定的子路径(等价 delete_data)")
|
|
18110
|
+
del: t.boolean().optional().describe("true 则删除 patch.jsonPath 指定的子路径(等价 delete_data)"),
|
|
18111
|
+
dryRun: t.boolean().optional().describe("预检模式:走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘、不入快照,返回预览。四意图(value/patch/patches/del)均支持;乐观锁冲突照常检测(返回 VERSION_CONFLICT 不挂起)")
|
|
18112
|
+
})
|
|
18113
|
+
}),
|
|
18114
|
+
r(async ({ jsonPath: e }) => {
|
|
18115
|
+
let t = e || "", n = t ? yv(i, t) : i;
|
|
18116
|
+
return n ? `schema${t ? ` @ ${t}` : ""} = ${jy(Dv(n))}` : $({
|
|
18117
|
+
code: "PATH_DENIED",
|
|
18118
|
+
message: `schema @ "${t}" 不存在`,
|
|
18119
|
+
hint: "jsonPath 需在 schema 声明字段内(用 read() 不传 jsonPath 查看顶层字段)"
|
|
18120
|
+
});
|
|
18121
|
+
}, {
|
|
18122
|
+
name: "schema_data",
|
|
18123
|
+
description: "查看主数据(或子路径)的字段约束:类型/min/max/enum/必填/默认值/嵌套 shape。写前查约束,避免写错重试。不传 jsonPath 查根;传子路径(如 components.0)查该位置约束。",
|
|
18124
|
+
schema: t.object({ jsonPath: t.string().optional().describe("要查约束的子路径;不传查根 schema") })
|
|
18125
|
+
}),
|
|
18126
|
+
r(async ({ snapshotId: e, against: t }) => {
|
|
18127
|
+
let n = t != null, r, i;
|
|
18128
|
+
if (n) r = t, i = "against";
|
|
18129
|
+
else {
|
|
18130
|
+
if (!c.length) return $({
|
|
18131
|
+
code: "NO_SNAPSHOT",
|
|
18132
|
+
message: "无快照可对比",
|
|
18133
|
+
hint: "set/edit/delete 自动存快照;或传 against 一段 JSON 值直接对比"
|
|
18134
|
+
});
|
|
18135
|
+
let t = e === void 0 ? c[c.length - 1] : c.find((t) => t.id === e);
|
|
18136
|
+
if (!t) return $({
|
|
18137
|
+
code: "SNAPSHOT_NOT_FOUND",
|
|
18138
|
+
message: `未找到快照 #${e}`,
|
|
18139
|
+
hint: "不传 snapshotId 用最近一次;或传 against"
|
|
18140
|
+
});
|
|
18141
|
+
r = t.value, i = `快照 #${t.id}`;
|
|
18142
|
+
}
|
|
18143
|
+
let o = s ? xv(a, s) : a, l = Ry(r, Dy(o));
|
|
18144
|
+
return l.length ? `差异(当前 vs ${i},共 ${l.length} 处):\n${l.map((e) => ` ${e.path}: ${jy(e.from)} → ${jy(e.to)}`).join("\n")}` : `无差异:当前主数据与 ${i} 完全相同。`;
|
|
18145
|
+
}, {
|
|
18146
|
+
name: "diff_data",
|
|
18147
|
+
description: "对比当前主数据与某快照(默认最近)或一段 JSON(against)的差异,返回结构化 {path, from→to} 列表。供 verify 自纠/冲突诊断/操作审计(\"刚才改了啥\")。snapshotId 指定快照;against 传一段 JSON 值(与 snapshotId 互斥,传则忽略快照)。",
|
|
18148
|
+
schema: t.object({
|
|
18149
|
+
snapshotId: t.number().int().optional().describe("对比的快照序号;不传则最近一次"),
|
|
18150
|
+
against: t.unknown().optional().describe("对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)")
|
|
17779
18151
|
})
|
|
17780
18152
|
})
|
|
17781
18153
|
];
|
|
@@ -17788,8 +18160,8 @@ function Xy(e, n = {}) {
|
|
|
17788
18160
|
}
|
|
17789
18161
|
//#endregion
|
|
17790
18162
|
//#region src/core/tools/fetchDoc.ts
|
|
17791
|
-
var
|
|
17792
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
18163
|
+
var _b = 3e4, vb = [r(async ({ url: e, as: t }) => {
|
|
18164
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), _b);
|
|
17793
18165
|
try {
|
|
17794
18166
|
let r = await fetch(e, {
|
|
17795
18167
|
method: "GET",
|
|
@@ -17806,7 +18178,7 @@ var Zy = 3e4, Qy = [r(async ({ url: e, as: t }) => {
|
|
|
17806
18178
|
].join("\n");
|
|
17807
18179
|
} catch (t) {
|
|
17808
18180
|
let r = t?.message || String(t);
|
|
17809
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
18181
|
+
return n.signal.aborted ? `获取失败:请求超时(${_b}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
17810
18182
|
} finally {
|
|
17811
18183
|
clearTimeout(r);
|
|
17812
18184
|
}
|
|
@@ -17817,25 +18189,25 @@ var Zy = 3e4, Qy = [r(async ({ url: e, as: t }) => {
|
|
|
17817
18189
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
17818
18190
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
17819
18191
|
})
|
|
17820
|
-
})],
|
|
17821
|
-
function
|
|
17822
|
-
return
|
|
18192
|
+
})], yb = vb;
|
|
18193
|
+
function bb(e, t) {
|
|
18194
|
+
return gb(e, t);
|
|
17823
18195
|
}
|
|
17824
|
-
function
|
|
18196
|
+
function xb(e, t, n) {
|
|
17825
18197
|
let r = e?.dataOps !== !1, i = e?.fetch !== !1;
|
|
17826
18198
|
return [...r ? t : [], ...i ? n : []];
|
|
17827
18199
|
}
|
|
17828
18200
|
//#endregion
|
|
17829
18201
|
//#region src/core/harness/usageHints.ts
|
|
17830
|
-
var
|
|
17831
|
-
function
|
|
18202
|
+
var Sb = .7;
|
|
18203
|
+
function Cb(e, t, n = "simple") {
|
|
17832
18204
|
let r = n !== "advanced";
|
|
17833
18205
|
return {
|
|
17834
18206
|
name: "usageHints",
|
|
17835
18207
|
augmentPrompt: () => {
|
|
17836
18208
|
let n = [];
|
|
17837
|
-
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) {
|
|
17838
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
18209
|
+
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("读大数组(read 返回 hasMore=true)用 read({jsonPath,offset,limit}) 分页(offset+=limit 续读,默认 limit=50);一次读多个不相关子路径用 read({jsonPaths:[...]}) 省轮次;复杂 patches 改动先 write({patches,dryRun:true}) 预检(走完整校验不落盘)。"), n.push("查历史快照值(看上一版长啥样 / 冲突诊断 / 用户问\"刚才改了啥\")用 history_data({id?,jsonPath?})(只读不改当前);对比当前与历史快照的差异需切 advanced 用 diff_data(返回结构化 path→from/to)。"), 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(返回值经校验后落地)。"), n.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), n.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。"))), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
18210
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= Sb || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), i = e.subagents.filter((e) => (e.temperature ?? 0) < Sb && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
17839
18211
|
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(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
17840
18212
|
}
|
|
17841
18213
|
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;
|
|
@@ -17844,72 +18216,72 @@ function rb(e, t, n = "simple") {
|
|
|
17844
18216
|
}
|
|
17845
18217
|
//#endregion
|
|
17846
18218
|
//#region src/core/backends/skillStore.ts
|
|
17847
|
-
var
|
|
17848
|
-
function
|
|
17849
|
-
return `${
|
|
18219
|
+
var wb = "v:1::skill-store", Tb = "chat-sdk";
|
|
18220
|
+
function Eb(e, t, n) {
|
|
18221
|
+
return `${wb}::${e}::${t}::${n}`;
|
|
17850
18222
|
}
|
|
17851
|
-
function
|
|
17852
|
-
return `${
|
|
18223
|
+
function Db(e, t) {
|
|
18224
|
+
return `${wb}::${e}::${t}::`;
|
|
17853
18225
|
}
|
|
17854
|
-
function
|
|
17855
|
-
let t = e.dbName ??
|
|
18226
|
+
function Ob(e = {}) {
|
|
18227
|
+
let t = e.dbName ?? Tb, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
17856
18228
|
a = e;
|
|
17857
18229
|
});
|
|
17858
18230
|
return (async () => {
|
|
17859
18231
|
try {
|
|
17860
18232
|
if (n === "indexed") {
|
|
17861
18233
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
17862
|
-
i = await
|
|
18234
|
+
i = await ly(t), a(!0);
|
|
17863
18235
|
} else if (n === "session") {
|
|
17864
18236
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
17865
|
-
i =
|
|
18237
|
+
i = uy(sessionStorage), a(!0);
|
|
17866
18238
|
} else if (n === "local") {
|
|
17867
18239
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
17868
|
-
i =
|
|
17869
|
-
} else i =
|
|
18240
|
+
i = uy(localStorage), a(!0);
|
|
18241
|
+
} else i = cy(), a(!1);
|
|
17870
18242
|
} catch {
|
|
17871
|
-
i =
|
|
18243
|
+
i = cy(), a(!1);
|
|
17872
18244
|
}
|
|
17873
18245
|
})(), {
|
|
17874
18246
|
ready: o,
|
|
17875
18247
|
async list() {
|
|
17876
18248
|
let e = [];
|
|
17877
|
-
return await i.scan(
|
|
18249
|
+
return await i.scan(Db(t, r), (t, n) => {
|
|
17878
18250
|
e.push(n);
|
|
17879
18251
|
}), e;
|
|
17880
18252
|
},
|
|
17881
18253
|
async get(e) {
|
|
17882
|
-
return await i.get(
|
|
18254
|
+
return await i.get(Eb(t, r, e));
|
|
17883
18255
|
},
|
|
17884
18256
|
async put(e) {
|
|
17885
18257
|
try {
|
|
17886
|
-
await i.set(
|
|
18258
|
+
await i.set(Eb(t, r, e.name), e);
|
|
17887
18259
|
} catch (e) {
|
|
17888
|
-
|
|
18260
|
+
ey(e) && (i = cy());
|
|
17889
18261
|
}
|
|
17890
18262
|
},
|
|
17891
18263
|
async remove(e) {
|
|
17892
|
-
let n =
|
|
18264
|
+
let n = Eb(t, r, e);
|
|
17893
18265
|
return await i.get(n) != null && (await i.del(n), !0);
|
|
17894
18266
|
},
|
|
17895
18267
|
async clear() {
|
|
17896
|
-
await i.clearPrefix(
|
|
18268
|
+
await i.clearPrefix(Db(t, r));
|
|
17897
18269
|
},
|
|
17898
18270
|
dispose() {}
|
|
17899
18271
|
};
|
|
17900
18272
|
}
|
|
17901
18273
|
//#endregion
|
|
17902
18274
|
//#region src/core/sdk/createChatSdk.ts
|
|
17903
|
-
var
|
|
17904
|
-
function
|
|
18275
|
+
var kb = 50, Ab = /* @__PURE__ */ new Map();
|
|
18276
|
+
function jb(e, t) {
|
|
17905
18277
|
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;
|
|
17906
18278
|
}
|
|
17907
|
-
function
|
|
18279
|
+
function Mb(e, t, n, r) {
|
|
17908
18280
|
let i = 0;
|
|
17909
18281
|
return {
|
|
17910
18282
|
name: "sdk-events",
|
|
17911
18283
|
wrapToolCall: async (t, r) => {
|
|
17912
|
-
let i = await r(t), a =
|
|
18284
|
+
let i = await r(t), a = jb(t.name, t.args);
|
|
17913
18285
|
return a && e({
|
|
17914
18286
|
type: "data_change",
|
|
17915
18287
|
operation: a,
|
|
@@ -17944,29 +18316,29 @@ function fb(e, t, n, r) {
|
|
|
17944
18316
|
}
|
|
17945
18317
|
};
|
|
17946
18318
|
}
|
|
17947
|
-
function
|
|
18319
|
+
function Nb(e, i) {
|
|
17948
18320
|
let a = {
|
|
17949
18321
|
prompt_tokens: 0,
|
|
17950
18322
|
completion_tokens: 0,
|
|
17951
18323
|
total_tokens: 0
|
|
17952
|
-
}, o =
|
|
18324
|
+
}, o = Vv(() => Se), s = /* @__PURE__ */ U(0), c = py(e.storage);
|
|
17953
18325
|
e.debug && c && c.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
17954
|
-
let { modelCaps: l, summaryLlmInvoke: u } =
|
|
18326
|
+
let { modelCaps: l, summaryLlmInvoke: u } = Bv(e), d = l;
|
|
17955
18327
|
e.debug && console.log("[page-agent-sdk][modelCaps]", d);
|
|
17956
18328
|
let f = e.llm;
|
|
17957
18329
|
e.debug && !u && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
17958
|
-
let p = /* @__PURE__ */ tn([]), m =
|
|
18330
|
+
let p = /* @__PURE__ */ tn([]), m = Hy(e.vfs?.initialFiles, {
|
|
17959
18331
|
persist: c ? { save: (e) => {
|
|
17960
18332
|
z.sessionId && c && c.save(i, z.sessionId, { vfs: e });
|
|
17961
18333
|
} } : void 0,
|
|
17962
18334
|
maxBytes: e.vfs?.maxBytes,
|
|
17963
18335
|
poolBytes: e.vfs?.poolBytes
|
|
17964
|
-
}), h =
|
|
18336
|
+
}), h = $g(), g = s_(e.memory || "");
|
|
17965
18337
|
typeof e.memory == "function" && g.refresh();
|
|
17966
18338
|
let _ = { current: null }, v = e.data ? {
|
|
17967
18339
|
...e.data,
|
|
17968
18340
|
description: e.data.description ?? "主数据对象"
|
|
17969
|
-
} : void 0, y = e.checkpoint, b = y !== void 0 && y !== !1, x = b ?
|
|
18341
|
+
} : void 0, y = e.checkpoint, b = y !== void 0 && y !== !1, x = b ? w_({
|
|
17970
18342
|
getData: () => k()?.bind,
|
|
17971
18343
|
slotPaths: v ? [""] : [],
|
|
17972
18344
|
vfsStore: m,
|
|
@@ -17974,18 +18346,18 @@ function pb(e, i) {
|
|
|
17974
18346
|
getTodos: () => _.current?.getState?.()?.todos ?? [],
|
|
17975
18347
|
messages: p,
|
|
17976
18348
|
maxCheckpoints: y && typeof y == "object" ? y.maxCheckpoints : void 0
|
|
17977
|
-
}) : null, S = !y || typeof y != "object" || y.auto !== !1, C = e.capabilities, w = C?.dataOps !== !1, T =
|
|
18349
|
+
}) : null, S = !y || typeof y != "object" || y.auto !== !1, C = e.capabilities, w = C?.dataOps !== !1, T = Iv(e), E = w && v ? gb(v, {
|
|
17978
18350
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
17979
18351
|
maxSnapshots: e.maxSnapshots,
|
|
17980
18352
|
onConflict: o.set,
|
|
17981
18353
|
autoLock: e.autoLock,
|
|
17982
18354
|
interceptors: e.interceptors
|
|
17983
|
-
}) : [], D = w ?
|
|
17984
|
-
|
|
17985
|
-
let
|
|
17986
|
-
|
|
17987
|
-
let
|
|
17988
|
-
P && A.set(
|
|
18355
|
+
}) : [], D = w ? hb(E, e.toolMode) : [], O = w && v ? E.controller ?? null : null, k = () => O?.get() ?? v, A = /* @__PURE__ */ new Map(), ee = xb(C, D, vb);
|
|
18356
|
+
ee.forEach((e) => A.set(e.name, "builtin"));
|
|
18357
|
+
let j = [...e.tools || []];
|
|
18358
|
+
j.forEach((e) => A.set(e.name, "user"));
|
|
18359
|
+
let M = [], N = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), P = N ? g_() : null;
|
|
18360
|
+
P && A.set(m_, "builtin");
|
|
17989
18361
|
let F = b && x ? [r(async () => {
|
|
17990
18362
|
let e = x.list();
|
|
17991
18363
|
return e.length ? x.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
@@ -18003,25 +18375,25 @@ function pb(e, i) {
|
|
|
18003
18375
|
})] : [];
|
|
18004
18376
|
F.forEach((e) => A.set(e.name, "builtin"));
|
|
18005
18377
|
let I = [
|
|
18378
|
+
...ee,
|
|
18006
18379
|
...j,
|
|
18007
|
-
...M,
|
|
18008
18380
|
...P ? [P] : [],
|
|
18009
18381
|
...F
|
|
18010
18382
|
];
|
|
18011
18383
|
function te() {
|
|
18012
18384
|
return [
|
|
18385
|
+
...ee,
|
|
18013
18386
|
...j,
|
|
18014
|
-
...M,
|
|
18015
18387
|
...P ? [P] : [],
|
|
18016
18388
|
...F,
|
|
18017
|
-
...
|
|
18389
|
+
...M
|
|
18018
18390
|
];
|
|
18019
18391
|
}
|
|
18020
18392
|
let ne = C?.planning !== !1, re = C?.skills !== !1, ie = C?.vfs !== !1;
|
|
18021
|
-
if (ie) for (let e of
|
|
18393
|
+
if (ie) for (let e of Yy) A.set(e, "builtin");
|
|
18022
18394
|
let ae = C?.summarization !== !1, oe = C?.memory !== !1, se = C?.subagent !== !1, ce = e.verify?.maxAttempts ?? 2, le = C?.verify === !0 && e.verify?.enabled !== !1 && ce > 0;
|
|
18023
18395
|
e.verify?.check && C?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
18024
|
-
let ue = e.subagent, L = ue?.allowedTools ?? [], de = !se || ue?.enabled === !1 ? void 0 :
|
|
18396
|
+
let ue = e.subagent, L = ue?.allowedTools ?? [], de = !se || ue?.enabled === !1 ? void 0 : N_({
|
|
18025
18397
|
llm: ue?.llm ?? e.llm,
|
|
18026
18398
|
allTools: I,
|
|
18027
18399
|
allowedTools: L.length ? L : void 0,
|
|
@@ -18032,7 +18404,7 @@ function pb(e, i) {
|
|
|
18032
18404
|
maxDepth: ue?.maxDepth,
|
|
18033
18405
|
maxParallel: ue?.maxParallel,
|
|
18034
18406
|
debug: e.debug
|
|
18035
|
-
}), fe = se && e.subagents !== void 0 ?
|
|
18407
|
+
}), fe = se && e.subagents !== void 0 ? I_(e.subagents, {
|
|
18036
18408
|
llm: e.llm,
|
|
18037
18409
|
allTools: I,
|
|
18038
18410
|
debug: e.debug
|
|
@@ -18041,8 +18413,8 @@ function pb(e, i) {
|
|
|
18041
18413
|
"describe_data",
|
|
18042
18414
|
"read",
|
|
18043
18415
|
"fetch_document"
|
|
18044
|
-
], he = I.filter((e) => me.includes(e.name)), ge = le ?
|
|
18045
|
-
check: e.verify.check ??
|
|
18416
|
+
], he = I.filter((e) => me.includes(e.name)), ge = le ? L_({
|
|
18417
|
+
check: e.verify.check ?? U_({
|
|
18046
18418
|
schemas: () => k() ? { "": k().schema } : {},
|
|
18047
18419
|
root: () => k()?.bind
|
|
18048
18420
|
}),
|
|
@@ -18050,7 +18422,7 @@ function pb(e, i) {
|
|
|
18050
18422
|
llm: e.llm,
|
|
18051
18423
|
tools: he
|
|
18052
18424
|
} : void 0
|
|
18053
|
-
}) : void 0, _e =
|
|
18425
|
+
}) : void 0, _e = Cb({
|
|
18054
18426
|
...C,
|
|
18055
18427
|
humanConfirm: N,
|
|
18056
18428
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -18060,7 +18432,7 @@ function pb(e, i) {
|
|
|
18060
18432
|
}))
|
|
18061
18433
|
}, w && !!v, e.toolMode), ve = v ? {
|
|
18062
18434
|
name: "dataHint",
|
|
18063
|
-
augmentPrompt: () =>
|
|
18435
|
+
augmentPrompt: () => Fv(k()) || void 0
|
|
18064
18436
|
} : null, ye = e.augmentSystem ? {
|
|
18065
18437
|
name: "augmentSystem",
|
|
18066
18438
|
augmentPrompt: (t) => {
|
|
@@ -18074,7 +18446,7 @@ function pb(e, i) {
|
|
|
18074
18446
|
return;
|
|
18075
18447
|
}
|
|
18076
18448
|
}
|
|
18077
|
-
} : null, be = e.onEvent, xe =
|
|
18449
|
+
} : null, be = e.onEvent, xe = hy(e.onEvent), Se = xe.emit, Ce, we = [], Te = (e) => ({
|
|
18078
18450
|
name: e.name,
|
|
18079
18451
|
description: e.description,
|
|
18080
18452
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -18082,7 +18454,7 @@ function pb(e, i) {
|
|
|
18082
18454
|
name: e.name,
|
|
18083
18455
|
description: e.description,
|
|
18084
18456
|
getContent: () => e.content
|
|
18085
|
-
}), R = e.skillStorage === !1 ? null :
|
|
18457
|
+
}), R = e.skillStorage === !1 ? null : Ob({
|
|
18086
18458
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
18087
18459
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${i}`
|
|
18088
18460
|
}), De = () => {
|
|
@@ -18105,30 +18477,30 @@ function pb(e, i) {
|
|
|
18105
18477
|
z.infoTick.value++;
|
|
18106
18478
|
}
|
|
18107
18479
|
} catch {}
|
|
18108
|
-
}, ke = [
|
|
18480
|
+
}, ke = by([
|
|
18109
18481
|
...ve ? [ve] : [],
|
|
18110
18482
|
_e,
|
|
18111
18483
|
...ne ? [h] : [],
|
|
18112
|
-
...re ? [Ce =
|
|
18113
|
-
...ie ? [
|
|
18114
|
-
...ae ? [
|
|
18115
|
-
...
|
|
18484
|
+
...re ? [Ce = o_(e.skills || [], { readVfs: ie ? (e) => m.files[e]?.content : void 0 })] : [],
|
|
18485
|
+
...ie ? [Zy(m)] : [],
|
|
18486
|
+
...ae ? [hv({
|
|
18487
|
+
...vy(e, d.contextWindow),
|
|
18116
18488
|
llmInvoke: u,
|
|
18117
18489
|
getRegisteredData: () => k() ? [{ description: k().description ?? "主数据对象" }] : [],
|
|
18118
|
-
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ??
|
|
18490
|
+
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? _y[e.contextPreset ?? "auto"]
|
|
18119
18491
|
})] : [],
|
|
18120
18492
|
...oe ? [g] : [],
|
|
18121
|
-
...e.permissions?.length ? [
|
|
18122
|
-
...b && S && x ? [
|
|
18123
|
-
...N ? [
|
|
18124
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
18493
|
+
...e.permissions?.length ? [f_(e.permissions)] : [],
|
|
18494
|
+
...b && S && x ? [T_(x)] : [],
|
|
18495
|
+
...N ? [__()] : [],
|
|
18496
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [p_(e.approval)] : [],
|
|
18125
18497
|
...ge ? [ge] : [],
|
|
18126
18498
|
...de ? [de] : [],
|
|
18127
18499
|
...fe ? [fe] : [],
|
|
18128
18500
|
...ye ? [ye] : [],
|
|
18129
18501
|
...e.middleware || [],
|
|
18130
|
-
|
|
18131
|
-
], Ae = e.maxMemoryRounds ??
|
|
18502
|
+
Mb(Se, p, k, a)
|
|
18503
|
+
]), Ae = e.maxMemoryRounds ?? kb, z = {
|
|
18132
18504
|
agentId: i,
|
|
18133
18505
|
store: c,
|
|
18134
18506
|
messages: p,
|
|
@@ -18199,9 +18571,13 @@ function pb(e, i) {
|
|
|
18199
18571
|
timestamp: Date.now()
|
|
18200
18572
|
}), z.afterRound(), c && await c.flush(), t;
|
|
18201
18573
|
} catch (e) {
|
|
18574
|
+
let t = wg(e, "fatal");
|
|
18202
18575
|
throw Se({
|
|
18203
18576
|
type: "error",
|
|
18204
|
-
message:
|
|
18577
|
+
message: t.message,
|
|
18578
|
+
severity: t.severity,
|
|
18579
|
+
...t.code ? { code: t.code } : {},
|
|
18580
|
+
...t.context === void 0 ? {} : { context: t.context }
|
|
18205
18581
|
}), e;
|
|
18206
18582
|
}
|
|
18207
18583
|
},
|
|
@@ -18230,24 +18606,24 @@ function pb(e, i) {
|
|
|
18230
18606
|
if (z.refCount--, z.refCount <= 0) {
|
|
18231
18607
|
c && (m.flush?.(), c.flush(), c.dispose()), R && R.dispose();
|
|
18232
18608
|
let e = z.mcpClosers.splice(0);
|
|
18233
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
18609
|
+
e.length && Promise.allSettled(e.map((e) => e())), Ab.delete(i);
|
|
18234
18610
|
}
|
|
18235
18611
|
},
|
|
18236
18612
|
resolveConflict: o.resolve,
|
|
18237
18613
|
setTools(e) {
|
|
18238
|
-
|
|
18239
|
-
|
|
18614
|
+
j.length = 0, e.forEach((e) => {
|
|
18615
|
+
j.push(e), A.set(e.name, "user");
|
|
18240
18616
|
}), I = te(), z.agent && z.agent.setTools(I), z.infoTick.value++;
|
|
18241
18617
|
},
|
|
18242
18618
|
addTool(e) {
|
|
18243
|
-
|
|
18619
|
+
j.some((t) => t.name === e.name) || (j.push(e), A.set(e.name, "user"), I = te(), z.agent && z.agent.setTools(I), z.infoTick.value++);
|
|
18244
18620
|
},
|
|
18245
18621
|
removeTool(e) {
|
|
18246
|
-
let t =
|
|
18247
|
-
return t < 0 ? !1 : (
|
|
18622
|
+
let t = j.findIndex((t) => t.name === e);
|
|
18623
|
+
return t < 0 ? !1 : (j.splice(t, 1), I = te(), z.agent && z.agent.setTools(I), z.infoTick.value++, !0);
|
|
18248
18624
|
},
|
|
18249
18625
|
setLlm(t) {
|
|
18250
|
-
let r =
|
|
18626
|
+
let r = Lv(t) ? t : new n({
|
|
18251
18627
|
apiKey: t.apiKey,
|
|
18252
18628
|
model: t.model,
|
|
18253
18629
|
temperature: t.temperature,
|
|
@@ -18288,8 +18664,8 @@ function pb(e, i) {
|
|
|
18288
18664
|
getInfo() {
|
|
18289
18665
|
return {
|
|
18290
18666
|
id: i,
|
|
18291
|
-
model:
|
|
18292
|
-
systemPrompt:
|
|
18667
|
+
model: Lv(f) ? f.model ?? f.modelName : f.model,
|
|
18668
|
+
systemPrompt: z.agent?.getEffectiveSystemPrompt?.() ?? T + Fv(k()),
|
|
18293
18669
|
tools: (z.agent?.allTools ?? I).map((e) => ({
|
|
18294
18670
|
name: e.name,
|
|
18295
18671
|
description: e.description,
|
|
@@ -18363,7 +18739,7 @@ function pb(e, i) {
|
|
|
18363
18739
|
await Oe();
|
|
18364
18740
|
}
|
|
18365
18741
|
function Ne() {
|
|
18366
|
-
let e =
|
|
18742
|
+
let e = ov(p, Ae);
|
|
18367
18743
|
e.trimmed && p.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
18368
18744
|
}
|
|
18369
18745
|
function Pe() {
|
|
@@ -18375,7 +18751,7 @@ function pb(e, i) {
|
|
|
18375
18751
|
}
|
|
18376
18752
|
return z.initDone = (async () => {
|
|
18377
18753
|
if (await je(), await Me(), e.mcp?.length) {
|
|
18378
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
18754
|
+
let t = await Promise.allSettled(e.mcp.map((e) => $_(e)));
|
|
18379
18755
|
z.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), z.mcpServers = [];
|
|
18380
18756
|
let n = [];
|
|
18381
18757
|
t.forEach((t, r) => {
|
|
@@ -18387,8 +18763,8 @@ function pb(e, i) {
|
|
|
18387
18763
|
}), t.value.tools.forEach((e) => A.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
18388
18764
|
}), I = te(), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${z.mcpServers.length} 个 server`);
|
|
18389
18765
|
}
|
|
18390
|
-
z.agent =
|
|
18391
|
-
...
|
|
18766
|
+
z.agent = Zg({
|
|
18767
|
+
...Lv(e.llm) ? { llm: e.llm } : {
|
|
18392
18768
|
apiKey: e.llm.apiKey,
|
|
18393
18769
|
baseUrl: e.llm.baseUrl,
|
|
18394
18770
|
model: e.llm.model,
|
|
@@ -18407,8 +18783,8 @@ function pb(e, i) {
|
|
|
18407
18783
|
maxOutputTokens: d.maxOutputTokens,
|
|
18408
18784
|
maxVerifyAttempts: le ? ce : 0,
|
|
18409
18785
|
onLlmChange: (t) => {
|
|
18410
|
-
let n =
|
|
18411
|
-
d =
|
|
18786
|
+
let n = Lv(t) ? void 0 : t;
|
|
18787
|
+
d = Mg({
|
|
18412
18788
|
model: n?.model ?? t.model ?? t.modelName,
|
|
18413
18789
|
contextWindow: e.contextWindow ?? n?.contextWindow,
|
|
18414
18790
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens
|
|
@@ -18420,12 +18796,12 @@ function pb(e, i) {
|
|
|
18420
18796
|
});
|
|
18421
18797
|
})(), z;
|
|
18422
18798
|
}
|
|
18423
|
-
function
|
|
18424
|
-
let t = e.id ??
|
|
18799
|
+
function Pb(e) {
|
|
18800
|
+
let t = e.id ?? Hv();
|
|
18425
18801
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
18426
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
18427
|
-
a ? i = a : (i =
|
|
18428
|
-
let o = null, s = null, c =
|
|
18802
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? Ab.get(t) : void 0;
|
|
18803
|
+
a ? i = a : (i = Nb(e, t), e.shareContext && Ab.set(t, i)), i.refCount++;
|
|
18804
|
+
let o = null, s = null, c = my(e), l = null, u = null;
|
|
18429
18805
|
async function d(t) {
|
|
18430
18806
|
if (await i.initDone, o) {
|
|
18431
18807
|
m();
|
|
@@ -18464,7 +18840,7 @@ function mb(e) {
|
|
|
18464
18840
|
i.afterRound(), i.store && await i.store.flush();
|
|
18465
18841
|
},
|
|
18466
18842
|
onClear: () => {
|
|
18467
|
-
i.store && (i.sessionId =
|
|
18843
|
+
i.store && (i.sessionId = Hv(), 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));
|
|
18468
18844
|
},
|
|
18469
18845
|
pendingConflict: i.pendingConflict.value,
|
|
18470
18846
|
onResolveConflict: (e) => i.resolveConflict(e),
|
|
@@ -18580,7 +18956,7 @@ function mb(e) {
|
|
|
18580
18956
|
error: "schema 校验失败:" + (t.error?.message ?? "未知错误")
|
|
18581
18957
|
};
|
|
18582
18958
|
}
|
|
18583
|
-
return
|
|
18959
|
+
return x_(r, e), t?.emit !== !1 && i.emit({
|
|
18584
18960
|
type: "data_change",
|
|
18585
18961
|
operation: "set",
|
|
18586
18962
|
value: r
|
|
@@ -18602,7 +18978,7 @@ function mb(e) {
|
|
|
18602
18978
|
}
|
|
18603
18979
|
//#endregion
|
|
18604
18980
|
//#region src/core/sdk/defineTool.ts
|
|
18605
|
-
function
|
|
18981
|
+
function Fb(e) {
|
|
18606
18982
|
return r(async (t) => {
|
|
18607
18983
|
let n = await e.handler(t);
|
|
18608
18984
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -18613,4 +18989,4 @@ function hb(e) {
|
|
|
18613
18989
|
});
|
|
18614
18990
|
}
|
|
18615
18991
|
//#endregion
|
|
18616
|
-
export {
|
|
18992
|
+
export { gy as CONTEXT_PRESETS, yg as ChatDialog, nf as CodePreview, Pv as DEFAULT_SYSTEM_PROMPT, m_ as HUMAN_CONFIRM_TOOL_NAME, af as MessageContent, sv as STOP_WORDS, sh as SkillPanel, xy as UNSAFE_KEYS, Tg as agentError, Py as applyPatchToClone, Fy as applyPatchToLive, wg as asAgentError, Fv as buildDataPrompt, Iv as buildSystemPrompt, $_ as connectMcp, wl as copyText, Zg as createAgent, p_ as createApprovalMiddleware, Pb as createChatSdk, w_ as createCheckpointManager, T_ as createCheckpointMiddleware, Vv as createConflictManager, gb as createDataOps, __ as createHumanConfirmMiddleware, g_ as createHumanConfirmTool, cy as createMemoryBackend, s_ as createMemoryMiddleware, v as createProxyLlm, hy as createSdkEvents, fy as createSessionStore, Ob as createSkillStore, N_ as createSubagentMiddleware, I_ as createSubagentsMiddleware, Cb as createUsageHintsMiddleware, L_ as createVerifyMiddleware, Hy as createVfs, uy as createWebStorageBackend, U_ as createWriteBackCheck, Dy as deepClone, bb as defineDataToolset, e_ as defineSkill, Fb as defineTool, Ey as deleteByPath, Dv as describeSchemaNode, Gg as detectGarbledToolCall, Ry as diffObjects, lv as estimateMessageTokens, uv as estimateRoundTokens, Ng as estimateTokens, Nv as extractSchemaHint, X_ as extractText, vb as fetchDocTools, yb as fetchTools, hb as filterByToolMode, Ov as formatConstraints, bg as formatZodIssues, wy as getByPath, yv as getSchemaAtPath, gv as getSchemaTopKeys, Ny as hashValue, dv as indexSummarize, Lv as isChatModel, _v as isPathAllowed, ey as isQuotaError, Sy as isUnsafePath, sb as jpEval, Sg as jsonParseError, Ay as limitDepth, Oy as maybeParseValue, Fg as offloadPassThroughChars, Pg as offloadThresholdChars, jv as presets, xv as projectBySchema, bv as projectBySchemaDeep, ky as projectFields, fv as recallRounds, kv as renderSchemaHint, Av as renderSchemaOverview, vy as resolveContextOptions, my as resolveDialogConfig, Bv as resolveLlm, Mg as resolveModelCaps, py as resolveStorage, Ly as restoreInPlace, Iy as restoreLive, Cg as routeError, fb as runSandboxedScript, Cy as safeMerge, jy as safeStringify, lb as searchJson, xb as selectBuiltinTools, Ty as setByPath, Mv as systemPromptHelpers, cv as tokenize, $ as toolError, vv as unwrapSchema, Cl as useChat, e as z, xg as zodError };
|