/** * 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 { 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}` } } }