Swadhin Biswas feat: implement mervelas cli engine, built-in tools, and reactive UI · 4/3/2026
0358986
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type { AppState } from '../state/AppState.js'
/**
* Parse `@agent-name message` syntax for direct team member messaging.
*/
export function parseDirectMemberMessage(input: string): {
recipientName: string
message: string
} | null {
const match = input.match(/^@([\w-]+)\s+(.+)$/s)
if (!match) return null
const [, recipientName, message] = match
if (!recipientName || !message) return null
const trimmedMessage = message.trim()
if (!trimmedMessage) return null
return { recipientName, message: trimmedMessage }
}
export type DirectMessageResult =
| { success: true; recipientName: string }
| {
success: false
error: 'no_team_context' | 'unknown_recipient'
recipientName?: string
}
type WriteToMailboxFn = (
recipientName: string,
message: { from: string; text: string; timestamp: string },
teamName: string,
) => Promise<void>
/**
* Send a direct message to a team member, bypassing the model.
*/
export async function sendDirectMemberMessage(
recipientName: string,
message: string,
teamContext: AppState['teamContext'],
writeToMailbox?: WriteToMailboxFn,
): Promise<DirectMessageResult> {
if (!teamContext || !writeToMailbox) {
return { success: false, error: 'no_team_context' }
}
// Find team member by name
const member = Object.values(teamContext.teammates ?? {}).find(
t => t.name === recipientName,
)
if (!member) {
return { success: false, error: 'unknown_recipient', recipientName }
}
await writeToMailbox(
recipientName,
{
from: 'user',
text: message,
timestamp: new Date().toISOString(),
},
teamContext.teamName,
)
return { success: true, recipientName }
}