diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 3d1ccfa99..a3a0b328d 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -246,9 +246,6 @@ func registerSharedTools( agent.Tools.Register(messageTool) } - // Always register Voice Leave Tool (it inherently checks if channel == "discord") - agent.Tools.Register(tools.NewVoiceLeaveTool(msgBus)) - // Send file tool (outbound media via MediaStore — store injected later by SetMediaStore) if cfg.Tools.IsToolEnabled("send_file") { sendFileTool := tools.NewSendFileTool( diff --git a/pkg/tools/voice_leave.go b/pkg/tools/voice_leave.go deleted file mode 100644 index 882e7cb9d..000000000 --- a/pkg/tools/voice_leave.go +++ /dev/null @@ -1,52 +0,0 @@ -package tools - -import ( - "context" - - "github.com/sipeed/picoclaw/pkg/bus" - "github.com/sipeed/picoclaw/pkg/logger" -) - -type VoiceLeaveTool struct { - bus *bus.MessageBus -} - -func NewVoiceLeaveTool(mb *bus.MessageBus) *VoiceLeaveTool { - return &VoiceLeaveTool{bus: mb} -} - -func (t *VoiceLeaveTool) Name() string { - return "voice_leave" -} - -func (t *VoiceLeaveTool) Description() string { - return "Disconnects the bot from the current voice channel. Use this tool when the user says goodbye or explicitly asks you to leave the voice chat." -} - -func (t *VoiceLeaveTool) Parameters() map[string]any { - return map[string]any{ - "type": "object", - "properties": map[string]any{}, - } -} - -func (t *VoiceLeaveTool) Execute(ctx context.Context, args map[string]any) *ToolResult { - channel := ToolChannel(ctx) - chatID := ToolChatID(ctx) - - if channel != "discord" { - return &ToolResult{ForLLM: "Can only leave voice channels on Discord", IsError: true} - } - - t.bus.PublishVoiceControl(ctx, bus.VoiceControl{ - ChatID: chatID, - Type: "command", - Action: "leave", - }) - - logger.InfoCF("agent", "Voice command triggered via tool: leave", map[string]any{"chat_id": chatID}) - - return &ToolResult{ - ForLLM: "Successfully sent disconnect command to voice adapter.", - } -} diff --git a/pkg/voice/agent.go b/pkg/voice/agent.go index cc8968b84..8cd01c338 100644 --- a/pkg/voice/agent.go +++ b/pkg/voice/agent.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "sync" "time"