With this, your mind can tell you each morning what the Cloudflare account it runs in costs, and say plainly what it could not see.
Why. A mind runs in its owner's Cloudflare account. The bill is right there, one API call away from an agent that could read it.
How it works. A schedule fires at an exact time, and "09:00 in London" moves twice a year. So the code does no date maths. It walks forward an hour at a time and asks what the London clock says:
export function nextCostReport(now = new Date()) {
const fmt = new Intl.DateTimeFormat("en-GB", { timeZone: "Europe/London",
hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
const start = Math.floor(now.getTime() / 3600000) * 3600000;
for (let t = start + 3600000; t <= start + 49 * 3600000; t += 3600000)
if (fmt.format(new Date(t)) === "09:00") return new Date(t).toISOString();
throw new Error("No 09:00 in London in the next two days");
}
When the tick comes, the code sets tomorrow's tick first, then wakes the agent that posts the report. A failed report cannot stop the clock.
Our files:
cloudflare-costs.ts: the clock above, and the wake: oneagent/context-addedwith the job.cloudflare-costs.md: the rules. Fetch fresh numbers. Say the period and the currency. Keep estimates apart from bills. Keep a few numbers from yesterday to compare. An unknown is never zero.cloudflare.ts:itx.config.cloudflare(tool, args), which calls Cloudflare's own MCP server with the mind's token.worker.ts: the install in themind/worker-updatedcase, and the tick's handler.
What it needs. The mind's Cloudflare connection: an owner turns it on in iterate Cloud, and a read-only token lands in /secrets/cloudflare. Somewhere to post: we use a Slack thread (see the Slack post); mail works too. Cloudflare's general billing endpoints need a Billing Read permission the token may lack; the AI Gateway's numbers are readable.
What surprised us. The rules file is longer than the code. The code is a clock; the rules are what make the report worth reading. When Cloudflare answers 403, the report says so and does not guess.