// From https://exe.dev/deploy/eve/email_owner.ts import { defineTool } from "eve/tools"; import { z } from "zod"; // Emails the VM's owner through exe.dev: the Reflection integration names // the owner, and the VM's email gateway sends to them. No mail credentials. export default defineTool({ description: "Email the owner of this agent a plain-text message.", inputSchema: z.object({ subject: z.string().min(1).max(200), body: z.string().min(1).max(20000), }), async execute({ subject, body }) { const owner = await fetch("https://reflection.int.exe.xyz/email"); if (!owner.ok) throw new Error(`Reflection: ${owner.status} ${await owner.text()}`); const { email } = (await owner.json()) as { email: string }; const sent = await fetch("http://169.254.169.254/gateway/email/send", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ to: email, subject, body }), }); if (!sent.ok) throw new Error(`Email: ${sent.status} ${await sent.text()}`); return { sent: true, to: email }; }, });