(config: Partial<ReplayingCapiProxyState>)
| 103 | } |
| 104 | |
| 105 | async updateConfig(config: Partial<ReplayingCapiProxyState>): Promise<void> { |
| 106 | if (!config.filePath || !config.workDir) { |
| 107 | throw new Error("filePath and workDir must be provided in config"); |
| 108 | } |
| 109 | |
| 110 | // Since we're about to switch to a new file, write out any captured exchanges |
| 111 | // Note that the final call to stop() will also write out any remaining exchanges. |
| 112 | // In CI mode (GITHUB_ACTIONS=true) we never write — the snapshots are read-only. |
| 113 | // Otherwise tests that exercise only a subset of a multi-conversation snapshot |
| 114 | // would silently overwrite the file with that subset, breaking subsequent runs. |
| 115 | if (this.state && process.env.GITHUB_ACTIONS !== "true") { |
| 116 | await writeCapturesToDisk(this.exchanges, this.state); |
| 117 | } |
| 118 | |
| 119 | this.state = { |
| 120 | filePath: config.filePath, |
| 121 | workDir: config.workDir, |
| 122 | testInfo: config.testInfo, |
| 123 | toolResultNormalizers: [...this.defaultToolResultNormalizers], |
| 124 | }; |
| 125 | |
| 126 | this.clearExchanges(); |
| 127 | await this.loadStoredData(); |
| 128 | } |
| 129 | |
| 130 | private async loadStoredData(): Promise<void> { |
| 131 | if (this.state && existsSync(this.state.filePath)) { |
no test coverage detected