English
core/quests/standard.ts
Generated from the exports of core/quests/standard.ts · npm run docs:gen
Quests in the Alta Quest Standard (schema alta.game/0.3, reads 0.1 and 0.2): branches > acts > quests > steps, skills, read-only checks, quest types with their life cycles (campaign, instant, daily, repeatable, repair, system, personal). 0.3 adds what a step asks before it acts (inputs, core/runs/inputs.ts), references in run.args, why a step stays with the player (human) and a step proven by a later one (provenBy). Every 0.3 field is optional, so a 0.2 file evaluates the same; checkGame refuses the 0.3 fields in a file that declares 0.1 or 0.2. This module computes, from the check results, the world, the clock and the game's save, what is done, what is next and how much xp and which skills the owner has. It never runs anything: checks are run by the server, read-only; entity, world, mission and item checks are resolved here from what the client already holds. The clock is injected (Context.now, Context.tzOffsetMin): every test can play days and weeks in a few lines. The xp of non-campaign quests lives only in Save.log, written by record() and turnIn() (pure functions that return a new save): evaluate() stays a pure reading of the state.
Standards that cite this file: alta.game/0.2: quests, types and cycles · alta.game/0.3: steps that act, ask and say why · Resources: what a step, a choice or an executor needs of the machine · Executors, run engine, routes, checks
Exports
export … re-export
ts
export type { ArgValue, Input, InputKind } from "../runs/inputs";export … re-export
ts
export type { OS } from "../platform/platform";Lang type
ts
type Lang = "en" | "fr";Text type
ts
type Text = Partial<Record<Lang, string>> | null | undefined;QuestType type
ts
type QuestType = "campaign" | "daily" | "repeatable" | "instant" | "repair" | "system" | "personal";QUEST_TYPES const
ts
const QUEST_TYPES: readonly QuestType[]Reset interface
Reset of a daily quest: local time, no streak, no penalty.
ts
interface Reset { every: "day" | "week"; at?: string /* "HH:MM", default "04:00" */; weekday?: 1 | 2 | 3 | 4 | 5 | 6 | 7 }Repeat interface
Repeatable: turned in as often as wanted, with an optional cooldown and cap.
ts
interface Repeat { cooldownS?: number; max?: number }Origin interface
Where a quest that is not written in a branch comes from.
ts
interface Origin { kind: "item" | "entity" | "probe" | "task"; ref: string; since?: string /* ISO */ }MissionSpec interface
Sending an agent: who goes, with which instructions, towards what on the map.
ts
interface MissionSpec {
agent?: string; // default: the giver; "daemon" becomes "main" on the server
brief: Text; // prefilled instructions
editable?: boolean; // default true
target?: string; // entity id the orb goes to; default QuestDef.target, else the edge of the world
}RunSpec interface
An executor of the closed list and its arguments: literals, or (0.3) { input } and { answer } references.
ts
interface RunSpec { do: string; args?: Record<string, ArgValue> }Check interface
ts
interface Check { type: string; [k: string]: unknown }HUMAN_REASONS const
Why a step stays with the player (0.3, required on a manual step).
ts
const HUMAN_REASONS = ["speak", "approve", "device", "external", "judge", "before"] as constHumanReason type
ts
type HumanReason = (typeof HUMAN_REASONS)[number];PERMISSIONS const
Permissions of the OpenClaw app on this Mac a permission check reads.
ts
const PERMISSIONS = ["microphone", "speech", "accessibility", "screen", "notifications", "camera", "location"] as constACCOUNT_SCOPES const
Accounts an account check reads, and the scopes it can ask for.
ts
const ACCOUNT_SCOPES: Readonly<Record<string, readonly string[]>>CHANNEL_STATES const
ts
const CHANNEL_STATES = ["configured", "paired"] as constBIN_NAME const
A program name of a bin check (found by the server's lib/bins.mjs).
ts
const BIN_NAME = /^[a-z0-9][a-z0-9._+-]{0,63}$/INSTALL_PARTS const
The parts of the Alta install a part check reads (engine/STEPS.md; the executors' ALTA_PARTS).
ts
const INSTALL_PARTS = ["machine", "mind", "memory", "agents", "map", "modules"] as constMINDS const
The minds a Daemon can think with, as checks and executors name them.
ts
const MINDS = ["claude", "codex", "local"] as constMind type
ts
type Mind = (typeof MINDS)[number];SIGNIN_MINDS const
Minds signed in through their own command line tool (signin check, llm.signin executor).
ts
const SIGNIN_MINDS: readonly Mind[]CHECK_TYPE_IDS const
Every check type a step may name: the core's own (answer, entity, world, mission, seen, item, host) and the server's table (server/checks/index.mjs, tested equal), plus probe (the system's measures) and script (bridged to another type). An unknown type would never be proven: checkGame refuses it (rule check.type).
ts
const CHECK_TYPE_IDS = [ "answer", "entity", "world", "mission", "seen", "item", "host", "identity", "module", "automation", "config", "file", …SEEN_KEY const
A scene key of seen: "trailer" (the trailer of any world), or a key the game saves ("intro:core.wake").
ts
const SEEN_KEY = /^(trailer|[a-z]{1,16}:[a-z0-9.\-_]{1,80})$/isSceneKey const
A seen key that names a scene the player watches or skips ("trailer", "trailer:<world>", "intro:<uid>", "outro:<uid>", "scene:<id>"). Any other key ("heard:…", "played:…", "read:…", "ran:…", "asked:…", "tour:…") is marked by the game itself when the step's own action succeeded: its run, its message to the agent, or the guide's stop that visits it.
ts
const isSceneKey = (key: string) => …Choice interface
One answer of a choice step (0.2 adds host, off, resources, hint, recommended; none of them changes the evaluation).
ts
interface Choice {
id: string; label: Text;
/** Shown only there. */
host?: HostCond;
/** Shown there but cannot be picked, with the reason said to the player. */
off?: { host: HostCond; why: Text };
/**
* What it needs of the machine (core/platform/resources.ts): greyed where the server measured less, with the reason
* that names what is missing. A resource not measured is never refused. `off` comes first when both hold.
*/
resources?: Resources;
/** One sentence under the label: what this choice promises. */
hint?: Text;
/** Shown with a "Recommended" tag. */
recommended?: boolean;
}Step interface
ts
interface Step {
id: string;
/** The kinds of the standard, or a kind drawn by a client feature (registerStepKind); unknown, it renders as "action". */
kind: "manual" | "choice" | "check" | "action" | "command" | "link" | "mission" | (string & {});
title: Text;
hint?: Text;
os?: OS[] | null;
arch?: Arch[] | null;
/** Where this step exists (0.2): hidden elsewhere, like a step of another system. */
host?: HostCond | null;
optional?: boolean;
check?: Check | null;
choices?: Choice[] | null;
saves?: string | null;
cmd?: PerOS<string> | null;
open?: PerOS<string> | null;
ask?: Text;
when?: { answer: string; equals: string } | null;
agent?: string | null;
mission?: MissionSpec | null;
/** An action of the closed list of executors; never run without a plan card (unless it changes nothing). */
run?: PerOS<RunSpec> | null;
/** 0.3: what the step asks the player before its `run` (a form in the plan card). */
inputs?: Input[] | null;
/**
* What it needs of the machine, with those of the executor it runs (core/platform/resources.ts): where the server
* measured less, the step says what is missing instead of its "Do it". Never hides it, never proves it.
*/
resources?: Resources | null;
/** 0.3: why only the player can do this step. Required on a manual step. */
human?: HumanReason | null;
/** 0.3: the id of another step of the same quest whose proof proves this one too. */
provenBy?: string | null;
}QuestDef interface
ts
interface QuestDef {
id: string;
uid: string;
act: number;
giver: string;
main?: boolean;
title: Text;
summary?: Text;
quote?: Text;
why?: Text;
ask?: Text;
requires?: string[] | null;
level?: number;
reward: { xp: number; skills?: string[] };
steps: Step[];
type?: QuestType; // absent = "campaign"
reset?: Reset; // required for daily
repeat?: Repeat; // allowed for repeatable
origin?: Origin; // required for repair and personal
target?: string; // linked entity id
expires?: string; // ISO
support?: Support;
}Skill interface
ts
interface Skill { id: string; title: Text; desc?: Text; agent?: string; after?: string; place?: { angle: number; radius: number } }Act interface
ts
interface Act { id: number; title: Text; sub?: Text; level?: number; /** An unavailable quest of an optional act does not block. */ optional?: boolean }Branch interface
ts
interface Branch {
id: string; version: string; price?: string; requires?: string[]; title: Text; summary?: Text; why?: Text;
planned?: { quests: number; skills: number } | null; constellation?: { color?: number[] } | null;
acts: Act[]; skills: Skill[]; quests: QuestDef[];
item?: string;
generated?: boolean; // reserved ids: "_repair", "_system", "_personal"
support?: Support;
}Game interface
ts
interface Game { schema: "alta.game/0.1" | "alta.game/0.2" | "alta.game/0.3" | string; langs: Lang[]; branches: Branch[] }QuestFragment interface
Quests added to an existing branch (content/quests/*.json, or a store item).
ts
interface QuestFragment { schema: "alta.quests/0.2" | "alta.quests/0.3"; branch: string; acts?: Act[]; skills?: Skill[]; quests: QuestDef[] }GAME_SCHEMAS const
ts
const GAME_SCHEMAS = ["alta.game/0.1", "alta.game/0.2", "alta.game/0.3"] as constFRAGMENT_SCHEMAS const
ts
const FRAGMENT_SCHEMAS = ["alta.quests/0.2", "alta.quests/0.3"] as constversionOf const
The version a game or fragment file declares, as a number (0.1, 0.2, 0.3), or 0 when unknown.
ts
const versionOf = (schema: unknown): number => …CheckResult interface
Result of one check, as the server returns it. Never carries a value read from the machine.
ts
interface CheckResult {
status: "pass" | "fail" | "unverifiable"; detail: string;
/** Why it fails, as a word the game can say to the player in their language ("not-installed": the program is missing). */
reason?: "not-installed";
}LogEntry interface
ts
interface LogEntry { n: number; xp: number; last: string; period?: string }Save interface
ts
interface Save {
v?: 2;
/** Key "uid/step", or "uid@period/step" for daily and repeatable quests. */
ticked?: Record<string, true>;
answers?: Record<string, string>;
/** What was accomplished: the only source of xp for non-campaign quests. */
log?: Record<string, LogEntry>;
/** Repair incidents, by entity id (or origin ref). */
incidents?: Record<string, { since: string; doneAt?: string }>;
tasks?: { id: string; title: string; done?: boolean; at: string }[];
/** Cutscenes and trailers already seen ("trailer:<universe>", "intro:<uid>"). */
seen?: Record<string, true>;
}Context interface
ts
interface Context {
game: Game;
os: OS;
checks: Record<string, CheckResult>;
provenQuests: Record<string, string>;
save: Save;
now?: number;
/** Local time minus UTC, in minutes (Paris in winter: 60). Default: the runtime's. */
tzOffsetMin?: number;
world?: WorldState;
/** Missions by step key, in the current period. */
missions?: Record<string, "out" | "ok" | "failed">;
items?: Record<string, "installed" | "disabled" | "archived">;
host?: Host;
}StepStatus type
ts
type StepStatus = "done" | "declared" | "open" | "failing";StepView interface
ts
interface StepView {
step: Step; key: string; status: StepStatus; check?: CheckResult; answer?: string;
/** A step not done yet that this machine is too small for: the reason, naming what is missing (`resources`). */
short?: Text;
}QuestStatus type
ts
type QuestStatus = "locked" | "open" | "active" | "done" | "cooldown" | "unavailable";QuestView interface
ts
interface QuestView {
quest: QuestDef;
branch: Branch;
status: QuestStatus;
steps: StepView[];
done: number;
total: number;
missing: string[];
proven?: string;
xp: number;
type: QuestType;
/** Current period key (daily: the day or week; repeatable: the round). */
period?: string;
/** When the daily quest resets, or the cooldown ends (ms). */
resetsAt?: number;
/** How many times it was accomplished (log). */
count: number;
/** A campaign quest done once whose proof fell back: xp kept, to redo. */
reopened?: boolean;
/** A repeatable quest whose steps are all done: it can be turned in. */
ready?: boolean;
/** Why the quest cannot be played on this host. */
unavailable?: { reason: string; detail: string };
}LEVELS const
ts
const LEVELS = [0, 180, 420, 750, 1150, 1600, 2100, 2700, 3400]STEP_XP const
ts
const STEP_XP = 10XP const
Constants of the life cycles (PLAN-V2 §2.1).
ts
const XP = { repair: 40, system: 20, personal: 5, personalPerDay: 25, repeatableMax: 30, instantMin: 10, instantMax: 30, dailyPerBranch: 60, } as constINCIDENT_MERGE_MS const
A new incident on the same entity within this time is the same incident (no second xp).
ts
const INCIDENT_MERGE_MS = 24 * 3600 * 1000CORE_CHECKS const
Checks resolved by the core from what the client holds; the server never runs them.
ts
const CORE_CHECKS = new Set(["answer", "entity", "world", "mission", "item", "seen", "host"])t const
ts
const t = (x: Text, lang: Lang): string => …typeOf const
ts
const typeOf = (q: QuestDef): QuestType => …checkKey function
A stable key for a check: the same check in two steps is run once.
ts
function checkKey(c: Check): stringstepKey function
ts
function stepKey(q: QuestDef, s: Step, period?: string)nowOf const
ts
const nowOf = (ctx: { now?: number }) => …tzOf const
ts
const tzOf = (ctx: { now?: number; tzOffsetMin?: number }) => …periodOf function
The period a reset is in at now: its key ("2026-12-05", or "w2026-11-30" for a week) and when it ends (ms).
ts
function periodOf(r: Reset, now: number, tzOffsetMin: number): { key: string; endsAt: number }dayOf const
The local day of now (midnight to midnight), for daily caps.
ts
const dayOf = (now: number, tzOffsetMin: number) => …choicesFor function
The choices of a step on this host: those it shows, each with the reason it cannot be picked here (off).
ts
function choicesFor(s: Step, host: Host | undefined): { choice: Choice; off?: Text }[]stepResources function
What a step needs of the machine: its own resources and those of the executor it runs on this system.
ts
function stepResources(s: Step, os: OS): Resources | undefinedallQuests function
ts
function allQuests(game: Game): { q: QuestDef; b: Branch }[]levelOf function
ts
function levelOf(xp: number)unavailableOn function
Why a quest cannot be played on this host (undefined: it can). Used by the validators of the guide.
ts
function unavailableOn(q: QuestDef, b: Branch, host: Host)evaluate function
Every quest's state, the skills owned, xp and level. Done quests unlock the ones that require them.
ts
function evaluate(ctx: Context)Evaluation type
ts
type Evaluation = ReturnType<typeof evaluate>;record function
Writes into the history what the evaluation shows as accomplished: instant, daily (once per period), personal (capped per day), repair and system (once per incident), and campaign quests (frozen xp) unless campaign: false. Opens and closes repair incidents. Pure: returns the new save and the xp gained.
ts
function record(ctx: Context, ev: Evaluation, opts: { campaign?: boolean } = {}): { save: Save; gained: { uid: string; xp: number }[] }turnIn function
Turns in a repeatable quest whose steps are all done: one more in the history, its ticks of that round purged.
ts
function turnIn(ctx: Context, v: QuestView): SaveupgradeSave function
A save without v is read as is; its history is rebuilt for the campaign quests already done.
ts
function upgradeSave(ctx: Context): SaveupgradeGame function
Brings a game file (0.1, 0.2 or 0.3) to the shape the evaluator reads, in memory, without writing anything. Throws on another schema. A 0.1 file becomes 0.2; a 0.2 or 0.3 file keeps its version, because the version says which rules checkGame applies (a 0.2 file has no human on its manual steps). Every 0.3 field is optional: a 0.2 file evaluates the same as the same file declared 0.3 (tested on content/branches.json).
ts
function upgradeGame(g: unknown): GamemergeFragments function
Adds fragments to the branches they name. A fragment for an unknown branch, or a repeated uid, is left out.
ts
function mergeFragments(g: Game, fragments: QuestFragment[]): GameSTEP_KINDS const
The step kinds of the standard. A file an author writes uses one of these (alta lint, rule step.kind); the game itself may also draw a kind a client feature registers (registerStepKind), so checkGame only checks the format.
ts
const STEP_KINDS = ["manual", "choice", "check", "action", "command", "link", "mission"] as constcheckProblems function
Problems of one check against the closed list of check types and the fields each type takes (rule check.*). Used by quest steps and by the proofs of a chart (core/charts/chart.ts).
ts
function checkProblems(at: string, c: Check): string[]checkGame function
Problems of a game file (empty = playable). Covers the rules of 0.1, 0.2 and 0.3, by the version it declares.
ts
function checkGame(g: Game): string[]checkFragment function
Problems of a quest fragment against the game it joins (empty = it can be merged).
ts
function checkFragment(f: QuestFragment, g: Game): string[]nextQuest function
The quest to show first: a main quest in progress, else the first open main quest, else any open one.
ts
function nextQuest(views: QuestView[]): QuestView | undefinedallChecks function
Every distinct check of the game.
ts
function allChecks(game: Game): Check[]serverChecks const
The checks the server runs (the others are resolved here; item and host are run by both).
ts
const serverChecks = (game: Game) => …command function
ts
function command(s: Step, os: OS): string | nullexport … re-export
ts
export type { EntityKind };