page-agent-sdk 1.1.4 → 1.3.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 +6 -4
- package/README.zh-CN.md +5 -3
- package/dist/page-agent-sdk.iife.js +117 -112
- package/dist/page-agent-sdk.js +497 -441
- package/dist/page-agent-sdk.umd.cjs +39 -34
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/SKILL.md +6 -3
- package/skills/page-agent-sdk-integrate/references/advanced.md +69 -2
- package/skills/page-agent-sdk-integrate/references/api.md +16 -0
- package/skills/page-agent-sdk-integrate/references/options.md +2 -2
- package/skills/page-agent-sdk-integrate/references/quickstart.md +33 -1
- package/skills/page-agent-sdk-integrate/references/use-cases.md +31 -0
- package/types/index.d.ts +23 -0
package/dist/page-agent-sdk.js
CHANGED
|
@@ -27,7 +27,7 @@ var v = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), y = proc
|
|
|
27
27
|
}, E = Object.prototype.hasOwnProperty, D = (e, t) => E.call(e, t), O = Array.isArray, k = (e) => R(e) === "[object Map]", A = (e) => R(e) === "[object Set]", j = (e) => R(e) === "[object Date]", M = (e) => typeof e == "function", N = (e) => typeof e == "string", P = (e) => typeof e == "symbol", F = (e) => typeof e == "object" && !!e, I = (e) => (F(e) || M(e)) && M(e.then) && M(e.catch), L = Object.prototype.toString, R = (e) => L.call(e), ee = (e) => R(e).slice(8, -1), te = (e) => R(e) === "[object Object]", ne = (e) => N(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, re = /* @__PURE__ */ _(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"), ie = /* @__PURE__ */ _("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"), ae = (e) => {
|
|
28
28
|
let t = /* @__PURE__ */ Object.create(null);
|
|
29
29
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
30
|
-
}, oe = /-\w/g,
|
|
30
|
+
}, oe = /-\w/g, se = ae((e) => e.replace(oe, (e) => e.slice(1).toUpperCase())), ce = /\B([A-Z])/g, z = ae((e) => e.replace(ce, "-$1").toLowerCase()), le = ae((e) => e.charAt(0).toUpperCase() + e.slice(1)), B = ae((e) => e ? `on${le(e)}` : ""), ue = (e, t) => !Object.is(e, t), de = (e, ...t) => {
|
|
31
31
|
for (let n = 0; n < e.length; n++) e[n](...t);
|
|
32
32
|
}, fe = (e, t, n, r = !1) => {
|
|
33
33
|
Object.defineProperty(e, t, {
|
|
@@ -630,7 +630,7 @@ function zt(e) {
|
|
|
630
630
|
return function(...t) {
|
|
631
631
|
if (process.env.NODE_ENV !== "production") {
|
|
632
632
|
let n = t[0] ? `on key "${t[0]}" ` : "";
|
|
633
|
-
Le(`${
|
|
633
|
+
Le(`${le(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ U(this));
|
|
634
634
|
}
|
|
635
635
|
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
|
|
636
636
|
};
|
|
@@ -1772,7 +1772,7 @@ function Li(e, t, n = ps, r = !1) {
|
|
|
1772
1772
|
return i(), it(), a;
|
|
1773
1773
|
};
|
|
1774
1774
|
return r ? i.unshift(a) : i.push(a), a;
|
|
1775
|
-
} else process.env.NODE_ENV !== "production" && G(`${
|
|
1775
|
+
} else process.env.NODE_ENV !== "production" && G(`${B(Ln[e].replace(/ hook$/, ""))} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`);
|
|
1776
1776
|
}
|
|
1777
1777
|
var Ri = (e) => (t, n = ps) => {
|
|
1778
1778
|
(!Ss || e === "sp") && Li(e, (...e) => t(...e), n);
|
|
@@ -2169,13 +2169,13 @@ function wa(e, t) {
|
|
|
2169
2169
|
return c;
|
|
2170
2170
|
};
|
|
2171
2171
|
}
|
|
2172
|
-
var Ta = null, Ea = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${
|
|
2172
|
+
var Ta = null, Ea = (e, t) => t === "modelValue" || t === "model-value" ? e.modelModifiers : e[`${t}Modifiers`] || e[`${se(t)}Modifiers`] || e[`${z(t)}Modifiers`];
|
|
2173
2173
|
function Da(e, t, ...n) {
|
|
2174
2174
|
if (e.isUnmounted) return;
|
|
2175
2175
|
let r = e.vnode.props || v;
|
|
2176
2176
|
if (process.env.NODE_ENV !== "production") {
|
|
2177
2177
|
let { emitsOptions: r, propsOptions: [i] } = e;
|
|
2178
|
-
if (r) if (!(t in r)) (!i || !(
|
|
2178
|
+
if (r) if (!(t in r)) (!i || !(B(se(t)) in i)) && G(`Component emitted event "${t}" but it is neither declared in the emits option nor as an "${B(se(t))}" prop.`);
|
|
2179
2179
|
else {
|
|
2180
2180
|
let e = r[t];
|
|
2181
2181
|
M(e) && (e(...n) || G(`Invalid event arguments: event validation failed for event "${t}".`));
|
|
@@ -2184,10 +2184,10 @@ function Da(e, t, ...n) {
|
|
|
2184
2184
|
let i = n, a = t.startsWith("update:"), o = a && Ea(r, t.slice(7));
|
|
2185
2185
|
if (o && (o.trim && (i = n.map((e) => N(e) ? e.trim() : e)), o.number && (i = n.map(pe))), process.env.NODE_ENV !== "production" && Nr(e, t, i), process.env.NODE_ENV !== "production") {
|
|
2186
2186
|
let n = t.toLowerCase();
|
|
2187
|
-
n !== t && r[
|
|
2187
|
+
n !== t && r[B(n)] && G(`Event "${n}" is emitted in component ${Ls(e, e.type)} but the handler is registered for "${t}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${z(t)}" instead of "${t}".`);
|
|
2188
2188
|
}
|
|
2189
|
-
let s, c = r[s =
|
|
2190
|
-
!c && a && (c = r[s =
|
|
2189
|
+
let s, c = r[s = B(t)] || r[s = B(se(t))];
|
|
2190
|
+
!c && a && (c = r[s = B(z(t))]), c && zn(c, e, 6, i);
|
|
2191
2191
|
let l = r[s + "Once"];
|
|
2192
2192
|
if (l) {
|
|
2193
2193
|
if (!e.emitted) e.emitted = {};
|
|
@@ -2210,7 +2210,7 @@ function ka(e, t, n = !1) {
|
|
|
2210
2210
|
return !a && !s ? (F(e) && r.set(e, null), null) : (O(a) ? a.forEach((e) => o[e] = null) : w(o, a), F(e) && r.set(e, o), o);
|
|
2211
2211
|
}
|
|
2212
2212
|
function Aa(e, t) {
|
|
2213
|
-
return !e || !S(t) ? !1 : (t = t.slice(2), t = t === "Once" ? t : t.replace(/Once$/, ""), D(e, t[0].toLowerCase() + t.slice(1)) || D(e,
|
|
2213
|
+
return !e || !S(t) ? !1 : (t = t.slice(2), t = t === "Once" ? t : t.replace(/Once$/, ""), D(e, t[0].toLowerCase() + t.slice(1)) || D(e, z(t)) || D(e, t));
|
|
2214
2214
|
}
|
|
2215
2215
|
var ja = !1;
|
|
2216
2216
|
function Ma() {
|
|
@@ -2351,7 +2351,7 @@ function Ja(e, t, n, r) {
|
|
|
2351
2351
|
let u = t[o];
|
|
2352
2352
|
if (c) if (D(a, o)) u !== a[o] && (a[o] = u, l = !0);
|
|
2353
2353
|
else {
|
|
2354
|
-
let t =
|
|
2354
|
+
let t = se(o);
|
|
2355
2355
|
i[t] = Xa(c, s, t, u, e, !1);
|
|
2356
2356
|
}
|
|
2357
2357
|
else u !== a[o] && (a[o] = u, l = !0);
|
|
@@ -2360,7 +2360,7 @@ function Ja(e, t, n, r) {
|
|
|
2360
2360
|
} else {
|
|
2361
2361
|
Ya(e, t, i, a) && (l = !0);
|
|
2362
2362
|
let r;
|
|
2363
|
-
for (let a in s) (!t || !D(t, a) && ((r =
|
|
2363
|
+
for (let a in s) (!t || !D(t, a) && ((r = z(a)) === a || !D(t, r))) && (c ? n && (n[a] !== void 0 || n[r] !== void 0) && (i[a] = Xa(c, s, a, void 0, e, !0)) : delete i[a]);
|
|
2364
2364
|
if (a !== s) for (let e in a) (!t || !D(t, e)) && (delete a[e], l = !0);
|
|
2365
2365
|
}
|
|
2366
2366
|
l && ht(e.attrs, "set", ""), process.env.NODE_ENV !== "production" && to(t || {}, i, e);
|
|
@@ -2370,7 +2370,7 @@ function Ya(e, t, n, r) {
|
|
|
2370
2370
|
if (t) for (let c in t) {
|
|
2371
2371
|
if (re(c)) continue;
|
|
2372
2372
|
let l = t[c], u;
|
|
2373
|
-
i && D(i, u =
|
|
2373
|
+
i && D(i, u = se(c)) ? !a || !a.includes(u) ? n[u] = l : (s ||= {})[u] = l : Aa(e.emitsOptions, c) || (!(c in r) || l !== r[c]) && (r[c] = l, o = !0);
|
|
2374
2374
|
}
|
|
2375
2375
|
if (a) {
|
|
2376
2376
|
let t = /* @__PURE__ */ U(n), r = s || v;
|
|
@@ -2397,7 +2397,7 @@ function Xa(e, t, n, r, i, a) {
|
|
|
2397
2397
|
} else r = e;
|
|
2398
2398
|
i.ce && i.ce._setProp(n, r);
|
|
2399
2399
|
}
|
|
2400
|
-
o[0] && (a && !e ? r = !1 : o[1] && (r === "" || r ===
|
|
2400
|
+
o[0] && (a && !e ? r = !1 : o[1] && (r === "" || r === z(n)) && (r = !0));
|
|
2401
2401
|
}
|
|
2402
2402
|
return r;
|
|
2403
2403
|
}
|
|
@@ -2417,13 +2417,13 @@ function Qa(e, t, n = !1) {
|
|
|
2417
2417
|
if (!a && !c) return F(e) && r.set(e, y), y;
|
|
2418
2418
|
if (O(a)) for (let e = 0; e < a.length; e++) {
|
|
2419
2419
|
process.env.NODE_ENV !== "production" && !N(a[e]) && G("props must be strings when using array syntax.", a[e]);
|
|
2420
|
-
let t =
|
|
2420
|
+
let t = se(a[e]);
|
|
2421
2421
|
$a(t) && (o[t] = v);
|
|
2422
2422
|
}
|
|
2423
2423
|
else if (a) {
|
|
2424
2424
|
process.env.NODE_ENV !== "production" && !F(a) && G("invalid props options", a);
|
|
2425
2425
|
for (let e in a) {
|
|
2426
|
-
let t =
|
|
2426
|
+
let t = se(e);
|
|
2427
2427
|
if ($a(t)) {
|
|
2428
2428
|
let n = a[e], r = o[t] = O(n) || M(n) ? { type: n } : w({}, n), i = r.type, c = !1, l = !0;
|
|
2429
2429
|
if (O(i)) for (let e = 0; e < i.length; ++e) {
|
|
@@ -2448,7 +2448,7 @@ function eo(e) {
|
|
|
2448
2448
|
return e === null ? "null" : typeof e == "function" ? e.name || "" : typeof e == "object" && e.constructor && e.constructor.name || "";
|
|
2449
2449
|
}
|
|
2450
2450
|
function to(e, t, n) {
|
|
2451
|
-
let r = /* @__PURE__ */ U(t), i = n.propsOptions[0], a = Object.keys(e).map((e) =>
|
|
2451
|
+
let r = /* @__PURE__ */ U(t), i = n.propsOptions[0], a = Object.keys(e).map((e) => se(e));
|
|
2452
2452
|
for (let e in i) {
|
|
2453
2453
|
let t = i[e];
|
|
2454
2454
|
t != null && no(e, r[e], t, process.env.NODE_ENV === "production" ? r : /* @__PURE__ */ tn(r), !a.includes(e));
|
|
@@ -2490,7 +2490,7 @@ function io(e, t) {
|
|
|
2490
2490
|
}
|
|
2491
2491
|
function ao(e, t, n) {
|
|
2492
2492
|
if (n.length === 0) return `Prop type [] for prop "${e}" won't match anything. Did you mean to use type Array instead?`;
|
|
2493
|
-
let r = `Invalid prop: type check failed for prop "${e}". Expected ${n.map(
|
|
2493
|
+
let r = `Invalid prop: type check failed for prop "${e}". Expected ${n.map(le).join(" | ")}`, i = n[0], a = ee(t), o = oo(t, i), s = oo(t, a);
|
|
2494
2494
|
return n.length === 1 && so(i) && co(i, a) && (r += ` with value ${o}`), r += `, got ${a} `, so(a) && (r += `with value ${s}.`), r;
|
|
2495
2495
|
}
|
|
2496
2496
|
function oo(e, t) {
|
|
@@ -2577,7 +2577,7 @@ function Eo(e, t) {
|
|
|
2577
2577
|
n.__VUE__ = !0, process.env.NODE_ENV !== "production" && Sr(n.__VUE_DEVTOOLS_GLOBAL_HOOK__, n);
|
|
2578
2578
|
let { insert: r, remove: i, patchProp: a, createElement: o, createText: s, createComment: c, setText: l, setElementText: u, parentNode: d, nextSibling: f, setScopeId: p = b, insertStaticContent: m } = e, h = (e, t, n, r = null, i = null, a = null, o = void 0, s = null, c = process.env.NODE_ENV !== "production" && or ? !1 : !!t.dynamicChildren) => {
|
|
2579
2579
|
if (e === t) return;
|
|
2580
|
-
e && !Jo(e, t) && (r =
|
|
2580
|
+
e && !Jo(e, t) && (r = z(e), ie(e, i, a, !0), e = null), t.patchFlag === -2 && (c = !1, t.dynamicChildren = null);
|
|
2581
2581
|
let { type: l, ref: u, shapeFlag: d } = t;
|
|
2582
2582
|
switch (l) {
|
|
2583
2583
|
case Lo:
|
|
@@ -2738,7 +2738,7 @@ function Eo(e, t) {
|
|
|
2738
2738
|
let p = Na(e);
|
|
2739
2739
|
process.env.NODE_ENV !== "production" && xo(e, "render");
|
|
2740
2740
|
let m = e.subTree;
|
|
2741
|
-
e.subTree = p, process.env.NODE_ENV !== "production" && bo(e, "patch"), h(m, p, d(m.el),
|
|
2741
|
+
e.subTree = p, process.env.NODE_ENV !== "production" && bo(e, "patch"), h(m, p, d(m.el), z(m), e, i, a), process.env.NODE_ENV !== "production" && xo(e, "patch"), t.el = p.el, u === null && Ha(e, p.el), r && wo(r, i), (f = t.props && t.props.onVnodeUpdated) && wo(() => ls(f, s, t, c), i), process.env.NODE_ENV !== "production" && Er(e), process.env.NODE_ENV !== "production" && kn();
|
|
2742
2742
|
} else {
|
|
2743
2743
|
let o, { el: s, props: c } = t, { bm: l, m: u, parent: d, root: f, type: p } = e, m = ji(t);
|
|
2744
2744
|
if (Oo(e, !1), l && de(l), !m && (o = c && c.onVnodeBeforeMount) && ls(o, d, t), Oo(e, !0), s && me) {
|
|
@@ -2778,7 +2778,7 @@ function Eo(e, t) {
|
|
|
2778
2778
|
return;
|
|
2779
2779
|
}
|
|
2780
2780
|
}
|
|
2781
|
-
m & 8 ? (d & 16 &&
|
|
2781
|
+
m & 8 ? (d & 16 && ce(l, i, a), f !== l && u(n, f)) : d & 16 ? m & 16 ? te(l, f, n, r, i, a, o, s, c) : ce(l, i, a, !0) : (d & 8 && u(n, ""), m & 16 && O(f, n, r, i, a, o, s, c));
|
|
2782
2782
|
}, ee = (e, t, n, r, i, a, o, s, c) => {
|
|
2783
2783
|
e ||= y, t ||= y;
|
|
2784
2784
|
let l = e.length, u = t.length, d = Math.min(l, u), f;
|
|
@@ -2786,7 +2786,7 @@ function Eo(e, t) {
|
|
|
2786
2786
|
let r = t[f] = c ? os(t[f]) : as(t[f]);
|
|
2787
2787
|
h(e[f], r, n, null, i, a, o, s, c);
|
|
2788
2788
|
}
|
|
2789
|
-
l > u ?
|
|
2789
|
+
l > u ? ce(e, i, a, !0, !1, d) : O(t, n, r, i, a, o, s, c, d);
|
|
2790
2790
|
}, te = (e, t, n, r, i, a, o, s, c) => {
|
|
2791
2791
|
let l = 0, u = t.length, d = e.length - 1, f = u - 1;
|
|
2792
2792
|
for (; l <= d && l <= f;) {
|
|
@@ -2879,13 +2879,13 @@ function Eo(e, t) {
|
|
|
2879
2879
|
return;
|
|
2880
2880
|
}
|
|
2881
2881
|
let h = u & 1 && f, g = !ji(e), _;
|
|
2882
|
-
if (g && (_ = o && o.onVnodeBeforeUnmount) && ls(_, t, e), u & 6)
|
|
2882
|
+
if (g && (_ = o && o.onVnodeBeforeUnmount) && ls(_, t, e), u & 6) se(e.component, n, r);
|
|
2883
2883
|
else {
|
|
2884
2884
|
if (u & 128) {
|
|
2885
2885
|
e.suspense.unmount(n, r);
|
|
2886
2886
|
return;
|
|
2887
2887
|
}
|
|
2888
|
-
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n, ue, r) : l && !l.hasOnce && (a !== K || d > 0 && d & 64) ?
|
|
2888
|
+
h && Br(e, null, t, "beforeUnmount"), u & 64 ? e.type.remove(e, t, n, ue, r) : l && !l.hasOnce && (a !== K || d > 0 && d & 64) ? ce(l, t, n, !1, !0) : (a === K && d & 384 || !i && u & 16) && ce(c, t, n), r && ae(e);
|
|
2889
2889
|
}
|
|
2890
2890
|
let v = m != null && p == null;
|
|
2891
2891
|
(g && (_ = o && o.onVnodeUnmounted) || h || v) && wo(() => {
|
|
@@ -2914,22 +2914,22 @@ function Eo(e, t) {
|
|
|
2914
2914
|
let n;
|
|
2915
2915
|
for (; e !== t;) n = f(e), i(e), e = n;
|
|
2916
2916
|
i(t);
|
|
2917
|
-
},
|
|
2917
|
+
}, se = (e, t, n) => {
|
|
2918
2918
|
process.env.NODE_ENV !== "production" && e.type.__hmrId && dr(e);
|
|
2919
2919
|
let { bum: r, scope: i, job: a, subTree: o, um: s, m: c, a: l } = e;
|
|
2920
2920
|
No(c), No(l), r && de(r), i.stop(), a && (a.flags |= 8, ie(o, e, t, n)), s && wo(s, t), wo(() => {
|
|
2921
2921
|
e.isUnmounted = !0;
|
|
2922
2922
|
}, t), process.env.NODE_ENV !== "production" && Or(e);
|
|
2923
|
-
},
|
|
2923
|
+
}, ce = (e, t, n, r = !1, i = !1, a = 0) => {
|
|
2924
2924
|
for (let o = a; o < e.length; o++) ie(e[o], t, n, r, i);
|
|
2925
|
-
},
|
|
2926
|
-
if (e.shapeFlag & 6) return
|
|
2925
|
+
}, z = (e) => {
|
|
2926
|
+
if (e.shapeFlag & 6) return z(e.component.subTree);
|
|
2927
2927
|
if (e.shapeFlag & 128) return e.suspense.next();
|
|
2928
2928
|
let t = f(e.anchor || e.el), n = t && t[Xr];
|
|
2929
2929
|
return n ? f(n) : t;
|
|
2930
|
-
},
|
|
2930
|
+
}, le = !1, B = (e, t, n) => {
|
|
2931
2931
|
let r;
|
|
2932
|
-
e == null ? t._vnode && (ie(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e,
|
|
2932
|
+
e == null ? t._vnode && (ie(t._vnode, null, null, !0), r = t._vnode.component) : h(t._vnode || null, e, t, null, null, null, n), t._vnode = e, le ||= (le = !0, tr(r), nr(), !1);
|
|
2933
2933
|
}, ue = {
|
|
2934
2934
|
p: h,
|
|
2935
2935
|
um: ie,
|
|
@@ -2939,13 +2939,13 @@ function Eo(e, t) {
|
|
|
2939
2939
|
mc: O,
|
|
2940
2940
|
pc: R,
|
|
2941
2941
|
pbc: A,
|
|
2942
|
-
n:
|
|
2942
|
+
n: z,
|
|
2943
2943
|
o: e
|
|
2944
2944
|
}, pe, me;
|
|
2945
2945
|
return t && ([pe, me] = t(ue)), {
|
|
2946
|
-
render:
|
|
2946
|
+
render: B,
|
|
2947
2947
|
hydrate: pe,
|
|
2948
|
-
createApp: wa(
|
|
2948
|
+
createApp: wa(B, pe)
|
|
2949
2949
|
};
|
|
2950
2950
|
}
|
|
2951
2951
|
function Do({ type: e, props: t }, n) {
|
|
@@ -3798,7 +3798,7 @@ function Oc(e, t, n) {
|
|
|
3798
3798
|
else if (n ??= "", process.env.NODE_ENV !== "production" && Ec.test(n) && Us(`Unexpected semicolon at the end of '${t}' style value: '${n}'`), t.startsWith("--")) e.setProperty(t, n);
|
|
3799
3799
|
else {
|
|
3800
3800
|
let r = jc(e, t);
|
|
3801
|
-
Dc.test(n) ? e.setProperty(
|
|
3801
|
+
Dc.test(n) ? e.setProperty(z(r), n.replace(Dc, ""), "important") : e[r] = n;
|
|
3802
3802
|
}
|
|
3803
3803
|
}
|
|
3804
3804
|
var kc = [
|
|
@@ -3809,9 +3809,9 @@ var kc = [
|
|
|
3809
3809
|
function jc(e, t) {
|
|
3810
3810
|
let n = Ac[t];
|
|
3811
3811
|
if (n) return n;
|
|
3812
|
-
let r =
|
|
3812
|
+
let r = se(t);
|
|
3813
3813
|
if (r !== "filter" && r in e) return Ac[t] = r;
|
|
3814
|
-
r =
|
|
3814
|
+
r = le(r);
|
|
3815
3815
|
for (let n = 0; n < kc.length; n++) {
|
|
3816
3816
|
let i = kc[n] + r;
|
|
3817
3817
|
if (i in e) return Ac[t] = i;
|
|
@@ -3867,7 +3867,7 @@ var Bc = /(Once|Passive|Capture)$/, Vc = /^on:?(?:Once|Passive|Capture)$/;
|
|
|
3867
3867
|
function Hc(e) {
|
|
3868
3868
|
let t, n;
|
|
3869
3869
|
for (; (n = e.match(Bc)) && !Vc.test(e);) t ||= {}, e = e.slice(0, e.length - n[1].length), t[n[1].toLowerCase()] = !0;
|
|
3870
|
-
return [e[2] === ":" ? e.slice(3) :
|
|
3870
|
+
return [e[2] === ":" ? e.slice(3) : z(e.slice(2)), t];
|
|
3871
3871
|
}
|
|
3872
3872
|
var Uc = 0, Wc = /* @__PURE__ */ Promise.resolve(), Gc = () => Uc ||= (Wc.then(() => Uc = 0), Date.now());
|
|
3873
3873
|
function Kc(e, t) {
|
|
@@ -3895,7 +3895,7 @@ Expected function or array of functions, received type ${typeof e}.`), b);
|
|
|
3895
3895
|
}
|
|
3896
3896
|
var Jc = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && e.charCodeAt(2) > 96 && e.charCodeAt(2) < 123, Yc = (e, t, n, r, i, a) => {
|
|
3897
3897
|
let o = i === "svg";
|
|
3898
|
-
t === "class" ? vc(e, r, o) : t === "style" ? Tc(e, n, r) : S(t) ? C(t) || zc(e, t, n, r, a) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Xc(e, t, r, o)) ? (Fc(e, t, r), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && Pc(e, t, r, o, a, t !== "value")) : e._isVueCE && (Zc(e, t) || e._def.__asyncLoader && (/[A-Z]/.test(t) || !N(r))) ? Fc(e,
|
|
3898
|
+
t === "class" ? vc(e, r, o) : t === "style" ? Tc(e, n, r) : S(t) ? C(t) || zc(e, t, n, r, a) : (t[0] === "." ? (t = t.slice(1), !0) : t[0] === "^" ? (t = t.slice(1), !1) : Xc(e, t, r, o)) ? (Fc(e, t, r), !e.tagName.includes("-") && (t === "value" || t === "checked" || t === "selected") && Pc(e, t, r, o, a, t !== "value")) : e._isVueCE && (Zc(e, t) || e._def.__asyncLoader && (/[A-Z]/.test(t) || !N(r))) ? Fc(e, se(t), r, a, t) : (t === "true-value" ? e._trueValue = r : t === "false-value" && (e._falseValue = r), Pc(e, t, r, o));
|
|
3899
3899
|
};
|
|
3900
3900
|
function Xc(e, t, n, r) {
|
|
3901
3901
|
if (r) return !!(t === "innerHTML" || t === "textContent" || t in e && Jc(t) && M(n));
|
|
@@ -3909,8 +3909,8 @@ function Xc(e, t, n, r) {
|
|
|
3909
3909
|
function Zc(e, t) {
|
|
3910
3910
|
let n = e._def.props;
|
|
3911
3911
|
if (!n) return !1;
|
|
3912
|
-
let r =
|
|
3913
|
-
return Array.isArray(n) ? n.some((e) =>
|
|
3912
|
+
let r = se(t);
|
|
3913
|
+
return Array.isArray(n) ? n.some((e) => se(e) === r) : Object.keys(n).some((e) => se(e) === r);
|
|
3914
3914
|
}
|
|
3915
3915
|
var Qc = (e) => {
|
|
3916
3916
|
let t = e.props["onUpdate:modelValue"] || !1;
|
|
@@ -5976,10 +5976,10 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5976
5976
|
e.begin = e.match, delete e.match;
|
|
5977
5977
|
}
|
|
5978
5978
|
}
|
|
5979
|
-
function
|
|
5979
|
+
function se(e, t) {
|
|
5980
5980
|
e.relevance === void 0 && (e.relevance = 1);
|
|
5981
5981
|
}
|
|
5982
|
-
var
|
|
5982
|
+
var ce = (e, t) => {
|
|
5983
5983
|
if (!e.beforeMatch) return;
|
|
5984
5984
|
if (e.starts) throw Error("beforeMatch cannot be used with starts");
|
|
5985
5985
|
let n = Object.assign({}, e);
|
|
@@ -5989,7 +5989,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
5989
5989
|
relevance: 0,
|
|
5990
5990
|
contains: [Object.assign(n, { endsParent: !0 })]
|
|
5991
5991
|
}, e.relevance = 0, delete n.beforeMatch;
|
|
5992
|
-
},
|
|
5992
|
+
}, z = [
|
|
5993
5993
|
"of",
|
|
5994
5994
|
"and",
|
|
5995
5995
|
"for",
|
|
@@ -6001,11 +6001,11 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6001
6001
|
"parent",
|
|
6002
6002
|
"list",
|
|
6003
6003
|
"value"
|
|
6004
|
-
],
|
|
6005
|
-
function
|
|
6004
|
+
], le = "keyword";
|
|
6005
|
+
function B(e, t, n = le) {
|
|
6006
6006
|
let r = Object.create(null);
|
|
6007
6007
|
return typeof e == "string" ? i(n, e.split(" ")) : Array.isArray(e) ? i(n, e) : Object.keys(e).forEach(function(n) {
|
|
6008
|
-
Object.assign(r,
|
|
6008
|
+
Object.assign(r, B(e[n], t, n));
|
|
6009
6009
|
}), r;
|
|
6010
6010
|
function i(e, n) {
|
|
6011
6011
|
t && (n = n.map((e) => e.toLowerCase())), n.forEach(function(t) {
|
|
@@ -6018,7 +6018,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6018
6018
|
return t ? Number(t) : +!de(e);
|
|
6019
6019
|
}
|
|
6020
6020
|
function de(e) {
|
|
6021
|
-
return
|
|
6021
|
+
return z.includes(e.toLowerCase());
|
|
6022
6022
|
}
|
|
6023
6023
|
var fe = {}, pe = (e) => {
|
|
6024
6024
|
console.error(e);
|
|
@@ -6119,14 +6119,14 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
6119
6119
|
re,
|
|
6120
6120
|
oe,
|
|
6121
6121
|
xe,
|
|
6122
|
-
|
|
6122
|
+
ce
|
|
6123
6123
|
].forEach((e) => e(n, r)), e.compilerExtensions.forEach((e) => e(n, r)), n.__beforeBegin = null, [
|
|
6124
6124
|
ie,
|
|
6125
6125
|
ae,
|
|
6126
|
-
|
|
6126
|
+
se
|
|
6127
6127
|
].forEach((e) => e(n, r)), n.isCompiled = !0;
|
|
6128
6128
|
let s = null;
|
|
6129
|
-
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 &&=
|
|
6129
|
+
return typeof n.keywords == "object" && n.keywords.$pattern && (n.keywords = Object.assign({}, n.keywords), s = n.keywords.$pattern, delete n.keywords.$pattern), s ||= /\w+/, n.keywords &&= B(n.keywords, e.case_insensitive), a.keywordPatternRe = t(s, !0), r && (n.begin ||= /\B|\b/, a.beginRe = t(a.begin), !n.end && !n.endsWithParent && (n.end = /\B|\b/), n.end && (a.endRe = t(a.end)), a.terminatorEnd = p(a.end) || "", n.endsWithParent && r.terminatorEnd && (a.terminatorEnd += (n.end ? "|" : "") + r.terminatorEnd)), n.illegal && (a.illegalRe = t(n.illegal)), n.contains ||= [], n.contains = [].concat(...n.contains.map(function(e) {
|
|
6130
6130
|
return we(e === "self" ? n : e);
|
|
6131
6131
|
})), n.contains.forEach(function(e) {
|
|
6132
6132
|
o(e, a);
|
|
@@ -11345,7 +11345,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11345
11345
|
ie("#"),
|
|
11346
11346
|
re
|
|
11347
11347
|
]
|
|
11348
|
-
}, oe = { match: i(/`/, x, /`/) },
|
|
11348
|
+
}, oe = { match: i(/`/, x, /`/) }, se = [
|
|
11349
11349
|
oe,
|
|
11350
11350
|
{
|
|
11351
11351
|
className: "variable",
|
|
@@ -11355,7 +11355,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11355
11355
|
className: "variable",
|
|
11356
11356
|
match: `\\$${b}+`
|
|
11357
11357
|
}
|
|
11358
|
-
],
|
|
11358
|
+
], ce = [
|
|
11359
11359
|
{
|
|
11360
11360
|
match: /(@|#(un)?)available/,
|
|
11361
11361
|
scope: "keyword",
|
|
@@ -11378,7 +11378,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11378
11378
|
scope: "meta",
|
|
11379
11379
|
match: i(/@/, x)
|
|
11380
11380
|
}
|
|
11381
|
-
],
|
|
11381
|
+
], z = {
|
|
11382
11382
|
match: r(/\b[A-Z]/),
|
|
11383
11383
|
relevance: 0,
|
|
11384
11384
|
contains: [
|
|
@@ -11404,20 +11404,20 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11404
11404
|
relevance: 0
|
|
11405
11405
|
}
|
|
11406
11406
|
]
|
|
11407
|
-
},
|
|
11407
|
+
}, le = {
|
|
11408
11408
|
begin: /</,
|
|
11409
11409
|
end: />/,
|
|
11410
11410
|
keywords: D,
|
|
11411
11411
|
contains: [
|
|
11412
11412
|
...a,
|
|
11413
11413
|
...O,
|
|
11414
|
-
...
|
|
11414
|
+
...ce,
|
|
11415
11415
|
A,
|
|
11416
|
-
|
|
11416
|
+
z
|
|
11417
11417
|
]
|
|
11418
11418
|
};
|
|
11419
|
-
|
|
11420
|
-
let
|
|
11419
|
+
z.contains.push(le);
|
|
11420
|
+
let B = {
|
|
11421
11421
|
begin: /\(/,
|
|
11422
11422
|
end: /\)/,
|
|
11423
11423
|
relevance: 0,
|
|
@@ -11436,15 +11436,15 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11436
11436
|
...j,
|
|
11437
11437
|
P,
|
|
11438
11438
|
te,
|
|
11439
|
-
...z,
|
|
11440
11439
|
...se,
|
|
11441
|
-
|
|
11440
|
+
...ce,
|
|
11441
|
+
z
|
|
11442
11442
|
]
|
|
11443
11443
|
}, ue = {
|
|
11444
11444
|
begin: /</,
|
|
11445
11445
|
end: />/,
|
|
11446
11446
|
keywords: "repeat each",
|
|
11447
|
-
contains: [...a,
|
|
11447
|
+
contains: [...a, z]
|
|
11448
11448
|
}, de = {
|
|
11449
11449
|
begin: /\(/,
|
|
11450
11450
|
end: /\)/,
|
|
@@ -11467,9 +11467,9 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11467
11467
|
...j,
|
|
11468
11468
|
P,
|
|
11469
11469
|
te,
|
|
11470
|
-
...
|
|
11471
|
-
|
|
11472
|
-
|
|
11470
|
+
...ce,
|
|
11471
|
+
z,
|
|
11472
|
+
B
|
|
11473
11473
|
],
|
|
11474
11474
|
endsParent: !0,
|
|
11475
11475
|
illegal: /["']/
|
|
@@ -11518,7 +11518,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11518
11518
|
1: "keyword",
|
|
11519
11519
|
3: "title"
|
|
11520
11520
|
},
|
|
11521
|
-
contains: [
|
|
11521
|
+
contains: [z],
|
|
11522
11522
|
keywords: [...p, ...f],
|
|
11523
11523
|
end: /}/
|
|
11524
11524
|
}, ge = {
|
|
@@ -11580,7 +11580,7 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11580
11580
|
...j,
|
|
11581
11581
|
P,
|
|
11582
11582
|
te,
|
|
11583
|
-
...
|
|
11583
|
+
...se
|
|
11584
11584
|
];
|
|
11585
11585
|
t.contains = [...n, {
|
|
11586
11586
|
begin: /\(/,
|
|
@@ -11612,10 +11612,10 @@ var ed = /* @__PURE__ */ m(((e, t) => {
|
|
|
11612
11612
|
...j,
|
|
11613
11613
|
P,
|
|
11614
11614
|
te,
|
|
11615
|
-
...z,
|
|
11616
11615
|
...se,
|
|
11617
|
-
|
|
11618
|
-
|
|
11616
|
+
...ce,
|
|
11617
|
+
z,
|
|
11618
|
+
B
|
|
11619
11619
|
]
|
|
11620
11620
|
};
|
|
11621
11621
|
}
|
|
@@ -14683,25 +14683,25 @@ function Qg(e, t) {
|
|
|
14683
14683
|
return n;
|
|
14684
14684
|
}
|
|
14685
14685
|
function $g(e = {}) {
|
|
14686
|
-
let t = e.window ?? globalThis.window, n = e.schemas ?? {};
|
|
14686
|
+
let t = e.window ?? globalThis.window, n = typeof e.schemas == "function" ? e.schemas : () => e.schemas ?? {};
|
|
14687
14687
|
return async ({ messages: e }) => {
|
|
14688
14688
|
let r = Xg(e);
|
|
14689
14689
|
if (!r.length) return { ok: !0 };
|
|
14690
|
-
let i = Zg(e), a = [];
|
|
14691
|
-
for (let { path: e, op:
|
|
14690
|
+
let i = Zg(e), a = n(), o = [];
|
|
14691
|
+
for (let { path: e, op: n, callId: s } of r) {
|
|
14692
14692
|
let r = s ? i.get(s) : void 0;
|
|
14693
14693
|
if (r && Yg.test(r)) continue;
|
|
14694
14694
|
let c = Qg(t, e);
|
|
14695
|
-
if (
|
|
14696
|
-
else if (c == null)
|
|
14697
|
-
else if (
|
|
14698
|
-
let t =
|
|
14699
|
-
t.success ||
|
|
14695
|
+
if (n === "delete_window_prop") c !== void 0 && o.push(`${e} 删除后读回仍有值,疑似未生效`);
|
|
14696
|
+
else if (c == null) o.push(`写入 ${e} 后读回为空,疑似未生效`);
|
|
14697
|
+
else if (a[e]) {
|
|
14698
|
+
let t = a[e].safeParse(c);
|
|
14699
|
+
t.success || o.push(`${e} 读回值不符合 schema:${t.error.issues?.[0]?.message ?? "校验失败"}`);
|
|
14700
14700
|
}
|
|
14701
14701
|
}
|
|
14702
|
-
return
|
|
14702
|
+
return o.length ? {
|
|
14703
14703
|
ok: !1,
|
|
14704
|
-
feedback:
|
|
14704
|
+
feedback: o.join(";\n")
|
|
14705
14705
|
} : { ok: !0 };
|
|
14706
14706
|
};
|
|
14707
14707
|
}
|
|
@@ -14876,10 +14876,15 @@ function v_(e) {
|
|
|
14876
14876
|
for (let n of e.assistantMsgs) t += __(n);
|
|
14877
14877
|
return t;
|
|
14878
14878
|
}
|
|
14879
|
-
function y_(e) {
|
|
14879
|
+
function y_(e, t) {
|
|
14880
14880
|
return e.map((e) => {
|
|
14881
|
-
let
|
|
14882
|
-
|
|
14881
|
+
let n = d_(e.userMsg.content, 60) || "(空)", r = e.assistantMsgs[0] ? d_(e.assistantMsgs[0].content, 80) : "(无回复)", i = e.assistantMsgs.flatMap((e) => (e.steps || []).map((e) => e.name)), a = i.length ? ` [工具: ${i.join(", ")}]` : "", o = "";
|
|
14882
|
+
if (t && t.size) {
|
|
14883
|
+
let n = [];
|
|
14884
|
+
for (let r of e.assistantMsgs) for (let e of r.steps || []) e.name && t.has(e.name) && e.result && n.push(`${e.name}: ${d_(e.result, 120)}`);
|
|
14885
|
+
n.length && (o = `\n 字段提示: ${n.join(" | ")}`);
|
|
14886
|
+
}
|
|
14887
|
+
return `- 第${e.round}轮:${n} → ${r}${a}${o}`;
|
|
14883
14888
|
}).join("\n");
|
|
14884
14889
|
}
|
|
14885
14890
|
function b_(e, t, n) {
|
|
@@ -14925,32 +14930,38 @@ function x_(e = {}) {
|
|
|
14925
14930
|
let e = Math.min(t.windowRounds, n.length);
|
|
14926
14931
|
a = n.slice(n.length - e), o = n.slice(0, n.length - e), s = "window+";
|
|
14927
14932
|
}
|
|
14928
|
-
let c = [...e].reverse().find((e) => e.role === "user")?.content || "", l, u;
|
|
14933
|
+
let c = [...e].reverse().find((e) => e.role === "user")?.content || "", l = t.preserveLastToolResults?.length ? new Set(t.preserveLastToolResults) : void 0, u, d;
|
|
14929
14934
|
if (t.enableLLMSummary && t.llmInvoke) try {
|
|
14930
|
-
|
|
14935
|
+
u = await t.llmInvoke(y_(o, l)), d = s + "llm_summary";
|
|
14931
14936
|
} catch {
|
|
14932
|
-
|
|
14933
|
-
}
|
|
14934
|
-
else
|
|
14935
|
-
let
|
|
14936
|
-
|
|
14937
|
-
|
|
14937
|
+
u = y_(o, l), d = s + "index_summary(llm_fallback)";
|
|
14938
|
+
}
|
|
14939
|
+
else u = y_(o, l), d = s + "index_summary";
|
|
14940
|
+
let f = t.enableRecall ? b_(o, c, t.recallTopK) : [], p = f.length ? f.map((e) => `- 第${e.round}轮:${d_(e.userMsg.content, 60)} → ${e.assistantMsgs[0] ? d_(e.assistantMsgs[0].content, 80) : ""}`).join("\n") : "", m = [`【对话历史摘要】以下是之前 ${o.length} 轮对话的要点(最新 ${a.length} 轮已完整保留):`, u];
|
|
14941
|
+
if (p && m.push("\n【与当前问题可能相关的早期对话】", p), t.getRegisteredProps) try {
|
|
14942
|
+
let e = t.getRegisteredProps();
|
|
14943
|
+
if (e.length) {
|
|
14944
|
+
let t = e.map((e) => `- ${e.path}: ${e.description}`).join("\n");
|
|
14945
|
+
m.push("\n【当前可操作 window 属性(动态增删后的最新状态,操作前以 list_window_props 为准)】", t);
|
|
14946
|
+
}
|
|
14947
|
+
} catch {}
|
|
14948
|
+
let h = {
|
|
14938
14949
|
role: "system",
|
|
14939
|
-
content:
|
|
14950
|
+
content: m.join("\n"),
|
|
14940
14951
|
timestamp: Date.now()
|
|
14941
|
-
},
|
|
14942
|
-
for (let e of a)
|
|
14943
|
-
let
|
|
14952
|
+
}, g = [];
|
|
14953
|
+
for (let e of a) g.push(e.userMsg), g.push(...e.assistantMsgs);
|
|
14954
|
+
let _ = [h, ...g];
|
|
14944
14955
|
return {
|
|
14945
|
-
messages:
|
|
14956
|
+
messages: _,
|
|
14946
14957
|
stats: {
|
|
14947
14958
|
triggered: !0,
|
|
14948
14959
|
roundsTotal: n.length,
|
|
14949
14960
|
roundsSummarized: o.length,
|
|
14950
|
-
roundsRecalled:
|
|
14961
|
+
roundsRecalled: f.length,
|
|
14951
14962
|
originalMessages: r,
|
|
14952
|
-
compressedMessages:
|
|
14953
|
-
strategy:
|
|
14963
|
+
compressedMessages: _.length,
|
|
14964
|
+
strategy: d
|
|
14954
14965
|
}
|
|
14955
14966
|
};
|
|
14956
14967
|
}
|
|
@@ -14993,8 +15004,29 @@ function C_(e = {}) {
|
|
|
14993
15004
|
};
|
|
14994
15005
|
}
|
|
14995
15006
|
//#endregion
|
|
14996
|
-
//#region src/core/
|
|
15007
|
+
//#region src/core/presets.ts
|
|
14997
15008
|
var w_ = {
|
|
15009
|
+
pageBuilder: { systemPrompt: "你是页面构建助手。流程:get_window_prop 读取当前页面结构 → set_window_prop / edit_window_prop 修改属性 → 页面实时更新。多步任务先用 write_todos 拆解,逐步推进。" },
|
|
15010
|
+
researcher: {
|
|
15011
|
+
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
15012
|
+
subagent: { maxParallel: 4 }
|
|
15013
|
+
},
|
|
15014
|
+
minimal: { capabilities: {
|
|
15015
|
+
planning: !1,
|
|
15016
|
+
skills: !1,
|
|
15017
|
+
vfs: !1,
|
|
15018
|
+
summarization: !1,
|
|
15019
|
+
memory: !1,
|
|
15020
|
+
subagent: !1
|
|
15021
|
+
} }
|
|
15022
|
+
}, T_ = { reliableWriteRules: [
|
|
15023
|
+
"【可靠写入规则】",
|
|
15024
|
+
"1. 改任何属性前,先用 get_window_prop 读其当前真实值,基于真实值改,不要凭记忆;",
|
|
15025
|
+
"2. 若不确定可操作哪些属性,先 list_window_props 查看当前注册项(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);",
|
|
15026
|
+
"3. 不确定某属性字段结构时,先 describe_window_prop 看其说明,字段以 describe 返回为准;",
|
|
15027
|
+
"4. 写入若被 schema 校验拒绝(返回结构化错误含字段名与期望类型),按错误修正后重试,不要放弃;",
|
|
15028
|
+
"5. 优先用 edit_window_prop 增量 patch(只发改动),避免 set 整体重传大 JSON 被截断。"
|
|
15029
|
+
].join("\n") }, E_ = {
|
|
14998
15030
|
auto: {
|
|
14999
15031
|
summaryThresholdRatio: .5,
|
|
15000
15032
|
windowRatio: .4,
|
|
@@ -15016,8 +15048,8 @@ var w_ = {
|
|
|
15016
15048
|
enableLLMSummary: !0
|
|
15017
15049
|
}
|
|
15018
15050
|
};
|
|
15019
|
-
function
|
|
15020
|
-
let n =
|
|
15051
|
+
function D_(e, t) {
|
|
15052
|
+
let n = E_[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
15021
15053
|
return {
|
|
15022
15054
|
...n,
|
|
15023
15055
|
...r,
|
|
@@ -15034,7 +15066,7 @@ function $(e) {
|
|
|
15034
15066
|
};
|
|
15035
15067
|
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)}`;
|
|
15036
15068
|
}
|
|
15037
|
-
function
|
|
15069
|
+
function O_(e) {
|
|
15038
15070
|
return e.slice(0, 10).map((e) => {
|
|
15039
15071
|
let t = e, n = {
|
|
15040
15072
|
path: (Array.isArray(t.path) ? t.path.join(".") : String(t.path ?? "")) || "(root)",
|
|
@@ -15043,16 +15075,16 @@ function E_(e) {
|
|
|
15043
15075
|
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;
|
|
15044
15076
|
});
|
|
15045
15077
|
}
|
|
15046
|
-
function
|
|
15078
|
+
function k_(e, t) {
|
|
15047
15079
|
return $({
|
|
15048
15080
|
code: "SCHEMA_INVALID",
|
|
15049
15081
|
path: e,
|
|
15050
15082
|
message: `值不符合 "${e}" 的 schema(${t.length} 处问题)`,
|
|
15051
15083
|
hint: `按 describe_window_prop("${e}") 查看格式,修正后重试;改大对象优先用 edit_window_prop 增量 patch(只发改动部分)`,
|
|
15052
|
-
details:
|
|
15084
|
+
details: O_(t)
|
|
15053
15085
|
});
|
|
15054
15086
|
}
|
|
15055
|
-
function
|
|
15087
|
+
function A_(e, t, n) {
|
|
15056
15088
|
let r = n?.message || String(n);
|
|
15057
15089
|
return $({
|
|
15058
15090
|
code: "JSON_PARSE",
|
|
@@ -15061,18 +15093,18 @@ function O_(e, t, n) {
|
|
|
15061
15093
|
hint: `检查引号/逗号/括号是否闭合;字符串值需双引号包裹(如 '"dark"' 表示字符串 dark,数字直接写如 5);预览前 80 字符:${t.slice(0, 80)}`
|
|
15062
15094
|
});
|
|
15063
15095
|
}
|
|
15064
|
-
var
|
|
15065
|
-
function
|
|
15096
|
+
var j_ = .9;
|
|
15097
|
+
function M_(e, t = {}) {
|
|
15066
15098
|
let n = Object.create(null);
|
|
15067
|
-
if (e) for (let [t, r] of Object.entries(e)) n[
|
|
15099
|
+
if (e) for (let [t, r] of Object.entries(e)) n[F_(t)] = {
|
|
15068
15100
|
content: r,
|
|
15069
|
-
updatedAt:
|
|
15101
|
+
updatedAt: L_()
|
|
15070
15102
|
};
|
|
15071
15103
|
let { persist: r } = t, i = t.maxBytes ?? 4194304;
|
|
15072
15104
|
function a() {
|
|
15073
|
-
if (
|
|
15074
|
-
let e = i *
|
|
15075
|
-
for (let [r] of t) if (delete n[r],
|
|
15105
|
+
if (P_(n) <= i) return;
|
|
15106
|
+
let e = i * j_, t = Object.entries(n).sort((e, t) => e[1].updatedAt - t[1].updatedAt);
|
|
15107
|
+
for (let [r] of t) if (delete n[r], P_(n) <= e) break;
|
|
15076
15108
|
}
|
|
15077
15109
|
let o = null;
|
|
15078
15110
|
function s() {
|
|
@@ -15097,7 +15129,7 @@ function A_(e, t = {}) {
|
|
|
15097
15129
|
}
|
|
15098
15130
|
}) };
|
|
15099
15131
|
return r && (l.hydrate = (e) => {
|
|
15100
|
-
for (let [t, r] of Object.entries(e)) n[
|
|
15132
|
+
for (let [t, r] of Object.entries(e)) n[F_(t)] = r;
|
|
15101
15133
|
a();
|
|
15102
15134
|
}, l.flush = () => {
|
|
15103
15135
|
o &&= (clearTimeout(o), null), s();
|
|
@@ -15106,17 +15138,17 @@ function A_(e, t = {}) {
|
|
|
15106
15138
|
c();
|
|
15107
15139
|
}), l;
|
|
15108
15140
|
}
|
|
15109
|
-
var
|
|
15110
|
-
function
|
|
15111
|
-
|
|
15141
|
+
var N_ = null;
|
|
15142
|
+
function P_(e) {
|
|
15143
|
+
N_ ||= new TextEncoder();
|
|
15112
15144
|
let t = 0;
|
|
15113
|
-
for (let n of Object.values(e)) t +=
|
|
15145
|
+
for (let n of Object.values(e)) t += N_.encode(n.content).length;
|
|
15114
15146
|
return t;
|
|
15115
15147
|
}
|
|
15116
|
-
function
|
|
15148
|
+
function F_(e) {
|
|
15117
15149
|
return e.replace(/^\/+/, "").replace(/\/+/g, "/");
|
|
15118
15150
|
}
|
|
15119
|
-
function
|
|
15151
|
+
function I_(e) {
|
|
15120
15152
|
let t = "";
|
|
15121
15153
|
for (let n = 0; n < e.length; n++) {
|
|
15122
15154
|
let r = e[n];
|
|
@@ -15124,13 +15156,13 @@ function P_(e) {
|
|
|
15124
15156
|
}
|
|
15125
15157
|
return RegExp("^" + t + "$");
|
|
15126
15158
|
}
|
|
15127
|
-
function
|
|
15159
|
+
function L_() {
|
|
15128
15160
|
return Date.now();
|
|
15129
15161
|
}
|
|
15130
|
-
function
|
|
15162
|
+
function R_(e) {
|
|
15131
15163
|
return [
|
|
15132
15164
|
n(async ({ path: t, offset: n, limit: r }) => {
|
|
15133
|
-
let i = e.files[
|
|
15165
|
+
let i = e.files[F_(t)];
|
|
15134
15166
|
if (!i) return $({
|
|
15135
15167
|
code: "NOT_FOUND",
|
|
15136
15168
|
path: t,
|
|
@@ -15148,9 +15180,9 @@ function I_(e) {
|
|
|
15148
15180
|
limit: t.number().int().min(1).default(2e3).describe("读取行数")
|
|
15149
15181
|
})
|
|
15150
15182
|
}),
|
|
15151
|
-
n(async ({ path: t, content: n }) => (e.files[
|
|
15183
|
+
n(async ({ path: t, content: n }) => (e.files[F_(t)] = {
|
|
15152
15184
|
content: n,
|
|
15153
|
-
updatedAt:
|
|
15185
|
+
updatedAt: L_()
|
|
15154
15186
|
}, `已写入 ${t}(${n.length} 字符)`), {
|
|
15155
15187
|
name: "vfs_write",
|
|
15156
15188
|
description: "写入/覆盖虚拟工作区文件,作为中间工作记忆。",
|
|
@@ -15160,7 +15192,7 @@ function I_(e) {
|
|
|
15160
15192
|
})
|
|
15161
15193
|
}),
|
|
15162
15194
|
n(async ({ path: t, oldString: n, newString: r }) => {
|
|
15163
|
-
let i =
|
|
15195
|
+
let i = F_(t), a = e.files[i];
|
|
15164
15196
|
if (!a) return $({
|
|
15165
15197
|
code: "NOT_FOUND",
|
|
15166
15198
|
path: t,
|
|
@@ -15190,7 +15222,7 @@ function I_(e) {
|
|
|
15190
15222
|
}
|
|
15191
15223
|
return e.files[i] = {
|
|
15192
15224
|
content: a.content.replace(n, r),
|
|
15193
|
-
updatedAt:
|
|
15225
|
+
updatedAt: L_()
|
|
15194
15226
|
}, `已替换 ${t} 中 1 处。`;
|
|
15195
15227
|
}, {
|
|
15196
15228
|
name: "vfs_edit",
|
|
@@ -15212,7 +15244,7 @@ function I_(e) {
|
|
|
15212
15244
|
n(async ({ pattern: t }) => {
|
|
15213
15245
|
let n;
|
|
15214
15246
|
try {
|
|
15215
|
-
n =
|
|
15247
|
+
n = I_(t);
|
|
15216
15248
|
} catch (e) {
|
|
15217
15249
|
return $({
|
|
15218
15250
|
code: "GLOB_INVALID",
|
|
@@ -15241,7 +15273,7 @@ function I_(e) {
|
|
|
15241
15273
|
details: { pattern: t }
|
|
15242
15274
|
});
|
|
15243
15275
|
}
|
|
15244
|
-
let i = n ? [
|
|
15276
|
+
let i = n ? [F_(n)] : Object.keys(e.files), a = [];
|
|
15245
15277
|
for (let t of i) {
|
|
15246
15278
|
let n = e.files[t];
|
|
15247
15279
|
n && n.content.split("\n").forEach((e, n) => {
|
|
@@ -15259,17 +15291,17 @@ function I_(e) {
|
|
|
15259
15291
|
})
|
|
15260
15292
|
];
|
|
15261
15293
|
}
|
|
15262
|
-
function
|
|
15294
|
+
function z_(e) {
|
|
15263
15295
|
return {
|
|
15264
15296
|
name: "vfs",
|
|
15265
|
-
tools:
|
|
15297
|
+
tools: R_(e),
|
|
15266
15298
|
beforeAgent: () => ({ files: e.files })
|
|
15267
15299
|
};
|
|
15268
15300
|
}
|
|
15269
15301
|
//#endregion
|
|
15270
15302
|
//#region src/core/tools/windowQuery.ts
|
|
15271
|
-
var
|
|
15272
|
-
function
|
|
15303
|
+
var B_ = /[\w$-]/;
|
|
15304
|
+
function V_(e) {
|
|
15273
15305
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
15274
15306
|
for (; r < n.length;) {
|
|
15275
15307
|
let e = n[r];
|
|
@@ -15280,7 +15312,7 @@ function z_(e) {
|
|
|
15280
15312
|
continue;
|
|
15281
15313
|
}
|
|
15282
15314
|
let e = "";
|
|
15283
|
-
for (; r < n.length &&
|
|
15315
|
+
for (; r < n.length && B_.test(n[r]);) e += n[r++];
|
|
15284
15316
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
15285
15317
|
t.push({
|
|
15286
15318
|
type: "descendKey",
|
|
@@ -15293,7 +15325,7 @@ function z_(e) {
|
|
|
15293
15325
|
continue;
|
|
15294
15326
|
}
|
|
15295
15327
|
let e = "";
|
|
15296
|
-
for (; r < n.length &&
|
|
15328
|
+
for (; r < n.length && B_.test(n[r]);) e += n[r++];
|
|
15297
15329
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
15298
15330
|
t.push({
|
|
15299
15331
|
type: "key",
|
|
@@ -15349,7 +15381,7 @@ function z_(e) {
|
|
|
15349
15381
|
}
|
|
15350
15382
|
return t;
|
|
15351
15383
|
}
|
|
15352
|
-
function
|
|
15384
|
+
function H_(e) {
|
|
15353
15385
|
let t = [], n = 0, r = e.trim();
|
|
15354
15386
|
for (; n < r.length;) {
|
|
15355
15387
|
let e = r[n];
|
|
@@ -15394,7 +15426,7 @@ function B_(e) {
|
|
|
15394
15426
|
}
|
|
15395
15427
|
return t;
|
|
15396
15428
|
}
|
|
15397
|
-
var
|
|
15429
|
+
var U_ = class {
|
|
15398
15430
|
toks;
|
|
15399
15431
|
item;
|
|
15400
15432
|
pos = 0;
|
|
@@ -15430,12 +15462,12 @@ var V_ = class {
|
|
|
15430
15462
|
return this.next(), e;
|
|
15431
15463
|
}
|
|
15432
15464
|
let e = this.operand(), t = this.peek();
|
|
15433
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
15465
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), K_(t, e, this.operand())) : W_(e);
|
|
15434
15466
|
}
|
|
15435
15467
|
operand() {
|
|
15436
15468
|
let e = this.next();
|
|
15437
15469
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
15438
|
-
if (e.startsWith("@")) return
|
|
15470
|
+
if (e.startsWith("@")) return G_(e, this.item);
|
|
15439
15471
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
15440
15472
|
if (e === "true") return !0;
|
|
15441
15473
|
if (e === "false") return !1;
|
|
@@ -15445,10 +15477,10 @@ var V_ = class {
|
|
|
15445
15477
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
15446
15478
|
}
|
|
15447
15479
|
};
|
|
15448
|
-
function
|
|
15480
|
+
function W_(e) {
|
|
15449
15481
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
15450
15482
|
}
|
|
15451
|
-
function
|
|
15483
|
+
function G_(e, t) {
|
|
15452
15484
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
15453
15485
|
for (let e of n) {
|
|
15454
15486
|
if (typeof r != "object" || !r) return;
|
|
@@ -15456,7 +15488,7 @@ function U_(e, t) {
|
|
|
15456
15488
|
}
|
|
15457
15489
|
return r;
|
|
15458
15490
|
}
|
|
15459
|
-
function
|
|
15491
|
+
function K_(e, t, n) {
|
|
15460
15492
|
switch (e) {
|
|
15461
15493
|
case "==": return t === n;
|
|
15462
15494
|
case "!=": return t !== n;
|
|
@@ -15467,47 +15499,47 @@ function W_(e, t, n) {
|
|
|
15467
15499
|
default: return !1;
|
|
15468
15500
|
}
|
|
15469
15501
|
}
|
|
15470
|
-
function
|
|
15471
|
-
return new
|
|
15502
|
+
function q_(e, t) {
|
|
15503
|
+
return new U_(H_(e), t).parse();
|
|
15472
15504
|
}
|
|
15473
|
-
function
|
|
15505
|
+
function J_(e, t) {
|
|
15474
15506
|
return e ? `${e}.${t}` : String(t);
|
|
15475
15507
|
}
|
|
15476
|
-
function
|
|
15508
|
+
function Y_(e, t) {
|
|
15477
15509
|
let n = [{
|
|
15478
15510
|
path: "",
|
|
15479
15511
|
value: e
|
|
15480
15512
|
}];
|
|
15481
|
-
for (let e of
|
|
15513
|
+
for (let e of V_(t)) {
|
|
15482
15514
|
let t = [];
|
|
15483
15515
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
15484
|
-
path:
|
|
15516
|
+
path: J_(r.path, e.key),
|
|
15485
15517
|
value: r.value[e.key]
|
|
15486
15518
|
});
|
|
15487
15519
|
else if (e.type === "index") {
|
|
15488
15520
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
15489
15521
|
let n = r.value[e.index];
|
|
15490
15522
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
15491
|
-
path:
|
|
15523
|
+
path: J_(r.path, e.index),
|
|
15492
15524
|
value: n,
|
|
15493
15525
|
index: e.index
|
|
15494
15526
|
});
|
|
15495
15527
|
}
|
|
15496
15528
|
} else if (e.type === "wildcard") {
|
|
15497
15529
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
15498
|
-
path:
|
|
15530
|
+
path: J_(e.path, r),
|
|
15499
15531
|
value: n,
|
|
15500
15532
|
index: r
|
|
15501
15533
|
}));
|
|
15502
15534
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
15503
|
-
path:
|
|
15535
|
+
path: J_(e.path, n),
|
|
15504
15536
|
value: e.value[n]
|
|
15505
15537
|
});
|
|
15506
15538
|
} else if (e.type === "descendKey") {
|
|
15507
15539
|
let r = e.key, i = (e) => {
|
|
15508
15540
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
15509
15541
|
let a = {
|
|
15510
|
-
path:
|
|
15542
|
+
path: J_(e.path, n),
|
|
15511
15543
|
value: e.value[n]
|
|
15512
15544
|
};
|
|
15513
15545
|
n === r && t.push(a), i(a);
|
|
@@ -15518,7 +15550,7 @@ function q_(e, t) {
|
|
|
15518
15550
|
let e = (n) => {
|
|
15519
15551
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
15520
15552
|
let i = {
|
|
15521
|
-
path:
|
|
15553
|
+
path: J_(n.path, r),
|
|
15522
15554
|
value: n.value[r]
|
|
15523
15555
|
};
|
|
15524
15556
|
t.push(i), e(i);
|
|
@@ -15527,16 +15559,16 @@ function q_(e, t) {
|
|
|
15527
15559
|
for (let t of n) e(t);
|
|
15528
15560
|
} else if (e.type === "filter") {
|
|
15529
15561
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
15530
|
-
|
|
15531
|
-
path:
|
|
15562
|
+
q_(e.filter, n) && t.push({
|
|
15563
|
+
path: J_(r.path, i),
|
|
15532
15564
|
value: n,
|
|
15533
15565
|
index: i
|
|
15534
15566
|
});
|
|
15535
15567
|
});
|
|
15536
15568
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
15537
15569
|
let i = r.value[n];
|
|
15538
|
-
|
|
15539
|
-
path:
|
|
15570
|
+
q_(e.filter, i) && t.push({
|
|
15571
|
+
path: J_(r.path, n),
|
|
15540
15572
|
value: i
|
|
15541
15573
|
});
|
|
15542
15574
|
}
|
|
@@ -15545,7 +15577,7 @@ function q_(e, t) {
|
|
|
15545
15577
|
}
|
|
15546
15578
|
return n;
|
|
15547
15579
|
}
|
|
15548
|
-
function
|
|
15580
|
+
function X_(e, t) {
|
|
15549
15581
|
let n = e.length, r = t.length;
|
|
15550
15582
|
if (!n) return r;
|
|
15551
15583
|
if (!r) return n;
|
|
@@ -15561,7 +15593,7 @@ function J_(e, t) {
|
|
|
15561
15593
|
}
|
|
15562
15594
|
return i[r];
|
|
15563
15595
|
}
|
|
15564
|
-
function
|
|
15596
|
+
function Z_(e, t, n = {}) {
|
|
15565
15597
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
15566
15598
|
if (r === "regex") try {
|
|
15567
15599
|
s = new RegExp(t, "i");
|
|
@@ -15571,11 +15603,11 @@ function Y_(e, t, n = {}) {
|
|
|
15571
15603
|
let c = (e, l, u) => {
|
|
15572
15604
|
if (o.length >= i || e == null) return;
|
|
15573
15605
|
if (typeof e == "object") {
|
|
15574
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
15575
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
15606
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, J_(l, t), String(t)));
|
|
15607
|
+
else for (let t of Object.keys(e)) c(e[t], J_(l, t), t);
|
|
15576
15608
|
return;
|
|
15577
15609
|
}
|
|
15578
|
-
let d = String(e), f =
|
|
15610
|
+
let d = String(e), f = Q_(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15579
15611
|
if (f) {
|
|
15580
15612
|
o.push({
|
|
15581
15613
|
path: l,
|
|
@@ -15586,7 +15618,7 @@ function Y_(e, t, n = {}) {
|
|
|
15586
15618
|
return;
|
|
15587
15619
|
}
|
|
15588
15620
|
if (a && u) {
|
|
15589
|
-
let e =
|
|
15621
|
+
let e = Q_(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
15590
15622
|
e && o.push({
|
|
15591
15623
|
path: l,
|
|
15592
15624
|
key: u,
|
|
@@ -15597,18 +15629,18 @@ function Y_(e, t, n = {}) {
|
|
|
15597
15629
|
};
|
|
15598
15630
|
return c(e, ""), o;
|
|
15599
15631
|
}
|
|
15600
|
-
function
|
|
15632
|
+
function Q_(e, t, n, r, i) {
|
|
15601
15633
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
15602
15634
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
15603
15635
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
15604
15636
|
if (n === "fuzzy") {
|
|
15605
15637
|
if (a.includes(o)) return 2;
|
|
15606
|
-
let e =
|
|
15638
|
+
let e = X_(a, o);
|
|
15607
15639
|
return e <= r ? r - e + 1 : null;
|
|
15608
15640
|
}
|
|
15609
15641
|
return null;
|
|
15610
15642
|
}
|
|
15611
|
-
var
|
|
15643
|
+
var $_ = [
|
|
15612
15644
|
"self.fetch = () => { throw new Error('fetch 已被沙箱禁用') }",
|
|
15613
15645
|
"self.XMLHttpRequest = function(){ throw new Error('XMLHttpRequest 已被沙箱禁用') }",
|
|
15614
15646
|
"self.importScripts = () => { throw new Error('importScripts 已被沙箱禁用') }",
|
|
@@ -15621,7 +15653,7 @@ var Z_ = [
|
|
|
15621
15653
|
"try { self.BroadcastChannel = undefined } catch {}",
|
|
15622
15654
|
"if (self.navigator && self.navigator.sendBeacon) self.navigator.sendBeacon = () => { throw new Error('sendBeacon 已被沙箱禁用') }"
|
|
15623
15655
|
].join("\n");
|
|
15624
|
-
function
|
|
15656
|
+
function ev(e, t, n = 3e3) {
|
|
15625
15657
|
return new Promise((r) => {
|
|
15626
15658
|
let i = Date.now(), a = !1, o = (e) => {
|
|
15627
15659
|
if (!a) {
|
|
@@ -15634,7 +15666,7 @@ function Q_(e, t, n = 3e3) {
|
|
|
15634
15666
|
elapsedMs: Date.now() - i
|
|
15635
15667
|
});
|
|
15636
15668
|
}
|
|
15637
|
-
}, s =
|
|
15669
|
+
}, s = $_ + "\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;
|
|
15638
15670
|
try {
|
|
15639
15671
|
let e = new Blob([s], { type: "application/javascript" });
|
|
15640
15672
|
c = URL.createObjectURL(e), l = new Worker(c);
|
|
@@ -15669,19 +15701,19 @@ function Q_(e, t, n = 3e3) {
|
|
|
15669
15701
|
}
|
|
15670
15702
|
//#endregion
|
|
15671
15703
|
//#region src/core/tools/windowOps.ts
|
|
15672
|
-
var
|
|
15704
|
+
var tv = /* @__PURE__ */ new Set([
|
|
15673
15705
|
"__proto__",
|
|
15674
15706
|
"constructor",
|
|
15675
15707
|
"prototype"
|
|
15676
15708
|
]);
|
|
15677
|
-
function
|
|
15678
|
-
return e.split(".").some((e) =>
|
|
15709
|
+
function nv(e) {
|
|
15710
|
+
return e.split(".").some((e) => tv.has(e));
|
|
15679
15711
|
}
|
|
15680
|
-
function
|
|
15681
|
-
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t))
|
|
15712
|
+
function rv(e, t) {
|
|
15713
|
+
if (!(!t || typeof t != "object" || Array.isArray(t))) for (let n of Object.keys(t)) tv.has(n) || (e[n] = t[n]);
|
|
15682
15714
|
}
|
|
15683
|
-
function
|
|
15684
|
-
if (
|
|
15715
|
+
function iv(e, t) {
|
|
15716
|
+
if (nv(t)) return;
|
|
15685
15717
|
let n = t.split("."), r = e;
|
|
15686
15718
|
for (let e of n) {
|
|
15687
15719
|
if (r == null) return;
|
|
@@ -15689,8 +15721,8 @@ function nv(e, t) {
|
|
|
15689
15721
|
}
|
|
15690
15722
|
return r;
|
|
15691
15723
|
}
|
|
15692
|
-
function
|
|
15693
|
-
if (
|
|
15724
|
+
function av(e, t, n) {
|
|
15725
|
+
if (nv(t)) return;
|
|
15694
15726
|
let r = t.split("."), i = e;
|
|
15695
15727
|
for (let e = 0; e < r.length - 1; e++) {
|
|
15696
15728
|
let t = r[e];
|
|
@@ -15698,8 +15730,8 @@ function rv(e, t, n) {
|
|
|
15698
15730
|
}
|
|
15699
15731
|
i[r[r.length - 1]] = n;
|
|
15700
15732
|
}
|
|
15701
|
-
function
|
|
15702
|
-
if (
|
|
15733
|
+
function ov(e, t) {
|
|
15734
|
+
if (nv(t)) return !1;
|
|
15703
15735
|
let n = t.split("."), r = e;
|
|
15704
15736
|
for (let e = 0; e < n.length - 1; e++) {
|
|
15705
15737
|
if (r == null) return !1;
|
|
@@ -15708,10 +15740,10 @@ function iv(e, t) {
|
|
|
15708
15740
|
let i = n[n.length - 1];
|
|
15709
15741
|
return r == null || !(i in r) ? !1 : (delete r[i], !0);
|
|
15710
15742
|
}
|
|
15711
|
-
function
|
|
15743
|
+
function sv(e) {
|
|
15712
15744
|
return e === void 0 ? void 0 : JSON.parse(JSON.stringify(e));
|
|
15713
15745
|
}
|
|
15714
|
-
function
|
|
15746
|
+
function cv(e, t = Infinity) {
|
|
15715
15747
|
let n = /* @__PURE__ */ new WeakSet(), r;
|
|
15716
15748
|
try {
|
|
15717
15749
|
r = JSON.stringify(e, (e, t) => {
|
|
@@ -15730,30 +15762,30 @@ function ov(e, t = Infinity) {
|
|
|
15730
15762
|
}
|
|
15731
15763
|
return r.length > t && (r = r.slice(0, t) + `\n…[已截断,原长度 ${r.length}]`), r;
|
|
15732
15764
|
}
|
|
15733
|
-
function
|
|
15734
|
-
if (t === "set") return n ? (
|
|
15735
|
-
if (t === "remove") return n ? (
|
|
15765
|
+
function lv(e, t, n, r) {
|
|
15766
|
+
if (t === "set") return n ? (av(e, n, r), null) : "set 操作需要 jsonPath(整体替换请用 set_window_prop)";
|
|
15767
|
+
if (t === "remove") return n ? (ov(e, n), null) : "remove 操作需要 jsonPath";
|
|
15736
15768
|
if (t === "merge") {
|
|
15737
|
-
let t = n ?
|
|
15738
|
-
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (
|
|
15769
|
+
let t = n ? iv(e, n) : e;
|
|
15770
|
+
return typeof t != "object" || !t || Array.isArray(t) ? `merge 目标${n ? `(${n})` : "(根)"}不是对象` : (rv(t, r), null);
|
|
15739
15771
|
}
|
|
15740
|
-
let i = n ?
|
|
15772
|
+
let i = n ? iv(e, n) : e;
|
|
15741
15773
|
return Array.isArray(i) ? (Array.isArray(r) ? i.push(...r) : i.push(r), null) : `append 目标${n ? `(${n})` : "(根)"}不是数组`;
|
|
15742
15774
|
}
|
|
15743
|
-
function
|
|
15744
|
-
if (t === "set")
|
|
15745
|
-
else if (t === "remove")
|
|
15746
|
-
else if (t === "merge")
|
|
15775
|
+
function uv(e, t, n, r) {
|
|
15776
|
+
if (t === "set") av(window, `${e}.${n}`, r);
|
|
15777
|
+
else if (t === "remove") ov(window, `${e}.${n}`);
|
|
15778
|
+
else if (t === "merge") rv(n ? iv(window, `${e}.${n}`) : iv(window, e), r);
|
|
15747
15779
|
else {
|
|
15748
|
-
let t = n ?
|
|
15780
|
+
let t = n ? iv(window, `${e}.${n}`) : iv(window, e);
|
|
15749
15781
|
Array.isArray(r) ? t.push(...r) : t.push(r);
|
|
15750
15782
|
}
|
|
15751
15783
|
}
|
|
15752
|
-
function
|
|
15753
|
-
let n =
|
|
15754
|
-
typeof n == "object" && n ?
|
|
15784
|
+
function dv(e, t) {
|
|
15785
|
+
let n = iv(window, e);
|
|
15786
|
+
typeof n == "object" && n ? fv(n, t) : av(window, e, t);
|
|
15755
15787
|
}
|
|
15756
|
-
function
|
|
15788
|
+
function fv(e, t) {
|
|
15757
15789
|
if (Array.isArray(e)) {
|
|
15758
15790
|
e.length = 0, Array.isArray(t) && e.push(...t);
|
|
15759
15791
|
return;
|
|
@@ -15762,17 +15794,34 @@ function uv(e, t) {
|
|
|
15762
15794
|
for (let t of Object.keys(e)) t in n || delete e[t];
|
|
15763
15795
|
for (let t of Object.keys(n)) e[t] = n[t];
|
|
15764
15796
|
}
|
|
15765
|
-
function
|
|
15797
|
+
function pv(e, r = {}) {
|
|
15766
15798
|
let i = /* @__PURE__ */ new Map();
|
|
15767
15799
|
for (let t of e) i.set(t.path, t);
|
|
15768
|
-
let a = /* @__PURE__ */ new Map(), o = r.maxSnapshots ?? 20, s =
|
|
15800
|
+
let a = /* @__PURE__ */ new Map(), o = r.maxSnapshots ?? 20, s = {
|
|
15801
|
+
add: (e) => {
|
|
15802
|
+
i.set(e.path, e);
|
|
15803
|
+
},
|
|
15804
|
+
remove: (e) => {
|
|
15805
|
+
let t = i.delete(e);
|
|
15806
|
+
return t && a.delete(e), t;
|
|
15807
|
+
},
|
|
15808
|
+
list: () => [...i.values()],
|
|
15809
|
+
has: (e) => i.has(e)
|
|
15810
|
+
}, c = (e) => {
|
|
15769
15811
|
r.onAudit?.(e);
|
|
15770
|
-
}
|
|
15771
|
-
function l(
|
|
15772
|
-
|
|
15812
|
+
};
|
|
15813
|
+
function l() {
|
|
15814
|
+
let e = [...i.keys()];
|
|
15815
|
+
if (!e.length) return "";
|
|
15816
|
+
let t = e.join(", ");
|
|
15817
|
+
return e.length > 8 || t.length > 240 ? `\n(当前可操作属性共 ${e.length} 项,用 list_window_props 查看)` : `\n(当前可操作 path: ${t})`;
|
|
15818
|
+
}
|
|
15819
|
+
let u = (r.whitelist ?? !0) === !1;
|
|
15820
|
+
function d(e) {
|
|
15821
|
+
return r.allowRawRead ? !0 : [...i.keys()].some((t) => e === t || e.startsWith(t + ".") || u && t.startsWith(e + "."));
|
|
15773
15822
|
}
|
|
15774
|
-
function
|
|
15775
|
-
let r =
|
|
15823
|
+
function f(e, t, n) {
|
|
15824
|
+
let r = sv(iv(window, e)), i = a.get(e) || [], s = i.length ? i[i.length - 1].id + 1 : 1;
|
|
15776
15825
|
for (i.push({
|
|
15777
15826
|
id: s,
|
|
15778
15827
|
ts: Date.now(),
|
|
@@ -15782,7 +15831,7 @@ function dv(e, r = {}) {
|
|
|
15782
15831
|
}); i.length > o;) i.shift();
|
|
15783
15832
|
return a.set(e, i), s;
|
|
15784
15833
|
}
|
|
15785
|
-
let
|
|
15834
|
+
let p = n(async () => {
|
|
15786
15835
|
if (!i.size) return "当前没有已注册的可操作 window 属性。";
|
|
15787
15836
|
let e = [...i.values()].map((e) => `- ${e.path}: ${e.description}`);
|
|
15788
15837
|
return `可操作的 window 属性(共 ${i.size} 项):\n${e.join("\n")}`;
|
|
@@ -15790,7 +15839,7 @@ function dv(e, r = {}) {
|
|
|
15790
15839
|
name: "list_window_props",
|
|
15791
15840
|
description: "列出所有已注册、可操作的 window 属性(path + 说明)。操作 window 前先调用此工具了解可用范围。",
|
|
15792
15841
|
schema: t.object({})
|
|
15793
|
-
}),
|
|
15842
|
+
}), m = n(async ({ path: e }) => {
|
|
15794
15843
|
let t = i.get(e);
|
|
15795
15844
|
return t ? [
|
|
15796
15845
|
`路径: ${t.path}`,
|
|
@@ -15806,20 +15855,20 @@ function dv(e, r = {}) {
|
|
|
15806
15855
|
name: "describe_window_prop",
|
|
15807
15856
|
description: "获取单个已注册 window 属性的说明与格式要求。",
|
|
15808
15857
|
schema: t.object({ path: t.string().describe("属性路径,如 app.theme") })
|
|
15809
|
-
}),
|
|
15810
|
-
if (!
|
|
15858
|
+
}), h = n(async ({ path: e }) => {
|
|
15859
|
+
if (!d(e)) return $({
|
|
15811
15860
|
code: "NOT_REGISTERED",
|
|
15812
15861
|
path: e,
|
|
15813
15862
|
message: `属性 "${e}" 不可读取(未注册,且非已注册路径的后代)`,
|
|
15814
15863
|
hint: "用 list_window_props 查看可操作字段;字段白名单读模式下未注册的祖先(整体大 JSON)不暴露,需读其声明子路径"
|
|
15815
15864
|
});
|
|
15816
|
-
let t =
|
|
15817
|
-
return t === void 0 ? `${e} = (undefined)` : `${e} = ${
|
|
15865
|
+
let t = iv(window, e);
|
|
15866
|
+
return t === void 0 ? `${e} = (undefined)` : `${e} = ${cv(t)}`;
|
|
15818
15867
|
}, {
|
|
15819
15868
|
name: "get_window_prop",
|
|
15820
15869
|
description: "读取一个已注册 window 属性的当前值(安全序列化:函数/DOM/循环引用做摘要;大结果由系统自动外存,提示用 vfs_read 回读)。字段白名单读模式(默认)下仅可读注册 path 自身/后代;未注册祖先(整体大 JSON)不可读,避免大 JSON 拉进上下文。",
|
|
15821
15870
|
schema: t.object({ path: t.string().describe("已注册的属性路径或其后代") })
|
|
15822
|
-
}),
|
|
15871
|
+
}), g = n(async ({ path: e, value: t }) => {
|
|
15823
15872
|
let n = i.get(e);
|
|
15824
15873
|
if (!n) return $({
|
|
15825
15874
|
code: "NOT_REGISTERED",
|
|
@@ -15831,18 +15880,18 @@ function dv(e, r = {}) {
|
|
|
15831
15880
|
try {
|
|
15832
15881
|
r = JSON.parse(t);
|
|
15833
15882
|
} catch (n) {
|
|
15834
|
-
return
|
|
15883
|
+
return A_(e, t, n);
|
|
15835
15884
|
}
|
|
15836
15885
|
let a = n.schema.safeParse(r);
|
|
15837
|
-
if (!a.success) return
|
|
15838
|
-
|
|
15839
|
-
let o =
|
|
15840
|
-
return typeof o == "object" && o && a.data !== null && typeof a.data == "object" ?
|
|
15886
|
+
if (!a.success) return k_(e, a.error.issues);
|
|
15887
|
+
f(e, "set");
|
|
15888
|
+
let o = iv(window, e);
|
|
15889
|
+
return typeof o == "object" && o && a.data !== null && typeof a.data == "object" ? fv(o, a.data) : av(window, e, a.data), c({
|
|
15841
15890
|
op: "set",
|
|
15842
15891
|
path: e,
|
|
15843
15892
|
value: a.data,
|
|
15844
15893
|
timestamp: Date.now()
|
|
15845
|
-
}), `已设置 ${e} = ${
|
|
15894
|
+
}), `已设置 ${e} = ${cv(a.data, 600)}${l()}`;
|
|
15846
15895
|
}, {
|
|
15847
15896
|
name: "set_window_prop",
|
|
15848
15897
|
description: "设置一个已注册 window 属性的值(整体替换)。仅能操作注册表内声明的属性;value 为 JSON 字符串,需通过该属性声明的 schema 校验。校验失败会返回错误而非写入。大对象/数组强烈建议改用 edit_window_prop 增量 patch —— 整体重传大 JSON 时输出可能被 max_tokens 截断,导致 JSON 不完整而校验失败,且浪费 token。",
|
|
@@ -15850,7 +15899,7 @@ function dv(e, r = {}) {
|
|
|
15850
15899
|
path: t.string().describe("已注册的属性路径"),
|
|
15851
15900
|
value: t.string().describe("JSON 字符串形式的值,需符合该属性 schema")
|
|
15852
15901
|
})
|
|
15853
|
-
}),
|
|
15902
|
+
}), _ = n(async ({ path: e, op: t, jsonPath: n, value: r }) => {
|
|
15854
15903
|
let a = i.get(e);
|
|
15855
15904
|
if (!a) return $({
|
|
15856
15905
|
code: "NOT_REGISTERED",
|
|
@@ -15859,13 +15908,13 @@ function dv(e, r = {}) {
|
|
|
15859
15908
|
hint: "用 list_window_props 查看可用属性"
|
|
15860
15909
|
});
|
|
15861
15910
|
let o = n || "";
|
|
15862
|
-
if (
|
|
15911
|
+
if (nv(o)) return $({
|
|
15863
15912
|
code: "PATH_UNSAFE",
|
|
15864
15913
|
path: e,
|
|
15865
15914
|
message: `jsonPath "${o}" 含非法段(__proto__/constructor/prototype)`,
|
|
15866
15915
|
hint: "使用正常的属性路径,如 components.0.text(数组索引用数字)"
|
|
15867
15916
|
});
|
|
15868
|
-
let
|
|
15917
|
+
let s;
|
|
15869
15918
|
if (t !== "remove") {
|
|
15870
15919
|
if (r === void 0 || r === "") return $({
|
|
15871
15920
|
code: "MISSING_VALUE",
|
|
@@ -15874,33 +15923,33 @@ function dv(e, r = {}) {
|
|
|
15874
15923
|
hint: `op 为 ${t} 时 value 必填;若想删除请用 op:'remove'`
|
|
15875
15924
|
});
|
|
15876
15925
|
try {
|
|
15877
|
-
|
|
15926
|
+
s = JSON.parse(r);
|
|
15878
15927
|
} catch (t) {
|
|
15879
|
-
return
|
|
15928
|
+
return A_(e, r, t);
|
|
15880
15929
|
}
|
|
15881
15930
|
}
|
|
15882
|
-
let
|
|
15883
|
-
if (typeof
|
|
15931
|
+
let u = iv(window, e);
|
|
15932
|
+
if (typeof u != "object" || !u) return $({
|
|
15884
15933
|
code: "NOT_OBJECT",
|
|
15885
15934
|
path: e,
|
|
15886
|
-
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${
|
|
15935
|
+
message: `edit 仅适用于对象/数组属性,"${e}" 当前是 ${u === void 0 ? "undefined" : typeof u}`,
|
|
15887
15936
|
hint: "叶子属性(原始类型)请用 set_window_prop 整体设置"
|
|
15888
15937
|
});
|
|
15889
|
-
let d =
|
|
15890
|
-
if (
|
|
15938
|
+
let d = sv(u), p = lv(d, t, o, s);
|
|
15939
|
+
if (p) return $({
|
|
15891
15940
|
code: "PATCH_FAILED",
|
|
15892
15941
|
path: e,
|
|
15893
|
-
message:
|
|
15942
|
+
message: p,
|
|
15894
15943
|
hint: "检查 op 与目标类型:merge 需目标为对象,append 需目标为数组;jsonPath 指向需存在"
|
|
15895
15944
|
});
|
|
15896
|
-
let
|
|
15897
|
-
return
|
|
15945
|
+
let m = a.schema.safeParse(d);
|
|
15946
|
+
return m.success ? (f(e, "edit"), uv(e, t, o, s), c({
|
|
15898
15947
|
op: "edit",
|
|
15899
15948
|
path: e,
|
|
15900
15949
|
detail: `${t}${o ? "@" + o : ""}`,
|
|
15901
|
-
value:
|
|
15950
|
+
value: s,
|
|
15902
15951
|
timestamp: Date.now()
|
|
15903
|
-
}), `已 edit ${e}(${t}${o ? " @ " + o : ""})。当前值:${
|
|
15952
|
+
}), `已 edit ${e}(${t}${o ? " @ " + o : ""})。当前值:${cv(iv(window, e), 600)}${l()}`) : k_(e, m.error.issues);
|
|
15904
15953
|
}, {
|
|
15905
15954
|
name: "edit_window_prop",
|
|
15906
15955
|
description: "增量编辑一个已注册的「对象/数组」window 属性,只发改动的 patch,无需重传整个大对象。op:set(在 jsonPath 设值)、remove(删 jsonPath)、merge(把 value 合并到 jsonPath 指向的对象,默认根)、append(把 value 追加到 jsonPath 指向的数组,默认根)。jsonPath 为相对属性根的点号路径(数组索引用数字,如 components.0.text);value 为 JSON 字符串。整体仍经 schema 校验,失败不写入。",
|
|
@@ -15915,25 +15964,25 @@ function dv(e, r = {}) {
|
|
|
15915
15964
|
jsonPath: t.string().optional().describe("相对属性根的点号路径(数组索引用数字,如 components.0.text)。set/remove 必填;merge/append 不填则作用于根"),
|
|
15916
15965
|
value: t.string().optional().describe("JSON 字符串(set/merge/append 必填)")
|
|
15917
15966
|
})
|
|
15918
|
-
}),
|
|
15967
|
+
}), v = n(async ({ path: e }) => {
|
|
15919
15968
|
if (!i.has(e)) return $({
|
|
15920
15969
|
code: "NOT_REGISTERED",
|
|
15921
15970
|
path: e,
|
|
15922
15971
|
message: `属性 "${e}" 未在注册表中声明,不可删除`,
|
|
15923
15972
|
hint: "用 list_window_props 查看可用属性"
|
|
15924
15973
|
});
|
|
15925
|
-
|
|
15926
|
-
let t =
|
|
15927
|
-
return
|
|
15974
|
+
f(e, "delete");
|
|
15975
|
+
let t = ov(window, e);
|
|
15976
|
+
return c({
|
|
15928
15977
|
op: "delete",
|
|
15929
15978
|
path: e,
|
|
15930
15979
|
timestamp: Date.now()
|
|
15931
|
-
}), t ? `已删除 ${e}` : `${e} 不存在(无需删除)`;
|
|
15980
|
+
}), t ? `已删除 ${e}${l()}` : `${e} 不存在(无需删除)${l()}`;
|
|
15932
15981
|
}, {
|
|
15933
15982
|
name: "delete_window_prop",
|
|
15934
15983
|
description: "删除一个已注册 window 属性。",
|
|
15935
15984
|
schema: t.object({ path: t.string().describe("已注册的属性路径") })
|
|
15936
|
-
}),
|
|
15985
|
+
}), y = n(async ({ path: e, label: t }) => i.has(e) ? `已为 ${e} 创建快照 #${f(e, "manual", t)}${t ? `(${t})` : ""}。可用 list_window_snapshots 查看、restore_window_snapshot 回退。` : $({
|
|
15937
15986
|
code: "NOT_REGISTERED",
|
|
15938
15987
|
path: e,
|
|
15939
15988
|
message: `属性 "${e}" 未注册,无法打快照`,
|
|
@@ -15945,7 +15994,7 @@ function dv(e, r = {}) {
|
|
|
15945
15994
|
path: t.string().describe("已注册的属性路径"),
|
|
15946
15995
|
label: t.string().optional().describe("可选的快照标签,便于识别")
|
|
15947
15996
|
})
|
|
15948
|
-
}),
|
|
15997
|
+
}), b = n(async ({ path: e }) => {
|
|
15949
15998
|
let t = e ? [e] : [...i.keys()];
|
|
15950
15999
|
if (e && !i.has(e)) return $({
|
|
15951
16000
|
code: "NOT_REGISTERED",
|
|
@@ -15971,7 +16020,7 @@ function dv(e, r = {}) {
|
|
|
15971
16020
|
name: "list_window_snapshots",
|
|
15972
16021
|
description: "列出 window 属性的快照时间线(序号、操作类型、标签、大小)。不传 path 列出所有属性。",
|
|
15973
16022
|
schema: t.object({ path: t.string().optional().describe("限定单个属性,不传则列出全部") })
|
|
15974
|
-
}),
|
|
16023
|
+
}), x = n(async ({ path: e, id: t }) => {
|
|
15975
16024
|
let n = i.get(e);
|
|
15976
16025
|
if (!n) return $({
|
|
15977
16026
|
code: "NOT_REGISTERED",
|
|
@@ -15993,8 +16042,8 @@ function dv(e, r = {}) {
|
|
|
15993
16042
|
message: `未找到快照 #${t}`,
|
|
15994
16043
|
hint: "用 list_window_snapshots 查看可用快照序号"
|
|
15995
16044
|
});
|
|
15996
|
-
let
|
|
15997
|
-
return
|
|
16045
|
+
let s = n.schema.safeParse(o.value);
|
|
16046
|
+
return s.success ? (dv(e, sv(o.value)), c({
|
|
15998
16047
|
op: "restore",
|
|
15999
16048
|
path: e,
|
|
16000
16049
|
detail: `#${o.id}`,
|
|
@@ -16004,7 +16053,7 @@ function dv(e, r = {}) {
|
|
|
16004
16053
|
path: e,
|
|
16005
16054
|
message: `快照 #${o.id} 的值不符合当前 schema,无法回退`,
|
|
16006
16055
|
hint: "schema 可能已变更;该快照已过期,选其他快照或重新设置",
|
|
16007
|
-
details:
|
|
16056
|
+
details: O_(s.error.issues)
|
|
16008
16057
|
});
|
|
16009
16058
|
}, {
|
|
16010
16059
|
name: "restore_window_snapshot",
|
|
@@ -16013,15 +16062,14 @@ function dv(e, r = {}) {
|
|
|
16013
16062
|
path: t.string().describe("已注册的属性路径"),
|
|
16014
16063
|
id: t.number().int().optional().describe("指定快照序号;不传则回退最近一次")
|
|
16015
16064
|
})
|
|
16016
|
-
})
|
|
16017
|
-
return [
|
|
16018
|
-
d,
|
|
16019
|
-
f,
|
|
16065
|
+
}), S = [
|
|
16020
16066
|
p,
|
|
16067
|
+
m,
|
|
16068
|
+
h,
|
|
16021
16069
|
n(async ({ paths: e }) => {
|
|
16022
16070
|
let t = [];
|
|
16023
16071
|
for (let n of e) {
|
|
16024
|
-
if (!
|
|
16072
|
+
if (!d(n)) {
|
|
16025
16073
|
t.push(`- ${n} = ERROR: ${$({
|
|
16026
16074
|
code: "NOT_REGISTERED",
|
|
16027
16075
|
path: n,
|
|
@@ -16030,8 +16078,8 @@ function dv(e, r = {}) {
|
|
|
16030
16078
|
})}`);
|
|
16031
16079
|
continue;
|
|
16032
16080
|
}
|
|
16033
|
-
let e =
|
|
16034
|
-
t.push(`- ${n} = ${e === void 0 ? "(undefined)" :
|
|
16081
|
+
let e = iv(window, n);
|
|
16082
|
+
t.push(`- ${n} = ${e === void 0 ? "(undefined)" : cv(e)}`);
|
|
16035
16083
|
}
|
|
16036
16084
|
return t.join("\n");
|
|
16037
16085
|
}, {
|
|
@@ -16039,12 +16087,12 @@ function dv(e, r = {}) {
|
|
|
16039
16087
|
description: "批量按路径读取 window 属性的局部或多个字段(避免对大 JSON 整体读取)。paths 支持注册属性的任意后代路径(如 page.components.0.text)、自身。字段白名单读模式(默认)下未注册祖先不可读。逐行返回 path = value;单个值过大仍由系统自动外存 vfs。",
|
|
16040
16088
|
schema: t.object({ paths: t.array(t.string().describe("路径,如 page.components.0.text")).min(1).max(20) })
|
|
16041
16089
|
}),
|
|
16042
|
-
m,
|
|
16043
|
-
h,
|
|
16044
16090
|
g,
|
|
16045
16091
|
_,
|
|
16046
16092
|
v,
|
|
16047
16093
|
y,
|
|
16094
|
+
b,
|
|
16095
|
+
x,
|
|
16048
16096
|
n(async ({ path: e, expr: t, limit: n }) => {
|
|
16049
16097
|
if (!i.get(e)) return $({
|
|
16050
16098
|
code: "NOT_REGISTERED",
|
|
@@ -16052,7 +16100,7 @@ function dv(e, r = {}) {
|
|
|
16052
16100
|
message: `属性 "${e}" 未注册`,
|
|
16053
16101
|
hint: "用 list_window_props 查看可用属性"
|
|
16054
16102
|
});
|
|
16055
|
-
let r =
|
|
16103
|
+
let r = iv(window, e);
|
|
16056
16104
|
if (typeof r != "object" || !r) return $({
|
|
16057
16105
|
code: "NOT_OBJECT",
|
|
16058
16106
|
path: e,
|
|
@@ -16061,7 +16109,7 @@ function dv(e, r = {}) {
|
|
|
16061
16109
|
});
|
|
16062
16110
|
let a;
|
|
16063
16111
|
try {
|
|
16064
|
-
a =
|
|
16112
|
+
a = Y_(r, t);
|
|
16065
16113
|
} catch (n) {
|
|
16066
16114
|
return $({
|
|
16067
16115
|
code: "JSONPATH_SYNTAX",
|
|
@@ -16071,7 +16119,7 @@ function dv(e, r = {}) {
|
|
|
16071
16119
|
details: { expr: t }
|
|
16072
16120
|
});
|
|
16073
16121
|
}
|
|
16074
|
-
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${
|
|
16122
|
+
let o = n ?? 50, s = a.slice(0, o), c = s.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${cv(e.value)}}`);
|
|
16075
16123
|
return `{"matched":${a.length},"returned":${s.length},"truncated":${a.length > o},"results":[${c.join(",")}]}`;
|
|
16076
16124
|
}, {
|
|
16077
16125
|
name: "query_window_prop",
|
|
@@ -16089,20 +16137,20 @@ function dv(e, r = {}) {
|
|
|
16089
16137
|
message: `属性 "${e}" 未注册`,
|
|
16090
16138
|
hint: "用 list_window_props 查看可用属性"
|
|
16091
16139
|
});
|
|
16092
|
-
let s =
|
|
16140
|
+
let s = iv(window, e);
|
|
16093
16141
|
if (s == null) return $({
|
|
16094
16142
|
code: "EMPTY",
|
|
16095
16143
|
path: e,
|
|
16096
16144
|
message: `"${e}" 为空,无可搜索内容`
|
|
16097
16145
|
});
|
|
16098
16146
|
try {
|
|
16099
|
-
let e =
|
|
16147
|
+
let e = Z_(s, t, {
|
|
16100
16148
|
mode: n,
|
|
16101
16149
|
fuzzyThreshold: r,
|
|
16102
16150
|
matchKey: a,
|
|
16103
16151
|
limit: o ?? 50
|
|
16104
16152
|
});
|
|
16105
|
-
return
|
|
16153
|
+
return cv({
|
|
16106
16154
|
matched: e.length,
|
|
16107
16155
|
results: e
|
|
16108
16156
|
});
|
|
@@ -16145,7 +16193,7 @@ function dv(e, r = {}) {
|
|
|
16145
16193
|
message: `脚本过长(${t.length} 字符,上限 8000)`,
|
|
16146
16194
|
hint: "精简脚本;复杂逻辑可分步(先 query 探查再 transform 改),或拆成多次 eval"
|
|
16147
16195
|
});
|
|
16148
|
-
let a = await
|
|
16196
|
+
let a = await ev(sv(iv(window, e)), t, 3e3);
|
|
16149
16197
|
if (!a.ok) {
|
|
16150
16198
|
let n = /超时/.test(a.error || "");
|
|
16151
16199
|
return $({
|
|
@@ -16166,18 +16214,18 @@ function dv(e, r = {}) {
|
|
|
16166
16214
|
path: e,
|
|
16167
16215
|
message: "脚本返回值校验失败,未写入(transform 模式要求返回该属性的完整新值且符合 schema)",
|
|
16168
16216
|
hint: `确认脚本 return 了完整新值(非部分);按 describe_window_prop("${e}") 查看格式`,
|
|
16169
|
-
details:
|
|
16217
|
+
details: O_(t.error.issues)
|
|
16170
16218
|
});
|
|
16171
|
-
|
|
16172
|
-
let n =
|
|
16173
|
-
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ?
|
|
16219
|
+
f(e, "edit", "eval_transform");
|
|
16220
|
+
let n = iv(window, e);
|
|
16221
|
+
return typeof n == "object" && n && t.data !== null && typeof t.data == "object" ? fv(n, t.data) : av(window, e, t.data), c({
|
|
16174
16222
|
op: "edit",
|
|
16175
16223
|
path: e,
|
|
16176
16224
|
detail: "eval_transform",
|
|
16177
16225
|
timestamp: Date.now()
|
|
16178
|
-
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${
|
|
16226
|
+
}), `已通过脚本 transform 更新 ${e}(耗时 ${a.elapsedMs}ms)。当前值: ${cv(iv(window, e), 600)}`;
|
|
16179
16227
|
}
|
|
16180
|
-
return
|
|
16228
|
+
return cv({
|
|
16181
16229
|
ok: !0,
|
|
16182
16230
|
result: a.result,
|
|
16183
16231
|
elapsedMs: a.elapsedMs
|
|
@@ -16192,11 +16240,17 @@ function dv(e, r = {}) {
|
|
|
16192
16240
|
})
|
|
16193
16241
|
})
|
|
16194
16242
|
];
|
|
16243
|
+
return Object.defineProperty(S, "controller", {
|
|
16244
|
+
value: s,
|
|
16245
|
+
enumerable: !1,
|
|
16246
|
+
configurable: !1,
|
|
16247
|
+
writable: !1
|
|
16248
|
+
}), S;
|
|
16195
16249
|
}
|
|
16196
16250
|
//#endregion
|
|
16197
16251
|
//#region src/core/tools/fetchDoc.ts
|
|
16198
|
-
var
|
|
16199
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
16252
|
+
var mv = 3e4, hv = [n(async ({ url: e, as: t }) => {
|
|
16253
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), mv);
|
|
16200
16254
|
try {
|
|
16201
16255
|
let r = await fetch(e, {
|
|
16202
16256
|
method: "GET",
|
|
@@ -16213,7 +16267,7 @@ var fv = 3e4, pv = [n(async ({ url: e, as: t }) => {
|
|
|
16213
16267
|
].join("\n");
|
|
16214
16268
|
} catch (t) {
|
|
16215
16269
|
let r = t?.message || String(t);
|
|
16216
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
16270
|
+
return n.signal.aborted ? `获取失败:请求超时(${mv}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
16217
16271
|
} finally {
|
|
16218
16272
|
clearTimeout(r);
|
|
16219
16273
|
}
|
|
@@ -16224,24 +16278,24 @@ var fv = 3e4, pv = [n(async ({ url: e, as: t }) => {
|
|
|
16224
16278
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
16225
16279
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
16226
16280
|
})
|
|
16227
|
-
})],
|
|
16228
|
-
function
|
|
16229
|
-
return
|
|
16281
|
+
})], gv = hv;
|
|
16282
|
+
function _v(e, t) {
|
|
16283
|
+
return pv(e, t);
|
|
16230
16284
|
}
|
|
16231
|
-
function
|
|
16285
|
+
function vv(e, t, n) {
|
|
16232
16286
|
let r = e?.windowOps !== !1, i = e?.fetch !== !1;
|
|
16233
16287
|
return [...r ? t : [], ...i ? n : []];
|
|
16234
16288
|
}
|
|
16235
16289
|
//#endregion
|
|
16236
16290
|
//#region src/core/harness/usageHints.ts
|
|
16237
|
-
var
|
|
16238
|
-
function
|
|
16291
|
+
var yv = .7;
|
|
16292
|
+
function bv(e, t) {
|
|
16239
16293
|
return {
|
|
16240
16294
|
name: "usageHints",
|
|
16241
16295
|
augmentPrompt: () => {
|
|
16242
16296
|
let n = [];
|
|
16243
|
-
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("修改大对象/数组属性优先用 edit_window_prop 增量 patch(只发改动部分),避免 set 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改属性出错时可用 restore_window_snapshot(path) 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_window_prop(JSONPath,如 $[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_window_prop 改。"), n.push("找名字记不清的元素用 search_window_prop(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_window_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。")), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
16244
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
16297
|
+
if (e?.planning !== !1 && n.push("多步任务建议先 write_todos 拆解为步骤并逐步推进。"), t && (n.push("不确定可操作哪些属性时用 list_window_props 查看(动态组件场景下注册表会增删,以工具返回为准,勿凭旧记忆);不确定某属性字段结构时用 describe_window_prop。"), n.push("改属性前先 get_window_prop 读其当前真实值,基于真实值改,不要凭记忆。"), n.push("修改大对象/数组属性优先用 edit_window_prop 增量 patch(只发改动部分),避免 set 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), n.push("修改属性出错时可用 restore_window_snapshot(path) 回退最近一次。"), n.push("在大数组里按条件筛选元素用 query_window_prop(JSONPath,如 $[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_window_prop 改。"), n.push("找名字记不清的元素用 search_window_prop(支持 substring/regex/fuzzy 模糊搜索)。"), n.push("需要过滤/映射/聚合/批量重写大数组时用 eval_window_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。")), e?.subagent !== !1 && n.push("独立子任务可 spawn_agent 委派(只读工具,过程不占主上下文)。"), e?.subagents?.length) {
|
|
16298
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= yv || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), r = e.subagents.filter((e) => (e.temperature ?? 0) < yv && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
16245
16299
|
n.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (n.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), n.push(" 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。")), r.length && n.push(` · 严谨/易错/校验类 → 可先调 ${r.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), n.push(" · 方案定稿后,由你(主 agent)用 edit_window_prop 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), n.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
16246
16300
|
}
|
|
16247
16301
|
return e?.humanConfirm && (n.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), n.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), n.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), n.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), n.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。")), n.length ? "## 能力使用提示\n" + n.join("\n") : void 0;
|
|
@@ -16250,7 +16304,7 @@ function vv(e, t) {
|
|
|
16250
16304
|
}
|
|
16251
16305
|
//#endregion
|
|
16252
16306
|
//#region src/core/utils/id.ts
|
|
16253
|
-
function
|
|
16307
|
+
function xv() {
|
|
16254
16308
|
try {
|
|
16255
16309
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
16256
16310
|
} catch {}
|
|
@@ -16258,57 +16312,57 @@ function yv() {
|
|
|
16258
16312
|
}
|
|
16259
16313
|
//#endregion
|
|
16260
16314
|
//#region src/core/backends/storage.ts
|
|
16261
|
-
var
|
|
16315
|
+
var Sv = "chat-sdk", Cv = 50 * 1024 * 1024, wv = 4 * 1024 * 1024, Tv = 10 * 1024 * 1024, Ev = .9, Dv = 500, Ov = 300, kv = "__meta__", Av = "v:1", jv = [
|
|
16262
16316
|
"messages",
|
|
16263
16317
|
"vfs",
|
|
16264
16318
|
"todos",
|
|
16265
16319
|
"memory"
|
|
16266
16320
|
];
|
|
16267
|
-
function
|
|
16268
|
-
return e === "local" || e === "session" ?
|
|
16321
|
+
function Mv(e) {
|
|
16322
|
+
return e === "local" || e === "session" ? wv : Cv;
|
|
16269
16323
|
}
|
|
16270
|
-
function
|
|
16324
|
+
function Nv(e) {
|
|
16271
16325
|
if (typeof e != "object" || !e) return !1;
|
|
16272
16326
|
let t = e;
|
|
16273
16327
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
16274
16328
|
}
|
|
16275
|
-
function
|
|
16329
|
+
function Pv(e, t, n, r) {
|
|
16276
16330
|
return [
|
|
16277
|
-
|
|
16331
|
+
Av,
|
|
16278
16332
|
e,
|
|
16279
16333
|
t,
|
|
16280
16334
|
n,
|
|
16281
16335
|
r
|
|
16282
16336
|
].join("::");
|
|
16283
16337
|
}
|
|
16284
|
-
function
|
|
16338
|
+
function Fv(e, t, n) {
|
|
16285
16339
|
return [
|
|
16286
|
-
|
|
16340
|
+
Av,
|
|
16287
16341
|
e,
|
|
16288
16342
|
t,
|
|
16289
16343
|
n
|
|
16290
16344
|
].join("::") + "::";
|
|
16291
16345
|
}
|
|
16292
|
-
function
|
|
16346
|
+
function Iv(e, t) {
|
|
16293
16347
|
return [
|
|
16294
|
-
|
|
16348
|
+
Av,
|
|
16295
16349
|
e,
|
|
16296
16350
|
t
|
|
16297
16351
|
].join("::") + "::";
|
|
16298
16352
|
}
|
|
16299
|
-
function Fv(e) {
|
|
16300
|
-
return [Ov, e].join("::") + "::";
|
|
16301
|
-
}
|
|
16302
|
-
var Iv = null;
|
|
16303
16353
|
function Lv(e) {
|
|
16304
|
-
|
|
16354
|
+
return [Av, e].join("::") + "::";
|
|
16355
|
+
}
|
|
16356
|
+
var Rv = null;
|
|
16357
|
+
function zv(e) {
|
|
16358
|
+
Rv ||= new TextEncoder();
|
|
16305
16359
|
try {
|
|
16306
|
-
return
|
|
16360
|
+
return Rv.encode(JSON.stringify(e)).length;
|
|
16307
16361
|
} catch {
|
|
16308
16362
|
return 0;
|
|
16309
16363
|
}
|
|
16310
16364
|
}
|
|
16311
|
-
function
|
|
16365
|
+
function Bv(e, t, n) {
|
|
16312
16366
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
16313
16367
|
if (r <= t) return [];
|
|
16314
16368
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -16318,7 +16372,7 @@ function Rv(e, t, n) {
|
|
|
16318
16372
|
}
|
|
16319
16373
|
return o;
|
|
16320
16374
|
}
|
|
16321
|
-
function
|
|
16375
|
+
function Vv() {
|
|
16322
16376
|
let e = /* @__PURE__ */ new Map();
|
|
16323
16377
|
return {
|
|
16324
16378
|
async get(t) {
|
|
@@ -16338,7 +16392,7 @@ function zv() {
|
|
|
16338
16392
|
}
|
|
16339
16393
|
};
|
|
16340
16394
|
}
|
|
16341
|
-
function
|
|
16395
|
+
function Hv(e) {
|
|
16342
16396
|
return new Promise((t, n) => {
|
|
16343
16397
|
if (typeof indexedDB > "u") {
|
|
16344
16398
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -16399,7 +16453,7 @@ function Bv(e) {
|
|
|
16399
16453
|
}, r.onerror = () => n(r.error);
|
|
16400
16454
|
});
|
|
16401
16455
|
}
|
|
16402
|
-
function
|
|
16456
|
+
function Uv(e) {
|
|
16403
16457
|
return {
|
|
16404
16458
|
async get(t) {
|
|
16405
16459
|
let n = e.getItem(t);
|
|
@@ -16433,12 +16487,12 @@ function Vv(e) {
|
|
|
16433
16487
|
}
|
|
16434
16488
|
};
|
|
16435
16489
|
}
|
|
16436
|
-
function
|
|
16490
|
+
function Wv(e, t, n) {
|
|
16437
16491
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
16438
16492
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
16439
16493
|
}
|
|
16440
|
-
function
|
|
16441
|
-
let t = e.dbName ??
|
|
16494
|
+
function Gv(e = {}) {
|
|
16495
|
+
let t = e.dbName ?? Sv, n = e.backend ?? "indexed", r = e.maxBytes ?? Mv(n), i = e.maxBytesPerSession ?? Tv, a = e.evictionWatermark ?? Ev, o = e.debounceMs ?? Dv, s = /* @__PURE__ */ new Set();
|
|
16442
16496
|
function c(e) {
|
|
16443
16497
|
for (let t of s) try {
|
|
16444
16498
|
t(e);
|
|
@@ -16451,16 +16505,16 @@ function Uv(e = {}) {
|
|
|
16451
16505
|
try {
|
|
16452
16506
|
if (n === "indexed") {
|
|
16453
16507
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
16454
|
-
l = await
|
|
16508
|
+
l = await Hv(t), d(!0);
|
|
16455
16509
|
} else if (n === "session") {
|
|
16456
16510
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
16457
|
-
l =
|
|
16511
|
+
l = Uv(sessionStorage), d(!0);
|
|
16458
16512
|
} else if (n === "local") {
|
|
16459
16513
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
16460
|
-
l =
|
|
16461
|
-
} else l =
|
|
16514
|
+
l = Uv(localStorage), d(!0);
|
|
16515
|
+
} else l = Vv(), d(!1);
|
|
16462
16516
|
} catch (e) {
|
|
16463
|
-
l =
|
|
16517
|
+
l = Vv();
|
|
16464
16518
|
let t = e instanceof Error ? e.message : String(e);
|
|
16465
16519
|
d(!1), Promise.resolve().then(() => c({
|
|
16466
16520
|
type: "degraded",
|
|
@@ -16470,10 +16524,10 @@ function Uv(e = {}) {
|
|
|
16470
16524
|
})();
|
|
16471
16525
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
16472
16526
|
function g(e, n, r, a) {
|
|
16473
|
-
let o =
|
|
16474
|
-
return
|
|
16527
|
+
let o = Pv(t, r, a, kv);
|
|
16528
|
+
return Wv(h, o, async () => {
|
|
16475
16529
|
let t = async () => {
|
|
16476
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
16530
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : zv(s), d = zv(n), f = (t?.bytes ?? 0) + (d - u);
|
|
16477
16531
|
if (f > i) {
|
|
16478
16532
|
c({
|
|
16479
16533
|
type: "quota",
|
|
@@ -16495,12 +16549,12 @@ function Uv(e = {}) {
|
|
|
16495
16549
|
try {
|
|
16496
16550
|
await t();
|
|
16497
16551
|
} catch (e) {
|
|
16498
|
-
if (
|
|
16552
|
+
if (Nv(e) && !u) {
|
|
16499
16553
|
u = !0;
|
|
16500
16554
|
try {
|
|
16501
16555
|
await b();
|
|
16502
16556
|
} catch {}
|
|
16503
|
-
l =
|
|
16557
|
+
l = Vv(), Promise.resolve().then(() => c({
|
|
16504
16558
|
type: "degraded",
|
|
16505
16559
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
16506
16560
|
}));
|
|
@@ -16512,7 +16566,7 @@ function Uv(e = {}) {
|
|
|
16512
16566
|
});
|
|
16513
16567
|
}
|
|
16514
16568
|
function _(e, n, r, i) {
|
|
16515
|
-
let a =
|
|
16569
|
+
let a = Pv(t, e, n, r), s = p.get(a);
|
|
16516
16570
|
s && s.resolve();
|
|
16517
16571
|
let c = m.get(a);
|
|
16518
16572
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -16539,15 +16593,15 @@ function Uv(e = {}) {
|
|
|
16539
16593
|
function y() {
|
|
16540
16594
|
v ||= setTimeout(() => {
|
|
16541
16595
|
v = null, b();
|
|
16542
|
-
},
|
|
16596
|
+
}, Ov);
|
|
16543
16597
|
}
|
|
16544
16598
|
async function b() {
|
|
16545
16599
|
let e = [];
|
|
16546
|
-
await l.scan(
|
|
16600
|
+
await l.scan(Lv(t), (t, n) => {
|
|
16547
16601
|
t.endsWith("::__meta__") && e.push(n);
|
|
16548
16602
|
});
|
|
16549
|
-
let n =
|
|
16550
|
-
for (let e of n) await l.clearPrefix(
|
|
16603
|
+
let n = Bv(e, r, a);
|
|
16604
|
+
for (let e of n) await l.clearPrefix(Fv(t, e.agentId, e.sessionId)), c({
|
|
16551
16605
|
type: "evicted",
|
|
16552
16606
|
agentId: e.agentId,
|
|
16553
16607
|
sessionId: e.sessionId,
|
|
@@ -16558,13 +16612,13 @@ function Uv(e = {}) {
|
|
|
16558
16612
|
ready: f,
|
|
16559
16613
|
async listSessions(e) {
|
|
16560
16614
|
let n = [];
|
|
16561
|
-
return await l.scan(
|
|
16615
|
+
return await l.scan(Iv(t, e), (e, t) => {
|
|
16562
16616
|
e.endsWith("::__meta__") && n.push(t);
|
|
16563
16617
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
16564
16618
|
},
|
|
16565
16619
|
async load(e, n) {
|
|
16566
|
-
let r =
|
|
16567
|
-
return await
|
|
16620
|
+
let r = Pv(t, e, n, kv);
|
|
16621
|
+
return await Wv(h, r, async () => {
|
|
16568
16622
|
let i = await l.get(r);
|
|
16569
16623
|
if (!i) return;
|
|
16570
16624
|
let a = {
|
|
@@ -16573,8 +16627,8 @@ function Uv(e = {}) {
|
|
|
16573
16627
|
todos: [],
|
|
16574
16628
|
memory: ""
|
|
16575
16629
|
};
|
|
16576
|
-
for (let r of
|
|
16577
|
-
let i = await l.get(
|
|
16630
|
+
for (let r of jv) {
|
|
16631
|
+
let i = await l.get(Pv(t, e, n, r));
|
|
16578
16632
|
i != null && (a[r] = i);
|
|
16579
16633
|
}
|
|
16580
16634
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -16582,7 +16636,7 @@ function Uv(e = {}) {
|
|
|
16582
16636
|
},
|
|
16583
16637
|
async save(e, t, n) {
|
|
16584
16638
|
let r = [];
|
|
16585
|
-
for (let i of
|
|
16639
|
+
for (let i of jv) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
16586
16640
|
await Promise.all(r);
|
|
16587
16641
|
},
|
|
16588
16642
|
async flush() {
|
|
@@ -16596,10 +16650,10 @@ function Uv(e = {}) {
|
|
|
16596
16650
|
})), c({ type: "flush" }), await b();
|
|
16597
16651
|
},
|
|
16598
16652
|
async deleteSession(e, n) {
|
|
16599
|
-
await l.clearPrefix(
|
|
16653
|
+
await l.clearPrefix(Fv(t, e, n));
|
|
16600
16654
|
},
|
|
16601
16655
|
async createSession(e, n, r) {
|
|
16602
|
-
let i = r ??
|
|
16656
|
+
let i = r ?? xv(), a = Date.now(), o = {
|
|
16603
16657
|
agentId: e,
|
|
16604
16658
|
sessionId: i,
|
|
16605
16659
|
createdAt: a,
|
|
@@ -16607,7 +16661,7 @@ function Uv(e = {}) {
|
|
|
16607
16661
|
bytes: 0,
|
|
16608
16662
|
title: n
|
|
16609
16663
|
};
|
|
16610
|
-
return await l.set(
|
|
16664
|
+
return await l.set(Pv(t, e, i, kv), o), i;
|
|
16611
16665
|
},
|
|
16612
16666
|
onEvent(e) {
|
|
16613
16667
|
s.add(e);
|
|
@@ -16622,23 +16676,28 @@ function Uv(e = {}) {
|
|
|
16622
16676
|
}
|
|
16623
16677
|
//#endregion
|
|
16624
16678
|
//#region src/core/sdk/createChatSdk.ts
|
|
16625
|
-
var
|
|
16626
|
-
|
|
16627
|
-
|
|
16679
|
+
var Kv = [
|
|
16680
|
+
"你是一个页面操作助手。宿主页面在 window 对象上注册了可操作的属性,你通过专用工具安全地读写这些属性来操作页面。",
|
|
16681
|
+
"所有写操作都经范围控制(仅注册表内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
16682
|
+
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
16683
|
+
T_.reliableWriteRules
|
|
16684
|
+
].join("\n\n"), qv = 50;
|
|
16685
|
+
function Jv(e) {
|
|
16686
|
+
return e === void 0 || e === !1 ? null : typeof e == "string" ? Gv({ backend: e }) : e.enabled === !1 ? null : Gv(e);
|
|
16628
16687
|
}
|
|
16629
|
-
function
|
|
16688
|
+
function Yv(e) {
|
|
16630
16689
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
16631
16690
|
}
|
|
16632
|
-
var
|
|
16633
|
-
function
|
|
16691
|
+
var Xv = /* @__PURE__ */ new Map();
|
|
16692
|
+
function Zv(e) {
|
|
16634
16693
|
let t = e.content;
|
|
16635
16694
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
16636
16695
|
}
|
|
16637
|
-
function
|
|
16696
|
+
function Qv(e) {
|
|
16638
16697
|
let t = e.summaryLlm ?? e.llm;
|
|
16639
16698
|
if (!t) return;
|
|
16640
16699
|
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, o = e.summaryTimeoutMs ?? 15e3, c;
|
|
16641
|
-
if (
|
|
16700
|
+
if (Yv(t)) c = t;
|
|
16642
16701
|
else {
|
|
16643
16702
|
let i = t;
|
|
16644
16703
|
if (!i.apiKey) {
|
|
@@ -16656,16 +16715,16 @@ function Yv(e) {
|
|
|
16656
16715
|
return async (e) => {
|
|
16657
16716
|
let t = new AbortController(), n = setTimeout(() => t.abort(), o);
|
|
16658
16717
|
try {
|
|
16659
|
-
return
|
|
16718
|
+
return Zv(await c.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
16660
16719
|
} finally {
|
|
16661
16720
|
clearTimeout(n);
|
|
16662
16721
|
}
|
|
16663
16722
|
};
|
|
16664
16723
|
}
|
|
16665
|
-
function
|
|
16724
|
+
function $v(e) {
|
|
16666
16725
|
return e === "set_window_prop" ? "set" : e === "edit_window_prop" ? "edit" : e === "delete_window_prop" ? "delete" : e === "restore_window_snapshot" ? "restore" : null;
|
|
16667
16726
|
}
|
|
16668
|
-
function
|
|
16727
|
+
function ey(e) {
|
|
16669
16728
|
let t = e.split("."), n = globalThis.window;
|
|
16670
16729
|
for (let e of t) {
|
|
16671
16730
|
if (n == null) return;
|
|
@@ -16673,18 +16732,18 @@ function Zv(e) {
|
|
|
16673
16732
|
}
|
|
16674
16733
|
return n;
|
|
16675
16734
|
}
|
|
16676
|
-
function
|
|
16735
|
+
function ty(e, t) {
|
|
16677
16736
|
return {
|
|
16678
16737
|
name: "sdk-events",
|
|
16679
16738
|
wrapToolCall: async (t, n) => {
|
|
16680
|
-
let r = await n(t), i =
|
|
16739
|
+
let r = await n(t), i = $v(t.name);
|
|
16681
16740
|
if (i) {
|
|
16682
16741
|
let n = String(t.args?.path ?? "");
|
|
16683
16742
|
e({
|
|
16684
16743
|
type: "window_prop_change",
|
|
16685
16744
|
path: n,
|
|
16686
16745
|
operation: i,
|
|
16687
|
-
value: n ?
|
|
16746
|
+
value: n ? ey(n) : void 0
|
|
16688
16747
|
});
|
|
16689
16748
|
}
|
|
16690
16749
|
return r;
|
|
@@ -16697,18 +16756,18 @@ function Qv(e, t) {
|
|
|
16697
16756
|
}
|
|
16698
16757
|
};
|
|
16699
16758
|
}
|
|
16700
|
-
function
|
|
16701
|
-
let i =
|
|
16759
|
+
function ny(e, r) {
|
|
16760
|
+
let i = Jv(e.storage);
|
|
16702
16761
|
e.debug && i && i.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
16703
|
-
let a =
|
|
16762
|
+
let a = Yv(e.llm) ? void 0 : e.llm, o = Wh({
|
|
16704
16763
|
model: a?.model,
|
|
16705
16764
|
contextWindow: e.contextWindow ?? a?.contextWindow,
|
|
16706
16765
|
maxOutputTokens: e.maxOutputTokens ?? a?.maxOutputTokens
|
|
16707
16766
|
});
|
|
16708
16767
|
e.debug && console.log("[page-agent-sdk][modelCaps]", o);
|
|
16709
|
-
let s =
|
|
16768
|
+
let s = Qv(e);
|
|
16710
16769
|
e.debug && !s && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
16711
|
-
let c = /* @__PURE__ */ Qt([]), l =
|
|
16770
|
+
let c = /* @__PURE__ */ Qt([]), l = M_(e.vfs?.initialFiles, {
|
|
16712
16771
|
persist: i ? { save: (e) => {
|
|
16713
16772
|
B.sessionId && i && i.save(r, B.sessionId, { vfs: e });
|
|
16714
16773
|
} } : void 0,
|
|
@@ -16720,16 +16779,16 @@ function $v(e, r) {
|
|
|
16720
16779
|
getTodos: () => f.current?.getState?.()?.todos ?? [],
|
|
16721
16780
|
messages: c,
|
|
16722
16781
|
maxCheckpoints: p && typeof p == "object" ? p.maxCheckpoints : void 0
|
|
16723
|
-
}) : null, g = !p || typeof p != "object" || p.auto !== !1, _ = e.capabilities, v = _?.windowOps !== !1, y = v ?
|
|
16782
|
+
}) : null, g = !p || typeof p != "object" || p.auto !== !1, _ = e.capabilities, v = _?.windowOps !== !1, y = v ? pv(e.windowProps || [], {
|
|
16724
16783
|
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][window audit]", e) : void 0,
|
|
16725
16784
|
maxSnapshots: e.maxSnapshots
|
|
16726
|
-
}) : [], b = /* @__PURE__ */ new Map(),
|
|
16727
|
-
|
|
16728
|
-
let
|
|
16729
|
-
|
|
16730
|
-
let
|
|
16731
|
-
|
|
16732
|
-
let
|
|
16785
|
+
}) : [], b = v ? y.controller ?? null : null, x = () => b?.list() ?? e.windowProps ?? [], S = /* @__PURE__ */ new Map(), C = vv(_, y, hv);
|
|
16786
|
+
C.forEach((e) => S.set(e.name, "builtin"));
|
|
16787
|
+
let w = [...e.tools || []];
|
|
16788
|
+
w.forEach((e) => S.set(e.name, "user"));
|
|
16789
|
+
let T = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), E = T ? Eg() : null;
|
|
16790
|
+
E && S.set(wg, "builtin");
|
|
16791
|
+
let D = m && h ? [n(async () => {
|
|
16733
16792
|
let e = h.list();
|
|
16734
16793
|
return e.length ? h.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、window 注册属性、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
16735
16794
|
}, {
|
|
@@ -16744,83 +16803,88 @@ function $v(e, r) {
|
|
|
16744
16803
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
16745
16804
|
schema: t.object({}).optional()
|
|
16746
16805
|
})] : [];
|
|
16747
|
-
|
|
16748
|
-
let
|
|
16749
|
-
...
|
|
16750
|
-
...
|
|
16751
|
-
...
|
|
16752
|
-
...
|
|
16753
|
-
],
|
|
16806
|
+
D.forEach((e) => S.set(e.name, "builtin"));
|
|
16807
|
+
let O = [
|
|
16808
|
+
...C,
|
|
16809
|
+
...w,
|
|
16810
|
+
...E ? [E] : [],
|
|
16811
|
+
...D
|
|
16812
|
+
], k = _?.planning !== !1, A = _?.skills !== !1, j = _?.vfs !== !1, M = _?.summarization !== !1, N = _?.memory !== !1, P = _?.subagent !== !1, F = e.verify?.maxAttempts ?? 2, I = _?.verify === !0 && e.verify?.enabled !== !1 && F > 0;
|
|
16754
16813
|
e.verify?.check && _?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
16755
|
-
let
|
|
16756
|
-
llm:
|
|
16757
|
-
allTools:
|
|
16758
|
-
allowedTools:
|
|
16759
|
-
systemPrompt:
|
|
16760
|
-
temperature:
|
|
16761
|
-
maxTokens:
|
|
16762
|
-
skills:
|
|
16763
|
-
maxDepth:
|
|
16764
|
-
maxParallel:
|
|
16814
|
+
let L = e.subagent, R = L?.allowedTools ?? [], ee = !P || L?.enabled === !1 ? void 0 : Ug({
|
|
16815
|
+
llm: L?.llm ?? e.llm,
|
|
16816
|
+
allTools: O,
|
|
16817
|
+
allowedTools: R.length ? R : void 0,
|
|
16818
|
+
systemPrompt: L?.systemPrompt,
|
|
16819
|
+
temperature: L?.temperature,
|
|
16820
|
+
maxTokens: L?.maxTokens,
|
|
16821
|
+
skills: L?.skills,
|
|
16822
|
+
maxDepth: L?.maxDepth,
|
|
16823
|
+
maxParallel: L?.maxParallel,
|
|
16765
16824
|
debug: e.debug
|
|
16766
|
-
}),
|
|
16825
|
+
}), te = e.subagents?.length ? Kg(e.subagents, {
|
|
16767
16826
|
llm: e.llm,
|
|
16768
|
-
allTools:
|
|
16827
|
+
allTools: O,
|
|
16769
16828
|
debug: e.debug
|
|
16770
|
-
}) : void 0,
|
|
16829
|
+
}) : void 0, ne = [
|
|
16771
16830
|
"get_window_prop",
|
|
16772
16831
|
"get_window_paths",
|
|
16773
16832
|
"list_window_props",
|
|
16774
16833
|
"describe_window_prop",
|
|
16775
16834
|
"fetch_document"
|
|
16776
|
-
],
|
|
16777
|
-
check: e.verify.check ?? $g({ schemas: Object.fromEntries((
|
|
16835
|
+
], re = O.filter((e) => ne.includes(e.name)), ie = I ? qg({
|
|
16836
|
+
check: e.verify.check ?? $g({ schemas: () => Object.fromEntries(x().map((e) => [e.path, e.schema])) }),
|
|
16778
16837
|
adversarial: e.verify?.adversarial ? {
|
|
16779
16838
|
llm: e.llm,
|
|
16780
|
-
tools:
|
|
16839
|
+
tools: re
|
|
16781
16840
|
} : void 0
|
|
16782
|
-
}) : void 0,
|
|
16841
|
+
}) : void 0, ae = bv({
|
|
16783
16842
|
..._,
|
|
16784
|
-
humanConfirm:
|
|
16843
|
+
humanConfirm: T,
|
|
16785
16844
|
subagents: e.subagents?.map((e) => ({
|
|
16786
16845
|
id: e.id,
|
|
16787
16846
|
description: e.description,
|
|
16788
16847
|
temperature: e.temperature
|
|
16789
16848
|
}))
|
|
16790
|
-
}, v && !!e.windowProps?.length),
|
|
16849
|
+
}, v && !!e.windowProps?.length), oe = e.onEvent, se = /* @__PURE__ */ new Set(), ce = (e) => {
|
|
16791
16850
|
if (e.type !== "approval_request") {
|
|
16792
|
-
if (
|
|
16793
|
-
|
|
16851
|
+
if (oe) try {
|
|
16852
|
+
oe(e);
|
|
16794
16853
|
} catch {}
|
|
16795
|
-
for (let t of
|
|
16854
|
+
for (let t of se) try {
|
|
16796
16855
|
t(e);
|
|
16797
16856
|
} catch {}
|
|
16798
16857
|
}
|
|
16799
16858
|
}, z = [
|
|
16800
|
-
|
|
16801
|
-
...
|
|
16802
|
-
...
|
|
16803
|
-
...
|
|
16804
|
-
...
|
|
16805
|
-
...
|
|
16806
|
-
llmInvoke: s
|
|
16859
|
+
ae,
|
|
16860
|
+
...k ? [u] : [],
|
|
16861
|
+
...A ? [gg(e.skills || [], { readVfs: j ? (e) => l.files[e]?.content : void 0 })] : [],
|
|
16862
|
+
...j ? [z_(l)] : [],
|
|
16863
|
+
...M ? [C_({
|
|
16864
|
+
...D_(e, o.contextWindow),
|
|
16865
|
+
llmInvoke: s,
|
|
16866
|
+
getRegisteredProps: () => x().map((e) => ({
|
|
16867
|
+
path: e.path,
|
|
16868
|
+
description: e.description
|
|
16869
|
+
})),
|
|
16870
|
+
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_window_prop", "list_window_props"]
|
|
16807
16871
|
})] : [],
|
|
16808
|
-
...
|
|
16872
|
+
...N ? [d] : [],
|
|
16809
16873
|
...e.permissions?.length ? [Sg(e.permissions)] : [],
|
|
16810
16874
|
...m && g && h ? [Fg(h)] : [],
|
|
16811
|
-
...
|
|
16875
|
+
...T ? [Dg()] : [],
|
|
16812
16876
|
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [Cg(e.approval)] : [],
|
|
16813
|
-
...
|
|
16814
|
-
...
|
|
16815
|
-
...
|
|
16877
|
+
...ie ? [ie] : [],
|
|
16878
|
+
...ee ? [ee] : [],
|
|
16879
|
+
...te ? [te] : [],
|
|
16816
16880
|
...e.middleware || [],
|
|
16817
|
-
|
|
16818
|
-
],
|
|
16881
|
+
ty(ce, c)
|
|
16882
|
+
], le = e.maxMemoryRounds ?? qv, B = {
|
|
16819
16883
|
agentId: r,
|
|
16820
16884
|
store: i,
|
|
16821
16885
|
messages: c,
|
|
16822
16886
|
vfsStore: l,
|
|
16823
|
-
listeners:
|
|
16887
|
+
listeners: se,
|
|
16824
16888
|
todosMw: u,
|
|
16825
16889
|
memoryMw: d,
|
|
16826
16890
|
agent: null,
|
|
@@ -16834,7 +16898,7 @@ function $v(e, r) {
|
|
|
16834
16898
|
t.messages?.length && c.push(...t.messages), t.vfs && l.hydrate && l.hydrate(t.vfs), t.todos?.length && u.reset(t.todos), t.memory && !e.memory && d.reset(t.memory);
|
|
16835
16899
|
},
|
|
16836
16900
|
afterRound() {
|
|
16837
|
-
|
|
16901
|
+
de(), fe();
|
|
16838
16902
|
},
|
|
16839
16903
|
async send(e) {
|
|
16840
16904
|
await B.initDone, c.push({
|
|
@@ -16850,7 +16914,7 @@ function $v(e, r) {
|
|
|
16850
16914
|
timestamp: Date.now()
|
|
16851
16915
|
}), B.afterRound(), i && await i.flush(), e;
|
|
16852
16916
|
} catch (e) {
|
|
16853
|
-
throw
|
|
16917
|
+
throw ce({
|
|
16854
16918
|
type: "error",
|
|
16855
16919
|
message: e?.message || String(e)
|
|
16856
16920
|
}), e;
|
|
@@ -16864,8 +16928,8 @@ function $v(e, r) {
|
|
|
16864
16928
|
},
|
|
16865
16929
|
stream: (e, t, n) => {
|
|
16866
16930
|
if (!B.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
16867
|
-
let r =
|
|
16868
|
-
t?.(e),
|
|
16931
|
+
let r = oe ? (e) => {
|
|
16932
|
+
t?.(e), ce(e);
|
|
16869
16933
|
} : t;
|
|
16870
16934
|
return B.agent.stream(e, r, n);
|
|
16871
16935
|
},
|
|
@@ -16873,24 +16937,24 @@ function $v(e, r) {
|
|
|
16873
16937
|
if (B.refCount--, B.refCount <= 0) {
|
|
16874
16938
|
i && (l.flush?.(), i.flush(), i.dispose());
|
|
16875
16939
|
let e = B.mcpClosers.splice(0);
|
|
16876
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
16940
|
+
e.length && Promise.allSettled(e.map((e) => e())), Xv.delete(r);
|
|
16877
16941
|
}
|
|
16878
16942
|
},
|
|
16879
16943
|
getInfo() {
|
|
16880
16944
|
return {
|
|
16881
16945
|
id: r,
|
|
16882
|
-
model:
|
|
16883
|
-
tools:
|
|
16946
|
+
model: Yv(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
16947
|
+
tools: O.map((e) => ({
|
|
16884
16948
|
name: e.name,
|
|
16885
16949
|
description: e.description,
|
|
16886
16950
|
schema: e.schema,
|
|
16887
|
-
source:
|
|
16951
|
+
source: S.get(e.name) || "user"
|
|
16888
16952
|
})),
|
|
16889
16953
|
skills: (e.skills ?? []).map((e) => ({
|
|
16890
16954
|
name: e.name,
|
|
16891
16955
|
description: e.description
|
|
16892
16956
|
})),
|
|
16893
|
-
windowProps: (
|
|
16957
|
+
windowProps: x().map((e) => ({
|
|
16894
16958
|
path: e.path,
|
|
16895
16959
|
description: e.description,
|
|
16896
16960
|
schema: e.schema
|
|
@@ -16902,15 +16966,15 @@ function $v(e, r) {
|
|
|
16902
16966
|
status: e.status
|
|
16903
16967
|
})),
|
|
16904
16968
|
subagent: {
|
|
16905
|
-
enabled: !!
|
|
16969
|
+
enabled: !!ee,
|
|
16906
16970
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
16907
16971
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
16908
16972
|
allowedTools: e.subagent?.allowedTools ?? []
|
|
16909
16973
|
},
|
|
16910
16974
|
verify: {
|
|
16911
|
-
enabled: !!
|
|
16912
|
-
maxAttempts:
|
|
16913
|
-
adversarial:
|
|
16975
|
+
enabled: !!ie,
|
|
16976
|
+
maxAttempts: I ? F : 0,
|
|
16977
|
+
adversarial: I && !!e.verify?.adversarial
|
|
16914
16978
|
},
|
|
16915
16979
|
mcp: { servers: B.mcpServers },
|
|
16916
16980
|
lastCompression: B.agent?.getState?.()?.lastCompression,
|
|
@@ -16922,7 +16986,7 @@ function $v(e, r) {
|
|
|
16922
16986
|
};
|
|
16923
16987
|
}
|
|
16924
16988
|
};
|
|
16925
|
-
async function
|
|
16989
|
+
async function ue() {
|
|
16926
16990
|
if (!i) return;
|
|
16927
16991
|
await i.ready;
|
|
16928
16992
|
let t = e.session || {};
|
|
@@ -16940,11 +17004,11 @@ function $v(e, r) {
|
|
|
16940
17004
|
} else B.sessionId = await i.createSession(r, t.title);
|
|
16941
17005
|
e.memory && i.save(r, B.sessionId, { memory: e.memory });
|
|
16942
17006
|
}
|
|
16943
|
-
function
|
|
16944
|
-
let e = p_(c,
|
|
17007
|
+
function de() {
|
|
17008
|
+
let e = p_(c, le);
|
|
16945
17009
|
e.trimmed && c.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
16946
17010
|
}
|
|
16947
|
-
function
|
|
17011
|
+
function fe() {
|
|
16948
17012
|
if (!B.sessionId || !i) return;
|
|
16949
17013
|
let t = JSON.parse(JSON.stringify(c));
|
|
16950
17014
|
i.save(r, B.sessionId, { messages: t });
|
|
@@ -16952,7 +17016,7 @@ function $v(e, r) {
|
|
|
16952
17016
|
i.save(r, B.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", B.sessionId, `${c.length} msgs`);
|
|
16953
17017
|
}
|
|
16954
17018
|
return B.initDone = (async () => {
|
|
16955
|
-
if (await
|
|
17019
|
+
if (await ue(), e.mcp?.length) {
|
|
16956
17020
|
let t = await Promise.allSettled(e.mcp.map((e) => l_(e)));
|
|
16957
17021
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
16958
17022
|
let n = [];
|
|
@@ -16962,35 +17026,35 @@ function $v(e, r) {
|
|
|
16962
17026
|
name: a,
|
|
16963
17027
|
url: i.url,
|
|
16964
17028
|
toolCount: t.value.tools.length
|
|
16965
|
-
}), t.value.tools.forEach((e) =>
|
|
16966
|
-
}),
|
|
17029
|
+
}), t.value.tools.forEach((e) => S.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17030
|
+
}), O.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
16967
17031
|
}
|
|
16968
17032
|
B.agent = sg({
|
|
16969
|
-
...
|
|
17033
|
+
...Yv(e.llm) ? { llm: e.llm } : {
|
|
16970
17034
|
apiKey: e.llm.apiKey,
|
|
16971
17035
|
baseUrl: e.llm.baseUrl,
|
|
16972
17036
|
model: e.llm.model,
|
|
16973
17037
|
temperature: e.llm.temperature,
|
|
16974
17038
|
maxTokens: e.llm.maxTokens
|
|
16975
17039
|
},
|
|
16976
|
-
systemPrompt: e.systemPrompt,
|
|
16977
|
-
tools:
|
|
17040
|
+
systemPrompt: e.systemPrompt ?? Kv,
|
|
17041
|
+
tools: O,
|
|
16978
17042
|
middleware: z,
|
|
16979
17043
|
maxToolRounds: e.maxToolRounds,
|
|
16980
17044
|
maxRetries: e.maxRetries,
|
|
16981
17045
|
maxParallelTools: e.maxParallelTools,
|
|
16982
17046
|
contextWindow: o.contextWindow,
|
|
16983
17047
|
maxOutputTokens: o.maxOutputTokens,
|
|
16984
|
-
maxVerifyAttempts:
|
|
17048
|
+
maxVerifyAttempts: I ? F : 0,
|
|
16985
17049
|
debug: e.debug
|
|
16986
17050
|
}), f.current = B.agent;
|
|
16987
17051
|
})(), B;
|
|
16988
17052
|
}
|
|
16989
|
-
function
|
|
16990
|
-
let t = e.id ??
|
|
17053
|
+
function ry(e) {
|
|
17054
|
+
let t = e.id ?? xv();
|
|
16991
17055
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${t}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
16992
|
-
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ?
|
|
16993
|
-
a ? i = a : (i =
|
|
17056
|
+
let n = e.streaming ?? !0, r = e.ui ?? "default", i, a = e.shareContext ? Xv.get(t) : void 0;
|
|
17057
|
+
a ? i = a : (i = ny(e, t), e.shareContext && Xv.set(t, i)), i.refCount++;
|
|
16994
17058
|
let o = null, s = null, c = null;
|
|
16995
17059
|
async function l() {
|
|
16996
17060
|
if (await i.initDone, r === !1) {
|
|
@@ -17019,7 +17083,7 @@ function ey(e) {
|
|
|
17019
17083
|
i.afterRound(), i.store && await i.store.flush();
|
|
17020
17084
|
},
|
|
17021
17085
|
onClear: () => {
|
|
17022
|
-
i.store && (i.sessionId =
|
|
17086
|
+
i.store && (i.sessionId = xv(), 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));
|
|
17023
17087
|
}
|
|
17024
17088
|
});
|
|
17025
17089
|
} })), o.mount(t), i.store && (s = () => {
|
|
@@ -17041,12 +17105,21 @@ function ey(e) {
|
|
|
17041
17105
|
messages: i.messages,
|
|
17042
17106
|
restoreLastCheckpoint: () => i.checkpoint?.restore() ?? !1,
|
|
17043
17107
|
listCheckpoints: () => i.checkpoint?.list() ?? [],
|
|
17044
|
-
hook: (e) => (i.listeners.add(e), () => i.listeners.delete(e))
|
|
17108
|
+
hook: (e) => (i.listeners.add(e), () => i.listeners.delete(e)),
|
|
17109
|
+
addWindowProp: (e) => {
|
|
17110
|
+
if (!windowOpsController) {
|
|
17111
|
+
console.warn("[page-agent-sdk] addWindowProp 忽略:windowOps 已关闭(capabilities.windowOps:false)");
|
|
17112
|
+
return;
|
|
17113
|
+
}
|
|
17114
|
+
windowOpsController.add(e);
|
|
17115
|
+
},
|
|
17116
|
+
removeWindowProp: (e) => windowOpsController ? windowOpsController.remove(e) : !1,
|
|
17117
|
+
listWindowProps: () => liveWindowProps()
|
|
17045
17118
|
};
|
|
17046
17119
|
}
|
|
17047
17120
|
//#endregion
|
|
17048
17121
|
//#region src/core/sdk/defineTool.ts
|
|
17049
|
-
function
|
|
17122
|
+
function iy(e) {
|
|
17050
17123
|
return n(async (t) => {
|
|
17051
17124
|
let n = await e.handler(t);
|
|
17052
17125
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -17057,21 +17130,4 @@ function ty(e) {
|
|
|
17057
17130
|
});
|
|
17058
17131
|
}
|
|
17059
17132
|
//#endregion
|
|
17060
|
-
|
|
17061
|
-
var ny = {
|
|
17062
|
-
pageBuilder: { systemPrompt: "你是页面构建助手。流程:get_window_prop 读取当前页面结构 → set_window_prop / edit_window_prop 修改属性 → 页面实时更新。多步任务先用 write_todos 拆解,逐步推进。" },
|
|
17063
|
-
researcher: {
|
|
17064
|
-
systemPrompt: "你是调研助手。多路调研用 spawn_agents 并行委派子 agent(各负责一个方向);单份资料用 fetch_document 抓取;最后结构化汇总,给出结论与依据。",
|
|
17065
|
-
subagent: { maxParallel: 4 }
|
|
17066
|
-
},
|
|
17067
|
-
minimal: { capabilities: {
|
|
17068
|
-
planning: !1,
|
|
17069
|
-
skills: !1,
|
|
17070
|
-
vfs: !1,
|
|
17071
|
-
summarization: !1,
|
|
17072
|
-
memory: !1,
|
|
17073
|
-
subagent: !1
|
|
17074
|
-
} }
|
|
17075
|
-
};
|
|
17076
|
-
//#endregion
|
|
17077
|
-
export { w_ as CONTEXT_PRESETS, Rh as ChatDialog, Qd as CodePreview, wg as HUMAN_CONFIRM_TOOL_NAME, ef as MessageContent, l_ as connectMcp, sg as createAgent, Cg as createApprovalMiddleware, ey as createChatSdk, Pg as createCheckpointManager, Fg as createCheckpointMiddleware, Dg as createHumanConfirmMiddleware, Eg as createHumanConfirmTool, zv as createMemoryBackend, Uv as createSessionStore, Ug as createSubagentMiddleware, Kg as createSubagentsMiddleware, vv as createUsageHintsMiddleware, qg as createVerifyMiddleware, A_ as createVfs, Vv as createWebStorageBackend, dv as createWindowOps, $g as createWriteBackCheck, ug as defineSkill, ty as defineTool, hv as defineWindowToolset, Gh as estimateTokens, o_ as extractText, pv as fetchDocTools, mv as fetchTools, E_ as formatZodIssues, jv as isQuotaError, q_ as jpEval, O_ as jsonParseError, qh as offloadPassThroughChars, Kh as offloadThresholdChars, ny as presets, T_ as resolveContextOptions, Wh as resolveModelCaps, Q_ as runSandboxedScript, Y_ as searchJson, gv as selectBuiltinTools, $ as toolError, xl as useChat, e as z, D_ as zodError };
|
|
17133
|
+
export { E_ as CONTEXT_PRESETS, Rh as ChatDialog, Qd as CodePreview, wg as HUMAN_CONFIRM_TOOL_NAME, ef as MessageContent, l_ as connectMcp, sg as createAgent, Cg as createApprovalMiddleware, ry as createChatSdk, Pg as createCheckpointManager, Fg as createCheckpointMiddleware, Dg as createHumanConfirmMiddleware, Eg as createHumanConfirmTool, Vv as createMemoryBackend, Gv as createSessionStore, Ug as createSubagentMiddleware, Kg as createSubagentsMiddleware, bv as createUsageHintsMiddleware, qg as createVerifyMiddleware, M_ as createVfs, Uv as createWebStorageBackend, pv as createWindowOps, $g as createWriteBackCheck, ug as defineSkill, iy as defineTool, _v as defineWindowToolset, Gh as estimateTokens, o_ as extractText, hv as fetchDocTools, gv as fetchTools, O_ as formatZodIssues, Nv as isQuotaError, Y_ as jpEval, A_ as jsonParseError, qh as offloadPassThroughChars, Kh as offloadThresholdChars, w_ as presets, D_ as resolveContextOptions, Wh as resolveModelCaps, ev as runSandboxedScript, Z_ as searchJson, vv as selectBuiltinTools, T_ as systemPromptHelpers, $ as toolError, xl as useChat, e as z, k_ as zodError };
|