← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
/**
* Periodic sweep of work items. Declared enabled in package.json;
* owner enablement Approve may still be required on first publish.
*/
import { sweep } from '../core/orchestrator.ts'
import { reconcilePendingWakes } from '../events/wake-transport.ts'
/**
* Job entry: sweep the global work-item ledger.
*
* @param params - Optional dryRun / limit
* @returns Sweep summary
*
* @example
* import sweepJob from 'kody:@kody/kody-factory/jobs/sweep'
* await sweepJob({ dryRun: true })
*/
export default async function sweepJob(params?: { dryRun?: boolean; limit?: number; projectId?: string }) {
if (params?.dryRun !== true) {
// Wakes with no relay answer in time raise a wake alert. Never blocks the sweep.
try {
const pending = await reconcilePendingWakes()
if (pending.alerted.length) console.warn(`sweep: ${pending.alerted.length} wake(s) not confirmed by @kody/wake-relay; wake alert raised`)
} catch (error) {
console.error(`sweep: pending wake reconcile failed: ${error instanceof Error ? error.message.slice(0, 200) : 'error'}`)
}
}
return sweep({
dryRun: params?.dryRun === true,
projectId: typeof params?.projectId === 'string' ? params.projectId : undefined,
limit: typeof params?.limit === 'number' ? params.limit : undefined,
})
}