@webskill/sdk 0.1.4 → 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,4 +1,4 @@
1
- import { A as SkillCatalog, C as JsonSchema, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, P as SkillInstallSource, S as FileSystemProvider, U as ValidationReport, _ as RenderResultRequest, a as InteractionPolicy, b as DiscoveryResult, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, j as SkillCatalogEntry, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.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 {
@@ -263,6 +263,14 @@ interface AgentLoopConfig {
263
263
  temperature?: number;
264
264
  /** 设为 'off' 时完成 run 不调用 uiBridge.renderResult */
265
265
  renderResult?: 'off';
266
+ /** 工具结果回喂上限(字节,默认 100_000;超长头尾保留 + 完整内容落 artifact) */
267
+ toolResultMaxBytes?: number;
268
+ }
269
+ /** 技能状态拦截 port(治理装配;无注入默认全放行) */
270
+ interface SkillStateGuard {
271
+ canRead?(skillName: string): boolean | Promise<boolean>;
272
+ canActivate?(skillName: string): boolean | Promise<boolean>;
273
+ canExecute?(skillName: string): boolean | Promise<boolean>;
266
274
  }
267
275
  interface RuntimeSession {
268
276
  id: string;
@@ -287,6 +295,12 @@ interface RuntimeRun {
287
295
  interface RunResult {
288
296
  output: string;
289
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>;
290
304
  }
291
305
  //#endregion
292
306
  //#region src/interaction/renderResult.d.ts
@@ -409,6 +423,26 @@ declare class FsMemoryStore implements MemoryStore {
409
423
  clear(scope?: string): Promise<void>;
410
424
  }
411
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
412
446
  //#region src/artifacts/fsArtifactStore.d.ts
413
447
  /**
414
448
  * 基于 FileSystemProvider 的 ArtifactStore:产物落盘 <root>/<runId>/<path>,
@@ -523,6 +557,8 @@ declare class CapabilityApproval {
523
557
  uiBridge?: UiBridge;
524
558
  scope?: ApprovalScope;
525
559
  });
560
+ /** run 终态清理授权记录(宿主在 run 结束后调用;同时有 LRU 上限兜底) */
561
+ clearRun(runId: string): void;
526
562
  authorize(input: {
527
563
  runId: string;
528
564
  capability: BridgeCapability;
@@ -592,6 +628,10 @@ interface RunSnapshot {
592
628
  activatedTools: ToolDefinition[];
593
629
  /** 等待中的交互(恢复时重新发起,表单重新渲染) */
594
630
  pendingInteraction: InteractionRequest;
631
+ /** $chart 等内容收集的渲染块(0.2.0 起跨 resume 保留;旧快照缺省视为空) */
632
+ renderBlocks?: RenderBlock[];
633
+ /** 交互 id 序号(resume 后续算,避免 id 冲突;旧快照缺省从 0 起) */
634
+ interactionSeq?: number;
595
635
  /** 进入 interrupted 时计算的过期时间 */
596
636
  interactionExpiresAt: string;
597
637
  config: {
@@ -612,6 +652,10 @@ interface RunSnapshotStore {
612
652
  /**
613
653
  * FileSystemProvider 后端的快照存储:<root>/<runId>.snapshot.json。
614
654
  * 坏 JSON → RUN_SNAPSHOT_INCOMPATIBLE 并自动清理坏文件;runId 过路径安全校验。
655
+ * save/list 时顺带清理已过 interactionExpiresAt 的过期快照。
656
+ *
657
+ * 数据敏感性说明:快照含完整对话历史(用户输入、工具结果、可能的凭据片段),
658
+ * 以明文 JSON 落盘于宿主提供的 fs;宿主应将其视为会话数据同等保护。
615
659
  * @experimental
616
660
  */
617
661
  declare class FsRunSnapshotStore implements RunSnapshotStore {
@@ -657,6 +701,8 @@ interface AgentLoopDeps {
657
701
  skillProviders?: ExternalSkillProvider[];
658
702
  /** Catalog 过滤钩子(治理状态拦截路由,如 quarantined/deprecated 过滤) */
659
703
  catalogFilter?: (entries: SkillCatalogEntry[]) => SkillCatalogEntry[] | Promise<SkillCatalogEntry[]>;
704
+ /** 技能状态拦截(read/activate/execute 三入口一致执行;无注入默认全放行) */
705
+ skillStateGuard?: SkillStateGuard;
660
706
  /** D3:interrupt 点快照存储(无配置则行为与现状完全一致) */
661
707
  snapshotStore?: RunSnapshotStore;
662
708
  }
@@ -673,6 +719,8 @@ declare class AgentLoop {
673
719
  userPrompt: string;
674
720
  route: RouteResult;
675
721
  runId?: string;
722
+ /** 多会话历史延续:插入 system 与本轮 user 之间(不含 system 消息) */
723
+ history?: LlmMessage[];
676
724
  }): Promise<RunResult>;
677
725
  /**
678
726
  * D3 恢复:以快照重建 LoopState,重新发起等待中的交互(表单重新渲染),
@@ -719,6 +767,8 @@ interface WebSkillRuntimeDeps {
719
767
  }) => Promise<void>;
720
768
  /** D3:interrupt 点快照存储(配置后 interrupted run 可 resumeRun 恢复) */
721
769
  snapshotStore?: RunSnapshotStore;
770
+ /** 技能状态拦截 port(治理 SkillStatePolicy.toSkillStateGuard 装配;无注入默认全放行) */
771
+ skillStateGuard?: SkillStateGuard;
722
772
  }
723
773
  /**
724
774
  * runtime 门面:组合 discovery / router / agent loop / lifecycle
@@ -730,8 +780,23 @@ declare class WebSkillRuntime {
730
780
  get session(): RuntimeSession;
731
781
  /** 生命周期事件总线(只读观测) */
732
782
  get events(): EventBus;
783
+ /**
784
+ * Catalog 缓存失效:下次 run/discover 重新扫描技能目录。
785
+ * 与 SkillManager onChanged 接线:`new SkillManager({ ..., onChanged: () => runtime.invalidate() })`。
786
+ */
787
+ invalidate(): void;
788
+ /**
789
+ * 多会话:session 对象的 run(prompt) 跨 run 延续消息历史(同一 session 对话上下文连续)。
790
+ * 既有 runtime.run(prompt) 保持无状态单次语义不变。
791
+ */
792
+ createSession(options?: {
793
+ sessionId?: string;
794
+ }): RuntimeSessionHandle;
733
795
  discover(): Promise<DiscoveryResult>;
734
- run(userPrompt: string): Promise<RunResult>;
796
+ run(userPrompt: string, options?: {
797
+ sessionId?: string;
798
+ history?: LlmMessage[];
799
+ }): Promise<RunResult>;
735
800
  /** D3:列出可恢复的 interrupted run(供 UI 展示"未完成任务") */
736
801
  listInterruptedRuns(): Promise<RunSnapshot[]>;
737
802
  /**
@@ -743,4 +808,4 @@ declare class WebSkillRuntime {
743
808
  resumeRun(runId: string): Promise<RunResult>;
744
809
  }
745
810
  //#endregion
746
- export { ToolDefinition as $, LifecycleHook as A, RUN_SNAPSHOT_SCHEMA_VERSION as B, FullDisclosureRouter as C, schemaToForm as Ct, HookRunnerOptions as D, HookRunner as E, 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, resolveToolName as St, GoogleGenAiClientConfig as T, toVercelToolSpecs as Tt, RunSnapshot as U, RouteResult as V, RunSnapshotStore as W, ScriptExecutionContext as X, SchemaInferer as Y, ScriptExecutor as Z, EventBus as _, isNetworkAllowed as _t, AgentLoopConfig as a, TraceRecorder as at, FsArtifactStore as b, normalizeToolContent as bt, AnthropicClientConfig as c, WebSkillRuntime as ct, BridgeCapabilities as d, buildRenderResult as dt, ToolResolution as et, BridgeCapability as f, createScriptContext as ft, CapabilityMode as g, fromVercelStreamPart as gt, CapabilityApproval as h, fromVercelResult as ht, AgentLoop as i, TraceEventType as it, LifecycleHookContext as j, LifecycleEvent as k, ApprovalDecision as l, WebSkillRuntimeDeps as lt, BridgeResponse as m, extractChartSpec as mt, ASK_USER_TOOL as n, TraceClock as nt, AgentLoopDeps as o, VercelToolSpec as ot, BridgeRequest as p, createWebSkillApi as pt, RuntimeRun as q, ASK_USER_TOOL_NAME as r, TraceEvent as rt, AnthropicClient as s, WebSkillApi as st, ASK_USER_INPUT_SCHEMA as t, ToolResult as tt, ApprovalScope as u, bridgeError as ut, ExternalSkillProvider as v, mergeCatalogEntries as vt, GoogleGenAiClient as w, toLlmToolSpec as wt, FsMemoryStore as x, parseBridgeRequest as xt, ExternalToolSource as y, networkUrlHost 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 JsonSchema, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, S as FileSystemProvider, W as VerifyResult, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, x as FileStat } from "./types-CgNC-oQu-DYrxhD3z.js";
2
- import { $ as ToolDefinition, N as NetworkPolicy, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, b as FsArtifactStore, d as BridgeCapabilities, tt as ToolResult, u as ApprovalScope, x as FsMemoryStore } from "./index-BSS3EWY-.js";
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
@@ -158,7 +159,13 @@ declare class SkillManager {
158
159
  fetchImpl?: typeof fetch;
159
160
  /** D2 安装期 schema 预推导(默认 true,可关) */
160
161
  schemaInference?: boolean;
162
+ /** 归档体积三重上限(缺省 DEFAULT_ARCHIVE_LIMITS) */
163
+ archiveLimits?: ArchiveLimits;
164
+ /** install/uninstall 成功后的变更回调(宿主接线缓存失效,如 WebSkillRuntime.invalidate) */
165
+ onChanged?: () => void;
161
166
  });
167
+ /** 托管根目录(治理发布归档捕获等只读场景) */
168
+ get managedRoot(): string;
162
169
  install(source: SkillInstallSource, options?: {
163
170
  expectedSha256?: string;
164
171
  }): Promise<SkillManifest>;
@@ -176,42 +183,12 @@ declare class SkillManager {
176
183
  }
177
184
  //#endregion
178
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>;
179
191
  /** 只解出归档中的 webskill.skill-manifest.json 条目(安装前预览) */
180
192
  declare function readArchiveManifest(fs: FileSystemProvider, archivePath: string): Promise<SkillManifest>;
181
193
  //#endregion
182
- //#region src/env.d.ts
183
- interface LlmEnvConfig {
184
- baseUrl: string;
185
- apiKey: string;
186
- model: string;
187
- }
188
- /** per-provider env 配置(baseUrl 可选,客户端自带默认) */
189
- interface ProviderEnvConfig {
190
- apiKey: string;
191
- model: string;
192
- baseUrl?: string;
193
- }
194
- /**
195
- * 读取 VITE_BASE_URL / VITE_API_KEY / VITE_MODEL_NAME;缺项返回 undefined 供测试 skip 判断。
196
- */
197
- declare function loadLlmConfigFromEnv(dotenvPath?: string): LlmEnvConfig | undefined;
198
- /** ANTHROPIC_API_KEY / ANTHROPIC_MODEL(可选 ANTHROPIC_BASE_URL);缺项返回 undefined */
199
- declare function loadAnthropicConfigFromEnv(dotenvPath?: string): ProviderEnvConfig | undefined;
200
- /** GOOGLE_API_KEY / GOOGLE_MODEL(可选 GOOGLE_BASE_URL);缺项返回 undefined */
201
- declare function loadGoogleConfigFromEnv(dotenvPath?: string): ProviderEnvConfig | undefined;
202
- interface LlmCapabilities {
203
- available: boolean;
204
- nonStreaming: boolean;
205
- reason?: string;
206
- }
207
- /**
208
- * 探测 LLM 能力(结果模块级缓存):
209
- * - available:GET /models 可达(与 checkAvailability 同语义)
210
- * - nonStreaming:最小非流式 chat completion(max_tokens=1,短超时);
211
- * HTTP 400/404 或明确不支持非流式的错误 → false
212
- * - streaming 能力由 available 推断(SSE 解析在 SDK 侧实现)
213
- * 环境变量 VITE_LLM_NON_STREAMING=0 可显式强制 nonStreaming=false(模拟流式-only 回归)。
214
- */
215
- declare function probeLlmCapabilities(config: LlmEnvConfig): Promise<LlmCapabilities>;
216
- //#endregion
217
- 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 escapeXml, A as SkillCatalog, B as SkillReader, C as JsonSchema, D as SKILL_NAME_MAX_LENGTH, E as SKILL_MANIFEST_FILE, F as SkillIssue, G as WebSkillError, H as SkillsLockfile, I as SkillLocation, J as buildCatalog, K as WebSkillErrorCode, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, O as SKILL_NAME_PATTERN, P as SkillInstallSource, Q as computeDigest, R as SkillMetadata, S as FileSystemProvider, T as SKILLS_LOCKFILE, U as ValidationReport, V as SkillSource, W as VerifyResult, X as checkDependencyCycles, Y as buildManifest, Z as checkSkillRules, _ as RenderResultRequest, a as InteractionPolicy, at as parseSkillPackManifest, b as DiscoveryResult, c as LlmClient, ct as resolveInsideRoot, d as LlmResponse, dt as xmlRenderer, et as exportSkills, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, it as parseSkillMarkdown, j as SkillCatalogEntry, k as SKILL_PACK_FILE, l as LlmCompleteInput, lt as validateSkills, m as LlmToolSpec, n as ArtifactStore, nt as jsonRenderer, o as InteractionRequest, ot as renderAvailableSkillsXml, p as LlmToolCall, q as assertSafePathSegment, r as ChartSpec, rt as normalizePath, s as InteractionResponse, st as renderCatalogJson, t as Artifact, tt as isValidSkillName, u as LlmMessage, ut as verifyManifest, v as UiBridge, w as MemoryFS, x as FileStat, y as CatalogRenderer, z as SkillPackManifest } from "./types-CgNC-oQu-DYrxhD3z.js";
2
- import { $ as ToolDefinition, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as schemaToForm, D as HookRunnerOptions, E as HookRunner, F as OpenAiCompatibleClientConfig, G as RunTerminationReason, H as RunResult, I as ProgressiveRouter, J as RuntimeSession, K as RuntimePhase, L as READ_SKILL_FILE_INPUT_SCHEMA, M as LifecycleListener, N as NetworkPolicy, O as InstalledSkillManifest, P as OpenAiCompatibleClient, Q as SkillRouter, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as resolveToolName, T as GoogleGenAiClientConfig, Tt as toVercelToolSpecs, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, _ as EventBus, _t as isNetworkAllowed, a as AgentLoopConfig, at as TraceRecorder, b as FsArtifactStore, bt as normalizeToolContent, c as AnthropicClientConfig, ct as WebSkillRuntime, d as BridgeCapabilities, dt as buildRenderResult, et as ToolResolution, f as BridgeCapability, ft as createScriptContext, g as CapabilityMode, gt as fromVercelStreamPart, h as CapabilityApproval, ht as fromVercelResult, i as AgentLoop, it as TraceEventType, j as LifecycleHookContext, k as LifecycleEvent, l as ApprovalDecision, lt as WebSkillRuntimeDeps, m as BridgeResponse, mt as extractChartSpec, n as ASK_USER_TOOL, nt as TraceClock, o as AgentLoopDeps, ot as VercelToolSpec, p as BridgeRequest, pt as createWebSkillApi, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as TraceEvent, s as AnthropicClient, st as WebSkillApi, t as ASK_USER_INPUT_SCHEMA, tt as ToolResult, u as ApprovalScope, ut as bridgeError, v as ExternalSkillProvider, vt as mergeCatalogEntries, w as GoogleGenAiClient, wt as toLlmToolSpec, x as FsMemoryStore, xt as parseBridgeRequest, y as ExternalToolSource, yt as networkUrlHost, z as READ_SKILL_FILE_TOOL_NAME } from "./index-BSS3EWY-.js";
3
- export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, AnthropicClient, type AnthropicClientConfig, type ApprovalDecision, type ApprovalScope, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, type DiscoveryResult, EventBus, type ExternalSkillProvider, type ExternalToolSource, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, type GoogleGenAiClientConfig, HookRunner, type HookRunnerOptions, type InstalledSkillManifest, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillInstallSource, type SkillIssue, type SkillLocation, type SkillManifest, type SkillMetadata, type SkillPackManifest, SkillReader, type SkillRouter, type SkillSource, type SkillsLockfile, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
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 { C as renderAvailableSkillsXml, D as verifyManifest, E as validateSkills, O as xmlRenderer, S as parseSkillPackManifest, T as resolveInsideRoot, _ as exportSkills, a as SKILL_NAME_PATTERN, b as normalizePath, c as SkillReader, d as buildCatalog, f as buildManifest, g as escapeXml, h as computeDigest, i as SKILL_NAME_MAX_LENGTH, l as WebSkillError, m as checkSkillRules, n as SKILLS_LOCKFILE, o as SKILL_PACK_FILE, p as checkDependencyCycles, r as SKILL_MANIFEST_FILE, s as SkillDiscovery, t as MemoryFS, u as assertSafePathSegment, v as isValidSkillName, w as renderCatalogJson, x as parseSkillMarkdown, y as jsonRenderer } from "./dist-DvoBsChX.js";
2
- import { A as mergeCatalogEntries, C as buildRenderResult, D as fromVercelResult, E as extractChartSpec, F as schemaToForm, I as toLlmToolSpec, L as toVercelToolSpecs, M as normalizeToolContent, N as parseBridgeRequest, O as fromVercelStreamPart, P as resolveToolName, S as bridgeError, T as createWebSkillApi, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as TraceRecorder, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as networkUrlHost, k as isNetworkAllowed, l as FsMemoryStore, m as OpenAiCompatibleClient, n as ASK_USER_TOOL, o as CapabilityApproval, p as HookRunner, r as ASK_USER_TOOL_NAME, s as EventBus, t as ASK_USER_INPUT_SCHEMA, u as FsRunSnapshotStore, v as READ_SKILL_FILE_TOOL_NAME, w as createScriptContext, x as WebSkillRuntime, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-DAn07zHu.js";
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, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
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 { C as JsonSchema, N as SkillDocument, j as SkillCatalogEntry, m as LlmToolSpec } from "./types-CgNC-oQu-DYrxhD3z.js";
2
- import { tt as ToolResult, v as ExternalSkillProvider, vt as mergeCatalogEntries, y as ExternalToolSource } from "./index-BSS3EWY-.js";
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 { l as WebSkillError } from "./dist-DvoBsChX.js";
2
- import { A as mergeCatalogEntries, M as normalizeToolContent } from "./dist-DAn07zHu.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
  /**
@@ -44,6 +40,8 @@ var MessageChannelTransport = class {
44
40
  onmessage;
45
41
  #port;
46
42
  #allowedOrigins;
43
+ /** 用户显式传入 allowedOrigins(区别于 window 环境自动推导):空 origin 默认拒绝 */
44
+ #explicitOrigins;
47
45
  #strictOrigin;
48
46
  #connectionTimeoutMs;
49
47
  #state = "idle";
@@ -53,6 +51,7 @@ var MessageChannelTransport = class {
53
51
  this.#port = port;
54
52
  this.#strictOrigin = options.strictOrigin ?? false;
55
53
  this.#connectionTimeoutMs = options.connectionTimeoutMs ?? 0;
54
+ this.#explicitOrigins = options.allowedOrigins !== void 0;
56
55
  if (options.allowedOrigins !== void 0) this.#allowedOrigins = options.allowedOrigins;
57
56
  else {
58
57
  const origin = currentOrigin();
@@ -92,7 +91,10 @@ var MessageChannelTransport = class {
92
91
  #originAllowed(origin) {
93
92
  if (this.#allowedOrigins === void 0) return true;
94
93
  if (this.#allowedOrigins.includes("*")) return true;
95
- if (origin === void 0 || origin === "") return !this.#strictOrigin;
94
+ if (origin === void 0 || origin === "") {
95
+ if (this.#explicitOrigins) return false;
96
+ return !this.#strictOrigin;
97
+ }
96
98
  return this.#allowedOrigins.includes(origin);
97
99
  }
98
100
  #onInbound(event) {
@@ -340,8 +342,15 @@ var TemporarySkillProvider = class {
340
342
  }
341
343
  }
342
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
+ }
343
352
  /** 注册端:在页面 MCP server 上一行声明动态技能(prompt + resources + tools) */
344
- function serveSkillAsMcp(server, skill) {
353
+ async function serveSkillAsMcp(server, skill) {
345
354
  server.registerPrompt(skill.name, { description: skill.description }, async () => ({ messages: [{
346
355
  role: "user",
347
356
  content: {
@@ -356,7 +365,7 @@ function serveSkillAsMcp(server, skill) {
356
365
  }] }));
357
366
  for (const tool of skill.tools ?? []) server.registerTool(tool.name, {
358
367
  description: tool.description ?? "",
359
- ...tool.inputSchema ? { inputSchema: fromJSONSchema(tool.inputSchema) } : {}
368
+ ...tool.inputSchema ? { inputSchema: (await loadFromJSONSchema())(tool.inputSchema) } : {}
360
369
  }, async (args) => {
361
370
  return { content: normalizeToolContent(await tool.handler(args ?? {})).map((item) => item.type === "text" ? {
362
371
  type: "text",
@@ -515,6 +524,22 @@ var McpRuntimePlugin = class {
515
524
  };
516
525
  }
517
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
+ }
518
543
  const messageOf = (e) => e instanceof Error ? e.message : String(e);
519
544
  /**
520
545
  * 远程 MCP endpoint 装配:SDK 官方 StreamableHTTPClientTransport(默认)/
@@ -523,6 +548,7 @@ const messageOf = (e) => e instanceof Error ? e.message : String(e);
523
548
  * 返回 close 句柄:断开后 unregister(临时技能随既有生命周期自然消失)。
524
549
  */
525
550
  async function connectRemoteEndpoint(registry, config) {
551
+ const { Client, SSEClientTransport, StreamableHTTPClientTransport } = await loadMcpSdk();
526
552
  const url = new URL(config.url);
527
553
  const requestInit = config.headers ? { headers: config.headers } : void 0;
528
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 { E as SKILL_MANIFEST_FILE, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, T as SKILLS_LOCKFILE, W as VerifyResult } from "./types-CgNC-oQu-DYrxhD3z.js";
2
- import { ft as createScriptContext } from "./index-BSS3EWY-.js";
3
- import { _ as readArchiveManifest, a as LlmEnvConfig, c as OxcSchemaInferer, d as SandboxedScriptExecutor, f as SkillManager, g as probeLlmCapabilities, h as loadLlmConfigFromEnv, i as LlmCapabilities, l as ProviderEnvConfig, m as loadGoogleConfigFromEnv, n as FileArtifactStore, o as NodeFS, p as loadAnthropicConfigFromEnv, r as FileMemoryStore, s as NodeScriptExecutor, t as CliUiBridge, u as SandboxOptions } from "./index-npFMt2Zw.js";
4
- 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 { n as SKILLS_LOCKFILE, r as SKILL_MANIFEST_FILE } from "./dist-DvoBsChX.js";
2
- import { w as createScriptContext } from "./dist-DAn07zHu.js";
3
- import { a as NodeScriptExecutor, c as SkillManager, d as loadLlmConfigFromEnv, f as probeLlmCapabilities, i as NodeFS, l as loadAnthropicConfigFromEnv, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as loadGoogleConfigFromEnv } from "./dist-BVXZF7H_.js";
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,6 +1,9 @@
1
1
  import { register } from "node:module";
2
+ import path from "node:path";
3
+ import { tmpdir } from "node:os";
2
4
  import { pathToFileURL } from "node:url";
3
5
  import { isMainThread, parentPort, workerData } from "node:worker_threads";
6
+ import { mkdtemp, rm, writeFile } from "node:fs/promises";
4
7
 
5
8
  //#region ../node/dist/executor/sandboxWorkerEntry.js
6
9
  /**
@@ -47,7 +50,21 @@ function callCapability(kind, payload) {
47
50
  return r.value;
48
51
  });
49
52
  }
50
- async function loadModule(scriptPath) {
53
+ async function loadModule(scriptPath, scriptSource) {
54
+ if (scriptPath.endsWith(".js") && scriptSource !== void 0) return await import(`data:text/javascript;charset=utf-8,${encodeURIComponent(`${scriptSource}\n//# ${Date.now()}`)}`);
55
+ if (scriptPath.endsWith(".ts") && scriptSource !== void 0) {
56
+ const dir = await mkdtemp(path.join(tmpdir(), "webskill-ts-"));
57
+ try {
58
+ const file = path.join(dir, "script.ts");
59
+ await writeFile(file, scriptSource);
60
+ return await import(`${pathToFileURL(file).href}?t=${Date.now()}`);
61
+ } finally {
62
+ await rm(dir, {
63
+ recursive: true,
64
+ force: true
65
+ });
66
+ }
67
+ }
51
68
  return await import(`${pathToFileURL(scriptPath).href}?t=${Date.now()}`);
52
69
  }
53
70
  function post(message) {
@@ -129,7 +146,7 @@ async function main() {
129
146
  });
130
147
  if (task.mode === "load") {
131
148
  try {
132
- const mod = await loadModule(task.scriptPath);
149
+ const mod = await loadModule(task.scriptPath, task.scriptSource);
133
150
  post({
134
151
  type: "load-result",
135
152
  ok: true,
@@ -163,7 +180,7 @@ async function main() {
163
180
  console.log = console.info = console.debug = (...args) => stdout.push(args.map(String).join(" "));
164
181
  console.warn = console.error = (...args) => stderr.push(args.map(String).join(" "));
165
182
  try {
166
- const mod = await loadModule(task.scriptPath);
183
+ const mod = await loadModule(task.scriptPath, task.scriptSource);
167
184
  if (typeof mod["run"] !== "function") throw new Error("Script does not export a run function");
168
185
  const context = {
169
186
  skillName: task.skillName ?? "",
@@ -1,4 +1,4 @@
1
- import { l as WebSkillError } from "./dist-DvoBsChX.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-DYrxhD3z.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-S8SN9Lc6.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 };
@@ -74,7 +74,12 @@ interface SkillsLockfile {
74
74
  }
75
75
  interface VerifyResult {
76
76
  ok: boolean;
77
+ /** 清单与实际均存在但 sha256 不一致的文件 */
77
78
  mismatches: string[];
79
+ /** 实际目录存在但清单未登记的文件(有 extra 即 ok:false) */
80
+ extras: string[];
81
+ /** 清单登记但实际目录缺失的文件 */
82
+ missing: string[];
78
83
  }
79
84
  /** 技能目录内的安装清单文件名(不参与 files 列表与 digest) */
80
85
  declare const SKILL_MANIFEST_FILE = "webskill.skill-manifest.json";
@@ -95,8 +100,8 @@ declare function buildManifest(input: {
95
100
  files: SkillManifest['files'];
96
101
  sha256: Sha256Fn;
97
102
  }): Promise<SkillManifest>;
98
- /** 按 manifest.files 比对实际 hash(调用方负责计算 actualHashes) */
99
- declare function verifyManifest(manifest: SkillManifest, actualHashes: Map<string, string>): VerifyResult;
103
+ /** 按 manifest.files 比对实际 hash 与文件集(mismatches/extras/missing 三类全空才 ok) */
104
+ declare function verifyManifest(manifest: SkillManifest, actualHashes: Map<string, string>, actualFiles?: string[]): VerifyResult;
100
105
  //#endregion
101
106
  //#region src/fs/types.d.ts
102
107
  interface FileStat {
@@ -122,6 +127,8 @@ interface FileSystemProvider {
122
127
  remove(path: string, options?: {
123
128
  recursive?: boolean;
124
129
  }): Promise<void>;
130
+ /** 原子重命名(lockfile 等先写临时文件再 rename 的场景;实现侧无原生 rename 时 copy+remove 兜底) */
131
+ rename(from: string, to: string): Promise<void>;
125
132
  }
126
133
  //#endregion
127
134
  //#region src/fs/memoryFs.d.ts
@@ -141,8 +148,13 @@ declare class MemoryFS implements FileSystemProvider {
141
148
  remove(path: string, options?: {
142
149
  recursive?: boolean;
143
150
  }): Promise<void>;
151
+ rename(from: string, to: string): Promise<void>;
144
152
  }
145
153
  //#endregion
154
+ //#region src/fs/atomicWrite.d.ts
155
+ /** 原子写文本:先写临时文件再 rename(进程崩溃不留下半写文件;lockfile 等账本场景) */
156
+ declare function atomicWriteText(fs: FileSystemProvider, path: string, content: string): Promise<void>;
157
+ //#endregion
146
158
  //#region src/fs/pathSecurity.d.ts
147
159
  /** 统一分隔符为 `/`,去除 `.` 段与重复分隔符(不解析 `..`) */
148
160
  declare function normalizePath(path: string): string;
@@ -279,6 +291,27 @@ declare function exportSkills(fs: FileSystemProvider, input: {
279
291
  /** 包级清单解析 + 形状校验;损坏 → INSTALL_FAILED(安装侧保证零残留) */
280
292
  declare function parseSkillPackManifest(text: string): SkillPackManifest;
281
293
  //#endregion
294
+ //#region src/skill/zipLimits.d.ts
295
+ /**
296
+ * 归档体积三重上限(node/browser 共用单一来源):
297
+ * 下载(Content-Length + 流式累计)、单条目解压后大小、总解压体积。
298
+ * fflate 流式 Unzip 逐 chunk 计量,超限即中止(zip bomb 在计量点截断)。
299
+ */
300
+ interface ArchiveLimits {
301
+ /** 下载字节上限(默认 64MB) */
302
+ maxDownloadBytes?: number;
303
+ /** 单条目解压后上限(默认 64MB) */
304
+ maxEntryBytes?: number;
305
+ /** 总解压体积上限(默认 256MB) */
306
+ maxTotalBytes?: number;
307
+ }
308
+ declare const DEFAULT_ARCHIVE_LIMITS: Required<ArchiveLimits>;
309
+ declare function resolveArchiveLimits(limits?: ArchiveLimits): Required<ArchiveLimits>;
310
+ /** 流式解 zip(单条目/总双重上限);返回 [path, content][](目录条目以 / 结尾、内容为空) */
311
+ declare function unzipWithLimits(data: Uint8Array, limits?: ArchiveLimits): Promise<Array<[string, Uint8Array]>>;
312
+ /** 下载响应体:Content-Length 预检 + 流式累计上限 */
313
+ declare function readResponseWithLimit(res: Response, limits?: ArchiveLimits): Promise<Uint8Array>;
314
+ //#endregion
282
315
  //#region src/skill/discovery.d.ts
283
316
  interface DiscoveryResult {
284
317
  entries: SkillCatalogEntry[];
@@ -339,7 +372,7 @@ declare function escapeXml(text: string): string;
339
372
  declare function renderAvailableSkillsXml(catalog: SkillCatalog): string;
340
373
  declare const xmlRenderer: CatalogRenderer;
341
374
  //#endregion
342
- //#region ../runtime/dist/types-CgNC-oQu.d.ts
375
+ //#region ../runtime/dist/types-CKm5G_eQ.d.ts
343
376
  //#region src/llm/streamTypes.d.ts
344
377
  /** 流式 LLM 事件(OpenAI SSE / Vercel fullStream 统一映射) */
345
378
  type LlmStreamEvent = {
@@ -502,6 +535,8 @@ interface RenderResultRequest {
502
535
  /** @stable */
503
536
  interface UiBridge {
504
537
  request(input: InteractionRequest): Promise<InteractionResponse>;
538
+ /** 尽力取消等待中的 request(如交互超时后清理遗留表单/提示;可选实现) */
539
+ cancel?(id: string): void | Promise<void>;
505
540
  progress?(input: {
506
541
  runId: string;
507
542
  message: string;
@@ -544,6 +579,8 @@ interface MemoryStore {
544
579
  value: unknown;
545
580
  }>>;
546
581
  clear(scope?: string): Promise<void>;
582
+ /** 可选:scope 级原子段(read-modify-write 全段串行;fn 收到底层 store,禁止重入装饰器自身) */
583
+ transaction?<T>(scope: string, fn: (inner: MemoryStore) => Promise<T>): Promise<T>;
547
584
  }
548
585
  //#endregion
549
- export { escapeXml as $, SkillCatalog as A, SkillReader as B, JsonSchema as C, SKILL_NAME_MAX_LENGTH as D, SKILL_MANIFEST_FILE as E, SkillIssue as F, WebSkillError as G, SkillsLockfile as H, SkillLocation as I, buildCatalog as J, WebSkillErrorCode as K, SkillManifest as L, SkillDiscovery as M, SkillDocument as N, SKILL_NAME_PATTERN as O, SkillInstallSource as P, computeDigest as Q, SkillMetadata as R, FileSystemProvider as S, SKILLS_LOCKFILE as T, ValidationReport as U, SkillSource as V, VerifyResult as W, checkDependencyCycles as X, buildManifest as Y, checkSkillRules as Z, RenderResultRequest as _, InteractionPolicy as a, parseSkillPackManifest as at, DiscoveryResult as b, LlmClient as c, resolveInsideRoot as ct, LlmResponse as d, xmlRenderer as dt, exportSkills as et, LlmStreamEvent as f, RenderBlock as g, MemoryStore as h, FormField as i, parseSkillMarkdown as it, SkillCatalogEntry as j, SKILL_PACK_FILE as k, LlmCompleteInput as l, validateSkills as lt, LlmToolSpec as m, ArtifactStore as n, jsonRenderer as nt, InteractionRequest as o, renderAvailableSkillsXml as ot, LlmToolCall as p, assertSafePathSegment as q, ChartSpec as r, normalizePath as rt, InteractionResponse as s, renderCatalogJson as st, Artifact as t, isValidSkillName as tt, LlmMessage as u, verifyManifest as ut, UiBridge as v, MemoryFS as w, FileStat as x, CatalogRenderer as y, SkillPackManifest as z };
586
+ export { checkDependencyCycles as $, SKILL_NAME_PATTERN as A, SkillMetadata as B, FileStat as C, SKILLS_LOCKFILE as D, MemoryFS as E, SkillDocument as F, ValidationReport as G, SkillReader as H, SkillInstallSource as I, WebSkillErrorCode as J, VerifyResult as K, SkillIssue as L, SkillCatalog as M, SkillCatalogEntry as N, SKILL_MANIFEST_FILE as O, SkillDiscovery as P, buildManifest as Q, SkillLocation as R, DiscoveryResult as S, JsonSchema as T, SkillSource as U, SkillPackManifest as V, SkillsLockfile as W, atomicWriteText as X, assertSafePathSegment as Y, buildCatalog as Z, RenderResultRequest as _, xmlRenderer as _t, InteractionPolicy as a, jsonRenderer as at, CatalogRenderer as b, LlmClient as c, parseSkillPackManifest as ct, LlmResponse as d, renderCatalogJson as dt, checkSkillRules as et, LlmStreamEvent as f, resolveArchiveLimits as ft, RenderBlock as g, verifyManifest as gt, MemoryStore as h, validateSkills as ht, FormField as i, isValidSkillName as it, SKILL_PACK_FILE as j, SKILL_NAME_MAX_LENGTH as k, LlmCompleteInput as l, readResponseWithLimit as lt, LlmToolSpec as m, unzipWithLimits as mt, ArtifactStore as n, escapeXml as nt, InteractionRequest as o, normalizePath as ot, LlmToolCall as p, resolveInsideRoot as pt, WebSkillError as q, ChartSpec as r, exportSkills as rt, InteractionResponse as s, parseSkillMarkdown as st, Artifact as t, computeDigest as tt, LlmMessage as u, renderAvailableSkillsXml as ut, UiBridge as v, FileSystemProvider as w, DEFAULT_ARCHIVE_LIMITS as x, ArchiveLimits as y, SkillManifest as z };