/** * AGT-02 Fail-Fast Policy (SPEC §3.3) — tool-output safety invariant. * * Mirrors `edge-client/src/session/fail_fast.rs` 1:1. The edge-client's core * doctrine is "TRUST PI, TRANSPORT 100%": it forwards every pi event verbatim * and does not second-guess pi's reasoning. AGT-02 adds ONE scoped exception: * it inspects pi's **tool execution OUTPUT** (not pi's reasoning/text) for * forbidden OS-policy keywords. When a tool result contains "Access Denied" * / "AppLocker" / "Permission denied", the agent reasoning loop is aborted * immediately and an error is reported to the server, so pi cannot auto-seek * alternative methods that would violate the organization's internal security * policy. * * This does NOT break transport-100%: the triggering event is still forwarded * unchanged — the wrapper only ADDS an abort + a synthetic `error` event. * * Disable for pure-trust mode via `EDGE_FAIL_FAST=0` (or `EDGE_FAIL_FAST=false`). */ /** * Forbidden keywords per SPEC §3.3 AGT-02. Matched case-insensitively as * substrings of the concatenated tool-output text. * Mirror of Rust `fail_fast::FORBIDDEN_KEYWORDS`. */ export declare const FORBIDDEN_KEYWORDS: readonly string[]; /** * Pi event types whose payload may carry tool OUTPUT worth inspecting. * We deliberately do NOT inspect reasoning/text events (`message_update`, * `message_end`, ...) — only concrete tool execution results, so the policy * acts on what a tool actually returned, never on pi's narration. * Mirror of Rust `fail_fast::INSPECTABLE_EVENT_TYPES`. */ export declare const INSPECTABLE_EVENT_TYPES: readonly string[]; /** * Synthetic error content emitted on fail-fast. Wording matches SPEC §3.3. * Mirror of Rust `fail_fast::FAIL_FAST_ERROR_CONTENT`. */ export declare const FAIL_FAST_ERROR_CONTENT = "Permission Denied: OS Blocked"; /** Env var name (mirror of Rust `fail_fast::fail_fast_enabled`). */ export declare const ENV_FAIL_FAST = "EDGE_FAIL_FAST"; /** * Forbidden COMMAND patterns — destructive shell commands that should NEVER * be executed by an unverified tool call, regardless of the operator's * intent. Matched case-insensitively as substrings of the concatenated * string args of a `tool_execution_start` event. * * FIX (2026-07-14, F-11): previously the TS client only had the output-side * detector. A successful `rm -rf /home` that doesn't echo "Permission denied" * would slip through. This command-side blocklist closes the gap when * opted in via `EDGE_FAIL_FAST_COMMAND_BLOCKLIST=1`. * * Mirror of Rust `fail_fast::FORBIDDEN_COMMAND_PATTERNS`. */ export declare const FORBIDDEN_COMMAND_PATTERNS: readonly string[]; /** Env var to opt into the COMMAND blocklist (default OFF; output scan is always on). */ export declare const ENV_FAIL_FAST_COMMAND_BLOCKLIST = "EDGE_FAIL_FAST_COMMAND_BLOCKLIST"; /** * Whether AGT-02 layer 2 (command blocklist) is enabled. Default OFF because * false positives on shell commands can break legitimate dev workflows. * Operators opt in via `EDGE_FAIL_FAST_COMMAND_BLOCKLIST=1`. * * Mirror of Rust `fail_fast::command_blocklist_enabled`. */ export declare function commandBlocklistEnabled(env?: NodeJS.ProcessEnv): boolean; /** * If `event_type` is `tool_execution_start` AND any of the * `FORBIDDEN_COMMAND_PATTERNS` appears (case-insensitive substring) in the * concatenated string args of `payload`, return the matched pattern. * Returns `null` otherwise (including for non-start events — output-side * detection is handled by `detectForbidden`). * * PURE — no env, no I/O; callers gate on `commandBlocklistEnabled()`. * * Mirror of Rust `fail_fast::detect_forbidden_command`. */ export declare function detectForbiddenCommand(eventType: string, payload: unknown): string | null; /** * Whether AGT-02 fail-fast is enabled. Default ON per SPEC. Disable with * `EDGE_FAIL_FAST=0` (or `false`) for pure trust-pi mode (legacy). * * Mirror of Rust `fail_fast_enabled()`. Reads `process.env` directly — keep * the option to pass a custom env in for testability. */ export declare function failFastEnabled(env?: NodeJS.ProcessEnv): boolean; /** * If `event_type` is an inspectable tool-execution event AND its payload text * contains a forbidden keyword, return that keyword (the FIRST match, in the * order defined in `FORBIDDEN_KEYWORDS`). Returns `null` otherwise. * * PURE — no env, no I/O; callers gate on `failFastEnabled()` separately so * the detection logic is unit-testable deterministically. * * Mirror of Rust `fail_fast::detect_forbidden`. */ export declare function detectForbidden(eventType: string, payload: unknown): string | null; /** * Build the synthetic error event the wrapper emits on fail-fast. The shape * matches a pi `error` event (payload can be forwarded over `/edge` exactly * like any other event — transport-100% preserved). * * Mirror of the synthetic-event construction in `fail_fast.rs::on_tool_event` * (the Rust side builds the same `{type:"error", content:FAIL_FAST_ERROR_CONTENT}`). */ export declare function buildSyntheticErrorEvent(): { type: 'error'; content: string; };