mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-22 20:29:18 +01:00
fix(plugins): refresh unchanged-version bundle descriptions (#22295)
Refresh known display descriptions in same-version bundled plugin registrations only when every behavioral field matches. Compare manifests in their persisted JSON form and await bundle reconciliation before final volume-free package qualification. Verified 77 focused tests, server typechecking, and all 59 successful PR checks. Greptile 5/5 with no unresolved review comments. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
b7177db6aa
commit
417802ca87
9 files changed
+146
-5
No files matched your search
@@ -7,6 +7,10 @@ import { assertDistributionManifestCapabilities } from "./distribution-plugin-ca
|
||||
|
||||
export type BundledPluginRegistration = Pick<PluginRecord, "pluginKey" | "packageName" | "version" | "manifestJson">;
|
||||
|
||||
export function pluginManifestJson(manifest: PaperclipPluginManifestV1): PaperclipPluginManifestV1 {
|
||||
return JSON.parse(JSON.stringify(manifest)) as PaperclipPluginManifestV1;
|
||||
}
|
||||
|
||||
export interface BundledPluginPackageIdentity {
|
||||
kind: "bundled_image";
|
||||
catalogKey: string;
|
||||
@@ -88,7 +92,7 @@ export function createBundledPluginPackageResolver(installs: readonly ResolvedBu
|
||||
const install = byKey.get(plugin.pluginKey)!;
|
||||
if (!verifiedManifest) return { compatible: false, pluginKey: plugin.pluginKey, code: "missing_manifest_evidence", reason: "Image manifest evidence is required" };
|
||||
assertManifest(install, verifiedManifest);
|
||||
if (!isDeepStrictEqual(verifiedManifest, plugin.manifestJson)) throw new Error("Approved plugin manifest does not match the image");
|
||||
if (!isDeepStrictEqual(pluginManifestJson(verifiedManifest), pluginManifestJson(plugin.manifestJson))) throw new Error("Approved plugin manifest does not match the image");
|
||||
return { compatible: true, identity: {
|
||||
kind: "bundled_image", catalogKey: install.key, pluginKey: plugin.pluginKey,
|
||||
packageName: plugin.packageName, version: plugin.version,
|
||||
|
||||
@@ -2,6 +2,7 @@ import path from "node:path";
|
||||
import fs from "node:fs";
|
||||
import { isDeepStrictEqual } from "node:util";
|
||||
import { isCloudManagedInstance } from "./cloud-instance.js";
|
||||
import { pluginManifestJson } from "./bundled-plugin-package.js";
|
||||
import type { PaperclipPluginManifestV1 } from "@paperclipai/shared";
|
||||
import { assertDistributionManifestCapabilities, readDistributionPluginCatalog, type DistributionPlugin } from "./distribution-plugin-catalog.js";
|
||||
|
||||
@@ -257,6 +258,26 @@ function defaultBundleManifestExists(localPath: string): boolean {
|
||||
return fs.existsSync(path.join(localPath, "dist", "manifest.js"));
|
||||
}
|
||||
|
||||
function withoutDisplayDescriptions(manifest: PaperclipPluginManifestV1): unknown {
|
||||
const copy = pluginManifestJson(manifest) as unknown as Record<string, unknown>;
|
||||
const removeDescription = (value: unknown) => {
|
||||
if (value && typeof value === "object" && !Array.isArray(value)) {
|
||||
const object = value as Record<string, unknown>;
|
||||
if (typeof object.description === "string") delete object.description;
|
||||
}
|
||||
};
|
||||
removeDescription(copy);
|
||||
if (Array.isArray(copy.environmentDrivers)) for (const driver of copy.environmentDrivers) {
|
||||
removeDescription(driver);
|
||||
const schema = driver?.configSchema;
|
||||
removeDescription(schema);
|
||||
if (schema?.properties && typeof schema.properties === "object" && !Array.isArray(schema.properties)) {
|
||||
for (const property of Object.values(schema.properties)) removeDescription(property);
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reconcile a present bundled plugin's persisted manifest with the shipped
|
||||
* bundle. The bundle is part of the release image, so its manifest is the
|
||||
@@ -294,7 +315,10 @@ async function reconcileBundledPluginManifest(
|
||||
}
|
||||
const rebindPackage = !preservePackagePath && install.distribution && existing.packagePath !== install.localPath && existing.status !== "uninstalled";
|
||||
const refreshDistribution = install.distribution && !isDeepStrictEqual(bundleManifest, existing.manifestJson);
|
||||
if (bundleManifest.version === existing.version && !rebindPackage && !requiresApproval && !refreshDistribution) return;
|
||||
const refreshDescriptions = !install.distribution && !["uninstalled", "upgrade_pending"].includes(existing.status) &&
|
||||
!isDeepStrictEqual(pluginManifestJson(bundleManifest), pluginManifestJson(existing.manifestJson)) &&
|
||||
isDeepStrictEqual(withoutDisplayDescriptions(bundleManifest), withoutDisplayDescriptions(existing.manifestJson));
|
||||
if (bundleManifest.version === existing.version && !rebindPackage && !requiresApproval && !refreshDistribution && !refreshDescriptions) return;
|
||||
await deps.registry.update(existing.id, {
|
||||
version: bundleManifest.version,
|
||||
manifest: bundleManifest,
|
||||
|
||||
@@ -10,9 +10,11 @@ import { pluginLoader } from "./plugin-loader.js";
|
||||
export async function qualifyCloudConfigurationForCurrentImage(db: Db, options: {
|
||||
runtimeEnv?: CloudInstanceEnv;
|
||||
expectedPackageEvidenceDigest?: string;
|
||||
bundledManifestsReady?: Promise<unknown>;
|
||||
} = {}) {
|
||||
const env = options.runtimeEnv ?? process.env;
|
||||
if (!isCloudManagedInstance(env)) return null;
|
||||
await options.bundledManifestsReady;
|
||||
const service = cloudConfigurationMigrationService(db, { runtimeEnv: env });
|
||||
const catalogRoot = resolveBundledCatalogRoot(env);
|
||||
let installs: ResolvedBundledPlugin[];
|
||||
|
||||
Reference in new issue
Block a user