/** * Rule Host Input Builder — Pure action snapshot construction (PRI-439 Phase 3) * * PURPOSE: Provide a single pure function that both Golden Trace replay and * the production OpenClaw Gate use to construct the `action` field of * RuleHostInput. This eliminates the divergence where Golden Trace produced * `normalizedPath: null` while production produced a non-null string. * * ARCHITECTURE: Pure logic — no node:path, no node:fs, no platform-dependent * APIs. Path normalization is implemented via manual string operations, * following the pattern established in correction-proposal.ts. * * The 6 path types handled: * 1. Absolute POSIX (/project/src/index.ts, /project) * 2. Absolute Windows (D:\project\src\index.ts, D:\project) * 3. Relative bare (src/index.ts, /project) * 4. Relative ./ (./src/index.ts, /project) * 5. Relative ../ (../src/index.ts, /project) — escapes project * 6. Empty/null (null / '' / undefined, /project) */ import type { RuleHostInput } from './rule-host-contracts.js'; import type { CanonicalKind } from './rule-context-v2.js'; /** * Normalize a file path to a project-relative POSIX-style path. * * Returns '' for empty/null/undefined input. * Returns the original path (with separators normalized to /) if the path * escapes the project directory (starts with ../ after relativization). * * This function is deterministic — the same inputs produce the same output * regardless of the host platform. */ export declare function normalizePathPure(filePath: string | null | undefined, projectDir: string): string; export interface ExtractFilePathOptions { /** Whether the tool is a write/edit tool (triggers synthetic path). */ isWriteTool?: boolean; /** Whether the tool is a bash tool (triggers command mutation regex). */ isBashTool?: boolean; /** The tool name (used for synthetic path generation). */ toolName?: string; /** * PRI-634-F: canonical kind from the ToolSemanticRegistry. When provided, * unspecified isBashTool/isWriteTool hints are DERIVED from it * (execute→isBashTool, write→isWriteTool) so extraction behavior is a pure * function of (toolName, params, projectDir, registry) — identical in * replay and production. Explicit hints keep precedence for callers that * classify with their own host dispatch surface. */ canonicalKind?: CanonicalKind; } /** * Extract the file path from tool call params, using the same heuristic * as the production OpenClaw Gate (gate.ts). * * Extraction order: * 1. params.file_path || params.path || params.file || params.target * 2. Bash command mutation regex (for bash tools without a file_path) * 3. Synthetic (for write tools without any path) * * Returns null if no path can be extracted. */ export declare function extractFilePathFromParams(params: Record, options?: ExtractFilePathOptions): string | null; export type BuildRuleHostActionOptions = ExtractFilePathOptions; /** * PRI-634-F Phase 2: derive extraction hints from a canonical kind. * execute → bash-tool extraction; write → write-tool synthetic path; all * other kinds → no tool-specific extraction. Pure, total. */ export declare function deriveToolHintsFromCanonicalKind(canonicalKind: CanonicalKind): { isBashTool: boolean; isWriteTool: boolean; }; /** * Build the `action` field of RuleHostInput — the unified snapshot used by * both Golden Trace replay and the production OpenClaw Gate. * * This function combines file path extraction + path normalization into a * single pure call, ensuring both paths produce the same `normalizedPath`. * When `options.canonicalKind` is provided it is echoed onto the action * snapshot and drives hint derivation (see ExtractFilePathOptions). */ export declare function buildRuleHostAction(toolName: string, params: Record, projectDir: string, options?: BuildRuleHostActionOptions): RuleHostInput['action']; //# sourceMappingURL=rule-host-input-builder.d.ts.map