* Force kills an in-process teammate immediately. * * Uses the teammate's AbortController to cancel all async operations * and updates the task state to 'killed'.
(agentId: string)
| 259 | * and updates the task state to 'killed'. |
| 260 | */ |
| 261 | async kill(agentId: string): Promise<boolean> { |
| 262 | logForDebugging(`[InProcessBackend] kill() called for ${agentId}`) |
| 263 | |
| 264 | if (!this.context) { |
| 265 | logForDebugging( |
| 266 | `[InProcessBackend] kill() failed: no context set for ${agentId}`, |
| 267 | ) |
| 268 | return false |
| 269 | } |
| 270 | |
| 271 | // Get current AppState to find the task |
| 272 | const state = this.context.getAppState() |
| 273 | const task = findTeammateTaskByAgentId(agentId, state.tasks) |
| 274 | |
| 275 | if (!task) { |
| 276 | logForDebugging( |
| 277 | `[InProcessBackend] kill() failed: task not found for ${agentId}`, |
| 278 | ) |
| 279 | return false |
| 280 | } |
| 281 | |
| 282 | // Kill the teammate via the existing helper function |
| 283 | const killed = killInProcessTeammate(task.id, this.context.setAppState) |
| 284 | |
| 285 | logForDebugging( |
| 286 | `[InProcessBackend] kill() ${killed ? 'succeeded' : 'failed'} for ${agentId}`, |
| 287 | ) |
| 288 | |
| 289 | return killed |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Checks if an in-process teammate is still active. |
no test coverage detected