Skip to content

core/charts/needs.ts ​

Generated from the exports of core/charts/needs.ts · npm run docs:gen

Needs of alta.chart/0.1 (docs/standards/alta-chart-0.1.md, "Needs"): a chart says it needs "a mind" or "a channel" instead of naming Claude or Telegram. The player binds each kind once to a provider (their onboarding choices) and every chart reuses that binding unless it says otherwise. Agents, parts and proofs name the need ("need:mind"); the engine binds. Providers are a closed table here (like the sign-in tools): their services, sign-ins, proofs and repairs come from their row, never from a chart. Pure: no disk, no network.

Standards that cite this file: alta.chart/0.1: the Agent Chart

Exports ​

NEED_KINDS const ​

ts
const NEED_KINDS = ["mind", "channel"] as const

NeedKind type ​

ts
type NeedKind = (typeof NEED_KINDS)[number];

NEED_FEATURES const ​

What a provider of each kind may offer (closed): a need asks for some with features.

ts
const NEED_FEATURES: Readonly<Record<NeedKind, readonly string[]>>

NEED_ID const ​

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

NEED_KEYS const ​

ts
const NEED_KEYS = ["$comment", "kind", "why", "accept", "model", "features", "prefer", "reuse", "optional"] as const

Need interface ​

A need as written: {} or true is broad (any provider of its kind, the player's own choice).

ts
interface Need {
  kind?: NeedKind;
  why?: Text;
  accept?: string[];
  model?: string;
  features?: string[];
  prefer?: string[];
  reuse?: "owner" | "ask";
  optional?: boolean;
}

NeedDecl type ​

ts
type NeedDecl = Need | true;

NeedOf interface ​

A need with its kind known and its defaults filled.

ts
interface NeedOf extends Need { id: string; kind: NeedKind; why: Text; reuse: "owner" | "ask"; optional: boolean }

NEED_WHY const ​

The sentence the consent screen shows when a need has no why.

ts
const NEED_WHY: Readonly<Record<NeedKind, Text>>

NEED_DATA const ​

What leaves the machine through a provider of each kind (external.services data).

ts
const NEED_DATA: Readonly<Record<NeedKind, "prompts" | "messages">>

ProviderSignin interface ​

ts
interface ProviderSignin { id: string; use: "signin.cli" | "channel.connect" | "channel.pair-approve"; args: Record<string, string>; proof: Check; why: Text; requires?: string[] }

Provider interface ​

ts
interface Provider {
  id: string;
  kind: NeedKind;
  label: Text;
  features: readonly string[];
  /** Runs on the machine (or in the game itself): nothing leaves it. */
  local: boolean;
  /** The engine's word for it (`alta-step --model` / `--channel`, the answers `default_model` and `channel`). */
  word: string;
  /** Mind: the providers of a "provider/model" id it serves (a pinned `model`). */
  models?: readonly string[];
  /** Not local: the online service, generated in `external.services` when it is bound. */
  service?: { name: string; hosts: readonly string[]; account: "none" | "free" | "paid"; homepage?: string };
  /** What connects it, in order (each a generated sign-in step). Empty: nothing to connect. */
  signins: readonly ProviderSignin[];
  /** The read-only proof that it still works (cheap): the `need` proof becomes this one. Absent: always met. */
  proof?: Check;
  /** The repairs of that proof, from the closed list of repair kinds. */
  repairs: readonly { id: string; kind: string; args: Record<string, string> }[];
  resources?: Resources;
  /** Can it be bound in a hosted world? Default yes. */
  hosted?: boolean;
  /** How the consent step names the binding: "will think with <this>", "will write to you <this>". */
  phrase: Text;
}

PROVIDERS const ​

The closed table of providers. Order is the engine's recommendation order.

ts
const PROVIDERS: readonly Provider[]

PROVIDER_IDS const ​

ts
const PROVIDER_IDS: readonly string[]

provider const ​

ts
const provider = (id: unknown) => …

providersOf const ​

ts
const providersOf = (kind: NeedKind) => …

needKindOf function ​

The kind of a need: its kind, else its id (mind), else the prefix of its id (mind-deep).

ts
function needKindOf(id: string, decl: unknown): NeedKind | undefined

inferredKind function ​

The kind its id alone says, or undefined.

ts
function inferredKind(id: string): NeedKind | undefined

needsOf function ​

The needs of a chart, kinds known and defaults filled (a need of unknown kind is left out: lint reports it).

ts
function needsOf(c: { needs?: unknown }): Record<string, NeedOf>

needRefOf const ​

"need:<id>" → id, or undefined.

ts
const needRefOf = (v: unknown): string | undefined => …

isNeedRef const ​

ts
const isNeedRef = (v: unknown) => …

mindOfModel const ​

The provider of a "provider/model" id, among the minds.

ts
const mindOfModel = (model: unknown) => …

candidates function ​

The providers a need may take, from what it says alone (kind, accept, model, features): no machine, no player.

ts
function candidates(n: Pick<NeedOf, "kind" | "accept" | "model" | "features">): Provider[]

World interface ​

What the player has: their default per kind (onboarding answers), the providers already connected, the preset.

ts
interface World {
  /** Their default provider per kind ("my install"). */
  owner?: Partial<Record<NeedKind, string>>;
  /** Providers already connected on this machine (their sign-in holds). */
  connected?: readonly string[];
  /** The preset "100% local": only providers that keep everything on the machine. */
  localOnly?: boolean;
  /** The player's own pick per need ("change", or the preset "customise"). */
  picked?: Readonly<Record<string, string>>;
}

BindStatus type ​

ts
type BindStatus = "bound" | "connect" | "choose" | "unmet" | "skip";

Binding interface ​

ts
interface Binding {
  need: string; kind: NeedKind;
  status: BindStatus;
  /** The provider: bound, to connect, or preselected when the player is asked. */
  provider?: string;
  /** Every provider the player may pick, recommended first. */
  candidates: string[];
  /** The rule of `bind` that decided (0: the player's own pick). */
  rule: 0 | 2 | 3 | 4 | 5 | 6;
  optional: boolean;
  /** Why no provider fits (rule 2). */
  reason?: Text;
}

ownerFromAnswers function ​

The engine's answers → the player's default per kind: default_model ("provider/model" or a word), channel.

ts
function ownerFromAnswers(a: Record<string, unknown> | null | undefined): Partial<Record<NeedKind, string>>

fitting function ​

Rule 1 for one need: the candidates that also fit this machine and the player's preset, recommended first.

ts
function fitting(n: NeedOf, host?: Host, localOnly = false): Provider[]

bind function ​

Binds every need of a chart (pure). The first rule that applies:

  1. candidates: right kind, inside accept, with the features, the pinned model, that this machine can carry and, with "100% local", local only; 2. none: unmet, with the reason (the chart is greyed, never hidden);
  2. one candidate (pinned): bound when connected, else a connection; 4. reuse owner and the player's default is a candidate: bound, no question; 5. another candidate already connected: proposed, preselected, one question;
  3. nothing connected: a choice, recommended first by prefer then by the engine, then the connection. The player's own pick (world.picked) comes before 3 when it is a candidate.
ts
function bind(chart: { needs?: unknown }, world: World = {}, machine?: Host): Record<string, Binding>

bindingValues function ​

The provider each need goes with (bound, to connect, or preselected), as the chosen map keys "need:<id>".

ts
function bindingValues(b: Record<string, Binding>): Record<string, string>

bindingWords function ​

The words of one binding on the consent step: "will think with your Claude subscription".

ts
function bindingWords(b: Binding): Text

bindingLines function ​

One line per need for the consent step: "This chart will think with your Claude subscription · change".

ts
function bindingLines(title: Text, b: Record<string, Binding>): { en: string[]; fr: string[] }

needService function ​

The online service a bound provider adds (external.services shape), or undefined for a local one.

ts
function needService(needId: string, p: Provider, optional = false)

Alta OS is open source (MIT).