page-agent-sdk 2.10.3 → 2.11.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 +6 -3
- package/README.zh-CN.md +5 -2
- package/dist/page-agent-sdk.iife.js +122 -122
- package/dist/page-agent-sdk.js +3102 -3047
- package/dist/page-agent-sdk.umd.cjs +66 -66
- package/package.json +2 -1
- package/skills/page-agent-sdk-integrate/references/api.md +42 -0
- package/skills/page-agent-sdk-integrate/references/integration-prompt.md +4 -0
- package/skills/page-agent-sdk-integrate/references/quickstart.md +34 -0
- package/types/index.d.ts +15 -0
package/README.md
CHANGED
|
@@ -137,6 +137,8 @@ The core of letting AI safely edit JSON is a **three-layer decoupled split** —
|
|
|
137
137
|
```ts
|
|
138
138
|
// entry & tool construction
|
|
139
139
|
createChatSdk, defineTool, defineSkill, presets, z
|
|
140
|
+
// proxy connection (prevent apiKey leakage: proxy mode / direct mode)
|
|
141
|
+
createProxyLlm
|
|
140
142
|
// harness & middleware (custom orchestration)
|
|
141
143
|
createAgent, createSubagentMiddleware, createSubagentsMiddleware,
|
|
142
144
|
createVerifyMiddleware, createWriteBackCheck, createApprovalMiddleware,
|
|
@@ -245,7 +247,7 @@ src/core/
|
|
|
245
247
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
246
248
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
247
249
|
└── types/index.ts index.ts # types / sole library entry
|
|
248
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
|
|
250
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo / proxy-demo
|
|
249
251
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
250
252
|
CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
|
|
251
253
|
```
|
|
@@ -300,7 +302,7 @@ src/core/
|
|
|
300
302
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
301
303
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
302
304
|
└── types/index.ts index.ts # types / sole library entry
|
|
303
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
|
|
305
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo / proxy-demo
|
|
304
306
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
305
307
|
CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
|
|
306
308
|
```
|
|
@@ -422,6 +424,7 @@ After `npm run dev`, visit the corresponding page:
|
|
|
422
424
|
| mcp-demo | `/examples/mcp-demo/` | MCP remote tools (needs `npm run mcp:mock`) |
|
|
423
425
|
| animation-demo | `/examples/animation-demo/` | ChatDialog enter/collapse/unmount animations + inline/drawer + hide/show |
|
|
424
426
|
| multi-agent-demo | `/examples/multi-agent-demo/` | Multi-agent parallel + exclusive switch (3 independent agents, drawer hide/show keeps each history) |
|
|
427
|
+
| proxy-demo | `/examples/proxy-demo/` | Proxy connection to prevent apiKey leakage (browser holds only userToken, proxy injects real key; includes auto-refresh on expired token; needs `npm run proxy:mock`) |
|
|
425
428
|
|
|
426
429
|
Framework-agnostic integration: `demo/plain.html` (importmap + esm.sh).
|
|
427
430
|
|
|
@@ -456,7 +459,7 @@ function switchTo(i: number) {
|
|
|
456
459
|
## Self-tests
|
|
457
460
|
|
|
458
461
|
```bash
|
|
459
|
-
npm test #
|
|
462
|
+
npm test # 483 assertions (tsx, source-level; no LLM dependency)
|
|
460
463
|
npm run test:e2e # 173 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 / 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)
|
|
461
464
|
```
|
|
462
465
|
|
package/README.zh-CN.md
CHANGED
|
@@ -137,6 +137,8 @@ SDK 让 AI 安全改 JSON 的核心是**三层解耦配合**——各司其职
|
|
|
137
137
|
```ts
|
|
138
138
|
// 入口与工具构造
|
|
139
139
|
createChatSdk, defineTool, defineSkill, presets, z
|
|
140
|
+
// 代理连接(防 apiKey 泄露:proxy 代理模式 / direct 直连模式)
|
|
141
|
+
createProxyLlm
|
|
140
142
|
// harness 与中间件(自定义编排)
|
|
141
143
|
createAgent, createSubagentMiddleware, createSubagentsMiddleware,
|
|
142
144
|
createVerifyMiddleware, createWriteBackCheck, createApprovalMiddleware,
|
|
@@ -245,7 +247,7 @@ src/core/
|
|
|
245
247
|
├── composables/ # useChat / useContextManager / useMarkdown
|
|
246
248
|
├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
|
|
247
249
|
└── types/index.ts index.ts # 类型 / 库唯一入口
|
|
248
|
-
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
|
|
250
|
+
examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo / proxy-demo
|
|
249
251
|
doc/ # usage-guide / architecture / context-management / architecture-files
|
|
250
252
|
CLAUDE.md # 架构要点 + 约定坑 + 编码规范(agent 必读)
|
|
251
253
|
```
|
|
@@ -367,6 +369,7 @@ createChatSdk({
|
|
|
367
369
|
| mcp-demo | `/examples/mcp-demo/` | MCP 远程工具(需 `npm run mcp:mock`) |
|
|
368
370
|
| animation-demo | `/examples/animation-demo/` | ChatDialog 入场/收起/卸载动画 + inline/drawer 模式 + hide/show |
|
|
369
371
|
| multi-agent-demo | `/examples/multi-agent-demo/` | 多 Agent 并行 + 互斥切换(三独立 agent,drawer hide/show 保留各自历史) |
|
|
372
|
+
| proxy-demo | `/examples/proxy-demo/` | 代理连接防 apiKey 泄露(浏览器只持 userToken,代理注入真实 key;含 token 过期自动刷新;需 `npm run proxy:mock`) |
|
|
370
373
|
|
|
371
374
|
框架无关集成:`demo/plain.html`(importmap + esm.sh)。
|
|
372
375
|
|
|
@@ -401,7 +404,7 @@ function switchTo(i: number) {
|
|
|
401
404
|
## 自测
|
|
402
405
|
|
|
403
406
|
```bash
|
|
404
|
-
npm test #
|
|
407
|
+
npm test # 483 项断言(tsx 源码级,不依赖 LLM)
|
|
405
408
|
npm run test:e2e # 173 项集成断言(node 跑构建产物 dist;覆盖各 API/配置项/功能模块/简单与复杂场景:默认 systemPrompt(含能力概述) / 动态注册与 inspect 同步 / inspect(tools/middleware/subagent/verify/mcp/todos/lastCompression/checkpoints 反映配置) / 自定义 tools/middleware/skills/memory 注入 / switchSession(开/未开) / shareContext 开/关共享独立 / storage 后端+对象配置 / presets 三预设 / checkpoint / 导出项完整(39+ 函数/组件) / 工具函数可用(isQuotaError/estimateTokens/jpEval/searchJson) / source=builtin / mount 边界 / hook 多监听器 / llm 配置 / 错误场景)
|
|
406
409
|
```
|
|
407
410
|
|