@serene-pub/sdk 0.6.0-pr-8 → 0.6.0-pr-9

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.
Files changed (62) hide show
  1. package/dist/announce.d.ts +36 -3
  2. package/dist/announce.js +59 -4
  3. package/dist/builder.d.ts +5 -7
  4. package/dist/cadences.d.ts +1 -3
  5. package/dist/componentWire.js +28 -0
  6. package/dist/conditions.d.ts +5 -1
  7. package/dist/conditions.js +7 -0
  8. package/dist/declarations.d.ts +63 -1
  9. package/dist/declarations.js +172 -7
  10. package/dist/descriptors.d.ts +86 -12
  11. package/dist/descriptors.js +83 -5
  12. package/dist/document.d.ts +1 -1
  13. package/dist/events.d.ts +68 -25
  14. package/dist/events.js +35 -2
  15. package/dist/executor.d.ts +27 -0
  16. package/dist/executor.js +6 -3
  17. package/dist/exposure.d.ts +35 -1
  18. package/dist/exposure.js +64 -2
  19. package/dist/extension.d.ts +13 -2
  20. package/dist/extension.js +3 -1
  21. package/dist/genres.d.ts +61 -3
  22. package/dist/genres.js +131 -10
  23. package/dist/hostElements.d.ts +3 -3
  24. package/dist/hostElements.js +12 -4
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/participants.d.ts +30 -0
  28. package/dist/provisos.d.ts +92 -0
  29. package/dist/provisos.js +273 -0
  30. package/dist/receiverRules.js +1 -1
  31. package/dist/registrations.d.ts +154 -14
  32. package/dist/registrations.js +293 -23
  33. package/dist/repertoires.d.ts +13 -1
  34. package/dist/repertoires.js +5 -1
  35. package/dist/rulesetDocument.d.ts +11 -0
  36. package/dist/rulesetDocument.js +17 -0
  37. package/dist/rulesetSections.d.ts +12 -0
  38. package/dist/rulesetSections.js +8 -0
  39. package/dist/rulesets.js +6 -0
  40. package/dist/sceneSettings.d.ts +3 -1
  41. package/dist/sceneSettings.js +3 -1
  42. package/dist/sessionDossier.d.ts +102 -2
  43. package/dist/sessionSettings.d.ts +18 -0
  44. package/dist/shapes.d.ts +9 -0
  45. package/dist/shapes.js +9 -0
  46. package/dist/speech.d.ts +14 -3
  47. package/dist/storyTime.d.ts +77 -1
  48. package/dist/storyTime.js +111 -4
  49. package/dist/surfaces.d.ts +38 -1
  50. package/dist/surfaces.js +3 -0
  51. package/dist/template.d.ts +13 -1
  52. package/dist/templateCheck.js +175 -12
  53. package/dist/templateFit.js +4 -1
  54. package/dist/validate.js +69 -0
  55. package/dist/variableLayouts.d.ts +19 -0
  56. package/dist/variableLayouts.js +19 -0
  57. package/dist/variables.d.ts +202 -13
  58. package/dist/variables.js +258 -32
  59. package/dist/widgets.d.ts +68 -9
  60. package/dist/widgets.js +10 -2
  61. package/host-elements.d.ts +4 -2
  62. package/package.json +1 -1
@@ -29,6 +29,14 @@
29
29
  * trigger is a different registration. Two alike in one layer warn, never
30
30
  * refuse (R34).
31
31
  *
32
+ * ## One registration runs
33
+ *
34
+ * An event declared `runsOne` runs exactly one of its registrations: the
35
+ * session's choice, else the one marked `default: true`. Each registration is
36
+ * an option a session's owner picks, named by its `label`. A later layer's
37
+ * `default` replaces the earlier layers' (`effectiveRegistrations`); the door
38
+ * refuses two marks in one layer and warns when none is marked.
39
+ *
32
40
  * ## Objects first; strings warn (R30, A18)
33
41
  *
34
42
  * `register()` takes the declared objects — an event (`coreEvents.…`, a
@@ -46,6 +54,7 @@ import { type I18n } from './i18n.js';
46
54
  import { type EventDef, type SessionEventDecl } from './events.js';
47
55
  import { type CadenceRef } from './cadences.js';
48
56
  import { type ConditionDecl } from './conditions.js';
57
+ import { type ClauseMode } from './clauses.js';
49
58
  import { type NormalizedAction } from './actions.js';
50
59
  /**
51
60
  * The trigger families — open (LS1): Live is a later family, and a closed
@@ -87,15 +96,16 @@ export type RoutineMode = 'off' | 'review' | 'full';
87
96
  /** The routine modes. @experimental */
88
97
  export declare const ROUTINE_MODES: readonly RoutineMode[];
89
98
  /**
90
- * The per-routine cron caps (R11) — each at most the owner's user setting,
91
- * which is at most the system's. For routines on the system clock.
99
+ * A routine's run limit (R11, RG2) — each at most the owner's user setting,
100
+ * which is at most the system's. It counts a routine group's runs (a routine
101
+ * with no routine group is one of its own), and is valid on any cadence.
92
102
  * @experimental
93
- * @ruling R11
103
+ * @ruling R11, RG2
94
104
  */
95
105
  export interface RoutineCaps {
96
106
  /** How long the session may go without a person's interaction before the routine stops running. */
97
107
  readonly idleTimeoutMinutes?: number;
98
- /** How many system-clock routine runs may happen since the last interaction. */
108
+ /** How many runs may happen since the last interaction. */
99
109
  readonly maxRunsInRow?: number;
100
110
  }
101
111
  /**
@@ -110,7 +120,11 @@ export interface RegistrationDecl {
110
120
  readonly trigger: Trigger;
111
121
  /** The spec id of the pipeline that runs. */
112
122
  readonly pipeline: string;
113
- /** Runs only when this holds over the session's published values (R31: absent = always). */
123
+ /**
124
+ * Runs only when this holds over the session's published values (R31: absent = always). A
125
+ * registration on an event also reads that event's payload, under the reserved name `event`
126
+ * (`event.asked` on Turn order asked); an action's or a routine's `when` has no event to read.
127
+ */
114
128
  readonly when?: ConditionDecl;
115
129
  /** Changes to the pipeline's declared defaults (R38). */
116
130
  readonly values?: RegistrationValues;
@@ -120,7 +134,10 @@ export interface RegistrationDecl {
120
134
  readonly mode?: RoutineMode;
121
135
  /** Routines only (R18): default false — a firing that finds one waiting is refused. */
122
136
  readonly allowStacking?: boolean;
123
- /** Routines on the system clock only (R11), an administrator's. */
137
+ /**
138
+ * Routines only (R11, RG2), an administrator's: the run limit counts a routine group's runs (a
139
+ * routine with no routine group is one of its own); valid on any cadence.
140
+ */
124
141
  readonly caps?: RoutineCaps;
125
142
  /**
126
143
  * 🚧 How old a line must be before this registration's run may name it in `sources` — a message
@@ -128,11 +145,52 @@ export interface RegistrationDecl {
128
145
  * 20 for a routine, 0 for an action or an event (a person vouches; the scene closed).
129
146
  */
130
147
  readonly minAge?: number;
131
- /** What the settings call it, when not the pipeline's name. */
148
+ /**
149
+ * What the settings call it, when not the pipeline's name — on an event where one registration
150
+ * runs, the name of the option a session's owner picks.
151
+ */
152
+ readonly label?: I18n;
153
+ /**
154
+ * 🚧 On an event where one registration runs (`EventDef.runsOne`): the one that
155
+ * runs when the session chose none. At most one per event in a layer; a later
156
+ * layer's mark replaces the earlier layers' (`effectiveRegistrations`). Refused
157
+ * on any other trigger (`registrationFindings`).
158
+ * ⚠ Not a pipeline's default preset (`.defaults()`), not a field's `default` value.
159
+ * @ruling programme 2.3, TC2, TN1 (owner 2026-11-18)
160
+ */
161
+ readonly default?: true;
162
+ /**
163
+ * 🚧 The routine group this routine belongs to (its key). Set by `register(routineGroup(…), …)`
164
+ * or a preset's `change: [{ of, group }]`. Absent: the routine is a routine group of its own
165
+ * (the host's reading); the SDK never adds `group` to such a declaration.
166
+ */
167
+ readonly group?: string;
168
+ }
169
+ /**
170
+ * 🚧 A routine group: routines that share one cadence, one `when`, one stacking switch and one
171
+ * run limit (RG1, RG2). Made with `routineGroup(cadence, { key, … })`; a routine joins it with
172
+ * `register(group, pipeline)` or a preset's `change: [{ of, group }]`. A routine with no routine
173
+ * group is a routine group of its own (the host's reading).
174
+ * @experimental
175
+ * @ruling RG1, RG2, RG3, RN1
176
+ */
177
+ export interface RoutineGroupDecl {
178
+ /** Author-chosen slug: lowercase letters, digits and dashes. */
179
+ readonly key: string;
180
+ /** When the routine group fires. */
181
+ readonly cadence: CadenceRef;
132
182
  readonly label?: I18n;
183
+ /** Over the session's published values; a routine group has no event to read. */
184
+ readonly when?: ConditionDecl;
185
+ /** Default false — a firing that finds one waiting is refused. */
186
+ readonly allowStacking?: boolean;
187
+ /** The routine group's run limit. */
188
+ readonly caps?: RoutineCaps;
189
+ /** How its routines run: `sequential` (default, one after another) or `parallel` (side by side). */
190
+ readonly run?: ClauseMode;
133
191
  }
134
192
  /** What `register()` takes beside the trigger and the pipeline. @experimental */
135
- export type RegistrationOptions = Omit<RegistrationDecl, 'key' | 'trigger' | 'pipeline'>;
193
+ export type RegistrationOptions = Omit<RegistrationDecl, 'key' | 'trigger' | 'pipeline' | 'group'>;
136
194
  /** 🚧 The routine default (ruled 2026-10-24). @experimental */
137
195
  export declare const DEFAULT_ROUTINE_MIN_AGE = 20;
138
196
  /** 🚧 A registration's effective minAge. @experimental */
@@ -172,9 +230,25 @@ export declare function actionHandlesOf(s: {
172
230
  contributes?: unknown;
173
231
  }): Record<string, ActionHandle>;
174
232
  /** What `register()` accepts as a trigger: the declared objects, or a string (warned, R30). @experimental */
175
- export type TriggerInput = EventDef | SessionEventDecl | ActionHandle | CadenceRef | Trigger | string;
233
+ export type TriggerInput = EventDef | SessionEventDecl | ActionHandle | CadenceRef | RoutineGroupDecl | Trigger | string;
176
234
  /** What `register()` accepts as a pipeline: the spec you built or compiled, `use('…')`, or a string (warned, R30). @experimental */
177
235
  export type PipelineInput = BuiltSpec | SpecDocument | ExternalRef | string;
236
+ /**
237
+ * 🚧 Declare a routine group: routines that fire together on `cadence`, counted and limited as
238
+ * one. `key` is the author's slug (`scenes`, `world-turns`). A routine joins it with
239
+ * `register(group, pipeline)` or a preset's `change: [{ of, group }]`. Judges nothing but the
240
+ * shape; the values are `routineGroupFindings`'s.
241
+ * @experimental
242
+ * @ruling RG1, RG2, RG3, RN1
243
+ */
244
+ export declare function routineGroup(cadence: CadenceRef, opts: {
245
+ key: string;
246
+ label?: I18n;
247
+ when?: ConditionDecl;
248
+ allowStacking?: boolean;
249
+ caps?: RoutineCaps;
250
+ run?: ClauseMode;
251
+ }): RoutineGroupDecl;
178
252
  /** The arrow a registration key joins its two halves with. @experimental */
179
253
  export declare const REGISTRATION_KEY_JOIN = "\u2192";
180
254
  /** A trigger's half of a registration key. @experimental */
@@ -197,6 +271,7 @@ export declare function registrationKeyOf(trigger: Trigger | TriggerInput, pipel
197
271
  export declare function triggerOf(input: TriggerInput): {
198
272
  trigger: Trigger;
199
273
  spelled?: string;
274
+ group?: string;
200
275
  };
201
276
  /** The spec id a registration names, and the range a `use()` carried. @internal */
202
277
  export declare function pipelineOf(input: PipelineInput): {
@@ -209,7 +284,8 @@ export declare function pipelineOf(input: PipelineInput): {
209
284
  * key is derived (A8); `opts` are the registration's `when`, `values`,
210
285
  * `order` and, for a routine, `mode`, `allowStacking` and `caps`. Nothing
211
286
  * here refuses what the door judges (fit, cadence options, duplicates): call
212
- * `registrationFindings`, which a package build and a host both do.
287
+ * `registrationFindings`, which a package build and a host both do. A routine
288
+ * group (`routineGroup(…)`) as the trigger makes the routine a member of it.
213
289
  * @experimental
214
290
  * @ruling D1, A8, R30
215
291
  */
@@ -258,7 +334,7 @@ export declare function emitCycles(decls: readonly RegistrationDecl[], pipeline:
258
334
  * story clock, a session that has one;
259
335
  * · the pipeline resolves, and **fits** the trigger (R4, R12);
260
336
  * · routine-only fields (`mode`, `allowStacking`, `caps`) sit on routines,
261
- * caps on the system clock and within the system's (R11);
337
+ * caps within the system's (RG2);
262
338
  * · `values` set the slots a registration may (never a connection), on
263
339
  * nodes the pipeline has;
264
340
  * · the pipeline exposes no model plumbing to the owner (ruled 10-12);
@@ -268,6 +344,19 @@ export declare function emitCycles(decls: readonly RegistrationDecl[], pipeline:
268
344
  * @ruling §11-2, R4, R11, R12, R30, R34, A11, A12, LS1
269
345
  */
270
346
  export declare function registrationFindings(decls: readonly RegistrationDecl[], ctx?: RegistrationContext): Finding[];
347
+ /**
348
+ * 🚧 **The routine group door**: the whole-list check a host calls beside
349
+ * `registrationFindings`, which stays per registration. It judges each routine
350
+ * group (shape, key, cadence, clock, `run`, stacking, run limit, `when`, label,
351
+ * duplicates), each registration's `group` (a routine's, naming a declared
352
+ * routine group, never restating what the routine group owns), and warns about
353
+ * a routine group no routine is in. A host passes the effective routine groups
354
+ * (`effectiveRoutineGroups`) with the effective registrations. `groups` of
355
+ * `null` or `undefined`: a check the context cannot support is skipped.
356
+ * @experimental
357
+ * @ruling RG1, RG2, RG3
358
+ */
359
+ export declare function routineGroupFindings(decls: readonly RegistrationDecl[], groups: readonly RoutineGroupDecl[] | null | undefined, ctx?: RegistrationContext): Finding[];
271
360
  /**
272
361
  * Author presets a pipeline ships that are not its declared defaults (R38,
273
362
  * PLAN-layering D5): only the `default: true` one (`.defaults()`) is read;
@@ -291,6 +380,11 @@ export interface RegistrationChange {
291
380
  readonly key: string;
292
381
  readonly values?: RegistrationValues;
293
382
  readonly mode?: RoutineMode;
383
+ /**
384
+ * Over the session's published values; for a registration on an event, also that event's
385
+ * payload under the reserved name `event` (`event.asked` on Turn order asked). Absent for
386
+ * actions and routines.
387
+ */
294
388
  readonly when?: ConditionDecl;
295
389
  readonly allowStacking?: boolean;
296
390
  readonly caps?: RoutineCaps;
@@ -302,17 +396,41 @@ export interface RegistrationChange {
302
396
  readonly minAge?: number;
303
397
  readonly order?: number;
304
398
  readonly label?: I18n;
399
+ /** A preset marks the option that runs by default. */
400
+ readonly default?: true;
401
+ /** 🚧 Places the routine into a routine group (its key); the routine's key, trigger and state are unchanged. */
402
+ readonly group?: string;
403
+ }
404
+ /**
405
+ * 🚧 A change to one routine group, named by its key: each stated field
406
+ * replaces the earlier layer's whole (`caps` included).
407
+ * @experimental
408
+ * @ruling RG1, RN1
409
+ */
410
+ export interface RoutineGroupChange {
411
+ readonly key: string;
412
+ readonly cadence?: CadenceRef;
413
+ readonly label?: I18n;
414
+ readonly when?: ConditionDecl;
415
+ readonly allowStacking?: boolean;
416
+ readonly caps?: RoutineCaps;
417
+ readonly run?: ClauseMode;
305
418
  }
306
419
  /**
307
420
  * A preset's changes on top of the genre's defaults (R2): registrations it
308
- * adds, the keys it drops, and the changes it makes to the rest.
421
+ * adds, the keys it drops, and the changes it makes to the rest — and the
422
+ * routine groups it declares or changes.
309
423
  * @experimental
310
- * @ruling R2, R3
424
+ * @ruling R2, R3, RG1
311
425
  */
312
426
  export interface PresetRegistrationChanges {
313
427
  readonly register?: readonly RegistrationDecl[];
314
428
  readonly drop?: readonly string[];
315
429
  readonly change?: readonly RegistrationChange[];
430
+ /** 🚧 Routine groups this preset declares. */
431
+ readonly groups?: readonly RoutineGroupDecl[];
432
+ /** 🚧 Changes to the genre's routine groups. */
433
+ readonly changeGroups?: readonly RoutineGroupChange[];
316
434
  }
317
435
  /**
318
436
  * One session row over the effective registrations: a change to one
@@ -352,11 +470,33 @@ export type EffectiveRegistration = RegistrationDecl & {
352
470
  * a session's rows (PLAN-layering D4). Pure; the host's resolver reuses it.
353
471
  * A dropped registration is gone; a routine switched Off stays, with
354
472
  * `mode: 'off'` (R8). Sorted by `order`, then key (R24). Within one layer the
355
- * first of two alike wins — the door warns about the second (R34).
473
+ * first of two alike wins — the door warns about the second (R34). A layer
474
+ * that marks a registration `default` on an event takes the mark from the
475
+ * others on that event: a later layer's default replaces the earlier layers'.
476
+ * A session's change row never carries the mark: the session's choice is its
477
+ * own column, read by the host. A routine in a routine group carries `group`
478
+ * (from its declaration, or a layer's change) and nothing else about it
479
+ * changes; its routine group's cadence, `when`, stacking and run limit are
480
+ * read from `effectiveRoutineGroups`.
356
481
  * @experimental
357
482
  * @ruling R2, R8, R22, R24, R34
358
483
  */
359
484
  export declare function effectiveRegistrations(genreDefaults: readonly RegistrationDecl[] | undefined, presetChanges?: PresetRegistrationChanges | null, sessionRows?: readonly SessionRegistrationRow[] | null): EffectiveRegistration[];
485
+ /**
486
+ * 🚧 **Effective routine groups** — the genre's routine groups ⊕ a preset's
487
+ * changes ⊕ a session's changes, layered as `effectiveRegistrations` is: the
488
+ * genre's by key (the first of two alike in a layer wins); the preset's
489
+ * `changeGroups` on the ones present (an unknown key is ignored); the preset's
490
+ * `groups` set by key (replacing a genre's of that key, origin `preset`); the
491
+ * session's changes on the ones present. Sorted by key. Pure; refuses nothing
492
+ * (`routineGroupFindings` judges).
493
+ * @experimental
494
+ * @ruling RG1, RG2
495
+ */
496
+ export declare function effectiveRoutineGroups(genreGroups: readonly RoutineGroupDecl[] | undefined, presetChanges?: PresetRegistrationChanges | null, sessionChanges?: readonly RoutineGroupChange[] | null): Array<RoutineGroupDecl & {
497
+ readonly origin: 'genre' | 'preset' | (string & {});
498
+ readonly changedBy?: readonly string[];
499
+ }>;
360
500
  /** Do two triggers name the same thing (event, action, or cadence id)? @experimental */
361
501
  export declare function sameTrigger(a: Trigger, b: Trigger): boolean;
362
502
  /**