@lute-lang/runtime 0.39.0 → 0.40.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Where a session's bundle comes from (spec 0.39.0 §5.1): a `lute compile
2
+ * Where a session's bundle comes from (spec 0.40.0 §5.1): a `lute compile
3
3
  * --all` output directory, the same layout served over HTTP, or a value the
4
4
  * host already holds.
5
5
  */
package/dist/Errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The typed failures of the runtime (spec 0.39.0 §5.3).
2
+ * The typed failures of the runtime (spec 0.40.0 §5.3).
3
3
  *
4
4
  * A rejected input is an expected failure: each runtime code is its own
5
5
  * tagged error, carrying the runtime's `code` and `message`. A code this
@@ -14,6 +14,13 @@ declare const RuntimeBusy_base: Schema.Class<RuntimeBusy, Schema.TaggedStruct<"R
14
14
  /** `E-RUNTIME-BUSY`: the current await does not accept this input. */
15
15
  export declare class RuntimeBusy extends RuntimeBusy_base {
16
16
  }
17
+ declare const TimeoutUnavailable_base: Schema.Class<TimeoutUnavailable, Schema.TaggedStruct<"TimeoutUnavailable", {
18
+ readonly code: Schema.Literal<"E-RUNTIME-TIMEOUT">;
19
+ readonly message: Schema.String;
20
+ }>, import("effect/Cause").YieldableError>;
21
+ /** `E-RUNTIME-TIMEOUT`: the pending await is not a timed choice. */
22
+ export declare class TimeoutUnavailable extends TimeoutUnavailable_base {
23
+ }
17
24
  declare const RequestMismatch_base: Schema.Class<RequestMismatch, Schema.TaggedStruct<"RequestMismatch", {
18
25
  readonly code: Schema.Literal<"E-RUNTIME-REQUEST">;
19
26
  readonly message: Schema.String;
@@ -71,7 +78,7 @@ declare const SnapshotVersionMismatch_base: Schema.Class<SnapshotVersionMismatch
71
78
  export declare class SnapshotVersionMismatch extends SnapshotVersionMismatch_base {
72
79
  }
73
80
  /** Every rejection the runtime returns. */
74
- export type RuntimeRejection = RuntimeBusy | RequestMismatch | OptionUnavailable | BridgeShapeMismatch | InvalidInput | RuntimeHalted | IrVersionMismatch | SnapshotProjectMismatch | SnapshotVersionMismatch;
81
+ export type RuntimeRejection = RuntimeBusy | RequestMismatch | OptionUnavailable | BridgeShapeMismatch | InvalidInput | TimeoutUnavailable | RuntimeHalted | IrVersionMismatch | SnapshotProjectMismatch | SnapshotVersionMismatch;
75
82
  /**
76
83
  * Fail with the typed error of a runtime rejection; a code this package does
77
84
  * not know dies.
@@ -28,6 +28,7 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
28
28
  readonly await: Schema.suspend<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
29
29
  readonly menu: Schema.suspend<Schema.Struct<{
30
30
  readonly construct: Schema.String;
31
+ readonly default: Schema.optionalKey<Schema.NullOr<Schema.String>>;
31
32
  readonly document: Schema.String;
32
33
  readonly id: Schema.String;
33
34
  readonly options: Schema.$Array<Schema.suspend<Schema.Struct<{
@@ -39,7 +40,7 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
39
40
  readonly position: Schema.String;
40
41
  readonly presentation: Schema.Int;
41
42
  readonly prompt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
42
- readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
43
+ readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Int>>;
43
44
  }>>;
44
45
  readonly request: Schema.Int;
45
46
  readonly type: Schema.Literal<"awaitChoice">;
@@ -103,6 +104,32 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
103
104
  }>>>;
104
105
  readonly spentRun: Schema.UniqueArray<Schema.String>;
105
106
  readonly spentUser: Schema.UniqueArray<Schema.String>;
107
+ readonly stage: Schema.suspend<Schema.Struct<{
108
+ readonly actors: Schema.$Array<Schema.suspend<Schema.Struct<{
109
+ readonly anchor: Schema.optionalKey<Schema.NullOr<Schema.String>>;
110
+ readonly character: Schema.String;
111
+ readonly costume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
112
+ readonly emotion: Schema.optionalKey<Schema.NullOr<Schema.String>>;
113
+ }>>>;
114
+ readonly bg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
115
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
116
+ readonly location: Schema.optionalKey<Schema.NullOr<Schema.String>>;
117
+ readonly time: Schema.optionalKey<Schema.NullOr<Schema.String>>;
118
+ }>>>>;
119
+ readonly cg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
120
+ readonly assetId: Schema.String;
121
+ readonly layout: Schema.optionalKey<Schema.NullOr<Schema.String>>;
122
+ }>>>>;
123
+ readonly music: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
124
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
125
+ readonly mood: Schema.optionalKey<Schema.NullOr<Schema.String>>;
126
+ readonly playback: Schema.optionalKey<Schema.NullOr<Schema.String>>;
127
+ readonly volume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
128
+ }>>>>;
129
+ readonly video: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
130
+ readonly assetId: Schema.String;
131
+ }>>>>;
132
+ }>>;
106
133
  readonly state: Schema.$Record<Schema.String, Schema.suspend<Schema.toTaggedUnion<"kind", readonly [Schema.Struct<{
107
134
  readonly kind: Schema.Literal<"bool">;
108
135
  readonly value: Schema.Boolean;
@@ -142,6 +169,9 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
142
169
  readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
143
170
  }>>>>;
144
171
  }>>>;
172
+ }>, Schema.Struct<{
173
+ readonly request: Schema.Int;
174
+ readonly type: Schema.Literal<"timeout">;
145
175
  }>, Schema.Struct<{
146
176
  readonly option: Schema.String;
147
177
  readonly request: Schema.Int;
@@ -204,6 +234,7 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
204
234
  readonly pending: Schema.suspend<Schema.toTaggedUnion<"type", readonly [Schema.Struct<{
205
235
  readonly menu: Schema.suspend<Schema.Struct<{
206
236
  readonly construct: Schema.String;
237
+ readonly default: Schema.optionalKey<Schema.NullOr<Schema.String>>;
207
238
  readonly document: Schema.String;
208
239
  readonly id: Schema.String;
209
240
  readonly options: Schema.$Array<Schema.suspend<Schema.Struct<{
@@ -215,7 +246,7 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
215
246
  readonly position: Schema.String;
216
247
  readonly presentation: Schema.Int;
217
248
  readonly prompt: Schema.optionalKey<Schema.NullOr<Schema.String>>;
218
- readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
249
+ readonly timeout: Schema.optionalKey<Schema.NullOr<Schema.Int>>;
219
250
  }>>;
220
251
  readonly request: Schema.Int;
221
252
  readonly type: Schema.Literal<"awaitChoice">;
@@ -237,6 +268,32 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
237
268
  readonly site: Schema.optionalKey<Schema.NullOr<Schema.String>>;
238
269
  readonly type: Schema.Literal<"halted">;
239
270
  }>]>>;
271
+ readonly stage: Schema.suspend<Schema.Struct<{
272
+ readonly actors: Schema.$Array<Schema.suspend<Schema.Struct<{
273
+ readonly anchor: Schema.optionalKey<Schema.NullOr<Schema.String>>;
274
+ readonly character: Schema.String;
275
+ readonly costume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
276
+ readonly emotion: Schema.optionalKey<Schema.NullOr<Schema.String>>;
277
+ }>>>;
278
+ readonly bg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
279
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
280
+ readonly location: Schema.optionalKey<Schema.NullOr<Schema.String>>;
281
+ readonly time: Schema.optionalKey<Schema.NullOr<Schema.String>>;
282
+ }>>>>;
283
+ readonly cg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
284
+ readonly assetId: Schema.String;
285
+ readonly layout: Schema.optionalKey<Schema.NullOr<Schema.String>>;
286
+ }>>>>;
287
+ readonly music: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
288
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
289
+ readonly mood: Schema.optionalKey<Schema.NullOr<Schema.String>>;
290
+ readonly playback: Schema.optionalKey<Schema.NullOr<Schema.String>>;
291
+ readonly volume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
292
+ }>>>>;
293
+ readonly video: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
294
+ readonly assetId: Schema.String;
295
+ }>>>>;
296
+ }>>;
240
297
  }>>>>;
241
298
  readonly project: Schema.String;
242
299
  readonly request: Schema.Int;
@@ -271,6 +328,32 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
271
328
  }>>>;
272
329
  readonly spentRun: Schema.UniqueArray<Schema.String>;
273
330
  readonly spentUser: Schema.UniqueArray<Schema.String>;
331
+ readonly stage: Schema.suspend<Schema.Struct<{
332
+ readonly actors: Schema.$Array<Schema.suspend<Schema.Struct<{
333
+ readonly anchor: Schema.optionalKey<Schema.NullOr<Schema.String>>;
334
+ readonly character: Schema.String;
335
+ readonly costume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
336
+ readonly emotion: Schema.optionalKey<Schema.NullOr<Schema.String>>;
337
+ }>>>;
338
+ readonly bg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
339
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
340
+ readonly location: Schema.optionalKey<Schema.NullOr<Schema.String>>;
341
+ readonly time: Schema.optionalKey<Schema.NullOr<Schema.String>>;
342
+ }>>>>;
343
+ readonly cg: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
344
+ readonly assetId: Schema.String;
345
+ readonly layout: Schema.optionalKey<Schema.NullOr<Schema.String>>;
346
+ }>>>>;
347
+ readonly music: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
348
+ readonly assetId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
349
+ readonly mood: Schema.optionalKey<Schema.NullOr<Schema.String>>;
350
+ readonly playback: Schema.optionalKey<Schema.NullOr<Schema.String>>;
351
+ readonly volume: Schema.optionalKey<Schema.NullOr<Schema.String>>;
352
+ }>>>>;
353
+ readonly video: Schema.optionalKey<Schema.NullOr<Schema.suspend<Schema.Struct<{
354
+ readonly assetId: Schema.String;
355
+ }>>>>;
356
+ }>>;
274
357
  readonly state: Schema.$Record<Schema.String, Schema.suspend<Schema.toTaggedUnion<"kind", readonly [Schema.Struct<{
275
358
  readonly kind: Schema.Literal<"bool">;
276
359
  readonly value: Schema.Boolean;
@@ -311,6 +394,9 @@ export declare const LogEntry: Schema.Union<readonly [Schema.Struct<{
311
394
  readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
312
395
  }>>>>;
313
396
  }>>>;
397
+ }>, Schema.Struct<{
398
+ readonly request: Schema.Int;
399
+ readonly type: Schema.Literal<"timeout">;
314
400
  }>, Schema.Struct<{
315
401
  readonly option: Schema.String;
316
402
  readonly request: Schema.Int;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Loads bundles into {@link Program}s (spec 0.39.0 §5.1). A program lives in
2
+ * Loads bundles into {@link Program}s (spec 0.40.0 §5.1). A program lives in
3
3
  * the scope that loaded it and is freed when the scope closes.
4
4
  */
5
5
  import { Context, Effect, Layer, Scope } from "effect";
package/dist/Program.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * A loaded bundle and the runtime's step function over it (spec 0.39.0 §5.1).
2
+ * A loaded bundle and the runtime's step function over it (spec 0.40.0 §5.1).
3
3
  *
4
4
  * Every value crossing the binding is encoded and decoded with the contract
5
5
  * schemas generated from the Rust types. JSON the binding returns that does
@@ -34,6 +34,7 @@ export interface Program {
34
34
  readonly eligibility: (state: RuntimeState, beat: string, member?: string) => Effect.Effect<Option.Option<Contract.Candidate>>;
35
35
  readonly clock: (state: RuntimeState) => Effect.Effect<Option.Option<Contract.ClockAt>>;
36
36
  readonly terminal: (state: RuntimeState) => Effect.Effect<boolean>;
37
+ readonly stage: (state: RuntimeState) => Effect.Effect<Contract.Stage>;
37
38
  readonly view: (state: RuntimeState, options?: {
38
39
  readonly facts?: boolean;
39
40
  }) => Effect.Effect<Contract.WorldView>;
package/dist/Replay.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Replaying a recorded input log (spec 0.39.0 §5.4). Against the bundle
2
+ * Replaying a recorded input log (spec 0.40.0 §5.4). Against the bundle
3
3
  * that recorded it, a log reproduces every output.
4
4
  */
5
5
  import { Effect, Schema, Stream } from "effect";
package/dist/Session.d.ts CHANGED
@@ -1,18 +1,19 @@
1
1
  /**
2
- * One running playthrough (spec 0.39.0 §5.2): the host sends inputs, watches
2
+ * One running playthrough (spec 0.40.0 §5.2): the host sends inputs, watches
3
3
  * the state, and subscribes to events and awaits. The session adds no game
4
4
  * policy — it answers nothing and paces nothing.
5
5
  */
6
6
  import { Context, Effect, Layer, Scope, Stream, SubscriptionRef } from "effect";
7
7
  import { BundleSource } from "./BundleSource.js";
8
8
  import type { BundleError, InputLogError, RuntimeRejection } from "./Errors.js";
9
- import type { Await, Event, Input, Output, Seed, Snapshot } from "./generated/Contract.js";
9
+ import type { Await, Event, Input, Output, Seed, Snapshot, Stage } from "./generated/Contract.js";
10
10
  import { InputLog } from "./InputLog.js";
11
11
  import { LuteRuntime } from "./LuteRuntime.js";
12
12
  import type { RuntimeState } from "./Program.js";
13
- /** Where the session stands: its state and what it waits for. */
13
+ /** Where the session stands: its state, stage, and what it waits for. */
14
14
  export interface SessionState {
15
15
  readonly state: RuntimeState;
16
+ readonly stage: Stage;
16
17
  readonly await: Await;
17
18
  }
18
19
  declare const Session_base: Context.ServiceClass<Session, "@lute-lang/runtime/Session", {
package/dist/browser.js CHANGED
@@ -1,28 +1,28 @@
1
1
  import {
2
- LuteWasm,
3
2
  WasmLoadError,
4
- fromBytes,
3
+ url,
4
+ memory,
5
5
  keyValueStore,
6
+ LuteWasm2,
7
+ fromBytes,
6
8
  layer,
7
- layer1 as layer2,
8
- memory,
9
- url
10
- } from "./index-eqt12qy0.js";
9
+ layer2
10
+ } from "./index-wshk3yvw.js";
11
11
 
12
12
  // src/browser.ts
13
13
  import * as BrowserKeyValueStore from "@effect/platform-browser/BrowserKeyValueStore";
14
14
  import { Effect, Layer } from "effect";
15
15
  import * as FetchHttpClient from "effect/http/FetchHttpClient";
16
16
  import * as HttpClient from "effect/http/HttpClient";
17
- var wasm = (url2) => Layer.effect(LuteWasm, HttpClient.get(url2).pipe(Effect.flatMap((response) => response.arrayBuffer), Effect.mapError((error) => new WasmLoadError({ message: `cannot fetch the runtime binding: ${error.message}` })), Effect.flatMap(fromBytes))).pipe(Layer.provide(FetchHttpClient.layer));
18
- var runtime = (url2) => layer.pipe(Layer.provide(wasm(url2)));
17
+ var wasm = (url) => Layer.effect(LuteWasm2, HttpClient.get(url).pipe(Effect.flatMap((response) => response.arrayBuffer), Effect.mapError((error) => new WasmLoadError({ message: `cannot fetch the runtime binding: ${error.message}` })), Effect.flatMap(fromBytes))).pipe(Layer.provide(FetchHttpClient.layer));
18
+ var runtime = (url) => layer.pipe(Layer.provide(wasm(url)));
19
19
  var bundle = (base) => url(base).pipe(Layer.provide(FetchHttpClient.layer));
20
20
  var inputLog = (key) => keyValueStore(key).pipe(Layer.provide(BrowserKeyValueStore.layerLocalStorage));
21
21
  var session = (options) => layer2(options).pipe(Layer.provide(Layer.mergeAll(runtime(options.wasm), bundle(options.bundle), options.log === undefined ? memory : inputLog(options.log))));
22
22
  export {
23
- wasm,
24
- session,
25
- runtime,
23
+ bundle,
26
24
  inputLog,
27
- bundle
25
+ runtime,
26
+ session,
27
+ wasm
28
28
  };
package/dist/bun.js CHANGED
@@ -1,17 +1,17 @@
1
1
  import {
2
- LuteWasm,
3
2
  WasmLoadError,
4
3
  directory,
4
+ memory,
5
+ LuteWasm2,
5
6
  fromBytes,
6
7
  layer,
7
- layer1 as layer2,
8
- memory
9
- } from "./index-eqt12qy0.js";
8
+ layer2
9
+ } from "./index-wshk3yvw.js";
10
10
 
11
11
  // src/bun.ts
12
12
  import * as BunServices from "@effect/platform-bun/BunServices";
13
13
  import { Effect, FileSystem, Layer, Path } from "effect";
14
- var wasm = Layer.effect(LuteWasm, Effect.gen(function* () {
14
+ var wasm = Layer.effect(LuteWasm2, Effect.gen(function* () {
15
15
  const fs = yield* FileSystem.FileSystem;
16
16
  const path = yield* Path.Path;
17
17
  const bytes = yield* path.fromFileUrl(new URL("./wasm/lute_runtime_wasm_bg.wasm", import.meta.url)).pipe(Effect.flatMap(fs.readFile), Effect.mapError((error) => new WasmLoadError({ message: `cannot read the runtime binding: ${error.message}` })));
@@ -21,8 +21,8 @@ var runtime = layer.pipe(Layer.provide(wasm));
21
21
  var bundle = (directory2) => directory(directory2).pipe(Layer.provide(BunServices.layer));
22
22
  var session = (options) => layer2(options).pipe(Layer.provide(Layer.mergeAll(runtime, bundle(options.bundle), options.log ?? memory)));
23
23
  export {
24
- wasm,
25
- session,
24
+ bundle,
26
25
  runtime,
27
- bundle
26
+ session,
27
+ wasm
28
28
  };