page-agent-sdk 2.9.1 → 2.10.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 +21 -6
- package/README.zh-CN.md +21 -6
- package/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +112 -112
- package/dist/page-agent-sdk.js +1016 -721
- package/dist/page-agent-sdk.umd.cjs +45 -45
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/references/api.md +4 -0
- package/skills/page-agent-sdk-integrate/references/integration-prompt.md +7 -5
- package/skills/page-agent-sdk-integrate/references/options.md +30 -2
- package/skills/page-agent-sdk-integrate/references/use-cases.md +3 -3
- package/types/index.d.ts +47 -2
package/dist/page-agent-sdk.js
CHANGED
|
@@ -47,33 +47,33 @@ function ye(e) {
|
|
|
47
47
|
if (O(e)) {
|
|
48
48
|
let t = {};
|
|
49
49
|
for (let n = 0; n < e.length; n++) {
|
|
50
|
-
let r = e[n], i = N(r) ?
|
|
50
|
+
let r = e[n], i = N(r) ? Ce(r) : ye(r);
|
|
51
51
|
if (i) for (let e in i) t[e] = i[e];
|
|
52
52
|
}
|
|
53
53
|
return t;
|
|
54
54
|
} else if (N(e) || F(e)) return e;
|
|
55
55
|
}
|
|
56
|
-
var be = /;(?![^(]*\))/g, xe = /:([^]+)/,
|
|
57
|
-
function
|
|
56
|
+
var be = /;(?![^(]*\))/g, xe = /:([^]+)/, Se = /\/\*[^]*?\*\//g;
|
|
57
|
+
function Ce(e) {
|
|
58
58
|
let t = {};
|
|
59
|
-
return e.replace(
|
|
59
|
+
return e.replace(Se, "").split(be).forEach((e) => {
|
|
60
60
|
if (e) {
|
|
61
61
|
let n = e.split(xe);
|
|
62
62
|
n.length > 1 && (t[n[0].trim()] = n[1].trim());
|
|
63
63
|
}
|
|
64
64
|
}), t;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function we(e) {
|
|
67
67
|
let t = "";
|
|
68
68
|
if (N(e)) t = e;
|
|
69
69
|
else if (O(e)) for (let n = 0; n < e.length; n++) {
|
|
70
|
-
let r =
|
|
70
|
+
let r = we(e[n]);
|
|
71
71
|
r && (t += r + " ");
|
|
72
72
|
}
|
|
73
73
|
else if (F(e)) for (let n in e) e[n] && (t += n + " ");
|
|
74
74
|
return t.trim();
|
|
75
75
|
}
|
|
76
|
-
var
|
|
76
|
+
var Te = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot", Ee = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view", De = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics", z = /* @__PURE__ */ _(Te), Oe = /* @__PURE__ */ _(Ee), ke = /* @__PURE__ */ _(De), Ae = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly", je = /* @__PURE__ */ _(Ae);
|
|
77
77
|
Ae + "";
|
|
78
78
|
function Me(e) {
|
|
79
79
|
return !!e || e === "";
|
|
@@ -3073,7 +3073,7 @@ function es(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
3073
3073
|
if (Rs(e) && (e = e.__vccOpts), t) {
|
|
3074
3074
|
t = ts(t);
|
|
3075
3075
|
let { class: e, style: n } = t;
|
|
3076
|
-
e && !N(e) && (t.class =
|
|
3076
|
+
e && !N(e) && (t.class = we(e)), F(n) && (/* @__PURE__ */ cn(n) && !O(n) && (n = w({}, n)), t.style = ye(n));
|
|
3077
3077
|
}
|
|
3078
3078
|
let o = N(e) ? 1 : Fo(e) ? 128 : Zr(e) ? 64 : F(e) ? 4 : M(e) ? 2 : 0;
|
|
3079
3079
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ cn(e) && (e = /* @__PURE__ */ H(e), G("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), Y(e, t, n, r, i, o, a, !0);
|
|
@@ -3160,7 +3160,7 @@ function cs(...e) {
|
|
|
3160
3160
|
let t = {};
|
|
3161
3161
|
for (let n = 0; n < e.length; n++) {
|
|
3162
3162
|
let r = e[n];
|
|
3163
|
-
for (let e in r) if (e === "class") t.class !== r.class && (t.class =
|
|
3163
|
+
for (let e in r) if (e === "class") t.class !== r.class && (t.class = we([t.class, r.class]));
|
|
3164
3164
|
else if (e === "style") t.style = ye([t.style, r.style]);
|
|
3165
3165
|
else if (S(e)) {
|
|
3166
3166
|
let n = t[e], i = r[e];
|
|
@@ -3997,7 +3997,7 @@ function dl(e) {
|
|
|
3997
3997
|
}
|
|
3998
3998
|
function fl(e) {
|
|
3999
3999
|
Object.defineProperty(e.config, "isNativeTag", {
|
|
4000
|
-
value: (e) =>
|
|
4000
|
+
value: (e) => z(e) || Oe(e) || ke(e),
|
|
4001
4001
|
writable: !1
|
|
4002
4002
|
});
|
|
4003
4003
|
}
|
|
@@ -6074,13 +6074,13 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6074
6074
|
ye(e, e.end, { key: "endScope" }), e.end = C(e.end, { joinWith: "" });
|
|
6075
6075
|
}
|
|
6076
6076
|
}
|
|
6077
|
-
function z(e) {
|
|
6078
|
-
e.scope && typeof e.scope == "object" && e.scope !== null && (e.beginScope = e.scope, delete e.scope);
|
|
6079
|
-
}
|
|
6080
6077
|
function Se(e) {
|
|
6081
|
-
|
|
6078
|
+
e.scope && typeof e.scope == "object" && e.scope !== null && (e.beginScope = e.scope, delete e.scope);
|
|
6082
6079
|
}
|
|
6083
6080
|
function Ce(e) {
|
|
6081
|
+
Se(e), typeof e.beginScope == "string" && (e.beginScope = { _wrap: e.beginScope }), typeof e.endScope == "string" && (e.endScope = { _wrap: e.endScope }), be(e), xe(e);
|
|
6082
|
+
}
|
|
6083
|
+
function we(e) {
|
|
6084
6084
|
function t(t, n) {
|
|
6085
6085
|
return new RegExp(p(t), "m" + (e.case_insensitive ? "i" : "") + (e.unicodeRegex ? "u" : "") + (n ? "g" : ""));
|
|
6086
6086
|
}
|
|
@@ -6146,7 +6146,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6146
6146
|
[
|
|
6147
6147
|
re,
|
|
6148
6148
|
oe,
|
|
6149
|
-
|
|
6149
|
+
Ce,
|
|
6150
6150
|
ce
|
|
6151
6151
|
].forEach((e) => e(n, r)), e.compilerExtensions.forEach((e) => e(n, r)), n.__beforeBegin = null, [
|
|
6152
6152
|
ie,
|
|
@@ -6155,7 +6155,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6155
6155
|
].forEach((e) => e(n, r)), n.isCompiled = !0;
|
|
6156
6156
|
let s = null;
|
|
6157
6157
|
return typeof n.keywords == "object" && n.keywords.$pattern && (n.keywords = Object.assign({}, n.keywords), s = n.keywords.$pattern, delete n.keywords.$pattern), s ||= /\w+/, n.keywords &&= de(n.keywords, e.case_insensitive), a.keywordPatternRe = t(s, !0), r && (n.begin ||= /\B|\b/, a.beginRe = t(a.begin), !n.end && !n.endsWithParent && (n.end = /\B|\b/), n.end && (a.endRe = t(a.end)), a.terminatorEnd = p(a.end) || "", n.endsWithParent && r.terminatorEnd && (a.terminatorEnd += (n.end ? "|" : "") + r.terminatorEnd)), n.illegal && (a.illegalRe = t(n.illegal)), n.contains ||= [], n.contains = [].concat(...n.contains.map(function(e) {
|
|
6158
|
-
return
|
|
6158
|
+
return Ee(e === "self" ? n : e);
|
|
6159
6159
|
})), n.contains.forEach(function(e) {
|
|
6160
6160
|
o(e, a);
|
|
6161
6161
|
}), n.starts && o(n.starts, r), a.matcher = i(a), a;
|
|
@@ -6163,15 +6163,15 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6163
6163
|
if (e.compilerExtensions ||= [], e.contains && e.contains.includes("self")) throw Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
|
|
6164
6164
|
return e.classNameAliases = a(e.classNameAliases || {}), o(e);
|
|
6165
6165
|
}
|
|
6166
|
-
function we(e) {
|
|
6167
|
-
return e ? e.endsWithParent || we(e.starts) : !1;
|
|
6168
|
-
}
|
|
6169
6166
|
function Te(e) {
|
|
6167
|
+
return e ? e.endsWithParent || Te(e.starts) : !1;
|
|
6168
|
+
}
|
|
6169
|
+
function Ee(e) {
|
|
6170
6170
|
return e.variants && !e.cachedVariants && (e.cachedVariants = e.variants.map(function(t) {
|
|
6171
6171
|
return a(e, { variants: null }, t);
|
|
6172
|
-
})), e.cachedVariants ? e.cachedVariants :
|
|
6172
|
+
})), e.cachedVariants ? e.cachedVariants : Te(e) ? a(e, { starts: e.starts ? a(e.starts) : null }) : Object.isFrozen(e) ? a(e) : e;
|
|
6173
6173
|
}
|
|
6174
|
-
var
|
|
6174
|
+
var De = "11.11.1", z = class extends Error {
|
|
6175
6175
|
constructor(e, t) {
|
|
6176
6176
|
super(e), this.name = "HTMLInjectionError", this.html = t;
|
|
6177
6177
|
}
|
|
@@ -6336,7 +6336,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6336
6336
|
}
|
|
6337
6337
|
let D = N(e);
|
|
6338
6338
|
if (!D) throw he(s.replace("{}", e)), Error("Unknown language: \"" + e + "\"");
|
|
6339
|
-
let O =
|
|
6339
|
+
let O = we(D), k = "", A = a || O, j = {}, M = new l.__emitter(l);
|
|
6340
6340
|
w();
|
|
6341
6341
|
let P = "", F = 0, I = 0, L = 0, R = !1;
|
|
6342
6342
|
try {
|
|
@@ -6424,7 +6424,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6424
6424
|
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", e);
|
|
6425
6425
|
return;
|
|
6426
6426
|
}
|
|
6427
|
-
if (e.children.length > 0 && (l.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(e)), l.throwUnescapedHTML)) throw new
|
|
6427
|
+
if (e.children.length > 0 && (l.ignoreUnescapedHTML || (console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."), console.warn("https://github.com/highlightjs/highlight.js/wiki/security"), console.warn("The element with unescaped HTML:"), console.warn(e)), l.throwUnescapedHTML)) throw new z("One of your code blocks includes unescaped HTML.", e.innerHTML);
|
|
6428
6428
|
t = e;
|
|
6429
6429
|
let r = t.textContent, i = n ? p(r, {
|
|
6430
6430
|
language: n,
|
|
@@ -6538,7 +6538,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6538
6538
|
o = !1;
|
|
6539
6539
|
}, e.safeMode = function() {
|
|
6540
6540
|
o = !0;
|
|
6541
|
-
}, e.versionString =
|
|
6541
|
+
}, e.versionString = De, e.regex = {
|
|
6542
6542
|
concat: _,
|
|
6543
6543
|
lookahead: m,
|
|
6544
6544
|
either: y,
|
|
@@ -12547,11 +12547,11 @@ app.mount('#app');
|
|
|
12547
12547
|
}, [Y("div", Hd, [Y("div", Ud, [
|
|
12548
12548
|
Y("span", Wd, "代码预览 · " + B(e.lang), 1),
|
|
12549
12549
|
Y("div", Gd, [Y("button", {
|
|
12550
|
-
class:
|
|
12550
|
+
class: we({ active: a.value === "preview" }),
|
|
12551
12551
|
disabled: !s.value,
|
|
12552
12552
|
onClick: n[0] ||= (e) => a.value = "preview"
|
|
12553
12553
|
}, "预览", 10, Kd), Y("button", {
|
|
12554
|
-
class:
|
|
12554
|
+
class: we({ active: a.value === "source" }),
|
|
12555
12555
|
onClick: n[1] ||= (e) => a.value = "source"
|
|
12556
12556
|
}, "源码", 2)]),
|
|
12557
12557
|
Y("div", qd, [
|
|
@@ -12995,16 +12995,16 @@ app.mount('#app');
|
|
|
12995
12995
|
default: Lr(() => [e.visible ? (q(), J("div", rf, [Y("div", af, [
|
|
12996
12996
|
Y("div", of, [Y("div", sf, [
|
|
12997
12997
|
Y("button", {
|
|
12998
|
-
class:
|
|
12998
|
+
class: we(["tab-btn", { active: y.value === "logs" }]),
|
|
12999
12999
|
onClick: n[0] ||= (e) => w("logs")
|
|
13000
13000
|
}, "🐛 日志", 2),
|
|
13001
13001
|
Y("button", {
|
|
13002
|
-
class:
|
|
13002
|
+
class: we(["tab-btn", { active: y.value === "flow" }]),
|
|
13003
13003
|
onClick: n[1] ||= (e) => w("flow")
|
|
13004
13004
|
}, "🔀 流程", 2),
|
|
13005
13005
|
e.getInfo ? (q(), J("button", {
|
|
13006
13006
|
key: 0,
|
|
13007
|
-
class:
|
|
13007
|
+
class: we(["tab-btn", { active: y.value === "info" }]),
|
|
13008
13008
|
onClick: n[2] ||= (e) => w("info")
|
|
13009
13009
|
}, "🧬 Agent 信息", 2)) : X("", !0)
|
|
13010
13010
|
]), Y("div", cf, [y.value === "logs" ? (q(), J("button", {
|
|
@@ -13019,11 +13019,11 @@ app.mount('#app');
|
|
|
13019
13019
|
}, "✕")])]),
|
|
13020
13020
|
y.value === "logs" ? (q(), J("div", lf, [(q(), J(K, null, Xi(s, (e, t) => Y("button", {
|
|
13021
13021
|
key: t,
|
|
13022
|
-
class:
|
|
13022
|
+
class: we(["filter-chip", { active: i.value === t }]),
|
|
13023
13023
|
style: ye({ "--chip-color": e.color }),
|
|
13024
13024
|
onClick: (e) => i.value = t
|
|
13025
13025
|
}, [is(B(e.icon) + " " + B(e.label) + " ", 1), Y("span", df, B(u.value[t] || 0), 1)], 14, uf)), 64)), Y("button", {
|
|
13026
|
-
class:
|
|
13026
|
+
class: we(["filter-chip all", { active: i.value === "all" }]),
|
|
13027
13027
|
onClick: n[3] ||= (e) => i.value = "all"
|
|
13028
13028
|
}, [n[4] ||= is(" 全部 ", -1), Y("span", ff, B(u.value.all || 0), 1)], 2)])) : X("", !0),
|
|
13029
13029
|
Y("div", pf, [y.value === "logs" ? (q(), J(K, { key: 0 }, [l.value.length === 0 ? (q(), J("div", mf, " 暂无日志,发送消息后这里会显示 Agent 的完整上下文、工具调用等信息 ")) : X("", !0), (q(!0), J(K, null, Xi(l.value, (e, t) => (q(), J("div", {
|
|
@@ -13105,7 +13105,7 @@ app.mount('#app');
|
|
|
13105
13105
|
c.value.length ? X("", !0) : (q(), J("div", pp, "暂无日志,发送消息后这里按轮次展示执行流程")),
|
|
13106
13106
|
O.value.pre.length ? (q(), J("div", mp, [n[10] ||= Y("div", { class: "flow-section-title" }, "⚙️ 准备 / 其他", -1), (q(!0), J(K, null, Xi(O.value.pre, (e, t) => (q(), J("div", {
|
|
13107
13107
|
key: "p" + t,
|
|
13108
|
-
class:
|
|
13108
|
+
class: we(["flow-node", e.type])
|
|
13109
13109
|
}, [
|
|
13110
13110
|
Y("span", hp, B(s[e.type]?.icon), 1),
|
|
13111
13111
|
Y("span", gp, B(s[e.type]?.label), 1),
|
|
@@ -13117,7 +13117,7 @@ app.mount('#app');
|
|
|
13117
13117
|
class: "flow-round"
|
|
13118
13118
|
}, [Y("div", yp, "🔁 第 " + B(e.round) + " 轮", 1), Y("div", bp, [(q(!0), J(K, null, Xi(e.items, (e, t) => (q(), J("div", {
|
|
13119
13119
|
key: t,
|
|
13120
|
-
class:
|
|
13120
|
+
class: we(["flow-node", e.type])
|
|
13121
13121
|
}, [
|
|
13122
13122
|
Y("span", xp, B(s[e.type]?.icon), 1),
|
|
13123
13123
|
Y("span", Sp, B(s[e.type]?.label), 1),
|
|
@@ -13140,7 +13140,7 @@ app.mount('#app');
|
|
|
13140
13140
|
class: "info-item"
|
|
13141
13141
|
}, [Y("div", Vp, [is(B(e.name), 1), e.source ? (q(), J("span", {
|
|
13142
13142
|
key: 0,
|
|
13143
|
-
class:
|
|
13143
|
+
class: we(["src-tag", D(e.source)])
|
|
13144
13144
|
}, B(e.source), 3)) : X("", !0)]), Y("div", Hp, B(e.description), 1)]))), 128))]),
|
|
13145
13145
|
b.value.skills.length ? (q(), J("div", Up, [Y("div", Wp, [is("📘 技能 (" + B(b.value.skills.length) + ")", 1), n[17] ||= Y("span", { class: "info-hint" }, "点击展开查看全文", -1)]), (q(!0), J(K, null, Xi(b.value.skills, (e) => (q(), J("div", {
|
|
13146
13146
|
key: e.name,
|
|
@@ -13149,7 +13149,7 @@ app.mount('#app');
|
|
|
13149
13149
|
Y("div", {
|
|
13150
13150
|
class: "info-name skill-toggle",
|
|
13151
13151
|
onClick: (t) => S(e.name)
|
|
13152
|
-
}, [Y("span", { class:
|
|
13152
|
+
}, [Y("span", { class: we(["skill-arrow", { open: !!x.value[e.name] }]) }, "▶", 2), is(" " + B(e.name), 1)], 8, Gp),
|
|
13153
13153
|
Y("div", Kp, B(e.description), 1),
|
|
13154
13154
|
x.value[e.name] ? (q(), J("div", qp, [x.value[e.name].loading ? (q(), J("div", Jp, "加载中…")) : x.value[e.name].error ? (q(), J("div", Yp, B(x.value[e.name].error), 1)) : x.value[e.name].content ? (q(), J("pre", Xp, B(x.value[e.name].content), 1)) : X("", !0)])) : X("", !0)
|
|
13155
13155
|
]))), 128))])) : X("", !0),
|
|
@@ -13193,102 +13193,224 @@ app.mount('#app');
|
|
|
13193
13193
|
_: 1
|
|
13194
13194
|
})]));
|
|
13195
13195
|
}
|
|
13196
|
-
}), [["__scopeId", "data-v-01f829a3"]]), Um = { class: "
|
|
13196
|
+
}), [["__scopeId", "data-v-01f829a3"]]), Um = { class: "skill-panel" }, Wm = { class: "skill-header" }, Gm = { class: "skill-section" }, Km = { class: "section-title" }, qm = { class: "field" }, Jm = ["disabled"], Ym = { class: "field" }, Xm = { class: "field field-textarea" }, Zm = {
|
|
13197
|
+
key: 0,
|
|
13198
|
+
class: "skill-error"
|
|
13199
|
+
}, Qm = { class: "skill-section" }, $m = { class: "section-title" }, eh = {
|
|
13200
|
+
key: 0,
|
|
13201
|
+
class: "empty-hint"
|
|
13202
|
+
}, th = {
|
|
13203
|
+
key: 1,
|
|
13204
|
+
class: "skill-list"
|
|
13205
|
+
}, nh = { class: "skill-actions" }, rh = ["onClick"], ih = ["onClick"], ah = /*#__PURE__*/ $d(/* @__PURE__ */ wi({
|
|
13206
|
+
__name: "SkillPanel",
|
|
13207
|
+
props: {
|
|
13208
|
+
visible: { type: Boolean },
|
|
13209
|
+
onAddSkill: { type: Function },
|
|
13210
|
+
onRemoveSkill: { type: Function },
|
|
13211
|
+
getUserSkillNames: { type: Function },
|
|
13212
|
+
onGetSkill: { type: Function }
|
|
13213
|
+
},
|
|
13214
|
+
emits: ["close"],
|
|
13215
|
+
setup(e, { emit: t }) {
|
|
13216
|
+
let n = e, r = t, i = /* @__PURE__ */ U(""), a = /* @__PURE__ */ U(""), o = /* @__PURE__ */ U(""), s = /* @__PURE__ */ U(""), c = /* @__PURE__ */ U([]), l = /* @__PURE__ */ U(0), u = /* @__PURE__ */ U(null);
|
|
13217
|
+
Gr(() => n.visible, (e) => {
|
|
13218
|
+
e && d();
|
|
13219
|
+
}, { immediate: !0 }), Gr(l, () => d());
|
|
13220
|
+
function d() {
|
|
13221
|
+
n.getUserSkillNames && (c.value = n.getUserSkillNames());
|
|
13222
|
+
}
|
|
13223
|
+
function f() {
|
|
13224
|
+
if (s.value = "", !i.value.trim()) {
|
|
13225
|
+
s.value = "skill 名不能为空";
|
|
13226
|
+
return;
|
|
13227
|
+
}
|
|
13228
|
+
if (!a.value.trim()) {
|
|
13229
|
+
s.value = "描述不能为空";
|
|
13230
|
+
return;
|
|
13231
|
+
}
|
|
13232
|
+
if (!o.value.trim()) {
|
|
13233
|
+
s.value = "内容不能为空";
|
|
13234
|
+
return;
|
|
13235
|
+
}
|
|
13236
|
+
let e = i.value.trim();
|
|
13237
|
+
u.value === null && c.value.includes(e) && (s.value = `已存在同名用户 skill "${e}",将覆盖`), n.onAddSkill?.({
|
|
13238
|
+
name: e,
|
|
13239
|
+
description: a.value.trim(),
|
|
13240
|
+
getContent: () => o.value
|
|
13241
|
+
}), h(), l.value++;
|
|
13242
|
+
}
|
|
13243
|
+
function p(e) {
|
|
13244
|
+
n.onRemoveSkill && n.onRemoveSkill(e) && (u.value === e && h(), l.value++);
|
|
13245
|
+
}
|
|
13246
|
+
function m(e) {
|
|
13247
|
+
if (!n.onGetSkill) return;
|
|
13248
|
+
let t = n.onGetSkill(e);
|
|
13249
|
+
t && (u.value = e, i.value = t.name, a.value = t.description, o.value = t.content, s.value = "");
|
|
13250
|
+
}
|
|
13251
|
+
function h() {
|
|
13252
|
+
u.value = null, i.value = "", a.value = "", o.value = "", s.value = "";
|
|
13253
|
+
}
|
|
13254
|
+
return (t, n) => (q(), Ko(oi, { to: "body" }, [$o(rc, { name: "cs-skill-fade" }, {
|
|
13255
|
+
default: Lr(() => [e.visible ? (q(), J("div", {
|
|
13256
|
+
key: 0,
|
|
13257
|
+
class: "skill-mask",
|
|
13258
|
+
onClick: n[4] ||= ol((e) => r("close"), ["self"])
|
|
13259
|
+
}, [Y("div", Um, [
|
|
13260
|
+
Y("div", Wm, [n[5] ||= Y("span", { class: "skill-title" }, "🧩 Skill 管理", -1), Y("button", {
|
|
13261
|
+
class: "skill-close",
|
|
13262
|
+
title: "关闭",
|
|
13263
|
+
onClick: n[0] ||= (e) => r("close")
|
|
13264
|
+
}, "✕")]),
|
|
13265
|
+
Y("div", Gm, [
|
|
13266
|
+
Y("div", Km, [is(B(u.value ? `编辑 Skill: ${u.value}` : "创建新 Skill") + " ", 1), u.value ? (q(), J("button", {
|
|
13267
|
+
key: 0,
|
|
13268
|
+
class: "btn btn-ghost btn-cancel",
|
|
13269
|
+
title: "取消编辑,回到新建",
|
|
13270
|
+
onClick: h
|
|
13271
|
+
}, "取消编辑")) : X("", !0)]),
|
|
13272
|
+
Y("label", qm, [n[6] ||= Y("span", { class: "field-label" }, "名称", -1), zr(Y("input", {
|
|
13273
|
+
"onUpdate:modelValue": n[1] ||= (e) => i.value = e,
|
|
13274
|
+
disabled: !!u.value,
|
|
13275
|
+
placeholder: "如:my-writer",
|
|
13276
|
+
class: "field-input"
|
|
13277
|
+
}, null, 8, Jm), [[rl, i.value]])]),
|
|
13278
|
+
Y("label", Ym, [n[7] ||= Y("span", { class: "field-label" }, "描述", -1), zr(Y("input", {
|
|
13279
|
+
"onUpdate:modelValue": n[2] ||= (e) => a.value = e,
|
|
13280
|
+
placeholder: "一句话说明用途与触发时机",
|
|
13281
|
+
class: "field-input"
|
|
13282
|
+
}, null, 512), [[rl, a.value]])]),
|
|
13283
|
+
Y("label", Xm, [n[8] ||= Y("span", { class: "field-label" }, "内容", -1), zr(Y("textarea", {
|
|
13284
|
+
"onUpdate:modelValue": n[3] ||= (e) => o.value = e,
|
|
13285
|
+
placeholder: "skill 全文指令(支持 Markdown)",
|
|
13286
|
+
rows: "6",
|
|
13287
|
+
class: "field-input"
|
|
13288
|
+
}, null, 512), [[rl, o.value]])]),
|
|
13289
|
+
s.value ? (q(), J("div", Zm, B(s.value), 1)) : X("", !0),
|
|
13290
|
+
Y("button", {
|
|
13291
|
+
class: "btn btn-primary",
|
|
13292
|
+
onClick: f
|
|
13293
|
+
}, B(u.value ? "保存修改" : "添加 Skill"), 1)
|
|
13294
|
+
]),
|
|
13295
|
+
Y("div", Qm, [Y("div", $m, "已创建 Skill(" + B(c.value.length) + ")", 1), c.value.length ? (q(), J("ul", th, [(q(!0), J(K, null, Xi(c.value, (e) => (q(), J("li", {
|
|
13296
|
+
key: e,
|
|
13297
|
+
class: "skill-item"
|
|
13298
|
+
}, [Y("span", { class: we(["skill-name", { active: u.value === e }]) }, B(e), 3), Y("span", nh, [Y("button", {
|
|
13299
|
+
class: "btn btn-ghost btn-edit",
|
|
13300
|
+
title: "加载到表单编辑",
|
|
13301
|
+
onClick: (t) => m(e)
|
|
13302
|
+
}, "编辑", 8, rh), Y("button", {
|
|
13303
|
+
class: "btn btn-ghost btn-del",
|
|
13304
|
+
title: "删除该用户 skill",
|
|
13305
|
+
onClick: (t) => p(e)
|
|
13306
|
+
}, "删除", 8, ih)])]))), 128))])) : (q(), J("div", eh, "暂无用户创建的 skill"))]),
|
|
13307
|
+
n[9] ||= Y("div", { class: "skill-hint" }, [
|
|
13308
|
+
is(" 💡 创建/编辑的 skill 会自动加入 agent(下轮 system prompt 索引可见),agent 经 "),
|
|
13309
|
+
Y("code", null, "load_skill(name)"),
|
|
13310
|
+
is(" 按需加载全文; 持久化由独立 SkillStore 管理(默认 indexedDB,与 storage 选项分离),跨刷新自动恢复;可经 "),
|
|
13311
|
+
Y("code", null, "skillStorage.id"),
|
|
13312
|
+
is(" 跨页面复用。 ")
|
|
13313
|
+
], -1)
|
|
13314
|
+
])])) : X("", !0)]),
|
|
13315
|
+
_: 1
|
|
13316
|
+
})]));
|
|
13317
|
+
}
|
|
13318
|
+
}), [["__scopeId", "data-v-c6a22ea5"]]), oh = { class: "chat-header" }, sh = { class: "header-left" }, ch = { class: "header-title" }, lh = {
|
|
13197
13319
|
key: 0,
|
|
13198
13320
|
class: "status-dot pulse"
|
|
13199
|
-
},
|
|
13321
|
+
}, uh = { class: "header-actions" }, dh = {
|
|
13200
13322
|
key: 0,
|
|
13201
13323
|
class: "debug-badge"
|
|
13202
|
-
},
|
|
13324
|
+
}, fh = ["disabled"], ph = {
|
|
13203
13325
|
width: "16",
|
|
13204
13326
|
height: "16",
|
|
13205
13327
|
viewBox: "0 0 24 24",
|
|
13206
13328
|
fill: "none",
|
|
13207
13329
|
stroke: "currentColor",
|
|
13208
13330
|
"stroke-width": "2"
|
|
13209
|
-
},
|
|
13331
|
+
}, mh = {
|
|
13210
13332
|
key: 0,
|
|
13211
13333
|
d: "M18 15l-6-6-6 6"
|
|
13212
|
-
},
|
|
13334
|
+
}, hh = {
|
|
13213
13335
|
key: 1,
|
|
13214
13336
|
d: "M6 9l6 6 6-6"
|
|
13215
|
-
},
|
|
13337
|
+
}, gh = {
|
|
13216
13338
|
key: 0,
|
|
13217
13339
|
class: "empty-state"
|
|
13218
|
-
},
|
|
13340
|
+
}, _h = ["data-msg-idx"], vh = {
|
|
13219
13341
|
key: 0,
|
|
13220
13342
|
class: "message-avatar"
|
|
13221
|
-
},
|
|
13343
|
+
}, yh = { class: "message-content" }, bh = ["onClick"], xh = { class: "reasoning-toggle" }, Sh = {
|
|
13222
13344
|
key: 0,
|
|
13223
13345
|
class: "reasoning-body"
|
|
13224
|
-
},
|
|
13346
|
+
}, Ch = {
|
|
13225
13347
|
key: 1,
|
|
13226
13348
|
class: "steps-block"
|
|
13227
|
-
},
|
|
13349
|
+
}, wh = { class: "step-head" }, Th = { class: "step-icon" }, Eh = { class: "step-name" }, Dh = {
|
|
13228
13350
|
key: 0,
|
|
13229
13351
|
class: "step-count"
|
|
13230
|
-
},
|
|
13352
|
+
}, Oh = {
|
|
13231
13353
|
key: 1,
|
|
13232
13354
|
class: "step-status running"
|
|
13233
|
-
},
|
|
13355
|
+
}, kh = {
|
|
13234
13356
|
key: 0,
|
|
13235
13357
|
class: "step-children"
|
|
13236
|
-
},
|
|
13358
|
+
}, Ah = { class: "step-icon" }, jh = { class: "step-name" }, Mh = {
|
|
13237
13359
|
key: 0,
|
|
13238
13360
|
class: "step-status running"
|
|
13239
|
-
},
|
|
13361
|
+
}, Nh = {
|
|
13240
13362
|
key: 1,
|
|
13241
13363
|
class: "typing-text"
|
|
13242
|
-
},
|
|
13364
|
+
}, Ph = {
|
|
13243
13365
|
key: 2,
|
|
13244
13366
|
class: "stream-cursor"
|
|
13245
|
-
},
|
|
13367
|
+
}, Fh = { class: "message-time" }, Ih = {
|
|
13246
13368
|
key: 3,
|
|
13247
13369
|
class: "msg-actions"
|
|
13248
|
-
},
|
|
13370
|
+
}, Lh = ["title", "onClick"], Rh = {
|
|
13249
13371
|
key: 1,
|
|
13250
13372
|
class: "message-row assistant"
|
|
13251
|
-
},
|
|
13373
|
+
}, zh = {
|
|
13252
13374
|
key: 0,
|
|
13253
13375
|
class: "message-avatar"
|
|
13254
|
-
},
|
|
13376
|
+
}, Bh = { class: "message-content" }, Vh = { class: "message-bubble typing" }, Hh = {
|
|
13255
13377
|
key: 1,
|
|
13256
13378
|
class: "typing-text"
|
|
13257
|
-
},
|
|
13379
|
+
}, Uh = {
|
|
13258
13380
|
key: 2,
|
|
13259
13381
|
class: "error-bar"
|
|
13260
|
-
},
|
|
13382
|
+
}, Wh = { class: "error-text" }, Gh = {
|
|
13261
13383
|
key: 0,
|
|
13262
13384
|
class: "approval-bar"
|
|
13263
|
-
},
|
|
13385
|
+
}, Kh = {
|
|
13264
13386
|
key: 0,
|
|
13265
13387
|
class: "approval-question"
|
|
13266
|
-
},
|
|
13388
|
+
}, qh = {
|
|
13267
13389
|
key: 1,
|
|
13268
13390
|
class: "approval-context"
|
|
13269
|
-
},
|
|
13391
|
+
}, Jh = {
|
|
13270
13392
|
key: 2,
|
|
13271
13393
|
class: "approval-recommend"
|
|
13272
|
-
},
|
|
13394
|
+
}, Yh = { class: "approval-actions" }, Xh = ["onClick"], Zh = { class: "approval-head" }, Qh = { class: "approval-title" }, $h = {
|
|
13273
13395
|
key: 0,
|
|
13274
13396
|
class: "approval-args"
|
|
13275
|
-
},
|
|
13397
|
+
}, eg = { class: "approval-actions" }, tg = {
|
|
13276
13398
|
key: 1,
|
|
13277
13399
|
class: "conflict-bar"
|
|
13278
|
-
},
|
|
13400
|
+
}, ng = { class: "conflict-head" }, rg = { class: "conflict-title" }, ig = { class: "conflict-detail" }, ag = {
|
|
13279
13401
|
key: 0,
|
|
13280
13402
|
class: "conflict-diff"
|
|
13281
|
-
},
|
|
13403
|
+
}, og = { class: "conflict-diff-col" }, sg = { class: "conflict-diff-pre" }, cg = { class: "conflict-diff-col" }, lg = { class: "conflict-diff-pre" }, ug = { class: "conflict-actions" }, dg = { class: "chat-footer" }, fg = {
|
|
13282
13404
|
key: 0,
|
|
13283
13405
|
class: "cap-badge",
|
|
13284
13406
|
title: "能力概览(MCP / 工具数)"
|
|
13285
|
-
},
|
|
13407
|
+
}, pg = ["placeholder", "rows"], mg = ["disabled", "title"], hg = {
|
|
13286
13408
|
key: 0,
|
|
13287
13409
|
width: "16",
|
|
13288
13410
|
height: "16",
|
|
13289
13411
|
viewBox: "0 0 24 24",
|
|
13290
13412
|
fill: "currentColor"
|
|
13291
|
-
},
|
|
13413
|
+
}, gg = {
|
|
13292
13414
|
key: 1,
|
|
13293
13415
|
width: "18",
|
|
13294
13416
|
height: "18",
|
|
@@ -13296,7 +13418,7 @@ app.mount('#app');
|
|
|
13296
13418
|
fill: "none",
|
|
13297
13419
|
stroke: "currentColor",
|
|
13298
13420
|
"stroke-width": "2"
|
|
13299
|
-
},
|
|
13421
|
+
}, _g = /*#__PURE__*/ $d(/* @__PURE__ */ wi({
|
|
13300
13422
|
__name: "ChatDialog",
|
|
13301
13423
|
props: {
|
|
13302
13424
|
fetchResponse: {},
|
|
@@ -13322,7 +13444,14 @@ app.mount('#app');
|
|
|
13322
13444
|
onResolveConflict: {},
|
|
13323
13445
|
infoTick: {},
|
|
13324
13446
|
getSkillContent: {},
|
|
13325
|
-
|
|
13447
|
+
onAddSkill: {},
|
|
13448
|
+
onRemoveSkill: {},
|
|
13449
|
+
getUserSkillNames: {},
|
|
13450
|
+
onGetSkill: {},
|
|
13451
|
+
drawer: { type: Boolean },
|
|
13452
|
+
drawerWidth: {},
|
|
13453
|
+
drawerHidden: { type: Boolean },
|
|
13454
|
+
inputRows: { default: 2 }
|
|
13326
13455
|
},
|
|
13327
13456
|
emits: ["close"],
|
|
13328
13457
|
setup(e, { emit: t }) {
|
|
@@ -13374,14 +13503,14 @@ app.mount('#app');
|
|
|
13374
13503
|
function C() {
|
|
13375
13504
|
n.onUndo?.() && (i.error = null);
|
|
13376
13505
|
}
|
|
13377
|
-
let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U({}),
|
|
13378
|
-
function j(e) {
|
|
13379
|
-
D.value[e] = !D.value[e];
|
|
13380
|
-
}
|
|
13506
|
+
let w = /* @__PURE__ */ U(""), T = /* @__PURE__ */ U(!0), E = /* @__PURE__ */ U(!1), D = /* @__PURE__ */ U(!1), O = /* @__PURE__ */ U({}), k = zs(() => i.messages.length > 0), A = zs(() => i.messages.some((e) => e.role === "user")), j = zs(() => (n.debugLogs?.length ?? 0) > 0);
|
|
13381
13507
|
function M(e) {
|
|
13382
|
-
|
|
13508
|
+
O.value[e] = !O.value[e];
|
|
13383
13509
|
}
|
|
13384
13510
|
function N(e) {
|
|
13511
|
+
return e.status === "running" ? "⏳" : e.status === "error" ? "❌" : "✅";
|
|
13512
|
+
}
|
|
13513
|
+
function P(e) {
|
|
13385
13514
|
let t = [];
|
|
13386
13515
|
for (let n of e) {
|
|
13387
13516
|
let e = t.length ? t[t.length - 1] : null;
|
|
@@ -13400,56 +13529,66 @@ app.mount('#app');
|
|
|
13400
13529
|
children: e.children
|
|
13401
13530
|
}));
|
|
13402
13531
|
}
|
|
13403
|
-
function
|
|
13532
|
+
function F(e) {
|
|
13404
13533
|
return e === "running" ? "⏳" : e === "error" ? "❌" : "✅";
|
|
13405
13534
|
}
|
|
13406
|
-
function
|
|
13535
|
+
function I(e) {
|
|
13407
13536
|
let t = i.messages[e];
|
|
13408
13537
|
return !!t && t.role === "assistant" && i.loading && e === i.messages.length - 1 && !t.content && !t.reasoning;
|
|
13409
13538
|
}
|
|
13410
|
-
function
|
|
13539
|
+
function L() {
|
|
13411
13540
|
w.value.trim() && (s(w.value), w.value = "");
|
|
13412
13541
|
}
|
|
13413
|
-
function L(e) {
|
|
13414
|
-
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), I());
|
|
13415
|
-
}
|
|
13416
13542
|
function R(e) {
|
|
13543
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), L());
|
|
13544
|
+
}
|
|
13545
|
+
function ee(e) {
|
|
13417
13546
|
return new Date(e).toLocaleTimeString("zh-CN", {
|
|
13418
13547
|
hour: "2-digit",
|
|
13419
13548
|
minute: "2-digit"
|
|
13420
13549
|
});
|
|
13421
13550
|
}
|
|
13422
|
-
let
|
|
13551
|
+
let te = zs(() => {
|
|
13423
13552
|
let e = n.getInfo?.();
|
|
13424
13553
|
return {
|
|
13425
13554
|
mcp: e?.mcp?.servers?.length ?? 0,
|
|
13426
13555
|
tools: e?.tools?.length ?? 0
|
|
13427
13556
|
};
|
|
13428
13557
|
});
|
|
13429
|
-
function
|
|
13558
|
+
function ne(e) {
|
|
13430
13559
|
Sl(e).then((e) => {
|
|
13431
|
-
e && (
|
|
13560
|
+
e && (re.value = !0, setTimeout(() => re.value = !1, 1500));
|
|
13432
13561
|
});
|
|
13433
13562
|
}
|
|
13434
|
-
let
|
|
13563
|
+
let re = /* @__PURE__ */ U(!1), ie = zs(() => {
|
|
13564
|
+
if (!n.drawer || n.drawerWidth == null) return null;
|
|
13565
|
+
let e = n.drawerWidth;
|
|
13566
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
13567
|
+
});
|
|
13435
13568
|
return (t, s) => (q(), J(K, null, [e.drawer ? (q(), J("div", {
|
|
13436
13569
|
key: 0,
|
|
13437
13570
|
class: "chat-mask",
|
|
13438
13571
|
onClick: s[0] ||= (e) => r("close")
|
|
13439
|
-
})) : X("", !0), Y("div", {
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13444
|
-
|
|
13445
|
-
|
|
13446
|
-
|
|
13447
|
-
|
|
13572
|
+
})) : X("", !0), Y("div", {
|
|
13573
|
+
class: we(["chat-dialog", {
|
|
13574
|
+
collapsed: !T.value && !e.drawer,
|
|
13575
|
+
drawer: e.drawer
|
|
13576
|
+
}]),
|
|
13577
|
+
style: ye(ie.value ? {
|
|
13578
|
+
width: ie.value,
|
|
13579
|
+
maxWidth: ie.value
|
|
13580
|
+
} : null)
|
|
13581
|
+
}, [
|
|
13582
|
+
Y("div", oh, [Y("div", sh, [
|
|
13583
|
+
s[23] ||= Y("span", { class: "header-icon" }, "🤖", -1),
|
|
13584
|
+
Y("span", ch, B(e.title), 1),
|
|
13585
|
+
W(i).loading ? (q(), J("span", lh)) : X("", !0)
|
|
13586
|
+
]), Y("div", uh, [
|
|
13448
13587
|
Y("button", {
|
|
13449
|
-
class:
|
|
13588
|
+
class: we(["action-btn debug-btn", { active: E.value }]),
|
|
13450
13589
|
title: "日志 / 执行流程 / Agent 信息",
|
|
13451
13590
|
onClick: s[1] ||= (e) => E.value = !0
|
|
13452
|
-
}, [s[
|
|
13591
|
+
}, [s[24] ||= Y("svg", {
|
|
13453
13592
|
width: "16",
|
|
13454
13593
|
height: "16",
|
|
13455
13594
|
viewBox: "0 0 24 24",
|
|
@@ -13460,26 +13599,39 @@ app.mount('#app');
|
|
|
13460
13599
|
Y("path", { d: "M9 2v8l-3 3v2h12v-2l-3-3V2" }),
|
|
13461
13600
|
Y("path", { d: "M9 2h6" }),
|
|
13462
13601
|
Y("path", { d: "M9 18h6" })
|
|
13463
|
-
], -1),
|
|
13602
|
+
], -1), j.value ? (q(), J("span", dh, B(e.debugLogs?.length), 1)) : X("", !0)], 2),
|
|
13603
|
+
n.onAddSkill ? (q(), J("button", {
|
|
13604
|
+
key: 0,
|
|
13605
|
+
class: we(["action-btn", { active: D.value }]),
|
|
13606
|
+
title: "创建 / 管理自定义 Skill",
|
|
13607
|
+
onClick: s[2] ||= (e) => D.value = !0
|
|
13608
|
+
}, [...s[25] ||= [Y("svg", {
|
|
13609
|
+
width: "16",
|
|
13610
|
+
height: "16",
|
|
13611
|
+
viewBox: "0 0 24 24",
|
|
13612
|
+
fill: "none",
|
|
13613
|
+
stroke: "currentColor",
|
|
13614
|
+
"stroke-width": "2"
|
|
13615
|
+
}, [Y("path", { d: "M12 2l2.4 7.4H22l-6 4.4 2.3 7.2L12 16.8 5.7 21l2.3-7.2-6-4.4h7.6z" })], -1)]], 2)) : X("", !0),
|
|
13464
13616
|
Y("button", {
|
|
13465
13617
|
class: "action-btn",
|
|
13466
13618
|
title: "清空对话",
|
|
13467
|
-
onClick: s[
|
|
13468
|
-
disabled: !
|
|
13469
|
-
}, [...s[
|
|
13619
|
+
onClick: s[3] ||= (...e) => W(c) && W(c)(...e),
|
|
13620
|
+
disabled: !k.value
|
|
13621
|
+
}, [...s[26] ||= [Y("svg", {
|
|
13470
13622
|
width: "16",
|
|
13471
13623
|
height: "16",
|
|
13472
13624
|
viewBox: "0 0 24 24",
|
|
13473
13625
|
fill: "none",
|
|
13474
13626
|
stroke: "currentColor",
|
|
13475
13627
|
"stroke-width": "2"
|
|
13476
|
-
}, [Y("polyline", { points: "3 6 5 6 21 6" }), Y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })], -1)]], 8,
|
|
13628
|
+
}, [Y("polyline", { points: "3 6 5 6 21 6" }), Y("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })], -1)]], 8, fh),
|
|
13477
13629
|
e.drawer ? (q(), J("button", {
|
|
13478
|
-
key:
|
|
13630
|
+
key: 1,
|
|
13479
13631
|
class: "action-btn",
|
|
13480
13632
|
title: "关闭",
|
|
13481
|
-
onClick: s[
|
|
13482
|
-
}, [...s[
|
|
13633
|
+
onClick: s[4] ||= (e) => r("close")
|
|
13634
|
+
}, [...s[27] ||= [Y("svg", {
|
|
13483
13635
|
width: "16",
|
|
13484
13636
|
height: "16",
|
|
13485
13637
|
viewBox: "0 0 24 24",
|
|
@@ -13487,83 +13639,83 @@ app.mount('#app');
|
|
|
13487
13639
|
stroke: "currentColor",
|
|
13488
13640
|
"stroke-width": "2"
|
|
13489
13641
|
}, [Y("path", { d: "M18 6L6 18M6 6l12 12" })], -1)]])) : (q(), J("button", {
|
|
13490
|
-
key:
|
|
13642
|
+
key: 2,
|
|
13491
13643
|
class: "action-btn",
|
|
13492
|
-
onClick: s[
|
|
13493
|
-
}, [(q(), J("svg",
|
|
13644
|
+
onClick: s[5] ||= (e) => T.value = !T.value
|
|
13645
|
+
}, [(q(), J("svg", ph, [T.value ? (q(), J("path", mh)) : (q(), J("path", hh))]))]))
|
|
13494
13646
|
])]),
|
|
13495
13647
|
$o(rc, { name: "cs-slide" }, {
|
|
13496
13648
|
default: Lr(() => [zr(Y("div", {
|
|
13497
13649
|
class: "chat-body",
|
|
13498
13650
|
ref_key: "scrollContainer",
|
|
13499
13651
|
ref: a,
|
|
13500
|
-
onScroll: s[
|
|
13501
|
-
onWheel: s[
|
|
13652
|
+
onScroll: s[8] ||= (...e) => W(p) && W(p)(...e),
|
|
13653
|
+
onWheel: s[9] ||= (...e) => W(m) && W(m)(...e)
|
|
13502
13654
|
}, [
|
|
13503
|
-
|
|
13655
|
+
k.value ? X("", !0) : (q(), J("div", gh, [...s[28] ||= [Y("div", { class: "empty-icon" }, "💬", -1), Y("p", null, "有什么可以帮你的?", -1)]])),
|
|
13504
13656
|
(q(!0), J(K, null, Xi(W(i).messages, (t, n) => (q(), J("div", {
|
|
13505
13657
|
key: n,
|
|
13506
|
-
class:
|
|
13658
|
+
class: we(["message-row", t.role]),
|
|
13507
13659
|
"data-msg-idx": n
|
|
13508
|
-
}, [e.showAvatar ? (q(), J("div",
|
|
13660
|
+
}, [e.showAvatar ? (q(), J("div", vh, B(t.role === "user" ? "👤" : "🤖"), 1)) : X("", !0), Y("div", yh, [
|
|
13509
13661
|
t.role === "assistant" && t.reasoning ? (q(), J("div", {
|
|
13510
13662
|
key: 0,
|
|
13511
|
-
class:
|
|
13663
|
+
class: we(["reasoning-block", { expanded: O.value[n] }])
|
|
13512
13664
|
}, [Y("div", {
|
|
13513
13665
|
class: "reasoning-header",
|
|
13514
|
-
onClick: (e) =>
|
|
13666
|
+
onClick: (e) => M(n)
|
|
13515
13667
|
}, [
|
|
13516
|
-
s[
|
|
13517
|
-
s[
|
|
13518
|
-
Y("span",
|
|
13519
|
-
], 8,
|
|
13520
|
-
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div",
|
|
13668
|
+
s[29] ||= Y("span", { class: "reasoning-icon" }, "🧠", -1),
|
|
13669
|
+
s[30] ||= Y("span", { class: "reasoning-title" }, "思考过程", -1),
|
|
13670
|
+
Y("span", xh, B(O.value[n] ? "▾" : "▸"), 1)
|
|
13671
|
+
], 8, bh), O.value[n] ? (q(), J("div", Sh, B(t.reasoning), 1)) : X("", !0)], 2)) : X("", !0),
|
|
13672
|
+
t.role === "assistant" && t.steps && t.steps.length ? (q(), J("div", Ch, [(q(!0), J(K, null, Xi(P(t.steps), (e, t) => (q(), J("div", {
|
|
13521
13673
|
key: t,
|
|
13522
13674
|
class: "step-item"
|
|
13523
|
-
}, [Y("div",
|
|
13524
|
-
Y("span",
|
|
13525
|
-
Y("span",
|
|
13526
|
-
e.count > 1 ? (q(), J("span",
|
|
13527
|
-
e.status === "running" ? (q(), J("span",
|
|
13528
|
-
]), e.children && e.children.length ? (q(), J("div",
|
|
13675
|
+
}, [Y("div", wh, [
|
|
13676
|
+
Y("span", Th, B(F(e.status)), 1),
|
|
13677
|
+
Y("span", Eh, B(e.name), 1),
|
|
13678
|
+
e.count > 1 ? (q(), J("span", Dh, "×" + B(e.count), 1)) : X("", !0),
|
|
13679
|
+
e.status === "running" ? (q(), J("span", Oh, "执行中…")) : X("", !0)
|
|
13680
|
+
]), e.children && e.children.length ? (q(), J("div", kh, [s[31] ||= Y("div", { class: "step-children-label" }, "🧬 子 agent 进度", -1), (q(!0), J(K, null, Xi(e.children, (e, t) => (q(), J("div", {
|
|
13529
13681
|
key: t,
|
|
13530
13682
|
class: "step-child"
|
|
13531
13683
|
}, [
|
|
13532
|
-
Y("span",
|
|
13533
|
-
Y("span",
|
|
13534
|
-
e.status === "running" ? (q(), J("span",
|
|
13684
|
+
Y("span", Ah, B(N(e)), 1),
|
|
13685
|
+
Y("span", jh, B(e.name), 1),
|
|
13686
|
+
e.status === "running" ? (q(), J("span", Mh, "…")) : X("", !0)
|
|
13535
13687
|
]))), 128))])) : X("", !0)]))), 128))])) : X("", !0),
|
|
13536
|
-
Y("div", { class:
|
|
13537
|
-
s[
|
|
13538
|
-
s[
|
|
13539
|
-
s[
|
|
13540
|
-
], 64)) : (q(), J("span",
|
|
13688
|
+
Y("div", { class: we(["message-bubble", { typing: I(n) }]) }, [I(n) ? (q(), J(K, { key: 0 }, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13689
|
+
s[32] ||= Y("span", { class: "dot" }, null, -1),
|
|
13690
|
+
s[33] ||= Y("span", { class: "dot" }, null, -1),
|
|
13691
|
+
s[34] ||= Y("span", { class: "dot" }, null, -1)
|
|
13692
|
+
], 64)) : (q(), J("span", Nh, "思考中…"))], 64)) : (q(), J(K, { key: 1 }, [t.role === "assistant" ? (q(), Ko(nf, {
|
|
13541
13693
|
key: 0,
|
|
13542
13694
|
content: t.content
|
|
13543
13695
|
}, null, 8, ["content"])) : (q(), J(K, { key: 1 }, [is(B(t.content), 1)], 64))], 64))], 2),
|
|
13544
|
-
t.role === "assistant" && W(i).loading && n === W(i).messages.length - 1 && t.content ? (q(), J("span",
|
|
13545
|
-
Y("div",
|
|
13546
|
-
t.role === "assistant" && t.content && !W(i).loading && n === W(i).messages.length - 1 ? (q(), J("div",
|
|
13696
|
+
t.role === "assistant" && W(i).loading && n === W(i).messages.length - 1 && t.content ? (q(), J("span", Ph)) : X("", !0),
|
|
13697
|
+
Y("div", Fh, B(ee(t.timestamp)), 1),
|
|
13698
|
+
t.role === "assistant" && t.content && !W(i).loading && n === W(i).messages.length - 1 ? (q(), J("div", Ih, [Y("button", {
|
|
13547
13699
|
class: "msg-action-btn",
|
|
13548
|
-
title:
|
|
13549
|
-
onClick: (e) =>
|
|
13550
|
-
}, B(
|
|
13700
|
+
title: re.value ? "已复制" : "复制",
|
|
13701
|
+
onClick: (e) => ne(t.content)
|
|
13702
|
+
}, B(re.value ? "✓ 已复制" : "📋 复制"), 9, Lh), Y("button", {
|
|
13551
13703
|
class: "msg-action-btn",
|
|
13552
13704
|
title: "重新生成",
|
|
13553
|
-
onClick: s[
|
|
13705
|
+
onClick: s[6] ||= (...e) => W(d) && W(d)(...e)
|
|
13554
13706
|
}, "🔄 重新生成")])) : X("", !0)
|
|
13555
|
-
])], 10,
|
|
13556
|
-
W(i).loading && W(i).messages[W(i).messages.length - 1]?.role !== "assistant" ? (q(), J("div",
|
|
13557
|
-
s[
|
|
13558
|
-
s[
|
|
13559
|
-
s[
|
|
13560
|
-
], 64)) : (q(), J("span",
|
|
13561
|
-
W(i).error ? (q(), J("div",
|
|
13562
|
-
Y("span",
|
|
13563
|
-
|
|
13707
|
+
])], 10, _h))), 128)),
|
|
13708
|
+
W(i).loading && W(i).messages[W(i).messages.length - 1]?.role !== "assistant" ? (q(), J("div", Rh, [e.showAvatar ? (q(), J("div", zh, "🤖")) : X("", !0), Y("div", Bh, [Y("div", Vh, [e.showTyping ? (q(), J(K, { key: 0 }, [
|
|
13709
|
+
s[35] ||= Y("span", { class: "dot" }, null, -1),
|
|
13710
|
+
s[36] ||= Y("span", { class: "dot" }, null, -1),
|
|
13711
|
+
s[37] ||= Y("span", { class: "dot" }, null, -1)
|
|
13712
|
+
], 64)) : (q(), J("span", Hh, "思考中…"))])])])) : X("", !0),
|
|
13713
|
+
W(i).error ? (q(), J("div", Uh, [
|
|
13714
|
+
Y("span", Wh, B(W(i).error), 1),
|
|
13715
|
+
A.value ? (q(), J("button", {
|
|
13564
13716
|
key: 0,
|
|
13565
13717
|
class: "retry-btn",
|
|
13566
|
-
onClick: s[
|
|
13718
|
+
onClick: s[7] ||= (...e) => W(u) && W(u)(...e)
|
|
13567
13719
|
}, "重试")) : X("", !0),
|
|
13568
13720
|
S.value ? (q(), J("button", {
|
|
13569
13721
|
key: 1,
|
|
@@ -13575,75 +13727,75 @@ app.mount('#app');
|
|
|
13575
13727
|
], 544), [[xc, T.value]])]),
|
|
13576
13728
|
_: 1
|
|
13577
13729
|
}),
|
|
13578
|
-
W(o) ? (q(), J("div",
|
|
13579
|
-
s[
|
|
13580
|
-
W(o).args?.question ? (q(), J("div",
|
|
13581
|
-
W(o).args?.context ? (q(), J("div",
|
|
13582
|
-
W(o).args?.recommendation ? (q(), J("div",
|
|
13583
|
-
Y("div",
|
|
13730
|
+
W(o) ? (q(), J("div", Gh, [y.value ? (q(), J(K, { key: 0 }, [
|
|
13731
|
+
s[38] ||= Y("div", { class: "approval-head" }, [Y("span", { class: "approval-icon" }, "❓"), Y("span", { class: "approval-title" }, "AI 需要你确认")], -1),
|
|
13732
|
+
W(o).args?.question ? (q(), J("div", Kh, B(W(o).args.question), 1)) : X("", !0),
|
|
13733
|
+
W(o).args?.context ? (q(), J("div", qh, B(W(o).args.context), 1)) : X("", !0),
|
|
13734
|
+
W(o).args?.recommendation ? (q(), J("div", Jh, "💡 推荐:" + B(W(o).args.recommendation), 1)) : X("", !0),
|
|
13735
|
+
Y("div", Yh, [Y("button", {
|
|
13584
13736
|
class: "approval-deny",
|
|
13585
|
-
onClick: s[
|
|
13737
|
+
onClick: s[10] ||= (e) => W(f)(!1)
|
|
13586
13738
|
}, "拒绝"), b.value.length ? (q(!0), J(K, { key: 0 }, Xi(b.value, (e) => (q(), J("button", {
|
|
13587
13739
|
key: e,
|
|
13588
13740
|
class: "approval-opt",
|
|
13589
13741
|
onClick: (t) => W(f)(e)
|
|
13590
|
-
}, B(e), 9,
|
|
13742
|
+
}, B(e), 9, Xh))), 128)) : (q(), J("button", {
|
|
13591
13743
|
key: 1,
|
|
13592
13744
|
class: "approval-allow",
|
|
13593
|
-
onClick: s[
|
|
13745
|
+
onClick: s[11] ||= (e) => W(f)(!0)
|
|
13594
13746
|
}, "允许"))])
|
|
13595
13747
|
], 64)) : (q(), J(K, { key: 1 }, [
|
|
13596
|
-
Y("div",
|
|
13597
|
-
s[
|
|
13598
|
-
Y("span",
|
|
13748
|
+
Y("div", Zh, [
|
|
13749
|
+
s[40] ||= Y("span", { class: "approval-icon" }, "✋", -1),
|
|
13750
|
+
Y("span", Qh, [s[39] ||= is("需确认工具调用:", -1), Y("code", null, B(W(o).toolName), 1)]),
|
|
13599
13751
|
h.value ? (q(), J("button", {
|
|
13600
13752
|
key: 0,
|
|
13601
13753
|
class: "approval-toggle",
|
|
13602
|
-
onClick: s[
|
|
13754
|
+
onClick: s[12] ||= (e) => x.value = !x.value
|
|
13603
13755
|
}, B(x.value ? "收起参数" : "查看参数") + B(x.value ? " ▴" : " ▾"), 1)) : X("", !0)
|
|
13604
13756
|
]),
|
|
13605
|
-
h.value && x.value ? (q(), J("pre",
|
|
13606
|
-
Y("div",
|
|
13757
|
+
h.value && x.value ? (q(), J("pre", $h, B(h.value), 1)) : X("", !0),
|
|
13758
|
+
Y("div", eg, [Y("button", {
|
|
13607
13759
|
class: "approval-deny",
|
|
13608
|
-
onClick: s[
|
|
13760
|
+
onClick: s[13] ||= (e) => W(f)(!1)
|
|
13609
13761
|
}, "拒绝"), Y("button", {
|
|
13610
13762
|
class: "approval-allow",
|
|
13611
|
-
onClick: s[
|
|
13763
|
+
onClick: s[14] ||= (e) => W(f)(!0)
|
|
13612
13764
|
}, "允许")])
|
|
13613
13765
|
], 64))])) : X("", !0),
|
|
13614
|
-
n.pendingConflict ? (q(), J("div",
|
|
13615
|
-
Y("div",
|
|
13616
|
-
s[
|
|
13766
|
+
n.pendingConflict ? (q(), J("div", tg, [
|
|
13767
|
+
Y("div", ng, [s[43] ||= Y("span", { class: "conflict-icon" }, "⚠️", -1), Y("span", rg, [
|
|
13768
|
+
s[41] ||= is("写入冲突:", -1),
|
|
13617
13769
|
Y("code", null, B(n.pendingConflict.path), 1),
|
|
13618
|
-
s[
|
|
13770
|
+
s[42] ||= is(" 已被外部修改", -1)
|
|
13619
13771
|
])]),
|
|
13620
|
-
Y("div",
|
|
13772
|
+
Y("div", ig, " AI 基于「读取时的旧值」准备" + B(n.pendingConflict.op === "delete" ? "删除" : "写入") + ",但该属性在你读取之后被外部代码/其他 agent/手动改过。 ", 1),
|
|
13621
13773
|
Y("button", {
|
|
13622
13774
|
class: "conflict-toggle",
|
|
13623
|
-
onClick: s[
|
|
13775
|
+
onClick: s[15] ||= (e) => v.value = !v.value
|
|
13624
13776
|
}, B(v.value ? "收起对比" : "查看值对比") + B(v.value ? " ▴" : " ▾"), 1),
|
|
13625
|
-
v.value ? (q(), J("div",
|
|
13626
|
-
Y("div",
|
|
13777
|
+
v.value ? (q(), J("div", ag, [Y("div", og, [s[44] ||= Y("div", { class: "conflict-diff-label" }, "AI 想写的值", -1), Y("pre", sg, B(g.value || "(delete 操作无值)"), 1)]), Y("div", cg, [s[45] ||= Y("div", { class: "conflict-diff-label" }, "外部改后的当前值", -1), Y("pre", lg, B(_.value), 1)])])) : X("", !0),
|
|
13778
|
+
Y("div", ug, [
|
|
13627
13779
|
Y("button", {
|
|
13628
13780
|
class: "conflict-keep",
|
|
13629
|
-
onClick: s[
|
|
13781
|
+
onClick: s[16] ||= (e) => n.onResolveConflict?.("keep_external"),
|
|
13630
13782
|
title: "不写入,保留外部修改后的值,AI 重新读取再改"
|
|
13631
13783
|
}, "保留外部"),
|
|
13632
13784
|
Y("button", {
|
|
13633
13785
|
class: "conflict-overwrite",
|
|
13634
|
-
onClick: s[
|
|
13786
|
+
onClick: s[17] ||= (e) => n.onResolveConflict?.("overwrite"),
|
|
13635
13787
|
title: "用 AI 的值覆盖外部修改"
|
|
13636
13788
|
}, "强制覆盖"),
|
|
13637
13789
|
Y("button", {
|
|
13638
13790
|
class: "conflict-restore",
|
|
13639
|
-
onClick: s[
|
|
13791
|
+
onClick: s[18] ||= (e) => n.onResolveConflict?.("restore"),
|
|
13640
13792
|
title: "回退到最近一次历史快照(agent 之前操作的检查点),撤销外部修改 + AI 不写入"
|
|
13641
13793
|
}, "回退")
|
|
13642
13794
|
])
|
|
13643
13795
|
])) : X("", !0),
|
|
13644
13796
|
$o(rc, { name: "cs-slide" }, {
|
|
13645
|
-
default: Lr(() => [zr(Y("div",
|
|
13646
|
-
n.getInfo ? (q(), J("span",
|
|
13797
|
+
default: Lr(() => [zr(Y("div", dg, [
|
|
13798
|
+
n.getInfo ? (q(), J("span", fg, " 🔌" + B(te.value.mcp) + " · 🔧" + B(te.value.tools), 1)) : X("", !0),
|
|
13647
13799
|
S.value ? (q(), J("button", {
|
|
13648
13800
|
key: 1,
|
|
13649
13801
|
class: "undo-foot-btn",
|
|
@@ -13651,35 +13803,35 @@ app.mount('#app');
|
|
|
13651
13803
|
onClick: C
|
|
13652
13804
|
}, "↩ 回退")) : X("", !0),
|
|
13653
13805
|
zr(Y("textarea", {
|
|
13654
|
-
"onUpdate:modelValue": s[
|
|
13806
|
+
"onUpdate:modelValue": s[19] ||= (e) => w.value = e,
|
|
13655
13807
|
class: "chat-input",
|
|
13656
13808
|
placeholder: e.placeholder,
|
|
13657
|
-
rows:
|
|
13658
|
-
onKeydown:
|
|
13659
|
-
}, null, 40,
|
|
13809
|
+
rows: n.inputRows,
|
|
13810
|
+
onKeydown: R
|
|
13811
|
+
}, null, 40, pg), [[rl, w.value]]),
|
|
13660
13812
|
Y("button", {
|
|
13661
|
-
class:
|
|
13813
|
+
class: we(["send-btn", { "stop-btn": W(i).loading }]),
|
|
13662
13814
|
disabled: !W(i).loading && !w.value.trim(),
|
|
13663
13815
|
title: W(i).loading ? "停止生成" : "发送",
|
|
13664
|
-
onClick: s[
|
|
13665
|
-
}, [W(i).loading ? (q(), J("svg",
|
|
13816
|
+
onClick: s[20] ||= (e) => W(i).loading ? W(l)() : L()
|
|
13817
|
+
}, [W(i).loading ? (q(), J("svg", hg, [...s[46] ||= [Y("rect", {
|
|
13666
13818
|
x: "6",
|
|
13667
13819
|
y: "6",
|
|
13668
13820
|
width: "12",
|
|
13669
13821
|
height: "12",
|
|
13670
13822
|
rx: "2"
|
|
13671
|
-
}, null, -1)]])) : (q(), J("svg",
|
|
13823
|
+
}, null, -1)]])) : (q(), J("svg", gg, [...s[47] ||= [Y("line", {
|
|
13672
13824
|
x1: "22",
|
|
13673
13825
|
y1: "2",
|
|
13674
13826
|
x2: "11",
|
|
13675
13827
|
y2: "13"
|
|
13676
|
-
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10,
|
|
13828
|
+
}, null, -1), Y("polygon", { points: "22 2 15 22 11 13 2 9 22 2" }, null, -1)]]))], 10, mg)
|
|
13677
13829
|
], 512), [[xc, T.value]])]),
|
|
13678
13830
|
_: 1
|
|
13679
13831
|
}),
|
|
13680
13832
|
$o(Hm, {
|
|
13681
13833
|
visible: E.value,
|
|
13682
|
-
"onUpdate:visible": s[
|
|
13834
|
+
"onUpdate:visible": s[21] ||= (e) => E.value = e,
|
|
13683
13835
|
logs: e.debugLogs,
|
|
13684
13836
|
"get-info": n.getInfo,
|
|
13685
13837
|
"info-tick": n.infoTick,
|
|
@@ -13690,23 +13842,37 @@ app.mount('#app');
|
|
|
13690
13842
|
"get-info",
|
|
13691
13843
|
"info-tick",
|
|
13692
13844
|
"get-skill-content"
|
|
13845
|
+
]),
|
|
13846
|
+
$o(ah, {
|
|
13847
|
+
visible: D.value,
|
|
13848
|
+
"on-add-skill": n.onAddSkill,
|
|
13849
|
+
"on-remove-skill": n.onRemoveSkill,
|
|
13850
|
+
"get-user-skill-names": n.getUserSkillNames,
|
|
13851
|
+
"on-get-skill": n.onGetSkill,
|
|
13852
|
+
onClose: s[22] ||= (e) => D.value = !1
|
|
13853
|
+
}, null, 8, [
|
|
13854
|
+
"visible",
|
|
13855
|
+
"on-add-skill",
|
|
13856
|
+
"on-remove-skill",
|
|
13857
|
+
"get-user-skill-names",
|
|
13858
|
+
"on-get-skill"
|
|
13693
13859
|
])
|
|
13694
|
-
],
|
|
13860
|
+
], 6)], 64));
|
|
13695
13861
|
}
|
|
13696
|
-
}), [["__scopeId", "data-v-
|
|
13697
|
-
function
|
|
13862
|
+
}), [["__scopeId", "data-v-d3eca61c"]]);
|
|
13863
|
+
function vg(e) {
|
|
13698
13864
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
13699
13865
|
}
|
|
13700
|
-
function
|
|
13866
|
+
function yg(e) {
|
|
13701
13867
|
let t = 5381;
|
|
13702
13868
|
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
13703
13869
|
return (t >>> 0).toString(36);
|
|
13704
13870
|
}
|
|
13705
|
-
function
|
|
13871
|
+
function bg(e, t) {
|
|
13706
13872
|
let n = t.threshold ?? 6e3;
|
|
13707
13873
|
if (e.length <= n) return e;
|
|
13708
13874
|
if (t.vfsAvailable && t.files) {
|
|
13709
|
-
let n = `large_results/${t.toolName}-${
|
|
13875
|
+
let n = `large_results/${t.toolName}-${yg(e)}.txt`, r = vg(n);
|
|
13710
13876
|
return t.files[r] = {
|
|
13711
13877
|
content: e,
|
|
13712
13878
|
updatedAt: Date.now()
|
|
@@ -13721,7 +13887,7 @@ function rg(e, t) {
|
|
|
13721
13887
|
}
|
|
13722
13888
|
//#endregion
|
|
13723
13889
|
//#region src/core/utils/pool.ts
|
|
13724
|
-
async function
|
|
13890
|
+
async function xg(e, t, n, r) {
|
|
13725
13891
|
let i = Array(e.length), a = Math.max(1, t);
|
|
13726
13892
|
if (a === 1) {
|
|
13727
13893
|
for (let t = 0; t < e.length && !r?.aborted; t++) i[t] = await n(e[t], t);
|
|
@@ -13738,7 +13904,7 @@ async function ig(e, t, n, r) {
|
|
|
13738
13904
|
}
|
|
13739
13905
|
//#endregion
|
|
13740
13906
|
//#region src/core/utils/modelCaps.ts
|
|
13741
|
-
var
|
|
13907
|
+
var Sg = [
|
|
13742
13908
|
{
|
|
13743
13909
|
pattern: /deepseek-v4/i,
|
|
13744
13910
|
caps: {
|
|
@@ -13900,34 +14066,34 @@ var ag = [
|
|
|
13900
14066
|
maxOutputTokens: 4096
|
|
13901
14067
|
}
|
|
13902
14068
|
}
|
|
13903
|
-
],
|
|
14069
|
+
], Cg = {
|
|
13904
14070
|
contextWindow: 32768,
|
|
13905
14071
|
maxOutputTokens: 4096
|
|
13906
14072
|
};
|
|
13907
|
-
function
|
|
14073
|
+
function wg(e = {}) {
|
|
13908
14074
|
let t = (() => {
|
|
13909
|
-
if (e.model) return
|
|
14075
|
+
if (e.model) return Sg.find((t) => t.pattern.test(e.model))?.caps;
|
|
13910
14076
|
})();
|
|
13911
14077
|
return {
|
|
13912
|
-
contextWindow: e.contextWindow ?? t?.contextWindow ??
|
|
13913
|
-
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ??
|
|
14078
|
+
contextWindow: e.contextWindow ?? t?.contextWindow ?? Cg.contextWindow,
|
|
14079
|
+
maxOutputTokens: e.maxOutputTokens ?? t?.maxOutputTokens ?? Cg.maxOutputTokens
|
|
13914
14080
|
};
|
|
13915
14081
|
}
|
|
13916
|
-
function
|
|
14082
|
+
function Tg(e) {
|
|
13917
14083
|
if (!e) return 0;
|
|
13918
14084
|
let t = (e.match(/[\u4e00-\u9fff]/g) || []).length, n = e.length - t;
|
|
13919
14085
|
return Math.ceil(t * 1.5 + n * .25);
|
|
13920
14086
|
}
|
|
13921
|
-
function
|
|
14087
|
+
function Eg(e) {
|
|
13922
14088
|
return Math.max(2e3, Math.min(2e4, Math.round(e * .035)));
|
|
13923
14089
|
}
|
|
13924
|
-
function
|
|
13925
|
-
let t =
|
|
14090
|
+
function Dg(e) {
|
|
14091
|
+
let t = Eg(e);
|
|
13926
14092
|
return Math.min(2e5, Math.max(t, Math.round(e * .7)));
|
|
13927
14093
|
}
|
|
13928
14094
|
//#endregion
|
|
13929
14095
|
//#region src/core/harness/state.ts
|
|
13930
|
-
function
|
|
14096
|
+
function Og() {
|
|
13931
14097
|
return {
|
|
13932
14098
|
messages: [],
|
|
13933
14099
|
todos: [],
|
|
@@ -13940,42 +14106,42 @@ function dg() {
|
|
|
13940
14106
|
}
|
|
13941
14107
|
//#endregion
|
|
13942
14108
|
//#region src/core/harness/middleware.ts
|
|
13943
|
-
function
|
|
14109
|
+
function kg(e, t) {
|
|
13944
14110
|
return t ? {
|
|
13945
14111
|
...e,
|
|
13946
14112
|
...t
|
|
13947
14113
|
} : e;
|
|
13948
14114
|
}
|
|
13949
|
-
async function
|
|
14115
|
+
async function Ag(e, t) {
|
|
13950
14116
|
let n = t;
|
|
13951
|
-
for (let t of e) t.beforeAgent && (n =
|
|
14117
|
+
for (let t of e) t.beforeAgent && (n = kg(n, await t.beforeAgent(n)));
|
|
13952
14118
|
return n;
|
|
13953
14119
|
}
|
|
13954
|
-
function
|
|
14120
|
+
function jg(e, t) {
|
|
13955
14121
|
let n = t.state;
|
|
13956
|
-
for (let r of e) r.beforeModel && (n =
|
|
14122
|
+
for (let r of e) r.beforeModel && (n = kg(n, r.beforeModel({
|
|
13957
14123
|
messages: t.messages,
|
|
13958
14124
|
state: n
|
|
13959
14125
|
})));
|
|
13960
14126
|
return n;
|
|
13961
14127
|
}
|
|
13962
|
-
function
|
|
14128
|
+
function Mg(e, t, n) {
|
|
13963
14129
|
let r = n;
|
|
13964
14130
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
13965
14131
|
let i = e[n];
|
|
13966
|
-
i.afterModel && (r =
|
|
14132
|
+
i.afterModel && (r = kg(r, i.afterModel(t, r)));
|
|
13967
14133
|
}
|
|
13968
14134
|
return r;
|
|
13969
14135
|
}
|
|
13970
|
-
async function
|
|
14136
|
+
async function Ng(e, t) {
|
|
13971
14137
|
let n = t;
|
|
13972
14138
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
13973
14139
|
let r = e[t];
|
|
13974
|
-
r.afterAgent && (n =
|
|
14140
|
+
r.afterAgent && (n = kg(n, await r.afterAgent(n)));
|
|
13975
14141
|
}
|
|
13976
14142
|
return n;
|
|
13977
14143
|
}
|
|
13978
|
-
async function
|
|
14144
|
+
async function Pg(e, t) {
|
|
13979
14145
|
let n = [];
|
|
13980
14146
|
for (let r of e) {
|
|
13981
14147
|
if (!r.beforeReturn) continue;
|
|
@@ -13984,19 +14150,19 @@ async function _g(e, t) {
|
|
|
13984
14150
|
}
|
|
13985
14151
|
return n.length ? n.join("\n\n") : null;
|
|
13986
14152
|
}
|
|
13987
|
-
function
|
|
14153
|
+
function Fg(e, t) {
|
|
13988
14154
|
return e.reduceRight((e, t) => (n) => t.wrapModelCall ? t.wrapModelCall(n, e) : e(n), t);
|
|
13989
14155
|
}
|
|
13990
|
-
function
|
|
14156
|
+
function Ig(e, t) {
|
|
13991
14157
|
return e.reduceRight((e, t) => (n) => t.wrapToolCall ? t.wrapToolCall(n, e) : e(n), t);
|
|
13992
14158
|
}
|
|
13993
14159
|
//#endregion
|
|
13994
14160
|
//#region src/core/harness/createAgent.ts
|
|
13995
|
-
function
|
|
14161
|
+
function Lg(e) {
|
|
13996
14162
|
return e ? /<|tool_calls|>|<||[^>]*tool_call|<invoke\s+name=|<\/?tool_call>|<function_call>/i.test(e) : !1;
|
|
13997
14163
|
}
|
|
13998
|
-
var
|
|
13999
|
-
function
|
|
14164
|
+
var Rg = 10, zg = 300, Bg = 6e3;
|
|
14165
|
+
function Vg(e, t) {
|
|
14000
14166
|
let n = e.reduce((e, t) => e + (typeof t.content == "string" ? t.content.length : JSON.stringify(t.content).length), 0);
|
|
14001
14167
|
if (n <= t) return e;
|
|
14002
14168
|
let r = 0, i = n - t, a = Math.max(100, Math.min(400, Math.round(t / 500)));
|
|
@@ -14011,29 +14177,29 @@ function wg(e, t) {
|
|
|
14011
14177
|
});
|
|
14012
14178
|
});
|
|
14013
14179
|
}
|
|
14014
|
-
function
|
|
14015
|
-
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m =
|
|
14180
|
+
function Hg(e) {
|
|
14181
|
+
let { apiKey: t, baseUrl: n, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, systemPrompt: d, tools: f = [], middleware: p = [], maxToolRounds: m = Rg, maxRetries: h = 2, retryDelayMs: g = 500, maxParallelTools: _ = 1, maxVerifyAttempts: v = 0, onLog: y, debug: b = !1 } = e, x = wg({
|
|
14016
14182
|
model: c,
|
|
14017
14183
|
contextWindow: e.contextWindow,
|
|
14018
14184
|
maxOutputTokens: e.maxOutputTokens
|
|
14019
|
-
}), S = u ?? x.maxOutputTokens, C =
|
|
14185
|
+
}), S = u ?? x.maxOutputTokens, C = Eg(x.contextWindow), w = Dg(x.contextWindow), T = /* @__PURE__ */ pn([]);
|
|
14020
14186
|
function E(e, t) {
|
|
14021
14187
|
let n = {
|
|
14022
14188
|
timestamp: Date.now(),
|
|
14023
14189
|
type: e,
|
|
14024
14190
|
data: t
|
|
14025
14191
|
};
|
|
14026
|
-
T.value.push(n), T.value.length >
|
|
14192
|
+
T.value.push(n), T.value.length > zg && T.value.splice(0, T.value.length - zg), gn(T), y?.(n), b && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
14027
14193
|
}
|
|
14028
14194
|
let D = (e) => {
|
|
14029
|
-
T.value.push(e), T.value.length >
|
|
14195
|
+
T.value.push(e), T.value.length > zg && T.value.splice(0, T.value.length - zg), gn(T);
|
|
14030
14196
|
}, O = [...p.flatMap((e) => e.tools || []), ...f], k = e.llm ?? new s({
|
|
14031
14197
|
apiKey: t,
|
|
14032
14198
|
model: c,
|
|
14033
14199
|
temperature: l,
|
|
14034
14200
|
maxTokens: S,
|
|
14035
14201
|
configuration: n ? { baseURL: n } : void 0
|
|
14036
|
-
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j =
|
|
14202
|
+
}), A = O.length > 0 ? k.bindTools?.(O) ?? k : k, j = Og();
|
|
14037
14203
|
function M() {
|
|
14038
14204
|
let e = [d || "你是一个智能助手。"];
|
|
14039
14205
|
for (let t of p) if (t.augmentPrompt) {
|
|
@@ -14108,7 +14274,7 @@ function Tg(e) {
|
|
|
14108
14274
|
};
|
|
14109
14275
|
try {
|
|
14110
14276
|
let n = await t.invoke(e.args), r = typeof n == "string" ? n : JSON.stringify(n);
|
|
14111
|
-
return r =
|
|
14277
|
+
return r = bg(r, {
|
|
14112
14278
|
files: e.state.files,
|
|
14113
14279
|
vfsAvailable: O.some((e) => e.name === "vfs_read"),
|
|
14114
14280
|
toolName: e.name,
|
|
@@ -14129,12 +14295,12 @@ function Tg(e) {
|
|
|
14129
14295
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
14130
14296
|
}
|
|
14131
14297
|
function R(e, t) {
|
|
14132
|
-
return
|
|
14298
|
+
return Vg(e, t);
|
|
14133
14299
|
}
|
|
14134
14300
|
function ee(e) {
|
|
14135
14301
|
return e.map((e) => {
|
|
14136
14302
|
let t = L(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
14137
|
-
r && (n.content = r.length >
|
|
14303
|
+
r && (n.content = r.length > Bg ? r.slice(0, Bg) + `…(截断 ${r.length - Bg} 字符)` : r);
|
|
14138
14304
|
let i = e.tool_calls;
|
|
14139
14305
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
14140
14306
|
id: e.id,
|
|
@@ -14149,7 +14315,7 @@ function Tg(e) {
|
|
|
14149
14315
|
});
|
|
14150
14316
|
}
|
|
14151
14317
|
async function te(e, t, n) {
|
|
14152
|
-
T.value = [], j =
|
|
14318
|
+
T.value = [], j = Og(), j.messages = e, j = await Ag(p, j);
|
|
14153
14319
|
let r = e;
|
|
14154
14320
|
for (let e of p) if (e.compressInput) {
|
|
14155
14321
|
let t = await e.compressInput(r);
|
|
@@ -14164,13 +14330,13 @@ function Tg(e) {
|
|
|
14164
14330
|
tools: O.map((e) => e.name),
|
|
14165
14331
|
middleware: p.map((e) => e.name)
|
|
14166
14332
|
});
|
|
14167
|
-
let l =
|
|
14333
|
+
let l = Fg(p, (e) => F(e, t, n)), u = Ig(p, I), d = 0, f = null, h = 0;
|
|
14168
14334
|
try {
|
|
14169
14335
|
for (; d < m && !n?.aborted;) {
|
|
14170
14336
|
t({
|
|
14171
14337
|
type: "round_start",
|
|
14172
14338
|
round: d + 1
|
|
14173
|
-
}), j =
|
|
14339
|
+
}), j = jg(p, {
|
|
14174
14340
|
messages: s,
|
|
14175
14341
|
state: j
|
|
14176
14342
|
}), s = P(s), s = R(s, w), E("llm_request", {
|
|
@@ -14187,12 +14353,12 @@ function Tg(e) {
|
|
|
14187
14353
|
round: d + 1,
|
|
14188
14354
|
content: e.content,
|
|
14189
14355
|
toolCalls: e.toolCalls
|
|
14190
|
-
}), j =
|
|
14356
|
+
}), j = Mg(p, e, j), e.aborted) return t({
|
|
14191
14357
|
type: "done",
|
|
14192
14358
|
content: e.content
|
|
14193
14359
|
}), e.content;
|
|
14194
14360
|
if (!e.toolCalls.length) {
|
|
14195
|
-
if (h < 2 &&
|
|
14361
|
+
if (h < 2 && Lg(e.content)) {
|
|
14196
14362
|
h += 1, E("middleware", {
|
|
14197
14363
|
stage: "format_retry",
|
|
14198
14364
|
attempt: h,
|
|
@@ -14201,7 +14367,7 @@ function Tg(e) {
|
|
|
14201
14367
|
continue;
|
|
14202
14368
|
}
|
|
14203
14369
|
if (v > 0 && j.verifyAttempts < v) {
|
|
14204
|
-
let t = await
|
|
14370
|
+
let t = await Pg(p, {
|
|
14205
14371
|
messages: s,
|
|
14206
14372
|
state: j,
|
|
14207
14373
|
response: e,
|
|
@@ -14236,7 +14402,7 @@ function Tg(e) {
|
|
|
14236
14402
|
logSink: D
|
|
14237
14403
|
}
|
|
14238
14404
|
};
|
|
14239
|
-
}), a = await
|
|
14405
|
+
}), a = await xg(r, _, async (e) => {
|
|
14240
14406
|
if (n?.aborted) return;
|
|
14241
14407
|
t({
|
|
14242
14408
|
type: "tool_call",
|
|
@@ -14307,7 +14473,7 @@ function Tg(e) {
|
|
|
14307
14473
|
}), r;
|
|
14308
14474
|
} finally {
|
|
14309
14475
|
try {
|
|
14310
|
-
await
|
|
14476
|
+
await Ng(p, j);
|
|
14311
14477
|
} catch (e) {
|
|
14312
14478
|
console.warn("[Agent] afterAgent 清理出错(已忽略):", e);
|
|
14313
14479
|
}
|
|
@@ -14329,14 +14495,14 @@ function Tg(e) {
|
|
|
14329
14495
|
}
|
|
14330
14496
|
//#endregion
|
|
14331
14497
|
//#region src/core/harness/todos.ts
|
|
14332
|
-
function
|
|
14498
|
+
function Ug(e) {
|
|
14333
14499
|
if (e.length) return [
|
|
14334
14500
|
"## 当前任务清单(用 write_todos 工具管理)",
|
|
14335
14501
|
e.map((e, t) => `${t + 1}. [${e.status}] ${e.content}`).join("\n"),
|
|
14336
14502
|
"规则:开始前用 write_todos 拆解;首个任务标 in_progress;完成一个立即标 completed(不批量);保持至少一个 in_progress 直到全部完成。"
|
|
14337
14503
|
].join("\n");
|
|
14338
14504
|
}
|
|
14339
|
-
function
|
|
14505
|
+
function Wg(e = []) {
|
|
14340
14506
|
let r = e.map((e) => ({ ...e })), i = 0;
|
|
14341
14507
|
return {
|
|
14342
14508
|
name: "todos",
|
|
@@ -14354,7 +14520,7 @@ function Dg(e = []) {
|
|
|
14354
14520
|
})],
|
|
14355
14521
|
beforeAgent: () => ({ todos: r }),
|
|
14356
14522
|
beforeModel: () => (i = 0, { todos: r }),
|
|
14357
|
-
augmentPrompt: () =>
|
|
14523
|
+
augmentPrompt: () => Ug(r),
|
|
14358
14524
|
wrapToolCall: async (e, t) => e.name === "write_todos" && (i++, i > 1) ? {
|
|
14359
14525
|
content: "错误:write_todos 不应在一轮中并行多次调用(整表替换语义)。请串行使用。",
|
|
14360
14526
|
status: "error"
|
|
@@ -14366,18 +14532,18 @@ function Dg(e = []) {
|
|
|
14366
14532
|
}
|
|
14367
14533
|
//#endregion
|
|
14368
14534
|
//#region src/core/harness/skills.ts
|
|
14369
|
-
function
|
|
14535
|
+
function Gg(e) {
|
|
14370
14536
|
return e;
|
|
14371
14537
|
}
|
|
14372
|
-
var
|
|
14373
|
-
function
|
|
14374
|
-
return
|
|
14538
|
+
var Kg = /^https?:\/\//i;
|
|
14539
|
+
function qg(e) {
|
|
14540
|
+
return Kg.test(e) || e.startsWith("//") ? "http" : "vfs";
|
|
14375
14541
|
}
|
|
14376
|
-
function
|
|
14542
|
+
function Jg(e) {
|
|
14377
14543
|
return e.replace(/^vfs:\/\//, "").replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
14378
14544
|
}
|
|
14379
|
-
async function
|
|
14380
|
-
if (
|
|
14545
|
+
async function Yg(e, t) {
|
|
14546
|
+
if (qg(e) === "http") try {
|
|
14381
14547
|
let t = await fetch(e);
|
|
14382
14548
|
return t.ok ? {
|
|
14383
14549
|
ok: !0,
|
|
@@ -14400,7 +14566,7 @@ async function Mg(e, t) {
|
|
|
14400
14566
|
ok: !1,
|
|
14401
14567
|
error: `skill 文档 ${e} 是 vfs 路径,但 vfs 未启用`
|
|
14402
14568
|
};
|
|
14403
|
-
let n = t(
|
|
14569
|
+
let n = t(Jg(e));
|
|
14404
14570
|
return n == null ? {
|
|
14405
14571
|
ok: !1,
|
|
14406
14572
|
error: `未找到 vfs 文档 ${e}(可用 vfs_ls 查看)`
|
|
@@ -14409,14 +14575,14 @@ async function Mg(e, t) {
|
|
|
14409
14575
|
content: n
|
|
14410
14576
|
};
|
|
14411
14577
|
}
|
|
14412
|
-
function
|
|
14578
|
+
function Xg(e) {
|
|
14413
14579
|
if (e.length) return [
|
|
14414
14580
|
"## 可用 Skills(渐进式披露)",
|
|
14415
14581
|
e.map((e) => `- ${e.name}: ${e.description}`).join("\n"),
|
|
14416
14582
|
"当某 skill 适用时,先调用 load_skill(name) 加载其完整指令,再按指令执行。不要凭记忆猜测 skill 内容。"
|
|
14417
14583
|
].join("\n");
|
|
14418
14584
|
}
|
|
14419
|
-
function
|
|
14585
|
+
function Zg(e, r) {
|
|
14420
14586
|
let i = [...e], a = new Map(i.map((e) => [e.name, e])), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = {
|
|
14421
14587
|
set(e) {
|
|
14422
14588
|
i = [...e], a = new Map(i.map((e) => [e.name, e])), s.clear(), o.clear();
|
|
@@ -14433,7 +14599,7 @@ function Pg(e, r) {
|
|
|
14433
14599
|
let n = s.get(e);
|
|
14434
14600
|
if (n != null) return n;
|
|
14435
14601
|
if (t.doc) {
|
|
14436
|
-
let e = await
|
|
14602
|
+
let e = await Yg(t.doc, r?.readVfs);
|
|
14437
14603
|
if (!e.ok) return null;
|
|
14438
14604
|
n = e.content;
|
|
14439
14605
|
} else if (t.getContent) n = await t.getContent();
|
|
@@ -14449,7 +14615,7 @@ function Pg(e, r) {
|
|
|
14449
14615
|
let n = s.get(e);
|
|
14450
14616
|
if (n == null) {
|
|
14451
14617
|
if (t.doc) {
|
|
14452
|
-
let i = await
|
|
14618
|
+
let i = await Yg(t.doc, r?.readVfs);
|
|
14453
14619
|
if (!i.ok) return `加载 skill "${e}" 文档失败:${i.error}`;
|
|
14454
14620
|
n = i.content;
|
|
14455
14621
|
} else if (t.getContent) n = await t.getContent();
|
|
@@ -14469,7 +14635,7 @@ function Pg(e, r) {
|
|
|
14469
14635
|
})),
|
|
14470
14636
|
skillsLoaded: []
|
|
14471
14637
|
}),
|
|
14472
|
-
augmentPrompt: () =>
|
|
14638
|
+
augmentPrompt: () => Xg(i),
|
|
14473
14639
|
afterModel: () => ({ skillsLoaded: [...o] })
|
|
14474
14640
|
};
|
|
14475
14641
|
return Object.defineProperty(l, "controller", {
|
|
@@ -14481,7 +14647,7 @@ function Pg(e, r) {
|
|
|
14481
14647
|
}
|
|
14482
14648
|
//#endregion
|
|
14483
14649
|
//#region src/core/harness/memory.ts
|
|
14484
|
-
function
|
|
14650
|
+
function Qg(e = "") {
|
|
14485
14651
|
let t = e;
|
|
14486
14652
|
return {
|
|
14487
14653
|
name: "memory",
|
|
@@ -14494,14 +14660,14 @@ function Fg(e = "") {
|
|
|
14494
14660
|
}
|
|
14495
14661
|
//#endregion
|
|
14496
14662
|
//#region src/core/harness/permissions.ts
|
|
14497
|
-
var
|
|
14663
|
+
var $g = /* @__PURE__ */ new Set([
|
|
14498
14664
|
"set_data",
|
|
14499
14665
|
"edit_data",
|
|
14500
14666
|
"delete_data",
|
|
14501
14667
|
"write",
|
|
14502
14668
|
"vfs_write",
|
|
14503
14669
|
"vfs_edit"
|
|
14504
|
-
]),
|
|
14670
|
+
]), e_ = /* @__PURE__ */ new Set([
|
|
14505
14671
|
"get_data",
|
|
14506
14672
|
"describe_data",
|
|
14507
14673
|
"read",
|
|
@@ -14512,7 +14678,7 @@ var Ig = /* @__PURE__ */ new Set([
|
|
|
14512
14678
|
"vfs_glob",
|
|
14513
14679
|
"vfs_grep"
|
|
14514
14680
|
]);
|
|
14515
|
-
function
|
|
14681
|
+
function t_(e) {
|
|
14516
14682
|
let t = "";
|
|
14517
14683
|
for (let n = 0; n < e.length; n++) {
|
|
14518
14684
|
let r = e[n];
|
|
@@ -14520,16 +14686,16 @@ function Rg(e) {
|
|
|
14520
14686
|
}
|
|
14521
14687
|
return RegExp("^" + t + "$");
|
|
14522
14688
|
}
|
|
14523
|
-
function
|
|
14524
|
-
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) =>
|
|
14689
|
+
function n_(e, t, n) {
|
|
14690
|
+
for (let r of e) if (r.operations.includes(t) && r.scopes.some((e) => t_(e).test(n))) return r.mode;
|
|
14525
14691
|
return "allow";
|
|
14526
14692
|
}
|
|
14527
|
-
function
|
|
14693
|
+
function r_(e) {
|
|
14528
14694
|
return {
|
|
14529
14695
|
name: "permissions",
|
|
14530
14696
|
wrapToolCall: async (t, n) => {
|
|
14531
|
-
let r =
|
|
14532
|
-
return r && i &&
|
|
14697
|
+
let r = $g.has(t.name) ? "write" : e_.has(t.name) ? "read" : null, i = t.args?.jsonPath || t.args?.path || "";
|
|
14698
|
+
return r && i && n_(e, r, i) === "deny" ? {
|
|
14533
14699
|
content: `权限拒绝:${r} 操作 "${i}" 被 permissions 规则禁止。`,
|
|
14534
14700
|
status: "error"
|
|
14535
14701
|
} : n(t);
|
|
@@ -14538,7 +14704,7 @@ function Bg(e) {
|
|
|
14538
14704
|
}
|
|
14539
14705
|
//#endregion
|
|
14540
14706
|
//#region src/core/harness/approval.ts
|
|
14541
|
-
function
|
|
14707
|
+
function i_(e = {}) {
|
|
14542
14708
|
let t = (t, n) => e.confirm ? !!e.confirm(t, n) : e.tools === void 0 || e.tools.includes(t);
|
|
14543
14709
|
return {
|
|
14544
14710
|
name: "approval",
|
|
@@ -14572,15 +14738,15 @@ function Vg(e = {}) {
|
|
|
14572
14738
|
}
|
|
14573
14739
|
//#endregion
|
|
14574
14740
|
//#region src/core/harness/humanConfirm.ts
|
|
14575
|
-
var
|
|
14741
|
+
var a_ = "request_human_confirmation", o_ = t.object({
|
|
14576
14742
|
question: t.string().describe("要征询用户的问题/方案描述。清晰具体:说明当前情况、为什么需要确认、确认什么。"),
|
|
14577
14743
|
options: t.array(t.string()).optional().describe("可选方案列表(2-4 个)。用户从中选一个。不传则用户只回答允许/拒绝。"),
|
|
14578
14744
|
recommendation: t.string().optional().describe("你推荐的方案(优先在 options 中选一个)及推荐理由,帮用户快速决策。"),
|
|
14579
14745
|
context: t.string().optional().describe("补充上下文:已做了什么、约束、影响范围等,帮用户判断。")
|
|
14580
14746
|
});
|
|
14581
|
-
function
|
|
14747
|
+
function s_() {
|
|
14582
14748
|
return n(async () => "人工确认中间件未装载,无法征询用户。请直接向用户说明情况并等待回复。", {
|
|
14583
|
-
name:
|
|
14749
|
+
name: a_,
|
|
14584
14750
|
description: [
|
|
14585
14751
|
"当遇到以下情况时,主动调用本工具征询用户确认后再继续(不要默默猜测后直接执行高风险动作):",
|
|
14586
14752
|
"1) 不确定用户意图、需求有歧义;",
|
|
@@ -14590,10 +14756,10 @@ function Wg() {
|
|
|
14590
14756
|
"入参:question=问题/方案描述;options=可选方案列表(多方案时给);recommendation=你推荐的方案及理由。",
|
|
14591
14757
|
"用户选择后,据其回答继续;若用户拒绝,停止当前操作并询问如何调整。"
|
|
14592
14758
|
].join(""),
|
|
14593
|
-
schema:
|
|
14759
|
+
schema: o_
|
|
14594
14760
|
});
|
|
14595
14761
|
}
|
|
14596
|
-
function
|
|
14762
|
+
function c_() {
|
|
14597
14763
|
return {
|
|
14598
14764
|
name: "humanConfirm",
|
|
14599
14765
|
wrapToolCall: async (e, t) => e.name === "request_human_confirmation" ? new Promise((t) => {
|
|
@@ -14625,14 +14791,14 @@ function Gg() {
|
|
|
14625
14791
|
}
|
|
14626
14792
|
//#endregion
|
|
14627
14793
|
//#region src/core/harness/checkpoint.ts
|
|
14628
|
-
function
|
|
14794
|
+
function l_(e) {
|
|
14629
14795
|
if (typeof e != "object" || !e) return e;
|
|
14630
14796
|
if (typeof structuredClone == "function") try {
|
|
14631
14797
|
return structuredClone(e);
|
|
14632
14798
|
} catch {}
|
|
14633
14799
|
return JSON.parse(JSON.stringify(e));
|
|
14634
14800
|
}
|
|
14635
|
-
function
|
|
14801
|
+
function u_(e, t) {
|
|
14636
14802
|
let n = t.split("."), r = e;
|
|
14637
14803
|
for (let e of n) {
|
|
14638
14804
|
if (r == null) return;
|
|
@@ -14640,12 +14806,12 @@ function qg(e, t) {
|
|
|
14640
14806
|
}
|
|
14641
14807
|
return r;
|
|
14642
14808
|
}
|
|
14643
|
-
function
|
|
14809
|
+
function d_(e, t, n) {
|
|
14644
14810
|
let r = t.split("."), i = e;
|
|
14645
14811
|
for (let e = 0; e < r.length - 1; e++) i[r[e]] ?? (i[r[e]] = {}), i = i[r[e]];
|
|
14646
14812
|
i[r[r.length - 1]] = n;
|
|
14647
14813
|
}
|
|
14648
|
-
function
|
|
14814
|
+
function f_(e, t) {
|
|
14649
14815
|
if (Array.isArray(e)) {
|
|
14650
14816
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
14651
14817
|
return;
|
|
@@ -14654,11 +14820,11 @@ function Yg(e, t) {
|
|
|
14654
14820
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
14655
14821
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
14656
14822
|
}
|
|
14657
|
-
function
|
|
14658
|
-
let n =
|
|
14659
|
-
typeof n == "object" && n ?
|
|
14823
|
+
function p_(e, t) {
|
|
14824
|
+
let n = u_(window, e);
|
|
14825
|
+
typeof n == "object" && n ? f_(n, t) : d_(window, e, t);
|
|
14660
14826
|
}
|
|
14661
|
-
function
|
|
14827
|
+
function m_(e) {
|
|
14662
14828
|
let t = e.slice();
|
|
14663
14829
|
for (; t.length;) {
|
|
14664
14830
|
let e = t[t.length - 1];
|
|
@@ -14667,21 +14833,21 @@ function Zg(e) {
|
|
|
14667
14833
|
}
|
|
14668
14834
|
return t;
|
|
14669
14835
|
}
|
|
14670
|
-
function
|
|
14836
|
+
function h_(e) {
|
|
14671
14837
|
let t = [], n = e.maxCheckpoints ?? 5, r = 1;
|
|
14672
14838
|
return {
|
|
14673
14839
|
save(i) {
|
|
14674
|
-
let a =
|
|
14675
|
-
if (e.getData) o[""] =
|
|
14676
|
-
else for (let t of e.slotPaths ?? []) o[t] =
|
|
14840
|
+
let a = m_(e.messages), o = {};
|
|
14841
|
+
if (e.getData) o[""] = l_(e.getData());
|
|
14842
|
+
else for (let t of e.slotPaths ?? []) o[t] = l_(u_(window, t));
|
|
14677
14843
|
let s = {
|
|
14678
14844
|
id: r++,
|
|
14679
14845
|
label: i,
|
|
14680
14846
|
timestamp: Date.now(),
|
|
14681
|
-
messages:
|
|
14847
|
+
messages: l_(a),
|
|
14682
14848
|
windowVals: o,
|
|
14683
|
-
vfs:
|
|
14684
|
-
todos:
|
|
14849
|
+
vfs: l_(e.vfsStore.files),
|
|
14850
|
+
todos: l_(e.getTodos()),
|
|
14685
14851
|
messageCount: a.length
|
|
14686
14852
|
};
|
|
14687
14853
|
for (t.push(s); t.length > n;) t.shift();
|
|
@@ -14701,20 +14867,20 @@ function Qg(e) {
|
|
|
14701
14867
|
restore(n) {
|
|
14702
14868
|
let r = n == null ? t[t.length - 1] : t.find((e) => e.id === n);
|
|
14703
14869
|
if (!r) return !1;
|
|
14704
|
-
if (e.messages.splice(0, e.messages.length, ...
|
|
14870
|
+
if (e.messages.splice(0, e.messages.length, ...l_(r.messages)), e.getData) {
|
|
14705
14871
|
let t = r.windowVals[""];
|
|
14706
14872
|
if (t !== void 0) {
|
|
14707
14873
|
let n = e.getData();
|
|
14708
|
-
typeof n == "object" && n &&
|
|
14874
|
+
typeof n == "object" && n && f_(n, l_(t));
|
|
14709
14875
|
}
|
|
14710
|
-
} else for (let [e, t] of Object.entries(r.windowVals))
|
|
14876
|
+
} else for (let [e, t] of Object.entries(r.windowVals)) p_(e, l_(t));
|
|
14711
14877
|
let i = e.vfsStore.files;
|
|
14712
14878
|
for (let e of Object.keys(i)) delete i[e];
|
|
14713
|
-
return Object.assign(i,
|
|
14879
|
+
return Object.assign(i, l_(r.vfs)), e.todosMw.reset(l_(r.todos)), !0;
|
|
14714
14880
|
}
|
|
14715
14881
|
};
|
|
14716
14882
|
}
|
|
14717
|
-
function
|
|
14883
|
+
function g_(e) {
|
|
14718
14884
|
let t = !1;
|
|
14719
14885
|
return {
|
|
14720
14886
|
name: "checkpoint",
|
|
@@ -14728,23 +14894,23 @@ function $g(e) {
|
|
|
14728
14894
|
}
|
|
14729
14895
|
//#endregion
|
|
14730
14896
|
//#region src/core/harness/subagent.ts
|
|
14731
|
-
function
|
|
14897
|
+
function __(e) {
|
|
14732
14898
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14733
14899
|
}
|
|
14734
|
-
var
|
|
14900
|
+
var v_ = [
|
|
14735
14901
|
"describe_data",
|
|
14736
14902
|
"get_data",
|
|
14737
14903
|
"read",
|
|
14738
14904
|
"query_data",
|
|
14739
14905
|
"search_data",
|
|
14740
14906
|
"fetch_document"
|
|
14741
|
-
],
|
|
14742
|
-
async function
|
|
14743
|
-
let a = t.depth ?? 0, o = t.maxDepth ??
|
|
14907
|
+
], y_ = 1, b_ = 4, x_ = 6, S_ = ["spawn_agent", "spawn_agents"];
|
|
14908
|
+
async function C_(e, t, n, r, i) {
|
|
14909
|
+
let a = t.depth ?? 0, o = t.maxDepth ?? y_, s = /* @__PURE__ */ new Set([...v_, ...t.allowedTools ?? []]), c = [...t.allTools.filter((e) => s.has(e.name) && !S_.includes(e.name)), ...t.extraTools ?? []], l = a + 1 < o ? [w_({
|
|
14744
14910
|
...t,
|
|
14745
14911
|
depth: a + 1
|
|
14746
|
-
})] : [], u =
|
|
14747
|
-
...
|
|
14912
|
+
})] : [], u = Hg({
|
|
14913
|
+
...__(t.llm) ? { llm: t.llm } : {
|
|
14748
14914
|
apiKey: t.llm.apiKey,
|
|
14749
14915
|
baseUrl: t.llm.baseUrl,
|
|
14750
14916
|
model: e.model ?? t.llm.model,
|
|
@@ -14753,8 +14919,8 @@ async function o_(e, t, n, r, i) {
|
|
|
14753
14919
|
},
|
|
14754
14920
|
systemPrompt: e.role?.trim() || t.systemPrompt || "你是一个专注的子任务执行者。你只有只读工具(读主数据 / 抓文档),用它们完成给定任务,给出简洁结论,不要展开多余解释。",
|
|
14755
14921
|
tools: c,
|
|
14756
|
-
middleware: [...t.skills?.length ? [
|
|
14757
|
-
maxToolRounds: t.maxToolRounds ??
|
|
14922
|
+
middleware: [...t.skills?.length ? [Zg(t.skills)] : [], ...l],
|
|
14923
|
+
maxToolRounds: t.maxToolRounds ?? x_,
|
|
14758
14924
|
onLog: i,
|
|
14759
14925
|
debug: t.debug
|
|
14760
14926
|
});
|
|
@@ -14766,8 +14932,8 @@ async function o_(e, t, n, r, i) {
|
|
|
14766
14932
|
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
14767
14933
|
}, n);
|
|
14768
14934
|
}
|
|
14769
|
-
function
|
|
14770
|
-
let r = e.maxParallel ??
|
|
14935
|
+
function w_(e) {
|
|
14936
|
+
let r = e.maxParallel ?? b_, i, a, o, s = (e, t) => (n) => {
|
|
14771
14937
|
a && a({
|
|
14772
14938
|
type: "subagent",
|
|
14773
14939
|
taskId: e,
|
|
@@ -14786,7 +14952,7 @@ function s_(e) {
|
|
|
14786
14952
|
...e,
|
|
14787
14953
|
allowedTools: r
|
|
14788
14954
|
} : e, l = `sub-${Math.random().toString(36).slice(2, 8)}`, u = n?.trim() || "子任务";
|
|
14789
|
-
return await
|
|
14955
|
+
return await C_({
|
|
14790
14956
|
prompt: t,
|
|
14791
14957
|
role: n,
|
|
14792
14958
|
model: a
|
|
@@ -14803,9 +14969,9 @@ function s_(e) {
|
|
|
14803
14969
|
tools: t.array(t.string()).optional().describe("子 agent 可用工具名白名单(默认只读主数据 + fetch)"),
|
|
14804
14970
|
model: t.string().optional().describe("覆盖模型(默认同主)")
|
|
14805
14971
|
})
|
|
14806
|
-
}), n(async ({ tasks: t }) => (await
|
|
14972
|
+
}), n(async ({ tasks: t }) => (await xg(t, r, async (t, n) => {
|
|
14807
14973
|
let r = `sub-${n}-${Math.random().toString(36).slice(2, 6)}`, a = t.role?.trim() || `子任务${n + 1}`;
|
|
14808
|
-
return
|
|
14974
|
+
return C_(t, e, i, s(r, a), (e) => o?.({
|
|
14809
14975
|
...e,
|
|
14810
14976
|
source: `子:${a}`
|
|
14811
14977
|
}));
|
|
@@ -14820,8 +14986,8 @@ function s_(e) {
|
|
|
14820
14986
|
wrapToolCall: async (e, t) => (e.signal && (i = e.signal), e.emit && (a = e.emit), e.logSink && (o = e.logSink), t(e))
|
|
14821
14987
|
};
|
|
14822
14988
|
}
|
|
14823
|
-
var
|
|
14824
|
-
function
|
|
14989
|
+
var T_ = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
14990
|
+
function E_(e, t) {
|
|
14825
14991
|
let n = e.tools ?? [];
|
|
14826
14992
|
return {
|
|
14827
14993
|
llm: e.llm ?? t.llm,
|
|
@@ -14835,9 +15001,9 @@ function l_(e, t) {
|
|
|
14835
15001
|
debug: t.debug
|
|
14836
15002
|
};
|
|
14837
15003
|
}
|
|
14838
|
-
function
|
|
15004
|
+
function D_(e, r) {
|
|
14839
15005
|
let i = /* @__PURE__ */ new Set(), a = e.filter((e) => {
|
|
14840
|
-
if (!
|
|
15006
|
+
if (!T_.test(e.id)) return console.warn(`[subagents] id "${e.id}" 非合法工具名(须 [a-zA-Z_][a-zA-Z0-9_]*),已跳过`), !1;
|
|
14841
15007
|
let t = `use_${e.id}`;
|
|
14842
15008
|
return i.has(t) ? (console.warn(`[subagents] id "${e.id}" 重复,已跳过`), !1) : (i.add(t), !0);
|
|
14843
15009
|
}), o, s, c, l = (e, t) => (n) => {
|
|
@@ -14855,8 +15021,8 @@ function u_(e, r) {
|
|
|
14855
15021
|
return {
|
|
14856
15022
|
name: "subagents",
|
|
14857
15023
|
tools: a.map((e) => n(async ({ task: t }) => {
|
|
14858
|
-
let n =
|
|
14859
|
-
return
|
|
15024
|
+
let n = E_(e, r);
|
|
15025
|
+
return C_({ prompt: t }, n, o, l(`use_${e.id}`, e.id), (t) => c?.({
|
|
14860
15026
|
...t,
|
|
14861
15027
|
source: `子:${e.id}`
|
|
14862
15028
|
}));
|
|
@@ -14875,7 +15041,7 @@ function u_(e, r) {
|
|
|
14875
15041
|
}
|
|
14876
15042
|
//#endregion
|
|
14877
15043
|
//#region src/core/harness/verify.ts
|
|
14878
|
-
function
|
|
15044
|
+
function O_(e) {
|
|
14879
15045
|
return {
|
|
14880
15046
|
name: "verify",
|
|
14881
15047
|
async beforeReturn({ messages: t, state: n, log: r }) {
|
|
@@ -14887,10 +15053,10 @@ function d_(e) {
|
|
|
14887
15053
|
if (e.adversarial) {
|
|
14888
15054
|
r?.("middleware", {
|
|
14889
15055
|
stage: "adversarial_start",
|
|
14890
|
-
model:
|
|
15056
|
+
model: I_(e.adversarial.llm),
|
|
14891
15057
|
tools: (e.adversarial.tools ?? []).length
|
|
14892
15058
|
});
|
|
14893
|
-
let n = await
|
|
15059
|
+
let n = await B_(t, e.adversarial.llm, r, e.adversarial.tools);
|
|
14894
15060
|
if (r?.("middleware", {
|
|
14895
15061
|
stage: "adversarial_done",
|
|
14896
15062
|
clean: n === null,
|
|
@@ -14901,18 +15067,18 @@ function d_(e) {
|
|
|
14901
15067
|
}
|
|
14902
15068
|
};
|
|
14903
15069
|
}
|
|
14904
|
-
var
|
|
15070
|
+
var k_ = /* @__PURE__ */ new Set([
|
|
14905
15071
|
"set_data",
|
|
14906
15072
|
"edit_data",
|
|
14907
15073
|
"delete_data",
|
|
14908
15074
|
"write"
|
|
14909
|
-
]),
|
|
14910
|
-
function
|
|
15075
|
+
]), A_ = /校验失败|SCHEMA_INVALID|未注册|不存在|仅支持|必须是|NOT_OBJECT|PATH_UNSAFE|VERSION_CONFLICT|WRITE_INTERCEPT/;
|
|
15076
|
+
function j_(e) {
|
|
14911
15077
|
let t = /* @__PURE__ */ new Map();
|
|
14912
15078
|
for (let n of e) {
|
|
14913
15079
|
let e = n?.tool_calls;
|
|
14914
15080
|
if (Array.isArray(e)) {
|
|
14915
|
-
for (let n of e) if (
|
|
15081
|
+
for (let n of e) if (k_.has(n.name)) {
|
|
14916
15082
|
let e = typeof n?.args?.jsonPath == "string" ? n.args.jsonPath : "";
|
|
14917
15083
|
t.set(e, {
|
|
14918
15084
|
path: e,
|
|
@@ -14924,7 +15090,7 @@ function m_(e) {
|
|
|
14924
15090
|
}
|
|
14925
15091
|
return [...t.values()];
|
|
14926
15092
|
}
|
|
14927
|
-
function
|
|
15093
|
+
function M_(e) {
|
|
14928
15094
|
let t = /* @__PURE__ */ new Map();
|
|
14929
15095
|
for (let n of e) {
|
|
14930
15096
|
let e = n?.tool_call_id, r = n?.content;
|
|
@@ -14932,7 +15098,7 @@ function h_(e) {
|
|
|
14932
15098
|
}
|
|
14933
15099
|
return t;
|
|
14934
15100
|
}
|
|
14935
|
-
function
|
|
15101
|
+
function N_(e, t) {
|
|
14936
15102
|
if (t === "") return e;
|
|
14937
15103
|
if (e == null) return;
|
|
14938
15104
|
let n = e;
|
|
@@ -14942,16 +15108,16 @@ function g_(e, t) {
|
|
|
14942
15108
|
}
|
|
14943
15109
|
return n;
|
|
14944
15110
|
}
|
|
14945
|
-
function
|
|
15111
|
+
function P_(e = {}) {
|
|
14946
15112
|
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 ?? {};
|
|
14947
15113
|
return async ({ messages: e }) => {
|
|
14948
|
-
let r =
|
|
15114
|
+
let r = j_(e);
|
|
14949
15115
|
if (!r.length) return { ok: !0 };
|
|
14950
|
-
let i =
|
|
15116
|
+
let i = M_(e), a = n()[""], o = t(), s = [];
|
|
14951
15117
|
for (let { path: e, op: t, callId: n } of r) {
|
|
14952
15118
|
let r = n ? i.get(n) : void 0;
|
|
14953
|
-
if (r &&
|
|
14954
|
-
let c =
|
|
15119
|
+
if (r && A_.test(r)) continue;
|
|
15120
|
+
let c = N_(o, e);
|
|
14955
15121
|
if (t === "delete_data") c !== void 0 && s.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14956
15122
|
else if (c == null) s.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14957
15123
|
else if (a) {
|
|
@@ -14965,17 +15131,17 @@ function __(e = {}) {
|
|
|
14965
15131
|
} : { ok: !0 };
|
|
14966
15132
|
};
|
|
14967
15133
|
}
|
|
14968
|
-
function
|
|
15134
|
+
function F_(e) {
|
|
14969
15135
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
14970
15136
|
}
|
|
14971
|
-
function
|
|
14972
|
-
return
|
|
15137
|
+
function I_(e) {
|
|
15138
|
+
return F_(e) ? e.model ?? e.modelName ?? "<实例>" : e.model ?? "<配置>";
|
|
14973
15139
|
}
|
|
14974
|
-
var
|
|
14975
|
-
function
|
|
14976
|
-
return
|
|
15140
|
+
var L_ = /无问题|没有问题|未发现问题|没有发现|没问题|未发现/;
|
|
15141
|
+
function R_(e) {
|
|
15142
|
+
return L_.test(e);
|
|
14977
15143
|
}
|
|
14978
|
-
function
|
|
15144
|
+
function z_(e) {
|
|
14979
15145
|
let t = "", n = "";
|
|
14980
15146
|
for (let a of e) a instanceof i ? t = typeof a.content == "string" ? a.content : "" : a instanceof r && !(a.tool_calls?.length > 0) && (n = typeof a.content == "string" ? a.content : "");
|
|
14981
15147
|
return {
|
|
@@ -14983,8 +15149,8 @@ function S_(e) {
|
|
|
14983
15149
|
lastReply: n
|
|
14984
15150
|
};
|
|
14985
15151
|
}
|
|
14986
|
-
async function
|
|
14987
|
-
let { lastUser: i, lastReply: a } =
|
|
15152
|
+
async function B_(e, t, n, r) {
|
|
15153
|
+
let { lastUser: i, lastReply: a } = z_(e);
|
|
14988
15154
|
if (!a) return null;
|
|
14989
15155
|
let o = Array.isArray(r) && r.length > 0, s = [
|
|
14990
15156
|
"你是严格的对抗式审查者,目标是找出以下 AI 助手回复的错误并证明它有问题(事实错误 / 遗漏 / 逻辑矛盾 / 与需求不符)。",
|
|
@@ -14995,7 +15161,7 @@ async function C_(e, t, n, r) {
|
|
|
14995
15161
|
].join("\n"), c = "你是严格的对抗式审查者,只找问题不赞美。目标是反驳,不是改进。", l = n ? (e) => n(e.type, {
|
|
14996
15162
|
...e.data,
|
|
14997
15163
|
source: "adversarial"
|
|
14998
|
-
}) : void 0, u = await
|
|
15164
|
+
}) : void 0, u = await Hg(F_(t) ? {
|
|
14999
15165
|
llm: t,
|
|
15000
15166
|
tools: r,
|
|
15001
15167
|
maxToolRounds: o ? 4 : 1,
|
|
@@ -15020,17 +15186,17 @@ async function C_(e, t, n, r) {
|
|
|
15020
15186
|
stage: "adversarial_verdict",
|
|
15021
15187
|
verdict: u,
|
|
15022
15188
|
source: "adversarial"
|
|
15023
|
-
}),
|
|
15189
|
+
}), R_(u) ? null : u.trim();
|
|
15024
15190
|
}
|
|
15025
15191
|
//#endregion
|
|
15026
15192
|
//#region src/core/mcp/client.ts
|
|
15027
|
-
function
|
|
15193
|
+
function V_(e) {
|
|
15028
15194
|
let t = e?.content;
|
|
15029
15195
|
if (!Array.isArray(t) || !t.length) return "";
|
|
15030
15196
|
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");
|
|
15031
15197
|
return e?.isError ? `工具错误:${n}` : n;
|
|
15032
15198
|
}
|
|
15033
|
-
async function
|
|
15199
|
+
async function H_(e) {
|
|
15034
15200
|
let t = new URL(e.url), n = e.requestInit;
|
|
15035
15201
|
if (e.transport === "http") {
|
|
15036
15202
|
let { StreamableHTTPClientTransport: e } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
@@ -15043,8 +15209,8 @@ async function T_(e) {
|
|
|
15043
15209
|
let { WebSocketClientTransport: r } = await import("@modelcontextprotocol/sdk/client/websocket.js");
|
|
15044
15210
|
return new r(t);
|
|
15045
15211
|
}
|
|
15046
|
-
function
|
|
15047
|
-
return n(async (n) =>
|
|
15212
|
+
function U_(e, t) {
|
|
15213
|
+
return n(async (n) => V_(await t.callTool({
|
|
15048
15214
|
name: e.name,
|
|
15049
15215
|
arguments: n
|
|
15050
15216
|
})), {
|
|
@@ -15053,21 +15219,21 @@ function E_(e, t) {
|
|
|
15053
15219
|
schema: e.inputSchema
|
|
15054
15220
|
});
|
|
15055
15221
|
}
|
|
15056
|
-
async function
|
|
15057
|
-
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await
|
|
15222
|
+
async function W_(e) {
|
|
15223
|
+
let { Client: t } = await import("@modelcontextprotocol/sdk/client"), n = await H_(e), r = new t({
|
|
15058
15224
|
name: "page-agent-sdk",
|
|
15059
15225
|
version: "1.0"
|
|
15060
15226
|
}, { capabilities: {} });
|
|
15061
15227
|
await r.connect(n);
|
|
15062
15228
|
let { tools: i } = await r.listTools();
|
|
15063
15229
|
return {
|
|
15064
|
-
tools: i.map((e) =>
|
|
15230
|
+
tools: i.map((e) => U_(e, r)),
|
|
15065
15231
|
close: () => r.close()
|
|
15066
15232
|
};
|
|
15067
15233
|
}
|
|
15068
15234
|
//#endregion
|
|
15069
15235
|
//#region src/core/utils/rounds.ts
|
|
15070
|
-
function
|
|
15236
|
+
function G_(e) {
|
|
15071
15237
|
let t = [], n = null, r = 0;
|
|
15072
15238
|
for (let i = 0; i < e.length; i++) {
|
|
15073
15239
|
let a = e[i];
|
|
@@ -15081,14 +15247,14 @@ function O_(e) {
|
|
|
15081
15247
|
}
|
|
15082
15248
|
return n && t.push(n), t;
|
|
15083
15249
|
}
|
|
15084
|
-
function
|
|
15250
|
+
function K_(e, t) {
|
|
15085
15251
|
let n = (e || "").replace(/```[\s\S]*?```/g, "[代码]").replace(/`([^`]+)`/g, "$1").replace(/[#*_>\-]\s?/g, "").replace(/\[(代码)\]/g, "「代码」").replace(/\s+/g, " ").trim();
|
|
15086
15252
|
return n.length > t ? n.slice(0, t) + "…" : n;
|
|
15087
15253
|
}
|
|
15088
|
-
var
|
|
15089
|
-
function
|
|
15254
|
+
var q_ = "【更早对话摘要";
|
|
15255
|
+
function J_(e, t) {
|
|
15090
15256
|
if (t <= 0) return { trimmed: !1 };
|
|
15091
|
-
let n =
|
|
15257
|
+
let n = G_(e);
|
|
15092
15258
|
if (n.length <= t) return { trimmed: !1 };
|
|
15093
15259
|
let r = n[n.length - t].startIdx, i = n.slice(0, n.length - t), a = n[0].startIdx, o = "";
|
|
15094
15260
|
for (let t = 0; t < a; t++) {
|
|
@@ -15099,7 +15265,7 @@ function j_(e, t) {
|
|
|
15099
15265
|
}
|
|
15100
15266
|
}
|
|
15101
15267
|
let s = i.map((e) => {
|
|
15102
|
-
let t =
|
|
15268
|
+
let t = K_(e.userMsg.content, 60) || "(空)", n = e.assistantMsgs[0] ? K_(e.assistantMsgs[0].content, 80) : "(无回复)";
|
|
15103
15269
|
return `- 第${e.round}轮:${t} → ${n}`;
|
|
15104
15270
|
}).join("\n"), c = o ? o.replace(/^【[^】]*】\n?/, "") : "";
|
|
15105
15271
|
return {
|
|
@@ -15108,47 +15274,47 @@ function j_(e, t) {
|
|
|
15108
15274
|
deleteCount: r,
|
|
15109
15275
|
summary: {
|
|
15110
15276
|
role: "system",
|
|
15111
|
-
content: c ? `${
|
|
15277
|
+
content: c ? `${q_}(${i.length} 轮,含累积)】\n${c}\n【续】\n${s}` : `${q_}(${i.length} 轮)】\n${s}`,
|
|
15112
15278
|
timestamp: i[0].userMsg.timestamp
|
|
15113
15279
|
}
|
|
15114
15280
|
};
|
|
15115
15281
|
}
|
|
15116
15282
|
//#endregion
|
|
15117
15283
|
//#region src/core/composables/useContextManager.ts
|
|
15118
|
-
var
|
|
15284
|
+
var Y_ = {
|
|
15119
15285
|
windowRounds: 6,
|
|
15120
15286
|
summaryThresholdRounds: 8,
|
|
15121
15287
|
toolResultMaxChars: 800,
|
|
15122
15288
|
enableRecall: !0,
|
|
15123
15289
|
recallTopK: 3,
|
|
15124
15290
|
enableLLMSummary: !1
|
|
15125
|
-
},
|
|
15126
|
-
function
|
|
15127
|
-
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !
|
|
15291
|
+
}, X_ = /* @__PURE__ */ new Set(/* @__PURE__ */ "的.了.是.在.我.你.他.她.它.这.那.和.与.及.或.一个.什么.怎么.如何.为什么.可以.能.请.帮.一下.需要.想要.the.a.an.is.are.of.to.in.on".split("."));
|
|
15292
|
+
function Z_(e) {
|
|
15293
|
+
return e.toLowerCase().split(/[^a-z0-9\u4e00-\u9fa5]+/i).map((e) => e.trim()).filter((e) => e.length >= 2 && !X_.has(e));
|
|
15128
15294
|
}
|
|
15129
|
-
function
|
|
15295
|
+
function Q_(e) {
|
|
15130
15296
|
let t = typeof e.content == "string" ? e.content : "";
|
|
15131
15297
|
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);
|
|
15132
|
-
return
|
|
15298
|
+
return Tg(t);
|
|
15133
15299
|
}
|
|
15134
|
-
function
|
|
15135
|
-
let t =
|
|
15136
|
-
for (let n of e.assistantMsgs) t +=
|
|
15300
|
+
function $_(e) {
|
|
15301
|
+
let t = Q_(e.userMsg);
|
|
15302
|
+
for (let n of e.assistantMsgs) t += Q_(n);
|
|
15137
15303
|
return t;
|
|
15138
15304
|
}
|
|
15139
|
-
function
|
|
15305
|
+
function ev(e, t) {
|
|
15140
15306
|
return e.map((e) => {
|
|
15141
|
-
let n =
|
|
15307
|
+
let n = K_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? K_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
15142
15308
|
if (t && t.size) {
|
|
15143
15309
|
let n = [];
|
|
15144
|
-
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${
|
|
15310
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${K_(e.result, 120)}`);
|
|
15145
15311
|
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
15146
15312
|
}
|
|
15147
15313
|
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
15148
15314
|
}).join("\n");
|
|
15149
15315
|
}
|
|
15150
|
-
function
|
|
15151
|
-
let r =
|
|
15316
|
+
function tv(e, t, n) {
|
|
15317
|
+
let r = Z_(t);
|
|
15152
15318
|
return r.length === 0 ? [] : e.map((e) => {
|
|
15153
15319
|
let t = (e.userMsg.content + " " + e.assistantMsgs.map((e) => e.content).join(" ")).toLowerCase(), n = 0;
|
|
15154
15320
|
for (let e of r) t.includes(e) && n++;
|
|
@@ -15158,13 +15324,13 @@ function R_(e, t, n) {
|
|
|
15158
15324
|
};
|
|
15159
15325
|
}).filter((e) => e.score > 0).sort((e, t) => t.score - e.score).slice(0, n).map((e) => e.r);
|
|
15160
15326
|
}
|
|
15161
|
-
function
|
|
15327
|
+
function nv(e = {}) {
|
|
15162
15328
|
let t = {
|
|
15163
|
-
...
|
|
15329
|
+
...Y_,
|
|
15164
15330
|
...e
|
|
15165
15331
|
};
|
|
15166
15332
|
async function n(e) {
|
|
15167
|
-
let n =
|
|
15333
|
+
let n = G_(e), r = e.length, i = "";
|
|
15168
15334
|
if (n.length) {
|
|
15169
15335
|
let t = n[0].startIdx;
|
|
15170
15336
|
for (let n = 0; n < t; n++) {
|
|
@@ -15188,9 +15354,9 @@ function z_(e = {}) {
|
|
|
15188
15354
|
}
|
|
15189
15355
|
}), o, s, c;
|
|
15190
15356
|
if (t.contextWindow && t.contextWindow > 0) {
|
|
15191
|
-
if (n.reduce((e, t) => e +
|
|
15357
|
+
if (n.reduce((e, t) => e + $_(t), 0) <= t.contextWindow * (t.summaryThresholdRatio ?? .5)) return a("none");
|
|
15192
15358
|
let e = t.contextWindow * (t.windowRatio ?? .4), r = 0, i = 0;
|
|
15193
|
-
for (let t = n.length - 1; t >= 0; t--) if (r +=
|
|
15359
|
+
for (let t = n.length - 1; t >= 0; t--) if (r += $_(n[t]), r >= e) {
|
|
15194
15360
|
i = t + 1;
|
|
15195
15361
|
break;
|
|
15196
15362
|
}
|
|
@@ -15203,12 +15369,12 @@ function z_(e = {}) {
|
|
|
15203
15369
|
}
|
|
15204
15370
|
let l = [...e].reverse().find((e) => e.role === "user")?.content || "", u = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, d, f;
|
|
15205
15371
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
15206
|
-
d = await t.llmInvoke(
|
|
15372
|
+
d = await t.llmInvoke(ev(s, u)), f = c + "llm_summary";
|
|
15207
15373
|
} catch {
|
|
15208
|
-
d =
|
|
15374
|
+
d = ev(s, u), f = c + "index_summary(llm_fallback)";
|
|
15209
15375
|
}
|
|
15210
|
-
else d =
|
|
15211
|
-
let p = t.enableRecall ?
|
|
15376
|
+
else d = ev(s, u), f = c + "index_summary";
|
|
15377
|
+
let p = t.enableRecall ? tv(s, l, t.recallTopK) : [], m = p.length ? p.map((e) => `- 第${e.round}轮:${K_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? K_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", h = i ? `${d}\n【更早累积摘要】\n${i}` : d, g = [`【对话历史摘要】以下是之前 ${s.length} 轮对话的要点(最新 ${o.length} 轮已完整保留):`, h];
|
|
15212
15378
|
m && g.push("\n【与当前问题可能相关的早期对话】", m);
|
|
15213
15379
|
let _ = t.getRegisteredData ?? t.getRegisteredSlots;
|
|
15214
15380
|
if (_) try {
|
|
@@ -15245,8 +15411,8 @@ function z_(e = {}) {
|
|
|
15245
15411
|
}
|
|
15246
15412
|
//#endregion
|
|
15247
15413
|
//#region src/core/harness/summarization.ts
|
|
15248
|
-
function
|
|
15249
|
-
let t =
|
|
15414
|
+
function rv(e = {}) {
|
|
15415
|
+
let t = nv(e);
|
|
15250
15416
|
return {
|
|
15251
15417
|
name: "summarization",
|
|
15252
15418
|
compressInput: async (e) => {
|
|
@@ -15260,7 +15426,7 @@ function B_(e = {}) {
|
|
|
15260
15426
|
}
|
|
15261
15427
|
//#endregion
|
|
15262
15428
|
//#region src/core/presets.ts
|
|
15263
|
-
var
|
|
15429
|
+
var iv = {
|
|
15264
15430
|
pageBuilder: { systemPrompt: "你是页面构建助手。按用户意图读写主数据(经 data 声明 + schema 校验),改完页面实时更新。" },
|
|
15265
15431
|
researcher: {
|
|
15266
15432
|
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
@@ -15274,7 +15440,7 @@ var V_ = {
|
|
|
15274
15440
|
memory: !1,
|
|
15275
15441
|
subagent: !1
|
|
15276
15442
|
} }
|
|
15277
|
-
},
|
|
15443
|
+
}, av = { reliableWriteRules: [
|
|
15278
15444
|
"【可靠写入规则】",
|
|
15279
15445
|
"1. 改任何字段前,先用 read({ jsonPath }) 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15280
15446
|
"2. 若不确定可操作哪些字段,先 read() 不传 jsonPath 查看主数据说明 + schema 声明字段(集成方可经 sdk.setData 运行时替换 schema,以工具返回为准,勿凭旧记忆);",
|
|
@@ -15282,7 +15448,7 @@ var V_ = {
|
|
|
15282
15448
|
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15283
15449
|
"5. 优先用 write 的 patch 增量改(只发改动,如 write({ value, patch:{ op, jsonPath } })),避免整体重传大 JSON 被截断。"
|
|
15284
15450
|
].join("\n") };
|
|
15285
|
-
function
|
|
15451
|
+
function ov(e) {
|
|
15286
15452
|
if (!e) return "";
|
|
15287
15453
|
try {
|
|
15288
15454
|
let t = e.shape ?? (e._def?.shape ? typeof e._def.shape == "function" ? e._def.shape() : e._def.shape : null);
|
|
@@ -15295,7 +15461,7 @@ function U_(e) {
|
|
|
15295
15461
|
}
|
|
15296
15462
|
//#endregion
|
|
15297
15463
|
//#region src/core/sdk/contextPreset.ts
|
|
15298
|
-
var
|
|
15464
|
+
var sv = {
|
|
15299
15465
|
auto: {
|
|
15300
15466
|
summaryThresholdRatio: .5,
|
|
15301
15467
|
windowRatio: .4,
|
|
@@ -15317,8 +15483,8 @@ var W_ = {
|
|
|
15317
15483
|
enableLLMSummary: !0
|
|
15318
15484
|
}
|
|
15319
15485
|
};
|
|
15320
|
-
function
|
|
15321
|
-
let n =
|
|
15486
|
+
function cv(e, t) {
|
|
15487
|
+
let n = sv[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15322
15488
|
return {
|
|
15323
15489
|
...n,
|
|
15324
15490
|
...r,
|
|
@@ -15335,7 +15501,7 @@ function $(e) {
|
|
|
15335
15501
|
};
|
|
15336
15502
|
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)}`;
|
|
15337
15503
|
}
|
|
15338
|
-
function
|
|
15504
|
+
function lv(e) {
|
|
15339
15505
|
return e.slice(0, 10).map((e) => {
|
|
15340
15506
|
let t = e, n = {
|
|
15341
15507
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15344,16 +15510,16 @@ function K_(e) {
|
|
|
15344
15510
|
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;
|
|
15345
15511
|
});
|
|
15346
15512
|
}
|
|
15347
|
-
function
|
|
15513
|
+
function uv(e, t) {
|
|
15348
15514
|
return $({
|
|
15349
15515
|
code: "SCHEMA_INVALID",
|
|
15350
15516
|
path: e,
|
|
15351
15517
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15352
15518
|
hint: `用 read({jsonPath:"${e}"}) 查看当前值,按 describe_data() 查看主数据 schema,修正后重试;改大对象优先用 write 的 patch 增量(只发改动部分)`,
|
|
15353
|
-
details:
|
|
15519
|
+
details: lv(t)
|
|
15354
15520
|
});
|
|
15355
15521
|
}
|
|
15356
|
-
function
|
|
15522
|
+
function dv(e, t, n) {
|
|
15357
15523
|
let r = n?.message || String(n);
|
|
15358
15524
|
return $({
|
|
15359
15525
|
code: "JSON_PARSE",
|
|
@@ -15362,18 +15528,18 @@ function J_(e, t, n) {
|
|
|
15362
15528
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15363
15529
|
});
|
|
15364
15530
|
}
|
|
15365
|
-
var
|
|
15366
|
-
function
|
|
15531
|
+
var fv = .9;
|
|
15532
|
+
function pv(e, t = {}) {
|
|
15367
15533
|
let n = Object.create(null);
|
|
15368
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15534
|
+
if (e) for (let [t, r] of Object.entries(e)) n[gv(t)] = {
|
|
15369
15535
|
content: r,
|
|
15370
|
-
updatedAt:
|
|
15536
|
+
updatedAt: vv()
|
|
15371
15537
|
};
|
|
15372
15538
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15373
15539
|
function a() {
|
|
15374
|
-
if (
|
|
15375
|
-
let e = i *
|
|
15376
|
-
for (let [r] of t) if (delete n[r],
|
|
15540
|
+
if (hv(n) <= i) return;
|
|
15541
|
+
let e = i * fv, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15542
|
+
for (let [r] of t) if (delete n[r], hv(n) <= e) break;
|
|
15377
15543
|
}
|
|
15378
15544
|
let o = null;
|
|
15379
15545
|
function s() {
|
|
@@ -15398,7 +15564,7 @@ function X_(e, t = {}) {
|
|
|
15398
15564
|
}
|
|
15399
15565
|
}) };
|
|
15400
15566
|
return r && (l.hydrate = (e) => {
|
|
15401
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15567
|
+
for (let [t, r] of Object.entries(e)) n[gv(t)] = r;
|
|
15402
15568
|
a();
|
|
15403
15569
|
}, l.flush = () => {
|
|
15404
15570
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15407,17 +15573,17 @@ function X_(e, t = {}) {
|
|
|
15407
15573
|
c();
|
|
15408
15574
|
}), l;
|
|
15409
15575
|
}
|
|
15410
|
-
var
|
|
15411
|
-
function
|
|
15412
|
-
|
|
15576
|
+
var mv = null;
|
|
15577
|
+
function hv(e) {
|
|
15578
|
+
mv ||= new TextEncoder();
|
|
15413
15579
|
let t = 0;
|
|
15414
|
-
for (let n of Object.values(e)) t +=
|
|
15580
|
+
for (let n of Object.values(e)) t += mv.encode(n.content).length;
|
|
15415
15581
|
return t;
|
|
15416
15582
|
}
|
|
15417
|
-
function
|
|
15583
|
+
function gv(e) {
|
|
15418
15584
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15419
15585
|
}
|
|
15420
|
-
function
|
|
15586
|
+
function _v(e) {
|
|
15421
15587
|
let t = "";
|
|
15422
15588
|
for (let n = 0; n < e.length; n++) {
|
|
15423
15589
|
let r = e[n];
|
|
@@ -15425,13 +15591,13 @@ function ev(e) {
|
|
|
15425
15591
|
}
|
|
15426
15592
|
return RegExp("^" + t + "$");
|
|
15427
15593
|
}
|
|
15428
|
-
function
|
|
15594
|
+
function vv() {
|
|
15429
15595
|
return Date.now();
|
|
15430
15596
|
}
|
|
15431
|
-
function
|
|
15597
|
+
function yv(e) {
|
|
15432
15598
|
return [
|
|
15433
15599
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15434
|
-
let i = e.files[
|
|
15600
|
+
let i = e.files[gv(t)];
|
|
15435
15601
|
if (!i) return $({
|
|
15436
15602
|
code: "NOT_FOUND",
|
|
15437
15603
|
path: t,
|
|
@@ -15449,9 +15615,9 @@ function nv(e) {
|
|
|
15449
15615
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15450
15616
|
})
|
|
15451
15617
|
}),
|
|
15452
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15618
|
+
n(async ({ path: t, content: n }) => (e.files[gv(t)] = {
|
|
15453
15619
|
content: n,
|
|
15454
|
-
updatedAt:
|
|
15620
|
+
updatedAt: vv()
|
|
15455
15621
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15456
15622
|
name: "vfs_write",
|
|
15457
15623
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15461,7 +15627,7 @@ function nv(e) {
|
|
|
15461
15627
|
})
|
|
15462
15628
|
}),
|
|
15463
15629
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15464
|
-
let i =
|
|
15630
|
+
let i = gv(t), a = e.files[i];
|
|
15465
15631
|
if (!a) return $({
|
|
15466
15632
|
code: "NOT_FOUND",
|
|
15467
15633
|
path: t,
|
|
@@ -15491,7 +15657,7 @@ function nv(e) {
|
|
|
15491
15657
|
}
|
|
15492
15658
|
return e.files[i] = {
|
|
15493
15659
|
content: a.content.replace(n, r),
|
|
15494
|
-
updatedAt:
|
|
15660
|
+
updatedAt: vv()
|
|
15495
15661
|
}, `已替换 ${t} 中 1 处。`;
|
|
15496
15662
|
}, {
|
|
15497
15663
|
name: "vfs_edit",
|
|
@@ -15513,7 +15679,7 @@ function nv(e) {
|
|
|
15513
15679
|
n(async ({ pattern: t }) => {
|
|
15514
15680
|
let n;
|
|
15515
15681
|
try {
|
|
15516
|
-
n =
|
|
15682
|
+
n = _v(t);
|
|
15517
15683
|
} catch (e) {
|
|
15518
15684
|
return $({
|
|
15519
15685
|
code: "GLOB_INVALID",
|
|
@@ -15542,7 +15708,7 @@ function nv(e) {
|
|
|
15542
15708
|
details: { pattern: t }
|
|
15543
15709
|
});
|
|
15544
15710
|
}
|
|
15545
|
-
let i = n ? [
|
|
15711
|
+
let i = n ? [gv(n)] : Object.keys(e.files), a = [];
|
|
15546
15712
|
for (let t of i) {
|
|
15547
15713
|
let n = e.files[t];
|
|
15548
15714
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15560,17 +15726,17 @@ function nv(e) {
|
|
|
15560
15726
|
})
|
|
15561
15727
|
];
|
|
15562
15728
|
}
|
|
15563
|
-
function
|
|
15729
|
+
function bv(e) {
|
|
15564
15730
|
return {
|
|
15565
15731
|
name: "vfs",
|
|
15566
|
-
tools:
|
|
15732
|
+
tools: yv(e),
|
|
15567
15733
|
beforeAgent: () => ({ files: e.files })
|
|
15568
15734
|
};
|
|
15569
15735
|
}
|
|
15570
15736
|
//#endregion
|
|
15571
15737
|
//#region src/core/tools/dataSlotQuery.ts
|
|
15572
|
-
var
|
|
15573
|
-
function
|
|
15738
|
+
var xv = /[\w$-]/;
|
|
15739
|
+
function Sv(e) {
|
|
15574
15740
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15575
15741
|
for (; r < n.length;) {
|
|
15576
15742
|
let e = n[r];
|
|
@@ -15581,7 +15747,7 @@ function av(e) {
|
|
|
15581
15747
|
continue;
|
|
15582
15748
|
}
|
|
15583
15749
|
let e = "";
|
|
15584
|
-
for (; r < n.length &&
|
|
15750
|
+
for (; r < n.length && xv.test(n[r]);) e += n[r++];
|
|
15585
15751
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15586
15752
|
t.push({
|
|
15587
15753
|
type: "descendKey",
|
|
@@ -15594,7 +15760,7 @@ function av(e) {
|
|
|
15594
15760
|
continue;
|
|
15595
15761
|
}
|
|
15596
15762
|
let e = "";
|
|
15597
|
-
for (; r < n.length &&
|
|
15763
|
+
for (; r < n.length && xv.test(n[r]);) e += n[r++];
|
|
15598
15764
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15599
15765
|
t.push({
|
|
15600
15766
|
type: "key",
|
|
@@ -15650,7 +15816,7 @@ function av(e) {
|
|
|
15650
15816
|
}
|
|
15651
15817
|
return t;
|
|
15652
15818
|
}
|
|
15653
|
-
function
|
|
15819
|
+
function Cv(e) {
|
|
15654
15820
|
let t = [], n = 0, r = e.trim();
|
|
15655
15821
|
for (; n < r.length;) {
|
|
15656
15822
|
let e = r[n];
|
|
@@ -15695,7 +15861,7 @@ function ov(e) {
|
|
|
15695
15861
|
}
|
|
15696
15862
|
return t;
|
|
15697
15863
|
}
|
|
15698
|
-
var
|
|
15864
|
+
var wv = class {
|
|
15699
15865
|
toks;
|
|
15700
15866
|
item;
|
|
15701
15867
|
pos = 0;
|
|
@@ -15731,12 +15897,12 @@ var sv = class {
|
|
|
15731
15897
|
return this.next(), e;
|
|
15732
15898
|
}
|
|
15733
15899
|
let e = this.operand(), t = this.peek();
|
|
15734
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15900
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), Dv(t, e, this.operand())) : Tv(e);
|
|
15735
15901
|
}
|
|
15736
15902
|
operand() {
|
|
15737
15903
|
let e = this.next();
|
|
15738
15904
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15739
|
-
if (e.startsWith("@")) return
|
|
15905
|
+
if (e.startsWith("@")) return Ev(e, this.item);
|
|
15740
15906
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15741
15907
|
if (e === "true") return !0;
|
|
15742
15908
|
if (e === "false") return !1;
|
|
@@ -15746,10 +15912,10 @@ var sv = class {
|
|
|
15746
15912
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15747
15913
|
}
|
|
15748
15914
|
};
|
|
15749
|
-
function
|
|
15915
|
+
function Tv(e) {
|
|
15750
15916
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15751
15917
|
}
|
|
15752
|
-
function
|
|
15918
|
+
function Ev(e, t) {
|
|
15753
15919
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15754
15920
|
for (let e of n) {
|
|
15755
15921
|
if (typeof r != "object" || !r) return;
|
|
@@ -15757,7 +15923,7 @@ function lv(e, t) {
|
|
|
15757
15923
|
}
|
|
15758
15924
|
return r;
|
|
15759
15925
|
}
|
|
15760
|
-
function
|
|
15926
|
+
function Dv(e, t, n) {
|
|
15761
15927
|
switch (e) {
|
|
15762
15928
|
case "==": return t === n;
|
|
15763
15929
|
case "!=": return t !== n;
|
|
@@ -15768,47 +15934,47 @@ function uv(e, t, n) {
|
|
|
15768
15934
|
default: return !1;
|
|
15769
15935
|
}
|
|
15770
15936
|
}
|
|
15771
|
-
function
|
|
15772
|
-
return new
|
|
15937
|
+
function Ov(e, t) {
|
|
15938
|
+
return new wv(Cv(e), t).parse();
|
|
15773
15939
|
}
|
|
15774
|
-
function
|
|
15940
|
+
function kv(e, t) {
|
|
15775
15941
|
return e ? `${e}.${t}` : String(t);
|
|
15776
15942
|
}
|
|
15777
|
-
function
|
|
15943
|
+
function Av(e, t) {
|
|
15778
15944
|
let n = [{
|
|
15779
15945
|
path: "",
|
|
15780
15946
|
value: e
|
|
15781
15947
|
}];
|
|
15782
|
-
for (let e of
|
|
15948
|
+
for (let e of Sv(t)) {
|
|
15783
15949
|
let t = [];
|
|
15784
15950
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15785
|
-
path:
|
|
15951
|
+
path: kv(r.path, e.key),
|
|
15786
15952
|
value: r.value[e.key]
|
|
15787
15953
|
});
|
|
15788
15954
|
else if (e.type === "index") {
|
|
15789
15955
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15790
15956
|
let n = r.value[e.index];
|
|
15791
15957
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15792
|
-
path:
|
|
15958
|
+
path: kv(r.path, e.index),
|
|
15793
15959
|
value: n,
|
|
15794
15960
|
index: e.index
|
|
15795
15961
|
});
|
|
15796
15962
|
}
|
|
15797
15963
|
} else if (e.type === "wildcard") {
|
|
15798
15964
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15799
|
-
path:
|
|
15965
|
+
path: kv(e.path, r),
|
|
15800
15966
|
value: n,
|
|
15801
15967
|
index: r
|
|
15802
15968
|
}));
|
|
15803
15969
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15804
|
-
path:
|
|
15970
|
+
path: kv(e.path, n),
|
|
15805
15971
|
value: e.value[n]
|
|
15806
15972
|
});
|
|
15807
15973
|
} else if (e.type === "descendKey") {
|
|
15808
15974
|
let r = e.key, i = (e) => {
|
|
15809
15975
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15810
15976
|
let a = {
|
|
15811
|
-
path:
|
|
15977
|
+
path: kv(e.path, n),
|
|
15812
15978
|
value: e.value[n]
|
|
15813
15979
|
};
|
|
15814
15980
|
n === r && t.push(a), i(a);
|
|
@@ -15819,7 +15985,7 @@ function pv(e, t) {
|
|
|
15819
15985
|
let e = (n) => {
|
|
15820
15986
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15821
15987
|
let i = {
|
|
15822
|
-
path:
|
|
15988
|
+
path: kv(n.path, r),
|
|
15823
15989
|
value: n.value[r]
|
|
15824
15990
|
};
|
|
15825
15991
|
t.push(i), e(i);
|
|
@@ -15828,16 +15994,16 @@ function pv(e, t) {
|
|
|
15828
15994
|
for (let t of n) e(t);
|
|
15829
15995
|
} else if (e.type === "filter") {
|
|
15830
15996
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15831
|
-
|
|
15832
|
-
path:
|
|
15997
|
+
Ov(e.filter, n) && t.push({
|
|
15998
|
+
path: kv(r.path, i),
|
|
15833
15999
|
value: n,
|
|
15834
16000
|
index: i
|
|
15835
16001
|
});
|
|
15836
16002
|
});
|
|
15837
16003
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15838
16004
|
let i = r.value[n];
|
|
15839
|
-
|
|
15840
|
-
path:
|
|
16005
|
+
Ov(e.filter, i) && t.push({
|
|
16006
|
+
path: kv(r.path, n),
|
|
15841
16007
|
value: i
|
|
15842
16008
|
});
|
|
15843
16009
|
}
|
|
@@ -15846,7 +16012,7 @@ function pv(e, t) {
|
|
|
15846
16012
|
}
|
|
15847
16013
|
return n;
|
|
15848
16014
|
}
|
|
15849
|
-
function
|
|
16015
|
+
function jv(e, t) {
|
|
15850
16016
|
let n = e.length, r = t.length;
|
|
15851
16017
|
if (!n) return r;
|
|
15852
16018
|
if (!r) return n;
|
|
@@ -15862,7 +16028,7 @@ function mv(e, t) {
|
|
|
15862
16028
|
}
|
|
15863
16029
|
return i[r];
|
|
15864
16030
|
}
|
|
15865
|
-
function
|
|
16031
|
+
function Mv(e, t, n = {}) {
|
|
15866
16032
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15867
16033
|
if (r === "regex") try {
|
|
15868
16034
|
s = new RegExp(t, "i");
|
|
@@ -15872,11 +16038,11 @@ function hv(e, t, n = {}) {
|
|
|
15872
16038
|
let c = (e, l, u) => {
|
|
15873
16039
|
if (o.length >= i || e == null) return;
|
|
15874
16040
|
if (typeof e == "object") {
|
|
15875
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15876
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
16041
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, kv(l, t), String(t)));
|
|
16042
|
+
else for (let t of Object.keys(e)) c(e[t], kv(l, t), t);
|
|
15877
16043
|
return;
|
|
15878
16044
|
}
|
|
15879
|
-
let d = String(e), f =
|
|
16045
|
+
let d = String(e), f = Nv(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15880
16046
|
if (f) {
|
|
15881
16047
|
o.push({
|
|
15882
16048
|
path: l,
|
|
@@ -15887,7 +16053,7 @@ function hv(e, t, n = {}) {
|
|
|
15887
16053
|
return;
|
|
15888
16054
|
}
|
|
15889
16055
|
if (a && u) {
|
|
15890
|
-
let e =
|
|
16056
|
+
let e = Nv(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15891
16057
|
e && o.push({
|
|
15892
16058
|
path: l,
|
|
15893
16059
|
key: u,
|
|
@@ -15898,18 +16064,18 @@ function hv(e, t, n = {}) {
|
|
|
15898
16064
|
};
|
|
15899
16065
|
return c(e, ""), o;
|
|
15900
16066
|
}
|
|
15901
|
-
function
|
|
16067
|
+
function Nv(e, t, n, r, i) {
|
|
15902
16068
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15903
16069
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15904
16070
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15905
16071
|
if (n === "fuzzy") {
|
|
15906
16072
|
if (a.includes(o)) return 2;
|
|
15907
|
-
let e =
|
|
16073
|
+
let e = jv(a, o);
|
|
15908
16074
|
return e <= r ? r - e + 1 : null;
|
|
15909
16075
|
}
|
|
15910
16076
|
return null;
|
|
15911
16077
|
}
|
|
15912
|
-
var
|
|
16078
|
+
var Pv = [
|
|
15913
16079
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15914
16080
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15915
16081
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15922,7 +16088,7 @@ var _v = [
|
|
|
15922
16088
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15923
16089
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15924
16090
|
].join("\n");
|
|
15925
|
-
function
|
|
16091
|
+
function Fv(e, t, n = 3e3) {
|
|
15926
16092
|
return new Promise((r) => {
|
|
15927
16093
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15928
16094
|
if (!a) {
|
|
@@ -15935,7 +16101,7 @@ function vv(e, t, n = 3e3) {
|
|
|
15935
16101
|
elapsedMs: Date.now() - i
|
|
15936
16102
|
});
|
|
15937
16103
|
}
|
|
15938
|
-
}, s =
|
|
16104
|
+
}, s = Pv + "\nself.onmessage = async (e) => {\n try {\n const fn = new Function(\"data\", e.data.script);\n let result = fn(e.data.data);\n if (result && typeof result.then === \"function\") result = await result;\n self.postMessage({ ok: true, result });\n } catch (err) {\n self.postMessage({ ok: false, error: String((err && err.message) || err) });\n }\n};", c, l;
|
|
15939
16105
|
try {
|
|
15940
16106
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15941
16107
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15970,20 +16136,20 @@ function vv(e, t, n = 3e3) {
|
|
|
15970
16136
|
}
|
|
15971
16137
|
//#endregion
|
|
15972
16138
|
//#region src/core/tools/dataOps.ts
|
|
15973
|
-
var
|
|
16139
|
+
var Iv = /* @__PURE__ */ new Set([
|
|
15974
16140
|
"__proto__",
|
|
15975
16141
|
"constructor",
|
|
15976
16142
|
"prototype"
|
|
15977
16143
|
]);
|
|
15978
|
-
function
|
|
15979
|
-
return e.split(".").some((e) =>
|
|
16144
|
+
function Lv(e) {
|
|
16145
|
+
return e.split(".").some((e) => Iv.has(e));
|
|
15980
16146
|
}
|
|
15981
|
-
function
|
|
15982
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t))
|
|
16147
|
+
function Rv(e, t) {
|
|
16148
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) Iv.has(n) || (e[n] = t[n]);
|
|
15983
16149
|
}
|
|
15984
|
-
function
|
|
16150
|
+
function zv(e, t) {
|
|
15985
16151
|
if (!t) return e;
|
|
15986
|
-
if (
|
|
16152
|
+
if (Lv(t)) return;
|
|
15987
16153
|
let n = t.split("."), r = e;
|
|
15988
16154
|
for (let e of n) {
|
|
15989
16155
|
if (r == null) return;
|
|
@@ -15991,8 +16157,8 @@ function Sv(e, t) {
|
|
|
15991
16157
|
}
|
|
15992
16158
|
return r;
|
|
15993
16159
|
}
|
|
15994
|
-
function
|
|
15995
|
-
if (!t ||
|
|
16160
|
+
function Bv(e, t, n) {
|
|
16161
|
+
if (!t || Lv(t)) return;
|
|
15996
16162
|
let r = t.split("."), i = e;
|
|
15997
16163
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15998
16164
|
let t = r[e];
|
|
@@ -16000,8 +16166,8 @@ function Cv(e, t, n) {
|
|
|
16000
16166
|
}
|
|
16001
16167
|
i[r[r.length - 1]] = n;
|
|
16002
16168
|
}
|
|
16003
|
-
function
|
|
16004
|
-
if (!t ||
|
|
16169
|
+
function Vv(e, t) {
|
|
16170
|
+
if (!t || Lv(t)) return !1;
|
|
16005
16171
|
let n = t.split("."), r = e;
|
|
16006
16172
|
for (let e = 0; e < n.length - 1; e++) {
|
|
16007
16173
|
if (r == null) return !1;
|
|
@@ -16010,10 +16176,10 @@ function wv(e, t) {
|
|
|
16010
16176
|
let i = n[n.length - 1];
|
|
16011
16177
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
16012
16178
|
}
|
|
16013
|
-
function
|
|
16179
|
+
function Hv(e) {
|
|
16014
16180
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
16015
16181
|
}
|
|
16016
|
-
function
|
|
16182
|
+
function Uv(e) {
|
|
16017
16183
|
if (typeof e != "string") return { parsed: e };
|
|
16018
16184
|
let t = e.trim();
|
|
16019
16185
|
if (!t) return { parsed: e };
|
|
@@ -16024,23 +16190,23 @@ function Ev(e) {
|
|
|
16024
16190
|
return n ? { parseError: t } : { parsed: e };
|
|
16025
16191
|
}
|
|
16026
16192
|
}
|
|
16027
|
-
function
|
|
16193
|
+
function Wv(e, t) {
|
|
16028
16194
|
if (typeof e != "object" || !e) return e;
|
|
16029
16195
|
let n = new Set(t);
|
|
16030
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
16196
|
+
if (Array.isArray(e)) return e.map((e) => Wv(e, t));
|
|
16031
16197
|
let r = {};
|
|
16032
16198
|
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
16033
16199
|
return r;
|
|
16034
16200
|
}
|
|
16035
|
-
function
|
|
16201
|
+
function Gv(e, t) {
|
|
16036
16202
|
if (typeof e != "object" || !e) return e;
|
|
16037
16203
|
if (t <= 0) return Array.isArray(e) ? `[...${e.length}]` : "{...}";
|
|
16038
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
16204
|
+
if (Array.isArray(e)) return e.map((e) => Gv(e, t - 1));
|
|
16039
16205
|
let n = {};
|
|
16040
|
-
for (let r of Object.keys(e)) n[r] =
|
|
16206
|
+
for (let r of Object.keys(e)) n[r] = Gv(e[r], t - 1);
|
|
16041
16207
|
return n;
|
|
16042
16208
|
}
|
|
16043
|
-
function
|
|
16209
|
+
function Kv(e, t = Infinity) {
|
|
16044
16210
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
16045
16211
|
try {
|
|
16046
16212
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -16059,12 +16225,12 @@ function kv(e, t = Infinity) {
|
|
|
16059
16225
|
}
|
|
16060
16226
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
16061
16227
|
}
|
|
16062
|
-
function
|
|
16063
|
-
let t =
|
|
16228
|
+
function qv(e) {
|
|
16229
|
+
let t = Kv(e), n = 5381;
|
|
16064
16230
|
for (let e = 0; e < t.length; e++) n = (n << 5) + n + t.charCodeAt(e) >>> 0;
|
|
16065
16231
|
return n.toString(36);
|
|
16066
16232
|
}
|
|
16067
|
-
function
|
|
16233
|
+
function Jv(e) {
|
|
16068
16234
|
let t = e;
|
|
16069
16235
|
for (let e = 0; e < 5 && t && t._def; e++) {
|
|
16070
16236
|
if (t._def.innerType) {
|
|
@@ -16081,12 +16247,12 @@ function jv(e) {
|
|
|
16081
16247
|
return null;
|
|
16082
16248
|
}
|
|
16083
16249
|
}
|
|
16084
|
-
function
|
|
16250
|
+
function Yv(e, t, n) {
|
|
16085
16251
|
if (!n || !e) return !0;
|
|
16086
|
-
let r =
|
|
16252
|
+
let r = Xv(t);
|
|
16087
16253
|
for (let t of e.split(".")) {
|
|
16088
16254
|
if (!r) return !1;
|
|
16089
|
-
if (r =
|
|
16255
|
+
if (r = Xv(r), r && r.shape && typeof r.shape == "object") {
|
|
16090
16256
|
let e = typeof r.shape == "function" ? r.shape() : r.shape;
|
|
16091
16257
|
if (!(t in e)) return !1;
|
|
16092
16258
|
r = e[t];
|
|
@@ -16095,7 +16261,7 @@ function Mv(e, t, n) {
|
|
|
16095
16261
|
}
|
|
16096
16262
|
return !0;
|
|
16097
16263
|
}
|
|
16098
|
-
function
|
|
16264
|
+
function Xv(e) {
|
|
16099
16265
|
let t = e;
|
|
16100
16266
|
for (let e = 0; e < 8 && t && t._def; e++) {
|
|
16101
16267
|
if (t._def.innerType) {
|
|
@@ -16114,63 +16280,63 @@ function Nv(e) {
|
|
|
16114
16280
|
}
|
|
16115
16281
|
return t;
|
|
16116
16282
|
}
|
|
16117
|
-
function
|
|
16283
|
+
function Zv(e, t) {
|
|
16118
16284
|
if (!t) return e;
|
|
16119
|
-
let n =
|
|
16285
|
+
let n = Xv(e), r = t.split(".");
|
|
16120
16286
|
for (let e of r) {
|
|
16121
16287
|
if (!n) return null;
|
|
16122
|
-
if (n =
|
|
16288
|
+
if (n = Xv(n), n && n.shape && typeof n.shape == "object") n = (typeof n.shape == "function" ? n.shape() : n.shape)[e];
|
|
16123
16289
|
else if (n && (n._def?.type || n.element)) n = n.element ?? n._def?.type;
|
|
16124
16290
|
else return null;
|
|
16125
16291
|
}
|
|
16126
16292
|
return n ?? null;
|
|
16127
16293
|
}
|
|
16128
|
-
function
|
|
16294
|
+
function Qv(e, t) {
|
|
16129
16295
|
if (typeof e != "object" || !e || !t) return e;
|
|
16130
|
-
let n =
|
|
16296
|
+
let n = Xv(t);
|
|
16131
16297
|
if (!n || !n.shape) {
|
|
16132
16298
|
if (Array.isArray(e) && (n?._def?.type || n?.element)) {
|
|
16133
16299
|
let t = n.element ?? n._def?.type;
|
|
16134
|
-
return e.map((e) =>
|
|
16300
|
+
return e.map((e) => Qv(e, t));
|
|
16135
16301
|
}
|
|
16136
16302
|
return e;
|
|
16137
16303
|
}
|
|
16138
16304
|
let r = typeof n.shape == "function" ? n.shape() : n.shape, i = {};
|
|
16139
16305
|
for (let t of Object.keys(e)) if (t in r) {
|
|
16140
16306
|
let n = e[t];
|
|
16141
|
-
i[t] =
|
|
16307
|
+
i[t] = Qv(n, r[t]);
|
|
16142
16308
|
}
|
|
16143
16309
|
return i;
|
|
16144
16310
|
}
|
|
16145
|
-
function
|
|
16311
|
+
function $v(e, t) {
|
|
16146
16312
|
if (!t || typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
16147
16313
|
let n = new Set(t), r = {};
|
|
16148
16314
|
for (let t of Object.keys(e)) n.has(t) && (r[t] = e[t]);
|
|
16149
16315
|
return r;
|
|
16150
16316
|
}
|
|
16151
|
-
function
|
|
16152
|
-
if (t === "set") return n ? (
|
|
16153
|
-
if (t === "remove") return n ? (
|
|
16317
|
+
function ey(e, t, n, r) {
|
|
16318
|
+
if (t === "set") return n ? (Bv(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_data)";
|
|
16319
|
+
if (t === "remove") return n ? (Vv(e, n), null) : "remove 操作需要 jsonPath";
|
|
16154
16320
|
if (t === "merge") {
|
|
16155
|
-
let t = n ?
|
|
16156
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
16321
|
+
let t = n ? zv(e, n) : e;
|
|
16322
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (Rv(t, r), null);
|
|
16157
16323
|
}
|
|
16158
|
-
let i = n ?
|
|
16324
|
+
let i = n ? zv(e, n) : e;
|
|
16159
16325
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
16160
16326
|
}
|
|
16161
|
-
function
|
|
16162
|
-
if (t === "set")
|
|
16163
|
-
else if (t === "remove")
|
|
16164
|
-
else if (t === "merge")
|
|
16327
|
+
function ty(e, t, n, r) {
|
|
16328
|
+
if (t === "set") Bv(e, n, r);
|
|
16329
|
+
else if (t === "remove") Vv(e, n);
|
|
16330
|
+
else if (t === "merge") Rv(n ? zv(e, n) : e, r);
|
|
16165
16331
|
else {
|
|
16166
|
-
let t = n ?
|
|
16332
|
+
let t = n ? zv(e, n) : e;
|
|
16167
16333
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
16168
16334
|
}
|
|
16169
16335
|
}
|
|
16170
|
-
function
|
|
16171
|
-
typeof e == "object" && e &&
|
|
16336
|
+
function ny(e, t) {
|
|
16337
|
+
typeof e == "object" && e && ry(e, t);
|
|
16172
16338
|
}
|
|
16173
|
-
function
|
|
16339
|
+
function ry(e, t) {
|
|
16174
16340
|
if (Array.isArray(e)) {
|
|
16175
16341
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
16176
16342
|
return;
|
|
@@ -16179,25 +16345,25 @@ function Bv(e, t) {
|
|
|
16179
16345
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
16180
16346
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
16181
16347
|
}
|
|
16182
|
-
var
|
|
16348
|
+
var iy = /* @__PURE__ */ new Set([
|
|
16183
16349
|
"describe_data",
|
|
16184
16350
|
"get_data",
|
|
16185
16351
|
"set_data",
|
|
16186
16352
|
"edit_data",
|
|
16187
16353
|
"delete_data"
|
|
16188
|
-
]),
|
|
16189
|
-
function
|
|
16190
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
16354
|
+
]), ay = /* @__PURE__ */ new Set(["read", "write"]);
|
|
16355
|
+
function oy(e, t = "simple") {
|
|
16356
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => ay.has(e.name)) : e.filter((e) => !iy.has(e.name));
|
|
16191
16357
|
}
|
|
16192
|
-
function
|
|
16193
|
-
let i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s =
|
|
16358
|
+
function sy(e, r = {}) {
|
|
16359
|
+
let i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = Jv(i), c = [], l = r.maxSnapshots ?? 20, u, d = r.autoLock !== !1, f = {
|
|
16194
16360
|
get: () => ({
|
|
16195
16361
|
schema: i,
|
|
16196
16362
|
bind: a,
|
|
16197
16363
|
description: o
|
|
16198
16364
|
}),
|
|
16199
16365
|
set: (e) => {
|
|
16200
|
-
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s =
|
|
16366
|
+
i = e.schema, a = e.bind, o = e.description ?? "主数据对象", s = Jv(i), c.length = 0, u = void 0;
|
|
16201
16367
|
},
|
|
16202
16368
|
update: (e) => {
|
|
16203
16369
|
a = e, c.length = 0, u = void 0;
|
|
@@ -16206,7 +16372,7 @@ function Wv(e, r = {}) {
|
|
|
16206
16372
|
r.onAudit?.(e);
|
|
16207
16373
|
};
|
|
16208
16374
|
function m(e, t) {
|
|
16209
|
-
let n =
|
|
16375
|
+
let n = Hv(a), r = c.length ? c[c.length - 1].id + 1 : 1;
|
|
16210
16376
|
for (c.push({
|
|
16211
16377
|
id: r,
|
|
16212
16378
|
ts: Date.now(),
|
|
@@ -16218,12 +16384,12 @@ function Wv(e, r = {}) {
|
|
|
16218
16384
|
}
|
|
16219
16385
|
async function h(e, t, n) {
|
|
16220
16386
|
if (!t || t === "") return null;
|
|
16221
|
-
let i =
|
|
16387
|
+
let i = qv(a);
|
|
16222
16388
|
if (i === t) return null;
|
|
16223
16389
|
if (!r.onConflict) return $({
|
|
16224
16390
|
code: "VERSION_CONFLICT",
|
|
16225
16391
|
message: `乐观锁冲突:expectedHash=${t} 但当前 hash=${i}。主数据在你 read 之后已被修改(外部代码/其他 agent/用户手动改)。`,
|
|
16226
|
-
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${
|
|
16392
|
+
hint: `重新 read 拿最新值与 hash,基于最新值修改后再写入(传新的 expectedHash)。当前值:${Kv(a, 400)}`
|
|
16227
16393
|
});
|
|
16228
16394
|
let o = await r.onConflict({
|
|
16229
16395
|
op: e,
|
|
@@ -16233,11 +16399,11 @@ function Wv(e, r = {}) {
|
|
|
16233
16399
|
expectedHash: t,
|
|
16234
16400
|
snapshotId: 0
|
|
16235
16401
|
});
|
|
16236
|
-
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${
|
|
16402
|
+
if (o.action === "keep_external") return `已保留外部修改(未写入)。当前值:${Kv(a, 400)} (hash=${i})。请重新 read 拿最新值与 hash 再改。`;
|
|
16237
16403
|
if (o.action === "restore") {
|
|
16238
|
-
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${
|
|
16404
|
+
if (!c.length) return `无历史快照可回退(本次为首次操作)。当前值:${Kv(a, 400)} (hash=${i})。请重新 read 再改或选「强制覆盖」。`;
|
|
16239
16405
|
let e = c[c.length - 1];
|
|
16240
|
-
return
|
|
16406
|
+
return ny(a, Hv(e.value)), `已回退主数据到历史快照 #${e.id}[${e.op}]。当前值:${Kv(a, 400)} (hash=${qv(a)})。请基于回退后的值重写或停止。`;
|
|
16241
16407
|
}
|
|
16242
16408
|
return null;
|
|
16243
16409
|
}
|
|
@@ -16249,15 +16415,15 @@ function Wv(e, r = {}) {
|
|
|
16249
16415
|
}),
|
|
16250
16416
|
n(async ({ jsonPath: e }) => {
|
|
16251
16417
|
let t = e || "";
|
|
16252
|
-
if (!
|
|
16418
|
+
if (!Yv(t, i, s)) return $({
|
|
16253
16419
|
code: "PATH_DENIED",
|
|
16254
16420
|
message: `get_data @ "${t}" 不在 schema 声明字段内(仅 schema 声明的 key 可读)`,
|
|
16255
16421
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
16256
16422
|
});
|
|
16257
|
-
let n = t ?
|
|
16258
|
-
t || (n =
|
|
16259
|
-
let r =
|
|
16260
|
-
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${
|
|
16423
|
+
let n = t ? zv(a, t) : a;
|
|
16424
|
+
t || (n = $v(n, s));
|
|
16425
|
+
let r = qv(a);
|
|
16426
|
+
return u = r, n === void 0 ? `主数据${t ? ` @ ${t}` : ""} = (undefined) (hash=${r})` : `主数据${t ? ` @ ${t}` : ""} = ${Kv(n)} (hash=${r})`;
|
|
16261
16427
|
}, {
|
|
16262
16428
|
name: "get_data",
|
|
16263
16429
|
description: "读取主数据的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。返回含 hash(乐观锁):改前先 read/get 拿 hash,写入时传 expectedHash 回传,系统对比当前 hash 防\"基于过期值覆盖\"。jsonPath 可选:读整个主数据不传,读子路径传(如 components.0.text)。",
|
|
@@ -16266,27 +16432,27 @@ function Wv(e, r = {}) {
|
|
|
16266
16432
|
n(async ({ value: e, expectedHash: t }) => {
|
|
16267
16433
|
let n = await h("set", t || (d ? u : void 0));
|
|
16268
16434
|
if (n !== null) return n;
|
|
16269
|
-
let r, o =
|
|
16270
|
-
if (o.parseError) return
|
|
16435
|
+
let r, o = Uv(e);
|
|
16436
|
+
if (o.parseError) return dv("", e, o.parseError);
|
|
16271
16437
|
r = o.parsed;
|
|
16272
16438
|
let c = i.safeParse(r);
|
|
16273
|
-
if (!c.success) return
|
|
16439
|
+
if (!c.success) return uv("", c.error.issues);
|
|
16274
16440
|
if (typeof a != "object" || !a) return $({
|
|
16275
16441
|
code: "LEAF_BIND",
|
|
16276
16442
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),set_data 无法就地替换外部持有的值引用`,
|
|
16277
16443
|
hint: "主数据 bind 必须为对象/数组(低代码主 JSON 本就是);叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
16278
16444
|
});
|
|
16279
16445
|
if (m("set"), c.data !== null && typeof c.data == "object") if (s) {
|
|
16280
|
-
if (
|
|
16446
|
+
if (Rv(a, c.data), r && typeof r == "object" && !Array.isArray(r)) {
|
|
16281
16447
|
let e = new Set(s);
|
|
16282
16448
|
for (let [t, n] of Object.entries(r)) e.has(t) || (a[t] = n);
|
|
16283
16449
|
}
|
|
16284
|
-
} else
|
|
16450
|
+
} else ry(a, c.data);
|
|
16285
16451
|
return p({
|
|
16286
16452
|
op: "set",
|
|
16287
16453
|
value: c.data,
|
|
16288
16454
|
timestamp: Date.now()
|
|
16289
|
-
}), u =
|
|
16455
|
+
}), u = qv(a), `已设置主数据 = ${Kv(c.data, 600)} (新 hash=${qv(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
16290
16456
|
}, {
|
|
16291
16457
|
name: "set_data",
|
|
16292
16458
|
description: "设置主数据的值(整体替换)。value 为 JSON 对象(或 JSON 字符串),需通过 schema 校验。校验失败会返回错误而非写入。expectedHash(可选):改前 read/get 返回的 hash,传入则启用乐观锁;不传时系统自动用你最后一次读到的 hash 比对(autoLock,默认开)。大对象/数组强烈建议改用 edit_data 增量 patch。",
|
|
@@ -16297,12 +16463,12 @@ function Wv(e, r = {}) {
|
|
|
16297
16463
|
}),
|
|
16298
16464
|
n(async ({ op: e, jsonPath: t, value: n, expectedHash: r }) => {
|
|
16299
16465
|
let o = t || "";
|
|
16300
|
-
if (
|
|
16466
|
+
if (Lv(o)) return $({
|
|
16301
16467
|
code: "PATH_UNSAFE",
|
|
16302
16468
|
message: `jsonPath "${o}" 含非法段(__proto__/constructor/prototype)`,
|
|
16303
16469
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
16304
16470
|
});
|
|
16305
|
-
if (!
|
|
16471
|
+
if (!Yv(o, i, s)) return $({
|
|
16306
16472
|
code: "PATH_DENIED",
|
|
16307
16473
|
message: `edit_data @ "${o}" 不在 schema 声明字段内`,
|
|
16308
16474
|
hint: "仅 schema 声明的 key 可写;若需操作该字段,集成方需在 schema 中声明它"
|
|
@@ -16321,23 +16487,23 @@ function Wv(e, r = {}) {
|
|
|
16321
16487
|
message: `${e} 操作需要 value`,
|
|
16322
16488
|
hint: `op 为 ${e} 时 value 必填;删除请用 op:'remove'`
|
|
16323
16489
|
});
|
|
16324
|
-
let t =
|
|
16325
|
-
if (t.parseError) return
|
|
16490
|
+
let t = Uv(n);
|
|
16491
|
+
if (t.parseError) return dv("", n, t.parseError);
|
|
16326
16492
|
l = t.parsed;
|
|
16327
16493
|
}
|
|
16328
|
-
let f =
|
|
16494
|
+
let f = Hv(a), g = ey(f, e, o, l);
|
|
16329
16495
|
if (g) return $({
|
|
16330
16496
|
code: "PATCH_FAILED",
|
|
16331
16497
|
message: g,
|
|
16332
16498
|
hint: "检查 op 与目标类型:merge 需对象,append 需数组;jsonPath 指向需存在"
|
|
16333
16499
|
});
|
|
16334
16500
|
let _ = i.safeParse(f);
|
|
16335
|
-
return _.success ? (m("edit"),
|
|
16501
|
+
return _.success ? (m("edit"), ty(a, e, o, l), p({
|
|
16336
16502
|
op: "edit",
|
|
16337
16503
|
detail: `${e}${o ? "@" + o : ""}`,
|
|
16338
16504
|
value: l,
|
|
16339
16505
|
timestamp: Date.now()
|
|
16340
|
-
}), u =
|
|
16506
|
+
}), u = qv(a), `已 edit 主数据(${e}${o ? " @ " + o : ""})。当前值:${Kv(a, 600)} (新 hash=${qv(a)})`) : uv("", _.error.issues);
|
|
16341
16507
|
}, {
|
|
16342
16508
|
name: "edit_data",
|
|
16343
16509
|
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,默认开)防\"基于过期值覆盖\"。",
|
|
@@ -16359,12 +16525,12 @@ function Wv(e, r = {}) {
|
|
|
16359
16525
|
message: "delete_data 需要 jsonPath 指定要删的子路径(主数据整体不可删,用 set_data 整体替换)",
|
|
16360
16526
|
hint: "如 jsonPath:\"components.0\" 删数组首项"
|
|
16361
16527
|
});
|
|
16362
|
-
if (
|
|
16528
|
+
if (Lv(e)) return $({
|
|
16363
16529
|
code: "PATH_UNSAFE",
|
|
16364
16530
|
message: `jsonPath "${e}" 含非法段`,
|
|
16365
16531
|
hint: "使用正常属性路径"
|
|
16366
16532
|
});
|
|
16367
|
-
if (!
|
|
16533
|
+
if (!Yv(e, i, s)) return $({
|
|
16368
16534
|
code: "PATH_DENIED",
|
|
16369
16535
|
message: `delete_data @ "${e}" 不在 schema 声明字段内`,
|
|
16370
16536
|
hint: "仅 schema 声明的 key 可删"
|
|
@@ -16372,12 +16538,12 @@ function Wv(e, r = {}) {
|
|
|
16372
16538
|
let n = await h("delete", t || (d ? u : void 0));
|
|
16373
16539
|
if (n !== null) return n;
|
|
16374
16540
|
m("delete");
|
|
16375
|
-
let r =
|
|
16541
|
+
let r = Vv(a, e);
|
|
16376
16542
|
return p({
|
|
16377
16543
|
op: "delete",
|
|
16378
16544
|
detail: e,
|
|
16379
16545
|
timestamp: Date.now()
|
|
16380
|
-
}), u =
|
|
16546
|
+
}), u = qv(a), r ? `已删除主数据 @ ${e}` : `主数据 @ ${e} 不存在(无需删除)`;
|
|
16381
16547
|
}, {
|
|
16382
16548
|
name: "delete_data",
|
|
16383
16549
|
description: "删除主数据的某个子路径(jsonPath)。主数据整体不可删(用 set_data 整体替换)。expectedHash(可选):改前 read/get 返回的 hash;不传时自动用你最后读到的 hash(autoLock,默认开)防\"基于过期值删除\"。",
|
|
@@ -16416,15 +16582,15 @@ function Wv(e, r = {}) {
|
|
|
16416
16582
|
hint: "用 list_data_snapshots 查看可用快照序号"
|
|
16417
16583
|
});
|
|
16418
16584
|
let n = i.safeParse(t.value);
|
|
16419
|
-
return n.success ? (
|
|
16585
|
+
return n.success ? (ny(a, Hv(t.value)), p({
|
|
16420
16586
|
op: "restore",
|
|
16421
16587
|
detail: `#${t.id}`,
|
|
16422
16588
|
timestamp: Date.now()
|
|
16423
|
-
}), u =
|
|
16589
|
+
}), u = qv(a), `已回退主数据到快照 #${t.id}[${t.op}]${t.label ? `(${t.label})` : ""}。`) : $({
|
|
16424
16590
|
code: "SNAPSHOT_SCHEMA_INVALID",
|
|
16425
16591
|
message: `快照 #${t.id} 的值不符合当前 schema,无法回退`,
|
|
16426
16592
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16427
|
-
details:
|
|
16593
|
+
details: lv(n.error.issues)
|
|
16428
16594
|
});
|
|
16429
16595
|
}, {
|
|
16430
16596
|
name: "restore_data",
|
|
@@ -16437,9 +16603,9 @@ function Wv(e, r = {}) {
|
|
|
16437
16603
|
message: `主数据不是对象/数组,无法查询(当前为 ${a === void 0 ? "undefined" : typeof a})`,
|
|
16438
16604
|
hint: "query 仅适用于对象/数组;叶子用 get_data 读"
|
|
16439
16605
|
});
|
|
16440
|
-
let n = s ?
|
|
16606
|
+
let n = s ? $v(a, s) : a, r;
|
|
16441
16607
|
try {
|
|
16442
|
-
r =
|
|
16608
|
+
r = Av(n, e);
|
|
16443
16609
|
} catch (t) {
|
|
16444
16610
|
return $({
|
|
16445
16611
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16448,7 +16614,7 @@ function Wv(e, r = {}) {
|
|
|
16448
16614
|
details: { expr: e }
|
|
16449
16615
|
});
|
|
16450
16616
|
}
|
|
16451
|
-
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":${
|
|
16617
|
+
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":${Kv(e.value)}}`);
|
|
16452
16618
|
return `{"matched":${r.length},"returned":${o.length},"truncated":${r.length > i},"results":[${c.join(",")}]}`;
|
|
16453
16619
|
}, {
|
|
16454
16620
|
name: "query_data",
|
|
@@ -16464,13 +16630,13 @@ function Wv(e, r = {}) {
|
|
|
16464
16630
|
message: "主数据为空,无可搜索内容"
|
|
16465
16631
|
});
|
|
16466
16632
|
try {
|
|
16467
|
-
let o =
|
|
16633
|
+
let o = Mv(s ? $v(a, s) : a, e, {
|
|
16468
16634
|
mode: t,
|
|
16469
16635
|
fuzzyThreshold: n,
|
|
16470
16636
|
matchKey: r,
|
|
16471
16637
|
limit: i ?? 50
|
|
16472
16638
|
});
|
|
16473
|
-
return
|
|
16639
|
+
return Kv({
|
|
16474
16640
|
matched: o.length,
|
|
16475
16641
|
results: o
|
|
16476
16642
|
});
|
|
@@ -16503,7 +16669,7 @@ function Wv(e, r = {}) {
|
|
|
16503
16669
|
message: `脚本过长(${e.length} 字符,上限 8000)`,
|
|
16504
16670
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16505
16671
|
});
|
|
16506
|
-
let n = await
|
|
16672
|
+
let n = await Fv(Hv(s ? $v(a, s) : a), e, 3e3);
|
|
16507
16673
|
if (!n.ok) {
|
|
16508
16674
|
let t = /超时/.test(n.error || "");
|
|
16509
16675
|
return $({
|
|
@@ -16524,15 +16690,15 @@ function Wv(e, r = {}) {
|
|
|
16524
16690
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform(patches) 无法就地替换`,
|
|
16525
16691
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
16526
16692
|
});
|
|
16527
|
-
let t = e.patches, r =
|
|
16693
|
+
let t = e.patches, r = Hv(a), o = [];
|
|
16528
16694
|
for (let e = 0; e < t.length; e++) {
|
|
16529
16695
|
let n = t[e], a = n.jsonPath || "";
|
|
16530
|
-
if (
|
|
16696
|
+
if (Lv(a)) return $({
|
|
16531
16697
|
code: "PATH_UNSAFE",
|
|
16532
16698
|
message: `patches[${e}] jsonPath "${a}" 含非法段`,
|
|
16533
16699
|
hint: "使用正常属性路径"
|
|
16534
16700
|
});
|
|
16535
|
-
if (!
|
|
16701
|
+
if (!Yv(a, i, s)) return $({
|
|
16536
16702
|
code: "PATH_DENIED",
|
|
16537
16703
|
message: `patches[${e}] @ "${a}" 不在 schema 声明字段内`,
|
|
16538
16704
|
hint: "仅 schema 声明的 key 可写"
|
|
@@ -16544,11 +16710,11 @@ function Wv(e, r = {}) {
|
|
|
16544
16710
|
message: `patches[${e}] ${c} 操作需要 value`,
|
|
16545
16711
|
hint: `op 为 ${c} 时 value 必填`
|
|
16546
16712
|
});
|
|
16547
|
-
let t =
|
|
16548
|
-
if (t.parseError) return
|
|
16713
|
+
let t = Uv(n.value);
|
|
16714
|
+
if (t.parseError) return dv(`patches[${e}]`, n.value, t.parseError);
|
|
16549
16715
|
l = t.parsed;
|
|
16550
16716
|
}
|
|
16551
|
-
let u =
|
|
16717
|
+
let u = ey(r, c, a, l);
|
|
16552
16718
|
if (u) return $({
|
|
16553
16719
|
code: "PATCH_FAILED",
|
|
16554
16720
|
message: `patches[${e}]: ${u}`,
|
|
@@ -16565,33 +16731,33 @@ function Wv(e, r = {}) {
|
|
|
16565
16731
|
code: "SCHEMA_INVALID",
|
|
16566
16732
|
message: "脚本 patches 应用后整体校验失败,未写入",
|
|
16567
16733
|
hint: "确认 patches 合并后整体仍符合 schema",
|
|
16568
|
-
details:
|
|
16734
|
+
details: lv(c.error.issues)
|
|
16569
16735
|
});
|
|
16570
16736
|
m("edit", "eval_transform");
|
|
16571
|
-
for (let e of o)
|
|
16737
|
+
for (let e of o) ty(a, e.op, e.jp, e.value);
|
|
16572
16738
|
return p({
|
|
16573
16739
|
op: "edit",
|
|
16574
16740
|
detail: `eval_transform(${o.length} patches)`,
|
|
16575
16741
|
timestamp: Date.now()
|
|
16576
|
-
}), u =
|
|
16742
|
+
}), u = qv(a), `已通过脚本 transform(patches) 更新主数据(${o.length} 个 patch,耗时 ${n.elapsedMs}ms)。当前值: ${Kv(a, 600)}`;
|
|
16577
16743
|
}
|
|
16578
16744
|
let t = i.safeParse(e);
|
|
16579
16745
|
return t.success ? typeof a != "object" || !a ? $({
|
|
16580
16746
|
code: "LEAF_BIND",
|
|
16581
16747
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),eval transform 无法就地替换外部持有的值引用`,
|
|
16582
16748
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
16583
|
-
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ?
|
|
16749
|
+
}) : (m("edit", "eval_transform"), t.data !== null && typeof t.data == "object" && (s ? Rv(a, t.data) : ry(a, t.data)), p({
|
|
16584
16750
|
op: "edit",
|
|
16585
16751
|
detail: "eval_transform",
|
|
16586
16752
|
timestamp: Date.now()
|
|
16587
|
-
}), u =
|
|
16753
|
+
}), u = qv(a), `已通过脚本 transform 更新主数据(耗时 ${n.elapsedMs}ms)。当前值: ${Kv(a, 600)}`) : $({
|
|
16588
16754
|
code: "SCHEMA_INVALID",
|
|
16589
16755
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回主数据的完整新值且符合 schema)",
|
|
16590
16756
|
hint: "确认脚本 return 了完整新值(非部分);或返回 {patches:[...]} 走增量模式;按 describe_data() 查看格式",
|
|
16591
|
-
details:
|
|
16757
|
+
details: lv(t.error.issues)
|
|
16592
16758
|
});
|
|
16593
16759
|
}
|
|
16594
|
-
return
|
|
16760
|
+
return Kv({
|
|
16595
16761
|
ok: !0,
|
|
16596
16762
|
result: n.result,
|
|
16597
16763
|
elapsedMs: n.elapsedMs
|
|
@@ -16606,16 +16772,16 @@ function Wv(e, r = {}) {
|
|
|
16606
16772
|
}),
|
|
16607
16773
|
n(async ({ jsonPath: e, fields: t, depth: n }) => {
|
|
16608
16774
|
let c = e || "";
|
|
16609
|
-
if (!
|
|
16775
|
+
if (!Yv(c, i, s)) return $({
|
|
16610
16776
|
code: "PATH_DENIED",
|
|
16611
16777
|
message: `read @ "${c}" 不在 schema 声明字段内`,
|
|
16612
16778
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
16613
16779
|
});
|
|
16614
|
-
let l = c ?
|
|
16615
|
-
if (!c) l =
|
|
16780
|
+
let l = c ? zv(a, c) : a;
|
|
16781
|
+
if (!c) l = $v(l, s);
|
|
16616
16782
|
else if (s) {
|
|
16617
|
-
let e =
|
|
16618
|
-
e && (l =
|
|
16783
|
+
let e = Zv(i, c);
|
|
16784
|
+
e && (l = Qv(l, e));
|
|
16619
16785
|
}
|
|
16620
16786
|
let d = l;
|
|
16621
16787
|
if (r.interceptors?.read) try {
|
|
@@ -16626,11 +16792,11 @@ function Wv(e, r = {}) {
|
|
|
16626
16792
|
message: `read 拦截器抛错: ${e.message}`
|
|
16627
16793
|
});
|
|
16628
16794
|
}
|
|
16629
|
-
t && t.length && (d =
|
|
16630
|
-
let f =
|
|
16795
|
+
t && t.length && (d = Wv(d, t)), n != null && (d = Gv(d, n));
|
|
16796
|
+
let f = qv(a);
|
|
16631
16797
|
u = f;
|
|
16632
16798
|
let p = t && t.length ? `(字段裁剪:${t.join(",")})` : "", m = n == null ? "" : `(深度≤${n})`, h = p || m ? ` ${p}${m}` : "", g = e ? "" : `主数据说明: ${o}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。\n\n`;
|
|
16633
|
-
return d === void 0 ? `${g}主数据${e ? ` @ ${e}` : ""}${h} = (undefined) (hash=${f})` : `${g}主数据${e ? ` @ ${e}` : ""}${h} = ${
|
|
16799
|
+
return d === void 0 ? `${g}主数据${e ? ` @ ${e}` : ""}${h} = (undefined) (hash=${f})` : `${g}主数据${e ? ` @ ${e}` : ""}${h} = ${Kv(d)} (hash=${f})`;
|
|
16634
16800
|
}, {
|
|
16635
16801
|
name: "read",
|
|
16636
16802
|
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示;传 jsonPath → 返回该子路径当前值 + hash。hash 用于乐观锁(默认 autoLock,write 时自动比对,无需手动传)。fields(可选):字段裁剪,只返回对象(及数组元素)的指定字段,减少大对象返回体积;depth(可选):嵌套深度限制(0=只根占位,1=根+子,递归截断深层),减少深层结构返回体积。两者可组合,先裁字段再截深度。集成方可能经 read 拦截器对返回值脱敏/派生。",
|
|
@@ -16671,12 +16837,12 @@ function Wv(e, r = {}) {
|
|
|
16671
16837
|
message: "delete 需要 patch.jsonPath 指定要删的子路径(主数据整体不可删,用 write(value) 整体替换)",
|
|
16672
16838
|
hint: "如 patch:{jsonPath:\"components.0\"}, del:true"
|
|
16673
16839
|
});
|
|
16674
|
-
if (
|
|
16840
|
+
if (Lv(t.jsonPath)) return $({
|
|
16675
16841
|
code: "PATH_UNSAFE",
|
|
16676
16842
|
message: `jsonPath "${t.jsonPath}" 含非法段`,
|
|
16677
16843
|
hint: "使用正常属性路径"
|
|
16678
16844
|
});
|
|
16679
|
-
if (!
|
|
16845
|
+
if (!Yv(t.jsonPath, i, s)) return $({
|
|
16680
16846
|
code: "PATH_DENIED",
|
|
16681
16847
|
message: `write delete @ "${t.jsonPath}" 不在 schema 声明字段内`,
|
|
16682
16848
|
hint: "仅 schema 声明的 key 可删"
|
|
@@ -16684,12 +16850,12 @@ function Wv(e, r = {}) {
|
|
|
16684
16850
|
let e = await h("delete", g);
|
|
16685
16851
|
if (e !== null) return e;
|
|
16686
16852
|
m("delete");
|
|
16687
|
-
let n =
|
|
16853
|
+
let n = Vv(a, t.jsonPath);
|
|
16688
16854
|
return p({
|
|
16689
16855
|
op: "delete",
|
|
16690
16856
|
detail: t.jsonPath,
|
|
16691
16857
|
timestamp: Date.now()
|
|
16692
|
-
}), u =
|
|
16858
|
+
}), u = qv(a), n ? `已删除主数据 @ ${t.jsonPath}` : `主数据 @ ${t.jsonPath} 不存在(无需删除)`;
|
|
16693
16859
|
}
|
|
16694
16860
|
if (c === "edit") {
|
|
16695
16861
|
if (typeof a != "object" || !a) return $({
|
|
@@ -16703,15 +16869,15 @@ function Wv(e, r = {}) {
|
|
|
16703
16869
|
op: t.op,
|
|
16704
16870
|
jsonPath: t.jsonPath || "",
|
|
16705
16871
|
value: l
|
|
16706
|
-
}]), o =
|
|
16872
|
+
}]), o = Hv(a), c = [];
|
|
16707
16873
|
for (let e = 0; e < r.length; e++) {
|
|
16708
16874
|
let t = r[e], n = t.jsonPath || "";
|
|
16709
|
-
if (
|
|
16875
|
+
if (Lv(n)) return $({
|
|
16710
16876
|
code: "PATH_UNSAFE",
|
|
16711
16877
|
message: `patches[${e}] jsonPath "${n}" 含非法段`,
|
|
16712
16878
|
hint: "使用正常属性路径,如 components.0.text"
|
|
16713
16879
|
});
|
|
16714
|
-
if (!
|
|
16880
|
+
if (!Yv(n, i, s)) return $({
|
|
16715
16881
|
code: "PATH_DENIED",
|
|
16716
16882
|
message: `patches[${e}] @ "${n}" 不在 schema 声明字段内`,
|
|
16717
16883
|
hint: "仅 schema 声明的 key 可写"
|
|
@@ -16723,11 +16889,11 @@ function Wv(e, r = {}) {
|
|
|
16723
16889
|
message: `patches[${e}] ${a} 操作需要 value`,
|
|
16724
16890
|
hint: `op 为 ${a} 时 value 必填;删除请用 op:'remove'`
|
|
16725
16891
|
});
|
|
16726
|
-
let n =
|
|
16727
|
-
if (n.parseError) return
|
|
16892
|
+
let n = Uv(t.value);
|
|
16893
|
+
if (n.parseError) return dv(`patches[${e}]`, t.value, n.parseError);
|
|
16728
16894
|
l = n.parsed;
|
|
16729
16895
|
}
|
|
16730
|
-
let u =
|
|
16896
|
+
let u = ey(o, a, n, l);
|
|
16731
16897
|
if (u) return $({
|
|
16732
16898
|
code: "PATCH_FAILED",
|
|
16733
16899
|
message: `patches[${e}]: ${u}`,
|
|
@@ -16740,39 +16906,39 @@ function Wv(e, r = {}) {
|
|
|
16740
16906
|
});
|
|
16741
16907
|
}
|
|
16742
16908
|
let d = i.safeParse(o);
|
|
16743
|
-
if (!d.success) return
|
|
16909
|
+
if (!d.success) return uv("", d.error.issues);
|
|
16744
16910
|
m("edit");
|
|
16745
|
-
for (let e of c)
|
|
16911
|
+
for (let e of c) ty(a, e.op, e.jp, e.value);
|
|
16746
16912
|
return p({
|
|
16747
16913
|
op: "edit",
|
|
16748
16914
|
detail: `${c.length} 个 patch${c.length > 1 ? "(批量)" : ""}`,
|
|
16749
16915
|
value: c.map((e) => `${e.op}@${e.jp}`),
|
|
16750
16916
|
timestamp: Date.now()
|
|
16751
|
-
}), u =
|
|
16917
|
+
}), u = qv(a), `已 write(edit) 主数据(${c.length} 个 patch)。当前值:${Kv(a, 600)} (新 hash=${qv(a)})`;
|
|
16752
16918
|
}
|
|
16753
|
-
let _, v =
|
|
16754
|
-
if (v.parseError) return
|
|
16919
|
+
let _, v = Uv(l);
|
|
16920
|
+
if (v.parseError) return dv("", l, v.parseError);
|
|
16755
16921
|
_ = v.parsed;
|
|
16756
16922
|
let y = await h("set", g);
|
|
16757
16923
|
if (y !== null) return y;
|
|
16758
16924
|
let b = i.safeParse(_);
|
|
16759
|
-
if (!b.success) return
|
|
16925
|
+
if (!b.success) return uv("", b.error.issues);
|
|
16760
16926
|
if (typeof a != "object" || !a) return $({
|
|
16761
16927
|
code: "LEAF_BIND",
|
|
16762
16928
|
message: `主数据 bind 为原始类型(${a === null ? "null" : typeof a}),write(set) 无法就地替换外部持有的值引用`,
|
|
16763
16929
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹(如 {value:\"x\"})或集成方通过 sdk.setData 替换 bind"
|
|
16764
16930
|
});
|
|
16765
16931
|
if (m("set"), b.data !== null && typeof b.data == "object") if (s) {
|
|
16766
|
-
if (
|
|
16932
|
+
if (Rv(a, b.data), _ && typeof _ == "object" && !Array.isArray(_)) {
|
|
16767
16933
|
let e = new Set(s);
|
|
16768
16934
|
for (let [t, n] of Object.entries(_)) e.has(t) || (a[t] = n);
|
|
16769
16935
|
}
|
|
16770
|
-
} else
|
|
16936
|
+
} else ry(a, b.data);
|
|
16771
16937
|
return p({
|
|
16772
16938
|
op: "set",
|
|
16773
16939
|
value: b.data,
|
|
16774
16940
|
timestamp: Date.now()
|
|
16775
|
-
}), u =
|
|
16941
|
+
}), u = qv(a), `已 write(set) 主数据 = ${Kv(b.data, 600)} (新 hash=${qv(a)})${s ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
16776
16942
|
}, {
|
|
16777
16943
|
name: "write",
|
|
16778
16944
|
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})。",
|
|
@@ -16810,8 +16976,8 @@ function Wv(e, r = {}) {
|
|
|
16810
16976
|
}
|
|
16811
16977
|
//#endregion
|
|
16812
16978
|
//#region src/core/tools/fetchDoc.ts
|
|
16813
|
-
var
|
|
16814
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16979
|
+
var cy = 3e4, ly = [n(async ({ url: e, as: t }) => {
|
|
16980
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), cy);
|
|
16815
16981
|
try {
|
|
16816
16982
|
let r = await fetch(e, {
|
|
16817
16983
|
method: "GET",
|
|
@@ -16828,7 +16994,7 @@ var Gv = 3e4, Kv = [n(async ({ url: e, as: t }) => {
|
|
|
16828
16994
|
].join("\n");
|
|
16829
16995
|
} catch (t) {
|
|
16830
16996
|
let r = t?.message || String(t);
|
|
16831
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16997
|
+
return n.signal.aborted ? `获取失败:请求超时(${cy}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16832
16998
|
} finally {
|
|
16833
16999
|
clearTimeout(r);
|
|
16834
17000
|
}
|
|
@@ -16839,25 +17005,25 @@ var Gv = 3e4, Kv = [n(async ({ url: e, as: t }) => {
|
|
|
16839
17005
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16840
17006
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16841
17007
|
})
|
|
16842
|
-
})],
|
|
16843
|
-
function
|
|
16844
|
-
return
|
|
17008
|
+
})], uy = ly;
|
|
17009
|
+
function dy(e, t) {
|
|
17010
|
+
return sy(e, t);
|
|
16845
17011
|
}
|
|
16846
|
-
function
|
|
17012
|
+
function fy(e, t, n) {
|
|
16847
17013
|
let r = e?.dataOps !== !1, i = e?.fetch !== !1;
|
|
16848
17014
|
return [...r ? t : [], ...i ? n : []];
|
|
16849
17015
|
}
|
|
16850
17016
|
//#endregion
|
|
16851
17017
|
//#region src/core/harness/usageHints.ts
|
|
16852
|
-
var
|
|
16853
|
-
function
|
|
17018
|
+
var py = .7;
|
|
17019
|
+
function my(e, t, n = "simple") {
|
|
16854
17020
|
let r = n !== "advanced";
|
|
16855
17021
|
return {
|
|
16856
17022
|
name: "usageHints",
|
|
16857
17023
|
augmentPrompt: () => {
|
|
16858
17024
|
let n = [];
|
|
16859
17025
|
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) {
|
|
16860
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
17026
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= py || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), i = e.subagents.filter((e) => (e.temperature ?? 0) < py && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16861
17027
|
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(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16862
17028
|
}
|
|
16863
17029
|
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;
|
|
@@ -16866,7 +17032,7 @@ function Zv(e, t, n = "simple") {
|
|
|
16866
17032
|
}
|
|
16867
17033
|
//#endregion
|
|
16868
17034
|
//#region src/core/utils/id.ts
|
|
16869
|
-
function
|
|
17035
|
+
function hy() {
|
|
16870
17036
|
try {
|
|
16871
17037
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16872
17038
|
} catch {}
|
|
@@ -16874,57 +17040,57 @@ function Qv() {
|
|
|
16874
17040
|
}
|
|
16875
17041
|
//#endregion
|
|
16876
17042
|
//#region src/core/backends/storage.ts
|
|
16877
|
-
var
|
|
17043
|
+
var gy = "chat-sdk", _y = 50 * 1024 * 1024, vy = 4 * 1024 * 1024, yy = 10 * 1024 * 1024, by = .9, xy = 500, Sy = 300, Cy = "__meta__", wy = "v:1", Ty = [
|
|
16878
17044
|
"messages",
|
|
16879
17045
|
"vfs",
|
|
16880
17046
|
"todos",
|
|
16881
17047
|
"memory"
|
|
16882
17048
|
];
|
|
16883
|
-
function
|
|
16884
|
-
return e === "local" || e === "session" ?
|
|
17049
|
+
function Ey(e) {
|
|
17050
|
+
return e === "local" || e === "session" ? vy : _y;
|
|
16885
17051
|
}
|
|
16886
|
-
function
|
|
17052
|
+
function Dy(e) {
|
|
16887
17053
|
if (typeof e != "object" || !e) return !1;
|
|
16888
17054
|
let t = e;
|
|
16889
17055
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16890
17056
|
}
|
|
16891
|
-
function
|
|
17057
|
+
function Oy(e, t, n, r) {
|
|
16892
17058
|
return [
|
|
16893
|
-
|
|
17059
|
+
wy,
|
|
16894
17060
|
e,
|
|
16895
17061
|
t,
|
|
16896
17062
|
n,
|
|
16897
17063
|
r
|
|
16898
17064
|
].join("::");
|
|
16899
17065
|
}
|
|
16900
|
-
function
|
|
17066
|
+
function ky(e, t, n) {
|
|
16901
17067
|
return [
|
|
16902
|
-
|
|
17068
|
+
wy,
|
|
16903
17069
|
e,
|
|
16904
17070
|
t,
|
|
16905
17071
|
n
|
|
16906
17072
|
].join("::") + "::";
|
|
16907
17073
|
}
|
|
16908
|
-
function
|
|
17074
|
+
function Ay(e, t) {
|
|
16909
17075
|
return [
|
|
16910
|
-
|
|
17076
|
+
wy,
|
|
16911
17077
|
e,
|
|
16912
17078
|
t
|
|
16913
17079
|
].join("::") + "::";
|
|
16914
17080
|
}
|
|
16915
|
-
function
|
|
16916
|
-
return [
|
|
17081
|
+
function jy(e) {
|
|
17082
|
+
return [wy, e].join("::") + "::";
|
|
16917
17083
|
}
|
|
16918
|
-
var
|
|
16919
|
-
function
|
|
16920
|
-
|
|
17084
|
+
var My = null;
|
|
17085
|
+
function Ny(e) {
|
|
17086
|
+
My ||= new TextEncoder();
|
|
16921
17087
|
try {
|
|
16922
|
-
return
|
|
17088
|
+
return My.encode(JSON.stringify(e)).length;
|
|
16923
17089
|
} catch {
|
|
16924
17090
|
return 0;
|
|
16925
17091
|
}
|
|
16926
17092
|
}
|
|
16927
|
-
function
|
|
17093
|
+
function Py(e, t, n) {
|
|
16928
17094
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16929
17095
|
if (r <= t) return [];
|
|
16930
17096
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16934,7 +17100,7 @@ function _y(e, t, n) {
|
|
|
16934
17100
|
}
|
|
16935
17101
|
return o;
|
|
16936
17102
|
}
|
|
16937
|
-
function
|
|
17103
|
+
function Fy() {
|
|
16938
17104
|
let e = /* @__PURE__ */ new Map();
|
|
16939
17105
|
return {
|
|
16940
17106
|
async get(t) {
|
|
@@ -16954,7 +17120,7 @@ function vy() {
|
|
|
16954
17120
|
}
|
|
16955
17121
|
};
|
|
16956
17122
|
}
|
|
16957
|
-
function
|
|
17123
|
+
function Iy(e) {
|
|
16958
17124
|
return new Promise((t, n) => {
|
|
16959
17125
|
if (typeof indexedDB > "u") {
|
|
16960
17126
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -17015,7 +17181,7 @@ function yy(e) {
|
|
|
17015
17181
|
}, r.onerror = () => n(r.error);
|
|
17016
17182
|
});
|
|
17017
17183
|
}
|
|
17018
|
-
function
|
|
17184
|
+
function Ly(e) {
|
|
17019
17185
|
return {
|
|
17020
17186
|
async get(t) {
|
|
17021
17187
|
let n = e.getItem(t);
|
|
@@ -17049,12 +17215,12 @@ function by(e) {
|
|
|
17049
17215
|
}
|
|
17050
17216
|
};
|
|
17051
17217
|
}
|
|
17052
|
-
function
|
|
17218
|
+
function Ry(e, t, n) {
|
|
17053
17219
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
17054
17220
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
17055
17221
|
}
|
|
17056
|
-
function
|
|
17057
|
-
let t = e.dbName ??
|
|
17222
|
+
function zy(e = {}) {
|
|
17223
|
+
let t = e.dbName ?? gy, n = e.backend ?? "indexed", r = e.maxBytes ?? Ey(n), i = e.maxBytesPerSession ?? yy, a = e.evictionWatermark ?? by, o = e.debounceMs ?? xy, s = /* @__PURE__ */ new Set();
|
|
17058
17224
|
function c(e) {
|
|
17059
17225
|
for (let t of s) try {
|
|
17060
17226
|
t(e);
|
|
@@ -17067,16 +17233,16 @@ function Sy(e = {}) {
|
|
|
17067
17233
|
try {
|
|
17068
17234
|
if (n === "indexed") {
|
|
17069
17235
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
17070
|
-
l = await
|
|
17236
|
+
l = await Iy(t), d(!0);
|
|
17071
17237
|
} else if (n === "session") {
|
|
17072
17238
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
17073
|
-
l =
|
|
17239
|
+
l = Ly(sessionStorage), d(!0);
|
|
17074
17240
|
} else if (n === "local") {
|
|
17075
17241
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
17076
|
-
l =
|
|
17077
|
-
} else l =
|
|
17242
|
+
l = Ly(localStorage), d(!0);
|
|
17243
|
+
} else l = Fy(), d(!1);
|
|
17078
17244
|
} catch (e) {
|
|
17079
|
-
l =
|
|
17245
|
+
l = Fy();
|
|
17080
17246
|
let t = e instanceof Error ? e.message : String(e);
|
|
17081
17247
|
d(!1), Promise.resolve().then(() => c({
|
|
17082
17248
|
type: "degraded",
|
|
@@ -17086,10 +17252,10 @@ function Sy(e = {}) {
|
|
|
17086
17252
|
})();
|
|
17087
17253
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
17088
17254
|
function g(e, n, r, a) {
|
|
17089
|
-
let o =
|
|
17090
|
-
return
|
|
17255
|
+
let o = Oy(t, r, a, Cy);
|
|
17256
|
+
return Ry(h, o, async () => {
|
|
17091
17257
|
let t = async () => {
|
|
17092
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
17258
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : Ny(s), d = Ny(n), f = (t?.bytes ?? 0) + (d - u);
|
|
17093
17259
|
if (f > i) {
|
|
17094
17260
|
c({
|
|
17095
17261
|
type: "quota",
|
|
@@ -17111,12 +17277,12 @@ function Sy(e = {}) {
|
|
|
17111
17277
|
try {
|
|
17112
17278
|
await t();
|
|
17113
17279
|
} catch (e) {
|
|
17114
|
-
if (
|
|
17280
|
+
if (Dy(e) && !u) {
|
|
17115
17281
|
u = !0;
|
|
17116
17282
|
try {
|
|
17117
17283
|
await b();
|
|
17118
17284
|
} catch {}
|
|
17119
|
-
l =
|
|
17285
|
+
l = Fy(), Promise.resolve().then(() => c({
|
|
17120
17286
|
type: "degraded",
|
|
17121
17287
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
17122
17288
|
}));
|
|
@@ -17128,7 +17294,7 @@ function Sy(e = {}) {
|
|
|
17128
17294
|
});
|
|
17129
17295
|
}
|
|
17130
17296
|
function _(e, n, r, i) {
|
|
17131
|
-
let a =
|
|
17297
|
+
let a = Oy(t, e, n, r), s = p.get(a);
|
|
17132
17298
|
s && s.resolve();
|
|
17133
17299
|
let c = m.get(a);
|
|
17134
17300
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -17155,15 +17321,15 @@ function Sy(e = {}) {
|
|
|
17155
17321
|
function y() {
|
|
17156
17322
|
v ||= setTimeout(() => {
|
|
17157
17323
|
v = null, b();
|
|
17158
|
-
},
|
|
17324
|
+
}, Sy);
|
|
17159
17325
|
}
|
|
17160
17326
|
async function b() {
|
|
17161
17327
|
let e = [];
|
|
17162
|
-
await l.scan(
|
|
17328
|
+
await l.scan(jy(t), (t, n) => {
|
|
17163
17329
|
t.endsWith("::__meta__") && e.push(n);
|
|
17164
17330
|
});
|
|
17165
|
-
let n =
|
|
17166
|
-
for (let e of n) await l.clearPrefix(
|
|
17331
|
+
let n = Py(e, r, a);
|
|
17332
|
+
for (let e of n) await l.clearPrefix(ky(t, e.agentId, e.sessionId)), c({
|
|
17167
17333
|
type: "evicted",
|
|
17168
17334
|
agentId: e.agentId,
|
|
17169
17335
|
sessionId: e.sessionId,
|
|
@@ -17174,13 +17340,13 @@ function Sy(e = {}) {
|
|
|
17174
17340
|
ready: f,
|
|
17175
17341
|
async listSessions(e) {
|
|
17176
17342
|
let n = [];
|
|
17177
|
-
return await l.scan(
|
|
17343
|
+
return await l.scan(Ay(t, e), (e, t) => {
|
|
17178
17344
|
e.endsWith("::__meta__") && n.push(t);
|
|
17179
17345
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
17180
17346
|
},
|
|
17181
17347
|
async load(e, n) {
|
|
17182
|
-
let r =
|
|
17183
|
-
return await
|
|
17348
|
+
let r = Oy(t, e, n, Cy);
|
|
17349
|
+
return await Ry(h, r, async () => {
|
|
17184
17350
|
let i = await l.get(r);
|
|
17185
17351
|
if (!i) return;
|
|
17186
17352
|
let a = {
|
|
@@ -17189,8 +17355,8 @@ function Sy(e = {}) {
|
|
|
17189
17355
|
todos: [],
|
|
17190
17356
|
memory: ""
|
|
17191
17357
|
};
|
|
17192
|
-
for (let r of
|
|
17193
|
-
let i = await l.get(
|
|
17358
|
+
for (let r of Ty) {
|
|
17359
|
+
let i = await l.get(Oy(t, e, n, r));
|
|
17194
17360
|
i != null && (a[r] = i);
|
|
17195
17361
|
}
|
|
17196
17362
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -17198,7 +17364,7 @@ function Sy(e = {}) {
|
|
|
17198
17364
|
},
|
|
17199
17365
|
async save(e, t, n) {
|
|
17200
17366
|
let r = [];
|
|
17201
|
-
for (let i of
|
|
17367
|
+
for (let i of Ty) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
17202
17368
|
await Promise.all(r);
|
|
17203
17369
|
},
|
|
17204
17370
|
async flush() {
|
|
@@ -17212,10 +17378,10 @@ function Sy(e = {}) {
|
|
|
17212
17378
|
})), c({ type: "flush" }), await b();
|
|
17213
17379
|
},
|
|
17214
17380
|
async deleteSession(e, n) {
|
|
17215
|
-
await l.clearPrefix(
|
|
17381
|
+
await l.clearPrefix(ky(t, e, n));
|
|
17216
17382
|
},
|
|
17217
17383
|
async createSession(e, n, r) {
|
|
17218
|
-
let i = r ??
|
|
17384
|
+
let i = r ?? hy(), a = Date.now(), o = {
|
|
17219
17385
|
agentId: e,
|
|
17220
17386
|
sessionId: i,
|
|
17221
17387
|
createdAt: a,
|
|
@@ -17223,7 +17389,7 @@ function Sy(e = {}) {
|
|
|
17223
17389
|
bytes: 0,
|
|
17224
17390
|
title: n
|
|
17225
17391
|
};
|
|
17226
|
-
return await l.set(
|
|
17392
|
+
return await l.set(Oy(t, e, i, Cy), o), i;
|
|
17227
17393
|
},
|
|
17228
17394
|
onEvent(e) {
|
|
17229
17395
|
s.add(e);
|
|
@@ -17237,36 +17403,95 @@ function Sy(e = {}) {
|
|
|
17237
17403
|
};
|
|
17238
17404
|
}
|
|
17239
17405
|
//#endregion
|
|
17406
|
+
//#region src/core/backends/skillStore.ts
|
|
17407
|
+
var By = "v:1::skill-store", Vy = "chat-sdk";
|
|
17408
|
+
function Hy(e, t, n) {
|
|
17409
|
+
return `${By}::${e}::${t}::${n}`;
|
|
17410
|
+
}
|
|
17411
|
+
function Uy(e, t) {
|
|
17412
|
+
return `${By}::${e}::${t}::`;
|
|
17413
|
+
}
|
|
17414
|
+
function Wy(e = {}) {
|
|
17415
|
+
let t = e.dbName ?? Vy, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
17416
|
+
a = e;
|
|
17417
|
+
});
|
|
17418
|
+
return (async () => {
|
|
17419
|
+
try {
|
|
17420
|
+
if (n === "indexed") {
|
|
17421
|
+
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
17422
|
+
i = await Iy(t), a(!0);
|
|
17423
|
+
} else if (n === "session") {
|
|
17424
|
+
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
17425
|
+
i = Ly(sessionStorage), a(!0);
|
|
17426
|
+
} else if (n === "local") {
|
|
17427
|
+
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
17428
|
+
i = Ly(localStorage), a(!0);
|
|
17429
|
+
} else i = Fy(), a(!1);
|
|
17430
|
+
} catch {
|
|
17431
|
+
i = Fy(), a(!1);
|
|
17432
|
+
}
|
|
17433
|
+
})(), {
|
|
17434
|
+
ready: o,
|
|
17435
|
+
async list() {
|
|
17436
|
+
let e = [];
|
|
17437
|
+
return await i.scan(Uy(t, r), (t, n) => {
|
|
17438
|
+
e.push(n);
|
|
17439
|
+
}), e;
|
|
17440
|
+
},
|
|
17441
|
+
async get(e) {
|
|
17442
|
+
return await i.get(Hy(t, r, e));
|
|
17443
|
+
},
|
|
17444
|
+
async put(e) {
|
|
17445
|
+
try {
|
|
17446
|
+
await i.set(Hy(t, r, e.name), e);
|
|
17447
|
+
} catch (e) {
|
|
17448
|
+
Dy(e) && (i = Fy());
|
|
17449
|
+
}
|
|
17450
|
+
},
|
|
17451
|
+
async remove(e) {
|
|
17452
|
+
let n = Hy(t, r, e);
|
|
17453
|
+
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
17454
|
+
},
|
|
17455
|
+
async clear() {
|
|
17456
|
+
await i.clearPrefix(Uy(t, r));
|
|
17457
|
+
},
|
|
17458
|
+
dispose() {}
|
|
17459
|
+
};
|
|
17460
|
+
}
|
|
17461
|
+
//#endregion
|
|
17240
17462
|
//#region src/core/sdk/createChatSdk.ts
|
|
17241
|
-
var
|
|
17463
|
+
var Gy = [
|
|
17242
17464
|
"你是一个 JSON 操作助手。集成方声明了一个主数据对象(含 zod schema 校验),你通过专用工具安全地读写它来完成任务。",
|
|
17243
17465
|
"所有写操作都经范围控制(仅 schema 声明字段内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
17244
17466
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
17245
17467
|
"---",
|
|
17246
|
-
|
|
17468
|
+
av.reliableWriteRules
|
|
17247
17469
|
].join("\n\n");
|
|
17248
|
-
function
|
|
17470
|
+
function Ky(e) {
|
|
17249
17471
|
if (!e) return "";
|
|
17250
|
-
let t =
|
|
17472
|
+
let t = ov(e.schema);
|
|
17251
17473
|
return `\n\n## 可操作数据(字段以 read 工具返回的实际值为准)\n${e.description ? e.description + "\n" : ""}${t}`;
|
|
17252
17474
|
}
|
|
17253
|
-
var
|
|
17254
|
-
function
|
|
17255
|
-
return e === void 0 || e === !1 ? null : typeof e == "string" ?
|
|
17475
|
+
var qy = 50;
|
|
17476
|
+
function Jy(e) {
|
|
17477
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? zy({ backend: e }) : e.enabled === !1 ? null : zy(e);
|
|
17256
17478
|
}
|
|
17257
|
-
function
|
|
17479
|
+
function Yy(e) {
|
|
17480
|
+
return e.dialog ?? {};
|
|
17481
|
+
}
|
|
17482
|
+
function Xy(e) {
|
|
17258
17483
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
17259
17484
|
}
|
|
17260
|
-
var
|
|
17261
|
-
function
|
|
17485
|
+
var Zy = /* @__PURE__ */ new Map();
|
|
17486
|
+
function Qy(e) {
|
|
17262
17487
|
let t = e.content;
|
|
17263
17488
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
17264
17489
|
}
|
|
17265
|
-
function
|
|
17490
|
+
function $y(e) {
|
|
17266
17491
|
let t = e.summaryLlm ?? e.llm;
|
|
17267
17492
|
if (!t) return;
|
|
17268
17493
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
17269
|
-
if (
|
|
17494
|
+
if (Xy(t)) c = t;
|
|
17270
17495
|
else {
|
|
17271
17496
|
let i = t;
|
|
17272
17497
|
if (!i.apiKey) {
|
|
@@ -17284,21 +17509,21 @@ function Ay(e) {
|
|
|
17284
17509
|
return async (e) => {
|
|
17285
17510
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
17286
17511
|
try {
|
|
17287
|
-
return
|
|
17512
|
+
return Qy(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
17288
17513
|
} finally {
|
|
17289
17514
|
clearTimeout(n);
|
|
17290
17515
|
}
|
|
17291
17516
|
};
|
|
17292
17517
|
}
|
|
17293
|
-
function
|
|
17518
|
+
function eb(e, t) {
|
|
17294
17519
|
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;
|
|
17295
17520
|
}
|
|
17296
|
-
function
|
|
17521
|
+
function tb(e, t, n, r) {
|
|
17297
17522
|
let i = 0;
|
|
17298
17523
|
return {
|
|
17299
17524
|
name: "sdk-events",
|
|
17300
17525
|
wrapToolCall: async (t, r) => {
|
|
17301
|
-
let i = await r(t), a =
|
|
17526
|
+
let i = await r(t), a = eb(t.name, t.args);
|
|
17302
17527
|
return a && e({
|
|
17303
17528
|
type: "data_change",
|
|
17304
17529
|
operation: a,
|
|
@@ -17333,7 +17558,7 @@ function My(e, t, n, r) {
|
|
|
17333
17558
|
}
|
|
17334
17559
|
};
|
|
17335
17560
|
}
|
|
17336
|
-
function
|
|
17561
|
+
function nb(e, r) {
|
|
17337
17562
|
let i = {
|
|
17338
17563
|
prompt_tokens: 0,
|
|
17339
17564
|
completion_tokens: 0,
|
|
@@ -17358,25 +17583,25 @@ function Ny(e, r) {
|
|
|
17358
17583
|
let t = a.value;
|
|
17359
17584
|
t && (a.value = null, t.resolve({ action: e }));
|
|
17360
17585
|
}
|
|
17361
|
-
let u =
|
|
17586
|
+
let u = Jy(e.storage);
|
|
17362
17587
|
e.debug && u && u.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
17363
|
-
let d =
|
|
17588
|
+
let d = Xy(e.llm) ? void 0 : e.llm, f = wg({
|
|
17364
17589
|
model: d?.model,
|
|
17365
17590
|
contextWindow: e.contextWindow ?? d?.contextWindow,
|
|
17366
17591
|
maxOutputTokens: e.maxOutputTokens ?? d?.maxOutputTokens
|
|
17367
17592
|
});
|
|
17368
17593
|
e.debug && console.log("[page-agent-sdk][modelCaps]", f);
|
|
17369
|
-
let p =
|
|
17594
|
+
let p = $y(e);
|
|
17370
17595
|
e.debug && !p && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
17371
|
-
let m = /* @__PURE__ */ $t([]), h =
|
|
17596
|
+
let m = /* @__PURE__ */ $t([]), h = pv(e.vfs?.initialFiles, {
|
|
17372
17597
|
persist: u ? { save: (e) => {
|
|
17373
17598
|
z.sessionId && u && u.save(r, z.sessionId, { vfs: e });
|
|
17374
17599
|
} } : void 0,
|
|
17375
17600
|
maxBytes: e.vfs?.maxBytes
|
|
17376
|
-
}), g =
|
|
17601
|
+
}), g = Wg(), _ = Qg(e.memory || ""), v = { current: null }, y = e.data ? {
|
|
17377
17602
|
...e.data,
|
|
17378
17603
|
description: e.data.description ?? "主数据对象"
|
|
17379
|
-
} : void 0, b = e.checkpoint, x = b !== void 0 && b !== !1, S = x ?
|
|
17604
|
+
} : void 0, b = e.checkpoint, x = b !== void 0 && b !== !1, S = x ? h_({
|
|
17380
17605
|
getData: () => j()?.bind,
|
|
17381
17606
|
slotPaths: y ? [""] : [],
|
|
17382
17607
|
vfsStore: h,
|
|
@@ -17384,18 +17609,18 @@ function Ny(e, r) {
|
|
|
17384
17609
|
getTodos: () => v.current?.getState?.()?.todos ?? [],
|
|
17385
17610
|
messages: m,
|
|
17386
17611
|
maxCheckpoints: b && typeof b == "object" ? b.maxCheckpoints : void 0
|
|
17387
|
-
}) : null, C = !b || typeof b != "object" || b.auto !== !1, w = e.capabilities, T = w?.dataOps !== !1, E = e.appendReliableWriteRules !== !1, D = (e.systemPrompt ? E ? e.systemPrompt + "\n\n---\n\n" +
|
|
17612
|
+
}) : null, C = !b || typeof b != "object" || b.auto !== !1, w = e.capabilities, T = w?.dataOps !== !1, E = e.appendReliableWriteRules !== !1, D = (e.systemPrompt ? E ? e.systemPrompt + "\n\n---\n\n" + av.reliableWriteRules : e.systemPrompt : Gy) + Ky(y), O = T && y ? sy(y, {
|
|
17388
17613
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
17389
17614
|
maxSnapshots: e.maxSnapshots,
|
|
17390
17615
|
onConflict: c,
|
|
17391
17616
|
autoLock: e.autoLock,
|
|
17392
17617
|
interceptors: e.interceptors
|
|
17393
|
-
}) : [], k = T ?
|
|
17618
|
+
}) : [], k = T ? oy(O, e.toolMode) : [], A = T && y ? O.controller ?? null : null, j = () => A?.get() ?? y, M = /* @__PURE__ */ new Map(), N = fy(w, k, ly);
|
|
17394
17619
|
N.forEach((e) => M.set(e.name, "builtin"));
|
|
17395
17620
|
let P = [...e.tools || []];
|
|
17396
17621
|
P.forEach((e) => M.set(e.name, "user"));
|
|
17397
|
-
let F = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), I = F ?
|
|
17398
|
-
I && M.set(
|
|
17622
|
+
let F = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), I = F ? s_() : null;
|
|
17623
|
+
I && M.set(a_, "builtin");
|
|
17399
17624
|
let L = x && S ? [n(async () => {
|
|
17400
17625
|
let e = S.list();
|
|
17401
17626
|
return e.length ? S.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
@@ -17419,7 +17644,7 @@ function Ny(e, r) {
|
|
|
17419
17644
|
...L
|
|
17420
17645
|
], ee = w?.planning !== !1, te = w?.skills !== !1, ne = w?.vfs !== !1, re = w?.summarization !== !1, ie = w?.memory !== !1, ae = w?.subagent !== !1, oe = e.verify?.maxAttempts ?? 2, se = w?.verify === !0 && e.verify?.enabled !== !1 && oe > 0;
|
|
17421
17646
|
e.verify?.check && w?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
17422
|
-
let ce = e.subagent, le = ce?.allowedTools ?? [], ue = !ae || ce?.enabled === !1 ? void 0 :
|
|
17647
|
+
let ce = e.subagent, le = ce?.allowedTools ?? [], ue = !ae || ce?.enabled === !1 ? void 0 : w_({
|
|
17423
17648
|
llm: ce?.llm ?? e.llm,
|
|
17424
17649
|
allTools: R,
|
|
17425
17650
|
allowedTools: le.length ? le : void 0,
|
|
@@ -17430,7 +17655,7 @@ function Ny(e, r) {
|
|
|
17430
17655
|
maxDepth: ce?.maxDepth,
|
|
17431
17656
|
maxParallel: ce?.maxParallel,
|
|
17432
17657
|
debug: e.debug
|
|
17433
|
-
}), de = e.subagents?.length ?
|
|
17658
|
+
}), de = e.subagents?.length ? D_(e.subagents, {
|
|
17434
17659
|
llm: e.llm,
|
|
17435
17660
|
allTools: R,
|
|
17436
17661
|
debug: e.debug
|
|
@@ -17439,8 +17664,8 @@ function Ny(e, r) {
|
|
|
17439
17664
|
"describe_data",
|
|
17440
17665
|
"read",
|
|
17441
17666
|
"fetch_document"
|
|
17442
|
-
], pe = R.filter((e) => fe.includes(e.name)), me = se ?
|
|
17443
|
-
check: e.verify.check ??
|
|
17667
|
+
], pe = R.filter((e) => fe.includes(e.name)), me = se ? O_({
|
|
17668
|
+
check: e.verify.check ?? P_({
|
|
17444
17669
|
schemas: () => j() ? { "": j().schema } : {},
|
|
17445
17670
|
root: () => j()?.bind
|
|
17446
17671
|
}),
|
|
@@ -17448,7 +17673,7 @@ function Ny(e, r) {
|
|
|
17448
17673
|
llm: e.llm,
|
|
17449
17674
|
tools: pe
|
|
17450
17675
|
} : void 0
|
|
17451
|
-
}) : void 0, he =
|
|
17676
|
+
}) : void 0, he = my({
|
|
17452
17677
|
...w,
|
|
17453
17678
|
humanConfirm: F,
|
|
17454
17679
|
subagents: e.subagents?.map((e) => ({
|
|
@@ -17465,28 +17690,59 @@ function Ny(e, r) {
|
|
|
17465
17690
|
t(e);
|
|
17466
17691
|
} catch {}
|
|
17467
17692
|
}
|
|
17468
|
-
}, ye, be = [
|
|
17693
|
+
}, ye, be = [], xe = (e) => ({
|
|
17694
|
+
name: e.name,
|
|
17695
|
+
description: e.description,
|
|
17696
|
+
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
17697
|
+
}), Se = (e) => ({
|
|
17698
|
+
name: e.name,
|
|
17699
|
+
description: e.description,
|
|
17700
|
+
getContent: () => e.content
|
|
17701
|
+
}), Ce = e.skillStorage === !1 ? null : Wy({
|
|
17702
|
+
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
17703
|
+
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${r}`
|
|
17704
|
+
}), we = () => {
|
|
17705
|
+
let t = ye ? ye.controller : null;
|
|
17706
|
+
if (t) {
|
|
17707
|
+
let n = (e.skills || []).filter((e) => !be.some((t) => t.name === e.name));
|
|
17708
|
+
t.set([...n, ...be]);
|
|
17709
|
+
}
|
|
17710
|
+
z.infoTick.value++;
|
|
17711
|
+
}, Te = async () => {
|
|
17712
|
+
if (Ce) try {
|
|
17713
|
+
let t = await Ce.list();
|
|
17714
|
+
if (t.length) {
|
|
17715
|
+
be = t.map(Se);
|
|
17716
|
+
let n = ye ? ye.controller : null;
|
|
17717
|
+
if (n) {
|
|
17718
|
+
let t = (e.skills || []).filter((e) => !be.some((t) => t.name === e.name));
|
|
17719
|
+
n.set([...t, ...be]);
|
|
17720
|
+
}
|
|
17721
|
+
z.infoTick.value++;
|
|
17722
|
+
}
|
|
17723
|
+
} catch {}
|
|
17724
|
+
}, Ee = [
|
|
17469
17725
|
he,
|
|
17470
17726
|
...ee ? [g] : [],
|
|
17471
|
-
...te ? [ye =
|
|
17472
|
-
...ne ? [
|
|
17473
|
-
...re ? [
|
|
17474
|
-
...
|
|
17727
|
+
...te ? [ye = Zg(e.skills || [], { readVfs: ne ? (e) => h.files[e]?.content : void 0 })] : [],
|
|
17728
|
+
...ne ? [bv(h)] : [],
|
|
17729
|
+
...re ? [rv({
|
|
17730
|
+
...cv(e, f.contextWindow),
|
|
17475
17731
|
llmInvoke: p,
|
|
17476
17732
|
getRegisteredData: () => j() ? [{ description: j().description ?? "主数据对象" }] : [],
|
|
17477
17733
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_data", "read"]
|
|
17478
17734
|
})] : [],
|
|
17479
17735
|
...ie ? [_] : [],
|
|
17480
|
-
...e.permissions?.length ? [
|
|
17481
|
-
...x && C && S ? [
|
|
17482
|
-
...F ? [
|
|
17483
|
-
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [
|
|
17736
|
+
...e.permissions?.length ? [r_(e.permissions)] : [],
|
|
17737
|
+
...x && C && S ? [g_(S)] : [],
|
|
17738
|
+
...F ? [c_()] : [],
|
|
17739
|
+
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [i_(e.approval)] : [],
|
|
17484
17740
|
...me ? [me] : [],
|
|
17485
17741
|
...ue ? [ue] : [],
|
|
17486
17742
|
...de ? [de] : [],
|
|
17487
17743
|
...e.middleware || [],
|
|
17488
|
-
|
|
17489
|
-
],
|
|
17744
|
+
tb(ve, m, j, i)
|
|
17745
|
+
], De = e.maxMemoryRounds ?? qy, z = {
|
|
17490
17746
|
agentId: r,
|
|
17491
17747
|
store: u,
|
|
17492
17748
|
messages: m,
|
|
@@ -17511,8 +17767,27 @@ function Ny(e, r) {
|
|
|
17511
17767
|
applySnapshot(t) {
|
|
17512
17768
|
t.messages?.length && m.push(...t.messages), t.vfs && h.hydrate && h.hydrate(t.vfs), t.todos?.length && g.reset(t.todos), t.memory && !e.memory && _.reset(t.memory);
|
|
17513
17769
|
},
|
|
17770
|
+
addSkill(e) {
|
|
17771
|
+
let t = be.findIndex((t) => t.name === e.name);
|
|
17772
|
+
t >= 0 ? be[t] = e : be.push(e), we(), Ce && Ce.put(xe(e));
|
|
17773
|
+
},
|
|
17774
|
+
removeSkill(e) {
|
|
17775
|
+
let t = be.findIndex((t) => t.name === e);
|
|
17776
|
+
return t < 0 ? !1 : (be.splice(t, 1), we(), Ce && Ce.remove(e), !0);
|
|
17777
|
+
},
|
|
17778
|
+
listUserSkills() {
|
|
17779
|
+
return be.map((e) => e.name);
|
|
17780
|
+
},
|
|
17781
|
+
getUserSkill(e) {
|
|
17782
|
+
let t = be.find((t) => t.name === e);
|
|
17783
|
+
if (t) return {
|
|
17784
|
+
name: t.name,
|
|
17785
|
+
description: t.description,
|
|
17786
|
+
content: typeof t.getContent == "function" ? t.getContent() : ""
|
|
17787
|
+
};
|
|
17788
|
+
},
|
|
17514
17789
|
afterRound() {
|
|
17515
|
-
|
|
17790
|
+
Ae(), je();
|
|
17516
17791
|
},
|
|
17517
17792
|
async send(t) {
|
|
17518
17793
|
await z.initDone;
|
|
@@ -17567,16 +17842,16 @@ function Ny(e, r) {
|
|
|
17567
17842
|
},
|
|
17568
17843
|
release() {
|
|
17569
17844
|
if (z.refCount--, z.refCount <= 0) {
|
|
17570
|
-
u && (h.flush?.(), u.flush(), u.dispose());
|
|
17845
|
+
u && (h.flush?.(), u.flush(), u.dispose()), Ce && Ce.dispose();
|
|
17571
17846
|
let e = z.mcpClosers.splice(0);
|
|
17572
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
17847
|
+
e.length && Promise.allSettled(e.map((e) => e())), Zy.delete(r);
|
|
17573
17848
|
}
|
|
17574
17849
|
},
|
|
17575
17850
|
resolveConflict: l,
|
|
17576
17851
|
getInfo() {
|
|
17577
17852
|
return {
|
|
17578
17853
|
id: r,
|
|
17579
|
-
model:
|
|
17854
|
+
model: Xy(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17580
17855
|
systemPrompt: D,
|
|
17581
17856
|
tools: R.map((e) => ({
|
|
17582
17857
|
name: e.name,
|
|
@@ -17593,7 +17868,7 @@ function Ny(e, r) {
|
|
|
17593
17868
|
schema: j().schema
|
|
17594
17869
|
} : void 0,
|
|
17595
17870
|
memory: e.memory ?? "",
|
|
17596
|
-
middleware:
|
|
17871
|
+
middleware: Ee.map((e) => e.name),
|
|
17597
17872
|
todos: (z.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
17598
17873
|
content: e.content,
|
|
17599
17874
|
status: e.status
|
|
@@ -17619,7 +17894,7 @@ function Ny(e, r) {
|
|
|
17619
17894
|
};
|
|
17620
17895
|
}
|
|
17621
17896
|
};
|
|
17622
|
-
async function
|
|
17897
|
+
async function Oe() {
|
|
17623
17898
|
if (!u) return;
|
|
17624
17899
|
await u.ready;
|
|
17625
17900
|
let t = e.session || {};
|
|
@@ -17645,11 +17920,14 @@ function Ny(e, r) {
|
|
|
17645
17920
|
} else z.sessionId = await u.createSession(r, t.title);
|
|
17646
17921
|
e.memory && u.save(r, z.sessionId, { memory: e.memory });
|
|
17647
17922
|
}
|
|
17648
|
-
function
|
|
17649
|
-
|
|
17923
|
+
async function ke() {
|
|
17924
|
+
await Te();
|
|
17925
|
+
}
|
|
17926
|
+
function Ae() {
|
|
17927
|
+
let e = J_(m, De);
|
|
17650
17928
|
e.trimmed && m.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17651
17929
|
}
|
|
17652
|
-
function
|
|
17930
|
+
function je() {
|
|
17653
17931
|
if (!z.sessionId || !u) return;
|
|
17654
17932
|
let t = JSON.parse(JSON.stringify(m));
|
|
17655
17933
|
u.save(r, z.sessionId, { messages: t });
|
|
@@ -17657,8 +17935,8 @@ function Ny(e, r) {
|
|
|
17657
17935
|
u.save(r, z.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", z.sessionId, `${m.length} msgs`);
|
|
17658
17936
|
}
|
|
17659
17937
|
return z.initDone = (async () => {
|
|
17660
|
-
if (await
|
|
17661
|
-
let t = await Promise.allSettled(e.mcp.map((e) =>
|
|
17938
|
+
if (await Oe(), await ke(), e.mcp?.length) {
|
|
17939
|
+
let t = await Promise.allSettled(e.mcp.map((e) => W_(e)));
|
|
17662
17940
|
z.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), z.mcpServers = [];
|
|
17663
17941
|
let n = [];
|
|
17664
17942
|
t.forEach((t, r) => {
|
|
@@ -17670,8 +17948,8 @@ function Ny(e, r) {
|
|
|
17670
17948
|
}), t.value.tools.forEach((e) => M.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17671
17949
|
}), R.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${z.mcpServers.length} 个 server`);
|
|
17672
17950
|
}
|
|
17673
|
-
z.agent =
|
|
17674
|
-
...
|
|
17951
|
+
z.agent = Hg({
|
|
17952
|
+
...Xy(e.llm) ? { llm: e.llm } : {
|
|
17675
17953
|
apiKey: e.llm.apiKey,
|
|
17676
17954
|
baseUrl: e.llm.baseUrl,
|
|
17677
17955
|
model: e.llm.model,
|
|
@@ -17680,7 +17958,7 @@ function Ny(e, r) {
|
|
|
17680
17958
|
},
|
|
17681
17959
|
systemPrompt: D,
|
|
17682
17960
|
tools: R,
|
|
17683
|
-
middleware:
|
|
17961
|
+
middleware: Ee,
|
|
17684
17962
|
maxToolRounds: e.maxToolRounds,
|
|
17685
17963
|
maxRetries: e.maxRetries,
|
|
17686
17964
|
maxParallelTools: e.maxParallelTools,
|
|
@@ -17691,23 +17969,23 @@ function Ny(e, r) {
|
|
|
17691
17969
|
}), v.current = z.agent;
|
|
17692
17970
|
})(), z;
|
|
17693
17971
|
}
|
|
17694
|
-
function
|
|
17695
|
-
let t = e.id ??
|
|
17972
|
+
function rb(e) {
|
|
17973
|
+
let t = e.id ?? hy();
|
|
17696
17974
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
17697
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
17698
|
-
a ? i = a : (i =
|
|
17699
|
-
let o = null, s = null, c =
|
|
17700
|
-
async function
|
|
17975
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? Zy.get(t) : void 0;
|
|
17976
|
+
a ? i = a : (i = nb(e, t), e.shareContext && Zy.set(t, i)), i.refCount++;
|
|
17977
|
+
let o = null, s = null, c = Yy(e), l = null, u = null;
|
|
17978
|
+
async function d() {
|
|
17701
17979
|
if (await i.initDone, o) {
|
|
17702
|
-
|
|
17980
|
+
m();
|
|
17703
17981
|
return;
|
|
17704
17982
|
}
|
|
17705
17983
|
if (r === !1) {
|
|
17706
|
-
i.store && (
|
|
17984
|
+
i.store && (l = () => {
|
|
17707
17985
|
i.vfsStore.flush?.(), i.store.flush();
|
|
17708
|
-
},
|
|
17986
|
+
}, u = () => {
|
|
17709
17987
|
document.visibilityState === "hidden" && i.store.flush();
|
|
17710
|
-
}, typeof window < "u" && window.addEventListener("pagehide",
|
|
17988
|
+
}, typeof window < "u" && window.addEventListener("pagehide", l), typeof document < "u" && document.addEventListener("visibilitychange", u));
|
|
17711
17989
|
return;
|
|
17712
17990
|
}
|
|
17713
17991
|
let t = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
|
|
@@ -17715,7 +17993,7 @@ function Py(e) {
|
|
|
17715
17993
|
s = t;
|
|
17716
17994
|
let a = i.agent.debugLogs;
|
|
17717
17995
|
o = ul(/* @__PURE__ */ wi({ setup() {
|
|
17718
|
-
return () => Bs(
|
|
17996
|
+
return () => Bs(_g, {
|
|
17719
17997
|
fetchStream: n ? i.agent.stream : void 0,
|
|
17720
17998
|
fetchResponse: n ? void 0 : (e, t) => {
|
|
17721
17999
|
if (t) {
|
|
@@ -17724,8 +18002,8 @@ function Py(e) {
|
|
|
17724
18002
|
}
|
|
17725
18003
|
return i.agent.invoke(e, t);
|
|
17726
18004
|
},
|
|
17727
|
-
title:
|
|
17728
|
-
placeholder:
|
|
18005
|
+
title: c.title,
|
|
18006
|
+
placeholder: c.placeholder,
|
|
17729
18007
|
debugLogs: a.value,
|
|
17730
18008
|
initialMessages: i.messages,
|
|
17731
18009
|
getInfo: () => i.getInfo(),
|
|
@@ -17735,23 +18013,30 @@ function Py(e) {
|
|
|
17735
18013
|
i.afterRound(), i.store && await i.store.flush();
|
|
17736
18014
|
},
|
|
17737
18015
|
onClear: () => {
|
|
17738
|
-
i.store && (i.sessionId =
|
|
18016
|
+
i.store && (i.sessionId = hy(), 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));
|
|
17739
18017
|
},
|
|
17740
18018
|
pendingConflict: i.pendingConflict.value,
|
|
17741
18019
|
onResolveConflict: (e) => i.resolveConflict(e),
|
|
17742
18020
|
infoTick: i.infoTick,
|
|
17743
18021
|
getSkillContent: i.skillsController ? (e) => i.skillsController.getContent(e) : void 0,
|
|
17744
|
-
|
|
17745
|
-
|
|
18022
|
+
onAddSkill: i.skillsController ? (e) => i.addSkill(e) : void 0,
|
|
18023
|
+
onRemoveSkill: i.skillsController ? (e) => i.removeSkill(e) : void 0,
|
|
18024
|
+
getUserSkillNames: i.skillsController ? () => i.listUserSkills() : void 0,
|
|
18025
|
+
onGetSkill: i.skillsController ? (e) => i.getUserSkill(e) : void 0,
|
|
18026
|
+
drawer: c.drawer === !0,
|
|
18027
|
+
drawerWidth: c.drawerWidth,
|
|
18028
|
+
drawerHidden: c.drawerHidden === !0,
|
|
18029
|
+
inputRows: c.inputRows,
|
|
18030
|
+
onClose: c.onClose ?? (c.drawer === !0 ? () => p() : () => f())
|
|
17746
18031
|
});
|
|
17747
|
-
} })), o.mount(t), i.store && (
|
|
18032
|
+
} })), o.mount(t), c.drawer === !0 && c.drawerHidden === !0 && p(), i.store && (l = () => {
|
|
17748
18033
|
i.vfsStore.flush?.(), i.store.flush();
|
|
17749
|
-
},
|
|
18034
|
+
}, u = () => {
|
|
17750
18035
|
document.visibilityState === "hidden" && i.store.flush();
|
|
17751
|
-
}, typeof window < "u" && window.addEventListener("pagehide",
|
|
18036
|
+
}, typeof window < "u" && window.addEventListener("pagehide", l), typeof document < "u" && document.addEventListener("visibilitychange", u));
|
|
17752
18037
|
}
|
|
17753
|
-
function
|
|
17754
|
-
i.resolveConflict("keep_external"),
|
|
18038
|
+
function f() {
|
|
18039
|
+
i.resolveConflict("keep_external"), l && typeof window < "u" && window.removeEventListener("pagehide", l), u && typeof document < "u" && document.removeEventListener("visibilitychange", u), l = null, u = null;
|
|
17755
18040
|
let e = s?.querySelector?.(".chat-dialog");
|
|
17756
18041
|
if (o && e) {
|
|
17757
18042
|
e.classList.add("cs-leaving");
|
|
@@ -17765,21 +18050,21 @@ function Py(e) {
|
|
|
17765
18050
|
}
|
|
17766
18051
|
o?.unmount(), o = null, s = null, i.release();
|
|
17767
18052
|
}
|
|
17768
|
-
function
|
|
18053
|
+
function p() {
|
|
17769
18054
|
if (!o) return;
|
|
17770
18055
|
let e = s?.querySelector?.(".chat-dialog"), t = s?.querySelector?.(".chat-mask");
|
|
17771
18056
|
e && e.classList.add("cs-hidden"), t && t.classList.add("cs-hidden");
|
|
17772
18057
|
}
|
|
17773
|
-
function
|
|
18058
|
+
function m() {
|
|
17774
18059
|
if (!o) return;
|
|
17775
18060
|
let e = s?.querySelector?.(".chat-dialog"), t = s?.querySelector?.(".chat-mask");
|
|
17776
18061
|
e && e.classList.remove("cs-hidden"), t && t.classList.remove("cs-hidden");
|
|
17777
18062
|
}
|
|
17778
18063
|
return {
|
|
17779
|
-
mount:
|
|
17780
|
-
unmount:
|
|
17781
|
-
hide:
|
|
17782
|
-
show:
|
|
18064
|
+
mount: d,
|
|
18065
|
+
unmount: f,
|
|
18066
|
+
hide: p,
|
|
18067
|
+
show: m,
|
|
17783
18068
|
send: i.send,
|
|
17784
18069
|
switchSession: i.switchSession,
|
|
17785
18070
|
stream: i.stream,
|
|
@@ -17804,6 +18089,16 @@ function Py(e) {
|
|
|
17804
18089
|
}
|
|
17805
18090
|
t.set(e), i.infoTick.value++;
|
|
17806
18091
|
},
|
|
18092
|
+
addSkill: (e) => {
|
|
18093
|
+
if (!i.skillsController) {
|
|
18094
|
+
console.warn("[page-agent-sdk] addSkill 忽略:skills 已关闭(capabilities.skills:false)");
|
|
18095
|
+
return;
|
|
18096
|
+
}
|
|
18097
|
+
i.addSkill(e);
|
|
18098
|
+
},
|
|
18099
|
+
removeSkill: (e) => i.skillsController ? i.removeSkill(e) : (console.warn("[page-agent-sdk] removeSkill 忽略:skills 已关闭(capabilities.skills:false)"), !1),
|
|
18100
|
+
listUserSkills: () => i.listUserSkills(),
|
|
18101
|
+
getUserSkill: (e) => i.getUserSkill(e),
|
|
17807
18102
|
invalidateSkillCache: (e) => {
|
|
17808
18103
|
let t = i.skillsController;
|
|
17809
18104
|
if (!t) {
|
|
@@ -17834,7 +18129,7 @@ function Py(e) {
|
|
|
17834
18129
|
error: "schema 校验失败:" + (t.error?.message ?? "未知错误")
|
|
17835
18130
|
};
|
|
17836
18131
|
}
|
|
17837
|
-
return
|
|
18132
|
+
return f_(r, e), t?.emit !== !1 && i.emit({
|
|
17838
18133
|
type: "data_change",
|
|
17839
18134
|
operation: "set",
|
|
17840
18135
|
value: r
|
|
@@ -17847,7 +18142,7 @@ function Py(e) {
|
|
|
17847
18142
|
}
|
|
17848
18143
|
//#endregion
|
|
17849
18144
|
//#region src/core/sdk/defineTool.ts
|
|
17850
|
-
function
|
|
18145
|
+
function ib(e) {
|
|
17851
18146
|
return n(async (t) => {
|
|
17852
18147
|
let n = await e.handler(t);
|
|
17853
18148
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17858,4 +18153,4 @@ function Fy(e) {
|
|
|
17858
18153
|
});
|
|
17859
18154
|
}
|
|
17860
18155
|
//#endregion
|
|
17861
|
-
export {
|
|
18156
|
+
export { sv as CONTEXT_PRESETS, _g as ChatDialog, ef as CodePreview, a_ as HUMAN_CONFIRM_TOOL_NAME, nf as MessageContent, ah as SkillPanel, W_ as connectMcp, Sl as copyText, Hg as createAgent, i_ as createApprovalMiddleware, rb as createChatSdk, h_ as createCheckpointManager, g_ as createCheckpointMiddleware, sy as createDataOps, c_ as createHumanConfirmMiddleware, s_ as createHumanConfirmTool, Fy as createMemoryBackend, zy as createSessionStore, Wy as createSkillStore, w_ as createSubagentMiddleware, D_ as createSubagentsMiddleware, my as createUsageHintsMiddleware, O_ as createVerifyMiddleware, pv as createVfs, Ly as createWebStorageBackend, P_ as createWriteBackCheck, dy as defineDataToolset, Gg as defineSkill, ib as defineTool, Lg as detectGarbledToolCall, Tg as estimateTokens, ov as extractSchemaHint, V_ as extractText, ly as fetchDocTools, uy as fetchTools, oy as filterByToolMode, lv as formatZodIssues, Dy as isQuotaError, Av as jpEval, dv as jsonParseError, Dg as offloadPassThroughChars, Eg as offloadThresholdChars, iv as presets, cv as resolveContextOptions, wg as resolveModelCaps, Fv as runSandboxedScript, Mv as searchJson, fy as selectBuiltinTools, av as systemPromptHelpers, $ as toolError, xl as useChat, e as z, uv as zodError };
|