@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.
package/dist/ops.d.ts ADDED
@@ -0,0 +1,458 @@
1
+ import type * as T from "./types.ts";
2
+ /** Every op: its argument object, and its reply's ok value — a Result where the function returns one. */
3
+ export interface Ops {
4
+ identity: {
5
+ input: {
6
+ text: string;
7
+ };
8
+ output: T.Identity;
9
+ };
10
+ manifest: {
11
+ input: {
12
+ doc: T.Document;
13
+ };
14
+ output: T.Result<T.Manifest, T.Diagnostic[]>;
15
+ };
16
+ overlay: {
17
+ input: {
18
+ doc: T.Document;
19
+ of: T.Manifest;
20
+ };
21
+ output: T.Result<T.Overlay, T.Diagnostic[]>;
22
+ };
23
+ vocabulary: {
24
+ input: {
25
+ doc: T.Document;
26
+ };
27
+ output: T.Result<T.Vocabulary, T.Diagnostic[]>;
28
+ };
29
+ project: {
30
+ input: {
31
+ doc: T.Document;
32
+ };
33
+ output: T.Result<T.Project, T.Diagnostic[]>;
34
+ };
35
+ lock: {
36
+ input: {
37
+ doc: T.Document;
38
+ };
39
+ output: T.Result<T.Lock, T.Diagnostic[]>;
40
+ };
41
+ render_lock: {
42
+ input: {
43
+ lock: T.Lock;
44
+ };
45
+ output: string;
46
+ };
47
+ location: {
48
+ input: {
49
+ location: T.Location;
50
+ };
51
+ output: string;
52
+ };
53
+ name: {
54
+ input: {
55
+ text: string;
56
+ kind: "local" | "vocab";
57
+ };
58
+ output: T.Result<string, string>;
59
+ };
60
+ reference: {
61
+ input: {
62
+ text: string;
63
+ };
64
+ output: T.Result<[T.Reference, T.Version | null], T.Diagnostic>;
65
+ };
66
+ digest: {
67
+ input: {
68
+ hashed: [T.RelPath, T.Digest][];
69
+ };
70
+ output: T.Digest;
71
+ };
72
+ fix: {
73
+ input: {
74
+ fix: T.Fix;
75
+ invoked?: string;
76
+ };
77
+ output: string;
78
+ };
79
+ fault: {
80
+ input: {
81
+ fault: T.Fault;
82
+ invoked?: string;
83
+ };
84
+ output: {
85
+ message: string;
86
+ command: string;
87
+ };
88
+ };
89
+ version: {
90
+ input: Record<never, never>;
91
+ output: T.Version;
92
+ };
93
+ effective: {
94
+ input: {
95
+ shipped: T.Manifest;
96
+ yours?: T.Overlay;
97
+ };
98
+ output: T.Effective;
99
+ };
100
+ report: {
101
+ input: {
102
+ previous: T.Manifest;
103
+ next: T.Manifest;
104
+ yours?: T.Overlay;
105
+ };
106
+ output: T.Report;
107
+ };
108
+ compile: {
109
+ input: {
110
+ set: T.Installed;
111
+ limits?: T.Limits;
112
+ };
113
+ output: T.Result<T.Plan, T.Diagnostic>;
114
+ };
115
+ propose: {
116
+ input: {
117
+ input: T.Input;
118
+ };
119
+ output: T.Proposed[];
120
+ };
121
+ request: {
122
+ input: {
123
+ plan: T.Plan;
124
+ input: string;
125
+ tags: T.Tag[];
126
+ only?: T.LocalName;
127
+ scope: T.Scope;
128
+ };
129
+ output: T.Result<T.Request, T.Diagnostic>;
130
+ };
131
+ read: {
132
+ input: {
133
+ plan: T.Plan;
134
+ request: T.Request;
135
+ raw: T.Raw;
136
+ };
137
+ output: T.Result<T.Reading, T.Fault>;
138
+ };
139
+ gate: {
140
+ input: {
141
+ plan: T.Plan;
142
+ reading: T.Reading;
143
+ gate?: T.Gate;
144
+ };
145
+ output: T.Decision;
146
+ };
147
+ fill: {
148
+ input: {
149
+ plan: T.Plan;
150
+ asking: T.Asking;
151
+ given: Record<T.ArgName, T.Value>;
152
+ gate?: T.Gate;
153
+ };
154
+ output: T.Decision;
155
+ };
156
+ by_name: {
157
+ input: {
158
+ plan: T.Plan;
159
+ written: T.Written;
160
+ };
161
+ output: T.Result<T.Decision, T.Diagnostic>;
162
+ };
163
+ picked: {
164
+ input: {
165
+ text: string;
166
+ recognizer: T.Recognizer;
167
+ };
168
+ output: T.Value | null;
169
+ };
170
+ values: {
171
+ input: {
172
+ args: Record<T.ArgName, T.Value>;
173
+ };
174
+ output: Record<T.ArgName, string | number | true>;
175
+ };
176
+ call: {
177
+ input: {
178
+ text: string;
179
+ };
180
+ output: T.Result<T.Written, T.Diagnostic>;
181
+ };
182
+ envelope: {
183
+ input: {
184
+ chosen: T.Chosen;
185
+ active: T.Active;
186
+ input: T.Input;
187
+ deadline: T.Millis;
188
+ home: string;
189
+ };
190
+ output: T.Envelope;
191
+ };
192
+ argv: {
193
+ input: {
194
+ chosen: T.Chosen;
195
+ active: T.Active;
196
+ home: string;
197
+ };
198
+ output: T.Result<string[], T.Diagnostic>;
199
+ };
200
+ "needs.resolve": {
201
+ input: {
202
+ needs: T.Needs;
203
+ call: T.Call;
204
+ active: T.Active;
205
+ config: Record<T.ConfigKey, string>;
206
+ home: string;
207
+ };
208
+ output: T.Result<T.Policy, T.Diagnostic>;
209
+ };
210
+ "needs.widens": {
211
+ input: {
212
+ from: T.Needs;
213
+ to: T.Needs;
214
+ };
215
+ output: boolean;
216
+ };
217
+ "needs.consent": {
218
+ input: {
219
+ locked: T.Needs;
220
+ upstream: T.Needs;
221
+ };
222
+ output: T.NeedsConsent;
223
+ };
224
+ "contain.seatbelt": {
225
+ input: {
226
+ policy: T.Policy;
227
+ facts: T.Facts;
228
+ };
229
+ output: string;
230
+ };
231
+ "contain.node_flags": {
232
+ input: {
233
+ policy: T.Policy;
234
+ facts: T.Facts;
235
+ };
236
+ output: string[];
237
+ };
238
+ "contain.landlock": {
239
+ input: {
240
+ policy: T.Policy;
241
+ facts: T.Facts;
242
+ };
243
+ output: T.Rule[];
244
+ };
245
+ "needs.declared_at": {
246
+ input: {
247
+ doc: T.Document;
248
+ };
249
+ output: T.At;
250
+ };
251
+ "needs.lacking": {
252
+ input: {
253
+ lacking: T.Lacking;
254
+ reflex: T.LocalName;
255
+ active: T.Active;
256
+ origin: T.Origin;
257
+ home: string;
258
+ };
259
+ output: T.Diagnostic;
260
+ };
261
+ "needs.refusal": {
262
+ input: {
263
+ policy: T.Policy;
264
+ upstream?: T.Policy;
265
+ reflex: T.LocalName;
266
+ origin: T.Origin;
267
+ refused: T.Refused;
268
+ home: string;
269
+ };
270
+ output: T.Diagnostic | null;
271
+ };
272
+ teach: {
273
+ input: {
274
+ plan: T.Plan;
275
+ utterance: T.Utterance;
276
+ lesson: T.Lesson;
277
+ };
278
+ output: T.Result<T.Edit, T.Diagnostic>;
279
+ };
280
+ set_config: {
281
+ input: {
282
+ name: T.LocalName;
283
+ key: T.ConfigKey;
284
+ setting: T.Setting;
285
+ spec: T.ConfigSpec;
286
+ };
287
+ output: T.Result<T.Edit, T.Diagnostic>;
288
+ };
289
+ vocab_edit: {
290
+ input: {
291
+ name: T.VocabName;
292
+ change: T.VocabChange;
293
+ };
294
+ output: T.Edit;
295
+ };
296
+ add_entry: {
297
+ input: {
298
+ name: T.LocalName;
299
+ location: T.Location;
300
+ };
301
+ output: T.Edit;
302
+ };
303
+ remove_entry: {
304
+ input: {
305
+ name: T.LocalName;
306
+ };
307
+ output: T.Edit;
308
+ };
309
+ diff: {
310
+ input: {
311
+ previous: T.Manifest;
312
+ next: T.Manifest;
313
+ };
314
+ output: T.ContractDiff;
315
+ };
316
+ consent: {
317
+ input: {
318
+ locked: T.Effect;
319
+ upstream: T.Effect;
320
+ };
321
+ output: T.Consent;
322
+ };
323
+ lint: {
324
+ input: {
325
+ manifest: T.Manifest;
326
+ };
327
+ output: T.Finding[];
328
+ };
329
+ reflex_dts: {
330
+ input: {
331
+ manifest: T.Manifest;
332
+ };
333
+ output: string;
334
+ };
335
+ project_dts: {
336
+ input: {
337
+ set: T.Installed;
338
+ };
339
+ output: string;
340
+ };
341
+ cases: {
342
+ input: {
343
+ set: T.Installed;
344
+ };
345
+ output: T.Case[];
346
+ };
347
+ judge: {
348
+ input: {
349
+ case: T.Case;
350
+ decision: T.Decision;
351
+ };
352
+ output: T.CaseVerdict;
353
+ };
354
+ regressions: {
355
+ input: {
356
+ before: T.Baseline;
357
+ judged: [T.Case, T.NonEmpty<T.CaseVerdict>][];
358
+ };
359
+ output: T.Regression[];
360
+ };
361
+ baseline: {
362
+ input: {
363
+ before: T.Baseline;
364
+ judged: [T.Case, T.NonEmpty<T.CaseVerdict>][];
365
+ };
366
+ output: T.Baseline;
367
+ };
368
+ thieves: {
369
+ input: {
370
+ newcomers: T.LocalName[];
371
+ routed: [T.Case, T.LocalName | null][];
372
+ };
373
+ output: T.Theft[];
374
+ };
375
+ calibrate: {
376
+ input: {
377
+ adapter: T.AdapterId;
378
+ gate?: T.Gate;
379
+ plan: T.Plan;
380
+ judged: [T.Case, T.NonEmpty<T.Decision>][];
381
+ };
382
+ output: T.Calibration;
383
+ };
384
+ "calibrate.log": {
385
+ input: {
386
+ adapter: T.AdapterId;
387
+ gate?: T.Gate;
388
+ lines: T.Logged[];
389
+ cases: T.Case[];
390
+ unread: number;
391
+ };
392
+ output: T.LogBlock;
393
+ };
394
+ "weave.plan": {
395
+ input: {
396
+ plan: T.Plan;
397
+ input: string;
398
+ tags: T.Tag[];
399
+ answers: T.Answers;
400
+ };
401
+ output: T.Result<T.Planning, T.Fault>;
402
+ };
403
+ "weave.execute": {
404
+ input: {
405
+ plan: T.Plan;
406
+ gate?: T.Gate;
407
+ weave: T.Weave;
408
+ progress: T.Progress;
409
+ };
410
+ output: T.Running;
411
+ };
412
+ "systemone.settings": {
413
+ input: {
414
+ door: T.Door;
415
+ table?: T.Json;
416
+ };
417
+ output: T.Result<T.Settings, T.Diagnostic[]>;
418
+ };
419
+ "systemone.request": {
420
+ input: {
421
+ request: T.Request;
422
+ };
423
+ output: T.Json;
424
+ };
425
+ "systemone.answers": {
426
+ input: {
427
+ status: number;
428
+ body: string;
429
+ credential: T.VarName;
430
+ };
431
+ output: T.Result<T.Raw, T.Fault>;
432
+ };
433
+ "replay.recording": {
434
+ input: {
435
+ toml: string;
436
+ };
437
+ output: T.Result<T.Recording, string>;
438
+ };
439
+ "replay.render": {
440
+ input: {
441
+ recording: T.Recording;
442
+ };
443
+ output: string;
444
+ };
445
+ "replay.answer": {
446
+ input: {
447
+ recording: T.Recording;
448
+ request: T.Request;
449
+ };
450
+ output: T.Result<T.Raw, T.Fault>;
451
+ };
452
+ }
453
+ export type Op = keyof Ops;
454
+ /** One vector of spec/vectors/<op>/: the op's arguments, and what it must answer. */
455
+ export type Vector<O extends Op> = {
456
+ input: Ops[O]["input"];
457
+ expect: Ops[O]["output"];
458
+ };
package/dist/ops.js ADDED
@@ -0,0 +1,4 @@
1
+ // The op table as types: every op's argument object and what it answers, mirroring crates/evoke-wasm/src/ops.rs
2
+ // name for name. A Result op answers { ok } | { err }; any other answers its value under ok. The vectors pin this
3
+ // table: build/vectors.ts makes every case satisfy Vector<op>.
4
+ export {};
@@ -0,0 +1,138 @@
1
+ import { type Adapter } from "./adapter.ts";
2
+ import type { AnyReflexes, Ask, Confirm, Decision, Given, Handled, Run } from "./decision.ts";
3
+ import { type Problem } from "./errors.ts";
4
+ import type { Inline } from "./reflex.ts";
5
+ import { type Result } from "./runtime.ts";
6
+ import type * as W from "./types.ts";
7
+ export interface LoadOptions<R = AnyReflexes> {
8
+ /** The project directory: evoke.toml, evoke.lock, overlays/, vocab/, local reflexes. Absent: no files at all. */
9
+ root?: string | undefined;
10
+ /** Reflexes handed as code, by local name; a name evoke.toml also lists is an error. Overlays under root apply.
11
+ * R is inferred from this map when no root is given; with a root, write `load<Reflexes & ReflexesOf<typeof own>>`. */
12
+ reflexes?: {
13
+ [K in keyof R]?: Inline<R[K]> | undefined;
14
+ } | undefined;
15
+ /** Who answers. Absent: the adapter evoke.toml names, from its own subpath; required without a root. */
16
+ adapter?: Adapter | undefined;
17
+ }
18
+ export interface DecideOptions {
19
+ /** Only reflexes carrying one of these tags are offered. */
20
+ tags?: string[] | undefined;
21
+ /** This reflex alone is offered: how a weave decides a fragment, or a step with a value written into its words. */
22
+ only?: string | undefined;
23
+ /** Aborts the adapter call; `decide` rejects with the signal's reason. */
24
+ signal?: AbortSignal | undefined;
25
+ }
26
+ export interface RunOptions {
27
+ /** Aborts the body: its `signal` in-process, its group otherwise; `run` rejects with the signal's reason. */
28
+ signal?: AbortSignal | undefined;
29
+ }
30
+ export interface Handlers<R = AnyReflexes> {
31
+ /** Asked at a confirm: `true` runs, `false` declines. Absent and reached: `unanswered`. */
32
+ confirm?: ((decision: Confirm<R>) => boolean | Promise<boolean>) | undefined;
33
+ /** Asked at an ask: answers by argument name, or `undefined` to decline; asked again when an answer does not
34
+ * read or leaves something missing, and declined when it changes nothing. Absent and reached: `unanswered`. */
35
+ ask?: ((decision: Ask<R>) => Given<Ask<R>> | undefined | Promise<Given<Ask<R>> | undefined>) | undefined;
36
+ }
37
+ /** Which step of a weave, and which of its rounds, a handler is asked for. */
38
+ export interface Turn {
39
+ /** From 1, as the plan numbers them. */
40
+ step: number;
41
+ /** From 0; a step bound to a list runs one round per record. */
42
+ round: number;
43
+ }
44
+ /** What `weave` takes beside the decision's options: `handle`'s handlers, each told which step asks, and one
45
+ * more for the plan itself. */
46
+ export interface WeaveOptions<R = AnyReflexes> extends DecideOptions {
47
+ /** Asked at a step's confirm: `true` runs, `false` declines the step, which ends the weave after its stage.
48
+ * Absent and reached: the step is `unanswered`. */
49
+ confirm?: ((decision: Confirm<R>, turn: Turn) => boolean | Promise<boolean>) | undefined;
50
+ /** Asked at a step's ask — before anything runs for a required argument no binding covers, else at the step's
51
+ * turn — as `handle` asks one. Absent and reached: `unanswered`. */
52
+ ask?: ((decision: Ask<R>, turn: Turn) => Given<Ask<R>> | undefined | Promise<Given<Ask<R>> | undefined>) | undefined;
53
+ /** Asked when the plan holds at confirm — a step refers to another whose result it takes nothing from: `true`
54
+ * runs the plan as it stands. Absent and reached: nothing runs. */
55
+ proceed?: ((plan: W.Weave) => boolean | Promise<boolean>) | undefined;
56
+ }
57
+ /** One round of a step as it ran: the decision the loop settled, the input its body saw, what became of it. */
58
+ export interface WovenRound<R = AnyReflexes> {
59
+ round: number;
60
+ input: string;
61
+ decision: Decision<R>;
62
+ status: W.Status;
63
+ why?: W.WeaveWhy | undefined;
64
+ result?: Result | undefined;
65
+ }
66
+ /** What became of one step of a weave. */
67
+ export interface WovenStep<R = AnyReflexes> {
68
+ step: number;
69
+ status: W.Status;
70
+ why?: W.WeaveWhy | undefined;
71
+ bound: W.Bound[];
72
+ rounds: WovenRound<R>[];
73
+ }
74
+ /** A request planned and run: the plan; the whole's status — the worst step's, as the exit codes rank them, or
75
+ * why nothing ran: refused by the verdict, declined or unanswered at what the plan asked first; per step what
76
+ * became of it, none when nothing ran. */
77
+ export interface Woven<R = AnyReflexes> {
78
+ plan: W.Weave;
79
+ status: W.Status;
80
+ steps: WovenStep<R>[];
81
+ }
82
+ /** Vocabularies in the file's form: per name, word → what it means, or `{ what, value? }`. */
83
+ export type Vocab = Record<string, Record<string, string | {
84
+ what: string;
85
+ value?: string | undefined;
86
+ }>>;
87
+ /** A reflex the project holds: active, with its effect and how it runs; or inactive, with each problem and its fix. */
88
+ export type ReflexStatus = {
89
+ active: true;
90
+ effect: W.Effect;
91
+ runs: "inline" | "file" | "argv";
92
+ } | {
93
+ active: false;
94
+ problems: Problem[];
95
+ };
96
+ export interface Project<R = AnyReflexes> {
97
+ /** Every reflex the project holds. */
98
+ readonly reflexes: Readonly<Record<string, ReflexStatus>>;
99
+ /** The plan's digest — `h1:<hex>` — which every decision carries and a recording may pin. */
100
+ readonly plan: string;
101
+ /** This project over vocabularies of the call's own, compiled to their own plan; nothing else changes. */
102
+ with(options: {
103
+ vocab: Vocab;
104
+ }): Project<R>;
105
+ /** One input decided: asked, answered, read, gated. Runs nothing. */
106
+ decide(input: string, options?: DecideOptions): Promise<Decision<R>>;
107
+ /** An ask answered — an option's key, else the text a person typed — and gated again. */
108
+ fill<D extends Ask<R>>(decision: D, given: Given<D>): Decision<R>;
109
+ /** The chosen call's body: in-process, in a child through the loader, or as an argv. */
110
+ run(decision: Run<R>, options?: RunOptions): Promise<Result>;
111
+ /** A confirm decision runs only once confirmed. */
112
+ run(decision: Confirm<R>, options: RunOptions & {
113
+ confirmed: true;
114
+ }): Promise<Result>;
115
+ /** The whole loop: decide; ask and fill until nothing is missing; confirm; run. */
116
+ handle(input: string, options?: DecideOptions & Handlers<R>): Promise<Handled<R>>;
117
+ /** One request read into its steps, each decided as `decide` decides one, ordered by the words, a result of
118
+ * one threaded into a later one: the plan alone, its verdict before anything runs. Runs nothing. */
119
+ steps(input: string, options?: DecideOptions): Promise<W.Weave>;
120
+ /** The steps, what the plan asks first answered, then every step run stage by stage under the same handlers. */
121
+ weave(input: string, options?: WeaveOptions<R>): Promise<Woven<R>>;
122
+ }
123
+ /** A project from its root: its installed reflexes are what `Reflexes` from evoke.d.ts names, so R is written. */
124
+ export declare function load<R extends object = AnyReflexes>(options: {
125
+ root: string;
126
+ reflexes?: NoInfer<{
127
+ [K in keyof R]?: Inline<R[K]> | undefined;
128
+ }> | undefined;
129
+ adapter?: Adapter | undefined;
130
+ }): Promise<Project<R>>;
131
+ /** A project from reflexes handed as code alone: R is inferred from them. */
132
+ export declare function load<R extends object = AnyReflexes>(options: {
133
+ root?: undefined;
134
+ reflexes?: {
135
+ [K in keyof R]?: Inline<R[K]> | undefined;
136
+ } | undefined;
137
+ adapter: Adapter;
138
+ }): Promise<Project<R>>;