diff --git a/agent/src/agentModeParser.ts b/agent/src/agentModeParser.ts index eef2e16..ad3a437 100644 --- a/agent/src/agentModeParser.ts +++ b/agent/src/agentModeParser.ts @@ -108,17 +108,15 @@ export const parseModeResult = ( if (!isObject(parsed)) { parsed = { answerMarkdown: rawText.trim() }; } - const warnings = stringArray((parsed as Record).warnings); - const parsedChecklist = Array.isArray( - (parsed as Record).checklist, - ) - ? ((parsed as Record).checklist as unknown[]) + const p = parsed as Record; + const warnings = stringArray(p.warnings); + const parsedChecklist = Array.isArray(p.checklist) + ? (p.checklist as unknown[]) : undefined; const analysisGuard = analysisGuardFrom(request, parsedChecklist); - const answerMarkdown = requireString( - (parsed as Record).answerMarkdown, - { fieldName: "answerMarkdown" }, - ); + const answerMarkdown = requireString(p.answerMarkdown, { + fieldName: "answerMarkdown", + }); return { markdown: answerMarkdown, warnings, diff --git a/agent/src/pi/piSession.ts b/agent/src/pi/piSession.ts index 6349b86..b1e3ab2 100644 --- a/agent/src/pi/piSession.ts +++ b/agent/src/pi/piSession.ts @@ -185,34 +185,22 @@ export const runPiSession = async ( }); await loader.reload(); + const baseOptions = { + model, + thinkingLevel: "high" as const, + authStorage: registry.authStorage, + modelRegistry: registry, + resourceLoader: loader, + sessionManager: SessionManager.inMemory(), + settingsManager: SettingsManager.inMemory({ + compaction: { enabled: false }, + retry: { enabled: true, maxRetries: 1 }, + }), + }; const sessionOptions = tools.length > 0 - ? { - model, - thinkingLevel: "high" as const, - authStorage: registry.authStorage, - modelRegistry: registry, - resourceLoader: loader, - sessionManager: SessionManager.inMemory(), - settingsManager: SettingsManager.inMemory({ - compaction: { enabled: false }, - retry: { enabled: true, maxRetries: 1 }, - }), - customTools: tools, - } - : { - model, - thinkingLevel: "high" as const, - authStorage: registry.authStorage, - modelRegistry: registry, - resourceLoader: loader, - sessionManager: SessionManager.inMemory(), - settingsManager: SettingsManager.inMemory({ - compaction: { enabled: false }, - retry: { enabled: true, maxRetries: 1 }, - }), - noTools: "all" as const, - }; + ? { ...baseOptions, customTools: tools } + : { ...baseOptions, noTools: "all" as const }; const { session } = await createAgentSession(sessionOptions); @@ -223,10 +211,9 @@ export const runPiSession = async ( const toolTraces: TraceLogEntry[] = []; const abortController = new AbortController(); + const traceVal = (process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase(); const traceEnabled = - (process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "0" && - (process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "false" && - (process.env.GONGSIRI_TRACE_STDOUT ?? "true").toLowerCase() !== "off"; + traceVal !== "0" && traceVal !== "false" && traceVal !== "off"; const tracePrefix = `pi:${promptCtx?.mode ?? "run"}:${(promptCtx?.traceId ?? "--------").slice(0, 8)}`; const traceLog = (msg: string) => { if (traceEnabled) console.log(`[${tracePrefix}] ${msg}`); diff --git a/frontend/app/(app)/portfolio/page.tsx b/frontend/app/(app)/portfolio/page.tsx index 6182f42..82be07a 100644 --- a/frontend/app/(app)/portfolio/page.tsx +++ b/frontend/app/(app)/portfolio/page.tsx @@ -5,6 +5,18 @@ import RiskBadge from "@/components/ui/RiskBadge"; import AddStockModal from "@/app/(app)/watchlist/_components/AddStockModal"; import type { PortfolioItem, RiskLevel } from "@/lib/types"; +const RISK_BAR_COLOR: Record = { + high: "#E24B4A", + caution: "#BA7517", + normal: "#639922", +}; + +function toRiskLevel(score: number): RiskLevel { + if (score >= 4) return "high"; + if (score >= 2) return "caution"; + return "normal"; +} + const MOCK: PortfolioItem[] = [ { corp_code: "00258801", @@ -39,8 +51,7 @@ export default function PortfolioPage() { return sum + (i.risk_score ?? 0) * weight; }, 0); - const overallLevel: RiskLevel = - weightedScore >= 4 ? "high" : weightedScore >= 2 ? "caution" : "normal"; + const overallLevel = toRiskLevel(weightedScore); return (
@@ -110,12 +121,7 @@ export default function PortfolioPage() { style={{ height: "100%", width: `${(weightedScore / 6) * 100}%`, - background: - overallLevel === "high" - ? "#E24B4A" - : overallLevel === "caution" - ? "#BA7517" - : "#639922", + background: RISK_BAR_COLOR[overallLevel], borderRadius: 100, }} /> diff --git a/frontend/app/(app)/report/page.tsx b/frontend/app/(app)/report/page.tsx index 8b631ba..d9af20b 100644 --- a/frontend/app/(app)/report/page.tsx +++ b/frontend/app/(app)/report/page.tsx @@ -87,7 +87,8 @@ export default async function ReportListPage() { ) : ( reportSummaries.map((r, i) => { const hasReport = r.hasReport !== false; - return hasReport ? ( + const isLast = i === reportSummaries.length - 1; + return (
@@ -116,87 +117,62 @@ export default async function ReportListPage() { > {r.corpName}

-

- {r.analyzedAt} 분석 -

+ {hasReport ? ( +

+ {r.analyzedAt} 분석 +

+ ) : ( +

+ 리포트 미생성 +

+ )}
- -

- {r.riskScore}/6 -

-
- - ) : ( - -
-
-

+ +

+ {r.riskScore}/6 +

+ + ) : ( + - {r.corpName} -

-

- 리포트 미생성 -

-
- - 리포트 생성 - + 리포트 생성 + + )}
); diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 3a13f90..577a4f4 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -30,5 +30,5 @@ ".next/dev/types/**/*.ts", "**/*.mts" ], - "exclude": ["node_modules"] + "exclude": ["node_modules", "e2e"] }