Reduce local debug detail in mailbox and session helpers
This commit is contained in:
@@ -57,11 +57,7 @@ export function getInboxPath(agentName: string, teamName?: string): string {
|
||||
const safeTeam = sanitizePathComponent(team)
|
||||
const safeAgentName = sanitizePathComponent(agentName)
|
||||
const inboxDir = join(getTeamsDir(), safeTeam, 'inboxes')
|
||||
const fullPath = join(inboxDir, `${safeAgentName}.json`)
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] getInboxPath: agent=${agentName}, team=${team}, fullPath=${fullPath}`,
|
||||
)
|
||||
return fullPath
|
||||
return join(inboxDir, `${safeAgentName}.json`)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +68,7 @@ async function ensureInboxDir(teamName?: string): Promise<void> {
|
||||
const safeTeam = sanitizePathComponent(team)
|
||||
const inboxDir = join(getTeamsDir(), safeTeam, 'inboxes')
|
||||
await mkdir(inboxDir, { recursive: true })
|
||||
logForDebugging(`[TeammateMailbox] Ensured inbox directory: ${inboxDir}`)
|
||||
logForDebugging('[TeammateMailbox] Ensured inbox directory')
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +81,6 @@ export async function readMailbox(
|
||||
teamName?: string,
|
||||
): Promise<TeammateMessage[]> {
|
||||
const inboxPath = getInboxPath(agentName, teamName)
|
||||
logForDebugging(`[TeammateMailbox] readMailbox: path=${inboxPath}`)
|
||||
|
||||
try {
|
||||
const content = await readFile(inboxPath, 'utf-8')
|
||||
@@ -100,7 +95,7 @@ export async function readMailbox(
|
||||
logForDebugging(`[TeammateMailbox] readMailbox: file does not exist`)
|
||||
return []
|
||||
}
|
||||
logForDebugging(`Failed to read inbox for ${agentName}: ${error}`)
|
||||
logForDebugging(`[TeammateMailbox] Failed to read inbox for ${agentName}`)
|
||||
logError(error)
|
||||
return []
|
||||
}
|
||||
@@ -141,7 +136,7 @@ export async function writeToMailbox(
|
||||
const lockFilePath = `${inboxPath}.lock`
|
||||
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] writeToMailbox: recipient=${recipientName}, from=${message.from}, path=${inboxPath}`,
|
||||
`[TeammateMailbox] writeToMailbox: recipient=${recipientName}, from=${message.from}`,
|
||||
)
|
||||
|
||||
// Ensure the inbox file exists before locking (proper-lockfile requires the file to exist)
|
||||
@@ -152,7 +147,7 @@ export async function writeToMailbox(
|
||||
const code = getErrnoCode(error)
|
||||
if (code !== 'EEXIST') {
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] writeToMailbox: failed to create inbox file: ${error}`,
|
||||
`[TeammateMailbox] writeToMailbox: failed to create inbox file`,
|
||||
)
|
||||
logError(error)
|
||||
return
|
||||
@@ -181,7 +176,9 @@ export async function writeToMailbox(
|
||||
`[TeammateMailbox] Wrote message to ${recipientName}'s inbox from ${message.from}`,
|
||||
)
|
||||
} catch (error) {
|
||||
logForDebugging(`Failed to write to inbox for ${recipientName}: ${error}`)
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] Failed to write to inbox for ${recipientName}`,
|
||||
)
|
||||
logError(error)
|
||||
} finally {
|
||||
if (release) {
|
||||
@@ -204,7 +201,7 @@ export async function markMessageAsReadByIndex(
|
||||
): Promise<void> {
|
||||
const inboxPath = getInboxPath(agentName, teamName)
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] markMessageAsReadByIndex called: agentName=${agentName}, teamName=${teamName}, index=${messageIndex}, path=${inboxPath}`,
|
||||
`[TeammateMailbox] markMessageAsReadByIndex called: agentName=${agentName}, index=${messageIndex}`,
|
||||
)
|
||||
|
||||
const lockFilePath = `${inboxPath}.lock`
|
||||
@@ -256,13 +253,11 @@ export async function markMessageAsReadByIndex(
|
||||
} catch (error) {
|
||||
const code = getErrnoCode(error)
|
||||
if (code === 'ENOENT') {
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] markMessageAsReadByIndex: file does not exist at ${inboxPath}`,
|
||||
)
|
||||
logForDebugging(`[TeammateMailbox] markMessageAsReadByIndex: file missing`)
|
||||
return
|
||||
}
|
||||
logForDebugging(
|
||||
`[TeammateMailbox] markMessageAsReadByIndex FAILED for ${agentName}: ${error}`,
|
||||
`[TeammateMailbox] markMessageAsReadByIndex failed for ${agentName}`,
|
||||
)
|
||||
logError(error)
|
||||
} finally {
|
||||
@@ -296,7 +291,7 @@ export async function clearMailbox(
|
||||
if (code === 'ENOENT') {
|
||||
return
|
||||
}
|
||||
logForDebugging(`Failed to clear inbox for ${agentName}: ${error}`)
|
||||
logForDebugging(`[TeammateMailbox] Failed to clear inbox for ${agentName}`)
|
||||
logError(error)
|
||||
}
|
||||
}
|
||||
@@ -1108,7 +1103,7 @@ export function getLastPeerDmSummary(messages: Message[]): string | undefined {
|
||||
const summary =
|
||||
'summary' in block.input && typeof block.input.summary === 'string'
|
||||
? block.input.summary
|
||||
: block.input.message.slice(0, 80)
|
||||
: 'sent update'
|
||||
return `[to ${to}] ${summary}`
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user