ChloeGet Started

Reference

@chloejs/core/tools/gmail

Reading, answering and sending mail, as the person signed in to Google.

The tools over gmailService.ts: reading the mail an agent is bound to, answering one of those messages, and sending one as the signed-in person.

The binding lives in the agent's config, not in anything the model can write. For reading, all the model chooses is how far back and how many. For replying, it chooses which of the messages it has already listed and what to say, and never the address.

import * as gmail from "@chloejs/core/tools/gmail";
tools: { gmailReadEmail: gmail.readEmail({ search: "in:inbox" }) }

readEmailreplyEmailsendEmail

readEmailfunction

export function readEmail({
  search = "in:inbox",
  what = "mail in the inbox",
  days = 7,
}: Options = {})

A tool that reads the mail the agent is bound to. The search is the binding's, and the model chooses only how far back and how many.

It needs the google connection, so when nobody has signed in the runtime sends the sign-in itself: mail that cannot be read because nobody has signed in is not a different problem from mail, and there is nothing to add.

connections/google/gmail.ts:45

replyEmailfunction

export function replyEmail({
  search = "in:inbox",
  what = "mail in the inbox",
  days = 7,
  when = "",
  markdown = false,
  keep,
}: ReplyOptions = {})

A tool that answers one of the messages the agent can already read.

It sends as the signed-in account, inside the original thread. The address is read off the message being answered and is never the model's to choose, so this grants the ability to answer somebody who wrote in, not the ability to mail a stranger. That matters more here than anywhere else: the text the model is reacting to was written by whoever sent the mail, so an instruction buried in an email that talked the model into mailing an address of its own choosing is the whole risk, and the only reliable answer is for the address not to be an input.

Give it the same search as the agent's readEmail, so the mail it can answer is exactly the mail that search lists.

connections/google/gmail.ts:105

sendEmailfunction

export function sendEmail(options: SendOptions)

Sends mail as the person signed in to Google, from the address the agent was given, which has to be that account or an alias Google verified for it.

connections/google/gmail.ts:171