Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions Releases/v4.0.3/.claude/hooks/lib/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,49 @@ export async function sendPush(
return false;
}
}

// ============================================================================
// Pushcut Push (fire-and-forget) — iOS rich notifications + Shortcuts bridge
// ============================================================================

function loadPushcutConfig(): { enabled: boolean; webhookUrl: string } {
try {
const paiDir = process.env.PAI_DIR || join(homedir(), '.claude');
const settingsPath = join(paiDir, 'settings.json');
if (!existsSync(settingsPath)) return { enabled: false, webhookUrl: '' };

const raw = readFileSync(settingsPath, 'utf-8')
.replace(/\$\{(\w+)\}/g, (_, key) => process.env[key] || '');
const settings = JSON.parse(raw);
const pushcut = settings.notifications?.pushcut;
return {
enabled: pushcut?.enabled ?? false,
webhookUrl: pushcut?.webhookUrl ?? '',
};
} catch {
return { enabled: false, webhookUrl: '' };
}
}

export async function sendPushcut(
message: string,
options: NotificationOptions = {}
): Promise<boolean> {
const config = loadPushcutConfig();
if (!config.enabled || !config.webhookUrl) return false;

try {
const body: Record<string, unknown> = { text: message };
if (options.title) body.title = options.title;

const response = await fetch(config.webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body),
signal: AbortSignal.timeout(5000),
});
return response.ok;
} catch {
return false;
}
}
4 changes: 4 additions & 0 deletions Releases/v4.0.3/.claude/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,10 @@
"enabled": true,
"toNumber": "${TWILIO_TO_NUMBER}"
},
"pushcut": {
"enabled": false,
"webhookUrl": "${PUSHCUT_WEBHOOK_URL}"
},
"thresholds": {
"longTaskMinutes": 5
},
Expand Down