( targetName: string, reason: string | undefined, context: ToolUseContext, )
| 312 | } |
| 313 | |
| 314 | async function handleShutdownRequest( |
| 315 | targetName: string, |
| 316 | reason: string | undefined, |
| 317 | context: ToolUseContext, |
| 318 | ): Promise<{ data: RequestOutput }> { |
| 319 | const appState = context.getAppState() |
| 320 | const teamName = getTeamName(appState.teamContext) |
| 321 | const senderName = getAgentName() || TEAM_LEAD_NAME |
| 322 | const requestId = generateRequestId('shutdown', targetName) |
| 323 | |
| 324 | const shutdownMessage = createShutdownRequestMessage({ |
| 325 | requestId, |
| 326 | from: senderName, |
| 327 | reason, |
| 328 | }) |
| 329 | |
| 330 | await writeToMailbox( |
| 331 | targetName, |
| 332 | { |
| 333 | from: senderName, |
| 334 | text: jsonStringify(shutdownMessage), |
| 335 | timestamp: new Date().toISOString(), |
| 336 | color: getTeammateColor(), |
| 337 | }, |
| 338 | teamName, |
| 339 | ) |
| 340 | |
| 341 | return { |
| 342 | data: { |
| 343 | success: true, |
| 344 | message: `Shutdown request sent to ${targetName}. Request ID: ${requestId}`, |
| 345 | request_id: requestId, |
| 346 | target: targetName, |
| 347 | }, |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | async function handleShutdownApproval( |
| 352 | requestId: string, |
no test coverage detected