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

Function readMailbox

src/utils/teammateMailbox.ts:84–108  ·  view source on GitHub ↗
(
  agentName: string,
  teamName?: string,
)

Source from the content-addressed store, hash-verified

82 * @param teamName - Optional team name (defaults to CLAUDE_CODE_TEAM_NAME env var or 'default')
83 */
84export async function readMailbox(
85 agentName: string,
86 teamName?: string,
87): Promise<TeammateMessage[]> {
88 const inboxPath = getInboxPath(agentName, teamName)
89 logForDebugging(`[TeammateMailbox] readMailbox: path=${inboxPath}`)
90
91 try {
92 const content = await readFile(inboxPath, 'utf-8')
93 const messages = jsonParse(content) as TeammateMessage[]
94 logForDebugging(
95 `[TeammateMailbox] readMailbox: read ${messages.length} message(s)`,
96 )
97 return messages
98 } catch (error) {
99 const code = getErrnoCode(error)
100 if (code === 'ENOENT') {
101 logForDebugging(`[TeammateMailbox] readMailbox: file does not exist`)
102 return []
103 }
104 logForDebugging(`Failed to read inbox for ${agentName}: ${error}`)
105 logError(error)
106 return []
107 }
108}
109
110/**
111 * Read only unread messages from a teammate's inbox

Callers 7

readUnreadMessagesFunction · 0.85
writeToMailboxFunction · 0.85
markMessageAsReadByIndexFunction · 0.85
markMessagesAsReadFunction · 0.85

Calls 6

getInboxPathFunction · 0.85
logForDebuggingFunction · 0.85
readFileFunction · 0.85
jsonParseFunction · 0.85
getErrnoCodeFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected