@webskill/sdk 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { A as validateSkills, O as resolveInsideRoot, d as assertSafePathSegment, u as WebSkillError, y as isValidSkillName } from "./dist-fZFZaf43.js";
2
- import { i as NodeFS } from "./dist-LIFS3ZjI.js";
1
+ import { A as unzipWithLimits, b as isValidSkillName, d as assertSafePathSegment, j as validateSkills, k as resolveInsideRoot, u as WebSkillError } from "./dist-D0saNPi_.js";
2
+ import { i as NodeFS, l as exportArchive } from "./dist-Dj6QjHBn.js";
3
3
  import path from "node:path";
4
4
  import { tmpdir } from "node:os";
5
5
  import { mkdtemp } from "node:fs/promises";
@@ -307,9 +307,15 @@ var ApprovalWorkflow = class {
307
307
  type: "local",
308
308
  path: skillDir
309
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
+ });
310
315
  await this.#versions.add(candidate.name, {
311
316
  reason: `Publish candidate ${candidateId}`,
312
- manifest
317
+ manifest,
318
+ archive: await this.#fs.readBinary(archiveOut)
313
319
  });
314
320
  await this.#store.updateStatus(candidateId, "published");
315
321
  await this.#audit.append({
@@ -325,11 +331,79 @@ var ApprovalWorkflow = class {
325
331
  } catch (e) {
326
332
  if (e instanceof WebSkillError) throw e;
327
333
  throw new WebSkillError("GOVERNANCE_FAILED", `Failed to publish candidate "${candidateId}": ${messageOf$1(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$1(e)}`, e);
385
+ } finally {
386
+ try {
387
+ await this.#fs.remove(stagingRoot, { recursive: true });
388
+ } catch {}
328
389
  }
329
390
  }
330
391
  };
331
392
  const fileOf$1 = (root) => `${root}/.webskill/audit.jsonl`;
332
- /** JSONL 追加的审计日志:<managedRoot>/.webskill/audit.jsonl;跨实例可恢复查询 */
393
+ const sha256Hex = (text) => createHash("sha256").update(text, "utf8").digest("hex");
394
+ /** 链字段之外的规范化事件载荷(hash 计算输入) */
395
+ function canonical(event) {
396
+ return JSON.stringify({
397
+ id: event.id,
398
+ ts: event.ts,
399
+ type: event.type,
400
+ target: event.target,
401
+ actor: event.actor,
402
+ data: event.data,
403
+ prevHash: event.prevHash
404
+ });
405
+ }
406
+ /** JSONL 追加的审计日志:<managedRoot>/.webskill/audit.jsonl;跨实例可恢复查询;prevHash 链可校验完整性 */
333
407
  var FsAuditLog = class {
334
408
  #root;
335
409
  #fs;
@@ -342,16 +416,26 @@ var FsAuditLog = class {
342
416
  this.#createId = deps.createId;
343
417
  }
344
418
  async append(event) {
419
+ const path = fileOf$1(this.#root);
420
+ const existing = await this.#fs.exists(path) ? await this.#fs.readText(path) : "";
421
+ const lines = existing.split("\n").filter((l) => l.trim() !== "");
422
+ let prevHash = "GENESIS";
423
+ if (lines.length > 0) try {
424
+ const last = JSON.parse(lines.at(-1));
425
+ prevHash = last.hash ?? sha256Hex(canonical(last));
426
+ } catch {
427
+ prevHash = "GENESIS";
428
+ }
345
429
  const full = {
346
430
  id: event.id ?? this.#createId?.() ?? `audit-${Math.random().toString(36).slice(2, 10)}`,
347
431
  ts: event.ts ?? this.#now?.() ?? (/* @__PURE__ */ new Date()).toISOString(),
348
432
  type: event.type,
349
433
  target: event.target,
350
434
  ...event.actor !== void 0 ? { actor: event.actor } : {},
351
- ...event.data !== void 0 ? { data: event.data } : {}
435
+ ...event.data !== void 0 ? { data: event.data } : {},
436
+ prevHash
352
437
  };
353
- const path = fileOf$1(this.#root);
354
- const existing = await this.#fs.exists(path) ? await this.#fs.readText(path) : "";
438
+ full.hash = sha256Hex(canonical(full));
355
439
  const prefix = existing === "" || existing.endsWith("\n") ? existing : `${existing}\n`;
356
440
  await this.#fs.writeText(path, `${prefix}${JSON.stringify(full)}\n`);
357
441
  return full;
@@ -371,6 +455,38 @@ var FsAuditLog = class {
371
455
  }
372
456
  return events;
373
457
  }
458
+ /** hash 链完整性校验:逐行重算 hash 并核对 prevHash 链接 */
459
+ async verifyChain() {
460
+ const path = fileOf$1(this.#root);
461
+ if (!await this.#fs.exists(path)) return { ok: true };
462
+ const lines = (await this.#fs.readText(path)).split("\n").filter((l) => l.trim() !== "");
463
+ let expectedPrev = "GENESIS";
464
+ for (let i = 0; i < lines.length; i++) {
465
+ let event;
466
+ try {
467
+ event = JSON.parse(lines[i]);
468
+ } catch {
469
+ return {
470
+ ok: false,
471
+ brokenAt: i,
472
+ reason: "line is not valid JSON"
473
+ };
474
+ }
475
+ if (event.prevHash !== expectedPrev) return {
476
+ ok: false,
477
+ brokenAt: i,
478
+ reason: "prevHash link mismatch (events may have been removed or reordered)"
479
+ };
480
+ const expectedHash = sha256Hex(canonical(event));
481
+ if (event.hash !== expectedHash) return {
482
+ ok: false,
483
+ brokenAt: i,
484
+ reason: "event hash mismatch (event content was tampered)"
485
+ };
486
+ expectedPrev = event.hash;
487
+ }
488
+ return { ok: true };
489
+ }
374
490
  };
375
491
  const dirOf = (root, skillName) => {
376
492
  assertSafePathSegment(skillName, "skill name");
@@ -400,9 +516,20 @@ var SkillVersionStore = class {
400
516
  manifest: input.manifest
401
517
  };
402
518
  assertSafePathSegment(version.versionId, "version id");
519
+ if (input.archive) {
520
+ const archivePath = `${dirOf(this.#root, skillName)}/${version.versionId}.zip`;
521
+ await this.#fs.writeBinary(archivePath, input.archive);
522
+ version.archivePath = archivePath;
523
+ }
403
524
  await this.#fs.writeText(`${dirOf(this.#root, skillName)}/${version.versionId}.json`, JSON.stringify(version, null, 2));
404
525
  return version;
405
526
  }
527
+ /** 读取版本归档字节(applyRollback 用;未捕获归档的旧版本 → GOVERNANCE_FAILED) */
528
+ async readArchive(skillName, versionId) {
529
+ const version = await this.get(skillName, versionId);
530
+ if (!version.archivePath || !await this.#fs.exists(version.archivePath)) throw new WebSkillError("GOVERNANCE_FAILED", `Version "${versionId}" of skill "${skillName}" has no captured archive (recorded before archive capture existed)`);
531
+ return this.#fs.readBinary(version.archivePath);
532
+ }
406
533
  async list(skillName) {
407
534
  const dir = dirOf(this.#root, skillName);
408
535
  if (!await this.#fs.exists(dir)) return [];
@@ -484,7 +611,7 @@ var FailureAnalyzer = class {
484
611
  };
485
612
  /**
486
613
  * 修订选项规划:patch(按诊断给具体文件变更)/ rollback(有旧版本时)/ quarantine。
487
- * 注意:任何 option 的 apply 都必须经 ApprovalWorkflow 审批后执行。
614
+ * 注意:任何 option 的 apply 都必须经 ApprovalWorkflow 审批后执行;rollback 选项(targetVersionId)经 ApprovalWorkflow.applyRollback 真实恢复文件。
488
615
  */
489
616
  var RepairPlanner = class {
490
617
  plan(input) {
@@ -522,6 +649,8 @@ var SkillStatePolicy = class {
522
649
  #audit;
523
650
  #failureThreshold;
524
651
  #loaded;
652
+ /** 缓存文件 mtime(states.json 外部变更时按 mtime 重载) */
653
+ #loadedMtimeMs;
525
654
  constructor(deps) {
526
655
  this.#root = deps.root.replace(/\/+$/, "");
527
656
  this.#fs = deps.fs;
@@ -529,17 +658,33 @@ var SkillStatePolicy = class {
529
658
  this.#failureThreshold = deps.failureThreshold ?? 3;
530
659
  }
531
660
  async #load() {
532
- if (this.#loaded) return this.#loaded;
533
661
  const path = fileOf(this.#root);
662
+ if (this.#loaded) try {
663
+ const stat = await this.#fs.stat(path);
664
+ if (stat.mtimeMs !== void 0 && stat.mtimeMs === this.#loadedMtimeMs) return this.#loaded;
665
+ } catch {
666
+ return this.#loaded;
667
+ }
534
668
  this.#loaded = await this.#fs.exists(path) ? JSON.parse(await this.#fs.readText(path)) : {
535
669
  states: {},
536
670
  failures: {}
537
671
  };
672
+ try {
673
+ this.#loadedMtimeMs = (await this.#fs.stat(path)).mtimeMs;
674
+ } catch {
675
+ this.#loadedMtimeMs = void 0;
676
+ }
538
677
  return this.#loaded;
539
678
  }
540
679
  async #persist() {
541
680
  const data = await this.#load();
542
- await this.#fs.writeText(fileOf(this.#root), JSON.stringify(data, null, 2));
681
+ const path = fileOf(this.#root);
682
+ await this.#fs.writeText(path, JSON.stringify(data, null, 2));
683
+ try {
684
+ this.#loadedMtimeMs = (await this.#fs.stat(path)).mtimeMs;
685
+ } catch {
686
+ this.#loadedMtimeMs = void 0;
687
+ }
543
688
  }
544
689
  async getState(skillName) {
545
690
  assertSafePathSegment(skillName, "skill name");
@@ -1,4 +1,4 @@
1
- import { F as SkillDocument, G as ValidationReport, I as SkillInstallSource, M as SkillCatalog, N as SkillCatalogEntry, P as SkillDiscovery, S as DiscoveryResult, T as JsonSchema, _ as RenderResultRequest, a as InteractionPolicy, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge, w as FileSystemProvider, z as SkillManifest } from "./types-CgNC-oQu-DEcIBJKG.js";
1
+ import { F as SkillDocument, G as ValidationReport, I as SkillInstallSource, M as SkillCatalog, N as SkillCatalogEntry, P as SkillDiscovery, S as DiscoveryResult, T as JsonSchema, _ as RenderResultRequest, a as InteractionPolicy, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge, w as FileSystemProvider, z as SkillManifest } from "./types-CKm5G_eQ-8W8FnP4u.js";
2
2
  //#region ../runtime/dist/index.d.ts
3
3
  //#region src/llm/openAiCompatibleClient.d.ts
4
4
  interface OpenAiCompatibleClientConfig {
@@ -295,6 +295,12 @@ interface RuntimeRun {
295
295
  interface RunResult {
296
296
  output: string;
297
297
  run: RuntimeRun;
298
+ /** 最终消息历史(多会话延续用;含 system/user/assistant/tool) */
299
+ messages: LlmMessage[];
300
+ }
301
+ /** createSession 返回的会话句柄:跨 run 延续消息历史 */
302
+ interface RuntimeSessionHandle extends RuntimeSession {
303
+ run(prompt: string): Promise<RunResult>;
298
304
  }
299
305
  //#endregion
300
306
  //#region src/interaction/renderResult.d.ts
@@ -417,6 +423,26 @@ declare class FsMemoryStore implements MemoryStore {
417
423
  clear(scope?: string): Promise<void>;
418
424
  }
419
425
  //#endregion
426
+ //#region src/memory/serializingMemoryStore.d.ts
427
+ /**
428
+ * per-scope 串行化 MemoryStore 装饰器:同一 scope 的 get/set/delete/list
429
+ * 按 promise 链串行(并发 run 的 read-modify-write 不丢计数)。
430
+ */
431
+ declare class SerializingMemoryStore implements MemoryStore {
432
+ #private;
433
+ constructor(inner: MemoryStore);
434
+ get(scope: string, key: string): Promise<unknown>;
435
+ set(scope: string, key: string, value: unknown): Promise<void>;
436
+ delete(scope: string, key: string): Promise<void>;
437
+ list(scope: string): Promise<Array<{
438
+ key: string;
439
+ value: unknown;
440
+ }>>;
441
+ clear(scope?: string): Promise<void>;
442
+ /** scope 级原子段:read-modify-write 全段在 promise 链内串行执行(fn 收到底层 store) */
443
+ transaction<T>(scope: string, fn: (inner: MemoryStore) => Promise<T>): Promise<T>;
444
+ }
445
+ //#endregion
420
446
  //#region src/artifacts/fsArtifactStore.d.ts
421
447
  /**
422
448
  * 基于 FileSystemProvider 的 ArtifactStore:产物落盘 <root>/<runId>/<path>,
@@ -531,6 +557,8 @@ declare class CapabilityApproval {
531
557
  uiBridge?: UiBridge;
532
558
  scope?: ApprovalScope;
533
559
  });
560
+ /** run 终态清理授权记录(宿主在 run 结束后调用;同时有 LRU 上限兜底) */
561
+ clearRun(runId: string): void;
534
562
  authorize(input: {
535
563
  runId: string;
536
564
  capability: BridgeCapability;
@@ -600,6 +628,10 @@ interface RunSnapshot {
600
628
  activatedTools: ToolDefinition[];
601
629
  /** 等待中的交互(恢复时重新发起,表单重新渲染) */
602
630
  pendingInteraction: InteractionRequest;
631
+ /** $chart 等内容收集的渲染块(0.2.0 起跨 resume 保留;旧快照缺省视为空) */
632
+ renderBlocks?: RenderBlock[];
633
+ /** 交互 id 序号(resume 后续算,避免 id 冲突;旧快照缺省从 0 起) */
634
+ interactionSeq?: number;
603
635
  /** 进入 interrupted 时计算的过期时间 */
604
636
  interactionExpiresAt: string;
605
637
  config: {
@@ -620,6 +652,10 @@ interface RunSnapshotStore {
620
652
  /**
621
653
  * FileSystemProvider 后端的快照存储:<root>/<runId>.snapshot.json。
622
654
  * 坏 JSON → RUN_SNAPSHOT_INCOMPATIBLE 并自动清理坏文件;runId 过路径安全校验。
655
+ * save/list 时顺带清理已过 interactionExpiresAt 的过期快照。
656
+ *
657
+ * 数据敏感性说明:快照含完整对话历史(用户输入、工具结果、可能的凭据片段),
658
+ * 以明文 JSON 落盘于宿主提供的 fs;宿主应将其视为会话数据同等保护。
623
659
  * @experimental
624
660
  */
625
661
  declare class FsRunSnapshotStore implements RunSnapshotStore {
@@ -683,6 +719,8 @@ declare class AgentLoop {
683
719
  userPrompt: string;
684
720
  route: RouteResult;
685
721
  runId?: string;
722
+ /** 多会话历史延续:插入 system 与本轮 user 之间(不含 system 消息) */
723
+ history?: LlmMessage[];
686
724
  }): Promise<RunResult>;
687
725
  /**
688
726
  * D3 恢复:以快照重建 LoopState,重新发起等待中的交互(表单重新渲染),
@@ -747,8 +785,18 @@ declare class WebSkillRuntime {
747
785
  * 与 SkillManager onChanged 接线:`new SkillManager({ ..., onChanged: () => runtime.invalidate() })`。
748
786
  */
749
787
  invalidate(): void;
788
+ /**
789
+ * 多会话:session 对象的 run(prompt) 跨 run 延续消息历史(同一 session 对话上下文连续)。
790
+ * 既有 runtime.run(prompt) 保持无状态单次语义不变。
791
+ */
792
+ createSession(options?: {
793
+ sessionId?: string;
794
+ }): RuntimeSessionHandle;
750
795
  discover(): Promise<DiscoveryResult>;
751
- run(userPrompt: string): Promise<RunResult>;
796
+ run(userPrompt: string, options?: {
797
+ sessionId?: string;
798
+ history?: LlmMessage[];
799
+ }): Promise<RunResult>;
752
800
  /** D3:列出可恢复的 interrupted run(供 UI 展示"未完成任务") */
753
801
  listInterruptedRuns(): Promise<RunSnapshot[]>;
754
802
  /**
@@ -760,4 +808,4 @@ declare class WebSkillRuntime {
760
808
  resumeRun(runId: string): Promise<RunResult>;
761
809
  }
762
810
  //#endregion
763
- export { SkillStateGuard as $, LifecycleHook as A, RUN_SNAPSHOT_SCHEMA_VERSION as B, FullDisclosureRouter as C, resolveToolName as Ct, HookRunnerOptions as D, HookRunner as E, toVercelToolSpecs 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, OpenAiCompatibleClient as P, SkillRouter as Q, READ_SKILL_FILE_TOOL as R, FsRunSnapshotStore as S, parseBridgeRequest as St, GoogleGenAiClientConfig as T, toLlmToolSpec as Tt, RunSnapshot as U, RouteResult as V, RunSnapshotStore as W, ScriptExecutionContext as X, SchemaInferer as Y, ScriptExecutor as Z, EventBus as _, fromVercelStreamPart as _t, AgentLoopConfig as a, TraceEventType as at, FsArtifactStore as b, networkUrlHost as bt, AnthropicClientConfig as c, WebSkillApi as ct, BridgeCapabilities as d, bridgeError as dt, ToolDefinition as et, BridgeCapability as f, buildRenderResult as ft, CapabilityMode as g, fromVercelResult as gt, CapabilityApproval as h, extractChartSpec as ht, AgentLoop as i, TraceEvent as it, LifecycleHookContext as j, LifecycleEvent as k, ApprovalDecision as l, WebSkillRuntime as lt, BridgeResponse as m, createWebSkillApi as mt, ASK_USER_TOOL as n, ToolResult as nt, AgentLoopDeps as o, TraceRecorder as ot, BridgeRequest as p, createScriptContext as pt, RuntimeRun as q, ASK_USER_TOOL_NAME as r, TraceClock as rt, AnthropicClient as s, VercelToolSpec as st, ASK_USER_INPUT_SCHEMA as t, ToolResolution as tt, ApprovalScope as u, WebSkillRuntimeDeps as ut, ExternalSkillProvider as v, isNetworkAllowed as vt, GoogleGenAiClient as w, schemaToForm as wt, FsMemoryStore as x, normalizeToolContent as xt, ExternalToolSource as y, mergeCatalogEntries as yt, READ_SKILL_FILE_TOOL_NAME as z };
811
+ export { SerializingMemoryStore as $, LifecycleHook as A, RUN_SNAPSHOT_SCHEMA_VERSION as B, FullDisclosureRouter as C, normalizeToolContent as Ct, HookRunnerOptions as D, toLlmToolSpec as Dt, HookRunner as E, schemaToForm 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, toVercelToolSpecs as Ot, OpenAiCompatibleClient as P, ScriptExecutor as Q, READ_SKILL_FILE_TOOL as R, FsRunSnapshotStore as S, networkUrlHost as St, GoogleGenAiClientConfig as T, resolveToolName 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, 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, parseBridgeRequest 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
- import { C as FileStat, I as SkillInstallSource, K as VerifyResult, T as JsonSchema, W as SkillsLockfile, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, w as FileSystemProvider, y as ArchiveLimits, z as SkillManifest } from "./types-CgNC-oQu-DEcIBJKG.js";
2
- import { N as NetworkPolicy, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, b as FsArtifactStore, d as BridgeCapabilities, et as ToolDefinition, nt as ToolResult, u as ApprovalScope, x as FsMemoryStore } from "./index-COuOu6gw.js";
1
+ import { C as FileStat, I as SkillInstallSource, K as VerifyResult, T as JsonSchema, W as SkillsLockfile, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, w as FileSystemProvider, y as ArchiveLimits, z as SkillManifest } from "./types-CKm5G_eQ-8W8FnP4u.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-CySxIvRz.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
@@ -25,6 +25,7 @@ declare class NodeFS implements FileSystemProvider {
25
25
  remove(p: string, options?: {
26
26
  recursive?: boolean;
27
27
  }): Promise<void>;
28
+ rename(from: string, to: string): Promise<void>;
28
29
  }
29
30
  //#endregion
30
31
  //#region src/executor/nodeScriptExecutor.d.ts
@@ -163,6 +164,8 @@ declare class SkillManager {
163
164
  /** install/uninstall 成功后的变更回调(宿主接线缓存失效,如 WebSkillRuntime.invalidate) */
164
165
  onChanged?: () => void;
165
166
  });
167
+ /** 托管根目录(治理发布归档捕获等只读场景) */
168
+ get managedRoot(): string;
166
169
  install(source: SkillInstallSource, options?: {
167
170
  expectedSha256?: string;
168
171
  }): Promise<SkillManifest>;
@@ -180,42 +183,12 @@ declare class SkillManager {
180
183
  }
181
184
  //#endregion
182
185
  //#region src/skillManagement/export/archiveExporter.d.ts
186
+ /** 导出技能目录全部文件(含 manifest)为 zip/tar 归档,返回 outPath */
187
+ declare function exportArchive(fs: FileSystemProvider, skillRoot: string, options: {
188
+ format: 'zip' | 'tar';
189
+ outPath: string;
190
+ }): Promise<string>;
183
191
  /** 只解出归档中的 webskill.skill-manifest.json 条目(安装前预览) */
184
192
  declare function readArchiveManifest(fs: FileSystemProvider, archivePath: string): Promise<SkillManifest>;
185
193
  //#endregion
186
- //#region src/env.d.ts
187
- interface LlmEnvConfig {
188
- baseUrl: string;
189
- apiKey: string;
190
- model: string;
191
- }
192
- /** per-provider env 配置(baseUrl 可选,客户端自带默认) */
193
- interface ProviderEnvConfig {
194
- apiKey: string;
195
- model: string;
196
- baseUrl?: string;
197
- }
198
- /**
199
- * 读取 VITE_BASE_URL / VITE_API_KEY / VITE_MODEL_NAME;缺项返回 undefined 供测试 skip 判断。
200
- */
201
- declare function loadLlmConfigFromEnv(dotenvPath?: string): LlmEnvConfig | undefined;
202
- /** ANTHROPIC_API_KEY / ANTHROPIC_MODEL(可选 ANTHROPIC_BASE_URL);缺项返回 undefined */
203
- declare function loadAnthropicConfigFromEnv(dotenvPath?: string): ProviderEnvConfig | undefined;
204
- /** GOOGLE_API_KEY / GOOGLE_MODEL(可选 GOOGLE_BASE_URL);缺项返回 undefined */
205
- declare function loadGoogleConfigFromEnv(dotenvPath?: string): ProviderEnvConfig | undefined;
206
- interface LlmCapabilities {
207
- available: boolean;
208
- nonStreaming: boolean;
209
- reason?: string;
210
- }
211
- /**
212
- * 探测 LLM 能力(结果模块级缓存):
213
- * - available:GET /models 可达(与 checkAvailability 同语义)
214
- * - nonStreaming:最小非流式 chat completion(max_tokens=1,短超时);
215
- * HTTP 400/404 或明确不支持非流式的错误 → false
216
- * - streaming 能力由 available 推断(SSE 解析在 SDK 侧实现)
217
- * 环境变量 VITE_LLM_NON_STREAMING=0 可显式强制 nonStreaming=false(模拟流式-only 回归)。
218
- */
219
- declare function probeLlmCapabilities(config: LlmEnvConfig): Promise<LlmCapabilities>;
220
- //#endregion
221
- export { readArchiveManifest as _, LlmEnvConfig as a, OxcSchemaInferer as c, SandboxedScriptExecutor as d, SkillManager as f, probeLlmCapabilities as g, loadLlmConfigFromEnv as h, LlmCapabilities as i, ProviderEnvConfig as l, loadGoogleConfigFromEnv as m, FileArtifactStore as n, NodeFS as o, loadAnthropicConfigFromEnv as p, FileMemoryStore as r, NodeScriptExecutor as s, CliUiBridge as t, SandboxOptions as u };
194
+ export { NodeScriptExecutor as a, SandboxedScriptExecutor as c, readArchiveManifest as d, NodeFS as i, SkillManager as l, FileArtifactStore as n, OxcSchemaInferer as o, FileMemoryStore as r, SandboxOptions as s, CliUiBridge as t, exportArchive as u };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as checkSkillRules, A as SKILL_NAME_PATTERN, B as SkillMetadata, C as FileStat, D as SKILLS_LOCKFILE, E as MemoryFS, F as SkillDocument, G as ValidationReport, H as SkillReader, I as SkillInstallSource, J as WebSkillErrorCode, K as VerifyResult, L as SkillIssue, M as SkillCatalog, N as SkillCatalogEntry, O as SKILL_MANIFEST_FILE, P as SkillDiscovery, Q as checkDependencyCycles, R as SkillLocation, S as DiscoveryResult, T as JsonSchema, U as SkillSource, V as SkillPackManifest, W as SkillsLockfile, X as buildCatalog, Y as assertSafePathSegment, Z as buildManifest, _ as RenderResultRequest, a as InteractionPolicy, at as normalizePath, b as CatalogRenderer, c as LlmClient, ct as readResponseWithLimit, d as LlmResponse, dt as resolveArchiveLimits, et as computeDigest, f as LlmStreamEvent, ft as resolveInsideRoot, g as RenderBlock, gt as xmlRenderer, h as MemoryStore, ht as verifyManifest, i as FormField, it as jsonRenderer, j as SKILL_PACK_FILE, k as SKILL_NAME_MAX_LENGTH, l as LlmCompleteInput, lt as renderAvailableSkillsXml, m as LlmToolSpec, mt as validateSkills, n as ArtifactStore, nt as exportSkills, o as InteractionRequest, ot as parseSkillMarkdown, p as LlmToolCall, pt as unzipWithLimits, q as WebSkillError, r as ChartSpec, rt as isValidSkillName, s as InteractionResponse, st as parseSkillPackManifest, t as Artifact, tt as escapeXml, u as LlmMessage, ut as renderCatalogJson, v as UiBridge, w as FileSystemProvider, x as DEFAULT_ARCHIVE_LIMITS, y as ArchiveLimits, z as SkillManifest } from "./types-CgNC-oQu-DEcIBJKG.js";
2
- import { $ as SkillStateGuard, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as resolveToolName, D as HookRunnerOptions, E as HookRunner, Et as toVercelToolSpecs, 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 parseBridgeRequest, T as GoogleGenAiClientConfig, Tt as toLlmToolSpec, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, _ as EventBus, _t as fromVercelStreamPart, a as AgentLoopConfig, at as TraceEventType, b as FsArtifactStore, bt as networkUrlHost, c as AnthropicClientConfig, ct as WebSkillApi, d as BridgeCapabilities, dt as bridgeError, et as ToolDefinition, f as BridgeCapability, ft as buildRenderResult, g as CapabilityMode, gt as fromVercelResult, h as CapabilityApproval, ht as extractChartSpec, i as AgentLoop, it as TraceEvent, j as LifecycleHookContext, k as LifecycleEvent, l as ApprovalDecision, lt as WebSkillRuntime, m as BridgeResponse, mt as createWebSkillApi, n as ASK_USER_TOOL, nt as ToolResult, o as AgentLoopDeps, ot as TraceRecorder, p as BridgeRequest, pt as createScriptContext, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as TraceClock, s as AnthropicClient, st as VercelToolSpec, t as ASK_USER_INPUT_SCHEMA, tt as ToolResolution, u as ApprovalScope, ut as WebSkillRuntimeDeps, v as ExternalSkillProvider, vt as isNetworkAllowed, w as GoogleGenAiClient, wt as schemaToForm, x as FsMemoryStore, xt as normalizeToolContent, y as ExternalToolSource, yt as mergeCatalogEntries, z as READ_SKILL_FILE_TOOL_NAME } from "./index-COuOu6gw.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 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 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 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, 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, readResponseWithLimit, renderAvailableSkillsXml, renderCatalogJson, resolveArchiveLimits, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, unzipWithLimits, validateSkills, verifyManifest, xmlRenderer };
1
+ import { $ as checkDependencyCycles, A as SKILL_NAME_PATTERN, B as SkillMetadata, C as FileStat, D as SKILLS_LOCKFILE, E as MemoryFS, F as SkillDocument, G as ValidationReport, H as SkillReader, I as SkillInstallSource, J as WebSkillErrorCode, K as VerifyResult, L as SkillIssue, M as SkillCatalog, N as SkillCatalogEntry, O as SKILL_MANIFEST_FILE, P as SkillDiscovery, Q as buildManifest, R as SkillLocation, S as DiscoveryResult, T as JsonSchema, U as SkillSource, V as SkillPackManifest, W as SkillsLockfile, X as atomicWriteText, Y as assertSafePathSegment, Z as buildCatalog, _ as RenderResultRequest, _t as xmlRenderer, a as InteractionPolicy, at as jsonRenderer, b as CatalogRenderer, c as LlmClient, ct as parseSkillPackManifest, d as LlmResponse, dt as renderCatalogJson, et as checkSkillRules, f as LlmStreamEvent, ft as resolveArchiveLimits, g as RenderBlock, gt as verifyManifest, h as MemoryStore, ht as validateSkills, i as FormField, it as isValidSkillName, j as SKILL_PACK_FILE, k as SKILL_NAME_MAX_LENGTH, l as LlmCompleteInput, lt as readResponseWithLimit, m as LlmToolSpec, mt as unzipWithLimits, n as ArtifactStore, nt as escapeXml, o as InteractionRequest, ot as normalizePath, p as LlmToolCall, pt as resolveInsideRoot, q as WebSkillError, r as ChartSpec, rt as exportSkills, s as InteractionResponse, st as parseSkillMarkdown, t as Artifact, tt as computeDigest, u as LlmMessage, ut as renderAvailableSkillsXml, v as UiBridge, w as FileSystemProvider, x as DEFAULT_ARCHIVE_LIMITS, y as ArchiveLimits, z as SkillManifest } from "./types-CKm5G_eQ-8W8FnP4u.js";
2
+ import { $ as SerializingMemoryStore, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as normalizeToolContent, D as HookRunnerOptions, Dt as toLlmToolSpec, E as HookRunner, Et as schemaToForm, 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 toVercelToolSpecs, P as OpenAiCompatibleClient, Q as ScriptExecutor, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as networkUrlHost, T as GoogleGenAiClientConfig, Tt as resolveToolName, 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, 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 parseBridgeRequest, x as FsMemoryStore, xt as mergeCatalogEntries, y as ExternalToolSource, yt as fromVercelStreamPart, z as READ_SKILL_FILE_TOOL_NAME } from "./index-CySxIvRz.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 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 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, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, 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
- import { A as validateSkills, C as parseSkillPackManifest, D as resolveArchiveLimits, E as renderCatalogJson, M as xmlRenderer, O as resolveInsideRoot, S as parseSkillMarkdown, T as renderAvailableSkillsXml, _ as escapeXml, a as SKILL_NAME_MAX_LENGTH, b as jsonRenderer, c as SkillDiscovery, d as assertSafePathSegment, f as buildCatalog, g as computeDigest, h as checkSkillRules, i as SKILL_MANIFEST_FILE, j as verifyManifest, k as unzipWithLimits, l as SkillReader, m as checkDependencyCycles, n as MemoryFS, o as SKILL_NAME_PATTERN, p as buildManifest, r as SKILLS_LOCKFILE, s as SKILL_PACK_FILE, t as DEFAULT_ARCHIVE_LIMITS, u as WebSkillError, v as exportSkills, w as readResponseWithLimit, x as normalizePath, y as isValidSkillName } from "./dist-fZFZaf43.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-DuGN5x0v.js";
1
+ import { A as unzipWithLimits, C as parseSkillMarkdown, D as renderCatalogJson, E as renderAvailableSkillsXml, M as verifyManifest, N as xmlRenderer, O as resolveArchiveLimits, S as normalizePath, T as readResponseWithLimit, _ as computeDigest, a as SKILL_NAME_MAX_LENGTH, b as isValidSkillName, c as SkillDiscovery, d as assertSafePathSegment, f as atomicWriteText, g as checkSkillRules, h as checkDependencyCycles, i as SKILL_MANIFEST_FILE, j as validateSkills, k as resolveInsideRoot, l as SkillReader, m as buildManifest, n as MemoryFS, o as SKILL_NAME_PATTERN, p as buildCatalog, r as SKILLS_LOCKFILE, s as SKILL_PACK_FILE, t as DEFAULT_ARCHIVE_LIMITS, u as WebSkillError, v as escapeXml, w as parseSkillPackManifest, x as jsonRenderer, y as exportSkills } from "./dist-D0saNPi_.js";
2
+ import { A as isNetworkAllowed, C as bridgeError, D as extractChartSpec, E as createWebSkillApi, F as resolveToolName, I as schemaToForm, L as toLlmToolSpec, M as networkUrlHost, N as normalizeToolContent, O as fromVercelResult, P as parseBridgeRequest, R as toVercelToolSpecs, 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 } from "./dist-BS5OpedX.js";
3
3
 
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, 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, readResponseWithLimit, renderAvailableSkillsXml, renderCatalogJson, resolveArchiveLimits, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, unzipWithLimits, validateSkills, verifyManifest, xmlRenderer };
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, assertSafePathSegment, atomicWriteText, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, 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
- import { F as SkillDocument, N as SkillCatalogEntry, T as JsonSchema, m as LlmToolSpec } from "./types-CgNC-oQu-DEcIBJKG.js";
2
- import { nt as ToolResult, v as ExternalSkillProvider, y as ExternalToolSource, yt as mergeCatalogEntries } from "./index-COuOu6gw.js";
1
+ import { F as SkillDocument, N as SkillCatalogEntry, T as JsonSchema, m as LlmToolSpec } from "./types-CKm5G_eQ-8W8FnP4u.js";
2
+ import { it as ToolResult, v as ExternalSkillProvider, xt as mergeCatalogEntries, y as ExternalToolSource } from "./index-CySxIvRz.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";
@@ -182,7 +182,7 @@ interface ServedSkill {
182
182
  }>;
183
183
  }
184
184
  /** 注册端:在页面 MCP server 上一行声明动态技能(prompt + resources + tools) */
185
- declare function serveSkillAsMcp(server: McpServer, skill: ServedSkill): void;
185
+ declare function serveSkillAsMcp(server: McpServer, skill: ServedSkill): Promise<void>;
186
186
  //#endregion
187
187
  //#region src/skills/catalogMerge.d.ts
188
188
  /**
package/dist/mcp.js CHANGED
@@ -1,9 +1,5 @@
1
- import { u as WebSkillError } from "./dist-fZFZaf43.js";
2
- import { A as mergeCatalogEntries, M as normalizeToolContent } from "./dist-DuGN5x0v.js";
3
- import { fromJSONSchema } from "zod";
4
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
5
- import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
6
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
1
+ import { u as WebSkillError } from "./dist-D0saNPi_.js";
2
+ import { N as normalizeToolContent, j as mergeCatalogEntries } from "./dist-BS5OpedX.js";
7
3
 
8
4
  //#region ../mcp/dist/index.js
9
5
  /**
@@ -346,8 +342,15 @@ var TemporarySkillProvider = class {
346
342
  }
347
343
  }
348
344
  };
345
+ async function loadFromJSONSchema() {
346
+ try {
347
+ return (await import("zod")).fromJSONSchema;
348
+ } catch (e) {
349
+ throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", "The \"zod\" package is required to serve skills as MCP tools; install it first (npm i zod)", e);
350
+ }
351
+ }
349
352
  /** 注册端:在页面 MCP server 上一行声明动态技能(prompt + resources + tools) */
350
- function serveSkillAsMcp(server, skill) {
353
+ async function serveSkillAsMcp(server, skill) {
351
354
  server.registerPrompt(skill.name, { description: skill.description }, async () => ({ messages: [{
352
355
  role: "user",
353
356
  content: {
@@ -362,7 +365,7 @@ function serveSkillAsMcp(server, skill) {
362
365
  }] }));
363
366
  for (const tool of skill.tools ?? []) server.registerTool(tool.name, {
364
367
  description: tool.description ?? "",
365
- ...tool.inputSchema ? { inputSchema: fromJSONSchema(tool.inputSchema) } : {}
368
+ ...tool.inputSchema ? { inputSchema: (await loadFromJSONSchema())(tool.inputSchema) } : {}
366
369
  }, async (args) => {
367
370
  return { content: normalizeToolContent(await tool.handler(args ?? {})).map((item) => item.type === "text" ? {
368
371
  type: "text",
@@ -521,6 +524,22 @@ var McpRuntimePlugin = class {
521
524
  };
522
525
  }
523
526
  };
527
+ async function loadMcpSdk() {
528
+ try {
529
+ const [client, sse, streamable] = await Promise.all([
530
+ import("@modelcontextprotocol/sdk/client/index.js"),
531
+ import("@modelcontextprotocol/sdk/client/sse.js"),
532
+ import("@modelcontextprotocol/sdk/client/streamableHttp.js")
533
+ ]);
534
+ return {
535
+ Client: client.Client,
536
+ SSEClientTransport: sse.SSEClientTransport,
537
+ StreamableHTTPClientTransport: streamable.StreamableHTTPClientTransport
538
+ };
539
+ } catch (e) {
540
+ throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", "The \"@modelcontextprotocol/sdk\" package is required for remote MCP endpoints; install it first (npm i @modelcontextprotocol/sdk)", e);
541
+ }
542
+ }
524
543
  const messageOf = (e) => e instanceof Error ? e.message : String(e);
525
544
  /**
526
545
  * 远程 MCP endpoint 装配:SDK 官方 StreamableHTTPClientTransport(默认)/
@@ -529,6 +548,7 @@ const messageOf = (e) => e instanceof Error ? e.message : String(e);
529
548
  * 返回 close 句柄:断开后 unregister(临时技能随既有生命周期自然消失)。
530
549
  */
531
550
  async function connectRemoteEndpoint(registry, config) {
551
+ const { Client, SSEClientTransport, StreamableHTTPClientTransport } = await loadMcpSdk();
532
552
  const url = new URL(config.url);
533
553
  const requestInit = config.headers ? { headers: config.headers } : void 0;
534
554
  const transport = config.transport === "sse" ? new SSEClientTransport(url, { ...requestInit ? { requestInit } : {} }) : new StreamableHTTPClientTransport(url, { ...requestInit ? { requestInit } : {} });
package/dist/node.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { D as SKILLS_LOCKFILE, I as SkillInstallSource, K as VerifyResult, O as SKILL_MANIFEST_FILE, W as SkillsLockfile, z as SkillManifest } from "./types-CgNC-oQu-DEcIBJKG.js";
2
- import { pt as createScriptContext } from "./index-COuOu6gw.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-Bun1aEf4.js";
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 };
1
+ import { D as SKILLS_LOCKFILE, I as SkillInstallSource, K as VerifyResult, O as SKILL_MANIFEST_FILE, W as SkillsLockfile, z as SkillManifest } from "./types-CKm5G_eQ-8W8FnP4u.js";
2
+ import { ht as createScriptContext } from "./index-CySxIvRz.js";
3
+ import { n as LlmEnvConfig, s as probeLlmCapabilities, t as LlmCapabilities } from "./env-BPUBZCwJ-4jat_SVG.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 SandboxOptions, t as CliUiBridge, u as exportArchive } from "./index-Vn63HJRO.js";
5
+ export { CliUiBridge, FileArtifactStore, FileMemoryStore, type LlmCapabilities, type LlmEnvConfig, NodeFS, NodeScriptExecutor, OxcSchemaInferer, 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,5 +1,6 @@
1
- import { i as SKILL_MANIFEST_FILE, r as SKILLS_LOCKFILE } from "./dist-fZFZaf43.js";
2
- import { w as createScriptContext } from "./dist-DuGN5x0v.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-LIFS3ZjI.js";
1
+ import { i as SKILL_MANIFEST_FILE, r as SKILLS_LOCKFILE } from "./dist-D0saNPi_.js";
2
+ import { T as createScriptContext } from "./dist-BS5OpedX.js";
3
+ import { i as probeLlmCapabilities } from "./env--jJB-TSX-04klhTYi.js";
4
+ import { a as NodeScriptExecutor, c as SkillManager, i as NodeFS, l as exportArchive, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as readArchiveManifest } from "./dist-Dj6QjHBn.js";
4
5
 
5
- export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
6
+ export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, exportArchive, probeLlmCapabilities, readArchiveManifest };
@@ -1,4 +1,4 @@
1
- import { u as WebSkillError } from "./dist-fZFZaf43.js";
1
+ import { u as WebSkillError } from "./dist-D0saNPi_.js";
2
2
 
3
3
  //#region ../runtime/dist/testing.js
4
4
  /**
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,5 @@
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-DEcIBJKG.js";
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-CKm5G_eQ-8W8FnP4u.js";
2
+ import { a as loadGoogleConfigFromEnv, i as loadAnthropicConfigFromEnv, n as LlmEnvConfig, o as loadLlmConfigFromEnv, r as ProviderEnvConfig } from "./env-BPUBZCwJ-4jat_SVG.js";
2
3
  //#region ../runtime/dist/testing.d.ts
3
4
  //#region src/llm/mockLlmClient.d.ts
4
5
  type MockLlmHandler = (input: LlmCompleteInput) => LlmResponse | Promise<LlmResponse>;
@@ -70,4 +71,4 @@ declare class MemoryArtifactStore implements ArtifactStore {
70
71
  listArtifacts(runId: string): Promise<Artifact[]>;
71
72
  }
72
73
  //#endregion
73
- export { InMemoryStore, MemoryArtifactStore, MockLlmClient, type MockLlmHandler, type MockLlmQueueItem, type MockUiAnswer, MockUiBridge };
74
+ export { InMemoryStore, type LlmEnvConfig, MemoryArtifactStore, MockLlmClient, type MockLlmHandler, type MockLlmQueueItem, type MockUiAnswer, MockUiBridge, type ProviderEnvConfig, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv };
package/dist/testing.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { t as MemoryArtifactStore } from "./memoryArtifactStore-C9lFVqPF-yFz6yJj0.js";
2
- import { n as MockLlmClient, r as MockUiBridge, t as InMemoryStore } from "./testing-BmR48Pn1.js";
2
+ import { n as loadGoogleConfigFromEnv, r as loadLlmConfigFromEnv, t as loadAnthropicConfigFromEnv } from "./env--jJB-TSX-04klhTYi.js";
3
+ import { n as MockLlmClient, r as MockUiBridge, t as InMemoryStore } from "./testing-B4pq6JYa.js";
3
4
 
4
- export { InMemoryStore, MemoryArtifactStore, MockLlmClient, MockUiBridge };
5
+ export { InMemoryStore, MemoryArtifactStore, MockLlmClient, MockUiBridge, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv };