mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
refactor(hooks): address PR feedback
- Rename getTools/setTools to getActiveTools/setActiveTools - Add getAllTools to enumerate all configured tools - Remove text_delta event (use turn_end/agent_end instead) - Add shortcut conflict detection: - Skip shortcuts that conflict with built-in shortcuts (with warning) - Log warnings when hooks register same shortcut (last wins) - Add note about prompt cache invalidation in setActiveTools - Update plan-mode hook to use agent_end for [DONE:id] parsing
This commit is contained in:
parent
5b634ddf75
commit
4ecf3f9422
13 changed files with 175 additions and 153 deletions
|
|
@ -224,15 +224,6 @@ export class AgentSession {
|
|||
|
||||
/** Internal handler for agent events - shared by subscribe and reconnect */
|
||||
private _handleAgentEvent = async (event: AgentEvent): Promise<void> => {
|
||||
// Emit text_delta events to hooks for streaming text monitoring
|
||||
if (
|
||||
event.type === "message_update" &&
|
||||
event.assistantMessageEvent.type === "text_delta" &&
|
||||
this._hookRunner
|
||||
) {
|
||||
await this._hookRunner.emit({ type: "text_delta", text: event.assistantMessageEvent.delta });
|
||||
}
|
||||
|
||||
// When a user message starts, check if it's from either queue and remove it BEFORE emitting
|
||||
// This ensures the UI sees the updated queue state
|
||||
if (event.type === "message_start" && event.message.role === "user") {
|
||||
|
|
@ -447,6 +438,13 @@ export class AgentSession {
|
|||
return this.agent.state.tools.map((t) => t.name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all configured tool names (built-in via --tools or default, plus custom tools).
|
||||
*/
|
||||
getAllToolNames(): string[] {
|
||||
return Array.from(this._toolRegistry.keys());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set active tools by name.
|
||||
* Only tools in the registry can be enabled. Unknown tool names are ignored.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue