# `core/onboarding/onboarding.ts`

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

The onboarding standard (alta.onboarding/0.2, reads 0.1): a guided chain of beats, played like a video game's tutorial. Each world can ship its own file (universes/&lt;id&gt;/onboarding.json); content/onboarding.json is the neutral fallback. A beat is one of: - say: the narrator speaks (one or more lines), the player continues. - quest: a quest of the Alta Quest Standard, played inside the guide. `auto` names a proof the game holds by itself ("app-open": this app running proves the install quests on a Mac; "hosted": a hosted world proves its arrival quest), and the quest completes on its own, step after step. `steps` gives the narrator a line per step and can ask for an input in place. - tour: the camera walks the player to things in the world while the narrator presents them; each stop can tick a step of a quest. The last played beat may name a quest to `track` once the guide ends. `cutscenes` (by quest uid) play when a quest completes, inside the guide or later (0.1; in 0.2 scenes live in alta.cinematics, see core/cinematics). 0.2 adds (PLAN-V2 §2.2): a step can show a setup plan card (`setup`) and play a scene (`cutscene`); a beat can move on once its run has started (`wait: "started"`); the proof "hosted". 0.2 also adds (ONBOARDING-V2 §4.4) a `host` condition on a beat and on a tour stop: where it is played (local, hosted, hosted-free, hosted-paid). An `auto` beat implies its host (app-open = local, hosted = hosted). The marketing axis is a file variant (onboarding.&lt;axis&gt;.json, see onboardingFor); a host mode is never a variant name.

**Standards that cite this file**: [alta.onboarding/0.2: the guide](https://docs.altasystem.ai/reference/advanced/specs/alta-onboarding-0.2)

## Exports

### `OnbStep` 
```ts
interface OnbStep {
  say?: Text; sayDone?: Text; input?: { saves: string; placeholder?: Text; ask?: Text };
  /** Id of an element of /api/setup: the step shows its plan card. */
  setup?: string;
  /** Id of a scene (cinematics.scenes) played on this step. */
  cutscene?: string;
}
```

### `OnbStop` 
```ts
interface OnbStop { walk: string; say: Text; tick?: string; /** Where this stop is played (0.2). */ host?: HostCond }
```

### `Beat` 
```ts
interface Beat {
  id: string;
  kind: "say" | "quest" | "tour";
  say?: Text | Text[];
  quest?: string;
  auto?: "app-open" | "hosted";
  steps?: Record<string, OnbStep>;
  stops?: OnbStop[];
  /** Line said once the quest of this beat is done. */
  done?: Text;
  track?: string;
  /** "started": the guide moves on as soon as the run is started (0.2). */
  wait?: "done" | "started";
  /** Where this beat is played (0.2). Absent: everywhere, or the host its `auto` implies. */
  host?: HostCond;
}
```

### `Cutscene` 
A short video played when a quest completes (in the guide or later). Skipping it shows its recap as text,
 so the player always learns what was just done and why it matters. Without a video, the recap plays as a
 narrated card.

```ts
interface Cutscene { video?: string; title: Text; recap: Text[] }
```

### `Onboarding` 
```ts
interface Onboarding { schema: "alta.onboarding/0.1" | "alta.onboarding/0.2"; narrator: string; beats: Beat[]; cutscenes?: Record<string, Cutscene> }
```

### `AUTO_PROOFS` 
```ts
const AUTO_PROOFS = new Set(["app-open", "hosted"])
```

### `HOST_VARIANT_NAMES` 
Names a variant can never take: the host mode is a condition inside the file, not a file of its own.

```ts
const HOST_VARIANT_NAMES: readonly string[]
```

### `beatHost` 
The host a beat is played on: its own `host`, else the one its `auto` proof implies, else everywhere.

```ts
function beatHost(b: Beat): HostCond | undefined
```

### `beatsFor` 
The beats this host plays, in file order.

```ts
function beatsFor(o: Onboarding, host: Host | undefined): Beat[]
```

### `stopsFor` 
The stops of a tour this host plays.

```ts
function stopsFor(b: Beat, host: Host | undefined): OnbStop[]
```

### `resumeAt` 
Where the guide resumes on this host: the saved beat if it is played here, else the first played beat after it in
the file (null: the guide ends). An unknown or absent beat resumes at the first played beat.

```ts
function resumeAt(o: Onboarding, at: string | undefined, host: Host | undefined): Beat | null
```

### `variantOk` 
Is this a variant name a file may carry? (A host mode never is.)

```ts
const variantOk = (v: string | null | undefined): v is string => …
```

### `onboardingFor` 
The file to play: the first that exists, in this order (GAPS G01, PLAN-V4 §3). Pure.
  universes/&lt;u&gt;/onboarding.&lt;v&gt;.json → universes/&lt;u&gt;/onboarding.json → content/onboarding.&lt;v&gt;.json → content/onboarding.json
A variant named after a host mode is ignored.

```ts
function onboardingFor(files: Record<string, unknown>, universe: string, variant?: string | null): { path: string; onboarding: unknown } | null
```

### `checkOnboarding` 
Problems of an onboarding file, against the quests of the game (and the scene ids of the cinematics, when known).
Empty when it can be played. The 0.2 fields are refused in a 0.1 file. With `opts.game`, every beat played on a
reference host must name a quest that host can play; with `opts.variant`, the name of the file's variant.

```ts
function checkOnboarding(o: any, questUids: Set<string>, sceneIds?: Set<string>, opts: { game?: Game; variant?: string } = {}): string[]
```

### `guideProofs` 
Quests proven by the guide itself: the `auto` quests of the beats this host plays that the player has already
reached (or all of them, once the guide is done).

```ts
function guideProofs(o: Onboarding, at: string | undefined, done: boolean, host?: Host): string[]
```
