page-agent-sdk 2.15.0 → 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 +40 -6
- package/README.zh-CN.md +40 -6
- package/dist/page-agent-sdk.iife.js +125 -124
- package/dist/page-agent-sdk.js +647 -478
- package/dist/page-agent-sdk.umd.cjs +29 -29
- package/package.json +24 -4
- package/skills/page-agent-sdk-integrate/references/api.md +29 -0
- package/types/index.d.ts +4 -2
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-agent-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "AI agent SDK for web pages — embed a chat assistant that edits page data via schema-validated tools. A lighter, framework-agnostic alternative to CopilotKit/LangChain for in-page JSON-editing agents. Vue-bundled; works with DeepSeek, OpenAI, MCP.",
|
|
6
6
|
"main": "./dist/page-agent-sdk.umd.cjs",
|
|
7
7
|
"module": "./dist/page-agent-sdk.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
@@ -55,21 +55,41 @@
|
|
|
55
55
|
"keywords": [
|
|
56
56
|
"ai",
|
|
57
57
|
"agent",
|
|
58
|
+
"ai-agent",
|
|
59
|
+
"agent-sdk",
|
|
58
60
|
"llm",
|
|
59
61
|
"chatbot",
|
|
60
62
|
"chat-dialog",
|
|
63
|
+
"chat-sdk",
|
|
61
64
|
"tool-calling",
|
|
65
|
+
"function-calling",
|
|
62
66
|
"react-agent",
|
|
67
|
+
"browser-agent",
|
|
68
|
+
"in-page-agent",
|
|
69
|
+
"conversational-editor",
|
|
70
|
+
"ai-json-editor",
|
|
71
|
+
"json-editor",
|
|
72
|
+
"json-patch",
|
|
73
|
+
"schema-validation",
|
|
74
|
+
"human-in-the-loop",
|
|
63
75
|
"sdk",
|
|
64
76
|
"browser",
|
|
65
|
-
"json-editor",
|
|
66
77
|
"low-code",
|
|
78
|
+
"low-code-builder",
|
|
79
|
+
"no-code",
|
|
80
|
+
"visual-builder",
|
|
67
81
|
"page-builder",
|
|
68
82
|
"deepseek",
|
|
69
83
|
"openai",
|
|
70
84
|
"langchain",
|
|
85
|
+
"langchain-alternative",
|
|
86
|
+
"langgraph",
|
|
87
|
+
"langgraph-alternative",
|
|
88
|
+
"copilotkit",
|
|
71
89
|
"mcp",
|
|
72
|
-
"
|
|
90
|
+
"model-context-protocol",
|
|
91
|
+
"vue",
|
|
92
|
+
"react",
|
|
73
93
|
"zod"
|
|
74
94
|
],
|
|
75
95
|
"author": "武浩",
|
|
@@ -128,6 +128,35 @@ Example: `write({ value: 9.9, patch: { op: 'set', jsonPath: 'items.0.price' } })
|
|
|
128
128
|
|
|
129
129
|
`fetch_document` — GET a URL, return cleaned text (HTML→markdown, truncated, offloaded to vfs if large).
|
|
130
130
|
|
|
131
|
+
## Built-in vfs tools (`capabilities.vfs`, default on)
|
|
132
|
+
|
|
133
|
+
The virtual file workspace holds tool-result offloads (>6000 chars), agent/integrator drafts, and user files. 2.16.0+ partitions it into three independent LRU pools (`large_results/*` / `drafts/*` / `userFiles`), so offloaded results can't evict drafts or user files.
|
|
134
|
+
|
|
135
|
+
| Tool | Signature | Purpose |
|
|
136
|
+
|---|---|---|
|
|
137
|
+
| `vfs_read` | `({ path }) => string` | Read a file (path may be returned by a prior offload). |
|
|
138
|
+
| `vfs_write` | `({ path, content, jsonString? }) => meta` | Write/overwrite a file. `jsonString:true` (2.16.0+) validates `content` is valid JSON before writing (invalid → `VFS_JSON_INVALID`, not written). |
|
|
139
|
+
| `vfs_grep` | `({ pattern, paths? }) => matches` | Grep across workspace files. |
|
|
140
|
+
| `vfs_json_read` (2.16.0+) | `({ path, jsonPath? }) => json\|string` | Read a JSON subtree from a vfs file via jsonPath (omit for the whole file). Returns `VFS_JSON_INVALID` if the file isn't valid JSON; `VFS_PATH_NOT_FOUND` if jsonPath doesn't exist. |
|
|
141
|
+
| `vfs_json_patch` (2.16.0+) | `({ path, patches: [{op:'set'\|'remove'\|'merge'\|'append', jsonPath, value?}] }) => meta` | Atomic jsonPath patch inside a vfs file. Applied on a clone; any patch failure → `PATCH_FAILED`, original file unchanged. Avoids re-sending large JSON (delta only). |
|
|
142
|
+
|
|
143
|
+
## Context compression presets (`contextPreset`)
|
|
144
|
+
|
|
145
|
+
`contextPreset` is a one-line knob over the `summarization` middleware (ratio-based); `contextOptions` overrides individual fields.
|
|
146
|
+
|
|
147
|
+
| Preset | When | Profile |
|
|
148
|
+
|---|---|---|
|
|
149
|
+
| `auto` (default) | General chat | window 0.4 / threshold 0.5 / recall Top-3 / LLM summary |
|
|
150
|
+
| `conservative` | Big models / cost | window 0.5 / threshold 0.7 / recall Top-2 / index summary (no LLM) |
|
|
151
|
+
| `aggressive` | Small models / save context | window 0.3 / threshold 0.3 / recall Top-5 |
|
|
152
|
+
| `complex` (2.16.0+) | Multi-step complex tasks / large JSON / long workflows | windowRatio 0.6 / summaryThresholdRatio 0.7 / recall Top-5 / LLM summary; `preserveLastToolResults` defaults to `['describe_data','read','query_data','search_data']` |
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
createChatSdk({ contextPreset: 'complex', contextOptions: { recallTopK: 8 } })
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`inspect().contextPreset` (2.16.0+) exposes the effective preset.
|
|
159
|
+
|
|
131
160
|
## SdkEvent types (for `onEvent` / `sdk.hook`)
|
|
132
161
|
|
|
133
162
|
| `type` | Payload | When |
|
package/types/index.d.ts
CHANGED
|
@@ -135,6 +135,8 @@ export interface AgentInfo {
|
|
|
135
135
|
tools: ToolInfo[];
|
|
136
136
|
skills: SkillInfo[];
|
|
137
137
|
data?: DataInfo;
|
|
138
|
+
/** 当前上下文压缩预设(默认 auto;complex 为多步复杂任务/大 JSON 场景) */
|
|
139
|
+
contextPreset: 'auto' | 'conservative' | 'aggressive' | 'complex';
|
|
138
140
|
memory: string;
|
|
139
141
|
middleware: string[];
|
|
140
142
|
todos: { content: string; status: string }[];
|
|
@@ -464,8 +466,8 @@ export interface ChatSdkOptions {
|
|
|
464
466
|
mcp?: McpServerConfig[];
|
|
465
467
|
/** 上下文压缩配置(false 关闭;默认 LLM 摘要,失败回退索引摘要) */
|
|
466
468
|
contextOptions?: any;
|
|
467
|
-
/** 上下文压缩预设档位(默认 'auto'):auto / conservative / aggressive;提供合理默认,contextOptions 细参可覆盖 */
|
|
468
|
-
contextPreset?: 'auto' | 'conservative' | 'aggressive';
|
|
469
|
+
/** 上下文压缩预设档位(默认 'auto'):auto / conservative / aggressive / complex(多步复杂任务/大 JSON);提供合理默认,contextOptions 细参可覆盖 */
|
|
470
|
+
contextPreset?: 'auto' | 'conservative' | 'aggressive' | 'complex';
|
|
469
471
|
/** 摘要压缩专用 LLM(BaseChatModel 实例或 LLMConfig);不传则默认用主 agent 模型(llm) */
|
|
470
472
|
summaryLlm?: any;
|
|
471
473
|
/** 摘要 LLM 温度(默认 0.3) */
|