English
core/runs/inputs.ts
Generated from the exports of core/runs/inputs.ts · npm run docs:gen
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 · alta.game/0.3: steps that act, ask and say why · Executors, run engine, routes, checks
Exports
INPUT_KINDS const
ts
const INPUT_KINDS = ["text", "choice", "email", "path", "number", "boolean", "secret"] as constInputKind type
ts
type InputKind = (typeof INPUT_KINDS)[number];PlainInput interface
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 interface
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 interface
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 type
ts
type Input = PlainInput | SecretInput;ArgValue type
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 const
ts
const INPUT_ID = /^[a-z][a-z0-9-]{0,31}$/ANSWER_REF const
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 const
ts
const TEXT_MAX = 200TEXT_CAP const
ts
const TEXT_CAP = 2000SECRET_MAX const
ts
const SECRET_MAX = 4096EMAIL_MAX const
ts
const EMAIL_MAX = 254NOT_MAX const
At most this many refused values (not.values), each at most TEXT_CAP characters.
ts
const NOT_MAX = 64NOT_PROBLEM const
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 const
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)/ilooksSecret const
ts
const looksSecret = (v: unknown) => …isInputRef const
ts
const isInputRef = (v: unknown): v is { input: string } => …isAnswerRef const
ts
const isAnswerRef = (v: unknown): v is { answer: string } => …safePattern function
An anchored pattern of 200 characters at most that compiles (else undefined).
ts
function safePattern(p: string | undefined): RegExp | undefinedpathProblems function
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 function
Problems of the value given to one input (empty = acceptable). Never repeats the value.
ts
function inputProblems(input: Input, value: unknown): string[]paramProblems function
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 function
The answer a reference ("answers.<key>") 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 | undefinedprefill function
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 | undefinedResolved interface
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 function
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<Step, "run" | "inputs">, os: OS, values: Record<string, unknown>, answers: Record<string, string> = {}): Resolved