# `core/runs/inputs.ts`

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

What a step asks the player before its executor runs (alta.game/0.3, `Step.inputs`), and how the answers become the executor's arguments. Pure functions shared by the client, the server and the SDK; they never run anything. Secrets (AGENTS.md §2): a `secret` input has no default, no prefill, is never saved and never becomes an argument. `resolveArgs` leaves it out of `args` and only says which parameter it feeds (`secretParams`): the page sends the value once, in the body of the agreement, and the server hands it to the program by standard input. Nothing here reads a secret's value beyond its length, and no problem message ever repeats a value.

**Standards that cite this file**: [alta.chart/0.1: the Agent Chart](https://docs.altasystem.ai/reference/advanced/specs/alta-chart-0.1) · [alta.game/0.3: steps that act, ask and say why](https://docs.altasystem.ai/reference/advanced/specs/alta-game-0.3) · [Executors, run engine, routes, checks](https://docs.altasystem.ai/reference/advanced/specs/runs-routes-checks)

## Exports

### `INPUT_KINDS` 
```ts
const INPUT_KINDS = ["text", "choice", "email", "path", "number", "boolean", "secret"] as const
```

### `InputKind` 
```ts
type InputKind = (typeof INPUT_KINDS)[number];
```

### `PlainInput` 
A field the player fills in; its value may be prefilled (`from`) and kept (`saves`).

```ts
interface PlainInput extends InputBase {
  kind: Exclude<InputKind, "secret">;
  default?: string | number | boolean;
  /** Prefill from an answer already given: "answers.<key of Save.answers>". */
  from?: string;
  /** Keep the value in Save.answers under this key ("answers.<key>"). */
  saves?: string;
  /** kind choice: the same shape as Step.choices. */
  choices?: Choice[];
  /** text: longest length (default 200, at most 2000); number: highest value. */
  max?: number;
  /** text: shortest length; number: lowest value. */
  min?: number;
  /** text: an anchored pattern (`^…$`), 200 characters at most. */
  pattern?: string;
  /** path: what must be there. */
  must?: "exist" | "dir" | "file";
  /** text: values refused although they fit (names kept for something else), and why, said under the field. */
  not?: NotList;
}
```

### `NotList` 
Values a text input refuses, compared without case, and the sentence the field says when one is typed.

```ts
interface NotList { values: string[]; why: Text }
```

### `SecretInput` 
A password, token, key or one-time code: a password field, never prefilled, never kept, never echoed.

```ts
interface SecretInput extends InputBase {
  kind: "secret";
  default?: never; from?: never; saves?: never; pattern?: never; choices?: never; must?: never; max?: never; min?: never; not?: never;
}
```

### `Input` 
```ts
type Input = PlainInput | SecretInput;
```

### `ArgValue` 
A value of `run.args`: a literal, the value of one of the step's inputs, or an answer already given.

```ts
type ArgValue = string | number | boolean | { input: string } | { answer: string };
```

### `INPUT_ID` 
```ts
const INPUT_ID = /^[a-z][a-z0-9-]{0,31}$/
```

### `ANSWER_REF` 
A key of Save.answers, as an input's `from`/`saves` and an `{answer}` reference write it.

```ts
const ANSWER_REF = /^answers\.[a-z0-9][a-z0-9.\-_/@]{0,119}$/
```

### `TEXT_MAX` 
```ts
const TEXT_MAX = 200
```

### `TEXT_CAP` 
```ts
const TEXT_CAP = 2000
```

### `SECRET_MAX` 
```ts
const SECRET_MAX = 4096
```

### `EMAIL_MAX` 
```ts
const EMAIL_MAX = 254
```

### `NOT_MAX` 
At most this many refused values (`not.values`), each at most TEXT_CAP characters.

```ts
const NOT_MAX = 64
```

### `NOT_PROBLEM` 
The core's words for a refused value (the page says the input's `not.why` instead).

```ts
const NOT_PROBLEM = "is kept for something else"
```

### `SECRETISH` 
A value that looks like a credential: the install script's detector (core/install/alta-os.ts), plus common token prefixes.

```ts
const SECRETISH = /(\bsk-[a-z0-9]|api[_-]?key|password|token=|secret=|\bghp_|\bxox[bp]-|-----BEGIN)/i
```

### `looksSecret` 
```ts
const looksSecret = (v: unknown) => …
```

### `isInputRef` 
```ts
const isInputRef = (v: unknown): v is { input: string } => …
```

### `isAnswerRef` 
```ts
const isAnswerRef = (v: unknown): v is { answer: string } => …
```

### `safePattern` 
An anchored pattern of 200 characters at most that compiles (else undefined).

```ts
function safePattern(p: string | undefined): RegExp | undefined
```

### `pathProblems` 
Problems of a path as typed: under `~/` or `/Volumes/`, no `..`. The server resolves it and checks `must`.

```ts
function pathProblems(v: unknown, what = "value"): string[]
```

### `inputProblems` 
Problems of the value given to one input (empty = acceptable). Never repeats the value.

```ts
function inputProblems(input: Input, value: unknown): string[]
```

### `paramProblems` 
Problems of the arguments given to an executor (its declared `args`; none when it declares no list). References
(`{input}`, `{answer}`) are accepted here as placeholders: `checkGame` checks them against the step's inputs, and
the server gets plain values from `resolveArgs`. A string that looks like a credential is refused everywhere.

```ts
function paramProblems(id: string, args: Record<string, unknown> | undefined): string[]
```

### `answerOf` 
The answer a reference ("answers.&lt;key&gt;") names. Save.answers keeps an answer under its whole key, as a choice step's
`saves` writes it ("answers.brief.time"); a key written without the prefix ("brief.time") is read too.

```ts
function answerOf(answers: Record<string, string>, ref: string): string | undefined
```

### `prefill` 
The value an input starts with: its `from` answer if given, else its default. Never for a secret.

```ts
function prefill(input: Input, answers: Record<string, string> = {}): string | number | boolean | undefined
```

### `Resolved` 
```ts
interface Resolved {
  /** Plain values for `POST /api/runs/plan`: never a secret. */
  args: Record<string, string | number | boolean>;
  /** The secret inputs the agreement must carry (`POST /api/runs/run`, body `secrets`). */
  secretIds: string[];
  /** Which parameter each secret input feeds (parameter → input id). */
  secretParams: Record<string, string>;
  /** Values to keep in Save.answers (inputs with `saves`): key without "answers." → value. Never a secret. */
  saves: Record<string, string>;
  problems: string[];
}
```

### `resolveArgs` 
Replaces the references of a step's `run.args` (for this system) by the values typed in its form (`values`, by
input id) and the answers already given. A secret input is never read and never put in `args`.

```ts
function resolveArgs(step: Pick### 
, os: OS, values: Record<string, unknown>, answers: Record<string, string> = {}): Resolved
```
