import type { AgentRun, AgentRunAttempt, AttemptId, ActionId, ActorMetadata, ApprovalId, AssetId, ChildTaskRecord, EventEnvelope, EventCursor, GetThreadEventsResponse, GetThreadHistoryResponse, Item, ItemId, ProjectionStatus, QueuedTurn, QueuedTurnId, RunExecutionMode, RunId, RunPhaseName, RunStatus, RunWaitReason, RoutingDecisionRecord, ServerEvent, ThreadAsset, ThreadDetail, NodeContract, PlanProjection, PlanTodo, PromptContentPart, ThreadId, ThreadListItem, ThreadMetadata, ThreadMode, ThreadProjectionKind, ThreadProjectionSnapshot, WorkerKind, WorkerLease, WorkerLeaseStatus, Turn, TurnId, TurnStatus, VerdictRecord, StepId } from "@best-agent/protocol";
export interface ThreadStoreOptions {
    storageRoot: string;
}
export interface CreateThreadInput {
    cwd: string;
    mode?: ThreadMode;
    title?: string;
}
export interface CreateTurnInput {
    threadId: ThreadId;
}
export interface CreateRunInput {
    executionMode?: RunExecutionMode;
    graphId?: string;
    graphRevision?: number;
    nodeId?: string;
    phaseIndex?: number;
    phaseName?: RunPhaseName;
    threadId: ThreadId;
    turnId: TurnId;
    waitReason?: RunWaitReason;
}
export interface CreateRunAttemptInput {
    ownerId: string;
    ownerHostId: string;
    runId: RunId;
}
export interface ClaimRunAttemptInput {
    ownerId: string;
    ownerHostId: string;
    staleBefore: string;
    turnId: TurnId;
}
export interface UpdateRunInput {
    endedAt?: string;
    executionMode?: RunExecutionMode;
    graphId?: string;
    graphRevision?: number;
    nodeId?: string;
    phaseIndex?: number;
    phaseName?: RunPhaseName;
    phaseStartedAt?: string;
    status?: RunStatus;
    waitReason?: RunWaitReason;
}
export interface UpdateRunAttemptInput {
    endedAt?: string;
    lastHeartbeatAt?: string;
    leaseEpoch?: number;
    restartCount?: number;
    stallCount?: number;
    status?: AgentRunAttempt["status"];
    takeoverCount?: number;
}
export declare const REPLAY_TOOL_INPUT_ASSET_CONTENT_TYPE = "application/vnd.best-agent.replay-tool-input+json";
export interface ExpectedRunAttemptGuard {
    attemptId: AttemptId;
    ownerId: string;
    turnId: TurnId;
}
export interface AppendItemsInput {
    expectedRunAttempts?: ExpectedRunAttemptGuard[];
}
export interface UpdateTurnStatusInput {
    expectedRunAttempt?: Omit<ExpectedRunAttemptGuard, "turnId">;
}
export interface UpdateRunInputOptions {
    expectedRunAttempt?: Omit<ExpectedRunAttemptGuard, "turnId">;
}
export interface UpdateRunAttemptInputOptions {
    expectLatest?: boolean;
    expectedOwnerId?: string;
}
export interface PutAssetInputOptions {
    expectedRunAttempt?: Omit<ExpectedRunAttemptGuard, "turnId">;
}
export interface EnqueueTurnInput {
    activeSkills?: string[];
    agentProfile?: string;
    actor?: ActorMetadata;
    prompt: string;
    promptContent?: PromptContentPart[];
    threadId: ThreadId;
}
export interface ForkThreadInput {
    threadId: ThreadId;
    fromItemId?: ItemId;
    title?: string;
}
export interface UpdateThreadMetadataInput {
    metadata?: ThreadMetadata;
    mode?: ThreadMode;
    title?: string;
}
export interface ListThreadsInput {
    forkedFromThreadId?: ThreadId;
    includeArchived?: boolean;
    limit?: number;
}
export interface ReadHistoryInput {
    threadId: ThreadId;
    limit?: number;
    beforeItemId?: ItemId;
}
export interface ReadEventsInput {
    threadId: ThreadId;
    after?: EventCursor;
    afterSequence?: number;
    limit?: number;
}
export interface PutAttachmentInput {
    threadId: ThreadId;
    turnId?: TurnId;
    name: string;
    contentType?: string;
    data: Buffer | string;
}
export interface PutArtifactInput {
    threadId: ThreadId;
    turnId?: TurnId;
    name: string;
    contentType?: string;
    data: Buffer | string;
}
export interface SaveProjectionSnapshotInput {
    kind: ThreadProjectionKind;
    schemaVersion?: number;
    sequence: number;
    snapshot: ThreadMetadata;
    status?: ProjectionStatus;
    threadId: ThreadId;
}
export interface CreateWorkerLeaseInput {
    attemptId?: AttemptId;
    kind: WorkerKind;
    ownerHostId: string;
    runId: RunId;
    stepId: StepId;
    threadId: ThreadId;
    turnId: TurnId;
}
export interface UpdateWorkerLeaseInput {
    endedAt?: string;
    leaseEpoch?: number;
    ownerHostId?: string;
    status?: WorkerLeaseStatus;
}
export interface RunCheckpoint {
    actionId?: ActionId;
    approvalId?: ApprovalId;
    attemptId?: AttemptId;
    completedAt?: string;
    createdAt: string;
    graphId?: string;
    graphRevision?: number;
    id: StepId;
    kind: "action-wait" | "approval-wait" | "phase-transition" | "provider-request" | "subagent-spawn" | "subagent-join" | "tool-dispatch" | "tool-output" | "verification-verdict" | "response-output";
    nodeId?: string;
    payload: ThreadMetadata;
    runId: RunId;
    turnId: TurnId;
    updatedAt: string;
}
export interface SaveRunCheckpointInput {
    actionId?: ActionId;
    approvalId?: ApprovalId;
    attemptId?: AttemptId;
    graphId?: string;
    graphRevision?: number;
    kind: RunCheckpoint["kind"];
    nodeId?: string;
    payload: ThreadMetadata;
    runId: RunId;
    turnId: TurnId;
}
export interface UpdateRunCheckpointInput {
    completedAt?: string;
    graphId?: string;
    graphRevision?: number;
    nodeId?: string;
    payload?: ThreadMetadata;
}
export interface SaveRunCheckpointOptions {
    expectedRunAttempt?: Omit<ExpectedRunAttemptGuard, "turnId">;
}
export interface UpdateRunCheckpointOptions {
    expectedRunAttempt?: Omit<ExpectedRunAttemptGuard, "turnId">;
}
export interface ThreadPlanNodeRecord {
    contract?: NodeContract;
    graphId: string;
    graphRevision: number;
    nodeId: string;
    position: number;
    todo: PlanTodo;
}
export interface ThreadPlanState {
    nodes: ThreadPlanNodeRecord[];
    plan: PlanProjection;
}
export interface SavePlanStateInput {
    nodeContracts?: NodeContract[];
    plan: PlanProjection;
}
export interface AppendThreadVerdictInput {
    threadId: ThreadId;
    verdict: VerdictRecord;
}
export interface ThreadStore {
    close?(): void | Promise<void>;
    createThread(input: CreateThreadInput): Promise<ThreadDetail>;
    forkThread(input: ForkThreadInput): Promise<ThreadDetail>;
    getThread(threadId: ThreadId): Promise<ThreadDetail | null>;
    listThreads(input?: ListThreadsInput): Promise<ThreadListItem[]>;
    createTurn(input: CreateTurnInput): Promise<Turn>;
    createRun(input: CreateRunInput): Promise<AgentRun>;
    createRunAttempt(input: CreateRunAttemptInput): Promise<AgentRunAttempt>;
    claimRunAttempt(input: ClaimRunAttemptInput): Promise<AgentRunAttempt | null>;
    enqueueTurn(input: EnqueueTurnInput): Promise<QueuedTurn>;
    getTurn(turnId: TurnId): Promise<Turn | null>;
    getRun(runId: RunId): Promise<AgentRun | null>;
    getRunByTurn(turnId: TurnId): Promise<AgentRun | null>;
    getLatestTurn(threadId: ThreadId): Promise<Turn | null>;
    listRuns(threadId: ThreadId): Promise<AgentRun[]>;
    listRunAttempts(runId: RunId): Promise<AgentRunAttempt[]>;
    listTurns(threadId: ThreadId): Promise<Turn[]>;
    listQueuedTurns(threadId: ThreadId): Promise<QueuedTurn[]>;
    dequeueTurn(threadId: ThreadId, queuedTurnId: QueuedTurnId): Promise<QueuedTurn>;
    claimNextQueuedTurn(threadId: ThreadId): Promise<QueuedTurn | null>;
    updateQueuedTurnStatus(queuedTurnId: QueuedTurnId, status: QueuedTurn["status"]): Promise<QueuedTurn>;
    appendItems(items: Item[], input?: AppendItemsInput): Promise<void>;
    appendEvent(event: ServerEvent): EventEnvelope;
    listItems(threadId: ThreadId): Promise<Item[]>;
    listItemsForTurn?(threadId: ThreadId, turnId: TurnId): Promise<Item[]>;
    readHistory(input: ReadHistoryInput): Promise<GetThreadHistoryResponse>;
    readEvents(input: ReadEventsInput): Promise<GetThreadEventsResponse>;
    getLatestEventSequence(threadId: ThreadId): Promise<number>;
    saveProjectionSnapshot(input: SaveProjectionSnapshotInput): Promise<ThreadProjectionSnapshot>;
    listProjectionSnapshots(threadId: ThreadId): Promise<ThreadProjectionSnapshot[]>;
    getPlanState(threadId: ThreadId): Promise<ThreadPlanState | null>;
    savePlanState(input: SavePlanStateInput): Promise<ThreadPlanState>;
    appendVerdictRecord(input: AppendThreadVerdictInput): Promise<VerdictRecord>;
    getEffectiveVerdict(threadId: ThreadId, nodeId: string): Promise<VerdictRecord | null>;
    getEffectiveVerdicts(threadId: ThreadId, nodeIds: string[]): Promise<Map<string, VerdictRecord>>;
    listVerdictRecords(threadId: ThreadId, nodeId?: string): Promise<VerdictRecord[]>;
    createWorkerLease(input: CreateWorkerLeaseInput): Promise<WorkerLease>;
    updateWorkerLease(stepId: StepId, input: UpdateWorkerLeaseInput): Promise<WorkerLease>;
    listWorkerLeases(threadId: ThreadId, limit?: number): Promise<WorkerLease[]>;
    listChildTaskRecords(threadId: ThreadId, limit?: number): Promise<ChildTaskRecord[]>;
    listRoutingRecords(threadId: ThreadId, limit?: number): Promise<RoutingDecisionRecord[]>;
    saveRunCheckpoint(input: SaveRunCheckpointInput, options?: SaveRunCheckpointOptions): Promise<RunCheckpoint>;
    getPendingRunCheckpointByTurn(turnId: TurnId): Promise<RunCheckpoint | null>;
    getPendingRunCheckpointByApprovalId(approvalId: ApprovalId): Promise<RunCheckpoint | null>;
    getPendingRunCheckpointByActionId(actionId: ActionId): Promise<RunCheckpoint | null>;
    updateRunCheckpoint(checkpointId: StepId, input: UpdateRunCheckpointInput, options?: UpdateRunCheckpointOptions): Promise<RunCheckpoint>;
    updateTurnStatus(turnId: TurnId, status: TurnStatus, completedAt?: string, input?: UpdateTurnStatusInput): Promise<Turn>;
    updateRun(runId: RunId, input: UpdateRunInput, options?: UpdateRunInputOptions): Promise<AgentRun>;
    updateRunAttempt(attemptId: AttemptId, input: UpdateRunAttemptInput, options?: UpdateRunAttemptInputOptions): Promise<AgentRunAttempt>;
    updateThreadMetadata(threadId: ThreadId, input: UpdateThreadMetadataInput): Promise<ThreadDetail>;
    archiveThread(threadId: ThreadId): Promise<ThreadDetail>;
    unarchiveThread(threadId: ThreadId): Promise<ThreadDetail>;
    purgeThread(threadId: ThreadId): Promise<void>;
    putAttachment(input: PutAttachmentInput, options?: PutAssetInputOptions): Promise<ThreadAsset>;
    putArtifact(input: PutArtifactInput, options?: PutAssetInputOptions): Promise<ThreadAsset>;
    readAssetData(assetId: AssetId): Promise<Buffer | undefined>;
    deleteReplayToolInputAsset(assetId: AssetId): Promise<void>;
    listThreadAssets(threadId: ThreadId): Promise<ThreadAsset[]>;
    pruneThreadScratch(threadId: ThreadId): Promise<void>;
    getThreadPaths(threadId: ThreadId): ThreadPaths;
}
export interface ThreadPaths {
    threadDir: string;
    artifactsDir: string;
    scratchDir: string;
    memoryDir: string;
}
export declare class LocalThreadStore implements ThreadStore {
    #private;
    constructor(options: ThreadStoreOptions);
    close(): void;
    createThread(input: CreateThreadInput): Promise<ThreadDetail>;
    forkThread(input: ForkThreadInput): Promise<ThreadDetail>;
    getThread(threadId: ThreadId): Promise<ThreadDetail | null>;
    listThreads(input?: ListThreadsInput): Promise<ThreadListItem[]>;
    createTurn(input: CreateTurnInput): Promise<Turn>;
    createRun(input: CreateRunInput): Promise<AgentRun>;
    createRunAttempt(input: CreateRunAttemptInput): Promise<AgentRunAttempt>;
    claimRunAttempt(input: ClaimRunAttemptInput): Promise<AgentRunAttempt | null>;
    enqueueTurn(input: EnqueueTurnInput): Promise<QueuedTurn>;
    getTurn(turnId: TurnId): Promise<Turn | null>;
    getRun(runId: RunId): Promise<AgentRun | null>;
    getRunByTurn(turnId: TurnId): Promise<AgentRun | null>;
    getLatestTurn(threadId: ThreadId): Promise<Turn | null>;
    listRuns(threadId: ThreadId): Promise<AgentRun[]>;
    listRunAttempts(runId: RunId): Promise<AgentRunAttempt[]>;
    listTurns(threadId: ThreadId): Promise<Turn[]>;
    listQueuedTurns(threadId: ThreadId): Promise<QueuedTurn[]>;
    dequeueTurn(threadId: ThreadId, queuedTurnId: QueuedTurnId): Promise<QueuedTurn>;
    claimNextQueuedTurn(threadId: ThreadId): Promise<QueuedTurn | null>;
    updateQueuedTurnStatus(queuedTurnId: QueuedTurnId, status: QueuedTurn["status"]): Promise<QueuedTurn>;
    appendItems(items: Item[], input?: AppendItemsInput): Promise<void>;
    appendEvent(event: ServerEvent): EventEnvelope;
    listItems(threadId: ThreadId): Promise<Item[]>;
    listItemsForTurn(threadId: ThreadId, turnId: TurnId): Promise<Item[]>;
    readHistory(input: ReadHistoryInput): Promise<GetThreadHistoryResponse>;
    readEvents(input: ReadEventsInput): Promise<GetThreadEventsResponse>;
    getLatestEventSequence(threadId: ThreadId): Promise<number>;
    saveProjectionSnapshot(input: SaveProjectionSnapshotInput): Promise<ThreadProjectionSnapshot>;
    listProjectionSnapshots(threadId: ThreadId): Promise<ThreadProjectionSnapshot[]>;
    getPlanState(threadId: ThreadId): Promise<ThreadPlanState | null>;
    savePlanState(input: SavePlanStateInput): Promise<ThreadPlanState>;
    appendVerdictRecord(input: AppendThreadVerdictInput): Promise<VerdictRecord>;
    listVerdictRecords(threadId: ThreadId, nodeId?: string): Promise<VerdictRecord[]>;
    getEffectiveVerdict(threadId: ThreadId, nodeId: string): Promise<VerdictRecord | null>;
    getEffectiveVerdicts(threadId: ThreadId, nodeIds: string[]): Promise<Map<string, VerdictRecord>>;
    createWorkerLease(input: CreateWorkerLeaseInput): Promise<WorkerLease>;
    updateWorkerLease(stepId: StepId, input: UpdateWorkerLeaseInput): Promise<WorkerLease>;
    listWorkerLeases(threadId: ThreadId, limit?: number): Promise<WorkerLease[]>;
    listChildTaskRecords(threadId: ThreadId, limit?: number): Promise<ChildTaskRecord[]>;
    listRoutingRecords(threadId: ThreadId, limit?: number): Promise<RoutingDecisionRecord[]>;
    saveRunCheckpoint(input: SaveRunCheckpointInput, options?: SaveRunCheckpointOptions): Promise<RunCheckpoint>;
    getPendingRunCheckpointByTurn(turnId: TurnId): Promise<RunCheckpoint | null>;
    getPendingRunCheckpointByApprovalId(approvalId: ApprovalId): Promise<RunCheckpoint | null>;
    getPendingRunCheckpointByActionId(actionId: ActionId): Promise<RunCheckpoint | null>;
    updateRunCheckpoint(checkpointId: StepId, input: UpdateRunCheckpointInput, options?: UpdateRunCheckpointOptions): Promise<RunCheckpoint>;
    updateTurnStatus(turnId: TurnId, status: TurnStatus, completedAt?: string, input?: UpdateTurnStatusInput): Promise<Turn>;
    updateRun(runId: RunId, input: UpdateRunInput, options?: UpdateRunInputOptions): Promise<AgentRun>;
    updateRunAttempt(attemptId: AttemptId, input: UpdateRunAttemptInput, options?: UpdateRunAttemptInputOptions): Promise<AgentRunAttempt>;
    updateThreadMetadata(threadId: ThreadId, input: UpdateThreadMetadataInput): Promise<ThreadDetail>;
    archiveThread(threadId: ThreadId): Promise<ThreadDetail>;
    unarchiveThread(threadId: ThreadId): Promise<ThreadDetail>;
    purgeThread(threadId: ThreadId): Promise<void>;
    putAttachment(input: PutAttachmentInput, options?: PutAssetInputOptions): Promise<ThreadAsset>;
    putArtifact(input: PutArtifactInput, options?: PutAssetInputOptions): Promise<ThreadAsset>;
    listThreadAssets(threadId: ThreadId): Promise<ThreadAsset[]>;
    readAssetData(assetId: AssetId): Promise<Buffer | undefined>;
    deleteReplayToolInputAsset(assetId: AssetId): Promise<void>;
    pruneThreadScratch(threadId: ThreadId): Promise<void>;
    getThreadPaths(threadId: ThreadId): ThreadPaths;
}
//# sourceMappingURL=thread-store.d.ts.map