Skip to content

feat: add tool-scoped hooks and fork guard#73590

Closed
kami-saia wants to merge 10000 commits intoopenclaw:developfrom
kami-saia:feat/tool-call-hooks
Closed

feat: add tool-scoped hooks and fork guard#73590
kami-saia wants to merge 10000 commits intoopenclaw:developfrom
kami-saia:feat/tool-call-hooks

Conversation

@kami-saia
Copy link
Copy Markdown

Summary

  • add tool-scoped plugin hook registrations for zero-overhead per-tool interception
  • add the fork-guard bundled plugin to block risky exec-driven fork writes like git push and gh pr create
  • cover the new hook scoping and fork-guard behavior with regression tests

Why

OpenClaw already had global before_tool_call / after_tool_call hooks, but no narrow way for a plugin to intercept only one tool without paying dispatch overhead across every call. That made policy plugins like fork hygiene guards awkward and broader than they needed to be.

This PR adds opt-in tool scoping to the existing hook system, then uses it to implement a focused fork-guard plugin that inspects exec commands before they run and blocks pushes / PR creation when the current diff matches configured sensitive patterns.

Testing

🤖 AI-assisted

  • pnpm vitest run src/plugins/hooks.test.ts src/agents/pi-tools.before-tool-call.test.ts extensions/fork-guard/src/config.test.ts extensions/fork-guard/src/index.test.ts
  • pnpm --dir extensions/fork-guard exec tsc --noEmit

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: android App: android app: ios App: ios app: macos App: macos channel: bluebubbles Channel integration: bluebubbles channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: googlechat Channel integration: googlechat channel: imessage Channel integration: imessage channel: irc channel: line Channel integration: line channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: nextcloud-talk Channel integration: nextcloud-talk channel: nostr Channel integration: nostr channel: qa-channel Channel integration: qa-channel channel: qqbot channel: signal Channel integration: signal channel: slack Channel integration: slack channel: synology-chat channel: telegram Channel integration: telegram channel: tlon Channel integration: tlon channel: twitch Channel integration: twitch channel: whatsapp-web Channel integration: whatsapp-web channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser docker Docker and sandbox tooling docs Improvements or additions to documentation extensions: acpx extensions: anthropic extensions: arcee extensions: byteplus extensions: cloudflare-ai-gateway extensions: codex extensions: copilot-proxy Extension: copilot-proxy extensions: deepseek extensions: device-pair extensions: inworld Extension: inworld extensions: litellm extensions: qa-lab extensions: senseaudio extensions: tts-local-cli gateway Gateway runtime plugin: azure-speech Azure Speech plugin plugin: bonjour Plugin integration: bonjour plugin: google-meet security Security documentation size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.