/**
 * Comprehensive REST SDK Client for @hasna/todos
 *
 * Zero-dependency HTTP client covering ALL REST API endpoints.
 * Typed errors, cursor pagination, batch operations, SSE subscriptions.
 *
 * @example
 * ```ts
 * import { TodosClient } from "@hasna/todos";
 *
 * const client = new TodosClient(); // uses local TODOS_URL or localhost:19427
 * const tasks = await client.tasks.list({ status: "pending", limit: 20 });
 * await client.tasks.complete(taskId);
 * ```
 */
import type { Task, Agent, Project, Plan, Org, Webhook, TaskTemplate, TaskComment, TaskHistory, CreateTaskInput, CreateProjectInput, CreatePlanInput, UpdatePlanInput, CreateOrgInput, CreateWebhookInput, CreateTemplateInput, RegisterAgentInput, DashboardStats, TaskSummary, TaskPriority } from "../types/index.js";
import type { TodosClientOptions, SSEEvent, TaskStatusResponse, TaskNextResponse, TaskActiveResponse, TaskStaleResponse, TaskChangedResponse, TaskContextResponse, TaskProgressResponse, TaskAttachmentsResponse, TaskFailResponse, TaskBulkResponse, AgentMeResponse, AgentQueueResponse, OrgNode, PlanWithTasks, ReportResponse, DoctorResponse } from "./types.js";
export type { TodosClientOptions } from "./types.js";
declare class TasksResource {
    private client;
    constructor(client: TodosClient);
    /** List tasks with optional filters. Supports cursor pagination. */
    list(options?: {
        status?: string;
        project_id?: string;
        session_id?: string;
        agent_id?: string;
        assigned_to?: string;
        limit?: number;
        offset?: number;
        cursor?: string;
        fields?: string | string[];
    }): Promise<TaskSummary[]>;
    /** Get a single task by ID */
    get(id: string, options?: {
        fields?: string | string[];
    }): Promise<TaskSummary>;
    /** Get task with full relations (subtasks, dependencies, comments, checklist) */
    getWithRelations(id: string): Promise<Task>;
    /** Create a new task */
    create(data: CreateTaskInput & {
        agent_id?: string;
    }): Promise<TaskSummary>;
    /** Update a task (PATCH — only allowed fields) */
    update(id: string, data: Record<string, unknown>): Promise<TaskSummary>;
    /** Delete a task */
    delete(id: string): Promise<{
        success: boolean;
    }>;
    /** Start a task (pending → in_progress) */
    start(id: string, agentId?: string): Promise<TaskSummary>;
    /** Complete a task */
    complete(id: string, agentId?: string): Promise<TaskSummary>;
    /** Fail a task with optional retry */
    fail(id: string, options?: {
        reason?: string;
        agent_id?: string;
        retry?: boolean;
        error_code?: string;
    }): Promise<TaskFailResponse>;
    /** Log progress on a task */
    logProgress(taskId: string, message: string, pctComplete?: number, agentId?: string): Promise<TaskComment>;
    /** Get progress entries for a task */
    getProgress(id: string, options?: {
        limit?: number;
        format?: "compact" | "full";
    }): Promise<TaskProgressResponse>;
    /** Get task history (audit log) */
    getHistory(id: string, options?: {
        limit?: number;
        format?: "compact" | "full";
    }): Promise<TaskHistory[]>;
    /** Get task attachments */
    getAttachments(id: string): Promise<TaskAttachmentsResponse>;
    /** Get task status summary (counts by status, active work, next task) */
    status(options?: {
        project_id?: string;
        agent_id?: string;
    }): Promise<TaskStatusResponse>;
    /** Get next available task for an agent */
    next(options?: {
        project_id?: string;
        agent_id?: string;
        fields?: string | string[];
    }): Promise<TaskNextResponse>;
    /** Get active (in-progress) work */
    active(projectId?: string): Promise<TaskActiveResponse>;
    /** Get stale tasks (in_progress > N minutes) */
    stale(options?: {
        project_id?: string;
        minutes?: number;
        fields?: string | string[];
    }): Promise<TaskStaleResponse>;
    /** Get tasks changed since a timestamp */
    changedSince(since: string, projectId?: string, options?: {
        fields?: string | string[];
    }): Promise<TaskChangedResponse>;
    /** Get task context (summary text or JSON for agent prompt injection) */
    context(options?: {
        agentId?: string;
        projectId?: string;
        format?: "text" | "compact" | "json";
        fields?: string | string[];
    }): Promise<TaskContextResponse | string>;
    /** Export tasks as JSON or CSV */
    export(options?: {
        status?: string;
        project_id?: string;
        format?: "json" | "csv";
    }): Promise<TaskSummary[] | string>;
    /** Bulk operations: complete, start, or delete multiple tasks */
    bulk(ids: string[], action: "complete" | "start" | "delete"): Promise<TaskBulkResponse>;
    /** Claim the next available task for an agent */
    claim(agentId: string, projectId?: string): Promise<{
        task: TaskSummary | null;
    }>;
    /** Subscribe to task events via SSE. Returns an AsyncGenerator. */
    subscribe(options?: {
        agentId?: string;
        projectId?: string;
        events?: string[];
    }): AsyncGenerator<SSEEvent, void, unknown>;
}
declare class AgentsResource {
    private client;
    constructor(client: TodosClient);
    /** List all agents */
    list(options?: {
        fields?: string;
    }): Promise<Agent[]>;
    /** Register a new agent (or heartbeat existing) */
    register(data: {
        name: string;
        description?: string;
        role?: string;
        session_id?: string;
        working_dir?: string;
    }): Promise<Agent>;
    /** Full agent registration with all fields */
    fullRegister(data: RegisterAgentInput): Promise<Agent | {
        conflict: true;
        message: string;
    }>;
    /** Update an agent */
    update(id: string, data: {
        name?: string;
        description?: string;
        role?: string;
    }): Promise<Agent>;
    /** Delete an agent */
    delete(id: string): Promise<{
        success: boolean;
    }>;
    /** Bulk delete agents */
    bulkDelete(ids: string[]): Promise<{
        succeeded: number;
        failed: number;
    }>;
    /** Get agent info + their tasks (as if they just registered) */
    me(name: string): Promise<AgentMeResponse>;
    /** Get pending task queue for an agent */
    queue(agentId: string): Promise<AgentQueueResponse>;
    /** Get direct reports (team) for an agent */
    team(agentId: string): Promise<Agent[]>;
    /** Get full org chart */
    orgChart(): Promise<OrgNode[]>;
}
declare class ProjectsResource {
    private client;
    constructor(client: TodosClient);
    /** List all projects */
    list(options?: {
        fields?: string;
    }): Promise<Project[]>;
    /** Create a project */
    create(data: CreateProjectInput): Promise<Project>;
    /** Delete a project */
    delete(id: string): Promise<{
        success: boolean;
    }>;
    /** Bulk delete projects */
    bulkDelete(ids: string[]): Promise<{
        succeeded: number;
        failed: number;
    }>;
}
declare class PlansResource {
    private client;
    constructor(client: TodosClient);
    /** List plans, optionally filtered by project */
    list(projectId?: string): Promise<Plan[]>;
    /** Create a plan */
    create(data: CreatePlanInput): Promise<Plan>;
    /** Get a plan with its tasks */
    get(id: string): Promise<PlanWithTasks>;
    /** Update a plan */
    update(id: string, data: UpdatePlanInput): Promise<Plan>;
    /** Delete a plan */
    delete(id: string): Promise<{
        success: boolean;
    }>;
    /** Bulk delete plans */
    bulkDelete(ids: string[]): Promise<{
        succeeded: number;
        failed: number;
    }>;
}
declare class OrgsResource {
    private client;
    constructor(client: TodosClient);
    /** List all orgs */
    list(): Promise<Org[]>;
    /** Create an org */
    create(data: CreateOrgInput): Promise<Org>;
    /** Update an org */
    update(id: string, data: Record<string, unknown>): Promise<Org>;
    /** Delete an org */
    delete(id: string): Promise<{
        success: boolean;
    }>;
}
declare class WebhooksResource {
    private client;
    constructor(client: TodosClient);
    /** List all webhooks */
    list(): Promise<Webhook[]>;
    /** Create a webhook */
    create(data: CreateWebhookInput): Promise<Webhook>;
    /** Delete a webhook */
    delete(id: string): Promise<{
        success: boolean;
    }>;
}
declare class TemplatesResource {
    private client;
    constructor(client: TodosClient);
    /** List all templates */
    list(): Promise<TaskTemplate[]>;
    /** Create a template */
    create(data: CreateTemplateInput): Promise<TaskTemplate>;
    /** Delete a template */
    delete(id: string): Promise<{
        success: boolean;
    }>;
}
export declare class TodosClient {
    readonly baseUrl: string;
    readonly timeout: number;
    readonly apiKey: string | null;
    readonly maxRetries: number;
    readonly retryDelay: number;
    /** Namespaced resource accessors */
    readonly tasks: TasksResource;
    readonly agents: AgentsResource;
    readonly projects: ProjectsResource;
    readonly plans: PlansResource;
    readonly orgs: OrgsResource;
    readonly webhooks: WebhooksResource;
    readonly templates: TemplatesResource;
    constructor(options?: TodosClientOptions);
    /** Create a client from TODOS_URL env var */
    static fromEnv(apiKey?: string): TodosClient;
    /** Raw fetch — for endpoints that don't return JSON (text, CSV, SSE) */
    _fetchRaw(url: string, init?: RequestInit): Promise<Response>;
    private _buildHeaders;
    private _fetchWithRetry;
    private _fetch;
    _get<T>(path: string, query?: string): Promise<T>;
    _post<T>(path: string, body?: Record<string, unknown>): Promise<T>;
    _patch<T>(path: string, body: Record<string, unknown>): Promise<T>;
    _delete<T>(path: string): Promise<T>;
    private _sleep;
    /** Health check */
    getHealth(): Promise<{
        status: "ok" | "warn";
        tasks: number;
        stale: number;
        overdue_recurring: number;
        timestamp: string;
    }>;
    /** Quick alive check */
    isAlive(): Promise<boolean>;
    /** Dashboard stats */
    getStats(): Promise<DashboardStats>;
    /** Report for the last N days */
    getReport(options?: {
        days?: number;
        projectId?: string;
    }): Promise<ReportResponse>;
    /** Doctor — health diagnostics */
    doctor(): Promise<DoctorResponse>;
    /** Recent activity */
    activity(limit?: number): Promise<any[]>;
    /** @deprecated Use client.tasks.list() instead */
    listTasks(filter?: {
        status?: string;
        project_id?: string;
        assigned_to?: string;
        limit?: number;
        offset?: number;
        session_id?: string;
        due_today?: boolean;
        overdue?: boolean;
        fields?: string | string[];
    }): Promise<TaskSummary[]>;
    /** @deprecated Use client.tasks.get() instead */
    getTask(id: string, options?: {
        fields?: string | string[];
    }): Promise<TaskSummary>;
    /** @deprecated Use client.tasks.create() instead */
    createTask(data: {
        title: string;
        description?: string;
        priority?: TaskPriority;
        project_id?: string;
        assigned_to?: string;
        tags?: string[];
        recurrence_rule?: string;
        due_at?: string;
    }): Promise<any>;
    /** @deprecated Use client.tasks.update() instead */
    updateTask(id: string, data: Record<string, unknown>): Promise<any>;
    /** @deprecated Use client.tasks.delete() instead */
    deleteTask(id: string): Promise<void>;
    /** @deprecated Use client.tasks.start() instead */
    startTask(id: string, agentId: string): Promise<any>;
    /** @deprecated Use client.tasks.complete() instead */
    completeTask(id: string, agentId?: string): Promise<any>;
    /** @deprecated Use client.tasks.fail() instead */
    failTask(id: string, options?: {
        reason?: string;
        agent_id?: string;
        retry?: boolean;
        error_code?: string;
    }): Promise<any>;
    /** @deprecated Use client.tasks.logProgress() instead */
    logProgress(taskId: string, message: string, pctComplete?: number, agentId?: string): Promise<any>;
    /** @deprecated Use client.tasks.status() instead */
    getStatus(projectId?: string, agentId?: string): Promise<TaskStatusResponse>;
    /** @deprecated Use client.tasks.active() instead */
    getActiveWork(projectId?: string): Promise<any[]>;
    /** @deprecated Use client.tasks.changedSince() instead */
    getTasksChangedSince(since: string, projectId?: string): Promise<any>;
    /** @deprecated Use client.tasks.stale() instead */
    getStaleTasks(minutes?: number, projectId?: string): Promise<any>;
    /** @deprecated Use client.tasks.context() instead */
    getContext(options?: {
        agentId?: string;
        projectId?: string;
        format?: "text" | "compact" | "json";
    }): Promise<string | any>;
    /** @deprecated Use client.tasks.export() instead */
    exportTasks(filter?: {
        status?: string;
        project_id?: string;
        format?: "json" | "csv";
    }): Promise<any>;
    /** @deprecated Use client.tasks.claim() instead */
    claimNextTask(agentId: string, projectId?: string): Promise<any>;
    /** @deprecated Use client.tasks.getHistory() instead */
    getTaskHistory(id: string, options?: {
        limit?: number;
        format?: "compact" | "full";
    }): Promise<any[]>;
    /** @deprecated Use client.tasks.getAttachments() instead */
    getTaskAttachments(id: string): Promise<any>;
    /** @deprecated Use client.tasks.getProgress() instead */
    getTaskProgress(id: string, options?: {
        limit?: number;
        format?: "compact" | "full";
    }): Promise<any>;
    /** @deprecated Use client.tasks.subscribe() instead */
    subscribeToStream(options?: {
        agentId?: string;
        projectId?: string;
        events?: string[];
    }): AsyncGenerator<SSEEvent, void, unknown>;
    /** @deprecated Use client.projects.list() instead */
    getProjects(): Promise<Project[]>;
}
/** Create a new TodosClient instance */
export declare function createClient(options?: TodosClientOptions): TodosClient;
//# sourceMappingURL=client.d.ts.map