page-agent-sdk 3.0.0 → 3.1.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 +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/page-agent-sdk.headless.js +31 -3
- package/dist/page-agent-sdk.iife.js +96 -96
- package/dist/page-agent-sdk.js +859 -816
- package/dist/page-agent-sdk.umd.cjs +54 -54
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -528,7 +528,7 @@ function switchTo(i: number) {
|
|
|
528
528
|
|
|
529
529
|
```bash
|
|
530
530
|
npm test # 1801 assertions (tsx, source-level; no LLM dependency)
|
|
531
|
-
npm run test:e2e #
|
|
531
|
+
npm run test:e2e # 521 integration assertions (node, built dist; covers APIs/options/modules/simple&complex scenes: default systemPrompt(capability overview) / dynamic register + inspect sync / inspect(tools/middleware/subagent/verify/mcp/todos/lastCompression/checkpoints reflect config) / custom tools/middleware/skills/memory injection / runtime dynamic reconfiguration(setTools/addTool/removeTool/setLlm/setMemory/setSubagents reflect) / switchSession(on/off) / shareContext on/off sharing/independent / storage backends + object config / presets(3) / checkpoint / exports complete(39+ fns/components) / util fns usable(isQuotaError/estimateTokens/jpEval/searchJson) / source=builtin / mount boundary / hook multi-listener / llm config / hide/show / error scenes)
|
|
532
532
|
```
|
|
533
533
|
|
|
534
534
|
## Local npm package test
|
package/README.zh-CN.md
CHANGED
|
@@ -473,7 +473,7 @@ function switchTo(i: number) {
|
|
|
473
473
|
|
|
474
474
|
```bash
|
|
475
475
|
npm test # 1801 项断言(tsx 源码级,不依赖 LLM)
|
|
476
|
-
npm run test:e2e #
|
|
476
|
+
npm run test:e2e # 521 项集成断言(node 跑构建产物 dist;覆盖各 API/配置项/功能模块/简单与复杂场景:默认 systemPrompt(含能力概述) / 动态注册与 inspect 同步 / inspect(tools/middleware/subagent/verify/mcp/todos/lastCompression/checkpoints 反映配置) / 自定义 tools/middleware/skills/memory 注入 / 运行时动态重配置(setTools/addTool/removeTool/setLlm/setMemory/setSubagents 反映) / switchSession(开/未开) / shareContext 开/关共享独立 / storage 后端+对象配置 / presets 三预设 / checkpoint / 导出项完整(39+ 函数/组件) / 工具函数可用(isQuotaError/estimateTokens/jpEval/searchJson) / source=builtin / mount 边界 / hook 多监听器 / llm 配置 / 错误场景)
|
|
477
477
|
```
|
|
478
478
|
|
|
479
479
|
## 本地 npm 包测试
|
|
@@ -4465,7 +4465,7 @@ async function Ho(e, t, n, r, i, a) {
|
|
|
4465
4465
|
a?.(e);
|
|
4466
4466
|
return;
|
|
4467
4467
|
}
|
|
4468
|
-
r && (e.type === "tool_call" || e.type === "tool_result") && r(e);
|
|
4468
|
+
r && (e.type === "tool_call" || e.type === "tool_result" || e.type === "reasoning") && r(e);
|
|
4469
4469
|
}, x.signal);
|
|
4470
4470
|
if (!t.timeoutMs || t.timeoutMs <= 0) try {
|
|
4471
4471
|
return await w;
|
|
@@ -4486,6 +4486,17 @@ async function Ho(e, t, n, r, i, a) {
|
|
|
4486
4486
|
}
|
|
4487
4487
|
function Uo(e) {
|
|
4488
4488
|
let n = e.maxParallel ?? jo, i, a, o, s = (t, n) => (r) => {
|
|
4489
|
+
if (r.type === "reasoning") {
|
|
4490
|
+
a?.({
|
|
4491
|
+
type: "subagent",
|
|
4492
|
+
taskId: t,
|
|
4493
|
+
label: n,
|
|
4494
|
+
kind: "reasoning",
|
|
4495
|
+
name: "",
|
|
4496
|
+
delta: r.delta
|
|
4497
|
+
});
|
|
4498
|
+
return;
|
|
4499
|
+
}
|
|
4489
4500
|
e.tracker?.pushStep(t, {
|
|
4490
4501
|
kind: r.type,
|
|
4491
4502
|
name: r.name,
|
|
@@ -4594,6 +4605,17 @@ function Go(e, t) {
|
|
|
4594
4605
|
}
|
|
4595
4606
|
function Ko(e, n) {
|
|
4596
4607
|
let i, a, o, s = (e, t) => (n) => {
|
|
4608
|
+
if (n.type === "reasoning") {
|
|
4609
|
+
a?.({
|
|
4610
|
+
type: "subagent",
|
|
4611
|
+
taskId: e,
|
|
4612
|
+
label: t,
|
|
4613
|
+
kind: "reasoning",
|
|
4614
|
+
name: "",
|
|
4615
|
+
delta: n.delta
|
|
4616
|
+
});
|
|
4617
|
+
return;
|
|
4618
|
+
}
|
|
4597
4619
|
a && a({
|
|
4598
4620
|
type: "subagent",
|
|
4599
4621
|
taskId: e,
|
|
@@ -4622,7 +4644,7 @@ function Ko(e, n) {
|
|
|
4622
4644
|
...e,
|
|
4623
4645
|
source: `子:${d.id}`
|
|
4624
4646
|
}), c = n.tracker, l = c ? `use_${d.id}-${Math.random().toString(36).slice(2, 6)}` : `use_${d.id}`, u = s(`use_${d.id}`, d.id), f = c ? (e) => {
|
|
4625
|
-
c.pushStep(l, {
|
|
4647
|
+
e.type !== "reasoning" && c.pushStep(l, {
|
|
4626
4648
|
kind: e.type,
|
|
4627
4649
|
name: e.name,
|
|
4628
4650
|
ts: Date.now()
|
|
@@ -9442,7 +9464,7 @@ function Du(e, n) {
|
|
|
9442
9464
|
if (!G.agent) throw Error("page-agent-sdk: agent 尚未初始化完成,请先 await mount()");
|
|
9443
9465
|
x?.setProtectedRefs?.(yu(e));
|
|
9444
9466
|
let r = (e) => {
|
|
9445
|
-
t?.(e), W(e)
|
|
9467
|
+
t?.(e), W(e), e.type === "subagent" && (e.kind === "tool_call" || e.kind === "tool_result") && G.infoTick.value++;
|
|
9446
9468
|
};
|
|
9447
9469
|
if (n) {
|
|
9448
9470
|
let e = () => a.resolve("keep_external");
|
|
@@ -10392,12 +10414,18 @@ function Yu(e = {}) {
|
|
|
10392
10414
|
case "tool_result":
|
|
10393
10415
|
for (let n = t.steps.length - 1; n >= 0; n--) if (t.steps[n].name === e.name && t.steps[n].status === "running") {
|
|
10394
10416
|
t.steps[n].result = e.result, t.steps[n].status = e.status, t.steps[n].durationMs = e.durationMs;
|
|
10417
|
+
let r = t.steps[n].subReason;
|
|
10418
|
+
r && r.length > 80 && (t.steps[n].subReason = r.slice(0, 80) + "…");
|
|
10395
10419
|
break;
|
|
10396
10420
|
}
|
|
10397
10421
|
break;
|
|
10398
10422
|
case "subagent": {
|
|
10399
10423
|
let n = t.steps[t.steps.length - 1];
|
|
10400
10424
|
if (!n) break;
|
|
10425
|
+
if (e.kind === "reasoning") {
|
|
10426
|
+
n.subReason = (n.subReason || "") + (e.delta || "");
|
|
10427
|
+
break;
|
|
10428
|
+
}
|
|
10401
10429
|
n.children ||= [];
|
|
10402
10430
|
let r = e.label ? `[${e.label}] ${e.name}` : e.name;
|
|
10403
10431
|
if (e.kind === "tool_call") n.children.push({
|