MCPcopy Create free account
hub / github.com/Noumena-Network/code / handlePlanApproval

Function handlePlanApproval

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

Source from the content-addressed store, hash-verified

478}
479
480async 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
524async function handlePlanRejection(
525 recipientName: string,

Callers 1

callFunction · 0.85

Calls 3

isTeamLeadFunction · 0.85
writeToMailboxFunction · 0.85
jsonStringifyFunction · 0.85

Tested by

no test coverage detected