@@ -3,6 +3,7 @@ import fs from "node:fs/promises";
33import path from "node:path" ;
44import type { PluginInstallRecord } from "../../config/types.plugins.js" ;
55import { detectBundleManifestFormat , loadBundleManifest } from "../../plugins/bundle-manifest.js" ;
6+ import type { PluginBundleFormat } from "../../plugins/manifest-types.js" ;
67import { resolvePackageExtensionEntries , type PackageManifest } from "../../plugins/manifest.js" ;
78import { validatePackageExtensionEntriesForInstall } from "../../plugins/package-entry-resolution.js" ;
89import { auditOpenClawPeerDependencyLink } from "../../plugins/plugin-peer-link.js" ;
@@ -82,11 +83,11 @@ export async function runPluginPayloadSmokeCheck(params: {
8283 continue ;
8384 }
8485
85- const isBundleRecord = isBundleInstallRecord ( record ) ;
86+ const bundlePayload = resolveBundleInstallRecordPayload ( { record, installPath } ) ;
8687 const packagePayload = await readPackagePayloadManifest ( installPath ) ;
8788 if ( packagePayload . status === "present" ) {
8889 const usePackagePayload =
89- ! isBundleRecord || hasNativePackageMetadata ( packagePayload . manifest ) ;
90+ ! bundlePayload . isBundlePayload || hasNativePackageMetadata ( packagePayload . manifest ) ;
9091 if ( usePackagePayload ) {
9192 failures . push (
9293 ...( await validatePackagePayload ( {
@@ -97,12 +98,17 @@ export async function runPluginPayloadSmokeCheck(params: {
9798 ) ;
9899 continue ;
99100 }
100- } else if ( ! isBundleRecord ) {
101+ } else if ( ! bundlePayload . isBundlePayload ) {
101102 failures . push ( formatPackagePayloadReadFailure ( { pluginId, installPath, packagePayload } ) ) ;
102103 continue ;
103104 }
104105
105- const bundleFailure = validateBundleInstallRecordPayload ( { pluginId, installPath, record } ) ;
106+ const bundleFailure = validateBundleInstallRecordPayload ( {
107+ pluginId,
108+ installPath,
109+ record,
110+ bundleFormat : bundlePayload . bundleFormat ,
111+ } ) ;
106112 if ( bundleFailure ) {
107113 failures . push ( bundleFailure ) ;
108114 }
@@ -163,9 +169,7 @@ function hasNativePackageMetadata(manifest: PackageManifest): boolean {
163169
164170export async function hasNativePackageInstallPayload ( installPath : string ) : Promise < boolean > {
165171 const packagePayload = await readPackagePayloadManifest ( installPath ) ;
166- return (
167- packagePayload . status === "present" && hasNativePackageMetadata ( packagePayload . manifest )
168- ) ;
172+ return packagePayload . status === "present" && hasNativePackageMetadata ( packagePayload . manifest ) ;
169173}
170174
171175async function validatePackagePayload ( params : {
@@ -246,15 +250,35 @@ export function isBundleInstallRecord(record: PluginInstallRecord): boolean {
246250 ) ;
247251}
248252
253+ export function resolveBundleInstallRecordPayload ( params : {
254+ record : PluginInstallRecord ;
255+ installPath : string ;
256+ } ) : { isBundlePayload : boolean ; bundleFormat : PluginBundleFormat | null } {
257+ const hasBundleRecordMetadata = isBundleInstallRecord ( params . record ) ;
258+ if ( ! hasBundleRecordMetadata && params . record . source !== "marketplace" ) {
259+ return { isBundlePayload : false , bundleFormat : null } ;
260+ }
261+ const bundleFormat = detectBundleManifestFormat ( params . installPath ) ;
262+ return {
263+ isBundlePayload : hasBundleRecordMetadata || bundleFormat !== null ,
264+ bundleFormat,
265+ } ;
266+ }
267+
249268export function validateBundleInstallRecordPayload ( params : {
250269 pluginId : string ;
251270 installPath : string ;
252271 record : PluginInstallRecord ;
272+ bundleFormat ?: PluginBundleFormat | null ;
253273} ) : PluginPayloadSmokeFailure | null {
254- if ( ! isBundleInstallRecord ( params . record ) ) {
274+ const hasBundleRecordMetadata = isBundleInstallRecord ( params . record ) ;
275+ const bundleFormat =
276+ params . bundleFormat === undefined
277+ ? detectBundleManifestFormat ( params . installPath )
278+ : params . bundleFormat ;
279+ if ( ! hasBundleRecordMetadata && ! bundleFormat ) {
255280 return null ;
256281 }
257- const bundleFormat = detectBundleManifestFormat ( params . installPath ) ;
258282 if ( ! bundleFormat ) {
259283 return {
260284 pluginId : params . pluginId ,
0 commit comments