mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(server): pass logger to agent clients in e2e tests
Update remaining e2e test files to pass logger to CodexMcpAgentClient and OpenCodeAgentClient constructors.
This commit is contained in:
@@ -129,8 +129,9 @@ describe("agent MCP end-to-end", () => {
|
||||
: undefined;
|
||||
|
||||
const daemonConfig: PaseoDaemonConfig = {
|
||||
port,
|
||||
listen: `${port}`,
|
||||
paseoHome,
|
||||
corsAllowedOrigins: [],
|
||||
agentMcpRoute: "/mcp/agents",
|
||||
agentMcpAllowedHosts: [`127.0.0.1:${port}`, `localhost:${port}`],
|
||||
auth: {
|
||||
@@ -170,9 +171,7 @@ describe("agent MCP end-to-end", () => {
|
||||
process.env.CLAUDE_CONFIG_DIR = claudeConfigDir;
|
||||
|
||||
const daemon = await createPaseoDaemon(daemonConfig, pino({ level: "silent" }));
|
||||
await new Promise<void>((resolve) => {
|
||||
daemon.httpServer.listen(port, () => resolve());
|
||||
});
|
||||
await daemon.start();
|
||||
|
||||
const transport = new StreamableHTTPClientTransport(
|
||||
new URL(`http://127.0.0.1:${port}/mcp/agents`),
|
||||
@@ -283,7 +282,7 @@ describe("agent MCP end-to-end", () => {
|
||||
await client.callTool({ name: "kill_agent", args: { agentId } });
|
||||
}
|
||||
await client.close();
|
||||
await daemon.close();
|
||||
await daemon.stop();
|
||||
if (previousCodexSessionDir === undefined) {
|
||||
delete process.env.CODEX_SESSION_DIR;
|
||||
} else {
|
||||
@@ -330,8 +329,9 @@ describe("agent MCP end-to-end", () => {
|
||||
: undefined;
|
||||
|
||||
const daemonConfig: PaseoDaemonConfig = {
|
||||
port,
|
||||
listen: `${port}`,
|
||||
paseoHome,
|
||||
corsAllowedOrigins: [],
|
||||
agentMcpRoute: "/mcp/agents",
|
||||
agentMcpAllowedHosts: [`127.0.0.1:${port}`, `localhost:${port}`],
|
||||
auth: {
|
||||
@@ -384,9 +384,7 @@ describe("agent MCP end-to-end", () => {
|
||||
process.env.CLAUDE_CONFIG_DIR = claudeConfigDir;
|
||||
|
||||
const daemon = await createPaseoDaemon(daemonConfig, pino({ level: "silent" }));
|
||||
await new Promise<void>((resolve) => {
|
||||
daemon.httpServer.listen(port, () => resolve());
|
||||
});
|
||||
await daemon.start();
|
||||
|
||||
const transport = new StreamableHTTPClientTransport(
|
||||
new URL(`http://127.0.0.1:${port}/mcp/agents`),
|
||||
@@ -479,7 +477,7 @@ describe("agent MCP end-to-end", () => {
|
||||
await client.callTool({ name: "kill_agent", args: { agentId } });
|
||||
}
|
||||
await client.close();
|
||||
await daemon.close();
|
||||
await daemon.stop();
|
||||
if (previousCodexSessionDir === undefined) {
|
||||
delete process.env.CODEX_SESSION_DIR;
|
||||
} else {
|
||||
|
||||
@@ -6,6 +6,7 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
|
||||
import { createTestLogger } from "../../../test-utils/test-logger.js";
|
||||
import type {
|
||||
AgentPermissionRequest,
|
||||
AgentSession,
|
||||
@@ -401,13 +402,15 @@ function getConversationIdFromMetadata(metadata: unknown): string | undefined {
|
||||
}
|
||||
|
||||
describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const logger = createTestLogger();
|
||||
|
||||
test(
|
||||
"provider does not emit user_message (agent-manager handles that), emits exactly one assistant_message",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -477,7 +480,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -507,7 +510,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -610,7 +613,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const mcpServerScript = writeTestMcpServerScript(cwd);
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const nodeModulesPath = resolveNodeModulesPath();
|
||||
const config = {
|
||||
provider: "codex",
|
||||
@@ -758,7 +761,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const mcpServerScript = writeTestMcpServerScript(cwd);
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const nodeModulesPath = resolveNodeModulesPath();
|
||||
const config = {
|
||||
provider: "codex",
|
||||
@@ -905,7 +908,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -963,7 +966,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1042,7 +1045,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1080,7 +1083,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1151,7 +1154,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1202,7 +1205,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1268,7 +1271,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1346,7 +1349,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1423,7 +1426,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
const cwd = tmpCwd();
|
||||
const restoreSessionDir = useTempCodexSessionDir();
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const config = {
|
||||
provider: "codex",
|
||||
model: CODEX_TEST_MODEL,
|
||||
@@ -1511,7 +1514,7 @@ describe("CodexMcpAgentClient (MCP integration)", () => {
|
||||
"listModels returns models with required fields",
|
||||
async () => {
|
||||
const { CodexMcpAgentClient } = await loadCodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient();
|
||||
const client = new CodexMcpAgentClient(logger);
|
||||
const models = await client.listModels();
|
||||
|
||||
// HARD ASSERT: Returns an array
|
||||
|
||||
@@ -3,6 +3,7 @@ import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { createTestLogger } from "../../../test-utils/test-logger.js";
|
||||
import { OpenCodeAgentClient } from "./opencode-agent.js";
|
||||
import type {
|
||||
AgentSessionConfig,
|
||||
@@ -73,6 +74,7 @@ async function collectTurnEvents(
|
||||
}
|
||||
|
||||
describe("OpenCodeAgentClient", () => {
|
||||
const logger = createTestLogger();
|
||||
const buildConfig = (cwd: string): AgentSessionConfig => ({
|
||||
provider: "opencode",
|
||||
cwd,
|
||||
@@ -83,7 +85,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"creates a session with valid id and provider",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
// HARD ASSERT: Session has required fields
|
||||
@@ -101,7 +103,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"single turn completes with streaming deltas",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const iterator = session.stream("Say hello");
|
||||
@@ -133,7 +135,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"user prompt text never appears in assistant_message",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const userMarker = "UNIQUE_USER_MARKER_XYZ789";
|
||||
@@ -161,7 +163,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"multi-turn preserves context",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const secretCode = "ZEBRA_42";
|
||||
@@ -201,7 +203,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
const testFile = path.join(cwd, "test-file.txt");
|
||||
writeFileSync(testFile, "original content\n");
|
||||
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const iterator = session.stream(`Read the file at ${testFile}`);
|
||||
@@ -228,7 +230,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"can be interrupted during streaming",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const events: AgentStreamEvent[] = [];
|
||||
@@ -258,7 +260,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"run() returns accumulated response text",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const marker = "OPENCODE_ACK_TOKEN";
|
||||
@@ -280,7 +282,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"handles permission requests",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
const events: AgentStreamEvent[] = [];
|
||||
@@ -320,7 +322,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
test(
|
||||
"listModels returns models with required fields",
|
||||
async () => {
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const models = await client.listModels();
|
||||
|
||||
// HARD ASSERT: Returns an array
|
||||
@@ -348,7 +350,7 @@ describe("OpenCodeAgentClient", () => {
|
||||
"streamHistory returns exact conversation history after multi-turn session",
|
||||
async () => {
|
||||
const cwd = tmpCwd();
|
||||
const client = new OpenCodeAgentClient();
|
||||
const client = new OpenCodeAgentClient(logger);
|
||||
const session = await client.createSession(buildConfig(cwd));
|
||||
|
||||
// Turn 1: Ask agent to remember a secret
|
||||
|
||||
Reference in New Issue
Block a user