page-agent-sdk 4.23.2 → 4.24.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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/page-agent-sdk.headless.js +532 -495
- package/dist/page-agent-sdk.iife.js +37 -35
- package/dist/page-agent-sdk.js +1732 -1695
- package/dist/page-agent-sdk.legacy.js +1148 -1111
- package/dist/page-agent-sdk.umd.cjs +51 -49
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/style.css +1 -1
- package/types/headless.d.ts +4 -0
- package/types/index.d.ts +4 -0
|
@@ -503,10 +503,10 @@ function ae(e) {
|
|
|
503
503
|
}
|
|
504
504
|
var oe = process.env.NODE_ENV === "production" ? {} : Object.freeze({});
|
|
505
505
|
process.env.NODE_ENV === "production" || Object.freeze([]);
|
|
506
|
-
var A = () => {}, j = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), se = (e) => e.startsWith("onUpdate:"), M = Object.assign,
|
|
506
|
+
var A = () => {}, j = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), se = (e) => e.startsWith("onUpdate:"), M = Object.assign, ce = (e, t) => {
|
|
507
507
|
let n = e.indexOf(t);
|
|
508
508
|
n > -1 && e.splice(n, 1);
|
|
509
|
-
},
|
|
509
|
+
}, N = Object.prototype.hasOwnProperty, P = (e, t) => N.call(e, t), F = Array.isArray, le = (e) => he(e) === "[object Map]", I = (e) => he(e) === "[object Set]", L = (e) => typeof e == "function", ue = (e) => typeof e == "string", de = (e) => typeof e == "symbol", fe = (e) => typeof e == "object" && !!e, pe = (e) => (fe(e) || L(e)) && L(e.then) && L(e.catch), me = Object.prototype.toString, he = (e) => me.call(e), R = (e) => he(e).slice(8, -1), z = (e) => he(e) === "[object Object]", B = (e) => ue(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, ge = ((e) => {
|
|
510
510
|
let t = /* @__PURE__ */ Object.create(null);
|
|
511
511
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
512
512
|
})((e) => e.charAt(0).toUpperCase() + e.slice(1)), _e = (e, t) => !Object.is(e, t), ve = (e, t, n, r = !1) => {
|
|
@@ -518,14 +518,14 @@ var A = () => {}, j = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110
|
|
|
518
518
|
});
|
|
519
519
|
}, ye, be = () => ye ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
|
|
520
520
|
function V(e) {
|
|
521
|
-
if (
|
|
521
|
+
if (F(e)) {
|
|
522
522
|
let t = {};
|
|
523
523
|
for (let n = 0; n < e.length; n++) {
|
|
524
|
-
let r = e[n], i =
|
|
524
|
+
let r = e[n], i = ue(r) ? Ce(r) : V(r);
|
|
525
525
|
if (i) for (let e in i) t[e] = i[e];
|
|
526
526
|
}
|
|
527
527
|
return t;
|
|
528
|
-
} else if (
|
|
528
|
+
} else if (ue(e) || fe(e)) return e;
|
|
529
529
|
}
|
|
530
530
|
var xe = /;(?![^(]*\))/g, H = /:([^]+)/, Se = /\/\*[^]*?\*\//g;
|
|
531
531
|
function Ce(e) {
|
|
@@ -539,12 +539,12 @@ function Ce(e) {
|
|
|
539
539
|
}
|
|
540
540
|
function U(e) {
|
|
541
541
|
let t = "";
|
|
542
|
-
if (
|
|
543
|
-
else if (
|
|
542
|
+
if (ue(e)) t = e;
|
|
543
|
+
else if (F(e)) for (let n = 0; n < e.length; n++) {
|
|
544
544
|
let r = U(e[n]);
|
|
545
545
|
r && (t += r + " ");
|
|
546
546
|
}
|
|
547
|
-
else if (
|
|
547
|
+
else if (fe(e)) for (let n in e) e[n] && (t += n + " ");
|
|
548
548
|
return t.trim();
|
|
549
549
|
}
|
|
550
550
|
//#endregion
|
|
@@ -765,21 +765,21 @@ function tt(e, t, n, r, i, a) {
|
|
|
765
765
|
};
|
|
766
766
|
if (Ne(), t === "clear") o.forEach(s);
|
|
767
767
|
else {
|
|
768
|
-
let i =
|
|
768
|
+
let i = F(e), a = i && B(n);
|
|
769
769
|
if (i && n === "length") {
|
|
770
770
|
let e = Number(r);
|
|
771
771
|
o.forEach((t, n) => {
|
|
772
|
-
(n === "length" || n === $e || !
|
|
772
|
+
(n === "length" || n === $e || !de(n) && n >= e) && s(t);
|
|
773
773
|
});
|
|
774
774
|
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get($e)), t) {
|
|
775
775
|
case "add":
|
|
776
|
-
i ? a && s(o.get("length")) : (s(o.get(Ze)),
|
|
776
|
+
i ? a && s(o.get("length")) : (s(o.get(Ze)), le(e) && s(o.get(Qe)));
|
|
777
777
|
break;
|
|
778
778
|
case "delete":
|
|
779
|
-
i || (s(o.get(Ze)),
|
|
779
|
+
i || (s(o.get(Ze)), le(e) && s(o.get(Qe)));
|
|
780
780
|
break;
|
|
781
781
|
case "set":
|
|
782
|
-
|
|
782
|
+
le(e) && s(o.get(Ze));
|
|
783
783
|
break;
|
|
784
784
|
}
|
|
785
785
|
}
|
|
@@ -801,7 +801,7 @@ var it = {
|
|
|
801
801
|
return at(this, Symbol.iterator, (e) => G(this, e));
|
|
802
802
|
},
|
|
803
803
|
concat(...e) {
|
|
804
|
-
return nt(this).concat(...e.map((e) =>
|
|
804
|
+
return nt(this).concat(...e.map((e) => F(e) ? nt(e) : e));
|
|
805
805
|
},
|
|
806
806
|
entries() {
|
|
807
807
|
return at(this, "entries", (e) => (e[1] = G(this, e[1]), e));
|
|
@@ -923,9 +923,9 @@ function ut(e, t, n = []) {
|
|
|
923
923
|
let r = (/* @__PURE__ */ q(e))[t].apply(e, n);
|
|
924
924
|
return Pe(), We(), r;
|
|
925
925
|
}
|
|
926
|
-
var dt = /* @__PURE__ */ ae("__proto__,__v_isRef,__isVue"), ft = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(
|
|
926
|
+
var dt = /* @__PURE__ */ ae("__proto__,__v_isRef,__isVue"), ft = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(de));
|
|
927
927
|
function pt(e) {
|
|
928
|
-
|
|
928
|
+
de(e) || (e = String(e));
|
|
929
929
|
let t = /* @__PURE__ */ q(this);
|
|
930
930
|
return et(t, "has", e), t.hasOwnProperty(e);
|
|
931
931
|
}
|
|
@@ -940,43 +940,43 @@ var mt = class {
|
|
|
940
940
|
if (t === "__v_isReadonly") return r;
|
|
941
941
|
if (t === "__v_isShallow") return i;
|
|
942
942
|
if (t === "__v_raw") return n === (r ? i ? Nt : Mt : i ? jt : At).get(e) || Object.getPrototypeOf(e) === Object.getPrototypeOf(n) ? e : void 0;
|
|
943
|
-
let a =
|
|
943
|
+
let a = F(e);
|
|
944
944
|
if (!r) {
|
|
945
945
|
let e;
|
|
946
946
|
if (a && (e = it[t])) return e;
|
|
947
947
|
if (t === "hasOwnProperty") return pt;
|
|
948
948
|
}
|
|
949
949
|
let o = Reflect.get(e, t, /* @__PURE__ */ Y(e) ? e : n);
|
|
950
|
-
if ((
|
|
950
|
+
if ((de(t) ? ft.has(t) : dt(t)) || (r || et(e, "get", t), i)) return o;
|
|
951
951
|
if (/* @__PURE__ */ Y(o)) {
|
|
952
952
|
let e = a && B(t) ? o : o.value;
|
|
953
|
-
return r &&
|
|
953
|
+
return r && fe(e) ? /* @__PURE__ */ It(e) : e;
|
|
954
954
|
}
|
|
955
|
-
return
|
|
955
|
+
return fe(o) ? r ? /* @__PURE__ */ It(o) : /* @__PURE__ */ Ft(o) : o;
|
|
956
956
|
}
|
|
957
957
|
}, ht = class extends mt {
|
|
958
958
|
constructor(e = !1) {
|
|
959
959
|
super(!1, e);
|
|
960
960
|
}
|
|
961
961
|
set(e, t, n, r) {
|
|
962
|
-
let i = e[t], a =
|
|
962
|
+
let i = e[t], a = F(e) && B(t);
|
|
963
963
|
if (!this._isShallow) {
|
|
964
964
|
let r = /* @__PURE__ */ zt(i);
|
|
965
965
|
if (!/* @__PURE__ */ Bt(n) && !/* @__PURE__ */ zt(n) && (i = /* @__PURE__ */ q(i), n = /* @__PURE__ */ q(n)), !a && /* @__PURE__ */ Y(i) && !/* @__PURE__ */ Y(n)) return r ? (process.env.NODE_ENV !== "production" && we(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
|
|
966
966
|
}
|
|
967
|
-
let o = a ? Number(t) < e.length :
|
|
967
|
+
let o = a ? Number(t) < e.length : P(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ Y(e) ? e : r);
|
|
968
968
|
return e === /* @__PURE__ */ q(r) && s && (o ? _e(n, i) && tt(e, "set", t, n, i) : tt(e, "add", t, n)), s;
|
|
969
969
|
}
|
|
970
970
|
deleteProperty(e, t) {
|
|
971
|
-
let n =
|
|
971
|
+
let n = P(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
|
|
972
972
|
return i && n && tt(e, "delete", t, void 0, r), i;
|
|
973
973
|
}
|
|
974
974
|
has(e, t) {
|
|
975
975
|
let n = Reflect.has(e, t);
|
|
976
|
-
return (!
|
|
976
|
+
return (!de(t) || !ft.has(t)) && et(e, "has", t), n;
|
|
977
977
|
}
|
|
978
978
|
ownKeys(e) {
|
|
979
|
-
return et(e, "iterate",
|
|
979
|
+
return et(e, "iterate", F(e) ? "length" : Ze), Reflect.ownKeys(e);
|
|
980
980
|
}
|
|
981
981
|
}, gt = class extends mt {
|
|
982
982
|
constructor(e = !1) {
|
|
@@ -991,7 +991,7 @@ var mt = class {
|
|
|
991
991
|
}, _t = /* @__PURE__ */ new ht(), vt = /* @__PURE__ */ new gt(), yt = /* @__PURE__ */ new gt(!0), bt = (e) => e, xt = (e) => Reflect.getPrototypeOf(e);
|
|
992
992
|
function St(e, t, n) {
|
|
993
993
|
return function(...r) {
|
|
994
|
-
let i = this.__v_raw, a = /* @__PURE__ */ q(i), o =
|
|
994
|
+
let i = this.__v_raw, a = /* @__PURE__ */ q(i), o = le(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? bt : t ? J : Ut;
|
|
995
995
|
return !t && et(a, "iterate", c ? Qe : Ze), M(Object.create(l), { next() {
|
|
996
996
|
let { value: e, done: t } = l.next();
|
|
997
997
|
return t ? {
|
|
@@ -1060,7 +1060,7 @@ function wt(e, t) {
|
|
|
1060
1060
|
return i && tt(t, "delete", e, void 0, a), o;
|
|
1061
1061
|
},
|
|
1062
1062
|
clear() {
|
|
1063
|
-
let e = /* @__PURE__ */ q(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 :
|
|
1063
|
+
let e = /* @__PURE__ */ q(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : le(e) ? new Map(e) : new Set(e), r = e.clear();
|
|
1064
1064
|
return t && tt(e, "clear", void 0, void 0, n), r;
|
|
1065
1065
|
}
|
|
1066
1066
|
}), [
|
|
@@ -1074,13 +1074,13 @@ function wt(e, t) {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
function Tt(e, t) {
|
|
1076
1076
|
let n = wt(e, t);
|
|
1077
|
-
return (t, r, i) => r === "__v_isReactive" ? !e : r === "__v_isReadonly" ? e : r === "__v_raw" ? t : Reflect.get(
|
|
1077
|
+
return (t, r, i) => r === "__v_isReactive" ? !e : r === "__v_isReadonly" ? e : r === "__v_raw" ? t : Reflect.get(P(n, r) && r in t ? n : t, r, i);
|
|
1078
1078
|
}
|
|
1079
1079
|
var Et = { get: /* @__PURE__ */ Tt(!1, !1) }, Dt = { get: /* @__PURE__ */ Tt(!0, !1) }, Ot = { get: /* @__PURE__ */ Tt(!0, !0) };
|
|
1080
1080
|
function kt(e, t, n) {
|
|
1081
1081
|
let r = /* @__PURE__ */ q(n);
|
|
1082
1082
|
if (r !== n && t.call(e, r)) {
|
|
1083
|
-
let t =
|
|
1083
|
+
let t = R(e);
|
|
1084
1084
|
we(`Reactive ${t} contains both the raw and reactive versions of the same object${t === "Map" ? " as keys" : ""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
@@ -1109,11 +1109,11 @@ function Lt(e) {
|
|
|
1109
1109
|
return Rt(e, !0, yt, Ot, Nt);
|
|
1110
1110
|
}
|
|
1111
1111
|
function Rt(e, t, n, r, i) {
|
|
1112
|
-
if (!
|
|
1112
|
+
if (!fe(e)) return process.env.NODE_ENV !== "production" && we(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
|
|
1113
1113
|
if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
|
|
1114
1114
|
let a = i.get(e);
|
|
1115
1115
|
if (a) return a;
|
|
1116
|
-
let o = Pt(
|
|
1116
|
+
let o = Pt(R(e));
|
|
1117
1117
|
if (o === 0) return e;
|
|
1118
1118
|
let s = new Proxy(e, o === 2 ? r : n);
|
|
1119
1119
|
return i.set(e, s), s;
|
|
@@ -1140,9 +1140,9 @@ function q(e) {
|
|
|
1140
1140
|
return t ? /* @__PURE__ */ q(t) : e;
|
|
1141
1141
|
}
|
|
1142
1142
|
function Ht(e) {
|
|
1143
|
-
return !
|
|
1143
|
+
return !P(e, "__v_skip") && Object.isExtensible(e) && ve(e, "__v_skip", !0), e;
|
|
1144
1144
|
}
|
|
1145
|
-
var Ut = (e) =>
|
|
1145
|
+
var Ut = (e) => fe(e) ? /* @__PURE__ */ Ft(e) : e, J = (e) => fe(e) ? /* @__PURE__ */ It(e) : e;
|
|
1146
1146
|
// @__NO_SIDE_EFFECTS__
|
|
1147
1147
|
function Y(e) {
|
|
1148
1148
|
return e ? e.__v_isRef === !0 : !1;
|
|
@@ -1224,7 +1224,7 @@ var Qt = class {
|
|
|
1224
1224
|
// @__NO_SIDE_EFFECTS__
|
|
1225
1225
|
function $t(e, t, n = !1) {
|
|
1226
1226
|
let r, i;
|
|
1227
|
-
|
|
1227
|
+
L(e) ? r = e : (r = e.get, i = e.set);
|
|
1228
1228
|
let a = new Qt(r, i, n);
|
|
1229
1229
|
return process.env.NODE_ENV !== "production" && t && !n && (a.onTrack = t.onTrack, a.onTrigger = t.onTrigger), a;
|
|
1230
1230
|
}
|
|
@@ -1239,12 +1239,12 @@ function an(e, t, n = oe) {
|
|
|
1239
1239
|
let { immediate: r, deep: i, once: a, scheduler: o, augmentJob: s, call: c } = n, l = (e) => {
|
|
1240
1240
|
(n.onWarn || we)("Invalid watch source: ", e, "A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.");
|
|
1241
1241
|
}, u = (e) => i ? e : /* @__PURE__ */ Bt(e) || i === !1 || i === 0 ? on(e, 1) : on(e), d, f, p, m, h = !1, g = !1;
|
|
1242
|
-
if (/* @__PURE__ */ Y(e) ? (f = () => e.value, h = /* @__PURE__ */ Bt(e)) : /* @__PURE__ */ K(e) ? (f = () => u(e), h = !0) :
|
|
1242
|
+
if (/* @__PURE__ */ Y(e) ? (f = () => e.value, h = /* @__PURE__ */ Bt(e)) : /* @__PURE__ */ K(e) ? (f = () => u(e), h = !0) : F(e) ? (g = !0, h = e.some((e) => /* @__PURE__ */ K(e) || /* @__PURE__ */ Bt(e)), f = () => e.map((e) => {
|
|
1243
1243
|
if (/* @__PURE__ */ Y(e)) return e.value;
|
|
1244
1244
|
if (/* @__PURE__ */ K(e)) return u(e);
|
|
1245
|
-
if (
|
|
1245
|
+
if (L(e)) return c ? c(e, 2) : e();
|
|
1246
1246
|
process.env.NODE_ENV !== "production" && l(e);
|
|
1247
|
-
})) :
|
|
1247
|
+
})) : L(e) ? f = t ? c ? () => c(e, 2) : e : () => {
|
|
1248
1248
|
if (p) {
|
|
1249
1249
|
Ue();
|
|
1250
1250
|
try {
|
|
@@ -1265,7 +1265,7 @@ function an(e, t, n = oe) {
|
|
|
1265
1265
|
f = () => on(e(), t);
|
|
1266
1266
|
}
|
|
1267
1267
|
let _ = Ee(), v = () => {
|
|
1268
|
-
d.stop(), _ && _.active &&
|
|
1268
|
+
d.stop(), _ && _.active && ce(_.effects, d);
|
|
1269
1269
|
};
|
|
1270
1270
|
if (a && t) {
|
|
1271
1271
|
let e = t;
|
|
@@ -1304,10 +1304,10 @@ function an(e, t, n = oe) {
|
|
|
1304
1304
|
}, process.env.NODE_ENV !== "production" && (d.onTrack = n.onTrack, d.onTrigger = n.onTrigger), t ? r ? b(!0) : y = d.run() : o ? o(b.bind(null, !0), !0) : d.run(), v.pause = d.pause.bind(d), v.resume = d.resume.bind(d), v.stop = v, v;
|
|
1305
1305
|
}
|
|
1306
1306
|
function on(e, t = Infinity, n) {
|
|
1307
|
-
if (t <= 0 || !
|
|
1307
|
+
if (t <= 0 || !fe(e) || e.__v_skip || (n ||= /* @__PURE__ */ new Map(), (n.get(e) || 0) >= t)) return e;
|
|
1308
1308
|
if (n.set(e, t), t--, /* @__PURE__ */ Y(e)) on(e.value, t, n);
|
|
1309
|
-
else if (
|
|
1310
|
-
else if (
|
|
1309
|
+
else if (F(e)) for (let r = 0; r < e.length; r++) on(e[r], t, n);
|
|
1310
|
+
else if (I(e) || le(e)) e.forEach((e) => {
|
|
1311
1311
|
on(e, t, n);
|
|
1312
1312
|
});
|
|
1313
1313
|
else if (z(e)) {
|
|
@@ -1378,11 +1378,11 @@ function mn(e) {
|
|
|
1378
1378
|
}), n.length > 3 && t.push(" ..."), t;
|
|
1379
1379
|
}
|
|
1380
1380
|
function hn(e, t, n) {
|
|
1381
|
-
return
|
|
1381
|
+
return ue(t) ? (t = JSON.stringify(t), n ? t : [`${e}=${t}`]) : typeof t == "number" || typeof t == "boolean" || t == null ? n ? t : [`${e}=${t}`] : /* @__PURE__ */ Y(t) ? (t = hn(e, /* @__PURE__ */ q(t.value), !0), n ? t : [
|
|
1382
1382
|
`${e}=Ref<`,
|
|
1383
1383
|
t,
|
|
1384
1384
|
">"
|
|
1385
|
-
]) :
|
|
1385
|
+
]) : L(t) ? [`${e}=fn${t.name ? `<${t.name}>` : ""}`] : (t = /* @__PURE__ */ q(t), n ? t : [`${e}=`, t]);
|
|
1386
1386
|
}
|
|
1387
1387
|
var gn = {
|
|
1388
1388
|
sp: "serverPrefetch hook",
|
|
@@ -1425,13 +1425,13 @@ function _n(e, t, n, r) {
|
|
|
1425
1425
|
}
|
|
1426
1426
|
}
|
|
1427
1427
|
function vn(e, t, n, r) {
|
|
1428
|
-
if (
|
|
1428
|
+
if (L(e)) {
|
|
1429
1429
|
let i = _n(e, t, n, r);
|
|
1430
|
-
return i &&
|
|
1430
|
+
return i && pe(i) && i.catch((e) => {
|
|
1431
1431
|
yn(e, t, n);
|
|
1432
1432
|
}), i;
|
|
1433
1433
|
}
|
|
1434
|
-
if (
|
|
1434
|
+
if (F(e)) {
|
|
1435
1435
|
let i = [];
|
|
1436
1436
|
for (let a = 0; a < e.length; a++) i.push(vn(e[a], t, n, r));
|
|
1437
1437
|
return i;
|
|
@@ -1490,7 +1490,7 @@ function Mn() {
|
|
|
1490
1490
|
Dn ||= En.then(In);
|
|
1491
1491
|
}
|
|
1492
1492
|
function Nn(e) {
|
|
1493
|
-
|
|
1493
|
+
F(e) ? Cn.push(...e) : wn && e.id === -1 ? wn.splice(Tn + 1, 0, e) : e.flags & 1 || (Cn.push(e), e.flags |= 1), Mn();
|
|
1494
1494
|
}
|
|
1495
1495
|
function Pn(e) {
|
|
1496
1496
|
if (Cn.length) {
|
|
@@ -1598,7 +1598,7 @@ function Zn(e, t, n = !1) {
|
|
|
1598
1598
|
if (r || Sr) {
|
|
1599
1599
|
let i = Sr ? Sr._context.provides : r ? r.parent == null || r.ce ? r.vnode.appContext && r.vnode.appContext.provides : r.parent.provides : void 0;
|
|
1600
1600
|
if (i && e in i) return i[e];
|
|
1601
|
-
if (arguments.length > 1) return n &&
|
|
1601
|
+
if (arguments.length > 1) return n && L(t) ? t.call(r && r.proxy) : t;
|
|
1602
1602
|
process.env.NODE_ENV !== "production" && un(`injection "${String(e)}" not found.`);
|
|
1603
1603
|
} else process.env.NODE_ENV !== "production" && un("inject() can only be used inside setup() or functional components.");
|
|
1604
1604
|
}
|
|
@@ -1637,8 +1637,8 @@ function er(e, t, n = oe) {
|
|
|
1637
1637
|
return Xr && (l ? l.push(f) : c && f()), f;
|
|
1638
1638
|
}
|
|
1639
1639
|
function tr(e, t, n) {
|
|
1640
|
-
let r = this.proxy, i =
|
|
1641
|
-
|
|
1640
|
+
let r = this.proxy, i = ue(e) ? e.includes(".") ? nr(r, e) : () => r[e] : e.bind(r, r), a;
|
|
1641
|
+
L(t) ? a = t : (a = t.handler, n = t);
|
|
1642
1642
|
let o = Jr(this), s = er(i, a.bind(r), n);
|
|
1643
1643
|
return o(), s;
|
|
1644
1644
|
}
|
|
@@ -1673,7 +1673,7 @@ var ar = /* @__PURE__ */ Symbol.for("v-ndc"), or = (e) => e ? Yr(e) ? Zr(e) : or
|
|
|
1673
1673
|
},
|
|
1674
1674
|
$nextTick: (e) => e.n ||= kn.bind(e.proxy),
|
|
1675
1675
|
$watch: (e) => tr.bind(e)
|
|
1676
|
-
}), cr = (e, t) => e !== oe && !e.__isScriptSetup &&
|
|
1676
|
+
}), cr = (e, t) => e !== oe && !e.__isScriptSetup && P(e, t), lr = {
|
|
1677
1677
|
get({ _: e }, t) {
|
|
1678
1678
|
if (t === "__v_skip") return !0;
|
|
1679
1679
|
let { ctx: n, setupState: r, data: i, props: a, accessCache: o, type: s, appContext: c } = e;
|
|
@@ -1687,21 +1687,21 @@ var ar = /* @__PURE__ */ Symbol.for("v-ndc"), or = (e) => e ? Yr(e) ? Zr(e) : or
|
|
|
1687
1687
|
case 3: return a[t];
|
|
1688
1688
|
}
|
|
1689
1689
|
else if (cr(r, t)) return o[t] = 1, r[t];
|
|
1690
|
-
else if (i !== oe &&
|
|
1691
|
-
else if (
|
|
1692
|
-
else if (n !== oe &&
|
|
1690
|
+
else if (i !== oe && P(i, t)) return o[t] = 2, i[t];
|
|
1691
|
+
else if (P(a, t)) return o[t] = 3, a[t];
|
|
1692
|
+
else if (n !== oe && P(n, t)) return o[t] = 4, n[t];
|
|
1693
1693
|
else dr && (o[t] = 0);
|
|
1694
1694
|
}
|
|
1695
1695
|
let l = sr[t], u, d;
|
|
1696
1696
|
if (l) return t === "$attrs" ? (et(e.attrs, "get", ""), process.env.NODE_ENV) : process.env.NODE_ENV !== "production" && t === "$slots" && et(e, "get", t), l(e);
|
|
1697
1697
|
if ((u = s.__cssModules) && (u = u[t])) return u;
|
|
1698
|
-
if (n !== oe &&
|
|
1699
|
-
if (d = c.config.globalProperties,
|
|
1698
|
+
if (n !== oe && P(n, t)) return o[t] = 4, n[t];
|
|
1699
|
+
if (d = c.config.globalProperties, P(d, t)) return d[t];
|
|
1700
1700
|
process.env.NODE_ENV;
|
|
1701
1701
|
},
|
|
1702
1702
|
set({ _: e }, t, n) {
|
|
1703
1703
|
let { data: r, setupState: i, ctx: a } = e;
|
|
1704
|
-
return cr(i, t) ? (i[t] = n, !0) : process.env.NODE_ENV !== "production" && i.__isScriptSetup &&
|
|
1704
|
+
return cr(i, t) ? (i[t] = n, !0) : process.env.NODE_ENV !== "production" && i.__isScriptSetup && P(i, t) ? (un(`Cannot mutate <script setup> binding "${t}" from Options API.`), !1) : r !== oe && P(r, t) ? (r[t] = n, !0) : P(e.props, t) ? (process.env.NODE_ENV !== "production" && un(`Attempting to mutate prop "${t}". Props are readonly.`), !1) : t[0] === "$" && t.slice(1) in e ? (process.env.NODE_ENV !== "production" && un(`Attempting to mutate public property "${t}". Properties starting with $ are reserved and readonly.`), !1) : (process.env.NODE_ENV !== "production" && t in e.appContext.config.globalProperties ? Object.defineProperty(a, t, {
|
|
1705
1705
|
enumerable: !0,
|
|
1706
1706
|
configurable: !0,
|
|
1707
1707
|
value: n
|
|
@@ -1709,20 +1709,20 @@ var ar = /* @__PURE__ */ Symbol.for("v-ndc"), or = (e) => e ? Yr(e) ? Zr(e) : or
|
|
|
1709
1709
|
},
|
|
1710
1710
|
has({ _: { data: e, setupState: t, accessCache: n, ctx: r, appContext: i, props: a, type: o } }, s) {
|
|
1711
1711
|
let c;
|
|
1712
|
-
return !!(n[s] || e !== oe && s[0] !== "$" &&
|
|
1712
|
+
return !!(n[s] || e !== oe && s[0] !== "$" && P(e, s) || cr(t, s) || P(a, s) || P(r, s) || P(sr, s) || P(i.config.globalProperties, s) || (c = o.__cssModules) && c[s]);
|
|
1713
1713
|
},
|
|
1714
1714
|
defineProperty(e, t, n) {
|
|
1715
|
-
return n.get == null ?
|
|
1715
|
+
return n.get == null ? P(n, "value") && this.set(e, t, n.value, null) : e._.accessCache[t] = 0, Reflect.defineProperty(e, t, n);
|
|
1716
1716
|
}
|
|
1717
1717
|
};
|
|
1718
1718
|
process.env.NODE_ENV !== "production" && (lr.ownKeys = (e) => (un("Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead."), Reflect.ownKeys(e)));
|
|
1719
1719
|
function ur(e) {
|
|
1720
|
-
return
|
|
1720
|
+
return F(e) ? e.reduce((e, t) => (e[t] = null, e), {}) : e;
|
|
1721
1721
|
}
|
|
1722
1722
|
var dr = !0;
|
|
1723
1723
|
function fr(e) {
|
|
1724
1724
|
let t = e.type, { mixins: n, extends: r } = t, { mixins: i, optionsCache: a, config: { optionMergeStrategies: o } } = e.appContext, s = a.get(t), c;
|
|
1725
|
-
return s ? c = s : !i.length && !n && !r ? c = t : (c = {}, i.length && i.forEach((e) => pr(c, e, o, !0)), pr(c, t, o)),
|
|
1725
|
+
return s ? c = s : !i.length && !n && !r ? c = t : (c = {}, i.length && i.forEach((e) => pr(c, e, o, !0)), pr(c, t, o)), fe(t) && a.set(t, c), c;
|
|
1726
1726
|
}
|
|
1727
1727
|
function pr(e, t, n, r = !1) {
|
|
1728
1728
|
let { mixins: i, extends: a } = t;
|
|
@@ -1762,14 +1762,14 @@ var mr = {
|
|
|
1762
1762
|
};
|
|
1763
1763
|
function hr(e, t) {
|
|
1764
1764
|
return t ? e ? function() {
|
|
1765
|
-
return M(
|
|
1765
|
+
return M(L(e) ? e.call(this, this) : e, L(t) ? t.call(this, this) : t);
|
|
1766
1766
|
} : t : e;
|
|
1767
1767
|
}
|
|
1768
1768
|
function gr(e, t) {
|
|
1769
1769
|
return yr(_r(e), _r(t));
|
|
1770
1770
|
}
|
|
1771
1771
|
function _r(e) {
|
|
1772
|
-
if (
|
|
1772
|
+
if (F(e)) {
|
|
1773
1773
|
let t = {};
|
|
1774
1774
|
for (let n = 0; n < e.length; n++) t[e[n]] = e[n];
|
|
1775
1775
|
return t;
|
|
@@ -1783,7 +1783,7 @@ function yr(e, t) {
|
|
|
1783
1783
|
return e ? M(/* @__PURE__ */ Object.create(null), e, t) : t;
|
|
1784
1784
|
}
|
|
1785
1785
|
function br(e, t) {
|
|
1786
|
-
return e ?
|
|
1786
|
+
return e ? F(e) && F(t) ? [.../* @__PURE__ */ new Set([...e, ...t])] : M(/* @__PURE__ */ Object.create(null), ur(e), ur(t ?? {})) : t;
|
|
1787
1787
|
}
|
|
1788
1788
|
function xr(e, t) {
|
|
1789
1789
|
if (!e) return t;
|
|
@@ -1794,13 +1794,13 @@ function xr(e, t) {
|
|
|
1794
1794
|
}
|
|
1795
1795
|
var Sr = null, Cr = {}, wr = (e) => Object.getPrototypeOf(e) === Cr, Tr = Dr, Er = (e) => e.__isSuspense;
|
|
1796
1796
|
function Dr(e, t) {
|
|
1797
|
-
t && t.pendingBranch ?
|
|
1797
|
+
t && t.pendingBranch ? F(e) ? t.effects.push(...e) : t.effects.push(e) : Nn(e);
|
|
1798
1798
|
}
|
|
1799
1799
|
var Or = /* @__PURE__ */ Symbol.for("v-fgt"), kr = /* @__PURE__ */ Symbol.for("v-txt"), Ar = /* @__PURE__ */ Symbol.for("v-cmt");
|
|
1800
1800
|
function jr(e) {
|
|
1801
1801
|
return e ? e.__v_isVNode === !0 : !1;
|
|
1802
1802
|
}
|
|
1803
|
-
var Mr, Nr = (...e) => Rr(...Mr ? Mr(e, Yn) : e), Pr = ({ key: e }) => e ?? null, Fr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null :
|
|
1803
|
+
var Mr, Nr = (...e) => Rr(...Mr ? Mr(e, Yn) : e), Pr = ({ key: e }) => e ?? null, Fr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null : ue(e) || /* @__PURE__ */ Y(e) || L(e) ? {
|
|
1804
1804
|
i: Yn,
|
|
1805
1805
|
r: e,
|
|
1806
1806
|
k: t,
|
|
@@ -1836,7 +1836,7 @@ function Ir(e, t = null, n = null, r = 0, i = null, a = e === Or ? 0 : 1, o = !1
|
|
|
1836
1836
|
appContext: null,
|
|
1837
1837
|
ctx: Yn
|
|
1838
1838
|
};
|
|
1839
|
-
return s ? (Ur(c, n), a & 128 && e.normalize(c)) : n && (c.shapeFlag |=
|
|
1839
|
+
return s ? (Ur(c, n), a & 128 && e.normalize(c)) : n && (c.shapeFlag |= ue(n) ? 8 : 16), process.env.NODE_ENV !== "production" && c.key !== c.key && un("VNode created with invalid key (NaN). VNode type:", c.type), c;
|
|
1840
1840
|
}
|
|
1841
1841
|
var Lr = process.env.NODE_ENV === "production" ? Rr : Nr;
|
|
1842
1842
|
function Rr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
@@ -1847,9 +1847,9 @@ function Rr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
1847
1847
|
if (ni(e) && (e = e.__vccOpts), t) {
|
|
1848
1848
|
t = zr(t);
|
|
1849
1849
|
let { class: e, style: n } = t;
|
|
1850
|
-
e && !
|
|
1850
|
+
e && !ue(e) && (t.class = U(e)), fe(n) && (/* @__PURE__ */ Vt(n) && !F(n) && (n = M({}, n)), t.style = V(n));
|
|
1851
1851
|
}
|
|
1852
|
-
let o =
|
|
1852
|
+
let o = ue(e) ? 1 : Er(e) ? 128 : rr(e) ? 64 : fe(e) ? 4 : L(e) ? 2 : 0;
|
|
1853
1853
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ Vt(e) && (e = /* @__PURE__ */ q(e), un("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), Ir(e, t, n, r, i, o, a, !0);
|
|
1854
1854
|
}
|
|
1855
1855
|
function zr(e) {
|
|
@@ -1862,10 +1862,10 @@ function Br(e, t, n = !1, r = !1) {
|
|
|
1862
1862
|
type: e.type,
|
|
1863
1863
|
props: l,
|
|
1864
1864
|
key: l && Pr(l),
|
|
1865
|
-
ref: t && t.ref ? n && a ?
|
|
1865
|
+
ref: t && t.ref ? n && a ? F(a) ? a.concat(Fr(t)) : [a, Fr(t)] : Fr(t) : a,
|
|
1866
1866
|
scopeId: e.scopeId,
|
|
1867
1867
|
slotScopeIds: e.slotScopeIds,
|
|
1868
|
-
children: process.env.NODE_ENV !== "production" && o === -1 &&
|
|
1868
|
+
children: process.env.NODE_ENV !== "production" && o === -1 && F(s) ? s.map(Vr) : s,
|
|
1869
1869
|
target: e.target,
|
|
1870
1870
|
targetStart: e.targetStart,
|
|
1871
1871
|
targetAnchor: e.targetAnchor,
|
|
@@ -1891,7 +1891,7 @@ function Br(e, t, n = !1, r = !1) {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
function Vr(e) {
|
|
1893
1893
|
let t = Br(e);
|
|
1894
|
-
return
|
|
1894
|
+
return F(e.children) && (t.children = e.children.map(Vr)), t;
|
|
1895
1895
|
}
|
|
1896
1896
|
function Hr(e = " ", t = 0) {
|
|
1897
1897
|
return Lr(kr, null, e, t);
|
|
@@ -1899,13 +1899,13 @@ function Hr(e = " ", t = 0) {
|
|
|
1899
1899
|
function Ur(e, t) {
|
|
1900
1900
|
let n = 0, { shapeFlag: r } = e;
|
|
1901
1901
|
if (t == null) t = null;
|
|
1902
|
-
else if (
|
|
1902
|
+
else if (F(t)) n = 16;
|
|
1903
1903
|
else if (typeof t == "object") if (r & 65) {
|
|
1904
1904
|
let n = t.default;
|
|
1905
1905
|
n && (n._c && (n._d = !1), Ur(e, n()), n._c && (n._d = !0));
|
|
1906
1906
|
return;
|
|
1907
1907
|
} else n = 32, !t._ && !wr(t) && (t._ctx = Yn);
|
|
1908
|
-
else if (
|
|
1908
|
+
else if (L(t)) {
|
|
1909
1909
|
if (r & 65) {
|
|
1910
1910
|
Ur(e, { default: t });
|
|
1911
1911
|
return;
|
|
@@ -1925,7 +1925,7 @@ function Wr(...e) {
|
|
|
1925
1925
|
else if (e === "style") t.style = V([t.style, r.style]);
|
|
1926
1926
|
else if (j(e)) {
|
|
1927
1927
|
let n = t[e], i = r[e];
|
|
1928
|
-
i && n !== i && !(
|
|
1928
|
+
i && n !== i && !(F(n) && n.includes(i)) ? t[e] = n ? [].concat(n, i) : i : i == null && n == null && !se(e) && (t[e] = i);
|
|
1929
1929
|
} else e !== "" && (t[e] = r[e]);
|
|
1930
1930
|
}
|
|
1931
1931
|
return t;
|
|
@@ -1964,7 +1964,7 @@ function Zr(e) {
|
|
|
1964
1964
|
}
|
|
1965
1965
|
var Qr = /(?:^|[-_])\w/g, $r = (e) => e.replace(Qr, (e) => e.toUpperCase()).replace(/[-_]/g, "");
|
|
1966
1966
|
function ei(e, t = !0) {
|
|
1967
|
-
return
|
|
1967
|
+
return L(e) ? e.displayName || e.name : e.name || t && e.__name;
|
|
1968
1968
|
}
|
|
1969
1969
|
function ti(e, t, n = !1) {
|
|
1970
1970
|
let r = ei(t);
|
|
@@ -1981,7 +1981,7 @@ function ti(e, t, n = !1) {
|
|
|
1981
1981
|
return r ? $r(r) : n ? "App" : "Anonymous";
|
|
1982
1982
|
}
|
|
1983
1983
|
function ni(e) {
|
|
1984
|
-
return
|
|
1984
|
+
return L(e) && "__vccOpts" in e;
|
|
1985
1985
|
}
|
|
1986
1986
|
var ri = (e, t) => {
|
|
1987
1987
|
let n = /* @__PURE__ */ $t(e, t, Xr);
|
|
@@ -1996,7 +1996,7 @@ function ii() {
|
|
|
1996
1996
|
let e = { style: "color:#3ba776" }, t = { style: "color:#1677ff" }, n = { style: "color:#f5222d" }, r = { style: "color:#eb2f96" }, i = {
|
|
1997
1997
|
__vue_custom_formatter: !0,
|
|
1998
1998
|
header(t) {
|
|
1999
|
-
if (!
|
|
1999
|
+
if (!fe(t)) return null;
|
|
2000
2000
|
if (t.__isVue) return [
|
|
2001
2001
|
"div",
|
|
2002
2002
|
e,
|
|
@@ -2109,7 +2109,7 @@ function ii() {
|
|
|
2109
2109
|
"span",
|
|
2110
2110
|
r,
|
|
2111
2111
|
e
|
|
2112
|
-
] :
|
|
2112
|
+
] : fe(e) ? ["object", { object: i ? /* @__PURE__ */ q(e) : e }] : [
|
|
2113
2113
|
"span",
|
|
2114
2114
|
n,
|
|
2115
2115
|
String(e)
|
|
@@ -2117,14 +2117,14 @@ function ii() {
|
|
|
2117
2117
|
}
|
|
2118
2118
|
function c(e, t) {
|
|
2119
2119
|
let n = e.type;
|
|
2120
|
-
if (
|
|
2120
|
+
if (L(n)) return;
|
|
2121
2121
|
let r = {};
|
|
2122
2122
|
for (let i in e.ctx) l(n, i, t) && (r[i] = e.ctx[i]);
|
|
2123
2123
|
return r;
|
|
2124
2124
|
}
|
|
2125
2125
|
function l(e, t, n) {
|
|
2126
2126
|
let r = e[n];
|
|
2127
|
-
if (
|
|
2127
|
+
if (F(r) && r.includes(t) || fe(r) && t in r || e.extends && l(e.extends, t, n) || e.mixins && e.mixins.some((e) => l(e, t, n))) return !0;
|
|
2128
2128
|
}
|
|
2129
2129
|
function u(e) {
|
|
2130
2130
|
return /* @__PURE__ */ Bt(e) ? "ShallowRef" : e.effect ? "ComputedRef" : "Ref";
|
|
@@ -3998,50 +3998,50 @@ function js(e) {
|
|
|
3998
3998
|
function Ms(e) {
|
|
3999
3999
|
let { apiKey: t, baseUrl: s, model: c = "deepseek-v4-flash", temperature: l = .7, maxTokens: u, extraBody: d, extraConfig: f, systemPrompt: p, tools: m = [], middleware: h = [], maxToolRounds: g, maxIterations: _, maxRetries: S = 2, retryDelayMs: C = 500, stallMs: E = fa, streamMaxMs: D = ma, toolTimeoutMs: O, maxParallelTools: k = 1, maxVerifyAttempts: ne = 0, roundTokenBudget: re = 0, onLog: ae, onLlmChange: oe, imageContentFormat: A = "openai", staleReadInvalidation: j = !0, debug: se = !1 } = e, M = g ?? xs;
|
|
4000
4000
|
(!Number.isFinite(M) || M < 1) && (console.warn(`[page-agent-sdk] maxToolRounds=${M} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`), M = 1);
|
|
4001
|
-
let
|
|
4001
|
+
let ce = v({
|
|
4002
4002
|
model: c,
|
|
4003
4003
|
contextWindow: e.contextWindow,
|
|
4004
4004
|
maxOutputTokens: e.maxOutputTokens,
|
|
4005
4005
|
vision: e.vision
|
|
4006
|
-
}),
|
|
4007
|
-
function
|
|
4008
|
-
|
|
4006
|
+
}), N = u ?? ce.maxOutputTokens, P = b(ce.contextWindow), F = x(ce.contextWindow);
|
|
4007
|
+
function le(e) {
|
|
4008
|
+
ce = e, P = b(ce.contextWindow), F = x(ce.contextWindow);
|
|
4009
4009
|
}
|
|
4010
|
-
let
|
|
4010
|
+
let I = /* @__PURE__ */ Gt([]), L = 0, ue = () => ({
|
|
4011
4011
|
retries: 0,
|
|
4012
4012
|
exhausted: 0
|
|
4013
|
-
}),
|
|
4014
|
-
transitional_retry:
|
|
4015
|
-
completion_gate:
|
|
4016
|
-
evidence_audit_gate:
|
|
4017
|
-
zero_tool_gate:
|
|
4018
|
-
status_query_gate:
|
|
4019
|
-
...e.pageAssertionGate === !0 ? { page_assertion_gate:
|
|
4020
|
-
},
|
|
4013
|
+
}), de = {
|
|
4014
|
+
transitional_retry: ue(),
|
|
4015
|
+
completion_gate: ue(),
|
|
4016
|
+
evidence_audit_gate: ue(),
|
|
4017
|
+
zero_tool_gate: ue(),
|
|
4018
|
+
status_query_gate: ue(),
|
|
4019
|
+
...e.pageAssertionGate === !0 ? { page_assertion_gate: ue() } : {}
|
|
4020
|
+
}, fe = {
|
|
4021
4021
|
ZERO_TOOL_GATE_EXHAUSTED: "zero_tool_gate",
|
|
4022
4022
|
AUDIT_GATE_EXHAUSTED: "evidence_audit_gate",
|
|
4023
4023
|
COMPLETION_GATE_EXHAUSTED: "completion_gate",
|
|
4024
4024
|
PAGE_ASSERTION_GATE_EXHAUSTED: "page_assertion_gate"
|
|
4025
|
-
},
|
|
4025
|
+
}, pe = [], me = 0, he = 0, R = /* @__PURE__ */ new Set();
|
|
4026
4026
|
function z(e, t) {
|
|
4027
4027
|
let n = {
|
|
4028
4028
|
timestamp: Date.now(),
|
|
4029
4029
|
type: e,
|
|
4030
4030
|
data: Es(t)
|
|
4031
4031
|
};
|
|
4032
|
-
|
|
4032
|
+
I.value.push(n), I.value.length > Ss && I.value.splice(0, I.value.length - Ss), Jt(I), ae?.(n), se && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
4033
4033
|
}
|
|
4034
4034
|
let B = (e) => {
|
|
4035
|
-
|
|
4035
|
+
I.value.push({
|
|
4036
4036
|
...e,
|
|
4037
4037
|
timestamp: typeof e.timestamp == "number" ? e.timestamp : Date.now(),
|
|
4038
4038
|
data: Es(e.data)
|
|
4039
|
-
}),
|
|
4039
|
+
}), I.value.length > Ss && I.value.splice(0, I.value.length - Ss), Jt(I);
|
|
4040
4040
|
}, ge = [...h.flatMap((e) => e.tools || []), ...m], _e = e.llm ?? new n({
|
|
4041
4041
|
apiKey: t,
|
|
4042
4042
|
model: c,
|
|
4043
4043
|
temperature: l,
|
|
4044
|
-
maxTokens:
|
|
4044
|
+
maxTokens: N,
|
|
4045
4045
|
maxRetries: 0,
|
|
4046
4046
|
configuration: {
|
|
4047
4047
|
...s ? { baseURL: T(s) } : {},
|
|
@@ -4078,16 +4078,16 @@ function Ms(e) {
|
|
|
4078
4078
|
pin: H.has(e.name)
|
|
4079
4079
|
});
|
|
4080
4080
|
}
|
|
4081
|
-
let n = Math.max(2e3, Math.round(
|
|
4081
|
+
let n = Math.max(2e3, Math.round(ce.contextWindow * xe)), r = y(e) + t.reduce((e, t) => e + t.tokens, 0), i = /* @__PURE__ */ new Set();
|
|
4082
4082
|
if (r > n) {
|
|
4083
4083
|
let e = r, a = [];
|
|
4084
4084
|
for (let e of t.filter((e) => !e.pin).sort((e, t) => t.tokens - e.tokens)) {
|
|
4085
4085
|
if (r <= n) break;
|
|
4086
4086
|
a.push(`${e.name}(${e.tokens})`), i.add(e.name), r -= e.tokens, e.text = "";
|
|
4087
4087
|
}
|
|
4088
|
-
a.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${
|
|
4088
|
+
a.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${ce.contextWindow} 的 ${xe * 100}%),drop 非核心段:${a.join(", ")}(保 base/mission/workingMemory)`);
|
|
4089
4089
|
}
|
|
4090
|
-
return
|
|
4090
|
+
return pe = t.map((e) => ({
|
|
4091
4091
|
name: e.name,
|
|
4092
4092
|
tokens: e.tokens,
|
|
4093
4093
|
dropped: i.has(e.name)
|
|
@@ -4096,7 +4096,7 @@ function Ms(e) {
|
|
|
4096
4096
|
function Ce(e) {
|
|
4097
4097
|
let t = [new a(Se())];
|
|
4098
4098
|
for (let n of e) if (n.role === "user") {
|
|
4099
|
-
let e = n.quote ? Pi(n.content, n.quote) : n.content, r =
|
|
4099
|
+
let e = n.quote ? Pi(n.content, n.quote) : n.content, r = ce.vision && n.images?.length ? yi(e, n.images, A) : null;
|
|
4100
4100
|
r ? t.push(new i({ content: r })) : n.images?.some((e) => e.description) ? t.push(new i(bi(e, n.images))) : t.push(new i(e));
|
|
4101
4101
|
} else n.role === "assistant" ? t.push(new r(n.content)) : n.role === "system" && t.push(new a(n.content));
|
|
4102
4102
|
return t;
|
|
@@ -4112,7 +4112,7 @@ function Ms(e) {
|
|
|
4112
4112
|
baseDelayMs: C,
|
|
4113
4113
|
onRetry: ({ attempt: e, error: t, waitMs: n }) => {
|
|
4114
4114
|
let r = t?.message ?? String(t);
|
|
4115
|
-
|
|
4115
|
+
me += 1, z("error", {
|
|
4116
4116
|
stage: "model_retry",
|
|
4117
4117
|
at: "launch",
|
|
4118
4118
|
attempt: e,
|
|
@@ -4145,23 +4145,23 @@ function Ms(e) {
|
|
|
4145
4145
|
};
|
|
4146
4146
|
if (ga(a) && !e._ctxRetry) {
|
|
4147
4147
|
e._ctxRetry = !0;
|
|
4148
|
-
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = W(e.messages, Math.round(
|
|
4148
|
+
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = W(e.messages, Math.round(ce.contextWindow * .3)), s = o.reduce((e, t) => e + r(t), 0);
|
|
4149
4149
|
return z("error", {
|
|
4150
4150
|
stage: "context_overflow_retry",
|
|
4151
4151
|
at: "launch",
|
|
4152
4152
|
beforeTokens: a,
|
|
4153
4153
|
afterTokens: s,
|
|
4154
|
-
window:
|
|
4154
|
+
window: ce.contextWindow
|
|
4155
4155
|
}), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`), we({
|
|
4156
4156
|
...e,
|
|
4157
4157
|
messages: o
|
|
4158
4158
|
}, t, n, i);
|
|
4159
4159
|
}
|
|
4160
|
-
throw ya(a) ? (
|
|
4160
|
+
throw ya(a) ? (he += 1, z("error", {
|
|
4161
4161
|
stage: "model_unavailable",
|
|
4162
4162
|
at: "launch",
|
|
4163
4163
|
status: a?.status
|
|
4164
|
-
})) : (
|
|
4164
|
+
})) : (he += 1, z("error", {
|
|
4165
4165
|
stage: "model_call_failed",
|
|
4166
4166
|
at: "launch",
|
|
4167
4167
|
retries: S,
|
|
@@ -4190,7 +4190,7 @@ function Ms(e) {
|
|
|
4190
4190
|
});
|
|
4191
4191
|
}
|
|
4192
4192
|
} catch (a) {
|
|
4193
|
-
if (a instanceof ua) throw s.abort(),
|
|
4193
|
+
if (a instanceof ua) throw s.abort(), he += 1, z("error", {
|
|
4194
4194
|
stage: a instanceof da ? "stream_max_duration" : "stream_stalled",
|
|
4195
4195
|
waitedMs: a.waitedMs,
|
|
4196
4196
|
stallMs: E,
|
|
@@ -4204,20 +4204,20 @@ function Ms(e) {
|
|
|
4204
4204
|
};
|
|
4205
4205
|
if (ga(a) && l === null && u === "" && !e._ctxRetry) {
|
|
4206
4206
|
e._ctxRetry = !0;
|
|
4207
|
-
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = W(e.messages, Math.round(
|
|
4207
|
+
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = W(e.messages, Math.round(ce.contextWindow * .3)), s = o.reduce((e, t) => e + r(t), 0);
|
|
4208
4208
|
return z("error", {
|
|
4209
4209
|
stage: "context_overflow_retry",
|
|
4210
4210
|
beforeTokens: a,
|
|
4211
4211
|
afterTokens: s,
|
|
4212
|
-
window:
|
|
4213
|
-
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${
|
|
4212
|
+
window: ce.contextWindow
|
|
4213
|
+
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${ce.contextWindow})`), we({
|
|
4214
4214
|
...e,
|
|
4215
4215
|
messages: o
|
|
4216
4216
|
}, t, n, i);
|
|
4217
4217
|
}
|
|
4218
4218
|
let o = (e._iterRetries ?? 0) + 1;
|
|
4219
4219
|
if (l === null && u === "" && o <= S && oa(a, n)) {
|
|
4220
|
-
e._iterRetries = o,
|
|
4220
|
+
e._iterRetries = o, me += 1;
|
|
4221
4221
|
let s = C * 2 ** (o - 1);
|
|
4222
4222
|
if (z("error", {
|
|
4223
4223
|
stage: "model_retry",
|
|
@@ -4249,11 +4249,11 @@ function Ms(e) {
|
|
|
4249
4249
|
}
|
|
4250
4250
|
return we(e, t, n, i);
|
|
4251
4251
|
}
|
|
4252
|
-
throw ya(a) ? (
|
|
4252
|
+
throw ya(a) ? (he += 1, z("error", {
|
|
4253
4253
|
stage: "model_unavailable",
|
|
4254
4254
|
at: "iterate",
|
|
4255
4255
|
status: a?.status
|
|
4256
|
-
})) : (
|
|
4256
|
+
})) : (he += 1, z("error", {
|
|
4257
4257
|
stage: "model_call_failed",
|
|
4258
4258
|
at: "iterate",
|
|
4259
4259
|
emitted: l !== null || u !== "",
|
|
@@ -4269,7 +4269,7 @@ function Ms(e) {
|
|
|
4269
4269
|
stage: "empty_llm_response",
|
|
4270
4270
|
retried: !0,
|
|
4271
4271
|
hint: "重试后仍零 chunk,抛 EmptyLLMResponseError 显式报错"
|
|
4272
|
-
}),
|
|
4272
|
+
}), he += 1, new pa();
|
|
4273
4273
|
}
|
|
4274
4274
|
let d = l;
|
|
4275
4275
|
return {
|
|
@@ -4312,8 +4312,8 @@ function Ms(e) {
|
|
|
4312
4312
|
files: e.state.files,
|
|
4313
4313
|
vfsAvailable: !!e.state.files && o,
|
|
4314
4314
|
toolName: e.name,
|
|
4315
|
-
threshold:
|
|
4316
|
-
passThroughChars:
|
|
4315
|
+
threshold: P,
|
|
4316
|
+
passThroughChars: F
|
|
4317
4317
|
}).content, {
|
|
4318
4318
|
content: a,
|
|
4319
4319
|
status: "done"
|
|
@@ -4360,9 +4360,9 @@ function Ms(e) {
|
|
|
4360
4360
|
});
|
|
4361
4361
|
}
|
|
4362
4362
|
{
|
|
4363
|
-
let e = y(p || "你是一个智能助手。"), t = Math.max(2e3, Math.round(
|
|
4363
|
+
let e = y(p || "你是一个智能助手。"), t = Math.max(2e3, Math.round(ce.contextWindow * xe));
|
|
4364
4364
|
if (e > t) {
|
|
4365
|
-
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${
|
|
4365
|
+
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${ce.contextWindow} 的 ${xe * 100}%);请缩减 systemPrompt 或换更大窗口模型`;
|
|
4366
4366
|
return console.error(r), n({
|
|
4367
4367
|
type: "error",
|
|
4368
4368
|
message: r,
|
|
@@ -4430,7 +4430,7 @@ function Ms(e) {
|
|
|
4430
4430
|
}), V = ls(h, {
|
|
4431
4431
|
messages: c,
|
|
4432
4432
|
state: V
|
|
4433
|
-
}), c = U(c, ks(S, M, e.hasSubagent)), c = W(c, Math.round(
|
|
4433
|
+
}), c = U(c, ks(S, M, e.hasSubagent)), c = W(c, Math.round(ce.contextWindow * .6)), z("llm_request", {
|
|
4434
4434
|
round: S + 1,
|
|
4435
4435
|
model: ye(),
|
|
4436
4436
|
tools: ge.map((e) => e.name),
|
|
@@ -4509,7 +4509,7 @@ function Ms(e) {
|
|
|
4509
4509
|
turnUsage: f,
|
|
4510
4510
|
isWriteToolByName: x,
|
|
4511
4511
|
messages: c,
|
|
4512
|
-
sessionWritePaths:
|
|
4512
|
+
sessionWritePaths: R,
|
|
4513
4513
|
todosStatusAtStart: g,
|
|
4514
4514
|
pageGate: e.pageAssertionGate === !0,
|
|
4515
4515
|
pageReadTools: e.pageReadTools,
|
|
@@ -4517,7 +4517,7 @@ function Ms(e) {
|
|
|
4517
4517
|
});
|
|
4518
4518
|
if (a?.kind === "feedback") {
|
|
4519
4519
|
O = !0;
|
|
4520
|
-
let e =
|
|
4520
|
+
let e = de[a.gate.stage];
|
|
4521
4521
|
e && (e.retries += 1), z("middleware", {
|
|
4522
4522
|
stage: a.gate.stage,
|
|
4523
4523
|
attempt: a.gate.attempt,
|
|
@@ -4527,8 +4527,8 @@ function Ms(e) {
|
|
|
4527
4527
|
continue;
|
|
4528
4528
|
}
|
|
4529
4529
|
if (a?.kind === "observable") {
|
|
4530
|
-
let e =
|
|
4531
|
-
e &&
|
|
4530
|
+
let e = fe[a.obs.code];
|
|
4531
|
+
e && de[e] && (de[e].exhausted += 1), z("error", {
|
|
4532
4532
|
stage: a.obs.code,
|
|
4533
4533
|
...a.obs.context,
|
|
4534
4534
|
content: t.content.slice(0, 160)
|
|
@@ -4675,7 +4675,7 @@ function Ms(e) {
|
|
|
4675
4675
|
args: p[e].call.args,
|
|
4676
4676
|
callIndex: e
|
|
4677
4677
|
});
|
|
4678
|
-
if (r) for (let e of r.paths)
|
|
4678
|
+
if (r) for (let e of r.paths) R.add(e);
|
|
4679
4679
|
}
|
|
4680
4680
|
}
|
|
4681
4681
|
if (j && y.length) {
|
|
@@ -4683,7 +4683,7 @@ function Ms(e) {
|
|
|
4683
4683
|
round: S + 1,
|
|
4684
4684
|
maxParallelTools: k
|
|
4685
4685
|
});
|
|
4686
|
-
e.invalidatedCount > 0 && (c = e.messages,
|
|
4686
|
+
e.invalidatedCount > 0 && (c = e.messages, L += e.invalidatedCount, z("middleware", {
|
|
4687
4687
|
stage: "stale_read_invalidated",
|
|
4688
4688
|
round: S + 1,
|
|
4689
4689
|
writtenPaths: y.map((e) => js(e.args) || "(整体)"),
|
|
@@ -4716,9 +4716,9 @@ function Ms(e) {
|
|
|
4716
4716
|
maxIterations: w
|
|
4717
4717
|
}
|
|
4718
4718
|
});
|
|
4719
|
-
let te = is(V.todos ?? [], g,
|
|
4719
|
+
let te = is(V.todos ?? [], g, R);
|
|
4720
4720
|
if (te.length) {
|
|
4721
|
-
|
|
4721
|
+
de.evidence_audit_gate.exhausted += 1;
|
|
4722
4722
|
let e = te.map((e) => ({
|
|
4723
4723
|
id: e.id,
|
|
4724
4724
|
evidence: e.evidence
|
|
@@ -4815,19 +4815,19 @@ function Ms(e) {
|
|
|
4815
4815
|
get allTools() {
|
|
4816
4816
|
return ge;
|
|
4817
4817
|
},
|
|
4818
|
-
getStaleReadsInvalidated: () =>
|
|
4819
|
-
getLlmRetries: () =>
|
|
4820
|
-
getLlmCallFailures: () =>
|
|
4821
|
-
getGateStats: () =>
|
|
4822
|
-
getLastSystemSegments: () =>
|
|
4818
|
+
getStaleReadsInvalidated: () => L,
|
|
4819
|
+
getLlmRetries: () => me,
|
|
4820
|
+
getLlmCallFailures: () => he,
|
|
4821
|
+
getGateStats: () => de,
|
|
4822
|
+
getLastSystemSegments: () => pe,
|
|
4823
4823
|
resetSessionCounters: () => {
|
|
4824
|
-
|
|
4825
|
-
for (let e of Object.keys(
|
|
4824
|
+
L = 0, me = 0, he = 0;
|
|
4825
|
+
for (let e of Object.keys(de)) de[e] = ue();
|
|
4826
4826
|
},
|
|
4827
4827
|
setTools: Ae,
|
|
4828
4828
|
setLlm: je,
|
|
4829
|
-
setModelCaps:
|
|
4830
|
-
debugLogs:
|
|
4829
|
+
setModelCaps: le,
|
|
4830
|
+
debugLogs: I,
|
|
4831
4831
|
getEffectiveSystemPrompt: () => Se()
|
|
4832
4832
|
};
|
|
4833
4833
|
}
|
|
@@ -5309,6 +5309,36 @@ var dc = {
|
|
|
5309
5309
|
"5. Prefer incremental write patches (send only the change, e.g. write({ value, patch:{ op, jsonPath } })) over resending the whole large JSON, which risks truncation;",
|
|
5310
5310
|
"6. If a write hits an optimistic-lock conflict (VERSION_CONFLICT returned, or the tool suspends awaiting the user decision): after the tool returns, follow its instruction (keep external → re-read then edit; overwritten/restored → continue from the result); do not abandon the task."
|
|
5311
5311
|
].join("\n"),
|
|
5312
|
+
answerLanes: [
|
|
5313
|
+
"【作答车道:先判问题形态,再选纪律】",
|
|
5314
|
+
"用户的问题分三类,判错车道是最大的答非所问:",
|
|
5315
|
+
"A. 问页面内容(「这页写了什么 / 哪里提到 / 原文是什么 / 这段在说什么」)",
|
|
5316
|
+
" → 以页面实料为准并点明出处;页面内容与你的先验知识冲突时以页面为准;页面没写就说没写,一句话即可,不列举查过哪些节。",
|
|
5317
|
+
"B. 问概念术语(「X 是什么 / 啥意思 / X 和 Y 什么区别」)",
|
|
5318
|
+
" → 页面有语境就先按页面语境讲;页面没有也必须直接用自己的知识解释,",
|
|
5319
|
+
" 开头一句「本页未提及,以下是通用解释:」即可 —— 不许把「页面上没有」当答案。",
|
|
5320
|
+
"C. 求观点经验(「你觉得呢 / 按你的经验 / 是不是很难 / 该怎么选」)",
|
|
5321
|
+
" → 直接给判断和理由;笔记口径与个人观点分开说(「本页的立场是…;我的看法是…」)。",
|
|
5322
|
+
" 页面没写不构成不答的理由。",
|
|
5323
|
+
"",
|
|
5324
|
+
"出处密度:只有「对页面内容的断言」才标出处(句末括注即可);概念解释、个人观点、",
|
|
5325
|
+
"过渡句一律不标。「没找到」的说明压成一句,不报检索过程。"
|
|
5326
|
+
].join("\n"),
|
|
5327
|
+
answerLanesEn: [
|
|
5328
|
+
"[Answer lanes: classify the question first, then pick the discipline]",
|
|
5329
|
+
"User questions fall into three categories; picking the wrong lane is the biggest way to miss the point:",
|
|
5330
|
+
"A. Asking about page content (\"what does this page say / where is it mentioned / what is the original text / what does this passage mean\")",
|
|
5331
|
+
" → Ground answers in what the page actually says and cite where it came from; when the page conflicts with your prior knowledge, the page wins; if the page does not say it, say so in one sentence — do not enumerate which sections you searched.",
|
|
5332
|
+
"B. Asking about a concept or term (\"what is X / what does it mean / how do X and Y differ\")",
|
|
5333
|
+
" → If the page has context for it, explain in that context first; if the page does not, you MUST still explain it directly from your own knowledge,",
|
|
5334
|
+
" opening with one line like \"Not covered on this page — general explanation:\" — never treat \"it is not on the page\" as the answer.",
|
|
5335
|
+
"C. Asking for your opinion or experience (\"what do you think / in your experience / is it hard to match / which should I choose\")",
|
|
5336
|
+
" → Give your judgment and reasoning directly; keep the notes' stance and your own view separate (\"this page's position is ...; my take is ...\").",
|
|
5337
|
+
" The page not covering it is never a reason to refuse.",
|
|
5338
|
+
"",
|
|
5339
|
+
"Citation density: only claims about page content get a citation (a short parenthetical); concept explanations,",
|
|
5340
|
+
"personal opinions, and transitions get none. Compress \"not found\" statements to one sentence; never narrate the search process."
|
|
5341
|
+
].join("\n"),
|
|
5312
5342
|
htmlPageOrchestrator: uc("html"),
|
|
5313
5343
|
htmlPageProposeFirst: ["【新建/创意类请求】先用简短文字给出 2~3 套方案(每套一两句风格/配色/结构要点),询问用户选哪套;选定前不要委派生成代码、不要写 components。", "【方案切换】已生成某套方案后改选另一套:不重新罗列,直接依据之前描述重新委派生成并覆盖相应组件(委派工具见编排段 use_<id>)。"].join("\n"),
|
|
5314
5344
|
htmlDirectWriteFallback: [
|
|
@@ -7827,14 +7857,14 @@ var cd = [
|
|
|
7827
7857
|
"你是一个页面内容助手,帮助用户理解、查找与排查其当前所在的网页。",
|
|
7828
7858
|
"你可以经专用工具探查页面:read_page 读页面正文(长文按 hasMore 分页续读)、get_dom 读渲染后结构、dom_search / dom_info 定位元素与查属性" + (e ? "、take_screenshot 截图查看实际渲染效果(视觉问题优先截图,结构推断不能代替)" : "") + ";一切以工具读到的页面实料为准。",
|
|
7829
7859
|
"用户消息可能带 [引用原文] 块(其在页面上选中的文字):优先围绕引用内容作答,需要更多上下文再向外探索(所在小节 → 整页)。",
|
|
7830
|
-
|
|
7860
|
+
dc.answerLanes,
|
|
7831
7861
|
"输出从简:直接说内容,不写过程 —— 不要「我先读一下页面」这类旁白、不要「先给结论/依据是」这类包装、不要解释结论是怎么推出来的、不要「下面分三点/综上」这类套话;出处用句末括注(如「(§小节名)」)带过即可。",
|
|
7832
7862
|
ud
|
|
7833
7863
|
].join("\n"), pd = (e) => [
|
|
7834
7864
|
"You are a page content assistant that helps users understand, locate, and troubleshoot the web page they are on.",
|
|
7835
7865
|
"You can inspect the page through dedicated tools: read_page for page text (paginate via hasMore on long documents), get_dom for the rendered structure, dom_search / dom_info to locate elements and read attributes" + (e ? ", and take_screenshot to see the actual rendered appearance (prefer a screenshot for visual questions; structural inference is no substitute)" : "") + "; the page as read by tools is the source of truth.",
|
|
7836
7866
|
"User messages may carry a [quoted text] block (text they selected on the page): answer around the quote first, then explore outward (its section → the whole page) if more context is needed.",
|
|
7837
|
-
|
|
7867
|
+
dc.answerLanesEn,
|
|
7838
7868
|
"Be terse: state the content directly, never narrate process — no \"let me first read the page\" asides, no \"in summary / the evidence is\" packaging, no explaining how you derived the conclusion, no \"here are three points\" preambles; cite sources inline as a short parenthetical such as \"(§ section name)\".",
|
|
7839
7869
|
dd,
|
|
7840
7870
|
"Respond in English."
|
|
@@ -9448,7 +9478,7 @@ function hf(e, n = {}) {
|
|
|
9448
9478
|
}, M = (e) => {
|
|
9449
9479
|
n.onAudit?.(e);
|
|
9450
9480
|
};
|
|
9451
|
-
function
|
|
9481
|
+
function ce(e, t) {
|
|
9452
9482
|
let n = Oc(l()), r = g.length ? g[g.length - 1].id + 1 : 1;
|
|
9453
9483
|
for (g.push({
|
|
9454
9484
|
id: r,
|
|
@@ -9459,7 +9489,7 @@ function hf(e, n = {}) {
|
|
|
9459
9489
|
}); g.length > _;) g.shift();
|
|
9460
9490
|
return r;
|
|
9461
9491
|
}
|
|
9462
|
-
async function
|
|
9492
|
+
async function N(e, t, r, i, a) {
|
|
9463
9493
|
if (!t || t === "") return null;
|
|
9464
9494
|
let o = k();
|
|
9465
9495
|
if (o === t) return null;
|
|
@@ -9513,9 +9543,9 @@ function hf(e, n = {}) {
|
|
|
9513
9543
|
hint: "重新 read 拿最新值与 hash,基于最新值修改后再写入(单次校验,不再二次挂起)。"
|
|
9514
9544
|
}));
|
|
9515
9545
|
}
|
|
9516
|
-
let
|
|
9546
|
+
let P = (e, t = !0) => {
|
|
9517
9547
|
e.writeCapable = t;
|
|
9518
|
-
},
|
|
9548
|
+
}, F = s(async ({ id: e }, t) => {
|
|
9519
9549
|
let n = b(t), r = await re();
|
|
9520
9550
|
try {
|
|
9521
9551
|
if (!g.length) return Z({
|
|
@@ -9591,8 +9621,8 @@ function hf(e, n = {}) {
|
|
|
9591
9621
|
description: "把主数据回退到某个快照(不传 id 回退最近一次)。快照列表用 history_data({list:true})。",
|
|
9592
9622
|
schema: t.object({ id: t.number().int().optional().describe("快照序号;不传回退最近一次") })
|
|
9593
9623
|
});
|
|
9594
|
-
F
|
|
9595
|
-
let
|
|
9624
|
+
P(F);
|
|
9625
|
+
let le = s(async ({ id: e, jsonPath: t, list: n }) => {
|
|
9596
9626
|
if (n) {
|
|
9597
9627
|
if (!g.length) return "无快照。set/edit/delete 会自动存快照。";
|
|
9598
9628
|
let e = g.map((e) => {
|
|
@@ -9637,7 +9667,7 @@ function hf(e, n = {}) {
|
|
|
9637
9667
|
jsonPath: t.string().optional().describe("只看快照的某子路径"),
|
|
9638
9668
|
list: t.boolean().optional().describe("true 列出快照时间线(序号/操作/标签/时间/大小)")
|
|
9639
9669
|
})
|
|
9640
|
-
}),
|
|
9670
|
+
}), I = s(async ({ expr: e, queries: t, limit: n }, r) => {
|
|
9641
9671
|
let i = b(r);
|
|
9642
9672
|
if (typeof c != "object" || !c) return Z({
|
|
9643
9673
|
code: "NOT_OBJECT",
|
|
@@ -9680,7 +9710,7 @@ function hf(e, n = {}) {
|
|
|
9680
9710
|
queries: t.array(t.string()).min(2).max(10).optional().describe("批量模式:2-10 条 JSONPath 一次取回(与 expr 同传按 queries);逐条独立返回,单条失败该项标 error 不整批"),
|
|
9681
9711
|
limit: t.number().int().min(1).max(200).optional().describe("返回结果上限(批量时逐条适用),默认 50")
|
|
9682
9712
|
})
|
|
9683
|
-
}),
|
|
9713
|
+
}), L = s(async ({ query: e, mode: t, fuzzyThreshold: n, matchKey: r, limit: i }) => {
|
|
9684
9714
|
if (c == null) return Z({
|
|
9685
9715
|
code: "EMPTY",
|
|
9686
9716
|
message: "主数据为空,无可搜索内容"
|
|
@@ -9718,7 +9748,7 @@ function hf(e, n = {}) {
|
|
|
9718
9748
|
matchKey: t.boolean().optional().describe("是否同时匹配 key 名,默认 true"),
|
|
9719
9749
|
limit: t.number().int().min(1).max(200).optional().describe("返回上限,默认 50")
|
|
9720
9750
|
})
|
|
9721
|
-
}),
|
|
9751
|
+
}), ue = s(async ({ script: e, mode: t, jsonPath: n }, r) => {
|
|
9722
9752
|
let s = b(r);
|
|
9723
9753
|
if (e.length > 8e3) return Z({
|
|
9724
9754
|
code: "SCRIPT_TOO_LARGE",
|
|
@@ -9761,7 +9791,7 @@ function hf(e, n = {}) {
|
|
|
9761
9791
|
if (u) {
|
|
9762
9792
|
let e = await re();
|
|
9763
9793
|
try {
|
|
9764
|
-
let n = await
|
|
9794
|
+
let n = await N("edit", O ? w(s) : void 0, void 0, e, s);
|
|
9765
9795
|
if (n !== null) return n;
|
|
9766
9796
|
let r = rf({
|
|
9767
9797
|
bindRef: c,
|
|
@@ -9797,7 +9827,7 @@ function hf(e, n = {}) {
|
|
|
9797
9827
|
});
|
|
9798
9828
|
let e = await re();
|
|
9799
9829
|
try {
|
|
9800
|
-
let n = await
|
|
9830
|
+
let n = await N("edit", O ? w(s) : void 0, void 0, e, s);
|
|
9801
9831
|
if (n !== null) return n;
|
|
9802
9832
|
let r = rf({
|
|
9803
9833
|
bindRef: c,
|
|
@@ -9838,7 +9868,7 @@ function hf(e, n = {}) {
|
|
|
9838
9868
|
});
|
|
9839
9869
|
let i = await re();
|
|
9840
9870
|
try {
|
|
9841
|
-
let e = await
|
|
9871
|
+
let e = await N("set", O ? w(s) : void 0, n, i, s);
|
|
9842
9872
|
if (e !== null) return e;
|
|
9843
9873
|
let t = a ? Oc(l()) : null, r = ef({
|
|
9844
9874
|
schema: o,
|
|
@@ -9846,7 +9876,7 @@ function hf(e, n = {}) {
|
|
|
9846
9876
|
value: n,
|
|
9847
9877
|
bindRef: c
|
|
9848
9878
|
});
|
|
9849
|
-
return r.ok ? (
|
|
9879
|
+
return r.ok ? (ce("edit", "eval_transform"), r.wholeParsed ? Vc(c, r.assembly) : r.assembly !== null && typeof r.assembly == "object" && Tc(c, r.assembly), j(), a && (a(c, t), j()), M({
|
|
9850
9880
|
op: "edit",
|
|
9851
9881
|
detail: "eval_transform",
|
|
9852
9882
|
timestamp: Date.now()
|
|
@@ -9874,8 +9904,8 @@ function hf(e, n = {}) {
|
|
|
9874
9904
|
jsonPath: t.string().optional().describe("子树模式:仅对该子树执行;transform 返回值作为子树新值")
|
|
9875
9905
|
})
|
|
9876
9906
|
});
|
|
9877
|
-
|
|
9878
|
-
let
|
|
9907
|
+
P(ue, (e) => e?.mode === "transform");
|
|
9908
|
+
let de = s(async ({ jsonPath: e, jsonPaths: t, fields: n, depth: r, offset: i, limit: a }, s) => {
|
|
9879
9909
|
let c = b(s), f = x(s), p = l(), m, g = () => m ??= k();
|
|
9880
9910
|
if (t && t.length) {
|
|
9881
9911
|
let e = !1, i = t.map((t) => {
|
|
@@ -9965,7 +9995,7 @@ function hf(e, n = {}) {
|
|
|
9965
9995
|
offset: t.number().int().min(0).optional().describe("数组分页起始偏移(仅数组目标,默认 0)"),
|
|
9966
9996
|
limit: t.number().int().min(1).max(200).optional().describe("数组分页每页条数(默认 50,上限 200),返回切片+total/hasMore")
|
|
9967
9997
|
})
|
|
9968
|
-
}),
|
|
9998
|
+
}), fe = s(async ({ value: e, patch: t, patches: n, del: i, dryRun: s }, u) => {
|
|
9969
9999
|
let f = b(u), p = "set";
|
|
9970
10000
|
i ? p = "delete" : (n && n.length || t) && (p = "edit");
|
|
9971
10001
|
let m = t?.value === void 0 ? e : t.value, v = await re();
|
|
@@ -10003,13 +10033,13 @@ function hf(e, n = {}) {
|
|
|
10003
10033
|
hint: e.spec.mode === "freeze" ? "冻结字段不可删" : "verbatim 字段不可直接删;先 resource_delete 释放"
|
|
10004
10034
|
});
|
|
10005
10035
|
}
|
|
10006
|
-
let n = await
|
|
10036
|
+
let n = await N("delete", e, void 0, v, f);
|
|
10007
10037
|
if (n !== null) return n;
|
|
10008
10038
|
if (s) {
|
|
10009
10039
|
let e = Oc(l());
|
|
10010
10040
|
return Dc(e, t.jsonPath) ? `dryRun(delete): 将删除 @ ${t.jsonPath}。预览剩余:${$(e, 600)}。未实际写入、未入快照。` : `dryRun(delete): @ ${t.jsonPath} 不存在(无需删除)。未实际写入。`;
|
|
10011
10041
|
}
|
|
10012
|
-
|
|
10042
|
+
ce("delete");
|
|
10013
10043
|
let r = Dc(c, t.jsonPath);
|
|
10014
10044
|
return j(), M({
|
|
10015
10045
|
op: "delete",
|
|
@@ -10023,7 +10053,7 @@ function hf(e, n = {}) {
|
|
|
10023
10053
|
message: `edit 仅适用于对象/数组主数据,当前是 ${c === void 0 ? "undefined" : typeof c}`,
|
|
10024
10054
|
hint: "叶子用 write(value) 整体设置"
|
|
10025
10055
|
});
|
|
10026
|
-
let r = await
|
|
10056
|
+
let r = await N("edit", e, void 0, v, f);
|
|
10027
10057
|
if (r !== null) return r;
|
|
10028
10058
|
let i = n && n.length ? n : [{
|
|
10029
10059
|
op: t.op ?? "set",
|
|
@@ -10055,7 +10085,7 @@ function hf(e, n = {}) {
|
|
|
10055
10085
|
}
|
|
10056
10086
|
let i = Ac(m);
|
|
10057
10087
|
if (i.parseError) return ci("", m, i.parseError);
|
|
10058
|
-
let u = await
|
|
10088
|
+
let u = await N("set", e, m, v, f);
|
|
10059
10089
|
if (u !== null) return u;
|
|
10060
10090
|
let y = nf({
|
|
10061
10091
|
bindRef: c,
|
|
@@ -10111,8 +10141,8 @@ function hf(e, n = {}) {
|
|
|
10111
10141
|
dryRun: t.boolean().optional().describe("预检:走完整校验链但不落盘不入快照;冲突返回 VERSION_CONFLICT 不挂起")
|
|
10112
10142
|
})
|
|
10113
10143
|
});
|
|
10114
|
-
|
|
10115
|
-
let
|
|
10144
|
+
P(fe);
|
|
10145
|
+
let pe = s(async ({ jsonPath: e }) => {
|
|
10116
10146
|
let t = e || "", n = t ? Is(o, t) : o;
|
|
10117
10147
|
return n ? `schema${t ? ` @ ${t}` : ""} = ${$(nc(n))}` : Z({
|
|
10118
10148
|
code: "PATH_DENIED",
|
|
@@ -10123,7 +10153,7 @@ function hf(e, n = {}) {
|
|
|
10123
10153
|
name: "schema_data",
|
|
10124
10154
|
description: "查看主数据(或子路径)的字段约束:类型/min/max/enum/必填/默认值/嵌套 shape。写前查约束,避免写错重试。不传 jsonPath 查根;传子路径(如 components.0)查该位置约束。",
|
|
10125
10155
|
schema: t.object({ jsonPath: t.string().optional().describe("要查约束的子路径;不传查根 schema") })
|
|
10126
|
-
}),
|
|
10156
|
+
}), me = s(async ({ snapshotId: e, against: t }) => {
|
|
10127
10157
|
let n = t != null, r, i;
|
|
10128
10158
|
if (n) {
|
|
10129
10159
|
let e = t;
|
|
@@ -10155,7 +10185,7 @@ function hf(e, n = {}) {
|
|
|
10155
10185
|
snapshotId: t.number().int().optional().describe("对比的快照序号;不传则最近一次"),
|
|
10156
10186
|
against: t.unknown().optional().describe("对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)")
|
|
10157
10187
|
})
|
|
10158
|
-
}),
|
|
10188
|
+
}), he = [];
|
|
10159
10189
|
if (n.vfsStore) {
|
|
10160
10190
|
let e = n.vfsStore, r = (e) => `drafts/${e}.json`, i = s(({ draftId: t, chunk: n, mode: i }) => {
|
|
10161
10191
|
let a = r(t), o = e.files[a], s = i === "append" && o, c = s ? o.content + n : n;
|
|
@@ -10198,7 +10228,7 @@ function hf(e, n = {}) {
|
|
|
10198
10228
|
}
|
|
10199
10229
|
let f = await re();
|
|
10200
10230
|
try {
|
|
10201
|
-
let n = await
|
|
10231
|
+
let n = await N("set", O ? w(i) : void 0, u, f, i);
|
|
10202
10232
|
if (n !== null) return n;
|
|
10203
10233
|
let r = nf({
|
|
10204
10234
|
bindRef: c,
|
|
@@ -10223,9 +10253,9 @@ function hf(e, n = {}) {
|
|
|
10223
10253
|
description: "把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。",
|
|
10224
10254
|
schema: t.object({ draftId: t.string().describe("要提交的草稿标识(对应 draft_write 的 draftId)") })
|
|
10225
10255
|
});
|
|
10226
|
-
|
|
10256
|
+
P(l), he.push(i, l);
|
|
10227
10257
|
}
|
|
10228
|
-
let
|
|
10258
|
+
let R = [];
|
|
10229
10259
|
if (e.resources?.length && p) {
|
|
10230
10260
|
let e = s(async ({ path: e, handle: t }) => {
|
|
10231
10261
|
let n = e;
|
|
@@ -10311,7 +10341,7 @@ function hf(e, n = {}) {
|
|
|
10311
10341
|
value: t.unknown().describe("新值(需符合字段 schema 类型)")
|
|
10312
10342
|
})
|
|
10313
10343
|
});
|
|
10314
|
-
|
|
10344
|
+
P(n);
|
|
10315
10345
|
let r = s(async () => {
|
|
10316
10346
|
let e = p.list();
|
|
10317
10347
|
if (!e.length) {
|
|
@@ -10342,20 +10372,20 @@ function hf(e, n = {}) {
|
|
|
10342
10372
|
handle: t.string().optional().describe("占位符句柄(与 path 二选一)")
|
|
10343
10373
|
})
|
|
10344
10374
|
});
|
|
10345
|
-
|
|
10375
|
+
P(i), R.push(e, n, r, i);
|
|
10346
10376
|
}
|
|
10347
10377
|
let z = [
|
|
10378
|
+
F,
|
|
10379
|
+
le,
|
|
10348
10380
|
I,
|
|
10349
|
-
ce,
|
|
10350
10381
|
L,
|
|
10351
|
-
R,
|
|
10352
|
-
le,
|
|
10353
10382
|
ue,
|
|
10354
10383
|
de,
|
|
10355
10384
|
fe,
|
|
10356
10385
|
pe,
|
|
10357
|
-
|
|
10358
|
-
...he
|
|
10386
|
+
me,
|
|
10387
|
+
...he,
|
|
10388
|
+
...R
|
|
10359
10389
|
];
|
|
10360
10390
|
function B(e) {
|
|
10361
10391
|
let t = e, n = (e) => {
|
|
@@ -13472,11 +13502,18 @@ function tg(e) {
|
|
|
13472
13502
|
return `[data-path="${String(e ?? "").replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"]`;
|
|
13473
13503
|
}
|
|
13474
13504
|
function ng(e) {
|
|
13505
|
+
try {
|
|
13506
|
+
return !e || typeof e.querySelectorAll != "function" ? 0 : e.querySelectorAll("iframe").length;
|
|
13507
|
+
} catch {
|
|
13508
|
+
return 0;
|
|
13509
|
+
}
|
|
13510
|
+
}
|
|
13511
|
+
function rg(e) {
|
|
13475
13512
|
let [t, n] = e.split(",", 2), r = /:(.*?);/.exec(t)?.[1] ?? "image/png", i = atob(n ?? ""), a = new Uint8Array(i.length);
|
|
13476
13513
|
for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
|
|
13477
13514
|
return new Blob([a], { type: r });
|
|
13478
13515
|
}
|
|
13479
|
-
function
|
|
13516
|
+
function ig(e, t, n) {
|
|
13480
13517
|
if (n.selector) {
|
|
13481
13518
|
let t = null;
|
|
13482
13519
|
try {
|
|
@@ -13502,7 +13539,7 @@ function rg(e, t, n) {
|
|
|
13502
13539
|
height: i
|
|
13503
13540
|
};
|
|
13504
13541
|
}
|
|
13505
|
-
function
|
|
13542
|
+
function ag(e) {
|
|
13506
13543
|
let n = e.render ?? eg;
|
|
13507
13544
|
return s(async (t) => {
|
|
13508
13545
|
if (typeof document > "u") return "ERROR: take_screenshot 仅在浏览器环境可用(当前运行在 node/服务端,无 DOM)。";
|
|
@@ -13522,52 +13559,52 @@ function ig(e) {
|
|
|
13522
13559
|
}, r = `(取景=聚焦组件 ${n.path},data-path 锚定)`) : r = `(当前聚焦 ${n.path},但未在 DOM 找到对应锚点,已回退视口;要精确截取可传 selector)`;
|
|
13523
13560
|
}
|
|
13524
13561
|
}
|
|
13525
|
-
let a =
|
|
13562
|
+
let a = ig(document, typeof window < "u" ? window : {}, i);
|
|
13526
13563
|
if (!a.ok) return `ERROR: ${a.error}`;
|
|
13527
|
-
let o = a.el ?? e.getRootEl?.() ?? document.documentElement, s = {
|
|
13564
|
+
let o = a.el ?? e.getRootEl?.() ?? document.documentElement, s = ng(o), c = s > 0 ? `⚠️ 取景范围内含 ${s} 个 iframe:跨 frame 内容(如代码组件沙箱)截图捕获不到,图里只会是其外壳/空白区域 —— 验证 iframe 内部请走数据侧核对(read/validate_code/get_dom),勿再对同一区域重复截图。` : "", l = {
|
|
13528
13565
|
width: a.width,
|
|
13529
13566
|
height: a.height
|
|
13530
13567
|
};
|
|
13531
13568
|
if (a.mode === "fullPage") {
|
|
13532
13569
|
let e = Math.max(document.documentElement?.scrollHeight ?? 0, document.body?.scrollHeight ?? 0);
|
|
13533
13570
|
if (e > 32768) return `ERROR: 整页高度 ${e}px 超上限 ${$h}(超长文档渲染会卡死页面)。请改用 selector 分段截取关键区域。`;
|
|
13534
|
-
|
|
13571
|
+
l = {
|
|
13535
13572
|
width: a.width,
|
|
13536
13573
|
height: e
|
|
13537
13574
|
};
|
|
13538
13575
|
}
|
|
13539
|
-
let
|
|
13576
|
+
let u;
|
|
13540
13577
|
try {
|
|
13541
|
-
|
|
13578
|
+
u = await n(o, l);
|
|
13542
13579
|
} catch (e) {
|
|
13543
|
-
return `ERROR: 截图渲染失败(${e instanceof Error ? e.message : String(e)})${r}.常见原因:宿主页面 CSP 禁止 SVG data URL / 跨域图片污染画布 / 元素含无法克隆的内容。建议:① 改用 selector 缩小到目标区域;② 结构验证可改用 get_dom / dom_info(rect+styles);③ 宿主可配 screenshot.renderer
|
|
13580
|
+
return `ERROR: 截图渲染失败(${e instanceof Error ? e.message : String(e)})${r}.常见原因:宿主页面 CSP 禁止 SVG data URL / 跨域图片污染画布 / 元素含无法克隆的内容。建议:① 改用 selector 缩小到目标区域;② 结构验证可改用 get_dom / dom_info(rect+styles);③ 宿主可配 screenshot.renderer 自定义渲染器绕过。${c}`;
|
|
13544
13581
|
}
|
|
13545
|
-
let
|
|
13582
|
+
let d;
|
|
13546
13583
|
try {
|
|
13547
|
-
|
|
13584
|
+
d = await Ei(rg(u), { name: `screenshot-${a.mode}.png` });
|
|
13548
13585
|
} catch (e) {
|
|
13549
|
-
return `ERROR: 截图压缩失败(${e instanceof Error ? e.message : String(e)})
|
|
13586
|
+
return `ERROR: 截图压缩失败(${e instanceof Error ? e.message : String(e)}),未投递。${c}`;
|
|
13550
13587
|
}
|
|
13551
|
-
let
|
|
13588
|
+
let f = e.stow?.(d), p = {
|
|
13552
13589
|
mode: a.mode,
|
|
13553
13590
|
...i.selector ? { selector: i.selector } : {}
|
|
13554
|
-
},
|
|
13555
|
-
|
|
13556
|
-
let
|
|
13557
|
-
if (!
|
|
13591
|
+
}, m = e.getVision();
|
|
13592
|
+
m && e.onShot?.(d, p);
|
|
13593
|
+
let h;
|
|
13594
|
+
if (!m) {
|
|
13558
13595
|
if (!e.describe) return "ERROR: 截图已生成但主模型不支持图片(vision=false)且未配置 images.describe,无处投递。请换多模态模型 / LLMConfig.vision:true / 配置 images.describe(集成方识图旁路)。";
|
|
13559
13596
|
try {
|
|
13560
|
-
|
|
13597
|
+
h = await e.describe(d, { text: `页面截图(${a.mode}${t.selector ? ` ${t.selector}` : ""})` });
|
|
13561
13598
|
} catch {
|
|
13562
|
-
|
|
13599
|
+
h = void 0;
|
|
13563
13600
|
}
|
|
13564
13601
|
}
|
|
13565
|
-
let
|
|
13566
|
-
`截图完成(${a.mode}${i.selector ? ` selector="${i.selector}"` : ""}):${
|
|
13567
|
-
|
|
13568
|
-
`投递形态:${
|
|
13602
|
+
let g = m ? "vision-image(随后的图片消息)" : h ? "describe-text(转述如下)" : "none", _ = [
|
|
13603
|
+
`截图完成(${a.mode}${i.selector ? ` selector="${i.selector}"` : ""}):${d.width}x${d.height},${Math.round((d.bytes ?? 0) / 1024)}KB(jpeg 压缩后)${r}`,
|
|
13604
|
+
f ? `原图已存 vfs:${f}` : "vfs 未开启,原图仅本轮内存",
|
|
13605
|
+
`投递形态:${g}`
|
|
13569
13606
|
];
|
|
13570
|
-
return
|
|
13607
|
+
return c && _.push(c), h && _.push(`识图转述:${h}`), _.join("\n");
|
|
13571
13608
|
}, {
|
|
13572
13609
|
name: "take_screenshot",
|
|
13573
13610
|
description: "截取当前页面图像查看(视觉验证:布局/样式/渲染效果)。聚焦态下**不传 selector 默认截取聚焦组件**(宿主 data-path 锚定 —— 指代问句「这是啥/这里画的是啥」优先此取景,整页截图仅在用户明确要求时用)。selector 截取指定元素区域;fullPage 截整页(超长文档会被拒,改用 selector 分段);都不传且无聚焦截当前视口。只读;截图经压缩后投递(多模态主模型直看图,纯文本模型自动走识图转述)。",
|
|
@@ -13577,7 +13614,7 @@ function ig(e) {
|
|
|
13577
13614
|
})
|
|
13578
13615
|
});
|
|
13579
13616
|
}
|
|
13580
|
-
async function
|
|
13617
|
+
async function og(e) {
|
|
13581
13618
|
if (typeof FileReader < "u") return new Promise((t, n) => {
|
|
13582
13619
|
let r = new FileReader();
|
|
13583
13620
|
r.onload = () => t(String(r.result)), r.onerror = () => n(/* @__PURE__ */ Error("FileReader 读取失败")), r.readAsDataURL(e);
|
|
@@ -13586,7 +13623,7 @@ async function ag(e) {
|
|
|
13586
13623
|
for (let e = 0; e < t.length; e += 8192) n += String.fromCharCode(...t.subarray(e, e + 8192));
|
|
13587
13624
|
return `data:${e.type || "image/png"};base64,${btoa(n)}`;
|
|
13588
13625
|
}
|
|
13589
|
-
function
|
|
13626
|
+
function sg(e) {
|
|
13590
13627
|
let n = e.clientFetch ?? (async (e) => {
|
|
13591
13628
|
try {
|
|
13592
13629
|
return await fetch(e, { mode: "cors" });
|
|
@@ -13602,7 +13639,7 @@ function og(e) {
|
|
|
13602
13639
|
let e = await n(r);
|
|
13603
13640
|
if (e?.ok) {
|
|
13604
13641
|
let t = await e.blob();
|
|
13605
|
-
t.size > 0 && t.size <= 20 * 1024 * 1024 && String(t.type).startsWith("image/") && (i = await
|
|
13642
|
+
t.size > 0 && t.size <= 20 * 1024 * 1024 && String(t.type).startsWith("image/") && (i = await og(t));
|
|
13606
13643
|
}
|
|
13607
13644
|
} catch {}
|
|
13608
13645
|
let a = {
|
|
@@ -13626,13 +13663,13 @@ function og(e) {
|
|
|
13626
13663
|
}
|
|
13627
13664
|
//#endregion
|
|
13628
13665
|
//#region src/core/tools/domEdit.ts
|
|
13629
|
-
var
|
|
13666
|
+
var cg = "data-pg-snap", lg = 20, ug = 256 * 1024, dg = t.enum([
|
|
13630
13667
|
"before",
|
|
13631
13668
|
"after",
|
|
13632
13669
|
"prepend",
|
|
13633
13670
|
"append",
|
|
13634
13671
|
"replace"
|
|
13635
|
-
]),
|
|
13672
|
+
]), fg = /* @__PURE__ */ new Set([
|
|
13636
13673
|
"script",
|
|
13637
13674
|
"iframe",
|
|
13638
13675
|
"object",
|
|
@@ -13640,7 +13677,7 @@ var sg = "data-pg-snap", cg = 20, lg = 256 * 1024, ug = t.enum([
|
|
|
13640
13677
|
"link",
|
|
13641
13678
|
"meta",
|
|
13642
13679
|
"base"
|
|
13643
|
-
]),
|
|
13680
|
+
]), pg = /^on\w+$/i, mg = /* @__PURE__ */ new Set([
|
|
13644
13681
|
"href",
|
|
13645
13682
|
"src",
|
|
13646
13683
|
"action",
|
|
@@ -13648,22 +13685,22 @@ var sg = "data-pg-snap", cg = 20, lg = 256 * 1024, ug = t.enum([
|
|
|
13648
13685
|
"xlink:href",
|
|
13649
13686
|
"data"
|
|
13650
13687
|
]);
|
|
13651
|
-
function
|
|
13688
|
+
function hg(e) {
|
|
13652
13689
|
return /^\s*(javascript|vbscript)\s*:/i.test(e);
|
|
13653
13690
|
}
|
|
13654
|
-
function
|
|
13655
|
-
return !e || !/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(e) ? `非法属性名 "${e}"` :
|
|
13691
|
+
function gg(e) {
|
|
13692
|
+
return !e || !/^[a-zA-Z_:][-a-zA-Z0-9_:.]*$/.test(e) ? `非法属性名 "${e}"` : pg.test(e) ? `事件属性 ${e} 被拒(on* 内联脚本防误执行)` : null;
|
|
13656
13693
|
}
|
|
13657
|
-
function
|
|
13694
|
+
function _g(e, t) {
|
|
13658
13695
|
let n = [];
|
|
13659
|
-
|
|
13696
|
+
fg.has(e.toLowerCase()) && n.push(`标签 <${e}> 被拒(可执行/页面行为面;文档标注场景请用常规内容标签)`);
|
|
13660
13697
|
for (let [e, r] of Object.entries(t ?? {})) {
|
|
13661
|
-
let t =
|
|
13662
|
-
t ? n.push(t) :
|
|
13698
|
+
let t = gg(e);
|
|
13699
|
+
t ? n.push(t) : mg.has(e.toLowerCase()) && hg(String(r)) && n.push(`${e} 的 javascript:/vbscript: 协议被拒`);
|
|
13663
13700
|
}
|
|
13664
13701
|
return n;
|
|
13665
13702
|
}
|
|
13666
|
-
var
|
|
13703
|
+
var vg = t.discriminatedUnion("op", [
|
|
13667
13704
|
t.object({
|
|
13668
13705
|
op: t.literal("set_text"),
|
|
13669
13706
|
selector: t.string().min(1),
|
|
@@ -13703,7 +13740,7 @@ var _g = t.discriminatedUnion("op", [
|
|
|
13703
13740
|
t.object({
|
|
13704
13741
|
op: t.literal("insert"),
|
|
13705
13742
|
anchor: t.string().min(1).describe("锚元素 selector"),
|
|
13706
|
-
position:
|
|
13743
|
+
position: dg.describe("before/after = 锚前后兄弟;prepend/append = 锚首尾子;replace = 换掉锚本身"),
|
|
13707
13744
|
tag: t.string().min(1).describe("新元素标签名,如 div/span/mark"),
|
|
13708
13745
|
attrs: t.record(t.string(), t.string()).optional(),
|
|
13709
13746
|
text: t.string().optional(),
|
|
@@ -13732,19 +13769,19 @@ var _g = t.discriminatedUnion("op", [
|
|
|
13732
13769
|
note: t.string().optional().describe("可选浮注文案")
|
|
13733
13770
|
})
|
|
13734
13771
|
]);
|
|
13735
|
-
function
|
|
13772
|
+
function yg(e) {
|
|
13736
13773
|
let t = [];
|
|
13737
13774
|
for (let n = 0; n < e.length; n++) {
|
|
13738
13775
|
let r = e[n], i = `patches[${n}](${r.op})`;
|
|
13739
13776
|
if (r.op === "set_attr") {
|
|
13740
|
-
let e =
|
|
13741
|
-
e ? t.push(`${i}: ${e}`) :
|
|
13777
|
+
let e = gg(r.name);
|
|
13778
|
+
e ? t.push(`${i}: ${e}`) : mg.has(r.name.toLowerCase()) && hg(r.value) && t.push(`${i}: ${r.name} 的 javascript:/vbscript: 协议被拒`);
|
|
13742
13779
|
}
|
|
13743
|
-
r.op === "insert" && (t.push(...
|
|
13780
|
+
r.op === "insert" && (t.push(..._g(r.tag, r.attrs).map((e) => `${i}: ${e}`)), r.text !== void 0 && r.html !== void 0 && t.push(`${i}: text 与 html 二选一`)), r.op === "highlight" && r.color && !/^#[0-9a-fA-F]{3,8}$|^[a-zA-Z]+$/.test(r.color) && t.push(`${i}: color 仅接受 hex 或颜色名`);
|
|
13744
13781
|
}
|
|
13745
13782
|
return t;
|
|
13746
13783
|
}
|
|
13747
|
-
function
|
|
13784
|
+
function bg(e = {}) {
|
|
13748
13785
|
let n = [], r = 0, i = () => e.getDocument?.() ?? (typeof document < "u" ? document : null), a = (e, t, n) => {
|
|
13749
13786
|
let r = [];
|
|
13750
13787
|
try {
|
|
@@ -13756,9 +13793,9 @@ function yg(e = {}) {
|
|
|
13756
13793
|
}, o = (e) => ji(e) ? "目标元素位于 SDK 对话框自身 DOM 内,写操作被拒(防 agent 改坏自己的 UI)。请操作宿主页面内容区域" : null, c = (e, t) => {
|
|
13757
13794
|
if (!e) return null;
|
|
13758
13795
|
let n = e.outerHTML;
|
|
13759
|
-
if (n.length >
|
|
13760
|
-
let i = e.getAttribute?.(
|
|
13761
|
-
return i || (i = `pg${++r}`, e.setAttribute?.(
|
|
13796
|
+
if (n.length > ug) return `快照超限:受影响子树 ${(n.length / 1024).toFixed(0)}KB > ${ug / 1024}KB。缩小 selector 到更深的子树再改(快照是回滚安全网,巨树快照爆内存)`;
|
|
13797
|
+
let i = e.getAttribute?.(cg) ?? "";
|
|
13798
|
+
return i || (i = `pg${++r}`, e.setAttribute?.(cg, i)), t.some((e) => e.id === i) || t.push({
|
|
13762
13799
|
id: i,
|
|
13763
13800
|
html: n
|
|
13764
13801
|
}), null;
|
|
@@ -13844,7 +13881,7 @@ function yg(e = {}) {
|
|
|
13844
13881
|
let s = i();
|
|
13845
13882
|
if (!s) return "ERROR: dom_edit 仅在浏览器环境可用(当前运行在 node/服务端,无 DOM)。改数据请用 write 工具。";
|
|
13846
13883
|
if (!t?.length) return "ERROR: patches 不能为空。支持 op:set_text/set_html/set_attr/remove_attr/add_class/remove_class/set_style/insert/remove/move/highlight";
|
|
13847
|
-
let c =
|
|
13884
|
+
let c = yg(t);
|
|
13848
13885
|
if (c.length) return `ERROR: 校验失败(整批拒绝,零改动):\n- ${c.join("\n- ")}`;
|
|
13849
13886
|
let u = (e, t) => {
|
|
13850
13887
|
let n = a(s, e, t);
|
|
@@ -13872,7 +13909,7 @@ function yg(e = {}) {
|
|
|
13872
13909
|
return f.length && (n.push({
|
|
13873
13910
|
snips: f,
|
|
13874
13911
|
ops: d
|
|
13875
|
-
}), n.length >
|
|
13912
|
+
}), n.length > lg && n.shift()), e.onEdit?.({
|
|
13876
13913
|
ops: d,
|
|
13877
13914
|
applied: t.length,
|
|
13878
13915
|
dryRun: !1
|
|
@@ -13881,7 +13918,7 @@ function yg(e = {}) {
|
|
|
13881
13918
|
name: "dom_edit",
|
|
13882
13919
|
description: "修改宿主页面元素(标注/内容/结构):patches 批量原子操作(任一失败整批拒绝)。op 集:set_text/set_html(内容)、set_attr/remove_attr、add_class/remove_class、set_style(样式)、insert(新建元素,before/after/prepend/append/replace)、remove、move(层级调整)、highlight(高亮+滚动定位)。纪律:selector 必须唯一命中(先 get_dom/dom_search 定位);改前自动快照,dom_restore 回滚;数据驱动页面请改数据而非 DOM。",
|
|
13883
13920
|
schema: t.object({
|
|
13884
|
-
patches: t.array(
|
|
13921
|
+
patches: t.array(vg).min(1).max(20).describe("批量操作(原子;顺序应用)"),
|
|
13885
13922
|
dryRun: t.boolean().optional().describe("只校验不落地(预检)")
|
|
13886
13923
|
})
|
|
13887
13924
|
}), d = s(async () => {
|
|
@@ -13891,7 +13928,7 @@ function yg(e = {}) {
|
|
|
13891
13928
|
if (!r) return "无可用快照(栈空)。";
|
|
13892
13929
|
let a = 0, o = [];
|
|
13893
13930
|
for (let e = r.snips.length - 1; e >= 0; e--) {
|
|
13894
|
-
let { id: n, html: i } = r.snips[e], s = t.querySelector(`[${
|
|
13931
|
+
let { id: n, html: i } = r.snips[e], s = t.querySelector(`[${cg}="${n}"]`);
|
|
13895
13932
|
if (!s) {
|
|
13896
13933
|
o.push(n);
|
|
13897
13934
|
continue;
|
|
@@ -13918,14 +13955,14 @@ function yg(e = {}) {
|
|
|
13918
13955
|
}
|
|
13919
13956
|
//#endregion
|
|
13920
13957
|
//#region src/core/sdk/hostWatcher.ts
|
|
13921
|
-
var
|
|
13922
|
-
function xg(e) {
|
|
13923
|
-
return e.kind === "title" ? `页面标题已变更:${bg(e.to, 60)}` : `页面导航:${bg(e.from, 80)} → ${bg(e.to, 80)}`;
|
|
13924
|
-
}
|
|
13958
|
+
var xg = (e, t) => e.length > t ? `${e.slice(0, t)}…` : e;
|
|
13925
13959
|
function Sg(e) {
|
|
13926
|
-
return e.kind === "title" ?
|
|
13960
|
+
return e.kind === "title" ? `页面标题已变更:${xg(e.to, 60)}` : `页面导航:${xg(e.from, 80)} → ${xg(e.to, 80)}`;
|
|
13927
13961
|
}
|
|
13928
13962
|
function Cg(e) {
|
|
13963
|
+
return e.kind === "title" ? 0 : 1;
|
|
13964
|
+
}
|
|
13965
|
+
function wg(e) {
|
|
13929
13966
|
let { target: t, history: n, document: r, MutationObserver: i, onReport: a } = e, o = e.options ?? {}, s = Math.max(0, o.debounceMs ?? 300), c = () => String(t?.location?.href ?? ""), l = () => String(r?.title ?? ""), u = !1, d = null, f = null, p = [], m = c(), h = l(), g = (e) => {
|
|
13930
13967
|
if (u) return;
|
|
13931
13968
|
let t = c();
|
|
@@ -13947,7 +13984,7 @@ function Cg(e) {
|
|
|
13947
13984
|
};
|
|
13948
13985
|
h = e, v(t);
|
|
13949
13986
|
}, v = (e) => {
|
|
13950
|
-
f = f &&
|
|
13987
|
+
f = f && Cg(f) >= Cg(e) ? f : e, d === null && (d = setTimeout(() => {
|
|
13951
13988
|
d = null;
|
|
13952
13989
|
let e = f;
|
|
13953
13990
|
f = null, !(u || !e) && o.ignore?.(e) !== !0 && a(e);
|
|
@@ -13999,22 +14036,22 @@ function Cg(e) {
|
|
|
13999
14036
|
}
|
|
14000
14037
|
//#endregion
|
|
14001
14038
|
//#region src/core/tools/proposalOps.ts
|
|
14002
|
-
var
|
|
14003
|
-
function
|
|
14039
|
+
var Tg = 4e6;
|
|
14040
|
+
function Eg(e, t) {
|
|
14004
14041
|
return t.map((t) => ({
|
|
14005
14042
|
type: e,
|
|
14006
14043
|
text: t
|
|
14007
14044
|
}));
|
|
14008
14045
|
}
|
|
14009
|
-
function
|
|
14046
|
+
function Dg(e, t) {
|
|
14010
14047
|
let n = e ? String(e).split("\n") : [], r = t ? String(t).split("\n") : [], i = 0;
|
|
14011
14048
|
for (; i < n.length && i < r.length && n[i] === r[i];) i += 1;
|
|
14012
14049
|
let a = n.length, o = r.length;
|
|
14013
14050
|
for (; a > i && o > i && n[a - 1] === r[o - 1];) --a, --o;
|
|
14014
|
-
let s = n.slice(i, a), c = r.slice(i, o), l = s.length * c.length >
|
|
14015
|
-
...
|
|
14051
|
+
let s = n.slice(i, a), c = r.slice(i, o), l = s.length * c.length > Tg ? [...Eg("del", s), ...Eg("add", c)] : Og(s, c), u = [
|
|
14052
|
+
...Eg("same", n.slice(0, i)),
|
|
14016
14053
|
...l,
|
|
14017
|
-
...
|
|
14054
|
+
...Eg("same", n.slice(a))
|
|
14018
14055
|
];
|
|
14019
14056
|
return {
|
|
14020
14057
|
rows: u,
|
|
@@ -14024,7 +14061,7 @@ function Eg(e, t) {
|
|
|
14024
14061
|
}
|
|
14025
14062
|
};
|
|
14026
14063
|
}
|
|
14027
|
-
function
|
|
14064
|
+
function Og(e, t) {
|
|
14028
14065
|
let n = e.length, r = t.length, i = new Uint32Array((n + 1) * (r + 1)), a = (e, t) => e * (r + 1) + t;
|
|
14029
14066
|
for (let o = n - 1; o >= 0; --o) for (let n = r - 1; n >= 0; --n) i[a(o, n)] = e[o] === t[n] ? i[a(o + 1, n + 1)] + 1 : Math.max(i[a(o + 1, n)], i[a(o, n + 1)]);
|
|
14030
14067
|
let o = [], s = 0, c = 0;
|
|
@@ -14048,13 +14085,13 @@ function Dg(e, t) {
|
|
|
14048
14085
|
}), c += 1;
|
|
14049
14086
|
return o;
|
|
14050
14087
|
}
|
|
14051
|
-
function
|
|
14088
|
+
function kg(e, t) {
|
|
14052
14089
|
if (!t) return 0;
|
|
14053
14090
|
let n = 0, r = e.indexOf(t);
|
|
14054
14091
|
for (; r !== -1;) n += 1, r = e.indexOf(t, r + t.length);
|
|
14055
14092
|
return n;
|
|
14056
14093
|
}
|
|
14057
|
-
function
|
|
14094
|
+
function Ag(e, t) {
|
|
14058
14095
|
let n = String(e ?? "");
|
|
14059
14096
|
for (let e = 0; e < t.length; e += 1) {
|
|
14060
14097
|
let r = t[e];
|
|
@@ -14063,7 +14100,7 @@ function kg(e, t) {
|
|
|
14063
14100
|
error: `第 ${e + 1} 个 op 格式无效`
|
|
14064
14101
|
};
|
|
14065
14102
|
if (r.op === "replace") {
|
|
14066
|
-
let t =
|
|
14103
|
+
let t = kg(n, r.find);
|
|
14067
14104
|
if (t === 0) return {
|
|
14068
14105
|
ok: !1,
|
|
14069
14106
|
error: `第 ${e + 1} 个 op(replace)锚点未命中 —— 锚文本在当前内容中不存在(可能锚写错或基底已变),请核对 read_content 的原文后重试`
|
|
@@ -14074,7 +14111,7 @@ function kg(e, t) {
|
|
|
14074
14111
|
};
|
|
14075
14112
|
n = n.replace(r.find, r.with);
|
|
14076
14113
|
} else if (r.op === "insertAfter" || r.op === "insertBefore") {
|
|
14077
|
-
let t =
|
|
14114
|
+
let t = kg(n, r.anchor);
|
|
14078
14115
|
if (t === 0) return {
|
|
14079
14116
|
ok: !1,
|
|
14080
14117
|
error: `第 ${e + 1} 个 op(${r.op})锚点未命中 —— 请核对 read_content 的原文后重试`
|
|
@@ -14096,14 +14133,14 @@ function kg(e, t) {
|
|
|
14096
14133
|
content: n
|
|
14097
14134
|
};
|
|
14098
14135
|
}
|
|
14099
|
-
function
|
|
14136
|
+
function jg(e) {
|
|
14100
14137
|
let t = String(e ?? ""), n = 2166136261;
|
|
14101
14138
|
for (let e = 0; e < t.length; e += 1) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
14102
14139
|
return (n >>> 0).toString(36);
|
|
14103
14140
|
}
|
|
14104
14141
|
//#endregion
|
|
14105
14142
|
//#region src/core/sdk/proposals.ts
|
|
14106
|
-
function
|
|
14143
|
+
function Mg(e) {
|
|
14107
14144
|
return {
|
|
14108
14145
|
read: e.read,
|
|
14109
14146
|
onProposal: e.onProposal,
|
|
@@ -14113,14 +14150,14 @@ function jg(e) {
|
|
|
14113
14150
|
maxPending: Math.max(1, e.maxPending ?? 1)
|
|
14114
14151
|
};
|
|
14115
14152
|
}
|
|
14116
|
-
async function
|
|
14153
|
+
async function Ng(e) {
|
|
14117
14154
|
try {
|
|
14118
14155
|
return await e.read();
|
|
14119
14156
|
} catch (e) {
|
|
14120
14157
|
return { __err: e };
|
|
14121
14158
|
}
|
|
14122
14159
|
}
|
|
14123
|
-
var
|
|
14160
|
+
var Pg = t.discriminatedUnion("op", [
|
|
14124
14161
|
t.object({
|
|
14125
14162
|
op: t.literal("replace"),
|
|
14126
14163
|
find: t.string().min(1).describe("要替换的原文片段(字面匹配,须在全文唯一 —— 多带上下文保唯一)"),
|
|
@@ -14141,8 +14178,8 @@ var Ng = t.discriminatedUnion("op", [
|
|
|
14141
14178
|
text: t.string().describe("追加到全文末尾的文本")
|
|
14142
14179
|
})
|
|
14143
14180
|
]);
|
|
14144
|
-
function
|
|
14145
|
-
let r =
|
|
14181
|
+
function Fg(e, n) {
|
|
14182
|
+
let r = Mg(e), i = {
|
|
14146
14183
|
pending: [],
|
|
14147
14184
|
applied: 0,
|
|
14148
14185
|
discarded: 0,
|
|
@@ -14183,11 +14220,11 @@ function Pg(e, n) {
|
|
|
14183
14220
|
summary: o.summary
|
|
14184
14221
|
}), !0;
|
|
14185
14222
|
}, c = s(async () => {
|
|
14186
|
-
let e = await
|
|
14223
|
+
let e = await Ng(r);
|
|
14187
14224
|
if (e && typeof e == "object" && "__err" in e) return `读取失败:${String(e.__err ?? "未知错误")}。请如实告知用户,不要编造内容。`;
|
|
14188
14225
|
let t = e;
|
|
14189
14226
|
if (!t || typeof t.content != "string") return "当前没有可编辑的内容对象(宿主 read 返回空)。请如实告知用户,不要编造内容。";
|
|
14190
|
-
let i =
|
|
14227
|
+
let i = jg(t.content);
|
|
14191
14228
|
return n.log("read", {
|
|
14192
14229
|
hash: i,
|
|
14193
14230
|
chars: t.content.length
|
|
@@ -14199,7 +14236,7 @@ function Pg(e, n) {
|
|
|
14199
14236
|
}), l = t.object({
|
|
14200
14237
|
summary: t.string().describe("一句话修改说明(展示在评审面板):改了什么、为什么"),
|
|
14201
14238
|
baseHash: t.string().describe("read_content 返回的 hash(基底锚定;基底已变会被拒,须重读)"),
|
|
14202
|
-
ops: t.array(
|
|
14239
|
+
ops: t.array(Pg).min(1).max(50).optional().describe("增量操作(顺序应用,原子;推荐 —— token 只花在改动上,勿全量重发)"),
|
|
14203
14240
|
content: t.string().optional().describe(`修改后的完整${r.contentKind}(小改动可直发;与 ops 二选一)`)
|
|
14204
14241
|
}).superRefine((e, n) => {
|
|
14205
14242
|
(Array.isArray(e.ops) && e.ops.length > 0) === (typeof e.content == "string" && e.content.length > 0) && n.addIssue({
|
|
@@ -14207,13 +14244,13 @@ function Pg(e, n) {
|
|
|
14207
14244
|
message: "ops 与 content 必须二选一(且只给一个)"
|
|
14208
14245
|
});
|
|
14209
14246
|
}), u = [c, s(async (e) => {
|
|
14210
|
-
let t = await
|
|
14247
|
+
let t = await Ng(r);
|
|
14211
14248
|
if (t && typeof t == "object" && "__err" in t) return `提案被拒:读取当前内容失败(${String(t.__err ?? "未知错误")})。`;
|
|
14212
14249
|
let a = t;
|
|
14213
14250
|
if (!a || typeof a.content != "string") return "提案被拒:当前没有可编辑的内容对象。";
|
|
14214
|
-
let o = a.content, s = typeof a.label == "string" ? a.label : void 0, c =
|
|
14251
|
+
let o = a.content, s = typeof a.label == "string" ? a.label : void 0, c = jg(o);
|
|
14215
14252
|
if (e.baseHash !== c) return n.log("rejected", { reason: "base_hash_mismatch" }), `提案被拒:基底已变(read_content 之后内容被修改,hash 不匹配)。请重新 ${r.readToolName} 取当前原文与 hash 后基于新基底重提 —— 不要在旧印象上猜测改动。`;
|
|
14216
|
-
let l = Array.isArray(e.ops) && e.ops.length > 0 ?
|
|
14253
|
+
let l = Array.isArray(e.ops) && e.ops.length > 0 ? Ag(o, e.ops) : {
|
|
14217
14254
|
ok: !0,
|
|
14218
14255
|
content: String(e.content ?? "")
|
|
14219
14256
|
};
|
|
@@ -14236,7 +14273,7 @@ function Pg(e, n) {
|
|
|
14236
14273
|
baseHash: c,
|
|
14237
14274
|
baseContent: o,
|
|
14238
14275
|
content: u,
|
|
14239
|
-
diff:
|
|
14276
|
+
diff: Dg(o, u),
|
|
14240
14277
|
createdAt: Date.now()
|
|
14241
14278
|
};
|
|
14242
14279
|
i.pending.push(d), n.log("pending", {
|
|
@@ -14273,8 +14310,8 @@ function Pg(e, n) {
|
|
|
14273
14310
|
}
|
|
14274
14311
|
//#endregion
|
|
14275
14312
|
//#region src/core/tools/fetchDoc.ts
|
|
14276
|
-
var
|
|
14277
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
14313
|
+
var Ig = 3e4, Lg = [s(async ({ url: e, as: t }) => {
|
|
14314
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Ig);
|
|
14278
14315
|
try {
|
|
14279
14316
|
let r = await fetch(e, {
|
|
14280
14317
|
method: "GET",
|
|
@@ -14291,7 +14328,7 @@ var Fg = 3e4, Ig = [s(async ({ url: e, as: t }) => {
|
|
|
14291
14328
|
].join("\n");
|
|
14292
14329
|
} catch (t) {
|
|
14293
14330
|
let r = t?.message || String(t);
|
|
14294
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
14331
|
+
return n.signal.aborted ? `获取失败:请求超时(${Ig}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
14295
14332
|
} finally {
|
|
14296
14333
|
clearTimeout(r);
|
|
14297
14334
|
}
|
|
@@ -14302,7 +14339,7 @@ var Fg = 3e4, Ig = [s(async ({ url: e, as: t }) => {
|
|
|
14302
14339
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
14303
14340
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
14304
14341
|
})
|
|
14305
|
-
})],
|
|
14342
|
+
})], Rg = [
|
|
14306
14343
|
"id",
|
|
14307
14344
|
"class",
|
|
14308
14345
|
"href",
|
|
@@ -14314,12 +14351,12 @@ var Fg = 3e4, Ig = [s(async ({ url: e, as: t }) => {
|
|
|
14314
14351
|
"aria-label",
|
|
14315
14352
|
"name",
|
|
14316
14353
|
"type"
|
|
14317
|
-
],
|
|
14318
|
-
function
|
|
14354
|
+
], zg = /^(value|srcdoc|formaction|on\w+)$/i, Bg = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
14355
|
+
function Vg(e, t) {
|
|
14319
14356
|
if (!e) return null;
|
|
14320
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
14357
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Rg, s = (e) => {
|
|
14321
14358
|
let t = {};
|
|
14322
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
14359
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (zg.test(n.name) || Bg.test(n.name) || (t[n.name] = n.value));
|
|
14323
14360
|
return t;
|
|
14324
14361
|
}, c = (e, t) => {
|
|
14325
14362
|
let n = {
|
|
@@ -14335,11 +14372,11 @@ function Bg(e, t) {
|
|
|
14335
14372
|
};
|
|
14336
14373
|
return c(e, n);
|
|
14337
14374
|
}
|
|
14338
|
-
var
|
|
14375
|
+
var Hg = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
14339
14376
|
if (typeof document > "u") return "ERROR: get_dom 仅在浏览器环境可用(当前运行在 node/服务端,无 DOM)。请改用数据工具(read/schema_data)排查结构。";
|
|
14340
14377
|
let i = e ? document.querySelector(e) : document.body;
|
|
14341
14378
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
14342
|
-
let a =
|
|
14379
|
+
let a = Vg(i, {
|
|
14343
14380
|
depth: t ?? 3,
|
|
14344
14381
|
attrs: n,
|
|
14345
14382
|
includeText: r ?? !0
|
|
@@ -14354,7 +14391,7 @@ var Vg = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
14354
14391
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
14355
14392
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
14356
14393
|
})
|
|
14357
|
-
}),
|
|
14394
|
+
}), Ug = [
|
|
14358
14395
|
"article",
|
|
14359
14396
|
"main",
|
|
14360
14397
|
"[role=\"main\"]",
|
|
@@ -14363,7 +14400,7 @@ var Vg = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
14363
14400
|
".post-content",
|
|
14364
14401
|
".markdown-body",
|
|
14365
14402
|
"#content"
|
|
14366
|
-
],
|
|
14403
|
+
], Wg = /* @__PURE__ */ new Set([
|
|
14367
14404
|
"script",
|
|
14368
14405
|
"style",
|
|
14369
14406
|
"noscript",
|
|
@@ -14371,15 +14408,15 @@ var Vg = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
14371
14408
|
"svg",
|
|
14372
14409
|
"iframe",
|
|
14373
14410
|
"canvas"
|
|
14374
|
-
]),
|
|
14375
|
-
function
|
|
14376
|
-
for (let t of
|
|
14411
|
+
]), Gg = "script,style,noscript,template,svg,iframe,canvas";
|
|
14412
|
+
function Kg(e) {
|
|
14413
|
+
for (let t of Ug) try {
|
|
14377
14414
|
let n = e.querySelector?.(t);
|
|
14378
14415
|
if (n) return n;
|
|
14379
14416
|
} catch {}
|
|
14380
14417
|
return e.body ?? null;
|
|
14381
14418
|
}
|
|
14382
|
-
function
|
|
14419
|
+
function qg(e, t, n) {
|
|
14383
14420
|
if (!e) return "";
|
|
14384
14421
|
let r = [], i = (e) => {
|
|
14385
14422
|
let t = (e.innerText ?? e.textContent ?? "").replace(/\r\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
@@ -14387,7 +14424,7 @@ function Kg(e, t, n) {
|
|
|
14387
14424
|
}, a = (e) => {
|
|
14388
14425
|
for (let r of Array.from(e.children ?? [])) {
|
|
14389
14426
|
let e = r, o = String(e.tagName ?? "").toLowerCase();
|
|
14390
|
-
if (!(t(e) ||
|
|
14427
|
+
if (!(t(e) || Wg.has(o))) {
|
|
14391
14428
|
if (!n(e)) {
|
|
14392
14429
|
i(e);
|
|
14393
14430
|
continue;
|
|
@@ -14398,21 +14435,21 @@ function Kg(e, t, n) {
|
|
|
14398
14435
|
};
|
|
14399
14436
|
return a(e), r.join("\n\n").trim();
|
|
14400
14437
|
}
|
|
14401
|
-
function
|
|
14438
|
+
function Jg(e) {
|
|
14402
14439
|
try {
|
|
14403
|
-
return e.querySelector?.(
|
|
14440
|
+
return e.querySelector?.(Gg) != null || e.querySelector?.(".chat-dialog, .chat-mask, .debug-drawer, .skill-mask, .skill-panel, .chat-selection-menu") != null;
|
|
14404
14441
|
} catch {
|
|
14405
14442
|
return !0;
|
|
14406
14443
|
}
|
|
14407
14444
|
}
|
|
14408
|
-
var
|
|
14445
|
+
var Yg = [Hg, s(({ selector: e, offset: t, limit: n }) => {
|
|
14409
14446
|
if (typeof document > "u") return "ERROR: read_page 仅在浏览器环境可用(当前运行在 node/服务端,无 DOM)。请基于用户消息中的引用原文回答。";
|
|
14410
14447
|
let r, i;
|
|
14411
14448
|
if (e) {
|
|
14412
14449
|
if (r = document.querySelector(e), !r) return `未找到匹配元素:selector="${e}"`;
|
|
14413
14450
|
i = e;
|
|
14414
|
-
} else r =
|
|
14415
|
-
let a =
|
|
14451
|
+
} else r = Kg(document), i = r ? r.tagName.toLowerCase() : "body";
|
|
14452
|
+
let a = qg(r, ji, Jg), o = t ?? 0, s = n ?? 4e3;
|
|
14416
14453
|
if (o > a.length) return `offset=${o} 超出正文长度 ${a.length}(先从 offset=0 读,按 hasMore 续读)`;
|
|
14417
14454
|
let c = a.slice(o, o + s);
|
|
14418
14455
|
return JSON.stringify({
|
|
@@ -14431,22 +14468,22 @@ var Jg = [Vg, s(({ selector: e, offset: t, limit: n }) => {
|
|
|
14431
14468
|
offset: t.number().int().min(0).optional().describe("起始字符偏移(默认 0;续读传上次 offset + 返回 text 长度)"),
|
|
14432
14469
|
limit: t.number().int().min(200).max(2e4).optional().describe("本次返回字符上限(默认 4000,上限 20000)")
|
|
14433
14470
|
})
|
|
14434
|
-
})],
|
|
14435
|
-
function
|
|
14436
|
-
if (
|
|
14471
|
+
})], Xg = /* @__PURE__ */ "display.position.visibility.opacity.color.background-color.background-image.font-size.font-weight.line-height.text-align.z-index.overflow.width.height.margin.padding.border.border-radius.box-shadow.transform.transition.animation.cursor.pointer-events.flex-direction.gap.max-width.min-height".split("."), Zg = /* @__PURE__ */ new WeakMap(), Qg = !1;
|
|
14472
|
+
function $g() {
|
|
14473
|
+
if (Qg) return;
|
|
14437
14474
|
let e = globalThis.EventTarget;
|
|
14438
14475
|
if (!e?.prototype?.addEventListener) return;
|
|
14439
|
-
|
|
14476
|
+
Qg = !0;
|
|
14440
14477
|
let t = e.prototype.addEventListener, n = e.prototype.removeEventListener;
|
|
14441
14478
|
e.prototype.addEventListener = function(e, ...n) {
|
|
14442
14479
|
try {
|
|
14443
|
-
let t =
|
|
14444
|
-
t || (t = /* @__PURE__ */ new Map(),
|
|
14480
|
+
let t = Zg.get(this);
|
|
14481
|
+
t || (t = /* @__PURE__ */ new Map(), Zg.set(this, t)), t.set(String(e), (t.get(String(e)) ?? 0) + 1);
|
|
14445
14482
|
} catch {}
|
|
14446
14483
|
return t.call(this, e, ...n);
|
|
14447
14484
|
}, e.prototype.removeEventListener = function(e, ...t) {
|
|
14448
14485
|
try {
|
|
14449
|
-
let t =
|
|
14486
|
+
let t = Zg.get(this);
|
|
14450
14487
|
if (t) {
|
|
14451
14488
|
let n = (t.get(String(e)) ?? 1) - 1;
|
|
14452
14489
|
n <= 0 ? t.delete(String(e)) : t.set(String(e), n);
|
|
@@ -14455,10 +14492,10 @@ function Qg() {
|
|
|
14455
14492
|
return n.call(this, e, ...t);
|
|
14456
14493
|
};
|
|
14457
14494
|
}
|
|
14458
|
-
function
|
|
14459
|
-
return [...
|
|
14495
|
+
function e_(e) {
|
|
14496
|
+
return [...Zg.get(e)?.entries() ?? []].filter(([, e]) => e > 0).map(([e]) => e);
|
|
14460
14497
|
}
|
|
14461
|
-
function
|
|
14498
|
+
function t_(e, t = 12) {
|
|
14462
14499
|
let n = [], r = e, i = 0;
|
|
14463
14500
|
for (; r && r.tagName && i < t;) {
|
|
14464
14501
|
let e = r.tagName.toLowerCase(), t = r.id;
|
|
@@ -14479,7 +14516,7 @@ function e_(e, t = 12) {
|
|
|
14479
14516
|
}
|
|
14480
14517
|
return n.join(" > ");
|
|
14481
14518
|
}
|
|
14482
|
-
function
|
|
14519
|
+
function n_(e, t, n = {}) {
|
|
14483
14520
|
if (!e) return {
|
|
14484
14521
|
hits: [],
|
|
14485
14522
|
total: 0,
|
|
@@ -14517,7 +14554,7 @@ function t_(e, t, n = {}) {
|
|
|
14517
14554
|
n = r.slice(Math.max(0, i - 20), i + t.length + 40);
|
|
14518
14555
|
}
|
|
14519
14556
|
return {
|
|
14520
|
-
selector:
|
|
14557
|
+
selector: t_(e),
|
|
14521
14558
|
tag: e.tagName.toLowerCase(),
|
|
14522
14559
|
text: n.slice(0, 120)
|
|
14523
14560
|
};
|
|
@@ -14526,7 +14563,7 @@ function t_(e, t, n = {}) {
|
|
|
14526
14563
|
truncated: a.length > o
|
|
14527
14564
|
};
|
|
14528
14565
|
}
|
|
14529
|
-
var
|
|
14566
|
+
var r_ = [
|
|
14530
14567
|
"content",
|
|
14531
14568
|
"display",
|
|
14532
14569
|
"width",
|
|
@@ -14534,14 +14571,14 @@ var n_ = [
|
|
|
14534
14571
|
"background-color",
|
|
14535
14572
|
"position"
|
|
14536
14573
|
];
|
|
14537
|
-
function
|
|
14574
|
+
function i_(e, t = {}) {
|
|
14538
14575
|
if (!e) return null;
|
|
14539
14576
|
let n = {
|
|
14540
|
-
selector:
|
|
14577
|
+
selector: t_(e),
|
|
14541
14578
|
tag: e.tagName.toLowerCase(),
|
|
14542
14579
|
attrs: {}
|
|
14543
14580
|
};
|
|
14544
|
-
for (let t of Array.from(e.attributes)) !(
|
|
14581
|
+
for (let t of Array.from(e.attributes)) !(Rg.includes(t.name) || t.name.startsWith("data-")) || zg.test(t.name) || Bg.test(t.name) || (n.attrs[t.name] = t.value);
|
|
14545
14582
|
let r = Array.from(e.childNodes).filter((e) => e.nodeType === 3).map((e) => e.textContent || "").join("").trim();
|
|
14546
14583
|
r && (n.text = r.slice(0, 400));
|
|
14547
14584
|
let i = String(e.innerText ?? e.textContent ?? "").trim();
|
|
@@ -14563,7 +14600,7 @@ function r_(e, t = {}) {
|
|
|
14563
14600
|
if (typeof a != "function") return r;
|
|
14564
14601
|
try {
|
|
14565
14602
|
let i = a(e, n ?? null);
|
|
14566
|
-
for (let e of n ?
|
|
14603
|
+
for (let e of n ? r_ : t.styles ?? Xg) {
|
|
14567
14604
|
let t = typeof i.getPropertyValue == "function" ? i.getPropertyValue(e) : i[e];
|
|
14568
14605
|
t && (r[e] = String(t).slice(0, 200));
|
|
14569
14606
|
}
|
|
@@ -14581,16 +14618,16 @@ function r_(e, t = {}) {
|
|
|
14581
14618
|
n.events = {
|
|
14582
14619
|
inline: t,
|
|
14583
14620
|
vue: r ? Object.keys(r).filter((e) => /^on[A-Z]/.test(e)).map((e) => e.slice(2).toLowerCase()) : [],
|
|
14584
|
-
captured:
|
|
14621
|
+
captured: e_(e)
|
|
14585
14622
|
};
|
|
14586
14623
|
}
|
|
14587
14624
|
return n;
|
|
14588
14625
|
}
|
|
14589
|
-
var
|
|
14590
|
-
|
|
14626
|
+
var a_ = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
14627
|
+
$g();
|
|
14591
14628
|
let i = r ? document.querySelector(r) : document;
|
|
14592
14629
|
if (r && !i) return `未找到 root 元素:selector="${r}"`;
|
|
14593
|
-
let a =
|
|
14630
|
+
let a = n_(i, e, {
|
|
14594
14631
|
mode: t,
|
|
14595
14632
|
limit: n
|
|
14596
14633
|
});
|
|
@@ -14607,11 +14644,11 @@ var i_ = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
14607
14644
|
limit: t.number().int().min(1).max(20).optional().describe("返回上限(默认 10)"),
|
|
14608
14645
|
root: t.string().optional().describe("限定搜索范围的容器选择器(默认整页)")
|
|
14609
14646
|
})
|
|
14610
|
-
}),
|
|
14611
|
-
|
|
14647
|
+
}), o_ = s(({ selector: e, styles: t, includeHtml: n, htmlLimit: r, includeEvents: i, includeRect: a, pseudo: o }) => {
|
|
14648
|
+
$g();
|
|
14612
14649
|
let s = document.querySelector(e);
|
|
14613
14650
|
if (!s) return `未找到匹配元素:selector="${e}"(可先用 dom_search 定位)`;
|
|
14614
|
-
let c =
|
|
14651
|
+
let c = i_(s, {
|
|
14615
14652
|
styles: t,
|
|
14616
14653
|
includeHtml: n,
|
|
14617
14654
|
htmlLimit: r,
|
|
@@ -14632,10 +14669,10 @@ var i_ = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
14632
14669
|
includeRect: t.boolean().optional().describe("是否含几何位置(默认 true)"),
|
|
14633
14670
|
pseudo: t.boolean().optional().describe("是否含 ::before/::after 伪元素摘要(默认 false)")
|
|
14634
14671
|
})
|
|
14635
|
-
}),
|
|
14636
|
-
function
|
|
14672
|
+
}), s_ = "dom-inspect";
|
|
14673
|
+
function c_(e = {}) {
|
|
14637
14674
|
return {
|
|
14638
|
-
name:
|
|
14675
|
+
name: s_,
|
|
14639
14676
|
description: "页面 DOM 深度检视工具(dom_search 搜索元素 / dom_info 读内容·计算样式·事件绑定·几何)。定位元素、验证样式落地、排查交互绑定时加载",
|
|
14640
14677
|
getContent: () => [
|
|
14641
14678
|
"# DOM 检视工具用法",
|
|
@@ -14666,13 +14703,13 @@ function s_(e = {}) {
|
|
|
14666
14703
|
"## 排障套路",
|
|
14667
14704
|
...e.withScreenshot ? ["1. dom_search(mode:\"text\", query:按钮文案) 定位 → 2. 视觉验证 take_screenshot / 结构验证 dom_info(styles) → 3. " + (e.withDataOps ? "不符则改数据(write 修正后再验证)" : "不符则如实报告差异(页面为真值;本页面无数据写通道,调整预期或告知用户)")] : ["1. dom_search(mode:\"text\", query:按钮文案) 定位 → 2. dom_info(styles:[\"display\",\"background-color\",\"pointer-events\"]) 验证样式/点击性 → 3. " + (e.withDataOps ? "不符则改数据(write 修正后再验证)" : "不符则如实报告差异(页面为真值;本页面无数据写通道,调整预期或告知用户)")]
|
|
14668
14705
|
].join("\n"),
|
|
14669
|
-
tools: [() => [
|
|
14706
|
+
tools: [() => [a_, o_]]
|
|
14670
14707
|
};
|
|
14671
14708
|
}
|
|
14672
|
-
var
|
|
14673
|
-
function
|
|
14709
|
+
var l_ = "page-analysis";
|
|
14710
|
+
function u_(e = {}) {
|
|
14674
14711
|
return {
|
|
14675
|
-
name:
|
|
14712
|
+
name: l_,
|
|
14676
14713
|
description: "页面内容分析策略:按问题类型选工具(引用原文/整页理解/定位/结构/视觉/页面操作),含分页探索纪律与基于页面实料的回答纪律。回答用户关于当前页面的问题时加载",
|
|
14677
14714
|
getContent: () => [
|
|
14678
14715
|
"# 页面内容分析策略",
|
|
@@ -14701,14 +14738,14 @@ function l_(e = {}) {
|
|
|
14701
14738
|
].join("\n")
|
|
14702
14739
|
};
|
|
14703
14740
|
}
|
|
14704
|
-
var
|
|
14741
|
+
var d_ = c_();
|
|
14705
14742
|
//#endregion
|
|
14706
14743
|
//#region src/core/tools/envTool.ts
|
|
14707
|
-
function
|
|
14744
|
+
function f_(e) {
|
|
14708
14745
|
let t = e;
|
|
14709
14746
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
14710
14747
|
}
|
|
14711
|
-
function
|
|
14748
|
+
function p_(e, t = 3, n = 2e3, r, i) {
|
|
14712
14749
|
if (e == null) return e;
|
|
14713
14750
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
14714
14751
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -14717,14 +14754,14 @@ function f_(e, t = 3, n = 2e3, r, i) {
|
|
|
14717
14754
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
14718
14755
|
if (typeof e != "object") return String(e);
|
|
14719
14756
|
let a = e;
|
|
14720
|
-
if (
|
|
14757
|
+
if (f_(a)) {
|
|
14721
14758
|
let e = a;
|
|
14722
14759
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
14723
14760
|
}
|
|
14724
14761
|
if (r?.has(a)) return "[Circular]";
|
|
14725
14762
|
let o = r ?? /* @__PURE__ */ new WeakSet();
|
|
14726
14763
|
if (o.add(a), Array.isArray(e)) {
|
|
14727
|
-
let r = e.slice(0, 100).map((e) =>
|
|
14764
|
+
let r = e.slice(0, 100).map((e) => p_(e, t - 1, n, o, i));
|
|
14728
14765
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
14729
14766
|
}
|
|
14730
14767
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -14737,14 +14774,14 @@ function f_(e, t = 3, n = 2e3, r, i) {
|
|
|
14737
14774
|
}
|
|
14738
14775
|
try {
|
|
14739
14776
|
let e = a[r];
|
|
14740
|
-
i?.test(r) ? s[r] = "[REDACTED]" : s[r] =
|
|
14777
|
+
i?.test(r) ? s[r] = "[REDACTED]" : s[r] = p_(e, t - 1, n, o, i);
|
|
14741
14778
|
} catch {
|
|
14742
14779
|
s[r] = "(getter 抛错)";
|
|
14743
14780
|
}
|
|
14744
14781
|
}
|
|
14745
14782
|
return s;
|
|
14746
14783
|
}
|
|
14747
|
-
function
|
|
14784
|
+
function m_(e) {
|
|
14748
14785
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
14749
14786
|
return {
|
|
14750
14787
|
location: {
|
|
@@ -14777,9 +14814,9 @@ function p_(e) {
|
|
|
14777
14814
|
} : "(无 document)"
|
|
14778
14815
|
};
|
|
14779
14816
|
}
|
|
14780
|
-
var
|
|
14817
|
+
var h_ = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, g_ = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, __ = s(({ key: e }) => {
|
|
14781
14818
|
if (e) {
|
|
14782
|
-
if (
|
|
14819
|
+
if (h_.test(e) || g_.test(e)) return JSON.stringify({
|
|
14783
14820
|
key: e,
|
|
14784
14821
|
denied: !0,
|
|
14785
14822
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -14789,18 +14826,18 @@ var m_ = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
14789
14826
|
key: e,
|
|
14790
14827
|
exists: t !== void 0,
|
|
14791
14828
|
type: typeof t,
|
|
14792
|
-
value:
|
|
14829
|
+
value: p_(t, 3, 2e3, void 0, g_)
|
|
14793
14830
|
}, null, 2);
|
|
14794
14831
|
}
|
|
14795
|
-
return JSON.stringify(
|
|
14832
|
+
return JSON.stringify(m_(), null, 2);
|
|
14796
14833
|
}, {
|
|
14797
14834
|
name: "inspect_env",
|
|
14798
14835
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
14799
14836
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
14800
|
-
}),
|
|
14837
|
+
}), v_ = [__];
|
|
14801
14838
|
//#endregion
|
|
14802
14839
|
//#region src/core/harness/budget.ts
|
|
14803
|
-
function
|
|
14840
|
+
function y_(e, t, n) {
|
|
14804
14841
|
let i = 0;
|
|
14805
14842
|
return {
|
|
14806
14843
|
name: "budget",
|
|
@@ -14825,12 +14862,12 @@ function v_(e, t, n) {
|
|
|
14825
14862
|
}
|
|
14826
14863
|
//#endregion
|
|
14827
14864
|
//#region src/core/sdk/actions.ts
|
|
14828
|
-
var
|
|
14829
|
-
function
|
|
14865
|
+
var b_ = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
14866
|
+
function x_(e) {
|
|
14830
14867
|
let n = [];
|
|
14831
14868
|
for (let [r, i] of Object.entries(e)) {
|
|
14832
|
-
if (!
|
|
14833
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${r}" 非法(须匹配 ${
|
|
14869
|
+
if (!b_.test(r)) {
|
|
14870
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${r}" 非法(须匹配 ${b_}),已跳过`);
|
|
14834
14871
|
continue;
|
|
14835
14872
|
}
|
|
14836
14873
|
let e = i.description || `宿主动作 ${r}`;
|
|
@@ -14850,9 +14887,9 @@ function b_(e) {
|
|
|
14850
14887
|
}
|
|
14851
14888
|
return n;
|
|
14852
14889
|
}
|
|
14853
|
-
function
|
|
14890
|
+
function S_(e) {
|
|
14854
14891
|
let t = {};
|
|
14855
|
-
for (let [n, r] of Object.entries(e))
|
|
14892
|
+
for (let [n, r] of Object.entries(e)) b_.test(n) && (t[n] = {
|
|
14856
14893
|
description: r.description,
|
|
14857
14894
|
hasParams: !!r.params,
|
|
14858
14895
|
readsHostState: r.readsHostState === !0,
|
|
@@ -14862,11 +14899,11 @@ function x_(e) {
|
|
|
14862
14899
|
}
|
|
14863
14900
|
//#endregion
|
|
14864
14901
|
//#region src/core/toolsets.ts
|
|
14865
|
-
var
|
|
14866
|
-
function
|
|
14902
|
+
var C_ = Lg, w_ = Yg;
|
|
14903
|
+
function T_(e, t) {
|
|
14867
14904
|
return hf(e, t);
|
|
14868
14905
|
}
|
|
14869
|
-
function
|
|
14906
|
+
function E_(e, t, n, r, i) {
|
|
14870
14907
|
let a = bm(e);
|
|
14871
14908
|
return [
|
|
14872
14909
|
...a.dataOps ? t : [],
|
|
@@ -14877,13 +14914,13 @@ function T_(e, t, n, r, i) {
|
|
|
14877
14914
|
}
|
|
14878
14915
|
//#endregion
|
|
14879
14916
|
//#region src/core/harness/usageHints.ts
|
|
14880
|
-
var
|
|
14881
|
-
function
|
|
14882
|
-
if (!Number.isFinite(t) || t <= 0 || e <= 0 || e < t *
|
|
14917
|
+
var D_ = .7, O_ = .5, k_ = .85;
|
|
14918
|
+
function A_(e, t) {
|
|
14919
|
+
if (!Number.isFinite(t) || t <= 0 || e <= 0 || e < t * O_) return "";
|
|
14883
14920
|
let n = Math.max(1, Math.round(e / 1e3));
|
|
14884
|
-
return e >= t *
|
|
14921
|
+
return e >= t * k_ ? `⏳ 预算告急:本任务累计约 ${n}K prompt tokens(已达 softCap 上限的 ${Math.round(k_ * 100)}%)。立即停止扩展性操作(新查询/重读/优化),完成手头最关键一步后基于已有工具结果给出结论,并如实汇报剩余未完成项。轮次预算吃紧时系统会另行注入轮次提示段。` : `⏳ 预算提示:本任务累计约 ${n}K prompt tokens(已过 softCap 半程)。若已接近目标请收敛并给出总结;尚未接近请向用户汇报进度与剩余计划,勿默默继续。轮次预算吃紧时系统会另行注入轮次提示段。`;
|
|
14885
14922
|
}
|
|
14886
|
-
function
|
|
14923
|
+
function j_(e, t, n) {
|
|
14887
14924
|
let r = bm(e);
|
|
14888
14925
|
return {
|
|
14889
14926
|
name: "usageHints",
|
|
@@ -14894,13 +14931,13 @@ function A_(e, t, n) {
|
|
|
14894
14931
|
a.push(`回答用户关于当前页面/文档的问题时优先用 read_page({selector?,offset?,limit?}) 读页面正文纯文本(长文按 hasMore 分页续读;自动排除本对话框自身);需要页面结构(检查渲染是否生效/定位元素/辅助 UI 设计问答)再用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。${n}`);
|
|
14895
14932
|
}
|
|
14896
14933
|
if (e?.screenshot && a.push("视觉验证(看布局/样式/渲染效果像不像、对不对)用 take_screenshot({selector?, fullPage?}) 截图查看:selector 截指定元素、fullPage 截整页、默认当前视口;截图自动压缩投递(多模态直看图/纯文本模型走识图转述)。优先级:视觉问题先截图,结构/属性问题用 dom_info。"), e?.domEdit && a.push("修改宿主页面元素(高亮/改文案/调样式/插删移元素)用 dom_edit({patches:[{op,selector,...}],dryRun?}) 批量原子操作(op:set_text/set_html/set_attr/add_class/remove_class/set_style/insert/remove/move/highlight);selector 必须唯一命中(先 get_dom/dom_search 定位);改前自动快照,dom_restore 回滚最近一批;改动为会话临时态(刷新即失)——数据驱动页面改数据(write)不要改 DOM。"), e?.viewImage && a.push("看「页面数据里的某张图」(轮播第 N 帧/商品图/封面,read 结果里有其 URL)用 view_image({url}) 原图直投 —— 问特定帧时勿截当前渲染帧(自动轮播可能已切帧);要看渲染后的组件(布局/叠加文案)才用 take_screenshot。"), e?.hasProposals && a.push("【内容修改(提案制)】修改当前内容(文章/笔记/文档)只有一条通道:①先 read_content 取真实原文与 hash;②propose_content 带 baseHash 提案 —— 优先 ops 增量操作(replace/insertAfter/insertBefore/append,find/anchor 用原文字面片段且须唯一命中,多带上下文保唯一),勿全量重发整篇(token 只花在改动上);③提案仅送达:评审面板打开、用户点「应用」才会写回 —— 提案后如实告知用户待确认,勿声称已修改;用户裁决结果会在下一轮告知你,以裁决为准作答。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read 查。")), e?.subagents?.length) {
|
|
14897
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
14934
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= D_ || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < D_ && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
14898
14935
|
a.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (a.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), a.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && a.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), a.push(" · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), a.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
14899
14936
|
}
|
|
14900
14937
|
e?.humanConfirm && (a.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), a.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), a.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), a.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), a.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), a.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
14901
14938
|
let o = i?.loopProgress;
|
|
14902
14939
|
if (o) {
|
|
14903
|
-
let e =
|
|
14940
|
+
let e = A_(o.invokeUsage.prompt_tokens || o.invokeUsage.total_tokens, n?.promptSoftCap ?? Infinity);
|
|
14904
14941
|
e && a.push(e);
|
|
14905
14942
|
let t = Object.entries(o.writeFailures).filter(([, e]) => e >= 2);
|
|
14906
14943
|
if (t.length) {
|
|
@@ -14914,7 +14951,7 @@ function A_(e, t, n) {
|
|
|
14914
14951
|
}
|
|
14915
14952
|
//#endregion
|
|
14916
14953
|
//#region src/core/harness/pageContext.ts
|
|
14917
|
-
function
|
|
14954
|
+
function M_(e, t) {
|
|
14918
14955
|
let n = [
|
|
14919
14956
|
"[当前页面] 用户正在浏览:",
|
|
14920
14957
|
`- 标题:${e.title}`,
|
|
@@ -14923,18 +14960,18 @@ function j_(e, t) {
|
|
|
14923
14960
|
];
|
|
14924
14961
|
return t && n.push("需要页面正文时用 read_page 读取纯文本(长文按 hasMore 分页续读);读结构用 get_dom。"), n.join("\n");
|
|
14925
14962
|
}
|
|
14926
|
-
function
|
|
14963
|
+
function N_(e) {
|
|
14927
14964
|
return {
|
|
14928
14965
|
name: "pageContext",
|
|
14929
14966
|
augmentPrompt: () => {
|
|
14930
14967
|
let t = e.getPageInfo();
|
|
14931
|
-
if (t) return
|
|
14968
|
+
if (t) return M_(t, e.canReadPage);
|
|
14932
14969
|
}
|
|
14933
14970
|
};
|
|
14934
14971
|
}
|
|
14935
14972
|
//#endregion
|
|
14936
14973
|
//#region src/core/harness/resourcesPin.ts
|
|
14937
|
-
function
|
|
14974
|
+
function P_(e) {
|
|
14938
14975
|
return {
|
|
14939
14976
|
name: "resourcesPin",
|
|
14940
14977
|
augmentPrompt: () => {
|
|
@@ -14948,15 +14985,15 @@ function N_(e) {
|
|
|
14948
14985
|
}
|
|
14949
14986
|
//#endregion
|
|
14950
14987
|
//#region src/core/backends/skillStore.ts
|
|
14951
|
-
var
|
|
14952
|
-
function
|
|
14953
|
-
return `${
|
|
14988
|
+
var F_ = "v:1::skill-store", I_ = "chat-sdk";
|
|
14989
|
+
function L_(e, t, n) {
|
|
14990
|
+
return `${F_}::${e}::${t}::${n}`;
|
|
14954
14991
|
}
|
|
14955
|
-
function
|
|
14956
|
-
return `${
|
|
14992
|
+
function R_(e, t) {
|
|
14993
|
+
return `${F_}::${e}::${t}::`;
|
|
14957
14994
|
}
|
|
14958
|
-
function
|
|
14959
|
-
let t = e.dbName ??
|
|
14995
|
+
function z_(e = {}) {
|
|
14996
|
+
let t = e.dbName ?? I_, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
14960
14997
|
a = e;
|
|
14961
14998
|
});
|
|
14962
14999
|
return (async () => {
|
|
@@ -14978,36 +15015,36 @@ function R_(e = {}) {
|
|
|
14978
15015
|
ready: o,
|
|
14979
15016
|
async list() {
|
|
14980
15017
|
let e = [];
|
|
14981
|
-
return await i.scan(
|
|
15018
|
+
return await i.scan(R_(t, r), (t, n) => {
|
|
14982
15019
|
e.push(n);
|
|
14983
15020
|
}), e;
|
|
14984
15021
|
},
|
|
14985
15022
|
async get(e) {
|
|
14986
|
-
return await i.get(
|
|
15023
|
+
return await i.get(L_(t, r, e));
|
|
14987
15024
|
},
|
|
14988
15025
|
async put(e) {
|
|
14989
15026
|
try {
|
|
14990
|
-
await i.set(
|
|
15027
|
+
await i.set(L_(t, r, e.name), e);
|
|
14991
15028
|
} catch (e) {
|
|
14992
15029
|
nm(e) && (i = um());
|
|
14993
15030
|
}
|
|
14994
15031
|
},
|
|
14995
15032
|
async remove(e) {
|
|
14996
|
-
let n =
|
|
15033
|
+
let n = L_(t, r, e);
|
|
14997
15034
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
14998
15035
|
},
|
|
14999
15036
|
async clear() {
|
|
15000
|
-
await i.clearPrefix(
|
|
15037
|
+
await i.clearPrefix(R_(t, r));
|
|
15001
15038
|
},
|
|
15002
15039
|
dispose() {}
|
|
15003
15040
|
};
|
|
15004
15041
|
}
|
|
15005
|
-
var
|
|
15006
|
-
function
|
|
15042
|
+
var B_ = /large_results\/[^\s"'`),]+\.txt/g;
|
|
15043
|
+
function V_(e) {
|
|
15007
15044
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
15008
15045
|
if (typeof e != "string" || !e) return;
|
|
15009
15046
|
let n;
|
|
15010
|
-
for (
|
|
15047
|
+
for (B_.lastIndex = 0; (n = B_.exec(e)) !== null;) t.add(n[0]);
|
|
15011
15048
|
};
|
|
15012
15049
|
for (let r of e) {
|
|
15013
15050
|
if (n(r.content), r.steps) for (let e of r.steps) n(e.result);
|
|
@@ -15015,14 +15052,14 @@ function B_(e) {
|
|
|
15015
15052
|
}
|
|
15016
15053
|
return t;
|
|
15017
15054
|
}
|
|
15018
|
-
function
|
|
15055
|
+
function H_(e, t) {
|
|
15019
15056
|
let n = [];
|
|
15020
15057
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
15021
15058
|
return n;
|
|
15022
15059
|
}
|
|
15023
15060
|
//#endregion
|
|
15024
15061
|
//#region src/core/utils/serialRunner.ts
|
|
15025
|
-
function
|
|
15062
|
+
function U_() {
|
|
15026
15063
|
let e = Promise.resolve();
|
|
15027
15064
|
return function(t) {
|
|
15028
15065
|
let n = e.then(t, t);
|
|
@@ -15031,24 +15068,24 @@ function H_() {
|
|
|
15031
15068
|
}
|
|
15032
15069
|
//#endregion
|
|
15033
15070
|
//#region src/core/sdk/createChatSdk.ts
|
|
15034
|
-
var
|
|
15035
|
-
function
|
|
15071
|
+
var W_ = 30, G_ = /* @__PURE__ */ new Map();
|
|
15072
|
+
function K_(e, t) {
|
|
15036
15073
|
return e === "restore_data" ? "restore" : e === "write" ? t?.dryRun ? null : t?.del ? "delete" : t?.patch || t?.patches ? "edit" : "set" : e === "eval_script" ? t?.mode === "transform" ? "edit" : null : e === "draft_commit" || e === "resource_update" ? "edit" : null;
|
|
15037
15074
|
}
|
|
15038
|
-
function
|
|
15075
|
+
function q_(e) {
|
|
15039
15076
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
15040
15077
|
}
|
|
15041
|
-
function
|
|
15078
|
+
function J_(e, t, n, r) {
|
|
15042
15079
|
let i = 0;
|
|
15043
15080
|
return {
|
|
15044
15081
|
name: "sdk-events",
|
|
15045
15082
|
wrapToolCall: async (t, r) => {
|
|
15046
|
-
let i = await r(t), a =
|
|
15083
|
+
let i = await r(t), a = K_(t.name, t.args), o = typeof i.content == "string" && i.content.startsWith("ERROR:");
|
|
15047
15084
|
return a && !o ? e({
|
|
15048
15085
|
type: "data_change",
|
|
15049
15086
|
operation: a,
|
|
15050
15087
|
value: n()?.bind
|
|
15051
|
-
}) : i.status === "done" && !o &&
|
|
15088
|
+
}) : i.status === "done" && !o && q_(t.name) && e({
|
|
15052
15089
|
type: "data_change",
|
|
15053
15090
|
operation: "edit",
|
|
15054
15091
|
value: n()?.bind
|
|
@@ -15076,7 +15113,7 @@ function q_(e, t, n, r) {
|
|
|
15076
15113
|
}
|
|
15077
15114
|
};
|
|
15078
15115
|
}
|
|
15079
|
-
function
|
|
15116
|
+
function Y_(e, t, n, r, i) {
|
|
15080
15117
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
15081
15118
|
ok: !1,
|
|
15082
15119
|
error: "capabilities.focus 关闭"
|
|
@@ -15094,7 +15131,7 @@ function J_(e, t, n, r, i) {
|
|
|
15094
15131
|
error: "当前无主数据 schema,无法聚焦"
|
|
15095
15132
|
});
|
|
15096
15133
|
}
|
|
15097
|
-
function
|
|
15134
|
+
function X_(e, n, r) {
|
|
15098
15135
|
let a = {
|
|
15099
15136
|
prompt_tokens: 0,
|
|
15100
15137
|
completion_tokens: 0,
|
|
@@ -15176,47 +15213,47 @@ function Y_(e, n, r) {
|
|
|
15176
15213
|
} : e;
|
|
15177
15214
|
}, se = fu(), M = pu(e.memory || "");
|
|
15178
15215
|
typeof e.memory == "function" && M.refresh();
|
|
15179
|
-
let
|
|
15216
|
+
let ce = { current: null }, N = e.data ? {
|
|
15180
15217
|
...e.data,
|
|
15181
15218
|
description: e.data.description ?? "主数据对象"
|
|
15182
|
-
} : void 0,
|
|
15183
|
-
|
|
15184
|
-
let
|
|
15185
|
-
for (let e of
|
|
15219
|
+
} : void 0, P = !(e.subagents ?? []).some((e) => e._codeAsset) && bm(e.capabilities).subagent, F = e.subagents;
|
|
15220
|
+
P && N?.schema && Js(N.schema).length && (F = [...e.subagents ?? [], Cp()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
15221
|
+
let le = (F ?? []).filter((e) => !!e._codeAsset), I = /* @__PURE__ */ new Set();
|
|
15222
|
+
for (let e of le) {
|
|
15186
15223
|
if (e._codeAsset.writablePaths.length) continue;
|
|
15187
|
-
let t = Js(
|
|
15188
|
-
t.length ? (e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), e._rebuildCodeAssetPaths?.(t[0]), console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map((e) => `'${e}'`).join(", ")}]`)) : (console.warn("[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])"),
|
|
15224
|
+
let t = Js(N?.schema, e._codeAsset.codeField);
|
|
15225
|
+
t.length ? (e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), e._rebuildCodeAssetPaths?.(t[0]), console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map((e) => `'${e}'`).join(", ")}]`)) : (console.warn("[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])"), I.add(e));
|
|
15189
15226
|
}
|
|
15190
|
-
let
|
|
15227
|
+
let L = I.size ? le.filter((e) => !I.has(e)) : le, ue = I.size ? (F ?? []).filter((e) => !I.has(e)) : F, de = L.length > 0, fe = L.flatMap((e) => e._codeAsset.writablePaths), pe = L.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), me = e.checkpoint, he = me !== void 0 && me !== !1, R = he ? Mu({
|
|
15191
15228
|
getData: () => U()?.bind,
|
|
15192
15229
|
consumeDataDirty: () => H?.consumeDataDirty?.() ?? !0,
|
|
15193
|
-
slotPaths:
|
|
15230
|
+
slotPaths: N ? [""] : [],
|
|
15194
15231
|
vfsStore: T,
|
|
15195
15232
|
todosMw: D,
|
|
15196
|
-
getTodos: () =>
|
|
15233
|
+
getTodos: () => ce.current?.getState?.()?.todos ?? [],
|
|
15197
15234
|
messages: w,
|
|
15198
|
-
maxCheckpoints:
|
|
15199
|
-
}) : null, z = !
|
|
15235
|
+
maxCheckpoints: me && typeof me == "object" ? me.maxCheckpoints : void 0
|
|
15236
|
+
}) : null, z = !me || typeof me != "object" || me.auto !== !1, B = bm(e.capabilities), ge = B.dataOps, _e = B.draftWrite, ve = B.automation, ye = B.domInspect && (g.vision === !0 || typeof e.images?.describe == "function"), be = _d({
|
|
15200
15237
|
...e,
|
|
15201
15238
|
locale: e.i18n?.locale,
|
|
15202
|
-
dataOps: ge && !!
|
|
15239
|
+
dataOps: ge && !!N,
|
|
15203
15240
|
domInspect: B.domInspect === !0,
|
|
15204
15241
|
screenshot: ye
|
|
15205
15242
|
});
|
|
15206
|
-
if (
|
|
15207
|
-
let e =
|
|
15243
|
+
if (de) {
|
|
15244
|
+
let e = L.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
15208
15245
|
e && (be += "\n\n" + e);
|
|
15209
|
-
} else
|
|
15210
|
-
let V = ge &&
|
|
15246
|
+
} else N?.schema && qs(N.schema) && (be += "\n\n" + dc.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
15247
|
+
let V = ge && N ? hf(N, {
|
|
15211
15248
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
15212
15249
|
maxSnapshots: e.maxSnapshots,
|
|
15213
15250
|
onConflict: o.set,
|
|
15214
15251
|
conflictWatchFields: e.conflictWatchFields,
|
|
15215
15252
|
maxParallelTools: e.maxParallelTools,
|
|
15216
|
-
vfsStore: _e ||
|
|
15217
|
-
...
|
|
15218
|
-
...
|
|
15219
|
-
}) : [], xe = ge ? V : [], H = ge &&
|
|
15253
|
+
vfsStore: _e || N?.resources?.length ? T : void 0,
|
|
15254
|
+
...fe.length ? { pgIdPaths: fe } : {},
|
|
15255
|
+
...pe.length ? { largeTextPaths: pe } : {}
|
|
15256
|
+
}) : [], xe = ge ? V : [], H = ge && N ? V.controller ?? null : null, Se = ge && N ? V.previewWrite : void 0, Ce = ge && N?.resources?.length && H?.getResourcesSnapshot ? P_({ getResourcesSnapshot: () => H?.getResourcesSnapshot?.() ?? [] }) : void 0, U = () => H?.get() ?? N, we = new Set(V.map((e) => e.name)), Te = e.conflictWatchFields ?? [], Ee = !Te.includes("*") && Te.length ? new Set(Te) : void 0, W = H ? Jf({
|
|
15220
15257
|
getBind: () => U()?.bind,
|
|
15221
15258
|
recomputeAll: () => H.recomputeAllBaselines?.(),
|
|
15222
15259
|
hasBaselines: () => H.hasBaselines?.() ?? !1,
|
|
@@ -15244,7 +15281,7 @@ function Y_(e, n, r) {
|
|
|
15244
15281
|
} });
|
|
15245
15282
|
}
|
|
15246
15283
|
return e;
|
|
15247
|
-
}, Ae = g.vision === !0 || typeof e.images?.describe == "function" ?
|
|
15284
|
+
}, Ae = g.vision === !0 || typeof e.images?.describe == "function" ? sg({
|
|
15248
15285
|
getVision: () => g.vision === !0,
|
|
15249
15286
|
describe: e.images?.describe,
|
|
15250
15287
|
onShot: (e, t) => {
|
|
@@ -15253,7 +15290,7 @@ function Y_(e, n, r) {
|
|
|
15253
15290
|
meta: t
|
|
15254
15291
|
});
|
|
15255
15292
|
}
|
|
15256
|
-
}) : void 0, je = ye ?
|
|
15293
|
+
}) : void 0, je = ye ? ag({
|
|
15257
15294
|
render: e.screenshot?.renderer,
|
|
15258
15295
|
getActiveFocus: () => X.getFocus(),
|
|
15259
15296
|
focusSelector: e.screenshot?.focusSelector,
|
|
@@ -15288,7 +15325,7 @@ function Y_(e, n, r) {
|
|
|
15288
15325
|
}
|
|
15289
15326
|
return t(e);
|
|
15290
15327
|
}
|
|
15291
|
-
} : null, Pe = !1, Fe = B.domEdit ?
|
|
15328
|
+
} : null, Pe = !1, Fe = B.domEdit ? bg({
|
|
15292
15329
|
onEdit: (e) => {
|
|
15293
15330
|
X.agent?.debugLogs?.value?.push({
|
|
15294
15331
|
timestamp: Date.now(),
|
|
@@ -15304,14 +15341,14 @@ function Y_(e, n, r) {
|
|
|
15304
15341
|
onRestore: (e) => {
|
|
15305
15342
|
e.restored > 0 && (Pe = !0);
|
|
15306
15343
|
}
|
|
15307
|
-
}) : [], Ie = [...
|
|
15308
|
-
...
|
|
15344
|
+
}) : [], Ie = [...E_(B, xe, Lg, B.domInspect ? [
|
|
15345
|
+
...Yg,
|
|
15309
15346
|
...Fe,
|
|
15310
15347
|
...je ? [je] : [],
|
|
15311
|
-
...B.skills ? [] : [
|
|
15312
|
-
] : [],
|
|
15348
|
+
...B.skills ? [] : [a_, o_]
|
|
15349
|
+
] : [], v_), ...Ae ? [Ae] : []];
|
|
15313
15350
|
Ae && De.set("view_image", "builtin"), Ie.forEach((e) => De.set(e.name, "builtin"));
|
|
15314
|
-
let Le = e.proposals ?
|
|
15351
|
+
let Le = e.proposals ? Fg(e.proposals, {
|
|
15315
15352
|
emit: (e) => {
|
|
15316
15353
|
try {
|
|
15317
15354
|
J(e);
|
|
@@ -15330,19 +15367,19 @@ function Y_(e, n, r) {
|
|
|
15330
15367
|
}
|
|
15331
15368
|
}) : null, Re = [...e.tools || [], ...Le?.tools ?? []];
|
|
15332
15369
|
Re.forEach((e) => De.set(e.name, "user"));
|
|
15333
|
-
let ze =
|
|
15370
|
+
let ze = x_(e.actions ?? {});
|
|
15334
15371
|
ze.forEach((e) => De.set(e.name, "action"));
|
|
15335
15372
|
let Be = Le ? e.proposals?.readToolName || "read_content" : null, Ve = Le ? e.proposals?.toolName || "propose_content" : null, He = /* @__PURE__ */ new Set([...Object.entries(e.actions ?? {}).filter(([, e]) => e?.readsHostState === !0).map(([e]) => e), ...Be ? [Be] : []]), Ue = /* @__PURE__ */ new Set([...Object.entries(e.actions ?? {}).filter(([, e]) => e?.deferredWrite === !0).map(([e]) => e), ...Ve ? [Ve] : []]), We = [], Ge = !1, Ke = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), qe = Ke ? Cu() : null;
|
|
15336
15373
|
qe && De.set(xu, "builtin");
|
|
15337
|
-
let Je =
|
|
15338
|
-
let e =
|
|
15339
|
-
return e.length ?
|
|
15374
|
+
let Je = he && R ? [s(async () => {
|
|
15375
|
+
let e = R.list();
|
|
15376
|
+
return e.length ? R.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
15340
15377
|
}, {
|
|
15341
15378
|
name: "restore_last_checkpoint",
|
|
15342
15379
|
description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
15343
15380
|
schema: t.object({}).optional()
|
|
15344
15381
|
}), s(async () => {
|
|
15345
|
-
let e =
|
|
15382
|
+
let e = R.list();
|
|
15346
15383
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
|
|
15347
15384
|
}, {
|
|
15348
15385
|
name: "list_checkpoints",
|
|
@@ -15409,7 +15446,7 @@ function Y_(e, n, r) {
|
|
|
15409
15446
|
focusTools: () => et,
|
|
15410
15447
|
mcpTools: () => We,
|
|
15411
15448
|
loadedSkillTools: () => tt
|
|
15412
|
-
}), G = rt(), it = B.planning, at = B.missionAnchor, ot = B.workingMemory, st = B.skills, ct = B.vfs ||
|
|
15449
|
+
}), G = rt(), it = B.planning, at = B.missionAnchor, ot = B.workingMemory, st = B.skills, ct = B.vfs || de;
|
|
15413
15450
|
if (ct) for (let e of Dd) De.set(e, "builtin");
|
|
15414
15451
|
if (it) for (let e of D.tools ?? []) De.set(e.name, "builtin");
|
|
15415
15452
|
let lt = B.summarization, ut = B.agentCompression && !!m;
|
|
@@ -15449,7 +15486,7 @@ function Y_(e, n, r) {
|
|
|
15449
15486
|
a.prompt_tokens = (a.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), a.completion_tokens = (a.completion_tokens ?? 0) + (e.completion_tokens ?? 0), a.total_tokens = (a.total_tokens ?? 0) + (e.total_tokens ?? 0), e.reasoning_tokens && (a.reasoning_tokens = (a.reasoning_tokens ?? 0) + e.reasoning_tokens);
|
|
15450
15487
|
},
|
|
15451
15488
|
timeoutMs: yt?.timeoutMs
|
|
15452
|
-
}), Tt =
|
|
15489
|
+
}), Tt = ue?.map((e) => {
|
|
15453
15490
|
if (!e._codeAsset) return e;
|
|
15454
15491
|
let t = e._codeAsset, n = Nf({
|
|
15455
15492
|
writablePaths: t.writablePaths,
|
|
@@ -15466,12 +15503,12 @@ function Y_(e, n, r) {
|
|
|
15466
15503
|
...e,
|
|
15467
15504
|
middleware: r
|
|
15468
15505
|
};
|
|
15469
|
-
}), Et =
|
|
15506
|
+
}), Et = de && ft ? Pf() : void 0, Dt = Et ? Vf({
|
|
15470
15507
|
getBind: () => U()?.bind,
|
|
15471
|
-
writablePaths:
|
|
15508
|
+
writablePaths: fe,
|
|
15472
15509
|
getLocked: () => Et.locked(),
|
|
15473
15510
|
tools: G,
|
|
15474
|
-
getCodeFieldPaths: () => zf(U()?.bind,
|
|
15511
|
+
getCodeFieldPaths: () => zf(U()?.bind, L.map((e) => ({
|
|
15475
15512
|
writablePaths: e._codeAsset.writablePaths,
|
|
15476
15513
|
codeField: e._codeAsset.codeField
|
|
15477
15514
|
})))
|
|
@@ -15498,7 +15535,7 @@ function Y_(e, n, r) {
|
|
|
15498
15535
|
timeoutMs: e.subagent?.timeoutMs,
|
|
15499
15536
|
...Et ? {
|
|
15500
15537
|
componentLock: Et,
|
|
15501
|
-
resolveComponents: (e) => Ff(e, kf(U()?.bind,
|
|
15538
|
+
resolveComponents: (e) => Ff(e, kf(U()?.bind, fe))
|
|
15502
15539
|
} : {}
|
|
15503
15540
|
}) : void 0, At = kt ? kt.controller : null, jt = (t) => {
|
|
15504
15541
|
let n = t.thinkingMode ?? e.subagent?.thinkingMode, r = n ? Ap(t.llm ?? e.llm) ? "instance-noop" : "applied" : "inherited";
|
|
@@ -15519,7 +15556,7 @@ function Y_(e, n, r) {
|
|
|
15519
15556
|
}) : void 0, It = vt ? td({
|
|
15520
15557
|
contextWindow: g.contextWindow,
|
|
15521
15558
|
thresholdRatio: wm(e, g.contextWindow).summaryThresholdRatio
|
|
15522
|
-
}) : void 0, Lt =
|
|
15559
|
+
}) : void 0, Lt = j_({
|
|
15523
15560
|
...B,
|
|
15524
15561
|
humanConfirm: Ke,
|
|
15525
15562
|
screenshot: !!je,
|
|
@@ -15527,8 +15564,8 @@ function Y_(e, n, r) {
|
|
|
15527
15564
|
hasActions: !!e.actions && Object.keys(e.actions).length > 0,
|
|
15528
15565
|
hasProposals: !!e.proposals,
|
|
15529
15566
|
viewImage: !!Ae,
|
|
15530
|
-
subagents:
|
|
15531
|
-
}, ge && !!
|
|
15567
|
+
subagents: ue?.map(jt)
|
|
15568
|
+
}, ge && !!N, { promptSoftCap: Nl(g.contextWindow, y.promptSoftCapTokens) }), Rt = B.pageContext ? N_({
|
|
15532
15569
|
getPageInfo: () => typeof document < "u" && typeof location < "u" ? {
|
|
15533
15570
|
title: document.title || "",
|
|
15534
15571
|
url: location.href
|
|
@@ -15592,7 +15629,7 @@ function Y_(e, n, r) {
|
|
|
15592
15629
|
afterAgent: () => {
|
|
15593
15630
|
Le.state.notices.length = 0;
|
|
15594
15631
|
}
|
|
15595
|
-
} : null, q =
|
|
15632
|
+
} : null, q = N ? {
|
|
15596
15633
|
name: "dataHint",
|
|
15597
15634
|
augmentPrompt: () => gd(U(), e.schemaHint) || void 0
|
|
15598
15635
|
} : null, Ht = e.augmentSystem ? {
|
|
@@ -15616,7 +15653,7 @@ function Y_(e, n, r) {
|
|
|
15616
15653
|
name: e.name,
|
|
15617
15654
|
description: e.description,
|
|
15618
15655
|
getContent: () => e.content
|
|
15619
|
-
}), Yt = e.skillStorage === !1 ? null :
|
|
15656
|
+
}), Yt = e.skillStorage === !1 ? null : z_({
|
|
15620
15657
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
15621
15658
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
15622
15659
|
}), Xt = () => {
|
|
@@ -15649,12 +15686,12 @@ function Y_(e, n, r) {
|
|
|
15649
15686
|
getSnapshot: () => It?.getSnapshot()
|
|
15650
15687
|
} : {}
|
|
15651
15688
|
}) : void 0, $t = st ? fl([
|
|
15652
|
-
...B.domInspect && !(e.skills || []).some((e) => e.name === "dom-inspect") ? [
|
|
15689
|
+
...B.domInspect && !(e.skills || []).some((e) => e.name === "dom-inspect") ? [c_({
|
|
15653
15690
|
withScreenshot: !!je,
|
|
15654
15691
|
withDomEdit: B.domEdit,
|
|
15655
|
-
withDataOps: ge && !!
|
|
15692
|
+
withDataOps: ge && !!N
|
|
15656
15693
|
})] : [],
|
|
15657
|
-
...B.domInspect && !(e.skills || []).some((e) => e.name === "page-analysis") ? [
|
|
15694
|
+
...B.domInspect && !(e.skills || []).some((e) => e.name === "page-analysis") ? [u_({
|
|
15658
15695
|
withScreenshot: !!je,
|
|
15659
15696
|
withDomEdit: B.domEdit,
|
|
15660
15697
|
withVfs: ct
|
|
@@ -15689,7 +15726,7 @@ function Y_(e, n, r) {
|
|
|
15689
15726
|
...Ce ? [Ce] : [],
|
|
15690
15727
|
...dt ? [M] : [],
|
|
15691
15728
|
...xt ? [xt] : [],
|
|
15692
|
-
...
|
|
15729
|
+
...he && z && R ? [Nu(R)] : [],
|
|
15693
15730
|
...Ke ? [oe] : [],
|
|
15694
15731
|
...St ? [St] : [],
|
|
15695
15732
|
...W ? [W] : [],
|
|
@@ -15706,18 +15743,18 @@ function Y_(e, n, r) {
|
|
|
15706
15743
|
...It ? [It] : [],
|
|
15707
15744
|
...Ne ? [Ne] : [],
|
|
15708
15745
|
...e.middleware || [],
|
|
15709
|
-
...ve ? [
|
|
15746
|
+
...ve ? [y_(a, {
|
|
15710
15747
|
tokenBudget: e.tokenBudget,
|
|
15711
15748
|
timeBudgetMs: e.timeBudgetMs
|
|
15712
15749
|
}, J)] : [],
|
|
15713
|
-
|
|
15714
|
-
]), tn = e.maxMemoryRounds ??
|
|
15750
|
+
J_(J, w, U, a)
|
|
15751
|
+
]), tn = e.maxMemoryRounds ?? W_;
|
|
15715
15752
|
function nn(e) {
|
|
15716
15753
|
return (e) => {
|
|
15717
15754
|
e.type !== "approval_request" && J(ke(e));
|
|
15718
15755
|
};
|
|
15719
15756
|
}
|
|
15720
|
-
let rn = /* @__PURE__ */ Wt([]), an =
|
|
15757
|
+
let rn = /* @__PURE__ */ Wt([]), an = U_(), on = /* @__PURE__ */ new Set();
|
|
15721
15758
|
function sn(e) {
|
|
15722
15759
|
let t = new AbortController(), n = () => t.abort();
|
|
15723
15760
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), on.add(t), {
|
|
@@ -15749,7 +15786,7 @@ function Y_(e, n, r) {
|
|
|
15749
15786
|
mcpClosers: [],
|
|
15750
15787
|
mcpServers: [],
|
|
15751
15788
|
mcpFailed: [],
|
|
15752
|
-
checkpoint:
|
|
15789
|
+
checkpoint: R,
|
|
15753
15790
|
dataOpsController: H,
|
|
15754
15791
|
skillsController: Y ? Y.controller : null,
|
|
15755
15792
|
infoTick: c,
|
|
@@ -15775,7 +15812,7 @@ function Y_(e, n, r) {
|
|
|
15775
15812
|
G = rt(), X.agent && X.agent.setTools(G);
|
|
15776
15813
|
},
|
|
15777
15814
|
applySnapshot(t) {
|
|
15778
|
-
if (t.vfs && T.hydrate && T.hydrate(t.vfs), t.messages?.length && (w.push(...Ci(t.messages, (e) => (e ? X.vfsStore?.files?.[e]?.content : void 0) || void 0)), te.markResumed()), t.todos?.length && D.reset(t.todos), t.memory && !e.memory && M.reset(t.memory), t.checkpoints?.length &&
|
|
15815
|
+
if (t.vfs && T.hydrate && T.hydrate(t.vfs), t.messages?.length && (w.push(...Ci(t.messages, (e) => (e ? X.vfsStore?.files?.[e]?.content : void 0) || void 0)), te.markResumed()), t.todos?.length && D.reset(t.todos), t.memory && !e.memory && M.reset(t.memory), t.checkpoints?.length && R && R.importStack(t.checkpoints), t.usage && Object.assign(a, t.usage), t.mission && at && O.setMission(t.mission), t.workingMemory && ot && se.restore(t.workingMemory), t.planConfirmation && (ne.lastPlanConfirmation = t.planConfirmation), Ye) {
|
|
15779
15816
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
15780
15817
|
if (r.length) {
|
|
15781
15818
|
let t = U()?.schema, n = t ? r.filter((e) => Is(t, e.path)) : [];
|
|
@@ -15827,7 +15864,7 @@ function Y_(e, n, r) {
|
|
|
15827
15864
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
15828
15865
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
15829
15866
|
}
|
|
15830
|
-
T?.setProtectedRefs?.(
|
|
15867
|
+
T?.setProtectedRefs?.(V_(w));
|
|
15831
15868
|
let i = ve ? t.maxAutoRetries ?? 1 : 0, a = 0, s = !1, c = nn(t.signal);
|
|
15832
15869
|
if (t.signal) {
|
|
15833
15870
|
let e = () => o.resolve("keep_external");
|
|
@@ -15888,8 +15925,8 @@ function Y_(e, n, r) {
|
|
|
15888
15925
|
...n,
|
|
15889
15926
|
code: "MODEL_UNAVAILABLE",
|
|
15890
15927
|
message: e instanceof Error ? e.message : n.message
|
|
15891
|
-
}), a < i &&
|
|
15892
|
-
a += 1,
|
|
15928
|
+
}), a < i && R?.canRestore()) {
|
|
15929
|
+
a += 1, R.restore(), s = !0, J({
|
|
15893
15930
|
type: "error",
|
|
15894
15931
|
message: `致命错误自动恢复(${a}/${i}):${n.message},已回退 checkpoint 重试`,
|
|
15895
15932
|
severity: "observable",
|
|
@@ -15915,7 +15952,7 @@ function Y_(e, n, r) {
|
|
|
15915
15952
|
if (await X.initDone, !e.length) return [];
|
|
15916
15953
|
if (X.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
15917
15954
|
let r = [], i = nn(n);
|
|
15918
|
-
if (T?.setProtectedRefs?.(
|
|
15955
|
+
if (T?.setProtectedRefs?.(V_(w)), n) {
|
|
15919
15956
|
let e = () => o.resolve("keep_external");
|
|
15920
15957
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
15921
15958
|
}
|
|
@@ -15930,7 +15967,7 @@ function Y_(e, n, r) {
|
|
|
15930
15967
|
break;
|
|
15931
15968
|
}
|
|
15932
15969
|
let o = e[a];
|
|
15933
|
-
|
|
15970
|
+
R && R.save(`batch:${a}`);
|
|
15934
15971
|
let s = w.length;
|
|
15935
15972
|
try {
|
|
15936
15973
|
w.push({
|
|
@@ -16022,7 +16059,7 @@ function Y_(e, n, r) {
|
|
|
16022
16059
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
16023
16060
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
16024
16061
|
}
|
|
16025
|
-
T?.setProtectedRefs?.(
|
|
16062
|
+
T?.setProtectedRefs?.(V_(e));
|
|
16026
16063
|
let i = (e) => {
|
|
16027
16064
|
t?.(ke(e)), J(ke(e)), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && X.infoTick.value++;
|
|
16028
16065
|
};
|
|
@@ -16037,7 +16074,7 @@ function Y_(e, n, r) {
|
|
|
16037
16074
|
if (X.refCount--, X.refCount <= 0) {
|
|
16038
16075
|
cn(), Ge = !0, l && (T.flush?.(), l.flush(), l.dispose()), Yt && Yt.dispose();
|
|
16039
16076
|
let e = X.mcpClosers.splice(0);
|
|
16040
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
16077
|
+
e.length && Promise.allSettled(e.map((e) => e())), G_.delete(n);
|
|
16041
16078
|
}
|
|
16042
16079
|
},
|
|
16043
16080
|
resolveConflict: o.resolve,
|
|
@@ -16155,7 +16192,7 @@ function Y_(e, n, r) {
|
|
|
16155
16192
|
workingMemory: ot ? se.getWorkingMemory() : void 0,
|
|
16156
16193
|
focus: Ye ? A.getFocus() : void 0,
|
|
16157
16194
|
focuses: Ye ? A.getFocuses() : [],
|
|
16158
|
-
actions:
|
|
16195
|
+
actions: S_(e.actions ?? {}),
|
|
16159
16196
|
subagent: {
|
|
16160
16197
|
enabled: !!wt,
|
|
16161
16198
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -16185,10 +16222,10 @@ function Y_(e, n, r) {
|
|
|
16185
16222
|
...X.mcpFailed.length ? { failed: X.mcpFailed } : {}
|
|
16186
16223
|
},
|
|
16187
16224
|
lastCompression: X.agent?.getState?.()?.lastCompression,
|
|
16188
|
-
checkpoints:
|
|
16225
|
+
checkpoints: R ? {
|
|
16189
16226
|
enabled: !0,
|
|
16190
16227
|
auto: z,
|
|
16191
|
-
list:
|
|
16228
|
+
list: R.list()
|
|
16192
16229
|
} : void 0
|
|
16193
16230
|
};
|
|
16194
16231
|
},
|
|
@@ -16242,11 +16279,11 @@ function Y_(e, n, r) {
|
|
|
16242
16279
|
return Ye ? A.getFocuses() : [];
|
|
16243
16280
|
},
|
|
16244
16281
|
setFocus(t) {
|
|
16245
|
-
let n =
|
|
16282
|
+
let n = Y_(t, "setFocus", Ye, () => U()?.schema, e.debug);
|
|
16246
16283
|
return n.ok ? (A.setFocus(j(t)), e.debug && A.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), X.infoTick.value++, { ok: !0 }) : n;
|
|
16247
16284
|
},
|
|
16248
16285
|
addFocus(t) {
|
|
16249
|
-
let n =
|
|
16286
|
+
let n = Y_(t, "addFocus", Ye, () => U()?.schema, e.debug);
|
|
16250
16287
|
return n.ok ? A.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
16251
16288
|
ok: !1,
|
|
16252
16289
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -16350,14 +16387,14 @@ function Y_(e, n, r) {
|
|
|
16350
16387
|
}
|
|
16351
16388
|
function fn(e) {
|
|
16352
16389
|
let t = {};
|
|
16353
|
-
for (let n of
|
|
16390
|
+
for (let n of V_(e)) {
|
|
16354
16391
|
let e = T.files[n];
|
|
16355
16392
|
e && (t[n] = e.content);
|
|
16356
16393
|
}
|
|
16357
16394
|
return t;
|
|
16358
16395
|
}
|
|
16359
16396
|
function pn() {
|
|
16360
|
-
let e =
|
|
16397
|
+
let e = H_(T.files, V_(w));
|
|
16361
16398
|
for (let t of e) delete T.files[t];
|
|
16362
16399
|
}
|
|
16363
16400
|
function mn() {
|
|
@@ -16416,7 +16453,7 @@ function Y_(e, n, r) {
|
|
|
16416
16453
|
useAutomation: ve
|
|
16417
16454
|
},
|
|
16418
16455
|
vfsStore: T,
|
|
16419
|
-
checkpointMgr:
|
|
16456
|
+
checkpointMgr: R,
|
|
16420
16457
|
conflictResolve: (e) => o.resolve(e),
|
|
16421
16458
|
abortAllActive: cn,
|
|
16422
16459
|
titleLlmInvoke: f
|
|
@@ -16473,12 +16510,12 @@ function Y_(e, n, r) {
|
|
|
16473
16510
|
C = e;
|
|
16474
16511
|
},
|
|
16475
16512
|
debug: e.debug
|
|
16476
|
-
}),
|
|
16513
|
+
}), ce.current = X.agent, kt && kt.setReconfigureHook(() => {
|
|
16477
16514
|
X.agent && X.agent.setTools(rt());
|
|
16478
16515
|
});
|
|
16479
16516
|
})(), X;
|
|
16480
16517
|
}
|
|
16481
|
-
function
|
|
16518
|
+
function Z_(e, t) {
|
|
16482
16519
|
let n = e.id ?? Up();
|
|
16483
16520
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
16484
16521
|
let r = e.streaming ?? !0, i = e.ui ?? "default", a = e.hostWatch === !0 ? { url: !0 } : e.hostWatch && typeof e.hostWatch == "object" ? e.hostWatch : null, o = {
|
|
@@ -16487,8 +16524,8 @@ function X_(e, t) {
|
|
|
16487
16524
|
pushState: !1,
|
|
16488
16525
|
title: !1,
|
|
16489
16526
|
autoNotified: 0
|
|
16490
|
-
}, s = null, c, l = e.shareContext ?
|
|
16491
|
-
l ? c = l : (c =
|
|
16527
|
+
}, s = null, c, l = e.shareContext ? G_.get(n) : void 0;
|
|
16528
|
+
l ? c = l : (c = X_(e, n, a ? o : void 0), e.shareContext && G_.set(n, c)), c.refCount++;
|
|
16492
16529
|
let u = null, d = vm(e), f = null, p = null;
|
|
16493
16530
|
async function m(n) {
|
|
16494
16531
|
if (await c.initDone, u) {
|
|
@@ -16506,7 +16543,7 @@ function X_(e, t) {
|
|
|
16506
16543
|
if (!a) return;
|
|
16507
16544
|
s?.dispose(), s = null;
|
|
16508
16545
|
let e = typeof window < "u" ? window : void 0;
|
|
16509
|
-
s =
|
|
16546
|
+
s = wg({
|
|
16510
16547
|
target: e,
|
|
16511
16548
|
history: typeof history < "u" ? history : e?.history,
|
|
16512
16549
|
document: typeof document < "u" ? document : void 0,
|
|
@@ -16522,7 +16559,7 @@ function X_(e, t) {
|
|
|
16522
16559
|
from: e.from.slice(0, 120),
|
|
16523
16560
|
to: e.to.slice(0, 120)
|
|
16524
16561
|
}
|
|
16525
|
-
}), c.notifyHostChange({ reason:
|
|
16562
|
+
}), c.notifyHostChange({ reason: Sg(e) });
|
|
16526
16563
|
}
|
|
16527
16564
|
}), s && (o.enabled = !0, o.url = s.info.url, o.pushState = s.info.pushState, o.title = s.info.title);
|
|
16528
16565
|
})(), i === !1 || !t) {
|
|
@@ -16748,7 +16785,7 @@ function X_(e, t) {
|
|
|
16748
16785
|
}
|
|
16749
16786
|
//#endregion
|
|
16750
16787
|
//#region src/core/sdk/ragSubagent.ts
|
|
16751
|
-
function
|
|
16788
|
+
function Q_(e, t, n, r, i) {
|
|
16752
16789
|
let a = [];
|
|
16753
16790
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
16754
16791
|
let o = [];
|
|
@@ -16763,7 +16800,7 @@ function Z_(e, t, n, r, i) {
|
|
|
16763
16800
|
|
|
16764
16801
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
16765
16802
|
}
|
|
16766
|
-
function
|
|
16803
|
+
function $_(e, t, n, r, i) {
|
|
16767
16804
|
let a = [], o = [];
|
|
16768
16805
|
return e && (a.push("- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查"), o.push("- 静态文档(组件库文档 / UI 规范):vfs_grep")), t && (a.push(`- ${r}:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用`), o.push(`- 语义相似(「瀑布流组件」「倒计时」「拼团」):${r}`)), n && (a.push(`- ${i}:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档`), o.push(`- 已知文档 id / URL:${i}`)), a.push("- fetch_document:公网 URL —— 查公开资料"), o.push("- 公开 URL(设计规范网站 / 第三方文档):fetch_document"), `# 知识检索策略(RAG)
|
|
16769
16806
|
|
|
@@ -16780,12 +16817,12 @@ ${a.join("\n")}
|
|
|
16780
16817
|
## 何时用何源
|
|
16781
16818
|
${o.join("\n")}`;
|
|
16782
16819
|
}
|
|
16783
|
-
var
|
|
16820
|
+
var ev = {
|
|
16784
16821
|
name: "rag-search",
|
|
16785
16822
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
16786
|
-
getContent: () =>
|
|
16823
|
+
getContent: () => $_(!0, !0, !0, "search_docs", "load_doc")
|
|
16787
16824
|
};
|
|
16788
|
-
function
|
|
16825
|
+
function tv(e, n, r) {
|
|
16789
16826
|
let i = s(async ({ query: e, topK: t }) => {
|
|
16790
16827
|
try {
|
|
16791
16828
|
let i = await n(e, { topK: t ?? r });
|
|
@@ -16803,7 +16840,7 @@ function ev(e, n, r) {
|
|
|
16803
16840
|
});
|
|
16804
16841
|
return ta([i]), i;
|
|
16805
16842
|
}
|
|
16806
|
-
function
|
|
16843
|
+
function nv(e, n) {
|
|
16807
16844
|
let r = s(async ({ source: e }) => {
|
|
16808
16845
|
try {
|
|
16809
16846
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -16818,19 +16855,19 @@ function tv(e, n) {
|
|
|
16818
16855
|
});
|
|
16819
16856
|
return ta([r]), r;
|
|
16820
16857
|
}
|
|
16821
|
-
function
|
|
16858
|
+
function rv(e) {
|
|
16822
16859
|
let { retriever: t, loader: n, useVfs: r = !0, id: i = "rag", description: a, topK: o = 5, searchToolName: s = "search_docs", loadToolName: c = "load_doc", maxToolRounds: l = 8, summarization: u, skills: d, extraTools: f } = e;
|
|
16823
16860
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
16824
16861
|
let p = [];
|
|
16825
|
-
t && p.push(
|
|
16862
|
+
t && p.push(tv(s, t, o)), n && p.push(nv(c, n)), f && p.push(...f);
|
|
16826
16863
|
let m = r ? [
|
|
16827
16864
|
"vfs_grep",
|
|
16828
16865
|
"vfs_read",
|
|
16829
16866
|
"vfs_json_read"
|
|
16830
|
-
] : void 0, h =
|
|
16867
|
+
] : void 0, h = Q_(r, !!t, !!n, s, c), g = {
|
|
16831
16868
|
name: "rag-search",
|
|
16832
|
-
description:
|
|
16833
|
-
getContent: () =>
|
|
16869
|
+
description: ev.description,
|
|
16870
|
+
getContent: () => $_(r, !!t, !!n, s, c)
|
|
16834
16871
|
};
|
|
16835
16872
|
return {
|
|
16836
16873
|
id: i,
|
|
@@ -16845,7 +16882,7 @@ function nv(e) {
|
|
|
16845
16882
|
}
|
|
16846
16883
|
//#endregion
|
|
16847
16884
|
//#region src/core/sdk/evalToolkit.ts
|
|
16848
|
-
function
|
|
16885
|
+
function iv(e = {}) {
|
|
16849
16886
|
let t = e.quietMs ?? 9e4, n = e.confirmSamples ?? 3, r = e.baselineMessageCount ?? 0, i = 0;
|
|
16850
16887
|
return {
|
|
16851
16888
|
push(e) {
|
|
@@ -16856,12 +16893,12 @@ function rv(e = {}) {
|
|
|
16856
16893
|
}
|
|
16857
16894
|
};
|
|
16858
16895
|
}
|
|
16859
|
-
var
|
|
16860
|
-
function
|
|
16896
|
+
var av = /* @__PURE__ */ new Set(["elapsedSec"]);
|
|
16897
|
+
function ov(e, t, n = {}) {
|
|
16861
16898
|
let r = n.tokenAbs ?? 2e3, i = n.tokenPct ?? 15, a = n.toolCountAbs ?? 3, o = [], s = 0, c = 0, l = 0, u = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
16862
16899
|
for (let n of u) {
|
|
16863
16900
|
let u = Number(e?.[n] ?? 0), d = Number(t?.[n] ?? 0), f = u - d, p = d > 0 ? Math.round(f / d * 100) : 0, m = "";
|
|
16864
|
-
|
|
16901
|
+
av.has(n) || (n === "toolCount" ? Math.abs(f) > a : Math.abs(f) > r && Math.abs(p) >= i) && (m = f > 0 ? "up" : "down", m === "up" ? (s++, c++) : l++), o.push({
|
|
16865
16902
|
key: n,
|
|
16866
16903
|
prev: d,
|
|
16867
16904
|
cur: u,
|
|
@@ -16876,7 +16913,7 @@ function av(e, t, n = {}) {
|
|
|
16876
16913
|
fields: o
|
|
16877
16914
|
};
|
|
16878
16915
|
}
|
|
16879
|
-
function
|
|
16916
|
+
function sv(e) {
|
|
16880
16917
|
let { sdk: t } = e, n = () => {
|
|
16881
16918
|
let e = t.debugLogs.value ?? [], n = e.length ? e[e.length - 1].timestamp : 0;
|
|
16882
16919
|
return {
|
|
@@ -16889,7 +16926,7 @@ function ov(e) {
|
|
|
16889
16926
|
};
|
|
16890
16927
|
return {
|
|
16891
16928
|
async waitForIdle(e = {}) {
|
|
16892
|
-
let { timeoutMs: r = 6e5, sampleMs: i = 2500, onSample: a, ...o } = e, s =
|
|
16929
|
+
let { timeoutMs: r = 6e5, sampleMs: i = 2500, onSample: a, ...o } = e, s = iv(o), c = Date.now();
|
|
16893
16930
|
for (;;) {
|
|
16894
16931
|
let e = n(), o = s.push(e);
|
|
16895
16932
|
if (a?.(e), o === "done") return e;
|
|
@@ -16919,7 +16956,7 @@ function ov(e) {
|
|
|
16919
16956
|
}
|
|
16920
16957
|
//#endregion
|
|
16921
16958
|
//#region src/core/utils/clipboard.ts
|
|
16922
|
-
async function
|
|
16959
|
+
async function cv(e) {
|
|
16923
16960
|
try {
|
|
16924
16961
|
let t = globalThis.navigator?.clipboard;
|
|
16925
16962
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -16937,8 +16974,8 @@ async function sv(e) {
|
|
|
16937
16974
|
}
|
|
16938
16975
|
//#endregion
|
|
16939
16976
|
//#region src/core/composables/useChat.ts
|
|
16940
|
-
var
|
|
16941
|
-
function
|
|
16977
|
+
var lv = 4e3;
|
|
16978
|
+
function uv(e = {}) {
|
|
16942
16979
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */ Ft({
|
|
16943
16980
|
messages: e.messages ?? [],
|
|
16944
16981
|
loading: !1,
|
|
@@ -17019,7 +17056,7 @@ function lv(e = {}) {
|
|
|
17019
17056
|
let t = e.delta || "";
|
|
17020
17057
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
17021
17058
|
let r = (n.subReason || "") + t;
|
|
17022
|
-
n.subReason = r.length >
|
|
17059
|
+
n.subReason = r.length > lv ? r.slice(-4e3) : r;
|
|
17023
17060
|
break;
|
|
17024
17061
|
}
|
|
17025
17062
|
n.children ||= [];
|
|
@@ -17150,7 +17187,7 @@ function lv(e = {}) {
|
|
|
17150
17187
|
}
|
|
17151
17188
|
//#endregion
|
|
17152
17189
|
//#region src/core/components/icons.ts
|
|
17153
|
-
var
|
|
17190
|
+
var dv = {
|
|
17154
17191
|
header: "🤖",
|
|
17155
17192
|
subagent: "🤖",
|
|
17156
17193
|
subagentProgress: "🧬",
|
|
@@ -17161,10 +17198,10 @@ var uv = {
|
|
|
17161
17198
|
recommend: "💡",
|
|
17162
17199
|
conflict: "⚠️"
|
|
17163
17200
|
};
|
|
17164
|
-
function
|
|
17165
|
-
let t = { ...
|
|
17201
|
+
function fv(e) {
|
|
17202
|
+
let t = { ...dv };
|
|
17166
17203
|
if (!e) return t;
|
|
17167
|
-
let n = Object.keys(
|
|
17204
|
+
let n = Object.keys(dv);
|
|
17168
17205
|
for (let r of n) {
|
|
17169
17206
|
let n = e[r];
|
|
17170
17207
|
typeof n == "string" && (t[r] = n);
|
|
@@ -17173,7 +17210,7 @@ function dv(e) {
|
|
|
17173
17210
|
}
|
|
17174
17211
|
//#endregion
|
|
17175
17212
|
//#region src/core/components/messages.ts
|
|
17176
|
-
var
|
|
17213
|
+
var pv = {
|
|
17177
17214
|
defaultTitle: "AI 助手",
|
|
17178
17215
|
inputPlaceholder: "输入消息,Enter 发送...",
|
|
17179
17216
|
newSession: "新建会话",
|
|
@@ -17405,8 +17442,8 @@ var fv = {
|
|
|
17405
17442
|
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
17406
17443
|
codeDemoButton: "按钮",
|
|
17407
17444
|
codeDemoInput: "输入框"
|
|
17408
|
-
},
|
|
17409
|
-
"zh-CN":
|
|
17445
|
+
}, mv = {
|
|
17446
|
+
"zh-CN": pv,
|
|
17410
17447
|
"en-US": {
|
|
17411
17448
|
defaultTitle: "AI Assistant",
|
|
17412
17449
|
inputPlaceholder: "Type a message, Enter to send...",
|
|
@@ -17641,10 +17678,10 @@ var fv = {
|
|
|
17641
17678
|
codeDemoInput: "Input"
|
|
17642
17679
|
}
|
|
17643
17680
|
};
|
|
17644
|
-
function
|
|
17681
|
+
function hv(e = "zh-CN", t) {
|
|
17645
17682
|
let n = {
|
|
17646
|
-
...
|
|
17647
|
-
...
|
|
17683
|
+
...pv,
|
|
17684
|
+
...mv[e]
|
|
17648
17685
|
};
|
|
17649
17686
|
if (!t) return n;
|
|
17650
17687
|
let r = { ...n };
|
|
@@ -17656,9 +17693,9 @@ function mv(e = "zh-CN", t) {
|
|
|
17656
17693
|
}
|
|
17657
17694
|
//#endregion
|
|
17658
17695
|
//#region src/core/composables/chatContext.ts
|
|
17659
|
-
var
|
|
17660
|
-
function
|
|
17661
|
-
let t =
|
|
17696
|
+
var gv = Symbol("chatContext");
|
|
17697
|
+
function _v(e = {}) {
|
|
17698
|
+
let t = uv({
|
|
17662
17699
|
fetchResponse: e.fetchResponse,
|
|
17663
17700
|
fetchStream: e.fetchStream,
|
|
17664
17701
|
messages: e.messages,
|
|
@@ -17680,7 +17717,7 @@ function gv(e = {}) {
|
|
|
17680
17717
|
}, h = /* @__PURE__ */ Wt({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
17681
17718
|
h.value[e] = !g(e);
|
|
17682
17719
|
}, v = /* @__PURE__ */ Wt(!1), y = (e) => {
|
|
17683
|
-
|
|
17720
|
+
cv(e).then((e) => {
|
|
17684
17721
|
e && (v.value = !0, setTimeout(() => {
|
|
17685
17722
|
v.value = !1;
|
|
17686
17723
|
}, 1500));
|
|
@@ -17693,7 +17730,7 @@ function gv(e = {}) {
|
|
|
17693
17730
|
};
|
|
17694
17731
|
}), x = ri(() => (n.messages.length, typeof e.canUndo == "function" && !!e.canUndo())), S = () => {
|
|
17695
17732
|
e.onUndo?.() && (n.error = null);
|
|
17696
|
-
}, C = (e) => new Date(e).toLocaleTimeString(
|
|
17733
|
+
}, C = (e) => new Date(e).toLocaleTimeString(le, {
|
|
17697
17734
|
hour: "2-digit",
|
|
17698
17735
|
minute: "2-digit"
|
|
17699
17736
|
}), w = () => {
|
|
@@ -17708,16 +17745,16 @@ function gv(e = {}) {
|
|
|
17708
17745
|
if (!t.length) return;
|
|
17709
17746
|
let n = 4 - T.value.length;
|
|
17710
17747
|
if (n <= 0) {
|
|
17711
|
-
k(`${
|
|
17748
|
+
k(`${I.imageCountLimitPrefix}4${I.imageCountLimitSuffix}`);
|
|
17712
17749
|
return;
|
|
17713
17750
|
}
|
|
17714
|
-
t.length > n && k(`${
|
|
17751
|
+
t.length > n && k(`${I.imageCountLimitPrefix}4${I.imageCountLimitSuffix}`), D.value = !0;
|
|
17715
17752
|
try {
|
|
17716
17753
|
for (let e of t.slice(0, n)) try {
|
|
17717
17754
|
let t = await Ei(e, { name: e.name });
|
|
17718
17755
|
T.value.push(t);
|
|
17719
17756
|
} catch (e) {
|
|
17720
|
-
k(e instanceof hi ? `${e.message}` :
|
|
17757
|
+
k(e instanceof hi ? `${e.message}` : I.imageInvalid);
|
|
17721
17758
|
}
|
|
17722
17759
|
} finally {
|
|
17723
17760
|
D.value = !1;
|
|
@@ -17740,13 +17777,13 @@ function gv(e = {}) {
|
|
|
17740
17777
|
}, j = ri(() => (e.infoTick?.value, e.getFocuses?.() ?? [])), se = ri(() => (e.infoTick?.value, e.getInfo?.()?.planConfirmation)), M = (t) => e.onAddFocus ? e.onAddFocus(t) : {
|
|
17741
17778
|
ok: !1,
|
|
17742
17779
|
error: "focus 未启用"
|
|
17743
|
-
},
|
|
17780
|
+
}, ce = (t) => {
|
|
17744
17781
|
e.onRemoveFocus?.(t);
|
|
17745
|
-
},
|
|
17782
|
+
}, N = () => {
|
|
17746
17783
|
e.onClearFocus?.();
|
|
17747
|
-
},
|
|
17784
|
+
}, P = (t) => {
|
|
17748
17785
|
e.onFocusChipClick?.(t);
|
|
17749
|
-
},
|
|
17786
|
+
}, F = fv(e.icons), le = e.locale ?? "zh-CN", I = hv(le, e.dialogMessages);
|
|
17750
17787
|
return {
|
|
17751
17788
|
chat: t,
|
|
17752
17789
|
inputText: o,
|
|
@@ -17782,24 +17819,24 @@ function gv(e = {}) {
|
|
|
17782
17819
|
focuses: j,
|
|
17783
17820
|
planConfirmation: se,
|
|
17784
17821
|
addFocus: M,
|
|
17785
|
-
removeFocus:
|
|
17786
|
-
clearFocus:
|
|
17787
|
-
focusChipClick:
|
|
17788
|
-
icons:
|
|
17789
|
-
locale:
|
|
17790
|
-
messages:
|
|
17822
|
+
removeFocus: ce,
|
|
17823
|
+
clearFocus: N,
|
|
17824
|
+
focusChipClick: P,
|
|
17825
|
+
icons: F,
|
|
17826
|
+
locale: le,
|
|
17827
|
+
messages: I,
|
|
17791
17828
|
toolStepView: e.toolStepView
|
|
17792
17829
|
};
|
|
17793
17830
|
}
|
|
17794
|
-
function
|
|
17795
|
-
let e = Zn(
|
|
17831
|
+
function vv() {
|
|
17832
|
+
let e = Zn(gv);
|
|
17796
17833
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
17797
17834
|
return e;
|
|
17798
17835
|
}
|
|
17799
17836
|
//#endregion
|
|
17800
17837
|
//#region src/core/index.headless.ts
|
|
17801
|
-
function
|
|
17802
|
-
return
|
|
17838
|
+
function yv(e) {
|
|
17839
|
+
return Z_(e);
|
|
17803
17840
|
}
|
|
17804
17841
|
//#endregion
|
|
17805
|
-
export { ym as CAPABILITIES, Sm as CONTEXT_PRESETS, Dp as CompressDecisionSchema,
|
|
17842
|
+
export { ym as CAPABILITIES, Sm as CONTEXT_PRESETS, Dp as CompressDecisionSchema, Xg as DEFAULT_COMPUTED_STYLES, jl as DEFAULT_PROMPT_SOFT_CAP, cd as DEFAULT_SYSTEM_PROMPT, ld as DEFAULT_SYSTEM_PROMPT_EN, gf as HTML_VOID_TAGS, xu as HUMAN_CONFIRM_TOOL_NAME, hi as ImageInputError, g as LOW_CAPS_HINT_BASELINE, p as MIN_CONTEXT_WINDOW, va as MODEL_UNAVAILABLE_GUIDANCE, Al as SOFT_CAP_MIN_WINDOW, Sl as STOP_WORDS, Cc as UNSAFE_KEYS, S_ as actionsToInspectInfo, x_ as actionsToTools, di as agentError, ed as analyzeContext, Ic as applyPatchToClone, zc as applyPatchToLive, rf as applyPatchesToBind, Ag as applyProposalOps, Hs as arrayMinLength, ui as asAgentError, sp as buildCollectorJs, t_ as buildCssPath, gd as buildDataPrompt, $f as buildDiagnosticsReport, _p as buildHtmlFragmentSkill, cp as buildSandboxSrcdoc, _d as buildSystemPrompt, Ji as captureSelectionQuote, gv as chatContextKey, nf as commitSetToBind, mp as composeStructureThenRender, Ei as compressImage, od as connectMcp, k as constructLlmFromConfig, E as constructOpenLlmSync, cv as copyText, kg as countOccurrences, Ms as createAgent, bu as createApprovalMiddleware, _v as createChatContext, yv as createChatSdk, Mu as createCheckpointManager, Nu as createCheckpointMiddleware, Hp as createConflictManager, td as createContextInspectorMiddleware, xp as createCraftNoteCheck, hf as createDataOps, sv as createEvalHarness, yp as createHtmlFormatCheck, pp as createHtmlRenderCheck, Cp as createHtmlSubagent, wu as createHumanConfirmMiddleware, Cu as createHumanConfirmTool, iv as createIdleDetector, um as createMemoryBackend, pu as createMemoryMiddleware, u as createProxyLlm, rv as createRagSubagent, wa as createSandboxRunner, xm as createSdkEvents, U_ as createSerialRunner, mm as createSessionStore, hm as createSessionStoreWithBackend, z_ as createSkillStore, iu as createSubagentMiddleware, Rl as createSubagentTracker, su as createSubagentsMiddleware, j_ as createUsageHintsMiddleware, Fu as createVerifyMiddleware, xd as createVfs, fm as createWebStorageBackend, Vu as createWriteBackCheck, ya as decorateModelUnavailable, Oc as deepClone, T_ as defineDataToolset, Qc as defineSkill, wp as defineTool, Dc as deleteByPath, Op as deriveTitle, nc as describeSchemaNode, hs as detectGarbledToolCall, To as detectTransitionalReply, Uc as diffObjects, ov as diffReport, o_ as domInfoTool, d_ as domInspectSkill, a_ as domSearchTool, Vg as domToStructure, Yg as domTools, w_ as domToolsStatic, Us as elementSchemaCandidates, $g as ensureDomListenerRecorder, wl as estimateMessageTokens, Dl as estimateRoundTokens, y as estimateTokens, te as extractReasoningDelta, hc as extractSchemaHint, nd as extractText, ee as extractTextDelta, ne as extractUsage, Lg as fetchDocTools, C_ as fetchTools, Hc as findStrippedKeys, rc as formatConstraints, oi as formatZodIssues, Q as getByPath, Hg as getDomTool, i_ as getElementInfo, m_ as getEnvSummary, e_ as getRecordedListeners, dp as getSandboxLifecycle, Is as getSchemaAtPath, Ns as getSchemaTopKeys, jg as hashContent, Pc as hashValue, vp as htmlFragmentSkill, uc as htmlOrchestratorPrompt, Ol as indexSummarize, __ as inspectEnvTool, v_ as inspectTools, Ap as isChatModel, ga as isContextLengthError, _a as isModelUnavailableError, Ps as isPathAllowed, nm as isQuotaError, wc as isUnsafePath, Pa as jpEval, ci as jsonParseError, Mc as limitDepth, Dg as lineDiff, _ as lowCapsHint, Zf as maskUrlCredentials, Ac as maybeParseValue, Gf as measureWriteScale, Rc as moveByPath, T as normalizeBaseUrl, op as normalizeRenderResult, ie as normalizeUsage, x as offloadPassThroughChars, b as offloadThresholdChars, lc as presets, Xs as projectBySchema, Ys as projectBySchemaDeep, jc as projectFields, kl as recallRounds, fp as renderInSandbox, ic as renderSchemaHint, ac as renderSchemaOverview, cc as renderSchemaShallow, bm as resolveCapabilities, wm as resolveContextOptions, vm as resolveDialogConfig, Vp as resolveLlm, v as resolveModelCaps, Nl as resolvePromptSoftCap, zs as resolveSchemaPath, _m as resolveStorage, Vc as restoreInPlace, Bc as restoreLive, li as routeError, Ra as runSandboxedScript, Tc as safeMerge, p_ as safeSerialize, $ as safeStringify, gs as sanitizeGarbledContent, Vs as schemaHasRefinement, n_ as searchDom, Ia as searchJson, E_ as selectBuiltinTools, Ec as setByPath, Pl as shouldTriggerCompression, ep as stringifyDiagnosticsReport, w as stripStainlessFetch, dc as systemPromptHelpers, h as tableMaxOutputTokens, Cl as tokenize, Z as toolError, Fs as unwrapSchema, uv as useChat, vv as useChatContext, Bs as validateAtPath, vf as validateHtmlFormat, ef as validateRootValueLocally, tf as validateWriteLocally, Fc as watchFieldsHash, e as z, si as zodError };
|