/**
 * Task History Subscriber
 *
 * Listens on the in-process EventBus for `task:done_by_worker`,
 * `task:rejected`, and `task:cancelled` and writes a {@link
 * TaskHistoryEntry} into the originating project's `ProjectMemory`.
 *
 * This is the load-bearing write path behind "who in my team has done
 * X?" — the orchestrator queries the resulting ledger via
 * `recall_memory({ capability: '<canonical-cap>' })` before delegating
 * external-access work.
 *
 * @module services/memory/task-history.subscriber
 */
import { EventBusService, type InProcessUnsubscribe } from '../event-bus/event-bus.service.js';
import { TaskPoolService } from '../task-pool/task-pool.service.js';
import { IProjectMemoryService } from './project-memory.service.js';
import { AgentEvent } from '../../types/event-bus.types.js';
import { CapabilityInferenceService } from './capability-inference.js';
export interface TaskHistorySubscriberDeps {
    /** Bus to listen on */
    eventBus: EventBusService;
    /** Memory service that owns the ledger */
    projectMemoryService: IProjectMemoryService;
    /** Pool service used to resolve the WorkItem from id (description, type, etc.) */
    taskPoolService: TaskPoolService;
    /** Optional override for capability inference (tests pass a stub) */
    capabilityInference?: CapabilityInferenceService;
    /**
     * Optional override for the project path resolver. Production uses the
     * WorkItem's `metadata.projectPath`; tests can substitute a fixed path.
     */
    resolveProjectPath?: (event: AgentEvent) => string | null;
}
export declare class TaskHistorySubscriber {
    private readonly logger;
    private readonly eventBus;
    private readonly projectMemory;
    private readonly taskPool;
    private readonly inference;
    private readonly resolveProjectPath;
    private unsubscribeFn;
    constructor(deps: TaskHistorySubscriberDeps);
    /**
     * Attach the in-process handler. Returns a detach function. Idempotent —
     * calling start() twice without intervening stop() returns the first
     * detach function (the second start is a no-op).
     */
    start(): InProcessUnsubscribe;
    /**
     * Detach the handler. Safe to call multiple times.
     */
    stop(): void;
    /**
     * Handle one event. Public for unit testing — production flow goes
     * through the bus.
     */
    handle(event: AgentEvent): Promise<void>;
}
/**
 * Default resolver: lift `metadata.projectPath` off the WorkItem. The
 * subscriber prefers the event's own projectPath if present, then falls
 * back to the WorkItem's. Returns null when neither is set.
 *
 * Exported for unit testing.
 */
export declare function defaultResolveProjectPath(event: AgentEvent): string | null;
/**
 * Extract the tool names invoked during the task from the WorkItem's
 * metadata. Tries `metadata.toolsUsed` (canonical), `metadata.tools`
 * (legacy), and an empty list as a last resort.
 *
 * Exported for unit testing.
 */
export declare function extractToolsUsed(workItem: Record<string, unknown>): string[];
//# sourceMappingURL=task-history.subscriber.d.ts.map