← Public packages
@kentcdodds/sentry-triage
Sentry triage wakes Cole (Grok Bot) per issue: one active wake per repo (lease + queue), loop-safe Discord. Cole may spawn Cursor for isolated repo work.
src/probe-wake-webhook.ts
47 lines · 1.6 KB · TypeScriptimport { packageStorage } from 'kody:runtime'
import { WAKE_WEBHOOK_STORAGE_KEY } from './configure-wake-webhook.ts'
/** Probe the stored Cole wake webhook without returning its credential URL. */
export default async function probeWakeWebhook(
input: { live?: boolean; prompt?: string } = {},
) {
const stored = await packageStorage().get(WAKE_WEBHOOK_STORAGE_KEY)
if (typeof stored !== 'string' || !stored.startsWith('https://')) {
return { ok: false as const, error: 'missing packageStorage wake URL' }
}
let host = ''
try {
host = new URL(stored).host
} catch {
return { ok: false as const, error: 'stored wake URL is invalid' }
}
const live = input.live === true
const prompt =
typeof input.prompt === 'string' && input.prompt.trim()
? input.prompt.trim()
: live
? 'sentry-triage wake probe — reply with one word ACK and stop.'
: 'sentry-triage wake dryRun probe'
const response = await fetch(stored, {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ bot: 'cole', prompt, dryRun: !live }),
})
const text = await response.text()
let body: unknown = null
try {
body = text ? JSON.parse(text) : null
} catch {
body = { raw: text.slice(0, 500) }
}
const root = body && typeof body === 'object' ? (body as Record<string, unknown>) : null
return {
ok: response.ok,
host,
httpStatus: response.status,
bodyType: body === null ? 'null' : Array.isArray(body) ? 'array' : typeof body,
bodyKeys: root ? Object.keys(root).slice(0, 30) : [],
bodyPreview: JSON.stringify(body).slice(0, 800),
live,
}
}