Repository navigation
feat(cli): tole hook add|list|remove|test (#582 part 3) - #648
Merged
Merged
Conversation
Webhook routes are added to the user config only (never a project one), checked with the loader tole serve uses. The key is named by --key-env or --key-file, never given on the command line and never printed. Widening a route (allow_writes, insecure_loopback, filters) stays a manual edit. list shows job, events, filter shape and writes, no key source. test is a local dry run that signs, filters and prints the fenced, redacted context; --fire posts the signed delivery to a loopback tole serve only.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 3 of #582:
tole hook add|list|remove|testand its docs. The end-to-end test showing that serve renders the template into a fired agent run's context is in a separate PR (#649), so this one stays under ~900 lines.Why
Before this PR, routes were edited into the user config by hand, and there was no way to check a route before a real delivery arrived. The commands make that safe:
testshows exactly what the fired run would see, without firing it.Changes
crates/tole-cli/src/hook_cli.rs(new), wired in astole hookundershell-toolswithGatePolicy::Skip, liketole cron.add ROUTE --key-env NAME | --key-file /abs/path [--job J] [--event E]... [--template T] [--rate-per-minute N] [--max-body-bytes N]:[hooks.ROUTE]section to the user config only, keeping the rest of the file and its comments, and writes through a temporary file and a rename;hooks::load, the loader serve uses, and checks that the result round-trips through the config parser.allow_writes,insecure_loopbackand the filter have no flag. Widening a route stays a manual edit, as design P8 says.listshows the job, events, filter shape (newhook_filter::summary: paths and operators, no values),writes: yes|noandsignedorinsecure. It shows no key, no key variable and no key file.remove ROUTEcuts[hooks.ROUTE]and[hooks.ROUTE.*]and keeps the rest. It refuses ("edit by hand") if the route is still there afterwards, for example when it is written as an inline table.test ROUTE [--payload FILE] [--event E]is a local dry run:--fire --url http://127.0.0.1:PORTposts the signed delivery to a running serve, which uses the real claim path. Only loopbackhttp://URLs are accepted (127/8,[::1],localhost).tests/hook_cli.rs(new): 5 tests on the real binary.[Unreleased], design §6 "as implemented, part 3", README usage lines, and a threat-model row.Testing
cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo test --workspacecargo test -p tole-core --no-default-featurescargo check -p tole-cli --no-default-featurescargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warningscargo test -p tole-cli --no-default-featurescora review --no-llm --staged: no issues.addaccepts no key source;adddrops the existing file (comments lost);listprints the key variable;listprints filter values;removeleaves[hooks.ROUTE.filter];testrenders with an empty secret set (no redaction);testskips the events check;--fireaccepts a non-loopback IP;--firesends a bad signature.