MCPcopy Index your code
hub / github.com/codeaashu/claude-code / handlePlanApproval

Function handlePlanApproval

src/tools/SendMessageTool/SendMessageTool.ts:434–476  ·  view source on GitHub ↗
(
  recipientName: string,
  requestId: string,
  context: ToolUseContext,
)

Source from the content-addressed store, hash-verified

432}
433
434async 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
478async function handlePlanRejection(
479 recipientName: string,

Callers 1

callFunction · 0.85

Calls 3

isTeamLeadFunction · 0.85
writeToMailboxFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected