@webskill/sdk 0.6.0 → 0.8.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.
- package/dist/agent.d.ts +2 -2
- package/dist/agent.js +218 -28
- package/dist/browser.d.ts +177 -4
- package/dist/browser.js +444 -35
- package/dist/{catalogComponents-Dr5dFMAb-Dacibl1e.js → catalogComponents-DfxxfUvn-D55Gbb2l.js} +4016 -1226
- package/dist/{dist-8oQRa8Xz.js → dist-59XlqDuv.js} +93 -6
- package/dist/{dist-DnYG2-eY.js → dist-CJqQsIm9.js} +498 -118
- package/dist/{dist-DusANsrn.js → dist-DmI5SBBF.js} +437 -55
- package/dist/eventTypes-g1BXL6x5-CibcOftR.js +37 -0
- package/dist/governance.d.ts +91 -11
- package/dist/governance.js +194 -52
- package/dist/{index-C-KFAZoF.d.ts → index-K-eewlGL.d.ts} +176 -75
- package/dist/{index-BMocOEi0.d.ts → index-P9J2LTfU.d.ts} +163 -6
- package/dist/{index-BuTpBMzr.d.ts → index-fLskQfAS.d.ts} +156 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/mcp.d.ts +129 -6
- package/dist/mcp.js +235 -28
- package/dist/{memoryArtifactStore-52Zn9npI-BMPYwvoy.js → memoryArtifactStore-52Zn9npI-upv5OWYf.js} +1 -1
- package/dist/node.d.ts +3 -3
- package/dist/node.js +4 -3
- package/dist/{openUiLibrary-Bdrji9qK-DzAxRlTY.js → openUiLibrary-DURlAxjk-CU6AzfSW.js} +3 -3
- package/dist/{skillVersionStore-BzLbzFOL-CxdAFWO2.d.ts → skillVersionStore-Bl-ElD45-gRfSaAby.d.ts} +8 -2
- package/dist/{testing-CYTFqkDm.js → testing-BCUO5gZR.js} +2 -2
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/{types-4pg-qp_I-Gq63X8Oa.d.ts → types-B3n0cMZu-BdcqQ35O.d.ts} +74 -7
- package/dist/ui-react.d.ts +16 -7
- package/dist/ui-react.js +159 -108
- package/dist/ui-vue.d.ts +1 -1
- package/dist/ui-vue.js +2 -2
- package/dist/ui.d.ts +4 -4
- package/dist/ui.js +3 -3
- package/dist/{webskillLitCatalog-_mugzRHx-B_54vxum.js → webskillLitCatalog-DwTwSBFt-DiXXpNZA.js} +22 -3
- package/package.json +2 -2
|
@@ -714,6 +714,87 @@ function parseSkillPackManifest(text) {
|
|
|
714
714
|
}
|
|
715
715
|
return raw;
|
|
716
716
|
}
|
|
717
|
+
const SKILL_FILE = "SKILL.md";
|
|
718
|
+
function normalize(path) {
|
|
719
|
+
return path.replace(/^\.?\//, "");
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* 按归档条目表判定包结构。
|
|
723
|
+
*
|
|
724
|
+
* 入参是条目表而不是文件系统:预览侧只有解压后的 entries,没有落盘的目录。
|
|
725
|
+
* 只看路径,不读内容——内容合法性由 checkSkillRules 负责,两者不重叠。
|
|
726
|
+
*/
|
|
727
|
+
function detectSkillArchiveShape(entries) {
|
|
728
|
+
const paths = [];
|
|
729
|
+
for (const raw of entries) {
|
|
730
|
+
const p = normalize(raw);
|
|
731
|
+
if (p !== "") paths.push(p);
|
|
732
|
+
}
|
|
733
|
+
if (paths.length === 0) return {
|
|
734
|
+
shape: "invalid",
|
|
735
|
+
reason: "Archive is empty."
|
|
736
|
+
};
|
|
737
|
+
if (paths.includes("webskill.skill-pack.json")) return { shape: "pack-set" };
|
|
738
|
+
if (paths.includes(SKILL_FILE)) return { shape: "flat" };
|
|
739
|
+
const topLevels = /* @__PURE__ */ new Set();
|
|
740
|
+
let hasLooseRootFile = false;
|
|
741
|
+
for (const p of paths) {
|
|
742
|
+
const slash = p.indexOf("/");
|
|
743
|
+
if (slash <= 0) hasLooseRootFile = true;
|
|
744
|
+
else topLevels.add(p.slice(0, slash));
|
|
745
|
+
}
|
|
746
|
+
if (!hasLooseRootFile && topLevels.size === 1) {
|
|
747
|
+
const [dir] = [...topLevels];
|
|
748
|
+
if (dir !== void 0) {
|
|
749
|
+
if (paths.includes(`${dir}/webskill.skill-pack.json`)) return {
|
|
750
|
+
shape: "pack-set",
|
|
751
|
+
rootDir: dir
|
|
752
|
+
};
|
|
753
|
+
if (paths.includes(`${dir}/${SKILL_FILE}`)) return {
|
|
754
|
+
shape: "nested-single",
|
|
755
|
+
rootDir: dir
|
|
756
|
+
};
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
return {
|
|
760
|
+
shape: "invalid",
|
|
761
|
+
reason: `Archive does not contain a ${SKILL_FILE} at its root or in a single top-level directory.`
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
/** nested-single 时剥掉顶层目录,其余形态原样返回 */
|
|
765
|
+
function stripArchiveRoot(entries, detection) {
|
|
766
|
+
if (detection.rootDir === void 0) return entries;
|
|
767
|
+
const prefix = `${detection.rootDir}/`;
|
|
768
|
+
const out = {};
|
|
769
|
+
for (const [path, value] of Object.entries(entries)) {
|
|
770
|
+
const p = normalize(path);
|
|
771
|
+
if (!p.startsWith(prefix)) continue;
|
|
772
|
+
const rel = p.slice(prefix.length);
|
|
773
|
+
if (rel !== "") out[rel] = value;
|
|
774
|
+
}
|
|
775
|
+
return out;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* 文件系统入口:安装管线拿到的是解压后的目录,不是条目表。
|
|
779
|
+
*
|
|
780
|
+
* 只探测判定所需的少量路径(不递归全量列举),再交给上面的纯函数——
|
|
781
|
+
* 判定规则仍然只有一份,这正是 S7 的目的。
|
|
782
|
+
*/
|
|
783
|
+
async function detectSkillArchiveShapeFromFs(fs, contentDir) {
|
|
784
|
+
const sample = [];
|
|
785
|
+
const top = await fs.list(contentDir);
|
|
786
|
+
for (const entry of top) {
|
|
787
|
+
const name = entry.path.slice(contentDir.length + 1);
|
|
788
|
+
if (entry.type !== "directory") {
|
|
789
|
+
sample.push(name);
|
|
790
|
+
continue;
|
|
791
|
+
}
|
|
792
|
+
if (await fs.exists(`${entry.path}/${SKILL_FILE}`)) sample.push(`${name}/${SKILL_FILE}`);
|
|
793
|
+
else if (await fs.exists(`${entry.path}/webskill.skill-pack.json`)) sample.push(`${name}/${SKILL_PACK_FILE}`);
|
|
794
|
+
else sample.push(`${name}/`);
|
|
795
|
+
}
|
|
796
|
+
return detectSkillArchiveShape(sample);
|
|
797
|
+
}
|
|
717
798
|
const DEFAULT_ARCHIVE_LIMITS = {
|
|
718
799
|
maxDownloadBytes: 64 * 1024 * 1024,
|
|
719
800
|
maxEntryBytes: 64 * 1024 * 1024,
|
|
@@ -854,12 +935,15 @@ const baseName = (path) => path.split("/").pop() ?? path;
|
|
|
854
935
|
var SkillDiscovery = class {
|
|
855
936
|
#fs;
|
|
856
937
|
#roots;
|
|
938
|
+
/** 扫描范围之外已知存在的技能名:只影响 dependencies 存在性判定,不产生目录项 */
|
|
939
|
+
#extraKnownSkillNames;
|
|
857
940
|
/** name → skillRoot,与 SkillReader 共享同一 Map 引用 */
|
|
858
941
|
#index = /* @__PURE__ */ new Map();
|
|
859
942
|
#reader;
|
|
860
|
-
constructor(fs, roots) {
|
|
943
|
+
constructor(fs, roots, options) {
|
|
861
944
|
this.#fs = fs;
|
|
862
945
|
this.#roots = roots;
|
|
946
|
+
this.#extraKnownSkillNames = options?.extraKnownSkillNames ?? [];
|
|
863
947
|
this.#reader = new SkillReader(fs, this.#index);
|
|
864
948
|
}
|
|
865
949
|
async discover() {
|
|
@@ -867,7 +951,7 @@ var SkillDiscovery = class {
|
|
|
867
951
|
const entries = [];
|
|
868
952
|
const issues = [];
|
|
869
953
|
const candidates = [];
|
|
870
|
-
const knownSkillNames =
|
|
954
|
+
const knownSkillNames = new Set(this.#extraKnownSkillNames);
|
|
871
955
|
const adjacency = /* @__PURE__ */ new Map();
|
|
872
956
|
for (const [rootIndex, root] of this.#roots.entries()) {
|
|
873
957
|
if (!await this.#fs.exists(root)) {
|
|
@@ -940,7 +1024,7 @@ var SkillDiscovery = class {
|
|
|
940
1024
|
});
|
|
941
1025
|
}
|
|
942
1026
|
issues.push(...cycles.issues);
|
|
943
|
-
const admitted = new Set(entries.map((e) => e.name));
|
|
1027
|
+
const admitted = /* @__PURE__ */ new Set([...entries.map((e) => e.name), ...this.#extraKnownSkillNames]);
|
|
944
1028
|
let changed = true;
|
|
945
1029
|
while (changed) {
|
|
946
1030
|
changed = false;
|
|
@@ -996,9 +1080,12 @@ var SkillDiscovery = class {
|
|
|
996
1080
|
/**
|
|
997
1081
|
* 合规校验。内部直接复用 SkillDiscovery 的扫描逻辑,
|
|
998
1082
|
* 规则判定同样落在 checkSkillRules 单一来源上。
|
|
1083
|
+
*
|
|
1084
|
+
* `extraKnownSkillNames`:扫描范围之外已存在的技能名。安装时只扫刚解出来的那一个目录,
|
|
1085
|
+
* 不告诉它库里还有谁,任何指向包外的 dependencies 都会被判成不存在。
|
|
999
1086
|
*/
|
|
1000
|
-
async function validateSkills(fs, roots) {
|
|
1001
|
-
const { issues } = await new SkillDiscovery(fs, roots).discover();
|
|
1087
|
+
async function validateSkills(fs, roots, options) {
|
|
1088
|
+
const { issues } = await new SkillDiscovery(fs, roots, options).discover();
|
|
1002
1089
|
return {
|
|
1003
1090
|
ok: !issues.some((i) => i.severity === "error"),
|
|
1004
1091
|
issues
|
|
@@ -1035,4 +1122,4 @@ const xmlRenderer = {
|
|
|
1035
1122
|
};
|
|
1036
1123
|
|
|
1037
1124
|
//#endregion
|
|
1038
|
-
export {
|
|
1125
|
+
export { messageOf as A, signSkill as B, detectSkillArchiveShape as C, isValidSkillName as D, exportSkills as E, readSkillSignature as F, verifyManifest as G, stripArchiveRoot as H, renderAvailableSkillsXml as I, verifySkillSignature as K, renderCatalogJson as L, parseSkillMarkdown as M, parseSkillPackManifest as N, jsonRenderer as O, readResponseWithLimit as P, resolveArchiveLimits as R, computeDigest as S, escapeXml as T, unzipWithLimits as U, signaturePayloadBytes as V, validateSkills as W, atomicWriteText as _, SIGNATURE_SCHEMA_VERSION as a, checkDependencyCycles as b, SKILL_NAME_MAX_LENGTH as c, SKILL_SIGNATURE_FILE as d, SkillDiscovery as f, assertSafePathSegment as g, assertRemoteUrlAllowed as h, MemoryFS as i, normalizePath as j, keyIdOf as k, SKILL_NAME_PATTERN as l, WebSkillError as m, FsTrustedKeyStore as n, SKILLS_LOCKFILE as o, SkillReader as p, xmlRenderer as q, MANIFEST_EXCLUDED_FILES as r, SKILL_MANIFEST_FILE as s, DEFAULT_ARCHIVE_LIMITS as t, SKILL_PACK_FILE as u, buildCatalog as v, detectSkillArchiveShapeFromFs as w, checkSkillRules as x, buildManifest as y, resolveInsideRoot as z };
|