/** * Tool metadata capture handler with per-tool pruning rules. * * Handles `tool.execute.after` hook events from OpenCode. Applies * SPEC.md Section 5.1 capture rules for each tool type: * * - **skill**: captures skill name + first `#` header line only (REQ-ST-04) * - **read**: captures file path only, NEVER file content (REQ-ST-05) * - **task**: captures delegation metadata + triggers child `.json` creation (REQ-ST-06) * - **other**: captures tool name and callID only (metadata safe) * * All handlers are best-effort — errors are logged, never thrown. * * @module session-tracker/capture/tool-capture */ import type { SessionWriter } from "../persistence/session-writer.js"; import type { ChildWriter } from "../persistence/child-writer.js"; import type { SessionIndexWriter } from "../persistence/session-index-writer.js"; import type { ProjectIndexWriter } from "../persistence/project-index-writer.js"; import type { HierarchyIndex } from "../persistence/hierarchy-index.js"; import type { SessionRouter } from "../session-router.js"; import type { PendingDispatchRegistry } from "../persistence/pending-dispatch-registry.js"; import type { OpenCodeClient } from "../../../shared/session-api.js"; /** Shape of the tool.execute.after hook input. */ interface ToolInput { tool: string; sessionID: string; callID: string; args: unknown; } /** Shape of the tool.execute.after hook output. */ interface ToolOutput { title?: string; output?: unknown; metadata?: unknown; } /** * Captures tool execution metadata from the `tool.execute.after` hook. * * Applies per-tool pruning rules to keep session knowledge files focused * and avoid capturing sensitive or excessive data. */ export declare class ToolCapture { private client; private sessionWriter; private childWriter; private sessionIndexWriter; private projectIndexWriter; private hierarchyIndex; private pendingRegistry; private sessionRouter; /** * @param deps - Injected dependencies. * @param deps.client - The OpenCode SDK client for logging. * @param deps.sessionWriter - The main session writer for .md output. * @param deps.childWriter - The child session writer for .json delegation files. * @param deps.sessionIndexWriter - The session-local index writer. * @param deps.projectIndexWriter - The project-level index writer. */ constructor(deps: { client: OpenCodeClient; sessionWriter: SessionWriter; childWriter: ChildWriter; sessionIndexWriter: SessionIndexWriter; projectIndexWriter: ProjectIndexWriter; hierarchyIndex: HierarchyIndex; sessionRouter: SessionRouter; pendingRegistry?: PendingDispatchRegistry; }); /** * Handles a tool.execute.after hook event. * * @param input - Hook input containing tool name, sessionID, callID, and args. * @param output - Hook output containing title, output, and metadata. * @returns Promise that resolves when the tool invocation has been captured. */ handleToolExecuteAfter(input: ToolInput, output: ToolOutput): Promise; /** * Captures a skill tool invocation. * * Input: captures `args.name` (the skill name). * Output: captures only the first `#` header line, if present (REQ-ST-04). * * @param input - The hook input. * @param output - The hook output. */ private handleSkill; /** * Captures a read tool invocation. * * Input: captures `args.filePath` (the file path). * Output: NEVER captures file content — only the path (REQ-ST-05). * If the output indicates an error, the error message is captured. * * @param input - The hook input. * @param output - The hook output. */ private handleRead; /** * Captures a task tool invocation — the authoritative delegation signal. * * Input: captures `args.description` and `args.subagent_type`. * Output: extracts `task_id` from output to create the child `.json` file * and update both continuity indices (REQ-ST-06, D-04). * * @param input - The hook input. * @param output - The hook output. */ private handleTask; /** * Captures unknown tool invocations as metadata only. * * Only the `callID` is captured — no args or output content. * This prevents sensitive tool output from being captured verbatim. * * @param input - The hook input. */ private handleOther; private extractFirstHeader; private extractTaskId; private extractTaskResult; } export {}; //# sourceMappingURL=tool-capture.d.ts.map