log
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { spawnSync } from "node:child_process";
|
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 { Codex, type CodexOptions, type ThreadEvent } from "@openai/codex-sdk";
|
||||||
import { log } from "../utils/cli.ts";
|
import { log } from "../utils/cli.ts";
|
||||||
import { addInstructions } from "./instructions.ts";
|
import { addInstructions } from "./instructions.ts";
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|||||||
import { join, resolve } from "node:path";
|
import { join, resolve } from "node:path";
|
||||||
import { log } from "../utils/cli.ts";
|
import { log } from "../utils/cli.ts";
|
||||||
import { addInstructions } from "./instructions.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({
|
export const cursor = agent({
|
||||||
name: "cursor",
|
name: "cursor",
|
||||||
|
|||||||
+17
-22
@@ -52,32 +52,27 @@ function logToolCall({
|
|||||||
request: unknown;
|
request: unknown;
|
||||||
error?: unknown;
|
error?: unknown;
|
||||||
success?: boolean;
|
success?: boolean;
|
||||||
}): void {
|
}) {
|
||||||
try {
|
const logPath = getLogPath();
|
||||||
const logPath = getLogPath();
|
const timestamp = new Date().toISOString();
|
||||||
const timestamp = new Date().toISOString();
|
const requestStr = JSON.stringify(request, null, 2);
|
||||||
const requestStr = JSON.stringify(request, null, 2);
|
|
||||||
|
|
||||||
let logEntry = `[${timestamp}] Tool: ${toolName}\n`;
|
let logEntry = `[${timestamp}] Tool: ${toolName}\nRequest: ${requestStr}\n`;
|
||||||
logEntry += `Request: ${requestStr}\n`;
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
const errorStack = error instanceof Error ? error.stack : undefined;
|
const errorStack = error instanceof Error ? error.stack : undefined;
|
||||||
logEntry += `Error: ${errorMessage}\n`;
|
logEntry += `Error: ${errorMessage}\n`;
|
||||||
if (errorStack) {
|
if (errorStack) {
|
||||||
logEntry += `Stack: ${errorStack}\n`;
|
logEntry += `Stack: ${errorStack}\n`;
|
||||||
}
|
|
||||||
logEntry += `Status: FAILED\n`;
|
|
||||||
} else if (success !== undefined) {
|
|
||||||
logEntry += `Status: ${success ? "SUCCESS" : "FAILED"}\n`;
|
|
||||||
}
|
}
|
||||||
|
logEntry += `Status: FAILED\n`;
|
||||||
logEntry += `${"=".repeat(80)}\n\n`;
|
} else if (success !== undefined) {
|
||||||
appendFileSync(logPath, logEntry, "utf-8");
|
logEntry += `Status: ${success ? "SUCCESS" : "FAILED"}\n`;
|
||||||
} catch {
|
|
||||||
// Silently fail if logging fails to avoid breaking the tool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logEntry += `${"=".repeat(80)}\n\n`;
|
||||||
|
appendFileSync(logPath, logEntry, "utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tool = <const params>(toolDef: Tool<any, StandardSchemaV1<params>>) => {
|
export const tool = <const params>(toolDef: Tool<any, StandardSchemaV1<params>>) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user