@webskill/sdk 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp.js CHANGED
@@ -1,5 +1,5 @@
1
- import { u as WebSkillError } from "./dist-D7MsoMPx.js";
2
- import { P as normalizeToolContent, j as mergeCatalogEntries } from "./dist-CV64gN62.js";
1
+ import { C as messageOf, d as assertRemoteUrlAllowed, u as WebSkillError } from "./dist-BQzncxXg.js";
2
+ import { P as normalizeToolContent, j as mergeCatalogEntries } from "./dist-B77plHjw.js";
3
3
 
4
4
  //#region ../mcp/dist/index.js
5
5
  /**
@@ -172,7 +172,6 @@ var EndpointRegistry = class {
172
172
  for (const resolve of queue) resolve(client);
173
173
  }
174
174
  };
175
- const messageOf$3 = (e) => e instanceof Error ? e.message : String(e);
176
175
  /** MCP 结果单项 text 上限(64KB) */
177
176
  const MAX_MCP_RESULT_TEXT_BYTES = 64 * 1024;
178
177
  const failure$1 = (code, message) => ({
@@ -199,20 +198,20 @@ var McpToolResolver = class {
199
198
  try {
200
199
  client = this.#registry.get(endpoint);
201
200
  } catch (e) {
202
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", messageOf$3(e));
201
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", messageOf(e));
203
202
  }
204
203
  let names;
205
204
  try {
206
205
  names = await this.#toolNames(endpoint, client);
207
206
  } catch (e) {
208
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$3(e)}`);
207
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf(e)}`);
209
208
  }
210
209
  if (!names.has(toolName)) {
211
210
  this.#cache.delete(endpoint);
212
211
  try {
213
212
  names = await this.#toolNames(endpoint, client);
214
213
  } catch (e) {
215
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf$3(e)}`);
214
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Failed to list tools: ${messageOf(e)}`);
216
215
  }
217
216
  if (!names.has(toolName)) return failure$1("MCP_TOOL_NOT_FOUND", `Tool "${toolName}" not found on endpoint "${endpoint}"`);
218
217
  }
@@ -223,7 +222,7 @@ var McpToolResolver = class {
223
222
  });
224
223
  return this.#normalizeCallResult(raw);
225
224
  } catch (e) {
226
- return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Tool "${toolName}" on endpoint "${endpoint}" failed: ${messageOf$3(e)}`);
225
+ return failure$1("MCP_ENDPOINT_UNAVAILABLE", `Tool "${toolName}" on endpoint "${endpoint}" failed: ${messageOf(e)}`);
227
226
  }
228
227
  }
229
228
  async #toolNames(endpoint, client) {
@@ -241,7 +240,7 @@ var McpToolResolver = class {
241
240
  /** CallToolResult → ToolResult;isError 转失败;形状消毒(无 content 且无 isError 不当作 ok)+ 大小上限 */
242
241
  #normalizeCallResult(raw) {
243
242
  const result = raw;
244
- if (result?.isError !== true && result?.content === void 0) return failure$1("MCP_ENDPOINT_UNAVAILABLE", `MCP tool returned a malformed result (no "content" and no "isError"): ${messageOf$3(raw).slice(0, 200)}`);
243
+ if (result?.isError !== true && result?.content === void 0) return failure$1("MCP_ENDPOINT_UNAVAILABLE", `MCP tool returned a malformed result (no "content" and no "isError"): ${messageOf(raw).slice(0, 200)}`);
245
244
  const content = normalizeToolContent(result?.content ?? raw);
246
245
  if (result?.isError === true) {
247
246
  const text = content.map((c) => c.text ?? "").filter(Boolean).join("\n");
@@ -272,7 +271,6 @@ function webMcpToolLlmName(toolName) {
272
271
  function parseWebMcpToolLlmName(llmName) {
273
272
  return llmName.startsWith("mcp__") && llmName.length > 5 ? llmName.slice(5) : void 0;
274
273
  }
275
- const messageOf$2 = (e) => e instanceof Error ? e.message : String(e);
276
274
  const textOfContent = (content) => {
277
275
  if (typeof content === "string") return content;
278
276
  if (typeof content === "object" && content !== null) {
@@ -318,7 +316,7 @@ var TemporarySkillProvider = class {
318
316
  try {
319
317
  result = await client.getPrompt({ name });
320
318
  } catch (e) {
321
- throw new WebSkillError("SKILL_NOT_FOUND", `Prompt "${name}" not found on endpoint "${this.#endpoint}": ${messageOf$2(e)}`, e);
319
+ throw new WebSkillError("SKILL_NOT_FOUND", `Prompt "${name}" not found on endpoint "${this.#endpoint}": ${messageOf(e)}`, e);
322
320
  }
323
321
  const body = (result.messages ?? []).map((m) => textOfContent(m.content)).filter(Boolean).join("\n\n");
324
322
  return {
@@ -343,7 +341,7 @@ var TemporarySkillProvider = class {
343
341
  try {
344
342
  return this.#registry.get(this.#endpoint);
345
343
  } catch (e) {
346
- throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", messageOf$2(e), e);
344
+ throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", messageOf(e), e);
347
345
  }
348
346
  }
349
347
  };
@@ -386,7 +384,6 @@ async function serveSkillAsMcp(server, skill) {
386
384
  * 实现单一来源在 runtime(runtime 自身合并也用同一函数)。
387
385
  */
388
386
  const catalogMerge = mergeCatalogEntries;
389
- const messageOf$1 = (e) => e instanceof Error ? e.message : String(e);
390
387
  const failure = (code, message) => ({
391
388
  ok: false,
392
389
  content: [],
@@ -449,7 +446,7 @@ var ExperimentalWebMcpAdapter = class {
449
446
  content: normalizeToolContent(await api.executeTool(toolName, JSON.stringify(args)))
450
447
  };
451
448
  } catch (e) {
452
- return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf$1(e)}`);
449
+ return failure("TOOL_EXECUTION_FAILED", `WebMCP tool "${toolName}" failed: ${messageOf(e)}`);
453
450
  }
454
451
  }
455
452
  };
@@ -545,7 +542,6 @@ async function loadMcpSdk() {
545
542
  throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", "The \"@modelcontextprotocol/sdk\" package is required for remote MCP endpoints; install it first (npm i @modelcontextprotocol/sdk)", e);
546
543
  }
547
544
  }
548
- const messageOf = (e) => e instanceof Error ? e.message : String(e);
549
545
  /**
550
546
  * 远程 MCP endpoint 装配:SDK 官方 StreamableHTTPClientTransport(默认)/
551
547
  * SSEClientTransport(遗留)连接远端 server,注册进 EndpointRegistry——
@@ -560,6 +556,10 @@ async function connectRemoteEndpoint(registry, config) {
560
556
  } catch (e) {
561
557
  throw new WebSkillError("MCP_ENDPOINT_UNAVAILABLE", `Invalid remote MCP endpoint URL for "${config.endpoint}": ${JSON.stringify(config.url)}`, e);
562
558
  }
559
+ assertRemoteUrlAllowed(url.href, {
560
+ allowHttp: config.allowHttp ?? false,
561
+ allowPrivateHosts: config.allowPrivateHosts ?? false
562
+ });
563
563
  const requestInit = config.headers ? { headers: config.headers } : void 0;
564
564
  const transport = config.transport === "sse" ? new SSEClientTransport(url, { ...requestInit ? { requestInit } : {} }) : new StreamableHTTPClientTransport(url, { ...requestInit ? { requestInit } : {} });
565
565
  const client = new Client({
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { D as SKILLS_LOCKFILE, I as SkillInstallSource, K as VerifyResult, O as SKILL_MANIFEST_FILE, W as SkillsLockfile, z as SkillManifest } from "./types-CKm5G_eQ-BqyXnvoR.js";
2
- import { ht as createScriptContext } from "./index-DZShzhon.js";
1
+ import { B as SkillManifest, G as SkillsLockfile, L as SkillInstallSource, O as SKILLS_LOCKFILE, k as SKILL_MANIFEST_FILE, q as VerifyResult } from "./types-CKm5G_eQ-krKWW8WV.js";
2
+ import { ht as createScriptContext } from "./index-DfINBEOy.js";
3
3
  import { n as LlmEnvConfig, s as probeLlmCapabilities, t as LlmCapabilities } from "./env-BPUBZCwJ-4jat_SVG.js";
4
- import { a as NodeScriptExecutor, c as ProcessSandboxOptions, d as SkillManager, f as exportArchive, i as NodeFS, l as SandboxOptions, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as SandboxedScriptExecutor } from "./index-DrHelz72.js";
4
+ import { a as NodeScriptExecutor, c as ProcessSandboxOptions, d as SkillManager, f as exportArchive, i as NodeFS, l as SandboxOptions, n as FileArtifactStore, o as OxcSchemaInferer, p as readArchiveManifest, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as SandboxedScriptExecutor } from "./index-CsDJvYGV.js";
5
5
  export { CliUiBridge, FileArtifactStore, FileMemoryStore, type LlmCapabilities, type LlmEnvConfig, NodeFS, NodeScriptExecutor, OxcSchemaInferer, ProcessSandboxExecutor, type ProcessSandboxOptions, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, type SandboxOptions, SandboxedScriptExecutor, type SkillInstallSource, SkillManager, type SkillManifest, type SkillsLockfile, type VerifyResult, createScriptContext, exportArchive, probeLlmCapabilities, readArchiveManifest };
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
- import { i as SKILL_MANIFEST_FILE, r as SKILLS_LOCKFILE } from "./dist-D7MsoMPx.js";
2
- import { T as createScriptContext } from "./dist-CV64gN62.js";
1
+ import { i as SKILL_MANIFEST_FILE, r as SKILLS_LOCKFILE } from "./dist-BQzncxXg.js";
2
+ import { T as createScriptContext } from "./dist-B77plHjw.js";
3
3
  import { i as probeLlmCapabilities } from "./env--jJB-TSX-04klhTYi.js";
4
- import { a as NodeScriptExecutor, c as SandboxedScriptExecutor, d as readArchiveManifest, i as NodeFS, l as SkillManager, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as exportArchive } from "./dist-Chgf2tcy.js";
4
+ import { a as NodeScriptExecutor, c as SandboxedScriptExecutor, d as readArchiveManifest, i as NodeFS, l as SkillManager, n as FileArtifactStore, o as OxcSchemaInferer, r as FileMemoryStore, s as ProcessSandboxExecutor, t as CliUiBridge, u as exportArchive } from "./dist-Chk8iB-E.js";
5
5
 
6
6
  export { CliUiBridge, FileArtifactStore, FileMemoryStore, NodeFS, NodeScriptExecutor, OxcSchemaInferer, ProcessSandboxExecutor, SKILLS_LOCKFILE, SKILL_MANIFEST_FILE, SandboxedScriptExecutor, SkillManager, createScriptContext, exportArchive, probeLlmCapabilities, readArchiveManifest };
@@ -1,4 +1,4 @@
1
- import { u as WebSkillError } from "./dist-D7MsoMPx.js";
1
+ import { u as WebSkillError } from "./dist-BQzncxXg.js";
2
2
 
3
3
  //#region ../runtime/dist/testing.js
4
4
  /**
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
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-BqyXnvoR.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-krKWW8WV.js";
2
2
  import { a as loadGoogleConfigFromEnv, i as loadAnthropicConfigFromEnv, n as LlmEnvConfig, o as loadLlmConfigFromEnv, r as ProviderEnvConfig } from "./env-BPUBZCwJ-4jat_SVG.js";
3
3
  //#region ../runtime/dist/testing.d.ts
4
4
  //#region src/llm/mockLlmClient.d.ts
package/dist/testing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as MemoryArtifactStore } from "./memoryArtifactStore-C9lFVqPF-yFz6yJj0.js";
2
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-BN18eqbD.js";
3
+ import { n as MockLlmClient, r as MockUiBridge, t as InMemoryStore } from "./testing-BUoXvm1u.js";
4
4
 
5
5
  export { InMemoryStore, MemoryArtifactStore, MockLlmClient, MockUiBridge, loadAnthropicConfigFromEnv, loadGoogleConfigFromEnv, loadLlmConfigFromEnv };
@@ -10,6 +10,8 @@ declare class WebSkillError extends Error {
10
10
  readonly details?: unknown;
11
11
  constructor(code: WebSkillErrorCode, message: string, details?: unknown);
12
12
  }
13
+ /** unknown 异常取消息文本(全仓单一来源,勿再本地重复定义) */
14
+ declare function messageOf(e: unknown): string;
13
15
  //#endregion
14
16
  //#region src/contracts/jsonSchema.d.ts
15
17
  /**
@@ -34,6 +36,10 @@ type SkillInstallSource = {
34
36
  } | {
35
37
  type: 'http';
36
38
  url: string;
39
+ /** 显式允许 http://(SSRF 防护默认仅 https) */
40
+ allowHttp?: boolean;
41
+ /** 显式允许私有/环回/链路本地地址(SSRF 防护默认拒绝) */
42
+ allowPrivateHosts?: boolean;
37
43
  } | {
38
44
  type: 'archive';
39
45
  data: ArrayBuffer;
@@ -160,7 +166,12 @@ declare class MemoryFS implements FileSystemProvider {
160
166
  }
161
167
  //#endregion
162
168
  //#region src/fs/atomicWrite.d.ts
163
- /** 原子写文本:先写临时文件再 rename(进程崩溃不留下半写文件;lockfile 等账本场景) */
169
+ /**
170
+ * 原子写文本:先写临时文件再 rename(进程崩溃不留下半写文件;lockfile 等账本场景)。
171
+ * 原子性强弱取决于 provider 的 rename 实现:NodeFS/MemoryFS 为真 rename;
172
+ * OPFS 无原生 move,rename 是 copy+delete(非原子,崩溃可能残留双份),
173
+ * 对崩溃一致性要求极高的场景在浏览器侧需知悉此前提。
174
+ */
164
175
  declare function atomicWriteText(fs: FileSystemProvider, path: string, content: string): Promise<void>;
165
176
  //#endregion
166
177
  //#region src/fs/pathSecurity.d.ts
@@ -177,6 +188,25 @@ declare function assertSafePathSegment(segment: string, kind: string): void;
177
188
  */
178
189
  declare function resolveInsideRoot(root: string, relativePath: string): string;
179
190
  //#endregion
191
+ //#region src/net/urlSafety.d.ts
192
+ /**
193
+ * SSRF 防护(单一来源:node http 安装源与 mcp 远程 endpoint 共用):
194
+ * - 协议限 https(http 需显式 opt-in)
195
+ * - 默认拒私有/环回/链路本地地址字面量(127.0.0.0/8、RFC1918、169.254.0.0/16、localhost、::1、fe80::/10)
196
+ * 注意:仅校验 URL 字面量主机名;DNS 解析到私有地址的 rebinding 场景不在此层覆盖。
197
+ */
198
+ interface RemoteUrlPolicy {
199
+ /** 显式允许 http://(默认仅 https) */
200
+ allowHttp?: boolean;
201
+ /** 显式允许私有/环回/链路本地地址(默认拒绝) */
202
+ allowPrivateHosts?: boolean;
203
+ }
204
+ /**
205
+ * 校验远程 URL 是否允许连接;违规抛 NETWORK_BLOCKED。
206
+ * rawUrl 非合法 URL 时抛 TypeError(由调用方按自身错误码包装)。
207
+ */
208
+ declare function assertRemoteUrlAllowed(rawUrl: string, policy?: RemoteUrlPolicy): URL;
209
+ //#endregion
180
210
  //#region src/skill/types.d.ts
181
211
  type SkillSource = 'local' | 'mcp' | 'generated' | 'installed';
182
212
  /**
@@ -586,4 +616,4 @@ interface MemoryStore {
586
616
  transaction?<T>(scope: string, fn: (inner: MemoryStore) => Promise<T>): Promise<T>;
587
617
  }
588
618
  //#endregion
589
- 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 };
619
+ export { buildCatalog as $, SKILL_NAME_MAX_LENGTH as A, SkillManifest as B, FileStat as C, RemoteUrlPolicy as D, MemoryFS as E, SkillDiscovery as F, SkillsLockfile as G, SkillPackManifest as H, SkillDocument as I, WebSkillError as J, ValidationReport as K, SkillInstallSource as L, SKILL_PACK_FILE as M, SkillCatalog as N, SKILLS_LOCKFILE as O, SkillCatalogEntry as P, atomicWriteText as Q, SkillIssue as R, DiscoveryResult as S, JsonSchema as T, SkillReader as U, SkillMetadata as V, SkillSource as W, assertRemoteUrlAllowed as X, WebSkillErrorCode as Y, assertSafePathSegment as Z, RenderResultRequest as _, unzipWithLimits as _t, InteractionPolicy as a, exportSkills as at, CatalogRenderer as b, xmlRenderer as bt, LlmClient as c, messageOf as ct, LlmResponse as d, parseSkillPackManifest as dt, buildManifest as et, LlmStreamEvent as f, readResponseWithLimit as ft, RenderBlock as g, resolveInsideRoot as gt, MemoryStore as h, resolveArchiveLimits as ht, FormField as i, escapeXml as it, SKILL_NAME_PATTERN as j, SKILL_MANIFEST_FILE as k, LlmCompleteInput as l, normalizePath as lt, LlmToolSpec as m, renderCatalogJson as mt, ArtifactStore as n, checkSkillRules as nt, InteractionRequest as o, isValidSkillName as ot, LlmToolCall as p, renderAvailableSkillsXml as pt, VerifyResult as q, ChartSpec as r, computeDigest as rt, InteractionResponse as s, jsonRenderer as st, Artifact as t, checkDependencyCycles as tt, LlmMessage as u, parseSkillMarkdown as ut, UiBridge as v, validateSkills as vt, FileSystemProvider as w, DEFAULT_ARCHIVE_LIMITS as x, ArchiveLimits as y, verifyManifest as yt, SkillLocation as z };
@@ -1,4 +1,4 @@
1
- import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-BqyXnvoR.js";
1
+ import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-krKWW8WV.js";
2
2
  //#region ../ui-react/dist/index.d.ts
3
3
  //#region src/bridgeState.d.ts
4
4
  /**
@@ -17,6 +17,8 @@ declare class ReactBridgeState implements UiBridge {
17
17
  request(input: InteractionRequest): Promise<InteractionResponse>;
18
18
  /** 组件提交/取消回调 */
19
19
  resolve(response: InteractionResponse): void;
20
+ /** runtime 交互超时/取消:卸载表单并以 cancelled resolve pending Promise(防悬挂 + 残留) */
21
+ cancel(id: string): void;
20
22
  renderResult(input: RenderResultRequest): Promise<void>;
21
23
  onTextDelta(runId: string, delta: string): Promise<void>;
22
24
  }
package/dist/ui-react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-CeNAzFYi.js";
1
+ import { C as renderMiniChart, E as shapeInteractionValue, h as collectValues, w as renderMiniMarkdown, x as interactionToFormModel } from "./dist-DNSG9FqC.js";
2
2
  import { useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -39,6 +39,13 @@ var ReactBridgeState = class {
39
39
  this.#emit();
40
40
  resolver(response);
41
41
  }
42
+ /** runtime 交互超时/取消:卸载表单并以 cancelled resolve pending Promise(防悬挂 + 残留) */
43
+ cancel(id) {
44
+ this.resolve({
45
+ id,
46
+ cancelled: true
47
+ });
48
+ }
42
49
  async renderResult(input) {
43
50
  this.latestResult = input;
44
51
  this.#emit();
package/dist/ui-vue.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-BqyXnvoR.js";
1
+ import { _ as RenderResultRequest, o as InteractionRequest, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-krKWW8WV.js";
2
2
  import { PropType } from "vue";
3
3
  //#region ../ui-vue/dist/index.d.ts
4
4
  //#region src/bridgeState.d.ts
@@ -18,6 +18,8 @@ declare class VueBridgeState implements UiBridge {
18
18
  request(input: InteractionRequest): Promise<InteractionResponse>;
19
19
  /** 组件提交/取消回调 */
20
20
  resolve(response: InteractionResponse): void;
21
+ /** runtime 交互超时/取消:卸载表单并以 cancelled resolve pending Promise(防悬挂 + 残留) */
22
+ cancel(id: string): void;
21
23
  renderResult(input: RenderResultRequest): Promise<void>;
22
24
  onTextDelta(runId: string, delta: string): Promise<void>;
23
25
  }
package/dist/ui-vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { S as renderMiniMarkdown, m as collectValues, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-CeNAzFYi.js";
1
+ import { C as renderMiniChart, E as shapeInteractionValue, h as collectValues, w as renderMiniMarkdown, x as interactionToFormModel } from "./dist-DNSG9FqC.js";
2
2
  import { defineComponent, h, reactive, ref } from "vue";
3
3
 
4
4
  //#region ../ui-vue/dist/index.js
@@ -28,6 +28,13 @@ var VueBridgeState = class {
28
28
  this.state.pending = null;
29
29
  resolver(response);
30
30
  }
31
+ /** runtime 交互超时/取消:卸载表单并以 cancelled resolve pending Promise(防悬挂 + 残留) */
32
+ cancel(id) {
33
+ this.resolve({
34
+ id,
35
+ cancelled: true
36
+ });
37
+ }
31
38
  async renderResult(input) {
32
39
  this.state.latestResult = input;
33
40
  }
package/dist/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as RenderResultRequest, g as RenderBlock, o as InteractionRequest, r as ChartSpec, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-BqyXnvoR.js";
2
- import { mt as buildRenderResult } from "./index-DZShzhon.js";
1
+ import { _ as RenderResultRequest, g as RenderBlock, o as InteractionRequest, r as ChartSpec, s as InteractionResponse, v as UiBridge } from "./types-CKm5G_eQ-krKWW8WV.js";
2
+ import { mt as buildRenderResult } from "./index-DfINBEOy.js";
3
3
  //#region ../ui/dist/index.d.ts
4
4
  //#region src/model/formModel.d.ts
5
5
  interface FormModel {
@@ -35,7 +35,7 @@ interface CollectedValues {
35
35
  }
36
36
  /**
37
37
  * 严格类型化控件值收集:
38
- * - number 空串 → undefined(非 0)
38
+ * - number 空串 → undefined(非 0);非数值输入(NaN)按缺失处理(required 时入 missingRequired
39
39
  * - select 用 option 值本身经 JSON 编码比对命中(对象值可正确命中)
40
40
  * - required 空值列入 missingRequired(由调用方阻止提交并标记)
41
41
  */
@@ -133,12 +133,15 @@ declare class VercelUiBridge implements UiBridge {
133
133
  * - 每行一条语句 `identifier = Expression`,`root = Component(...)` 为入口
134
134
  * - 组件调用参数为位置参数;字符串双引号反斜杠转义
135
135
  * - 组件词汇(与应用 Library 约定):Form(title, children)、
136
+ * Text(content)(纯展示文本,authorize 的能力描述用)、
136
137
  * TextField(name, label, required?, defaultValue?)、NumberField、BooleanField(name, label, default?)、
137
138
  * SelectField(name, label, options)、SubmitButton(label, actionType, requestId)、
138
139
  * CancelButton(label, actionType, requestId)
139
140
  */
140
141
  declare const OPENUI_SUBMIT_ACTION = "webskill:submit";
141
142
  declare const OPENUI_CANCEL_ACTION = "webskill:cancel";
143
+ /** authorize 的 Allow 专用动作(提交即批准 → value:true;Deny 走 cancel → cancelled:true) */
144
+ declare const OPENUI_AUTHORIZE_ACTION = "webskill:authorize";
142
145
  /** @experimental */
143
146
  declare function toOpenUiLang(request: InteractionRequest): string;
144
147
  /**
@@ -170,10 +173,19 @@ interface A2uiMessage {
170
173
  /** @experimental */
171
174
  declare function toA2uiMessages(request: InteractionRequest): A2uiMessage[];
172
175
  /**
173
- * A2UI client→server action 事件 → InteractionResponse
176
+ * InteractionRequest.type 解码提交值(绑定模型原样回传的是表单对象):
177
+ * confirm 仅 confirmed===true 批准;select 还原原始 option 值(非字符串值经 JSON 编码比对);
178
+ * form 的 number 字段转 number(NaN 保留原值);ask 取 answer;authorize 提交即批准。
179
+ * 纯转换器:任何直接使用 fromA2uiAction 的消费者都应经此拿到正确类型。
174
180
  * @experimental
175
181
  */
176
- declare function fromA2uiAction(event: unknown): InteractionResponse;
182
+ declare function decodeInteractionResponse(request: InteractionRequest, response: InteractionResponse): InteractionResponse;
183
+ /**
184
+ * A2UI client→server action 事件 → InteractionResponse。
185
+ * 传入 request 时按类型解码提交值(见 decodeInteractionResponse)。
186
+ * @experimental
187
+ */
188
+ declare function fromA2uiAction(event: unknown, request?: InteractionRequest): InteractionResponse;
177
189
  //#endregion
178
190
  //#region src/a2uiRuntime/litRendererBridge.d.ts
179
191
  /** @experimental */
@@ -184,6 +196,8 @@ declare class LitRendererBridge implements UiBridge {
184
196
  document?: Document;
185
197
  });
186
198
  request(input: InteractionRequest): Promise<InteractionResponse>;
199
+ /** runtime 交互超时/取消:移除 surface 并以 cancelled resolve pending Promise(防悬挂 + DOM 残留) */
200
+ cancel(id: string): void;
187
201
  }
188
202
  //#endregion
189
- export { A2UI_BASIC_CATALOG_ID, A2UI_CANCEL_ACTION, A2UI_SUBMIT_ACTION, A2UI_VERSION, type A2uiMessage, CHART_PALETTE, type CollectedValues, type ControlModel, type FormModel, LitRendererBridge, OPENUI_CANCEL_ACTION, OPENUI_SUBMIT_ACTION, VERCEL_INTERACTION_TOOL_NAME, type VercelToolInvocation, VercelUiBridge, WEBSKILL_STYLES_CSS, WebFormBridge, buildRenderResult, chartToTable, collectValues, ensureStyles, fromA2uiAction, fromOpenUiAction, fromVercelToolResult, interactionToFormModel, renderBlocks, renderMiniChart, renderMiniMarkdown, renderRenderResult, shapeInteractionValue, toA2uiMessages, toOpenUiLang, toVercelToolInvocation };
203
+ export { A2UI_BASIC_CATALOG_ID, A2UI_CANCEL_ACTION, A2UI_SUBMIT_ACTION, A2UI_VERSION, type A2uiMessage, CHART_PALETTE, type CollectedValues, type ControlModel, type FormModel, LitRendererBridge, OPENUI_AUTHORIZE_ACTION, OPENUI_CANCEL_ACTION, OPENUI_SUBMIT_ACTION, VERCEL_INTERACTION_TOOL_NAME, type VercelToolInvocation, VercelUiBridge, WEBSKILL_STYLES_CSS, WebFormBridge, buildRenderResult, chartToTable, collectValues, decodeInteractionResponse, ensureStyles, fromA2uiAction, fromOpenUiAction, fromVercelToolResult, interactionToFormModel, renderBlocks, renderMiniChart, renderMiniMarkdown, renderRenderResult, shapeInteractionValue, toA2uiMessages, toOpenUiLang, toVercelToolInvocation };
package/dist/ui.js CHANGED
@@ -1,4 +1,4 @@
1
- import { w as buildRenderResult } from "./dist-CV64gN62.js";
2
- import { C as renderRenderResult, D as toVercelToolInvocation, E as toOpenUiLang, S as renderMiniMarkdown, T as toA2uiMessages, _ as fromOpenUiAction, a as CHART_PALETTE, b as renderBlocks, c as OPENUI_SUBMIT_ACTION, d as WEBSKILL_STYLES_CSS, f as WebFormBridge, g as fromA2uiAction, h as ensureStyles, i as A2UI_VERSION, l as VERCEL_INTERACTION_TOOL_NAME, m as collectValues, n as A2UI_CANCEL_ACTION, o as LitRendererBridge, p as chartToTable, r as A2UI_SUBMIT_ACTION, s as OPENUI_CANCEL_ACTION, t as A2UI_BASIC_CATALOG_ID, u as VercelUiBridge, v as fromVercelToolResult, w as shapeInteractionValue, x as renderMiniChart, y as interactionToFormModel } from "./dist-CeNAzFYi.js";
1
+ import { w as buildRenderResult } from "./dist-B77plHjw.js";
2
+ import { C as renderMiniChart, D as toA2uiMessages, E as shapeInteractionValue, O as toOpenUiLang, S as renderBlocks, T as renderRenderResult, _ as ensureStyles, a as CHART_PALETTE, b as fromVercelToolResult, c as OPENUI_CANCEL_ACTION, d as VercelUiBridge, f as WEBSKILL_STYLES_CSS, g as decodeInteractionResponse, h as collectValues, i as A2UI_VERSION, k as toVercelToolInvocation, l as OPENUI_SUBMIT_ACTION, m as chartToTable, n as A2UI_CANCEL_ACTION, o as LitRendererBridge, p as WebFormBridge, r as A2UI_SUBMIT_ACTION, s as OPENUI_AUTHORIZE_ACTION, t as A2UI_BASIC_CATALOG_ID, u as VERCEL_INTERACTION_TOOL_NAME, v as fromA2uiAction, w as renderMiniMarkdown, x as interactionToFormModel, y as fromOpenUiAction } from "./dist-DNSG9FqC.js";
3
3
 
4
- export { A2UI_BASIC_CATALOG_ID, A2UI_CANCEL_ACTION, A2UI_SUBMIT_ACTION, A2UI_VERSION, CHART_PALETTE, LitRendererBridge, OPENUI_CANCEL_ACTION, OPENUI_SUBMIT_ACTION, VERCEL_INTERACTION_TOOL_NAME, VercelUiBridge, WEBSKILL_STYLES_CSS, WebFormBridge, buildRenderResult, chartToTable, collectValues, ensureStyles, fromA2uiAction, fromOpenUiAction, fromVercelToolResult, interactionToFormModel, renderBlocks, renderMiniChart, renderMiniMarkdown, renderRenderResult, shapeInteractionValue, toA2uiMessages, toOpenUiLang, toVercelToolInvocation };
4
+ export { A2UI_BASIC_CATALOG_ID, A2UI_CANCEL_ACTION, A2UI_SUBMIT_ACTION, A2UI_VERSION, CHART_PALETTE, LitRendererBridge, OPENUI_AUTHORIZE_ACTION, OPENUI_CANCEL_ACTION, OPENUI_SUBMIT_ACTION, VERCEL_INTERACTION_TOOL_NAME, VercelUiBridge, WEBSKILL_STYLES_CSS, WebFormBridge, buildRenderResult, chartToTable, collectValues, decodeInteractionResponse, ensureStyles, fromA2uiAction, fromOpenUiAction, fromVercelToolResult, interactionToFormModel, renderBlocks, renderMiniChart, renderMiniMarkdown, renderRenderResult, shapeInteractionValue, toA2uiMessages, toOpenUiLang, toVercelToolInvocation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webskill/sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "WebSkill \u2014 browser/Node agent skill runtime (skills, tools, MCP, governance, UI)",
5
5
  "license": "MIT",
6
6
  "type": "module",