prepare_package_tgz() { if [ -n "$PACKAGE_TGZ" ]; then if [ ! -f "$PACKAGE_TGZ" ]; then echo"OPENCLAW_NPM_ONBOARD_PACKAGE_TGZ does not exist: $PACKAGE_TGZ" >&2
exit 1 fi
PACKAGE_TGZ="$(cd "$(dirname "$PACKAGE_TGZ")" && pwd)/$(basename "$PACKAGE_TGZ")"
return 0 fi
if [ "$HOST_BUILD" != "0" ]; then echo"Building host package artifacts..."
run_logged npm-onboard-channel-agent-host-build pnpm build else echo"Skipping host build (OPENCLAW_NPM_ONBOARD_HOST_BUILD=0)" fi
command -v openclaw >/dev/null
package_root="$(npm root -g)/openclaw"
test -d "$package_root/dist/extensions/telegram"
test -d "$package_root/dist/extensions/discord"
assert_dep_absent() {
local sentinel="$1" if find "$package_root""$HOME/.openclaw" -path "*/node_modules/$sentinel/package.json" -print -quit 2>/dev/null | grep -q .; then echo"$sentinel should not be installed before channel activation repair" >&2
find "$package_root""$HOME/.openclaw" -path "*/node_modules/$sentinel/package.json"-print 2>/dev/null >&2 || true
exit 1 fi
}
assert_dep_present() {
local sentinel="$1" if ! find "$package_root""$HOME/.openclaw" -path "*/node_modules/$sentinel/package.json" -print -quit 2>/dev/null | grep -q .; then echo"$sentinel was not installed on demand" >&2
find "$package_root""$HOME/.openclaw" -maxdepth 6 -type d -name node_modules -print 2>/dev/null >&2 || true
exit 1 fi
}
MOCK_PORT="$MOCK_PORT" SUCCESS_MARKER="$SUCCESS_MARKER" MOCK_REQUEST_LOG="$MOCK_REQUEST_LOG" node scripts/e2e/mock-openai-server.mjs >/tmp/openclaw-mock-openai.log 2>&1 &
mock_pid="$!" for _ in $(seq 1 80); do if node -e "fetch('http://127.0.0.1:${MOCK_PORT}/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"; then
break fi
sleep 0.1 done
node -e "fetch('http://127.0.0.1:${MOCK_PORT}/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
if (!fs.existsSync(configPath)) {
throw new Error("onboard did not write openclaw.json");
} if (!fs.existsSync(agentDir)) {
throw new Error("onboard did not create main agent dir");
} if (!fs.existsSync(authPath)) {
throw new Error("onboard did not create auth-profiles.json");
}
const authRaw = fs.readFileSync(authPath, "utf8"); if (!authRaw.includes("OPENAI_API_KEY")) {
throw new Error("auth profile did not persist OPENAI_API_KEY env ref");
} if (authRaw.includes("sk-openclaw-npm-onboard-e2e")) {
throw new Error("auth profile persisted the raw OpenAI test key");
}
NODE
echo"Configuring $CHANNEL..."
openclaw channels add --channel "$CHANNEL" --token "$CHANNEL_TOKEN" >/tmp/openclaw-channel-add.log 2>&1
node - "$CHANNEL""$CHANNEL_TOKEN" <<'NODE'
const fs = require("node:fs");
const path = require("node:path");
const channel = process.argv[2];
const token = process.argv[3];
const cfg = JSON.parse(fs.readFileSync(path.join(process.env.HOME, ".openclaw", "openclaw.json"), "utf8"));
const entry = cfg.channels?.[channel]; if (!entry || entry.enabled === false) {
throw new Error(`${channel} was not enabled`);
}
const serialized = JSON.stringify(entry); if (!serialized.includes(token)) {
throw new Error(`${channel} token was not persisted`);
}
NODE
echo"Running doctor after channel activation..."
openclaw doctor --repair --non-interactive >/tmp/openclaw-doctor.log 2>&1
assert_dep_present "$DEP_SENTINEL"
echo"Running local agent turn against mocked OpenAI..."
openclaw agent --local \
--agent main \
--session-id npm-onboard-channel-agent \
--message "Return the success marker from the test server." \
--thinking off \
--json >/tmp/openclaw-agent.combined 2>&1
node - "$SUCCESS_MARKER""$MOCK_REQUEST_LOG" <<'NODE'
const fs = require("node:fs");
const marker = process.argv[2];
const logPath = process.argv[3];
const output = fs.readFileSync("/tmp/openclaw-agent.combined", "utf8"); if (!output.includes(marker)) {
throw new Error(`agent JSON did not contain success marker. Output: ${output}`);
}
const requestLog = fs.existsSync(logPath) ? fs.readFileSync(logPath, "utf8") : ""; if (!/\/v1\/(responses|chat\/completions)/.test(requestLog)) {
throw new Error(`mock OpenAI server was not used. Requests: ${requestLog}`);
}
NODE
echo"npm tarball onboard/channel/agent Docker E2E passed for $CHANNEL"
EOF then cat"$run_log" rm -f "$run_log"
exit 1 fi
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.