@webskill/sdk 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { B as SkillManifest, C as FileStat, G as SkillsLockfile, L as SkillInstallSource, _ as RenderResultRequest, a as InteractionPolicy, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, o as InteractionRequest, q as VerifyResult, s as InteractionResponse, v as UiBridge, w as FileSystemProvider, y as ArchiveLimits } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { Et as parseBridgeRequest, N as NetworkPolicy, Q as ScriptExecutor, Z as ScriptExecutionContext, d as BridgeCapabilities, it as ToolResult, m as BridgeResponse, nt as ToolDefinition, p as BridgeRequest, pt as bridgeError, u as ApprovalScope, ut as WebSkillApi, v as ExternalSkillProvider, y as ExternalToolSource } from "./index-DfINBEOy.js";
2
+ import { Et as parseBridgeRequest, N as NetworkPolicy, Q as ScriptExecutor, Z as ScriptExecutionContext, d as BridgeCapabilities, it as ToolResult, m as BridgeResponse, nt as ToolDefinition, p as BridgeRequest, pt as bridgeError, u as ApprovalScope, ut as WebSkillApi, v as ExternalSkillProvider, y as ExternalToolSource } from "./index-DJOha4b6.js";
3
3
  //#region ../browser/dist/index.d.ts
4
4
  //#region src/fs/featureDetection.d.ts
5
5
  /** 检测当前环境是否可用 OPFS(navigator.storage.getDirectory) */
package/dist/browser.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { C as messageOf, D as readResponseWithLimit, E as parseSkillPackManifest, M as unzipWithLimits, N as validateSkills, P as verifyManifest, T as parseSkillMarkdown, b as exportSkills, c as SkillDiscovery, d as assertRemoteUrlAllowed, h as buildManifest, i as SKILL_MANIFEST_FILE, j as resolveInsideRoot, m as buildCatalog, p as atomicWriteText, r as SKILLS_LOCKFILE, s as SKILL_PACK_FILE, u as WebSkillError, x as isValidSkillName } from "./dist-BQzncxXg.js";
2
- import { A as isNetworkAllowed, C as bridgeError, E as createWebSkillApi, F as normalizeToolError, I as parseBridgeRequest, M as networkUrlHost, P as normalizeToolContent, c as FsArtifactStore, h as ProgressiveRouter, i as AgentLoop, j as mergeCatalogEntries, l as FsMemoryStore, m as OpenAiCompatibleClient, o as CapabilityApproval, u as FsRunSnapshotStore, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-B77plHjw.js";
2
+ import { A as isNetworkAllowed, C as bridgeError, E as createWebSkillApi, F as normalizeToolError, I as parseBridgeRequest, M as networkUrlHost, P as normalizeToolContent, c as FsArtifactStore, h as ProgressiveRouter, i as AgentLoop, j as mergeCatalogEntries, l as FsMemoryStore, m as OpenAiCompatibleClient, o as CapabilityApproval, u as FsRunSnapshotStore, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-BXpDDZpR.js";
3
3
  import { n as MockLlmClient } from "./testing-BUoXvm1u.js";
4
4
 
5
5
  //#region ../browser/dist/index.js
@@ -40,7 +40,7 @@ var OpenAiCompatibleClient = class {
40
40
  #fetch;
41
41
  constructor(config) {
42
42
  this.#config = config;
43
- this.#fetch = config.fetchImpl ?? fetch;
43
+ this.#fetch = config.fetchImpl ?? ((input, init) => fetch(input, init));
44
44
  }
45
45
  #requireConfig() {
46
46
  const { baseUrl, apiKey, model } = this.#config;
@@ -262,7 +262,7 @@ var AnthropicClient = class {
262
262
  #fetch;
263
263
  constructor(config) {
264
264
  this.#config = config;
265
- this.#fetch = config.fetchImpl ?? fetch;
265
+ this.#fetch = config.fetchImpl ?? ((input, init) => fetch(input, init));
266
266
  }
267
267
  #baseUrl() {
268
268
  return (this.#config.baseUrl ?? "https://api.anthropic.com").replace(/\/+$/, "");
@@ -491,7 +491,7 @@ var GoogleGenAiClient = class {
491
491
  #fetch;
492
492
  constructor(config) {
493
493
  this.#config = config;
494
- this.#fetch = config.fetchImpl ?? fetch;
494
+ this.#fetch = config.fetchImpl ?? ((input, init) => fetch(input, init));
495
495
  }
496
496
  #baseUrl() {
497
497
  return (this.#config.baseUrl ?? "https://generativelanguage.googleapis.com").replace(/\/+$/, "");
@@ -1092,6 +1092,11 @@ const toolError = (code, message) => ({
1092
1092
  message
1093
1093
  }
1094
1094
  });
1095
+ /** 工具参数摘要(JSON 截断 100 字符;trace 与实时事件同一口径,ToolCallCard 展开详情用) */
1096
+ const summarizeArgs = (args) => {
1097
+ const json = JSON.stringify(args);
1098
+ return json.length > 100 ? `${json.slice(0, 100)}…` : json;
1099
+ };
1095
1100
  /**
1096
1101
  * 多轮 Agent 循环。
1097
1102
  * 工具失败一律转为 ToolResult{ok:false} 回喂 LLM 继续循环;
@@ -1101,6 +1106,10 @@ var AgentLoop = class {
1101
1106
  #deps;
1102
1107
  #config;
1103
1108
  #policy;
1109
+ /** 活跃 run 的 AbortController(cancel(runId) 触发;终态清理) */
1110
+ #controllers = /* @__PURE__ */ new Map();
1111
+ /** 经 cancel() 主动取消的 run(aborted 分支据此区分 cancelled 与 timeout) */
1112
+ #cancelled = /* @__PURE__ */ new Set();
1104
1113
  constructor(deps, config = {}) {
1105
1114
  this.#deps = {
1106
1115
  ...deps,
@@ -1121,6 +1130,18 @@ var AgentLoop = class {
1121
1130
  interactionTimeoutMs: deps.interaction?.interactionTimeoutMs ?? 3e5
1122
1131
  };
1123
1132
  }
1133
+ /**
1134
+ * 取消进行中的 run:触发该 run 的 AbortController(与 totalTimeout 硬期限同一通道),
1135
+ * run 以 cancelled(RUN_CANCELLED)终止;未找到(已终态或不属于本实例)返回 false。
1136
+ * 取消在下一个中断点生效(LLM complete/stream 调用;交互等待不强制中断)。
1137
+ */
1138
+ cancel(runId) {
1139
+ const controller = this.#controllers.get(runId);
1140
+ if (!controller) return false;
1141
+ this.#cancelled.add(runId);
1142
+ controller.abort();
1143
+ return true;
1144
+ }
1124
1145
  async run(input) {
1125
1146
  const now = this.#deps.clock?.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
1126
1147
  const runId = input.runId ?? `run-${Math.random().toString(36).slice(2, 10)}`;
@@ -1156,6 +1177,7 @@ var AgentLoop = class {
1156
1177
  totalTimeoutMs: this.#config.totalTimeoutMs,
1157
1178
  controller: new AbortController()
1158
1179
  };
1180
+ this.#controllers.set(runId, state.controller);
1159
1181
  if (this.#deps.hooks && !this.#deps.hooks.onWarning) this.#deps.hooks.onWarning = (message) => trace.record("run.warning", { message });
1160
1182
  const route = this.#deps.catalogFilter ? {
1161
1183
  ...input.route,
@@ -1250,7 +1272,10 @@ var AgentLoop = class {
1250
1272
  signal: state.controller.signal
1251
1273
  });
1252
1274
  } catch (e) {
1253
- if (state.controller.signal.aborted) return finish("failed", "timeout", `Agent loop exceeded the total timeout of ${state.totalTimeoutMs}ms`, "RUN_TIMEOUT");
1275
+ if (state.controller.signal.aborted) {
1276
+ if (this.#cancelled.has(state.runId)) return finish("cancelled", "user-cancelled", "Run cancelled by user", "RUN_CANCELLED");
1277
+ return finish("failed", "timeout", `Agent loop exceeded the total timeout of ${state.totalTimeoutMs}ms`, "RUN_TIMEOUT");
1278
+ }
1254
1279
  const code = e instanceof WebSkillError && (e.code === "LLM_UNAVAILABLE" || e.code === "LLM_REQUEST_FAILED") ? e.code : "LLM_REQUEST_FAILED";
1255
1280
  return finish("failed", "llm-error", messageOf(e), code);
1256
1281
  }
@@ -1294,6 +1319,8 @@ var AgentLoop = class {
1294
1319
  /** 统一终态处理:completed/failed/cancelled;终态即删快照(快照是续命机制,审计归治理) */
1295
1320
  async #finish(state, status, reason, output, errorCode) {
1296
1321
  this.#disarmDeadline(state);
1322
+ this.#controllers.delete(state.runId);
1323
+ this.#cancelled.delete(state.runId);
1297
1324
  const { run, trace } = state;
1298
1325
  run.status = status;
1299
1326
  run.terminationReason = reason;
@@ -1408,6 +1435,7 @@ var AgentLoop = class {
1408
1435
  totalTimeoutMs: snapshot.config.totalTimeoutMs,
1409
1436
  controller: new AbortController()
1410
1437
  };
1438
+ this.#controllers.set(runId, state.controller);
1411
1439
  if (this.#deps.hooks && !this.#deps.hooks.onWarning) this.#deps.hooks.onWarning = (message) => trace.record("run.warning", { message });
1412
1440
  trace.record("run.resumed", { data: {
1413
1441
  snapshotAt: snapshot.snapshotAt,
@@ -1628,10 +1656,14 @@ var AgentLoop = class {
1628
1656
  });
1629
1657
  }
1630
1658
  async #executeCall(call, state) {
1659
+ const argsSummary = summarizeArgs(call.arguments);
1660
+ const callStartMs = Date.parse(state.now());
1631
1661
  state.trace.record("tool.started", { data: {
1632
1662
  name: call.name,
1633
- callId: call.id
1663
+ callId: call.id,
1664
+ args: argsSummary
1634
1665
  } });
1666
+ this.#emitTool(state, "started", call);
1635
1667
  let result;
1636
1668
  if (call.name === "read_skill_file") result = await this.#handleReadSkillFile(call, state);
1637
1669
  else if (call.name === "ask_user") result = await this.#handleAskUser(call, state);
@@ -1643,11 +1675,15 @@ var AgentLoop = class {
1643
1675
  result = source ? await source.call(call.name, call.arguments) : toolError(resolution.code, resolution.message);
1644
1676
  }
1645
1677
  }
1678
+ const durationMs = Date.parse(state.now()) - callStartMs;
1646
1679
  if (result.ok) {
1647
1680
  state.trace.record("tool.completed", { data: {
1648
1681
  name: call.name,
1649
- callId: call.id
1682
+ callId: call.id,
1683
+ args: argsSummary,
1684
+ durationMs
1650
1685
  } });
1686
+ this.#emitTool(state, "completed", call);
1651
1687
  for (const item of result.content) {
1652
1688
  if (item.type !== "json") continue;
1653
1689
  const chart = extractChartSpec(item.data);
@@ -1656,20 +1692,45 @@ var AgentLoop = class {
1656
1692
  chart
1657
1693
  });
1658
1694
  }
1659
- } else state.trace.record("tool.failed", {
1660
- message: result.error?.message,
1661
- data: {
1662
- name: call.name,
1663
- callId: call.id,
1664
- code: result.error?.code
1665
- }
1666
- });
1695
+ } else {
1696
+ state.trace.record("tool.failed", {
1697
+ message: result.error?.message,
1698
+ data: {
1699
+ name: call.name,
1700
+ callId: call.id,
1701
+ code: result.error?.code,
1702
+ args: argsSummary,
1703
+ durationMs
1704
+ }
1705
+ });
1706
+ this.#emitTool(state, "failed", call);
1707
+ }
1667
1708
  for (const artifact of result.artifacts ?? []) state.trace.record("artifact.created", { data: {
1668
1709
  artifactId: artifact.id,
1669
1710
  path: artifact.path
1670
1711
  } });
1671
1712
  return result;
1672
1713
  }
1714
+ /**
1715
+ * 逐工具实时事件(execute 相位,data.type='tool'):chatbot ToolCallCard 等的 live 状态源;
1716
+ * 与既有 execute 相位事件({turn})并存,监听方按 data.type 区分。
1717
+ * data.args 为参数摘要(JSON 截断 100 字符,卡片展开详情用)。
1718
+ */
1719
+ #emitTool(state, status, call) {
1720
+ this.#deps.eventBus?.emit({
1721
+ phase: "execute",
1722
+ runId: state.runId,
1723
+ sessionId: state.run.sessionId,
1724
+ ts: state.now(),
1725
+ data: {
1726
+ type: "tool",
1727
+ status,
1728
+ name: call.name,
1729
+ callId: call.id,
1730
+ args: summarizeArgs(call.arguments)
1731
+ }
1732
+ });
1733
+ }
1673
1734
  async #handleAskUser(call, state) {
1674
1735
  const question = call.arguments["question"];
1675
1736
  if (typeof question !== "string" || question === "") return toolError("TOOL_EXECUTION_FAILED", "ask_user requires a non-empty \"question\" string argument");
@@ -2140,6 +2201,8 @@ var WebSkillRuntime = class {
2140
2201
  #session;
2141
2202
  #events;
2142
2203
  #catalogCache;
2204
+ /** 活跃 run 的 loop 实例(cancel(runId) 路由;终态清理) */
2205
+ #loops = /* @__PURE__ */ new Map();
2143
2206
  constructor(deps) {
2144
2207
  this.#deps = {
2145
2208
  ...deps,
@@ -2224,7 +2287,7 @@ var WebSkillRuntime = class {
2224
2287
  const catalog = providerEntries.length > 0 ? { entries: mergeCatalogEntries(cache.catalog.entries, providerEntries) } : cache.catalog;
2225
2288
  const filteredCatalog = this.#deps.catalogFilter ? { entries: await this.#deps.catalogFilter(catalog.entries) } : catalog;
2226
2289
  const route = await this.#router.route(filteredCatalog);
2227
- const result = await new AgentLoop({
2290
+ const loop = new AgentLoop({
2228
2291
  llm: this.#deps.llm,
2229
2292
  executor: this.#deps.executor,
2230
2293
  schemaInferer: this.#deps.schemaInferer,
@@ -2243,12 +2306,21 @@ var WebSkillRuntime = class {
2243
2306
  catalogFilter: this.#deps.catalogFilter,
2244
2307
  snapshotStore: this.#deps.snapshotStore,
2245
2308
  skillStateGuard: this.#deps.skillStateGuard
2246
- }, this.#deps.config).run({
2247
- sessionId: options.sessionId ?? this.#session.id,
2248
- userPrompt,
2249
- route,
2250
- ...options.history ? { history: options.history } : {}
2251
- });
2309
+ }, this.#deps.config);
2310
+ const runId = `run-${Math.random().toString(36).slice(2, 10)}`;
2311
+ this.#loops.set(runId, loop);
2312
+ let result;
2313
+ try {
2314
+ result = await loop.run({
2315
+ sessionId: options.sessionId ?? this.#session.id,
2316
+ userPrompt,
2317
+ route,
2318
+ runId,
2319
+ ...options.history ? { history: options.history } : {}
2320
+ });
2321
+ } finally {
2322
+ this.#loops.delete(runId);
2323
+ }
2252
2324
  for (const failure of providerFailures) result.run.trace.push({
2253
2325
  id: `evt-provider-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2254
2326
  runId: result.run.id,
@@ -2323,7 +2395,7 @@ var WebSkillRuntime = class {
2323
2395
  if (!this.#catalogCache) await this.discover();
2324
2396
  const cache = this.#catalogCache;
2325
2397
  if (!cache) throw new WebSkillError("RUN_FAILED", "discover() did not populate the catalog cache");
2326
- return new AgentLoop({
2398
+ const loop = new AgentLoop({
2327
2399
  llm: this.#deps.llm,
2328
2400
  executor: this.#deps.executor,
2329
2401
  schemaInferer: this.#deps.schemaInferer,
@@ -2342,7 +2414,21 @@ var WebSkillRuntime = class {
2342
2414
  catalogFilter: this.#deps.catalogFilter,
2343
2415
  snapshotStore: store,
2344
2416
  skillStateGuard: this.#deps.skillStateGuard
2345
- }, this.#deps.config).resume(snapshot);
2417
+ }, this.#deps.config);
2418
+ this.#loops.set(runId, loop);
2419
+ try {
2420
+ return await loop.resume(snapshot);
2421
+ } finally {
2422
+ this.#loops.delete(runId);
2423
+ }
2424
+ }
2425
+ /**
2426
+ * 取消进行中的 run(chatbot Stop 按钮等):触发该 run 的 AbortController,
2427
+ * run 以 cancelled(RUN_CANCELLED)终止;未找到活跃 run 返回 false。
2428
+ * 取消在下一个中断点生效(LLM complete/stream;交互等待不强制中断)。
2429
+ */
2430
+ cancel(runId) {
2431
+ return this.#loops.get(runId)?.cancel(runId) ?? false;
2346
2432
  }
2347
2433
  };
2348
2434
  /**
@@ -1,5 +1,5 @@
1
1
  import { A as resolveArchiveLimits, C as messageOf, D as readResponseWithLimit, E as parseSkillPackManifest, M as unzipWithLimits, N as validateSkills, P as verifyManifest, T as parseSkillMarkdown, b as exportSkills, d as assertRemoteUrlAllowed, h as buildManifest, i as SKILL_MANIFEST_FILE, j as resolveInsideRoot, p as atomicWriteText, r as SKILLS_LOCKFILE, s as SKILL_PACK_FILE, u as WebSkillError, x as isValidSkillName } from "./dist-BQzncxXg.js";
2
- import { A as isNetworkAllowed, C as bridgeError, F as normalizeToolError, I as parseBridgeRequest, M as networkUrlHost, P as normalizeToolContent, c as FsArtifactStore, l as FsMemoryStore, o as CapabilityApproval } from "./dist-B77plHjw.js";
2
+ import { A as isNetworkAllowed, C as bridgeError, F as normalizeToolError, I as parseBridgeRequest, M as networkUrlHost, P as normalizeToolContent, c as FsArtifactStore, l as FsMemoryStore, o as CapabilityApproval } from "./dist-BXpDDZpR.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { unzipSync, zipSync } from "fflate";
5
5
  import { existsSync, promises, realpathSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  import { B as SkillManifest, I as SkillDocument, P as SkillCatalogEntry, c as LlmClient, u as LlmMessage, v as UiBridge, w as FileSystemProvider } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { Q as ScriptExecutor, dt as WebSkillRuntime, ft as WebSkillRuntimeDeps, q as RuntimeRun, tt as SkillStateGuard } from "./index-DfINBEOy.js";
3
- import { d as SkillManager } from "./index-CsDJvYGV.js";
4
- //#region ../governance/dist/index.d.ts
2
+ import { Q as ScriptExecutor, dt as WebSkillRuntime, ft as WebSkillRuntimeDeps, q as RuntimeRun, tt as SkillStateGuard } from "./index-DJOha4b6.js";
3
+ import { d as SkillManager } from "./index-DRlYzdr2.js";
4
+ //#region ../governance/dist/documentSource-9dhqKIVQ.d.ts
5
5
  //#region src/types.d.ts
6
6
  type CandidateStatus = 'draft' | 'pending-review' | 'approved' | 'published' | 'rejected';
7
7
  type CandidateSource = 'runtime-miss' | 'document' | 'manual';
@@ -60,32 +60,6 @@ interface SkillVersion {
60
60
  }
61
61
  type SkillState = 'active' | 'quarantined' | 'deprecated' | 'disabled';
62
62
  //#endregion
63
- //#region src/candidate/candidateNormalizer.d.ts
64
- /** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
65
- declare function parseJsonObject(raw: string): Record<string, unknown>;
66
- /** 小写连字符化、≤64、过 isValidSkillName */
67
- declare function sanitizeCandidateName(raw: string): string;
68
- /**
69
- * 文件归一:补 SKILL.md;路径含 `..` / 以 `/` 开头 / 含 `\` → CANDIDATE_INVALID;
70
- * scripts/ 下必须是 .ts/.js。
71
- */
72
- declare function normalizeCandidateFiles(files: Array<{
73
- path: string;
74
- content: string;
75
- }>, name: string, description: string): CandidateFile[];
76
- /** 含脚本且 LLM 自报 low → 强制 medium 并追加"必须人工审批"原因 */
77
- declare function normalizeRisk(declared: unknown, files: CandidateFile[], reasons: string[]): {
78
- risk: CandidateRisk;
79
- reasons: string[];
80
- };
81
- /** 不信任归一化管线全链路;状态恒为 draft */
82
- declare function normalizeCandidate(input: {
83
- raw: Record<string, unknown>;
84
- source: CandidateSource;
85
- now?: () => string;
86
- createId?: () => string;
87
- }): CandidateSkill;
88
- //#endregion
89
63
  //#region src/candidate/candidateValidator.d.ts
90
64
  /** 候选校验:缺 SKILL.md / 非法扩展名 → CANDIDATE_INVALID */
91
65
  declare function validateCandidate(candidate: CandidateSkill): void;
@@ -123,25 +97,6 @@ declare class LlmCandidateGenerator {
123
97
  }): Promise<CandidateSkill>;
124
98
  }
125
99
  //#endregion
126
- //#region src/approval/policies.d.ts
127
- interface ApprovalDecision {
128
- needsHuman: boolean;
129
- reason: string;
130
- }
131
- interface ApprovalPolicy {
132
- evaluate(candidate: CandidateSkill): ApprovalDecision;
133
- }
134
- /** 默认策略:任何候选都必须人工审批 */
135
- declare class AlwaysHumanApprovalPolicy implements ApprovalPolicy {
136
- evaluate(candidate: CandidateSkill): ApprovalDecision;
137
- }
138
- /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
139
- declare class CompositeApprovalPolicy implements ApprovalPolicy {
140
- #private;
141
- constructor(rules: Array<(candidate: CandidateSkill) => ApprovalDecision | undefined>, fallback?: ApprovalPolicy);
142
- evaluate(candidate: CandidateSkill): ApprovalDecision;
143
- }
144
- //#endregion
145
100
  //#region src/versioning/skillVersionStore.d.ts
146
101
  /** 版本存储:manifest 快照 + parentVersionId 链;回滚 = 追加新版本(谱系不断)。
147
102
  * 保留策略:maxArchivesPerSkill(默认 5)超出时清理最旧版本(json + zip 归档一并删除)。 */
@@ -173,38 +128,6 @@ declare class SkillVersionStore {
173
128
  }): Promise<SkillVersion>;
174
129
  }
175
130
  //#endregion
176
- //#region src/approval/approvalWorkflow.d.ts
177
- /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
178
- declare class ApprovalWorkflow {
179
- #private;
180
- constructor(deps: {
181
- policy: ApprovalPolicy;
182
- audit: AuditLog;
183
- store: CandidateStore;
184
- skillManager: SkillManager;
185
- versions: SkillVersionStore;
186
- fs?: FileSystemProvider;
187
- });
188
- /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
189
- review(candidateId: string, input: {
190
- actor: string;
191
- uiBridge?: UiBridge;
192
- }): Promise<CandidateSkill>;
193
- /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
194
- publish(candidateId: string, input: {
195
- actor: string;
196
- }): Promise<SkillManifest>;
197
- /**
198
- * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
199
- * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
200
- * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
201
- */
202
- applyRollback(skillName: string, versionId: string, input: {
203
- actor: string;
204
- reason?: string;
205
- }): Promise<SkillManifest>;
206
- }
207
- //#endregion
208
131
  //#region src/audit/fsAuditLog.d.ts
209
132
  interface AuditChainVerification {
210
133
  ok: boolean;
@@ -365,18 +288,6 @@ declare class EvaluationRunner {
365
288
  run(tasks: EvaluationTask[]): Promise<EvaluationReport>;
366
289
  }
367
290
  //#endregion
368
- //#region src/evaluation/evaluationRuntime.d.ts
369
- /**
370
- * 治理评估专用 runtime 装配(不可信技能试用路径):
371
- * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
372
- * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
373
- * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
374
- * 非安全边界;envWhitelist 同样适用于该执行器)。
375
- */
376
- declare function createEvaluationRuntime(deps: WebSkillRuntimeDeps & {
377
- executor?: ScriptExecutor;
378
- }): WebSkillRuntime;
379
- //#endregion
380
291
  //#region src/evaluation/testSuggestion.d.ts
381
292
  /** 失败 trace → 回归评估任务建议(prompt 复现 + expected 错误模式) */
382
293
  declare function suggestFromFailedRun(run: RuntimeRun): EvaluationTask;
@@ -448,6 +359,96 @@ interface SourceDocument {
448
359
  /** 读文档 + sha256 hash(变更检测用) */
449
360
  declare function readDocument(fs: FileSystemProvider, path: string): Promise<SourceDocument>;
450
361
  //#endregion
362
+ //#region ../governance/dist/index.d.ts
363
+ //#region src/candidate/candidateNormalizer.d.ts
364
+ /** 剥 markdown fence 与 <think> 块、截取首尾 {};非对象 → CANDIDATE_INVALID */
365
+ declare function parseJsonObject(raw: string): Record<string, unknown>;
366
+ /** 小写连字符化、≤64、过 isValidSkillName */
367
+ declare function sanitizeCandidateName(raw: string): string;
368
+ /**
369
+ * 文件归一:补 SKILL.md;路径含 `..` / 以 `/` 开头 / 含 `\` → CANDIDATE_INVALID;
370
+ * scripts/ 下必须是 .ts/.js。
371
+ */
372
+ declare function normalizeCandidateFiles(files: Array<{
373
+ path: string;
374
+ content: string;
375
+ }>, name: string, description: string): CandidateFile[];
376
+ /** 含脚本且 LLM 自报 low → 强制 medium 并追加"必须人工审批"原因 */
377
+ declare function normalizeRisk(declared: unknown, files: CandidateFile[], reasons: string[]): {
378
+ risk: CandidateRisk;
379
+ reasons: string[];
380
+ };
381
+ /** 不信任归一化管线全链路;状态恒为 draft */
382
+ declare function normalizeCandidate(input: {
383
+ raw: Record<string, unknown>;
384
+ source: CandidateSource;
385
+ now?: () => string;
386
+ createId?: () => string;
387
+ }): CandidateSkill;
388
+ //#endregion
389
+ //#region src/approval/policies.d.ts
390
+ interface ApprovalDecision {
391
+ needsHuman: boolean;
392
+ reason: string;
393
+ }
394
+ interface ApprovalPolicy {
395
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
396
+ }
397
+ /** 默认策略:任何候选都必须人工审批 */
398
+ declare class AlwaysHumanApprovalPolicy implements ApprovalPolicy {
399
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
400
+ }
401
+ /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
402
+ declare class CompositeApprovalPolicy implements ApprovalPolicy {
403
+ #private;
404
+ constructor(rules: Array<(candidate: CandidateSkill) => ApprovalDecision | undefined>, fallback?: ApprovalPolicy);
405
+ evaluate(candidate: CandidateSkill): ApprovalDecision;
406
+ }
407
+ //#endregion
408
+ //#region src/approval/approvalWorkflow.d.ts
409
+ /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
410
+ declare class ApprovalWorkflow {
411
+ #private;
412
+ constructor(deps: {
413
+ policy: ApprovalPolicy;
414
+ audit: AuditLog;
415
+ store: CandidateStore;
416
+ skillManager: SkillManager;
417
+ versions: SkillVersionStore;
418
+ fs?: FileSystemProvider;
419
+ });
420
+ /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
421
+ review(candidateId: string, input: {
422
+ actor: string;
423
+ uiBridge?: UiBridge;
424
+ }): Promise<CandidateSkill>;
425
+ /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
426
+ publish(candidateId: string, input: {
427
+ actor: string;
428
+ }): Promise<SkillManifest>;
429
+ /**
430
+ * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
431
+ * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
432
+ * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
433
+ */
434
+ applyRollback(skillName: string, versionId: string, input: {
435
+ actor: string;
436
+ reason?: string;
437
+ }): Promise<SkillManifest>;
438
+ }
439
+ //#endregion
440
+ //#region src/evaluation/evaluationRuntime.d.ts
441
+ /**
442
+ * 治理评估专用 runtime 装配(不可信技能试用路径):
443
+ * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
444
+ * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
445
+ * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
446
+ * 非安全边界;envWhitelist 同样适用于该执行器)。
447
+ */
448
+ declare function createEvaluationRuntime(deps: WebSkillRuntimeDeps & {
449
+ executor?: ScriptExecutor;
450
+ }): WebSkillRuntime;
451
+ //#endregion
451
452
  //#region src/documents/documentSkillExtractor.d.ts
452
453
  /** 文档 → LLM 抽取 → 完整防御管线 → draft 候选(source: document) */
453
454
  declare class DocumentSkillExtractor {
@@ -1,12 +1,11 @@
1
1
  import { C as messageOf, M as unzipWithLimits, N as validateSkills, f as assertSafePathSegment, j as resolveInsideRoot, u as WebSkillError, x as isValidSkillName } from "./dist-BQzncxXg.js";
2
- import { S as WebSkillRuntime } from "./dist-B77plHjw.js";
3
- import { i as NodeFS, s as ProcessSandboxExecutor, u as exportArchive } from "./dist-Chk8iB-E.js";
2
+ import { S as WebSkillRuntime } from "./dist-BXpDDZpR.js";
3
+ import { i as NodeFS, s as ProcessSandboxExecutor, u as exportArchive } from "./dist-DWFDb1Ww.js";
4
4
  import path from "node:path";
5
5
  import { tmpdir } from "node:os";
6
6
  import { mkdtemp } from "node:fs/promises";
7
- import { createHash } from "node:crypto";
8
7
 
9
- //#region ../governance/dist/index.js
8
+ //#region ../governance/dist/documentSource-C6gq6pbk.js
10
9
  const invalid = (message, details) => {
11
10
  throw new WebSkillError("CANDIDATE_INVALID", message, details);
12
11
  };
@@ -217,180 +216,12 @@ var LlmCandidateGenerator = class {
217
216
  return candidate;
218
217
  }
219
218
  };
220
- /** 默认策略:任何候选都必须人工审批 */
221
- var AlwaysHumanApprovalPolicy = class {
222
- evaluate(candidate) {
223
- return {
224
- needsHuman: true,
225
- reason: `Candidate "${candidate.name}" requires human approval (risk: ${candidate.risk})`
226
- };
227
- }
228
- };
229
- /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
230
- var CompositeApprovalPolicy = class {
231
- #rules;
232
- #fallback;
233
- constructor(rules, fallback) {
234
- this.#rules = rules;
235
- this.#fallback = fallback ?? new AlwaysHumanApprovalPolicy();
236
- }
237
- evaluate(candidate) {
238
- for (const rule of this.#rules) {
239
- const decision = rule(candidate);
240
- if (decision) return decision;
241
- }
242
- return this.#fallback.evaluate(candidate);
243
- }
244
- };
245
- /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
246
- var ApprovalWorkflow = class {
247
- #policy;
248
- #audit;
249
- #store;
250
- #skillManager;
251
- #versions;
252
- #fs;
253
- constructor(deps) {
254
- this.#policy = deps.policy;
255
- this.#audit = deps.audit;
256
- this.#store = deps.store;
257
- this.#skillManager = deps.skillManager;
258
- this.#versions = deps.versions;
259
- this.#fs = deps.fs ?? new NodeFS();
260
- }
261
- /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
262
- async review(candidateId, input) {
263
- const candidate = await this.#store.get(candidateId);
264
- if (candidate.status !== "draft" && candidate.status !== "pending-review") throw new WebSkillError("GOVERNANCE_FAILED", `Candidate "${candidateId}" cannot be reviewed from status "${candidate.status}"`);
265
- const decision = this.#policy.evaluate(candidate);
266
- let approved;
267
- if (decision.needsHuman) {
268
- if (!input.uiBridge) {
269
- await this.#store.updateStatus(candidateId, "pending-review");
270
- throw new WebSkillError("APPROVAL_REQUIRED", `Candidate "${candidate.name}" requires human approval: ${decision.reason}`);
271
- }
272
- await this.#store.updateStatus(candidateId, "pending-review");
273
- const response = await input.uiBridge.request({
274
- type: "confirm",
275
- id: `approval-${candidateId}`,
276
- message: `Approve candidate "${candidate.name}" (risk: ${candidate.risk})? ${decision.reason}`,
277
- defaultValue: false
278
- });
279
- approved = response.cancelled !== true && response.value === true;
280
- } else approved = true;
281
- const updated = await this.#store.updateStatus(candidateId, approved ? "approved" : "rejected");
282
- await this.#audit.append({
283
- type: "candidate.reviewed",
284
- target: candidateId,
285
- actor: input.actor,
286
- data: {
287
- approved,
288
- reason: decision.reason
289
- }
290
- });
291
- return updated;
292
- }
293
- /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
294
- async publish(candidateId, input) {
295
- const candidate = await this.#store.get(candidateId);
296
- if (candidate.status !== "approved") throw new WebSkillError("APPROVAL_REQUIRED", `Candidate "${candidate.name}" must be approved before publishing (status: ${candidate.status})`);
297
- const stagingRoot = (await mkdtemp(path.join(tmpdir(), "webskill-candidate-"))).split(path.sep).join("/");
298
- try {
299
- const skillDir = `${stagingRoot}/${candidate.name}`;
300
- for (const file of candidate.files) await this.#fs.writeText(resolveInsideRoot(skillDir, file.path), file.content);
301
- const report = await validateSkills(this.#fs, [stagingRoot]);
302
- if (!report.ok) {
303
- const errors = report.issues.filter((i) => i.severity === "error");
304
- throw new WebSkillError("GOVERNANCE_FAILED", `Candidate "${candidate.name}" failed validation: ${errors.map((i) => i.message).join("; ")}`, errors);
305
- }
306
- const manifest = await this.#skillManager.install({
307
- type: "local",
308
- path: skillDir
309
- });
310
- const archiveOut = `${stagingRoot}/version-archive.zip`;
311
- await exportArchive(this.#fs, `${this.#skillManager.managedRoot}/${candidate.name}`, {
312
- format: "zip",
313
- outPath: archiveOut
314
- });
315
- await this.#versions.add(candidate.name, {
316
- reason: `Publish candidate ${candidateId}`,
317
- manifest,
318
- archive: await this.#fs.readBinary(archiveOut)
319
- });
320
- await this.#store.updateStatus(candidateId, "published");
321
- await this.#audit.append({
322
- type: "skill.published",
323
- target: candidate.name,
324
- actor: input.actor,
325
- data: {
326
- candidateId,
327
- digest: manifest.integrity.digest
328
- }
329
- });
330
- return manifest;
331
- } catch (e) {
332
- if (e instanceof WebSkillError) throw e;
333
- throw new WebSkillError("GOVERNANCE_FAILED", `Failed to publish candidate "${candidateId}": ${messageOf(e)}`, e);
334
- } finally {
335
- try {
336
- await this.#fs.remove(stagingRoot, { recursive: true });
337
- } catch {}
338
- }
339
- }
340
- /**
341
- * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
342
- * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
343
- * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
344
- */
345
- async applyRollback(skillName, versionId, input) {
346
- assertSafePathSegment(skillName, "skill name");
347
- assertSafePathSegment(versionId, "version id");
348
- const version = await this.#versions.get(skillName, versionId);
349
- const archive = await this.#versions.readArchive(skillName, versionId);
350
- const stagingRoot = (await mkdtemp(path.join(tmpdir(), "webskill-rollback-"))).split(path.sep).join("/");
351
- try {
352
- const skillDir = `${stagingRoot}/${skillName}`;
353
- for (const [rel, content] of await unzipWithLimits(archive)) {
354
- if (rel.endsWith("/")) continue;
355
- await this.#fs.writeBinary(resolveInsideRoot(skillDir, rel), content);
356
- }
357
- const report = await validateSkills(this.#fs, [stagingRoot]);
358
- if (!report.ok) {
359
- const errors = report.issues.filter((i) => i.severity === "error");
360
- throw new WebSkillError("GOVERNANCE_FAILED", `Rollback archive of "${skillName}" failed validation: ${errors.map((i) => i.message).join("; ")}`, errors);
361
- }
362
- const manifest = await this.#skillManager.install({
363
- type: "local",
364
- path: skillDir
365
- });
366
- if (manifest.integrity.digest !== version.manifest.integrity.digest) throw new WebSkillError("GOVERNANCE_FAILED", `Rollback of "${skillName}" to version "${versionId}" produced a digest mismatch: expected ${version.manifest.integrity.digest}, got ${manifest.integrity.digest}`);
367
- await this.#versions.add(skillName, {
368
- reason: input.reason ?? `Rollback to version ${versionId}`,
369
- manifest,
370
- archive
371
- });
372
- await this.#audit.append({
373
- type: "skill.rolled_back",
374
- target: skillName,
375
- actor: input.actor,
376
- data: {
377
- targetVersionId: versionId,
378
- reason: input.reason
379
- }
380
- });
381
- return manifest;
382
- } catch (e) {
383
- if (e instanceof WebSkillError) throw e;
384
- throw new WebSkillError("GOVERNANCE_FAILED", `Failed to roll back "${skillName}" to version "${versionId}": ${messageOf(e)}`, e);
385
- } finally {
386
- try {
387
- await this.#fs.remove(stagingRoot, { recursive: true });
388
- } catch {}
389
- }
390
- }
391
- };
392
219
  const fileOf$1 = (root) => `${root}/.webskill/audit.jsonl`;
393
- const sha256Hex = (text) => createHash("sha256").update(text, "utf8").digest("hex");
220
+ /** 环境无关 sha256(WebCrypto;Node ≥17 与浏览器均有 globalThis.crypto.subtle) */
221
+ const sha256Hex$1 = async (text) => {
222
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
223
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
224
+ };
394
225
  /** 链字段之外的规范化事件载荷(hash 计算输入) */
395
226
  function canonical(event) {
396
227
  return JSON.stringify({
@@ -432,7 +263,7 @@ var FsAuditLog = class {
432
263
  if (lines.length === 0) return "GENESIS";
433
264
  try {
434
265
  const last = JSON.parse(lines.at(-1));
435
- return last.hash ?? sha256Hex(canonical(last));
266
+ return last.hash ?? await sha256Hex$1(canonical(last));
436
267
  } catch (e) {
437
268
  throw new WebSkillError("GOVERNANCE_FAILED", `Audit log tail line at ${path} is corrupted; refusing to append (the chain must not silently restart)`, e);
438
269
  }
@@ -448,7 +279,7 @@ var FsAuditLog = class {
448
279
  ...event.data !== void 0 ? { data: event.data } : {},
449
280
  prevHash
450
281
  };
451
- full.hash = sha256Hex(canonical(full));
282
+ full.hash = await sha256Hex$1(canonical(full));
452
283
  await this.#fs.appendText(fileOf$1(this.#root), `${JSON.stringify(full)}\n`);
453
284
  this.#lastHash = full.hash;
454
285
  return full;
@@ -495,7 +326,7 @@ var FsAuditLog = class {
495
326
  brokenAt: i,
496
327
  reason: "prevHash link mismatch (events may have been removed or reordered)"
497
328
  };
498
- const expectedHash = sha256Hex(canonical(event));
329
+ const expectedHash = await sha256Hex$1(canonical(event));
499
330
  if (event.hash !== expectedHash) return {
500
331
  ok: false,
501
332
  brokenAt: i,
@@ -871,19 +702,6 @@ var EvaluationRunner = class {
871
702
  };
872
703
  }
873
704
  };
874
- /**
875
- * 治理评估专用 runtime 装配(不可信技能试用路径):
876
- * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
877
- * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
878
- * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
879
- * 非安全边界;envWhitelist 同样适用于该执行器)。
880
- */
881
- function createEvaluationRuntime(deps) {
882
- return new WebSkillRuntime({
883
- ...deps,
884
- executor: deps.executor ?? new ProcessSandboxExecutor(deps.fs)
885
- });
886
- }
887
705
  /** 失败 trace → 回归评估任务建议(prompt 复现 + expected 错误模式) */
888
706
  function suggestFromFailedRun(run) {
889
707
  const errorPatterns = run.trace.filter((e) => e.type === "tool.failed" || e.type === "run.failed").map((e) => String(e.data?.["code"] ?? e.message ?? "")).filter(Boolean);
@@ -977,15 +795,208 @@ var DependencyGraph = class DependencyGraph {
977
795
  return out.sort();
978
796
  }
979
797
  };
798
+ /** 环境无关 sha256(WebCrypto;Node ≥17 与浏览器均有 globalThis.crypto.subtle) */
799
+ async function sha256Hex(text) {
800
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(text));
801
+ return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
802
+ }
980
803
  /** 读文档 + sha256 hash(变更检测用) */
981
804
  async function readDocument(fs, path) {
982
805
  const content = await fs.readText(path);
983
806
  return {
984
807
  path,
985
808
  content,
986
- hash: createHash("sha256").update(content).digest("hex")
809
+ hash: await sha256Hex(content)
987
810
  };
988
811
  }
812
+
813
+ //#endregion
814
+ //#region ../governance/dist/index.js
815
+ /** 默认策略:任何候选都必须人工审批 */
816
+ var AlwaysHumanApprovalPolicy = class {
817
+ evaluate(candidate) {
818
+ return {
819
+ needsHuman: true,
820
+ reason: `Candidate "${candidate.name}" requires human approval (risk: ${candidate.risk})`
821
+ };
822
+ }
823
+ };
824
+ /** 规则组合策略:首个命中的规则胜出,全部未命中走 fallback(默认 AlwaysHuman) */
825
+ var CompositeApprovalPolicy = class {
826
+ #rules;
827
+ #fallback;
828
+ constructor(rules, fallback) {
829
+ this.#rules = rules;
830
+ this.#fallback = fallback ?? new AlwaysHumanApprovalPolicy();
831
+ }
832
+ evaluate(candidate) {
833
+ for (const rule of this.#rules) {
834
+ const decision = rule(candidate);
835
+ if (decision) return decision;
836
+ }
837
+ return this.#fallback.evaluate(candidate);
838
+ }
839
+ };
840
+ /** 审批工作流:review(UiBridge confirm 真实接线)/ publish(校验→安装→版本→审计) */
841
+ var ApprovalWorkflow = class {
842
+ #policy;
843
+ #audit;
844
+ #store;
845
+ #skillManager;
846
+ #versions;
847
+ #fs;
848
+ constructor(deps) {
849
+ this.#policy = deps.policy;
850
+ this.#audit = deps.audit;
851
+ this.#store = deps.store;
852
+ this.#skillManager = deps.skillManager;
853
+ this.#versions = deps.versions;
854
+ this.#fs = deps.fs ?? new NodeFS();
855
+ }
856
+ /** 策略评估;needs-human 时经 UiBridge confirm 真实询问,按应答迁移状态 */
857
+ async review(candidateId, input) {
858
+ const candidate = await this.#store.get(candidateId);
859
+ if (candidate.status !== "draft" && candidate.status !== "pending-review") throw new WebSkillError("GOVERNANCE_FAILED", `Candidate "${candidateId}" cannot be reviewed from status "${candidate.status}"`);
860
+ const decision = this.#policy.evaluate(candidate);
861
+ let approved;
862
+ if (decision.needsHuman) {
863
+ if (!input.uiBridge) {
864
+ await this.#store.updateStatus(candidateId, "pending-review");
865
+ throw new WebSkillError("APPROVAL_REQUIRED", `Candidate "${candidate.name}" requires human approval: ${decision.reason}`);
866
+ }
867
+ await this.#store.updateStatus(candidateId, "pending-review");
868
+ const response = await input.uiBridge.request({
869
+ type: "confirm",
870
+ id: `approval-${candidateId}`,
871
+ message: `Approve candidate "${candidate.name}" (risk: ${candidate.risk})? ${decision.reason}`,
872
+ defaultValue: false
873
+ });
874
+ approved = response.cancelled !== true && response.value === true;
875
+ } else approved = true;
876
+ const updated = await this.#store.updateStatus(candidateId, approved ? "approved" : "rejected");
877
+ await this.#audit.append({
878
+ type: "candidate.reviewed",
879
+ target: candidateId,
880
+ actor: input.actor,
881
+ data: {
882
+ approved,
883
+ reason: decision.reason
884
+ }
885
+ });
886
+ return updated;
887
+ }
888
+ /** publish 全链路:approved 前置 → 写出 staging → validateSkills → install → 版本 → 审计 */
889
+ async publish(candidateId, input) {
890
+ const candidate = await this.#store.get(candidateId);
891
+ if (candidate.status !== "approved") throw new WebSkillError("APPROVAL_REQUIRED", `Candidate "${candidate.name}" must be approved before publishing (status: ${candidate.status})`);
892
+ const stagingRoot = (await mkdtemp(path.join(tmpdir(), "webskill-candidate-"))).split(path.sep).join("/");
893
+ try {
894
+ const skillDir = `${stagingRoot}/${candidate.name}`;
895
+ for (const file of candidate.files) await this.#fs.writeText(resolveInsideRoot(skillDir, file.path), file.content);
896
+ const report = await validateSkills(this.#fs, [stagingRoot]);
897
+ if (!report.ok) {
898
+ const errors = report.issues.filter((i) => i.severity === "error");
899
+ throw new WebSkillError("GOVERNANCE_FAILED", `Candidate "${candidate.name}" failed validation: ${errors.map((i) => i.message).join("; ")}`, errors);
900
+ }
901
+ const manifest = await this.#skillManager.install({
902
+ type: "local",
903
+ path: skillDir
904
+ });
905
+ const archiveOut = `${stagingRoot}/version-archive.zip`;
906
+ await exportArchive(this.#fs, `${this.#skillManager.managedRoot}/${candidate.name}`, {
907
+ format: "zip",
908
+ outPath: archiveOut
909
+ });
910
+ await this.#versions.add(candidate.name, {
911
+ reason: `Publish candidate ${candidateId}`,
912
+ manifest,
913
+ archive: await this.#fs.readBinary(archiveOut)
914
+ });
915
+ await this.#store.updateStatus(candidateId, "published");
916
+ await this.#audit.append({
917
+ type: "skill.published",
918
+ target: candidate.name,
919
+ actor: input.actor,
920
+ data: {
921
+ candidateId,
922
+ digest: manifest.integrity.digest
923
+ }
924
+ });
925
+ return manifest;
926
+ } catch (e) {
927
+ if (e instanceof WebSkillError) throw e;
928
+ throw new WebSkillError("GOVERNANCE_FAILED", `Failed to publish candidate "${candidateId}": ${messageOf(e)}`, e);
929
+ } finally {
930
+ try {
931
+ await this.#fs.remove(stagingRoot, { recursive: true });
932
+ } catch {}
933
+ }
934
+ }
935
+ /**
936
+ * 真实回滚(受审批保护:仅经显式 actor 调用并全程审计):
937
+ * 版本归档解包 → staging 校验 → 原子安装(复用安装管线 swap)→ 追加新版本 + 审计。
938
+ * RepairPlanner 的 rollback 选项(targetVersionId)经本方法执行。
939
+ */
940
+ async applyRollback(skillName, versionId, input) {
941
+ assertSafePathSegment(skillName, "skill name");
942
+ assertSafePathSegment(versionId, "version id");
943
+ const version = await this.#versions.get(skillName, versionId);
944
+ const archive = await this.#versions.readArchive(skillName, versionId);
945
+ const stagingRoot = (await mkdtemp(path.join(tmpdir(), "webskill-rollback-"))).split(path.sep).join("/");
946
+ try {
947
+ const skillDir = `${stagingRoot}/${skillName}`;
948
+ for (const [rel, content] of await unzipWithLimits(archive)) {
949
+ if (rel.endsWith("/")) continue;
950
+ await this.#fs.writeBinary(resolveInsideRoot(skillDir, rel), content);
951
+ }
952
+ const report = await validateSkills(this.#fs, [stagingRoot]);
953
+ if (!report.ok) {
954
+ const errors = report.issues.filter((i) => i.severity === "error");
955
+ throw new WebSkillError("GOVERNANCE_FAILED", `Rollback archive of "${skillName}" failed validation: ${errors.map((i) => i.message).join("; ")}`, errors);
956
+ }
957
+ const manifest = await this.#skillManager.install({
958
+ type: "local",
959
+ path: skillDir
960
+ });
961
+ if (manifest.integrity.digest !== version.manifest.integrity.digest) throw new WebSkillError("GOVERNANCE_FAILED", `Rollback of "${skillName}" to version "${versionId}" produced a digest mismatch: expected ${version.manifest.integrity.digest}, got ${manifest.integrity.digest}`);
962
+ await this.#versions.add(skillName, {
963
+ reason: input.reason ?? `Rollback to version ${versionId}`,
964
+ manifest,
965
+ archive
966
+ });
967
+ await this.#audit.append({
968
+ type: "skill.rolled_back",
969
+ target: skillName,
970
+ actor: input.actor,
971
+ data: {
972
+ targetVersionId: versionId,
973
+ reason: input.reason
974
+ }
975
+ });
976
+ return manifest;
977
+ } catch (e) {
978
+ if (e instanceof WebSkillError) throw e;
979
+ throw new WebSkillError("GOVERNANCE_FAILED", `Failed to roll back "${skillName}" to version "${versionId}": ${messageOf(e)}`, e);
980
+ } finally {
981
+ try {
982
+ await this.#fs.remove(stagingRoot, { recursive: true });
983
+ } catch {}
984
+ }
985
+ }
986
+ };
987
+ /**
988
+ * 治理评估专用 runtime 装配(不可信技能试用路径):
989
+ * 默认注入 ProcessSandboxExecutor(fork + --permission 真实进程隔离;子进程
990
+ * env 默认清空防密钥泄露,需透传时经 ProcessSandboxOptions.envWhitelist 显式放行)。
991
+ * 可配置 executor 切回 SandboxedScriptExecutor(worker_threads 能力面收敛形态,
992
+ * 非安全边界;envWhitelist 同样适用于该执行器)。
993
+ */
994
+ function createEvaluationRuntime(deps) {
995
+ return new WebSkillRuntime({
996
+ ...deps,
997
+ executor: deps.executor ?? new ProcessSandboxExecutor(deps.fs)
998
+ });
999
+ }
989
1000
  const EXTRACT_PROMPT = (doc, nameHint) => [
990
1001
  "Extract an executable skill from the following document as STRICT JSON only.",
991
1002
  "Schema: {\"name\": string, \"description\": string, \"risk\": \"low\"|\"medium\"|\"high\",",
@@ -738,6 +738,12 @@ interface AgentLoopDeps {
738
738
  declare class AgentLoop {
739
739
  #private;
740
740
  constructor(deps: AgentLoopDeps, config?: AgentLoopConfig);
741
+ /**
742
+ * 取消进行中的 run:触发该 run 的 AbortController(与 totalTimeout 硬期限同一通道),
743
+ * run 以 cancelled(RUN_CANCELLED)终止;未找到(已终态或不属于本实例)返回 false。
744
+ * 取消在下一个中断点生效(LLM complete/stream 调用;交互等待不强制中断)。
745
+ */
746
+ cancel(runId: string): boolean;
741
747
  run(input: {
742
748
  sessionId: string;
743
749
  userPrompt: string;
@@ -835,6 +841,12 @@ declare class WebSkillRuntime {
835
841
  * @experimental
836
842
  */
837
843
  resumeRun(runId: string): Promise<RunResult>;
844
+ /**
845
+ * 取消进行中的 run(chatbot Stop 按钮等):触发该 run 的 AbortController,
846
+ * run 以 cancelled(RUN_CANCELLED)终止;未找到活跃 run 返回 false。
847
+ * 取消在下一个中断点生效(LLM complete/stream;交互等待不强制中断)。
848
+ */
849
+ cancel(runId: string): boolean;
838
850
  }
839
851
  //#endregion
840
852
  export { SerializingMemoryStore as $, LifecycleHook as A, toVercelToolSpecs as At, RUN_SNAPSHOT_SCHEMA_VERSION as B, FullDisclosureRouter as C, normalizeErrorCode as Ct, HookRunnerOptions as D, resolveToolName as Dt, HookRunner as E, parseBridgeRequest as Et, OpenAiCompatibleClientConfig as F, RunTerminationReason as G, RunResult as H, ProgressiveRouter as I, RuntimeSession as J, RuntimePhase as K, READ_SKILL_FILE_INPUT_SCHEMA as L, LifecycleListener as M, NetworkPolicy as N, InstalledSkillManifest as O, schemaToForm as Ot, OpenAiCompatibleClient as P, ScriptExecutor as Q, READ_SKILL_FILE_TOOL as R, FsRunSnapshotStore as S, networkUrlHost as St, GoogleGenAiClientConfig as T, normalizeToolError as Tt, RunSnapshot as U, RouteResult as V, RunSnapshotStore as W, SchemaInferer as X, RuntimeSessionHandle as Y, ScriptExecutionContext as Z, EventBus as _, extractChartSpec as _t, AgentLoopConfig as a, TraceClock as at, FsArtifactStore as b, isNetworkAllowed as bt, AnthropicClientConfig as c, TraceRecorder as ct, BridgeCapabilities as d, WebSkillRuntime as dt, SkillRouter as et, BridgeCapability as f, WebSkillRuntimeDeps as ft, CapabilityMode as g, createWebSkillApi as gt, CapabilityApproval as h, createScriptContext as ht, AgentLoop as i, ToolResult as it, LifecycleHookContext as j, LifecycleEvent as k, toLlmToolSpec as kt, ApprovalDecision as l, VercelToolSpec as lt, BridgeResponse as m, buildRenderResult as mt, ASK_USER_TOOL as n, ToolDefinition as nt, AgentLoopDeps as o, TraceEvent as ot, BridgeRequest as p, bridgeError as pt, RuntimeRun as q, ASK_USER_TOOL_NAME as r, ToolResolution as rt, AnthropicClient as s, TraceEventType as st, ASK_USER_INPUT_SCHEMA as t, SkillStateGuard as tt, ApprovalScope as u, WebSkillApi as ut, ExternalSkillProvider as v, fromVercelResult as vt, GoogleGenAiClient as w, normalizeToolContent as wt, FsMemoryStore as x, mergeCatalogEntries as xt, ExternalToolSource as y, fromVercelStreamPart as yt, READ_SKILL_FILE_TOOL_NAME as z };
@@ -1,5 +1,5 @@
1
1
  import { B as SkillManifest, C as FileStat, G as SkillsLockfile, L as SkillInstallSource, T as JsonSchema, _ as RenderResultRequest, o as InteractionRequest, q as VerifyResult, s as InteractionResponse, v as UiBridge, w as FileSystemProvider, y as ArchiveLimits } from "./types-CKm5G_eQ-krKWW8WV.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-DfINBEOy.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-DJOha4b6.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
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { $ as buildCatalog, A as SKILL_NAME_MAX_LENGTH, B as SkillManifest, C as FileStat, D as RemoteUrlPolicy, E as MemoryFS, F as SkillDiscovery, G as SkillsLockfile, H as SkillPackManifest, I as SkillDocument, J as WebSkillError, K as ValidationReport, L as SkillInstallSource, M as SKILL_PACK_FILE, N as SkillCatalog, O as SKILLS_LOCKFILE, P as SkillCatalogEntry, Q as atomicWriteText, R as SkillIssue, S as DiscoveryResult, T as JsonSchema, U as SkillReader, V as SkillMetadata, W as SkillSource, X as assertRemoteUrlAllowed, Y as WebSkillErrorCode, Z as assertSafePathSegment, _ as RenderResultRequest, _t as unzipWithLimits, a as InteractionPolicy, at as exportSkills, b as CatalogRenderer, bt as xmlRenderer, c as LlmClient, ct as messageOf, d as LlmResponse, dt as parseSkillPackManifest, et as buildManifest, f as LlmStreamEvent, ft as readResponseWithLimit, g as RenderBlock, gt as resolveInsideRoot, h as MemoryStore, ht as resolveArchiveLimits, i as FormField, it as escapeXml, j as SKILL_NAME_PATTERN, k as SKILL_MANIFEST_FILE, l as LlmCompleteInput, lt as normalizePath, m as LlmToolSpec, mt as renderCatalogJson, n as ArtifactStore, nt as checkSkillRules, o as InteractionRequest, ot as isValidSkillName, p as LlmToolCall, pt as renderAvailableSkillsXml, q as VerifyResult, r as ChartSpec, rt as computeDigest, s as InteractionResponse, st as jsonRenderer, t as Artifact, tt as checkDependencyCycles, u as LlmMessage, ut as parseSkillMarkdown, v as UiBridge, vt as validateSkills, w as FileSystemProvider, x as DEFAULT_ARCHIVE_LIMITS, y as ArchiveLimits, yt as verifyManifest, z as SkillLocation } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { $ as SerializingMemoryStore, A as LifecycleHook, At as toVercelToolSpecs, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as normalizeErrorCode, D as HookRunnerOptions, Dt as resolveToolName, E as HookRunner, Et as parseBridgeRequest, 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, Ot as schemaToForm, P as OpenAiCompatibleClient, Q as ScriptExecutor, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as networkUrlHost, T as GoogleGenAiClientConfig, Tt as normalizeToolError, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as SchemaInferer, Y as RuntimeSessionHandle, Z as ScriptExecutionContext, _ as EventBus, _t as extractChartSpec, a as AgentLoopConfig, at as TraceClock, b as FsArtifactStore, bt as isNetworkAllowed, c as AnthropicClientConfig, ct as TraceRecorder, d as BridgeCapabilities, dt as WebSkillRuntime, et as SkillRouter, f as BridgeCapability, ft as WebSkillRuntimeDeps, g as CapabilityMode, gt as createWebSkillApi, h as CapabilityApproval, ht as createScriptContext, i as AgentLoop, it as ToolResult, j as LifecycleHookContext, k as LifecycleEvent, kt as toLlmToolSpec, l as ApprovalDecision, lt as VercelToolSpec, m as BridgeResponse, mt as buildRenderResult, n as ASK_USER_TOOL, nt as ToolDefinition, o as AgentLoopDeps, ot as TraceEvent, p as BridgeRequest, pt as bridgeError, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as ToolResolution, s as AnthropicClient, st as TraceEventType, t as ASK_USER_INPUT_SCHEMA, tt as SkillStateGuard, u as ApprovalScope, ut as WebSkillApi, v as ExternalSkillProvider, vt as fromVercelResult, w as GoogleGenAiClient, wt as normalizeToolContent, x as FsMemoryStore, xt as mergeCatalogEntries, y as ExternalToolSource, yt as fromVercelStreamPart, z as READ_SKILL_FILE_TOOL_NAME } from "./index-DfINBEOy.js";
2
+ import { $ as SerializingMemoryStore, A as LifecycleHook, At as toVercelToolSpecs, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as normalizeErrorCode, D as HookRunnerOptions, Dt as resolveToolName, E as HookRunner, Et as parseBridgeRequest, 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, Ot as schemaToForm, P as OpenAiCompatibleClient, Q as ScriptExecutor, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as networkUrlHost, T as GoogleGenAiClientConfig, Tt as normalizeToolError, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as SchemaInferer, Y as RuntimeSessionHandle, Z as ScriptExecutionContext, _ as EventBus, _t as extractChartSpec, a as AgentLoopConfig, at as TraceClock, b as FsArtifactStore, bt as isNetworkAllowed, c as AnthropicClientConfig, ct as TraceRecorder, d as BridgeCapabilities, dt as WebSkillRuntime, et as SkillRouter, f as BridgeCapability, ft as WebSkillRuntimeDeps, g as CapabilityMode, gt as createWebSkillApi, h as CapabilityApproval, ht as createScriptContext, i as AgentLoop, it as ToolResult, j as LifecycleHookContext, k as LifecycleEvent, kt as toLlmToolSpec, l as ApprovalDecision, lt as VercelToolSpec, m as BridgeResponse, mt as buildRenderResult, n as ASK_USER_TOOL, nt as ToolDefinition, o as AgentLoopDeps, ot as TraceEvent, p as BridgeRequest, pt as bridgeError, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as ToolResolution, s as AnthropicClient, st as TraceEventType, t as ASK_USER_INPUT_SCHEMA, tt as SkillStateGuard, u as ApprovalScope, ut as WebSkillApi, v as ExternalSkillProvider, vt as fromVercelResult, w as GoogleGenAiClient, wt as normalizeToolContent, x as FsMemoryStore, xt as mergeCatalogEntries, y as ExternalToolSource, yt as fromVercelStreamPart, z as READ_SKILL_FILE_TOOL_NAME } from "./index-DJOha4b6.js";
3
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 ArchiveLimits, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, DEFAULT_ARCHIVE_LIMITS, 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 RemoteUrlPolicy, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, type RuntimeSessionHandle, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, SerializingMemoryStore, 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 SkillStateGuard, 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, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, messageOf, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, readResponseWithLimit, renderAvailableSkillsXml, renderCatalogJson, resolveArchiveLimits, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, unzipWithLimits, validateSkills, verifyManifest, xmlRenderer };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { A as resolveArchiveLimits, C as messageOf, D as readResponseWithLimit, E as parseSkillPackManifest, F as xmlRenderer, M as unzipWithLimits, N as validateSkills, O as renderAvailableSkillsXml, P as verifyManifest, S as jsonRenderer, T as parseSkillMarkdown, _ as checkSkillRules, a as SKILL_NAME_MAX_LENGTH, b as exportSkills, c as SkillDiscovery, d as assertRemoteUrlAllowed, f as assertSafePathSegment, g as checkDependencyCycles, h as buildManifest, i as SKILL_MANIFEST_FILE, j as resolveInsideRoot, k as renderCatalogJson, l as SkillReader, m as buildCatalog, n as MemoryFS, o as SKILL_NAME_PATTERN, p as atomicWriteText, r as SKILLS_LOCKFILE, s as SKILL_PACK_FILE, t as DEFAULT_ARCHIVE_LIMITS, u as WebSkillError, v as computeDigest, w as normalizePath, x as isValidSkillName, y as escapeXml } from "./dist-BQzncxXg.js";
2
- import { A as isNetworkAllowed, B as toVercelToolSpecs, C as bridgeError, D as extractChartSpec, E as createWebSkillApi, F as normalizeToolError, I as parseBridgeRequest, L as resolveToolName, M as networkUrlHost, N as normalizeErrorCode, O as fromVercelResult, P as normalizeToolContent, R as schemaToForm, S as WebSkillRuntime, T as createScriptContext, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as SerializingMemoryStore, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as mergeCatalogEntries, k as fromVercelStreamPart, 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 buildRenderResult, x as TraceRecorder, y as RUN_SNAPSHOT_SCHEMA_VERSION, z as toLlmToolSpec } from "./dist-B77plHjw.js";
2
+ import { A as isNetworkAllowed, B as toVercelToolSpecs, C as bridgeError, D as extractChartSpec, E as createWebSkillApi, F as normalizeToolError, I as parseBridgeRequest, L as resolveToolName, M as networkUrlHost, N as normalizeErrorCode, O as fromVercelResult, P as normalizeToolContent, R as schemaToForm, S as WebSkillRuntime, T as createScriptContext, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as SerializingMemoryStore, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as mergeCatalogEntries, k as fromVercelStreamPart, 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 buildRenderResult, x as TraceRecorder, y as RUN_SNAPSHOT_SCHEMA_VERSION, z as toLlmToolSpec } from "./dist-BXpDDZpR.js";
3
3
 
4
4
  export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, AnthropicClient, CapabilityApproval, DEFAULT_ARCHIVE_LIMITS, 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, SerializingMemoryStore, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, assertRemoteUrlAllowed, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, messageOf, networkUrlHost, normalizeErrorCode, normalizePath, normalizeToolContent, normalizeToolError, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, readResponseWithLimit, renderAvailableSkillsXml, renderCatalogJson, resolveArchiveLimits, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, unzipWithLimits, validateSkills, verifyManifest, xmlRenderer };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { I as SkillDocument, P as SkillCatalogEntry, T as JsonSchema, m as LlmToolSpec } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { it as ToolResult, v as ExternalSkillProvider, xt as mergeCatalogEntries, y as ExternalToolSource } from "./index-DfINBEOy.js";
2
+ import { it as ToolResult, v as ExternalSkillProvider, xt as mergeCatalogEntries, y as ExternalToolSource } from "./index-DJOha4b6.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
1
  import { C as messageOf, d as assertRemoteUrlAllowed, u as WebSkillError } from "./dist-BQzncxXg.js";
2
- import { P as normalizeToolContent, j as mergeCatalogEntries } from "./dist-B77plHjw.js";
2
+ import { P as normalizeToolContent, j as mergeCatalogEntries } from "./dist-BXpDDZpR.js";
3
3
 
4
4
  //#region ../mcp/dist/index.js
5
5
  /**
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { B as SkillManifest, G as SkillsLockfile, L as SkillInstallSource, O as SKILLS_LOCKFILE, k as SKILL_MANIFEST_FILE, q as VerifyResult } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { ht as createScriptContext } from "./index-DfINBEOy.js";
2
+ import { ht as createScriptContext } from "./index-DJOha4b6.js";
3
3
  import { n as LlmEnvConfig, s as probeLlmCapabilities, t as LlmCapabilities } from "./env-BPUBZCwJ-4jat_SVG.js";
4
- import { a as NodeScriptExecutor, c as ProcessSandboxOptions, d as SkillManager, f as exportArchive, i as NodeFS, l as SandboxOptions, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as SandboxedScriptExecutor } from "./index-CsDJvYGV.js";
4
+ import { a as NodeScriptExecutor, c as ProcessSandboxOptions, d as SkillManager, f as exportArchive, i as NodeFS, l as SandboxOptions, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as SandboxedScriptExecutor } from "./index-DRlYzdr2.js";
5
5
  export { CliUiBridge, FileArtifactStore, FileMemoryStore, type LlmCapabilities, type LlmEnvConfig, NodeFS, NodeScriptExecutor, OxcSchemaInferer, ProcessSandboxExecutor, type ProcessSandboxOptions, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, type SandboxOptions, SandboxedScriptExecutor, type SkillInstallSource, SkillManager, type SkillManifest, type SkillsLockfile, type VerifyResult, createScriptContext, exportArchive, probeLlmCapabilities, readArchiveManifest };
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { i as SKILL_MANIFEST_FILE, r as SKILLS_LOCKFILE } from "./dist-BQzncxXg.js";
2
- import { T as createScriptContext } from "./dist-B77plHjw.js";
2
+ import { T as createScriptContext } from "./dist-BXpDDZpR.js";
3
3
  import { i as probeLlmCapabilities } from "./env--jJB-TSX-04klhTYi.js";
4
- import { a as NodeScriptExecutor, c as SandboxedScriptExecutor, d as readArchiveManifest, i as NodeFS, l as SkillManager, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as exportArchive } from "./dist-Chk8iB-E.js";
4
+ import { a as NodeScriptExecutor, c as SandboxedScriptExecutor, d as readArchiveManifest, i as NodeFS, l as SkillManager, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as exportArchive } from "./dist-DWFDb1Ww.js";
5
5
 
6
6
  export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, ProcessSandboxExecutor, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, exportArchive, probeLlmCapabilities, readArchiveManifest };
package/dist/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { _ as RenderResultRequest, g as RenderBlock, o as InteractionRequest, r as ChartSpec, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-krKWW8WV.js";
2
- import { mt as buildRenderResult } from "./index-DfINBEOy.js";
2
+ import { mt as buildRenderResult } from "./index-DJOha4b6.js";
3
3
  //#region ../ui/dist/index.d.ts
4
4
  //#region src/model/formModel.d.ts
5
5
  interface FormModel {
package/dist/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- import { w as buildRenderResult } from "./dist-B77plHjw.js";
1
+ import { w as buildRenderResult } from "./dist-BXpDDZpR.js";
2
2
  import { C as renderMiniChart, D as toA2uiMessages, E as shapeInteractionValue, O as toOpenUiLang, S as renderBlocks, T as renderRenderResult, _ as ensureStyles, a as CHART_PALETTE, b as fromVercelToolResult, c as OPENUI_CANCEL_ACTION, d as VercelUiBridge, f as WEBSKILL_STYLES_CSS, g as decodeInteractionResponse, h as collectValues, i as A2UI_VERSION, k as toVercelToolInvocation, l as OPENUI_SUBMIT_ACTION, m as chartToTable, n as A2UI_CANCEL_ACTION, o as LitRendererBridge, p as WebFormBridge, r as A2UI_SUBMIT_ACTION, s as OPENUI_AUTHORIZE_ACTION, t as A2UI_BASIC_CATALOG_ID, u as VERCEL_INTERACTION_TOOL_NAME, v as fromA2uiAction, w as renderMiniMarkdown, x as interactionToFormModel, y as fromOpenUiAction } from "./dist-DNSG9FqC.js";
3
3
 
4
4
  export { A2UI_BASIC_CATALOG_ID, A2UI_CANCEL_ACTION, A2UI_SUBMIT_ACTION, A2UI_VERSION, CHART_PALETTE, LitRendererBridge, OPENUI_AUTHORIZE_ACTION, OPENUI_CANCEL_ACTION, OPENUI_SUBMIT_ACTION, VERCEL_INTERACTION_TOOL_NAME, VercelUiBridge, WEBSKILL_STYLES_CSS, WebFormBridge, buildRenderResult, chartToTable, collectValues, decodeInteractionResponse, ensureStyles, fromA2uiAction, fromOpenUiAction, fromVercelToolResult, interactionToFormModel, renderBlocks, renderMiniChart, renderMiniMarkdown, renderRenderResult, shapeInteractionValue, toA2uiMessages, toOpenUiLang, toVercelToolInvocation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webskill/sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "WebSkill \u2014 browser/Node agent skill runtime (skills, tools, MCP, governance, UI)",
5
5
  "license": "MIT",
6
6
  "type": "module",