@webskill/sdk 0.1.3 → 0.1.4
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 +5 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +54 -22
- package/dist/{dist-Cm_j6Jol.js → dist-BVXZF7H_.js} +138 -52
- package/dist/{dist-DZobLFh6.js → dist-DAn07zHu.js} +24 -6
- package/dist/{dist-DS1sfgHa.js → dist-DvoBsChX.js} +13 -1
- package/dist/{dist-DxGyAznR.js → dist-MTc2KB03.js} +46 -3
- package/dist/governance.d.ts +7 -4
- package/dist/governance.js +19 -4
- package/dist/{index-CqMuvcb2.d.ts → index-BSS3EWY-.d.ts} +1 -1
- package/dist/{index-CPuwsnmB.d.ts → index-npFMt2Zw.d.ts} +16 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/node.d.ts +3 -3
- package/dist/node.js +3 -3
- package/dist/sandboxWorkerEntry.d.ts +1 -0
- package/dist/sandboxWorkerEntry.js +214 -0
- package/dist/{testing-CbM6rJ-E.js → testing-S8SN9Lc6.js} +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-CgNC-oQu-Dq_A1yA-.d.ts → types-CgNC-oQu-DYrxhD3z.d.ts} +11 -1
- package/dist/ui-react.d.ts +1 -1
- package/dist/ui-react.js +1 -1
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +1 -1
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as WebSkillError } from "./dist-
|
|
1
|
+
import { l as WebSkillError } from "./dist-DvoBsChX.js";
|
|
2
2
|
|
|
3
3
|
//#region ../ui/dist/index.js
|
|
4
4
|
/** 提交值按请求类型归形(WebFormBridge 与框架组件库共享单一来源) */
|
|
@@ -1040,8 +1040,7 @@ var LitRendererBridge = class {
|
|
|
1040
1040
|
values: formValues
|
|
1041
1041
|
}
|
|
1042
1042
|
});
|
|
1043
|
-
|
|
1044
|
-
resolve(response);
|
|
1043
|
+
resolve(this.#decodeValue(input, response));
|
|
1045
1044
|
}, { version: "v0.9.1" });
|
|
1046
1045
|
processor.onSurfaceCreated((surface) => {
|
|
1047
1046
|
const el = this.#doc.createElement("a2ui-surface");
|
|
@@ -1052,6 +1051,50 @@ var LitRendererBridge = class {
|
|
|
1052
1051
|
processor.processMessages(messages);
|
|
1053
1052
|
});
|
|
1054
1053
|
}
|
|
1054
|
+
/**
|
|
1055
|
+
* 按 InteractionRequest.type 解码提交值(绑定模型原样回传的是表单对象):
|
|
1056
|
+
* confirm 仅 confirmed===true 批准;select 还原原始 option 值(非字符串值经 JSON 编码比对);
|
|
1057
|
+
* form 的 number 字段转 number;ask 取 answer;authorize 提交即批准。
|
|
1058
|
+
*/
|
|
1059
|
+
#decodeValue(input, response) {
|
|
1060
|
+
if (response.cancelled) return response;
|
|
1061
|
+
const values = response.value;
|
|
1062
|
+
switch (input.type) {
|
|
1063
|
+
case "confirm": return {
|
|
1064
|
+
...response,
|
|
1065
|
+
value: values?.confirmed === true
|
|
1066
|
+
};
|
|
1067
|
+
case "ask": return {
|
|
1068
|
+
...response,
|
|
1069
|
+
value: values?.answer
|
|
1070
|
+
};
|
|
1071
|
+
case "select": {
|
|
1072
|
+
const raw = values?.selected;
|
|
1073
|
+
const option = input.options.find((o) => o.value === raw || JSON.stringify(o.value) === raw);
|
|
1074
|
+
return {
|
|
1075
|
+
...response,
|
|
1076
|
+
value: option ? option.value : raw
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
case "form": {
|
|
1080
|
+
if (typeof values !== "object" || values === null) return response;
|
|
1081
|
+
const out = { ...values };
|
|
1082
|
+
for (const field of input.fields) if (field.type === "number" && out[field.name] !== void 0) {
|
|
1083
|
+
const n = Number(out[field.name]);
|
|
1084
|
+
if (!Number.isNaN(n)) out[field.name] = n;
|
|
1085
|
+
}
|
|
1086
|
+
return {
|
|
1087
|
+
...response,
|
|
1088
|
+
value: out
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
case "authorize": return {
|
|
1092
|
+
...response,
|
|
1093
|
+
value: true
|
|
1094
|
+
};
|
|
1095
|
+
default: return response;
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1055
1098
|
};
|
|
1056
1099
|
|
|
1057
1100
|
//#endregion
|
package/dist/governance.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as SkillManifest, N as SkillDocument, S as FileSystemProvider, c as LlmClient, j as SkillCatalogEntry, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-
|
|
2
|
-
import { ct as WebSkillRuntime, q as RuntimeRun } from "./index-
|
|
3
|
-
import { f as SkillManager } from "./index-
|
|
1
|
+
import { L as SkillManifest, N as SkillDocument, S as FileSystemProvider, c as LlmClient, j as SkillCatalogEntry, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
|
+
import { ct as WebSkillRuntime, q as RuntimeRun } from "./index-BSS3EWY-.js";
|
|
3
|
+
import { f as SkillManager } from "./index-npFMt2Zw.js";
|
|
4
4
|
//#region ../governance/dist/index.d.ts
|
|
5
5
|
//#region src/types.d.ts
|
|
6
6
|
type CandidateStatus = 'draft' | 'pending-review' | 'approved' | 'published' | 'rejected';
|
|
@@ -311,11 +311,14 @@ interface EvaluationReport {
|
|
|
311
311
|
}
|
|
312
312
|
//#endregion
|
|
313
313
|
//#region src/evaluation/evaluationRunner.d.ts
|
|
314
|
-
/** 批量评估:顺序执行(单任务异常不中断批);expected
|
|
314
|
+
/** 批量评估:顺序执行(单任务异常不中断批);expected 参与判定;结构化报告。
|
|
315
|
+
* 注意:评估会真实执行技能脚本(试用路径)——必须显式 opt-in(allowExecution: true),
|
|
316
|
+
* 且沙箱执行器是能力面收敛而非安全边界,禁止对不可信候选技能直接跑评估。 */
|
|
315
317
|
declare class EvaluationRunner {
|
|
316
318
|
#private;
|
|
317
319
|
constructor(deps: {
|
|
318
320
|
runtime: WebSkillRuntime;
|
|
321
|
+
allowExecution?: boolean;
|
|
319
322
|
now?: () => string;
|
|
320
323
|
createId?: () => string;
|
|
321
324
|
});
|
package/dist/governance.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as NodeFS } from "./dist-
|
|
1
|
+
import { E as validateSkills, T as resolveInsideRoot, l as WebSkillError, u as assertSafePathSegment, v as isValidSkillName } from "./dist-DvoBsChX.js";
|
|
2
|
+
import { i as NodeFS } from "./dist-BVXZF7H_.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { mkdtemp } from "node:fs/promises";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
@@ -115,9 +115,11 @@ var CandidateStore = class {
|
|
|
115
115
|
}
|
|
116
116
|
async save(candidate) {
|
|
117
117
|
validateCandidate(candidate);
|
|
118
|
+
assertSafePathSegment(candidate.id, "candidate id");
|
|
118
119
|
await this.#fs.writeText(`${dirOf$1(this.#root)}/${candidate.id}.json`, JSON.stringify(candidate, null, 2));
|
|
119
120
|
}
|
|
120
121
|
async get(id) {
|
|
122
|
+
assertSafePathSegment(id, "candidate id");
|
|
121
123
|
const path = `${dirOf$1(this.#root)}/${id}.json`;
|
|
122
124
|
if (!await this.#fs.exists(path)) throw new WebSkillError("GOVERNANCE_FAILED", `Candidate not found: ${id}`);
|
|
123
125
|
return JSON.parse(await this.#fs.readText(path));
|
|
@@ -370,7 +372,10 @@ var FsAuditLog = class {
|
|
|
370
372
|
return events;
|
|
371
373
|
}
|
|
372
374
|
};
|
|
373
|
-
const dirOf = (root, skillName) =>
|
|
375
|
+
const dirOf = (root, skillName) => {
|
|
376
|
+
assertSafePathSegment(skillName, "skill name");
|
|
377
|
+
return `${root}/.webskill/versions/${skillName}`;
|
|
378
|
+
};
|
|
374
379
|
/** 版本存储:manifest 快照 + parentVersionId 链;回滚 = 追加新版本(谱系不断) */
|
|
375
380
|
var SkillVersionStore = class {
|
|
376
381
|
#root;
|
|
@@ -394,6 +399,7 @@ var SkillVersionStore = class {
|
|
|
394
399
|
reason: input.reason,
|
|
395
400
|
manifest: input.manifest
|
|
396
401
|
};
|
|
402
|
+
assertSafePathSegment(version.versionId, "version id");
|
|
397
403
|
await this.#fs.writeText(`${dirOf(this.#root, skillName)}/${version.versionId}.json`, JSON.stringify(version, null, 2));
|
|
398
404
|
return version;
|
|
399
405
|
}
|
|
@@ -408,6 +414,7 @@ var SkillVersionStore = class {
|
|
|
408
414
|
return out.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
409
415
|
}
|
|
410
416
|
async get(skillName, versionId) {
|
|
417
|
+
assertSafePathSegment(versionId, "version id");
|
|
411
418
|
const path = `${dirOf(this.#root, skillName)}/${versionId}.json`;
|
|
412
419
|
if (!await this.#fs.exists(path)) throw new WebSkillError("GOVERNANCE_FAILED", `Version "${versionId}" of skill "${skillName}" not found`);
|
|
413
420
|
return JSON.parse(await this.#fs.readText(path));
|
|
@@ -535,12 +542,14 @@ var SkillStatePolicy = class {
|
|
|
535
542
|
await this.#fs.writeText(fileOf(this.#root), JSON.stringify(data, null, 2));
|
|
536
543
|
}
|
|
537
544
|
async getState(skillName) {
|
|
545
|
+
assertSafePathSegment(skillName, "skill name");
|
|
538
546
|
return (await this.#load()).states[skillName] ?? "active";
|
|
539
547
|
}
|
|
540
548
|
async listStates() {
|
|
541
549
|
return { ...(await this.#load()).states };
|
|
542
550
|
}
|
|
543
551
|
async setState(skillName, state, input) {
|
|
552
|
+
assertSafePathSegment(skillName, "skill name");
|
|
544
553
|
const data = await this.#load();
|
|
545
554
|
data.states[skillName] = state;
|
|
546
555
|
if (state === "active") delete data.failures[skillName];
|
|
@@ -554,6 +563,7 @@ var SkillStatePolicy = class {
|
|
|
554
563
|
}
|
|
555
564
|
/** 失败计数;达阈值(默认 3)→ quarantined + 审计 */
|
|
556
565
|
async recordFailure(skillName, input = {}) {
|
|
566
|
+
assertSafePathSegment(skillName, "skill name");
|
|
557
567
|
const data = await this.#load();
|
|
558
568
|
const count = (data.failures[skillName] ?? 0) + 1;
|
|
559
569
|
data.failures[skillName] = count;
|
|
@@ -621,17 +631,22 @@ function matchExpected(expected, output, run) {
|
|
|
621
631
|
if (typeof expected === "string") return output.includes(expected);
|
|
622
632
|
return expected(output, run);
|
|
623
633
|
}
|
|
624
|
-
/** 批量评估:顺序执行(单任务异常不中断批);expected
|
|
634
|
+
/** 批量评估:顺序执行(单任务异常不中断批);expected 参与判定;结构化报告。
|
|
635
|
+
* 注意:评估会真实执行技能脚本(试用路径)——必须显式 opt-in(allowExecution: true),
|
|
636
|
+
* 且沙箱执行器是能力面收敛而非安全边界,禁止对不可信候选技能直接跑评估。 */
|
|
625
637
|
var EvaluationRunner = class {
|
|
626
638
|
#runtime;
|
|
639
|
+
#allowExecution;
|
|
627
640
|
#now;
|
|
628
641
|
#createId;
|
|
629
642
|
constructor(deps) {
|
|
630
643
|
this.#runtime = deps.runtime;
|
|
644
|
+
this.#allowExecution = deps.allowExecution ?? false;
|
|
631
645
|
this.#now = deps.now;
|
|
632
646
|
this.#createId = deps.createId;
|
|
633
647
|
}
|
|
634
648
|
async run(tasks) {
|
|
649
|
+
if (!this.#allowExecution) throw new WebSkillError("GOVERNANCE_FAILED", "EvaluationRunner executes skill scripts; pass allowExecution: true to opt in (sandbox executors are capability-reducing, not a security boundary)");
|
|
635
650
|
const results = [];
|
|
636
651
|
for (const task of tasks) try {
|
|
637
652
|
const { output, run } = await this.#runtime.run(task.prompt);
|
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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-DYrxhD3z.js";
|
|
2
2
|
//#region ../runtime/dist/index.d.ts
|
|
3
3
|
//#region src/llm/openAiCompatibleClient.d.ts
|
|
4
4
|
interface OpenAiCompatibleClientConfig {
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import { C as JsonSchema, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, S as FileSystemProvider, W as VerifyResult, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, x as FileStat } from "./types-CgNC-oQu-
|
|
2
|
-
import { $ as ToolDefinition, N as NetworkPolicy, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, b as FsArtifactStore, d as BridgeCapabilities, tt as ToolResult, u as ApprovalScope, x as FsMemoryStore } from "./index-
|
|
1
|
+
import { C as JsonSchema, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, S as FileSystemProvider, W as VerifyResult, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, x as FileStat } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
|
+
import { $ as ToolDefinition, N as NetworkPolicy, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, b as FsArtifactStore, d as BridgeCapabilities, tt as ToolResult, u as ApprovalScope, x as FsMemoryStore } from "./index-BSS3EWY-.js";
|
|
3
3
|
import { Readable, Writable } from "node:stream";
|
|
4
4
|
//#region ../node/dist/index.d.ts
|
|
5
5
|
//#region src/fs/nodeFs.d.ts
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* 基于 node:fs/promises 的 FileSystemProvider;接受 `/` 风格路径,写入自动创建父目录。
|
|
8
|
+
* 可选 root 模式:构造传入 root 后,read/write 操作先做 realpath 包含校验
|
|
9
|
+
* (root 与目标都 realpath 后前缀比对),经符号链接逃逸 root → FS_PATH_OUTSIDE_ROOT。
|
|
10
|
+
*/
|
|
7
11
|
declare class NodeFS implements FileSystemProvider {
|
|
8
12
|
#private;
|
|
9
13
|
readonly kind = "node";
|
|
14
|
+
constructor(deps?: {
|
|
15
|
+
root?: string;
|
|
16
|
+
});
|
|
10
17
|
readText(p: string): Promise<string>;
|
|
11
18
|
writeText(p: string, content: string): Promise<void>;
|
|
12
19
|
readBinary(p: string): Promise<Uint8Array>;
|
|
@@ -50,6 +57,8 @@ interface SandboxOptions {
|
|
|
50
57
|
capabilities?: BridgeCapabilities;
|
|
51
58
|
/** 网络策略:默认 'deny-all'(白名单见 runtime/sandbox/networkPolicy) */
|
|
52
59
|
networkPolicy?: NetworkPolicy;
|
|
60
|
+
/** 裸模块 allowlist(默认 []:一切 node: 内置模块全禁;按需放行如 ['node:path']) */
|
|
61
|
+
allowedModules?: string[];
|
|
53
62
|
/** require-approval 模式的授权询问出口(缺失时 require-approval 一律拒绝) */
|
|
54
63
|
uiBridge?: UiBridge;
|
|
55
64
|
/** 授权粒度:默认 'once-per-run' */
|
|
@@ -60,6 +69,10 @@ interface SandboxOptions {
|
|
|
60
69
|
* 每次执行独立 Worker(resourceLimits + env 白名单),loadDefinition 同样在
|
|
61
70
|
* Worker 内完成(禁止主进程 import 不可信脚本);超时 terminate(可杀同步死循环)。
|
|
62
71
|
* 能力桥协议与浏览器同一来源(runtime/sandbox/bridgeProtocol)。
|
|
72
|
+
*
|
|
73
|
+
* 诚实标注:本执行器做的是**能力面收敛**(网络策略、模块 allowlist、资源限额、
|
|
74
|
+
* 超时强杀),**不是安全边界**——Worker 内脚本与宿主共享进程,仍有绕过手段;
|
|
75
|
+
* 禁止假定其可隔离不可信脚本。
|
|
63
76
|
*/
|
|
64
77
|
declare class SandboxedScriptExecutor implements ScriptExecutor {
|
|
65
78
|
#private;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { $ as ToolDefinition, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as schemaToForm, D as HookRunnerOptions, E as HookRunner, F as OpenAiCompatibleClientConfig, G as RunTerminationReason, H as RunResult, I as ProgressiveRouter, J as RuntimeSession, K as RuntimePhase, L as READ_SKILL_FILE_INPUT_SCHEMA, M as LifecycleListener, N as NetworkPolicy, O as InstalledSkillManifest, P as OpenAiCompatibleClient, Q as SkillRouter, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as resolveToolName, T as GoogleGenAiClientConfig, Tt as toVercelToolSpecs, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, _ as EventBus, _t as isNetworkAllowed, a as AgentLoopConfig, at as TraceRecorder, b as FsArtifactStore, bt as normalizeToolContent, c as AnthropicClientConfig, ct as WebSkillRuntime, d as BridgeCapabilities, dt as buildRenderResult, et as ToolResolution, f as BridgeCapability, ft as createScriptContext, g as CapabilityMode, gt as fromVercelStreamPart, h as CapabilityApproval, ht as fromVercelResult, i as AgentLoop, it as TraceEventType, j as LifecycleHookContext, k as LifecycleEvent, l as ApprovalDecision, lt as WebSkillRuntimeDeps, m as BridgeResponse, mt as extractChartSpec, n as ASK_USER_TOOL, nt as TraceClock, o as AgentLoopDeps, ot as VercelToolSpec, p as BridgeRequest, pt as createWebSkillApi, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as TraceEvent, s as AnthropicClient, st as WebSkillApi, t as ASK_USER_INPUT_SCHEMA, tt as ToolResult, u as ApprovalScope, ut as bridgeError, v as ExternalSkillProvider, vt as mergeCatalogEntries, w as GoogleGenAiClient, wt as toLlmToolSpec, x as FsMemoryStore, xt as parseBridgeRequest, y as ExternalToolSource, yt as networkUrlHost, z as READ_SKILL_FILE_TOOL_NAME } from "./index-
|
|
3
|
-
export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, AnthropicClient, type AnthropicClientConfig, type ApprovalDecision, type ApprovalScope, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, type DiscoveryResult, EventBus, type ExternalSkillProvider, type ExternalToolSource, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, type GoogleGenAiClientConfig, HookRunner, type HookRunnerOptions, type InstalledSkillManifest, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillInstallSource, type SkillIssue, type SkillLocation, type SkillManifest, type SkillMetadata, type SkillPackManifest, SkillReader, type SkillRouter, type SkillSource, type SkillsLockfile, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
|
|
1
|
+
import { $ as escapeXml, A as SkillCatalog, B as SkillReader, C as JsonSchema, D as SKILL_NAME_MAX_LENGTH, E as SKILL_MANIFEST_FILE, F as SkillIssue, G as WebSkillError, H as SkillsLockfile, I as SkillLocation, J as buildCatalog, K as WebSkillErrorCode, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, O as SKILL_NAME_PATTERN, P as SkillInstallSource, Q as computeDigest, R as SkillMetadata, S as FileSystemProvider, T as SKILLS_LOCKFILE, U as ValidationReport, V as SkillSource, W as VerifyResult, X as checkDependencyCycles, Y as buildManifest, Z as checkSkillRules, _ as RenderResultRequest, a as InteractionPolicy, at as parseSkillPackManifest, b as DiscoveryResult, c as LlmClient, ct as resolveInsideRoot, d as LlmResponse, dt as xmlRenderer, et as exportSkills, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, it as parseSkillMarkdown, j as SkillCatalogEntry, k as SKILL_PACK_FILE, l as LlmCompleteInput, lt as validateSkills, m as LlmToolSpec, n as ArtifactStore, nt as jsonRenderer, o as InteractionRequest, ot as renderAvailableSkillsXml, p as LlmToolCall, q as assertSafePathSegment, r as ChartSpec, rt as normalizePath, s as InteractionResponse, st as renderCatalogJson, t as Artifact, tt as isValidSkillName, u as LlmMessage, ut as verifyManifest, v as UiBridge, w as MemoryFS, x as FileStat, y as CatalogRenderer, z as SkillPackManifest } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
|
+
import { $ as ToolDefinition, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as schemaToForm, D as HookRunnerOptions, E as HookRunner, F as OpenAiCompatibleClientConfig, G as RunTerminationReason, H as RunResult, I as ProgressiveRouter, J as RuntimeSession, K as RuntimePhase, L as READ_SKILL_FILE_INPUT_SCHEMA, M as LifecycleListener, N as NetworkPolicy, O as InstalledSkillManifest, P as OpenAiCompatibleClient, Q as SkillRouter, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as resolveToolName, T as GoogleGenAiClientConfig, Tt as toVercelToolSpecs, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, _ as EventBus, _t as isNetworkAllowed, a as AgentLoopConfig, at as TraceRecorder, b as FsArtifactStore, bt as normalizeToolContent, c as AnthropicClientConfig, ct as WebSkillRuntime, d as BridgeCapabilities, dt as buildRenderResult, et as ToolResolution, f as BridgeCapability, ft as createScriptContext, g as CapabilityMode, gt as fromVercelStreamPart, h as CapabilityApproval, ht as fromVercelResult, i as AgentLoop, it as TraceEventType, j as LifecycleHookContext, k as LifecycleEvent, l as ApprovalDecision, lt as WebSkillRuntimeDeps, m as BridgeResponse, mt as extractChartSpec, n as ASK_USER_TOOL, nt as TraceClock, o as AgentLoopDeps, ot as VercelToolSpec, p as BridgeRequest, pt as createWebSkillApi, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as TraceEvent, s as AnthropicClient, st as WebSkillApi, t as ASK_USER_INPUT_SCHEMA, tt as ToolResult, u as ApprovalScope, ut as bridgeError, v as ExternalSkillProvider, vt as mergeCatalogEntries, w as GoogleGenAiClient, wt as toLlmToolSpec, x as FsMemoryStore, xt as parseBridgeRequest, y as ExternalToolSource, yt as networkUrlHost, z as READ_SKILL_FILE_TOOL_NAME } from "./index-BSS3EWY-.js";
|
|
3
|
+
export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, AnthropicClient, type AnthropicClientConfig, type ApprovalDecision, type ApprovalScope, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, type DiscoveryResult, EventBus, type ExternalSkillProvider, type ExternalToolSource, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, type GoogleGenAiClientConfig, HookRunner, type HookRunnerOptions, type InstalledSkillManifest, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillInstallSource, type SkillIssue, type SkillLocation, type SkillManifest, type SkillMetadata, type SkillPackManifest, SkillReader, type SkillRouter, type SkillSource, type SkillsLockfile, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { A as mergeCatalogEntries, C as buildRenderResult, D as fromVercelResult, E as extractChartSpec, F as schemaToForm, I as toLlmToolSpec, L as toVercelToolSpecs, M as normalizeToolContent, N as parseBridgeRequest, O as fromVercelStreamPart, P as resolveToolName, S as bridgeError, T as createWebSkillApi, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as TraceRecorder, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as networkUrlHost, k as isNetworkAllowed, l as FsMemoryStore, m as OpenAiCompatibleClient, n as ASK_USER_TOOL, o as CapabilityApproval, p as HookRunner, r as ASK_USER_TOOL_NAME, s as EventBus, t as ASK_USER_INPUT_SCHEMA, u as FsRunSnapshotStore, v as READ_SKILL_FILE_TOOL_NAME, w as createScriptContext, x as WebSkillRuntime, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-
|
|
1
|
+
import { C as renderAvailableSkillsXml, D as verifyManifest, E as validateSkills, O as xmlRenderer, S as parseSkillPackManifest, T as resolveInsideRoot, _ as exportSkills, a as SKILL_NAME_PATTERN, b as normalizePath, c as SkillReader, d as buildCatalog, f as buildManifest, g as escapeXml, h as computeDigest, i as SKILL_NAME_MAX_LENGTH, l as WebSkillError, m as checkSkillRules, n as SKILLS_LOCKFILE, o as SKILL_PACK_FILE, p as checkDependencyCycles, r as SKILL_MANIFEST_FILE, s as SkillDiscovery, t as MemoryFS, u as assertSafePathSegment, v as isValidSkillName, w as renderCatalogJson, x as parseSkillMarkdown, y as jsonRenderer } from "./dist-DvoBsChX.js";
|
|
2
|
+
import { A as mergeCatalogEntries, C as buildRenderResult, D as fromVercelResult, E as extractChartSpec, F as schemaToForm, I as toLlmToolSpec, L as toVercelToolSpecs, M as normalizeToolContent, N as parseBridgeRequest, O as fromVercelStreamPart, P as resolveToolName, S as bridgeError, T as createWebSkillApi, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as TraceRecorder, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as networkUrlHost, k as isNetworkAllowed, l as FsMemoryStore, m as OpenAiCompatibleClient, n as ASK_USER_TOOL, o as CapabilityApproval, p as HookRunner, r as ASK_USER_TOOL_NAME, s as EventBus, t as ASK_USER_INPUT_SCHEMA, u as FsRunSnapshotStore, v as READ_SKILL_FILE_TOOL_NAME, w as createScriptContext, x as WebSkillRuntime, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-DAn07zHu.js";
|
|
3
3
|
|
|
4
|
-
export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, AnthropicClient, CapabilityApproval, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
|
|
4
|
+
export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, AnthropicClient, CapabilityApproval, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as JsonSchema, N as SkillDocument, j as SkillCatalogEntry, m as LlmToolSpec } from "./types-CgNC-oQu-
|
|
2
|
-
import { tt as ToolResult, v as ExternalSkillProvider, vt as mergeCatalogEntries, y as ExternalToolSource } from "./index-
|
|
1
|
+
import { C as JsonSchema, N as SkillDocument, j as SkillCatalogEntry, m as LlmToolSpec } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
|
+
import { tt as ToolResult, v as ExternalSkillProvider, vt as mergeCatalogEntries, y as ExternalToolSource } from "./index-BSS3EWY-.js";
|
|
3
3
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
4
4
|
import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l as WebSkillError } from "./dist-
|
|
2
|
-
import { A as mergeCatalogEntries, M as normalizeToolContent } from "./dist-
|
|
1
|
+
import { l as WebSkillError } from "./dist-DvoBsChX.js";
|
|
2
|
+
import { A as mergeCatalogEntries, M as normalizeToolContent } from "./dist-DAn07zHu.js";
|
|
3
3
|
import { fromJSONSchema } from "zod";
|
|
4
4
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
5
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as SKILL_MANIFEST_FILE, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, T as SKILLS_LOCKFILE, W as VerifyResult } from "./types-CgNC-oQu-
|
|
2
|
-
import { ft as createScriptContext } from "./index-
|
|
3
|
-
import { _ as readArchiveManifest, a as LlmEnvConfig, c as OxcSchemaInferer, d as SandboxedScriptExecutor, f as SkillManager, g as probeLlmCapabilities, h as loadLlmConfigFromEnv, i as LlmCapabilities, l as ProviderEnvConfig, m as loadGoogleConfigFromEnv, n as FileArtifactStore, o as NodeFS, p as loadAnthropicConfigFromEnv, r as FileMemoryStore, s as NodeScriptExecutor, t as CliUiBridge, u as SandboxOptions } from "./index-
|
|
1
|
+
import { E as SKILL_MANIFEST_FILE, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, T as SKILLS_LOCKFILE, W as VerifyResult } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
|
+
import { ft as createScriptContext } from "./index-BSS3EWY-.js";
|
|
3
|
+
import { _ as readArchiveManifest, a as LlmEnvConfig, c as OxcSchemaInferer, d as SandboxedScriptExecutor, f as SkillManager, g as probeLlmCapabilities, h as loadLlmConfigFromEnv, i as LlmCapabilities, l as ProviderEnvConfig, m as loadGoogleConfigFromEnv, n as FileArtifactStore, o as NodeFS, p as loadAnthropicConfigFromEnv, r as FileMemoryStore, s as NodeScriptExecutor, t as CliUiBridge, u as SandboxOptions } from "./index-npFMt2Zw.js";
|
|
4
4
|
export { CliUiBridge, FileArtifactStore, FileMemoryStore, type LlmCapabilities, type LlmEnvConfig, NodeFS, NodeScriptExecutor, OxcSchemaInferer, type ProviderEnvConfig, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, type SandboxOptions, SandboxedScriptExecutor, type SkillInstallSource, SkillManager, type SkillManifest, type SkillsLockfile, type VerifyResult, createScriptContext, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
|
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as SKILLS_LOCKFILE, r as SKILL_MANIFEST_FILE } from "./dist-
|
|
2
|
-
import { w as createScriptContext } from "./dist-
|
|
3
|
-
import { a as NodeScriptExecutor, c as SkillManager, d as loadLlmConfigFromEnv, f as probeLlmCapabilities, i as NodeFS, l as loadAnthropicConfigFromEnv, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as loadGoogleConfigFromEnv } from "./dist-
|
|
1
|
+
import { n as SKILLS_LOCKFILE, r as SKILL_MANIFEST_FILE } from "./dist-DvoBsChX.js";
|
|
2
|
+
import { w as createScriptContext } from "./dist-DAn07zHu.js";
|
|
3
|
+
import { a as NodeScriptExecutor, c as SkillManager, d as loadLlmConfigFromEnv, f as probeLlmCapabilities, i as NodeFS, l as loadAnthropicConfigFromEnv, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as loadGoogleConfigFromEnv } from "./dist-BVXZF7H_.js";
|
|
4
4
|
|
|
5
5
|
export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { register } from "node:module";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { isMainThread, parentPort, workerData } from "node:worker_threads";
|
|
4
|
+
|
|
5
|
+
//#region ../node/dist/executor/sandboxWorkerEntry.js
|
|
6
|
+
/**
|
|
7
|
+
* D1 沙箱 Worker 入口(loader 文件形式,非内嵌字符串)。
|
|
8
|
+
* 主线程经 workerData 传入任务;脚本源码路径直接 import(.ts 依赖
|
|
9
|
+
* Node>=22.18 原生 type stripping,Worker 内同样生效)。
|
|
10
|
+
* 能力桥 RPC(readReference/writeArtifact/confirm)经 parentPort 消息。
|
|
11
|
+
*
|
|
12
|
+
* 网络与模块管控:
|
|
13
|
+
* - patch globalThis.fetch / globalThis.WebSocket(策略判定函数源码经 workerData
|
|
14
|
+
* 注入,匹配逻辑单一来源在 runtime/sandbox/networkPolicy.ts——Worker 线程不走
|
|
15
|
+
* vitest 别名、也不应反向依赖宿主打包产物,故注入而非 import)。
|
|
16
|
+
* - node: 内置模块 allowlist(module.register resolve 钩子):默认全禁
|
|
17
|
+
* (含 fs/child_process/net 等),执行器配置可显式放行指定模块。
|
|
18
|
+
* 能力面收敛,非安全边界(仍有绕过手段,禁止假定其可隔离不可信脚本)。
|
|
19
|
+
* - 网络阻断时 postMessage {type:'network-blocked', host} → 宿主记 run.warning(URL 脱敏只记 host)。
|
|
20
|
+
*/
|
|
21
|
+
const port = parentPort;
|
|
22
|
+
if (!port || isMainThread) throw new Error("sandboxWorkerEntry must run inside a worker thread");
|
|
23
|
+
const pending = /* @__PURE__ */ new Map();
|
|
24
|
+
let bridgeSeq = 0;
|
|
25
|
+
function callCapability(kind, payload) {
|
|
26
|
+
const request = {
|
|
27
|
+
kind,
|
|
28
|
+
id: `br-${++bridgeSeq}`,
|
|
29
|
+
...payload
|
|
30
|
+
};
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
pending.set(request.id, {
|
|
33
|
+
resolve,
|
|
34
|
+
reject
|
|
35
|
+
});
|
|
36
|
+
port.postMessage({
|
|
37
|
+
type: "bridge",
|
|
38
|
+
request
|
|
39
|
+
});
|
|
40
|
+
}).then((response) => {
|
|
41
|
+
const r = response;
|
|
42
|
+
if (!r.ok) {
|
|
43
|
+
const err = new Error(r.error?.message ?? "capability call failed");
|
|
44
|
+
err.code = r.error?.code ?? "TOOL_EXECUTION_FAILED";
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
return r.value;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async function loadModule(scriptPath) {
|
|
51
|
+
return await import(`${pathToFileURL(scriptPath).href}?t=${Date.now()}`);
|
|
52
|
+
}
|
|
53
|
+
function post(message) {
|
|
54
|
+
port.postMessage(message);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 裸模块 allowlist 钩子(data: URL 注册):
|
|
58
|
+
* 默认禁止一切 node: 内置模块(含 fs/child_process/process/vm/module/worker_threads 等),
|
|
59
|
+
* 仅 ALLOWED 清单(执行器配置注入)显式放行。网络裸模块语义合并统一:
|
|
60
|
+
* allowlist 为空即全禁(含 node:net/http/https/dgram/tls)。
|
|
61
|
+
*/
|
|
62
|
+
const MODULE_HOOK_SOURCE = `
|
|
63
|
+
var ALLOWED = new Set(%ALLOWED_MODULES%);
|
|
64
|
+
var TOP_BUILTINS = new Set(['assert','async_hooks','buffer','child_process','cluster','console','constants','crypto','dgram','diagnostics_channel','dns','domain','events','fs','http','http2','https','inspector','module','net','os','path','perf_hooks','process','punycode','querystring','readline','repl','sea','sqlite','stream','string_decoder','sys','test','timers','tls','trace_events','tty','url','util','v8','vm','wasi','worker_threads','zlib']);
|
|
65
|
+
function isAllowed(bare, name, top) {
|
|
66
|
+
return ALLOWED.has(bare) || ALLOWED.has(name) || ALLOWED.has('node:' + name) || ALLOWED.has(top) || ALLOWED.has('node:' + top);
|
|
67
|
+
}
|
|
68
|
+
export async function resolve(specifier, context, nextResolve) {
|
|
69
|
+
var bare = specifier.split('?')[0];
|
|
70
|
+
var name = bare.indexOf('node:') === 0 ? bare.slice(5) : bare;
|
|
71
|
+
var top = name.split('/')[0];
|
|
72
|
+
var isBuiltin = bare.indexOf('node:') === 0 || TOP_BUILTINS.has(top);
|
|
73
|
+
if (isBuiltin && !isAllowed(bare, name, top)) {
|
|
74
|
+
var err = new Error('Builtin module import blocked by sandbox module policy: ' + bare);
|
|
75
|
+
err.code = 'TOOL_UNSUPPORTED';
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
return nextResolve(specifier, context);
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
function blockedError(host) {
|
|
82
|
+
const err = /* @__PURE__ */ new Error(`Network request blocked by sandbox network policy: ${host}`);
|
|
83
|
+
err.code = "NETWORK_BLOCKED";
|
|
84
|
+
return err;
|
|
85
|
+
}
|
|
86
|
+
/** patch 全局 fetch / WebSocket;注册裸网络模块 denylist(allow-all 之外均启用) */
|
|
87
|
+
function setupNetworkGuards(task) {
|
|
88
|
+
const policy = task.networkPolicy ?? "deny-all";
|
|
89
|
+
if (!task.networkPolicyLib) return;
|
|
90
|
+
const { isNetworkAllowed, networkUrlHost } = new Function(`${task.networkPolicyLib}\nreturn { isNetworkAllowed: isNetworkAllowed, networkUrlHost: networkUrlHost };`)();
|
|
91
|
+
const gate = (rawUrl) => {
|
|
92
|
+
const url = String(rawUrl);
|
|
93
|
+
if (isNetworkAllowed(policy, url)) return null;
|
|
94
|
+
const host = networkUrlHost(url);
|
|
95
|
+
post({
|
|
96
|
+
type: "network-blocked",
|
|
97
|
+
host
|
|
98
|
+
});
|
|
99
|
+
return blockedError(host);
|
|
100
|
+
};
|
|
101
|
+
const originalFetch = globalThis["fetch"];
|
|
102
|
+
if (typeof originalFetch === "function") globalThis["fetch"] = (input, init) => {
|
|
103
|
+
const raw = typeof input === "string" ? input : input instanceof URL ? input.href : input?.url ?? String(input);
|
|
104
|
+
const blocked = gate(raw);
|
|
105
|
+
if (blocked) return Promise.reject(blocked);
|
|
106
|
+
return originalFetch(input, init);
|
|
107
|
+
};
|
|
108
|
+
const OriginalWebSocket = globalThis["WebSocket"];
|
|
109
|
+
if (typeof OriginalWebSocket === "function") globalThis["WebSocket"] = class extends OriginalWebSocket {
|
|
110
|
+
constructor(url, protocols) {
|
|
111
|
+
const blocked = gate(String(url));
|
|
112
|
+
if (blocked) throw blocked;
|
|
113
|
+
super(url, protocols);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
register(`data:text/javascript,${encodeURIComponent(MODULE_HOOK_SOURCE.replace("%ALLOWED_MODULES%", JSON.stringify(task.allowedModules ?? [])))}`);
|
|
117
|
+
}
|
|
118
|
+
async function main() {
|
|
119
|
+
const task = workerData;
|
|
120
|
+
setupNetworkGuards(task);
|
|
121
|
+
port.on("message", (msg) => {
|
|
122
|
+
if (msg?.type === "bridge-response" && msg.response?.id) {
|
|
123
|
+
const entry = pending.get(msg.response.id);
|
|
124
|
+
if (entry) {
|
|
125
|
+
pending.delete(msg.response.id);
|
|
126
|
+
entry.resolve(msg.response);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
if (task.mode === "load") {
|
|
131
|
+
try {
|
|
132
|
+
const mod = await loadModule(task.scriptPath);
|
|
133
|
+
post({
|
|
134
|
+
type: "load-result",
|
|
135
|
+
ok: true,
|
|
136
|
+
definition: {
|
|
137
|
+
description: typeof mod["description"] === "string" ? mod["description"] : void 0,
|
|
138
|
+
inputSchema: mod["inputSchema"] !== void 0 ? mod["inputSchema"] : void 0,
|
|
139
|
+
hasRun: typeof mod["run"] === "function"
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} catch (e) {
|
|
143
|
+
post({
|
|
144
|
+
type: "load-result",
|
|
145
|
+
ok: false,
|
|
146
|
+
error: {
|
|
147
|
+
code: e?.code ?? "TOOL_EXECUTION_FAILED",
|
|
148
|
+
message: String(e?.message ?? e)
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const stdout = [];
|
|
155
|
+
const stderr = [];
|
|
156
|
+
const originals = {
|
|
157
|
+
log: console.log,
|
|
158
|
+
info: console.info,
|
|
159
|
+
debug: console.debug,
|
|
160
|
+
warn: console.warn,
|
|
161
|
+
error: console.error
|
|
162
|
+
};
|
|
163
|
+
console.log = console.info = console.debug = (...args) => stdout.push(args.map(String).join(" "));
|
|
164
|
+
console.warn = console.error = (...args) => stderr.push(args.map(String).join(" "));
|
|
165
|
+
try {
|
|
166
|
+
const mod = await loadModule(task.scriptPath);
|
|
167
|
+
if (typeof mod["run"] !== "function") throw new Error("Script does not export a run function");
|
|
168
|
+
const context = {
|
|
169
|
+
skillName: task.skillName ?? "",
|
|
170
|
+
runId: task.runId ?? "",
|
|
171
|
+
readReference: (path) => callCapability("readReference", { path }),
|
|
172
|
+
writeArtifact: (path, content, options) => callCapability("writeArtifact", {
|
|
173
|
+
path,
|
|
174
|
+
content: typeof content === "string" ? content : Array.from(content ?? []),
|
|
175
|
+
mimeType: options?.mimeType
|
|
176
|
+
}),
|
|
177
|
+
confirm: (message) => callCapability("confirm", { message })
|
|
178
|
+
};
|
|
179
|
+
const runFn = mod["run"];
|
|
180
|
+
const value = await runFn(task.args ?? {}, context);
|
|
181
|
+
post({
|
|
182
|
+
type: "execute-result",
|
|
183
|
+
ok: true,
|
|
184
|
+
value: value === void 0 ? null : value,
|
|
185
|
+
stdout,
|
|
186
|
+
stderr
|
|
187
|
+
});
|
|
188
|
+
} catch (e) {
|
|
189
|
+
const err = e;
|
|
190
|
+
post({
|
|
191
|
+
type: "execute-result",
|
|
192
|
+
ok: false,
|
|
193
|
+
error: {
|
|
194
|
+
code: err?.code ?? "TOOL_EXECUTION_FAILED",
|
|
195
|
+
message: String(err?.message ?? e)
|
|
196
|
+
},
|
|
197
|
+
stdout,
|
|
198
|
+
stderr
|
|
199
|
+
});
|
|
200
|
+
} finally {
|
|
201
|
+
console.log = originals.log;
|
|
202
|
+
console.info = originals.info;
|
|
203
|
+
console.debug = originals.debug;
|
|
204
|
+
console.warn = originals.warn;
|
|
205
|
+
console.error = originals.error;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
main().then(() => process.exit(0), (e) => {
|
|
209
|
+
console.error(e);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
export { };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as LlmClient, d as LlmResponse, f as LlmStreamEvent, h as MemoryStore, l as LlmCompleteInput, n as ArtifactStore, o as InteractionRequest, s as InteractionResponse, t as Artifact, v as UiBridge } from "./types-CgNC-oQu-
|
|
1
|
+
import { c as LlmClient, d as LlmResponse, f as LlmStreamEvent, h as MemoryStore, l as LlmCompleteInput, n as ArtifactStore, o as InteractionRequest, s as InteractionResponse, t as Artifact, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
2
|
//#region ../runtime/dist/testing.d.ts
|
|
3
3
|
//#region src/llm/mockLlmClient.d.ts
|
|
4
4
|
type MockLlmHandler = (input: LlmCompleteInput) => LlmResponse | Promise<LlmResponse>;
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { t as MemoryArtifactStore } from "./memoryArtifactStore-C9lFVqPF-yFz6yJj0.js";
|
|
2
|
-
import { n as MockLlmClient, r as MockUiBridge, t as InMemoryStore } from "./testing-
|
|
2
|
+
import { n as MockLlmClient, r as MockUiBridge, t as InMemoryStore } from "./testing-S8SN9Lc6.js";
|
|
3
3
|
|
|
4
4
|
export { InMemoryStore, MemoryArtifactStore, MockLlmClient, MockUiBridge };
|
|
@@ -146,9 +146,19 @@ declare class MemoryFS implements FileSystemProvider {
|
|
|
146
146
|
//#region src/fs/pathSecurity.d.ts
|
|
147
147
|
/** 统一分隔符为 `/`,去除 `.` 段与重复分隔符(不解析 `..`) */
|
|
148
148
|
declare function normalizePath(path: string): string;
|
|
149
|
+
/**
|
|
150
|
+
* 外部标识(runId、candidateId、skillName、versionId 等)作为单一路径段使用前的统一校验:
|
|
151
|
+
* 拒绝空串、`.`、`..`、含 `/` 或 `\`、含 `:`(Windows 盘符/ADS)。
|
|
152
|
+
* 违规抛 FS_PATH_OUTSIDE_ROOT(kind 用于错误消息定位,如 "runId")。
|
|
153
|
+
*/
|
|
154
|
+
declare function assertSafePathSegment(segment: string, kind: string): void;
|
|
149
155
|
/**
|
|
150
156
|
* 将相对路径安全地解析到 root 之内。
|
|
151
157
|
* 拒绝空路径、绝对路径(`/`、`\\`、`C:\` 形式)与任何 `..` 段。
|
|
158
|
+
*
|
|
159
|
+
* 注意:本函数仅做**词法**校验,不解析符号链接——root 内经符号链接指向
|
|
160
|
+
* 外部的目标无法被词法检查拦截(realpath 防护见 NodeFS root 模式与
|
|
161
|
+
* 安装管线的 lstat 符号链接扫描)。
|
|
152
162
|
*/
|
|
153
163
|
declare function resolveInsideRoot(root: string, relativePath: string): string;
|
|
154
164
|
//#endregion
|
|
@@ -536,4 +546,4 @@ interface MemoryStore {
|
|
|
536
546
|
clear(scope?: string): Promise<void>;
|
|
537
547
|
}
|
|
538
548
|
//#endregion
|
|
539
|
-
export {
|
|
549
|
+
export { escapeXml as $, SkillCatalog as A, SkillReader as B, JsonSchema as C, SKILL_NAME_MAX_LENGTH as D, SKILL_MANIFEST_FILE as E, SkillIssue as F, WebSkillError as G, SkillsLockfile as H, SkillLocation as I, buildCatalog as J, WebSkillErrorCode as K, SkillManifest as L, SkillDiscovery as M, SkillDocument as N, SKILL_NAME_PATTERN as O, SkillInstallSource as P, computeDigest as Q, SkillMetadata as R, FileSystemProvider as S, SKILLS_LOCKFILE as T, ValidationReport as U, SkillSource as V, VerifyResult as W, checkDependencyCycles as X, buildManifest as Y, checkSkillRules as Z, RenderResultRequest as _, InteractionPolicy as a, parseSkillPackManifest as at, DiscoveryResult as b, LlmClient as c, resolveInsideRoot as ct, LlmResponse as d, xmlRenderer as dt, exportSkills as et, LlmStreamEvent as f, RenderBlock as g, MemoryStore as h, FormField as i, parseSkillMarkdown as it, SkillCatalogEntry as j, SKILL_PACK_FILE as k, LlmCompleteInput as l, validateSkills as lt, LlmToolSpec as m, ArtifactStore as n, jsonRenderer as nt, InteractionRequest as o, renderAvailableSkillsXml as ot, LlmToolCall as p, assertSafePathSegment as q, ChartSpec as r, normalizePath as rt, InteractionResponse as s, renderCatalogJson as st, Artifact as t, isValidSkillName as tt, LlmMessage as u, verifyManifest as ut, UiBridge as v, MemoryFS as w, FileStat as x, CatalogRenderer as y, SkillPackManifest as z };
|
package/dist/ui-react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CgNC-oQu-
|
|
1
|
+
import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
2
|
//#region ../ui-react/dist/index.d.ts
|
|
3
3
|
//#region src/bridgeState.d.ts
|
|
4
4
|
/**
|
package/dist/ui-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-
|
|
1
|
+
import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-MTc2KB03.js";
|
|
2
2
|
import { useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
|
package/dist/ui-vue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CgNC-oQu-
|
|
1
|
+
import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.js";
|
|
2
2
|
import { PropType } from "vue";
|
|
3
3
|
//#region ../ui-vue/dist/index.d.ts
|
|
4
4
|
//#region src/bridgeState.d.ts
|
package/dist/ui-vue.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-
|
|
1
|
+
import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-MTc2KB03.js";
|
|
2
2
|
import { defineComponent, h, reactive, ref } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region ../ui-vue/dist/index.js
|