UNPKG

framework

Version:

The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.

36 lines 1.66 kB
/** Discord rejects a message over 2000 characters outright, so a long reply is trimmed. */ export const MAX_CONTENT = 2000; /** Trim to Discord's limit, marking the cut so a truncated answer never reads as a complete one. */ function clampContent(text) { if (text.length <= MAX_CONTENT) return text; const notice = '\n… (truncated)'; return text.slice(0, MAX_CONTENT - notice.length) + notice; } /** * The one Discord *webhook* transport (#627): a single POST of one message. The two * notification posters (activity, interventions) each carried their own copy of this fetch; * their line formatters rightly stay beside the types they switch on, but the transport is * not per-feed. Deliberately not in discord/rest.ts — that module is the bot-token API * (channels, replies), and a webhook needs no token and reaches one fixed channel — though * it shares that module's clamp: Discord rejects a message over 2000 chars outright, so an * unclamped "needs you" batch would silently post nothing (#940). * * Resolves whether Discord accepted the post. A failed delivery must never throw out of a * daemon watcher, so a non-ok response and a network error both resolve `false` for the * caller to log. */ export async function postDiscordWebhook(webhook, content, fetchImpl = fetch) { try { const res = await fetchImpl(webhook, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content: clampContent(content) }), }); return res.ok; } catch { return false; } } //# sourceMappingURL=discord-webhook.js.map