/** * After-Tool-Call Decomposition Helpers — PRI-326 * * Extracted functions from handleAfterToolCall that implement * individual pipeline stages. Each function has a focused responsibility. * * Pipeline order: classify → record → triage → gate → emit * * ERR checklist: * - ERR-001: No `as` casts on untrusted runtime values. * - ERR-002: Every skip/rejection includes structured reason + nextAction. * - EP-01: Runtime values validated before use. * - EP-03: No silent failures — every path is logged or structured. */ import { normalizeProfile } from '../core/profile.js'; import { type SessionState } from '../core/session-tracker.js'; import { WorkspaceContext } from '../core/workspace-context.js'; import type { PluginHookAfterToolCallEvent } from '../openclaw-sdk.js'; import type { ToolCallOutcome, ToolCallObservation, PainAdmissionDecision } from './after-tool-call-types.js'; /** * Extract a preview string from tool call result for diagnostic evidence. * Pure function — no I/O, no side effects. ERR-001 / ERR-014 compliant. */ export declare function extractToolResultPreview(result: unknown): string | null; /** * Classify the outcome of a tool call event. * * Pure function — no I/O, no side effects. * Extracts exitCode logic, determines failure/success, classifies failure source. */ export declare function classifyToolCallOutcome(event: PluginHookAfterToolCallEvent): ToolCallOutcome; /** * Build a normalized observation from the tool call event and workspace context. * * Combines file path normalization, risk classification, and error analysis. * The profile parameter is passed in (loaded once at function scope). */ export declare function buildToolCallObservation(event: PluginHookAfterToolCallEvent, outcome: ToolCallOutcome, workspaceDir: string, profile: ReturnType): ToolCallObservation; /** * Handle friction tracking for a tool failure. * * Updates GFI, records to event log and trajectory. * Returns the updated session state and friction info. */ export declare function handleFrictionTrackingForFailure(sessionId: string, event: PluginHookAfterToolCallEvent, outcome: ToolCallOutcome, observation: ToolCallObservation, gfiBefore: number, workspaceDir: string, config: { get: (key: string) => unknown; }, wctx: WorkspaceContext, options?: { recordTrajectory?: boolean; }): SessionState; /** * Handle friction relief and recording for a tool success. * * Relieves both tool_failure and dispatch_error GFI sources proportionally. */ export declare function handleFrictionTrackingForSuccess(sessionId: string, event: PluginHookAfterToolCallEvent, outcome: ToolCallOutcome, observation: ToolCallObservation, gfiBefore: number, workspaceDir: string, wctx: WorkspaceContext, options?: { recordTrajectory?: boolean; }): SessionState; /** * Record hygiene tracking for memory/plan persistence actions on success. */ export declare function recordHygieneTracking(event: PluginHookAfterToolCallEvent, observation: ToolCallObservation, wctx: WorkspaceContext): void; /** * Record probation feedback for injected probation IDs. * * On success: positive feedback for matching principles. * On failure: negative feedback for matching principles. */ export declare function handleProbationFeedback(sessionId: string, toolName: string, workspaceDir: string, wctx: WorkspaceContext, isSuccess: boolean): void; /** * Evaluate whether a tool failure should trigger pain diagnosis. * * PRI-363: Single-gate architecture — only TriggerController decides. * * Combines: * 1. Write-tool check — only write tools on failures enter this path * 2. PEAT-B1 triage — evidence triage (always enabled now) * 3. PEAT-B2 trigger controller — single source of truth for task creation * 4. Cooldown tracking — plugin layer owns this state * * Returns a structured decision with reason and stage. */ export declare function evaluatePainAdmissionForToolCall(event: PluginHookAfterToolCallEvent, observation: ToolCallObservation, outcome: ToolCallOutcome, latestFailureState: SessionState | undefined, sessionState: SessionState | undefined, sessionId: string, workspaceDir: string, _config: { get: (key: string) => unknown; }): PainAdmissionDecision; /** * Emit pain signal after admission. * * Records to trajectory, event log, principle value tracker, * and emits the pain_detected event. * * Only called when the admission decision is 'admitted'. */ export declare function emitPainIfAdmitted(wctx: WorkspaceContext, event: PluginHookAfterToolCallEvent, observation: ToolCallObservation, outcome: ToolCallOutcome, admission: PainAdmissionDecision, sessionId: string, agentId: string | undefined, workspaceDir: string, emitPainDetectedEvent: (wctx: WorkspaceContext, event: import('../core/evolution-types.js').EvolutionLoopEvent, options?: { recordObservability?: boolean; }) => Promise): void; export { buildTrajectoryEvidence } from './trajectory-evidence.js'; /** * Reset trigger cooldown state (for tests). * PRI-454: Delegates to shared cooldown Map reset. */ export declare function resetTriggerCooldownForTest(): void;