( runState: RunState, messages: ChatMessage[], )
| 75 | * Save both the RunState and ChatMessage[] to disk |
| 76 | */ |
| 77 | export function saveChatState( |
| 78 | runState: RunState, |
| 79 | messages: ChatMessage[], |
| 80 | ): void { |
| 81 | try { |
| 82 | const runStatePath = getRunStatePath() |
| 83 | const messagesPath = getChatMessagesPath() |
| 84 | |
| 85 | fs.writeFileSync(runStatePath, JSON.stringify(runState, null, 2)) |
| 86 | fs.writeFileSync(messagesPath, JSON.stringify(messages, null, 2)) |
| 87 | } catch (error) { |
| 88 | logger.error( |
| 89 | { |
| 90 | error: error instanceof Error ? error.message : String(error), |
| 91 | }, |
| 92 | 'Failed to save chat state', |
| 93 | ) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Load both RunState and ChatMessage[] from a specific chat directory or the most recent one. |
no test coverage detected