( recipientName: string, requestId: string, context: ToolUseContext, )
| 432 | } |
| 433 | |
| 434 | async function handlePlanApproval( |
| 435 | recipientName: string, |
| 436 | requestId: string, |
| 437 | context: ToolUseContext, |
| 438 | ): Promise<{ data: ResponseOutput }> { |
| 439 | const appState = context.getAppState() |
| 440 | const teamName = appState.teamContext?.teamName |
| 441 | |
| 442 | if (!isTeamLead(appState.teamContext)) { |
| 443 | throw new Error( |
| 444 | 'Only the team lead can approve plans. Teammates cannot approve their own or other plans.', |
| 445 | ) |
| 446 | } |
| 447 | |
| 448 | const leaderMode = appState.toolPermissionContext.mode |
| 449 | const modeToInherit = leaderMode === 'plan' ? 'default' : leaderMode |
| 450 | |
| 451 | const approvalResponse = { |
| 452 | type: 'plan_approval_response', |
| 453 | requestId, |
| 454 | approved: true, |
| 455 | timestamp: new Date().toISOString(), |
| 456 | permissionMode: modeToInherit, |
| 457 | } |
| 458 | |
| 459 | await writeToMailbox( |
| 460 | recipientName, |
| 461 | { |
| 462 | from: TEAM_LEAD_NAME, |
| 463 | text: jsonStringify(approvalResponse), |
| 464 | timestamp: new Date().toISOString(), |
| 465 | }, |
| 466 | teamName, |
| 467 | ) |
| 468 | |
| 469 | return { |
| 470 | data: { |
| 471 | success: true, |
| 472 | message: `Plan approved for ${recipientName}. They will receive the approval and can proceed with implementation.`, |
| 473 | request_id: requestId, |
| 474 | }, |
| 475 | } |
| 476 | } |
| 477 | |
| 478 | async function handlePlanRejection( |
| 479 | recipientName: string, |
no test coverage detected