Skip to content

Commit 94ba9f9

Browse files
committed
fix(plugins): close beta install fallback gaps
Carry hosted official provenance into beta release selection and make a missing cohort terminal before hook fallback. Align the plugin docs with the fresh-install and recovery policies.
1 parent d5763b1 commit 94ba9f9

7 files changed

Lines changed: 39 additions & 10 deletions

‎docs/cli/plugins.md‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,13 @@ remains a supported fallback and direct-install path. OpenClaw-owned
172172
`@openclaw/*` plugin packages are published on npm again; see the current list
173173
on [npmjs.com/org/openclaw](https://www.npmjs.com/org/openclaw) or the
174174
[plugin inventory](/plugins/plugin-inventory). Stable installs use `latest`.
175-
Beta-channel installs and updates prefer the npm `beta` dist-tag when available,
176-
falling back to `latest`. On the extended-stable channel, official npm plugins
177-
with bare/default or `latest` intent resolve to the exact installed core
178-
version. Exact pins and explicit non-`latest` tags, third-party packages, and
179-
non-npm sources are not rewritten.
175+
Fresh beta-channel installs of official plugins require the npm `beta` dist-tag
176+
and stop if that release is missing; pass an explicit version to choose another
177+
release. Doctor, onboarding, and plugin-update recovery paths can fall back to
178+
the recorded or default selector with a visible warning. On the extended-stable
179+
channel, official npm plugins with bare/default or `latest` intent resolve to
180+
the exact installed core version. Exact pins and explicit non-`latest` tags,
181+
third-party packages, and non-npm sources are not rewritten.
180182
</Note>
181183

182184
<AccordionGroup>

‎src/cli/plugins-cli-test-helpers.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ vi.mock("./prompt.js", () => ({
647647
vi.mock("../plugins/install.js", () => ({
648648
PLUGIN_INSTALL_ERROR_CODE: {
649649
NPM_PACKAGE_NOT_FOUND: "npm_package_not_found",
650+
RELEASE_COHORT_UNAVAILABLE: "release_cohort_unavailable",
650651
SECURITY_SCAN_BLOCKED: "security_scan_blocked",
651652
SECURITY_SCAN_FAILED: "security_scan_failed",
652653
UNSUPPORTED_PLAIN_FILE_PLUGIN: "unsupported_plain_file_plugin",

‎src/cli/plugins-cli.install.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,6 +2016,7 @@ describe("plugins cli install", () => {
20162016

20172017
expect(npmInstallCall(0).spec).toBe("@openclaw/brave-plugin@beta");
20182018
expect(installPluginFromNpmSpecMock).toHaveBeenCalledTimes(1);
2019+
expect(installHooksFromNpmSpecMock).not.toHaveBeenCalled();
20192020
expect(configWriteMock).not.toHaveBeenCalled();
20202021
expect(runtimeErrors.at(-1)).toContain(
20212022
"No @openclaw/brave-plugin@beta release is published for this gateway",

‎src/cli/plugins-install-hook-fallback.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export function isTerminalPluginInstallFailure(code?: string): boolean {
6363
return (
6464
code === PLUGIN_INSTALL_ERROR_CODE.SECURITY_SCAN_BLOCKED ||
6565
code === PLUGIN_INSTALL_ERROR_CODE.SECURITY_SCAN_FAILED ||
66+
code === PLUGIN_INSTALL_ERROR_CODE.RELEASE_COHORT_UNAVAILABLE ||
6667
code === PLUGIN_INSTALL_ERROR_CODE.UNSUPPORTED_PLAIN_FILE_PLUGIN
6768
);
6869
}

‎src/plugins/install-types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const PLUGIN_INSTALL_ERROR_CODE = {
2929
INVALID_OPENCLAW_EXTENSIONS: "invalid_openclaw_extensions",
3030
NPM_METADATA_FAILURE: "npm_metadata_failure",
3131
NPM_PACKAGE_NOT_FOUND: "npm_package_not_found",
32+
RELEASE_COHORT_UNAVAILABLE: "release_cohort_unavailable",
3233
PLUGIN_ID_MISMATCH: "plugin_id_mismatch",
3334
SECURITY_SCAN_BLOCKED: "security_scan_blocked",
3435
SECURITY_SCAN_FAILED: "security_scan_failed",

‎src/plugins/management-service.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,13 +611,13 @@ describe("plugin management service", () => {
611611
expect(mocks.persistInstall).not.toHaveBeenCalled();
612612
});
613613

614-
it("does not pin a runtime id when the hosted entry only exposes its package name", async () => {
614+
it("resolves hosted-only beta installs without pinning the package name as a runtime id", async () => {
615615
const installRecord = {
616616
source: "clawhub",
617617
spec: "clawhub:@openclaw/bluebubbles",
618618
installPath: "/tmp/extensions/bluebubbles",
619619
};
620-
mocks.readConfig.mockResolvedValue(configSnapshot());
620+
mocks.readConfig.mockResolvedValue(configSnapshot({ update: { channel: "beta" } }));
621621
// Package identity without a declared runtime id must not become an expectedPluginId pin.
622622
mockHostedOfficialCatalog([
623623
{
@@ -651,6 +651,14 @@ describe("plugin management service", () => {
651651
expect(mocks.clawhubInstall).toHaveBeenCalledWith(
652652
expect.not.objectContaining({ expectedPluginId: expect.anything() }),
653653
);
654+
expect(mocks.clawhubInstall).toHaveBeenCalledWith(
655+
expect.objectContaining({ spec: "clawhub:@openclaw/bluebubbles@beta" }),
656+
);
657+
expect(mocks.persistInstall).toHaveBeenCalledWith(
658+
expect.objectContaining({
659+
install: expect.objectContaining({ spec: "clawhub:@openclaw/bluebubbles" }),
660+
}),
661+
);
654662
expect(result.plugin.id).toBe("bluebubbles");
655663
});
656664

‎src/plugins/management-service.ts‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ import {
4949
import { commitPluginInstallRecordsWithConfig } from "./install-record-commit.js";
5050
import type { InstallSafetyOverrides } from "./install-security-scan.js";
5151
import type { InstallPolicyWarningDetails } from "./install-security-scan.types.js";
52-
import { isUnavailableNpmTarget, type PluginInstallLogger } from "./install-types.js";
52+
import {
53+
isUnavailableNpmTarget,
54+
PLUGIN_INSTALL_ERROR_CODE,
55+
type PluginInstallLogger,
56+
} from "./install-types.js";
5357
import {
5458
installPluginFromNpmPackArchive,
5559
installPluginFromNpmSpec,
@@ -170,6 +174,8 @@ export type ManagedPluginSourceInstallRequest =
170174
mode?: "install" | "update";
171175
expectedPluginId?: string;
172176
expectedIntegrity?: string;
177+
/** Host-validated official catalog provenance for release-cohort resolution. */
178+
trustedSourceLinkedOfficialInstall?: true;
173179
acknowledgeClawHubRisk?: boolean;
174180
onClawHubRisk?: NonNullable<Parameters<typeof installPluginFromClawHub>[0]["onClawHubRisk"]>;
175181
}
@@ -1244,7 +1250,9 @@ function resolveOfficialManagedInstallSpec(params: {
12441250
config: OpenClawConfig;
12451251
}): string | null {
12461252
const { request } = params;
1247-
if (request.source === "npm" && request.trustedSourceLinkedOfficialInstall !== true) {
1253+
const trustedSourceLinkedOfficialInstall =
1254+
request.source !== "official" && request.trustedSourceLinkedOfficialInstall === true;
1255+
if (request.source === "npm" && !trustedSourceLinkedOfficialInstall) {
12481256
return null;
12491257
}
12501258
// An integrity pin identifies one exact artifact, so it outranks the channel.
@@ -1255,7 +1263,12 @@ function resolveOfficialManagedInstallSpec(params: {
12551263
request.source === "clawhub"
12561264
? parseClawHubPluginSpec(request.spec)?.name
12571265
: parseRegistryNpmSpec(request.spec)?.name;
1258-
if (!packageName || !getOfficialExternalPluginCatalogEntryForPackage(packageName)) {
1266+
if (
1267+
!packageName ||
1268+
(request.source !== "official" &&
1269+
!trustedSourceLinkedOfficialInstall &&
1270+
!getOfficialExternalPluginCatalogEntryForPackage(packageName))
1271+
) {
12591272
return null;
12601273
}
12611274
const updateChannel = resolveRegistryUpdateChannel({
@@ -1321,6 +1334,7 @@ export async function installManagedPluginSource(
13211334
}
13221335
return {
13231336
...result,
1337+
code: PLUGIN_INSTALL_ERROR_CODE.RELEASE_COHORT_UNAVAILABLE,
13241338
error: `No ${installSpec} release is published for this gateway. Installing ${request.spec} would resolve a build from another release; pass an explicit version to install one anyway.`,
13251339
};
13261340
}
@@ -1567,6 +1581,7 @@ function resolveManagedClawHubInstallRequest(params: {
15671581
return {
15681582
source: "clawhub",
15691583
spec: buildClawHubSpec(packageName, version),
1584+
...(official ? { trustedSourceLinkedOfficialInstall: true } : {}),
15701585
...(expectedPluginId ? { expectedPluginId } : {}),
15711586
...(expectedIntegrity ? { expectedIntegrity } : {}),
15721587
...(params.request.acknowledgeClawHubRisk ? { acknowledgeClawHubRisk: true } : {}),

0 commit comments

Comments
 (0)