@webskill/sdk 0.4.0 → 0.6.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/dist/agent.d.ts +2 -0
- package/dist/agent.js +909 -0
- package/dist/browser.d.ts +233 -4
- package/dist/browser.js +869 -19
- package/dist/{catalogComponents-KsujmL4b-Clx1kCnU.js → catalogComponents-Dr5dFMAb-Dacibl1e.js} +372 -126
- package/dist/{dist-D9Lcn5Pp.js → dist-DnYG2-eY.js} +642 -39
- package/dist/{dist-C-Sh0MDU.js → dist-DusANsrn.js} +1035 -99
- package/dist/{env--jJB-TSX-04klhTYi.js → env-8cY40DXB-CGnEVZby.js} +7 -6
- package/dist/{env-BPUBZCwJ-4jat_SVG.d.ts → env-AK3cSMEA-Dli6QU5E.d.ts} +4 -3
- package/dist/governance.d.ts +46 -4
- package/dist/governance.js +45 -2
- package/dist/{index-CHXxDccV.d.ts → index-BMocOEi0.d.ts} +106 -10
- package/dist/index-BuTpBMzr.d.ts +474 -0
- package/dist/{index-DLfR2Y6I.d.ts → index-C-KFAZoF.d.ts} +337 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/mcp.d.ts +39 -8
- package/dist/mcp.js +53 -19
- package/dist/{memoryArtifactStore-BtOeB_hm-tj3fC5ip.js → memoryArtifactStore-52Zn9npI-BMPYwvoy.js} +10 -2
- package/dist/node.d.ts +4 -4
- package/dist/node.js +9 -2
- package/dist/{openUiLibrary-YLS-cxyT-C96jWDQq.js → openUiLibrary-Bdrji9qK-DzAxRlTY.js} +3 -3
- package/dist/{skillVersionStore-uyefLPR1-DXOzbksv.d.ts → skillVersionStore-BzLbzFOL-CxdAFWO2.d.ts} +4 -3
- package/dist/{testing-DDCJWvgA.js → testing-CYTFqkDm.js} +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +3 -3
- package/dist/{types-7Wcg--Vh-1YlQ4jF9.d.ts → types-4pg-qp_I-Gq63X8Oa.d.ts} +55 -5
- package/dist/ui-react.d.ts +26 -5
- package/dist/ui-react.js +147 -29
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +30 -6
- package/dist/ui.d.ts +4 -4
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-CSTbhBe_-CYIs5BX8.js → webskillLitCatalog-_mugzRHx-B_54vxum.js} +88 -2
- package/package.json +6 -1
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { a as InteractionOrigin, b as UiBridge } from "./types-4pg-qp_I-Gq63X8Oa.js";
|
|
2
|
+
import { O as ExternalToolSource } from "./index-C-KFAZoF.js";
|
|
3
|
+
//#region ../agent/dist/index.d.ts
|
|
4
|
+
//#region src/todo/types.d.ts
|
|
5
|
+
/** 待办条目状态:未开始 / 进行中 / 已完成(FR-3.1) */
|
|
6
|
+
type TodoStatus = 'pending' | 'in-progress' | 'completed';
|
|
7
|
+
interface TodoItem {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
status: TodoStatus;
|
|
11
|
+
/** 委派给子 agent 时填入(串行委派批次使用) */
|
|
12
|
+
delegatedTo?: string;
|
|
13
|
+
}
|
|
14
|
+
interface TodoList {
|
|
15
|
+
readonly items: readonly TodoItem[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 清单变更事件(FR-3.3)。
|
|
19
|
+
* 走既有的运行事件通道下发:工具结果里的 `$todo` 标记 → runtime 记 trace →
|
|
20
|
+
* console 读同一份 trace 文件重建时间线,不新建通道。
|
|
21
|
+
*/
|
|
22
|
+
type TodoEvent = {
|
|
23
|
+
type: 'todo.created';
|
|
24
|
+
items: readonly TodoItem[];
|
|
25
|
+
} | {
|
|
26
|
+
type: 'todo.updated';
|
|
27
|
+
item: TodoItem;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'todo.cleared';
|
|
30
|
+
};
|
|
31
|
+
type TodoListener = (event: TodoEvent) => void;
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/todo/store.d.ts
|
|
34
|
+
/**
|
|
35
|
+
* 待办清单状态容器(FR-3.1 / FR-3.2 / FR-3.3)。
|
|
36
|
+
*
|
|
37
|
+
* 单一进行中约束在**容器内部**强制,而不是靠提示词约束模型:
|
|
38
|
+
* 模型偶尔会同时标记多条,UI 上出现两个「进行中」时用户无法判断实际进度。
|
|
39
|
+
* 这里把 `in-progress` 当成互斥资源,置位即降级其余条目。
|
|
40
|
+
*/
|
|
41
|
+
declare class TodoStore {
|
|
42
|
+
#private;
|
|
43
|
+
snapshot(): TodoList;
|
|
44
|
+
/** 订阅变更;返回退订函数 */
|
|
45
|
+
subscribe(listener: TodoListener): () => void;
|
|
46
|
+
/** 整表替换(模型每次给出完整清单,避免第二套增量协议)。多条 in-progress 时只保留第一条 */
|
|
47
|
+
create(items: readonly TodoItem[]): TodoList;
|
|
48
|
+
/**
|
|
49
|
+
* 更新单条。置为 `in-progress` 时其余进行中条目降级为 `pending`,
|
|
50
|
+
* 每条降级各发一次 `todo.updated`,事件序列与状态变化一一对应。
|
|
51
|
+
*/
|
|
52
|
+
update(id: string, patch: {
|
|
53
|
+
status?: TodoStatus;
|
|
54
|
+
title?: string;
|
|
55
|
+
delegatedTo?: string;
|
|
56
|
+
}): TodoList;
|
|
57
|
+
clear(): void;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/todo/toolSource.d.ts
|
|
61
|
+
declare const MANAGE_TODO_TOOL = "manage_todo";
|
|
62
|
+
interface TodoToolSourceOptions {
|
|
63
|
+
/** 复用宿主已持有的容器(chatbot 用它驱动消息流内的清单面板);缺省新建 */
|
|
64
|
+
store?: TodoStore;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 把待办清单接到既有的工具协议上(设计 03 §4 红线:不引入第二个循环、
|
|
68
|
+
* 不引入第二套工具协议、包内不含执行器)。
|
|
69
|
+
*
|
|
70
|
+
* 变更经工具结果的 `$todo` 标记回传,runtime 据此记 trace——
|
|
71
|
+
* 与 `$chart` / `$surface` 同一条既有通道,console 读同一份 trace 文件重建时间线。
|
|
72
|
+
*/
|
|
73
|
+
declare function createTodoToolSource(options?: TodoToolSourceOptions): ExternalToolSource & {
|
|
74
|
+
store: TodoStore;
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/prompts/todo.d.ts
|
|
78
|
+
/**
|
|
79
|
+
* 待办清单提示词片段(FR-3.4)。
|
|
80
|
+
*
|
|
81
|
+
* 体积约束(设计 03 §8):开启后常驻——每次请求都带,所以必须比生成式 UI 的
|
|
82
|
+
* ~14 KB catalog 小一个数量级。这里刻意只给规则,不给示例对话。
|
|
83
|
+
*/
|
|
84
|
+
declare const TODO_SYSTEM_PROMPT: string;
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/skillGeneration/types.d.ts
|
|
87
|
+
/** 生成产物(设计 02 §1.2):SKILL.md 全文 + 附带脚本/引用文件 */
|
|
88
|
+
interface GeneratedSkillDraft {
|
|
89
|
+
name: string;
|
|
90
|
+
description: string;
|
|
91
|
+
/** SKILL.md 全文,含 frontmatter */
|
|
92
|
+
content: string;
|
|
93
|
+
files?: readonly {
|
|
94
|
+
path: string;
|
|
95
|
+
content: string;
|
|
96
|
+
}[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 候选收货端口。实现由宿主注入——`@webskill/agent` 不依赖 `@webskill/governance`
|
|
100
|
+
* (治理层要求宿主提供治理根与审计存储,是可选层)。
|
|
101
|
+
* `@webskill/governance` 的 `createCandidateSink()` 是现成实现。
|
|
102
|
+
*/
|
|
103
|
+
interface SkillCandidateSink {
|
|
104
|
+
submit(input: {
|
|
105
|
+
draft: GeneratedSkillDraft;
|
|
106
|
+
/** 触发生成的会话(审计留痕与 console 溯源用) */
|
|
107
|
+
sessionId?: string;
|
|
108
|
+
/** 用户确认的时刻(FR-9.7 要求审计能查到确认事实) */
|
|
109
|
+
confirmedAt: string;
|
|
110
|
+
}): Promise<{
|
|
111
|
+
id: string;
|
|
112
|
+
}>;
|
|
113
|
+
}
|
|
114
|
+
/** 频率约束(设计 02 §1.6) */
|
|
115
|
+
interface SkillGenerationPolicy {
|
|
116
|
+
/** 单次会话内的生成次数上限,默认 3 */
|
|
117
|
+
maxPerSession?: number;
|
|
118
|
+
}
|
|
119
|
+
type SkillGenerationOutcome = {
|
|
120
|
+
status: 'submitted';
|
|
121
|
+
candidateId: string;
|
|
122
|
+
name: string;
|
|
123
|
+
} | {
|
|
124
|
+
status: 'declined';
|
|
125
|
+
};
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region src/skillGeneration/generator.d.ts
|
|
128
|
+
interface SkillGeneratorOptions {
|
|
129
|
+
/** 确认交互走既有的 UiBridge——不新造交互通道(设计 02 §1.4) */
|
|
130
|
+
ui: UiBridge;
|
|
131
|
+
/** 缺省表示宿主没接治理层,调用时报 SKILL_GENERATION_DISABLED */
|
|
132
|
+
sink?: SkillCandidateSink;
|
|
133
|
+
policy?: SkillGenerationPolicy;
|
|
134
|
+
/** 生成所属会话,写入审计与候选 metadata */
|
|
135
|
+
sessionId?: () => string | undefined;
|
|
136
|
+
now?: () => Date;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* 技能自动生成策略。生成动作是策略而不是内核:它不进入 `AgentLoop`,
|
|
140
|
+
* 而是经既有的 `ExternalToolSource` 扩展点接入(设计 02 §0)。
|
|
141
|
+
*
|
|
142
|
+
* 固定顺序:生成 → 校验 → 确认 → 提交。任何一步不通过都不产生候选。
|
|
143
|
+
* @experimental
|
|
144
|
+
*/
|
|
145
|
+
declare class SkillGenerator {
|
|
146
|
+
#private;
|
|
147
|
+
constructor(options: SkillGeneratorOptions);
|
|
148
|
+
/** 本会话剩余的生成次数 */
|
|
149
|
+
get remaining(): number;
|
|
150
|
+
generate(draft: GeneratedSkillDraft): Promise<SkillGenerationOutcome>;
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/skillGeneration/toolSource.d.ts
|
|
154
|
+
declare const GENERATE_SKILL_TOOL = "generate_skill";
|
|
155
|
+
type SkillGenerationToolSourceOptions = SkillGeneratorOptions;
|
|
156
|
+
/**
|
|
157
|
+
* 把技能自动生成接到既有的工具协议上(设计 02 §1.3)。
|
|
158
|
+
*
|
|
159
|
+
* 该工具源默认不注册:宿主只有在开关打开时才把它放进工具表,
|
|
160
|
+
* 关闭时模型的工具列表里根本没有这个名字。
|
|
161
|
+
*/
|
|
162
|
+
declare function createSkillGenerationToolSource(options: SkillGenerationToolSourceOptions): ExternalToolSource;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/prompts/skillGeneration.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* 技能自动生成的系统提示词。默认不注册工具,因此这段提示词只在
|
|
167
|
+
* 宿主打开开关时才进入上下文(设计 02 §1.3)。
|
|
168
|
+
*
|
|
169
|
+
* 触发条件写成正面清单而不是「不要自发调用」(0.6.0 FR-18.5):实测中后者会连
|
|
170
|
+
* 「帮我写一份流程规范」这类明确的沉淀请求一起抑制掉,开关等于白开。
|
|
171
|
+
*/
|
|
172
|
+
declare const SKILL_GENERATION_SYSTEM_PROMPT: string;
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/delegation/types.d.ts
|
|
175
|
+
/** 一次委派请求(设计 03 §12) */
|
|
176
|
+
interface DelegationRequest {
|
|
177
|
+
/** 关联的待办条目;委派关系经它落到清单上(FR-11.5) */
|
|
178
|
+
todoId: string;
|
|
179
|
+
task: string;
|
|
180
|
+
/** 子 agent 可用的工具子集;缺省继承父级 */
|
|
181
|
+
allowedTools?: readonly string[];
|
|
182
|
+
}
|
|
183
|
+
interface DelegationResult {
|
|
184
|
+
todoId: string;
|
|
185
|
+
outcome: 'completed' | 'failed';
|
|
186
|
+
/** 只回传结论,不回传子 agent 的中间历史(FR-11.3) */
|
|
187
|
+
summary: string;
|
|
188
|
+
}
|
|
189
|
+
/** 子 agent 的实际预算(父级剩余与自身上限取小,见 §15) */
|
|
190
|
+
interface DelegationBudget {
|
|
191
|
+
maxTurns: number;
|
|
192
|
+
timeoutMs: number;
|
|
193
|
+
}
|
|
194
|
+
/** 父 agent 当前剩余的预算;由宿主在委派发生的那一刻读取 */
|
|
195
|
+
interface ParentBudget {
|
|
196
|
+
remainingTurns: number;
|
|
197
|
+
remainingTimeoutMs: number;
|
|
198
|
+
}
|
|
199
|
+
interface SubAgentRunInput {
|
|
200
|
+
task: string;
|
|
201
|
+
/** 缺省表示继承父级工具集 */
|
|
202
|
+
allowedTools?: readonly string[];
|
|
203
|
+
budget: DelegationBudget;
|
|
204
|
+
/** 超时由编排器统一裁决:宿主须把它透传给子 run,中途取消即抛错 */
|
|
205
|
+
signal: AbortSignal;
|
|
206
|
+
/** 子 agent 发起交互时挂在 `InteractionRequest.origin` 上(FR-11.6) */
|
|
207
|
+
origin: InteractionOrigin;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* 子 agent 执行端口。**实现不在本包内**——包内不得含执行器(FR-A.4)。
|
|
211
|
+
* 宿主的实现通常是「再跑一次 `AgentLoop.run`,把结论摘要回传」。
|
|
212
|
+
*/
|
|
213
|
+
type SubAgentRunner = (input: SubAgentRunInput) => Promise<{
|
|
214
|
+
summary: string;
|
|
215
|
+
}>;
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/delegation/orchestrator.d.ts
|
|
218
|
+
interface DelegationOrchestratorOptions {
|
|
219
|
+
/** 缺省表示宿主没接子 agent 执行端口,调用时报 DELEGATION_UNAVAILABLE */
|
|
220
|
+
runner?: SubAgentRunner;
|
|
221
|
+
/** 委派发生的那一刻读取父级剩余预算(§15) */
|
|
222
|
+
parentBudget: () => ParentBudget;
|
|
223
|
+
/** 子 agent 自身上限;与父级剩余取小 */
|
|
224
|
+
policy?: Partial<DelegationBudget>;
|
|
225
|
+
/** 接上清单后委派关系在 UI 可见(FR-11.5) */
|
|
226
|
+
todos?: TodoStore;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* 串行委派编排器(设计 03 §13–§16)。
|
|
230
|
+
*
|
|
231
|
+
* 严格串行由**内部互斥**保证而不是调用方自觉:并发委派会产生并发待决交互,
|
|
232
|
+
* 而当前交互模型是单一待决 nonce,届时表现为「点了没反应」。
|
|
233
|
+
* 放开并发必须显式改这里的守卫,不会悄悄发生。
|
|
234
|
+
*
|
|
235
|
+
* 上下文隔离靠回值形状达成:只有 `summary` 回到父 agent,
|
|
236
|
+
* 子 agent 的消息历史根本不经过本对象。
|
|
237
|
+
* @experimental
|
|
238
|
+
*/
|
|
239
|
+
declare class DelegationOrchestrator {
|
|
240
|
+
#private;
|
|
241
|
+
constructor(options: DelegationOrchestratorOptions);
|
|
242
|
+
/** 当前正在执行的委派任务;无则 undefined */
|
|
243
|
+
get running(): string | undefined;
|
|
244
|
+
delegate(request: DelegationRequest): Promise<DelegationResult>;
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/delegation/toolSource.d.ts
|
|
248
|
+
declare const DELEGATE_TASK_TOOL = "delegate_task";
|
|
249
|
+
interface DelegationToolSourceOptions extends DelegationOrchestratorOptions {
|
|
250
|
+
/** 复用宿主已持有的编排器(同一个 run 内父 agent 只能有一个);缺省新建 */
|
|
251
|
+
orchestrator?: DelegationOrchestrator;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 把串行委派接到既有工具协议上(红线:不引入第二个循环、不引入第二套工具协议、
|
|
255
|
+
* 包内不含执行器——子 run 由宿主注入的 `runner` 执行)。
|
|
256
|
+
*
|
|
257
|
+
* 结果里只有 `summary`:上下文隔离不是靠调用方自律,是因为这里根本拿不到子 agent 的历史。
|
|
258
|
+
* @experimental
|
|
259
|
+
*/
|
|
260
|
+
declare function createDelegationToolSource(options: DelegationToolSourceOptions): ExternalToolSource & {
|
|
261
|
+
orchestrator: DelegationOrchestrator;
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/delegation/origin.d.ts
|
|
265
|
+
/**
|
|
266
|
+
* 给子 agent 的交互请求打上来源标识(FR-11.6)。
|
|
267
|
+
*
|
|
268
|
+
* 为什么是包装 bridge 而不是让编排器去改请求:交互请求由子 run 内部各处发起
|
|
269
|
+
* (缺参表单、confirm、授权),编排器看不到它们。宿主在构造子 run 的 bridge 时套一层,
|
|
270
|
+
* 所有出口就都带上了来源。
|
|
271
|
+
* @experimental
|
|
272
|
+
*/
|
|
273
|
+
declare function withDelegationOrigin(bridge: UiBridge, origin: InteractionOrigin): UiBridge;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/prompts/delegation.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* 串行委派的策略提示词(设计 03 §13)。
|
|
278
|
+
*
|
|
279
|
+
* 「一次只能有一个」是编排器的硬约束,这里写进提示词是为了让模型不去
|
|
280
|
+
* 尝试并行委派——被拒绝的调用会浪费一轮,而不是产生并发。
|
|
281
|
+
*/
|
|
282
|
+
declare const DELEGATION_SYSTEM_PROMPT: string;
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/perception/types.d.ts
|
|
285
|
+
/**
|
|
286
|
+
* 页面只读感知的策略层类型(需求 10)。
|
|
287
|
+
*
|
|
288
|
+
* 这一层刻意不含任何 DOM 概念:遍历实现在 `@webskill/browser`,
|
|
289
|
+
* 本包只定义「什么允许被读」以及读到的东西长什么样。
|
|
290
|
+
*/
|
|
291
|
+
/**
|
|
292
|
+
* 可感知范围白名单(FR-10.2,硬约束)。
|
|
293
|
+
*
|
|
294
|
+
* **没有默认值,空 `include` 就是什么都读不到。** 宿主忘了配的后果是
|
|
295
|
+
* 功能不可用,而不是全页泄露——失败方向必须落在安全那一侧。
|
|
296
|
+
* @experimental
|
|
297
|
+
*/
|
|
298
|
+
interface PerceptionScope {
|
|
299
|
+
/** 可感知的根节点选择器;未声明即不可读 */
|
|
300
|
+
include: readonly string[];
|
|
301
|
+
/** 从 include 子树中剪除的敏感区域(凭据输入、个人信息展示区等) */
|
|
302
|
+
exclude?: readonly string[];
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* 结构化元素描述(FR-10.4,硬约束):只有角色、名称、值。
|
|
306
|
+
*
|
|
307
|
+
* 不下发 HTML 原文有两条理由:HTML 里的 class / data 属性 / 注释远超模型
|
|
308
|
+
* 完成任务所需;且页面文本一旦以 HTML 形式进上下文,就多了一条注入通道。
|
|
309
|
+
* @experimental
|
|
310
|
+
*/
|
|
311
|
+
interface PerceivedNode {
|
|
312
|
+
/** 可访问性角色 */
|
|
313
|
+
role: string;
|
|
314
|
+
/** 可访问名称 */
|
|
315
|
+
name?: string;
|
|
316
|
+
/** 仅非敏感控件的当前值 */
|
|
317
|
+
value?: string;
|
|
318
|
+
/** 关联的图像分片 id(FR-12.1);节点里只放 id 不放 base64,否则 JSON 树会被截断切碎 */
|
|
319
|
+
imageId?: string;
|
|
320
|
+
/** 取像失败的降级说明(英文);不得静默丢弃(FR-12.1) */
|
|
321
|
+
imageNote?: string;
|
|
322
|
+
children?: readonly PerceivedNode[];
|
|
323
|
+
}
|
|
324
|
+
/** 随感知一起下发的一张图像(FR-12.1) @experimental */
|
|
325
|
+
interface PerceivedImage {
|
|
326
|
+
/** 与 `PerceivedNode.imageId` 对应 */
|
|
327
|
+
id: string;
|
|
328
|
+
mimeType: string;
|
|
329
|
+
/** base64,不含 `data:` 前缀 */
|
|
330
|
+
data: string;
|
|
331
|
+
/** 取像级别:`src` 为原图字节,`canvas` 为画布/SVG 读回 */
|
|
332
|
+
level: 'src' | 'canvas';
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* 取像预算与开关(FR-12.3 / FR-12.5)。
|
|
336
|
+
* 它只能来自宿主配置与当前模型能力,**不包含任何范围字段**:
|
|
337
|
+
* “读哪里”仍只由构造时的 `scope` 决定(AC-10.8)。
|
|
338
|
+
* @experimental
|
|
339
|
+
*/
|
|
340
|
+
interface PerceptionCaptureOptions {
|
|
341
|
+
/** false 时 reader 不得进入任何取像分支(抓完再丢弃不可接受) */
|
|
342
|
+
images: boolean;
|
|
343
|
+
maxImageBytes: number;
|
|
344
|
+
maxImages: number;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* reader 的完整产物。只实现文本的 reader 可以继续返回节点数组。
|
|
348
|
+
* @experimental
|
|
349
|
+
*/
|
|
350
|
+
interface PerceptionResult {
|
|
351
|
+
nodes: readonly PerceivedNode[];
|
|
352
|
+
images?: readonly PerceivedImage[];
|
|
353
|
+
/** 超出 `maxImages` 而未下发的张数 */
|
|
354
|
+
imagesOmitted?: number;
|
|
355
|
+
/** 取像失败的张数;失败不影响整次感知的成功与否 */
|
|
356
|
+
imageFailures?: number;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 页面读取实现的注入口(浏览器侧 `createDomPerceptionReader`)。
|
|
360
|
+
*
|
|
361
|
+
* 参数是宿主配置的 scope,不是模型给的——`PagePerceptionPolicy.perceive()`
|
|
362
|
+
* 根本不接受范围参数,模型没有可以影响它的入口(AC-10.8)。
|
|
363
|
+
* @experimental
|
|
364
|
+
*/
|
|
365
|
+
interface PagePerceptionReader {
|
|
366
|
+
read(scope: PerceptionScope, capture?: PerceptionCaptureOptions): Promise<readonly PerceivedNode[] | PerceptionResult> | readonly PerceivedNode[] | PerceptionResult;
|
|
367
|
+
}
|
|
368
|
+
/** 一次感知的留痕(FR-10.5 的 UI 提示与 FR-10.6 的审计共用同一条记录) @experimental */
|
|
369
|
+
interface PerceptionRecord {
|
|
370
|
+
/** ISO 8601 */
|
|
371
|
+
at: string;
|
|
372
|
+
/** 本次实际生效的白名单 */
|
|
373
|
+
include: readonly string[];
|
|
374
|
+
exclude: readonly string[];
|
|
375
|
+
/** 读到的顶层节点数;用于「它读的比我预期的多」这类判断 */
|
|
376
|
+
nodeCount: number;
|
|
377
|
+
/** 本次下发的图像张数,按取像级别分组(只在取像开启时存在) */
|
|
378
|
+
images?: {
|
|
379
|
+
src: number;
|
|
380
|
+
canvas: number;
|
|
381
|
+
};
|
|
382
|
+
imagesOmitted?: number;
|
|
383
|
+
/** 读取失败的张数;藏起来会让用户误以为模型看到了全部图片 */
|
|
384
|
+
imageFailures?: number;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 审计落盘端口。刻意只声明 `append` 的结构化子集,`FsAuditLog` 直接满足——
|
|
388
|
+
* agent 包不能依赖 governance,但审计不能因此变成「记在内存里」。
|
|
389
|
+
* @experimental
|
|
390
|
+
*/
|
|
391
|
+
interface PerceptionAuditSink {
|
|
392
|
+
append(event: {
|
|
393
|
+
type: string;
|
|
394
|
+
target: string;
|
|
395
|
+
data?: Record<string, unknown>;
|
|
396
|
+
}): Promise<unknown>;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/perception/policy.d.ts
|
|
400
|
+
interface PagePerceptionPolicyOptions {
|
|
401
|
+
/** 宿主声明的白名单;`include` 为空即整个能力不可用 */
|
|
402
|
+
scope: PerceptionScope;
|
|
403
|
+
reader: PagePerceptionReader;
|
|
404
|
+
/** FR-10.6:每次感知写审计。不注入即不留痕,装配方要自己承担这个选择 */
|
|
405
|
+
audit?: PerceptionAuditSink;
|
|
406
|
+
/** 审计事件的 target(缺省 `page`);多页面宿主可用它区分来源 */
|
|
407
|
+
auditTarget?: string;
|
|
408
|
+
now?(): string;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* 页面只读感知策略(需求 10)。
|
|
412
|
+
*
|
|
413
|
+
* **`perceive()` 不接受任何范围参数**——这是「白名单判定不受模型输出影响」
|
|
414
|
+
* (AC-10.8)的实现方式。不是先拿模型给的范围再去校验,而是模型压根没有
|
|
415
|
+
* 表达范围的入口:能被读的区域只由构造时的 `scope` 决定。
|
|
416
|
+
* 唯一的参数是取像预算(`PerceptionCaptureOptions`),它里面没有任何范围字段。
|
|
417
|
+
*
|
|
418
|
+
* 本类**没有**任何点击 / 输入 / 提交 / 导航 / 滚动方法(FR-10.7)。
|
|
419
|
+
* @experimental
|
|
420
|
+
*/
|
|
421
|
+
declare class PagePerceptionPolicy {
|
|
422
|
+
#private;
|
|
423
|
+
constructor(options: PagePerceptionPolicyOptions);
|
|
424
|
+
/** 白名单为空即不可用(FR-10.1/10.2):宿主没声明范围就没有这个能力 */
|
|
425
|
+
get enabled(): boolean;
|
|
426
|
+
get scope(): PerceptionScope;
|
|
427
|
+
/** 最近的感知记录(console 只读展示用),新的在前 */
|
|
428
|
+
get records(): readonly PerceptionRecord[];
|
|
429
|
+
/** FR-10.5:感知发生时通知 UI,chatbot 据此在消息流里标注一行 */
|
|
430
|
+
subscribe(listener: (record: PerceptionRecord) => void): () => void;
|
|
431
|
+
perceive(capture?: PerceptionCaptureOptions): Promise<{
|
|
432
|
+
nodes: readonly PerceivedNode[];
|
|
433
|
+
images: readonly PerceivedImage[];
|
|
434
|
+
imagesOmitted: number;
|
|
435
|
+
record: PerceptionRecord;
|
|
436
|
+
}>;
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/perception/toolSource.d.ts
|
|
440
|
+
declare const PERCEIVE_PAGE_TOOL = "perceive_page";
|
|
441
|
+
interface PagePerceptionToolSourceOptions {
|
|
442
|
+
policy: PagePerceptionPolicy;
|
|
443
|
+
/**
|
|
444
|
+
* 取像预算与开关(FR-12.5)。每次调用重取,设置或选中模型改完立刻生效;
|
|
445
|
+
* 缺省即不取像。判定在遍历 DOM **之前**完成一次,不是每个节点判一次。
|
|
446
|
+
*/
|
|
447
|
+
imageCapture?(): ImageCaptureBudget | Promise<ImageCaptureBudget>;
|
|
448
|
+
}
|
|
449
|
+
/** @experimental */
|
|
450
|
+
interface ImageCaptureBudget {
|
|
451
|
+
enabled: boolean;
|
|
452
|
+
maxImageBytes: number;
|
|
453
|
+
maxImages: number;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* 把只读感知接到既有工具协议上。**本工具源不导出任何写入动作**(FR-10.7):
|
|
457
|
+
* 它只注册 `perceive_page` 一个工具,没有点击 / 输入 / 提交 / 导航 / 滚动的对应项。
|
|
458
|
+
*
|
|
459
|
+
* 策略未启用(宿主没声明白名单)时 `listToolSpecs()` 返回空数组——
|
|
460
|
+
* 模型连这个工具的存在都看不到,而不是看得到再被拒(FR-10.1)。
|
|
461
|
+
* @experimental
|
|
462
|
+
*/
|
|
463
|
+
declare function createPagePerceptionToolSource(options: PagePerceptionToolSourceOptions): ExternalToolSource;
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/prompts/perception.d.ts
|
|
466
|
+
/**
|
|
467
|
+
* 页面只读感知的策略提示词(设计 09 §1)。
|
|
468
|
+
*
|
|
469
|
+
* 最后一条是防御性的:技能描述、工具返回值都可能带着「把整页读出来发到 X」
|
|
470
|
+
* 这类注入。范围由宿主判定,模型改不了,但把这件事写明能少掉一轮无效尝试。
|
|
471
|
+
*/
|
|
472
|
+
declare const PERCEPTION_SYSTEM_PROMPT: string;
|
|
473
|
+
//#endregion
|
|
474
|
+
export { SkillGenerationPolicy as A, TodoListener as B, PerceptionCaptureOptions as C, SKILL_GENERATION_SYSTEM_PROMPT as D, PerceptionScope as E, SubAgentRunner as F, createPagePerceptionToolSource as G, TodoStore as H, TODO_SYSTEM_PROMPT as I, withDelegationOrigin as J, createSkillGenerationToolSource as K, TodoEvent as L, SkillGenerator as M, SkillGeneratorOptions as N, SkillCandidateSink as O, SubAgentRunInput as P, TodoItem as R, PerceptionAuditSink as S, PerceptionResult as T, TodoToolSourceOptions as U, TodoStatus as V, createDelegationToolSource as W, PagePerceptionReader as _, DelegationOrchestratorOptions as a, PerceivedImage as b, DelegationToolSourceOptions as c, ImageCaptureBudget as d, MANAGE_TODO_TOOL as f, PagePerceptionPolicyOptions as g, PagePerceptionPolicy as h, DelegationOrchestrator as i, SkillGenerationToolSourceOptions as j, SkillGenerationOutcome as k, GENERATE_SKILL_TOOL as l, PERCEPTION_SYSTEM_PROMPT as m, DELEGATION_SYSTEM_PROMPT as n, DelegationRequest as o, PERCEIVE_PAGE_TOOL as p, createTodoToolSource as q, DelegationBudget as r, DelegationResult as s, DELEGATE_TASK_TOOL as t, GeneratedSkillDraft as u, PagePerceptionToolSourceOptions as v, PerceptionRecord as w, PerceivedNode as x, ParentBudget as y, TodoList as z };
|