Skip to content
← 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.

FollowFork

Files

single-agent.ts

53 lines · 1.5 KB · TypeScript
/**
 * Single-agent fallback: explicit non-live no-op.
 * Records dry runs in memory only. Never pretends to be a production runner.
 * Prefer the `devin` runner for real implementer sessions.
 */
import type { AgentRunner, AgentStartResult, AgentStatusResult, AgentTask } from './types.ts'

const runs = new Map<string, { task: AgentTask; state: AgentStatusResult['state']; at: string }>()

export const singleAgentFallback: AgentRunner = {
	id: 'single-agent',
	displayName: 'Single-agent fallback (non-live no-op)',
	capabilities: ['plan', 'implement', 'review', 'verify'],
	onComplete: { mode: 'poll', pollIntervalMs: 60_000 },

	async start(task: AgentTask): Promise<AgentStartResult> {
		const runId = `solo_noop_${crypto.randomUUID().replace(/-/g, '').slice(0, 12)}`
		const at = new Date().toISOString()
		// Always no-op success locally; never calls external agents.
		runs.set(runId, {
			task,
			state: 'succeeded',
			at,
		})
		return {
			runId,
			url: undefined,
		}
	},

	async status(runId: string): Promise<AgentStatusResult> {
		const row = runs.get(runId)
		if (!row) {
			return {
				state: 'unknown',
				summary: 'single-agent is a non-live no-op; run not in local map',
			}
		}
		return {
			state: row.state,
			updatedAt: row.at,
			summary: `non-live no-op workItem=${row.task.workItemId}`,
		}
	},

	async cancel(runId: string): Promise<void> {
		const row = runs.get(runId)
		if (row) {
			row.state = 'cancelled'
			row.at = new Date().toISOString()
		}
	},
}