/**
 * Task Projection Service (V3.1)
 *
 * Projects agent behavior into structured TaskRecord + TaskEvent entries.
 * The system automatically calls this — agents do not create TaskRecords directly.
 *
 * Responsibilities:
 * - CRUD for TaskRecords and TaskEvents
 * - Aggregation (per request, per agent, per skill)
 * - Token/cost accumulation
 * - Persistence to ~/.crewly/task-records/
 *
 * @module services/v3/task-projection.service
 */
import { type TaskRecord, type TaskEvent, type CreateTaskRecordInput, type UpdateTaskRecordInput, type TokenUsage } from '../../types/v3/task-record.types.js';
export declare class TaskProjectionService {
    private static instance;
    private readonly logger;
    private readonly recordsDir;
    private readonly recordsFile;
    private readonly eventsFile;
    private records;
    private events;
    private constructor();
    static getInstance(projectPath?: string): TaskProjectionService;
    static resetInstance(): void;
    load(): Promise<void>;
    /**
     * Creates a new TaskRecord and emits a task_created event.
     *
     * @param input - Creation parameters
     * @returns The created TaskRecord
     */
    createRecord(input: CreateTaskRecordInput): Promise<TaskRecord>;
    /**
     * Updates a TaskRecord's status and timestamps.
     *
     * @param id - TaskRecord ID
     * @param updates - Fields to update
     * @returns Updated TaskRecord or null if not found
     */
    updateRecord(id: string, updates: UpdateTaskRecordInput): Promise<TaskRecord | null>;
    /**
     * Gets a TaskRecord by ID.
     */
    getRecord(id: string): TaskRecord | undefined;
    /**
     * Lists TaskRecords, optionally filtered by requestId, ownerAgent, status, or workItemId.
     */
    listRecords(filter?: {
        requestId?: string;
        ownerAgent?: string;
        status?: string;
        workItemId?: string;
    }): TaskRecord[];
    /**
     * Marks a task as assigned to an agent.
     */
    markAssigned(taskId: string, agentId: string, assignedBy?: string): Promise<void>;
    /**
     * Marks a task as started/running.
     */
    markStarted(taskId: string, agentId: string): Promise<void>;
    /**
     * Marks a task as completed. Triggers async token roll-up to parent Request if applicable.
     */
    markDone(taskId: string, agentId: string, tokenUsage?: TokenUsage): Promise<void>;
    /**
     * Asynchronously rolls up token usage from a completed task to its parent Request.
     * Errors are swallowed — this must never block agent-facing operations.
     *
     * @param requestId - Parent Request ID
     * @param tokenUsage - Token counts from the completed task
     */
    private rollUpToRequest;
    /**
     * Marks a task as failed.
     */
    markFailed(taskId: string, agentId: string, reason?: string): Promise<void>;
    /**
     * Marks a task as blocked.
     */
    markBlocked(taskId: string, agentId: string, reason?: string): Promise<void>;
    /**
     * Records a skill invocation (called/succeeded/failed).
     */
    recordSkillCall(params: {
        taskId: string;
        agentId: string;
        skillName: string;
        success: boolean;
        tokenUsage?: TokenUsage;
        durationMs?: number;
        error?: string;
    }): Promise<void>;
    /**
     * Gets all events for a specific task.
     */
    getEventsForTask(taskId: string): TaskEvent[];
    /**
     * Lists recent events, optionally filtered by taskId.
     */
    listEvents(filter?: {
        taskId?: string;
        eventType?: string;
    }, limit?: number): TaskEvent[];
    /**
     * Returns token usage aggregated per request.
     */
    aggregateByRequest(): Record<string, TokenUsage>;
    /**
     * Returns token usage aggregated per agent.
     */
    aggregateByAgent(): Record<string, TokenUsage>;
    /**
     * Returns a summary of task counts by status.
     */
    getSummary(): {
        total: number;
        byStatus: Record<string, number>;
        byType: Record<string, number>;
        byAgent: Record<string, number>;
    };
    private persistRecords;
    private persistEvents;
    private appendEvent;
}
//# sourceMappingURL=task-projection.service.d.ts.map