import { OpenCodeClient } from "./client.js";
import { type RequestOptions } from "./async.js";
export type JobStatus = "accepted" | "running" | "input_required" | "completed" | "failed" | "cancelled" | "unknown";
export interface PendingInput {
    id: string;
    kind: "question" | "permission";
    sessionID: string;
    [key: string]: unknown;
}
export interface JobSnapshot {
    jobId?: string;
    sessionId?: string;
    messageId?: string;
    directory?: string;
    status: JobStatus;
    result?: unknown;
    text?: string;
    error?: unknown;
    inputs?: PendingInput[];
    session?: unknown;
    createdAt?: number;
    updatedAt?: number;
    expiresAt?: number;
}
export interface JobStartArgs {
    prompt: string;
    sessionId?: string;
    title?: string;
    directory?: string;
    model?: {
        providerID: string;
        modelID: string;
    };
    variant?: string;
    agent?: string;
    format?: unknown;
}
export interface JobInputResponse {
    id: string;
    kind: "question" | "permission";
    answers?: string[][];
    reply?: "once" | "always" | "reject";
    reject?: boolean;
    message?: string;
}
export interface JobServiceOptions {
    /** null creates a process-local store for isolated tests or ephemeral clients. */
    storeRoot?: string | null;
    /** Opaque identity supplied by the caller, including auth identity if used. */
    scope?: string;
    directory?: string;
    ttlMs?: number;
}
export declare function createMessageId(): string;
/** Observe a specific dispatched turn, or the latest user turn in a legacy session. */
export declare function observeSession(client: OpenCodeClient, sessionId: string, directory?: string, messageId?: string, options?: RequestOptions): Promise<JobSnapshot>;
/** Durable ownership and observation handles. Prompt execution remains owned by OpenCode. */
export declare class JobService {
    private readonly client;
    private readonly store;
    private readonly ttl;
    private readonly directory?;
    private readonly memory;
    private readonly memoryLocks;
    constructor(client: OpenCodeClient, options?: JobServiceOptions);
    private checkId;
    private prepare;
    private read;
    private save;
    private locked;
    private recoverDeadOwner;
    start(args: JobStartArgs, options?: RequestOptions): Promise<JobSnapshot>;
    private refresh;
    get(jobId: string, options?: RequestOptions): Promise<JobSnapshot>;
    list(limit?: number): Promise<JobSnapshot[]>;
    cancel(jobId: string, options?: RequestOptions): Promise<JobSnapshot>;
    update(jobId: string, responses: JobInputResponse[], options?: RequestOptions): Promise<JobSnapshot>;
}
