A mail is an event, and the Dash's guard answers a frame
Misha Kaletsky, 2026-11-25 15:23 UTC · d7316b26c2c87c18a963e01ca57c4f6255c56b7e · parent b033e95
3 files changed
M AGENTS.md
@@ -71,15 +71,15 @@ ## worker.ts -The platform calls three methods of the class that `worker.ts` exports: +The platform calls two methods of the class that `worker.ts` exports: - `fetch(request)`: every request to a hostname of the mind but its control-plane hostname. It switches on the hostname's first label: `dash`, `tasks`, `git`. Any other hostname is the public website: the profile, then the homepage (`homepage.ts`), then a 404. `this.auth.require` lets a member in and answers the sign-in to anyone else. -- `email({ save })`: every mail to an address of the mind. `await save()` keeps it. - `processEvent({ event, itx })`: every event of every context, one at a time, in no order, at - least once. So each case is idempotent, and no state is kept in the worker. + least once. So each case is idempotent, and no state is kept in the worker. A mail to an + address of the mind is one of them: `email/received`. Every other public method of the class is the mind's own API, `itx.config.<name>(…)`. They are in `api.ts`. Everything a member can do on a page, an agent can do through an API.
M tests/worker.test.mjs
@@ -134,17 +134,6 @@ }); }); -test("the email hook saves the mail once, and forwards it nowhere", async () => { - const mind = mindAt("example.com"); - const did = []; - await mind.config.email({ - mail: {}, - save: async () => void did.push("saved"), - forward: async (to) => void did.push(`forwarded to ${to}`), - }); - assert.deepEqual(did, ["saved"]); -}); - test("a publish installs the agents from stdlib's module, and tells the Dash which file of this repo holds the kind", async () => { const mind = mindAt("example.com"); await mind.config.processEvent({
M worker.ts
@@ -5,17 +5,16 @@ // and in a folder on a laptop where the repos are cloned side by side. A push to `main` of any // repo that this file's imports reach publishes the mind a few seconds later (AGENTS.md). // -// The platform calls three methods of the class below: +// The platform calls two methods of the class below: // // fetch(request) every request to a hostname of the mind: its apps, its website -// email({ save }) every mail to an address of the mind // processEvent({ event }) every event of every context: a publish, a mail, a person's words // // Every other public method of the class is the mind's own API, `itx.config.<name>(…)`, for its // agents and its pages. Those are in api.ts. -import type { EmailHookArgs } from "iterate/email"; import type { IterateConfigProcessEventArgs } from "iterate/sdk"; import { dashApp } from "../dash/app.ts"; +import { framedSignIn } from "../dash/framed-sign-in.ts"; import { gitApp } from "../git/app.ts"; import { everyEvent } from "../stdlib/every-event.ts"; import { init, step } from "../stdlib/init.ts"; @@ -48,7 +47,11 @@ // the sign-in for anyone else. An app's name and icon are for anyone (`open`). switch (new URL(request.url).hostname.split(".")[0]) { case "dash": // the Dash, for members: every agent and a chat with each - return dash.open(request) || this.auth.require(request) || dash.fetch(request, this); + return ( + dash.open(request) || + framedSignIn(request, this.auth.require(request)) || + dash.fetch(request, this) + ); case "tasks": // Tasks, for members: the board of task files return tasks.open(request) || this.auth.require(request) || tasks.fetch(request, this); case "git": // the mind's repos, for git and for a browser: the app says who may do what @@ -60,13 +63,6 @@ (await homepage(request, this)) || // homepage.ts: change that file to make the site yours new Response("Not found\n", { status: 404 }) ); - } - - // EVERY MAIL to an address of the mind. `save()` keeps it: one `email/received` event on the - // context /integrations/email, which the case below hands to an agent. A hook that returns - // without it leaves the mail off the log, and no agent gets it. - async email({ save }: EmailHookArgs) { - await save(); } // EVERY EVENT of every context of the mind, one at a time, in no order, at least once: each