import type { IAgentRuntime } from "@elizaos/core";
import type { CodingAgentType } from "./pty-types.ts";
export type TaskThreadKind = "coding" | "research" | "planning" | "ops" | "mixed";
export type TaskThreadStatus = "open" | "active" | "waiting_on_user" | "blocked" | "validating" | "done" | "failed" | "archived" | "interrupted";
export type TaskSessionStatus = "active" | "blocked" | "waiting_on_user" | "completed" | "stopped" | "error" | "tool_running" | "interrupted";
export type TaskThreadEventType = "task_created" | "task_registered" | "task_status_changed" | "task_paused" | "task_resumed" | "task_stopped" | "task_archived" | "task_reopened" | "session_registered" | "session_updated" | "session_interrupted" | "decision_recorded" | "artifact_recorded" | "summary_updated" | "share_discovered";
export interface TaskThreadRecord {
    id: string;
    agentId: string;
    roomId: string | null;
    worldId: string | null;
    ownerUserId: string | null;
    scenarioId: string | null;
    batchId: string | null;
    title: string;
    kind: TaskThreadKind;
    status: TaskThreadStatus;
    originalRequest: string;
    summary: string;
    acceptanceCriteria: string[];
    currentPlan: Record<string, unknown>;
    searchText: string;
    createdAt: string;
    updatedAt: string;
    closedAt: string | null;
    archivedAt: string | null;
    lastUserTurnAt: string | null;
    lastCoordinatorTurnAt: string | null;
    metadata: Record<string, unknown>;
}
export interface TaskSessionRecord {
    id: string;
    threadId: string;
    agentId: string;
    sessionId: string;
    framework: CodingAgentType;
    providerSource: string | null;
    label: string;
    originalTask: string;
    workdir: string;
    repo: string | null;
    status: TaskSessionStatus;
    decisionCount: number;
    autoResolvedCount: number;
    registeredAt: number;
    lastActivityAt: number;
    idleCheckCount: number;
    taskDelivered: boolean;
    completionSummary: string | null;
    lastSeenDecisionIndex: number;
    lastInputSentAt: number | null;
    stoppedAt: number | null;
    createdAt: string;
    updatedAt: string;
    metadata: Record<string, unknown>;
}
export interface TaskDecisionRecord {
    id: string;
    threadId: string;
    sessionId: string;
    timestamp: number;
    event: string;
    promptText: string;
    decision: string;
    response: string | null;
    reasoning: string;
    metadata: Record<string, unknown>;
}
export interface TaskEventRecord {
    id: string;
    threadId: string;
    sessionId: string | null;
    eventType: TaskThreadEventType | string;
    timestamp: number;
    summary: string;
    data: Record<string, unknown>;
    createdAt: string;
}
export interface TaskArtifactRecord {
    id: string;
    threadId: string;
    sessionId: string | null;
    artifactType: string;
    title: string;
    path: string | null;
    uri: string | null;
    mimeType: string | null;
    metadata: Record<string, unknown>;
    createdAt: string;
}
export interface TaskTranscriptRecord {
    id: string;
    threadId: string;
    sessionId: string;
    timestamp: number;
    direction: "stdout" | "stderr" | "stdin" | "keys" | "system";
    content: string;
    metadata: Record<string, unknown>;
    createdAt: string;
}
export interface TaskPendingDecisionRecord {
    sessionId: string;
    threadId: string;
    promptText: string;
    recentOutput: string;
    llmDecision: Record<string, unknown>;
    taskContext: Record<string, unknown>;
    createdAt: number;
    updatedAt: string;
}
export type TaskNodeKind = "goal" | "execution" | "research" | "planning" | "verification" | "handoff";
export type TaskNodeStatus = "planned" | "ready" | "claimed" | "running" | "blocked" | "waiting_on_user" | "verifying" | "completed" | "failed" | "canceled" | "interrupted";
export interface TaskNodeRecord {
    id: string;
    threadId: string;
    parentNodeId: string | null;
    kind: TaskNodeKind;
    status: TaskNodeStatus;
    title: string;
    instructions: string;
    acceptanceCriteria: string[];
    requiredCapabilities: string[];
    expectedArtifacts: string[];
    assignedSessionId: string | null;
    assignedLabel: string | null;
    agentType: CodingAgentType | null;
    workdir: string | null;
    repo: string | null;
    priority: number;
    depth: number;
    sequence: number;
    createdFrom: string | null;
    metadata: Record<string, unknown>;
    createdAt: string;
    updatedAt: string;
    startedAt: string | null;
    completedAt: string | null;
}
export type TaskDependencyKind = "blocks" | "parent_child" | "artifact" | "handoff";
export interface TaskDependencyRecord {
    id: string;
    threadId: string;
    fromNodeId: string;
    toNodeId: string;
    dependencyKind: TaskDependencyKind;
    requiredStatus: TaskNodeStatus;
    metadata: Record<string, unknown>;
    createdAt: string;
}
export type TaskClaimType = "execution" | "verification" | "ownership";
export type TaskClaimStatus = "active" | "released" | "completed" | "failed" | "interrupted";
export interface TaskClaimRecord {
    id: string;
    threadId: string;
    nodeId: string;
    sessionId: string;
    claimType: TaskClaimType;
    status: TaskClaimStatus;
    claimedAt: string;
    releasedAt: string | null;
    metadata: Record<string, unknown>;
}
export type TaskMailboxDeliveryState = "pending" | "delivered" | "consumed";
export interface TaskMailboxMessageRecord {
    id: string;
    threadId: string;
    nodeId: string | null;
    sessionId: string | null;
    sender: string;
    recipient: string;
    subject: string;
    body: string;
    deliveryState: TaskMailboxDeliveryState;
    metadata: Record<string, unknown>;
    createdAt: string;
    deliveredAt: string | null;
}
export type TaskVerifierJobStatus = "pending" | "running" | "passed" | "failed" | "canceled";
export interface TaskVerifierJobRecord {
    id: string;
    threadId: string;
    nodeId: string;
    status: TaskVerifierJobStatus;
    verifierType: string;
    title: string;
    instructions: string;
    config: Record<string, unknown>;
    metadata: Record<string, unknown>;
    createdAt: string;
    startedAt: string | null;
    completedAt: string | null;
}
export interface TaskEvidenceRecord {
    id: string;
    threadId: string;
    nodeId: string | null;
    sessionId: string | null;
    verifierJobId: string | null;
    evidenceType: string;
    title: string;
    summary: string;
    path: string | null;
    uri: string | null;
    content: Record<string, unknown>;
    metadata: Record<string, unknown>;
    createdAt: string;
}
export interface TaskThreadSummary extends TaskThreadRecord {
    sessionCount: number;
    activeSessionCount: number;
    latestSessionId: string | null;
    latestSessionLabel: string | null;
    latestWorkdir: string | null;
    latestRepo: string | null;
    latestActivityAt: number | null;
    decisionCount: number;
    nodeCount: number;
    readyNodeCount: number;
    completedNodeCount: number;
    verifierJobCount: number;
    evidenceCount: number;
}
export interface TaskThreadDetail extends TaskThreadSummary {
    sessions: TaskSessionRecord[];
    decisions: TaskDecisionRecord[];
    events: TaskEventRecord[];
    artifacts: TaskArtifactRecord[];
    transcripts: TaskTranscriptRecord[];
    pendingDecisions: TaskPendingDecisionRecord[];
    nodes: TaskNodeRecord[];
    dependencies: TaskDependencyRecord[];
    claims: TaskClaimRecord[];
    mailbox: TaskMailboxMessageRecord[];
    verifierJobs: TaskVerifierJobRecord[];
    evidence: TaskEvidenceRecord[];
}
export interface CreateTaskThreadInput {
    id?: string;
    title: string;
    originalRequest: string;
    kind?: TaskThreadKind;
    roomId?: string | null;
    worldId?: string | null;
    ownerUserId?: string | null;
    scenarioId?: string | null;
    batchId?: string | null;
    summary?: string;
    acceptanceCriteria?: string[];
    currentPlan?: Record<string, unknown>;
    lastUserTurnAt?: string | null;
    metadata?: Record<string, unknown>;
}
export interface RegisterTaskSessionInput {
    threadId: string;
    sessionId: string;
    framework: CodingAgentType;
    label: string;
    originalTask: string;
    workdir: string;
    repo?: string;
    providerSource?: string | null;
    status?: TaskSessionStatus;
    decisionCount?: number;
    autoResolvedCount?: number;
    registeredAt?: number;
    lastActivityAt?: number;
    idleCheckCount?: number;
    taskDelivered?: boolean;
    completionSummary?: string | null;
    lastSeenDecisionIndex?: number;
    lastInputSentAt?: number | null;
    stoppedAt?: number | null;
    metadata?: Record<string, unknown>;
}
export interface UpdateTaskSessionInput {
    status?: TaskSessionStatus;
    decisionCount?: number;
    autoResolvedCount?: number;
    lastActivityAt?: number;
    idleCheckCount?: number;
    taskDelivered?: boolean;
    completionSummary?: string | null;
    lastSeenDecisionIndex?: number;
    lastInputSentAt?: number | null;
    stoppedAt?: number | null;
    metadata?: Record<string, unknown>;
}
export interface UpdateTaskThreadInput {
    status?: TaskThreadStatus;
    summary?: string;
    currentPlan?: Record<string, unknown>;
    lastUserTurnAt?: string | null;
    lastCoordinatorTurnAt?: string | null;
    closedAt?: string | null;
    archivedAt?: string | null;
    metadata?: Record<string, unknown>;
}
export interface RecordTaskDecisionInput {
    threadId: string;
    sessionId: string;
    timestamp: number;
    event: string;
    promptText: string;
    decision: string;
    response?: string;
    reasoning: string;
    metadata?: Record<string, unknown>;
}
export interface RecordTaskEventInput {
    threadId: string;
    sessionId?: string | null;
    eventType: TaskThreadEventType | string;
    timestamp?: number;
    summary?: string;
    data?: Record<string, unknown>;
}
export interface RecordTaskArtifactInput {
    threadId: string;
    sessionId?: string | null;
    artifactType: string;
    title: string;
    path?: string | null;
    uri?: string | null;
    mimeType?: string | null;
    metadata?: Record<string, unknown>;
}
export interface RecordTaskTranscriptInput {
    threadId: string;
    sessionId: string;
    timestamp?: number;
    direction: TaskTranscriptRecord["direction"];
    content: string;
    metadata?: Record<string, unknown>;
}
export interface UpsertPendingDecisionInput {
    sessionId: string;
    threadId: string;
    promptText: string;
    recentOutput: string;
    llmDecision: Record<string, unknown>;
    taskContext: Record<string, unknown>;
    createdAt?: number;
}
export interface CreateTaskNodeInput {
    id?: string;
    threadId: string;
    parentNodeId?: string | null;
    kind?: TaskNodeKind;
    status?: TaskNodeStatus;
    title: string;
    instructions?: string;
    acceptanceCriteria?: string[];
    requiredCapabilities?: string[];
    expectedArtifacts?: string[];
    assignedSessionId?: string | null;
    assignedLabel?: string | null;
    agentType?: CodingAgentType | null;
    workdir?: string | null;
    repo?: string | null;
    priority?: number;
    depth?: number;
    sequence?: number;
    createdFrom?: string | null;
    metadata?: Record<string, unknown>;
    startedAt?: string | null;
    completedAt?: string | null;
}
export interface UpdateTaskNodeInput {
    parentNodeId?: string | null;
    kind?: TaskNodeKind;
    status?: TaskNodeStatus;
    title?: string;
    instructions?: string;
    acceptanceCriteria?: string[];
    requiredCapabilities?: string[];
    expectedArtifacts?: string[];
    assignedSessionId?: string | null;
    assignedLabel?: string | null;
    agentType?: CodingAgentType | null;
    workdir?: string | null;
    repo?: string | null;
    priority?: number;
    depth?: number;
    sequence?: number;
    createdFrom?: string | null;
    metadata?: Record<string, unknown>;
    startedAt?: string | null;
    completedAt?: string | null;
}
export interface CreateTaskDependencyInput {
    id?: string;
    threadId: string;
    fromNodeId: string;
    toNodeId: string;
    dependencyKind?: TaskDependencyKind;
    requiredStatus?: TaskNodeStatus;
    metadata?: Record<string, unknown>;
}
export interface CreateTaskClaimInput {
    id?: string;
    threadId: string;
    nodeId: string;
    sessionId: string;
    claimType?: TaskClaimType;
    status?: TaskClaimStatus;
    metadata?: Record<string, unknown>;
    claimedAt?: string;
    releasedAt?: string | null;
}
export interface UpdateTaskClaimInput {
    status?: TaskClaimStatus;
    metadata?: Record<string, unknown>;
    releasedAt?: string | null;
}
export interface AppendTaskMailboxMessageInput {
    id?: string;
    threadId: string;
    nodeId?: string | null;
    sessionId?: string | null;
    sender: string;
    recipient: string;
    subject?: string;
    body: string;
    deliveryState?: TaskMailboxDeliveryState;
    metadata?: Record<string, unknown>;
    createdAt?: string;
    deliveredAt?: string | null;
}
export interface CreateTaskVerifierJobInput {
    id?: string;
    threadId: string;
    nodeId: string;
    status?: TaskVerifierJobStatus;
    verifierType: string;
    title: string;
    instructions?: string;
    config?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
    createdAt?: string;
    startedAt?: string | null;
    completedAt?: string | null;
}
export interface UpdateTaskVerifierJobInput {
    status?: TaskVerifierJobStatus;
    title?: string;
    instructions?: string;
    config?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
    startedAt?: string | null;
    completedAt?: string | null;
}
export interface RecordTaskEvidenceInput {
    id?: string;
    threadId: string;
    nodeId?: string | null;
    sessionId?: string | null;
    verifierJobId?: string | null;
    evidenceType: string;
    title: string;
    summary?: string;
    path?: string | null;
    uri?: string | null;
    content?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}
export interface ListTaskThreadsOptions {
    includeArchived?: boolean;
    threadId?: string;
    status?: TaskThreadStatus;
    statuses?: TaskThreadStatus[];
    kind?: TaskThreadKind;
    roomId?: string;
    worldId?: string;
    ownerUserId?: string;
    scenarioId?: string;
    batchId?: string;
    createdAfter?: string;
    createdBefore?: string;
    updatedAfter?: string;
    updatedBefore?: string;
    latestActivityAfter?: number;
    latestActivityBefore?: number;
    hasActiveSession?: boolean;
    search?: string;
    limit?: number;
}
export declare class TaskRegistry {
    private readonly runtime;
    constructor(runtime: IAgentRuntime);
    private schemaKey;
    ensureSchema(): Promise<void>;
    recoverInterruptedTasks(): Promise<void>;
    createThread(input: CreateTaskThreadInput): Promise<TaskThreadRecord>;
    getThreadRecord(threadId: string): Promise<TaskThreadRecord | null>;
    getThread(threadId: string): Promise<TaskThreadDetail | null>;
    listThreads(options?: ListTaskThreadsOptions): Promise<TaskThreadSummary[]>;
    countThreads(options?: ListTaskThreadsOptions): Promise<number>;
    getThreadSummary(threadId: string): Promise<TaskThreadSummary | null>;
    findThreadIdBySessionId(sessionId: string): Promise<string | null>;
    getSession(sessionId: string): Promise<TaskSessionRecord | null>;
    registerSession(input: RegisterTaskSessionInput): Promise<void>;
    updateSession(sessionId: string, patch: UpdateTaskSessionInput): Promise<void>;
    recordDecision(input: RecordTaskDecisionInput): Promise<void>;
    appendEvent(input: RecordTaskEventInput): Promise<void>;
    recordArtifact(input: RecordTaskArtifactInput): Promise<void>;
    recordTranscript(input: RecordTaskTranscriptInput): Promise<void>;
    updateThreadSummary(threadId: string, summary: string): Promise<void>;
    updateThread(threadId: string, patch: UpdateTaskThreadInput): Promise<void>;
    archiveThread(threadId: string): Promise<void>;
    reopenThread(threadId: string): Promise<void>;
    upsertPendingDecision(input: UpsertPendingDecisionInput): Promise<void>;
    deletePendingDecision(sessionId: string): Promise<void>;
    listPendingDecisions(): Promise<TaskPendingDecisionRecord[]>;
    listPendingDecisionsForThread(threadId: string): Promise<TaskPendingDecisionRecord[]>;
    createTaskNode(input: CreateTaskNodeInput): Promise<TaskNodeRecord>;
    getTaskNode(nodeId: string): Promise<TaskNodeRecord | null>;
    updateTaskNode(nodeId: string, patch: UpdateTaskNodeInput): Promise<void>;
    listTaskNodesForThread(threadId: string): Promise<TaskNodeRecord[]>;
    listReadyTaskNodesForThread(threadId: string): Promise<TaskNodeRecord[]>;
    createTaskDependency(input: CreateTaskDependencyInput): Promise<TaskDependencyRecord>;
    getTaskDependency(dependencyId: string): Promise<TaskDependencyRecord | null>;
    listTaskDependenciesForThread(threadId: string): Promise<TaskDependencyRecord[]>;
    createTaskClaim(input: CreateTaskClaimInput): Promise<TaskClaimRecord>;
    getTaskClaim(claimId: string): Promise<TaskClaimRecord | null>;
    findActiveTaskClaim(nodeId: string, sessionId: string): Promise<TaskClaimRecord | null>;
    updateTaskClaim(claimId: string, patch: UpdateTaskClaimInput): Promise<void>;
    listTaskClaimsForThread(threadId: string): Promise<TaskClaimRecord[]>;
    appendTaskMailboxMessage(input: AppendTaskMailboxMessageInput): Promise<TaskMailboxMessageRecord>;
    getTaskMailboxMessage(messageId: string): Promise<TaskMailboxMessageRecord | null>;
    markTaskMailboxMessageDelivered(messageId: string): Promise<void>;
    listTaskMailboxMessagesForThread(threadId: string): Promise<TaskMailboxMessageRecord[]>;
    createTaskVerifierJob(input: CreateTaskVerifierJobInput): Promise<TaskVerifierJobRecord>;
    getTaskVerifierJob(verifierJobId: string): Promise<TaskVerifierJobRecord | null>;
    updateTaskVerifierJob(verifierJobId: string, patch: UpdateTaskVerifierJobInput): Promise<void>;
    listTaskVerifierJobsForThread(threadId: string): Promise<TaskVerifierJobRecord[]>;
    recordTaskEvidence(input: RecordTaskEvidenceInput): Promise<TaskEvidenceRecord>;
    getTaskEvidence(evidenceId: string): Promise<TaskEvidenceRecord | null>;
    listTaskEvidenceForThread(threadId: string): Promise<TaskEvidenceRecord[]>;
    private deriveDependentNodeStatus;
    private recomputeTaskGraphState;
    getLastUsedRepo(): Promise<string | undefined>;
    listSessionsForThread(threadId: string): Promise<TaskSessionRecord[]>;
    listDecisionsForThread(threadId: string): Promise<TaskDecisionRecord[]>;
    listDecisionsForSession(sessionId: string): Promise<TaskDecisionRecord[]>;
    listEventsForThread(threadId: string): Promise<TaskEventRecord[]>;
    listArtifactsForThread(threadId: string): Promise<TaskArtifactRecord[]>;
    listTranscriptsForThread(threadId: string): Promise<TaskTranscriptRecord[]>;
    private recomputeThreadStatus;
}
//# sourceMappingURL=task-registry.d.ts.map