@serene-pub/sdk 0.6.0-pr-7 โ†’ 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 (106) hide show
  1. package/dist/annexFields.d.ts +14 -0
  2. package/dist/annexFields.js +7 -0
  3. package/dist/announce.d.ts +62 -16
  4. package/dist/announce.js +90 -4
  5. package/dist/appletCard.d.ts +17 -0
  6. package/dist/appletCard.js +60 -0
  7. package/dist/attributes.d.ts +3 -3
  8. package/dist/attributes.js +1 -1
  9. package/dist/builder.d.ts +28 -13
  10. package/dist/builder.js +57 -5
  11. package/dist/cadences.d.ts +8 -1
  12. package/dist/cadences.js +27 -2
  13. package/dist/characterProfile.d.ts +137 -0
  14. package/dist/characterProfile.js +24 -0
  15. package/dist/component.d.ts +1 -1
  16. package/dist/componentImports.d.ts +1 -1
  17. package/dist/componentImports.js +2 -0
  18. package/dist/componentWire.js +28 -0
  19. package/dist/conditions.d.ts +5 -1
  20. package/dist/conditions.js +7 -0
  21. package/dist/declarations.d.ts +63 -1
  22. package/dist/declarations.js +176 -7
  23. package/dist/descriptors.d.ts +145 -6
  24. package/dist/descriptors.js +106 -5
  25. package/dist/document.d.ts +9 -1
  26. package/dist/document.js +44 -1
  27. package/dist/events.d.ts +82 -8
  28. package/dist/events.js +42 -5
  29. package/dist/executor.d.ts +27 -0
  30. package/dist/executor.js +32 -8
  31. package/dist/exposure.d.ts +35 -1
  32. package/dist/exposure.js +64 -2
  33. package/dist/extension.d.ts +30 -2
  34. package/dist/extension.js +3 -1
  35. package/dist/fit.d.ts +4 -1
  36. package/dist/fit.js +43 -1
  37. package/dist/functions.d.ts +7 -1
  38. package/dist/functions.js +3 -1
  39. package/dist/genres.d.ts +67 -2
  40. package/dist/genres.js +160 -8
  41. package/dist/hookGrants.js +10 -0
  42. package/dist/hostElements.d.ts +3 -3
  43. package/dist/hostElements.js +12 -4
  44. package/dist/index.d.ts +5 -0
  45. package/dist/index.js +10 -0
  46. package/dist/layout.d.ts +18 -0
  47. package/dist/libraryDraft.d.ts +2 -0
  48. package/dist/libraryDraft.js +5 -1
  49. package/dist/lorebookFile.d.ts +8 -0
  50. package/dist/lorebookFile.js +21 -0
  51. package/dist/participants.d.ts +83 -8
  52. package/dist/participants.js +9 -5
  53. package/dist/pluginPermissions.js +1 -1
  54. package/dist/promptBlocks.d.ts +5 -1
  55. package/dist/promptBlocks.js +23 -8
  56. package/dist/provisos.d.ts +92 -0
  57. package/dist/provisos.js +273 -0
  58. package/dist/receiverRules.js +1 -1
  59. package/dist/registrations.d.ts +154 -14
  60. package/dist/registrations.js +293 -23
  61. package/dist/registry.js +6 -3
  62. package/dist/repertoires.d.ts +13 -1
  63. package/dist/repertoires.js +5 -1
  64. package/dist/rulesetDocument.d.ts +11 -0
  65. package/dist/rulesetDocument.js +17 -0
  66. package/dist/rulesetSections.d.ts +12 -0
  67. package/dist/rulesetSections.js +8 -0
  68. package/dist/rulesets.js +6 -0
  69. package/dist/sceneSettings.d.ts +7 -1
  70. package/dist/sceneSettings.js +10 -5
  71. package/dist/sessionDossier.d.ts +159 -2
  72. package/dist/sessionLayout.d.ts +296 -85
  73. package/dist/sessionLayout.js +397 -133
  74. package/dist/sessionSettings.d.ts +18 -0
  75. package/dist/settings.d.ts +28 -1
  76. package/dist/settings.js +50 -2
  77. package/dist/shapes.d.ts +15 -1
  78. package/dist/shapes.js +15 -1
  79. package/dist/sheetLatitude.d.ts +148 -0
  80. package/dist/sheetLatitude.js +161 -0
  81. package/dist/speech.d.ts +14 -3
  82. package/dist/storyTime.d.ts +77 -1
  83. package/dist/storyTime.js +117 -8
  84. package/dist/surfaces.d.ts +49 -2
  85. package/dist/surfaces.js +3 -0
  86. package/dist/template.d.ts +38 -1
  87. package/dist/templateCheck.d.ts +24 -0
  88. package/dist/templateCheck.js +465 -10
  89. package/dist/templateFit.js +8 -1
  90. package/dist/templateIds.d.ts +6 -0
  91. package/dist/templateIds.js +9 -0
  92. package/dist/turnLock.d.ts +10 -1
  93. package/dist/turnLock.js +6 -1
  94. package/dist/turnOrder.d.ts +37 -4
  95. package/dist/turnOrder.js +49 -11
  96. package/dist/validate.d.ts +4 -2
  97. package/dist/validate.js +84 -11
  98. package/dist/variableLayouts.d.ts +160 -0
  99. package/dist/variableLayouts.js +202 -0
  100. package/dist/variables.d.ts +237 -20
  101. package/dist/variables.js +292 -33
  102. package/dist/widgetDecls.js +12 -0
  103. package/dist/widgets.d.ts +449 -47
  104. package/dist/widgets.js +31 -0
  105. package/host-elements.d.ts +4 -2
  106. package/package.json +1 -1
@@ -100,6 +100,18 @@ export interface AnnexFieldDecl {
100
100
  readonly scope?: 'session' | 'lorebook' | 'user';
101
101
  /** ๐Ÿšง The value follows the player into the next chapter (M0, F5): a `next-chapter` session copies it. */
102
102
  readonly nextChapter?: true;
103
+ /**
104
+ * ๐Ÿšง The value stays when the turn that wrote it is replaced โ€” a swipe, a
105
+ * regenerate, a failed run โ€” and goes when the turn leaves (Back, delete).
106
+ * For a genre that tells a turn again from what it decided: its plan is not
107
+ * written again, so it must not be taken back. Absent means it goes with the
108
+ * turn either way. `session` scope only: only a session's annex is taken back
109
+ * with a turn.
110
+ * @experimental
111
+ * โš  Not a cast member's _retold_ field (NOMENCLATURE ยง8 **retold** โ€” a card
112
+ * field told in the member's own words); a near-neighbour word.
113
+ */
114
+ readonly keepOnRetell?: true;
103
115
  /** What a listing calls the action. Default: the key. */
104
116
  readonly label?: I18n;
105
117
  readonly description?: I18n;
@@ -118,6 +130,8 @@ export type AnnexFieldInput = {
118
130
  scope?: 'session' | 'lorebook' | 'user';
119
131
  /** ๐Ÿšง The value follows the player into the next chapter โ€” {@link AnnexFieldDecl.nextChapter}. */
120
132
  nextChapter?: true;
133
+ /** ๐Ÿšง The value stays when its turn is replaced โ€” {@link AnnexFieldDecl.keepOnRetell}. */
134
+ keepOnRetell?: true;
121
135
  label?: I18n;
122
136
  description?: I18n;
123
137
  };
@@ -120,6 +120,8 @@ export function annexFieldFindings(raw, at = 'annexFields') {
120
120
  out.push(`${where}.genre: a user-scoped field is not bound to a genre โ€” a person's documents follow them across sessions`);
121
121
  if (f.nextChapter !== undefined)
122
122
  out.push(`${where}.nextChapter: a user-scoped field is not part of a session, so nothing follows into a chapter`);
123
+ if (f.keepOnRetell !== undefined)
124
+ out.push(`${where}.keepOnRetell: a user-scoped field is not taken back with a turn, so there is nothing to keep โ€” only a session-scope field can keep its value`);
123
125
  }
124
126
  if (f.act !== undefined && f.scope !== 'user') {
125
127
  if (!Array.isArray(f.act) || !f.act.length)
@@ -140,6 +142,10 @@ export function annexFieldFindings(raw, at = 'annexFields') {
140
142
  if (f.scope !== undefined && f.scope !== 'session' && f.scope !== 'lorebook' && f.scope !== 'user')
141
143
  out.push(`${where}.scope: 'session' (the session annex, the default), 'lorebook' (the lorebook annex) or 'user' (the user annex) โ€” ` +
142
144
  `'${String(f.scope)}' is neither`);
145
+ if (f.scope === 'lorebook' && f.keepOnRetell !== undefined)
146
+ out.push(`${where}.keepOnRetell: a session-scope field only โ€” a lorebook-scope field's change is a lorebook write, and goes back with its turn as every lorebook write does`);
147
+ if (f.keepOnRetell !== undefined && f.keepOnRetell !== true)
148
+ out.push(`${where}.keepOnRetell: true or absent โ€” the value stays when its turn is told again`);
143
149
  if (f.nextChapter !== undefined && f.nextChapter !== true)
144
150
  out.push(`${where}.nextChapter: true or absent โ€” the value follows the player into the next chapter`);
145
151
  out.push(...i18nFindings(f.label, `${where}.label`));
@@ -165,6 +171,7 @@ export function annexField(d) {
165
171
  ...(d.genre !== undefined ? { genre: typeof d.genre === 'string' ? d.genre : d.genre.id } : {}),
166
172
  ...(d.scope !== undefined ? { scope: d.scope } : {}),
167
173
  ...(d.nextChapter !== undefined ? { nextChapter: d.nextChapter } : {}),
174
+ ...(d.keepOnRetell !== undefined ? { keepOnRetell: d.keepOnRetell } : {}),
168
175
  ...(d.label !== undefined ? { label: d.label } : {}),
169
176
  ...(d.description !== undefined ? { description: d.description } : {}),
170
177
  });
@@ -72,8 +72,9 @@ export type SpecRef = AnnouncedSpec | ExternalRef;
72
72
  /** The id a `SpecRef` names; a bare string is refused with the fix. @experimental */
73
73
  export declare function specIdOf(v: unknown, where: string): string;
74
74
  import { type GenreDecl, type GenreProps } from './genres.js';
75
- import { type PresetRegistrationChanges, type RegistrationDecl } from './registrations.js';
75
+ import { type PresetRegistrationChanges, type RegistrationDecl, type RoutineGroupDecl } from './registrations.js';
76
76
  import type { SettingValue } from './exposure.js';
77
+ import type { VariableId } from './variables.js';
77
78
  import { type SessionEventDecl } from './events.js';
78
79
  import { type ValueToolkit } from './values.js';
79
80
  import type { ComponentDecl, Extension } from './extension.js';
@@ -141,6 +142,22 @@ export interface PromptDecl {
141
142
  label: I18n;
142
143
  /** Field name โ†’ prose, exactly as that slot declares them. */
143
144
  fields: Record<string, string>;
145
+ /**
146
+ * The pipeline this prompt is filed under: the spec's `id`
147
+ * (`<owner>:spec/<name>`, versionless). Session owners are offered the prompt
148
+ * on that pipeline's steps, and every other pipeline stops offering it.
149
+ * Absent: administrators only.
150
+ *
151
+ * It may name another package's pipeline. That is accepted: on a pub where
152
+ * that pipeline is not installed it resolves to nothing, and the prompt is
153
+ * offered to administrators only.
154
+ *
155
+ * โš  Not `defaultForSpecs` โ€” that says which pipelines' shipped configuration
156
+ * *starts* on a row, a different claim.
157
+ * @experimental
158
+ * @ruling PR3
159
+ */
160
+ forPipeline?: string;
144
161
  }
145
162
  /**
146
163
  * A named configuration: a typed delta over a spec's author defaults.
@@ -198,7 +215,8 @@ export interface PresetBinding {
198
215
  * recognises, type-checks each, and ignores the rest โ€” so a preset written
199
216
  * against a newer genre than the instance has can still be started, and a
200
217
  * genre's own fields ride along in `genreFields` rather than growing this
201
- * shape a key at a time.
218
+ * shape a key at a time. The exception is `timeline`: a genre that requires a
219
+ * timeline (`GenreDecl.timeline`) refuses `timeline: false` at declaration.
202
220
  * @experimental
203
221
  * @ruling 23 ยง9
204
222
  */
@@ -229,6 +247,15 @@ export interface PresetDefaults {
229
247
  * @ruling R-18, U5g
230
248
  */
231
249
  envoys?: string[];
250
+ /**
251
+ * ๐Ÿšง A preset's timeline default: whether a new session's lorebook starts
252
+ * with a timeline when the session starts on its own notes. Left out = none,
253
+ * unless the genre requires one (`GenreDecl.timeline`). A genre
254
+ * that requires a timeline (`GenreDecl.timeline`) refuses `false` at
255
+ * declaration. Only a default for a new session's lorebook; the lorebook
256
+ * decides whether story time moves.
257
+ */
258
+ timeline?: boolean;
232
259
  }
233
260
  /**
234
261
  * A preset populates a genre's event slots: for each event the genre
@@ -310,18 +337,18 @@ export interface PresetDecl {
310
337
  */
311
338
  settings?: Readonly<Record<string, SettingValue>>;
312
339
  /**
313
- * Whether the instance should offer this preset the moment the package is
314
- * enabled. **Absent means no**, and that is the interesting half.
315
- *
316
- * A preset is what a non-admin picks from, so a package that installed one
317
- * straight into everybody's picker would be deciding, on the administrator's
318
- * behalf, what this instance offers. So the projection lands it disabled and
319
- * an administrator switches it on โ€” the same shape as a declared permission,
320
- * which is also announced by the package and granted by the instance.
321
- *
322
- * Setting it is a request, not a grant: an instance is free to ignore it,
323
- * and an administrator who has already disabled a preset keeps that decision
324
- * across upgrades.
340
+ * ๐Ÿšง Variable id โ†’ layout reference (`{ 'core:var/characters@1': 'core/json@1' }`):
341
+ * this preset's sessions write that variable out with that layout instead of
342
+ * the pub's. A reference to a layout that isn't installed is accepted; the
343
+ * host skips it, renders the pub's layout and says so. โš  Not a genre's
344
+ * `layouts` (session layouts) and not `settings`.
345
+ */
346
+ variableLayouts?: Readonly<Record<VariableId, string>>;
347
+ /**
348
+ * @deprecated โณ Ignored. The instance offers a plugin's presets as soon as
349
+ * the plugin is enabled; an administrator may hide one afterwards, and that
350
+ * choice survives upgrades. Kept so existing packages still compile;
351
+ * removing it is the owner's call.
325
352
  */
326
353
  enabled?: boolean;
327
354
  }
@@ -409,7 +436,14 @@ export interface PresetInput {
409
436
  */
410
437
  change?: ReadonlyArray<{
411
438
  of: RegistrationDecl;
439
+ group?: RoutineGroupDecl;
412
440
  } & Partial<Pick<RegistrationDecl, 'values' | 'mode' | 'when' | 'allowStacking' | 'caps' | 'order' | 'label'>>>;
441
+ /** ๐Ÿšง Routine groups this preset declares โ€” `routineGroup(cadence, { key })` values. */
442
+ groups?: readonly RoutineGroupDecl[];
443
+ /** ๐Ÿšง Changes to routine groups of the genre's defaults โ€” `{ of: scenes, run: 'parallel' }`: the routine group object, and the fields that differ. */
444
+ changeGroups?: ReadonlyArray<{
445
+ of: RoutineGroupDecl;
446
+ } & Partial<Pick<RoutineGroupDecl, 'cadence' | 'label' | 'when' | 'allowStacking' | 'caps' | 'run'>>>;
413
447
  /** ๐Ÿšง Package requirements with version ranges โ€” `acme.dice@^1.2` (A16). `use('โ€ฆ@range')` pipelines add their own. */
414
448
  requires?: readonly string[];
415
449
  /**
@@ -437,7 +471,9 @@ export interface PresetInput {
437
471
  };
438
472
  /** ๐Ÿšง See `PresetDecl.settings` โ€” each a value, or `{ value, lock?, askAtStart? }`. */
439
473
  settings?: Readonly<Record<string, SettingValue>>;
440
- /** Ask the instance to offer this preset immediately. See `PresetDecl.enabled`. */
474
+ /** ๐Ÿšง See `PresetDecl.variableLayouts`. */
475
+ variableLayouts?: Readonly<Record<VariableId, string>>;
476
+ /** @deprecated โณ Ignored โ€” presets are offered once the plugin is enabled. See `PresetDecl.enabled`. */
441
477
  enabled?: boolean;
442
478
  }
443
479
  /**
@@ -461,7 +497,7 @@ export declare function presetLevelFindings(preset: {
461
497
  slug?: string;
462
498
  genre?: unknown;
463
499
  registrations?: PresetRegistrationChanges;
464
- } | null | undefined, genreDefaults?: readonly RegistrationDecl[]): string[];
500
+ } | null | undefined, genreDefaults?: readonly RegistrationDecl[], genreGroups?: readonly RoutineGroupDecl[]): string[];
465
501
  /**
466
502
  * ๐Ÿšง One `requires` entry read (A16): a package with a version range
467
503
  * (`acme.dice@^1.2`), or a declared id (`acme:spec/x`, `core:event/x@1` โ€” the
@@ -492,6 +528,16 @@ export declare function requirementRanges(manifest: {
492
528
  id?: string;
493
529
  range: string;
494
530
  }>;
531
+ /**
532
+ * What is wrong with a preset's `variableLayouts`, as sentences โ€” the one
533
+ * statement of the rule, for a preset that arrives as data (a manifest, a row)
534
+ * and for `preset()`. Empty when it is clean or absent.
535
+ * @experimental
536
+ */
537
+ export declare function presetVariableLayoutFindings(preset: {
538
+ slug?: string;
539
+ variableLayouts?: unknown;
540
+ } | null | undefined): string[];
495
541
  /**
496
542
  * The stored form of a preset. Every reference is read down to its id and
497
543
  * checked against what the value says: a binding's events against its spec's
package/dist/announce.js CHANGED
@@ -33,6 +33,7 @@ const actionKeysOf = (v) => {
33
33
  };
34
34
  import { genre as makeGenre, genreIdOf, sessionEvents } from './genres.js';
35
35
  import { registrationRange, } from './registrations.js';
36
+ import { parseVariableLayoutReference, variableIdParts } from './variableLayouts.js';
36
37
  import { eventById, isEventId, isSessionEventDecl } from './events.js';
37
38
  import { makeValueToolkit } from './values.js';
38
39
  import { SAVE_MESSAGE_SPEC_ID } from './descriptors.js';
@@ -141,7 +142,7 @@ const presetParentSentence = (where, k) => `${where} names '${k}' โ€” a preset n
141
142
  * @experimental
142
143
  * @ruling R2, R3, R22
143
144
  */
144
- export function presetLevelFindings(preset, genreDefaults) {
145
+ export function presetLevelFindings(preset, genreDefaults, genreGroups) {
145
146
  if (!preset || typeof preset !== 'object')
146
147
  return ['a preset is an object โ€” make it with preset({ โ€ฆ })'];
147
148
  const where = `preset '${preset.slug ?? '?'}'`;
@@ -161,8 +162,19 @@ export function presetLevelFindings(preset, genreDefaults) {
161
162
  if (!held.has(c.key))
162
163
  out.push(`${where} changes '${c.key}', which its genre's defaults do not register โ€” a preset changes the genre's defaults, never another preset's changes (R2)`);
163
164
  }
165
+ if (changes && genreGroups) {
166
+ const held = new Set([...genreGroups.map((g) => g.key), ...(changes.groups ?? []).map((g) => g.key)]);
167
+ for (const c of changes.changeGroups ?? [])
168
+ if (!held.has(c.key))
169
+ out.push(`${where} changes routine group '${c.key}', which its genre's defaults do not declare โ€” a preset changes the genre's defaults, never another preset's changes (R2)`);
170
+ }
164
171
  return out;
165
172
  }
173
+ const isRoutineGroupShaped = (v) => !!v &&
174
+ typeof v === 'object' &&
175
+ typeof v.key === 'string' &&
176
+ !!v.cadence &&
177
+ typeof v.cadence.id === 'string';
166
178
  const isRegistrationShaped = (v) => !!v &&
167
179
  typeof v === 'object' &&
168
180
  typeof v.key === 'string' &&
@@ -170,7 +182,9 @@ const isRegistrationShaped = (v) => !!v &&
170
182
  typeof v.pipeline === 'string';
171
183
  const isPresetShaped = (v) => !!v && typeof v === 'object' && typeof v.slug === 'string' && ('bindings' in v || 'genre' in v);
172
184
  /** The fields a preset's `change` may state beside `of`. */
173
- const PRESET_CHANGE_KEYS = ['values', 'mode', 'when', 'allowStacking', 'caps', 'order', 'label'];
185
+ const PRESET_CHANGE_KEYS = ['values', 'mode', 'when', 'allowStacking', 'caps', 'order', 'label', 'group'];
186
+ /** The fields a preset's `changeGroups` may state beside `of`. */
187
+ const PRESET_GROUP_CHANGE_KEYS = ['cadence', 'label', 'when', 'allowStacking', 'caps', 'run'];
174
188
  /** `<package>@<range>` โ€” a package requirement with a semver range (A16). */
175
189
  const PACKAGE_REQUIREMENT = /^([a-z0-9]+(?:[.-][a-z0-9]+)*)@([~^<>=]*\s*\d[\w.+\-<>=|^~* ]*)$/;
176
190
  /**
@@ -218,6 +232,32 @@ export function requirementRanges(manifest) {
218
232
  return out;
219
233
  }
220
234
  const isBindingObject = (v) => !!v && typeof v === 'object' && 'spec' in v;
235
+ /**
236
+ * What is wrong with a preset's `variableLayouts`, as sentences โ€” the one
237
+ * statement of the rule, for a preset that arrives as data (a manifest, a row)
238
+ * and for `preset()`. Empty when it is clean or absent.
239
+ * @experimental
240
+ */
241
+ export function presetVariableLayoutFindings(preset) {
242
+ const where = `preset '${preset?.slug ?? '?'}'`;
243
+ const map = preset?.variableLayouts;
244
+ if (map === undefined)
245
+ return [];
246
+ if (!map || typeof map !== 'object' || Array.isArray(map))
247
+ return [
248
+ `${where}.variableLayouts is a map from variable id to layout reference โ€” ` +
249
+ `{ 'core:var/characters@1': 'core/json@1' }`,
250
+ ];
251
+ const findings = [];
252
+ for (const [key, value] of Object.entries(map)) {
253
+ if (!variableIdParts(key))
254
+ findings.push(`${where}.variableLayouts: '${key}' is not a variable id โ€” it reads 'core:var/characters@1'`);
255
+ else if (!parseVariableLayoutReference(value))
256
+ findings.push(`${where}.variableLayouts: '${key}' is given '${String(value)}', which is not a layout reference โ€” ` +
257
+ `it reads '<owner>/<slug>@<major>', such as 'core/json@1'`);
258
+ }
259
+ return findings;
260
+ }
221
261
  /**
222
262
  * The stored form of a preset. Every reference is read down to its id and
223
263
  * checked against what the value says: a binding's events against its spec's
@@ -228,6 +268,9 @@ const isBindingObject = (v) => !!v && typeof v === 'object' && 'spec' in v;
228
268
  export function preset(input) {
229
269
  const where = `preset '${input?.slug}'`;
230
270
  assertDisplayText(where, input);
271
+ const layoutFindings = presetVariableLayoutFindings(input);
272
+ if (layoutFindings.length)
273
+ throw new Error(layoutFindings[0]);
231
274
  if (typeof input.genre === 'string')
232
275
  throw new Error(`${where} names its genre as a string โ€” pass the genre value (import it), or use('${input.genre}')`);
233
276
  const genre = isExternalRef(input.genre) ? input.genre.id : genreIdOf(input.genre);
@@ -238,6 +281,13 @@ export function preset(input) {
238
281
  throw new Error(presetParentSentence(where, k));
239
282
  if (input.history !== undefined)
240
283
  throw new Error(`${where} sets history โ€” when a session's history settles is its genre's to say (history.settle), never a preset's.`);
284
+ if (input.defaults?.timeline !== undefined && typeof input.defaults.timeline !== 'boolean')
285
+ throw new Error(`${where}.defaults.timeline: true or false, or leave it out`);
286
+ // ๐Ÿšง A genre named by `use(โ€ฆ)` is another package's and cannot be checked here; the host's resolver lets the mandate win.
287
+ if (input.defaults?.timeline === false &&
288
+ !isExternalRef(input.genre) &&
289
+ input.genre?.timeline === 'required')
290
+ throw new Error(`${where} sets defaults.timeline: false, but its genre '${genre}' requires a timeline โ€” leave it out, or set it true`);
241
291
  const registrations = presetRegistrationsOf(input, where);
242
292
  if (input.default !== undefined && input.default !== true)
243
293
  throw new Error(`${where}.default: true, or leave it out`);
@@ -360,6 +410,7 @@ export function preset(input) {
360
410
  ...(input.callsPerTurn !== undefined ? { callsPerTurn: assertCallsPerTurn(input.callsPerTurn, where) } : {}),
361
411
  ...(input.cast ? { cast: assertCastFloor(input.cast, where) } : {}),
362
412
  ...(input.settings && Object.keys(input.settings).length ? { settings: { ...input.settings } } : {}),
413
+ ...(input.variableLayouts && Object.keys(input.variableLayouts).length ? { variableLayouts: { ...input.variableLayouts } } : {}),
363
414
  };
364
415
  }
365
416
  const assertCallsPerTurn = (v, where) => {
@@ -381,7 +432,11 @@ const assertCastFloor = (v, where) => {
381
432
  * in). Throws the first mistake, with the fix.
382
433
  */
383
434
  function presetRegistrationsOf(input, where) {
384
- if (input.register === undefined && input.drop === undefined && input.change === undefined)
435
+ if (input.register === undefined &&
436
+ input.drop === undefined &&
437
+ input.change === undefined &&
438
+ input.groups === undefined &&
439
+ input.changeGroups === undefined)
385
440
  return undefined;
386
441
  const one = (v, at) => {
387
442
  if (isPresetShaped(v) && !isRegistrationShaped(v))
@@ -408,15 +463,46 @@ function presetRegistrationsOf(input, where) {
408
463
  for (const k of Object.keys(c))
409
464
  if (k !== 'of' && !PRESET_CHANGE_KEYS.includes(k))
410
465
  throw new Error(`${at}: '${k}' is not something a preset changes โ€” one of ${PRESET_CHANGE_KEYS.join(', ')}`);
466
+ if (c.group !== undefined && !isRoutineGroupShaped(c.group))
467
+ throw new Error(`${at}.group is not a routine group โ€” pass routineGroup(โ€ฆ)`);
411
468
  return Object.freeze({
412
469
  key: of.key,
413
- ...Object.fromEntries(PRESET_CHANGE_KEYS.filter((k) => c[k] !== undefined).map((k) => [k, c[k]])),
470
+ ...Object.fromEntries(PRESET_CHANGE_KEYS.filter((k) => c[k] !== undefined).map((k) => [
471
+ k,
472
+ k === 'group' ? c.group.key : c[k],
473
+ ])),
474
+ });
475
+ });
476
+ if (input.groups !== undefined && !Array.isArray(input.groups))
477
+ throw new Error(`${where}.groups is a list of routine groups`);
478
+ const groups = (input.groups ?? []).map((g, i) => {
479
+ if (!isRoutineGroupShaped(g))
480
+ throw new Error(`${where}.groups[${i}] is not a routine group โ€” make it with routineGroup(cadence, { key })`);
481
+ return g;
482
+ });
483
+ if (input.changeGroups !== undefined && !Array.isArray(input.changeGroups))
484
+ throw new Error(`${where}.changeGroups is a list of routine group changes`);
485
+ const changeGroups = (input.changeGroups ?? []).map((raw, i) => {
486
+ const at = `${where}.changeGroups[${i}]`;
487
+ if (!raw || typeof raw !== 'object')
488
+ throw new Error(`${at}: { of: routine group, โ€ฆchanges }`);
489
+ const c = raw;
490
+ if (!isRoutineGroupShaped(c.of))
491
+ throw new Error(`${at}.of is not a routine group โ€” make it with routineGroup(cadence, { key })`);
492
+ for (const k of Object.keys(c))
493
+ if (k !== 'of' && !PRESET_GROUP_CHANGE_KEYS.includes(k))
494
+ throw new Error(`${at}: '${k}' is not something a preset changes โ€” one of ${PRESET_GROUP_CHANGE_KEYS.join(', ')}`);
495
+ return Object.freeze({
496
+ key: c.of.key,
497
+ ...Object.fromEntries(PRESET_GROUP_CHANGE_KEYS.filter((k) => c[k] !== undefined).map((k) => [k, c[k]])),
414
498
  });
415
499
  });
416
500
  return Object.freeze({
417
501
  ...(register.length ? { register: Object.freeze(register) } : {}),
418
502
  ...(drop.length ? { drop: Object.freeze(drop) } : {}),
419
503
  ...(change.length ? { change: Object.freeze(change) } : {}),
504
+ ...(groups.length ? { groups: Object.freeze(groups) } : {}),
505
+ ...(changeGroups.length ? { changeGroups: Object.freeze(changeGroups) } : {}),
420
506
  });
421
507
  }
422
508
  const NS = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ๐Ÿšง The one rule for a package's applet card (M2d), run by the packager
3
+ * (`serene-pub check`) and again by the instance's install over the stored
4
+ * manifest. Pure: the caller says which package files exist.
5
+ *
6
+ * Returns one finding per mistake, each with a `fix`: `E_APPLET_CARD_OUTSIDE_ASSETS`,
7
+ * `E_APPLET_CARD_MISSING`, `E_APPLET_CARD_BLURB_LONG`, `E_APPLET_CARD_WITHOUT_APPLET`.
8
+ * Empty when `appletCard` is undefined. Not a reader of files and not a layout
9
+ * check โ€” no aspect ratio is tested.
10
+ * @experimental (M2d)
11
+ */
12
+ export declare function appletCardFindings(card: unknown, assetsDir: string | undefined, fileExists: (path: string) => boolean, hasAppletGenre: boolean): Array<{
13
+ code: string;
14
+ message: string;
15
+ fix: string;
16
+ }>;
17
+ //# sourceMappingURL=appletCard.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { i18nText } from './i18n.js';
2
+ /**
3
+ * ๐Ÿšง The one rule for a package's applet card (M2d), run by the packager
4
+ * (`serene-pub check`) and again by the instance's install over the stored
5
+ * manifest. Pure: the caller says which package files exist.
6
+ *
7
+ * Returns one finding per mistake, each with a `fix`: `E_APPLET_CARD_OUTSIDE_ASSETS`,
8
+ * `E_APPLET_CARD_MISSING`, `E_APPLET_CARD_BLURB_LONG`, `E_APPLET_CARD_WITHOUT_APPLET`.
9
+ * Empty when `appletCard` is undefined. Not a reader of files and not a layout
10
+ * check โ€” no aspect ratio is tested.
11
+ * @experimental (M2d)
12
+ */
13
+ export function appletCardFindings(card, assetsDir, fileExists, hasAppletGenre) {
14
+ if (card === undefined)
15
+ return [];
16
+ const out = [];
17
+ const c = (card && typeof card === 'object' ? card : {});
18
+ const dir = assetsDir?.replace(/\/+$/, '');
19
+ for (const key of ['poster', 'logo']) {
20
+ const raw = c[key];
21
+ if (raw === undefined)
22
+ continue;
23
+ const shown = String(raw);
24
+ const safe = typeof raw === 'string' &&
25
+ !raw.startsWith('/') &&
26
+ !raw.includes('\\') &&
27
+ !raw.split('/').some((x) => !x || x === '.' || x === '..');
28
+ if (!safe || !dir || !raw.startsWith(`${dir}/`)) {
29
+ out.push({
30
+ code: 'E_APPLET_CARD_OUTSIDE_ASSETS',
31
+ message: `appletCard.${key} is '${shown}', which is not a file under the package's assets folder${dir ? ` '${dir}'` : ' (the package declares none)'}`,
32
+ fix: `declare assets: { dir: 'assets' } and put the picture under it โ€” 'assets/card/${key}.png'`,
33
+ });
34
+ continue;
35
+ }
36
+ if (!fileExists(raw))
37
+ out.push({
38
+ code: 'E_APPLET_CARD_MISSING',
39
+ message: `appletCard.${key} names '${shown}', and the package has no such file`,
40
+ fix: `add the picture at that path, or remove appletCard.${key}`,
41
+ });
42
+ }
43
+ if (c.blurb !== undefined) {
44
+ const text = i18nText(c.blurb) ?? '';
45
+ if (text.length > 160)
46
+ out.push({
47
+ code: 'E_APPLET_CARD_BLURB_LONG',
48
+ message: `appletCard.blurb is ${text.length} characters; the card shows at most 160`,
49
+ fix: 'shorten it to one line of at most 160 characters',
50
+ });
51
+ }
52
+ if (!hasAppletGenre)
53
+ out.push({
54
+ code: 'E_APPLET_CARD_WITHOUT_APPLET',
55
+ message: 'appletCard is declared, and no genre of this package presents as an applet',
56
+ fix: "add applet: true to a genre's shape, or remove appletCard",
57
+ });
58
+ return out;
59
+ }
60
+ //# sourceMappingURL=appletCard.js.map
@@ -517,8 +517,8 @@ export interface AttributeSlotProps {
517
517
  appliesTo: readonly SlotAppliesTo[];
518
518
  /**
519
519
  * ๐Ÿšง **What its values survive** (M0, SHAPES F1): `session` โ€” they
520
- * die with the session (its session layer: `session`, `session_cast`,
521
- * `player_seat`, `session_location`); `world` โ€” they live on the book,
520
+ * die with the session (its session layer: `session`, ๐Ÿšง `seated_member`, โณ
521
+ * `session_cast`, `player_seat`, `session_location`); `world` โ€” they live on the book,
522
522
  * dated on its timeline (`lorebook`, `cast_member`, `location`). Absent:
523
523
  * `session`. A ruleset attribute's `scope` lands here. The player's own
524
524
  * (`owner: 'player'` on a ruleset attribute) is a `cast` slot read on the
@@ -977,7 +977,7 @@ export declare function applyListOp(current: readonly SlotListItem[] | null | un
977
977
  * Whether a slot may attach to this kind of owner.
978
978
  *
979
979
  * The owner *kinds* the host stores (`card`, `cast_member`, `lorebook`,
980
- * `session`, `session_cast`, `location`, `session_location`) collapse to the
980
+ * `session`, ๐Ÿšง `seated_member`, โณ `session_cast`, `location`, `session_location`) collapse to the
981
981
  * three a declaration talks about: a lorebook and a session are the **world**,
982
982
  * a location entry and its session layer are a **location**, everything that
983
983
  * is somebody is the **cast**. A declaration should not have to know the
@@ -1195,7 +1195,7 @@ export function applyListOp(current, op, items, config = {}) {
1195
1195
  * Whether a slot may attach to this kind of owner.
1196
1196
  *
1197
1197
  * The owner *kinds* the host stores (`card`, `cast_member`, `lorebook`,
1198
- * `session`, `session_cast`, `location`, `session_location`) collapse to the
1198
+ * `session`, ๐Ÿšง `seated_member`, โณ `session_cast`, `location`, `session_location`) collapse to the
1199
1199
  * three a declaration talks about: a lorebook and a session are the **world**,
1200
1200
  * a location entry and its session layer are a **location**, everything that
1201
1201
  * is somebody is the **cast**. A declaration should not have to know the
package/dist/builder.d.ts CHANGED
@@ -210,10 +210,13 @@ export interface BuiltNode {
210
210
  * its legend among Advanced settings. Wins over the step status and the
211
211
  * node definition's name. Any node may carry one.
212
212
  * ยท `purpose` โ€” **the step purpose**: one or two plain sentences under
213
- * that group's heading, saying what this model call is for. Only on a
214
- * model call โ€” an oracle whose definition declares a `connection` slot
215
- * (`isModelCall`); no other step heads a group, so a purpose anywhere
216
- * else would never be read.
213
+ * that group's heading, saying what this model call is for. On a spec
214
+ * that calls no model at all it may sit on any step (the routines list
215
+ * prints the first one a routine's steps declare); on a spec that calls
216
+ * a model โ€” a node whose definition declares a `connection` slot
217
+ * (`isModelCall`), or one a node's `expose.swaps` lists โ€” only on a model
218
+ * call, because no other step heads a group. `build()` and `validate()`
219
+ * refuse the rest.
217
220
  *
218
221
  * Display text, hashed with the document like `status`: a spec that
219
222
  * sets neither hashes as it always did.
@@ -226,7 +229,7 @@ export interface BuiltNode {
226
229
  status?: I18n;
227
230
  label?: I18n;
228
231
  purpose?: I18n;
229
- /** ๐Ÿšง R54: the owner chooses this step's prompt (among those not hidden) โ€” see `NodeOpts.expose.promptReach`. */
232
+ /** โณ Transitional (R6): ignored by the host, which offers the owner every model call's prompt choice โ€” see `NodeOpts.expose.promptReach`. */
230
233
  promptReach?: 'owner';
231
234
  };
232
235
  /** The placement's `prefers`, when stated โ€” see `NodeOpts.prefers`. */
@@ -492,15 +495,13 @@ export interface NodeOpts {
492
495
  status?: I18n;
493
496
  /** The step label: this step's name in settings โ€” see `BuiltNode.expose`. */
494
497
  label?: I18n;
495
- /** The step purpose: what this model call is for, under its settings heading โ€” see `BuiltNode.expose`. */
498
+ /** The step purpose: what this step is for, under its settings heading โ€” see `BuiltNode.expose` for where it is allowed. */
496
499
  purpose?: I18n;
497
500
  /**
498
- * ๐Ÿšง **The prompt choice's reach** (R54, 2026-10-21): `'owner'` offers
499
- * the session's owner a choice of this step's prompt โ€” among the
500
- * prompts of its slot's pool an administrator has not hidden โ€” as a
501
- * setting of the pipeline. Never the prompt's text: members never edit
502
- * a prompt. Only on a step whose definition declares a `prompts` slot.
503
- * Absent: an administrator's choice alone.
501
+ * โณ **Transitional** (R6): the host offers a session's owner the
502
+ * prompt choice of every model call that offers one, whatever this
503
+ * says โ€” the choice, never the prompt's text. Kept so existing specs
504
+ * build; its only value is `'owner'`.
504
505
  */
505
506
  promptReach?: 'owner';
506
507
  };
@@ -534,7 +535,21 @@ export declare function isModelCall(def: {
534
535
  kind: string;
535
536
  }>>;
536
537
  }): boolean;
537
- /** The one sentence a misplaced step purpose is refused with, at construction and at `validate()`. @internal */
538
+ /**
539
+ * Whether a spec **calls a model at all**: any node whose definition `isModelCall`, or any definition
540
+ * a node lists in `expose.swaps` that does (a swap can seat a model call). A definition the registry
541
+ * does not know counts as none. Decides where a step purpose is allowed: on any step of a spec that
542
+ * calls no model, and only on a model call in one that does.
543
+ * @internal
544
+ */
545
+ export declare function specCallsModel(nodes: readonly {
546
+ definitionId: string;
547
+ definitionVersion: number;
548
+ expose?: {
549
+ swaps?: readonly string[];
550
+ };
551
+ }[]): boolean;
552
+ /** The one sentence a misplaced step purpose is refused with, at `build()` and at `validate()`. @internal */
538
553
  export declare const stepPurposeRefusal: (key: string, definitionId: string) => string;
539
554
  /**
540
555
  * A pinned constructor of a given kind. Constraining each method to its own kind makes