Skip to content

Commit ebd192f

Browse files
committed
fix(plugins): require explicit source external startup
1 parent 86b1e26 commit ebd192f

2 files changed

Lines changed: 84 additions & 2 deletions

File tree

‎src/plugins/channel-plugin-ids.test.ts‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@ function createManifestRegistryFixture(): PluginManifestRegistry {
211211
origin: "global",
212212
activation: { onStartup: true },
213213
},
214+
{
215+
id: "source-external-startup",
216+
enabledByDefault: true,
217+
activation: { onStartup: true },
218+
channels: ["source-external-channel"],
219+
providers: ["source-external-provider"],
220+
packageManifest: {
221+
build: { bundledDist: false },
222+
},
223+
},
214224
{
215225
id: "demo-config-startup",
216226
enabledByDefault: true,
@@ -314,6 +324,7 @@ function createInstalledPluginRecordFixture(
314324
origin: record.origin,
315325
enabled: true,
316326
...(record.enabledByDefault === true ? { enabledByDefault: true } : {}),
327+
...(record.packageManifest?.build ? { packageBuild: record.packageManifest.build } : {}),
317328
startup: {
318329
sidecar: record.activation?.onStartup === true,
319330
memory,
@@ -1429,6 +1440,72 @@ describe("resolveGatewayStartupPluginIds", () => {
14291440
});
14301441
});
14311442

1443+
it("does not ambient-start source-discovered external plugins from onStartup alone", () => {
1444+
expectStartupPluginIds({
1445+
config: createStartupConfig({
1446+
noConfiguredChannels: true,
1447+
memorySlot: "none",
1448+
}),
1449+
expected: ["browser"],
1450+
});
1451+
});
1452+
1453+
it.each([
1454+
[
1455+
"plugins.entries",
1456+
createStartupConfig({
1457+
enabledPluginIds: ["source-external-startup"],
1458+
noConfiguredChannels: true,
1459+
memorySlot: "none",
1460+
}),
1461+
["browser", "source-external-startup"],
1462+
],
1463+
[
1464+
"plugins.allow",
1465+
createStartupConfig({
1466+
allowPluginIds: ["source-external-startup"],
1467+
noConfiguredChannels: true,
1468+
memorySlot: "none",
1469+
}),
1470+
["source-external-startup"],
1471+
],
1472+
])(
1473+
"starts source-discovered external plugins explicitly selected through %s",
1474+
(_name, config, expected) => {
1475+
expectStartupPluginIds({
1476+
config,
1477+
expected,
1478+
});
1479+
},
1480+
);
1481+
1482+
it.each([
1483+
[
1484+
"configured channel",
1485+
{
1486+
channels: {
1487+
"source-external-channel": { enabled: true },
1488+
},
1489+
plugins: {
1490+
slots: { memory: "none" },
1491+
},
1492+
} as OpenClawConfig,
1493+
],
1494+
[
1495+
"selected provider",
1496+
createStartupConfig({
1497+
modelId: "source-external-provider/demo-model",
1498+
noConfiguredChannels: true,
1499+
memorySlot: "none",
1500+
}),
1501+
],
1502+
])("preserves %s activation for source-discovered external plugins", (_name, config) => {
1503+
expectStartupPluginIds({
1504+
config,
1505+
expected: ["browser", "source-external-startup"],
1506+
});
1507+
});
1508+
14321509
it("loads explicit trusted policy plugins at startup", () => {
14331510
expectStartupPluginIds({
14341511
config: createStartupConfig({

‎src/plugins/gateway-startup-plugin-plan.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,14 @@ export function resolveGatewayStartupPluginPlanFromRegistry(params: {
418418
pluginIds.push(plugin.pluginId);
419419
continue;
420420
}
421+
const isSourceExternalPlugin =
422+
plugin.origin === "bundled" && plugin.packageBuild?.bundledDist === false;
423+
// Source checkout discovery still uses the bundled root, but source-only
424+
// packages are externally owned and must keep the external explicit-startup policy.
425+
const startupPolicyOrigin = isSourceExternalPlugin ? "workspace" : plugin.origin;
421426
const activationState = resolveEffectivePluginActivationState({
422427
id: plugin.pluginId,
423-
origin: plugin.origin,
428+
origin: startupPolicyOrigin,
424429
config: pluginsConfig,
425430
rootConfig: params.config,
426431
enabledByDefault: isPluginEnabledByDefaultForPlatform(plugin, params.platform),
@@ -430,7 +435,7 @@ export function resolveGatewayStartupPluginPlanFromRegistry(params: {
430435
continue;
431436
}
432437
if (
433-
plugin.origin !== "bundled"
438+
startupPolicyOrigin !== "bundled"
434439
? activationState.explicitlyEnabled
435440
: activationState.source === "explicit" || activationState.source === "default"
436441
) {

0 commit comments

Comments
 (0)