# `core/runs/card.ts`

<p class="generated-note">Generated from the exports of <a href="https://github.com/altasystem-ai/alta/blob/main/core/runs/card.ts"><code>core/runs/card.ts</code></a> · <code>npm run docs:gen</code></p>

The plan card an executor's `plan` returns (POST /api/runs/plan → `card`), as the page reads it, and the words of a run's report lines. The server's executors (server/exec/*.mjs) build the card; the quest panel (client/quests/rail.ts, &lt;alta-plan-card&gt;) draws it the same way for every executor. Nothing here runs anything. What the player sees first: the title, the short list of what gets installed or changed (`items`: a name and a few words each), and two chips (`duration`, `size`). The long `body`, the exact `command`, `writes` and the undo are folded under "Details". An executor without `items` falls back to its `writes`.

**Standards that cite this file**: [Executors, run engine, routes, checks](https://docs.altasystem.ai/reference/advanced/specs/runs-routes-checks)

## Exports

### `CardText` 
A text of a card: one string (English, or a name the same in every language), or `{ en, fr }`.

```ts
type CardText = string | { en: string; fr?: string; [lang: string]: string | undefined };
```

### `CardItem` 
One thing the run installs or changes, in the player's words: "Postgres" / "where the memory lives".

```ts
interface CardItem {
  /** What it is: a program, a setting, a folder (one to four words). */
  name: CardText;
  /** Why, in two to five words. */
  what?: CardText;
  /** Already there: the run only checks it (shown ticked). */
  done?: boolean;
}
```

### `PlanCard` 
```ts
interface PlanCard {
  /** What happens, in one line (the card's head). */
  title?: CardText;
  /** The same in English, for the logs (never shown before `title`). */
  summary?: string;
  /** What happens, in a few sentences: folded under "Details" when `items` says it. */
  body?: CardText;
  /** The short list of what is installed or changed (at most 12 shown). */
  items?: CardItem[];
  /** How long it takes, roughly ("5 to 20 min"): a chip. */
  duration?: CardText;
  /** What it downloads, roughly ("about 1 GB"): a chip. */
  size?: CardText;
  /** The exact command (under "Details"). */
  command?: string;
  /** What it writes on the machine, one line each (under "Details"; the list when there are no `items`). */
  writes?: CardText[];
  /** It cannot run now, and why. */
  blocked?: CardText;
  /** It is already done: the run only checks. */
  already?: CardText | boolean;
  /** The executor reports a percentage while it runs. */
  progress?: boolean;
  undo?: { how: "auto" | "command" | "archive" | "none"; command?: string; text?: CardText };
  missing?: { pkg?: string; workflow?: string; executor?: string; args?: Record<string, string>; text?: CardText };
  capture?: { kind: "audio"; required?: boolean; maxSeconds?: number };
  read?: string | null;
  /** The ways it can run, the first being the default: "page" (here), "terminal" (a Terminal window on this Mac). */
  ways?: string[];
  /** The command a Terminal window would run (the other way), under "Details". */
  terminalCommand?: string;
  /** A sign-in (signin.cli): the tool, its flow, its names and the hosts its link may point at. */
  signin?: { tool: string; flow: string; label: CardText; product: string; hosts: string[] };
}
```

### `SigninLive` 
What a sign-in run going shows the player (the run view's `live`, server/exec/signin-cli.mjs): its phase, the link
(already checked by the server against the step's hosts), a device code to type on the provider's page, and the
key of a problem with a pasted code.

```ts
interface SigninLive {
  flow: string;
  phase: "starting" | "link" | "code" | "checking" | "device" | "email";
  label?: CardText; product?: string;
  url?: string; host?: string; code?: string; problem?: string;
}
```

### `cardText` 
A card's text in a language (English when that language is not written).

```ts
function cardText(x: CardText | undefined | null, lang: string): string
```

### `cardItems` 
What the card lists first: its `items`, else one item per line of `writes`.

```ts
function cardItems(card: PlanCard): CardItem[]
```

### `LineMark` 
The status of a report line: done, a warning, failed, or a plain line.

```ts
type LineMark = "ok" | "warn" | "fail" | "todo" | "note";
```

### `ReportLine` 
One line of a run's report, in words: its mark and its text without the engine's code ("OK  R10 x  the model answers").

```ts
interface ReportLine { mark: LineMark; text: string }
```

### `reportLine` 
A report line of the Alta install engine (`<KIND> <where> <text>`, where = a sub-step id and a short name, padded
with spaces) or of Homebrew (`==> …`, `Error: …`), in words: the code prefix stripped, the first letter up. Any
other line is kept as it is.

```ts
function reportLine(raw: string): ReportLine
```

### `RunReport` 
A finished run as the page reads it: its result and its log.

```ts
interface RunReport {
  result?: { error?: string; fails?: { text?: string }[]; steps?: { kind?: string; text?: string }[] } | null;
  log?: { msg: string }[];
}
```

### `failReasons` 
What stopped a run, in its own words (English, as the program gave it): the Alta install engine's FAIL lines
(`result.fails`, else its FAIL report lines: `engine` true, running the same command again would stop the same way),
else the FAIL lines of the run's log and of its error (the base installer's "FAIL Only 17 GB free…"), colours and
codes stripped, each once.

```ts
function failReasons(run: RunReport | null | undefined): { reasons: string[]; engine: boolean }
```

### `Reason` 
A known reason a program gives (in English), as the key of a sentence the page says in the player's language
(`run.why.<key>` in content/copy/&lt;lang&gt;/runs.json) and its values. The raw words stay under "Details". Unknown
words give null: the page says them as they are in English, or a plain sentence in another language.

```ts
interface Reason { key: string; vars?: Record<string, string> }
```

### `knownReason` 
```ts
function knownReason(text: string): Reason | null
```

### `Activity` 
What a run is doing, read from a line of its log while it runs. A line of a run still going is never said as a
reason it stopped (knownReason is for failures only). The key of a phrase in the player's language
(`run.doing.<key>`, `run.doing.<key>.pct` when the program gave its own percentage), and that percentage. Unknown
lines give null.
  model     the local model downloading: the engine's "downloading qwen3:4b in the background", "waiting for … to
            finish downloading", "downloading the local model qwen3:4b: 45%", or `ollama pull`'s own lines
  download  anything else downloading ("==&gt; Downloading …", "Pulling …")

```ts
interface Activity { key: string; pct?: number }
```

### `knownActivity` 
```ts
function knownActivity(text: string): Activity | null
```
