dash: the Dash app, as the template has it
Misha Kaletsky, 2026-11-24 18:16 UTC · cce61531adc788e37e385d360d445a1bbe3a2025 · the first commit
13 files changed
- A app.ts
- A index.html
- A links.ts
- A public/app.css
- A public/app.js
- A public/brands/cloudflare.svg
- A public/brands/github.svg
- A public/brands/google.svg
- A public/brands/slack.svg
- A public/brands/x.svg
- A public/call-facet.js
- A public/mcp-page.js
- A public/share-links.js
A app.ts
@@ -0,0 +1,38 @@ +// 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. +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 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). */ +const DASH: AppDescription = { name: "Dash", icon: "/icon.svg", for: "members" }; + +export function dashApp() { + 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), + /** 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 }, + }); + }, + }; +}
A index.html
@@ -0,0 +1,127 @@ +<!doctype html> +<html lang="en" data-frame> + <head> + <meta charset="utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + <title>Dash</title> + <!-- The components' modules and stylesheet come from one other host: the connection to it + starts now, while the rest of this head is read. --> + <link rel="preconnect" href="https://esm.iterate.com" crossorigin /> + <link rel="icon" href="/icon.svg" type="image/svg+xml" /> + <!-- iterate's components, pinned to one build. To upgrade, change the version here. --> + <script type="importmap"> + { + "imports": { + "@iterate-com/ui/": "https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/", + "react": "https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/react", + "react/": "https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/react/", + "react-dom": "https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/react-dom", + "react-dom/": "https://esm.iterate.com/@iterate-com/ui@0.1.0-main.20261124T154040Z-83b4390/react-dom/", + "lucide-react": "https://esm.iterate.com/lucide-react@1.48.0?external=react,react-dom" + } + } + </script> + <!-- THE PAGE'S SOCKET AND ITS SESSION, asked for here and not when the app's modules have + loaded, which is a second later: `memberItx` (@iterate-com/ui/live, in app.js) takes the + socket for its first session, and app.js takes the session's answer (the mind's + address) from `__session`. Without these lines the app asks for both itself when it runs. + It stands before the stylesheets, because a script after a stylesheet waits for it. --> + <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> + <!-- THE FRAME'S SHAPE, said before the first paint. The body draws the app's frame from HTML + 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 + components that the person's wait began with this frame. --> + <script> + { + const query = new URLSearchParams(location.search); + const agent = location.pathname.startsWith("/agents/") + ? location.pathname.slice("/agents".length) + : location.pathname === "/agents" + ? 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"; + if (agent) document.documentElement.dataset.page = "agent"; + } + </script> + <!-- The stylesheet at the address the build serves it from: the shorter one answers with a + redirect to this one. `crossorigin`, so it comes over the connection the modules use. --> + <link + rel="stylesheet" + 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. --> + <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 + row and the page's first shapes, with no word in it. app.css draws it and says where each + number comes from. React puts the app in #root, and so takes the frame out. --> + <div id="root"> + <div class="frame" aria-busy="true" aria-label="Loading"> + <div class="frame-sidebar" data-frame="sidebar"> + <div class="frame-mind"></div> + <div class="frame-row"></div> + <div class="frame-label"></div> + <div class="frame-agent"><span></span><span></span></div> + <div class="frame-agent"><span></span><span></span></div> + <div class="frame-agent"><span></span><span></span></div> + <div class="frame-view-all"></div> + <div class="frame-foot"></div> + <div class="frame-foot"></div> + <div class="frame-fold"></div> + <div class="frame-account"></div> + </div> + <div class="frame-main"> + <div class="frame-header" data-frame="header"> + <div class="frame-button"></div> + <div class="frame-path"></div> + <div class="frame-tabs"></div> + </div> + <div class="frame-page" data-frame="page"> + <div class="frame-column"> + <div class="frame-line"></div> + <div class="frame-composer"></div> + <div class="frame-section"> + <div></div> + <div></div> + </div> + <div class="frame-section"> + <div></div> + <div class="frame-card"></div> + </div> + </div> + </div> + </div> + </div> + </div> + <script type="module" src="/app.js"></script> + </body> +</html>
A links.ts
@@ -0,0 +1,187 @@ +// 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); + } +}
A public/app.css
@@ -0,0 +1,323 @@ +/* app.css — the page's own layout. The Dash's parts bring their look in @iterate-com/ui's + stylesheet; what this page adds is written here as plain CSS, on the theme's variables + (apps/theme.css). */ +html, +body, +#root { + height: 100%; +} + +/* THE FRAME: what index.html draws before the app has loaded, in the places where the app's shell + will draw the same parts, so that nothing moves when the app takes over. It is plain CSS on the + theme's variables, and holds no word. + + THE NUMBERS ARE THE SHELL'S (@iterate-com/ui: components/ui/sidebar.tsx, components/app-shell.tsx + and components/dash): the sidebar is 16rem wide, or 3rem as a rail of icons; under 768px it is + out of sight and the page has a header row of 42px; an agent's page has a header row of 45px + with a rule under it (53px under 768px); a page's content is a column of 48rem. When a new + build of the components changes one, change it here. + + index.html says the shape on the root element before the first paint: data-sidebar is "open" + or "collapsed", and data-page is "agent" on an agent's page. */ +.frame { + display: flex; + width: 100%; + height: 100svh; + background: var(--background); +} +/* each shape is an element with nothing in it */ +.frame :empty { + flex: none; + border-radius: calc(var(--radius) - 2px); + background: var(--muted); +} + +/* the sidebar: the mind's name, New agent, Agents label + three loading rows, View all, + two foot rows (Approvals, Settings), and Collapse + account at its foot */ +.frame-sidebar { + position: relative; + flex: none; + box-sizing: border-box; + width: 16rem; + border-right: 1px solid var(--sidebar-border); + background: var(--sidebar); +} +.frame-sidebar div { + position: absolute; + right: 8px; + left: 8px; + height: 32px; +} +.frame-mind { + top: 8px; +} +.frame-sidebar .frame-mind { + height: 48px; +} +.frame-sidebar .frame-row { + right: auto; + left: 16px; + width: 55%; + height: 12px; +} +.frame-row:nth-of-type(2) { + top: 82px; +} +.frame-sidebar .frame-label { + top: 123px; + right: auto; + left: 16px; + width: 24%; + height: 10px; +} +.frame-sidebar .frame-agent { + display: flex; + align-items: center; + gap: 8px; + box-sizing: border-box; + height: 48px; + padding: 0 8px; +} +.frame-sidebar .frame-agent span:first-child { + width: 16px; + height: 16px; +} +.frame-sidebar .frame-agent span:last-child { + width: 66.6667%; + height: 16px; +} +.frame-sidebar .frame-agent:nth-of-type(4) { + top: 144px; +} +.frame-sidebar .frame-agent:nth-of-type(5) { + top: 192px; +} +.frame-sidebar .frame-agent:nth-of-type(6) { + top: 240px; +} +.frame-sidebar .frame-view-all { + top: 302px; + right: auto; + left: 16px; + width: 34%; + height: 12px; +} +.frame-sidebar .frame-foot { + right: auto; + left: 16px; + width: 44%; + height: 12px; +} +.frame-sidebar .frame-foot:nth-of-type(8) { + bottom: 150px; +} +.frame-sidebar .frame-foot:nth-of-type(9) { + bottom: 118px; + width: 36%; +} +.frame-sidebar .frame-fold { + bottom: 64px; + height: 28px; +} +.frame-sidebar .frame-account { + bottom: 8px; + height: 48px; +} +/* the rail: each part is its icon's square */ +[data-sidebar="collapsed"] .frame-sidebar { + width: 3rem; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-mind, +[data-sidebar="collapsed"] .frame-sidebar .frame-fold, +[data-sidebar="collapsed"] .frame-sidebar .frame-account { + height: 32px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-row { + width: 16px; + height: 16px; + margin-top: -18px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-label { + display: none; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-agent { + justify-content: center; + height: 32px; + padding: 0; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-agent span:last-child { + display: none; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-agent:nth-of-type(4) { + top: 104px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-agent:nth-of-type(5) { + top: 136px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-agent:nth-of-type(6) { + top: 168px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-view-all { + top: 212px; + width: 16px; + height: 16px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-foot { + width: 16px; + height: 16px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-foot:nth-of-type(8) { + bottom: 136px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-foot:nth-of-type(9) { + bottom: 104px; +} +[data-sidebar="collapsed"] .frame-sidebar .frame-fold { + bottom: 48px; +} + +.frame-main { + display: flex; + flex: 1; + flex-direction: column; + min-width: 0; +} + +/* the header row: an agent's page has one at any width, with the agent's path and its two tabs */ +.frame-header { + position: relative; + display: none; + flex: none; + box-sizing: border-box; + height: 45px; +} +.frame-header div { + position: absolute; + top: 12px; + height: 20px; +} +.frame-header .frame-button { + display: none; +} +.frame-path { + left: 16px; + width: min(14rem, 40%); +} +.frame-header .frame-tabs { + top: 6px; + right: 16px; + width: 115px; + height: 32px; +} +[data-page="agent"] .frame-header { + display: block; + border-bottom: 1px solid var(--border); +} + +/* the page, in the content's column: the home's composer and its two sections, which the app + draws again in the same places until the page's own part has loaded (the components' DashPlaceholder); on an + agent's page, one line where the chat's first row will stand */ +.frame-page { + flex: 1; + min-height: 0; + overflow: hidden; +} +.frame-column { + display: flex; + flex-direction: column; + gap: 2rem; + box-sizing: border-box; + width: 100%; + max-width: 48rem; + margin: 0 auto; + padding: 4rem 2rem 0; +} +.frame-composer { + height: 58px; +} +.frame-section { + display: flex; + flex-direction: column; + gap: 20px; + box-sizing: border-box; + height: 88px; + padding-top: 4px; +} +.frame-section div { + width: 7rem; + height: 12px; +} +.frame-section div + div { + width: 12rem; +} +.frame-section + .frame-section { + gap: 16px; + height: auto; +} +.frame-section .frame-card { + width: auto; + height: 68px; +} +.frame-column .frame-line { + display: none; + width: 9rem; + height: 12px; + margin: 4px 0; +} +[data-page="agent"] .frame-column { + padding: 1rem 1.5rem 0; +} +[data-page="agent"] .frame-composer, +[data-page="agent"] .frame-section { + display: none; +} +[data-page="agent"] .frame-column .frame-line { + display: block; +} + +/* under 768px: no sidebar, and a header row on every page with the sidebar's button */ +@media (max-width: 767px) { + .frame-sidebar { + display: none; + } + .frame-header { + display: block; + height: 42px; + } + .frame-header .frame-button { + top: 14px; + left: 16px; + display: block; + width: 20px; + height: 20px; + } + .frame-header .frame-path, + .frame-header .frame-tabs { + display: none; + } + [data-page="agent"] .frame-header { + height: 53px; + } + [data-page="agent"] .frame-header .frame-button, + [data-page="agent"] .frame-header .frame-path { + top: 16px; + } + [data-page="agent"] .frame-header .frame-path { + left: 52px; + display: block; + width: 30%; + } + [data-page="agent"] .frame-header .frame-tabs { + display: block; + height: 40px; + } + .frame-column { + padding: 2rem 1rem 0; + } + .frame-composer { + height: 50px; + } + [data-page="agent"] .frame-column { + padding: 1rem 1rem 0; + } +}
A public/app.js
@@ -0,0 +1,282 @@ +// app.js — THE DASH'S PAGE: which pages there are and in what order, their names and icons, +// and the apps and the pages about access it links to. `Dash` from @iterate-com/ui draws them: +// how the sidebar, the URL and the three ids `agents`, `contexts` and `settings` work is in its +// source, packages/ui/src/components/dash/dash.tsx (links below). +// +// A PAGE OF YOUR OWN is a row with a component, which gets `{ itx, mind, principal, page, agents }`: +// import { Notes } from "./notes.js"; +// { 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). +// 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 { + Dash, + DashAnalytics, + DashContexts, + DashIntegrations, + DashRepo, + DashSecrets, + DashSettings, +} from "@iterate-com/ui/components/dash/dash"; +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 +// asks the mind who is signed in after it has drawn. +const itx = memberItx(); +// The mind's address is its control-plane hostname, where the stack's own pages are (keys, members, +// approvals): this host says it (`/.auth/session.json`, ../app.ts). The page never works it out +// from its own hostname, which may be in any zone of the mind. The Dash waits for this answer +// 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()); +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. */ +const zone = location.hostname.split(".").slice(1).join("."); + +const pages = [ + { id: "home", name: "Home", icon: LayoutDashboardIcon, component: DashHome }, + { + id: "agents", + name: "Agents", + icon: BotIcon, + component: DashAgents, + // the chat shows who else has this agent open now and who is typing: the faces come from the + // 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.", + icon: LockKeyholeIcon, + row: false, + component: DashSecrets, + }, + { + id: "repos", + name: "Config repo", + about: "The mind's code. A commit to main publishes it.", + icon: FolderGit2Icon, + component: DashRepo, + }, + { + id: "contexts", + name: "Contexts", + about: "Every context of the mind, raw and live.", + 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. +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.", + host: "tasks", + icon: CircleCheckIcon, + }, +].map((app) => ({ ...app, href: `https://${app.host}.${zone}` })); + +// The stack's pages about who may do what. "Approvals" shows how many requests wait for a yes. +const access = [ + { + name: "Approvals", + about: "What waits for a passkey, and the rules.", + href: `${stack}/secrets/approvals`, + icon: ShieldCheckIcon, + count: "approvals", + }, + { + name: "Members", + about: "Who reaches the whole mind.", + href: `${stack}/members`, + 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 = [ + { title: "Access", rows: access }, + { title: "Apps", rows: apps }, +]; + +// Anchored at the foot of the sidebar above Settings. +const foot = [ + { + name: "Approvals", + href: `${stack}/secrets/approvals`, + icon: ShieldCheckIcon, + count: "approvals", + }, +]; + +// 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. +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(); + +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); + }, []); + // with no icon, the kit draws its own mark + const logo = icon && html`<img src=${icon} alt="" className="size-8 rounded-md" />`; + const shown = { + name: name || zone, + logo, + itx, + mind, + pages, + links, + foot, + accountLinks, + sidebarDefaultOpen, + }; + return html`<${Dash} app="Dash" ...${shown} />`; +} + +render(html`<${MindDash} />`, document.getElementById("root"));
A public/brands/cloudflare.svg
@@ -0,0 +1,1 @@ +<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>
A public/brands/github.svg
@@ -0,0 +1,1 @@ +<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>
A public/brands/google.svg
@@ -0,0 +1,6 @@ +<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>
A public/brands/slack.svg
@@ -0,0 +1,24 @@ +<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>
A public/brands/x.svg
@@ -0,0 +1,1 @@ +<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>
A public/call-facet.js
@@ -0,0 +1,20 @@ +// 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", + ], +};
A public/mcp-page.js
@@ -0,0 +1,106 @@ +// 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;
A public/share-links.js
@@ -0,0 +1,80 @@ +// 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 }, +});