@webskill/sdk 0.13.0 → 0.15.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.
Files changed (60) hide show
  1. package/dist/agent.d.ts +3 -3
  2. package/dist/agent.js +2442 -3
  3. package/dist/{dist-ExSQky4C.js → approval-BnLLCOG0.js} +277 -2934
  4. package/dist/browser.d.ts +327 -8
  5. package/dist/browser.js +1017 -51
  6. package/dist/{openUiLibrary-BKXW7Iwx-CWWBVOkE.js → dist-CTsxblSD.js} +496 -28
  7. package/dist/{echarts-De78wXqV.js → echarts-BE7oV_Dl.js} +1 -1
  8. package/dist/{env-8cY40DXB-CGnEVZby.js → env-Bj1MI2Ww.js} +1 -1
  9. package/dist/errors-BDZNpC13.js +22 -0
  10. package/dist/{eventTypes-FllCrX-Z-DNDeHWoG.js → eventTypes-Y07N8IAC.js} +14 -2
  11. package/dist/external-_ZRQe-V9.js +53 -0
  12. package/dist/governance.d.ts +15 -3
  13. package/dist/governance.js +86 -4
  14. package/dist/{index-iBm9tJL_.d.ts → index-CQYo4tcT.d.ts} +469 -10
  15. package/dist/{index-C3XdItd_.d.ts → index-CU2md8R1.d.ts} +26 -18
  16. package/dist/{index-DkvBhJQy.d.ts → index-Oc3H89TJ.d.ts} +204 -4
  17. package/dist/index.d.ts +4 -4
  18. package/dist/index.js +1001 -5
  19. package/dist/kind-DxgS8LM-.js +77 -0
  20. package/dist/linkedDocument-xNXF-z8n.js +94 -0
  21. package/dist/llm-B7lLH0ZI.js +1767 -0
  22. package/dist/mcp.d.ts +56 -3
  23. package/dist/mcp.js +75 -5
  24. package/dist/memoryArtifactStore-D6dLeY55.js +48 -0
  25. package/dist/miniChart-owdCdaw-.js +533 -0
  26. package/dist/node.d.ts +3 -3
  27. package/dist/node.js +110 -13
  28. package/dist/openUiLibrary-CY_ADoe0.js +30 -0
  29. package/dist/openUiSpecLang-DuOCdw9G.js +1849 -0
  30. package/dist/pathSecurity-B1owvJAF.js +65 -0
  31. package/dist/processSandboxEntry.js +5 -1
  32. package/dist/renderResult-D9Q-Vu2x.js +143 -0
  33. package/dist/{rolldown-runtime-BOF7iYI8.js → rolldown-runtime-BHkdefai.js} +1 -2
  34. package/dist/sandboxWorkerEntry.js +5 -1
  35. package/dist/{dist-Bev6i6Ip.js → skill-CAJMsLod.js} +44 -314
  36. package/dist/{skillVersionStore-D-qHk9ZE-DheTIwAB.d.ts → skillVersionStore-B24Jjjry-C4zomhMZ.d.ts} +14 -2
  37. package/dist/surface-DVGiCmwq.js +145 -0
  38. package/dist/testing.d.ts +1 -1
  39. package/dist/testing.js +64 -3
  40. package/dist/{types-DLctJep_-B5G4uk2u.d.ts → types-C3V6lAeO-BIf7UB2e.d.ts} +79 -4
  41. package/dist/types-TUydnxaj.js +78 -0
  42. package/dist/ui-react.d.ts +12 -5
  43. package/dist/ui-react.js +128548 -4729
  44. package/dist/ui-vue.d.ts +1 -1
  45. package/dist/ui-vue.js +11 -2
  46. package/dist/ui.d.ts +3 -3
  47. package/dist/ui.js +1254 -3
  48. package/dist/urlSafety-CiSuCJvX.js +65 -0
  49. package/dist/webSkillApi-DOOyz2G5.js +106 -0
  50. package/dist/{webskillLitCatalog-D_zCqeQF-C9lrvvMr.js → webskillLitCatalog-DSqVFQjK.js} +11 -3
  51. package/package.json +1 -1
  52. package/dist/catalogComponents-BgAJN0p8-CYEXSk45.js +0 -124384
  53. package/dist/client-BCM6Z3yq-qUQNkKrK.js +0 -7787
  54. package/dist/dist-DqcL6jKO.js +0 -3509
  55. package/dist/dist-DxyxmXPU-DGC-dpXf.js +0 -5621
  56. package/dist/dist-GK6dtjRv.js +0 -1493
  57. package/dist/memoryArtifactStore-52Zn9npI-LbCQaqyx.js +0 -86
  58. package/dist/stdio-CFMoANJJ-BxrTeXh7.js +0 -31
  59. package/dist/testing-WPTyXQYt.js +0 -142
  60. package/dist/types-WovEf4ED-CZSDiiBU.js +0 -6215
@@ -0,0 +1,65 @@
1
+ import { t as WebSkillError } from "./errors-BDZNpC13.js";
2
+
3
+ //#region ../core/src/net/urlSafety.ts
4
+ const LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["localhost", "localhost."]);
5
+ function ipv4Octets(host) {
6
+ const parts = host.split(".");
7
+ if (parts.length !== 4) return void 0;
8
+ const octets = parts.map((p) => /^\d{1,3}$/.test(p) ? Number(p) : NaN);
9
+ return octets.every((n) => n >= 0 && n <= 255) ? octets : void 0;
10
+ }
11
+ function isPrivateIpv4(octets) {
12
+ const [a, b] = octets;
13
+ return a === 0 || a === 10 || a === 127 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 169 && b === 254;
14
+ }
15
+ function isPrivateIpv6(host) {
16
+ const h = host.toLowerCase();
17
+ if (h === "::1" || h === "::") return true;
18
+ const mapped = h.match(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/);
19
+ if (mapped) {
20
+ const octets = ipv4Octets(mapped[1]);
21
+ return octets !== void 0 && isPrivateIpv4(octets);
22
+ }
23
+ const mappedHex = h.match(/^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/);
24
+ if (mappedHex) {
25
+ const hi = parseInt(mappedHex[1], 16);
26
+ const lo = parseInt(mappedHex[2], 16);
27
+ return isPrivateIpv4([
28
+ hi >> 8,
29
+ hi & 255,
30
+ lo >> 8,
31
+ lo & 255
32
+ ]);
33
+ }
34
+ const first = h.split(":")[0];
35
+ if (/^[0-9a-f]{1,4}$/.test(first)) {
36
+ const n = parseInt(first, 16);
37
+ if ((n & 65472) === 65152) return true;
38
+ if ((n & 65024) === 64512) return true;
39
+ }
40
+ return false;
41
+ }
42
+ function isPrivateHost(hostname) {
43
+ const host = hostname.toLowerCase();
44
+ if (LOOPBACK_HOSTNAMES.has(host) || host.endsWith(".localhost")) return true;
45
+ const v4 = ipv4Octets(host);
46
+ if (v4) return isPrivateIpv4(v4);
47
+ if (host.startsWith("[") && host.endsWith("]")) return isPrivateIpv6(host.slice(1, -1));
48
+ if (host.includes(":")) return isPrivateIpv6(host);
49
+ return false;
50
+ }
51
+ /**
52
+ * 校验远程 URL 是否允许连接;违规抛 NETWORK_BLOCKED。
53
+ * rawUrl 非合法 URL 时抛 TypeError(由调用方按自身错误码包装)。
54
+ */
55
+ function assertRemoteUrlAllowed(rawUrl, policy = {}) {
56
+ const url = new URL(rawUrl);
57
+ if (url.protocol === "http:") {
58
+ if (!policy.allowHttp) throw new WebSkillError("NETWORK_BLOCKED", `Insecure URL scheme "http:" is not allowed (opt in via allowHttp): ${url.href}`);
59
+ } else if (url.protocol !== "https:") throw new WebSkillError("NETWORK_BLOCKED", `URL scheme "${url.protocol}" is not allowed (https only): ${url.href}`);
60
+ if (!policy.allowPrivateHosts && isPrivateHost(url.hostname)) throw new WebSkillError("NETWORK_BLOCKED", `Refusing to connect to a private/loopback/link-local address: ${url.hostname}`);
61
+ return url;
62
+ }
63
+
64
+ //#endregion
65
+ export { assertRemoteUrlAllowed as t };
@@ -0,0 +1,106 @@
1
+ import { t as WebSkillError } from "./errors-BDZNpC13.js";
2
+ import { b as parseSkillMarkdown, i as buildCatalog, n as SkillDiscovery, t as validateSkills } from "./skill-CAJMsLod.js";
3
+ import { f as WebSkillRuntime } from "./approval-BnLLCOG0.js";
4
+
5
+ //#region ../runtime/src/facade/webSkillApi.ts
6
+ /**
7
+ * navigator.webskill 门面装配层:零新业务逻辑,全部直转
8
+ * SkillDiscovery / validateSkills / WebSkillRuntime / SkillManager。
9
+ * @stable
10
+ */
11
+ function createWebSkillApi(deps) {
12
+ const { fs, roots } = deps;
13
+ let runtime;
14
+ const discoveries = /* @__PURE__ */ new Map();
15
+ const discoveryFor = (paths) => {
16
+ const key = paths.join("");
17
+ let discovery = discoveries.get(key);
18
+ if (!discovery) {
19
+ discovery = new SkillDiscovery(fs, paths);
20
+ discoveries.set(key, discovery);
21
+ }
22
+ return discovery;
23
+ };
24
+ const lazyRuntime = () => {
25
+ runtime ??= new WebSkillRuntime({
26
+ fs,
27
+ roots,
28
+ llm: deps.llm,
29
+ ...deps.executor ? { executor: deps.executor } : {},
30
+ ...deps.artifactStore ? { artifactStore: deps.artifactStore } : {},
31
+ ...deps.loopConfig ? { config: deps.loopConfig } : {}
32
+ });
33
+ return runtime;
34
+ };
35
+ const requireManager = () => {
36
+ if (!deps.skillManager) throw new WebSkillError("TOOL_UNSUPPORTED", "No skill manager is configured; install/uninstall is unavailable");
37
+ return deps.skillManager;
38
+ };
39
+ return {
40
+ async discover(path) {
41
+ const { entries } = await discoveryFor([path]).discover();
42
+ return buildCatalog(entries);
43
+ },
44
+ async read(name) {
45
+ const { entries } = await discoveryFor(roots).discover();
46
+ const entry = entries.find((e) => e.name === name);
47
+ if (!entry) throw new WebSkillError("SKILL_NOT_FOUND", `Unknown skill: ${name}`);
48
+ const skillMdPath = `${entry.root}/SKILL.md`;
49
+ const { metadata, body } = parseSkillMarkdown(await fs.readText(skillMdPath));
50
+ return {
51
+ metadata,
52
+ body,
53
+ location: {
54
+ skillRoot: entry.root,
55
+ skillMdPath,
56
+ source: entry.source
57
+ }
58
+ };
59
+ },
60
+ validate(path) {
61
+ return validateSkills(fs, [path]);
62
+ },
63
+ async run(prompt) {
64
+ return (await lazyRuntime().run(prompt)).run;
65
+ },
66
+ async install(url) {
67
+ const manifest = await requireManager().install(sourceFromUrl(url));
68
+ return {
69
+ name: manifest.name,
70
+ ...manifest.version !== void 0 ? { version: manifest.version } : {},
71
+ installedAt: manifest.installedAt,
72
+ integrity: manifest.integrity
73
+ };
74
+ },
75
+ async uninstall(name) {
76
+ await requireManager().uninstall(name);
77
+ }
78
+ };
79
+ }
80
+ /** install URL 分派:http(s) .zip → http;.git → git(无 git 能力的 manager 自行 TOOL_UNSUPPORTED);
81
+ * 其余 http(s) URL → INSTALL_FAILED(不静默当 local);非 URL → local */
82
+ function sourceFromUrl(url) {
83
+ const bare = url.split("?")[0] ?? url;
84
+ if (/^https?:\/\//.test(url)) {
85
+ if (bare.endsWith(".zip")) return {
86
+ type: "http",
87
+ url
88
+ };
89
+ if (bare.endsWith(".git")) return {
90
+ type: "git",
91
+ url
92
+ };
93
+ throw new WebSkillError("INSTALL_FAILED", `Unsupported install URL "${url}" (supported: http(s) URLs ending in .zip or .git, or local paths)`);
94
+ }
95
+ if (bare.endsWith(".git")) return {
96
+ type: "git",
97
+ url
98
+ };
99
+ return {
100
+ type: "local",
101
+ path: url
102
+ };
103
+ }
104
+
105
+ //#endregion
106
+ export { createWebSkillApi as t };
@@ -1,4 +1,6 @@
1
- import { Dt as uiCatalog, bt as renderMiniMarkdown, et as A2UI_CHILDREN_PROP, ft as WEBSKILL_A2UI_CATALOG_ID, gt as chartSpecFromProps, mt as a2uiComponentShapes, st as DEFAULT_SURFACE_FORM_TEXTS, yt as mountEchart } from "./dist-DqcL6jKO.js";
1
+ import { c as DEFAULT_SURFACE_FORM_TEXTS, i as renderMiniMarkdown } from "./miniChart-owdCdaw-.js";
2
+ import { C as chartSpecFromProps, h as uiCatalog, w as mountEchart } from "./openUiSpecLang-DuOCdw9G.js";
3
+ import { WEBSKILL_A2UI_CATALOG_ID, a2uiComponentShapes, t as A2UI_CHILDREN_PROP } from "./ui.js";
2
4
  import { A2uiController, A2uiLitElement } from "@a2ui/lit/v0_9";
3
5
  import { Catalog } from "@a2ui/web_core/v0_9";
4
6
  import { z } from "zod/v3";
@@ -1419,7 +1421,7 @@ var f = class extends i {
1419
1421
  };
1420
1422
 
1421
1423
  //#endregion
1422
- //#region ../ui/dist/webskillLitCatalog-D_zCqeQF.js
1424
+ //#region ../ui/src/a2uiRuntime/echartDirective.ts
1423
1425
  /**
1424
1426
  * Lit 元素上的 echarts 挂载指令。
1425
1427
  * A2UI 档的 catalog `Chart` 渲染在 shadow root 里,实例必须随元素断开而 dispose,
@@ -1458,6 +1460,9 @@ var EchartDirective = class extends f {
1458
1460
  }
1459
1461
  };
1460
1462
  const echart = e(EchartDirective);
1463
+
1464
+ //#endregion
1465
+ //#region ../ui/src/a2uiRuntime/webskillLitCatalog.ts
1461
1466
  /** 自定义元素 tag 前缀(同一文档里与 A2UI Basic Catalog 的 `a2ui-basic-*` 互不冲突) */
1462
1467
  const WEBSKILL_A2UI_TAG_PREFIX = "webskill-a2ui";
1463
1468
  /** 与 React 档 `specLayout.tsx` 同一组取值:语义档最小列宽与主次分栏比例 */
@@ -1932,7 +1937,10 @@ const renderers = {
1932
1937
  ${props["description"] ? T`<p class="muted">${str(props, "description")}</p>` : A}
1933
1938
  </div>
1934
1939
  `,
1935
- Custom: (props) => T` <div role="alert" class="error">Unsupported registered surface: ${str(props, "name")}</div> `
1940
+ Custom: (props) => T`
1941
+ <div role="alert" class="error">Unsupported registered surface: ${str(props, "name")}</div>
1942
+ `,
1943
+ OpenDocument: () => T` <div role="alert" class="error">Document surface is not supported by this renderer</div> `
1936
1944
  };
1937
1945
  /**
1938
1946
  * shape → A2UI 组件 API 的 zod schema。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webskill/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "WebSkill — browser/Node agent skill runtime (skills, tools, MCP, governance, UI)",
5
5
  "license": "MIT",
6
6
  "type": "module",