@arcforge/types 2.0.146 → 2.0.147

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,4 +5,4 @@
5
5
  // A profile has no node_modules, so its globals cannot import — they must be
6
6
  // this text, inlined.
7
7
 
8
- export const TUI_CONTRACT = " /**\n * The TUI extension contract — what a user's `main.ts`, a profile config, and\n * a published extension are written against.\n *\n * ── This file is copied verbatim into generated type frames ──────────────────\n *\n * `axon prepare` writes this source text into a profile's `.axon/types/` and an\n * extension's `.extension/types/` as ambient globals. That is why it declares\n * NO imports: a profile directory has no node_modules for an import to resolve\n * through (see prompt-dts.ts, which accepted the same constraint for the same\n * reason). Unlike prompts, there is no duplicated copy to keep in step — the\n * generator reads THIS file, so the contract and the globals cannot drift.\n *\n * Adding an import here breaks every profile's typecheck. Add the type instead.\n *\n * ── What this layer is for ───────────────────────────────────────────────────\n *\n * Workflow design in the terminal, and nothing more. The rule that draws the\n * boundary: an extension DRIVES the conversation, it never CONSUMES it.\n * `agents.send()` returns void — an extension that awaited model output and\n * branched on its text would be writing an agent, in the config layer, badly.\n * Agent behaviour belongs in a cognet, which the same user can build.\n *\n * The surface is deliberately small and complete against one test: everything\n * reachable from the keyboard is reachable from code. Mode keys → `mode`,\n * typing → `input`, palette navigation → `palette`, `:` → `commands`, chords →\n * `keys`, `~`/`/`/`^` → `agents`, Ctrl+C → `tui`. `keys.send()` backstops\n * whatever this missed. Nothing here renders: user surfaces are built from the\n * palette primitives, so every extension's UI is as good as the built-in one\n * and stays that way when the palette improves.\n */\n\n // ── Disposal ─────────────────────────────────────────────────────────────────\n\n /**\n * Undoes one registration.\n *\n * Every `register`/`create` returns one, and the loader tracks them per\n * extension so a hot-reload can tear the previous load down before running\n * setup again. Without this, each reload leaves its registrations behind and\n * one keystroke fires N handlers — the accumulation `Hooks().reset()` exists to\n * prevent on the agent runtime side.\n */\n type Disposer = () => void\n\n // ── Palette ──────────────────────────────────────────────────────────────────\n\n /**\n * One row in any palette — user-created or built-in.\n *\n * This is the SAME item type the TUI's own modes produce. A user palette that\n * could not express what `~` or `^` expresses would turn every gap into a\n * feature request, so the built-ins hold no privileged row shape: they are\n * simply the palettes that ship.\n */\n type PaletteItem = {\n id: string\n label: string\n description?: string\n /**\n * Independently-searchable parts of this row, for a list long enough that\n * one substring match over `label` stops being enough — every query term\n * narrows against any chunk. The model palette sets route and model id as\n * separate chunks, which is what lets ~800 rows live in one flat list with\n * no tabs or pages. Omit for ordinary rows.\n */\n chunks?: readonly string[]\n /**\n * Run on Enter. A returned promise holds the palette in its working state\n * until it settles. The signal aborts when the user escapes mid-flight —\n * actions that cannot be cancelled may ignore it.\n */\n action?: (signal: AbortSignal) => void | Promise<void>\n /** Selecting this row rewrites the query to this text instead of running `action` — descending into a group. */\n descendQuery?: string\n /** Selecting this row shows these rows as a follow-up list — a confirm/choice step. Computed at the moment it is confirmed. */\n choices?: () => PaletteItem[]\n /** Run on cursor movement, before confirming — live preview. */\n preview?: () => void\n /** Shown in the working row while an async `action` is in flight. */\n workingMessage?: string\n /**\n * Close immediately and let `action` finish in the background, rather than\n * holding the list open behind a working row.\n *\n * Only for actions whose progress has its OWN surface. An action that\n * reports nowhere else must not set this, or its failure becomes invisible.\n */\n detach?: boolean\n /** Non-selectable section header. */\n header?: boolean\n /** Non-selectable blank spacer between groups. */\n separator?: boolean\n }\n\n /** A tab in a tabbed palette. First tab is active on entry. */\n type PaletteTab = {\n id: string\n label: string\n }\n\n /** Loading/error indicator shown above the item list. */\n type PaletteStatus =\n | { kind: \"loading\"; message: string }\n | { kind: \"error\"; message: string }\n | null\n\n /**\n * What one query resolves to — items plus everything else this palette has to\n * say about that same query.\n *\n * Derived from a single call so status, breadcrumb and items can never drift\n * out of sync, which is the failure mode of computing them as independently\n * triggered fields. Returning a bare array is shorthand for `{ items }`.\n */\n type PaletteResult = {\n items: PaletteItem[]\n /** Prefix shown on every row — a path walked so far. */\n breadcrumb?: string | null\n status?: PaletteStatus\n /** True when the query cannot resolve to anything selectable — a dead-end token. */\n invalid?: boolean\n }\n\n /**\n * A user-defined palette.\n *\n * `list` is the only required member: given the query and active tab, return\n * the rows. It may be async — the palette shows its own loading state while the\n * first call is in flight, and results are cached until `refresh()` is called\n * on the handle.\n */\n type PaletteDefinition = {\n /**\n * Produce the rows for one query.\n *\n * The TUI applies its own substring filter over the returned items unless\n * `filter: false` — so a list that does not care about `query` can ignore\n * the argument entirely and still be searchable.\n */\n list: (query: string, tab: string | null) => PaletteItem[] | PaletteResult | Promise<PaletteItem[] | PaletteResult>\n /** This palette filters by query itself — the TUI must not filter again. */\n filter?: boolean\n /** Declares this palette as tabbed. Omit for a single flat list. */\n tabs?: PaletteTab[]\n /** Max visible rows before scrolling. */\n maxHeight?: number\n /**\n * \"top\" (default): newest first, cursor starts at the top. \"bottom\": items\n * are given oldest→newest, the cursor starts on the last row and up-arrow\n * walks back in time — the terminal-log feel of history and session mode.\n */\n anchor?: \"top\" | \"bottom\"\n /**\n * A mode key that opens this palette from an empty input, e.g. \"&\".\n *\n * Throws at registration if the key is already taken — a silently shadowed\n * mode key is unbearable to debug in someone else's config.\n */\n key?: string\n /** Symbol shown in the input bar while this palette is open. Defaults to `key`. */\n symbol?: string\n /** One-line description, shown in `?` (help) alongside the built-in modes. */\n description?: string\n }\n\n /** Handle on one registered palette. */\n type PaletteHandle = {\n readonly name: string\n /** Open it. Rejects if another palette is already open — see `palette.open`. */\n open: () => Promise<void>\n /** Drop the cached list so the next open recomputes it. Does not reopen. */\n refresh: () => void\n /** Unregister, closing it first if it is open. */\n dispose: Disposer\n }\n\n /** A pick option carrying a value, for `pick` over things that are not strings. */\n type PickOption<T> = {\n label: string\n description?: string\n value: T\n }\n\n /**\n * The palette — the TUI's interaction primitive, and the reason this layer can\n * stay small. Registered palettes cover \"the user opens a list\"; `pick`,\n * `confirm` and `prompt` cover \"code asks the user a question\".\n *\n * The question verbs return promises rather than taking callbacks, which is\n * what makes multi-step flows fall out for free: they are sequential awaits,\n * not a wizard framework.\n *\n * Every question resolves to a cancelled value on escape — `undefined`, or\n * `false` for `confirm`. That is in the return type deliberately: a caller is\n * forced to handle the user walking away.\n */\n type AxonPalette = {\n /** Register a palette. Throws if `name` is taken. */\n create: (name: string, definition: PaletteDefinition) => PaletteHandle\n\n /** A registered palette by name, or null. */\n get: (name: string) => PaletteHandle | null\n\n /**\n * Open a registered palette by name.\n *\n * Throws if no palette has that name, and throws if another palette is\n * already open — stealing the palette out from under someone mid-navigation\n * is exactly the kind of silent degradation that makes an extension system\n * feel haunted. Check `palette.isOpen` first if a keybind might collide.\n */\n open: (name: string) => Promise<void>\n\n /** Close whatever is open. No-op when nothing is. */\n close: () => void\n\n /** True while any palette is open, built-in or user-defined. */\n readonly isOpen: boolean\n\n /** Ask the user to choose one of a list of strings. Resolves undefined on escape. */\n pick: {\n (options: readonly string[], opts?: { placeholder?: string }): Promise<string | undefined>\n <T>(options: readonly PickOption<T>[], opts?: { placeholder?: string }): Promise<T | undefined>\n }\n\n /** Ask a yes/no question. Resolves false on escape. */\n confirm: (message: string) => Promise<boolean>\n\n /** Ask for a line of text. Resolves undefined on escape. */\n prompt: (message: string, opts?: { placeholder?: string; initial?: string }) => Promise<string | undefined>\n }\n\n // ── Commands ─────────────────────────────────────────────────────────────────\n\n /**\n * Where a command sits in the `:` tree.\n *\n * `\"deploy\"` is top level; `[\"theme\", \"set\"]` is nested under a group, which is\n * created on demand. Both forms accepted — a flat command should not have to be\n * written as a one-element array.\n */\n type CommandPath = string | readonly string[]\n\n /**\n * What a command IS — its behaviour and how it presents.\n *\n * ── Why a definition object rather than trailing options ────────────────────\n *\n * The alternative was `register(path, action, options?)`, and it loses for the\n * same reason positional hook arguments do. A third parameter is a fixed slot:\n * the day a command needs a fourth thing, it is either a fourth positional\n * nobody discovers or a breaking change. And `register(\"x\", fn, {...})` reads\n * as a function with some settings bolted on, when the truth is that the\n * behaviour and the presentation are one declaration.\n *\n * It also matches `palette.create(name, definition)`, which already takes its\n * work verb (`list`) inside the object. Two registration APIs shaped\n * differently is a thing to remember for no reason.\n *\n * The verb is `run` because that is what a command does. `action` was the\n * internal name and it describes a slot in a data structure, not the thing a\n * user is writing.\n */\n type CommandDefinition = {\n /**\n * The command's behaviour.\n *\n * A returned promise holds the palette in its working state until it\n * settles. The signal aborts when the user escapes mid-flight — a command\n * that cannot be cancelled may ignore it.\n */\n run: (signal: AbortSignal) => void | Promise<void>\n /** Shown beside the command in the palette. */\n description?: string\n /** Shown in the working row while an async command runs. */\n workingMessage?: string\n }\n\n type CommandsApi = {\n /**\n * Add a command to the `:` tree.\n *\n * Two forms, and the short one is not a legacy shape to be migrated off:\n *\n * commands.register(\"deploy\", async () => { ... })\n * commands.register(\"deploy\", {\n * async run() { ... },\n * description: \"Restart and redeploy\",\n * })\n *\n * A command with nothing to configure is genuinely just its behaviour, and\n * making that case carry `{ run }` would be ceremony charged to the most\n * common thing anyone writes. The moment there IS configuration, the object\n * form keeps it in one declaration instead of trailing off the end.\n *\n * Built-in commands always win a collision, and two extensions colliding is\n * first-registered-wins with a warning naming both — never silent shadowing.\n */\n register: {\n (path: CommandPath, run: (signal: AbortSignal) => void | Promise<void>): Disposer\n (path: CommandPath, definition: CommandDefinition): Disposer\n }\n\n /**\n * Run a command by path, exactly as pressing Enter on it would.\n *\n * This is how an extension reaches functionality that has a command but no\n * dedicated API — one verb instead of re-exposing every command's\n * implementation. Throws if the path resolves to nothing.\n */\n run: (path: CommandName | CommandPath) => Promise<void>\n\n /** Every registered command path, built-in and user. */\n list: () => readonly string[][]\n }\n\n // ── Keys ─────────────────────────────────────────────────────────────────────\n\n type KeysApi = {\n /**\n * Bind a chord, e.g. \"ctrl+o\".\n *\n * Built-in bindings win; two extensions colliding is first-wins with a\n * warning naming both. Bindings do not fire while a palette is open.\n */\n register: (chord: string, handler: () => void | Promise<void>) => Disposer\n\n /**\n * Deliver a keypress as though the user had typed it.\n *\n * The escape hatch that keeps this surface honest: anything the API forgot\n * to expose is still reachable, so a missing verb is an inconvenience\n * rather than a wall.\n */\n send: (chord: string) => void\n }\n\n // ── Modes ────────────────────────────────────────────────────────────────────\n\n /**\n * Built-in mode names. A user palette registered with a `key` adds its own\n * name to what `mode.set` accepts at runtime, which is why this is not a\n * closed union at the type level.\n */\n type BuiltinMode =\n | \"normal\"\n | \"command\"\n | \"model\"\n | \"session\"\n | \"agent\"\n | \"instance\"\n | \"voice\"\n | \"help\"\n | \"history\"\n | \"prompt\"\n | \"module\"\n | \"script\"\n\n type ModeName = BuiltinMode | (string & {})\n\n type AxonMode = {\n /** Switch modes. Throws on an unknown mode rather than silently doing nothing. */\n set: (mode: ModeName) => Promise<void>\n /** The active mode. */\n get: () => ModeName\n /** The symbol currently shown in the input bar. */\n symbol: () => string\n }\n\n // ── Input ────────────────────────────────────────────────────────────────────\n\n /** The message box the user types into. */\n type InputApi = {\n get: () => string\n set: (text: string) => void\n /** Append to the current text without clearing it — the voice-transcript behaviour. */\n append: (text: string) => void\n clear: () => void\n /**\n * Send the current input as a message to the focused agent, exactly as\n * pressing Enter would, and clear the box. No-op when it is empty.\n */\n submit: () => Promise<void>\n }\n\n // ── Agents ───────────────────────────────────────────────────────────────────\n\n /** What a running instance looks like to an extension. */\n type AgentInstance = {\n /** Stable identity of this instance. Every instance verb addresses by this. */\n readonly id: string\n /** The agent project's name — several instances may share one. */\n readonly name: string\n /** True for the instance currently on screen. */\n readonly focused: boolean\n /**\n * Null when idle.\n *\n * The last two are ATTACHED instances only — an agent reached over a URL,\n * whose wire can drop without the agent itself stopping. A local instance\n * never reports them: its runtime lives in this process, so there is no\n * connection to lose.\n *\n * Kept in step with `AgentActivity` in the TUI and with the copy in\n * tui-contract.ts, which is what a user's own config typechecks against.\n */\n readonly activity: \"booting\" | \"rebooting\" | \"shutting-down\" | \"working\" | \"reconnecting\" | \"disconnected\" | null\n }\n\n /** An agent that can be started — a local project or a deployment. */\n type AgentTarget = {\n readonly name: string\n readonly kind: \"local\" | \"deployed\"\n /** Running instances of this agent, most recently focused first. */\n readonly instances: readonly AgentInstance[]\n }\n\n /**\n * Agents, addressed the way the TUI addresses them: you START by name and then\n * everything else is BY INSTANCE.\n *\n * That split is not incidental. One agent can have many live instances — that\n * is what `spawn` twice gives you — so a verb taking a name has no answer for\n * \"which one\", and collapsing the two would make siblings unreachable from\n * extensions.\n */\n type AgentsApi = {\n /** Every agent that can be started, with its live instances. */\n targets: () => Promise<readonly AgentTarget[]>\n\n /** Every running instance, in spawn order. */\n list: () => readonly AgentInstance[]\n\n /** One instance by id, or null if it is not running. */\n get: (id: string) => AgentInstance | null\n\n /** The instance currently on screen, or null when nothing is running. */\n focused: () => AgentInstance | null\n\n /**\n * Boot a new instance of an agent IN THE BACKGROUND, resolving once it is\n * live. The view does not change.\n *\n * Always a NEW instance — this is the sibling verb.\n *\n * Background is the whole point: a config that booted two agents would\n * otherwise have them race for the screen, and neither asked to be looked\n * at. Showing one is a separate, explicit act — `tui.nav(name)` goes to an\n * agent (booting one if none is live), and `agents.focus(id)` goes to a\n * specific instance.\n *\n * Returns the instance, which is what makes a workflow composable: the id\n * is how every other verb here addresses it, and one agent may have many\n * live instances, so \"the one I just started\" cannot be recovered from the\n * name afterwards.\n */\n spawn: (name: string) => Promise<AgentInstance>\n\n /** Put an instance on screen. Throws if it is not running. */\n focus: (id: string) => void\n\n /**\n * Shut an instance down. The only verb here that ends a conversation.\n *\n * Omit `id` for the focused instance.\n */\n stop: (id?: string) => Promise<void>\n\n /**\n * Reload an instance's blueprint in place. The conversation survives.\n *\n * Omit `id` for the focused instance.\n */\n reboot: (id?: string) => Promise<void>\n\n /**\n * Send a message to the FOCUSED instance, as though the user had typed it\n * and pressed Enter.\n *\n * Returns when the message is DELIVERED, not when the agent has answered,\n * and yields nothing: an extension drives the conversation and never\n * consumes it. Reading a model's output to decide what to do next is an\n * agent's job — build a cognet.\n *\n * Focused rather than addressable, deliberately. Delivery is not a simple\n * dispatch — a send during a switch is QUEUED for the agent arriving rather\n * than delivered to the one being left, which is the difference between a\n * message landing in the right conversation and the wrong one. That rule is\n * defined in terms of what the user is looking at, so a per-instance send\n * would need its own answer to a question the focused path already answers\n * correctly.\n *\n * Note that `spawn()` does NOT focus what it starts, so sending to a\n * freshly spawned agent means going to it first:\n *\n * const reviewer = await agents.spawn(\"@axon/reviewer\")\n * agents.focus(reviewer.id)\n * await agents.send(\"review main\")\n */\n send: (content: string) => Promise<void>\n\n /** Interrupt the focused instance's current wake, as Escape does. True if something was interrupted. */\n interrupt: () => boolean\n }\n\n // ── The TUI itself ───────────────────────────────────────────────────────────\n\n /** Terminal dimensions in cells. */\n type TuiSize = {\n readonly width: number\n readonly height: number\n }\n\n // ── Themes ───────────────────────────────────────────────────────────────────\n\n /**\n * Every colour name the terminal can render.\n *\n * ── Generated, not written ──────────────────────────────────────────────────\n *\n * The list between the markers is produced by `scripts/contract.ts` from\n * VTerm's own colour parser — its terminal basics (`brightcyan`) plus the full\n * CSS3 named set. Do not edit it by hand; a name here that the parser does not\n * know renders as nothing, which is the failure the union exists to prevent.\n */\n type ColorName =\n // <color-names>\n | \"aliceblue\"\n | \"antiquewhite\"\n | \"aqua\"\n | \"aquamarine\"\n | \"azure\"\n | \"beige\"\n | \"bisque\"\n | \"black\"\n | \"blanchedalmond\"\n | \"blue\"\n | \"blueviolet\"\n | \"brightblack\"\n | \"brightblue\"\n | \"brightcyan\"\n | \"brightgreen\"\n | \"brightmagenta\"\n | \"brightred\"\n | \"brightwhite\"\n | \"brightyellow\"\n | \"brown\"\n | \"burlywood\"\n | \"cadetblue\"\n | \"chartreuse\"\n | \"chocolate\"\n | \"coral\"\n | \"cornflowerblue\"\n | \"cornsilk\"\n | \"crimson\"\n | \"cyan\"\n | \"darkblue\"\n | \"darkcyan\"\n | \"darkgoldenrod\"\n | \"darkgray\"\n | \"darkgreen\"\n | \"darkgrey\"\n | \"darkkhaki\"\n | \"darkmagenta\"\n | \"darkolivegreen\"\n | \"darkorange\"\n | \"darkorchid\"\n | \"darkred\"\n | \"darksalmon\"\n | \"darkseagreen\"\n | \"darkslateblue\"\n | \"darkslategray\"\n | \"darkslategrey\"\n | \"darkturquoise\"\n | \"darkviolet\"\n | \"deeppink\"\n | \"deepskyblue\"\n | \"dimgray\"\n | \"dimgrey\"\n | \"dodgerblue\"\n | \"firebrick\"\n | \"floralwhite\"\n | \"forestgreen\"\n | \"fuchsia\"\n | \"gainsboro\"\n | \"ghostwhite\"\n | \"gold\"\n | \"goldenrod\"\n | \"gray\"\n | \"green\"\n | \"greenyellow\"\n | \"grey\"\n | \"honeydew\"\n | \"hotpink\"\n | \"indianred\"\n | \"indigo\"\n | \"ivory\"\n | \"khaki\"\n | \"lavender\"\n | \"lavenderblush\"\n | \"lawngreen\"\n | \"lemonchiffon\"\n | \"lightblue\"\n | \"lightcoral\"\n | \"lightcyan\"\n | \"lightgoldenrodyellow\"\n | \"lightgray\"\n | \"lightgreen\"\n | \"lightgrey\"\n | \"lightpink\"\n | \"lightsalmon\"\n | \"lightseagreen\"\n | \"lightskyblue\"\n | \"lightslategray\"\n | \"lightslategrey\"\n | \"lightsteelblue\"\n | \"lightyellow\"\n | \"lime\"\n | \"limegreen\"\n | \"linen\"\n | \"magenta\"\n | \"maroon\"\n | \"mediumaquamarine\"\n | \"mediumblue\"\n | \"mediumorchid\"\n | \"mediumpurple\"\n | \"mediumseagreen\"\n | \"mediumslateblue\"\n | \"mediumspringgreen\"\n | \"mediumturquoise\"\n | \"mediumvioletred\"\n | \"midnightblue\"\n | \"mintcream\"\n | \"mistyrose\"\n | \"moccasin\"\n | \"navajowhite\"\n | \"navy\"\n | \"oldlace\"\n | \"olive\"\n | \"olivedrab\"\n | \"orange\"\n | \"orangered\"\n | \"orchid\"\n | \"palegoldenrod\"\n | \"palegreen\"\n | \"paleturquoise\"\n | \"palevioletred\"\n | \"papayawhip\"\n | \"peachpuff\"\n | \"peru\"\n | \"pink\"\n | \"plum\"\n | \"powderblue\"\n | \"purple\"\n | \"rebeccapurple\"\n | \"red\"\n | \"rosybrown\"\n | \"royalblue\"\n | \"saddlebrown\"\n | \"salmon\"\n | \"sandybrown\"\n | \"seagreen\"\n | \"seashell\"\n | \"sienna\"\n | \"silver\"\n | \"skyblue\"\n | \"slateblue\"\n | \"slategray\"\n | \"slategrey\"\n | \"snow\"\n | \"springgreen\"\n | \"steelblue\"\n | \"tan\"\n | \"teal\"\n | \"thistle\"\n | \"tomato\"\n | \"turquoise\"\n | \"violet\"\n | \"wheat\"\n | \"white\"\n | \"whitesmoke\"\n | \"yellow\"\n | \"yellowgreen\"\n // </color-names>\n\n /**\n * Any colour a theme token can hold.\n *\n * A named colour autocompletes; so does `transparent`, which means \"paint\n * nothing and let the real terminal show through\" — the right answer for\n * `background` in almost every theme.\n *\n * `(string & {})` keeps that autocomplete while still accepting the forms a\n * union cannot enumerate: `#1a1b26`, `rgb(26, 27, 38)`, an rgba() with alpha.\n * Unlike `syntax`, an unrecognised value here is not automatically a typo —\n * hex is the common case — so this stays open where that one is closed.\n */\n type ThemeColor =\n | ColorName\n | \"transparent\"\n | (string & {})\n\n /**\n * The seven tokens every Axon surface draws from.\n *\n * Closed on purpose. The TUI reached ~30 hard-coded colours before this — four\n * greys nobody chose deliberately, five reds — and a theme API with a field per\n * call site would preserve that forever: a \"theme\" would mean thirty decisions,\n * and no two themes would agree what any of them were for.\n *\n * Seven decisions, and every surface derives from them. That is what makes a\n * theme portable: whatever an author writes lands on the same things.\n */\n type ThemeTokens = {\n /** Accent. Selection, the input rule, focused rows, links. */\n primary: ThemeColor\n /** The terminal's own ground. */\n background: ThemeColor\n /** Ordinary foreground — what most text is. */\n text: ThemeColor\n /** Secondary foreground: paths, descriptions, timestamps, anything subordinate. */\n dim: ThemeColor\n /** Something needs attention but nothing failed. */\n warn: ThemeColor\n /** Something failed. */\n error: ThemeColor\n /**\n * Syntax highlighting for code blocks and the editor.\n *\n * A bundled theme name autocompletes — see `BundledSyntax` for the full\n * set. An author who wants their own tokenisation passes a TextMate theme\n * object instead, which is the same shape Shiki takes.\n *\n * Deliberately NOT widened with `(string & {})` the way `ThemeColor` is.\n * A colour Axon does not recognise still renders — the terminal hands it\n * to the ANSI layer and something sensible happens. A syntax theme name\n * Shiki does not have loads nothing, so an unrecognised string is always a\n * typo, and the union is what turns it into a red squiggle in the user's\n * editor instead of unhighlighted code they have to diagnose.\n */\n syntax: BundledSyntax | Record<string, unknown>\n }\n\n /** A registered theme: its tokens plus the name it is addressed by. */\n type Theme = ThemeTokens & { name: string }\n\n /**\n * Every syntax theme that ships with Axon.\n *\n * ── Generated, not written ──────────────────────────────────────────────────\n *\n * The list between the markers below is produced by `scripts/contract.ts` from\n * Shiki's own `bundledThemes`, and rewritten in place whenever that script\n * runs. Do not edit it by hand — a name here that Shiki does not have is a\n * theme that typechecks and then fails to load at runtime, which is exactly the\n * failure a literal union is supposed to prevent.\n *\n * It is a literal union rather than an import because this file is copied\n * verbatim into a profile's type frame, where there is no node_modules to\n * import Shiki through. The generator is what keeps the copy honest.\n *\n * ── Bundling all of them is nearly free ─────────────────────────────────────\n *\n * Shiki's bundle is a map of dynamic-import thunks and the highlighter is\n * constructed with ONE theme, calling `loadTheme()` for each further one a user\n * actually selects. So the cost of offering every theme is a single import at\n * the moment someone picks it — not the whole set at boot.\n */\n type BundledSyntax =\n // <bundled-syntax>\n | \"andromeeda\"\n | \"aurora-x\"\n | \"ayu-dark\"\n | \"catppuccin-frappe\"\n | \"catppuccin-latte\"\n | \"catppuccin-macchiato\"\n | \"catppuccin-mocha\"\n | \"dark-plus\"\n | \"dracula\"\n | \"dracula-soft\"\n | \"everforest-dark\"\n | \"everforest-light\"\n | \"github-dark\"\n | \"github-dark-default\"\n | \"github-dark-dimmed\"\n | \"github-dark-high-contrast\"\n | \"github-light\"\n | \"github-light-default\"\n | \"github-light-high-contrast\"\n | \"houston\"\n | \"kanagawa-dragon\"\n | \"kanagawa-lotus\"\n | \"kanagawa-wave\"\n | \"laserwave\"\n | \"light-plus\"\n | \"material-theme\"\n | \"material-theme-darker\"\n | \"material-theme-lighter\"\n | \"material-theme-ocean\"\n | \"material-theme-palenight\"\n | \"min-dark\"\n | \"min-light\"\n | \"monokai\"\n | \"night-owl\"\n | \"nord\"\n | \"one-dark-pro\"\n | \"one-light\"\n | \"plastic\"\n | \"poimandres\"\n | \"red\"\n | \"rose-pine\"\n | \"rose-pine-dawn\"\n | \"rose-pine-moon\"\n | \"slack-dark\"\n | \"slack-ochin\"\n | \"snazzy-light\"\n | \"solarized-dark\"\n | \"solarized-light\"\n | \"synthwave-84\"\n | \"tokyo-night\"\n | \"vesper\"\n | \"vitesse-black\"\n | \"vitesse-dark\"\n | \"vitesse-light\"\n // </bundled-syntax>\n /** Axon's own, and the default. */\n | \"arcnight\"\n\n // ── lines ───────────────────────────────────────────────────────────────────\n\n /**\n * One live value on a line — a name, when it changes, and what it says.\n *\n * THE TRIGGER IS DECLARED, and that is the whole design. A bare `() => string`\n * would leave the terminal with no idea when to call it: re-running every\n * component on every frame makes one slow component stall the paint, and the\n * alternative — asking users to wire their own reactivity — is the thing this\n * API exists to avoid. So a component states what wakes it and the renderer\n * evaluates it then and never otherwise.\n *\n * `render` is SYNCHRONOUS by contract. A frame cannot await, and a component\n * that needs real work (a git branch, a network call) does that work in its\n * trigger and returns the cached value here — the same discipline lualine\n * settles on, arrived at from the render loop rather than from convention.\n *\n * A component with neither `on` nor `every` renders once and stays put, which\n * is the right shape for something static.\n */\n type LineComponent = {\n /**\n * A glyph shown before the value — a NAME from the catalogue, or a literal.\n *\n * A NAME resolves through the active icon set, so one setting swaps every\n * icon at once — which is what makes a shared component work on a machine\n * without a patched font. A literal glyph is the escape hatch for\n * something the catalogue does not name, and it does NOT respond to the\n * setting: an author writing a raw character has said they know what\n * appears.\n *\n * The author's, not the config's — an icon is part of what a component\n * MEANS (a git component without its branch glyph is a worse git\n * component), where colour is part of how a LINE looks and belongs to\n * whoever composes the row.\n *\n * Rendered only when the component has something to say: an icon beside an\n * empty value is a glyph floating on its own.\n */\n icon?: IconName | (string & {})\n /**\n * Hook events that change this value — the same names `tui.hook` takes.\n *\n * Reusing that vocabulary is deliberate: the terminal already emits a\n * precise event for everything it does, so a component author picks from a\n * list they have already learned rather than inventing a subscription.\n */\n on?: readonly TuiHookName[]\n /**\n * Re-render every N milliseconds — for values that change with time rather\n * than with anything the terminal does. A clock is the case; there is no\n * event for \"a second passed\".\n *\n * Taken as written, with no floor. Painting a string is cheap and the\n * renderer diffs frames for exactly this; a component doing heavy work on\n * a fast interval is the author's call, the same as a slow hook handler.\n */\n every?: number\n /**\n * Run when the user clicks this component.\n *\n * Named for what the AUTHOR does, not for the event vterm dispatches\n * (`@press`). A config says \"when this is clicked\"; the transport's name\n * for that is an implementation detail of the layer below.\n *\n * What turns a status line into a control surface: a row of agent names\n * becomes a nav bar, a branch indicator becomes a branch picker. Without\n * it a line can only report, and reporting is the smaller half of what a\n * bar sitting in front of you all day could do.\n *\n * Unawaited by the terminal — a handler that takes a second must not hold\n * the frame — and a failure is reported like any other config fault rather\n * than surfacing as a click that silently did nothing.\n */\n click?: () => void | Promise<void>\n /**\n * What to show, coerced to text.\n *\n * Primitives only, deliberately. `string` alone forced `String(count)` on\n * the most ordinary component there is; `unknown` would accept an object,\n * an array or a promise and render `[object Object]` silently — and an\n * author who slipped an `async` onto this would get `[object Promise]` on\n * their line with nothing to explain it. Widening removes ceremony, not\n * the errors the type was catching.\n *\n * `null`/`undefined` are the honest way to say \"nothing right now\", and\n * render as empty rather than as the text \"null\".\n */\n render: () => string | number | null | undefined\n }\n\n /**\n * A line's content — up to three slots, laid out by the terminal.\n *\n * Axon owns spacing, separators, truncation and colour; a config supplies text\n * and its order. That split is the product decision: every layout knob is a\n * way for two configs to disagree, and the failure mode it prevents is a\n * handful of beautiful setups surrounded by mediocre ones. Users theme,\n * Axon lays out.\n *\n * `left` and `right` push apart. `middle` centres on the LINE, not on the gap\n * between the sides, and truncates when there is no room — one rule, so a\n * three-slot line never needs a negotiation nobody can predict.\n */\n type LineContent = {\n left?: LineSlot\n middle?: LineSlot\n right?: LineSlot\n /**\n * The style this line was DESIGNED for — a default, not a decree.\n *\n * An author knows what their line is meant to look like, so declaring it\n * here means a shared line arrives looking right with no configuration.\n * But the placement wins: a user who wants it plain says so in\n * `lines.set()` and never has to fork the line to restyle it.\n *\n * Precedence, narrowest first: placement → this → `lines.style()`.\n */\n style?: AxonLineStyle\n }\n\n /**\n * One slot's contents: a flat list of components, or a list of SECTIONS.\n *\n * A section is the unit a separator divides and a background fills — which is\n * why the nesting exists at all. Inside one section every component shares a\n * ground, so the divider between them is a hairline; between sections the\n * ground changes, so the divider is a filled arrow. That is the whole\n * distinction lualine draws with `component_separators` and\n * `section_separators`, and it cannot be expressed on a flat list.\n *\n * A flat array is one section. Nothing already written changes meaning.\n */\n type LineSlot = readonly ComponentName[] | readonly (readonly ComponentName[])[]\n\n /**\n * A component's name — the catalogue Axon ships, or one you registered.\n *\n * The built-ins are enumerated so an editor completes them and a typo is a\n * compile error rather than a gap you find on screen. `(string & {})` keeps\n * that completion while still accepting names this union cannot know: a\n * component from an extension, or one the same config declared a few lines up.\n *\n * The same shape `ThemeColor` uses, for the same reason — a closed union would\n * make the escape hatch impossible, and an open `string` would make the\n * catalogue undiscoverable.\n */\n type ComponentName = RegistryName<AxonComponentRegistry>\n\n /**\n * A generated registry's names — CLOSED once the registry has entries.\n *\n * ── Why this is not simply `keyof R | (string & {})` ────────────────────────\n *\n * That shape gives completion but never rejects anything: the open arm accepts\n * every string, so a typo typechecks and only fails at runtime — which is the\n * bug the generator exists to remove.\n *\n * An empty registry still has to accept anything, though. A profile before its\n * first `axon prepare` has no generated file, and every name in it would be an\n * error against a `never` union — a config that was fine yesterday would light\n * up red because a build step had not run yet.\n *\n * So the union closes only when it has something to close AROUND: empty means\n * open, populated means exact. A name the generator genuinely cannot see (one\n * computed at runtime) is cast at the call site, which is the honest signal\n * that it is unverifiable rather than a hole left open for every name.\n */\n type RegistryName<R> = keyof R extends never ? string : keyof R & string\n\n /**\n * Every line name known at generation time.\n *\n * Same mechanism as AxonComponentRegistry — see that interface for why these\n * are generated rather than written by hand.\n */\n type LineName = RegistryName<AxonLineRegistry>\n\n /**\n * Every palette name known at generation time.\n */\n type PaletteName = RegistryName<AxonPaletteRegistry>\n\n /**\n * Every command path known at generation time, space-joined.\n */\n type CommandName = RegistryName<AxonCommandRegistry>\n\n /**\n * The registries `axon prepare` fills in.\n *\n * ── Generated, not hand-written ─────────────────────────────────────────────\n *\n * These were a hand-maintained union of the built-in names, which drifted the\n * first time someone added a component and forgot to update it. The generator\n * reads the actual catalogue AND every config's own `create` calls, so what an\n * editor completes is what is really registered — including the component you\n * declared four lines above the line using it.\n *\n * ── Why an interface rather than a type alias ───────────────────────────────\n *\n * Declaration merging. A generated `.d.ts` reopens the interface and adds its\n * keys, which means built-ins, extension contributions and a user's own\n * registrations all land in one union with no privileged tier. An alias could\n * only be replaced, not extended, so every source would need its own name and\n * the consumer would have to union them by hand.\n *\n * Empty here by design: a profile with no generated types still typechecks,\n * because every consuming alias keeps a `(string & {})` arm.\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonComponentRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonLineRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonPaletteRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonCommandRegistry {}\n\n /**\n * How a line draws its separators and shades its sections.\n *\n * A preset, never individual glyphs. Axon owning the glyph set is the line\n * between \"every config looks like Axon\" and \"everyone invents their own bar\"\n * — and a config that picked its own would be choosing a look that has to hold\n * against every theme, which is not a decision anyone should have to make\n * per row.\n *\n * Backgrounds step from the EDGE INWARD: the outermost section takes the\n * accent, each step inward is softer, and the innermost sits on the terminal's\n * own ground. Position in the array is the section, so there is no background\n * to configure — which is what stops two configs disagreeing about what a\n * status bar looks like.\n */\n type AxonLineStyle =\n /** No glyphs. Components separated by spacing alone. */\n | \"plain\"\n /**\n * Filled arrows between sections, hairlines within — the default.\n *\n * The separator block (`U+E0B0`–`U+E0B7`) predates Nerd Fonts and ships far\n * more widely than the icon range, so a terminal that draws a git icon as a\n * box still renders these. One without even that sets `\"plain\"`.\n */\n | \"powerline\"\n /** The same, with round caps. Needs a Nerd Font. */\n | \"rounded\"\n /**\n * Square edges: a flat boundary between fills and a vertical bar within.\n *\n * The same section model as `powerline`, without the arrow's implied\n * direction — which reads as calmer beside a busy conversation, and is\n * what you want when the bar should sit still rather than point at\n * something. Needs a Nerd Font.\n */\n | \"block\"\n /** A thin middle dot between components, no section fills. */\n | \"minimal\"\n\n /**\n * A line's definition: the full three-slot form, or a bare array.\n *\n * The array means LEFT, always — never auto-distributed. Both built-in lines\n * are left-aligned, so it is the common case worth a shorthand, and a rule\n * that reads the same every time beats one that guesses.\n */\n type LineDefinition = LineContent | readonly string[]\n\n /**\n * One entry in the stack: a name, or a name with placement overrides.\n *\n * The bare string is the common case and stays the common case — an object is\n * only needed when this particular placement differs from what the line\n * declared.\n */\n type AxonLineEntry = LineName | AxonLinePlacement\n\n /**\n * How ONE line is placed in ONE stack.\n *\n * ── Why placement owns style ────────────────────────────────────────────────\n *\n * Three layers, three owners: a COMPONENT is what the data is (an extension\n * author's), a LINE is what sits where (shared or personal), and a PLACEMENT\n * is how it looks in this stack (always the user's).\n *\n * Style began on the line and that was the wrong layer. A shared line would\n * ship with its look baked in, so anyone installing `@cody/git-line` had to\n * fork it to restyle — which is the coupling that stops a registry being\n * worth having. A line may still declare a default, because an author knows\n * what their line was designed to look like; the placement wins when it says\n * otherwise.\n *\n * Precedence, narrowest first: this placement → the line's own default →\n * `lines.style()`.\n */\n type AxonLinePlacement = {\n /** The registered line this entry places. */\n line: LineName\n /** How it draws here, overriding the line's default and the stack's. */\n style?: AxonLineStyle\n /**\n * Start hidden, keeping its place in the stack.\n *\n * Declared here rather than left to a `hide()` call afterwards, so the\n * stack is one description instead of a description plus a sequence of\n * mutations. `toggle()` still flips it at runtime.\n */\n hidden?: boolean\n }\n\n /**\n * Where a line moves to. `\"up\"`/`\"down\"` are relative; a number is an absolute\n * index in the stack, clamped rather than throwing — a keybind that walks a\n * line to the top should stop there, not fail on the last press.\n */\n type LinePosition = \"up\" | \"down\" | number\n\n /** A registered line, as `lines.list()` reports it. */\n type Line = {\n /**\n * Unique within the stack — the name is NOT an identity, since a line may\n * be placed more than once (comparing two styles side by side is a real\n * thing to want).\n */\n id: string\n name: string\n content: LineContent\n /** How it draws. Falls back to the stack default when the line declared none. */\n style: AxonLineStyle\n /** False when hidden. A hidden line keeps its place in the stack. */\n visible: boolean\n }\n\n /**\n * Components — the live values a line can show.\n *\n * Axon ships a catalogue under the `axon:` prefix (`axon:token/counter` and\n * friends), and anything else registers here. The two are the same kind of\n * thing: a built-in is a component the terminal registered against its own\n * hooks, with no privilege a user's cannot have.\n *\n * Names are `provider:name` rather than a package specifier. A package ships\n * many things; a component comes from one provider — conflating the two would\n * make every component name read like an import path.\n */\n type AxonComponents = {\n /**\n * Register a component. Throws if the name is taken. Returns a disposer.\n *\n * A `render` that throws costs that component and nothing else: it renders\n * empty and the fault is reported, the same containment the config loader\n * applies per file. One bad value must not take down the line around it.\n */\n create: (name: string, component: LineComponent) => Disposer\n\n /** Every registered component name, built-ins included. */\n list: () => readonly string[]\n }\n\n /**\n * Lines — the configurable rows above the input bar.\n *\n * The terminal ships two of its own and they stay its: the cwd/token row and\n * the voice row. A user's lines sit between them, which is the one layout\n * decision Axon does not delegate — the rows that must always be readable are\n * not ones a config can push off screen.\n *\n * Registration and placement are SEPARATE VERBS, and that is what makes the\n * surface extensible: an extension `create`s lines without deciding where they\n * go, and the user `set`s the stack without knowing who authored what.\n */\n type AxonLines = {\n /**\n * Register a line. Throws if the name is taken, or if it names a component\n * that does not exist — a config error the loader can contain, reported\n * where it can be fixed rather than rendered as a blank row.\n */\n create: (name: string, definition: LineDefinition) => Disposer\n\n /**\n * The default style for every line that does not declare one.\n *\n * A stack-wide setting because a bar with one powerline row among plain\n * ones reads as a mistake, not a choice — and because the common case is\n * wanting ALL of them to match. A line that genuinely differs still says so\n * itself, which is the rarer thing and reads as deliberate at the call site.\n *\n * Called with no argument, returns the current default.\n */\n style: {\n (style: AxonLineStyle): void\n (): AxonLineStyle\n }\n\n /**\n * The single line ABOVE the conversation, or null to clear it.\n *\n * One line, not a stack. The room above the conversation is scarce in a\n * way the room below it is not — the bottom already holds the input bar\n * and its own rows, so a stack there is bounded by something. A second\n * unbounded stack at the top could push the conversation off screen, and\n * the constraint costs nothing: nobody has wanted two.\n *\n * Takes the same placement object as `set`, so a top line styles itself\n * the same way any other does.\n */\n top: {\n /** Set it by name, with placement options. */\n (name: LineName, options?: Omit<AxonLinePlacement, \"line\">): void\n /** Set it from a placement object, or clear it with null. */\n (entry: AxonLineEntry | null): void\n /** Read what is currently set. */\n (): Line | null\n }\n\n /**\n * Set the whole stack, top to bottom. Declarative and idempotent: this is\n * the one place order lives, so reordering is calling it again.\n *\n * An entry is a bare name, or an object when this placement differs from\n * the line's own defaults — see LinePlacement. Registered lines left out\n * of the array are not shown; an unknown name is reported.\n */\n set: (entries: readonly AxonLineEntry[]) => void\n\n /**\n * Move one line within the stack. Addressed by NAME, never by index —\n * an index shifts when anything above it moves, so a keybind written today\n * would quietly mean something else tomorrow.\n */\n move: (name: string, position: LinePosition) => void\n\n /** Hide a line. It keeps its place, so showing it again returns it there. */\n hide: (name: string) => void\n /** Show a hidden line, back where it was. */\n show: (name: string) => void\n /** Flip visibility — the verb a keybind wants. */\n toggle: (name: string) => void\n\n /** Every registered line, in stack order. What a picker palette reads. */\n list: () => readonly Line[]\n }\n\n /**\n * Themes — the terminal's colours, and switching between them.\n *\n * A theme is registered like a palette and applied like a mode. `\"` opens the\n * built-in picker, which previews as the cursor moves: hovering a row paints it\n * for real, because a preview that rendered differently from the result would\n * be worth nothing.\n */\n type AxonTheme = {\n /**\n * Register a theme. Throws if the name is taken. Returns a disposer.\n *\n * Name first, tokens second — the same shape as `palette.create`, so the\n * two read alike rather than one carrying its identity inside the object\n * and the other beside it.\n */\n create: (name: string, tokens: ThemeTokens) => Disposer\n\n /** Paint a theme and keep it. Throws on an unknown name. */\n set: (name: string) => void\n\n /** Every registered theme, built-ins first. */\n list: () => readonly Theme[]\n\n /** The theme currently painted. */\n readonly active: Theme\n }\n\n /**\n * Everything that belongs to the terminal rather than to one of the domains\n * above. Kept deliberately thin — a verb with a natural home in `palette`,\n * `commands`, `keys`, `mode`, `input` or `agents` belongs there.\n */\n /** Trailing options for `tui.info` / `warn` / `error`. */\n type NoticeOptions = {\n /** How long the notice holds the row, in milliseconds. Clamped to a few seconds. */\n ms: number\n }\n\n type AxonTui = {\n /**\n * Go to an agent: focus the instance the user was last on, booting one if\n * none is live. The `~` key's behaviour.\n *\n * Name-addressed on purpose — \"take me to this agent\" is a different verb\n * from \"focus this exact instance\" (`agents.focus`), and both are real.\n */\n nav: (name: string) => Promise<void>\n\n /**\n * Register a lifecycle handler. See TuiHooks.\n *\n * Available everywhere — `main.ts`, a `plugins/` file, an extension's\n * `setup()` — because there is no capability difference between them, only\n * a timing one. `plugins/` is where hooks live by convention, not by rule.\n */\n hook: <N extends TuiHookName>(name: N, handler: TuiHooks[N]) => Disposer\n\n /**\n * A brief label on the cwd row — the same line the ctrl+c and double-esc\n * hints borrow. Flashes for 300ms by default, then the row returns to the\n * path.\n *\n * tui.info(\"deployed\")\n * tui.warn(\"nothing to do\", { ms: 600 })\n * tui.error(\"command failed\")\n *\n * ── A reaction, not a message ───────────────────────────────────────────\n *\n * This row's existing tenants are both feedback about the key just pressed,\n * and these are the same thing: something to catch the eye, not something\n * to read. Longer than ~50 characters is trailed with an ellipsis, which is\n * the honest consequence of a one-line surface rather than a limit to work\n * around.\n *\n * So anything with CONTENT — a reason, a path, a stack — does not belong\n * here. Throw instead: it lands in the config error list on the chat page,\n * which is scrollable and stays put.\n *\n * Takes any number of values and joins them with a space, the way\n * `console.log` does — so a config building a label from several pieces\n * does not have to concatenate first. Non-strings are stringified;\n * objects and arrays go through JSON so a stray value reads as data\n * rather than as `[object Object]`.\n *\n * The terminal's own hints outrank all three verbs — one fired during the\n * ctrl+c window waits rather than displacing the exit ladder.\n *\n * Duration is a trailing `{ ms }` rather than a bare number, because\n * under variadic args a trailing number is DATA: `tui.info(\"saved\", 500)`\n * has to mean \"saved 500\", not \"show this for half a second\".\n *\n * tui.info(\"[\", keys.join(\" \"), \"]\")\n * tui.warn(\"nothing to do\", { ms: 600 })\n */\n info: (...args: unknown[]) => void\n\n /** As `info`, in the warning colour. */\n warn: (...args: unknown[]) => void\n\n /** As `info`, in the error colour. For \"that failed\" — never for why. */\n error: (...args: unknown[]) => void\n\n readonly size: TuiSize\n\n /** The directory the TUI was launched from. */\n readonly cwd: string\n\n /** Version of the running Axon CLI. */\n readonly version: string\n\n /**\n * Quit, running the same exit guards a Ctrl+C does.\n *\n * There is deliberately no `update()`: a self-update hands off to a helper\n * that runs after the process exits, and an extension triggering that is a\n * way for a config to brick an install mid-session.\n */\n exit: () => Promise<void>\n }\n\n // ── Hooks ────────────────────────────────────────────────────────────────────\n //\n // ONE verb: `tui.hook(name, handler)`. There is deliberately no `.on()`\n // alongside it.\n //\n // A blocking `hook()` and a fire-and-forget `on()` are indistinguishable at the\n // call site — one letter apart, differing only in a consequence you cannot see\n // — and picking the wrong one buys either a race or a hang. Whether the TUI\n // waits is a property of the EVENT, not of how a handler was registered: `boot`\n // has a meaningful \"before\" to run in, `mode:changed` announces something that\n // already happened and waiting on it only delays the UI.\n //\n // So the event decides, the types say which is which, and a user who wants\n // fire-and-forget writes it where it is visible:\n //\n // tui.hook(\"tui:boot\", () => { void backgroundSync() })\n\n /**\n * Gating hooks — the TUI WAITS for these, and they can fail the operation.\n *\n * Only lifecycle transitions with a real \"before\" qualify. A slow handler here\n * delays the terminal, so the runtime bounds it: exceeding the budget reports\n * `extension X is blocking <hook>` and continues. It never hangs silently, and\n * a config that stalls boot must always say so — an unexplained frozen terminal\n * is the worst failure this feature can produce.\n */\n type TuiGateHooks = {\n /** Before the TUI becomes interactive. Registration is done; the screen is not up. */\n \"tui:boot\": (payload: TuiBootPayload) => void | Promise<void>\n /** Before shutdown proceeds. The last point at which anything can be flushed to disk. */\n \"tui:shutdown\": (payload: TuiShutdownPayload) => void | Promise<void>\n }\n\n // ── Hook payloads ────────────────────────────────────────────────────────────\n //\n // EVERY hook takes exactly one object, always — including the ones that have\n // nothing to say. `tui.hook(name, ({ x }) => ...)` is the shape throughout, so\n // a handler is written the same way whichever event it listens to, and reading\n // one tells you nothing about which.\n //\n // Positional arguments were the alternative and they lose on every axis that\n // matters here. They fix an order, so adding a field is a choice between a\n // trailing bag nobody discovers and a breaking change; they cannot be\n // destructured by name, so `(a, b)` at a call site says nothing about what a\n // and b are; and they make the empty case a THIRD spelling (`() => {}` beside\n // `(x) => {}` beside `(x, y) => {}`) for no gain. An empty object costs a\n // handler nothing — `() => {}` still type-checks, because a function may always\n // ignore parameters it was handed.\n //\n // So the rule is mechanical and has no exceptions: one payload object per hook,\n // named fields, and a payload type declared here even when it is empty. An\n // empty payload is where a field will go, and having the type already named is\n // what makes adding one a non-event.\n\n /**\n * `tui:boot` — nothing yet.\n *\n * Empty rather than absent: the parameter exists so a later field arrives\n * without changing any handler's shape, and so boot is written exactly like\n * every other hook.\n */\n type TuiBootPayload = {}\n\n /** `tui:shutdown` — nothing yet. Empty for the same reason as boot. */\n type TuiShutdownPayload = {}\n\n /** `tui:reloaded` — nothing yet. Empty for the same reason as boot. */\n type TuiReloadedPayload = {}\n\n /** `tui:resize` — the terminal's new dimensions, in cells. */\n type TuiResizePayload = {\n /** Columns. */\n width: number\n /** Rows. */\n height: number\n }\n\n /**\n * `tui:copy` — the text that was copied.\n *\n * The text is CARRIED rather than left for the handler to read back off the\n * selection: copying does not clear the selection, but nothing stops the user\n * (or another handler) from clearing it before this one runs, and a handler\n * that re-read it would then see an empty string for a copy that plainly\n * happened. What is passed is exactly what reached the clipboard.\n *\n * Never empty — an empty selection copies nothing and fires nothing.\n */\n type TuiCopyPayload = {\n /** The copied text, verbatim: original line breaks, no trimming. */\n text: string\n }\n\n /**\n * `key:pressed` — one keystroke the TUI did not act on.\n *\n * `mode` rides along because \"was a palette open when this fired\" is the first\n * question a handler asks, and reading it back through `mode.get()` would race\n * the very transition that may have been caused by this key.\n */\n type KeyPressedPayload = {\n /**\n * The chord, in the spelling `keys.register()` accepts — `\"a\"`, `\"ctrl+o\"`,\n * `\"shift+tab\"`. Round-trips deliberately: a handler that decides to claim\n * a key can pass this string straight to `keys.register`.\n */\n key: string\n /** The mode that was active when the key arrived. */\n mode: ModeName\n }\n\n /** `palette:opened` / `palette:closed` — which palette. */\n type PalettePayload = {\n /** The palette's mode name — `\"command\"`, `\"agent\"`, or a user palette's. */\n name: ModeName\n }\n\n /** What one instance hook reports. */\n type AgentPayload = {\n instance: AgentInstance\n }\n\n /** `message:sent` — the text, and where it went. */\n type MessageSentPayload = {\n content: string\n instance: AgentInstance\n }\n\n /** `message:received` — see the hook for why there is no content. */\n type MessageReceivedPayload = {\n instance: AgentInstance\n }\n\n /** `mode:changed` — the transition, both ends. */\n type ModeChangedPayload = {\n from: ModeName\n to: ModeName\n }\n\n /** `command:ran` / `command:failed` — which command, and how it was reached. */\n type CommandPayload = {\n /**\n * Where the command sits in the command TREE, one segment per level —\n * `[\"ext\", \"update\"]`, `[\"theme\", \"set\", \"gruvbox\"]`.\n *\n * An array rather than a space-joined string because the segments are what\n * both call sites already hold (`[...breadcrumb, node.label]` in the\n * palette, `toPath(path)` in `commands.run()`) and what registration,\n * lookup and COMMAND_NOT_FOUND all use. The string was a lossy projection\n * at one boundary: `split(\" \")` is not its inverse once an argument\n * contains a space, so the commands most worth reacting to — a pasted key,\n * a path with spaces — were exactly the ones a handler mis-parsed.\n *\n * A list-backed group puts its chosen row here, not in `arg`: a theme name\n * is a NODE the palette listed, from a closed set, so `:theme set gruvbox`\n * is three segments. That makes every pick a distinct path, which is how a\n * handler knows WHICH theme — so match a namespace with `path[0]`, not a\n * whole-array compare.\n */\n path: string[]\n\n /**\n * The raw text typed after an input command, or undefined when the command\n * takes none — `\"/some/dir\"` for `:watch /some/dir`.\n *\n * Separate from `path` because it is a different KIND of thing: a segment\n * comes from a closed set and is matchable, an argument is arbitrary user\n * text. Folding it in would turn \"did watch run\" from an equality check\n * into a prefix test, and make every invocation its own path.\n *\n * ── The invariant this field rests on ───────────────────────────────────\n *\n * An input node TERMINATES traversal — `CommandInput` has no children, and\n * everything after it is taken as the argument verbatim, spaces included\n * (traverse.ts: `rawSegments.slice(i + 1).join(\" \")`). So there is at most\n * one per path and it is always the tail, at whatever depth the input node\n * sits: `:watch <dir>` is depth 1, `:provider openrouter connect <key>` is\n * depth 3, and both put the whole remainder here.\n *\n * If the grammar ever admits MID-PATH arguments (`:agent <name> rename\n * <new>`), this field must change shape — one string cannot represent two.\n * That is a parser change, so it will be caught here rather than silently\n * producing a wrong `arg`.\n */\n arg?: string\n /**\n * How it was invoked: chosen in the command palette, or run by\n * `commands.run()`.\n *\n * Present so a handler can tell the user's action from its own — an\n * extension that reacts to every command by running another would otherwise\n * have no way to avoid recursing into itself.\n *\n * There is deliberately no `\"key\"`. A key bound to a command calls\n * `commands.run()` from its handler, so it IS an api call and reporting it\n * as its own source would be inventing a distinction the runtime cannot\n * actually make — a handler that checked for it would never match.\n */\n source: \"palette\" | \"api\"\n }\n\n /** `command:failed` — the above, plus what went wrong. */\n type CommandFailedPayload = CommandPayload & {\n /** The thrown value, exactly as it was thrown. */\n error: unknown\n }\n\n /**\n * Notification hooks — announcements of something that ALREADY happened.\n *\n * Handlers return void: nothing waits, and nothing they do can alter the event.\n * That is enforced by the signature rather than documented, so the question\n * \"does the TUI block on this?\" is answered by the type instead of by reading\n * the runtime. A handler needing async work owns it (`void doThing()`), which\n * keeps the fire-and-forget visible at the call site.\n *\n * There is deliberately no `tui:ready`. It existed, was typed, was documented,\n * and never fired — and the moment it is wired it is indistinguishable from\n * `tui:boot`, which already runs once registration is complete and gates the\n * terminal becoming interactive. Two hooks separated only by whether the screen\n * has painted is a distinction nothing in this API can act on.\n */\n type TuiNotifyHooks = {\n /**\n * The config was reloaded — `:reload`, or a file change.\n *\n * Fires on the NEW generation, after every registration is in place. The\n * old generation is already disposed and never sees it: its handlers went\n * with everything else it registered.\n *\n * Distinct from `tui:boot`, which also runs on a reload but gates it. Use\n * boot for setup that must finish first; use this to react to having been\n * reloaded — refreshing a cached palette, re-reading a file on disk.\n */\n \"tui:reloaded\": (payload: TuiReloadedPayload) => void\n\n /**\n * The terminal was resized.\n *\n * Fires after the new size is in effect, so `tui.size` and this payload\n * always agree. Coalesced by the underlying watcher: a drag produces the\n * sizes the terminal actually reported, not one event per column.\n */\n \"tui:resize\": (payload: TuiResizePayload) => void\n\n /**\n * Text was copied to the system clipboard.\n *\n * Fires after the copy is dispatched (OSC 52 plus the native fallback), for\n * a selection copy the user made in the terminal. Observational, like every\n * notify hook: a handler cannot alter or veto what was copied, and the\n * clipboard has already been written by the time it runs.\n *\n * It does NOT fire for an empty selection — copying nothing is not an\n * event — nor for text the user pastes, which is the opposite direction and\n * would need its own hook.\n */\n \"tui:copy\": (payload: TuiCopyPayload) => void\n\n /**\n * A key the TUI did not handle.\n *\n * ── Unhandled only, and never consumable ────────────────────────────────\n *\n * This fires at the END of dispatch — after reserved chords, after\n * `keys.register()` bindings, after mode keys. A key that did something\n * does not arrive here.\n *\n * That is not a limitation to route around; it is the only shape that can\n * be safe. User key handling is mounted as a WILDCARD, and wildcards fire\n * before exact-key handlers — so a hook able to consume a press would beat\n * every built-in binding, including the ctrl+c exit ladder. The reserved\n * list refuses those chords at registration precisely because a check at\n * press time is already too late.\n *\n * So there is no return value and no consumption: this observes, exactly\n * like every other notify hook. To OWN a key, register it —\n * `keys.register(\"ctrl+o\", ...)` — which is checked against the reserved\n * set and cannot break the terminal.\n */\n \"key:pressed\": (payload: KeyPressedPayload) => void\n\n /**\n * A palette opened.\n *\n * Narrower than `mode:changed`, and deliberately its own event: not every\n * mode is a palette. `loading` is a spinner and `voice` is a capture state,\n * and an extension gating on \"is the user picking something\" has to exclude\n * them — a derivation every consumer would otherwise write, and get wrong\n * the same way.\n */\n \"palette:opened\": (payload: PalettePayload) => void\n\n /** A palette closed. Fires for whichever palette was open. */\n \"palette:closed\": (payload: PalettePayload) => void\n\n /**\n * A command finished successfully.\n *\n * Covers built-ins and user commands alike, however they were reached —\n * `source` says which. Fires AFTER the action resolves, so an async command\n * reports when it is genuinely done rather than when it started.\n */\n \"command:ran\": (payload: CommandPayload) => void\n\n /**\n * A command threw.\n *\n * Its own event rather than a field on `command:ran`, so a handler that\n * only cares about failures does not have to filter — and so the success\n * payload never carries an error slot that is null almost always.\n */\n \"command:failed\": (payload: CommandFailedPayload) => void\n\n /** An instance finished booting. */\n \"agent:ready\": (payload: AgentPayload) => void\n /** An instance shut down. */\n \"agent:stopped\": (payload: AgentPayload) => void\n /** A different instance came on screen. */\n \"agent:focused\": (payload: AgentPayload) => void\n\n /** The user sent a message. Fires once it is delivered. */\n \"message:sent\": (payload: MessageSentPayload) => void\n /**\n * The agent finished a wake.\n *\n * Carries no content on purpose. A payload with the model's reply would\n * reopen the consumption boundary through the back door — an extension\n * reacting to WHAT was said is writing an agent, which is a cognet's job.\n * This says only THAT a wake completed.\n */\n \"message:received\": (payload: MessageReceivedPayload) => void\n\n /**\n * The active mode changed.\n *\n * The general event; `palette:opened`/`closed` are the specific ones. Use\n * this to observe every transition (including `loading` and `voice`), those\n * to react to the user opening something to pick from.\n */\n \"mode:changed\": (payload: ModeChangedPayload) => void\n }\n\n /** Every lifecycle hook, gating and notifying. */\n type TuiHooks = TuiGateHooks & TuiNotifyHooks\n\n type TuiHookName = keyof TuiHooks\n\n /**\n * A plugin file under `plugins/`.\n *\n * Plugins need no wrapper and no default export — `tui.hook(...)` at module\n * scope is the whole API, exactly as `main.ts` registers commands at module\n * scope. The file is hooks by convention rather than by ceremony, and there is\n * one way to reach every verb from every file in a profile.\n *\n * What separates a plugin from `setup()` is TIME, not capability: setup runs at\n * load, before anything is on screen, and is where registration belongs —\n * registering a command from a live hook would flicker it into a palette the\n * user is already looking at.\n *\n * A throwing handler disables its extension with a visible error. It never\n * takes the TUI down, and it is never silently swallowed.\n */\n type PluginModule = void\n\n // ── Extensions ───────────────────────────────────────────────────────────────\n\n /**\n * An extension's `extension.config.ts`.\n *\n * ── An extension is a profile, packaged ──────────────────────────────────────\n *\n * There is no `setup()`. An extension's behaviour lives in its `main.ts` and\n * its `plugins/`, registered at module scope, exactly as a user's own profile\n * does — same files, same globals, same moment. That symmetry is the point: a\n * user who has written a `main.ts` can publish it, and a reader who knows one\n * layout knows both.\n *\n * A `setup()` wrapper would have made the two differ for no gain. It exists on\n * `defineModule` because a module has data the loader must read WITHOUT\n * executing it — an options schema to validate, `emits` for typegen to merge,\n * env and policy requirements, sub-modules to flatten at manifest time. An\n * extension has none of that: its identity is package.json, and its behaviour\n * is registration.\n *\n * ── Then why does this file exist? ───────────────────────────────────────────\n *\n * It marks the directory as an extension. A kind is identified by its config\n * file (see detectKind), and `main.ts` cannot be that marker — a profile has\n * one, and so does half of npm.\n *\n * It is deliberately empty today. Keeping it means declarative, inspectable\n * per-extension data has somewhere to land later without a breaking change —\n * options schemas being the obvious candidate, if third-party configuration\n * ever needs a validated boundary rather than a user editing TypeScript.\n */\n type ExtensionConfig = {\n /**\n * Reserved. An extension declares nothing here yet — identity lives in\n * package.json and behaviour lives in main.ts.\n */\n readonly _reserved?: never\n }\n\n /** What `defineExtension()` returns. */\n type ExtensionDefinition = {\n _kind: \"extension\"\n config: ExtensionConfig\n }\n\n // ── Profile ──────────────────────────────────────────────────────────────────\n\n /**\n * One entry in `profile.config.ts`'s `extensions`.\n *\n * `\"@axon/vim\"` resolves from the registry and installs into the profile\n * frame; `\"./extensions/sketch\"` is a local directory. The object form lets an\n * extension be disabled without deleting its line — which is what makes this\n * editable by machine, the reason the enabled set is declared here rather than\n * being the side-effect of running code.\n */\n type ExtensionEntry =\n | string\n | {\n /** Registry specifier or local path. */\n source: string\n /** Default true. False keeps the entry but does not load it. */\n enabled?: boolean\n }\n\n /**\n * A user's `profile.config.ts` — what is ENABLED, declaratively.\n *\n * Declarative rather than imperative registration calls specifically so it can\n * be edited by machine: installing an extension from Fleet or the CLI is a data\n * edit to this array, which is not possible when the enabled set is the\n * side-effect of running arbitrary code.\n *\n * Behaviour lives in `main.ts`; this file only says what loads.\n */\n /** What the timeline shows. Every field optional; defaults applied at read. */\n type VerbosityProfile = {\n /** Session lifecycle events — quiet: errors only; normal (default): + info (reloads); verbose: + plumbing. */\n session?: \"quiet\" | \"normal\" | \"verbose\"\n /** Interleave kernel:* telemetry (runs, engine calls) into the timeline. Default false. */\n kernel?: boolean\n /** Interleave cognet:* telemetry (ticks, phases, systems). Default false. */\n cognet?: boolean\n }\n\n /**\n * The platform's own settings — a CLOSED, typed set.\n *\n * Closed on purpose. These are the keys the terminal itself acts on, so each\n * one has a meaning the platform enforces: `theme` names a registered theme,\n * `paths` are scanned for agents. An open bag would make \"is this setting\n * doing anything?\" unanswerable, which is the question a settings file exists\n * to answer.\n *\n * Extension settings live OUTSIDE this, as their own top-level key on the\n * profile config (`\"@cody/vim\": { leader: \",\" }`). Two reasons: an extension's\n * settings are its own contract rather than the platform's, and keeping them\n * out means adding a platform key can never collide with one an extension\n * already chose.\n */\n type ProfileSettings = {\n /** The active theme, by the name it was registered under. */\n theme?: string\n /**\n * Which glyph set line components draw their icons from.\n *\n * ── Why this is a SETTING and not code ──────────────────────────────────\n *\n * It answers \"what does this machine's font support\", which is a property\n * of the terminal rather than of the config. A shared line should look\n * right on a laptop with a patched font and on a server without one, and\n * that cannot be true if the answer is compiled into the line.\n *\n * ── Why the default is \"auto\" ───────────────────────────────────────────\n *\n * Nerd Fonts are the de facto standard — lualine, starship, powerlevel10k\n * and oh-my-posh all assume one — so defaulting them OFF would give the\n * majority a plainer bar than they installed a patched font for.\n *\n * But a font cannot be detected from inside a terminal, so \"auto\" is a\n * heuristic, not a fact: it reads the same environment the ecosystem uses\n * (TERM_PROGRAM, and whether a font name mentions \"Nerd\"), and falls back\n * to unicode when nothing says yes. Someone seeing boxes sets \"unicode\" and\n * is done; someone seeing plain text sets \"nerd\".\n */\n icons?: IconSet\n /**\n * Extra directories scanned for agent projects, beyond\n * `profiles/<email>/agents/`. `~` expands to the home directory.\n */\n paths?: string[]\n /** What the timeline shows. */\n verbosity?: VerbosityProfile\n /**\n * Blank space around the whole terminal UI, in cells.\n *\n * Shorthand for both axes: `padding-inline`/`padding-block` override it per\n * axis when present, so `{ padding: 1, \"padding-inline\": 4 }` reads as \"one\n * row top and bottom, four columns each side\".\n *\n * ── CSS names, spelled exactly ──────────────────────────────────────────\n *\n * This config layer speaks CSS — VTerm mimics browser CSS, and users write\n * scoped CSS in their own extensions. Where CSS already has a name for a\n * thing, these settings use it verbatim rather than a near-synonym, so\n * there is nothing to translate between what you write here and what you\n * write in a stylesheet. (VTerm implements only the physical longhands\n * internally, so these are expanded to `padding-top`/`-left`/... at the\n * layout that consumes them — an implementation detail of the renderer,\n * not a reason to rename the setting.)\n */\n padding?: number\n /** Columns of blank space at the left and right edges. Overrides `padding` horizontally. */\n \"padding-inline\"?: number\n /**\n * Rows of blank space added at the top and bottom edges. Overrides\n * `padding` vertically.\n *\n * ADDED to the layout's own one-row top offset rather than replacing it, so\n * 0 (the default) is the shipped look. The status line is the bottom edge\n * and sits flush by design; this is what lifts it off.\n */\n \"padding-block\"?: number\n /** Not wired to anything yet — kept for when it is. */\n telemetry?: boolean\n }\n\n /**\n * `profile.config.ts` — the one declarative source of truth for a terminal.\n *\n * Which extensions load, how the platform is configured, and whatever those\n * extensions were configured with. Written by hand AND edited surgically by\n * the terminal (`:theme set`, `axon ext install`) — so what you see in this\n * file is always what is in effect, with no second store that can disagree.\n *\n * Extension settings are top-level keys named after the extension, siblings of\n * `settings` rather than nested inside it:\n *\n * export default defineProfile({\n * extensions: [\"@cody/vim\"],\n * settings: { theme: \"ember\" },\n * \"@cody/vim\": { leader: \",\" },\n * })\n */\n type ProfileConfig = {\n extensions?: ExtensionEntry[]\n /** Platform settings — see ProfileSettings. */\n settings?: ProfileSettings\n /**\n * The machine-wide policy CEILING every agent on this profile runs under.\n *\n * A top-level key rather than a setting: `ProfileSettings` is the set the\n * TERMINAL acts on, and this is read by the runtime and enforced inside\n * the capsule. Folding it in would widen that set's meaning to \"anything\n * configurable\" and lose the boundary it draws.\n *\n * An agent narrows within this and can never widen it. Set `process.run`\n * to `false` here and no agent on the machine gets a shell, whatever its\n * own axon.config.ts says. Set a rule to `\"escalate\"` and every agent asks\n * you — an agent author cannot suppress the prompt by allowing it.\n *\n * policy: {\n * process: { run: { allow: [\"bun *\", \"git *\"] }, spawn: false },\n * network: { \"api.anthropic.com:443\": true, \"*\": \"escalate\" },\n * tools: { github: \"escalate\" },\n * }\n *\n * Silence is no opinion, never a denial: a capability neither layer\n * mentions falls through to the agent's own policy, so adding one rule\n * here cannot lock out everything else.\n */\n policy?: ProfilePolicy\n /**\n * Extension settings, keyed by the extension's own scoped name.\n *\n * Typed as unknown because the platform has no business knowing an\n * extension's shape — the extension reads and validates its own block.\n */\n [extension: `@${string}/${string}`]: unknown\n }\n\n /**\n * One capability's rule.\n *\n * `true` allows, `false` denies, `\"escalate\"` asks. The object form matches\n * the first string argument — a command, a host, a path — by glob, where `*`\n * stops at a `/` and `**` crosses it. Inside one rule the strictest matching\n * clause wins: deny, then escalate, then allow, regardless of the order they\n * are written in.\n *\n * Declared INLINE rather than imported from the policy module, because this\n * file is copied verbatim into profile type frames and a profile directory has\n * no node_modules for an import to resolve through. `tui-policy.test.ts`\n * asserts it stays structurally identical to the real `PolicyRule` — a drift\n * here means a config that typechecks and does not enforce.\n */\n type ProfilePolicyRule =\n | boolean\n | \"escalate\"\n | {\n allow?: string[]\n deny?: string[]\n escalate?: string[]\n }\n\n /**\n * The subset of a capsule policy a PROFILE may declare.\n *\n * `fs` and `limits` are OS-layer facts (bind mounts, cgroups) rather than\n * per-call verdicts, and are taken from the profile wholesale when present —\n * a ceiling a bind mount ignores is not a ceiling.\n */\n type ProfilePolicy = {\n /**\n * OS confinement tier — Linux only, a no-op elsewhere. An agent may harden\n * beyond this but never drop below it.\n */\n isolation?: \"none\" | \"auto\" | \"hardened\"\n /** Filesystem view. Enforced by the mount namespace under `auto`/`hardened`. */\n fs?: {\n read?: string[]\n write?: string[]\n }\n /** Network destinations, keyed by `host:port` glob. */\n network?: Record<string, ProfilePolicyRule>\n /** Shell access. `run` is a one-shot command, `spawn` a long-lived child. */\n process?: {\n spawn?: ProfilePolicyRule\n run?: ProfilePolicyRule\n }\n /** OS resource caps, applied to the whole process tree. */\n limits?: {\n memory?: string\n cpu?: string\n pids?: number\n }\n /** Tool namespaces, keyed by the name a tool registers under. */\n tools?: Record<string, ProfilePolicyRule>\n }\n\n /**\n * A glyph vocabulary.\n *\n * `nerd` is the full Nerd Font range — branch symbols, folder icons, the lot.\n * `unicode` is the subset present in essentially every font (▸ ● ◆), which\n * renders everywhere and reads as deliberate rather than degraded. `none`\n * drops icons entirely, for a bar that should be text and nothing else.\n */\n type IconSet = \"auto\" | \"nerd\" | \"unicode\" | \"none\"\n\n /**\n * The named icons every set provides.\n *\n * Deliberately small and semantic: a component says what its value MEANS, and\n * the set decides what that looks like. Naming them after appearance\n * (\"triangle\") would tie every component to one set's vocabulary and defeat\n * the swap.\n */\n type IconName =\n | \"agent\"\n | \"model\"\n | \"session\"\n | \"tokens\"\n | \"messages\"\n | \"modules\"\n | \"branch\"\n | \"changes\"\n | \"ahead\"\n | \"behind\"\n | \"folder\"\n | \"clock\"\n | \"user\"\n | \"warning\"\n | \"error\"\n\n /** What `defineProfile()` returns. */\n type ProfileDefinition = {\n _kind: \"profile\"\n config: ProfileConfig\n }"
8
+ export const TUI_CONTRACT = " /**\n * The TUI extension contract — what a user's `main.ts`, a profile config, and\n * a published extension are written against.\n *\n * ── This file is copied verbatim into generated type frames ──────────────────\n *\n * `axon prepare` writes this source text into a profile's `.axon/types/` and an\n * extension's `.extension/types/` as ambient globals. That is why it declares\n * NO imports: a profile directory has no node_modules for an import to resolve\n * through (see prompt-dts.ts, which accepted the same constraint for the same\n * reason). Unlike prompts, there is no duplicated copy to keep in step — the\n * generator reads THIS file, so the contract and the globals cannot drift.\n *\n * Adding an import here breaks every profile's typecheck. Add the type instead.\n *\n * ── What this layer is for ───────────────────────────────────────────────────\n *\n * Workflow design in the terminal, and nothing more. The rule that draws the\n * boundary: an extension DRIVES the conversation, it never CONSUMES it.\n * `agents.send()` returns void — an extension that awaited model output and\n * branched on its text would be writing an agent, in the config layer, badly.\n * Agent behaviour belongs in a cognet, which the same user can build.\n *\n * The surface is deliberately small and complete against one test: everything\n * reachable from the keyboard is reachable from code. Mode keys → `mode`,\n * typing → `input`, palette navigation → `palette`, `:` → `commands`, chords →\n * `keys`, `~`/`/`/`^` → `agents`, Ctrl+C → `tui`. `keys.send()` backstops\n * whatever this missed. Nothing here renders: user surfaces are built from the\n * palette primitives, so every extension's UI is as good as the built-in one\n * and stays that way when the palette improves.\n */\n\n // ── Disposal ─────────────────────────────────────────────────────────────────\n\n /**\n * Undoes one registration.\n *\n * Every `register`/`create` returns one, and the loader tracks them per\n * extension so a hot-reload can tear the previous load down before running\n * setup again. Without this, each reload leaves its registrations behind and\n * one keystroke fires N handlers — the accumulation `Hooks().reset()` exists to\n * prevent on the agent runtime side.\n */\n type Disposer = () => void\n\n // ── Palette ──────────────────────────────────────────────────────────────────\n\n /**\n * One row in any palette — user-created or built-in.\n *\n * This is the SAME item type the TUI's own modes produce. A user palette that\n * could not express what `~` or `^` expresses would turn every gap into a\n * feature request, so the built-ins hold no privileged row shape: they are\n * simply the palettes that ship.\n */\n type PaletteItem = {\n id: string\n label: string\n description?: string\n /**\n * Independently-searchable parts of this row, for a list long enough that\n * one substring match over `label` stops being enough — every query term\n * narrows against any chunk. The model palette sets route and model id as\n * separate chunks, which is what lets ~800 rows live in one flat list with\n * no tabs or pages. Omit for ordinary rows.\n */\n chunks?: readonly string[]\n /**\n * Run on Enter. A returned promise holds the palette in its working state\n * until it settles. The signal aborts when the user escapes mid-flight —\n * actions that cannot be cancelled may ignore it.\n */\n action?: (signal: AbortSignal) => void | Promise<void>\n /** Selecting this row rewrites the query to this text instead of running `action` — descending into a group. */\n descendQuery?: string\n /** Selecting this row shows these rows as a follow-up list — a confirm/choice step. Computed at the moment it is confirmed. */\n choices?: () => PaletteItem[]\n /** Run on cursor movement, before confirming — live preview. */\n preview?: () => void\n /** Shown in the working row while an async `action` is in flight. */\n workingMessage?: string\n /**\n * Close immediately and let `action` finish in the background, rather than\n * holding the list open behind a working row.\n *\n * Only for actions whose progress has its OWN surface. An action that\n * reports nowhere else must not set this, or its failure becomes invisible.\n */\n detach?: boolean\n /** Non-selectable section header. */\n header?: boolean\n /** Non-selectable blank spacer between groups. */\n separator?: boolean\n }\n\n /** A tab in a tabbed palette. First tab is active on entry. */\n type PaletteTab = {\n id: string\n label: string\n }\n\n /** Loading/error indicator shown above the item list. */\n type PaletteStatus =\n | { kind: \"loading\"; message: string }\n | { kind: \"error\"; message: string }\n | null\n\n /**\n * What one query resolves to — items plus everything else this palette has to\n * say about that same query.\n *\n * Derived from a single call so status, breadcrumb and items can never drift\n * out of sync, which is the failure mode of computing them as independently\n * triggered fields. Returning a bare array is shorthand for `{ items }`.\n */\n type PaletteResult = {\n items: PaletteItem[]\n /** Prefix shown on every row — a path walked so far. */\n breadcrumb?: string | null\n status?: PaletteStatus\n /** True when the query cannot resolve to anything selectable — a dead-end token. */\n invalid?: boolean\n }\n\n /**\n * A user-defined palette.\n *\n * `list` is the only required member: given the query and active tab, return\n * the rows. It may be async — the palette shows its own loading state while the\n * first call is in flight, and results are cached until `refresh()` is called\n * on the handle.\n */\n type PaletteDefinition = {\n /**\n * Produce the rows for one query.\n *\n * The TUI applies its own substring filter over the returned items unless\n * `filter: false` — so a list that does not care about `query` can ignore\n * the argument entirely and still be searchable.\n */\n list: (query: string, tab: string | null) => PaletteItem[] | PaletteResult | Promise<PaletteItem[] | PaletteResult>\n /** This palette filters by query itself — the TUI must not filter again. */\n filter?: boolean\n /** Declares this palette as tabbed. Omit for a single flat list. */\n tabs?: PaletteTab[]\n /** Max visible rows before scrolling. */\n maxHeight?: number\n /**\n * \"top\" (default): newest first, cursor starts at the top. \"bottom\": items\n * are given oldest→newest, the cursor starts on the last row and up-arrow\n * walks back in time — the terminal-log feel of history and session mode.\n */\n anchor?: \"top\" | \"bottom\"\n /**\n * A mode key that opens this palette from an empty input, e.g. \"&\".\n *\n * Throws at registration if the key is already taken — a silently shadowed\n * mode key is unbearable to debug in someone else's config.\n */\n key?: string\n /** Symbol shown in the input bar while this palette is open. Defaults to `key`. */\n symbol?: string\n /** One-line description, shown in `?` (help) alongside the built-in modes. */\n description?: string\n }\n\n /** Handle on one registered palette. */\n type PaletteHandle = {\n readonly name: string\n /** Open it. Rejects if another palette is already open — see `palette.open`. */\n open: () => Promise<void>\n /** Drop the cached list so the next open recomputes it. Does not reopen. */\n refresh: () => void\n /** Unregister, closing it first if it is open. */\n dispose: Disposer\n }\n\n /** A pick option carrying a value, for `pick` over things that are not strings. */\n type PickOption<T> = {\n label: string\n description?: string\n value: T\n }\n\n /**\n * The palette — the TUI's interaction primitive, and the reason this layer can\n * stay small. Registered palettes cover \"the user opens a list\"; `pick`,\n * `confirm` and `prompt` cover \"code asks the user a question\".\n *\n * The question verbs return promises rather than taking callbacks, which is\n * what makes multi-step flows fall out for free: they are sequential awaits,\n * not a wizard framework.\n *\n * Every question resolves to a cancelled value on escape — `undefined`, or\n * `false` for `confirm`. That is in the return type deliberately: a caller is\n * forced to handle the user walking away.\n */\n type AxonPalette = {\n /** Register a palette. Throws if `name` is taken. */\n create: (name: string, definition: PaletteDefinition) => PaletteHandle\n\n /** A registered palette by name, or null. */\n get: (name: string) => PaletteHandle | null\n\n /**\n * Open a registered palette by name.\n *\n * Throws if no palette has that name, and throws if another palette is\n * already open — stealing the palette out from under someone mid-navigation\n * is exactly the kind of silent degradation that makes an extension system\n * feel haunted. Check `palette.isOpen` first if a keybind might collide.\n */\n open: (name: string) => Promise<void>\n\n /** Close whatever is open. No-op when nothing is. */\n close: () => void\n\n /** True while any palette is open, built-in or user-defined. */\n readonly isOpen: boolean\n\n /** Ask the user to choose one of a list of strings. Resolves undefined on escape. */\n pick: {\n (options: readonly string[], opts?: { placeholder?: string }): Promise<string | undefined>\n <T>(options: readonly PickOption<T>[], opts?: { placeholder?: string }): Promise<T | undefined>\n }\n\n /** Ask a yes/no question. Resolves false on escape. */\n confirm: (message: string) => Promise<boolean>\n\n /** Ask for a line of text. Resolves undefined on escape. */\n prompt: (message: string, opts?: { placeholder?: string; initial?: string }) => Promise<string | undefined>\n }\n\n // ── Commands ─────────────────────────────────────────────────────────────────\n\n /**\n * Where a command sits in the `:` tree.\n *\n * `\"deploy\"` is top level; `[\"theme\", \"set\"]` is nested under a group, which is\n * created on demand. Both forms accepted — a flat command should not have to be\n * written as a one-element array.\n */\n type CommandPath = string | readonly string[]\n\n /**\n * What a command IS — its behaviour and how it presents.\n *\n * ── Why a definition object rather than trailing options ────────────────────\n *\n * The alternative was `register(path, action, options?)`, and it loses for the\n * same reason positional hook arguments do. A third parameter is a fixed slot:\n * the day a command needs a fourth thing, it is either a fourth positional\n * nobody discovers or a breaking change. And `register(\"x\", fn, {...})` reads\n * as a function with some settings bolted on, when the truth is that the\n * behaviour and the presentation are one declaration.\n *\n * It also matches `palette.create(name, definition)`, which already takes its\n * work verb (`list`) inside the object. Two registration APIs shaped\n * differently is a thing to remember for no reason.\n *\n * The verb is `run` because that is what a command does. `action` was the\n * internal name and it describes a slot in a data structure, not the thing a\n * user is writing.\n */\n type CommandDefinition = {\n /**\n * The command's behaviour.\n *\n * A returned promise holds the palette in its working state until it\n * settles. The signal aborts when the user escapes mid-flight — a command\n * that cannot be cancelled may ignore it.\n */\n run: (signal: AbortSignal) => void | Promise<void>\n /** Shown beside the command in the palette. */\n description?: string\n /** Shown in the working row while an async command runs. */\n workingMessage?: string\n }\n\n type CommandsApi = {\n /**\n * Add a command to the `:` tree.\n *\n * Two forms, and the short one is not a legacy shape to be migrated off:\n *\n * commands.register(\"deploy\", async () => { ... })\n * commands.register(\"deploy\", {\n * async run() { ... },\n * description: \"Restart and redeploy\",\n * })\n *\n * A command with nothing to configure is genuinely just its behaviour, and\n * making that case carry `{ run }` would be ceremony charged to the most\n * common thing anyone writes. The moment there IS configuration, the object\n * form keeps it in one declaration instead of trailing off the end.\n *\n * Built-in commands always win a collision, and two extensions colliding is\n * first-registered-wins with a warning naming both — never silent shadowing.\n */\n register: {\n (path: CommandPath, run: (signal: AbortSignal) => void | Promise<void>): Disposer\n (path: CommandPath, definition: CommandDefinition): Disposer\n }\n\n /**\n * Run a command by path, exactly as pressing Enter on it would.\n *\n * This is how an extension reaches functionality that has a command but no\n * dedicated API — one verb instead of re-exposing every command's\n * implementation. Throws if the path resolves to nothing.\n */\n run: (path: CommandName | CommandPath) => Promise<void>\n\n /** Every registered command path, built-in and user. */\n list: () => readonly string[][]\n }\n\n // ── Keys ─────────────────────────────────────────────────────────────────────\n\n type KeysApi = {\n /**\n * Bind a chord, e.g. \"ctrl+o\".\n *\n * Built-in bindings win; two extensions colliding is first-wins with a\n * warning naming both. Bindings do not fire while a palette is open.\n */\n register: (chord: string, handler: () => void | Promise<void>) => Disposer\n\n /**\n * Deliver a keypress as though the user had typed it.\n *\n * The escape hatch that keeps this surface honest: anything the API forgot\n * to expose is still reachable, so a missing verb is an inconvenience\n * rather than a wall.\n */\n send: (chord: string) => void\n }\n\n // ── Modes ────────────────────────────────────────────────────────────────────\n\n /**\n * Built-in mode names. A user palette registered with a `key` adds its own\n * name to what `mode.set` accepts at runtime, which is why this is not a\n * closed union at the type level.\n */\n type BuiltinMode =\n | \"normal\"\n | \"command\"\n | \"model\"\n | \"session\"\n | \"agent\"\n | \"instance\"\n | \"voice\"\n | \"help\"\n | \"history\"\n | \"prompt\"\n | \"module\"\n | \"script\"\n\n type ModeName = BuiltinMode | (string & {})\n\n type AxonMode = {\n /** Switch modes. Throws on an unknown mode rather than silently doing nothing. */\n set: (mode: ModeName) => Promise<void>\n /** The active mode. */\n get: () => ModeName\n /** The symbol currently shown in the input bar. */\n symbol: () => string\n }\n\n // ── Input ────────────────────────────────────────────────────────────────────\n\n /** The message box the user types into. */\n type InputApi = {\n get: () => string\n set: (text: string) => void\n /** Append to the current text without clearing it — the voice-transcript behaviour. */\n append: (text: string) => void\n clear: () => void\n /**\n * Send the current input as a message to the focused agent, exactly as\n * pressing Enter would, and clear the box. No-op when it is empty.\n */\n submit: () => Promise<void>\n }\n\n // ── Agents ───────────────────────────────────────────────────────────────────\n\n /** What a running instance looks like to an extension. */\n type AgentInstance = {\n /** Stable identity of this instance. Every instance verb addresses by this. */\n readonly id: string\n /** The agent project's name — several instances may share one. */\n readonly name: string\n /** True for the instance currently on screen. */\n readonly focused: boolean\n /**\n * Null when idle.\n *\n * The last two are ATTACHED instances only — an agent reached over a URL,\n * whose wire can drop without the agent itself stopping. A local instance\n * never reports them: its runtime lives in this process, so there is no\n * connection to lose.\n *\n * Kept in step with `AgentActivity` in the TUI and with the copy in\n * tui-contract.ts, which is what a user's own config typechecks against.\n */\n readonly activity: \"booting\" | \"rebooting\" | \"shutting-down\" | \"working\" | \"reconnecting\" | \"disconnected\" | null\n }\n\n /** An agent that can be started — a local project or a deployment. */\n type AgentTarget = {\n readonly name: string\n readonly kind: \"local\" | \"deployed\"\n /** Running instances of this agent, most recently focused first. */\n readonly instances: readonly AgentInstance[]\n }\n\n /**\n * Agents, addressed the way the TUI addresses them: you START by name and then\n * everything else is BY INSTANCE.\n *\n * That split is not incidental. One agent can have many live instances — that\n * is what `spawn` twice gives you — so a verb taking a name has no answer for\n * \"which one\", and collapsing the two would make siblings unreachable from\n * extensions.\n */\n type AgentsApi = {\n /** Every agent that can be started, with its live instances. */\n targets: () => Promise<readonly AgentTarget[]>\n\n /** Every running instance, in spawn order. */\n list: () => readonly AgentInstance[]\n\n /** One instance by id, or null if it is not running. */\n get: (id: string) => AgentInstance | null\n\n /** The instance currently on screen, or null when nothing is running. */\n focused: () => AgentInstance | null\n\n /**\n * Boot a new instance of an agent IN THE BACKGROUND, resolving once it is\n * live. The view does not change.\n *\n * Always a NEW instance — this is the sibling verb.\n *\n * Background is the whole point: a config that booted two agents would\n * otherwise have them race for the screen, and neither asked to be looked\n * at. Showing one is a separate, explicit act — `tui.nav(name)` goes to an\n * agent (booting one if none is live), and `agents.focus(id)` goes to a\n * specific instance.\n *\n * Returns the instance, which is what makes a workflow composable: the id\n * is how every other verb here addresses it, and one agent may have many\n * live instances, so \"the one I just started\" cannot be recovered from the\n * name afterwards.\n */\n spawn: (name: string) => Promise<AgentInstance>\n\n /** Put an instance on screen. Throws if it is not running. */\n focus: (id: string) => void\n\n /**\n * Shut an instance down. The only verb here that ends a conversation.\n *\n * Omit `id` for the focused instance.\n */\n stop: (id?: string) => Promise<void>\n\n /**\n * Reload an instance's blueprint in place. The conversation survives.\n *\n * Omit `id` for the focused instance.\n */\n reboot: (id?: string) => Promise<void>\n\n /**\n * Send a message to the FOCUSED instance, as though the user had typed it\n * and pressed Enter.\n *\n * Returns when the message is DELIVERED, not when the agent has answered,\n * and yields nothing: an extension drives the conversation and never\n * consumes it. Reading a model's output to decide what to do next is an\n * agent's job — build a cognet.\n *\n * Focused rather than addressable, deliberately. Delivery is not a simple\n * dispatch — a send during a switch is QUEUED for the agent arriving rather\n * than delivered to the one being left, which is the difference between a\n * message landing in the right conversation and the wrong one. That rule is\n * defined in terms of what the user is looking at, so a per-instance send\n * would need its own answer to a question the focused path already answers\n * correctly.\n *\n * Note that `spawn()` does NOT focus what it starts, so sending to a\n * freshly spawned agent means going to it first:\n *\n * const reviewer = await agents.spawn(\"@axon/reviewer\")\n * agents.focus(reviewer.id)\n * await agents.send(\"review main\")\n */\n send: (content: string) => Promise<void>\n\n /** Interrupt the focused instance's current wake, as Escape does. True if something was interrupted. */\n interrupt: () => boolean\n }\n\n // ── The TUI itself ───────────────────────────────────────────────────────────\n\n /** Terminal dimensions in cells. */\n type TuiSize = {\n readonly width: number\n readonly height: number\n }\n\n // ── Themes ───────────────────────────────────────────────────────────────────\n\n /**\n * Every colour name the terminal can render.\n *\n * ── Generated, not written ──────────────────────────────────────────────────\n *\n * The list between the markers is produced by `scripts/contract.ts` from\n * VTerm's own colour parser — its terminal basics (`brightcyan`) plus the full\n * CSS3 named set. Do not edit it by hand; a name here that the parser does not\n * know renders as nothing, which is the failure the union exists to prevent.\n */\n type ColorName =\n // <color-names>\n | \"aliceblue\"\n | \"antiquewhite\"\n | \"aqua\"\n | \"aquamarine\"\n | \"azure\"\n | \"beige\"\n | \"bisque\"\n | \"black\"\n | \"blanchedalmond\"\n | \"blue\"\n | \"blueviolet\"\n | \"brightblack\"\n | \"brightblue\"\n | \"brightcyan\"\n | \"brightgreen\"\n | \"brightmagenta\"\n | \"brightred\"\n | \"brightwhite\"\n | \"brightyellow\"\n | \"brown\"\n | \"burlywood\"\n | \"cadetblue\"\n | \"chartreuse\"\n | \"chocolate\"\n | \"coral\"\n | \"cornflowerblue\"\n | \"cornsilk\"\n | \"crimson\"\n | \"cyan\"\n | \"darkblue\"\n | \"darkcyan\"\n | \"darkgoldenrod\"\n | \"darkgray\"\n | \"darkgreen\"\n | \"darkgrey\"\n | \"darkkhaki\"\n | \"darkmagenta\"\n | \"darkolivegreen\"\n | \"darkorange\"\n | \"darkorchid\"\n | \"darkred\"\n | \"darksalmon\"\n | \"darkseagreen\"\n | \"darkslateblue\"\n | \"darkslategray\"\n | \"darkslategrey\"\n | \"darkturquoise\"\n | \"darkviolet\"\n | \"deeppink\"\n | \"deepskyblue\"\n | \"dimgray\"\n | \"dimgrey\"\n | \"dodgerblue\"\n | \"firebrick\"\n | \"floralwhite\"\n | \"forestgreen\"\n | \"fuchsia\"\n | \"gainsboro\"\n | \"ghostwhite\"\n | \"gold\"\n | \"goldenrod\"\n | \"gray\"\n | \"green\"\n | \"greenyellow\"\n | \"grey\"\n | \"honeydew\"\n | \"hotpink\"\n | \"indianred\"\n | \"indigo\"\n | \"ivory\"\n | \"khaki\"\n | \"lavender\"\n | \"lavenderblush\"\n | \"lawngreen\"\n | \"lemonchiffon\"\n | \"lightblue\"\n | \"lightcoral\"\n | \"lightcyan\"\n | \"lightgoldenrodyellow\"\n | \"lightgray\"\n | \"lightgreen\"\n | \"lightgrey\"\n | \"lightpink\"\n | \"lightsalmon\"\n | \"lightseagreen\"\n | \"lightskyblue\"\n | \"lightslategray\"\n | \"lightslategrey\"\n | \"lightsteelblue\"\n | \"lightyellow\"\n | \"lime\"\n | \"limegreen\"\n | \"linen\"\n | \"magenta\"\n | \"maroon\"\n | \"mediumaquamarine\"\n | \"mediumblue\"\n | \"mediumorchid\"\n | \"mediumpurple\"\n | \"mediumseagreen\"\n | \"mediumslateblue\"\n | \"mediumspringgreen\"\n | \"mediumturquoise\"\n | \"mediumvioletred\"\n | \"midnightblue\"\n | \"mintcream\"\n | \"mistyrose\"\n | \"moccasin\"\n | \"navajowhite\"\n | \"navy\"\n | \"oldlace\"\n | \"olive\"\n | \"olivedrab\"\n | \"orange\"\n | \"orangered\"\n | \"orchid\"\n | \"palegoldenrod\"\n | \"palegreen\"\n | \"paleturquoise\"\n | \"palevioletred\"\n | \"papayawhip\"\n | \"peachpuff\"\n | \"peru\"\n | \"pink\"\n | \"plum\"\n | \"powderblue\"\n | \"purple\"\n | \"rebeccapurple\"\n | \"red\"\n | \"rosybrown\"\n | \"royalblue\"\n | \"saddlebrown\"\n | \"salmon\"\n | \"sandybrown\"\n | \"seagreen\"\n | \"seashell\"\n | \"sienna\"\n | \"silver\"\n | \"skyblue\"\n | \"slateblue\"\n | \"slategray\"\n | \"slategrey\"\n | \"snow\"\n | \"springgreen\"\n | \"steelblue\"\n | \"tan\"\n | \"teal\"\n | \"thistle\"\n | \"tomato\"\n | \"turquoise\"\n | \"violet\"\n | \"wheat\"\n | \"white\"\n | \"whitesmoke\"\n | \"yellow\"\n | \"yellowgreen\"\n // </color-names>\n\n /**\n * Any colour a theme token can hold.\n *\n * A named colour autocompletes; so does `transparent`, which means \"paint\n * nothing and let the real terminal show through\" — the right answer for\n * `background` in almost every theme.\n *\n * `(string & {})` keeps that autocomplete while still accepting the forms a\n * union cannot enumerate: `#1a1b26`, `rgb(26, 27, 38)`, an rgba() with alpha.\n * Unlike `syntax`, an unrecognised value here is not automatically a typo —\n * hex is the common case — so this stays open where that one is closed.\n */\n type ThemeColor =\n | ColorName\n | \"transparent\"\n | (string & {})\n\n /**\n * The seven tokens every Axon surface draws from.\n *\n * Closed on purpose. The TUI reached ~30 hard-coded colours before this — four\n * greys nobody chose deliberately, five reds — and a theme API with a field per\n * call site would preserve that forever: a \"theme\" would mean thirty decisions,\n * and no two themes would agree what any of them were for.\n *\n * Seven decisions, and every surface derives from them. That is what makes a\n * theme portable: whatever an author writes lands on the same things.\n */\n type ThemeTokens = {\n /** Accent. Selection, the input rule, focused rows, links. */\n primary: ThemeColor\n /** The terminal's own ground. */\n background: ThemeColor\n /** Ordinary foreground — what most text is. */\n text: ThemeColor\n /** Secondary foreground: paths, descriptions, timestamps, anything subordinate. */\n dim: ThemeColor\n /** Something needs attention but nothing failed. */\n warn: ThemeColor\n /** Something failed. */\n error: ThemeColor\n /**\n * Syntax highlighting for code blocks and the editor.\n *\n * A bundled theme name autocompletes — see `BundledSyntax` for the full\n * set. An author who wants their own tokenisation passes a TextMate theme\n * object instead, which is the same shape Shiki takes.\n *\n * Deliberately NOT widened with `(string & {})` the way `ThemeColor` is.\n * A colour Axon does not recognise still renders — the terminal hands it\n * to the ANSI layer and something sensible happens. A syntax theme name\n * Shiki does not have loads nothing, so an unrecognised string is always a\n * typo, and the union is what turns it into a red squiggle in the user's\n * editor instead of unhighlighted code they have to diagnose.\n */\n syntax: BundledSyntax | Record<string, unknown>\n }\n\n /** A registered theme: its tokens plus the name it is addressed by. */\n type Theme = ThemeTokens & { name: string }\n\n /**\n * Every syntax theme that ships with Axon.\n *\n * ── Generated, not written ──────────────────────────────────────────────────\n *\n * The list between the markers below is produced by `scripts/contract.ts` from\n * Shiki's own `bundledThemes`, and rewritten in place whenever that script\n * runs. Do not edit it by hand — a name here that Shiki does not have is a\n * theme that typechecks and then fails to load at runtime, which is exactly the\n * failure a literal union is supposed to prevent.\n *\n * It is a literal union rather than an import because this file is copied\n * verbatim into a profile's type frame, where there is no node_modules to\n * import Shiki through. The generator is what keeps the copy honest.\n *\n * ── Bundling all of them is nearly free ─────────────────────────────────────\n *\n * Shiki's bundle is a map of dynamic-import thunks and the highlighter is\n * constructed with ONE theme, calling `loadTheme()` for each further one a user\n * actually selects. So the cost of offering every theme is a single import at\n * the moment someone picks it — not the whole set at boot.\n */\n type BundledSyntax =\n // <bundled-syntax>\n | \"andromeeda\"\n | \"aurora-x\"\n | \"ayu-dark\"\n | \"catppuccin-frappe\"\n | \"catppuccin-latte\"\n | \"catppuccin-macchiato\"\n | \"catppuccin-mocha\"\n | \"dark-plus\"\n | \"dracula\"\n | \"dracula-soft\"\n | \"everforest-dark\"\n | \"everforest-light\"\n | \"github-dark\"\n | \"github-dark-default\"\n | \"github-dark-dimmed\"\n | \"github-dark-high-contrast\"\n | \"github-light\"\n | \"github-light-default\"\n | \"github-light-high-contrast\"\n | \"houston\"\n | \"kanagawa-dragon\"\n | \"kanagawa-lotus\"\n | \"kanagawa-wave\"\n | \"laserwave\"\n | \"light-plus\"\n | \"material-theme\"\n | \"material-theme-darker\"\n | \"material-theme-lighter\"\n | \"material-theme-ocean\"\n | \"material-theme-palenight\"\n | \"min-dark\"\n | \"min-light\"\n | \"monokai\"\n | \"night-owl\"\n | \"nord\"\n | \"one-dark-pro\"\n | \"one-light\"\n | \"plastic\"\n | \"poimandres\"\n | \"red\"\n | \"rose-pine\"\n | \"rose-pine-dawn\"\n | \"rose-pine-moon\"\n | \"slack-dark\"\n | \"slack-ochin\"\n | \"snazzy-light\"\n | \"solarized-dark\"\n | \"solarized-light\"\n | \"synthwave-84\"\n | \"tokyo-night\"\n | \"vesper\"\n | \"vitesse-black\"\n | \"vitesse-dark\"\n | \"vitesse-light\"\n // </bundled-syntax>\n /** Axon's own, and the default. */\n | \"arcnight\"\n\n // ── lines ───────────────────────────────────────────────────────────────────\n\n /**\n * One live value on a line — a name, when it changes, and what it says.\n *\n * THE TRIGGER IS DECLARED, and that is the whole design. A bare `() => string`\n * would leave the terminal with no idea when to call it: re-running every\n * component on every frame makes one slow component stall the paint, and the\n * alternative — asking users to wire their own reactivity — is the thing this\n * API exists to avoid. So a component states what wakes it and the renderer\n * evaluates it then and never otherwise.\n *\n * `render` is SYNCHRONOUS by contract. A frame cannot await, and a component\n * that needs real work (a git branch, a network call) does that work in its\n * trigger and returns the cached value here — the same discipline lualine\n * settles on, arrived at from the render loop rather than from convention.\n *\n * A component with neither `on` nor `every` renders once and stays put, which\n * is the right shape for something static.\n */\n type LineComponent = {\n /**\n * A glyph shown before the value — a NAME from the catalogue, or a literal.\n *\n * A NAME resolves through the active icon set, so one setting swaps every\n * icon at once — which is what makes a shared component work on a machine\n * without a patched font. A literal glyph is the escape hatch for\n * something the catalogue does not name, and it does NOT respond to the\n * setting: an author writing a raw character has said they know what\n * appears.\n *\n * The author's, not the config's — an icon is part of what a component\n * MEANS (a git component without its branch glyph is a worse git\n * component), where colour is part of how a LINE looks and belongs to\n * whoever composes the row.\n *\n * Rendered only when the component has something to say: an icon beside an\n * empty value is a glyph floating on its own.\n */\n icon?: IconName | (string & {})\n /**\n * Hook events that change this value — the same names `tui.hook` takes.\n *\n * Reusing that vocabulary is deliberate: the terminal already emits a\n * precise event for everything it does, so a component author picks from a\n * list they have already learned rather than inventing a subscription.\n */\n on?: readonly TuiHookName[]\n /**\n * Re-render every N milliseconds — for values that change with time rather\n * than with anything the terminal does. A clock is the case; there is no\n * event for \"a second passed\".\n *\n * Taken as written, with no floor. Painting a string is cheap and the\n * renderer diffs frames for exactly this; a component doing heavy work on\n * a fast interval is the author's call, the same as a slow hook handler.\n */\n every?: number\n /**\n * Run when the user clicks this component.\n *\n * Named for what the AUTHOR does, not for the event vterm dispatches\n * (`@press`). A config says \"when this is clicked\"; the transport's name\n * for that is an implementation detail of the layer below.\n *\n * What turns a status line into a control surface: a row of agent names\n * becomes a nav bar, a branch indicator becomes a branch picker. Without\n * it a line can only report, and reporting is the smaller half of what a\n * bar sitting in front of you all day could do.\n *\n * Unawaited by the terminal — a handler that takes a second must not hold\n * the frame — and a failure is reported like any other config fault rather\n * than surfacing as a click that silently did nothing.\n */\n click?: () => void | Promise<void>\n /**\n * What to show, coerced to text.\n *\n * Primitives only, deliberately. `string` alone forced `String(count)` on\n * the most ordinary component there is; `unknown` would accept an object,\n * an array or a promise and render `[object Object]` silently — and an\n * author who slipped an `async` onto this would get `[object Promise]` on\n * their line with nothing to explain it. Widening removes ceremony, not\n * the errors the type was catching.\n *\n * `null`/`undefined` are the honest way to say \"nothing right now\", and\n * render as empty rather than as the text \"null\".\n */\n render: () => string | number | null | undefined\n }\n\n /**\n * A line's content — up to three slots, laid out by the terminal.\n *\n * Axon owns spacing, separators, truncation and colour; a config supplies text\n * and its order. That split is the product decision: every layout knob is a\n * way for two configs to disagree, and the failure mode it prevents is a\n * handful of beautiful setups surrounded by mediocre ones. Users theme,\n * Axon lays out.\n *\n * `left` and `right` push apart. `middle` centres on the LINE, not on the gap\n * between the sides, and truncates when there is no room — one rule, so a\n * three-slot line never needs a negotiation nobody can predict.\n */\n type LineContent = {\n left?: LineSlot\n middle?: LineSlot\n right?: LineSlot\n /**\n * The style this line was DESIGNED for — a default, not a decree.\n *\n * An author knows what their line is meant to look like, so declaring it\n * here means a shared line arrives looking right with no configuration.\n * But the placement wins: a user who wants it plain says so in\n * `lines.set()` and never has to fork the line to restyle it.\n *\n * Precedence, narrowest first: placement → this → `lines.style()`.\n */\n style?: AxonLineStyle\n }\n\n /**\n * One slot's contents: a flat list of components, or a list of SECTIONS.\n *\n * A section is the unit a separator divides and a background fills — which is\n * why the nesting exists at all. Inside one section every component shares a\n * ground, so the divider between them is a hairline; between sections the\n * ground changes, so the divider is a filled arrow. That is the whole\n * distinction lualine draws with `component_separators` and\n * `section_separators`, and it cannot be expressed on a flat list.\n *\n * A flat array is one section. Nothing already written changes meaning.\n */\n type LineSlot = readonly ComponentName[] | readonly (readonly ComponentName[])[]\n\n /**\n * A component's name — the catalogue Axon ships, or one you registered.\n *\n * The built-ins are enumerated so an editor completes them and a typo is a\n * compile error rather than a gap you find on screen. `(string & {})` keeps\n * that completion while still accepting names this union cannot know: a\n * component from an extension, or one the same config declared a few lines up.\n *\n * The same shape `ThemeColor` uses, for the same reason — a closed union would\n * make the escape hatch impossible, and an open `string` would make the\n * catalogue undiscoverable.\n */\n type ComponentName = RegistryName<AxonComponentRegistry>\n\n /**\n * A generated registry's names — CLOSED once the registry has entries.\n *\n * ── Why this is not simply `keyof R | (string & {})` ────────────────────────\n *\n * That shape gives completion but never rejects anything: the open arm accepts\n * every string, so a typo typechecks and only fails at runtime — which is the\n * bug the generator exists to remove.\n *\n * An empty registry still has to accept anything, though. A profile before its\n * first `axon prepare` has no generated file, and every name in it would be an\n * error against a `never` union — a config that was fine yesterday would light\n * up red because a build step had not run yet.\n *\n * So the union closes only when it has something to close AROUND: empty means\n * open, populated means exact. A name the generator genuinely cannot see (one\n * computed at runtime) is cast at the call site, which is the honest signal\n * that it is unverifiable rather than a hole left open for every name.\n */\n type RegistryName<R> = keyof R extends never ? string : keyof R & string\n\n /**\n * Every line name known at generation time.\n *\n * Same mechanism as AxonComponentRegistry — see that interface for why these\n * are generated rather than written by hand.\n */\n type LineName = RegistryName<AxonLineRegistry>\n\n /**\n * Every palette name known at generation time.\n */\n type PaletteName = RegistryName<AxonPaletteRegistry>\n\n /**\n * Every command path known at generation time, space-joined.\n */\n type CommandName = RegistryName<AxonCommandRegistry>\n\n /**\n * The registries `axon prepare` fills in.\n *\n * ── Generated, not hand-written ─────────────────────────────────────────────\n *\n * These were a hand-maintained union of the built-in names, which drifted the\n * first time someone added a component and forgot to update it. The generator\n * reads the actual catalogue AND every config's own `create` calls, so what an\n * editor completes is what is really registered — including the component you\n * declared four lines above the line using it.\n *\n * ── Why an interface rather than a type alias ───────────────────────────────\n *\n * Declaration merging. A generated `.d.ts` reopens the interface and adds its\n * keys, which means built-ins, extension contributions and a user's own\n * registrations all land in one union with no privileged tier. An alias could\n * only be replaced, not extended, so every source would need its own name and\n * the consumer would have to union them by hand.\n *\n * Empty here by design: a profile with no generated types still typechecks,\n * because every consuming alias keeps a `(string & {})` arm.\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonComponentRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonLineRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonPaletteRegistry {}\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface AxonCommandRegistry {}\n\n /**\n * How a line draws its separators and shades its sections.\n *\n * A preset, never individual glyphs. Axon owning the glyph set is the line\n * between \"every config looks like Axon\" and \"everyone invents their own bar\"\n * — and a config that picked its own would be choosing a look that has to hold\n * against every theme, which is not a decision anyone should have to make\n * per row.\n *\n * Backgrounds step from the EDGE INWARD: the outermost section takes the\n * accent, each step inward is softer, and the innermost sits on the terminal's\n * own ground. Position in the array is the section, so there is no background\n * to configure — which is what stops two configs disagreeing about what a\n * status bar looks like.\n */\n type AxonLineStyle =\n /** No glyphs. Components separated by spacing alone. */\n | \"plain\"\n /**\n * Filled arrows between sections, hairlines within — the default.\n *\n * The separator block (`U+E0B0`–`U+E0B7`) predates Nerd Fonts and ships far\n * more widely than the icon range, so a terminal that draws a git icon as a\n * box still renders these. One without even that sets `\"plain\"`.\n */\n | \"powerline\"\n /** The same, with round caps. Needs a Nerd Font. */\n | \"rounded\"\n /**\n * Square edges: a flat boundary between fills and a vertical bar within.\n *\n * The same section model as `powerline`, without the arrow's implied\n * direction — which reads as calmer beside a busy conversation, and is\n * what you want when the bar should sit still rather than point at\n * something. Needs a Nerd Font.\n */\n | \"block\"\n /** A thin middle dot between components, no section fills. */\n | \"minimal\"\n\n /**\n * A line's definition: the full three-slot form, or a bare array.\n *\n * The array means LEFT, always — never auto-distributed. Both built-in lines\n * are left-aligned, so it is the common case worth a shorthand, and a rule\n * that reads the same every time beats one that guesses.\n */\n type LineDefinition = LineContent | readonly string[]\n\n /**\n * One entry in the stack: a name, or a name with placement overrides.\n *\n * The bare string is the common case and stays the common case — an object is\n * only needed when this particular placement differs from what the line\n * declared.\n */\n type AxonLineEntry = LineName | AxonLinePlacement\n\n /**\n * How ONE line is placed in ONE stack.\n *\n * ── Why placement owns style ────────────────────────────────────────────────\n *\n * Three layers, three owners: a COMPONENT is what the data is (an extension\n * author's), a LINE is what sits where (shared or personal), and a PLACEMENT\n * is how it looks in this stack (always the user's).\n *\n * Style began on the line and that was the wrong layer. A shared line would\n * ship with its look baked in, so anyone installing `@cody/git-line` had to\n * fork it to restyle — which is the coupling that stops a registry being\n * worth having. A line may still declare a default, because an author knows\n * what their line was designed to look like; the placement wins when it says\n * otherwise.\n *\n * Precedence, narrowest first: this placement → the line's own default →\n * `lines.style()`.\n */\n type AxonLinePlacement = {\n /** The registered line this entry places. */\n line: LineName\n /** How it draws here, overriding the line's default and the stack's. */\n style?: AxonLineStyle\n /**\n * Start hidden, keeping its place in the stack.\n *\n * Declared here rather than left to a `hide()` call afterwards, so the\n * stack is one description instead of a description plus a sequence of\n * mutations. `toggle()` still flips it at runtime.\n */\n hidden?: boolean\n }\n\n /**\n * Where a line moves to. `\"up\"`/`\"down\"` are relative; a number is an absolute\n * index in the stack, clamped rather than throwing — a keybind that walks a\n * line to the top should stop there, not fail on the last press.\n */\n type LinePosition = \"up\" | \"down\" | number\n\n /** A registered line, as `lines.list()` reports it. */\n type Line = {\n /**\n * Unique within the stack — the name is NOT an identity, since a line may\n * be placed more than once (comparing two styles side by side is a real\n * thing to want).\n */\n id: string\n name: string\n content: LineContent\n /** How it draws. Falls back to the stack default when the line declared none. */\n style: AxonLineStyle\n /** False when hidden. A hidden line keeps its place in the stack. */\n visible: boolean\n }\n\n /**\n * Components — the live values a line can show.\n *\n * Axon ships a catalogue under the `axon:` prefix (`axon:token/counter` and\n * friends), and anything else registers here. The two are the same kind of\n * thing: a built-in is a component the terminal registered against its own\n * hooks, with no privilege a user's cannot have.\n *\n * Names are `provider:name` rather than a package specifier. A package ships\n * many things; a component comes from one provider — conflating the two would\n * make every component name read like an import path.\n */\n type AxonComponents = {\n /**\n * Register a component. Throws if the name is taken. Returns a disposer.\n *\n * A `render` that throws costs that component and nothing else: it renders\n * empty and the fault is reported, the same containment the config loader\n * applies per file. One bad value must not take down the line around it.\n */\n create: (name: string, component: LineComponent) => Disposer\n\n /** Every registered component name, built-ins included. */\n list: () => readonly string[]\n }\n\n /**\n * Lines — the configurable rows above the input bar.\n *\n * The terminal ships two of its own and they stay its: the cwd/token row and\n * the voice row. A user's lines sit between them, which is the one layout\n * decision Axon does not delegate — the rows that must always be readable are\n * not ones a config can push off screen.\n *\n * Registration and placement are SEPARATE VERBS, and that is what makes the\n * surface extensible: an extension `create`s lines without deciding where they\n * go, and the user `set`s the stack without knowing who authored what.\n */\n type AxonLines = {\n /**\n * Register a line. Throws if the name is taken, or if it names a component\n * that does not exist — a config error the loader can contain, reported\n * where it can be fixed rather than rendered as a blank row.\n */\n create: (name: string, definition: LineDefinition) => Disposer\n\n /**\n * The default style for every line that does not declare one.\n *\n * A stack-wide setting because a bar with one powerline row among plain\n * ones reads as a mistake, not a choice — and because the common case is\n * wanting ALL of them to match. A line that genuinely differs still says so\n * itself, which is the rarer thing and reads as deliberate at the call site.\n *\n * Called with no argument, returns the current default.\n */\n style: {\n (style: AxonLineStyle): void\n (): AxonLineStyle\n }\n\n /**\n * The single line ABOVE the conversation, or null to clear it.\n *\n * One line, not a stack. The room above the conversation is scarce in a\n * way the room below it is not — the bottom already holds the input bar\n * and its own rows, so a stack there is bounded by something. A second\n * unbounded stack at the top could push the conversation off screen, and\n * the constraint costs nothing: nobody has wanted two.\n *\n * Takes the same placement object as `set`, so a top line styles itself\n * the same way any other does.\n */\n top: {\n /** Set it by name, with placement options. */\n (name: LineName, options?: Omit<AxonLinePlacement, \"line\">): void\n /** Set it from a placement object, or clear it with null. */\n (entry: AxonLineEntry | null): void\n /** Read what is currently set. */\n (): Line | null\n }\n\n /**\n * Set the whole stack, top to bottom. Declarative and idempotent: this is\n * the one place order lives, so reordering is calling it again.\n *\n * An entry is a bare name, or an object when this placement differs from\n * the line's own defaults — see LinePlacement. Registered lines left out\n * of the array are not shown; an unknown name is reported.\n */\n set: (entries: readonly AxonLineEntry[]) => void\n\n /**\n * Move one line within the stack. Addressed by NAME, never by index —\n * an index shifts when anything above it moves, so a keybind written today\n * would quietly mean something else tomorrow.\n */\n move: (name: string, position: LinePosition) => void\n\n /** Hide a line. It keeps its place, so showing it again returns it there. */\n hide: (name: string) => void\n /** Show a hidden line, back where it was. */\n show: (name: string) => void\n /** Flip visibility — the verb a keybind wants. */\n toggle: (name: string) => void\n\n /** Every registered line, in stack order. What a picker palette reads. */\n list: () => readonly Line[]\n }\n\n /**\n * Themes — the terminal's colours, and switching between them.\n *\n * A theme is registered like a palette and applied like a mode. `\"` opens the\n * built-in picker, which previews as the cursor moves: hovering a row paints it\n * for real, because a preview that rendered differently from the result would\n * be worth nothing.\n */\n type AxonTheme = {\n /**\n * Register a theme. Throws if the name is taken. Returns a disposer.\n *\n * Name first, tokens second — the same shape as `palette.create`, so the\n * two read alike rather than one carrying its identity inside the object\n * and the other beside it.\n */\n create: (name: string, tokens: ThemeTokens) => Disposer\n\n /** Paint a theme and keep it. Throws on an unknown name. */\n set: (name: string) => void\n\n /** Every registered theme, built-ins first. */\n list: () => readonly Theme[]\n\n /** The theme currently painted. */\n readonly active: Theme\n }\n\n /**\n * Everything that belongs to the terminal rather than to one of the domains\n * above. Kept deliberately thin — a verb with a natural home in `palette`,\n * `commands`, `keys`, `mode`, `input` or `agents` belongs there.\n */\n /** Trailing options for `tui.info` / `warn` / `error`. */\n type NoticeOptions = {\n /** How long the notice holds the row, in milliseconds. Clamped to a few seconds. */\n ms: number\n }\n\n type AxonTui = {\n /**\n * Go to an agent: focus the instance the user was last on, booting one if\n * none is live. The `~` key's behaviour.\n *\n * Name-addressed on purpose — \"take me to this agent\" is a different verb\n * from \"focus this exact instance\" (`agents.focus`), and both are real.\n */\n nav: (name: string) => Promise<void>\n\n /**\n * Register a lifecycle handler. See TuiHooks.\n *\n * Available everywhere — `main.ts`, a `plugins/` file, an extension's\n * `setup()` — because there is no capability difference between them, only\n * a timing one. `plugins/` is where hooks live by convention, not by rule.\n */\n hook: <N extends TuiHookName>(name: N, handler: TuiHooks[N]) => Disposer\n\n /**\n * A brief label on the cwd row — the same line the ctrl+c and double-esc\n * hints borrow. Flashes for 300ms by default, then the row returns to the\n * path.\n *\n * tui.info(\"deployed\")\n * tui.warn(\"nothing to do\", { ms: 600 })\n * tui.error(\"command failed\")\n *\n * ── A reaction, not a message ───────────────────────────────────────────\n *\n * This row's existing tenants are both feedback about the key just pressed,\n * and these are the same thing: something to catch the eye, not something\n * to read. Longer than ~50 characters is trailed with an ellipsis, which is\n * the honest consequence of a one-line surface rather than a limit to work\n * around.\n *\n * So anything with CONTENT — a reason, a path, a stack — does not belong\n * here. Throw instead: it lands in the config error list on the chat page,\n * which is scrollable and stays put.\n *\n * Takes any number of values and joins them with a space, the way\n * `console.log` does — so a config building a label from several pieces\n * does not have to concatenate first. Non-strings are stringified;\n * objects and arrays go through JSON so a stray value reads as data\n * rather than as `[object Object]`.\n *\n * The terminal's own hints outrank all three verbs — one fired during the\n * ctrl+c window waits rather than displacing the exit ladder.\n *\n * Duration is a trailing `{ ms }` rather than a bare number, because\n * under variadic args a trailing number is DATA: `tui.info(\"saved\", 500)`\n * has to mean \"saved 500\", not \"show this for half a second\".\n *\n * tui.info(\"[\", keys.join(\" \"), \"]\")\n * tui.warn(\"nothing to do\", { ms: 600 })\n */\n info: (...args: unknown[]) => void\n\n /** As `info`, in the warning colour. */\n warn: (...args: unknown[]) => void\n\n /** As `info`, in the error colour. For \"that failed\" — never for why. */\n error: (...args: unknown[]) => void\n\n readonly size: TuiSize\n\n /** The directory the TUI was launched from. */\n readonly cwd: string\n\n /** Version of the running Axon CLI. */\n readonly version: string\n\n /**\n * Quit, running the same exit guards a Ctrl+C does.\n *\n * There is deliberately no `update()`: a self-update hands off to a helper\n * that runs after the process exits, and an extension triggering that is a\n * way for a config to brick an install mid-session.\n */\n exit: () => Promise<void>\n }\n\n // ── Hooks ────────────────────────────────────────────────────────────────────\n //\n // ONE verb: `tui.hook(name, handler)`. There is deliberately no `.on()`\n // alongside it.\n //\n // A blocking `hook()` and a fire-and-forget `on()` are indistinguishable at the\n // call site — one letter apart, differing only in a consequence you cannot see\n // — and picking the wrong one buys either a race or a hang. Whether the TUI\n // waits is a property of the EVENT, not of how a handler was registered: `boot`\n // has a meaningful \"before\" to run in, `mode:changed` announces something that\n // already happened and waiting on it only delays the UI.\n //\n // So the event decides, the types say which is which, and a user who wants\n // fire-and-forget writes it where it is visible:\n //\n // tui.hook(\"tui:boot\", () => { void backgroundSync() })\n\n /**\n * Gating hooks — the TUI WAITS for these, and they can fail the operation.\n *\n * Only lifecycle transitions with a real \"before\" qualify. A slow handler here\n * delays the terminal, so the runtime bounds it: exceeding the budget reports\n * `extension X is blocking <hook>` and continues. It never hangs silently, and\n * a config that stalls boot must always say so — an unexplained frozen terminal\n * is the worst failure this feature can produce.\n */\n type TuiGateHooks = {\n /** Before the TUI becomes interactive. Registration is done; the screen is not up. */\n \"tui:boot\": (payload: TuiBootPayload) => void | Promise<void>\n /** Before shutdown proceeds. The last point at which anything can be flushed to disk. */\n \"tui:shutdown\": (payload: TuiShutdownPayload) => void | Promise<void>\n }\n\n // ── Hook payloads ────────────────────────────────────────────────────────────\n //\n // EVERY hook takes exactly one object, always — including the ones that have\n // nothing to say. `tui.hook(name, ({ x }) => ...)` is the shape throughout, so\n // a handler is written the same way whichever event it listens to, and reading\n // one tells you nothing about which.\n //\n // Positional arguments were the alternative and they lose on every axis that\n // matters here. They fix an order, so adding a field is a choice between a\n // trailing bag nobody discovers and a breaking change; they cannot be\n // destructured by name, so `(a, b)` at a call site says nothing about what a\n // and b are; and they make the empty case a THIRD spelling (`() => {}` beside\n // `(x) => {}` beside `(x, y) => {}`) for no gain. An empty object costs a\n // handler nothing — `() => {}` still type-checks, because a function may always\n // ignore parameters it was handed.\n //\n // So the rule is mechanical and has no exceptions: one payload object per hook,\n // named fields, and a payload type declared here even when it is empty. An\n // empty payload is where a field will go, and having the type already named is\n // what makes adding one a non-event.\n\n /**\n * `tui:boot` — nothing yet.\n *\n * Empty rather than absent: the parameter exists so a later field arrives\n * without changing any handler's shape, and so boot is written exactly like\n * every other hook.\n */\n type TuiBootPayload = {}\n\n /** `tui:shutdown` — nothing yet. Empty for the same reason as boot. */\n type TuiShutdownPayload = {}\n\n /** `tui:reloaded` — nothing yet. Empty for the same reason as boot. */\n type TuiReloadedPayload = {}\n\n /** `tui:resize` — the terminal's new dimensions, in cells. */\n type TuiResizePayload = {\n /** Columns. */\n width: number\n /** Rows. */\n height: number\n }\n\n /**\n * `tui:copy` — the text that was copied.\n *\n * The text is CARRIED rather than left for the handler to read back off the\n * selection: copying does not clear the selection, but nothing stops the user\n * (or another handler) from clearing it before this one runs, and a handler\n * that re-read it would then see an empty string for a copy that plainly\n * happened. What is passed is exactly what reached the clipboard.\n *\n * Never empty — an empty selection copies nothing and fires nothing.\n */\n type TuiCopyPayload = {\n /** The copied text, verbatim: original line breaks, no trimming. */\n text: string\n }\n\n /**\n * `key:pressed` — one keystroke the TUI did not act on.\n *\n * `mode` rides along because \"was a palette open when this fired\" is the first\n * question a handler asks, and reading it back through `mode.get()` would race\n * the very transition that may have been caused by this key.\n */\n type KeyPressedPayload = {\n /**\n * The chord, in the spelling `keys.register()` accepts — `\"a\"`, `\"ctrl+o\"`,\n * `\"shift+tab\"`. Round-trips deliberately: a handler that decides to claim\n * a key can pass this string straight to `keys.register`.\n */\n key: string\n /** The mode that was active when the key arrived. */\n mode: ModeName\n }\n\n /** `palette:opened` / `palette:closed` — which palette. */\n type PalettePayload = {\n /** The palette's mode name — `\"command\"`, `\"agent\"`, or a user palette's. */\n name: ModeName\n }\n\n /** What one instance hook reports. */\n type AgentPayload = {\n instance: AgentInstance\n }\n\n /** `message:sent` — the text, and where it went. */\n type MessageSentPayload = {\n content: string\n instance: AgentInstance\n }\n\n /** `message:received` — see the hook for why there is no content. */\n type MessageReceivedPayload = {\n instance: AgentInstance\n }\n\n /** `mode:changed` — the transition, both ends. */\n type ModeChangedPayload = {\n from: ModeName\n to: ModeName\n }\n\n /** `command:ran` / `command:failed` — which command, and how it was reached. */\n type CommandPayload = {\n /**\n * Where the command sits in the command TREE, one segment per level —\n * `[\"ext\", \"update\"]`, `[\"theme\", \"set\", \"gruvbox\"]`.\n *\n * An array rather than a space-joined string because the segments are what\n * both call sites already hold (`[...breadcrumb, node.label]` in the\n * palette, `toPath(path)` in `commands.run()`) and what registration,\n * lookup and COMMAND_NOT_FOUND all use. The string was a lossy projection\n * at one boundary: `split(\" \")` is not its inverse once an argument\n * contains a space, so the commands most worth reacting to — a pasted key,\n * a path with spaces — were exactly the ones a handler mis-parsed.\n *\n * A list-backed group puts its chosen row here, not in `arg`: a theme name\n * is a NODE the palette listed, from a closed set, so `:theme set gruvbox`\n * is three segments. That makes every pick a distinct path, which is how a\n * handler knows WHICH theme — so match a namespace with `path[0]`, not a\n * whole-array compare.\n */\n path: string[]\n\n /**\n * The raw text typed after an input command, or undefined when the command\n * takes none — `\"/some/dir\"` for `:watch /some/dir`.\n *\n * Separate from `path` because it is a different KIND of thing: a segment\n * comes from a closed set and is matchable, an argument is arbitrary user\n * text. Folding it in would turn \"did watch run\" from an equality check\n * into a prefix test, and make every invocation its own path.\n *\n * ── The invariant this field rests on ───────────────────────────────────\n *\n * An input node TERMINATES traversal — `CommandInput` has no children, and\n * everything after it is taken as the argument verbatim, spaces included\n * (traverse.ts: `rawSegments.slice(i + 1).join(\" \")`). So there is at most\n * one per path and it is always the tail, at whatever depth the input node\n * sits: `:watch <dir>` is depth 1, `:provider openrouter connect <key>` is\n * depth 3, and both put the whole remainder here.\n *\n * If the grammar ever admits MID-PATH arguments (`:agent <name> rename\n * <new>`), this field must change shape — one string cannot represent two.\n * That is a parser change, so it will be caught here rather than silently\n * producing a wrong `arg`.\n */\n arg?: string\n /**\n * How it was invoked: chosen in the command palette, or run by\n * `commands.run()`.\n *\n * Present so a handler can tell the user's action from its own — an\n * extension that reacts to every command by running another would otherwise\n * have no way to avoid recursing into itself.\n *\n * There is deliberately no `\"key\"`. A key bound to a command calls\n * `commands.run()` from its handler, so it IS an api call and reporting it\n * as its own source would be inventing a distinction the runtime cannot\n * actually make — a handler that checked for it would never match.\n */\n source: \"palette\" | \"api\"\n }\n\n /** `command:failed` — the above, plus what went wrong. */\n type CommandFailedPayload = CommandPayload & {\n /** The thrown value, exactly as it was thrown. */\n error: unknown\n }\n\n /**\n * Notification hooks — announcements of something that ALREADY happened.\n *\n * Handlers return void: nothing waits, and nothing they do can alter the event.\n * That is enforced by the signature rather than documented, so the question\n * \"does the TUI block on this?\" is answered by the type instead of by reading\n * the runtime. A handler needing async work owns it (`void doThing()`), which\n * keeps the fire-and-forget visible at the call site.\n *\n * There is deliberately no `tui:ready`. It existed, was typed, was documented,\n * and never fired — and the moment it is wired it is indistinguishable from\n * `tui:boot`, which already runs once registration is complete and gates the\n * terminal becoming interactive. Two hooks separated only by whether the screen\n * has painted is a distinction nothing in this API can act on.\n */\n type TuiNotifyHooks = {\n /**\n * The config was reloaded — `:reload`, or a file change.\n *\n * Fires on the NEW generation, after every registration is in place. The\n * old generation is already disposed and never sees it: its handlers went\n * with everything else it registered.\n *\n * Distinct from `tui:boot`, which also runs on a reload but gates it. Use\n * boot for setup that must finish first; use this to react to having been\n * reloaded — refreshing a cached palette, re-reading a file on disk.\n */\n \"tui:reloaded\": (payload: TuiReloadedPayload) => void\n\n /**\n * The terminal was resized.\n *\n * Fires after the new size is in effect, so `tui.size` and this payload\n * always agree. Coalesced by the underlying watcher: a drag produces the\n * sizes the terminal actually reported, not one event per column.\n */\n \"tui:resize\": (payload: TuiResizePayload) => void\n\n /**\n * Text was copied to the system clipboard.\n *\n * Fires after the copy is dispatched (OSC 52 plus the native fallback), for\n * a selection copy the user made in the terminal. Observational, like every\n * notify hook: a handler cannot alter or veto what was copied, and the\n * clipboard has already been written by the time it runs.\n *\n * It does NOT fire for an empty selection — copying nothing is not an\n * event — nor for text the user pastes, which is the opposite direction and\n * would need its own hook.\n */\n \"tui:copy\": (payload: TuiCopyPayload) => void\n\n /**\n * A key the TUI did not handle.\n *\n * ── Unhandled only, and never consumable ────────────────────────────────\n *\n * This fires at the END of dispatch — after reserved chords, after\n * `keys.register()` bindings, after mode keys. A key that did something\n * does not arrive here.\n *\n * That is not a limitation to route around; it is the only shape that can\n * be safe. User key handling is mounted as a WILDCARD, and wildcards fire\n * before exact-key handlers — so a hook able to consume a press would beat\n * every built-in binding, including the ctrl+c exit ladder. The reserved\n * list refuses those chords at registration precisely because a check at\n * press time is already too late.\n *\n * So there is no return value and no consumption: this observes, exactly\n * like every other notify hook. To OWN a key, register it —\n * `keys.register(\"ctrl+o\", ...)` — which is checked against the reserved\n * set and cannot break the terminal.\n */\n \"key:pressed\": (payload: KeyPressedPayload) => void\n\n /**\n * A palette opened.\n *\n * Narrower than `mode:changed`, and deliberately its own event: not every\n * mode is a palette. `loading` is a spinner and `voice` is a capture state,\n * and an extension gating on \"is the user picking something\" has to exclude\n * them — a derivation every consumer would otherwise write, and get wrong\n * the same way.\n */\n \"palette:opened\": (payload: PalettePayload) => void\n\n /** A palette closed. Fires for whichever palette was open. */\n \"palette:closed\": (payload: PalettePayload) => void\n\n /**\n * A command finished successfully.\n *\n * Covers built-ins and user commands alike, however they were reached —\n * `source` says which. Fires AFTER the action resolves, so an async command\n * reports when it is genuinely done rather than when it started.\n */\n \"command:ran\": (payload: CommandPayload) => void\n\n /**\n * A command threw.\n *\n * Its own event rather than a field on `command:ran`, so a handler that\n * only cares about failures does not have to filter — and so the success\n * payload never carries an error slot that is null almost always.\n */\n \"command:failed\": (payload: CommandFailedPayload) => void\n\n /** An instance finished booting. */\n \"agent:ready\": (payload: AgentPayload) => void\n /** An instance shut down. */\n \"agent:stopped\": (payload: AgentPayload) => void\n /** A different instance came on screen. */\n \"agent:focused\": (payload: AgentPayload) => void\n\n /** The user sent a message. Fires once it is delivered. */\n \"message:sent\": (payload: MessageSentPayload) => void\n /**\n * The agent finished a wake.\n *\n * Carries no content on purpose. A payload with the model's reply would\n * reopen the consumption boundary through the back door — an extension\n * reacting to WHAT was said is writing an agent, which is a cognet's job.\n * This says only THAT a wake completed.\n */\n \"message:received\": (payload: MessageReceivedPayload) => void\n\n /**\n * The active mode changed.\n *\n * The general event; `palette:opened`/`closed` are the specific ones. Use\n * this to observe every transition (including `loading` and `voice`), those\n * to react to the user opening something to pick from.\n */\n \"mode:changed\": (payload: ModeChangedPayload) => void\n }\n\n /** Every lifecycle hook, gating and notifying. */\n type TuiHooks = TuiGateHooks & TuiNotifyHooks\n\n type TuiHookName = keyof TuiHooks\n\n /**\n * A plugin file under `plugins/`.\n *\n * Plugins need no wrapper and no default export — `tui.hook(...)` at module\n * scope is the whole API, exactly as `main.ts` registers commands at module\n * scope. The file is hooks by convention rather than by ceremony, and there is\n * one way to reach every verb from every file in a profile.\n *\n * What separates a plugin from `setup()` is TIME, not capability: setup runs at\n * load, before anything is on screen, and is where registration belongs —\n * registering a command from a live hook would flicker it into a palette the\n * user is already looking at.\n *\n * A throwing handler disables its extension with a visible error. It never\n * takes the TUI down, and it is never silently swallowed.\n */\n type PluginModule = void\n\n // ── Extensions ───────────────────────────────────────────────────────────────\n\n /**\n * An extension's `extension.config.ts`.\n *\n * ── An extension is a profile, packaged ──────────────────────────────────────\n *\n * There is no `setup()`. An extension's behaviour lives in its `main.ts` and\n * its `plugins/`, registered at module scope, exactly as a user's own profile\n * does — same files, same globals, same moment. That symmetry is the point: a\n * user who has written a `main.ts` can publish it, and a reader who knows one\n * layout knows both.\n *\n * A `setup()` wrapper would have made the two differ for no gain. It exists on\n * `defineModule` because a module has data the loader must read WITHOUT\n * executing it — an options schema to validate, `emits` for typegen to merge,\n * env and policy requirements, sub-modules to flatten at manifest time. An\n * extension has none of that: its identity is package.json, and its behaviour\n * is registration.\n *\n * ── Then why does this file exist? ───────────────────────────────────────────\n *\n * It marks the directory as an extension. A kind is identified by its config\n * file (see detectKind), and `main.ts` cannot be that marker — a profile has\n * one, and so does half of npm.\n *\n * It is deliberately empty today. Keeping it means declarative, inspectable\n * per-extension data has somewhere to land later without a breaking change —\n * options schemas being the obvious candidate, if third-party configuration\n * ever needs a validated boundary rather than a user editing TypeScript.\n */\n type ExtensionConfig = {\n /**\n * Reserved. An extension declares nothing here yet — identity lives in\n * package.json and behaviour lives in main.ts.\n */\n readonly _reserved?: never\n }\n\n /** What `defineExtension()` returns. */\n type ExtensionDefinition = {\n _kind: \"extension\"\n config: ExtensionConfig\n }\n\n // ── Profile ──────────────────────────────────────────────────────────────────\n\n /**\n * One inference source, as declared in `providers`.\n *\n * What a provider factory (`Axon()`, `Ollama()`, `HuggingFace()`) returns:\n * an identity plus whatever that source needs to be reachable. Deliberately\n * NOT a model — a provider answers \"what can I supply\", and which of those\n * fills which role is resolved at boot from the running cognet's declared\n * requirements.\n *\n * Credentials are absent by design. Axon holds a user's provider connections\n * in their account vault, which is what lets a deployed agent use the same\n * connection the terminal does and why a rotated token needs nothing\n * re-entered. `key` exists for the self-hosted case — a user running their\n * own box against their own endpoint has nobody to vault it with.\n */\n type ProviderEntry = {\n /** Which source: \"axon\", \"codex\", \"openrouter\", \"ollama\", \"huggingface\". */\n provider: string\n /**\n * Direct credential, for a user supplying their own rather than\n * connecting the account. Omitted means the vault answers.\n */\n key?: string\n /** Endpoint override — self-hosted daemons and local harnesses. */\n url?: string\n /**\n * Ceiling on concurrent calls through this provider.\n *\n * Present because a cognet that fans a role out will use every slot it is\n * given, and a user who has just plugged in a metered route should be\n * able to say how much of it a brain may spend at once without editing\n * the brain.\n */\n slots?: number\n }\n\n /**\n * A ceiling on what local inference may use.\n *\n * Sizes are strings with a unit — `\"8GB\"`, `\"512MB\"` — rather than raw bytes,\n * because this is a number a person writes and reads. A bare number would be\n * ambiguous at exactly the scale that matters.\n */\n type ResourceBudget = {\n /**\n * Video memory local models may occupy, total.\n *\n * Unparseable or absent means no ceiling. Deliberately permissive: a\n * budget that failed closed would refuse every load on a machine whose\n * owner made a typo, and the honest failure for \"I could not read your\n * limit\" is to behave as though none was set rather than to stop.\n */\n vram?: string\n }\n\n /**\n * One entry in `profile.config.ts`'s `extensions`.\n *\n * `\"@axon/vim\"` resolves from the registry and installs into the profile\n * frame; `\"./extensions/sketch\"` is a local directory. The object form lets an\n * extension be disabled without deleting its line — which is what makes this\n * editable by machine, the reason the enabled set is declared here rather than\n * being the side-effect of running code.\n */\n type ExtensionEntry =\n | string\n | {\n /** Registry specifier or local path. */\n source: string\n /** Default true. False keeps the entry but does not load it. */\n enabled?: boolean\n }\n\n /**\n * A user's `profile.config.ts` — what is ENABLED, declaratively.\n *\n * Declarative rather than imperative registration calls specifically so it can\n * be edited by machine: installing an extension from Fleet or the CLI is a data\n * edit to this array, which is not possible when the enabled set is the\n * side-effect of running arbitrary code.\n *\n * Behaviour lives in `main.ts`; this file only says what loads.\n */\n /** What the timeline shows. Every field optional; defaults applied at read. */\n type VerbosityProfile = {\n /** Session lifecycle events — quiet: errors only; normal (default): + info (reloads); verbose: + plumbing. */\n session?: \"quiet\" | \"normal\" | \"verbose\"\n /** Interleave kernel:* telemetry (runs, engine calls) into the timeline. Default false. */\n kernel?: boolean\n /** Interleave cognet:* telemetry (ticks, phases, systems). Default false. */\n cognet?: boolean\n }\n\n /**\n * The platform's own settings — a CLOSED, typed set.\n *\n * Closed on purpose. These are the keys the terminal itself acts on, so each\n * one has a meaning the platform enforces: `theme` names a registered theme,\n * `paths` are scanned for agents. An open bag would make \"is this setting\n * doing anything?\" unanswerable, which is the question a settings file exists\n * to answer.\n *\n * Extension settings live OUTSIDE this, as their own top-level key on the\n * profile config (`\"@cody/vim\": { leader: \",\" }`). Two reasons: an extension's\n * settings are its own contract rather than the platform's, and keeping them\n * out means adding a platform key can never collide with one an extension\n * already chose.\n */\n type ProfileSettings = {\n /** The active theme, by the name it was registered under. */\n theme?: string\n /**\n * Which glyph set line components draw their icons from.\n *\n * ── Why this is a SETTING and not code ──────────────────────────────────\n *\n * It answers \"what does this machine's font support\", which is a property\n * of the terminal rather than of the config. A shared line should look\n * right on a laptop with a patched font and on a server without one, and\n * that cannot be true if the answer is compiled into the line.\n *\n * ── Why the default is \"auto\" ───────────────────────────────────────────\n *\n * Nerd Fonts are the de facto standard — lualine, starship, powerlevel10k\n * and oh-my-posh all assume one — so defaulting them OFF would give the\n * majority a plainer bar than they installed a patched font for.\n *\n * But a font cannot be detected from inside a terminal, so \"auto\" is a\n * heuristic, not a fact: it reads the same environment the ecosystem uses\n * (TERM_PROGRAM, and whether a font name mentions \"Nerd\"), and falls back\n * to unicode when nothing says yes. Someone seeing boxes sets \"unicode\" and\n * is done; someone seeing plain text sets \"nerd\".\n */\n icons?: IconSet\n /**\n * Extra directories scanned for agent projects, beyond\n * `profiles/<email>/agents/`. `~` expands to the home directory.\n */\n paths?: string[]\n /** What the timeline shows. */\n verbosity?: VerbosityProfile\n /**\n * Blank space around the whole terminal UI, in cells.\n *\n * Shorthand for both axes: `padding-inline`/`padding-block` override it per\n * axis when present, so `{ padding: 1, \"padding-inline\": 4 }` reads as \"one\n * row top and bottom, four columns each side\".\n *\n * ── CSS names, spelled exactly ──────────────────────────────────────────\n *\n * This config layer speaks CSS — VTerm mimics browser CSS, and users write\n * scoped CSS in their own extensions. Where CSS already has a name for a\n * thing, these settings use it verbatim rather than a near-synonym, so\n * there is nothing to translate between what you write here and what you\n * write in a stylesheet. (VTerm implements only the physical longhands\n * internally, so these are expanded to `padding-top`/`-left`/... at the\n * layout that consumes them — an implementation detail of the renderer,\n * not a reason to rename the setting.)\n */\n padding?: number\n /** Columns of blank space at the left and right edges. Overrides `padding` horizontally. */\n \"padding-inline\"?: number\n /**\n * Rows of blank space added at the top and bottom edges. Overrides\n * `padding` vertically.\n *\n * ADDED to the layout's own one-row top offset rather than replacing it, so\n * 0 (the default) is the shipped look. The status line is the bottom edge\n * and sits flush by design; this is what lifts it off.\n */\n \"padding-block\"?: number\n /** Not wired to anything yet — kept for when it is. */\n telemetry?: boolean\n }\n\n /**\n * `profile.config.ts` — the one declarative source of truth for a terminal.\n *\n * Which extensions load, how the platform is configured, and whatever those\n * extensions were configured with. Written by hand AND edited surgically by\n * the terminal (`:theme set`, `axon ext install`) — so what you see in this\n * file is always what is in effect, with no second store that can disagree.\n *\n * Extension settings are top-level keys named after the extension, siblings of\n * `settings` rather than nested inside it:\n *\n * export default defineProfile({\n * extensions: [\"@cody/vim\"],\n * settings: { theme: \"ember\" },\n * \"@cody/vim\": { leader: \",\" },\n * })\n */\n type ProfileConfig = {\n extensions?: ExtensionEntry[]\n /** Platform settings — see ProfileSettings. */\n settings?: ProfileSettings\n /**\n * The inference this user HAS — every agent on this profile inherits it.\n *\n * providers: [Axon(), Codex(), Ollama(), HuggingFace()]\n *\n * A pool, never a wiring table. The user says what they have; a cognet\n * says what it needs, by names it made up; the runtime matches them. That\n * is the whole configuration step — there is deliberately no way to say\n * \"use this model for that role\", because a role name belongs to one\n * brain's private vocabulary and typing it here would couple a user's\n * profile to the internals of whatever cognet they happen to run.\n *\n * Each entry is a CATALOGUE, not a model: it answers \"what can I supply\",\n * so the model a role ends up on is chosen at boot rather than written\n * down. That is what lets one declaration serve every agent, and what\n * lets a user with no network run any cognet whose needs their local\n * models happen to cover.\n *\n * Order is preference, applied only among candidates that all satisfy a\n * requirement — it can never make an unusable model usable.\n */\n providers?: ProviderEntry[]\n\n /**\n * What local inference may use on this machine.\n *\n * resources: { vram: \"8GB\" }\n *\n * A CEILING, not a reservation: nothing is held until a model is actually\n * loaded, and this only bounds how much may be. Absent means no ceiling —\n * local inference uses whatever the hardware has, which is the right\n * default for a machine whose owner has not said otherwise.\n *\n * Declared on the profile because that is where a user configures their\n * machine today. The BUDGET is a fact about hardware rather than about an\n * account, so the state it bounds is keyed by machine — two profiles on\n * one laptop share a GPU, and both must see the same free VRAM or both\n * will decide they have room for the same six gigabytes.\n */\n resources?: ResourceBudget\n /**\n * The machine-wide policy CEILING every agent on this profile runs under.\n *\n * A top-level key rather than a setting: `ProfileSettings` is the set the\n * TERMINAL acts on, and this is read by the runtime and enforced inside\n * the capsule. Folding it in would widen that set's meaning to \"anything\n * configurable\" and lose the boundary it draws.\n *\n * An agent narrows within this and can never widen it. Set `process.run`\n * to `false` here and no agent on the machine gets a shell, whatever its\n * own axon.config.ts says. Set a rule to `\"escalate\"` and every agent asks\n * you — an agent author cannot suppress the prompt by allowing it.\n *\n * policy: {\n * process: { run: { allow: [\"bun *\", \"git *\"] }, spawn: false },\n * network: { \"api.anthropic.com:443\": true, \"*\": \"escalate\" },\n * tools: { github: \"escalate\" },\n * }\n *\n * Silence is no opinion, never a denial: a capability neither layer\n * mentions falls through to the agent's own policy, so adding one rule\n * here cannot lock out everything else.\n */\n policy?: ProfilePolicy\n /**\n * Extension settings, keyed by the extension's own scoped name.\n *\n * Typed as unknown because the platform has no business knowing an\n * extension's shape — the extension reads and validates its own block.\n */\n [extension: `@${string}/${string}`]: unknown\n }\n\n /**\n * One capability's rule.\n *\n * `true` allows, `false` denies, `\"escalate\"` asks. The object form matches\n * the first string argument — a command, a host, a path — by glob, where `*`\n * stops at a `/` and `**` crosses it. Inside one rule the strictest matching\n * clause wins: deny, then escalate, then allow, regardless of the order they\n * are written in.\n *\n * Declared INLINE rather than imported from the policy module, because this\n * file is copied verbatim into profile type frames and a profile directory has\n * no node_modules for an import to resolve through. `tui-policy.test.ts`\n * asserts it stays structurally identical to the real `PolicyRule` — a drift\n * here means a config that typechecks and does not enforce.\n */\n type ProfilePolicyRule =\n | boolean\n | \"escalate\"\n | {\n allow?: string[]\n deny?: string[]\n escalate?: string[]\n }\n\n /**\n * The subset of a capsule policy a PROFILE may declare.\n *\n * `fs` and `limits` are OS-layer facts (bind mounts, cgroups) rather than\n * per-call verdicts, and are taken from the profile wholesale when present —\n * a ceiling a bind mount ignores is not a ceiling.\n */\n type ProfilePolicy = {\n /**\n * OS confinement tier — Linux only, a no-op elsewhere. An agent may harden\n * beyond this but never drop below it.\n */\n isolation?: \"none\" | \"auto\" | \"hardened\"\n /** Filesystem view. Enforced by the mount namespace under `auto`/`hardened`. */\n fs?: {\n read?: string[]\n write?: string[]\n }\n /** Network destinations, keyed by `host:port` glob. */\n network?: Record<string, ProfilePolicyRule>\n /** Shell access. `run` is a one-shot command, `spawn` a long-lived child. */\n process?: {\n spawn?: ProfilePolicyRule\n run?: ProfilePolicyRule\n }\n /** OS resource caps, applied to the whole process tree. */\n limits?: {\n memory?: string\n cpu?: string\n pids?: number\n }\n /** Tool namespaces, keyed by the name a tool registers under. */\n tools?: Record<string, ProfilePolicyRule>\n }\n\n /**\n * A glyph vocabulary.\n *\n * `nerd` is the full Nerd Font range — branch symbols, folder icons, the lot.\n * `unicode` is the subset present in essentially every font (▸ ● ◆), which\n * renders everywhere and reads as deliberate rather than degraded. `none`\n * drops icons entirely, for a bar that should be text and nothing else.\n */\n type IconSet = \"auto\" | \"nerd\" | \"unicode\" | \"none\"\n\n /**\n * The named icons every set provides.\n *\n * Deliberately small and semantic: a component says what its value MEANS, and\n * the set decides what that looks like. Naming them after appearance\n * (\"triangle\") would tie every component to one set's vocabulary and defeat\n * the swap.\n */\n type IconName =\n | \"agent\"\n | \"model\"\n | \"session\"\n | \"tokens\"\n | \"messages\"\n | \"modules\"\n | \"branch\"\n | \"changes\"\n | \"ahead\"\n | \"behind\"\n | \"folder\"\n | \"clock\"\n | \"user\"\n | \"warning\"\n | \"error\"\n\n /** What `defineProfile()` returns. */\n type ProfileDefinition = {\n _kind: \"profile\"\n config: ProfileConfig\n }"
package/src/tui.ts CHANGED
@@ -1805,6 +1805,61 @@ export type ExtensionDefinition = {
1805
1805
 
1806
1806
  // ── Profile ──────────────────────────────────────────────────────────────────
1807
1807
 
1808
+ /**
1809
+ * One inference source, as declared in `providers`.
1810
+ *
1811
+ * What a provider factory (`Axon()`, `Ollama()`, `HuggingFace()`) returns:
1812
+ * an identity plus whatever that source needs to be reachable. Deliberately
1813
+ * NOT a model — a provider answers "what can I supply", and which of those
1814
+ * fills which role is resolved at boot from the running cognet's declared
1815
+ * requirements.
1816
+ *
1817
+ * Credentials are absent by design. Axon holds a user's provider connections
1818
+ * in their account vault, which is what lets a deployed agent use the same
1819
+ * connection the terminal does and why a rotated token needs nothing
1820
+ * re-entered. `key` exists for the self-hosted case — a user running their
1821
+ * own box against their own endpoint has nobody to vault it with.
1822
+ */
1823
+ export type ProviderEntry = {
1824
+ /** Which source: "axon", "codex", "openrouter", "ollama", "huggingface". */
1825
+ provider: string
1826
+ /**
1827
+ * Direct credential, for a user supplying their own rather than
1828
+ * connecting the account. Omitted means the vault answers.
1829
+ */
1830
+ key?: string
1831
+ /** Endpoint override — self-hosted daemons and local harnesses. */
1832
+ url?: string
1833
+ /**
1834
+ * Ceiling on concurrent calls through this provider.
1835
+ *
1836
+ * Present because a cognet that fans a role out will use every slot it is
1837
+ * given, and a user who has just plugged in a metered route should be
1838
+ * able to say how much of it a brain may spend at once without editing
1839
+ * the brain.
1840
+ */
1841
+ slots?: number
1842
+ }
1843
+
1844
+ /**
1845
+ * A ceiling on what local inference may use.
1846
+ *
1847
+ * Sizes are strings with a unit — `"8GB"`, `"512MB"` — rather than raw bytes,
1848
+ * because this is a number a person writes and reads. A bare number would be
1849
+ * ambiguous at exactly the scale that matters.
1850
+ */
1851
+ export type ResourceBudget = {
1852
+ /**
1853
+ * Video memory local models may occupy, total.
1854
+ *
1855
+ * Unparseable or absent means no ceiling. Deliberately permissive: a
1856
+ * budget that failed closed would refuse every load on a machine whose
1857
+ * owner made a typo, and the honest failure for "I could not read your
1858
+ * limit" is to behave as though none was set rather than to stop.
1859
+ */
1860
+ vram?: string
1861
+ }
1862
+
1808
1863
  /**
1809
1864
  * One entry in `profile.config.ts`'s `extensions`.
1810
1865
  *
@@ -1946,6 +2001,46 @@ export type ProfileConfig = {
1946
2001
  extensions?: ExtensionEntry[]
1947
2002
  /** Platform settings — see ProfileSettings. */
1948
2003
  settings?: ProfileSettings
2004
+ /**
2005
+ * The inference this user HAS — every agent on this profile inherits it.
2006
+ *
2007
+ * providers: [Axon(), Codex(), Ollama(), HuggingFace()]
2008
+ *
2009
+ * A pool, never a wiring table. The user says what they have; a cognet
2010
+ * says what it needs, by names it made up; the runtime matches them. That
2011
+ * is the whole configuration step — there is deliberately no way to say
2012
+ * "use this model for that role", because a role name belongs to one
2013
+ * brain's private vocabulary and typing it here would couple a user's
2014
+ * profile to the internals of whatever cognet they happen to run.
2015
+ *
2016
+ * Each entry is a CATALOGUE, not a model: it answers "what can I supply",
2017
+ * so the model a role ends up on is chosen at boot rather than written
2018
+ * down. That is what lets one declaration serve every agent, and what
2019
+ * lets a user with no network run any cognet whose needs their local
2020
+ * models happen to cover.
2021
+ *
2022
+ * Order is preference, applied only among candidates that all satisfy a
2023
+ * requirement — it can never make an unusable model usable.
2024
+ */
2025
+ providers?: ProviderEntry[]
2026
+
2027
+ /**
2028
+ * What local inference may use on this machine.
2029
+ *
2030
+ * resources: { vram: "8GB" }
2031
+ *
2032
+ * A CEILING, not a reservation: nothing is held until a model is actually
2033
+ * loaded, and this only bounds how much may be. Absent means no ceiling —
2034
+ * local inference uses whatever the hardware has, which is the right
2035
+ * default for a machine whose owner has not said otherwise.
2036
+ *
2037
+ * Declared on the profile because that is where a user configures their
2038
+ * machine today. The BUDGET is a fact about hardware rather than about an
2039
+ * account, so the state it bounds is keyed by machine — two profiles on
2040
+ * one laptop share a GPU, and both must see the same free VRAM or both
2041
+ * will decide they have room for the same six gigabytes.
2042
+ */
2043
+ resources?: ResourceBudget
1949
2044
  /**
1950
2045
  * The machine-wide policy CEILING every agent on this profile runs under.
1951
2046
  *