page-agent-sdk 1.4.2 → 2.0.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 +29 -29
- package/README.zh-CN.md +27 -27
- package/dist/page-agent-sdk.css +1 -1
- package/dist/page-agent-sdk.iife.js +17 -17
- package/dist/page-agent-sdk.js +111 -111
- package/dist/page-agent-sdk.umd.cjs +17 -17
- package/package.json +2 -2
- package/skills/page-agent-sdk-integrate/SKILL.md +18 -18
- package/skills/page-agent-sdk-integrate/references/advanced.md +29 -29
- package/skills/page-agent-sdk-integrate/references/api.md +24 -24
- package/skills/page-agent-sdk-integrate/references/options.md +8 -8
- package/skills/page-agent-sdk-integrate/references/quickstart.md +14 -14
- package/skills/page-agent-sdk-integrate/references/use-cases.md +27 -27
- package/types/index.d.ts +36 -36
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Use cases — end-to-end scenarios
|
|
2
2
|
|
|
3
|
-
Concrete integration patterns for common scenarios. Each shows the key `
|
|
3
|
+
Concrete integration patterns for common scenarios. Each shows the key `dataSlots` + options that matter. Adapt the LLM config to your provider.
|
|
4
4
|
|
|
5
5
|
## 1. Low-code page builder
|
|
6
6
|
|
|
@@ -17,21 +17,21 @@ window.page = {
|
|
|
17
17
|
createChatSdk({
|
|
18
18
|
container: '#chat',
|
|
19
19
|
llm: { apiKey, baseUrl: 'https://api.deepseek.com/v1', model: 'deepseek-chat', temperature: 0.3 },
|
|
20
|
-
systemPrompt: '你是页面搭建助手。用
|
|
21
|
-
|
|
20
|
+
systemPrompt: '你是页面搭建助手。用 edit_data_slot 按 jsonPath 增量改 components,不要重传整树。',
|
|
21
|
+
dataSlots: [
|
|
22
22
|
{ path: 'page.components', description: '组件树',
|
|
23
23
|
schema: z.array(z.object({
|
|
24
24
|
id: z.string(), type: z.string(),
|
|
25
25
|
props: z.record(z.any()),
|
|
26
26
|
})) },
|
|
27
27
|
],
|
|
28
|
-
onEvent(e) { if (e.type === '
|
|
28
|
+
onEvent(e) { if (e.type === 'data_slot_change') renderCanvas() }, // canvas reactive refresh
|
|
29
29
|
checkpoint: true, // bad edit → one-click rollback
|
|
30
|
-
approval: { tools: ['
|
|
30
|
+
approval: { tools: ['set_data_slot', 'edit_data_slot'] }, // confirm writes
|
|
31
31
|
}).mount()
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
User: "顶部 Banner 改深色、主标题加粗、加一张新品卡" → AI calls `
|
|
34
|
+
User: "顶部 Banner 改深色、主标题加粗、加一张新品卡" → AI calls `edit_data_slot` per component.
|
|
35
35
|
|
|
36
36
|
## 2. Form designer
|
|
37
37
|
|
|
@@ -48,7 +48,7 @@ window.form = {
|
|
|
48
48
|
createChatSdk({
|
|
49
49
|
container: '#chat', llm: { ... },
|
|
50
50
|
systemPrompt: '你是表单设计助手。改 form.fields 的字段定义,保持 schema 合法。',
|
|
51
|
-
|
|
51
|
+
dataSlots: [
|
|
52
52
|
{ path: 'form.fields', description: '字段定义数组',
|
|
53
53
|
schema: z.array(z.object({
|
|
54
54
|
name: z.string(), label: z.string(),
|
|
@@ -58,7 +58,7 @@ createChatSdk({
|
|
|
58
58
|
cascade: z.boolean().optional(),
|
|
59
59
|
})) },
|
|
60
60
|
],
|
|
61
|
-
onEvent(e) { if (e.type === '
|
|
61
|
+
onEvent(e) { if (e.type === 'data_slot_change') renderForm() },
|
|
62
62
|
}).mount()
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -66,7 +66,7 @@ User: "手机号加格式校验、地址改三级联动" → AI patches `form.fi
|
|
|
66
66
|
|
|
67
67
|
## 3. CMS batch operation
|
|
68
68
|
|
|
69
|
-
Bulk-edit a product list; use `
|
|
69
|
+
Bulk-edit a product list; use `eval_script` or `search_data_slot` + `edit_data_slot` for batch ops.
|
|
70
70
|
|
|
71
71
|
```ts
|
|
72
72
|
window.products = [
|
|
@@ -77,18 +77,18 @@ window.products = [
|
|
|
77
77
|
|
|
78
78
|
createChatSdk({
|
|
79
79
|
container: '#chat', llm: { ... },
|
|
80
|
-
systemPrompt: '你是运营助手。批量改 products;标题加前缀用
|
|
81
|
-
|
|
80
|
+
systemPrompt: '你是运营助手。批量改 products;标题加前缀用 eval_script,按条件筛选用 search_data_slot。',
|
|
81
|
+
dataSlots: [
|
|
82
82
|
{ path: 'products', description: '商品列表',
|
|
83
83
|
schema: z.array(z.object({
|
|
84
84
|
id: z.number(), title: z.string(), price: z.number(), highlight: z.boolean(),
|
|
85
85
|
})) },
|
|
86
86
|
],
|
|
87
|
-
onEvent(e) { if (e.type === '
|
|
87
|
+
onEvent(e) { if (e.type === 'data_slot_change') renderTable() },
|
|
88
88
|
}).mount()
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
User: "标题加『限时』前缀、低于 100 元的标红" → AI uses `
|
|
91
|
+
User: "标题加『限时』前缀、低于 100 元的标红" → AI uses `eval_script` for the prefix loop + `search_data_slot` to find `<100` then `edit_data_slot` to set `highlight`.
|
|
92
92
|
|
|
93
93
|
## 4. Ops config console
|
|
94
94
|
|
|
@@ -103,13 +103,13 @@ window.config = {
|
|
|
103
103
|
createChatSdk({
|
|
104
104
|
container: '#chat', llm: { ... },
|
|
105
105
|
systemPrompt: '你是运维助手。改 config 前必须经用户确认。',
|
|
106
|
-
|
|
106
|
+
dataSlots: [
|
|
107
107
|
{ path: 'config.expA', description: '实验A',
|
|
108
108
|
schema: z.object({ threshold: z.number().min(0).max(1), enabled: z.boolean() }) },
|
|
109
109
|
{ path: 'config.featureB', description: 'B开关',
|
|
110
110
|
schema: z.object({ enabled: z.boolean() }) },
|
|
111
111
|
],
|
|
112
|
-
approval: { tools: ['
|
|
112
|
+
approval: { tools: ['set_data_slot', 'edit_data_slot'] }, // human-in-the-loop
|
|
113
113
|
checkpoint: true,
|
|
114
114
|
capabilities: { verify: true }, // write-back read + schema check
|
|
115
115
|
}).mount()
|
|
@@ -119,7 +119,7 @@ User: "A 实验阈值调到 30%、关掉 B 开关" → AI proposes writes → us
|
|
|
119
119
|
|
|
120
120
|
## 5. AI-native assistant (no page data, custom tools)
|
|
121
121
|
|
|
122
|
-
The agent drives your product's own API via custom tools (no
|
|
122
|
+
The agent drives your product's own API via custom tools (no dataSlotOps).
|
|
123
123
|
|
|
124
124
|
```ts
|
|
125
125
|
const lookupTool = defineTool({
|
|
@@ -134,7 +134,7 @@ createChatSdk({
|
|
|
134
134
|
llm: { ... },
|
|
135
135
|
systemPrompt: '你是订单助手。用 lookup_order 查询。',
|
|
136
136
|
tools: [lookupTool],
|
|
137
|
-
capabilities: {
|
|
137
|
+
capabilities: { dataSlotOps: false, fetch: false }, // pure custom-tool agent
|
|
138
138
|
}).mount()
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -146,7 +146,7 @@ Pure research: fetch docs, parallel subagents for multi-source investigation.
|
|
|
146
146
|
createChatSdk({
|
|
147
147
|
container: '#chat', llm: { ... },
|
|
148
148
|
systemPrompt: '你是调研助手。多源对比用 spawn_agents 并行委派。',
|
|
149
|
-
capabilities: {
|
|
149
|
+
capabilities: { dataSlotOps: false }, // read-only, no page edits
|
|
150
150
|
subagent: { allowedTools: ['fetch_document'] },
|
|
151
151
|
contextPreset: 'conservative', // long research sessions
|
|
152
152
|
}).mount()
|
|
@@ -154,7 +154,7 @@ createChatSdk({
|
|
|
154
154
|
|
|
155
155
|
## 7. Headless server-side (Node.js)
|
|
156
156
|
|
|
157
|
-
Run the agent in Node (no browser). Provide `globalThis.window` only if you enable
|
|
157
|
+
Run the agent in Node (no browser). Provide `globalThis.window` only if you enable dataSlotOps.
|
|
158
158
|
|
|
159
159
|
```ts
|
|
160
160
|
// node mjs
|
|
@@ -165,7 +165,7 @@ const sdk = createChatSdk({
|
|
|
165
165
|
storage: 'memory',
|
|
166
166
|
llm: { apiKey, baseUrl, model },
|
|
167
167
|
systemPrompt: '...',
|
|
168
|
-
capabilities: {
|
|
168
|
+
capabilities: { dataSlotOps: false, fetch: false },
|
|
169
169
|
tools: [/* your tools */],
|
|
170
170
|
})
|
|
171
171
|
await sdk.mount()
|
|
@@ -179,8 +179,8 @@ sdk.unmount()
|
|
|
179
179
|
Two dialogs backed by one agent brain.
|
|
180
180
|
|
|
181
181
|
```ts
|
|
182
|
-
const a = createChatSdk({ id: 'shared', container: '#dlg-a', llm: {...}, shareContext: true,
|
|
183
|
-
const b = createChatSdk({ id: 'shared', container: '#dlg-b', llm: {...}, shareContext: true,
|
|
182
|
+
const a = createChatSdk({ id: 'shared', container: '#dlg-a', llm: {...}, shareContext: true, dataSlots }).mount()
|
|
183
|
+
const b = createChatSdk({ id: 'shared', container: '#dlg-b', llm: {...}, shareContext: true, dataSlots }).mount()
|
|
184
184
|
// a & b share messages/agent/vfs/todos/memory — two views of one agent
|
|
185
185
|
```
|
|
186
186
|
|
|
@@ -199,7 +199,7 @@ createChatSdk({
|
|
|
199
199
|
|
|
200
200
|
> Note: `@modelcontextprotocol/sdk` is an optional peerDep — install it only if you use `mcp`. Browser supports only remote transports (http/sse/websocket), not stdio.
|
|
201
201
|
|
|
202
|
-
## 10. Lazy-loaded components with dynamic schemas (dynamic
|
|
202
|
+
## 10. Lazy-loaded components with dynamic schemas (dynamic dataSlots)
|
|
203
203
|
|
|
204
204
|
Components loaded on demand with **different structures each** — register their schema at mount time, unregister at unmount. No need to pre-declare every possible component at `createChatSdk`.
|
|
205
205
|
|
|
@@ -207,14 +207,14 @@ Components loaded on demand with **different structures each** — register thei
|
|
|
207
207
|
const sdk = createChatSdk({
|
|
208
208
|
container: '#chat', llm: { ... },
|
|
209
209
|
// only the static container is pre-declared; per-component paths are dynamic
|
|
210
|
-
|
|
211
|
-
systemPrompt: '用
|
|
210
|
+
dataSlots: [{ path: 'app.components', description: '动态组件容器', schema: z.record(z.any()) }],
|
|
211
|
+
systemPrompt: '用 list_data_slots 查看当前可操作的组件 path,再按各自 schema 操作',
|
|
212
212
|
}).mount()
|
|
213
213
|
|
|
214
214
|
// 组件挂载(懒加载)→ 动态注册其 schema,立即对 AI 生效
|
|
215
215
|
function mountComp(comp: { id: string; type: CompType }) {
|
|
216
216
|
window.app.components[comp.id] = reactive(comp)
|
|
217
|
-
sdk.
|
|
217
|
+
sdk.addDataSlot({
|
|
218
218
|
path: `app.components.${comp.id}`,
|
|
219
219
|
description: `${comp.type} 组件`,
|
|
220
220
|
schema: compSchemas[comp.type], // 结构各异:banner/card/stat/chart 各自 schema
|
|
@@ -223,7 +223,7 @@ function mountComp(comp: { id: string; type: CompType }) {
|
|
|
223
223
|
// 组件卸载 → 动态移除注册(快照栈一并清理)
|
|
224
224
|
function unmountComp(id: string) {
|
|
225
225
|
delete window.app.components[id]
|
|
226
|
-
sdk.
|
|
226
|
+
sdk.removeDataSlot(`app.components.${id}`)
|
|
227
227
|
}
|
|
228
228
|
```
|
|
229
229
|
|
package/types/index.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export type StreamHandler = (event: StreamEvent) => void;
|
|
|
45
45
|
/**
|
|
46
46
|
* SDK 事件(供 createChatSdk({ onEvent }) 订阅常用时机)。
|
|
47
47
|
* 复用 StreamEvent(round_start/reasoning/text/tool_call/tool_result/subagent/done;approval_request 不外发)
|
|
48
|
-
* + 额外时机:
|
|
48
|
+
* + 额外时机:data_slot_change / message_update / error。
|
|
49
49
|
*/
|
|
50
50
|
export type SdkEvent =
|
|
51
51
|
| { type: 'round_start'; round: number }
|
|
@@ -55,7 +55,7 @@ export type SdkEvent =
|
|
|
55
55
|
| { type: 'tool_result'; name: string; result: string; status: 'done' | 'error' }
|
|
56
56
|
| { type: 'subagent'; taskId: string; label: string; kind: 'tool_call' | 'tool_result'; name: string; args?: any; result?: string; status?: 'done' | 'error' }
|
|
57
57
|
| { type: 'done'; content: string }
|
|
58
|
-
| { type: '
|
|
58
|
+
| { type: 'data_slot_change'; path: string; operation: 'set' | 'edit' | 'delete' | 'restore'; value?: unknown }
|
|
59
59
|
| { type: 'message_update'; count: number }
|
|
60
60
|
| { type: 'conflict'; conflict: PendingConflict }
|
|
61
61
|
| { type: 'error'; message: string };
|
|
@@ -80,7 +80,7 @@ export interface ChatDialogProps {
|
|
|
80
80
|
|
|
81
81
|
export interface ToolInfo { name: string; description: string; schema?: unknown; source?: string }
|
|
82
82
|
export interface SkillInfo { name: string; description: string }
|
|
83
|
-
export interface
|
|
83
|
+
export interface DataSlotInfo { path: string; description: string; schema?: unknown }
|
|
84
84
|
export interface SubagentInfo {
|
|
85
85
|
enabled: boolean;
|
|
86
86
|
maxDepth: number;
|
|
@@ -108,7 +108,7 @@ export interface AgentInfo {
|
|
|
108
108
|
systemPrompt: string;
|
|
109
109
|
tools: ToolInfo[];
|
|
110
110
|
skills: SkillInfo[];
|
|
111
|
-
|
|
111
|
+
dataSlots: DataSlotInfo[];
|
|
112
112
|
memory: string;
|
|
113
113
|
middleware: string[];
|
|
114
114
|
todos: { content: string; status: string }[];
|
|
@@ -149,35 +149,35 @@ export type ChatModelLike = {
|
|
|
149
149
|
bindTools: (tools: any[]) => any;
|
|
150
150
|
};
|
|
151
151
|
|
|
152
|
-
export interface
|
|
152
|
+
export interface DataSlotSpec {
|
|
153
153
|
/** window 上的路径,支持点号嵌套 */
|
|
154
154
|
path: string;
|
|
155
155
|
description: string;
|
|
156
156
|
/** 值的 zod schema(写入时校验) */
|
|
157
157
|
schema: any;
|
|
158
158
|
}
|
|
159
|
-
/**
|
|
160
|
-
export interface
|
|
159
|
+
/** createDataSlotOps 选项(审计回调 / 只读探测 / 快照上限 / 字段白名单读) */
|
|
160
|
+
export interface DataSlotOpsOptions {
|
|
161
161
|
onAudit?: (entry: { op: string; path: string; value?: any; detail?: string; timestamp: number }) => void;
|
|
162
162
|
allowRawRead?: boolean;
|
|
163
163
|
maxSnapshots?: number;
|
|
164
164
|
/**
|
|
165
165
|
* 字段白名单读模式(默认 true):仅允许读「注册 path 自身 / 其后代」,禁止读未注册的祖先,
|
|
166
|
-
* 防止 LLM 经
|
|
166
|
+
* 防止 LLM 经 get_data_slot('page') 把整个大 JSON 拉进上下文。
|
|
167
167
|
* 集成方注册「可操作子路径」(如 page.theme.color / page.components)而非顶层时,默认即「LLM 只见声明字段」。
|
|
168
168
|
* 设 false 回退原行为(允许读注册 path 的祖先,即整体读)。
|
|
169
169
|
*/
|
|
170
170
|
whitelist?: boolean;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
/**
|
|
174
|
-
export interface
|
|
173
|
+
/** 数据槽注册表控制器(运行时动态增删;createDataSlotOps 返回的工具数组上以不可枚举属性 `controller` 挂载) */
|
|
174
|
+
export interface DataSlotOpsController {
|
|
175
175
|
/** 新增/覆盖一个属性注册项(运行时懒加载组件场景);覆盖时旧快照栈保留 */
|
|
176
|
-
add(spec:
|
|
176
|
+
add(spec: DataSlotSpec): void;
|
|
177
177
|
/** 移除一个属性注册项;返回是否确实存在并移除。快照栈一并清理 */
|
|
178
178
|
remove(path: string): boolean;
|
|
179
179
|
/** 列出当前所有注册项(反映动态增删后的最新状态) */
|
|
180
|
-
list():
|
|
180
|
+
list(): DataSlotSpec[];
|
|
181
181
|
/** 是否已注册某 path */
|
|
182
182
|
has(path: string): boolean;
|
|
183
183
|
}
|
|
@@ -217,7 +217,7 @@ export interface VerifyMiddlewareOptions {
|
|
|
217
217
|
}
|
|
218
218
|
/** createWriteBackCheck 选项 */
|
|
219
219
|
export interface WriteBackCheckOptions {
|
|
220
|
-
/** path → zod schema(由 createChatSdk 从
|
|
220
|
+
/** path → zod schema(由 createChatSdk 从 dataSlots 构造注入);省略则只校验「读回非空」 */
|
|
221
221
|
schemas?: Record<string, any>;
|
|
222
222
|
/** 读 window 的根对象(默认 globalThis.window) */
|
|
223
223
|
window?: unknown;
|
|
@@ -325,12 +325,12 @@ export interface ChatSdkOptions {
|
|
|
325
325
|
tools?: any[];
|
|
326
326
|
skills?: SkillSpec[];
|
|
327
327
|
memory?: string;
|
|
328
|
-
|
|
328
|
+
dataSlots?: DataSlotSpec[];
|
|
329
329
|
permissions?: PermissionRule[];
|
|
330
330
|
/** 自定义中间件(注入到内置中间件之后;可拦截/观察模型调用、工具、prompt) */
|
|
331
331
|
middleware?: any[];
|
|
332
332
|
vfs?: { initialFiles?: Record<string, string>; maxBytes?: number };
|
|
333
|
-
/** 每个
|
|
333
|
+
/** 每个 数据槽最多保留快照数(默认 20) */
|
|
334
334
|
maxSnapshots?: number;
|
|
335
335
|
/** 内存中保留的对话轮数上限(默认 50);超限把最旧轮次压缩为摘要 system 消息(防 OOM);0 关闭 */
|
|
336
336
|
maxMemoryRounds?: number;
|
|
@@ -345,7 +345,7 @@ export interface ChatSdkOptions {
|
|
|
345
345
|
/** 模型最大输出(token);顶层声明对 llm 实例场景也生效,缺省按 model 名查表 */
|
|
346
346
|
maxOutputTokens?: number;
|
|
347
347
|
/** 子 agent 委派(默认开启;{ enabled: false } 关闭) */
|
|
348
|
-
capabilities?: {
|
|
348
|
+
capabilities?: { dataSlotOps?: boolean; fetch?: boolean; planning?: boolean; skills?: boolean; vfs?: boolean; summarization?: boolean; memory?: boolean; subagent?: boolean; verify?: boolean };
|
|
349
349
|
subagent?: { enabled?: boolean; allowedTools?: string[]; systemPrompt?: string; temperature?: number; maxTokens?: number; skills?: SkillSpec[]; llm?: LLMConfig | ChatModelLike; maxDepth?: number; maxParallel?: number };
|
|
350
350
|
/** 预声明子 agent 列表:每个用同主配置方式声明,自动生成 use_<id> 委派工具(与 spawn_agent 共存) */
|
|
351
351
|
subagents?: SubagentConfig[];
|
|
@@ -370,7 +370,7 @@ export interface ChatSdkOptions {
|
|
|
370
370
|
/** 摘要 LLM 超时毫秒(默认 15000;超时回退索引摘要) */
|
|
371
371
|
summaryTimeoutMs?: number;
|
|
372
372
|
/**
|
|
373
|
-
* SDK 事件回调:订阅常用时机(
|
|
373
|
+
* SDK 事件回调:订阅常用时机(数据槽变化 / 消息更新 / 工具调用 / 流式文本 / 轮次 / 错误)。
|
|
374
374
|
* UI 与 headless 模式均生效;用于外部联动(宿主页面响应式刷新、埋点、日志),替代轮询。
|
|
375
375
|
* approval_request 不外发(UI 已处理)。
|
|
376
376
|
*/
|
|
@@ -389,27 +389,27 @@ export interface ChatSdk {
|
|
|
389
389
|
send(message: string): Promise<string>;
|
|
390
390
|
switchSession(sessionId?: string): Promise<string>;
|
|
391
391
|
stream: (messages: AgentMessage[], onEvent: StreamHandler, signal?: AbortSignal) => Promise<string>;
|
|
392
|
-
/** 检视 agent 详细信息(tools/skills/
|
|
392
|
+
/** 检视 agent 详细信息(tools/skills/dataSlots/middleware/todos) */
|
|
393
393
|
inspect(): AgentInfo;
|
|
394
|
-
/** 回退到最近一次正常 checkpoint(整体还原对话历史 +
|
|
394
|
+
/** 回退到最近一次正常 checkpoint(整体还原对话历史 + 数据槽注册项 + vfs + todos);需开启 checkpoint,无可用返回 false */
|
|
395
395
|
restoreLastCheckpoint(): boolean;
|
|
396
396
|
/** 列出可用 checkpoint(回退点);需开启 checkpoint,未开启返回空数组 */
|
|
397
397
|
listCheckpoints(): CheckpointMeta[];
|
|
398
398
|
/** 运行时订阅 SDK 事件(可多个监听器,返回取消函数);与构造时 onEvent 互补 */
|
|
399
399
|
hook(handler: SdkEventHandler): () => void;
|
|
400
|
-
/** 运行时动态新增/覆盖一个
|
|
401
|
-
|
|
402
|
-
/** 运行时移除一个
|
|
403
|
-
|
|
404
|
-
/** 列出当前所有已注册
|
|
405
|
-
|
|
400
|
+
/** 运行时动态新增/覆盖一个 数据槽注册项(懒加载组件:组件挂载时注册其 schema);立即对 数据槽工具生效,无需重建 agent。需开启 dataSlotOps */
|
|
401
|
+
addDataSlot(spec: DataSlotSpec): void;
|
|
402
|
+
/** 运行时移除一个 数据槽注册项(组件卸载);返回是否确实存在并移除。快照栈一并清理 */
|
|
403
|
+
removeDataSlot(path: string): boolean;
|
|
404
|
+
/** 列出当前所有已注册 数据槽(反映动态增删后的最新状态) */
|
|
405
|
+
listDataSlots(): DataSlotSpec[];
|
|
406
406
|
/** 乐观锁冲突挂起状态(响应式 ref;无冲突为 null,有冲突时 UI 据此渲染冲突对话框)。headless 集成方可 watch 自建 UI */
|
|
407
407
|
pendingConflict: Ref<PendingConflict | null>;
|
|
408
408
|
/** 冲突解决:用户点「保留外部」(keep_external)/「强制覆盖」(overwrite)/「回退」(restore) → 收口挂起的 conflict,被挂起的工具调用继续 */
|
|
409
409
|
resolveConflict(action: ConflictResolution['action']): void;
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
/** 乐观锁冲突挂起(
|
|
412
|
+
/** 乐观锁冲突挂起(dataSlotOps 写入时 expectedHash 不匹配,挂起等用户决定) */
|
|
413
413
|
export interface PendingConflict {
|
|
414
414
|
id: number;
|
|
415
415
|
path: string;
|
|
@@ -428,7 +428,7 @@ export type ConflictResolution =
|
|
|
428
428
|
| { action: 'overwrite' }
|
|
429
429
|
| { action: 'restore' };
|
|
430
430
|
|
|
431
|
-
/** 乐观锁冲突信息(
|
|
431
|
+
/** 乐观锁冲突信息(dataSlotOps onConflict 回调参数) */
|
|
432
432
|
export interface ConflictInfo {
|
|
433
433
|
path: string;
|
|
434
434
|
op: 'set' | 'edit' | 'delete';
|
|
@@ -446,12 +446,12 @@ export declare function defineTool(opts: {
|
|
|
446
446
|
schema: any;
|
|
447
447
|
handler: (args: any) => unknown | Promise<unknown>;
|
|
448
448
|
}): any;
|
|
449
|
-
export declare function
|
|
450
|
-
export declare function selectBuiltinTools(caps: {
|
|
451
|
-
export declare function createUsageHintsMiddleware(caps: { planning?: boolean;
|
|
449
|
+
export declare function createDataSlotOps(props: DataSlotSpec[], opts?: DataSlotOpsOptions): any[];
|
|
450
|
+
export declare function selectBuiltinTools(caps: { dataSlotOps?: boolean; fetch?: boolean } | undefined, dataSlotOps: any[], fetchDocs: any[]): any[];
|
|
451
|
+
export declare function createUsageHintsMiddleware(caps: { planning?: boolean; dataSlotOps?: boolean; subagent?: boolean } | undefined, hasDataSlotOps: boolean): any;
|
|
452
452
|
export declare const fetchDocTools: any[];
|
|
453
453
|
export declare const fetchTools: any[];
|
|
454
|
-
export declare function
|
|
454
|
+
export declare function defineDataSlotToolset(props: DataSlotSpec[], opts?: DataSlotOpsOptions): any[];
|
|
455
455
|
export declare function defineSkill(spec: SkillSpec): SkillSpec;
|
|
456
456
|
export declare function createAgent(options: any): any;
|
|
457
457
|
/** 检测模型把工具调用写成文本(伪 XML/标签)而非标准 tool_calls 的异常格式;主循环据此回灌 feedback 自纠 */
|
|
@@ -470,13 +470,13 @@ export declare function createMemoryBackend(): StorageBackend;
|
|
|
470
470
|
export declare function createWebStorageBackend(storage: Storage): StorageBackend;
|
|
471
471
|
export declare function isQuotaError(err: unknown): boolean;
|
|
472
472
|
|
|
473
|
-
// ============ 大 JSON 查询/搜索/沙箱脚本(
|
|
473
|
+
// ============ 大 JSON 查询/搜索/沙箱脚本(dataSlotQuery)============
|
|
474
474
|
export interface JpNode {
|
|
475
475
|
/** 相对属性根的点号路径(数组索引用数字,如 components.0.text) */
|
|
476
476
|
path: string;
|
|
477
477
|
/** 匹配元素值 */
|
|
478
478
|
value: unknown;
|
|
479
|
-
/** 父为数组时的索引(便于后续
|
|
479
|
+
/** 父为数组时的索引(便于后续 edit_data_slot 的 jsonPath 定位) */
|
|
480
480
|
index?: number;
|
|
481
481
|
}
|
|
482
482
|
export interface SearchHit {
|
|
@@ -550,10 +550,10 @@ export declare function createSubagentsMiddleware(opts: any): any;
|
|
|
550
550
|
export interface SubagentOptions { [k: string]: any }
|
|
551
551
|
export interface SubagentLlmConfig { [k: string]: any }
|
|
552
552
|
|
|
553
|
-
// checkpoint /
|
|
553
|
+
// checkpoint / dataSlotOps / permissions
|
|
554
554
|
export interface CheckpointDeps { [k: string]: any }
|
|
555
|
-
export interface
|
|
556
|
-
export interface
|
|
555
|
+
export interface DataSlotAuditEntry { [k: string]: any }
|
|
556
|
+
export interface DataSlotSnapshotEntry { [k: string]: any }
|
|
557
557
|
export type PermissionOp = string;
|
|
558
558
|
|
|
559
559
|
// vfs
|