Let plugins intercept CLI invocations and agent tool calls - #2444
Open
SawyerHood wants to merge 1 commit into
Open
Let plugins intercept CLI invocations and agent tool calls#2444SawyerHood wants to merge 1 commit into
SawyerHood wants to merge 1 commit into
Conversation
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.
Human comments
What was wrong
A policy plugin had no way to observe or block a
bbcommand or a bb-defined agent tool call before it ran.What changed
bb.events.on("experimental_invocation.before", handler)returning{ allowed, reason? }; the server runs every loaded plugin's handlers in deterministic order (plugin-service.ts,plugin-api.ts) and records invocation events (packages/domainchange kinds,event-pruning).POST /api/v1/plugins/invocations/preflight(apps/server/src/routes/plugins.ts); the CLI asks it once per executable command (apps/cli/src/invocation-preflight.ts, registered with the lazily loaded command groups inindex.ts) and before proxying a plugin command. It fails open when the server is unreachable or predates the route, and blocks on an explicit block, a malformed 2xx, any other non-2xx, or a server that accepts the connection and then goes quiet (headers/body timeout).bb guideandbb managerare never preflighted.apps/server/src/internal/tool-calls.tsconsults the same policy for bb-defined agent tools; a handler failure returns a tool error to the agent instead of failing the turn.packages/plugin-sdk/src/testing) supports scripted decisions; the plugin-authoring skill andbb guide pluginsdocument the hook.No wire change. Prerequisite: #2443 (stack order only).
Open decision for reviewers: fail-open vs fail-closed when the server is down, and whether a per-handler timeout is required before this ships.
How you verified
turbo run typecheck;turbo run testfor@bb/cli(invocation-preflight.test.ts, packaged plugin build),@bb/server(plugin-invocation-events.test.ts, internal tool calls),@get-bb/plugin-sdk(fake host),@bb/db.Fixes: none (upstream stack split).