惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
D
Docker
J
Java Code Geeks
L
LangChain Blog
Microsoft Security Blog
Microsoft Security Blog
The GitHub Blog
The GitHub Blog
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
MongoDB | Blog
MongoDB | Blog
月光博客
月光博客
T
Tailwind CSS Blog
M
MIT News - Artificial intelligence
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
腾讯CDC
罗磊的独立博客
U
Unit 42
爱范儿
爱范儿
Vercel News
Vercel News
MyScale Blog
MyScale Blog

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
refactor: share e2e mock http helpers · openclaw/openclaw...
vincentkoc · 2026-05-30 · via Recent Commits to openclaw:main

File tree

      • openai-web-search-minimal

Original file line numberDiff line numberDiff line change

@@ -0,0 +1,29 @@

1+

export function readBody(req) {

2+

return new Promise((resolve, reject) => {

3+

let body = "";

4+

req.setEncoding("utf8");

5+

req.on("data", (chunk) => {

6+

body += chunk;

7+

});

8+

req.on("end", () => resolve(body));

9+

req.on("error", reject);

10+

});

11+

}

12+
13+

export function writeJson(res, status, body) {

14+

res.writeHead(status, { "content-type": "application/json" });

15+

res.end(JSON.stringify(body));

16+

}

17+
18+

export function writeSse(res, events) {

19+

res.writeHead(200, {

20+

"content-type": "text/event-stream",

21+

"cache-control": "no-store",

22+

connection: "keep-alive",

23+

});

24+

for (const event of events) {

25+

res.write(`data: ${JSON.stringify(event)}\n\n`);

26+

}

27+

res.write("data: [DONE]\n\n");

28+

res.end();

29+

}

Original file line numberDiff line numberDiff line change

@@ -1,29 +1,13 @@

11

import fs from "node:fs";

22

import http from "node:http";

33

import { readPositiveIntEnv } from "../env-limits.mjs";

4+

import { readBody, writeJson, writeSse } from "../mock-openai-http.mjs";

45
56

const port = readPositiveIntEnv("MOCK_PORT");

67

const requestLog = process.env.MOCK_REQUEST_LOG;

78

const successMarker = process.env.SUCCESS_MARKER;

89

const rawSchemaError = process.env.RAW_SCHEMA_ERROR;

910
10-

function readBody(req) {

11-

return new Promise((resolve, reject) => {

12-

let body = "";

13-

req.setEncoding("utf8");

14-

req.on("data", (chunk) => {

15-

body += chunk;

16-

});

17-

req.on("end", () => resolve(body));

18-

req.on("error", reject);

19-

});

20-

}

21-
22-

function writeJson(res, status, body) {

23-

res.writeHead(status, { "content-type": "application/json" });

24-

res.end(JSON.stringify(body));

25-

}

26-
2711

function writeOpenAiReject(res) {

2812

writeJson(res, 400, {

2913

error: {

@@ -97,19 +81,6 @@ function responseEvents(text) {

9781

];

9882

}

9983
100-

function writeSse(res, events) {

101-

res.writeHead(200, {

102-

"content-type": "text/event-stream",

103-

"cache-control": "no-store",

104-

connection: "keep-alive",

105-

});

106-

for (const event of events) {

107-

res.write(`data: ${JSON.stringify(event)}\n\n`);

108-

}

109-

res.write("data: [DONE]\n\n");

110-

res.end();

111-

}

112-
11384

const server = http.createServer(async (req, res) => {

11485

const url = new URL(req.url ?? "/", "http://127.0.0.1");

11586

if (req.method === "GET" && url.pathname === "/health") {

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,7 @@

11

import fs from "node:fs";

22

import http from "node:http";

33

import { readPositiveIntEnv } from "./lib/env-limits.mjs";

4+

import { readBody, writeJson, writeSse } from "./lib/mock-openai-http.mjs";

45
56

const port =

67

process.env.MOCK_PORT != null

@@ -9,23 +10,6 @@ const port =

910

const successMarker = process.env.SUCCESS_MARKER ?? "OPENCLAW_E2E_OK";

1011

const requestLog = process.env.MOCK_REQUEST_LOG;

1112
12-

function readBody(req) {

13-

return new Promise((resolve, reject) => {

14-

let body = "";

15-

req.setEncoding("utf8");

16-

req.on("data", (chunk) => {

17-

body += chunk;

18-

});

19-

req.on("end", () => resolve(body));

20-

req.on("error", reject);

21-

});

22-

}

23-
24-

function writeJson(res, status, body) {

25-

res.writeHead(status, { "content-type": "application/json" });

26-

res.end(JSON.stringify(body));

27-

}

28-
2913

function responseEvents(text) {

3014

const itemId = "msg_e2e_1";

3115

return [

@@ -88,19 +72,6 @@ function responseEvents(text) {

8872

];

8973

}

9074
91-

function writeSse(res, events) {

92-

res.writeHead(200, {

93-

"content-type": "text/event-stream",

94-

"cache-control": "no-store",

95-

connection: "keep-alive",

96-

});

97-

for (const event of events) {

98-

res.write(`data: ${JSON.stringify(event)}\n\n`);

99-

}

100-

res.write("data: [DONE]\n\n");

101-

res.end();

102-

}

103-
10475

function writeChatCompletion(res, stream, text = successMarker) {

10576

if (stream) {

10677

writeSse(res, [