@webskill/sdk 0.2.7 → 0.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 +42 -0
- package/dist/browser.d.ts +13 -4
- package/dist/browser.js +19 -10
- package/dist/{catalogComponents-C_V39rbF-B94i0fW7.js → catalogComponents-C_V39rbF-BOHveMWa.js} +254 -9090
- package/dist/client-BCM6Z3yq-qUQNkKrK.js +7787 -0
- package/dist/{dist-BQzncxXg.js → dist-8oQRa8Xz.js} +212 -13
- package/dist/{dist-CtBLBbEz.js → dist-ZKaM8j06.js} +2 -2
- package/dist/{dist-BdOW8N4V.js → dist-rorEJsNi.js} +596 -59
- package/dist/governance.d.ts +30 -197
- package/dist/governance.js +38 -199
- package/dist/{index-BpIK7tJM.d.ts → index-8d-oEDww.d.ts} +215 -2
- package/dist/{index-BNQNSDKg.d.ts → index-wiV5X8Rz.d.ts} +21 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/{jsonRenderRegistry-9GrWP_hE-CMkryt1H.js → jsonRenderRegistry-9GrWP_hE-U6Do3Kid.js} +2 -2
- package/dist/mcp.d.ts +5 -3
- package/dist/mcp.js +10 -5
- package/dist/node.d.ts +338 -4
- package/dist/node.js +2338 -4
- package/dist/{openUiLibrary-B8-Cvou9-Cu1QZqoT.js → openUiLibrary-B8-Cvou9-BbpNTXS3.js} +2 -2
- package/dist/sandboxWorkerEntry.js +12 -3
- package/dist/skillVersionStore-DOEI9ptb-BxbYL70B.d.ts +127 -0
- package/dist/stdio-CFMoANJJ-BxrTeXh7.js +31 -0
- package/dist/{testing-BUoXvm1u.js → testing-CsrG3XLz.js} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-7fnqDVrf-BnRQjVU3.d.ts → types-AmKCKJn_-VGabeXK4.d.ts} +140 -3
- package/dist/types-WovEf4ED-CZSDiiBU.js +6215 -0
- package/dist/ui-react.d.ts +2 -2
- package/dist/ui-react.js +6 -6
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +1 -1
- package/dist/ui.d.ts +3 -3
- package/dist/ui.js +2 -2
- package/dist/{webskillLitCatalog-CNaUpasU-CfSRvqCZ.js → webskillLitCatalog-CNaUpasU-BslMcxRZ.js} +1 -1
- package/package.json +4 -7
- package/dist/dist-CcMIUXeZ.js +0 -1896
- package/dist/index-BHL5FWGw.d.ts +0 -240
package/dist/index-BHL5FWGw.d.ts
DELETED
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { K as SkillInstallSource, M as FileStat, N as FileSystemProvider, O as ArchiveLimits, P as JsonSchema, Y as SkillManifest, _ as RenderResultRequest, et as SkillsLockfile, nt as VerifyResult, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-7fnqDVrf-BnRQjVU3.js";
|
|
2
|
-
import { N as NetworkPolicy, Q as ScriptExecutor, X as SchemaInferer, Z as ScriptExecutionContext, b as FsArtifactStore, d as BridgeCapabilities, it as ToolResult, nt as ToolDefinition, u as ApprovalScope, x as FsMemoryStore } from "./index-BpIK7tJM.js";
|
|
3
|
-
import { Readable, Writable } from "node:stream";
|
|
4
|
-
//#region ../node/dist/index.d.ts
|
|
5
|
-
//#region src/fs/nodeFs.d.ts
|
|
6
|
-
/**
|
|
7
|
-
* 基于 node:fs/promises 的 FileSystemProvider;接受 `/` 风格路径,写入自动创建父目录。
|
|
8
|
-
* 可选 root 模式:构造传入 root 后,read/write 操作先做 realpath 包含校验
|
|
9
|
-
* (root 与目标都 realpath 后前缀比对),经符号链接逃逸 root → FS_PATH_OUTSIDE_ROOT。
|
|
10
|
-
*/
|
|
11
|
-
declare class NodeFS implements FileSystemProvider {
|
|
12
|
-
#private;
|
|
13
|
-
readonly kind = "node";
|
|
14
|
-
constructor(deps?: {
|
|
15
|
-
root?: string;
|
|
16
|
-
});
|
|
17
|
-
/** root 模式:全部方法(read/write/exists/stat/list/mkdir/remove/rename)目标 realpath 必须落在 root realpath 前缀内 */
|
|
18
|
-
withRoot(root: string): NodeFS;
|
|
19
|
-
readText(p: string): Promise<string>;
|
|
20
|
-
writeText(p: string, content: string): Promise<void>;
|
|
21
|
-
appendText(p: string, content: string): Promise<void>;
|
|
22
|
-
readBinary(p: string): Promise<Uint8Array>;
|
|
23
|
-
writeBinary(p: string, content: Uint8Array): Promise<void>;
|
|
24
|
-
exists(p: string): Promise<boolean>;
|
|
25
|
-
stat(p: string): Promise<FileStat>;
|
|
26
|
-
list(p: string): Promise<FileStat[]>;
|
|
27
|
-
mkdir(p: string): Promise<void>;
|
|
28
|
-
remove(p: string, options?: {
|
|
29
|
-
recursive?: boolean;
|
|
30
|
-
}): Promise<void>;
|
|
31
|
-
rename(from: string, to: string): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/executor/nodeScriptExecutor.d.ts
|
|
35
|
-
/**
|
|
36
|
-
* 进程内脚本执行器。接口按沙箱语义设计(context 无隐式宿主访问),
|
|
37
|
-
* worker_threads 沙箱见 deferred-items D1。
|
|
38
|
-
*/
|
|
39
|
-
declare class NodeScriptExecutor implements ScriptExecutor {
|
|
40
|
-
#private;
|
|
41
|
-
constructor(fs: FileSystemProvider);
|
|
42
|
-
loadDefinition(skillRoot: string, scriptName: string): Promise<ToolDefinition>;
|
|
43
|
-
execute(input: {
|
|
44
|
-
skillRoot: string;
|
|
45
|
-
scriptName: string;
|
|
46
|
-
args: Record<string, unknown>;
|
|
47
|
-
context: Parameters<ScriptExecutor['execute']>[0]['context'];
|
|
48
|
-
timeoutMs: number;
|
|
49
|
-
}): Promise<ToolResult>;
|
|
50
|
-
}
|
|
51
|
-
//#endregion
|
|
52
|
-
//#region src/executor/sandboxedScriptExecutor.d.ts
|
|
53
|
-
interface SandboxOptions {
|
|
54
|
-
/** 默认 { maxOldGenerationSizeMb: 64, maxYoungGenerationSizeMb: 16 } */
|
|
55
|
-
resourceLimits?: {
|
|
56
|
-
maxOldGenerationSizeMb?: number;
|
|
57
|
-
maxYoungGenerationSizeMb?: number;
|
|
58
|
-
};
|
|
59
|
-
/** env 白名单(仅这些变量传入 Worker;默认空) */
|
|
60
|
-
envWhitelist?: string[];
|
|
61
|
-
capabilities?: BridgeCapabilities;
|
|
62
|
-
/** 网络策略:默认 'deny-all'(白名单见 runtime/sandbox/networkPolicy) */
|
|
63
|
-
networkPolicy?: NetworkPolicy;
|
|
64
|
-
/** 裸模块 allowlist(默认 []:一切 node: 内置模块全禁;按需放行如 ['node:path']) */
|
|
65
|
-
allowedModules?: string[];
|
|
66
|
-
/** require-approval 模式的授权询问出口(缺失时 require-approval 一律拒绝) */
|
|
67
|
-
uiBridge?: UiBridge;
|
|
68
|
-
/** 授权粒度:默认 'once-per-run' */
|
|
69
|
-
approvalScope?: ApprovalScope;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* D1:worker_threads 沙箱脚本执行器。
|
|
73
|
-
* 每次执行独立 Worker(resourceLimits + env 白名单),loadDefinition 同样在
|
|
74
|
-
* Worker 内完成(禁止主进程 import 不可信脚本);超时 terminate(可杀同步死循环)。
|
|
75
|
-
* 能力桥协议与浏览器同一来源(runtime/sandbox/bridgeProtocol)。
|
|
76
|
-
*
|
|
77
|
-
* 诚实标注:本执行器做的是**能力面收敛**(网络策略、模块 allowlist、资源限额、
|
|
78
|
-
* 超时强杀),**不是安全边界**——Worker 内脚本与宿主共享进程;
|
|
79
|
-
* 已知主动逃逸面(process.binding/_linkedBinding/dlopen/openStdin/reallyExit/abort)
|
|
80
|
-
* 已在入口删除(0.2.3),常规 import 拦截之外不承诺防御其它宿主共享面;
|
|
81
|
-
* 禁止假定其可隔离不可信脚本(隔离级需求用 ProcessSandboxExecutor)。
|
|
82
|
-
*/
|
|
83
|
-
declare class SandboxedScriptExecutor implements ScriptExecutor {
|
|
84
|
-
#private;
|
|
85
|
-
constructor(fs: FileSystemProvider, options?: SandboxOptions);
|
|
86
|
-
loadDefinition(skillRoot: string, scriptName: string): Promise<ToolDefinition>;
|
|
87
|
-
execute(input: {
|
|
88
|
-
skillRoot: string;
|
|
89
|
-
scriptName: string;
|
|
90
|
-
args: Record<string, unknown>;
|
|
91
|
-
context: ScriptExecutionContext;
|
|
92
|
-
timeoutMs: number;
|
|
93
|
-
}): Promise<ToolResult>;
|
|
94
|
-
}
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/executor/processSandboxExecutor.d.ts
|
|
97
|
-
interface ProcessSandboxOptions {
|
|
98
|
-
/** 温池大小(并发上限;执行后 kill 并补位重生),默认 2 */
|
|
99
|
-
poolSize?: number;
|
|
100
|
-
/** 透传给子进程的环境变量白名单(默认 []:子进程 env 为空,防密钥泄露) */
|
|
101
|
-
envWhitelist?: string[];
|
|
102
|
-
capabilities?: BridgeCapabilities;
|
|
103
|
-
/** 网络策略:默认 'deny-all'(权限模型无网络维度,补丁兜底;node:net 裸模块为已知残余面) */
|
|
104
|
-
networkPolicy?: NetworkPolicy;
|
|
105
|
-
/** require-approval 模式的授权询问出口 */
|
|
106
|
-
uiBridge?: UiBridge;
|
|
107
|
-
/** 授权粒度:默认 'once-per-run' */
|
|
108
|
-
approvalScope?: ApprovalScope;
|
|
109
|
-
/** 池维护告警出口(recycle 重生失败等;默认 console.warn) */
|
|
110
|
-
onWarning?: (message: string) => void;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* child_process.fork + --permission 进程沙箱(真实进程隔离)。
|
|
114
|
-
* 每个子进程以 `--permission --allow-fs-read=<入口目录> --allow-fs-read=<skillRoot>
|
|
115
|
-
* --allow-fs-write=<artifactDir>` 启动:fs 维度由权限模型管控(experimental),
|
|
116
|
-
* 子进程/Worker/addons 默认禁;网络无权限维度仍靠 fetch/WebSocket patch。
|
|
117
|
-
* 能力桥协议与 worker_threads 沙箱同一形态(readReference/writeArtifact/confirm + 授权)。
|
|
118
|
-
* 温池(默认 2):同 skillRoot 复用子进程;执行后 kill 并补位重生;并发上限即池大小。
|
|
119
|
-
* 超时 kill(同步死循环可杀);非零退出码 → TOOL_EXECUTION_FAILED。
|
|
120
|
-
*/
|
|
121
|
-
declare class ProcessSandboxExecutor implements ScriptExecutor {
|
|
122
|
-
#private;
|
|
123
|
-
constructor(fs: FileSystemProvider, options?: ProcessSandboxOptions);
|
|
124
|
-
get poolSize(): number;
|
|
125
|
-
/** 池全部子进程销毁(测试收尾/进程退出前调用);排队中的 acquire 一律 reject(不悬挂) */
|
|
126
|
-
dispose(): Promise<void>;
|
|
127
|
-
loadDefinition(skillRoot: string, scriptName: string): Promise<ToolDefinition>;
|
|
128
|
-
execute(input: {
|
|
129
|
-
skillRoot: string;
|
|
130
|
-
scriptName: string;
|
|
131
|
-
args: Record<string, unknown>;
|
|
132
|
-
context: ScriptExecutionContext;
|
|
133
|
-
timeoutMs: number;
|
|
134
|
-
}): Promise<ToolResult>;
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/schema/oxcSchemaInferer.d.ts
|
|
138
|
-
/**
|
|
139
|
-
* D2 Schema 推导(OXC 静态文本分析,宿主侧执行,不进沙箱)。
|
|
140
|
-
* TS 类型标注为主路径,JSDoc @param 为辅路径;不支持类型降级 string 并标 'x-inferred'。
|
|
141
|
-
*/
|
|
142
|
-
declare class OxcSchemaInferer implements SchemaInferer {
|
|
143
|
-
inferSchemaFromSource(source: string, options?: {
|
|
144
|
-
fileName?: string;
|
|
145
|
-
}): JsonSchema | undefined;
|
|
146
|
-
}
|
|
147
|
-
//#endregion
|
|
148
|
-
//#region src/artifacts/fileArtifactStore.d.ts
|
|
149
|
-
/**
|
|
150
|
-
* FileArtifactStore:兼容别名,语义同阶段 2-4。
|
|
151
|
-
* 实现已上移到 runtime 的 FsArtifactStore;node 侧保留 NodeFS 默认值。
|
|
152
|
-
*/
|
|
153
|
-
declare class FileArtifactStore extends FsArtifactStore {
|
|
154
|
-
constructor(deps: {
|
|
155
|
-
root: string;
|
|
156
|
-
fs?: FileSystemProvider;
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/memory/fileMemoryStore.d.ts
|
|
161
|
-
/**
|
|
162
|
-
* FileMemoryStore:兼容别名,语义同阶段 3。
|
|
163
|
-
* 实现已上移到 runtime 的 FsMemoryStore;node 侧保留 NodeFS 默认值。
|
|
164
|
-
*/
|
|
165
|
-
declare class FileMemoryStore extends FsMemoryStore {
|
|
166
|
-
constructor(deps: {
|
|
167
|
-
root: string;
|
|
168
|
-
fs?: FileSystemProvider;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/ui/cliUiBridge.d.ts
|
|
173
|
-
/**
|
|
174
|
-
* 命令行 UiBridge:ask→问答,confirm→y/n(带默认值),
|
|
175
|
-
* form→逐字段提示(显示默认值与必填标记),select→编号列表,
|
|
176
|
-
* authorize→授权询问(默认拒绝,仅显式 y/yes 批准)。
|
|
177
|
-
* 输入/输出流可注入(测试用 PassThrough)。
|
|
178
|
-
*/
|
|
179
|
-
declare class CliUiBridge implements UiBridge {
|
|
180
|
-
#private;
|
|
181
|
-
constructor(deps?: {
|
|
182
|
-
input?: Readable;
|
|
183
|
-
output?: Writable;
|
|
184
|
-
});
|
|
185
|
-
request(input: InteractionRequest): Promise<InteractionResponse>;
|
|
186
|
-
progress(input: {
|
|
187
|
-
runId: string;
|
|
188
|
-
message: string;
|
|
189
|
-
value?: number;
|
|
190
|
-
}): Promise<void>;
|
|
191
|
-
renderResult(input: RenderResultRequest): Promise<void>;
|
|
192
|
-
}
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/skillManagement/skillManager.d.ts
|
|
195
|
-
/**
|
|
196
|
-
* 技能管理门面:统一安装管线(staging → 解析 name → 校验 → 拷贝 → manifest → lockfile),
|
|
197
|
-
* 任何失败清理现场抛 INSTALL_FAILED。
|
|
198
|
-
* @stable
|
|
199
|
-
*/
|
|
200
|
-
declare class SkillManager {
|
|
201
|
-
#private;
|
|
202
|
-
constructor(deps: {
|
|
203
|
-
managedRoot: string;
|
|
204
|
-
fs?: FileSystemProvider;
|
|
205
|
-
fetchImpl?: typeof fetch;
|
|
206
|
-
/** D2 安装期 schema 预推导(默认 true,可关) */
|
|
207
|
-
schemaInference?: boolean;
|
|
208
|
-
/** 归档体积三重上限(缺省 DEFAULT_ARCHIVE_LIMITS) */
|
|
209
|
-
archiveLimits?: ArchiveLimits;
|
|
210
|
-
/** install/uninstall 成功后的变更回调(宿主接线缓存失效,如 WebSkillRuntime.invalidate) */
|
|
211
|
-
onChanged?: () => void;
|
|
212
|
-
});
|
|
213
|
-
/** 托管根目录(治理发布归档捕获等只读场景) */
|
|
214
|
-
get managedRoot(): string;
|
|
215
|
-
install(source: SkillInstallSource, options?: {
|
|
216
|
-
expectedSha256?: string;
|
|
217
|
-
}): Promise<SkillManifest>;
|
|
218
|
-
uninstall(name: string): Promise<void>;
|
|
219
|
-
verifyIntegrity(name: string): Promise<VerifyResult>;
|
|
220
|
-
listInstalled(): Promise<SkillsLockfile>;
|
|
221
|
-
exportArchive(name: string, options: {
|
|
222
|
-
format: 'zip' | 'tar';
|
|
223
|
-
outPath: string;
|
|
224
|
-
}): Promise<string>;
|
|
225
|
-
/** 多技能包集导出(webskill.skill-pack.json + 各技能目录含 manifest),写 outPath 并返回 */
|
|
226
|
-
exportPack(names: string[], options: {
|
|
227
|
-
outPath: string;
|
|
228
|
-
}): Promise<string>;
|
|
229
|
-
}
|
|
230
|
-
//#endregion
|
|
231
|
-
//#region src/skillManagement/export/archiveExporter.d.ts
|
|
232
|
-
/** 导出技能目录全部文件(含 manifest)为 zip/tar 归档,返回 outPath */
|
|
233
|
-
declare function exportArchive(fs: FileSystemProvider, skillRoot: string, options: {
|
|
234
|
-
format: 'zip' | 'tar';
|
|
235
|
-
outPath: string;
|
|
236
|
-
}): Promise<string>;
|
|
237
|
-
/** 只解出归档中的 webskill.skill-manifest.json 条目(安装前预览) */
|
|
238
|
-
declare function readArchiveManifest(fs: FileSystemProvider, archivePath: string): Promise<SkillManifest>;
|
|
239
|
-
//#endregion
|
|
240
|
-
export { NodeScriptExecutor as a, ProcessSandboxOptions as c, SkillManager as d, exportArchive as f, NodeFS as i, SandboxOptions as l, FileArtifactStore as n, OxcSchemaInferer as o, readArchiveManifest as p, FileMemoryStore as r, ProcessSandboxExecutor as s, CliUiBridge as t, SandboxedScriptExecutor as u };
|