page-agent-sdk 3.12.0 → 3.14.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 +7 -8
- package/README.zh-CN.md +6 -7
- package/dist/page-agent-sdk.headless.js +1013 -819
- package/dist/page-agent-sdk.iife.js +146 -146
- package/dist/page-agent-sdk.js +1992 -1792
- package/dist/page-agent-sdk.umd.cjs +63 -63
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/headless.d.ts +2 -0
- package/types/index.d.ts +2 -0
|
@@ -202,23 +202,23 @@ var z, ge = /* @__PURE__ */ new WeakSet(), _e = class {
|
|
|
202
202
|
this.flags & 64 && (this.flags &= -65, ge.has(this) && (ge.delete(this), this.trigger()));
|
|
203
203
|
}
|
|
204
204
|
notify() {
|
|
205
|
-
this.flags & 2 && !(this.flags & 32) || this.flags & 8 ||
|
|
205
|
+
this.flags & 2 && !(this.flags & 32) || this.flags & 8 || xe(this);
|
|
206
206
|
}
|
|
207
207
|
run() {
|
|
208
208
|
if (!(this.flags & 1)) return this.fn();
|
|
209
|
-
this.flags |= 2,
|
|
210
|
-
let e = z, t =
|
|
211
|
-
z = this,
|
|
209
|
+
this.flags |= 2, Me(this), Ce(this);
|
|
210
|
+
let e = z, t = V;
|
|
211
|
+
z = this, V = !0;
|
|
212
212
|
try {
|
|
213
213
|
return this.fn();
|
|
214
214
|
} finally {
|
|
215
|
-
process.env.NODE_ENV !== "production" && z !== this && L("Active effect was not restored correctly - this is likely a Vue internal bug."), we(this), z = e,
|
|
215
|
+
process.env.NODE_ENV !== "production" && z !== this && L("Active effect was not restored correctly - this is likely a Vue internal bug."), we(this), z = e, V = t, this.flags &= -3;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
stop() {
|
|
219
219
|
if (this.flags & 1) {
|
|
220
220
|
for (let e = this.deps; e; e = e.nextDep) De(e);
|
|
221
|
-
this.deps = this.depsTail = void 0,
|
|
221
|
+
this.deps = this.depsTail = void 0, Me(this), this.onStop && this.onStop(), this.flags &= -2;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
trigger() {
|
|
@@ -231,14 +231,14 @@ var z, ge = /* @__PURE__ */ new WeakSet(), _e = class {
|
|
|
231
231
|
return Te(this);
|
|
232
232
|
}
|
|
233
233
|
}, ve = 0, ye, be;
|
|
234
|
-
function
|
|
234
|
+
function xe(e, t = !1) {
|
|
235
235
|
if (e.flags |= 8, t) {
|
|
236
236
|
e.next = be, be = e;
|
|
237
237
|
return;
|
|
238
238
|
}
|
|
239
239
|
e.next = ye, ye = e;
|
|
240
240
|
}
|
|
241
|
-
function
|
|
241
|
+
function B() {
|
|
242
242
|
ve++;
|
|
243
243
|
}
|
|
244
244
|
function Se() {
|
|
@@ -272,7 +272,7 @@ function we(e) {
|
|
|
272
272
|
let t, n = e.depsTail, r = n;
|
|
273
273
|
for (; r;) {
|
|
274
274
|
let e = r.prevDep;
|
|
275
|
-
r.version === -1 ? (r === n && (n = e), De(r),
|
|
275
|
+
r.version === -1 ? (r === n && (n = e), De(r), Oe(r)) : t = r, r.dep.activeLink = r.prevActiveLink, r.prevActiveLink = void 0, r = e;
|
|
276
276
|
}
|
|
277
277
|
e.deps = t, e.depsTail = n;
|
|
278
278
|
}
|
|
@@ -281,10 +281,10 @@ function Te(e) {
|
|
|
281
281
|
return !!e._dirty;
|
|
282
282
|
}
|
|
283
283
|
function Ee(e) {
|
|
284
|
-
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion ===
|
|
284
|
+
if (e.flags & 4 && !(e.flags & 16) || (e.flags &= -17, e.globalVersion === Ne) || (e.globalVersion = Ne, !e.isSSR && e.flags & 128 && (!e.deps && !e._dirty || !Te(e)))) return;
|
|
285
285
|
e.flags |= 2;
|
|
286
|
-
let t = e.dep, n = z, r =
|
|
287
|
-
z = e,
|
|
286
|
+
let t = e.dep, n = z, r = V;
|
|
287
|
+
z = e, V = !0;
|
|
288
288
|
try {
|
|
289
289
|
Ce(e);
|
|
290
290
|
let n = e.fn(e._value);
|
|
@@ -292,7 +292,7 @@ function Ee(e) {
|
|
|
292
292
|
} catch (e) {
|
|
293
293
|
throw t.version++, e;
|
|
294
294
|
} finally {
|
|
295
|
-
z = n,
|
|
295
|
+
z = n, V = r, we(e), e.flags &= -3;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
function De(e, t = !1) {
|
|
@@ -303,19 +303,19 @@ function De(e, t = !1) {
|
|
|
303
303
|
}
|
|
304
304
|
!t && !--n.sc && n.map && n.map.delete(n.key);
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function Oe(e) {
|
|
307
307
|
let { prevDep: t, nextDep: n } = e;
|
|
308
308
|
t && (t.nextDep = n, e.prevDep = void 0), n && (n.prevDep = t, e.nextDep = void 0);
|
|
309
309
|
}
|
|
310
|
-
var
|
|
311
|
-
function ke() {
|
|
312
|
-
Oe.push(H), H = !1;
|
|
313
|
-
}
|
|
310
|
+
var V = !0, ke = [];
|
|
314
311
|
function Ae() {
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
ke.push(V), V = !1;
|
|
313
|
+
}
|
|
314
|
+
function je() {
|
|
315
|
+
let e = ke.pop();
|
|
316
|
+
V = e === void 0 || e;
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function Me(e) {
|
|
319
319
|
let { cleanup: t } = e;
|
|
320
320
|
if (e.cleanup = void 0, t) {
|
|
321
321
|
let e = z;
|
|
@@ -327,18 +327,18 @@ function je(e) {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
|
-
var
|
|
330
|
+
var Ne = 0, Pe = class {
|
|
331
331
|
constructor(e, t) {
|
|
332
332
|
this.sub = e, this.dep = t, this.version = t.version, this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
333
333
|
}
|
|
334
|
-
},
|
|
334
|
+
}, Fe = class {
|
|
335
335
|
constructor(e) {
|
|
336
336
|
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);
|
|
337
337
|
}
|
|
338
338
|
track(e) {
|
|
339
|
-
if (!z || !
|
|
339
|
+
if (!z || !V || z === this.computed) return;
|
|
340
340
|
let t = this.activeLink;
|
|
341
|
-
if (t === void 0 || t.sub !== z) t = this.activeLink = new
|
|
341
|
+
if (t === void 0 || t.sub !== z) t = this.activeLink = new Pe(z, this), z.deps ? (t.prevDep = z.depsTail, z.depsTail.nextDep = t, z.depsTail = t) : z.deps = z.depsTail = t, Ie(t);
|
|
342
342
|
else if (t.version === -1 && (t.version = this.version, t.nextDep)) {
|
|
343
343
|
let e = t.nextDep;
|
|
344
344
|
e.prevDep = t.prevDep, t.prevDep && (t.prevDep.nextDep = e), t.prevDep = z.depsTail, t.nextDep = void 0, z.depsTail.nextDep = t, z.depsTail = t, z.deps === t && (z.deps = e);
|
|
@@ -346,10 +346,10 @@ var Me = 0, Ne = class {
|
|
|
346
346
|
return process.env.NODE_ENV !== "production" && z.onTrack && z.onTrack(w({ effect: z }, e)), t;
|
|
347
347
|
}
|
|
348
348
|
trigger(e) {
|
|
349
|
-
this.version++,
|
|
349
|
+
this.version++, Ne++, this.notify(e);
|
|
350
350
|
}
|
|
351
351
|
notify(e) {
|
|
352
|
-
|
|
352
|
+
B();
|
|
353
353
|
try {
|
|
354
354
|
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(w({ effect: t.sub }, e));
|
|
355
355
|
for (let e = this.subs; e; e = e.prevSub) e.sub.notify() && e.sub.dep.notify();
|
|
@@ -358,34 +358,34 @@ var Me = 0, Ne = class {
|
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
|
-
function
|
|
361
|
+
function Ie(e) {
|
|
362
362
|
if (e.dep.sc++, e.sub.flags & 4) {
|
|
363
363
|
let t = e.dep.computed;
|
|
364
364
|
if (t && !e.dep.subs) {
|
|
365
365
|
t.flags |= 20;
|
|
366
|
-
for (let e = t.deps; e; e = e.nextDep)
|
|
366
|
+
for (let e = t.deps; e; e = e.nextDep) Ie(e);
|
|
367
367
|
}
|
|
368
368
|
let n = e.dep.subs;
|
|
369
369
|
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;
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
var
|
|
373
|
-
function
|
|
374
|
-
if (
|
|
375
|
-
let r =
|
|
376
|
-
r ||
|
|
372
|
+
var Le = /* @__PURE__ */ new WeakMap(), Re = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Object iterate"), ze = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Map keys iterate"), Be = /* @__PURE__ */ Symbol(process.env.NODE_ENV === "production" ? "" : "Array iterate");
|
|
373
|
+
function H(e, t, n) {
|
|
374
|
+
if (V && z) {
|
|
375
|
+
let r = Le.get(e);
|
|
376
|
+
r || Le.set(e, r = /* @__PURE__ */ new Map());
|
|
377
377
|
let i = r.get(n);
|
|
378
|
-
i || (r.set(n, i = new
|
|
378
|
+
i || (r.set(n, i = new Fe()), i.map = r, i.key = n), process.env.NODE_ENV === "production" ? i.track() : i.track({
|
|
379
379
|
target: e,
|
|
380
380
|
type: t,
|
|
381
381
|
key: n
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
let o =
|
|
385
|
+
function Ve(e, t, n, r, i, a) {
|
|
386
|
+
let o = Le.get(e);
|
|
387
387
|
if (!o) {
|
|
388
|
-
|
|
388
|
+
Ne++;
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
391
|
let s = (o) => {
|
|
@@ -398,63 +398,63 @@ function Be(e, t, n, r, i, a) {
|
|
|
398
398
|
oldTarget: a
|
|
399
399
|
}));
|
|
400
400
|
};
|
|
401
|
-
if (
|
|
401
|
+
if (B(), t === "clear") o.forEach(s);
|
|
402
402
|
else {
|
|
403
403
|
let i = O(e), a = i && P(n);
|
|
404
404
|
if (i && n === "length") {
|
|
405
405
|
let e = Number(r);
|
|
406
406
|
o.forEach((t, n) => {
|
|
407
|
-
(n === "length" || n ===
|
|
407
|
+
(n === "length" || n === Be || !te(n) && n >= e) && s(t);
|
|
408
408
|
});
|
|
409
|
-
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(
|
|
409
|
+
} else switch ((n !== void 0 || o.has(void 0)) && s(o.get(n)), a && s(o.get(Be)), t) {
|
|
410
410
|
case "add":
|
|
411
|
-
i ? a && s(o.get("length")) : (s(o.get(
|
|
411
|
+
i ? a && s(o.get("length")) : (s(o.get(Re)), k(e) && s(o.get(ze)));
|
|
412
412
|
break;
|
|
413
413
|
case "delete":
|
|
414
|
-
i || (s(o.get(
|
|
414
|
+
i || (s(o.get(Re)), k(e) && s(o.get(ze)));
|
|
415
415
|
break;
|
|
416
416
|
case "set":
|
|
417
|
-
k(e) && s(o.get(
|
|
417
|
+
k(e) && s(o.get(Re));
|
|
418
418
|
break;
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
Se();
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function He(e) {
|
|
424
424
|
let t = /* @__PURE__ */ K(e);
|
|
425
|
-
return t === e ? t : (
|
|
425
|
+
return t === e ? t : (H(t, "iterate", Be), /* @__PURE__ */ G(e) ? t : t.map(Dt));
|
|
426
426
|
}
|
|
427
|
-
function
|
|
428
|
-
return
|
|
427
|
+
function Ue(e) {
|
|
428
|
+
return H(e = /* @__PURE__ */ K(e), "iterate", Be), e;
|
|
429
429
|
}
|
|
430
|
-
function
|
|
431
|
-
return /* @__PURE__ */ Tt(e) ?
|
|
430
|
+
function U(e, t) {
|
|
431
|
+
return /* @__PURE__ */ Tt(e) ? Ot(/* @__PURE__ */ wt(e) ? Dt(t) : t) : Dt(t);
|
|
432
432
|
}
|
|
433
433
|
var We = {
|
|
434
434
|
__proto__: null,
|
|
435
435
|
[Symbol.iterator]() {
|
|
436
|
-
return Ge(this, Symbol.iterator, (e) =>
|
|
436
|
+
return Ge(this, Symbol.iterator, (e) => U(this, e));
|
|
437
437
|
},
|
|
438
438
|
concat(...e) {
|
|
439
|
-
return
|
|
439
|
+
return He(this).concat(...e.map((e) => O(e) ? He(e) : e));
|
|
440
440
|
},
|
|
441
441
|
entries() {
|
|
442
|
-
return Ge(this, "entries", (e) => (e[1] =
|
|
442
|
+
return Ge(this, "entries", (e) => (e[1] = U(this, e[1]), e));
|
|
443
443
|
},
|
|
444
444
|
every(e, t) {
|
|
445
445
|
return qe(this, "every", e, t, void 0, arguments);
|
|
446
446
|
},
|
|
447
447
|
filter(e, t) {
|
|
448
|
-
return qe(this, "filter", e, t, (e) => e.map((e) =>
|
|
448
|
+
return qe(this, "filter", e, t, (e) => e.map((e) => U(this, e)), arguments);
|
|
449
449
|
},
|
|
450
450
|
find(e, t) {
|
|
451
|
-
return qe(this, "find", e, t, (e) =>
|
|
451
|
+
return qe(this, "find", e, t, (e) => U(this, e), arguments);
|
|
452
452
|
},
|
|
453
453
|
findIndex(e, t) {
|
|
454
454
|
return qe(this, "findIndex", e, t, void 0, arguments);
|
|
455
455
|
},
|
|
456
456
|
findLast(e, t) {
|
|
457
|
-
return qe(this, "findLast", e, t, (e) =>
|
|
457
|
+
return qe(this, "findLast", e, t, (e) => U(this, e), arguments);
|
|
458
458
|
},
|
|
459
459
|
findLastIndex(e, t) {
|
|
460
460
|
return qe(this, "findLastIndex", e, t, void 0, arguments);
|
|
@@ -469,7 +469,7 @@ var We = {
|
|
|
469
469
|
return Ye(this, "indexOf", e);
|
|
470
470
|
},
|
|
471
471
|
join(e) {
|
|
472
|
-
return
|
|
472
|
+
return He(this).join(e);
|
|
473
473
|
},
|
|
474
474
|
lastIndexOf(...e) {
|
|
475
475
|
return Ye(this, "lastIndexOf", e);
|
|
@@ -499,23 +499,23 @@ var We = {
|
|
|
499
499
|
return Xe(this, "splice", e);
|
|
500
500
|
},
|
|
501
501
|
toReversed() {
|
|
502
|
-
return
|
|
502
|
+
return He(this).toReversed();
|
|
503
503
|
},
|
|
504
504
|
toSorted(e) {
|
|
505
|
-
return
|
|
505
|
+
return He(this).toSorted(e);
|
|
506
506
|
},
|
|
507
507
|
toSpliced(...e) {
|
|
508
|
-
return
|
|
508
|
+
return He(this).toSpliced(...e);
|
|
509
509
|
},
|
|
510
510
|
unshift(...e) {
|
|
511
511
|
return Xe(this, "unshift", e);
|
|
512
512
|
},
|
|
513
513
|
values() {
|
|
514
|
-
return Ge(this, "values", (e) =>
|
|
514
|
+
return Ge(this, "values", (e) => U(this, e));
|
|
515
515
|
}
|
|
516
516
|
};
|
|
517
517
|
function Ge(e, t, n) {
|
|
518
|
-
let r =
|
|
518
|
+
let r = Ue(e), i = r[t]();
|
|
519
519
|
return r !== e && !/* @__PURE__ */ G(e) && (i._next = i.next, i.next = () => {
|
|
520
520
|
let e = i._next();
|
|
521
521
|
return e.done || (e.value = n(e.value)), e;
|
|
@@ -523,14 +523,14 @@ function Ge(e, t, n) {
|
|
|
523
523
|
}
|
|
524
524
|
var Ke = Array.prototype;
|
|
525
525
|
function qe(e, t, n, r, i, a) {
|
|
526
|
-
let o =
|
|
526
|
+
let o = Ue(e), s = o !== e && !/* @__PURE__ */ G(e), c = o[t];
|
|
527
527
|
if (c !== Ke[t]) {
|
|
528
528
|
let t = c.apply(e, a);
|
|
529
|
-
return s ?
|
|
529
|
+
return s ? Dt(t) : t;
|
|
530
530
|
}
|
|
531
531
|
let l = n;
|
|
532
532
|
o !== e && (s ? l = function(t, r) {
|
|
533
|
-
return n.call(this,
|
|
533
|
+
return n.call(this, U(e, t), r, e);
|
|
534
534
|
} : n.length > 2 && (l = function(t, r) {
|
|
535
535
|
return n.call(this, t, r, e);
|
|
536
536
|
}));
|
|
@@ -538,31 +538,31 @@ function qe(e, t, n, r, i, a) {
|
|
|
538
538
|
return s && i ? i(u) : u;
|
|
539
539
|
}
|
|
540
540
|
function Je(e, t, n, r) {
|
|
541
|
-
let i =
|
|
541
|
+
let i = Ue(e), a = i !== e && !/* @__PURE__ */ G(e), o = n, s = !1;
|
|
542
542
|
i !== e && (a ? (s = r.length === 0, o = function(t, r, i) {
|
|
543
|
-
return s && (s = !1, t =
|
|
543
|
+
return s && (s = !1, t = U(e, t)), n.call(this, t, U(e, r), i, e);
|
|
544
544
|
}) : n.length > 3 && (o = function(t, r, i) {
|
|
545
545
|
return n.call(this, t, r, i, e);
|
|
546
546
|
}));
|
|
547
547
|
let c = i[t](o, ...r);
|
|
548
|
-
return s ?
|
|
548
|
+
return s ? U(e, c) : c;
|
|
549
549
|
}
|
|
550
550
|
function Ye(e, t, n) {
|
|
551
551
|
let r = /* @__PURE__ */ K(e);
|
|
552
|
-
|
|
552
|
+
H(r, "iterate", Be);
|
|
553
553
|
let i = r[t](...n);
|
|
554
554
|
return (i === -1 || i === !1) && /* @__PURE__ */ Et(n[0]) ? (n[0] = /* @__PURE__ */ K(n[0]), r[t](...n)) : i;
|
|
555
555
|
}
|
|
556
556
|
function Xe(e, t, n = []) {
|
|
557
|
-
|
|
557
|
+
Ae(), B();
|
|
558
558
|
let r = (/* @__PURE__ */ K(e))[t].apply(e, n);
|
|
559
|
-
return Se(),
|
|
559
|
+
return Se(), je(), r;
|
|
560
560
|
}
|
|
561
561
|
var Ze = /* @__PURE__ */ y("__proto__,__v_isRef,__isVue"), Qe = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((e) => e !== "arguments" && e !== "caller").map((e) => Symbol[e]).filter(te));
|
|
562
562
|
function $e(e) {
|
|
563
563
|
te(e) || (e = String(e));
|
|
564
564
|
let t = /* @__PURE__ */ K(this);
|
|
565
|
-
return
|
|
565
|
+
return H(t, "has", e), t.hasOwnProperty(e);
|
|
566
566
|
}
|
|
567
567
|
var et = class {
|
|
568
568
|
constructor(e = !1, t = !1) {
|
|
@@ -581,9 +581,9 @@ var et = class {
|
|
|
581
581
|
if (a && (e = We[t])) return e;
|
|
582
582
|
if (t === "hasOwnProperty") return $e;
|
|
583
583
|
}
|
|
584
|
-
let o = Reflect.get(e, t, /* @__PURE__ */
|
|
585
|
-
if ((te(t) ? Qe.has(t) : Ze(t)) || (r ||
|
|
586
|
-
if (/* @__PURE__ */
|
|
584
|
+
let o = Reflect.get(e, t, /* @__PURE__ */ kt(e) ? e : n);
|
|
585
|
+
if ((te(t) ? Qe.has(t) : Ze(t)) || (r || H(e, "get", t), i)) return o;
|
|
586
|
+
if (/* @__PURE__ */ kt(o)) {
|
|
587
587
|
let e = a && P(t) ? o : o.value;
|
|
588
588
|
return r && M(e) ? /* @__PURE__ */ xt(e) : e;
|
|
589
589
|
}
|
|
@@ -597,21 +597,21 @@ var et = class {
|
|
|
597
597
|
let i = e[t], a = O(e) && P(t);
|
|
598
598
|
if (!this._isShallow) {
|
|
599
599
|
let r = /* @__PURE__ */ Tt(i);
|
|
600
|
-
if (!/* @__PURE__ */ G(n) && !/* @__PURE__ */ Tt(n) && (i = /* @__PURE__ */ K(i), n = /* @__PURE__ */ K(n)), !a && /* @__PURE__ */
|
|
600
|
+
if (!/* @__PURE__ */ G(n) && !/* @__PURE__ */ Tt(n) && (i = /* @__PURE__ */ K(i), n = /* @__PURE__ */ K(n)), !a && /* @__PURE__ */ kt(i) && !/* @__PURE__ */ kt(n)) return r ? (process.env.NODE_ENV !== "production" && L(`Set operation on key "${String(t)}" failed: target is readonly.`, e[t]), !0) : (i.value = n, !0);
|
|
601
601
|
}
|
|
602
|
-
let o = a ? Number(t) < e.length : D(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */
|
|
603
|
-
return e === /* @__PURE__ */ K(r) && s && (o ? F(n, i) &&
|
|
602
|
+
let o = a ? Number(t) < e.length : D(e, t), s = Reflect.set(e, t, n, /* @__PURE__ */ kt(e) ? e : r);
|
|
603
|
+
return e === /* @__PURE__ */ K(r) && s && (o ? F(n, i) && Ve(e, "set", t, n, i) : Ve(e, "add", t, n)), s;
|
|
604
604
|
}
|
|
605
605
|
deleteProperty(e, t) {
|
|
606
606
|
let n = D(e, t), r = e[t], i = Reflect.deleteProperty(e, t);
|
|
607
|
-
return i && n &&
|
|
607
|
+
return i && n && Ve(e, "delete", t, void 0, r), i;
|
|
608
608
|
}
|
|
609
609
|
has(e, t) {
|
|
610
610
|
let n = Reflect.has(e, t);
|
|
611
|
-
return (!te(t) || !Qe.has(t)) &&
|
|
611
|
+
return (!te(t) || !Qe.has(t)) && H(e, "has", t), n;
|
|
612
612
|
}
|
|
613
613
|
ownKeys(e) {
|
|
614
|
-
return
|
|
614
|
+
return H(e, "iterate", O(e) ? "length" : Re), Reflect.ownKeys(e);
|
|
615
615
|
}
|
|
616
616
|
}, nt = class extends et {
|
|
617
617
|
constructor(e = !1) {
|
|
@@ -623,11 +623,11 @@ var et = class {
|
|
|
623
623
|
deleteProperty(e, t) {
|
|
624
624
|
return process.env.NODE_ENV !== "production" && L(`Delete operation on key "${String(t)}" failed: target is readonly.`, e), !0;
|
|
625
625
|
}
|
|
626
|
-
}, rt = /* @__PURE__ */ new tt(), it = /* @__PURE__ */ new nt(),
|
|
627
|
-
function
|
|
626
|
+
}, rt = /* @__PURE__ */ new tt(), it = /* @__PURE__ */ new nt(), at = /* @__PURE__ */ new nt(!0), ot = (e) => e, st = (e) => Reflect.getPrototypeOf(e);
|
|
627
|
+
function W(e, t, n) {
|
|
628
628
|
return function(...r) {
|
|
629
|
-
let i = this.__v_raw, a = /* @__PURE__ */ K(i), o = k(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ?
|
|
630
|
-
return !t &&
|
|
629
|
+
let i = this.__v_raw, a = /* @__PURE__ */ K(i), o = k(a), s = e === "entries" || e === Symbol.iterator && o, c = e === "keys" && o, l = i[e](...r), u = n ? ot : t ? Ot : Dt;
|
|
630
|
+
return !t && H(a, "iterate", c ? ze : Re), w(Object.create(l), { next() {
|
|
631
631
|
let { value: e, done: t } = l.next();
|
|
632
632
|
return t ? {
|
|
633
633
|
value: e,
|
|
@@ -652,23 +652,23 @@ function lt(e, t) {
|
|
|
652
652
|
let n = {
|
|
653
653
|
get(n) {
|
|
654
654
|
let r = this.__v_raw, i = /* @__PURE__ */ K(r), a = /* @__PURE__ */ K(n);
|
|
655
|
-
e || (F(n, a) &&
|
|
656
|
-
let { has: o } =
|
|
655
|
+
e || (F(n, a) && H(i, "get", n), H(i, "get", a));
|
|
656
|
+
let { has: o } = st(i), s = t ? ot : e ? Ot : Dt;
|
|
657
657
|
if (o.call(i, n)) return s(r.get(n));
|
|
658
658
|
if (o.call(i, a)) return s(r.get(a));
|
|
659
659
|
r !== i && r.get(n);
|
|
660
660
|
},
|
|
661
661
|
get size() {
|
|
662
662
|
let t = this.__v_raw;
|
|
663
|
-
return !e &&
|
|
663
|
+
return !e && H(/* @__PURE__ */ K(t), "iterate", Re), t.size;
|
|
664
664
|
},
|
|
665
665
|
has(t) {
|
|
666
666
|
let n = this.__v_raw, r = /* @__PURE__ */ K(n), i = /* @__PURE__ */ K(t);
|
|
667
|
-
return e || (F(t, i) &&
|
|
667
|
+
return e || (F(t, i) && H(r, "has", t), H(r, "has", i)), t === i ? n.has(t) : n.has(t) || n.has(i);
|
|
668
668
|
},
|
|
669
669
|
forEach(n, r) {
|
|
670
|
-
let i = this, a = i.__v_raw, o = /* @__PURE__ */ K(a), s = t ?
|
|
671
|
-
return !e &&
|
|
670
|
+
let i = this, a = i.__v_raw, o = /* @__PURE__ */ K(a), s = t ? ot : e ? Ot : Dt;
|
|
671
|
+
return !e && H(o, "iterate", Re), a.forEach((e, t) => n.call(r, s(e), s(t), i));
|
|
672
672
|
}
|
|
673
673
|
};
|
|
674
674
|
return w(n, e ? {
|
|
@@ -678,25 +678,25 @@ function lt(e, t) {
|
|
|
678
678
|
clear: ct("clear")
|
|
679
679
|
} : {
|
|
680
680
|
add(e) {
|
|
681
|
-
let n = /* @__PURE__ */ K(this), r =
|
|
682
|
-
return r.has.call(n, a) || F(e, a) && r.has.call(n, e) || F(i, a) && r.has.call(n, i) || (n.add(a),
|
|
681
|
+
let n = /* @__PURE__ */ K(this), r = st(n), i = /* @__PURE__ */ K(e), a = !t && !/* @__PURE__ */ G(e) && !/* @__PURE__ */ Tt(e) ? i : e;
|
|
682
|
+
return r.has.call(n, a) || F(e, a) && r.has.call(n, e) || F(i, a) && r.has.call(n, i) || (n.add(a), Ve(n, "add", a, a)), this;
|
|
683
683
|
},
|
|
684
684
|
set(e, n) {
|
|
685
685
|
!t && !/* @__PURE__ */ G(n) && !/* @__PURE__ */ Tt(n) && (n = /* @__PURE__ */ K(n));
|
|
686
|
-
let r = /* @__PURE__ */ K(this), { has: i, get: a } =
|
|
686
|
+
let r = /* @__PURE__ */ K(this), { has: i, get: a } = st(r), o = i.call(r, e);
|
|
687
687
|
o ? process.env.NODE_ENV !== "production" && mt(r, i, e) : (e = /* @__PURE__ */ K(e), o = i.call(r, e));
|
|
688
688
|
let s = a.call(r, e);
|
|
689
|
-
return r.set(e, n), o ? F(n, s) &&
|
|
689
|
+
return r.set(e, n), o ? F(n, s) && Ve(r, "set", e, n, s) : Ve(r, "add", e, n), this;
|
|
690
690
|
},
|
|
691
691
|
delete(e) {
|
|
692
|
-
let t = /* @__PURE__ */ K(this), { has: n, get: r } =
|
|
692
|
+
let t = /* @__PURE__ */ K(this), { has: n, get: r } = st(t), i = n.call(t, e);
|
|
693
693
|
i ? process.env.NODE_ENV !== "production" && mt(t, n, e) : (e = /* @__PURE__ */ K(e), i = n.call(t, e));
|
|
694
694
|
let a = r ? r.call(t, e) : void 0, o = t.delete(e);
|
|
695
|
-
return i &&
|
|
695
|
+
return i && Ve(t, "delete", e, void 0, a), o;
|
|
696
696
|
},
|
|
697
697
|
clear() {
|
|
698
698
|
let e = /* @__PURE__ */ K(this), t = e.size !== 0, n = process.env.NODE_ENV === "production" ? void 0 : k(e) ? new Map(e) : new Set(e), r = e.clear();
|
|
699
|
-
return t &&
|
|
699
|
+
return t && Ve(e, "clear", void 0, void 0, n), r;
|
|
700
700
|
}
|
|
701
701
|
}), [
|
|
702
702
|
"keys",
|
|
@@ -704,7 +704,7 @@ function lt(e, t) {
|
|
|
704
704
|
"entries",
|
|
705
705
|
Symbol.iterator
|
|
706
706
|
].forEach((r) => {
|
|
707
|
-
n[r] =
|
|
707
|
+
n[r] = W(r, e, t);
|
|
708
708
|
}), n;
|
|
709
709
|
}
|
|
710
710
|
function ut(e, t) {
|
|
@@ -741,7 +741,7 @@ function xt(e) {
|
|
|
741
741
|
}
|
|
742
742
|
// @__NO_SIDE_EFFECTS__
|
|
743
743
|
function St(e) {
|
|
744
|
-
return Ct(e, !0,
|
|
744
|
+
return Ct(e, !0, at, pt, vt);
|
|
745
745
|
}
|
|
746
746
|
function Ct(e, t, n, r, i) {
|
|
747
747
|
if (!M(e)) return process.env.NODE_ENV !== "production" && L(`value cannot be made ${t ? "readonly" : "reactive"}: ${String(e)}`), e;
|
|
@@ -774,12 +774,12 @@ function K(e) {
|
|
|
774
774
|
let t = e && e.__v_raw;
|
|
775
775
|
return t ? /* @__PURE__ */ K(t) : e;
|
|
776
776
|
}
|
|
777
|
-
function
|
|
777
|
+
function q(e) {
|
|
778
778
|
return !D(e, "__v_skip") && Object.isExtensible(e) && se(e, "__v_skip", !0), e;
|
|
779
779
|
}
|
|
780
|
-
var
|
|
780
|
+
var Dt = (e) => M(e) ? /* @__PURE__ */ bt(e) : e, Ot = (e) => M(e) ? /* @__PURE__ */ xt(e) : e;
|
|
781
781
|
// @__NO_SIDE_EFFECTS__
|
|
782
|
-
function
|
|
782
|
+
function kt(e) {
|
|
783
783
|
return e ? e.__v_isRef === !0 : !1;
|
|
784
784
|
}
|
|
785
785
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -791,11 +791,11 @@ function jt(e) {
|
|
|
791
791
|
return Mt(e, !0);
|
|
792
792
|
}
|
|
793
793
|
function Mt(e, t) {
|
|
794
|
-
return /* @__PURE__ */
|
|
794
|
+
return /* @__PURE__ */ kt(e) ? e : new Nt(e, t);
|
|
795
795
|
}
|
|
796
796
|
var Nt = class {
|
|
797
797
|
constructor(e, t) {
|
|
798
|
-
this.dep = new
|
|
798
|
+
this.dep = new Fe(), this.__v_isRef = !0, this.__v_isShallow = !1, this._rawValue = t ? e : /* @__PURE__ */ K(e), this._value = t ? e : Dt(e), this.__v_isShallow = t;
|
|
799
799
|
}
|
|
800
800
|
get value() {
|
|
801
801
|
return process.env.NODE_ENV === "production" ? this.dep.track() : this.dep.track({
|
|
@@ -806,7 +806,7 @@ var Nt = class {
|
|
|
806
806
|
}
|
|
807
807
|
set value(e) {
|
|
808
808
|
let t = this._rawValue, n = this.__v_isShallow || /* @__PURE__ */ G(e) || /* @__PURE__ */ Tt(e);
|
|
809
|
-
e = n ? e : /* @__PURE__ */ K(e), F(e, t) && (this._rawValue = e, this._value = n ? e :
|
|
809
|
+
e = n ? e : /* @__PURE__ */ K(e), F(e, t) && (this._rawValue = e, this._value = n ? e : Dt(e), process.env.NODE_ENV === "production" ? this.dep.trigger() : this.dep.trigger({
|
|
810
810
|
target: this,
|
|
811
811
|
type: "set",
|
|
812
812
|
key: "value",
|
|
@@ -824,13 +824,13 @@ function Pt(e) {
|
|
|
824
824
|
}));
|
|
825
825
|
}
|
|
826
826
|
function Ft(e) {
|
|
827
|
-
return /* @__PURE__ */
|
|
827
|
+
return /* @__PURE__ */ kt(e) ? e.value : e;
|
|
828
828
|
}
|
|
829
829
|
var It = {
|
|
830
830
|
get: (e, t, n) => t === "__v_raw" ? e : Ft(Reflect.get(e, t, n)),
|
|
831
831
|
set: (e, t, n, r) => {
|
|
832
832
|
let i = e[t];
|
|
833
|
-
return /* @__PURE__ */
|
|
833
|
+
return /* @__PURE__ */ kt(i) && !/* @__PURE__ */ kt(n) ? (i.value = n, !0) : Reflect.set(e, t, n, r);
|
|
834
834
|
}
|
|
835
835
|
};
|
|
836
836
|
function Lt(e) {
|
|
@@ -838,10 +838,10 @@ function Lt(e) {
|
|
|
838
838
|
}
|
|
839
839
|
var Rt = class {
|
|
840
840
|
constructor(e, t, n) {
|
|
841
|
-
this.fn = e, this.setter = t, this._value = void 0, this.dep = new
|
|
841
|
+
this.fn = e, this.setter = t, this._value = void 0, this.dep = new Fe(this), this.__v_isRef = !0, this.deps = void 0, this.depsTail = void 0, this.flags = 16, this.globalVersion = Ne - 1, this.next = void 0, this.effect = this, this.__v_isReadonly = !t, this.isSSR = n;
|
|
842
842
|
}
|
|
843
843
|
notify() {
|
|
844
|
-
if (this.flags |= 16, !(this.flags & 8) && z !== this) return
|
|
844
|
+
if (this.flags |= 16, !(this.flags & 8) && z !== this) return xe(this, !0), !0;
|
|
845
845
|
process.env.NODE_ENV;
|
|
846
846
|
}
|
|
847
847
|
get value() {
|
|
@@ -874,18 +874,18 @@ function Wt(e, t, n = b) {
|
|
|
874
874
|
let { immediate: r, deep: i, once: a, scheduler: o, augmentJob: s, call: c } = n, l = (e) => {
|
|
875
875
|
(n.onWarn || L)("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.");
|
|
876
876
|
}, u = (e) => i ? e : /* @__PURE__ */ G(e) || i === !1 || i === 0 ? Gt(e, 1) : Gt(e), d, f, p, m, h = !1, g = !1;
|
|
877
|
-
if (/* @__PURE__ */
|
|
878
|
-
if (/* @__PURE__ */
|
|
877
|
+
if (/* @__PURE__ */ kt(e) ? (f = () => e.value, h = /* @__PURE__ */ G(e)) : /* @__PURE__ */ wt(e) ? (f = () => u(e), h = !0) : O(e) ? (g = !0, h = e.some((e) => /* @__PURE__ */ wt(e) || /* @__PURE__ */ G(e)), f = () => e.map((e) => {
|
|
878
|
+
if (/* @__PURE__ */ kt(e)) return e.value;
|
|
879
879
|
if (/* @__PURE__ */ wt(e)) return u(e);
|
|
880
880
|
if (A(e)) return c ? c(e, 2) : e();
|
|
881
881
|
process.env.NODE_ENV !== "production" && l(e);
|
|
882
882
|
})) : A(e) ? f = t ? c ? () => c(e, 2) : e : () => {
|
|
883
883
|
if (p) {
|
|
884
|
-
|
|
884
|
+
Ae();
|
|
885
885
|
try {
|
|
886
886
|
p();
|
|
887
887
|
} finally {
|
|
888
|
-
|
|
888
|
+
je();
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
891
|
let t = Ht;
|
|
@@ -940,7 +940,7 @@ function Wt(e, t, n = b) {
|
|
|
940
940
|
}
|
|
941
941
|
function Gt(e, t = Infinity, n) {
|
|
942
942
|
if (t <= 0 || !M(e) || e.__v_skip || (n ||= /* @__PURE__ */ new Map(), (n.get(e) || 0) >= t)) return e;
|
|
943
|
-
if (n.set(e, t), t--, /* @__PURE__ */
|
|
943
|
+
if (n.set(e, t), t--, /* @__PURE__ */ kt(e)) Gt(e.value, t, n);
|
|
944
944
|
else if (O(e)) for (let r = 0; r < e.length; r++) Gt(e[r], t, n);
|
|
945
945
|
else if (ee(e) || k(e)) e.forEach((e) => {
|
|
946
946
|
Gt(e, t, n);
|
|
@@ -963,7 +963,7 @@ function Jt() {
|
|
|
963
963
|
var Yt = !1;
|
|
964
964
|
function J(e, ...t) {
|
|
965
965
|
if (Yt) return;
|
|
966
|
-
Yt = !0,
|
|
966
|
+
Yt = !0, Ae();
|
|
967
967
|
let n = Kt.length ? Kt[Kt.length - 1].component : null, r = n && n.appContext.config.warnHandler, i = Xt();
|
|
968
968
|
if (r) nn(r, n, 11, [
|
|
969
969
|
e + t.map((e) => e.toString?.call(e) ?? JSON.stringify(e)).join(""),
|
|
@@ -975,7 +975,7 @@ function J(e, ...t) {
|
|
|
975
975
|
let n = [`[Vue warn]: ${e}`, ...t];
|
|
976
976
|
i.length && n.push("\n", ...Zt(i)), console.warn(...n);
|
|
977
977
|
}
|
|
978
|
-
|
|
978
|
+
je(), Yt = !1;
|
|
979
979
|
}
|
|
980
980
|
function Xt() {
|
|
981
981
|
let e = Kt[Kt.length - 1];
|
|
@@ -1013,7 +1013,7 @@ function $t(e) {
|
|
|
1013
1013
|
}), n.length > 3 && t.push(" ..."), t;
|
|
1014
1014
|
}
|
|
1015
1015
|
function en(e, t, n) {
|
|
1016
|
-
return j(t) ? (t = JSON.stringify(t), n ? t : [`${e}=${t}`]) : typeof t == "number" || typeof t == "boolean" || t == null ? n ? t : [`${e}=${t}`] : /* @__PURE__ */
|
|
1016
|
+
return j(t) ? (t = JSON.stringify(t), n ? t : [`${e}=${t}`]) : typeof t == "number" || typeof t == "boolean" || t == null ? n ? t : [`${e}=${t}`] : /* @__PURE__ */ kt(t) ? (t = en(e, /* @__PURE__ */ K(t.value), !0), n ? t : [
|
|
1017
1017
|
`${e}=Ref<`,
|
|
1018
1018
|
t,
|
|
1019
1019
|
">"
|
|
@@ -1084,11 +1084,11 @@ function an(e, t, n, r = !0) {
|
|
|
1084
1084
|
r = r.parent;
|
|
1085
1085
|
}
|
|
1086
1086
|
if (a) {
|
|
1087
|
-
|
|
1087
|
+
Ae(), nn(a, null, 10, [
|
|
1088
1088
|
e,
|
|
1089
1089
|
i,
|
|
1090
1090
|
o
|
|
1091
|
-
]),
|
|
1091
|
+
]), je();
|
|
1092
1092
|
return;
|
|
1093
1093
|
}
|
|
1094
1094
|
}
|
|
@@ -1328,7 +1328,7 @@ var Gn = /* @__PURE__ */ Symbol.for("v-ndc"), Kn = (e) => e ? Fr(e) ? Lr(e) : Kn
|
|
|
1328
1328
|
else Zn && (o[t] = 0);
|
|
1329
1329
|
}
|
|
1330
1330
|
let l = qn[t], u, d;
|
|
1331
|
-
if (l) return t === "$attrs" ? (
|
|
1331
|
+
if (l) return t === "$attrs" ? (H(e.attrs, "get", ""), process.env.NODE_ENV) : process.env.NODE_ENV !== "production" && t === "$slots" && H(e, "get", t), l(e);
|
|
1332
1332
|
if ((u = s.__cssModules) && (u = u[t])) return u;
|
|
1333
1333
|
if (n !== b && D(n, t)) return o[t] = 4, n[t];
|
|
1334
1334
|
if (d = c.config.globalProperties, D(d, t)) return d[t];
|
|
@@ -1435,7 +1435,7 @@ var mr = /* @__PURE__ */ Symbol.for("v-fgt"), hr = /* @__PURE__ */ Symbol.for("v
|
|
|
1435
1435
|
function _r(e) {
|
|
1436
1436
|
return e ? e.__v_isVNode === !0 : !1;
|
|
1437
1437
|
}
|
|
1438
|
-
var vr, yr = (...e) => wr(...vr ? vr(e, Fn) : e), br = ({ key: e }) => e ?? null, xr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null : j(e) || /* @__PURE__ */
|
|
1438
|
+
var vr, yr = (...e) => wr(...vr ? vr(e, Fn) : e), br = ({ key: e }) => e ?? null, xr = ({ ref: e, ref_key: t, ref_for: n }) => (typeof e == "number" && (e = "" + e), e == null ? null : j(e) || /* @__PURE__ */ kt(e) || A(e) ? {
|
|
1439
1439
|
i: Fn,
|
|
1440
1440
|
r: e,
|
|
1441
1441
|
k: t,
|
|
@@ -1587,7 +1587,7 @@ function Fr(e) {
|
|
|
1587
1587
|
var Ir = !1;
|
|
1588
1588
|
process.env.NODE_ENV;
|
|
1589
1589
|
function Lr(e) {
|
|
1590
|
-
return e.exposed ? e.exposeProxy ||= new Proxy(Lt(
|
|
1590
|
+
return e.exposed ? e.exposeProxy ||= new Proxy(Lt(q(e.exposed)), {
|
|
1591
1591
|
get(t, n) {
|
|
1592
1592
|
if (n in t) return t[n];
|
|
1593
1593
|
if (n in qn) return qn[n](e);
|
|
@@ -1637,10 +1637,10 @@ function Wr() {
|
|
|
1637
1637
|
e,
|
|
1638
1638
|
"VueInstance"
|
|
1639
1639
|
];
|
|
1640
|
-
if (/* @__PURE__ */
|
|
1641
|
-
|
|
1640
|
+
if (/* @__PURE__ */ kt(t)) {
|
|
1641
|
+
Ae();
|
|
1642
1642
|
let n = t.value;
|
|
1643
|
-
return
|
|
1643
|
+
return je(), [
|
|
1644
1644
|
"div",
|
|
1645
1645
|
{},
|
|
1646
1646
|
[
|
|
@@ -2438,7 +2438,7 @@ function Ui(e) {
|
|
|
2438
2438
|
return t;
|
|
2439
2439
|
}
|
|
2440
2440
|
function ve(e) {
|
|
2441
|
-
let t = e[0] &&
|
|
2441
|
+
let t = e[0] && xe(e[0]) === "system" ? e.slice(1) : e.slice();
|
|
2442
2442
|
return [new o(ge()), ...t];
|
|
2443
2443
|
}
|
|
2444
2444
|
async function ye(e, t, n, r) {
|
|
@@ -2476,7 +2476,7 @@ function Ui(e) {
|
|
|
2476
2476
|
};
|
|
2477
2477
|
if (vi(a) && !e._ctxRetry) {
|
|
2478
2478
|
e._ctxRetry = !0;
|
|
2479
|
-
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o =
|
|
2479
|
+
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = B(e.messages, Math.round(N.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
|
|
2480
2480
|
return F("error", {
|
|
2481
2481
|
stage: "context_overflow_retry",
|
|
2482
2482
|
at: "launch",
|
|
@@ -2525,7 +2525,7 @@ function Ui(e) {
|
|
|
2525
2525
|
};
|
|
2526
2526
|
if (vi(a) && l === null && u === "" && !e._ctxRetry) {
|
|
2527
2527
|
e._ctxRetry = !0;
|
|
2528
|
-
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o =
|
|
2528
|
+
let i = (e) => X(typeof e.content == "string" ? e.content : JSON.stringify(e.content)), a = e.messages.reduce((e, t) => e + i(t), 0), o = B(e.messages, Math.round(N.contextWindow * .3)), s = o.reduce((e, t) => e + i(t), 0);
|
|
2529
2529
|
return F("error", {
|
|
2530
2530
|
stage: "context_overflow_retry",
|
|
2531
2531
|
beforeTokens: a,
|
|
@@ -2570,15 +2570,15 @@ function Ui(e) {
|
|
|
2570
2570
|
};
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
2573
|
-
function
|
|
2573
|
+
function xe(e) {
|
|
2574
2574
|
return e instanceof a ? "human" : e instanceof i ? "ai" : e instanceof o ? "system" : e instanceof s ? "tool" : "unknown";
|
|
2575
2575
|
}
|
|
2576
|
-
function
|
|
2576
|
+
function B(e, t) {
|
|
2577
2577
|
return zi(e, t);
|
|
2578
2578
|
}
|
|
2579
2579
|
function Se(e) {
|
|
2580
2580
|
return !M && !ee ? [] : e.map((e) => {
|
|
2581
|
-
let t =
|
|
2581
|
+
let t = xe(e), n = { role: t === "human" ? "user" : t === "ai" ? "assistant" : t }, r = typeof e.content == "string" ? e.content : JSON.stringify(e.content);
|
|
2582
2582
|
r && (n.content = r.length > Ri ? r.slice(0, Ri) + `…(截断 ${r.length - Ri} 字符)` : r);
|
|
2583
2583
|
let i = e.tool_calls;
|
|
2584
2584
|
Array.isArray(i) && i.length && (n.tool_calls = i.map((e) => ({
|
|
@@ -2667,7 +2667,7 @@ function Ui(e) {
|
|
|
2667
2667
|
}), R = xi(x, {
|
|
2668
2668
|
messages: i,
|
|
2669
2669
|
state: R
|
|
2670
|
-
}), i = ve(i), i =
|
|
2670
|
+
}), i = ve(i), i = B(i, Math.round(N.contextWindow * .6));
|
|
2671
2671
|
let r = de(e, "model", c, {
|
|
2672
2672
|
round: f + 1,
|
|
2673
2673
|
tools: pe.map((e) => e.name)
|
|
@@ -2834,8 +2834,8 @@ function Ui(e) {
|
|
|
2834
2834
|
content: h
|
|
2835
2835
|
}), h;
|
|
2836
2836
|
let e = i[i.length - 1];
|
|
2837
|
-
if (e &&
|
|
2838
|
-
let e = i.filter((e) =>
|
|
2837
|
+
if (e && xe(e) === "tool") {
|
|
2838
|
+
let e = i.filter((e) => xe(e) !== "system"), r = [new o(ge() + "\n\n工具调用次数已达上限,请基于已有工具结果直接给出最终回答,不要再调用工具。"), ...e];
|
|
2839
2839
|
F("llm_request", {
|
|
2840
2840
|
round: "wrap_up",
|
|
2841
2841
|
model: c,
|
|
@@ -3266,7 +3266,7 @@ function ma(e, t = "code") {
|
|
|
3266
3266
|
`【执行纪律(最重要)】收到代码组件任务后:**新建类直接委派**(追加组件无需通读/翻页现有数组,子 agent 自会采样一个组件看结构)→ 修改类才 read 定位(by name)→ 调 ${n} 委派 → read 核对 → 回复用户。**中间绝不输出过渡性文字** —— 「我先看看…」「稍后委派」「接下来我会…」这类计划性回复等于任务没做就结束了(回复即本轮终止);所有调研和委派在本轮内连续完成,完成后才回复总结。`,
|
|
3267
3267
|
"【产物形态】每个组件是完整、自包含的 HTML 页面(含 style/script,可独立成页);你只负责委派和收尾,不关心宿主如何渲染(v-html / iframe / SFC 是集成方的事)。",
|
|
3268
3268
|
`【主 agent 职责边界(硬规则)】禁止直接 read/write 代码组件的 ${t} 字段(read 只得 <code Nkb> 摘要没用;write 绕过 vfs/verify 危险)—— 生成/修改/排查代码一律经 ${n},收尾 read 核对。`,
|
|
3269
|
-
|
|
3269
|
+
`【多组件委派(防上下文污染)】一次要多个组件:① write_todos 列出(每项 name + 要点)② **不同组件可在同一轮并行发多个 ${n} 委派**(每组件一次 ${n},task 只写该组件 name + 要点 + 主题/风格;每次委派是独立子 agent 实例,互不共享上下文);**同一组件同一时间只能有一个委派在途**,勿对同一组件同轮发两个委派 ③ 委派返回后逐个 read 核对(确认已生成 + 名称对)+ update_todo 标完成 ④ 主题/风格在每次 task 里转述(每个子 agent 全新上下文,不知其他组件)。一次 task 塞多个组件仍禁止(同一子 agent 共享上下文生成多个 → class/样式冲突污染);主 agent 自己的 write(普通组件属性)可与委派同轮发出,不必等委派返回。`,
|
|
3270
3270
|
`【委派 task 规格化(收窄子 agent 决策,防开放任务致装饰穷举)】委派 ${n} 的 task 必须含:① 组件定位(by name)② 视觉风格(配色/质感/字体;**给 1-2 个具体视觉锚** —— 主色 hex **取自平台 UI/设计规范 skill 的定义值**(有规范类 skill 先 load 再引用其 hex,勿凭页面观察自造近似色;无规范才自定,如「金黄 #F7C948」)、主体占比(如「杯高约画布 60%」)或装饰密度(如「仅 2 类背景装饰」)—— 细节空间收窄,子 agent 不在装饰细节上展开推演)③ 内容(文案/数据/图)④ 交互意图(动效/状态/触发)⑤ 历史偏好(可选):聊天上下文中有与该组件相关的用户历史偏好/反馈(如「用户偏好深色系」「上轮嫌动画太快」),提炼一句附 task 末尾(新子 agent 无记忆,全靠 task);**不含技术实现**(SVG vs CSS / keyframes vs transition 归子 agent 选)。❌「生成啤酒杯动画」→ ✅「啤酒杯倒酒(beer):金黄啤酒 #F7C948 从上方倒入透明杯(杯高约画布 60%),深绿背景,液体循环下落 2s,hover 杯子放大」。规格简练(4 要素各半句),远省子 agent 思考 token。`,
|
|
3271
3271
|
`【委派失败重试】${n} 返回乱码/内部标记(如 <|DSML|)/空结论或报错 = 子 agent 异常,**重新委派一次**(task 附「上次失败,这次先把代码写短些/分步」);连续两次失败才降级告知用户。**不要因此自己直接 write/edit ${t} 字段**(绕过 vfs/格式校验,且你拿不到规范全文)。`,
|
|
3272
3272
|
"【预算将尽暂停】组件很多、接近工具轮次上限不要硬扛:完成手头这个后报告「已生成 K/N,还剩 M 个」,等用户确认后从 todos 剩余项继续(勿重复已完成)。"
|
|
@@ -4864,33 +4864,41 @@ async function ws(e, t, n, r, i, a) {
|
|
|
4864
4864
|
let f = o + 1 < s ? [Ts({
|
|
4865
4865
|
...t,
|
|
4866
4866
|
depth: o + 1
|
|
4867
|
-
})] : [], p = t.getFocuses?.() ?? [],
|
|
4867
|
+
})] : [], p = t.getFocuses?.() ?? [], h = p.length ? Za({
|
|
4868
4868
|
getSchema: t.getSchema ?? (() => null),
|
|
4869
4869
|
getBind: t.getBind,
|
|
4870
4870
|
initialFocuses: p,
|
|
4871
4871
|
unfocusGuidance: "report-parent"
|
|
4872
|
-
}) : void 0,
|
|
4872
|
+
}) : void 0, g = t.getVfsFiles ? {
|
|
4873
4873
|
name: "vfs-bridge",
|
|
4874
4874
|
beforeAgent: () => ({ files: t.getVfsFiles() })
|
|
4875
|
-
} : void 0,
|
|
4875
|
+
} : void 0, _ = ai({
|
|
4876
4876
|
model: us(t.llm) ? t.llm.model ?? t.llm.modelName : e.model ?? t.llm.model,
|
|
4877
4877
|
contextWindow: t.llm.contextWindow,
|
|
4878
4878
|
maxOutputTokens: t.llm.maxOutputTokens
|
|
4879
4879
|
});
|
|
4880
|
-
if (
|
|
4881
|
-
let
|
|
4882
|
-
contextWindow:
|
|
4880
|
+
if (_.contextWindow < 2e5) throw Error(`[page-agent-sdk][subagent] 子 agent 模型上下文窗口 ${_.contextWindow} 小于最小支持 ${ii}(需 ≥200K 窗口模型)`);
|
|
4881
|
+
let y = t.summarization === void 0 ? void 0 : cs(typeof t.summarization == "object" ? {
|
|
4882
|
+
contextWindow: _.contextWindow,
|
|
4883
4883
|
...t.summarization
|
|
4884
|
-
} : { contextWindow:
|
|
4884
|
+
} : { contextWindow: _.contextWindow }), b = t.onUsage ? {
|
|
4885
4885
|
name: "sub-usage",
|
|
4886
4886
|
afterModel: (e) => {
|
|
4887
4887
|
let n = v(e.message);
|
|
4888
4888
|
n && t.onUsage(n);
|
|
4889
4889
|
}
|
|
4890
|
-
} : void 0,
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4890
|
+
} : void 0, x;
|
|
4891
|
+
!us(t.llm) && t.llm.provider === "anthropic" && (x = await m({
|
|
4892
|
+
...t.llm,
|
|
4893
|
+
model: e.model ?? t.llm.model
|
|
4894
|
+
}, {
|
|
4895
|
+
temperature: t.temperature ?? t.llm.temperature,
|
|
4896
|
+
maxTokens: t.maxTokens ?? t.llm.maxTokens
|
|
4897
|
+
}));
|
|
4898
|
+
let S = Ui({
|
|
4899
|
+
contextWindow: _.contextWindow,
|
|
4900
|
+
maxOutputTokens: _.maxOutputTokens,
|
|
4901
|
+
...us(t.llm) ? { llm: t.llm } : x ? { llm: x } : {
|
|
4894
4902
|
apiKey: t.llm.apiKey,
|
|
4895
4903
|
baseUrl: t.llm.baseUrl,
|
|
4896
4904
|
model: e.model ?? t.llm.model,
|
|
@@ -4903,11 +4911,11 @@ async function ws(e, t, n, r, i, a) {
|
|
|
4903
4911
|
tools: u,
|
|
4904
4912
|
middleware: [
|
|
4905
4913
|
...t.skills?.length ? [bo(t.skills)] : [],
|
|
4906
|
-
..._ ? [_] : [],
|
|
4907
|
-
...h ? [h] : [],
|
|
4908
|
-
...f,
|
|
4909
|
-
...m ? [m] : [],
|
|
4910
4914
|
...y ? [y] : [],
|
|
4915
|
+
...g ? [g] : [],
|
|
4916
|
+
...f,
|
|
4917
|
+
...h ? [h] : [],
|
|
4918
|
+
...b ? [b] : [],
|
|
4911
4919
|
...t.guardMiddleware ?? [],
|
|
4912
4920
|
...t.middleware ?? []
|
|
4913
4921
|
],
|
|
@@ -4917,11 +4925,11 @@ async function ws(e, t, n, r, i, a) {
|
|
|
4917
4925
|
debug: t.debug
|
|
4918
4926
|
});
|
|
4919
4927
|
t.debug && console.log(`[subagent] 启动子 agent(depth=${o},工具 ${u.length} 个)`);
|
|
4920
|
-
let
|
|
4921
|
-
n?.addEventListener("abort",
|
|
4922
|
-
let
|
|
4923
|
-
n?.removeEventListener("abort",
|
|
4924
|
-
},
|
|
4928
|
+
let C = new AbortController(), w = () => C.abort();
|
|
4929
|
+
n?.addEventListener("abort", w, { once: !0 });
|
|
4930
|
+
let T = () => {
|
|
4931
|
+
n?.removeEventListener("abort", w), t.exitDataScope?.(d);
|
|
4932
|
+
}, E = S.stream([{
|
|
4925
4933
|
role: "user",
|
|
4926
4934
|
content: e.prompt,
|
|
4927
4935
|
timestamp: Date.now()
|
|
@@ -4931,22 +4939,22 @@ async function ws(e, t, n, r, i, a) {
|
|
|
4931
4939
|
return;
|
|
4932
4940
|
}
|
|
4933
4941
|
r && (e.type === "tool_call" || e.type === "tool_result" || e.type === "reasoning") && r(e);
|
|
4934
|
-
},
|
|
4942
|
+
}, C.signal);
|
|
4935
4943
|
if (!t.timeoutMs || t.timeoutMs <= 0) try {
|
|
4936
|
-
return await
|
|
4944
|
+
return await E;
|
|
4937
4945
|
} finally {
|
|
4938
|
-
|
|
4946
|
+
T();
|
|
4939
4947
|
}
|
|
4940
|
-
let
|
|
4941
|
-
|
|
4942
|
-
|
|
4948
|
+
let D, O = new Promise((e, n) => {
|
|
4949
|
+
D = setTimeout(() => {
|
|
4950
|
+
C.abort(), n(/* @__PURE__ */ Error(`子 agent 执行超时(${t.timeoutMs}ms),已中止。可简化子任务或拆更小的子任务重试`));
|
|
4943
4951
|
}, t.timeoutMs);
|
|
4944
4952
|
});
|
|
4945
|
-
|
|
4953
|
+
E.catch(() => {});
|
|
4946
4954
|
try {
|
|
4947
|
-
return await Promise.race([
|
|
4955
|
+
return await Promise.race([E, O]);
|
|
4948
4956
|
} finally {
|
|
4949
|
-
clearTimeout(
|
|
4957
|
+
clearTimeout(D), T();
|
|
4950
4958
|
}
|
|
4951
4959
|
}
|
|
4952
4960
|
function Ts(e) {
|
|
@@ -5122,28 +5130,52 @@ function Os(e, n) {
|
|
|
5122
5130
|
console.warn(`[subagents] id "${l.id}" 重复,已跳过`);
|
|
5123
5131
|
continue;
|
|
5124
5132
|
}
|
|
5125
|
-
i.add(e), a.push(l), o.push(r(async ({ task: e },
|
|
5126
|
-
let
|
|
5133
|
+
i.add(e), a.push(l), o.push(r(async ({ task: e, components: t }, r) => {
|
|
5134
|
+
let i = s(r), a = Ds(l, n), o = (e) => i.logSink?.({
|
|
5127
5135
|
...e,
|
|
5128
5136
|
source: `子:${l.id}`
|
|
5129
|
-
}),
|
|
5130
|
-
|
|
5137
|
+
}), u = n.tracker, d = u ? `use_${l.id}-${Math.random().toString(36).slice(2, 6)}` : `use_${l.id}`, f = n.componentLock, p = d, m, h = [], g = (e, t) => i.logSink?.({
|
|
5138
|
+
timestamp: Date.now(),
|
|
5139
|
+
type: "middleware",
|
|
5140
|
+
data: {
|
|
5141
|
+
name: "component-lock",
|
|
5142
|
+
kind: e,
|
|
5143
|
+
components: h,
|
|
5144
|
+
owner: p,
|
|
5145
|
+
...t
|
|
5146
|
+
}
|
|
5147
|
+
});
|
|
5148
|
+
if (f && (h = n.resolveComponents?.({
|
|
5149
|
+
components: t,
|
|
5150
|
+
task: e
|
|
5151
|
+
})?.names ?? [], h.length)) {
|
|
5152
|
+
let e = await f.acquire(h, p);
|
|
5153
|
+
if (!e.ok) return g("conflict", { heldBy: e.heldBy }), `COMPONENT_BUSY · 组件 [${h.join(", ")}] 正在被子 agent(${e.heldBy})修改,本次委派未执行。同一组件同一时间只能有一个委派在途;请先做其他组件,或等该委派结束后(下一轮)再重试本组件。`;
|
|
5154
|
+
m = e.release, g("acquire");
|
|
5155
|
+
}
|
|
5156
|
+
let _ = c(`use_${l.id}`, l.id, i.emit), v = u ? (e) => {
|
|
5157
|
+
e.type !== "reasoning" && u.pushStep(d, {
|
|
5131
5158
|
kind: e.type,
|
|
5132
5159
|
name: e.name,
|
|
5133
5160
|
ts: Date.now()
|
|
5134
|
-
}),
|
|
5135
|
-
} :
|
|
5136
|
-
|
|
5161
|
+
}), _(e);
|
|
5162
|
+
} : _, y = Date.now();
|
|
5163
|
+
u?.start(d, e, l.id, y);
|
|
5137
5164
|
try {
|
|
5138
|
-
let t = await ws({ prompt: e },
|
|
5139
|
-
return
|
|
5165
|
+
let t = await ws({ prompt: e }, a, i.signal, v, o, i.emit);
|
|
5166
|
+
return u?.finish(d, "done", t), t;
|
|
5140
5167
|
} catch (e) {
|
|
5141
|
-
throw
|
|
5168
|
+
throw u?.finish(d, "error", String(e?.message ?? e)), e;
|
|
5169
|
+
} finally {
|
|
5170
|
+
m && (m(), g("release"));
|
|
5142
5171
|
}
|
|
5143
5172
|
}, {
|
|
5144
5173
|
name: `use_${l.id}`,
|
|
5145
5174
|
description: `委派给「${l.description}」子 agent 执行任务,返回其结论(过程隔离,不占主上下文)。`,
|
|
5146
|
-
schema: t.object({
|
|
5175
|
+
schema: t.object({
|
|
5176
|
+
task: t.string().describe("委派给该子 agent 的任务描述"),
|
|
5177
|
+
components: t.array(t.string()).optional().describe("本次委派要修改的组件名列表(并行委派时必填,框架按组件互斥:同组件同时只允许一个委派在途)")
|
|
5178
|
+
})
|
|
5147
5179
|
}));
|
|
5148
5180
|
}
|
|
5149
5181
|
return {
|
|
@@ -6136,8 +6168,8 @@ function yc(e) {
|
|
|
6136
6168
|
}
|
|
6137
6169
|
//#endregion
|
|
6138
6170
|
//#region src/core/sdk/codeAssetMiddleware.ts
|
|
6139
|
-
var bc = "__pgTouched", xc = "__pgFinalText", Sc = "
|
|
6140
|
-
function
|
|
6171
|
+
var bc = "__pgTouched", xc = "__pgFinalText", Sc = "__pgCodeHashes", Cc = "__pgNotes", wc = 200;
|
|
6172
|
+
function Tc(e) {
|
|
6141
6173
|
let t = [];
|
|
6142
6174
|
for (let n of e.split("\n")) {
|
|
6143
6175
|
let e = n.match(/^\s*[-*]?\s*\[note\]\s*(.*)$/i);
|
|
@@ -6145,16 +6177,27 @@ function wc(e) {
|
|
|
6145
6177
|
}
|
|
6146
6178
|
return [...new Set(t)];
|
|
6147
6179
|
}
|
|
6148
|
-
function Tc(e, t) {
|
|
6149
|
-
let n = Array.isArray(e[Sc]) ? e[Sc].filter((e) => typeof e == "string") : [];
|
|
6150
|
-
e[Sc] = [.../* @__PURE__ */ new Set([...n, ...t])].map((e) => e.length > Cc ? e.slice(0, Cc) + "…" : e).slice(-5);
|
|
6151
|
-
}
|
|
6152
6180
|
function Ec(e, t) {
|
|
6181
|
+
let n = Array.isArray(e[Cc]) ? e[Cc].filter((e) => typeof e == "string") : [];
|
|
6182
|
+
e[Cc] = [.../* @__PURE__ */ new Set([...n, ...t])].map((e) => e.length > wc ? e.slice(0, wc) + "…" : e).slice(-5);
|
|
6183
|
+
}
|
|
6184
|
+
function Dc(e) {
|
|
6185
|
+
let t = 5381;
|
|
6186
|
+
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
6187
|
+
return (t >>> 0).toString(16);
|
|
6188
|
+
}
|
|
6189
|
+
function Oc(e, t) {
|
|
6190
|
+
let n = [];
|
|
6191
|
+
return Ac(e, t, (e) => {
|
|
6192
|
+
typeof e.name == "string" && e.name && n.push(e.name);
|
|
6193
|
+
}), n;
|
|
6194
|
+
}
|
|
6195
|
+
function kc(e, t) {
|
|
6153
6196
|
if (!e.startsWith(t)) return null;
|
|
6154
6197
|
let n = e.slice(t.length), r = n.lastIndexOf(".");
|
|
6155
6198
|
return (r > 0 ? n.slice(0, r) : r === 0 ? "" : n) || null;
|
|
6156
6199
|
}
|
|
6157
|
-
function
|
|
6200
|
+
function Ac(e, t, n) {
|
|
6158
6201
|
if (!(!e || typeof e != "object")) for (let r of t) {
|
|
6159
6202
|
let t = Z(e, r);
|
|
6160
6203
|
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
@@ -6163,7 +6206,7 @@ function Dc(e, t, n) {
|
|
|
6163
6206
|
}
|
|
6164
6207
|
}
|
|
6165
6208
|
}
|
|
6166
|
-
function
|
|
6209
|
+
function jc(e, t, n) {
|
|
6167
6210
|
let r = /* @__PURE__ */ new Set();
|
|
6168
6211
|
if (!e || typeof e != "object") return r;
|
|
6169
6212
|
for (let i of t) {
|
|
@@ -6182,17 +6225,17 @@ function Oc(e, t, n) {
|
|
|
6182
6225
|
}
|
|
6183
6226
|
return r;
|
|
6184
6227
|
}
|
|
6185
|
-
function
|
|
6228
|
+
function Mc(e) {
|
|
6186
6229
|
let { writablePaths: t, codeVfsPrefix: n, ext: r, codeField: i = "code", onWarning: a, getController: o, vfsStore: s, craftNotes: c = !0 } = e;
|
|
6187
6230
|
return {
|
|
6188
6231
|
name: "code-asset-checkout-commit",
|
|
6189
6232
|
beforeAgent: (e) => {
|
|
6190
|
-
let c = o()?.get?.().bind, l = 0, u = 0;
|
|
6191
|
-
if (
|
|
6233
|
+
let c = o()?.get?.().bind, l = 0, u = 0, d = /* @__PURE__ */ new Map();
|
|
6234
|
+
if (Ac(c, t, (e) => {
|
|
6192
6235
|
l++;
|
|
6193
6236
|
let t = Z(e, i);
|
|
6194
6237
|
if (typeof t == "string") {
|
|
6195
|
-
u
|
|
6238
|
+
u++, d.set(e.__pgId, Dc(t));
|
|
6196
6239
|
let i = `${n}${e.__pgId}.${r}`;
|
|
6197
6240
|
s.files[i] = {
|
|
6198
6241
|
content: t,
|
|
@@ -6213,7 +6256,8 @@ function kc(e) {
|
|
|
6213
6256
|
return {
|
|
6214
6257
|
files: s.files,
|
|
6215
6258
|
[bc]: /* @__PURE__ */ new Set(),
|
|
6216
|
-
[xc]: { text: "" }
|
|
6259
|
+
[xc]: { text: "" },
|
|
6260
|
+
[Sc]: d
|
|
6217
6261
|
};
|
|
6218
6262
|
},
|
|
6219
6263
|
wrapModelCall: async (e, t) => {
|
|
@@ -6222,11 +6266,11 @@ function kc(e) {
|
|
|
6222
6266
|
},
|
|
6223
6267
|
augmentPrompt: () => {
|
|
6224
6268
|
let e = o()?.get?.().bind, i = [], a = 0;
|
|
6225
|
-
if (
|
|
6269
|
+
if (Ac(e, t, (e, t, o) => {
|
|
6226
6270
|
a++;
|
|
6227
6271
|
let l = typeof e.name == "string" && e.name ? e.name : "", u = l ? `${l} [${o}]` : `(未命名 [${o}])`, d = `${n}${e.__pgId}.${r}`, f = !!s.files[d];
|
|
6228
6272
|
if (i.push(`- ${u} → ${d}${f ? "" : "(尚未检出,先 vfs_write 创建)"}`), c) {
|
|
6229
|
-
let t = Array.isArray(e[
|
|
6273
|
+
let t = Array.isArray(e[Cc]) ? e[Cc].filter((e) => typeof e == "string") : [];
|
|
6230
6274
|
if (t.length) {
|
|
6231
6275
|
let e = t[t.length - 1];
|
|
6232
6276
|
i.push(` 📝 笔记×${t.length}(最近):${e.length > 120 ? e.slice(0, 120) + "…" : e}`);
|
|
@@ -6248,9 +6292,9 @@ function kc(e) {
|
|
|
6248
6292
|
if (c) {
|
|
6249
6293
|
let i = e.state.focuses;
|
|
6250
6294
|
if (i && i.length) {
|
|
6251
|
-
let e =
|
|
6295
|
+
let e = jc(o()?.get?.().bind, t, i);
|
|
6252
6296
|
if (e.size) {
|
|
6253
|
-
let t =
|
|
6297
|
+
let t = kc(s, n);
|
|
6254
6298
|
if (t && !e.has(t)) return {
|
|
6255
6299
|
content: `PATH_DENIED · vfs 越界:当前聚焦代码文件 [${[...e].map((e) => `${n}${e}.${r}`).join(", ")}],你要改的 "${s}" 不在其中。请只改焦点组件的代码文件;如需改其他组件,请在收口回复中说明需先取消聚焦(焦点由主会话/用户管理,你无 focus 工具)后重试。`,
|
|
6256
6300
|
status: "error"
|
|
@@ -6270,48 +6314,184 @@ function kc(e) {
|
|
|
6270
6314
|
if (!l) return;
|
|
6271
6315
|
let u = e[bc] ?? /* @__PURE__ */ new Set();
|
|
6272
6316
|
if (u.size) {
|
|
6273
|
-
let e = /* @__PURE__ */ new Set();
|
|
6274
|
-
|
|
6275
|
-
let
|
|
6276
|
-
|
|
6277
|
-
let
|
|
6278
|
-
if (u.has(
|
|
6279
|
-
let
|
|
6280
|
-
if (
|
|
6281
|
-
let
|
|
6282
|
-
if (
|
|
6283
|
-
|
|
6317
|
+
let o = e[Sc] ?? /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
|
|
6318
|
+
Ac(l, t, (e) => {
|
|
6319
|
+
let t = e.__pgId;
|
|
6320
|
+
c.add(t);
|
|
6321
|
+
let a = `${n}${t}.${r}`;
|
|
6322
|
+
if (u.has(a)) try {
|
|
6323
|
+
let n = s.files[a];
|
|
6324
|
+
if (n && typeof n.content == "string") {
|
|
6325
|
+
let r = o.get(t);
|
|
6326
|
+
if (r !== void 0) {
|
|
6327
|
+
let n = Z(e, i);
|
|
6328
|
+
if (typeof n != "string" || Dc(n) !== r) {
|
|
6329
|
+
console.warn(`[page-agent-sdk][code-asset] 组件 ${e.name ?? t}(${a})在修改期间被外部更新,已保留外部版本(keep_external),本次子 agent 修改未提交`);
|
|
6330
|
+
return;
|
|
6331
|
+
}
|
|
6332
|
+
}
|
|
6333
|
+
let s = yc(n.content);
|
|
6334
|
+
if (s.length) {
|
|
6335
|
+
console.warn(`[page-agent-sdk][code-asset] 跳过 commit 未通过校验的半成品(可能 abort/timeout 未跑完 verify):${a} - ${s[0].message}(${s[0].code})`);
|
|
6284
6336
|
return;
|
|
6285
6337
|
}
|
|
6286
|
-
Ma(
|
|
6338
|
+
Ma(e, i, n.content);
|
|
6287
6339
|
}
|
|
6340
|
+
} catch (e) {
|
|
6341
|
+
console.warn(`[page-agent-sdk][code-asset] 组件 commit 失败已跳过(其余组件不受影响):${a} - ${String(e?.message ?? e)}`);
|
|
6288
6342
|
}
|
|
6289
6343
|
});
|
|
6290
|
-
for (let
|
|
6291
|
-
let
|
|
6292
|
-
|
|
6344
|
+
for (let e of u) {
|
|
6345
|
+
let t = kc(e, n);
|
|
6346
|
+
t && !c.has(t) && (console.warn(`[page-agent-sdk][code-asset] 组件 ${t}(${e})已被外部删除,放弃 commit 并清理 vfs 工作副本(不复活组件)`), delete s.files[e]);
|
|
6293
6347
|
}
|
|
6294
6348
|
a?.markDataDirty?.(), a?.recomputeBaseline?.();
|
|
6295
6349
|
}
|
|
6296
6350
|
if (!c) return;
|
|
6297
|
-
let d =
|
|
6351
|
+
let d = Tc(e[xc]?.text ?? "");
|
|
6298
6352
|
if (!d.length) return;
|
|
6299
6353
|
let f = [];
|
|
6300
|
-
if (
|
|
6354
|
+
if (Ac(l, t, (e) => {
|
|
6301
6355
|
(u.size === 0 || u.has(`${n}${e.__pgId}.${r}`)) && f.push(e);
|
|
6302
6356
|
}), !f.length) return;
|
|
6303
6357
|
let p = !1;
|
|
6304
6358
|
for (let e of d) {
|
|
6305
6359
|
let t = f.length === 1 ? f[0] : f.find((t) => typeof t.name == "string" && !!t.name && e.includes(t.name));
|
|
6306
|
-
t && (
|
|
6360
|
+
t && (Ec(t, [e]), p = !0);
|
|
6307
6361
|
}
|
|
6308
6362
|
p && a?.markDataDirty?.();
|
|
6309
6363
|
}
|
|
6310
6364
|
};
|
|
6311
6365
|
}
|
|
6312
6366
|
//#endregion
|
|
6367
|
+
//#region src/core/sdk/componentLock.ts
|
|
6368
|
+
function Nc() {
|
|
6369
|
+
let e = /* @__PURE__ */ new Map();
|
|
6370
|
+
return {
|
|
6371
|
+
async acquire(t, n) {
|
|
6372
|
+
for (let r of t) {
|
|
6373
|
+
let t = e.get(r);
|
|
6374
|
+
if (t && t.owner !== n) return {
|
|
6375
|
+
ok: !1,
|
|
6376
|
+
heldBy: t.owner
|
|
6377
|
+
};
|
|
6378
|
+
}
|
|
6379
|
+
for (let r of t) e.set(r, { owner: n });
|
|
6380
|
+
let r = !1;
|
|
6381
|
+
return {
|
|
6382
|
+
ok: !0,
|
|
6383
|
+
release: () => {
|
|
6384
|
+
if (!r) {
|
|
6385
|
+
r = !0;
|
|
6386
|
+
for (let r of t) {
|
|
6387
|
+
let t = e.get(r);
|
|
6388
|
+
t && t.owner === n && e.delete(r);
|
|
6389
|
+
}
|
|
6390
|
+
}
|
|
6391
|
+
}
|
|
6392
|
+
};
|
|
6393
|
+
},
|
|
6394
|
+
release(t, n) {
|
|
6395
|
+
for (let r of t) {
|
|
6396
|
+
let t = e.get(r);
|
|
6397
|
+
t && t.owner === n && e.delete(r);
|
|
6398
|
+
}
|
|
6399
|
+
},
|
|
6400
|
+
locked() {
|
|
6401
|
+
let t = {};
|
|
6402
|
+
for (let [n, r] of e) t[n] = r.owner;
|
|
6403
|
+
return t;
|
|
6404
|
+
}
|
|
6405
|
+
};
|
|
6406
|
+
}
|
|
6407
|
+
function Pc(e, t) {
|
|
6408
|
+
if (Array.isArray(e.components) && e.components.length) {
|
|
6409
|
+
let n = new Set(t), r = [...new Set(e.components.filter((e) => typeof e == "string" && e && n.has(e)))];
|
|
6410
|
+
if (r.length) return {
|
|
6411
|
+
names: r,
|
|
6412
|
+
via: "explicit"
|
|
6413
|
+
};
|
|
6414
|
+
}
|
|
6415
|
+
let n = t.filter((t) => t ? RegExp(`(^|[^\\w-])${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}([^\\w-]|$)`).test(e.task) : !1);
|
|
6416
|
+
return n.length === 1 ? {
|
|
6417
|
+
names: [n[0]],
|
|
6418
|
+
via: "text-match"
|
|
6419
|
+
} : {
|
|
6420
|
+
names: [],
|
|
6421
|
+
via: "none"
|
|
6422
|
+
};
|
|
6423
|
+
}
|
|
6424
|
+
function Fc(e, t, n) {
|
|
6425
|
+
let r = new Set(n);
|
|
6426
|
+
if (!r.size || !e || typeof e != "object") return [];
|
|
6427
|
+
let i = [];
|
|
6428
|
+
for (let n of t) {
|
|
6429
|
+
let t = Ic(e, n);
|
|
6430
|
+
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
6431
|
+
let a = t[e];
|
|
6432
|
+
a && typeof a == "object" && typeof a.name == "string" && r.has(a.name) && i.push(`${n}.${e}`);
|
|
6433
|
+
}
|
|
6434
|
+
}
|
|
6435
|
+
return i;
|
|
6436
|
+
}
|
|
6437
|
+
function Ic(e, t) {
|
|
6438
|
+
let n = e;
|
|
6439
|
+
for (let e of t.split(".")) {
|
|
6440
|
+
if (!n || typeof n != "object") return;
|
|
6441
|
+
n = n[e];
|
|
6442
|
+
}
|
|
6443
|
+
return n;
|
|
6444
|
+
}
|
|
6445
|
+
function Lc(e, t) {
|
|
6446
|
+
return t.some((t) => e === t || e.startsWith(t + "."));
|
|
6447
|
+
}
|
|
6448
|
+
var Rc = /* @__PURE__ */ new Set([
|
|
6449
|
+
"write",
|
|
6450
|
+
"set_data",
|
|
6451
|
+
"edit_data",
|
|
6452
|
+
"delete_data",
|
|
6453
|
+
"draft_commit"
|
|
6454
|
+
]);
|
|
6455
|
+
function zc(e) {
|
|
6456
|
+
let t = e ?? {}, n = /* @__PURE__ */ new Set();
|
|
6457
|
+
if (typeof t.jsonPath == "string" && t.jsonPath && n.add(t.jsonPath), typeof t.path == "string" && t.path && n.add(t.path), t.patch && typeof t.patch.jsonPath == "string" && t.patch.jsonPath && n.add(t.patch.jsonPath), Array.isArray(t.patches)) for (let e of t.patches) e && typeof e.jsonPath == "string" && e.jsonPath && n.add(e.jsonPath);
|
|
6458
|
+
return [...n];
|
|
6459
|
+
}
|
|
6460
|
+
function Bc(e) {
|
|
6461
|
+
return {
|
|
6462
|
+
name: "component-write-guard",
|
|
6463
|
+
wrapToolCall: async (t, n) => {
|
|
6464
|
+
if (!Rc.has(t.name)) return n(t);
|
|
6465
|
+
let r = t.args ?? {};
|
|
6466
|
+
if (r.dryRun === !0) return n(t);
|
|
6467
|
+
let i = e.getLocked(), a = Object.keys(i);
|
|
6468
|
+
if (!a.length) return n(t);
|
|
6469
|
+
let o = Fc(e.getBind(), e.writablePaths, a);
|
|
6470
|
+
if (!o.length) return n(t);
|
|
6471
|
+
let s = zc(r);
|
|
6472
|
+
if (!s.length) return e.onReject?.({
|
|
6473
|
+
paths: ["(整体 set)"],
|
|
6474
|
+
lockedPrefixes: o,
|
|
6475
|
+
owner: a.join(",")
|
|
6476
|
+
}), {
|
|
6477
|
+
content: `COMPONENT_LOCKED · 组件 [${a.join(", ")}] 正在被子 agent 修改,整体写入会触碰它们。请改用增量 patch(write({patch:{jsonPath,...}}))只写未锁定组件,或等委派结束后再整体操作。`,
|
|
6478
|
+
status: "error"
|
|
6479
|
+
};
|
|
6480
|
+
let c = s.filter((e) => Lc(e, o));
|
|
6481
|
+
return c.length ? (e.onReject?.({
|
|
6482
|
+
paths: c,
|
|
6483
|
+
lockedPrefixes: o,
|
|
6484
|
+
owner: a.join(",")
|
|
6485
|
+
}), {
|
|
6486
|
+
content: `COMPONENT_LOCKED · 写目标 [${c.join(", ")}] 命中的组件正在被子 agent 修改(委派结束后自动解锁)。请先做其他组件/其他操作,稍后再写该组件;若需改它,等本轮委派完成后再试。`,
|
|
6487
|
+
status: "error"
|
|
6488
|
+
}) : n(t);
|
|
6489
|
+
}
|
|
6490
|
+
};
|
|
6491
|
+
}
|
|
6492
|
+
//#endregion
|
|
6313
6493
|
//#region src/core/sdk/htmlSubagent.ts
|
|
6314
|
-
function
|
|
6494
|
+
function Vc(e, t, n) {
|
|
6315
6495
|
let r = "html";
|
|
6316
6496
|
return `你是纯代码组件生成专家。可用工具:vfs_write / vfs_edit / vfs_rm(写/改/删代码工作副本 vfs ${e}) / vfs_read + vfs_grep(读 vfs) / validate_code(代码格式自检) / write(写 data,writablePaths 限定;set/patch 增量或整体) / read / write_todos + update_todo(规划)。
|
|
6317
6497
|
|
|
@@ -6363,7 +6543,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
|
|
|
6363
6543
|
- 一次想清楚 → 动手 → 验证 → 收口。**思考是手段不是目的,产出代码才是**。
|
|
6364
6544
|
8. **收口格式(必守,最后一行)**:收口回复 = 简短结果总结 + **末行交接笔记** \`[note] <一句话实现要点>\` —— 关键设计决策 / 用户偏好 / 踩坑(如「[note] 液面用 height keyframes 4.2s 循环;装饰仅灯串+光斑 2 类」)。框架只识别末尾 [note] 行存进组件、自动转交下次维护该组件的子 agent;**漏写 = 下任失去交接**(真 LLM 实测漏写率 3/4,务必末行带上)。一行内,只写可复用结论。`;
|
|
6365
6545
|
}
|
|
6366
|
-
function
|
|
6546
|
+
function Hc(e, t) {
|
|
6367
6547
|
return `# HTML 完整页面生成规范
|
|
6368
6548
|
|
|
6369
6549
|
## 代码资产模型(重要)
|
|
@@ -6401,14 +6581,14 @@ function jc(e, t) {
|
|
|
6401
6581
|
- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦
|
|
6402
6582
|
- 颜色对比达标;不只用颜色传达信息`;
|
|
6403
6583
|
}
|
|
6404
|
-
function
|
|
6584
|
+
function Uc(e = "components", t = "code") {
|
|
6405
6585
|
return {
|
|
6406
6586
|
name: "html-fragment",
|
|
6407
6587
|
description: "完整 HTML 页面生成规范:代码作为 data 资产 / vfs 工作副本 / 完整自包含可独立成页 / script+CSS 集中放置 / 可引外部 JS/CSS / validate_code 自检 / 安全底线 / 可访问性",
|
|
6408
|
-
getContent: () =>
|
|
6588
|
+
getContent: () => Hc(e, t)
|
|
6409
6589
|
};
|
|
6410
6590
|
}
|
|
6411
|
-
function
|
|
6591
|
+
function Wc(e = {}) {
|
|
6412
6592
|
let t = e.vfsPrefix ?? "html/";
|
|
6413
6593
|
return ({ state: e }) => {
|
|
6414
6594
|
let n = e.files;
|
|
@@ -6425,7 +6605,7 @@ function Nc(e = {}) {
|
|
|
6425
6605
|
} : { ok: !0 };
|
|
6426
6606
|
};
|
|
6427
6607
|
}
|
|
6428
|
-
function
|
|
6608
|
+
function Gc(e) {
|
|
6429
6609
|
let n, i, a = {
|
|
6430
6610
|
name: "html-validate-tools",
|
|
6431
6611
|
beforeAgent: (e) => {
|
|
@@ -6478,16 +6658,16 @@ function Pc(e) {
|
|
|
6478
6658
|
i = e;
|
|
6479
6659
|
}, a;
|
|
6480
6660
|
}
|
|
6481
|
-
var
|
|
6482
|
-
function
|
|
6661
|
+
var Kc = 2;
|
|
6662
|
+
function qc(e = {}) {
|
|
6483
6663
|
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 } = e;
|
|
6484
6664
|
if (t !== void 0 && !Array.isArray(t)) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 须为字符串数组(代码组件 data 区,如 [\"components\"])/ 省略以从 schema 自动推断");
|
|
6485
6665
|
let h = [];
|
|
6486
|
-
a && h.push(wa()), d && (h.push(
|
|
6666
|
+
a && h.push(wa()), d && (h.push(Gc(n)), h.push(ks({ check: Wc({ vfsPrefix: n }) })));
|
|
6487
6667
|
let g = u ?? [], _ = t?.[0] ?? "components", v = l === void 0, y = {
|
|
6488
6668
|
id: r,
|
|
6489
6669
|
description: i ?? `生成/修改纯代码组件(代码作为 data 资产,代码字段 ${f} 随 data 持久化;vfs 作工作副本;能规划(write_todos)+ 执行)。需写代码组件或灵活定制时委派`,
|
|
6490
|
-
systemPrompt:
|
|
6670
|
+
systemPrompt: Vc(n, f, _),
|
|
6491
6671
|
writablePaths: t ?? [],
|
|
6492
6672
|
allowedTools: [
|
|
6493
6673
|
"vfs_write",
|
|
@@ -6498,9 +6678,9 @@ function Ic(e = {}) {
|
|
|
6498
6678
|
],
|
|
6499
6679
|
middleware: h.length ? h : void 0,
|
|
6500
6680
|
summarization: o === !1 ? void 0 : o,
|
|
6501
|
-
maxVerifyAttempts: d ?
|
|
6681
|
+
maxVerifyAttempts: d ? Kc : void 0,
|
|
6502
6682
|
temperature: c,
|
|
6503
|
-
skills: v ? [
|
|
6683
|
+
skills: v ? [Uc(_, f)] : l,
|
|
6504
6684
|
maxToolRounds: s,
|
|
6505
6685
|
tools: g.length ? g : void 0,
|
|
6506
6686
|
_codeAsset: {
|
|
@@ -6513,12 +6693,12 @@ function Ic(e = {}) {
|
|
|
6513
6693
|
}
|
|
6514
6694
|
};
|
|
6515
6695
|
return y._rebuildCodeAssetPaths = (e) => {
|
|
6516
|
-
y.systemPrompt =
|
|
6696
|
+
y.systemPrompt = Vc(n, f, e), v && (y.skills = [Uc(e, f)]);
|
|
6517
6697
|
}, y;
|
|
6518
6698
|
}
|
|
6519
6699
|
//#endregion
|
|
6520
6700
|
//#region src/core/sdk/defineTool.ts
|
|
6521
|
-
function
|
|
6701
|
+
function Jc(e) {
|
|
6522
6702
|
return r(async (t) => {
|
|
6523
6703
|
let n = await e.handler(t);
|
|
6524
6704
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -6530,7 +6710,7 @@ function Lc(e) {
|
|
|
6530
6710
|
}
|
|
6531
6711
|
//#endregion
|
|
6532
6712
|
//#region src/core/sdk/inspectContextTool.ts
|
|
6533
|
-
var
|
|
6713
|
+
var Yc = t.object({
|
|
6534
6714
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
6535
6715
|
role: t.enum([
|
|
6536
6716
|
"user",
|
|
@@ -6540,11 +6720,11 @@ var Rc = t.object({
|
|
|
6540
6720
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
6541
6721
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
6542
6722
|
});
|
|
6543
|
-
function
|
|
6544
|
-
return
|
|
6723
|
+
function Xc(e) {
|
|
6724
|
+
return Jc({
|
|
6545
6725
|
name: "inspect_context",
|
|
6546
6726
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
6547
|
-
schema:
|
|
6727
|
+
schema: Yc,
|
|
6548
6728
|
handler: (t) => {
|
|
6549
6729
|
let n = Vo(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) => {
|
|
6550
6730
|
let n = $o(e), r = Uo(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = Ho(typeof i.content == "string" ? i.content : "", 60);
|
|
@@ -6567,7 +6747,7 @@ function zc(e) {
|
|
|
6567
6747
|
}
|
|
6568
6748
|
//#endregion
|
|
6569
6749
|
//#region src/core/sdk/compressDecision.ts
|
|
6570
|
-
var
|
|
6750
|
+
var Zc = t.object({
|
|
6571
6751
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
6572
6752
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
6573
6753
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -6577,23 +6757,23 @@ var Bc = t.object({
|
|
|
6577
6757
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
6578
6758
|
//#endregion
|
|
6579
6759
|
//#region src/core/sdk/llmResolver.ts
|
|
6580
|
-
function
|
|
6760
|
+
function Qc(e) {
|
|
6581
6761
|
let t = e.find((e) => e.role === "user");
|
|
6582
6762
|
if (!t) return;
|
|
6583
6763
|
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, " ");
|
|
6584
6764
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
6585
6765
|
}
|
|
6586
|
-
function
|
|
6766
|
+
function $c(e) {
|
|
6587
6767
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
6588
6768
|
}
|
|
6589
|
-
function
|
|
6769
|
+
function el(e) {
|
|
6590
6770
|
let t = e.content;
|
|
6591
6771
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
6592
6772
|
}
|
|
6593
|
-
function
|
|
6773
|
+
function tl(e) {
|
|
6594
6774
|
let t = e.summaryLlm ?? e.llm;
|
|
6595
6775
|
if (!t) return;
|
|
6596
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s =
|
|
6776
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s = $c(t) ? t : null, c = $c(t) ? null : t;
|
|
6597
6777
|
if (c && !c.apiKey) {
|
|
6598
6778
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
6599
6779
|
return;
|
|
@@ -6605,16 +6785,16 @@ function Wc(e) {
|
|
|
6605
6785
|
return !l && c && (l = await m(c, {
|
|
6606
6786
|
temperature: n,
|
|
6607
6787
|
maxTokens: r
|
|
6608
|
-
})),
|
|
6788
|
+
})), el(await l.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
6609
6789
|
} finally {
|
|
6610
6790
|
clearTimeout(s);
|
|
6611
6791
|
}
|
|
6612
6792
|
};
|
|
6613
6793
|
}
|
|
6614
|
-
function
|
|
6794
|
+
function nl(e) {
|
|
6615
6795
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
6616
6796
|
if (!t) return;
|
|
6617
|
-
let n =
|
|
6797
|
+
let n = $c(t) ? t : null, r = $c(t) ? null : t;
|
|
6618
6798
|
if (r && !r.apiKey) return;
|
|
6619
6799
|
let i = n;
|
|
6620
6800
|
return async (e) => {
|
|
@@ -6623,7 +6803,7 @@ function Gc(e) {
|
|
|
6623
6803
|
return !i && r && (i = await m(r, {
|
|
6624
6804
|
temperature: 0,
|
|
6625
6805
|
maxTokens: 30
|
|
6626
|
-
})),
|
|
6806
|
+
})), el(await i.invoke([new o("根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(t)], { signal: n.signal })).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, 20);
|
|
6627
6807
|
} catch {
|
|
6628
6808
|
return "";
|
|
6629
6809
|
} finally {
|
|
@@ -6631,10 +6811,10 @@ function Gc(e) {
|
|
|
6631
6811
|
}
|
|
6632
6812
|
};
|
|
6633
6813
|
}
|
|
6634
|
-
function
|
|
6814
|
+
function rl() {
|
|
6635
6815
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
6636
6816
|
}
|
|
6637
|
-
function
|
|
6817
|
+
function il(e) {
|
|
6638
6818
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
6639
6819
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
6640
6820
|
try {
|
|
@@ -6643,21 +6823,21 @@ function qc(e) {
|
|
|
6643
6823
|
return null;
|
|
6644
6824
|
}
|
|
6645
6825
|
}
|
|
6646
|
-
function
|
|
6826
|
+
function al(e) {
|
|
6647
6827
|
if (!e) return null;
|
|
6648
|
-
let t =
|
|
6828
|
+
let t = il(e);
|
|
6649
6829
|
if (t == null) return null;
|
|
6650
|
-
let n =
|
|
6830
|
+
let n = Zc.safeParse(t);
|
|
6651
6831
|
return n.success ? n.data : null;
|
|
6652
6832
|
}
|
|
6653
|
-
async function
|
|
6833
|
+
async function ol(e, t, n, r) {
|
|
6654
6834
|
let i = [...n];
|
|
6655
6835
|
for (let n = 0; n < 3; n++) {
|
|
6656
6836
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
6657
|
-
if (!a.length) return
|
|
6837
|
+
if (!a.length) return el(n).trim();
|
|
6658
6838
|
i = [...i, n];
|
|
6659
6839
|
for (let e of a) {
|
|
6660
|
-
let n = e.id ??
|
|
6840
|
+
let n = e.id ?? rl();
|
|
6661
6841
|
try {
|
|
6662
6842
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
6663
6843
|
i = [...i, new s({
|
|
@@ -6674,10 +6854,10 @@ async function Yc(e, t, n, r) {
|
|
|
6674
6854
|
}
|
|
6675
6855
|
return "";
|
|
6676
6856
|
}
|
|
6677
|
-
function
|
|
6857
|
+
function sl(e) {
|
|
6678
6858
|
let t = e.summaryLlm ?? e.llm;
|
|
6679
6859
|
if (!t) return;
|
|
6680
|
-
let n =
|
|
6860
|
+
let n = $c(t) ? t : null, r = $c(t) ? null : t;
|
|
6681
6861
|
if (r && !r.apiKey) return;
|
|
6682
6862
|
let i = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
6683
6863
|
return async (e) => {
|
|
@@ -6689,12 +6869,12 @@ function Xc(e) {
|
|
|
6689
6869
|
}));
|
|
6690
6870
|
let n = c;
|
|
6691
6871
|
if (typeof n.bindTools != "function") return null;
|
|
6692
|
-
let i =
|
|
6872
|
+
let i = Xc({
|
|
6693
6873
|
getMessages: e.getMessages,
|
|
6694
6874
|
getSnapshot: e.getSnapshot,
|
|
6695
6875
|
contextWindow: e.contextWindow
|
|
6696
6876
|
}), l = n.bindTools([i]), u = e.triggerMode === "token" ? "token 模式:必填 windowRatio(0~1 保留窗口预算比例,如 0.4);keepRounds 可选" : "轮数模式:必填 keepRounds(保留最近几轮,如 6);windowRatio 可选", d = [new o(`你是对话历史压缩决策助手。当前触发模式 = ${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 a(`触发原因:${e.triggerReason}\n上下文窗口:${e.contextWindow ?? "未知"} tokens\n阈值比例:${e.thresholdRatio ?? "未知"}\n\n请决策压缩策略(先 inspect_context 查看,再输出 JSON)。`)];
|
|
6697
|
-
return
|
|
6877
|
+
return al(await ol(l, i, d, t.signal)) || al(await ol(l, i, [...d, new a("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
6698
6878
|
} catch {
|
|
6699
6879
|
return null;
|
|
6700
6880
|
} finally {
|
|
@@ -6702,22 +6882,22 @@ function Xc(e) {
|
|
|
6702
6882
|
}
|
|
6703
6883
|
};
|
|
6704
6884
|
}
|
|
6705
|
-
function
|
|
6706
|
-
let t = e.llm, n =
|
|
6885
|
+
function cl(e) {
|
|
6886
|
+
let t = e.llm, n = $c(e.llm) ? void 0 : e.llm;
|
|
6707
6887
|
return {
|
|
6708
6888
|
modelCaps: ai({
|
|
6709
6889
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
6710
6890
|
contextWindow: e.contextWindow ?? n?.contextWindow ?? t?.contextWindow,
|
|
6711
6891
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens
|
|
6712
6892
|
}),
|
|
6713
|
-
summaryLlmInvoke:
|
|
6714
|
-
titleLlmInvoke:
|
|
6715
|
-
compressDecisionInvoke:
|
|
6893
|
+
summaryLlmInvoke: tl(e),
|
|
6894
|
+
titleLlmInvoke: nl(e),
|
|
6895
|
+
compressDecisionInvoke: sl(e)
|
|
6716
6896
|
};
|
|
6717
6897
|
}
|
|
6718
6898
|
//#endregion
|
|
6719
6899
|
//#region src/core/sdk/conflictManager.ts
|
|
6720
|
-
function
|
|
6900
|
+
function ll(e) {
|
|
6721
6901
|
let t = /* @__PURE__ */ At(null), n = 0;
|
|
6722
6902
|
function r(r) {
|
|
6723
6903
|
return new Promise((i) => {
|
|
@@ -6748,7 +6928,7 @@ function Qc(e) {
|
|
|
6748
6928
|
}
|
|
6749
6929
|
//#endregion
|
|
6750
6930
|
//#region src/core/utils/id.ts
|
|
6751
|
-
function
|
|
6931
|
+
function ul() {
|
|
6752
6932
|
try {
|
|
6753
6933
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
6754
6934
|
} catch {}
|
|
@@ -6756,7 +6936,7 @@ function $c() {
|
|
|
6756
6936
|
}
|
|
6757
6937
|
//#endregion
|
|
6758
6938
|
//#region src/core/backends/storage.ts
|
|
6759
|
-
var
|
|
6939
|
+
var dl = "chat-sdk", fl = 50 * 1024 * 1024, pl = 4 * 1024 * 1024, ml = 10 * 1024 * 1024, hl = .9, gl = 500, _l = 300, vl = "__meta__", yl = "v:1", bl = [
|
|
6760
6940
|
"messages",
|
|
6761
6941
|
"vfs",
|
|
6762
6942
|
"todos",
|
|
@@ -6767,51 +6947,51 @@ var el = "chat-sdk", tl = 50 * 1024 * 1024, nl = 4 * 1024 * 1024, rl = 10 * 1024
|
|
|
6767
6947
|
"workingMemory",
|
|
6768
6948
|
"focus"
|
|
6769
6949
|
];
|
|
6770
|
-
function
|
|
6771
|
-
return e === "local" || e === "session" ?
|
|
6950
|
+
function xl(e) {
|
|
6951
|
+
return e === "local" || e === "session" ? pl : fl;
|
|
6772
6952
|
}
|
|
6773
|
-
function
|
|
6953
|
+
function Sl(e) {
|
|
6774
6954
|
if (typeof e != "object" || !e) return !1;
|
|
6775
6955
|
let t = e;
|
|
6776
6956
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
6777
6957
|
}
|
|
6778
|
-
function
|
|
6958
|
+
function Cl(e, t, n, r) {
|
|
6779
6959
|
return [
|
|
6780
|
-
|
|
6960
|
+
yl,
|
|
6781
6961
|
e,
|
|
6782
6962
|
t,
|
|
6783
6963
|
n,
|
|
6784
6964
|
r
|
|
6785
6965
|
].join("::");
|
|
6786
6966
|
}
|
|
6787
|
-
function
|
|
6967
|
+
function wl(e, t, n) {
|
|
6788
6968
|
return [
|
|
6789
|
-
|
|
6969
|
+
yl,
|
|
6790
6970
|
e,
|
|
6791
6971
|
t,
|
|
6792
6972
|
n
|
|
6793
6973
|
].join("::") + "::";
|
|
6794
6974
|
}
|
|
6795
|
-
function
|
|
6975
|
+
function Tl(e, t) {
|
|
6796
6976
|
return [
|
|
6797
|
-
|
|
6977
|
+
yl,
|
|
6798
6978
|
e,
|
|
6799
6979
|
t
|
|
6800
6980
|
].join("::") + "::";
|
|
6801
6981
|
}
|
|
6802
|
-
function
|
|
6803
|
-
return [
|
|
6982
|
+
function El(e) {
|
|
6983
|
+
return [yl, e].join("::") + "::";
|
|
6804
6984
|
}
|
|
6805
|
-
var
|
|
6806
|
-
function
|
|
6807
|
-
|
|
6985
|
+
var Dl = null;
|
|
6986
|
+
function Ol(e) {
|
|
6987
|
+
Dl ||= new TextEncoder();
|
|
6808
6988
|
try {
|
|
6809
|
-
return
|
|
6989
|
+
return Dl.encode(JSON.stringify(e)).length;
|
|
6810
6990
|
} catch {
|
|
6811
6991
|
return 0;
|
|
6812
6992
|
}
|
|
6813
6993
|
}
|
|
6814
|
-
function
|
|
6994
|
+
function kl(e, t, n) {
|
|
6815
6995
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
6816
6996
|
if (r <= t) return [];
|
|
6817
6997
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -6821,7 +7001,7 @@ function vl(e, t, n) {
|
|
|
6821
7001
|
}
|
|
6822
7002
|
return o;
|
|
6823
7003
|
}
|
|
6824
|
-
function
|
|
7004
|
+
function Al() {
|
|
6825
7005
|
let e = /* @__PURE__ */ new Map();
|
|
6826
7006
|
return {
|
|
6827
7007
|
async get(t) {
|
|
@@ -6841,7 +7021,7 @@ function yl() {
|
|
|
6841
7021
|
}
|
|
6842
7022
|
};
|
|
6843
7023
|
}
|
|
6844
|
-
function
|
|
7024
|
+
function jl(e) {
|
|
6845
7025
|
return new Promise((t, n) => {
|
|
6846
7026
|
if (typeof indexedDB > "u") {
|
|
6847
7027
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -6902,7 +7082,7 @@ function bl(e) {
|
|
|
6902
7082
|
}, r.onerror = () => n(r.error);
|
|
6903
7083
|
});
|
|
6904
7084
|
}
|
|
6905
|
-
function
|
|
7085
|
+
function Ml(e) {
|
|
6906
7086
|
return {
|
|
6907
7087
|
async get(t) {
|
|
6908
7088
|
let n = e.getItem(t);
|
|
@@ -6947,12 +7127,12 @@ function xl(e) {
|
|
|
6947
7127
|
}
|
|
6948
7128
|
};
|
|
6949
7129
|
}
|
|
6950
|
-
function
|
|
7130
|
+
function Nl(e, t, n) {
|
|
6951
7131
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
6952
7132
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
6953
7133
|
}
|
|
6954
|
-
function
|
|
6955
|
-
let t = e.dbName ??
|
|
7134
|
+
function Pl(e = {}) {
|
|
7135
|
+
let t = e.dbName ?? dl, n = e.backend ?? "indexed", r = e.maxBytes ?? xl(n), i = e.maxBytesPerSession ?? ml, a = e.evictionWatermark ?? hl, o = e.debounceMs ?? gl, s = /* @__PURE__ */ new Set();
|
|
6956
7136
|
function c(e) {
|
|
6957
7137
|
for (let t of s) try {
|
|
6958
7138
|
t(e);
|
|
@@ -6965,16 +7145,16 @@ function Cl(e = {}) {
|
|
|
6965
7145
|
try {
|
|
6966
7146
|
if (n === "indexed") {
|
|
6967
7147
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
6968
|
-
l = await
|
|
7148
|
+
l = await jl(t), d(!0);
|
|
6969
7149
|
} else if (n === "session") {
|
|
6970
7150
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
6971
|
-
l =
|
|
7151
|
+
l = Ml(sessionStorage), d(!0);
|
|
6972
7152
|
} else if (n === "local") {
|
|
6973
7153
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
6974
|
-
l =
|
|
6975
|
-
} else l =
|
|
7154
|
+
l = Ml(localStorage), d(!0);
|
|
7155
|
+
} else l = Al(), d(!1);
|
|
6976
7156
|
} catch (e) {
|
|
6977
|
-
l =
|
|
7157
|
+
l = Al();
|
|
6978
7158
|
let t = e instanceof Error ? e.message : String(e);
|
|
6979
7159
|
d(!1), Promise.resolve().then(() => c({
|
|
6980
7160
|
type: "degraded",
|
|
@@ -6984,10 +7164,10 @@ function Cl(e = {}) {
|
|
|
6984
7164
|
})();
|
|
6985
7165
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
6986
7166
|
function g(e, n, r, a) {
|
|
6987
|
-
let o =
|
|
6988
|
-
return
|
|
7167
|
+
let o = Cl(t, r, a, vl);
|
|
7168
|
+
return Nl(h, o, async () => {
|
|
6989
7169
|
let t = async () => {
|
|
6990
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
7170
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : Ol(s), d = Ol(n), f = (t?.bytes ?? 0) + (d - u);
|
|
6991
7171
|
if (f > i) {
|
|
6992
7172
|
c({
|
|
6993
7173
|
type: "quota",
|
|
@@ -7009,12 +7189,12 @@ function Cl(e = {}) {
|
|
|
7009
7189
|
try {
|
|
7010
7190
|
await t();
|
|
7011
7191
|
} catch (e) {
|
|
7012
|
-
if (
|
|
7192
|
+
if (Sl(e) && !u) {
|
|
7013
7193
|
u = !0;
|
|
7014
7194
|
try {
|
|
7015
7195
|
await b();
|
|
7016
7196
|
} catch {}
|
|
7017
|
-
l =
|
|
7197
|
+
l = Al(), Promise.resolve().then(() => c({
|
|
7018
7198
|
type: "degraded",
|
|
7019
7199
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
7020
7200
|
}));
|
|
@@ -7026,7 +7206,7 @@ function Cl(e = {}) {
|
|
|
7026
7206
|
});
|
|
7027
7207
|
}
|
|
7028
7208
|
function _(e, n, r, i) {
|
|
7029
|
-
let a =
|
|
7209
|
+
let a = Cl(t, e, n, r), s = p.get(a);
|
|
7030
7210
|
s && s.resolve();
|
|
7031
7211
|
let c = m.get(a);
|
|
7032
7212
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -7053,15 +7233,15 @@ function Cl(e = {}) {
|
|
|
7053
7233
|
function y() {
|
|
7054
7234
|
v ||= setTimeout(() => {
|
|
7055
7235
|
v = null, b();
|
|
7056
|
-
},
|
|
7236
|
+
}, _l);
|
|
7057
7237
|
}
|
|
7058
7238
|
async function b() {
|
|
7059
7239
|
let e = [];
|
|
7060
|
-
await l.scan(
|
|
7240
|
+
await l.scan(El(t), (t, n) => {
|
|
7061
7241
|
t.endsWith("::__meta__") && e.push(n);
|
|
7062
7242
|
});
|
|
7063
|
-
let n =
|
|
7064
|
-
for (let e of n) await l.clearPrefix(
|
|
7243
|
+
let n = kl(e, r, a);
|
|
7244
|
+
for (let e of n) await l.clearPrefix(wl(t, e.agentId, e.sessionId)), c({
|
|
7065
7245
|
type: "evicted",
|
|
7066
7246
|
agentId: e.agentId,
|
|
7067
7247
|
sessionId: e.sessionId,
|
|
@@ -7072,13 +7252,13 @@ function Cl(e = {}) {
|
|
|
7072
7252
|
ready: f,
|
|
7073
7253
|
async listSessions(e) {
|
|
7074
7254
|
let n = [];
|
|
7075
|
-
return await l.scan(
|
|
7255
|
+
return await l.scan(Tl(t, e), (e, t) => {
|
|
7076
7256
|
e.endsWith("::__meta__") && n.push(t);
|
|
7077
7257
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
7078
7258
|
},
|
|
7079
7259
|
async load(e, n) {
|
|
7080
|
-
let r =
|
|
7081
|
-
return await
|
|
7260
|
+
let r = Cl(t, e, n, vl);
|
|
7261
|
+
return await Nl(h, r, async () => {
|
|
7082
7262
|
let i = await l.get(r);
|
|
7083
7263
|
if (!i) return;
|
|
7084
7264
|
let a = {
|
|
@@ -7087,8 +7267,8 @@ function Cl(e = {}) {
|
|
|
7087
7267
|
todos: [],
|
|
7088
7268
|
memory: ""
|
|
7089
7269
|
};
|
|
7090
|
-
for (let r of
|
|
7091
|
-
let i = await l.get(
|
|
7270
|
+
for (let r of bl) {
|
|
7271
|
+
let i = await l.get(Cl(t, e, n, r));
|
|
7092
7272
|
i != null && (a[r] = i);
|
|
7093
7273
|
}
|
|
7094
7274
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -7096,12 +7276,12 @@ function Cl(e = {}) {
|
|
|
7096
7276
|
},
|
|
7097
7277
|
async save(e, t, n) {
|
|
7098
7278
|
let r = [];
|
|
7099
|
-
for (let i of
|
|
7279
|
+
for (let i of bl) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
7100
7280
|
await Promise.all(r);
|
|
7101
7281
|
},
|
|
7102
7282
|
async updateTitle(e, n, r) {
|
|
7103
|
-
let i =
|
|
7104
|
-
return
|
|
7283
|
+
let i = Cl(t, e, n, vl);
|
|
7284
|
+
return Nl(h, i, async () => {
|
|
7105
7285
|
let e = await l.get(i);
|
|
7106
7286
|
e && (e.title = r, e.lastAccessed = Date.now(), await l.set(i, e));
|
|
7107
7287
|
});
|
|
@@ -7117,10 +7297,10 @@ function Cl(e = {}) {
|
|
|
7117
7297
|
})), c({ type: "flush" }), await b();
|
|
7118
7298
|
},
|
|
7119
7299
|
async deleteSession(e, n) {
|
|
7120
|
-
await l.clearPrefix(
|
|
7300
|
+
await l.clearPrefix(wl(t, e, n));
|
|
7121
7301
|
},
|
|
7122
7302
|
async createSession(e, n, r) {
|
|
7123
|
-
let i = r ??
|
|
7303
|
+
let i = r ?? ul(), a = Date.now(), o = {
|
|
7124
7304
|
agentId: e,
|
|
7125
7305
|
sessionId: i,
|
|
7126
7306
|
createdAt: a,
|
|
@@ -7128,7 +7308,7 @@ function Cl(e = {}) {
|
|
|
7128
7308
|
bytes: 0,
|
|
7129
7309
|
title: n
|
|
7130
7310
|
};
|
|
7131
|
-
return await l.set(
|
|
7311
|
+
return await l.set(Cl(t, e, i, vl), o), i;
|
|
7132
7312
|
},
|
|
7133
7313
|
onEvent(e) {
|
|
7134
7314
|
s.add(e);
|
|
@@ -7143,15 +7323,15 @@ function Cl(e = {}) {
|
|
|
7143
7323
|
}
|
|
7144
7324
|
//#endregion
|
|
7145
7325
|
//#region src/core/sdk/optionsResolver.ts
|
|
7146
|
-
function
|
|
7147
|
-
return e === void 0 ?
|
|
7326
|
+
function Fl(e) {
|
|
7327
|
+
return e === void 0 ? Pl({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? Pl({ backend: e }) : e.enabled === !1 ? null : Pl(e);
|
|
7148
7328
|
}
|
|
7149
|
-
function
|
|
7329
|
+
function Il(e) {
|
|
7150
7330
|
return e.dialog ?? {};
|
|
7151
7331
|
}
|
|
7152
7332
|
//#endregion
|
|
7153
7333
|
//#region src/core/capabilities.ts
|
|
7154
|
-
var
|
|
7334
|
+
var Ll = [
|
|
7155
7335
|
{
|
|
7156
7336
|
name: "dataOps",
|
|
7157
7337
|
defaultOn: !0
|
|
@@ -7240,13 +7420,13 @@ var El = [
|
|
|
7240
7420
|
requires: ["summarization"]
|
|
7241
7421
|
}
|
|
7242
7422
|
];
|
|
7243
|
-
function
|
|
7423
|
+
function Rl(e) {
|
|
7244
7424
|
let t = {};
|
|
7245
|
-
for (let n of
|
|
7425
|
+
for (let n of Ll) {
|
|
7246
7426
|
let r = e?.[n.name];
|
|
7247
7427
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
7248
7428
|
}
|
|
7249
|
-
for (let e of
|
|
7429
|
+
for (let e of Ll) if (e.requires && t[e.name]) {
|
|
7250
7430
|
for (let n of e.requires) if (!t[n]) {
|
|
7251
7431
|
t[e.name] = !1;
|
|
7252
7432
|
break;
|
|
@@ -7256,7 +7436,7 @@ function Dl(e) {
|
|
|
7256
7436
|
}
|
|
7257
7437
|
//#endregion
|
|
7258
7438
|
//#region src/core/sdk/events.ts
|
|
7259
|
-
function
|
|
7439
|
+
function zl(e) {
|
|
7260
7440
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
7261
7441
|
if (n.type !== "approval_request") {
|
|
7262
7442
|
if (e) try {
|
|
@@ -7282,7 +7462,7 @@ function Ol(e) {
|
|
|
7282
7462
|
}
|
|
7283
7463
|
//#endregion
|
|
7284
7464
|
//#region src/core/sdk/contextPreset.ts
|
|
7285
|
-
var
|
|
7465
|
+
var Bl = {
|
|
7286
7466
|
auto: {
|
|
7287
7467
|
summaryThresholdRatio: .5,
|
|
7288
7468
|
windowRatio: .4,
|
|
@@ -7310,7 +7490,7 @@ var kl = {
|
|
|
7310
7490
|
enableRecall: !0,
|
|
7311
7491
|
enableLLMSummary: !0
|
|
7312
7492
|
}
|
|
7313
|
-
},
|
|
7493
|
+
}, Vl = {
|
|
7314
7494
|
auto: ["describe_data", "read"],
|
|
7315
7495
|
conservative: ["describe_data"],
|
|
7316
7496
|
aggressive: ["describe_data", "read"],
|
|
@@ -7321,8 +7501,8 @@ var kl = {
|
|
|
7321
7501
|
"search_data"
|
|
7322
7502
|
]
|
|
7323
7503
|
};
|
|
7324
|
-
function
|
|
7325
|
-
let n =
|
|
7504
|
+
function Hl(e, t) {
|
|
7505
|
+
let n = Bl[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
7326
7506
|
return {
|
|
7327
7507
|
...n,
|
|
7328
7508
|
...r,
|
|
@@ -7332,7 +7512,7 @@ function jl(e, t) {
|
|
|
7332
7512
|
}
|
|
7333
7513
|
//#endregion
|
|
7334
7514
|
//#region src/core/sdk/middlewareStack.ts
|
|
7335
|
-
var
|
|
7515
|
+
var Ul = {
|
|
7336
7516
|
dataHint: 10,
|
|
7337
7517
|
usageHints: 20,
|
|
7338
7518
|
todos: 30,
|
|
@@ -7349,17 +7529,17 @@ var Ml = {
|
|
|
7349
7529
|
subagents: 140,
|
|
7350
7530
|
augmentSystem: 150
|
|
7351
7531
|
};
|
|
7352
|
-
function
|
|
7532
|
+
function Wl(e) {
|
|
7353
7533
|
return e.map((e, t) => ({
|
|
7354
7534
|
m: e,
|
|
7355
7535
|
i: t,
|
|
7356
|
-
p:
|
|
7536
|
+
p: Ul[e.name] ?? Infinity
|
|
7357
7537
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
7358
7538
|
}
|
|
7359
7539
|
//#endregion
|
|
7360
7540
|
//#region src/core/tools/dataSlotQuery.ts
|
|
7361
|
-
var
|
|
7362
|
-
function
|
|
7541
|
+
var Gl = /[\w$-]/;
|
|
7542
|
+
function Kl(e) {
|
|
7363
7543
|
let t = [], n = e.trim(), r = +(n[0] === "$");
|
|
7364
7544
|
for (; r < n.length;) {
|
|
7365
7545
|
let e = n[r];
|
|
@@ -7370,7 +7550,7 @@ function Fl(e) {
|
|
|
7370
7550
|
continue;
|
|
7371
7551
|
}
|
|
7372
7552
|
let e = "";
|
|
7373
|
-
for (; r < n.length &&
|
|
7553
|
+
for (; r < n.length && Gl.test(n[r]);) e += n[r++];
|
|
7374
7554
|
if (!e) throw Error("JSONPath: .. 后缺属性名");
|
|
7375
7555
|
t.push({
|
|
7376
7556
|
type: "descendKey",
|
|
@@ -7383,7 +7563,7 @@ function Fl(e) {
|
|
|
7383
7563
|
continue;
|
|
7384
7564
|
}
|
|
7385
7565
|
let e = "";
|
|
7386
|
-
for (; r < n.length &&
|
|
7566
|
+
for (; r < n.length && Gl.test(n[r]);) e += n[r++];
|
|
7387
7567
|
if (!e) throw Error("JSONPath: . 后缺属性名");
|
|
7388
7568
|
t.push({
|
|
7389
7569
|
type: "key",
|
|
@@ -7439,7 +7619,7 @@ function Fl(e) {
|
|
|
7439
7619
|
}
|
|
7440
7620
|
return t;
|
|
7441
7621
|
}
|
|
7442
|
-
function
|
|
7622
|
+
function ql(e) {
|
|
7443
7623
|
let t = [], n = 0, r = e.trim();
|
|
7444
7624
|
for (; n < r.length;) {
|
|
7445
7625
|
let e = r[n];
|
|
@@ -7484,7 +7664,7 @@ function Il(e) {
|
|
|
7484
7664
|
}
|
|
7485
7665
|
return t;
|
|
7486
7666
|
}
|
|
7487
|
-
var
|
|
7667
|
+
var Jl = class {
|
|
7488
7668
|
toks;
|
|
7489
7669
|
item;
|
|
7490
7670
|
pos = 0;
|
|
@@ -7520,12 +7700,12 @@ var Ll = class {
|
|
|
7520
7700
|
return this.next(), e;
|
|
7521
7701
|
}
|
|
7522
7702
|
let e = this.operand(), t = this.peek();
|
|
7523
|
-
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(),
|
|
7703
|
+
return t === "==" || t === "!=" || t === "<" || t === "<=" || t === ">" || t === ">=" ? (this.next(), Zl(t, e, this.operand())) : Yl(e);
|
|
7524
7704
|
}
|
|
7525
7705
|
operand() {
|
|
7526
7706
|
let e = this.next();
|
|
7527
7707
|
if (e === void 0) throw Error("过滤表达式:缺操作数");
|
|
7528
|
-
if (e.startsWith("@")) return
|
|
7708
|
+
if (e.startsWith("@")) return Xl(e, this.item);
|
|
7529
7709
|
if (e[0] === "'" || e[0] === "\"") return e.slice(1, -1);
|
|
7530
7710
|
if (e === "true") return !0;
|
|
7531
7711
|
if (e === "false") return !1;
|
|
@@ -7535,10 +7715,10 @@ var Ll = class {
|
|
|
7535
7715
|
throw Error(`过滤表达式:未知操作数 '${e}'`);
|
|
7536
7716
|
}
|
|
7537
7717
|
};
|
|
7538
|
-
function
|
|
7718
|
+
function Yl(e) {
|
|
7539
7719
|
return !!e && e !== 0 && e !== "" && e !== null;
|
|
7540
7720
|
}
|
|
7541
|
-
function
|
|
7721
|
+
function Xl(e, t) {
|
|
7542
7722
|
let n = e.split(".").filter((e) => e && e !== "@"), r = t;
|
|
7543
7723
|
for (let e of n) {
|
|
7544
7724
|
if (typeof r != "object" || !r) return;
|
|
@@ -7546,7 +7726,7 @@ function zl(e, t) {
|
|
|
7546
7726
|
}
|
|
7547
7727
|
return r;
|
|
7548
7728
|
}
|
|
7549
|
-
function
|
|
7729
|
+
function Zl(e, t, n) {
|
|
7550
7730
|
switch (e) {
|
|
7551
7731
|
case "==": return t === n;
|
|
7552
7732
|
case "!=": return t !== n;
|
|
@@ -7557,47 +7737,47 @@ function Bl(e, t, n) {
|
|
|
7557
7737
|
default: return !1;
|
|
7558
7738
|
}
|
|
7559
7739
|
}
|
|
7560
|
-
function
|
|
7561
|
-
return new
|
|
7740
|
+
function Ql(e, t) {
|
|
7741
|
+
return new Jl(ql(e), t).parse();
|
|
7562
7742
|
}
|
|
7563
|
-
function
|
|
7743
|
+
function $l(e, t) {
|
|
7564
7744
|
return e ? `${e}.${t}` : String(t);
|
|
7565
7745
|
}
|
|
7566
|
-
function
|
|
7746
|
+
function eu(e, t) {
|
|
7567
7747
|
let n = [{
|
|
7568
7748
|
path: "",
|
|
7569
7749
|
value: e
|
|
7570
7750
|
}];
|
|
7571
|
-
for (let e of
|
|
7751
|
+
for (let e of Kl(t)) {
|
|
7572
7752
|
let t = [];
|
|
7573
7753
|
if (e.type === "key") for (let r of n) r.value != null && typeof r.value == "object" && e.key in r.value && t.push({
|
|
7574
|
-
path:
|
|
7754
|
+
path: $l(r.path, e.key),
|
|
7575
7755
|
value: r.value[e.key]
|
|
7576
7756
|
});
|
|
7577
7757
|
else if (e.type === "index") {
|
|
7578
7758
|
for (let r of n) if (Array.isArray(r.value)) {
|
|
7579
7759
|
let n = r.value[e.index];
|
|
7580
7760
|
e.index >= 0 && e.index < r.value.length && t.push({
|
|
7581
|
-
path:
|
|
7761
|
+
path: $l(r.path, e.index),
|
|
7582
7762
|
value: n,
|
|
7583
7763
|
index: e.index
|
|
7584
7764
|
});
|
|
7585
7765
|
}
|
|
7586
7766
|
} else if (e.type === "wildcard") {
|
|
7587
7767
|
for (let e of n) if (Array.isArray(e.value)) e.value.forEach((n, r) => t.push({
|
|
7588
|
-
path:
|
|
7768
|
+
path: $l(e.path, r),
|
|
7589
7769
|
value: n,
|
|
7590
7770
|
index: r
|
|
7591
7771
|
}));
|
|
7592
7772
|
else if (e.value != null && typeof e.value == "object") for (let n of Object.keys(e.value)) t.push({
|
|
7593
|
-
path:
|
|
7773
|
+
path: $l(e.path, n),
|
|
7594
7774
|
value: e.value[n]
|
|
7595
7775
|
});
|
|
7596
7776
|
} else if (e.type === "descendKey") {
|
|
7597
7777
|
let r = e.key, i = (e) => {
|
|
7598
7778
|
if (!(e.value == null || typeof e.value != "object")) for (let n of Object.keys(e.value)) {
|
|
7599
7779
|
let a = {
|
|
7600
|
-
path:
|
|
7780
|
+
path: $l(e.path, n),
|
|
7601
7781
|
value: e.value[n]
|
|
7602
7782
|
};
|
|
7603
7783
|
n === r && t.push(a), i(a);
|
|
@@ -7608,7 +7788,7 @@ function Ul(e, t) {
|
|
|
7608
7788
|
let e = (n) => {
|
|
7609
7789
|
if (!(n.value == null || typeof n.value != "object")) for (let r of Object.keys(n.value)) {
|
|
7610
7790
|
let i = {
|
|
7611
|
-
path:
|
|
7791
|
+
path: $l(n.path, r),
|
|
7612
7792
|
value: n.value[r]
|
|
7613
7793
|
};
|
|
7614
7794
|
t.push(i), e(i);
|
|
@@ -7617,16 +7797,16 @@ function Ul(e, t) {
|
|
|
7617
7797
|
for (let t of n) e(t);
|
|
7618
7798
|
} else if (e.type === "filter") {
|
|
7619
7799
|
for (let r of n) if (Array.isArray(r.value)) r.value.forEach((n, i) => {
|
|
7620
|
-
|
|
7621
|
-
path:
|
|
7800
|
+
Ql(e.filter, n) && t.push({
|
|
7801
|
+
path: $l(r.path, i),
|
|
7622
7802
|
value: n,
|
|
7623
7803
|
index: i
|
|
7624
7804
|
});
|
|
7625
7805
|
});
|
|
7626
7806
|
else if (r.value != null && typeof r.value == "object") for (let n of Object.keys(r.value)) {
|
|
7627
7807
|
let i = r.value[n];
|
|
7628
|
-
|
|
7629
|
-
path:
|
|
7808
|
+
Ql(e.filter, i) && t.push({
|
|
7809
|
+
path: $l(r.path, n),
|
|
7630
7810
|
value: i
|
|
7631
7811
|
});
|
|
7632
7812
|
}
|
|
@@ -7635,7 +7815,7 @@ function Ul(e, t) {
|
|
|
7635
7815
|
}
|
|
7636
7816
|
return n;
|
|
7637
7817
|
}
|
|
7638
|
-
function
|
|
7818
|
+
function tu(e, t) {
|
|
7639
7819
|
let n = e.length, r = t.length;
|
|
7640
7820
|
if (!n) return r;
|
|
7641
7821
|
if (!r) return n;
|
|
@@ -7651,7 +7831,7 @@ function Wl(e, t) {
|
|
|
7651
7831
|
}
|
|
7652
7832
|
return i[r];
|
|
7653
7833
|
}
|
|
7654
|
-
function
|
|
7834
|
+
function nu(e, t, n = {}) {
|
|
7655
7835
|
let r = n.mode || "substring", i = n.limit ?? 50, a = n.matchKey !== !1, o = [], s = null;
|
|
7656
7836
|
if (r === "regex") try {
|
|
7657
7837
|
s = new RegExp(t, "i");
|
|
@@ -7661,11 +7841,11 @@ function Gl(e, t, n = {}) {
|
|
|
7661
7841
|
let c = (e, l, u) => {
|
|
7662
7842
|
if (o.length >= i || e == null) return;
|
|
7663
7843
|
if (typeof e == "object") {
|
|
7664
|
-
if (Array.isArray(e)) e.forEach((e, t) => c(e,
|
|
7665
|
-
else for (let t of Object.keys(e)) c(e[t],
|
|
7844
|
+
if (Array.isArray(e)) e.forEach((e, t) => c(e, $l(l, t), String(t)));
|
|
7845
|
+
else for (let t of Object.keys(e)) c(e[t], $l(l, t), t);
|
|
7666
7846
|
return;
|
|
7667
7847
|
}
|
|
7668
|
-
let d = String(e), f =
|
|
7848
|
+
let d = String(e), f = ru(d, t, r, n.fuzzyThreshold ?? 2, s);
|
|
7669
7849
|
if (f) {
|
|
7670
7850
|
o.push({
|
|
7671
7851
|
path: l,
|
|
@@ -7676,7 +7856,7 @@ function Gl(e, t, n = {}) {
|
|
|
7676
7856
|
return;
|
|
7677
7857
|
}
|
|
7678
7858
|
if (a && u) {
|
|
7679
|
-
let e =
|
|
7859
|
+
let e = ru(u, t, r, n.fuzzyThreshold ?? 2, s);
|
|
7680
7860
|
e && o.push({
|
|
7681
7861
|
path: l,
|
|
7682
7862
|
key: u,
|
|
@@ -7687,51 +7867,51 @@ function Gl(e, t, n = {}) {
|
|
|
7687
7867
|
};
|
|
7688
7868
|
return c(e, ""), o;
|
|
7689
7869
|
}
|
|
7690
|
-
function
|
|
7870
|
+
function ru(e, t, n, r, i) {
|
|
7691
7871
|
let a = e.toLowerCase(), o = t.toLowerCase();
|
|
7692
7872
|
if (n === "substring") return a.includes(o) ? 1 : null;
|
|
7693
7873
|
if (n === "regex") return i && i.test(e) ? 1 : null;
|
|
7694
7874
|
if (n === "fuzzy") {
|
|
7695
7875
|
if (a.includes(o)) return 2;
|
|
7696
|
-
let e =
|
|
7876
|
+
let e = tu(a, o);
|
|
7697
7877
|
return e <= r ? r - e + 1 : null;
|
|
7698
7878
|
}
|
|
7699
7879
|
return null;
|
|
7700
7880
|
}
|
|
7701
|
-
function
|
|
7881
|
+
function iu(e, t, n = 3e3) {
|
|
7702
7882
|
return io(t, n)(e);
|
|
7703
7883
|
}
|
|
7704
7884
|
//#endregion
|
|
7705
7885
|
//#region src/core/tools/resources.ts
|
|
7706
|
-
var
|
|
7707
|
-
function
|
|
7708
|
-
return `${
|
|
7886
|
+
var au = "⟦frozen:", ou = "⟦res:", su = "⟧";
|
|
7887
|
+
function cu(e) {
|
|
7888
|
+
return `${au}${e}${su}`;
|
|
7709
7889
|
}
|
|
7710
|
-
function
|
|
7711
|
-
return `${
|
|
7890
|
+
function lu(e) {
|
|
7891
|
+
return `${ou}${e}${su}`;
|
|
7712
7892
|
}
|
|
7713
|
-
function
|
|
7714
|
-
return typeof e == "string" ? e.startsWith(
|
|
7893
|
+
function uu(e) {
|
|
7894
|
+
return typeof e == "string" ? e.startsWith(au) && e.endsWith(su) ? {
|
|
7715
7895
|
type: "frozen",
|
|
7716
7896
|
path: e.slice(8, e.length - 1)
|
|
7717
|
-
} : e.startsWith(
|
|
7897
|
+
} : e.startsWith(ou) && e.endsWith(su) ? {
|
|
7718
7898
|
type: "res",
|
|
7719
7899
|
handle: e.slice(5, e.length - 1)
|
|
7720
7900
|
} : null : null;
|
|
7721
7901
|
}
|
|
7722
|
-
function
|
|
7902
|
+
function du(e) {
|
|
7723
7903
|
return String(e ?? "").trim().replace(/^\.+/, "");
|
|
7724
7904
|
}
|
|
7725
|
-
function
|
|
7905
|
+
function fu(e) {
|
|
7726
7906
|
let t = 5381;
|
|
7727
7907
|
for (let n = 0; n < e.length; n++) t = (t * 33 ^ e.charCodeAt(n)) >>> 0;
|
|
7728
7908
|
return (t >>> 0).toString(16).padStart(8, "0").slice(0, 8);
|
|
7729
7909
|
}
|
|
7730
|
-
function
|
|
7910
|
+
function pu(e, t) {
|
|
7731
7911
|
return e === t ? !0 : e && t && typeof e == "object" && typeof t == "object" ? JSON.stringify(e) === JSON.stringify(t) : !1;
|
|
7732
7912
|
}
|
|
7733
|
-
function
|
|
7734
|
-
let n =
|
|
7913
|
+
function mu(e, t) {
|
|
7914
|
+
let n = du(e);
|
|
7735
7915
|
if (!n) return;
|
|
7736
7916
|
let r = t.get(n);
|
|
7737
7917
|
if (r) return {
|
|
@@ -7751,7 +7931,7 @@ function ru(e, t) {
|
|
|
7751
7931
|
}));
|
|
7752
7932
|
return i;
|
|
7753
7933
|
}
|
|
7754
|
-
var
|
|
7934
|
+
var hu = class {
|
|
7755
7935
|
vfs;
|
|
7756
7936
|
constructor(e) {
|
|
7757
7937
|
this.vfs = e;
|
|
@@ -7760,7 +7940,7 @@ var iu = class {
|
|
|
7760
7940
|
return `resources/${e}.json`;
|
|
7761
7941
|
}
|
|
7762
7942
|
ensure(e, t, n) {
|
|
7763
|
-
let r =
|
|
7943
|
+
let r = fu(e), i = {
|
|
7764
7944
|
path: e,
|
|
7765
7945
|
mode: n,
|
|
7766
7946
|
value: t,
|
|
@@ -7772,7 +7952,7 @@ var iu = class {
|
|
|
7772
7952
|
}, r;
|
|
7773
7953
|
}
|
|
7774
7954
|
get(e) {
|
|
7775
|
-
return this.readEntry(this.key(e)) || this.readEntry(this.key(
|
|
7955
|
+
return this.readEntry(this.key(e)) || this.readEntry(this.key(fu(e)));
|
|
7776
7956
|
}
|
|
7777
7957
|
readEntry(e) {
|
|
7778
7958
|
let t = this.vfs.files[e];
|
|
@@ -7788,7 +7968,7 @@ var iu = class {
|
|
|
7788
7968
|
this.ensure(e, t, n?.mode ?? "verbatim");
|
|
7789
7969
|
}
|
|
7790
7970
|
delete(e) {
|
|
7791
|
-
let t = this.get(e)?.handle ??
|
|
7971
|
+
let t = this.get(e)?.handle ?? fu(e), n = this.key(t), r = !!this.vfs.files[n];
|
|
7792
7972
|
return r && delete this.vfs.files[n], r;
|
|
7793
7973
|
}
|
|
7794
7974
|
list() {
|
|
@@ -7808,7 +7988,7 @@ var iu = class {
|
|
|
7808
7988
|
for (let e of Object.keys(this.vfs.files)) e.startsWith("resources/") && delete this.vfs.files[e];
|
|
7809
7989
|
}
|
|
7810
7990
|
};
|
|
7811
|
-
function
|
|
7991
|
+
function gu(e) {
|
|
7812
7992
|
let { jp: t, resolved: n, resourcesByPath: r, resourceStore: i } = e;
|
|
7813
7993
|
if (!r.size) return n;
|
|
7814
7994
|
let a = !1;
|
|
@@ -7822,14 +8002,14 @@ function au(e) {
|
|
|
7822
8002
|
if (t !== "" && e !== t && !e.startsWith(t + ".")) continue;
|
|
7823
8003
|
if (e === t) {
|
|
7824
8004
|
if (o === void 0) continue;
|
|
7825
|
-
return n.mode === "freeze" ?
|
|
8005
|
+
return n.mode === "freeze" ? cu(e) : i ? lu(i.ensure(e, o, "verbatim")) : o;
|
|
7826
8006
|
}
|
|
7827
8007
|
let r = t === "" ? e : e.slice(t.length + 1), a = Z(o, r);
|
|
7828
|
-
a !== void 0 && (n.mode === "freeze" ? Ma(o, r,
|
|
8008
|
+
a !== void 0 && (n.mode === "freeze" ? Ma(o, r, cu(e)) : i && Ma(o, r, lu(i.ensure(e, a, "verbatim"))));
|
|
7829
8009
|
}
|
|
7830
8010
|
return o;
|
|
7831
8011
|
}
|
|
7832
|
-
function
|
|
8012
|
+
function _u(e, t, n, r) {
|
|
7833
8013
|
if (!r) return {
|
|
7834
8014
|
code: "RESOURCE_NOT_FOUND",
|
|
7835
8015
|
message: `句柄 "${e}" 无法展开(资源池未启用)`,
|
|
@@ -7840,7 +8020,7 @@ function ou(e, t, n, r) {
|
|
|
7840
8020
|
code: "RESOURCE_NOT_FOUND",
|
|
7841
8021
|
message: `字段 "${t}" 在 bind 中已不存在,无法展开句柄 "${e}"`,
|
|
7842
8022
|
hint: "该字段可能已被删除或 restore 到不含此字段的快照;重新 read 确认当前结构"
|
|
7843
|
-
} :
|
|
8023
|
+
} : pu(i.value, n) ? { value: i.value } : (r.update(t, n), { value: n }) : n === void 0 ? {
|
|
7844
8024
|
code: "RESOURCE_NOT_FOUND",
|
|
7845
8025
|
message: `句柄 "${e}" 不存在(字段 "${t}" 可能未注册或已被删除)`,
|
|
7846
8026
|
hint: "重新 read 该字段触发懒注册"
|
|
@@ -7850,7 +8030,7 @@ function ou(e, t, n, r) {
|
|
|
7850
8030
|
hint: "重新 read 该字段触发懒注册重建句柄,再写回新句柄 ⟦res:<handle>⟧"
|
|
7851
8031
|
};
|
|
7852
8032
|
}
|
|
7853
|
-
function
|
|
8033
|
+
function vu(e, t) {
|
|
7854
8034
|
let n = t.getBind();
|
|
7855
8035
|
for (let [r, i] of t.resourcesByPath) {
|
|
7856
8036
|
let a = Z(n, r), o = Z(e, r);
|
|
@@ -7859,11 +8039,11 @@ function su(e, t) {
|
|
|
7859
8039
|
continue;
|
|
7860
8040
|
}
|
|
7861
8041
|
if (i.mode === "freeze") {
|
|
7862
|
-
if (o ===
|
|
8042
|
+
if (o === cu(r)) {
|
|
7863
8043
|
Ma(e, r, a);
|
|
7864
8044
|
continue;
|
|
7865
8045
|
}
|
|
7866
|
-
if (!
|
|
8046
|
+
if (!pu(o, a)) return {
|
|
7867
8047
|
ok: !1,
|
|
7868
8048
|
code: "FROZEN_FIELD",
|
|
7869
8049
|
path: r,
|
|
@@ -7871,9 +8051,9 @@ function su(e, t) {
|
|
|
7871
8051
|
hint: "该字段由系统/集成方维护,LLM 不得改动。如需展示其值用 resource_get({path}) 取真值"
|
|
7872
8052
|
};
|
|
7873
8053
|
} else {
|
|
7874
|
-
let n =
|
|
8054
|
+
let n = uu(o);
|
|
7875
8055
|
if (n && n.type === "res") {
|
|
7876
|
-
let i =
|
|
8056
|
+
let i = _u(n.handle, r, a, t.resourceStore);
|
|
7877
8057
|
if ("value" in i) {
|
|
7878
8058
|
Ma(e, r, i.value);
|
|
7879
8059
|
continue;
|
|
@@ -7886,7 +8066,7 @@ function su(e, t) {
|
|
|
7886
8066
|
hint: i.hint
|
|
7887
8067
|
};
|
|
7888
8068
|
}
|
|
7889
|
-
if (!
|
|
8069
|
+
if (!pu(o, a)) return {
|
|
7890
8070
|
ok: !1,
|
|
7891
8071
|
code: "VERBATIM_MISMATCH",
|
|
7892
8072
|
path: r,
|
|
@@ -7897,7 +8077,7 @@ function su(e, t) {
|
|
|
7897
8077
|
}
|
|
7898
8078
|
return { ok: !0 };
|
|
7899
8079
|
}
|
|
7900
|
-
function
|
|
8080
|
+
function yu(e, t, n) {
|
|
7901
8081
|
let r = t === void 0 ? e.message : `patches[${t}]${n ? ` @ "${n}"` : ""}: ${e.message}`;
|
|
7902
8082
|
return Y({
|
|
7903
8083
|
code: e.code,
|
|
@@ -7910,28 +8090,28 @@ function cu(e, t, n) {
|
|
|
7910
8090
|
} }
|
|
7911
8091
|
});
|
|
7912
8092
|
}
|
|
7913
|
-
function
|
|
8093
|
+
function bu(e) {
|
|
7914
8094
|
let { value: t, ctx: n } = e;
|
|
7915
8095
|
if (!n || !n.resourcesByPath.size) return {
|
|
7916
8096
|
ok: !0,
|
|
7917
8097
|
value: t
|
|
7918
8098
|
};
|
|
7919
|
-
let r = Pa(t), i =
|
|
8099
|
+
let r = Pa(t), i = vu(r, n);
|
|
7920
8100
|
return i.ok ? {
|
|
7921
8101
|
ok: !0,
|
|
7922
8102
|
value: r
|
|
7923
8103
|
} : {
|
|
7924
8104
|
ok: !1,
|
|
7925
|
-
error:
|
|
8105
|
+
error: yu(i)
|
|
7926
8106
|
};
|
|
7927
8107
|
}
|
|
7928
|
-
function
|
|
8108
|
+
function xu(e) {
|
|
7929
8109
|
let { patches: t, clone: n, ctx: r } = e;
|
|
7930
8110
|
if (!r || !r.resourcesByPath.size) return { ok: !0 };
|
|
7931
8111
|
for (let e = 0; e < t.length; e++) {
|
|
7932
8112
|
let n = t[e];
|
|
7933
8113
|
if (n.op === "remove") {
|
|
7934
|
-
let t =
|
|
8114
|
+
let t = mu(n.jsonPath || "", r.resourcesByPath);
|
|
7935
8115
|
if (t) {
|
|
7936
8116
|
let r = t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED", i = t.spec.mode === "freeze" ? "冻结字段不可删。如需移除请联系集成方调整 data.resources 配置" : "verbatim 字段不可直接删;先 resource_delete({path}) 释放资源保护后再删";
|
|
7937
8117
|
return {
|
|
@@ -7950,27 +8130,27 @@ function uu(e) {
|
|
|
7950
8130
|
}
|
|
7951
8131
|
}
|
|
7952
8132
|
}
|
|
7953
|
-
let i =
|
|
8133
|
+
let i = vu(n, r);
|
|
7954
8134
|
if (!i.ok) {
|
|
7955
|
-
let e =
|
|
8135
|
+
let e = Su(i.path, t);
|
|
7956
8136
|
return {
|
|
7957
8137
|
ok: !1,
|
|
7958
|
-
error:
|
|
8138
|
+
error: yu(i, e >= 0 ? e : void 0, e >= 0 ? t[e].jsonPath : void 0)
|
|
7959
8139
|
};
|
|
7960
8140
|
}
|
|
7961
8141
|
return { ok: !0 };
|
|
7962
8142
|
}
|
|
7963
|
-
function
|
|
7964
|
-
let n =
|
|
8143
|
+
function Su(e, t) {
|
|
8144
|
+
let n = du(e);
|
|
7965
8145
|
for (let e = 0; e < t.length; e++) {
|
|
7966
|
-
let r =
|
|
8146
|
+
let r = du(t[e].jsonPath || "");
|
|
7967
8147
|
if (r && (r === n || n.startsWith(r + ".") || r.startsWith(n + "."))) return e;
|
|
7968
8148
|
}
|
|
7969
8149
|
return -1;
|
|
7970
8150
|
}
|
|
7971
8151
|
//#endregion
|
|
7972
8152
|
//#region src/core/tools/dataOps.ts
|
|
7973
|
-
var
|
|
8153
|
+
var Cu = /* @__PURE__ */ new Set([
|
|
7974
8154
|
"describe_data",
|
|
7975
8155
|
"get_data",
|
|
7976
8156
|
"set_data",
|
|
@@ -7984,14 +8164,14 @@ var fu = /* @__PURE__ */ new Set([
|
|
|
7984
8164
|
"resource_update",
|
|
7985
8165
|
"resource_list",
|
|
7986
8166
|
"resource_delete"
|
|
7987
|
-
]),
|
|
7988
|
-
function
|
|
7989
|
-
return t === "advanced" ? e : t === "minimal" ? e.filter((e) =>
|
|
8167
|
+
]), wu = /* @__PURE__ */ new Set(["read", "write"]);
|
|
8168
|
+
function Tu(e, t = "simple") {
|
|
8169
|
+
return t === "advanced" ? e : t === "minimal" ? e.filter((e) => wu.has(e.name)) : e.filter((e) => !Cu.has(e.name));
|
|
7990
8170
|
}
|
|
7991
|
-
function
|
|
8171
|
+
function Eu(e) {
|
|
7992
8172
|
let { bindRef: t, schema: n, allowKeys: r, snapshots: i, maxSnapshots: a, audit: o, dryRun: s, op: c = "set", protectedCtx: l } = e, u = e.value;
|
|
7993
8173
|
if (l) {
|
|
7994
|
-
let e =
|
|
8174
|
+
let e = bu({
|
|
7995
8175
|
value: u,
|
|
7996
8176
|
ctx: l
|
|
7997
8177
|
});
|
|
@@ -8047,7 +8227,7 @@ function hu(e) {
|
|
|
8047
8227
|
data: d.data
|
|
8048
8228
|
};
|
|
8049
8229
|
}
|
|
8050
|
-
function
|
|
8230
|
+
function Du(e) {
|
|
8051
8231
|
let { bindRef: t, patches: n, schema: r, allowKeys: i, snapshots: a, maxSnapshots: o, markDataDirty: s, schemaErrorMode: c = "zod", snapshotLabel: l, dryRun: u, protectedCtx: d } = e, f = Pa(t), p = [];
|
|
8052
8232
|
for (let e = 0; e < n.length; e++) {
|
|
8053
8233
|
let t = n[e], a = t.jsonPath || "";
|
|
@@ -8107,7 +8287,7 @@ function gu(e) {
|
|
|
8107
8287
|
});
|
|
8108
8288
|
}
|
|
8109
8289
|
if (d) {
|
|
8110
|
-
let e =
|
|
8290
|
+
let e = xu({
|
|
8111
8291
|
patches: n,
|
|
8112
8292
|
clone: f,
|
|
8113
8293
|
ctx: d
|
|
@@ -8158,41 +8338,41 @@ function gu(e) {
|
|
|
8158
8338
|
clone: f
|
|
8159
8339
|
};
|
|
8160
8340
|
}
|
|
8161
|
-
function
|
|
8341
|
+
function Ou(e) {
|
|
8162
8342
|
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
8163
8343
|
}
|
|
8164
|
-
function
|
|
8344
|
+
function ku(e, t, n, r) {
|
|
8165
8345
|
if (!t || !n.length || typeof e != "object" || !e) return e;
|
|
8166
8346
|
let i = new Set(n.map((e) => e.field)), a = Pa(e);
|
|
8167
8347
|
return (function e(t) {
|
|
8168
8348
|
if (Array.isArray(t)) for (let n of t) e(n);
|
|
8169
8349
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) {
|
|
8170
8350
|
let a = t[n];
|
|
8171
|
-
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${
|
|
8351
|
+
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${Ou(a.length)}>` : e(a);
|
|
8172
8352
|
}
|
|
8173
8353
|
})(a), a;
|
|
8174
8354
|
}
|
|
8175
|
-
var
|
|
8176
|
-
function
|
|
8177
|
-
return
|
|
8355
|
+
var Au = 0;
|
|
8356
|
+
function ju() {
|
|
8357
|
+
return Au++, "c_" + Math.random().toString(36).slice(2, 8) + Au.toString(36);
|
|
8178
8358
|
}
|
|
8179
|
-
function
|
|
8359
|
+
function Mu(e, t) {
|
|
8180
8360
|
if (!(!e || typeof e != "object")) for (let n of t) {
|
|
8181
8361
|
let t = Z(e, n);
|
|
8182
|
-
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId =
|
|
8362
|
+
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId = ju());
|
|
8183
8363
|
}
|
|
8184
8364
|
}
|
|
8185
|
-
function
|
|
8365
|
+
function Nu(e) {
|
|
8186
8366
|
(function e(t) {
|
|
8187
8367
|
if (Array.isArray(t)) t.forEach(e);
|
|
8188
8368
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) n.startsWith("__pg") ? delete t[n] : e(t[n]);
|
|
8189
8369
|
})(e);
|
|
8190
8370
|
}
|
|
8191
|
-
function
|
|
8192
|
-
let i = n.pgIdPaths ?? [], a = i.length ? (e) =>
|
|
8371
|
+
function Pu(e, n = {}) {
|
|
8372
|
+
let i = n.pgIdPaths ?? [], a = i.length ? (e) => Mu(e, i) : void 0, o = i.length ? da(e.schema, i).schema : e.schema, s = e.bind, c = e.description ?? "主数据对象", l = Wi(o), u = /* @__PURE__ */ new Map(), d = n.vfsStore ? new hu(n.vfsStore) : void 0;
|
|
8193
8373
|
function f(e) {
|
|
8194
8374
|
if (u.clear(), e) for (let t of e) {
|
|
8195
|
-
let e =
|
|
8375
|
+
let e = du(t.path);
|
|
8196
8376
|
u.set(e, {
|
|
8197
8377
|
path: e,
|
|
8198
8378
|
mode: t.mode
|
|
@@ -8265,7 +8445,7 @@ function Cu(e, n = {}) {
|
|
|
8265
8445
|
return e;
|
|
8266
8446
|
},
|
|
8267
8447
|
createResource: d ? (e, t) => {
|
|
8268
|
-
let n =
|
|
8448
|
+
let n = du(e), r = u.get(n), i = t === void 0 ? Z(s, n) : t;
|
|
8269
8449
|
return d.ensure(n, i, r?.mode ?? "verbatim");
|
|
8270
8450
|
} : void 0,
|
|
8271
8451
|
getResource: d ? (e) => {
|
|
@@ -8278,7 +8458,7 @@ function Cu(e, n = {}) {
|
|
|
8278
8458
|
} : void 0;
|
|
8279
8459
|
} : void 0,
|
|
8280
8460
|
updateResource: d ? (e, t) => {
|
|
8281
|
-
let n =
|
|
8461
|
+
let n = du(e);
|
|
8282
8462
|
d.update(n, t), Ma(s, n, t), T();
|
|
8283
8463
|
} : void 0,
|
|
8284
8464
|
deleteResource: d ? (e) => d.delete(e) : void 0,
|
|
@@ -8339,7 +8519,7 @@ function Cu(e, n = {}) {
|
|
|
8339
8519
|
hint: "主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它"
|
|
8340
8520
|
});
|
|
8341
8521
|
let i = r ? Z(s, r) : s;
|
|
8342
|
-
!r && l && (i = $i(i, o)), p && (i =
|
|
8522
|
+
!r && l && (i = $i(i, o)), p && (i = gu({
|
|
8343
8523
|
jp: r,
|
|
8344
8524
|
resolved: i,
|
|
8345
8525
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -8356,7 +8536,7 @@ function Cu(e, n = {}) {
|
|
|
8356
8536
|
if (i !== null) return i;
|
|
8357
8537
|
let a = Fa(e);
|
|
8358
8538
|
if (a.parseError) return Jr("", e, a.parseError);
|
|
8359
|
-
let c =
|
|
8539
|
+
let c = Eu({
|
|
8360
8540
|
bindRef: s,
|
|
8361
8541
|
value: a.parsed,
|
|
8362
8542
|
schema: o,
|
|
@@ -8400,7 +8580,7 @@ function Cu(e, n = {}) {
|
|
|
8400
8580
|
message: `edit 仅适用于对象/数组主数据,当前是 ${s === void 0 ? "undefined" : typeof s}`,
|
|
8401
8581
|
hint: "叶子(原始类型)请用 set_data 整体设置"
|
|
8402
8582
|
});
|
|
8403
|
-
let f =
|
|
8583
|
+
let f = Du({
|
|
8404
8584
|
bindRef: s,
|
|
8405
8585
|
patches: [{
|
|
8406
8586
|
op: r,
|
|
@@ -8466,7 +8646,7 @@ function Cu(e, n = {}) {
|
|
|
8466
8646
|
hint: "仅 schema 声明的 key 可删"
|
|
8467
8647
|
});
|
|
8468
8648
|
if (p) {
|
|
8469
|
-
let t =
|
|
8649
|
+
let t = mu(e, p.resourcesByPath);
|
|
8470
8650
|
if (t) return Y({
|
|
8471
8651
|
code: t.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
8472
8652
|
message: `delete_data @ "${e}" 命中受保护字段 "${t.protectedPath}"(${t.spec.mode}),不可删除`,
|
|
@@ -8570,7 +8750,7 @@ function Cu(e, n = {}) {
|
|
|
8570
8750
|
});
|
|
8571
8751
|
let n = l ? $i(s, o) : s, r;
|
|
8572
8752
|
try {
|
|
8573
|
-
r =
|
|
8753
|
+
r = eu(n, e);
|
|
8574
8754
|
} catch (t) {
|
|
8575
8755
|
return Y({
|
|
8576
8756
|
code: "JSONPATH_SYNTAX",
|
|
@@ -8594,7 +8774,7 @@ function Cu(e, n = {}) {
|
|
|
8594
8774
|
message: "主数据为空,无可搜索内容"
|
|
8595
8775
|
});
|
|
8596
8776
|
try {
|
|
8597
|
-
let a =
|
|
8777
|
+
let a = nu(l ? $i(s, o) : s, e, {
|
|
8598
8778
|
mode: t,
|
|
8599
8779
|
fuzzyThreshold: n,
|
|
8600
8780
|
matchKey: r,
|
|
@@ -8645,7 +8825,7 @@ function Cu(e, n = {}) {
|
|
|
8645
8825
|
e && (c = $i(c, e));
|
|
8646
8826
|
}
|
|
8647
8827
|
} else c = l ? $i(s, o) : s;
|
|
8648
|
-
let u = Pa(c), d = await
|
|
8828
|
+
let u = Pa(c), d = await iu(u, e, a && JSON.stringify(u).length > 1e5 ? 8e3 : 3e3);
|
|
8649
8829
|
if (!d.ok) {
|
|
8650
8830
|
let t = /超时/.test(d.error || "");
|
|
8651
8831
|
return Y({
|
|
@@ -8661,7 +8841,7 @@ function Cu(e, n = {}) {
|
|
|
8661
8841
|
if (t === "transform") {
|
|
8662
8842
|
let e = d.result;
|
|
8663
8843
|
if (a) {
|
|
8664
|
-
let t =
|
|
8844
|
+
let t = Du({
|
|
8665
8845
|
bindRef: s,
|
|
8666
8846
|
patches: [{
|
|
8667
8847
|
op: "set",
|
|
@@ -8689,7 +8869,7 @@ function Cu(e, n = {}) {
|
|
|
8689
8869
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform(patches) 无法就地替换`,
|
|
8690
8870
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
8691
8871
|
});
|
|
8692
|
-
let t =
|
|
8872
|
+
let t = Du({
|
|
8693
8873
|
bindRef: s,
|
|
8694
8874
|
patches: e.patches,
|
|
8695
8875
|
schema: o,
|
|
@@ -8709,7 +8889,7 @@ function Cu(e, n = {}) {
|
|
|
8709
8889
|
}
|
|
8710
8890
|
let t = e;
|
|
8711
8891
|
if (p) {
|
|
8712
|
-
let e =
|
|
8892
|
+
let e = bu({
|
|
8713
8893
|
value: t,
|
|
8714
8894
|
ctx: p
|
|
8715
8895
|
});
|
|
@@ -8758,7 +8938,7 @@ function Cu(e, n = {}) {
|
|
|
8758
8938
|
e && (a = $i(a, e));
|
|
8759
8939
|
}
|
|
8760
8940
|
let c = a;
|
|
8761
|
-
if (p && (c =
|
|
8941
|
+
if (p && (c = gu({
|
|
8762
8942
|
jp: t,
|
|
8763
8943
|
resolved: c,
|
|
8764
8944
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -8768,7 +8948,7 @@ function Cu(e, n = {}) {
|
|
|
8768
8948
|
} catch (e) {
|
|
8769
8949
|
return `- ${t}: [READ_INTERCEPT: ${e.message}]`;
|
|
8770
8950
|
}
|
|
8771
|
-
return r && r.length && (c = Ia(c, r)), i != null && (c = La(c, i)), c =
|
|
8951
|
+
return r && r.length && (c = Ia(c, r)), i != null && (c = La(c, i)), c = ku(c, f === "", C, S), c === void 0 ? `- ${t} = (undefined)` : `- ${t} = ${Q(c)}`;
|
|
8772
8952
|
});
|
|
8773
8953
|
return `多路径读取(共 ${t.length} 项,hash=${m}):\n${e.join("\n")}`;
|
|
8774
8954
|
}
|
|
@@ -8790,7 +8970,7 @@ function Cu(e, n = {}) {
|
|
|
8790
8970
|
e && (g = $i(g, e));
|
|
8791
8971
|
}
|
|
8792
8972
|
let _ = g;
|
|
8793
|
-
if (p && (_ =
|
|
8973
|
+
if (p && (_ = gu({
|
|
8794
8974
|
jp: h,
|
|
8795
8975
|
resolved: _,
|
|
8796
8976
|
resourcesByPath: p.resourcesByPath,
|
|
@@ -8803,7 +8983,7 @@ function Cu(e, n = {}) {
|
|
|
8803
8983
|
message: `read 拦截器抛错: ${e.message}`
|
|
8804
8984
|
});
|
|
8805
8985
|
}
|
|
8806
|
-
r && r.length && (_ = Ia(_, r)), i != null && (_ = La(_, i)), _ =
|
|
8986
|
+
r && r.length && (_ = Ia(_, r)), i != null && (_ = La(_, i)), _ = ku(_, f === "", C, S);
|
|
8807
8987
|
let y = e ? "" : `主数据说明: ${c}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, x = r && r.length ? `(字段裁剪:${r.join(",")})` : "", w = i == null ? "" : `(深度≤${i})`, T = x || w ? ` ${x}${w}` : "";
|
|
8808
8988
|
if ((a !== void 0 || u !== void 0) && Array.isArray(_)) {
|
|
8809
8989
|
let e = _.length, t = Math.max(0, a ?? 0), n = Math.min(200, Math.max(1, u ?? 50)), r = _.slice(t, t + n), i = t + n < e;
|
|
@@ -8876,7 +9056,7 @@ function Cu(e, n = {}) {
|
|
|
8876
9056
|
hint: "仅 schema 声明的 key 可删"
|
|
8877
9057
|
});
|
|
8878
9058
|
if (p) {
|
|
8879
|
-
let e =
|
|
9059
|
+
let e = mu(t.jsonPath, p.resourcesByPath);
|
|
8880
9060
|
if (e) return Y({
|
|
8881
9061
|
code: e.spec.mode === "freeze" ? "FROZEN_FIELD" : "VERBATIM_PROTECTED",
|
|
8882
9062
|
message: `write delete @ "${t.jsonPath}" 命中受保护字段 "${e.protectedPath}"(${e.spec.mode}),不可删除`,
|
|
@@ -8909,7 +9089,7 @@ function Cu(e, n = {}) {
|
|
|
8909
9089
|
op: t.op ?? "set",
|
|
8910
9090
|
jsonPath: t.jsonPath || "",
|
|
8911
9091
|
value: g
|
|
8912
|
-
}]), i =
|
|
9092
|
+
}]), i = Du({
|
|
8913
9093
|
bindRef: s,
|
|
8914
9094
|
patches: n,
|
|
8915
9095
|
schema: o,
|
|
@@ -8926,13 +9106,13 @@ function Cu(e, n = {}) {
|
|
|
8926
9106
|
detail: `${i.applied.length} 个 patch${i.applied.length > 1 ? "(批量)" : ""}`,
|
|
8927
9107
|
value: i.applied.map((e) => `${e.op}@${e.jp}`),
|
|
8928
9108
|
timestamp: Date.now()
|
|
8929
|
-
}), a && (a(s), T()), b($(s), d),
|
|
9109
|
+
}), a && (a(s), T()), b($(s), d), Nu(i.clone), `已 write(edit) 主数据(${i.applied.length} 个 patch)。当前值:${Q(i.clone, 600)} (新 hash=${$(s)})`) : i.error;
|
|
8930
9110
|
}
|
|
8931
9111
|
let C = Fa(g);
|
|
8932
9112
|
if (C.parseError) return Jr("", g, C.parseError);
|
|
8933
9113
|
let w = await k("set", S);
|
|
8934
9114
|
if (w !== null) return w;
|
|
8935
|
-
let E =
|
|
9115
|
+
let E = Eu({
|
|
8936
9116
|
bindRef: s,
|
|
8937
9117
|
value: C.parsed,
|
|
8938
9118
|
schema: o,
|
|
@@ -8948,7 +9128,7 @@ function Cu(e, n = {}) {
|
|
|
8948
9128
|
if (c) return `dryRun(set): schema 校验通过。预览新值:${Q(E.data, 600)}。未实际写入、未入快照。`;
|
|
8949
9129
|
a && (a(s), T());
|
|
8950
9130
|
let ee = $(s);
|
|
8951
|
-
return b(ee, d),
|
|
9131
|
+
return b(ee, d), Nu(E.data), `已 write(set) 主数据 = ${Q(E.data, 600)} (新 hash=${ee})${l ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
8952
9132
|
}, {
|
|
8953
9133
|
name: "write",
|
|
8954
9134
|
description: "写入主数据(高层入口,合并 set/edit/delete + 自动乐观锁 + 自动快照)。四意图:① 整体替换 write({value:整个对象});② 增量 write({patch:{op,jsonPath,value}}) op=set/remove/merge/append/move(move 的 value=目标路径字符串);③ 批量原子 write({patches:[...]})(任一失败整批回滚);④ 删子路径 write({patch:{jsonPath},del:true})。dryRun:true 预检不落盘。写入自动 schema 校验(失败不写,按错误修正重试)+ 自动快照。详细用法见系统提示「能力使用提示」。",
|
|
@@ -9065,7 +9245,7 @@ function Cu(e, n = {}) {
|
|
|
9065
9245
|
}
|
|
9066
9246
|
let f = await k("set", n || (x ? y(a) : void 0));
|
|
9067
9247
|
if (f !== null) return f;
|
|
9068
|
-
let g =
|
|
9248
|
+
let g = Eu({
|
|
9069
9249
|
bindRef: s,
|
|
9070
9250
|
value: d,
|
|
9071
9251
|
schema: o,
|
|
@@ -9097,7 +9277,7 @@ function Cu(e, n = {}) {
|
|
|
9097
9277
|
message: "未提供 path 或有效 handle",
|
|
9098
9278
|
hint: "传 path(受保护字段)或 handle(占位符 ⟦res:handle⟧ 里的句柄)"
|
|
9099
9279
|
});
|
|
9100
|
-
let r =
|
|
9280
|
+
let r = du(n);
|
|
9101
9281
|
if (!u.has(r)) return Y({
|
|
9102
9282
|
code: "RESOURCE_NOT_FOUND",
|
|
9103
9283
|
message: `"${n}" 不是受保护字段`,
|
|
@@ -9137,7 +9317,7 @@ function Cu(e, n = {}) {
|
|
|
9137
9317
|
message: "resource_update 需要 path",
|
|
9138
9318
|
hint: "传要更新的 verbatim 受保护字段路径"
|
|
9139
9319
|
});
|
|
9140
|
-
let i =
|
|
9320
|
+
let i = du(e), a = u.get(i);
|
|
9141
9321
|
if (!a) return Y({
|
|
9142
9322
|
code: "RESOURCE_NOT_FOUND",
|
|
9143
9323
|
message: `"${e}" 不是受保护字段`,
|
|
@@ -9225,8 +9405,8 @@ function Cu(e, n = {}) {
|
|
|
9225
9405
|
}
|
|
9226
9406
|
//#endregion
|
|
9227
9407
|
//#region src/core/tools/fetchDoc.ts
|
|
9228
|
-
var
|
|
9229
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
9408
|
+
var Fu = 3e4, Iu = [r(async ({ url: e, as: t }) => {
|
|
9409
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), Fu);
|
|
9230
9410
|
try {
|
|
9231
9411
|
let r = await fetch(e, {
|
|
9232
9412
|
method: "GET",
|
|
@@ -9243,7 +9423,7 @@ var wu = 3e4, Tu = [r(async ({ url: e, as: t }) => {
|
|
|
9243
9423
|
].join("\n");
|
|
9244
9424
|
} catch (t) {
|
|
9245
9425
|
let r = t?.message || String(t);
|
|
9246
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
9426
|
+
return n.signal.aborted ? `获取失败:请求超时(${Fu}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
9247
9427
|
} finally {
|
|
9248
9428
|
clearTimeout(r);
|
|
9249
9429
|
}
|
|
@@ -9254,7 +9434,7 @@ var wu = 3e4, Tu = [r(async ({ url: e, as: t }) => {
|
|
|
9254
9434
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
9255
9435
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
9256
9436
|
})
|
|
9257
|
-
})],
|
|
9437
|
+
})], Lu = [
|
|
9258
9438
|
"id",
|
|
9259
9439
|
"class",
|
|
9260
9440
|
"href",
|
|
@@ -9266,12 +9446,12 @@ var wu = 3e4, Tu = [r(async ({ url: e, as: t }) => {
|
|
|
9266
9446
|
"aria-label",
|
|
9267
9447
|
"name",
|
|
9268
9448
|
"type"
|
|
9269
|
-
],
|
|
9270
|
-
function
|
|
9449
|
+
], Ru = /^(value|srcdoc|formaction|on\w+)$/i, zu = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
9450
|
+
function Bu(e, t) {
|
|
9271
9451
|
if (!e) return null;
|
|
9272
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
9452
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? Lu, s = (e) => {
|
|
9273
9453
|
let t = {};
|
|
9274
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
9454
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (Ru.test(n.name) || zu.test(n.name) || (t[n.name] = n.value));
|
|
9275
9455
|
return t;
|
|
9276
9456
|
}, c = (e, t) => {
|
|
9277
9457
|
let n = {
|
|
@@ -9287,10 +9467,10 @@ function ku(e, t) {
|
|
|
9287
9467
|
};
|
|
9288
9468
|
return c(e, n);
|
|
9289
9469
|
}
|
|
9290
|
-
var
|
|
9470
|
+
var Vu = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
9291
9471
|
let i = e ? document.querySelector(e) : document.body;
|
|
9292
9472
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
9293
|
-
let a =
|
|
9473
|
+
let a = Bu(i, {
|
|
9294
9474
|
depth: t ?? 3,
|
|
9295
9475
|
attrs: n,
|
|
9296
9476
|
includeText: r ?? !0
|
|
@@ -9305,14 +9485,14 @@ var Au = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
9305
9485
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
9306
9486
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
9307
9487
|
})
|
|
9308
|
-
}),
|
|
9488
|
+
}), Hu = [Vu];
|
|
9309
9489
|
//#endregion
|
|
9310
9490
|
//#region src/core/tools/envTool.ts
|
|
9311
|
-
function
|
|
9491
|
+
function Uu(e) {
|
|
9312
9492
|
let t = e;
|
|
9313
9493
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
9314
9494
|
}
|
|
9315
|
-
function
|
|
9495
|
+
function Wu(e, t = 3, n = 2e3, r) {
|
|
9316
9496
|
if (e == null) return e;
|
|
9317
9497
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
9318
9498
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -9321,14 +9501,14 @@ function Nu(e, t = 3, n = 2e3, r) {
|
|
|
9321
9501
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
9322
9502
|
if (typeof e != "object") return String(e);
|
|
9323
9503
|
let i = e;
|
|
9324
|
-
if (
|
|
9504
|
+
if (Uu(i)) {
|
|
9325
9505
|
let e = i;
|
|
9326
9506
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
9327
9507
|
}
|
|
9328
9508
|
if (r?.has(i)) return "[Circular]";
|
|
9329
9509
|
let a = r ?? /* @__PURE__ */ new WeakSet();
|
|
9330
9510
|
if (a.add(i), Array.isArray(e)) {
|
|
9331
|
-
let r = e.slice(0, 100).map((e) =>
|
|
9511
|
+
let r = e.slice(0, 100).map((e) => Wu(e, t - 1, n, a));
|
|
9332
9512
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
9333
9513
|
}
|
|
9334
9514
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -9340,14 +9520,14 @@ function Nu(e, t = 3, n = 2e3, r) {
|
|
|
9340
9520
|
break;
|
|
9341
9521
|
}
|
|
9342
9522
|
try {
|
|
9343
|
-
o[r] =
|
|
9523
|
+
o[r] = Wu(i[r], t - 1, n, a);
|
|
9344
9524
|
} catch {
|
|
9345
9525
|
o[r] = "(getter 抛错)";
|
|
9346
9526
|
}
|
|
9347
9527
|
}
|
|
9348
9528
|
return o;
|
|
9349
9529
|
}
|
|
9350
|
-
function
|
|
9530
|
+
function Gu(e) {
|
|
9351
9531
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
9352
9532
|
return {
|
|
9353
9533
|
location: {
|
|
@@ -9380,9 +9560,9 @@ function Pu(e) {
|
|
|
9380
9560
|
} : "(无 document)"
|
|
9381
9561
|
};
|
|
9382
9562
|
}
|
|
9383
|
-
var
|
|
9563
|
+
var Ku = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, qu = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, Ju = r(({ key: e }) => {
|
|
9384
9564
|
if (e) {
|
|
9385
|
-
if (
|
|
9565
|
+
if (Ku.test(e) || qu.test(e)) return JSON.stringify({
|
|
9386
9566
|
key: e,
|
|
9387
9567
|
denied: !0,
|
|
9388
9568
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -9392,18 +9572,18 @@ var Fu = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
9392
9572
|
key: e,
|
|
9393
9573
|
exists: t !== void 0,
|
|
9394
9574
|
type: typeof t,
|
|
9395
|
-
value:
|
|
9575
|
+
value: Wu(t)
|
|
9396
9576
|
}, null, 2);
|
|
9397
9577
|
}
|
|
9398
|
-
return JSON.stringify(
|
|
9578
|
+
return JSON.stringify(Gu(), null, 2);
|
|
9399
9579
|
}, {
|
|
9400
9580
|
name: "inspect_env",
|
|
9401
9581
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
9402
9582
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
9403
|
-
}),
|
|
9583
|
+
}), Yu = [Ju];
|
|
9404
9584
|
//#endregion
|
|
9405
9585
|
//#region src/core/harness/budget.ts
|
|
9406
|
-
function
|
|
9586
|
+
function Xu(e, t, n) {
|
|
9407
9587
|
let r = 0;
|
|
9408
9588
|
return {
|
|
9409
9589
|
name: "budget",
|
|
@@ -9428,12 +9608,12 @@ function zu(e, t, n) {
|
|
|
9428
9608
|
}
|
|
9429
9609
|
//#endregion
|
|
9430
9610
|
//#region src/core/sdk/actions.ts
|
|
9431
|
-
var
|
|
9432
|
-
function
|
|
9611
|
+
var Zu = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
9612
|
+
function Qu(e) {
|
|
9433
9613
|
let n = [];
|
|
9434
9614
|
for (let [i, a] of Object.entries(e)) {
|
|
9435
|
-
if (!
|
|
9436
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
9615
|
+
if (!Zu.test(i)) {
|
|
9616
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${Zu}),已跳过`);
|
|
9437
9617
|
continue;
|
|
9438
9618
|
}
|
|
9439
9619
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -9453,9 +9633,9 @@ function Vu(e) {
|
|
|
9453
9633
|
}
|
|
9454
9634
|
return n;
|
|
9455
9635
|
}
|
|
9456
|
-
function
|
|
9636
|
+
function $u(e) {
|
|
9457
9637
|
let t = {};
|
|
9458
|
-
for (let [n, r] of Object.entries(e))
|
|
9638
|
+
for (let [n, r] of Object.entries(e)) Zu.test(n) && (t[n] = {
|
|
9459
9639
|
description: r.description,
|
|
9460
9640
|
hasParams: !!r.params
|
|
9461
9641
|
});
|
|
@@ -9463,12 +9643,12 @@ function Hu(e) {
|
|
|
9463
9643
|
}
|
|
9464
9644
|
//#endregion
|
|
9465
9645
|
//#region src/core/toolsets.ts
|
|
9466
|
-
var
|
|
9467
|
-
function
|
|
9468
|
-
return
|
|
9646
|
+
var ed = Iu, td = Hu;
|
|
9647
|
+
function nd(e, t) {
|
|
9648
|
+
return Pu(e, t);
|
|
9469
9649
|
}
|
|
9470
|
-
function
|
|
9471
|
-
let a =
|
|
9650
|
+
function rd(e, t, n, r, i) {
|
|
9651
|
+
let a = Rl(e);
|
|
9472
9652
|
return [
|
|
9473
9653
|
...a.dataOps ? t : [],
|
|
9474
9654
|
...a.fetch ? n : [],
|
|
@@ -9478,7 +9658,7 @@ function Ku(e, t, n, r, i) {
|
|
|
9478
9658
|
}
|
|
9479
9659
|
//#endregion
|
|
9480
9660
|
//#region src/core/sdk/toolRegistry.ts
|
|
9481
|
-
function
|
|
9661
|
+
function id(e) {
|
|
9482
9662
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
9483
9663
|
for (let r of e) for (let e of r.tools) {
|
|
9484
9664
|
let i = t.get(e.name);
|
|
@@ -9498,15 +9678,15 @@ function qu(e) {
|
|
|
9498
9678
|
}
|
|
9499
9679
|
//#endregion
|
|
9500
9680
|
//#region src/core/harness/usageHints.ts
|
|
9501
|
-
var
|
|
9502
|
-
function
|
|
9503
|
-
let a =
|
|
9681
|
+
var ad = .7;
|
|
9682
|
+
function od(e, t, n = "simple", r, i) {
|
|
9683
|
+
let a = Rl(e), o = n !== "advanced", s = n === "minimal";
|
|
9504
9684
|
return {
|
|
9505
9685
|
name: "usageHints",
|
|
9506
9686
|
augmentPrompt: (n) => {
|
|
9507
9687
|
let r = [];
|
|
9508
9688
|
if (a.planning && (r.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), r.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), r.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), r.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), e?.humanConfirm ? r.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : r.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), r.push(" · 规划阶段有轮次预算(maxPlanRevisions,默认 5):勿反复调研/改计划而不执行,规划充分后即开始 write 落地。")), t && (o ? (r.push("读写主数据用 read/write(高层入口,自动乐观锁 + 自动快照)。read({jsonPath}) 读子路径当前值(返回含 hash,write 时自动比对,无需手动传);read() 不传读整个主数据 + 说明。write 改值两姿势:① 改单个字段/子路径用 write({patch:{op:\"set\", jsonPath:\"路径.字段\", value:新值}})——patch.value 就是该字段的新值(类型匹配:string 直传字符串、number 传数字、对象传对象),不要包成 {字段:值} 对象(字段名已在 jsonPath);也兼容 write({value:新值, patch:{op,jsonPath}}) 顶层 value(向后兼容,但优先 patch.value,避免与整体 set 的 value 混淆);② 替换整个对象用 write({value:{整个新对象}})。op:set 设值 / remove 删 / merge 合并对象 / append 追加数组 / move 移动数组元素(value=目标路径字符串:数组本身=追加到末尾、数组内下标=插到该位置;同数组即重排如组件调序,目标下标按移除源后解释,一步完成免双 set 交换);批量多改动 write({patches:[{op,jsonPath,value},...]});删子路径 write({patch:{jsonPath:\"路径\"}, del:true})。写入自动经 schema 校验(失败不写,按错误提示改值类型/形状后重试)+ 自动存快照" + (s ? "。" : "(出错可用 restore_data 回退)。")), r.push("修改大对象/数组优先用 write 的 patch 增量(只发改动部分),避免整体重传被 max_tokens 截断致 JSON 不完整。"), r.push("读大数组(read 返回 hasMore=true)用 read({jsonPath,offset,limit}) 分页(offset+=limit 续读,默认 limit=50);一次读多个不相关子路径用 read({jsonPaths:[...]}) 省轮次;复杂 patches 改动先 write({patches,dryRun:true}) 预检(走完整校验不落盘)。"), r.push("read/describe 返回按 schema 投影:仅 schema 声明的字段可见(未声明字段自动隐藏,防误操作);要操作某字段需集成方在 schema 声明。"), s || (r.push("查任意路径完整约束或对比快照差异需切 advanced 工具模式(schema_data/diff_data,当前未装载勿调用);查历史快照值(只读不改当前)用 history_data({id?,jsonPath?})。"), r.push("在大数组里按条件筛选用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素 path/index;定位后用 write patch 改。找名字记不清的元素用 search_data(substring/regex/fuzzy)。批量过滤/映射/聚合/重写大数组用 eval_script(沙箱脚本,mode=query 只读/transform 落地)。"))) : (r.push("改主数据前先 get_data({jsonPath}) 读其当前真实值与 hash(返回末尾 hash=xxx),基于真实值改,不要凭记忆。写入(set/edit/delete)时回传 expectedHash=该 hash 启用乐观锁——若主数据在你 get 之后被外部代码/其他 agent/用户手动改过,会触发冲突:集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值与 hash 再改。"), r.push("不确定主数据字段结构时用 describe_data 查看说明。"), r.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), r.push("修改主数据出错时可用 restore_data 回退最近一次。"), r.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), r.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), r.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), r.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), r.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。"))), a.subagent && r.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), a.inspectEnv && r.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), a.domInspect && r.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), a.draftWrite && !o && (r.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。"), r.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=10 可能触顶被 while 截断导致草稿写不完;目标组件数大时集成方应在 createChatSdk 配 maxToolRounds ≥ 20(或按 N+5 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), a.todoDeps && r.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), a.focus && !o && (r.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), r.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), r.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), r.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), r.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), r.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
|
|
9509
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
9689
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= ad || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < ad && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
9510
9690
|
r.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (r.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), r.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && r.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), r.push(o ? " · 方案定稿后,由你(主 agent)用 write 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。" : " · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), r.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
9511
9691
|
}
|
|
9512
9692
|
e?.humanConfirm && (r.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), r.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), r.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), r.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), r.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), r.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
@@ -9526,7 +9706,7 @@ function Yu(e, t, n = "simple", r, i) {
|
|
|
9526
9706
|
}
|
|
9527
9707
|
//#endregion
|
|
9528
9708
|
//#region src/core/harness/resourcesPin.ts
|
|
9529
|
-
function
|
|
9709
|
+
function sd(e) {
|
|
9530
9710
|
let t = e.toolsExposed === !1 ? "读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);resource_get/resource_update 为 advanced 工具,当前模式未装载,勿尝试调用;freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 字段保持原值,勿在当前模式下尝试改写(直接写新值会 VERBATIM_MISMATCH);撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。" : "读到 ⟦frozen:path⟧/⟦res:handle⟧ 占位符 = 精确值在冻结区/资源池(不入消息流);需真值用 resource_get({path});freeze 字段不可写(撞 FROZEN_FIELD 即放弃);verbatim 直接写新值会 VERBATIM_MISMATCH,先 resource_update 再写回句柄;撞 RESOURCE_EVICTED/RESOURCE_NOT_FOUND 重新 read 懒注册。";
|
|
9531
9711
|
return {
|
|
9532
9712
|
name: "resourcesPin",
|
|
@@ -9541,78 +9721,78 @@ function Xu(e) {
|
|
|
9541
9721
|
}
|
|
9542
9722
|
//#endregion
|
|
9543
9723
|
//#region src/core/backends/skillStore.ts
|
|
9544
|
-
var
|
|
9545
|
-
function
|
|
9546
|
-
return `${
|
|
9724
|
+
var cd = "v:1::skill-store", ld = "chat-sdk";
|
|
9725
|
+
function ud(e, t, n) {
|
|
9726
|
+
return `${cd}::${e}::${t}::${n}`;
|
|
9547
9727
|
}
|
|
9548
|
-
function
|
|
9549
|
-
return `${
|
|
9728
|
+
function dd(e, t) {
|
|
9729
|
+
return `${cd}::${e}::${t}::`;
|
|
9550
9730
|
}
|
|
9551
|
-
function
|
|
9552
|
-
let t = e.dbName ??
|
|
9731
|
+
function fd(e = {}) {
|
|
9732
|
+
let t = e.dbName ?? ld, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
9553
9733
|
a = e;
|
|
9554
9734
|
});
|
|
9555
9735
|
return (async () => {
|
|
9556
9736
|
try {
|
|
9557
9737
|
if (n === "indexed") {
|
|
9558
9738
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
9559
|
-
i = await
|
|
9739
|
+
i = await jl(t), a(!0);
|
|
9560
9740
|
} else if (n === "session") {
|
|
9561
9741
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
9562
|
-
i =
|
|
9742
|
+
i = Ml(sessionStorage), a(!0);
|
|
9563
9743
|
} else if (n === "local") {
|
|
9564
9744
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
9565
|
-
i =
|
|
9566
|
-
} else i =
|
|
9745
|
+
i = Ml(localStorage), a(!0);
|
|
9746
|
+
} else i = Al(), a(!1);
|
|
9567
9747
|
} catch {
|
|
9568
|
-
i =
|
|
9748
|
+
i = Al(), a(!1);
|
|
9569
9749
|
}
|
|
9570
9750
|
})(), {
|
|
9571
9751
|
ready: o,
|
|
9572
9752
|
async list() {
|
|
9573
9753
|
let e = [];
|
|
9574
|
-
return await i.scan(
|
|
9754
|
+
return await i.scan(dd(t, r), (t, n) => {
|
|
9575
9755
|
e.push(n);
|
|
9576
9756
|
}), e;
|
|
9577
9757
|
},
|
|
9578
9758
|
async get(e) {
|
|
9579
|
-
return await i.get(
|
|
9759
|
+
return await i.get(ud(t, r, e));
|
|
9580
9760
|
},
|
|
9581
9761
|
async put(e) {
|
|
9582
9762
|
try {
|
|
9583
|
-
await i.set(
|
|
9763
|
+
await i.set(ud(t, r, e.name), e);
|
|
9584
9764
|
} catch (e) {
|
|
9585
|
-
|
|
9765
|
+
Sl(e) && (i = Al());
|
|
9586
9766
|
}
|
|
9587
9767
|
},
|
|
9588
9768
|
async remove(e) {
|
|
9589
|
-
let n =
|
|
9769
|
+
let n = ud(t, r, e);
|
|
9590
9770
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
9591
9771
|
},
|
|
9592
9772
|
async clear() {
|
|
9593
|
-
await i.clearPrefix(
|
|
9773
|
+
await i.clearPrefix(dd(t, r));
|
|
9594
9774
|
},
|
|
9595
9775
|
dispose() {}
|
|
9596
9776
|
};
|
|
9597
9777
|
}
|
|
9598
|
-
var
|
|
9599
|
-
function
|
|
9778
|
+
var pd = /large_results\/[^\s"'`),]+\.txt/g;
|
|
9779
|
+
function md(e) {
|
|
9600
9780
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
9601
9781
|
if (typeof e != "string" || !e) return;
|
|
9602
9782
|
let n;
|
|
9603
|
-
for (
|
|
9783
|
+
for (pd.lastIndex = 0; (n = pd.exec(e)) !== null;) t.add(n[0]);
|
|
9604
9784
|
};
|
|
9605
9785
|
for (let t of e) if (n(t.content), t.steps) for (let e of t.steps) n(e.result);
|
|
9606
9786
|
return t;
|
|
9607
9787
|
}
|
|
9608
|
-
function
|
|
9788
|
+
function hd(e, t) {
|
|
9609
9789
|
let n = [];
|
|
9610
9790
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
9611
9791
|
return n;
|
|
9612
9792
|
}
|
|
9613
9793
|
//#endregion
|
|
9614
9794
|
//#region src/core/utils/serialRunner.ts
|
|
9615
|
-
function
|
|
9795
|
+
function gd() {
|
|
9616
9796
|
let e = Promise.resolve();
|
|
9617
9797
|
return function(t) {
|
|
9618
9798
|
let n = e.then(t, t);
|
|
@@ -9621,24 +9801,24 @@ function ad() {
|
|
|
9621
9801
|
}
|
|
9622
9802
|
//#endregion
|
|
9623
9803
|
//#region src/core/sdk/createChatSdk.ts
|
|
9624
|
-
var
|
|
9625
|
-
function
|
|
9804
|
+
var _d = 30, vd = /* @__PURE__ */ new Map();
|
|
9805
|
+
function yd(e, t) {
|
|
9626
9806
|
return e === "set_data" ? "set" : e === "edit_data" ? "edit" : e === "delete_data" ? "delete" : e === "restore_data" ? "restore" : e === "write" ? t?.del ? "delete" : t?.patch ? "edit" : "set" : null;
|
|
9627
9807
|
}
|
|
9628
|
-
function
|
|
9808
|
+
function bd(e) {
|
|
9629
9809
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
9630
9810
|
}
|
|
9631
|
-
function
|
|
9811
|
+
function xd(e, t, n, r) {
|
|
9632
9812
|
let i = 0;
|
|
9633
9813
|
return {
|
|
9634
9814
|
name: "sdk-events",
|
|
9635
9815
|
wrapToolCall: async (t, r) => {
|
|
9636
|
-
let i = await r(t), a =
|
|
9816
|
+
let i = await r(t), a = yd(t.name, t.args);
|
|
9637
9817
|
return a ? e({
|
|
9638
9818
|
type: "data_change",
|
|
9639
9819
|
operation: a,
|
|
9640
9820
|
value: n()?.bind
|
|
9641
|
-
}) : i.status === "done" &&
|
|
9821
|
+
}) : i.status === "done" && bd(t.name) && e({
|
|
9642
9822
|
type: "data_change",
|
|
9643
9823
|
operation: "edit",
|
|
9644
9824
|
value: n()?.bind
|
|
@@ -9665,7 +9845,7 @@ function ud(e, t, n, r) {
|
|
|
9665
9845
|
}
|
|
9666
9846
|
};
|
|
9667
9847
|
}
|
|
9668
|
-
function
|
|
9848
|
+
function Sd(e, t, n, r, i) {
|
|
9669
9849
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
9670
9850
|
ok: !1,
|
|
9671
9851
|
error: "capabilities.focus 关闭"
|
|
@@ -9683,20 +9863,20 @@ function dd(e, t, n, r, i) {
|
|
|
9683
9863
|
error: "当前无主数据 schema,无法聚焦"
|
|
9684
9864
|
});
|
|
9685
9865
|
}
|
|
9686
|
-
function
|
|
9866
|
+
function Cd(e, n) {
|
|
9687
9867
|
let i = {
|
|
9688
9868
|
prompt_tokens: 0,
|
|
9689
9869
|
completion_tokens: 0,
|
|
9690
9870
|
total_tokens: 0
|
|
9691
|
-
}, a =
|
|
9871
|
+
}, a = ll(() => W), o = /* @__PURE__ */ At(0), s = Fl(e.storage);
|
|
9692
9872
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
9693
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } =
|
|
9873
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } = cl(e), f = c;
|
|
9694
9874
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", f), f.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${f.contextWindow} 小于最小支持 ${ii}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
9695
|
-
let h =
|
|
9875
|
+
let h = Hl(e, f.contextWindow), g = h.enableLLMSummary !== !1, _ = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? Vl[e.contextPreset ?? "auto"], v = new Set(_), y = e.llm;
|
|
9696
9876
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
9697
9877
|
let b = /* @__PURE__ */ bt([]), x = sc(e.vfs?.initialFiles, {
|
|
9698
9878
|
persist: s ? { save: (e) => {
|
|
9699
|
-
|
|
9879
|
+
q.sessionId && s && s.save(n, q.sessionId, { vfs: e });
|
|
9700
9880
|
} } : void 0,
|
|
9701
9881
|
maxBytes: e.vfs?.maxBytes,
|
|
9702
9882
|
poolBytes: e.vfs?.poolBytes
|
|
@@ -9713,8 +9893,8 @@ function fd(e, n) {
|
|
|
9713
9893
|
let D = { current: null }, O = e.data ? {
|
|
9714
9894
|
...e.data,
|
|
9715
9895
|
description: e.data.description ?? "主数据对象"
|
|
9716
|
-
} : void 0, k = !(e.subagents ?? []).some((e) => e._codeAsset) &&
|
|
9717
|
-
k && O?.schema && Qi(O.schema).length && (ee = [...e.subagents ?? [],
|
|
9896
|
+
} : void 0, k = !(e.subagents ?? []).some((e) => e._codeAsset) && Rl(e.capabilities).subagent, ee = e.subagents;
|
|
9897
|
+
k && O?.schema && Qi(O.schema).length && (ee = [...e.subagents ?? [], qc()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
9718
9898
|
let A = (ee ?? []).filter((e) => !!e._codeAsset), j = /* @__PURE__ */ new Set();
|
|
9719
9899
|
for (let e of A) {
|
|
9720
9900
|
if (e._codeAsset.writablePaths.length) continue;
|
|
@@ -9730,12 +9910,12 @@ function fd(e, n) {
|
|
|
9730
9910
|
getTodos: () => D.current?.getState?.()?.todos ?? [],
|
|
9731
9911
|
messages: b,
|
|
9732
9912
|
maxCheckpoints: ie && typeof ie == "object" ? ie.maxCheckpoints : void 0
|
|
9733
|
-
}) : null, oe = !ie || typeof ie != "object" || ie.auto !== !1, F =
|
|
9913
|
+
}) : null, oe = !ie || typeof ie != "object" || ie.auto !== !1, F = Rl(e.capabilities), se = F.dataOps, ce = F.draftWrite, le = F.tracing, ue = F.automation, de = rc(e);
|
|
9734
9914
|
if (ne) {
|
|
9735
9915
|
let e = te.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
9736
9916
|
e && (de += "\n\n" + e);
|
|
9737
9917
|
} else O?.schema && Zi(O.schema) && (de += "\n\n" + ha.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
9738
|
-
let fe = se && O ?
|
|
9918
|
+
let fe = se && O ? Pu(O, {
|
|
9739
9919
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
9740
9920
|
maxSnapshots: e.maxSnapshots,
|
|
9741
9921
|
onConflict: a.set,
|
|
@@ -9744,18 +9924,18 @@ function fd(e, n) {
|
|
|
9744
9924
|
vfsStore: ce || O?.resources?.length ? x : void 0,
|
|
9745
9925
|
...N.length ? { pgIdPaths: N } : {},
|
|
9746
9926
|
...re.length ? { largeTextPaths: re } : {}
|
|
9747
|
-
}) : [], pe = se ?
|
|
9927
|
+
}) : [], pe = se ? Tu(fe, e.toolMode) : [], I = se && O ? fe.controller ?? null : null, me = se && O?.resources?.length && I?.getResourcesSnapshot ? sd({
|
|
9748
9928
|
getResourcesSnapshot: () => I?.getResourcesSnapshot?.() ?? [],
|
|
9749
9929
|
toolsExposed: e.toolMode === "advanced"
|
|
9750
|
-
}) : void 0, L = () => I?.get() ?? O, R = /* @__PURE__ */ new Map(), he =
|
|
9930
|
+
}) : void 0, L = () => I?.get() ?? O, R = /* @__PURE__ */ new Map(), he = rd(F, pe, Iu, Hu, Yu);
|
|
9751
9931
|
he.forEach((e) => R.set(e.name, "builtin"));
|
|
9752
9932
|
let z = [...e.tools || []];
|
|
9753
9933
|
z.forEach((e) => R.set(e.name, "user"));
|
|
9754
|
-
let ge =
|
|
9934
|
+
let ge = Qu(e.actions ?? {});
|
|
9755
9935
|
ge.forEach((e) => R.set(e.name, "action"));
|
|
9756
|
-
let _e = [], ve = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1),
|
|
9757
|
-
|
|
9758
|
-
let
|
|
9936
|
+
let _e = [], ve = !1, ye = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), be = ye ? jo() : null;
|
|
9937
|
+
be && R.set(ko, "builtin");
|
|
9938
|
+
let xe = ae && P ? [r(async () => {
|
|
9759
9939
|
let e = P.list();
|
|
9760
9940
|
return e.length ? P.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
9761
9941
|
}, {
|
|
@@ -9770,8 +9950,8 @@ function fd(e, n) {
|
|
|
9770
9950
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
9771
9951
|
schema: t.object({}).optional()
|
|
9772
9952
|
})] : [];
|
|
9773
|
-
|
|
9774
|
-
let B = F.focus,
|
|
9953
|
+
xe.forEach((e) => R.set(e.name, "builtin"));
|
|
9954
|
+
let B = F.focus, Se = r(async ({ path: e, label: t }) => {
|
|
9775
9955
|
let n = L()?.schema;
|
|
9776
9956
|
return n ? qi(n, e) ? (w.setFocus({
|
|
9777
9957
|
path: e,
|
|
@@ -9784,11 +9964,11 @@ function fd(e, n) {
|
|
|
9784
9964
|
path: t.string().describe("要聚焦的组件 jsonPath,如 components.3"),
|
|
9785
9965
|
label: t.string().optional().describe("人类可读标签,如「导航栏」")
|
|
9786
9966
|
})
|
|
9787
|
-
}),
|
|
9967
|
+
}), Ce = r(async () => (w.clearFocus(), "已清除聚焦,恢复全量可操作范围(可读写所有组件)。"), {
|
|
9788
9968
|
name: "clear_focus",
|
|
9789
9969
|
description: "清除当前聚焦,退出精修模式,恢复对全部组件的读写权限。",
|
|
9790
9970
|
schema: t.object({}).optional()
|
|
9791
|
-
}),
|
|
9971
|
+
}), we = r(async ({ path: e, label: t }) => {
|
|
9792
9972
|
let n = L()?.schema;
|
|
9793
9973
|
if (!n) return "聚焦失败:当前无主数据 schema,无法聚焦。";
|
|
9794
9974
|
if (!qi(n, e)) return `PATH_DENIED · 聚焦失败:path "${e}" 不在 schema 内。请先用 read 查看可操作路径再聚焦。`;
|
|
@@ -9805,7 +9985,7 @@ function fd(e, n) {
|
|
|
9805
9985
|
path: t.string().describe("要追加聚焦的组件 jsonPath,如 components.3"),
|
|
9806
9986
|
label: t.string().optional().describe("人类可读标签")
|
|
9807
9987
|
})
|
|
9808
|
-
}),
|
|
9988
|
+
}), Te = r(async ({ path: e }) => {
|
|
9809
9989
|
let t = w.getFocuses().length;
|
|
9810
9990
|
w.removeFocus(e);
|
|
9811
9991
|
let n = w.getFocuses();
|
|
@@ -9814,16 +9994,16 @@ function fd(e, n) {
|
|
|
9814
9994
|
name: "remove_focus",
|
|
9815
9995
|
description: "移除单个聚焦焦点(by path),保留其他焦点。移除最后一个等价退出精修。全部退出用 clear_focus。",
|
|
9816
9996
|
schema: t.object({ path: t.string().describe("要移除的焦点 jsonPath") })
|
|
9817
|
-
}),
|
|
9818
|
-
xe,
|
|
9997
|
+
}), Ee = B && e.toolMode === "advanced" ? [
|
|
9819
9998
|
Se,
|
|
9820
9999
|
Ce,
|
|
9821
|
-
we
|
|
10000
|
+
we,
|
|
10001
|
+
Te
|
|
9822
10002
|
] : [];
|
|
9823
|
-
|
|
9824
|
-
let
|
|
9825
|
-
function
|
|
9826
|
-
let { tools: e, collisions: t } =
|
|
10003
|
+
Ee.forEach((e) => R.set(e.name, "builtin"));
|
|
10004
|
+
let De = [], Oe = /* @__PURE__ */ new Map(), V = ke();
|
|
10005
|
+
function ke() {
|
|
10006
|
+
let { tools: e, collisions: t } = id([
|
|
9827
10007
|
{
|
|
9828
10008
|
label: "builtin",
|
|
9829
10009
|
tools: he
|
|
@@ -9838,15 +10018,15 @@ function fd(e, n) {
|
|
|
9838
10018
|
},
|
|
9839
10019
|
{
|
|
9840
10020
|
label: "humanConfirm",
|
|
9841
|
-
tools:
|
|
10021
|
+
tools: be ? [be] : []
|
|
9842
10022
|
},
|
|
9843
10023
|
{
|
|
9844
10024
|
label: "checkpoint",
|
|
9845
|
-
tools:
|
|
10025
|
+
tools: xe
|
|
9846
10026
|
},
|
|
9847
10027
|
{
|
|
9848
10028
|
label: "focus",
|
|
9849
|
-
tools:
|
|
10029
|
+
tools: Ee
|
|
9850
10030
|
},
|
|
9851
10031
|
{
|
|
9852
10032
|
label: "mcp",
|
|
@@ -9854,43 +10034,43 @@ function fd(e, n) {
|
|
|
9854
10034
|
},
|
|
9855
10035
|
{
|
|
9856
10036
|
label: "skill",
|
|
9857
|
-
tools:
|
|
10037
|
+
tools: De
|
|
9858
10038
|
}
|
|
9859
10039
|
]);
|
|
9860
10040
|
return t.length && console.warn("[page-agent-sdk] 工具重名,后注册覆盖先注册:", t.map((e) => `${e.name}(${e.loser}→${e.winner})`).join(", ")), e;
|
|
9861
10041
|
}
|
|
9862
|
-
let
|
|
9863
|
-
if (
|
|
9864
|
-
if (
|
|
9865
|
-
let
|
|
10042
|
+
let Ae = F.planning, je = F.missionAnchor, Me = F.workingMemory, Ne = F.skills, Pe = F.vfs || ne;
|
|
10043
|
+
if (Pe) for (let e of mc) R.set(e, "builtin");
|
|
10044
|
+
if (Ae) for (let e of S.tools ?? []) R.set(e.name, "builtin");
|
|
10045
|
+
let Fe = F.summarization, Ie = F.agentCompression && !!d;
|
|
9866
10046
|
e.debug && F.agentCompression && !d && console.warn("[page-agent-sdk][agentCompression] agentCompression 开启但 summaryLlm 不可用(或缺 apiKey / 模型不支持工具),压缩决策不启用,回退静态压缩");
|
|
9867
|
-
let
|
|
9868
|
-
|
|
9869
|
-
let
|
|
9870
|
-
llm:
|
|
9871
|
-
allTools: () =>
|
|
9872
|
-
allowedTools:
|
|
9873
|
-
systemPrompt:
|
|
9874
|
-
temperature:
|
|
9875
|
-
maxTokens:
|
|
9876
|
-
skills:
|
|
9877
|
-
maxDepth:
|
|
9878
|
-
maxParallel:
|
|
10047
|
+
let Le = F.memory, Re = F.subagent, ze = Re ? ls() : void 0, Be = e.verify?.maxAttempts ?? 2, H = !!(e.verify?.check || e.verify?.maxAttempts || e.verify?.adversarial), Ve = e.capabilities?.verify === !1, He = (F.verify || H && !Ve) && e.verify?.enabled !== !1 && Be > 0, Ue = F.contextInspector;
|
|
10048
|
+
H && !He && e.verify?.enabled !== !1 && console.warn("[page-agent-sdk][verify] 检测到 verify 配置(check/maxAttempts/adversarial)但未装载(capabilities.verify:false 显式关闭 或 maxAttempts≤0)");
|
|
10049
|
+
let U = e.subagent, We = U?.allowedTools ?? [], Ge = e.permissions?.length ? Do(e.permissions) : void 0, Ke = e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? Oo(e.approval) : void 0, qe = [...Ge ? [Ge] : [], ...Ke ? [Ke] : []], Je = !Re || U?.enabled === !1 ? void 0 : Ts({
|
|
10050
|
+
llm: U?.llm ?? e.llm,
|
|
10051
|
+
allTools: () => q.agent?.allTools ?? V,
|
|
10052
|
+
allowedTools: We.length ? We : void 0,
|
|
10053
|
+
systemPrompt: U?.systemPrompt,
|
|
10054
|
+
temperature: U?.temperature,
|
|
10055
|
+
maxTokens: U?.maxTokens,
|
|
10056
|
+
skills: U?.skills,
|
|
10057
|
+
maxDepth: U?.maxDepth,
|
|
10058
|
+
maxParallel: U?.maxParallel,
|
|
9879
10059
|
debug: e.debug,
|
|
9880
10060
|
getFocuses: () => w.getFocuses(),
|
|
9881
10061
|
getSchema: () => L()?.schema ?? null,
|
|
9882
|
-
tracker:
|
|
9883
|
-
guardMiddleware:
|
|
9884
|
-
getVfsFiles:
|
|
10062
|
+
tracker: ze,
|
|
10063
|
+
guardMiddleware: qe.length ? qe : void 0,
|
|
10064
|
+
getVfsFiles: Pe ? () => x.files : void 0,
|
|
9885
10065
|
enterDataScope: I?.enterScope ? (e) => I.enterScope(e) : void 0,
|
|
9886
10066
|
exitDataScope: I?.exitScope ? (e) => I.exitScope(e) : void 0,
|
|
9887
10067
|
onUsage: (e) => {
|
|
9888
10068
|
i.prompt_tokens = (i.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), i.completion_tokens = (i.completion_tokens ?? 0) + (e.completion_tokens ?? 0), i.total_tokens = (i.total_tokens ?? 0) + (e.total_tokens ?? 0);
|
|
9889
10069
|
},
|
|
9890
|
-
timeoutMs:
|
|
9891
|
-
}),
|
|
10070
|
+
timeoutMs: U?.timeoutMs
|
|
10071
|
+
}), Ye = M?.map((e) => {
|
|
9892
10072
|
if (!e._codeAsset) return e;
|
|
9893
|
-
let t = e._codeAsset, n =
|
|
10073
|
+
let t = e._codeAsset, n = Mc({
|
|
9894
10074
|
writablePaths: t.writablePaths,
|
|
9895
10075
|
codeVfsPrefix: t.codeVfsPrefix,
|
|
9896
10076
|
ext: t.ext,
|
|
@@ -9905,51 +10085,59 @@ function fd(e, n) {
|
|
|
9905
10085
|
...e,
|
|
9906
10086
|
middleware: r
|
|
9907
10087
|
};
|
|
9908
|
-
}),
|
|
10088
|
+
}), Xe = ne && Re ? Nc() : void 0, Ze = Xe ? Bc({
|
|
10089
|
+
getBind: () => L()?.bind,
|
|
10090
|
+
writablePaths: N,
|
|
10091
|
+
getLocked: () => Xe.locked()
|
|
10092
|
+
}) : void 0, Qe = Re && Ye !== void 0 ? Os(Ye, {
|
|
9909
10093
|
llm: e.llm,
|
|
9910
|
-
allTools: () =>
|
|
10094
|
+
allTools: () => q.agent?.allTools ?? V,
|
|
9911
10095
|
debug: e.debug,
|
|
9912
10096
|
getFocuses: () => w.getFocuses(),
|
|
9913
10097
|
getSchema: () => L()?.schema ?? null,
|
|
9914
10098
|
getBind: () => L()?.bind,
|
|
9915
|
-
tracker:
|
|
9916
|
-
guardMiddleware:
|
|
9917
|
-
getVfsFiles:
|
|
10099
|
+
tracker: ze,
|
|
10100
|
+
guardMiddleware: qe.length ? qe : void 0,
|
|
10101
|
+
getVfsFiles: Pe ? () => x.files : void 0,
|
|
9918
10102
|
enterDataScope: I?.enterScope ? (e) => I.enterScope(e) : void 0,
|
|
9919
10103
|
exitDataScope: I?.exitScope ? (e) => I.exitScope(e) : void 0,
|
|
9920
10104
|
onUsage: (e) => {
|
|
9921
10105
|
i.prompt_tokens = (i.prompt_tokens ?? 0) + (e.prompt_tokens ?? 0), i.completion_tokens = (i.completion_tokens ?? 0) + (e.completion_tokens ?? 0), i.total_tokens = (i.total_tokens ?? 0) + (e.total_tokens ?? 0);
|
|
9922
10106
|
},
|
|
9923
|
-
timeoutMs: e.subagent?.timeoutMs
|
|
9924
|
-
|
|
10107
|
+
timeoutMs: e.subagent?.timeoutMs,
|
|
10108
|
+
...Xe ? {
|
|
10109
|
+
componentLock: Xe,
|
|
10110
|
+
resolveComponents: (e) => Pc(e, Oc(L()?.bind, N))
|
|
10111
|
+
} : {}
|
|
10112
|
+
}) : void 0, $e = Qe ? Qe.controller : null, et = [
|
|
9925
10113
|
"get_data",
|
|
9926
10114
|
"describe_data",
|
|
9927
10115
|
"read",
|
|
9928
10116
|
"fetch_document"
|
|
9929
|
-
],
|
|
10117
|
+
], tt = V.filter((e) => et.includes(e.name)), nt = He ? ks({
|
|
9930
10118
|
check: e.verify.check ?? Fs({
|
|
9931
10119
|
schemas: () => L() ? { "": L().schema } : {},
|
|
9932
10120
|
root: () => L()?.bind
|
|
9933
10121
|
}),
|
|
9934
10122
|
adversarial: e.verify?.adversarial ? {
|
|
9935
10123
|
llm: e.llm,
|
|
9936
|
-
tools:
|
|
10124
|
+
tools: tt
|
|
9937
10125
|
} : void 0
|
|
9938
|
-
}) : void 0,
|
|
10126
|
+
}) : void 0, rt = Ue ? Ys({
|
|
9939
10127
|
contextWindow: f.contextWindow,
|
|
9940
|
-
thresholdRatio:
|
|
9941
|
-
}) : void 0,
|
|
10128
|
+
thresholdRatio: Hl(e, f.contextWindow).summaryThresholdRatio
|
|
10129
|
+
}) : void 0, it = od({
|
|
9942
10130
|
...F,
|
|
9943
|
-
humanConfirm:
|
|
10131
|
+
humanConfirm: ye,
|
|
9944
10132
|
subagents: M?.map((e) => ({
|
|
9945
10133
|
id: e.id,
|
|
9946
10134
|
description: e.description,
|
|
9947
10135
|
temperature: e.temperature
|
|
9948
10136
|
}))
|
|
9949
|
-
}, se && !!O, e.toolMode, !!O?.resources?.length, { promptSoftCap: is(f.contextWindow, h.promptSoftCapTokens) }),
|
|
10137
|
+
}, se && !!O, e.toolMode, !!O?.resources?.length, { promptSoftCap: is(f.contextWindow, h.promptSoftCapTokens) }), at = O ? {
|
|
9950
10138
|
name: "dataHint",
|
|
9951
10139
|
augmentPrompt: () => nc(L(), e.schemaHint) || void 0
|
|
9952
|
-
} : null,
|
|
10140
|
+
} : null, ot = e.augmentSystem ? {
|
|
9953
10141
|
name: "augmentSystem",
|
|
9954
10142
|
augmentPrompt: (t) => {
|
|
9955
10143
|
try {
|
|
@@ -9962,86 +10150,87 @@ function fd(e, n) {
|
|
|
9962
10150
|
return;
|
|
9963
10151
|
}
|
|
9964
10152
|
}
|
|
9965
|
-
} : null,
|
|
10153
|
+
} : null, st = zl(e.onEvent), W = st.emit, ct, lt = [], ut = (e) => ({
|
|
9966
10154
|
name: e.name,
|
|
9967
10155
|
description: e.description,
|
|
9968
10156
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
9969
|
-
}),
|
|
10157
|
+
}), dt = (e) => ({
|
|
9970
10158
|
name: e.name,
|
|
9971
10159
|
description: e.description,
|
|
9972
10160
|
getContent: () => e.content
|
|
9973
|
-
}),
|
|
10161
|
+
}), ft = e.skillStorage === !1 ? null : fd({
|
|
9974
10162
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
9975
10163
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
9976
|
-
}),
|
|
9977
|
-
let t =
|
|
10164
|
+
}), pt = () => {
|
|
10165
|
+
let t = ct ? ct.controller : null;
|
|
9978
10166
|
if (t) {
|
|
9979
|
-
let n = (e.skills || []).filter((e) => !
|
|
9980
|
-
t.set([...n, ...
|
|
10167
|
+
let n = (e.skills || []).filter((e) => !lt.some((t) => t.name === e.name));
|
|
10168
|
+
t.set([...n, ...lt]);
|
|
9981
10169
|
}
|
|
9982
|
-
|
|
9983
|
-
},
|
|
9984
|
-
if (
|
|
9985
|
-
let t = await
|
|
10170
|
+
q.infoTick.value++;
|
|
10171
|
+
}, mt = async () => {
|
|
10172
|
+
if (ft) try {
|
|
10173
|
+
let t = await ft.list();
|
|
9986
10174
|
if (t.length) {
|
|
9987
|
-
|
|
9988
|
-
let n =
|
|
10175
|
+
lt = t.map(dt);
|
|
10176
|
+
let n = ct ? ct.controller : null;
|
|
9989
10177
|
if (n) {
|
|
9990
|
-
let t = (e.skills || []).filter((e) => !
|
|
9991
|
-
n.set([...t, ...
|
|
10178
|
+
let t = (e.skills || []).filter((e) => !lt.some((t) => t.name === e.name));
|
|
10179
|
+
n.set([...t, ...lt]);
|
|
9992
10180
|
}
|
|
9993
|
-
|
|
10181
|
+
q.infoTick.value++;
|
|
9994
10182
|
}
|
|
9995
10183
|
} catch {}
|
|
9996
|
-
},
|
|
10184
|
+
}, ht = Fe ? cs({
|
|
9997
10185
|
...h,
|
|
9998
10186
|
llmInvoke: l,
|
|
9999
10187
|
getRegisteredData: () => L() ? [{ description: L().description ?? "主数据对象" }] : [],
|
|
10000
10188
|
preserveLastToolResults: _,
|
|
10001
|
-
...
|
|
10189
|
+
...Ie ? {
|
|
10002
10190
|
decideInvoke: d,
|
|
10003
|
-
getSnapshot: () =>
|
|
10191
|
+
getSnapshot: () => rt?.getSnapshot()
|
|
10004
10192
|
} : {}
|
|
10005
|
-
}) : void 0,
|
|
10006
|
-
...
|
|
10007
|
-
|
|
10008
|
-
...
|
|
10009
|
-
...
|
|
10010
|
-
...
|
|
10011
|
-
readVfs:
|
|
10193
|
+
}) : void 0, gt = Wl([
|
|
10194
|
+
...at ? [at] : [],
|
|
10195
|
+
it,
|
|
10196
|
+
...je ? [C] : [],
|
|
10197
|
+
...Ae ? [S] : [],
|
|
10198
|
+
...Ne ? [ct = bo(e.skills || [], {
|
|
10199
|
+
readVfs: Pe ? (e) => x.files[e]?.content : void 0,
|
|
10012
10200
|
hostScriptEnabled: F.skillHostScript,
|
|
10013
10201
|
onToolsReady: (e, t) => {
|
|
10014
10202
|
for (let n of t) {
|
|
10015
|
-
let t =
|
|
10016
|
-
t >= 0 &&
|
|
10203
|
+
let t = De.findIndex((e) => e.name === n.name);
|
|
10204
|
+
t >= 0 && De.splice(t, 1), De.push(n), Oe.set(n.name, e), R.set(n.name, `skill:${e}`);
|
|
10017
10205
|
}
|
|
10018
|
-
V =
|
|
10206
|
+
V = ke(), q.agent && q.agent.setTools(V), q.infoTick.value++;
|
|
10019
10207
|
}
|
|
10020
10208
|
})] : [],
|
|
10021
|
-
...
|
|
10022
|
-
...
|
|
10023
|
-
...
|
|
10209
|
+
...Pe ? [gc(x)] : [],
|
|
10210
|
+
...ht ? [ht] : [],
|
|
10211
|
+
...Me ? [T] : [],
|
|
10024
10212
|
...B ? [w] : [],
|
|
10025
10213
|
...me ? [me] : [],
|
|
10026
|
-
...
|
|
10027
|
-
...We ? [We] : [],
|
|
10028
|
-
...ae && oe && P ? [Bo(P)] : [],
|
|
10029
|
-
...ve ? [Mo()] : [],
|
|
10214
|
+
...Le ? [E] : [],
|
|
10030
10215
|
...Ge ? [Ge] : [],
|
|
10031
|
-
|
|
10032
|
-
...
|
|
10033
|
-
...
|
|
10216
|
+
...ae && oe && P ? [Bo(P)] : [],
|
|
10217
|
+
...ye ? [Mo()] : [],
|
|
10218
|
+
...Ke ? [Ke] : [],
|
|
10219
|
+
...nt ? [nt] : [],
|
|
10220
|
+
...Je ? [Je] : [],
|
|
10221
|
+
...Qe ? [Qe] : [],
|
|
10222
|
+
...Ze ? [Ze] : [],
|
|
10223
|
+
...ot ? [ot] : [],
|
|
10034
10224
|
...rt ? [rt] : [],
|
|
10035
|
-
...et ? [et] : [],
|
|
10036
10225
|
...e.middleware || [],
|
|
10037
|
-
...ue ? [
|
|
10226
|
+
...ue ? [Xu(i, {
|
|
10038
10227
|
tokenBudget: e.tokenBudget,
|
|
10039
10228
|
timeBudgetMs: e.timeBudgetMs
|
|
10040
10229
|
}, W)] : [],
|
|
10041
|
-
|
|
10042
|
-
]),
|
|
10043
|
-
function
|
|
10044
|
-
if (
|
|
10230
|
+
xd(W, b, L, i)
|
|
10231
|
+
]), _t = e.maxMemoryRounds ?? _d, vt = e.approval?.timeoutMs, yt = vt === void 0 || vt === 0 ? 3e4 : !Number.isFinite(vt) || vt < 0 ? 0 : vt;
|
|
10232
|
+
function xt(e) {
|
|
10233
|
+
if (yt) return (t) => {
|
|
10045
10234
|
if (t.type !== "approval_request") return;
|
|
10046
10235
|
let n = Date.now(), r = t.toolName;
|
|
10047
10236
|
setTimeout(() => {
|
|
@@ -10055,37 +10244,37 @@ function fd(e, n) {
|
|
|
10055
10244
|
waitedMs: Date.now() - n
|
|
10056
10245
|
}
|
|
10057
10246
|
}));
|
|
10058
|
-
},
|
|
10247
|
+
}, yt);
|
|
10059
10248
|
};
|
|
10060
10249
|
}
|
|
10061
|
-
function
|
|
10062
|
-
let t =
|
|
10250
|
+
function St(e) {
|
|
10251
|
+
let t = xt(e);
|
|
10063
10252
|
return (e) => {
|
|
10064
10253
|
t?.(e), e.type === "error" && W(e);
|
|
10065
10254
|
};
|
|
10066
10255
|
}
|
|
10067
|
-
let
|
|
10068
|
-
async function
|
|
10069
|
-
s && (
|
|
10256
|
+
let Ct = /* @__PURE__ */ At([]);
|
|
10257
|
+
async function wt() {
|
|
10258
|
+
s && (Ct.value = (await s.listSessions(n)).sort((e, t) => t.lastAccessed - e.lastAccessed));
|
|
10070
10259
|
}
|
|
10071
|
-
let
|
|
10072
|
-
function
|
|
10260
|
+
let Tt = gd(), G = /* @__PURE__ */ new Set();
|
|
10261
|
+
function Et(e) {
|
|
10073
10262
|
let t = new AbortController();
|
|
10074
|
-
return e && (e.aborted ? t.abort() : e.addEventListener("abort", () => t.abort(), { once: !0 })),
|
|
10263
|
+
return e && (e.aborted ? t.abort() : e.addEventListener("abort", () => t.abort(), { once: !0 })), G.add(t), {
|
|
10075
10264
|
controller: t,
|
|
10076
|
-
untrack: () =>
|
|
10265
|
+
untrack: () => G.delete(t)
|
|
10077
10266
|
};
|
|
10078
10267
|
}
|
|
10079
|
-
function
|
|
10080
|
-
for (let e of
|
|
10081
|
-
|
|
10268
|
+
function K() {
|
|
10269
|
+
for (let e of G) e.abort();
|
|
10270
|
+
G.clear();
|
|
10082
10271
|
}
|
|
10083
|
-
let
|
|
10272
|
+
let q = {
|
|
10084
10273
|
agentId: n,
|
|
10085
10274
|
store: s,
|
|
10086
10275
|
messages: b,
|
|
10087
10276
|
vfsStore: x,
|
|
10088
|
-
listeners:
|
|
10277
|
+
listeners: st.listeners,
|
|
10089
10278
|
todosMw: S,
|
|
10090
10279
|
memoryMw: E,
|
|
10091
10280
|
missionMw: C,
|
|
@@ -10099,30 +10288,30 @@ function fd(e, n) {
|
|
|
10099
10288
|
mcpServers: [],
|
|
10100
10289
|
checkpoint: P,
|
|
10101
10290
|
dataOpsController: I,
|
|
10102
|
-
skillsController:
|
|
10291
|
+
skillsController: ct ? ct.controller : null,
|
|
10103
10292
|
infoTick: o,
|
|
10104
10293
|
pendingConflict: a.pendingConflict,
|
|
10105
|
-
sessions:
|
|
10106
|
-
refreshSessions:
|
|
10294
|
+
sessions: Ct,
|
|
10295
|
+
refreshSessions: wt,
|
|
10107
10296
|
liveData: L,
|
|
10108
10297
|
usage: i,
|
|
10109
10298
|
emit: W,
|
|
10110
|
-
runSerial:
|
|
10111
|
-
trackActive:
|
|
10112
|
-
abortAllActive:
|
|
10299
|
+
runSerial: Tt,
|
|
10300
|
+
trackActive: Et,
|
|
10301
|
+
abortAllActive: K,
|
|
10113
10302
|
unloadSkillTools(e) {
|
|
10114
10303
|
if (e) {
|
|
10115
|
-
let t =
|
|
10116
|
-
if (
|
|
10304
|
+
let t = De.length;
|
|
10305
|
+
if (De = De.filter((t) => Oe.get(t.name) === e ? (R.delete(t.name), Oe.delete(t.name), !1) : !0), De.length === t) return;
|
|
10117
10306
|
} else {
|
|
10118
|
-
if (!
|
|
10119
|
-
for (let e of
|
|
10120
|
-
|
|
10307
|
+
if (!De.length) return;
|
|
10308
|
+
for (let e of De) R.delete(e.name), Oe.delete(e.name);
|
|
10309
|
+
De = [];
|
|
10121
10310
|
}
|
|
10122
|
-
V =
|
|
10311
|
+
V = ke(), q.agent && q.agent.setTools(V);
|
|
10123
10312
|
},
|
|
10124
10313
|
applySnapshot(t) {
|
|
10125
|
-
if (t.messages?.length && b.push(...t.messages), t.vfs && x.hydrate && x.hydrate(t.vfs), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && E.reset(t.memory), t.checkpoints?.length && P && P.importStack(t.checkpoints), t.usage && Object.assign(i, t.usage), t.mission &&
|
|
10314
|
+
if (t.messages?.length && b.push(...t.messages), t.vfs && x.hydrate && x.hydrate(t.vfs), t.todos?.length && S.reset(t.todos), t.memory && !e.memory && E.reset(t.memory), t.checkpoints?.length && P && P.importStack(t.checkpoints), t.usage && Object.assign(i, t.usage), t.mission && je && C.setMission(t.mission), t.workingMemory && Me && T.restore(t.workingMemory), B) {
|
|
10126
10315
|
let n = t.focus, r = n ? Array.isArray(n) ? n : [n] : [];
|
|
10127
10316
|
if (r.length) {
|
|
10128
10317
|
let t = L()?.schema, n = t ? r.filter((e) => qi(t, e.path)) : [];
|
|
@@ -10132,21 +10321,21 @@ function fd(e, n) {
|
|
|
10132
10321
|
}
|
|
10133
10322
|
}
|
|
10134
10323
|
}
|
|
10135
|
-
|
|
10324
|
+
jt();
|
|
10136
10325
|
},
|
|
10137
10326
|
addSkill(e) {
|
|
10138
|
-
let t =
|
|
10139
|
-
t >= 0 ?
|
|
10327
|
+
let t = lt.findIndex((t) => t.name === e.name);
|
|
10328
|
+
t >= 0 ? lt[t] = e : lt.push(e), pt(), ft && ft.put(ut(e));
|
|
10140
10329
|
},
|
|
10141
10330
|
removeSkill(e) {
|
|
10142
|
-
let t =
|
|
10143
|
-
return t < 0 ? !1 : (
|
|
10331
|
+
let t = lt.findIndex((t) => t.name === e);
|
|
10332
|
+
return t < 0 ? !1 : (lt.splice(t, 1), pt(), ft && ft.remove(e), !0);
|
|
10144
10333
|
},
|
|
10145
10334
|
listUserSkills() {
|
|
10146
|
-
return
|
|
10335
|
+
return lt.map((e) => e.name);
|
|
10147
10336
|
},
|
|
10148
10337
|
getUserSkill(e) {
|
|
10149
|
-
let t =
|
|
10338
|
+
let t = lt.find((t) => t.name === e);
|
|
10150
10339
|
if (t) return {
|
|
10151
10340
|
name: t.name,
|
|
10152
10341
|
description: t.description,
|
|
@@ -10154,16 +10343,16 @@ function fd(e, n) {
|
|
|
10154
10343
|
};
|
|
10155
10344
|
},
|
|
10156
10345
|
afterRound() {
|
|
10157
|
-
|
|
10346
|
+
Mt(), Ft();
|
|
10158
10347
|
},
|
|
10159
10348
|
async send(e, t) {
|
|
10160
|
-
await
|
|
10349
|
+
await q.initDone, t ??= {}, t?.mission && je && C.setMission(t.mission);
|
|
10161
10350
|
let n = e;
|
|
10162
10351
|
if (t.interceptors?.input) try {
|
|
10163
10352
|
let r = t.interceptors.input(e);
|
|
10164
10353
|
typeof r == "string" && (n = r);
|
|
10165
10354
|
} catch {}
|
|
10166
|
-
let r = ue ? t.maxAutoRetries ?? 1 : 0, i = 0, a = !1, o =
|
|
10355
|
+
let r = ue ? t.maxAutoRetries ?? 1 : 0, i = 0, a = !1, o = St(t.signal);
|
|
10167
10356
|
for (;;) {
|
|
10168
10357
|
a ||= (b.push({
|
|
10169
10358
|
role: "user",
|
|
@@ -10171,7 +10360,7 @@ function fd(e, n) {
|
|
|
10171
10360
|
timestamp: Date.now()
|
|
10172
10361
|
}), !0);
|
|
10173
10362
|
try {
|
|
10174
|
-
let e = await
|
|
10363
|
+
let e = await q.agent.invoke(b, t.signal, o);
|
|
10175
10364
|
if (t.interceptors?.output) try {
|
|
10176
10365
|
let n = t.interceptors.output(e);
|
|
10177
10366
|
typeof n == "string" && (e = n);
|
|
@@ -10180,7 +10369,7 @@ function fd(e, n) {
|
|
|
10180
10369
|
role: "assistant",
|
|
10181
10370
|
content: e,
|
|
10182
10371
|
timestamp: Date.now()
|
|
10183
|
-
}),
|
|
10372
|
+
}), q.afterRound(), s && await s.flush(), e;
|
|
10184
10373
|
} catch (e) {
|
|
10185
10374
|
if (ui(e, t.signal)) throw e;
|
|
10186
10375
|
let n = Xr(e, "fatal");
|
|
@@ -10208,8 +10397,8 @@ function fd(e, n) {
|
|
|
10208
10397
|
}
|
|
10209
10398
|
},
|
|
10210
10399
|
async batch(e, t, n) {
|
|
10211
|
-
if (await
|
|
10212
|
-
let r = [], i =
|
|
10400
|
+
if (await q.initDone, !e.length) return [];
|
|
10401
|
+
let r = [], i = St(n);
|
|
10213
10402
|
for (let a = 0; a < e.length; a++) {
|
|
10214
10403
|
if (n?.aborted) {
|
|
10215
10404
|
for (let t = a; t < e.length; t++) r.push({
|
|
@@ -10229,12 +10418,12 @@ function fd(e, n) {
|
|
|
10229
10418
|
content: o,
|
|
10230
10419
|
timestamp: Date.now()
|
|
10231
10420
|
});
|
|
10232
|
-
let c = await
|
|
10421
|
+
let c = await q.agent.invoke(b, n, i);
|
|
10233
10422
|
b.push({
|
|
10234
10423
|
role: "assistant",
|
|
10235
10424
|
content: c,
|
|
10236
10425
|
timestamp: Date.now()
|
|
10237
|
-
}),
|
|
10426
|
+
}), q.afterRound(), s && await s.flush(), r.push({
|
|
10238
10427
|
index: a,
|
|
10239
10428
|
task: o,
|
|
10240
10429
|
reply: c,
|
|
@@ -10287,132 +10476,132 @@ function fd(e, n) {
|
|
|
10287
10476
|
return r;
|
|
10288
10477
|
},
|
|
10289
10478
|
async switchSession(t) {
|
|
10290
|
-
if (await
|
|
10291
|
-
if (a.resolve("keep_external"),
|
|
10292
|
-
if (
|
|
10479
|
+
if (await q.initDone, !s) throw Error("page-agent-sdk: storage 未开启,无法切换会话(请传 storage 选项)");
|
|
10480
|
+
if (a.resolve("keep_external"), q.sessionId && s) {
|
|
10481
|
+
if (je) {
|
|
10293
10482
|
let e = C.getMission();
|
|
10294
|
-
e && s.save(n,
|
|
10483
|
+
e && s.save(n, q.sessionId, { mission: e });
|
|
10295
10484
|
}
|
|
10296
|
-
if (
|
|
10485
|
+
if (Me) {
|
|
10297
10486
|
let e = T.getWorkingMemory();
|
|
10298
|
-
e && s.save(n,
|
|
10487
|
+
e && s.save(n, q.sessionId, { workingMemory: e });
|
|
10299
10488
|
}
|
|
10300
10489
|
if (B) {
|
|
10301
10490
|
let e = w.getFocuses();
|
|
10302
|
-
s.save(n,
|
|
10491
|
+
s.save(n, q.sessionId, { focus: e.length ? e : null });
|
|
10303
10492
|
}
|
|
10304
10493
|
}
|
|
10305
10494
|
x.flush?.(), await s.flush();
|
|
10306
10495
|
let r = t ?? "", i;
|
|
10307
|
-
return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title),
|
|
10496
|
+
return r ? (i = await s.load(n, r), i || await s.createSession(n, e.session?.title, r)) : r = await s.createSession(n, e.session?.title), q.sessionId = r, b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), P && P.importStack([]), q.agent.debugLogs.value = [], i ||= await s.load(n, r), i && (q.applySnapshot(i), W({
|
|
10308
10497
|
type: "session_restored",
|
|
10309
10498
|
sessionId: r,
|
|
10310
10499
|
rounds: i.messages?.length ?? 0
|
|
10311
|
-
})), e.memory && s.save(n,
|
|
10500
|
+
})), e.memory && s.save(n, q.sessionId, { memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), wt(), Nt = void 0, Pt = !1, q.infoTick.value++, r;
|
|
10312
10501
|
},
|
|
10313
10502
|
resetSession: () => {
|
|
10314
|
-
|
|
10503
|
+
K(), a.resolve("keep_external"), q.sessionId = ul(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || E.reset(""), C.reset(), T.reset(), w.reset(), P && P.importStack([]), q.agent && (q.agent.debugLogs.value = []), s && s.createSession(q.agentId, e.session?.title, q.sessionId), W({
|
|
10315
10504
|
type: "session_restored",
|
|
10316
|
-
sessionId:
|
|
10505
|
+
sessionId: q.sessionId,
|
|
10317
10506
|
rounds: 0
|
|
10318
|
-
}),
|
|
10507
|
+
}), q.infoTick.value++, wt(), Nt = void 0, Pt = !1;
|
|
10319
10508
|
},
|
|
10320
10509
|
stream: (e, t, n) => {
|
|
10321
|
-
if (!
|
|
10322
|
-
x?.setProtectedRefs?.(
|
|
10510
|
+
if (!q.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
10511
|
+
x?.setProtectedRefs?.(md(e));
|
|
10323
10512
|
let r = (e) => {
|
|
10324
|
-
t?.(e), W(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") &&
|
|
10513
|
+
t?.(e), W(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && q.infoTick.value++;
|
|
10325
10514
|
};
|
|
10326
10515
|
if (n) {
|
|
10327
10516
|
let e = () => a.resolve("keep_external");
|
|
10328
10517
|
n.aborted ? e() : n.addEventListener("abort", e, { once: !0 });
|
|
10329
10518
|
}
|
|
10330
|
-
let { controller: i, untrack: o } =
|
|
10331
|
-
return
|
|
10519
|
+
let { controller: i, untrack: o } = Et(n);
|
|
10520
|
+
return q.agent.stream(e, r, i.signal).finally(o);
|
|
10332
10521
|
},
|
|
10333
10522
|
release() {
|
|
10334
|
-
if (
|
|
10335
|
-
|
|
10336
|
-
let e =
|
|
10337
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
10523
|
+
if (q.refCount--, q.refCount <= 0) {
|
|
10524
|
+
K(), ve = !0, s && (x.flush?.(), s.flush(), s.dispose()), ft && ft.dispose();
|
|
10525
|
+
let e = q.mcpClosers.splice(0);
|
|
10526
|
+
e.length && Promise.allSettled(e.map((e) => e())), vd.delete(n);
|
|
10338
10527
|
}
|
|
10339
10528
|
},
|
|
10340
10529
|
resolveConflict: a.resolve,
|
|
10341
10530
|
setTools(e) {
|
|
10342
10531
|
z.length = 0, e.forEach((e) => {
|
|
10343
10532
|
z.push(e), R.set(e.name, "user");
|
|
10344
|
-
}), V =
|
|
10533
|
+
}), V = ke(), q.agent && q.agent.setTools(V), q.infoTick.value++;
|
|
10345
10534
|
},
|
|
10346
10535
|
addTool(e) {
|
|
10347
10536
|
V.some((t) => t.name === e.name) && console.warn(`[page-agent-sdk] 工具 "${e.name}" 已存在,新工具覆盖(后注册覆盖先注册)`);
|
|
10348
10537
|
for (let t = z.length - 1; t >= 0; t--) z[t].name === e.name && z.splice(t, 1);
|
|
10349
|
-
z.push(e), R.set(e.name, "user"), V =
|
|
10538
|
+
z.push(e), R.set(e.name, "user"), V = ke(), q.agent && q.agent.setTools(V), q.infoTick.value++;
|
|
10350
10539
|
},
|
|
10351
10540
|
removeTool(e) {
|
|
10352
10541
|
let t = z.findIndex((t) => t.name === e);
|
|
10353
|
-
return t < 0 ? !1 : (z.splice(t, 1), R.delete(e), V =
|
|
10542
|
+
return t < 0 ? !1 : (z.splice(t, 1), R.delete(e), V = ke(), q.agent && q.agent.setTools(V), q.infoTick.value++, !0);
|
|
10354
10543
|
},
|
|
10355
10544
|
setLlm(t) {
|
|
10356
10545
|
let n;
|
|
10357
|
-
if (
|
|
10546
|
+
if ($c(t)) n = t;
|
|
10358
10547
|
else {
|
|
10359
10548
|
let e = t;
|
|
10360
10549
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
10361
10550
|
n = p(e);
|
|
10362
10551
|
}
|
|
10363
10552
|
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), y = t;
|
|
10364
|
-
let r =
|
|
10553
|
+
let r = $c(t) ? void 0 : t;
|
|
10365
10554
|
if (f = ai({
|
|
10366
10555
|
model: r?.model ?? t.model ?? t.modelName,
|
|
10367
10556
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
10368
10557
|
maxOutputTokens: e.maxOutputTokens ?? r?.maxOutputTokens
|
|
10369
10558
|
}), f.contextWindow < 2e5) throw Error(`[page-agent-sdk][setLlm] 新模型上下文窗口 ${f.contextWindow} 小于最小支持 ${ii}(需 ≥200K 窗口模型)`);
|
|
10370
|
-
|
|
10559
|
+
q.agent && (q.agent.setLlm(n), q.agent.setModelCaps?.(f)), ht?.setContextWindow?.(f.contextWindow), rt?.setContextWindow?.(f.contextWindow), q.infoTick.value++, e.debug && console.log("[page-agent-sdk][setLlm] 重解析 modelCaps + 回灌:", f);
|
|
10371
10560
|
},
|
|
10372
10561
|
setMemory(e) {
|
|
10373
|
-
E.reset(e), typeof e == "function" && E.refresh(),
|
|
10562
|
+
E.reset(e), typeof e == "function" && E.refresh(), q.infoTick.value++;
|
|
10374
10563
|
},
|
|
10375
10564
|
refreshMemory() {
|
|
10376
10565
|
return E.refresh();
|
|
10377
10566
|
},
|
|
10378
10567
|
setSubagents(t) {
|
|
10379
|
-
if (
|
|
10568
|
+
if (!$e) {
|
|
10380
10569
|
e.debug && console.warn("[page-agent-sdk][setSubagents] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
10381
10570
|
return;
|
|
10382
10571
|
}
|
|
10383
|
-
|
|
10572
|
+
$e.set(t), q.infoTick.value++;
|
|
10384
10573
|
},
|
|
10385
10574
|
addSubagent(t) {
|
|
10386
|
-
if (
|
|
10575
|
+
if (!$e) {
|
|
10387
10576
|
e.debug && console.warn("[page-agent-sdk][addSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略");
|
|
10388
10577
|
return;
|
|
10389
10578
|
}
|
|
10390
|
-
|
|
10579
|
+
$e.add(t), q.infoTick.value++;
|
|
10391
10580
|
},
|
|
10392
10581
|
removeSubagent(t) {
|
|
10393
|
-
if (
|
|
10394
|
-
let n =
|
|
10395
|
-
return n &&
|
|
10582
|
+
if (!$e) return e.debug && console.warn("[page-agent-sdk][removeSubagent] 未配 subagents:[] 或 capabilities.subagent 关闭,忽略"), !1;
|
|
10583
|
+
let n = $e.remove(t);
|
|
10584
|
+
return n && q.infoTick.value++, n;
|
|
10396
10585
|
},
|
|
10397
10586
|
getActiveSubagents() {
|
|
10398
|
-
return
|
|
10587
|
+
return ze?.getActive() ?? [];
|
|
10399
10588
|
},
|
|
10400
10589
|
get subagentHistory() {
|
|
10401
|
-
return
|
|
10590
|
+
return ze?.getHistory() ?? [];
|
|
10402
10591
|
},
|
|
10403
10592
|
getInfo() {
|
|
10404
10593
|
return {
|
|
10405
10594
|
id: n,
|
|
10406
|
-
sessionId:
|
|
10407
|
-
model:
|
|
10408
|
-
systemPrompt:
|
|
10409
|
-
tools: (
|
|
10595
|
+
sessionId: q.sessionId,
|
|
10596
|
+
model: $c(y) ? y.model ?? y.modelName : y.model,
|
|
10597
|
+
systemPrompt: q.agent?.getEffectiveSystemPrompt?.() ?? de + nc(L(), e.schemaHint),
|
|
10598
|
+
tools: (q.agent?.allTools ?? V).map((e) => ({
|
|
10410
10599
|
name: e.name,
|
|
10411
10600
|
description: e.description,
|
|
10412
10601
|
schema: e.schema,
|
|
10413
10602
|
source: R.get(e.name) || "user"
|
|
10414
10603
|
})),
|
|
10415
|
-
skills: (
|
|
10604
|
+
skills: (ct ? ct.controller.get() : e.skills ?? []).map((e) => ({
|
|
10416
10605
|
name: e.name,
|
|
10417
10606
|
description: e.description
|
|
10418
10607
|
})),
|
|
@@ -10427,8 +10616,8 @@ function fd(e, n) {
|
|
|
10427
10616
|
promptSoftCap: is(f.contextWindow, h.promptSoftCapTokens)
|
|
10428
10617
|
},
|
|
10429
10618
|
memory: E.get(),
|
|
10430
|
-
middleware:
|
|
10431
|
-
todos: (
|
|
10619
|
+
middleware: gt.map((e) => e.name),
|
|
10620
|
+
todos: (q.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
10432
10621
|
id: e.id,
|
|
10433
10622
|
content: e.content,
|
|
10434
10623
|
status: e.status,
|
|
@@ -10438,39 +10627,40 @@ function fd(e, n) {
|
|
|
10438
10627
|
...e.evidence === void 0 ? {} : { evidence: e.evidence }
|
|
10439
10628
|
})),
|
|
10440
10629
|
planPhase: S.getPlanPhase(),
|
|
10441
|
-
mission:
|
|
10442
|
-
workingMemory:
|
|
10630
|
+
mission: je ? C.getMission() : void 0,
|
|
10631
|
+
workingMemory: Me ? T.getWorkingMemory() : void 0,
|
|
10443
10632
|
focus: B ? w.getFocus() : void 0,
|
|
10444
10633
|
focuses: B ? w.getFocuses() : [],
|
|
10445
|
-
trace: le &&
|
|
10446
|
-
spans:
|
|
10447
|
-
metrics: ci(
|
|
10634
|
+
trace: le && q.agent?.spans ? {
|
|
10635
|
+
spans: q.agent.spans.value,
|
|
10636
|
+
metrics: ci(q.agent.spans.value)
|
|
10448
10637
|
} : void 0,
|
|
10449
|
-
actions:
|
|
10638
|
+
actions: $u(e.actions ?? {}),
|
|
10450
10639
|
subagent: {
|
|
10451
|
-
enabled: !!
|
|
10640
|
+
enabled: !!Je,
|
|
10452
10641
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
10453
10642
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
10454
10643
|
allowedTools: e.subagent?.allowedTools ?? [],
|
|
10455
|
-
subagents:
|
|
10456
|
-
active:
|
|
10457
|
-
history:
|
|
10644
|
+
subagents: $e?.get() ?? [],
|
|
10645
|
+
active: ze?.getActive() ?? [],
|
|
10646
|
+
history: ze?.getHistory() ?? [],
|
|
10647
|
+
lockedComponents: Xe?.locked() ?? {}
|
|
10458
10648
|
},
|
|
10459
10649
|
verify: {
|
|
10460
|
-
enabled:
|
|
10461
|
-
maxAttempts:
|
|
10462
|
-
adversarial:
|
|
10650
|
+
enabled: !!nt,
|
|
10651
|
+
maxAttempts: He ? Be : 0,
|
|
10652
|
+
adversarial: He && !!e.verify?.adversarial
|
|
10463
10653
|
},
|
|
10464
10654
|
context: (() => {
|
|
10465
|
-
let e =
|
|
10655
|
+
let e = rt?.getSnapshot();
|
|
10466
10656
|
if (e) {
|
|
10467
|
-
let t =
|
|
10657
|
+
let t = q.agent?.getState?.()?.lastCompression;
|
|
10468
10658
|
t && (e.compression = t);
|
|
10469
10659
|
}
|
|
10470
10660
|
return e;
|
|
10471
10661
|
})(),
|
|
10472
|
-
mcp: { servers:
|
|
10473
|
-
lastCompression:
|
|
10662
|
+
mcp: { servers: q.mcpServers },
|
|
10663
|
+
lastCompression: q.agent?.getState?.()?.lastCompression,
|
|
10474
10664
|
checkpoints: P ? {
|
|
10475
10665
|
enabled: !0,
|
|
10476
10666
|
auto: oe,
|
|
@@ -10479,14 +10669,14 @@ function fd(e, n) {
|
|
|
10479
10669
|
};
|
|
10480
10670
|
},
|
|
10481
10671
|
getMission() {
|
|
10482
|
-
return
|
|
10672
|
+
return je ? C.getMission() : void 0;
|
|
10483
10673
|
},
|
|
10484
10674
|
setMission(t) {
|
|
10485
|
-
if (!
|
|
10675
|
+
if (!je) {
|
|
10486
10676
|
e.debug && console.warn("[page-agent-sdk][mission] capabilities.missionAnchor 关闭,setMission 忽略");
|
|
10487
10677
|
return;
|
|
10488
10678
|
}
|
|
10489
|
-
C.setMission(t),
|
|
10679
|
+
C.setMission(t), q.infoTick.value++;
|
|
10490
10680
|
},
|
|
10491
10681
|
getFocus() {
|
|
10492
10682
|
return B ? w.getFocus() : void 0;
|
|
@@ -10495,66 +10685,66 @@ function fd(e, n) {
|
|
|
10495
10685
|
return B ? w.getFocuses() : [];
|
|
10496
10686
|
},
|
|
10497
10687
|
setFocus(t) {
|
|
10498
|
-
let n =
|
|
10499
|
-
return n.ok ? (w.setFocus(t),
|
|
10688
|
+
let n = Sd(t, "setFocus", B, () => L()?.schema, e.debug);
|
|
10689
|
+
return n.ok ? (w.setFocus(t), q.infoTick.value++, { ok: !0 }) : n;
|
|
10500
10690
|
},
|
|
10501
10691
|
addFocus(t) {
|
|
10502
|
-
let n =
|
|
10692
|
+
let n = Sd(t, "addFocus", B, () => L()?.schema, e.debug);
|
|
10503
10693
|
return n.ok ? w.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
10504
10694
|
ok: !1,
|
|
10505
10695
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
10506
|
-
}) : (w.addFocus(t),
|
|
10696
|
+
}) : (w.addFocus(t), q.infoTick.value++, { ok: !0 }) : n;
|
|
10507
10697
|
},
|
|
10508
10698
|
removeFocus(e) {
|
|
10509
|
-
B && (w.removeFocus(e),
|
|
10699
|
+
B && (w.removeFocus(e), q.infoTick.value++);
|
|
10510
10700
|
},
|
|
10511
10701
|
clearFocus() {
|
|
10512
|
-
B && (w.clearFocus(),
|
|
10702
|
+
B && (w.clearFocus(), q.infoTick.value++);
|
|
10513
10703
|
}
|
|
10514
10704
|
};
|
|
10515
|
-
async function
|
|
10705
|
+
async function Dt() {
|
|
10516
10706
|
if (!s) return;
|
|
10517
10707
|
await s.ready;
|
|
10518
10708
|
let t = e.session || {};
|
|
10519
10709
|
if (t.id) {
|
|
10520
|
-
|
|
10521
|
-
let e = await s.load(n,
|
|
10522
|
-
e ? (
|
|
10710
|
+
q.sessionId = t.id;
|
|
10711
|
+
let e = await s.load(n, q.sessionId);
|
|
10712
|
+
e ? (q.applySnapshot(e), W({
|
|
10523
10713
|
type: "session_restored",
|
|
10524
|
-
sessionId:
|
|
10714
|
+
sessionId: q.sessionId,
|
|
10525
10715
|
rounds: e.messages?.length ?? 0
|
|
10526
|
-
})) : await s.createSession(n, t.title,
|
|
10716
|
+
})) : await s.createSession(n, t.title, q.sessionId);
|
|
10527
10717
|
} else if (t.autoResume !== !1) {
|
|
10528
10718
|
let r = await s.listSessions(n);
|
|
10529
10719
|
if (e.debug && console.log("[page-agent-sdk][restore] listSessions", n, r.length, r.map((e) => e.sessionId)), r.length) {
|
|
10530
|
-
|
|
10531
|
-
let t = await s.load(n,
|
|
10532
|
-
t ? (
|
|
10720
|
+
q.sessionId = r[0].sessionId;
|
|
10721
|
+
let t = await s.load(n, q.sessionId);
|
|
10722
|
+
t ? (q.applySnapshot(t), W({
|
|
10533
10723
|
type: "session_restored",
|
|
10534
|
-
sessionId:
|
|
10724
|
+
sessionId: q.sessionId,
|
|
10535
10725
|
rounds: t.messages?.length ?? 0
|
|
10536
|
-
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话",
|
|
10537
|
-
} else
|
|
10538
|
-
} else
|
|
10539
|
-
e.memory && s.save(n,
|
|
10726
|
+
}), e.debug && console.log("[page-agent-sdk][restore] 恢复会话", q.sessionId, `${t.messages?.length ?? 0} msgs`)) : e.debug && console.log("[page-agent-sdk][restore] 会话 meta 存在但快照为空", q.sessionId);
|
|
10727
|
+
} else q.sessionId = await s.createSession(n, t.title), e.debug && console.log("[page-agent-sdk][restore] 新建会话(无历史)", q.sessionId);
|
|
10728
|
+
} else q.sessionId = await s.createSession(n, t.title);
|
|
10729
|
+
e.memory && s.save(n, q.sessionId, { memory: E.get() || (typeof e.memory == "string" ? e.memory : "") }), wt();
|
|
10540
10730
|
}
|
|
10541
|
-
async function
|
|
10542
|
-
await
|
|
10731
|
+
async function Ot() {
|
|
10732
|
+
await mt();
|
|
10543
10733
|
}
|
|
10544
|
-
function
|
|
10734
|
+
function kt(e) {
|
|
10545
10735
|
let t = {};
|
|
10546
|
-
for (let n of
|
|
10736
|
+
for (let n of md(e)) {
|
|
10547
10737
|
let e = x.files[n];
|
|
10548
10738
|
e && (t[n] = e.content);
|
|
10549
10739
|
}
|
|
10550
10740
|
return t;
|
|
10551
10741
|
}
|
|
10552
|
-
function
|
|
10553
|
-
let e =
|
|
10742
|
+
function jt() {
|
|
10743
|
+
let e = hd(x.files, md(b));
|
|
10554
10744
|
for (let t of e) delete x.files[t];
|
|
10555
10745
|
}
|
|
10556
|
-
function
|
|
10557
|
-
let e = Yo(b,
|
|
10746
|
+
function Mt() {
|
|
10747
|
+
let e = Yo(b, _t);
|
|
10558
10748
|
if (!e.trimmed) return;
|
|
10559
10749
|
let { older: t, summary: n } = e;
|
|
10560
10750
|
if (W({
|
|
@@ -10565,70 +10755,74 @@ function fd(e, n) {
|
|
|
10565
10755
|
assistant: e.assistantMsgs.map((e) => e.content),
|
|
10566
10756
|
steps: e.assistantMsgs.flatMap((e) => e.steps ?? [])
|
|
10567
10757
|
})),
|
|
10568
|
-
vfsResults:
|
|
10758
|
+
vfsResults: kt(t.flatMap((e) => [e.userMsg, ...e.assistantMsgs])),
|
|
10569
10759
|
summary: n.content,
|
|
10570
10760
|
reason: "max_memory_rounds"
|
|
10571
|
-
}), b.splice(e.deleteFrom, e.deleteCount, n),
|
|
10761
|
+
}), b.splice(e.deleteFrom, e.deleteCount, n), jt(), g && l) {
|
|
10572
10762
|
let n = e.summary, { prevSeg: r } = e;
|
|
10573
10763
|
(async () => {
|
|
10574
10764
|
try {
|
|
10575
10765
|
let e = await l(es(t, v)), i = b.indexOf(n);
|
|
10576
10766
|
if (i < 0) return;
|
|
10577
|
-
b[i].content = Jo(t, r, e),
|
|
10767
|
+
b[i].content = Jo(t, r, e), Ft();
|
|
10578
10768
|
} catch {}
|
|
10579
10769
|
})();
|
|
10580
10770
|
}
|
|
10581
10771
|
}
|
|
10582
|
-
let
|
|
10583
|
-
function
|
|
10584
|
-
if (!
|
|
10772
|
+
let Nt, Pt = !1;
|
|
10773
|
+
function Ft() {
|
|
10774
|
+
if (!q.sessionId || !s) return;
|
|
10585
10775
|
let t = JSON.parse(JSON.stringify(b));
|
|
10586
|
-
s.save(n,
|
|
10587
|
-
let r =
|
|
10588
|
-
if (s.save(n,
|
|
10776
|
+
s.save(n, q.sessionId, { messages: t });
|
|
10777
|
+
let r = q.agent?.getState?.()?.todos ?? [];
|
|
10778
|
+
if (s.save(n, q.sessionId, { todos: r }), je) {
|
|
10589
10779
|
let e = C.getMission();
|
|
10590
|
-
e && s.save(n,
|
|
10780
|
+
e && s.save(n, q.sessionId, { mission: e });
|
|
10591
10781
|
}
|
|
10592
|
-
if (
|
|
10782
|
+
if (Me) {
|
|
10593
10783
|
let e = T.getWorkingMemory();
|
|
10594
|
-
e && s.save(n,
|
|
10784
|
+
e && s.save(n, q.sessionId, { workingMemory: e });
|
|
10595
10785
|
}
|
|
10596
10786
|
if (B) {
|
|
10597
10787
|
let e = w.getFocuses();
|
|
10598
|
-
s.save(n,
|
|
10788
|
+
s.save(n, q.sessionId, { focus: e.length ? e : null });
|
|
10599
10789
|
}
|
|
10600
|
-
ue && P && (s.save(n,
|
|
10601
|
-
let a =
|
|
10602
|
-
a && a !==
|
|
10790
|
+
ue && P && (s.save(n, q.sessionId, { checkpoints: P.exportStack() }), s.save(n, q.sessionId, { usage: i }));
|
|
10791
|
+
let a = Qc(b);
|
|
10792
|
+
a && a !== Nt && (Nt = a, s.updateTitle(n, q.sessionId, a)), e.autoTitle !== !1 && u && !Pt && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant") && (Pt = !0, (async () => {
|
|
10603
10793
|
let e = await u(b);
|
|
10604
|
-
e && (await s.updateTitle(n,
|
|
10605
|
-
})()), e.debug && console.log("[page-agent-sdk][persist] save",
|
|
10606
|
-
}
|
|
10607
|
-
return
|
|
10608
|
-
|
|
10609
|
-
let t = await Promise.allSettled(e.mcp.map((e) => ec(e)));
|
|
10610
|
-
|
|
10794
|
+
e && (await s.updateTitle(n, q.sessionId, e), await wt());
|
|
10795
|
+
})()), e.debug && console.log("[page-agent-sdk][persist] save", q.sessionId, `${b.length} msgs`);
|
|
10796
|
+
}
|
|
10797
|
+
return q.initDone = (async () => {
|
|
10798
|
+
await Dt(), await Ot(), e.mcp?.length && (async () => {
|
|
10799
|
+
let t = await Promise.allSettled(e.mcp.map((e) => ec(e))), n = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []);
|
|
10800
|
+
if (ve) {
|
|
10801
|
+
Promise.allSettled(n.map((e) => e()));
|
|
10802
|
+
return;
|
|
10803
|
+
}
|
|
10804
|
+
q.mcpClosers = n, q.mcpServers = [], t.forEach((t, n) => {
|
|
10611
10805
|
let r = e.mcp[n], i = r.name ?? r.url;
|
|
10612
|
-
t.status === "fulfilled" ? (
|
|
10806
|
+
t.status === "fulfilled" ? (q.mcpServers.push({
|
|
10613
10807
|
name: i,
|
|
10614
10808
|
url: r.url,
|
|
10615
10809
|
toolCount: t.value.tools.length
|
|
10616
10810
|
}), t.value.tools.forEach((e) => R.set(e.name, `mcp:${i}`)), _e.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${i} 连接失败:`, t.reason);
|
|
10617
|
-
}), V =
|
|
10618
|
-
}
|
|
10619
|
-
let t =
|
|
10620
|
-
|
|
10811
|
+
}), _e.length && (V = ke(), q.agent && q.agent.setTools(V), q.infoTick.value++), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${_e.length} 个工具,${q.mcpServers.length} 个 server`);
|
|
10812
|
+
})();
|
|
10813
|
+
let t = $c(e.llm) ? e.llm : await m(e.llm);
|
|
10814
|
+
q.agent = Ui({
|
|
10621
10815
|
llm: t,
|
|
10622
10816
|
systemPrompt: de,
|
|
10623
10817
|
tools: V,
|
|
10624
|
-
middleware:
|
|
10818
|
+
middleware: gt,
|
|
10625
10819
|
maxToolRounds: e.maxToolRounds,
|
|
10626
10820
|
maxRetries: e.maxRetries,
|
|
10627
10821
|
stallMs: e.streamStallMs ?? 9e4,
|
|
10628
10822
|
maxParallelTools: e.maxParallelTools,
|
|
10629
10823
|
contextWindow: f.contextWindow,
|
|
10630
10824
|
maxOutputTokens: f.maxOutputTokens,
|
|
10631
|
-
maxVerifyAttempts:
|
|
10825
|
+
maxVerifyAttempts: He ? Be : 0,
|
|
10632
10826
|
roundTokenBudget: e.roundTokenBudget ?? 0,
|
|
10633
10827
|
onLlmChange: (e) => {
|
|
10634
10828
|
y = e;
|
|
@@ -10643,17 +10837,17 @@ function fd(e, n) {
|
|
|
10643
10837
|
} catch {}
|
|
10644
10838
|
} : void 0,
|
|
10645
10839
|
debug: e.debug
|
|
10646
|
-
}), D.current =
|
|
10647
|
-
|
|
10840
|
+
}), D.current = q.agent, Qe && Qe.setReconfigureHook && Qe.setReconfigureHook(() => {
|
|
10841
|
+
q.agent && q.agent.setTools(ke());
|
|
10648
10842
|
});
|
|
10649
|
-
})(),
|
|
10843
|
+
})(), q;
|
|
10650
10844
|
}
|
|
10651
|
-
function
|
|
10652
|
-
let n = e.id ??
|
|
10845
|
+
function wd(e, t) {
|
|
10846
|
+
let n = e.id ?? ul();
|
|
10653
10847
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
10654
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
10655
|
-
o ? a = o : (a =
|
|
10656
|
-
let s = null, c =
|
|
10848
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? vd.get(n) : void 0;
|
|
10849
|
+
o ? a = o : (a = Cd(e, n), e.shareContext && vd.set(n, a)), a.refCount++;
|
|
10850
|
+
let s = null, c = Il(e), l = null, u = null;
|
|
10657
10851
|
async function d(n) {
|
|
10658
10852
|
if (await a.initDone, s) {
|
|
10659
10853
|
s.show();
|
|
@@ -10869,12 +11063,12 @@ function pd(e, t) {
|
|
|
10869
11063
|
}
|
|
10870
11064
|
//#endregion
|
|
10871
11065
|
//#region src/core/sdk/ragSubagent.ts
|
|
10872
|
-
var
|
|
11066
|
+
var Td = "你是知识检索专家。可用工具:search_docs(语义检索)/ load_doc(按 source 加载)/ vfs_grep+vfs_read(搜预注入文档)/ fetch_document(公网 URL)。\n\n工作方式:\n1. 分析任务,拆出需查证的要点(如:需要哪些组件、各自的 props 约束、UI 规范要求);\n2. 多源检索:先 vfs_grep 搜预注入文档(快、静态)→ 不够用 search_docs 语义检索 → 需特定文档用 load_doc → 公网用 fetch_document;\n3. 检索结果不足时换关键词、扩大 topK、或换源重试;\n4. 综合成结构化、可执行结论(不堆原文,提炼成可直接用于决策/配置的信息);\n5. 标注关键信息来源(文档名/段落),便于溯源;检索不到明确说「未检索到」,不编造。\n\n你是只读检索角色,不要尝试修改任何数据。", Ed = "# 知识检索策略(RAG)\n\n## 多源决策树\n- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查\n- search_docs:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用\n- load_doc:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档\n- fetch_document:公网 URL —— 查公开资料\n\n## 综合规范\n- 多源交叉验证(关键结论优先 ≥2 源印证,或单一权威源)\n- 标注来源(文档名 / URL / 段落),便于溯源\n- 结构化、可执行结论(组件清单 + 各自 props 约束 + 适用场景),不堆原文\n- 未检索到明确说「未检索到」,不编造;建议替代方案(改关键词 / 建议写代码组件等)\n\n## 何时用何源\n- 静态文档(组件库文档 / UI 规范):vfs_grep\n- 语义相似(「瀑布流组件」「倒计时」「拼团」):search_docs\n- 已知文档 id / URL:load_doc\n- 公开 URL(设计规范网站 / 第三方文档):fetch_document", Dd = {
|
|
10873
11067
|
name: "rag-search",
|
|
10874
11068
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
10875
|
-
getContent: () =>
|
|
11069
|
+
getContent: () => Ed
|
|
10876
11070
|
};
|
|
10877
|
-
function
|
|
11071
|
+
function Od(e, n, i) {
|
|
10878
11072
|
return r(async ({ query: e, topK: t }) => {
|
|
10879
11073
|
try {
|
|
10880
11074
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -10891,7 +11085,7 @@ function _d(e, n, i) {
|
|
|
10891
11085
|
})
|
|
10892
11086
|
});
|
|
10893
11087
|
}
|
|
10894
|
-
function
|
|
11088
|
+
function kd(e, n) {
|
|
10895
11089
|
return r(async ({ source: e }) => {
|
|
10896
11090
|
try {
|
|
10897
11091
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -10905,11 +11099,11 @@ function vd(e, n) {
|
|
|
10905
11099
|
schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
|
|
10906
11100
|
});
|
|
10907
11101
|
}
|
|
10908
|
-
function
|
|
11102
|
+
function Ad(e) {
|
|
10909
11103
|
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;
|
|
10910
11104
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
10911
11105
|
let p = [];
|
|
10912
|
-
t && p.push(
|
|
11106
|
+
t && p.push(Od(s, t, o)), n && p.push(kd(c, n)), f && p.push(...f);
|
|
10913
11107
|
let m = r ? [
|
|
10914
11108
|
"vfs_grep",
|
|
10915
11109
|
"vfs_read",
|
|
@@ -10918,17 +11112,17 @@ function yd(e) {
|
|
|
10918
11112
|
return {
|
|
10919
11113
|
id: i,
|
|
10920
11114
|
description: a ?? "检索知识库(组件文档/UI 规范/业务规则),返回有依据的结构化结论。需要查阅文档才能回答或决定如何配置时委派",
|
|
10921
|
-
systemPrompt:
|
|
11115
|
+
systemPrompt: Td,
|
|
10922
11116
|
tools: p.length ? p : void 0,
|
|
10923
11117
|
allowedTools: m,
|
|
10924
|
-
skills: d ?? [
|
|
11118
|
+
skills: d ?? [Dd],
|
|
10925
11119
|
maxToolRounds: l,
|
|
10926
11120
|
...u === void 0 ? {} : { summarization: u }
|
|
10927
11121
|
};
|
|
10928
11122
|
}
|
|
10929
11123
|
//#endregion
|
|
10930
11124
|
//#region src/core/utils/clipboard.ts
|
|
10931
|
-
async function
|
|
11125
|
+
async function jd(e) {
|
|
10932
11126
|
try {
|
|
10933
11127
|
let t = globalThis.navigator?.clipboard;
|
|
10934
11128
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -10946,8 +11140,8 @@ async function bd(e) {
|
|
|
10946
11140
|
}
|
|
10947
11141
|
//#endregion
|
|
10948
11142
|
//#region src/core/composables/useChat.ts
|
|
10949
|
-
var
|
|
10950
|
-
function
|
|
11143
|
+
var Md = 4e3;
|
|
11144
|
+
function Nd(e = {}) {
|
|
10951
11145
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a } = e, o = /* @__PURE__ */ bt({
|
|
10952
11146
|
messages: e.messages ?? [],
|
|
10953
11147
|
loading: !1,
|
|
@@ -11016,7 +11210,7 @@ function Sd(e = {}) {
|
|
|
11016
11210
|
let t = e.delta || "";
|
|
11017
11211
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
11018
11212
|
let r = (n.subReason || "") + t;
|
|
11019
|
-
n.subReason = r.length >
|
|
11213
|
+
n.subReason = r.length > Md ? r.slice(-4e3) : r;
|
|
11020
11214
|
break;
|
|
11021
11215
|
}
|
|
11022
11216
|
n.children ||= [];
|
|
@@ -11145,9 +11339,9 @@ function Sd(e = {}) {
|
|
|
11145
11339
|
}
|
|
11146
11340
|
//#endregion
|
|
11147
11341
|
//#region src/core/composables/chatContext.ts
|
|
11148
|
-
var
|
|
11149
|
-
function
|
|
11150
|
-
let t =
|
|
11342
|
+
var Pd = Symbol("chatContext");
|
|
11343
|
+
function Fd(e = {}) {
|
|
11344
|
+
let t = Nd({
|
|
11151
11345
|
fetchResponse: e.fetchResponse,
|
|
11152
11346
|
fetchStream: e.fetchStream,
|
|
11153
11347
|
messages: e.messages,
|
|
@@ -11167,7 +11361,7 @@ function wd(e = {}) {
|
|
|
11167
11361
|
}, h = /* @__PURE__ */ At({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
11168
11362
|
h.value[e] = !g(e);
|
|
11169
11363
|
}, v = /* @__PURE__ */ At(!1), y = (e) => {
|
|
11170
|
-
|
|
11364
|
+
jd(e).then((e) => {
|
|
11171
11365
|
e && (v.value = !0, setTimeout(() => {
|
|
11172
11366
|
v.value = !1;
|
|
11173
11367
|
}, 1500));
|
|
@@ -11235,15 +11429,15 @@ function wd(e = {}) {
|
|
|
11235
11429
|
}
|
|
11236
11430
|
};
|
|
11237
11431
|
}
|
|
11238
|
-
function
|
|
11239
|
-
let e = Ln(
|
|
11432
|
+
function Id() {
|
|
11433
|
+
let e = Ln(Pd);
|
|
11240
11434
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
11241
11435
|
return e;
|
|
11242
11436
|
}
|
|
11243
11437
|
//#endregion
|
|
11244
11438
|
//#region src/core/index.headless.ts
|
|
11245
|
-
function
|
|
11246
|
-
return
|
|
11439
|
+
function Ld(e) {
|
|
11440
|
+
return wd(e);
|
|
11247
11441
|
}
|
|
11248
11442
|
//#endregion
|
|
11249
|
-
export {
|
|
11443
|
+
export { Ll as CAPABILITIES, Bl as CONTEXT_PRESETS, Zc as CompressDecisionSchema, rs as DEFAULT_PROMPT_SOFT_CAP, tc as DEFAULT_SYSTEM_PROMPT, _c as HTML_VOID_TAGS, ko as HUMAN_CONFIRM_TOOL_NAME, ii as MIN_CONTEXT_WINDOW, ns as SOFT_CAP_MIN_WINDOW, Xo as STOP_WORDS, ka as UNSAFE_KEYS, $u as actionsToInspectInfo, Qu as actionsToTools, Zr as agentError, Js as analyzeContext, za as applyPatchToClone, Ha as applyPatchToLive, Xr as asAgentError, nc as buildDataPrompt, rc as buildSystemPrompt, Pd as chatContextKey, Eu as commitSetToBind, ec as connectMcp, m as constructLlmFromConfig, p as constructOpenLlmSync, jd as copyText, Ui as createAgent, Oo as createApprovalMiddleware, Fd as createChatContext, Ld as createChatSdk, zo as createCheckpointManager, Bo as createCheckpointMiddleware, ll as createConflictManager, Ys as createContextInspectorMiddleware, Pu as createDataOps, Wc as createHtmlFormatCheck, qc as createHtmlSubagent, Mo as createHumanConfirmMiddleware, jo as createHumanConfirmTool, Al as createMemoryBackend, xo as createMemoryMiddleware, u as createProxyLlm, Ad as createRagSubagent, io as createSandboxRunner, zl as createSdkEvents, gd as createSerialRunner, Pl as createSessionStore, fd as createSkillStore, Ts as createSubagentMiddleware, ls as createSubagentTracker, Os as createSubagentsMiddleware, od as createUsageHintsMiddleware, ks as createVerifyMiddleware, sc as createVfs, Ml as createWebStorageBackend, Fs as createWriteBackCheck, Pa as deepClone, nd as defineDataToolset, oo as defineSkill, Jc as defineTool, Na as deleteByPath, Qc as deriveTitle, oa as describeSchemaNode, Di as detectGarbledToolCall, Ka as diffObjects, Bu as domToStructure, Hu as domTools, td as domToolsStatic, Qo as estimateMessageTokens, $o as estimateRoundTokens, X as estimateTokens, g as extractReasoningDelta, ya as extractSchemaHint, Xs as extractText, h as extractTextDelta, _ as extractUsage, Iu as fetchDocTools, ed as fetchTools, Tu as filterByToolMode, Ga as findStrippedKeys, sa as formatConstraints, Kr as formatZodIssues, Z as getByPath, Vu as getDomTool, Gu as getEnvSummary, qi as getSchemaAtPath, Wi as getSchemaTopKeys, ci as getTraceMetrics, $ as hashValue, ma as htmlOrchestratorPrompt, es as indexSummarize, Ju as inspectEnvTool, Yu as inspectTools, $c as isChatModel, vi as isContextLengthError, Gi as isPathAllowed, Sl as isQuotaError, Aa as isUnsafePath, eu as jpEval, Jr as jsonParseError, La as limitDepth, Fa as maybeParseValue, v as normalizeUsage, si as offloadPassThroughChars, oi as offloadThresholdChars, pa as presets, ea as projectBySchema, $i as projectBySchemaDeep, Ia as projectFields, ts as recallRounds, ca as renderSchemaHint, la as renderSchemaOverview, fa as renderSchemaShallow, Rl as resolveCapabilities, Hl as resolveContextOptions, Il as resolveDialogConfig, cl as resolveLlm, ai as resolveModelCaps, is as resolvePromptSoftCap, Fl as resolveStorage, Wa as restoreInPlace, Ua as restoreLive, Yr as routeError, ao as runHostScript, iu as runSandboxedScript, ja as safeMerge, Wu as safeSerialize, Q as safeStringify, nu as searchJson, rd as selectBuiltinTools, Ma as setByPath, as as shouldTriggerCompression, ha as systemPromptHelpers, Zo as tokenize, Y as toolError, Ki as unwrapSchema, Nd as useChat, Id as useChatContext, yc as validateHtmlFormat, e as z, qr as zodError };
|