aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / kernel / svc / allen_intent.h
| 1 | /* allen_intent.h -- How Allen reads a line he cannot answer by heart and |
| 2 | * writes the job he hands to a far-off worker (a language model reached |
| 3 | * through a courier, svc/courier.h). Allen decides what is wanted, something |
| 4 | * made, something explained, something done, or just talk, and composes the |
| 5 | * instruction himself: who he is, who asked, and the shape the answer must |
| 6 | * take, so the worker speaks in his voice and the person only ever hears |
| 7 | * Allen. Pure: no I/O, no model here. Host tested in ui/tests/allen_ui_test.c. */ |
| 8 | #ifndef AIENOS_ALLEN_INTENT_H |
| 9 | #define AIENOS_ALLEN_INTENT_H |
| 10 | #include <stdint.h> |
| 11 | #include "allen_reply.h" |
| 12 | |
| 13 | typedef enum { CK_WANT_CHAT, CK_WANT_MAKE, CK_WANT_EXPLAIN, CK_WANT_DO } ck_allen_want; |
| 14 | |
| 15 | /* What a folded line (ck_allen_fold) asks for, from its first word and its verbs. */ |
| 16 | ck_allen_want ck_allen_want_of(const char *folded); |
| 17 | /* "chat", "make", "explain" or "do". */ |
| 18 | const char *ck_allen_want_name(ck_allen_want w); |
| 19 | /* The job Allen sends, one line: "JOB <seq> <want> <instruction>\t<line>" |
| 20 | * (tabs, newlines and control bytes in line become spaces; no trailing |
| 21 | * newline). Returns the length, 0 when cap is too small. */ |
| 22 | unsigned ck_allen_job(const ck_allen_mind *m, uint32_t seq, const char *line, char *out, unsigned cap); |
| 23 | /* Reads an answer "SAY <seq> <text>" (the worker turns newlines into "\n"): |
| 24 | * 1 with the seq and the text (at most cap - 1 bytes, "\n" back to a space), |
| 25 | * 0 when the line is not an answer. */ |
| 26 | int ck_allen_answer_line(const char *in, uint32_t *seq, char *text, unsigned cap); |
| 27 | /* Allen's memory for the worker, appended to a job line as tab-separated |
| 28 | * fields: "self=<his name>", "name=<the person's>", "starts=<n>", one |
| 29 | * "fact <key> is|are <val>" per taught fact, one "note <text>" per live note |
| 30 | * among the newest `notes_max`. Returns the bytes written at out (no leading |
| 31 | * tab is missing: the first byte is a tab), 0 when cap is too small. */ |
| 32 | unsigned ck_allen_job_memory(const ck_allen_mind *m, unsigned notes_max, char *out, unsigned cap); |
| 33 | /* Reads one answer part "SAY <seq> <part>/<total> <text>" (parts count from |
| 34 | * 1; total is 0 until the last part, which carries its own number as the |
| 35 | * total) or a whole answer "SAY <seq> <text>" (part 1 of 1): 1 with seq, |
| 36 | * part, total and the text folded as ck_allen_answer_line does; 0 when the |
| 37 | * line is not an answer. "WAIT <seq>" (the worker is waiting on a busy |
| 38 | * model) is 1 with part 0, total 0 and an empty text. */ |
| 39 | int ck_allen_say_line(const char *in, uint32_t *seq, unsigned *part, unsigned *total, char *text, unsigned cap); |
| 40 | |
| 41 | /* Code asked of the Spark (svc/allen_code.h). folded as ck_allen_want_of's. |
| 42 | * 1 when the line asks for code to be written ("make me a calculator", |
| 43 | * "write a snake game in python"); 0 for anything else, prose included. */ |
| 44 | int ck_allen_wants_code(const char *folded); |
| 45 | /* 1 when the line reads as a change to code just shown ("now add a square |
| 46 | * root key"); the caller asks only while code is fresh. */ |
| 47 | int ck_allen_code_more(const char *folded); |
| 48 | /* The courier job for a code request: "JOB <seq> code|code-more <instruction>\t<line>" |
| 49 | * (want "code" starts afresh, "code-more" goes on with the code before). |
| 50 | * Returns its length, 0 when it does not fit in cap. */ |
| 51 | unsigned ck_allen_code_job(const ck_allen_mind *m, uint32_t seq, const char *line, int more, char *out, unsigned cap); |
| 52 | |
| 53 | #endif |