@webskill/sdk 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { T as validateSkills, _ as isValidSkillName, l as WebSkillError, w as resolveInsideRoot } from "./dist-DS1sfgHa.js";
2
- import { i as NodeFS } from "./dist-SarUS8EP.js";
1
+ import { E as validateSkills, T as resolveInsideRoot, l as WebSkillError, u as assertSafePathSegment, v as isValidSkillName } from "./dist-DvoBsChX.js";
2
+ import { i as NodeFS } from "./dist-BVXZF7H_.js";
3
3
  import path from "node:path";
4
4
  import { mkdtemp } from "node:fs/promises";
5
5
  import { tmpdir } from "node:os";
@@ -115,9 +115,11 @@ var CandidateStore = class {
115
115
  }
116
116
  async save(candidate) {
117
117
  validateCandidate(candidate);
118
+ assertSafePathSegment(candidate.id, "candidate id");
118
119
  await this.#fs.writeText(`${dirOf$1(this.#root)}/${candidate.id}.json`, JSON.stringify(candidate, null, 2));
119
120
  }
120
121
  async get(id) {
122
+ assertSafePathSegment(id, "candidate id");
121
123
  const path = `${dirOf$1(this.#root)}/${id}.json`;
122
124
  if (!await this.#fs.exists(path)) throw new WebSkillError("GOVERNANCE_FAILED", `Candidate not found: ${id}`);
123
125
  return JSON.parse(await this.#fs.readText(path));
@@ -370,7 +372,10 @@ var FsAuditLog = class {
370
372
  return events;
371
373
  }
372
374
  };
373
- const dirOf = (root, skillName) => `${root}/.webskill/versions/${skillName}`;
375
+ const dirOf = (root, skillName) => {
376
+ assertSafePathSegment(skillName, "skill name");
377
+ return `${root}/.webskill/versions/${skillName}`;
378
+ };
374
379
  /** 版本存储:manifest 快照 + parentVersionId 链;回滚 = 追加新版本(谱系不断) */
375
380
  var SkillVersionStore = class {
376
381
  #root;
@@ -394,6 +399,7 @@ var SkillVersionStore = class {
394
399
  reason: input.reason,
395
400
  manifest: input.manifest
396
401
  };
402
+ assertSafePathSegment(version.versionId, "version id");
397
403
  await this.#fs.writeText(`${dirOf(this.#root, skillName)}/${version.versionId}.json`, JSON.stringify(version, null, 2));
398
404
  return version;
399
405
  }
@@ -408,6 +414,7 @@ var SkillVersionStore = class {
408
414
  return out.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
409
415
  }
410
416
  async get(skillName, versionId) {
417
+ assertSafePathSegment(versionId, "version id");
411
418
  const path = `${dirOf(this.#root, skillName)}/${versionId}.json`;
412
419
  if (!await this.#fs.exists(path)) throw new WebSkillError("GOVERNANCE_FAILED", `Version "${versionId}" of skill "${skillName}" not found`);
413
420
  return JSON.parse(await this.#fs.readText(path));
@@ -535,12 +542,14 @@ var SkillStatePolicy = class {
535
542
  await this.#fs.writeText(fileOf(this.#root), JSON.stringify(data, null, 2));
536
543
  }
537
544
  async getState(skillName) {
545
+ assertSafePathSegment(skillName, "skill name");
538
546
  return (await this.#load()).states[skillName] ?? "active";
539
547
  }
540
548
  async listStates() {
541
549
  return { ...(await this.#load()).states };
542
550
  }
543
551
  async setState(skillName, state, input) {
552
+ assertSafePathSegment(skillName, "skill name");
544
553
  const data = await this.#load();
545
554
  data.states[skillName] = state;
546
555
  if (state === "active") delete data.failures[skillName];
@@ -554,6 +563,7 @@ var SkillStatePolicy = class {
554
563
  }
555
564
  /** 失败计数;达阈值(默认 3)→ quarantined + 审计 */
556
565
  async recordFailure(skillName, input = {}) {
566
+ assertSafePathSegment(skillName, "skill name");
557
567
  const data = await this.#load();
558
568
  const count = (data.failures[skillName] ?? 0) + 1;
559
569
  data.failures[skillName] = count;
@@ -621,17 +631,22 @@ function matchExpected(expected, output, run) {
621
631
  if (typeof expected === "string") return output.includes(expected);
622
632
  return expected(output, run);
623
633
  }
624
- /** 批量评估:顺序执行(单任务异常不中断批);expected 参与判定;结构化报告 */
634
+ /** 批量评估:顺序执行(单任务异常不中断批);expected 参与判定;结构化报告。
635
+ * 注意:评估会真实执行技能脚本(试用路径)——必须显式 opt-in(allowExecution: true),
636
+ * 且沙箱执行器是能力面收敛而非安全边界,禁止对不可信候选技能直接跑评估。 */
625
637
  var EvaluationRunner = class {
626
638
  #runtime;
639
+ #allowExecution;
627
640
  #now;
628
641
  #createId;
629
642
  constructor(deps) {
630
643
  this.#runtime = deps.runtime;
644
+ this.#allowExecution = deps.allowExecution ?? false;
631
645
  this.#now = deps.now;
632
646
  this.#createId = deps.createId;
633
647
  }
634
648
  async run(tasks) {
649
+ if (!this.#allowExecution) throw new WebSkillError("GOVERNANCE_FAILED", "EvaluationRunner executes skill scripts; pass allowExecution: true to opt in (sandbox executors are capability-reducing, not a security boundary)");
635
650
  const results = [];
636
651
  for (const task of tasks) try {
637
652
  const { output, run } = await this.#runtime.run(task.prompt);
@@ -1,4 +1,4 @@
1
- import { A as SkillCatalog, C as JsonSchema, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, P as SkillInstallSource, S as FileSystemProvider, U as ValidationReport, _ as RenderResultRequest, a as InteractionPolicy, b as DiscoveryResult, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, j as SkillCatalogEntry, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-Dq_A1yA-.js";
1
+ import { A as SkillCatalog, C as JsonSchema, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, P as SkillInstallSource, S as FileSystemProvider, U as ValidationReport, _ as RenderResultRequest, a as InteractionPolicy, b as DiscoveryResult, c as LlmClient, d as LlmResponse, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, j as SkillCatalogEntry, l as LlmCompleteInput, m as LlmToolSpec, n as ArtifactStore, o as InteractionRequest, r as ChartSpec, t as Artifact, u as LlmMessage, v as UiBridge } from "./types-CgNC-oQu-DYrxhD3z.js";
2
2
  //#region ../runtime/dist/index.d.ts
3
3
  //#region src/llm/openAiCompatibleClient.d.ts
4
4
  interface OpenAiCompatibleClientConfig {
@@ -21,6 +21,52 @@ declare class OpenAiCompatibleClient implements LlmClient {
21
21
  checkAvailability(): Promise<boolean>;
22
22
  }
23
23
  //#endregion
24
+ //#region src/llm/anthropicClient.d.ts
25
+ interface AnthropicClientConfig {
26
+ apiKey: string;
27
+ model: string;
28
+ /** 默认 https://api.anthropic.com */
29
+ baseUrl?: string;
30
+ /** 可注入 fetch(测试用 mock);缺省用全局 fetch */
31
+ fetchImpl?: typeof fetch;
32
+ /** 单次请求超时 */
33
+ requestTimeoutMs?: number;
34
+ /** max_tokens(Messages API 必填),默认 4096 */
35
+ maxTokens?: number;
36
+ }
37
+ /** Anthropic Messages API 客户端(零依赖 fetch;Node/浏览器通用) */
38
+ declare class AnthropicClient implements LlmClient {
39
+ #private;
40
+ constructor(config: AnthropicClientConfig);
41
+ complete(input: LlmCompleteInput): Promise<LlmResponse>;
42
+ /** SSE 流式:text_delta → text-delta;input_json_delta 按 block index 聚合 → tool-calls */
43
+ stream(input: LlmCompleteInput): AsyncIterable<LlmStreamEvent>;
44
+ /** 轻量探测(GET /v1/models),集成测试据此决定 skip */
45
+ checkAvailability(): Promise<boolean>;
46
+ }
47
+ //#endregion
48
+ //#region src/llm/googleGenAiClient.d.ts
49
+ interface GoogleGenAiClientConfig {
50
+ apiKey: string;
51
+ model: string;
52
+ /** 默认 https://generativelanguage.googleapis.com */
53
+ baseUrl?: string;
54
+ /** 可注入 fetch(测试用 mock);缺省用全局 fetch */
55
+ fetchImpl?: typeof fetch;
56
+ /** 单次请求超时 */
57
+ requestTimeoutMs?: number;
58
+ }
59
+ /** Google GenAI(generateContent / streamGenerateContent)客户端(零依赖 fetch) */
60
+ declare class GoogleGenAiClient implements LlmClient {
61
+ #private;
62
+ constructor(config: GoogleGenAiClientConfig);
63
+ complete(input: LlmCompleteInput): Promise<LlmResponse>;
64
+ /** SSE 流式:chunk.parts text → text-delta;functionCall 聚合 → tool-calls */
65
+ stream(input: LlmCompleteInput): AsyncIterable<LlmStreamEvent>;
66
+ /** 轻量探测(GET /v1beta/models),集成测试据此决定 skip */
67
+ checkAvailability(): Promise<boolean>;
68
+ }
69
+ //#endregion
24
70
  //#region src/llm/vercelAiAdapter.d.ts
25
71
  /**
26
72
  * Vercel AI SDK 适配层:纯数据转换,不 import SDK。
@@ -697,4 +743,4 @@ declare class WebSkillRuntime {
697
743
  resumeRun(runId: string): Promise<RunResult>;
698
744
  }
699
745
  //#endregion
700
- export { TraceEvent as $, OpenAiCompatibleClient as A, RunSnapshotStore as B, HookRunnerOptions as C, LifecycleHookContext as D, LifecycleHook as E, READ_SKILL_FILE_TOOL_NAME as F, SchemaInferer as G, RuntimePhase as H, RUN_SNAPSHOT_SCHEMA_VERSION as I, SkillRouter as J, ScriptExecutionContext as K, RouteResult as L, ProgressiveRouter as M, READ_SKILL_FILE_INPUT_SCHEMA as N, LifecycleListener as O, READ_SKILL_FILE_TOOL as P, TraceClock as Q, RunResult as R, HookRunner as S, LifecycleEvent as T, RuntimeRun as U, RunTerminationReason as V, RuntimeSession as W, ToolResolution as X, ToolDefinition as Y, ToolResult as Z, ExternalToolSource as _, parseBridgeRequest as _t, AgentLoopConfig as a, WebSkillRuntimeDeps as at, FsRunSnapshotStore as b, toLlmToolSpec as bt, ApprovalScope as c, createScriptContext as ct, BridgeRequest as d, fromVercelResult as dt, TraceEventType as et, BridgeResponse as f, fromVercelStreamPart as ft, ExternalSkillProvider as g, normalizeToolContent as gt, EventBus as h, networkUrlHost as ht, AgentLoop as i, WebSkillRuntime as it, OpenAiCompatibleClientConfig as j, NetworkPolicy as k, BridgeCapabilities as l, createWebSkillApi as lt, CapabilityMode as m, mergeCatalogEntries as mt, ASK_USER_TOOL as n, VercelToolSpec as nt, AgentLoopDeps as o, bridgeError as ot, CapabilityApproval as p, isNetworkAllowed as pt, ScriptExecutor as q, ASK_USER_TOOL_NAME as r, WebSkillApi as rt, ApprovalDecision as s, buildRenderResult as st, ASK_USER_INPUT_SCHEMA as t, TraceRecorder as tt, BridgeCapability as u, extractChartSpec as ut, FsArtifactStore as v, resolveToolName as vt, InstalledSkillManifest as w, FullDisclosureRouter as x, toVercelToolSpecs as xt, FsMemoryStore as y, schemaToForm as yt, RunSnapshot as z };
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 };
@@ -1,12 +1,19 @@
1
- import { C as JsonSchema, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, S as FileSystemProvider, W as VerifyResult, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, x as FileStat } from "./types-CgNC-oQu-Dq_A1yA-.js";
2
- import { G as SchemaInferer, K as ScriptExecutionContext, Y as ToolDefinition, Z as ToolResult, c as ApprovalScope, k as NetworkPolicy, l as BridgeCapabilities, q as ScriptExecutor, v as FsArtifactStore, y as FsMemoryStore } from "./index-fjRF4H5o.js";
1
+ import { C as JsonSchema, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, S as FileSystemProvider, W as VerifyResult, _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge, x as FileStat } from "./types-CgNC-oQu-DYrxhD3z.js";
2
+ import { $ as ToolDefinition, N as NetworkPolicy, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, b as FsArtifactStore, d as BridgeCapabilities, tt as ToolResult, u as ApprovalScope, x as FsMemoryStore } from "./index-BSS3EWY-.js";
3
3
  import { Readable, Writable } from "node:stream";
4
4
  //#region ../node/dist/index.d.ts
5
5
  //#region src/fs/nodeFs.d.ts
6
- /** 基于 node:fs/promises 的 FileSystemProvider;接受 `/` 风格路径,写入自动创建父目录 */
6
+ /**
7
+ * 基于 node:fs/promises 的 FileSystemProvider;接受 `/` 风格路径,写入自动创建父目录。
8
+ * 可选 root 模式:构造传入 root 后,read/write 操作先做 realpath 包含校验
9
+ * (root 与目标都 realpath 后前缀比对),经符号链接逃逸 root → FS_PATH_OUTSIDE_ROOT。
10
+ */
7
11
  declare class NodeFS implements FileSystemProvider {
8
12
  #private;
9
13
  readonly kind = "node";
14
+ constructor(deps?: {
15
+ root?: string;
16
+ });
10
17
  readText(p: string): Promise<string>;
11
18
  writeText(p: string, content: string): Promise<void>;
12
19
  readBinary(p: string): Promise<Uint8Array>;
@@ -50,6 +57,8 @@ interface SandboxOptions {
50
57
  capabilities?: BridgeCapabilities;
51
58
  /** 网络策略:默认 'deny-all'(白名单见 runtime/sandbox/networkPolicy) */
52
59
  networkPolicy?: NetworkPolicy;
60
+ /** 裸模块 allowlist(默认 []:一切 node: 内置模块全禁;按需放行如 ['node:path']) */
61
+ allowedModules?: string[];
53
62
  /** require-approval 模式的授权询问出口(缺失时 require-approval 一律拒绝) */
54
63
  uiBridge?: UiBridge;
55
64
  /** 授权粒度:默认 'once-per-run' */
@@ -60,6 +69,10 @@ interface SandboxOptions {
60
69
  * 每次执行独立 Worker(resourceLimits + env 白名单),loadDefinition 同样在
61
70
  * Worker 内完成(禁止主进程 import 不可信脚本);超时 terminate(可杀同步死循环)。
62
71
  * 能力桥协议与浏览器同一来源(runtime/sandbox/bridgeProtocol)。
72
+ *
73
+ * 诚实标注:本执行器做的是**能力面收敛**(网络策略、模块 allowlist、资源限额、
74
+ * 超时强杀),**不是安全边界**——Worker 内脚本与宿主共享进程,仍有绕过手段;
75
+ * 禁止假定其可隔离不可信脚本。
63
76
  */
64
77
  declare class SandboxedScriptExecutor implements ScriptExecutor {
65
78
  #private;
@@ -172,11 +185,20 @@ interface LlmEnvConfig {
172
185
  apiKey: string;
173
186
  model: string;
174
187
  }
188
+ /** per-provider env 配置(baseUrl 可选,客户端自带默认) */
189
+ interface ProviderEnvConfig {
190
+ apiKey: string;
191
+ model: string;
192
+ baseUrl?: string;
193
+ }
175
194
  /**
176
- * 解析 .env(简单 KEY=VALUE 行解析,不引依赖),
177
195
  * 读取 VITE_BASE_URL / VITE_API_KEY / VITE_MODEL_NAME;缺项返回 undefined 供测试 skip 判断。
178
196
  */
179
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;
180
202
  interface LlmCapabilities {
181
203
  available: boolean;
182
204
  nonStreaming: boolean;
@@ -192,4 +214,4 @@ interface LlmCapabilities {
192
214
  */
193
215
  declare function probeLlmCapabilities(config: LlmEnvConfig): Promise<LlmCapabilities>;
194
216
  //#endregion
195
- export { LlmEnvConfig as a, OxcSchemaInferer as c, SkillManager as d, loadLlmConfigFromEnv as f, LlmCapabilities as i, SandboxOptions as l, readArchiveManifest as m, FileArtifactStore as n, NodeFS as o, probeLlmCapabilities as p, FileMemoryStore as r, NodeScriptExecutor as s, CliUiBridge as t, SandboxedScriptExecutor as u };
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 };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as exportSkills, 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 buildManifest, K as WebSkillErrorCode, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, O as SKILL_NAME_PATTERN, P as SkillInstallSource, Q as escapeXml, R as SkillMetadata, S as FileSystemProvider, T as SKILLS_LOCKFILE, U as ValidationReport, V as SkillSource, W as VerifyResult, X as checkSkillRules, Y as checkDependencyCycles, Z as computeDigest, _ as RenderResultRequest, a as InteractionPolicy, at as renderAvailableSkillsXml, b as DiscoveryResult, c as LlmClient, ct as validateSkills, d as LlmResponse, et as isValidSkillName, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, it as parseSkillPackManifest, j as SkillCatalogEntry, k as SKILL_PACK_FILE, l as LlmCompleteInput, lt as verifyManifest, m as LlmToolSpec, n as ArtifactStore, nt as normalizePath, o as InteractionRequest, ot as renderCatalogJson, p as LlmToolCall, q as buildCatalog, r as ChartSpec, rt as parseSkillMarkdown, s as InteractionResponse, st as resolveInsideRoot, t as Artifact, tt as jsonRenderer, u as LlmMessage, ut as xmlRenderer, v as UiBridge, w as MemoryFS, x as FileStat, y as CatalogRenderer, z as SkillPackManifest } from "./types-CgNC-oQu-Dq_A1yA-.js";
2
- import { $ as TraceEvent, A as OpenAiCompatibleClient, B as RunSnapshotStore, C as HookRunnerOptions, D as LifecycleHookContext, E as LifecycleHook, F as READ_SKILL_FILE_TOOL_NAME, G as SchemaInferer, H as RuntimePhase, I as RUN_SNAPSHOT_SCHEMA_VERSION, J as SkillRouter, K as ScriptExecutionContext, L as RouteResult, M as ProgressiveRouter, N as READ_SKILL_FILE_INPUT_SCHEMA, O as LifecycleListener, P as READ_SKILL_FILE_TOOL, Q as TraceClock, R as RunResult, S as HookRunner, T as LifecycleEvent, U as RuntimeRun, V as RunTerminationReason, W as RuntimeSession, X as ToolResolution, Y as ToolDefinition, Z as ToolResult, _ as ExternalToolSource, _t as parseBridgeRequest, a as AgentLoopConfig, at as WebSkillRuntimeDeps, b as FsRunSnapshotStore, bt as toLlmToolSpec, c as ApprovalScope, ct as createScriptContext, d as BridgeRequest, dt as fromVercelResult, et as TraceEventType, f as BridgeResponse, ft as fromVercelStreamPart, g as ExternalSkillProvider, gt as normalizeToolContent, h as EventBus, ht as networkUrlHost, i as AgentLoop, it as WebSkillRuntime, j as OpenAiCompatibleClientConfig, k as NetworkPolicy, l as BridgeCapabilities, lt as createWebSkillApi, m as CapabilityMode, mt as mergeCatalogEntries, n as ASK_USER_TOOL, nt as VercelToolSpec, o as AgentLoopDeps, ot as bridgeError, p as CapabilityApproval, pt as isNetworkAllowed, q as ScriptExecutor, r as ASK_USER_TOOL_NAME, rt as WebSkillApi, s as ApprovalDecision, st as buildRenderResult, t as ASK_USER_INPUT_SCHEMA, tt as TraceRecorder, u as BridgeCapability, ut as extractChartSpec, v as FsArtifactStore, vt as resolveToolName, w as InstalledSkillManifest, x as FullDisclosureRouter, xt as toVercelToolSpecs, y as FsMemoryStore, yt as schemaToForm, z as RunSnapshot } from "./index-fjRF4H5o.js";
3
- export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, 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, HookRunner, type HookRunnerOptions, type InstalledSkillManifest, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillInstallSource, type SkillIssue, type SkillLocation, type SkillManifest, type SkillMetadata, type SkillPackManifest, SkillReader, type SkillRouter, type SkillSource, type SkillsLockfile, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
1
+ import { $ as escapeXml, A as SkillCatalog, B as SkillReader, C as JsonSchema, D as SKILL_NAME_MAX_LENGTH, E as SKILL_MANIFEST_FILE, F as SkillIssue, G as WebSkillError, H as SkillsLockfile, I as SkillLocation, J as buildCatalog, K as WebSkillErrorCode, L as SkillManifest, M as SkillDiscovery, N as SkillDocument, O as SKILL_NAME_PATTERN, P as SkillInstallSource, Q as computeDigest, R as SkillMetadata, S as FileSystemProvider, T as SKILLS_LOCKFILE, U as ValidationReport, V as SkillSource, W as VerifyResult, X as checkDependencyCycles, Y as buildManifest, Z as checkSkillRules, _ as RenderResultRequest, a as InteractionPolicy, at as parseSkillPackManifest, b as DiscoveryResult, c as LlmClient, ct as resolveInsideRoot, d as LlmResponse, dt as xmlRenderer, et as exportSkills, f as LlmStreamEvent, g as RenderBlock, h as MemoryStore, i as FormField, it as parseSkillMarkdown, j as SkillCatalogEntry, k as SKILL_PACK_FILE, l as LlmCompleteInput, lt as validateSkills, m as LlmToolSpec, n as ArtifactStore, nt as jsonRenderer, o as InteractionRequest, ot as renderAvailableSkillsXml, p as LlmToolCall, q as assertSafePathSegment, r as ChartSpec, rt as normalizePath, s as InteractionResponse, st as renderCatalogJson, t as Artifact, tt as isValidSkillName, u as LlmMessage, ut as verifyManifest, v as UiBridge, w as MemoryFS, x as FileStat, y as CatalogRenderer, z as SkillPackManifest } from "./types-CgNC-oQu-DYrxhD3z.js";
2
+ import { $ as ToolDefinition, A as LifecycleHook, B as RUN_SNAPSHOT_SCHEMA_VERSION, C as FullDisclosureRouter, Ct as schemaToForm, D as HookRunnerOptions, E as HookRunner, F as OpenAiCompatibleClientConfig, G as RunTerminationReason, H as RunResult, I as ProgressiveRouter, J as RuntimeSession, K as RuntimePhase, L as READ_SKILL_FILE_INPUT_SCHEMA, M as LifecycleListener, N as NetworkPolicy, O as InstalledSkillManifest, P as OpenAiCompatibleClient, Q as SkillRouter, R as READ_SKILL_FILE_TOOL, S as FsRunSnapshotStore, St as resolveToolName, T as GoogleGenAiClientConfig, Tt as toVercelToolSpecs, U as RunSnapshot, V as RouteResult, W as RunSnapshotStore, X as ScriptExecutionContext, Y as SchemaInferer, Z as ScriptExecutor, _ as EventBus, _t as isNetworkAllowed, a as AgentLoopConfig, at as TraceRecorder, b as FsArtifactStore, bt as normalizeToolContent, c as AnthropicClientConfig, ct as WebSkillRuntime, d as BridgeCapabilities, dt as buildRenderResult, et as ToolResolution, f as BridgeCapability, ft as createScriptContext, g as CapabilityMode, gt as fromVercelStreamPart, h as CapabilityApproval, ht as fromVercelResult, i as AgentLoop, it as TraceEventType, j as LifecycleHookContext, k as LifecycleEvent, l as ApprovalDecision, lt as WebSkillRuntimeDeps, m as BridgeResponse, mt as extractChartSpec, n as ASK_USER_TOOL, nt as TraceClock, o as AgentLoopDeps, ot as VercelToolSpec, p as BridgeRequest, pt as createWebSkillApi, q as RuntimeRun, r as ASK_USER_TOOL_NAME, rt as TraceEvent, s as AnthropicClient, st as WebSkillApi, t as ASK_USER_INPUT_SCHEMA, tt as ToolResult, u as ApprovalScope, ut as bridgeError, v as ExternalSkillProvider, vt as mergeCatalogEntries, w as GoogleGenAiClient, wt as toLlmToolSpec, x as FsMemoryStore, xt as parseBridgeRequest, y as ExternalToolSource, yt as networkUrlHost, z as READ_SKILL_FILE_TOOL_NAME } from "./index-BSS3EWY-.js";
3
+ export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, type AgentLoopConfig, type AgentLoopDeps, AnthropicClient, type AnthropicClientConfig, type ApprovalDecision, type ApprovalScope, type Artifact, type ArtifactStore, type BridgeCapabilities, type BridgeCapability, type BridgeRequest, type BridgeResponse, CapabilityApproval, type CapabilityMode, type CatalogRenderer, type ChartSpec, type DiscoveryResult, EventBus, type ExternalSkillProvider, type ExternalToolSource, type FileStat, type FileSystemProvider, type FormField, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, type GoogleGenAiClientConfig, HookRunner, type HookRunnerOptions, type InstalledSkillManifest, type InteractionPolicy, type InteractionRequest, type InteractionResponse, type JsonSchema, type LifecycleEvent, type LifecycleHook, type LifecycleHookContext, type LifecycleListener, type LlmClient, type LlmCompleteInput, type LlmMessage, type LlmResponse, type LlmStreamEvent, type LlmToolCall, type LlmToolSpec, MemoryFS, type MemoryStore, type NetworkPolicy, OpenAiCompatibleClient, type OpenAiCompatibleClientConfig, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, type RenderBlock, type RenderResultRequest, type RouteResult, type RunResult, type RunSnapshot, type RunSnapshotStore, type RunTerminationReason, type RuntimePhase, type RuntimeRun, type RuntimeSession, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, type SchemaInferer, type ScriptExecutionContext, type ScriptExecutor, type SkillCatalog, type SkillCatalogEntry, SkillDiscovery, type SkillDocument, type SkillInstallSource, type SkillIssue, type SkillLocation, type SkillManifest, type SkillMetadata, type SkillPackManifest, SkillReader, type SkillRouter, type SkillSource, type SkillsLockfile, type ToolDefinition, type ToolResolution, type ToolResult, type TraceClock, type TraceEvent, type TraceEventType, TraceRecorder, type UiBridge, type ValidationReport, type VercelToolSpec, type VerifyResult, type WebSkillApi, WebSkillError, type WebSkillErrorCode, WebSkillRuntime, type WebSkillRuntimeDeps, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as renderCatalogJson, D as xmlRenderer, E as verifyManifest, S as renderAvailableSkillsXml, T as validateSkills, _ as isValidSkillName, a as SKILL_NAME_PATTERN, b as parseSkillMarkdown, c as SkillReader, d as buildManifest, f as checkDependencyCycles, g as exportSkills, h as escapeXml, i as SKILL_NAME_MAX_LENGTH, l as WebSkillError, m as computeDigest, n as SKILLS_LOCKFILE, o as SKILL_PACK_FILE, p as checkSkillRules, r as SKILL_MANIFEST_FILE, s as SkillDiscovery, t as MemoryFS, u as buildCatalog, v as jsonRenderer, w as resolveInsideRoot, x as parseSkillPackManifest, y as normalizePath } from "./dist-DS1sfgHa.js";
2
- import { A as normalizeToolContent, C as createWebSkillApi, D as isNetworkAllowed, E as fromVercelStreamPart, F as toVercelToolSpecs, M as resolveToolName, N as schemaToForm, O as mergeCatalogEntries, P as toLlmToolSpec, S as createScriptContext, T as fromVercelResult, _ as RUN_SNAPSHOT_SCHEMA_VERSION, a as CapabilityApproval, b as bridgeError, c as FsMemoryStore, d as HookRunner, f as OpenAiCompatibleClient, g as READ_SKILL_FILE_TOOL_NAME, h as READ_SKILL_FILE_TOOL, i as AgentLoop, j as parseBridgeRequest, k as networkUrlHost, l as FsRunSnapshotStore, m as READ_SKILL_FILE_INPUT_SCHEMA, n as ASK_USER_TOOL, o as EventBus, p as ProgressiveRouter, r as ASK_USER_TOOL_NAME, s as FsArtifactStore, t as ASK_USER_INPUT_SCHEMA, u as FullDisclosureRouter, v as TraceRecorder, w as extractChartSpec, x as buildRenderResult, y as WebSkillRuntime } from "./dist-DRsnVw6A.js";
1
+ import { C as renderAvailableSkillsXml, D as verifyManifest, E as validateSkills, O as xmlRenderer, S as parseSkillPackManifest, T as resolveInsideRoot, _ as exportSkills, a as SKILL_NAME_PATTERN, b as normalizePath, c as SkillReader, d as buildCatalog, f as buildManifest, g as escapeXml, h as computeDigest, i as SKILL_NAME_MAX_LENGTH, l as WebSkillError, m as checkSkillRules, n as SKILLS_LOCKFILE, o as SKILL_PACK_FILE, p as checkDependencyCycles, r as SKILL_MANIFEST_FILE, s as SkillDiscovery, t as MemoryFS, u as assertSafePathSegment, v as isValidSkillName, w as renderCatalogJson, x as parseSkillMarkdown, y as jsonRenderer } from "./dist-DvoBsChX.js";
2
+ import { A as mergeCatalogEntries, C as buildRenderResult, D as fromVercelResult, E as extractChartSpec, F as schemaToForm, I as toLlmToolSpec, L as toVercelToolSpecs, M as normalizeToolContent, N as parseBridgeRequest, O as fromVercelStreamPart, P as resolveToolName, S as bridgeError, T as createWebSkillApi, _ as READ_SKILL_FILE_TOOL, a as AnthropicClient, b as TraceRecorder, c as FsArtifactStore, d as FullDisclosureRouter, f as GoogleGenAiClient, g as READ_SKILL_FILE_INPUT_SCHEMA, h as ProgressiveRouter, i as AgentLoop, j as networkUrlHost, k as isNetworkAllowed, l as FsMemoryStore, m as OpenAiCompatibleClient, n as ASK_USER_TOOL, o as CapabilityApproval, p as HookRunner, r as ASK_USER_TOOL_NAME, s as EventBus, t as ASK_USER_INPUT_SCHEMA, u as FsRunSnapshotStore, v as READ_SKILL_FILE_TOOL_NAME, w as createScriptContext, x as WebSkillRuntime, y as RUN_SNAPSHOT_SCHEMA_VERSION } from "./dist-DAn07zHu.js";
3
3
 
4
- export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, CapabilityApproval, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, HookRunner, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
4
+ export { ASK_USER_INPUT_SCHEMA, ASK_USER_TOOL, ASK_USER_TOOL_NAME, AgentLoop, AnthropicClient, CapabilityApproval, EventBus, FsArtifactStore, FsMemoryStore, FsRunSnapshotStore, FullDisclosureRouter, GoogleGenAiClient, HookRunner, MemoryFS, OpenAiCompatibleClient, ProgressiveRouter, READ_SKILL_FILE_INPUT_SCHEMA, READ_SKILL_FILE_TOOL, READ_SKILL_FILE_TOOL_NAME, RUN_SNAPSHOT_SCHEMA_VERSION, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SKILL_NAME_MAX_LENGTH, SKILL_NAME_PATTERN, SKILL_PACK_FILE, SkillDiscovery, SkillReader, TraceRecorder, WebSkillError, WebSkillRuntime, assertSafePathSegment, bridgeError, buildCatalog, buildManifest, buildRenderResult, checkDependencyCycles, checkSkillRules, computeDigest, createScriptContext, createWebSkillApi, escapeXml, exportSkills, extractChartSpec, fromVercelResult, fromVercelStreamPart, isNetworkAllowed, isValidSkillName, jsonRenderer, mergeCatalogEntries, networkUrlHost, normalizePath, normalizeToolContent, parseBridgeRequest, parseSkillMarkdown, parseSkillPackManifest, renderAvailableSkillsXml, renderCatalogJson, resolveInsideRoot, resolveToolName, schemaToForm, toLlmToolSpec, toVercelToolSpecs, validateSkills, verifyManifest, xmlRenderer };
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as JsonSchema, N as SkillDocument, j as SkillCatalogEntry, m as LlmToolSpec } from "./types-CgNC-oQu-Dq_A1yA-.js";
2
- import { Z as ToolResult, _ as ExternalToolSource, g as ExternalSkillProvider, mt as mergeCatalogEntries } from "./index-fjRF4H5o.js";
1
+ import { C as JsonSchema, N as SkillDocument, j as SkillCatalogEntry, m as LlmToolSpec } from "./types-CgNC-oQu-DYrxhD3z.js";
2
+ import { tt as ToolResult, v as ExternalSkillProvider, vt as mergeCatalogEntries, y as ExternalToolSource } from "./index-BSS3EWY-.js";
3
3
  import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
4
4
  import { JSONRPCMessage } from "@modelcontextprotocol/sdk/types.js";
5
5
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -241,4 +241,26 @@ declare class McpRuntimePlugin implements ExternalToolSource {
241
241
  call(llmToolName: string, args: Record<string, unknown>): Promise<ToolResult>;
242
242
  }
243
243
  //#endregion
244
- export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, type ServedSkill, TemporarySkillProvider, type TransportState, type WebMcpToolDescriptor, catalogMerge, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
244
+ //#region src/remote/connectRemoteEndpoint.d.ts
245
+ interface RemoteEndpointConfig {
246
+ /** registry 中的名字(endpoint:tool 引用) */
247
+ endpoint: string;
248
+ url: string;
249
+ /** 默认 'streamable-http'(现行标准);'sse' 为遗留兼容 */
250
+ transport?: 'streamable-http' | 'sse';
251
+ /** 鉴权等请求头(Bearer 等),经 transport requestInit.headers 透传 */
252
+ headers?: Record<string, string>;
253
+ /** 连接超时;0/缺省 = 不超时 */
254
+ timeoutMs?: number;
255
+ }
256
+ /**
257
+ * 远程 MCP endpoint 装配:SDK 官方 StreamableHTTPClientTransport(默认)/
258
+ * SSEClientTransport(遗留)连接远端 server,注册进 EndpointRegistry——
259
+ * endpoint:tool 解析、TTL+版本缓存、临时技能消费自动生效。
260
+ * 返回 close 句柄:断开后 unregister(临时技能随既有生命周期自然消失)。
261
+ */
262
+ declare function connectRemoteEndpoint(registry: EndpointRegistry<McpClientLike>, config: RemoteEndpointConfig): Promise<{
263
+ close(): Promise<void>;
264
+ }>;
265
+ //#endregion
266
+ export { type BrowserModelContextLike, EndpointRegistry, ExperimentalWebMcpAdapter, type McpClientLike, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, type MessageChannelTransportOptions, type MessagePortLike, type RemoteEndpointConfig, type ServedSkill, TemporarySkillProvider, type TransportState, type WebMcpToolDescriptor, catalogMerge, connectRemoteEndpoint, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
package/dist/mcp.js CHANGED
@@ -1,6 +1,9 @@
1
- import { l as WebSkillError } from "./dist-DS1sfgHa.js";
2
- import { A as normalizeToolContent, O as mergeCatalogEntries } from "./dist-DRsnVw6A.js";
1
+ import { l as WebSkillError } from "./dist-DvoBsChX.js";
2
+ import { A as mergeCatalogEntries, M as normalizeToolContent } from "./dist-DAn07zHu.js";
3
3
  import { fromJSONSchema } from "zod";
4
+ 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";
4
7
 
5
8
  //#region ../mcp/dist/index.js
6
9
  /**
@@ -166,7 +169,7 @@ var EndpointRegistry = class {
166
169
  for (const resolve of queue) resolve(client);
167
170
  }
168
171
  };
169
- const messageOf$2 = (e) => e instanceof Error ? e.message : String(e);
172
+ const messageOf$3 = (e) => e instanceof Error ? e.message : String(e);
170
173
  const failure$1 = (code, message) => ({
171
174
  ok: false,
172
175
  content: [],
@@ -191,20 +194,20 @@ var McpToolResolver = class {
191
194
  try {
192
195
  client = this.#registry.get(endpoint);
193
196
  } catch (e) {
194
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", messageOf$2(e));
197
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", messageOf$3(e));
195
198
  }
196
199
  let names;
197
200
  try {
198
201
  names = await this.#toolNames(endpoint, client);
199
202
  } catch (e) {
200
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$2(e)}`);
203
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$3(e)}`);
201
204
  }
202
205
  if (!names.has(toolName)) {
203
206
  this.#cache.delete(endpoint);
204
207
  try {
205
208
  names = await this.#toolNames(endpoint, client);
206
209
  } catch (e) {
207
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$2(e)}`);
210
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$3(e)}`);
208
211
  }
209
212
  if (!names.has(toolName)) return failure$1("MCP_TOOL_NOT_FOUND", `Tool "${toolName}" not found on endpoint "${endpoint}"`);
210
213
  }
@@ -215,7 +218,7 @@ var McpToolResolver = class {
215
218
  });
216
219
  return this.#normalizeCallResult(raw);
217
220
  } catch (e) {
218
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Tool "${toolName}" on endpoint "${endpoint}" failed: ${messageOf$2(e)}`);
221
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Tool "${toolName}" on endpoint "${endpoint}" failed: ${messageOf$3(e)}`);
219
222
  }
220
223
  }
221
224
  async #toolNames(endpoint, client) {
@@ -262,7 +265,7 @@ function webMcpToolLlmName(toolName) {
262
265
  function parseWebMcpToolLlmName(llmName) {
263
266
  return llmName.startsWith("mcp__") && llmName.length > 5 ? llmName.slice(5) : void 0;
264
267
  }
265
- const messageOf$1 = (e) => e instanceof Error ? e.message : String(e);
268
+ const messageOf$2 = (e) => e instanceof Error ? e.message : String(e);
266
269
  const textOfContent = (content) => {
267
270
  if (typeof content === "string") return content;
268
271
  if (typeof content === "object" && content !== null) {
@@ -308,7 +311,7 @@ var TemporarySkillProvider = class {
308
311
  try {
309
312
  result = await client.getPrompt({ name });
310
313
  } catch (e) {
311
- throw new WebSkillError("SKILL_NOT_FOUND", `Prompt "${name}" not found on endpoint "${this.#endpoint}": ${messageOf$1(e)}`, e);
314
+ throw new WebSkillError("SKILL_NOT_FOUND", `Prompt "${name}" not found on endpoint "${this.#endpoint}": ${messageOf$2(e)}`, e);
312
315
  }
313
316
  const body = (result.messages ?? []).map((m) => textOfContent(m.content)).filter(Boolean).join("\n\n");
314
317
  return {
@@ -333,7 +336,7 @@ var TemporarySkillProvider = class {
333
336
  try {
334
337
  return this.#registry.get(this.#endpoint);
335
338
  } catch (e) {
336
- throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", messageOf$1(e), e);
339
+ throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", messageOf$2(e), e);
337
340
  }
338
341
  }
339
342
  };
@@ -369,7 +372,7 @@ function serveSkillAsMcp(server, skill) {
369
372
  * 实现单一来源在 runtime(runtime 自身合并也用同一函数)。
370
373
  */
371
374
  const catalogMerge = mergeCatalogEntries;
372
- const messageOf = (e) => e instanceof Error ? e.message : String(e);
375
+ const messageOf$1 = (e) => e instanceof Error ? e.message : String(e);
373
376
  const failure = (code, message) => ({
374
377
  ok: false,
375
378
  content: [],
@@ -432,7 +435,7 @@ var ExperimentalWebMcpAdapter = class {
432
435
  content: normalizeToolContent(await api.executeTool(toolName, JSON.stringify(args)))
433
436
  };
434
437
  } catch (e) {
435
- return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf(e)}`);
438
+ return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf$1(e)}`);
436
439
  }
437
440
  }
438
441
  };
@@ -512,6 +515,48 @@ var McpRuntimePlugin = class {
512
515
  };
513
516
  }
514
517
  };
518
+ const messageOf = (e) => e instanceof Error ? e.message : String(e);
519
+ /**
520
+ * 远程 MCP endpoint 装配:SDK 官方 StreamableHTTPClientTransport(默认)/
521
+ * SSEClientTransport(遗留)连接远端 server,注册进 EndpointRegistry——
522
+ * endpoint:tool 解析、TTL+版本缓存、临时技能消费自动生效。
523
+ * 返回 close 句柄:断开后 unregister(临时技能随既有生命周期自然消失)。
524
+ */
525
+ async function connectRemoteEndpoint(registry, config) {
526
+ const url = new URL(config.url);
527
+ const requestInit = config.headers ? { headers: config.headers } : void 0;
528
+ const transport = config.transport === "sse" ? new SSEClientTransport(url, { ...requestInit ? { requestInit } : {} }) : new StreamableHTTPClientTransport(url, { ...requestInit ? { requestInit } : {} });
529
+ const client = new Client({
530
+ name: "webskill-remote-client",
531
+ version: "0.1.0"
532
+ });
533
+ const unavailable = (e) => new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", `Failed to connect remote MCP endpoint "${config.endpoint}" at ${config.url}: ${messageOf(e)}`, e);
534
+ try {
535
+ let connect = client.connect(transport);
536
+ if (config.timeoutMs && config.timeoutMs > 0) {
537
+ const timeoutMs = config.timeoutMs;
538
+ connect = Promise.race([connect, new Promise((_resolve, reject) => setTimeout(() => reject(/* @__PURE__ */ new Error(`Connection timed out after ${timeoutMs}ms`)), timeoutMs))]);
539
+ }
540
+ await connect;
541
+ } catch (e) {
542
+ try {
543
+ await client.close();
544
+ } catch {}
545
+ throw unavailable(e);
546
+ }
547
+ registry.register(config.endpoint, client);
548
+ let closed = false;
549
+ return { close: async () => {
550
+ if (closed) return;
551
+ closed = true;
552
+ registry.unregister(config.endpoint);
553
+ try {
554
+ await client.close();
555
+ } catch (e) {
556
+ throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", `Failed to close remote MCP endpoint "${config.endpoint}": ${messageOf(e)}`, e);
557
+ }
558
+ } };
559
+ }
515
560
 
516
561
  //#endregion
517
- export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, TemporarySkillProvider, catalogMerge, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
562
+ export { EndpointRegistry, ExperimentalWebMcpAdapter, McpRuntimePlugin, McpToolResolver, MessageChannelTransport, TemporarySkillProvider, catalogMerge, connectRemoteEndpoint, endpointToolLlmName, parseEndpointToolLlmName, parseWebMcpToolLlmName, serveSkillAsMcp, validateJsonRpcMessage, webMcpToolLlmName };
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as SKILL_MANIFEST_FILE, H as SkillsLockfile, L as SkillManifest, P as SkillInstallSource, T as SKILLS_LOCKFILE, W as VerifyResult } from "./types-CgNC-oQu-Dq_A1yA-.js";
2
- import { ct as createScriptContext } from "./index-fjRF4H5o.js";
3
- import { a as LlmEnvConfig, c as OxcSchemaInferer, d as SkillManager, f as loadLlmConfigFromEnv, i as LlmCapabilities, l as SandboxOptions, m as readArchiveManifest, n as FileArtifactStore, o as NodeFS, p as probeLlmCapabilities, r as FileMemoryStore, s as NodeScriptExecutor, t as CliUiBridge, u as SandboxedScriptExecutor } from "./index-DkPK44Ji.js";
4
- 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, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
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 };
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as SKILLS_LOCKFILE, r as SKILL_MANIFEST_FILE } from "./dist-DS1sfgHa.js";
2
- import { S as createScriptContext } from "./dist-DRsnVw6A.js";
3
- import { a as NodeScriptExecutor, c as SkillManager, d as readArchiveManifest, i as NodeFS, l as loadLlmConfigFromEnv, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as probeLlmCapabilities } from "./dist-SarUS8EP.js";
1
+ import { n as SKILLS_LOCKFILE, r as SKILL_MANIFEST_FILE } from "./dist-DvoBsChX.js";
2
+ import { w as createScriptContext } from "./dist-DAn07zHu.js";
3
+ import { a as NodeScriptExecutor, c as SkillManager, d as loadLlmConfigFromEnv, f as probeLlmCapabilities, i as NodeFS, l as loadAnthropicConfigFromEnv, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as SandboxedScriptExecutor, t as CliUiBridge, u as loadGoogleConfigFromEnv } from "./dist-BVXZF7H_.js";
4
4
 
5
- export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
5
+ export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv, probeLlmCapabilities, readArchiveManifest };
@@ -0,0 +1 @@
1
+ export {}