Skip to content

Commit e2295b3

Browse files
committed
fix(ci): restore full release validation blockers
1 parent 2290adb commit e2295b3

6 files changed

Lines changed: 166 additions & 28 deletions

File tree

extensions/browser/src/browser/trash.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "node:fs";
22
import os from "node:os";
33
import path from "node:path";
4+
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
45

56
const TRASH_DESTINATION_COLLISION_CODES = new Set(["EEXIST", "ENOTEMPTY", "ERR_FS_CP_EEXIST"]);
67
const TRASH_DESTINATION_RETRY_LIMIT = 4;
@@ -23,7 +24,7 @@ function isSameOrChildPath(candidate: string, parent: string): boolean {
2324
}
2425

2526
function resolveAllowedTrashRoots(): string[] {
26-
const roots = [os.homedir(), os.tmpdir()].map((root) => {
27+
const roots = [os.homedir(), resolvePreferredOpenClawTmpDir()].map((root) => {
2728
try {
2829
return path.resolve(fs.realpathSync.native(root));
2930
} catch {

extensions/signal/src/install-signal-cli.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -247,21 +247,32 @@ async function installSignalCliViaBrew(runtime: RuntimeEnv): Promise<SignalInsta
247247

248248
async function installSignalCliFromRelease(runtime: RuntimeEnv): Promise<SignalInstallResult> {
249249
const apiUrl = "https://api.github.com/repos/AsamK/signal-cli/releases/latest";
250-
const response = await fetch(apiUrl, {
251-
headers: {
252-
"User-Agent": "openclaw",
253-
Accept: "application/vnd.github+json",
250+
const { response, release } = await fetchWithSsrFGuard({
251+
url: apiUrl,
252+
maxRedirects: 5,
253+
requireHttps: true,
254+
capture: false,
255+
auditContext: "signal-cli-release-info",
256+
init: {
257+
headers: {
258+
"User-Agent": "openclaw",
259+
Accept: "application/vnd.github+json",
260+
},
254261
},
255262
});
256263

257-
if (!response.ok) {
258-
return {
259-
ok: false,
260-
error: `Failed to fetch release info (${response.status})`,
261-
};
264+
let payload: ReleaseResponse;
265+
try {
266+
if (!response.ok) {
267+
return {
268+
ok: false,
269+
error: `Failed to fetch release info (${response.status})`,
270+
};
271+
}
272+
payload = (await response.json()) as ReleaseResponse;
273+
} finally {
274+
await release();
262275
}
263-
264-
const payload = (await response.json()) as ReleaseResponse;
265276
const version = payload.tag_name?.replace(/^v/, "") ?? "unknown";
266277
const assets = payload.assets ?? [];
267278
const asset = pickAsset(assets, process.platform, process.arch);

scripts/test-built-plugin-singleton.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,10 @@ const record = registry.plugins.find((entry) => entry.id === pluginId);
135135
assert.ok(record, "smoke plugin missing from registry");
136136
assert.equal(record.status, "loaded", record.error ?? "smoke plugin failed to load");
137137

138-
assert.deepEqual(getPluginCommandSpecs(), [
139-
{ name: "pair", description: "Pair a device", acceptsArgs: true },
140-
]);
138+
assert.deepEqual(
139+
getPluginCommandSpecs().filter((command) => command.name === "pair"),
140+
[{ name: "pair", description: "Pair a device", acceptsArgs: true }],
141+
);
141142

142143
const match = matchPluginCommand("/pair now");
143144
assert.ok(match, "canonical built command registry did not receive the command");

src/commands/doctor-bundled-plugin-runtime-deps.ts

Lines changed: 104 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,108 @@
1+
import fs from "node:fs";
12
import path from "node:path";
23
import { formatCliCommand } from "../cli/command-format.js";
34
import type { OpenClawConfig } from "../config/types.openclaw.js";
45
import { resolveOpenClawPackageRootSync } from "../infra/openclaw-root.js";
6+
import { resolveBundledPluginsDir } from "../plugins/bundled-dir.js";
57
import {
68
createBundledRuntimeDepsWritableInstallSpecs,
79
repairBundledRuntimeDepsInstallRootAsync,
810
resolveBundledRuntimeDependencyPackageInstallRootPlan,
911
scanBundledPluginRuntimeDeps,
1012
type BundledRuntimeDepsInstallParams,
1113
} from "../plugins/bundled-runtime-deps.js";
14+
import { normalizePluginsConfig } from "../plugins/config-state.js";
1215
import { resolveEffectivePluginIds } from "../plugins/effective-plugin-ids.js";
16+
import { passesManifestOwnerBasePolicy } from "../plugins/manifest-owner-policy.js";
1317
import type { RuntimeEnv } from "../runtime.js";
1418
import { note } from "../terminal/note.js";
1519
import type { DoctorPrompter } from "./doctor-prompter.js";
1620

1721
const RUNTIME_DEPS_INSTALL_HEARTBEAT_MS = 15_000;
1822

23+
function filterPluginIdsPresentInBundledTree(
24+
bundledPluginsDir: string,
25+
pluginIds: readonly string[],
26+
): string[] | undefined {
27+
const present = pluginIds.filter((pluginId) => {
28+
if (path.basename(pluginId) !== pluginId) {
29+
return false;
30+
}
31+
return fs.existsSync(path.join(bundledPluginsDir, pluginId));
32+
});
33+
return present.length > 0 ? present : undefined;
34+
}
35+
36+
function collectPackagedRuntimeDepsRepairPluginIds(params: {
37+
bundledPluginsDir: string;
38+
config: OpenClawConfig;
39+
includeConfiguredChannels?: boolean;
40+
}): string[] {
41+
if (!fs.existsSync(params.bundledPluginsDir)) {
42+
return [];
43+
}
44+
const plugins = normalizePluginsConfig(params.config.plugins);
45+
const ids = new Set<string>();
46+
for (const entry of fs.readdirSync(params.bundledPluginsDir, { withFileTypes: true })) {
47+
if (!entry.isDirectory()) {
48+
continue;
49+
}
50+
const pluginDir = path.join(params.bundledPluginsDir, entry.name);
51+
let manifest: Record<string, unknown>;
52+
try {
53+
manifest = JSON.parse(
54+
fs.readFileSync(path.join(pluginDir, "openclaw.plugin.json"), "utf-8"),
55+
) as Record<string, unknown>;
56+
} catch {
57+
continue;
58+
}
59+
const pluginId = typeof manifest.id === "string" && manifest.id ? manifest.id : entry.name;
60+
if (
61+
!passesManifestOwnerBasePolicy({
62+
plugin: { id: pluginId },
63+
normalizedConfig: plugins,
64+
allowRestrictiveAllowlistBypass: true,
65+
})
66+
) {
67+
continue;
68+
}
69+
if (plugins.allow.includes(pluginId) || plugins.entries[pluginId]?.enabled === true) {
70+
ids.add(pluginId);
71+
continue;
72+
}
73+
const channels = Array.isArray(manifest.channels)
74+
? manifest.channels.filter((channel): channel is string => typeof channel === "string")
75+
: [];
76+
if (
77+
channels.some((channelId) => {
78+
const channelConfig = (params.config.channels as Record<string, unknown> | undefined)?.[
79+
channelId
80+
];
81+
if (!channelConfig || typeof channelConfig !== "object" || Array.isArray(channelConfig)) {
82+
return false;
83+
}
84+
if ((channelConfig as { enabled?: unknown }).enabled === false) {
85+
return false;
86+
}
87+
return (
88+
(channelConfig as { enabled?: unknown }).enabled === true ||
89+
params.includeConfiguredChannels === true
90+
);
91+
})
92+
) {
93+
ids.add(pluginId);
94+
continue;
95+
}
96+
const providers = Array.isArray(manifest.providers)
97+
? manifest.providers.filter((provider): provider is string => typeof provider === "string")
98+
: [];
99+
if (manifest.enabledByDefault === true && providers.length === 0 && channels.length === 0) {
100+
ids.add(pluginId);
101+
}
102+
}
103+
return [...ids].toSorted((left, right) => left.localeCompare(right));
104+
}
105+
19106
function formatElapsedMs(elapsedMs: number): string {
20107
if (elapsedMs < 1000) {
21108
return `${elapsedMs}ms`;
@@ -56,13 +143,23 @@ export async function maybeRepairBundledPluginRuntimeDeps(params: {
56143
const env = params.env ?? process.env;
57144
const bundledPluginsDir = path.join(packageRoot, "dist", "extensions");
58145
const effectivePluginIds = params.config
59-
? resolveEffectivePluginIds({
60-
config: params.config,
61-
env: {
62-
...env,
63-
OPENCLAW_BUNDLED_PLUGINS_DIR: bundledPluginsDir,
64-
},
65-
})
146+
? resolveBundledPluginsDir({ ...env, OPENCLAW_BUNDLED_PLUGINS_DIR: bundledPluginsDir }) ===
147+
bundledPluginsDir
148+
? filterPluginIdsPresentInBundledTree(
149+
bundledPluginsDir,
150+
resolveEffectivePluginIds({
151+
config: params.config,
152+
env: {
153+
...env,
154+
OPENCLAW_BUNDLED_PLUGINS_DIR: bundledPluginsDir,
155+
},
156+
}),
157+
)
158+
: collectPackagedRuntimeDepsRepairPluginIds({
159+
bundledPluginsDir,
160+
config: params.config,
161+
includeConfiguredChannels: params.includeConfiguredChannels,
162+
})
66163
: undefined;
67164
const { deps, missing, conflicts } = scanBundledPluginRuntimeDeps({
68165
packageRoot,

src/commands/doctor-plugin-manifests.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ describe("doctor plugin manifest legacy contract repair", () => {
9090
const migrations = collectLegacyPluginManifestContractMigrations({
9191
env: {
9292
...process.env,
93-
OPENCLAW_BUNDLED_PLUGINS_DIR: pluginsRoot,
9493
},
94+
manifestRoots: [pluginsRoot],
9595
});
9696

9797
expect(migrations).toHaveLength(1);
@@ -119,8 +119,8 @@ describe("doctor plugin manifest legacy contract repair", () => {
119119
await maybeRepairLegacyPluginManifestContracts({
120120
env: {
121121
...process.env,
122-
OPENCLAW_BUNDLED_PLUGINS_DIR: pluginsRoot,
123122
},
123+
manifestRoots: [pluginsRoot],
124124
runtime: createRuntime(),
125125
prompter: createPrompter(),
126126
note: vi.fn(),
@@ -156,8 +156,8 @@ describe("doctor plugin manifest legacy contract repair", () => {
156156
const migrations = collectLegacyPluginManifestContractMigrations({
157157
env: {
158158
...process.env,
159-
OPENCLAW_BUNDLED_PLUGINS_DIR: pluginsRoot,
160159
},
160+
manifestRoots: [pluginsRoot],
161161
});
162162

163163
expect(migrations).toHaveLength(1);

src/commands/doctor-plugin-manifests.ts

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs from "node:fs";
2+
import path from "node:path";
23
import { z } from "zod";
34
import { loadPluginManifestRegistry } from "../plugins/manifest-registry.js";
45
import type { RuntimeEnv } from "../runtime.js";
@@ -81,10 +82,35 @@ function buildLegacyManifestContractMigration(params: {
8182

8283
export function collectLegacyPluginManifestContractMigrations(params?: {
8384
env?: NodeJS.ProcessEnv;
85+
manifestRoots?: string[];
8486
}): LegacyManifestContractMigration[] {
8587
const seen = new Set<string>();
8688
const migrations: LegacyManifestContractMigration[] = [];
8789

90+
for (const root of params?.manifestRoots ?? []) {
91+
if (!fs.existsSync(root)) {
92+
continue;
93+
}
94+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
95+
if (!entry.isDirectory()) {
96+
continue;
97+
}
98+
const manifestPath = path.join(root, entry.name, "openclaw.plugin.json");
99+
if (seen.has(manifestPath)) {
100+
continue;
101+
}
102+
seen.add(manifestPath);
103+
const raw = readManifestJson(manifestPath);
104+
if (!raw) {
105+
continue;
106+
}
107+
const migration = buildLegacyManifestContractMigration({ manifestPath, raw });
108+
if (migration) {
109+
migrations.push(migration);
110+
}
111+
}
112+
}
113+
88114
for (const plugin of loadPluginManifestRegistry({
89115
cache: false,
90116
...(params?.env ? { env: params.env } : {}),
@@ -111,13 +137,15 @@ export function collectLegacyPluginManifestContractMigrations(params?: {
111137

112138
export async function maybeRepairLegacyPluginManifestContracts(params: {
113139
env?: NodeJS.ProcessEnv;
140+
manifestRoots?: string[];
114141
runtime: RuntimeEnv;
115142
prompter: DoctorPrompter;
116143
note?: typeof note;
117144
}): Promise<void> {
118-
const migrations = collectLegacyPluginManifestContractMigrations(
119-
params.env ? { env: params.env } : undefined,
120-
);
145+
const migrations = collectLegacyPluginManifestContractMigrations({
146+
...(params.env ? { env: params.env } : {}),
147+
...(params.manifestRoots ? { manifestRoots: params.manifestRoots } : {}),
148+
});
121149
if (migrations.length === 0) {
122150
return;
123151
}

0 commit comments

Comments
 (0)