export declare const DEFAULT_APP_BUILDING_IMAGE_REF = "ghcr.io/replayio/app-building:latest";
export interface AppBuildingMachineState {
    machineId: string;
    instanceId: string | null;
    volumeId: string | null;
    region: string;
}
export interface AppBuildingWorkerStatus {
    state: 'starting' | 'idle' | 'processing' | 'stopping' | 'stopped';
    containerName: string;
    pushBranch: string;
    pendingTasks: number;
    tasksProcessed: number;
    totalCost: number;
    iteration: number;
    detachRequested: boolean;
    revision: string;
    lastActivityAt: string;
    /** Detected dev-server port inside the container, exposed via /preview/. */
    previewPort?: number | null;
    /** ISO timestamp of when the dev-server port was last detected. */
    previewDetectedAt?: string | null;
}
export interface AppBuildingOffsetBatch {
    items: string[];
    nextOffset: number;
}
interface FlyVolumeInfo {
    id: string;
    attached_machine_id: string | null;
}
export interface FlyMachineInfo {
    id: string;
    instance_id?: string | null;
    state?: string;
    region?: string;
}
export declare function infisicalLogin(clientId: string, clientSecret: string): Promise<string>;
export declare function workerHeaders(instanceId: string | null): Record<string, string>;
export declare function listFlyVolumes(appName: string, token: string): Promise<FlyVolumeInfo[]>;
export declare function setInfisicalGlobalSecret(options: {
    token: string;
    projectId: string;
    environment: string;
    name: string;
    value: string;
}): Promise<void>;
export declare function destroyFlyMachine(appName: string, token: string, machineId: string, volumeId?: string | null): Promise<void>;
export declare function createAppBuildingMachine(options: {
    appName: string;
    token: string;
    imageRef: string;
    env: Record<string, string>;
    machineName: string;
}): Promise<AppBuildingMachineState>;
export declare function getFlyMachine(appName: string, token: string, machineId: string): Promise<FlyMachineInfo>;
export declare function waitForFlyMachineStarted(appName: string, token: string, machineId: string, timeoutMs?: number): Promise<void>;
export declare function waitForWorkerReady(baseUrl: string, instanceId: string | null, timeoutMs?: number): Promise<AppBuildingWorkerStatus>;
export declare function fetchAppBuildingStatus(baseUrl: string, instanceId: string | null): Promise<AppBuildingWorkerStatus>;
export declare function fetchAppBuildingLogs(baseUrl: string, instanceId: string | null, offset?: number): Promise<AppBuildingOffsetBatch>;
export interface FlyLogsEntry {
    instance?: string;
    level?: string;
    message?: string;
    region?: string;
    timestamp?: string;
    meta?: Record<string, unknown>;
}
export interface FlyLogsPage {
    entries: FlyLogsEntry[];
    nextToken: string;
}
export declare function fetchFlyLogsPage(appName: string, token: string, options?: {
    nextToken?: string;
    startTime?: string | null;
    region?: string | null;
    instanceId?: string | null;
    signal?: AbortSignal;
}): Promise<FlyLogsPage>;
/**
 * Fetch logs for an app-building machine using either an opaque Fly cursor
 * (`next_token`) or a `start_time` ISO anchor. `machineId` is passed as the
 * `instance` query param (Fly's logs API actually filters by machine ID, not
 * instance_id). When a machine filter is set, region is forced null — machine
 * IDs are globally unique.
 */
export declare function fetchFlyLogsSince(appName: string, token: string, options?: {
    machineId?: string | null;
    cursor?: string | null;
    startTime?: string | null;
    signal?: AbortSignal;
}): Promise<FlyLogsPage>;
export declare function pollFlyLogs(appName: string, token: string, options?: {
    region?: string | null;
    instanceId?: string | null;
    maxAttempts?: number;
    maxPages?: number;
    initialDelayMs?: number;
    maxDelayMs?: number;
}): Promise<FlyLogsEntry[]>;
export declare function formatFlyLogEntry(entry: FlyLogsEntry): string;
/**
 * A single subtask extracted from an add-task.ts invocation in the worker logs.
 * Subtasks use the convention `"Name: description"` — the name becomes the card
 * title, the full string is the card prompt.
 */
export interface ParsedAddTaskSubtask {
    /** Full subtask string, including the "Name:" prefix. */
    raw: string;
    /** Portion before the first colon — used as the card title. */
    name: string;
    /** Portion after the first colon — used as the card description. */
    description: string;
    /** Skill file the parent task is attached to (e.g. skills/tasks/build/writeApp.md). */
    skill: string;
    /** Optional app name associated with the task. */
    app: string | null;
}
/**
 * Parse an `add-task.ts` tool invocation out of a Fly log message. The worker
 * emits lines shaped like:
 *   [2026-04-17T01:23:15Z] {"type":"tool","tool":"$ npx tsx /repo/scripts/add-task.ts <<'EOF'\n[...]\nEOF"}
 * Returns all subtasks across all tasks in the HEREDOC, or `null` if the line
 * isn't an add-task invocation.
 */
export declare function parseAddTaskLogMessage(message: string): ParsedAddTaskSubtask[] | null;
export declare const DEFAULT_FLY_LOG_BUFFER_LIMIT = 500;
/**
 * Merge a fresh Fly logs page into an existing ring buffer, dedup by formatted
 * string (effectively (timestamp, instance, message) tuple after formatting),
 * and return the delta + bounded buffer + advanced timestamp.
 */
export declare function mergeFlyLogDelta(existingBuffer: readonly string[], entries: readonly FlyLogsEntry[], options?: {
    lastTimestamp?: string | null;
    bufferLimit?: number;
}): {
    newFormatted: string[];
    mergedBuffer: string[];
    latestTimestamp: string | null;
};
export declare function fetchAppBuildingEvents(baseUrl: string, instanceId: string | null, offset?: number): Promise<AppBuildingOffsetBatch>;
export declare function postAppBuildingMessage(baseUrl: string, instanceId: string | null, prompt: string): Promise<void>;
export declare function postAppBuildingStop(baseUrl: string, instanceId: string | null): Promise<void>;
export {};
//# sourceMappingURL=app-building-remote.d.ts.map