ChloeGet Started

Example 1 of 4

A note in your inbox every morning

One job, one model call, one email, one file. It runs, sends, and exits. Want it every morning? Put that line in your crontab.

morning.ts
import { z } from "zod";
import { defineAgent, defineJob } from "@chloejs/core";
import { deliverEmail } from "@chloejs/core/services";

const digest = defineJob({
  id: "digest",
  description: "Writes a short morning note and emails it.",
  run: async (work) => {
    const { note } = await work.model("write the note", {
      prompt: "Write three upbeat lines to start the day.",
      output: z.object({ note: z.string() }),
    });
    await work.step("email it", () =>
      deliverEmail({ from: "Chloe <chloe@example.com>", to: ["you@example.com"] }, "Good morning", note),
    );
    return { note };
  },
});

const morning = defineAgent({
  id: "morning",
  description: "Sends a morning note.",
  instructions: "Be brief.",
  model: "anthropic/claude-sonnet-5",
  jobs: [digest],
});

const result = await morning.run({
  job: digest,
  settings: { connections: { resend: { api_key: process.env.RESEND_API_KEY } } },
});
console.log(result.text);
$ node morning.ts

Copy it into an empty folder, npm install @chloejs/core, and put any keys in .env next to it.


Next: Ask it about your email