( recipientName: string, requestId: string, feedback: string, context: ToolUseContext, )
| 522 | } |
| 523 | |
| 524 | async function handlePlanRejection( |
| 525 | recipientName: string, |
| 526 | requestId: string, |
| 527 | feedback: string, |
| 528 | context: ToolUseContext, |
| 529 | ): Promise<{ data: ResponseOutput }> { |
| 530 | const appState = context.getAppState() |
| 531 | const teamName = appState.teamContext?.teamName |
| 532 | |
| 533 | if (!isTeamLead(appState.teamContext)) { |
| 534 | throw new Error( |
| 535 | 'Only the team lead can reject plans. Teammates cannot reject their own or other plans.', |
| 536 | ) |
| 537 | } |
| 538 | |
| 539 | const rejectionResponse = { |
| 540 | type: 'plan_approval_response', |
| 541 | requestId, |
| 542 | approved: false, |
| 543 | feedback, |
| 544 | timestamp: new Date().toISOString(), |
| 545 | } |
| 546 | |
| 547 | await writeToMailbox( |
| 548 | recipientName, |
| 549 | { |
| 550 | from: TEAM_LEAD_NAME, |
| 551 | text: jsonStringify(rejectionResponse), |
| 552 | timestamp: new Date().toISOString(), |
| 553 | }, |
| 554 | teamName, |
| 555 | ) |
| 556 | |
| 557 | return { |
| 558 | data: { |
| 559 | success: true, |
| 560 | message: `Plan rejected for ${recipientName} with feedback: "${feedback}"`, |
| 561 | request_id: requestId, |
| 562 | }, |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | export const SendMessageTool: Tool<InputSchema, SendMessageToolOutput> = |
| 567 | buildTool({ |
no test coverage detected