






















@@ -7,27 +7,31 @@ source "$ROOT_DIR/scripts/lib/docker-e2e-image.sh"
77IMAGE_NAME="$(docker_e2e_resolve_image "openclaw-openai-web-search-minimal-e2e" OPENCLAW_OPENAI_WEB_SEARCH_MINIMAL_E2E_IMAGE)"
88SKIP_BUILD="${OPENCLAW_OPENAI_WEB_SEARCH_MINIMAL_E2E_SKIP_BUILD:-0}"
99PORT="18789"
10-MOCK_PORT="19191"
10+MOCK_PORT="80"
1111TOKEN="openai-web-search-minimal-e2e-$$"
12121313docker_e2e_build_or_reuse "$IMAGE_NAME" openai-web-search-minimal "$ROOT_DIR/scripts/e2e/Dockerfile" "$ROOT_DIR" "" "$SKIP_BUILD"
14+OPENCLAW_TEST_STATE_SCRIPT_B64="$(docker_e2e_test_state_shell_b64 openai-web-search-minimal empty)"
14151516echo "Running OpenAI web_search minimal reasoning Docker E2E..."
1617run_logged openai-web-search-minimal docker run --rm \
18+ --add-host api.openai.com:127.0.0.1 \
1719 -e "OPENCLAW_GATEWAY_TOKEN=$TOKEN" \
1820 -e "OPENAI_API_KEY=sk-openclaw-web-search-minimal-e2e" \
19- -e "BRAVE_API_KEY=brave-openclaw-web-search-minimal-e2e" \
21+ -e "OPENCLAW_TEST_STATE_SCRIPT_B64=$OPENCLAW_TEST_STATE_SCRIPT_B64" \
2022 -e "PORT=$PORT" \
2123 -e "MOCK_PORT=$MOCK_PORT" \
2224 -i "$IMAGE_NAME" bash -s <<'EOF'
2325set -euo pipefail
242625-export HOME="$(mktemp -d "/tmp/openclaw-openai-web-search-minimal.XXXXXX")"
26-export OPENCLAW_STATE_DIR="$HOME/.openclaw"
27+eval "$(printf "%s" "${OPENCLAW_TEST_STATE_SCRIPT_B64:?missing OPENCLAW_TEST_STATE_SCRIPT_B64}" | base64 -d)"
2728export OPENCLAW_SKIP_CHANNELS=1
2829export OPENCLAW_SKIP_GMAIL_WATCHER=1
2930export OPENCLAW_SKIP_CRON=1
3031export OPENCLAW_SKIP_CANVAS_HOST=1
32+export OPENCLAW_SKIP_BROWSER_CONTROL_SERVER=1
33+export OPENCLAW_SKIP_ACPX_RUNTIME=1
34+export OPENCLAW_SKIP_ACPX_RUNTIME_PROBE=1
31353236PORT="${PORT:?missing PORT}"
3337MOCK_PORT="${MOCK_PORT:?missing MOCK_PORT}"
@@ -126,7 +130,7 @@ cat >"$OPENCLAW_STATE_DIR/openclaw.json" <<JSON
126130 "providers": {
127131 "openai": {
128132 "api": "openai-responses",
129- "baseUrl": "http://127.0.0.1:${MOCK_PORT}/v1",
133+ "baseUrl": "http://api.openai.com/v1",
130134 "apiKey": { "source": "env", "provider": "default", "id": "OPENAI_API_KEY" },
131135 "request": { "allowPrivateNetwork": true },
132136 "models": [
@@ -149,22 +153,15 @@ cat >"$OPENCLAW_STATE_DIR/openclaw.json" <<JSON
149153 "web": {
150154 "search": {
151155 "enabled": true,
152- "provider": "brave",
153156 "maxResults": 3
154157 }
155158 }
156159 },
157160 "plugins": {
158161 "enabled": true,
162+ "allow": ["openai"],
159163 "entries": {
160- "brave": {
161- "enabled": true,
162- "config": {
163- "webSearch": {
164- "apiKey": { "source": "env", "provider": "default", "id": "BRAVE_API_KEY" }
165- }
166- }
167- }
164+ "openai": { "enabled": true }
168165 }
169166 },
170167 "gateway": {
@@ -359,9 +356,22 @@ node "$entry" gateway health \
359356 --json >/dev/null
360357361358cat >/tmp/openclaw-openai-web-search-minimal-client.mjs <<'NODE'
362-import { execFileSync } from "node:child_process";
359+import { readdirSync } from "node:fs";
360+import { pathToFileURL } from "node:url";
361+362+async function loadCallGateway() {
363+ const candidates = readdirSync("/app/dist")
364+ .filter((name) => /^call(?:\.runtime)?-[A-Za-z0-9_-]+\.js$/.test(name))
365+ .sort();
366+ for (const name of candidates) {
367+ const mod = await import(pathToFileURL(`/app/dist/${name}`).href);
368+ if (typeof mod.callGateway === "function") return mod.callGateway;
369+ }
370+ throw new Error(`unable to find callGateway export in /app/dist (${candidates.join(", ")})`);
371+}
372+373+const callGateway = await loadCallGateway();
363374364-const entry = process.env.OPENCLAW_ENTRY;
365375const port = process.env.PORT;
366376const token = process.env.OPENCLAW_GATEWAY_TOKEN;
367377const mode = process.argv[2];
@@ -372,40 +382,32 @@ const message =
372382 : "Return exactly OPENCLAW_SCHEMA_E2E_OK.";
373383const id = mode === "reject" ? "schema-reject" : "schema-success";
374384375-if (!entry || !port || !token) throw new Error("missing OPENCLAW_ENTRY/PORT/OPENCLAW_GATEWAY_TOKEN");
376-377-const gatewayArgs = [
378- entry,
379- "gateway",
380- "call",
381- "--url",
382- `ws://127.0.0.1:${port}`,
383- "--token",
384- token,
385- "--timeout",
386- "240000",
387- "--expect-final",
388- "--json",
389-];
390-391-function gatewayAgent(params) {
385+if (!port || !token) throw new Error("missing PORT/OPENCLAW_GATEWAY_TOKEN");
386+387+async function gatewayAgent(params) {
392388 try {
393389 return {
394390 ok: true,
395- value: JSON.parse(execFileSync("node", [...gatewayArgs, "agent", "--params", JSON.stringify(params)], {
396- encoding: "utf8",
397- stdio: ["ignore", "pipe", "pipe"],
398- })),
391+ value: await callGateway({
392+ url: `ws://127.0.0.1:${port}`,
393+ token,
394+ method: "agent",
395+ params,
396+ expectFinal: true,
397+ timeoutMs: 240_000,
398+ clientName: "gateway-client",
399+ mode: "backend",
400+ scopes: ["operator.write"],
401+ deviceIdentity: null,
402+ }),
399403 };
400404 } catch (error) {
401- const stderr = typeof error?.stderr === "string" ? error.stderr : "";
402- const stdout = typeof error?.stdout === "string" ? error.stdout : "";
403- const combined = [String(error), stderr.trim(), stdout.trim()].filter(Boolean).join("\n");
405+ const combined = String(error);
404406 return { ok: false, error: new Error(combined) };
405407 }
406408}
407409408-const result = gatewayAgent({
410+const result = await gatewayAgent({
409411 sessionKey,
410412 message,
411413 thinking: "minimal",
@@ -424,7 +426,7 @@ if (result.value?.status !== "ok") {
424426}
425427NODE
426428427-OPENCLAW_ENTRY="$entry" PORT="$PORT" OPENCLAW_GATEWAY_TOKEN="$TOKEN" node /tmp/openclaw-openai-web-search-minimal-client.mjs success >/tmp/openclaw-openai-web-search-minimal-client-success.log 2>&1
429+PORT="$PORT" OPENCLAW_GATEWAY_TOKEN="$TOKEN" node /tmp/openclaw-openai-web-search-minimal-client.mjs success >/tmp/openclaw-openai-web-search-minimal-client-success.log 2>&1
428430429431node - "$MOCK_REQUEST_LOG" <<'NODE'
430432const fs = require("node:fs");
@@ -448,7 +450,7 @@ if (success.body.reasoning?.effort === "minimal") {
448450}
449451NODE
450452451-OPENCLAW_ENTRY="$entry" PORT="$PORT" OPENCLAW_GATEWAY_TOKEN="$TOKEN" node /tmp/openclaw-openai-web-search-minimal-client.mjs reject >/tmp/openclaw-openai-web-search-minimal-client-reject.log 2>&1
453+PORT="$PORT" OPENCLAW_GATEWAY_TOKEN="$TOKEN" node /tmp/openclaw-openai-web-search-minimal-client.mjs reject >/tmp/openclaw-openai-web-search-minimal-client-reject.log 2>&1
452454453455for _ in $(seq 1 80); do
454456 if grep -Fq "$RAW_SCHEMA_ERROR" "$GATEWAY_LOG"; then
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。