You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`placeholder.rs`| Placeholder parsing, generation, and resolution |`make_id()`, `resolve_placeholders()`|
52
53
|`redaction.rs`| JSON tree walker, notice injection |`walk_json_strings()`, `inject_redaction_notice()`|
@@ -87,6 +88,10 @@ Edit `src/launcher.rs` to extend the clap surface and subcommand dispatch, then
87
88
88
89
Edit `src/redaction.rs` → `inject_redaction_notice_with_mode()` and `src/config.rs` for `KEYCLAW_NOTICE_MODE`. The notice is injected differently for Anthropic (appended to `system` field) vs OpenAI (added as `developer` role message), and the shipped modes are `verbose`, `minimal`, and `off`.
89
90
91
+
### Adding or changing hooks
92
+
93
+
Edit `src/hooks.rs` for hook parsing/execution and `src/config.rs` for `[[hooks]]` config loading. Request-side hook dispatch is wired through `src/pipeline.rs`, with call sites in `src/proxy/http.rs`, `src/proxy/websocket.rs`, and `src/launcher.rs`.
94
+
90
95
## Important Patterns
91
96
92
97
### Placeholder format
@@ -125,6 +130,7 @@ All errors use `KeyclawError` with optional deterministic codes:
125
130
-`invalid_json` — JSON parse/rewrite failed
126
131
-`request_timeout` — request body read timed out before inspection completed
127
132
-`strict_resolve_failed` — placeholder resolution failed in strict mode
133
+
-`hook_blocked` — a configured hook rejected the request
128
134
129
135
Check errors with `code_of(&err)` to get the code string.
|`placeholder.rs`| Placeholder parsing, generation, and resolution |`make_id()`, `resolve_placeholders()`|
52
53
|`redaction.rs`| JSON tree walker, notice injection |`walk_json_strings()`, `inject_redaction_notice()`|
@@ -87,6 +88,10 @@ Edit `src/launcher.rs` to extend the clap surface and subcommand dispatch, then
87
88
88
89
Edit `src/redaction.rs` → `inject_redaction_notice_with_mode()` and `src/config.rs` for `KEYCLAW_NOTICE_MODE`. The notice is injected differently for Anthropic (appended to `system` field) vs OpenAI (added as `developer` role message), and the shipped modes are `verbose`, `minimal`, and `off`.
89
90
91
+
### Adding or changing hooks
92
+
93
+
Edit `src/hooks.rs` for hook parsing/execution and `src/config.rs` for `[[hooks]]` config loading. Request-side hook dispatch is wired through `src/pipeline.rs`, with call sites in `src/proxy/http.rs`, `src/proxy/websocket.rs`, and `src/launcher.rs`.
94
+
90
95
## Important Patterns
91
96
92
97
### Placeholder format
@@ -125,6 +130,7 @@ All errors use `KeyclawError` with optional deterministic codes:
125
130
-`invalid_json` — JSON parse/rewrite failed
126
131
-`request_timeout` — request body read timed out before inspection completed
127
132
-`strict_resolve_failed` — placeholder resolution failed in strict mode
133
+
-`hook_blocked` — a configured hook rejected the request
128
134
129
135
Check errors with `code_of(&err)` to get the code string.
Supported file sections today are `proxy`, `vault`, `logging`, `notice`, `detection`, `audit`, `hosts`, and `allowlist`. Use the file for steady-state local settings, then reach for env vars when you want a one-off override.
389
+
Supported file sections today are `proxy`, `vault`, `logging`, `notice`, `detection`, `audit`, `hosts`, `allowlist`, and `hooks`. Use the file for steady-state local settings, then reach for env vars when you want a one-off override.
372
390
373
391
Allowlist entries let you intentionally skip redaction for known-safe matches:
Hook entries let you trigger local side effects from request-side events without exposing the raw secret:
411
+
412
+
-`event = "secret_detected"` fires when a secret match is found during request rewriting
413
+
-`event = "request_redacted"` fires after a request has been rewritten, just before it is forwarded upstream
414
+
-`action = "exec"` runs a local command with sanitized metadata in env vars and a JSON payload on `stdin`
415
+
-`action = "log"` appends a JSON line to the configured file
416
+
-`action = "block"` rejects matching `secret_detected` requests with `hook_blocked`
417
+
418
+
Hook payloads include only `event`, `rule_id`, `placeholder`, and `request_host`. Raw secret values are never passed to hook commands or hook log files.
0 commit comments