( recipientName: string, requestId: string, context: ToolUseContext, )
| 478 | } |
| 479 | |
| 480 | async function handlePlanApproval( |
| 481 | recipientName: string, |
| 482 | requestId: string, |
| 483 | context: ToolUseContext, |
| 484 | ): Promise<{ data: ResponseOutput }> { |
| 485 | const appState = context.getAppState() |
| 486 | const teamName = appState.teamContext?.teamName |
| 487 | |
| 488 | if (!isTeamLead(appState.teamContext)) { |
| 489 | throw new Error( |
| 490 | 'Only the team lead can approve plans. Teammates cannot approve their own or other plans.', |
| 491 | ) |
| 492 | } |
| 493 | |
| 494 | const leaderMode = appState.toolPermissionContext.mode |
| 495 | const modeToInherit = leaderMode === 'plan' ? 'default' : leaderMode |
| 496 | |
| 497 | const approvalResponse = { |
| 498 | type: 'plan_approval_response', |
| 499 | requestId, |
| 500 | approved: true, |
| 501 | timestamp: new Date().toISOString(), |
| 502 | permissionMode: modeToInherit, |
| 503 | } |
| 504 | |
| 505 | await writeToMailbox( |
| 506 | recipientName, |
| 507 | { |
| 508 | from: TEAM_LEAD_NAME, |
| 509 | text: jsonStringify(approvalResponse), |
| 510 | timestamp: new Date().toISOString(), |
| 511 | }, |
| 512 | teamName, |
| 513 | ) |
| 514 | |
| 515 | return { |
| 516 | data: { |
| 517 | success: true, |
| 518 | message: `Plan approved for ${recipientName}. They will receive the approval and can proceed with implementation.`, |
| 519 | request_id: requestId, |
| 520 | }, |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | async function handlePlanRejection( |
| 525 | recipientName: string, |
no test coverage detected