( agent: AgentDefinition, )
| 304 | * Deletes an agent file |
| 305 | */ |
| 306 | export async function deleteAgentFromFile( |
| 307 | agent: AgentDefinition, |
| 308 | ): Promise<void> { |
| 309 | if (agent.source === 'built-in') { |
| 310 | throw new Error('Cannot delete built-in agents') |
| 311 | } |
| 312 | |
| 313 | const filePath = getActualAgentFilePath(agent) |
| 314 | |
| 315 | try { |
| 316 | await unlink(filePath) |
| 317 | } catch (e: unknown) { |
| 318 | const code = getErrnoCode(e) |
| 319 | if (code !== 'ENOENT') { |
| 320 | throw e |
| 321 | } |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | async function writeFileAndFlush( |
| 326 | filePath: string, |
no test coverage detected