/** * apps/worker — integration adapter registry (TASK-0112 §2, Phase-13 hook). * * The CALL_INTEGRATION executor looks up the adapter for the integration's * `provider` here. Phase 11 ships the registry EMPTY: every provider * resolves to `undefined` → the executor fails with the FATAL * INTEGRATION_NOT_AVAILABLE (Phase 13). Phase 13 fills the map with real * adapters (GitHub/Slack/…) without touching the executor. * * An adapter is a thin, provider-specific implementation of the executor * surface: it validates `params` against the provider's operation contract * and performs the side effect, returning the standard ActionResult. */ import type { ActionExecutor, ActionResult, AutomationRunContext, ExecutorDeps } from "./types.js"; export interface IntegrationAdapter { /** The provider name this adapter handles (the Integration.provider value). */ provider: string; execute(cfg: Record, ctx: AutomationRunContext, deps: ExecutorDeps): Promise; } /** Provider → adapter. Empty until Phase 13. */ const adapters = new Map(); /** Register an adapter (Phase 13). */ export function registerAdapter(adapter: IntegrationAdapter): void { adapters.set(adapter.provider, adapter); } /** Look up an adapter by provider name (undefined → not available). */ export function adapterFor(provider: string): IntegrationAdapter | undefined { return adapters.get(provider); } export type { ActionExecutor };