( agent: AgentDefinition, )
| 239 | * Deletes an agent file |
| 240 | */ |
| 241 | export async function deleteAgentFromFile( |
| 242 | agent: AgentDefinition, |
| 243 | ): Promise<void> { |
| 244 | if (agent.source === 'built-in') { |
| 245 | throw new Error('Cannot delete built-in agents') |
| 246 | } |
| 247 | |
| 248 | const filePath = getActualAgentFilePath(agent) |
| 249 | |
| 250 | try { |
| 251 | await unlink(filePath) |
| 252 | } catch (e: unknown) { |
| 253 | const code = getErrnoCode(e) |
| 254 | if (code !== 'ENOENT') { |
| 255 | throw e |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | async function writeFileAndFlush( |
| 261 | filePath: string, |
no test coverage detected