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:
19
src/agent-protocol.ts
Normal file
19
src/agent-protocol.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Agent Protocol Constants (SSOT).
|
||||
*
|
||||
* Shared constants for host ↔ runner communication.
|
||||
* Runners are separate packages and can't import this directly —
|
||||
* they define local copies with comments referencing this file.
|
||||
*/
|
||||
|
||||
/** Sentinel markers for robust stdout output parsing. */
|
||||
export const OUTPUT_START_MARKER = '---EJCLAW_OUTPUT_START---';
|
||||
export const OUTPUT_END_MARKER = '---EJCLAW_OUTPUT_END---';
|
||||
|
||||
/** Regex to extract [Image: /path/to/file] tags from agent text. */
|
||||
export const IMAGE_TAG_RE = /\[Image:\s*(\/[^\]]+)\]/g;
|
||||
|
||||
/** IPC polling interval (ms) used by runners to check for follow-up messages. */
|
||||
export const IPC_POLL_MS = 500;
|
||||
export const IPC_INPUT_SUBDIR = 'input';
|
||||
export const IPC_CLOSE_SENTINEL = '_close';
|
||||
Reference in New Issue
Block a user