Fit the Dash to a repo of its own, and cut what the strawman leaves out
Misha Kaletsky, 2026-11-24 18:18 UTC · f75e8ba3e19c4929202a6120b555aacb2d89dc61 · parent cce6153
14 files changed
- M app.ts
- M index.html
- D links.ts
- M public/app.js
- D public/brands/cloudflare.svg
- D public/brands/github.svg
- D public/brands/google.svg
- D public/brands/slack.svg
- D public/brands/x.svg
- D public/call-facet.js
- D public/mcp-page.js
- D public/share-links.js
- A tests/page.test.mjs
- A tsconfig.json
M app.ts
@@ -1,38 +1,30 @@ -// app.ts — THE DASH, as worker.ts mounts it: the host of one page. It answers the member's `itx` -// socket, what the UI kit's shell asks of its host, and the app's files. What the page shows is -// said in public/app.js. The Integrations page's buttons need no path here: "Connect", "Add -// account", "Connect again" and "Remove" call the mind's config over the page's own socket -// (`itx.config.cloudflareConnect`, `connectCloudAccount`, `removeCloudAccount`), the same -// functions an agent calls. +// app.ts — THE DASH, as config/worker.ts mounts it on dash.<domain>: the host of one page. It +// answers the member's `itx` socket, what the UI kit's shell asks of its host, and the app's +// files. What the page shows is said in public/app.js. import { type AppDescription, serveFiles, type IterateConfigEntrypoint } from "iterate/sdk"; -import theme from "../theme.css"; -// oxlint-disable-next-line import/extensions -- a folder: the loader hands over every file under it, by path -import liveReload from "../live-reload/"; -import { openFile } from "../open-files.ts"; +import { openFile } from "../stdlib/open-files.ts"; +import theme from "../stdlib/theme.css"; import index from "./index.html"; -// oxlint-disable-next-line import/extensions -- a folder: the loader hands over every file under it, by path import files from "./public/"; /** WHAT THE DASH SAYS OF ITSELF: the mind's sign-in pages show its name and its icon, and - * open on the passkey, since it is for members (../open-files.ts answers it to anyone). */ + * open on the passkey, since it is for members. */ const DASH: AppDescription = { name: "Dash", icon: "/icon.svg", for: "members" }; -export function dashApp() { +/** `icon`: the answer for the mind's icon, which every app serves as its own + * (../stdlib/open-files.ts). */ +export function dashApp({ icon }: { icon: () => Response }) { return { - /** The app's description and icon, for anyone: worker.ts asks this before its guard - * (../open-files.ts). */ - open: (request: Request) => openFile(request, DASH), + /** The app's description and icon, for anyone: worker.ts asks this before its guard. */ + open: (request: Request) => openFile(request, DASH, icon), /** Every request on the app's host. worker.ts guards it, so a member alone gets here. */ fetch(request: Request, host: Pick<IterateConfigEntrypoint, "auth">) { // The page's own socket (public/app.js opens it), and what @iterate-com/ui's shell asks of // its host: which platform this page talks to, the one mind this app serves, its "Sign out". const page = host.auth.memberPage(request); if (page) return page; - // the app's own files, and the two files that every app of this mind shares - return serveFiles(request, { - index, - files: { ...files, ...liveReload, "theme.css": theme }, - }); + // the app's own files, and the theme that every app of this mind shares + return serveFiles(request, { index, files: { ...files, "theme.css": theme } }); }, }; }
M index.html
@@ -29,10 +29,6 @@ <script> try { window.__itxSocket = new WebSocket(new URL("/itx", location.href.replace(/^http/, "ws"))); - // time to itx: when the socket opens (page-events.md, "Speed") - window.__itxSocket.addEventListener("open", () => performance.mark("iterate:itx-open"), { - once: true, - }); } catch {} window.__session = fetch("/.auth/session.json").then((answer) => answer.json()); </script> @@ -40,9 +36,7 @@ and app.css alone, in the places the shell will draw it, so nothing moves when the app takes over. These lines decide what the shell decides: the sidebar as the person left it (the cookie `sidebar_state`, which the shell writes at each toggle), and whether the - page is an agent's, which has a header row. A first arrival at the onboarding agent, with - no choice stored, starts with the sidebar as a rail of icons, so the chat has the room: - app.js hands the Dash the same choice. `data-frame` on the root element tells the + page is an agent's, which has a header row. `data-frame` on the root element tells the components that the person's wait began with this frame. --> <script> { @@ -53,8 +47,7 @@ ? query.get("contextPath") : null; const left = /(?:^|; )sidebar_state=(true|false)/.exec(document.cookie)?.[1]; - const open = left ? left === "true" : agent !== "/agents/onboarding"; - document.documentElement.dataset.sidebar = open ? "open" : "collapsed"; + document.documentElement.dataset.sidebar = left === "false" ? "collapsed" : "open"; if (agent) document.documentElement.dataset.page = "agent"; } </script> @@ -65,20 +58,15 @@ crossorigin href="https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/dist/styles.css" /> - <!-- The look of this mind's apps: apps/theme.css, one file for every app. One line there - makes them all dark. shadcn's components also ask for the class `dark`, so the script - puts it on <html> when the file says dark. --> + <!-- The look of this mind's apps: theme.css of /repos/stdlib, one file for every app. One + line there makes them all dark. shadcn's components also ask for the class `dark`, so the + script puts it on <html> when the file says dark. --> <link rel="stylesheet" href="/theme.css" /> <script> if (getComputedStyle(document.documentElement).colorScheme === "dark") document.documentElement.classList.add("dark"); </script> <link rel="stylesheet" href="/app.css" /> - <!-- The page takes a new commit by itself: apps/live-reload/live-reload.js says how. Take - this line out, and the page changes at its next load only. It is in the head, where the - browser can wait for it before it draws: after a reload that the script asked for, - nothing is drawn before the script has put what the person saw back over the app. --> - <script type="module" src="/live-reload.js" blocking="render"></script> </head> <body> <!-- THE FRAME, until the app has drawn itself in its place: the sidebar, an agent page's header
D links.ts
@@ -1,187 +0,0 @@ -// links.ts — CANONICAL DASH URLS for a mind: one pure formatter shared by config code, Slack and -// mail writers, and `itx.config.dashLink(input)` for agents. Keeps the same encoding rules as -// `@iterate-com/ui`'s `dashPaths` (`dash-paths.ts`), pinned by `dash-routes.fixture.json`. -import { z } from "zod"; - -/** Page ids allowed as the first path segment (host-reserved paths and dotted names are rejected). */ -const PAGE_SEGMENT = /^(?!(?:itx|connect|api|keys|brands)$)[A-Za-z0-9][A-Za-z0-9_-]*$/; - -/** Hostname of a mind's zone (`example.com`), never a scheme, path or credentials. */ -const APEX_HOST = /^[A-Za-z0-9](?:[A-Za-z0-9.-]*[A-Za-z0-9])?$/; - -/** Trailing `.` `,` `:` encoded so Slack and mail linkifiers do not drop them from the link. */ -const TRAILING_PUNCTUATION: Record<string, string> = { ".": "%2E", ",": "%2C", ":": "%3A" }; - -/** A path that a URL's pathname can carry and read back cleanly (non-root, no empty/`.`/`..` segments). */ -const sayable = (path: string) => - path.length > 1 && - path.startsWith("/") && - path - .slice(1) - .split("/") - .every((segment) => segment && segment !== "." && segment !== ".."); - -/** A single path segment that round-trips without splitting or dot-segment resolution. */ -const sayableSegment = (segment: string) => - Boolean(segment) && !segment.includes("/") && segment !== "." && segment !== ".."; - -/** A relative multi-segment path (a repo file or page remainder) that round-trips. */ -const sayableRelative = (path: string) => !path.startsWith("/") && sayable(`/${path}`); - -/** Context path encoded for a URL pathname, keeping path-safe sub-delimiters readable. */ -const urlPathOf = (path: string) => - path - .split("/") - .map(encodeURIComponent) - .join("/") - .replace(/%(?:40|3A|24|26|2B|2C|3B|3D)/g, decodeURIComponent); - -/** Query string for `contextPath`, keeping `/ @ : ,` raw and spaces as `%20`. */ -function contextPathQuery(contextPath: string): string { - const ordered = new URLSearchParams(); - ordered.set("contextPath", contextPath); - return ordered - .toString() - .replaceAll("+", "%20") - .replace(/%(?:2F|40|3A|2C)/g, decodeURIComponent); -} - -/** Finalizes a Dash path and optional query string, encoding trailing `.` `,` `:`. */ -function finish(origin: string, pathname: string, query = ""): string { - const href = query ? `${pathname}?${query}` : pathname; - return `${origin}${href.replace(/[.,:]$/, (char) => TRAILING_PUNCTUATION[char]!)}`; -} - -/** Shared context-path formatter for `/agents` and `/contexts`: sayable non-root paths go in the - * pathname; root `/` and unsayable paths stay in `?contextPath=`. */ -function contextRoute(origin: string, page: "agents" | "contexts", contextPath: string): string { - if (sayable(contextPath)) return finish(origin, `/${page}${urlPathOf(contextPath)}`); - return finish(origin, `/${page}`, contextPathQuery(contextPath)); -} - -function assertApex(apex: string): string { - if (!APEX_HOST.test(apex) || apex.includes("..")) - throw new Error(`dashLinks: invalid apex hostname "${apex}"`); - return `https://dash.${apex}`; -} - -function assertContextPath(path: string, label: string): string { - if (!path.startsWith("/")) - throw new Error(`dashLinks: ${label} must start with "/" (got "${path}")`); - return path; -} - -function assertPageId(id: string): string { - if (!PAGE_SEGMENT.test(id)) throw new Error(`dashLinks: "${id}" is not a valid Dash page id`); - return id; -} - -function assertRelative(path: string, label: string): string { - if (!sayableRelative(path)) throw new Error(`dashLinks: invalid ${label} "${path}"`); - return path; -} - -const ContextPath = z - .string() - .min(1) - .max(1000) - .refine((path) => path.startsWith("/"), 'contextPath must start with "/"'); - -const PageId = z - .string() - .refine((id) => PAGE_SEGMENT.test(id), "page must be a valid non-reserved Dash page id"); - -const RepoName = z - .string() - .min(1) - .max(200) - .refine(sayableSegment, "repo must be a plain repo name"); - -const RelativePath = z - .string() - .min(1) - .max(1000) - .refine(sayableRelative, "path must be a relative path with no empty, . or .. segments"); - -/** Structured destination for `dashLink` and `itx.config.dashLink(input)`. */ -export const DashLinkInput = z.discriminatedUnion("view", [ - z.object({ view: z.literal("home") }), - z.object({ view: z.literal("agent"), contextPath: ContextPath }), - z.object({ view: z.literal("context"), contextPath: ContextPath }), - z.object({ - view: z.literal("repos"), - repo: RepoName.optional(), - file: RelativePath.optional(), - }), - z.object({ - view: z.literal("page"), - page: PageId, - rest: RelativePath.optional(), - }), - z.object({ view: z.literal("agents") }), - z.object({ view: z.literal("contexts") }), - z.object({ view: z.literal("secrets"), rest: RelativePath.optional() }), - z.object({ view: z.literal("integrations"), rest: RelativePath.optional() }), - z.object({ view: z.literal("analytics"), rest: RelativePath.optional() }), -]); - -export type DashLinkInput = z.infer<typeof DashLinkInput>; - -/** Pure URL builder for a mind's Dash (`https://dash.<apex>`). */ -export function dashLinks(apex: string) { - const origin = assertApex(apex); - const page = (id: string, rest?: string) => { - assertPageId(id); - const tail = rest ? urlPathOf(`/${assertRelative(rest, "page remainder")}`) : ""; - return finish(origin, `/${id}${tail}`); - }; - return { - origin, - home: () => `${origin}/`, - page, - agent: (contextPath: string) => - contextRoute(origin, "agents", assertContextPath(contextPath, "agent path")), - context: (contextPath: string) => - contextRoute(origin, "contexts", assertContextPath(contextPath, "context path")), - repos: (repo?: string, file?: string) => { - if (!repo && !file) return `${origin}/repos`; - const target = repo || "config"; - if (!sayableSegment(target)) throw new Error(`dashLinks: invalid repo "${target}"`); - const fileTail = file ? urlPathOf(`/${assertRelative(file, "repo file")}`) : ""; - return finish(origin, `/repos${urlPathOf(`/${target}`)}${fileTail}`); - }, - agents: () => `${origin}/agents`, - contexts: () => page("contexts"), - secrets: (rest?: string) => page("secrets", rest), - integrations: (rest?: string) => page("integrations", rest), - analytics: (rest?: string) => page("analytics", rest), - }; -} - -/** Validates a structured destination and returns its canonical URL on `https://dash.<apex>`. */ -export function dashLink(apex: string, input: DashLinkInput): string { - const parsed = DashLinkInput.parse(input); - const links = dashLinks(apex); - switch (parsed.view) { - case "home": - return links.home(); - case "agent": - return links.agent(parsed.contextPath); - case "context": - return links.context(parsed.contextPath); - case "repos": - return links.repos(parsed.repo, parsed.file); - case "page": - return links.page(parsed.page, parsed.rest); - case "agents": - return links.agents(); - case "contexts": - return links.contexts(); - case "secrets": - return links.secrets(parsed.rest); - case "integrations": - return links.integrations(parsed.rest); - case "analytics": - return links.analytics(parsed.rest); - } -}
M public/app.js
@@ -8,20 +8,18 @@ // { id: "notes", name: "Notes", icon: NotebookIcon, component: Notes }, // The Dash draws before the mind has said who is signed in: `principal` is undefined until then. // A page or a wrapper of your own is mounted anew when the page's connection comes back, unless it -// says `Notes.staysOverReconnect = true` (apps.md, "The Dash", says when that is right). +// says `Notes.staysOverReconnect = true`. // TO REPLACE A KIT PAGE, put your component in its row, under the same id. Each kit page is one // small component in @iterate-com/ui: copy it into this folder and change it there. Their source: // https://github.com/iterate/packages/tree/main/packages/ui/src/components/dash (the Dash and // most pages) and .../packages/ui/src/agent-kind-view/dash-agents.tsx (Home and Agents) -// (apps.md, "UI components in a page", for the source of the version index.html pins). // // The kit's pages load their larger parts when they first open: the home loads the composer only. -import { html, render, useEffect, useState } from "@iterate-com/ui/page"; +import { html, render } from "@iterate-com/ui/page"; +import { QueryClient, QueryClientProvider, useQuery } from "@iterate-com/ui/query"; import { Dash, - DashAnalytics, DashContexts, - DashIntegrations, DashRepo, DashSecrets, DashSettings, @@ -29,27 +27,18 @@ import { DashAgents, DashHome } from "@iterate-com/ui/agent-kind-view/dash-agents"; import { memberItx } from "@iterate-com/ui/live"; import { - BlocksIcon, - BookOpenIcon, BotIcon, - ChartLineIcon, CircleCheckIcon, - CompassIcon, FolderGit2Icon, HistoryIcon, KeyRoundIcon, LayoutDashboardIcon, LockKeyholeIcon, - PlugIcon, SettingsIcon, ShieldCheckIcon, - SparklesIcon, UsersIcon, WaypointsIcon, } from "@iterate-com/ui/icons"; -import { CALL_FACET } from "./call-facet.js"; -import { DashMcp } from "./mcp-page.js"; -import { endLink, makeLink } from "./share-links.js"; // The member's itx, from this host's /itx (app.ts answers it): over the socket that index.html // dialled in its head, when it is there. The Dash draws in the frame that index.html drew, and @@ -61,7 +50,7 @@ // before it draws. index.html asks for it in its head, while the modules load, so it is // usually there when this line runs. const hostSession = - window.__session ?? fetch("/.auth/session.json").then((answer) => answer.json()); + window.__session || fetch("/.auth/session.json").then((answer) => answer.json()); const stack = (await hostSession).issuer; const mind = new URL(stack).hostname; /** The zone this page is on: an app's hostname is one label under its zone. */ @@ -78,44 +67,8 @@ // context's own subscription rows (who holds each open page), and a page says only its status // (hidden, typing) in an ephemeral event. Nothing durable is written for it. presence: true, - // a call on any agent's page: the first press of the header's call buttons turns the call - // facet on for the agent (call.ts) - call: { - enable: (itx, path) => itx.cd(path).processors.enable("call", CALL_FACET), - }, - // SHARE beside the call's controls: links that let people who are not members into one agent's - // chat and call, the live ones with their guests, End, and a calendar invite. The link is made - // by share-links.js, the one module that Meet and `itx.config.shareAgent` use too, and appended - // through the member's own stub, so the link names the member as its maker. A guest comes in on - // Meet's guest page. Take this out, and the agent's header has no Share. - share: { - make: async (itx, path, lifetimeMs) => { - const { event, url, until, link } = await makeLink({ - zone, - agent: path, - lifetimeMs, - now: Date.now(), - }); - await itx.cd(path).append(event); - return { url, until, link }; - }, - end: (itx, path, link) => itx.cd(path).append(endLink(link)), - }, - // AN AGENT'S TOOLS IN THIS PAGE are off. `pageTools: true` here lends the agent whose page a - // member has open a banner in that tab, and, inside what index.html marks with - // `data-page-tools="scope"` (<body> for all of it), Playwright's locators: fill, click, press, - // highlight, read. What the agent does there carries THAT MEMBER's stamp in the log, and the - // page's audit row for the call names no caller. A jailed agent gets nothing. apps.md, "The - // Dash", says what it costs. }, { - id: "integrations", - name: "Integrations", - about: "The accounts and services the mind is connected to.", - icon: BlocksIcon, - component: DashIntegrations, - }, - { id: "secrets", name: "Secrets", about: "The credentials the mind holds.", @@ -125,8 +78,8 @@ }, { id: "repos", - name: "Config repo", - about: "The mind's code. A commit to main publishes it.", + name: "Repos", + about: "The mind's code. A push to main publishes it.", icon: FolderGit2Icon, component: DashRepo, }, @@ -137,49 +90,15 @@ icon: WaypointsIcon, component: DashContexts, }, - // not every stack has telemetry: without it, the row says "Off" - { - id: "analytics", - name: "Analytics", - about: "The mind's telemetry.", - icon: ChartLineIcon, - serves: "telemetry", - component: DashAnalytics, - }, - { - id: "mcp", - name: "MCP", - about: "Connect coding agents over MCP — stays up even if you brick the userspace web UI.", - icon: PlugIcon, - component: DashMcp, - }, { id: "settings", name: "Settings", icon: SettingsIcon, component: DashSettings }, ]; -// The mind's apps, each on its own hostname of this page's zone: an app you add in worker.ts -// gets a row here. +// The mind's apps, each on its own hostname of this page's zone: an app you add in +// config/worker.ts gets a row here. const apps = [ { - name: "Docs", - about: "The repos' files, written together.", - host: "docs", - icon: BookOpenIcon, - }, - { - name: "Meet", - about: "Calls and meetings with agents and guests.", - host: "meet", - icon: UsersIcon, - }, - { - name: "Onboarding", - about: "Set up this mind step by step.", - host: "onboarding", - icon: SparklesIcon, - }, - { name: "Tasks", - about: "Tasks and onboarding cards as a board.", + about: "The task files of the home repo, as a board.", host: "tasks", icon: CircleCheckIcon, }, @@ -201,12 +120,6 @@ icon: UsersIcon, }, { name: "Keys", about: "The keys of this mind.", href: `${stack}/keys`, icon: KeyRoundIcon }, - { - name: "Other minds", - about: "The minds that may send events here.", - href: `${stack}/minds`, - icon: CompassIcon, - }, ]; const links = [ @@ -227,42 +140,23 @@ // Personal items inside the account popover above Sign out. const accountLinks = [{ name: "Your sessions", href: `${stack}/sessions`, icon: HistoryIcon }]; -// The sidebar for a person who has not toggled it yet: as index.html drew it in its frame (open, -// or the rail of icons for a first arrival at the onboarding agent). A choice they made wins. +// The sidebar for a person who has not toggled it yet: as index.html drew it in its frame. A +// choice they made wins. const sidebarDefaultOpen = document.documentElement.dataset.sidebar !== "collapsed"; -// The mind's name and icon, as its owner wrote them (profile.ts, the folder profile/ of the -// repo): the zone's website answers them to anyone. The Dash never waits for the answer: it draws -// with the zone at once, and takes the name and the icon when they are here. -// A zone that answers no profile (a worker.ts of your own without the routes) keeps the zone -// as its name. -// -// AFTER EACH PUBLICATION the open Dash reads them again (live-reload.js tells the window), so a -// new name or icon shows with no reload. `at` makes the addresses new ones: a browser keeps the -// profile and the icon for five minutes. -const readProfile = (at) => - fetch(`https://${zone}/.well-known/iterate-profile${at ? `?at=${at}` : ""}`) - .then((answer) => answer.json()) - .then((said) => (at && said.icon ? { ...said, icon: `${said.icon}?at=${at}` } : said)) - .catch(() => null); -const profile = readProfile(); - +// The mind's name and icon, as its owner wrote them (the folder profile/ of /repos/config): the +// zone's website answers them to anyone. The Dash never waits for the answer: it draws with the +// zone at once, and takes the name and the icon when they are here. A zone that answers no +// profile keeps the zone as its name. function MindDash() { - const [{ name, icon }, setProfile] = useState({}); - useEffect(() => { - void profile.then((said) => said && setProfile(said)); - const readAgain = async () => { - const at = Date.now(); - const said = await readProfile(at); - if (!said) return; - setProfile(said); - // the tab's icon is the same file, on this host - const tab = document.querySelector('link[rel="icon"]'); - if (tab) tab.href = `/icon.svg?at=${at}`; - }; - window.addEventListener("live-reload:published", readAgain); - return () => window.removeEventListener("live-reload:published", readAgain); - }, []); + const profile = useQuery({ + queryKey: ["profile", zone], + queryFn: () => + fetch(`https://${zone}/.well-known/iterate-profile`).then((answer) => answer.json()), + retry: false, + staleTime: Infinity, + }); + const { name, icon } = profile.data || {}; // with no icon, the kit draws its own mark const logo = icon && html`<img src=${icon} alt="" className="size-8 rounded-md" />`; const shown = { @@ -279,4 +173,7 @@ return html`<${Dash} app="Dash" ...${shown} />`; } -render(html`<${MindDash} />`, document.getElementById("root")); +render( + html`<${QueryClientProvider} client=${new QueryClient()}><${MindDash} /><//>`, + document.getElementById("root"), +);
D public/brands/cloudflare.svg
@@ -1,1 +0,0 @@ -<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Cloudflare</title><path d="M16.5088 16.8447c.1475-.5068.0908-.9707-.1553-1.3154-.2246-.3164-.6045-.499-1.0615-.5205l-8.6592-.1123a.1559.1559 0 0 1-.1333-.0713c-.0283-.042-.0351-.0986-.021-.1553.0278-.084.1123-.1484.2036-.1562l8.7359-.1123c1.0351-.0489 2.1601-.8868 2.5537-1.9136l.499-1.3013c.0215-.0561.0293-.1128.0147-.168-.5625-2.5463-2.835-4.4453-5.5499-4.4453-2.5039 0-4.6284 1.6177-5.3876 3.8614-.4927-.3658-1.1187-.5625-1.794-.499-1.2026.119-2.1665 1.083-2.2861 2.2856-.0283.31-.0069.6128.0635.894C1.5683 13.171 0 14.7754 0 16.752c0 .1748.0142.3515.0352.5273.0141.083.0844.1475.1689.1475h15.9814c.0909 0 .1758-.0645.2032-.1553l.12-.4268zm2.7568-5.5634c-.0771 0-.1611 0-.2383.0112-.0566 0-.1054.0415-.127.0976l-.3378 1.1744c-.1475.5068-.0918.9707.1543 1.3164.2256.3164.6055.498 1.0625.5195l1.8437.1133c.0557 0 .1055.0263.1329.0703.0283.043.0351.1074.0214.1562-.0283.084-.1132.1485-.204.1553l-1.921.1123c-1.041.0488-2.1582.8867-2.5527 1.914l-.1406.3585c-.0283.0713.0215.1416.0986.1416h6.5977c.0771 0 .1474-.0489.169-.126.1122-.4082.1757-.837.1757-1.2803 0-2.6025-2.125-4.727-4.7344-4.727"/></svg>
D public/brands/github.svg
@@ -1,1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="#181717"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
D public/brands/google.svg
@@ -1,6 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> - <path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/> - <path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/> - <path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/> - <path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/> -</svg>
D public/brands/slack.svg
@@ -1,24 +0,0 @@ -<svg - enable-background="new 0 0 2447.6 2452.5" - viewBox="0 0 2447.6 2452.5" - xmlns="http://www.w3.org/2000/svg" -> - <g clip-rule="evenodd" fill-rule="evenodd"> - <path - d="m897.4 0c-135.3.1-244.8 109.9-244.7 245.2-.1 135.3 109.5 245.1 244.8 245.2h244.8v-245.1c.1-135.3-109.5-245.1-244.9-245.3.1 0 .1 0 0 0m0 654h-652.6c-135.3.1-244.9 109.9-244.8 245.2-.2 135.3 109.4 245.1 244.7 245.3h652.7c135.3-.1 244.9-109.9 244.8-245.2.1-135.4-109.5-245.2-244.8-245.3z" - fill="#36c5f0" - /> - <path - d="m2447.6 899.2c.1-135.3-109.5-245.1-244.8-245.2-135.3.1-244.9 109.9-244.8 245.2v245.3h244.8c135.3-.1 244.9-109.9 244.8-245.3zm-652.7 0v-654c.1-135.2-109.4-245-244.7-245.2-135.3.1-244.9 109.9-244.8 245.2v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.3z" - fill="#2eb67d" - /> - <path - d="m1550.1 2452.5c135.3-.1 244.9-109.9 244.8-245.2.1-135.3-109.5-245.1-244.8-245.2h-244.8v245.2c-.1 135.2 109.5 245 244.8 245.2zm0-654.1h652.7c135.3-.1 244.9-109.9 244.8-245.2.2-135.3-109.4-245.1-244.7-245.3h-652.7c-135.3.1-244.9 109.9-244.8 245.2-.1 135.4 109.4 245.2 244.7 245.3z" - fill="#ecb22e" - /> - <path - d="m0 1553.2c-.1 135.3 109.5 245.1 244.8 245.2 135.3-.1 244.9-109.9 244.8-245.2v-245.2h-244.8c-135.3.1-244.9 109.9-244.8 245.2zm652.7 0v654c-.2 135.3 109.4 245.1 244.7 245.3 135.3-.1 244.9-109.9 244.8-245.2v-653.9c.2-135.3-109.4-245.1-244.7-245.3-135.4 0-244.9 109.8-244.8 245.1 0 0 0 .1 0 0" - fill="#e01e5a" - /> - </g> -</svg>
D public/brands/x.svg
@@ -1,1 +0,0 @@ -<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>X</title><path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"/></svg>
D public/call-facet.js
@@ -1,20 +0,0 @@ -// call-facet.js — THE CALL'S FACET SPEC for the Dash's first press of a call: the same object as -// `CALL_FACET` in ../../../call.ts, written here because a browser module cannot import call.ts -// (it imports iterate/sdk). A test holds the two equal (core/lib config-default-dash.test.ts). -export const CALL_FACET = { - className: "CallDurableObject", - mainModule: "call.ts", - source: ["itx", ["cd", "/"], "config"], - consumes: [ - "share/link-made", - "share/link-ended", - "share/guest-joined", - "events.iterate.com/itx/subscription-configured", - "call/due", - "events.iterate.com/agent/web-message-sent", - "events.iterate.com/agent/llm-request-settled", - "events.iterate.com/itx/run-requested", - "events.iterate.com/agent-ui/message-sent", - "events.iterate.com/llm-request/settled", - ], -};
D public/mcp-page.js
@@ -1,106 +0,0 @@ -// mcp-page.js — THE DASH'S MCP PAGE: how to connect coding agents (Claude Code, Codex, Claude) -// to this mind over MCP. Shows both the platform endpoint (`https://<mind>/mcp`, which stays up -// even if userspace code breaks the web UI) and the customizable userspace endpoint -// (`https://mcp.<zone>/mcp`, served by apps/mcp/ in /repos/config). -import { html } from "@iterate-com/ui/page"; -import { CopyText } from "@iterate-com/ui/components/copy-text"; -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@iterate-com/ui/components/ui/card"; - -function Command({ text, label }) { - return html` - <${CopyText} - text=${text} - label=${label} - className="[&>code]:overflow-visible [&>code]:break-all [&>code]:whitespace-normal" - /> - `; -} - -function EndpointSection({ title, description, server, name }) { - return html` - <${Card}> - <${CardHeader}> - <${CardTitle}>${title}<//> - <${CardDescription}>${description}<//> - <//> - <${CardContent} className="flex flex-col gap-4"> - <div className="flex flex-col gap-1.5"> - <div className="text-xs font-medium text-muted-foreground">Server URL</div> - <${Command} text=${server} label=${`${title} address`} /> - </div> - <div className="flex flex-col gap-1.5"> - <div className="text-xs font-medium text-muted-foreground"> - Claude Code — add, then run <code>/mcp</code>, pick <code>${name}</code>, Authenticate - </div> - <${Command} - text=${`claude mcp add --transport http ${name} ${server}`} - label=${`Claude Code command for ${title}`} - /> - </div> - <div className="flex flex-col gap-1.5"> - <div className="text-xs font-medium text-muted-foreground">Codex CLI</div> - <${Command} - text=${`codex mcp add ${name} --url ${server}`} - label=${`Codex add command for ${title}`} - /> - <${Command} - text=${`codex mcp login ${name}`} - label=${`Codex login command for ${title}`} - /> - </div> - <//> - <//> - `; -} - -export function DashMcp({ mind }) { - const zone = location.hostname.split(".").slice(1).join("."); - const platformServer = `https://${mind}/mcp`; - const platformName = mind.replaceAll(".", "-"); - const userspaceHost = `mcp.${zone}`; - const userspaceServer = `https://${userspaceHost}/mcp`; - const userspaceName = userspaceHost.replaceAll(".", "-"); - - return html` - <div className="min-h-0 flex-1 overflow-y-auto"> - <div className="mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 md:p-8"> - <div className="flex flex-col gap-1.5"> - <h1 className="text-2xl font-semibold tracking-tight">MCP</h1> - <p className="text-sm text-muted-foreground"> - Connect Claude Code, Codex, or Claude to this mind over MCP. One tool, - <code>run</code>, evaluates scripts at <code>/</code> as you, and every run is recorded - on the mind root's log. - </p> - <p className="text-sm text-muted-foreground"> - <strong>Handy safety net:</strong> the Dash and every web UI in this mind live in - userspace (<code>/repos/config</code>). Connecting a coding agent to the platform - <code>/mcp</code> endpoint means you can still inspect and fix - <code>/repos/config</code> - even if a bad edit bricks the web UI. - </p> - </div> - <${EndpointSection} - title="Platform MCP (always-on recovery)" - description="Served directly by the platform — keeps working even if userspace code breaks the Dash or another web app." - server=${platformServer} - name=${platformName} - /> - <${EndpointSection} - title="Userspace MCP (customizable)" - description="Served by apps/mcp/ in /repos/config, so you can customize the instructions and run tool description your coding agents see." - server=${userspaceServer} - name=${userspaceName} - /> - </div> - </div> - `; -} - -// holds nothing of a session -DashMcp.staysOverReconnect = true;
D public/share-links.js
@@ -1,80 +0,0 @@ -// share-links.js — PURE: THE TEMPLATE'S ONE LINK-MAKING for guests, and the event that ends a link. -// The Dash's Share (the kit's, which app.js's `share` hands it to) and Meet's page append what it -// makes through the member's own stub; `itx.config.shareAgent` (../../../call/share-api.ts) appends it as the config. -// The events and their rules are the call's (../../../call/share.ts): a link lets a guest into that -// one agent's chat and call, through Meet's guest page (`https://meet.<zone>/join<agent>#<secret>`, -// ../../meet/app.ts), which checks the link by the call's state. It is a plain module because a -// page cannot import a .ts file; the config imports the Dash's file as it is. -// TWINS: apps/dash/public/share-links.js and apps/meet/public/share-links.js hold the same bytes, -// one in each app's folder, because an app follows the template whole. Change both together: -// core/lib's config-default-dash.test.ts holds them equal, and folds what they make through -// call/share.ts. - -export const LINK_MADE = "share/link-made"; -export const LINK_ENDED = "share/link-ended"; - -const HOUR = 3_600_000; -/** The longest life of a link: the share rules' own limit (call/share.ts `LONGEST_LIFETIME_MS`). */ -export const LONGEST_LIFETIME = 7 * 24 * HOUR; -/** How long a link lives when its maker says nothing. */ -export const DEFAULT_LIFETIME = 24 * HOUR; - -/** One part of an agent's path: a letter or digit first, then letters, digits and `._:@+-`. */ -const SEGMENT = /^[A-Za-z0-9][A-Za-z0-9._:@+-]{0,127}$/; - -/** The agent's path if `value` is one, exactly as written, else null: `/agents/<part>(/<part>)*`, - * at most 300 characters. Nothing is decoded or resolved, so the path checked is the path used. */ -export function agentPathOf(value) { - if (typeof value !== "string" || value.length > 300) return null; - const [empty, agents, ...rest] = value.split("/"); - if (empty !== "" || agents !== "agents" || rest.length === 0) return null; - return rest.every((part) => SEGMENT.test(part)) ? value : null; -} - -const base64url = (bytes) => - btoa(String.fromCharCode(...bytes)) - .replaceAll("+", "-") - .replaceAll("/", "_") - .replace(/=+$/, ""); - -/** A link's secret as the log knows it: the SHA-256 of its text, lower-case hex. */ -export const hashOfSecret = async (secret) => - [...new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(secret)))] - .map((byte) => byte.toString(16).padStart(2, "0")) - .join(""); - -/** A new link to `agent`, on the zone `zone`: 32 random bytes as its secret (base64url), its hash, - * a UUID as its id. It lives `lifetimeMs`. Answers the ONE event to append, and the link to show - * once, `https://meet.<zone>/join<agent>#<secret>`, with its id and its end: the secret is in the - * fragment alone, which no request carries, and the log keeps its hash alone. A path that is no - * agent's, a life that is no positive number, or one longer than `LONGEST_LIFETIME`, throws: a - * link never lives another time than the one its maker asked for. */ -export async function makeLink({ zone, agent, lifetimeMs, now }) { - if (!agentPathOf(agent)) throw new Error(`${agent} is no agent's path.`); - if (!(lifetimeMs > 0)) throw new Error("A link lives a positive number of milliseconds."); - if (lifetimeMs > LONGEST_LIFETIME) - throw new Error( - `A link lives 7 days at most (${LONGEST_LIFETIME} ms); ${lifetimeMs} ms was asked for.`, - ); - const secret = base64url(crypto.getRandomValues(new Uint8Array(32))); - const secretHash = await hashOfSecret(secret); - const link = crypto.randomUUID(); - const until = now + lifetimeMs; - return { - event: { - type: LINK_MADE, - idempotencyKey: `${LINK_MADE}:${link}`, - payload: { link, secretHash, until }, - }, - url: `https://meet.${zone}/join${agent}#${secret}`, - link, - until, - }; -} - -/** The event that ends `link`. */ -export const endLink = (link) => ({ - type: LINK_ENDED, - idempotencyKey: `${LINK_ENDED}:${link}`, - payload: { link }, -});
A tests/page.test.mjs
@@ -0,0 +1,30 @@ +// tests/page.test.mjs — what the Dash's page does before its modules have loaded (../index.html, +// ../public/app.js), read from the files' text. +// Run from the repo's root: node --test "tests/*.test.mjs" +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { test } from "node:test"; + +const page = readFileSync(new URL("../index.html", import.meta.url), "utf8"); +const script = readFileSync(new URL("../public/app.js", import.meta.url), "utf8"); + +test("the page asks for its session in its head, while its modules load, and app.js takes that answer", () => { + const asked = page.indexOf('window.__session = fetch("/.auth/session.json")'); + assert.ok(asked > 0); + // before the first stylesheet, which a script after it waits for, and before the app's module + assert.ok(asked < page.indexOf('rel="stylesheet"')); + assert.ok(script.includes("window.__session")); +}); + +test("the Dash asks the zone's website for the profile, and draws with the zone until it answers", () => { + assert.ok(script.includes("fetch(`https://${zone}/.well-known/iterate-profile`)")); + assert.ok(script.includes("name: name || zone")); +}); + +test("the sidebar shows Repos and Contexts as rows of their own", () => { + for (const id of ["repos", "contexts"]) { + const block = new RegExp(`id:\\s*"${id}"[\\s\\S]*?component:`).exec(script)?.[0]; + assert.ok(block, `the page "${id}"`); + assert.doesNotMatch(block, /\brow\s*:\s*false\b/); + } +});
A tsconfig.json
@@ -0,0 +1,4 @@ +{ + "extends": "../tsconfig.base.json", + "include": ["**/*.ts"] +}