Skip to main content

Configuration types

RefrainConfig

Alias for LocalConfig. See Local Execution for full property table.
interface RefrainConfig {
  ai: AIModelConfig;
  headless?: boolean;
  loggerFactory?: LoggerFactory;
  debug?: boolean;
  apiKey?: string;
  locale?: "en" | "ja";
  stealth?: boolean;
  proxy?: string | { server: string; username?: string; password?: string };
}

AIModelConfig

interface AIModelConfig {
  modelId: string;
  provider: ModelProvider;
  apiKey?: string;
  baseURL?: string;
  azureResourceName?: string;
  azureApiVersion?: string;
  bedrockRegion?: string;
  bedrockAccessKeyId?: string;
  bedrockSecretAccessKey?: string;
  bedrockSessionToken?: string;
  vertexProject?: string;
  vertexLocation?: string;
  modelOverrides?: Partial<Record<ModelPurpose, string>>;
}

ModelProvider

type ModelProvider =
  | "anthropic"
  | "openai"
  | "openai-compatible"
  | "google"
  | "azure"
  | "bedrock"
  | "vertex";

ModelPurpose

type ModelPurpose =
  | "exploration"
  | "exploration-light"
  | "selector"
  | "extraction"
  | "review"
  | "fallback"
  | "vision";

ExecuteOptions

See Local Execution for full property table.

ExecutionStrategy

interface ExecutionStrategy {
  maxRetries: number;
  changeTimeouts: number[];
  finalRetryStabilizeMs: number;
  domStabilityMs: number;
}

Result types

ExecutionReport

interface ExecutionReport {
  runbookTitle: string;
  startUrl: string;
  totalSteps: number;
  executed: number;
  succeeded: number;
  failed: number;
  skipped: number;
  aborted: boolean;
  steps: StepExecutionResult[];
  totalDurationMs: number;
  memoryCollections?: Record<string, number>;
  downloadedFiles?: string[];
  videoPaths?: string[];
  aiMetrics?: AIMetricsSummary;
}

StepExecutionResult

interface StepExecutionResult {
  ordinal: number;
  description: string;
  status: StepStatus;
  durationMs: number;
  error?: string;
  capturedValues?: Record<string, string>;
  actionType?: string;

  // Conditional & loop fields
  conditionSkipped?: boolean;
  loopIterations?: number;
  subStepResults?: StepExecutionResult[][];
  branchMatch?: string;
  forEachItemCount?: number;

  // Self-healing fields
  retryCount?: number;
  retryDetails?: StepRetryDetail[];
  failureCategory?: FailureCategory;

  // Output fields
  extractedData?: string;
  downloadedFile?: string;
  exportedFile?: string;

  // Diagnostics
  diagnostics?: StepDiagnostics;

  // Telemetry
  resolveMethod?: "cache" | "deterministic" | "ai" | "scroll" | "vision" | "agent" | null;
  deterministicMatchType?: string;
  deterministicConfidence?: number;
  contextChunksUsed?: number;
  failureHintsProvided?: boolean;
  workingMemoryTokens?: number;
  snapshotElementCount?: number;
}

StepStatus

type StepStatus = "success" | "failed" | "skipped";

StepDiagnostics

Attached to failed steps with detailed failure information:
interface StepDiagnostics {
  lastSnapshotPreview?: string;
  failureHistory?: string[];
  lastAiResponseText?: string;
  recoveryHint?: string;
  deterministicResolveResult?: string;
  visionFallbackResult?: {
    annotationCount: number;
    reasoning: string;
    success: boolean;
  };
  agentFallbackResult?: {
    strategy: string;
    analysis: string;
    reasoning: string;
    success: boolean;
  };
  validationWarnings?: string[];
  validationErrors?: string[];
  executionStrategy?: ExecutionStrategy;
  stepAction?: { type: string; selector?: any; value?: string; url?: string };
  stepUrl?: string;
}

BatchExecutionReport

interface BatchExecutionReport {
  runbookTitle: string;
  totalRows: number;
  succeeded: number;
  failed: number;
  rows: {
    rowIndex: number;
    rowLabel: string;
    report: ExecutionReport;
  }[];
  totalDurationMs: number;
}

Runbook types

ParsedRunbook

Inferred from the Zod schema. See Runbook YAML for field descriptions.

ParsedStep / StepAction / Selector

See Actions, Selectors.

ActionType

type ActionType =
  | "click" | "input" | "select" | "navigate"
  | "scroll" | "wait" | "hover" | "extract"
  | "download" | "export" | "memory" | "key";

RiskLevel

type RiskLevel = "low" | "medium" | "high";

VariableSource

type VariableSource = "prompt" | "fixed" | "context" | "env" | "expression" | "data";

CaptureStrategy

type CaptureStrategy = "snapshot" | "url" | "ai" | "expression" | "evaluate";

Logger types

Logger

interface Logger {
  step(message: string): void;
  success(message: string): void;
  error(message: string): void;
  warn(message: string): void;
  info(message: string): void;
  debug(message: string): void;
}

LoggerFactory

interface LoggerFactory {
  createLogger(): Logger;
  createSpinner(): SpinnerLike;
}

SpinnerLike

interface SpinnerLike {
  start(message: string): void;
  stop(message: string): void;
}

CallbackLogger

Custom logger that forwards all messages to a callback:
import { CallbackLogger } from "@refrainai/sdk";

const logger = new CallbackLogger((level, message) => {
  // level: "step" | "success" | "error" | "warn" | "info" | "debug"
  console.log(`[${level}] ${message}`);
});

LogLevel

type LogLevel = "step" | "success" | "error" | "warn" | "info" | "debug";

Utility types

ResolveVariablesInput

interface ResolveVariablesInput {
  secrets?: Record<string, string>;
  contextMarkdown: string;
}

ResolveVariablesResult

interface ResolveVariablesResult {
  variables: Record<string, string>;
  secrets: Record<string, string>;
}

Plan types

Plan

interface Plan {
  tier: PlanTier;
  limits: PlanLimits;
  features: PlanFeatures;
}

PlanTier

type PlanTier = "community" | "pro" | "team" | "business" | "enterprise";

PlanLimitError / PlanFeatureError

Thrown when a plan limit or feature gate is hit:
try {
  await client.execute(runbook, options);
} catch (e) {
  if (e instanceof PlanLimitError) {
    console.error(`Limit exceeded: ${e.limitType}`);
  }
  if (e instanceof PlanFeatureError) {
    console.error(`Feature not available: ${e.message}`);
  }
}

Other types

TypeDescription
DataStoreInterface for memory data collection
DataAggregatorInterface for data aggregation queries
InMemoryDataStoreBuilt-in in-memory data store
DownloadManagerFile download and CSV merge utility
DownloadRecordDownload metadata
AggregateOperation"sum" | "count" | "concat" | "min" | "max" | "avg" | "unique_count"
Locale"en" | "ja"
MeteringCollectorUsage metering interface
NoopMeteringCollectorNo-op metering implementation