Repository navigation
Conversation
The Hermes plugin applied rewrites by mutating the caller's `args` dict in
place. That only happens to work: Hermes' `_pre_tool_block` returns the same
object it passed to the hook, so argument identity carries the change. The
documented and tested hook contract is different — a callback returns
`{"action": "modify", "args": {...}}` and Hermes shallow-merges it, which also
makes the rewrite visible to the plugin ledger.
Return that directive and leave the incoming payload untouched. Fail-open
behaviour and the exit-code handling are unchanged; the plugin tests now assert
the returned directive and that `args` is not mutated.
Two problems stopped the plugin from ever running in a Gateway: 1. `openclaw plugins install ./openclaw` is refused with "package.json missing openclaw.extensions", and fixing that surfaces a second refusal: package installs require compiled JavaScript (`expected ./dist/index.js`) — a TypeScript entry only loads for source checkouts via `--link`, which the Gateway does not pick up either. 2. With no `activation` block in the manifest, OpenClaw never imports the plugin at Gateway startup (since 2026.9.2 `onStartup` is no longer implicit), so the `before_tool_call` hook is never registered — while `openclaw plugins list` and `openclaw plugins doctor` both report the plugin as enabled and healthy. Add a `tsc` build (`npm run build` -> `dist/index.js`), point `main`, `openclaw.extensions` and the published `files` at it, emit the built artifact so installing straight from the repo works, and declare `activation.onStartup: true` plus the `before_tool_call` hook in the manifest. Verified on OpenClaw 2026.9.2: the Gateway's startup plugin list goes from 17 to 18 entries with `rtk-rewrite` included after the change, and an `exec` turn returns RTK's compact output with the command tracked by `rtk gain`.
The OpenClaw install steps were missing the build step, and neither the README nor the supported-agents page mentioned that `activation.onStartup` is what makes the Gateway import the plugin, or that `rtk rewrite` reads its allow/ask/deny verdict from Claude Code `Bash()` permission rules — without matching allow rules every rewrite becomes an approval request that is denied on timeout in an unattended agent. Also correct the Hermes section: the plugin returns a `modify` directive rather than mutating the tool payload.
|
Rik seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
📊 Automated PR Analysis
SummaryFixes two broken agent integrations: the Hermes rtk-rewrite plugin now returns Hermes' documented Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
KuSh
left a comment
There was a problem hiding this comment.
Round 1 — CHANGES REQUESTED
Claim: the bundled OpenClaw plugin installs with openclaw plugins install ./openclaw and is loaded by the Gateway at startup; the Hermes plugin returns a modify directive.
Scope: accept if narrowed to "the OpenClaw plugin installs with openclaw plugins install ./openclaw and is loaded at Gateway startup". The Hermes commit (5d4fa42) is the change under review in #3833, opened earlier; please drop it from this PR so that discussion stays in one place.
Ran: OpenClaw 2026.8.35, 2026.9.2, 2026.9.6 and 2026.10.3, with plugin trees from develop (f16beca), #4373, this head (322aefb), this head merged onto develop, the merge with dist/ rebuilt from develop's index.ts, and the merge without activation. Each tree was installed by copy, by --link, and by develop's README manual copy (32 install rows). Then a real Gateway agent turn ran with a stub OpenAI-compatible model that issues one exec git status in a scratch repo, against a real rtk built from develop, with no Claude Code settings and with a Bash(git status) deny rule (25 rows). Invariants: every decision; non-default targets (4 releases × 3 install forms). Savings 79% (207 → 44 bytes on git status) vs the 20% floor (CONTRIBUTING.md).
Pins: 4 decisions; 3 mutated, 3 survived (activation, the compiled extensions entry, the dist/ content). The 4th, the manifest hooks field, has no observable effect: #4373's tree omits it and its hook fires on all four releases.
Matrix: executed this round; pin check: executed this round
CI @322aefbdf: the CI run is waiting for workflow approval, and no workflow builds or tests openclaw/ (#4588). This verdict rests on the matrix above.
Blocks merge (2, frozen at round 1)
-
openclaw/package.json:24: committed build output drifts from its source (1 artifact, 1 source; nothing ties the two). Since this branch was cut, develop changedopenclaw/index.tsin c6f484f, the #3908 fix: it passesRTK_REWRITE_HOST=openclaw, so a command that matches no Claude Code rule no longer raises an approval. The committeddist/index.jsis byte-identical totscof the pre-#3908 file, and bothmainandopenclaw.extensionspoint at it. So once this PR is merged onto develop, OpenClaw loads the old code.
Evidence, merged tree, copy install, no Claude Code settings, agent turnexec git status:- On all four releases the tool returns
{"status":"error","tool":"exec","error":"Plugin approval unavailable (no approval route)"}and the command does not run. This head on its own branch gives the same result. - The same tree with
dist/rebuilt from develop'sindex.tsreturns* No commits yet on master\n?? a.txt\n?? b.txton all four, andrtk gainrecords it. - With the deny rule, both block (
RTK deny rule matched).
Nothing keeps the two in step: no CI job, script or test reads
openclaw/, and #4044 and #4372 (open) edit onlyindex.ts. The new "Allow rules for headless agents" README section, and the matching sentence insupported-agents.md, document this pre-#3908 behaviour as expected. Git merges the README without a conflict, so after merge it says both that and develop's "does not prompt for a command that matched no rule" (lines 51-56 vs 90).
A fix passes the rows above on the merged tree: an unmatched command gives RTK output with no approval, and a deny rule still blocks. It must also make it impossible for anindex.tschange without a rebuild to reach users unnoticed. Which shape do you prefer?- (a) Keep
dist/committed and add a check that fails when it differs fromtscofindex.ts. That needs a node step in CI, which nothing provides today (#4588). - (b) Stop committing
dist/: gitignore it, build it from apreparescript, and keep the README build step.
Either way, the allow-rules paragraphs go when you rebase.
- On all four releases the tool returns
-
openclaw/openclaw.plugin.json:8: unpinned behaviour (startup activation, compiled entry). Evidence: removingactivation, pointingopenclaw.extensionsback at./index.tsand deletingdist/index.jstogether still passes 4953/4954 tests across 49 binaries. The one failure,go_test_help_is_not_replayed_through_the_injected_json, fails the same way unmutated. Each of these changes matters on a real Gateway:- Without
activation, the plugin is missing from the Gateway's startup plugin list and rawgit statusruns, on all four releases, 2026.8.35 included. - With a
./index.tsentry, a copy install is refused:package install requires compiled runtime output for TypeScript entry ./index.ts.
The test must read
openclaw/openclaw.plugin.jsonandopenclaw/package.jsonand assertactivation.onStartup == trueand that everyopenclaw.extensionsentry is an existing.jsfile. Under (a), it must also assert thatdist/matches its source. Each of the three edits above must turn it red. - Without
Optional (won't hold merge)
- Following the README (
npm install,npm run build, then a copy install) putsnode_modules/into~/.openclaw/extensions/rtk-rewrite/: 25 MB oftypescriptand@types/node, on 2026.9.2 and 2026.10.3.filesonly filtersnpm pack, not a directory install. - The manifest
hooks: ["before_tool_call"]can stay or go: it changes nothing on the four releases tried.
Relation to #4373
| this PR | #4373 | |
|---|---|---|
openclaw plugins install ./openclaw (the documented form) |
installs and loads on all four releases | refused on all four (TypeScript entry needs compiled output) |
--link install |
installs and loads | installs and loads; hook rewrites, deny blocks |
| code OpenClaw loads | committed dist/ (stale once merged, item 1) |
index.ts directly, cannot drift |
| docs | install, build, activation | none |
This PR is the one that makes the documented install work, and it covers both fields #4373 adds. Once it lands, #4373 has nothing left to add.
Checked and correct — no need to re-verify
activation.onStartup: trueis required for the Gateway to import the plugin on 2026.8.35, 2026.9.2, 2026.9.6 and 2026.10.3. (The description says "since 2026.9.2"; 2026.8.35 needs it too.)- A compiled
.jsentry inopenclaw.extensionsis required for a copy install on all four releases;--linkacceptsindex.ts. --accept-capabilitiesis accepted byplugins installon all four releases.- The committed
dist/index.jsis exactly whattscproduces from this branch's ownindex.ts. The build is honest; it is the base that moved. - Rebuilt from develop's
index.ts, the compiled plugin rewrites, records inrtk gain, and blocks on a deny rule.
Your questions
None asked.
Next
Drop the Hermes commit and rebase onto develop: .gitignore and supported-agents.md conflict. Take develop's OpenClaw permission text and drop the allow-rules paragraphs. Then fix item 1 in shape (a) or (b) and add the test in item 2.
The CLA also needs to be signed before this can merge: license/cla is still pending. The commits are authored as "Rik" with an email that is not linked to your GitHub account, so the CLA check cannot match them to you. Add that email to your account (or re-author the commits with one that is), then sign through the link in the license/cla check. After that, this merges.
Rounds: 1. Threads: 2 open (waiting on the author), 0 resolved this round.
| ], | ||
| "openclaw": { | ||
| "extensions": [ | ||
| "./dist/index.js" |
There was a problem hiding this comment.
OpenClaw loads this file, and it is tsc of the index.ts this branch started from. develop has changed index.ts since (c6f484f, #3908). Merged onto develop, a copy install with no Claude Code settings turns an agent's exec git status into Plugin approval unavailable (no approval route) on OpenClaw 2026.8.35, 9.2, 9.6 and 10.3. With dist/ rebuilt from develop's index.ts, the same turn returns RTK's output. Nothing rebuilds or checks dist/. Details and the two possible shapes are in the review body, item 1.
| "description": "Transparently rewrites shell commands to their RTK equivalents, cutting up to 90% of the bash output reaching the LLM context", | ||
| "homepage": "https://github.com/rtk-ai/rtk", | ||
| "license": "Apache-2.0", | ||
| "activation": { |
There was a problem hiding this comment.
Without this block the Gateway never imports the plugin, on all four releases I tried. Removing it, pointing openclaw.extensions at ./index.ts and deleting dist/index.js all at once still passes the whole suite. A test that reads the two manifests and asserts activation.onStartup and a .js entry that exists would catch all three. See item 2.
Summary
Two agent integrations could not actually run, and one used an undocumented hook path.
_pre_tool_blockhappens to return the same object it passed to the hook; Hermes' documented and tested contract is the{"action": "modify", "args": {...}}directive, which is also what the plugin ledger records. Returns the directive now; tests assert the directive and that the incomingargsis untouched.openclaw plugins install ./openclawis refused for a missingopenclaw.extensions; after adding that it is refused again because package installs require compiled JS (a TypeScript entry only loads for--linksource checkouts). Worse, with noactivationblock the Gateway never imports the plugin at all (since 2026.9.2onStartupis no longer implicit) — whileopenclaw plugins listandopenclaw plugins doctorstill report it enabled and healthy. Adds atscbuild, pointsmain/openclaw.extensions/filesatdist/index.js, commits the built artifact, and declaresactivation.onStartup: trueand thebefore_tool_callhook..gitignorelearnsnode_modules/.Worth knowing for anyone testing this:
rtk rewritetakes its allow/ask/deny verdict from Claude CodeBash()permission rules. With no matching allow rule every rewritable command returns "ask", which the OpenClaw plugin turns into an approval request denied on timeout — an unattended agent stalls or blocks on nearly every command. That is documented in the README change, not altered here.Test plan
python3 -m unittest discover -s hooks/hermes— 18 tests, 17 pass. The single failure istest_cargo_init_installs_importable_plugin_that_rewrites_with_fake_rtk, which shells out tocargoand cannot build on a host with cargo 1.75 (repo requires edition 2024); it fails identically before and after these commits.cd openclaw && npm install && npm run build— emitsdist/index.jscleanly.dist/index.jsthrough a stub OpenClaw plugin API against a realrtkbinary:git status→rtk git status(params rewritten, no approval once an allow rule exists), unsupported commands and non-exectools untouched.rtk-rewritein it (before the fix the same install produced 17 with nortk-rewrite), and a liveexecturn returned RTK's compact output withrtk gainrecording the command.cargo fmt --all && cargo clippy --all-targets && cargo test— not run here (no edition-2024 toolchain on this host); no Rust source is touched by this PR apart from.gitignore.rtk <command>output inspected — unchanged by this PR.