refactor: extract shared utilities, protocol constants, and retry loop
Phase 3: provider-retry.ts — shared Claude rotation loop (SSOT) - retryClaudeWithRotation extracted from message-agent-executor + task-scheduler - ~200 lines of duplicated retry logic removed Phase 4: types.ts — AgentOutputPhase + VisiblePhase unified Phase 5: types.ts — AgentConfig extended with claudeThinking/claudeThinkingBudget Utilities (utils.ts): - getErrorMessage: 14 occurrences of instanceof Error pattern → 1 function - readJsonFile/writeJsonFile: 19 occurrences of JSON+fs pattern → 2 functions - fetchWithTimeout: 3 occurrences of AbortController pattern → 1 function - formatElapsedKorean: deduplicated from task-watch-status + message-turn-controller Protocol (agent-protocol.ts): - OUTPUT_START/END_MARKER centralized (runners keep local copies with SSOT reference) - IMAGE_TAG_RE, IPC constants documented Runner: show "대화 요약 중..." progress message during auto-compact Net: -137 lines, 354/354 tests passing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { TIMEZONE } from './config.js';
|
||||
import type { ScheduledTask } from './types.js';
|
||||
import { formatElapsedKorean } from './utils.js';
|
||||
|
||||
export type WatcherStatusPhase =
|
||||
| 'checking'
|
||||
@@ -65,16 +66,7 @@ function formatElapsedLabel(
|
||||
0,
|
||||
new Date(checkedAtIso).getTime() - new Date(startedAtIso).getTime(),
|
||||
);
|
||||
const totalSeconds = Math.floor(elapsedMs / 1000);
|
||||
const hours = Math.floor(totalSeconds / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
|
||||
const parts: string[] = [];
|
||||
if (hours > 0) parts.push(`${hours}시간`);
|
||||
if (minutes > 0) parts.push(`${minutes}분`);
|
||||
parts.push(`${seconds}초`);
|
||||
return parts.join(' ');
|
||||
return formatElapsedKorean(elapsedMs);
|
||||
}
|
||||
|
||||
export function renderWatchCiStatusMessage(args: {
|
||||
|
||||
Reference in New Issue
Block a user