← Public packages
@kentcdodds/kody-issue-triage
Loop-safe triage for Kody run errors and fleet package-runtime error-rate elevations. Wakes Cole (Grok Bot) to decide; Cursor agents only when Cole escalates.
src/configure-wake-webhook.ts
30 lines · 1.1 KB · TypeScriptimport { packageStorage } from 'kody:runtime'
export const WAKE_WEBHOOK_STORAGE_KEY = 'grokBotWakeWebhookUrl'
/**
* Store the minted `@kentcdodds/grok-bot` `wake` webhook URL in package
* storage so jobs/subscriptions can POST without a secret host approval.
* Prefer this after `webhookUrlMint({ webhookName: 'wake' })`.
*
* @param input.url - Full minted ingress URL (credential; not logged)
* @returns Whether the URL was stored
*
* @example
* import configureWakeWebhook from 'kody:@kentcdodds/kody-issue-triage/configure-wake-webhook'
* await configureWakeWebhook({ url: minted.webhook.url })
*/
export default async function configureWakeWebhook(input: { url?: string } = {}) {
const url = typeof input.url === 'string' ? input.url.trim() : ''
if (!url.startsWith('https://')) {
return { ok: false as const, error: 'url must be an https minted webhook URL' }
}
let host = ''
try {
host = new URL(url).host
} catch {
return { ok: false as const, error: 'url is not a valid URL' }
}
await packageStorage().set(WAKE_WEBHOOK_STORAGE_KEY, url)
return { ok: true as const, host, key: WAKE_WEBHOOK_STORAGE_KEY }
}