page-agent-sdk 4.12.0 → 4.13.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 +2 -0
- package/README.zh-CN.md +2 -0
- package/dist/page-agent-sdk.headless.js +756 -755
- package/package.json +2 -1
- package/types/headless.d.ts +556 -36
- package/types/index.d.ts +523 -38
|
@@ -497,42 +497,42 @@ process.env.NODE_ENV === "production" || Object.freeze([]);
|
|
|
497
497
|
var ae = () => {}, M = (e) => e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97), oe = (e) => e.startsWith("onUpdate:"), N = Object.assign, P = (e, t) => {
|
|
498
498
|
let n = e.indexOf(t);
|
|
499
499
|
n > -1 && e.splice(n, 1);
|
|
500
|
-
}, se = Object.prototype.hasOwnProperty, F = (e, t) => se.call(e, t), I = Array.isArray, ce = (e) =>
|
|
500
|
+
}, se = Object.prototype.hasOwnProperty, F = (e, t) => se.call(e, t), I = Array.isArray, ce = (e) => V(e) === "[object Map]", le = (e) => V(e) === "[object Set]", L = (e) => typeof e == "function", ue = (e) => typeof e == "string", de = (e) => typeof e == "symbol", R = (e) => typeof e == "object" && !!e, z = (e) => (R(e) || L(e)) && L(e.then) && L(e.catch), B = Object.prototype.toString, V = (e) => B.call(e), H = (e) => V(e).slice(8, -1), fe = (e) => V(e) === "[object Object]", pe = (e) => ue(e) && e !== "NaN" && e[0] !== "-" && "" + parseInt(e, 10) === e, me = ((e) => {
|
|
501
501
|
let t = /* @__PURE__ */ Object.create(null);
|
|
502
502
|
return ((n) => t[n] || (t[n] = e(n)));
|
|
503
|
-
})((e) => e.charAt(0).toUpperCase() + e.slice(1)),
|
|
503
|
+
})((e) => e.charAt(0).toUpperCase() + e.slice(1)), U = (e, t) => !Object.is(e, t), he = (e, t, n, r = !1) => {
|
|
504
504
|
Object.defineProperty(e, t, {
|
|
505
505
|
configurable: !0,
|
|
506
506
|
enumerable: !1,
|
|
507
507
|
writable: r,
|
|
508
508
|
value: n
|
|
509
509
|
});
|
|
510
|
-
},
|
|
511
|
-
function
|
|
510
|
+
}, ge, W = () => ge ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
|
|
511
|
+
function _e(e) {
|
|
512
512
|
if (I(e)) {
|
|
513
513
|
let t = {};
|
|
514
514
|
for (let n = 0; n < e.length; n++) {
|
|
515
|
-
let r = e[n], i = ue(r) ?
|
|
515
|
+
let r = e[n], i = ue(r) ? be(r) : _e(r);
|
|
516
516
|
if (i) for (let e in i) t[e] = i[e];
|
|
517
517
|
}
|
|
518
518
|
return t;
|
|
519
519
|
} else if (ue(e) || R(e)) return e;
|
|
520
520
|
}
|
|
521
|
-
var
|
|
522
|
-
function
|
|
521
|
+
var ve = /;(?![^(]*\))/g, G = /:([^]+)/, ye = /\/\*[^]*?\*\//g;
|
|
522
|
+
function be(e) {
|
|
523
523
|
let t = {};
|
|
524
|
-
return e.replace(
|
|
524
|
+
return e.replace(ye, "").split(ve).forEach((e) => {
|
|
525
525
|
if (e) {
|
|
526
|
-
let n = e.split(
|
|
526
|
+
let n = e.split(G);
|
|
527
527
|
n.length > 1 && (t[n[0].trim()] = n[1].trim());
|
|
528
528
|
}
|
|
529
529
|
}), t;
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function xe(e) {
|
|
532
532
|
let t = "";
|
|
533
533
|
if (ue(e)) t = e;
|
|
534
534
|
else if (I(e)) for (let n = 0; n < e.length; n++) {
|
|
535
|
-
let r =
|
|
535
|
+
let r = xe(e[n]);
|
|
536
536
|
r && (t += r + " ");
|
|
537
537
|
}
|
|
538
538
|
else if (R(e)) for (let n in e) e[n] && (t += n + " ");
|
|
@@ -540,76 +540,76 @@ function Se(e) {
|
|
|
540
540
|
}
|
|
541
541
|
//#endregion
|
|
542
542
|
//#region node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
543
|
-
function
|
|
543
|
+
function Se(e, ...t) {
|
|
544
544
|
console.warn(`[Vue warn] ${e}`, ...t);
|
|
545
545
|
}
|
|
546
|
-
var
|
|
547
|
-
function
|
|
548
|
-
return
|
|
546
|
+
var K;
|
|
547
|
+
function Ce() {
|
|
548
|
+
return K;
|
|
549
549
|
}
|
|
550
|
-
var
|
|
550
|
+
var q, we = /* @__PURE__ */ new WeakSet(), Te = class {
|
|
551
551
|
constructor(e) {
|
|
552
|
-
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,
|
|
552
|
+
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, K && (K.active ? K.effects.push(this) : this.flags &= -2);
|
|
553
553
|
}
|
|
554
554
|
pause() {
|
|
555
555
|
this.flags |= 64;
|
|
556
556
|
}
|
|
557
557
|
resume() {
|
|
558
|
-
this.flags & 64 && (this.flags &= -65,
|
|
558
|
+
this.flags & 64 && (this.flags &= -65, we.has(this) && (we.delete(this), this.trigger()));
|
|
559
559
|
}
|
|
560
560
|
notify() {
|
|
561
|
-
this.flags & 2 && !(this.flags & 32) || this.flags & 8 ||
|
|
561
|
+
this.flags & 2 && !(this.flags & 32) || this.flags & 8 || ke(this);
|
|
562
562
|
}
|
|
563
563
|
run() {
|
|
564
564
|
if (!(this.flags & 1)) return this.fn();
|
|
565
|
-
this.flags |= 2,
|
|
566
|
-
let e =
|
|
567
|
-
|
|
565
|
+
this.flags |= 2, Ve(this), Me(this);
|
|
566
|
+
let e = q, t = J;
|
|
567
|
+
q = this, J = !0;
|
|
568
568
|
try {
|
|
569
569
|
return this.fn();
|
|
570
570
|
} finally {
|
|
571
|
-
process.env.NODE_ENV !== "production" &&
|
|
571
|
+
process.env.NODE_ENV !== "production" && q !== this && Se("Active effect was not restored correctly - this is likely a Vue internal bug."), Ne(this), q = e, J = t, this.flags &= -3;
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
574
|
stop() {
|
|
575
575
|
if (this.flags & 1) {
|
|
576
|
-
for (let e = this.deps; e; e = e.nextDep)
|
|
577
|
-
this.deps = this.depsTail = void 0,
|
|
576
|
+
for (let e = this.deps; e; e = e.nextDep) Ie(e);
|
|
577
|
+
this.deps = this.depsTail = void 0, Ve(this), this.onStop && this.onStop(), this.flags &= -2;
|
|
578
578
|
}
|
|
579
579
|
}
|
|
580
580
|
trigger() {
|
|
581
|
-
this.flags & 64 ?
|
|
581
|
+
this.flags & 64 ? we.add(this) : this.scheduler ? this.scheduler() : this.runIfDirty();
|
|
582
582
|
}
|
|
583
583
|
runIfDirty() {
|
|
584
|
-
|
|
584
|
+
Pe(this) && this.run();
|
|
585
585
|
}
|
|
586
586
|
get dirty() {
|
|
587
|
-
return
|
|
587
|
+
return Pe(this);
|
|
588
588
|
}
|
|
589
|
-
},
|
|
590
|
-
function
|
|
589
|
+
}, Ee = 0, De, Oe;
|
|
590
|
+
function ke(e, t = !1) {
|
|
591
591
|
if (e.flags |= 8, t) {
|
|
592
|
-
e.next =
|
|
592
|
+
e.next = Oe, Oe = e;
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
|
-
e.next =
|
|
595
|
+
e.next = De, De = e;
|
|
596
596
|
}
|
|
597
|
-
function
|
|
598
|
-
|
|
597
|
+
function Ae() {
|
|
598
|
+
Ee++;
|
|
599
599
|
}
|
|
600
|
-
function
|
|
601
|
-
if (--
|
|
602
|
-
if (
|
|
603
|
-
let e =
|
|
604
|
-
for (
|
|
600
|
+
function je() {
|
|
601
|
+
if (--Ee > 0) return;
|
|
602
|
+
if (Oe) {
|
|
603
|
+
let e = Oe;
|
|
604
|
+
for (Oe = void 0; e;) {
|
|
605
605
|
let t = e.next;
|
|
606
606
|
e.next = void 0, e.flags &= -9, e = t;
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
609
|
let e;
|
|
610
|
-
for (;
|
|
611
|
-
let t =
|
|
612
|
-
for (
|
|
610
|
+
for (; De;) {
|
|
611
|
+
let t = De;
|
|
612
|
+
for (De = void 0; t;) {
|
|
613
613
|
let n = t.next;
|
|
614
614
|
if (t.next = void 0, t.flags &= -9, t.flags & 1) try {
|
|
615
615
|
t.trigger();
|
|
@@ -621,127 +621,127 @@ function Me() {
|
|
|
621
621
|
}
|
|
622
622
|
if (e) throw e;
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function Me(e) {
|
|
625
625
|
for (let t = e.deps; t; t = t.nextDep) t.version = -1, t.prevActiveLink = t.dep.activeLink, t.dep.activeLink = t;
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function Ne(e) {
|
|
628
628
|
let t, n = e.depsTail, r = n;
|
|
629
629
|
for (; r;) {
|
|
630
630
|
let e = r.prevDep;
|
|
631
|
-
r.version === -1 ? (r === n && (n = e),
|
|
631
|
+
r.version === -1 ? (r === n && (n = e), Ie(r), Le(r)) : t = r, r.dep.activeLink = r.prevActiveLink, r.prevActiveLink = void 0, r = e;
|
|
632
632
|
}
|
|
633
633
|
e.deps = t, e.depsTail = n;
|
|
634
634
|
}
|
|
635
|
-
function
|
|
636
|
-
for (let t = e.deps; t; t = t.nextDep) if (t.dep.version !== t.version || t.dep.computed && (
|
|
635
|
+
function Pe(e) {
|
|
636
|
+
for (let t = e.deps; t; t = t.nextDep) if (t.dep.version !== t.version || t.dep.computed && (Fe(t.dep.computed) || t.dep.version !== t.version)) return !0;
|
|
637
637
|
return !!e._dirty;
|
|
638
638
|
}
|
|
639
|
-
function
|
|
640
|
-
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion ===
|
|
639
|
+
function Fe(e) {
|
|
640
|
+
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === He) || (e.globalVersion = He, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !Pe(e)))) return;
|
|
641
641
|
e.flags |= 2;
|
|
642
|
-
let t = e.dep, n =
|
|
643
|
-
|
|
642
|
+
let t = e.dep, n = q, r = J;
|
|
643
|
+
q = e, J = !0;
|
|
644
644
|
try {
|
|
645
|
-
|
|
645
|
+
Me(e);
|
|
646
646
|
let n = e.fn(e._value);
|
|
647
|
-
(t.version === 0 ||
|
|
647
|
+
(t.version === 0 || U(n, e._value)) && (e.flags |= 128, e._value = n, t.version++);
|
|
648
648
|
} catch (e) {
|
|
649
649
|
throw t.version++, e;
|
|
650
650
|
} finally {
|
|
651
|
-
|
|
651
|
+
q = n, J = r, Ne(e), e.flags &= -3;
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
-
function
|
|
654
|
+
function Ie(e, t = !1) {
|
|
655
655
|
let { dep: n, prevSub: r, nextSub: i } = e;
|
|
656
656
|
if (r && (r.nextSub = i, e.prevSub = void 0), i && (i.prevSub = r, e.nextSub = void 0), process.env.NODE_ENV !== "production" && n.subsHead === e && (n.subsHead = i), n.subs === e && (n.subs = r, !r && n.computed)) {
|
|
657
657
|
n.computed.flags &= -5;
|
|
658
|
-
for (let e = n.computed.deps; e; e = e.nextDep)
|
|
658
|
+
for (let e = n.computed.deps; e; e = e.nextDep) Ie(e, !0);
|
|
659
659
|
}
|
|
660
660
|
!t && !--n.sc && n.map && n.map.delete(n.key);
|
|
661
661
|
}
|
|
662
|
-
function
|
|
662
|
+
function Le(e) {
|
|
663
663
|
let { prevDep: t, nextDep: n } = e;
|
|
664
664
|
t && (t.nextDep = n, e.prevDep = void 0), n && (n.prevDep = t, e.nextDep = void 0);
|
|
665
665
|
}
|
|
666
|
-
var
|
|
667
|
-
function
|
|
668
|
-
|
|
666
|
+
var J = !0, Re = [];
|
|
667
|
+
function ze() {
|
|
668
|
+
Re.push(J), J = !1;
|
|
669
669
|
}
|
|
670
|
-
function
|
|
671
|
-
let e =
|
|
672
|
-
|
|
670
|
+
function Be() {
|
|
671
|
+
let e = Re.pop();
|
|
672
|
+
J = e === void 0 || e;
|
|
673
673
|
}
|
|
674
|
-
function
|
|
674
|
+
function Ve(e) {
|
|
675
675
|
let { cleanup: t } = e;
|
|
676
676
|
if (e.cleanup = void 0, t) {
|
|
677
|
-
let e =
|
|
678
|
-
|
|
677
|
+
let e = q;
|
|
678
|
+
q = void 0;
|
|
679
679
|
try {
|
|
680
680
|
t();
|
|
681
681
|
} finally {
|
|
682
|
-
|
|
682
|
+
q = e;
|
|
683
683
|
}
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
|
-
var
|
|
686
|
+
var He = 0, Ue = class {
|
|
687
687
|
constructor(e, t) {
|
|
688
688
|
this.sub = e, this.dep = t, this.version = t.version, this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
689
689
|
}
|
|
690
|
-
},
|
|
690
|
+
}, We = class {
|
|
691
691
|
constructor(e) {
|
|
692
692
|
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);
|
|
693
693
|
}
|
|
694
694
|
track(e) {
|
|
695
|
-
if (!
|
|
695
|
+
if (!q || !J || q === this.computed) return;
|
|
696
696
|
let t = this.activeLink;
|
|
697
|
-
if (t === void 0 || t.sub !==
|
|
697
|
+
if (t === void 0 || t.sub !== q) t = this.activeLink = new Ue(q, this), q.deps ? (t.prevDep = q.depsTail, q.depsTail.nextDep = t, q.depsTail = t) : q.deps = q.depsTail = t, Ge(t);
|
|
698
698
|
else if (t.version === -1 && (t.version = this.version, t.nextDep)) {
|
|
699
699
|
let e = t.nextDep;
|
|
700
|
-
e.prevDep = t.prevDep, t.prevDep && (t.prevDep.nextDep = e), t.prevDep =
|
|
700
|
+
e.prevDep = t.prevDep, t.prevDep && (t.prevDep.nextDep = e), t.prevDep = q.depsTail, t.nextDep = void 0, q.depsTail.nextDep = t, q.depsTail = t, q.deps === t && (q.deps = e);
|
|
701
701
|
}
|
|
702
|
-
return process.env.NODE_ENV !== "production" &&
|
|
702
|
+
return process.env.NODE_ENV !== "production" && q.onTrack && q.onTrack(N({ effect: q }, e)), t;
|
|
703
703
|
}
|
|
704
704
|
trigger(e) {
|
|
705
|
-
this.version++,
|
|
705
|
+
this.version++, He++, this.notify(e);
|
|
706
706
|
}
|
|
707
707
|
notify(e) {
|
|
708
|
-
|
|
708
|
+
Ae();
|
|
709
709
|
try {
|
|
710
710
|
if (process.env.NODE_ENV !== "production") for (let t = this.subsHead; t; t = t.nextSub) t.sub.onTrigger && !(t.sub.flags & 8) && t.sub.onTrigger(N({ effect: t.sub }, e));
|
|
711
711
|
for (let e = this.subs; e; e = e.prevSub) e.sub.notify() && e.sub.dep.notify();
|
|
712
712
|
} finally {
|
|
713
|
-
|
|
713
|
+
je();
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
};
|
|
717
|
-
function
|
|
717
|
+
function Ge(e) {
|
|
718
718
|
if (e.dep.sc++, e.sub.flags & 4) {
|
|
719
719
|
let t = e.dep.computed;
|
|
720
720
|
if (t && !e.dep.subs) {
|
|
721
721
|
t.flags |= 20;
|
|
722
|
-
for (let e = t.deps; e; e = e.nextDep)
|
|
722
|
+
for (let e = t.deps; e; e = e.nextDep) Ge(e);
|
|
723
723
|
}
|
|
724
724
|
let n = e.dep.subs;
|
|
725
725
|
n !== e && (e.prevSub = n, n && (n.nextSub = e)), process.env.NODE_ENV !== "production" && e.dep.subsHead === void 0 && (e.dep.subsHead = e), e.dep.subs = e;
|
|
726
726
|
}
|
|
727
727
|
}
|
|
728
|
-
var
|
|
729
|
-
function
|
|
730
|
-
if (
|
|
731
|
-
let r =
|
|
732
|
-
r ||
|
|
728
|
+
var Ke = /* @__PURE__ */ new WeakMap(), qe = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Object iterate"), Je = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Map keys iterate"), Ye = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Array iterate");
|
|
729
|
+
function Xe(e, t, n) {
|
|
730
|
+
if (J && q) {
|
|
731
|
+
let r = Ke.get(e);
|
|
732
|
+
r || Ke.set(e, r = /* @__PURE__ */ new Map());
|
|
733
733
|
let i = r.get(n);
|
|
734
|
-
i || (r.set(n, i = new
|
|
734
|
+
i || (r.set(n, i = new We()), i.map = r, i.key = n), process.env.NODE_ENV === "production" ? i.track() : i.track({
|
|
735
735
|
target: e,
|
|
736
736
|
type: t,
|
|
737
737
|
key: n
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
|
-
function
|
|
742
|
-
let o =
|
|
741
|
+
function Ze(e, t, n, r, i, a) {
|
|
742
|
+
let o = Ke.get(e);
|
|
743
743
|
if (!o) {
|
|
744
|
-
|
|
744
|
+
He++;
|
|
745
745
|
return;
|
|
746
746
|
}
|
|
747
747
|
let s = (o) => {
|
|
@@ -754,63 +754,63 @@ function Qe(e, t, n, r, i, a) {
|
|
|
754
754
|
oldTarget: a
|
|
755
755
|
}));
|
|
756
756
|
};
|
|
757
|
-
if (
|
|
757
|
+
if (Ae(), t === "clear") o.forEach(s);
|
|
758
758
|
else {
|
|
759
|
-
let i = I(e), a = i &&
|
|
759
|
+
let i = I(e), a = i && pe(n);
|
|
760
760
|
if (i && n === "length") {
|
|
761
761
|
let e = Number(r);
|
|
762
762
|
o.forEach((t, n) => {
|
|
763
|
-
(n === "length" || n ===
|
|
763
|
+
(n === "length" || n === Ye || !de(n) && n >= e) && s(t);
|
|
764
764
|
});
|
|
765
|
-
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(
|
|
765
|
+
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(Ye)), t) {
|
|
766
766
|
case "add":
|
|
767
|
-
i ? a && s(o.get("length")) : (s(o.get(
|
|
767
|
+
i ? a && s(o.get("length")) : (s(o.get(qe)), ce(e) && s(o.get(Je)));
|
|
768
768
|
break;
|
|
769
769
|
case "delete":
|
|
770
|
-
i || (s(o.get(
|
|
770
|
+
i || (s(o.get(qe)), ce(e) && s(o.get(Je)));
|
|
771
771
|
break;
|
|
772
772
|
case "set":
|
|
773
|
-
ce(e) && s(o.get(
|
|
773
|
+
ce(e) && s(o.get(qe));
|
|
774
774
|
break;
|
|
775
775
|
}
|
|
776
776
|
}
|
|
777
|
-
|
|
777
|
+
je();
|
|
778
778
|
}
|
|
779
|
-
function
|
|
779
|
+
function Qe(e) {
|
|
780
780
|
let t = /* @__PURE__ */ X(e);
|
|
781
|
-
return t === e ? t : (
|
|
781
|
+
return t === e ? t : (Xe(t, "iterate", Ye), /* @__PURE__ */ Lt(e) ? t : t.map(Bt));
|
|
782
782
|
}
|
|
783
|
-
function
|
|
784
|
-
return
|
|
783
|
+
function $e(e) {
|
|
784
|
+
return Xe(e = /* @__PURE__ */ X(e), "iterate", Ye), e;
|
|
785
785
|
}
|
|
786
|
-
function
|
|
786
|
+
function et(e, t) {
|
|
787
787
|
return /* @__PURE__ */ It(e) ? Vt(/* @__PURE__ */ Ft(e) ? Bt(t) : t) : Bt(t);
|
|
788
788
|
}
|
|
789
789
|
var tt = {
|
|
790
790
|
__proto__: null,
|
|
791
791
|
[Symbol.iterator]() {
|
|
792
|
-
return nt(this, Symbol.iterator, (e) =>
|
|
792
|
+
return nt(this, Symbol.iterator, (e) => et(this, e));
|
|
793
793
|
},
|
|
794
794
|
concat(...e) {
|
|
795
|
-
return
|
|
795
|
+
return Qe(this).concat(...e.map((e) => I(e) ? Qe(e) : e));
|
|
796
796
|
},
|
|
797
797
|
entries() {
|
|
798
|
-
return nt(this, "entries", (e) => (e[1] =
|
|
798
|
+
return nt(this, "entries", (e) => (e[1] = et(this, e[1]), e));
|
|
799
799
|
},
|
|
800
800
|
every(e, t) {
|
|
801
801
|
return it(this, "every", e, t, void 0, arguments);
|
|
802
802
|
},
|
|
803
803
|
filter(e, t) {
|
|
804
|
-
return it(this, "filter", e, t, (e) => e.map((e) =>
|
|
804
|
+
return it(this, "filter", e, t, (e) => e.map((e) => et(this, e)), arguments);
|
|
805
805
|
},
|
|
806
806
|
find(e, t) {
|
|
807
|
-
return it(this, "find", e, t, (e) =>
|
|
807
|
+
return it(this, "find", e, t, (e) => et(this, e), arguments);
|
|
808
808
|
},
|
|
809
809
|
findIndex(e, t) {
|
|
810
810
|
return it(this, "findIndex", e, t, void 0, arguments);
|
|
811
811
|
},
|
|
812
812
|
findLast(e, t) {
|
|
813
|
-
return it(this, "findLast", e, t, (e) =>
|
|
813
|
+
return it(this, "findLast", e, t, (e) => et(this, e), arguments);
|
|
814
814
|
},
|
|
815
815
|
findLastIndex(e, t) {
|
|
816
816
|
return it(this, "findLastIndex", e, t, void 0, arguments);
|
|
@@ -825,7 +825,7 @@ var tt = {
|
|
|
825
825
|
return ot(this, "indexOf", e);
|
|
826
826
|
},
|
|
827
827
|
join(e) {
|
|
828
|
-
return
|
|
828
|
+
return Qe(this).join(e);
|
|
829
829
|
},
|
|
830
830
|
lastIndexOf(...e) {
|
|
831
831
|
return ot(this, "lastIndexOf", e);
|
|
@@ -855,23 +855,23 @@ var tt = {
|
|
|
855
855
|
return st(this, "splice", e);
|
|
856
856
|
},
|
|
857
857
|
toReversed() {
|
|
858
|
-
return
|
|
858
|
+
return Qe(this).toReversed();
|
|
859
859
|
},
|
|
860
860
|
toSorted(e) {
|
|
861
|
-
return
|
|
861
|
+
return Qe(this).toSorted(e);
|
|
862
862
|
},
|
|
863
863
|
toSpliced(...e) {
|
|
864
|
-
return
|
|
864
|
+
return Qe(this).toSpliced(...e);
|
|
865
865
|
},
|
|
866
866
|
unshift(...e) {
|
|
867
867
|
return st(this, "unshift", e);
|
|
868
868
|
},
|
|
869
869
|
values() {
|
|
870
|
-
return nt(this, "values", (e) =>
|
|
870
|
+
return nt(this, "values", (e) => et(this, e));
|
|
871
871
|
}
|
|
872
872
|
};
|
|
873
873
|
function nt(e, t, n) {
|
|
874
|
-
let r =
|
|
874
|
+
let r = $e(e), i = r[t]();
|
|
875
875
|
return r !== e && !/* @__PURE__ */ Lt(e) && (i._next = i.next, i.next = () => {
|
|
876
876
|
let e = i._next();
|
|
877
877
|
return e.done || (e.value = n(e.value)), e;
|
|
@@ -879,14 +879,14 @@ function nt(e, t, n) {
|
|
|
879
879
|
}
|
|
880
880
|
var rt = Array.prototype;
|
|
881
881
|
function it(e, t, n, r, i, a) {
|
|
882
|
-
let o =
|
|
882
|
+
let o = $e(e), s = o !== e && !/* @__PURE__ */ Lt(e), c = o[t];
|
|
883
883
|
if (c !== rt[t]) {
|
|
884
884
|
let t = c.apply(e, a);
|
|
885
885
|
return s ? Bt(t) : t;
|
|
886
886
|
}
|
|
887
887
|
let l = n;
|
|
888
888
|
o !== e && (s ? l = function(t, r) {
|
|
889
|
-
return n.call(this,
|
|
889
|
+
return n.call(this, et(e, t), r, e);
|
|
890
890
|
} : n.length > 2 && (l = function(t, r) {
|
|
891
891
|
return n.call(this, t, r, e);
|
|
892
892
|
}));
|
|
@@ -894,31 +894,31 @@ function it(e, t, n, r, i, a) {
|
|
|
894
894
|
return s && i ? i(u) : u;
|
|
895
895
|
}
|
|
896
896
|
function at(e, t, n, r) {
|
|
897
|
-
let i =
|
|
897
|
+
let i = $e(e), a = i !== e && !/* @__PURE__ */ Lt(e), o = n, s = !1;
|
|
898
898
|
i !== e && (a ? (s = r.length === 0, o = function(t, r, i) {
|
|
899
|
-
return s && (s = !1, t =
|
|
899
|
+
return s && (s = !1, t = et(e, t)), n.call(this, t, et(e, r), i, e);
|
|
900
900
|
}) : n.length > 3 && (o = function(t, r, i) {
|
|
901
901
|
return n.call(this, t, r, i, e);
|
|
902
902
|
}));
|
|
903
903
|
let c = i[t](o, ...r);
|
|
904
|
-
return s ?
|
|
904
|
+
return s ? et(e, c) : c;
|
|
905
905
|
}
|
|
906
906
|
function ot(e, t, n) {
|
|
907
907
|
let r = /* @__PURE__ */ X(e);
|
|
908
|
-
|
|
908
|
+
Xe(r, "iterate", Ye);
|
|
909
909
|
let i = r[t](...n);
|
|
910
910
|
return (i === -1 || i === !1) && /* @__PURE__ */ Rt(n[0]) ? (n[0] = /* @__PURE__ */ X(n[0]), r[t](...n)) : i;
|
|
911
911
|
}
|
|
912
912
|
function st(e, t, n = []) {
|
|
913
|
-
|
|
913
|
+
ze(), Ae();
|
|
914
914
|
let r = (/* @__PURE__ */ X(e))[t].apply(e, n);
|
|
915
|
-
return
|
|
915
|
+
return je(), Be(), r;
|
|
916
916
|
}
|
|
917
917
|
var ct = /* @__PURE__ */ A("__proto__,__v_isRef,__isVue"), lt = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(de));
|
|
918
918
|
function ut(e) {
|
|
919
919
|
de(e) || (e = String(e));
|
|
920
920
|
let t = /* @__PURE__ */ X(this);
|
|
921
|
-
return
|
|
921
|
+
return Xe(t, "has", e), t.hasOwnProperty(e);
|
|
922
922
|
}
|
|
923
923
|
var dt = class {
|
|
924
924
|
constructor(e = !1, t = !1) {
|
|
@@ -938,9 +938,9 @@ var dt = class {
|
|
|
938
938
|
if (t === "hasOwnProperty") return ut;
|
|
939
939
|
}
|
|
940
940
|
let o = Reflect.get(e, t, /* @__PURE__ */ Ht(e) ? e : n);
|
|
941
|
-
if ((de(t) ? lt.has(t) : ct(t)) || (r ||
|
|
941
|
+
if ((de(t) ? lt.has(t) : ct(t)) || (r || Xe(e, "get", t), i)) return o;
|
|
942
942
|
if (/* @__PURE__ */ Ht(o)) {
|
|
943
|
-
let e = a &&
|
|
943
|
+
let e = a && pe(t) ? o : o.value;
|
|
944
944
|
return r && R(e) ? /* @__PURE__ */ Mt(e) : e;
|
|
945
945
|
}
|
|
946
946
|
return R(o) ? r ? /* @__PURE__ */ Mt(o) : /* @__PURE__ */ jt(o) : o;
|
|
@@ -950,40 +950,40 @@ var dt = class {
|
|
|
950
950
|
super(!1, e);
|
|
951
951
|
}
|
|
952
952
|
set(e, t, n, r) {
|
|
953
|
-
let i = e[t], a = I(e) &&
|
|
953
|
+
let i = e[t], a = I(e) && pe(t);
|
|
954
954
|
if (!this._isShallow) {
|
|
955
955
|
let r = /* @__PURE__ */ It(i);
|
|
956
|
-
if (!/* @__PURE__ */ Lt(n) && !/* @__PURE__ */ It(n) && (i = /* @__PURE__ */ X(i), n = /* @__PURE__ */ X(n)), !a && /* @__PURE__ */ Ht(i) && !/* @__PURE__ */ Ht(n)) return r ? (process.env.NODE_ENV !== "production" &&
|
|
956
|
+
if (!/* @__PURE__ */ Lt(n) && !/* @__PURE__ */ It(n) && (i = /* @__PURE__ */ X(i), n = /* @__PURE__ */ X(n)), !a && /* @__PURE__ */ Ht(i) && !/* @__PURE__ */ Ht(n)) return r ? (process.env.NODE_ENV !== "production" && Se(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
|
|
957
957
|
}
|
|
958
958
|
let o = a ? Number(t) < e.length : F(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ Ht(e) ? e : r);
|
|
959
|
-
return e === /* @__PURE__ */ X(r) && s && (o ?
|
|
959
|
+
return e === /* @__PURE__ */ X(r) && s && (o ? U(n, i) && Ze(e, "set", t, n, i) : Ze(e, "add", t, n)), s;
|
|
960
960
|
}
|
|
961
961
|
deleteProperty(e, t) {
|
|
962
962
|
let n = F(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
|
|
963
|
-
return i && n &&
|
|
963
|
+
return i && n && Ze(e, "delete", t, void 0, r), i;
|
|
964
964
|
}
|
|
965
965
|
has(e, t) {
|
|
966
966
|
let n = Reflect.has(e, t);
|
|
967
|
-
return (!de(t) || !lt.has(t)) &&
|
|
967
|
+
return (!de(t) || !lt.has(t)) && Xe(e, "has", t), n;
|
|
968
968
|
}
|
|
969
969
|
ownKeys(e) {
|
|
970
|
-
return
|
|
970
|
+
return Xe(e, "iterate", I(e) ? "length" : qe), Reflect.ownKeys(e);
|
|
971
971
|
}
|
|
972
972
|
}, pt = class extends dt {
|
|
973
973
|
constructor(e = !1) {
|
|
974
974
|
super(!0, e);
|
|
975
975
|
}
|
|
976
976
|
set(e, t) {
|
|
977
|
-
return process.env.NODE_ENV !== "production" &&
|
|
977
|
+
return process.env.NODE_ENV !== "production" && Se(`Set operation on key "${String(t)}" failed: target is readonly.`, e), !0;
|
|
978
978
|
}
|
|
979
979
|
deleteProperty(e, t) {
|
|
980
|
-
return process.env.NODE_ENV !== "production" &&
|
|
980
|
+
return process.env.NODE_ENV !== "production" && Se(`Delete operation on key "${String(t)}" failed: target is readonly.`, e), !0;
|
|
981
981
|
}
|
|
982
982
|
}, mt = /* @__PURE__ */ new ft(), ht = /* @__PURE__ */ new pt(), gt = /* @__PURE__ */ new pt(!0), _t = (e) => e, vt = (e) => Reflect.getPrototypeOf(e);
|
|
983
983
|
function yt(e, t, n) {
|
|
984
984
|
return function(...r) {
|
|
985
985
|
let i = this.__v_raw, a = /* @__PURE__ */ X(i), o = ce(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? _t : t ? Vt : Bt;
|
|
986
|
-
return !t &&
|
|
986
|
+
return !t && Xe(a, "iterate", c ? Je : qe), N(Object.create(l), { next() {
|
|
987
987
|
let { value: e, done: t } = l.next();
|
|
988
988
|
return t ? {
|
|
989
989
|
value: e,
|
|
@@ -999,7 +999,7 @@ function bt(e) {
|
|
|
999
999
|
return function(...t) {
|
|
1000
1000
|
if (process.env.NODE_ENV !== "production") {
|
|
1001
1001
|
let n = t[0] ? `on key "${t[0]}" ` : "";
|
|
1002
|
-
|
|
1002
|
+
Se(`${me(e)} operation ${n}failed: target is readonly.`, /* @__PURE__ */ X(this));
|
|
1003
1003
|
}
|
|
1004
1004
|
return e === "delete" ? !1 : e === "clear" ? void 0 : this;
|
|
1005
1005
|
};
|
|
@@ -1008,7 +1008,7 @@ function Y(e, t) {
|
|
|
1008
1008
|
let n = {
|
|
1009
1009
|
get(n) {
|
|
1010
1010
|
let r = this.__v_raw, i = /* @__PURE__ */ X(r), a = /* @__PURE__ */ X(n);
|
|
1011
|
-
e || (
|
|
1011
|
+
e || (U(n, a) && Xe(i, "get", n), Xe(i, "get", a));
|
|
1012
1012
|
let { has: o } = vt(i), s = t ? _t : e ? Vt : Bt;
|
|
1013
1013
|
if (o.call(i, n)) return s(r.get(n));
|
|
1014
1014
|
if (o.call(i, a)) return s(r.get(a));
|
|
@@ -1016,15 +1016,15 @@ function Y(e, t) {
|
|
|
1016
1016
|
},
|
|
1017
1017
|
get size() {
|
|
1018
1018
|
let t = this.__v_raw;
|
|
1019
|
-
return !e &&
|
|
1019
|
+
return !e && Xe(/* @__PURE__ */ X(t), "iterate", qe), t.size;
|
|
1020
1020
|
},
|
|
1021
1021
|
has(t) {
|
|
1022
1022
|
let n = this.__v_raw, r = /* @__PURE__ */ X(n), i = /* @__PURE__ */ X(t);
|
|
1023
|
-
return e || (
|
|
1023
|
+
return e || (U(t, i) && Xe(r, "has", t), Xe(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
|
|
1024
1024
|
},
|
|
1025
1025
|
forEach(n, r) {
|
|
1026
1026
|
let i = this, a = i.__v_raw, o = /* @__PURE__ */ X(a), s = t ? _t : e ? Vt : Bt;
|
|
1027
|
-
return !e &&
|
|
1027
|
+
return !e && Xe(o, "iterate", qe), a.forEach((e, t) => n.call(r, s(e), s(t), i));
|
|
1028
1028
|
}
|
|
1029
1029
|
};
|
|
1030
1030
|
return N(n, e ? {
|
|
@@ -1035,24 +1035,24 @@ function Y(e, t) {
|
|
|
1035
1035
|
} : {
|
|
1036
1036
|
add(e) {
|
|
1037
1037
|
let n = /* @__PURE__ */ X(this), r = vt(n), i = /* @__PURE__ */ X(e), a = !t && !/* @__PURE__ */ Lt(e) && !/* @__PURE__ */ It(e) ? i : e;
|
|
1038
|
-
return r.has.call(n, a) ||
|
|
1038
|
+
return r.has.call(n, a) || U(e, a) && r.has.call(n, e) || U(i, a) && r.has.call(n, i) || (n.add(a), Ze(n, "add", a, a)), this;
|
|
1039
1039
|
},
|
|
1040
1040
|
set(e, n) {
|
|
1041
1041
|
!t && !/* @__PURE__ */ Lt(n) && !/* @__PURE__ */ It(n) && (n = /* @__PURE__ */ X(n));
|
|
1042
1042
|
let r = /* @__PURE__ */ X(this), { has: i, get: a } = vt(r), o = i.call(r, e);
|
|
1043
1043
|
o ? process.env.NODE_ENV !== "production" && Tt(r, i, e) : (e = /* @__PURE__ */ X(e), o = i.call(r, e));
|
|
1044
1044
|
let s = a.call(r, e);
|
|
1045
|
-
return r.set(e, n), o ?
|
|
1045
|
+
return r.set(e, n), o ? U(n, s) && Ze(r, "set", e, n, s) : Ze(r, "add", e, n), this;
|
|
1046
1046
|
},
|
|
1047
1047
|
delete(e) {
|
|
1048
1048
|
let t = /* @__PURE__ */ X(this), { has: n, get: r } = vt(t), i = n.call(t, e);
|
|
1049
1049
|
i ? process.env.NODE_ENV !== "production" && Tt(t, n, e) : (e = /* @__PURE__ */ X(e), i = n.call(t, e));
|
|
1050
1050
|
let a = r ? r.call(t, e) : void 0, o = t.delete(e);
|
|
1051
|
-
return i &&
|
|
1051
|
+
return i && Ze(t, "delete", e, void 0, a), o;
|
|
1052
1052
|
},
|
|
1053
1053
|
clear() {
|
|
1054
1054
|
let e = /* @__PURE__ */ X(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : ce(e) ? new Map(e) : new Set(e), r = e.clear();
|
|
1055
|
-
return t &&
|
|
1055
|
+
return t && Ze(e, "clear", void 0, void 0, n), r;
|
|
1056
1056
|
}
|
|
1057
1057
|
}), [
|
|
1058
1058
|
"keys",
|
|
@@ -1071,8 +1071,8 @@ var St = { get: /* @__PURE__ */ xt(!1, !1) }, Ct = { get: /* @__PURE__ */ xt(!0,
|
|
|
1071
1071
|
function Tt(e, t, n) {
|
|
1072
1072
|
let r = /* @__PURE__ */ X(n);
|
|
1073
1073
|
if (r !== n && t.call(e, r)) {
|
|
1074
|
-
let t =
|
|
1075
|
-
|
|
1074
|
+
let t = H(e);
|
|
1075
|
+
Se(`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.`);
|
|
1076
1076
|
}
|
|
1077
1077
|
}
|
|
1078
1078
|
var Et = /* @__PURE__ */ new WeakMap(), Dt = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakMap();
|
|
@@ -1100,11 +1100,11 @@ function Nt(e) {
|
|
|
1100
1100
|
return Pt(e, !0, gt, wt, kt);
|
|
1101
1101
|
}
|
|
1102
1102
|
function Pt(e, t, n, r, i) {
|
|
1103
|
-
if (!R(e)) return process.env.NODE_ENV !== "production" &&
|
|
1103
|
+
if (!R(e)) return process.env.NODE_ENV !== "production" && Se(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
|
|
1104
1104
|
if (e.__v_raw && !(t && e.__v_isReactive) || e.__v_skip || !Object.isExtensible(e)) return e;
|
|
1105
1105
|
let a = i.get(e);
|
|
1106
1106
|
if (a) return a;
|
|
1107
|
-
let o = At(
|
|
1107
|
+
let o = At(H(e));
|
|
1108
1108
|
if (o === 0) return e;
|
|
1109
1109
|
let s = new Proxy(e, o === 2 ? r : n);
|
|
1110
1110
|
return i.set(e, s), s;
|
|
@@ -1131,7 +1131,7 @@ function X(e) {
|
|
|
1131
1131
|
return t ? /* @__PURE__ */ X(t) : e;
|
|
1132
1132
|
}
|
|
1133
1133
|
function zt(e) {
|
|
1134
|
-
return !F(e, "__v_skip") && Object.isExtensible(e) &&
|
|
1134
|
+
return !F(e, "__v_skip") && Object.isExtensible(e) && he(e, "__v_skip", !0), e;
|
|
1135
1135
|
}
|
|
1136
1136
|
var Bt = (e) => R(e) ? /* @__PURE__ */ jt(e) : e, Vt = (e) => R(e) ? /* @__PURE__ */ Mt(e) : e;
|
|
1137
1137
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1151,7 +1151,7 @@ function Gt(e, t) {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
var Kt = class {
|
|
1153
1153
|
constructor(e, t) {
|
|
1154
|
-
this.dep = new
|
|
1154
|
+
this.dep = new We(), this.__v_isRef = !0, this.__v_isShallow = !1, this._rawValue = t ? e : /* @__PURE__ */ X(e), this._value = t ? e : Bt(e), this.__v_isShallow = t;
|
|
1155
1155
|
}
|
|
1156
1156
|
get value() {
|
|
1157
1157
|
return process.env.NODE_ENV === "production" ? this.dep.track() : this.dep.track({
|
|
@@ -1162,7 +1162,7 @@ var Kt = class {
|
|
|
1162
1162
|
}
|
|
1163
1163
|
set value(e) {
|
|
1164
1164
|
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ Lt(e) || /* @__PURE__ */ It(e);
|
|
1165
|
-
e = n ? e : /* @__PURE__ */ X(e),
|
|
1165
|
+
e = n ? e : /* @__PURE__ */ X(e), U(e, t) && (this._rawValue = e, this._value = n ? e : Bt(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
|
|
1166
1166
|
target: this,
|
|
1167
1167
|
type: "set",
|
|
1168
1168
|
key: "value",
|
|
@@ -1194,10 +1194,10 @@ function Xt(e) {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
var Zt = class {
|
|
1196
1196
|
constructor(e, t, n) {
|
|
1197
|
-
this.fn = e, this.setter = t, this._value = void 0, this.dep = new
|
|
1197
|
+
this.fn = e, this.setter = t, this._value = void 0, this.dep = new We(this), this.__v_isRef = !0, this.deps = void 0, this.depsTail = void 0, this.flags = 16, this.globalVersion = He - 1, this.next = void 0, this.effect = this, this.__v_isReadonly = !t, this.isSSR = n;
|
|
1198
1198
|
}
|
|
1199
1199
|
notify() {
|
|
1200
|
-
if (this.flags |= 16, !(this.flags & 8) &&
|
|
1200
|
+
if (this.flags |= 16, !(this.flags & 8) && q !== this) return ke(this, !0), !0;
|
|
1201
1201
|
process.env.NODE_ENV;
|
|
1202
1202
|
}
|
|
1203
1203
|
get value() {
|
|
@@ -1206,10 +1206,10 @@ var Zt = class {
|
|
|
1206
1206
|
type: "get",
|
|
1207
1207
|
key: "value"
|
|
1208
1208
|
});
|
|
1209
|
-
return
|
|
1209
|
+
return Fe(this), e && (e.version = this.dep.version), this._value;
|
|
1210
1210
|
}
|
|
1211
1211
|
set value(e) {
|
|
1212
|
-
this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" &&
|
|
1212
|
+
this.setter ? this.setter(e) : process.env.NODE_ENV !== "production" && Se("Write operation failed: computed value is readonly");
|
|
1213
1213
|
}
|
|
1214
1214
|
};
|
|
1215
1215
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1224,11 +1224,11 @@ function nn(e, t = !1, n = tn) {
|
|
|
1224
1224
|
if (n) {
|
|
1225
1225
|
let t = en.get(n);
|
|
1226
1226
|
t || en.set(n, t = []), t.push(e);
|
|
1227
|
-
} else process.env.NODE_ENV !== "production" && !t &&
|
|
1227
|
+
} else process.env.NODE_ENV !== "production" && !t && Se("onWatcherCleanup() was called when there was no active watcher to associate with.");
|
|
1228
1228
|
}
|
|
1229
1229
|
function rn(e, t, n = j) {
|
|
1230
1230
|
let { immediate: r, deep: i, once: a, scheduler: o, augmentJob: s, call: c } = n, l = (e) => {
|
|
1231
|
-
(n.onWarn ||
|
|
1231
|
+
(n.onWarn || Se)("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.");
|
|
1232
1232
|
}, u = (e) => i ? e : /* @__PURE__ */ Lt(e) || i === !1 || i === 0 ? an(e, 1) : an(e), d, f, p, m, h = !1, g = !1;
|
|
1233
1233
|
if (/* @__PURE__ */ Ht(e) ? (f = () => e.value, h = /* @__PURE__ */ Lt(e)) : /* @__PURE__ */ Ft(e) ? (f = () => u(e), h = !0) : I(e) ? (g = !0, h = e.some((e) => /* @__PURE__ */ Ft(e) || /* @__PURE__ */ Lt(e)), f = () => e.map((e) => {
|
|
1234
1234
|
if (/* @__PURE__ */ Ht(e)) return e.value;
|
|
@@ -1237,11 +1237,11 @@ function rn(e, t, n = j) {
|
|
|
1237
1237
|
process.env.NODE_ENV !== "production" && l(e);
|
|
1238
1238
|
})) : L(e) ? f = t ? c ? () => c(e, 2) : e : () => {
|
|
1239
1239
|
if (p) {
|
|
1240
|
-
|
|
1240
|
+
ze();
|
|
1241
1241
|
try {
|
|
1242
1242
|
p();
|
|
1243
1243
|
} finally {
|
|
1244
|
-
|
|
1244
|
+
Be();
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
let t = tn;
|
|
@@ -1255,7 +1255,7 @@ function rn(e, t, n = j) {
|
|
|
1255
1255
|
let e = f, t = i === !0 ? Infinity : i;
|
|
1256
1256
|
f = () => an(e(), t);
|
|
1257
1257
|
}
|
|
1258
|
-
let _ =
|
|
1258
|
+
let _ = Ce(), v = () => {
|
|
1259
1259
|
d.stop(), _ && _.active && P(_.effects, d);
|
|
1260
1260
|
};
|
|
1261
1261
|
if (a && t) {
|
|
@@ -1268,7 +1268,7 @@ function rn(e, t, n = j) {
|
|
|
1268
1268
|
let y = g ? Array(e.length).fill($t) : $t, b = (e) => {
|
|
1269
1269
|
if (!(!(d.flags & 1) || !d.dirty && !e)) if (t) {
|
|
1270
1270
|
let n = d.run();
|
|
1271
|
-
if (e || i || h || (g ? n.some((e, t) =>
|
|
1271
|
+
if (e || i || h || (g ? n.some((e, t) => U(e, y[t])) : U(n, y))) {
|
|
1272
1272
|
p && p();
|
|
1273
1273
|
let e = tn;
|
|
1274
1274
|
tn = d;
|
|
@@ -1285,7 +1285,7 @@ function rn(e, t, n = j) {
|
|
|
1285
1285
|
}
|
|
1286
1286
|
} else d.run();
|
|
1287
1287
|
};
|
|
1288
|
-
return s && s(b), d = new
|
|
1288
|
+
return s && s(b), d = new Te(f), d.scheduler = o ? () => o(b, !1) : b, m = (e) => nn(e, !1, d), p = d.onStop = () => {
|
|
1289
1289
|
let e = en.get(d);
|
|
1290
1290
|
if (e) {
|
|
1291
1291
|
if (c) c(e, 4);
|
|
@@ -1301,7 +1301,7 @@ function an(e, t = Infinity, n) {
|
|
|
1301
1301
|
else if (le(e) || ce(e)) e.forEach((e) => {
|
|
1302
1302
|
an(e, t, n);
|
|
1303
1303
|
});
|
|
1304
|
-
else if (
|
|
1304
|
+
else if (fe(e)) {
|
|
1305
1305
|
for (let r in e) an(e[r], t, n);
|
|
1306
1306
|
for (let r of Object.getOwnPropertySymbols(e)) Object.prototype.propertyIsEnumerable.call(e, r) && an(e[r], t, n);
|
|
1307
1307
|
}
|
|
@@ -1319,7 +1319,7 @@ function cn() {
|
|
|
1319
1319
|
var ln = !1;
|
|
1320
1320
|
function un(e, ...t) {
|
|
1321
1321
|
if (ln) return;
|
|
1322
|
-
ln = !0,
|
|
1322
|
+
ln = !0, ze();
|
|
1323
1323
|
let n = on.length ? on[on.length - 1].component : null, r = n && n.appContext.config.warnHandler, i = dn();
|
|
1324
1324
|
if (r) _n(r, n, 11, [
|
|
1325
1325
|
e + t.map((e) => e.toString?.call(e) ?? JSON.stringify(e)).join(""),
|
|
@@ -1331,7 +1331,7 @@ function un(e, ...t) {
|
|
|
1331
1331
|
let n = [`[Vue warn]: ${e}`, ...t];
|
|
1332
1332
|
i.length && n.push("\n", ...fn(i)), console.warn(...n);
|
|
1333
1333
|
}
|
|
1334
|
-
|
|
1334
|
+
Be(), ln = !1;
|
|
1335
1335
|
}
|
|
1336
1336
|
function dn() {
|
|
1337
1337
|
let e = on[on.length - 1];
|
|
@@ -1440,11 +1440,11 @@ function yn(e, t, n, r = !0) {
|
|
|
1440
1440
|
r = r.parent;
|
|
1441
1441
|
}
|
|
1442
1442
|
if (a) {
|
|
1443
|
-
|
|
1443
|
+
ze(), _n(a, null, 10, [
|
|
1444
1444
|
e,
|
|
1445
1445
|
i,
|
|
1446
1446
|
o
|
|
1447
|
-
]),
|
|
1447
|
+
]), Be();
|
|
1448
1448
|
return;
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
@@ -1526,7 +1526,7 @@ function Ln(e, t) {
|
|
|
1526
1526
|
return e.set(t, n + 1), !1;
|
|
1527
1527
|
}
|
|
1528
1528
|
var Rn = /* @__PURE__ */ new Map();
|
|
1529
|
-
process.env.NODE_ENV !== "production" && (
|
|
1529
|
+
process.env.NODE_ENV !== "production" && (W().__VUE_HMR_RUNTIME__ = {
|
|
1530
1530
|
createRecord: Gn(Bn),
|
|
1531
1531
|
rerender: Gn(Hn),
|
|
1532
1532
|
reload: Gn(Un)
|
|
@@ -1645,7 +1645,7 @@ var rr = (e) => e.__isTeleport;
|
|
|
1645
1645
|
function ir(e, t) {
|
|
1646
1646
|
e.shapeFlag & 6 && e.component ? (e.transition = t, ir(e.component.subTree, t)) : e.shapeFlag & 128 ? (e.ssContent.transition = t.clone(e.ssContent), e.ssFallback.transition = t.clone(e.ssFallback)) : e.transition = t;
|
|
1647
1647
|
}
|
|
1648
|
-
|
|
1648
|
+
W().requestIdleCallback, W().cancelIdleCallback;
|
|
1649
1649
|
var ar = /* @__PURE__ */ Symbol.for("v-ndc"), or = (e) => e ? Yr(e) ? Zr(e) : or(e.parent) : null, sr = /* @__PURE__ */ N(/* @__PURE__ */ Object.create(null), {
|
|
1650
1650
|
$: (e) => e,
|
|
1651
1651
|
$el: (e) => e.vnode.el,
|
|
@@ -1684,7 +1684,7 @@ var ar = /* @__PURE__ */ Symbol.for("v-ndc"), or = (e) => e ? Yr(e) ? Zr(e) : or
|
|
|
1684
1684
|
else dr && (o[t] = 0);
|
|
1685
1685
|
}
|
|
1686
1686
|
let l = sr[t], u, d;
|
|
1687
|
-
if (l) return t === "$attrs" ? (
|
|
1687
|
+
if (l) return t === "$attrs" ? (Xe(e.attrs, "get", ""), process.env.NODE_ENV) : process.env.NODE_ENV !== "production" && t === "$slots" && Xe(e, "get", t), l(e);
|
|
1688
1688
|
if ((u = s.__cssModules) && (u = u[t])) return u;
|
|
1689
1689
|
if (n !== j && F(n, t)) return o[t] = 4, n[t];
|
|
1690
1690
|
if (d = c.config.globalProperties, F(d, t)) return d[t];
|
|
@@ -1838,7 +1838,7 @@ function Rr(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
1838
1838
|
if (ni(e) && (e = e.__vccOpts), t) {
|
|
1839
1839
|
t = zr(t);
|
|
1840
1840
|
let { class: e, style: n } = t;
|
|
1841
|
-
e && !ue(e) && (t.class =
|
|
1841
|
+
e && !ue(e) && (t.class = xe(e)), R(n) && (/* @__PURE__ */ Rt(n) && !I(n) && (n = N({}, n)), t.style = _e(n));
|
|
1842
1842
|
}
|
|
1843
1843
|
let o = ue(e) ? 1 : Er(e) ? 128 : rr(e) ? 64 : R(e) ? 4 : L(e) ? 2 : 0;
|
|
1844
1844
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ Rt(e) && (e = /* @__PURE__ */ X(e), un("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), Ir(e, t, n, r, i, o, a, !0);
|
|
@@ -1912,8 +1912,8 @@ function Wr(...e) {
|
|
|
1912
1912
|
let t = {};
|
|
1913
1913
|
for (let n = 0; n < e.length; n++) {
|
|
1914
1914
|
let r = e[n];
|
|
1915
|
-
for (let e in r) if (e === "class") t.class !== r.class && (t.class =
|
|
1916
|
-
else if (e === "style") t.style =
|
|
1915
|
+
for (let e in r) if (e === "class") t.class !== r.class && (t.class = xe([t.class, r.class]));
|
|
1916
|
+
else if (e === "style") t.style = _e([t.style, r.style]);
|
|
1917
1917
|
else if (M(e)) {
|
|
1918
1918
|
let n = t[e], i = r[e];
|
|
1919
1919
|
i && n !== i && !(I(n) && n.includes(i)) ? t[e] = n ? [].concat(n, i) : i : i == null && n == null && !oe(e) && (t[e] = i);
|
|
@@ -1923,7 +1923,7 @@ function Wr(...e) {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
var Gr = null, Kr = () => Gr || Yn, qr;
|
|
1925
1925
|
{
|
|
1926
|
-
let e =
|
|
1926
|
+
let e = W(), t = (t, n) => {
|
|
1927
1927
|
let r;
|
|
1928
1928
|
return (r = e[t]) || (r = e[t] = []), r.push(n), (e) => {
|
|
1929
1929
|
r.length > 1 ? r.forEach((t) => t(e)) : r[0](e);
|
|
@@ -1994,9 +1994,9 @@ function ii() {
|
|
|
1994
1994
|
"VueInstance"
|
|
1995
1995
|
];
|
|
1996
1996
|
if (/* @__PURE__ */ Ht(t)) {
|
|
1997
|
-
|
|
1997
|
+
ze();
|
|
1998
1998
|
let n = t.value;
|
|
1999
|
-
return
|
|
1999
|
+
return Be(), [
|
|
2000
2000
|
"div",
|
|
2001
2001
|
{},
|
|
2002
2002
|
[
|
|
@@ -3711,7 +3711,7 @@ function es(e) {
|
|
|
3711
3711
|
...e,
|
|
3712
3712
|
data: Jo(e.data)
|
|
3713
3713
|
}), le.value.length > Wo && le.value.splice(0, le.value.length - Wo), qt(le);
|
|
3714
|
-
},
|
|
3714
|
+
}, V = [...h.flatMap((e) => e.tools || []), ...m], H = e.llm ?? new n({
|
|
3715
3715
|
apiKey: t,
|
|
3716
3716
|
model: c,
|
|
3717
3717
|
temperature: l,
|
|
@@ -3723,57 +3723,57 @@ function es(e) {
|
|
|
3723
3723
|
...f
|
|
3724
3724
|
},
|
|
3725
3725
|
...d ? { modelKwargs: d } : {}
|
|
3726
|
-
}),
|
|
3727
|
-
let e =
|
|
3726
|
+
}), fe = V.length > 0 ? H.bindTools?.(V) ?? H : H, pe = () => {
|
|
3727
|
+
let e = H;
|
|
3728
3728
|
return (typeof e.model == "string" && e.model ? e.model : typeof e.modelName == "string" && e.modelName ? e.modelName : "") || c;
|
|
3729
3729
|
};
|
|
3730
|
-
function
|
|
3731
|
-
|
|
3730
|
+
function me() {
|
|
3731
|
+
fe = V.length > 0 ? H.bindTools?.(V) ?? H : H;
|
|
3732
3732
|
}
|
|
3733
|
-
let
|
|
3734
|
-
e.__pgIsSubagent && (
|
|
3735
|
-
let
|
|
3733
|
+
let U = Ri();
|
|
3734
|
+
e.__pgIsSubagent && (U.__pgIsSubagent = !0);
|
|
3735
|
+
let he = .25, ge = /* @__PURE__ */ new Set([
|
|
3736
3736
|
"mission",
|
|
3737
3737
|
"workingMemory",
|
|
3738
3738
|
"intentGuard",
|
|
3739
3739
|
"resumeNotice"
|
|
3740
3740
|
]);
|
|
3741
|
-
function
|
|
3741
|
+
function W() {
|
|
3742
3742
|
let e = p || "你是一个智能助手。", t = [];
|
|
3743
3743
|
for (let e of h) if (e.augmentPrompt) {
|
|
3744
|
-
let n = e.augmentPrompt(
|
|
3744
|
+
let n = e.augmentPrompt(U);
|
|
3745
3745
|
n && t.push({
|
|
3746
3746
|
name: e.name,
|
|
3747
3747
|
text: n,
|
|
3748
3748
|
tokens: y(n),
|
|
3749
|
-
pin:
|
|
3749
|
+
pin: ge.has(e.name)
|
|
3750
3750
|
});
|
|
3751
3751
|
}
|
|
3752
|
-
let n = Math.max(2e3, Math.round(P.contextWindow *
|
|
3752
|
+
let n = Math.max(2e3, Math.round(P.contextWindow * he)), r = y(e) + t.reduce((e, t) => e + t.tokens, 0);
|
|
3753
3753
|
if (r > n) {
|
|
3754
3754
|
let e = r, i = [];
|
|
3755
3755
|
for (let e of t.filter((e) => !e.pin).sort((e, t) => t.tokens - e.tokens)) {
|
|
3756
3756
|
if (r <= n) break;
|
|
3757
3757
|
i.push(`${e.name}(${e.tokens})`), r -= e.tokens, e.text = "";
|
|
3758
3758
|
}
|
|
3759
|
-
i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${P.contextWindow} 的 ${
|
|
3759
|
+
i.length && console.warn(`[page-agent-sdk] 系统段超预算(${e} > ${n} tokens,窗口 ${P.contextWindow} 的 ${he * 100}%),drop 非核心段:${i.join(", ")}(保 base/mission/workingMemory)`);
|
|
3760
3760
|
}
|
|
3761
3761
|
return [e, ...t.filter((e) => e.text).map((e) => e.text)].join("\n\n");
|
|
3762
3762
|
}
|
|
3763
|
-
function
|
|
3764
|
-
let t = [new a(
|
|
3763
|
+
function _e(e) {
|
|
3764
|
+
let t = [new a(W())];
|
|
3765
3765
|
for (let n of e) if (n.role === "user") {
|
|
3766
3766
|
let e = P.vision && n.images?.length ? yi(n.content, n.images, ae) : null;
|
|
3767
3767
|
e ? t.push(new i({ content: e })) : n.images?.some((e) => e.description) ? t.push(new i(bi(n.content, n.images))) : t.push(new i(n.content));
|
|
3768
3768
|
} else n.role === "assistant" ? t.push(new r(n.content)) : n.role === "system" && t.push(new a(n.content));
|
|
3769
3769
|
return t;
|
|
3770
3770
|
}
|
|
3771
|
-
function
|
|
3772
|
-
let n = e[0] &&
|
|
3771
|
+
function ve(e, t) {
|
|
3772
|
+
let n = e[0] && be(e[0]) === "system" ? e.slice(1) : e.slice(), r = W();
|
|
3773
3773
|
return [new a(t ? `${r}\n\n${t}` : r), ...n];
|
|
3774
3774
|
}
|
|
3775
|
-
async function
|
|
3776
|
-
let a = i ??
|
|
3775
|
+
async function G(e, t, n, i) {
|
|
3776
|
+
let a = i ?? fe, o = {
|
|
3777
3777
|
signal: n,
|
|
3778
3778
|
maxRetries: S,
|
|
3779
3779
|
baseDelayMs: C,
|
|
@@ -3812,14 +3812,14 @@ function es(e) {
|
|
|
3812
3812
|
};
|
|
3813
3813
|
if (Xi(a) && !e._ctxRetry) {
|
|
3814
3814
|
e._ctxRetry = !0;
|
|
3815
|
-
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o =
|
|
3815
|
+
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = xe(e.messages, Math.round(P.contextWindow * .3)), s = o.reduce((e, t) => e + r(t), 0);
|
|
3816
3816
|
return z("error", {
|
|
3817
3817
|
stage: "context_overflow_retry",
|
|
3818
3818
|
at: "launch",
|
|
3819
3819
|
beforeTokens: a,
|
|
3820
3820
|
afterTokens: s,
|
|
3821
3821
|
window: P.contextWindow
|
|
3822
|
-
}), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`),
|
|
3822
|
+
}), console.warn(`[page-agent-sdk] 上下文超限(启动)→ 激进 trim 重试:${a} → ${s} tokens`), G({
|
|
3823
3823
|
...e,
|
|
3824
3824
|
messages: o
|
|
3825
3825
|
}, t, n, i);
|
|
@@ -3871,13 +3871,13 @@ function es(e) {
|
|
|
3871
3871
|
};
|
|
3872
3872
|
if (Xi(a) && l === null && u === "" && !e._ctxRetry) {
|
|
3873
3873
|
e._ctxRetry = !0;
|
|
3874
|
-
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o =
|
|
3874
|
+
let r = (e) => y(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + r(t), 0), o = xe(e.messages, Math.round(P.contextWindow * .3)), s = o.reduce((e, t) => e + r(t), 0);
|
|
3875
3875
|
return z("error", {
|
|
3876
3876
|
stage: "context_overflow_retry",
|
|
3877
3877
|
beforeTokens: a,
|
|
3878
3878
|
afterTokens: s,
|
|
3879
3879
|
window: P.contextWindow
|
|
3880
|
-
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${P.contextWindow})`),
|
|
3880
|
+
}), console.warn(`[page-agent-sdk] 上下文超限 → 激进 trim 重试:${a} → ${s} tokens(窗口 ${P.contextWindow})`), G({
|
|
3881
3881
|
...e,
|
|
3882
3882
|
messages: o
|
|
3883
3883
|
}, t, n, i);
|
|
@@ -3914,7 +3914,7 @@ function es(e) {
|
|
|
3914
3914
|
aborted: !0
|
|
3915
3915
|
};
|
|
3916
3916
|
}
|
|
3917
|
-
return
|
|
3917
|
+
return G(e, t, n, i);
|
|
3918
3918
|
}
|
|
3919
3919
|
throw $i(a) ? (de += 1, z("error", {
|
|
3920
3920
|
stage: "model_unavailable",
|
|
@@ -3931,7 +3931,7 @@ function es(e) {
|
|
|
3931
3931
|
if (!e._emptyRetry) return e._emptyRetry = !0, z("error", {
|
|
3932
3932
|
stage: "empty_llm_response_retry",
|
|
3933
3933
|
hint: "流正常结束但零 chunk(网关 200+错误体形态),自动重试 1 次"
|
|
3934
|
-
}),
|
|
3934
|
+
}), G(e, t, n, i);
|
|
3935
3935
|
throw z("error", {
|
|
3936
3936
|
stage: "empty_llm_response",
|
|
3937
3937
|
retried: !0,
|
|
@@ -3945,10 +3945,10 @@ function es(e) {
|
|
|
3945
3945
|
content: u
|
|
3946
3946
|
};
|
|
3947
3947
|
}
|
|
3948
|
-
async function
|
|
3949
|
-
let t =
|
|
3948
|
+
async function ye(e) {
|
|
3949
|
+
let t = V.find((t) => t.name === e.name);
|
|
3950
3950
|
if (!t) {
|
|
3951
|
-
let t =
|
|
3951
|
+
let t = V.map((e) => e.name).filter((e) => !e.startsWith("__"));
|
|
3952
3952
|
return {
|
|
3953
3953
|
content: `工具 "${e.name}" 不存在(当前上下文可用工具:${t.join(", ")})`,
|
|
3954
3954
|
status: "error"
|
|
@@ -3974,7 +3974,7 @@ function es(e) {
|
|
|
3974
3974
|
throw t;
|
|
3975
3975
|
}
|
|
3976
3976
|
else i = await t.invoke(e.args, { configurable: n });
|
|
3977
|
-
let a = typeof i == "string" ? i : JSON.stringify(i), o =
|
|
3977
|
+
let a = typeof i == "string" ? i : JSON.stringify(i), o = V.some((e) => e.name === "vfs_read");
|
|
3978
3978
|
return a = ji(a, {
|
|
3979
3979
|
files: e.state.files,
|
|
3980
3980
|
vfsAvailable: !!e.state.files && o,
|
|
@@ -3992,15 +3992,15 @@ function es(e) {
|
|
|
3992
3992
|
};
|
|
3993
3993
|
}
|
|
3994
3994
|
}
|
|
3995
|
-
function
|
|
3995
|
+
function be(e) {
|
|
3996
3996
|
return e instanceof i ? "human" : e instanceof r ? "ai" : e instanceof a ? "system" : e instanceof o ? "tool" : "unknown";
|
|
3997
3997
|
}
|
|
3998
|
-
function
|
|
3998
|
+
function xe(e, t) {
|
|
3999
3999
|
return Yo(e, t);
|
|
4000
4000
|
}
|
|
4001
|
-
function
|
|
4001
|
+
function Se(e) {
|
|
4002
4002
|
return !oe && !A ? [] : e.map((e) => {
|
|
4003
|
-
let t =
|
|
4003
|
+
let t = be(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
4004
4004
|
r && (n.content = r.length > Go ? r.slice(0, Go) + `…(截断 ${r.length - Go} 字符)` : r);
|
|
4005
4005
|
let i = e.tool_calls;
|
|
4006
4006
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
@@ -4015,21 +4015,21 @@ function es(e) {
|
|
|
4015
4015
|
return a && (n.tool_call_id = a), n;
|
|
4016
4016
|
});
|
|
4017
4017
|
}
|
|
4018
|
-
async function
|
|
4019
|
-
|
|
4018
|
+
async function K(t, n, r) {
|
|
4019
|
+
U = Ri(), e.__pgIsSubagent && (U.__pgIsSubagent = !0), U.messages = t, U = await Ao(h, U);
|
|
4020
4020
|
try {
|
|
4021
4021
|
let s = t;
|
|
4022
4022
|
for (let e of h) if (e.compressInput) {
|
|
4023
4023
|
let t = await e.compressInput(s);
|
|
4024
|
-
s = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (
|
|
4025
|
-
...
|
|
4024
|
+
s = Array.isArray(t) ? t : t.messages, t && !Array.isArray(t) && t.stats && (U = {
|
|
4025
|
+
...U,
|
|
4026
4026
|
lastCompression: t.stats
|
|
4027
4027
|
});
|
|
4028
4028
|
}
|
|
4029
4029
|
{
|
|
4030
|
-
let e = y(p || "你是一个智能助手。"), t = Math.max(2e3, Math.round(P.contextWindow *
|
|
4030
|
+
let e = y(p || "你是一个智能助手。"), t = Math.max(2e3, Math.round(P.contextWindow * he));
|
|
4031
4031
|
if (e > t) {
|
|
4032
|
-
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${P.contextWindow} 的 ${
|
|
4032
|
+
let r = `[page-agent-sdk] systemPrompt 本身(${e} tokens)超过系统段预算(${t} tokens,窗口 ${P.contextWindow} 的 ${he * 100}%);请缩减 systemPrompt 或换更大窗口模型`;
|
|
4033
4033
|
return console.error(r), n({
|
|
4034
4034
|
type: "error",
|
|
4035
4035
|
message: r,
|
|
@@ -4041,13 +4041,13 @@ function es(e) {
|
|
|
4041
4041
|
}), "";
|
|
4042
4042
|
}
|
|
4043
4043
|
}
|
|
4044
|
-
let c =
|
|
4044
|
+
let c = _e(s);
|
|
4045
4045
|
z("context", {
|
|
4046
|
-
model:
|
|
4047
|
-
tools:
|
|
4046
|
+
model: pe(),
|
|
4047
|
+
tools: V.map((e) => e.name),
|
|
4048
4048
|
middleware: h.map((e) => e.name)
|
|
4049
4049
|
});
|
|
4050
|
-
let l = Fo(h, (e) =>
|
|
4050
|
+
let l = Fo(h, (e) => G(e, n, r)), u = Io(h, ye), d = {
|
|
4051
4051
|
rounds: 0,
|
|
4052
4052
|
maxToolRounds: N,
|
|
4053
4053
|
invokeUsage: {
|
|
@@ -4058,16 +4058,16 @@ function es(e) {
|
|
|
4058
4058
|
writeFailures: {},
|
|
4059
4059
|
budgetHinted: !1
|
|
4060
4060
|
};
|
|
4061
|
-
|
|
4061
|
+
U.loopProgress = d;
|
|
4062
4062
|
let f = {
|
|
4063
4063
|
counts: {},
|
|
4064
4064
|
writePaths: [],
|
|
4065
4065
|
failures: 0
|
|
4066
|
-
}, m = xo(), g = new Map((
|
|
4066
|
+
}, m = xo(), g = new Map((U.todos ?? []).map((e) => [e.id, {
|
|
4067
4067
|
status: e.status,
|
|
4068
4068
|
content: e.content
|
|
4069
4069
|
}])), v = /* @__PURE__ */ new Map(), b = 0, x = (e) => {
|
|
4070
|
-
let t =
|
|
4070
|
+
let t = V.find((t) => t.name === e);
|
|
4071
4071
|
return t && "writeCapable" in t ? typeof t.writeCapable == "function" || t.writeCapable === !0 : Qo.has(e);
|
|
4072
4072
|
}, S = 0, C = 0, w = Xo(N, _), T = null, E = 0, ee = !1, D = !1;
|
|
4073
4073
|
for (; (S < N || D) && C < w && (C++, !r?.aborted);) {
|
|
@@ -4095,18 +4095,18 @@ function es(e) {
|
|
|
4095
4095
|
n({
|
|
4096
4096
|
type: "round_start",
|
|
4097
4097
|
round: C
|
|
4098
|
-
}),
|
|
4098
|
+
}), U = jo(h, {
|
|
4099
4099
|
messages: c,
|
|
4100
|
-
state:
|
|
4101
|
-
}), c =
|
|
4100
|
+
state: U
|
|
4101
|
+
}), c = ve(c, Zo(S, N, e.hasSubagent)), c = xe(c, Math.round(P.contextWindow * .6)), z("llm_request", {
|
|
4102
4102
|
round: S + 1,
|
|
4103
|
-
model:
|
|
4104
|
-
tools:
|
|
4105
|
-
messages:
|
|
4103
|
+
model: pe(),
|
|
4104
|
+
tools: V.map((e) => e.name),
|
|
4105
|
+
messages: Se(c)
|
|
4106
4106
|
});
|
|
4107
4107
|
let t = await l({
|
|
4108
4108
|
messages: c,
|
|
4109
|
-
state:
|
|
4109
|
+
state: U
|
|
4110
4110
|
});
|
|
4111
4111
|
c.push(t.message);
|
|
4112
4112
|
let a = ie(t.message);
|
|
@@ -4115,7 +4115,7 @@ function es(e) {
|
|
|
4115
4115
|
content: t.content,
|
|
4116
4116
|
toolCalls: t.toolCalls,
|
|
4117
4117
|
...a ? { usage: a } : {}
|
|
4118
|
-
}), a && (d.invokeUsage.prompt_tokens += a.prompt_tokens ?? 0, d.invokeUsage.completion_tokens += a.completion_tokens ?? 0, d.invokeUsage.total_tokens += a.total_tokens ?? 0),
|
|
4118
|
+
}), a && (d.invokeUsage.prompt_tokens += a.prompt_tokens ?? 0, d.invokeUsage.completion_tokens += a.completion_tokens ?? 0, d.invokeUsage.total_tokens += a.total_tokens ?? 0), U = Mo(h, t, U), t.aborted) return n({
|
|
4119
4119
|
type: "done",
|
|
4120
4120
|
content: t.content
|
|
4121
4121
|
}), t.content;
|
|
@@ -4127,7 +4127,7 @@ function es(e) {
|
|
|
4127
4127
|
stage: "completion_truncated_retry",
|
|
4128
4128
|
completionTokens: r?.completion_tokens,
|
|
4129
4129
|
stopReason: n ?? null,
|
|
4130
|
-
maxTokens:
|
|
4130
|
+
maxTokens: H?.maxTokens ?? null,
|
|
4131
4131
|
hint: "空输出且 completion 达上限,疑似 max_tokens 截断;回灌分步写入指引"
|
|
4132
4132
|
}), c.push(new i("⚠️ 你上一轮输出为空(疑似被 max_tokens 截断:单次输出过长,常见于把完整大段代码塞进一次工具调用参数)。必须改用分块输出,不要一次性输出完整大段内容:① 先写小体积骨架 —— 大 code 场景先 write 组件、code 字段只含开头一小段(≤800 字符);② 用增量追加逐块补全 —— write({ patch:{ op:\"append\", jsonPath:\"<该组件 code 的路径>\", value:\"<后续代码块,每段 ≤1500 字符>\" } })(append 对字符串是尾接,可连续多次直至完整);③ 已写入部分勿在后续调用重传全文。其他大内容同理:先骨架后增量。"));
|
|
4133
4133
|
continue;
|
|
@@ -4172,8 +4172,8 @@ function es(e) {
|
|
|
4172
4172
|
garbled: e,
|
|
4173
4173
|
rounds: S,
|
|
4174
4174
|
finalContent: t.content,
|
|
4175
|
-
todos:
|
|
4176
|
-
isSubagent: !!
|
|
4175
|
+
todos: U.todos,
|
|
4176
|
+
isSubagent: !!U.__pgIsSubagent,
|
|
4177
4177
|
turnUsage: f,
|
|
4178
4178
|
isWriteToolByName: x,
|
|
4179
4179
|
messages: c,
|
|
@@ -4199,17 +4199,17 @@ function es(e) {
|
|
|
4199
4199
|
severity: "observable",
|
|
4200
4200
|
code: r.obs.code,
|
|
4201
4201
|
context: r.obs.context
|
|
4202
|
-
})), !e && ne > 0 &&
|
|
4202
|
+
})), !e && ne > 0 && U.verifyAttempts < ne) {
|
|
4203
4203
|
let e = await Po(h, {
|
|
4204
4204
|
messages: c,
|
|
4205
|
-
state:
|
|
4205
|
+
state: U,
|
|
4206
4206
|
response: t,
|
|
4207
4207
|
log: (e, t) => z(e, t)
|
|
4208
4208
|
});
|
|
4209
4209
|
if (e) {
|
|
4210
|
-
T = t.content,
|
|
4210
|
+
T = t.content, U.verifyAttempts += 1, c.push(new i(`⚠️ 验证未通过,请修正:${e}`)), z("middleware", {
|
|
4211
4211
|
stage: "verify_retry",
|
|
4212
|
-
attempt:
|
|
4212
|
+
attempt: U.verifyAttempts,
|
|
4213
4213
|
feedback: e
|
|
4214
4214
|
});
|
|
4215
4215
|
continue;
|
|
@@ -4237,7 +4237,7 @@ function es(e) {
|
|
|
4237
4237
|
id: t,
|
|
4238
4238
|
name: e.name,
|
|
4239
4239
|
args: e.args,
|
|
4240
|
-
state:
|
|
4240
|
+
state: U,
|
|
4241
4241
|
signal: r,
|
|
4242
4242
|
emit: n,
|
|
4243
4243
|
logSink: B
|
|
@@ -4322,7 +4322,7 @@ function es(e) {
|
|
|
4322
4322
|
let t = _[e];
|
|
4323
4323
|
if (!t) continue;
|
|
4324
4324
|
let n = p[e].call.name;
|
|
4325
|
-
if (f.counts[n] = (f.counts[n] ?? 0) + 1, t.status === "error" && (f.failures += 1), La.test(n) && String(t.content || "").startsWith("ERROR:") && (f.rejectedDelegations = f.rejectedDelegations ?? {}, f.rejectedDelegations[n] = (f.rejectedDelegations[n] ?? 0) + 1), so(
|
|
4325
|
+
if (f.counts[n] = (f.counts[n] ?? 0) + 1, t.status === "error" && (f.failures += 1), La.test(n) && String(t.content || "").startsWith("ERROR:") && (f.rejectedDelegations = f.rejectedDelegations ?? {}, f.rejectedDelegations[n] = (f.rejectedDelegations[n] ?? 0) + 1), so(V.find((e) => e.name === n), p[e].call.args, t)) {
|
|
4326
4326
|
let t = $o(p[e].call.args);
|
|
4327
4327
|
f.writePaths.push(t || "(整体)"), y.push({
|
|
4328
4328
|
name: n,
|
|
@@ -4375,7 +4375,7 @@ function es(e) {
|
|
|
4375
4375
|
maxIterations: w
|
|
4376
4376
|
}
|
|
4377
4377
|
});
|
|
4378
|
-
let k = Do(
|
|
4378
|
+
let k = Do(U.todos ?? [], g, R);
|
|
4379
4379
|
if (k.length) {
|
|
4380
4380
|
let e = k.map((e) => ({
|
|
4381
4381
|
id: e.id,
|
|
@@ -4400,19 +4400,19 @@ function es(e) {
|
|
|
4400
4400
|
}), e;
|
|
4401
4401
|
}
|
|
4402
4402
|
let A = c[c.length - 1];
|
|
4403
|
-
if (A &&
|
|
4404
|
-
let e = c[0] &&
|
|
4403
|
+
if (A && be(A) === "tool") {
|
|
4404
|
+
let e = c[0] && be(c[0]) === "system" ? c.slice(1) : c.slice(), t = [new a(W() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
4405
4405
|
z("llm_request", {
|
|
4406
4406
|
round: "wrap_up",
|
|
4407
|
-
model:
|
|
4407
|
+
model: pe(),
|
|
4408
4408
|
tools: [],
|
|
4409
|
-
messages:
|
|
4409
|
+
messages: Se(t)
|
|
4410
4410
|
});
|
|
4411
|
-
let i = await Fo(h, (e) =>
|
|
4411
|
+
let i = await Fo(h, (e) => G(e, n, r, H))({
|
|
4412
4412
|
messages: t,
|
|
4413
|
-
state:
|
|
4413
|
+
state: U
|
|
4414
4414
|
});
|
|
4415
|
-
if (
|
|
4415
|
+
if (U = Mo(h, i, U), z("llm_response", {
|
|
4416
4416
|
round: "wrap_up",
|
|
4417
4417
|
content: i.content
|
|
4418
4418
|
}), i.aborted) return n({
|
|
@@ -4447,31 +4447,31 @@ function es(e) {
|
|
|
4447
4447
|
}), j + te;
|
|
4448
4448
|
} finally {
|
|
4449
4449
|
try {
|
|
4450
|
-
await No(h,
|
|
4450
|
+
await No(h, U);
|
|
4451
4451
|
} catch (e) {
|
|
4452
4452
|
let t = ui(e, "observable");
|
|
4453
4453
|
console.warn("[Agent] afterAgent 清理出错(observable,已忽略):", t.message);
|
|
4454
4454
|
}
|
|
4455
4455
|
}
|
|
4456
4456
|
}
|
|
4457
|
-
async function
|
|
4457
|
+
async function Ce(e, t, n) {
|
|
4458
4458
|
let r = "";
|
|
4459
|
-
return await
|
|
4459
|
+
return await K(e, (e) => {
|
|
4460
4460
|
e.type === "done" && (r = e.content), n?.(e);
|
|
4461
4461
|
}, t), r;
|
|
4462
4462
|
}
|
|
4463
|
-
function
|
|
4464
|
-
|
|
4463
|
+
function q(e) {
|
|
4464
|
+
V = [...h.flatMap((e) => e.tools || []), ...e], me();
|
|
4465
4465
|
}
|
|
4466
|
-
function
|
|
4467
|
-
|
|
4466
|
+
function we(e) {
|
|
4467
|
+
H = e, me(), j?.(e);
|
|
4468
4468
|
}
|
|
4469
4469
|
return {
|
|
4470
|
-
invoke:
|
|
4471
|
-
stream:
|
|
4472
|
-
getState: () =>
|
|
4470
|
+
invoke: Ce,
|
|
4471
|
+
stream: K,
|
|
4472
|
+
getState: () => U,
|
|
4473
4473
|
get allTools() {
|
|
4474
|
-
return
|
|
4474
|
+
return V;
|
|
4475
4475
|
},
|
|
4476
4476
|
getStaleReadsInvalidated: () => L,
|
|
4477
4477
|
getLlmRetries: () => ue,
|
|
@@ -4479,11 +4479,11 @@ function es(e) {
|
|
|
4479
4479
|
resetSessionCounters: () => {
|
|
4480
4480
|
L = 0, ue = 0, de = 0;
|
|
4481
4481
|
},
|
|
4482
|
-
setTools:
|
|
4483
|
-
setLlm:
|
|
4482
|
+
setTools: q,
|
|
4483
|
+
setLlm: we,
|
|
4484
4484
|
setModelCaps: ce,
|
|
4485
4485
|
debugLogs: le,
|
|
4486
|
-
getEffectiveSystemPrompt: () =>
|
|
4486
|
+
getEffectiveSystemPrompt: () => W()
|
|
4487
4487
|
};
|
|
4488
4488
|
}
|
|
4489
4489
|
//#endregion
|
|
@@ -9727,7 +9727,7 @@ function kd(e, n = {}) {
|
|
|
9727
9727
|
snapshotId: t.number().int().optional().describe("对比的快照序号;不传则最近一次"),
|
|
9728
9728
|
against: t.unknown().optional().describe("对比的一段 JSON 值(与 snapshotId 互斥;传则忽略快照)")
|
|
9729
9729
|
})
|
|
9730
|
-
}),
|
|
9730
|
+
}), V = [];
|
|
9731
9731
|
if (n.vfsStore) {
|
|
9732
9732
|
let e = n.vfsStore, r = (e) => `drafts/${e}.json`, i = s(({ draftId: t, chunk: n, mode: i }) => {
|
|
9733
9733
|
let a = r(t), o = e.files[a], s = i === "append" && o, c = s ? o.content + n : n;
|
|
@@ -9795,9 +9795,9 @@ function kd(e, n = {}) {
|
|
|
9795
9795
|
description: "把 draft_write 累积的草稿合并 + JSON.parse + 乐观锁 + schema 校验,原子提交主数据(任一步失败不写,草稿保留可修后重试;成功清草稿 + 自动快照可回退)。仅大 JSON 从零生成用;小改用 write。",
|
|
9796
9796
|
schema: t.object({ draftId: t.string().describe("要提交的草稿标识(对应 draft_write 的 draftId)") })
|
|
9797
9797
|
});
|
|
9798
|
-
F(l),
|
|
9798
|
+
F(l), V.push(i, l);
|
|
9799
9799
|
}
|
|
9800
|
-
let
|
|
9800
|
+
let H = [];
|
|
9801
9801
|
if (e.resources?.length && p) {
|
|
9802
9802
|
let e = s(async ({ path: e, handle: t }) => {
|
|
9803
9803
|
let n = e;
|
|
@@ -9914,9 +9914,9 @@ function kd(e, n = {}) {
|
|
|
9914
9914
|
handle: t.string().optional().describe("占位符句柄(与 path 二选一)")
|
|
9915
9915
|
})
|
|
9916
9916
|
});
|
|
9917
|
-
F(i),
|
|
9917
|
+
F(i), H.push(e, n, r, i);
|
|
9918
9918
|
}
|
|
9919
|
-
let
|
|
9919
|
+
let fe = [
|
|
9920
9920
|
I,
|
|
9921
9921
|
ce,
|
|
9922
9922
|
le,
|
|
@@ -9926,10 +9926,10 @@ function kd(e, n = {}) {
|
|
|
9926
9926
|
R,
|
|
9927
9927
|
z,
|
|
9928
9928
|
B,
|
|
9929
|
-
...
|
|
9930
|
-
...
|
|
9929
|
+
...V,
|
|
9930
|
+
...H
|
|
9931
9931
|
];
|
|
9932
|
-
function
|
|
9932
|
+
function pe(e) {
|
|
9933
9933
|
let t = e, n = (e) => {
|
|
9934
9934
|
if (e === void 0) return "undefined";
|
|
9935
9935
|
let t = $(e, 200);
|
|
@@ -10023,23 +10023,23 @@ function kd(e, n = {}) {
|
|
|
10023
10023
|
}]
|
|
10024
10024
|
};
|
|
10025
10025
|
}
|
|
10026
|
-
Object.defineProperty(
|
|
10026
|
+
Object.defineProperty(fe, "controller", {
|
|
10027
10027
|
value: oe,
|
|
10028
10028
|
enumerable: !1,
|
|
10029
10029
|
configurable: !1,
|
|
10030
10030
|
writable: !1
|
|
10031
|
-
}), Object.defineProperty(
|
|
10032
|
-
value:
|
|
10031
|
+
}), Object.defineProperty(fe, "previewWrite", {
|
|
10032
|
+
value: pe,
|
|
10033
10033
|
enumerable: !1,
|
|
10034
10034
|
configurable: !1,
|
|
10035
10035
|
writable: !1
|
|
10036
10036
|
});
|
|
10037
|
-
for (let e of
|
|
10037
|
+
for (let e of fe) Object.defineProperty(e, "__dataOpsScoped", {
|
|
10038
10038
|
value: !0,
|
|
10039
10039
|
enumerable: !1,
|
|
10040
10040
|
configurable: !1
|
|
10041
10041
|
});
|
|
10042
|
-
return
|
|
10042
|
+
return fe;
|
|
10043
10043
|
}
|
|
10044
10044
|
//#endregion
|
|
10045
10045
|
//#region src/core/tools/htmlValidate.ts
|
|
@@ -11273,7 +11273,8 @@ function Mf(e = "components", t = "code") {
|
|
|
11273
11273
|
getContent: () => jf(e, t)
|
|
11274
11274
|
};
|
|
11275
11275
|
}
|
|
11276
|
-
|
|
11276
|
+
var Nf = Mf();
|
|
11277
|
+
function Pf(e = {}) {
|
|
11277
11278
|
let t = e.vfsPrefix ?? "html/";
|
|
11278
11279
|
return ({ state: e }) => {
|
|
11279
11280
|
let n = e.files;
|
|
@@ -11290,7 +11291,7 @@ function Nf(e = {}) {
|
|
|
11290
11291
|
} : { ok: !0 };
|
|
11291
11292
|
};
|
|
11292
11293
|
}
|
|
11293
|
-
function
|
|
11294
|
+
function Ff(e) {
|
|
11294
11295
|
let n, r, i = {
|
|
11295
11296
|
name: "html-validate-tools",
|
|
11296
11297
|
beforeAgent: (e) => {
|
|
@@ -11343,7 +11344,7 @@ function Pf(e) {
|
|
|
11343
11344
|
r = e;
|
|
11344
11345
|
}, i;
|
|
11345
11346
|
}
|
|
11346
|
-
function
|
|
11347
|
+
function If() {
|
|
11347
11348
|
return ({ state: e }) => {
|
|
11348
11349
|
let t = e.__pgFinalText?.text ?? "";
|
|
11349
11350
|
return !t || Bd(t).length ? { ok: !0 } : {
|
|
@@ -11352,8 +11353,8 @@ function Ff() {
|
|
|
11352
11353
|
};
|
|
11353
11354
|
};
|
|
11354
11355
|
}
|
|
11355
|
-
var
|
|
11356
|
-
function
|
|
11356
|
+
var Lf = 2;
|
|
11357
|
+
function Rf(e = {}) {
|
|
11357
11358
|
let { writablePaths: t, codeVfsPrefix: n = "html/", id: r = "html", description: i, planning: a = !0, summarization: o = !0, maxToolRounds: s = 12, temperature: c = .4, skills: l, extraTools: u, formatCheck: d = !0, codeField: f = "code", orchestratorPrompt: p = !0, craftNotes: m = !0, llm: h, thinkingMode: g, allowedTools: _, design: v } = e;
|
|
11358
11359
|
if (t !== void 0 && !Array.isArray(t)) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 须为字符串数组(代码组件 data 区,如 [\"components\"])/ 省略以从 schema 自动推断");
|
|
11359
11360
|
let y = [];
|
|
@@ -11364,8 +11365,8 @@ function Lf(e = {}) {
|
|
|
11364
11365
|
writablePaths: t ?? []
|
|
11365
11366
|
}) : void 0;
|
|
11366
11367
|
if (d) {
|
|
11367
|
-
y.push(
|
|
11368
|
-
let e =
|
|
11368
|
+
y.push(Ff(n));
|
|
11369
|
+
let e = Pf({ vfsPrefix: n }), t = b ? kf(e, b.check) : e, r = m ? If() : void 0, i = ru({ check: r ? nu(t, r) : t });
|
|
11369
11370
|
b && (i._setGetController = b.setGetController), y.push(i);
|
|
11370
11371
|
}
|
|
11371
11372
|
let x = u ?? [], S = t?.[0] ?? "components", C = l === void 0, w = v === !1 ? null : v === void 0 || v === !0 ? yf() : v, T = (e) => [...C ? [Mf(e, f)] : l, ...w ? [w] : []], E = {
|
|
@@ -11385,7 +11386,7 @@ function Lf(e = {}) {
|
|
|
11385
11386
|
],
|
|
11386
11387
|
middleware: y.length ? y : void 0,
|
|
11387
11388
|
summarization: o === !1 ? void 0 : o,
|
|
11388
|
-
maxVerifyAttempts: d ?
|
|
11389
|
+
maxVerifyAttempts: d ? Lf : void 0,
|
|
11389
11390
|
temperature: c,
|
|
11390
11391
|
skills: T(S),
|
|
11391
11392
|
maxToolRounds: s,
|
|
@@ -11405,7 +11406,7 @@ function Lf(e = {}) {
|
|
|
11405
11406
|
}
|
|
11406
11407
|
//#endregion
|
|
11407
11408
|
//#region src/core/sdk/defineTool.ts
|
|
11408
|
-
function
|
|
11409
|
+
function zf(e) {
|
|
11409
11410
|
let t = s(async (t) => {
|
|
11410
11411
|
let n = await e.handler(t);
|
|
11411
11412
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -11418,7 +11419,7 @@ function Rf(e) {
|
|
|
11418
11419
|
}
|
|
11419
11420
|
//#endregion
|
|
11420
11421
|
//#region src/core/sdk/inspectContextTool.ts
|
|
11421
|
-
var
|
|
11422
|
+
var Bf = t.object({
|
|
11422
11423
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
11423
11424
|
role: t.enum([
|
|
11424
11425
|
"user",
|
|
@@ -11428,11 +11429,11 @@ var zf = t.object({
|
|
|
11428
11429
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
11429
11430
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
11430
11431
|
});
|
|
11431
|
-
function
|
|
11432
|
-
return
|
|
11432
|
+
function Vf(e) {
|
|
11433
|
+
return zf({
|
|
11433
11434
|
name: "inspect_context",
|
|
11434
11435
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
11435
|
-
schema:
|
|
11436
|
+
schema: Bf,
|
|
11436
11437
|
handler: (t) => {
|
|
11437
11438
|
let n = Fc(e.getMessages()), r = n.length > 50 ? n.slice(n.length - 50) : n, i = (t.limit && r.length > t.limit ? r.slice(r.length - t.limit) : r).map((e) => {
|
|
11438
11439
|
let n = Jc(e), r = Lc(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = Ic(typeof i.content == "string" ? i.content : "", 60);
|
|
@@ -11455,7 +11456,7 @@ function Bf(e) {
|
|
|
11455
11456
|
}
|
|
11456
11457
|
//#endregion
|
|
11457
11458
|
//#region src/core/sdk/compressDecision.ts
|
|
11458
|
-
var
|
|
11459
|
+
var Hf = t.object({
|
|
11459
11460
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
11460
11461
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
11461
11462
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -11465,27 +11466,27 @@ var Vf = t.object({
|
|
|
11465
11466
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
11466
11467
|
//#endregion
|
|
11467
11468
|
//#region src/core/sdk/llmResolver.ts
|
|
11468
|
-
function
|
|
11469
|
+
function Uf(e) {
|
|
11469
11470
|
let t = e.find((e) => e.role === "user");
|
|
11470
11471
|
if (!t) return;
|
|
11471
11472
|
let n = t.content, r = (typeof n == "string" ? n : Array.isArray(n) ? n.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(n ?? "")).trim().replace(/[\n\r]+/g, " ");
|
|
11472
11473
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
11473
11474
|
}
|
|
11474
|
-
function
|
|
11475
|
+
function Wf(e) {
|
|
11475
11476
|
if (!e) return e;
|
|
11476
11477
|
let t = e;
|
|
11477
11478
|
return t.__pgAnthropicShaped || t._llmType?.() !== "chat-anthropic" ? e : (t.__pgAnthropicShaped = !0, D(e));
|
|
11478
11479
|
}
|
|
11479
|
-
function
|
|
11480
|
+
function Gf(e) {
|
|
11480
11481
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
11481
11482
|
}
|
|
11482
|
-
function
|
|
11483
|
-
if (!
|
|
11483
|
+
function Kf(e) {
|
|
11484
|
+
if (!Gf(e)) return;
|
|
11484
11485
|
let t = e.caller?.maxRetries;
|
|
11485
11486
|
return typeof t == "number" && t >= 0 ? t : void 0;
|
|
11486
11487
|
}
|
|
11487
|
-
function
|
|
11488
|
-
let n =
|
|
11488
|
+
function qf(e, t = {}) {
|
|
11489
|
+
let n = Kf(e);
|
|
11489
11490
|
if (n === void 0 || n === 0) return n;
|
|
11490
11491
|
let r = `预构造 LLM 实例内层 maxRetries=${n}(LangChain 缺省 6)与 SDK 外层重试叠乘:瞬时错误会被不可见放大;排障时先看实例内层。实例不可改,建议构造 ChatOpenAI/ChatAnthropic 时显式传 maxRetries:0(SDK 构造路径内层恒 0 无此问题)`;
|
|
11491
11492
|
return console.warn(`[page-agent-sdk][llm] ${r}`), t.emit?.({
|
|
@@ -11496,14 +11497,14 @@ function Kf(e, t = {}) {
|
|
|
11496
11497
|
context: { maxRetries: n }
|
|
11497
11498
|
}), n;
|
|
11498
11499
|
}
|
|
11499
|
-
function
|
|
11500
|
+
function Jf(e) {
|
|
11500
11501
|
let t = e.content;
|
|
11501
11502
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
11502
11503
|
}
|
|
11503
|
-
function
|
|
11504
|
+
function Yf(e) {
|
|
11504
11505
|
let t = e.summaryLlm ?? e.llm;
|
|
11505
11506
|
if (!t) return;
|
|
11506
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 2048, o = e.summaryTimeoutMs ?? 15e3, s =
|
|
11507
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 2048, o = e.summaryTimeoutMs ?? 15e3, s = Gf(t) ? Wf(t) : null, c = Gf(t) ? null : t;
|
|
11507
11508
|
if (c && !c.apiKey) {
|
|
11508
11509
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
11509
11510
|
return;
|
|
@@ -11516,16 +11517,16 @@ function Jf(e) {
|
|
|
11516
11517
|
temperature: n,
|
|
11517
11518
|
maxTokens: r,
|
|
11518
11519
|
thinkingFallback: "simple"
|
|
11519
|
-
})),
|
|
11520
|
+
})), Jf(await l.invoke([new a("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new i(e)], { signal: t.signal })).trim();
|
|
11520
11521
|
} finally {
|
|
11521
11522
|
clearTimeout(s);
|
|
11522
11523
|
}
|
|
11523
11524
|
};
|
|
11524
11525
|
}
|
|
11525
|
-
function
|
|
11526
|
+
function Xf(e) {
|
|
11526
11527
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
11527
11528
|
if (!t) return;
|
|
11528
|
-
let n =
|
|
11529
|
+
let n = Gf(t) ? Wf(t) : null, r = Gf(t) ? null : t;
|
|
11529
11530
|
if (r && !r.apiKey) return;
|
|
11530
11531
|
let o = n;
|
|
11531
11532
|
return async (t) => {
|
|
@@ -11537,7 +11538,7 @@ function Yf(e) {
|
|
|
11537
11538
|
thinkingFallback: "simple"
|
|
11538
11539
|
}));
|
|
11539
11540
|
let t = await o.invoke([new a(e.i18n?.locale === "en-US" ? "Generate a short English title (max 10 words) summarizing the conversation below. Output the title text only, no quotes or punctuation." : "根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new i(n)], { signal: s.signal }), c = e.i18n?.locale === "en-US" ? 60 : 20;
|
|
11540
|
-
return
|
|
11541
|
+
return Jf(t).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, c);
|
|
11541
11542
|
} catch {
|
|
11542
11543
|
return "";
|
|
11543
11544
|
} finally {
|
|
@@ -11545,10 +11546,10 @@ function Yf(e) {
|
|
|
11545
11546
|
}
|
|
11546
11547
|
};
|
|
11547
11548
|
}
|
|
11548
|
-
function
|
|
11549
|
+
function Zf() {
|
|
11549
11550
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
11550
11551
|
}
|
|
11551
|
-
function
|
|
11552
|
+
function Qf(e) {
|
|
11552
11553
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
11553
11554
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
11554
11555
|
try {
|
|
@@ -11557,21 +11558,21 @@ function Zf(e) {
|
|
|
11557
11558
|
return null;
|
|
11558
11559
|
}
|
|
11559
11560
|
}
|
|
11560
|
-
function
|
|
11561
|
+
function $f(e) {
|
|
11561
11562
|
if (!e) return null;
|
|
11562
|
-
let t =
|
|
11563
|
+
let t = Qf(e);
|
|
11563
11564
|
if (t == null) return null;
|
|
11564
|
-
let n =
|
|
11565
|
+
let n = Hf.safeParse(t);
|
|
11565
11566
|
return n.success ? n.data : null;
|
|
11566
11567
|
}
|
|
11567
|
-
async function
|
|
11568
|
+
async function ep(e, t, n, r) {
|
|
11568
11569
|
let i = [...n];
|
|
11569
11570
|
for (let n = 0; n < 3; n++) {
|
|
11570
11571
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
11571
|
-
if (!a.length) return
|
|
11572
|
+
if (!a.length) return Jf(n).trim();
|
|
11572
11573
|
i = [...i, n];
|
|
11573
11574
|
for (let e of a) {
|
|
11574
|
-
let n = e.id ??
|
|
11575
|
+
let n = e.id ?? Zf();
|
|
11575
11576
|
try {
|
|
11576
11577
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
11577
11578
|
i = [...i, new o({
|
|
@@ -11588,10 +11589,10 @@ async function $f(e, t, n, r) {
|
|
|
11588
11589
|
}
|
|
11589
11590
|
return "";
|
|
11590
11591
|
}
|
|
11591
|
-
function
|
|
11592
|
+
function tp(e) {
|
|
11592
11593
|
let t = e.summaryLlm ?? e.llm;
|
|
11593
11594
|
if (!t) return;
|
|
11594
|
-
let n =
|
|
11595
|
+
let n = Gf(t) ? Wf(t) : null, r = Gf(t) ? null : t;
|
|
11595
11596
|
if (r && !r.apiKey) return;
|
|
11596
11597
|
let o = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
11597
11598
|
return async (e) => {
|
|
@@ -11604,12 +11605,12 @@ function ep(e) {
|
|
|
11604
11605
|
}));
|
|
11605
11606
|
let n = c;
|
|
11606
11607
|
if (typeof n.bindTools != "function") return null;
|
|
11607
|
-
let o =
|
|
11608
|
+
let o = Vf({
|
|
11608
11609
|
getMessages: e.getMessages,
|
|
11609
11610
|
getSnapshot: e.getSnapshot,
|
|
11610
11611
|
contextWindow: e.contextWindow
|
|
11611
11612
|
}), l = n.bindTools([o]), u = e.triggerMode === "token" ? "token 模式:必填 windowRatio(0~1 保留窗口预算比例,如 0.4);keepRounds 可选" : "轮数模式:必填 keepRounds(保留最近几轮,如 6);windowRatio 可选", d = [new a(`你是对话历史压缩决策助手。当前触发模式 = ${e.triggerMode}(${e.triggerReason})。先调用 inspect_context 查看上下文构成,再输出压缩决策 JSON。${u}。仅输出 JSON,不要多余文字/markdown。schema:{keepRounds?(int 0-50), windowRatio?(0-1), summarize:{mode:"index"|"llm"}, recallTopK?(int 0-10), preserveTools?(string[]≤10), reason?(≤200字)}。keepRounds/windowRatio 至少填一个。`), new i(`触发原因:${e.triggerReason}\n上下文窗口:${e.contextWindow ?? "未知"} tokens\n阈值比例:${e.thresholdRatio ?? "未知"}\n\n请决策压缩策略(先 inspect_context 查看,再输出 JSON)。`)];
|
|
11612
|
-
return
|
|
11613
|
+
return $f(await ep(l, o, d, t.signal)) || $f(await ep(l, o, [...d, new i("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
11613
11614
|
} catch {
|
|
11614
11615
|
return null;
|
|
11615
11616
|
} finally {
|
|
@@ -11617,8 +11618,8 @@ function ep(e) {
|
|
|
11617
11618
|
}
|
|
11618
11619
|
};
|
|
11619
11620
|
}
|
|
11620
|
-
function
|
|
11621
|
-
let t = e.llm, n =
|
|
11621
|
+
function np(e) {
|
|
11622
|
+
let t = e.llm, n = Gf(e.llm) ? void 0 : e.llm;
|
|
11622
11623
|
return {
|
|
11623
11624
|
modelCaps: v({
|
|
11624
11625
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
@@ -11626,14 +11627,14 @@ function tp(e) {
|
|
|
11626
11627
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens,
|
|
11627
11628
|
vision: n?.vision ?? t?.vision
|
|
11628
11629
|
}),
|
|
11629
|
-
summaryLlmInvoke:
|
|
11630
|
-
titleLlmInvoke:
|
|
11631
|
-
compressDecisionInvoke:
|
|
11630
|
+
summaryLlmInvoke: Yf(e),
|
|
11631
|
+
titleLlmInvoke: Xf(e),
|
|
11632
|
+
compressDecisionInvoke: tp(e)
|
|
11632
11633
|
};
|
|
11633
11634
|
}
|
|
11634
11635
|
//#endregion
|
|
11635
11636
|
//#region src/core/sdk/conflictManager.ts
|
|
11636
|
-
function
|
|
11637
|
+
function rp(e, t, n) {
|
|
11637
11638
|
let r = /* @__PURE__ */ Ut(null), i = 0;
|
|
11638
11639
|
function a(a, o) {
|
|
11639
11640
|
let s = t?.() ?? "ask";
|
|
@@ -11700,7 +11701,7 @@ function np(e, t, n) {
|
|
|
11700
11701
|
}
|
|
11701
11702
|
//#endregion
|
|
11702
11703
|
//#region src/core/utils/id.ts
|
|
11703
|
-
function
|
|
11704
|
+
function ip() {
|
|
11704
11705
|
try {
|
|
11705
11706
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
11706
11707
|
} catch {}
|
|
@@ -11708,7 +11709,7 @@ function rp() {
|
|
|
11708
11709
|
}
|
|
11709
11710
|
//#endregion
|
|
11710
11711
|
//#region src/core/backends/storage.ts
|
|
11711
|
-
var
|
|
11712
|
+
var ap = "chat-sdk", op = 50 * 1024 * 1024, sp = 4 * 1024 * 1024, cp = 10 * 1024 * 1024, lp = .9, up = 500, dp = 5e3, fp = 300, pp = "__meta__", mp = "v:1", hp = [
|
|
11712
11713
|
"messages",
|
|
11713
11714
|
"vfs",
|
|
11714
11715
|
"todos",
|
|
@@ -11720,51 +11721,51 @@ var ip = "chat-sdk", ap = 50 * 1024 * 1024, op = 4 * 1024 * 1024, sp = 10 * 1024
|
|
|
11720
11721
|
"focus",
|
|
11721
11722
|
"planConfirmation"
|
|
11722
11723
|
];
|
|
11723
|
-
function hp(e) {
|
|
11724
|
-
return e === "local" || e === "session" ? op : ap;
|
|
11725
|
-
}
|
|
11726
11724
|
function gp(e) {
|
|
11725
|
+
return e === "local" || e === "session" ? sp : op;
|
|
11726
|
+
}
|
|
11727
|
+
function _p(e) {
|
|
11727
11728
|
if (typeof e != "object" || !e) return !1;
|
|
11728
11729
|
let t = e;
|
|
11729
11730
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
11730
11731
|
}
|
|
11731
|
-
function
|
|
11732
|
+
function vp(e, t, n, r) {
|
|
11732
11733
|
return [
|
|
11733
|
-
|
|
11734
|
+
mp,
|
|
11734
11735
|
e,
|
|
11735
11736
|
t,
|
|
11736
11737
|
n,
|
|
11737
11738
|
r
|
|
11738
11739
|
].join("::");
|
|
11739
11740
|
}
|
|
11740
|
-
function
|
|
11741
|
+
function yp(e, t, n) {
|
|
11741
11742
|
return [
|
|
11742
|
-
|
|
11743
|
+
mp,
|
|
11743
11744
|
e,
|
|
11744
11745
|
t,
|
|
11745
11746
|
n
|
|
11746
11747
|
].join("::") + "::";
|
|
11747
11748
|
}
|
|
11748
|
-
function
|
|
11749
|
+
function bp(e, t) {
|
|
11749
11750
|
return [
|
|
11750
|
-
|
|
11751
|
+
mp,
|
|
11751
11752
|
e,
|
|
11752
11753
|
t
|
|
11753
11754
|
].join("::") + "::";
|
|
11754
11755
|
}
|
|
11755
|
-
function
|
|
11756
|
-
return [
|
|
11756
|
+
function xp(e) {
|
|
11757
|
+
return [mp, e].join("::") + "::";
|
|
11757
11758
|
}
|
|
11758
|
-
var
|
|
11759
|
-
function
|
|
11760
|
-
|
|
11759
|
+
var Sp = null;
|
|
11760
|
+
function Cp(e) {
|
|
11761
|
+
Sp ||= new TextEncoder();
|
|
11761
11762
|
try {
|
|
11762
|
-
return
|
|
11763
|
+
return Sp.encode(JSON.stringify(e)).length;
|
|
11763
11764
|
} catch {
|
|
11764
11765
|
return 0;
|
|
11765
11766
|
}
|
|
11766
11767
|
}
|
|
11767
|
-
function
|
|
11768
|
+
function wp(e, t, n) {
|
|
11768
11769
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
11769
11770
|
if (r <= t) return [];
|
|
11770
11771
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -11774,7 +11775,7 @@ function Cp(e, t, n) {
|
|
|
11774
11775
|
}
|
|
11775
11776
|
return o;
|
|
11776
11777
|
}
|
|
11777
|
-
function
|
|
11778
|
+
function Tp() {
|
|
11778
11779
|
let e = /* @__PURE__ */ new Map();
|
|
11779
11780
|
return {
|
|
11780
11781
|
async get(t) {
|
|
@@ -11794,7 +11795,7 @@ function wp() {
|
|
|
11794
11795
|
}
|
|
11795
11796
|
};
|
|
11796
11797
|
}
|
|
11797
|
-
function
|
|
11798
|
+
function Ep(e) {
|
|
11798
11799
|
return new Promise((t, n) => {
|
|
11799
11800
|
if (typeof indexedDB > "u") {
|
|
11800
11801
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -11855,7 +11856,7 @@ function Tp(e) {
|
|
|
11855
11856
|
}, r.onerror = () => n(r.error);
|
|
11856
11857
|
});
|
|
11857
11858
|
}
|
|
11858
|
-
function
|
|
11859
|
+
function Dp(e) {
|
|
11859
11860
|
return {
|
|
11860
11861
|
async get(t) {
|
|
11861
11862
|
let n = e.getItem(t);
|
|
@@ -11900,24 +11901,24 @@ function Ep(e) {
|
|
|
11900
11901
|
}
|
|
11901
11902
|
};
|
|
11902
11903
|
}
|
|
11903
|
-
function
|
|
11904
|
+
function Op(e, t, n) {
|
|
11904
11905
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
11905
11906
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
11906
11907
|
}
|
|
11907
|
-
function
|
|
11908
|
-
return
|
|
11908
|
+
function kp(e = {}) {
|
|
11909
|
+
return jp(e, typeof e.backend == "object" && e.backend ? e.backend : void 0);
|
|
11909
11910
|
}
|
|
11910
|
-
function
|
|
11911
|
-
return
|
|
11911
|
+
function Ap(e, t) {
|
|
11912
|
+
return jp(e, t);
|
|
11912
11913
|
}
|
|
11913
|
-
function
|
|
11914
|
-
let n = e.dbName ??
|
|
11914
|
+
function jp(e = {}, t) {
|
|
11915
|
+
let n = e.dbName ?? ap, r = typeof e.backend == "string" ? e.backend ?? "indexed" : "indexed", i = e.maxBytes ?? gp(r), a = e.maxBytesPerSession ?? (i === Infinity ? Infinity : cp), o = e.evictionWatermark ?? lp, s = e.debounceMs ?? up, c = /* @__PURE__ */ new Set();
|
|
11915
11916
|
function l(e) {
|
|
11916
11917
|
for (let t of c) try {
|
|
11917
11918
|
t(e);
|
|
11918
11919
|
} catch {}
|
|
11919
11920
|
}
|
|
11920
|
-
let u =
|
|
11921
|
+
let u = Tp(), d = !1, f, p = new Promise((e) => {
|
|
11921
11922
|
f = e;
|
|
11922
11923
|
});
|
|
11923
11924
|
(async () => {
|
|
@@ -11928,16 +11929,16 @@ function Ap(e = {}, t) {
|
|
|
11928
11929
|
}
|
|
11929
11930
|
if (r === "indexed") {
|
|
11930
11931
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
11931
|
-
u = await
|
|
11932
|
+
u = await Ep(n), f(!0);
|
|
11932
11933
|
} else if (r === "session") {
|
|
11933
11934
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
11934
|
-
u =
|
|
11935
|
+
u = Dp(sessionStorage), f(!0);
|
|
11935
11936
|
} else if (r === "local") {
|
|
11936
11937
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
11937
|
-
u =
|
|
11938
|
-
} else u =
|
|
11938
|
+
u = Dp(localStorage), f(!0);
|
|
11939
|
+
} else u = Tp(), f(!1);
|
|
11939
11940
|
} catch (e) {
|
|
11940
|
-
u =
|
|
11941
|
+
u = Tp();
|
|
11941
11942
|
let t = e instanceof Error ? e.message : String(e);
|
|
11942
11943
|
f(!1), Promise.resolve().then(() => l({
|
|
11943
11944
|
type: "degraded",
|
|
@@ -11947,10 +11948,10 @@ function Ap(e = {}, t) {
|
|
|
11947
11948
|
})();
|
|
11948
11949
|
let m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
11949
11950
|
function _(e, t, r, i) {
|
|
11950
|
-
let o =
|
|
11951
|
-
return
|
|
11951
|
+
let o = vp(n, r, i, pp);
|
|
11952
|
+
return Op(g, o, async () => {
|
|
11952
11953
|
let n = async () => {
|
|
11953
|
-
let n = await u.get(o), s = await u.get(e), c = s == null ? 0 :
|
|
11954
|
+
let n = await u.get(o), s = await u.get(e), c = s == null ? 0 : Cp(s), d = Cp(t), f = (n?.bytes ?? 0) + (d - c);
|
|
11954
11955
|
if (f > a) {
|
|
11955
11956
|
l({
|
|
11956
11957
|
type: "quota",
|
|
@@ -11972,12 +11973,12 @@ function Ap(e = {}, t) {
|
|
|
11972
11973
|
try {
|
|
11973
11974
|
await n();
|
|
11974
11975
|
} catch (e) {
|
|
11975
|
-
if (
|
|
11976
|
+
if (_p(e) && !d) {
|
|
11976
11977
|
d = !0;
|
|
11977
11978
|
try {
|
|
11978
11979
|
await x();
|
|
11979
11980
|
} catch {}
|
|
11980
|
-
u =
|
|
11981
|
+
u = Tp(), Promise.resolve().then(() => l({
|
|
11981
11982
|
type: "degraded",
|
|
11982
11983
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
11983
11984
|
}));
|
|
@@ -11989,7 +11990,7 @@ function Ap(e = {}, t) {
|
|
|
11989
11990
|
});
|
|
11990
11991
|
}
|
|
11991
11992
|
function v(e, t, r, i) {
|
|
11992
|
-
let a =
|
|
11993
|
+
let a = vp(n, e, t, r), o = m.get(a);
|
|
11993
11994
|
o && o.resolve();
|
|
11994
11995
|
let c = h.get(a);
|
|
11995
11996
|
return c && clearTimeout(c), new Promise((n) => {
|
|
@@ -12016,16 +12017,16 @@ function Ap(e = {}, t) {
|
|
|
12016
12017
|
function b() {
|
|
12017
12018
|
y ||= setTimeout(() => {
|
|
12018
12019
|
y = null, x();
|
|
12019
|
-
},
|
|
12020
|
+
}, fp);
|
|
12020
12021
|
}
|
|
12021
12022
|
async function x() {
|
|
12022
12023
|
if (i !== Infinity) try {
|
|
12023
12024
|
let e = [];
|
|
12024
|
-
await u.scan(
|
|
12025
|
+
await u.scan(xp(n), (t, n) => {
|
|
12025
12026
|
t.endsWith("::__meta__") && e.push(n);
|
|
12026
12027
|
});
|
|
12027
|
-
let t =
|
|
12028
|
-
for (let e of t) await u.clearPrefix(
|
|
12028
|
+
let t = wp(e, i, o);
|
|
12029
|
+
for (let e of t) await u.clearPrefix(yp(n, e.agentId, e.sessionId)), l({
|
|
12029
12030
|
type: "evicted",
|
|
12030
12031
|
agentId: e.agentId,
|
|
12031
12032
|
sessionId: e.sessionId,
|
|
@@ -12042,13 +12043,13 @@ function Ap(e = {}, t) {
|
|
|
12042
12043
|
ready: p,
|
|
12043
12044
|
async listSessions(e) {
|
|
12044
12045
|
let t = [];
|
|
12045
|
-
return await u.scan(
|
|
12046
|
+
return await u.scan(bp(n, e), (e, n) => {
|
|
12046
12047
|
e.endsWith("::__meta__") && t.push(n);
|
|
12047
12048
|
}), t.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
12048
12049
|
},
|
|
12049
12050
|
async load(e, t) {
|
|
12050
|
-
let r =
|
|
12051
|
-
return await
|
|
12051
|
+
let r = vp(n, e, t, pp);
|
|
12052
|
+
return await Op(g, r, async () => {
|
|
12052
12053
|
let i = await u.get(r);
|
|
12053
12054
|
if (!i) return;
|
|
12054
12055
|
let a = {
|
|
@@ -12057,8 +12058,8 @@ function Ap(e = {}, t) {
|
|
|
12057
12058
|
todos: [],
|
|
12058
12059
|
memory: ""
|
|
12059
12060
|
};
|
|
12060
|
-
for (let r of
|
|
12061
|
-
let i = await u.get(
|
|
12061
|
+
for (let r of hp) {
|
|
12062
|
+
let i = await u.get(vp(n, e, t, r));
|
|
12062
12063
|
i != null && (a[r] = i);
|
|
12063
12064
|
}
|
|
12064
12065
|
i.lastAccessed = Date.now();
|
|
@@ -12070,12 +12071,12 @@ function Ap(e = {}, t) {
|
|
|
12070
12071
|
},
|
|
12071
12072
|
async save(e, t, n) {
|
|
12072
12073
|
let r = [];
|
|
12073
|
-
for (let i of
|
|
12074
|
+
for (let i of hp) n[i] !== void 0 && r.push(v(e, t, i, n[i]));
|
|
12074
12075
|
await Promise.all(r);
|
|
12075
12076
|
},
|
|
12076
12077
|
async updateTitle(e, t, r) {
|
|
12077
|
-
let i =
|
|
12078
|
-
return
|
|
12078
|
+
let i = vp(n, e, t, pp);
|
|
12079
|
+
return Op(g, i, async () => {
|
|
12079
12080
|
let e = await u.get(i);
|
|
12080
12081
|
e && (e.title = r, e.lastAccessed = Date.now(), await u.set(i, e));
|
|
12081
12082
|
});
|
|
@@ -12085,7 +12086,7 @@ function Ap(e = {}, t) {
|
|
|
12085
12086
|
let t = h.get(e);
|
|
12086
12087
|
t && (clearTimeout(t), h.delete(e));
|
|
12087
12088
|
}
|
|
12088
|
-
let t = e.flushTimeoutMs ??
|
|
12089
|
+
let t = e.flushTimeoutMs ?? dp, n = Array.from(m.entries());
|
|
12089
12090
|
await Promise.all(n.map(([e, n]) => new Promise((r) => {
|
|
12090
12091
|
let i;
|
|
12091
12092
|
_(e, n.value, n.agentId, n.sessionId).then(() => {
|
|
@@ -12101,13 +12102,13 @@ function Ap(e = {}, t) {
|
|
|
12101
12102
|
}))), l({ type: "flush" }), x();
|
|
12102
12103
|
},
|
|
12103
12104
|
async deleteSession(e, t) {
|
|
12104
|
-
let r =
|
|
12105
|
+
let r = yp(n, e, t);
|
|
12105
12106
|
for (let [e, t] of m.entries()) e.startsWith(r) && (t.resolve(), m.delete(e));
|
|
12106
12107
|
for (let [e, t] of h.entries()) e.startsWith(r) && (clearTimeout(t), h.delete(e));
|
|
12107
12108
|
await u.clearPrefix(r);
|
|
12108
12109
|
},
|
|
12109
12110
|
async createSession(e, t, r) {
|
|
12110
|
-
let i = r ??
|
|
12111
|
+
let i = r ?? ip(), a = Date.now(), o = {
|
|
12111
12112
|
agentId: e,
|
|
12112
12113
|
sessionId: i,
|
|
12113
12114
|
createdAt: a,
|
|
@@ -12116,7 +12117,7 @@ function Ap(e = {}, t) {
|
|
|
12116
12117
|
title: t
|
|
12117
12118
|
};
|
|
12118
12119
|
try {
|
|
12119
|
-
await u.set(
|
|
12120
|
+
await u.set(vp(n, e, i, pp), o);
|
|
12120
12121
|
} catch {}
|
|
12121
12122
|
return i;
|
|
12122
12123
|
},
|
|
@@ -12133,15 +12134,15 @@ function Ap(e = {}, t) {
|
|
|
12133
12134
|
}
|
|
12134
12135
|
//#endregion
|
|
12135
12136
|
//#region src/core/sdk/optionsResolver.ts
|
|
12136
|
-
function jp(e) {
|
|
12137
|
-
return e === void 0 ? Op({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? Op({ backend: e }) : e.enabled === !1 ? null : Op(e);
|
|
12138
|
-
}
|
|
12139
12137
|
function Mp(e) {
|
|
12138
|
+
return e === void 0 ? kp({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? kp({ backend: e }) : e.enabled === !1 ? null : kp(e);
|
|
12139
|
+
}
|
|
12140
|
+
function Np(e) {
|
|
12140
12141
|
return e.dialog ?? {};
|
|
12141
12142
|
}
|
|
12142
12143
|
//#endregion
|
|
12143
12144
|
//#region src/core/capabilities.ts
|
|
12144
|
-
var
|
|
12145
|
+
var Pp = [
|
|
12145
12146
|
{
|
|
12146
12147
|
name: "dataOps",
|
|
12147
12148
|
defaultOn: !0
|
|
@@ -12217,13 +12218,13 @@ var Np = [
|
|
|
12217
12218
|
requires: ["summarization"]
|
|
12218
12219
|
}
|
|
12219
12220
|
];
|
|
12220
|
-
function
|
|
12221
|
+
function Fp(e) {
|
|
12221
12222
|
let t = {};
|
|
12222
|
-
for (let n of
|
|
12223
|
+
for (let n of Pp) {
|
|
12223
12224
|
let r = e?.[n.name];
|
|
12224
12225
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
12225
12226
|
}
|
|
12226
|
-
for (let e of
|
|
12227
|
+
for (let e of Pp) if (e.requires && t[e.name]) {
|
|
12227
12228
|
for (let n of e.requires) if (!t[n]) {
|
|
12228
12229
|
t[e.name] = !1;
|
|
12229
12230
|
break;
|
|
@@ -12233,7 +12234,7 @@ function Pp(e) {
|
|
|
12233
12234
|
}
|
|
12234
12235
|
//#endregion
|
|
12235
12236
|
//#region src/core/sdk/events.ts
|
|
12236
|
-
function
|
|
12237
|
+
function Ip(e) {
|
|
12237
12238
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
12238
12239
|
if (n.type !== "approval_request") {
|
|
12239
12240
|
if (e) try {
|
|
@@ -12259,7 +12260,7 @@ function Fp(e) {
|
|
|
12259
12260
|
}
|
|
12260
12261
|
//#endregion
|
|
12261
12262
|
//#region src/core/sdk/contextPreset.ts
|
|
12262
|
-
var
|
|
12263
|
+
var Lp = {
|
|
12263
12264
|
auto: {
|
|
12264
12265
|
summaryThresholdRatio: .5,
|
|
12265
12266
|
windowRatio: .4,
|
|
@@ -12287,7 +12288,7 @@ var Ip = {
|
|
|
12287
12288
|
enableRecall: !0,
|
|
12288
12289
|
enableLLMSummary: !0
|
|
12289
12290
|
}
|
|
12290
|
-
},
|
|
12291
|
+
}, Rp = {
|
|
12291
12292
|
auto: ["schema_data", "read"],
|
|
12292
12293
|
conservative: ["schema_data"],
|
|
12293
12294
|
aggressive: ["schema_data", "read"],
|
|
@@ -12298,8 +12299,8 @@ var Ip = {
|
|
|
12298
12299
|
"search_data"
|
|
12299
12300
|
]
|
|
12300
12301
|
};
|
|
12301
|
-
function
|
|
12302
|
-
let n =
|
|
12302
|
+
function zp(e, t) {
|
|
12303
|
+
let n = Lp[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
12303
12304
|
return {
|
|
12304
12305
|
...n,
|
|
12305
12306
|
...r,
|
|
@@ -12309,7 +12310,7 @@ function Rp(e, t) {
|
|
|
12309
12310
|
}
|
|
12310
12311
|
//#endregion
|
|
12311
12312
|
//#region src/core/sdk/middlewareStack.ts
|
|
12312
|
-
var
|
|
12313
|
+
var Bp = {
|
|
12313
12314
|
dataHint: 10,
|
|
12314
12315
|
usageHints: 20,
|
|
12315
12316
|
todos: 30,
|
|
@@ -12326,17 +12327,17 @@ var zp = {
|
|
|
12326
12327
|
subagents: 140,
|
|
12327
12328
|
augmentSystem: 150
|
|
12328
12329
|
};
|
|
12329
|
-
function
|
|
12330
|
+
function Vp(e) {
|
|
12330
12331
|
return e.map((e, t) => ({
|
|
12331
12332
|
m: e,
|
|
12332
12333
|
i: t,
|
|
12333
|
-
p:
|
|
12334
|
+
p: Bp[e.name] ?? Infinity
|
|
12334
12335
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
12335
12336
|
}
|
|
12336
12337
|
//#endregion
|
|
12337
12338
|
//#region src/core/tools/fetchDoc.ts
|
|
12338
|
-
var
|
|
12339
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
12339
|
+
var Hp = 3e4, Up = [s(async ({ url: e, as: t }) => {
|
|
12340
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Hp);
|
|
12340
12341
|
try {
|
|
12341
12342
|
let r = await fetch(e, {
|
|
12342
12343
|
method: "GET",
|
|
@@ -12353,7 +12354,7 @@ var Vp = 3e4, Hp = [s(async ({ url: e, as: t }) => {
|
|
|
12353
12354
|
].join("\n");
|
|
12354
12355
|
} catch (t) {
|
|
12355
12356
|
let r = t?.message || String(t);
|
|
12356
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
12357
|
+
return n.signal.aborted ? `获取失败:请求超时(${Hp}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
12357
12358
|
} finally {
|
|
12358
12359
|
clearTimeout(r);
|
|
12359
12360
|
}
|
|
@@ -12364,7 +12365,7 @@ var Vp = 3e4, Hp = [s(async ({ url: e, as: t }) => {
|
|
|
12364
12365
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
12365
12366
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
12366
12367
|
})
|
|
12367
|
-
})],
|
|
12368
|
+
})], Wp = [
|
|
12368
12369
|
"id",
|
|
12369
12370
|
"class",
|
|
12370
12371
|
"href",
|
|
@@ -12376,12 +12377,12 @@ var Vp = 3e4, Hp = [s(async ({ url: e, as: t }) => {
|
|
|
12376
12377
|
"aria-label",
|
|
12377
12378
|
"name",
|
|
12378
12379
|
"type"
|
|
12379
|
-
],
|
|
12380
|
-
function
|
|
12380
|
+
], Gp = /^(value|srcdoc|formaction|on\w+)$/i, Kp = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
12381
|
+
function qp(e, t) {
|
|
12381
12382
|
if (!e) return null;
|
|
12382
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
12383
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Wp, s = (e) => {
|
|
12383
12384
|
let t = {};
|
|
12384
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
12385
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (Gp.test(n.name) || Kp.test(n.name) || (t[n.name] = n.value));
|
|
12385
12386
|
return t;
|
|
12386
12387
|
}, c = (e, t) => {
|
|
12387
12388
|
let n = {
|
|
@@ -12397,11 +12398,11 @@ function Kp(e, t) {
|
|
|
12397
12398
|
};
|
|
12398
12399
|
return c(e, n);
|
|
12399
12400
|
}
|
|
12400
|
-
var
|
|
12401
|
+
var Jp = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
12401
12402
|
if (typeof document > "u") return "ERROR: get_dom 仅在浏览器环境可用(当前运行在 node/服务端,无 DOM)。请改用数据工具(read/schema_data)排查结构。";
|
|
12402
12403
|
let i = e ? document.querySelector(e) : document.body;
|
|
12403
12404
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
12404
|
-
let a =
|
|
12405
|
+
let a = qp(i, {
|
|
12405
12406
|
depth: t ?? 3,
|
|
12406
12407
|
attrs: n,
|
|
12407
12408
|
includeText: r ?? !0
|
|
@@ -12416,22 +12417,22 @@ var qp = s(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
12416
12417
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
12417
12418
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
12418
12419
|
})
|
|
12419
|
-
}),
|
|
12420
|
-
function
|
|
12421
|
-
if (
|
|
12420
|
+
}), Yp = [Jp], Xp = /* @__PURE__ */ "display.position.visibility.opacity.color.background-color.background-image.font-size.font-weight.line-height.text-align.z-index.overflow.width.height.margin.padding.border.border-radius.box-shadow.transform.transition.animation.cursor.pointer-events.flex-direction.gap.max-width.min-height".split("."), Zp = /* @__PURE__ */ new WeakMap(), Qp = !1;
|
|
12421
|
+
function $p() {
|
|
12422
|
+
if (Qp) return;
|
|
12422
12423
|
let e = globalThis.EventTarget;
|
|
12423
12424
|
if (!e?.prototype?.addEventListener) return;
|
|
12424
|
-
|
|
12425
|
+
Qp = !0;
|
|
12425
12426
|
let t = e.prototype.addEventListener, n = e.prototype.removeEventListener;
|
|
12426
12427
|
e.prototype.addEventListener = function(e, ...n) {
|
|
12427
12428
|
try {
|
|
12428
|
-
let t =
|
|
12429
|
-
t || (t = /* @__PURE__ */ new Map(),
|
|
12429
|
+
let t = Zp.get(this);
|
|
12430
|
+
t || (t = /* @__PURE__ */ new Map(), Zp.set(this, t)), t.set(String(e), (t.get(String(e)) ?? 0) + 1);
|
|
12430
12431
|
} catch {}
|
|
12431
12432
|
return t.call(this, e, ...n);
|
|
12432
12433
|
}, e.prototype.removeEventListener = function(e, ...t) {
|
|
12433
12434
|
try {
|
|
12434
|
-
let t =
|
|
12435
|
+
let t = Zp.get(this);
|
|
12435
12436
|
if (t) {
|
|
12436
12437
|
let n = (t.get(String(e)) ?? 1) - 1;
|
|
12437
12438
|
n <= 0 ? t.delete(String(e)) : t.set(String(e), n);
|
|
@@ -12440,10 +12441,10 @@ function Qp() {
|
|
|
12440
12441
|
return n.call(this, e, ...t);
|
|
12441
12442
|
};
|
|
12442
12443
|
}
|
|
12443
|
-
function
|
|
12444
|
-
return [...
|
|
12444
|
+
function em(e) {
|
|
12445
|
+
return [...Zp.get(e)?.entries() ?? []].filter(([, e]) => e > 0).map(([e]) => e);
|
|
12445
12446
|
}
|
|
12446
|
-
function
|
|
12447
|
+
function tm(e, t = 12) {
|
|
12447
12448
|
let n = [], r = e, i = 0;
|
|
12448
12449
|
for (; r && r.tagName && i < t;) {
|
|
12449
12450
|
let e = r.tagName.toLowerCase(), t = r.id;
|
|
@@ -12464,7 +12465,7 @@ function em(e, t = 12) {
|
|
|
12464
12465
|
}
|
|
12465
12466
|
return n.join(" > ");
|
|
12466
12467
|
}
|
|
12467
|
-
function
|
|
12468
|
+
function nm(e, t, n = {}) {
|
|
12468
12469
|
if (!e) return {
|
|
12469
12470
|
hits: [],
|
|
12470
12471
|
total: 0,
|
|
@@ -12502,7 +12503,7 @@ function tm(e, t, n = {}) {
|
|
|
12502
12503
|
n = r.slice(Math.max(0, i - 20), i + t.length + 40);
|
|
12503
12504
|
}
|
|
12504
12505
|
return {
|
|
12505
|
-
selector:
|
|
12506
|
+
selector: tm(e),
|
|
12506
12507
|
tag: e.tagName.toLowerCase(),
|
|
12507
12508
|
text: n.slice(0, 120)
|
|
12508
12509
|
};
|
|
@@ -12511,7 +12512,7 @@ function tm(e, t, n = {}) {
|
|
|
12511
12512
|
truncated: a.length > o
|
|
12512
12513
|
};
|
|
12513
12514
|
}
|
|
12514
|
-
var
|
|
12515
|
+
var rm = [
|
|
12515
12516
|
"content",
|
|
12516
12517
|
"display",
|
|
12517
12518
|
"width",
|
|
@@ -12519,14 +12520,14 @@ var nm = [
|
|
|
12519
12520
|
"background-color",
|
|
12520
12521
|
"position"
|
|
12521
12522
|
];
|
|
12522
|
-
function
|
|
12523
|
+
function im(e, t = {}) {
|
|
12523
12524
|
if (!e) return null;
|
|
12524
12525
|
let n = {
|
|
12525
|
-
selector:
|
|
12526
|
+
selector: tm(e),
|
|
12526
12527
|
tag: e.tagName.toLowerCase(),
|
|
12527
12528
|
attrs: {}
|
|
12528
12529
|
};
|
|
12529
|
-
for (let t of Array.from(e.attributes)) !(
|
|
12530
|
+
for (let t of Array.from(e.attributes)) !(Wp.includes(t.name) || t.name.startsWith("data-")) || Gp.test(t.name) || Kp.test(t.name) || (n.attrs[t.name] = t.value);
|
|
12530
12531
|
let r = Array.from(e.childNodes).filter((e) => e.nodeType === 3).map((e) => e.textContent || "").join("").trim();
|
|
12531
12532
|
r && (n.text = r.slice(0, 400));
|
|
12532
12533
|
let i = String(e.innerText ?? e.textContent ?? "").trim();
|
|
@@ -12548,7 +12549,7 @@ function rm(e, t = {}) {
|
|
|
12548
12549
|
if (typeof a != "function") return r;
|
|
12549
12550
|
try {
|
|
12550
12551
|
let i = a(e, n ?? null);
|
|
12551
|
-
for (let e of n ?
|
|
12552
|
+
for (let e of n ? rm : t.styles ?? Xp) {
|
|
12552
12553
|
let t = typeof i.getPropertyValue == "function" ? i.getPropertyValue(e) : i[e];
|
|
12553
12554
|
t && (r[e] = String(t).slice(0, 200));
|
|
12554
12555
|
}
|
|
@@ -12566,16 +12567,16 @@ function rm(e, t = {}) {
|
|
|
12566
12567
|
n.events = {
|
|
12567
12568
|
inline: t,
|
|
12568
12569
|
vue: r ? Object.keys(r).filter((e) => /^on[A-Z]/.test(e)).map((e) => e.slice(2).toLowerCase()) : [],
|
|
12569
|
-
captured:
|
|
12570
|
+
captured: em(e)
|
|
12570
12571
|
};
|
|
12571
12572
|
}
|
|
12572
12573
|
return n;
|
|
12573
12574
|
}
|
|
12574
|
-
var
|
|
12575
|
-
|
|
12575
|
+
var am = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
12576
|
+
$p();
|
|
12576
12577
|
let i = r ? document.querySelector(r) : document;
|
|
12577
12578
|
if (r && !i) return `未找到 root 元素:selector="${r}"`;
|
|
12578
|
-
let a =
|
|
12579
|
+
let a = nm(i, e, {
|
|
12579
12580
|
mode: t,
|
|
12580
12581
|
limit: n
|
|
12581
12582
|
});
|
|
@@ -12592,11 +12593,11 @@ var im = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
12592
12593
|
limit: t.number().int().min(1).max(20).optional().describe("返回上限(默认 10)"),
|
|
12593
12594
|
root: t.string().optional().describe("限定搜索范围的容器选择器(默认整页)")
|
|
12594
12595
|
})
|
|
12595
|
-
}),
|
|
12596
|
-
|
|
12596
|
+
}), om = s(({ selector: e, styles: t, includeHtml: n, htmlLimit: r, includeEvents: i, includeRect: a, pseudo: o }) => {
|
|
12597
|
+
$p();
|
|
12597
12598
|
let s = document.querySelector(e);
|
|
12598
12599
|
if (!s) return `未找到匹配元素:selector="${e}"(可先用 dom_search 定位)`;
|
|
12599
|
-
let c =
|
|
12600
|
+
let c = im(s, {
|
|
12600
12601
|
styles: t,
|
|
12601
12602
|
includeHtml: n,
|
|
12602
12603
|
htmlLimit: r,
|
|
@@ -12617,7 +12618,7 @@ var im = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
12617
12618
|
includeRect: t.boolean().optional().describe("是否含几何位置(默认 true)"),
|
|
12618
12619
|
pseudo: t.boolean().optional().describe("是否含 ::before/::after 伪元素摘要(默认 false)")
|
|
12619
12620
|
})
|
|
12620
|
-
}),
|
|
12621
|
+
}), sm = {
|
|
12621
12622
|
name: "dom-inspect",
|
|
12622
12623
|
description: "页面 DOM 深度检视工具(dom_search 搜索元素 / dom_info 读内容·计算样式·事件绑定·几何)。定位元素、验证样式落地、排查交互绑定时加载",
|
|
12623
12624
|
getContent: () => [
|
|
@@ -12634,15 +12635,15 @@ var im = s(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
12634
12635
|
"## 排障套路",
|
|
12635
12636
|
"1. dom_search(mode:\"text\", query:按钮文案) 定位 → 2. dom_info(styles:[\"display\",\"background-color\",\"pointer-events\"]) 验证样式/点击性 → 3. 不符则改数据(get_dom 看结构对照)"
|
|
12636
12637
|
].join("\n"),
|
|
12637
|
-
tools: [() => [
|
|
12638
|
+
tools: [() => [am, om]]
|
|
12638
12639
|
};
|
|
12639
12640
|
//#endregion
|
|
12640
12641
|
//#region src/core/tools/envTool.ts
|
|
12641
|
-
function
|
|
12642
|
+
function cm(e) {
|
|
12642
12643
|
let t = e;
|
|
12643
12644
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
12644
12645
|
}
|
|
12645
|
-
function
|
|
12646
|
+
function lm(e, t = 3, n = 2e3, r, i) {
|
|
12646
12647
|
if (e == null) return e;
|
|
12647
12648
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
12648
12649
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -12651,14 +12652,14 @@ function cm(e, t = 3, n = 2e3, r, i) {
|
|
|
12651
12652
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
12652
12653
|
if (typeof e != "object") return String(e);
|
|
12653
12654
|
let a = e;
|
|
12654
|
-
if (
|
|
12655
|
+
if (cm(a)) {
|
|
12655
12656
|
let e = a;
|
|
12656
12657
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
12657
12658
|
}
|
|
12658
12659
|
if (r?.has(a)) return "[Circular]";
|
|
12659
12660
|
let o = r ?? /* @__PURE__ */ new WeakSet();
|
|
12660
12661
|
if (o.add(a), Array.isArray(e)) {
|
|
12661
|
-
let r = e.slice(0, 100).map((e) =>
|
|
12662
|
+
let r = e.slice(0, 100).map((e) => lm(e, t - 1, n, o, i));
|
|
12662
12663
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
12663
12664
|
}
|
|
12664
12665
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -12671,14 +12672,14 @@ function cm(e, t = 3, n = 2e3, r, i) {
|
|
|
12671
12672
|
}
|
|
12672
12673
|
try {
|
|
12673
12674
|
let e = a[r];
|
|
12674
|
-
i?.test(r) ? s[r] = "[REDACTED]" : s[r] =
|
|
12675
|
+
i?.test(r) ? s[r] = "[REDACTED]" : s[r] = lm(e, t - 1, n, o, i);
|
|
12675
12676
|
} catch {
|
|
12676
12677
|
s[r] = "(getter 抛错)";
|
|
12677
12678
|
}
|
|
12678
12679
|
}
|
|
12679
12680
|
return s;
|
|
12680
12681
|
}
|
|
12681
|
-
function
|
|
12682
|
+
function um(e) {
|
|
12682
12683
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
12683
12684
|
return {
|
|
12684
12685
|
location: {
|
|
@@ -12711,9 +12712,9 @@ function lm(e) {
|
|
|
12711
12712
|
} : "(无 document)"
|
|
12712
12713
|
};
|
|
12713
12714
|
}
|
|
12714
|
-
var
|
|
12715
|
+
var dm = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, fm = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, pm = s(({ key: e }) => {
|
|
12715
12716
|
if (e) {
|
|
12716
|
-
if (
|
|
12717
|
+
if (dm.test(e) || fm.test(e)) return JSON.stringify({
|
|
12717
12718
|
key: e,
|
|
12718
12719
|
denied: !0,
|
|
12719
12720
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -12723,18 +12724,18 @@ var um = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
12723
12724
|
key: e,
|
|
12724
12725
|
exists: t !== void 0,
|
|
12725
12726
|
type: typeof t,
|
|
12726
|
-
value:
|
|
12727
|
+
value: lm(t, 3, 2e3, void 0, fm)
|
|
12727
12728
|
}, null, 2);
|
|
12728
12729
|
}
|
|
12729
|
-
return JSON.stringify(
|
|
12730
|
+
return JSON.stringify(um(), null, 2);
|
|
12730
12731
|
}, {
|
|
12731
12732
|
name: "inspect_env",
|
|
12732
12733
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
12733
12734
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
12734
|
-
}),
|
|
12735
|
+
}), mm = [pm];
|
|
12735
12736
|
//#endregion
|
|
12736
12737
|
//#region src/core/harness/budget.ts
|
|
12737
|
-
function
|
|
12738
|
+
function hm(e, t, n) {
|
|
12738
12739
|
let i = 0;
|
|
12739
12740
|
return {
|
|
12740
12741
|
name: "budget",
|
|
@@ -12759,12 +12760,12 @@ function mm(e, t, n) {
|
|
|
12759
12760
|
}
|
|
12760
12761
|
//#endregion
|
|
12761
12762
|
//#region src/core/sdk/actions.ts
|
|
12762
|
-
var
|
|
12763
|
-
function
|
|
12763
|
+
var gm = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
12764
|
+
function _m(e) {
|
|
12764
12765
|
let n = [];
|
|
12765
12766
|
for (let [r, i] of Object.entries(e)) {
|
|
12766
|
-
if (!
|
|
12767
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${r}" 非法(须匹配 ${
|
|
12767
|
+
if (!gm.test(r)) {
|
|
12768
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${r}" 非法(须匹配 ${gm}),已跳过`);
|
|
12768
12769
|
continue;
|
|
12769
12770
|
}
|
|
12770
12771
|
let e = i.description || `宿主动作 ${r}`;
|
|
@@ -12784,9 +12785,9 @@ function gm(e) {
|
|
|
12784
12785
|
}
|
|
12785
12786
|
return n;
|
|
12786
12787
|
}
|
|
12787
|
-
function
|
|
12788
|
+
function vm(e) {
|
|
12788
12789
|
let t = {};
|
|
12789
|
-
for (let [n, r] of Object.entries(e))
|
|
12790
|
+
for (let [n, r] of Object.entries(e)) gm.test(n) && (t[n] = {
|
|
12790
12791
|
description: r.description,
|
|
12791
12792
|
hasParams: !!r.params
|
|
12792
12793
|
});
|
|
@@ -12794,12 +12795,12 @@ function _m(e) {
|
|
|
12794
12795
|
}
|
|
12795
12796
|
//#endregion
|
|
12796
12797
|
//#region src/core/toolsets.ts
|
|
12797
|
-
var
|
|
12798
|
-
function
|
|
12798
|
+
var ym = Up, bm = Yp;
|
|
12799
|
+
function xm(e, t) {
|
|
12799
12800
|
return kd(e, t);
|
|
12800
12801
|
}
|
|
12801
|
-
function
|
|
12802
|
-
let a =
|
|
12802
|
+
function Sm(e, t, n, r, i) {
|
|
12803
|
+
let a = Fp(e);
|
|
12803
12804
|
return [
|
|
12804
12805
|
...a.dataOps ? t : [],
|
|
12805
12806
|
...a.fetch ? n : [],
|
|
@@ -12809,7 +12810,7 @@ function xm(e, t, n, r, i) {
|
|
|
12809
12810
|
}
|
|
12810
12811
|
//#endregion
|
|
12811
12812
|
//#region src/core/sdk/toolRegistry.ts
|
|
12812
|
-
function
|
|
12813
|
+
function Cm(e) {
|
|
12813
12814
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
12814
12815
|
for (let r of e) for (let e of r.tools) {
|
|
12815
12816
|
let i = t.get(e.name);
|
|
@@ -12829,15 +12830,15 @@ function Sm(e) {
|
|
|
12829
12830
|
}
|
|
12830
12831
|
//#endregion
|
|
12831
12832
|
//#region src/core/harness/usageHints.ts
|
|
12832
|
-
var
|
|
12833
|
-
function
|
|
12834
|
-
let r =
|
|
12833
|
+
var wm = .7;
|
|
12834
|
+
function Tm(e, t, n) {
|
|
12835
|
+
let r = Fp(e);
|
|
12835
12836
|
return {
|
|
12836
12837
|
name: "usageHints",
|
|
12837
12838
|
augmentPrompt: (i) => {
|
|
12838
12839
|
let a = [];
|
|
12839
12840
|
if (r.planning && (a.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), a.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), a.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), a.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), a.push(" · update_todo 标 completed 时附 evidence: 本次实际写入的 jsonPath(如 \"components.2\"),供收口对账;工作经委派子 agent 完成等无主写路径时,如实写明完成方式(勿编造路径)。"), e?.humanConfirm ? a.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : a.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), a.push(" · 计划修订有次数上限(maxPlanRevisions,默认 5,只计 write_todos 调用、调研轮不计):勿反复改计划而不执行,规划充分后即开始 write 落地。")), t && (a.push("改主数据前先 read({jsonPath}) 读其当前真实值(返回末尾 hash=xxx 为乐观锁标识),基于真实值改,不要凭记忆。写入是否被自动校验由集成方 conflictWatchFields 声明决定:若已声明且主数据在你 read 之后被外部改过,会触发冲突——集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 read 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 read 拿最新值再改。"), a.push("读类分流:取值/结构 → read(多路径用 jsonPaths);字段约束 → schema_data;条件筛选定位 → query_data(多条一次用 queries);名字模糊找 → search_data;整体说明 → read 不传路径。"), a.push("修改大对象/数组优先用 write 增量改({patch:{op,jsonPath,value}} 只发改动部分),避免 write({value}) 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), a.push("修改主数据出错时可用 restore_data 回退最近一次。"), a.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 write({patch}) 改。"), a.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), a.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), a.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), a.push("【省轮次·批量】≥2 个路径一律 read({jsonPaths:[...]}) 一次取回(路径互不相关也合批,禁止连续单路径 read);多条件筛选用 query_data({queries:[expr1,expr2,…]}) 一次取回(2-10 条);改多处用 write({patches:[{op:\"set\",jsonPath,value},...]}) 一次提交多改动(原子任一失败回滚),勿逐个 write 烧轮次预算。"), a.push("读到 <subtree Nkb keys:[…] #指纹> 或 <code Nkb> 占位 = 该子树键名/体积可见但内容未见:写入前先窄读全文(read({jsonPath:\"该子树路径\"}),结果根豁免返全文)或 set_focus 聚焦该区域;勿凭键名印象猜路径/猜值直写(直接写占位子树会被拦下要求先窄读)。"), a.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。")), r.subagent && a.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), r.inspectEnv && a.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), r.domInspect && a.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read 查。")), e?.subagents?.length) {
|
|
12840
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
12841
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= wm || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < wm && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
12841
12842
|
a.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (a.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), a.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && a.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), a.push(" · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), a.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
12842
12843
|
}
|
|
12843
12844
|
e?.humanConfirm && (a.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), a.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), a.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), a.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), a.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), a.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
@@ -12857,7 +12858,7 @@ function wm(e, t, n) {
|
|
|
12857
12858
|
}
|
|
12858
12859
|
//#endregion
|
|
12859
12860
|
//#region src/core/harness/resourcesPin.ts
|
|
12860
|
-
function
|
|
12861
|
+
function Em(e) {
|
|
12861
12862
|
return {
|
|
12862
12863
|
name: "resourcesPin",
|
|
12863
12864
|
augmentPrompt: () => {
|
|
@@ -12871,66 +12872,66 @@ function Tm(e) {
|
|
|
12871
12872
|
}
|
|
12872
12873
|
//#endregion
|
|
12873
12874
|
//#region src/core/backends/skillStore.ts
|
|
12874
|
-
var
|
|
12875
|
-
function
|
|
12876
|
-
return `${
|
|
12875
|
+
var Dm = "v:1::skill-store", Om = "chat-sdk";
|
|
12876
|
+
function km(e, t, n) {
|
|
12877
|
+
return `${Dm}::${e}::${t}::${n}`;
|
|
12877
12878
|
}
|
|
12878
|
-
function
|
|
12879
|
-
return `${
|
|
12879
|
+
function Am(e, t) {
|
|
12880
|
+
return `${Dm}::${e}::${t}::`;
|
|
12880
12881
|
}
|
|
12881
|
-
function
|
|
12882
|
-
let t = e.dbName ??
|
|
12882
|
+
function jm(e = {}) {
|
|
12883
|
+
let t = e.dbName ?? Om, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
12883
12884
|
a = e;
|
|
12884
12885
|
});
|
|
12885
12886
|
return (async () => {
|
|
12886
12887
|
try {
|
|
12887
12888
|
if (n === "indexed") {
|
|
12888
12889
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
12889
|
-
i = await
|
|
12890
|
+
i = await Ep(t), a(!0);
|
|
12890
12891
|
} else if (n === "session") {
|
|
12891
12892
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
12892
|
-
i =
|
|
12893
|
+
i = Dp(sessionStorage), a(!0);
|
|
12893
12894
|
} else if (n === "local") {
|
|
12894
12895
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
12895
|
-
i =
|
|
12896
|
-
} else i =
|
|
12896
|
+
i = Dp(localStorage), a(!0);
|
|
12897
|
+
} else i = Tp(), a(!1);
|
|
12897
12898
|
} catch {
|
|
12898
|
-
i =
|
|
12899
|
+
i = Tp(), a(!1);
|
|
12899
12900
|
}
|
|
12900
12901
|
})(), {
|
|
12901
12902
|
ready: o,
|
|
12902
12903
|
async list() {
|
|
12903
12904
|
let e = [];
|
|
12904
|
-
return await i.scan(
|
|
12905
|
+
return await i.scan(Am(t, r), (t, n) => {
|
|
12905
12906
|
e.push(n);
|
|
12906
12907
|
}), e;
|
|
12907
12908
|
},
|
|
12908
12909
|
async get(e) {
|
|
12909
|
-
return await i.get(
|
|
12910
|
+
return await i.get(km(t, r, e));
|
|
12910
12911
|
},
|
|
12911
12912
|
async put(e) {
|
|
12912
12913
|
try {
|
|
12913
|
-
await i.set(
|
|
12914
|
+
await i.set(km(t, r, e.name), e);
|
|
12914
12915
|
} catch (e) {
|
|
12915
|
-
|
|
12916
|
+
_p(e) && (i = Tp());
|
|
12916
12917
|
}
|
|
12917
12918
|
},
|
|
12918
12919
|
async remove(e) {
|
|
12919
|
-
let n =
|
|
12920
|
+
let n = km(t, r, e);
|
|
12920
12921
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
12921
12922
|
},
|
|
12922
12923
|
async clear() {
|
|
12923
|
-
await i.clearPrefix(
|
|
12924
|
+
await i.clearPrefix(Am(t, r));
|
|
12924
12925
|
},
|
|
12925
12926
|
dispose() {}
|
|
12926
12927
|
};
|
|
12927
12928
|
}
|
|
12928
|
-
var
|
|
12929
|
-
function
|
|
12929
|
+
var Mm = /large_results\/[^\s"'`),]+\.txt/g;
|
|
12930
|
+
function Nm(e) {
|
|
12930
12931
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
12931
12932
|
if (typeof e != "string" || !e) return;
|
|
12932
12933
|
let n;
|
|
12933
|
-
for (
|
|
12934
|
+
for (Mm.lastIndex = 0; (n = Mm.exec(e)) !== null;) t.add(n[0]);
|
|
12934
12935
|
};
|
|
12935
12936
|
for (let r of e) {
|
|
12936
12937
|
if (n(r.content), r.steps) for (let e of r.steps) n(e.result);
|
|
@@ -12938,14 +12939,14 @@ function Mm(e) {
|
|
|
12938
12939
|
}
|
|
12939
12940
|
return t;
|
|
12940
12941
|
}
|
|
12941
|
-
function
|
|
12942
|
+
function Pm(e, t) {
|
|
12942
12943
|
let n = [];
|
|
12943
12944
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
12944
12945
|
return n;
|
|
12945
12946
|
}
|
|
12946
12947
|
//#endregion
|
|
12947
12948
|
//#region src/core/utils/serialRunner.ts
|
|
12948
|
-
function
|
|
12949
|
+
function Fm() {
|
|
12949
12950
|
let e = Promise.resolve();
|
|
12950
12951
|
return function(t) {
|
|
12951
12952
|
let n = e.then(t, t);
|
|
@@ -12954,24 +12955,24 @@ function Pm() {
|
|
|
12954
12955
|
}
|
|
12955
12956
|
//#endregion
|
|
12956
12957
|
//#region src/core/sdk/createChatSdk.ts
|
|
12957
|
-
var
|
|
12958
|
-
function
|
|
12958
|
+
var Im = 30, Lm = 1, Rm = 6 * 1024 * 1024, zm = /* @__PURE__ */ new Map();
|
|
12959
|
+
function Bm(e, t) {
|
|
12959
12960
|
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;
|
|
12960
12961
|
}
|
|
12961
|
-
function
|
|
12962
|
+
function Vm(e) {
|
|
12962
12963
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
12963
12964
|
}
|
|
12964
|
-
function
|
|
12965
|
+
function Hm(e, t, n, r) {
|
|
12965
12966
|
let i = 0;
|
|
12966
12967
|
return {
|
|
12967
12968
|
name: "sdk-events",
|
|
12968
12969
|
wrapToolCall: async (t, r) => {
|
|
12969
|
-
let i = await r(t), a =
|
|
12970
|
+
let i = await r(t), a = Bm(t.name, t.args), o = typeof i.content == "string" && i.content.startsWith("ERROR:");
|
|
12970
12971
|
return a && !o ? e({
|
|
12971
12972
|
type: "data_change",
|
|
12972
12973
|
operation: a,
|
|
12973
12974
|
value: n()?.bind
|
|
12974
|
-
}) : i.status === "done" && !o &&
|
|
12975
|
+
}) : i.status === "done" && !o && Vm(t.name) && e({
|
|
12975
12976
|
type: "data_change",
|
|
12976
12977
|
operation: "edit",
|
|
12977
12978
|
value: n()?.bind
|
|
@@ -12999,7 +13000,7 @@ function Vm(e, t, n, r) {
|
|
|
12999
13000
|
}
|
|
13000
13001
|
};
|
|
13001
13002
|
}
|
|
13002
|
-
function
|
|
13003
|
+
function Um(e, t, n, r, i) {
|
|
13003
13004
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
13004
13005
|
ok: !1,
|
|
13005
13006
|
error: "capabilities.focus 关闭"
|
|
@@ -13017,12 +13018,12 @@ function Hm(e, t, n, r, i) {
|
|
|
13017
13018
|
error: "当前无主数据 schema,无法聚焦"
|
|
13018
13019
|
});
|
|
13019
13020
|
}
|
|
13020
|
-
function
|
|
13021
|
+
function Wm(e, n) {
|
|
13021
13022
|
let r = {
|
|
13022
13023
|
prompt_tokens: 0,
|
|
13023
13024
|
completion_tokens: 0,
|
|
13024
13025
|
total_tokens: 0
|
|
13025
|
-
}, i =
|
|
13026
|
+
}, i = rp(() => Y, () => e.conflictPolicy ?? "ask", () => X.agent?.debugLogs?.value), a = /* @__PURE__ */ Ut(0), o = Mp(e.storage);
|
|
13026
13027
|
o && (e.debug && o.onEvent((e) => console.log("[page-agent-sdk][storage]", e)), o.onEvent((e) => {
|
|
13027
13028
|
e.type === "quota" && X.agent?.debugLogs?.value?.push({
|
|
13028
13029
|
timestamp: Date.now(),
|
|
@@ -13034,13 +13035,13 @@ function Um(e, n) {
|
|
|
13034
13035
|
}
|
|
13035
13036
|
});
|
|
13036
13037
|
}));
|
|
13037
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } =
|
|
13038
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } = np(e), f = c;
|
|
13038
13039
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", f), f.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${f.contextWindow} 小于最小支持 ${p}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
13039
13040
|
{
|
|
13040
|
-
let t = e.llm, n =
|
|
13041
|
+
let t = e.llm, n = Gf(t) ? t.model ?? t.modelName ?? "" : t.model ?? "", r = Gf(t) ? t.maxTokens ?? f.maxOutputTokens : t.maxTokens ?? h(t.model) ?? f.maxOutputTokens, i = _(n || void 0, f, r);
|
|
13041
13042
|
i && console.warn(i);
|
|
13042
13043
|
}
|
|
13043
|
-
let m =
|
|
13044
|
+
let m = zp(e, f.contextWindow), g = m.enableLLMSummary !== !1, y = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? Rp[e.contextPreset ?? "auto"], b = new Set(y), x = e.llm;
|
|
13044
13045
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
13045
13046
|
let S = /* @__PURE__ */ jt([]), C = Iu(e.vfs?.initialFiles, {
|
|
13046
13047
|
persist: o ? { save: (e) => {
|
|
@@ -13085,14 +13086,14 @@ function Um(e, n) {
|
|
|
13085
13086
|
timeoutMs: ne,
|
|
13086
13087
|
onAutoReject: re
|
|
13087
13088
|
}), A = yc({
|
|
13088
|
-
getSchema: () =>
|
|
13089
|
-
getBind: () =>
|
|
13089
|
+
getSchema: () => G()?.schema,
|
|
13090
|
+
getBind: () => G()?.bind,
|
|
13090
13091
|
onChange: (e) => Y({
|
|
13091
13092
|
type: "focus_change",
|
|
13092
13093
|
focuses: e
|
|
13093
13094
|
})
|
|
13094
13095
|
}), j = (e) => {
|
|
13095
|
-
let t = _c(
|
|
13096
|
+
let t = _c(G()?.bind, e.path);
|
|
13096
13097
|
return t ? {
|
|
13097
13098
|
...e,
|
|
13098
13099
|
pgId: t
|
|
@@ -13102,8 +13103,8 @@ function Um(e, n) {
|
|
|
13102
13103
|
let oe = { current: null }, N = e.data ? {
|
|
13103
13104
|
...e.data,
|
|
13104
13105
|
description: e.data.description ?? "主数据对象"
|
|
13105
|
-
} : void 0, P = !(e.subagents ?? []).some((e) => e._codeAsset) &&
|
|
13106
|
-
P && N?.schema && gs(N.schema).length && (se = [...e.subagents ?? [],
|
|
13106
|
+
} : void 0, P = !(e.subagents ?? []).some((e) => e._codeAsset) && Fp(e.capabilities).subagent, se = e.subagents;
|
|
13107
|
+
P && N?.schema && gs(N.schema).length && (se = [...e.subagents ?? [], Rf()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
13107
13108
|
let F = (se ?? []).filter((e) => !!e._codeAsset), I = /* @__PURE__ */ new Set();
|
|
13108
13109
|
for (let e of F) {
|
|
13109
13110
|
if (e._codeAsset.writablePaths.length) continue;
|
|
@@ -13111,37 +13112,37 @@ function Um(e, n) {
|
|
|
13111
13112
|
t.length ? (e._codeAsset.writablePaths = t, Array.isArray(e.writablePaths) && (e.writablePaths = t), e._rebuildCodeAssetPaths?.(t[0]), console.info(`[page-agent-sdk][createHtmlSubagent] 未传 writablePaths,已从 schema 推断: [${t.map((e) => `'${e}'`).join(", ")}]`)) : (console.warn("[page-agent-sdk][createHtmlSubagent] 未能从 schema 推断 writablePaths(开放 schema(z.any()/z.record())/嵌套容器(如 sections[].children[])/点路径 codeField(如 props.html_code)不支持自动推断),已跳过该 html 子 agent(整体不受影响);如确需代码资产机制(vfs + 格式校验 + 增量 commit),请显式传 writablePaths(代码组件 data 区,如 ['components'])"), I.add(e));
|
|
13112
13113
|
}
|
|
13113
13114
|
let ce = I.size ? F.filter((e) => !I.has(e)) : F, le = I.size ? (se ?? []).filter((e) => !I.has(e)) : se, L = ce.length > 0, ue = ce.flatMap((e) => e._codeAsset.writablePaths), de = ce.flatMap((e) => e._codeAsset.writablePaths.map((t) => `${t}.${e._codeAsset.codeField}`)), R = e.checkpoint, z = R !== void 0 && R !== !1, B = z ? eu({
|
|
13114
|
-
getData: () =>
|
|
13115
|
-
consumeDataDirty: () =>
|
|
13115
|
+
getData: () => G()?.bind,
|
|
13116
|
+
consumeDataDirty: () => W?.consumeDataDirty?.() ?? !0,
|
|
13116
13117
|
slotPaths: N ? [""] : [],
|
|
13117
13118
|
vfsStore: C,
|
|
13118
13119
|
todosMw: w,
|
|
13119
13120
|
getTodos: () => oe.current?.getState?.()?.todos ?? [],
|
|
13120
13121
|
messages: S,
|
|
13121
13122
|
maxCheckpoints: R && typeof R == "object" ? R.maxCheckpoints : void 0
|
|
13122
|
-
}) : null,
|
|
13123
|
+
}) : null, V = !R || typeof R != "object" || R.auto !== !1, H = Fp(e.capabilities), fe = H.dataOps, pe = H.draftWrite, me = H.automation, U = Mu({
|
|
13123
13124
|
...e,
|
|
13124
13125
|
locale: e.i18n?.locale
|
|
13125
13126
|
});
|
|
13126
13127
|
if (L) {
|
|
13127
13128
|
let e = ce.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
13128
|
-
e && (
|
|
13129
|
-
} else N?.schema && hs(N.schema) && (
|
|
13130
|
-
let
|
|
13129
|
+
e && (U += "\n\n" + e);
|
|
13130
|
+
} else N?.schema && hs(N.schema) && (U += "\n\n" + Ns.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
13131
|
+
let he = fe && N ? kd(N, {
|
|
13131
13132
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
13132
13133
|
maxSnapshots: e.maxSnapshots,
|
|
13133
13134
|
onConflict: i.set,
|
|
13134
13135
|
conflictWatchFields: e.conflictWatchFields,
|
|
13135
13136
|
maxParallelTools: e.maxParallelTools,
|
|
13136
|
-
vfsStore:
|
|
13137
|
+
vfsStore: pe || N?.resources?.length ? C : void 0,
|
|
13137
13138
|
...ue.length ? { pgIdPaths: ue } : {},
|
|
13138
13139
|
...de.length ? { largeTextPaths: de } : {}
|
|
13139
|
-
}) : [],
|
|
13140
|
-
getBind: () =>
|
|
13141
|
-
recomputeAll: () =>
|
|
13142
|
-
hasBaselines: () =>
|
|
13143
|
-
isManaged: (e) =>
|
|
13144
|
-
hash: (e) =>
|
|
13140
|
+
}) : [], ge = fe ? he : [], W = fe && N ? he.controller ?? null : null, _e = fe && N ? he.previewWrite : void 0, ve = fe && N?.resources?.length && W?.getResourcesSnapshot ? Em({ getResourcesSnapshot: () => W?.getResourcesSnapshot?.() ?? [] }) : void 0, G = () => W?.get() ?? N, ye = new Set(he.map((e) => e.name)), be = e.conflictWatchFields ?? [], xe = !be.includes("*") && be.length ? new Set(be) : void 0, Se = W ? lf({
|
|
13141
|
+
getBind: () => G()?.bind,
|
|
13142
|
+
recomputeAll: () => W.recomputeAllBaselines?.(),
|
|
13143
|
+
hasBaselines: () => W.hasBaselines?.() ?? !1,
|
|
13144
|
+
isManaged: (e) => ye.has(e),
|
|
13145
|
+
hash: (e) => xe ? rc(ql(e), xe) : nc(ql(e)),
|
|
13145
13146
|
log: (e, t) => {
|
|
13146
13147
|
let n = X.agent?.debugLogs;
|
|
13147
13148
|
n && (n.value.push({
|
|
@@ -13153,19 +13154,19 @@ function Um(e, n) {
|
|
|
13153
13154
|
}
|
|
13154
13155
|
}), qt(n));
|
|
13155
13156
|
}
|
|
13156
|
-
}) : void 0,
|
|
13157
|
-
...
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
] :
|
|
13161
|
-
|
|
13162
|
-
let
|
|
13163
|
-
|
|
13164
|
-
let
|
|
13165
|
-
|
|
13166
|
-
let
|
|
13167
|
-
|
|
13168
|
-
let
|
|
13157
|
+
}) : void 0, K = /* @__PURE__ */ new Map(), Ce = Sm(H, ge, Up, H.domInspect && !H.skills ? [
|
|
13158
|
+
...Yp,
|
|
13159
|
+
am,
|
|
13160
|
+
om
|
|
13161
|
+
] : Yp, mm);
|
|
13162
|
+
Ce.forEach((e) => K.set(e.name, "builtin"));
|
|
13163
|
+
let q = [...e.tools || []];
|
|
13164
|
+
q.forEach((e) => K.set(e.name, "user"));
|
|
13165
|
+
let we = _m(e.actions ?? {});
|
|
13166
|
+
we.forEach((e) => K.set(e.name, "action"));
|
|
13167
|
+
let Te = [], Ee = !1, De = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), Oe = De ? Gl() : null;
|
|
13168
|
+
Oe && K.set(Ul, "builtin");
|
|
13169
|
+
let ke = z && B ? [s(async () => {
|
|
13169
13170
|
let e = B.list();
|
|
13170
13171
|
return e.length ? B.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
13171
13172
|
}, {
|
|
@@ -13180,9 +13181,9 @@ function Um(e, n) {
|
|
|
13180
13181
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
13181
13182
|
schema: t.object({}).optional()
|
|
13182
13183
|
})] : [];
|
|
13183
|
-
|
|
13184
|
-
let
|
|
13185
|
-
let n =
|
|
13184
|
+
ke.forEach((e) => K.set(e.name, "builtin"));
|
|
13185
|
+
let Ae = H.focus, je = s(async ({ path: e, label: t }) => {
|
|
13186
|
+
let n = G()?.schema;
|
|
13186
13187
|
return n ? is(n, e) ? (A.setFocus(j({
|
|
13187
13188
|
path: e,
|
|
13188
13189
|
...t ? { label: t } : {}
|
|
@@ -13194,12 +13195,12 @@ function Um(e, n) {
|
|
|
13194
13195
|
path: t.string().describe("要聚焦的组件 jsonPath,如 components.3"),
|
|
13195
13196
|
label: t.string().optional().describe("人类可读标签,如「导航栏」")
|
|
13196
13197
|
})
|
|
13197
|
-
}),
|
|
13198
|
+
}), Me = s(async () => (A.clearFocus("agent"), "已清除聚焦,恢复全量可操作范围(可读写所有组件)。"), {
|
|
13198
13199
|
name: "clear_focus",
|
|
13199
13200
|
description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
|
|
13200
13201
|
schema: t.object({}).optional()
|
|
13201
|
-
}),
|
|
13202
|
-
let n =
|
|
13202
|
+
}), Ne = s(async ({ path: e, label: t }) => {
|
|
13203
|
+
let n = G()?.schema;
|
|
13203
13204
|
if (!n) return "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
13204
13205
|
if (!is(n, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
|
|
13205
13206
|
A.addFocus(j({
|
|
@@ -13215,7 +13216,7 @@ function Um(e, n) {
|
|
|
13215
13216
|
path: t.string().describe("要追加聚焦的组件 jsonPath,如 components.3"),
|
|
13216
13217
|
label: t.string().optional().describe("人类可读标签")
|
|
13217
13218
|
})
|
|
13218
|
-
}),
|
|
13219
|
+
}), Pe = s(async ({ path: e }) => {
|
|
13219
13220
|
let t = A.getFocuses().length;
|
|
13220
13221
|
A.removeFocus(e, "agent");
|
|
13221
13222
|
let n = A.getFocuses();
|
|
@@ -13224,92 +13225,92 @@ function Um(e, n) {
|
|
|
13224
13225
|
name: "remove_focus",
|
|
13225
13226
|
description: "移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。",
|
|
13226
13227
|
schema: t.object({ path: t.string().describe("要移除的焦点 jsonPath") })
|
|
13227
|
-
}),
|
|
13228
|
+
}), Fe = Ae ? [
|
|
13229
|
+
je,
|
|
13228
13230
|
Me,
|
|
13229
13231
|
Ne,
|
|
13230
|
-
Pe
|
|
13231
|
-
Fe
|
|
13232
|
+
Pe
|
|
13232
13233
|
] : [];
|
|
13233
|
-
|
|
13234
|
-
let
|
|
13235
|
-
function
|
|
13236
|
-
Fi(
|
|
13237
|
-
let { tools: e, collisions: t } =
|
|
13234
|
+
Fe.forEach((e) => K.set(e.name, "builtin"));
|
|
13235
|
+
let Ie = [], Le = /* @__PURE__ */ new Map(), J = Re();
|
|
13236
|
+
function Re() {
|
|
13237
|
+
Fi(q), Fi(we), Fi(Ie);
|
|
13238
|
+
let { tools: e, collisions: t } = Cm([
|
|
13238
13239
|
{
|
|
13239
13240
|
label: "builtin",
|
|
13240
|
-
tools:
|
|
13241
|
+
tools: Ce
|
|
13241
13242
|
},
|
|
13242
13243
|
{
|
|
13243
13244
|
label: "user",
|
|
13244
|
-
tools:
|
|
13245
|
+
tools: q
|
|
13245
13246
|
},
|
|
13246
13247
|
{
|
|
13247
13248
|
label: "action",
|
|
13248
|
-
tools:
|
|
13249
|
+
tools: we
|
|
13249
13250
|
},
|
|
13250
13251
|
{
|
|
13251
13252
|
label: "humanConfirm",
|
|
13252
|
-
tools:
|
|
13253
|
+
tools: Oe ? [Oe] : []
|
|
13253
13254
|
},
|
|
13254
13255
|
{
|
|
13255
13256
|
label: "checkpoint",
|
|
13256
|
-
tools:
|
|
13257
|
+
tools: ke
|
|
13257
13258
|
},
|
|
13258
13259
|
{
|
|
13259
13260
|
label: "focus",
|
|
13260
|
-
tools:
|
|
13261
|
+
tools: Fe
|
|
13261
13262
|
},
|
|
13262
13263
|
{
|
|
13263
13264
|
label: "mcp",
|
|
13264
|
-
tools:
|
|
13265
|
+
tools: Te
|
|
13265
13266
|
},
|
|
13266
13267
|
{
|
|
13267
13268
|
label: "skill",
|
|
13268
|
-
tools:
|
|
13269
|
+
tools: Ie
|
|
13269
13270
|
}
|
|
13270
13271
|
]);
|
|
13271
13272
|
return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
|
|
13272
13273
|
}
|
|
13273
|
-
let
|
|
13274
|
-
if (
|
|
13275
|
-
if (
|
|
13276
|
-
let
|
|
13277
|
-
e.debug &&
|
|
13278
|
-
let
|
|
13279
|
-
|
|
13280
|
-
let
|
|
13274
|
+
let ze = H.planning, Be = H.missionAnchor, Ve = H.workingMemory, He = H.skills, Ue = H.vfs || L;
|
|
13275
|
+
if (Ue) for (let e of Hu) K.set(e, "builtin");
|
|
13276
|
+
if (ze) for (let e of w.tools ?? []) K.set(e.name, "builtin");
|
|
13277
|
+
let We = H.summarization, Ge = H.agentCompression && !!d;
|
|
13278
|
+
e.debug && H.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
13279
|
+
let Ke = H.memory, qe = H.subagent, Je = qe ? ol() : void 0, Ye = e.verify?.maxAttempts ?? 2, Xe = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), Ze = e.capabilities?.verify === !1, Qe = (H.verify || Xe && !Ze) && e.verify?.enabled !== !1 && Ye > 0, $e = H.contextInspector;
|
|
13280
|
+
Xe && !Qe && e.verify?.enabled !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
|
|
13281
|
+
let et = e.subagent, tt = et?.allowedTools ?? [], nt = e.permissions?.length ? Vl(e.permissions) : void 0, rt = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? Hl({
|
|
13281
13282
|
...e.approval,
|
|
13282
13283
|
timeoutMs: e.approval.timeoutMs ?? ne,
|
|
13283
13284
|
onAutoReject: re,
|
|
13284
|
-
previewWrite: e.approval.preview === !0 &&
|
|
13285
|
+
previewWrite: e.approval.preview === !0 && _e ? (e, t) => e === "write" ? _e(t) : null : void 0
|
|
13285
13286
|
}) : void 0, it = [
|
|
13286
13287
|
...nt ? [nt] : [],
|
|
13287
13288
|
...rt ? [rt] : [],
|
|
13288
|
-
...
|
|
13289
|
-
], at = !
|
|
13290
|
-
llm:
|
|
13291
|
-
allTools: () => X.agent?.allTools ??
|
|
13289
|
+
...Se ? [Se] : []
|
|
13290
|
+
], at = !qe || et?.enabled === !1 ? void 0 : El({
|
|
13291
|
+
llm: et?.llm ?? e.llm,
|
|
13292
|
+
allTools: () => X.agent?.allTools ?? J,
|
|
13292
13293
|
allowedTools: tt.length ? tt : void 0,
|
|
13293
13294
|
...e.staleReadInvalidation === void 0 ? {} : { staleReadInvalidation: e.staleReadInvalidation },
|
|
13294
|
-
systemPrompt:
|
|
13295
|
-
temperature:
|
|
13296
|
-
maxTokens:
|
|
13297
|
-
skills:
|
|
13298
|
-
maxDepth:
|
|
13299
|
-
maxParallel:
|
|
13300
|
-
thinkingMode:
|
|
13295
|
+
systemPrompt: et?.systemPrompt,
|
|
13296
|
+
temperature: et?.temperature,
|
|
13297
|
+
maxTokens: et?.maxTokens,
|
|
13298
|
+
skills: et?.skills,
|
|
13299
|
+
maxDepth: et?.maxDepth,
|
|
13300
|
+
maxParallel: et?.maxParallel,
|
|
13301
|
+
thinkingMode: et?.thinkingMode,
|
|
13301
13302
|
debug: e.debug,
|
|
13302
13303
|
getFocuses: () => A.getActiveFocuses(),
|
|
13303
|
-
getSchema: () =>
|
|
13304
|
-
tracker:
|
|
13304
|
+
getSchema: () => G()?.schema ?? null,
|
|
13305
|
+
tracker: Je,
|
|
13305
13306
|
guardMiddleware: it.length ? it : void 0,
|
|
13306
|
-
getVfsFiles:
|
|
13307
|
-
enterDataScope:
|
|
13308
|
-
exitDataScope:
|
|
13307
|
+
getVfsFiles: Ue ? () => C.files : void 0,
|
|
13308
|
+
enterDataScope: W?.enterScope ? (e) => W.enterScope(e) : void 0,
|
|
13309
|
+
exitDataScope: W?.exitScope ? (e) => W.exitScope(e) : void 0,
|
|
13309
13310
|
onUsage: (e) => {
|
|
13310
13311
|
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);
|
|
13311
13312
|
},
|
|
13312
|
-
timeoutMs:
|
|
13313
|
+
timeoutMs: et?.timeoutMs
|
|
13313
13314
|
}), ot = le?.map((e) => {
|
|
13314
13315
|
if (!e._codeAsset) return e;
|
|
13315
13316
|
let t = e._codeAsset, n = qd({
|
|
@@ -13319,88 +13320,88 @@ function Um(e, n) {
|
|
|
13319
13320
|
codeField: t.codeField,
|
|
13320
13321
|
craftNotes: t.craftNotes,
|
|
13321
13322
|
onWarning: (e) => console.warn(`[page-agent-sdk][code-asset] ${e}`),
|
|
13322
|
-
getController: () =>
|
|
13323
|
+
getController: () => W,
|
|
13323
13324
|
vfsStore: C
|
|
13324
13325
|
}), r = [...e.middleware ?? [], n];
|
|
13325
|
-
for (let e of r) e && typeof e == "object" && typeof e._setGetController == "function" && e._setGetController(() =>
|
|
13326
|
+
for (let e of r) e && typeof e == "object" && typeof e._setGetController == "function" && e._setGetController(() => W);
|
|
13326
13327
|
return {
|
|
13327
13328
|
...e,
|
|
13328
13329
|
middleware: r
|
|
13329
13330
|
};
|
|
13330
|
-
}), st = L &&
|
|
13331
|
-
getBind: () =>
|
|
13331
|
+
}), st = L && qe ? Jd() : void 0, ct = st ? tf({
|
|
13332
|
+
getBind: () => G()?.bind,
|
|
13332
13333
|
writablePaths: ue,
|
|
13333
13334
|
getLocked: () => st.locked(),
|
|
13334
|
-
tools:
|
|
13335
|
-
getCodeFieldPaths: () => $d(
|
|
13335
|
+
tools: J,
|
|
13336
|
+
getCodeFieldPaths: () => $d(G()?.bind, ce.map((e) => ({
|
|
13336
13337
|
writablePaths: e._codeAsset.writablePaths,
|
|
13337
13338
|
codeField: e._codeAsset.codeField
|
|
13338
13339
|
})))
|
|
13339
|
-
}) : void 0, lt =
|
|
13340
|
-
getSummarizedPaths: () =>
|
|
13341
|
-
clearSummarizedPaths: () =>
|
|
13342
|
-
}) : void 0, ut =
|
|
13340
|
+
}) : void 0, lt = W?.getSummarizedPaths && W.clearSummarizedPaths ? af({
|
|
13341
|
+
getSummarizedPaths: () => W.getSummarizedPaths(),
|
|
13342
|
+
clearSummarizedPaths: () => W.clearSummarizedPaths()
|
|
13343
|
+
}) : void 0, ut = qe && ot !== void 0 ? kl(ot, {
|
|
13343
13344
|
llm: e.llm,
|
|
13344
13345
|
thinkingModeDefault: e.subagent?.thinkingMode,
|
|
13345
13346
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
13346
|
-
allTools: () => X.agent?.allTools ??
|
|
13347
|
+
allTools: () => X.agent?.allTools ?? J,
|
|
13347
13348
|
debug: e.debug,
|
|
13348
13349
|
getFocuses: () => A.getActiveFocuses(),
|
|
13349
|
-
getSchema: () =>
|
|
13350
|
-
getBind: () =>
|
|
13351
|
-
tracker:
|
|
13350
|
+
getSchema: () => G()?.schema ?? null,
|
|
13351
|
+
getBind: () => G()?.bind,
|
|
13352
|
+
tracker: Je,
|
|
13352
13353
|
guardMiddleware: it.length ? it : void 0,
|
|
13353
|
-
getVfsFiles:
|
|
13354
|
-
enterDataScope:
|
|
13355
|
-
exitDataScope:
|
|
13354
|
+
getVfsFiles: Ue ? () => C.files : void 0,
|
|
13355
|
+
enterDataScope: W?.enterScope ? (e) => W.enterScope(e) : void 0,
|
|
13356
|
+
exitDataScope: W?.exitScope ? (e) => W.exitScope(e) : void 0,
|
|
13356
13357
|
onUsage: (e) => {
|
|
13357
13358
|
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);
|
|
13358
13359
|
},
|
|
13359
13360
|
timeoutMs: e.subagent?.timeoutMs,
|
|
13360
13361
|
...st ? {
|
|
13361
13362
|
componentLock: st,
|
|
13362
|
-
resolveComponents: (e) => Yd(e, Ud(
|
|
13363
|
+
resolveComponents: (e) => Yd(e, Ud(G()?.bind, ue))
|
|
13363
13364
|
} : {}
|
|
13364
13365
|
}) : void 0, dt = ut ? ut.controller : null, ft = (t) => {
|
|
13365
|
-
let n = t.thinkingMode ?? e.subagent?.thinkingMode, r = n ?
|
|
13366
|
+
let n = t.thinkingMode ?? e.subagent?.thinkingMode, r = n ? Gf(t.llm ?? e.llm) ? "instance-noop" : "applied" : "inherited";
|
|
13366
13367
|
return {
|
|
13367
13368
|
...t,
|
|
13368
13369
|
...n ? { thinkingMode: n } : {},
|
|
13369
13370
|
thinkingApplied: r
|
|
13370
13371
|
};
|
|
13371
|
-
}, pt = ["read", "fetch_document"], mt =
|
|
13372
|
+
}, pt = ["read", "fetch_document"], mt = J.filter((e) => pt.includes(e.name)), ht = Qe ? ru({
|
|
13372
13373
|
check: e.verify.check ?? lu({
|
|
13373
|
-
schemas: () =>
|
|
13374
|
-
root: () =>
|
|
13374
|
+
schemas: () => G() ? { "": G().schema } : {},
|
|
13375
|
+
root: () => G()?.bind
|
|
13375
13376
|
}),
|
|
13376
13377
|
adversarial: e.verify?.adversarial ? {
|
|
13377
13378
|
llm: e.llm,
|
|
13378
13379
|
tools: mt
|
|
13379
13380
|
} : void 0
|
|
13380
|
-
}) : void 0, gt =
|
|
13381
|
+
}) : void 0, gt = $e ? Cu({
|
|
13381
13382
|
contextWindow: f.contextWindow,
|
|
13382
|
-
thresholdRatio:
|
|
13383
|
-
}) : void 0, _t =
|
|
13384
|
-
...
|
|
13385
|
-
humanConfirm:
|
|
13383
|
+
thresholdRatio: zp(e, f.contextWindow).summaryThresholdRatio
|
|
13384
|
+
}) : void 0, _t = Tm({
|
|
13385
|
+
...H,
|
|
13386
|
+
humanConfirm: De,
|
|
13386
13387
|
subagents: le?.map(ft)
|
|
13387
|
-
},
|
|
13388
|
+
}, fe && !!N, { promptSoftCap: tl(f.contextWindow, m.promptSoftCapTokens) }), vt = N ? {
|
|
13388
13389
|
name: "dataHint",
|
|
13389
|
-
augmentPrompt: () => ju(
|
|
13390
|
+
augmentPrompt: () => ju(G(), e.schemaHint) || void 0
|
|
13390
13391
|
} : null, yt = e.augmentSystem ? {
|
|
13391
13392
|
name: "augmentSystem",
|
|
13392
13393
|
augmentPrompt: (t) => {
|
|
13393
13394
|
try {
|
|
13394
13395
|
return e.augmentSystem({
|
|
13395
13396
|
state: t,
|
|
13396
|
-
data:
|
|
13397
|
+
data: G()
|
|
13397
13398
|
});
|
|
13398
13399
|
} catch (t) {
|
|
13399
13400
|
e.debug && console.log("[page-agent-sdk][augmentSystem] 回调抛错,降级跳过:", t.message);
|
|
13400
13401
|
return;
|
|
13401
13402
|
}
|
|
13402
13403
|
}
|
|
13403
|
-
} : null, bt =
|
|
13404
|
+
} : null, bt = Ip(e.onEvent), Y = bt.emit, xt, St = [], Ct = (e) => ({
|
|
13404
13405
|
name: e.name,
|
|
13405
13406
|
description: e.description,
|
|
13406
13407
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -13408,7 +13409,7 @@ function Um(e, n) {
|
|
|
13408
13409
|
name: e.name,
|
|
13409
13410
|
description: e.description,
|
|
13410
13411
|
getContent: () => e.content
|
|
13411
|
-
}), Tt = e.skillStorage === !1 ? null :
|
|
13412
|
+
}), Tt = e.skillStorage === !1 ? null : jm({
|
|
13412
13413
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
13413
13414
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
13414
13415
|
}), Et = () => {
|
|
@@ -13431,61 +13432,61 @@ function Um(e, n) {
|
|
|
13431
13432
|
X.infoTick.value++;
|
|
13432
13433
|
}
|
|
13433
13434
|
} catch {}
|
|
13434
|
-
}, Ot =
|
|
13435
|
+
}, Ot = We ? al({
|
|
13435
13436
|
...m,
|
|
13436
13437
|
llmInvoke: l,
|
|
13437
|
-
getRegisteredData: () =>
|
|
13438
|
+
getRegisteredData: () => G() ? [{ description: G().description ?? "主数据对象" }] : [],
|
|
13438
13439
|
preserveLastToolResults: y,
|
|
13439
|
-
...
|
|
13440
|
+
...Ge ? {
|
|
13440
13441
|
decideInvoke: d,
|
|
13441
13442
|
getSnapshot: () => gt?.getSnapshot()
|
|
13442
13443
|
} : {}
|
|
13443
|
-
}) : void 0, kt =
|
|
13444
|
+
}) : void 0, kt = Vp([
|
|
13444
13445
|
...vt ? [vt] : [],
|
|
13445
13446
|
_t,
|
|
13446
|
-
...
|
|
13447
|
+
...Be ? [T] : [],
|
|
13447
13448
|
ee,
|
|
13448
13449
|
D,
|
|
13449
|
-
...
|
|
13450
|
-
...
|
|
13451
|
-
readVfs:
|
|
13450
|
+
...ze ? [w] : [],
|
|
13451
|
+
...He ? [xt = Pc([...H.domInspect && !(e.skills || []).some((e) => e.name === sm.name) ? [sm] : [], ...e.skills || []], {
|
|
13452
|
+
readVfs: Ue ? (e) => C.files[e]?.content : void 0,
|
|
13452
13453
|
onToolsReady: (e, t) => {
|
|
13453
13454
|
for (let n of t) {
|
|
13454
|
-
let t =
|
|
13455
|
-
t >= 0 &&
|
|
13455
|
+
let t = Ie.findIndex((e) => e.name === n.name);
|
|
13456
|
+
t >= 0 && Ie.splice(t, 1), Ie.push(n), Le.set(n.name, e), K.set(n.name, `skill:${e}`);
|
|
13456
13457
|
}
|
|
13457
|
-
|
|
13458
|
+
J = Re(), X.agent && X.agent.setTools(J), X.infoTick.value++;
|
|
13458
13459
|
}
|
|
13459
13460
|
})] : [],
|
|
13460
|
-
...
|
|
13461
|
+
...Ue ? [Wu(C)] : [],
|
|
13461
13462
|
...Ot ? [Ot] : [],
|
|
13462
|
-
...
|
|
13463
|
-
...
|
|
13464
|
-
...
|
|
13465
|
-
...
|
|
13463
|
+
...Ve ? [ae] : [],
|
|
13464
|
+
...Ae ? [A] : [],
|
|
13465
|
+
...ve ? [ve] : [],
|
|
13466
|
+
...Ke ? [M] : [],
|
|
13466
13467
|
...nt ? [nt] : [],
|
|
13467
|
-
...z &&
|
|
13468
|
-
...
|
|
13468
|
+
...z && V && B ? [tu(B)] : [],
|
|
13469
|
+
...De ? [ie] : [],
|
|
13469
13470
|
...rt ? [rt] : [],
|
|
13470
|
-
...
|
|
13471
|
+
...Se ? [Se] : [],
|
|
13471
13472
|
...ht ? [ht] : [],
|
|
13472
13473
|
...at ? [at] : [],
|
|
13473
13474
|
...ut ? [ut] : [],
|
|
13474
13475
|
...ct ? [ct] : [],
|
|
13475
13476
|
...lt ? [lt] : [],
|
|
13476
|
-
...
|
|
13477
|
-
getBind: () =>
|
|
13478
|
-
getTools: () => X.agent?.allTools ??
|
|
13477
|
+
...W && qe ? [cf({
|
|
13478
|
+
getBind: () => G()?.bind,
|
|
13479
|
+
getTools: () => X.agent?.allTools ?? J
|
|
13479
13480
|
})] : [],
|
|
13480
13481
|
...yt ? [yt] : [],
|
|
13481
13482
|
...gt ? [gt] : [],
|
|
13482
13483
|
...e.middleware || [],
|
|
13483
|
-
...
|
|
13484
|
+
...me ? [hm(r, {
|
|
13484
13485
|
tokenBudget: e.tokenBudget,
|
|
13485
13486
|
timeBudgetMs: e.timeBudgetMs
|
|
13486
13487
|
}, Y)] : [],
|
|
13487
|
-
|
|
13488
|
-
]), At = e.maxMemoryRounds ??
|
|
13488
|
+
Hm(Y, S, G, r)
|
|
13489
|
+
]), At = e.maxMemoryRounds ?? Im;
|
|
13489
13490
|
function Mt(e) {
|
|
13490
13491
|
return (e) => {
|
|
13491
13492
|
e.type !== "approval_request" && Y(e);
|
|
@@ -13499,7 +13500,7 @@ function Um(e, n) {
|
|
|
13499
13500
|
e.debug && console.warn("[page-agent-sdk][persist] refreshSessions 失败(已吞):", t);
|
|
13500
13501
|
}
|
|
13501
13502
|
}
|
|
13502
|
-
let Ft =
|
|
13503
|
+
let Ft = Fm(), It = /* @__PURE__ */ new Set();
|
|
13503
13504
|
function Lt(e) {
|
|
13504
13505
|
let t = new AbortController(), n = () => t.abort();
|
|
13505
13506
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), It.add(t), {
|
|
@@ -13532,13 +13533,13 @@ function Um(e, n) {
|
|
|
13532
13533
|
mcpServers: [],
|
|
13533
13534
|
mcpFailed: [],
|
|
13534
13535
|
checkpoint: B,
|
|
13535
|
-
dataOpsController:
|
|
13536
|
+
dataOpsController: W,
|
|
13536
13537
|
skillsController: xt ? xt.controller : null,
|
|
13537
13538
|
infoTick: a,
|
|
13538
13539
|
pendingConflict: i.pendingConflict,
|
|
13539
13540
|
sessions: Nt,
|
|
13540
13541
|
refreshSessions: Pt,
|
|
13541
|
-
liveData:
|
|
13542
|
+
liveData: G,
|
|
13542
13543
|
usage: r,
|
|
13543
13544
|
emit: Y,
|
|
13544
13545
|
runSerial: Ft,
|
|
@@ -13546,20 +13547,20 @@ function Um(e, n) {
|
|
|
13546
13547
|
abortAllActive: Rt,
|
|
13547
13548
|
unloadSkillTools(e) {
|
|
13548
13549
|
if (e) {
|
|
13549
|
-
let t =
|
|
13550
|
-
if (
|
|
13550
|
+
let t = Ie.length;
|
|
13551
|
+
if (Ie = Ie.filter((t) => Le.get(t.name) === e ? (K.delete(t.name), Le.delete(t.name), !1) : !0), Ie.length === t) return;
|
|
13551
13552
|
} else {
|
|
13552
|
-
if (!
|
|
13553
|
-
for (let e of
|
|
13554
|
-
|
|
13553
|
+
if (!Ie.length) return;
|
|
13554
|
+
for (let e of Ie) K.delete(e.name), Le.delete(e.name);
|
|
13555
|
+
Ie = [];
|
|
13555
13556
|
}
|
|
13556
|
-
|
|
13557
|
+
J = Re(), X.agent && X.agent.setTools(J);
|
|
13557
13558
|
},
|
|
13558
13559
|
applySnapshot(t) {
|
|
13559
|
-
if (t.vfs && C.hydrate && C.hydrate(t.vfs), t.messages?.length && (S.push(...Ci(t.messages, (e) => (e ? X.vfsStore?.files?.[e]?.content : void 0) || void 0)), D.markResumed()), t.todos?.length && w.reset(t.todos), t.memory && !e.memory && M.reset(t.memory), t.checkpoints?.length && B && B.importStack(t.checkpoints), t.usage && Object.assign(r, t.usage), t.mission &&
|
|
13560
|
+
if (t.vfs && C.hydrate && C.hydrate(t.vfs), t.messages?.length && (S.push(...Ci(t.messages, (e) => (e ? X.vfsStore?.files?.[e]?.content : void 0) || void 0)), D.markResumed()), t.todos?.length && w.reset(t.todos), t.memory && !e.memory && M.reset(t.memory), t.checkpoints?.length && B && B.importStack(t.checkpoints), t.usage && Object.assign(r, t.usage), t.mission && Be && T.setMission(t.mission), t.workingMemory && Ve && ae.restore(t.workingMemory), t.planConfirmation && (te = t.planConfirmation), Ae) {
|
|
13560
13561
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
13561
13562
|
if (r.length) {
|
|
13562
|
-
let t =
|
|
13563
|
+
let t = G()?.schema, n = t ? r.filter((e) => is(t, e.path)) : [];
|
|
13563
13564
|
if (n.length && (A.setFocus(null), n.forEach((e) => A.addFocus(j(e)))), e.debug && n.length < r.length) {
|
|
13564
13565
|
let e = r.filter((e) => !n.includes(e)).map((e) => e.path);
|
|
13565
13566
|
console.warn("[page-agent-sdk][focus] 恢复的焦点部分 path 已失效(schema 变化/无 schema),剔除:", e);
|
|
@@ -13596,7 +13597,7 @@ function Um(e, n) {
|
|
|
13596
13597
|
},
|
|
13597
13598
|
async send(e, t) {
|
|
13598
13599
|
if (await X.initDone, X.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 send");
|
|
13599
|
-
t ??= {}, t?.mission &&
|
|
13600
|
+
t ??= {}, t?.mission && Be && T.setMission(t.mission);
|
|
13600
13601
|
let n = e, r = (t.images ?? []).filter((e) => e && (e.dataUri || e.vfsRef || e.url));
|
|
13601
13602
|
if (r.length > 4) throw Error(`[page-agent-sdk] 单轮最多 4 张图片(收到 ${r.length})`);
|
|
13602
13603
|
if (r.length && (await Zt(r), await Qt(r, n)), r.length && !f.vision && !r.every((e) => e.description)) {
|
|
@@ -13608,8 +13609,8 @@ function Um(e, n) {
|
|
|
13608
13609
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
13609
13610
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
13610
13611
|
}
|
|
13611
|
-
C?.setProtectedRefs?.(
|
|
13612
|
-
let a =
|
|
13612
|
+
C?.setProtectedRefs?.(Nm(S));
|
|
13613
|
+
let a = me ? t.maxAutoRetries ?? 1 : 0, s = 0, c = !1, l = Mt(t.signal);
|
|
13613
13614
|
if (t.signal) {
|
|
13614
13615
|
let e = () => i.resolve("keep_external");
|
|
13615
13616
|
t.signal.aborted ? e() : t.signal.addEventListener("abort", e, { once: !0 });
|
|
@@ -13683,7 +13684,7 @@ function Um(e, n) {
|
|
|
13683
13684
|
if (await X.initDone, !e.length) return [];
|
|
13684
13685
|
if (X.refCount <= 0) throw Error("page-agent-sdk: agent 已释放(unmount),拒绝排队中的 batch");
|
|
13685
13686
|
let r = [], a = Mt(n);
|
|
13686
|
-
if (C?.setProtectedRefs?.(
|
|
13687
|
+
if (C?.setProtectedRefs?.(Nm(S)), n) {
|
|
13687
13688
|
let e = () => i.resolve("keep_external");
|
|
13688
13689
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
13689
13690
|
}
|
|
@@ -13777,15 +13778,15 @@ function Um(e, n) {
|
|
|
13777
13778
|
async switchSession(t) {
|
|
13778
13779
|
if (await X.initDone, !o) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
|
|
13779
13780
|
if (i.resolve("keep_external"), X.sessionId && o) {
|
|
13780
|
-
if (
|
|
13781
|
+
if (Be) {
|
|
13781
13782
|
let e = T.getMission();
|
|
13782
13783
|
e && Yt({ mission: e });
|
|
13783
13784
|
}
|
|
13784
|
-
if (
|
|
13785
|
+
if (Ve) {
|
|
13785
13786
|
let e = ae.getWorkingMemory();
|
|
13786
13787
|
e && Yt({ workingMemory: e });
|
|
13787
13788
|
}
|
|
13788
|
-
if (
|
|
13789
|
+
if (Ae) {
|
|
13789
13790
|
let e = A.getFocuses();
|
|
13790
13791
|
Yt({ focus: e.length ? e : null });
|
|
13791
13792
|
}
|
|
@@ -13817,7 +13818,7 @@ function Um(e, n) {
|
|
|
13817
13818
|
let r = await o.load(n, t);
|
|
13818
13819
|
if (!r) throw Error(`page-agent-sdk: 会话 ${t} 不存在或无可导出内容`);
|
|
13819
13820
|
return {
|
|
13820
|
-
formatVersion:
|
|
13821
|
+
formatVersion: Lm,
|
|
13821
13822
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13822
13823
|
sessionId: t,
|
|
13823
13824
|
snapshot: r
|
|
@@ -13832,16 +13833,16 @@ function Um(e, n) {
|
|
|
13832
13833
|
throw Error("page-agent-sdk: 导入内容不是合法 JSON");
|
|
13833
13834
|
}
|
|
13834
13835
|
let a = r ?? {};
|
|
13835
|
-
if (typeof r != "object" || !r || a.formatVersion !==
|
|
13836
|
+
if (typeof r != "object" || !r || a.formatVersion !== Lm) throw Error(`page-agent-sdk: 未知会话导出格式(期望 formatVersion=${Lm};请用 sdk.exportSession 的产物)`);
|
|
13836
13837
|
let s = a.snapshot;
|
|
13837
13838
|
if (!s || typeof s != "object" || !Array.isArray(s.messages)) throw Error("page-agent-sdk: 导入内容缺 snapshot.messages(非会话导出文件)");
|
|
13838
13839
|
let c = i || JSON.stringify(a).length;
|
|
13839
|
-
if (c >
|
|
13840
|
+
if (c > Rm) throw Error(`page-agent-sdk: 导入会话超过 ${Math.floor(Rm / 1024 / 1024)}MB 上限(${(c / 1024 / 1024).toFixed(1)}MB)`);
|
|
13840
13841
|
let l = await o.createSession(n, e.session?.title);
|
|
13841
13842
|
return await o.save(n, l, s), Pt(), { sessionId: l };
|
|
13842
13843
|
},
|
|
13843
13844
|
resetSession: () => {
|
|
13844
|
-
Rt(), i.resolve("keep_external"), X.sessionId =
|
|
13845
|
+
Rt(), i.resolve("keep_external"), X.sessionId = ip(), S.splice(0, S.length), C.clear?.(), w.reset([]), e.memory || M.reset(""), T.reset(), ae.reset(), A.reset(), Ot?.reset(), D.reset(), te = void 0, B && B.importStack([]), X.agent && (X.agent.debugLogs.value = [], X.agent.resetSessionCounters?.()), o && o.createSession(X.agentId, e.session?.title, X.sessionId).catch((t) => {
|
|
13845
13846
|
e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
|
|
13846
13847
|
}), Y({
|
|
13847
13848
|
type: "session_restored",
|
|
@@ -13861,7 +13862,7 @@ function Um(e, n) {
|
|
|
13861
13862
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
13862
13863
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
13863
13864
|
}
|
|
13864
|
-
C?.setProtectedRefs?.(
|
|
13865
|
+
C?.setProtectedRefs?.(Nm(e));
|
|
13865
13866
|
let a = (e) => {
|
|
13866
13867
|
t?.(e), Y(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && X.infoTick.value++;
|
|
13867
13868
|
};
|
|
@@ -13874,36 +13875,36 @@ function Um(e, n) {
|
|
|
13874
13875
|
},
|
|
13875
13876
|
release() {
|
|
13876
13877
|
if (X.refCount--, X.refCount <= 0) {
|
|
13877
|
-
Rt(),
|
|
13878
|
+
Rt(), Ee = !0, o && (C.flush?.(), o.flush(), o.dispose()), Tt && Tt.dispose();
|
|
13878
13879
|
let e = X.mcpClosers.splice(0);
|
|
13879
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
13880
|
+
e.length && Promise.allSettled(e.map((e) => e())), zm.delete(n);
|
|
13880
13881
|
}
|
|
13881
13882
|
},
|
|
13882
13883
|
resolveConflict: i.resolve,
|
|
13883
13884
|
setTools(e) {
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
}),
|
|
13885
|
+
q.length = 0, e.forEach((e) => {
|
|
13886
|
+
q.push(e), K.set(e.name, "user");
|
|
13887
|
+
}), J = Re(), X.agent && X.agent.setTools(J), X.infoTick.value++;
|
|
13887
13888
|
},
|
|
13888
13889
|
addTool(e) {
|
|
13889
|
-
|
|
13890
|
-
for (let t =
|
|
13891
|
-
|
|
13890
|
+
J.some((t) => t.name === e.name) && console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);
|
|
13891
|
+
for (let t = q.length - 1; t >= 0; t--) q[t].name === e.name && q.splice(t, 1);
|
|
13892
|
+
q.push(e), K.set(e.name, "user"), J = Re(), X.agent && X.agent.setTools(J), X.infoTick.value++;
|
|
13892
13893
|
},
|
|
13893
13894
|
removeTool(e) {
|
|
13894
|
-
let t =
|
|
13895
|
-
return t < 0 ? !1 : (
|
|
13895
|
+
let t = q.findIndex((t) => t.name === e);
|
|
13896
|
+
return t < 0 ? !1 : (q.splice(t, 1), K.delete(e), J = Re(), X.agent && X.agent.setTools(J), X.infoTick.value++, !0);
|
|
13896
13897
|
},
|
|
13897
13898
|
setLlm(t) {
|
|
13898
13899
|
let n;
|
|
13899
|
-
if (
|
|
13900
|
+
if (Gf(t)) n = t;
|
|
13900
13901
|
else {
|
|
13901
13902
|
let e = t;
|
|
13902
13903
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
13903
13904
|
n = E(e);
|
|
13904
13905
|
}
|
|
13905
|
-
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"),
|
|
13906
|
-
let r =
|
|
13906
|
+
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), qf(n, { emit: Y }), x = t;
|
|
13907
|
+
let r = Gf(t) ? void 0 : t;
|
|
13907
13908
|
if (f = v({
|
|
13908
13909
|
model: r?.model ?? t.model ?? t.modelName,
|
|
13909
13910
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
@@ -13938,30 +13939,30 @@ function Um(e, n) {
|
|
|
13938
13939
|
return n && X.infoTick.value++, n;
|
|
13939
13940
|
},
|
|
13940
13941
|
getActiveSubagents() {
|
|
13941
|
-
return
|
|
13942
|
+
return Je?.getActive() ?? [];
|
|
13942
13943
|
},
|
|
13943
13944
|
get subagentHistory() {
|
|
13944
|
-
return
|
|
13945
|
+
return Je?.getHistory() ?? [];
|
|
13945
13946
|
},
|
|
13946
13947
|
getInfo() {
|
|
13947
13948
|
return {
|
|
13948
13949
|
id: n,
|
|
13949
13950
|
sessionId: X.sessionId,
|
|
13950
|
-
model:
|
|
13951
|
-
systemPrompt: X.agent?.getEffectiveSystemPrompt?.() ??
|
|
13952
|
-
tools: (X.agent?.allTools ??
|
|
13951
|
+
model: Gf(x) ? x.model ?? x.modelName : x.model,
|
|
13952
|
+
systemPrompt: X.agent?.getEffectiveSystemPrompt?.() ?? U + ju(G(), e.schemaHint),
|
|
13953
|
+
tools: (X.agent?.allTools ?? J).map((e) => ({
|
|
13953
13954
|
name: e.name,
|
|
13954
13955
|
description: e.description,
|
|
13955
13956
|
schema: e.schema,
|
|
13956
|
-
source:
|
|
13957
|
+
source: K.get(e.name) || "user"
|
|
13957
13958
|
})),
|
|
13958
13959
|
skills: (xt ? xt.controller.get() : e.skills ?? []).map((e) => ({
|
|
13959
13960
|
name: e.name,
|
|
13960
13961
|
description: e.description
|
|
13961
13962
|
})),
|
|
13962
|
-
data:
|
|
13963
|
-
description:
|
|
13964
|
-
schema:
|
|
13963
|
+
data: G() ? {
|
|
13964
|
+
description: G().description,
|
|
13965
|
+
schema: G().schema
|
|
13965
13966
|
} : void 0,
|
|
13966
13967
|
contextPreset: e.contextPreset ?? "auto",
|
|
13967
13968
|
compression: {
|
|
@@ -13984,12 +13985,12 @@ function Um(e, n) {
|
|
|
13984
13985
|
...e.evidence === void 0 ? {} : { evidence: e.evidence }
|
|
13985
13986
|
})),
|
|
13986
13987
|
planPhase: w.getPlanPhase(),
|
|
13987
|
-
mission:
|
|
13988
|
+
mission: Be ? T.getMission() : void 0,
|
|
13988
13989
|
planConfirmation: te,
|
|
13989
|
-
workingMemory:
|
|
13990
|
-
focus:
|
|
13991
|
-
focuses:
|
|
13992
|
-
actions:
|
|
13990
|
+
workingMemory: Ve ? ae.getWorkingMemory() : void 0,
|
|
13991
|
+
focus: Ae ? A.getFocus() : void 0,
|
|
13992
|
+
focuses: Ae ? A.getFocuses() : [],
|
|
13993
|
+
actions: vm(e.actions ?? {}),
|
|
13993
13994
|
subagent: {
|
|
13994
13995
|
enabled: !!at,
|
|
13995
13996
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -13997,14 +13998,14 @@ function Um(e, n) {
|
|
|
13997
13998
|
timeoutMs: e.subagent?.timeoutMs === void 0 ? 18e5 : e.subagent.timeoutMs > 0 ? e.subagent.timeoutMs : 0,
|
|
13998
13999
|
allowedTools: e.subagent?.allowedTools ?? [],
|
|
13999
14000
|
subagents: (dt?.get() ?? []).map(ft),
|
|
14000
|
-
active:
|
|
14001
|
-
history:
|
|
14001
|
+
active: Je?.getActive() ?? [],
|
|
14002
|
+
history: Je?.getHistory() ?? [],
|
|
14002
14003
|
lockedComponents: st?.locked() ?? {}
|
|
14003
14004
|
},
|
|
14004
14005
|
verify: {
|
|
14005
14006
|
enabled: !!ht,
|
|
14006
|
-
maxAttempts:
|
|
14007
|
-
adversarial:
|
|
14007
|
+
maxAttempts: Qe ? Ye : 0,
|
|
14008
|
+
adversarial: Qe && !!e.verify?.adversarial
|
|
14008
14009
|
},
|
|
14009
14010
|
context: (() => {
|
|
14010
14011
|
let e = gt?.getSnapshot();
|
|
@@ -14021,7 +14022,7 @@ function Um(e, n) {
|
|
|
14021
14022
|
lastCompression: X.agent?.getState?.()?.lastCompression,
|
|
14022
14023
|
checkpoints: B ? {
|
|
14023
14024
|
enabled: !0,
|
|
14024
|
-
auto:
|
|
14025
|
+
auto: V,
|
|
14025
14026
|
list: B.list()
|
|
14026
14027
|
} : void 0
|
|
14027
14028
|
};
|
|
@@ -14060,37 +14061,37 @@ function Um(e, n) {
|
|
|
14060
14061
|
}));
|
|
14061
14062
|
},
|
|
14062
14063
|
getMission() {
|
|
14063
|
-
return
|
|
14064
|
+
return Be ? T.getMission() : void 0;
|
|
14064
14065
|
},
|
|
14065
14066
|
setMission(t) {
|
|
14066
|
-
if (!
|
|
14067
|
+
if (!Be) {
|
|
14067
14068
|
e.debug && console.warn("[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略");
|
|
14068
14069
|
return;
|
|
14069
14070
|
}
|
|
14070
14071
|
T.setMission(t), X.infoTick.value++;
|
|
14071
14072
|
},
|
|
14072
14073
|
getFocus() {
|
|
14073
|
-
return
|
|
14074
|
+
return Ae ? A.getFocus() : void 0;
|
|
14074
14075
|
},
|
|
14075
14076
|
getFocuses() {
|
|
14076
|
-
return
|
|
14077
|
+
return Ae ? A.getFocuses() : [];
|
|
14077
14078
|
},
|
|
14078
14079
|
setFocus(t) {
|
|
14079
|
-
let n =
|
|
14080
|
+
let n = Um(t, "setFocus", Ae, () => G()?.schema, e.debug);
|
|
14080
14081
|
return n.ok ? (A.setFocus(j(t)), e.debug && A.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), X.infoTick.value++, { ok: !0 }) : n;
|
|
14081
14082
|
},
|
|
14082
14083
|
addFocus(t) {
|
|
14083
|
-
let n =
|
|
14084
|
+
let n = Um(t, "addFocus", Ae, () => G()?.schema, e.debug);
|
|
14084
14085
|
return n.ok ? A.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
14085
14086
|
ok: !1,
|
|
14086
14087
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
14087
14088
|
}) : (A.addFocus(j(t)), e.debug && A.isInvokeActive() && console.info("[page-agent-sdk][focus] 在途流程进行中,聚焦将在下一次输入生效(当前流程不受影响)"), X.infoTick.value++, { ok: !0 }) : n;
|
|
14088
14089
|
},
|
|
14089
14090
|
removeFocus(e) {
|
|
14090
|
-
|
|
14091
|
+
Ae && (A.removeFocus(e), X.infoTick.value++);
|
|
14091
14092
|
},
|
|
14092
14093
|
clearFocus() {
|
|
14093
|
-
|
|
14094
|
+
Ae && (A.clearFocus(), X.infoTick.value++);
|
|
14094
14095
|
}
|
|
14095
14096
|
};
|
|
14096
14097
|
async function zt() {
|
|
@@ -14154,14 +14155,14 @@ function Um(e, n) {
|
|
|
14154
14155
|
}
|
|
14155
14156
|
function Vt(e) {
|
|
14156
14157
|
let t = {};
|
|
14157
|
-
for (let n of
|
|
14158
|
+
for (let n of Nm(e)) {
|
|
14158
14159
|
let e = C.files[n];
|
|
14159
14160
|
e && (t[n] = e.content);
|
|
14160
14161
|
}
|
|
14161
14162
|
return t;
|
|
14162
14163
|
}
|
|
14163
14164
|
function Ht() {
|
|
14164
|
-
let e =
|
|
14165
|
+
let e = Pm(C.files, Nm(S));
|
|
14165
14166
|
for (let t of e) delete C.files[t];
|
|
14166
14167
|
}
|
|
14167
14168
|
function Wt() {
|
|
@@ -14252,20 +14253,20 @@ function Um(e, n) {
|
|
|
14252
14253
|
}
|
|
14253
14254
|
function $t() {
|
|
14254
14255
|
if (!X.sessionId || !o) return;
|
|
14255
|
-
if (Yt({ messages: Si(JSON.parse(JSON.stringify(S))) }), Yt({ todos: X.agent?.getState?.()?.todos ?? [] }), Yt({ planConfirmation: te }),
|
|
14256
|
+
if (Yt({ messages: Si(JSON.parse(JSON.stringify(S))) }), Yt({ todos: X.agent?.getState?.()?.todos ?? [] }), Yt({ planConfirmation: te }), Be) {
|
|
14256
14257
|
let e = T.getMission();
|
|
14257
14258
|
e && Yt({ mission: e });
|
|
14258
14259
|
}
|
|
14259
|
-
if (
|
|
14260
|
+
if (Ve) {
|
|
14260
14261
|
let e = ae.getWorkingMemory();
|
|
14261
14262
|
e && Yt({ workingMemory: e });
|
|
14262
14263
|
}
|
|
14263
|
-
if (
|
|
14264
|
+
if (Ae) {
|
|
14264
14265
|
let e = A.getFocuses();
|
|
14265
14266
|
Yt({ focus: e.length ? e : null });
|
|
14266
14267
|
}
|
|
14267
|
-
|
|
14268
|
-
let t =
|
|
14268
|
+
me && B && (Yt({ checkpoints: B.exportStack() }), Yt({ usage: r }));
|
|
14269
|
+
let t = Uf(S);
|
|
14269
14270
|
if (t && t !== Gt && (Gt = t, Xt(X.sessionId, t)), e.autoTitle !== !1 && u && !Kt && S.some((e) => e.role === "user") && S.some((e) => e.role === "assistant")) {
|
|
14270
14271
|
Kt = !0;
|
|
14271
14272
|
let e = X.sessionId;
|
|
@@ -14296,8 +14297,8 @@ function Um(e, n) {
|
|
|
14296
14297
|
}
|
|
14297
14298
|
throw t;
|
|
14298
14299
|
}, n = /* @__PURE__ */ new Set();
|
|
14299
|
-
for (let e of
|
|
14300
|
-
let t =
|
|
14300
|
+
for (let e of J) {
|
|
14301
|
+
let t = K.get(e.name);
|
|
14301
14302
|
t && !t.startsWith("mcp:") && n.add(e.name);
|
|
14302
14303
|
}
|
|
14303
14304
|
let r = 0, i = e.mcp.length;
|
|
@@ -14305,7 +14306,7 @@ function Um(e, n) {
|
|
|
14305
14306
|
let o = a.name ?? a.url, s = !1;
|
|
14306
14307
|
try {
|
|
14307
14308
|
let e = await t(a);
|
|
14308
|
-
if (
|
|
14309
|
+
if (Ee) {
|
|
14309
14310
|
e.close();
|
|
14310
14311
|
return;
|
|
14311
14312
|
}
|
|
@@ -14318,10 +14319,10 @@ function Um(e, n) {
|
|
|
14318
14319
|
console.warn(`[page-agent-sdk][mcp] 工具 "${e.name}" 与内置工具重名,已拒绝注入(安全保留字保护)`);
|
|
14319
14320
|
return;
|
|
14320
14321
|
}
|
|
14321
|
-
|
|
14322
|
-
}), s && (
|
|
14322
|
+
K.set(e.name, `mcp:${o}`), Te.push(e), s = !0;
|
|
14323
|
+
}), s && (J = Re(), X.agent && X.agent.setTools(J), X.infoTick.value++);
|
|
14323
14324
|
} catch (e) {
|
|
14324
|
-
if (
|
|
14325
|
+
if (Ee) return;
|
|
14325
14326
|
console.warn(`[page-agent-sdk][mcp] server ${o} 连接失败:`, e);
|
|
14326
14327
|
let t = String(e?.message ?? e ?? "").slice(0, 200);
|
|
14327
14328
|
X.mcpFailed.push({
|
|
@@ -14339,18 +14340,18 @@ function Um(e, n) {
|
|
|
14339
14340
|
}
|
|
14340
14341
|
});
|
|
14341
14342
|
} finally {
|
|
14342
|
-
r++, r === i && e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${
|
|
14343
|
+
r++, r === i && e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${Te.length} 个工具,${X.mcpServers.length} 个 server`);
|
|
14343
14344
|
}
|
|
14344
14345
|
}));
|
|
14345
14346
|
})();
|
|
14346
|
-
let t =
|
|
14347
|
-
|
|
14347
|
+
let t = Gf(e.llm) ? e.llm : await O(e.llm);
|
|
14348
|
+
qf(t, { emit: Y }), X.agent = es({
|
|
14348
14349
|
llm: t,
|
|
14349
|
-
systemPrompt:
|
|
14350
|
-
tools:
|
|
14350
|
+
systemPrompt: U,
|
|
14351
|
+
tools: J,
|
|
14351
14352
|
middleware: kt,
|
|
14352
14353
|
maxToolRounds: e.maxToolRounds,
|
|
14353
|
-
hasSubagent:
|
|
14354
|
+
hasSubagent: qe,
|
|
14354
14355
|
maxRetries: e.maxRetries,
|
|
14355
14356
|
stallMs: e.streamStallMs ?? 9e4,
|
|
14356
14357
|
streamMaxMs: e.streamMaxDurationMs ?? 18e5,
|
|
@@ -14359,8 +14360,8 @@ function Um(e, n) {
|
|
|
14359
14360
|
contextWindow: f.contextWindow,
|
|
14360
14361
|
maxOutputTokens: f.maxOutputTokens,
|
|
14361
14362
|
vision: f.vision,
|
|
14362
|
-
imageContentFormat: !
|
|
14363
|
-
maxVerifyAttempts:
|
|
14363
|
+
imageContentFormat: !Gf(e.llm) && (e.llm.provider ?? "openai") === "anthropic" ? "anthropic" : "openai",
|
|
14364
|
+
maxVerifyAttempts: Qe ? Ye : 0,
|
|
14364
14365
|
roundTokenBudget: e.roundTokenBudget ?? 0,
|
|
14365
14366
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
14366
14367
|
onLlmChange: (e) => {
|
|
@@ -14368,16 +14369,16 @@ function Um(e, n) {
|
|
|
14368
14369
|
},
|
|
14369
14370
|
debug: e.debug
|
|
14370
14371
|
}), oe.current = X.agent, ut && ut.setReconfigureHook && ut.setReconfigureHook(() => {
|
|
14371
|
-
X.agent && X.agent.setTools(
|
|
14372
|
+
X.agent && X.agent.setTools(Re());
|
|
14372
14373
|
});
|
|
14373
14374
|
})(), X;
|
|
14374
14375
|
}
|
|
14375
|
-
function
|
|
14376
|
-
let n = e.id ??
|
|
14376
|
+
function Gm(e, t) {
|
|
14377
|
+
let n = e.id ?? ip();
|
|
14377
14378
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
14378
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
14379
|
-
o ? a = o : (a =
|
|
14380
|
-
let s = null, c =
|
|
14379
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? zm.get(n) : void 0;
|
|
14380
|
+
o ? a = o : (a = Wm(e, n), e.shareContext && zm.set(n, a)), a.refCount++;
|
|
14381
|
+
let s = null, c = Np(e), l = null, u = null;
|
|
14381
14382
|
async function d(n) {
|
|
14382
14383
|
if (await a.initDone, s) {
|
|
14383
14384
|
s.show();
|
|
@@ -14606,7 +14607,7 @@ function Wm(e, t) {
|
|
|
14606
14607
|
}
|
|
14607
14608
|
//#endregion
|
|
14608
14609
|
//#region src/core/sdk/ragSubagent.ts
|
|
14609
|
-
function
|
|
14610
|
+
function Km(e, t, n, r, i) {
|
|
14610
14611
|
let a = [];
|
|
14611
14612
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
14612
14613
|
let o = [];
|
|
@@ -14621,7 +14622,7 @@ function Gm(e, t, n, r, i) {
|
|
|
14621
14622
|
|
|
14622
14623
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
14623
14624
|
}
|
|
14624
|
-
function
|
|
14625
|
+
function qm(e, t, n, r, i) {
|
|
14625
14626
|
let a = [], o = [];
|
|
14626
14627
|
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)
|
|
14627
14628
|
|
|
@@ -14638,12 +14639,12 @@ ${a.join("\n")}
|
|
|
14638
14639
|
## 何时用何源
|
|
14639
14640
|
${o.join("\n")}`;
|
|
14640
14641
|
}
|
|
14641
|
-
var
|
|
14642
|
+
var Jm = {
|
|
14642
14643
|
name: "rag-search",
|
|
14643
14644
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
14644
|
-
getContent: () =>
|
|
14645
|
+
getContent: () => qm(!0, !0, !0, "search_docs", "load_doc")
|
|
14645
14646
|
};
|
|
14646
|
-
function
|
|
14647
|
+
function Ym(e, n, r) {
|
|
14647
14648
|
let i = s(async ({ query: e, topK: t }) => {
|
|
14648
14649
|
try {
|
|
14649
14650
|
let i = await n(e, { topK: t ?? r });
|
|
@@ -14661,7 +14662,7 @@ function Jm(e, n, r) {
|
|
|
14661
14662
|
});
|
|
14662
14663
|
return Fi([i]), i;
|
|
14663
14664
|
}
|
|
14664
|
-
function
|
|
14665
|
+
function Xm(e, n) {
|
|
14665
14666
|
let r = s(async ({ source: e }) => {
|
|
14666
14667
|
try {
|
|
14667
14668
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -14676,19 +14677,19 @@ function Ym(e, n) {
|
|
|
14676
14677
|
});
|
|
14677
14678
|
return Fi([r]), r;
|
|
14678
14679
|
}
|
|
14679
|
-
function
|
|
14680
|
+
function Zm(e) {
|
|
14680
14681
|
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;
|
|
14681
14682
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
14682
14683
|
let p = [];
|
|
14683
|
-
t && p.push(
|
|
14684
|
+
t && p.push(Ym(s, t, o)), n && p.push(Xm(c, n)), f && p.push(...f);
|
|
14684
14685
|
let m = r ? [
|
|
14685
14686
|
"vfs_grep",
|
|
14686
14687
|
"vfs_read",
|
|
14687
14688
|
"vfs_json_read"
|
|
14688
|
-
] : void 0, h =
|
|
14689
|
+
] : void 0, h = Km(r, !!t, !!n, s, c), g = {
|
|
14689
14690
|
name: "rag-search",
|
|
14690
|
-
description:
|
|
14691
|
-
getContent: () =>
|
|
14691
|
+
description: Jm.description,
|
|
14692
|
+
getContent: () => qm(r, !!t, !!n, s, c)
|
|
14692
14693
|
};
|
|
14693
14694
|
return {
|
|
14694
14695
|
id: i,
|
|
@@ -14703,7 +14704,7 @@ function Xm(e) {
|
|
|
14703
14704
|
}
|
|
14704
14705
|
//#endregion
|
|
14705
14706
|
//#region src/core/sdk/evalToolkit.ts
|
|
14706
|
-
function
|
|
14707
|
+
function Qm(e = {}) {
|
|
14707
14708
|
let t = e.quietMs ?? 9e4, n = e.confirmSamples ?? 3, r = e.baselineMessageCount ?? 0, i = 0;
|
|
14708
14709
|
return {
|
|
14709
14710
|
push(e) {
|
|
@@ -14714,12 +14715,12 @@ function Zm(e = {}) {
|
|
|
14714
14715
|
}
|
|
14715
14716
|
};
|
|
14716
14717
|
}
|
|
14717
|
-
var
|
|
14718
|
-
function
|
|
14718
|
+
var $m = /* @__PURE__ */ new Set(["elapsedSec"]);
|
|
14719
|
+
function eh(e, t, n = {}) {
|
|
14719
14720
|
let r = n.tokenAbs ?? 2e3, i = n.tokenPct ?? 15, a = n.toolCountAbs ?? 3, o = [], s = 0, c = 0, l = 0, u = /* @__PURE__ */ new Set([...Object.keys(e ?? {}), ...Object.keys(t ?? {})]);
|
|
14720
14721
|
for (let n of u) {
|
|
14721
14722
|
let u = Number(e?.[n] ?? 0), d = Number(t?.[n] ?? 0), f = u - d, p = d > 0 ? Math.round(f / d * 100) : 0, m = "";
|
|
14722
|
-
|
|
14723
|
+
$m.has(n) || (n === "toolCount" ? Math.abs(f) > a : Math.abs(f) > r && Math.abs(p) >= i) && (m = f > 0 ? "up" : "down", m === "up" ? (s++, c++) : l++), o.push({
|
|
14723
14724
|
key: n,
|
|
14724
14725
|
prev: d,
|
|
14725
14726
|
cur: u,
|
|
@@ -14734,7 +14735,7 @@ function $m(e, t, n = {}) {
|
|
|
14734
14735
|
fields: o
|
|
14735
14736
|
};
|
|
14736
14737
|
}
|
|
14737
|
-
function
|
|
14738
|
+
function th(e) {
|
|
14738
14739
|
let { sdk: t } = e, n = () => {
|
|
14739
14740
|
let e = t.debugLogs.value ?? [], n = e.length ? e[e.length - 1].timestamp : 0;
|
|
14740
14741
|
return {
|
|
@@ -14747,7 +14748,7 @@ function eh(e) {
|
|
|
14747
14748
|
};
|
|
14748
14749
|
return {
|
|
14749
14750
|
async waitForIdle(e = {}) {
|
|
14750
|
-
let { timeoutMs: r = 6e5, sampleMs: i = 2500, onSample: a, ...o } = e, s =
|
|
14751
|
+
let { timeoutMs: r = 6e5, sampleMs: i = 2500, onSample: a, ...o } = e, s = Qm(o), c = Date.now();
|
|
14751
14752
|
for (;;) {
|
|
14752
14753
|
let e = n(), o = s.push(e);
|
|
14753
14754
|
if (a?.(e), o === "done") return e;
|
|
@@ -14777,7 +14778,7 @@ function eh(e) {
|
|
|
14777
14778
|
}
|
|
14778
14779
|
//#endregion
|
|
14779
14780
|
//#region src/core/utils/clipboard.ts
|
|
14780
|
-
async function
|
|
14781
|
+
async function nh(e) {
|
|
14781
14782
|
try {
|
|
14782
14783
|
let t = globalThis.navigator?.clipboard;
|
|
14783
14784
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -14795,8 +14796,8 @@ async function th(e) {
|
|
|
14795
14796
|
}
|
|
14796
14797
|
//#endregion
|
|
14797
14798
|
//#region src/core/composables/useChat.ts
|
|
14798
|
-
var
|
|
14799
|
-
function
|
|
14799
|
+
var rh = 4e3;
|
|
14800
|
+
function ih(e = {}) {
|
|
14800
14801
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */ jt({
|
|
14801
14802
|
messages: e.messages ?? [],
|
|
14802
14803
|
loading: !1,
|
|
@@ -14876,7 +14877,7 @@ function rh(e = {}) {
|
|
|
14876
14877
|
let t = e.delta || "";
|
|
14877
14878
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
14878
14879
|
let r = (n.subReason || "") + t;
|
|
14879
|
-
n.subReason = r.length >
|
|
14880
|
+
n.subReason = r.length > rh ? r.slice(-4e3) : r;
|
|
14880
14881
|
break;
|
|
14881
14882
|
}
|
|
14882
14883
|
n.children ||= [];
|
|
@@ -15007,7 +15008,7 @@ function rh(e = {}) {
|
|
|
15007
15008
|
}
|
|
15008
15009
|
//#endregion
|
|
15009
15010
|
//#region src/core/components/icons.ts
|
|
15010
|
-
var
|
|
15011
|
+
var ah = {
|
|
15011
15012
|
header: "🤖",
|
|
15012
15013
|
subagent: "🤖",
|
|
15013
15014
|
subagentProgress: "🧬",
|
|
@@ -15018,10 +15019,10 @@ var ih = {
|
|
|
15018
15019
|
recommend: "💡",
|
|
15019
15020
|
conflict: "⚠️"
|
|
15020
15021
|
};
|
|
15021
|
-
function
|
|
15022
|
-
let t = { ...
|
|
15022
|
+
function oh(e) {
|
|
15023
|
+
let t = { ...ah };
|
|
15023
15024
|
if (!e) return t;
|
|
15024
|
-
let n = Object.keys(
|
|
15025
|
+
let n = Object.keys(ah);
|
|
15025
15026
|
for (let r of n) {
|
|
15026
15027
|
let n = e[r];
|
|
15027
15028
|
typeof n == "string" && (t[r] = n);
|
|
@@ -15030,7 +15031,7 @@ function ah(e) {
|
|
|
15030
15031
|
}
|
|
15031
15032
|
//#endregion
|
|
15032
15033
|
//#region src/core/components/messages.ts
|
|
15033
|
-
var
|
|
15034
|
+
var sh = {
|
|
15034
15035
|
defaultTitle: "AI 助手",
|
|
15035
15036
|
inputPlaceholder: "输入消息,Enter 发送...",
|
|
15036
15037
|
newSession: "新建会话",
|
|
@@ -15257,8 +15258,8 @@ var oh = {
|
|
|
15257
15258
|
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
15258
15259
|
codeDemoButton: "按钮",
|
|
15259
15260
|
codeDemoInput: "输入框"
|
|
15260
|
-
},
|
|
15261
|
-
"zh-CN":
|
|
15261
|
+
}, ch = {
|
|
15262
|
+
"zh-CN": sh,
|
|
15262
15263
|
"en-US": {
|
|
15263
15264
|
defaultTitle: "AI Assistant",
|
|
15264
15265
|
inputPlaceholder: "Type a message, Enter to send...",
|
|
@@ -15488,10 +15489,10 @@ var oh = {
|
|
|
15488
15489
|
codeDemoInput: "Input"
|
|
15489
15490
|
}
|
|
15490
15491
|
};
|
|
15491
|
-
function
|
|
15492
|
+
function lh(e = "zh-CN", t) {
|
|
15492
15493
|
let n = {
|
|
15493
|
-
...
|
|
15494
|
-
...
|
|
15494
|
+
...sh,
|
|
15495
|
+
...ch[e]
|
|
15495
15496
|
};
|
|
15496
15497
|
if (!t) return n;
|
|
15497
15498
|
let r = { ...n };
|
|
@@ -15503,9 +15504,9 @@ function ch(e = "zh-CN", t) {
|
|
|
15503
15504
|
}
|
|
15504
15505
|
//#endregion
|
|
15505
15506
|
//#region src/core/composables/chatContext.ts
|
|
15506
|
-
var
|
|
15507
|
-
function
|
|
15508
|
-
let t =
|
|
15507
|
+
var uh = Symbol("chatContext");
|
|
15508
|
+
function dh(e = {}) {
|
|
15509
|
+
let t = ih({
|
|
15509
15510
|
fetchResponse: e.fetchResponse,
|
|
15510
15511
|
fetchStream: e.fetchStream,
|
|
15511
15512
|
messages: e.messages,
|
|
@@ -15527,7 +15528,7 @@ function uh(e = {}) {
|
|
|
15527
15528
|
}, h = /* @__PURE__ */ Ut({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
15528
15529
|
h.value[e] = !g(e);
|
|
15529
15530
|
}, v = /* @__PURE__ */ Ut(!1), y = (e) => {
|
|
15530
|
-
|
|
15531
|
+
nh(e).then((e) => {
|
|
15531
15532
|
e && (v.value = !0, setTimeout(() => {
|
|
15532
15533
|
v.value = !1;
|
|
15533
15534
|
}, 1500));
|
|
@@ -15589,7 +15590,7 @@ function uh(e = {}) {
|
|
|
15589
15590
|
e.onClearFocus?.();
|
|
15590
15591
|
}, N = (t) => {
|
|
15591
15592
|
e.onFocusChipClick?.(t);
|
|
15592
|
-
}, P =
|
|
15593
|
+
}, P = oh(e.icons), se = e.locale ?? "zh-CN", F = lh(se, e.dialogMessages);
|
|
15593
15594
|
return {
|
|
15594
15595
|
chat: t,
|
|
15595
15596
|
inputText: o,
|
|
@@ -15631,15 +15632,15 @@ function uh(e = {}) {
|
|
|
15631
15632
|
toolStepView: e.toolStepView
|
|
15632
15633
|
};
|
|
15633
15634
|
}
|
|
15634
|
-
function
|
|
15635
|
-
let e = Zn(
|
|
15635
|
+
function fh() {
|
|
15636
|
+
let e = Zn(uh);
|
|
15636
15637
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
15637
15638
|
return e;
|
|
15638
15639
|
}
|
|
15639
15640
|
//#endregion
|
|
15640
15641
|
//#region src/core/index.headless.ts
|
|
15641
|
-
function
|
|
15642
|
-
return
|
|
15642
|
+
function ph(e) {
|
|
15643
|
+
return Gm(e);
|
|
15643
15644
|
}
|
|
15644
15645
|
//#endregion
|
|
15645
|
-
export {
|
|
15646
|
+
export { Pp as CAPABILITIES, Lp as CONTEXT_PRESETS, Hf as CompressDecisionSchema, Xp as DEFAULT_COMPUTED_STYLES, $c as DEFAULT_PROMPT_SOFT_CAP, ku as DEFAULT_SYSTEM_PROMPT, Au as DEFAULT_SYSTEM_PROMPT_EN, Ad as HTML_VOID_TAGS, Ul as HUMAN_CONFIRM_TOOL_NAME, hi as ImageInputError, g as LOW_CAPS_HINT_BASELINE, p as MIN_CONTEXT_WINDOW, Qi as MODEL_UNAVAILABLE_GUIDANCE, Qc as SOFT_CAP_MIN_WINDOW, Wc as STOP_WORDS, Gs as UNSAFE_KEYS, vm as actionsToInspectInfo, _m as actionsToTools, di as agentError, Su as analyzeContext, ic as applyPatchToClone, sc as applyPatchToLive, vd as applyPatchesToBind, us as arrayMinLength, ui as asAgentError, Sf as buildCollectorJs, tm as buildCssPath, ju as buildDataPrompt, mf as buildDiagnosticsReport, Mf as buildHtmlFragmentSkill, Cf as buildSandboxSrcdoc, Mu as buildSystemPrompt, uh as chatContextKey, _d as commitSetToBind, kf as composeStructureThenRender, Ei as compressImage, Ou as connectMcp, O as constructLlmFromConfig, E as constructOpenLlmSync, nh as copyText, es as createAgent, Hl as createApprovalMiddleware, dh as createChatContext, ph as createChatSdk, eu as createCheckpointManager, tu as createCheckpointMiddleware, rp as createConflictManager, Cu as createContextInspectorMiddleware, If as createCraftNoteCheck, kd as createDataOps, th as createEvalHarness, Pf as createHtmlFormatCheck, Of as createHtmlRenderCheck, Rf as createHtmlSubagent, Kl as createHumanConfirmMiddleware, Gl as createHumanConfirmTool, Qm as createIdleDetector, Tp as createMemoryBackend, Fl as createMemoryMiddleware, u as createProxyLlm, Zm as createRagSubagent, ia as createSandboxRunner, Ip as createSdkEvents, Fm as createSerialRunner, kp as createSessionStore, Ap as createSessionStoreWithBackend, jm as createSkillStore, El as createSubagentMiddleware, ol as createSubagentTracker, kl as createSubagentsMiddleware, Tm as createUsageHintsMiddleware, ru as createVerifyMiddleware, Iu as createVfs, Dp as createWebStorageBackend, lu as createWriteBackCheck, $i as decorateModelUnavailable, Xs as deepClone, xm as defineDataToolset, bc as defineSkill, zf as defineTool, Ys as deleteByPath, Uf as deriveTitle, ws as describeSchemaNode, Lo as detectGarbledToolCall, to as detectTransitionalReply, dc as diffObjects, eh as diffReport, om as domInfoTool, sm as domInspectSkill, am as domSearchTool, qp as domToStructure, Yp as domTools, bm as domToolsStatic, ds as elementSchemaCandidates, $p as ensureDomListenerRecorder, Kc as estimateMessageTokens, Yc as estimateRoundTokens, y as estimateTokens, k as extractReasoningDelta, Ls as extractSchemaHint, wu as extractText, te as extractTextDelta, ne as extractUsage, Up as fetchDocTools, ym as fetchTools, uc as findStrippedKeys, Ts as formatConstraints, oi as formatZodIssues, Q as getByPath, Jp as getDomTool, im as getElementInfo, um as getEnvSummary, em as getRecordedListeners, Ef as getSandboxLifecycle, is as getSchemaAtPath, ts as getSchemaTopKeys, nc as hashValue, Nf as htmlFragmentSkill, Ms as htmlOrchestratorPrompt, Xc as indexSummarize, pm as inspectEnvTool, mm as inspectTools, Gf as isChatModel, Xi as isContextLengthError, Zi as isModelUnavailableError, ns as isPathAllowed, _p as isQuotaError, Ks as isUnsafePath, ma as jpEval, ci as jsonParseError, ec as limitDepth, _ as lowCapsHint, ff as maskUrlCredentials, Qs as maybeParseValue, of as measureWriteScale, oc as moveByPath, T as normalizeBaseUrl, xf as normalizeRenderResult, ie as normalizeUsage, x as offloadPassThroughChars, b as offloadThresholdChars, js as presets, vs as projectBySchema, _s as projectBySchemaDeep, $s as projectFields, Zc as recallRounds, Df as renderInSandbox, Es as renderSchemaHint, Ds as renderSchemaOverview, As as renderSchemaShallow, Fp as resolveCapabilities, zp as resolveContextOptions, Np as resolveDialogConfig, np as resolveLlm, v as resolveModelCaps, tl as resolvePromptSoftCap, ss as resolveSchemaPath, Mp as resolveStorage, lc as restoreInPlace, cc as restoreLive, li as routeError, va as runSandboxedScript, qs as safeMerge, lm as safeSerialize, $ as safeStringify, Ro as sanitizeGarbledContent, ls as schemaHasRefinement, nm as searchDom, ga as searchJson, Sm as selectBuiltinTools, Js as setByPath, nl as shouldTriggerCompression, hf as stringifyDiagnosticsReport, w as stripStainlessFetch, Ns as systemPromptHelpers, h as tableMaxOutputTokens, Gc as tokenize, Z as toolError, rs as unwrapSchema, ih as useChat, fh as useChatContext, cs as validateAtPath, Md as validateHtmlFormat, hd as validateRootValueLocally, gd as validateWriteLocally, rc as watchFieldsHash, e as z, si as zodError };
|