feat(coding-agent): add event bus for tool/hook communication (#431)
* feat(coding-agent): add event bus for tool/hook communication Adds pi.events API enabling custom tools and hooks to communicate via pub/sub. Tools can emit events, hooks can listen. Shared EventBus instance created per session in createAgentSession(). - EventBus interface with emit() and on() methods - on() returns unsubscribe function - Threaded through hook and tool loaders - Documented in hooks.md and custom-tools.md * fix(coding-agent): wrap event handlers to catch errors * docs: note async handler error handling for event bus * feat(coding-agent): add sendMessage to tools, nextTurn delivery mode - Custom tools now have pi.sendMessage() for direct agent notifications - New deliverAs: 'nextTurn' queues messages for next user prompt - Fix: hooks and tools now share the same eventBus (was isolated before) * fix(coding-agent): nextTurn delivery should always queue, even when streaming
This commit is contained in:
@@ -43,6 +43,9 @@
|
||||
- Tool registry now contains all built-in tools (read, bash, edit, write, grep, find, ls) even when `--tools` limits the initially active set. Hooks can enable any tool from the registry via `pi.setActiveTools()`.
|
||||
- System prompt now automatically rebuilds when tools change via `setActiveTools()`, updating tool descriptions and guidelines to match the new tool set
|
||||
- Hook errors now display full stack traces for easier debugging
|
||||
- Event bus (`pi.events`) for tool/hook communication: shared pub/sub between custom tools and hooks
|
||||
- Custom tools now have `pi.sendMessage()` to send messages directly to the agent session without needing the event bus
|
||||
- `sendMessage()` supports `deliverAs: "nextTurn"` to queue messages for the next user prompt
|
||||
|
||||
### Changed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user