page-agent-sdk 4.9.3 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/dist/page-agent-sdk.headless.js +619 -470
- package/dist/page-agent-sdk.iife.js +169 -169
- package/dist/page-agent-sdk.js +2257 -1942
- package/dist/page-agent-sdk.legacy.js +13012 -12671
- package/dist/page-agent-sdk.umd.cjs +50 -50
- 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 +42 -0
|
@@ -514,12 +514,12 @@ function ye(e) {
|
|
|
514
514
|
return t;
|
|
515
515
|
} else if (de(e) || R(e)) return e;
|
|
516
516
|
}
|
|
517
|
-
var
|
|
517
|
+
var be = /;(?![^(]*\))/g, U = /:([^]+)/, xe = /\/\*[^]*?\*\//g;
|
|
518
518
|
function Se(e) {
|
|
519
519
|
let t = {};
|
|
520
|
-
return e.replace(xe, "").split(
|
|
520
|
+
return e.replace(xe, "").split(be).forEach((e) => {
|
|
521
521
|
if (e) {
|
|
522
|
-
let n = e.split(
|
|
522
|
+
let n = e.split(U);
|
|
523
523
|
n.length > 1 && (t[n[0].trim()] = n[1].trim());
|
|
524
524
|
}
|
|
525
525
|
}), t;
|
|
@@ -536,16 +536,16 @@ function Ce(e) {
|
|
|
536
536
|
}
|
|
537
537
|
//#endregion
|
|
538
538
|
//#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
539
|
-
function
|
|
539
|
+
function we(e, ...t) {
|
|
540
540
|
console.warn(`[Vue warn] ${e}`, ...t);
|
|
541
541
|
}
|
|
542
|
-
var
|
|
542
|
+
var W;
|
|
543
543
|
function Te() {
|
|
544
|
-
return
|
|
544
|
+
return W;
|
|
545
545
|
}
|
|
546
546
|
var G, Ee = /* @__PURE__ */ new WeakSet(), De = class {
|
|
547
547
|
constructor(e) {
|
|
548
|
-
this.fn = e, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0,
|
|
548
|
+
this.fn = e, this.deps = void 0, this.depsTail = void 0, this.flags = 5, this.next = void 0, this.cleanup = void 0, this.scheduler = void 0, W && (W.active ? W.effects.push(this) : this.flags &= -2);
|
|
549
549
|
}
|
|
550
550
|
pause() {
|
|
551
551
|
this.flags |= 64;
|
|
@@ -559,12 +559,12 @@ var G, Ee = /* @__PURE__ */ new WeakSet(), De = class {
|
|
|
559
559
|
run() {
|
|
560
560
|
if (!(this.flags & 1)) return this.fn();
|
|
561
561
|
this.flags |= 2, Ue(this), Pe(this);
|
|
562
|
-
let e = G, t =
|
|
563
|
-
G = this,
|
|
562
|
+
let e = G, t = K;
|
|
563
|
+
G = this, K = !0;
|
|
564
564
|
try {
|
|
565
565
|
return this.fn();
|
|
566
566
|
} finally {
|
|
567
|
-
process.env.NODE_ENV !== "production" && G !== this &&
|
|
567
|
+
process.env.NODE_ENV !== "production" && G !== this && we("Active effect was not restored correctly - this is likely a Vue internal bug."), Fe(this), G = e, K = t, this.flags &= -3;
|
|
568
568
|
}
|
|
569
569
|
}
|
|
570
570
|
stop() {
|
|
@@ -624,7 +624,7 @@ function Fe(e) {
|
|
|
624
624
|
let t, n = e.depsTail, r = n;
|
|
625
625
|
for (; r;) {
|
|
626
626
|
let e = r.prevDep;
|
|
627
|
-
r.version === -1 ? (r === n && (n = e), Re(r),
|
|
627
|
+
r.version === -1 ? (r === n && (n = e), Re(r), ze(r)) : t = r, r.dep.activeLink = r.prevActiveLink, r.prevActiveLink = void 0, r = e;
|
|
628
628
|
}
|
|
629
629
|
e.deps = t, e.depsTail = n;
|
|
630
630
|
}
|
|
@@ -635,8 +635,8 @@ function Ie(e) {
|
|
|
635
635
|
function Le(e) {
|
|
636
636
|
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === We) || (e.globalVersion = We, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !Ie(e)))) return;
|
|
637
637
|
e.flags |= 2;
|
|
638
|
-
let t = e.dep, n = G, r =
|
|
639
|
-
G = e,
|
|
638
|
+
let t = e.dep, n = G, r = K;
|
|
639
|
+
G = e, K = !0;
|
|
640
640
|
try {
|
|
641
641
|
Pe(e);
|
|
642
642
|
let n = e.fn(e._value);
|
|
@@ -644,7 +644,7 @@ function Le(e) {
|
|
|
644
644
|
} catch (e) {
|
|
645
645
|
throw t.version++, e;
|
|
646
646
|
} finally {
|
|
647
|
-
G = n,
|
|
647
|
+
G = n, K = r, Fe(e), e.flags &= -3;
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
function Re(e, t = !1) {
|
|
@@ -655,17 +655,17 @@ function Re(e, t = !1) {
|
|
|
655
655
|
}
|
|
656
656
|
!t && !--n.sc && n.map && n.map.delete(n.key);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function ze(e) {
|
|
659
659
|
let { prevDep: t, nextDep: n } = e;
|
|
660
660
|
t && (t.nextDep = n, e.prevDep = void 0), n && (n.prevDep = t, e.nextDep = void 0);
|
|
661
661
|
}
|
|
662
|
-
var
|
|
662
|
+
var K = !0, Be = [];
|
|
663
663
|
function Ve() {
|
|
664
|
-
Be.push(
|
|
664
|
+
Be.push(K), K = !1;
|
|
665
665
|
}
|
|
666
666
|
function He() {
|
|
667
667
|
let e = Be.pop();
|
|
668
|
-
|
|
668
|
+
K = e === void 0 || e;
|
|
669
669
|
}
|
|
670
670
|
function Ue(e) {
|
|
671
671
|
let { cleanup: t } = e;
|
|
@@ -688,7 +688,7 @@ var We = 0, Ge = class {
|
|
|
688
688
|
this.computed = e, this.version = 0, this.activeLink = void 0, this.subs = void 0, this.map = void 0, this.key = void 0, this.sc = 0, this.__v_skip = !0, process.env.NODE_ENV !== "production" && (this.subsHead = void 0);
|
|
689
689
|
}
|
|
690
690
|
track(e) {
|
|
691
|
-
if (!G || !
|
|
691
|
+
if (!G || !K || G === this.computed) return;
|
|
692
692
|
let t = this.activeLink;
|
|
693
693
|
if (t === void 0 || t.sub !== G) t = this.activeLink = new Ge(G, this), G.deps ? (t.prevDep = G.depsTail, G.depsTail.nextDep = t, G.depsTail = t) : G.deps = G.depsTail = t, qe(t);
|
|
694
694
|
else if (t.version === -1 && (t.version = this.version, t.nextDep)) {
|
|
@@ -723,7 +723,7 @@ function qe(e) {
|
|
|
723
723
|
}
|
|
724
724
|
var Je = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Object iterate"), Xe = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Map keys iterate"), Ze = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Array iterate");
|
|
725
725
|
function Qe(e, t, n) {
|
|
726
|
-
if (
|
|
726
|
+
if (K && G) {
|
|
727
727
|
let r = Je.get(e);
|
|
728
728
|
r || Je.set(e, r = /* @__PURE__ */ new Map());
|
|
729
729
|
let i = r.get(n);
|
|
@@ -774,81 +774,81 @@ function $e(e, t, n, r, i, a) {
|
|
|
774
774
|
}
|
|
775
775
|
function et(e) {
|
|
776
776
|
let t = /* @__PURE__ */ Y(e);
|
|
777
|
-
return t === e ? t : (Qe(t, "iterate", Ze), /* @__PURE__ */
|
|
777
|
+
return t === e ? t : (Qe(t, "iterate", Ze), /* @__PURE__ */ Rt(e) ? t : t.map(Vt));
|
|
778
778
|
}
|
|
779
779
|
function tt(e) {
|
|
780
780
|
return Qe(e = /* @__PURE__ */ Y(e), "iterate", Ze), e;
|
|
781
781
|
}
|
|
782
|
-
function
|
|
783
|
-
return /* @__PURE__ */
|
|
782
|
+
function q(e, t) {
|
|
783
|
+
return /* @__PURE__ */ Lt(e) ? Ht(/* @__PURE__ */ It(e) ? Vt(t) : t) : Vt(t);
|
|
784
784
|
}
|
|
785
|
-
var
|
|
785
|
+
var nt = {
|
|
786
786
|
__proto__: null,
|
|
787
787
|
[Symbol.iterator]() {
|
|
788
|
-
return
|
|
788
|
+
return rt(this, Symbol.iterator, (e) => q(this, e));
|
|
789
789
|
},
|
|
790
790
|
concat(...e) {
|
|
791
791
|
return et(this).concat(...e.map((e) => F(e) ? et(e) : e));
|
|
792
792
|
},
|
|
793
793
|
entries() {
|
|
794
|
-
return
|
|
794
|
+
return rt(this, "entries", (e) => (e[1] = q(this, e[1]), e));
|
|
795
795
|
},
|
|
796
796
|
every(e, t) {
|
|
797
|
-
return
|
|
797
|
+
return at(this, "every", e, t, void 0, arguments);
|
|
798
798
|
},
|
|
799
799
|
filter(e, t) {
|
|
800
|
-
return
|
|
800
|
+
return at(this, "filter", e, t, (e) => e.map((e) => q(this, e)), arguments);
|
|
801
801
|
},
|
|
802
802
|
find(e, t) {
|
|
803
|
-
return
|
|
803
|
+
return at(this, "find", e, t, (e) => q(this, e), arguments);
|
|
804
804
|
},
|
|
805
805
|
findIndex(e, t) {
|
|
806
|
-
return
|
|
806
|
+
return at(this, "findIndex", e, t, void 0, arguments);
|
|
807
807
|
},
|
|
808
808
|
findLast(e, t) {
|
|
809
|
-
return
|
|
809
|
+
return at(this, "findLast", e, t, (e) => q(this, e), arguments);
|
|
810
810
|
},
|
|
811
811
|
findLastIndex(e, t) {
|
|
812
|
-
return
|
|
812
|
+
return at(this, "findLastIndex", e, t, void 0, arguments);
|
|
813
813
|
},
|
|
814
814
|
forEach(e, t) {
|
|
815
|
-
return
|
|
815
|
+
return at(this, "forEach", e, t, void 0, arguments);
|
|
816
816
|
},
|
|
817
817
|
includes(...e) {
|
|
818
|
-
return
|
|
818
|
+
return st(this, "includes", e);
|
|
819
819
|
},
|
|
820
820
|
indexOf(...e) {
|
|
821
|
-
return
|
|
821
|
+
return st(this, "indexOf", e);
|
|
822
822
|
},
|
|
823
823
|
join(e) {
|
|
824
824
|
return et(this).join(e);
|
|
825
825
|
},
|
|
826
826
|
lastIndexOf(...e) {
|
|
827
|
-
return
|
|
827
|
+
return st(this, "lastIndexOf", e);
|
|
828
828
|
},
|
|
829
829
|
map(e, t) {
|
|
830
|
-
return
|
|
830
|
+
return at(this, "map", e, t, void 0, arguments);
|
|
831
831
|
},
|
|
832
832
|
pop() {
|
|
833
|
-
return
|
|
833
|
+
return ct(this, "pop");
|
|
834
834
|
},
|
|
835
835
|
push(...e) {
|
|
836
|
-
return
|
|
836
|
+
return ct(this, "push", e);
|
|
837
837
|
},
|
|
838
838
|
reduce(e, ...t) {
|
|
839
|
-
return
|
|
839
|
+
return ot(this, "reduce", e, t);
|
|
840
840
|
},
|
|
841
841
|
reduceRight(e, ...t) {
|
|
842
|
-
return
|
|
842
|
+
return ot(this, "reduceRight", e, t);
|
|
843
843
|
},
|
|
844
844
|
shift() {
|
|
845
|
-
return
|
|
845
|
+
return ct(this, "shift");
|
|
846
846
|
},
|
|
847
847
|
some(e, t) {
|
|
848
|
-
return
|
|
848
|
+
return at(this, "some", e, t, void 0, arguments);
|
|
849
849
|
},
|
|
850
850
|
splice(...e) {
|
|
851
|
-
return
|
|
851
|
+
return ct(this, "splice", e);
|
|
852
852
|
},
|
|
853
853
|
toReversed() {
|
|
854
854
|
return et(this).toReversed();
|
|
@@ -860,63 +860,63 @@ var rt = {
|
|
|
860
860
|
return et(this).toSpliced(...e);
|
|
861
861
|
},
|
|
862
862
|
unshift(...e) {
|
|
863
|
-
return
|
|
863
|
+
return ct(this, "unshift", e);
|
|
864
864
|
},
|
|
865
865
|
values() {
|
|
866
|
-
return
|
|
866
|
+
return rt(this, "values", (e) => q(this, e));
|
|
867
867
|
}
|
|
868
868
|
};
|
|
869
|
-
function
|
|
869
|
+
function rt(e, t, n) {
|
|
870
870
|
let r = tt(e), i = r[t]();
|
|
871
|
-
return r !== e && !/* @__PURE__ */
|
|
871
|
+
return r !== e && !/* @__PURE__ */ Rt(e) && (i._next = i.next, i.next = () => {
|
|
872
872
|
let e = i._next();
|
|
873
873
|
return e.done || (e.value = n(e.value)), e;
|
|
874
874
|
}), i;
|
|
875
875
|
}
|
|
876
|
-
var
|
|
877
|
-
function
|
|
878
|
-
let o = tt(e), s = o !== e && !/* @__PURE__ */
|
|
879
|
-
if (c !==
|
|
876
|
+
var it = Array.prototype;
|
|
877
|
+
function at(e, t, n, r, i, a) {
|
|
878
|
+
let o = tt(e), s = o !== e && !/* @__PURE__ */ Rt(e), c = o[t];
|
|
879
|
+
if (c !== it[t]) {
|
|
880
880
|
let t = c.apply(e, a);
|
|
881
881
|
return s ? Vt(t) : t;
|
|
882
882
|
}
|
|
883
883
|
let l = n;
|
|
884
884
|
o !== e && (s ? l = function(t, r) {
|
|
885
|
-
return n.call(this,
|
|
885
|
+
return n.call(this, q(e, t), r, e);
|
|
886
886
|
} : n.length > 2 && (l = function(t, r) {
|
|
887
887
|
return n.call(this, t, r, e);
|
|
888
888
|
}));
|
|
889
889
|
let u = c.call(o, l, r);
|
|
890
890
|
return s && i ? i(u) : u;
|
|
891
891
|
}
|
|
892
|
-
function
|
|
893
|
-
let i = tt(e), a = i !== e && !/* @__PURE__ */
|
|
892
|
+
function ot(e, t, n, r) {
|
|
893
|
+
let i = tt(e), a = i !== e && !/* @__PURE__ */ Rt(e), o = n, s = !1;
|
|
894
894
|
i !== e && (a ? (s = r.length === 0, o = function(t, r, i) {
|
|
895
|
-
return s && (s = !1, t =
|
|
895
|
+
return s && (s = !1, t = q(e, t)), n.call(this, t, q(e, r), i, e);
|
|
896
896
|
}) : n.length > 3 && (o = function(t, r, i) {
|
|
897
897
|
return n.call(this, t, r, i, e);
|
|
898
898
|
}));
|
|
899
899
|
let c = i[t](o, ...r);
|
|
900
|
-
return s ?
|
|
900
|
+
return s ? q(e, c) : c;
|
|
901
901
|
}
|
|
902
|
-
function
|
|
902
|
+
function st(e, t, n) {
|
|
903
903
|
let r = /* @__PURE__ */ Y(e);
|
|
904
904
|
Qe(r, "iterate", Ze);
|
|
905
905
|
let i = r[t](...n);
|
|
906
|
-
return (i === -1 || i === !1) && /* @__PURE__ */
|
|
906
|
+
return (i === -1 || i === !1) && /* @__PURE__ */ zt(n[0]) ? (n[0] = /* @__PURE__ */ Y(n[0]), r[t](...n)) : i;
|
|
907
907
|
}
|
|
908
|
-
function
|
|
908
|
+
function ct(e, t, n = []) {
|
|
909
909
|
Ve(), Me();
|
|
910
910
|
let r = (/* @__PURE__ */ Y(e))[t].apply(e, n);
|
|
911
911
|
return Ne(), He(), r;
|
|
912
912
|
}
|
|
913
|
-
var
|
|
914
|
-
function
|
|
913
|
+
var lt = /* @__PURE__ */ k("__proto__,__v_isRef,__isVue"), ut = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(L));
|
|
914
|
+
function dt(e) {
|
|
915
915
|
L(e) || (e = String(e));
|
|
916
916
|
let t = /* @__PURE__ */ Y(this);
|
|
917
917
|
return Qe(t, "has", e), t.hasOwnProperty(e);
|
|
918
918
|
}
|
|
919
|
-
var
|
|
919
|
+
var ft = class {
|
|
920
920
|
constructor(e = !1, t = !1) {
|
|
921
921
|
this._isReadonly = e, this._isShallow = t;
|
|
922
922
|
}
|
|
@@ -926,30 +926,30 @@ var pt = class {
|
|
|
926
926
|
if (t === "__v_isReactive") return !r;
|
|
927
927
|
if (t === "__v_isReadonly") return r;
|
|
928
928
|
if (t === "__v_isShallow") return i;
|
|
929
|
-
if (t === "__v_raw") return n === (r ? i ?
|
|
929
|
+
if (t === "__v_raw") return n === (r ? i ? At : kt : i ? Ot : Dt).get(e) || Object.getPrototypeOf(e) === Object.getPrototypeOf(n) ? e : void 0;
|
|
930
930
|
let a = F(e);
|
|
931
931
|
if (!r) {
|
|
932
932
|
let e;
|
|
933
|
-
if (a && (e =
|
|
934
|
-
if (t === "hasOwnProperty") return
|
|
933
|
+
if (a && (e = nt[t])) return e;
|
|
934
|
+
if (t === "hasOwnProperty") return dt;
|
|
935
935
|
}
|
|
936
936
|
let o = Reflect.get(e, t, /* @__PURE__ */ Ut(e) ? e : n);
|
|
937
|
-
if ((L(t) ?
|
|
937
|
+
if ((L(t) ? ut.has(t) : lt(t)) || (r || Qe(e, "get", t), i)) return o;
|
|
938
938
|
if (/* @__PURE__ */ Ut(o)) {
|
|
939
939
|
let e = a && V(t) ? o : o.value;
|
|
940
|
-
return r && R(e) ? /* @__PURE__ */
|
|
940
|
+
return r && R(e) ? /* @__PURE__ */ Nt(e) : e;
|
|
941
941
|
}
|
|
942
|
-
return R(o) ? r ? /* @__PURE__ */
|
|
942
|
+
return R(o) ? r ? /* @__PURE__ */ Nt(o) : /* @__PURE__ */ Mt(o) : o;
|
|
943
943
|
}
|
|
944
|
-
},
|
|
944
|
+
}, pt = class extends ft {
|
|
945
945
|
constructor(e = !1) {
|
|
946
946
|
super(!1, e);
|
|
947
947
|
}
|
|
948
948
|
set(e, t, n, r) {
|
|
949
949
|
let i = e[t], a = F(e) && V(t);
|
|
950
950
|
if (!this._isShallow) {
|
|
951
|
-
let r = /* @__PURE__ */
|
|
952
|
-
if (!/* @__PURE__ */
|
|
951
|
+
let r = /* @__PURE__ */ Lt(i);
|
|
952
|
+
if (!/* @__PURE__ */ Rt(n) && !/* @__PURE__ */ Lt(n) && (i = /* @__PURE__ */ Y(i), n = /* @__PURE__ */ Y(n)), !a && /* @__PURE__ */ Ut(i) && !/* @__PURE__ */ Ut(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);
|
|
953
953
|
}
|
|
954
954
|
let o = a ? Number(t) < e.length : P(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ Ut(e) ? e : r);
|
|
955
955
|
return e === /* @__PURE__ */ Y(r) && s && (o ? ge(n, i) && $e(e, "set", t, n, i) : $e(e, "add", t, n)), s;
|
|
@@ -960,25 +960,25 @@ var pt = class {
|
|
|
960
960
|
}
|
|
961
961
|
has(e, t) {
|
|
962
962
|
let n = Reflect.has(e, t);
|
|
963
|
-
return (!L(t) || !
|
|
963
|
+
return (!L(t) || !ut.has(t)) && Qe(e, "has", t), n;
|
|
964
964
|
}
|
|
965
965
|
ownKeys(e) {
|
|
966
966
|
return Qe(e, "iterate", F(e) ? "length" : Ye), Reflect.ownKeys(e);
|
|
967
967
|
}
|
|
968
|
-
},
|
|
968
|
+
}, mt = class extends ft {
|
|
969
969
|
constructor(e = !1) {
|
|
970
970
|
super(!0, e);
|
|
971
971
|
}
|
|
972
972
|
set(e, t) {
|
|
973
|
-
return process.env.NODE_ENV !== "production" &&
|
|
973
|
+
return process.env.NODE_ENV !== "production" && we(`Set operation on key "${String(t)}" failed: target is readonly.`, e), !0;
|
|
974
974
|
}
|
|
975
975
|
deleteProperty(e, t) {
|
|
976
|
-
return process.env.NODE_ENV !== "production" &&
|
|
976
|
+
return process.env.NODE_ENV !== "production" && we(`Delete operation on key "${String(t)}" failed: target is readonly.`, e), !0;
|
|
977
977
|
}
|
|
978
|
-
},
|
|
979
|
-
function
|
|
978
|
+
}, ht = /* @__PURE__ */ new pt(), gt = /* @__PURE__ */ new mt(), _t = /* @__PURE__ */ new mt(!0), vt = (e) => e, yt = (e) => Reflect.getPrototypeOf(e);
|
|
979
|
+
function bt(e, t, n) {
|
|
980
980
|
return function(...r) {
|
|
981
|
-
let i = this.__v_raw, a = /* @__PURE__ */ Y(i), o = le(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ?
|
|
981
|
+
let i = this.__v_raw, a = /* @__PURE__ */ Y(i), o = le(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? vt : t ? Ht : Vt;
|
|
982
982
|
return !t && Qe(a, "iterate", c ? Xe : Ye), M(Object.create(l), { next() {
|
|
983
983
|
let { value: e, done: t } = l.next();
|
|
984
984
|
return t ? {
|
|
@@ -991,21 +991,21 @@ function xt(e, t, n) {
|
|
|
991
991
|
} });
|
|
992
992
|
};
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function xt(e) {
|
|
995
995
|
return function(...t) {
|
|
996
996
|
if (process.env.NODE_ENV !== "production") {
|
|
997
997
|
let n = t[0] ? `on key "${t[0]}" ` : "";
|
|
998
|
-
|
|
998
|
+
we(`${he(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ Y(this));
|
|
999
999
|
}
|
|
1000
1000
|
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
|
|
1001
1001
|
};
|
|
1002
1002
|
}
|
|
1003
|
-
function
|
|
1003
|
+
function J(e, t) {
|
|
1004
1004
|
let n = {
|
|
1005
1005
|
get(n) {
|
|
1006
1006
|
let r = this.__v_raw, i = /* @__PURE__ */ Y(r), a = /* @__PURE__ */ Y(n);
|
|
1007
1007
|
e || (ge(n, a) && Qe(i, "get", n), Qe(i, "get", a));
|
|
1008
|
-
let { has: o } =
|
|
1008
|
+
let { has: o } = yt(i), s = t ? vt : e ? Ht : Vt;
|
|
1009
1009
|
if (o.call(i, n)) return s(r.get(n));
|
|
1010
1010
|
if (o.call(i, a)) return s(r.get(a));
|
|
1011
1011
|
r !== i && r.get(n);
|
|
@@ -1019,30 +1019,30 @@ function St(e, t) {
|
|
|
1019
1019
|
return e || (ge(t, i) && Qe(r, "has", t), Qe(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
|
|
1020
1020
|
},
|
|
1021
1021
|
forEach(n, r) {
|
|
1022
|
-
let i = this, a = i.__v_raw, o = /* @__PURE__ */ Y(a), s = t ?
|
|
1022
|
+
let i = this, a = i.__v_raw, o = /* @__PURE__ */ Y(a), s = t ? vt : e ? Ht : Vt;
|
|
1023
1023
|
return !e && Qe(o, "iterate", Ye), a.forEach((e, t) => n.call(r, s(e), s(t), i));
|
|
1024
1024
|
}
|
|
1025
1025
|
};
|
|
1026
1026
|
return M(n, e ? {
|
|
1027
|
-
add:
|
|
1028
|
-
set:
|
|
1029
|
-
delete:
|
|
1030
|
-
clear:
|
|
1027
|
+
add: xt("add"),
|
|
1028
|
+
set: xt("set"),
|
|
1029
|
+
delete: xt("delete"),
|
|
1030
|
+
clear: xt("clear")
|
|
1031
1031
|
} : {
|
|
1032
1032
|
add(e) {
|
|
1033
|
-
let n = /* @__PURE__ */ Y(this), r =
|
|
1033
|
+
let n = /* @__PURE__ */ Y(this), r = yt(n), i = /* @__PURE__ */ Y(e), a = !t && !/* @__PURE__ */ Rt(e) && !/* @__PURE__ */ Lt(e) ? i : e;
|
|
1034
1034
|
return r.has.call(n, a) || ge(e, a) && r.has.call(n, e) || ge(i, a) && r.has.call(n, i) || (n.add(a), $e(n, "add", a, a)), this;
|
|
1035
1035
|
},
|
|
1036
1036
|
set(e, n) {
|
|
1037
|
-
!t && !/* @__PURE__ */
|
|
1038
|
-
let r = /* @__PURE__ */ Y(this), { has: i, get: a } =
|
|
1039
|
-
o ? process.env.NODE_ENV !== "production" &&
|
|
1037
|
+
!t && !/* @__PURE__ */ Rt(n) && !/* @__PURE__ */ Lt(n) && (n = /* @__PURE__ */ Y(n));
|
|
1038
|
+
let r = /* @__PURE__ */ Y(this), { has: i, get: a } = yt(r), o = i.call(r, e);
|
|
1039
|
+
o ? process.env.NODE_ENV !== "production" && Et(r, i, e) : (e = /* @__PURE__ */ Y(e), o = i.call(r, e));
|
|
1040
1040
|
let s = a.call(r, e);
|
|
1041
1041
|
return r.set(e, n), o ? ge(n, s) && $e(r, "set", e, n, s) : $e(r, "add", e, n), this;
|
|
1042
1042
|
},
|
|
1043
1043
|
delete(e) {
|
|
1044
|
-
let t = /* @__PURE__ */ Y(this), { has: n, get: r } =
|
|
1045
|
-
i ? process.env.NODE_ENV !== "production" &&
|
|
1044
|
+
let t = /* @__PURE__ */ Y(this), { has: n, get: r } = yt(t), i = n.call(t, e);
|
|
1045
|
+
i ? process.env.NODE_ENV !== "production" && Et(t, n, e) : (e = /* @__PURE__ */ Y(e), i = n.call(t, e));
|
|
1046
1046
|
let a = r ? r.call(t, e) : void 0, o = t.delete(e);
|
|
1047
1047
|
return i && $e(t, "delete", e, void 0, a), o;
|
|
1048
1048
|
},
|
|
@@ -1056,23 +1056,23 @@ function St(e, t) {
|
|
|
1056
1056
|
"entries",
|
|
1057
1057
|
Symbol.iterator
|
|
1058
1058
|
].forEach((r) => {
|
|
1059
|
-
n[r] =
|
|
1059
|
+
n[r] = bt(r, e, t);
|
|
1060
1060
|
}), n;
|
|
1061
1061
|
}
|
|
1062
|
-
function
|
|
1063
|
-
let n =
|
|
1062
|
+
function St(e, t) {
|
|
1063
|
+
let n = J(e, t);
|
|
1064
1064
|
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);
|
|
1065
1065
|
}
|
|
1066
|
-
var
|
|
1067
|
-
function
|
|
1066
|
+
var Ct = { get: /* @__PURE__ */ St(!1, !1) }, wt = { get: /* @__PURE__ */ St(!0, !1) }, Tt = { get: /* @__PURE__ */ St(!0, !0) };
|
|
1067
|
+
function Et(e, t, n) {
|
|
1068
1068
|
let r = /* @__PURE__ */ Y(n);
|
|
1069
1069
|
if (r !== n && t.call(e, r)) {
|
|
1070
1070
|
let t = B(e);
|
|
1071
|
-
|
|
1071
|
+
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.`);
|
|
1072
1072
|
}
|
|
1073
1073
|
}
|
|
1074
|
-
var
|
|
1075
|
-
function
|
|
1074
|
+
var Dt = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap();
|
|
1075
|
+
function jt(e) {
|
|
1076
1076
|
switch (e) {
|
|
1077
1077
|
case "Object":
|
|
1078
1078
|
case "Array": return 1;
|
|
@@ -1084,41 +1084,41 @@ function Mt(e) {
|
|
|
1084
1084
|
}
|
|
1085
1085
|
}
|
|
1086
1086
|
// @__NO_SIDE_EFFECTS__
|
|
1087
|
-
function
|
|
1088
|
-
return /* @__PURE__ */
|
|
1087
|
+
function Mt(e) {
|
|
1088
|
+
return /* @__PURE__ */ Lt(e) ? e : Ft(e, !1, ht, Ct, Dt);
|
|
1089
1089
|
}
|
|
1090
1090
|
// @__NO_SIDE_EFFECTS__
|
|
1091
|
-
function
|
|
1092
|
-
return
|
|
1091
|
+
function Nt(e) {
|
|
1092
|
+
return Ft(e, !0, gt, wt, kt);
|
|
1093
1093
|
}
|
|
1094
1094
|
// @__NO_SIDE_EFFECTS__
|
|
1095
|
-
function
|
|
1096
|
-
return
|
|
1095
|
+
function Pt(e) {
|
|
1096
|
+
return Ft(e, !0, _t, Tt, At);
|
|
1097
1097
|
}
|
|
1098
|
-
function
|
|
1099
|
-
if (!R(e)) return process.env.NODE_ENV !== "production" &&
|
|
1098
|
+
function Ft(e, t, n, r, i) {
|
|
1099
|
+
if (!R(e)) return process.env.NODE_ENV !== "production" && we(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
|
|
1100
1100
|
if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
|
|
1101
1101
|
let a = i.get(e);
|
|
1102
1102
|
if (a) return a;
|
|
1103
|
-
let o =
|
|
1103
|
+
let o = jt(B(e));
|
|
1104
1104
|
if (o === 0) return e;
|
|
1105
1105
|
let s = new Proxy(e, o === 2 ? r : n);
|
|
1106
1106
|
return i.set(e, s), s;
|
|
1107
1107
|
}
|
|
1108
1108
|
// @__NO_SIDE_EFFECTS__
|
|
1109
|
-
function
|
|
1110
|
-
return /* @__PURE__ */
|
|
1109
|
+
function It(e) {
|
|
1110
|
+
return /* @__PURE__ */ Lt(e) ? /* @__PURE__ */ It(e.__v_raw) : !!(e && e.__v_isReactive);
|
|
1111
1111
|
}
|
|
1112
1112
|
// @__NO_SIDE_EFFECTS__
|
|
1113
|
-
function
|
|
1113
|
+
function Lt(e) {
|
|
1114
1114
|
return !!(e && e.__v_isReadonly);
|
|
1115
1115
|
}
|
|
1116
1116
|
// @__NO_SIDE_EFFECTS__
|
|
1117
|
-
function
|
|
1117
|
+
function Rt(e) {
|
|
1118
1118
|
return !!(e && e.__v_isShallow);
|
|
1119
1119
|
}
|
|
1120
1120
|
// @__NO_SIDE_EFFECTS__
|
|
1121
|
-
function
|
|
1121
|
+
function zt(e) {
|
|
1122
1122
|
return e ? !!e.__v_raw : !1;
|
|
1123
1123
|
}
|
|
1124
1124
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1129,7 +1129,7 @@ function Y(e) {
|
|
|
1129
1129
|
function Bt(e) {
|
|
1130
1130
|
return !P(e, "__v_skip") && Object.isExtensible(e) && _e(e, "__v_skip", !0), e;
|
|
1131
1131
|
}
|
|
1132
|
-
var Vt = (e) => R(e) ? /* @__PURE__ */
|
|
1132
|
+
var Vt = (e) => R(e) ? /* @__PURE__ */ Mt(e) : e, Ht = (e) => R(e) ? /* @__PURE__ */ Nt(e) : e;
|
|
1133
1133
|
// @__NO_SIDE_EFFECTS__
|
|
1134
1134
|
function Ut(e) {
|
|
1135
1135
|
return e ? e.__v_isRef === !0 : !1;
|
|
@@ -1157,7 +1157,7 @@ var qt = class {
|
|
|
1157
1157
|
}), this._value;
|
|
1158
1158
|
}
|
|
1159
1159
|
set value(e) {
|
|
1160
|
-
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */
|
|
1160
|
+
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ Rt(e) || /* @__PURE__ */ Lt(e);
|
|
1161
1161
|
e = n ? e : /* @__PURE__ */ Y(e), ge(e, t) && (this._rawValue = e, this._value = n ? e : Vt(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
|
|
1162
1162
|
target: this,
|
|
1163
1163
|
type: "set",
|
|
@@ -1186,7 +1186,7 @@ var Xt = {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
};
|
|
1188
1188
|
function Zt(e) {
|
|
1189
|
-
return /* @__PURE__ */
|
|
1189
|
+
return /* @__PURE__ */ It(e) ? e : new Proxy(e, Xt);
|
|
1190
1190
|
}
|
|
1191
1191
|
var Qt = class {
|
|
1192
1192
|
constructor(e, t, n) {
|
|
@@ -1205,7 +1205,7 @@ var Qt = class {
|
|
|
1205
1205
|
return Le(this), e && (e.version = this.dep.version), this._value;
|
|
1206
1206
|
}
|
|
1207
1207
|
set value(e) {
|
|
1208
|
-
this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" &&
|
|
1208
|
+
this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" && we("Write operation failed: computed value is readonly");
|
|
1209
1209
|
}
|
|
1210
1210
|
};
|
|
1211
1211
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1220,15 +1220,15 @@ function rn(e, t = !1, n = nn) {
|
|
|
1220
1220
|
if (n) {
|
|
1221
1221
|
let t = tn.get(n);
|
|
1222
1222
|
t || tn.set(n, t = []), t.push(e);
|
|
1223
|
-
} else process.env.NODE_ENV !== "production" && !t &&
|
|
1223
|
+
} else process.env.NODE_ENV !== "production" && !t && we("onWatcherCleanup() was called when there was no active watcher to associate with.");
|
|
1224
1224
|
}
|
|
1225
1225
|
function an(e, t, n = A) {
|
|
1226
1226
|
let { immediate: r, deep: i, once: a, scheduler: o, augmentJob: s, call: c } = n, l = (e) => {
|
|
1227
|
-
(n.onWarn ||
|
|
1228
|
-
}, u = (e) => i ? e : /* @__PURE__ */
|
|
1229
|
-
if (/* @__PURE__ */ Ut(e) ? (f = () => e.value, h = /* @__PURE__ */
|
|
1227
|
+
(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.");
|
|
1228
|
+
}, u = (e) => i ? e : /* @__PURE__ */ Rt(e) || i === !1 || i === 0 ? on(e, 1) : on(e), d, f, p, m, h = !1, g = !1;
|
|
1229
|
+
if (/* @__PURE__ */ Ut(e) ? (f = () => e.value, h = /* @__PURE__ */ Rt(e)) : /* @__PURE__ */ It(e) ? (f = () => u(e), h = !0) : F(e) ? (g = !0, h = e.some((e) => /* @__PURE__ */ It(e) || /* @__PURE__ */ Rt(e)), f = () => e.map((e) => {
|
|
1230
1230
|
if (/* @__PURE__ */ Ut(e)) return e.value;
|
|
1231
|
-
if (/* @__PURE__ */
|
|
1231
|
+
if (/* @__PURE__ */ It(e)) return u(e);
|
|
1232
1232
|
if (I(e)) return c ? c(e, 2) : e();
|
|
1233
1233
|
process.env.NODE_ENV !== "production" && l(e);
|
|
1234
1234
|
})) : I(e) ? f = t ? c ? () => c(e, 2) : e : () => {
|
|
@@ -1646,10 +1646,10 @@ var or = /* @__PURE__ */ Symbol.for("v-ndc"), sr = (e) => e ? Xr(e) ? Qr(e) : sr
|
|
|
1646
1646
|
$: (e) => e,
|
|
1647
1647
|
$el: (e) => e.vnode.el,
|
|
1648
1648
|
$data: (e) => e.data,
|
|
1649
|
-
$props: (e) => process.env.NODE_ENV === "production" ? e.props : /* @__PURE__ */
|
|
1650
|
-
$attrs: (e) => process.env.NODE_ENV === "production" ? e.attrs : /* @__PURE__ */
|
|
1651
|
-
$slots: (e) => process.env.NODE_ENV === "production" ? e.slots : /* @__PURE__ */
|
|
1652
|
-
$refs: (e) => process.env.NODE_ENV === "production" ? e.refs : /* @__PURE__ */
|
|
1649
|
+
$props: (e) => process.env.NODE_ENV === "production" ? e.props : /* @__PURE__ */ Pt(e.props),
|
|
1650
|
+
$attrs: (e) => process.env.NODE_ENV === "production" ? e.attrs : /* @__PURE__ */ Pt(e.attrs),
|
|
1651
|
+
$slots: (e) => process.env.NODE_ENV === "production" ? e.slots : /* @__PURE__ */ Pt(e.slots),
|
|
1652
|
+
$refs: (e) => process.env.NODE_ENV === "production" ? e.refs : /* @__PURE__ */ Pt(e.refs),
|
|
1653
1653
|
$parent: (e) => sr(e.parent),
|
|
1654
1654
|
$root: (e) => sr(e.root),
|
|
1655
1655
|
$host: (e) => e.ce,
|
|
@@ -1834,13 +1834,13 @@ function zr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
1834
1834
|
if (ri(e) && (e = e.__vccOpts), t) {
|
|
1835
1835
|
t = Br(t);
|
|
1836
1836
|
let { class: e, style: n } = t;
|
|
1837
|
-
e && !de(e) && (t.class = Ce(e)), R(n) && (/* @__PURE__ */
|
|
1837
|
+
e && !de(e) && (t.class = Ce(e)), R(n) && (/* @__PURE__ */ zt(n) && !F(n) && (n = M({}, n)), t.style = ye(n));
|
|
1838
1838
|
}
|
|
1839
1839
|
let o = de(e) ? 1 : Dr(e) ? 128 : ir(e) ? 64 : R(e) ? 4 : I(e) ? 2 : 0;
|
|
1840
|
-
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */
|
|
1840
|
+
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ zt(e) && (e = /* @__PURE__ */ Y(e), dn("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)), Lr(e, t, n, r, i, o, a, !0);
|
|
1841
1841
|
}
|
|
1842
1842
|
function Br(e) {
|
|
1843
|
-
return e ? /* @__PURE__ */
|
|
1843
|
+
return e ? /* @__PURE__ */ zt(e) || Tr(e) ? M({}, e) : e : null;
|
|
1844
1844
|
}
|
|
1845
1845
|
function Vr(e, t, n = !1, r = !1) {
|
|
1846
1846
|
let { props: i, ref: a, patchFlag: o, children: s, transition: c } = e, l = t ? Gr(i || {}, t) : i, u = {
|
|
@@ -2004,25 +2004,25 @@ function ai() {
|
|
|
2004
2004
|
s(n),
|
|
2005
2005
|
">"
|
|
2006
2006
|
];
|
|
2007
|
-
} else if (/* @__PURE__ */
|
|
2007
|
+
} else if (/* @__PURE__ */ It(t)) return [
|
|
2008
2008
|
"div",
|
|
2009
2009
|
{},
|
|
2010
2010
|
[
|
|
2011
2011
|
"span",
|
|
2012
2012
|
e,
|
|
2013
|
-
/* @__PURE__ */
|
|
2013
|
+
/* @__PURE__ */ Rt(t) ? "ShallowReactive" : "Reactive"
|
|
2014
2014
|
],
|
|
2015
2015
|
"<",
|
|
2016
2016
|
s(t),
|
|
2017
|
-
`>${/* @__PURE__ */
|
|
2017
|
+
`>${/* @__PURE__ */ Lt(t) ? " (readonly)" : ""}`
|
|
2018
2018
|
];
|
|
2019
|
-
else if (/* @__PURE__ */
|
|
2019
|
+
else if (/* @__PURE__ */ Lt(t)) return [
|
|
2020
2020
|
"div",
|
|
2021
2021
|
{},
|
|
2022
2022
|
[
|
|
2023
2023
|
"span",
|
|
2024
2024
|
e,
|
|
2025
|
-
/* @__PURE__ */
|
|
2025
|
+
/* @__PURE__ */ Rt(t) ? "ShallowReadonly" : "Readonly"
|
|
2026
2026
|
],
|
|
2027
2027
|
"<",
|
|
2028
2028
|
s(t),
|
|
@@ -2114,7 +2114,7 @@ function ai() {
|
|
|
2114
2114
|
if (F(r) && r.includes(t) || R(r) && t in r || e.extends && l(e.extends, t, n) || e.mixins && e.mixins.some((e) => l(e, t, n))) return !0;
|
|
2115
2115
|
}
|
|
2116
2116
|
function u(e) {
|
|
2117
|
-
return /* @__PURE__ */
|
|
2117
|
+
return /* @__PURE__ */ Rt(e) ? "ShallowRef" : e.effect ? "ComputedRef" : "Ref";
|
|
2118
2118
|
}
|
|
2119
2119
|
window.devtoolsFormatters ? window.devtoolsFormatters.push(i) : window.devtoolsFormatters = [i];
|
|
2120
2120
|
}
|
|
@@ -3723,7 +3723,7 @@ function Jo(e) {
|
|
|
3723
3723
|
return t;
|
|
3724
3724
|
}
|
|
3725
3725
|
function H(e, t) {
|
|
3726
|
-
let n = e[0] &&
|
|
3726
|
+
let n = e[0] && U(e[0]) === "system" ? e.slice(1) : e.slice(), r = _e();
|
|
3727
3727
|
return [new a(t ? `${r}\n\n${t}` : r), ...n];
|
|
3728
3728
|
}
|
|
3729
3729
|
async function ye(e, t, n, i) {
|
|
@@ -3854,7 +3854,7 @@ function Jo(e) {
|
|
|
3854
3854
|
content: u
|
|
3855
3855
|
};
|
|
3856
3856
|
}
|
|
3857
|
-
async function
|
|
3857
|
+
async function be(e) {
|
|
3858
3858
|
let t = fe.find((t) => t.name === e.name);
|
|
3859
3859
|
if (!t) {
|
|
3860
3860
|
let t = fe.map((e) => e.name).filter((e) => !e.startsWith("__"));
|
|
@@ -3901,7 +3901,7 @@ function Jo(e) {
|
|
|
3901
3901
|
};
|
|
3902
3902
|
}
|
|
3903
3903
|
}
|
|
3904
|
-
function
|
|
3904
|
+
function U(e) {
|
|
3905
3905
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
3906
3906
|
}
|
|
3907
3907
|
function xe(e, t) {
|
|
@@ -3909,7 +3909,7 @@ function Jo(e) {
|
|
|
3909
3909
|
}
|
|
3910
3910
|
function Se(e) {
|
|
3911
3911
|
return !se && !k ? [] : e.map((e) => {
|
|
3912
|
-
let t =
|
|
3912
|
+
let t = U(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
3913
3913
|
r && (n.content = r.length > Ho ? r.slice(0, Ho) + `…(截断 ${r.length - Ho} 字符)` : r);
|
|
3914
3914
|
let i = e.tool_calls;
|
|
3915
3915
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
@@ -3955,7 +3955,7 @@ function Jo(e) {
|
|
|
3955
3955
|
tools: fe.map((e) => e.name),
|
|
3956
3956
|
middleware: h.map((e) => e.name)
|
|
3957
3957
|
});
|
|
3958
|
-
let l = Mo(h, (e) => ye(e, n, r)), u = No(h,
|
|
3958
|
+
let l = Mo(h, (e) => ye(e, n, r)), u = No(h, be), d = {
|
|
3959
3959
|
rounds: 0,
|
|
3960
3960
|
maxToolRounds: M,
|
|
3961
3961
|
invokeUsage: {
|
|
@@ -4303,8 +4303,8 @@ function Jo(e) {
|
|
|
4303
4303
|
}), e;
|
|
4304
4304
|
}
|
|
4305
4305
|
let p = c[c.length - 1];
|
|
4306
|
-
if (p &&
|
|
4307
|
-
let e = c[0] &&
|
|
4306
|
+
if (p && U(p) === "tool") {
|
|
4307
|
+
let e = c[0] && U(c[0]) === "system" ? c.slice(1) : c.slice(), i = [new a(_e() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
4308
4308
|
L("llm_request", {
|
|
4309
4309
|
round: "wrap_up",
|
|
4310
4310
|
model: B(),
|
|
@@ -4357,20 +4357,20 @@ function Jo(e) {
|
|
|
4357
4357
|
}
|
|
4358
4358
|
}
|
|
4359
4359
|
}
|
|
4360
|
-
async function
|
|
4360
|
+
async function we(e, t, n) {
|
|
4361
4361
|
let r = "";
|
|
4362
4362
|
return await Ce(e, (e) => {
|
|
4363
4363
|
e.type === "done" && (r = e.content), n?.(e);
|
|
4364
4364
|
}, t), r;
|
|
4365
4365
|
}
|
|
4366
|
-
function
|
|
4366
|
+
function W(e) {
|
|
4367
4367
|
fe = [...h.flatMap((e) => e.tools || []), ...e], me();
|
|
4368
4368
|
}
|
|
4369
4369
|
function Te(e) {
|
|
4370
4370
|
z = e, me(), A?.(e);
|
|
4371
4371
|
}
|
|
4372
4372
|
return {
|
|
4373
|
-
invoke:
|
|
4373
|
+
invoke: we,
|
|
4374
4374
|
stream: Ce,
|
|
4375
4375
|
getState: () => V,
|
|
4376
4376
|
get allTools() {
|
|
@@ -4380,7 +4380,7 @@ function Jo(e) {
|
|
|
4380
4380
|
resetStaleReadsInvalidated: () => {
|
|
4381
4381
|
I = 0;
|
|
4382
4382
|
},
|
|
4383
|
-
setTools:
|
|
4383
|
+
setTools: W,
|
|
4384
4384
|
setLlm: Te,
|
|
4385
4385
|
setModelCaps: le,
|
|
4386
4386
|
debugLogs: ue,
|
|
@@ -6648,12 +6648,19 @@ function Fl(e = {}) {
|
|
|
6648
6648
|
r = !0, clearTimeout(c);
|
|
6649
6649
|
};
|
|
6650
6650
|
}
|
|
6651
|
+
let c;
|
|
6652
|
+
if (e.previewWrite) try {
|
|
6653
|
+
c = e.previewWrite(n.name, n.args) ?? void 0;
|
|
6654
|
+
} catch {
|
|
6655
|
+
c = void 0;
|
|
6656
|
+
}
|
|
6651
6657
|
n.emit?.({
|
|
6652
6658
|
type: "approval_request",
|
|
6653
6659
|
toolName: n.name,
|
|
6654
6660
|
args: n.args,
|
|
6655
6661
|
resolve: o,
|
|
6656
|
-
hold: s
|
|
6662
|
+
hold: s,
|
|
6663
|
+
...c ? { preview: c } : {}
|
|
6657
6664
|
}), n.logSink?.({
|
|
6658
6665
|
type: "middleware",
|
|
6659
6666
|
data: {
|
|
@@ -9774,11 +9781,110 @@ function Sd(e, n = {}) {
|
|
|
9774
9781
|
...z,
|
|
9775
9782
|
...pe
|
|
9776
9783
|
];
|
|
9784
|
+
function me(e) {
|
|
9785
|
+
let t = e, n = (e) => {
|
|
9786
|
+
if (e === void 0) return "undefined";
|
|
9787
|
+
let t = $(e, 200);
|
|
9788
|
+
return t === void 0 ? String(e) : t;
|
|
9789
|
+
}, r = (e) => typeof e == "string" ? e : String(e?.content ?? "校验失败");
|
|
9790
|
+
if (t.del) {
|
|
9791
|
+
let e = String(t.patch?.jsonPath ?? "");
|
|
9792
|
+
return {
|
|
9793
|
+
ok: !0,
|
|
9794
|
+
intent: "delete",
|
|
9795
|
+
items: [{
|
|
9796
|
+
op: "delete",
|
|
9797
|
+
jsonPath: e,
|
|
9798
|
+
oldSummary: n(Z(c, e)),
|
|
9799
|
+
newSummary: "(删除)"
|
|
9800
|
+
}]
|
|
9801
|
+
};
|
|
9802
|
+
}
|
|
9803
|
+
if (t.patches?.length || t.patch) {
|
|
9804
|
+
let e = t.patches?.length ? t.patches : [{
|
|
9805
|
+
op: t.patch?.op ?? "set",
|
|
9806
|
+
jsonPath: t.patch?.jsonPath ?? "",
|
|
9807
|
+
value: t.patch?.value
|
|
9808
|
+
}], i = dd({
|
|
9809
|
+
bindRef: c,
|
|
9810
|
+
patches: e,
|
|
9811
|
+
schema: o,
|
|
9812
|
+
allowKeys: u,
|
|
9813
|
+
snapshots: h,
|
|
9814
|
+
maxSnapshots: g,
|
|
9815
|
+
markDataDirty: () => {},
|
|
9816
|
+
schemaErrorMode: "zod",
|
|
9817
|
+
dryRun: !0,
|
|
9818
|
+
protectedCtx: m
|
|
9819
|
+
});
|
|
9820
|
+
return i.ok ? {
|
|
9821
|
+
ok: !0,
|
|
9822
|
+
intent: "edit",
|
|
9823
|
+
items: e.map((e) => ({
|
|
9824
|
+
op: String(e.op ?? "set"),
|
|
9825
|
+
jsonPath: String(e.jsonPath ?? ""),
|
|
9826
|
+
oldSummary: n(Z(c, String(e.jsonPath ?? ""))),
|
|
9827
|
+
newSummary: n(e.value)
|
|
9828
|
+
}))
|
|
9829
|
+
} : {
|
|
9830
|
+
ok: !1,
|
|
9831
|
+
intent: "edit",
|
|
9832
|
+
items: [],
|
|
9833
|
+
error: r(i.error)
|
|
9834
|
+
};
|
|
9835
|
+
}
|
|
9836
|
+
let i = Gs(t.value);
|
|
9837
|
+
if (i.parseError) return {
|
|
9838
|
+
ok: !1,
|
|
9839
|
+
intent: "set",
|
|
9840
|
+
items: [],
|
|
9841
|
+
error: `JSON 解析失败:${i.parseError}`
|
|
9842
|
+
};
|
|
9843
|
+
let a = ud({
|
|
9844
|
+
bindRef: c,
|
|
9845
|
+
value: i.parsed,
|
|
9846
|
+
schema: o,
|
|
9847
|
+
allowKeys: u,
|
|
9848
|
+
snapshots: h,
|
|
9849
|
+
maxSnapshots: g,
|
|
9850
|
+
audit: () => {},
|
|
9851
|
+
dryRun: !0,
|
|
9852
|
+
protectedCtx: m,
|
|
9853
|
+
hashFn: O
|
|
9854
|
+
});
|
|
9855
|
+
if (!a.ok) return {
|
|
9856
|
+
ok: !1,
|
|
9857
|
+
intent: "set",
|
|
9858
|
+
items: [],
|
|
9859
|
+
error: r(a.error)
|
|
9860
|
+
};
|
|
9861
|
+
let s = c ?? {}, l = a.data ?? {}, d = (u ?? []).filter((e) => JSON.stringify(s[e]) !== JSON.stringify(l[e]));
|
|
9862
|
+
return {
|
|
9863
|
+
ok: !0,
|
|
9864
|
+
intent: "set",
|
|
9865
|
+
items: d.length ? d.map((e) => ({
|
|
9866
|
+
op: "set",
|
|
9867
|
+
jsonPath: e,
|
|
9868
|
+
oldSummary: n(s[e]),
|
|
9869
|
+
newSummary: n(l[e])
|
|
9870
|
+
})) : [{
|
|
9871
|
+
op: "set",
|
|
9872
|
+
jsonPath: "",
|
|
9873
|
+
oldSummary: n(c),
|
|
9874
|
+
newSummary: n(a.data)
|
|
9875
|
+
}]
|
|
9876
|
+
};
|
|
9877
|
+
}
|
|
9777
9878
|
Object.defineProperty(B, "controller", {
|
|
9778
9879
|
value: oe,
|
|
9779
9880
|
enumerable: !1,
|
|
9780
9881
|
configurable: !1,
|
|
9781
9882
|
writable: !1
|
|
9883
|
+
}), Object.defineProperty(B, "previewWrite", {
|
|
9884
|
+
value: me,
|
|
9885
|
+
enumerable: !1,
|
|
9886
|
+
configurable: !1,
|
|
9887
|
+
writable: !1
|
|
9782
9888
|
});
|
|
9783
9889
|
for (let e of B) Object.defineProperty(e, "__dataOpsScoped", {
|
|
9784
9890
|
value: !0,
|
|
@@ -12661,24 +12767,24 @@ function Tm() {
|
|
|
12661
12767
|
}
|
|
12662
12768
|
//#endregion
|
|
12663
12769
|
//#region src/core/sdk/createChatSdk.ts
|
|
12664
|
-
var Em = 30, Dm = /* @__PURE__ */ new Map();
|
|
12665
|
-
function
|
|
12770
|
+
var Em = 30, Dm = 1, Om = 6 * 1024 * 1024, km = /* @__PURE__ */ new Map();
|
|
12771
|
+
function Am(e, t) {
|
|
12666
12772
|
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;
|
|
12667
12773
|
}
|
|
12668
|
-
function
|
|
12774
|
+
function jm(e) {
|
|
12669
12775
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
12670
12776
|
}
|
|
12671
|
-
function
|
|
12777
|
+
function Mm(e, t, n, r) {
|
|
12672
12778
|
let i = 0;
|
|
12673
12779
|
return {
|
|
12674
12780
|
name: "sdk-events",
|
|
12675
12781
|
wrapToolCall: async (t, r) => {
|
|
12676
|
-
let i = await r(t), a =
|
|
12782
|
+
let i = await r(t), a = Am(t.name, t.args), o = typeof i.content == "string" && i.content.startsWith("ERROR:");
|
|
12677
12783
|
return a && !o ? e({
|
|
12678
12784
|
type: "data_change",
|
|
12679
12785
|
operation: a,
|
|
12680
12786
|
value: n()?.bind
|
|
12681
|
-
}) : i.status === "done" && !o &&
|
|
12787
|
+
}) : i.status === "done" && !o && jm(t.name) && e({
|
|
12682
12788
|
type: "data_change",
|
|
12683
12789
|
operation: "edit",
|
|
12684
12790
|
value: n()?.bind
|
|
@@ -12706,7 +12812,7 @@ function Am(e, t, n, r) {
|
|
|
12706
12812
|
}
|
|
12707
12813
|
};
|
|
12708
12814
|
}
|
|
12709
|
-
function
|
|
12815
|
+
function Nm(e, t, n, r, i) {
|
|
12710
12816
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
12711
12817
|
ok: !1,
|
|
12712
12818
|
error: "capabilities.focus 关闭"
|
|
@@ -12724,14 +12830,14 @@ function jm(e, t, n, r, i) {
|
|
|
12724
12830
|
error: "当前无主数据 schema,无法聚焦"
|
|
12725
12831
|
});
|
|
12726
12832
|
}
|
|
12727
|
-
function
|
|
12833
|
+
function Pm(e, n) {
|
|
12728
12834
|
let r = {
|
|
12729
12835
|
prompt_tokens: 0,
|
|
12730
12836
|
completion_tokens: 0,
|
|
12731
12837
|
total_tokens: 0
|
|
12732
|
-
}, i = qf(() =>
|
|
12838
|
+
}, i = qf(() => J, () => e.conflictPolicy ?? "ask"), a = /* @__PURE__ */ Wt(0), o = Sp(e.storage);
|
|
12733
12839
|
o && (e.debug && o.onEvent((e) => console.log("[page-agent-sdk][storage]", e)), o.onEvent((e) => {
|
|
12734
|
-
e.type === "quota" &&
|
|
12840
|
+
e.type === "quota" && Y.agent?.debugLogs?.value?.push({
|
|
12735
12841
|
timestamp: Date.now(),
|
|
12736
12842
|
type: "middleware",
|
|
12737
12843
|
data: {
|
|
@@ -12749,14 +12855,14 @@ function Mm(e, n) {
|
|
|
12749
12855
|
}
|
|
12750
12856
|
let m = kp(e, f.contextWindow), g = m.enableLLMSummary !== !1, y = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? Op[e.contextPreset ?? "auto"], b = new Set(y), x = e.llm;
|
|
12751
12857
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
12752
|
-
let S = /* @__PURE__ */
|
|
12858
|
+
let S = /* @__PURE__ */ Mt([]), C = Ou(e.vfs?.initialFiles, {
|
|
12753
12859
|
persist: o ? { save: (e) => {
|
|
12754
|
-
|
|
12860
|
+
Xt({ vfs: e });
|
|
12755
12861
|
} } : void 0,
|
|
12756
12862
|
maxBytes: e.vfs?.maxBytes,
|
|
12757
12863
|
poolBytes: e.vfs?.poolBytes
|
|
12758
12864
|
}), w = uo([], { maxPlanRevisions: e.maxPlanRevisions }), T = Is(), D = _o((e) => {
|
|
12759
|
-
|
|
12865
|
+
Y.agent?.debugLogs?.value?.push({
|
|
12760
12866
|
timestamp: Date.now(),
|
|
12761
12867
|
type: "middleware",
|
|
12762
12868
|
data: {
|
|
@@ -12765,13 +12871,13 @@ function Mm(e, n) {
|
|
|
12765
12871
|
}
|
|
12766
12872
|
});
|
|
12767
12873
|
}), O = Rs(() => {
|
|
12768
|
-
|
|
12874
|
+
Y.agent?.debugLogs?.value?.push({
|
|
12769
12875
|
timestamp: Date.now(),
|
|
12770
12876
|
type: "middleware",
|
|
12771
12877
|
data: { stage: "resume_notice" }
|
|
12772
12878
|
});
|
|
12773
12879
|
}), te, ne = e.approval?.timeoutMs, re = ne !== void 0 && Number.isFinite(ne) && ne > 0 ? ne : ne !== void 0 && (!Number.isFinite(ne) || ne < 0) ? 0 : 3e4, ie = (e) => {
|
|
12774
|
-
|
|
12880
|
+
J({
|
|
12775
12881
|
type: "error",
|
|
12776
12882
|
message: `确认请求(${e.toolName})${Math.round(e.waitedMs / 1e3)}s 无响应已自动拒绝 —— 当前路径无 UI 响应方;可传 approval.timeoutMs 调整(Infinity = 无限等)`,
|
|
12777
12883
|
severity: "observable",
|
|
@@ -12779,7 +12885,7 @@ function Mm(e, n) {
|
|
|
12779
12885
|
context: e
|
|
12780
12886
|
});
|
|
12781
12887
|
}, ae = zl((e) => {
|
|
12782
|
-
te = e,
|
|
12888
|
+
te = e, Xt({ planConfirmation: e }), Y.agent?.debugLogs?.value?.push({
|
|
12783
12889
|
timestamp: Date.now(),
|
|
12784
12890
|
type: "middleware",
|
|
12785
12891
|
data: {
|
|
@@ -12794,7 +12900,7 @@ function Mm(e, n) {
|
|
|
12794
12900
|
}), k = fc({
|
|
12795
12901
|
getSchema: () => U()?.schema,
|
|
12796
12902
|
getBind: () => U()?.bind,
|
|
12797
|
-
onChange: (e) =>
|
|
12903
|
+
onChange: (e) => J({
|
|
12798
12904
|
type: "focus_change",
|
|
12799
12905
|
focuses: e
|
|
12800
12906
|
})
|
|
@@ -12843,14 +12949,14 @@ function Mm(e, n) {
|
|
|
12843
12949
|
vfsStore: V || M?.resources?.length ? C : void 0,
|
|
12844
12950
|
...de.length ? { pgIdPaths: de } : {},
|
|
12845
12951
|
...L.length ? { largeTextPaths: L } : {}
|
|
12846
|
-
}) : [], ve = me ? _e : [], H = me && M ? _e.controller ?? null : null, ye = me && M?.resources?.length && H?.getResourcesSnapshot ? gm({ getResourcesSnapshot: () => H?.getResourcesSnapshot?.() ?? [] }) : void 0, U = () => H?.get() ?? M,
|
|
12952
|
+
}) : [], ve = me ? _e : [], H = me && M ? _e.controller ?? null : null, ye = me && M ? _e.previewWrite : void 0, be = me && M?.resources?.length && H?.getResourcesSnapshot ? gm({ getResourcesSnapshot: () => H?.getResourcesSnapshot?.() ?? [] }) : void 0, U = () => H?.get() ?? M, xe = new Set(_e.map((e) => e.name)), Se = e.conflictWatchFields ?? [], Ce = !Se.includes("*") && Se.length ? new Set(Se) : void 0, we = H ? tf({
|
|
12847
12953
|
getBind: () => U()?.bind,
|
|
12848
12954
|
recomputeAll: () => H.recomputeAllBaselines?.(),
|
|
12849
12955
|
hasBaselines: () => H.hasBaselines?.() ?? !1,
|
|
12850
|
-
isManaged: (e) =>
|
|
12851
|
-
hash: (e) =>
|
|
12956
|
+
isManaged: (e) => xe.has(e),
|
|
12957
|
+
hash: (e) => Ce ? Xs(e, Ce) : Ys(e),
|
|
12852
12958
|
log: (e, t) => {
|
|
12853
|
-
let n =
|
|
12959
|
+
let n = Y.agent?.debugLogs;
|
|
12854
12960
|
n && (n.value.push({
|
|
12855
12961
|
timestamp: Date.now(),
|
|
12856
12962
|
type: "middleware",
|
|
@@ -12860,19 +12966,19 @@ function Mm(e, n) {
|
|
|
12860
12966
|
}
|
|
12861
12967
|
}), Jt(n));
|
|
12862
12968
|
}
|
|
12863
|
-
}) : void 0, W = /* @__PURE__ */ new Map(),
|
|
12969
|
+
}) : void 0, W = /* @__PURE__ */ new Map(), Te = fm(B, ve, Np, B.domInspect && !B.skills ? [
|
|
12864
12970
|
...zp,
|
|
12865
12971
|
Yp,
|
|
12866
12972
|
Xp
|
|
12867
12973
|
] : zp, im);
|
|
12868
|
-
|
|
12869
|
-
let
|
|
12870
|
-
|
|
12871
|
-
let
|
|
12872
|
-
|
|
12873
|
-
let
|
|
12874
|
-
|
|
12875
|
-
let
|
|
12974
|
+
Te.forEach((e) => W.set(e.name, "builtin"));
|
|
12975
|
+
let G = [...e.tools || []];
|
|
12976
|
+
G.forEach((e) => W.set(e.name, "user"));
|
|
12977
|
+
let Ee = sm(e.actions ?? {});
|
|
12978
|
+
Ee.forEach((e) => W.set(e.name, "action"));
|
|
12979
|
+
let De = [], Oe = !1, ke = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), Ae = ke ? Rl() : null;
|
|
12980
|
+
Ae && W.set(Il, "builtin");
|
|
12981
|
+
let je = fe && z ? [s(async () => {
|
|
12876
12982
|
let e = z.list();
|
|
12877
12983
|
return e.length ? z.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
12878
12984
|
}, {
|
|
@@ -12887,8 +12993,8 @@ function Mm(e, n) {
|
|
|
12887
12993
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
12888
12994
|
schema: t.object({}).optional()
|
|
12889
12995
|
})] : [];
|
|
12890
|
-
|
|
12891
|
-
let
|
|
12996
|
+
je.forEach((e) => W.set(e.name, "builtin"));
|
|
12997
|
+
let Me = B.focus, Ne = s(async ({ path: e, label: t }) => {
|
|
12892
12998
|
let n = U()?.schema;
|
|
12893
12999
|
return n ? Qo(n, e) ? (k.setFocus(A({
|
|
12894
13000
|
path: e,
|
|
@@ -12901,11 +13007,11 @@ function Mm(e, n) {
|
|
|
12901
13007
|
path: t.string().describe("要聚焦的组件 jsonPath,如 components.3"),
|
|
12902
13008
|
label: t.string().optional().describe("人类可读标签,如「导航栏」")
|
|
12903
13009
|
})
|
|
12904
|
-
}),
|
|
13010
|
+
}), Pe = s(async () => (k.clearFocus("agent"), "已清除聚焦,恢复全量可操作范围(可读写所有组件)。"), {
|
|
12905
13011
|
name: "clear_focus",
|
|
12906
13012
|
description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
|
|
12907
13013
|
schema: t.object({}).optional()
|
|
12908
|
-
}),
|
|
13014
|
+
}), Fe = s(async ({ path: e, label: t }) => {
|
|
12909
13015
|
let n = U()?.schema;
|
|
12910
13016
|
if (!n) return "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
12911
13017
|
if (!Qo(n, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
|
|
@@ -12922,7 +13028,7 @@ function Mm(e, n) {
|
|
|
12922
13028
|
path: t.string().describe("要追加聚焦的组件 jsonPath,如 components.3"),
|
|
12923
13029
|
label: t.string().optional().describe("人类可读标签")
|
|
12924
13030
|
})
|
|
12925
|
-
}),
|
|
13031
|
+
}), Ie = s(async ({ path: e }) => {
|
|
12926
13032
|
let t = k.getFocuses().length;
|
|
12927
13033
|
k.removeFocus(e, "agent");
|
|
12928
13034
|
let n = k.getFocuses();
|
|
@@ -12931,91 +13037,92 @@ function Mm(e, n) {
|
|
|
12931
13037
|
name: "remove_focus",
|
|
12932
13038
|
description: "移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。",
|
|
12933
13039
|
schema: t.object({ path: t.string().describe("要移除的焦点 jsonPath") })
|
|
12934
|
-
}),
|
|
12935
|
-
Me,
|
|
13040
|
+
}), Le = Me ? [
|
|
12936
13041
|
Ne,
|
|
12937
13042
|
Pe,
|
|
12938
|
-
Fe
|
|
13043
|
+
Fe,
|
|
13044
|
+
Ie
|
|
12939
13045
|
] : [];
|
|
12940
|
-
|
|
12941
|
-
let
|
|
12942
|
-
function
|
|
12943
|
-
Ii(
|
|
13046
|
+
Le.forEach((e) => W.set(e.name, "builtin"));
|
|
13047
|
+
let Re = [], ze = /* @__PURE__ */ new Map(), K = Be();
|
|
13048
|
+
function Be() {
|
|
13049
|
+
Ii(G), Ii(Ee), Ii(Re);
|
|
12944
13050
|
let { tools: e, collisions: t } = pm([
|
|
12945
13051
|
{
|
|
12946
13052
|
label: "builtin",
|
|
12947
|
-
tools:
|
|
13053
|
+
tools: Te
|
|
12948
13054
|
},
|
|
12949
13055
|
{
|
|
12950
13056
|
label: "user",
|
|
12951
|
-
tools:
|
|
13057
|
+
tools: G
|
|
12952
13058
|
},
|
|
12953
13059
|
{
|
|
12954
13060
|
label: "action",
|
|
12955
|
-
tools:
|
|
13061
|
+
tools: Ee
|
|
12956
13062
|
},
|
|
12957
13063
|
{
|
|
12958
13064
|
label: "humanConfirm",
|
|
12959
|
-
tools:
|
|
13065
|
+
tools: Ae ? [Ae] : []
|
|
12960
13066
|
},
|
|
12961
13067
|
{
|
|
12962
13068
|
label: "checkpoint",
|
|
12963
|
-
tools:
|
|
13069
|
+
tools: je
|
|
12964
13070
|
},
|
|
12965
13071
|
{
|
|
12966
13072
|
label: "focus",
|
|
12967
|
-
tools:
|
|
13073
|
+
tools: Le
|
|
12968
13074
|
},
|
|
12969
13075
|
{
|
|
12970
13076
|
label: "mcp",
|
|
12971
|
-
tools:
|
|
13077
|
+
tools: De
|
|
12972
13078
|
},
|
|
12973
13079
|
{
|
|
12974
13080
|
label: "skill",
|
|
12975
|
-
tools:
|
|
13081
|
+
tools: Re
|
|
12976
13082
|
}
|
|
12977
13083
|
]);
|
|
12978
13084
|
return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
|
|
12979
13085
|
}
|
|
12980
|
-
let
|
|
12981
|
-
if (
|
|
12982
|
-
if (
|
|
12983
|
-
let
|
|
13086
|
+
let Ve = B.planning, He = B.missionAnchor, Ue = B.workingMemory, We = B.skills, Ge = B.vfs || I;
|
|
13087
|
+
if (Ge) for (let e of Fu) W.set(e, "builtin");
|
|
13088
|
+
if (Ve) for (let e of w.tools ?? []) W.set(e.name, "builtin");
|
|
13089
|
+
let Ke = B.summarization, qe = B.agentCompression && !!d;
|
|
12984
13090
|
e.debug && B.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
12985
|
-
let
|
|
12986
|
-
|
|
12987
|
-
let
|
|
13091
|
+
let Je = B.memory, Ye = B.subagent, Xe = Ye ? $c() : void 0, Ze = e.verify?.maxAttempts ?? 2, Qe = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), $e = e.capabilities?.verify === !1, et = (B.verify || Qe && !$e) && e.verify?.enabled !== !1 && Ze > 0, tt = B.contextInspector;
|
|
13092
|
+
Qe && !et && e.verify?.enabled !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
|
|
13093
|
+
let q = e.subagent, nt = q?.allowedTools ?? [], rt = e.permissions?.length ? Pl(e.permissions) : void 0, it = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? Fl({
|
|
12988
13094
|
...e.approval,
|
|
12989
13095
|
timeoutMs: e.approval.timeoutMs ?? re,
|
|
12990
|
-
onAutoReject: ie
|
|
13096
|
+
onAutoReject: ie,
|
|
13097
|
+
previewWrite: e.approval.preview === !0 && ye ? (e, t) => e === "write" ? ye(t) : null : void 0
|
|
12991
13098
|
}) : void 0, at = [
|
|
12992
13099
|
...rt ? [rt] : [],
|
|
12993
13100
|
...it ? [it] : [],
|
|
12994
|
-
...
|
|
12995
|
-
], ot = !
|
|
12996
|
-
llm:
|
|
12997
|
-
allTools: () =>
|
|
13101
|
+
...we ? [we] : []
|
|
13102
|
+
], ot = !Ye || q?.enabled === !1 ? void 0 : yl({
|
|
13103
|
+
llm: q?.llm ?? e.llm,
|
|
13104
|
+
allTools: () => Y.agent?.allTools ?? K,
|
|
12998
13105
|
allowedTools: nt.length ? nt : void 0,
|
|
12999
13106
|
...e.staleReadInvalidation === void 0 ? {} : { staleReadInvalidation: e.staleReadInvalidation },
|
|
13000
|
-
systemPrompt:
|
|
13001
|
-
temperature:
|
|
13002
|
-
maxTokens:
|
|
13003
|
-
skills:
|
|
13004
|
-
maxDepth:
|
|
13005
|
-
maxParallel:
|
|
13006
|
-
thinkingMode:
|
|
13107
|
+
systemPrompt: q?.systemPrompt,
|
|
13108
|
+
temperature: q?.temperature,
|
|
13109
|
+
maxTokens: q?.maxTokens,
|
|
13110
|
+
skills: q?.skills,
|
|
13111
|
+
maxDepth: q?.maxDepth,
|
|
13112
|
+
maxParallel: q?.maxParallel,
|
|
13113
|
+
thinkingMode: q?.thinkingMode,
|
|
13007
13114
|
debug: e.debug,
|
|
13008
13115
|
getFocuses: () => k.getActiveFocuses(),
|
|
13009
13116
|
getSchema: () => U()?.schema ?? null,
|
|
13010
|
-
tracker:
|
|
13117
|
+
tracker: Xe,
|
|
13011
13118
|
guardMiddleware: at.length ? at : void 0,
|
|
13012
|
-
getVfsFiles:
|
|
13119
|
+
getVfsFiles: Ge ? () => C.files : void 0,
|
|
13013
13120
|
enterDataScope: H?.enterScope ? (e) => H.enterScope(e) : void 0,
|
|
13014
13121
|
exitDataScope: H?.exitScope ? (e) => H.exitScope(e) : void 0,
|
|
13015
13122
|
onUsage: (e) => {
|
|
13016
13123
|
r.prompt_tokens = (r.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), r.completion_tokens = (r.completion_tokens ?? 0) + (e.completion_tokens ?? 0), r.total_tokens = (r.total_tokens ?? 0) + (e.total_tokens ?? 0), e.reasoning_tokens && (r.reasoning_tokens = (r.reasoning_tokens ?? 0) + e.reasoning_tokens);
|
|
13017
13124
|
},
|
|
13018
|
-
timeoutMs:
|
|
13125
|
+
timeoutMs: q?.timeoutMs
|
|
13019
13126
|
}), st = ue?.map((e) => {
|
|
13020
13127
|
if (!e._codeAsset) return e;
|
|
13021
13128
|
let t = e._codeAsset, n = Bd({
|
|
@@ -13033,7 +13140,7 @@ function Mm(e, n) {
|
|
|
13033
13140
|
...e,
|
|
13034
13141
|
middleware: r
|
|
13035
13142
|
};
|
|
13036
|
-
}), ct = I &&
|
|
13143
|
+
}), ct = I && Ye ? Vd() : void 0, lt = ct ? Jd({
|
|
13037
13144
|
getBind: () => U()?.bind,
|
|
13038
13145
|
writablePaths: de,
|
|
13039
13146
|
getLocked: () => ct.locked(),
|
|
@@ -13045,18 +13152,18 @@ function Mm(e, n) {
|
|
|
13045
13152
|
}) : void 0, ut = H?.getSummarizedPaths && H.clearSummarizedPaths ? Zd({
|
|
13046
13153
|
getSummarizedPaths: () => H.getSummarizedPaths(),
|
|
13047
13154
|
clearSummarizedPaths: () => H.clearSummarizedPaths()
|
|
13048
|
-
}) : void 0, dt =
|
|
13155
|
+
}) : void 0, dt = Ye && st !== void 0 ? Sl(st, {
|
|
13049
13156
|
llm: e.llm,
|
|
13050
13157
|
thinkingModeDefault: e.subagent?.thinkingMode,
|
|
13051
13158
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
13052
|
-
allTools: () =>
|
|
13159
|
+
allTools: () => Y.agent?.allTools ?? K,
|
|
13053
13160
|
debug: e.debug,
|
|
13054
13161
|
getFocuses: () => k.getActiveFocuses(),
|
|
13055
13162
|
getSchema: () => U()?.schema ?? null,
|
|
13056
13163
|
getBind: () => U()?.bind,
|
|
13057
|
-
tracker:
|
|
13164
|
+
tracker: Xe,
|
|
13058
13165
|
guardMiddleware: at.length ? at : void 0,
|
|
13059
|
-
getVfsFiles:
|
|
13166
|
+
getVfsFiles: Ge ? () => C.files : void 0,
|
|
13060
13167
|
enterDataScope: H?.enterScope ? (e) => H.enterScope(e) : void 0,
|
|
13061
13168
|
exitDataScope: H?.exitScope ? (e) => H.exitScope(e) : void 0,
|
|
13062
13169
|
onUsage: (e) => {
|
|
@@ -13074,7 +13181,7 @@ function Mm(e, n) {
|
|
|
13074
13181
|
...n ? { thinkingMode: n } : {},
|
|
13075
13182
|
thinkingApplied: r
|
|
13076
13183
|
};
|
|
13077
|
-
}, mt = ["read", "fetch_document"], ht = K.filter((e) => mt.includes(e.name)), gt =
|
|
13184
|
+
}, mt = ["read", "fetch_document"], ht = K.filter((e) => mt.includes(e.name)), gt = et ? Yl({
|
|
13078
13185
|
check: e.verify.check ?? tu({
|
|
13079
13186
|
schemas: () => U() ? { "": U().schema } : {},
|
|
13080
13187
|
root: () => U()?.bind
|
|
@@ -13083,12 +13190,12 @@ function Mm(e, n) {
|
|
|
13083
13190
|
llm: e.llm,
|
|
13084
13191
|
tools: ht
|
|
13085
13192
|
} : void 0
|
|
13086
|
-
}) : void 0, _t =
|
|
13193
|
+
}) : void 0, _t = tt ? hu({
|
|
13087
13194
|
contextWindow: f.contextWindow,
|
|
13088
13195
|
thresholdRatio: kp(e, f.contextWindow).summaryThresholdRatio
|
|
13089
13196
|
}) : void 0, vt = hm({
|
|
13090
13197
|
...B,
|
|
13091
|
-
humanConfirm:
|
|
13198
|
+
humanConfirm: ke,
|
|
13092
13199
|
subagents: ue?.map(pt)
|
|
13093
13200
|
}, me && !!M, { promptSoftCap: Jc(f.contextWindow, m.promptSoftCapTokens) }), yt = M ? {
|
|
13094
13201
|
name: "dataHint",
|
|
@@ -13106,7 +13213,7 @@ function Mm(e, n) {
|
|
|
13106
13213
|
return;
|
|
13107
13214
|
}
|
|
13108
13215
|
}
|
|
13109
|
-
} : null, xt = Ep(e.onEvent),
|
|
13216
|
+
} : null, xt = Ep(e.onEvent), J = xt.emit, St, Ct = [], wt = (e) => ({
|
|
13110
13217
|
name: e.name,
|
|
13111
13218
|
description: e.description,
|
|
13112
13219
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -13123,7 +13230,7 @@ function Mm(e, n) {
|
|
|
13123
13230
|
let n = (e.skills || []).filter((e) => !Ct.some((t) => t.name === e.name));
|
|
13124
13231
|
t.set([...n, ...Ct]);
|
|
13125
13232
|
}
|
|
13126
|
-
|
|
13233
|
+
Y.infoTick.value++;
|
|
13127
13234
|
}, Ot = async () => {
|
|
13128
13235
|
if (Et) try {
|
|
13129
13236
|
let t = await Et.list();
|
|
@@ -13134,54 +13241,54 @@ function Mm(e, n) {
|
|
|
13134
13241
|
let t = (e.skills || []).filter((e) => !Ct.some((t) => t.name === e.name));
|
|
13135
13242
|
n.set([...t, ...Ct]);
|
|
13136
13243
|
}
|
|
13137
|
-
|
|
13244
|
+
Y.infoTick.value++;
|
|
13138
13245
|
}
|
|
13139
13246
|
} catch {}
|
|
13140
|
-
}, kt =
|
|
13247
|
+
}, kt = Ke ? Qc({
|
|
13141
13248
|
...m,
|
|
13142
13249
|
llmInvoke: l,
|
|
13143
13250
|
getRegisteredData: () => U() ? [{ description: U().description ?? "主数据对象" }] : [],
|
|
13144
13251
|
preserveLastToolResults: y,
|
|
13145
|
-
...
|
|
13252
|
+
...qe ? {
|
|
13146
13253
|
decideInvoke: d,
|
|
13147
13254
|
getSnapshot: () => _t?.getSnapshot()
|
|
13148
13255
|
} : {}
|
|
13149
13256
|
}) : void 0, At = jp([
|
|
13150
13257
|
...yt ? [yt] : [],
|
|
13151
13258
|
vt,
|
|
13152
|
-
...
|
|
13259
|
+
...He ? [T] : [],
|
|
13153
13260
|
D,
|
|
13154
13261
|
O,
|
|
13155
|
-
...
|
|
13156
|
-
...
|
|
13157
|
-
readVfs:
|
|
13262
|
+
...Ve ? [w] : [],
|
|
13263
|
+
...We ? [St = Dc([...B.domInspect && !(e.skills || []).some((e) => e.name === Zp.name) ? [Zp] : [], ...e.skills || []], {
|
|
13264
|
+
readVfs: Ge ? (e) => C.files[e]?.content : void 0,
|
|
13158
13265
|
onToolsReady: (e, t) => {
|
|
13159
13266
|
for (let n of t) {
|
|
13160
|
-
let t =
|
|
13161
|
-
t >= 0 &&
|
|
13267
|
+
let t = Re.findIndex((e) => e.name === n.name);
|
|
13268
|
+
t >= 0 && Re.splice(t, 1), Re.push(n), ze.set(n.name, e), W.set(n.name, `skill:${e}`);
|
|
13162
13269
|
}
|
|
13163
|
-
K =
|
|
13270
|
+
K = Be(), Y.agent && Y.agent.setTools(K), Y.infoTick.value++;
|
|
13164
13271
|
}
|
|
13165
13272
|
})] : [],
|
|
13166
|
-
...
|
|
13273
|
+
...Ge ? [Lu(C)] : [],
|
|
13167
13274
|
...kt ? [kt] : [],
|
|
13168
|
-
...
|
|
13169
|
-
...
|
|
13170
|
-
...
|
|
13171
|
-
...
|
|
13275
|
+
...Ue ? [j] : [],
|
|
13276
|
+
...Me ? [k] : [],
|
|
13277
|
+
...be ? [be] : [],
|
|
13278
|
+
...Je ? [oe] : [],
|
|
13172
13279
|
...rt ? [rt] : [],
|
|
13173
13280
|
...fe && pe && z ? [ql(z)] : [],
|
|
13174
|
-
...
|
|
13281
|
+
...ke ? [ae] : [],
|
|
13175
13282
|
...it ? [it] : [],
|
|
13176
|
-
...
|
|
13283
|
+
...we ? [we] : [],
|
|
13177
13284
|
...gt ? [gt] : [],
|
|
13178
13285
|
...ot ? [ot] : [],
|
|
13179
13286
|
...dt ? [dt] : [],
|
|
13180
13287
|
...lt ? [lt] : [],
|
|
13181
13288
|
...ut ? [ut] : [],
|
|
13182
|
-
...H &&
|
|
13289
|
+
...H && Ye ? [ef({
|
|
13183
13290
|
getBind: () => U()?.bind,
|
|
13184
|
-
getTools: () =>
|
|
13291
|
+
getTools: () => Y.agent?.allTools ?? K
|
|
13185
13292
|
})] : [],
|
|
13186
13293
|
...bt ? [bt] : [],
|
|
13187
13294
|
..._t ? [_t] : [],
|
|
@@ -13189,12 +13296,12 @@ function Mm(e, n) {
|
|
|
13189
13296
|
...he ? [am(r, {
|
|
13190
13297
|
tokenBudget: e.tokenBudget,
|
|
13191
13298
|
timeBudgetMs: e.timeBudgetMs
|
|
13192
|
-
},
|
|
13193
|
-
|
|
13299
|
+
}, J)] : [],
|
|
13300
|
+
Mm(J, S, U, r)
|
|
13194
13301
|
]), jt = e.maxMemoryRounds ?? Em;
|
|
13195
|
-
function
|
|
13302
|
+
function Nt(e) {
|
|
13196
13303
|
return (e) => {
|
|
13197
|
-
e.type !== "approval_request" &&
|
|
13304
|
+
e.type !== "approval_request" && J(e);
|
|
13198
13305
|
};
|
|
13199
13306
|
}
|
|
13200
13307
|
let Pt = /* @__PURE__ */ Wt([]);
|
|
@@ -13219,7 +13326,7 @@ function Mm(e, n) {
|
|
|
13219
13326
|
for (let e of Lt) e.abort();
|
|
13220
13327
|
Lt.clear();
|
|
13221
13328
|
}
|
|
13222
|
-
let
|
|
13329
|
+
let Y = {
|
|
13223
13330
|
agentId: n,
|
|
13224
13331
|
store: o,
|
|
13225
13332
|
messages: S,
|
|
@@ -13246,23 +13353,23 @@ function Mm(e, n) {
|
|
|
13246
13353
|
refreshSessions: Ft,
|
|
13247
13354
|
liveData: U,
|
|
13248
13355
|
usage: r,
|
|
13249
|
-
emit:
|
|
13356
|
+
emit: J,
|
|
13250
13357
|
runSerial: It,
|
|
13251
13358
|
trackActive: Rt,
|
|
13252
13359
|
abortAllActive: zt,
|
|
13253
13360
|
unloadSkillTools(e) {
|
|
13254
13361
|
if (e) {
|
|
13255
|
-
let t =
|
|
13256
|
-
if (
|
|
13362
|
+
let t = Re.length;
|
|
13363
|
+
if (Re = Re.filter((t) => ze.get(t.name) === e ? (W.delete(t.name), ze.delete(t.name), !1) : !0), Re.length === t) return;
|
|
13257
13364
|
} else {
|
|
13258
|
-
if (!
|
|
13259
|
-
for (let e of
|
|
13260
|
-
|
|
13365
|
+
if (!Re.length) return;
|
|
13366
|
+
for (let e of Re) W.delete(e.name), ze.delete(e.name);
|
|
13367
|
+
Re = [];
|
|
13261
13368
|
}
|
|
13262
|
-
K =
|
|
13369
|
+
K = Be(), Y.agent && Y.agent.setTools(K);
|
|
13263
13370
|
},
|
|
13264
13371
|
applySnapshot(t) {
|
|
13265
|
-
if (t.vfs && C.hydrate && C.hydrate(t.vfs), t.messages?.length && (S.push(...wi(t.messages, (e) => (e ?
|
|
13372
|
+
if (t.vfs && C.hydrate && C.hydrate(t.vfs), t.messages?.length && (S.push(...wi(t.messages, (e) => (e ? Y.vfsStore?.files?.[e]?.content : void 0) || void 0)), O.markResumed()), t.todos?.length && w.reset(t.todos), t.memory && !e.memory && oe.reset(t.memory), t.checkpoints?.length && z && z.importStack(t.checkpoints), t.usage && Object.assign(r, t.usage), t.mission && He && T.setMission(t.mission), t.workingMemory && Ue && j.restore(t.workingMemory), t.planConfirmation && (te = t.planConfirmation), Me) {
|
|
13266
13373
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
13267
13374
|
if (r.length) {
|
|
13268
13375
|
let t = U()?.schema, n = t ? r.filter((e) => Qo(t, e.path)) : [];
|
|
@@ -13272,7 +13379,7 @@ function Mm(e, n) {
|
|
|
13272
13379
|
}
|
|
13273
13380
|
}
|
|
13274
13381
|
}
|
|
13275
|
-
|
|
13382
|
+
Ut();
|
|
13276
13383
|
},
|
|
13277
13384
|
addSkill(e) {
|
|
13278
13385
|
let t = Ct.findIndex((t) => t.name === e.name);
|
|
@@ -13294,20 +13401,20 @@ function Mm(e, n) {
|
|
|
13294
13401
|
};
|
|
13295
13402
|
},
|
|
13296
13403
|
afterRound() {
|
|
13297
|
-
|
|
13404
|
+
Gt(), en();
|
|
13298
13405
|
},
|
|
13299
13406
|
clearCodeReuse() {
|
|
13300
13407
|
let e = C;
|
|
13301
13408
|
e.__pgPendingRetry?.clear(), e.__pgLastCheckout?.clear();
|
|
13302
13409
|
},
|
|
13303
13410
|
async send(e, t) {
|
|
13304
|
-
if (await
|
|
13305
|
-
t ??= {}, t?.mission &&
|
|
13411
|
+
if (await Y.initDone, Y.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 send");
|
|
13412
|
+
t ??= {}, t?.mission && He && T.setMission(t.mission);
|
|
13306
13413
|
let n = e, r = (t.images ?? []).filter((e) => e && (e.dataUri || e.vfsRef || e.url));
|
|
13307
13414
|
if (r.length > 4) throw Error(`[page-agent-sdk] 单轮最多 4 张图片(收到 ${r.length})`);
|
|
13308
|
-
if (r.length && (await
|
|
13415
|
+
if (r.length && (await Qt(r), await $t(r, n)), r.length && !f.vision && !r.every((e) => e.description)) {
|
|
13309
13416
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述(集成方识图子 agent / 自有 vision API)";
|
|
13310
|
-
throw
|
|
13417
|
+
throw J({
|
|
13311
13418
|
type: "error",
|
|
13312
13419
|
message: e,
|
|
13313
13420
|
severity: "recoverable",
|
|
@@ -13315,12 +13422,12 @@ function Mm(e, n) {
|
|
|
13315
13422
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
13316
13423
|
}
|
|
13317
13424
|
C?.setProtectedRefs?.(Cm(S));
|
|
13318
|
-
let a = he ? t.maxAutoRetries ?? 1 : 0, s = 0, c = !1, l =
|
|
13425
|
+
let a = he ? t.maxAutoRetries ?? 1 : 0, s = 0, c = !1, l = Nt(t.signal);
|
|
13319
13426
|
if (t.signal) {
|
|
13320
13427
|
let e = () => i.resolve("keep_external");
|
|
13321
13428
|
t.signal.aborted ? e() : t.signal.addEventListener("abort", e, { once: !0 });
|
|
13322
13429
|
}
|
|
13323
|
-
let u =
|
|
13430
|
+
let u = Y.sessionId;
|
|
13324
13431
|
for (;;) {
|
|
13325
13432
|
c ||= (S.push({
|
|
13326
13433
|
role: "user",
|
|
@@ -13329,25 +13436,25 @@ function Mm(e, n) {
|
|
|
13329
13436
|
...r.length ? { images: r } : {}
|
|
13330
13437
|
}), !0);
|
|
13331
13438
|
try {
|
|
13332
|
-
let e = await
|
|
13333
|
-
if (t.signal?.aborted ||
|
|
13439
|
+
let e = await Y.agent.invoke(S, t.signal, l);
|
|
13440
|
+
if (t.signal?.aborted || Y.sessionId !== u || Y.refCount <= 0) return Y.agent?.debugLogs?.value?.push({
|
|
13334
13441
|
timestamp: Date.now(),
|
|
13335
13442
|
type: "middleware",
|
|
13336
13443
|
data: {
|
|
13337
13444
|
stage: "orphan_round_dropped",
|
|
13338
13445
|
fromSession: u,
|
|
13339
13446
|
aborted: !!t.signal?.aborted,
|
|
13340
|
-
sessionChanged:
|
|
13447
|
+
sessionChanged: Y.sessionId !== u
|
|
13341
13448
|
}
|
|
13342
13449
|
}), e;
|
|
13343
13450
|
if (S.push({
|
|
13344
13451
|
role: "assistant",
|
|
13345
13452
|
content: e,
|
|
13346
13453
|
timestamp: Date.now()
|
|
13347
|
-
}),
|
|
13454
|
+
}), Y.afterRound(), o) try {
|
|
13348
13455
|
await o.flush();
|
|
13349
13456
|
} catch (e) {
|
|
13350
|
-
|
|
13457
|
+
J({
|
|
13351
13458
|
type: "error",
|
|
13352
13459
|
message: `落盘失败(不影响本轮回复):${e instanceof Error ? e.message : String(e)}`,
|
|
13353
13460
|
severity: "observable",
|
|
@@ -13363,7 +13470,7 @@ function Mm(e, n) {
|
|
|
13363
13470
|
code: "MODEL_UNAVAILABLE",
|
|
13364
13471
|
message: e instanceof Error ? e.message : n.message
|
|
13365
13472
|
}), s < a && z?.canRestore()) {
|
|
13366
|
-
s += 1, z.restore(), c = !0,
|
|
13473
|
+
s += 1, z.restore(), c = !0, J({
|
|
13367
13474
|
type: "error",
|
|
13368
13475
|
message: `致命错误自动恢复(${s}/${a}):${n.message},已回退 checkpoint 重试`,
|
|
13369
13476
|
severity: "observable",
|
|
@@ -13375,7 +13482,7 @@ function Mm(e, n) {
|
|
|
13375
13482
|
});
|
|
13376
13483
|
continue;
|
|
13377
13484
|
}
|
|
13378
|
-
throw
|
|
13485
|
+
throw J({
|
|
13379
13486
|
type: "error",
|
|
13380
13487
|
message: n.message,
|
|
13381
13488
|
severity: n.severity,
|
|
@@ -13386,9 +13493,9 @@ function Mm(e, n) {
|
|
|
13386
13493
|
}
|
|
13387
13494
|
},
|
|
13388
13495
|
async batch(e, t, n) {
|
|
13389
|
-
if (await
|
|
13390
|
-
if (
|
|
13391
|
-
let r = [], a =
|
|
13496
|
+
if (await Y.initDone, !e.length) return [];
|
|
13497
|
+
if (Y.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
13498
|
+
let r = [], a = Nt(n);
|
|
13392
13499
|
if (C?.setProtectedRefs?.(Cm(S)), n) {
|
|
13393
13500
|
let e = () => i.resolve("keep_external");
|
|
13394
13501
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
@@ -13412,15 +13519,15 @@ function Mm(e, n) {
|
|
|
13412
13519
|
content: s,
|
|
13413
13520
|
timestamp: Date.now()
|
|
13414
13521
|
});
|
|
13415
|
-
let c = await
|
|
13522
|
+
let c = await Y.agent.invoke(S, n, a);
|
|
13416
13523
|
if (S.push({
|
|
13417
13524
|
role: "assistant",
|
|
13418
13525
|
content: c,
|
|
13419
13526
|
timestamp: Date.now()
|
|
13420
|
-
}),
|
|
13527
|
+
}), Y.afterRound(), o) try {
|
|
13421
13528
|
await o.flush();
|
|
13422
13529
|
} catch (e) {
|
|
13423
|
-
|
|
13530
|
+
J({
|
|
13424
13531
|
type: "error",
|
|
13425
13532
|
message: `落盘失败(不影响本任务结果):${e instanceof Error ? e.message : String(e)}`,
|
|
13426
13533
|
severity: "observable",
|
|
@@ -13456,7 +13563,7 @@ function Mm(e, n) {
|
|
|
13456
13563
|
}
|
|
13457
13564
|
ea(a);
|
|
13458
13565
|
let o = di(a, "fatal");
|
|
13459
|
-
|
|
13566
|
+
J({
|
|
13460
13567
|
type: "error",
|
|
13461
13568
|
message: `批量任务 ${i + 1}/${e.length} 失败:${o.message}`,
|
|
13462
13569
|
severity: "observable",
|
|
@@ -13481,27 +13588,27 @@ function Mm(e, n) {
|
|
|
13481
13588
|
return r;
|
|
13482
13589
|
},
|
|
13483
13590
|
async switchSession(t) {
|
|
13484
|
-
if (await
|
|
13485
|
-
if (i.resolve("keep_external"),
|
|
13486
|
-
if (
|
|
13591
|
+
if (await Y.initDone, !o) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
|
|
13592
|
+
if (i.resolve("keep_external"), Y.sessionId && o) {
|
|
13593
|
+
if (He) {
|
|
13487
13594
|
let e = T.getMission();
|
|
13488
|
-
e &&
|
|
13595
|
+
e && Xt({ mission: e });
|
|
13489
13596
|
}
|
|
13490
|
-
if (
|
|
13597
|
+
if (Ue) {
|
|
13491
13598
|
let e = j.getWorkingMemory();
|
|
13492
|
-
e &&
|
|
13599
|
+
e && Xt({ workingMemory: e });
|
|
13493
13600
|
}
|
|
13494
|
-
if (
|
|
13601
|
+
if (Me) {
|
|
13495
13602
|
let e = k.getFocuses();
|
|
13496
|
-
|
|
13603
|
+
Xt({ focus: e.length ? e : null });
|
|
13497
13604
|
}
|
|
13498
13605
|
}
|
|
13499
13606
|
C.flush?.(), await o.flush();
|
|
13500
13607
|
let r = t ?? "", a;
|
|
13501
|
-
if (r ? (a = await o.load(n, r), a || await o.createSession(n, e.session?.title, r)) : r = await o.createSession(n, e.session?.title),
|
|
13608
|
+
if (r ? (a = await o.load(n, r), a || await o.createSession(n, e.session?.title, r)) : r = await o.createSession(n, e.session?.title), Y.sessionId = r, S.splice(0, S.length), C.clear?.(), w.reset([]), e.memory || oe.reset(""), T.reset(), j.reset(), k.reset(), kt?.reset(), O.reset(), te = void 0, z && z.importStack([]), Y.agent.debugLogs.value = [], Y.agent.resetStaleReadsInvalidated?.(), !a) try {
|
|
13502
13609
|
a = await o.load(n, r);
|
|
13503
13610
|
} catch (e) {
|
|
13504
|
-
|
|
13611
|
+
J({
|
|
13505
13612
|
type: "error",
|
|
13506
13613
|
message: `会话快照载入失败,已降级空会话:${e instanceof Error ? e.message : String(e)}`,
|
|
13507
13614
|
severity: "observable",
|
|
@@ -13509,27 +13616,58 @@ function Mm(e, n) {
|
|
|
13509
13616
|
context: { sessionId: r }
|
|
13510
13617
|
});
|
|
13511
13618
|
}
|
|
13512
|
-
return a && (
|
|
13619
|
+
return a && (Y.applySnapshot(a), J({
|
|
13513
13620
|
type: "session_restored",
|
|
13514
13621
|
sessionId: r,
|
|
13515
13622
|
rounds: a.messages?.length ?? 0
|
|
13516
|
-
})), e.memory &&
|
|
13623
|
+
})), e.memory && Xt({ memory: oe.get() || (typeof e.memory == "string" ? e.memory : "") }), Ft(), Kt = void 0, qt = !1, Y.infoTick.value++, r;
|
|
13624
|
+
},
|
|
13625
|
+
async exportSession(e) {
|
|
13626
|
+
if (!o) throw Error("page-agent-sdk: storage 未开启,无法导出会话(请传 storage 选项)");
|
|
13627
|
+
let t = e || Y.sessionId;
|
|
13628
|
+
if (!t) throw Error("page-agent-sdk: 无可导出的会话");
|
|
13629
|
+
t === Y.sessionId && (en(), C.flush?.(), await o.flush());
|
|
13630
|
+
let r = await o.load(n, t);
|
|
13631
|
+
if (!r) throw Error(`page-agent-sdk: 会话 ${t} 不存在或无可导出内容`);
|
|
13632
|
+
return {
|
|
13633
|
+
formatVersion: Dm,
|
|
13634
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13635
|
+
sessionId: t,
|
|
13636
|
+
snapshot: r
|
|
13637
|
+
};
|
|
13638
|
+
},
|
|
13639
|
+
async importSession(t) {
|
|
13640
|
+
if (!o) throw Error("page-agent-sdk: storage 未开启,无法导入会话(请传 storage 选项)");
|
|
13641
|
+
let r = t, i = typeof t == "string" ? t.length : 0;
|
|
13642
|
+
if (typeof t == "string") try {
|
|
13643
|
+
r = JSON.parse(t);
|
|
13644
|
+
} catch {
|
|
13645
|
+
throw Error("page-agent-sdk: 导入内容不是合法 JSON");
|
|
13646
|
+
}
|
|
13647
|
+
let a = r ?? {};
|
|
13648
|
+
if (typeof r != "object" || !r || a.formatVersion !== Dm) throw Error(`page-agent-sdk: 未知会话导出格式(期望 formatVersion=${Dm};请用 sdk.exportSession 的产物)`);
|
|
13649
|
+
let s = a.snapshot;
|
|
13650
|
+
if (!s || typeof s != "object" || !Array.isArray(s.messages)) throw Error("page-agent-sdk: 导入内容缺 snapshot.messages(非会话导出文件)");
|
|
13651
|
+
let c = i || JSON.stringify(a).length;
|
|
13652
|
+
if (c > Om) throw Error(`page-agent-sdk: 导入会话超过 ${Math.floor(Om / 1024 / 1024)}MB 上限(${(c / 1024 / 1024).toFixed(1)}MB)`);
|
|
13653
|
+
let l = await o.createSession(n, e.session?.title);
|
|
13654
|
+
return await o.save(n, l, s), Ft(), { sessionId: l };
|
|
13517
13655
|
},
|
|
13518
13656
|
resetSession: () => {
|
|
13519
|
-
zt(), i.resolve("keep_external"),
|
|
13657
|
+
zt(), i.resolve("keep_external"), Y.sessionId = Jf(), S.splice(0, S.length), C.clear?.(), w.reset([]), e.memory || oe.reset(""), T.reset(), j.reset(), k.reset(), kt?.reset(), O.reset(), te = void 0, z && z.importStack([]), Y.agent && (Y.agent.debugLogs.value = [], Y.agent.resetStaleReadsInvalidated?.()), o && o.createSession(Y.agentId, e.session?.title, Y.sessionId).catch((t) => {
|
|
13520
13658
|
e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
|
|
13521
|
-
}),
|
|
13659
|
+
}), J({
|
|
13522
13660
|
type: "session_restored",
|
|
13523
|
-
sessionId:
|
|
13661
|
+
sessionId: Y.sessionId,
|
|
13524
13662
|
rounds: 0
|
|
13525
|
-
}),
|
|
13663
|
+
}), Y.infoTick.value++, Ft(), Kt = void 0, qt = !1;
|
|
13526
13664
|
},
|
|
13527
13665
|
stream: async (e, t, n) => {
|
|
13528
|
-
if (!
|
|
13666
|
+
if (!Y.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
13529
13667
|
let r = [...e].reverse().find((e) => e.role === "user" && e.images?.length);
|
|
13530
|
-
if (r?.images?.length && (await
|
|
13668
|
+
if (r?.images?.length && (await Qt(r.images), await $t(r.images, r.content), !f.vision && !r.images.every((e) => e.description))) {
|
|
13531
13669
|
let e = "当前主模型不支持图片输入(modelCaps.vision=false)。请换多模态模型(gpt-4o/claude/qwen-vl)或 LLMConfig 声明 vision:true;或配置 images.describe 绑定识图转述";
|
|
13532
|
-
throw
|
|
13670
|
+
throw J({
|
|
13533
13671
|
type: "error",
|
|
13534
13672
|
message: e,
|
|
13535
13673
|
severity: "recoverable",
|
|
@@ -13538,36 +13676,36 @@ function Mm(e, n) {
|
|
|
13538
13676
|
}
|
|
13539
13677
|
C?.setProtectedRefs?.(Cm(e));
|
|
13540
13678
|
let a = (e) => {
|
|
13541
|
-
t?.(e),
|
|
13679
|
+
t?.(e), J(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && Y.infoTick.value++;
|
|
13542
13680
|
};
|
|
13543
13681
|
if (n) {
|
|
13544
13682
|
let e = () => i.resolve("keep_external");
|
|
13545
13683
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
13546
13684
|
}
|
|
13547
13685
|
let { controller: o, untrack: s } = Rt(n);
|
|
13548
|
-
return
|
|
13686
|
+
return Y.agent.stream(e, a, o.signal).finally(s);
|
|
13549
13687
|
},
|
|
13550
13688
|
release() {
|
|
13551
|
-
if (
|
|
13552
|
-
zt(),
|
|
13553
|
-
let e =
|
|
13554
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
13689
|
+
if (Y.refCount--, Y.refCount <= 0) {
|
|
13690
|
+
zt(), Oe = !0, o && (C.flush?.(), o.flush(), o.dispose()), Et && Et.dispose();
|
|
13691
|
+
let e = Y.mcpClosers.splice(0);
|
|
13692
|
+
e.length && Promise.allSettled(e.map((e) => e())), km.delete(n);
|
|
13555
13693
|
}
|
|
13556
13694
|
},
|
|
13557
13695
|
resolveConflict: i.resolve,
|
|
13558
13696
|
setTools(e) {
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
}), K =
|
|
13697
|
+
G.length = 0, e.forEach((e) => {
|
|
13698
|
+
G.push(e), W.set(e.name, "user");
|
|
13699
|
+
}), K = Be(), Y.agent && Y.agent.setTools(K), Y.infoTick.value++;
|
|
13562
13700
|
},
|
|
13563
13701
|
addTool(e) {
|
|
13564
13702
|
K.some((t) => t.name === e.name) && console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);
|
|
13565
|
-
for (let t =
|
|
13566
|
-
|
|
13703
|
+
for (let t = G.length - 1; t >= 0; t--) G[t].name === e.name && G.splice(t, 1);
|
|
13704
|
+
G.push(e), W.set(e.name, "user"), K = Be(), Y.agent && Y.agent.setTools(K), Y.infoTick.value++;
|
|
13567
13705
|
},
|
|
13568
13706
|
removeTool(e) {
|
|
13569
|
-
let t =
|
|
13570
|
-
return t < 0 ? !1 : (
|
|
13707
|
+
let t = G.findIndex((t) => t.name === e);
|
|
13708
|
+
return t < 0 ? !1 : (G.splice(t, 1), W.delete(e), K = Be(), Y.agent && Y.agent.setTools(K), Y.infoTick.value++, !0);
|
|
13571
13709
|
},
|
|
13572
13710
|
setLlm(t) {
|
|
13573
13711
|
let n;
|
|
@@ -13585,10 +13723,10 @@ function Mm(e, n) {
|
|
|
13585
13723
|
maxOutputTokens: e.maxOutputTokens ?? r?.maxOutputTokens,
|
|
13586
13724
|
vision: r?.vision ?? t.vision
|
|
13587
13725
|
}), f.contextWindow < 2e5) throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${f.contextWindow} 小于最小支持 ${p}(需 ≥200K 窗口模型)`);
|
|
13588
|
-
|
|
13726
|
+
Y.agent && (Y.agent.setLlm(n), Y.agent.setModelCaps?.(f)), kt?.setContextWindow?.(f.contextWindow), _t?.setContextWindow?.(f.contextWindow), Y.infoTick.value++, e.debug && console.log("[page-agent-sdk][setLlm] 重解析 modelCaps + 回灌:", f);
|
|
13589
13727
|
},
|
|
13590
13728
|
setMemory(e) {
|
|
13591
|
-
oe.reset(e), typeof e == "function" && oe.refresh(),
|
|
13729
|
+
oe.reset(e), typeof e == "function" && oe.refresh(), Y.infoTick.value++;
|
|
13592
13730
|
},
|
|
13593
13731
|
refreshMemory() {
|
|
13594
13732
|
return oe.refresh();
|
|
@@ -13598,33 +13736,33 @@ function Mm(e, n) {
|
|
|
13598
13736
|
e.debug && console.warn("[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
13599
13737
|
return;
|
|
13600
13738
|
}
|
|
13601
|
-
ft.set(t),
|
|
13739
|
+
ft.set(t), Y.infoTick.value++;
|
|
13602
13740
|
},
|
|
13603
13741
|
addSubagent(t) {
|
|
13604
13742
|
if (!ft) {
|
|
13605
13743
|
e.debug && console.warn("[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
13606
13744
|
return;
|
|
13607
13745
|
}
|
|
13608
|
-
ft.add(t),
|
|
13746
|
+
ft.add(t), Y.infoTick.value++;
|
|
13609
13747
|
},
|
|
13610
13748
|
removeSubagent(t) {
|
|
13611
13749
|
if (!ft) return e.debug && console.warn("[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略"), !1;
|
|
13612
13750
|
let n = ft.remove(t);
|
|
13613
|
-
return n &&
|
|
13751
|
+
return n && Y.infoTick.value++, n;
|
|
13614
13752
|
},
|
|
13615
13753
|
getActiveSubagents() {
|
|
13616
|
-
return
|
|
13754
|
+
return Xe?.getActive() ?? [];
|
|
13617
13755
|
},
|
|
13618
13756
|
get subagentHistory() {
|
|
13619
|
-
return
|
|
13757
|
+
return Xe?.getHistory() ?? [];
|
|
13620
13758
|
},
|
|
13621
13759
|
getInfo() {
|
|
13622
13760
|
return {
|
|
13623
13761
|
id: n,
|
|
13624
|
-
sessionId:
|
|
13762
|
+
sessionId: Y.sessionId,
|
|
13625
13763
|
model: Lf(x) ? x.model ?? x.modelName : x.model,
|
|
13626
|
-
systemPrompt:
|
|
13627
|
-
tools: (
|
|
13764
|
+
systemPrompt: Y.agent?.getEffectiveSystemPrompt?.() ?? ge + Cu(U(), e.schemaHint),
|
|
13765
|
+
tools: (Y.agent?.allTools ?? K).map((e) => ({
|
|
13628
13766
|
name: e.name,
|
|
13629
13767
|
description: e.description,
|
|
13630
13768
|
schema: e.schema,
|
|
@@ -13645,9 +13783,9 @@ function Mm(e, n) {
|
|
|
13645
13783
|
promptSoftCap: Jc(f.contextWindow, m.promptSoftCapTokens)
|
|
13646
13784
|
},
|
|
13647
13785
|
memory: oe.get(),
|
|
13648
|
-
staleReadsInvalidated:
|
|
13786
|
+
staleReadsInvalidated: Y.agent?.getStaleReadsInvalidated?.() ?? 0,
|
|
13649
13787
|
middleware: At.map((e) => e.name),
|
|
13650
|
-
todos: (
|
|
13788
|
+
todos: (Y.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
13651
13789
|
id: e.id,
|
|
13652
13790
|
content: e.content,
|
|
13653
13791
|
status: e.status,
|
|
@@ -13657,11 +13795,11 @@ function Mm(e, n) {
|
|
|
13657
13795
|
...e.evidence === void 0 ? {} : { evidence: e.evidence }
|
|
13658
13796
|
})),
|
|
13659
13797
|
planPhase: w.getPlanPhase(),
|
|
13660
|
-
mission:
|
|
13798
|
+
mission: He ? T.getMission() : void 0,
|
|
13661
13799
|
planConfirmation: te,
|
|
13662
|
-
workingMemory:
|
|
13663
|
-
focus:
|
|
13664
|
-
focuses:
|
|
13800
|
+
workingMemory: Ue ? j.getWorkingMemory() : void 0,
|
|
13801
|
+
focus: Me ? k.getFocus() : void 0,
|
|
13802
|
+
focuses: Me ? k.getFocuses() : [],
|
|
13665
13803
|
actions: cm(e.actions ?? {}),
|
|
13666
13804
|
subagent: {
|
|
13667
13805
|
enabled: !!ot,
|
|
@@ -13670,28 +13808,28 @@ function Mm(e, n) {
|
|
|
13670
13808
|
timeoutMs: e.subagent?.timeoutMs === void 0 ? 18e5 : e.subagent.timeoutMs > 0 ? e.subagent.timeoutMs : 0,
|
|
13671
13809
|
allowedTools: e.subagent?.allowedTools ?? [],
|
|
13672
13810
|
subagents: (ft?.get() ?? []).map(pt),
|
|
13673
|
-
active:
|
|
13674
|
-
history:
|
|
13811
|
+
active: Xe?.getActive() ?? [],
|
|
13812
|
+
history: Xe?.getHistory() ?? [],
|
|
13675
13813
|
lockedComponents: ct?.locked() ?? {}
|
|
13676
13814
|
},
|
|
13677
13815
|
verify: {
|
|
13678
13816
|
enabled: !!gt,
|
|
13679
|
-
maxAttempts:
|
|
13680
|
-
adversarial:
|
|
13817
|
+
maxAttempts: et ? Ze : 0,
|
|
13818
|
+
adversarial: et && !!e.verify?.adversarial
|
|
13681
13819
|
},
|
|
13682
13820
|
context: (() => {
|
|
13683
13821
|
let e = _t?.getSnapshot();
|
|
13684
13822
|
if (e) {
|
|
13685
|
-
let t =
|
|
13823
|
+
let t = Y.agent?.getState?.()?.lastCompression;
|
|
13686
13824
|
t && (e.compression = t);
|
|
13687
13825
|
}
|
|
13688
13826
|
return e;
|
|
13689
13827
|
})(),
|
|
13690
13828
|
mcp: {
|
|
13691
|
-
servers:
|
|
13692
|
-
...
|
|
13829
|
+
servers: Y.mcpServers,
|
|
13830
|
+
...Y.mcpFailed.length ? { failed: Y.mcpFailed } : {}
|
|
13693
13831
|
},
|
|
13694
|
-
lastCompression:
|
|
13832
|
+
lastCompression: Y.agent?.getState?.()?.lastCompression,
|
|
13695
13833
|
checkpoints: z ? {
|
|
13696
13834
|
enabled: !0,
|
|
13697
13835
|
auto: pe,
|
|
@@ -13700,14 +13838,14 @@ function Mm(e, n) {
|
|
|
13700
13838
|
};
|
|
13701
13839
|
},
|
|
13702
13840
|
exportDiagnostics() {
|
|
13703
|
-
let e =
|
|
13841
|
+
let e = Y.getInfo(), t = {
|
|
13704
13842
|
...e,
|
|
13705
13843
|
tools: e.tools.map(({ schema: e, ...t }) => t),
|
|
13706
13844
|
data: e.data ? {
|
|
13707
13845
|
description: e.data.description,
|
|
13708
13846
|
schemaTopKeys: Yo(e.data.schema) ?? []
|
|
13709
13847
|
} : void 0
|
|
13710
|
-
}, n =
|
|
13848
|
+
}, n = Y.liveData(), r = null;
|
|
13711
13849
|
if (n) {
|
|
13712
13850
|
let e = -1, t = [];
|
|
13713
13851
|
try {
|
|
@@ -13723,56 +13861,56 @@ function Mm(e, n) {
|
|
|
13723
13861
|
};
|
|
13724
13862
|
}
|
|
13725
13863
|
return cf(sf({
|
|
13726
|
-
debugLogs:
|
|
13727
|
-
messages:
|
|
13864
|
+
debugLogs: Y.agent?.debugLogs?.value ?? [],
|
|
13865
|
+
messages: Y.messages,
|
|
13728
13866
|
info: t,
|
|
13729
|
-
usage: { ...
|
|
13730
|
-
pendingConflict:
|
|
13731
|
-
sessionId:
|
|
13867
|
+
usage: { ...Y.usage },
|
|
13868
|
+
pendingConflict: Y.pendingConflict?.value ?? null,
|
|
13869
|
+
sessionId: Y.sessionId,
|
|
13732
13870
|
dataSummary: r
|
|
13733
13871
|
}));
|
|
13734
13872
|
},
|
|
13735
13873
|
getMission() {
|
|
13736
|
-
return
|
|
13874
|
+
return He ? T.getMission() : void 0;
|
|
13737
13875
|
},
|
|
13738
13876
|
setMission(t) {
|
|
13739
|
-
if (!
|
|
13877
|
+
if (!He) {
|
|
13740
13878
|
e.debug && console.warn("[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略");
|
|
13741
13879
|
return;
|
|
13742
13880
|
}
|
|
13743
|
-
T.setMission(t),
|
|
13881
|
+
T.setMission(t), Y.infoTick.value++;
|
|
13744
13882
|
},
|
|
13745
13883
|
getFocus() {
|
|
13746
|
-
return
|
|
13884
|
+
return Me ? k.getFocus() : void 0;
|
|
13747
13885
|
},
|
|
13748
13886
|
getFocuses() {
|
|
13749
|
-
return
|
|
13887
|
+
return Me ? k.getFocuses() : [];
|
|
13750
13888
|
},
|
|
13751
13889
|
setFocus(t) {
|
|
13752
|
-
let n =
|
|
13753
|
-
return n.ok ? (k.setFocus(A(t)), e.debug && k.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"),
|
|
13890
|
+
let n = Nm(t, "setFocus", Me, () => U()?.schema, e.debug);
|
|
13891
|
+
return n.ok ? (k.setFocus(A(t)), e.debug && k.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), Y.infoTick.value++, { ok: !0 }) : n;
|
|
13754
13892
|
},
|
|
13755
13893
|
addFocus(t) {
|
|
13756
|
-
let n =
|
|
13894
|
+
let n = Nm(t, "addFocus", Me, () => U()?.schema, e.debug);
|
|
13757
13895
|
return n.ok ? k.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
13758
13896
|
ok: !1,
|
|
13759
13897
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
13760
|
-
}) : (k.addFocus(A(t)), e.debug && k.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"),
|
|
13898
|
+
}) : (k.addFocus(A(t)), e.debug && k.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), Y.infoTick.value++, { ok: !0 }) : n;
|
|
13761
13899
|
},
|
|
13762
13900
|
removeFocus(e) {
|
|
13763
|
-
|
|
13901
|
+
Me && (k.removeFocus(e), Y.infoTick.value++);
|
|
13764
13902
|
},
|
|
13765
13903
|
clearFocus() {
|
|
13766
|
-
|
|
13904
|
+
Me && (k.clearFocus(), Y.infoTick.value++);
|
|
13767
13905
|
}
|
|
13768
13906
|
};
|
|
13769
|
-
async function
|
|
13907
|
+
async function Bt() {
|
|
13770
13908
|
if (!o) return;
|
|
13771
13909
|
let t = async (e) => {
|
|
13772
13910
|
try {
|
|
13773
13911
|
return await o.load(n, e);
|
|
13774
13912
|
} catch (t) {
|
|
13775
|
-
|
|
13913
|
+
J({
|
|
13776
13914
|
type: "error",
|
|
13777
13915
|
message: `会话快照读取失败,已降级空会话:${t instanceof Error ? t.message : String(t)}`,
|
|
13778
13916
|
severity: "observable",
|
|
@@ -13785,7 +13923,7 @@ function Mm(e, n) {
|
|
|
13785
13923
|
try {
|
|
13786
13924
|
return await o.listSessions(n);
|
|
13787
13925
|
} catch (e) {
|
|
13788
|
-
return
|
|
13926
|
+
return J({
|
|
13789
13927
|
type: "error",
|
|
13790
13928
|
message: `会话列表读取失败,已降级新建会话:${e instanceof Error ? e.message : String(e)}`,
|
|
13791
13929
|
severity: "observable",
|
|
@@ -13793,7 +13931,7 @@ function Mm(e, n) {
|
|
|
13793
13931
|
}), [];
|
|
13794
13932
|
}
|
|
13795
13933
|
}, i = Symbol("storage-ready-timeout");
|
|
13796
|
-
await Promise.race([o.ready.then(() => "ready"), new Promise((e) => setTimeout(() => e(i), 5e3))]) === i && (console.warn("[page-agent-sdk][persist] 存储初始化 5s 未就绪(可能被其他标签页锁住),已放行;持久化暂降级内存,就绪后自动恢复"),
|
|
13934
|
+
await Promise.race([o.ready.then(() => "ready"), new Promise((e) => setTimeout(() => e(i), 5e3))]) === i && (console.warn("[page-agent-sdk][persist] 存储初始化 5s 未就绪(可能被其他标签页锁住),已放行;持久化暂降级内存,就绪后自动恢复"), J({
|
|
13797
13935
|
type: "error",
|
|
13798
13936
|
message: "存储初始化 5s 未就绪(IDB blocked?),已放行降级运行",
|
|
13799
13937
|
severity: "observable",
|
|
@@ -13801,31 +13939,31 @@ function Mm(e, n) {
|
|
|
13801
13939
|
}));
|
|
13802
13940
|
let a = e.session || {};
|
|
13803
13941
|
if (a.id) {
|
|
13804
|
-
|
|
13805
|
-
let e = await t(
|
|
13806
|
-
e ? (
|
|
13942
|
+
Y.sessionId = a.id;
|
|
13943
|
+
let e = await t(Y.sessionId);
|
|
13944
|
+
e ? (Y.applySnapshot(e), J({
|
|
13807
13945
|
type: "session_restored",
|
|
13808
|
-
sessionId:
|
|
13946
|
+
sessionId: Y.sessionId,
|
|
13809
13947
|
rounds: e.messages?.length ?? 0
|
|
13810
|
-
})) : await o.createSession(n, a.title,
|
|
13948
|
+
})) : await o.createSession(n, a.title, Y.sessionId);
|
|
13811
13949
|
} else if (a.autoResume !== !1) {
|
|
13812
13950
|
let i = await r();
|
|
13813
13951
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", n, i.length, i.map((e) => e.sessionId)), i.length) {
|
|
13814
|
-
|
|
13815
|
-
let n = await t(
|
|
13816
|
-
n ? (
|
|
13952
|
+
Y.sessionId = i[0].sessionId;
|
|
13953
|
+
let n = await t(Y.sessionId);
|
|
13954
|
+
n ? (Y.applySnapshot(n), J({
|
|
13817
13955
|
type: "session_restored",
|
|
13818
|
-
sessionId:
|
|
13956
|
+
sessionId: Y.sessionId,
|
|
13819
13957
|
rounds: n.messages?.length ?? 0
|
|
13820
|
-
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话",
|
|
13821
|
-
} else
|
|
13822
|
-
} else
|
|
13823
|
-
e.memory &&
|
|
13958
|
+
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", Y.sessionId, `${n.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", Y.sessionId);
|
|
13959
|
+
} else Y.sessionId = await o.createSession(n, a.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", Y.sessionId);
|
|
13960
|
+
} else Y.sessionId = await o.createSession(n, a.title);
|
|
13961
|
+
e.memory && Xt({ memory: oe.get() || (typeof e.memory == "string" ? e.memory : "") }), Ft();
|
|
13824
13962
|
}
|
|
13825
|
-
async function
|
|
13963
|
+
async function Vt() {
|
|
13826
13964
|
await Ot();
|
|
13827
13965
|
}
|
|
13828
|
-
function
|
|
13966
|
+
function Ht(e) {
|
|
13829
13967
|
let t = {};
|
|
13830
13968
|
for (let n of Cm(e)) {
|
|
13831
13969
|
let e = C.files[n];
|
|
@@ -13833,15 +13971,15 @@ function Mm(e, n) {
|
|
|
13833
13971
|
}
|
|
13834
13972
|
return t;
|
|
13835
13973
|
}
|
|
13836
|
-
function
|
|
13974
|
+
function Ut() {
|
|
13837
13975
|
let e = wm(C.files, Cm(S));
|
|
13838
13976
|
for (let t of e) delete C.files[t];
|
|
13839
13977
|
}
|
|
13840
|
-
function
|
|
13978
|
+
function Gt() {
|
|
13841
13979
|
let e = Ic(S, jt);
|
|
13842
13980
|
if (!e.trimmed) return;
|
|
13843
13981
|
let { older: t, summary: n } = e;
|
|
13844
|
-
if (
|
|
13982
|
+
if (J({
|
|
13845
13983
|
type: "context_trimmed",
|
|
13846
13984
|
dropped: t.map((e) => ({
|
|
13847
13985
|
round: e.round,
|
|
@@ -13849,24 +13987,24 @@ function Mm(e, n) {
|
|
|
13849
13987
|
assistant: e.assistantMsgs.map((e) => e.content),
|
|
13850
13988
|
steps: e.assistantMsgs.flatMap((e) => e.steps ?? [])
|
|
13851
13989
|
})),
|
|
13852
|
-
vfsResults:
|
|
13990
|
+
vfsResults: Ht(t.flatMap((e) => [e.userMsg, ...e.assistantMsgs])),
|
|
13853
13991
|
summary: n.content,
|
|
13854
13992
|
reason: "max_memory_rounds"
|
|
13855
|
-
}), S.splice(e.deleteFrom, e.deleteCount, n),
|
|
13993
|
+
}), S.splice(e.deleteFrom, e.deleteCount, n), Ut(), g && l) {
|
|
13856
13994
|
let n = e.summary, { prevSeg: r } = e;
|
|
13857
13995
|
(async () => {
|
|
13858
13996
|
try {
|
|
13859
13997
|
let e = await l(Uc(t, b)), i = S.indexOf(n);
|
|
13860
13998
|
if (i < 0) return;
|
|
13861
|
-
S[i].content = Fc(t, r, e),
|
|
13999
|
+
S[i].content = Fc(t, r, e), en();
|
|
13862
14000
|
} catch {}
|
|
13863
14001
|
})();
|
|
13864
14002
|
}
|
|
13865
14003
|
}
|
|
13866
|
-
let
|
|
13867
|
-
function
|
|
14004
|
+
let Kt, qt = !1;
|
|
14005
|
+
function Yt(t, n) {
|
|
13868
14006
|
e.debug && console.warn(`[page-agent-sdk][persist] ${t} 失败(已吞):`, n);
|
|
13869
|
-
let r =
|
|
14007
|
+
let r = Y.agent?.debugLogs;
|
|
13870
14008
|
r && r.value.push({
|
|
13871
14009
|
timestamp: Date.now(),
|
|
13872
14010
|
type: "middleware",
|
|
@@ -13877,33 +14015,33 @@ function Mm(e, n) {
|
|
|
13877
14015
|
}
|
|
13878
14016
|
});
|
|
13879
14017
|
}
|
|
13880
|
-
function
|
|
13881
|
-
!
|
|
14018
|
+
function Xt(e) {
|
|
14019
|
+
!Y.sessionId || !o || o.save(n, Y.sessionId, e).catch((e) => Yt("save", e));
|
|
13882
14020
|
}
|
|
13883
|
-
function
|
|
13884
|
-
o && o.updateTitle(n, e, t).catch((e) =>
|
|
14021
|
+
function Zt(e, t) {
|
|
14022
|
+
o && o.updateTitle(n, e, t).catch((e) => Yt("updateTitle", e));
|
|
13885
14023
|
}
|
|
13886
|
-
async function
|
|
14024
|
+
async function Qt(t) {
|
|
13887
14025
|
let n = e.images?.upload;
|
|
13888
14026
|
for (let e of t) {
|
|
13889
14027
|
try {
|
|
13890
14028
|
e.dataUri && !e.thumb && (e.thumb = await ki(e.dataUri));
|
|
13891
14029
|
} catch (e) {
|
|
13892
|
-
|
|
14030
|
+
Yt("imageThumb", e);
|
|
13893
14031
|
}
|
|
13894
14032
|
if (n && e.dataUri && !e.url) try {
|
|
13895
14033
|
let t = await n(e.dataUri, e);
|
|
13896
|
-
t && (e.url = t, e.dataUri = void 0, e.vfsRef &&
|
|
14034
|
+
t && (e.url = t, e.dataUri = void 0, e.vfsRef && Y.vfsStore && delete Y.vfsStore.files[e.vfsRef]);
|
|
13897
14035
|
} catch (e) {
|
|
13898
14036
|
console.warn("[page-agent-sdk][images] upload 失败,回退 dataURI 内联直发:", e?.message ?? e);
|
|
13899
14037
|
}
|
|
13900
|
-
e.dataUri && !e.vfsRef &&
|
|
14038
|
+
e.dataUri && !e.vfsRef && Y.vfsStore && (e.vfsRef = `userImages/${e.id}`, Y.vfsStore.files[e.vfsRef] = {
|
|
13901
14039
|
content: e.dataUri,
|
|
13902
14040
|
updatedAt: Date.now()
|
|
13903
14041
|
});
|
|
13904
14042
|
}
|
|
13905
14043
|
}
|
|
13906
|
-
async function
|
|
14044
|
+
async function $t(t, n) {
|
|
13907
14045
|
let r = e.images?.describe;
|
|
13908
14046
|
if (f.vision || !r) return;
|
|
13909
14047
|
let i = e.images?.describeTimeoutMs ?? 15e3;
|
|
@@ -13915,7 +14053,7 @@ function Mm(e, n) {
|
|
|
13915
14053
|
clearTimeout(a);
|
|
13916
14054
|
}
|
|
13917
14055
|
} catch (t) {
|
|
13918
|
-
e.description = "[图片描述不可用]",
|
|
14056
|
+
e.description = "[图片描述不可用]", J({
|
|
13919
14057
|
type: "error",
|
|
13920
14058
|
message: `识图转述失败:${t?.message ?? String(t)}`,
|
|
13921
14059
|
severity: "observable",
|
|
@@ -13923,43 +14061,43 @@ function Mm(e, n) {
|
|
|
13923
14061
|
});
|
|
13924
14062
|
}
|
|
13925
14063
|
}
|
|
13926
|
-
function
|
|
13927
|
-
if (!
|
|
13928
|
-
if (
|
|
14064
|
+
function en() {
|
|
14065
|
+
if (!Y.sessionId || !o) return;
|
|
14066
|
+
if (Xt({ messages: Ci(JSON.parse(JSON.stringify(S))) }), Xt({ todos: Y.agent?.getState?.()?.todos ?? [] }), Xt({ planConfirmation: te }), He) {
|
|
13929
14067
|
let e = T.getMission();
|
|
13930
|
-
e &&
|
|
14068
|
+
e && Xt({ mission: e });
|
|
13931
14069
|
}
|
|
13932
|
-
if (
|
|
14070
|
+
if (Ue) {
|
|
13933
14071
|
let e = j.getWorkingMemory();
|
|
13934
|
-
e &&
|
|
14072
|
+
e && Xt({ workingMemory: e });
|
|
13935
14073
|
}
|
|
13936
|
-
if (
|
|
14074
|
+
if (Me) {
|
|
13937
14075
|
let e = k.getFocuses();
|
|
13938
|
-
|
|
14076
|
+
Xt({ focus: e.length ? e : null });
|
|
13939
14077
|
}
|
|
13940
|
-
he && z && (
|
|
14078
|
+
he && z && (Xt({ checkpoints: z.exportStack() }), Xt({ usage: r }));
|
|
13941
14079
|
let t = Ff(S);
|
|
13942
|
-
if (t && t !==
|
|
13943
|
-
|
|
13944
|
-
let e =
|
|
14080
|
+
if (t && t !== Kt && (Kt = t, Zt(Y.sessionId, t)), e.autoTitle !== !1 && u && !qt && S.some((e) => e.role === "user") && S.some((e) => e.role === "assistant")) {
|
|
14081
|
+
qt = !0;
|
|
14082
|
+
let e = Y.sessionId;
|
|
13945
14083
|
(async () => {
|
|
13946
14084
|
try {
|
|
13947
14085
|
let t = await u(S);
|
|
13948
|
-
if (t &&
|
|
14086
|
+
if (t && Y.refCount > 0 && Y.sessionId === e) {
|
|
13949
14087
|
try {
|
|
13950
14088
|
await o.updateTitle(n, e, t);
|
|
13951
14089
|
} catch (e) {
|
|
13952
|
-
|
|
14090
|
+
Yt("updateTitle", e);
|
|
13953
14091
|
}
|
|
13954
14092
|
await Ft();
|
|
13955
14093
|
}
|
|
13956
14094
|
} catch {}
|
|
13957
14095
|
})();
|
|
13958
14096
|
}
|
|
13959
|
-
e.debug && console.log("[page-agent-sdk][persist] save",
|
|
14097
|
+
e.debug && console.log("[page-agent-sdk][persist] save", Y.sessionId, `${S.length} msgs`);
|
|
13960
14098
|
}
|
|
13961
|
-
return
|
|
13962
|
-
await
|
|
14099
|
+
return Y.initDone = (async () => {
|
|
14100
|
+
await Bt(), await Vt(), e.mcp?.length && (async () => {
|
|
13963
14101
|
let t = async (e) => {
|
|
13964
14102
|
let t;
|
|
13965
14103
|
for (let n = 0; n < 3; n++) try {
|
|
@@ -13978,11 +14116,11 @@ function Mm(e, n) {
|
|
|
13978
14116
|
let o = a.name ?? a.url, s = !1;
|
|
13979
14117
|
try {
|
|
13980
14118
|
let e = await t(a);
|
|
13981
|
-
if (
|
|
14119
|
+
if (Oe) {
|
|
13982
14120
|
e.close();
|
|
13983
14121
|
return;
|
|
13984
14122
|
}
|
|
13985
|
-
|
|
14123
|
+
Y.mcpClosers.push(e.close), Y.mcpServers.push({
|
|
13986
14124
|
name: o,
|
|
13987
14125
|
url: a.url,
|
|
13988
14126
|
toolCount: e.tools.length
|
|
@@ -13991,17 +14129,17 @@ function Mm(e, n) {
|
|
|
13991
14129
|
console.warn(`[page-agent-sdk][mcp] 工具 "${e.name}" 与内置工具重名,已拒绝注入(安全保留字保护)`);
|
|
13992
14130
|
return;
|
|
13993
14131
|
}
|
|
13994
|
-
W.set(e.name, `mcp:${o}`),
|
|
13995
|
-
}), s && (K =
|
|
14132
|
+
W.set(e.name, `mcp:${o}`), De.push(e), s = !0;
|
|
14133
|
+
}), s && (K = Be(), Y.agent && Y.agent.setTools(K), Y.infoTick.value++);
|
|
13996
14134
|
} catch (e) {
|
|
13997
|
-
if (
|
|
14135
|
+
if (Oe) return;
|
|
13998
14136
|
console.warn(`[page-agent-sdk][mcp] server ${o} 连接失败:`, e);
|
|
13999
14137
|
let t = String(e?.message ?? e ?? "").slice(0, 200);
|
|
14000
|
-
|
|
14138
|
+
Y.mcpFailed.push({
|
|
14001
14139
|
name: o,
|
|
14002
14140
|
url: a.url,
|
|
14003
14141
|
error: t
|
|
14004
|
-
}),
|
|
14142
|
+
}), J({
|
|
14005
14143
|
type: "error",
|
|
14006
14144
|
message: `MCP server「${o}」连接失败,其工具不可用:${t}`,
|
|
14007
14145
|
severity: "observable",
|
|
@@ -14012,18 +14150,18 @@ function Mm(e, n) {
|
|
|
14012
14150
|
}
|
|
14013
14151
|
});
|
|
14014
14152
|
} finally {
|
|
14015
|
-
r++, r === i && e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${
|
|
14153
|
+
r++, r === i && e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${De.length} 个工具,${Y.mcpServers.length} 个 server`);
|
|
14016
14154
|
}
|
|
14017
14155
|
}));
|
|
14018
14156
|
})();
|
|
14019
14157
|
let t = Lf(e.llm) ? e.llm : await ee(e.llm);
|
|
14020
|
-
|
|
14158
|
+
Y.agent = Jo({
|
|
14021
14159
|
llm: t,
|
|
14022
14160
|
systemPrompt: ge,
|
|
14023
14161
|
tools: K,
|
|
14024
14162
|
middleware: At,
|
|
14025
14163
|
maxToolRounds: e.maxToolRounds,
|
|
14026
|
-
hasSubagent:
|
|
14164
|
+
hasSubagent: Ye,
|
|
14027
14165
|
maxRetries: e.maxRetries,
|
|
14028
14166
|
stallMs: e.streamStallMs ?? 9e4,
|
|
14029
14167
|
streamMaxMs: e.streamMaxDurationMs ?? 18e5,
|
|
@@ -14033,23 +14171,23 @@ function Mm(e, n) {
|
|
|
14033
14171
|
maxOutputTokens: f.maxOutputTokens,
|
|
14034
14172
|
vision: f.vision,
|
|
14035
14173
|
imageContentFormat: !Lf(e.llm) && (e.llm.provider ?? "openai") === "anthropic" ? "anthropic" : "openai",
|
|
14036
|
-
maxVerifyAttempts:
|
|
14174
|
+
maxVerifyAttempts: et ? Ze : 0,
|
|
14037
14175
|
roundTokenBudget: e.roundTokenBudget ?? 0,
|
|
14038
14176
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
14039
14177
|
onLlmChange: (e) => {
|
|
14040
14178
|
x = e;
|
|
14041
14179
|
},
|
|
14042
14180
|
debug: e.debug
|
|
14043
|
-
}), se.current =
|
|
14044
|
-
|
|
14181
|
+
}), se.current = Y.agent, dt && dt.setReconfigureHook && dt.setReconfigureHook(() => {
|
|
14182
|
+
Y.agent && Y.agent.setTools(Be());
|
|
14045
14183
|
});
|
|
14046
|
-
})(),
|
|
14184
|
+
})(), Y;
|
|
14047
14185
|
}
|
|
14048
|
-
function
|
|
14186
|
+
function Fm(e, t) {
|
|
14049
14187
|
let n = e.id ?? Jf();
|
|
14050
14188
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
14051
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
14052
|
-
o ? a = o : (a =
|
|
14189
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? km.get(n) : void 0;
|
|
14190
|
+
o ? a = o : (a = Pm(e, n), e.shareContext && km.set(n, a)), a.refCount++;
|
|
14053
14191
|
let s = null, c = Cp(e), l = null, u = null;
|
|
14054
14192
|
async function d(n) {
|
|
14055
14193
|
if (await a.initDone, s) {
|
|
@@ -14118,6 +14256,12 @@ function Nm(e, t) {
|
|
|
14118
14256
|
}
|
|
14119
14257
|
}),
|
|
14120
14258
|
switchSession: (...e) => a.runSerial(async () => (a.abortAllActive(), a.switchSession(...e))),
|
|
14259
|
+
async exportSession(e) {
|
|
14260
|
+
return a.runSerial(() => a.exportSession(e));
|
|
14261
|
+
},
|
|
14262
|
+
async importSession(e) {
|
|
14263
|
+
return a.runSerial(() => a.importSession(e));
|
|
14264
|
+
},
|
|
14121
14265
|
resetSession: () => a.resetSession(),
|
|
14122
14266
|
sessions: a.sessions,
|
|
14123
14267
|
async listSessions() {
|
|
@@ -14273,7 +14417,7 @@ function Nm(e, t) {
|
|
|
14273
14417
|
}
|
|
14274
14418
|
//#endregion
|
|
14275
14419
|
//#region src/core/sdk/ragSubagent.ts
|
|
14276
|
-
function
|
|
14420
|
+
function Im(e, t, n, r, i) {
|
|
14277
14421
|
let a = [];
|
|
14278
14422
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
14279
14423
|
let o = [];
|
|
@@ -14288,7 +14432,7 @@ function Pm(e, t, n, r, i) {
|
|
|
14288
14432
|
|
|
14289
14433
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
14290
14434
|
}
|
|
14291
|
-
function
|
|
14435
|
+
function Lm(e, t, n, r, i) {
|
|
14292
14436
|
let a = [], o = [];
|
|
14293
14437
|
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)
|
|
14294
14438
|
|
|
@@ -14305,12 +14449,12 @@ ${a.join("\n")}
|
|
|
14305
14449
|
## 何时用何源
|
|
14306
14450
|
${o.join("\n")}`;
|
|
14307
14451
|
}
|
|
14308
|
-
var
|
|
14452
|
+
var Rm = {
|
|
14309
14453
|
name: "rag-search",
|
|
14310
14454
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
14311
|
-
getContent: () =>
|
|
14455
|
+
getContent: () => Lm(!0, !0, !0, "search_docs", "load_doc")
|
|
14312
14456
|
};
|
|
14313
|
-
function
|
|
14457
|
+
function zm(e, n, r) {
|
|
14314
14458
|
let i = s(async ({ query: e, topK: t }) => {
|
|
14315
14459
|
try {
|
|
14316
14460
|
let i = await n(e, { topK: t ?? r });
|
|
@@ -14328,7 +14472,7 @@ function Lm(e, n, r) {
|
|
|
14328
14472
|
});
|
|
14329
14473
|
return Ii([i]), i;
|
|
14330
14474
|
}
|
|
14331
|
-
function
|
|
14475
|
+
function Bm(e, n) {
|
|
14332
14476
|
let r = s(async ({ source: e }) => {
|
|
14333
14477
|
try {
|
|
14334
14478
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -14343,19 +14487,19 @@ function Rm(e, n) {
|
|
|
14343
14487
|
});
|
|
14344
14488
|
return Ii([r]), r;
|
|
14345
14489
|
}
|
|
14346
|
-
function
|
|
14490
|
+
function Vm(e) {
|
|
14347
14491
|
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;
|
|
14348
14492
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
14349
14493
|
let p = [];
|
|
14350
|
-
t && p.push(
|
|
14494
|
+
t && p.push(zm(s, t, o)), n && p.push(Bm(c, n)), f && p.push(...f);
|
|
14351
14495
|
let m = r ? [
|
|
14352
14496
|
"vfs_grep",
|
|
14353
14497
|
"vfs_read",
|
|
14354
14498
|
"vfs_json_read"
|
|
14355
|
-
] : void 0, h =
|
|
14499
|
+
] : void 0, h = Im(r, !!t, !!n, s, c), g = {
|
|
14356
14500
|
name: "rag-search",
|
|
14357
|
-
description:
|
|
14358
|
-
getContent: () =>
|
|
14501
|
+
description: Rm.description,
|
|
14502
|
+
getContent: () => Lm(r, !!t, !!n, s, c)
|
|
14359
14503
|
};
|
|
14360
14504
|
return {
|
|
14361
14505
|
id: i,
|
|
@@ -14370,7 +14514,7 @@ function zm(e) {
|
|
|
14370
14514
|
}
|
|
14371
14515
|
//#endregion
|
|
14372
14516
|
//#region src/core/utils/clipboard.ts
|
|
14373
|
-
async function
|
|
14517
|
+
async function Hm(e) {
|
|
14374
14518
|
try {
|
|
14375
14519
|
let t = globalThis.navigator?.clipboard;
|
|
14376
14520
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -14388,9 +14532,9 @@ async function Bm(e) {
|
|
|
14388
14532
|
}
|
|
14389
14533
|
//#endregion
|
|
14390
14534
|
//#region src/core/composables/useChat.ts
|
|
14391
|
-
var
|
|
14392
|
-
function
|
|
14393
|
-
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */
|
|
14535
|
+
var Um = 4e3;
|
|
14536
|
+
function Wm(e = {}) {
|
|
14537
|
+
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */ Mt({
|
|
14394
14538
|
messages: e.messages ?? [],
|
|
14395
14539
|
loading: !1,
|
|
14396
14540
|
error: null
|
|
@@ -14417,7 +14561,7 @@ function Hm(e = {}) {
|
|
|
14417
14561
|
}
|
|
14418
14562
|
async function _(e) {
|
|
14419
14563
|
if (l.value = !0, n) {
|
|
14420
|
-
let t = /* @__PURE__ */
|
|
14564
|
+
let t = /* @__PURE__ */ Mt({
|
|
14421
14565
|
role: "assistant",
|
|
14422
14566
|
content: "",
|
|
14423
14567
|
timestamp: Date.now(),
|
|
@@ -14469,7 +14613,7 @@ function Hm(e = {}) {
|
|
|
14469
14613
|
let t = e.delta || "";
|
|
14470
14614
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
14471
14615
|
let r = (n.subReason || "") + t;
|
|
14472
|
-
n.subReason = r.length >
|
|
14616
|
+
n.subReason = r.length > Um ? r.slice(-4e3) : r;
|
|
14473
14617
|
break;
|
|
14474
14618
|
}
|
|
14475
14619
|
n.children ||= [];
|
|
@@ -14489,7 +14633,8 @@ function Hm(e = {}) {
|
|
|
14489
14633
|
e.hold?.(), f.value = {
|
|
14490
14634
|
toolName: e.toolName,
|
|
14491
14635
|
args: e.args,
|
|
14492
|
-
resolve: e.resolve
|
|
14636
|
+
resolve: e.resolve,
|
|
14637
|
+
...e.preview ? { preview: e.preview } : {}
|
|
14493
14638
|
};
|
|
14494
14639
|
break;
|
|
14495
14640
|
}
|
|
@@ -14599,7 +14744,7 @@ function Hm(e = {}) {
|
|
|
14599
14744
|
}
|
|
14600
14745
|
//#endregion
|
|
14601
14746
|
//#region src/core/components/icons.ts
|
|
14602
|
-
var
|
|
14747
|
+
var Gm = {
|
|
14603
14748
|
header: "🤖",
|
|
14604
14749
|
subagent: "🤖",
|
|
14605
14750
|
subagentProgress: "🧬",
|
|
@@ -14610,10 +14755,10 @@ var Um = {
|
|
|
14610
14755
|
recommend: "💡",
|
|
14611
14756
|
conflict: "⚠️"
|
|
14612
14757
|
};
|
|
14613
|
-
function
|
|
14614
|
-
let t = { ...
|
|
14758
|
+
function Km(e) {
|
|
14759
|
+
let t = { ...Gm };
|
|
14615
14760
|
if (!e) return t;
|
|
14616
|
-
let n = Object.keys(
|
|
14761
|
+
let n = Object.keys(Gm);
|
|
14617
14762
|
for (let r of n) {
|
|
14618
14763
|
let n = e[r];
|
|
14619
14764
|
typeof n == "string" && (t[r] = n);
|
|
@@ -14622,12 +14767,14 @@ function Wm(e) {
|
|
|
14622
14767
|
}
|
|
14623
14768
|
//#endregion
|
|
14624
14769
|
//#region src/core/components/messages.ts
|
|
14625
|
-
var
|
|
14770
|
+
var qm = {
|
|
14626
14771
|
defaultTitle: "AI 助手",
|
|
14627
14772
|
inputPlaceholder: "输入消息,Enter 发送...",
|
|
14628
14773
|
newSession: "新建会话",
|
|
14629
14774
|
history: "历史记录",
|
|
14630
14775
|
more: "更多",
|
|
14776
|
+
exportSession: "导出会话",
|
|
14777
|
+
importSession: "导入会话…",
|
|
14631
14778
|
close: "关闭",
|
|
14632
14779
|
debugMenu: "调试 / 日志",
|
|
14633
14780
|
debugMenuTitle: "日志 / 执行流程 / Agent 信息",
|
|
@@ -14847,14 +14994,16 @@ var Gm = {
|
|
|
14847
14994
|
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
14848
14995
|
codeDemoButton: "按钮",
|
|
14849
14996
|
codeDemoInput: "输入框"
|
|
14850
|
-
},
|
|
14851
|
-
"zh-CN":
|
|
14997
|
+
}, Jm = {
|
|
14998
|
+
"zh-CN": qm,
|
|
14852
14999
|
"en-US": {
|
|
14853
15000
|
defaultTitle: "AI Assistant",
|
|
14854
15001
|
inputPlaceholder: "Type a message, Enter to send...",
|
|
14855
15002
|
newSession: "New chat",
|
|
14856
15003
|
history: "History",
|
|
14857
15004
|
more: "More",
|
|
15005
|
+
exportSession: "Export chat",
|
|
15006
|
+
importSession: "Import chat…",
|
|
14858
15007
|
close: "Close",
|
|
14859
15008
|
debugMenu: "Debug / Logs",
|
|
14860
15009
|
debugMenuTitle: "Logs / execution flow / agent info",
|
|
@@ -15076,10 +15225,10 @@ var Gm = {
|
|
|
15076
15225
|
codeDemoInput: "Input"
|
|
15077
15226
|
}
|
|
15078
15227
|
};
|
|
15079
|
-
function
|
|
15228
|
+
function Ym(e = "zh-CN", t) {
|
|
15080
15229
|
let n = {
|
|
15081
|
-
...
|
|
15082
|
-
...
|
|
15230
|
+
...qm,
|
|
15231
|
+
...Jm[e]
|
|
15083
15232
|
};
|
|
15084
15233
|
if (!t) return n;
|
|
15085
15234
|
let r = { ...n };
|
|
@@ -15091,9 +15240,9 @@ function qm(e = "zh-CN", t) {
|
|
|
15091
15240
|
}
|
|
15092
15241
|
//#endregion
|
|
15093
15242
|
//#region src/core/composables/chatContext.ts
|
|
15094
|
-
var
|
|
15095
|
-
function
|
|
15096
|
-
let t =
|
|
15243
|
+
var Xm = Symbol("chatContext");
|
|
15244
|
+
function Zm(e = {}) {
|
|
15245
|
+
let t = Wm({
|
|
15097
15246
|
fetchResponse: e.fetchResponse,
|
|
15098
15247
|
fetchStream: e.fetchStream,
|
|
15099
15248
|
messages: e.messages,
|
|
@@ -15115,7 +15264,7 @@ function Ym(e = {}) {
|
|
|
15115
15264
|
}, h = /* @__PURE__ */ Wt({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
15116
15265
|
h.value[e] = !g(e);
|
|
15117
15266
|
}, v = /* @__PURE__ */ Wt(!1), y = (e) => {
|
|
15118
|
-
|
|
15267
|
+
Hm(e).then((e) => {
|
|
15119
15268
|
e && (v.value = !0, setTimeout(() => {
|
|
15120
15269
|
v.value = !1;
|
|
15121
15270
|
}, 1500));
|
|
@@ -15177,7 +15326,7 @@ function Ym(e = {}) {
|
|
|
15177
15326
|
e.onClearFocus?.();
|
|
15178
15327
|
}, M = (t) => {
|
|
15179
15328
|
e.onFocusChipClick?.(t);
|
|
15180
|
-
}, N =
|
|
15329
|
+
}, N = Km(e.icons), ce = e.locale ?? "zh-CN", P = Ym(ce, e.dialogMessages);
|
|
15181
15330
|
return {
|
|
15182
15331
|
chat: t,
|
|
15183
15332
|
inputText: o,
|
|
@@ -15219,15 +15368,15 @@ function Ym(e = {}) {
|
|
|
15219
15368
|
toolStepView: e.toolStepView
|
|
15220
15369
|
};
|
|
15221
15370
|
}
|
|
15222
|
-
function
|
|
15223
|
-
let e = Qn(
|
|
15371
|
+
function Qm() {
|
|
15372
|
+
let e = Qn(Xm);
|
|
15224
15373
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
15225
15374
|
return e;
|
|
15226
15375
|
}
|
|
15227
15376
|
//#endregion
|
|
15228
15377
|
//#region src/core/index.headless.ts
|
|
15229
|
-
function
|
|
15230
|
-
return
|
|
15378
|
+
function $m(e) {
|
|
15379
|
+
return Fm(e);
|
|
15231
15380
|
}
|
|
15232
15381
|
//#endregion
|
|
15233
|
-
export { wp as CAPABILITIES, Dp as CONTEXT_PRESETS, Pf as CompressDecisionSchema, Bp as DEFAULT_COMPUTED_STYLES, Kc as DEFAULT_PROMPT_SOFT_CAP, xu as DEFAULT_SYSTEM_PROMPT, Cd as HTML_VOID_TAGS, Il as HUMAN_CONFIRM_TOOL_NAME, gi as ImageInputError, g as LOW_CAPS_HINT_BASELINE, p as MIN_CONTEXT_WINDOW, $i as MODEL_UNAVAILABLE_GUIDANCE, Gc as SOFT_CAP_MIN_WINDOW, Lc as STOP_WORDS, zs as UNSAFE_KEYS, cm as actionsToInspectInfo, sm as actionsToTools, fi as agentError, mu as analyzeContext, Zs as applyPatchToClone, ec as applyPatchToLive, dd as applyPatchesToBind, is as arrayMinLength, di as asAgentError, hf as buildCollectorJs, Gp as buildCssPath, Cu as buildDataPrompt, sf as buildDiagnosticsReport, gf as buildSandboxSrcdoc, wu as buildSystemPrompt,
|
|
15382
|
+
export { wp as CAPABILITIES, Dp as CONTEXT_PRESETS, Pf as CompressDecisionSchema, Bp as DEFAULT_COMPUTED_STYLES, Kc as DEFAULT_PROMPT_SOFT_CAP, xu as DEFAULT_SYSTEM_PROMPT, Cd as HTML_VOID_TAGS, Il as HUMAN_CONFIRM_TOOL_NAME, gi as ImageInputError, g as LOW_CAPS_HINT_BASELINE, p as MIN_CONTEXT_WINDOW, $i as MODEL_UNAVAILABLE_GUIDANCE, Gc as SOFT_CAP_MIN_WINDOW, Lc as STOP_WORDS, zs as UNSAFE_KEYS, cm as actionsToInspectInfo, sm as actionsToTools, fi as agentError, mu as analyzeContext, Zs as applyPatchToClone, ec as applyPatchToLive, dd as applyPatchesToBind, is as arrayMinLength, di as asAgentError, hf as buildCollectorJs, Gp as buildCssPath, Cu as buildDataPrompt, sf as buildDiagnosticsReport, gf as buildSandboxSrcdoc, wu as buildSystemPrompt, Xm as chatContextKey, ud as commitSetToBind, Sf as composeStructureThenRender, Di as compressImage, bu as connectMcp, ee as constructLlmFromConfig, E as constructOpenLlmSync, Hm as copyText, Jo as createAgent, Fl as createApprovalMiddleware, Zm as createChatContext, $m as createChatSdk, Kl as createCheckpointManager, ql as createCheckpointMiddleware, qf as createConflictManager, hu as createContextInspectorMiddleware, Of as createCraftNoteCheck, Sd as createDataOps, Ef as createHtmlFormatCheck, xf as createHtmlRenderCheck, Af as createHtmlSubagent, zl as createHumanConfirmMiddleware, Rl as createHumanConfirmTool, hp as createMemoryBackend, Ol as createMemoryMiddleware, u as createProxyLlm, Vm as createRagSubagent, aa as createSandboxRunner, Ep as createSdkEvents, Tm as createSerialRunner, yp as createSessionStore, bp as createSessionStoreWithBackend, xm as createSkillStore, yl as createSubagentMiddleware, $c as createSubagentTracker, Sl as createSubagentsMiddleware, hm as createUsageHintsMiddleware, Yl as createVerifyMiddleware, Ou as createVfs, _p as createWebStorageBackend, tu as createWriteBackCheck, ea as decorateModelUnavailable, Q as deepClone, dm as defineDataToolset, pc as defineSkill, jf as defineTool, Us as deleteByPath, Ff as deriveTitle, vs as describeSchemaNode, Po as detectGarbledToolCall, ic as diffObjects, Xp as domInfoTool, Zp as domInspectSkill, Yp as domSearchTool, Lp as domToStructure, zp as domTools, um as domToolsStatic, as as elementSchemaCandidates, Up as ensureDomListenerRecorder, zc as estimateMessageTokens, Hc as estimateRoundTokens, y as estimateTokens, ne as extractReasoningDelta, js as extractSchemaHint, gu as extractText, te as extractTextDelta, re as extractUsage, Np as fetchDocTools, lm as fetchTools, rc as findStrippedKeys, ys as formatConstraints, si as formatZodIssues, Z as getByPath, Rp as getDomTool, Jp as getElementInfo, em as getEnvSummary, Wp as getRecordedListeners, yf as getSandboxLifecycle, Qo as getSchemaAtPath, Yo as getSchemaTopKeys, Ys as hashValue, Es as htmlOrchestratorPrompt, Uc as indexSummarize, rm as inspectEnvTool, im as inspectTools, Lf as isChatModel, Zi as isContextLengthError, Qi as isModelUnavailableError, Xo as isPathAllowed, sp as isQuotaError, Bs as isUnsafePath, ha as jpEval, li as jsonParseError, qs as limitDepth, _ as lowCapsHint, af as maskUrlCredentials, Gs as maybeParseValue, Qd as measureWriteScale, mf as normalizeRenderResult, ae as normalizeUsage, x as offloadPassThroughChars, b as offloadThresholdChars, Ts as presets, fs as projectBySchema, ds as projectBySchemaDeep, Ks as projectFields, Wc as recallRounds, bf as renderInSandbox, bs as renderSchemaHint, xs as renderSchemaOverview, ws as renderSchemaShallow, Tp as resolveCapabilities, kp as resolveContextOptions, Cp as resolveDialogConfig, Kf as resolveLlm, v as resolveModelCaps, Jc as resolvePromptSoftCap, ts as resolveSchemaPath, Sp as resolveStorage, nc as restoreInPlace, tc as restoreLive, ui as routeError, ya as runSandboxedScript, Vs as safeMerge, $p as safeSerialize, $ as safeStringify, rs as schemaHasRefinement, Kp as searchDom, _a as searchJson, fm as selectBuiltinTools, Hs as setByPath, Yc as shouldTriggerCompression, cf as stringifyDiagnosticsReport, Ds as systemPromptHelpers, h as tableMaxOutputTokens, Rc as tokenize, X as toolError, Zo as unwrapSchema, Wm as useChat, Qm as useChatContext, ns as validateAtPath, Td as validateHtmlFormat, cd as validateRootValueLocally, ld as validateWriteLocally, Xs as watchFieldsHash, e as z, ci as zodError };
|