interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / kernel / svc / setup_wizard.h

192 lines · 8672 bytes Raw Blame History
1/* setup_wizard.h -- Allen's first-run setup, as a conversation in his window.
2 *
3 * The screens follow docs/FIRST_RUN_UX.md (L266, draft 1), screens 3 to 9:
4 *
5 * hello -> the one question (games / an AI model / something else) ->
6 * getting to know this computer (what setup_inv.h found, line by line) ->
7 * the one consent (Set it up / Show me each one / Not now) ->
8 * the intent path (games: screen, graphics, processor, what cannot be
9 * measured yet; AI: the graphics memory and which models fit, from their
10 * measured sizes on disk) -> which AI (found here, found nearby, or
11 * connect my own: Claude, ChatGPT, another service; the key is tested with
12 * one request) -> "Allen is ready".
13 *
14 * Every question can be skipped (Escape is "Not now"), and every step is
15 * saved (sw_save) so a restart carries on from the step it stopped at.
16 *
17 * Pure: no screen, no disk, no wire. The caller feeds keys and the clock, and
18 * takes back what to show (sw_view), lines for the log (sw_event), a test
19 * request for a service key (sw_test_wanted / sw_test_done), and at the end
20 * the records the driver builder reads (sw_llm_conf, sw_consent; L268).
21 * The key the person types lives only in this struct; sw_forget_key wipes it
22 * once the test is done, and it is never written into any record.
23 *
24 * Freestanding: no libc, no heap. Host tested in svc/tests/setup_wizard_test.c. */
25#ifndef AIENOS_SETUP_WIZARD_H
26#define AIENOS_SETUP_WIZARD_H
27#include <stdint.h>
28#include "setup_inv.h"
29
30#define SW_SAY 160u /* Allen's words for a screen */
31#define SW_LINE 96u
32#define SW_LINES 8u /* panel lines under his words */
33#define SW_CHOICE 32u
34#define SW_CHOICES 5u
35#define SW_TEXT 200u /* what the person types (a key, an address, a sentence) */
36#define SW_ITEMS 5u /* things in the consent list */
37#define SW_CANDS 6u /* AI models to choose from */
38#define SW_EVENTS 8u
39
40enum sw_key {
41 SW_K_UP = 1,
42 SW_K_DOWN,
43 SW_K_LEFT,
44 SW_K_RIGHT,
45 SW_K_TAB,
46 SW_K_ENTER,
47 SW_K_ESC,
48 SW_K_BACK,
49 SW_K_CHAR, /* c: a printable character */
50};
51
52enum sw_step {
53 SW_HELLO = 0,
54 SW_INTENT,
55 SW_OTHER, /* typing: what they want, in their words */
56 SW_OTHER_CHECK, /* That's right / Not quite */
57 SW_SCAN,
58 SW_CONSENT,
59 SW_EACH, /* the consent list, one item at a time */
60 SW_GAMES,
61 SW_AI,
62 SW_LLM,
63 SW_SERVICE, /* Claude / ChatGPT / Another service */
64 SW_URL, /* typing: another service's address */
65 SW_KEY, /* typing: the key, shown as dots */
66 SW_TESTING, /* the one test request is out */
67 SW_TEST_FAILED,
68 SW_READY,
69 SW_DONE,
70 SW_STEPS
71};
72
73/* what they want the computer for (bits) */
74enum { SW_WANT_GAMES = 1, SW_WANT_AI = 2, SW_WANT_OTHER = 4, SW_WANT_ASKED = 8 /* the question was answered or skipped */ };
75
76/* things that change the machine, each asked once (the consent list) */
77enum sw_item { SW_I_DRIVERS = 0, SW_I_SCREEN, SW_I_CORES, SW_I_AI_GPU, SW_I_BUILD, SW_I_COUNT };
78
79/* where the chosen AI is */
80enum sw_llm_kind {
81 SW_LLM_NONE = 0,
82 SW_LLM_LOCAL, /* a model or server on this computer (or its host) */
83 SW_LLM_PEER, /* another AienOS computer nearby */
84 SW_LLM_CLAUDE,
85 SW_LLM_OPENAI,
86 SW_LLM_OTHER, /* any OpenAI-compatible service */
87 SW_LLM_FETCH, /* "get one for me": to be downloaded */
88};
89
90typedef struct {
91 char name[SI_NAME]; /* what it is called where it was found */
92 char label[SW_CHOICE]; /* its choice on screen */
93 char hint[SW_LINE]; /* one plain line about it */
94 char url[SI_URL]; /* where it answers ("" for a file not served yet) */
95 uint8_t kind; /* SW_LLM_LOCAL or SW_LLM_PEER */
96 uint8_t src; /* enum si_model_src */
97} sw_cand;
98
99/* what the window shows now */
100typedef struct {
101 char say[SW_SAY]; /* Allen's words */
102 char line[SW_LINES][SW_LINE]; /* the panel, eased in one after another */
103 unsigned nline;
104 char choice[SW_CHOICES][SW_CHOICE];
105 unsigned nchoice;
106 int lit; /* the lit choice */
107 char hint[SW_LINE]; /* the lit choice's line, under the row */
108 char aside[64]; /* small, under everything ("Not now: Escape") */
109 char prompt[64]; /* typing: the bar's hint; "" = choices */
110 char typed[SW_TEXT]; /* what is typed, as shown (dots for a key) */
111 unsigned ntyped;
112 unsigned gen; /* +1 on every change */
113 unsigned said_gen; /* +1 when say changes */
114} sw_view;
115
116typedef struct {
117 sw_view v;
118 const si_inv *inv;
119 int step;
120 uint32_t step_t; /* when this step began, ms */
121 unsigned want; /* SW_WANT_* */
122 char wish[SW_TEXT];/* their own words, from "Something else" */
123 /* the consent list */
124 uint8_t item[SW_ITEMS]; /* enum sw_item, in the order shown */
125 unsigned nitem, each; /* each: the item being asked in SW_EACH */
126 unsigned consent; /* bit per sw_item: yes */
127 int consent_asked; /* 0 not yet, 1 answered, -1 Not now */
128 /* the AI */
129 sw_cand cand[SW_CANDS];
130 unsigned ncand;
131 int listing; /* SW_LLM: the full list (after "Choose another") */
132 uint8_t llm_kind;
133 char llm_name[SI_NAME];
134 char llm_url[SI_URL];
135 int service; /* SW_LLM_CLAUDE / OPENAI / OTHER being connected */
136 char key[SW_TEXT]; /* the key: here only, wiped by sw_forget_key */
137 unsigned nkey;
138 char text[SW_TEXT]; /* the line being typed (not the key) */
139 unsigned ntext;
140 int courier; /* a wire to the host can carry the key test */
141 int test_out; /* a test request is wanted (1) or out (2) */
142 uint32_t test_t;
143 char why[SW_LINE]; /* what the service said when the test failed */
144 int resumed;
145 /* the log */
146 char ev[SW_EVENTS][SW_LINE];
147 unsigned ev_head, ev_n;
148} sw_wizard;
149
150/* Starts at hello (or at a saved step: saved = sw_save's text, n bytes;
151 * NULL for a first start). courier: 1 when a wire to the host is there to
152 * test a key (without one, Allen says he cannot keep a key safely yet). */
153void sw_start(sw_wizard *w, const si_inv *inv, int courier, const char *saved, unsigned n, uint32_t now_ms);
154/* A key. Returns 1 when the view changed. */
155int sw_key(sw_wizard *w, int key, char c, uint32_t now_ms);
156/* The clock: steps that move on by themselves (hello, the scan, the 10 s
157 * auto-pick of a single model, a test that never answers). 1 when the view changed. */
158int sw_tick(sw_wizard *w, uint32_t now_ms);
159/* The test request for a service key: 1 when one is wanted and fills kind
160 * ("anthropic" or "openai"), base_url, model and the key, then marks it out.
161 * 0 when none is wanted. */
162int sw_test_wanted(sw_wizard *w, const char **kind, const char **base_url, const char **model, const char **key);
163/* Its answer: ok, or what went wrong (plain words, may be NULL). */
164void sw_test_done(sw_wizard *w, int ok, const char *why, uint32_t now_ms);
165/* Wipes the key (after the test, or when leaving the key screens). */
166void sw_forget_key(sw_wizard *w);
167const sw_view *sw_view_of(const sw_wizard *w);
168int sw_step_of(const sw_wizard *w);
169const char *sw_step_name(int step);
170/* The next line for the log (no words the person typed): 1 and out filled, or 0. */
171int sw_event(sw_wizard *w, char *out, unsigned cap);
172
173/* Records (text, one item per line; each returns its length, 0 if cap is short):
174 * sw_save: "aienos-setup v1" then step, want, consent, asked, llm kind/name/url
175 * (enough to carry on after a restart; never the key, never the wish)
176 * sw_llm_conf: what L268 reads: kind, base_url, model, key_env (never the key)
177 * sw_consent: "aienos-consent v1" then one "<item> yes|no" per thing asked */
178unsigned sw_save(const sw_wizard *w, char *out, unsigned cap);
179unsigned sw_llm_conf(const sw_wizard *w, char *out, unsigned cap);
180unsigned sw_consent(const sw_wizard *w, char *out, unsigned cap);
181/* The three in one text, as kept on disk (svc/setup_store.h): sw_save, then
182 * sw_llm_conf (absent until an AI is picked), then sw_consent. 0 if cap is short. */
183unsigned sw_record(const sw_wizard *w, char *out, unsigned cap);
184/* 1 when a saved record says setup ran to the end. */
185int sw_saved_done(const char *saved, unsigned n);
186
187/* The model sizes Allen knows, measured on disk (du -sm on the Spark,
188 * 2026-10-20): weights only; the working memory on top is not measured. */
189#define SW_MIB_27B 29460u /* qwen3.8-27b-fp8 */
190#define SW_MIB_30B 29751u /* qwen3-30b-a3b-instruct-2507-fp8 */
191#define SW_MIB_4B 7688u /* qwen3-4b-instruct-2507 */
192#endif