page-agent-sdk 3.44.0 → 3.44.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.headless.js +501 -481
- package/dist/page-agent-sdk.iife.js +143 -143
- package/dist/page-agent-sdk.js +1924 -1904
- package/dist/page-agent-sdk.legacy.js +10135 -10112
- package/dist/page-agent-sdk.umd.cjs +59 -59
- package/package.json +1 -1
|
@@ -2957,7 +2957,7 @@ var aa = "", oa = "根(整体)", sa = /* @__PURE__ */ new Set([
|
|
|
2957
2957
|
]), ca = /* @__PURE__ */ new Set(["resource_update", "resource_delete"]), la = /* @__PURE__ */ new Set(["remove", "move"]);
|
|
2958
2958
|
function ua(e) {
|
|
2959
2959
|
let t = String(e).trim();
|
|
2960
|
-
return t === "(root)" || t === "$" ? aa : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t);
|
|
2960
|
+
return t === "(root)" || t === "$" ? aa : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t = t.replace(/\[(\d+)\]/g, ".$1"), t);
|
|
2961
2961
|
}
|
|
2962
2962
|
function da(e) {
|
|
2963
2963
|
let t = ua(e);
|
|
@@ -3220,9 +3220,14 @@ function Ga(e) {
|
|
|
3220
3220
|
function Ka(e, t) {
|
|
3221
3221
|
return !(!e.length || !e.some((e) => e.status !== "completed") || /[??]\s*$/.test(t));
|
|
3222
3222
|
}
|
|
3223
|
-
function qa(e) {
|
|
3224
|
-
let
|
|
3225
|
-
|
|
3223
|
+
function qa(e, t) {
|
|
3224
|
+
let n = e.filter((e) => e.status !== "completed"), r = n.map((e) => `#${e.id} [${e.status}] ${e.content.length > 60 ? `${e.content.slice(0, 60)}…` : e.content}`).join("\n"), i = e.filter((e) => {
|
|
3225
|
+
if (e.status !== "completed" || e.evidence) return !1;
|
|
3226
|
+
if (!t) return !0;
|
|
3227
|
+
let n = t.get(e.id);
|
|
3228
|
+
return !n || n.status !== "completed" || n.content !== e.content;
|
|
3229
|
+
}), a = i.length ? `\n另有 ${i.length} 项已标记完成但 evidence 为空(${i.map((e) => `#${e.id}`).join("、")}):标记完成时请用 update_todo 附 evidence(本次实际写入的 jsonPath,如 components.2);经委派完成等无主写路径时如实写明完成方式。` : "";
|
|
3230
|
+
return `⚠️ 任务未完成:待办清单还有 ${n.length} 项未完成:\n${r}\n若这些工作实际已完成,请先用 update_todo 把它们全部标记 completed(或一次 write_todos 整表替换)再给出最终总结;若尚未完成,请继续执行剩余任务。不要中途停止。${a}`;
|
|
3226
3231
|
}
|
|
3227
3232
|
function Ja(e = [], n = {}) {
|
|
3228
3233
|
let i = Wa(e), a = 0, o = 0, s = !1, c = 0, l = n.maxPlanRevisions ?? 5;
|
|
@@ -3325,7 +3330,7 @@ function eo(e) {
|
|
|
3325
3330
|
gate: {
|
|
3326
3331
|
stage: "completion_gate",
|
|
3327
3332
|
attempt: t.completionRetries,
|
|
3328
|
-
feedback: qa(e.todos),
|
|
3333
|
+
feedback: qa(e.todos, e.todosStatusAtStart),
|
|
3329
3334
|
logData: { pending: e.todos.filter((e) => e.status !== "completed").map((e) => e.id) }
|
|
3330
3335
|
}
|
|
3331
3336
|
};
|
|
@@ -3399,9 +3404,11 @@ function eo(e) {
|
|
|
3399
3404
|
function to(e, t, n) {
|
|
3400
3405
|
let r = Array.from(n ?? []);
|
|
3401
3406
|
return e.filter((e) => {
|
|
3402
|
-
if (e.status !== "completed"
|
|
3403
|
-
let n =
|
|
3404
|
-
|
|
3407
|
+
if (e.status !== "completed") return !1;
|
|
3408
|
+
let n = t?.get(e.id);
|
|
3409
|
+
if (n && n.status === "completed" && n.content === e.content) return !1;
|
|
3410
|
+
let i = Va(e.evidence ?? "");
|
|
3411
|
+
return i.length ? !Ha(i, r) : !1;
|
|
3405
3412
|
});
|
|
3406
3413
|
}
|
|
3407
3414
|
function no(e) {
|
|
@@ -3873,7 +3880,10 @@ function Eo(e) {
|
|
|
3873
3880
|
counts: {},
|
|
3874
3881
|
writePaths: [],
|
|
3875
3882
|
failures: 0
|
|
3876
|
-
}, p = Ya(), m = new Map((U.todos ?? []).map((e) => [e.id,
|
|
3883
|
+
}, p = Ya(), m = new Map((U.todos ?? []).map((e) => [e.id, {
|
|
3884
|
+
status: e.status,
|
|
3885
|
+
content: e.content
|
|
3886
|
+
}])), g = /* @__PURE__ */ new Map(), _ = (e) => {
|
|
3877
3887
|
let t = B.find((t) => t.name === e);
|
|
3878
3888
|
return t && "writeCapable" in t ? typeof t.writeCapable == "function" || t.writeCapable === !0 : wo.has(e);
|
|
3879
3889
|
}, y = 0, S = 0, w = So(ne, C), T = null, E = 0, D = !1;
|
|
@@ -4085,14 +4095,14 @@ function Eo(e) {
|
|
|
4085
4095
|
for (let e = 0; e < o.length; e++) {
|
|
4086
4096
|
let t = h[e];
|
|
4087
4097
|
if (!t) continue;
|
|
4088
|
-
let n = `${o[e].call.name}|${JSON.stringify(o[e].call.args ?? {})}`,
|
|
4089
|
-
if (
|
|
4090
|
-
let e = (g.get(
|
|
4091
|
-
g.set(
|
|
4092
|
-
} else g.delete(
|
|
4098
|
+
let n = (e) => e && typeof e == "object" && !Array.isArray(e) ? Object.fromEntries(Object.keys(e).sort().map((t) => [t, n(e[t])])) : e, r = `${o[e].call.name}|${JSON.stringify(n(o[e].call.args ?? {}))}`, i = t.status === "error" || typeof t.content == "string" && t.content.startsWith("ERROR:"), a = t.content;
|
|
4099
|
+
if (i) {
|
|
4100
|
+
let e = (g.get(r) ?? 0) + 1;
|
|
4101
|
+
g.set(r, e), e >= 2 && (a = `${t.content}\n(提示:同参数已连续失败 ${e} 次,原样重试大概率仍失败;请检查参数/换路径/换方法,或向用户如实说明困难)`);
|
|
4102
|
+
} else g.delete(r);
|
|
4093
4103
|
c.push(new s({
|
|
4094
4104
|
tool_call_id: o[e].id,
|
|
4095
|
-
content:
|
|
4105
|
+
content: a
|
|
4096
4106
|
}));
|
|
4097
4107
|
}
|
|
4098
4108
|
for (let e = 0; e < o.length; e++) {
|
|
@@ -7807,7 +7817,13 @@ function ju(e, t) {
|
|
|
7807
7817
|
}
|
|
7808
7818
|
//#endregion
|
|
7809
7819
|
//#region src/core/tools/dataOps.ts
|
|
7810
|
-
function Mu(e) {
|
|
7820
|
+
function Mu(e, t) {
|
|
7821
|
+
if (!e) return null;
|
|
7822
|
+
let n = (t ? Ao(e, t) : e)?.shape;
|
|
7823
|
+
return n && typeof n == "object" ? Object.keys(n) : null;
|
|
7824
|
+
}
|
|
7825
|
+
var Nu = (e) => e && e.length ? `(可用字段:${e.slice(0, 12).join(", ")}${e.length > 12 ? " …" : ""})` : "", Pu = (e) => /[.[]/.test(e) ? e.replace(/[.[][^.[]*$/, "") : "";
|
|
7826
|
+
function Fu(e) {
|
|
7811
7827
|
let { schema: t, allowKeys: n, value: r, bindRef: i } = e, a = [];
|
|
7812
7828
|
if (n) {
|
|
7813
7829
|
if (typeof r != "object" || !r || Array.isArray(r)) return {
|
|
@@ -7832,7 +7848,7 @@ function Mu(e) {
|
|
|
7832
7848
|
error: X({
|
|
7833
7849
|
code: "SCHEMA_STRIP",
|
|
7834
7850
|
message: `字段 ${r} 不在 schema 声明内,写入被拒绝(防静默丢失)`,
|
|
7835
|
-
hint:
|
|
7851
|
+
hint: `该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Nu(Mu(t, ""))}`,
|
|
7836
7852
|
path: r,
|
|
7837
7853
|
details: { stripped: [r] }
|
|
7838
7854
|
}),
|
|
@@ -7852,7 +7868,7 @@ function Mu(e) {
|
|
|
7852
7868
|
error: X({
|
|
7853
7869
|
code: "SCHEMA_STRIP",
|
|
7854
7870
|
message: `字段 ${c.join(", ")} 不在 schema 声明内,写入被拒绝(防静默丢失)`,
|
|
7855
|
-
hint:
|
|
7871
|
+
hint: `该数据结构不支持这些字段;请只用 schema 声明的字段,或在 data.schema 中声明后重试${Nu(Mu(t, Pu(String(c[0]))))}`,
|
|
7856
7872
|
path: c[0],
|
|
7857
7873
|
details: { stripped: c }
|
|
7858
7874
|
}),
|
|
@@ -7891,7 +7907,7 @@ function Mu(e) {
|
|
|
7891
7907
|
notices: a
|
|
7892
7908
|
};
|
|
7893
7909
|
}
|
|
7894
|
-
function
|
|
7910
|
+
function Iu(e) {
|
|
7895
7911
|
let { schema: t, bindRef: n, clone: r, patches: i, schemaErrorMode: a = "zod", appendCaptures: o, moveCaptures: s } = e, c = [], l = (t) => {
|
|
7896
7912
|
let n = Q(r, t);
|
|
7897
7913
|
return n === void 0 ? e.valueAt?.(t) : n;
|
|
@@ -8158,7 +8174,7 @@ function Nu(e) {
|
|
|
8158
8174
|
notices: c
|
|
8159
8175
|
};
|
|
8160
8176
|
}
|
|
8161
|
-
function
|
|
8177
|
+
function Lu(e) {
|
|
8162
8178
|
let { bindRef: t, schema: n, allowKeys: r, snapshots: i, maxSnapshots: a, audit: o, dryRun: s, op: c = "set", protectedCtx: l, snapshotLabel: u } = e, d = e.value, f = e.internalAfterWrite ? Os(t) : null;
|
|
8163
8179
|
if (l) {
|
|
8164
8180
|
let e = ku({
|
|
@@ -8171,7 +8187,7 @@ function Pu(e) {
|
|
|
8171
8187
|
};
|
|
8172
8188
|
d = e.value;
|
|
8173
8189
|
}
|
|
8174
|
-
let p =
|
|
8190
|
+
let p = Fu({
|
|
8175
8191
|
schema: n,
|
|
8176
8192
|
allowKeys: r,
|
|
8177
8193
|
value: d,
|
|
@@ -8215,7 +8231,7 @@ function Pu(e) {
|
|
|
8215
8231
|
notices: p.notices
|
|
8216
8232
|
};
|
|
8217
8233
|
}
|
|
8218
|
-
function
|
|
8234
|
+
function Ru(e) {
|
|
8219
8235
|
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 = e.internalAfterWrite ? Os(t) : null, p = Os(t), m = [], h = [], g = [], _ = [], v = (e, t) => {
|
|
8220
8236
|
(e === "set" || e === "merge") && _.push({
|
|
8221
8237
|
jp: t,
|
|
@@ -8237,7 +8253,7 @@ function Fu(e) {
|
|
|
8237
8253
|
error: X({
|
|
8238
8254
|
code: "PATH_DENIED",
|
|
8239
8255
|
message: `patches[${e}] @ "${a}" 不在 schema 声明字段内`,
|
|
8240
|
-
hint:
|
|
8256
|
+
hint: `仅 schema 声明的 key 可写${Nu(Mu(r, Pu(a)))}`
|
|
8241
8257
|
})
|
|
8242
8258
|
};
|
|
8243
8259
|
let o = t.op ?? "set", s;
|
|
@@ -8260,7 +8276,7 @@ function Fu(e) {
|
|
|
8260
8276
|
error: X({
|
|
8261
8277
|
code: "PATH_DENIED",
|
|
8262
8278
|
message: `patches[${e}] move 目标 "${s}" 不在 schema 声明字段内`,
|
|
8263
|
-
hint:
|
|
8279
|
+
hint: `move 的 value(目标路径)也须在 schema 声明字段内${Nu(Mu(r, Pu(String(s))))}`
|
|
8264
8280
|
})
|
|
8265
8281
|
};
|
|
8266
8282
|
}
|
|
@@ -8298,7 +8314,7 @@ function Fu(e) {
|
|
|
8298
8314
|
error: e.error
|
|
8299
8315
|
};
|
|
8300
8316
|
}
|
|
8301
|
-
let y =
|
|
8317
|
+
let y = Iu({
|
|
8302
8318
|
schema: r,
|
|
8303
8319
|
bindRef: t,
|
|
8304
8320
|
clone: p,
|
|
@@ -8343,37 +8359,37 @@ function Fu(e) {
|
|
|
8343
8359
|
notices: y.notices
|
|
8344
8360
|
};
|
|
8345
8361
|
}
|
|
8346
|
-
function
|
|
8362
|
+
function zu(e) {
|
|
8347
8363
|
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
8348
8364
|
}
|
|
8349
|
-
function
|
|
8365
|
+
function Bu(e, t, n, r) {
|
|
8350
8366
|
if (!t || !n.length || typeof e != "object" || !e) return e;
|
|
8351
8367
|
let i = new Set(n.map((e) => e.field)), a = Os(e);
|
|
8352
8368
|
return (function e(t) {
|
|
8353
8369
|
if (Array.isArray(t)) for (let n of t) e(n);
|
|
8354
8370
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) {
|
|
8355
8371
|
let a = t[n];
|
|
8356
|
-
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${
|
|
8372
|
+
typeof a == "string" && i.has(n) && a.length >= r ? t[n] = `<${n} ${zu(a.length)}>` : e(a);
|
|
8357
8373
|
}
|
|
8358
8374
|
})(a), a;
|
|
8359
8375
|
}
|
|
8360
|
-
var
|
|
8361
|
-
function
|
|
8362
|
-
return
|
|
8376
|
+
var Vu = 0;
|
|
8377
|
+
function Hu() {
|
|
8378
|
+
return Vu++, "c_" + Math.random().toString(36).slice(2, 8) + Vu.toString(36);
|
|
8363
8379
|
}
|
|
8364
|
-
function
|
|
8380
|
+
function Uu(e, t) {
|
|
8365
8381
|
if (!(!e || typeof e != "object")) for (let n of t) {
|
|
8366
8382
|
let t = Q(e, n);
|
|
8367
|
-
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId =
|
|
8383
|
+
if (Array.isArray(t)) for (let e of t) e && typeof e == "object" && !("__pgId" in e) && (e.__pgId = Hu());
|
|
8368
8384
|
}
|
|
8369
8385
|
}
|
|
8370
|
-
function
|
|
8386
|
+
function Wu(e) {
|
|
8371
8387
|
(function e(t) {
|
|
8372
8388
|
if (Array.isArray(t)) t.forEach(e);
|
|
8373
8389
|
else if (t && typeof t == "object") for (let n of Object.keys(t)) n.startsWith("__pg") ? delete t[n] : e(t[n]);
|
|
8374
8390
|
})(e);
|
|
8375
8391
|
}
|
|
8376
|
-
function
|
|
8392
|
+
function Gu(e, n = {}) {
|
|
8377
8393
|
let i = n.pgIdPaths ?? [], a = i.length ? (e, t) => {
|
|
8378
8394
|
if (t && typeof t == "object") for (let n of i) {
|
|
8379
8395
|
let r = Q(t, n), i = Q(e, n);
|
|
@@ -8400,7 +8416,7 @@ function Hu(e, n = {}) {
|
|
|
8400
8416
|
t && n && typeof n == "object" && !("__pgId" in n) && (n.__pgId = t, o.add(e));
|
|
8401
8417
|
}
|
|
8402
8418
|
}
|
|
8403
|
-
|
|
8419
|
+
Uu(e, i);
|
|
8404
8420
|
} : void 0, o = i.length ? ts(e.schema, i).schema : e.schema, s = e.bind, c = e.description ?? "主数据对象", l = Do(o), u = /* @__PURE__ */ new Map(), d = n.vfsStore ? new wu(n.vfsStore) : void 0;
|
|
8405
8421
|
function f(e) {
|
|
8406
8422
|
if (u.clear(), e) for (let t of e) {
|
|
@@ -8568,7 +8584,7 @@ function Hu(e, n = {}) {
|
|
|
8568
8584
|
resourceStore: p.resourceStore
|
|
8569
8585
|
}));
|
|
8570
8586
|
let a = w();
|
|
8571
|
-
return b(a, n), i === void 0 ? `主数据${r ? ` @ ${r}` : ""} = (undefined) (hash=${a})` : (i =
|
|
8587
|
+
return b(a, n), i === void 0 ? `主数据${r ? ` @ ${r}` : ""} = (undefined) (hash=${a})` : (i = Bu(i, n === "", D, E), `主数据${r ? ` @ ${r}` : ""} = ${$(i)} (hash=${a})`);
|
|
8572
8588
|
}, {
|
|
8573
8589
|
name: "get_data",
|
|
8574
8590
|
description: "@deprecated(改用 read,等价且支持 fields/depth/分页)。读取主数据当前值(返回含 hash 供乐观锁);jsonPath 可选读子路径。大结果自动外存 vfs。",
|
|
@@ -8578,7 +8594,7 @@ function Hu(e, n = {}) {
|
|
|
8578
8594
|
if (r !== null) return r;
|
|
8579
8595
|
let i = ks(e);
|
|
8580
8596
|
if (i.parseError) return Yr("", e, i.parseError);
|
|
8581
|
-
let c =
|
|
8597
|
+
let c = Lu({
|
|
8582
8598
|
bindRef: s,
|
|
8583
8599
|
value: i.parsed,
|
|
8584
8600
|
schema: o,
|
|
@@ -8623,7 +8639,7 @@ function Hu(e, n = {}) {
|
|
|
8623
8639
|
message: `edit 仅适用于对象/数组主数据,当前是 ${s === void 0 ? "undefined" : typeof s}`,
|
|
8624
8640
|
hint: "叶子(原始类型)请用 set_data 整体设置"
|
|
8625
8641
|
});
|
|
8626
|
-
let f =
|
|
8642
|
+
let f = Ru({
|
|
8627
8643
|
bindRef: s,
|
|
8628
8644
|
patches: [{
|
|
8629
8645
|
op: r,
|
|
@@ -8808,7 +8824,7 @@ function Hu(e, n = {}) {
|
|
|
8808
8824
|
details: { expr: e }
|
|
8809
8825
|
});
|
|
8810
8826
|
}
|
|
8811
|
-
let c = t ?? 50, u = a.slice(0, c), d = u.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${$(
|
|
8827
|
+
let c = t ?? 50, u = a.slice(0, c), d = u.map((e) => `{"path":${JSON.stringify(e.path)},"index":${e.index === void 0 ? "null" : e.index},"value":${$(Bu(e.value, r === "", D, E))}}`);
|
|
8812
8828
|
return `{"matched":${a.length},"returned":${u.length},"truncated":${a.length > c},"results":[${d.join(",")}]}`;
|
|
8813
8829
|
}, {
|
|
8814
8830
|
name: "query_data",
|
|
@@ -8890,7 +8906,7 @@ function Hu(e, n = {}) {
|
|
|
8890
8906
|
if (t === "transform") {
|
|
8891
8907
|
let e = f.result;
|
|
8892
8908
|
if (c) {
|
|
8893
|
-
let t =
|
|
8909
|
+
let t = Ru({
|
|
8894
8910
|
bindRef: s,
|
|
8895
8911
|
patches: [{
|
|
8896
8912
|
op: "set",
|
|
@@ -8919,7 +8935,7 @@ function Hu(e, n = {}) {
|
|
|
8919
8935
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform(patches) 无法就地替换`,
|
|
8920
8936
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
8921
8937
|
});
|
|
8922
|
-
let t =
|
|
8938
|
+
let t = Ru({
|
|
8923
8939
|
bindRef: s,
|
|
8924
8940
|
patches: e.patches,
|
|
8925
8941
|
schema: o,
|
|
@@ -8952,7 +8968,7 @@ function Hu(e, n = {}) {
|
|
|
8952
8968
|
message: `主数据 bind 为原始类型(${s === null ? "null" : typeof s}),eval transform 无法就地替换外部持有的值引用`,
|
|
8953
8969
|
hint: "主数据 bind 必须为对象/数组;叶子值请用对象包裹或集成方通过 sdk.setData 替换 bind"
|
|
8954
8970
|
});
|
|
8955
|
-
let n =
|
|
8971
|
+
let n = Fu({
|
|
8956
8972
|
schema: o,
|
|
8957
8973
|
allowKeys: l,
|
|
8958
8974
|
value: t,
|
|
@@ -9003,7 +9019,7 @@ function Hu(e, n = {}) {
|
|
|
9003
9019
|
resolved: c,
|
|
9004
9020
|
resourcesByPath: p.resourcesByPath,
|
|
9005
9021
|
resourceStore: p.resourceStore
|
|
9006
|
-
})), n && n.length && (c = As(c, n)), r != null && (c = js(c, r)), c =
|
|
9022
|
+
})), n && n.length && (c = As(c, n)), r != null && (c = js(c, r)), c = Bu(c, d === "", D, E), c === void 0 ? `- ${i} = (undefined)` : `- ${i} = ${$(c)}`;
|
|
9007
9023
|
});
|
|
9008
9024
|
return e && b(f, d), `多路径读取(共 ${t.length} 项,hash=${f}):\n${i.join("\n")}`;
|
|
9009
9025
|
}
|
|
@@ -9013,42 +9029,46 @@ function Hu(e, n = {}) {
|
|
|
9013
9029
|
message: `jsonPath "${m}" 含非法段(__proto__/constructor/prototype)`,
|
|
9014
9030
|
hint: "使用正常属性路径,如 components.0.text(数组索引数字)"
|
|
9015
9031
|
});
|
|
9032
|
+
let h = (e, t) => Mu(o, e) ?? (t && typeof t == "object" && !Array.isArray(t) ? Object.keys(t) : []);
|
|
9016
9033
|
if (!Oo(m, o, l)) {
|
|
9017
|
-
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = e ? Q(s, e) : s, n = t
|
|
9034
|
+
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = h(e, e ? Q(s, e) : s), n = t.length ? `;父级 "${e || "(root)"}" 的可用字段:${t.slice(0, 12).join(", ")}${t.length > 12 ? " …" : ""}` : "";
|
|
9018
9035
|
return X({
|
|
9019
9036
|
code: "PATH_DENIED",
|
|
9020
9037
|
message: `read @ "${m}" 不在 schema 声明字段内`,
|
|
9021
9038
|
hint: `主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它${n}`
|
|
9022
9039
|
});
|
|
9023
9040
|
}
|
|
9024
|
-
let
|
|
9025
|
-
if (m &&
|
|
9026
|
-
let e =
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9041
|
+
let g = m ? Q(s, m) : s;
|
|
9042
|
+
if (m && g === void 0) {
|
|
9043
|
+
let e = Ao(o, m);
|
|
9044
|
+
if (!(e && typeof e.isOptional == "function" && e.isOptional())) {
|
|
9045
|
+
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = e ? Q(s, e) : s, n = h(e, t), r = Array.isArray(t) ? `父级 "${e || "(root)"}" 是 ${t.length} 元数组,有效索引 0-${Math.max(t.length - 1, 0)};先 read({jsonPath:"${e}"}) 确认现状,追加元素走 write 的 append` : n.length ? `父级 "${e || "(root)"}" 的可用字段:${n.slice(0, 12).join(", ")}${n.length > 12 ? " …" : ""};先 read({jsonPath:"${e}"}) 确认` : `父级 "${e || "(root)"}" 不存在或不是容器;先 read() 不传 jsonPath 查看顶层字段`;
|
|
9046
|
+
return X({
|
|
9047
|
+
code: "PATH_NOT_FOUND",
|
|
9048
|
+
path: m,
|
|
9049
|
+
message: `路径 "${m}" 不存在`,
|
|
9050
|
+
hint: r
|
|
9051
|
+
});
|
|
9052
|
+
}
|
|
9033
9053
|
}
|
|
9034
|
-
if (!m && l)
|
|
9054
|
+
if (!m && l) g = Uo(g, o);
|
|
9035
9055
|
else if (l) {
|
|
9036
9056
|
let e = Ao(o, m);
|
|
9037
|
-
e && (
|
|
9057
|
+
e && (g = Uo(g, e));
|
|
9038
9058
|
}
|
|
9039
|
-
let
|
|
9040
|
-
p && (
|
|
9059
|
+
let _ = g;
|
|
9060
|
+
p && (_ = Tu({
|
|
9041
9061
|
jp: m,
|
|
9042
|
-
resolved:
|
|
9062
|
+
resolved: _,
|
|
9043
9063
|
resourcesByPath: p.resourcesByPath,
|
|
9044
9064
|
resourceStore: p.resourceStore
|
|
9045
|
-
})), b(f, d), n && n.length && (
|
|
9046
|
-
let
|
|
9047
|
-
if ((i !== void 0 || a !== void 0) && Array.isArray(
|
|
9048
|
-
let e =
|
|
9049
|
-
return `${
|
|
9065
|
+
})), b(f, d), n && n.length && (_ = As(_, n)), r != null && (_ = js(_, r)), _ = Bu(_, d === "", D, E);
|
|
9066
|
+
let y = e ? "" : `主数据说明: ${c}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, x = n && n.length ? `(字段裁剪:${n.join(",")})` : "", S = r == null ? "" : `(深度≤${r})`, C = x || S ? ` ${x}${S}` : "";
|
|
9067
|
+
if ((i !== void 0 || a !== void 0) && Array.isArray(_)) {
|
|
9068
|
+
let e = _.length, t = Math.max(0, i ?? 0), n = Math.min(200, Math.max(1, a ?? 50)), r = _.slice(t, t + n), o = t + n < e;
|
|
9069
|
+
return `${y}主数据${m ? ` @ ${m}` : ""} 数组分页[offset=${t},limit=${n}]${C} = ${$(r)} (total=${e}, hasMore=${o}) (hash=${f})`;
|
|
9050
9070
|
}
|
|
9051
|
-
return
|
|
9071
|
+
return _ === void 0 ? `${y}主数据${m ? ` @ ${m}` : ""}${C} = (undefined) (hash=${f})` : `${y}主数据${m ? ` @ ${m}` : ""}${C} = ${$(_)} (hash=${f})`;
|
|
9052
9072
|
}, {
|
|
9053
9073
|
name: "read",
|
|
9054
9074
|
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(声明 conflictWatchFields 后 write 自动比对;未声明不自动校验)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。",
|
|
@@ -9122,7 +9142,7 @@ function Hu(e, n = {}) {
|
|
|
9122
9142
|
op: t.op ?? "set",
|
|
9123
9143
|
jsonPath: t.jsonPath || "",
|
|
9124
9144
|
value: f
|
|
9125
|
-
}], c =
|
|
9145
|
+
}], c = Ru({
|
|
9126
9146
|
bindRef: s,
|
|
9127
9147
|
patches: r,
|
|
9128
9148
|
schema: o,
|
|
@@ -9144,13 +9164,13 @@ function Hu(e, n = {}) {
|
|
|
9144
9164
|
timestamp: Date.now()
|
|
9145
9165
|
});
|
|
9146
9166
|
let d = T(u);
|
|
9147
|
-
return
|
|
9167
|
+
return Wu(c.clone), `已 write(edit) 主数据(${c.applied.length} 个 patch)。当前值:${$(c.clone, 600)} (新 hash=${d})`;
|
|
9148
9168
|
}
|
|
9149
9169
|
let _ = ks(f);
|
|
9150
9170
|
if (_.parseError) return Yr("", f, _.parseError);
|
|
9151
9171
|
let x = await N("set", g);
|
|
9152
9172
|
if (x !== null) return x;
|
|
9153
|
-
let S =
|
|
9173
|
+
let S = Lu({
|
|
9154
9174
|
bindRef: s,
|
|
9155
9175
|
value: _.parsed,
|
|
9156
9176
|
schema: o,
|
|
@@ -9167,7 +9187,7 @@ function Hu(e, n = {}) {
|
|
|
9167
9187
|
if (!S.ok) return S.error;
|
|
9168
9188
|
if (i) return `dryRun(set): schema 校验通过。预览新值:${$(S.data, 600)}。未实际写入、未入快照。`;
|
|
9169
9189
|
let E = w();
|
|
9170
|
-
return b(E, u),
|
|
9190
|
+
return b(E, u), Wu(S.data), `已 write(set) 主数据 = ${$(S.data, 600)} (新 hash=${E})${l ? "(白名单模式:仅更新 schema 声明字段,未声明字段保留)" : ""}`;
|
|
9171
9191
|
}, {
|
|
9172
9192
|
name: "write",
|
|
9173
9193
|
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 校验(失败不写,按错误修正重试)+ 自动快照。详细用法见系统提示「能力使用提示」。",
|
|
@@ -9286,7 +9306,7 @@ function Hu(e, n = {}) {
|
|
|
9286
9306
|
}
|
|
9287
9307
|
let f = await N("set", C ? y(r) : void 0);
|
|
9288
9308
|
if (f !== null) return f;
|
|
9289
|
-
let g =
|
|
9309
|
+
let g = Lu({
|
|
9290
9310
|
bindRef: s,
|
|
9291
9311
|
value: d,
|
|
9292
9312
|
schema: o,
|
|
@@ -9447,7 +9467,7 @@ function Hu(e, n = {}) {
|
|
|
9447
9467
|
}
|
|
9448
9468
|
//#endregion
|
|
9449
9469
|
//#region src/core/tools/htmlValidate.ts
|
|
9450
|
-
var
|
|
9470
|
+
var Ku = /* @__PURE__ */ new Set([
|
|
9451
9471
|
"area",
|
|
9452
9472
|
"base",
|
|
9453
9473
|
"br",
|
|
@@ -9462,8 +9482,8 @@ var Uu = /* @__PURE__ */ new Set([
|
|
|
9462
9482
|
"source",
|
|
9463
9483
|
"track",
|
|
9464
9484
|
"wbr"
|
|
9465
|
-
]),
|
|
9466
|
-
function
|
|
9485
|
+
]), qu = /* @__PURE__ */ new Set(["script", "style"]);
|
|
9486
|
+
function Ju(e) {
|
|
9467
9487
|
let t = [], n = e.length;
|
|
9468
9488
|
if (!e.trim()) return t;
|
|
9469
9489
|
let r = [0];
|
|
@@ -9540,8 +9560,8 @@ function Gu(e) {
|
|
|
9540
9560
|
}
|
|
9541
9561
|
continue;
|
|
9542
9562
|
}
|
|
9543
|
-
if (!(
|
|
9544
|
-
if (
|
|
9563
|
+
if (!(Ku.has(p) || m)) {
|
|
9564
|
+
if (qu.has(p)) {
|
|
9545
9565
|
let n = RegExp(`</${p}\\s*>`, "i").exec(e.slice(o));
|
|
9546
9566
|
if (!n) {
|
|
9547
9567
|
t.push({
|
|
@@ -9570,8 +9590,8 @@ function Gu(e) {
|
|
|
9570
9590
|
}
|
|
9571
9591
|
//#endregion
|
|
9572
9592
|
//#region src/core/sdk/codeAssetMiddleware.ts
|
|
9573
|
-
var
|
|
9574
|
-
function
|
|
9593
|
+
var Yu = "__pgTouched", Xu = "__pgFinalText", Zu = "__pgCodeHashes", Qu = "__pgKeepExternal", $u = "__pgNotes", ed = 200;
|
|
9594
|
+
function td(e) {
|
|
9575
9595
|
let t = [];
|
|
9576
9596
|
for (let n of e.split("\n")) {
|
|
9577
9597
|
let e = n.match(/^\s*[-*]?\s*\[note\]\s*(.*)$/i);
|
|
@@ -9579,27 +9599,27 @@ function Qu(e) {
|
|
|
9579
9599
|
}
|
|
9580
9600
|
return [...new Set(t)];
|
|
9581
9601
|
}
|
|
9582
|
-
function
|
|
9583
|
-
let n = Array.isArray(e[
|
|
9584
|
-
e[
|
|
9602
|
+
function nd(e, t) {
|
|
9603
|
+
let n = Array.isArray(e[$u]) ? e[$u].filter((e) => typeof e == "string") : [];
|
|
9604
|
+
e[$u] = [.../* @__PURE__ */ new Set([...n, ...t])].map((e) => e.length > ed ? e.slice(0, ed) + "…" : e).slice(-5);
|
|
9585
9605
|
}
|
|
9586
|
-
function
|
|
9606
|
+
function rd(e) {
|
|
9587
9607
|
let t = 5381;
|
|
9588
9608
|
for (let n = 0; n < e.length; n++) t = (t << 5) + t + e.charCodeAt(n) | 0;
|
|
9589
9609
|
return (t >>> 0).toString(16);
|
|
9590
9610
|
}
|
|
9591
|
-
function
|
|
9611
|
+
function id(e, t) {
|
|
9592
9612
|
let n = [];
|
|
9593
|
-
return
|
|
9613
|
+
return od(e, t, (e) => {
|
|
9594
9614
|
typeof e.name == "string" && e.name && n.push(e.name);
|
|
9595
9615
|
}), n;
|
|
9596
9616
|
}
|
|
9597
|
-
function
|
|
9617
|
+
function ad(e, t) {
|
|
9598
9618
|
if (!e.startsWith(t)) return null;
|
|
9599
9619
|
let n = e.slice(t.length), r = n.lastIndexOf(".");
|
|
9600
9620
|
return (r > 0 ? n.slice(0, r) : r === 0 ? "" : n) || null;
|
|
9601
9621
|
}
|
|
9602
|
-
function
|
|
9622
|
+
function od(e, t, n) {
|
|
9603
9623
|
if (!(!e || typeof e != "object")) for (let r of t) {
|
|
9604
9624
|
let t = Q(e, r);
|
|
9605
9625
|
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
@@ -9608,7 +9628,7 @@ function rd(e, t, n) {
|
|
|
9608
9628
|
}
|
|
9609
9629
|
}
|
|
9610
9630
|
}
|
|
9611
|
-
function
|
|
9631
|
+
function sd(e, t, n) {
|
|
9612
9632
|
let r = /* @__PURE__ */ new Set();
|
|
9613
9633
|
if (!e || typeof e != "object") return r;
|
|
9614
9634
|
for (let i of t) {
|
|
@@ -9627,20 +9647,20 @@ function id(e, t, n) {
|
|
|
9627
9647
|
}
|
|
9628
9648
|
return r;
|
|
9629
9649
|
}
|
|
9630
|
-
function
|
|
9650
|
+
function cd(e) {
|
|
9631
9651
|
let { writablePaths: t, codeVfsPrefix: n, ext: r, codeField: i = "code", onWarning: a, getController: o, vfsStore: s, craftNotes: c = !0 } = e, l = s, u = l.__pgLastCheckout ??= /* @__PURE__ */ new Map(), d = l.__pgPendingRetry ??= /* @__PURE__ */ new Set();
|
|
9632
9652
|
return {
|
|
9633
9653
|
name: "code-asset-checkout-commit",
|
|
9634
9654
|
beforeAgent: (e) => {
|
|
9635
9655
|
let c = o()?.get?.().bind;
|
|
9636
|
-
c &&
|
|
9656
|
+
c && Uu(c, t);
|
|
9637
9657
|
let l = 0, f = 0, p = /* @__PURE__ */ new Map();
|
|
9638
|
-
if (
|
|
9658
|
+
if (od(c, t, (e) => {
|
|
9639
9659
|
l++;
|
|
9640
9660
|
let t = Q(e, i);
|
|
9641
9661
|
if (typeof t == "string") {
|
|
9642
9662
|
f++;
|
|
9643
|
-
let i = e.__pgId, a =
|
|
9663
|
+
let i = e.__pgId, a = rd(t);
|
|
9644
9664
|
p.set(i, a);
|
|
9645
9665
|
let o = `${n}${i}.${r}`, c = s.files[o], l = u.get(i);
|
|
9646
9666
|
c && typeof c.content == "string" && c.content !== t && l === a ? d.add(o) : (s.files[o] = {
|
|
@@ -9661,23 +9681,23 @@ function ad(e) {
|
|
|
9661
9681
|
}
|
|
9662
9682
|
return {
|
|
9663
9683
|
files: s.files,
|
|
9664
|
-
[
|
|
9665
|
-
[
|
|
9666
|
-
[
|
|
9667
|
-
[
|
|
9684
|
+
[Yu]: /* @__PURE__ */ new Set(),
|
|
9685
|
+
[Xu]: { text: "" },
|
|
9686
|
+
[Zu]: p,
|
|
9687
|
+
[Qu]: []
|
|
9668
9688
|
};
|
|
9669
9689
|
},
|
|
9670
9690
|
wrapModelCall: async (e, t) => {
|
|
9671
|
-
let n = await t(e), r = e.state[
|
|
9691
|
+
let n = await t(e), r = e.state[Xu];
|
|
9672
9692
|
return r && !(n.toolCalls && n.toolCalls.length) && typeof n.content == "string" && n.content && (r.text = n.content), n;
|
|
9673
9693
|
},
|
|
9674
9694
|
augmentPrompt: () => {
|
|
9675
9695
|
let e = o()?.get?.().bind, i = [], a = 0;
|
|
9676
|
-
if (
|
|
9696
|
+
if (od(e, t, (e, t, o) => {
|
|
9677
9697
|
a++;
|
|
9678
9698
|
let l = typeof e.name == "string" && e.name ? e.name : "", u = l ? `${l} [${o}]` : `(未命名 [${o}])`, d = `${n}${e.__pgId}.${r}`, f = !!s.files[d];
|
|
9679
9699
|
if (i.push(`- ${u} → ${d}${f ? "" : "(尚未检出,先 vfs_write 创建)"}`), c) {
|
|
9680
|
-
let t = Array.isArray(e[
|
|
9700
|
+
let t = Array.isArray(e[$u]) ? e[$u].filter((e) => typeof e == "string") : [];
|
|
9681
9701
|
if (t.length) {
|
|
9682
9702
|
let e = t[t.length - 1];
|
|
9683
9703
|
i.push(` 📝 笔记×${t.length}(最近):${e.length > 120 ? e.slice(0, 120) + "…" : e}`);
|
|
@@ -9699,9 +9719,9 @@ function ad(e) {
|
|
|
9699
9719
|
if (c) {
|
|
9700
9720
|
let i = e.state.focuses;
|
|
9701
9721
|
if (i && i.length) {
|
|
9702
|
-
let e =
|
|
9722
|
+
let e = sd(o()?.get?.().bind, t, i);
|
|
9703
9723
|
if (e.size) {
|
|
9704
|
-
let t =
|
|
9724
|
+
let t = ad(s, n);
|
|
9705
9725
|
if (t && !e.has(t)) return {
|
|
9706
9726
|
content: `PATH_DENIED · vfs 越界:当前聚焦代码文件 [${[...e].map((e) => `${n}${e}.${r}`).join(", ")}],你要改的 "${s}" 不在其中。请只改焦点组件的代码文件;如需改其他组件,请在收口回复中说明需先取消聚焦(焦点由主会话/用户管理,你无 focus 工具)后重试。`,
|
|
9707
9727
|
status: "error"
|
|
@@ -9711,7 +9731,7 @@ function ad(e) {
|
|
|
9711
9731
|
}
|
|
9712
9732
|
let l = await i(e);
|
|
9713
9733
|
if (c) {
|
|
9714
|
-
let t = e.state[
|
|
9734
|
+
let t = e.state[Yu];
|
|
9715
9735
|
t && t.add(s);
|
|
9716
9736
|
}
|
|
9717
9737
|
return l;
|
|
@@ -9719,10 +9739,10 @@ function ad(e) {
|
|
|
9719
9739
|
afterAgent: (e) => {
|
|
9720
9740
|
let a = o(), l = a?.get?.().bind;
|
|
9721
9741
|
if (!l) return;
|
|
9722
|
-
let u = e[
|
|
9742
|
+
let u = e[Yu] ?? /* @__PURE__ */ new Set();
|
|
9723
9743
|
if (u.size) {
|
|
9724
|
-
let o = e[
|
|
9725
|
-
|
|
9744
|
+
let o = e[Zu] ?? /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set();
|
|
9745
|
+
od(l, t, (t) => {
|
|
9726
9746
|
let a = t.__pgId;
|
|
9727
9747
|
c.add(a);
|
|
9728
9748
|
let l = `${n}${a}.${r}`;
|
|
@@ -9732,14 +9752,14 @@ function ad(e) {
|
|
|
9732
9752
|
let r = o.get(a);
|
|
9733
9753
|
if (r !== void 0) {
|
|
9734
9754
|
let n = Q(t, i);
|
|
9735
|
-
if (typeof n != "string" ||
|
|
9755
|
+
if (typeof n != "string" || rd(n) !== r) {
|
|
9736
9756
|
console.warn(`[page-agent-sdk][code-asset] 组件 ${t.name ?? a}(${l})在修改期间被外部更新,已保留外部版本(keep_external),本次子 agent 修改未提交`);
|
|
9737
|
-
let n = e[
|
|
9738
|
-
Array.isArray(n) ? n.push(r) : e[
|
|
9757
|
+
let n = e[Qu], r = String(t.name ?? a);
|
|
9758
|
+
Array.isArray(n) ? n.push(r) : e[Qu] = [r];
|
|
9739
9759
|
return;
|
|
9740
9760
|
}
|
|
9741
9761
|
}
|
|
9742
|
-
let s =
|
|
9762
|
+
let s = Ju(n.content);
|
|
9743
9763
|
if (s.length) {
|
|
9744
9764
|
console.warn(`[page-agent-sdk][code-asset] 跳过 commit 未通过校验的半成品(可能 abort/timeout 未跑完 verify):${l} - ${s[0].message}(${s[0].code})`);
|
|
9745
9765
|
return;
|
|
@@ -9751,22 +9771,22 @@ function ad(e) {
|
|
|
9751
9771
|
}
|
|
9752
9772
|
});
|
|
9753
9773
|
for (let e of u) {
|
|
9754
|
-
let t =
|
|
9774
|
+
let t = ad(e, n);
|
|
9755
9775
|
t && !c.has(t) && (console.warn(`[page-agent-sdk][code-asset] 组件 ${t}(${e})已被外部删除,放弃 commit 并清理 vfs 工作副本(不复活组件)`), delete s.files[e]);
|
|
9756
9776
|
}
|
|
9757
9777
|
a?.markDataDirty?.(), a?.recomputeBaseline?.();
|
|
9758
9778
|
}
|
|
9759
9779
|
if (!c) return;
|
|
9760
|
-
let f =
|
|
9780
|
+
let f = td(e[Xu]?.text ?? "");
|
|
9761
9781
|
if (!f.length) return;
|
|
9762
9782
|
let p = [];
|
|
9763
|
-
if (
|
|
9783
|
+
if (od(l, t, (e) => {
|
|
9764
9784
|
(u.size === 0 || u.has(`${n}${e.__pgId}.${r}`)) && p.push(e);
|
|
9765
9785
|
}), !p.length) return;
|
|
9766
9786
|
let m = !1;
|
|
9767
9787
|
for (let e of f) {
|
|
9768
9788
|
let t = p.length === 1 ? p[0] : p.find((t) => typeof t.name == "string" && !!t.name && e.includes(t.name));
|
|
9769
|
-
t && (
|
|
9789
|
+
t && (nd(t, [e]), m = !0);
|
|
9770
9790
|
}
|
|
9771
9791
|
m && a?.markDataDirty?.();
|
|
9772
9792
|
}
|
|
@@ -9774,7 +9794,7 @@ function ad(e) {
|
|
|
9774
9794
|
}
|
|
9775
9795
|
//#endregion
|
|
9776
9796
|
//#region src/core/sdk/componentLock.ts
|
|
9777
|
-
function
|
|
9797
|
+
function ld() {
|
|
9778
9798
|
let e = /* @__PURE__ */ new Map();
|
|
9779
9799
|
return {
|
|
9780
9800
|
async acquire(t, n) {
|
|
@@ -9813,7 +9833,7 @@ function od() {
|
|
|
9813
9833
|
}
|
|
9814
9834
|
};
|
|
9815
9835
|
}
|
|
9816
|
-
function
|
|
9836
|
+
function ud(e, t) {
|
|
9817
9837
|
if (Array.isArray(e.components) && e.components.length) {
|
|
9818
9838
|
let n = new Set(t), r = [...new Set(e.components.filter((e) => typeof e == "string" && e && n.has(e)))];
|
|
9819
9839
|
if (r.length) return {
|
|
@@ -9830,12 +9850,12 @@ function sd(e, t) {
|
|
|
9830
9850
|
via: "none"
|
|
9831
9851
|
};
|
|
9832
9852
|
}
|
|
9833
|
-
function
|
|
9853
|
+
function dd(e, t, n) {
|
|
9834
9854
|
let r = new Set(n);
|
|
9835
9855
|
if (!r.size || !e || typeof e != "object") return [];
|
|
9836
9856
|
let i = [];
|
|
9837
9857
|
for (let n of t) {
|
|
9838
|
-
let t =
|
|
9858
|
+
let t = fd(e, n);
|
|
9839
9859
|
if (Array.isArray(t)) for (let e = 0; e < t.length; e++) {
|
|
9840
9860
|
let a = t[e];
|
|
9841
9861
|
a && typeof a == "object" && typeof a.name == "string" && r.has(a.name) && i.push(`${n}.${e}`);
|
|
@@ -9843,7 +9863,7 @@ function cd(e, t, n) {
|
|
|
9843
9863
|
}
|
|
9844
9864
|
return i;
|
|
9845
9865
|
}
|
|
9846
|
-
function
|
|
9866
|
+
function fd(e, t) {
|
|
9847
9867
|
let n = e;
|
|
9848
9868
|
for (let e of t.split(".")) {
|
|
9849
9869
|
if (!n || typeof n != "object") return;
|
|
@@ -9851,26 +9871,26 @@ function ld(e, t) {
|
|
|
9851
9871
|
}
|
|
9852
9872
|
return n;
|
|
9853
9873
|
}
|
|
9854
|
-
function
|
|
9874
|
+
function pd(e, t) {
|
|
9855
9875
|
return t.some((t) => e === t || e.startsWith(t + "."));
|
|
9856
9876
|
}
|
|
9857
|
-
function
|
|
9877
|
+
function md(e, t) {
|
|
9858
9878
|
let n = [];
|
|
9859
9879
|
for (let { writablePaths: r, codeField: i } of t) for (let t of r) {
|
|
9860
|
-
let r =
|
|
9880
|
+
let r = fd(e, t);
|
|
9861
9881
|
if (Array.isArray(r)) for (let e = 0; e < r.length; e++) {
|
|
9862
9882
|
let a = r[e];
|
|
9863
|
-
a && typeof a == "object" && typeof
|
|
9883
|
+
a && typeof a == "object" && typeof fd(a, i) == "string" && n.push(`${t}.${e}.${i}`);
|
|
9864
9884
|
}
|
|
9865
9885
|
}
|
|
9866
9886
|
return n;
|
|
9867
9887
|
}
|
|
9868
|
-
function
|
|
9888
|
+
function hd(e) {
|
|
9869
9889
|
let t = e ?? {}, n = /* @__PURE__ */ new Set();
|
|
9870
9890
|
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);
|
|
9871
9891
|
return [...n];
|
|
9872
9892
|
}
|
|
9873
|
-
function
|
|
9893
|
+
function gd(e) {
|
|
9874
9894
|
return {
|
|
9875
9895
|
name: "component-write-guard",
|
|
9876
9896
|
wrapToolCall: async (t, n) => {
|
|
@@ -9889,9 +9909,9 @@ function pd(e) {
|
|
|
9889
9909
|
status: "error"
|
|
9890
9910
|
};
|
|
9891
9911
|
}
|
|
9892
|
-
let a = e.getLocked(), o = Object.keys(a), s = e.getCodeFieldPaths?.() ?? [], c =
|
|
9912
|
+
let a = e.getLocked(), o = Object.keys(a), s = e.getCodeFieldPaths?.() ?? [], c = hd(i);
|
|
9893
9913
|
if (s.length) {
|
|
9894
|
-
let t = c.filter((e) =>
|
|
9914
|
+
let t = c.filter((e) => pd(e, s));
|
|
9895
9915
|
if (t.length) return e.onReject?.({
|
|
9896
9916
|
paths: t,
|
|
9897
9917
|
lockedPrefixes: s,
|
|
@@ -9902,7 +9922,7 @@ function pd(e) {
|
|
|
9902
9922
|
};
|
|
9903
9923
|
}
|
|
9904
9924
|
if (!o.length) return n(t);
|
|
9905
|
-
let l =
|
|
9925
|
+
let l = dd(e.getBind(), e.writablePaths, o);
|
|
9906
9926
|
if (!l.length) return n(t);
|
|
9907
9927
|
if (!c.length) return e.onReject?.({
|
|
9908
9928
|
paths: ["(整体 set)"],
|
|
@@ -9912,7 +9932,7 @@ function pd(e) {
|
|
|
9912
9932
|
content: `COMPONENT_LOCKED · 组件 [${o.join(", ")}] 正在被子 agent 修改,整体写入会触碰它们。请改用增量 patch(write({patch:{jsonPath,...}}))只写未锁定组件,或等委派结束后再整体操作。`,
|
|
9913
9933
|
status: "error"
|
|
9914
9934
|
};
|
|
9915
|
-
let u = c.filter((e) =>
|
|
9935
|
+
let u = c.filter((e) => pd(e, l));
|
|
9916
9936
|
return u.length ? (e.onReject?.({
|
|
9917
9937
|
paths: u,
|
|
9918
9938
|
lockedPrefixes: l,
|
|
@@ -9926,7 +9946,7 @@ function pd(e) {
|
|
|
9926
9946
|
}
|
|
9927
9947
|
//#endregion
|
|
9928
9948
|
//#region src/core/sdk/baselineGuard.ts
|
|
9929
|
-
function
|
|
9949
|
+
function _d(e) {
|
|
9930
9950
|
return {
|
|
9931
9951
|
name: "baseline-guard",
|
|
9932
9952
|
wrapToolCall: async (t, n) => {
|
|
@@ -9946,21 +9966,21 @@ function md(e) {
|
|
|
9946
9966
|
}
|
|
9947
9967
|
//#endregion
|
|
9948
9968
|
//#region src/core/sdk/diagnostics.ts
|
|
9949
|
-
var
|
|
9950
|
-
function
|
|
9969
|
+
var vd = 5e4, yd = 6e6;
|
|
9970
|
+
function bd(e) {
|
|
9951
9971
|
return e.replace(/([?&][^=&?]*(?:key|token|secret|password|signature)[^=&?]*=)[^&]*/gi, "$1***");
|
|
9952
9972
|
}
|
|
9953
|
-
function
|
|
9954
|
-
if (typeof e == "string") return e.length >
|
|
9955
|
-
if (Array.isArray(e)) return e.map(
|
|
9973
|
+
function xd(e) {
|
|
9974
|
+
if (typeof e == "string") return e.length > vd ? e.slice(0, vd) + `…<truncated:${e.length - vd} chars>` : e;
|
|
9975
|
+
if (Array.isArray(e)) return e.map(xd);
|
|
9956
9976
|
if (e && typeof e == "object") {
|
|
9957
9977
|
let t = {};
|
|
9958
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
9978
|
+
for (let [n, r] of Object.entries(e)) t[n] = xd(r);
|
|
9959
9979
|
return t;
|
|
9960
9980
|
}
|
|
9961
9981
|
return e;
|
|
9962
9982
|
}
|
|
9963
|
-
function
|
|
9983
|
+
function Sd(e) {
|
|
9964
9984
|
let t = Array.isArray(e.debugLogs) ? e.debugLogs : [];
|
|
9965
9985
|
return {
|
|
9966
9986
|
format: "page-agent-sdk/diagnostics",
|
|
@@ -9968,23 +9988,23 @@ function yd(e) {
|
|
|
9968
9988
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9969
9989
|
environment: {
|
|
9970
9990
|
userAgent: typeof navigator < "u" ? navigator.userAgent : "node",
|
|
9971
|
-
url: typeof location < "u" ?
|
|
9991
|
+
url: typeof location < "u" ? bd(location.href) : null
|
|
9972
9992
|
},
|
|
9973
9993
|
sessionId: e.sessionId ?? null,
|
|
9974
9994
|
usage: e.usage ?? null,
|
|
9975
9995
|
pendingConflict: e.pendingConflict ?? null,
|
|
9976
9996
|
dataSummary: e.dataSummary ?? null,
|
|
9977
|
-
info: e.info ?
|
|
9978
|
-
messages: (e.messages ?? []).map(
|
|
9979
|
-
debugLogs: t.map(
|
|
9997
|
+
info: e.info ? xd(e.info) : null,
|
|
9998
|
+
messages: (e.messages ?? []).map(xd),
|
|
9999
|
+
debugLogs: t.map(xd),
|
|
9980
10000
|
extra: e.extra ?? null
|
|
9981
10001
|
};
|
|
9982
10002
|
}
|
|
9983
|
-
function
|
|
10003
|
+
function Cd(e) {
|
|
9984
10004
|
let t = JSON.stringify(e);
|
|
9985
|
-
if (t.length <=
|
|
10005
|
+
if (t.length <= yd) return t;
|
|
9986
10006
|
let n = Array.isArray(e.debugLogs) ? e.debugLogs : [], r = 0;
|
|
9987
|
-
for (; t.length >
|
|
10007
|
+
for (; t.length > yd && n.length > 1;) {
|
|
9988
10008
|
let i = Math.max(1, Math.floor(n.length / 2));
|
|
9989
10009
|
n.splice(0, i), r += i, t = JSON.stringify(e);
|
|
9990
10010
|
}
|
|
@@ -9994,13 +10014,13 @@ function bd(e) {
|
|
|
9994
10014
|
data: {
|
|
9995
10015
|
stage: "diagnostics_truncated",
|
|
9996
10016
|
droppedOldestLogs: r,
|
|
9997
|
-
reason: `report > ${
|
|
10017
|
+
reason: `report > ${yd} chars`
|
|
9998
10018
|
}
|
|
9999
10019
|
}), t = JSON.stringify(e)), t;
|
|
10000
10020
|
}
|
|
10001
10021
|
//#endregion
|
|
10002
10022
|
//#region src/core/sdk/htmlSubagent.ts
|
|
10003
|
-
function
|
|
10023
|
+
function wd(e, t, n) {
|
|
10004
10024
|
let r = "html";
|
|
10005
10025
|
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(规划)。
|
|
10006
10026
|
|
|
@@ -10054,7 +10074,7 @@ ${`- 输出形态:完整、自包含的 HTML 页面(.${r},可独立成页)`}
|
|
|
10054
10074
|
- 一次想清楚 → 动手 → 验证 → 收口。**思考是手段不是目的,产出代码才是**。
|
|
10055
10075
|
8. **收口格式(必守,最后一行)**:收口回复 = 简短结果总结 + **末行交接笔记** \`[note] <一句话实现要点>\` —— 关键设计决策 / 用户偏好 / 踩坑(如「[note] 液面用 height keyframes 4.2s 循环;装饰仅灯串+光斑 2 类」)。框架只识别末尾 [note] 行存进组件、自动转交下次维护该组件的子 agent;**漏写 = 下任失去交接**(真 LLM 实测漏写率 3/4,务必末行带上)。一行内,只写可复用结论。`;
|
|
10056
10076
|
}
|
|
10057
|
-
function
|
|
10077
|
+
function Td(e, t) {
|
|
10058
10078
|
return `# HTML 完整页面生成规范
|
|
10059
10079
|
|
|
10060
10080
|
## 代码资产模型(重要)
|
|
@@ -10092,14 +10112,14 @@ function Sd(e, t) {
|
|
|
10092
10112
|
- 语义化标签(button / nav / section);图片 alt;交互可键盘聚焦
|
|
10093
10113
|
- 颜色对比达标;不只用颜色传达信息`;
|
|
10094
10114
|
}
|
|
10095
|
-
function
|
|
10115
|
+
function Ed(e = "components", t = "code") {
|
|
10096
10116
|
return {
|
|
10097
10117
|
name: "html-fragment",
|
|
10098
10118
|
description: "完整 HTML 页面生成规范:代码作为 data 资产 / vfs 工作副本 / 完整自包含可独立成页 / script+CSS 集中放置 / 可引外部 JS/CSS / validate_code 自检 / 安全底线 / 可访问性",
|
|
10099
|
-
getContent: () =>
|
|
10119
|
+
getContent: () => Td(e, t)
|
|
10100
10120
|
};
|
|
10101
10121
|
}
|
|
10102
|
-
function
|
|
10122
|
+
function Dd(e = {}) {
|
|
10103
10123
|
let t = e.vfsPrefix ?? "html/";
|
|
10104
10124
|
return ({ state: e }) => {
|
|
10105
10125
|
let n = e.files;
|
|
@@ -10107,7 +10127,7 @@ function wd(e = {}) {
|
|
|
10107
10127
|
let r = [];
|
|
10108
10128
|
for (let [e, i] of Object.entries(n)) {
|
|
10109
10129
|
if (!e.startsWith(t)) continue;
|
|
10110
|
-
let n =
|
|
10130
|
+
let n = Ju(i.content);
|
|
10111
10131
|
for (let t of n) r.push(`${e} 第 ${t.line} 行:${t.message}(${t.code})`);
|
|
10112
10132
|
}
|
|
10113
10133
|
return r.length ? {
|
|
@@ -10116,7 +10136,7 @@ function wd(e = {}) {
|
|
|
10116
10136
|
} : { ok: !0 };
|
|
10117
10137
|
};
|
|
10118
10138
|
}
|
|
10119
|
-
function
|
|
10139
|
+
function Od(e) {
|
|
10120
10140
|
let n, i, a = {
|
|
10121
10141
|
name: "html-validate-tools",
|
|
10122
10142
|
beforeAgent: (e) => {
|
|
@@ -10151,7 +10171,7 @@ function Td(e) {
|
|
|
10151
10171
|
}
|
|
10152
10172
|
let s = [];
|
|
10153
10173
|
for (let e of o) {
|
|
10154
|
-
let t =
|
|
10174
|
+
let t = Ju(e.content);
|
|
10155
10175
|
t.length && s.push(`${e.path}:\n${t.map((e) => ` 第 ${e.line} 行 ${e.message}(${e.code})`).join("\n")}`);
|
|
10156
10176
|
}
|
|
10157
10177
|
return s.length ? `❌ 格式校验未通过:\n${s.join("\n")}\n请用 vfs_edit 修正后重新调用 validate_code 复查。` : `✅ 格式校验通过(${o.map((e) => e.path).join(", ")}:标签闭合等结构合法)。`;
|
|
@@ -10169,16 +10189,16 @@ function Td(e) {
|
|
|
10169
10189
|
i = e;
|
|
10170
10190
|
}, a;
|
|
10171
10191
|
}
|
|
10172
|
-
var
|
|
10173
|
-
function
|
|
10192
|
+
var kd = 2;
|
|
10193
|
+
function Ad(e = {}) {
|
|
10174
10194
|
let { writablePaths: t, codeVfsPrefix: n = "html/", id: r = "html", description: i, planning: a = !0, summarization: o = !0, maxToolRounds: s = 12, temperature: c = .4, skills: l, extraTools: u, formatCheck: d = !0, codeField: f = "code", orchestratorPrompt: p = !0, craftNotes: m = !0, llm: h, thinkingMode: g } = e;
|
|
10175
10195
|
if (t !== void 0 && !Array.isArray(t)) throw Error("[page-agent-sdk][createHtmlSubagent] writablePaths 须为字符串数组(代码组件 data 区,如 [\"components\"])/ 省略以从 schema 自动推断");
|
|
10176
10196
|
let _ = [];
|
|
10177
|
-
a && _.push(Ja()), d && (_.push(
|
|
10197
|
+
a && _.push(Ja()), d && (_.push(Od(n)), _.push(Tl({ check: Dd({ vfsPrefix: n }) })));
|
|
10178
10198
|
let v = u ?? [], y = t?.[0] ?? "components", b = l === void 0, x = {
|
|
10179
10199
|
id: r,
|
|
10180
10200
|
description: i ?? `生成/修改纯代码组件(代码作为 data 资产,代码字段 ${f} 随 data 持久化;vfs 作工作副本;能规划(write_todos)+ 执行)。需写代码组件或灵活定制时委派`,
|
|
10181
|
-
systemPrompt:
|
|
10201
|
+
systemPrompt: wd(n, f, y),
|
|
10182
10202
|
...h ? { llm: h } : {},
|
|
10183
10203
|
...g ? { thinkingMode: g } : {},
|
|
10184
10204
|
writablePaths: t ?? [],
|
|
@@ -10191,9 +10211,9 @@ function Dd(e = {}) {
|
|
|
10191
10211
|
],
|
|
10192
10212
|
middleware: _.length ? _ : void 0,
|
|
10193
10213
|
summarization: o === !1 ? void 0 : o,
|
|
10194
|
-
maxVerifyAttempts: d ?
|
|
10214
|
+
maxVerifyAttempts: d ? kd : void 0,
|
|
10195
10215
|
temperature: c,
|
|
10196
|
-
skills: b ? [
|
|
10216
|
+
skills: b ? [Ed(y, f)] : l,
|
|
10197
10217
|
maxToolRounds: s,
|
|
10198
10218
|
tools: v.length ? v : void 0,
|
|
10199
10219
|
_codeAsset: {
|
|
@@ -10206,12 +10226,12 @@ function Dd(e = {}) {
|
|
|
10206
10226
|
}
|
|
10207
10227
|
};
|
|
10208
10228
|
return x._rebuildCodeAssetPaths = (e) => {
|
|
10209
|
-
x.systemPrompt =
|
|
10229
|
+
x.systemPrompt = wd(n, f, e), b && (x.skills = [Ed(e, f)]);
|
|
10210
10230
|
}, x;
|
|
10211
10231
|
}
|
|
10212
10232
|
//#endregion
|
|
10213
10233
|
//#region src/core/sdk/defineTool.ts
|
|
10214
|
-
function
|
|
10234
|
+
function jd(e) {
|
|
10215
10235
|
return r(async (t) => {
|
|
10216
10236
|
let n = await e.handler(t);
|
|
10217
10237
|
return typeof n == "string" ? n : JSON.stringify(n);
|
|
@@ -10223,7 +10243,7 @@ function Od(e) {
|
|
|
10223
10243
|
}
|
|
10224
10244
|
//#endregion
|
|
10225
10245
|
//#region src/core/sdk/inspectContextTool.ts
|
|
10226
|
-
var
|
|
10246
|
+
var Md = t.object({
|
|
10227
10247
|
path: t.string().optional().describe("分类 key 过滤(如 toolResults/history/systemPrompt/dataHint);不传=全部分类"),
|
|
10228
10248
|
role: t.enum([
|
|
10229
10249
|
"user",
|
|
@@ -10233,11 +10253,11 @@ var kd = t.object({
|
|
|
10233
10253
|
]).optional().describe("聚焦每轮首句的角色(assistant→回复摘要,user→问题摘要);不影响工具列表"),
|
|
10234
10254
|
limit: t.number().int().min(1).max(50).optional().describe("返回最近 N 轮(默认全部;超 50 自动截最近 50 防返回过大)")
|
|
10235
10255
|
});
|
|
10236
|
-
function
|
|
10237
|
-
return
|
|
10256
|
+
function Nd(e) {
|
|
10257
|
+
return jd({
|
|
10238
10258
|
name: "inspect_context",
|
|
10239
10259
|
description: "查看当前对话上下文的构成(供压缩决策)。返回:totalTokens(历史轮次 token 总和,与触发判断同口径)、occupancy(窗口占用比)、contextWindow、categories(分类占用)、rounds(每轮 token/工具/首句)。先调用本工具查看构成,再决定压缩策略。",
|
|
10240
|
-
schema:
|
|
10260
|
+
schema: Md,
|
|
10241
10261
|
handler: (t) => {
|
|
10242
10262
|
let n = lc(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) => {
|
|
10243
10263
|
let n = xc(e), r = dc(e), i = t.role === "assistant" ? e.assistantMsgs[0] ?? e.userMsg : e.userMsg, a = uc(typeof i.content == "string" ? i.content : "", 60);
|
|
@@ -10260,7 +10280,7 @@ function Ad(e) {
|
|
|
10260
10280
|
}
|
|
10261
10281
|
//#endregion
|
|
10262
10282
|
//#region src/core/sdk/compressDecision.ts
|
|
10263
|
-
var
|
|
10283
|
+
var Pd = t.object({
|
|
10264
10284
|
keepRounds: t.number().int().min(0).max(50).optional(),
|
|
10265
10285
|
windowRatio: t.number().min(0).max(1).optional(),
|
|
10266
10286
|
summarize: t.object({ mode: t.enum(["index", "llm"]) }),
|
|
@@ -10270,23 +10290,23 @@ var jd = t.object({
|
|
|
10270
10290
|
}).refine((e) => e.keepRounds !== void 0 || e.windowRatio !== void 0, { message: "keepRounds 与 windowRatio 至少填一个(按当前触发模式)" });
|
|
10271
10291
|
//#endregion
|
|
10272
10292
|
//#region src/core/sdk/llmResolver.ts
|
|
10273
|
-
function
|
|
10293
|
+
function Fd(e) {
|
|
10274
10294
|
let t = e.find((e) => e.role === "user");
|
|
10275
10295
|
if (!t) return;
|
|
10276
10296
|
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, " ");
|
|
10277
10297
|
if (r) return r.length > 30 ? r.slice(0, 30) + "…" : r;
|
|
10278
10298
|
}
|
|
10279
|
-
function
|
|
10299
|
+
function Id(e) {
|
|
10280
10300
|
return !!e && typeof e == "object" && typeof e.invoke == "function" && typeof e.stream == "function";
|
|
10281
10301
|
}
|
|
10282
|
-
function
|
|
10302
|
+
function Ld(e) {
|
|
10283
10303
|
let t = e.content;
|
|
10284
10304
|
return typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "string" ? e : e?.text ?? "").join("") : String(t ?? "");
|
|
10285
10305
|
}
|
|
10286
|
-
function
|
|
10306
|
+
function Rd(e) {
|
|
10287
10307
|
let t = e.summaryLlm ?? e.llm;
|
|
10288
10308
|
if (!t) return;
|
|
10289
|
-
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s =
|
|
10309
|
+
let n = e.summaryTemperature ?? .3, r = e.summaryMaxTokens ?? 1024, i = e.summaryTimeoutMs ?? 15e3, s = Id(t) ? t : null, c = Id(t) ? null : t;
|
|
10290
10310
|
if (c && !c.apiKey) {
|
|
10291
10311
|
e.summaryLlm && console.warn("[page-agent-sdk][summarization] summaryLlm 已配置但缺 apiKey,摘要回退主 agent 模型或零成本索引摘要");
|
|
10292
10312
|
return;
|
|
@@ -10298,16 +10318,16 @@ function Fd(e) {
|
|
|
10298
10318
|
return !l && c && (l = await h(c, {
|
|
10299
10319
|
temperature: n,
|
|
10300
10320
|
maxTokens: r
|
|
10301
|
-
})),
|
|
10321
|
+
})), Ld(await l.invoke([new o("你是对话历史压缩助手。把下面按轮次索引的对话要点,改写成一段连贯、紧凑的中文摘要,保留关键事实、用户意图与已用工具,不要编造。直接输出摘要正文。"), new a(e)], { signal: t.signal })).trim();
|
|
10302
10322
|
} finally {
|
|
10303
10323
|
clearTimeout(s);
|
|
10304
10324
|
}
|
|
10305
10325
|
};
|
|
10306
10326
|
}
|
|
10307
|
-
function
|
|
10327
|
+
function zd(e) {
|
|
10308
10328
|
let t = e.titleLlm ?? e.summaryLlm ?? e.llm;
|
|
10309
10329
|
if (!t) return;
|
|
10310
|
-
let n =
|
|
10330
|
+
let n = Id(t) ? t : null, r = Id(t) ? null : t;
|
|
10311
10331
|
if (r && !r.apiKey) return;
|
|
10312
10332
|
let i = n;
|
|
10313
10333
|
return async (t) => {
|
|
@@ -10318,7 +10338,7 @@ function Id(e) {
|
|
|
10318
10338
|
maxTokens: 30
|
|
10319
10339
|
}));
|
|
10320
10340
|
let t = await i.invoke([new o(e.i18n?.locale === "en-US" ? "Generate a short English title (max 10 words) summarizing the conversation below. Output the title text only, no quotes or punctuation." : "根据以下对话的主旨,生成一个简短的中文标题(不超过15个字,不要标点和引号,直接输出标题文字)。"), new a(n)], { signal: s.signal }), c = e.i18n?.locale === "en-US" ? 60 : 20;
|
|
10321
|
-
return
|
|
10341
|
+
return Ld(t).trim().replace(/^["'""「『]|["'""」』]$/g, "").split("\n")[0].slice(0, c);
|
|
10322
10342
|
} catch {
|
|
10323
10343
|
return "";
|
|
10324
10344
|
} finally {
|
|
@@ -10326,10 +10346,10 @@ function Id(e) {
|
|
|
10326
10346
|
}
|
|
10327
10347
|
};
|
|
10328
10348
|
}
|
|
10329
|
-
function
|
|
10349
|
+
function Bd() {
|
|
10330
10350
|
return `call_dec_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
10331
10351
|
}
|
|
10332
|
-
function
|
|
10352
|
+
function Vd(e) {
|
|
10333
10353
|
let t = e.match(/```(?:json)?\s*([\s\S]*?)```/), n = t ? t[1] : e, r = n.indexOf("{"), i = n.lastIndexOf("}");
|
|
10334
10354
|
if (r < 0 || i < 0 || i <= r) return null;
|
|
10335
10355
|
try {
|
|
@@ -10338,21 +10358,21 @@ function Rd(e) {
|
|
|
10338
10358
|
return null;
|
|
10339
10359
|
}
|
|
10340
10360
|
}
|
|
10341
|
-
function
|
|
10361
|
+
function Hd(e) {
|
|
10342
10362
|
if (!e) return null;
|
|
10343
|
-
let t =
|
|
10363
|
+
let t = Vd(e);
|
|
10344
10364
|
if (t == null) return null;
|
|
10345
|
-
let n =
|
|
10365
|
+
let n = Pd.safeParse(t);
|
|
10346
10366
|
return n.success ? n.data : null;
|
|
10347
10367
|
}
|
|
10348
|
-
async function
|
|
10368
|
+
async function Ud(e, t, n, r) {
|
|
10349
10369
|
let i = [...n];
|
|
10350
10370
|
for (let n = 0; n < 3; n++) {
|
|
10351
10371
|
let n = await e.invoke(i, { signal: r }), a = n?.tool_calls ?? [];
|
|
10352
|
-
if (!a.length) return
|
|
10372
|
+
if (!a.length) return Ld(n).trim();
|
|
10353
10373
|
i = [...i, n];
|
|
10354
10374
|
for (let e of a) {
|
|
10355
|
-
let n = e.id ??
|
|
10375
|
+
let n = e.id ?? Bd();
|
|
10356
10376
|
try {
|
|
10357
10377
|
let r = await t.invoke(e.args ?? {}), a = typeof r == "string" ? r : r?.content ?? JSON.stringify(r);
|
|
10358
10378
|
i = [...i, new s({
|
|
@@ -10369,10 +10389,10 @@ async function Bd(e, t, n, r) {
|
|
|
10369
10389
|
}
|
|
10370
10390
|
return "";
|
|
10371
10391
|
}
|
|
10372
|
-
function
|
|
10392
|
+
function Wd(e) {
|
|
10373
10393
|
let t = e.summaryLlm ?? e.llm;
|
|
10374
10394
|
if (!t) return;
|
|
10375
|
-
let n =
|
|
10395
|
+
let n = Id(t) ? t : null, r = Id(t) ? null : t;
|
|
10376
10396
|
if (r && !r.apiKey) return;
|
|
10377
10397
|
let i = e.decisionTimeoutMs ?? 6e3, s = e.decisionMaxTokens ?? 2048, c = n;
|
|
10378
10398
|
return async (e) => {
|
|
@@ -10384,12 +10404,12 @@ function Vd(e) {
|
|
|
10384
10404
|
}));
|
|
10385
10405
|
let n = c;
|
|
10386
10406
|
if (typeof n.bindTools != "function") return null;
|
|
10387
|
-
let i =
|
|
10407
|
+
let i = Nd({
|
|
10388
10408
|
getMessages: e.getMessages,
|
|
10389
10409
|
getSnapshot: e.getSnapshot,
|
|
10390
10410
|
contextWindow: e.contextWindow
|
|
10391
10411
|
}), 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)。`)];
|
|
10392
|
-
return
|
|
10412
|
+
return Hd(await Ud(l, i, d, t.signal)) || Hd(await Ud(l, i, [...d, new a("上一次输出无效(JSON 解析失败或 schema 校验不通过)。请只输出符合 schema 的压缩决策 JSON,不要多余文字/markdown 代码块。")], t.signal));
|
|
10393
10413
|
} catch {
|
|
10394
10414
|
return null;
|
|
10395
10415
|
} finally {
|
|
@@ -10397,8 +10417,8 @@ function Vd(e) {
|
|
|
10397
10417
|
}
|
|
10398
10418
|
};
|
|
10399
10419
|
}
|
|
10400
|
-
function
|
|
10401
|
-
let t = e.llm, n =
|
|
10420
|
+
function Gd(e) {
|
|
10421
|
+
let t = e.llm, n = Id(e.llm) ? void 0 : e.llm;
|
|
10402
10422
|
return {
|
|
10403
10423
|
modelCaps: Ci({
|
|
10404
10424
|
model: n?.model ?? t?.model ?? t?.modelName,
|
|
@@ -10406,14 +10426,14 @@ function Hd(e) {
|
|
|
10406
10426
|
maxOutputTokens: e.maxOutputTokens ?? n?.maxOutputTokens ?? t?.maxOutputTokens,
|
|
10407
10427
|
vision: n?.vision ?? t?.vision
|
|
10408
10428
|
}),
|
|
10409
|
-
summaryLlmInvoke:
|
|
10410
|
-
titleLlmInvoke:
|
|
10411
|
-
compressDecisionInvoke:
|
|
10429
|
+
summaryLlmInvoke: Rd(e),
|
|
10430
|
+
titleLlmInvoke: zd(e),
|
|
10431
|
+
compressDecisionInvoke: Wd(e)
|
|
10412
10432
|
};
|
|
10413
10433
|
}
|
|
10414
10434
|
//#endregion
|
|
10415
10435
|
//#region src/core/sdk/conflictManager.ts
|
|
10416
|
-
function
|
|
10436
|
+
function Kd(e, t) {
|
|
10417
10437
|
let n = /* @__PURE__ */ jt(null), r = 0;
|
|
10418
10438
|
function i(i) {
|
|
10419
10439
|
let a = t?.() ?? "ask";
|
|
@@ -10457,7 +10477,7 @@ function Ud(e, t) {
|
|
|
10457
10477
|
}
|
|
10458
10478
|
//#endregion
|
|
10459
10479
|
//#region src/core/utils/id.ts
|
|
10460
|
-
function
|
|
10480
|
+
function qd() {
|
|
10461
10481
|
try {
|
|
10462
10482
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function") return crypto.randomUUID();
|
|
10463
10483
|
} catch {}
|
|
@@ -10465,7 +10485,7 @@ function Wd() {
|
|
|
10465
10485
|
}
|
|
10466
10486
|
//#endregion
|
|
10467
10487
|
//#region src/core/backends/storage.ts
|
|
10468
|
-
var
|
|
10488
|
+
var Jd = "chat-sdk", Yd = 50 * 1024 * 1024, Xd = 4 * 1024 * 1024, Zd = 10 * 1024 * 1024, Qd = .9, $d = 500, ef = 300, tf = "__meta__", nf = "v:1", rf = [
|
|
10469
10489
|
"messages",
|
|
10470
10490
|
"vfs",
|
|
10471
10491
|
"todos",
|
|
@@ -10477,51 +10497,51 @@ var Gd = "chat-sdk", Kd = 50 * 1024 * 1024, qd = 4 * 1024 * 1024, Jd = 10 * 1024
|
|
|
10477
10497
|
"focus",
|
|
10478
10498
|
"planConfirmation"
|
|
10479
10499
|
];
|
|
10480
|
-
function
|
|
10481
|
-
return e === "local" || e === "session" ?
|
|
10500
|
+
function af(e) {
|
|
10501
|
+
return e === "local" || e === "session" ? Xd : Yd;
|
|
10482
10502
|
}
|
|
10483
|
-
function
|
|
10503
|
+
function of(e) {
|
|
10484
10504
|
if (typeof e != "object" || !e) return !1;
|
|
10485
10505
|
let t = e;
|
|
10486
10506
|
return t.name === "QuotaExceededError" || t.name === "NS_ERROR_DOM_QUOTA_REACHED" || t.code === 22 || t.code === 1014;
|
|
10487
10507
|
}
|
|
10488
|
-
function
|
|
10508
|
+
function sf(e, t, n, r) {
|
|
10489
10509
|
return [
|
|
10490
|
-
|
|
10510
|
+
nf,
|
|
10491
10511
|
e,
|
|
10492
10512
|
t,
|
|
10493
10513
|
n,
|
|
10494
10514
|
r
|
|
10495
10515
|
].join("::");
|
|
10496
10516
|
}
|
|
10497
|
-
function
|
|
10517
|
+
function cf(e, t, n) {
|
|
10498
10518
|
return [
|
|
10499
|
-
|
|
10519
|
+
nf,
|
|
10500
10520
|
e,
|
|
10501
10521
|
t,
|
|
10502
10522
|
n
|
|
10503
10523
|
].join("::") + "::";
|
|
10504
10524
|
}
|
|
10505
|
-
function
|
|
10525
|
+
function lf(e, t) {
|
|
10506
10526
|
return [
|
|
10507
|
-
|
|
10527
|
+
nf,
|
|
10508
10528
|
e,
|
|
10509
10529
|
t
|
|
10510
10530
|
].join("::") + "::";
|
|
10511
10531
|
}
|
|
10512
|
-
function
|
|
10513
|
-
return [
|
|
10532
|
+
function uf(e) {
|
|
10533
|
+
return [nf, e].join("::") + "::";
|
|
10514
10534
|
}
|
|
10515
|
-
var
|
|
10516
|
-
function
|
|
10517
|
-
|
|
10535
|
+
var df = null;
|
|
10536
|
+
function ff(e) {
|
|
10537
|
+
df ||= new TextEncoder();
|
|
10518
10538
|
try {
|
|
10519
|
-
return
|
|
10539
|
+
return df.encode(JSON.stringify(e)).length;
|
|
10520
10540
|
} catch {
|
|
10521
10541
|
return 0;
|
|
10522
10542
|
}
|
|
10523
10543
|
}
|
|
10524
|
-
function
|
|
10544
|
+
function pf(e, t, n) {
|
|
10525
10545
|
let r = e.reduce((e, t) => e + t.bytes, 0);
|
|
10526
10546
|
if (r <= t) return [];
|
|
10527
10547
|
let i = t * n, a = [...e].sort((e, t) => e.lastAccessed - t.lastAccessed), o = [];
|
|
@@ -10531,7 +10551,7 @@ function uf(e, t, n) {
|
|
|
10531
10551
|
}
|
|
10532
10552
|
return o;
|
|
10533
10553
|
}
|
|
10534
|
-
function
|
|
10554
|
+
function mf() {
|
|
10535
10555
|
let e = /* @__PURE__ */ new Map();
|
|
10536
10556
|
return {
|
|
10537
10557
|
async get(t) {
|
|
@@ -10551,7 +10571,7 @@ function df() {
|
|
|
10551
10571
|
}
|
|
10552
10572
|
};
|
|
10553
10573
|
}
|
|
10554
|
-
function
|
|
10574
|
+
function hf(e) {
|
|
10555
10575
|
return new Promise((t, n) => {
|
|
10556
10576
|
if (typeof indexedDB > "u") {
|
|
10557
10577
|
n(/* @__PURE__ */ Error("indexedDB 不可用"));
|
|
@@ -10612,7 +10632,7 @@ function ff(e) {
|
|
|
10612
10632
|
}, r.onerror = () => n(r.error);
|
|
10613
10633
|
});
|
|
10614
10634
|
}
|
|
10615
|
-
function
|
|
10635
|
+
function gf(e) {
|
|
10616
10636
|
return {
|
|
10617
10637
|
async get(t) {
|
|
10618
10638
|
let n = e.getItem(t);
|
|
@@ -10657,12 +10677,12 @@ function pf(e) {
|
|
|
10657
10677
|
}
|
|
10658
10678
|
};
|
|
10659
10679
|
}
|
|
10660
|
-
function
|
|
10680
|
+
function _f(e, t, n) {
|
|
10661
10681
|
let r = (e.get(t) ?? Promise.resolve()).then(n, n);
|
|
10662
10682
|
return e.set(t, r.then(() => void 0, () => void 0)), r;
|
|
10663
10683
|
}
|
|
10664
|
-
function
|
|
10665
|
-
let t = e.dbName ??
|
|
10684
|
+
function vf(e = {}) {
|
|
10685
|
+
let t = e.dbName ?? Jd, n = e.backend ?? "indexed", r = e.maxBytes ?? af(n), i = e.maxBytesPerSession ?? Zd, a = e.evictionWatermark ?? Qd, o = e.debounceMs ?? $d, s = /* @__PURE__ */ new Set();
|
|
10666
10686
|
function c(e) {
|
|
10667
10687
|
for (let t of s) try {
|
|
10668
10688
|
t(e);
|
|
@@ -10675,16 +10695,16 @@ function hf(e = {}) {
|
|
|
10675
10695
|
try {
|
|
10676
10696
|
if (n === "indexed") {
|
|
10677
10697
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
10678
|
-
l = await
|
|
10698
|
+
l = await hf(t), d(!0);
|
|
10679
10699
|
} else if (n === "session") {
|
|
10680
10700
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
10681
|
-
l =
|
|
10701
|
+
l = gf(sessionStorage), d(!0);
|
|
10682
10702
|
} else if (n === "local") {
|
|
10683
10703
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
10684
|
-
l =
|
|
10685
|
-
} else l =
|
|
10704
|
+
l = gf(localStorage), d(!0);
|
|
10705
|
+
} else l = mf(), d(!1);
|
|
10686
10706
|
} catch (e) {
|
|
10687
|
-
l =
|
|
10707
|
+
l = mf();
|
|
10688
10708
|
let t = e instanceof Error ? e.message : String(e);
|
|
10689
10709
|
d(!1), Promise.resolve().then(() => c({
|
|
10690
10710
|
type: "degraded",
|
|
@@ -10694,10 +10714,10 @@ function hf(e = {}) {
|
|
|
10694
10714
|
})();
|
|
10695
10715
|
let p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
10696
10716
|
function g(e, n, r, a) {
|
|
10697
|
-
let o =
|
|
10698
|
-
return
|
|
10717
|
+
let o = sf(t, r, a, tf);
|
|
10718
|
+
return _f(h, o, async () => {
|
|
10699
10719
|
let t = async () => {
|
|
10700
|
-
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 :
|
|
10720
|
+
let t = await l.get(o), s = await l.get(e), u = s == null ? 0 : ff(s), d = ff(n), f = (t?.bytes ?? 0) + (d - u);
|
|
10701
10721
|
if (f > i) {
|
|
10702
10722
|
c({
|
|
10703
10723
|
type: "quota",
|
|
@@ -10719,12 +10739,12 @@ function hf(e = {}) {
|
|
|
10719
10739
|
try {
|
|
10720
10740
|
await t();
|
|
10721
10741
|
} catch (e) {
|
|
10722
|
-
if (
|
|
10742
|
+
if (of(e) && !u) {
|
|
10723
10743
|
u = !0;
|
|
10724
10744
|
try {
|
|
10725
10745
|
await b();
|
|
10726
10746
|
} catch {}
|
|
10727
|
-
l =
|
|
10747
|
+
l = mf(), Promise.resolve().then(() => c({
|
|
10728
10748
|
type: "degraded",
|
|
10729
10749
|
reason: "存储配额超限(QuotaExceededError),已淘汰最旧会话并降级内存"
|
|
10730
10750
|
}));
|
|
@@ -10736,7 +10756,7 @@ function hf(e = {}) {
|
|
|
10736
10756
|
});
|
|
10737
10757
|
}
|
|
10738
10758
|
function _(e, n, r, i) {
|
|
10739
|
-
let a =
|
|
10759
|
+
let a = sf(t, e, n, r), s = p.get(a);
|
|
10740
10760
|
s && s.resolve();
|
|
10741
10761
|
let c = m.get(a);
|
|
10742
10762
|
return c && clearTimeout(c), new Promise((t) => {
|
|
@@ -10763,15 +10783,15 @@ function hf(e = {}) {
|
|
|
10763
10783
|
function y() {
|
|
10764
10784
|
v ||= setTimeout(() => {
|
|
10765
10785
|
v = null, b();
|
|
10766
|
-
},
|
|
10786
|
+
}, ef);
|
|
10767
10787
|
}
|
|
10768
10788
|
async function b() {
|
|
10769
10789
|
let e = [];
|
|
10770
|
-
await l.scan(
|
|
10790
|
+
await l.scan(uf(t), (t, n) => {
|
|
10771
10791
|
t.endsWith("::__meta__") && e.push(n);
|
|
10772
10792
|
});
|
|
10773
|
-
let n =
|
|
10774
|
-
for (let e of n) await l.clearPrefix(
|
|
10793
|
+
let n = pf(e, r, a);
|
|
10794
|
+
for (let e of n) await l.clearPrefix(cf(t, e.agentId, e.sessionId)), c({
|
|
10775
10795
|
type: "evicted",
|
|
10776
10796
|
agentId: e.agentId,
|
|
10777
10797
|
sessionId: e.sessionId,
|
|
@@ -10782,13 +10802,13 @@ function hf(e = {}) {
|
|
|
10782
10802
|
ready: f,
|
|
10783
10803
|
async listSessions(e) {
|
|
10784
10804
|
let n = [];
|
|
10785
|
-
return await l.scan(
|
|
10805
|
+
return await l.scan(lf(t, e), (e, t) => {
|
|
10786
10806
|
e.endsWith("::__meta__") && n.push(t);
|
|
10787
10807
|
}), n.sort((e, t) => t.lastAccessed - e.lastAccessed);
|
|
10788
10808
|
},
|
|
10789
10809
|
async load(e, n) {
|
|
10790
|
-
let r =
|
|
10791
|
-
return await
|
|
10810
|
+
let r = sf(t, e, n, tf);
|
|
10811
|
+
return await _f(h, r, async () => {
|
|
10792
10812
|
let i = await l.get(r);
|
|
10793
10813
|
if (!i) return;
|
|
10794
10814
|
let a = {
|
|
@@ -10797,8 +10817,8 @@ function hf(e = {}) {
|
|
|
10797
10817
|
todos: [],
|
|
10798
10818
|
memory: ""
|
|
10799
10819
|
};
|
|
10800
|
-
for (let r of
|
|
10801
|
-
let i = await l.get(
|
|
10820
|
+
for (let r of rf) {
|
|
10821
|
+
let i = await l.get(sf(t, e, n, r));
|
|
10802
10822
|
i != null && (a[r] = i);
|
|
10803
10823
|
}
|
|
10804
10824
|
return i.lastAccessed = Date.now(), await l.set(r, i), a;
|
|
@@ -10806,12 +10826,12 @@ function hf(e = {}) {
|
|
|
10806
10826
|
},
|
|
10807
10827
|
async save(e, t, n) {
|
|
10808
10828
|
let r = [];
|
|
10809
|
-
for (let i of
|
|
10829
|
+
for (let i of rf) n[i] !== void 0 && r.push(_(e, t, i, n[i]));
|
|
10810
10830
|
await Promise.all(r);
|
|
10811
10831
|
},
|
|
10812
10832
|
async updateTitle(e, n, r) {
|
|
10813
|
-
let i =
|
|
10814
|
-
return
|
|
10833
|
+
let i = sf(t, e, n, tf);
|
|
10834
|
+
return _f(h, i, async () => {
|
|
10815
10835
|
let e = await l.get(i);
|
|
10816
10836
|
e && (e.title = r, e.lastAccessed = Date.now(), await l.set(i, e));
|
|
10817
10837
|
});
|
|
@@ -10827,13 +10847,13 @@ function hf(e = {}) {
|
|
|
10827
10847
|
})), c({ type: "flush" }), await b();
|
|
10828
10848
|
},
|
|
10829
10849
|
async deleteSession(e, n) {
|
|
10830
|
-
let r =
|
|
10850
|
+
let r = cf(t, e, n);
|
|
10831
10851
|
for (let [e, t] of p.entries()) e.startsWith(r) && (t.resolve(), p.delete(e));
|
|
10832
10852
|
for (let [e, t] of m.entries()) e.startsWith(r) && (clearTimeout(t), m.delete(e));
|
|
10833
10853
|
await l.clearPrefix(r);
|
|
10834
10854
|
},
|
|
10835
10855
|
async createSession(e, n, r) {
|
|
10836
|
-
let i = r ??
|
|
10856
|
+
let i = r ?? qd(), a = Date.now(), o = {
|
|
10837
10857
|
agentId: e,
|
|
10838
10858
|
sessionId: i,
|
|
10839
10859
|
createdAt: a,
|
|
@@ -10841,7 +10861,7 @@ function hf(e = {}) {
|
|
|
10841
10861
|
bytes: 0,
|
|
10842
10862
|
title: n
|
|
10843
10863
|
};
|
|
10844
|
-
return await l.set(
|
|
10864
|
+
return await l.set(sf(t, e, i, tf), o), i;
|
|
10845
10865
|
},
|
|
10846
10866
|
onEvent(e) {
|
|
10847
10867
|
s.add(e);
|
|
@@ -10856,15 +10876,15 @@ function hf(e = {}) {
|
|
|
10856
10876
|
}
|
|
10857
10877
|
//#endregion
|
|
10858
10878
|
//#region src/core/sdk/optionsResolver.ts
|
|
10859
|
-
function
|
|
10860
|
-
return e === void 0 ?
|
|
10879
|
+
function yf(e) {
|
|
10880
|
+
return e === void 0 ? vf({ backend: "memory" }) : e === !1 ? null : typeof e == "string" ? vf({ backend: e }) : e.enabled === !1 ? null : vf(e);
|
|
10861
10881
|
}
|
|
10862
|
-
function
|
|
10882
|
+
function bf(e) {
|
|
10863
10883
|
return e.dialog ?? {};
|
|
10864
10884
|
}
|
|
10865
10885
|
//#endregion
|
|
10866
10886
|
//#region src/core/capabilities.ts
|
|
10867
|
-
var
|
|
10887
|
+
var xf = [
|
|
10868
10888
|
{
|
|
10869
10889
|
name: "dataOps",
|
|
10870
10890
|
defaultOn: !0
|
|
@@ -10957,13 +10977,13 @@ var vf = [
|
|
|
10957
10977
|
defaultOn: !1
|
|
10958
10978
|
}
|
|
10959
10979
|
];
|
|
10960
|
-
function
|
|
10980
|
+
function Sf(e) {
|
|
10961
10981
|
let t = {};
|
|
10962
|
-
for (let n of
|
|
10982
|
+
for (let n of xf) {
|
|
10963
10983
|
let r = e?.[n.name];
|
|
10964
10984
|
t[n.name] = n.defaultOn ? r !== !1 : r === !0;
|
|
10965
10985
|
}
|
|
10966
|
-
for (let e of
|
|
10986
|
+
for (let e of xf) if (e.requires && t[e.name]) {
|
|
10967
10987
|
for (let n of e.requires) if (!t[n]) {
|
|
10968
10988
|
t[e.name] = !1;
|
|
10969
10989
|
break;
|
|
@@ -10973,7 +10993,7 @@ function yf(e) {
|
|
|
10973
10993
|
}
|
|
10974
10994
|
//#endregion
|
|
10975
10995
|
//#region src/core/sdk/events.ts
|
|
10976
|
-
function
|
|
10996
|
+
function Cf(e) {
|
|
10977
10997
|
let t = /* @__PURE__ */ new Set(), n = (n) => {
|
|
10978
10998
|
if (n.type !== "approval_request") {
|
|
10979
10999
|
if (e) try {
|
|
@@ -10999,7 +11019,7 @@ function bf(e) {
|
|
|
10999
11019
|
}
|
|
11000
11020
|
//#endregion
|
|
11001
11021
|
//#region src/core/sdk/contextPreset.ts
|
|
11002
|
-
var
|
|
11022
|
+
var wf = {
|
|
11003
11023
|
auto: {
|
|
11004
11024
|
summaryThresholdRatio: .5,
|
|
11005
11025
|
windowRatio: .4,
|
|
@@ -11027,7 +11047,7 @@ var xf = {
|
|
|
11027
11047
|
enableRecall: !0,
|
|
11028
11048
|
enableLLMSummary: !0
|
|
11029
11049
|
}
|
|
11030
|
-
},
|
|
11050
|
+
}, Tf = {
|
|
11031
11051
|
auto: ["describe_data", "read"],
|
|
11032
11052
|
conservative: ["describe_data"],
|
|
11033
11053
|
aggressive: ["describe_data", "read"],
|
|
@@ -11038,8 +11058,8 @@ var xf = {
|
|
|
11038
11058
|
"search_data"
|
|
11039
11059
|
]
|
|
11040
11060
|
};
|
|
11041
|
-
function
|
|
11042
|
-
let n =
|
|
11061
|
+
function Ef(e, t) {
|
|
11062
|
+
let n = wf[e.contextPreset ?? "auto"] ?? {}, r = e.contextOptions === !1 ? {} : e.contextOptions ?? {};
|
|
11043
11063
|
return {
|
|
11044
11064
|
...n,
|
|
11045
11065
|
...r,
|
|
@@ -11049,7 +11069,7 @@ function Cf(e, t) {
|
|
|
11049
11069
|
}
|
|
11050
11070
|
//#endregion
|
|
11051
11071
|
//#region src/core/sdk/middlewareStack.ts
|
|
11052
|
-
var
|
|
11072
|
+
var Df = {
|
|
11053
11073
|
dataHint: 10,
|
|
11054
11074
|
usageHints: 20,
|
|
11055
11075
|
todos: 30,
|
|
@@ -11066,17 +11086,17 @@ var wf = {
|
|
|
11066
11086
|
subagents: 140,
|
|
11067
11087
|
augmentSystem: 150
|
|
11068
11088
|
};
|
|
11069
|
-
function
|
|
11089
|
+
function Of(e) {
|
|
11070
11090
|
return e.map((e, t) => ({
|
|
11071
11091
|
m: e,
|
|
11072
11092
|
i: t,
|
|
11073
|
-
p:
|
|
11093
|
+
p: Df[e.name] ?? Infinity
|
|
11074
11094
|
})).sort((e, t) => e.p - t.p || e.i - t.i).map((e) => e.m);
|
|
11075
11095
|
}
|
|
11076
11096
|
//#endregion
|
|
11077
11097
|
//#region src/core/tools/fetchDoc.ts
|
|
11078
|
-
var
|
|
11079
|
-
let n = new AbortController(), r = setTimeout(() => n.abort(),
|
|
11098
|
+
var kf = 3e4, Af = [r(async ({ url: e, as: t }) => {
|
|
11099
|
+
let n = new AbortController(), r = setTimeout(() => n.abort(), kf);
|
|
11080
11100
|
try {
|
|
11081
11101
|
let r = await fetch(e, {
|
|
11082
11102
|
method: "GET",
|
|
@@ -11093,7 +11113,7 @@ var Ef = 3e4, Df = [r(async ({ url: e, as: t }) => {
|
|
|
11093
11113
|
].join("\n");
|
|
11094
11114
|
} catch (t) {
|
|
11095
11115
|
let r = t?.message || String(t);
|
|
11096
|
-
return n.signal.aborted ? `获取失败:请求超时(${
|
|
11116
|
+
return n.signal.aborted ? `获取失败:请求超时(${kf}ms,${e})。` : /Failed to fetch|NetworkError|CORS|blocked/i.test(r) ? `获取失败:可能是 CORS 跨域拦截或网络错误(${r})。浏览器仅能 GET 同源或服务端已配置 CORS 的资源;跨域抓取需后端代理。` : `获取失败:${r}`;
|
|
11097
11117
|
} finally {
|
|
11098
11118
|
clearTimeout(r);
|
|
11099
11119
|
}
|
|
@@ -11104,7 +11124,7 @@ var Ef = 3e4, Df = [r(async ({ url: e, as: t }) => {
|
|
|
11104
11124
|
url: t.string().describe("要抓取的 URL(同源或已配 CORS)"),
|
|
11105
11125
|
as: t.enum(["text", "markdown"]).optional().describe("返回格式标签,默认 text")
|
|
11106
11126
|
})
|
|
11107
|
-
})],
|
|
11127
|
+
})], jf = [
|
|
11108
11128
|
"id",
|
|
11109
11129
|
"class",
|
|
11110
11130
|
"href",
|
|
@@ -11116,12 +11136,12 @@ var Ef = 3e4, Df = [r(async ({ url: e, as: t }) => {
|
|
|
11116
11136
|
"aria-label",
|
|
11117
11137
|
"name",
|
|
11118
11138
|
"type"
|
|
11119
|
-
],
|
|
11120
|
-
function
|
|
11139
|
+
], Mf = /^(value|srcdoc|formaction|on\w+)$/i, Nf = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session/i;
|
|
11140
|
+
function Pf(e, t) {
|
|
11121
11141
|
if (!e) return null;
|
|
11122
|
-
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ??
|
|
11142
|
+
let { depth: n, attrs: r, includeText: i = !0 } = t, a = r !== void 0, o = r ?? jf, s = (e) => {
|
|
11123
11143
|
let t = {};
|
|
11124
|
-
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (
|
|
11144
|
+
for (let n of Array.from(e.attributes)) (a ? o.includes(n.name) : o.includes(n.name) || n.name.startsWith("data-")) && (Mf.test(n.name) || Nf.test(n.name) || (t[n.name] = n.value));
|
|
11125
11145
|
return t;
|
|
11126
11146
|
}, c = (e, t) => {
|
|
11127
11147
|
let n = {
|
|
@@ -11137,10 +11157,10 @@ function jf(e, t) {
|
|
|
11137
11157
|
};
|
|
11138
11158
|
return c(e, n);
|
|
11139
11159
|
}
|
|
11140
|
-
var
|
|
11160
|
+
var Ff = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
11141
11161
|
let i = e ? document.querySelector(e) : document.body;
|
|
11142
11162
|
if (!i) return `未找到匹配元素:selector="${e}"`;
|
|
11143
|
-
let a =
|
|
11163
|
+
let a = Pf(i, {
|
|
11144
11164
|
depth: t ?? 3,
|
|
11145
11165
|
attrs: n,
|
|
11146
11166
|
includeText: r ?? !0
|
|
@@ -11155,22 +11175,22 @@ var Mf = r(({ selector: e, depth: t, attrs: n, includeText: r }) => {
|
|
|
11155
11175
|
attrs: t.array(t.string()).optional().describe("属性白名单(传了 = 严格白名单;不传 = 默认常用 + data-*)"),
|
|
11156
11176
|
includeText: t.boolean().optional().describe("是否包含直接文本(默认 true)")
|
|
11157
11177
|
})
|
|
11158
|
-
}),
|
|
11159
|
-
function
|
|
11160
|
-
if (
|
|
11178
|
+
}), If = [Ff], Lf = /* @__PURE__ */ "display.position.visibility.opacity.color.background-color.background-image.font-size.font-weight.line-height.text-align.z-index.overflow.width.height.margin.padding.border.border-radius.box-shadow.transform.transition.animation.cursor.pointer-events.flex-direction.gap.max-width.min-height".split("."), Rf = /* @__PURE__ */ new WeakMap(), zf = !1;
|
|
11179
|
+
function Bf() {
|
|
11180
|
+
if (zf) return;
|
|
11161
11181
|
let e = globalThis.EventTarget;
|
|
11162
11182
|
if (!e?.prototype?.addEventListener) return;
|
|
11163
|
-
|
|
11183
|
+
zf = !0;
|
|
11164
11184
|
let t = e.prototype.addEventListener, n = e.prototype.removeEventListener;
|
|
11165
11185
|
e.prototype.addEventListener = function(e, ...n) {
|
|
11166
11186
|
try {
|
|
11167
|
-
let t =
|
|
11168
|
-
t || (t = /* @__PURE__ */ new Map(),
|
|
11187
|
+
let t = Rf.get(this);
|
|
11188
|
+
t || (t = /* @__PURE__ */ new Map(), Rf.set(this, t)), t.set(String(e), (t.get(String(e)) ?? 0) + 1);
|
|
11169
11189
|
} catch {}
|
|
11170
11190
|
return t.call(this, e, ...n);
|
|
11171
11191
|
}, e.prototype.removeEventListener = function(e, ...t) {
|
|
11172
11192
|
try {
|
|
11173
|
-
let t =
|
|
11193
|
+
let t = Rf.get(this);
|
|
11174
11194
|
if (t) {
|
|
11175
11195
|
let n = (t.get(String(e)) ?? 1) - 1;
|
|
11176
11196
|
n <= 0 ? t.delete(String(e)) : t.set(String(e), n);
|
|
@@ -11179,10 +11199,10 @@ function Lf() {
|
|
|
11179
11199
|
return n.call(this, e, ...t);
|
|
11180
11200
|
};
|
|
11181
11201
|
}
|
|
11182
|
-
function
|
|
11183
|
-
return [...
|
|
11202
|
+
function Vf(e) {
|
|
11203
|
+
return [...Rf.get(e)?.entries() ?? []].filter(([, e]) => e > 0).map(([e]) => e);
|
|
11184
11204
|
}
|
|
11185
|
-
function
|
|
11205
|
+
function Hf(e, t = 12) {
|
|
11186
11206
|
let n = [], r = e, i = 0;
|
|
11187
11207
|
for (; r && r.tagName && i < t;) {
|
|
11188
11208
|
let e = r.tagName.toLowerCase(), t = r.id;
|
|
@@ -11203,7 +11223,7 @@ function zf(e, t = 12) {
|
|
|
11203
11223
|
}
|
|
11204
11224
|
return n.join(" > ");
|
|
11205
11225
|
}
|
|
11206
|
-
function
|
|
11226
|
+
function Uf(e, t, n = {}) {
|
|
11207
11227
|
if (!e) return {
|
|
11208
11228
|
hits: [],
|
|
11209
11229
|
total: 0,
|
|
@@ -11241,7 +11261,7 @@ function Bf(e, t, n = {}) {
|
|
|
11241
11261
|
n = r.slice(Math.max(0, i - 20), i + t.length + 40);
|
|
11242
11262
|
}
|
|
11243
11263
|
return {
|
|
11244
|
-
selector:
|
|
11264
|
+
selector: Hf(e),
|
|
11245
11265
|
tag: e.tagName.toLowerCase(),
|
|
11246
11266
|
text: n.slice(0, 120)
|
|
11247
11267
|
};
|
|
@@ -11250,7 +11270,7 @@ function Bf(e, t, n = {}) {
|
|
|
11250
11270
|
truncated: a.length > o
|
|
11251
11271
|
};
|
|
11252
11272
|
}
|
|
11253
|
-
var
|
|
11273
|
+
var Wf = [
|
|
11254
11274
|
"content",
|
|
11255
11275
|
"display",
|
|
11256
11276
|
"width",
|
|
@@ -11258,14 +11278,14 @@ var Vf = [
|
|
|
11258
11278
|
"background-color",
|
|
11259
11279
|
"position"
|
|
11260
11280
|
];
|
|
11261
|
-
function
|
|
11281
|
+
function Gf(e, t = {}) {
|
|
11262
11282
|
if (!e) return null;
|
|
11263
11283
|
let n = {
|
|
11264
|
-
selector:
|
|
11284
|
+
selector: Hf(e),
|
|
11265
11285
|
tag: e.tagName.toLowerCase(),
|
|
11266
11286
|
attrs: {}
|
|
11267
11287
|
};
|
|
11268
|
-
for (let t of Array.from(e.attributes)) !(
|
|
11288
|
+
for (let t of Array.from(e.attributes)) !(jf.includes(t.name) || t.name.startsWith("data-")) || Mf.test(t.name) || Nf.test(t.name) || (n.attrs[t.name] = t.value);
|
|
11269
11289
|
let r = Array.from(e.childNodes).filter((e) => e.nodeType === 3).map((e) => e.textContent || "").join("").trim();
|
|
11270
11290
|
r && (n.text = r.slice(0, 400));
|
|
11271
11291
|
let i = String(e.innerText ?? e.textContent ?? "").trim();
|
|
@@ -11287,7 +11307,7 @@ function Hf(e, t = {}) {
|
|
|
11287
11307
|
if (typeof a != "function") return r;
|
|
11288
11308
|
try {
|
|
11289
11309
|
let i = a(e, n ?? null);
|
|
11290
|
-
for (let e of n ?
|
|
11310
|
+
for (let e of n ? Wf : t.styles ?? Lf) {
|
|
11291
11311
|
let t = typeof i.getPropertyValue == "function" ? i.getPropertyValue(e) : i[e];
|
|
11292
11312
|
t && (r[e] = String(t).slice(0, 200));
|
|
11293
11313
|
}
|
|
@@ -11305,16 +11325,16 @@ function Hf(e, t = {}) {
|
|
|
11305
11325
|
n.events = {
|
|
11306
11326
|
inline: t,
|
|
11307
11327
|
vue: r ? Object.keys(r).filter((e) => /^on[A-Z]/.test(e)).map((e) => e.slice(2).toLowerCase()) : [],
|
|
11308
|
-
captured:
|
|
11328
|
+
captured: Vf(e)
|
|
11309
11329
|
};
|
|
11310
11330
|
}
|
|
11311
11331
|
return n;
|
|
11312
11332
|
}
|
|
11313
|
-
var
|
|
11314
|
-
|
|
11333
|
+
var Kf = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
11334
|
+
Bf();
|
|
11315
11335
|
let i = r ? document.querySelector(r) : document;
|
|
11316
11336
|
if (r && !i) return `未找到 root 元素:selector="${r}"`;
|
|
11317
|
-
let a =
|
|
11337
|
+
let a = Uf(i, e, {
|
|
11318
11338
|
mode: t,
|
|
11319
11339
|
limit: n
|
|
11320
11340
|
});
|
|
@@ -11331,11 +11351,11 @@ var Uf = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11331
11351
|
limit: t.number().int().min(1).max(20).optional().describe("返回上限(默认 10)"),
|
|
11332
11352
|
root: t.string().optional().describe("限定搜索范围的容器选择器(默认整页)")
|
|
11333
11353
|
})
|
|
11334
|
-
}),
|
|
11335
|
-
|
|
11354
|
+
}), qf = r(({ selector: e, styles: t, includeHtml: n, htmlLimit: r, includeEvents: i, includeRect: a, pseudo: o }) => {
|
|
11355
|
+
Bf();
|
|
11336
11356
|
let s = document.querySelector(e);
|
|
11337
11357
|
if (!s) return `未找到匹配元素:selector="${e}"(可先用 dom_search 定位)`;
|
|
11338
|
-
let c =
|
|
11358
|
+
let c = Gf(s, {
|
|
11339
11359
|
styles: t,
|
|
11340
11360
|
includeHtml: n,
|
|
11341
11361
|
htmlLimit: r,
|
|
@@ -11356,7 +11376,7 @@ var Uf = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11356
11376
|
includeRect: t.boolean().optional().describe("是否含几何位置(默认 true)"),
|
|
11357
11377
|
pseudo: t.boolean().optional().describe("是否含 ::before/::after 伪元素摘要(默认 false)")
|
|
11358
11378
|
})
|
|
11359
|
-
}),
|
|
11379
|
+
}), Jf = {
|
|
11360
11380
|
name: "dom-inspect",
|
|
11361
11381
|
description: "页面 DOM 深度检视工具(dom_search 搜索元素 / dom_info 读内容·计算样式·事件绑定·几何)。定位元素、验证样式落地、排查交互绑定时加载",
|
|
11362
11382
|
getContent: () => [
|
|
@@ -11373,15 +11393,15 @@ var Uf = r(({ query: e, mode: t, limit: n, root: r }) => {
|
|
|
11373
11393
|
"## 排障套路",
|
|
11374
11394
|
"1. dom_search(mode:\"text\", query:按钮文案) 定位 → 2. dom_info(styles:[\"display\",\"background-color\",\"pointer-events\"]) 验证样式/点击性 → 3. 不符则改数据(get_dom 看结构对照)"
|
|
11375
11395
|
].join("\n"),
|
|
11376
|
-
tools: [() => [
|
|
11396
|
+
tools: [() => [Kf, qf]]
|
|
11377
11397
|
};
|
|
11378
11398
|
//#endregion
|
|
11379
11399
|
//#region src/core/tools/envTool.ts
|
|
11380
|
-
function
|
|
11400
|
+
function Yf(e) {
|
|
11381
11401
|
let t = e;
|
|
11382
11402
|
return typeof t.tagName == "string" || typeof t.nodeType == "number" && typeof t.nodeName == "string";
|
|
11383
11403
|
}
|
|
11384
|
-
function
|
|
11404
|
+
function Xf(e, t = 3, n = 2e3, r, i) {
|
|
11385
11405
|
if (e == null) return e;
|
|
11386
11406
|
if (typeof e == "string") return e.length > n ? e.slice(0, n) + "…(已截断)" : e;
|
|
11387
11407
|
if (typeof e == "number" || typeof e == "boolean") return e;
|
|
@@ -11390,14 +11410,14 @@ function qf(e, t = 3, n = 2e3, r, i) {
|
|
|
11390
11410
|
if (typeof e == "bigint") return `${e.toString()}n`;
|
|
11391
11411
|
if (typeof e != "object") return String(e);
|
|
11392
11412
|
let a = e;
|
|
11393
|
-
if (
|
|
11413
|
+
if (Yf(a)) {
|
|
11394
11414
|
let e = a;
|
|
11395
11415
|
return e.tagName ? `[Element: <${e.tagName.toLowerCase()}>]` : `[Node: ${e.nodeName}]`;
|
|
11396
11416
|
}
|
|
11397
11417
|
if (r?.has(a)) return "[Circular]";
|
|
11398
11418
|
let o = r ?? /* @__PURE__ */ new WeakSet();
|
|
11399
11419
|
if (o.add(a), Array.isArray(e)) {
|
|
11400
|
-
let r = e.slice(0, 100).map((e) =>
|
|
11420
|
+
let r = e.slice(0, 100).map((e) => Xf(e, t - 1, n, o, i));
|
|
11401
11421
|
return e.length > 100 && r.push(`…(共 ${e.length} 项,已截断)`), r;
|
|
11402
11422
|
}
|
|
11403
11423
|
if (t < 0) return "(对象,已截断)";
|
|
@@ -11410,14 +11430,14 @@ function qf(e, t = 3, n = 2e3, r, i) {
|
|
|
11410
11430
|
}
|
|
11411
11431
|
try {
|
|
11412
11432
|
let e = a[r];
|
|
11413
|
-
i?.test(r) ? s[r] = "[REDACTED]" : s[r] =
|
|
11433
|
+
i?.test(r) ? s[r] = "[REDACTED]" : s[r] = Xf(e, t - 1, n, o, i);
|
|
11414
11434
|
} catch {
|
|
11415
11435
|
s[r] = "(getter 抛错)";
|
|
11416
11436
|
}
|
|
11417
11437
|
}
|
|
11418
11438
|
return s;
|
|
11419
11439
|
}
|
|
11420
|
-
function
|
|
11440
|
+
function Zf(e) {
|
|
11421
11441
|
let t = e ?? (typeof window < "u" ? window : {}), n = t.navigator, r = t.location, i = t.document;
|
|
11422
11442
|
return {
|
|
11423
11443
|
location: {
|
|
@@ -11450,9 +11470,9 @@ function Jf(e) {
|
|
|
11450
11470
|
} : "(无 document)"
|
|
11451
11471
|
};
|
|
11452
11472
|
}
|
|
11453
|
-
var
|
|
11473
|
+
var Qf = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|opener|parent|top|self|window|globalThis|closed|history|navigation|trustedTypes|origin|crossOriginIsolated)$/, $f = /token|secret|password|passwd|api[-_]?key|auth|cred|csrf|session|ticket/i, ep = r(({ key: e }) => {
|
|
11454
11474
|
if (e) {
|
|
11455
|
-
if (
|
|
11475
|
+
if (Qf.test(e) || $f.test(e)) return JSON.stringify({
|
|
11456
11476
|
key: e,
|
|
11457
11477
|
denied: !0,
|
|
11458
11478
|
reason: "安全:该 key 在 denylist(localStorage/sessionStorage/cookie/document 或敏感命名 token/secret/key/auth),不读取防泄漏"
|
|
@@ -11462,18 +11482,18 @@ var Yf = /^(localStorage|sessionStorage|cookie|document|frames|frameElement|open
|
|
|
11462
11482
|
key: e,
|
|
11463
11483
|
exists: t !== void 0,
|
|
11464
11484
|
type: typeof t,
|
|
11465
|
-
value:
|
|
11485
|
+
value: Xf(t, 3, 2e3, void 0, $f)
|
|
11466
11486
|
}, null, 2);
|
|
11467
11487
|
}
|
|
11468
|
-
return JSON.stringify(
|
|
11488
|
+
return JSON.stringify(Zf(), null, 2);
|
|
11469
11489
|
}, {
|
|
11470
11490
|
name: "inspect_env",
|
|
11471
11491
|
description: "读宿主页面环境信息(排查调试)。不传参返回摘要(URL/origin、浏览器/语言、viewport、title/readyState);传 key 读指定 window 属性值(如 key:\"appConfig\")。只读,大结果自动外存 vfs。",
|
|
11472
11492
|
schema: t.object({ key: t.string().optional().describe("要读取的 window 属性名(如 \"appConfig\"/\"__DEBUG__\");不传 = 返回环境摘要") })
|
|
11473
|
-
}),
|
|
11493
|
+
}), tp = [ep];
|
|
11474
11494
|
//#endregion
|
|
11475
11495
|
//#region src/core/harness/budget.ts
|
|
11476
|
-
function
|
|
11496
|
+
function np(e, t, n) {
|
|
11477
11497
|
let r = 0;
|
|
11478
11498
|
return {
|
|
11479
11499
|
name: "budget",
|
|
@@ -11498,12 +11518,12 @@ function $f(e, t, n) {
|
|
|
11498
11518
|
}
|
|
11499
11519
|
//#endregion
|
|
11500
11520
|
//#region src/core/sdk/actions.ts
|
|
11501
|
-
var
|
|
11502
|
-
function
|
|
11521
|
+
var rp = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
11522
|
+
function ip(e) {
|
|
11503
11523
|
let n = [];
|
|
11504
11524
|
for (let [i, a] of Object.entries(e)) {
|
|
11505
|
-
if (!
|
|
11506
|
-
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${
|
|
11525
|
+
if (!rp.test(i)) {
|
|
11526
|
+
console.warn(`[page-agent-sdk][actions] 动作名 "${i}" 非法(须匹配 ${rp}),已跳过`);
|
|
11507
11527
|
continue;
|
|
11508
11528
|
}
|
|
11509
11529
|
let e = a.description || `宿主动作 ${i}`;
|
|
@@ -11523,9 +11543,9 @@ function tp(e) {
|
|
|
11523
11543
|
}
|
|
11524
11544
|
return n;
|
|
11525
11545
|
}
|
|
11526
|
-
function
|
|
11546
|
+
function ap(e) {
|
|
11527
11547
|
let t = {};
|
|
11528
|
-
for (let [n, r] of Object.entries(e))
|
|
11548
|
+
for (let [n, r] of Object.entries(e)) rp.test(n) && (t[n] = {
|
|
11529
11549
|
description: r.description,
|
|
11530
11550
|
hasParams: !!r.params
|
|
11531
11551
|
});
|
|
@@ -11533,12 +11553,12 @@ function np(e) {
|
|
|
11533
11553
|
}
|
|
11534
11554
|
//#endregion
|
|
11535
11555
|
//#region src/core/toolsets.ts
|
|
11536
|
-
var
|
|
11537
|
-
function
|
|
11538
|
-
return
|
|
11556
|
+
var op = Af, sp = If;
|
|
11557
|
+
function cp(e, t) {
|
|
11558
|
+
return Gu(e, t);
|
|
11539
11559
|
}
|
|
11540
|
-
function
|
|
11541
|
-
let a =
|
|
11560
|
+
function lp(e, t, n, r, i) {
|
|
11561
|
+
let a = Sf(e);
|
|
11542
11562
|
return [
|
|
11543
11563
|
...a.dataOps ? t : [],
|
|
11544
11564
|
...a.fetch ? n : [],
|
|
@@ -11548,7 +11568,7 @@ function op(e, t, n, r, i) {
|
|
|
11548
11568
|
}
|
|
11549
11569
|
//#endregion
|
|
11550
11570
|
//#region src/core/sdk/toolRegistry.ts
|
|
11551
|
-
function
|
|
11571
|
+
function up(e) {
|
|
11552
11572
|
let t = /* @__PURE__ */ new Map(), n = [];
|
|
11553
11573
|
for (let r of e) for (let e of r.tools) {
|
|
11554
11574
|
let i = t.get(e.name);
|
|
@@ -11568,15 +11588,15 @@ function sp(e) {
|
|
|
11568
11588
|
}
|
|
11569
11589
|
//#endregion
|
|
11570
11590
|
//#region src/core/harness/usageHints.ts
|
|
11571
|
-
var
|
|
11572
|
-
function
|
|
11573
|
-
let r =
|
|
11591
|
+
var dp = .7;
|
|
11592
|
+
function fp(e, t, n) {
|
|
11593
|
+
let r = Sf(e);
|
|
11574
11594
|
return {
|
|
11575
11595
|
name: "usageHints",
|
|
11576
11596
|
augmentPrompt: (i) => {
|
|
11577
11597
|
let a = [];
|
|
11578
11598
|
if (r.planning && (a.push("【自适应规划】按任务复杂度决定是否先规划,不要对简单任务过度编排:"), a.push(" · 简单/明确任务(改单字段、调样式、查值)→ 直接 read/write 执行,不必 write_todos。"), a.push(" · 复杂任务(多步、大改、有歧义、不可逆)→ 先 write_todos 拆解,首个任务标 in_progress,逐项推进。"), a.push(" · 执行中发现步骤要改/补/细分 → 用 update_todo({id, content?, status?}) 按 id 增量改单项,不必重传整个清单。"), a.push(" · update_todo 标 completed 时附 evidence: 本次实际写入的 jsonPath(如 \"components.2\"),供收口对账;工作经委派子 agent 完成等无主写路径时,如实写明完成方式(勿编造路径)。"), e?.humanConfirm ? a.push(" · 规划出多步方案若需用户拍板 → 先 request_human_confirmation 给方案选项,确认后再执行。") : a.push(" · 规划出多步方案若需用户拍板 → 以文字列出方案选项等用户回复,勿自行拍板。"), a.push(" · 计划修订有次数上限(maxPlanRevisions,默认 5,只计 write_todos 调用、调研轮不计):勿反复改计划而不执行,规划充分后即开始 write 落地。")), t && (a.push("改主数据前先 get_data({jsonPath}) 读其当前真实值(返回末尾 hash=xxx 为乐观锁标识),基于真实值改,不要凭记忆。写入是否被自动校验由集成方 conflictWatchFields 声明决定:若已声明且主数据在你 read 之后被外部改过,会触发冲突——集成方若开启人工介入,工具会挂起等用户决定(保留外部/强制覆盖/回退),你应等待工具返回后按结果继续(保留外部→重新 get 再改;强制覆盖→已写入,继续;回退→已回退到历史快照,基于回退值重写);未开启人工介入时返回 VERSION_CONFLICT 不写入,重新 get 拿最新值再改。"), a.push("不确定主数据字段结构时用 describe_data 查看说明。"), a.push("修改大对象/数组优先用 edit_data 增量 patch(只发改动部分),避免 set_data 整体重传被 max_tokens 截断导致 JSON 不完整、校验失败。"), a.push("修改主数据出错时可用 restore_data 回退最近一次。"), a.push("在大数组里按条件筛选元素用 query_data(JSONPath,如 $.components[?(@.type==\"card\" && @.price<100)]),返回匹配元素的 path/index;定位后再 edit_data 改。"), a.push("找名字记不清的元素用 search_data(支持 substring/regex/fuzzy 模糊搜索)。"), a.push("需要过滤/映射/聚合/批量重写大数组时用 eval_script(沙箱脚本,入参 data);只读探查用 mode=query,批量重写用 mode=transform(返回值经校验后落地)。"), a.push("读大数组用 read({jsonPath,offset,limit}) 分页(返回 hasMore=true 时 offset+=limit 续读);一次读多个不相关子路径用 read({jsonPaths});复杂改动先 write({...,dryRun:true}) 预检不落盘。"), a.push("【省轮次·批量】读多个同构子路径(如各组件 props)用 read({jsonPaths:[...]}) 一次取回,勿发多个独立 read;改多处用 write({patches:[{op:\"set\",jsonPath,value},...]}) 一次提交多改动(原子任一失败回滚),勿逐个 edit_data/write 烧轮次预算。"), a.push("对比当前与历史快照(或一段 JSON against)的差异用 diff_data({snapshotId?,against?})(返回结构化 path→from/to,verify 自纠/操作审计/\"刚才改了啥\");只读查历史快照值用 history_data({id?,jsonPath?})。")), r.subagent && a.push("独立子任务可 spawn_agent 委派(过程隔离,不占主上下文):默认只读,需要子 agent 写数据时传 writablePaths(路径前缀白名单,越界 PATH_OUT_OF_SCOPE)。多个独立子任务可 spawn_agents 并行委派(各子互不通信,结论由你汇总;并行委派不可授写权限,写操作由你收尾执行)。"), r.inspectEnv && a.push("排查页面环境(当前 URL/浏览器/视口/集成方调试变量)用 inspect_env——不传参返回环境摘要(location/navigator/viewport/document),传 key 读特定 window 属性(如 inspect_env({key:\"appConfig\"}) 读 window.appConfig)。改完数据看渲染、定位\"为何没生效\"时用它(只读,不改数据)。"), r.domInspect && a.push("改完数据想确认渲染是否生效(或定位元素/辅助 UI 设计问答)用 get_dom({selector?,depth?}) 读渲染后 DOM(结构化返回 tag/attrs/text/children,depth 控制深度防爆炸,只读)。配合宿主 actions(save_draft/publish 等)形成\"改数据→get_dom 看渲染→触发动作\"闭环。"), r.draftWrite && (a.push("生成超大 JSON(如 50+ 组件页面,单次 write 受 max_tokens 限制装不下)用 draft_write 分块构建 → draft_commit 原子提交:draft_write({draftId, chunk, mode}) mode:\"start\" 新建/\"append\" 追加(拼 JSON 片段到 drafts 池);累积完 draft_commit({draftId}) 合并 + schema 校验 + 写主数据(失败草稿保留可修后重试,成功自动清草稿)。小改仍用 write patch,只在大 JSON 从零生成时用 draft。"), a.push("⚠️ 大 JSON 分块构建是典型多轮工具调用(draft_write×N + draft_commit + read 确认 + 调研 read/query),默认 maxToolRounds=30(3.43 起;轮次预算吃紧时 system 会注入预算提示段,按提示优先收口);目标组件数很大时集成方仍可在 createChatSdk 显式上调 maxToolRounds(按 N+10 估算)。draft_commit 提交同样走乐观锁(改前 read 拿 hash,bind 被改过会触发冲突介入,不静默覆盖)。")), r.todoDeps && a.push("复杂任务可用 todos 层级依赖:write_todos 时给 todo 传 parentId(父任务 id,表达层级)+ deps(依赖的 todo id 数组,必须先完成)。有依赖的任务,deps 全 completed 后再标 in_progress;完成时 update_todo({id, status:\"completed\", evidence:\"完成证据\"}) 记证据。无依赖关系的任务不传 parentId/deps(扁平)。"), r.focus && (a.push("【上下文聚焦】判断任务范围,用 set_focus/add_focus/remove_focus/clear_focus 自动收敛工作范围:"), a.push(" · 局部任务(只改某一组件/区域,如「调导航栏」「改 components.3 样式」)→ 先 read 定位 jsonPath,再 set_focus({path:\"该子树路径\"}) 聚焦;聚焦后每轮只看该子树结构,写其他位置会被 PATH_DENIED 拒绝。"), a.push(" · 多个相关组件(如「同时改导航栏和页脚」)→ set_focus 聚焦首个后用 add_focus({path}) 追加其余;聚焦后可写任一焦点子树,越界仍被拒;移除单个用 remove_focus({path})。"), a.push(" · 全局任务(多处/整体结构,如「重排所有组件」「换主题」)→ 不要聚焦,保持全量视野直接写。"), a.push(" · 完成局部精修、要转向其他区域或做整体改动 → 调 clear_focus 退出聚焦(清空全部焦点),恢复全部读写权限。"), a.push(" · set_focus/add_focus 的 path 必须在 schema 内(类型校验);不确定路径先 read/describe_data 查。")), e?.subagents?.length) {
|
|
11579
|
-
let t = e.subagents.filter((e) => (e.temperature ?? 0) >=
|
|
11599
|
+
let t = e.subagents.filter((e) => (e.temperature ?? 0) >= dp || /规划|创意|设计|方案|brainstorm|plan/i.test(e.description)), n = e.subagents.filter((e) => (e.temperature ?? 0) < dp && /反思|审查|挑刺|校验|review|critique|reflect/i.test(e.description));
|
|
11580
11600
|
a.push("【规划-反思-执行·路由】按任务性质选模式,不要对简单任务过度编排:"), t.length && (a.push(` · 创作/设计/开放性需求(如"设计主题风格""换个感觉")→ 先调 ${t.map((e) => "use_" + e.id).join("/")} 出 2-3 套方案(高温创意),`), a.push(e?.humanConfirm ? " 不要自己拍板;拿到方案后,若需用户拍板用 request_human_confirmation 弹选项。" : " 不要自己拍板;拿到方案后以文字列出选项等用户回复(humanConfirm 未开,勿调不存在工具)。")), n.length && a.push(` · 严谨/易错/校验类 → 可先调 ${n.map((e) => "use_" + e.id).join("/")} 反思挑刺(低温审查),据反馈修订。`), a.push(" · 方案定稿后,由你(主 agent)用 edit_data 落地成 JSON(低温度执行 + schema 校验 + 写前确认)。"), a.push(" · 简单/明确任务(如\"标题改红色\")直接执行,不必走规划-反思。");
|
|
11581
11601
|
}
|
|
11582
11602
|
e?.humanConfirm && (a.push("【人工确认·必读】以下情形必须先调 request_human_confirmation 征询用户、拿到答复后再继续,不要自行拍板:"), a.push(" 1) 用户让你「给方案/列选项/我来选/挑一个」时:把每个方案作为一个 option,调 request_human_confirmation(question=简述, options=[方案A,方案B,...], recommendation=你推荐的)。不要只回文字罗列方案让用户自己回复——要用工具把选项做成可点选按钮。"), a.push(" 2) 需求有歧义/不确定时:调工具问清楚(options 不传则用户答同意或拒绝)。"), a.push(" 3) 即将执行高风险不可逆操作(删除/覆盖/批量改动)前:调工具确认。"), a.push(" 4) 规划出多步方案需用户确认时:把整个方案(或关键分步)作为 option 调 request_human_confirmation,确认后再执行。"), a.push("用户在选项里选了哪个,就按那个方案继续;选「拒绝」则停止并询问如何调整。"));
|
|
@@ -11596,7 +11616,7 @@ function lp(e, t, n) {
|
|
|
11596
11616
|
}
|
|
11597
11617
|
//#endregion
|
|
11598
11618
|
//#region src/core/harness/resourcesPin.ts
|
|
11599
|
-
function
|
|
11619
|
+
function pp(e) {
|
|
11600
11620
|
return {
|
|
11601
11621
|
name: "resourcesPin",
|
|
11602
11622
|
augmentPrompt: () => {
|
|
@@ -11610,102 +11630,102 @@ function up(e) {
|
|
|
11610
11630
|
}
|
|
11611
11631
|
//#endregion
|
|
11612
11632
|
//#region src/core/backends/skillStore.ts
|
|
11613
|
-
var
|
|
11614
|
-
function
|
|
11615
|
-
return `${
|
|
11633
|
+
var mp = "v:1::skill-store", hp = "chat-sdk";
|
|
11634
|
+
function gp(e, t, n) {
|
|
11635
|
+
return `${mp}::${e}::${t}::${n}`;
|
|
11616
11636
|
}
|
|
11617
|
-
function
|
|
11618
|
-
return `${
|
|
11637
|
+
function _p(e, t) {
|
|
11638
|
+
return `${mp}::${e}::${t}::`;
|
|
11619
11639
|
}
|
|
11620
|
-
function
|
|
11621
|
-
let t = e.dbName ??
|
|
11640
|
+
function vp(e = {}) {
|
|
11641
|
+
let t = e.dbName ?? hp, n = e.backend ?? "indexed", r = e.id ?? "", i, a, o = new Promise((e) => {
|
|
11622
11642
|
a = e;
|
|
11623
11643
|
});
|
|
11624
11644
|
return (async () => {
|
|
11625
11645
|
try {
|
|
11626
11646
|
if (n === "indexed") {
|
|
11627
11647
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
11628
|
-
i = await
|
|
11648
|
+
i = await hf(t), a(!0);
|
|
11629
11649
|
} else if (n === "session") {
|
|
11630
11650
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
11631
|
-
i =
|
|
11651
|
+
i = gf(sessionStorage), a(!0);
|
|
11632
11652
|
} else if (n === "local") {
|
|
11633
11653
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
11634
|
-
i =
|
|
11635
|
-
} else i =
|
|
11654
|
+
i = gf(localStorage), a(!0);
|
|
11655
|
+
} else i = mf(), a(!1);
|
|
11636
11656
|
} catch {
|
|
11637
|
-
i =
|
|
11657
|
+
i = mf(), a(!1);
|
|
11638
11658
|
}
|
|
11639
11659
|
})(), {
|
|
11640
11660
|
ready: o,
|
|
11641
11661
|
async list() {
|
|
11642
11662
|
let e = [];
|
|
11643
|
-
return await i.scan(
|
|
11663
|
+
return await i.scan(_p(t, r), (t, n) => {
|
|
11644
11664
|
e.push(n);
|
|
11645
11665
|
}), e;
|
|
11646
11666
|
},
|
|
11647
11667
|
async get(e) {
|
|
11648
|
-
return await i.get(
|
|
11668
|
+
return await i.get(gp(t, r, e));
|
|
11649
11669
|
},
|
|
11650
11670
|
async put(e) {
|
|
11651
11671
|
try {
|
|
11652
|
-
await i.set(
|
|
11672
|
+
await i.set(gp(t, r, e.name), e);
|
|
11653
11673
|
} catch (e) {
|
|
11654
|
-
|
|
11674
|
+
of(e) && (i = mf());
|
|
11655
11675
|
}
|
|
11656
11676
|
},
|
|
11657
11677
|
async remove(e) {
|
|
11658
|
-
let n =
|
|
11678
|
+
let n = gp(t, r, e);
|
|
11659
11679
|
return await i.get(n) == null ? !1 : (await i.del(n), !0);
|
|
11660
11680
|
},
|
|
11661
11681
|
async clear() {
|
|
11662
|
-
await i.clearPrefix(
|
|
11682
|
+
await i.clearPrefix(_p(t, r));
|
|
11663
11683
|
},
|
|
11664
11684
|
dispose() {}
|
|
11665
11685
|
};
|
|
11666
11686
|
}
|
|
11667
11687
|
//#endregion
|
|
11668
11688
|
//#region src/core/backends/preferenceStore.ts
|
|
11669
|
-
var
|
|
11689
|
+
var yp = [
|
|
11670
11690
|
"color",
|
|
11671
11691
|
"copy",
|
|
11672
11692
|
"layout",
|
|
11673
11693
|
"interaction",
|
|
11674
11694
|
"tech",
|
|
11675
11695
|
"other"
|
|
11676
|
-
],
|
|
11677
|
-
function
|
|
11678
|
-
return `${
|
|
11696
|
+
], bp = "v:1::pref-store", xp = "chat-sdk";
|
|
11697
|
+
function Sp(e, t, n) {
|
|
11698
|
+
return `${bp}::${e}::${t}::${n}`;
|
|
11679
11699
|
}
|
|
11680
|
-
function
|
|
11681
|
-
return `${
|
|
11700
|
+
function Cp(e, t) {
|
|
11701
|
+
return `${bp}::${e}::${t}::`;
|
|
11682
11702
|
}
|
|
11683
|
-
function
|
|
11703
|
+
function wp() {
|
|
11684
11704
|
return `pref-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
11685
11705
|
}
|
|
11686
|
-
function
|
|
11687
|
-
let t = e.dbName ??
|
|
11706
|
+
function Tp(e = {}) {
|
|
11707
|
+
let t = e.dbName ?? xp, n = e.backend ?? "indexed", r = e.id ?? "", i = e.maxEntries ?? 20, a, o, s = new Promise((e) => {
|
|
11688
11708
|
o = e;
|
|
11689
11709
|
});
|
|
11690
11710
|
(async () => {
|
|
11691
11711
|
try {
|
|
11692
11712
|
if (n === "indexed") {
|
|
11693
11713
|
if (typeof indexedDB > "u") throw Error("indexedDB 不可用");
|
|
11694
|
-
a = await
|
|
11714
|
+
a = await hf(t), o(!0);
|
|
11695
11715
|
} else if (n === "session") {
|
|
11696
11716
|
if (typeof sessionStorage > "u") throw Error("sessionStorage 不可用");
|
|
11697
|
-
a =
|
|
11717
|
+
a = gf(sessionStorage), o(!0);
|
|
11698
11718
|
} else if (n === "local") {
|
|
11699
11719
|
if (typeof localStorage > "u") throw Error("localStorage 不可用");
|
|
11700
|
-
a =
|
|
11701
|
-
} else a =
|
|
11720
|
+
a = gf(localStorage), o(!0);
|
|
11721
|
+
} else a = mf(), o(!1);
|
|
11702
11722
|
} catch {
|
|
11703
|
-
a =
|
|
11723
|
+
a = mf(), o(!1);
|
|
11704
11724
|
}
|
|
11705
11725
|
})();
|
|
11706
11726
|
async function c() {
|
|
11707
11727
|
let e = [];
|
|
11708
|
-
return await a.scan(
|
|
11728
|
+
return await a.scan(Cp(t, r), (t, n) => {
|
|
11709
11729
|
e.push(n);
|
|
11710
11730
|
}), e;
|
|
11711
11731
|
}
|
|
@@ -11716,7 +11736,7 @@ function Sp(e = {}) {
|
|
|
11716
11736
|
},
|
|
11717
11737
|
async put(e) {
|
|
11718
11738
|
let n = await c(), o = Date.now(), s = n.reduce((e, t) => Math.max(e, t.updatedAt), 0), l = n.find((t) => t.topic === e.topic), u = {
|
|
11719
|
-
id: e.id ?? l?.id ??
|
|
11739
|
+
id: e.id ?? l?.id ?? wp(),
|
|
11720
11740
|
content: e.content,
|
|
11721
11741
|
topic: e.topic,
|
|
11722
11742
|
sourceSessionId: l?.sourceSessionId ?? e.sourceSessionId,
|
|
@@ -11724,71 +11744,71 @@ function Sp(e = {}) {
|
|
|
11724
11744
|
createdAt: l?.createdAt ?? o,
|
|
11725
11745
|
updatedAt: Math.max(o, s + 1)
|
|
11726
11746
|
};
|
|
11727
|
-
l && l.id !== u.id && await a.del(
|
|
11747
|
+
l && l.id !== u.id && await a.del(Sp(t, r, l.id));
|
|
11728
11748
|
try {
|
|
11729
|
-
await a.set(
|
|
11749
|
+
await a.set(Sp(t, r, u.id), u);
|
|
11730
11750
|
} catch (e) {
|
|
11731
|
-
|
|
11751
|
+
of(e) && (a = mf(), await a.set(Sp(t, r, u.id), u));
|
|
11732
11752
|
}
|
|
11733
11753
|
let d = await c();
|
|
11734
11754
|
if (d.length > i) {
|
|
11735
11755
|
let e = d.sort((e, t) => e.updatedAt - t.updatedAt).slice(0, d.length - i);
|
|
11736
|
-
for (let n of e) await a.del(
|
|
11756
|
+
for (let n of e) await a.del(Sp(t, r, n.id));
|
|
11737
11757
|
}
|
|
11738
11758
|
return u;
|
|
11739
11759
|
},
|
|
11740
11760
|
async remove(e) {
|
|
11741
|
-
let n =
|
|
11761
|
+
let n = Sp(t, r, e);
|
|
11742
11762
|
return await a.get(n) == null ? !1 : (await a.del(n), !0);
|
|
11743
11763
|
},
|
|
11744
11764
|
async clear() {
|
|
11745
|
-
await a.clearPrefix(
|
|
11765
|
+
await a.clearPrefix(Cp(t, r));
|
|
11746
11766
|
},
|
|
11747
11767
|
dispose() {}
|
|
11748
11768
|
};
|
|
11749
11769
|
}
|
|
11750
11770
|
//#endregion
|
|
11751
11771
|
//#region src/core/harness/preferences.ts
|
|
11752
|
-
var
|
|
11772
|
+
var Ep = {
|
|
11753
11773
|
color: "颜色",
|
|
11754
11774
|
copy: "文案",
|
|
11755
11775
|
layout: "排版",
|
|
11756
11776
|
interaction: "交互",
|
|
11757
11777
|
tech: "技术",
|
|
11758
11778
|
other: "其他"
|
|
11759
|
-
},
|
|
11779
|
+
}, Dp = [
|
|
11760
11780
|
/^(?:请|帮我|麻烦)?你?记住[::,,、]?\s*(.{4,200})/,
|
|
11761
11781
|
/^(?:从)?今后(?:开始|起)?[::,,]?\s*(.{4,200})/,
|
|
11762
11782
|
/^以后(?:都|全都|总是|尽量)?[::,,]?\s*(.{4,200})/
|
|
11763
|
-
],
|
|
11783
|
+
], Op = /(?:不要|别再|别用|别加|太(?:艳|花|亮|暗|大|小|密|挤|乱|复杂|素|少)|不喜欢|讨厌|希望|更喜欢|偏好|永远|一律|统一保持|保持统一)/, kp = [
|
|
11764
11784
|
["layout", /布局|排版|间距|留白|密度|居中|对齐|栅格|边距|紧凑|圆角|分栏|层级|大小|尺寸/],
|
|
11765
11785
|
["copy", /文案|文字|标题|副标题|字体|字号|措辞|语气|口语|书面|简洁|简短|详尽|emoji|表情/],
|
|
11766
11786
|
["interaction", /动画|动效|过渡|交互|悬停|hover|点击反馈|弹窗|提示|加载|滚动/],
|
|
11767
11787
|
["tech", /代码|框架|组件|技术|写法|命名|注释|依赖|版本|接口/],
|
|
11768
11788
|
["color", /颜色|配色|色调|色彩|深色|浅色|饱和|渐变|紫|红|橙|黄|绿|青|蓝|粉|棕|灰|黑|白|金|银/]
|
|
11769
11789
|
];
|
|
11770
|
-
function
|
|
11771
|
-
for (let [t, n] of
|
|
11790
|
+
function Ap(e) {
|
|
11791
|
+
for (let [t, n] of kp) if (n.test(e)) return t;
|
|
11772
11792
|
return "other";
|
|
11773
11793
|
}
|
|
11774
|
-
function
|
|
11794
|
+
function jp(e) {
|
|
11775
11795
|
let t = e.trim();
|
|
11776
|
-
if (!(!t || t.length > 500)) for (let e of
|
|
11796
|
+
if (!(!t || t.length > 500)) for (let e of Dp) {
|
|
11777
11797
|
let n = t.match(e);
|
|
11778
11798
|
if (n?.[1]) {
|
|
11779
11799
|
let e = n[1].trim().replace(/[。.!!]+$/, "");
|
|
11780
11800
|
return e.length < 3 ? void 0 : {
|
|
11781
11801
|
content: e,
|
|
11782
|
-
topic:
|
|
11802
|
+
topic: Ap(e)
|
|
11783
11803
|
};
|
|
11784
11804
|
}
|
|
11785
11805
|
}
|
|
11786
11806
|
}
|
|
11787
|
-
function
|
|
11807
|
+
function Mp(e) {
|
|
11788
11808
|
let t = e.trim();
|
|
11789
|
-
return t.length < 4 || t.length > 500 || /^(你好|hi|hello|ok|好的|继续|嗯|谢谢|hey|哈喽|收到|明白)/i.test(t) ? !1 :
|
|
11809
|
+
return t.length < 4 || t.length > 500 || /^(你好|hi|hello|ok|好的|继续|嗯|谢谢|hey|哈喽|收到|明白)/i.test(t) ? !1 : Op.test(t);
|
|
11790
11810
|
}
|
|
11791
|
-
function
|
|
11811
|
+
function Np(e) {
|
|
11792
11812
|
return [
|
|
11793
11813
|
"你是用户偏好提取器。判断下面的用户消息是否包含「持久偏好」—— 对未来同类工作都适用的口味/规则(如配色口味、文案风格、排版密度),而非仅针对本轮的任务指令。",
|
|
11794
11814
|
"只输出 JSON(无任何其他文本):{\"captured\": true, \"content\": \"一句话中性陈述(用户视角,如:不用紫色,偏好低饱和)\", \"topic\": \"color|copy|layout|interaction|tech|other\"} 或 {\"captured\": false, \"content\": \"\", \"topic\": \"other\"}",
|
|
@@ -11797,7 +11817,7 @@ function Ap(e) {
|
|
|
11797
11817
|
`用户消息:"""${e.slice(0, 800)}"""`
|
|
11798
11818
|
].join("\n");
|
|
11799
11819
|
}
|
|
11800
|
-
function
|
|
11820
|
+
function Pp(e) {
|
|
11801
11821
|
if (!e) return;
|
|
11802
11822
|
let t = (e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1] ?? e).match(/\{[\s\S]*\}/)?.[0];
|
|
11803
11823
|
if (t) try {
|
|
@@ -11806,19 +11826,19 @@ function jp(e) {
|
|
|
11806
11826
|
let n = typeof e.content == "string" ? e.content.trim().replace(/[。.!!]+$/, "") : "";
|
|
11807
11827
|
return n.length < 3 || n.length > 200 ? void 0 : {
|
|
11808
11828
|
content: n,
|
|
11809
|
-
topic:
|
|
11829
|
+
topic: yp.includes(e.topic) ? e.topic : "other"
|
|
11810
11830
|
};
|
|
11811
11831
|
} catch {
|
|
11812
11832
|
return;
|
|
11813
11833
|
}
|
|
11814
11834
|
}
|
|
11815
|
-
function
|
|
11835
|
+
function Fp(e) {
|
|
11816
11836
|
if (!e.length) return;
|
|
11817
11837
|
let t = ["## 用户偏好(跨会话沉淀;除非用户本轮另有指示,遵守以下偏好)"];
|
|
11818
|
-
for (let n of e) t.push(`- ${
|
|
11838
|
+
for (let n of e) t.push(`- ${Ep[n.topic]}:${n.content}`);
|
|
11819
11839
|
return t.join("\n");
|
|
11820
11840
|
}
|
|
11821
|
-
function
|
|
11841
|
+
function Ip(e) {
|
|
11822
11842
|
let t = [], n = -1, r = Promise.resolve(), i = (t) => e.onDebug?.({
|
|
11823
11843
|
stage: "preferences",
|
|
11824
11844
|
...t
|
|
@@ -11839,21 +11859,21 @@ function Np(e) {
|
|
|
11839
11859
|
}
|
|
11840
11860
|
return {
|
|
11841
11861
|
name: "preferences",
|
|
11842
|
-
augmentPrompt: () =>
|
|
11862
|
+
augmentPrompt: () => Fp(t),
|
|
11843
11863
|
afterAgent: (t) => {
|
|
11844
11864
|
let r = t.messages ?? [];
|
|
11845
11865
|
for (let t = n + 1; t < r.length; t++) {
|
|
11846
11866
|
let n = r[t];
|
|
11847
11867
|
if (n.role !== "user" || typeof n.content != "string" || !n.content) continue;
|
|
11848
|
-
let o = n.content, s =
|
|
11868
|
+
let o = n.content, s = jp(o);
|
|
11849
11869
|
if (s) {
|
|
11850
11870
|
a(s.content, s.topic, t, "explicit");
|
|
11851
11871
|
continue;
|
|
11852
11872
|
}
|
|
11853
|
-
if (e.llmInvoke &&
|
|
11873
|
+
if (e.llmInvoke && Mp(o)) {
|
|
11854
11874
|
let n = t;
|
|
11855
|
-
e.llmInvoke(
|
|
11856
|
-
let t =
|
|
11875
|
+
e.llmInvoke(Np(o)).then((e) => {
|
|
11876
|
+
let t = Pp(e);
|
|
11857
11877
|
t && a(t.content, t.topic, n, "llm");
|
|
11858
11878
|
}).catch((e) => i({ extractError: String(e) }));
|
|
11859
11879
|
}
|
|
@@ -11876,12 +11896,12 @@ function Np(e) {
|
|
|
11876
11896
|
}
|
|
11877
11897
|
};
|
|
11878
11898
|
}
|
|
11879
|
-
var
|
|
11880
|
-
function
|
|
11899
|
+
var Lp = /large_results\/[^\s"'`),]+\.txt/g;
|
|
11900
|
+
function Rp(e) {
|
|
11881
11901
|
let t = /* @__PURE__ */ new Set(), n = (e) => {
|
|
11882
11902
|
if (typeof e != "string" || !e) return;
|
|
11883
11903
|
let n;
|
|
11884
|
-
for (
|
|
11904
|
+
for (Lp.lastIndex = 0; (n = Lp.exec(e)) !== null;) t.add(n[0]);
|
|
11885
11905
|
};
|
|
11886
11906
|
for (let r of e) {
|
|
11887
11907
|
if (n(r.content), r.steps) for (let e of r.steps) n(e.result);
|
|
@@ -11889,14 +11909,14 @@ function Fp(e) {
|
|
|
11889
11909
|
}
|
|
11890
11910
|
return t;
|
|
11891
11911
|
}
|
|
11892
|
-
function
|
|
11912
|
+
function zp(e, t) {
|
|
11893
11913
|
let n = [];
|
|
11894
11914
|
for (let r of Object.keys(e)) r.startsWith("large_results/") && !t.has(r) && n.push(r);
|
|
11895
11915
|
return n;
|
|
11896
11916
|
}
|
|
11897
11917
|
//#endregion
|
|
11898
11918
|
//#region src/core/utils/serialRunner.ts
|
|
11899
|
-
function
|
|
11919
|
+
function Bp() {
|
|
11900
11920
|
let e = Promise.resolve();
|
|
11901
11921
|
return function(t) {
|
|
11902
11922
|
let n = e.then(t, t);
|
|
@@ -11905,24 +11925,24 @@ function Lp() {
|
|
|
11905
11925
|
}
|
|
11906
11926
|
//#endregion
|
|
11907
11927
|
//#region src/core/sdk/createChatSdk.ts
|
|
11908
|
-
var
|
|
11909
|
-
function
|
|
11928
|
+
var Vp = 30, Hp = /* @__PURE__ */ new Map();
|
|
11929
|
+
function Up(e, t) {
|
|
11910
11930
|
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;
|
|
11911
11931
|
}
|
|
11912
|
-
function
|
|
11932
|
+
function Wp(e) {
|
|
11913
11933
|
return e === "spawn_agent" || e === "spawn_agents" || e.startsWith("use_");
|
|
11914
11934
|
}
|
|
11915
|
-
function
|
|
11935
|
+
function Gp(e, t, n, r) {
|
|
11916
11936
|
let i = 0;
|
|
11917
11937
|
return {
|
|
11918
11938
|
name: "sdk-events",
|
|
11919
11939
|
wrapToolCall: async (t, r) => {
|
|
11920
|
-
let i = await r(t), a =
|
|
11940
|
+
let i = await r(t), a = Up(t.name, t.args);
|
|
11921
11941
|
return a ? e({
|
|
11922
11942
|
type: "data_change",
|
|
11923
11943
|
operation: a,
|
|
11924
11944
|
value: n()?.bind
|
|
11925
|
-
}) : i.status === "done" &&
|
|
11945
|
+
}) : i.status === "done" && Wp(t.name) && e({
|
|
11926
11946
|
type: "data_change",
|
|
11927
11947
|
operation: "edit",
|
|
11928
11948
|
value: n()?.bind
|
|
@@ -11949,7 +11969,7 @@ function Hp(e, t, n, r) {
|
|
|
11949
11969
|
}
|
|
11950
11970
|
};
|
|
11951
11971
|
}
|
|
11952
|
-
function
|
|
11972
|
+
function Kp(e, t, n, r, i) {
|
|
11953
11973
|
if (!n) return i && console.warn(`[page-agent-sdk][focus] capabilities.focus 关闭,${t} 忽略`), {
|
|
11954
11974
|
ok: !1,
|
|
11955
11975
|
error: "capabilities.focus 关闭"
|
|
@@ -11967,16 +11987,16 @@ function Up(e, t, n, r, i) {
|
|
|
11967
11987
|
error: "当前无主数据 schema,无法聚焦"
|
|
11968
11988
|
});
|
|
11969
11989
|
}
|
|
11970
|
-
function
|
|
11990
|
+
function qp(e, n) {
|
|
11971
11991
|
let i = {
|
|
11972
11992
|
prompt_tokens: 0,
|
|
11973
11993
|
completion_tokens: 0,
|
|
11974
11994
|
total_tokens: 0
|
|
11975
|
-
}, a =
|
|
11995
|
+
}, a = Kd(() => K, () => e.conflictPolicy ?? "ask"), o = /* @__PURE__ */ jt(0), s = yf(e.storage);
|
|
11976
11996
|
e.debug && s && s.onEvent((e) => console.log("[page-agent-sdk][storage]", e));
|
|
11977
|
-
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } =
|
|
11997
|
+
let { modelCaps: c, summaryLlmInvoke: l, titleLlmInvoke: u, compressDecisionInvoke: d } = Gd(e), f = c;
|
|
11978
11998
|
if (e.debug && console.log("[page-agent-sdk][modelCaps]", f), f.contextWindow < 2e5) throw Error(`[page-agent-sdk] 模型上下文窗口 ${f.contextWindow} 小于最小支持 ${Si}(需 ≥200K 窗口模型,如 GLM-5.2/Claude/Kimi/Qwen-1M/DeepSeek-v4)`);
|
|
11979
|
-
let p =
|
|
11999
|
+
let p = Ef(e, f.contextWindow), g = p.enableLLMSummary !== !1, _ = (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? Tf[e.contextPreset ?? "auto"], v = new Set(_), y = e.llm;
|
|
11980
12000
|
e.debug && !l && console.warn("[page-agent-sdk][summarization] 未构造 llmInvoke(apiKey 缺失?),摘要回退零成本索引摘要");
|
|
11981
12001
|
let b = /* @__PURE__ */ bt([]), x = iu(e.vfs?.initialFiles, {
|
|
11982
12002
|
persist: s ? { save: (e) => {
|
|
@@ -12021,8 +12041,8 @@ function Wp(e, n) {
|
|
|
12021
12041
|
let j = { current: null }, M = e.data ? {
|
|
12022
12042
|
...e.data,
|
|
12023
12043
|
description: e.data.description ?? "主数据对象"
|
|
12024
|
-
} : void 0, N = !(e.subagents ?? []).some((e) => e._codeAsset) &&
|
|
12025
|
-
N && M?.schema && Ho(M.schema).length && (P = [...e.subagents ?? [],
|
|
12044
|
+
} : void 0, N = !(e.subagents ?? []).some((e) => e._codeAsset) && Sf(e.capabilities).subagent, P = e.subagents;
|
|
12045
|
+
N && M?.schema && Ho(M.schema).length && (P = [...e.subagents ?? [], Ad()], console.info("[page-agent-sdk] 检测到 schema 含代码组件数组(如 components[].code),已自动装配 HTML 代码子 agent(委派编排 + vfs 工作副本 + 格式校验 + 增量 commit)。需定制(codeField/formatCheck/craftNotes 等)请显式传 createHtmlSubagent(...)"));
|
|
12026
12046
|
let ee = (P ?? []).filter((e) => !!e._codeAsset), F = /* @__PURE__ */ new Set();
|
|
12027
12047
|
for (let e of ee) {
|
|
12028
12048
|
if (e._codeAsset.writablePaths.length) continue;
|
|
@@ -12038,7 +12058,7 @@ function Wp(e, n) {
|
|
|
12038
12058
|
getTodos: () => j.current?.getState?.()?.todos ?? [],
|
|
12039
12059
|
messages: b,
|
|
12040
12060
|
maxCheckpoints: ae && typeof ae == "object" ? ae.maxCheckpoints : void 0
|
|
12041
|
-
}) : null, se = !ae || typeof ae != "object" || ae.auto !== !1, R =
|
|
12061
|
+
}) : null, se = !ae || typeof ae != "object" || ae.auto !== !1, R = Sf(e.capabilities), z = R.dataOps, ce = R.draftWrite, le = R.tracing, ue = R.automation, de = eu({
|
|
12042
12062
|
...e,
|
|
12043
12063
|
locale: e.i18n?.locale
|
|
12044
12064
|
});
|
|
@@ -12046,7 +12066,7 @@ function Wp(e, n) {
|
|
|
12046
12066
|
let e = te.map((e) => e._codeAsset.orchestratorPrompt).filter(Boolean).join("\n\n");
|
|
12047
12067
|
e && (de += "\n\n" + e);
|
|
12048
12068
|
} else M?.schema && Vo(M.schema) && (de += "\n\n" + as.htmlDirectWriteFallback, console.warn("[page-agent-sdk] 检测到 schema 含 code 字段但未注册 html 子 agent:已自动注入「主 agent 自己写 HTML」编排(code 作普通字段直接 write,无 vfs 工作副本 / 无格式校验门禁)。如需代码资产机制(vfs + 格式校验 + 增量 commit + 主上下文 code 摘要),注册 createHtmlSubagent;若确为降级意图可忽略。"));
|
|
12049
|
-
let fe = z && M ?
|
|
12069
|
+
let fe = z && M ? Gu(M, {
|
|
12050
12070
|
onAudit: e.onAudit ?? (e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0),
|
|
12051
12071
|
maxSnapshots: e.maxSnapshots,
|
|
12052
12072
|
onConflict: a.set,
|
|
@@ -12054,7 +12074,7 @@ function Wp(e, n) {
|
|
|
12054
12074
|
vfsStore: ce || M?.resources?.length ? x : void 0,
|
|
12055
12075
|
...re.length ? { pgIdPaths: re } : {},
|
|
12056
12076
|
...ie.length ? { largeTextPaths: ie } : {}
|
|
12057
|
-
}) : [], pe = z ? fe : [], B = z && M ? fe.controller ?? null : null, me = z && M?.resources?.length && B?.getResourcesSnapshot ?
|
|
12077
|
+
}) : [], pe = z ? fe : [], B = z && M ? fe.controller ?? null : null, me = z && M?.resources?.length && B?.getResourcesSnapshot ? pp({ getResourcesSnapshot: () => B?.getResourcesSnapshot?.() ?? [] }) : void 0, V = () => B?.get() ?? M, H = new Set(fe.map((e) => e.name)), he = e.conflictWatchFields ?? [], U = !he.includes("*") && he.length ? new Set(he) : void 0, ge = B ? _d({
|
|
12058
12078
|
getBind: () => V()?.bind,
|
|
12059
12079
|
recomputeAll: () => B.recomputeAllBaselines?.(),
|
|
12060
12080
|
hasBaselines: () => B.hasBaselines?.() ?? !1,
|
|
@@ -12071,15 +12091,15 @@ function Wp(e, n) {
|
|
|
12071
12091
|
}
|
|
12072
12092
|
}), Ft(n));
|
|
12073
12093
|
}
|
|
12074
|
-
}) : void 0, W = /* @__PURE__ */ new Map(), _e =
|
|
12075
|
-
...
|
|
12076
|
-
|
|
12077
|
-
|
|
12078
|
-
] :
|
|
12094
|
+
}) : void 0, W = /* @__PURE__ */ new Map(), _e = lp(R, pe, Af, R.domInspect && !R.skills ? [
|
|
12095
|
+
...If,
|
|
12096
|
+
Kf,
|
|
12097
|
+
qf
|
|
12098
|
+
] : If, tp);
|
|
12079
12099
|
_e.forEach((e) => W.set(e.name, "builtin"));
|
|
12080
12100
|
let ve = [...e.tools || []];
|
|
12081
12101
|
ve.forEach((e) => W.set(e.name, "user"));
|
|
12082
|
-
let ye =
|
|
12102
|
+
let ye = ip(e.actions ?? {});
|
|
12083
12103
|
ye.forEach((e) => W.set(e.name, "action"));
|
|
12084
12104
|
let be = [], xe = !1, Se = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), Ce = Se ? pl() : null;
|
|
12085
12105
|
Ce && W.set(dl, "builtin");
|
|
@@ -12151,7 +12171,7 @@ function Wp(e, n) {
|
|
|
12151
12171
|
Ae.forEach((e) => W.set(e.name, "builtin"));
|
|
12152
12172
|
let je = [], Me = /* @__PURE__ */ new Map(), G = Ne();
|
|
12153
12173
|
function Ne() {
|
|
12154
|
-
let { tools: e, collisions: t } =
|
|
12174
|
+
let { tools: e, collisions: t } = up([
|
|
12155
12175
|
{
|
|
12156
12176
|
label: "builtin",
|
|
12157
12177
|
tools: _e
|
|
@@ -12224,7 +12244,7 @@ function Wp(e, n) {
|
|
|
12224
12244
|
timeoutMs: Ye?.timeoutMs
|
|
12225
12245
|
}), tt = ne?.map((e) => {
|
|
12226
12246
|
if (!e._codeAsset) return e;
|
|
12227
|
-
let t = e._codeAsset, n =
|
|
12247
|
+
let t = e._codeAsset, n = cd({
|
|
12228
12248
|
writablePaths: t.writablePaths,
|
|
12229
12249
|
codeVfsPrefix: t.codeVfsPrefix,
|
|
12230
12250
|
ext: t.ext,
|
|
@@ -12239,12 +12259,12 @@ function Wp(e, n) {
|
|
|
12239
12259
|
...e,
|
|
12240
12260
|
middleware: r
|
|
12241
12261
|
};
|
|
12242
|
-
}), nt = I && He ?
|
|
12262
|
+
}), nt = I && He ? ld() : void 0, rt = nt ? gd({
|
|
12243
12263
|
getBind: () => V()?.bind,
|
|
12244
12264
|
writablePaths: re,
|
|
12245
12265
|
getLocked: () => nt.locked(),
|
|
12246
12266
|
tools: G,
|
|
12247
|
-
getCodeFieldPaths: () =>
|
|
12267
|
+
getCodeFieldPaths: () => md(V()?.bind, te.map((e) => ({
|
|
12248
12268
|
writablePaths: e._codeAsset.writablePaths,
|
|
12249
12269
|
codeField: e._codeAsset.codeField
|
|
12250
12270
|
})))
|
|
@@ -12268,7 +12288,7 @@ function Wp(e, n) {
|
|
|
12268
12288
|
timeoutMs: e.subagent?.timeoutMs,
|
|
12269
12289
|
...nt ? {
|
|
12270
12290
|
componentLock: nt,
|
|
12271
|
-
resolveComponents: (e) =>
|
|
12291
|
+
resolveComponents: (e) => ud(e, id(V()?.bind, re))
|
|
12272
12292
|
} : {}
|
|
12273
12293
|
}) : void 0, at = !!e.capabilities?.bulkGuard && !!Qe, ot = at ? gl({
|
|
12274
12294
|
...e.bulkGuard ?? {},
|
|
@@ -12285,7 +12305,7 @@ function Wp(e, n) {
|
|
|
12285
12305
|
}) : void 0;
|
|
12286
12306
|
e.capabilities?.bulkGuard && !Qe && console.info("[page-agent-sdk] bulkGuard 已请求但未配置 approval,门禁未装配(整体 no-op;配置 approval.tools 或 approval.confirm 后生效)");
|
|
12287
12307
|
let st = it ? it.controller : null, ct = (t) => {
|
|
12288
|
-
let n = t.thinkingMode ?? e.subagent?.thinkingMode, r = n ?
|
|
12308
|
+
let n = t.thinkingMode ?? e.subagent?.thinkingMode, r = n ? Id(t.llm ?? e.llm) ? "instance-noop" : "applied" : "inherited";
|
|
12289
12309
|
return {
|
|
12290
12310
|
...t,
|
|
12291
12311
|
...n ? { thinkingMode: n } : {},
|
|
@@ -12307,8 +12327,8 @@ function Wp(e, n) {
|
|
|
12307
12327
|
} : void 0
|
|
12308
12328
|
}) : void 0, ft = Je ? Gl({
|
|
12309
12329
|
contextWindow: f.contextWindow,
|
|
12310
|
-
thresholdRatio:
|
|
12311
|
-
}) : void 0, pt =
|
|
12330
|
+
thresholdRatio: Ef(e, f.contextWindow).summaryThresholdRatio
|
|
12331
|
+
}) : void 0, pt = fp({
|
|
12312
12332
|
...R,
|
|
12313
12333
|
humanConfirm: Se,
|
|
12314
12334
|
subagents: ne?.map(ct)
|
|
@@ -12328,7 +12348,7 @@ function Wp(e, n) {
|
|
|
12328
12348
|
return;
|
|
12329
12349
|
}
|
|
12330
12350
|
}
|
|
12331
|
-
} : null, gt =
|
|
12351
|
+
} : null, gt = Cf(e.onEvent), K = gt.emit, _t, vt = [], yt = (e) => ({
|
|
12332
12352
|
name: e.name,
|
|
12333
12353
|
description: e.description,
|
|
12334
12354
|
content: typeof e.getContent == "function" ? e.getContent() : ""
|
|
@@ -12336,13 +12356,13 @@ function Wp(e, n) {
|
|
|
12336
12356
|
name: e.name,
|
|
12337
12357
|
description: e.description,
|
|
12338
12358
|
getContent: () => e.content
|
|
12339
|
-
}), St = e.skillStorage === !1 ? null :
|
|
12359
|
+
}), St = e.skillStorage === !1 ? null : vp({
|
|
12340
12360
|
...typeof e.skillStorage == "object" ? e.skillStorage : {},
|
|
12341
12361
|
id: e.skillStorage && typeof e.skillStorage == "object" && e.skillStorage.id ? e.skillStorage.id : `agent::${n}`
|
|
12342
|
-
}), Ct = R.preferences, wt = Ct && e.preferenceStorage !== !1 ?
|
|
12362
|
+
}), Ct = R.preferences, wt = Ct && e.preferenceStorage !== !1 ? Tp({
|
|
12343
12363
|
...typeof e.preferenceStorage == "object" ? e.preferenceStorage : {},
|
|
12344
12364
|
id: e.preferenceStorage && typeof e.preferenceStorage == "object" && e.preferenceStorage.id ? e.preferenceStorage.id : `agent::${n}`
|
|
12345
|
-
}) : null, q = wt ?
|
|
12365
|
+
}) : null, q = wt ? Ip({
|
|
12346
12366
|
store: wt,
|
|
12347
12367
|
llmInvoke: l,
|
|
12348
12368
|
getSessionId: () => Y.sessionId,
|
|
@@ -12383,7 +12403,7 @@ function Wp(e, n) {
|
|
|
12383
12403
|
decideInvoke: d,
|
|
12384
12404
|
getSnapshot: () => ft?.getSnapshot()
|
|
12385
12405
|
} : {}
|
|
12386
|
-
}) : void 0, Dt =
|
|
12406
|
+
}) : void 0, Dt = Of([
|
|
12387
12407
|
...mt ? [mt] : [],
|
|
12388
12408
|
pt,
|
|
12389
12409
|
...Fe ? [C] : [],
|
|
@@ -12391,7 +12411,7 @@ function Wp(e, n) {
|
|
|
12391
12411
|
T,
|
|
12392
12412
|
...q ? [q] : [],
|
|
12393
12413
|
...Pe ? [S] : [],
|
|
12394
|
-
...Le ? [_t = cc([...R.domInspect && !(e.skills || []).some((e) => e.name ===
|
|
12414
|
+
...Le ? [_t = cc([...R.domInspect && !(e.skills || []).some((e) => e.name === Jf.name) ? [Jf] : [], ...e.skills || []], {
|
|
12395
12415
|
readVfs: Re ? (e) => x.files[e]?.content : void 0,
|
|
12396
12416
|
hostScriptEnabled: R.skillHostScript,
|
|
12397
12417
|
onToolsReady: (e, t) => {
|
|
@@ -12421,12 +12441,12 @@ function Wp(e, n) {
|
|
|
12421
12441
|
...ht ? [ht] : [],
|
|
12422
12442
|
...ft ? [ft] : [],
|
|
12423
12443
|
...e.middleware || [],
|
|
12424
|
-
...ue ? [
|
|
12444
|
+
...ue ? [np(i, {
|
|
12425
12445
|
tokenBudget: e.tokenBudget,
|
|
12426
12446
|
timeBudgetMs: e.timeBudgetMs
|
|
12427
12447
|
}, K)] : [],
|
|
12428
|
-
|
|
12429
|
-
]), Ot = e.maxMemoryRounds ??
|
|
12448
|
+
Gp(K, b, V, i)
|
|
12449
|
+
]), Ot = e.maxMemoryRounds ?? Vp, kt = e.approval?.timeoutMs, At = kt === void 0 || kt === 0 ? 3e4 : !Number.isFinite(kt) || kt < 0 ? 0 : kt;
|
|
12430
12450
|
function Mt(e) {
|
|
12431
12451
|
if (At) return (t) => {
|
|
12432
12452
|
if (t.type !== "approval_request") return;
|
|
@@ -12459,7 +12479,7 @@ function Wp(e, n) {
|
|
|
12459
12479
|
e.debug && console.warn("[page-agent-sdk][persist] refreshSessions 失败(已吞):", t);
|
|
12460
12480
|
}
|
|
12461
12481
|
}
|
|
12462
|
-
let Lt =
|
|
12482
|
+
let Lt = Bp(), Rt = /* @__PURE__ */ new Set();
|
|
12463
12483
|
function zt(e) {
|
|
12464
12484
|
let t = new AbortController(), n = () => t.abort();
|
|
12465
12485
|
return e && (e.aborted ? t.abort() : e.addEventListener("abort", n, { once: !0 })), Rt.add(t), {
|
|
@@ -12723,7 +12743,7 @@ function Wp(e, n) {
|
|
|
12723
12743
|
})), e.memory && Yt({ memory: A.get() || (typeof e.memory == "string" ? e.memory : "") }), It(), Kt = void 0, qt = !1, Y.infoTick.value++, r;
|
|
12724
12744
|
},
|
|
12725
12745
|
resetSession: () => {
|
|
12726
|
-
Bt(), a.resolve("keep_external"), Y.sessionId =
|
|
12746
|
+
Bt(), a.resolve("keep_external"), Y.sessionId = qd(), b.splice(0, b.length), x.clear?.(), S.reset([]), e.memory || A.reset(""), C.reset(), k.reset(), O.reset(), T.reset(), E = void 0, ot?.state.reset(), q?.resetScanCursor(), L && L.importStack([]), Y.agent && (Y.agent.debugLogs.value = [], Y.agent.resetStaleReadsInvalidated?.()), s && s.createSession(Y.agentId, e.session?.title, Y.sessionId).catch((t) => {
|
|
12727
12747
|
e.debug && console.warn("[page-agent-sdk][persist] createSession 失败(已吞):", t);
|
|
12728
12748
|
}), K({
|
|
12729
12749
|
type: "session_restored",
|
|
@@ -12743,7 +12763,7 @@ function Wp(e, n) {
|
|
|
12743
12763
|
code: "IMAGE_UNSUPPORTED_MODEL"
|
|
12744
12764
|
}), Error(`[page-agent-sdk] ${e}`);
|
|
12745
12765
|
}
|
|
12746
|
-
x?.setProtectedRefs?.(
|
|
12766
|
+
x?.setProtectedRefs?.(Rp(e));
|
|
12747
12767
|
let i = (e) => {
|
|
12748
12768
|
t?.(e), K(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && Y.infoTick.value++;
|
|
12749
12769
|
};
|
|
@@ -12758,7 +12778,7 @@ function Wp(e, n) {
|
|
|
12758
12778
|
if (Y.refCount--, Y.refCount <= 0) {
|
|
12759
12779
|
Bt(), xe = !0, s && (x.flush?.(), s.flush(), s.dispose()), St && St.dispose();
|
|
12760
12780
|
let e = Y.mcpClosers.splice(0);
|
|
12761
|
-
e.length && Promise.allSettled(e.map((e) => e())),
|
|
12781
|
+
e.length && Promise.allSettled(e.map((e) => e())), Hp.delete(n);
|
|
12762
12782
|
}
|
|
12763
12783
|
},
|
|
12764
12784
|
resolveConflict: a.resolve,
|
|
@@ -12778,14 +12798,14 @@ function Wp(e, n) {
|
|
|
12778
12798
|
},
|
|
12779
12799
|
setLlm(t) {
|
|
12780
12800
|
let n;
|
|
12781
|
-
if (
|
|
12801
|
+
if (Id(t)) n = t;
|
|
12782
12802
|
else {
|
|
12783
12803
|
let e = t;
|
|
12784
12804
|
if ((e.provider ?? "openai") === "anthropic") throw Error("[page-agent-sdk][setLlm] 切换到 Anthropic 需传 BaseChatModel 实例(动态 import 无法同步);请先 const { ChatAnthropic } = await import(\"@langchain/anthropic\") 构造实例后传入");
|
|
12785
12805
|
n = m(e);
|
|
12786
12806
|
}
|
|
12787
12807
|
typeof n.bindTools != "function" && e.debug && console.warn("[page-agent-sdk][setLlm] 新模型不支持 bindTools(tool calling 会失效)"), y = t;
|
|
12788
|
-
let r =
|
|
12808
|
+
let r = Id(t) ? void 0 : t;
|
|
12789
12809
|
if (f = Ci({
|
|
12790
12810
|
model: r?.model ?? t.model ?? t.modelName,
|
|
12791
12811
|
contextWindow: e.contextWindow ?? r?.contextWindow,
|
|
@@ -12829,7 +12849,7 @@ function Wp(e, n) {
|
|
|
12829
12849
|
return {
|
|
12830
12850
|
id: n,
|
|
12831
12851
|
sessionId: Y.sessionId,
|
|
12832
|
-
model:
|
|
12852
|
+
model: Id(y) ? y.model ?? y.modelName : y.model,
|
|
12833
12853
|
systemPrompt: Y.agent?.getEffectiveSystemPrompt?.() ?? de + $l(V(), e.schemaHint),
|
|
12834
12854
|
tools: (Y.agent?.allTools ?? G).map((e) => ({
|
|
12835
12855
|
name: e.name,
|
|
@@ -12880,7 +12900,7 @@ function Wp(e, n) {
|
|
|
12880
12900
|
spans: Y.agent.spans.value,
|
|
12881
12901
|
metrics: Ei(Y.agent.spans.value)
|
|
12882
12902
|
} : void 0,
|
|
12883
|
-
actions:
|
|
12903
|
+
actions: ap(e.actions ?? {}),
|
|
12884
12904
|
subagent: {
|
|
12885
12905
|
enabled: !!et,
|
|
12886
12906
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
@@ -12939,7 +12959,7 @@ function Wp(e, n) {
|
|
|
12939
12959
|
approxBytes: e
|
|
12940
12960
|
};
|
|
12941
12961
|
}
|
|
12942
|
-
return
|
|
12962
|
+
return Cd(Sd({
|
|
12943
12963
|
debugLogs: Y.agent?.debugLogs?.value ?? [],
|
|
12944
12964
|
messages: Y.messages,
|
|
12945
12965
|
info: t,
|
|
@@ -12977,11 +12997,11 @@ function Wp(e, n) {
|
|
|
12977
12997
|
return Te ? O.getFocuses() : [];
|
|
12978
12998
|
},
|
|
12979
12999
|
setFocus(t) {
|
|
12980
|
-
let n =
|
|
13000
|
+
let n = Kp(t, "setFocus", Te, () => V()?.schema, e.debug);
|
|
12981
13001
|
return n.ok ? (O.setFocus(t), Y.infoTick.value++, { ok: !0 }) : n;
|
|
12982
13002
|
},
|
|
12983
13003
|
addFocus(t) {
|
|
12984
|
-
let n =
|
|
13004
|
+
let n = Kp(t, "addFocus", Te, () => V()?.schema, e.debug);
|
|
12985
13005
|
return n.ok ? O.getFocuses().length >= 8 ? (e.debug && console.warn("[page-agent-sdk][focus] addFocus 拒绝:焦点数已达上限 8(augmentPrompt 注入每焦点子树 schema,过多致 system prompt 超预算)"), {
|
|
12986
13006
|
ok: !1,
|
|
12987
13007
|
error: "焦点数上限 8(避免 system prompt 撑爆)"
|
|
@@ -13025,14 +13045,14 @@ function Wp(e, n) {
|
|
|
13025
13045
|
}
|
|
13026
13046
|
function Ut(e) {
|
|
13027
13047
|
let t = {};
|
|
13028
|
-
for (let n of
|
|
13048
|
+
for (let n of Rp(e)) {
|
|
13029
13049
|
let e = x.files[n];
|
|
13030
13050
|
e && (t[n] = e.content);
|
|
13031
13051
|
}
|
|
13032
13052
|
return t;
|
|
13033
13053
|
}
|
|
13034
13054
|
function Wt() {
|
|
13035
|
-
let e =
|
|
13055
|
+
let e = zp(x.files, Rp(b));
|
|
13036
13056
|
for (let t of e) delete x.files[t];
|
|
13037
13057
|
}
|
|
13038
13058
|
function Gt() {
|
|
@@ -13136,7 +13156,7 @@ function Wp(e, n) {
|
|
|
13136
13156
|
Yt({ focus: e.length ? e : null });
|
|
13137
13157
|
}
|
|
13138
13158
|
ue && L && (Yt({ checkpoints: L.exportStack() }), Yt({ usage: i }));
|
|
13139
|
-
let t =
|
|
13159
|
+
let t = Fd(b);
|
|
13140
13160
|
if (t && t !== Kt && (Kt = t, Xt(Y.sessionId, t)), e.autoTitle !== !1 && u && !qt && b.some((e) => e.role === "user") && b.some((e) => e.role === "assistant")) {
|
|
13141
13161
|
qt = !0;
|
|
13142
13162
|
let e = Y.sessionId;
|
|
@@ -13214,7 +13234,7 @@ function Wp(e, n) {
|
|
|
13214
13234
|
}
|
|
13215
13235
|
}));
|
|
13216
13236
|
})();
|
|
13217
|
-
let t =
|
|
13237
|
+
let t = Id(e.llm) ? e.llm : await h(e.llm);
|
|
13218
13238
|
Y.agent = Eo({
|
|
13219
13239
|
llm: t,
|
|
13220
13240
|
systemPrompt: de,
|
|
@@ -13228,7 +13248,7 @@ function Wp(e, n) {
|
|
|
13228
13248
|
contextWindow: f.contextWindow,
|
|
13229
13249
|
maxOutputTokens: f.maxOutputTokens,
|
|
13230
13250
|
vision: f.vision,
|
|
13231
|
-
imageContentFormat: !
|
|
13251
|
+
imageContentFormat: !Id(e.llm) && (e.llm.provider ?? "openai") === "anthropic" ? "anthropic" : "openai",
|
|
13232
13252
|
maxVerifyAttempts: qe ? We : 0,
|
|
13233
13253
|
roundTokenBudget: e.roundTokenBudget ?? 0,
|
|
13234
13254
|
staleReadInvalidation: e.staleReadInvalidation,
|
|
@@ -13250,12 +13270,12 @@ function Wp(e, n) {
|
|
|
13250
13270
|
});
|
|
13251
13271
|
})(), Y;
|
|
13252
13272
|
}
|
|
13253
|
-
function
|
|
13254
|
-
let n = e.id ??
|
|
13273
|
+
function Jp(e, t) {
|
|
13274
|
+
let n = e.id ?? qd();
|
|
13255
13275
|
e.id || console.warn(`[page-agent-sdk] 未传 options.id,已生成随机 id "${n}"。刷新后持久化数据无法恢复,请传稳定 id。`);
|
|
13256
|
-
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ?
|
|
13257
|
-
o ? a = o : (a =
|
|
13258
|
-
let s = null, c =
|
|
13276
|
+
let r = e.streaming ?? !0, i = e.ui ?? "default", a, o = e.shareContext ? Hp.get(n) : void 0;
|
|
13277
|
+
o ? a = o : (a = qp(e, n), e.shareContext && Hp.set(n, a)), a.refCount++;
|
|
13278
|
+
let s = null, c = bf(e), l = null, u = null;
|
|
13259
13279
|
async function d(n) {
|
|
13260
13280
|
if (await a.initDone, s) {
|
|
13261
13281
|
s.show();
|
|
@@ -13477,7 +13497,7 @@ function Gp(e, t) {
|
|
|
13477
13497
|
}
|
|
13478
13498
|
//#endregion
|
|
13479
13499
|
//#region src/core/sdk/ragSubagent.ts
|
|
13480
|
-
function
|
|
13500
|
+
function Yp(e, t, n, r, i) {
|
|
13481
13501
|
let a = [];
|
|
13482
13502
|
e && a.push("vfs_grep + vfs_read(搜预注入文档)"), t && a.push(`${r}(语义检索)`), n && a.push(`${i}(按 source 加载)`), a.push("fetch_document(公网 URL)");
|
|
13483
13503
|
let o = [];
|
|
@@ -13492,7 +13512,7 @@ function Kp(e, t, n, r, i) {
|
|
|
13492
13512
|
|
|
13493
13513
|
你是只读检索角色,不要尝试修改任何数据。不要尝试上面未列出的工具。`;
|
|
13494
13514
|
}
|
|
13495
|
-
function
|
|
13515
|
+
function Xp(e, t, n, r, i) {
|
|
13496
13516
|
let a = [], o = [];
|
|
13497
13517
|
return e && (a.push("- vfs_grep / vfs_read:搜集成方预注入 vfs 的文档(组件文档 / UI 规范)—— 快、静态,先查"), o.push("- 静态文档(组件库文档 / UI 规范):vfs_grep")), t && (a.push(`- ${r}:语义检索(retriever 向量库)—— 模糊匹配,关键词不确定 / 语义相似时用`), o.push(`- 语义相似(「瀑布流组件」「倒计时」「拼团」):${r}`)), n && (a.push(`- ${i}:按 source 精确加载(已知文档 id / URL / key)—— 精确取特定文档`), o.push(`- 已知文档 id / URL:${i}`)), a.push("- fetch_document:公网 URL —— 查公开资料"), o.push("- 公开 URL(设计规范网站 / 第三方文档):fetch_document"), `# 知识检索策略(RAG)
|
|
13498
13518
|
|
|
@@ -13509,12 +13529,12 @@ ${a.join("\n")}
|
|
|
13509
13529
|
## 何时用何源
|
|
13510
13530
|
${o.join("\n")}`;
|
|
13511
13531
|
}
|
|
13512
|
-
var
|
|
13532
|
+
var Zp = {
|
|
13513
13533
|
name: "rag-search",
|
|
13514
13534
|
description: "多源知识检索策略:vfs 预注入文档 → 语义检索 → 指定文档加载 → 公网;综合结构化结论 + 溯源",
|
|
13515
|
-
getContent: () =>
|
|
13535
|
+
getContent: () => Xp(!0, !0, !0, "search_docs", "load_doc")
|
|
13516
13536
|
};
|
|
13517
|
-
function
|
|
13537
|
+
function Qp(e, n, i) {
|
|
13518
13538
|
return r(async ({ query: e, topK: t }) => {
|
|
13519
13539
|
try {
|
|
13520
13540
|
let r = await n(e, { topK: t ?? i });
|
|
@@ -13531,7 +13551,7 @@ function Yp(e, n, i) {
|
|
|
13531
13551
|
})
|
|
13532
13552
|
});
|
|
13533
13553
|
}
|
|
13534
|
-
function
|
|
13554
|
+
function $p(e, n) {
|
|
13535
13555
|
return r(async ({ source: e }) => {
|
|
13536
13556
|
try {
|
|
13537
13557
|
let t = await n(e), r = Array.isArray(t) ? t : [t];
|
|
@@ -13545,19 +13565,19 @@ function Xp(e, n) {
|
|
|
13545
13565
|
schema: t.object({ source: t.string().describe("文档标识(id/URL/key)") })
|
|
13546
13566
|
});
|
|
13547
13567
|
}
|
|
13548
|
-
function
|
|
13568
|
+
function em(e) {
|
|
13549
13569
|
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;
|
|
13550
13570
|
if (!t && !n && r === !1) throw Error("[page-agent-sdk][createRagSubagent] 至少配一种知识源:retriever / loader / useVfs(true)");
|
|
13551
13571
|
let p = [];
|
|
13552
|
-
t && p.push(
|
|
13572
|
+
t && p.push(Qp(s, t, o)), n && p.push($p(c, n)), f && p.push(...f);
|
|
13553
13573
|
let m = r ? [
|
|
13554
13574
|
"vfs_grep",
|
|
13555
13575
|
"vfs_read",
|
|
13556
13576
|
"vfs_json_read"
|
|
13557
|
-
] : void 0, h =
|
|
13577
|
+
] : void 0, h = Yp(r, !!t, !!n, s, c), g = {
|
|
13558
13578
|
name: "rag-search",
|
|
13559
|
-
description:
|
|
13560
|
-
getContent: () =>
|
|
13579
|
+
description: Zp.description,
|
|
13580
|
+
getContent: () => Xp(r, !!t, !!n, s, c)
|
|
13561
13581
|
};
|
|
13562
13582
|
return {
|
|
13563
13583
|
id: i,
|
|
@@ -13572,7 +13592,7 @@ function Zp(e) {
|
|
|
13572
13592
|
}
|
|
13573
13593
|
//#endregion
|
|
13574
13594
|
//#region src/core/utils/clipboard.ts
|
|
13575
|
-
async function
|
|
13595
|
+
async function tm(e) {
|
|
13576
13596
|
try {
|
|
13577
13597
|
let t = globalThis.navigator?.clipboard;
|
|
13578
13598
|
if (t && typeof t.writeText == "function") return await t.writeText(e), !0;
|
|
@@ -13590,8 +13610,8 @@ async function Qp(e) {
|
|
|
13590
13610
|
}
|
|
13591
13611
|
//#endregion
|
|
13592
13612
|
//#region src/core/composables/useChat.ts
|
|
13593
|
-
var
|
|
13594
|
-
function
|
|
13613
|
+
var nm = 4e3;
|
|
13614
|
+
function rm(e = {}) {
|
|
13595
13615
|
let { fetchResponse: t, fetchStream: n, onPersist: r, onClear: i, onQueuedCleared: a, onBeforeRegenerate: o } = e, s = /* @__PURE__ */ bt({
|
|
13596
13616
|
messages: e.messages ?? [],
|
|
13597
13617
|
loading: !1,
|
|
@@ -13670,7 +13690,7 @@ function em(e = {}) {
|
|
|
13670
13690
|
let t = e.delta || "";
|
|
13671
13691
|
n.subReasonFull = (n.subReasonFull || "") + t;
|
|
13672
13692
|
let r = (n.subReason || "") + t;
|
|
13673
|
-
n.subReason = r.length >
|
|
13693
|
+
n.subReason = r.length > nm ? r.slice(-4e3) : r;
|
|
13674
13694
|
break;
|
|
13675
13695
|
}
|
|
13676
13696
|
n.children ||= [];
|
|
@@ -13800,7 +13820,7 @@ function em(e = {}) {
|
|
|
13800
13820
|
}
|
|
13801
13821
|
//#endregion
|
|
13802
13822
|
//#region src/core/components/icons.ts
|
|
13803
|
-
var
|
|
13823
|
+
var im = {
|
|
13804
13824
|
header: "🤖",
|
|
13805
13825
|
subagent: "🤖",
|
|
13806
13826
|
subagentProgress: "🧬",
|
|
@@ -13811,10 +13831,10 @@ var tm = {
|
|
|
13811
13831
|
recommend: "💡",
|
|
13812
13832
|
conflict: "⚠️"
|
|
13813
13833
|
};
|
|
13814
|
-
function
|
|
13815
|
-
let t = { ...
|
|
13834
|
+
function am(e) {
|
|
13835
|
+
let t = { ...im };
|
|
13816
13836
|
if (!e) return t;
|
|
13817
|
-
let n = Object.keys(
|
|
13837
|
+
let n = Object.keys(im);
|
|
13818
13838
|
for (let r of n) {
|
|
13819
13839
|
let n = e[r];
|
|
13820
13840
|
typeof n == "string" && (t[r] = n);
|
|
@@ -13823,7 +13843,7 @@ function nm(e) {
|
|
|
13823
13843
|
}
|
|
13824
13844
|
//#endregion
|
|
13825
13845
|
//#region src/core/components/messages.ts
|
|
13826
|
-
var
|
|
13846
|
+
var om = {
|
|
13827
13847
|
defaultTitle: "AI 助手",
|
|
13828
13848
|
inputPlaceholder: "输入消息,Enter 发送...",
|
|
13829
13849
|
newSession: "新建会话",
|
|
@@ -14062,8 +14082,8 @@ var rm = {
|
|
|
14062
14082
|
codeDemoText: "这是一段示例文字,用于展示 CSS 效果。",
|
|
14063
14083
|
codeDemoButton: "按钮",
|
|
14064
14084
|
codeDemoInput: "输入框"
|
|
14065
|
-
},
|
|
14066
|
-
"zh-CN":
|
|
14085
|
+
}, sm = {
|
|
14086
|
+
"zh-CN": om,
|
|
14067
14087
|
"en-US": {
|
|
14068
14088
|
defaultTitle: "AI Assistant",
|
|
14069
14089
|
inputPlaceholder: "Type a message, Enter to send...",
|
|
@@ -14305,10 +14325,10 @@ var rm = {
|
|
|
14305
14325
|
codeDemoInput: "Input"
|
|
14306
14326
|
}
|
|
14307
14327
|
};
|
|
14308
|
-
function
|
|
14328
|
+
function cm(e = "zh-CN", t) {
|
|
14309
14329
|
let n = {
|
|
14310
|
-
...
|
|
14311
|
-
...
|
|
14330
|
+
...om,
|
|
14331
|
+
...sm[e]
|
|
14312
14332
|
};
|
|
14313
14333
|
if (!t) return n;
|
|
14314
14334
|
let r = { ...n };
|
|
@@ -14320,9 +14340,9 @@ function am(e = "zh-CN", t) {
|
|
|
14320
14340
|
}
|
|
14321
14341
|
//#endregion
|
|
14322
14342
|
//#region src/core/composables/chatContext.ts
|
|
14323
|
-
var
|
|
14324
|
-
function
|
|
14325
|
-
let t =
|
|
14343
|
+
var lm = Symbol("chatContext");
|
|
14344
|
+
function um(e = {}) {
|
|
14345
|
+
let t = rm({
|
|
14326
14346
|
fetchResponse: e.fetchResponse,
|
|
14327
14347
|
fetchStream: e.fetchStream,
|
|
14328
14348
|
messages: e.messages,
|
|
@@ -14343,7 +14363,7 @@ function sm(e = {}) {
|
|
|
14343
14363
|
}, h = /* @__PURE__ */ jt({}), g = (e) => h.value[e] === !0, _ = (e) => {
|
|
14344
14364
|
h.value[e] = !g(e);
|
|
14345
14365
|
}, v = /* @__PURE__ */ jt(!1), y = (e) => {
|
|
14346
|
-
|
|
14366
|
+
tm(e).then((e) => {
|
|
14347
14367
|
e && (v.value = !0, setTimeout(() => {
|
|
14348
14368
|
v.value = !1;
|
|
14349
14369
|
}, 1500));
|
|
@@ -14405,7 +14425,7 @@ function sm(e = {}) {
|
|
|
14405
14425
|
e.onClearFocus?.();
|
|
14406
14426
|
}, re = (t) => {
|
|
14407
14427
|
e.onFocusChipClick?.(t);
|
|
14408
|
-
}, ie =
|
|
14428
|
+
}, ie = am(e.icons), ae = e.locale ?? "zh-CN", oe = cm(ae, e.dialogMessages);
|
|
14409
14429
|
return {
|
|
14410
14430
|
chat: t,
|
|
14411
14431
|
inputText: o,
|
|
@@ -14446,15 +14466,15 @@ function sm(e = {}) {
|
|
|
14446
14466
|
messages: oe
|
|
14447
14467
|
};
|
|
14448
14468
|
}
|
|
14449
|
-
function
|
|
14450
|
-
let e = Rn(
|
|
14469
|
+
function dm() {
|
|
14470
|
+
let e = Rn(lm);
|
|
14451
14471
|
if (!e) throw Error("useChatContext 必须在 provide(chatContextKey) 的组件子树内调用");
|
|
14452
14472
|
return e;
|
|
14453
14473
|
}
|
|
14454
14474
|
//#endregion
|
|
14455
14475
|
//#region src/core/index.headless.ts
|
|
14456
|
-
function
|
|
14457
|
-
return
|
|
14476
|
+
function fm(e) {
|
|
14477
|
+
return Jp(e);
|
|
14458
14478
|
}
|
|
14459
14479
|
//#endregion
|
|
14460
|
-
export {
|
|
14480
|
+
export { xf as CAPABILITIES, wf as CONTEXT_PRESETS, Pd as CompressDecisionSchema, Lf as DEFAULT_COMPUTED_STYLES, Tc as DEFAULT_PROMPT_SOFT_CAP, Zl as DEFAULT_SYSTEM_PROMPT, Ku as HTML_VOID_TAGS, dl as HUMAN_CONFIRM_TOOL_NAME, ni as ImageInputError, Si as MIN_CONTEXT_WINDOW, wc as SOFT_CAP_MIN_WINDOW, vc as STOP_WORDS, Cs as UNSAFE_KEYS, ap as actionsToInspectInfo, ip as actionsToTools, Qr as agentError, Wl as analyzeContext, Fs as applyPatchToClone, Rs as applyPatchToLive, Ru as applyPatchesToBind, Io as arrayMinLength, Zr as asAgentError, Hf as buildCssPath, $l as buildDataPrompt, Sd as buildDiagnosticsReport, eu as buildSystemPrompt, lm as chatContextKey, Lu as commitSetToBind, pi as compressImage, Xl as connectMcp, h as constructLlmFromConfig, m as constructOpenLlmSync, tm as copyText, Eo as createAgent, ul as createApprovalMiddleware, gl as createBulkGuardMiddleware, um as createChatContext, fm as createChatSdk, Cl as createCheckpointManager, wl as createCheckpointMiddleware, Kd as createConflictManager, Gl as createContextInspectorMiddleware, Gu as createDataOps, Dd as createHtmlFormatCheck, Ad as createHtmlSubagent, ml as createHumanConfirmMiddleware, pl as createHumanConfirmTool, mf as createMemoryBackend, rl as createMemoryMiddleware, u as createProxyLlm, em as createRagSubagent, Wi as createSandboxRunner, Cf as createSdkEvents, Bp as createSerialRunner, vf as createSessionStore, vp as createSkillStore, Jc as createSubagentMiddleware, jc as createSubagentTracker, Zc as createSubagentsMiddleware, fp as createUsageHintsMiddleware, Tl as createVerifyMiddleware, iu as createVfs, gf as createWebStorageBackend, jl as createWriteBackCheck, Os as deepClone, cp as defineDataToolset, Ys as defineSkill, jd as defineTool, Ds as deleteByPath, Fd as deriveTitle, Xo as describeSchemaNode, fo as detectGarbledToolCall, Hs as diffObjects, qf as domInfoTool, Jf as domInspectSkill, Kf as domSearchTool, Pf as domToStructure, If as domTools, sp as domToolsStatic, Lo as elementSchemaCandidates, Bf as ensureDomListenerRecorder, bc as estimateMessageTokens, xc as estimateRoundTokens, Z as estimateTokens, _ as extractReasoningDelta, ls as extractSchemaHint, Kl as extractText, g as extractTextDelta, v as extractUsage, Af as fetchDocTools, op as fetchTools, Vs as findStrippedKeys, Zo as formatConstraints, qr as formatZodIssues, Q as getByPath, Ff as getDomTool, Gf as getElementInfo, Zf as getEnvSummary, Vf as getRecordedListeners, Ao as getSchemaAtPath, Do as getSchemaTopKeys, Ei as getTraceMetrics, Ns as hashValue, is as htmlOrchestratorPrompt, Sc as indexSummarize, ep as inspectEnvTool, tp as inspectTools, Id as isChatModel, zi as isContextLengthError, Oo as isPathAllowed, of as isQuotaError, ws as isUnsafePath, ea as jpEval, Yr as jsonParseError, js as limitDepth, bd as maskUrlCredentials, ks as maybeParseValue, hl as measureWriteScale, b as normalizeUsage, Ti as offloadPassThroughChars, wi as offloadThresholdChars, rs as presets, Wo as projectBySchema, Uo as projectBySchemaDeep, As as projectFields, Cc as recallRounds, Qo as renderSchemaHint, $o as renderSchemaOverview, ns as renderSchemaShallow, Sf as resolveCapabilities, Ef as resolveContextOptions, bf as resolveDialogConfig, Gd as resolveLlm, Ci as resolveModelCaps, Ec as resolvePromptSoftCap, No as resolveSchemaPath, yf as resolveStorage, Bs as restoreInPlace, zs as restoreLive, Xr as routeError, Js as runHostScript, ia as runSandboxedScript, Ts as safeMerge, Xf as safeSerialize, $ as safeStringify, Fo as schemaHasRefinement, Uf as searchDom, na as searchJson, lp as selectBuiltinTools, Es as setByPath, Dc as shouldTriggerCompression, Cd as stringifyDiagnosticsReport, as as systemPromptHelpers, yc as tokenize, X as toolError, ko as unwrapSchema, rm as useChat, dm as useChatContext, Po as validateAtPath, Ju as validateHtmlFormat, Fu as validateRootValueLocally, Iu as validateWriteLocally, Ps as watchFieldsHash, e as z, Jr as zodError };
|