page-agent-sdk 2.15.1 → 2.16.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-642%20asserts-brightgreen.svg)](#self-tests)
11
+ [![tests](https://img.shields.io/badge/self%20tests-680%20asserts-brightgreen.svg)](#self-tests)
12
12
 
13
13
  ---
14
14
 
@@ -132,6 +132,7 @@ CDN zero-config: `<script src="https://unpkg.com/page-agent-sdk"></script>` →
132
132
  | 🤖 subagents | Delegate subtasks; process stays out of main context | `subagent` |
133
133
  | 🔌 MCP | Connect remote MCP servers, inject tools dynamically | `mcp` |
134
134
  | 📦 context compression | 4-layer adaptive compression, presets + LLM summary | `contextPreset` |
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` |
135
136
  | 🛡️ compression-safe | Live data snapshot + preserved tool results in summary; write returns hint available paths; `systemPromptHelpers.reliableWriteRules` | built-in |
136
137
  | 💾 persistence | IndexedDB multi-session + quota eviction + switch | `storage` |
137
138
 
@@ -208,7 +209,7 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, useChat
208
209
  | | `verify` | `{check?,maxAttempts?,adversarial?}` | Needs `capabilities.verify:true`; `check` omitted → `createWriteBackCheck` (read-back root auto-bound to `data.bind`, adapts to `sdk.setData` runtime swap) |
209
210
  | **Subagents** | `subagent` | `{allowedTools?,systemPrompt?,temperature?,llm?,maxDepth?·1,maxParallel?·4}` | Runtime ad-hoc delegation (`spawn_agent`/`spawn_agents`) |
210
211
  | | `subagents` | `SubagentConfig[]` | Pre-declared named subagents → each generates `use_<id>` tool |
211
- | **Context** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive'` · default `auto` | Compression preset |
212
+ | **Context** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive' \| 'complex'` · default `auto` | Compression preset (`complex` for multi-step / large-JSON / long-workflow tasks) |
212
213
  | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | Fine params (`false` disables compression). Includes `preserveLastToolResults` (default `['describe_data','describe_data']` — keep field descriptions in compressed summary) |
213
214
  | | `summaryLlm` | `BaseChatModel \| LLMConfig` | Summary-dedicated LLM (defaults to main `llm`) |
214
215
  | | `maxMemoryRounds` | `number` · default `50` | Dialog history memory round cap (`0` disables trim) |
@@ -418,7 +419,7 @@ createChatSdk({
418
419
  humanConfirm: true, // proactive inquiry (default on)
419
420
  approval: { tools: ['write'] }, // passive confirm whitelist (default off)
420
421
  checkpoint: true,
421
- contextPreset: 'auto', // auto/conservative/aggressive
422
+ contextPreset: 'auto', // auto/conservative/aggressive/complex
422
423
  summaryLlm: { ... }, // summary-dedicated LLM (defaults to main llm)
423
424
  maxRetries: 2, maxParallelTools: 1,
424
425
  subagent: { allowedTools: [...] },
@@ -508,8 +509,8 @@ function switchTo(i: number) {
508
509
  ## Self-tests
509
510
 
510
511
  ```bash
511
- npm test # 642 assertions (tsx, source-level; no LLM dependency)
512
- npm run test:e2e # 212 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)
512
+ npm test # 680 assertions (tsx, source-level; no LLM dependency)
513
+ npm run test:e2e # 217 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)
513
514
  ```
514
515
 
515
516
  ## Local npm package test
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-642%20asserts-brightgreen.svg)](#自测)
11
+ [![tests](https://img.shields.io/badge/self%20tests-680%20asserts-brightgreen.svg)](#自测)
12
12
 
13
13
  ---
14
14
 
@@ -132,6 +132,7 @@ CDN 零配置:`<script src="https://unpkg.com/page-agent-sdk"></script>` → `
132
132
  | 🤖 子 agent | 委派子任务,过程不占主上下文 | `subagent` |
133
133
  | 🔌 MCP | 连远程 MCP server 动态注入工具 | `mcp` |
134
134
  | 📦 上下文压缩 | 4 层自适应压缩,预设档位 + LLM 摘要 | `contextPreset` |
135
+ | 🧪 复杂任务调优 | `complex` 上下文预设(更大窗口 + 更晚压缩 + 更多召回,适合多步 / 大 JSON / 长流程编排);vfs JSON 感知工具(`vfs_json_read` / `vfs_json_patch`)在 vfs 内结构化操作大 JSON;vfs 三池分池(large_results / drafts / userFiles 隔离 LRU,互不挤占) | `contextPreset:'complex'`、`capabilities.vfs` |
135
136
  | 🛡️ 压缩不丢信息 | 摘要内嵌当前 data 快照 + 保留指定工具结果;写返回附可操作 path;`systemPromptHelpers.reliableWriteRules` | 内置 |
136
137
  | 💾 持久化 | IndexedDB 多会话 + 配额淘汰 + 切换 | `storage` |
137
138
 
@@ -208,7 +209,7 @@ ChatDialog, MessageContent, CodePreview, SkillPanel, useChat
208
209
  | | `verify` | `{check?,maxAttempts?,adversarial?}` | 需 `capabilities.verify:true`;`check` 省略用 `createWriteBackCheck`(读回根对象自动取 `data.bind`,适配 `sdk.setData` 运行时替换) |
209
210
  | **子 agent** | `subagent` | `{allowedTools?,systemPrompt?,temperature?,llm?,maxDepth?·1,maxParallel?·4}` | 运行时自由委派(`spawn_agent`/`spawn_agents`) |
210
211
  | | `subagents` | `SubagentConfig[]` | 预声明命名子 agent → 每个生成 `use_<id>` 委派工具 |
211
- | **上下文** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive'` · 默认 `auto` | 压缩预设档位 |
212
+ | **上下文** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive' \| 'complex'` · 默认 `auto` | 压缩预设档位(`complex` 面向多步 / 大 JSON / 长流程编排任务) |
212
213
  | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | 细参覆盖(`false` 关压缩)。含 `preserveLastToolResults`(默认 `['describe_data','describe_data']`——压缩摘要里保留字段说明) |
213
214
  | | `summaryLlm` | `BaseChatModel \| LLMConfig` | 摘要专用 LLM(不配用主 `llm`) |
214
215
  | | `maxMemoryRounds` | `number` · 默认 `50` | 对话历史内存上限轮次(`0` 关裁剪) |
@@ -363,7 +364,7 @@ createChatSdk({
363
364
  humanConfirm: true, // 主动征询(默认开;AI 不确定/多方案主动问你)
364
365
  approval: { tools: ['write'] }, // 被动确认白名单(默认关)
365
366
  checkpoint: true,
366
- contextPreset: 'auto', // auto/conservative/aggressive
367
+ contextPreset: 'auto', // auto/conservative/aggressive/complex
367
368
  summaryLlm: { ... }, // 摘要专用 LLM(不配用主 llm)
368
369
  maxRetries: 2, maxParallelTools: 1,
369
370
  subagent: { allowedTools: [...] },
@@ -453,8 +454,8 @@ function switchTo(i: number) {
453
454
  ## 自测
454
455
 
455
456
  ```bash
456
- npm test # 642 项断言(tsx 源码级,不依赖 LLM)
457
- npm run test:e2e # 212 项集成断言(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 配置 / 错误场景)
457
+ npm test # 680 项断言(tsx 源码级,不依赖 LLM)
458
+ npm run test:e2e # 217 项集成断言(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 配置 / 错误场景)
458
459
  ```
459
460
 
460
461
  ## 本地 npm 包测试