UNPKG

remcode

Version:

Turn your AI assistant into a codebase expert. Intelligent code analysis, semantic search, and software engineering guidance through MCP integration.

189 lines (188 loc) 6.64 kB
/** * Workflow run status type */ export type WorkflowRunStatus = 'queued' | 'in_progress' | 'completed' | 'waiting' | 'requested' | 'pending' | 'error' | 'unknown'; /** * Workflow run conclusion type */ export type WorkflowRunConclusion = 'success' | 'failure' | 'cancelled' | 'skipped' | 'timed_out' | 'action_required' | 'neutral' | null; /** * Workflow status response interface */ export interface WorkflowStatusResponse { status: WorkflowRunStatus; conclusion?: WorkflowRunConclusion; createdAt?: string; updatedAt?: string; runId?: number; url?: string; message?: string; timedOut?: boolean; jobSummary?: { [key: string]: string; }; steps?: Array<{ name: string; status: string; conclusion?: string; }>; } /** * Workflow monitoring options */ export interface MonitoringOptions { timeoutMs?: number; pollIntervalMs?: number; detailed?: boolean; logErrors?: boolean; logToFile?: boolean; logDirectory?: string; } /** * Class for monitoring GitHub Actions workflows */ export declare class WorkflowMonitor { private githubActions; private defaultOptions; /** * Constructor * @param githubToken Optional GitHub token * @param options Default monitoring options */ constructor(githubToken?: string, options?: Partial<MonitoringOptions>); /** * Get the current status of a workflow * @param owner Repository owner * @param repo Repository name * @param workflowId Workflow ID or name * @returns Workflow status response */ getWorkflowStatus(owner: string, repo: string, workflowId: number | string): Promise<WorkflowStatusResponse>; /** * Monitor a workflow until completion or timeout * @param owner Repository owner * @param repo Repository name * @param workflowId Workflow ID or name * @param options Monitoring options * @returns Final workflow status */ monitorWorkflowCompletion(owner: string, repo: string, workflowId: number | string, options?: Partial<MonitoringOptions>): Promise<WorkflowStatusResponse>; /** * Get logs for a workflow run * @param owner Repository owner * @param repo Repository name * @param runId Run ID * @returns Workflow run logs or null if error */ getWorkflowRunLogs(owner: string, repo: string, runId: number): Promise<Buffer | null>; /** * Find workflow by name * @param owner Repository owner * @param repo Repository name * @param workflowName Workflow name or filename * @returns Workflow ID or null if not found */ findWorkflowByName(owner: string, repo: string, workflowName: string): Promise<number | null>; /** * Trigger a workflow * @param owner Repository owner * @param repo Repository name * @param workflowId Workflow ID or name * @param ref Branch or tag to run workflow on * @param inputs Workflow inputs * @returns Workflow run ID or null if error */ triggerWorkflow(owner: string, repo: string, workflowId: number | string, ref?: string, inputs?: Record<string, string>): Promise<number | null>; /** * Check if any workflow in a repository has succeeded within a time period * @param owner Repository owner * @param repo Repository name * @param workflowNamePattern Optional pattern to match workflow names * @param timeWindowMs Time window in milliseconds to check (default: 24 hours) * @returns Boolean indicating if any successful workflow was found */ hasSuccessfulWorkflow(owner: string, repo: string, workflowNamePattern?: RegExp, timeWindowMs?: number): Promise<boolean>; /** * Get all runs for a specific workflow with detailed information * @param owner Repository owner * @param repo Repository name * @param workflowId Workflow ID or name * @param limit Maximum number of runs to return * @returns Array of workflow run details */ getWorkflowRunsDetailed(owner: string, repo: string, workflowId: number | string, limit?: number): Promise<Array<WorkflowStatusResponse>>; /** * Log workflow status to a file * @param owner Repository owner * @param repo Repository name * @param workflowId Workflow ID or name * @param status Workflow status * @param logDir Directory to store logs */ private logStatusToFile; /** * Cancel a workflow run * @param owner Repository owner * @param repo Repository name * @param runId Workflow run ID * @returns Promise that resolves when cancellation is complete */ cancelWorkflowRun(owner: string, repo: string, runId: number): Promise<void>; /** * Retry a failed workflow run * @param owner Repository owner * @param repo Repository name * @param runId Workflow run ID * @param onlyFailedJobs Whether to retry only failed jobs * @returns Promise that resolves when retry is triggered */ retryWorkflowRun(owner: string, repo: string, runId: number, onlyFailedJobs?: boolean): Promise<void>; /** * Get comprehensive workflow analytics * @param owner Repository owner * @param repo Repository name * @param days Number of days to analyze * @returns Promise with workflow analytics */ getWorkflowAnalytics(owner: string, repo: string, days?: number): Promise<{ totalRuns: number; successRate: number; averageDuration: number; failureReasons: Record<string, number>; trends: { dailyRuns: Array<{ date: string; count: number; success: number; failed: number; }>; performanceOverTime: Array<{ date: string; avgDuration: number; }>; }; }>; /** * Monitor workflow health and send alerts if needed * @param owner Repository owner * @param repo Repository name * @param options Monitoring options * @returns Promise with health status */ monitorWorkflowHealth(owner: string, repo: string, options?: { maxFailureRate?: number; maxConsecutiveFailures?: number; alertOnSlowRuns?: boolean; maxDurationMinutes?: number; }): Promise<{ healthy: boolean; issues: string[]; recommendations: string[]; lastRuns: Array<{ runId: number; status: string; conclusion: string; duration?: number; }>; }>; }