@lute-lang/runtime 0.40.0 → 0.41.1

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,2168 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __returnValue = (v) => v;
3
+ function __exportSetter(name, newValue) {
4
+ this[name] = __returnValue.bind(null, newValue);
5
+ }
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true,
11
+ configurable: true,
12
+ set: __exportSetter.bind(all, name)
13
+ });
14
+ };
15
+
16
+ // src/generated/Ir.ts
17
+ var exports_Ir = {};
18
+ __export(exports_Ir, {
19
+ Command: () => Command,
20
+ artifactMeta: () => artifactMeta,
21
+ atomEntry: () => atomEntry,
22
+ bodyEntry: () => bodyEntry,
23
+ celEnv: () => celEnv,
24
+ celSlot: () => celSlot,
25
+ choiceOption: () => choiceOption,
26
+ clockDecl: () => clockDecl,
27
+ cmdAccept: () => cmdAccept,
28
+ cmdActor: () => cmdActor,
29
+ cmdAssert: () => cmdAssert,
30
+ cmdBarrier: () => cmdBarrier,
31
+ cmdBeat: () => cmdBeat,
32
+ cmdBg: () => cmdBg,
33
+ cmdCamera: () => cmdCamera,
34
+ cmdCg: () => cmdCg,
35
+ cmdChoice: () => cmdChoice,
36
+ cmdEnd: () => cmdEnd,
37
+ cmdEntry: () => cmdEntry,
38
+ cmdHub: () => cmdHub,
39
+ cmdJump: () => cmdJump,
40
+ cmdLine: () => cmdLine,
41
+ cmdMatch: () => cmdMatch,
42
+ cmdMusic: () => cmdMusic,
43
+ cmdOn: () => cmdOn,
44
+ cmdPlugin: () => cmdPlugin,
45
+ cmdQuest: () => cmdQuest,
46
+ cmdRetract: () => cmdRetract,
47
+ cmdSequence: () => cmdSequence,
48
+ cmdSet: () => cmdSet,
49
+ cmdSfx: () => cmdSfx,
50
+ cmdVfx: () => cmdVfx,
51
+ cmdVideo: () => cmdVideo,
52
+ effect: () => effect,
53
+ effectSource: () => effectSource,
54
+ entityKindEntry: () => entityKindEntry,
55
+ enumEntry: () => enumEntry,
56
+ exprNode: () => exprNode,
57
+ family: () => family,
58
+ fieldType: () => fieldType,
59
+ forKind: () => forKind,
60
+ hubOption: () => hubOption,
61
+ indexBeat: () => indexBeat,
62
+ indexDef: () => indexDef,
63
+ indexDocument: () => indexDocument,
64
+ indexEntry: () => indexEntry,
65
+ indexOccasion: () => indexOccasion,
66
+ indexStateDomain: () => indexStateDomain,
67
+ labelForms: () => labelForms,
68
+ loreMeta: () => loreMeta,
69
+ matchArm: () => matchArm,
70
+ objectiveEntry: () => objectiveEntry,
71
+ placeholder: () => placeholder,
72
+ placeholderFormat: () => placeholderFormat,
73
+ placeholderForms: () => placeholderForms,
74
+ position: () => position,
75
+ prereqEdgeEntry: () => prereqEdgeEntry,
76
+ prereqFormula: () => prereqFormula,
77
+ projectIndex: () => projectIndex,
78
+ provenance: () => provenance,
79
+ questMeta: () => questMeta,
80
+ relationEntry: () => relationEntry,
81
+ rewardEntry: () => rewardEntry,
82
+ role: () => role,
83
+ ruleEntry: () => ruleEntry,
84
+ sceneBeat: () => sceneBeat,
85
+ sceneMeta: () => sceneMeta,
86
+ sectionEntry: () => sectionEntry,
87
+ seedFactEntry: () => seedFactEntry,
88
+ segment: () => segment,
89
+ segments: () => segments,
90
+ source: () => source,
91
+ stateEntry: () => stateEntry,
92
+ targetKind: () => targetKind,
93
+ termEntry: () => termEntry,
94
+ timing: () => timing
95
+ });
96
+ import * as Schema from "effect/Schema";
97
+ var provenance = Schema.Struct({
98
+ by: Schema.String,
99
+ explanation: Schema.String
100
+ });
101
+ var source = Schema.Struct({
102
+ component: Schema.String
103
+ });
104
+ var position = Schema.String;
105
+ var family = Schema.Literals([
106
+ "content",
107
+ "staging",
108
+ "state",
109
+ "control",
110
+ "declaration",
111
+ "plugin"
112
+ ]);
113
+ var timing = Schema.Struct({
114
+ wait: Schema.optionalKey(Schema.Boolean),
115
+ duration: Schema.optionalKey(Schema.Number.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))),
116
+ delay: Schema.optionalKey(Schema.Number.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))),
117
+ at: Schema.optionalKey(Schema.Number.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))),
118
+ timeline: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))))
119
+ });
120
+ var segment = Schema.Union([
121
+ Schema.Struct({
122
+ text: Schema.String,
123
+ styles: Schema.optionalKey(Schema.Array(Schema.String)),
124
+ rate: Schema.optionalKey(Schema.Number)
125
+ }),
126
+ Schema.Struct({
127
+ pause: Schema.Number.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))
128
+ })
129
+ ]);
130
+ var segments = Schema.Array(Schema.suspend(() => segment));
131
+ var exprNode = Schema.Union([
132
+ Schema.Struct({
133
+ int: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(-9007199254740992)))
134
+ }),
135
+ Schema.Struct({
136
+ double: Schema.Number
137
+ }),
138
+ Schema.Struct({
139
+ bool: Schema.Boolean
140
+ }),
141
+ Schema.Struct({
142
+ string: Schema.String
143
+ }),
144
+ Schema.Struct({
145
+ list: Schema.Array(Schema.Json)
146
+ }),
147
+ Schema.Struct({
148
+ path: Schema.String
149
+ }),
150
+ Schema.Struct({
151
+ index: Schema.Json,
152
+ key: Schema.Json
153
+ }),
154
+ Schema.Struct({
155
+ has: Schema.String
156
+ }),
157
+ Schema.Struct({
158
+ op: Schema.Literals([
159
+ "!",
160
+ "-"
161
+ ]),
162
+ l: Schema.Json
163
+ }),
164
+ Schema.Struct({
165
+ op: Schema.Literals([
166
+ "&&",
167
+ "||",
168
+ "==",
169
+ "!=",
170
+ "<",
171
+ "<=",
172
+ ">",
173
+ ">=",
174
+ "+",
175
+ "-",
176
+ "*",
177
+ "/",
178
+ "%",
179
+ "in"
180
+ ]),
181
+ l: Schema.Json,
182
+ r: Schema.Json
183
+ }),
184
+ Schema.Struct({
185
+ cond: Schema.Json,
186
+ then: Schema.Json,
187
+ else: Schema.Json
188
+ }),
189
+ Schema.Struct({
190
+ call: Schema.String,
191
+ args: Schema.Array(Schema.Json)
192
+ }),
193
+ Schema.Struct({
194
+ param: Schema.String
195
+ })
196
+ ]);
197
+ var celSlot = Schema.Struct({
198
+ cel: Schema.String,
199
+ expr: Schema.Json,
200
+ authored: Schema.optionalKey(Schema.String)
201
+ });
202
+ var celEnv = Schema.Struct({
203
+ variables: Schema.Array(Schema.Struct({
204
+ name: Schema.String,
205
+ type: Schema.String
206
+ })),
207
+ functions: Schema.Array(Schema.Struct({
208
+ name: Schema.String,
209
+ overloads: Schema.Array(Schema.Struct({
210
+ params: Schema.Array(Schema.String),
211
+ result: Schema.String
212
+ }))
213
+ }))
214
+ });
215
+ var placeholder = Schema.Union([
216
+ Schema.Struct({
217
+ kind: Schema.Literal("path"),
218
+ path: Schema.String,
219
+ format: Schema.optionalKey(Schema.suspend(() => placeholderFormat)),
220
+ forms: Schema.optionalKey(Schema.suspend(() => placeholderForms))
221
+ }),
222
+ Schema.Struct({
223
+ kind: Schema.Literal("ref"),
224
+ ref: Schema.String,
225
+ expr: Schema.optionalKey(Schema.suspend(() => celSlot)),
226
+ format: Schema.optionalKey(Schema.suspend(() => placeholderFormat)),
227
+ forms: Schema.optionalKey(Schema.suspend(() => placeholderForms))
228
+ }),
229
+ Schema.Struct({
230
+ kind: Schema.Literal("reserved"),
231
+ token: Schema.String,
232
+ format: Schema.optionalKey(Schema.suspend(() => placeholderFormat))
233
+ }),
234
+ Schema.Struct({
235
+ kind: Schema.Literal("occasionTarget"),
236
+ entityKind: Schema.String,
237
+ format: Schema.optionalKey(Schema.suspend(() => placeholderFormat))
238
+ })
239
+ ]).pipe(Schema.toTaggedUnion("kind"));
240
+ var placeholderFormat = Schema.Literals([
241
+ "ordinal",
242
+ "ordinalWord",
243
+ "cardinalWord",
244
+ "plural",
245
+ "capitalize",
246
+ "start",
247
+ "indefinite"
248
+ ]);
249
+ var labelForms = Schema.Record(Schema.String, Schema.Struct({
250
+ start: Schema.optionalKey(Schema.String),
251
+ indefinite: Schema.optionalKey(Schema.String)
252
+ }));
253
+ var placeholderForms = Schema.Array(Schema.String);
254
+ var role = Schema.Literals([
255
+ "dialogue",
256
+ "narration",
257
+ "mono",
258
+ "os",
259
+ "vo"
260
+ ]);
261
+ var entityKindEntry = Schema.Struct({
262
+ name: Schema.String,
263
+ members: Schema.optionalKey(Schema.Array(Schema.String)),
264
+ open: Schema.Boolean,
265
+ labels: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
266
+ labelForms: Schema.optionalKey(Schema.suspend(() => labelForms))
267
+ });
268
+ var enumEntry = Schema.Struct({
269
+ name: Schema.String,
270
+ members: Schema.Array(Schema.String),
271
+ labels: Schema.optionalKey(Schema.Record(Schema.String, Schema.String))
272
+ });
273
+ var relationEntry = Schema.Struct({
274
+ name: Schema.String,
275
+ args: Schema.Array(Schema.String),
276
+ tier: Schema.optionalKey(Schema.String),
277
+ derive: Schema.Boolean,
278
+ reserved: Schema.Boolean,
279
+ key: Schema.optionalKey(Schema.Array(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))))),
280
+ excludes: Schema.optionalKey(Schema.Array(Schema.String))
281
+ });
282
+ var seedFactEntry = Schema.Struct({
283
+ relation: Schema.String,
284
+ args: Schema.Array(Schema.String)
285
+ });
286
+ var termEntry = Schema.Union([
287
+ Schema.Struct({
288
+ kind: Schema.Literal("var"),
289
+ name: Schema.String
290
+ }),
291
+ Schema.Struct({
292
+ kind: Schema.Literal("const"),
293
+ value: Schema.String
294
+ })
295
+ ]).pipe(Schema.toTaggedUnion("kind"));
296
+ var atomEntry = Schema.Struct({
297
+ relation: Schema.String,
298
+ terms: Schema.Array(Schema.suspend(() => termEntry))
299
+ });
300
+ var bodyEntry = Schema.Union([
301
+ Schema.Struct({
302
+ kind: Schema.Literal("atom"),
303
+ atom: Schema.suspend(() => atomEntry),
304
+ negated: Schema.Boolean
305
+ }),
306
+ Schema.Struct({
307
+ kind: Schema.Literal("guard"),
308
+ cel: Schema.suspend(() => celSlot)
309
+ }),
310
+ Schema.Struct({
311
+ kind: Schema.Literal("cmp"),
312
+ lhs: Schema.suspend(() => termEntry),
313
+ rhs: Schema.suspend(() => termEntry),
314
+ negated: Schema.Boolean
315
+ }),
316
+ Schema.Struct({
317
+ kind: Schema.Literal("count"),
318
+ atom: Schema.suspend(() => atomEntry),
319
+ distinct: Schema.optionalKey(Schema.Array(Schema.String)),
320
+ op: Schema.Literals([
321
+ "==",
322
+ "!=",
323
+ "<",
324
+ "<=",
325
+ ">",
326
+ ">="
327
+ ]),
328
+ n: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))
329
+ })
330
+ ]).pipe(Schema.toTaggedUnion("kind"));
331
+ var ruleEntry = Schema.Struct({
332
+ head: Schema.suspend(() => atomEntry),
333
+ body: Schema.Array(Schema.suspend(() => bodyEntry)),
334
+ raw: Schema.String
335
+ });
336
+ var prereqEdgeEntry = Schema.Struct({
337
+ node: Schema.String,
338
+ after: Schema.optionalKey(Schema.String),
339
+ follows: Schema.optionalKey(Schema.String),
340
+ formula: Schema.optionalKey(Schema.Json)
341
+ }).check(Schema.makeFilter((value) => [
342
+ [
343
+ "after"
344
+ ],
345
+ [
346
+ "follows"
347
+ ]
348
+ ].filter((keys) => keys.every((key) => (key in value))).length === 1 || "expected exactly one of the key sets: after | follows"));
349
+ var prereqFormula = Schema.Union([
350
+ Schema.Struct({
351
+ visited: Schema.String
352
+ }),
353
+ Schema.Struct({
354
+ completed: Schema.String
355
+ }),
356
+ Schema.Struct({
357
+ active: Schema.String
358
+ }),
359
+ Schema.Struct({
360
+ and: Schema.Tuple([
361
+ Schema.Json,
362
+ Schema.Json
363
+ ])
364
+ }),
365
+ Schema.Struct({
366
+ or: Schema.Tuple([
367
+ Schema.Json,
368
+ Schema.Json
369
+ ])
370
+ })
371
+ ]);
372
+ var sceneMeta = Schema.Struct({
373
+ id: Schema.String,
374
+ character: Schema.optionalKey(Schema.String),
375
+ season: Schema.optionalKey(Schema.Int),
376
+ episode: Schema.optionalKey(Schema.Int),
377
+ episodeId: Schema.optionalKey(Schema.String),
378
+ title: Schema.optionalKey(Schema.String),
379
+ extra: Schema.optionalKey(Schema.Record(Schema.String, Schema.Union([
380
+ Schema.String,
381
+ Schema.Int,
382
+ Schema.Number,
383
+ Schema.Boolean,
384
+ Schema.Array(Schema.Union([
385
+ Schema.String,
386
+ Schema.Int,
387
+ Schema.Number,
388
+ Schema.Boolean
389
+ ]))
390
+ ]))),
391
+ plugin: Schema.optionalKey(Schema.Json),
392
+ beat: Schema.optionalKey(Schema.suspend(() => sceneBeat))
393
+ });
394
+ var targetKind = Schema.Struct({
395
+ kind: Schema.String,
396
+ prefix: Schema.String,
397
+ members: Schema.Array(Schema.String)
398
+ });
399
+ var forKind = Schema.Struct({
400
+ kind: Schema.String,
401
+ members: Schema.Array(Schema.String)
402
+ });
403
+ var sceneBeat = Schema.Struct({
404
+ on: Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$")))),
405
+ targetKind: Schema.optionalKey(Schema.suspend(() => targetKind)),
406
+ forKind: Schema.optionalKey(Schema.suspend(() => forKind)),
407
+ target: Schema.optionalKey(Schema.String),
408
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
409
+ priority: Schema.Int,
410
+ once: Schema.Union([
411
+ Schema.Literals([
412
+ "run",
413
+ "user",
414
+ "none",
415
+ "day",
416
+ "slot",
417
+ "week"
418
+ ]),
419
+ Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^season:[A-Za-z0-9_][A-Za-z0-9_-]*$"))))
420
+ ]),
421
+ also: Schema.optionalKey(Schema.Literal(true)),
422
+ spentBy: Schema.optionalKey(Schema.suspend(() => celSlot)),
423
+ share: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
424
+ advances: Schema.optionalKey(Schema.Union([
425
+ Schema.Literals([
426
+ "slot",
427
+ "day"
428
+ ]),
429
+ Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1)))
430
+ ]))
431
+ });
432
+ var questMeta = Schema.Struct({
433
+ id: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$"))))),
434
+ title: Schema.optionalKey(Schema.String),
435
+ contentLang: Schema.optionalKey(Schema.String),
436
+ extra: Schema.optionalKey(Schema.Record(Schema.String, Schema.Union([
437
+ Schema.String,
438
+ Schema.Int,
439
+ Schema.Number,
440
+ Schema.Boolean,
441
+ Schema.Array(Schema.Union([
442
+ Schema.String,
443
+ Schema.Int,
444
+ Schema.Number,
445
+ Schema.Boolean
446
+ ]))
447
+ ]))),
448
+ plugin: Schema.optionalKey(Schema.Json)
449
+ });
450
+ var stateEntry = Schema.Struct({
451
+ path: Schema.String,
452
+ type: Schema.String,
453
+ domain: Schema.optionalKey(Schema.Array(Schema.String)),
454
+ default: Schema.optionalKey(Schema.Json),
455
+ owner: Schema.optionalKey(Schema.Literals([
456
+ "engine"
457
+ ])),
458
+ provenance: Schema.optionalKey(Schema.String),
459
+ labels: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
460
+ labelForms: Schema.optionalKey(Schema.suspend(() => labelForms))
461
+ });
462
+ var effectSource = Schema.Union([
463
+ Schema.Struct({
464
+ bridgeResult: Schema.String
465
+ }),
466
+ Schema.Struct({
467
+ op: Schema.String,
468
+ by: Schema.Number
469
+ }),
470
+ Schema.Union([
471
+ Schema.Boolean,
472
+ Schema.Number,
473
+ Schema.String
474
+ ])
475
+ ]);
476
+ var effect = Schema.Struct({
477
+ path: Schema.String,
478
+ from: Schema.suspend(() => effectSource)
479
+ });
480
+ var choiceOption = Schema.Struct({
481
+ id: Schema.String,
482
+ text: Schema.String,
483
+ lineId: Schema.String,
484
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
485
+ target: Schema.suspend(() => position),
486
+ placeholders: Schema.optionalKey(Schema.Array(Schema.suspend(() => placeholder))),
487
+ texts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String))
488
+ });
489
+ var hubOption = Schema.Struct({
490
+ id: Schema.String,
491
+ text: Schema.String,
492
+ lineId: Schema.String,
493
+ once: Schema.Boolean,
494
+ exit: Schema.Boolean,
495
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
496
+ target: Schema.suspend(() => position),
497
+ placeholders: Schema.optionalKey(Schema.Array(Schema.suspend(() => placeholder))),
498
+ texts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String))
499
+ });
500
+ var matchArm = Schema.Struct({
501
+ is: Schema.optionalKey(Schema.String),
502
+ test: Schema.suspend(() => celSlot),
503
+ target: Schema.suspend(() => position)
504
+ });
505
+ var rewardEntry = Schema.Struct({
506
+ id: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z][A-Za-z0-9_-]{0,63}$"))))),
507
+ kind: Schema.String,
508
+ target: Schema.optionalKey(Schema.String),
509
+ amount: Schema.optionalKey(Schema.Int),
510
+ amountMin: Schema.optionalKey(Schema.Int),
511
+ amountMax: Schema.optionalKey(Schema.Int),
512
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
513
+ outcome: Schema.optionalKey(Schema.Literals([
514
+ "failed"
515
+ ])),
516
+ credits: Schema.optionalKey(Schema.String)
517
+ });
518
+ var objectiveEntry = Schema.Struct({
519
+ id: Schema.String,
520
+ title: Schema.optionalKey(Schema.String),
521
+ titleLineId: Schema.optionalKey(Schema.String),
522
+ done: Schema.suspend(() => celSlot),
523
+ visibleWhen: Schema.optionalKey(Schema.suspend(() => celSlot)),
524
+ optional: Schema.Boolean,
525
+ body: Schema.NullOr(Schema.suspend(() => position)),
526
+ quest: Schema.optionalKey(Schema.String),
527
+ rewards: Schema.optionalKey(Schema.Array(Schema.suspend(() => rewardEntry))),
528
+ on: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
529
+ by: Schema.optionalKey(Schema.suspend(() => celSlot)),
530
+ target: Schema.optionalKey(Schema.String),
531
+ until: Schema.optionalKey(Schema.suspend(() => celSlot))
532
+ });
533
+ var cmdLine = Schema.Struct({
534
+ kind: Schema.Literal("line"),
535
+ family: Schema.Literal("content"),
536
+ position: Schema.suspend(() => position),
537
+ role: Schema.suspend(() => role),
538
+ speaker: Schema.String,
539
+ text: Schema.String,
540
+ emotion: Schema.optionalKey(Schema.String),
541
+ variant: Schema.optionalKey(Schema.Int),
542
+ action: Schema.optionalKey(Schema.String),
543
+ dialogMotion: Schema.optionalKey(Schema.String),
544
+ as: Schema.optionalKey(Schema.String),
545
+ lineId: Schema.String,
546
+ voiceKey: Schema.String,
547
+ placeholders: Schema.optionalKey(Schema.Array(Schema.suspend(() => placeholder))),
548
+ texts: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
549
+ segments: Schema.optionalKey(Schema.suspend(() => segments)),
550
+ localeSegments: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => segments))),
551
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
552
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
553
+ source: Schema.optionalKey(Schema.suspend(() => source))
554
+ });
555
+ var cmdBg = Schema.Struct({
556
+ kind: Schema.Literal("bg"),
557
+ family: Schema.Literal("staging"),
558
+ position: Schema.suspend(() => position),
559
+ location: Schema.optionalKey(Schema.String),
560
+ time: Schema.optionalKey(Schema.String),
561
+ assetId: Schema.optionalKey(Schema.String),
562
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
563
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
564
+ source: Schema.optionalKey(Schema.suspend(() => source))
565
+ });
566
+ var cmdMusic = Schema.Struct({
567
+ kind: Schema.Literal("music"),
568
+ family: Schema.Literal("staging"),
569
+ position: Schema.suspend(() => position),
570
+ playback: Schema.optionalKey(Schema.String),
571
+ stop: Schema.optionalKey(Schema.Literal(true)),
572
+ mood: Schema.optionalKey(Schema.String),
573
+ volume: Schema.optionalKey(Schema.String),
574
+ assetId: Schema.optionalKey(Schema.String),
575
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
576
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
577
+ source: Schema.optionalKey(Schema.suspend(() => source))
578
+ });
579
+ var cmdSfx = Schema.Struct({
580
+ kind: Schema.Literal("sfx"),
581
+ family: Schema.Literal("staging"),
582
+ position: Schema.suspend(() => position),
583
+ sound: Schema.optionalKey(Schema.String),
584
+ assetId: Schema.optionalKey(Schema.String),
585
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
586
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
587
+ source: Schema.optionalKey(Schema.suspend(() => source))
588
+ });
589
+ var cmdVfx = Schema.Struct({
590
+ kind: Schema.Literal("vfx"),
591
+ family: Schema.Literal("staging"),
592
+ position: Schema.suspend(() => position),
593
+ type: Schema.String,
594
+ label: Schema.optionalKey(Schema.String),
595
+ transition: Schema.optionalKey(Schema.String),
596
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
597
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
598
+ source: Schema.optionalKey(Schema.suspend(() => source))
599
+ });
600
+ var cmdActor = Schema.Struct({
601
+ kind: Schema.Literal("actor"),
602
+ family: Schema.Literal("staging"),
603
+ position: Schema.suspend(() => position),
604
+ character: Schema.String,
605
+ anchor: Schema.optionalKey(Schema.String),
606
+ action: Schema.optionalKey(Schema.String),
607
+ exit: Schema.optionalKey(Schema.Boolean),
608
+ emotion: Schema.optionalKey(Schema.String),
609
+ costume: Schema.optionalKey(Schema.String),
610
+ posReset: Schema.optionalKey(Schema.Boolean),
611
+ preload: Schema.optionalKey(Schema.Boolean),
612
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
613
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
614
+ source: Schema.optionalKey(Schema.suspend(() => source))
615
+ });
616
+ var cmdCamera = Schema.Struct({
617
+ kind: Schema.Literal("camera"),
618
+ family: Schema.Literal("staging"),
619
+ position: Schema.suspend(() => position),
620
+ focus: Schema.optionalKey(Schema.String),
621
+ framing: Schema.optionalKey(Schema.String),
622
+ move: Schema.optionalKey(Schema.String),
623
+ transition: Schema.optionalKey(Schema.String),
624
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
625
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
626
+ source: Schema.optionalKey(Schema.suspend(() => source))
627
+ }).check(Schema.makeFilter((value) => [
628
+ [
629
+ "focus"
630
+ ],
631
+ [
632
+ "framing"
633
+ ],
634
+ [
635
+ "move"
636
+ ],
637
+ [
638
+ "transition"
639
+ ]
640
+ ].filter((keys) => keys.every((key) => (key in value))).length >= 1 || "expected at least one of the key sets: focus | framing | move | transition"));
641
+ var cmdCg = Schema.Struct({
642
+ kind: Schema.Literal("cg"),
643
+ family: Schema.Literal("staging"),
644
+ position: Schema.suspend(() => position),
645
+ assetId: Schema.String,
646
+ display: Schema.String,
647
+ layout: Schema.optionalKey(Schema.String),
648
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
649
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
650
+ source: Schema.optionalKey(Schema.suspend(() => source))
651
+ });
652
+ var cmdVideo = Schema.Struct({
653
+ kind: Schema.Literal("video"),
654
+ family: Schema.Literal("staging"),
655
+ position: Schema.suspend(() => position),
656
+ assetId: Schema.String,
657
+ display: Schema.String,
658
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
659
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
660
+ source: Schema.optionalKey(Schema.suspend(() => source))
661
+ });
662
+ var cmdSequence = Schema.Struct({
663
+ kind: Schema.Literal("sequence"),
664
+ family: Schema.Literal("staging"),
665
+ position: Schema.suspend(() => position),
666
+ name: Schema.String,
667
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
668
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
669
+ source: Schema.optionalKey(Schema.suspend(() => source))
670
+ });
671
+ var cmdSet = Schema.Struct({
672
+ kind: Schema.Literal("set"),
673
+ family: Schema.Literal("state"),
674
+ position: Schema.suspend(() => position),
675
+ path: Schema.String,
676
+ op: Schema.String,
677
+ value: Schema.suspend(() => celSlot),
678
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
679
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
680
+ source: Schema.optionalKey(Schema.suspend(() => source))
681
+ });
682
+ var cmdAssert = Schema.Struct({
683
+ kind: Schema.Literal("assert"),
684
+ family: Schema.Literal("state"),
685
+ position: Schema.suspend(() => position),
686
+ relation: Schema.String,
687
+ args: Schema.Array(Schema.String),
688
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
689
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
690
+ source: Schema.optionalKey(Schema.suspend(() => source))
691
+ });
692
+ var cmdRetract = Schema.Struct({
693
+ kind: Schema.Literal("retract"),
694
+ family: Schema.Literal("state"),
695
+ position: Schema.suspend(() => position),
696
+ relation: Schema.String,
697
+ args: Schema.Array(Schema.String),
698
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
699
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
700
+ source: Schema.optionalKey(Schema.suspend(() => source))
701
+ });
702
+ var cmdChoice = Schema.Struct({
703
+ kind: Schema.Literal("choice"),
704
+ family: Schema.Literal("control"),
705
+ position: Schema.suspend(() => position),
706
+ branchId: Schema.String,
707
+ selectionKey: Schema.String,
708
+ options: Schema.Array(Schema.suspend(() => choiceOption)),
709
+ converge: Schema.suspend(() => position),
710
+ prompt: Schema.optionalKey(Schema.String),
711
+ timeout: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1)))),
712
+ default: Schema.optionalKey(Schema.String),
713
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
714
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
715
+ source: Schema.optionalKey(Schema.suspend(() => source))
716
+ });
717
+ var cmdMatch = Schema.Struct({
718
+ kind: Schema.Literal("match"),
719
+ family: Schema.Literal("control"),
720
+ position: Schema.suspend(() => position),
721
+ subject: Schema.optionalKey(Schema.suspend(() => celSlot)),
722
+ arms: Schema.Array(Schema.suspend(() => matchArm)),
723
+ otherwise: Schema.optionalKey(Schema.suspend(() => position)),
724
+ converge: Schema.suspend(() => position),
725
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
726
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
727
+ source: Schema.optionalKey(Schema.suspend(() => source))
728
+ });
729
+ var cmdHub = Schema.Struct({
730
+ kind: Schema.Literal("hub"),
731
+ family: Schema.Literal("control"),
732
+ position: Schema.suspend(() => position),
733
+ id: Schema.String,
734
+ selectionKey: Schema.String,
735
+ options: Schema.Array(Schema.suspend(() => hubOption)),
736
+ converge: Schema.suspend(() => position),
737
+ prompt: Schema.optionalKey(Schema.String),
738
+ return: Schema.optionalKey(Schema.suspend(() => position)),
739
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
740
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
741
+ source: Schema.optionalKey(Schema.suspend(() => source))
742
+ });
743
+ var cmdJump = Schema.Struct({
744
+ kind: Schema.Literal("jump"),
745
+ family: Schema.Literal("control"),
746
+ position: Schema.suspend(() => position),
747
+ target: Schema.suspend(() => position)
748
+ });
749
+ var cmdEnd = Schema.Struct({
750
+ kind: Schema.Literal("end"),
751
+ family: Schema.Literal("control"),
752
+ position: Schema.suspend(() => position),
753
+ reason: Schema.optionalKey(Schema.String),
754
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
755
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
756
+ source: Schema.optionalKey(Schema.suspend(() => source))
757
+ });
758
+ var cmdBarrier = Schema.Struct({
759
+ kind: Schema.Literal("barrier"),
760
+ family: Schema.Literal("control"),
761
+ position: Schema.suspend(() => position),
762
+ timeline: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
763
+ at: Schema.Number.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))
764
+ });
765
+ var cmdQuest = Schema.Struct({
766
+ kind: Schema.Literal("quest"),
767
+ family: Schema.Literal("declaration"),
768
+ position: Schema.suspend(() => position),
769
+ id: Schema.String,
770
+ title: Schema.optionalKey(Schema.String),
771
+ titleLineId: Schema.optionalKey(Schema.String),
772
+ start: Schema.optionalKey(Schema.suspend(() => celSlot)),
773
+ fail: Schema.optionalKey(Schema.suspend(() => celSlot)),
774
+ objectives: Schema.Array(Schema.suspend(() => objectiveEntry)),
775
+ rewards: Schema.optionalKey(Schema.Array(Schema.suspend(() => rewardEntry))),
776
+ rearm: Schema.optionalKey(Schema.suspend(() => celSlot)),
777
+ tier: Schema.optionalKey(Schema.Union([
778
+ Schema.Literals([
779
+ "run"
780
+ ]),
781
+ Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^season:[A-Za-z0-9_][A-Za-z0-9_-]*$"))))
782
+ ])),
783
+ activate: Schema.optionalKey(Schema.Literals([
784
+ "accept"
785
+ ])),
786
+ complete: Schema.optionalKey(Schema.Literals([
787
+ "any"
788
+ ])),
789
+ accept: Schema.optionalKey(Schema.Literals([
790
+ "external"
791
+ ])),
792
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
793
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
794
+ source: Schema.optionalKey(Schema.suspend(() => source))
795
+ });
796
+ var cmdOn = Schema.Struct({
797
+ kind: Schema.Literal("on"),
798
+ family: Schema.Literal("declaration"),
799
+ position: Schema.suspend(() => position),
800
+ event: Schema.String,
801
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
802
+ body: Schema.suspend(() => position),
803
+ target: Schema.optionalKey(Schema.String),
804
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
805
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
806
+ source: Schema.optionalKey(Schema.suspend(() => source))
807
+ });
808
+ var cmdEntry = Schema.Struct({
809
+ kind: Schema.Literal("entry"),
810
+ family: Schema.Literal("declaration"),
811
+ position: Schema.suspend(() => position),
812
+ id: Schema.String,
813
+ target: Schema.optionalKey(Schema.String),
814
+ category: Schema.optionalKey(Schema.String),
815
+ title: Schema.optionalKey(Schema.String),
816
+ titleLineId: Schema.optionalKey(Schema.String),
817
+ series: Schema.optionalKey(Schema.String),
818
+ order: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))),
819
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
820
+ body: Schema.suspend(() => position),
821
+ on: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
822
+ priority: Schema.optionalKey(Schema.Int),
823
+ once: Schema.optionalKey(Schema.Union([
824
+ Schema.Literals([
825
+ "run",
826
+ "user",
827
+ "day",
828
+ "slot",
829
+ "week"
830
+ ]),
831
+ Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^season:[A-Za-z0-9_][A-Za-z0-9_-]*$"))))
832
+ ])),
833
+ share: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
834
+ targetKind: Schema.optionalKey(Schema.suspend(() => targetKind)),
835
+ forKind: Schema.optionalKey(Schema.suspend(() => forKind)),
836
+ spentBy: Schema.optionalKey(Schema.suspend(() => celSlot)),
837
+ advances: Schema.optionalKey(Schema.Union([
838
+ Schema.Literals([
839
+ "slot",
840
+ "day"
841
+ ]),
842
+ Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1)))
843
+ ])),
844
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
845
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
846
+ source: Schema.optionalKey(Schema.suspend(() => source))
847
+ });
848
+ var cmdAccept = Schema.Struct({
849
+ kind: Schema.Literal("accept"),
850
+ family: Schema.Literal("declaration"),
851
+ position: Schema.suspend(() => position),
852
+ quest: Schema.String,
853
+ applies: Schema.optionalKey(Schema.Literals([
854
+ "nextRun"
855
+ ])),
856
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
857
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
858
+ source: Schema.optionalKey(Schema.suspend(() => source))
859
+ });
860
+ var cmdBeat = Schema.Struct({
861
+ kind: Schema.Literal("beat"),
862
+ family: Schema.Literal("declaration"),
863
+ position: Schema.suspend(() => position),
864
+ id: Schema.String,
865
+ on: Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$")))),
866
+ target: Schema.optionalKey(Schema.String),
867
+ title: Schema.optionalKey(Schema.String),
868
+ titleLineId: Schema.optionalKey(Schema.String),
869
+ when: Schema.optionalKey(Schema.suspend(() => celSlot)),
870
+ priority: Schema.Int,
871
+ once: Schema.Union([
872
+ Schema.Literals([
873
+ "run",
874
+ "user",
875
+ "none",
876
+ "day",
877
+ "slot",
878
+ "week"
879
+ ]),
880
+ Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^season:[A-Za-z0-9_][A-Za-z0-9_-]*$"))))
881
+ ]),
882
+ also: Schema.optionalKey(Schema.Literal(true)),
883
+ share: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
884
+ after: Schema.optionalKey(Schema.String),
885
+ targetKind: Schema.optionalKey(Schema.suspend(() => targetKind)),
886
+ forKind: Schema.optionalKey(Schema.suspend(() => forKind)),
887
+ spentBy: Schema.optionalKey(Schema.suspend(() => celSlot)),
888
+ advances: Schema.optionalKey(Schema.Union([
889
+ Schema.Literals([
890
+ "slot",
891
+ "day"
892
+ ]),
893
+ Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1)))
894
+ ])),
895
+ body: Schema.suspend(() => position),
896
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
897
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
898
+ source: Schema.optionalKey(Schema.suspend(() => source))
899
+ });
900
+ var cmdPlugin = Schema.Struct({
901
+ kind: Schema.Literal("plugin"),
902
+ family: Schema.Literal("plugin"),
903
+ position: Schema.suspend(() => position),
904
+ tag: Schema.String,
905
+ plugin: Schema.optionalKey(Schema.String),
906
+ fields: Schema.Json,
907
+ effects: Schema.optionalKey(Schema.Array(Schema.suspend(() => effect))),
908
+ retracts: Schema.optionalKey(Schema.Array(Schema.Struct({
909
+ relation: Schema.String,
910
+ args: Schema.Array(Schema.String)
911
+ }))),
912
+ asserts: Schema.optionalKey(Schema.Array(Schema.Struct({
913
+ relation: Schema.String,
914
+ args: Schema.Array(Schema.String)
915
+ }))),
916
+ timing: Schema.optionalKey(Schema.suspend(() => timing)),
917
+ provenance: Schema.optionalKey(Schema.suspend(() => provenance)),
918
+ source: Schema.optionalKey(Schema.suspend(() => source))
919
+ });
920
+ var artifactMeta = Schema.Union([
921
+ Schema.suspend(() => sceneMeta),
922
+ Schema.suspend(() => questMeta),
923
+ Schema.suspend(() => loreMeta)
924
+ ]);
925
+ var loreMeta = Schema.Struct({
926
+ id: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*(\\.[A-Za-z0-9_][A-Za-z0-9_-]*)*$"))))),
927
+ title: Schema.optionalKey(Schema.String),
928
+ series: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
929
+ contentLang: Schema.optionalKey(Schema.String),
930
+ extra: Schema.optionalKey(Schema.Json),
931
+ plugin: Schema.optionalKey(Schema.Json)
932
+ });
933
+ var indexEntry = Schema.Struct({
934
+ category: Schema.optionalKey(Schema.String),
935
+ document: Schema.String,
936
+ id: Schema.String,
937
+ order: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0)))),
938
+ series: Schema.optionalKey(Schema.String),
939
+ target: Schema.optionalKey(Schema.String)
940
+ });
941
+ var indexBeat = Schema.Struct({
942
+ advances: Schema.optionalKey(Schema.Union([
943
+ Schema.Literals([
944
+ "slot",
945
+ "day"
946
+ ]),
947
+ Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1)))
948
+ ])),
949
+ document: Schema.String,
950
+ forKind: Schema.optionalKey(Schema.suspend(() => forKind)),
951
+ id: Schema.String,
952
+ kind: Schema.Literals([
953
+ "scene",
954
+ "entry",
955
+ "bundle"
956
+ ]),
957
+ on: Schema.String,
958
+ once: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^(run|user|none|day|slot|week|season:.+)$"))))),
959
+ priority: Schema.Int,
960
+ share: Schema.optionalKey(Schema.String),
961
+ spentBy: Schema.optionalKey(Schema.String),
962
+ target: Schema.optionalKey(Schema.String),
963
+ targetKind: Schema.optionalKey(Schema.suspend(() => targetKind)),
964
+ title: Schema.optionalKey(Schema.String),
965
+ when: Schema.optionalKey(Schema.String)
966
+ });
967
+ var sectionEntry = Schema.Struct({
968
+ section: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1))),
969
+ heading: Schema.String,
970
+ id: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z][A-Za-z0-9_-]{0,63}$")))))
971
+ });
972
+ var clockDecl = Schema.Struct({
973
+ day: Schema.String,
974
+ slot: Schema.optionalKey(Schema.String),
975
+ slots: Schema.optionalKey(Schema.Array(Schema.String)),
976
+ raise: Schema.optionalKey(Schema.Union([
977
+ Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$")))),
978
+ Schema.Struct({
979
+ slot: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
980
+ dayStart: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$"))))),
981
+ dayEnd: Schema.optionalKey(Schema.String.pipe(Schema.check(Schema.isPattern(new RegExp("^[A-Za-z0-9_][A-Za-z0-9_-]*$")))))
982
+ })
983
+ ])),
984
+ raiseAtStart: Schema.optionalKey(Schema.Literal(true)),
985
+ week: Schema.optionalKey(Schema.Struct({
986
+ length: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1))),
987
+ first: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(0))),
988
+ labels: Schema.optionalKey(Schema.Array(Schema.String))
989
+ })),
990
+ last: Schema.optionalKey(Schema.Struct({
991
+ day: Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1))),
992
+ slot: Schema.optionalKey(Schema.String)
993
+ })),
994
+ days: Schema.optionalKey(Schema.Int.pipe(Schema.check(Schema.isGreaterThanOrEqualTo(1))))
995
+ });
996
+ var indexOccasion = Schema.Struct({
997
+ judge: Schema.optionalKey(Schema.Literals([
998
+ "after",
999
+ "before"
1000
+ ])),
1001
+ outsideRun: Schema.optionalKey(Schema.Boolean),
1002
+ payload: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => fieldType))),
1003
+ select: Schema.Literals([
1004
+ "first",
1005
+ "all",
1006
+ "sequence"
1007
+ ]),
1008
+ target: Schema.Union([
1009
+ Schema.Boolean,
1010
+ Schema.Struct({
1011
+ entity: Schema.String,
1012
+ members: Schema.optionalKey(Schema.Array(Schema.String)),
1013
+ prefix: Schema.String
1014
+ })
1015
+ ])
1016
+ });
1017
+ var indexStateDomain = Schema.Struct({
1018
+ kind: Schema.String,
1019
+ members: Schema.Array(Schema.String)
1020
+ });
1021
+ var projectIndex = Schema.Struct({
1022
+ beats: Schema.optionalKey(Schema.Array(Schema.suspend(() => indexBeat))),
1023
+ bridgeResults: Schema.optionalKey(Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.suspend(() => fieldType)))),
1024
+ capabilitySnapshot: Schema.String,
1025
+ cast: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
1026
+ clock: Schema.optionalKey(Schema.suspend(() => clockDecl)),
1027
+ defs: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => indexDef))),
1028
+ documents: Schema.Array(Schema.suspend(() => indexDocument)),
1029
+ entities: Schema.Array(Schema.suspend(() => entityKindEntry)),
1030
+ entries: Schema.optionalKey(Schema.Array(Schema.suspend(() => indexEntry))),
1031
+ enums: Schema.Array(Schema.suspend(() => enumEntry)),
1032
+ gates: Schema.optionalKey(Schema.Array(Schema.Struct({
1033
+ occasion: Schema.String,
1034
+ raisedWhen: Schema.suspend(() => celSlot)
1035
+ }))),
1036
+ identityRenames: Schema.optionalKey(Schema.Array(Schema.Struct({
1037
+ from: Schema.String,
1038
+ to: Schema.String
1039
+ }))),
1040
+ irVersion: Schema.String,
1041
+ occasions: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => indexOccasion))),
1042
+ outsideRun: Schema.optionalKey(Schema.Array(Schema.String)),
1043
+ prereqEdges: Schema.Array(Schema.suspend(() => prereqEdgeEntry)),
1044
+ relations: Schema.Array(Schema.suspend(() => relationEntry)),
1045
+ requiredSemantics: Schema.Array(Schema.String),
1046
+ rules: Schema.Array(Schema.suspend(() => ruleEntry)),
1047
+ seasons: Schema.optionalKey(Schema.Array(Schema.Struct({
1048
+ live: Schema.suspend(() => celSlot),
1049
+ name: Schema.String
1050
+ }))),
1051
+ seedFacts: Schema.Array(Schema.suspend(() => seedFactEntry)),
1052
+ stateDomains: Schema.optionalKey(Schema.Record(Schema.String, Schema.suspend(() => indexStateDomain))),
1053
+ terminal: Schema.optionalKey(Schema.suspend(() => celSlot)),
1054
+ terminalPersists: Schema.optionalKey(Schema.Boolean),
1055
+ worldEvents: Schema.optionalKey(Schema.Array(Schema.String))
1056
+ });
1057
+ var indexDocument = Schema.Struct({
1058
+ artifact: Schema.String,
1059
+ key: Schema.String,
1060
+ kind: Schema.Literals([
1061
+ "scene",
1062
+ "quest",
1063
+ "lore"
1064
+ ]),
1065
+ path: Schema.String
1066
+ });
1067
+ var indexDef = Schema.Struct({
1068
+ authored: Schema.optionalKey(Schema.String),
1069
+ cel: Schema.String,
1070
+ expr: Schema.Json,
1071
+ host: Schema.optionalKey(Schema.Boolean),
1072
+ params: Schema.optionalKey(Schema.Array(Schema.Struct({
1073
+ name: Schema.String,
1074
+ type: Schema.suspend(() => fieldType)
1075
+ })))
1076
+ });
1077
+ var fieldType = Schema.Union([
1078
+ Schema.Literals([
1079
+ "bool",
1080
+ "int",
1081
+ "double",
1082
+ "string",
1083
+ "narrativeTime"
1084
+ ]),
1085
+ Schema.Struct({
1086
+ enum: Schema.Array(Schema.String)
1087
+ }),
1088
+ Schema.Struct({
1089
+ list: Schema.suspend(() => fieldType)
1090
+ }),
1091
+ Schema.Struct({
1092
+ record: Schema.Array(Schema.Struct({
1093
+ default: Schema.optionalKey(Schema.Json),
1094
+ name: Schema.String,
1095
+ required: Schema.Boolean,
1096
+ shape: Schema.optionalKey(Schema.String),
1097
+ type: Schema.suspend(() => fieldType)
1098
+ }))
1099
+ }),
1100
+ Schema.Struct({
1101
+ map: Schema.Struct({
1102
+ key: Schema.suspend(() => fieldType),
1103
+ value: Schema.suspend(() => fieldType)
1104
+ })
1105
+ }),
1106
+ Schema.Struct({
1107
+ enumFromOption: Schema.String
1108
+ }),
1109
+ Schema.Struct({
1110
+ providerRef: Schema.String
1111
+ }),
1112
+ Schema.Struct({
1113
+ domain: Schema.String
1114
+ }),
1115
+ Schema.Struct({
1116
+ entity: Schema.String
1117
+ }),
1118
+ Schema.Struct({
1119
+ slotId: Schema.Struct({
1120
+ namespace: Schema.String
1121
+ })
1122
+ }),
1123
+ Schema.Struct({
1124
+ assetKind: Schema.String
1125
+ })
1126
+ ]);
1127
+ var Command = Schema.Union([
1128
+ Schema.suspend(() => cmdLine),
1129
+ Schema.suspend(() => cmdBg),
1130
+ Schema.suspend(() => cmdMusic),
1131
+ Schema.suspend(() => cmdSfx),
1132
+ Schema.suspend(() => cmdVfx),
1133
+ Schema.suspend(() => cmdActor),
1134
+ Schema.suspend(() => cmdCamera),
1135
+ Schema.suspend(() => cmdCg),
1136
+ Schema.suspend(() => cmdVideo),
1137
+ Schema.suspend(() => cmdSequence),
1138
+ Schema.suspend(() => cmdSet),
1139
+ Schema.suspend(() => cmdAssert),
1140
+ Schema.suspend(() => cmdRetract),
1141
+ Schema.suspend(() => cmdChoice),
1142
+ Schema.suspend(() => cmdMatch),
1143
+ Schema.suspend(() => cmdHub),
1144
+ Schema.suspend(() => cmdJump),
1145
+ Schema.suspend(() => cmdEnd),
1146
+ Schema.suspend(() => cmdBarrier),
1147
+ Schema.suspend(() => cmdQuest),
1148
+ Schema.suspend(() => cmdOn),
1149
+ Schema.suspend(() => cmdEntry),
1150
+ Schema.suspend(() => cmdAccept),
1151
+ Schema.suspend(() => cmdBeat),
1152
+ Schema.suspend(() => cmdPlugin)
1153
+ ]);
1154
+
1155
+ // src/Errors.ts
1156
+ var exports_Errors = {};
1157
+ __export(exports_Errors, {
1158
+ BridgeShapeMismatch: () => BridgeShapeMismatch,
1159
+ BundleMalformed: () => BundleMalformed,
1160
+ BundleNotFound: () => BundleNotFound,
1161
+ BundleUnreadable: () => BundleUnreadable,
1162
+ EvaluationError: () => EvaluationError,
1163
+ InputLogError: () => InputLogError,
1164
+ InvalidInput: () => InvalidInput,
1165
+ IrVersionMismatch: () => IrVersionMismatch,
1166
+ OccasionGateClosed: () => OccasionGateClosed,
1167
+ OptionUnavailable: () => OptionUnavailable,
1168
+ RequestMismatch: () => RequestMismatch,
1169
+ RuntimeBusy: () => RuntimeBusy,
1170
+ RuntimeHalted: () => RuntimeHalted,
1171
+ SnapshotProjectMismatch: () => SnapshotProjectMismatch,
1172
+ SnapshotVersionMismatch: () => SnapshotVersionMismatch,
1173
+ TimeoutUnavailable: () => TimeoutUnavailable,
1174
+ WasmLoadError: () => WasmLoadError,
1175
+ fromGateRejected: () => fromGateRejected,
1176
+ fromQueryRejected: () => fromQueryRejected,
1177
+ fromRejected: () => fromRejected
1178
+ });
1179
+ import { Effect, Schema as Schema2 } from "effect";
1180
+
1181
+ class RuntimeBusy extends Schema2.TaggedError()("RuntimeBusy", {
1182
+ code: Schema2.Literal("E-RUNTIME-BUSY"),
1183
+ message: Schema2.String
1184
+ }) {
1185
+ }
1186
+
1187
+ class TimeoutUnavailable extends Schema2.TaggedError()("TimeoutUnavailable", {
1188
+ code: Schema2.Literal("E-RUNTIME-TIMEOUT"),
1189
+ message: Schema2.String
1190
+ }) {
1191
+ }
1192
+
1193
+ class RequestMismatch extends Schema2.TaggedError()("RequestMismatch", {
1194
+ code: Schema2.Literal("E-RUNTIME-REQUEST"),
1195
+ message: Schema2.String
1196
+ }) {
1197
+ }
1198
+
1199
+ class OptionUnavailable extends Schema2.TaggedError()("OptionUnavailable", {
1200
+ code: Schema2.Literal("E-RUNTIME-OPTION"),
1201
+ message: Schema2.String
1202
+ }) {
1203
+ }
1204
+
1205
+ class BridgeShapeMismatch extends Schema2.TaggedError()("BridgeShapeMismatch", {
1206
+ code: Schema2.Literal("E-RUNTIME-BRIDGE-SHAPE"),
1207
+ message: Schema2.String
1208
+ }) {
1209
+ }
1210
+
1211
+ class InvalidInput extends Schema2.TaggedError()("InvalidInput", {
1212
+ code: Schema2.Literal("E-RUNTIME-INPUT"),
1213
+ message: Schema2.String
1214
+ }) {
1215
+ }
1216
+
1217
+ class RuntimeHalted extends Schema2.TaggedError()("RuntimeHalted", {
1218
+ code: Schema2.Literal("E-RUNTIME-HALTED"),
1219
+ message: Schema2.String
1220
+ }) {
1221
+ }
1222
+
1223
+ class IrVersionMismatch extends Schema2.TaggedError()("IrVersionMismatch", {
1224
+ code: Schema2.Literal("E-RUNTIME-IR-VERSION"),
1225
+ message: Schema2.String
1226
+ }) {
1227
+ }
1228
+
1229
+ class SnapshotProjectMismatch extends Schema2.TaggedError()("SnapshotProjectMismatch", { code: Schema2.Literal("E-RUNTIME-SNAPSHOT-PROJECT"), message: Schema2.String }) {
1230
+ }
1231
+
1232
+ class SnapshotVersionMismatch extends Schema2.TaggedError()("SnapshotVersionMismatch", { code: Schema2.Literal("E-RUNTIME-SNAPSHOT-VERSION"), message: Schema2.String }) {
1233
+ }
1234
+
1235
+ class OccasionGateClosed extends Schema2.TaggedError()("OccasionGateClosed", {
1236
+ code: Schema2.Literal("E-OCCASION-GATE"),
1237
+ message: Schema2.String
1238
+ }) {
1239
+ }
1240
+ var byCode = {
1241
+ "E-RUNTIME-BUSY": (message) => new RuntimeBusy({ code: "E-RUNTIME-BUSY", message }),
1242
+ "E-RUNTIME-REQUEST": (message) => new RequestMismatch({ code: "E-RUNTIME-REQUEST", message }),
1243
+ "E-RUNTIME-OPTION": (message) => new OptionUnavailable({ code: "E-RUNTIME-OPTION", message }),
1244
+ "E-RUNTIME-BRIDGE-SHAPE": (message) => new BridgeShapeMismatch({ code: "E-RUNTIME-BRIDGE-SHAPE", message }),
1245
+ "E-RUNTIME-TIMEOUT": (message) => new TimeoutUnavailable({ code: "E-RUNTIME-TIMEOUT", message }),
1246
+ "E-RUNTIME-INPUT": (message) => new InvalidInput({ code: "E-RUNTIME-INPUT", message }),
1247
+ "E-RUNTIME-HALTED": (message) => new RuntimeHalted({ code: "E-RUNTIME-HALTED", message }),
1248
+ "E-RUNTIME-IR-VERSION": (message) => new IrVersionMismatch({ code: "E-RUNTIME-IR-VERSION", message }),
1249
+ "E-RUNTIME-SNAPSHOT-PROJECT": (message) => new SnapshotProjectMismatch({ code: "E-RUNTIME-SNAPSHOT-PROJECT", message }),
1250
+ "E-RUNTIME-SNAPSHOT-VERSION": (message) => new SnapshotVersionMismatch({ code: "E-RUNTIME-SNAPSHOT-VERSION", message }),
1251
+ "E-OCCASION-GATE": (message) => new OccasionGateClosed({ code: "E-OCCASION-GATE", message })
1252
+ };
1253
+ var fromRejected = (rejected) => {
1254
+ const make = byCode[rejected.code];
1255
+ return make === undefined ? Effect.die(new Error(`unknown runtime rejection ${rejected.code}: ${rejected.message}`)) : Effect.fail(make(rejected.message));
1256
+ };
1257
+
1258
+ class EvaluationError extends Schema2.TaggedError()("EvaluationError", {
1259
+ code: Schema2.Literal("E-RUNTIME-EVAL"),
1260
+ message: Schema2.String
1261
+ }) {
1262
+ }
1263
+ var fromQueryRejected = (rejected) => {
1264
+ switch (rejected.code) {
1265
+ case "E-RUNTIME-INPUT":
1266
+ return Effect.fail(new InvalidInput({ code: "E-RUNTIME-INPUT", message: rejected.message }));
1267
+ case "E-RUNTIME-EVAL":
1268
+ return Effect.fail(new EvaluationError({ code: "E-RUNTIME-EVAL", message: rejected.message }));
1269
+ default:
1270
+ return Effect.die(new Error(`unknown query rejection ${rejected.code}: ${rejected.message}`));
1271
+ }
1272
+ };
1273
+ var fromGateRejected = (rejected) => rejected.code === "E-RUNTIME-INPUT" ? Effect.fail(new InvalidInput({ code: "E-RUNTIME-INPUT", message: rejected.message })) : Effect.die(new Error(`unknown gate rejection ${rejected.code}: ${rejected.message}`));
1274
+
1275
+ class BundleNotFound extends Schema2.TaggedError()("BundleNotFound", {
1276
+ path: Schema2.String,
1277
+ message: Schema2.String
1278
+ }) {
1279
+ }
1280
+
1281
+ class BundleUnreadable extends Schema2.TaggedError()("BundleUnreadable", {
1282
+ path: Schema2.String,
1283
+ message: Schema2.String
1284
+ }) {
1285
+ }
1286
+
1287
+ class BundleMalformed extends Schema2.TaggedError()("BundleMalformed", {
1288
+ path: Schema2.String,
1289
+ message: Schema2.String
1290
+ }) {
1291
+ }
1292
+
1293
+ class WasmLoadError extends Schema2.TaggedError()("WasmLoadError", {
1294
+ message: Schema2.String
1295
+ }) {
1296
+ }
1297
+
1298
+ class InputLogError extends Schema2.TaggedError()("InputLogError", {
1299
+ message: Schema2.String
1300
+ }) {
1301
+ }
1302
+
1303
+ // src/BundleSource.ts
1304
+ var exports_BundleSource = {};
1305
+ __export(exports_BundleSource, {
1306
+ BundleSource: () => BundleSource,
1307
+ directory: () => directory,
1308
+ url: () => url,
1309
+ value: () => value
1310
+ });
1311
+ import { Context, Effect as Effect2, FileSystem, Layer, Path, Schema as Schema3 } from "effect";
1312
+ import * as HttpClient from "effect/http/HttpClient";
1313
+ class BundleSource extends Context.Service()("@lute-lang/runtime/BundleSource") {
1314
+ }
1315
+ var INDEX = "project.index.json";
1316
+ var decodeJson = Schema3.decodeUnknownEffect(Schema3.fromJsonString(Schema3.Json));
1317
+ var decodeIndex = Schema3.decodeUnknownEffect(Schema3.fromJsonString(projectIndex), { onExcessProperty: "error" });
1318
+ var assemble = (read) => Effect2.gen(function* () {
1319
+ const index = yield* Effect2.flatMap(read(INDEX), (text) => Effect2.mapError(decodeIndex(text), (error) => new BundleMalformed({ path: INDEX, message: error.message })));
1320
+ const artifacts = yield* Effect2.forEach(index.documents, ({ artifact }) => Effect2.flatMap(read(artifact), (text) => Effect2.mapError(decodeJson(text), (error) => new BundleMalformed({ path: artifact, message: error.message }))).pipe(Effect2.map((json) => [artifact, json])));
1321
+ return { index, artifacts: Object.fromEntries(artifacts) };
1322
+ });
1323
+ var value = (bundle) => Layer.succeed(BundleSource, { load: Effect2.succeed(bundle) });
1324
+ var directory = (root) => Layer.effect(BundleSource, Effect2.gen(function* () {
1325
+ const fs = yield* FileSystem.FileSystem;
1326
+ const path = yield* Path.Path;
1327
+ const read = (file) => {
1328
+ const full = path.join(root, file);
1329
+ return Effect2.mapError(fs.readFileString(full), (error) => error.reason._tag === "NotFound" ? new BundleNotFound({ path: full, message: error.message }) : new BundleUnreadable({ path: full, message: error.message }));
1330
+ };
1331
+ return { load: Effect2.withSpan(assemble(read), "Lute.BundleSource.directory", { attributes: { root } }) };
1332
+ }));
1333
+ var url = (base) => Layer.effect(BundleSource, Effect2.gen(function* () {
1334
+ const client = HttpClient.filterStatusOk(yield* HttpClient.HttpClient);
1335
+ const read = (file) => {
1336
+ const href = new URL(file, base).href;
1337
+ return client.get(href).pipe(Effect2.flatMap((response) => response.text), Effect2.mapError((error) => error.reason._tag === "StatusCodeError" && error.reason.response.status === 404 ? new BundleNotFound({ path: href, message: error.message }) : new BundleUnreadable({ path: href, message: error.message })));
1338
+ };
1339
+ return { load: Effect2.withSpan(assemble(read), "Lute.BundleSource.url", { attributes: { base } }) };
1340
+ }));
1341
+
1342
+ // src/generated/Contract.ts
1343
+ var exports_Contract = {};
1344
+ __export(exports_Contract, {
1345
+ AdvanceBy: () => AdvanceBy,
1346
+ Answer: () => Answer,
1347
+ Atom: () => Atom,
1348
+ Await: () => Await,
1349
+ BeatKind: () => BeatKind,
1350
+ BeatOnce: () => BeatOnce,
1351
+ Cadence: () => Cadence,
1352
+ Candidate: () => Candidate,
1353
+ ClockAt: () => ClockAt,
1354
+ ClockPosition: () => ClockPosition,
1355
+ ClockView: () => ClockView,
1356
+ Continuation: () => Continuation,
1357
+ Evaluation: () => Evaluation,
1358
+ Event: () => Event,
1359
+ Gate: () => Gate,
1360
+ GuardRead: () => GuardRead,
1361
+ Input: () => Input,
1362
+ MenuAwait: () => MenuAwait,
1363
+ MenuOptionAwait: () => MenuOptionAwait,
1364
+ Output: () => Output,
1365
+ PickInput: () => PickInput,
1366
+ Premise: () => Premise,
1367
+ Rejected: () => Rejected,
1368
+ SaveInput: () => SaveInput,
1369
+ Seed: () => Seed,
1370
+ Snapshot: () => Snapshot,
1371
+ Stage: () => Stage,
1372
+ StageActor: () => StageActor,
1373
+ StageBackground: () => StageBackground,
1374
+ StageCg: () => StageCg,
1375
+ StageMusic: () => StageMusic,
1376
+ StageVideo: () => StageVideo,
1377
+ StateWrite: () => StateWrite,
1378
+ StreamLine: () => StreamLine,
1379
+ Value: () => Value,
1380
+ Verdict: () => Verdict,
1381
+ World: () => World,
1382
+ WorldView: () => WorldView,
1383
+ WritesInput: () => WritesInput,
1384
+ fieldType: () => fieldType2,
1385
+ parseOptions: () => parseOptions
1386
+ });
1387
+ import * as Schema4 from "effect/Schema";
1388
+ var parseOptions = { onExcessProperty: "error" };
1389
+ var AdvanceBy = Schema4.Union([
1390
+ Schema4.String,
1391
+ Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1392
+ Schema4.Struct({
1393
+ to: Schema4.String
1394
+ }),
1395
+ Schema4.Struct({
1396
+ to: Schema4.suspend(() => ClockPosition)
1397
+ })
1398
+ ]);
1399
+ var Atom = Schema4.Union([
1400
+ Schema4.Struct({
1401
+ visited: Schema4.String
1402
+ }),
1403
+ Schema4.Struct({
1404
+ completed: Schema4.String
1405
+ }),
1406
+ Schema4.Struct({
1407
+ active: Schema4.String
1408
+ })
1409
+ ]);
1410
+ var Await = Schema4.Union([
1411
+ Schema4.Struct({
1412
+ menu: Schema4.suspend(() => MenuAwait),
1413
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1414
+ type: Schema4.Literal("awaitChoice")
1415
+ }),
1416
+ Schema4.Struct({
1417
+ attrs: Schema4.Record(Schema4.String, Schema4.Json),
1418
+ document: Schema4.String,
1419
+ position: Schema4.String,
1420
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1421
+ results: Schema4.Record(Schema4.String, Schema4.suspend(() => fieldType2)),
1422
+ tag: Schema4.String,
1423
+ type: Schema4.Literal("awaitBridge")
1424
+ }),
1425
+ Schema4.Struct({
1426
+ type: Schema4.Literal("idle")
1427
+ }),
1428
+ Schema4.Struct({
1429
+ reason: Schema4.String,
1430
+ type: Schema4.Literal("ended")
1431
+ }),
1432
+ Schema4.Struct({
1433
+ kind: Schema4.String,
1434
+ message: Schema4.String,
1435
+ site: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1436
+ type: Schema4.Literal("halted")
1437
+ })
1438
+ ]).pipe(Schema4.toTaggedUnion("type"));
1439
+ var BeatKind = Schema4.Literals([
1440
+ "scene",
1441
+ "entry",
1442
+ "bundle"
1443
+ ]);
1444
+ var BeatOnce = Schema4.String.pipe(Schema4.check(Schema4.isPattern(new RegExp("^(run|user|none|day|slot|week|season:.+)$"))));
1445
+ var Candidate = Schema4.Struct({
1446
+ also: Schema4.Boolean,
1447
+ document: Schema4.String,
1448
+ forMember: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1449
+ id: Schema4.String,
1450
+ kind: Schema4.suspend(() => BeatKind),
1451
+ priority: Schema4.Int,
1452
+ read: Schema4.Boolean,
1453
+ rejudged: Schema4.Boolean,
1454
+ verdict: Schema4.suspend(() => Verdict)
1455
+ });
1456
+ var ClockAt = Schema4.Struct({
1457
+ day: Schema4.Int,
1458
+ slot: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0)))
1459
+ });
1460
+ var ClockPosition = Schema4.Struct({
1461
+ slot: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1462
+ weekday: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1463
+ });
1464
+ var ClockView = Schema4.Struct({
1465
+ day: Schema4.Int,
1466
+ ended: Schema4.optionalKey(Schema4.NullOr(Schema4.Boolean)),
1467
+ last: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1468
+ slot: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1469
+ weekday: Schema4.optionalKey(Schema4.NullOr(Schema4.Int)),
1470
+ weekdayLabel: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1471
+ });
1472
+ var Evaluation = Schema4.Struct({
1473
+ unresolved: Schema4.optionalKey(Schema4.Array(Schema4.String)),
1474
+ value: Schema4.suspend(() => Value)
1475
+ });
1476
+ var Event = Schema4.Union([
1477
+ Schema4.Struct({
1478
+ document: Schema4.String,
1479
+ record: Schema4.Json,
1480
+ type: Schema4.Literal("record")
1481
+ }),
1482
+ Schema4.Struct({
1483
+ beat: Schema4.String,
1484
+ document: Schema4.String,
1485
+ kind: Schema4.String,
1486
+ occasion: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1487
+ target: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1488
+ type: Schema4.Literal("presentation")
1489
+ }),
1490
+ Schema4.Struct({
1491
+ beat: Schema4.String,
1492
+ document: Schema4.String,
1493
+ reason: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1494
+ type: Schema4.Literal("presentationEnd")
1495
+ }),
1496
+ Schema4.Struct({
1497
+ commands: Schema4.Array(Schema4.Json),
1498
+ document: Schema4.String,
1499
+ type: Schema4.Literal("quest")
1500
+ }),
1501
+ Schema4.Struct({
1502
+ from: Schema4.Json,
1503
+ passed: Schema4.optionalKey(Schema4.Json),
1504
+ to: Schema4.Json,
1505
+ type: Schema4.Literal("clock")
1506
+ })
1507
+ ]).pipe(Schema4.toTaggedUnion("type"));
1508
+ var Gate = Schema4.Struct({
1509
+ open: Schema4.Boolean,
1510
+ unresolved: Schema4.optionalKey(Schema4.Array(Schema4.String))
1511
+ });
1512
+ var GuardRead = Schema4.Union([
1513
+ Schema4.Struct({
1514
+ kind: Schema4.Literal("path"),
1515
+ value: Schema4.Tuple([
1516
+ Schema4.String,
1517
+ Schema4.suspend(() => Value)
1518
+ ])
1519
+ }),
1520
+ Schema4.Struct({
1521
+ kind: Schema4.Literal("fact"),
1522
+ value: Schema4.String
1523
+ }),
1524
+ Schema4.Struct({
1525
+ kind: Schema4.Literal("derived"),
1526
+ value: Schema4.Struct({
1527
+ base: Schema4.Array(Schema4.String),
1528
+ fact: Schema4.String,
1529
+ rules: Schema4.Array(Schema4.Tuple([
1530
+ Schema4.String,
1531
+ Schema4.Array(Schema4.String)
1532
+ ]))
1533
+ })
1534
+ }),
1535
+ Schema4.Struct({
1536
+ kind: Schema4.Literal("visited"),
1537
+ value: Schema4.String
1538
+ }),
1539
+ Schema4.Struct({
1540
+ kind: Schema4.Literal("holds"),
1541
+ value: Schema4.String
1542
+ }),
1543
+ Schema4.Struct({
1544
+ kind: Schema4.Literal("seen"),
1545
+ value: Schema4.String
1546
+ })
1547
+ ]).pipe(Schema4.toTaggedUnion("kind"));
1548
+ var Input = Schema4.Union([
1549
+ Schema4.Struct({
1550
+ occasion: Schema4.String,
1551
+ payload: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Json)),
1552
+ pick: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => PickInput))),
1553
+ target: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1554
+ type: Schema4.Literal("raiseOccasion"),
1555
+ writes: Schema4.optionalKey(Schema4.suspend(() => WritesInput))
1556
+ }),
1557
+ Schema4.Struct({
1558
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1559
+ type: Schema4.Literal("timeout")
1560
+ }),
1561
+ Schema4.Struct({
1562
+ option: Schema4.String,
1563
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1564
+ type: Schema4.Literal("choose")
1565
+ }),
1566
+ Schema4.Struct({
1567
+ fields: Schema4.Record(Schema4.String, Schema4.Json),
1568
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1569
+ type: Schema4.Literal("bridgeResult"),
1570
+ writes: Schema4.optionalKey(Schema4.suspend(() => WritesInput))
1571
+ }),
1572
+ Schema4.Struct({
1573
+ by: Schema4.suspend(() => AdvanceBy),
1574
+ pick: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => PickInput))),
1575
+ type: Schema4.Literal("advanceClock"),
1576
+ writes: Schema4.optionalKey(Schema4.suspend(() => WritesInput))
1577
+ }),
1578
+ Schema4.Struct({
1579
+ type: Schema4.Literal("hostWrite"),
1580
+ writes: Schema4.suspend(() => WritesInput)
1581
+ }),
1582
+ Schema4.Struct({
1583
+ name: Schema4.String,
1584
+ type: Schema4.Literal("worldEvent")
1585
+ }),
1586
+ Schema4.Struct({
1587
+ type: Schema4.Literal("newRun"),
1588
+ writes: Schema4.optionalKey(Schema4.suspend(() => WritesInput))
1589
+ })
1590
+ ]).pipe(Schema4.toTaggedUnion("type"));
1591
+ var MenuAwait = Schema4.Struct({
1592
+ construct: Schema4.String,
1593
+ default: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1594
+ document: Schema4.String,
1595
+ id: Schema4.String,
1596
+ options: Schema4.Array(Schema4.suspend(() => MenuOptionAwait)),
1597
+ position: Schema4.String,
1598
+ presentation: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1599
+ prompt: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1600
+ timeout: Schema4.optionalKey(Schema4.NullOr(Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0)))))
1601
+ });
1602
+ var MenuOptionAwait = Schema4.Struct({
1603
+ exit: Schema4.Boolean,
1604
+ id: Schema4.String,
1605
+ once: Schema4.Boolean,
1606
+ verdict: Schema4.String
1607
+ });
1608
+ var Output = Schema4.Struct({
1609
+ await: Schema4.suspend(() => Await),
1610
+ eventVersion: Schema4.String,
1611
+ events: Schema4.Array(Schema4.suspend(() => Event))
1612
+ });
1613
+ var PickInput = Schema4.Union([
1614
+ Schema4.String,
1615
+ Schema4.Struct({
1616
+ beat: Schema4.String
1617
+ })
1618
+ ]);
1619
+ var Premise = Schema4.Union([
1620
+ Schema4.Struct({
1621
+ once: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => BeatOnce))),
1622
+ premise: Schema4.Literal("spent"),
1623
+ reason: Schema4.String
1624
+ }),
1625
+ Schema4.Struct({
1626
+ chapters: Schema4.Boolean,
1627
+ premise: Schema4.Literal("after"),
1628
+ raw: Schema4.String,
1629
+ unmet: Schema4.Array(Schema4.suspend(() => Atom))
1630
+ }),
1631
+ Schema4.Struct({
1632
+ premise: Schema4.Literal("spentBy"),
1633
+ raw: Schema4.String
1634
+ }),
1635
+ Schema4.Struct({
1636
+ premise: Schema4.Literal("when"),
1637
+ raw: Schema4.String
1638
+ }),
1639
+ Schema4.Struct({
1640
+ occasion: Schema4.String,
1641
+ premise: Schema4.Literal("gate"),
1642
+ raw: Schema4.String,
1643
+ reads: Schema4.Array(Schema4.suspend(() => GuardRead))
1644
+ }),
1645
+ Schema4.Struct({
1646
+ occasion: Schema4.String,
1647
+ premise: Schema4.Literal("terminal"),
1648
+ raw: Schema4.String
1649
+ })
1650
+ ]).pipe(Schema4.toTaggedUnion("premise"));
1651
+ var Rejected = Schema4.Struct({
1652
+ code: Schema4.String,
1653
+ message: Schema4.String
1654
+ });
1655
+ var SaveInput = Schema4.Struct({
1656
+ entriesRead: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
1657
+ presented: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Array(Schema4.String))),
1658
+ questInstances: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))))),
1659
+ quests: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.String)),
1660
+ visited: Schema4.optionalKey(Schema4.Array(Schema4.String))
1661
+ });
1662
+ var Seed = Schema4.Struct({
1663
+ derive: Schema4.optionalKey(Schema4.Boolean),
1664
+ facts: Schema4.optionalKey(Schema4.Array(Schema4.String)),
1665
+ save: Schema4.optionalKey(Schema4.suspend(() => SaveInput)),
1666
+ state: Schema4.optionalKey(Schema4.Array(Schema4.suspend(() => StateWrite)))
1667
+ });
1668
+ var StateWrite = Schema4.Struct({
1669
+ add: Schema4.optionalKey(Schema4.NullOr(Schema4.Number)),
1670
+ path: Schema4.String,
1671
+ value: Schema4.optionalKey(Schema4.Json)
1672
+ });
1673
+ var StreamLine = Schema4.Union([
1674
+ Schema4.Struct({
1675
+ output: Schema4.suspend(() => Output),
1676
+ seed: Schema4.suspend(() => Seed)
1677
+ }),
1678
+ Schema4.Struct({
1679
+ input: Schema4.suspend(() => Input),
1680
+ output: Schema4.suspend(() => Output)
1681
+ }),
1682
+ Schema4.Struct({
1683
+ input: Schema4.suspend(() => Input),
1684
+ rejected: Schema4.suspend(() => Rejected)
1685
+ }),
1686
+ Schema4.Struct({
1687
+ rejected: Schema4.suspend(() => Rejected),
1688
+ seed: Schema4.suspend(() => Seed)
1689
+ })
1690
+ ]);
1691
+ var Value = Schema4.Union([
1692
+ Schema4.Struct({
1693
+ kind: Schema4.Literal("bool"),
1694
+ value: Schema4.Boolean
1695
+ }),
1696
+ Schema4.Struct({
1697
+ kind: Schema4.Literal("int"),
1698
+ value: Schema4.Int
1699
+ }),
1700
+ Schema4.Struct({
1701
+ kind: Schema4.Literal("double"),
1702
+ value: Schema4.Number
1703
+ }),
1704
+ Schema4.Struct({
1705
+ kind: Schema4.Literal("str"),
1706
+ value: Schema4.String
1707
+ }),
1708
+ Schema4.Struct({
1709
+ kind: Schema4.Literal("unknown")
1710
+ }),
1711
+ Schema4.Struct({
1712
+ kind: Schema4.Literal("error"),
1713
+ value: Schema4.String
1714
+ })
1715
+ ]).pipe(Schema4.toTaggedUnion("kind"));
1716
+ var Verdict = Schema4.Union([
1717
+ Schema4.Struct({
1718
+ verdict: Schema4.Literal("eligible")
1719
+ }),
1720
+ Schema4.Struct({
1721
+ premise: Schema4.suspend(() => Premise),
1722
+ verdict: Schema4.Literal("ineligible")
1723
+ }),
1724
+ Schema4.Struct({
1725
+ verdict: Schema4.Literal("unknown"),
1726
+ why: Schema4.String
1727
+ })
1728
+ ]).pipe(Schema4.toTaggedUnion("verdict"));
1729
+ var WorldView = Schema4.Struct({
1730
+ clock: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => ClockView))),
1731
+ facts: Schema4.optionalKey(Schema4.UniqueArray(Schema4.String)),
1732
+ quests: Schema4.Record(Schema4.String, Schema4.String),
1733
+ state: Schema4.Record(Schema4.String, Schema4.suspend(() => Value))
1734
+ });
1735
+ var WritesInput = Schema4.Struct({
1736
+ accept: Schema4.optionalKey(Schema4.Array(Schema4.String)),
1737
+ facts: Schema4.optionalKey(Schema4.Array(Schema4.String)),
1738
+ retract: Schema4.optionalKey(Schema4.Array(Schema4.String)),
1739
+ state: Schema4.optionalKey(Schema4.Array(Schema4.suspend(() => StateWrite)))
1740
+ });
1741
+ var fieldType2 = Schema4.Union([
1742
+ Schema4.Literals([
1743
+ "bool",
1744
+ "int",
1745
+ "double",
1746
+ "string",
1747
+ "narrativeTime"
1748
+ ]),
1749
+ Schema4.Struct({
1750
+ enum: Schema4.Array(Schema4.String)
1751
+ }),
1752
+ Schema4.Struct({
1753
+ list: Schema4.suspend(() => fieldType2)
1754
+ }),
1755
+ Schema4.Struct({
1756
+ record: Schema4.Array(Schema4.Struct({
1757
+ default: Schema4.optionalKey(Schema4.Json),
1758
+ name: Schema4.String,
1759
+ required: Schema4.Boolean,
1760
+ shape: Schema4.optionalKey(Schema4.String),
1761
+ type: Schema4.suspend(() => fieldType2)
1762
+ }))
1763
+ }),
1764
+ Schema4.Struct({
1765
+ map: Schema4.Struct({
1766
+ key: Schema4.suspend(() => fieldType2),
1767
+ value: Schema4.suspend(() => fieldType2)
1768
+ })
1769
+ }),
1770
+ Schema4.Struct({
1771
+ enumFromOption: Schema4.String
1772
+ }),
1773
+ Schema4.Struct({
1774
+ providerRef: Schema4.String
1775
+ }),
1776
+ Schema4.Struct({
1777
+ domain: Schema4.String
1778
+ }),
1779
+ Schema4.Struct({
1780
+ entity: Schema4.String
1781
+ }),
1782
+ Schema4.Struct({
1783
+ slotId: Schema4.Struct({
1784
+ namespace: Schema4.String
1785
+ })
1786
+ }),
1787
+ Schema4.Struct({
1788
+ assetKind: Schema4.String
1789
+ })
1790
+ ]);
1791
+ var Answer = Schema4.Union([
1792
+ Schema4.Struct({
1793
+ choice: Schema4.Struct({
1794
+ id: Schema4.String,
1795
+ option: Schema4.String
1796
+ })
1797
+ }),
1798
+ Schema4.Struct({
1799
+ bridge: Schema4.Struct({
1800
+ fields: Schema4.Record(Schema4.String, Schema4.Json),
1801
+ tag: Schema4.String,
1802
+ writes: Schema4.optionalKey(Schema4.suspend(() => WritesInput))
1803
+ })
1804
+ })
1805
+ ]);
1806
+ var Cadence = Schema4.Struct({
1807
+ latched: Schema4.Record(Schema4.String, Schema4.NullOr(Schema4.suspend(() => ClockAt))),
1808
+ live: Schema4.Record(Schema4.String, Schema4.Boolean),
1809
+ rearm: Schema4.Record(Schema4.String, Schema4.Boolean),
1810
+ spentSeason: Schema4.UniqueArray(Schema4.String),
1811
+ windows: Schema4.UniqueArray(Schema4.String)
1812
+ });
1813
+ var Continuation = Schema4.Struct({
1814
+ answers: Schema4.Array(Schema4.suspend(() => Answer)),
1815
+ before: Schema4.suspend(() => World),
1816
+ delivered: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1817
+ input: Schema4.suspend(() => Input),
1818
+ pending: Schema4.suspend(() => Await),
1819
+ stage: Schema4.suspend(() => Stage)
1820
+ });
1821
+ var Stage = Schema4.Struct({
1822
+ actors: Schema4.Array(Schema4.suspend(() => StageActor)),
1823
+ bg: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => StageBackground))),
1824
+ cg: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => StageCg))),
1825
+ music: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => StageMusic))),
1826
+ video: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => StageVideo)))
1827
+ });
1828
+ var StageActor = Schema4.Struct({
1829
+ anchor: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1830
+ character: Schema4.String,
1831
+ costume: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1832
+ emotion: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1833
+ });
1834
+ var StageBackground = Schema4.Struct({
1835
+ assetId: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1836
+ location: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1837
+ time: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1838
+ });
1839
+ var StageCg = Schema4.Struct({
1840
+ assetId: Schema4.String,
1841
+ layout: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1842
+ });
1843
+ var StageMusic = Schema4.Struct({
1844
+ assetId: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1845
+ mood: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1846
+ playback: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1847
+ volume: Schema4.optionalKey(Schema4.NullOr(Schema4.String))
1848
+ });
1849
+ var StageVideo = Schema4.Struct({
1850
+ assetId: Schema4.String
1851
+ });
1852
+ var World = Schema4.Struct({
1853
+ accepts: Schema4.Array(Schema4.String),
1854
+ advanceCascadeDepth: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1855
+ cadence: Schema4.suspend(() => Cadence),
1856
+ clockAdvancedByBeat: Schema4.Boolean,
1857
+ deferBy: Schema4.optionalKey(Schema4.NullOr(Schema4.String)),
1858
+ deferHandlers: Schema4.Boolean,
1859
+ deferredHandlers: Schema4.Array(Schema4.Tuple([
1860
+ Schema4.String,
1861
+ Schema4.String
1862
+ ])),
1863
+ derive: Schema4.optionalKey(Schema4.NullOr(Schema4.Boolean)),
1864
+ facts: Schema4.UniqueArray(Schema4.Tuple([
1865
+ Schema4.String,
1866
+ Schema4.Array(Schema4.String)
1867
+ ])),
1868
+ failedObjectives: Schema4.UniqueArray(Schema4.String),
1869
+ nextRunAccepts: Schema4.Array(Schema4.String),
1870
+ questInstances: Schema4.Record(Schema4.String, Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0)))),
1871
+ quests: Schema4.Record(Schema4.String, Schema4.String),
1872
+ shareSpentBy: Schema4.Record(Schema4.String, Schema4.String),
1873
+ spentAt: Schema4.Record(Schema4.String, Schema4.suspend(() => ClockAt)),
1874
+ spentRun: Schema4.UniqueArray(Schema4.String),
1875
+ spentUser: Schema4.UniqueArray(Schema4.String),
1876
+ stage: Schema4.suspend(() => Stage),
1877
+ state: Schema4.Record(Schema4.String, Schema4.suspend(() => Value)),
1878
+ visited: Schema4.UniqueArray(Schema4.String)
1879
+ });
1880
+ var Snapshot = Schema4.Struct({
1881
+ await: Schema4.suspend(() => Await),
1882
+ continuation: Schema4.optionalKey(Schema4.NullOr(Schema4.suspend(() => Continuation))),
1883
+ project: Schema4.String,
1884
+ request: Schema4.Int.pipe(Schema4.check(Schema4.isGreaterThanOrEqualTo(0))),
1885
+ snapshotVersion: Schema4.String,
1886
+ world: Schema4.suspend(() => World)
1887
+ });
1888
+
1889
+ // src/InputLog.ts
1890
+ var exports_InputLog = {};
1891
+ __export(exports_InputLog, {
1892
+ InputLog: () => InputLog,
1893
+ LogEntry: () => LogEntry,
1894
+ keyValueStore: () => keyValueStore,
1895
+ memory: () => memory
1896
+ });
1897
+ import { Context as Context2, Effect as Effect3, Layer as Layer2, Option, Ref, Schema as Schema5 } from "effect";
1898
+ import * as KeyValueStore from "effect/persistence/KeyValueStore";
1899
+ var LogEntry = Schema5.Union([
1900
+ Schema5.Struct({ seed: Seed }),
1901
+ Schema5.Struct({ snapshot: Snapshot }),
1902
+ Schema5.Struct({ input: Input })
1903
+ ]);
1904
+
1905
+ class InputLog extends Context2.Service()("@lute-lang/runtime/InputLog") {
1906
+ }
1907
+ var memory = Layer2.effect(InputLog, Effect3.map(Ref.make([]), (log) => ({
1908
+ reset: (start) => Ref.set(log, [start]),
1909
+ append: (entry) => Ref.update(log, (entries) => [...entries, entry]),
1910
+ entries: Ref.get(log)
1911
+ })));
1912
+ var keyValueStore = (key) => Layer2.effect(InputLog, Effect3.gen(function* () {
1913
+ const store = KeyValueStore.toSchemaStore(yield* KeyValueStore.KeyValueStore, Schema5.Array(LogEntry));
1914
+ const entries = store.get(key).pipe(Effect3.map(Option.getOrElse(() => [])), Effect3.mapError((error) => new InputLogError({ message: error.message })));
1915
+ return {
1916
+ reset: (start) => Effect3.mapError(store.set(key, [start]), (error) => new InputLogError({ message: error.message })),
1917
+ append: (entry) => entries.pipe(Effect3.flatMap((logged) => store.set(key, [...logged, entry])), Effect3.mapError((error) => new InputLogError({ message: error.message }))),
1918
+ entries
1919
+ };
1920
+ }));
1921
+
1922
+ // src/LuteWasm.ts
1923
+ var exports_LuteWasm = {};
1924
+ __export(exports_LuteWasm, {
1925
+ LuteWasm: () => LuteWasm2,
1926
+ fromBytes: () => fromBytes,
1927
+ layerFromBytes: () => layerFromBytes
1928
+ });
1929
+ import { Context as Context3, Effect as Effect4, Layer as Layer3 } from "effect";
1930
+ import * as Glue from "./wasm/lute_runtime_wasm.js";
1931
+
1932
+ class LuteWasm2 extends Context3.Service()("@lute-lang/runtime/LuteWasm") {
1933
+ }
1934
+ var fromBytes = (bytes) => Effect4.try({
1935
+ try: () => {
1936
+ const { buffer, byteOffset, byteLength } = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
1937
+ if (!(buffer instanceof ArrayBuffer))
1938
+ throw new TypeError("the bytes live in a SharedArrayBuffer");
1939
+ Glue.initSync({ module: new Uint8Array(buffer, byteOffset, byteLength) });
1940
+ return { Program: Glue.Program };
1941
+ },
1942
+ catch: (cause) => new WasmLoadError({ message: `cannot instantiate the runtime binding: ${String(cause)}` })
1943
+ });
1944
+ var layerFromBytes = (bytes) => Layer3.effect(LuteWasm2, fromBytes(bytes));
1945
+
1946
+ // src/Program.ts
1947
+ var exports_Program = {};
1948
+ __export(exports_Program, {
1949
+ make: () => make,
1950
+ rejection: () => rejection
1951
+ });
1952
+ import { Effect as Effect5, Option as Option2, Schema as Schema6 } from "effect";
1953
+ var TypeId = "~@lute-lang/runtime/RuntimeState";
1954
+ var handles = new WeakMap;
1955
+ var wrap = (handle, fingerprint) => {
1956
+ const state = { [TypeId]: TypeId };
1957
+ handles.set(state, { handle, fingerprint });
1958
+ return state;
1959
+ };
1960
+ var handleOf = (state, fingerprint) => Effect5.suspend(() => {
1961
+ const owned = handles.get(state);
1962
+ if (owned === undefined) {
1963
+ return Effect5.die(new Error("a RuntimeState must come from a Program of this package"));
1964
+ }
1965
+ if (owned.fingerprint !== fingerprint) {
1966
+ return Effect5.die(new Error(`a RuntimeState of bundle ${owned.fingerprint} was given to a Program of bundle ${fingerprint}: ` + "a state is valid only for programs of the bundle fingerprint that created it"));
1967
+ }
1968
+ return Effect5.succeed(owned.handle);
1969
+ });
1970
+ var fromBinding = (schema) => {
1971
+ const decode = Schema6.decodeUnknownEffect(Schema6.fromJsonString(schema), parseOptions);
1972
+ return (json) => Effect5.orDie(decode(json));
1973
+ };
1974
+ var toBinding = (schema) => {
1975
+ const encode = Schema6.encodeEffect(Schema6.fromJsonString(schema), parseOptions);
1976
+ return (value) => Effect5.orDie(encode(value));
1977
+ };
1978
+ var decodeOutput = fromBinding(Output);
1979
+ var decodeRejected = fromBinding(Rejected);
1980
+ var decodeSnapshot = fromBinding(Snapshot);
1981
+ var decodeCandidates = fromBinding(Schema6.Array(Candidate));
1982
+ var decodeCandidate = fromBinding(Schema6.NullOr(Candidate));
1983
+ var decodeStage = fromBinding(Stage);
1984
+ var decodeClock = fromBinding(Schema6.NullOr(ClockAt));
1985
+ var decodeView = fromBinding(WorldView);
1986
+ var decodeEvaluation = fromBinding(Evaluation);
1987
+ var decodeGate = fromBinding(Gate);
1988
+ var encodeExpr = toBinding(Schema6.Json);
1989
+ var encodeSeed = toBinding(Seed);
1990
+ var encodeInput = toBinding(Input);
1991
+ var encodeSnapshot = toBinding(Snapshot);
1992
+ var rejection = (json) => Effect5.flatMap(decodeRejected(json), fromRejected);
1993
+ var settle = (result, success) => Effect5.suspend(() => {
1994
+ const { ok, rejected } = result;
1995
+ if (ok)
1996
+ return success();
1997
+ if (rejected !== undefined)
1998
+ return rejection(rejected);
1999
+ return Effect5.die(new Error("the runtime binding returned neither a value nor a rejection"));
2000
+ }).pipe(Effect5.ensuring(Effect5.sync(() => result.free())));
2001
+ var queryOf = (result, decode, reject) => Effect5.suspend(() => {
2002
+ const { ok, value, rejected } = result;
2003
+ if (ok && value !== undefined)
2004
+ return decode(value);
2005
+ if (!ok && rejected !== undefined)
2006
+ return Effect5.flatMap(decodeRejected(rejected), reject);
2007
+ return Effect5.die(new Error("the runtime binding returned neither an answer nor a rejection"));
2008
+ }).pipe(Effect5.ensuring(Effect5.sync(() => result.free())));
2009
+ var make = (raw) => {
2010
+ const fingerprint = raw.fingerprint;
2011
+ const own = (state) => handleOf(state, fingerprint);
2012
+ const stepOf = (result) => settle(result, () => {
2013
+ const { state, output } = result;
2014
+ return state === undefined || output === undefined ? Effect5.die(new Error("the runtime binding accepted an input without a state and output")) : Effect5.map(decodeOutput(output), (output) => ({ state: wrap(state, fingerprint), output }));
2015
+ });
2016
+ return {
2017
+ fingerprint,
2018
+ begin: Effect5.fn("Lute.Program.begin")(function* (seed) {
2019
+ const json = yield* encodeSeed(seed);
2020
+ return yield* stepOf(raw.begin(json));
2021
+ }),
2022
+ step: Effect5.fn("Lute.Program.step")(function* (state, input) {
2023
+ const handle = yield* own(state);
2024
+ const json = yield* encodeInput(input);
2025
+ return yield* stepOf(raw.step(handle, json));
2026
+ }),
2027
+ snapshot: Effect5.fn("Lute.Program.snapshot")(function* (state) {
2028
+ const handle = yield* own(state);
2029
+ return yield* decodeSnapshot(raw.snapshot(handle));
2030
+ }),
2031
+ restore: Effect5.fn("Lute.Program.restore")(function* (snapshot) {
2032
+ const json = yield* encodeSnapshot(snapshot);
2033
+ const result = raw.restore(json);
2034
+ return yield* settle(result, () => {
2035
+ const { state } = result;
2036
+ return state === undefined ? Effect5.die(new Error("the runtime binding restored a snapshot without a state")) : Effect5.succeed(wrap(state, fingerprint));
2037
+ });
2038
+ }),
2039
+ candidates: Effect5.fn("Lute.Program.candidates")(function* (state, occasion, target) {
2040
+ const handle = yield* own(state);
2041
+ return yield* decodeCandidates(raw.candidates(handle, occasion, target));
2042
+ }),
2043
+ eligibility: Effect5.fn("Lute.Program.eligibility")(function* (state, beat, member) {
2044
+ const handle = yield* own(state);
2045
+ const candidate = yield* decodeCandidate(raw.eligibility(handle, beat, member));
2046
+ return Option2.fromNullOr(candidate);
2047
+ }),
2048
+ clock: Effect5.fn("Lute.Program.clock")(function* (state) {
2049
+ const handle = yield* own(state);
2050
+ const clock = yield* decodeClock(raw.clock(handle));
2051
+ return Option2.fromNullOr(clock);
2052
+ }),
2053
+ terminal: Effect5.fn("Lute.Program.terminal")(function* (state) {
2054
+ const handle = yield* own(state);
2055
+ return raw.terminal(handle);
2056
+ }),
2057
+ stage: Effect5.fn("Lute.Program.stage")(function* (state) {
2058
+ const handle = yield* own(state);
2059
+ return yield* decodeStage(raw.stage(handle));
2060
+ }),
2061
+ view: Effect5.fn("Lute.Program.view")(function* (state, options) {
2062
+ const handle = yield* own(state);
2063
+ return yield* decodeView(raw.view(handle, options?.facts === true));
2064
+ }),
2065
+ evaluate: Effect5.fn("Lute.Program.evaluate")(function* (state, expr) {
2066
+ const handle = yield* own(state);
2067
+ const json = yield* encodeExpr(expr);
2068
+ return yield* queryOf(raw.evaluate(handle, json), decodeEvaluation, fromQueryRejected);
2069
+ }),
2070
+ def: Effect5.fn("Lute.Program.def")(function* (state, name, args) {
2071
+ const handle = yield* own(state);
2072
+ const json = args === undefined ? undefined : JSON.stringify(args);
2073
+ return yield* queryOf(raw.def(handle, name, json), decodeEvaluation, fromQueryRejected);
2074
+ }),
2075
+ gate: Effect5.fn("Lute.Program.gate")(function* (state, occasion, target) {
2076
+ const handle = yield* own(state);
2077
+ return yield* queryOf(raw.gate(handle, occasion, target), decodeGate, fromGateRejected);
2078
+ }),
2079
+ free: Effect5.sync(() => raw.free())
2080
+ };
2081
+ };
2082
+
2083
+ // src/LuteRuntime.ts
2084
+ var exports_LuteRuntime = {};
2085
+ __export(exports_LuteRuntime, {
2086
+ LuteRuntime: () => LuteRuntime,
2087
+ layer: () => layer
2088
+ });
2089
+ import { Context as Context4, Effect as Effect6, Layer as Layer4 } from "effect";
2090
+ class LuteRuntime extends Context4.Service()("@lute-lang/runtime/LuteRuntime") {
2091
+ }
2092
+ var layer = Layer4.effect(LuteRuntime, Effect6.gen(function* () {
2093
+ const wasm = yield* LuteWasm2;
2094
+ const acquire = Effect6.fn("Lute.LuteRuntime.load")(function* (bundle) {
2095
+ const result = wasm.Program.load(JSON.stringify(bundle.index), JSON.stringify(bundle.artifacts));
2096
+ const { ok, program, rejected } = result;
2097
+ result.free();
2098
+ if (ok && program !== undefined)
2099
+ return make(program);
2100
+ if (rejected !== undefined)
2101
+ return yield* rejection(rejected);
2102
+ return yield* Effect6.die(new Error("the runtime binding returned neither a program nor a rejection"));
2103
+ });
2104
+ return {
2105
+ load: (bundle) => Effect6.acquireRelease(acquire(bundle), (program) => program.free)
2106
+ };
2107
+ }));
2108
+
2109
+ // src/Session.ts
2110
+ var exports_Session = {};
2111
+ __export(exports_Session, {
2112
+ Session: () => Session,
2113
+ layer: () => layer2
2114
+ });
2115
+ import { Context as Context5, Effect as Effect7, Layer as Layer5, PubSub, Semaphore, Stream, SubscriptionRef } from "effect";
2116
+ class Session extends Context5.Service()("@lute-lang/runtime/Session") {
2117
+ }
2118
+ var layer2 = (options) => Layer5.effect(Session, Effect7.gen(function* () {
2119
+ const runtime = yield* LuteRuntime;
2120
+ const log = yield* InputLog;
2121
+ const bundle = yield* (yield* BundleSource).load;
2122
+ const program = yield* runtime.load(bundle);
2123
+ const started = "seed" in options ? yield* program.begin(options.seed) : {
2124
+ state: yield* program.restore(options.snapshot),
2125
+ output: { eventVersion: options.snapshot.snapshotVersion, events: [], await: options.snapshot.await }
2126
+ };
2127
+ const stage = yield* program.stage(started.state);
2128
+ yield* log.reset(options);
2129
+ const current = yield* SubscriptionRef.make({
2130
+ state: started.state,
2131
+ stage,
2132
+ await: started.output.await
2133
+ });
2134
+ const events = yield* PubSub.unbounded();
2135
+ const awaits = yield* PubSub.unbounded();
2136
+ yield* Effect7.addFinalizer(() => Effect7.andThen(PubSub.shutdown(events), PubSub.shutdown(awaits)));
2137
+ const lock = yield* Semaphore.make(1);
2138
+ const send = Effect7.fn("Lute.Session.send")(function* (input) {
2139
+ const { state } = yield* SubscriptionRef.get(current);
2140
+ const step = yield* program.step(state, input);
2141
+ yield* log.append({ input });
2142
+ const stage = yield* program.stage(step.state);
2143
+ yield* SubscriptionRef.set(current, { state: step.state, stage, await: step.output.await });
2144
+ yield* PubSub.publishAll(events, step.output.events);
2145
+ yield* PubSub.publish(awaits, step.output.await);
2146
+ return step.output;
2147
+ });
2148
+ const restore = Effect7.fn("Lute.Session.restore")(function* (snapshot) {
2149
+ const state = yield* program.restore(snapshot);
2150
+ const stage = yield* program.stage(state);
2151
+ yield* log.reset({ snapshot });
2152
+ yield* SubscriptionRef.set(current, { state, stage, await: snapshot.await });
2153
+ yield* PubSub.publish(awaits, snapshot.await);
2154
+ });
2155
+ return {
2156
+ fingerprint: program.fingerprint,
2157
+ program,
2158
+ started: started.output,
2159
+ send: (input) => lock.withPermits(1)(send(input)),
2160
+ current,
2161
+ events: Effect7.map(PubSub.subscribe(events), Stream.fromSubscription),
2162
+ awaits: Effect7.map(PubSub.subscribe(awaits), Stream.fromSubscription),
2163
+ save: SubscriptionRef.get(current).pipe(Effect7.flatMap(({ state }) => program.snapshot(state)), Effect7.withSpan("Lute.Session.save")),
2164
+ restore: (snapshot) => lock.withPermits(1)(restore(snapshot))
2165
+ };
2166
+ }));
2167
+
2168
+ export { __export, projectIndex, exports_Ir, WasmLoadError, exports_Errors, directory, url, exports_BundleSource, exports_Contract, LogEntry, memory, keyValueStore, exports_InputLog, LuteWasm2, fromBytes, exports_LuteWasm, exports_Program, layer, exports_LuteRuntime, layer2, exports_Session };