← Public packages
@kentcdodds/friction-log
Qualify and file friction papercuts to GitHub (any owner/repo) or wake Patch for Kody packages; daily sweep of kody-hq/kody friction issues.
src/record-outcome.ts
36 lines · 1.1 KB · TypeScriptimport { denverDayKey, truncate } from './shared.ts'
import { recordOutcome as writeOutcome } from './storage.ts'
export type RecordOutcomeInput = {
outcome: 'fixed' | 'skipped' | 'closed' | 'failed'
summary: string
prUrl?: string
agentId?: string
}
const allowedOutcomes = new Set(['fixed', 'skipped', 'closed', 'failed'])
/**
* Final report from the friction-log Cloud Agent.
*/
export default async function recordOutcome(input: RecordOutcomeInput) {
const outcome = String(input?.outcome || '')
if (!allowedOutcomes.has(outcome)) {
throw new Error(`outcome must be one of ${[...allowedOutcomes].join(', ')}`)
}
const summary = truncate(input?.summary, 600).trim()
if (!summary) throw new Error('summary is required')
const agentId = String(input?.agentId || '').trim()
if (!agentId) throw new Error('agentId is required')
const record = {
agent_id: agentId,
day: denverDayKey(),
outcome,
summary,
pr_url: input.prUrl ? String(input.prUrl) : null,
completed_at: new Date().toISOString(),
}
await writeOutcome(record)
return { ok: true, ...record }
}