@evoke-build/evoke 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1363 @@
1
+ /** A `Result` on the wire: `{ ok }` or `{ err }`. */
2
+ export type Result<T, E> = {
3
+ ok: T;
4
+ } | {
5
+ err: E;
6
+ };
7
+ /** Text that cannot repaint a terminal: no C0 or C1 control but the line feed, no bidi control. */
8
+ export type Clean = string;
9
+ /** What a person typed: NFC, at most 2 000 characters, spelling kept; untrusted, never cleaned — only its spans are. */
10
+ export type Input = string;
11
+ /** What keys a record: NFC, lower-cased, whitespace collapsed and trimmed, terminal punctuation dropped; the core normalizes any string it is handed as one. */
12
+ export type Identity = string;
13
+ /** An utterance as written, with its identity: the text is what the classifier reads, the id what keys it. */
14
+ export interface Utterance {
15
+ /** One non-empty line. */
16
+ text: Clean;
17
+ /** The identity of `text`; anything else is refused. */
18
+ id: Identity;
19
+ }
20
+ /** A verbatim piece of one input: character offsets, `start < end`, and the text between them. */
21
+ export interface Span {
22
+ start: number;
23
+ end: number;
24
+ text: Clean;
25
+ }
26
+ /** A list that refuses to be empty; on the wire, a plain array — never `[]`. */
27
+ export type NonEmpty<T> = [T, ...T[]];
28
+ /** The `[reflexes]` key, the overlay's file name, a route option: `[a-z][a-z0-9_]*`, never `none`, `unstated`, `fits` or `weave`. */
29
+ export type LocalName = string;
30
+ /** An argument: `[a-z][a-z0-9_]*`, never a JavaScript reserved word, so a body can destructure it. */
31
+ export type ArgName = string;
32
+ /** An option's key, which the body receives: one clean line, never `none` or `unstated`. */
33
+ export type OptionKey = string;
34
+ /** A vocabulary word: one clean line, trimmed, never `none` or `unstated`; spaces allowed. */
35
+ export type Word = string;
36
+ /** A vocabulary, `vocab/<name>.toml`: `[a-z][a-z0-9_]*`. */
37
+ export type VocabName = string;
38
+ /** A key under `[config]`: `[a-z][a-z0-9_]*`. */
39
+ export type ConfigKey = string;
40
+ /** A field of a result's `data`, as `[yields]` names it: `[a-z][a-z0-9_]*`. */
41
+ export type FieldName = string;
42
+ /** A scope for `--tag`: `[a-z][a-z0-9_]*`. */
43
+ export type Tag = string;
44
+ /** An adapter, by the name it is resolved under: `[a-z][a-z0-9_]*`. */
45
+ export type AdapterName = string;
46
+ /** What an adapter declares itself as: non-empty; compared, never parsed. */
47
+ export type AdapterId = string;
48
+ /** An environment variable: `[A-Za-z_][A-Za-z0-9_]*`. */
49
+ export type VarName = string;
50
+ /** A path inside one reflex directory: relative, plain segments, no `..`. */
51
+ export type RelPath = string;
52
+ /** A `{name}` in `[needs]`: an argument or a config key, whose value fills the entry at the decision. */
53
+ export type ValueName = string;
54
+ /** An absolute path as `[needs]` names one: `/`, or plain segments under it, no `.` or `..`. */
55
+ export type AbsPath = string;
56
+ /** A GitHub owner, user or organization: `[A-Za-z0-9][A-Za-z0-9-]*`. */
57
+ export type Owner = string;
58
+ /** One segment of a ref: `[A-Za-z0-9._][A-Za-z0-9._-]*`, never option-shaped. */
59
+ export type Segment = string;
60
+ /** A problem a person has to fix, ending in the command that fixes it. */
61
+ export interface Diagnostic {
62
+ /** The reflex the problem belongs to, when it belongs to one. */
63
+ reflex?: LocalName;
64
+ /** The line, when the file has lines; a JSON document has none and fixes with `check`. */
65
+ at?: At;
66
+ message: string;
67
+ fix: Fix;
68
+ }
69
+ /** A line of an owned file. */
70
+ export interface At {
71
+ file: File;
72
+ line: number;
73
+ column: number;
74
+ }
75
+ /** One of the project's owned files, by role; it displays as its project-relative path. */
76
+ export type File = {
77
+ type: "manifest";
78
+ name: LocalName;
79
+ } | {
80
+ type: "overlay";
81
+ name: LocalName;
82
+ } | {
83
+ type: "vocab";
84
+ name: VocabName;
85
+ } | {
86
+ type: "project";
87
+ } | {
88
+ type: "lock";
89
+ };
90
+ /** The closed set of fixing commands, each rendered as the literal last line of a diagnostic. */
91
+ export type Fix = {
92
+ type: "vocab_add";
93
+ vocab: VocabName;
94
+ } | {
95
+ type: "vocab_remove";
96
+ vocab: VocabName;
97
+ } | {
98
+ type: "vocab";
99
+ vocab: VocabName;
100
+ } | {
101
+ type: "config_set";
102
+ reflex: LocalName;
103
+ key: ConfigKey;
104
+ } | {
105
+ type: "config_env";
106
+ reflex: LocalName;
107
+ key: ConfigKey;
108
+ } | {
109
+ type: "update";
110
+ reflex?: LocalName;
111
+ } | {
112
+ type: "accept";
113
+ reflex: LocalName;
114
+ } | {
115
+ type: "trust";
116
+ } | {
117
+ type: "remove";
118
+ reflex: LocalName;
119
+ } | {
120
+ type: "sync";
121
+ } | {
122
+ type: "check";
123
+ } | {
124
+ type: "edit_line";
125
+ at: At;
126
+ } | {
127
+ type: "export_key";
128
+ var: VarName;
129
+ } | {
130
+ type: "rerun";
131
+ } | {
132
+ type: "add";
133
+ } | {
134
+ type: "show";
135
+ reflex?: LocalName;
136
+ } | {
137
+ type: "add_ref";
138
+ reference: string;
139
+ name?: LocalName;
140
+ } | {
141
+ type: "add_refs";
142
+ references: string[];
143
+ } | {
144
+ type: "teach_not";
145
+ utterance: string;
146
+ reflex: LocalName;
147
+ } | {
148
+ type: "new";
149
+ } | {
150
+ type: "test";
151
+ } | {
152
+ type: "help";
153
+ };
154
+ /** A JSON value that keeps its key order: the wire form of every boundary type. */
155
+ export type Json = unknown;
156
+ /** A file to parse: its role, and its text as written — TOML, with lines — or as JSON, without. */
157
+ export type Document = {
158
+ file: File;
159
+ toml: string;
160
+ } | {
161
+ file: File;
162
+ json: Json;
163
+ };
164
+ /** Where in a file, by key: `["args", "state", "ask"]` is `args.state.ask`; a segment is verbatim, unescaped. */
165
+ export type KeyPath = string[];
166
+ /** A reflex's manifest, normalized: `effect` explicit, every table present, records typed. */
167
+ export interface Manifest {
168
+ description: Description;
169
+ not_for: Clean[];
170
+ tags: Tag[];
171
+ effect: Effect;
172
+ confirm: Template;
173
+ /** Absent: inline, a function the SDK holds. */
174
+ run?: Run;
175
+ /** What the body may touch; absent, the tightest declaration. Contract, like `run`. */
176
+ needs?: Needs;
177
+ config: Record<ConfigKey, ConfigSpec>;
178
+ args: Record<ArgName, Argument>;
179
+ /** What the body's `data` yields for a later step to take, per field. */
180
+ yields: Record<FieldName, Yield>;
181
+ examples: Records;
182
+ tests: Records;
183
+ /** Keys the format does not know: reported, never fatal. */
184
+ unknown: KeyPath[];
185
+ }
186
+ /** What the reflex does: a summary line, never empty; the rest, when there is one, after a line feed. */
187
+ export type Description = string;
188
+ /** What running the reflex does to the world; greater is tighter: read < write < destructive. */
189
+ export type Effect = "read" | "write" | "destructive";
190
+ /** The confirm prompt: text with `{placeholder}`s, each naming a required, non-flag argument. */
191
+ export type Template = string;
192
+ /** The body: an entrypoint run in a child, or an argv that never touches a shell. */
193
+ export type Run = Entrypoint | Argv;
194
+ /** The program, a literal, then each element. */
195
+ export type Argv = [program: Clean, ...rest: Element[]];
196
+ /** A path inside the reflex directory ending in `.mts` or `.mjs`. */
197
+ export type Entrypoint = RelPath;
198
+ /** One argv element after the program: a literal as written, or an argument's `{name}` — never a flag's. */
199
+ export type Element = string;
200
+ /** A setting the user provides; a secret is set only from an environment variable. */
201
+ export interface ConfigSpec {
202
+ about: Clean;
203
+ secret: boolean;
204
+ }
205
+ /** An argument: its question, where its values come from, and its former names. */
206
+ export type Argument = {
207
+ ask: Clean;
208
+ /** Flat and cumulative; a retired name never returns. */
209
+ was: ArgName[];
210
+ } & Kind;
211
+ /** A flag, or a value with exactly one source; a flag is optional by nature. */
212
+ export type Kind = {
213
+ flag: true;
214
+ } | (Source & {
215
+ optional: boolean;
216
+ });
217
+ /** Where an argument's values come from: the author, the user or the input. */
218
+ export type Source = {
219
+ options: Options;
220
+ } | {
221
+ vocab: VocabName;
222
+ } | Pick;
223
+ /** The author's closed set, never empty: key = what the body receives, value = what it means. */
224
+ export type Options = Record<OptionKey, Clean>;
225
+ /** A built-in recognizer over the input; a range only where a number exists, whole seconds for a duration. */
226
+ export type Pick = {
227
+ pick: "number" | "duration";
228
+ range?: Range;
229
+ } | {
230
+ pick: "email" | "url" | "quoted";
231
+ };
232
+ /** One of the five recognizers, by the name a manifest's `pick` writes. */
233
+ export type Recognizer = "number" | "duration" | "email" | "url" | "quoted";
234
+ /** What a field of a body's `data` holds, for a later step to take: a value the recognizer reads, or a list of records with such fields. Contract. */
235
+ export type Yield = Recognizer | {
236
+ each: Record<FieldName, Recognizer>;
237
+ };
238
+ /** `[min, max]` on a value, min ≤ max. */
239
+ export type Range = [min: number, max: number];
240
+ /** The declaration: four lists, each absent when empty. */
241
+ export interface Needs {
242
+ reads?: Entry[];
243
+ writes?: Entry[];
244
+ /** `["*"]` for any host, else absent: a name is held by no kernel. */
245
+ hosts?: Hosts;
246
+ runs?: Program[];
247
+ }
248
+ /** One path the declaration names: `~/…`, `/…`, or `{name}`, the value of an argument or a config key. */
249
+ export type Entry = string;
250
+ /** Which hosts the body may reach: `[]` none, `["*"]` any. */
251
+ export type Hosts = [] | ["*"];
252
+ /** A program the body may run: a name found on `PATH`, or an absolute path. */
253
+ export type Program = string;
254
+ /** A key of the table, as a line names it. */
255
+ export type NeedsKey = "reads" | "writes" | "hosts" | "runs";
256
+ /** The declaration resolved at a decision: every path absolute, a `{name}` replaced by its value or dropped when unstated. Strings a host holds paths by. */
257
+ export interface Policy {
258
+ reads?: Place[];
259
+ writes?: Place[];
260
+ hosts?: Hosts;
261
+ runs?: Program[];
262
+ }
263
+ /** A path the body may reach, and the entry it came from. */
264
+ export interface Place {
265
+ path: string;
266
+ from: Entry;
267
+ }
268
+ /** Where a declaration comes from, so a fix lands where it is written: a local reflex's manifest at its `[needs]` line, or a fetched reflex, whose author's it is. */
269
+ export type Origin = {
270
+ type: "local";
271
+ at: At;
272
+ } | {
273
+ type: "fetched";
274
+ };
275
+ /** What the machine lacks that the declaration names: a path, or a program `PATH` does not hold. */
276
+ export type Lacking = {
277
+ type: "place";
278
+ place: Place;
279
+ key: NeedsKey;
280
+ } | {
281
+ type: "program";
282
+ program: Program;
283
+ };
284
+ /** What refused a body, as the loader reports it: Node's permission or the kernel's syscall, and the path. */
285
+ export interface Refused {
286
+ what: string;
287
+ path: string;
288
+ }
289
+ /** What an update does to the needs a person consented to: upstream may keep or narrow them, and widens them only through `evoke update --accept`; `kept` is what the lock records meanwhile. */
290
+ export type NeedsConsent = {
291
+ type: "kept";
292
+ needs: Needs;
293
+ } | {
294
+ type: "tightened";
295
+ needs: Needs;
296
+ removed: Needs;
297
+ } | {
298
+ type: "needs_accept";
299
+ locked: Needs;
300
+ upstream: Needs;
301
+ };
302
+ /** What the host knows that the policy does not: where things are. */
303
+ export interface Facts {
304
+ platform: Platform;
305
+ /** The runtime a file body runs under; absent for an argv body. */
306
+ runtime?: Runtime;
307
+ /** The body's directory: readable, and its working directory. */
308
+ body_dir: string;
309
+ /** The private temporary folder made for the run, by its real path. */
310
+ tmp: string;
311
+ /** The home: the runtime's installation is readable whole unless that would be the home or above it. */
312
+ home: string;
313
+ /** Linux: the file `/etc/resolv.conf` really is when it links out of `/etc`. */
314
+ resolver?: string;
315
+ /** What the host found at each of the policy's paths, by the path as the policy spells it. */
316
+ found?: Record<string, Found>;
317
+ /** Where each program the policy names is, by the name as the policy spells it. */
318
+ programs?: Record<string, Executable>;
319
+ }
320
+ export type Platform = "linux" | "macos";
321
+ /** The runtime a file body runs under: its program, as `process.execPath` names it, and whether its permission
322
+ * model holds the network, which it does from Node 25, the first to know `--allow-net`. */
323
+ export interface Runtime extends Executable {
324
+ holds_network?: boolean;
325
+ }
326
+ /** A program as the kernel runs it: its path, and the interpreters the kernel executes to run it. */
327
+ export interface Executable {
328
+ path: string;
329
+ interpreters?: string[];
330
+ }
331
+ /** A path as the host found it: its real path, links followed, and whether it is a directory. */
332
+ export interface Found {
333
+ real: string;
334
+ dir: boolean;
335
+ }
336
+ /** One Landlock rule: the path, and the rights beneath it. */
337
+ export interface Rule {
338
+ path: string;
339
+ rights: Right[];
340
+ }
341
+ /** The file-system rights Landlock names. */
342
+ export type Right = "execute" | "write_file" | "read_file" | "read_dir" | "remove_dir" | "remove_file" | "make_char" | "make_dir" | "make_reg" | "make_sock" | "make_fifo" | "make_block" | "make_sym" | "refer" | "truncate" | "ioctl_dev";
343
+ /** Whether the machine holds the whole declaration: fully; partly, with what it does not hold; not at all, with why. */
344
+ export type Contained = {
345
+ type: "full";
346
+ } | {
347
+ type: "partial";
348
+ why: string;
349
+ } | {
350
+ type: "none";
351
+ why: string;
352
+ };
353
+ /** Utterances, each with what it asserts; keyed by spelling, no two sharing an identity. */
354
+ export type Records = Record<Clean, Asserted>;
355
+ /** `false`, or the asserted arguments; `{}` asserts the route alone. */
356
+ export type Asserted = false | Record<ArgName, Assertion>;
357
+ /** One argument's assertion: `false` unstated, `true` a flag, else an option key, a word or a span of the utterance. */
358
+ export type Assertion = boolean | OptionKey | Word | Clean;
359
+ /** Your wording for one reflex, its names already resolved through `was`. Read, never built. */
360
+ export interface Overlay {
361
+ description?: Description;
362
+ not_for?: Clean[];
363
+ tags?: Tag[];
364
+ effect?: Effect;
365
+ confirm?: Template;
366
+ args: Record<ArgName, Wording>;
367
+ examples: Records;
368
+ tests: Records;
369
+ /** Former names the file used, with the name each resolved to. */
370
+ renamed: [ArgName, ArgName][];
371
+ /** Keys that address nothing: skipped, the rest applies. */
372
+ orphaned: KeyPath[];
373
+ }
374
+ /** New wording for an argument: its question, and existing option keys. */
375
+ export interface Wording {
376
+ ask?: Clean;
377
+ options: Record<OptionKey, Clean>;
378
+ }
379
+ /** `shipped ⊕ yours`, with the key paths your file decided: what `show` marks. */
380
+ export interface Effective {
381
+ manifest: Manifest;
382
+ yours: KeyPath[];
383
+ }
384
+ /** What an update means for your file. */
385
+ export interface Report {
386
+ renamed: [ArgName, ArgName][];
387
+ /** You override what upstream changed: yours wins, both are shown once. */
388
+ stale: KeyPath[];
389
+ orphaned: KeyPath[];
390
+ }
391
+ /** Your closed set for the arguments that name it; may be empty, which `compile` reports. */
392
+ export type Vocabulary = Record<Word, Meaning>;
393
+ /** What a word means, and what the body receives instead of it when set. */
394
+ export interface Meaning {
395
+ what: Clean;
396
+ /** What the body receives instead of the word; never shown to the classifier. */
397
+ value?: string;
398
+ }
399
+ /** What you wrote: the adapter that decides, the reflexes you installed, their settings, the adapters' own tables. */
400
+ export interface Project {
401
+ /** Always stated; a name, never a path. */
402
+ adapter: AdapterName;
403
+ reflexes: Record<LocalName, Location>;
404
+ config: Record<LocalName, Record<ConfigKey, Setting>>;
405
+ /** Inert unless selected; then its adapter validates it. */
406
+ adapters: Record<AdapterName, Json>;
407
+ }
408
+ /** Where a reflex comes from: a directory as written, resolved by the host, or a repository. */
409
+ export type Location = {
410
+ type: "local";
411
+ path: string;
412
+ } | {
413
+ type: "remote";
414
+ reference: Reference;
415
+ pin?: Version;
416
+ };
417
+ /** A repository and a directory in it. */
418
+ export interface Reference {
419
+ repo: Repo;
420
+ dir?: RelPath;
421
+ }
422
+ /** A repository on GitHub, or by git URL. */
423
+ export type Repo = {
424
+ type: "github";
425
+ owner: Owner;
426
+ name: Segment;
427
+ } | {
428
+ type: "url";
429
+ url: GitUrl;
430
+ };
431
+ /** A git URL over an allow-listed scheme: `https` or `ssh`; a user may stand before the host; no `#` or
432
+ * whitespace, and no `@` past the host. */
433
+ export type GitUrl = string;
434
+ /** A tag `[v]X.Y.Z`, printed without the `v`: `"1.2.0"`. */
435
+ export type Version = string;
436
+ /** A config value as you stored it: plain, or a reference to an environment variable. */
437
+ export type Setting = {
438
+ type: "plain";
439
+ value: string;
440
+ } | {
441
+ type: "env";
442
+ var: VarName;
443
+ };
444
+ /** What `add`, `update` and `remove` write whole and `sync` realises; a local reflex is never in it. */
445
+ export interface Lock {
446
+ evoke: Version;
447
+ adapter: LockedAdapter;
448
+ reflexes: Record<LocalName, Locked>;
449
+ }
450
+ /** The adapter the lock was written under, by name and id. */
451
+ export interface LockedAdapter {
452
+ name: AdapterName;
453
+ id: AdapterId;
454
+ }
455
+ /** One remote reflex as pinned; `needs` absent means none consented to. */
456
+ export interface Locked {
457
+ reference: Reference;
458
+ tag: Version;
459
+ commit: Commit;
460
+ h1: Digest;
461
+ effect: Effect;
462
+ needs?: Needs;
463
+ }
464
+ /** A commit as git printed it: 40 or 64 lowercase hex; compared, never parsed. */
465
+ export type Commit = string;
466
+ /** A SHA-256, displayed and serialized as `h1:<hex>`. */
467
+ export type Digest = string;
468
+ /** A choice's key exactly as offered: an option key, a word, a candidate `<start>-<end>`, a flag's `yes` or `no`, a local name, `none` or `unstated`. The plan's slot gives it meaning at read. */
469
+ export type Key = string;
470
+ /** Which question: `route`, `fits.<reflex>`, `<reflex>.<argument>`, or `weave.<name>` — a question evoke asks on its own account beside the plan's. */
471
+ export type QuestionId = string;
472
+ /** One question for the adapter: a choice over keys, or a yes/no with both sides described. */
473
+ export type Question = ({
474
+ type: "choice";
475
+ } & Choice) | {
476
+ type: "yesno";
477
+ ask: Clean;
478
+ /** The reflex's description. */
479
+ yes: Text;
480
+ /** What the reflex is not for. */
481
+ no: Text;
482
+ };
483
+ /** A choice: the question, its options in order, and which key means "none of these". */
484
+ export interface Choice {
485
+ ask: Clean;
486
+ options: Record<Key, Text>;
487
+ /** One of `options`; absent when the choice has no sentinel. */
488
+ otherwise?: Key;
489
+ }
490
+ /** What an option means: a line, or a description with what it is not for and examples that assert it. */
491
+ export type Text = Clean | {
492
+ what: Clean;
493
+ /** Absent when empty. */
494
+ not_for?: Clean[];
495
+ /** Absent when empty. */
496
+ examples?: Clean[];
497
+ };
498
+ /** The only state an adapter ever sees. */
499
+ export interface State {
500
+ request: Input;
501
+ }
502
+ /** One call of `answer`: the state, the questions, and the candidate spans the pick questions were built from. */
503
+ export interface Request {
504
+ state: State;
505
+ questions: Record<QuestionId, Question>;
506
+ proposed: Proposed[];
507
+ }
508
+ /** A finite number in `[0, 1]`. */
509
+ export type Prob = number;
510
+ /** Per-call ceilings an adapter declares. */
511
+ export interface Limits {
512
+ /** The most options one choice may offer; `compile` refuses a plan over it. */
513
+ options?: number;
514
+ /** The adapter's own token ceiling, declared for the record; nothing here enforces it. */
515
+ tokens?: number;
516
+ }
517
+ /** The floors an adapter ships, each meaning P(correct); `read` never above `write`, and no destructive number exists. */
518
+ export interface Gate {
519
+ route: Prob;
520
+ /** The runner-up's floor; a plan without `fits` questions skips it. */
521
+ fits?: Prob;
522
+ read: Prob;
523
+ write: Prob;
524
+ }
525
+ /** What an adapter declares about itself. */
526
+ export interface Declared {
527
+ id: AdapterId;
528
+ limits?: Limits;
529
+ gate?: Gate;
530
+ }
531
+ /** Answers as the adapter gave them: per question, a number per key. `read` validates them against their `Request`. */
532
+ export type Raw = Record<QuestionId, Record<Key, number>>;
533
+ /** How an adapter fails, or how its answers failed validation; each ends in a fixing command. */
534
+ export type Fault = {
535
+ type: "transport";
536
+ message: string;
537
+ } | {
538
+ type: "status";
539
+ status: number;
540
+ } | {
541
+ type: "refused";
542
+ credential: VarName;
543
+ } | {
544
+ type: "retired";
545
+ id: AdapterId;
546
+ } | {
547
+ type: "unanswered";
548
+ question: QuestionId;
549
+ } | {
550
+ type: "malformed";
551
+ question: QuestionId;
552
+ message: string;
553
+ } | {
554
+ type: "unrecorded";
555
+ identity: Identity;
556
+ };
557
+ /** Everything the host found; `compile` alone judges activity. */
558
+ export interface Installed {
559
+ reflexes: Record<LocalName, Item>;
560
+ vocab: Record<VocabName, Vocabulary>;
561
+ adapter: AdapterId;
562
+ evoke: Version;
563
+ }
564
+ /** One installed reflex as found: its wording or why it has none, the effect and the needs consented to — the lock's for a remote reflex, its own for a local one — and how its config is held. */
565
+ export interface Item {
566
+ wording: Result<Effective, Diagnostic[]>;
567
+ consented: Effect;
568
+ /** Absent: none consented to. */
569
+ needs?: Needs;
570
+ configured: Record<ConfigKey, Held>;
571
+ }
572
+ /** How a set config key is held: the value itself, or a variable that is set or not. Never a secret's value. */
573
+ export type Held = {
574
+ type: "plain";
575
+ value: string;
576
+ } | {
577
+ type: "env";
578
+ var: VarName;
579
+ set: boolean;
580
+ };
581
+ /** A duration in milliseconds; the host makes it an instant. */
582
+ export type Millis = number;
583
+ /** The compiled set: the active reflexes, the inactive ones with a fix per problem, every input-independent question, and the digest that keys what is derived from it. */
584
+ export interface Plan {
585
+ /** SHA-256 of the compact JSON of `Installed`: keys the decision cache and the baselines. */
586
+ digest: Digest;
587
+ active: Record<LocalName, Active>;
588
+ /** Every problem of every inactive reflex, each with its fix. */
589
+ inactive: Record<LocalName, NonEmpty<Diagnostic>>;
590
+ /** The tags of the inactive reflexes whose manifest read; absent when none carries any. */
591
+ tagged?: Record<LocalName, Tag[]>;
592
+ /** `route`, then per active reflex `fits.<name>` and every argument, in that order. */
593
+ slots: Record<QuestionId, Slot>;
594
+ /** Per vocabulary, the words that carry a value. */
595
+ values: Record<VocabName, Record<Word, string>>;
596
+ /** The core's one deadline: 30 000 ms. */
597
+ deadline: Millis;
598
+ }
599
+ /** An active reflex as the decision needs it; `effect` is the tighter of the manifest's and the consented one, `needs` the manifest's declaration narrowed to what was consented to. */
600
+ export interface Active {
601
+ effect: Effect;
602
+ /** Absent: inline, a function the SDK holds. */
603
+ run?: Run;
604
+ /** Absent: the tightest declaration. */
605
+ needs?: Needs;
606
+ confirm: Template;
607
+ args: Record<ArgName, Argument>;
608
+ /** What the body's `data` yields for a later step to take, per field. */
609
+ yields: Record<FieldName, Yield>;
610
+ config: Record<ConfigKey, Setting>;
611
+ tags: Tag[];
612
+ }
613
+ /** A question that does not depend on the input, or a pick whose options exist only per input. */
614
+ export type Slot = Question | {
615
+ type: "pick";
616
+ ask: Clean;
617
+ pick: Recognizer;
618
+ optional: boolean;
619
+ };
620
+ /** A candidate for a pick: where it is in the input, and what its recognizer read. */
621
+ export interface Proposed {
622
+ span: Span;
623
+ value: PickValue;
624
+ }
625
+ /** What a pick hands the body: the number, the seconds, or the text. */
626
+ export type PickValue = {
627
+ type: "number";
628
+ value: number;
629
+ } | {
630
+ type: "duration";
631
+ value: number;
632
+ } | {
633
+ type: "email";
634
+ value: Clean;
635
+ } | {
636
+ type: "url";
637
+ value: Clean;
638
+ } | {
639
+ type: "quoted";
640
+ value: Clean;
641
+ };
642
+ /** What a request asks: everything, or the route alone — the conflict test at `add`. */
643
+ export type Scope = "full" | "route";
644
+ /** What the answers said: the reflexes ranked, every choice read, and the winner with its values. */
645
+ export interface Reading {
646
+ /** Sorted by route probability; `try` prints it. */
647
+ ranking: Contender[];
648
+ judgments: Judgment[];
649
+ /** Absent when `none` won. */
650
+ winner?: Winner;
651
+ }
652
+ /** A reflex in the ranking: its route probability, and its `fits` when that was asked. */
653
+ export interface Contender {
654
+ reflex: LocalName;
655
+ route: Prob;
656
+ fits?: Prob;
657
+ }
658
+ /** The reflex that won the route, with what its arguments read. */
659
+ export interface Winner {
660
+ reflex: LocalName;
661
+ args: Record<ArgName, Value>;
662
+ missing: Missing[];
663
+ /** Typed spans no argument consumed. */
664
+ unconsumed: Span[];
665
+ runner_up?: Contender;
666
+ }
667
+ /** One choice read: which key came out on top, and how probable it was. */
668
+ export interface Judgment {
669
+ question: QuestionId;
670
+ top: Key;
671
+ p: Prob;
672
+ }
673
+ /** An argument without a usable value, and what a person may choose from. */
674
+ export interface Missing {
675
+ arg: ArgName;
676
+ /** The argument's question, as the manifest asks it. */
677
+ ask: Clean;
678
+ because: Why;
679
+ choices: Choices;
680
+ }
681
+ /** Why a value is missing: the input never stated it, or a pick fell outside its range. */
682
+ export type Why = {
683
+ type: "unstated";
684
+ } | {
685
+ type: "out_of_range";
686
+ span: Span;
687
+ range: Range;
688
+ };
689
+ /** What a person may answer with; a vocabulary also prompts to add a word. */
690
+ export type Choices = {
691
+ type: "options";
692
+ options: Record<OptionKey, Clean>;
693
+ } | {
694
+ type: "vocab";
695
+ words: Record<Word, Clean>;
696
+ } | {
697
+ type: "pick";
698
+ pick: Recognizer;
699
+ };
700
+ /** The outcome, tagged by `outcome` on the wire, the chosen call's fields flattened beside it. */
701
+ export type Decision = {
702
+ outcome: "abstain";
703
+ contenders: Contender[];
704
+ judgments: Judgment[];
705
+ } | ({
706
+ outcome: "run";
707
+ } & Chosen) | ({
708
+ outcome: "confirm";
709
+ } & Chosen & {
710
+ prompt: Prompt;
711
+ because: NonEmpty<Cap>;
712
+ }) | ({
713
+ outcome: "ask";
714
+ } & Asking & {
715
+ missing: NonEmpty<Missing>;
716
+ });
717
+ /** A complete call with its effect and, unless called by name, what the classifier judged. */
718
+ export type Chosen = Call & {
719
+ effect: Effect;
720
+ } & (Judged | Unjudged);
721
+ /** Called by name, so nothing was judged: no field of `Judged` is present. */
722
+ export type Unjudged = {
723
+ [K in keyof Judged]?: never;
724
+ };
725
+ /** The judgments a decision rests on: confidence is the weakest one's probability, over the route and every argument question of the winner. */
726
+ export interface Judged {
727
+ /** `weakest.p`: the minimum over `judgments`. */
728
+ confidence: Prob;
729
+ weakest: Judgment;
730
+ judgments: NonEmpty<Judgment>;
731
+ runner_up?: Contender;
732
+ /** The ranking. */
733
+ contenders: Contender[];
734
+ }
735
+ /** An ask in flight: what the gate reads again once the missing values are given. */
736
+ export interface Asking extends Judged {
737
+ reflex: LocalName;
738
+ args: Record<ArgName, Value>;
739
+ /** Typed spans no argument consumed. */
740
+ unconsumed: Span[];
741
+ }
742
+ /** Why a decision stops at confirm; `because` lists them in this order. */
743
+ export type Cap = {
744
+ type: "destructive";
745
+ } | {
746
+ type: "no_gate";
747
+ } | {
748
+ type: "under_floor";
749
+ judgment: Judgment;
750
+ floor: Prob;
751
+ } | {
752
+ type: "unconsumed_span";
753
+ span: Span;
754
+ } | {
755
+ type: "two_things";
756
+ contender: Contender;
757
+ };
758
+ /** The confirm prompt: `evoke`'s own line, then the manifest's template filled in. */
759
+ export interface Prompt {
760
+ /** The call, its effect, the weakest judgment and each cap that names itself, joined by ` · `. */
761
+ own: string;
762
+ template: Clean;
763
+ }
764
+ /** A call resolved and complete; on the wire `{ reflex, args, call }`, the last being its rendering. */
765
+ export interface Call {
766
+ reflex: LocalName;
767
+ args: Record<ArgName, Value>;
768
+ /** The call on one line: the name, then each argument as `name="value"` or a bare flag. */
769
+ call: string;
770
+ }
771
+ /** An argument's value: a key, a word, a verbatim span, or a flag that is present. Never minted by the model. */
772
+ export type Value = {
773
+ type: "option";
774
+ key: OptionKey;
775
+ } | {
776
+ type: "word";
777
+ word: Word;
778
+ /** What the body receives instead of the word, when the vocabulary sets one. */
779
+ value?: string;
780
+ } | {
781
+ type: "pick";
782
+ span: Span;
783
+ value: PickValue;
784
+ } | {
785
+ type: "flag";
786
+ };
787
+ /** A call as typed: `lights room=den state=off`; a bare argument is a flag. Resolved by `by_name` or typed by a lesson, never run as it is. */
788
+ export interface Written {
789
+ reflex: LocalName;
790
+ /** As typed; `null` is written bare, so a flag. */
791
+ args: Record<ArgName, string | null>;
792
+ }
793
+ /** One JSON line on the loader's stdin. */
794
+ export interface Envelope {
795
+ reflex: LocalName;
796
+ /** Absent for an inline body. */
797
+ run?: Run;
798
+ /** An option key, a word's `value` if set else the word, a pick's value, `true` for a flag. */
799
+ args: Record<ArgName, string | number | true>;
800
+ input: Input;
801
+ /** An `env` setting stays a reference; the host resolves it. */
802
+ config: Record<ConfigKey, Setting>;
803
+ deadline: Millis;
804
+ }
805
+ /** A text for the foundation to decide: over the reflexes the tags allow, or one reflex alone. */
806
+ export interface Asked {
807
+ text: string;
808
+ tags?: Tag[];
809
+ only?: LocalName;
810
+ }
811
+ /** What the plan needs a host to do next: judge the split points, name each reference's step, or decide texts. */
812
+ export type Need = {
813
+ type: "judge";
814
+ request: Request;
815
+ } | {
816
+ type: "refer";
817
+ request: Request;
818
+ } | {
819
+ type: "decide";
820
+ asked: Asked[];
821
+ };
822
+ /** What a host gathered for the plan so far. */
823
+ export interface Answers {
824
+ judged?: Raw;
825
+ referred?: Raw;
826
+ decided?: [Asked, Decision][];
827
+ }
828
+ /** The plan, or what it needs first. */
829
+ export type Planning = {
830
+ type: "done";
831
+ weave: Weave;
832
+ } | {
833
+ type: "need";
834
+ need: Need;
835
+ };
836
+ /** What a connective does: `then` orders what follows after what precedes; the rest coordinate. */
837
+ export type Order = "then" | "and";
838
+ /** A place the request may split: the connective's span in characters, its word, whether it orders, and the engine's probability that the two sides are two things. */
839
+ export interface Split {
840
+ start: number;
841
+ end: number;
842
+ word: string;
843
+ order: Order;
844
+ p?: Prob;
845
+ }
846
+ /** The reference word in a step's text, in characters of that text. */
847
+ export interface Where {
848
+ start: number;
849
+ end: number;
850
+ text: string;
851
+ }
852
+ /** A reference in one step to earlier ones: the words, the steps it may name (zero-based), how it was found. */
853
+ export interface Ref {
854
+ span: Where;
855
+ from: number[];
856
+ how: "pronoun" | "phrase" | "engine";
857
+ /** `the <noun>`: a reference only when something takes it. */
858
+ weak?: boolean;
859
+ /** A phrase's noun, singular, which may name a field of the source's result. */
860
+ noun?: string;
861
+ /** Plural: over a result of several records, every one. */
862
+ many?: boolean;
863
+ p?: Prob;
864
+ }
865
+ /** How a segment that matched nothing on its own was settled. */
866
+ export type Repair = "narrowed" | "spliced" | "merged";
867
+ /** One step of the plan: a segment's text and the foundation's decision on it, in the order it is to happen. */
868
+ export interface Step {
869
+ /** From 1, as the plan prints it. */
870
+ n: number;
871
+ text: string;
872
+ /** Where the step's words end in the request, in characters. */
873
+ end: number;
874
+ decision: Decision;
875
+ reflex?: LocalName;
876
+ effect?: Effect;
877
+ refs?: Ref[];
878
+ repair?: Repair;
879
+ /** The steps this one must follow: an explicit `then`, or a binding. */
880
+ after?: number[];
881
+ }
882
+ /** How a bound value reaches its step: answering its own ask, or the step decided again with the value in its words. */
883
+ export type Via = "fill" | "rewrite";
884
+ /** A value of one step's result taken by a later step: which field, into which argument, how. */
885
+ export interface Binding {
886
+ from: number;
887
+ to: number;
888
+ arg: ArgName;
889
+ field: FieldName;
890
+ kind: Recognizer;
891
+ via: Via;
892
+ /** The list field of the source's result whose records carry `field`: the step runs once per record. */
893
+ each?: FieldName;
894
+ }
895
+ /** Why the plan does not simply run; each names its steps. */
896
+ export type Because = {
897
+ type: "nothing_to_do";
898
+ } | {
899
+ type: "no_reflex";
900
+ step: number;
901
+ } | {
902
+ type: "needs";
903
+ step: number;
904
+ arg: ArgName;
905
+ } | {
906
+ type: "several";
907
+ step: number;
908
+ source: number;
909
+ fields: FieldName[];
910
+ } | {
911
+ type: "one_of_many";
912
+ step: number;
913
+ source: number;
914
+ field: FieldName;
915
+ } | {
916
+ type: "takes_nothing";
917
+ step: number;
918
+ sources: number[];
919
+ };
920
+ /** The verdict before anything runs, with every reason. */
921
+ export interface Verdict {
922
+ outcome: "run" | "ask" | "confirm" | "refuse";
923
+ because?: Because[];
924
+ }
925
+ /** The plan: the request in the words' own order, its split points as judged, the steps, what was left out, the bindings, the schedule and the verdict. */
926
+ export interface Weave {
927
+ input: string;
928
+ splits?: Split[];
929
+ steps: Step[];
930
+ /** Fragments left out because they begin with a negation. */
931
+ excluded?: string[];
932
+ binds?: Binding[];
933
+ /** Whether a write is among the steps, so none may run beside another. */
934
+ exclusive: boolean;
935
+ /** A stage's steps run together; stages run in order. */
936
+ stages: number[][];
937
+ verdict: Verdict;
938
+ }
939
+ /** A value bound into a step at its turn. */
940
+ export interface Bound {
941
+ arg: ArgName;
942
+ from: number;
943
+ field: FieldName;
944
+ value: string;
945
+ }
946
+ /** What a body returned: its text, and data when it gave some. */
947
+ export interface Returned {
948
+ text: string;
949
+ data?: Json;
950
+ }
951
+ /** One round of a step for a host to take through the foundation's loop, the bound values in place. */
952
+ export interface Handling {
953
+ step: number;
954
+ /** From 0; a step bound to a list runs one round per record. */
955
+ round: number;
956
+ decision: Decision;
957
+ input: string;
958
+ bound?: Bound[];
959
+ }
960
+ /** What became of a step, or of one of its rounds. */
961
+ export type Status = "ran" | "failed" | "declined" | "refused" | "skipped" | "unanswered";
962
+ /** Why a step did not run, or did not finish. */
963
+ export type WeaveWhy = {
964
+ type: "earlier_step";
965
+ } | {
966
+ type: "nothing_to_take";
967
+ } | {
968
+ type: "found_nothing";
969
+ } | {
970
+ type: "no_reflex";
971
+ } | {
972
+ type: "read_as";
973
+ reflex: LocalName;
974
+ } | {
975
+ type: "said";
976
+ message: string;
977
+ };
978
+ /** What a host made of one round. */
979
+ export interface Handled {
980
+ step: number;
981
+ round: number;
982
+ status: Status;
983
+ why?: WeaveWhy;
984
+ result?: Returned;
985
+ }
986
+ /** What a host gathered for the run so far. */
987
+ export interface Progress {
988
+ decided?: [Asked, Decision][];
989
+ handled?: Handled[];
990
+ }
991
+ /** What the run needs a host to do next. */
992
+ export type Todo = {
993
+ type: "decide";
994
+ asked: Asked;
995
+ } | {
996
+ type: "handle";
997
+ handling: Handling[];
998
+ };
999
+ /** The run, or what it needs first. */
1000
+ export type Running = {
1001
+ type: "done";
1002
+ executed: Executed;
1003
+ } | {
1004
+ type: "todo";
1005
+ todo: Todo;
1006
+ };
1007
+ /** What became of one step. */
1008
+ export interface StepOutcome {
1009
+ step: number;
1010
+ status: Status;
1011
+ why?: WeaveWhy;
1012
+ bound?: Bound[];
1013
+ rounds?: Handled[];
1014
+ }
1015
+ /** The run: per step, what became of it, in plan order; and the whole's status, the worst step's as the exit codes rank them. */
1016
+ export interface Executed {
1017
+ steps: StepOutcome[];
1018
+ worst: Status;
1019
+ }
1020
+ /** What changed in the contract from one version to the next, and how much it matters. */
1021
+ export interface ContractDiff {
1022
+ level: Level;
1023
+ changes: Change[];
1024
+ violations: WasViolation[];
1025
+ }
1026
+ /** `same`: nothing but wording, or a declaration narrowed. `minor`: additions, a declaration widened, and a config key gone. `major`: something a person's files or calls may not survive. */
1027
+ export type Level = "same" | "minor" | "major";
1028
+ /** One change to the contract, in the order the diff walks: the previous arguments, the added ones, the body, what it may touch, config, then what the result yields. */
1029
+ export type Change = {
1030
+ type: "arg_removed";
1031
+ arg: ArgName;
1032
+ } | {
1033
+ type: "option_removed";
1034
+ arg: ArgName;
1035
+ key: OptionKey;
1036
+ } | {
1037
+ type: "arg_renamed";
1038
+ from: ArgName;
1039
+ to: ArgName;
1040
+ } | {
1041
+ type: "source_changed";
1042
+ arg: ArgName;
1043
+ } | {
1044
+ type: "range_changed";
1045
+ arg: ArgName;
1046
+ } | {
1047
+ type: "run_changed";
1048
+ } | {
1049
+ type: "needs_widened";
1050
+ added: Needs;
1051
+ } | {
1052
+ type: "needs_narrowed";
1053
+ removed: Needs;
1054
+ } | {
1055
+ type: "required";
1056
+ arg: ArgName;
1057
+ } | {
1058
+ type: "config_secret";
1059
+ key: ConfigKey;
1060
+ secret: boolean;
1061
+ } | {
1062
+ type: "arg_added";
1063
+ arg: ArgName;
1064
+ } | {
1065
+ type: "optional";
1066
+ arg: ArgName;
1067
+ } | {
1068
+ type: "option_added";
1069
+ arg: ArgName;
1070
+ key: OptionKey;
1071
+ } | {
1072
+ type: "config_added";
1073
+ key: ConfigKey;
1074
+ } | {
1075
+ type: "config_removed";
1076
+ key: ConfigKey;
1077
+ } | {
1078
+ type: "yield_added";
1079
+ field: FieldName;
1080
+ } | {
1081
+ type: "yield_removed";
1082
+ field: FieldName;
1083
+ } | {
1084
+ type: "yield_changed";
1085
+ field: FieldName;
1086
+ };
1087
+ /** `was` is flat and cumulative: a retired name never returns as a live argument, and never leaves the lists. */
1088
+ export type WasViolation = {
1089
+ type: "returned";
1090
+ arg: ArgName;
1091
+ } | {
1092
+ type: "dropped";
1093
+ arg: ArgName;
1094
+ };
1095
+ /** What an update does to the effect a person consented to: upstream may keep or tighten it, and loosens it only through `evoke update --accept`. */
1096
+ export type Consent = {
1097
+ type: "kept";
1098
+ effect: Effect;
1099
+ } | {
1100
+ type: "tightened";
1101
+ effect: Effect;
1102
+ } | {
1103
+ type: "needs_accept";
1104
+ locked: Effect;
1105
+ upstream: Effect;
1106
+ };
1107
+ /** What `lint` finds: a size cap passed, or text that addresses the model instead of describing an action. */
1108
+ export type LintRule = "size_cap" | "addresses_model";
1109
+ /** One thing `lint` found, at the key path it concerns; reported at `add` and by `check`, never a refusal. */
1110
+ export interface Finding {
1111
+ rule: LintRule;
1112
+ path: KeyPath;
1113
+ message: string;
1114
+ }
1115
+ /** One change to an owned file, which the host applies keeping the file's own shape: a key path set, or removed. */
1116
+ export type Edit = {
1117
+ type: "set";
1118
+ file: Owned;
1119
+ path: KeyPath;
1120
+ /** The line's value as JSON: a record, a string, `{ env }` or `{ what, value }`. */
1121
+ value: Json;
1122
+ } | {
1123
+ type: "remove";
1124
+ file: Owned;
1125
+ path: KeyPath;
1126
+ };
1127
+ /** A file `evoke` edits in place; the lock and `evoke.d.ts` are rendered whole, never edited. */
1128
+ export type Owned = {
1129
+ type: "project";
1130
+ } | {
1131
+ type: "overlay";
1132
+ name: LocalName;
1133
+ } | {
1134
+ type: "vocab";
1135
+ name: VocabName;
1136
+ };
1137
+ /** The overlay line itself: which reflex an utterance belongs to and what it asserts; `not <name>` is `false`. */
1138
+ export interface Lesson {
1139
+ reflex: LocalName;
1140
+ /** Names follow `was`; each value is typed against the plan at the door. */
1141
+ record: Asserted;
1142
+ }
1143
+ /** What `evoke vocab <name> add | remove` does to the file. */
1144
+ export type VocabChange = {
1145
+ type: "add";
1146
+ word: Word;
1147
+ meaning: Meaning;
1148
+ } | {
1149
+ type: "remove";
1150
+ word: Word;
1151
+ };
1152
+ /** One record as a test: whose it is, what was said, what should come of it, and the table it came from. */
1153
+ export interface Case {
1154
+ reflex: LocalName;
1155
+ utterance: Utterance;
1156
+ expect: Expected;
1157
+ from: Table;
1158
+ }
1159
+ /** Where a case came from: examples are sent to the classifier, tests are held out. */
1160
+ export type Table = "examples" | "tests";
1161
+ /** What a record expects, as a decision compares to it: `false` for never this reflex, or a claim per argument — `{}` asserts the route alone. */
1162
+ export type Expected = false | Record<ArgName, Claim>;
1163
+ /** One argument's claim: `false` unstated, `true` a flag raised, or the text a decision's value must show — an option key, a word or a span, which all compare as text. What a decision read takes the same shape. */
1164
+ export type Claim = boolean | Clean;
1165
+ /** What a decision made of a case: it passed, or where it first missed. */
1166
+ export type CaseVerdict = {
1167
+ type: "pass";
1168
+ } | {
1169
+ type: "fail";
1170
+ mismatch: Mismatch;
1171
+ };
1172
+ /** Where a decision missed a case: the route — read as another reflex, or as none — or the first asserted argument read as something else. */
1173
+ export type Mismatch = {
1174
+ type: "route";
1175
+ read: LocalName | null;
1176
+ } | {
1177
+ type: "arg";
1178
+ arg: ArgName;
1179
+ read: Claim;
1180
+ };
1181
+ /** The last run's verdict per case, by reflex and utterance identity; the host keeps one per plan digest. */
1182
+ export type Baseline = Record<LocalName, Record<Identity, CaseVerdict>>;
1183
+ /** A case that passed at the last run and fails now, two of three uncached repeats. */
1184
+ export interface Regression {
1185
+ case: Case;
1186
+ now: Mismatch;
1187
+ }
1188
+ /** A phrase an installed reflex claims that a newcomer wins at `add`. */
1189
+ export interface Theft {
1190
+ phrase: Utterance;
1191
+ owner: LocalName;
1192
+ thief: LocalName;
1193
+ }
1194
+ /** The report `evoke calibrate` prints: every record of the active reflexes decided once, or `repeats` times, and judged; each input counts once, by its first decision, the repeats measuring stability. */
1195
+ export interface Calibration {
1196
+ adapter: AdapterId;
1197
+ records: number;
1198
+ reflexes: number;
1199
+ inputs: number;
1200
+ repeats: number;
1201
+ outcomes: Outcomes;
1202
+ /** The whole call right, by the confidence claimed; a bin with no call is left out. */
1203
+ bins: BinRow[];
1204
+ /** Calls no record can judge: a `false` record routed to a reflex no record names. */
1205
+ unknown: number;
1206
+ abstained: Share;
1207
+ bars: Bars;
1208
+ questions: QuestionRow[];
1209
+ brier?: Brier;
1210
+ misses: Miss[];
1211
+ variance?: Variance;
1212
+ }
1213
+ /** How many inputs ended in each outcome. */
1214
+ export interface Outcomes {
1215
+ run: number;
1216
+ confirm: number;
1217
+ ask: number;
1218
+ abstain: number;
1219
+ }
1220
+ /** One bin: the calls whose confidence lies in `lo..hi` — `hi` inside the last bin — how many were right, the Wilson interval of that share, the mean confidence claimed; `over_confident` when the claim is above the interval, `thin` under a hundred calls. */
1221
+ export interface BinRow {
1222
+ lo: Prob;
1223
+ hi: Prob;
1224
+ calls: number;
1225
+ right: number;
1226
+ interval: [Prob, Prob];
1227
+ claimed: Prob;
1228
+ thin: boolean;
1229
+ over_confident: boolean;
1230
+ }
1231
+ /** A count with how many were right, and the Wilson interval of the share. */
1232
+ export interface Share {
1233
+ count: number;
1234
+ right: number;
1235
+ interval: [Prob, Prob];
1236
+ }
1237
+ /** Each effect's bar, for an effect with a judged call under a gate. */
1238
+ export interface Bars {
1239
+ read?: BarRow;
1240
+ write?: BarRow;
1241
+ }
1242
+ /** The calls of one effect at or over its bar: how many were wrong, per thousand, the one-sided bound at 95 % per thousand, and the neighbourhood at the bar and a step either side. */
1243
+ export interface BarRow {
1244
+ bar: Prob;
1245
+ wrong: number;
1246
+ calls: number;
1247
+ per_thousand: number;
1248
+ at_most: number;
1249
+ near: NearRow[];
1250
+ }
1251
+ /** At a threshold: how many calls would run, and how many of those are wrong. */
1252
+ export interface NearRow {
1253
+ at: Prob;
1254
+ run: number;
1255
+ wrong: number;
1256
+ }
1257
+ /** One kind of judgment on its own: the route, or the arguments by source; right when the record names the argument and the decision read it as claimed. */
1258
+ export interface QuestionRow {
1259
+ kind: QuestionKind;
1260
+ judgments: number;
1261
+ right: number;
1262
+ interval: [Prob, Prob];
1263
+ claimed: Prob;
1264
+ }
1265
+ export type QuestionKind = "route" | "options" | "vocab" | "pick" | "flag";
1266
+ /** The Brier score over the calls, and Murphy's parts over the bins. */
1267
+ export interface Brier {
1268
+ brier: number;
1269
+ reliability: number;
1270
+ resolution: number;
1271
+ uncertainty: number;
1272
+ }
1273
+ /** A decision a record proved wrong: the record, what was decided, where it missed; `wrong` counts the repeats that missed the same way. */
1274
+ export interface Miss {
1275
+ case: Case;
1276
+ outcome: "run" | "confirm" | "ask" | "abstain";
1277
+ reflex?: LocalName;
1278
+ confidence?: Prob;
1279
+ mismatch: Mismatch;
1280
+ wrong: number;
1281
+ }
1282
+ /** Over repeats: the inputs whose winner or verdict flipped, the spread of the confidence per input, the inputs straddling the bar of their effect, the calls wrong at or over their bar in any repeat, and what moved most. */
1283
+ export interface Variance {
1284
+ flips: number;
1285
+ verdict_flips: number;
1286
+ spread: Spread;
1287
+ straddling: number;
1288
+ wrong_at_bar: number;
1289
+ moved: Moved[];
1290
+ }
1291
+ export interface Spread {
1292
+ median: number;
1293
+ p90: number;
1294
+ max: number;
1295
+ }
1296
+ /** One input whose repeats moved: the confidence's range, the route's, each winner and outcome with its count, and how many repeats were wrong. */
1297
+ export interface Moved {
1298
+ utterance: string;
1299
+ confidence?: [Prob, Prob];
1300
+ route: [Prob, Prob];
1301
+ winners: Record<string, number>;
1302
+ outcomes: Record<string, number>;
1303
+ wrong: number;
1304
+ }
1305
+ /** One line of the log as the block reads it: what was decided, which adapters answered — none when the cache did — whether the body ran or failed, and a weave step's status. */
1306
+ export interface Logged {
1307
+ input: Input;
1308
+ decision: Decision;
1309
+ adapters?: AdapterId[];
1310
+ ran?: boolean;
1311
+ failed?: boolean;
1312
+ status?: Status;
1313
+ }
1314
+ /** The log's lines under one adapter, counted by what became of each; the confidence of what stopped at a confirm by segment; the lines whose input is a record, judged; and the lines that did not read. */
1315
+ export interface LogBlock {
1316
+ adapter: AdapterId;
1317
+ decisions: number;
1318
+ ran: number;
1319
+ confirmed_ran: number;
1320
+ confirmed_stopped: number;
1321
+ asked: number;
1322
+ abstained: number;
1323
+ failed: number;
1324
+ skipped: number;
1325
+ stopped_by_confidence: Counted[];
1326
+ records: Share;
1327
+ unread: number;
1328
+ }
1329
+ /** A count of confidences in `lo..hi`. */
1330
+ export interface Counted {
1331
+ lo: Prob;
1332
+ hi: Prob;
1333
+ count: number;
1334
+ }
1335
+ /** A door on the System One wire: which address, under which key, naming which model. Its adapter name. */
1336
+ export type Door = "jev" | "openjev";
1337
+ /** What both hosts read before the first call. */
1338
+ export interface Settings {
1339
+ declared: Declared;
1340
+ /** The variable the API key is read from. */
1341
+ credential: VarName;
1342
+ /** Where a key comes from, as the line that asks for one says it. */
1343
+ issuer: string;
1344
+ /** The endpoint both hosts post to. */
1345
+ url: string;
1346
+ policy: Transport;
1347
+ }
1348
+ /** The transport policy as a value, executed by each host: the wait after connect, how many times a connect error or a retried status is tried again, and which statuses those are. */
1349
+ export interface Transport {
1350
+ timeout: Millis;
1351
+ retries: number;
1352
+ /** `[min, max]`, both retried. */
1353
+ retry_statuses: Range;
1354
+ }
1355
+ /** Hand-writable answers keyed by utterance identity, with what the adapter declares — `id`, `limits` and `gate` are its `Declared`, flattened. */
1356
+ export interface Recording {
1357
+ id: AdapterId;
1358
+ limits?: Limits;
1359
+ gate?: Gate;
1360
+ /** The plan the answers were recorded against; the host compares it with `Plan.digest` before calling `answer`. */
1361
+ plan?: Digest;
1362
+ answers: Record<Identity, Raw>;
1363
+ }