page-agent-sdk 3.12.0 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -8
- package/README.zh-CN.md +6 -7
- package/dist/page-agent-sdk.headless.js +1013 -819
- package/dist/page-agent-sdk.iife.js +146 -146
- package/dist/page-agent-sdk.js +1992 -1792
- package/dist/page-agent-sdk.umd.cjs +63 -63
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/types/headless.d.ts +2 -0
- package/types/index.d.ts +2 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/page-agent-sdk)
|
|
10
10
|
[](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
|
|
11
|
-
[](#self-tests)
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -230,7 +230,7 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, DebugDrawer, useChat
|
|
|
230
230
|
| **Persistence** | `storage` | `'indexed' \| 'session' \| 'local' \| 'memory' \| config \| false` · default off | Assign to enable; multi-agent isolated by `id` |
|
|
231
231
|
| | `session` | `{id?,autoResume?,title?}` | Session control |
|
|
232
232
|
| | `shareContext` | `boolean` · default `false` | Same `id` instances share one agent |
|
|
233
|
-
| **Robustness/other** | `maxRetries` / `maxParallelTools` / `maxToolRounds` | `number` · 2 / 1 / 10 | Model retries / per-round tool concurrency / max rounds |
|
|
233
|
+
| **Robustness/other** | `maxRetries` / `maxParallelTools` / `maxToolRounds` | `number` · 2 / 1 / 10 | Model retries / per-round tool concurrency (>1 enables same-round parallel delegation with failure isolation + per-component mutex locks) / max rounds |
|
|
234
234
|
| | `roundTokenBudget` | `number` · default `0` (off) | Per-invocation cumulative token cap (3.11+; exceed → friendly wrap-up, partial work preserved; orthogonal to automation's `tokenBudget`, no automation capability needed) |
|
|
235
235
|
| | `mcp` | `McpServerConfig[]` | Remote MCP servers (http/sse/websocket) |
|
|
236
236
|
| | `middleware` | `Middleware[]` | Custom middleware (appended to built-in stack) |
|
|
@@ -300,7 +300,7 @@ src/core/
|
|
|
300
300
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
301
301
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
302
302
|
└── types/index.ts index.ts # types / sole library entry
|
|
303
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo /
|
|
303
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / toolsets-demo / proxy-demo
|
|
304
304
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
305
305
|
CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
|
|
306
306
|
```
|
|
@@ -357,7 +357,7 @@ src/core/
|
|
|
357
357
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
358
358
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
359
359
|
└── types/index.ts index.ts # types / sole library entry
|
|
360
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo /
|
|
360
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / toolsets-demo / proxy-demo
|
|
361
361
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
362
362
|
CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
|
|
363
363
|
```
|
|
@@ -483,7 +483,7 @@ After `npm run dev`, visit the corresponding page:
|
|
|
483
483
|
| Example | Entry | Demonstrates |
|
|
484
484
|
|---|---|---|
|
|
485
485
|
| minimal-demo | `/examples/minimal-demo/` | Minimal: 5-line chat dialog, no data ops |
|
|
486
|
-
| rag-demo | `/examples/rag-demo/` | RAG
|
|
486
|
+
| rag-demo | `/examples/rag-demo/` | RAG/MCP, 4 modes: A `memory` async fn load/switch KB · B `createRagSubagent` mock retriever · C subagent + real MCP (`VITE_RAG_MCP_URL`) · D MCP direct inject (`npm run mcp:mock` fallback) |
|
|
487
487
|
| headless-demo | `/examples/headless-demo/` | Headless: `ui:false` + self-built UI via `sdk.messages`/`sdk.send` |
|
|
488
488
|
| page-demo | `/` | Self-bootstrapping demo: left JSON reactive page + right chat |
|
|
489
489
|
| nested-demo | `/examples/nested-demo/` | Nested block tree + human confirm + checkpoint |
|
|
@@ -491,7 +491,6 @@ After `npm run dev`, visit the corresponding page:
|
|
|
491
491
|
| human-confirm-demo | `/examples/human-confirm-demo/` | AI proactive inquiry (multi-plan pick) + pre-write confirm |
|
|
492
492
|
| planner-demo | `/examples/planner-demo/` | Plan-reflect-execute (high-temp creative planner + low-temp reflector) |
|
|
493
493
|
| subagent-demo | `/examples/subagent-demo/` | Subagent parallel orchestration |
|
|
494
|
-
| mcp-demo | `/examples/mcp-demo/` | MCP remote tools (needs `npm run mcp:mock`) |
|
|
495
494
|
| animation-demo | `/examples/animation-demo/` | ChatDialog enter/collapse/unmount animations + inline/drawer + hide/show |
|
|
496
495
|
| multi-agent-demo | `/examples/multi-agent-demo/` | Multi-agent parallel + exclusive switch (3 independent agents, drawer hide/show keeps each history) |
|
|
497
496
|
| proxy-demo | `/examples/proxy-demo/` | LLM connection config: proxy to prevent apiKey leakage (browser holds only userToken, proxy injects real key; auto-refresh on expired token; needs `npm run proxy:mock`) + Provider switch (`provider:'anthropic'` for Claude native protocol, streaming + extended thinking) |
|
|
@@ -529,8 +528,8 @@ function switchTo(i: number) {
|
|
|
529
528
|
## Self-tests
|
|
530
529
|
|
|
531
530
|
```bash
|
|
532
|
-
npm test #
|
|
533
|
-
npm run test:e2e #
|
|
531
|
+
npm test # 2098 assertions (tsx, source-level; no LLM dependency)
|
|
532
|
+
npm run test:e2e # 666 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)
|
|
534
533
|
```
|
|
535
534
|
|
|
536
535
|
## Local npm package test
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/page-agent-sdk)
|
|
10
10
|
[](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
|
|
11
|
-
[](#自测)
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -226,7 +226,7 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, DebugDrawer, useChat
|
|
|
226
226
|
| **持久化** | `storage` | `'indexed' \| 'session' \| 'local' \| 'memory' \| 配置 \| false` · 默认关 | 赋值开启;多 agent 靠 `id` 隔离 |
|
|
227
227
|
| | `session` | `{id?,autoResume?,title?}` | 会话控制 |
|
|
228
228
|
| | `shareContext` | `boolean` · 默认 `false` | 同 `id` 多实例共享同一 agent |
|
|
229
|
-
| **鲁棒/其他** | `maxRetries` / `maxParallelTools` / `maxToolRounds` | `number` · 2 / 1 / 10 | 模型重试 / 同轮工具并发 / 最大轮次 |
|
|
229
|
+
| **鲁棒/其他** | `maxRetries` / `maxParallelTools` / `maxToolRounds` | `number` · 2 / 1 / 10 | 模型重试 / 同轮工具并发(>1 启用同轮并行委派,失败隔离 + 同组件锁互斥)/ 最大轮次 |
|
|
230
230
|
| | `roundTokenBudget` | `number` · 默认 `0`(关) | 单次调用累计 token 上限(3.11+;超限友好收口,已完成部分保留;与 automation 的 `tokenBudget` 正交,无需开 automation) |
|
|
231
231
|
| | `mcp` | `McpServerConfig[]` | 远程 MCP server(http/sse/websocket) |
|
|
232
232
|
| | `middleware` | `Middleware[]` | 自定义中间件(拼到内置栈末尾) |
|
|
@@ -302,7 +302,7 @@ src/core/
|
|
|
302
302
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
303
303
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
304
304
|
└── types/index.ts index.ts # 类型 / 库唯一入口
|
|
305
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo /
|
|
305
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / toolsets-demo / proxy-demo
|
|
306
306
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
307
307
|
CLAUDE.md # 架构要点 + 约定坑 + 编码规范(agent 必读)
|
|
308
308
|
```
|
|
@@ -428,7 +428,7 @@ createChatSdk({
|
|
|
428
428
|
| 示例 | 入口 | 演示 |
|
|
429
429
|
|---|---|---|
|
|
430
430
|
| minimal-demo | `/examples/minimal-demo/` | 最简集成:5 行加 AI 对话框,无数据操作 |
|
|
431
|
-
| rag-demo | `/examples/rag-demo/` | RAG
|
|
431
|
+
| rag-demo | `/examples/rag-demo/` | RAG / MCP 四模式:A `memory` 异步函数加载/切库 · B `createRagSubagent` mock 检索 · C 子 agent + 真实 MCP(`VITE_RAG_MCP_URL`)· D MCP 直连注入(mock fallback:`npm run mcp:mock`)|
|
|
432
432
|
| headless-demo | `/examples/headless-demo/` | Headless:`ui:false` + 自建 UI(`sdk.messages`/`sdk.send`) |
|
|
433
433
|
| page-demo | `/` | 自举 demo:左 JSON 响应式页面 + 右对话框 |
|
|
434
434
|
| nested-demo | `/examples/nested-demo/` | 嵌套区块树 + 人工确认 + checkpoint |
|
|
@@ -436,7 +436,6 @@ createChatSdk({
|
|
|
436
436
|
| human-confirm-demo | `/examples/human-confirm-demo/` | AI 主动征询(多方案点选)+ 写前确认 |
|
|
437
437
|
| planner-demo | `/examples/planner-demo/` | 规划-反思-执行(高温创意 planner + 低温 reflector) |
|
|
438
438
|
| subagent-demo | `/examples/subagent-demo/` | 子 agent 并行编排 |
|
|
439
|
-
| mcp-demo | `/examples/mcp-demo/` | MCP 远程工具(需 `npm run mcp:mock`) |
|
|
440
439
|
| animation-demo | `/examples/animation-demo/` | ChatDialog 入场/收起/卸载动画 + inline/drawer 模式 + hide/show |
|
|
441
440
|
| multi-agent-demo | `/examples/multi-agent-demo/` | 多 Agent 并行 + 互斥切换(三独立 agent,drawer hide/show 保留各自历史) |
|
|
442
441
|
| proxy-demo | `/examples/proxy-demo/` | LLM 连接配置:代理防 apiKey 泄露(浏览器只持 userToken,代理注入真实 key;含 token 过期自动刷新;需 `npm run proxy:mock`)+ Provider 切换(`provider:'anthropic'` 走 Claude 原生协议,流式 + extended thinking) |
|
|
@@ -474,8 +473,8 @@ function switchTo(i: number) {
|
|
|
474
473
|
## 自测
|
|
475
474
|
|
|
476
475
|
```bash
|
|
477
|
-
npm test #
|
|
478
|
-
npm run test:e2e #
|
|
476
|
+
npm test # 2098 项断言(tsx 源码级,不依赖 LLM)
|
|
477
|
+
npm run test:e2e # 666 项集成断言(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 配置 / 错误场景)
|
|
479
478
|
```
|
|
480
479
|
|
|
481
480
|
## 本地 npm 包测试
|