refactor: mechanical dedup batch (protocol types, update-cli bridge, talk fallback) (#114432)

* refactor(onboarding): remove search setup barrel

* refactor(plugins): reuse detected package manifest

* test(update): replace global helper bridges

* refactor(talk): remove dead legacy response fallback

* refactor(protocol): derive root types from schema

The maintainer approved broadening the additive schema-backed type surface without a protocol version bump.

* fix(plugins): drop stale package path import

* test(protocol): type dynamic registry lookups

* docs(talk): explain canonical response boundary

* refactor(talk): enforce canonical response input

* fix(protocol): keep root type exports registry-free

* refactor(update): expose helpers through test facades

* fix(protocol): keep result types on leaf schema modules
This commit is contained in:
Peter Steinberger
2026-07-27 06:55:07 -04:00
committed by GitHub
parent 0f879595d4
commit c6b2ec28c8
27 changed files with 582 additions and 2198 deletions
+10 -9
View File
@@ -12,6 +12,7 @@ import {
formatUnresolvedOpenClawPeerLinkError,
hasPackageRuntimeDependencies,
loadPluginInstallRuntime,
readOptionalPackageManifest,
runInstallSourceScan,
sourceFamilyForInstallPolicyKind,
sourceFamilyForInstallPolicySource,
@@ -42,6 +43,7 @@ type ValidatedPackagePlugin = {
export async function validatePackagePluginInstallSource(params: {
runtime: Awaited<ReturnType<typeof loadPluginInstallRuntime>>;
packageDir: string;
manifest?: PackageManifest;
expectedPluginId?: string;
requirePluginManifest?: boolean;
allowSourceTypeScriptEntries?: boolean;
@@ -59,16 +61,15 @@ export async function validatePackagePluginInstallSource(params: {
}
| PluginInstallFailureResult
> {
const manifestPath = path.join(params.packageDir, "package.json");
if (!(await params.runtime.fileExists(manifestPath))) {
return { ok: false, error: "extracted package missing package.json" };
const manifestResult = params.manifest
? ({ ok: true, manifest: params.manifest } as const)
: await readOptionalPackageManifest({ runtime: params.runtime, packageDir: params.packageDir });
if (!manifestResult.ok) {
return manifestResult;
}
let manifest: PackageManifest;
try {
manifest = await params.runtime.readJsonFile<PackageManifest>(manifestPath);
} catch (err) {
return { ok: false, error: `invalid package.json: ${String(err)}` };
const manifest = manifestResult.manifest;
if (!manifest) {
return { ok: false, error: "extracted package missing package.json" };
}
const pkgName = normalizeOptionalString(manifest.name) ?? "";
+11 -15
View File
@@ -1,5 +1,4 @@
import fs from "node:fs/promises";
import path from "node:path";
import { resolveUserPath } from "../utils.js";
import {
scanAndLinkInstalledPackage,
@@ -194,10 +193,11 @@ async function installPluginFromSourceDir(
sourceDir: string;
} & InternalPackageInstallCommonParams,
): Promise<InstallPluginResult> {
const nativePackageDetected = await detectNativePackageInstallSource(params.sourceDir);
if (nativePackageDetected) {
const nativePackageManifest = await detectNativePackageInstallSource(params.sourceDir);
if (nativePackageManifest) {
return await installPluginFromPackageDir({
packageDir: params.sourceDir,
packageManifest: nativePackageManifest,
...pickPackageInstallCommonParams(params),
});
}
@@ -214,24 +214,19 @@ async function installPluginFromSourceDir(
});
}
async function detectNativePackageInstallSource(packageDir: string): Promise<boolean> {
async function detectNativePackageInstallSource(
packageDir: string,
): Promise<PackageManifest | undefined> {
const runtime = await loadPluginInstallRuntime();
const manifestPath = path.join(packageDir, "package.json");
if (!(await runtime.fileExists(manifestPath))) {
return false;
}
try {
const manifest = await runtime.readJsonFile<PackageManifest>(manifestPath);
return ensureOpenClawExtensions({ manifest }).ok;
} catch {
return false;
}
const result = await readOptionalPackageManifest({ runtime, packageDir });
const manifest = result.ok ? result.manifest : undefined;
return manifest && ensureOpenClawExtensions({ manifest }).ok ? manifest : undefined;
}
async function installPluginFromPackageDir(
params: {
packageDir: string;
packageManifest?: PackageManifest;
} & InternalPackageInstallCommonParams,
): Promise<InstallPluginResult> {
const runtime = await loadPluginInstallRuntime();
@@ -260,6 +255,7 @@ async function installPluginFromPackageDir(
const validated = await validatePackagePluginInstallSource({
runtime,
packageDir: params.packageDir,
manifest: params.packageManifest,
expectedPluginId: params.expectedPluginId,
requirePluginManifest: params.requirePluginManifest,
allowSourceTypeScriptEntries: params.allowSourceTypeScriptEntries,