Extract two self-contained subsystems from agent-session.ts (3,367 -> 2,737 lines): - RetryHandler: auto-retry with exponential backoff, credential rotation, and cross-provider fallback logic - CompactionOrchestrator: manual/auto compaction, overflow recovery, and extension integration for custom compaction providers Also add shared getErrorMessage() utility to replace repeated `err instanceof Error ? err.message : String(err)` patterns. The extracted modules receive AgentSession state via dependency injection interfaces, avoiding state duplication. AgentSession remains the coordinator that delegates to these modules.
6 lines
190 B
TypeScript
6 lines
190 B
TypeScript
/**
|
|
* Extract a human-readable message from an unknown caught value.
|
|
*/
|
|
export function getErrorMessage(err: unknown): string {
|
|
return err instanceof Error ? err.message : String(err);
|
|
}
|