Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(gmail): leave the subject off reply drafts so they stay in the thread (#4318)
CI fixture829f09735b37
diff --git a/server/connector-app-tools.test.ts b/server/connector-app-tools.test.tsindex 75d4cd583f..3b5051177d 100644--- a/server/connector-app-tools.test.ts+++ b/server/connector-app-tools.test.ts@@ -45,12 +45,24 @@ describe("a call to one", () => {expect(update?.frame(1)).toMatchObject({ params: { arguments: { tools: [{ tool_slug: "GMAIL_UPDATE_DRAFT", arguments: {user_id: "me", draft_id: "r123", recipient_email: "[email protected]", subject: "Re: Account", body: "Revised reply", thread_id: "t123",} }] } } });- expect(appToolCall("gmail.create_draft", input)?.frame(2)).toMatchObject({ params: { arguments: { tools: [{ tool_slug: "GMAIL_CREATE_EMAIL_DRAFT", arguments: {- thread_id: "t123", subject: "Re: Account", body: "Revised reply",- } }] } } });expect(appToolsFor({ connectorTools: { gmail: { tools: ["GMAIL_CREATE_EMAIL_DRAFT"] } } }, ["gmail"])).toEqual(["gmail.create_draft"]);});+ it("drafts a reply with its thread id and no subject, so Composio keeps it in that thread", () => {+ const reply = appToolCall("gmail.create_draft", { to: "[email protected]", body: "Sounds good", thread_id: " t99 " });+ expect(reply?.slug).toBe("GMAIL_CREATE_EMAIL_DRAFT");+ const item = (reply!.frame(1) as { params: { arguments: { tools: Array<Record<string, unknown>> } } }).params.arguments.tools[0]!;+ expect(item.tool_slug).toBe("GMAIL_CREATE_EMAIL_DRAFT");+ expect(item.arguments).toEqual({ user_id: "me", recipient_email: "[email protected]", body: "Sounds good", thread_id: "t99" });+ expect((appToolEntries(["gmail.create_draft"], "dotted")[0]!.inputSchema as { required: string[] }).required).toEqual(["to", "body"]);+ });++ it("still sends the subject a new draft names", () => {+ expect(appToolCall("gmail.create_draft", { to: "[email protected]", subject: "Quote", body: "Here it is" })?.frame(1)).toMatchObject({+ params: { arguments: { tools: [{ tool_slug: "GMAIL_CREATE_EMAIL_DRAFT", arguments: { user_id: "me", recipient_email: "[email protected]", subject: "Quote", body: "Here it is" } }] } },+ });+ });+it("runs its Composio tool through the multi-execute tool, by either name, with the arguments it takes", () => {const call = appToolCall("gmail.search_emails", { query: "from:[email protected]", max_results: "5" });expect(call?.slug).toBe("GMAIL_FETCH_EMAILS");diff --git a/server/connector-app-tools.ts b/server/connector-app-tools.tsindex 59ebdecc0d..2cd6cd32b0 100644--- a/server/connector-app-tools.ts+++ b/server/connector-app-tools.ts@@ -76,19 +76,20 @@ export const APP_TOOLS: readonly AppTool[] = [{name: "gmail.create_draft",slug: "GMAIL_CREATE_EMAIL_DRAFT",- description: "Create a new Gmail draft without sending. For a reply, read the original thread and provide its thread_id and matching subject. Each call creates a separate draft: first check gmail.list_drafts; revise an existing draft with gmail.update_draft and its draft ID. Never use send_email or a reply/send action to save a draft.",+ description: "Create a new Gmail draft without sending. For a reply, read the original thread, pass its thread_id and leave the subject out: a subject on a reply starts a new thread and the draft leaves the conversation. Each call creates a separate draft: first check gmail.list_drafts; revise an existing draft with gmail.update_draft and its draft ID. Never use send_email or a reply/send action to save a draft.",properties: {to: { type: "string", description: "The recipient's address; several separated by commas." },- subject: { type: "string" },+ subject: { type: "string", description: "The subject of a new draft. Leave out for a reply: with thread_id, a subject starts a new thread instead." },body: { type: "string", description: "The text of the email." },thread_id: { type: "string", description: "For a reply: the conversation's thread id." },},- required: ["to", "subject", "body"],+ required: ["to", "body"],args: (input) => {const [first, ...rest] = addresses(input.to ?? input.recipient_email) ?? [];+ const subject = text(input.subject);return {- user_id: "me", recipient_email: first ?? "", body: String(input.body ?? ""), subject: String(input.subject ?? ""),- ...(rest.length ? { extra_recipients: rest } : {}), ...(text(input.thread_id) ? { thread_id: text(input.thread_id) } : {}),+ user_id: "me", recipient_email: first ?? "", body: String(input.body ?? ""),+ ...(subject ? { subject } : {}), ...(rest.length ? { extra_recipients: rest } : {}), ...(text(input.thread_id) ? { thread_id: text(input.thread_id) } : {}),};},},@@ -115,7 +116,7 @@ export const APP_TOOLS: readonly AppTool[] = [{name: "gmail.update_draft",slug: "GMAIL_UPDATE_DRAFT",- description: "Replace an existing Gmail draft in place without sending. Use its draft_id from creation or gmail.list_drafts, not a message ID. Read it first and provide the complete revised content, preserving recipients, subject and thread_id. Never create a replacement if this fails. Verify the result before claiming success.",+ description: "Replace an existing Gmail draft in place without sending. Use its draft_id from creation or gmail.list_drafts, not a message ID. Read it first and provide the complete revised content, preserving recipients and thread_id, and the subject only when the draft has one. Never create a replacement if this fails. Verify the result before claiming success.",properties: {draft_id: { type: "string" }, to: { type: "string" }, subject: { type: "string" }, body: { type: "string" },thread_id: { type: "string" }, cc: { type: "string" }, bcc: { type: "string" }, is_html: { type: "boolean" },