page-agent-sdk 2.29.0 → 2.31.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 +8 -4
- package/README.zh-CN.md +8 -4
- package/dist/page-agent-sdk.iife.js +111 -111
- package/dist/page-agent-sdk.js +3782 -3660
- package/dist/page-agent-sdk.umd.cjs +79 -79
- package/package.json +1 -1
- package/types/index.d.ts +7 -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
|
|
|
@@ -141,6 +141,8 @@ CDN zero-config: `<script src="https://unpkg.com/page-agent-sdk"></script>` →
|
|
|
141
141
|
| 🧩 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` |
|
|
142
142
|
| 📌 cross-compress working memory (2.20+) | Pin recent read/query paths + hashes across compression; no re-fetch, correct optimistic-lock hash | `capabilities.workingMemory` |
|
|
143
143
|
| 🤖 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` |
|
|
144
|
+
| 📐 context resilience (2.30+) | Hard floor `contextWindow ≥200K` (rejects <200K models like legacy `deepseek`/`gpt-4o`/`glm-4.5` at startup); three gates (compress/trim/offload) thresholds follow the live window after `setLlm`; reactive retry on `context_length_exceeded` (aggressive trim → single retry, never fails raw); vfs large-result refs protected from LRU eviction + OOM 1.5× fallback; system-prompt budget (25% window, drops non-pinned segments, keeps base/mission/workingMemory) | built-in |
|
|
145
|
+
| 🎯 focus auto-switch (2.31+) | AI auto-judges task scope → `set_focus` (local task) / `clear_focus` (global/done); focus persists across refresh/session-switch (restore validates path via `getSchemaAtPath`, drops if invalid); spawned subagents inherit parent focus (three-layer convergence; parent unfocused → child no focus middleware, zero regression) | `capabilities.focus` + `toolMode:'advanced'` |
|
|
144
146
|
|
|
145
147
|
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.
|
|
146
148
|
|
|
@@ -187,7 +189,7 @@ createVerifyMiddleware, createWriteBackCheck, createApprovalMiddleware,
|
|
|
187
189
|
createHumanConfirmMiddleware, createHumanConfirmTool, createCheckpointMiddleware, createCheckpointManager,
|
|
188
190
|
createUsageHintsMiddleware, createDataOps, createVfs, connectMcp
|
|
189
191
|
// context & model
|
|
190
|
-
resolveContextOptions, CONTEXT_PRESETS, resolveModelCaps, estimateTokens
|
|
192
|
+
resolveContextOptions, CONTEXT_PRESETS, resolveModelCaps, estimateTokens, isContextLengthError, MIN_CONTEXT_WINDOW
|
|
191
193
|
// storage
|
|
192
194
|
createSessionStore, createMemoryBackend, createWebStorageBackend, isQuotaError
|
|
193
195
|
// UI (reuse when headless)
|
|
@@ -409,6 +411,8 @@ VITE_AI_TEMPERATURE=0.3 # low temp recommended for structured ops
|
|
|
409
411
|
# VITE_AI_MAX_TOKENS= # omit → model default
|
|
410
412
|
```
|
|
411
413
|
|
|
414
|
+
> ⚠️ **Minimum context window 200K (2.30+)**: the SDK rejects models with `contextWindow < 200000` at startup (`setLlm`/subagent too) — excludes legacy `deepseek`/`deepseek-reasoner`/`glm-4.5`/`gpt-4o`/`qwen-max` etc. Use a ≥200K model (`deepseek-v4`/`glm-5.2`/`claude-3-*`/`kimi-k3`/`qwen-1m`) or declare `llm: { contextWindow: 500000 }` to override the table lookup.
|
|
415
|
+
|
|
412
416
|
```ts
|
|
413
417
|
createChatSdk({
|
|
414
418
|
container: '#root',
|
|
@@ -520,8 +524,8 @@ function switchTo(i: number) {
|
|
|
520
524
|
## Self-tests
|
|
521
525
|
|
|
522
526
|
```bash
|
|
523
|
-
npm test #
|
|
524
|
-
npm run test:e2e #
|
|
527
|
+
npm test # 1358 assertions (tsx, source-level; no LLM dependency)
|
|
528
|
+
npm run test:e2e # 362 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)
|
|
525
529
|
```
|
|
526
530
|
|
|
527
531
|
## 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
|
|
|
@@ -136,6 +136,8 @@ CDN 零配置:`<script src="https://unpkg.com/page-agent-sdk"></script>` → `
|
|
|
136
136
|
| 🛡️ 压缩不丢信息 | 摘要内嵌当前 data 快照 + 保留指定工具结果;写返回附可操作 path;`systemPromptHelpers.reliableWriteRules` | 内置 |
|
|
137
137
|
| 💾 持久化 | IndexedDB 多会话 + 配额淘汰 + 切换 | `storage` |
|
|
138
138
|
| 🤖 无人值守自动化 (2.20+) | 资源预算闸(`tokenBudget`/`timeBudgetMs`)+ 致命错误自动恢复(`maxAutoRetries`:回退 checkpoint + 重试)+ 刷新续跑 + `sdk.batch(tasks)` 批处理 | `capabilities.automation` |
|
|
139
|
+
| 📐 上下文健壮性 (2.30+) | 硬地板 `contextWindow ≥200K`(启动拒绝 <200K 模型如老款 `deepseek`/`gpt-4o`/`glm-4.5`);三道闸(压缩/trim/offload)阈值在 `setLlm` 后跟随实时窗口;遇 `context_length_exceeded` 反应性重试(激进 trim → 重试一次,不裸失败);vfs 大结果引用受保护免 LRU 淘汰 + OOM 1.5× 兜底;系统段预算(25% 窗口,丢弃非 pin 段保 base/mission/workingMemory) | 内置 |
|
|
140
|
+
| 🎯 focus 自动切换 (2.31+) | AI 自动判断任务范围 → `set_focus`(局部任务)/ `clear_focus`(全局/完成);focus 跨刷新/切会话持久化(restore 经 `getSchemaAtPath` 校验 path,失效丢弃);子 agent 继承主焦点(三层收敛;主未聚焦 → 子无 focus 中间件,零回归) | `capabilities.focus` + `toolMode:'advanced'` |
|
|
139
141
|
|
|
140
142
|
能力默认开(`verify`/`approval`/`checkpoint` 默认关;**主动征询 `humanConfirm` 默认开**——AI 遇不确定/多方案主动问你、不猜测),可经 `capabilities` 关掉无用的省 token。
|
|
141
143
|
|
|
@@ -182,7 +184,7 @@ createVerifyMiddleware, createWriteBackCheck, createApprovalMiddleware,
|
|
|
182
184
|
createHumanConfirmMiddleware, createHumanConfirmTool, createCheckpointMiddleware, createCheckpointManager,
|
|
183
185
|
createUsageHintsMiddleware, createDataOps, createVfs, connectMcp
|
|
184
186
|
// 上下文/模型
|
|
185
|
-
resolveContextOptions, CONTEXT_PRESETS, resolveModelCaps, estimateTokens
|
|
187
|
+
resolveContextOptions, CONTEXT_PRESETS, resolveModelCaps, estimateTokens, isContextLengthError, MIN_CONTEXT_WINDOW
|
|
186
188
|
// 存储
|
|
187
189
|
createSessionStore, createMemoryBackend, createWebStorageBackend, isQuotaError
|
|
188
190
|
// UI(headless 自建 UI 复用)
|
|
@@ -354,6 +356,8 @@ VITE_AI_TEMPERATURE=0.3 # 结构化操作建议低温
|
|
|
354
356
|
# VITE_AI_MAX_TOKENS= # 不配则按模型自动取值
|
|
355
357
|
```
|
|
356
358
|
|
|
359
|
+
> ⚠️ **最小上下文窗口 200K(2.30+)**:SDK 启动(`setLlm`/子 agent 同样)拒绝 `contextWindow < 200000` 的模型 —— 排除老款 `deepseek`/`deepseek-reasoner`/`glm-4.5`/`gpt-4o`/`qwen-max` 等。用 ≥200K 模型(`deepseek-v4`/`glm-5.2`/`claude-3-*`/`kimi-k3`/`qwen-1m`)或声明 `llm: { contextWindow: 500000 }` 覆盖查表。
|
|
360
|
+
|
|
357
361
|
```ts
|
|
358
362
|
createChatSdk({
|
|
359
363
|
container: '#root',
|
|
@@ -465,8 +469,8 @@ function switchTo(i: number) {
|
|
|
465
469
|
## 自测
|
|
466
470
|
|
|
467
471
|
```bash
|
|
468
|
-
npm test #
|
|
469
|
-
npm run test:e2e #
|
|
472
|
+
npm test # 1358 项断言(tsx 源码级,不依赖 LLM)
|
|
473
|
+
npm run test:e2e # 362 项集成断言(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 配置 / 错误场景)
|
|
470
474
|
```
|
|
471
475
|
|
|
472
476
|
## 本地 npm 包测试
|