page-agent-sdk 3.18.0 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/dist/page-agent-sdk.headless.js +208 -180
- package/dist/page-agent-sdk.iife.js +3 -3
- package/dist/page-agent-sdk.js +56 -28
- package/dist/page-agent-sdk.umd.cjs +3 -3
- package/package.json +2 -1
- package/types/index.d.ts +8 -0
|
@@ -101,7 +101,11 @@ async function m(e, t = {}) {
|
|
|
101
101
|
temperature: t.temperature ?? e.temperature,
|
|
102
102
|
maxTokens: t.maxTokens ?? e.maxTokens,
|
|
103
103
|
...e.baseUrl ? { anthropicApiUrl: f(e.baseUrl) } : {},
|
|
104
|
-
...e.extraConfig ? { clientOptions: e.extraConfig } : {}
|
|
104
|
+
...e.extraConfig ? { clientOptions: e.extraConfig } : {},
|
|
105
|
+
...e.cacheControl ? { invocationKwargs: { cache_control: {
|
|
106
|
+
type: "ephemeral",
|
|
107
|
+
...e.cacheControl === !0 ? {} : { ttl: e.cacheControl }
|
|
108
|
+
} } } : {}
|
|
105
109
|
});
|
|
106
110
|
}
|
|
107
111
|
//#endregion
|
|
@@ -142,10 +146,14 @@ function y(e) {
|
|
|
142
146
|
let t = _(e);
|
|
143
147
|
if (!t || typeof t != "object") return null;
|
|
144
148
|
let n = t, r = Number(n.prompt_tokens ?? n.promptTokens ?? n.input_tokens ?? n.inputTokens ?? 0) || 0, i = Number(n.completion_tokens ?? n.completionTokens ?? n.output_tokens ?? n.outputTokens ?? 0) || 0, a = Number(n.total_tokens ?? n.totalTokens ?? r + i) || 0;
|
|
145
|
-
|
|
149
|
+
if (!r && !i && !a) return null;
|
|
150
|
+
let o = n.input_token_details, s = Number(n.cache_read_input_tokens ?? n.cacheReadInputTokens ?? o?.cache_read ?? 0) || 0, c = Number(n.cache_creation_input_tokens ?? n.cacheCreationInputTokens ?? o?.cache_creation ?? 0) || 0;
|
|
151
|
+
return {
|
|
146
152
|
prompt_tokens: r,
|
|
147
153
|
completion_tokens: i,
|
|
148
|
-
total_tokens: a
|
|
154
|
+
total_tokens: a,
|
|
155
|
+
...s ? { cache_read_input_tokens: s } : {},
|
|
156
|
+
...c ? { cache_creation_input_tokens: c } : {}
|
|
149
157
|
};
|
|
150
158
|
}
|
|
151
159
|
//#endregion
|
|
@@ -161,10 +169,10 @@ process.env.NODE_ENV === "production" || Object.freeze([]);
|
|
|
161
169
|
var S = () => {}, C = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), w = (e) => e.startsWith("onUpdate:"), T = Object.assign, E = (e, t) => {
|
|
162
170
|
let n = e.indexOf(t);
|
|
163
171
|
n > -1 && e.splice(n, 1);
|
|
164
|
-
}, D = Object.prototype.hasOwnProperty, O = (e, t) => D.call(e, t), k = Array.isArray, A = (e) =>
|
|
172
|
+
}, D = Object.prototype.hasOwnProperty, O = (e, t) => D.call(e, t), k = Array.isArray, A = (e) => re(e) === "[object Map]", ee = (e) => re(e) === "[object Set]", j = (e) => typeof e == "function", M = (e) => typeof e == "string", te = (e) => typeof e == "symbol", N = (e) => typeof e == "object" && !!e, P = (e) => (N(e) || j(e)) && j(e.then) && j(e.catch), ne = Object.prototype.toString, re = (e) => ne.call(e), ie = (e) => re(e).slice(8, -1), F = (e) => re(e) === "[object Object]", I = (e) => M(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, L = ((e) => {
|
|
165
173
|
let t = /* @__PURE__ */ Object.create(null);
|
|
166
174
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
167
|
-
})((e) => e.charAt(0).toUpperCase() + e.slice(1)),
|
|
175
|
+
})((e) => e.charAt(0).toUpperCase() + e.slice(1)), ae = (e, t) => !Object.is(e, t), oe = (e, t, n, r = !1) => {
|
|
168
176
|
Object.defineProperty(e, t, {
|
|
169
177
|
configurable: !0,
|
|
170
178
|
enumerable: !1,
|
|
@@ -176,11 +184,11 @@ function le(e) {
|
|
|
176
184
|
if (k(e)) {
|
|
177
185
|
let t = {};
|
|
178
186
|
for (let n = 0; n < e.length; n++) {
|
|
179
|
-
let r = e[n], i =
|
|
187
|
+
let r = e[n], i = M(r) ? fe(r) : le(r);
|
|
180
188
|
if (i) for (let e in i) t[e] = i[e];
|
|
181
189
|
}
|
|
182
190
|
return t;
|
|
183
|
-
} else if (
|
|
191
|
+
} else if (M(e) || N(e)) return e;
|
|
184
192
|
}
|
|
185
193
|
var ue = /;(?![^(]*\))/g, de = /:([^]+)/, R = /\/\*[^]*?\*\//g;
|
|
186
194
|
function fe(e) {
|
|
@@ -194,12 +202,12 @@ function fe(e) {
|
|
|
194
202
|
}
|
|
195
203
|
function z(e) {
|
|
196
204
|
let t = "";
|
|
197
|
-
if (
|
|
205
|
+
if (M(e)) t = e;
|
|
198
206
|
else if (k(e)) for (let n = 0; n < e.length; n++) {
|
|
199
207
|
let r = z(e[n]);
|
|
200
208
|
r && (t += r + " ");
|
|
201
209
|
}
|
|
202
|
-
else if (
|
|
210
|
+
else if (N(e)) for (let n in e) e[n] && (t += n + " ");
|
|
203
211
|
return t.trim();
|
|
204
212
|
}
|
|
205
213
|
//#endregion
|
|
@@ -308,7 +316,7 @@ function Te(e) {
|
|
|
308
316
|
try {
|
|
309
317
|
Se(e);
|
|
310
318
|
let n = e.fn(e._value);
|
|
311
|
-
(t.version === 0 ||
|
|
319
|
+
(t.version === 0 || ae(n, e._value)) && (e.flags |= 128, e._value = n, t.version++);
|
|
312
320
|
} catch (e) {
|
|
313
321
|
throw t.version++, e;
|
|
314
322
|
} finally {
|
|
@@ -420,11 +428,11 @@ function ze(e, t, n, r, i, a) {
|
|
|
420
428
|
};
|
|
421
429
|
if (be(), t === "clear") o.forEach(s);
|
|
422
430
|
else {
|
|
423
|
-
let i = k(e), a = i &&
|
|
431
|
+
let i = k(e), a = i && I(n);
|
|
424
432
|
if (i && n === "length") {
|
|
425
433
|
let e = Number(r);
|
|
426
434
|
o.forEach((t, n) => {
|
|
427
|
-
(n === "length" || n === Re || !
|
|
435
|
+
(n === "length" || n === Re || !te(n) && n >= e) && s(t);
|
|
428
436
|
});
|
|
429
437
|
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(Re)), t) {
|
|
430
438
|
case "add":
|
|
@@ -578,9 +586,9 @@ function Ye(e, t, n = []) {
|
|
|
578
586
|
let r = (/* @__PURE__ */ q(e))[t].apply(e, n);
|
|
579
587
|
return xe(), ke(), r;
|
|
580
588
|
}
|
|
581
|
-
var Xe = /* @__PURE__ */ b("__proto__,__v_isRef,__isVue"), Ze = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(
|
|
589
|
+
var Xe = /* @__PURE__ */ b("__proto__,__v_isRef,__isVue"), Ze = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(te));
|
|
582
590
|
function Qe(e) {
|
|
583
|
-
|
|
591
|
+
te(e) || (e = String(e));
|
|
584
592
|
let t = /* @__PURE__ */ q(this);
|
|
585
593
|
return G(t, "has", e), t.hasOwnProperty(e);
|
|
586
594
|
}
|
|
@@ -602,25 +610,25 @@ var $e = class {
|
|
|
602
610
|
if (t === "hasOwnProperty") return Qe;
|
|
603
611
|
}
|
|
604
612
|
let o = Reflect.get(e, t, /* @__PURE__ */ J(e) ? e : n);
|
|
605
|
-
if ((
|
|
613
|
+
if ((te(t) ? Ze.has(t) : Xe(t)) || (r || G(e, "get", t), i)) return o;
|
|
606
614
|
if (/* @__PURE__ */ J(o)) {
|
|
607
|
-
let e = a &&
|
|
608
|
-
return r &&
|
|
615
|
+
let e = a && I(t) ? o : o.value;
|
|
616
|
+
return r && N(e) ? /* @__PURE__ */ bt(e) : e;
|
|
609
617
|
}
|
|
610
|
-
return
|
|
618
|
+
return N(o) ? r ? /* @__PURE__ */ bt(o) : /* @__PURE__ */ yt(o) : o;
|
|
611
619
|
}
|
|
612
620
|
}, et = class extends $e {
|
|
613
621
|
constructor(e = !1) {
|
|
614
622
|
super(!1, e);
|
|
615
623
|
}
|
|
616
624
|
set(e, t, n, r) {
|
|
617
|
-
let i = e[t], a = k(e) &&
|
|
625
|
+
let i = e[t], a = k(e) && I(t);
|
|
618
626
|
if (!this._isShallow) {
|
|
619
627
|
let r = /* @__PURE__ */ wt(i);
|
|
620
628
|
if (!/* @__PURE__ */ Tt(n) && !/* @__PURE__ */ wt(n) && (i = /* @__PURE__ */ q(i), n = /* @__PURE__ */ q(n)), !a && /* @__PURE__ */ J(i) && !/* @__PURE__ */ J(n)) return r ? (process.env.NODE_ENV !== "production" && B(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
|
|
621
629
|
}
|
|
622
630
|
let o = a ? Number(t) < e.length : O(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ J(e) ? e : r);
|
|
623
|
-
return e === /* @__PURE__ */ q(r) && s && (o ?
|
|
631
|
+
return e === /* @__PURE__ */ q(r) && s && (o ? ae(n, i) && ze(e, "set", t, n, i) : ze(e, "add", t, n)), s;
|
|
624
632
|
}
|
|
625
633
|
deleteProperty(e, t) {
|
|
626
634
|
let n = O(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
|
|
@@ -628,7 +636,7 @@ var $e = class {
|
|
|
628
636
|
}
|
|
629
637
|
has(e, t) {
|
|
630
638
|
let n = Reflect.has(e, t);
|
|
631
|
-
return (!
|
|
639
|
+
return (!te(t) || !Ze.has(t)) && G(e, "has", t), n;
|
|
632
640
|
}
|
|
633
641
|
ownKeys(e) {
|
|
634
642
|
return G(e, "iterate", k(e) ? "length" : Ie), Reflect.ownKeys(e);
|
|
@@ -663,7 +671,7 @@ function st(e) {
|
|
|
663
671
|
return function(...t) {
|
|
664
672
|
if (process.env.NODE_ENV !== "production") {
|
|
665
673
|
let n = t[0] ? `on key "${t[0]}" ` : "";
|
|
666
|
-
B(`${
|
|
674
|
+
B(`${L(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ q(this));
|
|
667
675
|
}
|
|
668
676
|
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
|
|
669
677
|
};
|
|
@@ -672,7 +680,7 @@ function ct(e, t) {
|
|
|
672
680
|
let n = {
|
|
673
681
|
get(n) {
|
|
674
682
|
let r = this.__v_raw, i = /* @__PURE__ */ q(r), a = /* @__PURE__ */ q(n);
|
|
675
|
-
e || (
|
|
683
|
+
e || (ae(n, a) && G(i, "get", n), G(i, "get", a));
|
|
676
684
|
let { has: o } = K(i), s = t ? at : e ? kt : Ot;
|
|
677
685
|
if (o.call(i, n)) return s(r.get(n));
|
|
678
686
|
if (o.call(i, a)) return s(r.get(a));
|
|
@@ -684,7 +692,7 @@ function ct(e, t) {
|
|
|
684
692
|
},
|
|
685
693
|
has(t) {
|
|
686
694
|
let n = this.__v_raw, r = /* @__PURE__ */ q(n), i = /* @__PURE__ */ q(t);
|
|
687
|
-
return e || (
|
|
695
|
+
return e || (ae(t, i) && G(r, "has", t), G(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
|
|
688
696
|
},
|
|
689
697
|
forEach(n, r) {
|
|
690
698
|
let i = this, a = i.__v_raw, o = /* @__PURE__ */ q(a), s = t ? at : e ? kt : Ot;
|
|
@@ -699,14 +707,14 @@ function ct(e, t) {
|
|
|
699
707
|
} : {
|
|
700
708
|
add(e) {
|
|
701
709
|
let n = /* @__PURE__ */ q(this), r = K(n), i = /* @__PURE__ */ q(e), a = !t && !/* @__PURE__ */ Tt(e) && !/* @__PURE__ */ wt(e) ? i : e;
|
|
702
|
-
return r.has.call(n, a) ||
|
|
710
|
+
return r.has.call(n, a) || ae(e, a) && r.has.call(n, e) || ae(i, a) && r.has.call(n, i) || (n.add(a), ze(n, "add", a, a)), this;
|
|
703
711
|
},
|
|
704
712
|
set(e, n) {
|
|
705
713
|
!t && !/* @__PURE__ */ Tt(n) && !/* @__PURE__ */ wt(n) && (n = /* @__PURE__ */ q(n));
|
|
706
714
|
let r = /* @__PURE__ */ q(this), { has: i, get: a } = K(r), o = i.call(r, e);
|
|
707
715
|
o ? process.env.NODE_ENV !== "production" && pt(r, i, e) : (e = /* @__PURE__ */ q(e), o = i.call(r, e));
|
|
708
716
|
let s = a.call(r, e);
|
|
709
|
-
return r.set(e, n), o ?
|
|
717
|
+
return r.set(e, n), o ? ae(n, s) && ze(r, "set", e, n, s) : ze(r, "add", e, n), this;
|
|
710
718
|
},
|
|
711
719
|
delete(e) {
|
|
712
720
|
let t = /* @__PURE__ */ q(this), { has: n, get: r } = K(t), i = n.call(t, e);
|
|
@@ -735,7 +743,7 @@ var ut = { get: /* @__PURE__ */ lt(!1, !1) }, dt = { get: /* @__PURE__ */ lt(!0,
|
|
|
735
743
|
function pt(e, t, n) {
|
|
736
744
|
let r = /* @__PURE__ */ q(n);
|
|
737
745
|
if (r !== n && t.call(e, r)) {
|
|
738
|
-
let t =
|
|
746
|
+
let t = ie(e);
|
|
739
747
|
B(`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.`);
|
|
740
748
|
}
|
|
741
749
|
}
|
|
@@ -764,11 +772,11 @@ function xt(e) {
|
|
|
764
772
|
return St(e, !0, it, ft, _t);
|
|
765
773
|
}
|
|
766
774
|
function St(e, t, n, r, i) {
|
|
767
|
-
if (!
|
|
775
|
+
if (!N(e)) return process.env.NODE_ENV !== "production" && B(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
|
|
768
776
|
if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
|
|
769
777
|
let a = i.get(e);
|
|
770
778
|
if (a) return a;
|
|
771
|
-
let o = vt(
|
|
779
|
+
let o = vt(ie(e));
|
|
772
780
|
if (o === 0) return e;
|
|
773
781
|
let s = new Proxy(e, o === 2 ? r : n);
|
|
774
782
|
return i.set(e, s), s;
|
|
@@ -797,7 +805,7 @@ function q(e) {
|
|
|
797
805
|
function Dt(e) {
|
|
798
806
|
return !O(e, "__v_skip") && Object.isExtensible(e) && oe(e, "__v_skip", !0), e;
|
|
799
807
|
}
|
|
800
|
-
var Ot = (e) =>
|
|
808
|
+
var Ot = (e) => N(e) ? /* @__PURE__ */ yt(e) : e, kt = (e) => N(e) ? /* @__PURE__ */ bt(e) : e;
|
|
801
809
|
// @__NO_SIDE_EFFECTS__
|
|
802
810
|
function J(e) {
|
|
803
811
|
return e ? e.__v_isRef === !0 : !1;
|
|
@@ -826,7 +834,7 @@ var Nt = class {
|
|
|
826
834
|
}
|
|
827
835
|
set value(e) {
|
|
828
836
|
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ Tt(e) || /* @__PURE__ */ wt(e);
|
|
829
|
-
e = n ? e : /* @__PURE__ */ q(e),
|
|
837
|
+
e = n ? e : /* @__PURE__ */ q(e), ae(e, t) && (this._rawValue = e, this._value = n ? e : Ot(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
|
|
830
838
|
target: this,
|
|
831
839
|
type: "set",
|
|
832
840
|
key: "value",
|
|
@@ -932,7 +940,7 @@ function Wt(e, t, n = x) {
|
|
|
932
940
|
let y = g ? Array(e.length).fill(Bt) : Bt, b = (e) => {
|
|
933
941
|
if (!(!(d.flags & 1) || !d.dirty && !e)) if (t) {
|
|
934
942
|
let n = d.run();
|
|
935
|
-
if (e || i || h || (g ? n.some((e, t) =>
|
|
943
|
+
if (e || i || h || (g ? n.some((e, t) => ae(e, y[t])) : ae(n, y))) {
|
|
936
944
|
p && p();
|
|
937
945
|
let e = Ht;
|
|
938
946
|
Ht = d;
|
|
@@ -959,13 +967,13 @@ function Wt(e, t, n = x) {
|
|
|
959
967
|
}, 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;
|
|
960
968
|
}
|
|
961
969
|
function Gt(e, t = Infinity, n) {
|
|
962
|
-
if (t <= 0 || !
|
|
970
|
+
if (t <= 0 || !N(e) || e.__v_skip || (n ||= /* @__PURE__ */ new Map(), (n.get(e) || 0) >= t)) return e;
|
|
963
971
|
if (n.set(e, t), t--, /* @__PURE__ */ J(e)) Gt(e.value, t, n);
|
|
964
972
|
else if (k(e)) for (let r = 0; r < e.length; r++) Gt(e[r], t, n);
|
|
965
973
|
else if (ee(e) || A(e)) e.forEach((e) => {
|
|
966
974
|
Gt(e, t, n);
|
|
967
975
|
});
|
|
968
|
-
else if (
|
|
976
|
+
else if (F(e)) {
|
|
969
977
|
for (let r in e) Gt(e[r], t, n);
|
|
970
978
|
for (let r of Object.getOwnPropertySymbols(e)) Object.prototype.propertyIsEnumerable.call(e, r) && Gt(e[r], t, n);
|
|
971
979
|
}
|
|
@@ -1033,7 +1041,7 @@ function en(e) {
|
|
|
1033
1041
|
}), n.length > 3 && t.push(" ..."), t;
|
|
1034
1042
|
}
|
|
1035
1043
|
function tn(e, t, n) {
|
|
1036
|
-
return
|
|
1044
|
+
return M(t) ? (t = JSON.stringify(t), n ? t : [`${e}=${t}`]) : typeof t == "number" || typeof t == "boolean" || t == null ? n ? t : [`${e}=${t}`] : /* @__PURE__ */ J(t) ? (t = tn(e, /* @__PURE__ */ q(t.value), !0), n ? t : [
|
|
1037
1045
|
`${e}=Ref<`,
|
|
1038
1046
|
t,
|
|
1039
1047
|
">"
|
|
@@ -1082,7 +1090,7 @@ function rn(e, t, n, r) {
|
|
|
1082
1090
|
function an(e, t, n, r) {
|
|
1083
1091
|
if (j(e)) {
|
|
1084
1092
|
let i = rn(e, t, n, r);
|
|
1085
|
-
return i &&
|
|
1093
|
+
return i && P(i) && i.catch((e) => {
|
|
1086
1094
|
on(e, t, n);
|
|
1087
1095
|
}), i;
|
|
1088
1096
|
}
|
|
@@ -1292,7 +1300,7 @@ function Vn(e, t, n = x) {
|
|
|
1292
1300
|
return Lr && (l ? l.push(f) : c && f()), f;
|
|
1293
1301
|
}
|
|
1294
1302
|
function Hn(e, t, n) {
|
|
1295
|
-
let r = this.proxy, i =
|
|
1303
|
+
let r = this.proxy, i = M(e) ? e.includes(".") ? Un(r, e) : () => r[e] : e.bind(r, r), a;
|
|
1296
1304
|
j(t) ? a = t : (a = t.handler, n = t);
|
|
1297
1305
|
let o = Fr(this), s = Vn(i, a.bind(r), n);
|
|
1298
1306
|
return o(), s;
|
|
@@ -1377,7 +1385,7 @@ function Zn(e) {
|
|
|
1377
1385
|
var Qn = !0;
|
|
1378
1386
|
function $n(e) {
|
|
1379
1387
|
let t = e.type, { mixins: n, extends: r } = t, { mixins: i, optionsCache: a, config: { optionMergeStrategies: o } } = e.appContext, s = a.get(t), c;
|
|
1380
|
-
return s ? c = s : !i.length && !n && !r ? c = t : (c = {}, i.length && i.forEach((e) => er(c, e, o, !0)), er(c, t, o)),
|
|
1388
|
+
return s ? c = s : !i.length && !n && !r ? c = t : (c = {}, i.length && i.forEach((e) => er(c, e, o, !0)), er(c, t, o)), N(t) && a.set(t, c), c;
|
|
1381
1389
|
}
|
|
1382
1390
|
function er(e, t, n, r = !1) {
|
|
1383
1391
|
let { mixins: i, extends: a } = t;
|
|
@@ -1455,7 +1463,7 @@ var hr = /* @__PURE__ */ Symbol.for("v-fgt"), gr = /* @__PURE__ */ Symbol.for("v
|
|
|
1455
1463
|
function vr(e) {
|
|
1456
1464
|
return e ? e.__v_isVNode === !0 : !1;
|
|
1457
1465
|
}
|
|
1458
|
-
var yr, br = (...e) => Tr(...yr ? yr(e, In) : e), xr = ({ key: e }) => e ?? null, Sr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null :
|
|
1466
|
+
var yr, br = (...e) => Tr(...yr ? yr(e, In) : e), xr = ({ key: e }) => e ?? null, Sr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null : M(e) || /* @__PURE__ */ J(e) || j(e) ? {
|
|
1459
1467
|
i: In,
|
|
1460
1468
|
r: e,
|
|
1461
1469
|
k: t,
|
|
@@ -1491,7 +1499,7 @@ function Cr(e, t = null, n = null, r = 0, i = null, a = e === hr ? 0 : 1, o = !1
|
|
|
1491
1499
|
appContext: null,
|
|
1492
1500
|
ctx: In
|
|
1493
1501
|
};
|
|
1494
|
-
return s ? (Ar(c, n), a & 128 && e.normalize(c)) : n && (c.shapeFlag |=
|
|
1502
|
+
return s ? (Ar(c, n), a & 128 && e.normalize(c)) : n && (c.shapeFlag |= M(n) ? 8 : 16), process.env.NODE_ENV !== "production" && c.key !== c.key && Xt("VNode created with invalid key (NaN). VNode type:", c.type), c;
|
|
1495
1503
|
}
|
|
1496
1504
|
var wr = process.env.NODE_ENV === "production" ? Tr : br;
|
|
1497
1505
|
function Tr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
@@ -1502,9 +1510,9 @@ function Tr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
1502
1510
|
if (Ur(e) && (e = e.__vccOpts), t) {
|
|
1503
1511
|
t = Er(t);
|
|
1504
1512
|
let { class: e, style: n } = t;
|
|
1505
|
-
e && !
|
|
1513
|
+
e && !M(e) && (t.class = z(e)), N(n) && (/* @__PURE__ */ Et(n) && !k(n) && (n = T({}, n)), t.style = le(n));
|
|
1506
1514
|
}
|
|
1507
|
-
let o =
|
|
1515
|
+
let o = M(e) ? 1 : pr(e) ? 128 : Wn(e) ? 64 : N(e) ? 4 : j(e) ? 2 : 0;
|
|
1508
1516
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ Et(e) && (e = /* @__PURE__ */ q(e), Xt("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)), Cr(e, t, n, r, i, o, a, !0);
|
|
1509
1517
|
}
|
|
1510
1518
|
function Er(e) {
|
|
@@ -1651,7 +1659,7 @@ function Gr() {
|
|
|
1651
1659
|
let e = { style: "color:#3ba776" }, t = { style: "color:#1677ff" }, n = { style: "color:#f5222d" }, r = { style: "color:#eb2f96" }, i = {
|
|
1652
1660
|
__vue_custom_formatter: !0,
|
|
1653
1661
|
header(t) {
|
|
1654
|
-
if (!
|
|
1662
|
+
if (!N(t)) return null;
|
|
1655
1663
|
if (t.__isVue) return [
|
|
1656
1664
|
"div",
|
|
1657
1665
|
e,
|
|
@@ -1764,7 +1772,7 @@ function Gr() {
|
|
|
1764
1772
|
"span",
|
|
1765
1773
|
r,
|
|
1766
1774
|
e
|
|
1767
|
-
] :
|
|
1775
|
+
] : N(e) ? ["object", { object: i ? /* @__PURE__ */ q(e) : e }] : [
|
|
1768
1776
|
"span",
|
|
1769
1777
|
n,
|
|
1770
1778
|
String(e)
|
|
@@ -1779,7 +1787,7 @@ function Gr() {
|
|
|
1779
1787
|
}
|
|
1780
1788
|
function l(e, t, n) {
|
|
1781
1789
|
let r = e[n];
|
|
1782
|
-
if (k(r) && r.includes(t) ||
|
|
1790
|
+
if (k(r) && r.includes(t) || N(r) && t in r || e.extends && l(e.extends, t, n) || e.mixins && e.mixins.some((e) => l(e, t, n))) return !0;
|
|
1783
1791
|
}
|
|
1784
1792
|
function u(e) {
|
|
1785
1793
|
return /* @__PURE__ */ Tt(e) ? "ShallowRef" : e.effect ? "ComputedRef" : "Ref";
|
|
@@ -2376,27 +2384,27 @@ function Ui(e) {
|
|
|
2376
2384
|
return Array.isArray(r) && r.length && r[0] && typeof r[0].jsonPath == "string" ? r[0].jsonPath : "";
|
|
2377
2385
|
}
|
|
2378
2386
|
function Wi(e) {
|
|
2379
|
-
let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, extraBody: p, extraConfig: m, systemPrompt: v, tools: b = [], middleware: x = [], maxToolRounds: S, maxIterations: C, maxRetries: w = 2, retryDelayMs: T = 500, stallMs: E = _i, maxParallelTools: D = 1, maxVerifyAttempts: O = 0, roundTokenBudget: k = 0, onLog: A, onSpan: ee, onTrace: j, onLlmChange:
|
|
2380
|
-
(!Number.isFinite(
|
|
2381
|
-
let
|
|
2387
|
+
let { apiKey: t, baseUrl: r, model: c = "gpt-3.5-turbo", temperature: l = .7, maxTokens: u, extraBody: p, extraConfig: m, systemPrompt: v, tools: b = [], middleware: x = [], maxToolRounds: S, maxIterations: C, maxRetries: w = 2, retryDelayMs: T = 500, stallMs: E = _i, maxParallelTools: D = 1, maxVerifyAttempts: O = 0, roundTokenBudget: k = 0, onLog: A, onSpan: ee, onTrace: j, onLlmChange: M, debug: te = !1 } = e, N = S ?? Li;
|
|
2388
|
+
(!Number.isFinite(N) || N < 1) && (console.warn(`[page-agent-sdk] maxToolRounds=${N} 非法(须 ≥1 正整数),已 clamp 到 1(0/负数致主循环 while 不进 → agent 不调 LLM 静默返回兜底文案)`), N = 1), D > 1 && console.warn(`[page-agent-sdk] maxParallelTools=${D}:并发工具下 dataOps 写工具不互锁(同轮并发两写都在 await handleConflict 让出前取旧基线 → 均通过乐观锁 → 后写覆盖前写,无 VERSION_CONFLICT 回灌);如需精确乐观锁保持 maxParallelTools=1 或写时显式传 expectedHash`);
|
|
2389
|
+
let P = oi({
|
|
2382
2390
|
model: c,
|
|
2383
2391
|
contextWindow: e.contextWindow,
|
|
2384
2392
|
maxOutputTokens: e.maxOutputTokens
|
|
2385
|
-
}),
|
|
2386
|
-
function
|
|
2387
|
-
|
|
2393
|
+
}), ne = u ?? P.maxOutputTokens, re = si(P.contextWindow), ie = ci(P.contextWindow);
|
|
2394
|
+
function F(e) {
|
|
2395
|
+
P = e, re = si(P.contextWindow), ie = ci(P.contextWindow);
|
|
2388
2396
|
}
|
|
2389
|
-
let
|
|
2390
|
-
function
|
|
2397
|
+
let I = /* @__PURE__ */ jt([]);
|
|
2398
|
+
function L(e, t) {
|
|
2391
2399
|
let n = {
|
|
2392
2400
|
timestamp: Date.now(),
|
|
2393
2401
|
type: e,
|
|
2394
2402
|
data: t
|
|
2395
2403
|
};
|
|
2396
|
-
|
|
2404
|
+
I.value.push(n), I.value.length > Ri && I.value.splice(0, I.value.length - Ri), Pt(I), A?.(n), te && console.log(`%c[Agent] ${e}`, "color:#667eea;font-weight:bold", t);
|
|
2397
2405
|
}
|
|
2398
|
-
let
|
|
2399
|
-
|
|
2406
|
+
let ae = (e) => {
|
|
2407
|
+
I.value.push(e), I.value.length > Ri && I.value.splice(0, I.value.length - Ri), Pt(I);
|
|
2400
2408
|
}, oe = /* @__PURE__ */ jt([]), se = 0, ce = !!ee || !!j;
|
|
2401
2409
|
function le(e, t, n, r = {}) {
|
|
2402
2410
|
if (!ce) return null;
|
|
@@ -2418,7 +2426,7 @@ function Wi(e) {
|
|
|
2418
2426
|
apiKey: t,
|
|
2419
2427
|
model: c,
|
|
2420
2428
|
temperature: l,
|
|
2421
|
-
maxTokens:
|
|
2429
|
+
maxTokens: ne,
|
|
2422
2430
|
configuration: {
|
|
2423
2431
|
...r ? { baseURL: f(r) } : {},
|
|
2424
2432
|
fetch: d,
|
|
@@ -2441,14 +2449,14 @@ function Wi(e) {
|
|
|
2441
2449
|
pin: me.has(e.name)
|
|
2442
2450
|
});
|
|
2443
2451
|
}
|
|
2444
|
-
let n = Math.max(2e3, Math.round(
|
|
2452
|
+
let n = Math.max(2e3, Math.round(P.contextWindow * pe)), r = X(e) + t.reduce((e, t) => e + t.tokens, 0);
|
|
2445
2453
|
if (r > n) {
|
|
2446
2454
|
let e = r, i = [];
|
|
2447
2455
|
for (let e of t.filter((e) => !e.pin).sort((e, t) => t.tokens - e.tokens)) {
|
|
2448
2456
|
if (r <= n) break;
|
|
2449
2457
|
i.push(`${e.name}(${e.tokens})`), r -= e.tokens, e.text = "";
|
|
2450
2458
|
}
|
|
2451
|
-
i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${
|
|
2459
|
+
i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${P.contextWindow} 的 ${pe * 100}%),drop 非核心段:${i.join(", ")}(保 base/mission/workingMemory)`);
|
|
2452
2460
|
}
|
|
2453
2461
|
return [e, ...t.filter((e) => e.text).map((e) => e.text)].join("\n\n");
|
|
2454
2462
|
}
|
|
@@ -2468,7 +2476,7 @@ function Wi(e) {
|
|
|
2468
2476
|
baseDelayMs: T,
|
|
2469
2477
|
onRetry: ({ attempt: e, error: t, waitMs: n }) => {
|
|
2470
2478
|
let r = t?.message ?? String(t);
|
|
2471
|
-
|
|
2479
|
+
L("error", {
|
|
2472
2480
|
stage: "model_retry",
|
|
2473
2481
|
attempt: e,
|
|
2474
2482
|
waitMs: n,
|
|
@@ -2500,13 +2508,13 @@ function Wi(e) {
|
|
|
2500
2508
|
};
|
|
2501
2509
|
if (yi(a) && !e._ctxRetry) {
|
|
2502
2510
|
e._ctxRetry = !0;
|
|
2503
|
-
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = H(e.messages, Math.round(
|
|
2504
|
-
return
|
|
2511
|
+
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = H(e.messages, Math.round(P.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
|
|
2512
|
+
return L("error", {
|
|
2505
2513
|
stage: "context_overflow_retry",
|
|
2506
2514
|
at: "launch",
|
|
2507
2515
|
beforeTokens: a,
|
|
2508
2516
|
afterTokens: s,
|
|
2509
|
-
window:
|
|
2517
|
+
window: P.contextWindow
|
|
2510
2518
|
}), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`), _e({
|
|
2511
2519
|
...e,
|
|
2512
2520
|
messages: o
|
|
@@ -2536,7 +2544,7 @@ function Wi(e) {
|
|
|
2536
2544
|
});
|
|
2537
2545
|
}
|
|
2538
2546
|
} catch (a) {
|
|
2539
|
-
if (a instanceof gi) throw s.abort(),
|
|
2547
|
+
if (a instanceof gi) throw s.abort(), L("error", {
|
|
2540
2548
|
stage: "stream_stalled",
|
|
2541
2549
|
waitedMs: a.waitedMs,
|
|
2542
2550
|
stallMs: E
|
|
@@ -2549,13 +2557,13 @@ function Wi(e) {
|
|
|
2549
2557
|
};
|
|
2550
2558
|
if (yi(a) && l === null && u === "" && !e._ctxRetry) {
|
|
2551
2559
|
e._ctxRetry = !0;
|
|
2552
|
-
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = H(e.messages, Math.round(
|
|
2553
|
-
return
|
|
2560
|
+
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = H(e.messages, Math.round(P.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
|
|
2561
|
+
return L("error", {
|
|
2554
2562
|
stage: "context_overflow_retry",
|
|
2555
2563
|
beforeTokens: a,
|
|
2556
2564
|
afterTokens: s,
|
|
2557
|
-
window:
|
|
2558
|
-
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${
|
|
2565
|
+
window: P.contextWindow
|
|
2566
|
+
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${P.contextWindow})`), _e({
|
|
2559
2567
|
...e,
|
|
2560
2568
|
messages: o
|
|
2561
2569
|
}, t, n, r);
|
|
@@ -2581,8 +2589,8 @@ function Wi(e) {
|
|
|
2581
2589
|
files: e.state.files,
|
|
2582
2590
|
vfsAvailable: de.some((e) => e.name === "vfs_read"),
|
|
2583
2591
|
toolName: e.name,
|
|
2584
|
-
threshold:
|
|
2585
|
-
passThroughChars:
|
|
2592
|
+
threshold: re,
|
|
2593
|
+
passThroughChars: ie
|
|
2586
2594
|
}).content, {
|
|
2587
2595
|
content: r,
|
|
2588
2596
|
status: "done"
|
|
@@ -2601,7 +2609,7 @@ function Wi(e) {
|
|
|
2601
2609
|
return Bi(e, t);
|
|
2602
2610
|
}
|
|
2603
2611
|
function be(e) {
|
|
2604
|
-
return !
|
|
2612
|
+
return !te && !A ? [] : e.map((e) => {
|
|
2605
2613
|
let t = ye(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
2606
2614
|
r && (n.content = r.length > zi ? r.slice(0, zi) + `…(截断 ${r.length - zi} 字符)` : r);
|
|
2607
2615
|
let i = e.tool_calls;
|
|
@@ -2618,7 +2626,7 @@ function Wi(e) {
|
|
|
2618
2626
|
});
|
|
2619
2627
|
}
|
|
2620
2628
|
async function xe(e, t, n) {
|
|
2621
|
-
|
|
2629
|
+
I.value = [], oe.value = [], se = 0, B = ui(), B.messages = e, B = await xi(x, B);
|
|
2622
2630
|
let r = e;
|
|
2623
2631
|
for (let e of x) if (e.compressInput) {
|
|
2624
2632
|
let t = le(void 0, "compression", `compress:${e.name}`, {}), n = await e.compressInput(r);
|
|
@@ -2628,9 +2636,9 @@ function Wi(e) {
|
|
|
2628
2636
|
}, ue(t, "ok", { stats: n.stats })) : ue(t);
|
|
2629
2637
|
}
|
|
2630
2638
|
{
|
|
2631
|
-
let e = X(v || "你是一个智能助手。"), n = Math.max(2e3, Math.round(
|
|
2639
|
+
let e = X(v || "你是一个智能助手。"), n = Math.max(2e3, Math.round(P.contextWindow * pe));
|
|
2632
2640
|
if (e > n) {
|
|
2633
|
-
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${n} tokens,窗口 ${
|
|
2641
|
+
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${n} tokens,窗口 ${P.contextWindow} 的 ${pe * 100}%);请缩减 systemPrompt 或换更大窗口模型`;
|
|
2634
2642
|
return console.error(r), t({
|
|
2635
2643
|
type: "error",
|
|
2636
2644
|
message: r,
|
|
@@ -2643,14 +2651,14 @@ function Wi(e) {
|
|
|
2643
2651
|
}
|
|
2644
2652
|
}
|
|
2645
2653
|
let i = he(r);
|
|
2646
|
-
|
|
2654
|
+
L("context", {
|
|
2647
2655
|
model: c,
|
|
2648
2656
|
tools: de.map((e) => e.name),
|
|
2649
2657
|
middleware: x.map((e) => e.name)
|
|
2650
2658
|
});
|
|
2651
2659
|
let l = Ei(x, (e) => _e(e, t, n)), u = Di(x, ve), d = {
|
|
2652
2660
|
rounds: 0,
|
|
2653
|
-
maxToolRounds:
|
|
2661
|
+
maxToolRounds: N,
|
|
2654
2662
|
invokeUsage: {
|
|
2655
2663
|
prompt_tokens: 0,
|
|
2656
2664
|
completion_tokens: 0,
|
|
@@ -2660,12 +2668,12 @@ function Wi(e) {
|
|
|
2660
2668
|
budgetHinted: !1
|
|
2661
2669
|
};
|
|
2662
2670
|
B.loopProgress = d;
|
|
2663
|
-
let f = 0, p = 0, m = Vi(
|
|
2671
|
+
let f = 0, p = 0, m = Vi(N, C), h = null, g = 0, b = !1, S = 0;
|
|
2664
2672
|
try {
|
|
2665
|
-
for (; (f <
|
|
2673
|
+
for (; (f < N || b) && p < m && (p++, !n?.aborted);) {
|
|
2666
2674
|
if (k > 0 && d.invokeUsage.total_tokens > k) {
|
|
2667
2675
|
let e = `本轮 token 预算(约 ${k})已用尽:任务在 ${f} 轮工具调用后中断,已完成的部分均保留。可继续对话,指定下一步(如「继续完成」/「只改 X」/「提高预算重试」)。`;
|
|
2668
|
-
return
|
|
2676
|
+
return L("error", {
|
|
2669
2677
|
stage: "round_token_budget_exceeded",
|
|
2670
2678
|
used: d.invokeUsage.total_tokens,
|
|
2671
2679
|
budget: k,
|
|
@@ -2691,12 +2699,12 @@ function Wi(e) {
|
|
|
2691
2699
|
}), B = Si(x, {
|
|
2692
2700
|
messages: i,
|
|
2693
2701
|
state: B
|
|
2694
|
-
}), i = ge(i), i = H(i, Math.round(
|
|
2702
|
+
}), i = ge(i), i = H(i, Math.round(P.contextWindow * .6));
|
|
2695
2703
|
let r = le(e, "model", c, {
|
|
2696
2704
|
round: f + 1,
|
|
2697
2705
|
tools: de.map((e) => e.name)
|
|
2698
2706
|
});
|
|
2699
|
-
|
|
2707
|
+
L("llm_request", {
|
|
2700
2708
|
round: f + 1,
|
|
2701
2709
|
model: c,
|
|
2702
2710
|
tools: de.map((e) => e.name),
|
|
@@ -2706,7 +2714,7 @@ function Wi(e) {
|
|
|
2706
2714
|
messages: i,
|
|
2707
2715
|
state: B
|
|
2708
2716
|
});
|
|
2709
|
-
i.push(o.message),
|
|
2717
|
+
i.push(o.message), L("llm_response", {
|
|
2710
2718
|
round: f + 1,
|
|
2711
2719
|
content: o.content,
|
|
2712
2720
|
toolCalls: o.toolCalls
|
|
@@ -2729,21 +2737,21 @@ function Wi(e) {
|
|
|
2729
2737
|
name: e.name,
|
|
2730
2738
|
args: e.args,
|
|
2731
2739
|
type: "tool_call"
|
|
2732
|
-
}))),
|
|
2740
|
+
}))), L("middleware", {
|
|
2733
2741
|
stage: "dsml_parsed",
|
|
2734
2742
|
count: n.length,
|
|
2735
2743
|
names: n.map((e) => e.name)
|
|
2736
2744
|
});
|
|
2737
2745
|
} else {
|
|
2738
2746
|
if (e && g < 2) {
|
|
2739
|
-
g += 1, b = !0,
|
|
2747
|
+
g += 1, b = !0, L("middleware", {
|
|
2740
2748
|
stage: "format_retry",
|
|
2741
2749
|
attempt: g,
|
|
2742
2750
|
content: o.content.slice(0, 200)
|
|
2743
2751
|
}), i.push(new a("⚠️ 你刚才把工具调用写成了文本(伪 XML/标签/DSML 标记,如 <|tool_calls|>、<||DSML||>、<invoke name=...>),未被系统识别为工具调用,因此未执行,页面无变化。请直接用标准 function calling(工具调用)格式重新发起工具调用,不要在回复正文里输出这些标签或 JSON 文本。"));
|
|
2744
2752
|
continue;
|
|
2745
2753
|
}
|
|
2746
|
-
if (e && (
|
|
2754
|
+
if (e && (L("error", {
|
|
2747
2755
|
stage: "garbled_exhausted",
|
|
2748
2756
|
retries: g,
|
|
2749
2757
|
content: o.content.slice(0, 200)
|
|
@@ -2754,7 +2762,7 @@ function Wi(e) {
|
|
|
2754
2762
|
code: "GARBLED_TOOL_CALL_EXHAUSTED",
|
|
2755
2763
|
context: { content: o.content.slice(0, 200) }
|
|
2756
2764
|
})), !e && f > 0 && S < 2 && Mi(o.content)) {
|
|
2757
|
-
S += 1, b = !0,
|
|
2765
|
+
S += 1, b = !0, L("middleware", {
|
|
2758
2766
|
stage: "transitional_retry",
|
|
2759
2767
|
attempt: S,
|
|
2760
2768
|
content: o.content.slice(0, 160)
|
|
@@ -2766,10 +2774,10 @@ function Wi(e) {
|
|
|
2766
2774
|
messages: i,
|
|
2767
2775
|
state: B,
|
|
2768
2776
|
response: o,
|
|
2769
|
-
log: (e, t) =>
|
|
2777
|
+
log: (e, t) => L(e, t)
|
|
2770
2778
|
});
|
|
2771
2779
|
if (e) {
|
|
2772
|
-
h = o.content, B.verifyAttempts += 1, i.push(new a(`⚠️ 验证未通过,请修正:${e}`)),
|
|
2780
|
+
h = o.content, B.verifyAttempts += 1, i.push(new a(`⚠️ 验证未通过,请修正:${e}`)), L("middleware", {
|
|
2773
2781
|
stage: "verify_retry",
|
|
2774
2782
|
attempt: B.verifyAttempts,
|
|
2775
2783
|
feedback: e
|
|
@@ -2802,7 +2810,7 @@ function Wi(e) {
|
|
|
2802
2810
|
state: B,
|
|
2803
2811
|
signal: n,
|
|
2804
2812
|
emit: t,
|
|
2805
|
-
logSink:
|
|
2813
|
+
logSink: ae
|
|
2806
2814
|
}
|
|
2807
2815
|
};
|
|
2808
2816
|
}), v = await ni(m, D, async (r) => {
|
|
@@ -2812,7 +2820,7 @@ function Wi(e) {
|
|
|
2812
2820
|
type: "tool_call",
|
|
2813
2821
|
name: r.call.name,
|
|
2814
2822
|
args: r.call.args
|
|
2815
|
-
}),
|
|
2823
|
+
}), L("tool_call", {
|
|
2816
2824
|
round: f + 1,
|
|
2817
2825
|
name: r.call.name,
|
|
2818
2826
|
args: r.call.args,
|
|
@@ -2835,7 +2843,7 @@ function Wi(e) {
|
|
|
2835
2843
|
result: o.content,
|
|
2836
2844
|
status: o.status,
|
|
2837
2845
|
durationMs: s
|
|
2838
|
-
}),
|
|
2846
|
+
}), L("tool_result", {
|
|
2839
2847
|
round: f + 1,
|
|
2840
2848
|
name: r.call.name,
|
|
2841
2849
|
result: o.content,
|
|
@@ -2870,7 +2878,7 @@ function Wi(e) {
|
|
|
2870
2878
|
let e = i[i.length - 1];
|
|
2871
2879
|
if (e && ye(e) === "tool") {
|
|
2872
2880
|
let e = i[0] && ye(i[0]) === "system" ? i.slice(1) : i.slice(), r = [new o(V() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
2873
|
-
|
|
2881
|
+
L("llm_request", {
|
|
2874
2882
|
round: "wrap_up",
|
|
2875
2883
|
model: c,
|
|
2876
2884
|
tools: [],
|
|
@@ -2880,7 +2888,7 @@ function Wi(e) {
|
|
|
2880
2888
|
messages: r,
|
|
2881
2889
|
state: B
|
|
2882
2890
|
});
|
|
2883
|
-
if (B = Ci(x, a, B),
|
|
2891
|
+
if (B = Ci(x, a, B), L("llm_response", {
|
|
2884
2892
|
round: "wrap_up",
|
|
2885
2893
|
content: a.content
|
|
2886
2894
|
}), a.aborted) return t({
|
|
@@ -2891,7 +2899,7 @@ function Wi(e) {
|
|
|
2891
2899
|
let e = a.content;
|
|
2892
2900
|
if (Oi(e)) {
|
|
2893
2901
|
let n = ki(e);
|
|
2894
|
-
|
|
2902
|
+
L("error", {
|
|
2895
2903
|
stage: "garbled_wrapup",
|
|
2896
2904
|
content: e.slice(0, 200)
|
|
2897
2905
|
}), t({
|
|
@@ -2935,7 +2943,7 @@ function Wi(e) {
|
|
|
2935
2943
|
de = [...x.flatMap((e) => e.tools || []), ...e], z();
|
|
2936
2944
|
}
|
|
2937
2945
|
function we(e) {
|
|
2938
|
-
R = e, z(),
|
|
2946
|
+
R = e, z(), M?.(e);
|
|
2939
2947
|
}
|
|
2940
2948
|
return {
|
|
2941
2949
|
invoke: Se,
|
|
@@ -2946,8 +2954,8 @@ function Wi(e) {
|
|
|
2946
2954
|
},
|
|
2947
2955
|
setTools: Ce,
|
|
2948
2956
|
setLlm: we,
|
|
2949
|
-
setModelCaps:
|
|
2950
|
-
debugLogs:
|
|
2957
|
+
setModelCaps: F,
|
|
2958
|
+
debugLogs: I,
|
|
2951
2959
|
spans: oe,
|
|
2952
2960
|
getEffectiveSystemPrompt: () => V()
|
|
2953
2961
|
};
|
|
@@ -8632,7 +8640,7 @@ function Pu(e, n = {}) {
|
|
|
8632
8640
|
name: "get_data",
|
|
8633
8641
|
description: "@deprecated(改用 read,等价且支持 fields/depth/分页)。读取主数据当前值(返回含 hash 供乐观锁);jsonPath 可选读子路径。大结果自动外存 vfs。",
|
|
8634
8642
|
schema: t.object({ jsonPath: t.string().optional().describe("相对主数据根的点号路径(如 components.0.text);不传则读整个主数据") })
|
|
8635
|
-
}),
|
|
8643
|
+
}), M = r(async ({ value: e, expectedHash: t }, n) => {
|
|
8636
8644
|
let r = v(n), i = await k("set", t || (x ? y(r) : void 0));
|
|
8637
8645
|
if (i !== null) return i;
|
|
8638
8646
|
let c = Ia(e);
|
|
@@ -8658,8 +8666,8 @@ function Pu(e, n = {}) {
|
|
|
8658
8666
|
expectedHash: t.string().optional().describe("乐观锁:改前 read/get 返回的 hash;传入则校验,不一致拒绝写入防覆盖。不传则自动用你最后读到的 hash(autoLock)")
|
|
8659
8667
|
})
|
|
8660
8668
|
});
|
|
8661
|
-
A(
|
|
8662
|
-
let
|
|
8669
|
+
A(M);
|
|
8670
|
+
let te = r(async (e, t) => {
|
|
8663
8671
|
let n = v(t), r = e.op ?? e.patch?.op, i = e.jsonPath ?? e.patch?.jsonPath, c = e.value ?? e.patch?.value, u = e.expectedHash;
|
|
8664
8672
|
if (!r) return Y({
|
|
8665
8673
|
code: "MISSING_VALUE",
|
|
@@ -8734,8 +8742,8 @@ function Pu(e, n = {}) {
|
|
|
8734
8742
|
}).optional().describe("容错:误传 write 的 {patch:{op,jsonPath,value}} 形式时从此取值(顶层优先)。正常用顶层 op/jsonPath/value 即可")
|
|
8735
8743
|
})
|
|
8736
8744
|
});
|
|
8737
|
-
A(
|
|
8738
|
-
let
|
|
8745
|
+
A(te);
|
|
8746
|
+
let N = r(async ({ jsonPath: e, expectedHash: t }, n) => {
|
|
8739
8747
|
let r = v(n);
|
|
8740
8748
|
if (!e) return Y({
|
|
8741
8749
|
code: "MISSING_VALUE",
|
|
@@ -8777,8 +8785,8 @@ function Pu(e, n = {}) {
|
|
|
8777
8785
|
expectedHash: t.string().optional().describe("乐观锁:改前 read/get 返回的 hash;传入则校验,不一致拒绝删除防覆盖")
|
|
8778
8786
|
})
|
|
8779
8787
|
});
|
|
8780
|
-
A(
|
|
8781
|
-
let
|
|
8788
|
+
A(N);
|
|
8789
|
+
let P = r(async ({ id: e }, t) => {
|
|
8782
8790
|
let n = v(t);
|
|
8783
8791
|
if (!m.length) return Y({
|
|
8784
8792
|
code: "NO_SNAPSHOT",
|
|
@@ -8807,8 +8815,8 @@ function Pu(e, n = {}) {
|
|
|
8807
8815
|
description: "把主数据回退到某个快照(就地还原,保留响应式)。不传 id 则回退最近一次(快速回退)。可用 history_data({list:true}) 查看快照列表。",
|
|
8808
8816
|
schema: t.object({ id: t.number().int().optional().describe("指定快照序号;不传则回退最近一次") })
|
|
8809
8817
|
});
|
|
8810
|
-
A(
|
|
8811
|
-
let
|
|
8818
|
+
A(P);
|
|
8819
|
+
let ne = r(async ({ id: e, jsonPath: t, list: n }) => {
|
|
8812
8820
|
if (n) {
|
|
8813
8821
|
if (!m.length) return "无快照。set/edit/delete 会自动存快照。";
|
|
8814
8822
|
let e = m.map((e) => {
|
|
@@ -8853,7 +8861,7 @@ function Pu(e, n = {}) {
|
|
|
8853
8861
|
jsonPath: t.string().optional().describe("只看快照的某子路径(相对主数据根);不传则整个快照"),
|
|
8854
8862
|
list: t.boolean().optional().describe("true 则列出快照时间线元信息(序号/操作/标签/时间/大小);不传则查看单条快照内容")
|
|
8855
8863
|
})
|
|
8856
|
-
}),
|
|
8864
|
+
}), re = r(async ({ expr: e, limit: t }) => {
|
|
8857
8865
|
if (typeof s != "object" || !s) return Y({
|
|
8858
8866
|
code: "NOT_OBJECT",
|
|
8859
8867
|
message: `主数据不是对象/数组,无法查询(当前为 ${s === void 0 ? "undefined" : typeof s})`,
|
|
@@ -8879,7 +8887,7 @@ function Pu(e, n = {}) {
|
|
|
8879
8887
|
expr: t.string().describe("JSONPath 表达式,如 $.components[?(@.type==\"card\" && @.price<100)] 或 $..title(递归找所有 title)"),
|
|
8880
8888
|
limit: t.number().int().min(1).max(200).optional().describe("返回结果上限,默认 50")
|
|
8881
8889
|
})
|
|
8882
|
-
}),
|
|
8890
|
+
}), ie = r(async ({ query: e, mode: t, fuzzyThreshold: n, matchKey: r, limit: i }) => {
|
|
8883
8891
|
if (s == null) return Y({
|
|
8884
8892
|
code: "EMPTY",
|
|
8885
8893
|
message: "主数据为空,无可搜索内容"
|
|
@@ -8917,7 +8925,7 @@ function Pu(e, n = {}) {
|
|
|
8917
8925
|
matchKey: t.boolean().optional().describe("是否同时匹配 key 名,默认 true"),
|
|
8918
8926
|
limit: t.number().int().min(1).max(200).optional().describe("返回上限,默认 50")
|
|
8919
8927
|
})
|
|
8920
|
-
}),
|
|
8928
|
+
}), F = r(async ({ script: e, mode: t, jsonPath: n }, r) => {
|
|
8921
8929
|
let i = v(r);
|
|
8922
8930
|
if (e.length > 8e3) return Y({
|
|
8923
8931
|
code: "SCRIPT_TOO_LARGE",
|
|
@@ -9039,8 +9047,8 @@ function Pu(e, n = {}) {
|
|
|
9039
9047
|
jsonPath: t.string().optional().describe("子树模式:仅对 jsonPath 指向的子树执行(降低大 JSON 成本);transform 时返回值作为该子树新值")
|
|
9040
9048
|
})
|
|
9041
9049
|
});
|
|
9042
|
-
A(
|
|
9043
|
-
let
|
|
9050
|
+
A(F, (e) => e?.mode === "transform");
|
|
9051
|
+
let I = r(async ({ jsonPath: e, jsonPaths: t, fields: r, depth: i, offset: a, limit: u }, d) => {
|
|
9044
9052
|
let f = v(d), m = $(s);
|
|
9045
9053
|
if (b(m, f), t && t.length) {
|
|
9046
9054
|
let e = t.map((e) => {
|
|
@@ -9116,7 +9124,7 @@ function Pu(e, n = {}) {
|
|
|
9116
9124
|
offset: t.number().int().min(0).optional().describe("数组分页起始偏移(仅当读取目标是数组时生效,默认 0),配合 limit 分页读大数组"),
|
|
9117
9125
|
limit: t.number().int().min(1).max(200).optional().describe("数组分页每页条数(默认 50,上限 200;仅数组时生效),返回切片 + total/hasMore")
|
|
9118
9126
|
})
|
|
9119
|
-
}),
|
|
9127
|
+
}), L = r(async ({ value: e, patch: t, patches: r, del: i, dryRun: c }, u) => {
|
|
9120
9128
|
let d = v(u), f = "set";
|
|
9121
9129
|
i ? f = "delete" : (r && r.length || t) && (f = "edit");
|
|
9122
9130
|
let g = t?.value === void 0 ? e : t.value, _;
|
|
@@ -9276,8 +9284,8 @@ function Pu(e, n = {}) {
|
|
|
9276
9284
|
dryRun: t.boolean().optional().describe("预检模式:走完整校验链(schema + 白名单 + patch 应用到 clone)但不落盘、不入快照,返回预览。四意图(value/patch/patches/del)均支持;乐观锁冲突照常检测(返回 VERSION_CONFLICT 不挂起)")
|
|
9277
9285
|
})
|
|
9278
9286
|
});
|
|
9279
|
-
A(
|
|
9280
|
-
let
|
|
9287
|
+
A(L);
|
|
9288
|
+
let ae = r(async ({ jsonPath: e }) => {
|
|
9281
9289
|
let t = e || "", n = t ? Ji(o, t) : o;
|
|
9282
9290
|
return n ? `schema${t ? ` @ ${t}` : ""} = ${Q(sa(n))}` : Y({
|
|
9283
9291
|
code: "PATH_DENIED",
|
|
@@ -9496,17 +9504,17 @@ function Pu(e, n = {}) {
|
|
|
9496
9504
|
let le = [
|
|
9497
9505
|
ee,
|
|
9498
9506
|
j,
|
|
9499
|
-
te,
|
|
9500
|
-
ne,
|
|
9501
9507
|
M,
|
|
9508
|
+
te,
|
|
9502
9509
|
N,
|
|
9510
|
+
P,
|
|
9511
|
+
ne,
|
|
9503
9512
|
re,
|
|
9504
9513
|
ie,
|
|
9505
|
-
ae,
|
|
9506
|
-
P,
|
|
9507
9514
|
F,
|
|
9508
9515
|
I,
|
|
9509
9516
|
L,
|
|
9517
|
+
ae,
|
|
9510
9518
|
oe,
|
|
9511
9519
|
...se,
|
|
9512
9520
|
...ce
|
|
@@ -9998,7 +10006,7 @@ function Cd(e, n) {
|
|
|
9998
10006
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
9999
10007
|
let b = /* @__PURE__ */ yt([]), x = cc(e.vfs?.initialFiles, {
|
|
10000
10008
|
persist: s ? { save: (e) => {
|
|
10001
|
-
|
|
10009
|
+
Pt({ vfs: e });
|
|
10002
10010
|
} } : void 0,
|
|
10003
10011
|
maxBytes: e.vfs?.maxBytes,
|
|
10004
10012
|
poolBytes: e.vfs?.poolBytes
|
|
@@ -10023,7 +10031,7 @@ function Cd(e, n) {
|
|
|
10023
10031
|
let t = $i(O?.schema, e._codeAsset.codeField);
|
|
10024
10032
|
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'])"), j.add(e));
|
|
10025
10033
|
}
|
|
10026
|
-
let
|
|
10034
|
+
let M = j.size ? ee.filter((e) => !j.has(e)) : ee, te = j.size ? (A ?? []).filter((e) => !j.has(e)) : A, N = M.length > 0, P = M.flatMap((e) => e._codeAsset.writablePaths), ne = M.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), re = e.checkpoint, ie = re !== void 0 && re !== !1, F = ie ? Bo({
|
|
10027
10035
|
getData: () => z()?.bind,
|
|
10028
10036
|
consumeDataDirty: () => R?.consumeDataDirty?.() ?? !0,
|
|
10029
10037
|
slotPaths: O ? [""] : [],
|
|
@@ -10031,25 +10039,25 @@ function Cd(e, n) {
|
|
|
10031
10039
|
todosMw: S,
|
|
10032
10040
|
getTodos: () => D.current?.getState?.()?.todos ?? [],
|
|
10033
10041
|
messages: b,
|
|
10034
|
-
maxCheckpoints:
|
|
10035
|
-
}) : null,
|
|
10036
|
-
if (
|
|
10037
|
-
let e =
|
|
10042
|
+
maxCheckpoints: re && typeof re == "object" ? re.maxCheckpoints : void 0
|
|
10043
|
+
}) : null, I = !re || typeof re != "object" || re.auto !== !1, L = Rl(e.capabilities), ae = L.dataOps, oe = L.draftWrite, se = L.tracing, ce = L.automation, le = ic(e);
|
|
10044
|
+
if (N) {
|
|
10045
|
+
let e = M.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
10038
10046
|
e && (le += "\n\n" + e);
|
|
10039
10047
|
} else O?.schema && Qi(O.schema) && (le += "\n\n" + ga.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
10040
|
-
let ue =
|
|
10048
|
+
let ue = ae && O ? Pu(O, {
|
|
10041
10049
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
10042
10050
|
maxSnapshots: e.maxSnapshots,
|
|
10043
10051
|
onConflict: a.set,
|
|
10044
10052
|
autoLock: e.autoLock,
|
|
10045
10053
|
interceptors: e.interceptors,
|
|
10046
10054
|
vfsStore: oe || O?.resources?.length ? x : void 0,
|
|
10047
|
-
...
|
|
10048
|
-
...
|
|
10049
|
-
}) : [], de =
|
|
10055
|
+
...P.length ? { pgIdPaths: P } : {},
|
|
10056
|
+
...ne.length ? { largeTextPaths: ne } : {}
|
|
10057
|
+
}) : [], de = ae ? Tu(ue, e.toolMode) : [], R = ae && O ? ue.controller ?? null : null, fe = ae && O?.resources?.length && R?.getResourcesSnapshot ? sd({
|
|
10050
10058
|
getResourcesSnapshot: () => R?.getResourcesSnapshot?.() ?? [],
|
|
10051
10059
|
toolsExposed: e.toolMode === "advanced"
|
|
10052
|
-
}) : void 0, z = () => R?.get() ?? O, B = /* @__PURE__ */ new Map(), pe = rd(
|
|
10060
|
+
}) : void 0, z = () => R?.get() ?? O, B = /* @__PURE__ */ new Map(), pe = rd(L, de, Iu, Hu, Yu);
|
|
10053
10061
|
pe.forEach((e) => B.set(e.name, "builtin"));
|
|
10054
10062
|
let me = [...e.tools || []];
|
|
10055
10063
|
me.forEach((e) => B.set(e.name, "user"));
|
|
@@ -10057,15 +10065,15 @@ function Cd(e, n) {
|
|
|
10057
10065
|
V.forEach((e) => B.set(e.name, "action"));
|
|
10058
10066
|
let he = [], ge = !1, _e = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), ve = _e ? Mo() : null;
|
|
10059
10067
|
ve && B.set(Ao, "builtin");
|
|
10060
|
-
let ye =
|
|
10061
|
-
let e =
|
|
10062
|
-
return e.length ?
|
|
10068
|
+
let ye = ie && F ? [r(async () => {
|
|
10069
|
+
let e = F.list();
|
|
10070
|
+
return e.length ? F.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
10063
10071
|
}, {
|
|
10064
10072
|
name: "restore_last_checkpoint",
|
|
10065
10073
|
description: "回退到最近一次正常状态(整体还原对话历史 + 主数据 + vfs + todos)。当本轮操作出错、页面被改坏、或走偏时调用,回到本轮起点重新来过。不传参数即回退最近一次。",
|
|
10066
10074
|
schema: t.object({}).optional()
|
|
10067
10075
|
}), r(async () => {
|
|
10068
|
-
let e =
|
|
10076
|
+
let e = F.list();
|
|
10069
10077
|
return e.length ? "可用 checkpoint:\n" + e.map((e) => `#${e.id} [${e.label ?? "auto"}] 消息数=${e.messageCount} 时间=${new Date(e.timestamp).toLocaleTimeString()}`).join("\n") : "无可用 checkpoint。";
|
|
10070
10078
|
}, {
|
|
10071
10079
|
name: "list_checkpoints",
|
|
@@ -10073,7 +10081,7 @@ function Cd(e, n) {
|
|
|
10073
10081
|
schema: t.object({}).optional()
|
|
10074
10082
|
})] : [];
|
|
10075
10083
|
ye.forEach((e) => B.set(e.name, "builtin"));
|
|
10076
|
-
let H =
|
|
10084
|
+
let H = L.focus, be = r(async ({ path: e, label: t }) => {
|
|
10077
10085
|
let n = z()?.schema;
|
|
10078
10086
|
return n ? Ji(n, e) ? (w.setFocus({
|
|
10079
10087
|
path: e,
|
|
@@ -10161,12 +10169,12 @@ function Cd(e, n) {
|
|
|
10161
10169
|
]);
|
|
10162
10170
|
return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
|
|
10163
10171
|
}
|
|
10164
|
-
let De =
|
|
10172
|
+
let De = L.planning, Oe = L.missionAnchor, ke = L.workingMemory, Ae = L.skills, je = L.vfs || N;
|
|
10165
10173
|
if (je) for (let e of hc) B.set(e, "builtin");
|
|
10166
10174
|
if (De) for (let e of S.tools ?? []) B.set(e.name, "builtin");
|
|
10167
|
-
let Me =
|
|
10168
|
-
e.debug &&
|
|
10169
|
-
let Pe =
|
|
10175
|
+
let Me = L.summarization, Ne = L.agentCompression && !!d;
|
|
10176
|
+
e.debug && L.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
10177
|
+
let Pe = L.memory, Fe = L.subagent, Ie = Fe ? us() : void 0, Le = e.verify?.maxAttempts ?? 2, Re = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), G = e.capabilities?.verify === !1, ze = (L.verify || Re && !G) && e.verify?.enabled !== !1 && Le > 0, Be = L.contextInspector;
|
|
10170
10178
|
Re && !ze && e.verify?.enabled !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
|
|
10171
10179
|
let Ve = e.subagent, He = Ve?.allowedTools ?? [], Ue = e.permissions?.length ? Oo(e.permissions) : void 0, We = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? ko(e.approval) : void 0, Ge = [...Ue ? [Ue] : [], ...We ? [We] : []], Ke = !Fe || Ve?.enabled === !1 ? void 0 : Es({
|
|
10172
10180
|
llm: Ve?.llm ?? e.llm,
|
|
@@ -10190,7 +10198,7 @@ function Cd(e, n) {
|
|
|
10190
10198
|
i.prompt_tokens = (i.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), i.completion_tokens = (i.completion_tokens ?? 0) + (e.completion_tokens ?? 0), i.total_tokens = (i.total_tokens ?? 0) + (e.total_tokens ?? 0);
|
|
10191
10199
|
},
|
|
10192
10200
|
timeoutMs: Ve?.timeoutMs
|
|
10193
|
-
}), qe =
|
|
10201
|
+
}), qe = te?.map((e) => {
|
|
10194
10202
|
if (!e._codeAsset) return e;
|
|
10195
10203
|
let t = e._codeAsset, n = Nc({
|
|
10196
10204
|
writablePaths: t.writablePaths,
|
|
@@ -10207,9 +10215,9 @@ function Cd(e, n) {
|
|
|
10207
10215
|
...e,
|
|
10208
10216
|
middleware: r
|
|
10209
10217
|
};
|
|
10210
|
-
}), Je =
|
|
10218
|
+
}), Je = N && Fe ? Pc() : void 0, Ye = Je ? Bc({
|
|
10211
10219
|
getBind: () => z()?.bind,
|
|
10212
|
-
writablePaths:
|
|
10220
|
+
writablePaths: P,
|
|
10213
10221
|
getLocked: () => Je.locked(),
|
|
10214
10222
|
tools: U
|
|
10215
10223
|
}) : void 0, Xe = Fe && qe !== void 0 ? ks(qe, {
|
|
@@ -10230,7 +10238,7 @@ function Cd(e, n) {
|
|
|
10230
10238
|
timeoutMs: e.subagent?.timeoutMs,
|
|
10231
10239
|
...Je ? {
|
|
10232
10240
|
componentLock: Je,
|
|
10233
|
-
resolveComponents: (e) => Fc(e, kc(z()?.bind,
|
|
10241
|
+
resolveComponents: (e) => Fc(e, kc(z()?.bind, P))
|
|
10234
10242
|
} : {}
|
|
10235
10243
|
}) : void 0, Ze = Xe ? Xe.controller : null, Qe = [
|
|
10236
10244
|
"get_data",
|
|
@@ -10250,14 +10258,14 @@ function Cd(e, n) {
|
|
|
10250
10258
|
contextWindow: f.contextWindow,
|
|
10251
10259
|
thresholdRatio: Hl(e, f.contextWindow).summaryThresholdRatio
|
|
10252
10260
|
}) : void 0, nt = od({
|
|
10253
|
-
...
|
|
10261
|
+
...L,
|
|
10254
10262
|
humanConfirm: _e,
|
|
10255
|
-
subagents:
|
|
10263
|
+
subagents: te?.map((e) => ({
|
|
10256
10264
|
id: e.id,
|
|
10257
10265
|
description: e.description,
|
|
10258
10266
|
temperature: e.temperature
|
|
10259
10267
|
}))
|
|
10260
|
-
},
|
|
10268
|
+
}, ae && !!O, e.toolMode, !!O?.resources?.length, { promptSoftCap: as(f.contextWindow, h.promptSoftCapTokens) }), rt = O ? {
|
|
10261
10269
|
name: "dataHint",
|
|
10262
10270
|
augmentPrompt: () => rc(z(), e.schemaHint) || void 0
|
|
10263
10271
|
} : null, it = e.augmentSystem ? {
|
|
@@ -10320,7 +10328,7 @@ function Cd(e, n) {
|
|
|
10320
10328
|
...De ? [S] : [],
|
|
10321
10329
|
...Ae ? [ot = xo(e.skills || [], {
|
|
10322
10330
|
readVfs: je ? (e) => x.files[e]?.content : void 0,
|
|
10323
|
-
hostScriptEnabled:
|
|
10331
|
+
hostScriptEnabled: L.skillHostScript,
|
|
10324
10332
|
onToolsReady: (e, t) => {
|
|
10325
10333
|
for (let n of t) {
|
|
10326
10334
|
let t = Te.findIndex((e) => e.name === n.name);
|
|
@@ -10336,7 +10344,7 @@ function Cd(e, n) {
|
|
|
10336
10344
|
...fe ? [fe] : [],
|
|
10337
10345
|
...Pe ? [E] : [],
|
|
10338
10346
|
...Ue ? [Ue] : [],
|
|
10339
|
-
...
|
|
10347
|
+
...ie && I && F ? [Vo(F)] : [],
|
|
10340
10348
|
..._e ? [No()] : [],
|
|
10341
10349
|
...We ? [We] : [],
|
|
10342
10350
|
...et ? [et] : [],
|
|
@@ -10378,7 +10386,11 @@ function Cd(e, n) {
|
|
|
10378
10386
|
}
|
|
10379
10387
|
let xt = /* @__PURE__ */ At([]);
|
|
10380
10388
|
async function St() {
|
|
10381
|
-
|
|
10389
|
+
if (s) try {
|
|
10390
|
+
xt.value = (await s.listSessions(n)).sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
10391
|
+
} catch (t) {
|
|
10392
|
+
e.debug && console.warn("[page-agent-sdk][persist] refreshSessions 失败(已吞):", t);
|
|
10393
|
+
}
|
|
10382
10394
|
}
|
|
10383
10395
|
let Ct = gd(), wt = /* @__PURE__ */ new Set();
|
|
10384
10396
|
function Tt(e) {
|
|
@@ -10409,7 +10421,7 @@ function Cd(e, n) {
|
|
|
10409
10421
|
refCount: 0,
|
|
10410
10422
|
mcpClosers: [],
|
|
10411
10423
|
mcpServers: [],
|
|
10412
|
-
checkpoint:
|
|
10424
|
+
checkpoint: F,
|
|
10413
10425
|
dataOpsController: R,
|
|
10414
10426
|
skillsController: ot ? ot.controller : null,
|
|
10415
10427
|
infoTick: o,
|
|
@@ -10434,7 +10446,7 @@ function Cd(e, n) {
|
|
|
10434
10446
|
U = W(), q.agent && q.agent.setTools(U);
|
|
10435
10447
|
},
|
|
10436
10448
|
applySnapshot(t) {
|
|
10437
|
-
if (t.messages?.length && b.push(...t.messages), t.vfs && x.hydrate && x.hydrate(t.vfs), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && E.reset(t.memory), t.checkpoints?.length &&
|
|
10449
|
+
if (t.messages?.length && b.push(...t.messages), t.vfs && x.hydrate && x.hydrate(t.vfs), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && E.reset(t.memory), t.checkpoints?.length && F && F.importStack(t.checkpoints), t.usage && Object.assign(i, t.usage), t.mission && Oe && C.setMission(t.mission), t.workingMemory && ke && T.restore(t.workingMemory), H) {
|
|
10438
10450
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
10439
10451
|
if (r.length) {
|
|
10440
10452
|
let t = z()?.schema, n = t ? r.filter((e) => Ji(t, e.path)) : [];
|
|
@@ -10466,7 +10478,7 @@ function Cd(e, n) {
|
|
|
10466
10478
|
};
|
|
10467
10479
|
},
|
|
10468
10480
|
afterRound() {
|
|
10469
|
-
jt(),
|
|
10481
|
+
jt(), It();
|
|
10470
10482
|
},
|
|
10471
10483
|
async send(e, t) {
|
|
10472
10484
|
await q.initDone, t ??= {}, t?.mission && Oe && C.setMission(t.mission);
|
|
@@ -10496,8 +10508,8 @@ function Cd(e, n) {
|
|
|
10496
10508
|
} catch (e) {
|
|
10497
10509
|
if (di(e, t.signal)) throw e;
|
|
10498
10510
|
let n = Zr(e, "fatal");
|
|
10499
|
-
if (i < r &&
|
|
10500
|
-
i += 1,
|
|
10511
|
+
if (i < r && F?.canRestore()) {
|
|
10512
|
+
i += 1, F.restore(), a = !0, K({
|
|
10501
10513
|
type: "error",
|
|
10502
10514
|
message: `致命错误自动恢复(${i}/${r}):${n.message},已回退 checkpoint 重试`,
|
|
10503
10515
|
severity: "observable",
|
|
@@ -10533,7 +10545,7 @@ function Cd(e, n) {
|
|
|
10533
10545
|
break;
|
|
10534
10546
|
}
|
|
10535
10547
|
let o = e[a];
|
|
10536
|
-
|
|
10548
|
+
F && F.save(`batch:${a}`);
|
|
10537
10549
|
let c = b.length;
|
|
10538
10550
|
try {
|
|
10539
10551
|
b.push({
|
|
@@ -10603,27 +10615,29 @@ function Cd(e, n) {
|
|
|
10603
10615
|
if (a.resolve("keep_external"), q.sessionId && s) {
|
|
10604
10616
|
if (Oe) {
|
|
10605
10617
|
let e = C.getMission();
|
|
10606
|
-
e &&
|
|
10618
|
+
e && Pt({ mission: e });
|
|
10607
10619
|
}
|
|
10608
10620
|
if (ke) {
|
|
10609
10621
|
let e = T.getWorkingMemory();
|
|
10610
|
-
e &&
|
|
10622
|
+
e && Pt({ workingMemory: e });
|
|
10611
10623
|
}
|
|
10612
10624
|
if (H) {
|
|
10613
10625
|
let e = w.getFocuses();
|
|
10614
|
-
|
|
10626
|
+
Pt({ focus: e.length ? e : null });
|
|
10615
10627
|
}
|
|
10616
10628
|
}
|
|
10617
10629
|
x.flush?.(), await s.flush();
|
|
10618
10630
|
let r = t ?? "", i;
|
|
10619
|
-
return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title), q.sessionId = r, b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(),
|
|
10631
|
+
return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title), q.sessionId = r, b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), F && F.importStack([]), q.agent.debugLogs.value = [], i ||= await s.load(n, r), i && (q.applySnapshot(i), K({
|
|
10620
10632
|
type: "session_restored",
|
|
10621
10633
|
sessionId: r,
|
|
10622
10634
|
rounds: i.messages?.length ?? 0
|
|
10623
|
-
})), e.memory &&
|
|
10635
|
+
})), e.memory && Pt({ memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), St(), Mt = void 0, Nt = !1, q.infoTick.value++, r;
|
|
10624
10636
|
},
|
|
10625
10637
|
resetSession: () => {
|
|
10626
|
-
Et(), a.resolve("keep_external"), q.sessionId = ul(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(),
|
|
10638
|
+
Et(), a.resolve("keep_external"), q.sessionId = ul(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), F && F.importStack([]), q.agent && (q.agent.debugLogs.value = []), s && s.createSession(q.agentId, e.session?.title, q.sessionId).catch((t) => {
|
|
10639
|
+
e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
|
|
10640
|
+
}), K({
|
|
10627
10641
|
type: "session_restored",
|
|
10628
10642
|
sessionId: q.sessionId,
|
|
10629
10643
|
rounds: 0
|
|
@@ -10784,10 +10798,10 @@ function Cd(e, n) {
|
|
|
10784
10798
|
})(),
|
|
10785
10799
|
mcp: { servers: q.mcpServers },
|
|
10786
10800
|
lastCompression: q.agent?.getState?.()?.lastCompression,
|
|
10787
|
-
checkpoints:
|
|
10801
|
+
checkpoints: F ? {
|
|
10788
10802
|
enabled: !0,
|
|
10789
|
-
auto:
|
|
10790
|
-
list:
|
|
10803
|
+
auto: I,
|
|
10804
|
+
list: F.list()
|
|
10791
10805
|
} : void 0
|
|
10792
10806
|
};
|
|
10793
10807
|
},
|
|
@@ -10849,7 +10863,7 @@ function Cd(e, n) {
|
|
|
10849
10863
|
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", q.sessionId, `${t.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", q.sessionId);
|
|
10850
10864
|
} else q.sessionId = await s.createSession(n, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", q.sessionId);
|
|
10851
10865
|
} else q.sessionId = await s.createSession(n, t.title);
|
|
10852
|
-
e.memory &&
|
|
10866
|
+
e.memory && Pt({ memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), St();
|
|
10853
10867
|
}
|
|
10854
10868
|
async function Ot() {
|
|
10855
10869
|
await ft();
|
|
@@ -10887,35 +10901,49 @@ function Cd(e, n) {
|
|
|
10887
10901
|
try {
|
|
10888
10902
|
let e = await l(ts(t, v)), i = b.indexOf(n);
|
|
10889
10903
|
if (i < 0) return;
|
|
10890
|
-
b[i].content = Yo(t, r, e),
|
|
10904
|
+
b[i].content = Yo(t, r, e), It();
|
|
10891
10905
|
} catch {}
|
|
10892
10906
|
})();
|
|
10893
10907
|
}
|
|
10894
10908
|
}
|
|
10895
10909
|
let Mt, Nt = !1;
|
|
10896
|
-
function Pt() {
|
|
10910
|
+
function Pt(t) {
|
|
10911
|
+
!q.sessionId || !s || s.save(n, q.sessionId, t).catch((t) => {
|
|
10912
|
+
e.debug && console.warn("[page-agent-sdk][persist] save 失败(已吞):", t);
|
|
10913
|
+
});
|
|
10914
|
+
}
|
|
10915
|
+
function Ft(t, r) {
|
|
10916
|
+
s && s.updateTitle(n, t, r).catch((t) => {
|
|
10917
|
+
e.debug && console.warn("[page-agent-sdk][persist] updateTitle 失败(已吞):", t);
|
|
10918
|
+
});
|
|
10919
|
+
}
|
|
10920
|
+
function It() {
|
|
10897
10921
|
if (!q.sessionId || !s) return;
|
|
10898
|
-
|
|
10899
|
-
s.save(n, q.sessionId, { messages: t });
|
|
10900
|
-
let r = q.agent?.getState?.()?.todos ?? [];
|
|
10901
|
-
if (s.save(n, q.sessionId, { todos: r }), Oe) {
|
|
10922
|
+
if (Pt({ messages: JSON.parse(JSON.stringify(b)) }), Pt({ todos: q.agent?.getState?.()?.todos ?? [] }), Oe) {
|
|
10902
10923
|
let e = C.getMission();
|
|
10903
|
-
e &&
|
|
10924
|
+
e && Pt({ mission: e });
|
|
10904
10925
|
}
|
|
10905
10926
|
if (ke) {
|
|
10906
10927
|
let e = T.getWorkingMemory();
|
|
10907
|
-
e &&
|
|
10928
|
+
e && Pt({ workingMemory: e });
|
|
10908
10929
|
}
|
|
10909
10930
|
if (H) {
|
|
10910
10931
|
let e = w.getFocuses();
|
|
10911
|
-
|
|
10912
|
-
}
|
|
10913
|
-
ce &&
|
|
10914
|
-
let
|
|
10915
|
-
|
|
10916
|
-
|
|
10917
|
-
e
|
|
10918
|
-
|
|
10932
|
+
Pt({ focus: e.length ? e : null });
|
|
10933
|
+
}
|
|
10934
|
+
ce && F && (Pt({ checkpoints: F.exportStack() }), Pt({ usage: i }));
|
|
10935
|
+
let t = Qc(b);
|
|
10936
|
+
if (t && t !== Mt && (Mt = t, Ft(q.sessionId, t)), e.autoTitle !== !1 && u && !Nt && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant")) {
|
|
10937
|
+
Nt = !0;
|
|
10938
|
+
let e = q.sessionId;
|
|
10939
|
+
(async () => {
|
|
10940
|
+
try {
|
|
10941
|
+
let t = await u(b);
|
|
10942
|
+
t && q.refCount > 0 && q.sessionId === e && (Ft(e, t), await St());
|
|
10943
|
+
} catch {}
|
|
10944
|
+
})();
|
|
10945
|
+
}
|
|
10946
|
+
e.debug && console.log("[page-agent-sdk][persist] save", q.sessionId, `${b.length} msgs`);
|
|
10919
10947
|
}
|
|
10920
10948
|
return q.initDone = (async () => {
|
|
10921
10949
|
await Dt(), await Ot(), e.mcp?.length && (async () => {
|