ptuf 0.1.0

PreToolUseFilter: a generic guardrail layer for coding agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Shared helpers for agent-specific input adapters.

use serde_json::{Map, Value};

/// Remove the first key in `keys` whose value is a JSON string and
/// return the owned string. Used by the Copilot and Kiro adapters to
/// promote alias keys (e.g. `cmd`/`script` → `command`) into the
/// canonical input shape consumed by the engine.
pub(super) fn take_first_string(args: &mut Map<String, Value>, keys: &[&str]) -> Option<String> {
    for key in keys {
        if let Some(Value::String(s)) = args.remove(*key) {
            return Some(s);
        }
    }
    None
}