diff --git a/app/routes/api/analyze.ts b/app/routes/api/analyze.ts index 1c8f651..cdf8d2d 100644 --- a/app/routes/api/analyze.ts +++ b/app/routes/api/analyze.ts @@ -3,16 +3,12 @@ // Server-only imports are loaded dynamically inside the action to avoid client bundling issues export async function action({ request }: { request: Request }) { - console.log("[analyze] Request received:", request.method, request.url); - const body = await request.json(); - console.log("[analyze] Request body:", JSON.stringify(body)); const ticker = body.ticker?.toUpperCase(); const date = body.date || new Date().toISOString().split("T")[0]; if (!ticker) { - console.log("[analyze] Error: ticker missing"); return Response.json({ error: "ticker is required" }, { status: 400 }); } @@ -22,10 +18,8 @@ export async function action({ request }: { request: Request }) { const { fetchAccount, fetchRecentCloses, fetchBars } = await import("../../lib/alpacaClient"); const apiKey = process.env.OPENROUTER_API_KEY; - console.log("[analyze] API key configured:", !!apiKey, apiKey?.substring(0, 10) + "..."); if (!apiKey || apiKey === "your_openrouter_api_key_here") { - console.log("[analyze] Using mock mode"); const mockDecision = { action: "hold" as const, confidence: 0.75, @@ -54,12 +48,10 @@ export async function action({ request }: { request: Request }) { }, ], }; - console.log("[analyze] Returning mock decision"); return Response.json(mockDecision); } const { graph, config } = await buildTradingGraph(apiKey); - console.log("[analyze] Trading config:", config); // Fetch latest Alpaca account and recent prices; abort if unavailable let account: any = undefined; @@ -101,8 +93,6 @@ export async function action({ request }: { request: Request }) { }; try { - console.log("[analyze] Running trading graph..."); - if (body.background) { // Enqueue background analyze job and return 202 immediately try { @@ -132,13 +122,6 @@ export async function action({ request }: { request: Request }) { console.warn("Failed to enrich execution plan:", e); } - // Avoid logging potentially verbose debate rounds to server CLI - try { - const { debateRounds, ...decisionSafe } = decision as any; - console.log("[analyze] Decision received (debate redacted):", JSON.stringify(decisionSafe)); - } catch (e) { - console.log("[analyze] Decision received"); - } return Response.json(decision); } catch (error) { const message = error instanceof Error ? error.message : "Unknown error";