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

dispatch.ts

24 lines · 867 B · TypeScript
/**
 * Dispatch a routed signal to its destination.
 */
import type { DestinationKind } from '../routing/types.ts'
import type { DispatchResult, PromptContext } from './types.ts'
import { dispatchBoardCard } from './board-card.ts'
import { dispatchGrokWake } from './grok-wake.ts'

export async function dispatch(
	destination: DestinationKind,
	ctx: PromptContext,
	opts: { templateId?: string | null; shadow?: boolean; dryRun?: boolean },
): Promise<DispatchResult> {
	switch (destination) {
		case 'board-card':
			return dispatchBoardCard(ctx, opts)
		case 'grok-wake':
			return dispatchGrokWake(ctx, { templateId: opts.templateId, dryRun: opts.dryRun })
		case 'none':
			return { destination: 'none', ok: true, detail: 'No action taken' }
		default:
			return { destination: String(destination), ok: false, detail: `Unknown destination: ${destination}` }
	}
}