page-agent-sdk 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/dist/page-agent-sdk.iife.js +70 -68
- package/dist/page-agent-sdk.js +107 -106
- package/dist/page-agent-sdk.umd.cjs +18 -16
- package/package.json +1 -1
- package/skills/page-agent-sdk-integrate/SKILL.md +1 -1
- package/skills/page-agent-sdk-integrate/references/api.md +1 -1
- package/skills/page-agent-sdk-integrate/references/options.md +1 -1
- package/types/index.d.ts +1 -1
package/dist/page-agent-sdk.js
CHANGED
|
@@ -42,12 +42,12 @@ var v = process.env.NODE_ENV === "production" ? {} : Object.freeze({}), y = proc
|
|
|
42
42
|
}, he = (e) => {
|
|
43
43
|
let t = N(e) ? Number(e) : NaN;
|
|
44
44
|
return isNaN(t) ? e : t;
|
|
45
|
-
}, ge,
|
|
46
|
-
function
|
|
45
|
+
}, ge, _e = () => ge ||= typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {};
|
|
46
|
+
function B(e) {
|
|
47
47
|
if (O(e)) {
|
|
48
48
|
let t = {};
|
|
49
49
|
for (let n = 0; n < e.length; n++) {
|
|
50
|
-
let r = e[n], i = N(r) ? xe(r) :
|
|
50
|
+
let r = e[n], i = N(r) ? xe(r) : B(r);
|
|
51
51
|
if (i) for (let e in i) t[e] = i[e];
|
|
52
52
|
}
|
|
53
53
|
return t;
|
|
@@ -1179,7 +1179,7 @@ var or = !1, sr = (e) => {
|
|
|
1179
1179
|
or = e;
|
|
1180
1180
|
}
|
|
1181
1181
|
}, cr = /* @__PURE__ */ new Map();
|
|
1182
|
-
process.env.NODE_ENV !== "production" && (
|
|
1182
|
+
process.env.NODE_ENV !== "production" && (_e().__VUE_HMR_RUNTIME__ = {
|
|
1183
1183
|
createRecord: _r(fr),
|
|
1184
1184
|
rerender: _r(mr),
|
|
1185
1185
|
reload: _r(hr)
|
|
@@ -1736,7 +1736,7 @@ function Ai(e) {
|
|
|
1736
1736
|
let t = Oi.get(e);
|
|
1737
1737
|
t && (t.flags |= 8, Oi.delete(e));
|
|
1738
1738
|
}
|
|
1739
|
-
|
|
1739
|
+
_e().requestIdleCallback, _e().cancelIdleCallback;
|
|
1740
1740
|
var ji = (e) => !!e.type.__asyncLoader, Mi = (e) => e.type.__isKeepAlive;
|
|
1741
1741
|
function Ni(e, t) {
|
|
1742
1742
|
Fi(e, "a", t);
|
|
@@ -2573,7 +2573,7 @@ function To(e) {
|
|
|
2573
2573
|
}
|
|
2574
2574
|
function Eo(e, t) {
|
|
2575
2575
|
Co();
|
|
2576
|
-
let n =
|
|
2576
|
+
let n = _e();
|
|
2577
2577
|
n.__VUE__ = !0, process.env.NODE_ENV !== "production" && Sr(n.__VUE_DEVTOOLS_GLOBAL_HOOK__, n);
|
|
2578
2578
|
let { insert: r, remove: i, patchProp: a, createElement: o, createText: s, createComment: c, setText: l, setElementText: u, parentNode: d, nextSibling: f, setScopeId: p = b, insertStaticContent: m } = e, h = (e, t, n, r = null, i = null, a = null, o = void 0, s = null, c = process.env.NODE_ENV !== "production" && or ? !1 : !!t.dynamicChildren) => {
|
|
2579
2579
|
if (e === t) return;
|
|
@@ -3073,7 +3073,7 @@ function es(e, t = null, n = null, r = 0, i = null, a = !1) {
|
|
|
3073
3073
|
if (Rs(e) && (e = e.__vccOpts), t) {
|
|
3074
3074
|
t = ts(t);
|
|
3075
3075
|
let { class: e, style: n } = t;
|
|
3076
|
-
e && !N(e) && (t.class = Se(e)), F(n) && (/* @__PURE__ */ sn(n) && !O(n) && (n = w({}, n)), t.style =
|
|
3076
|
+
e && !N(e) && (t.class = Se(e)), F(n) && (/* @__PURE__ */ sn(n) && !O(n) && (n = w({}, n)), t.style = B(n));
|
|
3077
3077
|
}
|
|
3078
3078
|
let o = N(e) ? 1 : Fo(e) ? 128 : Zr(e) ? 64 : F(e) ? 4 : M(e) ? 2 : 0;
|
|
3079
3079
|
return process.env.NODE_ENV !== "production" && o & 4 && /* @__PURE__ */ sn(e) && (e = /* @__PURE__ */ U(e), G("Vue received a Component that was made a reactive object. This can lead to unnecessary performance overhead and should be avoided by marking the component with `markRaw` or using `shallowRef` instead of `ref`.", "\nComponent that was made reactive: ", e)), Y(e, t, n, r, i, o, a, !0);
|
|
@@ -3161,7 +3161,7 @@ function cs(...e) {
|
|
|
3161
3161
|
for (let n = 0; n < e.length; n++) {
|
|
3162
3162
|
let r = e[n];
|
|
3163
3163
|
for (let e in r) if (e === "class") t.class !== r.class && (t.class = Se([t.class, r.class]));
|
|
3164
|
-
else if (e === "style") t.style =
|
|
3164
|
+
else if (e === "style") t.style = B([t.style, r.style]);
|
|
3165
3165
|
else if (S(e)) {
|
|
3166
3166
|
let n = t[e], i = r[e];
|
|
3167
3167
|
i && n !== i && !(O(n) && n.includes(i)) ? t[e] = n ? [].concat(n, i) : i : i == null && n == null && !C(e) && (t[e] = i);
|
|
@@ -3242,7 +3242,7 @@ function fs(e, t, n) {
|
|
|
3242
3242
|
}
|
|
3243
3243
|
var ps = null, ms = () => ps || Pr, hs, gs;
|
|
3244
3244
|
{
|
|
3245
|
-
let e =
|
|
3245
|
+
let e = _e(), t = (t, n) => {
|
|
3246
3246
|
let r;
|
|
3247
3247
|
return (r = e[t]) || (r = e[t] = []), r.push(n), (e) => {
|
|
3248
3248
|
r.length > 1 ? r.forEach((t) => t(e)) : r[0](e);
|
|
@@ -6054,24 +6054,24 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
6054
6054
|
console.log(`WARN: ${e}`, ...t);
|
|
6055
6055
|
}, ge = (e, t) => {
|
|
6056
6056
|
pe[`${e}/${t}`] || (console.log(`Deprecated as of ${e}. ${t}`), pe[`${e}/${t}`] = !0);
|
|
6057
|
-
},
|
|
6058
|
-
function
|
|
6057
|
+
}, _e = /* @__PURE__ */ Error();
|
|
6058
|
+
function B(e, t, { key: n }) {
|
|
6059
6059
|
let r = 0, i = e[n], a = {}, o = {};
|
|
6060
6060
|
for (let e = 1; e <= t.length; e++) o[e + r] = i[e], a[e + r] = !0, r += b(t[e - 1]);
|
|
6061
6061
|
e[n] = o, e[n]._emit = a, e[n]._multi = !0;
|
|
6062
6062
|
}
|
|
6063
6063
|
function ve(e) {
|
|
6064
6064
|
if (Array.isArray(e.begin)) {
|
|
6065
|
-
if (e.skip || e.excludeBegin || e.returnBegin) throw me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),
|
|
6066
|
-
if (typeof e.beginScope != "object" || e.beginScope === null) throw me("beginScope must be object"),
|
|
6067
|
-
|
|
6065
|
+
if (e.skip || e.excludeBegin || e.returnBegin) throw me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"), _e;
|
|
6066
|
+
if (typeof e.beginScope != "object" || e.beginScope === null) throw me("beginScope must be object"), _e;
|
|
6067
|
+
B(e, e.begin, { key: "beginScope" }), e.begin = C(e.begin, { joinWith: "" });
|
|
6068
6068
|
}
|
|
6069
6069
|
}
|
|
6070
6070
|
function ye(e) {
|
|
6071
6071
|
if (Array.isArray(e.end)) {
|
|
6072
|
-
if (e.skip || e.excludeEnd || e.returnEnd) throw me("skip, excludeEnd, returnEnd not compatible with endScope: {}"),
|
|
6073
|
-
if (typeof e.endScope != "object" || e.endScope === null) throw me("endScope must be object"),
|
|
6074
|
-
|
|
6072
|
+
if (e.skip || e.excludeEnd || e.returnEnd) throw me("skip, excludeEnd, returnEnd not compatible with endScope: {}"), _e;
|
|
6073
|
+
if (typeof e.endScope != "object" || e.endScope === null) throw me("endScope must be object"), _e;
|
|
6074
|
+
B(e, e.end, { key: "endScope" }), e.end = C(e.end, { joinWith: "" });
|
|
6075
6075
|
}
|
|
6076
6076
|
}
|
|
6077
6077
|
function be(e) {
|
|
@@ -11549,7 +11549,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11549
11549
|
contains: [ce],
|
|
11550
11550
|
keywords: [...p, ...f],
|
|
11551
11551
|
end: /}/
|
|
11552
|
-
},
|
|
11552
|
+
}, _e = {
|
|
11553
11553
|
match: [
|
|
11554
11554
|
/class\b/,
|
|
11555
11555
|
/\s+/,
|
|
@@ -11562,7 +11562,7 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11562
11562
|
3: "keyword",
|
|
11563
11563
|
5: "title.function"
|
|
11564
11564
|
}
|
|
11565
|
-
},
|
|
11565
|
+
}, B = {
|
|
11566
11566
|
match: [
|
|
11567
11567
|
/class\b/,
|
|
11568
11568
|
/\s+/,
|
|
@@ -11623,8 +11623,8 @@ var td = /* @__PURE__ */ m(((e, t) => {
|
|
|
11623
11623
|
...a,
|
|
11624
11624
|
pe,
|
|
11625
11625
|
me,
|
|
11626
|
-
B,
|
|
11627
11626
|
_e,
|
|
11627
|
+
B,
|
|
11628
11628
|
ve,
|
|
11629
11629
|
he,
|
|
11630
11630
|
ge,
|
|
@@ -12956,7 +12956,7 @@ app.mount('#app');
|
|
|
12956
12956
|
y.value === "logs" ? (q(), J("div", lf, [(q(), J(K, null, Xi(s, (e, t) => Y("button", {
|
|
12957
12957
|
key: t,
|
|
12958
12958
|
class: Se(["filter-chip", { active: i.value === t }]),
|
|
12959
|
-
style:
|
|
12959
|
+
style: B({ "--chip-color": e.color }),
|
|
12960
12960
|
onClick: (e) => i.value = t
|
|
12961
12961
|
}, [is(V(e.icon) + " " + V(e.label) + " ", 1), Y("span", df, V(u.value[t] || 0), 1)], 14, uf)), 64)), Y("button", {
|
|
12962
12962
|
class: Se(["filter-chip all", { active: i.value === "all" }]),
|
|
@@ -12969,7 +12969,7 @@ app.mount('#app');
|
|
|
12969
12969
|
Y("div", hf, [
|
|
12970
12970
|
Y("span", {
|
|
12971
12971
|
class: "log-type",
|
|
12972
|
-
style:
|
|
12972
|
+
style: B({ background: s[e.type].color })
|
|
12973
12973
|
}, V(s[e.type].icon) + " " + V(s[e.type].label), 5),
|
|
12974
12974
|
e.source ? (q(), J("span", gf, "↳ " + V(e.source), 1)) : X("", !0),
|
|
12975
12975
|
Y("span", _f, V(d(e.timestamp)), 1)
|
|
@@ -12992,7 +12992,7 @@ app.mount('#app');
|
|
|
12992
12992
|
class: "msg-row"
|
|
12993
12993
|
}, [Y("span", {
|
|
12994
12994
|
class: "msg-role",
|
|
12995
|
-
style:
|
|
12995
|
+
style: B({ background: g(e.type).color })
|
|
12996
12996
|
}, V(g(e.type).label), 5), Y("span", jf, V(e.content), 1)]))), 128))])
|
|
12997
12997
|
], 64)) : e.type === "llm_request" ? (q(), J(K, { key: 1 }, [Y("div", Mf, [
|
|
12998
12998
|
Y("span", Nf, "第 " + V(e.data.round) + " 轮", 1),
|
|
@@ -13008,7 +13008,7 @@ app.mount('#app');
|
|
|
13008
13008
|
class: "msg-row"
|
|
13009
13009
|
}, [Y("span", {
|
|
13010
13010
|
class: "msg-role",
|
|
13011
|
-
style:
|
|
13011
|
+
style: B({ background: g(e.role).color })
|
|
13012
13012
|
}, V(g(e.role).label), 5), Y("div", zf, [
|
|
13013
13013
|
e.content ? (q(), J("span", Bf, V(e.content), 1)) : X("", !0),
|
|
13014
13014
|
(q(!0), J(K, null, Xi(e.tool_calls || [], (e, t) => (q(), J("div", {
|
|
@@ -13104,7 +13104,7 @@ app.mount('#app');
|
|
|
13104
13104
|
class: "info-todo"
|
|
13105
13105
|
}, [Y("span", {
|
|
13106
13106
|
class: "todo-tag",
|
|
13107
|
-
style:
|
|
13107
|
+
style: B({ background: S[e.status] && S[e.status].color || "#9ca3af" })
|
|
13108
13108
|
}, V(C(e.status)), 5), Y("span", null, V(e.content), 1)]))), 128))])) : X("", !0),
|
|
13109
13109
|
b.value.memory ? (q(), J("div", wm, [n[28] ||= Y("div", { class: "info-title" }, "📝 持久指令 (memory)", -1), Y("pre", Tm, V(b.value.memory), 1)])) : X("", !0),
|
|
13110
13110
|
b.value.lastCompression ? (q(), J("div", Em, [n[34] ||= Y("div", { class: "info-title" }, "🗜️ 上轮压缩", -1), Y("div", Dm, [
|
|
@@ -17025,6 +17025,7 @@ var hy = [
|
|
|
17025
17025
|
"你是一个 JSON 操作助手。集成方声明了一个主数据对象(含 zod schema 校验),你通过专用工具安全地读写它来完成任务。",
|
|
17026
17026
|
"所有写操作都经范围控制(仅 schema 声明字段内)与 schema 校验(不合法会返回结构化错误而非写入),并自动留快照可回退。",
|
|
17027
17027
|
"大对象/数组优先用增量 patch(只发改动)而非整体重传,避免输出被截断。",
|
|
17028
|
+
"---",
|
|
17028
17029
|
L_.reliableWriteRules
|
|
17029
17030
|
].join("\n\n");
|
|
17030
17031
|
function gy(e) {
|
|
@@ -17105,7 +17106,7 @@ function Ty(e, r) {
|
|
|
17105
17106
|
id: ++a,
|
|
17106
17107
|
resolve: t
|
|
17107
17108
|
};
|
|
17108
|
-
i.value = r,
|
|
17109
|
+
i.value = r, he({
|
|
17109
17110
|
type: "conflict",
|
|
17110
17111
|
conflict: r
|
|
17111
17112
|
});
|
|
@@ -17134,26 +17135,26 @@ function Ty(e, r) {
|
|
|
17134
17135
|
...e.data,
|
|
17135
17136
|
description: e.data.description ?? "主数据对象"
|
|
17136
17137
|
} : void 0, v = e.checkpoint, y = v !== void 0 && v !== !1, b = y ? qg({
|
|
17137
|
-
getData: () =>
|
|
17138
|
+
getData: () => k()?.bind,
|
|
17138
17139
|
slotPaths: _ ? [""] : [],
|
|
17139
17140
|
vfsStore: p,
|
|
17140
17141
|
todosMw: m,
|
|
17141
17142
|
getTodos: () => g.current?.getState?.()?.todos ?? [],
|
|
17142
17143
|
messages: f,
|
|
17143
17144
|
maxCheckpoints: v && typeof v == "object" ? v.maxCheckpoints : void 0
|
|
17144
|
-
}) : null, x = !v || typeof v != "object" || v.auto !== !1, S = e.capabilities, C = S?.dataOps !== !1, w = (e.systemPrompt ?
|
|
17145
|
+
}) : null, x = !v || typeof v != "object" || v.auto !== !1, S = e.capabilities, C = S?.dataOps !== !1, w = e.appendReliableWriteRules !== !1, T = (e.systemPrompt ? w ? e.systemPrompt + "\n\n---\n\n" + L_.reliableWriteRules : e.systemPrompt : hy) + gy(_), E = C && _ ? Iv(_, {
|
|
17145
17146
|
onAudit: e.debug ? (e) => console.log("[page-agent-sdk][data audit]", e) : void 0,
|
|
17146
17147
|
maxSnapshots: e.maxSnapshots,
|
|
17147
17148
|
onConflict: o,
|
|
17148
17149
|
autoLock: e.autoLock,
|
|
17149
17150
|
interceptors: e.interceptors
|
|
17150
|
-
}) : [],
|
|
17151
|
-
|
|
17152
|
-
let
|
|
17153
|
-
|
|
17154
|
-
let
|
|
17155
|
-
|
|
17156
|
-
let
|
|
17151
|
+
}) : [], D = C ? Fv(E, e.toolMode) : [], O = C && _ ? E.controller ?? null : null, k = () => O?.get() ?? _, A = /* @__PURE__ */ new Map(), j = Vv(S, D, Rv);
|
|
17152
|
+
j.forEach((e) => A.set(e.name, "builtin"));
|
|
17153
|
+
let M = [...e.tools || []];
|
|
17154
|
+
M.forEach((e) => A.set(e.name, "user"));
|
|
17155
|
+
let N = e.humanConfirm !== !1 && (!e.approval || e.approval.humanConfirmTool !== !1), P = N ? zg() : null;
|
|
17156
|
+
P && A.set(Lg, "builtin");
|
|
17157
|
+
let F = y && b ? [n(async () => {
|
|
17157
17158
|
let e = b.list();
|
|
17158
17159
|
return e.length ? b.restore() ? `已回退到最近一次正常状态(checkpoint #${e[e.length - 1].id})。对话历史、主数据、vfs、todos 已整体还原。请基于回退后的状态重新判断并继续。` : "回退失败:无可用 checkpoint。" : "无可用 checkpoint,无法回退。";
|
|
17159
17160
|
}, {
|
|
@@ -17168,87 +17169,87 @@ function Ty(e, r) {
|
|
|
17168
17169
|
description: "列出可用会话 checkpoint(回退点)。",
|
|
17169
17170
|
schema: t.object({}).optional()
|
|
17170
17171
|
})] : [];
|
|
17171
|
-
|
|
17172
|
-
let
|
|
17173
|
-
...A,
|
|
17172
|
+
F.forEach((e) => A.set(e.name, "builtin"));
|
|
17173
|
+
let I = [
|
|
17174
17174
|
...j,
|
|
17175
|
-
...
|
|
17176
|
-
...P
|
|
17177
|
-
|
|
17175
|
+
...M,
|
|
17176
|
+
...P ? [P] : [],
|
|
17177
|
+
...F
|
|
17178
|
+
], L = S?.planning !== !1, ee = S?.skills !== !1, R = S?.vfs !== !1, z = S?.summarization !== !1, te = S?.memory !== !1, ne = S?.subagent !== !1, re = e.verify?.maxAttempts ?? 2, ie = S?.verify === !0 && e.verify?.enabled !== !1 && re > 0;
|
|
17178
17179
|
e.verify?.check && S?.verify !== !0 && console.warn("[page-agent-sdk][verify] 检测到 verify.check 但 capabilities.verify 未开启,verify 未装载");
|
|
17179
|
-
let
|
|
17180
|
-
llm:
|
|
17181
|
-
allTools:
|
|
17182
|
-
allowedTools:
|
|
17183
|
-
systemPrompt:
|
|
17184
|
-
temperature:
|
|
17185
|
-
maxTokens:
|
|
17186
|
-
skills:
|
|
17187
|
-
maxDepth:
|
|
17188
|
-
maxParallel:
|
|
17180
|
+
let ae = e.subagent, oe = ae?.allowedTools ?? [], se = !ne || ae?.enabled === !1 ? void 0 : n_({
|
|
17181
|
+
llm: ae?.llm ?? e.llm,
|
|
17182
|
+
allTools: I,
|
|
17183
|
+
allowedTools: oe.length ? oe : void 0,
|
|
17184
|
+
systemPrompt: ae?.systemPrompt,
|
|
17185
|
+
temperature: ae?.temperature,
|
|
17186
|
+
maxTokens: ae?.maxTokens,
|
|
17187
|
+
skills: ae?.skills,
|
|
17188
|
+
maxDepth: ae?.maxDepth,
|
|
17189
|
+
maxParallel: ae?.maxParallel,
|
|
17189
17190
|
debug: e.debug
|
|
17190
|
-
}),
|
|
17191
|
+
}), ce = e.subagents?.length ? a_(e.subagents, {
|
|
17191
17192
|
llm: e.llm,
|
|
17192
|
-
allTools:
|
|
17193
|
+
allTools: I,
|
|
17193
17194
|
debug: e.debug
|
|
17194
|
-
}) : void 0,
|
|
17195
|
+
}) : void 0, le = [
|
|
17195
17196
|
"get_data",
|
|
17196
17197
|
"describe_data",
|
|
17197
17198
|
"read",
|
|
17198
17199
|
"fetch_document"
|
|
17199
|
-
],
|
|
17200
|
+
], ue = I.filter((e) => le.includes(e.name)), de = ie ? o_({
|
|
17200
17201
|
check: e.verify.check ?? f_({
|
|
17201
|
-
schemas: () =>
|
|
17202
|
-
root: () =>
|
|
17202
|
+
schemas: () => k() ? { "": k().schema } : {},
|
|
17203
|
+
root: () => k()?.bind
|
|
17203
17204
|
}),
|
|
17204
17205
|
adversarial: e.verify?.adversarial ? {
|
|
17205
17206
|
llm: e.llm,
|
|
17206
|
-
tools:
|
|
17207
|
+
tools: ue
|
|
17207
17208
|
} : void 0
|
|
17208
|
-
}) : void 0,
|
|
17209
|
+
}) : void 0, fe = Uv({
|
|
17209
17210
|
...S,
|
|
17210
|
-
humanConfirm:
|
|
17211
|
+
humanConfirm: N,
|
|
17211
17212
|
subagents: e.subagents?.map((e) => ({
|
|
17212
17213
|
id: e.id,
|
|
17213
17214
|
description: e.description,
|
|
17214
17215
|
temperature: e.temperature
|
|
17215
17216
|
}))
|
|
17216
|
-
}, C && !!_, e.toolMode),
|
|
17217
|
+
}, C && !!_, e.toolMode), pe = e.onEvent, me = /* @__PURE__ */ new Set(), he = (e) => {
|
|
17217
17218
|
if (e.type !== "approval_request") {
|
|
17218
|
-
if (
|
|
17219
|
-
|
|
17219
|
+
if (pe) try {
|
|
17220
|
+
pe(e);
|
|
17220
17221
|
} catch {}
|
|
17221
|
-
for (let t of
|
|
17222
|
+
for (let t of me) try {
|
|
17222
17223
|
t(e);
|
|
17223
17224
|
} catch {}
|
|
17224
17225
|
}
|
|
17225
|
-
},
|
|
17226
|
-
|
|
17227
|
-
...
|
|
17228
|
-
...
|
|
17229
|
-
...
|
|
17230
|
-
...
|
|
17226
|
+
}, ge = [
|
|
17227
|
+
fe,
|
|
17228
|
+
...L ? [m] : [],
|
|
17229
|
+
...ee ? [kg(e.skills || [], { readVfs: R ? (e) => p.files[e]?.content : void 0 })] : [],
|
|
17230
|
+
...R ? [Q_(p)] : [],
|
|
17231
|
+
...z ? [F_({
|
|
17231
17232
|
...B_(e, u.contextWindow),
|
|
17232
17233
|
llmInvoke: d,
|
|
17233
|
-
getRegisteredData: () =>
|
|
17234
|
+
getRegisteredData: () => k() ? [{ description: k().description ?? "主数据对象" }] : [],
|
|
17234
17235
|
preserveLastToolResults: (e.contextOptions && e.contextOptions.preserveLastToolResults) ?? ["describe_data", "read"]
|
|
17235
17236
|
})] : [],
|
|
17236
|
-
...
|
|
17237
|
+
...te ? [h] : [],
|
|
17237
17238
|
...e.permissions?.length ? [Fg(e.permissions)] : [],
|
|
17238
17239
|
...y && x && b ? [Jg(b)] : [],
|
|
17239
|
-
...
|
|
17240
|
+
...N ? [Bg()] : [],
|
|
17240
17241
|
...e.approval && (e.approval.tools !== void 0 || e.approval.confirm) ? [Ig(e.approval)] : [],
|
|
17241
|
-
...
|
|
17242
|
-
...oe ? [oe] : [],
|
|
17242
|
+
...de ? [de] : [],
|
|
17243
17243
|
...se ? [se] : [],
|
|
17244
|
+
...ce ? [ce] : [],
|
|
17244
17245
|
...e.middleware || [],
|
|
17245
|
-
wy(
|
|
17246
|
-
],
|
|
17246
|
+
wy(he, f, k)
|
|
17247
|
+
], _e = e.maxMemoryRounds ?? _y, B = {
|
|
17247
17248
|
agentId: r,
|
|
17248
17249
|
store: c,
|
|
17249
17250
|
messages: f,
|
|
17250
17251
|
vfsStore: p,
|
|
17251
|
-
listeners:
|
|
17252
|
+
listeners: me,
|
|
17252
17253
|
todosMw: m,
|
|
17253
17254
|
memoryMw: h,
|
|
17254
17255
|
agent: null,
|
|
@@ -17258,14 +17259,14 @@ function Ty(e, r) {
|
|
|
17258
17259
|
mcpClosers: [],
|
|
17259
17260
|
mcpServers: [],
|
|
17260
17261
|
checkpoint: b,
|
|
17261
|
-
dataOpsController:
|
|
17262
|
+
dataOpsController: O,
|
|
17262
17263
|
pendingConflict: i,
|
|
17263
|
-
liveData:
|
|
17264
|
+
liveData: k,
|
|
17264
17265
|
applySnapshot(t) {
|
|
17265
17266
|
t.messages?.length && f.push(...t.messages), t.vfs && p.hydrate && p.hydrate(t.vfs), t.todos?.length && m.reset(t.todos), t.memory && !e.memory && h.reset(t.memory);
|
|
17266
17267
|
},
|
|
17267
17268
|
afterRound() {
|
|
17268
|
-
|
|
17269
|
+
ye(), be();
|
|
17269
17270
|
},
|
|
17270
17271
|
async send(t) {
|
|
17271
17272
|
await B.initDone;
|
|
@@ -17291,7 +17292,7 @@ function Ty(e, r) {
|
|
|
17291
17292
|
timestamp: Date.now()
|
|
17292
17293
|
}), B.afterRound(), c && await c.flush(), t;
|
|
17293
17294
|
} catch (e) {
|
|
17294
|
-
throw
|
|
17295
|
+
throw he({
|
|
17295
17296
|
type: "error",
|
|
17296
17297
|
message: e?.message || String(e)
|
|
17297
17298
|
}), e;
|
|
@@ -17305,8 +17306,8 @@ function Ty(e, r) {
|
|
|
17305
17306
|
},
|
|
17306
17307
|
stream: (e, t, n) => {
|
|
17307
17308
|
if (!B.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
17308
|
-
let r =
|
|
17309
|
-
t?.(e),
|
|
17309
|
+
let r = pe ? (e) => {
|
|
17310
|
+
t?.(e), he(e);
|
|
17310
17311
|
} : t;
|
|
17311
17312
|
if (n) {
|
|
17312
17313
|
let e = () => s("keep_external");
|
|
@@ -17326,37 +17327,37 @@ function Ty(e, r) {
|
|
|
17326
17327
|
return {
|
|
17327
17328
|
id: r,
|
|
17328
17329
|
model: yy(e.llm) ? e.llm.model ?? e.llm.modelName : e.llm.model,
|
|
17329
|
-
systemPrompt:
|
|
17330
|
-
tools:
|
|
17330
|
+
systemPrompt: T,
|
|
17331
|
+
tools: I.map((e) => ({
|
|
17331
17332
|
name: e.name,
|
|
17332
17333
|
description: e.description,
|
|
17333
17334
|
schema: e.schema,
|
|
17334
|
-
source:
|
|
17335
|
+
source: A.get(e.name) || "user"
|
|
17335
17336
|
})),
|
|
17336
17337
|
skills: (e.skills ?? []).map((e) => ({
|
|
17337
17338
|
name: e.name,
|
|
17338
17339
|
description: e.description
|
|
17339
17340
|
})),
|
|
17340
|
-
data:
|
|
17341
|
-
description:
|
|
17342
|
-
schema:
|
|
17341
|
+
data: k() ? {
|
|
17342
|
+
description: k().description,
|
|
17343
|
+
schema: k().schema
|
|
17343
17344
|
} : void 0,
|
|
17344
17345
|
memory: e.memory ?? "",
|
|
17345
|
-
middleware:
|
|
17346
|
+
middleware: ge.map((e) => e.name),
|
|
17346
17347
|
todos: (B.agent?.getState?.()?.todos ?? []).map((e) => ({
|
|
17347
17348
|
content: e.content,
|
|
17348
17349
|
status: e.status
|
|
17349
17350
|
})),
|
|
17350
17351
|
subagent: {
|
|
17351
|
-
enabled: !!
|
|
17352
|
+
enabled: !!se,
|
|
17352
17353
|
maxDepth: e.subagent?.maxDepth ?? 1,
|
|
17353
17354
|
maxParallel: e.subagent?.maxParallel ?? 4,
|
|
17354
17355
|
allowedTools: e.subagent?.allowedTools ?? []
|
|
17355
17356
|
},
|
|
17356
17357
|
verify: {
|
|
17357
|
-
enabled: !!
|
|
17358
|
-
maxAttempts:
|
|
17359
|
-
adversarial:
|
|
17358
|
+
enabled: !!de,
|
|
17359
|
+
maxAttempts: ie ? re : 0,
|
|
17360
|
+
adversarial: ie && !!e.verify?.adversarial
|
|
17360
17361
|
},
|
|
17361
17362
|
mcp: { servers: B.mcpServers },
|
|
17362
17363
|
lastCompression: B.agent?.getState?.()?.lastCompression,
|
|
@@ -17368,7 +17369,7 @@ function Ty(e, r) {
|
|
|
17368
17369
|
};
|
|
17369
17370
|
}
|
|
17370
17371
|
};
|
|
17371
|
-
async function
|
|
17372
|
+
async function ve() {
|
|
17372
17373
|
if (!c) return;
|
|
17373
17374
|
await c.ready;
|
|
17374
17375
|
let t = e.session || {};
|
|
@@ -17386,11 +17387,11 @@ function Ty(e, r) {
|
|
|
17386
17387
|
} else B.sessionId = await c.createSession(r, t.title);
|
|
17387
17388
|
e.memory && c.save(r, B.sessionId, { memory: e.memory });
|
|
17388
17389
|
}
|
|
17389
|
-
function
|
|
17390
|
-
let e = E_(f,
|
|
17390
|
+
function ye() {
|
|
17391
|
+
let e = E_(f, _e);
|
|
17391
17392
|
e.trimmed && f.splice(e.deleteFrom, e.deleteCount, e.summary);
|
|
17392
17393
|
}
|
|
17393
|
-
function
|
|
17394
|
+
function be() {
|
|
17394
17395
|
if (!B.sessionId || !c) return;
|
|
17395
17396
|
let t = JSON.parse(JSON.stringify(f));
|
|
17396
17397
|
c.save(r, B.sessionId, { messages: t });
|
|
@@ -17398,7 +17399,7 @@ function Ty(e, r) {
|
|
|
17398
17399
|
c.save(r, B.sessionId, { todos: n }), e.debug && console.log("[page-agent-sdk][persist] save", B.sessionId, `${f.length} msgs`);
|
|
17399
17400
|
}
|
|
17400
17401
|
return B.initDone = (async () => {
|
|
17401
|
-
if (await
|
|
17402
|
+
if (await ve(), e.mcp?.length) {
|
|
17402
17403
|
let t = await Promise.allSettled(e.mcp.map((e) => S_(e)));
|
|
17403
17404
|
B.mcpClosers = t.flatMap((e) => e.status === "fulfilled" ? [e.value.close] : []), B.mcpServers = [];
|
|
17404
17405
|
let n = [];
|
|
@@ -17408,8 +17409,8 @@ function Ty(e, r) {
|
|
|
17408
17409
|
name: a,
|
|
17409
17410
|
url: i.url,
|
|
17410
17411
|
toolCount: t.value.tools.length
|
|
17411
|
-
}), t.value.tools.forEach((e) =>
|
|
17412
|
-
}),
|
|
17412
|
+
}), t.value.tools.forEach((e) => A.set(e.name, `mcp:${a}`)), n.push(...t.value.tools)) : console.warn(`[page-agent-sdk][mcp] server ${a} 连接失败:`, t.reason);
|
|
17413
|
+
}), I.push(...n), e.debug && console.log(`[page-agent-sdk][mcp] 注入 ${n.length} 个工具,${B.mcpServers.length} 个 server`);
|
|
17413
17414
|
}
|
|
17414
17415
|
B.agent = bg({
|
|
17415
17416
|
...yy(e.llm) ? { llm: e.llm } : {
|
|
@@ -17419,15 +17420,15 @@ function Ty(e, r) {
|
|
|
17419
17420
|
temperature: e.llm.temperature,
|
|
17420
17421
|
maxTokens: e.llm.maxTokens
|
|
17421
17422
|
},
|
|
17422
|
-
systemPrompt:
|
|
17423
|
-
tools:
|
|
17424
|
-
middleware:
|
|
17423
|
+
systemPrompt: T,
|
|
17424
|
+
tools: I,
|
|
17425
|
+
middleware: ge,
|
|
17425
17426
|
maxToolRounds: e.maxToolRounds,
|
|
17426
17427
|
maxRetries: e.maxRetries,
|
|
17427
17428
|
maxParallelTools: e.maxParallelTools,
|
|
17428
17429
|
contextWindow: u.contextWindow,
|
|
17429
17430
|
maxOutputTokens: u.maxOutputTokens,
|
|
17430
|
-
maxVerifyAttempts:
|
|
17431
|
+
maxVerifyAttempts: ie ? re : 0,
|
|
17431
17432
|
debug: e.debug
|
|
17432
17433
|
}), g.current = B.agent;
|
|
17433
17434
|
})(), B;
|