MCPcopy Create free account
hub / github.com/freecodexyz/free-code / sendDirectMemberMessage

Function sendDirectMemberMessage

src/utils/directMemberMessage.ts:39–69  ·  view source on GitHub ↗
(
  recipientName: string,
  message: string,
  teamContext: AppState['teamContext'],
  writeToMailbox?: WriteToMailboxFn,
)

Source from the content-addressed store, hash-verified

37 * Send a direct message to a team member, bypassing the model.
38 */
39export async function sendDirectMemberMessage(
40 recipientName: string,
41 message: string,
42 teamContext: AppState['teamContext'],
43 writeToMailbox?: WriteToMailboxFn,
44): Promise<DirectMessageResult> {
45 if (!teamContext || !writeToMailbox) {
46 return { success: false, error: 'no_team_context' }
47 }
48
49 // Find team member by name
50 const member = Object.values(teamContext.teammates ?? {}).find(
51 t => t.name === recipientName,
52 )
53
54 if (!member) {
55 return { success: false, error: 'unknown_recipient', recipientName }
56 }
57
58 await writeToMailbox(
59 recipientName,
60 {
61 from: 'user',
62 text: message,
63 timestamp: new Date().toISOString(),
64 },
65 teamContext.teamName,
66 )
67
68 return { success: true, recipientName }
69}

Callers 1

PromptInputFunction · 0.85

Calls 1

writeToMailboxFunction · 0.85

Tested by

no test coverage detected