page-agent-sdk 1.2.0 → 1.3.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
@@ -90,6 +90,7 @@ CDN zero-config: `<script src="https://unpkg.com/page-agent-sdk"></script>` →
90
90
  | 🤖 subagents | Delegate subtasks; process stays out of main context | `subagent` |
91
91
  | 🔌 MCP | Connect remote MCP servers, inject tools dynamically | `mcp` |
92
92
  | 📦 context compression | 4-layer adaptive compression, presets + LLM summary | `contextPreset` |
93
+ | 🛡️ compression-safe | Live windowProps snapshot + preserved tool results in summary; write returns hint available paths; `systemPromptHelpers.reliableWriteRules` | built-in |
93
94
  | 💾 persistence | IndexedDB multi-session + quota eviction + switch | `storage` |
94
95
 
95
96
  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.
@@ -125,7 +126,7 @@ ChatDialog, MessageContent, CodePreview, useChat
125
126
  | | `ui` | `boolean \| 'default'` · default `true` | `false` = headless (build UI with `agent.messages`) |
126
127
  | | `llm` | `LLMConfig \| BaseChatModel` · **required** | `LLMConfig={apiKey,baseUrl?,model?,temperature?,maxTokens?}`; OpenAI-compatible (default DeepSeek) |
127
128
  | | `id` | `string` | Stable id (multi-agent isolation + persistence resume; random+warn if omitted) |
128
- | | `systemPrompt` | `string` | Agent identity (no hardcoded business; inject via this) |
129
+ | | `systemPrompt` | `string` | Agent identity (no hardcoded business; inject via this). Optional — built-in default (page assistant + `reliableWriteRules`) used if omitted; passing your own fully overrides it |
129
130
  | **Page data** | `windowProps` | `{path,description,schema}[]` | Register window props readable/writable by tools + zod schema |
130
131
  | | `tools` / `skills` / `memory` | `Tool[]` / `SkillSpec[]` / `string` | Custom tools / skills / AGENTS.md-style directives |
131
132
  | **Capability toggles** | `capabilities` | `{planning?,windowOps?,fetch?,skills?,vfs?,summarization?,memory?,subagent?,verify?}` | Default all on (`verify` default off); `false` to turn off |
@@ -137,7 +138,7 @@ ChatDialog, MessageContent, CodePreview, useChat
137
138
  | **Subagents** | `subagent` | `{allowedTools?,systemPrompt?,temperature?,llm?,maxDepth?·1,maxParallel?·4}` | Runtime ad-hoc delegation (`spawn_agent`/`spawn_agents`) |
138
139
  | | `subagents` | `SubagentConfig[]` | Pre-declared named subagents → each generates `use_<id>` tool |
139
140
  | **Context** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive'` · default `auto` | Compression preset |
140
- | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | Fine params (`false` disables compression) |
141
+ | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | Fine params (`false` disables compression). Includes `preserveLastToolResults` (default `['describe_window_prop','list_window_props']` — keep field descriptions in compressed summary) |
141
142
  | | `summaryLlm` | `BaseChatModel \| LLMConfig` | Summary-dedicated LLM (defaults to main `llm`) |
142
143
  | | `maxMemoryRounds` | `number` · default `50` | Dialog history memory round cap (`0` disables trim) |
143
144
  | | `vfs` | `{initialFiles?,maxBytes?}` · default 4MB | In-memory workspace cap (LRU evict on overflow) |
@@ -199,7 +200,7 @@ src/core/
199
200
  ├── composables/ # useChat / useContextManager / useMarkdown
200
201
  ├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
201
202
  └── types/index.ts index.ts # types / sole library entry
202
- examples/ # page-demo / nested-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo
203
+ examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
203
204
  doc/ # usage-guide / architecture / context-management / architecture-files
204
205
  CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
205
206
  ```
@@ -254,7 +255,7 @@ src/core/
254
255
  ├── composables/ # useChat / useContextManager / useMarkdown
255
256
  ├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
256
257
  └── types/index.ts index.ts # types / sole library entry
257
- examples/ # page-demo / nested-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo
258
+ examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
258
259
  doc/ # usage-guide / architecture / context-management / architecture-files
259
260
  CLAUDE.md # architecture + gotchas + coding conventions (agent must-read)
260
261
  ```
@@ -344,6 +345,7 @@ After `npm run dev`, visit the corresponding page:
344
345
  |---|---|---|
345
346
  | page-demo | `/` | Self-bootstrapping demo: left JSON reactive page + right chat |
346
347
  | nested-demo | `/examples/nested-demo/` | Nested block tree + human confirm + checkpoint |
348
+ | dynamic-demo | `/examples/dynamic-demo/` | Lazy-loaded components with dynamic schemas (`sdk.addWindowProp`/`removeWindowProp`) |
347
349
  | human-confirm-demo | `/examples/human-confirm-demo/` | AI proactive inquiry (multi-plan pick) + pre-write confirm |
348
350
  | planner-demo | `/examples/planner-demo/` | Plan-reflect-execute (high-temp creative planner + low-temp reflector) |
349
351
  | subagent-demo | `/examples/subagent-demo/` | Subagent parallel orchestration |
package/README.zh-CN.md CHANGED
@@ -90,6 +90,7 @@ CDN 零配置:`<script src="https://unpkg.com/page-agent-sdk"></script>` → `
90
90
  | 🤖 子 agent | 委派子任务,过程不占主上下文 | `subagent` |
91
91
  | 🔌 MCP | 连远程 MCP server 动态注入工具 | `mcp` |
92
92
  | 📦 上下文压缩 | 4 层自适应压缩,预设档位 + LLM 摘要 | `contextPreset` |
93
+ | 🛡️ 压缩不丢信息 | 摘要内嵌当前 windowProps 快照 + 保留指定工具结果;写返回附可操作 path;`systemPromptHelpers.reliableWriteRules` | 内置 |
93
94
  | 💾 持久化 | IndexedDB 多会话 + 配额淘汰 + 切换 | `storage` |
94
95
 
95
96
  能力默认开(`verify`/`approval`/`checkpoint` 默认关;**主动征询 `humanConfirm` 默认开**——AI 遇不确定/多方案主动问你、不猜测),可经 `capabilities` 关掉无用的省 token。
@@ -125,7 +126,7 @@ ChatDialog, MessageContent, CodePreview, useChat
125
126
  | | `ui` | `boolean \| 'default'` · 默认 `true` | `false` = headless(用 `agent.messages` 自建 UI) |
126
127
  | | `llm` | `LLMConfig \| BaseChatModel` · **必传** | `LLMConfig={apiKey,baseUrl?,model?,temperature?,maxTokens?}`;兼容 OpenAI 协议(默认 DeepSeek) |
127
128
  | | `id` | `string` | 稳定 id(多 agent 隔离 + 持久化恢复;不传随机+warn) |
128
- | | `systemPrompt` | `string` | Agent 身份(不硬编码业务,靠这注入) |
129
+ | | `systemPrompt` | `string` | Agent 身份(不硬编码业务,靠这注入)。可选——不传用内置默认(页面操作助手 + `reliableWriteRules`);传了则完全覆盖 |
129
130
  | **页面数据** | `windowProps` | `{path,description,schema}[]` | 注册可被工具读写的 window 属性 + zod schema 校验 |
130
131
  | | `tools` / `skills` / `memory` | `Tool[]` / `SkillSpec[]` / `string` | 自定义工具 / 技能 / AGENTS.md 风格持久指令 |
131
132
  | **能力开关** | `capabilities` | `{planning?,windowOps?,fetch?,skills?,vfs?,summarization?,memory?,subagent?,verify?}` | 默认全开(`verify` 默认关);`false` 关掉省 token |
@@ -137,7 +138,7 @@ ChatDialog, MessageContent, CodePreview, useChat
137
138
  | **子 agent** | `subagent` | `{allowedTools?,systemPrompt?,temperature?,llm?,maxDepth?·1,maxParallel?·4}` | 运行时自由委派(`spawn_agent`/`spawn_agents`) |
138
139
  | | `subagents` | `SubagentConfig[]` | 预声明命名子 agent → 每个生成 `use_<id>` 委派工具 |
139
140
  | **上下文** | `contextPreset` | `'auto' \| 'conservative' \| 'aggressive'` · 默认 `auto` | 压缩预设档位 |
140
- | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | 细参覆盖(`false` 关压缩) |
141
+ | | `contextOptions` | `Partial<ContextManagerOptions> \| false` | 细参覆盖(`false` 关压缩)。含 `preserveLastToolResults`(默认 `['describe_window_prop','list_window_props']`——压缩摘要里保留字段说明) |
141
142
  | | `summaryLlm` | `BaseChatModel \| LLMConfig` | 摘要专用 LLM(不配用主 `llm`) |
142
143
  | | `maxMemoryRounds` | `number` · 默认 `50` | 对话历史内存上限轮次(`0` 关裁剪) |
143
144
  | | `vfs` | `{initialFiles?,maxBytes?}` · 默认 4MB | 内存工作区上限(超限 LRU 淘汰) |
@@ -199,7 +200,7 @@ src/core/
199
200
  ├── composables/ # useChat / useContextManager / useMarkdown
200
201
  ├── components/ # ChatDialog / MessageContent / CodePreview / DebugDrawer
201
202
  └── types/index.ts index.ts # 类型 / 库唯一入口
202
- examples/ # page-demo / nested-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo
203
+ examples/ # page-demo / nested-demo / dynamic-demo / human-confirm-demo / planner-demo / subagent-demo / mcp-demo / toolsets-demo
203
204
  doc/ # usage-guide / architecture / context-management / architecture-files
204
205
  CLAUDE.md # 架构要点 + 约定坑 + 编码规范(agent 必读)
205
206
  ```
@@ -289,6 +290,7 @@ createChatSdk({
289
290
  |---|---|---|
290
291
  | page-demo | `/` | 自举 demo:左 JSON 响应式页面 + 右对话框 |
291
292
  | nested-demo | `/examples/nested-demo/` | 嵌套区块树 + 人工确认 + checkpoint |
293
+ | dynamic-demo | `/examples/dynamic-demo/` | 懒加载组件 + 动态注册 schema(`sdk.addWindowProp`/`removeWindowProp`) |
292
294
  | human-confirm-demo | `/examples/human-confirm-demo/` | AI 主动征询(多方案点选)+ 写前确认 |
293
295
  | planner-demo | `/examples/planner-demo/` | 规划-反思-执行(高温创意 planner + 低温 reflector) |
294
296
  | subagent-demo | `/examples/subagent-demo/` | 子 agent 并行编排 |