/** * Dependency injection interfaces for the Ion workflow engine. * * These interfaces define the contracts that the engine requires from its * runtime environment. Concrete implementations are provided by the * platform layer (CLI, server, etc.). */ // --------------------------------------------------------------------------- // Workflow platform — messaging back to the conversation channel // --------------------------------------------------------------------------- export interface IWorkflowPlatform { /** Send a text message to the conversation channel. */ sendMessage( conversationId: string, message: string, metadata?: Record, ): Promise; /** Whether the platform supports streaming responses. */ getStreamingMode(): boolean; /** Optional structured event emission (e.g. approval requests). */ sendStructuredEvent?( conversationId: string, event: Record, ): Promise; } // --------------------------------------------------------------------------- // Workflow configuration — per-workflow settings // --------------------------------------------------------------------------- /** Configuration for a single AI provider. */ export interface ProviderConfig { /** Provider identifier (e.g. "openai", "anthropic"). */ provider: string; /** Model name (e.g. "gpt-4o", "claude-sonnet-4-20250514"). */ model?: string; /** Additional provider-specific options. */ options?: Record; } /** Folder-level command configuration. */ export interface CommandFolderConfig { /** Path to the commands folder. */ path: string; /** Whether commands are enabled by default. */ enabled?: boolean; } export interface WorkflowConfig { /** Default assistant identifier. */ assistant: string; /** Named provider configurations keyed by provider id. */ assistants: Record; /** Environment variables available to the workflow. */ envVars: Record; /** Command folder configuration. */ commands: CommandFolderConfig; /** Base git branch for the workflow (optional). */ baseBranch?: string; /** Path to documentation directory (optional). */ docsPath?: string; } // --------------------------------------------------------------------------- // Workflow store — persistence interface (will move to store/ later) // --------------------------------------------------------------------------- /** Minimal data required to create a workflow run. */ export interface CreateWorkflowRunData { workflowPath: string; workflowName: string; trigger: string; input: Record; } /** Status of a workflow run. */ export type WorkflowRunStatus = | 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'; /** A persisted workflow run record. */ export interface WorkflowRun { id: string; workflowPath: string; workflowName: string; status: WorkflowRunStatus; trigger: string; input: Record; output?: Record; error?: string; createdAt: Date; updatedAt: Date; } /** A single event within a workflow run (node start/complete/etc.). */ export interface WorkflowEvent { id: string; runId: string; nodeId?: string; type: string; data: Record; createdAt: Date; } export interface IWorkflowStore { // -- Run lifecycle ------------------------------------------------------- /** Create a new workflow run. */ createWorkflowRun(data: CreateWorkflowRunData): Promise; /** Retrieve a workflow run by id. */ getWorkflowRun(id: string): Promise; /** Update a workflow run. */ updateWorkflowRun( id: string, data: Partial, ): Promise; /** Mark a workflow run as failed. */ failWorkflowRun(id: string, error: string): Promise; /** Get the current status of a workflow run. */ getWorkflowRunStatus(id: string): Promise; // -- Events -------------------------------------------------------------- /** Record a workflow event. */ createWorkflowEvent(event: Omit): Promise; /** Get completed DAG node outputs for a run. */ getCompletedDagNodeOutputs( runId: string, ): Promise>>; // -- Active runs --------------------------------------------------------- /** Find an active (non-terminal) run for a given workflow path. */ getActiveWorkflowRunByPath( path: string, opts?: { excludeId?: string }, ): Promise; // -- Codebase ------------------------------------------------------------ /** Get a codebase record by id. */ getCodebase(id: string): Promise | null>; /** Get environment variables for a codebase. */ getCodebaseEnvVars(id: string): Promise>; // -- Resumption ---------------------------------------------------------- /** Resume a paused workflow run. */ resumeWorkflowRun(id: string): Promise; } // --------------------------------------------------------------------------- // Agent provider — creates AI agent instances // --------------------------------------------------------------------------- export interface IAgentProvider { /** Provider identifier. */ readonly providerId: string; /** Send a prompt and return the response. */ sendPrompt(prompt: string, options?: Record): Promise; } // --------------------------------------------------------------------------- // Workflow dependencies — the full DI container // --------------------------------------------------------------------------- export interface WorkflowDeps { /** Persistence store. */ store: IWorkflowStore; /** Load workflow config from a working directory. */ loadConfig(cwd: string): Promise; /** Get an agent provider by its provider id. */ getAgentProvider(providerId: string): IAgentProvider; /** Resolve a bot-level GitHub token (optional). */ resolveBotGitHubToken?(): Promise; /** Get the user-level GitHub token (optional). */ getUserGithubToken?(): Promise; /** Whether per-user GitHub token resolution is enabled (optional). */ isPerUserGitHubEnabled?(): boolean; }