@@ -11,17 +11,39 @@ IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-codex-on-demand-e2e" OPENCLAW_C
1111DOCKER_TARGET=" ${OPENCLAW_CODEX_ON_DEMAND_DOCKER_TARGET:- bare} "
1212HOST_BUILD=" ${OPENCLAW_CODEX_ON_DEMAND_HOST_BUILD:- 1} "
1313PACKAGE_TGZ=" ${OPENCLAW_CURRENT_PACKAGE_TGZ:- } "
14+ PREPUBLISH_PLUGIN_REGISTRY_ARGS=()
15+ AUTO_PREPUBLISH_PLUGIN_REGISTRY_ROOT=" "
1416run_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.
1921export 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+
2140cleanup () {
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
4567prepare_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+
4783docker_e2e_package_mount_args " $PACKAGE_TGZ "
4884run_log=" $( docker_e2e_run_log codex-on-demand) "
4985OPENCLAW_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..."
5288if ! 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
5794set -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}
78116trap '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+
80176mkdir -p "$NPM_CONFIG_PREFIX" "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE"
81177chmod 700 "$XDG_CACHE_HOME" "$NPM_CONFIG_CACHE" || true
82178
@@ -87,6 +183,8 @@ openclaw_e2e_enable_openclaw_cli_timeout
87183openclaw_e2e_assert_dep_absent "@openclaw/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
88184openclaw_e2e_assert_dep_absent "@openai/codex" "$HOME/.openclaw" "$NPM_CONFIG_PREFIX"
89185
186+ configure_plugin_registry
187+
90188echo "Running non-interactive OpenAI onboarding; Codex should install on demand..."
91189openclaw onboard --non-interactive --accept-risk \
92190 --mode local \
0 commit comments