@webskill/sdk 0.2.6 → 0.2.8

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
- 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-DJOha4b6.js";
1
+ import { K as SkillInstallSource, M as FileStat, N as FileSystemProvider, O as ArchiveLimits, Y as SkillManifest, _ as RenderResultRequest, a as InteractionPolicy, c as LlmClient, d as LlmResponse, et as SkillsLockfile, f as LlmStreamEvent, nt as VerifyResult, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-AmKCKJn_-BogJPQHU.js";
2
+ import { N as NetworkPolicy, Ot as parseBridgeRequest, 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-QrHtAudz.js";
3
3
  //#region ../browser/dist/index.d.ts
4
4
  //#region src/fs/featureDetection.d.ts
5
5
  /** 检测当前环境是否可用 OPFS(navigator.storage.getDirectory) */
@@ -32,8 +32,9 @@ declare class OpfsProvider implements FileSystemProvider {
32
32
  /**
33
33
  * Worker 引导源码(字符串 → Blob URL → new Worker(url, {type:'module'}))。
34
34
  * 注意:内容为纯 JS,不能含反引号与 ${ 占位(外层用模板字符串内嵌);
35
- * isNetworkAllowed/networkUrlHost 经函数源码注入(匹配逻辑单一来源在
36
- * runtime/sandbox/networkPolicy.ts,此处禁止复制实现)。
35
+ * isNetworkAllowed/networkUrlHost 经 networkPolicyLibSource() 注入(匹配逻辑单一来源在
36
+ * runtime/sandbox/networkPolicy.ts,此处禁止复制实现)。该辅助把函数源码绑定到固定变量名,
37
+ * 消费方生产构建压缩改名后仍可调用(0.2.8 C4)。
37
38
  *
38
39
  * 协议(宿主 ↔ Worker):
39
40
  * - 宿主 → Worker:{type:'load', id, source, networkPolicy?} 请求加载脚本定义
@@ -296,6 +297,12 @@ type WorkerEvent = {
296
297
  type: 'text-delta';
297
298
  runId: string;
298
299
  delta: string;
300
+ } |
301
+ /** 不阻断 run 但宿主应当知晓的降级(如外部技能提供者报错导致技能缺失) */
302
+ {
303
+ type: 'host-warning';
304
+ runId: string;
305
+ message: string;
299
306
  };
300
307
  /** Worker 内全局作用域最小接口(postMessage + 消息监听) */
301
308
  interface WorkerScopeLike {
@@ -336,6 +343,8 @@ interface WorkerRuntimeClientDeps {
336
343
  uiBridge?: UiBridge;
337
344
  /** 单次请求超时(默认 120_000ms);超时返回结构化 error 响应(不 reject) */
338
345
  timeoutMs?: number;
346
+ /** 不阻断 run 的降级告警出口(默认 console.warn) */
347
+ onWarning?(runId: string, message: string): void;
339
348
  }
340
349
  /** 主线程客户端:init/run/cancel/status/dispose 的 Promise API + 交互转发 */
341
350
  declare class WorkerRuntimeClient {
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-BXpDDZpR.js";
2
+ import { C as bridgeError, E as createWebSkillApi, I as normalizeToolContent, L as normalizeToolError, M as mergeCatalogEntries, N as networkPolicyLibSource, R as parseBridgeRequest, c as FsArtifactStore, h as ProgressiveRouter, i as AgentLoop, l as FsMemoryStore, m as OpenAiCompatibleClient, o as CapabilityApproval, u as FsRunSnapshotStore, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-B9VLwOME.js";
3
3
  import { n as MockLlmClient } from "./testing-BUoXvm1u.js";
4
4
 
5
5
  //#region ../browser/dist/index.js
@@ -157,8 +157,9 @@ var OpfsProvider = class {
157
157
  /**
158
158
  * Worker 引导源码(字符串 → Blob URL → new Worker(url, {type:'module'}))。
159
159
  * 注意:内容为纯 JS,不能含反引号与 ${ 占位(外层用模板字符串内嵌);
160
- * isNetworkAllowed/networkUrlHost 经函数源码注入(匹配逻辑单一来源在
161
- * runtime/sandbox/networkPolicy.ts,此处禁止复制实现)。
160
+ * isNetworkAllowed/networkUrlHost 经 networkPolicyLibSource() 注入(匹配逻辑单一来源在
161
+ * runtime/sandbox/networkPolicy.ts,此处禁止复制实现)。该辅助把函数源码绑定到固定变量名,
162
+ * 消费方生产构建压缩改名后仍可调用(0.2.8 C4)。
162
163
  *
163
164
  * 协议(宿主 ↔ Worker):
164
165
  * - 宿主 → Worker:{type:'load', id, source, networkPolicy?} 请求加载脚本定义
@@ -180,9 +181,7 @@ var pending = new Map();
180
181
  var bridgeSeq = 0;
181
182
  var networkPolicy = 'deny-all';
182
183
 
183
- ${isNetworkAllowed.toString()}
184
-
185
- ${networkUrlHost.toString()}
184
+ ${networkPolicyLibSource()}
186
185
 
187
186
  function resolveUrl(raw) {
188
187
  try {
@@ -1180,6 +1179,11 @@ function parseWorkerEvent(data) {
1180
1179
  runId: data["runId"],
1181
1180
  delta: data["delta"]
1182
1181
  } : void 0;
1182
+ if (data["type"] === "host-warning") return isNonEmptyString(data["runId"]) && isNonEmptyString(data["message"]) ? {
1183
+ type: "host-warning",
1184
+ runId: data["runId"],
1185
+ message: data["message"]
1186
+ } : void 0;
1183
1187
  if (!isNonEmptyString(data["id"])) return;
1184
1188
  switch (data["type"]) {
1185
1189
  case "ready": return {
@@ -1499,10 +1503,12 @@ var WorkerRuntimeClient = class {
1499
1503
  #timeoutMs;
1500
1504
  #pending = /* @__PURE__ */ new Map();
1501
1505
  #seq = 0;
1506
+ #onWarning;
1502
1507
  constructor(deps) {
1503
1508
  this.#worker = deps.worker;
1504
1509
  this.#uiBridge = deps.uiBridge;
1505
1510
  this.#timeoutMs = deps.timeoutMs ?? 12e4;
1511
+ this.#onWarning = deps.onWarning ?? ((runId, message) => console.warn(`[webskill] run ${runId}: ${message}`));
1506
1512
  this.#worker.addEventListener("message", (event) => {
1507
1513
  this.#onMessage(event.data);
1508
1514
  });
@@ -1623,6 +1629,10 @@ var WorkerRuntimeClient = class {
1623
1629
  await this.#uiBridge?.onTextDelta?.(event.runId, event.delta);
1624
1630
  return;
1625
1631
  }
1632
+ if (event.type === "host-warning") {
1633
+ this.#onWarning(event.runId, event.message);
1634
+ return;
1635
+ }
1626
1636
  const pending = this.#pending.get(event.id);
1627
1637
  if (pending) {
1628
1638
  this.#pending.delete(event.id);