Skip to content

Pipeline Module

The pipeline orchestrator manages the full lifecycle of a content run: fetching, processing, video generation, and publishing.

PipelineService

run(): Promise<Result<PipelineRunStatus, PipelineError>>

Executes one complete pipeline iteration:

  1. Guard checks — rejects if already running or daily limit reached
  2. Fetch — scrapes Reddit for a suitable post (with retry)
  3. Process — branches on videoFormat config:
    • messages: LLM rewrite → MessageRenderer
    • classic: TTS → VideoService
  4. Publish — uploads to TikTok via CamoufoxTikTokProvider
  5. Persist — stores run metadata in SQLite

getCurrentStatus(): PipelineRunStatus | null

Returns the current or most recent pipeline run status.

getRecentRuns(limit: number): PipelineRunStatus[]

Returns recent runs from the database.

PipelineScheduler

Cron-based automatic scheduling:

  • Schedule: POSTING_CRON (default: every 4 hours)
  • Random jitter: 0–30 minutes added to each trigger
  • Tracks next scheduled run time

PipelineRunStatus

typescript
interface PipelineRunStatus {
  id: string;
  status: 'running' | 'complete' | 'failed';
  stage: PipelineStage;
  startedAt: string;
  completedAt: string | null;
  postId: string | null;
  postTitle: string | null;
  tiktokUrl: string | null;
  errorMessage: string | null;
  durationMs: number | null;
}

Stages

fetchingrewritingmessage_renderingsynthesizingcompositingpublishingcomplete | failed

Retry Strategy

  • Retryable stages: fetching, TTS, video generation
  • Max retries: PIPELINE_RETRY_MAX_ATTEMPTS (default: 2)
  • Backoff: delay = PIPELINE_RETRY_DELAY_MS * attempt (linear)
  • Non-retryable: DAILY_LIMIT_REACHED, ALREADY_RUNNING, NO_POSTS_AVAILABLE, CAPTCHA_DETECTED

Built with VitePress