mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-28 15:01:14 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
// Narrow bundled-plugin facts used before the full metadata/runtime registry is available.
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { isRecord } from "@openclaw/normalization-core/record-coerce";
|
|
import { tryReadJsonSync } from "../infra/json-files.js";
|
|
import { resolveBundledPluginsDir } from "./bundled-dir.js";
|
|
|
|
const DOCTOR_CONTRACT_BASENAMES = ["doctor-contract-api", "contract-api"] as const;
|
|
const MODULE_EXTENSIONS = ["js", "cjs", "mjs", "ts", "cts", "mts"] as const;
|
|
|
|
type BundledPluginStartupMetadata = {
|
|
hasDoctorContract: boolean;
|
|
};
|
|
|
|
function hasDoctorContractArtifact(pluginRoot: string): boolean {
|
|
return [pluginRoot, path.join(pluginRoot, "dist")].some((root) =>
|
|
DOCTOR_CONTRACT_BASENAMES.some((basename) =>
|
|
MODULE_EXTENSIONS.some((extension) =>
|
|
fs.existsSync(path.join(root, `${basename}.${extension}`)),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/** Resolves one exact bundled id without scanning or materializing the full plugin catalog. */
|
|
export function inspectBundledPluginStartupMetadata(params: {
|
|
pluginId: string;
|
|
env: NodeJS.ProcessEnv;
|
|
}): BundledPluginStartupMetadata | undefined {
|
|
const bundledPluginsDir = resolveBundledPluginsDir(params.env);
|
|
if (!bundledPluginsDir) {
|
|
return undefined;
|
|
}
|
|
const pluginRoot = path.join(bundledPluginsDir, params.pluginId);
|
|
const manifest = tryReadJsonSync(path.join(pluginRoot, "openclaw.plugin.json"));
|
|
if (!isRecord(manifest) || manifest.id !== params.pluginId) {
|
|
return undefined;
|
|
}
|
|
return { hasDoctorContract: hasDoctorContractArtifact(pluginRoot) };
|
|
}
|