






















@@ -305,6 +305,29 @@ function assertClawHubExternalInstallContract(installPath) {
305305}
306306}
307307308+function assertClawHubArtifactMetadata(record, pluginId) {
309+if (record.artifactKind === "legacy-zip") {
310+if (record.artifactFormat !== "zip") {
311+throw new Error(
312+`missing ClawHub legacy ZIP artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
313+);
314+}
315+return;
316+}
317+318+if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") {
319+throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`);
320+}
321+if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") {
322+throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`);
323+}
324+if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) {
325+throw new Error(
326+`missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
327+);
328+}
329+}
330+308331function assertPluginDirDeps() {
309332const sourceDir = process.argv[3];
310333assertSimplePlugin(
@@ -534,17 +557,7 @@ function assertClawHubInstalled() {
534557if (typeof record.installPath !== "string" || record.installPath.length === 0) {
535558throw new Error(`missing ClawHub install path for ${pluginId}`);
536559}
537-if (!record.clawpackSha256 || typeof record.clawpackSize !== "number") {
538-throw new Error(`missing ClawHub ClawPack metadata for ${pluginId}: ${JSON.stringify(record)}`);
539-}
540-if (record.artifactKind !== "npm-pack" || record.artifactFormat !== "tgz") {
541-throw new Error(`missing ClawHub artifact metadata for ${pluginId}: ${JSON.stringify(record)}`);
542-}
543-if (!record.npmIntegrity || !record.npmShasum || !record.npmTarballName) {
544-throw new Error(
545-`missing ClawHub npm artifact metadata for ${pluginId}: ${JSON.stringify(record)}`,
546-);
547-}
560+assertClawHubArtifactMetadata(record, pluginId);
548561549562const installPath = record.installPath.replace(/^~(?=$|\/)/u, process.env.HOME);
550563const extensionsRoot = path.join(process.env.HOME, ".openclaw", "extensions");
@@ -554,7 +567,9 @@ function assertClawHubInstalled() {
554567if (!fs.existsSync(installPath)) {
555568throw new Error(`ClawHub install path missing on disk: ${installPath}`);
556569}
557-assertClawHubExternalInstallContract(installPath);
570+if (record.artifactKind === "npm-pack") {
571+assertClawHubExternalInstallContract(installPath);
572+}
558573fs.writeFileSync("/tmp/plugins-clawhub-install-path.txt", installPath, "utf8");
559574}
560575@@ -596,10 +611,10 @@ function assertClawHubRemoved() {
596611}
597612598613function assertClawHubUpdated() {
599-assertUpdateOutput(
600- "/tmp/plugins-clawhub-update.log",
601-`${process.env.CLAWHUB_PLUGIN_ID} already at 0.1.0.`,
602-);
614+const output = fs.readFileSync("/tmp/plugins-clawhub-update.log", "utf8");
615+if (!output.includes(`${process.env.CLAWHUB_PLUGIN_ID} already at `)) {
616+throw new Error(`expected ClawHub update to report already-at version:\n${output}`);
617+}
603618assertClawHubInstalled();
604619}
605620此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。