


























@@ -1,6 +1,6 @@
11import { EventEmitter } from "node:events";
22import { PassThrough } from "node:stream";
3-import { embeddedAgentLog } from "openclaw/plugin-sdk/agent-harness-runtime";
3+import { embeddedAgentLog, OPENCLAW_VERSION } from "openclaw/plugin-sdk/agent-harness-runtime";
44import { afterEach, describe, expect, it, vi } from "vitest";
55import {
66__testing,
@@ -57,14 +57,25 @@ describe("CodexAppServerClient", () => {
57575858harness.process.stdout.write('{"token":"secret-value"} trailing\n');
595960-await vi.waitFor(() =>
61-expect(warn).toHaveBeenCalledWith(
62-"failed to parse codex app-server message",
63-expect.objectContaining({
64-consoleMessage: expect.stringContaining("<redacted>"),
65-linePreview: '{"token":"<redacted>"} trailing',
66-}),
67-),
60+await vi.waitFor(() => expect(warn).toHaveBeenCalledTimes(1));
61+expect(warn.mock.calls[0]?.[0]).toBe("failed to parse codex app-server message");
62+const metadata = warn.mock.calls[0]?.[1] as
63+| {
64+error?: unknown;
65+errorMessage?: string;
66+fragmentCount?: number;
67+linePreview?: string;
68+consoleMessage?: string;
69+}
70+| undefined;
71+expect(metadata?.error).toBeInstanceOf(SyntaxError);
72+expect(metadata?.errorMessage).toBe(
73+"Unexpected non-whitespace character after JSON at position 25 (line 1 column 26)",
74+);
75+expect(metadata?.fragmentCount).toBe(1);
76+expect(metadata?.linePreview).toBe('{"token":"<redacted>"} trailing');
77+expect(metadata?.consoleMessage).toBe(
78+'failed to parse codex app-server message: preview="{\\"token\\":\\"<redacted>\\"} trailing"',
6879);
6980expect(JSON.stringify(warn.mock.calls)).not.toContain("secret-value");
7081});
@@ -157,13 +168,17 @@ describe("CodexAppServerClient", () => {
157168});
158169159170await expect(initializing).resolves.toBeUndefined();
160-expect(outbound).toMatchObject({
171+expect(outbound).toStrictEqual({
172+id: outbound.id,
161173method: "initialize",
162174params: {
163175clientInfo: {
164176name: "openclaw",
165177title: "OpenClaw",
166-version: expect.any(String),
178+version: OPENCLAW_VERSION,
179+},
180+capabilities: {
181+experimentalApi: true,
167182},
168183},
169184});
@@ -433,14 +448,11 @@ describe("CodexAppServerClient", () => {
433448],
434449},
435450});
436-expect(warn).toHaveBeenCalledWith(
437-"codex app-server server request timed out",
438-expect.objectContaining({
439-id: "srv-timeout",
440-method: "item/tool/call",
441-timeoutMs: __testing.CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS,
442-}),
443-);
451+expect(warn).toHaveBeenCalledWith("codex app-server server request timed out", {
452+id: "srv-timeout",
453+method: "item/tool/call",
454+timeoutMs: __testing.CODEX_DYNAMIC_TOOL_SERVER_REQUEST_TIMEOUT_MS,
455+});
444456});
445457446458it("fails closed for unhandled native app-server approvals", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。