@webskill/sdk 0.0.5 → 0.1.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 +180 -46
- package/dist/browser.d.ts +37 -2
- package/dist/browser.js +112 -3
- package/dist/{dist-D405AlPD.js → dist-CiYRkm71.js} +840 -1291
- package/dist/{dist-Ixnb-hNR.js → dist-DfKKj86A.js} +84 -2
- package/dist/{dist-BM-VcQ90.js → dist-Dv4a1Jkm.js} +226 -4
- package/dist/governance.d.ts +5 -3
- package/dist/governance.js +13 -4
- package/dist/{index-aEple804.d.ts → index-DuodMfQw.d.ts} +7 -1
- package/dist/{index-BQDc-U1x.d.ts → index-S8uza3ld.d.ts} +65 -540
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/mcp.d.ts +3 -1
- package/dist/mcp.js +3 -1
- package/dist/memoryArtifactStore-C9lFVqPF-U8nXvqL9.js +637 -0
- package/dist/node.d.ts +4 -3
- package/dist/node.js +3 -2
- package/dist/testing-pn3NhXSV.js +117 -0
- package/dist/testing.d.ts +73 -0
- package/dist/testing.js +4 -0
- package/dist/types-CgNC-oQu-DCklnS0h.d.ts +539 -0
- package/dist/ui-react.d.ts +2 -2
- package/dist/ui-react.js +12 -2
- package/dist/ui-vue.d.ts +2 -2
- package/dist/ui-vue.js +9 -2
- package/dist/ui.d.ts +30 -5
- package/dist/ui.js +3 -3
- package/package.json +5 -1
|
@@ -1,353 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/errors.d.ts
|
|
3
|
-
type WebSkillErrorCode = 'FS_NOT_FOUND' | 'FS_PATH_OUTSIDE_ROOT' | 'SKILL_NOT_FOUND' | 'SKILL_INVALID_METADATA' | 'SKILL_INVALID_NAME' | 'SKILL_DUPLICATE_NAME' | 'SKILL_UNSUPPORTED_SCRIPT' | 'VALIDATION_FAILED' | 'TOOL_NOT_FOUND' | 'TOOL_EXECUTION_FAILED' | 'NETWORK_BLOCKED' | 'TOOL_UNSUPPORTED' | 'TOOL_SCHEMA_UNAVAILABLE' | 'RUN_TIMEOUT' | 'RUN_MAX_TURNS_EXCEEDED' | 'RUN_FAILED' | 'RUN_CANCELLED' | 'RUN_INTERACTION_TIMEOUT' | 'UI_UNAVAILABLE' | 'LLM_UNAVAILABLE' | 'LLM_REQUEST_FAILED' | 'INSTALL_FAILED' | 'UNINSTALL_FAILED' | 'EXPORT_FAILED' | 'INTEGRITY_FAILED' | 'FS_PERMISSION_DENIED' | 'MCP_ENDPOINT_UNAVAILABLE' | 'MCP_TOOL_NOT_FOUND' | 'CANDIDATE_INVALID' | 'APPROVAL_REQUIRED' | 'SKILL_QUARANTINED' | 'SKILL_DISABLED' | 'GOVERNANCE_FAILED' | 'RUN_SNAPSHOT_NOT_FOUND' | 'RUN_SNAPSHOT_EXPIRED' | 'RUN_SNAPSHOT_INCOMPATIBLE';
|
|
4
|
-
/** 所有公开 API 抛出的结构化错误,code 供上层可编程处理 */
|
|
5
|
-
declare class WebSkillError extends Error {
|
|
6
|
-
readonly code: WebSkillErrorCode;
|
|
7
|
-
readonly details?: unknown;
|
|
8
|
-
constructor(code: WebSkillErrorCode, message: string, details?: unknown);
|
|
9
|
-
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/contracts/jsonSchema.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* 宽松 JSON Schema:覆盖工具 inputSchema 的常见字段,
|
|
14
|
-
* 索引签名允许透传规范内的其他关键字。供 tools 与后续 UI 复用。
|
|
15
|
-
*/
|
|
16
|
-
interface JsonSchema {
|
|
17
|
-
type?: string;
|
|
18
|
-
properties?: Record<string, JsonSchema>;
|
|
19
|
-
required?: string[];
|
|
20
|
-
items?: JsonSchema;
|
|
21
|
-
enum?: unknown[];
|
|
22
|
-
description?: string;
|
|
23
|
-
default?: unknown;
|
|
24
|
-
[key: string]: unknown;
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/skill/manifest.d.ts
|
|
28
|
-
type SkillInstallSource = {
|
|
29
|
-
type: 'local';
|
|
30
|
-
path: string;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'http';
|
|
33
|
-
url: string;
|
|
34
|
-
} | {
|
|
35
|
-
type: 'archive';
|
|
36
|
-
data: ArrayBuffer;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'git';
|
|
39
|
-
url: string;
|
|
40
|
-
ref?: string;
|
|
41
|
-
commit?: string;
|
|
42
|
-
} | {
|
|
43
|
-
type: 'npm';
|
|
44
|
-
packageName: string;
|
|
45
|
-
version?: string;
|
|
46
|
-
};
|
|
47
|
-
interface SkillManifest {
|
|
48
|
-
schemaVersion: 1;
|
|
49
|
-
name: string;
|
|
50
|
-
version?: string;
|
|
51
|
-
source: SkillInstallSource;
|
|
52
|
-
installedAt: string;
|
|
53
|
-
integrity: {
|
|
54
|
-
algorithm: 'sha256';
|
|
55
|
-
digest: string;
|
|
56
|
-
};
|
|
57
|
-
files: Array<{
|
|
58
|
-
path: string;
|
|
59
|
-
size: number;
|
|
60
|
-
sha256: string;
|
|
61
|
-
}>;
|
|
62
|
-
}
|
|
63
|
-
interface SkillsLockfile {
|
|
64
|
-
schemaVersion: 1;
|
|
65
|
-
skills: Record<string, {
|
|
66
|
-
digest: string;
|
|
67
|
-
installedAt: string;
|
|
68
|
-
source: SkillInstallSource;
|
|
69
|
-
}>;
|
|
70
|
-
}
|
|
71
|
-
interface VerifyResult {
|
|
72
|
-
ok: boolean;
|
|
73
|
-
mismatches: string[];
|
|
74
|
-
}
|
|
75
|
-
/** 技能目录内的安装清单文件名(不参与 files 列表与 digest) */
|
|
76
|
-
declare const SKILL_MANIFEST_FILE = "webskill.skill-manifest.json";
|
|
77
|
-
/** managed root 下的锁定文件名(不参与 files 列表与 digest) */
|
|
78
|
-
declare const SKILLS_LOCKFILE = "skills.lock.json";
|
|
79
|
-
type Sha256Fn = (data: Uint8Array | string) => string | Promise<string>;
|
|
80
|
-
/** 整体 digest:逐文件 "<path>:<sha256>\n" 拼接串(文件按 path 排序)的 sha256(hash 由调用方提供,可为 WebCrypto 异步实现) */
|
|
81
|
-
declare function computeDigest(files: Array<{
|
|
82
|
-
path: string;
|
|
83
|
-
sha256: string;
|
|
84
|
-
}>, sha256: Sha256Fn): Promise<string>;
|
|
85
|
-
/** 由逐文件清单构建 manifest(digest 由 computeDigest 计算) */
|
|
86
|
-
declare function buildManifest(input: {
|
|
87
|
-
name: string;
|
|
88
|
-
version?: string;
|
|
89
|
-
source: SkillInstallSource;
|
|
90
|
-
installedAt: string;
|
|
91
|
-
files: SkillManifest['files'];
|
|
92
|
-
sha256: Sha256Fn;
|
|
93
|
-
}): Promise<SkillManifest>;
|
|
94
|
-
/** 按 manifest.files 比对实际 hash(调用方负责计算 actualHashes) */
|
|
95
|
-
declare function verifyManifest(manifest: SkillManifest, actualHashes: Map<string, string>): VerifyResult;
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/fs/types.d.ts
|
|
98
|
-
interface FileStat {
|
|
99
|
-
path: string;
|
|
100
|
-
type: 'file' | 'directory';
|
|
101
|
-
size?: number;
|
|
102
|
-
mtimeMs?: number;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* 文件系统抽象:core 只依赖此接口,Node/浏览器各自提供实现。
|
|
106
|
-
* 路径一律使用 `/` 分隔的 POSIX 风格。
|
|
107
|
-
*/
|
|
108
|
-
interface FileSystemProvider {
|
|
109
|
-
readonly kind: string;
|
|
110
|
-
readText(path: string): Promise<string>;
|
|
111
|
-
writeText(path: string, content: string): Promise<void>;
|
|
112
|
-
readBinary(path: string): Promise<Uint8Array>;
|
|
113
|
-
writeBinary(path: string, content: Uint8Array): Promise<void>;
|
|
114
|
-
exists(path: string): Promise<boolean>;
|
|
115
|
-
stat(path: string): Promise<FileStat>;
|
|
116
|
-
list(path: string): Promise<FileStat[]>;
|
|
117
|
-
mkdir(path: string): Promise<void>;
|
|
118
|
-
remove(path: string, options?: {
|
|
119
|
-
recursive?: boolean;
|
|
120
|
-
}): Promise<void>;
|
|
121
|
-
}
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/fs/memoryFs.d.ts
|
|
124
|
-
/** 内存文件系统:路径一律规范化为 `/` 分隔,写入自动创建父目录 */
|
|
125
|
-
declare class MemoryFS implements FileSystemProvider {
|
|
126
|
-
#private;
|
|
127
|
-
readonly kind = "memory";
|
|
128
|
-
constructor();
|
|
129
|
-
readText(path: string): Promise<string>;
|
|
130
|
-
writeText(path: string, content: string): Promise<void>;
|
|
131
|
-
readBinary(path: string): Promise<Uint8Array>;
|
|
132
|
-
writeBinary(path: string, content: Uint8Array): Promise<void>;
|
|
133
|
-
exists(path: string): Promise<boolean>;
|
|
134
|
-
stat(path: string): Promise<FileStat>;
|
|
135
|
-
list(path: string): Promise<FileStat[]>;
|
|
136
|
-
mkdir(path: string): Promise<void>;
|
|
137
|
-
remove(path: string, options?: {
|
|
138
|
-
recursive?: boolean;
|
|
139
|
-
}): Promise<void>;
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
|
-
//#region src/fs/pathSecurity.d.ts
|
|
143
|
-
/** 统一分隔符为 `/`,去除 `.` 段与重复分隔符(不解析 `..`) */
|
|
144
|
-
declare function normalizePath(path: string): string;
|
|
145
|
-
/**
|
|
146
|
-
* 将相对路径安全地解析到 root 之内。
|
|
147
|
-
* 拒绝空路径、绝对路径(`/`、`\\`、`C:\` 形式)与任何 `..` 段。
|
|
148
|
-
*/
|
|
149
|
-
declare function resolveInsideRoot(root: string, relativePath: string): string;
|
|
150
|
-
//#endregion
|
|
151
|
-
//#region src/skill/types.d.ts
|
|
152
|
-
type SkillSource = 'local' | 'mcp' | 'generated' | 'installed';
|
|
153
|
-
/** SKILL.md frontmatter 元数据;未知字段原样透传 */
|
|
154
|
-
interface SkillMetadata {
|
|
155
|
-
name: string;
|
|
156
|
-
description: string;
|
|
157
|
-
license?: string;
|
|
158
|
-
version?: string;
|
|
159
|
-
[key: string]: unknown;
|
|
160
|
-
}
|
|
161
|
-
interface SkillLocation {
|
|
162
|
-
skillRoot: string;
|
|
163
|
-
skillMdPath: string;
|
|
164
|
-
source: SkillSource;
|
|
165
|
-
}
|
|
166
|
-
interface SkillDocument {
|
|
167
|
-
metadata: SkillMetadata;
|
|
168
|
-
body: string;
|
|
169
|
-
location: SkillLocation;
|
|
170
|
-
}
|
|
171
|
-
/** Catalog 条目:渐进披露第一层,只含元数据摘要与标记位 */
|
|
172
|
-
interface SkillCatalogEntry {
|
|
173
|
-
name: string;
|
|
174
|
-
description: string;
|
|
175
|
-
version?: string;
|
|
176
|
-
license?: string;
|
|
177
|
-
root: string;
|
|
178
|
-
source: SkillSource;
|
|
179
|
-
hasScripts: boolean;
|
|
180
|
-
hasReferences: boolean;
|
|
181
|
-
hasAssets: boolean;
|
|
182
|
-
}
|
|
183
|
-
interface SkillCatalog {
|
|
184
|
-
skills: SkillCatalogEntry[];
|
|
185
|
-
}
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/skill/parser.d.ts
|
|
188
|
-
declare function parseSkillMarkdown(raw: string): {
|
|
189
|
-
metadata: SkillMetadata;
|
|
190
|
-
body: string;
|
|
191
|
-
};
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/skill/naming.d.ts
|
|
194
|
-
declare const SKILL_NAME_MAX_LENGTH = 64;
|
|
195
|
-
/** Agent Skills 官方命名规范:小写字母/数字/连字符,不允许首尾或连续连字符 */
|
|
196
|
-
declare const SKILL_NAME_PATTERN: RegExp;
|
|
197
|
-
declare function isValidSkillName(name: string): boolean;
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region src/skill/rules.d.ts
|
|
200
|
-
interface SkillIssue {
|
|
201
|
-
/** 与 WebSkillErrorCode 对齐 */
|
|
202
|
-
code: string;
|
|
203
|
-
severity: 'info' | 'warning' | 'error';
|
|
204
|
-
message: string;
|
|
205
|
-
path?: string;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* 技能合规规则的唯一实现。SkillDiscovery 与 validateSkills 都必须调用本函数,
|
|
209
|
-
* 禁止各自重复实现规则(避免两套规则漂移)。
|
|
210
|
-
*/
|
|
211
|
-
declare function checkSkillRules(input: {
|
|
212
|
-
dirName: string;
|
|
213
|
-
hasSkillMd: boolean;
|
|
214
|
-
metadata?: SkillMetadata;
|
|
215
|
-
parseError?: WebSkillError;
|
|
216
|
-
scriptFileNames?: string[];
|
|
217
|
-
existingNames?: Set<string>;
|
|
218
|
-
}): SkillIssue[];
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region src/skill/discovery.d.ts
|
|
221
|
-
interface DiscoveryResult {
|
|
222
|
-
entries: SkillCatalogEntry[];
|
|
223
|
-
issues: SkillIssue[];
|
|
224
|
-
}
|
|
225
|
-
declare class SkillDiscovery {
|
|
226
|
-
#private;
|
|
227
|
-
constructor(fs: FileSystemProvider, roots: string[]);
|
|
228
|
-
discover(): Promise<DiscoveryResult>;
|
|
229
|
-
catalog(): Promise<{
|
|
230
|
-
catalog: SkillCatalog;
|
|
231
|
-
issues: SkillIssue[];
|
|
232
|
-
}>;
|
|
233
|
-
/** 按需加载技能完整文档;技能不存在时抛 SKILL_NOT_FOUND */
|
|
234
|
-
loadDocument(skillName: string): Promise<SkillDocument>;
|
|
235
|
-
}
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/skill/validator.d.ts
|
|
238
|
-
interface ValidationReport {
|
|
239
|
-
/** 无 error 级 issue 即 true */
|
|
240
|
-
ok: boolean;
|
|
241
|
-
issues: SkillIssue[];
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* 合规校验。内部直接复用 SkillDiscovery 的扫描逻辑,
|
|
245
|
-
* 规则判定同样落在 checkSkillRules 单一来源上。
|
|
246
|
-
*/
|
|
247
|
-
declare function validateSkills(fs: FileSystemProvider, roots: string[]): Promise<ValidationReport>;
|
|
248
|
-
//#endregion
|
|
249
|
-
//#region src/skill/reader.d.ts
|
|
250
|
-
/** 按技能名读取技能根目录内的文件,全部读取强制经过路径安全检查 */
|
|
251
|
-
declare class SkillReader {
|
|
252
|
-
#private;
|
|
253
|
-
constructor(fs: FileSystemProvider, index: Map<string, string>);
|
|
254
|
-
readSkillMarkdown(skillName: string): Promise<string>;
|
|
255
|
-
readSkillFile(skillName: string, relativePath: string): Promise<string>;
|
|
256
|
-
readSkillBinary(skillName: string, relativePath: string): Promise<Uint8Array>;
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
//#region src/skill/catalog.d.ts
|
|
260
|
-
/** 由条目列表构建 Catalog,保证按名称排序 */
|
|
261
|
-
declare function buildCatalog(entries: SkillCatalogEntry[]): SkillCatalog;
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/render/types.d.ts
|
|
264
|
-
/** 可插拔的 Catalog 渲染器 */
|
|
265
|
-
interface CatalogRenderer {
|
|
266
|
-
readonly format: string;
|
|
267
|
-
render(catalog: SkillCatalog): string;
|
|
268
|
-
}
|
|
269
|
-
//#endregion
|
|
270
|
-
//#region src/render/jsonRenderer.d.ts
|
|
271
|
-
declare function renderCatalogJson(catalog: SkillCatalog): string;
|
|
272
|
-
declare const jsonRenderer: CatalogRenderer;
|
|
273
|
-
//#endregion
|
|
274
|
-
//#region src/render/xmlRenderer.d.ts
|
|
275
|
-
/** 转义 XML 五个特殊字符:& < > " ' */
|
|
276
|
-
declare function escapeXml(text: string): string;
|
|
277
|
-
declare function renderAvailableSkillsXml(catalog: SkillCatalog): string;
|
|
278
|
-
declare const xmlRenderer: CatalogRenderer;
|
|
279
|
-
//#endregion
|
|
1
|
+
import { A as SkillCatalog, C as JsonSchema, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, P as SkillInstallSource, S as FileSystemProvider, U as ValidationReport, _ as RenderResultRequest, a as InteractionPolicy, b as DiscoveryResult, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, j as SkillCatalogEntry, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-DCklnS0h.js";
|
|
280
2
|
//#region ../runtime/dist/index.d.ts
|
|
281
|
-
//#region src/llm/streamTypes.d.ts
|
|
282
|
-
/** 流式 LLM 事件(OpenAI SSE / Vercel fullStream 统一映射) */
|
|
283
|
-
type LlmStreamEvent = {
|
|
284
|
-
type: 'text-delta';
|
|
285
|
-
delta: string;
|
|
286
|
-
} | {
|
|
287
|
-
type: 'tool-calls';
|
|
288
|
-
toolCalls: LlmToolCall[];
|
|
289
|
-
} | {
|
|
290
|
-
type: 'done';
|
|
291
|
-
content?: string;
|
|
292
|
-
};
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region src/llm/types.d.ts
|
|
295
|
-
interface LlmMessage {
|
|
296
|
-
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
297
|
-
content: string;
|
|
298
|
-
/** role=tool 时必填 */
|
|
299
|
-
toolCallId?: string;
|
|
300
|
-
/** role=assistant 发起工具调用时携带 */
|
|
301
|
-
toolCalls?: LlmToolCall[];
|
|
302
|
-
}
|
|
303
|
-
interface LlmToolSpec {
|
|
304
|
-
name: string;
|
|
305
|
-
description?: string;
|
|
306
|
-
inputSchema: JsonSchema;
|
|
307
|
-
}
|
|
308
|
-
interface LlmToolCall {
|
|
309
|
-
id: string;
|
|
310
|
-
name: string;
|
|
311
|
-
arguments: Record<string, unknown>;
|
|
312
|
-
}
|
|
313
|
-
interface LlmResponse {
|
|
314
|
-
content?: string;
|
|
315
|
-
toolCalls?: LlmToolCall[];
|
|
316
|
-
raw?: unknown;
|
|
317
|
-
}
|
|
318
|
-
interface LlmCompleteInput {
|
|
319
|
-
model?: string;
|
|
320
|
-
messages: LlmMessage[];
|
|
321
|
-
tools?: LlmToolSpec[];
|
|
322
|
-
temperature?: number;
|
|
323
|
-
signal?: AbortSignal;
|
|
324
|
-
}
|
|
325
|
-
interface LlmClient {
|
|
326
|
-
complete(input: LlmCompleteInput): Promise<LlmResponse>;
|
|
327
|
-
/** 可选流式接口;实现后 AgentLoop 默认走流式(text-delta 增量 + 最终组装) */
|
|
328
|
-
stream?(input: LlmCompleteInput): AsyncIterable<LlmStreamEvent>;
|
|
329
|
-
}
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region src/llm/mockLlmClient.d.ts
|
|
332
|
-
type MockLlmHandler = (input: LlmCompleteInput) => LlmResponse | Promise<LlmResponse>;
|
|
333
|
-
type MockLlmQueueItem = LlmResponse | MockLlmHandler | {
|
|
334
|
-
stream: LlmStreamEvent[] | ((input: LlmCompleteInput) => LlmStreamEvent[]);
|
|
335
|
-
};
|
|
336
|
-
/**
|
|
337
|
-
* 预设响应序列的确定性 LlmClient;handler 形式可按会话状态动态应答。
|
|
338
|
-
* 默认不含 stream(存量行为);构造传 { streaming: true } 启用流式:
|
|
339
|
-
* 队列项 { stream: [...] } 按预设 delta 序列产出,LlmResponse 项自动合成增量。
|
|
340
|
-
*/
|
|
341
|
-
declare class MockLlmClient implements LlmClient {
|
|
342
|
-
#private;
|
|
343
|
-
readonly calls: LlmCompleteInput[];
|
|
344
|
-
readonly stream?: (input: LlmCompleteInput) => AsyncIterable<LlmStreamEvent>;
|
|
345
|
-
constructor(responses: MockLlmQueueItem[], options?: {
|
|
346
|
-
streaming?: boolean;
|
|
347
|
-
});
|
|
348
|
-
complete(input: LlmCompleteInput): Promise<LlmResponse>;
|
|
349
|
-
}
|
|
350
|
-
//#endregion
|
|
351
3
|
//#region src/llm/openAiCompatibleClient.d.ts
|
|
352
4
|
interface OpenAiCompatibleClientConfig {
|
|
353
5
|
baseUrl?: string;
|
|
@@ -411,35 +63,6 @@ declare class FullDisclosureRouter implements SkillRouter {
|
|
|
411
63
|
route(catalog: SkillCatalog): Promise<RouteResult>;
|
|
412
64
|
}
|
|
413
65
|
//#endregion
|
|
414
|
-
//#region src/artifacts/types.d.ts
|
|
415
|
-
interface Artifact {
|
|
416
|
-
id: string;
|
|
417
|
-
runId: string;
|
|
418
|
-
path: string;
|
|
419
|
-
type: 'text' | 'binary';
|
|
420
|
-
mimeType?: string;
|
|
421
|
-
size: number;
|
|
422
|
-
createdAt: string;
|
|
423
|
-
metadata?: Record<string, unknown>;
|
|
424
|
-
}
|
|
425
|
-
interface ArtifactStore {
|
|
426
|
-
createTextArtifact(input: {
|
|
427
|
-
runId: string;
|
|
428
|
-
path: string;
|
|
429
|
-
content: string;
|
|
430
|
-
mimeType?: string;
|
|
431
|
-
metadata?: Record<string, unknown>;
|
|
432
|
-
}): Promise<Artifact>;
|
|
433
|
-
createBinaryArtifact(input: {
|
|
434
|
-
runId: string;
|
|
435
|
-
path: string;
|
|
436
|
-
content: Uint8Array;
|
|
437
|
-
mimeType?: string;
|
|
438
|
-
metadata?: Record<string, unknown>;
|
|
439
|
-
}): Promise<Artifact>;
|
|
440
|
-
listArtifacts(runId: string): Promise<Artifact[]>;
|
|
441
|
-
}
|
|
442
|
-
//#endregion
|
|
443
66
|
//#region src/tools/types.d.ts
|
|
444
67
|
interface ToolDefinition {
|
|
445
68
|
/** LLM 可见名:脚本工具为 `${skillName}__${scriptName}` */
|
|
@@ -553,103 +176,6 @@ declare function createScriptContext(deps: {
|
|
|
553
176
|
onWarning?: (message: string) => void;
|
|
554
177
|
}): ScriptExecutionContext;
|
|
555
178
|
//#endregion
|
|
556
|
-
//#region src/interaction/types.d.ts
|
|
557
|
-
type InteractionRequest = {
|
|
558
|
-
type: 'ask';
|
|
559
|
-
id: string;
|
|
560
|
-
message: string;
|
|
561
|
-
schema?: JsonSchema;
|
|
562
|
-
} | {
|
|
563
|
-
type: 'confirm';
|
|
564
|
-
id: string;
|
|
565
|
-
message: string;
|
|
566
|
-
defaultValue?: boolean;
|
|
567
|
-
} | {
|
|
568
|
-
type: 'form';
|
|
569
|
-
id: string;
|
|
570
|
-
title?: string;
|
|
571
|
-
fields: FormField[];
|
|
572
|
-
} | {
|
|
573
|
-
type: 'select';
|
|
574
|
-
id: string;
|
|
575
|
-
message: string;
|
|
576
|
-
options: Array<{
|
|
577
|
-
label: string;
|
|
578
|
-
value: unknown;
|
|
579
|
-
}>;
|
|
580
|
-
} | {
|
|
581
|
-
/** 能力强制授权(require-approval):与脚本自发 confirm 区分,UI 渲染为授权样式 */
|
|
582
|
-
type: 'authorize';
|
|
583
|
-
id: string;
|
|
584
|
-
capability: 'readReference' | 'writeArtifact' | 'confirm';
|
|
585
|
-
message: string;
|
|
586
|
-
details?: unknown;
|
|
587
|
-
};
|
|
588
|
-
interface InteractionResponse {
|
|
589
|
-
id: string;
|
|
590
|
-
value?: unknown;
|
|
591
|
-
cancelled?: boolean;
|
|
592
|
-
}
|
|
593
|
-
type RenderBlock = {
|
|
594
|
-
type: 'markdown';
|
|
595
|
-
text: string;
|
|
596
|
-
} | {
|
|
597
|
-
type: 'json';
|
|
598
|
-
data: unknown;
|
|
599
|
-
} | {
|
|
600
|
-
type: 'table';
|
|
601
|
-
columns: string[];
|
|
602
|
-
rows: unknown[][];
|
|
603
|
-
} | {
|
|
604
|
-
type: 'image';
|
|
605
|
-
url: string;
|
|
606
|
-
alt?: string;
|
|
607
|
-
} | {
|
|
608
|
-
type: 'file';
|
|
609
|
-
path: string;
|
|
610
|
-
mimeType?: string;
|
|
611
|
-
size?: number;
|
|
612
|
-
};
|
|
613
|
-
interface RenderResultRequest {
|
|
614
|
-
runId: string;
|
|
615
|
-
title?: string;
|
|
616
|
-
summary?: string;
|
|
617
|
-
blocks: RenderBlock[];
|
|
618
|
-
artifacts?: Artifact[];
|
|
619
|
-
}
|
|
620
|
-
interface UiBridge {
|
|
621
|
-
request(input: InteractionRequest): Promise<InteractionResponse>;
|
|
622
|
-
progress?(input: {
|
|
623
|
-
runId: string;
|
|
624
|
-
message: string;
|
|
625
|
-
value?: number;
|
|
626
|
-
}): Promise<void>;
|
|
627
|
-
/** 定义即可,阶段 7 消费 */
|
|
628
|
-
renderResult?(input: RenderResultRequest): Promise<void>;
|
|
629
|
-
/** 流式文本增量(流式 LLM 路径下由 AgentLoop 转发) */
|
|
630
|
-
onTextDelta?(runId: string, delta: string): Promise<void> | void;
|
|
631
|
-
}
|
|
632
|
-
interface FormField {
|
|
633
|
-
name: string;
|
|
634
|
-
label: string;
|
|
635
|
-
type: 'text' | 'number' | 'boolean' | 'select' | 'textarea';
|
|
636
|
-
required?: boolean;
|
|
637
|
-
description?: string;
|
|
638
|
-
defaultValue?: unknown;
|
|
639
|
-
options?: Array<{
|
|
640
|
-
label: string;
|
|
641
|
-
value: unknown;
|
|
642
|
-
}>;
|
|
643
|
-
}
|
|
644
|
-
interface InteractionPolicy {
|
|
645
|
-
/** 缺必填参数策略:默认 'user'(表单问用户),'llm' 回喂自愈 */
|
|
646
|
-
missingParams?: 'user' | 'llm';
|
|
647
|
-
/** context.confirm 策略:默认 'required'(真实询问) */
|
|
648
|
-
confirmations?: 'required' | 'auto-approve';
|
|
649
|
-
/** 交互超时,默认 300_000ms */
|
|
650
|
-
interactionTimeoutMs?: number;
|
|
651
|
-
}
|
|
652
|
-
//#endregion
|
|
653
179
|
//#region src/lifecycle/types.d.ts
|
|
654
180
|
type RuntimePhase = 'discover' | 'route' | 'activate' | 'prepare' | 'execute' | 'observe' | 'interact' | 'complete' | 'fail';
|
|
655
181
|
interface LifecycleEvent {
|
|
@@ -717,10 +243,15 @@ interface RunResult {
|
|
|
717
243
|
//#endregion
|
|
718
244
|
//#region src/interaction/renderResult.d.ts
|
|
719
245
|
/**
|
|
720
|
-
*
|
|
721
|
-
*
|
|
246
|
+
* $chart 约定的形状校验:JSON content 的 data 含 $chart 键且形状合法 → ChartSpec;
|
|
247
|
+
* 任何畸形(kind 非法 / labels 非字符串数组 / series 项缺数值 data)→ undefined(忽略不炸)。
|
|
722
248
|
*/
|
|
723
|
-
declare function
|
|
249
|
+
declare function extractChartSpec(data: unknown): ChartSpec | undefined;
|
|
250
|
+
/**
|
|
251
|
+
* 默认的结果渲染构造:run 内收集的 renderBlocks(chart 等)在前,
|
|
252
|
+
* LLM 最终输出 → markdown block,run.artifacts → file blocks 在后;summary 取 terminationReason。
|
|
253
|
+
*/
|
|
254
|
+
declare function buildRenderResult(run: RuntimeRun, output: string, renderBlocks?: RenderBlock[]): RenderResultRequest;
|
|
724
255
|
//#endregion
|
|
725
256
|
//#region src/interaction/schemaToForm.d.ts
|
|
726
257
|
/**
|
|
@@ -730,21 +261,52 @@ declare function buildRenderResult(run: RuntimeRun, output: string): RenderResul
|
|
|
730
261
|
*/
|
|
731
262
|
declare function schemaToForm(schema: JsonSchema, providedArgs?: Record<string, unknown>): FormField[];
|
|
732
263
|
//#endregion
|
|
733
|
-
//#region src/
|
|
734
|
-
type MockUiAnswer = InteractionResponse | ((request: InteractionRequest) => InteractionResponse | Promise<InteractionResponse>);
|
|
264
|
+
//#region src/facade/types.d.ts
|
|
735
265
|
/**
|
|
736
|
-
*
|
|
737
|
-
*
|
|
266
|
+
* 安装结果清单(对齐 README IDL 命名;SkillManifest 的精简投影)
|
|
267
|
+
* @stable
|
|
738
268
|
*/
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
269
|
+
interface InstalledSkillManifest {
|
|
270
|
+
name: string;
|
|
271
|
+
version?: string;
|
|
272
|
+
installedAt: string;
|
|
273
|
+
integrity: {
|
|
274
|
+
algorithm: 'sha256';
|
|
275
|
+
digest: string;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/** navigator.webskill 统一门面(环境无关;浏览器挂载见 browser/navigator.ts) */
|
|
279
|
+
interface WebSkillApi {
|
|
280
|
+
discover(path: string): Promise<SkillCatalog>;
|
|
281
|
+
read(name: string): Promise<SkillDocument>;
|
|
282
|
+
validate(path: string): Promise<ValidationReport>;
|
|
283
|
+
run(prompt: string): Promise<RuntimeRun>;
|
|
284
|
+
install(url: string): Promise<InstalledSkillManifest>;
|
|
285
|
+
uninstall(name: string): Promise<void>;
|
|
746
286
|
}
|
|
747
287
|
//#endregion
|
|
288
|
+
//#region src/facade/webSkillApi.d.ts
|
|
289
|
+
/**
|
|
290
|
+
* navigator.webskill 门面装配层:零新业务逻辑,全部直转
|
|
291
|
+
* SkillDiscovery / validateSkills / WebSkillRuntime / SkillManager。
|
|
292
|
+
* @stable
|
|
293
|
+
*/
|
|
294
|
+
declare function createWebSkillApi(deps: {
|
|
295
|
+
fs: FileSystemProvider;
|
|
296
|
+
roots: string[];
|
|
297
|
+
llm: LlmClient;
|
|
298
|
+
executor?: ScriptExecutor;
|
|
299
|
+
artifactStore?: ArtifactStore;
|
|
300
|
+
/** 技能安装门面(Node SkillManager / BrowserSkillManager 均结构兼容);缺失时 install/uninstall 抛 TOOL_UNSUPPORTED */
|
|
301
|
+
skillManager?: {
|
|
302
|
+
install(source: SkillInstallSource, options?: {
|
|
303
|
+
expectedSha256?: string;
|
|
304
|
+
}): Promise<SkillManifest>;
|
|
305
|
+
uninstall(name: string): Promise<void>;
|
|
306
|
+
};
|
|
307
|
+
loopConfig?: AgentLoopConfig;
|
|
308
|
+
}): WebSkillApi;
|
|
309
|
+
//#endregion
|
|
748
310
|
//#region src/lifecycle/eventBus.d.ts
|
|
749
311
|
type LifecycleListener = (event: LifecycleEvent) => void;
|
|
750
312
|
/** 生命周期事件总线:只读观测,支持按阶段或通配订阅 */
|
|
@@ -777,33 +339,6 @@ declare class HookRunner {
|
|
|
777
339
|
run(phase: RuntimePhase, ctx: LifecycleHookContext): Promise<void>;
|
|
778
340
|
}
|
|
779
341
|
//#endregion
|
|
780
|
-
//#region src/memory/types.d.ts
|
|
781
|
-
/** scope/key 两级记忆存储;scope 约定:session:{id} / skill:{name} / user:{id} */
|
|
782
|
-
interface MemoryStore {
|
|
783
|
-
get(scope: string, key: string): Promise<unknown>;
|
|
784
|
-
set(scope: string, key: string, value: unknown): Promise<void>;
|
|
785
|
-
delete(scope: string, key: string): Promise<void>;
|
|
786
|
-
list(scope: string): Promise<Array<{
|
|
787
|
-
key: string;
|
|
788
|
-
value: unknown;
|
|
789
|
-
}>>;
|
|
790
|
-
clear(scope?: string): Promise<void>;
|
|
791
|
-
}
|
|
792
|
-
//#endregion
|
|
793
|
-
//#region src/memory/inMemoryStore.d.ts
|
|
794
|
-
/** 内存 MemoryStore:测试与浏览器降级用 */
|
|
795
|
-
declare class InMemoryStore implements MemoryStore {
|
|
796
|
-
#private;
|
|
797
|
-
get(scope: string, key: string): Promise<unknown>;
|
|
798
|
-
set(scope: string, key: string, value: unknown): Promise<void>;
|
|
799
|
-
delete(scope: string, key: string): Promise<void>;
|
|
800
|
-
list(scope: string): Promise<Array<{
|
|
801
|
-
key: string;
|
|
802
|
-
value: unknown;
|
|
803
|
-
}>>;
|
|
804
|
-
clear(scope?: string): Promise<void>;
|
|
805
|
-
}
|
|
806
|
-
//#endregion
|
|
807
342
|
//#region src/memory/fsMemoryStore.d.ts
|
|
808
343
|
/**
|
|
809
344
|
* 基于 FileSystemProvider 的 MemoryStore:
|
|
@@ -826,27 +361,6 @@ declare class FsMemoryStore implements MemoryStore {
|
|
|
826
361
|
clear(scope?: string): Promise<void>;
|
|
827
362
|
}
|
|
828
363
|
//#endregion
|
|
829
|
-
//#region src/artifacts/memoryArtifactStore.d.ts
|
|
830
|
-
/** 内存 ArtifactStore:测试与浏览器降级用;索引随进程生命周期存在 */
|
|
831
|
-
declare class MemoryArtifactStore implements ArtifactStore {
|
|
832
|
-
#private;
|
|
833
|
-
createTextArtifact(input: {
|
|
834
|
-
runId: string;
|
|
835
|
-
path: string;
|
|
836
|
-
content: string;
|
|
837
|
-
mimeType?: string;
|
|
838
|
-
metadata?: Record<string, unknown>;
|
|
839
|
-
}): Promise<Artifact>;
|
|
840
|
-
createBinaryArtifact(input: {
|
|
841
|
-
runId: string;
|
|
842
|
-
path: string;
|
|
843
|
-
content: Uint8Array;
|
|
844
|
-
mimeType?: string;
|
|
845
|
-
metadata?: Record<string, unknown>;
|
|
846
|
-
}): Promise<Artifact>;
|
|
847
|
-
listArtifacts(runId: string): Promise<Artifact[]>;
|
|
848
|
-
}
|
|
849
|
-
//#endregion
|
|
850
364
|
//#region src/artifacts/fsArtifactStore.d.ts
|
|
851
365
|
/**
|
|
852
366
|
* 基于 FileSystemProvider 的 ArtifactStore:产物落盘 <root>/<runId>/<path>,
|
|
@@ -938,6 +452,7 @@ type NetworkPolicy = 'deny-all' | 'allow-all' | {
|
|
|
938
452
|
* - 通配 '*.example.com'(含 apex 与任意深度子域)
|
|
939
453
|
* - 源 'http://localhost:3000'(协议 + host + port 全等)
|
|
940
454
|
* - URL 解析失败一律拒绝
|
|
455
|
+
* @stable
|
|
941
456
|
*/
|
|
942
457
|
declare function isNetworkAllowed(policy: NetworkPolicy, url: string): boolean;
|
|
943
458
|
/** 阻断 trace 用的脱敏 host(解析失败返回占位,不记录完整 URL) */
|
|
@@ -952,6 +467,7 @@ type ApprovalDecision = 'allowed' | 'denied' | 'disabled';
|
|
|
952
467
|
* Per-capability 强制授权判定(宿主侧,browser/node 执行器共用单一来源)。
|
|
953
468
|
* 'require-approval' 模式下经注入的 UiBridge 发 authorize 交互;
|
|
954
469
|
* once-per-run(默认)在 run 内记忆已批准能力,every-call 每次调用都问。
|
|
470
|
+
* @stable
|
|
955
471
|
*/
|
|
956
472
|
declare class CapabilityApproval {
|
|
957
473
|
#private;
|
|
@@ -1009,7 +525,10 @@ declare function mergeCatalogEntries(localEntries: SkillCatalogEntry[], provider
|
|
|
1009
525
|
//#endregion
|
|
1010
526
|
//#region src/engine/snapshot.d.ts
|
|
1011
527
|
declare const RUN_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
1012
|
-
/**
|
|
528
|
+
/**
|
|
529
|
+
* interrupted(等待用户)状态点的可恢复快照(D3 收窄版)
|
|
530
|
+
* @experimental
|
|
531
|
+
*/
|
|
1013
532
|
interface RunSnapshot {
|
|
1014
533
|
schemaVersion: 1;
|
|
1015
534
|
runId: string;
|
|
@@ -1035,6 +554,7 @@ interface RunSnapshot {
|
|
|
1035
554
|
};
|
|
1036
555
|
snapshotAt: string;
|
|
1037
556
|
}
|
|
557
|
+
/** @experimental */
|
|
1038
558
|
interface RunSnapshotStore {
|
|
1039
559
|
save(snapshot: RunSnapshot): Promise<void>;
|
|
1040
560
|
load(runId: string): Promise<RunSnapshot | undefined>;
|
|
@@ -1044,6 +564,7 @@ interface RunSnapshotStore {
|
|
|
1044
564
|
/**
|
|
1045
565
|
* FileSystemProvider 后端的快照存储:<root>/<runId>.snapshot.json。
|
|
1046
566
|
* 坏 JSON → RUN_SNAPSHOT_INCOMPATIBLE 并自动清理坏文件;runId 过路径安全校验。
|
|
567
|
+
* @experimental
|
|
1047
568
|
*/
|
|
1048
569
|
declare class FsRunSnapshotStore implements RunSnapshotStore {
|
|
1049
570
|
#private;
|
|
@@ -1151,7 +672,10 @@ interface WebSkillRuntimeDeps {
|
|
|
1151
672
|
/** D3:interrupt 点快照存储(配置后 interrupted run 可 resumeRun 恢复) */
|
|
1152
673
|
snapshotStore?: RunSnapshotStore;
|
|
1153
674
|
}
|
|
1154
|
-
/**
|
|
675
|
+
/**
|
|
676
|
+
* runtime 门面:组合 discovery / router / agent loop / lifecycle
|
|
677
|
+
* @stable
|
|
678
|
+
*/
|
|
1155
679
|
declare class WebSkillRuntime {
|
|
1156
680
|
#private;
|
|
1157
681
|
constructor(deps: WebSkillRuntimeDeps);
|
|
@@ -1166,8 +690,9 @@ declare class WebSkillRuntime {
|
|
|
1166
690
|
* D3 恢复 interrupted run:
|
|
1167
691
|
* 不存在 → RUN_SNAPSHOT_NOT_FOUND;schemaVersion 不匹配 → 删除 + RUN_SNAPSHOT_INCOMPATIBLE;
|
|
1168
692
|
* 已过期 → interaction-timeout 终态并删快照;否则重建 LoopState 重新发起交互续跑。
|
|
693
|
+
* @experimental
|
|
1169
694
|
*/
|
|
1170
695
|
resumeRun(runId: string): Promise<RunResult>;
|
|
1171
696
|
}
|
|
1172
697
|
//#endregion
|
|
1173
|
-
export {
|
|
698
|
+
export { TraceEvent as $, OpenAiCompatibleClient as A, RunSnapshotStore as B, HookRunnerOptions as C, LifecycleHookContext as D, LifecycleHook as E, READ_SKILL_FILE_TOOL_NAME as F, SchemaInferer as G, RuntimePhase as H, RUN_SNAPSHOT_SCHEMA_VERSION as I, SkillRouter as J, ScriptExecutionContext as K, RouteResult as L, ProgressiveRouter as M, READ_SKILL_FILE_INPUT_SCHEMA as N, LifecycleListener as O, READ_SKILL_FILE_TOOL as P, TraceClock as Q, RunResult as R, HookRunner as S, LifecycleEvent as T, RuntimeRun as U, RunTerminationReason as V, RuntimeSession as W, ToolResolution as X, ToolDefinition as Y, ToolResult as Z, ExternalToolSource as _, parseBridgeRequest as _t, AgentLoopConfig as a, WebSkillRuntimeDeps as at, FsRunSnapshotStore as b, toLlmToolSpec as bt, ApprovalScope as c, createScriptContext as ct, BridgeRequest as d, fromVercelResult as dt, TraceEventType as et, BridgeResponse as f, fromVercelStreamPart as ft, ExternalSkillProvider as g, normalizeToolContent as gt, EventBus as h, networkUrlHost as ht, AgentLoop as i, WebSkillRuntime as it, OpenAiCompatibleClientConfig as j, NetworkPolicy as k, BridgeCapabilities as l, createWebSkillApi as lt, CapabilityMode as m, mergeCatalogEntries as mt, ASK_USER_TOOL as n, VercelToolSpec as nt, AgentLoopDeps as o, bridgeError as ot, CapabilityApproval as p, isNetworkAllowed as pt, ScriptExecutor as q, ASK_USER_TOOL_NAME as r, WebSkillApi as rt, ApprovalDecision as s, buildRenderResult as st, ASK_USER_INPUT_SCHEMA as t, TraceRecorder as tt, BridgeCapability as u, extractChartSpec as ut, FsArtifactStore as v, resolveToolName as vt, InstalledSkillManifest as w, FullDisclosureRouter as x, toVercelToolSpecs as xt, FsMemoryStore as y, schemaToForm as yt, RunSnapshot as z };
|