export interface TodoItem {
    content: string;
    status: "pending" | "in_progress" | "completed";
}
/**
 * Compact progress record for a single nested subagent run (one Task
 * tool invocation). Tracked separately from `recentActions` so that a
 * chatty subagent can't flood the primary agent's recent-actions buffer.
 */
export interface SubagentProgress {
    /** Claude tool_use_id of the Task invocation that spawned this subagent. */
    toolUseId: string;
    /**
     * SDK-issued task_id (a.k.a. agentId) for async Agent runs. Captured from
     * the `task_started` system event and used as a fallback lookup key when
     * later events (notably `task_updated`) arrive without `tool_use_id`.
     */
    taskId?: string;
    subagentType?: string;
    /** Human-readable description, usually from the Task tool input. */
    description?: string;
    startedAt: number;
    completedAt: number | null;
    status: "running" | "completed" | "failed";
    /**
     * The most recent signal we saw from this subagent, formatted for
     * operator display. Typically a truncated tool call or a truncated
     * assistant-text excerpt. Null until the first nested event arrives.
     */
    lastActivity: string | null;
    /** Count of nested tool calls + assistant text blocks observed. */
    actionCount: number;
}
/**
 * Per-memory reference inside a {@link MemoryRecallEvent}. Mirrors the SDK
 * schema: an absolute path to the CLI-managed memory file plus a scope tag
 * (the CLI's built-in scopes are `"personal"`, `"project"`, `"local"`,
 * `"agent-memory"`, etc.; we pass whatever the CLI reports through untouched
 * so renderers stay forward-compatible).
 */
export interface MemoryRecallItem {
    path: string;
    scope?: string;
}
/**
 * Per-event record of a CLI auto-memory recall, captured from the SDK's
 * `system/memory_recall` messages. These are informational only — the CLI
 * surfaces any retrieved content directly to the model, we just observe
 * so operators can see what the agent has "remembered".
 *
 * Schema source: the CLI binary declares a Zod schema roughly equivalent to
 *   { type: "system", subtype: "memory_recall",
 *     mode: "select" | "synthesize",
 *     memories: [{ path, scope, content? }],
 *     uuid, session_id }
 * `content` only appears in `"synthesize"` mode and is a Sonnet-authored
 * distillation; we deliberately drop it from our record because it can be
 * large (hundreds to thousands of tokens) and isn't needed for operator
 * observability.
 */
export interface MemoryRecallEvent {
    /** Wall-clock time when we saw the event. */
    observedAt: number;
    /**
     * How the CLI surfaced memories for this recall. Today the CLI emits
     * either `"select"` (returns full file bodies chosen by the parallel
     * selector) or `"synthesize"` (returns a Sonnet-authored paragraph
     * distilled across many tiny memories). Typed as plain `string` to
     * stay forward-compatible with future modes; downstream callers should
     * treat unknown values as opaque.
     */
    mode?: string;
    /** Memory files referenced by this recall event. */
    memories: MemoryRecallItem[];
}
/**
 * Snapshot of the CLI's auto-memory state for the current session. Populated
 * from the `memory_paths` field on `system/init` messages plus any
 * `system/memory_recall` events we've seen since session start.
 */
export interface MemoryStatus {
    /**
     * Map of memory scope → filesystem path as reported by the CLI on
     * `system/init`. The only scope we've observed in the wild is `"auto"`
     * (e.g. `~/.claude/projects/<sanitized-cwd>/memory/`), but the CLI source
     * treats this as an open key/value map so we do too.
     */
    paths: Record<string, string>;
    /** Most-recent N recall events (newest last). */
    recentRecalls: MemoryRecallEvent[];
}
/**
 * Live snapshot of what the LLM is currently streaming. Cleared when the
 * content_block_stop or a new turn arrives.
 */
export interface StreamingActivity {
    /** Tool name being invoked, or "text" for plain assistant text. */
    blockType: string;
    /** Total characters received for this block so far. */
    charsAccumulated: number;
    /** Wall-clock time we last updated the summary field. */
    lastUpdatedAt: number;
    /** Human-readable one-liner for the fast responder. */
    summary: string;
}
/**
 * Maintains a rolling summary of the primary agent's current activity.
 * Read by the fast responder to give context-aware quick replies when the
 * agent is busy.
 */
export declare class ActivityTracker {
    private currentTaskDescription;
    private recentActions;
    private lastAssistantText;
    private taskStartedAt;
    private lastTodos;
    private recentExchanges;
    private streamingActivity;
    /**
     * Ordered map of in-flight + recently-completed subagent runs keyed by
     * tool_use_id. Insertion order is preserved by `Map`; we prune oldest
     * completed entries when the map exceeds `MAX_SUBAGENTS`.
     */
    private subagents;
    /**
     * CLI auto-memory state observed this session. Paths come from
     * `system/init` (stable for the life of a query); recall events come
     * from `system/memory_recall`. Survives across wake cycles so operator
     * surfaces like /obs/memory-status can display the most recent info.
     */
    private memoryPaths;
    private memoryRecallEvents;
    /**
     * Session-scoped registry of tasks seen via the incremental
     * `TaskCreate`/`TaskUpdate` tools, keyed by the SDK's task id. Unlike the
     * per-stream `TaskTodoAccumulator` (one `processAgentStream` call / one
     * turn), this lives for the life of the session, so a cross-turn status-only
     * `TaskUpdate` — whose `TaskCreate` landed in an earlier turn — can recover
     * the original subject instead of being dropped. In-memory only: it does not
     * survive a process restart, which is acceptable since a fresh session
     * re-creates its tasks.
     */
    private readonly taskRegistry;
    private readonly maxActions;
    constructor(maxActions?: number);
    /**
     * The session-scoped task registry shared with each turn's
     * `TaskTodoAccumulator` so cross-turn `TaskUpdate`s can restore subjects.
     */
    getTaskRegistry(): Map<string, {
        subject: string;
        status: TodoItem["status"];
    }>;
    startTask(description: string): void;
    recordUserMessage(text: string): void;
    recordAssistantText(text: string): void;
    recordToolCall(name: string, inputSummary: string): void;
    recordToolResult(name: string, outputSummary: string): void;
    recordTodos(todos: TodoItem[]): void;
    getTodos(): TodoItem[];
    /**
     * Signal that a new streaming content block has started. Sets up tracking
     * state so subsequent `recordStreamingDelta` calls can accumulate content.
     */
    startStreamingBlock(blockType: string): void;
    /**
     * Accumulate streaming delta characters. Updates the human-readable summary
     * only when enough time or content has elapsed (debounced).
     */
    recordStreamingDelta(chars: number): void;
    /** Signal that the current streaming block has finished. */
    stopStreamingBlock(): void;
    getStreamingActivity(): StreamingActivity | null;
    /**
     * Register a newly-spawned subagent. Safe to call multiple times for
     * the same toolUseId — later calls are treated as no-ops so we don't
     * clobber already-captured progress if events arrive out of order.
     */
    recordSubagentStarted(toolUseId: string, info: {
        subagentType?: string;
        description?: string;
    }): void;
    /**
     * Associate an SDK `task_id` with an already-registered subagent so that
     * subsequent system events lacking `tool_use_id` (notably `task_updated`)
     * can still be routed to the correct entry. No-op if the subagent isn't
     * tracked or already has a taskId — the mapping is stable for the life of
     * the task.
     */
    recordSubagentTaskId(toolUseId: string, taskId: string): void;
    /**
     * Reverse lookup: given an SDK `task_id`, return the tracked subagent.
     * Used by stream-handler to repair events that only carry `task_id`.
     */
    findSubagentByTaskId(taskId: string): SubagentProgress | undefined;
    /**
     * Record a nested event (assistant text or tool call) observed under
     * an active subagent. We keep only the latest activity string plus a
     * counter to avoid per-subagent history growth. No-op if the subagent
     * isn't tracked — stream ordering can produce nested events before we
     * see the parent Task block; callers should always `recordSubagentStarted`
     * first when possible.
     */
    recordSubagentActivity(toolUseId: string, label: string): void;
    /**
     * Record an async subagent progress snapshot from a `task_progress` system
     * event. Unlike {@link recordSubagentActivity}, the SDK supplies a cumulative
     * `toolUses` count, so we *set* `actionCount` instead of incrementing. The
     * `description` and `lastToolName` fields describe the current operation;
     * prefer `lastToolName` when present because descriptions often repeat the
     * subagent title (e.g. "Research Middle East situation") rather than the
     * current step.
     */
    recordSubagentProgress(toolUseId: string, info: {
        toolUses?: number;
        lastToolName?: string;
        description?: string;
    }): void;
    recordSubagentCompleted(toolUseId: string, info: {
        ok: boolean;
        summary?: string;
    }): void;
    /**
     * Returns all tracked subagents in insertion order. Callers that only
     * care about the currently-running ones should filter by status.
     */
    getSubagents(): SubagentProgress[];
    getActiveSubagents(): SubagentProgress[];
    /**
     * Update the known CLI auto-memory paths (typically one, keyed "auto").
     * Safe to call repeatedly — we merge new keys in rather than clobber, so
     * a transient CLI init that omits a known scope won't wipe it.
     *
     * The CLI reports `memory_paths` on every `system/init` event; the payload
     * is stable within a session and only changes if e.g. the operator moved
     * the profile directory. Callers should not filter — we take whatever the
     * CLI gives us.
     */
    recordMemoryPaths(paths: Record<string, unknown>): void;
    /**
     * Record a CLI `system/memory_recall` event. We keep a rolling ring of
     * the most recent N so operator surfaces can show what the CLI has been
     * pulling into context. Stores path/scope metadata only — any
     * `synthesize`-mode content is deliberately dropped (it can be large
     * and is already fed to the model by the CLI).
     */
    recordMemoryRecall(event: {
        mode?: string;
        memories: MemoryRecallItem[];
    }): void;
    /**
     * Snapshot of the observed CLI auto-memory state. Returns a shallow copy
     * so callers can't mutate internal state. Safe to call from /obs and
     * /tasks even when no memory activity has been seen yet — `paths` will
     * simply be empty.
     */
    getMemoryStatus(): MemoryStatus;
    getTaskDescription(): string;
    getTaskElapsedMs(): number | null;
    getRecentActions(): string[];
    /**
     * Produce a concise summary of the agent's current activity for the fast
     * responder's system context.
     */
    getSummary(): string;
    clear(): void;
    private push;
    private pushExchange;
    /**
     * Bound the subagent map. Running subagents are never evicted — only
     * already-completed ones age out when we exceed the cap. This protects
     * both against runaway growth and against losing in-flight progress
     * for long-running tasks.
     */
    private pruneCompletedSubagents;
}
/**
 * Render a one-line summary of a subagent for `/tasks` and status surfaces.
 * Kept at module scope so it can be reused by command handlers that want
 * a consistent presentation (e.g. /tasks).
 */
export declare function formatSubagentLine(progress: SubagentProgress): string;
//# sourceMappingURL=activity-tracker.d.ts.map