/** * Pain Hook — PRI-326 decomposed * * After-tool-call hook that captures tool failures and emits pain signals. * * Pipeline stages (delegated to after-tool-call-helpers): * 1. classifyToolCallOutcome — determine failure/success + source * 2. buildToolCallObservation — normalize event into observation * 3. handleFrictionTracking — GFI, event log, trajectory recording * 4. handleProbationFeedback — probation attribution + cleanup * 5. evaluatePainAdmission — triage + gate evaluation * 6. emitPainIfAdmitted — pain signal emission * * The manual pain path (toolName === 'pain') remains inline because it * has a different control flow (early return, no triage, no gate on cooldown). */ import { WorkspaceContext } from '../core/workspace-context.js'; import type { EvolutionLoopEvent } from '../core/evolution-types.js'; import type { PluginHookAfterToolCallEvent, PluginHookToolContext, OpenClawPluginApi } from '../openclaw-sdk.js'; import type { ProductionPainEnrichment } from '@principles/host-runtime'; import type { HostEventResult } from '@principles/core/host'; import { buildTrajectoryEvidence } from './trajectory-evidence.js'; export { buildTrajectoryEvidence }; /** * Host-owned best-effort continuation after durable shared persistence. * The hook may return once SQLite commits, while rejections remain observable * and tests/shutdown code can explicitly drain scheduled work. */ export declare function schedulePainContinuation(workspaceDir: string, continuation: Promise): void; export declare function drainPainContinuationsForTest(): Promise; export declare function emitPainDetectedEvent(wctx: WorkspaceContext, event: EvolutionLoopEvent, options?: { recordObservability?: boolean; }): Promise; /** * Handle after_tool_call hook — decomposed into pipeline stages. * * Pipeline: classify → record → triage → gate → emit * * Manual pain (toolName === 'pain') is handled inline with early return. */ export declare function handleAfterToolCall(event: PluginHookAfterToolCallEvent, ctx: PluginHookToolContext & { workspaceDir?: string; pluginConfig?: Record; }, api?: OpenClawPluginApi): void; /** * OpenClaw-owned enrichment for the shared ordinary after-tool kernel. * Session/GFI, event-log, probation, PROFILE and hygiene behavior stays here; * the shared runtime owns classification/admission and the atomic trajectory write. */ export declare function prepareOrdinaryAfterToolCallForSharedRuntime(event: PluginHookAfterToolCallEvent, ctx: PluginHookToolContext & { workspaceDir: string; pluginConfig?: Record; }): ProductionPainEnrichment; /** Restore OpenClaw-owned pain UX/diagnosis after the shared atomic evidence write. */ export declare function handleSharedPainEvidenceResult(event: PluginHookAfterToolCallEvent, ctx: PluginHookToolContext & { workspaceDir: string; }, result: HostEventResult): void;