( recipientName: string, requestId: string, feedback: string, context: ToolUseContext, )
| 476 | } |
| 477 | |
| 478 | async function handlePlanRejection( |
| 479 | recipientName: string, |
| 480 | requestId: string, |
| 481 | feedback: string, |
| 482 | context: ToolUseContext, |
| 483 | ): Promise<{ data: ResponseOutput }> { |
| 484 | const appState = context.getAppState() |
| 485 | const teamName = appState.teamContext?.teamName |
| 486 | |
| 487 | if (!isTeamLead(appState.teamContext)) { |
| 488 | throw new Error( |
| 489 | 'Only the team lead can reject plans. Teammates cannot reject their own or other plans.', |
| 490 | ) |
| 491 | } |
| 492 | |
| 493 | const rejectionResponse = { |
| 494 | type: 'plan_approval_response', |
| 495 | requestId, |
| 496 | approved: false, |
| 497 | feedback, |
| 498 | timestamp: new Date().toISOString(), |
| 499 | } |
| 500 | |
| 501 | await writeToMailbox( |
| 502 | recipientName, |
| 503 | { |
| 504 | from: TEAM_LEAD_NAME, |
| 505 | text: jsonStringify(rejectionResponse), |
| 506 | timestamp: new Date().toISOString(), |
| 507 | }, |
| 508 | teamName, |
| 509 | ) |
| 510 | |
| 511 | return { |
| 512 | data: { |
| 513 | success: true, |
| 514 | message: `Plan rejected for ${recipientName} with feedback: "${feedback}"`, |
| 515 | request_id: requestId, |
| 516 | }, |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | export const SendMessageTool: Tool<InputSchema, SendMessageToolOutput> = |
| 521 | buildTool({ |
no test coverage detected