page-agent-sdk 2.22.0 → 2.23.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 CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/page-agent-sdk.svg)](https://www.npmjs.com/package/page-agent-sdk)
10
10
  [![license](https://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
11
- [![tests](https://img.shields.io/badge/self%20tests-1092%20asserts-brightgreen.svg)](#self-tests)
11
+ [![tests](https://img.shields.io/badge/self%20tests-1130%20asserts-brightgreen.svg)](#self-tests)
12
12
 
13
13
  ---
14
14
 
@@ -99,7 +99,7 @@ window.page = page // optional: mount to window for your page to read; SDK tool
99
99
 
100
100
  createChatSdk({
101
101
  container: '#chat',
102
- llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com', model: 'deepseek-chat' },
102
+ llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com', model: 'deepseek-v4-flash' },
103
103
  systemPrompt: 'You are a page-builder assistant; read/write the main data via tools.',
104
104
  data: {
105
105
  schema: z.object({
@@ -135,10 +135,10 @@ CDN zero-config: `<script src="https://unpkg.com/page-agent-sdk"></script>` →
135
135
  | 🧪 complex-task tuned | `complex` context preset (larger window + later compress + more recall, for multi-step / large-JSON / long-workflow tasks); vfs JSON-aware tools (`vfs_json_read` / `vfs_json_patch`) for structured big-JSON ops inside vfs; vfs three-pool LRU (large_results / drafts / userFiles isolated, no mutual eviction) | `contextPreset:'complex'`, `capabilities.vfs` |
136
136
  | 🛡️ compression-safe | Live data snapshot + preserved tool results in summary; write returns hint available paths; `systemPromptHelpers.reliableWriteRules` | built-in |
137
137
  | 💾 persistence | IndexedDB multi-session + quota eviction + switch | `storage` |
138
- | 👁 DOM read (2.18+) | Read rendered DOM structure (depth-cutoff + attr whitelist); verify modifications took effect — distinct from `eval_script` (structured + read-only) | `capabilities.domInspect` |
139
- | ⚡ host actions (2.18+) | Register save/publish/preview etc; SDK auto-generates named tools, agent triggers page ops directly (no `trigger_action` indirection) | `actions` |
140
- | 🧩 schema tiered disclosure (2.18+) | Large schema → systemPrompt injects top-level overview only (no constraints/no recursion); deep constraints via `schema_data` on demand; small schema unaffected (full) | `schemaHint` |
141
- | 📌 cross-compress working memory (2.18+) | Pin recent read/query paths + hashes across compression; no re-fetch, correct optimistic-lock hash | `capabilities.workingMemory` |
138
+ | 👁 DOM read (2.20+) | Read rendered DOM structure (depth-cutoff + attr whitelist); verify modifications took effect — distinct from `eval_script` (structured + read-only) | `capabilities.domInspect` |
139
+ | ⚡ host actions (2.20+) | Register save/publish/preview etc; SDK auto-generates named tools, agent triggers page ops directly (no `trigger_action` indirection) | `actions` |
140
+ | 🧩 schema tiered disclosure (2.20+) | Large schema → systemPrompt injects top-level overview only (no constraints/no recursion); deep constraints via `schema_data` on demand; small schema unaffected (full) | `schemaHint` |
141
+ | 📌 cross-compress working memory (2.20+) | Pin recent read/query paths + hashes across compression; no re-fetch, correct optimistic-lock hash | `capabilities.workingMemory` |
142
142
  | 🤖 unattended automation (2.20+) | Resource budget guard (`tokenBudget`/`timeBudgetMs`) + fatal-error auto-recovery (`maxAutoRetries`: restore checkpoint + retry) + cross-refresh resume + `sdk.batch(tasks)` batch processing | `capabilities.automation` |
143
143
 
144
144
  Capabilities default on (`verify`/`approval`/`checkpoint` default off; **proactive `humanConfirm` default on** — AI asks when uncertain/multi-plan instead of guessing). Turn off unneeded ones via `capabilities` to save tokens.
@@ -399,7 +399,7 @@ flowchart TD
399
399
  # .env (VITE_ prefix)
400
400
  VITE_AI_API_KEY=sk-...
401
401
  VITE_AI_BASE_URL=https://api.deepseek.com
402
- VITE_AI_MODEL=deepseek-chat
402
+ VITE_AI_MODEL=deepseek-v4-flash
403
403
  VITE_AI_TEMPERATURE=0.3 # low temp recommended for structured ops
404
404
  # VITE_AI_MAX_TOKENS= # omit → model default
405
405
  ```
@@ -514,8 +514,8 @@ function switchTo(i: number) {
514
514
  ## Self-tests
515
515
 
516
516
  ```bash
517
- npm test # 782 assertions (tsx, source-level; no LLM dependency)
518
- npm run test:e2e # 283 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)
517
+ npm test # 1130 assertions (tsx, source-level; no LLM dependency)
518
+ npm run test:e2e # 286 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)
519
519
  ```
520
520
 
521
521
  ## Local npm package test
@@ -544,7 +544,7 @@ window.app = app // optional: mount to window for your page; tools operate on `
544
544
 
545
545
  createChatSdk({
546
546
  container: '#root',
547
- llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-chat' },
547
+ llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-v4-flash' },
548
548
  systemPrompt: 'You are a page assistant; read/write the main data via tools.',
549
549
  data: {
550
550
  schema: z.object({
package/README.zh-CN.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/page-agent-sdk.svg)](https://www.npmjs.com/package/page-agent-sdk)
10
10
  [![license](https://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/whyymj/page-agent-sdk/blob/master/LICENSE)
11
- [![tests](https://img.shields.io/badge/self%20tests-1092%20asserts-brightgreen.svg)](#自测)
11
+ [![tests](https://img.shields.io/badge/self%20tests-1130%20asserts-brightgreen.svg)](#自测)
12
12
 
13
13
  ---
14
14
 
@@ -99,7 +99,7 @@ window.page = page // 可选:挂到 window 供页面读取;SDK 工具直接读
99
99
 
100
100
  createChatSdk({
101
101
  container: '#chat',
102
- llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com', model: 'deepseek-chat' },
102
+ llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com', model: 'deepseek-v4-flash' },
103
103
  systemPrompt: '你是页面搭建助手,通过工具读写主数据。',
104
104
  data: {
105
105
  schema: z.object({
@@ -344,7 +344,7 @@ flowchart TD
344
344
  # .env(前缀 VITE_)
345
345
  VITE_AI_API_KEY=sk-...
346
346
  VITE_AI_BASE_URL=https://api.deepseek.com
347
- VITE_AI_MODEL=deepseek-chat
347
+ VITE_AI_MODEL=deepseek-v4-flash
348
348
  VITE_AI_TEMPERATURE=0.3 # 结构化操作建议低温
349
349
  # VITE_AI_MAX_TOKENS= # 不配则按模型自动取值
350
350
  ```
@@ -459,8 +459,8 @@ function switchTo(i: number) {
459
459
  ## 自测
460
460
 
461
461
  ```bash
462
- npm test # 1092 项断言(tsx 源码级,不依赖 LLM)
463
- npm run test:e2e # 283 项集成断言(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 配置 / 错误场景)
462
+ npm test # 1130 项断言(tsx 源码级,不依赖 LLM)
463
+ npm run test:e2e # 286 项集成断言(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 配置 / 错误场景)
464
464
  ```
465
465
 
466
466
  ## 本地 npm 包测试
@@ -489,7 +489,7 @@ window.app = app // 可选:挂到 window 供页面读取;工具直接读写 bin
489
489
 
490
490
  createChatSdk({
491
491
  container: '#root',
492
- llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-chat' },
492
+ llm: { apiKey: 'sk-...', baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-v4-flash' },
493
493
  systemPrompt: '你是页面助手,用工具读写主数据。',
494
494
  data: {
495
495
  schema: z.object({