/** * Security Gate Hook - Rule Host Only * * This is the SINGLE AUTHORITATIVE orchestration path. * All blocking logic is now dynamic via Rule Host — no hardcoded gates remain. * * Flow: * 1. Early Return: Skip if not write/bash/agent tool or no workspace * 2. Rule Host: Dynamic principle-based evaluation (sole gate) */ import { WorkspaceContext } from '../core/workspace-context.js'; import type { RuleContextV2 } from '@principles/core/runtime-v2'; import type { PluginHookBeforeToolCallEvent, PluginHookToolContext, PluginHookBeforeToolCallResult, PluginLogger } from '../openclaw-sdk.js'; import type { HostEventResult } from '@principles/core/host'; export declare function handleBeforeToolCall(event: PluginHookBeforeToolCallEvent, ctx: PluginHookToolContext & { workspaceDir?: string; pluginConfig?: Record; logger?: Partial; }): PluginHookBeforeToolCallResult | void; export declare function buildOpenClawRuleInputEnrichment(event: PluginHookBeforeToolCallEvent, workspaceDir: string, sessionId: string | undefined): { currentGfi: number; epTier: number; bashRisk: "dangerous" | "normal" | "safe" | "unknown"; }; /** * PRI-483 Phase 4 — Build RuleContextV2 for RuleHost.evaluate when the * `rulecode_context_v2` feature flag is ON. Returns `undefined` when the flag * is OFF (v1 zero-change — does NOT touch trajectory) or when config loading * fails (conservative fail-soft: can't determine flag state → v1-style). * * ERR-024 prevention: context assembly failures never skip RuleHost.evaluate. * - loadPdConfigForPlugin throws → return undefined (v1-style) * - buildProductionRuleContext throws → return UNAVAILABLE_RULE_CONTEXT * (structured unavailable so v2 rules see "context unavailable" and allow) * * Spec: docs/superpowers/specs/2026-06-27-rulecode-context-vision-design.md §5.3 */ export declare function buildRuleContextIfEnabled(wctx: WorkspaceContext, targetPath: string, sessionId: string | undefined, logger: { warn?: (msg: string) => void; } | undefined): RuleContextV2 | undefined; export declare function handleSharedRuleHostResult(event: PluginHookBeforeToolCallEvent, ctx: PluginHookToolContext & { workspaceDir: string; logger?: Partial; }, result: HostEventResult): void; /** * Authoritative accounting for ONE shared-path deny decision (PRI-569). * * Both shared-handler deny branches (resolvable and unresolved target path) * funnel here: receipt-ledger effect row (flag-gated, failure-degrading — * parity with the legacy hook path) plus persistGateBlock (session GFI, * EventLog gate_block, trajectory gate_blocks with bounded retry). A null * filePath is accounted with a null trajectory file_path; the EventLog copy * carries an '' placeholder. Never throws into the caller; * every skip/failure warns with a reasonCode (rc-9). */ export declare function accountSharedDeny(wctx: WorkspaceContext, accounting: { sessionId?: string; toolName: string; filePath: string | null; reason: string; ruleId?: string; principleId?: string; }, logger: { warn?: (_message: string) => void; error?: (_message: string) => void; }): void;