Skip to content

Commit 417e2a8

Browse files
authored
Merge pull request #55 from atxp-dev/naveen/agent-push-notifications
fix(atxp): send account_id for notification matching, fix heartbeat p…
2 parents 7b94def + 465c908 commit 417e2a8

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

packages/atxp/src/commands/notifications.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ async function sendHeartbeatInstruction(webhookUrl: string, hooksToken: string):
6363
'Authorization': `Bearer ${hooksToken}`,
6464
},
6565
body: JSON.stringify({
66-
text: 'SYSTEM: Push notifications are now enabled. Save the following text EXACTLY as-is to your HEARTBEAT.md file:\n\n# Notifications\n\nWhen you receive a message from /hooks/wake, it is a system event (e.g. inbound email). Do NOT just reply in the current chat. You MUST proactively use the message tool to broadcast the notification to every connected channel. Check your available tools, find all messaging channels, and send the notification to each one individually. The goal is that the owner sees the notification regardless of which channel they are watching.',
66+
message: 'SYSTEM: Push notifications are now enabled. Save the following text EXACTLY as-is to your HEARTBEAT.md file:\n\n# Notifications\n\nWhen you receive a message from /hooks/agent, it is a system event (e.g. inbound email). Do NOT just reply in the current chat. You MUST proactively use the message tool to broadcast the notification to every connected channel. Check your available tools, find all messaging channels, and send the notification to each one individually. The goal is that the owner sees the notification regardless of which channel they are watching.',
67+
name: 'Notification System',
6768
}),
6869
});
6970
if (!res.ok) {
@@ -89,12 +90,10 @@ function getMachineId(): string | undefined {
8990
return undefined;
9091
}
9192

92-
async function getEmailUserId(): Promise<string | undefined> {
93+
async function getAccountId(): Promise<string | undefined> {
9394
const { getAccountInfo } = await import('./whoami.js');
9495
const account = await getAccountInfo();
95-
if (!account?.email) return undefined;
96-
// Extract local part: agent_xyz@atxp.email -> agent_xyz
97-
return account.email.split('@')[0];
96+
return account?.accountId;
9897
}
9998

10099
async function enableNotifications(): Promise<void> {
@@ -107,11 +106,11 @@ async function enableNotifications(): Promise<void> {
107106

108107
console.log(chalk.gray('Enabling push notifications...'));
109108

110-
// Resolve email user ID for event matching
111-
const emailUserId = await getEmailUserId();
109+
// Resolve account ID for event matching
110+
const accountId = await getAccountId();
112111

113112
const body: Record<string, string> = { machine_id: machineId };
114-
if (emailUserId) body.email_user_id = emailUserId;
113+
if (accountId) body.account_id = accountId;
115114

116115
const res = await fetch(`${NOTIFICATIONS_BASE_URL}/notifications/enable`, {
117116
method: 'POST',

0 commit comments

Comments
 (0)