@lute-lang/runtime 0.0.0-stage → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A compiled bundle: `project.index.json` and every artifact it lists, keyed
3
+ * by the index's `artifact` paths — the output of `lute compile --all`
4
+ * (spec 0.38.0 §4.1). The runtime validates it on load.
5
+ */
6
+ import { Schema } from "effect";
7
+ export declare const Bundle: Schema.Struct<{
8
+ readonly index: Schema.Codec<Schema.Json, Schema.Json, never, never>;
9
+ readonly artifacts: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
10
+ }>;
11
+ export type Bundle = typeof Bundle.Type;
12
+ /** The part of `project.index.json` a loader reads: where each artifact is. */
13
+ export declare const IndexDocuments: Schema.Struct<{
14
+ readonly documents: Schema.$Array<Schema.Struct<{
15
+ readonly artifact: Schema.String;
16
+ }>>;
17
+ }>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Where a session's bundle comes from (spec 0.39.0 §5.1): a `lute compile
3
+ * --all` output directory, the same layout served over HTTP, or a value the
4
+ * host already holds.
5
+ */
6
+ import { Context, Effect, FileSystem, Layer, Path } from "effect";
7
+ import * as HttpClient from "effect/http/HttpClient";
8
+ import { Bundle } from "./Bundle.js";
9
+ import type { BundleError } from "./Errors.js";
10
+ declare const BundleSource_base: Context.ServiceClass<BundleSource, "@lute-lang/runtime/BundleSource", {
11
+ readonly load: Effect.Effect<Bundle, BundleError>;
12
+ }>;
13
+ export declare class BundleSource extends BundleSource_base {
14
+ }
15
+ /** A bundle the host already holds. */
16
+ export declare const value: (bundle: Bundle) => Layer.Layer<BundleSource>;
17
+ /** A `lute compile --all` output directory. */
18
+ export declare const directory: (root: string) => Layer.Layer<BundleSource, never, FileSystem.FileSystem | Path.Path>;
19
+ /** A `lute compile --all` output served under `base` (a URL ending in `/`). */
20
+ export declare const url: (base: string) => Layer.Layer<BundleSource, never, HttpClient.HttpClient>;
21
+ export {};
@@ -0,0 +1,115 @@
1
+ /**
2
+ * The typed failures of the runtime (spec 0.39.0 §5.3).
3
+ *
4
+ * A rejected input is an expected failure: each runtime code is its own
5
+ * tagged error, carrying the runtime's `code` and `message`. A code this
6
+ * package does not know is contract drift — a defect, never a typed error.
7
+ */
8
+ import { Effect, Schema } from "effect";
9
+ import type { Rejected } from "./generated/Contract.js";
10
+ declare const RuntimeBusy_base: Schema.Class<RuntimeBusy, Schema.TaggedStruct<"RuntimeBusy", {
11
+ readonly code: Schema.Literal<"E-RUNTIME-BUSY">;
12
+ readonly message: Schema.String;
13
+ }>, import("effect/Cause").YieldableError>;
14
+ /** `E-RUNTIME-BUSY`: the current await does not accept this input. */
15
+ export declare class RuntimeBusy extends RuntimeBusy_base {
16
+ }
17
+ declare const RequestMismatch_base: Schema.Class<RequestMismatch, Schema.TaggedStruct<"RequestMismatch", {
18
+ readonly code: Schema.Literal<"E-RUNTIME-REQUEST">;
19
+ readonly message: Schema.String;
20
+ }>, import("effect/Cause").YieldableError>;
21
+ /** `E-RUNTIME-REQUEST`: an answer names another request than the pending await. */
22
+ export declare class RequestMismatch extends RequestMismatch_base {
23
+ }
24
+ declare const OptionUnavailable_base: Schema.Class<OptionUnavailable, Schema.TaggedStruct<"OptionUnavailable", {
25
+ readonly code: Schema.Literal<"E-RUNTIME-OPTION">;
26
+ readonly message: Schema.String;
27
+ }>, import("effect/Cause").YieldableError>;
28
+ /** `E-RUNTIME-OPTION`: the chosen option is absent from the menu or not open. */
29
+ export declare class OptionUnavailable extends OptionUnavailable_base {
30
+ }
31
+ declare const BridgeShapeMismatch_base: Schema.Class<BridgeShapeMismatch, Schema.TaggedStruct<"BridgeShapeMismatch", {
32
+ readonly code: Schema.Literal<"E-RUNTIME-BRIDGE-SHAPE">;
33
+ readonly message: Schema.String;
34
+ }>, import("effect/Cause").YieldableError>;
35
+ /** `E-RUNTIME-BRIDGE-SHAPE`: a bridge result misses or mistypes a read field. */
36
+ export declare class BridgeShapeMismatch extends BridgeShapeMismatch_base {
37
+ }
38
+ declare const InvalidInput_base: Schema.Class<InvalidInput, Schema.TaggedStruct<"InvalidInput", {
39
+ readonly code: Schema.Literal<"E-RUNTIME-INPUT">;
40
+ readonly message: Schema.String;
41
+ }>, import("effect/Cause").YieldableError>;
42
+ /** `E-RUNTIME-INPUT`: a seed or input names something the project lacks. */
43
+ export declare class InvalidInput extends InvalidInput_base {
44
+ }
45
+ declare const RuntimeHalted_base: Schema.Class<RuntimeHalted, Schema.TaggedStruct<"RuntimeHalted", {
46
+ readonly code: Schema.Literal<"E-RUNTIME-HALTED">;
47
+ readonly message: Schema.String;
48
+ }>, import("effect/Cause").YieldableError>;
49
+ /** `E-RUNTIME-HALTED`: the state halted; restore an earlier snapshot. */
50
+ export declare class RuntimeHalted extends RuntimeHalted_base {
51
+ }
52
+ declare const IrVersionMismatch_base: Schema.Class<IrVersionMismatch, Schema.TaggedStruct<"IrVersionMismatch", {
53
+ readonly code: Schema.Literal<"E-RUNTIME-IR-VERSION">;
54
+ readonly message: Schema.String;
55
+ }>, import("effect/Cause").YieldableError>;
56
+ /** `E-RUNTIME-IR-VERSION`: the bundle is not one this runtime executes. */
57
+ export declare class IrVersionMismatch extends IrVersionMismatch_base {
58
+ }
59
+ declare const SnapshotProjectMismatch_base: Schema.Class<SnapshotProjectMismatch, Schema.TaggedStruct<"SnapshotProjectMismatch", {
60
+ readonly code: Schema.Literal<"E-RUNTIME-SNAPSHOT-PROJECT">;
61
+ readonly message: Schema.String;
62
+ }>, import("effect/Cause").YieldableError>;
63
+ /** `E-RUNTIME-SNAPSHOT-PROJECT`: the snapshot belongs to another bundle. */
64
+ export declare class SnapshotProjectMismatch extends SnapshotProjectMismatch_base {
65
+ }
66
+ declare const SnapshotVersionMismatch_base: Schema.Class<SnapshotVersionMismatch, Schema.TaggedStruct<"SnapshotVersionMismatch", {
67
+ readonly code: Schema.Literal<"E-RUNTIME-SNAPSHOT-VERSION">;
68
+ readonly message: Schema.String;
69
+ }>, import("effect/Cause").YieldableError>;
70
+ /** `E-RUNTIME-SNAPSHOT-VERSION`: the snapshot is of another Event minor. */
71
+ export declare class SnapshotVersionMismatch extends SnapshotVersionMismatch_base {
72
+ }
73
+ /** Every rejection the runtime returns. */
74
+ export type RuntimeRejection = RuntimeBusy | RequestMismatch | OptionUnavailable | BridgeShapeMismatch | InvalidInput | RuntimeHalted | IrVersionMismatch | SnapshotProjectMismatch | SnapshotVersionMismatch;
75
+ /**
76
+ * Fail with the typed error of a runtime rejection; a code this package does
77
+ * not know dies.
78
+ */
79
+ export declare const fromRejected: (rejected: Rejected) => Effect.Effect<never, RuntimeRejection>;
80
+ declare const BundleNotFound_base: Schema.Class<BundleNotFound, Schema.TaggedStruct<"BundleNotFound", {
81
+ readonly path: Schema.String;
82
+ readonly message: Schema.String;
83
+ }>, import("effect/Cause").YieldableError>;
84
+ /** The bundle's `project.index.json` or an artifact it lists does not exist. */
85
+ export declare class BundleNotFound extends BundleNotFound_base {
86
+ }
87
+ declare const BundleUnreadable_base: Schema.Class<BundleUnreadable, Schema.TaggedStruct<"BundleUnreadable", {
88
+ readonly path: Schema.String;
89
+ readonly message: Schema.String;
90
+ }>, import("effect/Cause").YieldableError>;
91
+ /** The bundle exists but could not be read. */
92
+ export declare class BundleUnreadable extends BundleUnreadable_base {
93
+ }
94
+ declare const BundleMalformed_base: Schema.Class<BundleMalformed, Schema.TaggedStruct<"BundleMalformed", {
95
+ readonly path: Schema.String;
96
+ readonly message: Schema.String;
97
+ }>, import("effect/Cause").YieldableError>;
98
+ /** A bundle file is not the JSON a bundle holds. */
99
+ export declare class BundleMalformed extends BundleMalformed_base {
100
+ }
101
+ /** Why a bundle could not be loaded. */
102
+ export type BundleError = BundleNotFound | BundleUnreadable | BundleMalformed;
103
+ declare const WasmLoadError_base: Schema.Class<WasmLoadError, Schema.TaggedStruct<"WasmLoadError", {
104
+ readonly message: Schema.String;
105
+ }>, import("effect/Cause").YieldableError>;
106
+ /** The wasm binding could not be fetched or instantiated. */
107
+ export declare class WasmLoadError extends WasmLoadError_base {
108
+ }
109
+ declare const InputLogError_base: Schema.Class<InputLogError, Schema.TaggedStruct<"InputLogError", {
110
+ readonly message: Schema.String;
111
+ }>, import("effect/Cause").YieldableError>;
112
+ /** The input log could not be read or written. */
113
+ export declare class InputLogError extends InputLogError_base {
114
+ }
115
+ export {};
@@ -0,0 +1,388 @@
1
+ /**
2
+ * The recorded input log of a session (spec 0.38.0 §9: `(seed or snapshot,
3
+ * inputs)`). Replaying it against the same bundle reproduces every output;
4
+ * its entries have the `inputs.jsonl` line shape.
5
+ */
6
+ import { Context, Effect, Layer, Schema } from "effect";
7
+ import * as KeyValueStore from "effect/persistence/KeyValueStore";
8
+ import { InputLogError } from "./Errors.js";
9
+ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
10
+ readonly seed: Schema.Struct<{
11
+ readonly derive: Schema.optionalKey<Schema.Boolean>;
12
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
13
+ readonly save: Schema.optionalKey<Schema.suspend<Schema.Struct<{
14
+ readonly entriesRead: Schema.optionalKey<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
15
+ readonly presented: Schema.optionalKey<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
16
+ readonly questInstances: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Int>>;
17
+ readonly quests: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
18
+ readonly visited: Schema.optionalKey<Schema.$Array<Schema.String>>;
19
+ }>>>;
20
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
21
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
22
+ readonly path: Schema.String;
23
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
24
+ }>>>>;
25
+ }>;
26
+ }>, Schema.Struct<{
27
+ readonly snapshot: Schema.Struct<{
28
+ readonly await: Schema.suspend<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
29
+ readonly menu: Schema.suspend<Schema.Struct<{
30
+ readonly construct: Schema.String;
31
+ readonly document: Schema.String;
32
+ readonly id: Schema.String;
33
+ readonly options: Schema.$Array<Schema.suspend<Schema.Struct<{
34
+ readonly exit: Schema.Boolean;
35
+ readonly id: Schema.String;
36
+ readonly once: Schema.Boolean;
37
+ readonly verdict: Schema.String;
38
+ }>>>;
39
+ readonly position: Schema.String;
40
+ readonly presentation: Schema.Int;
41
+ readonly prompt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
42
+ readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
43
+ }>>;
44
+ readonly request: Schema.Int;
45
+ readonly type: Schema.Literal<"awaitChoice">;
46
+ }>, Schema.Struct<{
47
+ readonly document: Schema.String;
48
+ readonly fields: Schema.$Record<Schema.String, Schema.String>;
49
+ readonly position: Schema.String;
50
+ readonly request: Schema.Int;
51
+ readonly tag: Schema.String;
52
+ readonly type: Schema.Literal<"awaitBridge">;
53
+ }>, Schema.Struct<{
54
+ readonly type: Schema.Literal<"idle">;
55
+ }>, Schema.Struct<{
56
+ readonly reason: Schema.String;
57
+ readonly type: Schema.Literal<"ended">;
58
+ }>, Schema.Struct<{
59
+ readonly kind: Schema.String;
60
+ readonly message: Schema.String;
61
+ readonly site: Schema.optionalKey<Schema.NullOr<Schema.String>>;
62
+ readonly type: Schema.Literal<"halted">;
63
+ }>]>>;
64
+ readonly continuation: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
65
+ readonly answers: Schema.$Array<Schema.suspend<Schema.Union<readonly [Schema.Struct<{
66
+ readonly choice: Schema.Struct<{
67
+ readonly id: Schema.String;
68
+ readonly option: Schema.String;
69
+ }>;
70
+ }>, Schema.Struct<{
71
+ readonly bridge: Schema.Struct<{
72
+ readonly fields: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
73
+ readonly tag: Schema.String;
74
+ }>;
75
+ }>]>>>;
76
+ readonly before: Schema.suspend<Schema.Struct<{
77
+ readonly accepts: Schema.$Array<Schema.String>;
78
+ readonly advanceCascadeDepth: Schema.Int;
79
+ readonly cadence: Schema.suspend<Schema.Struct<{
80
+ readonly latched: Schema.$Record<Schema.String, Schema.NullOr<Schema.suspend<Schema.Struct<{
81
+ readonly day: Schema.Int;
82
+ readonly slot: Schema.Int;
83
+ }>>>>;
84
+ readonly live: Schema.$Record<Schema.String, Schema.Boolean>;
85
+ readonly rearm: Schema.$Record<Schema.String, Schema.Boolean>;
86
+ readonly spentSeason: Schema.UniqueArray<Schema.String>;
87
+ readonly windows: Schema.UniqueArray<Schema.String>;
88
+ }>>;
89
+ readonly clockAdvancedByBeat: Schema.Boolean;
90
+ readonly deferBy: Schema.optionalKey<Schema.NullOr<Schema.String>>;
91
+ readonly deferHandlers: Schema.Boolean;
92
+ readonly deferredHandlers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
93
+ readonly derive: Schema.optionalKey<Schema.NullOr<Schema.Boolean>>;
94
+ readonly facts: Schema.UniqueArray<Schema.Tuple<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
95
+ readonly failedObjectives: Schema.UniqueArray<Schema.String>;
96
+ readonly nextRunAccepts: Schema.$Array<Schema.String>;
97
+ readonly questInstances: Schema.$Record<Schema.String, Schema.Int>;
98
+ readonly quests: Schema.$Record<Schema.String, Schema.String>;
99
+ readonly shareSpentBy: Schema.$Record<Schema.String, Schema.String>;
100
+ readonly spentAt: Schema.$Record<Schema.String, Schema.suspend<Schema.Struct<{
101
+ readonly day: Schema.Int;
102
+ readonly slot: Schema.Int;
103
+ }>>>;
104
+ readonly spentRun: Schema.UniqueArray<Schema.String>;
105
+ readonly spentUser: Schema.UniqueArray<Schema.String>;
106
+ readonly state: Schema.$Record<Schema.String, Schema.suspend<Schema.toTaggedUnion<"kind", readonly [Schema.Struct<{
107
+ readonly kind: Schema.Literal<"bool">;
108
+ readonly value: Schema.Boolean;
109
+ }>, Schema.Struct<{
110
+ readonly kind: Schema.Literal<"int">;
111
+ readonly value: Schema.Int;
112
+ }>, Schema.Struct<{
113
+ readonly kind: Schema.Literal<"double">;
114
+ readonly value: Schema.Number;
115
+ }>, Schema.Struct<{
116
+ readonly kind: Schema.Literal<"str">;
117
+ readonly value: Schema.String;
118
+ }>, Schema.Struct<{
119
+ readonly kind: Schema.Literal<"unknown">;
120
+ }>, Schema.Struct<{
121
+ readonly kind: Schema.Literal<"error">;
122
+ readonly value: Schema.String;
123
+ }>]>>>;
124
+ readonly visited: Schema.UniqueArray<Schema.String>;
125
+ }>>;
126
+ readonly delivered: Schema.Int;
127
+ readonly input: Schema.suspend<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
128
+ readonly occasion: Schema.String;
129
+ readonly payload: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
130
+ readonly pick: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Struct<{
131
+ readonly beat: Schema.String;
132
+ }>]>>>>;
133
+ readonly target: Schema.optionalKey<Schema.NullOr<Schema.String>>;
134
+ readonly type: Schema.Literal<"raiseOccasion">;
135
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
136
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
137
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
138
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
139
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
140
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
141
+ readonly path: Schema.String;
142
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
143
+ }>>>>;
144
+ }>>>;
145
+ }>, Schema.Struct<{
146
+ readonly option: Schema.String;
147
+ readonly request: Schema.Int;
148
+ readonly type: Schema.Literal<"choose">;
149
+ }>, Schema.Struct<{
150
+ readonly fields: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
151
+ readonly request: Schema.Int;
152
+ readonly type: Schema.Literal<"bridgeResult">;
153
+ }>, Schema.Struct<{
154
+ readonly by: Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Int, Schema.Struct<{
155
+ readonly to: Schema.String;
156
+ }>, Schema.Struct<{
157
+ readonly to: Schema.suspend<Schema.Struct<{
158
+ readonly slot: Schema.optionalKey<Schema.NullOr<Schema.String>>;
159
+ readonly weekday: Schema.optionalKey<Schema.NullOr<Schema.String>>;
160
+ }>>;
161
+ }>]>>;
162
+ readonly pick: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Struct<{
163
+ readonly beat: Schema.String;
164
+ }>]>>>>;
165
+ readonly type: Schema.Literal<"advanceClock">;
166
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
167
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
168
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
169
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
170
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
171
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
172
+ readonly path: Schema.String;
173
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
174
+ }>>>>;
175
+ }>>>;
176
+ }>, Schema.Struct<{
177
+ readonly type: Schema.Literal<"hostWrite">;
178
+ readonly writes: Schema.suspend<Schema.Struct<{
179
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
180
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
181
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
182
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
183
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
184
+ readonly path: Schema.String;
185
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
186
+ }>>>>;
187
+ }>>;
188
+ }>, Schema.Struct<{
189
+ readonly name: Schema.String;
190
+ readonly type: Schema.Literal<"worldEvent">;
191
+ }>, Schema.Struct<{
192
+ readonly type: Schema.Literal<"newRun">;
193
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
194
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
195
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
196
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
197
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
198
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
199
+ readonly path: Schema.String;
200
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
201
+ }>>>>;
202
+ }>>>;
203
+ }>]>>;
204
+ readonly pending: Schema.suspend<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
205
+ readonly menu: Schema.suspend<Schema.Struct<{
206
+ readonly construct: Schema.String;
207
+ readonly document: Schema.String;
208
+ readonly id: Schema.String;
209
+ readonly options: Schema.$Array<Schema.suspend<Schema.Struct<{
210
+ readonly exit: Schema.Boolean;
211
+ readonly id: Schema.String;
212
+ readonly once: Schema.Boolean;
213
+ readonly verdict: Schema.String;
214
+ }>>>;
215
+ readonly position: Schema.String;
216
+ readonly presentation: Schema.Int;
217
+ readonly prompt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
218
+ readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
219
+ }>>;
220
+ readonly request: Schema.Int;
221
+ readonly type: Schema.Literal<"awaitChoice">;
222
+ }>, Schema.Struct<{
223
+ readonly document: Schema.String;
224
+ readonly fields: Schema.$Record<Schema.String, Schema.String>;
225
+ readonly position: Schema.String;
226
+ readonly request: Schema.Int;
227
+ readonly tag: Schema.String;
228
+ readonly type: Schema.Literal<"awaitBridge">;
229
+ }>, Schema.Struct<{
230
+ readonly type: Schema.Literal<"idle">;
231
+ }>, Schema.Struct<{
232
+ readonly reason: Schema.String;
233
+ readonly type: Schema.Literal<"ended">;
234
+ }>, Schema.Struct<{
235
+ readonly kind: Schema.String;
236
+ readonly message: Schema.String;
237
+ readonly site: Schema.optionalKey<Schema.NullOr<Schema.String>>;
238
+ readonly type: Schema.Literal<"halted">;
239
+ }>]>>;
240
+ }>>>>;
241
+ readonly project: Schema.String;
242
+ readonly request: Schema.Int;
243
+ readonly snapshotVersion: Schema.String;
244
+ readonly world: Schema.suspend<Schema.Struct<{
245
+ readonly accepts: Schema.$Array<Schema.String>;
246
+ readonly advanceCascadeDepth: Schema.Int;
247
+ readonly cadence: Schema.suspend<Schema.Struct<{
248
+ readonly latched: Schema.$Record<Schema.String, Schema.NullOr<Schema.suspend<Schema.Struct<{
249
+ readonly day: Schema.Int;
250
+ readonly slot: Schema.Int;
251
+ }>>>>;
252
+ readonly live: Schema.$Record<Schema.String, Schema.Boolean>;
253
+ readonly rearm: Schema.$Record<Schema.String, Schema.Boolean>;
254
+ readonly spentSeason: Schema.UniqueArray<Schema.String>;
255
+ readonly windows: Schema.UniqueArray<Schema.String>;
256
+ }>>;
257
+ readonly clockAdvancedByBeat: Schema.Boolean;
258
+ readonly deferBy: Schema.optionalKey<Schema.NullOr<Schema.String>>;
259
+ readonly deferHandlers: Schema.Boolean;
260
+ readonly deferredHandlers: Schema.$Array<Schema.Tuple<readonly [Schema.String, Schema.String]>>;
261
+ readonly derive: Schema.optionalKey<Schema.NullOr<Schema.Boolean>>;
262
+ readonly facts: Schema.UniqueArray<Schema.Tuple<readonly [Schema.String, Schema.$Array<Schema.String>]>>;
263
+ readonly failedObjectives: Schema.UniqueArray<Schema.String>;
264
+ readonly nextRunAccepts: Schema.$Array<Schema.String>;
265
+ readonly questInstances: Schema.$Record<Schema.String, Schema.Int>;
266
+ readonly quests: Schema.$Record<Schema.String, Schema.String>;
267
+ readonly shareSpentBy: Schema.$Record<Schema.String, Schema.String>;
268
+ readonly spentAt: Schema.$Record<Schema.String, Schema.suspend<Schema.Struct<{
269
+ readonly day: Schema.Int;
270
+ readonly slot: Schema.Int;
271
+ }>>>;
272
+ readonly spentRun: Schema.UniqueArray<Schema.String>;
273
+ readonly spentUser: Schema.UniqueArray<Schema.String>;
274
+ readonly state: Schema.$Record<Schema.String, Schema.suspend<Schema.toTaggedUnion<"kind", readonly [Schema.Struct<{
275
+ readonly kind: Schema.Literal<"bool">;
276
+ readonly value: Schema.Boolean;
277
+ }>, Schema.Struct<{
278
+ readonly kind: Schema.Literal<"int">;
279
+ readonly value: Schema.Int;
280
+ }>, Schema.Struct<{
281
+ readonly kind: Schema.Literal<"double">;
282
+ readonly value: Schema.Number;
283
+ }>, Schema.Struct<{
284
+ readonly kind: Schema.Literal<"str">;
285
+ readonly value: Schema.String;
286
+ }>, Schema.Struct<{
287
+ readonly kind: Schema.Literal<"unknown">;
288
+ }>, Schema.Struct<{
289
+ readonly kind: Schema.Literal<"error">;
290
+ readonly value: Schema.String;
291
+ }>]>>>;
292
+ readonly visited: Schema.UniqueArray<Schema.String>;
293
+ }>>;
294
+ }>;
295
+ }>, Schema.Struct<{
296
+ readonly input: Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
297
+ readonly occasion: Schema.String;
298
+ readonly payload: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
299
+ readonly pick: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Struct<{
300
+ readonly beat: Schema.String;
301
+ }>]>>>>;
302
+ readonly target: Schema.optionalKey<Schema.NullOr<Schema.String>>;
303
+ readonly type: Schema.Literal<"raiseOccasion">;
304
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
305
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
306
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
307
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
308
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
309
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
310
+ readonly path: Schema.String;
311
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
312
+ }>>>>;
313
+ }>>>;
314
+ }>, Schema.Struct<{
315
+ readonly option: Schema.String;
316
+ readonly request: Schema.Int;
317
+ readonly type: Schema.Literal<"choose">;
318
+ }>, Schema.Struct<{
319
+ readonly fields: Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>;
320
+ readonly request: Schema.Int;
321
+ readonly type: Schema.Literal<"bridgeResult">;
322
+ }>, Schema.Struct<{
323
+ readonly by: Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Int, Schema.Struct<{
324
+ readonly to: Schema.String;
325
+ }>, Schema.Struct<{
326
+ readonly to: Schema.suspend<Schema.Struct<{
327
+ readonly slot: Schema.optionalKey<Schema.NullOr<Schema.String>>;
328
+ readonly weekday: Schema.optionalKey<Schema.NullOr<Schema.String>>;
329
+ }>>;
330
+ }>]>>;
331
+ readonly pick: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Union<readonly [Schema.String, Schema.Struct<{
332
+ readonly beat: Schema.String;
333
+ }>]>>>>;
334
+ readonly type: Schema.Literal<"advanceClock">;
335
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
336
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
337
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
338
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
339
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
340
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
341
+ readonly path: Schema.String;
342
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
343
+ }>>>>;
344
+ }>>>;
345
+ }>, Schema.Struct<{
346
+ readonly type: Schema.Literal<"hostWrite">;
347
+ readonly writes: Schema.suspend<Schema.Struct<{
348
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
349
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
350
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
351
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
352
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
353
+ readonly path: Schema.String;
354
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
355
+ }>>>>;
356
+ }>>;
357
+ }>, Schema.Struct<{
358
+ readonly name: Schema.String;
359
+ readonly type: Schema.Literal<"worldEvent">;
360
+ }>, Schema.Struct<{
361
+ readonly type: Schema.Literal<"newRun">;
362
+ readonly writes: Schema.optionalKey<Schema.suspend<Schema.Struct<{
363
+ readonly accept: Schema.optionalKey<Schema.$Array<Schema.String>>;
364
+ readonly facts: Schema.optionalKey<Schema.$Array<Schema.String>>;
365
+ readonly retract: Schema.optionalKey<Schema.$Array<Schema.String>>;
366
+ readonly state: Schema.optionalKey<Schema.$Array<Schema.suspend<Schema.Struct<{
367
+ readonly add: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
368
+ readonly path: Schema.String;
369
+ readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
370
+ }>>>>;
371
+ }>>>;
372
+ }>]>;
373
+ }>]>;
374
+ export type LogEntry = typeof LogEntry.Type;
375
+ declare const InputLog_base: Context.ServiceClass<InputLog, "@lute-lang/runtime/InputLog", {
376
+ /** Start a new log with its `seed` or `snapshot` entry. */
377
+ readonly reset: (start: LogEntry) => Effect.Effect<void, InputLogError>;
378
+ /** Record an accepted input. */
379
+ readonly append: (entry: LogEntry) => Effect.Effect<void, InputLogError>;
380
+ readonly entries: Effect.Effect<ReadonlyArray<LogEntry>, InputLogError>;
381
+ }>;
382
+ export declare class InputLog extends InputLog_base {
383
+ }
384
+ /** A log held in memory for the session's lifetime. */
385
+ export declare const memory: Layer.Layer<InputLog>;
386
+ /** A log persisted under `key` in a `KeyValueStore` (e.g. `localStorage`). */
387
+ export declare const keyValueStore: (key: string) => Layer.Layer<InputLog, never, KeyValueStore.KeyValueStore>;
388
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Loads bundles into {@link Program}s (spec 0.39.0 §5.1). A program lives in
3
+ * the scope that loaded it and is freed when the scope closes.
4
+ */
5
+ import { Context, Effect, Layer, Scope } from "effect";
6
+ import type { Bundle } from "./Bundle.js";
7
+ import type * as Errors from "./Errors.js";
8
+ import { LuteWasm } from "./LuteWasm.js";
9
+ import * as Program from "./Program.js";
10
+ declare const LuteRuntime_base: Context.ServiceClass<LuteRuntime, "@lute-lang/runtime/LuteRuntime", {
11
+ /**
12
+ * Load a bundle. `IrVersionMismatch` when the runtime does not execute
13
+ * it (another IR line, an unknown command kind, not a bundle).
14
+ */
15
+ readonly load: (bundle: Bundle) => Effect.Effect<Program.Program, Errors.RuntimeRejection, Scope.Scope>;
16
+ }>;
17
+ export declare class LuteRuntime extends LuteRuntime_base {
18
+ }
19
+ export declare const layer: Layer.Layer<LuteRuntime, never, LuteWasm>;
20
+ export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The instantiated wasm binding (`crates/lute-runtime-wasm`) as a service.
3
+ *
4
+ * Platform layers (`@lute-lang/runtime/bun`, `@lute-lang/runtime/browser`)
5
+ * obtain the module's bytes and instantiate it through {@link fromBytes};
6
+ * nothing else in the package touches the glue's module state.
7
+ */
8
+ import { Context, Effect, Layer } from "effect";
9
+ import { WasmLoadError } from "./Errors.js";
10
+ import * as Glue from "./wasm/lute_runtime_wasm.js";
11
+ /** The binding's entry point: `Program.load` and the result classes it returns. */
12
+ export interface LuteWasmShape {
13
+ readonly Program: typeof Glue.Program;
14
+ }
15
+ declare const LuteWasm_base: Context.ServiceClass<LuteWasm, "@lute-lang/runtime/LuteWasm", LuteWasmShape>;
16
+ export declare class LuteWasm extends LuteWasm_base {
17
+ }
18
+ /**
19
+ * Instantiate the binding from the `.wasm` bytes. Bytes backed by a
20
+ * `SharedArrayBuffer` are refused: WebAssembly compiles from an
21
+ * `ArrayBuffer`.
22
+ */
23
+ export declare const fromBytes: (bytes: Uint8Array | ArrayBuffer) => Effect.Effect<LuteWasmShape, WasmLoadError>;
24
+ /** The binding instantiated from bytes the host already holds. */
25
+ export declare const layerFromBytes: (bytes: Uint8Array | ArrayBuffer) => Layer.Layer<LuteWasm, WasmLoadError>;
26
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A loaded bundle and the runtime's step function over it (spec 0.39.0 §5.1).
3
+ *
4
+ * Every value crossing the binding is encoded and decoded with the contract
5
+ * schemas generated from the Rust types. JSON the binding returns that does
6
+ * not decode is contract drift — a defect.
7
+ */
8
+ import { Effect, Option } from "effect";
9
+ import * as Errors from "./Errors.js";
10
+ import * as Contract from "./generated/Contract.js";
11
+ import type * as Glue from "./wasm/lute_runtime_wasm.js";
12
+ declare const TypeId = "~@lute-lang/runtime/RuntimeState";
13
+ /**
14
+ * An opaque, immutable runtime state. Stepping from it never invalidates it,
15
+ * so a host may keep earlier states (undo, branching). Its serialized form
16
+ * is {@link Program.snapshot}.
17
+ */
18
+ export interface RuntimeState {
19
+ readonly [TypeId]: typeof TypeId;
20
+ }
21
+ /** One accepted input: the state it produced and the runtime's output. */
22
+ export interface Step {
23
+ readonly state: RuntimeState;
24
+ readonly output: Contract.Output;
25
+ }
26
+ export interface Program {
27
+ /** The bundle's identity, which snapshots carry. */
28
+ readonly fingerprint: string;
29
+ readonly begin: (seed: Contract.Seed) => Effect.Effect<Step, Errors.RuntimeRejection>;
30
+ readonly step: (state: RuntimeState, input: Contract.Input) => Effect.Effect<Step, Errors.RuntimeRejection>;
31
+ readonly snapshot: (state: RuntimeState) => Effect.Effect<Contract.Snapshot>;
32
+ readonly restore: (snapshot: Contract.Snapshot) => Effect.Effect<RuntimeState, Errors.RuntimeRejection>;
33
+ readonly candidates: (state: RuntimeState, occasion: string, target?: string) => Effect.Effect<ReadonlyArray<Contract.Candidate>>;
34
+ readonly eligibility: (state: RuntimeState, beat: string, member?: string) => Effect.Effect<Option.Option<Contract.Candidate>>;
35
+ readonly clock: (state: RuntimeState) => Effect.Effect<Option.Option<Contract.ClockAt>>;
36
+ readonly terminal: (state: RuntimeState) => Effect.Effect<boolean>;
37
+ readonly view: (state: RuntimeState, options?: {
38
+ readonly facts?: boolean;
39
+ }) => Effect.Effect<Contract.WorldView>;
40
+ }
41
+ /** Fail with a rejection the binding returned as JSON. */
42
+ export declare const rejection: (json: string) => Effect.Effect<never, Errors.RuntimeRejection>;
43
+ /** Wrap a program the binding loaded. The caller owns its lifetime ({@link free}). */
44
+ export declare const make: (raw: Glue.Program) => Program & {
45
+ readonly free: Effect.Effect<void>;
46
+ };
47
+ export {};