English
core/runs/signin.ts
Generated from the exports of core/runs/signin.ts · npm run docs:gen
Sign-in with a program's own command line, as the standard declares it (docs/standards/runs-routes-checks.md, "Sign-in"). One executor, signin.cli, runs any tool of the closed table below in one of five shapes (flow); one check, signin { tool }, proves it. A quest pack only names a tool, a flow and the hosts its link may point at: the program, its arguments and the widest list of hosts are data written here, in code. A pack never adds a program, an argument or a host outside this table (AGENTS.md §1, closed lists). The five flows (the SDK's templates, alta new signin --template <flow>): link-code the program prints a sign-in link; the page shows it as a button that opens the player's own browser; the code the provider then shows is pasted in the page, and goes to the program's standard input as a secret (Claude Code: claude auth login). device-code the program prints a link and a short code; the page shows both; the player types the code on the provider's page; the program waits for the provider by itself (Codex login --device-auth, gh). email-link the program sends an e-mail (or shows a link) and waits; the player confirms in their own browser; the program, then the proof, see it. secret a password or a token typed in the page goes to the program's standard input (AGENTS.md §2). tool-browser the program's own flow in a Terminal window on the player's Mac (it opens that Mac's browser): local, with a screen only. Nothing here runs anything: the server (server/exec/signin-cli.mjs) reads this table, and the SDK checks packs against it. The functions at the end read a program's output (link, code, prompt, problem) and are pure.
Standards that cite this file: alta.chart/0.1: the Agent Chart · Executors, run engine, routes, checks
Exports
SIGNIN_FLOWS const
ts
const SIGNIN_FLOWS = ["link-code", "device-code", "email-link", "secret", "tool-browser"] as constSigninFlow type
ts
type SigninFlow = (typeof SIGNIN_FLOWS)[number];LINK_FLOWS const
Flows whose program prints a link the page shows: each needs its hosts.
ts
const LINK_FLOWS: readonly SigninFlow[]FLOW_NEEDS const
What each flow needs from the host (a Terminal window and a screen for the tool's own browser flow).
ts
const FLOW_NEEDS: Readonly<Record<SigninFlow, readonly Need[]>>SigninWay interface
One way a tool signs in: constant arguments, and how to read what it prints.
ts
interface SigninWay {
/** The program's arguments, constant. */
argv: readonly string[];
/** link flows: the hosts its link may point at (the widest list; a pack declares a part of it). https only. */
hosts?: readonly string[];
/** link flows: the paths its link may have (exact, or a prefix ending with "/"). */
paths?: readonly string[];
/** device-code: the shape of the short code the player types on the provider's page (anchored). */
code?: string;
/** link-code: a piece of the line that asks for the code (the program waits on its standard input). */
prompt?: string;
/** Environment variables set to a program that opens nothing, so no browser opens on the machine of the server. */
noBrowser?: readonly string[];
/** Lines the program writes about a pasted code it did not take, while it still waits: key → a piece of the line. */
problems?: Readonly<Record<string, string>>;
/** Minutes before the game stops waiting (the provider's link or code expires). */
minutes: number;
}SigninTool interface
ts
interface SigninTool {
id: string;
/** The program's name (found by the server in its PATH). */
program: string;
/** What the player signs in to ("Claude", "GitHub"). */
label: T2;
/** The program, as the player knows it ("Claude Code", "GitHub CLI"). */
product: string;
/** The flows it offers. */
ways: Partial<Record<SigninFlow, SigninWay>>;
/** The proof (check `signin { tool }`): read only, never a token, an e-mail or an account name. */
status: { argv: readonly string[]; read: "json-loggedIn" | "exit-0" };
/** The package of `pkg.install` that installs it (the card's "Install it first"). */
pkg?: string;
/**
* The tool's own command that renews its session with what it already holds: no secret typed, same account, same
* scopes (the repair `signin.refresh`). Absent: the tool renews by itself when used, or has no such command; the
* repair is then never offered. Only set once the real command was verified.
*/
refresh?: { argv: readonly string[] };
/** A practice tool for authors: its program exists only in the test sandbox (tests/fakes/bin). */
practice?: boolean;
}SIGNIN_TOOLS const
The closed table. Each row was read from the tool itself: claude Claude Code 2.1: claude auth login prints "If the browser didn't open, visit: <link>" then "Paste code here if prompted >" and reads a line on its standard input (also when it is not a terminal). It opens a browser with $BROWSER when set. Its link: https://claude.ai/oauth/authorize?… (short form) or https://claude.com/cai/oauth/authorize?…, https://platform.claude.com/oauth/authorize?… (Console). codex Codex CLI: codex login --device-auth prints https://auth.openai.com/codex/device and a one-time code (codex-rs/login/src/device_code_auth.rs); codex login --with-api-key reads a key on standard input. gh GitHub CLI 2.106: gh auth login --web without a terminal prints "First copy your one-time code: XXXX-XXXX" and "Open this URL to continue in your web browser:" and the device page of github.com; --with-token reads a token on standard input. It opens a browser with $GH_BROWSER, else $BROWSER. practice alta-signin-practice: every flow, for authors and tests; only in the test sandbox.
ts
const SIGNIN_TOOLS: readonly SigninTool[]SIGNIN_TOOL_IDS const
ts
const SIGNIN_TOOL_IDS: readonly string[]signinTool const
ts
const signinTool = (id: unknown) => …signinWay const
ts
const signinWay = (tool: unknown, flow: unknown): SigninWay | undefined => …defaultFlow function
The flow a tool uses when a step names none: the first link flow it has, else its first flow.
ts
function defaultFlow(tool: unknown): SigninFlow | undefinedHOSTS_PATTERN const
The hosts argument of a step: a comma list of host names (no scheme, no port, no path).
ts
const HOSTS_PATTERN = "^[a-z0-9.-]{3,253}(,[a-z0-9.-]{3,253}){0,7}$"splitHosts const
ts
const splitHosts = (v: unknown): string[] => …signinArgsProblems function
The problems of a step's signin.cli arguments against the table (beyond the executor table's own rules): a known tool, a flow it offers, hosts that are its own, hosts only for a flow that shows a link. Each problem starts with a word the SDK maps to its rule (tool, flow, hosts).
ts
function signinArgsProblems(args: Record<string, unknown>): string[]plainText const
A program's output without terminal escapes (colours, OSC 8 links, cursor moves) and control characters.
ts
const plainText = (s: string) => …findLink function
The first link of text (escapes already removed) that is allowed: https, no user or port, a host of hosts, a path of paths (exact, or under a prefix ending with "/"), 4096 characters at most, only URL characters. Anything else is never shown to the player.
ts
function findLink(text: string, hosts: readonly string[], paths: readonly string[] = []): string | nullisAllowedLink function
ts
function isAllowedLink(raw: string, hosts: readonly string[], paths: readonly string[] = []): booleanfindDeviceCode function
The device code of text: the first word that has the tool's shape.
ts
function findDeviceCode(text: string, pattern: string): string | nullcodeProblem function
The key of a problem line about a pasted code (the program still waits), or null.
ts
function codeProblem(line: string, problems: Readonly<Record<string, string>> = {}): string | null