import { OpenRouterClient } from "../lib/openrouter"; import type { AnalystReport, DebateRound } from "../types/agents"; type ChatResponse = { choices?: Array<{ message?: { content?: string } }>; }; export class BullishResearcher { private client: OpenRouterClient; private model: string; constructor(client: OpenRouterClient, model?: string) { this.client = client; this.model = model ?? "openai/gpt-oss-120b:free"; } async research(ticker: string, reports: AnalystReport[]): Promise { const reportSummaries = reports .map((r) => `${r.analyst}: ${r.signal.signal} - ${r.report}`) .join("\n"); const prompt = `Analyze these analyst reports for ${ticker} and synthesize a bullish thesis: ${reportSummaries} Provide a bullish view based on the positive signals and reasoning.`; const response = await this.client.createChatCompletion( [ { role: "system", content: "You are a bullish equity researcher who finds the positive investment case." }, { role: "user", content: prompt }, ], this.model ); const content = ((response as ChatResponse).choices?.[0]?.message?.content) ?? ""; return { bullishView: content, bearishView: "", researcher: "bullish", }; } } export class BearishResearcher { private client: OpenRouterClient; private model: string; constructor(client: OpenRouterClient, model?: string) { this.client = client; this.model = model ?? "openai/gpt-oss-120b:free"; } async research(ticker: string, reports: AnalystReport[]): Promise { const reportSummaries = reports .map((r) => `${r.analyst}: ${r.signal.signal} - ${r.report}`) .join("\n"); const prompt = `Analyze these analyst reports for ${ticker} and synthesize a bearish thesis: ${reportSummaries} Provide a bearish view based on the risks and negative signals.`; const response = await this.client.createChatCompletion( [ { role: "system", content: "You are a bearish equity researcher who identifies investment risks." }, { role: "user", content: prompt }, ], this.model ); const content = ((response as ChatResponse).choices?.[0]?.message?.content) ?? ""; return { bullishView: "", bearishView: content, researcher: "bearish", }; } }