iterate.com / config-template

git clone https://git.iterate.com/repos/config-template

The onboarding app is back: onboarding.<domain>, itx.config.onboardingStep and the mind's events #1

merged restore-onboarding was squashed into main as a3ed324 by jonas, 2026-11-26 16:07 UTC. jonas opened it 2026-11-26 16:07 UTC.

A new mind had no onboarding host: `iterate deploy` waited for one, the first passkey sent the owner there, and nothing offered "Connect to iterate Cloud". The app is the repo /repos/onboarding now (public on this host at 2c82f1c). This config names it in package.json (so a mind is born with it), mounts it on onboarding.<domain> for members, hands it the mind's events, and takes another mind's event (processMindEvent) for it: iterate's mind says there that it let this mind in. The onboarding hook and the hook of every event run side by side.

Checks: tsc clean; node --test, 26 pass (a cross-origin press is refused by the guard; a failed onboarding hook does not stop the other hook). The set loaded as a candidate on iterate.com: onboarding.<domain>/.well-known/iterate-app 200 for anyone, / 401 for nobody signed in. /agents/reviewer read the change; its findings are answered on the card.

Via: /agents/claude/restore-template-onboarding-mwxo08t6-adbe6a
Session: claude 3a334e5f-97c0-4984-83df-58988ecbe7b0 on beelink

Conversation

Nobody has said anything yet.

Sign in to comment or to merge.

Files

7 files changed

M AGENTS.md
@@ -13,6 +13,7 @@
 | `/repos/stdlib` | the agent (`agent/`), and what `worker.ts` calls at each publish and each event |
 | `/repos/dash` | the Dash, on `dash.<domain>`, for members |
 | `/repos/tasks` | the Tasks board, on `tasks.<domain>`, for members |
+| `/repos/onboarding` | the first steps of a new mind, on `onboarding.<domain>`, for members: the page, its steps and the onboarding agent's guides |
 | `/repos/git` | the git app: every repo as a git remote at `git.<domain>/repos/<name>` |
 | `/repos/task-board` | the task files, under `todo/`, and nothing else. The mind makes it empty at its first publish |
 | `/repos/kernel` | the platform. Only a deploy changes what runs of it |
@@ -53,7 +54,7 @@
 ## What a push does
 
 - A push to `main` of a repo that `worker.ts` imports from (`config`, `stdlib`, `dash`, `tasks`,
-  `git`) publishes the mind. A few seconds later every request runs the new code, and
+  `git`, `onboarding`) publishes the mind. A few seconds later every request runs the new code, and
   `worker.ts` runs its `mind/worker-updated` case again.
 - A change across two repos is two pushes. When the code between them does not load, the mind
   keeps running the last set that did.
@@ -87,7 +88,7 @@
 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
+  switches on the hostname's first label: `dash`, `onboarding`, `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.
 - `processEvent({ event, itx })`: every event of every context, one at a time, in no order, at
M README.md
@@ -34,6 +34,7 @@
   stdlib/      the agent, what worker.ts calls, and what every repo is checked and tested with
   dash/        the Dash app
   tasks/       the Tasks app
+  onboarding/  the first steps of a new mind: the page at onboarding.<domain> and its guides
   git/         the git app: it serves git.<domain>
 ```
 
M api.ts
@@ -5,6 +5,7 @@
 // extends this one. Add a method here, or to worker.ts's class.
 import { IterateConfigEntrypoint } from "iterate/sdk";
 import { mergePull } from "@repos/git/pulls.ts";
+import { runStep, stepContext } from "@repos/onboarding/steps.ts";
 import { profileOf } from "./profile.ts";
 import profileFiles from "./profile/";
 
@@ -27,5 +28,14 @@
   async pullMerge(repo: string, number: number) {
     using itx = this.getItx();
     return await mergePull(itx, repo, number);
+  }
+
+  /** `itx.config.onboardingStep(step, action)`: one press of a button of the onboarding app, as
+   *  the onboarding agent makes it from the owner's plain words (steps.ts and
+   *  onboarding/connect-iterate-cloud.md of /repos/onboarding). It answers
+   *  `{ status, words, link? }`. */
+  async onboardingStep(step: string, action: string) {
+    using itx = this.getItx();
+    return await runStep(await stepContext(itx), step, action);
   }
 }
M package.json
@@ -10,6 +10,7 @@
   "dependencies": {
     "@repos/dash": "../dash",
     "@repos/git": "../git",
+    "@repos/onboarding": "../onboarding",
     "@repos/stdlib": "../stdlib",
     "@repos/tasks": "../tasks"
   },
M pnpm-lock.yaml
@@ -14,6 +14,9 @@
       '@repos/git':
         specifier: ../git
         version: link:../git
+      '@repos/onboarding':
+        specifier: ../onboarding
+        version: link:../onboarding
       '@repos/stdlib':
         specifier: ../stdlib
         version: link:../stdlib
M tests/worker.test.mjs
@@ -10,7 +10,7 @@
 const { default: Config } = await import("../worker.ts");
 const repoFile = (path) => new URL(`../${path}`, import.meta.url);
 
-for (const app of ["dash", "tasks"])
+for (const app of ["dash", "tasks", "onboarding"])
   test(`${app}.<domain>: the app's name and icon are for anyone, and everything else is for members`, async () => {
     const mind = mindAt("example.com");
     const ask = (path) => mind.config.fetch(new Request(`https://${app}.example.com${path}`));
@@ -22,7 +22,7 @@
     assert.equal(icon.headers.get("content-type"), "image/svg+xml");
     assert.equal(await icon.text(), readFileSync(repoFile("profile/icon.svg"), "utf8"));
     // nobody is signed in: the page and its files answer the sign-in
-    for (const path of ["/", "/app.js", "/theme.css", "/board.json"])
+    for (const path of ["/", "/app.js", "/theme.css", "/board.json", "/steps.json"])
       assert.equal((await ask(path)).status, 401, path);
 
     // a member: the guard lets them in
@@ -40,6 +40,49 @@
     );
   });
 
+test("a press of an onboarding step from another origin is refused even with a member's session: no cross-site disconnect", async () => {
+  const mind = mindAt("example.com");
+  mind.config.getItx = () => {
+    throw new Error("the guard let a request through to the mind");
+  };
+  const press = (headers) =>
+    mind.config.fetch(
+      new Request("https://onboarding.example.com/steps/connect-iterate-cloud/disconnect", {
+        method: "POST",
+        headers: {
+          "x-itx-principal": JSON.stringify({ actor: "user-1", email: "owner@example.org" }),
+          ...headers,
+        },
+      }),
+    );
+  const sameSite = await press({ origin: "https://blog.example.com", "sec-fetch-site": "same-site" });
+  assert.equal(sameSite.status, 403);
+  const crossSite = await press({ origin: "https://evil.example", "sec-fetch-site": "cross-site" });
+  assert.equal(crossSite.status, 403);
+});
+
+test("an onboarding hook that fails does not stop the hooks that look at every event, and the failure is thrown after them", async () => {
+  const mind = mindAt("example.com");
+  // the onboarding step cannot read the mind: its hook fails on a publish
+  mind.itx.whoami = async () => {
+    throw new Error("the mind did not answer");
+  };
+  // a context that the table of context descriptions names, with no description yet
+  mind.itx.contexts = { list: async () => [{ path: "/secrets/openai", description: "" }] };
+  await assert.rejects(
+    mind.config.processEvent({
+      event: { type: "events.iterate.com/mind/worker-updated", path: "/", offset: 9, payload: {} },
+      itx: mind.itx,
+    }),
+    /the mind did not answer/,
+  );
+  // the hook of every event still described the context (its description, then its title)
+  assert.deepEqual(
+    mind.appended.filter(({ path }) => path === "/secrets/openai").map(({ event }) => event.type),
+    ["events.iterate.com/itx/described", "events.iterate.com/itx/described"],
+  );
+});
+
 test("tasks.<domain> tells its page which repo the board shows: /repos/task-board", async () => {
   const mind = mindAt("example.com");
   mind.config.auth = { ...mind.config.auth, require: () => null };
@@ -150,8 +193,39 @@
   assert.equal(existsSync(repoFile(kinds.agent)), true);
   // a mind born from this config has no such repo yet: it is made empty, and making it again is nothing
   assert.deepEqual(mind.made, ["/repos/task-board"]);
+  // the onboarding app's step read the new mind, and wrote what it found on its own log
+  assert.deepEqual(
+    mind.appended
+      .filter(({ path }) => path === "/apps/onboarding")
+      .map(({ event }) => ({ type: event.type, payload: event.payload })),
+    [
+      {
+        type: "onboarding/step-checked",
+        payload: {
+          step: "connect-iterate-cloud",
+          facts: { canSign: false, meld: false, openai: "unset", exa: "unset" },
+        },
+      },
+    ],
+  );
 });
 
+test("another mind's event goes to the onboarding app alone, and one that is not iterate's does nothing", async () => {
+  const mind = mindAt("example.com");
+  await mind.config.processMindEvent({
+    event: {
+      type: "events.iterate.com/cloud/enrolled",
+      path: "/minds/someone-else/cloud",
+      offset: 3,
+      payload: {},
+      source: { signer: { principal: { kind: "mind", actor: "someone-else" } } },
+    },
+    mind: "someone-else",
+    itx: mind.itx,
+  });
+  assert.deepEqual(mind.appended, []);
+});
+
 test("an event that is no case's still reaches the hooks that look at every event", async () => {
   const mind = mindAt("example.com");
   // a context is born that the table of context descriptions names
@@ -184,7 +258,13 @@
   const kv = {};
   const made = [];
   const context = (path) => ({
-    append: async (...events) => void appended.push(...events.map((event) => ({ path, event }))),
+    append: async (...events) => {
+      appended.push(...events.map((event) => ({ path, event })));
+      return events.map((event, index) => ({ ...event, offset: appended.length - events.length + index + 1 }));
+    },
+    // every log is empty, and no rule is set: a new mind
+    readEvents: async () => ({ events: [], atHead: true, scannedThroughOffset: 0 }),
+    rewriteRules: { get: async () => null, list: async () => [] },
     processors: {
       enable: async (name, spec) => void enabled.push({ path, name, spec }),
       disable: async () => {},
@@ -195,6 +275,11 @@
     ...context("/"),
     cd: context,
     url: async () => `https://${zone}/`,
+    whoami: async () => ({ mindSlug: `iterate.${zone}` }),
+    // what the onboarding step's check reads of a new mind: a stack that publishes no key to sign
+    // with, and a vault with no secret
+    fetch: async () => new Response("Not found\n", { status: 404 }),
+    secrets: { describe: async () => ({ set: false }), list: async () => [] },
     kv: {
       get: async (key) => kv[key] || null,
       put: async (key, value) => {
M worker.ts
@@ -17,6 +17,8 @@
 import { dashApp } from "@repos/dash/app.ts";
 import { framedSignIn } from "@repos/dash/framed-sign-in.ts";
 import { gitApp } from "@repos/git/app.ts";
+import { onboardingApp } from "@repos/onboarding/app.ts";
+import { onboardingEvents, onboardingMindEvents } from "@repos/onboarding/events.ts";
 import { everyEvent } from "@repos/stdlib/every-event.ts";
 import { init, step } from "@repos/stdlib/init.ts";
 import { mailReceived } from "@repos/stdlib/mail.ts";
@@ -30,6 +32,10 @@
 const icon = () => mindIcon(profileFiles);
 
 const dash = dashApp({ icon });
+// The first steps of a new mind, for its owner: connect to iterate Cloud, prove that AI answers,
+// and start the first agent. The page, its steps and the agent's guides are /repos/onboarding.
+// To retire it: take out its lines here and in api.ts, and its line of package.json.
+const onboarding = onboardingApp({ icon });
 // The Tasks board shows the markdown files under todo/ of this repo, which holds nothing else.
 // No code is loaded from it, so package.json does not list it and it is cloned from nowhere:
 // the publish hook below makes it, empty, and the board's first task is its first commit.
@@ -56,6 +62,10 @@
           framedSignIn(request, this.auth.require(request)) ||
           dash.fetch(request, this)
         );
+      case "onboarding": // the first steps of a new mind, for members
+        return (
+          onboarding.open(request) || this.auth.require(request) || onboarding.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
@@ -90,7 +100,22 @@
         await mailReceived(itx, event);
         break;
     }
-    // what looks at every event: the agent's inputs, its prompt, each context's description
-    await everyEvent(itx, event);
+    // What looks at every event, side by side: one that fails does not stop the other, and the
+    // first failure is thrown after both settled.
+    const hooks = await Promise.allSettled([
+      // the onboarding app's part: what the owner told iterate Cloud, and what moves a step's card
+      onboardingEvents(itx, event),
+      // the agent's inputs, its prompt, each context's description
+      everyEvent(itx, event),
+    ]);
+    const failed = hooks.find((hook) => hook.status === "rejected");
+    if (failed) throw failed.reason;
+  }
+
+  // An event that ANOTHER MIND added here, signed with its own key, never reaches `processEvent`:
+  // its words are data, never a member's instruction. iterate's mind says this way that it let
+  // this mind in and granted its credit, and the onboarding step goes on from it.
+  async processMindEvent({ event, itx }: IterateConfigProcessEventArgs) {
+    await onboardingMindEvents(itx, event);
   }
 }