Commit Graph

1 Commits

Author SHA1 Message Date
dp-web4
dbbca8e040 feat: wire before_tool_call / after_tool_call plugin hooks into tool pipeline
The typed plugin hooks `before_tool_call` and `after_tool_call` were fully
implemented in the hook runner but never invoked during agent tool execution.

This adds a tool wrapper (`pi-tools.hooks.ts`) that intercepts every tool's
`execute()` to fire these hooks, following the same pattern as the existing
`wrapToolWithAbortSignal` wrapper:

- `before_tool_call` runs sequentially before execution and can modify params
  or block the call entirely.
- `after_tool_call` runs fire-and-forget after execution with result, error,
  and duration.

Includes 12 unit tests covering the full lifecycle: pass-through, blocking,
param modification, error propagation, and hook isolation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-27 19:42:51 -08:00