Skip to content

Commit 85d5df1

Browse files
steipeteampagentedenfunfRomneyDa
authored
fix(onboarding): OpenAI setup installs mismatched Codex plugin (#129195)
* fix(onboarding): align Codex plugin with core release Amp-Thread-ID: https://ampcode.com/threads/T-01a037b4-f621-7144-bfdf-a68df795dd57 * test(onboarding): reject unpinned Codex candidates Amp-Thread-ID: https://ampcode.com/threads/T-01a037b4-f621-7144-bfdf-a68df795dd57 * fix(onboarding): match stable correction release plugin cohorts Co-authored-by: 許元豪 <[email protected]> * test: isolate plugin metadata and register startup retry coverage * test: adopt upstream startup retry ownership pattern * test: keep plugin metadata readers process-stable * test: isolate terminal session recovery cases * test: drop speculative gateway isolation change * test(gateway): mock terminal transcript lifecycle decision * fix(plugins): align correction cohorts across stable tracks --------- Co-authored-by: Amp <[email protected]> Co-authored-by: 許元豪 <[email protected]> Co-authored-by: Dallin Romney <[email protected]>
1 parent 827433c commit 85d5df1

19 files changed

Lines changed: 238 additions & 23 deletions

‎docs/install/development-channels.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ Switching channels with `openclaw update` also syncs plugin sources:
120120
packages.
121121
- `extended-stable` resolves eligible official npm plugins with bare/default
122122
or `latest` intent to the exact installed core version. It does not query
123-
plugin `@extended-stable` tags at runtime.
123+
plugin `@extended-stable` tags at runtime. Version-bound runtime plugins use
124+
the base release cohort for correction versions (for example, `YYYY.M.P-2`
125+
uses plugin `YYYY.M.P`).
124126
- npm-installed plugins are updated after the core update completes.
125127

126128
## Checking current status

‎docs/install/updating.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ omit `--allow-scripts=openclaw`.
5454
After the core swap, eligible official npm plugins with bare/default or
5555
`latest` intent converge to that exact core version. Exact pins and explicit
5656
non-`latest` tags, third-party plugins, and non-npm sources remain unchanged.
57+
Version-bound runtime plugins converge to the base release cohort when the
58+
core is a correction release (for example, `YYYY.M.P-2` uses plugin
59+
`YYYY.M.P`).
5760
Catalog installs created by current OpenClaw versions retain that default
5861
intent. Older records that contain only an exact version remain pinned because
5962
OpenClaw cannot safely distinguish an old automatic pin from a user pin; run

‎scripts/e2e/codex-on-demand-docker.sh‎

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,39 @@ IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-codex-on-demand-e2e" OPENCLAW_C
1111
DOCKER_TARGET="${OPENCLAW_CODEX_ON_DEMAND_DOCKER_TARGET:-bare}"
1212
HOST_BUILD="${OPENCLAW_CODEX_ON_DEMAND_HOST_BUILD:-1}"
1313
PACKAGE_TGZ="${OPENCLAW_CURRENT_PACKAGE_TGZ:-}"
14+
PREPUBLISH_PLUGIN_REGISTRY_ARGS=()
15+
AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT=""
1416
run_log=""
1517

1618
# This lane installs the package and then exercises a managed npm install of Codex.
1719
# Keep the package install budget above the shared default so slow npm hosts reach
1820
# the Codex assertions instead of failing as a silent package-install timeout.
1921
export OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-1200s}"
2022

23+
configure_prepublish_plugin_registry() {
24+
local registry_dir="$1"
25+
local resolved_registry_dir
26+
resolved_registry_dir="$(cd "$registry_dir" && pwd)"
27+
if [ ! -f "$resolved_registry_dir/prepublish-plugin-registry.json" ]; then
28+
echo "Prepublish plugin registry manifest is missing." >&2
29+
exit 1
30+
fi
31+
PREPUBLISH_PLUGIN_REGISTRY_ARGS=(
32+
-e OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR=/tmp/openclaw-prepublish-plugin-registry
33+
-v "$resolved_registry_dir:/tmp/openclaw-prepublish-plugin-registry:ro"
34+
)
35+
}
36+
if [ -n "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ]; then
37+
configure_prepublish_plugin_registry "$OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR"
38+
fi
39+
2140
cleanup() {
2241
if [ -n "${PACKAGE_TGZ:-}" ]; then
2342
docker_e2e_cleanup_package_tgz "$PACKAGE_TGZ"
2443
fi
44+
if [ -n "$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT" ]; then
45+
rm -rf "$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT"
46+
fi
2547
if [ -n "${run_log:-}" ]; then
2648
rm -f "$run_log"
2749
fi
@@ -44,6 +66,20 @@ prepare_package_tgz() {
4466

4567
prepare_package_tgz
4668

69+
if [ -z "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ] &&
70+
[ -z "${OPENCLAW_CURRENT_PACKAGE_TGZ:-}" ] &&
71+
[ "$HOST_BUILD" != "0" ]; then
72+
AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT="$(
73+
mktemp -d "${TMPDIR:-/tmp}/openclaw-codex-on-demand-plugin-registry.XXXXXX"
74+
)"
75+
OPENCLAW_DOCKER_ALL_LANES=codex-on-demand \
76+
OPENCLAW_DOCKER_ALL_LOG_DIR="$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT" \
77+
OPENCLAW_DOCKER_ALL_TIMINGS=0 \
78+
node "$ROOT_DIR/scripts/test-docker-all.mjs" --prepare-plugin-registry >/dev/null
79+
configure_prepublish_plugin_registry \
80+
"$AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT/prepublish-plugin-registry"
81+
fi
82+
4783
docker_e2e_package_mount_args "$PACKAGE_TGZ"
4884
run_log="$(docker_e2e_run_log codex-on-demand)"
4985
OPENCLAW_TEST_STATE_SCRIPT_B64="$(docker_e2e_test_state_shell_b64 codex-on-demand empty)"
@@ -52,6 +88,7 @@ echo "Running Codex on-demand Docker E2E..."
5288
if ! docker_e2e_run_with_harness \
5389
-e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \
5490
-e "OPENCLAW_TEST_STATE_SCRIPT_B64=$OPENCLAW_TEST_STATE_SCRIPT_B64" \
91+
${PREPUBLISH_PLUGIN_REGISTRY_ARGS[@]+"${PREPUBLISH_PLUGIN_REGISTRY_ARGS[@]}"} \
5592
"${DOCKER_E2E_PACKAGE_ARGS[@]}" \
5693
-i "$IMAGE_NAME" bash -s >"$run_log" 2>&1 <<'EOF'; then
5794
set -euo pipefail
@@ -71,12 +108,71 @@ dump_debug_logs() {
71108
echo "Codex on-demand scenario failed with exit code $status" >&2
72109
openclaw_e2e_dump_logs \
73110
/tmp/openclaw-install.log \
111+
/tmp/openclaw-codex-registry/server.log \
74112
/tmp/openclaw-onboard.json \
75113
/tmp/openclaw-plugins-list.json \
76114
/tmp/openclaw-codex-inspect.json
77115
}
78116
trap 'status=$?; dump_debug_logs "$status"; exit "$status"' ERR
79117
118+
plugin_registry_pid=""
119+
cleanup_inner() {
120+
openclaw_e2e_stop_process "${plugin_registry_pid:-}"
121+
}
122+
trap cleanup_inner EXIT
123+
124+
configure_plugin_registry() {
125+
[ -n "${OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR:-}" ] || return 0
126+
local registry_root="/tmp/openclaw-codex-registry"
127+
local manifest="$OPENCLAW_PREPUBLISH_PLUGIN_REGISTRY_DIR/prepublish-plugin-registry.json"
128+
local package_name package_version package_tarball
129+
IFS=$'\t' read -r package_name package_version package_tarball < <(
130+
PREPUBLISH_PLUGIN_REGISTRY_MANIFEST="$manifest" node <<'NODE'
131+
const fs = require("node:fs");
132+
const path = require("node:path");
133+
const manifestPath = process.env.PREPUBLISH_PLUGIN_REGISTRY_MANIFEST;
134+
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
135+
const matches = Array.isArray(manifest.packages)
136+
? manifest.packages.filter((entry) => entry?.name === "@openclaw/codex")
137+
: [];
138+
if (matches.length !== 1) {
139+
throw new Error("prepublish plugin registry must contain exactly one @openclaw/codex package");
140+
}
141+
const entry = matches[0];
142+
if (
143+
typeof entry.version !== "string" ||
144+
typeof entry.tarball !== "string" ||
145+
path.basename(entry.tarball) !== entry.tarball
146+
) {
147+
throw new Error("invalid @openclaw/codex prepublish plugin registry entry");
148+
}
149+
process.stdout.write(
150+
`${entry.name}\t${entry.version}\t${path.join(path.dirname(manifestPath), entry.tarball)}\n`,
151+
);
152+
NODE
153+
)
154+
mkdir -p "$registry_root"
155+
OPENCLAW_NPM_REGISTRY_DIST_TAGS="latest=0.0.0,beta=$package_version" \
156+
OPENCLAW_NPM_REGISTRY_UPSTREAM=https://registry.npmjs.org \
157+
node scripts/e2e/lib/plugins/npm-registry-server.mjs \
158+
"$registry_root/port" \
159+
"$package_name" "$package_version" "$package_tarball" \
160+
>"$registry_root/server.log" 2>&1 &
161+
plugin_registry_pid="$!"
162+
for _ in $(seq 1 100); do
163+
[ -s "$registry_root/port" ] && break
164+
openclaw_e2e_process_alive "$plugin_registry_pid" || break
165+
sleep 0.1
166+
done
167+
if [ ! -s "$registry_root/port" ]; then
168+
openclaw_e2e_print_log "$registry_root/server.log" >&2
169+
echo "Timed out waiting for Codex npm registry." >&2
170+
return 1
171+
fi
172+
export NPM_CONFIG_REGISTRY="http://127.0.0.1:$(cat "$registry_root/port")"
173+
export npm_config_registry="$NPM_CONFIG_REGISTRY"
174+
}
175+
80176
mkdir -p "$NPM_CONFIG_PREFIX" "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE"
81177
chmod 700 "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE" || true
82178
@@ -87,6 +183,8 @@ openclaw_e2e_enable_openclaw_cli_timeout
87183
openclaw_e2e_assert_dep_absent "@openclaw/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
88184
openclaw_e2e_assert_dep_absent "@openai/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
89185
186+
configure_plugin_registry
187+
90188
echo "Running non-interactive OpenAI onboarding; Codex should install on demand..."
91189
openclaw onboard --non-interactive --accept-risk \
92190
--mode local \

‎scripts/lib/docker-e2e-plan.mts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ export function requiredPrepublishPluginPackagesForLanes(poolLanes: DockerE2eLan
746746
const configuredChannelIds = new Set<string>();
747747
const requiredPackages = new Set<string>();
748748
for (const poolLane of poolLanes) {
749+
for (const packageName of poolLane.prepublishPluginPackages ?? []) {
750+
requiredPackages.add(packageName);
751+
}
749752
const scenario = upgradeSurvivorScenarioForLane(poolLane);
750753
if (!scenario) {
751754
continue;

‎scripts/lib/docker-e2e-scenarios.mts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type DockerE2eLane = {
1616
name: string;
1717
needsLiveImage?: boolean;
1818
noOutputTimeoutMs?: number;
19+
prepublishPluginPackages?: string[];
1920
resources: string[];
2021
retries: number;
2122
retryPatterns: RegExp[];
@@ -106,6 +107,7 @@ function lane(name: string, command: string, options: LaneOptions = {}): DockerE
106107
noOutputTimeoutMs: options.noOutputTimeoutMs,
107108
name,
108109
needsLiveImage: options.needsLiveImage,
110+
prepublishPluginPackages: options.prepublishPluginPackages,
109111
retryPatterns: options.retryPatterns ?? [],
110112
retries: options.retries ?? 0,
111113
resources: options.resources ?? [],
@@ -442,6 +444,7 @@ export const mainLanes: DockerE2eLane[] = [
442444
weight: 2,
443445
}),
444446
npmLane("codex-on-demand", "OPENCLAW_SKIP_DOCKER_BUILD=1 pnpm test:docker:codex-on-demand", {
447+
prepublishPluginPackages: ["@openclaw/codex"],
445448
resources: ["service"],
446449
stateScenario: "empty",
447450
weight: 3,

‎src/commands/codex-runtime-plugin-install.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ describe("Codex runtime plugin install repair", () => {
175175
label: "Codex",
176176
install: { npmSpec: "@openclaw/codex", defaultChoice: "npm" },
177177
trustedSourceLinkedOfficialInstall: true,
178+
versionBoundToOpenClaw: true,
178179
},
179180
}),
180181
);

‎src/commands/codex-runtime-plugin-install.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const CODEX_RUNTIME_PLUGIN_DESCRIPTOR = {
1010
label: CODEX_RUNTIME_PLUGIN_LABEL,
1111
npmSpec: CODEX_RUNTIME_PLUGIN_NPM_SPEC,
1212
warningLabel: CODEX_RUNTIME_PLUGIN_LABEL,
13+
versionBoundToOpenClaw: true,
1314
};
1415

1516
const codexRuntimePluginInstall = createRuntimePluginModelSelectionHelpers({

‎src/commands/onboarding-plugin-install.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,47 @@ describe("ensureOnboardingPluginInstalled", () => {
827827
);
828828
});
829829

830+
it("keeps version-bound official runtime plugins aligned with the stable core version", async () => {
831+
installPluginFromNpmSpec.mockResolvedValueOnce({
832+
ok: true,
833+
pluginId: "codex",
834+
targetDir: "/tmp/codex",
835+
version: VERSION,
836+
npmResolution: {
837+
name: "@openclaw/codex",
838+
version: VERSION,
839+
resolvedSpec: `@openclaw/codex@${VERSION}`,
840+
},
841+
});
842+
843+
await ensureOnboardingPluginInstalled({
844+
cfg: { update: { channel: "stable" } },
845+
entry: {
846+
pluginId: "codex",
847+
label: "Codex",
848+
install: { npmSpec: "@openclaw/codex" },
849+
trustedSourceLinkedOfficialInstall: true,
850+
versionBoundToOpenClaw: true,
851+
},
852+
prompter: {
853+
select: vi.fn(async () => "npm"),
854+
progress: vi.fn(() => ({ update: vi.fn(), stop: vi.fn() })),
855+
} as never,
856+
runtime: {} as never,
857+
promptInstall: false,
858+
});
859+
860+
const [npmCall] = readFirstMockCall(installPluginFromNpmSpec, "installPluginFromNpmSpec") as [
861+
NpmSpecInstallCall,
862+
];
863+
expect(npmCall.spec).toBe(`@openclaw/codex@${VERSION}`);
864+
const [, recordUpdate] = readFirstMockCall(recordPluginInstall, "recordPluginInstall") as [
865+
OpenClawConfig,
866+
PluginInstallRecord,
867+
];
868+
expect(recordUpdate.spec).toBe("@openclaw/codex");
869+
});
870+
830871
it("logs npm install warnings once while shortening the progress label", async () => {
831872
const warning =
832873
"npm rejected managed npm alias overrides; retrying plugin install without alias overrides for this npm version.";

‎src/commands/onboarding-plugin-install.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export type OnboardingPluginInstallEntry = {
7373
label: string;
7474
install: PluginPackageInstall;
7575
trustedSourceLinkedOfficialInstall?: boolean;
76+
/** Keep this official runtime package on the same release cohort as OpenClaw. */
77+
versionBoundToOpenClaw?: boolean;
7678
preferRemoteInstall?: boolean;
7779
};
7880

@@ -1145,6 +1147,7 @@ export async function ensureOnboardingPluginInstalled(params: {
11451147
? parseRegistryNpmSpec(npmSpec)?.name
11461148
: undefined,
11471149
coreVersion: VERSION,
1150+
versionBoundToCore: entry.versionBoundToOpenClaw,
11481151
})
11491152
: null;
11501153
const clawhubInstallSpec = clawhubSpecs?.installSpec ?? clawhubSpec;

‎src/commands/runtime-plugin-install.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ type RuntimePluginInstallDescriptor = {
2020
label: string;
2121
npmSpec: string;
2222
warningLabel: string;
23+
/** Keep this official runtime package on the same release cohort as OpenClaw. */
24+
versionBoundToOpenClaw?: boolean;
2325
};
2426

2527
/** Result returned after ensuring a runtime plugin for a selected model. */
@@ -139,6 +141,7 @@ async function ensureRuntimePluginForModelSelection(params: {
139141
defaultChoice: "npm",
140142
},
141143
trustedSourceLinkedOfficialInstall: true,
144+
...(params.descriptor.versionBoundToOpenClaw ? { versionBoundToOpenClaw: true } : {}),
142145
},
143146
prompter: params.prompter,
144147
runtime: params.runtime,

0 commit comments

Comments
 (0)