Skip to content

fix(openclaw): make the rewrite plugin work end-to-end on OpenClaw 2026.6.x#2392

Closed
davidbordenwi wants to merge 1 commit into
rtk-ai:developfrom
davidbordenwi:fix/openclaw-plugin
Closed

fix(openclaw): make the rewrite plugin work end-to-end on OpenClaw 2026.6.x#2392
davidbordenwi wants to merge 1 commit into
rtk-ai:developfrom
davidbordenwi:fix/openclaw-plugin

Conversation

@davidbordenwi

Copy link
Copy Markdown

Summary

The OpenClaw plugin as shipped never rewrites anything on current OpenClaw (tested against 2026.6.5). This PR is the complete working set — four independent defects fixed together, verified end-to-end against live gateways. Fixes 1–3 overlap with open PRs #2202/#2220 (exit code 3), #2113 (TS build), and #1236/#1455 (extensions metadata) — credit to those authors; any one of them alone still leaves the plugin broken. Fix 4 is, as far as I can tell, not reported anywhere yet and is required even with 1–3 applied.

Closes #1810
Closes #944
Closes #1719

The four defects

  1. Exit-code protocolrtk rewrite signals a rewrite with exit code 3 (rewrite/ask) and the rewrite on stdout (per hooks/claude/rtk-rewrite.sh: 0+stdout allow-rewrite, 1 no-equivalent, 2 deny, 3+stdout ask-rewrite). execFileSync throws on non-zero exit, so tryRewrite returned null for every ask-classified rewrite — i.e. nearly always. Fixed by recovering status 3 + stdout from the thrown error, and passing through on 1/2 so the host's native deny policy still sees the original command.
  2. TypeScript entry — OpenClaw managed installs reject TS entry points ("compiled runtime output required"). Ship compiled index.js (types stripped, logic identical) with main pointing at it; index.ts stays as source.
  3. Missing openclaw.extensions — required in package.json for managed installs to register the entry point.
  4. Gateway startup activation intent (new) — OpenClaw 2026.6.x excludes hook-only installed plugins from the Gateway startup plugin plan unless the manifest declares activation intent. Without "activation": { "onCapabilities": ["hook"] }, the agent runtime's restricted plugin load silently skips the plugin: plugins inspect reports loaded and embedded CLI runs rewrite, but daemon-served agent turns never do. A daemon can even mask this intermittently — any unrestricted plugin-load event in the process (e.g. a subagent spawn) registers the hooks for the process lifetime, which makes the failure look nondeterministic across identically-configured gateways.

Verification

A/B against a throwaway local OpenClaw 2026.6.5 gateway: pre-fix, a daemon-served exec of ls -la <dir> returns raw output; post-fix the identical turn returns the rtk-compressed form, with the rewritten command recorded in rtk's gain history and the original command preserved in the session transcript (the host applies rewritten params at execution time only — worth knowing when verifying: the transcript is not evidence of failure).

1. rtk rewrite exits 3 (rewrite/ask) with the rewrite on stdout; execFileSync
   throws on non-zero exit, so the plugin never rewrote anything. Recover
   status 3 from the error object; pass through on 1/2 so native deny policy
   sees the original command.
2. Managed installs reject TypeScript entries - ship compiled index.js and
   point main at it (index.ts kept as source).
3. package.json needs openclaw.extensions for managed installs to register
   the entry point.
4. Hook-only plugins are excluded from the Gateway startup plugin plan unless
   the manifest declares activation intent - without
   activation.onCapabilities ["hook"], the agent runtime silently skips the
   plugin (inspect says loaded, daemon-served turns never rewrite).
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@davidbordenwi davidbordenwi closed this by deleting the head repository Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants