page-agent-sdk 3.44.0 → 3.44.1
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 +39 -32
- package/dist/page-agent-sdk.iife.js +6 -6
- package/dist/page-agent-sdk.js +39 -32
- package/dist/page-agent-sdk.legacy.js +39 -32
- package/dist/page-agent-sdk.umd.cjs +6 -6
- package/package.json +1 -1
package/dist/page-agent-sdk.js
CHANGED
|
@@ -5378,7 +5378,7 @@ var Gu = "", Ku = "根(整体)", qu = /* @__PURE__ */ new Set([
|
|
|
5378
5378
|
]), Ju = /* @__PURE__ */ new Set(["resource_update", "resource_delete"]), Yu = /* @__PURE__ */ new Set(["remove", "move"]);
|
|
5379
5379
|
function Xu(e) {
|
|
5380
5380
|
let t = String(e).trim();
|
|
5381
|
-
return t === "(root)" || t === "$" ? Gu : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t);
|
|
5381
|
+
return t === "(root)" || t === "$" ? Gu : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t = t.replace(/\[(\d+)\]/g, ".$1"), t);
|
|
5382
5382
|
}
|
|
5383
5383
|
function Zu(e) {
|
|
5384
5384
|
let t = Xu(e);
|
|
@@ -5641,9 +5641,9 @@ function jd(e) {
|
|
|
5641
5641
|
function Md(e, t) {
|
|
5642
5642
|
return !(!e.length || !e.some((e) => e.status !== "completed") || /[??]\s*$/.test(t));
|
|
5643
5643
|
}
|
|
5644
|
-
function Nd(e) {
|
|
5645
|
-
let
|
|
5646
|
-
return `⚠️ 任务未完成:待办清单还有 ${
|
|
5644
|
+
function Nd(e, t) {
|
|
5645
|
+
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) => e.status === "completed" && !e.evidence && (!t || t.get(e.id) !== "completed")), a = i.length ? `\n另有 ${i.length} 项已标记完成但 evidence 为空(${i.map((e) => `#${e.id}`).join("、")}):标记完成时请用 update_todo 附 evidence(本次实际写入的 jsonPath,如 components.2);经委派完成等无主写路径时如实写明完成方式。` : "";
|
|
5646
|
+
return `⚠️ 任务未完成:待办清单还有 ${n.length} 项未完成:\n${r}\n若这些工作实际已完成,请先用 update_todo 把它们全部标记 completed(或一次 write_todos 整表替换)再给出最终总结;若尚未完成,请继续执行剩余任务。不要中途停止。${a}`;
|
|
5647
5647
|
}
|
|
5648
5648
|
function Pd(e = [], n = {}) {
|
|
5649
5649
|
let i = Ad(e), a = 0, o = 0, s = !1, c = 0, l = n.maxPlanRevisions ?? 5;
|
|
@@ -5746,7 +5746,7 @@ function Bd(e) {
|
|
|
5746
5746
|
gate: {
|
|
5747
5747
|
stage: "completion_gate",
|
|
5748
5748
|
attempt: t.completionRetries,
|
|
5749
|
-
feedback: Nd(e.todos),
|
|
5749
|
+
feedback: Nd(e.todos, e.todosStatusAtStart),
|
|
5750
5750
|
logData: { pending: e.todos.filter((e) => e.status !== "completed").map((e) => e.id) }
|
|
5751
5751
|
}
|
|
5752
5752
|
};
|
|
@@ -6506,14 +6506,14 @@ function ff(e) {
|
|
|
6506
6506
|
for (let e = 0; e < o.length; e++) {
|
|
6507
6507
|
let t = p[e];
|
|
6508
6508
|
if (!t) continue;
|
|
6509
|
-
let n = `${o[e].call.name}|${JSON.stringify(o[e].call.args ?? {})}`,
|
|
6510
|
-
if (
|
|
6511
|
-
let e = (v.get(
|
|
6512
|
-
v.set(
|
|
6513
|
-
} else v.delete(
|
|
6509
|
+
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;
|
|
6510
|
+
if (i) {
|
|
6511
|
+
let e = (v.get(r) ?? 0) + 1;
|
|
6512
|
+
v.set(r, e), e >= 2 && (a = `${t.content}\n(提示:同参数已连续失败 ${e} 次,原样重试大概率仍失败;请检查参数/换路径/换方法,或向用户如实说明困难)`);
|
|
6513
|
+
} else v.delete(r);
|
|
6514
6514
|
c.push(new s({
|
|
6515
6515
|
tool_call_id: o[e].id,
|
|
6516
|
-
content:
|
|
6516
|
+
content: a
|
|
6517
6517
|
}));
|
|
6518
6518
|
}
|
|
6519
6519
|
for (let e = 0; e < o.length; e++) {
|
|
@@ -11434,42 +11434,49 @@ function Ag(e, n = {}) {
|
|
|
11434
11434
|
message: `jsonPath "${m}" 含非法段(__proto__/constructor/prototype)`,
|
|
11435
11435
|
hint: "使用正常属性路径,如 components.0.text(数组索引数字)"
|
|
11436
11436
|
});
|
|
11437
|
+
let h = (e, t) => {
|
|
11438
|
+
let n = (e ? gf(o, e) : o)?.shape;
|
|
11439
|
+
return n && typeof n == "object" ? Object.keys(n) : t && typeof t == "object" && !Array.isArray(t) ? Object.keys(t) : [];
|
|
11440
|
+
};
|
|
11437
11441
|
if (!mf(m, o, l)) {
|
|
11438
|
-
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = e ? fp(s, e) : s, n = t
|
|
11442
|
+
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = h(e, e ? fp(s, e) : s), n = t.length ? `;父级 "${e || "(root)"}" 的可用字段:${t.slice(0, 12).join(", ")}${t.length > 12 ? " …" : ""}` : "";
|
|
11439
11443
|
return $({
|
|
11440
11444
|
code: "PATH_DENIED",
|
|
11441
11445
|
message: `read @ "${m}" 不在 schema 声明字段内`,
|
|
11442
11446
|
hint: `主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它${n}`
|
|
11443
11447
|
});
|
|
11444
11448
|
}
|
|
11445
|
-
let
|
|
11446
|
-
if (m &&
|
|
11447
|
-
let e =
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11449
|
+
let g = m ? fp(s, m) : s;
|
|
11450
|
+
if (m && g === void 0) {
|
|
11451
|
+
let e = gf(o, m);
|
|
11452
|
+
if (!(e && typeof e.isOptional == "function" && e.isOptional())) {
|
|
11453
|
+
let e = /[.[]/.test(m) ? m.replace(/[.[][^.[]*$/, "") : "", t = e ? fp(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 查看顶层字段`;
|
|
11454
|
+
return $({
|
|
11455
|
+
code: "PATH_NOT_FOUND",
|
|
11456
|
+
path: m,
|
|
11457
|
+
message: `路径 "${m}" 不存在`,
|
|
11458
|
+
hint: r
|
|
11459
|
+
});
|
|
11460
|
+
}
|
|
11454
11461
|
}
|
|
11455
|
-
if (!m && l)
|
|
11462
|
+
if (!m && l) g = kf(g, o);
|
|
11456
11463
|
else if (l) {
|
|
11457
11464
|
let e = gf(o, m);
|
|
11458
|
-
e && (
|
|
11465
|
+
e && (g = kf(g, e));
|
|
11459
11466
|
}
|
|
11460
|
-
let
|
|
11461
|
-
p && (
|
|
11467
|
+
let _ = g;
|
|
11468
|
+
p && (_ = pg({
|
|
11462
11469
|
jp: m,
|
|
11463
|
-
resolved:
|
|
11470
|
+
resolved: _,
|
|
11464
11471
|
resourcesByPath: p.resourcesByPath,
|
|
11465
11472
|
resourceStore: p.resourceStore
|
|
11466
|
-
})), b(f, d), n && n.length && (
|
|
11467
|
-
let
|
|
11468
|
-
if ((i !== void 0 || a !== void 0) && Array.isArray(
|
|
11469
|
-
let e =
|
|
11470
|
-
return `${
|
|
11473
|
+
})), b(f, d), n && n.length && (_ = _p(_, n)), r != null && (_ = vp(_, r)), _ = Tg(_, d === "", D, E);
|
|
11474
|
+
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}` : "";
|
|
11475
|
+
if ((i !== void 0 || a !== void 0) && Array.isArray(_)) {
|
|
11476
|
+
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;
|
|
11477
|
+
return `${y}主数据${m ? ` @ ${m}` : ""} 数组分页[offset=${t},limit=${n}]${C} = ${yp(r)} (total=${e}, hasMore=${o}) (hash=${f})`;
|
|
11471
11478
|
}
|
|
11472
|
-
return
|
|
11479
|
+
return _ === void 0 ? `${y}主数据${m ? ` @ ${m}` : ""}${C} = (undefined) (hash=${f})` : `${y}主数据${m ? ` @ ${m}` : ""}${C} = ${yp(_)} (hash=${f})`;
|
|
11473
11480
|
}, {
|
|
11474
11481
|
name: "read",
|
|
11475
11482
|
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(声明 conflictWatchFields 后 write 自动比对;未声明不自动校验)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。",
|
|
@@ -55171,7 +55171,7 @@ var aQ = "", fCe = "根(整体)", pCe = /* @__PURE__ */ new Set([
|
|
|
55171
55171
|
]), mCe = /* @__PURE__ */ new Set(["resource_update", "resource_delete"]), hCe = /* @__PURE__ */ new Set(["remove", "move"]);
|
|
55172
55172
|
function oQ(e) {
|
|
55173
55173
|
let t = String(e).trim();
|
|
55174
|
-
return t === "(root)" || t === "$" ? aQ : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t);
|
|
55174
|
+
return t === "(root)" || t === "$" ? aQ : (t.startsWith("$.") ? t = t.slice(2) : t.startsWith("$") && (t = t.slice(1)), t = t.replace(/\[(\d+)\]/g, ".$1"), t);
|
|
55175
55175
|
}
|
|
55176
55176
|
function sQ(e) {
|
|
55177
55177
|
let t = oQ(e);
|
|
@@ -55442,9 +55442,9 @@ function VCe(e) {
|
|
|
55442
55442
|
function HCe(e, t) {
|
|
55443
55443
|
return !(!e.length || !e.some((e) => e.status !== "completed") || /[??]\s*$/.test(t));
|
|
55444
55444
|
}
|
|
55445
|
-
function UCe(e) {
|
|
55446
|
-
let
|
|
55447
|
-
return `⚠️ 任务未完成:待办清单还有 ${
|
|
55445
|
+
function UCe(e, t) {
|
|
55446
|
+
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) => e.status === "completed" && !e.evidence && (!t || t.get(e.id) !== "completed")), a = i.length ? `\n另有 ${i.length} 项已标记完成但 evidence 为空(${i.map((e) => `#${e.id}`).join("、")}):标记完成时请用 update_todo 附 evidence(本次实际写入的 jsonPath,如 components.2);经委派完成等无主写路径时如实写明完成方式。` : "";
|
|
55447
|
+
return `⚠️ 任务未完成:待办清单还有 ${n.length} 项未完成:\n${r}\n若这些工作实际已完成,请先用 update_todo 把它们全部标记 completed(或一次 write_todos 整表替换)再给出最终总结;若尚未完成,请继续执行剩余任务。不要中途停止。${a}`;
|
|
55448
55448
|
}
|
|
55449
55449
|
function gQ(e = [], t = {}) {
|
|
55450
55450
|
var n;
|
|
@@ -55549,7 +55549,7 @@ function JCe(e) {
|
|
|
55549
55549
|
gate: {
|
|
55550
55550
|
stage: "completion_gate",
|
|
55551
55551
|
attempt: r.completionRetries,
|
|
55552
|
-
feedback: UCe(e.todos),
|
|
55552
|
+
feedback: UCe(e.todos, e.todosStatusAtStart),
|
|
55553
55553
|
logData: { pending: e.todos.filter((e) => e.status !== "completed").map((e) => e.id) }
|
|
55554
55554
|
}
|
|
55555
55555
|
};
|
|
@@ -56323,15 +56323,15 @@ function OQ(e) {
|
|
|
56323
56323
|
var fe;
|
|
56324
56324
|
let t = d[e];
|
|
56325
56325
|
if (!t) continue;
|
|
56326
|
-
let n = `${a[e].call.name}|${JSON.stringify((fe = a[e].call.args) == null ? {} : fe)}`,
|
|
56327
|
-
if (
|
|
56326
|
+
let n = (e) => e && typeof e == "object" && !Array.isArray(e) ? Object.fromEntries(Object.keys(e).sort().map((t) => [t, n(e[t])])) : e, r = `${a[e].call.name}|${JSON.stringify(n((fe = a[e].call.args) == null ? {} : fe))}`, i = t.status === "error" || typeof t.content == "string" && t.content.startsWith("ERROR:"), s = t.content;
|
|
56327
|
+
if (i) {
|
|
56328
56328
|
var me;
|
|
56329
|
-
let e = ((me = g.get(
|
|
56330
|
-
g.set(
|
|
56331
|
-
} else g.delete(
|
|
56329
|
+
let e = ((me = g.get(r)) == null ? 0 : me) + 1;
|
|
56330
|
+
g.set(r, e), e >= 2 && (s = `${t.content}\n(提示:同参数已连续失败 ${e} 次,原样重试大概率仍失败;请检查参数/换路径/换方法,或向用户如实说明困难)`);
|
|
56331
|
+
} else g.delete(r);
|
|
56332
56332
|
o.push(new my({
|
|
56333
56333
|
tool_call_id: a[e].id,
|
|
56334
|
-
content:
|
|
56334
|
+
content: s
|
|
56335
56335
|
}));
|
|
56336
56336
|
}
|
|
56337
56337
|
for (let e = 0; e < a.length; e++) {
|
|
@@ -69067,42 +69067,49 @@ function $6(e, t = {}) {
|
|
|
69067
69067
|
message: `jsonPath "${l}" 含非法段(__proto__/constructor/prototype)`,
|
|
69068
69068
|
hint: "使用正常属性路径,如 components.0.text(数组索引数字)"
|
|
69069
69069
|
});
|
|
69070
|
+
let u = (e, t) => {
|
|
69071
|
+
let n = e ? MQ(d, e) : d, r = n == null ? void 0 : n.shape;
|
|
69072
|
+
return r && typeof r == "object" ? Object.keys(r) : t && typeof t == "object" && !Array.isArray(t) ? Object.keys(t) : [];
|
|
69073
|
+
};
|
|
69070
69074
|
if (!AQ(l, d, m)) {
|
|
69071
|
-
let e = /[.[]/.test(l) ? l.replace(/[.[][^.[]*$/, "") : "", t = e ? i$(f, e) : f, n = t
|
|
69075
|
+
let e = /[.[]/.test(l) ? l.replace(/[.[][^.[]*$/, "") : "", t = u(e, e ? i$(f, e) : f), n = t.length ? `;父级 "${e || "(root)"}" 的可用字段:${t.slice(0, 12).join(", ")}${t.length > 12 ? " …" : ""}` : "";
|
|
69072
69076
|
return TZ({
|
|
69073
69077
|
code: "PATH_DENIED",
|
|
69074
69078
|
message: `read @ "${l}" 不在 schema 声明字段内`,
|
|
69075
69079
|
hint: `主数据仅暴露 schema 声明的字段;若需操作该字段,集成方需在 schema 中声明它${n}`
|
|
69076
69080
|
});
|
|
69077
69081
|
}
|
|
69078
|
-
let
|
|
69079
|
-
if (l &&
|
|
69080
|
-
let e =
|
|
69081
|
-
|
|
69082
|
-
|
|
69083
|
-
|
|
69084
|
-
|
|
69085
|
-
|
|
69086
|
-
|
|
69082
|
+
let h = l ? i$(f, l) : f;
|
|
69083
|
+
if (l && h === void 0) {
|
|
69084
|
+
let e = MQ(d, l);
|
|
69085
|
+
if (!(e && typeof e.isOptional == "function" && e.isOptional())) {
|
|
69086
|
+
let e = /[.[]/.test(l) ? l.replace(/[.[][^.[]*$/, "") : "", t = e ? i$(f, e) : f, n = u(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 查看顶层字段`;
|
|
69087
|
+
return TZ({
|
|
69088
|
+
code: "PATH_NOT_FOUND",
|
|
69089
|
+
path: l,
|
|
69090
|
+
message: `路径 "${l}" 不存在`,
|
|
69091
|
+
hint: r
|
|
69092
|
+
});
|
|
69093
|
+
}
|
|
69087
69094
|
}
|
|
69088
|
-
if (!l && m)
|
|
69095
|
+
if (!l && m) h = HQ(h, d);
|
|
69089
69096
|
else if (m) {
|
|
69090
69097
|
let e = MQ(d, l);
|
|
69091
|
-
e && (
|
|
69098
|
+
e && (h = HQ(h, e));
|
|
69092
69099
|
}
|
|
69093
|
-
let
|
|
69094
|
-
v && (
|
|
69100
|
+
let g = h;
|
|
69101
|
+
v && (g = J6({
|
|
69095
69102
|
jp: l,
|
|
69096
|
-
resolved:
|
|
69103
|
+
resolved: g,
|
|
69097
69104
|
resourcesByPath: v.resourcesByPath,
|
|
69098
69105
|
resourceStore: v.resourceStore
|
|
69099
|
-
})), T(c, s), n && n.length && (
|
|
69100
|
-
let
|
|
69101
|
-
if ((i !== void 0 || a !== void 0) && Array.isArray(
|
|
69102
|
-
let e =
|
|
69103
|
-
return `${
|
|
69106
|
+
})), T(c, s), n && n.length && (g = l$(g, n)), r != null && (g = u$(g, r)), g = Q6(g, s === "", ee, M);
|
|
69107
|
+
let _ = e ? "" : `主数据说明: ${p}\n格式: 写入值需为 JSON,且通过声明的 schema 校验(校验失败时 write 会返回结构化错误)。字段约束(类型/min/max/enum/必填/默认)见 systemPrompt「可操作数据」段,或用 schema_data({ jsonPath }) 按需查。\n\n`, y = n && n.length ? `(字段裁剪:${n.join(",")})` : "", b = r == null ? "" : `(深度≤${r})`, x = y || b ? ` ${y}${b}` : "";
|
|
69108
|
+
if ((i !== void 0 || a !== void 0) && Array.isArray(g)) {
|
|
69109
|
+
let e = g.length, t = Math.max(0, i == null ? 0 : i), n = Math.min(200, Math.max(1, a == null ? 50 : a)), r = g.slice(t, t + n), o = t + n < e;
|
|
69110
|
+
return `${_}主数据${l ? ` @ ${l}` : ""} 数组分页[offset=${t},limit=${n}]${x} = ${d$(r)} (total=${e}, hasMore=${o}) (hash=${c})`;
|
|
69104
69111
|
}
|
|
69105
|
-
return
|
|
69112
|
+
return g === void 0 ? `${_}主数据${l ? ` @ ${l}` : ""}${x} = (undefined) (hash=${c})` : `${_}主数据${l ? ` @ ${l}` : ""}${x} = ${d$(g)} (hash=${c})`;
|
|
69106
69113
|
}, {
|
|
69107
69114
|
name: "read",
|
|
69108
69115
|
description: "读取主数据(高层入口,合并 describe/get)。不传 jsonPath → 返回主数据说明 + 格式提示(含字段约束);传 jsonPath → 返回该子路径当前值 + hash;传 jsonPaths → 一次读多个不相关子路径(省多轮往返)。hash 用于乐观锁(声明 conflictWatchFields 后 write 自动比对;未声明不自动校验)。fields(字段裁剪)/depth(深度截断)减体积;offset+limit 对数组目标分页(返回切片 + total/hasMore)。",
|