X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/0da1ef837bbd190cc5787214187d1b29d62b9410..38a9b0502a1ccefc6ccb3472c4a21805b222caa6:/tools.go?ds=inline diff --git a/tools.go b/tools.go index dd28ae0..b20b3ac 100644 --- a/tools.go +++ b/tools.go @@ -50,14 +50,15 @@ type ToolChat interface { // message. The call is durable before its tool runs, so the log never misses an // action outside the agent. Commands and files run as the user in the working // directory, with no sandbox. Zoom with a name reads the log of a subagent. -// The toolbox of the agent has the runs of its subagents for spawn and tell. -// The toolbox of a subagent has none, so spawn and tell are unknown tools -// there. +// The toolbox of the agent has the runs of its subagents for spawn and tell, +// and the WhatsApp link for the WhatsApp tools. The toolbox of a subagent has +// neither, so these are unknown tools there. type Toolbox struct { log ToolLog chat ToolChat subagents *Subagents runs *SubagentRuns + whatsapp *WhatsApp workdir string } @@ -152,6 +153,15 @@ func (b *Toolbox) run(ctx context.Context, name, arguments string) string { case err == nil: output, err = b.runs.Tell(ctx, args.Name, args.Message) } + case "whatsapp_find": + var args ToolWhatsAppFindArguments + err = toolDecodeArguments(arguments, &args) + switch { + case b.whatsapp == nil: + err = fmt.Errorf("unknown tool %q", name) + case err == nil: + output, err = b.whatsapp.Find(ctx, args.Name) + } default: err = fmt.Errorf("unknown tool %q", name) } @@ -393,6 +403,11 @@ type ToolTellArguments struct { Message string `json:"message"` } +// ToolWhatsAppFindArguments are the arguments of whatsapp_find. +type ToolWhatsAppFindArguments struct { + Name string `json:"name"` +} + // ToolHeadTail keeps the first and the last toolClipBytes bytes written to it, // and counts the bytes between them that it drops. type ToolHeadTail struct {