diff --git a/agents/codex.ts b/agents/codex.ts index ce8d5f3..76c6234 100644 --- a/agents/codex.ts +++ b/agents/codex.ts @@ -1,5 +1,4 @@ import { spawnSync } from "node:child_process"; -import type { McpServerConfig } from "@anthropic-ai/claude-agent-sdk"; import { Codex, type CodexOptions, type ThreadEvent } from "@openai/codex-sdk"; import { log } from "../utils/cli.ts"; import { addInstructions } from "./instructions.ts"; diff --git a/agents/cursor.ts b/agents/cursor.ts index c9270ad..f2ed72c 100644 --- a/agents/cursor.ts +++ b/agents/cursor.ts @@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { join, resolve } from "node:path"; import { log } from "../utils/cli.ts"; import { addInstructions } from "./instructions.ts"; -import { agent, installFromCurl, type AddMcpServerParams } from "./shared.ts"; +import { type AddMcpServerParams, agent, installFromCurl } from "./shared.ts"; export const cursor = agent({ name: "cursor", diff --git a/mcp/shared.ts b/mcp/shared.ts index 21be66b..3a46f64 100644 --- a/mcp/shared.ts +++ b/mcp/shared.ts @@ -52,32 +52,27 @@ function logToolCall({ request: unknown; error?: unknown; success?: boolean; -}): void { - try { - const logPath = getLogPath(); - const timestamp = new Date().toISOString(); - const requestStr = JSON.stringify(request, null, 2); +}) { + const logPath = getLogPath(); + const timestamp = new Date().toISOString(); + const requestStr = JSON.stringify(request, null, 2); - let logEntry = `[${timestamp}] Tool: ${toolName}\n`; - logEntry += `Request: ${requestStr}\n`; + let logEntry = `[${timestamp}] Tool: ${toolName}\nRequest: ${requestStr}\n`; - if (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - const errorStack = error instanceof Error ? error.stack : undefined; - logEntry += `Error: ${errorMessage}\n`; - if (errorStack) { - logEntry += `Stack: ${errorStack}\n`; - } - logEntry += `Status: FAILED\n`; - } else if (success !== undefined) { - logEntry += `Status: ${success ? "SUCCESS" : "FAILED"}\n`; + if (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + const errorStack = error instanceof Error ? error.stack : undefined; + logEntry += `Error: ${errorMessage}\n`; + if (errorStack) { + logEntry += `Stack: ${errorStack}\n`; } - - logEntry += `${"=".repeat(80)}\n\n`; - appendFileSync(logPath, logEntry, "utf-8"); - } catch { - // Silently fail if logging fails to avoid breaking the tool + logEntry += `Status: FAILED\n`; + } else if (success !== undefined) { + logEntry += `Status: ${success ? "SUCCESS" : "FAILED"}\n`; } + + logEntry += `${"=".repeat(80)}\n\n`; + appendFileSync(logPath, logEntry, "utf-8"); } export const tool = (toolDef: Tool>) => {