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

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 (79) hide show
  1. package/dist/annexFields.d.ts +14 -0
  2. package/dist/annexFields.js +7 -0
  3. package/dist/announce.d.ts +26 -13
  4. package/dist/announce.js +31 -0
  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 +23 -6
  10. package/dist/builder.js +57 -5
  11. package/dist/cadences.d.ts +11 -2
  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/declarations.js +4 -0
  19. package/dist/descriptors.d.ts +68 -3
  20. package/dist/descriptors.js +23 -0
  21. package/dist/document.d.ts +8 -0
  22. package/dist/document.js +44 -1
  23. package/dist/events.d.ts +35 -4
  24. package/dist/events.js +7 -3
  25. package/dist/executor.js +26 -5
  26. package/dist/extension.d.ts +17 -0
  27. package/dist/fit.d.ts +4 -1
  28. package/dist/fit.js +43 -1
  29. package/dist/functions.d.ts +7 -1
  30. package/dist/functions.js +3 -1
  31. package/dist/genres.d.ts +7 -0
  32. package/dist/genres.js +32 -1
  33. package/dist/hookGrants.js +10 -0
  34. package/dist/index.d.ts +4 -0
  35. package/dist/index.js +9 -0
  36. package/dist/layout.d.ts +18 -0
  37. package/dist/libraryDraft.d.ts +2 -0
  38. package/dist/libraryDraft.js +5 -1
  39. package/dist/lorebookFile.d.ts +8 -0
  40. package/dist/lorebookFile.js +21 -0
  41. package/dist/participants.d.ts +53 -8
  42. package/dist/participants.js +9 -5
  43. package/dist/pluginPermissions.js +1 -1
  44. package/dist/promptBlocks.d.ts +5 -1
  45. package/dist/promptBlocks.js +23 -8
  46. package/dist/registry.js +6 -3
  47. package/dist/sceneSettings.d.ts +4 -0
  48. package/dist/sceneSettings.js +7 -4
  49. package/dist/sessionDossier.d.ts +57 -0
  50. package/dist/sessionLayout.d.ts +296 -85
  51. package/dist/sessionLayout.js +397 -133
  52. package/dist/settings.d.ts +28 -1
  53. package/dist/settings.js +50 -2
  54. package/dist/shapes.d.ts +6 -1
  55. package/dist/shapes.js +6 -1
  56. package/dist/sheetLatitude.d.ts +148 -0
  57. package/dist/sheetLatitude.js +161 -0
  58. package/dist/storyTime.js +6 -4
  59. package/dist/surfaces.d.ts +11 -1
  60. package/dist/template.d.ts +26 -1
  61. package/dist/templateCheck.d.ts +24 -0
  62. package/dist/templateCheck.js +299 -7
  63. package/dist/templateFit.js +4 -0
  64. package/dist/templateIds.d.ts +6 -0
  65. package/dist/templateIds.js +9 -0
  66. package/dist/turnLock.d.ts +10 -1
  67. package/dist/turnLock.js +6 -1
  68. package/dist/turnOrder.d.ts +37 -4
  69. package/dist/turnOrder.js +49 -11
  70. package/dist/validate.d.ts +4 -2
  71. package/dist/validate.js +15 -11
  72. package/dist/variableLayouts.d.ts +141 -0
  73. package/dist/variableLayouts.js +183 -0
  74. package/dist/variables.d.ts +35 -7
  75. package/dist/variables.js +34 -1
  76. package/dist/widgetDecls.js +12 -0
  77. package/dist/widgets.d.ts +384 -41
  78. package/dist/widgets.js +23 -0
  79. package/package.json +1 -1
package/dist/fit.d.ts CHANGED
@@ -168,6 +168,8 @@ export interface RulesetFit {
168
168
  readonly inWords: readonly FitRow[];
169
169
  /** What the ruleset provides that the genre never exercises — shown neutrally, never a penalty. */
170
170
  readonly unused: readonly string[];
171
+ /** 🚧 The times its rules count on that the genre does not keep — a rating and a sentence, never a refusal (genres expect, never lock). Absent when none. */
172
+ readonly timeUnmet?: readonly ('story' | 'real')[];
171
173
  }
172
174
  /**
173
175
  * Cross-examine a genre's uses against a ruleset's provides.
@@ -180,9 +182,10 @@ export interface RulesetFit {
180
182
  * · Poor — more than half of the uses by words
181
183
  * · Incompatible — any use missing with no words fallback
182
184
  * A genre with no `uses` fits every ruleset Great (it asks for nothing).
185
+ * A genre that declares `keepsTime` lowers a better-than-Poor rating to Poor when the ruleset's functions count on a time the genre does not keep (`countsTime`), and says so; `timeUnmet` names it.
183
186
  * @experimental
184
187
  */
185
- export declare function rulesetFit(genre: Pick<GenreDecl, 'uses'> | null | undefined, ruleset: RulesetDecl | null | undefined): RulesetFit;
188
+ export declare function rulesetFit(genre: Pick<GenreDecl, 'uses' | 'keepsTime'> | null | undefined, ruleset: RulesetDecl | null | undefined): RulesetFit;
186
189
  /**
187
190
  * 🚧 What a genre **plays best with** (RF fix 8), as the picker lists it —
188
191
  * each expectation, required first, then optional (each label once): `plays
package/dist/fit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { normaliseConventions, rulesetDecides } from './rulesets.js';
2
2
  import { checkMethodKind } from './checkMethods.js';
3
3
  import { rulesetAttributeKinds, rulesetSections, rulesetZoneTypes } from './rulesetSections.js';
4
- import { functionProvides } from './functions.js';
4
+ import { functionProvides, resolveFunctionRef } from './functions.js';
5
5
  /** The six ratings, worst first. @experimental */
6
6
  export const RULESET_RATINGS = ['incompatible', 'poor', 'ok', 'good', 'great', 'perfect'];
7
7
  /** The picker's groups (ruled 2026-10-19): [Incompatible] · [Poor] · [Ok, Good] · [Great, Perfect]. @experimental */
@@ -158,6 +158,23 @@ export function rulesetProvides(decl) {
158
158
  return { verbs, slots, pieces, conditions, casting, dice, chance, methods: kinds, tags, tagged, scripted, decides: rulesetDecides(decl), attributeTags, zoneTags };
159
159
  }
160
160
  const PROSE_FALLBACK_VERBS = new Set(['modify', 'set', 'adjustDegree', 'harm', 'heal', 'cure', 'consume']);
161
+ /** Which times a ruleset's functions count on: each declaration's `countsTime`, and core's recurring function set to an hour or a day (a clock move). */
162
+ function timeNeedOf(ruleset) {
163
+ const need = { story: false, real: false };
164
+ if (!ruleset)
165
+ return need;
166
+ for (const ref of rulesetSections(ruleset).functions ?? []) {
167
+ const t = resolveFunctionRef(ref).decl?.countsTime;
168
+ if (t === 'story' || t === 'both')
169
+ need.story = true;
170
+ if (t === 'real' || t === 'both')
171
+ need.real = true;
172
+ const every = ref.options?.every;
173
+ if (ref.ref === 'core:function/recurring@1' && (every === 'hour' || every === 'day'))
174
+ need.story = true;
175
+ }
176
+ return need;
177
+ }
161
178
  /**
162
179
  * Cross-examine a genre's uses against a ruleset's provides.
163
180
  *
@@ -169,6 +186,7 @@ const PROSE_FALLBACK_VERBS = new Set(['modify', 'set', 'adjustDegree', 'harm', '
169
186
  * · Poor — more than half of the uses by words
170
187
  * · Incompatible — any use missing with no words fallback
171
188
  * A genre with no `uses` fits every ruleset Great (it asks for nothing).
189
+ * A genre that declares `keepsTime` lowers a better-than-Poor rating to Poor when the ruleset's functions count on a time the genre does not keep (`countsTime`), and says so; `timeUnmet` names it.
172
190
  * @experimental
173
191
  */
174
192
  export function rulesetFit(genre, ruleset) {
@@ -254,6 +272,30 @@ export function rulesetFit(genre, ruleset) {
254
272
  : rating === 'great'
255
273
  ? `this genre asks for nothing in particular`
256
274
  : `${words.map(name).join(', ')} — told in words`;
275
+ const keeps = genre?.keepsTime;
276
+ if (keeps) {
277
+ const need = timeNeedOf(ruleset);
278
+ const timeUnmet = [];
279
+ if (need.story && keeps !== 'story')
280
+ timeUnmet.push('story');
281
+ if (need.real && keeps !== 'real')
282
+ timeUnmet.push('real');
283
+ if (timeUnmet.length) {
284
+ const lowered = rating === 'incompatible' ? rating : 'poor';
285
+ const timeReason = timeUnmet[0] === 'story'
286
+ ? `its rules count story time, and this genre ${keeps === 'real' ? 'runs on real time' : 'keeps no clock'}: they would never move`
287
+ : `its rules count real time, and this genre ${keeps === 'story' ? 'keeps a story clock' : 'keeps no clock'}: they would move with the hours outside the story`;
288
+ return {
289
+ rating: lowered,
290
+ group: ratingGroupOf(lowered),
291
+ reason: rating === 'incompatible' ? reason : timeReason,
292
+ rows,
293
+ unused,
294
+ inWords,
295
+ timeUnmet,
296
+ };
297
+ }
298
+ }
257
299
  return { rating, group: ratingGroupOf(rating), reason, rows, unused, inWords };
258
300
  }
259
301
  /**
@@ -247,6 +247,12 @@ export interface FunctionProps {
247
247
  rollsDice?: true;
248
248
  /** 🚧 The function this one was forked from, by id (`forkFunction`). */
249
249
  forkedFrom?: FunctionId;
250
+ /**
251
+ * 🚧 Which time the function counts on — the story clock (`'story'`), real
252
+ * elapsed time (`'real'`), or both; left out, it counts on neither. Ruleset
253
+ * fit reads it (`rulesetFit`). Content, inside the hash — not display text.
254
+ */
255
+ countsTime?: 'story' | 'real' | 'both';
250
256
  }
251
257
  /** 🚧 A declared function module: its props and its id. @experimental */
252
258
  export interface FunctionDecl extends FunctionProps {
@@ -370,7 +376,7 @@ export declare const tagListFindings: (tags: unknown, at: string) => string[];
370
376
  * `missing-prose` · `bad-function-binding` · `bad-phase` · `bad-schema` ·
371
377
  * `bad-form` · `bad-body` · `body-without-phases` · `phases-without-body` ·
372
378
  * `bad-emits` · `bad-invokable` · `bad-adds` (with the attribute, outcome
373
- * and zone type reasons inside) · `bad-tags` · `bad-chance` · `bad-fork`.
379
+ * and zone type reasons inside) · `bad-tags` · `bad-chance` · `bad-fork` · `bad-counts-time`.
374
380
  * @experimental
375
381
  */
376
382
  export declare function functionFindings(id: string, props: FunctionProps): string[];
package/dist/functions.js CHANGED
@@ -266,7 +266,7 @@ function schemaFindings(schema, at, reason) {
266
266
  * `missing-prose` · `bad-function-binding` · `bad-phase` · `bad-schema` ·
267
267
  * `bad-form` · `bad-body` · `body-without-phases` · `phases-without-body` ·
268
268
  * `bad-emits` · `bad-invokable` · `bad-adds` (with the attribute, outcome
269
- * and zone type reasons inside) · `bad-tags` · `bad-chance` · `bad-fork`.
269
+ * and zone type reasons inside) · `bad-tags` · `bad-chance` · `bad-fork` · `bad-counts-time`.
270
270
  * @experimental
271
271
  */
272
272
  export function functionFindings(id, props) {
@@ -380,6 +380,8 @@ export function functionFindings(id, props) {
380
380
  out.push(finding('bad-chance', `${at} rolls dice and does not say chance. Dice are chance — say chance: true too.`));
381
381
  if (props.forkedFrom !== undefined && !isFunctionId(props.forkedFrom))
382
382
  out.push(finding('bad-fork', `${at}.forkedFrom is the id of the function it was forked from — 'core:function/die-target@1'.`));
383
+ if (props.countsTime !== undefined && props.countsTime !== 'story' && props.countsTime !== 'real' && props.countsTime !== 'both')
384
+ out.push(finding('bad-counts-time', `${at}.countsTime is 'story', 'real' or 'both', or left out — not ${JSON.stringify(props.countsTime)}.`));
383
385
  return out;
384
386
  }
385
387
  function addsFindings(adds, at) {
package/dist/genres.d.ts CHANGED
@@ -182,6 +182,8 @@ export interface GenreDecl {
182
182
  }[];
183
183
  /** 🚧 Who may sit here (ruled 2026-10-19): `'solo'` — never a group session: the form hides the group switch and the host refuses `isGroup`, invites, guest claims and lanes (the Guide: one person's questions about the app). `'group'` (default) — as the shape allows. */
184
184
  readonly members?: 'solo' | 'group';
185
+ /** 🚧 Which time this genre keeps — a story clock (`'story'`: Story, the Lair, the Dungeon Crawler), real time (`'real'`: the Guide, Chat) or neither (`'none'`). `rulesetFit` weighs a ruleset's functions' `countsTime` against it; left out, fit does not weigh time. */
186
+ readonly keepsTime?: 'story' | 'real' | 'none';
185
187
  /**
186
188
  * 🚧 What this genre **plays best with** (PLAN-genre-restructure §11; RF fix 8, owner ruling
187
189
  * 2026-10-23: "genres expect, never lock"): the verbs its scripts emit (or `'any'`), and the
@@ -311,6 +313,8 @@ export interface GenreDecl {
311
313
  */
312
314
  readonly history?: {
313
315
  readonly settle: 'on-write' | 'on-commit';
316
+ /** 🚧 How far one press of Back reaches (owner 2026-11-04): 'turn' (default) = the person's line and every reply that answered it; 'message' = the newest message only, with the routine lines (clock moves, notes) filed on it. */
317
+ readonly back?: 'message' | 'turn';
314
318
  };
315
319
  /**
316
320
  * The genre's **enabled-when defaults** (built
@@ -421,6 +425,8 @@ export interface GenreProps {
421
425
  handbook?: readonly HandbookPage[];
422
426
  /** 🚧 `'solo'` refuses group sessions — see `GenreDecl.members`. */
423
427
  members?: 'solo' | 'group';
428
+ /** 🚧 Which time the genre keeps — see `GenreDecl.keepsTime`. */
429
+ keepsTime?: 'story' | 'real' | 'none';
424
430
  /** 🚧 What the genre uses of a ruleset — see `GenreDecl.uses`. */
425
431
  uses?: GenreUses;
426
432
  /** 🚧 The genre's defaults — its registrations and setting values; see `GenreDecl.defaults`. */
@@ -433,6 +439,7 @@ export interface GenreProps {
433
439
  /** When the genre's history settles — see `GenreDecl.history`. */
434
440
  history?: {
435
441
  readonly settle: HistorySettle;
442
+ readonly back?: 'message' | 'turn';
436
443
  };
437
444
  /** Enabled-when defaults per action identity — see `GenreDecl.enabledWhen`. */
438
445
  enabledWhen?: Readonly<Record<string, EnabledWhenDecl>>;
package/dist/genres.js CHANGED
@@ -600,6 +600,31 @@ export function genre(id, props) {
600
600
  if (typeof props.shape.view !== 'string')
601
601
  throw new Error(`${id}.shape.applet without a session view. Declare shape.view (the plugin whose frame the applet mounts) or drop applet.`);
602
602
  }
603
+ // 🚧 The book seats its cast (M3b, ★M3-4): refused here — a declaration that could never seat anyone is an authoring mistake.
604
+ if (props.shape?.castFromLorebook !== undefined) {
605
+ const at = `${id}.shape.castFromLorebook`;
606
+ const declared = props.shape.castFromLorebook;
607
+ if (declared === null || typeof declared !== 'object' || Array.isArray(declared))
608
+ throw new Error(`${at} must be an object — { field?: 'examples' } — or left out.`);
609
+ const field = declared.field;
610
+ if (field !== undefined) {
611
+ if (typeof field !== 'string' || field.trim() === '')
612
+ throw new Error(`${at}.field must be the name of a boolean field of this shape. Name one, or drop field to seat the cast always.`);
613
+ const decl = props.shape.fields?.[field];
614
+ if (!decl)
615
+ throw new Error(`${at}.field must name a boolean field of this shape; '${field}' is not declared in shape.fields. Declare it there as { type: 'boolean' } or drop field.`);
616
+ if (decl.type !== 'boolean')
617
+ throw new Error(`${at}.field must name a boolean field of this shape; '${field}' is a ${String(decl.type)} field. Name a boolean field or drop field.`);
618
+ }
619
+ if (props.shape.lorebook === undefined)
620
+ throw new Error(`${at} needs shape.lorebook: without the attachment picker no book is ever attached. Declare lorebook: 'optional' or drop castFromLorebook.`);
621
+ const seats = props.shape.characters;
622
+ if (seats === undefined || seats.max === 0)
623
+ throw new Error(`${at} needs character seats: shape.characters is ${seats === undefined ? 'absent' : 'max: 0'}, so every seat would be refused. Declare characters with room for the cast or drop castFromLorebook.`);
624
+ }
625
+ // 🚧 Seat changes on each turn (owner 2026-11-09): a boolean opt-in, refused otherwise.
626
+ if (props.shape?.turnSeatChanges !== undefined && typeof props.shape.turnSeatChanges !== 'boolean')
627
+ throw new Error(`${id}.shape.turnSeatChanges must be true or false. Declare turnSeatChanges: true for turn-ended to carry the seats that changed, or leave it out.`);
603
628
  assertScenePlaceDeclared(props, id);
604
629
  const events = { ...(props.events ?? {}) };
605
630
  // The turn-order write's own event is core-internal (PLAN-turn-order
@@ -655,6 +680,8 @@ export function genre(id, props) {
655
680
  throw new RulesetError(id, rulesetFound);
656
681
  if (props.members !== undefined && props.members !== 'solo' && props.members !== 'group')
657
682
  throw new Error(`${id}.members: 'solo' or 'group' — not ${JSON.stringify(props.members)}`);
683
+ if (props.keepsTime !== undefined && props.keepsTime !== 'story' && props.keepsTime !== 'real' && props.keepsTime !== 'none')
684
+ throw new Error(`${id}.keepsTime: 'story', 'real' or 'none' — not ${JSON.stringify(props.keepsTime)}`);
658
685
  const usesFound = genreUsesFindings(props.uses, `${id}.uses`);
659
686
  if (usesFound.length)
660
687
  throw new Error(usesFound.join('\n'));
@@ -678,6 +705,8 @@ export function genre(id, props) {
678
705
  // 🚧 2026-10-23: absent when unstated, so a genre that says nothing hashes as it did.
679
706
  ...(props.handbook !== undefined ? { handbook: Object.freeze(props.handbook.map((p) => Object.freeze({ title: p.title, body: p.body }))) } : {}),
680
707
  ...(props.members === 'solo' ? { members: 'solo' } : {}),
708
+ // 🚧 absent when unstated, so a genre that says nothing hashes as it did.
709
+ ...(props.keepsTime !== undefined ? { keepsTime: props.keepsTime } : {}),
681
710
  ...(props.uses ? { uses: Object.freeze(JSON.parse(JSON.stringify(props.uses))) } : {}),
682
711
  // PLAN-layering D4: absent when unstated, so a genre that says nothing hashes as it did.
683
712
  ...(props.defaults ? { defaults: freezeGenreDefaults(props.defaults) } : {}),
@@ -687,7 +716,9 @@ export function genre(id, props) {
687
716
  // R4: absent when unstated, so a genre that says nothing hashes as it did.
688
717
  ...(playerLabel ? { playerLabel } : {}),
689
718
  // G2: absent when unstated, so a genre that says nothing hashes as it did.
690
- ...(props.history ? { history: Object.freeze({ settle: props.history.settle }) } : {}),
719
+ ...(props.history
720
+ ? { history: Object.freeze({ settle: props.history.settle, ...(props.history.back ? { back: props.history.back } : {}) }) }
721
+ : {}),
691
722
  ...(enabledWhen && Object.keys(enabledWhen).length ? { enabledWhen } : {}),
692
723
  // The pinned settings (§4.13): copied when stated, frozen like the
693
724
  // rest, absent otherwise — so an unpinned genre hashes as it did.
@@ -28,6 +28,16 @@ export const HOOK_CTX_KINDS = [
28
28
  * person's saved documents (🚧 M2b); no network.
29
29
  * - **oracle** — storage, package and fetch. The one kind that calls out, which is what
30
30
  * `effects: 'external'` names.
31
+ *
32
+ * The table says what a kind's `ctx` CARRIES, never whether a member works on a
33
+ * given call. The applet group — `ctx.annex('user')` and `ctx.storage.user` — is
34
+ * present on every kind above that has `annex` / `storage` and, per call, works
35
+ * only while the host's frame-origin cause names the calling plugin: its own
36
+ * mounted frame's request, or a person's press in it, caused the call (owner
37
+ * 2026-11-04). An event or lifecycle hook, the schedule tick and a routine,
38
+ * cadence or schedule run carry none, so those members reject there with one
39
+ * sentence ("<thing> is only available while the app is open.") — present and
40
+ * refusing, never absent, like `ctx.storage.user` with no acting person.
31
41
  * @ruling F11, F32
32
42
  */
33
43
  const GRANTS = {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './shapes.js';
2
2
  export * from './candidates.js';
3
3
  export * from './i18n.js';
4
+ export * from './appletCard.js';
4
5
  export * from './verdicts.js';
5
6
  export * from './descriptors.js';
6
7
  export * from './nodeInput.js';
@@ -29,6 +30,7 @@ export * from './engines.js';
29
30
  export * from './templateIds.js';
30
31
  export * from './loadouts.js';
31
32
  export * from './variables.js';
33
+ export * from './variableLayouts.js';
32
34
  export * from './bands.js';
33
35
  export * from './templateScopeAt.js';
34
36
  export * from './templateFit.js';
@@ -40,6 +42,7 @@ export * from './checkMethods.js';
40
42
  export * from './rulesetDocument.js';
41
43
  export * from './rulesetTemplates.js';
42
44
  export * from './rulesetSections.js';
45
+ export * from './sheetLatitude.js';
43
46
  export * from './functions.js';
44
47
  export * from './ties.js';
45
48
  export * from './jsonSchema.js';
@@ -102,6 +105,7 @@ export * from './componentWire.js';
102
105
  export * from './componentModule.js';
103
106
  export * from './channels.js';
104
107
  export * from './participants.js';
108
+ export * from './characterProfile.js';
105
109
  export * from './turnOrder.js';
106
110
  export * from './sessionSettings.js';
107
111
  export * from './actions.js';
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ export * from './candidates.js';
3
3
  // Display text (R-20): the one `I18n` type, `i18nFindings` every publish door
4
4
  // runs, and `i18nText` every reader resolves through.
5
5
  export * from './i18n.js';
6
+ export * from './appletCard.js';
6
7
  // One verdict per law (01 §13): `defineVerdict` / `verdicts()` and the five
7
8
  // verdicts whose judges read only leaf vocabulary — the effects line and form
8
9
  // staleness are declared in `messageBlocks.ts`, beside the primitives they
@@ -48,6 +49,10 @@ export * from './templateIds.js';
48
49
  // `loadout-ref` value a node's `loadout` slot holds, and `prefers`.
49
50
  export * from './loadouts.js';
50
51
  export * from './variables.js';
52
+ // 🚧 Variable layouts by reference (PLAN-variable-layouts-2026-11-10): the
53
+ // `<owner>/<slug>@<major>` a template, a preset and the pub name a layout by,
54
+ // and `variableLayout()`, the typed seed a plugin ships one with.
55
+ export * from './variableLayouts.js';
51
56
  // Bands as template variables (typed templates P2): a source declares the
52
57
  // bands it publishes; `rendersAt` is what a node's variables slot renders.
53
58
  export * from './bands.js';
@@ -83,6 +88,8 @@ export * from './rulesetDocument.js';
83
88
  // ruleset laws a shipped catalogue keeps (2026-10-22).
84
89
  export * from './rulesetTemplates.js';
85
90
  export * from './rulesetSections.js';
91
+ // 🚧 Sheet latitude — how far each role may change sheets and move items by hand, and the one judge (2026-11-05).
92
+ export * from './sheetLatitude.js';
86
93
  export * from './functions.js';
87
94
  export * from './ties.js';
88
95
  // 🚧 A declared shape as the JSON Schema a model answers against, and the one
@@ -195,6 +202,8 @@ export * from './channels.js';
195
202
  // Participant references — the audience grammar and the inlet's speaker
196
203
  // (R-15, R-18 (3)); `Portrayal` is the resolver's answer the receipt pins.
197
204
  export * from './participants.js';
205
+ // 🚧 The character profile and the cast member as a session reads them (cv-sdk).
206
+ export * from './characterProfile.js';
198
207
  // Turn order as state (PLAN-turn-order §4.2): the candidate, entry and order
199
208
  // documents, `EMPTY_TURN_ORDER` and `readTurnOrder`. After participants
200
209
  // because a candidate's `ref` is a participant reference.
package/dist/layout.d.ts CHANGED
@@ -13,6 +13,7 @@
13
13
  * @ruling PLAN-layout-one-format-2026-09-28 brief 1
14
14
  */
15
15
  import type { I18n } from './i18n.js';
16
+ import type { PanelPriority } from './sessionLayout.js';
16
17
  import type { SettingsSchema } from './settings.js';
17
18
  import type { WidgetBaseSection, WidgetSectionScope, WidgetWriteGrant } from './widgets.js';
18
19
  /**
@@ -182,6 +183,23 @@ export interface WidgetDecl {
182
183
  * reading order (middle, left, right) and `validateSessionLayout` warns.
183
184
  */
184
185
  maxInstances?: number;
186
+ /**
187
+ * 🚧 How the host sizes and weighs the panel that shows this widget when the
188
+ * layout doesn't say. `height`: `fit` its content, or `fill` a share of what
189
+ * is left (absent: `fill`). `priority`: when a zone runs short, `low` gives
190
+ * way first, then `normal` (absent: `normal`). A layout's own
191
+ * `PanelV2.height` / `priority` win. Core's: Messages
192
+ * `{ height: 'fill', priority: 'low' }`, Composer
193
+ * `{ height: 'fit', priority: 'high' }`, Turn line
194
+ * `{ height: 'fit', priority: 'normal' }`.
195
+ *
196
+ * @ruling the owner, 2026-11-05 (R8: "an expanding composer weighs more than
197
+ * the activity/turn, and it weighs more than the messages")
198
+ */
199
+ panel?: {
200
+ height?: 'fit' | 'fill';
201
+ priority?: PanelPriority;
202
+ };
185
203
  /**
186
204
  * ⏳ The surface manager's packing hints — what the app's panel packer
187
205
  * reads: the column span a widget asks for, its minimum box, whether it may
@@ -9,6 +9,8 @@
9
9
  * `readLibraryDraft` takes every such block out of the text (what the person reads, and what is saved), and reads
10
10
  * the LAST one: `make` names its kind and `draft` its parsed JSON. No block, an unknown kind, or JSON that does not
11
11
  * parse → `make: ''` and no `draft` (the blocks are still taken out). Pure; what `core:task/read-library-draft@1` runs.
12
+ * It is also the Guide reply's cleanup step: draft blocks out, and a line that is exactly `See: /docs/<path>` (optionally in
13
+ * backticks, optionally a trailing `.`) turned into a markdown link the message renderer draws.
12
14
  * ⚠ Not a tool call (`parse-tool-call@1`) and not `parse-json@1` (which reads a whole reply as JSON).
13
15
  * @experimental
14
16
  */
@@ -1,4 +1,5 @@
1
1
  const BLOCK = /<!--\s*draft:([a-z-]+)\s*([\s\S]*?)-->/g;
2
+ const SEE_LINE = /^See: ?`?(\/docs\/[^\s`]+?)`?\.?[ \t]*$/gm;
2
3
  /** @experimental */
3
4
  export function readLibraryDraft(text) {
4
5
  const s = typeof text === 'string' ? text : '';
@@ -9,7 +10,10 @@ export function readLibraryDraft(text) {
9
10
  // draft anyone can read, and it must not be saved into the message.
10
11
  const closed = s.replace(BLOCK, '');
11
12
  const open = closed.search(/<!--\s*draft:/);
12
- const stripped = (open >= 0 ? closed.slice(0, open) : closed).replace(/\n{3,}/g, '\n\n').trimEnd();
13
+ const stripped = (open >= 0 ? closed.slice(0, open) : closed)
14
+ .replace(/\n{3,}/g, '\n\n')
15
+ .trimEnd()
16
+ .replace(SEE_LINE, 'See: [$1]($1)');
13
17
  if (!last || (last.kind !== 'character' && last.kind !== 'lorebook'))
14
18
  return { text: stripped, make: '' };
15
19
  try {
@@ -11,6 +11,14 @@
11
11
  * file-level shape only: size, JSON, nesting, the entries list, and the
12
12
  * ceilings on counts and lengths. It never touches a database.
13
13
  *
14
+ * The file-level fields it also checks are a book's **rules**:
15
+ * `extensions.serenepub.primaryRuleset` (plus an optional `rulesetVersion`), the
16
+ * book's own ruleset beside `storyTime` (ruling ★M3b-S5-1, 2026-11-05). They are
17
+ * not a session's ruleset and not a lock: a session started on the book adopts
18
+ * them, and a Freeform book brings none. An id this pub doesn't have is the
19
+ * importer's business (it imports the book on Freeform with a warning), not the
20
+ * validator's; this checks the shape only.
21
+ *
14
22
  * @experimental
15
23
  */
16
24
  /** The ceilings an imported lorebook file is held to. Mirrors the app's `LOREBOOK_IMPORT_LIMITS`. @experimental */
@@ -11,6 +11,14 @@
11
11
  * file-level shape only: size, JSON, nesting, the entries list, and the
12
12
  * ceilings on counts and lengths. It never touches a database.
13
13
  *
14
+ * The file-level fields it also checks are a book's **rules**:
15
+ * `extensions.serenepub.primaryRuleset` (plus an optional `rulesetVersion`), the
16
+ * book's own ruleset beside `storyTime` (ruling ★M3b-S5-1, 2026-11-05). They are
17
+ * not a session's ruleset and not a lock: a session started on the book adopts
18
+ * them, and a Freeform book brings none. An id this pub doesn't have is the
19
+ * importer's business (it imports the book on Freeform with a warning), not the
20
+ * validator's; this checks the shape only.
21
+ *
14
22
  * @experimental
15
23
  */
16
24
  /** The ceilings an imported lorebook file is held to. Mirrors the app's `LOREBOOK_IMPORT_LIMITS`. @experimental */
@@ -175,6 +183,19 @@ export function lorebookFileFindings(text) {
175
183
  out.push(`Lorebook's narrative graph has too many nodes (${count(graph?.nodes)}); the maximum supported is ${L.maxNarrativeNodes}.`);
176
184
  if (count(graph?.relationships) > L.maxNarrativeRelationships)
177
185
  out.push(`Lorebook's narrative graph has too many relationships (${count(graph?.relationships)}); the maximum supported is ${L.maxNarrativeRelationships}.`);
186
+ if (serenepub && typeof serenepub === 'object' && !Array.isArray(serenepub)) {
187
+ const { primaryRuleset, rulesetVersion } = serenepub;
188
+ const named = primaryRuleset !== undefined && primaryRuleset !== null;
189
+ const versioned = rulesetVersion !== undefined && rulesetVersion !== null;
190
+ if (named && (typeof primaryRuleset !== 'string' || primaryRuleset === '' || primaryRuleset.length > L.maxNameChars))
191
+ out.push("This lorebook's primaryRuleset must be a ruleset id, such as 'core:ruleset/freeform@1'.");
192
+ if (versioned && (typeof rulesetVersion !== 'string' || !/^\d+\.\d+\.\d+/.test(rulesetVersion))) {
193
+ const shown = typeof rulesetVersion === 'string' && rulesetVersion.length <= 40 ? ` '${rulesetVersion}'` : '';
194
+ out.push(`This lorebook's rulesetVersion${shown} isn't a version like 1.2.0.`);
195
+ }
196
+ if (versioned && !named)
197
+ out.push('This lorebook names a rulesetVersion but no primaryRuleset.');
198
+ }
178
199
  const book = data.character_book ?? data.data?.character_book ?? data;
179
200
  if (typeof book?.name === 'string' && book.name.length > L.maxNameChars)
180
201
  out.push(`This lorebook's name is ${fmt(book.name.length)} characters; Serene Pub reads up to ${fmt(L.maxNameChars)}.`);
@@ -16,7 +16,8 @@
16
16
  * | `admin` | Any administrator acting in the session. |
17
17
  * | `participant` | Any member of the session — owner or guest. |
18
18
  * | `user:<id>` | One person, by user id. |
19
- * | `character:<id>` | One library character, by row id — a cast member, or a member's own persona. |
19
+ * | `character:<id>` | One library character, by row id — a cast member, or a member's own persona. ⏳ A seat by its card; removed in S5 of the seat-cast programme. |
20
+ * | `seated-member:<id>` | 🚧 One seated **cast member**, by cast member id (the host's `lorebook_bindings.id`) — the seat-cast programme's reference for a seat. |
20
21
  * | `player-seat:<id>` | 🚧 A player seat that voices **no card**, by seat id — a player character made up in the session. |
21
22
  * | `envoy:<slug>` | A speaker the genre (or a contributed action) brings with it — `envoy:mascot`, `envoy:chariot.dice-tray.master`. |
22
23
  * | `item` | The **per-message ownership rule**: whoever the message belongs to, decided at the venue, never resolvable ahead of a message. |
@@ -76,9 +77,14 @@ export type ParticipantRole = (typeof PARTICIPANT_ROLES)[number];
76
77
  * the id half is a string here and the host reads it at its seam. A
77
78
  * `player-seat:` id is the host's player seat row (`session_personas.id`). An envoy
78
79
  * slug is `[A-Za-z0-9]` followed by any of `[A-Za-z0-9._-]`.
80
+ *
81
+ * 🚧 `seated-member:<id>` is a seated **cast member**, by its cast member id
82
+ * (the host's `lorebook_bindings.id`) — the seat-cast programme's reference
83
+ * for a seat. ⏳ `character:<id>` (a seat by its card) is removed in S5 of the
84
+ * seat-cast programme.
79
85
  * @experimental
80
86
  */
81
- export type ParticipantRef = ParticipantRole | `user:${string}` | `character:${string}` | `player-seat:${string}` | `envoy:${string}`;
87
+ export type ParticipantRef = ParticipantRole | `user:${string}` | `character:${string}` | `seated-member:${string}` | `player-seat:${string}` | `envoy:${string}`;
82
88
  /** A reference taken apart. @experimental */
83
89
  export type ParsedParticipantRef = {
84
90
  kind: ParticipantRole;
@@ -88,6 +94,9 @@ export type ParsedParticipantRef = {
88
94
  } | {
89
95
  kind: 'character';
90
96
  id: string;
97
+ } | {
98
+ kind: 'seated-member';
99
+ id: string;
91
100
  } | {
92
101
  kind: 'player-seat';
93
102
  id: string;
@@ -146,8 +155,8 @@ export declare function audienceHolds(refs: ReadonlyArray<ParticipantRef>, portr
146
155
  }, item?: boolean): boolean;
147
156
  /**
148
157
  * Does the model's context hold any of these references? The prompt
149
- * built for `speaker` — a `character:` or `envoy:` reference, when there is
150
- * one — may carry what everyone may see (`participant`), what the model may
158
+ * built for `speaker` — a `character:`, `seated-member:` or `envoy:` reference,
159
+ * when there is one — may carry what everyone may see (`participant`), what the model may
151
160
  * (`ai`), and what that speaker may. `[]` holds for nobody.
152
161
  * @internal
153
162
  * @ruling R57
@@ -225,9 +234,12 @@ export declare function envoySlugOfRef(ref: unknown): string | null;
225
234
  * settings document (`SessionSettingsV1`, sessionSettings.ts) and the
226
235
  * `cast` in-port of `core:task/turn-pool@1`.
227
236
  *
228
- * Declared from the existing read and **adding no fields**: the character
237
+ * Declared from the existing read: the character
229
238
  * and persona rows go out raw with the seat's `position`, `removedAt` and
230
- * `enabled` riding along (the host retrieves, it does not choose), `envoys` is the
239
+ * `enabled` riding along (the host retrieves, it does not choose). 🚧 S3 of the
240
+ * seat-cast programme adds the host-filled identity (`ref`, `castMemberId`,
241
+ * `cardId`) on each seat row; a reader matches on it and never builds it.
242
+ * `envoys` is the
231
243
  * seated envoys `entities/envoys.ts seatedEnvoys` returns (each with `slug`,
232
244
  * `position`, `speaks`, `removedAt`), and the rest is what the prompt path
233
245
  * already reads. Every row is open: the host's character row has more
@@ -238,7 +250,12 @@ export declare function envoySlugOfRef(ref: unknown): string | null;
238
250
  * @experimental
239
251
  */
240
252
  export interface SessionCastV1 {
241
- /** Character seats: the library row under `character`, plus the seat's own columns. */
253
+ /**
254
+ * Character seats: the library row under `character`, plus the seat's own columns.
255
+ * `character` is card-shaped but has no `id` or `userId` for a card-less
256
+ * seat; read `ref` and `castMemberId`. `seatedByUserId` is the person who
257
+ * seated it and acts for it.
258
+ */
242
259
  sessionCharacters: Array<{
243
260
  character: {
244
261
  id: number;
@@ -260,6 +277,20 @@ export interface SessionCastV1 {
260
277
  removedAt: Date | string | null;
261
278
  /** Attached by the host from `lorebook_bindings`, not a cast column. */
262
279
  absorbedAliases: string[];
280
+ /**
281
+ * 🚧 The seat's participant reference, as the host fills it: from the flip
282
+ * a character seat is `seated-member:<castMemberId>` (⏳ `character:<cardId>`
283
+ * while it stores no member) and a player seat, carded or not,
284
+ * `player-seat:<seatId>`; before it the card form. A reader matches on it
285
+ * and never builds it.
286
+ */
287
+ ref?: ParticipantRef;
288
+ /** 🚧 The seat's cast member (the host's `lorebook_bindings.id`); null while the seat has none. */
289
+ castMemberId?: number | null;
290
+ /** 🚧 The member's active card on the timeline; null when card-less. */
291
+ cardId?: number | null;
292
+ /** 🚧 The person who seated this member and acts for it; null on a row from before it. */
293
+ seatedByUserId?: number | null;
263
294
  [k: string]: unknown;
264
295
  }>;
265
296
  /**
@@ -283,11 +314,23 @@ export interface SessionCastV1 {
283
314
  seatName: string | null;
284
315
  /** 🚧 Who sits in the seat; null on a row from before it (read the card's owner). */
285
316
  seatUserId: number | null;
286
- /** Always true — a persona seat has no switch — said so one filter serves both lists. */
317
+ /** 🚧 The seat is in play: false = benched (owner 2026-11-10). Every seat is here, benched or not; a reader that must not see a benched one — a turn pool, a names list — filters on this (the table's column is `is_active`). */
287
318
  enabled: boolean;
288
319
  position: number | null;
289
320
  removedAt: Date | string | null;
290
321
  absorbedAliases: string[];
322
+ /**
323
+ * 🚧 The seat's participant reference, as the host fills it: from the flip
324
+ * a character seat is `seated-member:<castMemberId>` (⏳ `character:<cardId>`
325
+ * while it stores no member) and a player seat, carded or not,
326
+ * `player-seat:<seatId>`; before it the card form. A reader matches on it
327
+ * and never builds it.
328
+ */
329
+ ref?: ParticipantRef;
330
+ /** 🚧 The seat's cast member (the host's `lorebook_bindings.id`); null while the seat has none. */
331
+ castMemberId?: number | null;
332
+ /** 🚧 The member's active card on the timeline; null when card-less. */
333
+ cardId?: number | null;
291
334
  [k: string]: unknown;
292
335
  }>;
293
336
  /** The seated envoys, live and departed, in seat order — each its declaration joined to the seat. */
@@ -307,6 +350,8 @@ export interface SessionCastV1 {
307
350
  isGroup: boolean;
308
351
  /** Whose turn this run is, from the scope; null when the trigger named nobody. */
309
352
  currentCharacterId: number | null;
353
+ /** 🚧 The member speaking a card-less seat's turn, from the scope; set only when `currentCharacterId` is null. */
354
+ currentCastMemberId?: number | null;
310
355
  /** The declared voice of the turn's channel, when the trigger named one and the genre shapes channels. */
311
356
  turnChannelVoice?: 'character' | 'narrator' | 'none';
312
357
  /**
@@ -16,7 +16,8 @@
16
16
  * | `admin` | Any administrator acting in the session. |
17
17
  * | `participant` | Any member of the session — owner or guest. |
18
18
  * | `user:<id>` | One person, by user id. |
19
- * | `character:<id>` | One library character, by row id — a cast member, or a member's own persona. |
19
+ * | `character:<id>` | One library character, by row id — a cast member, or a member's own persona. ⏳ A seat by its card; removed in S5 of the seat-cast programme. |
20
+ * | `seated-member:<id>` | 🚧 One seated **cast member**, by cast member id (the host's `lorebook_bindings.id`) — the seat-cast programme's reference for a seat. |
20
21
  * | `player-seat:<id>` | 🚧 A player seat that voices **no card**, by seat id — a player character made up in the session. |
21
22
  * | `envoy:<slug>` | A speaker the genre (or a contributed action) brings with it — `envoy:mascot`, `envoy:chariot.dice-tray.master`. |
22
23
  * | `item` | The **per-message ownership rule**: whoever the message belongs to, decided at the venue, never resolvable ahead of a message. |
@@ -94,8 +95,8 @@ export function audienceHolds(refs, portrayals, viewer, item) {
94
95
  }
95
96
  /**
96
97
  * Does the model's context hold any of these references? The prompt
97
- * built for `speaker` — a `character:` or `envoy:` reference, when there is
98
- * one — may carry what everyone may see (`participant`), what the model may
98
+ * built for `speaker` — a `character:`, `seated-member:` or `envoy:` reference,
99
+ * when there is one — may carry what everyone may see (`participant`), what the model may
99
100
  * (`ai`), and what that speaker may. `[]` holds for nobody.
100
101
  * @internal
101
102
  * @ruling R57
@@ -179,12 +180,13 @@ export function parseParticipantRef(raw) {
179
180
  const cut = text.indexOf(':');
180
181
  if (cut === -1)
181
182
  throw new Error(`'${raw}' is not a participant reference — expected one of ${PARTICIPANT_ROLES.join(', ')}, ` +
182
- `or user:<id>, character:<id>, player-seat:<id>, envoy:<slug>`);
183
+ `or user:<id>, character:<id>, seated-member:<id>, player-seat:<id>, envoy:<slug>`);
183
184
  const kind = text.slice(0, cut);
184
185
  const rest = text.slice(cut + 1);
185
186
  switch (kind) {
186
187
  case 'user':
187
188
  case 'character':
189
+ case 'seated-member':
188
190
  case 'player-seat':
189
191
  if (!ID.test(rest))
190
192
  throw new Error(`'${raw}' names a ${kind} with no readable id — a ${kind} reference is '${kind}:<id>'`);
@@ -195,7 +197,7 @@ export function parseParticipantRef(raw) {
195
197
  `the slug a letter or digit followed by letters, digits, '.', '_' or '-'`);
196
198
  return { kind, slug: rest };
197
199
  default:
198
- throw new Error(`'${raw}' is not a participant reference — '${kind}:' is not a kind (user, character, player-seat, envoy)`);
200
+ throw new Error(`'${raw}' is not a participant reference — '${kind}:' is not a kind (user, character, seated-member, player-seat, envoy)`);
199
201
  }
200
202
  }
201
203
  /** The one spelling a parsed reference has. `parse(format(x))` is `x`. @internal */
@@ -205,6 +207,8 @@ export function formatParticipantRef(parsed) {
205
207
  return `user:${parsed.id}`;
206
208
  case 'character':
207
209
  return `character:${parsed.id}`;
210
+ case 'seated-member':
211
+ return `seated-member:${parsed.id}`;
208
212
  case 'player-seat':
209
213
  return `player-seat:${parsed.id}`;
210
214
  case 'envoy':
@@ -121,7 +121,7 @@ export function renderPluginPermissionsGuide() {
121
121
  const keys = hookCtxKeysFor(k);
122
122
  lines.push(
123
123
  // GitHub's slug of "Kind: oracle" is `kind-oracle`, the anchor.
124
- `## Kind: ${k}`, '', KIND_ROLE[k], '', `- Handed: ${code(keys).join(', ')}.`, `- ${keys.includes('storage') ? "Storage: your plugin's own files, when it asks for storage (`permissions.storage`)." : 'No storage.'}`, `- ${keys.includes('package') ? "Package files: read-only, the files your plugin ships under `assets: { dir }` (`ctx.package.read`)." : 'No package files.'}`, `- ${keys.includes('annex') ? "The person's saved data: `ctx.annex('user')`, when your plugin holds `applet:annex:user` and a person is acting for the call; otherwise its methods reject." : "No saved data (`ctx.annex`) — a task is pure."}`, `- ${keys.includes('fetch') ? 'Network: only the hosts your plugin declares (`permissions.network.hosts`) and an admin left allowed.' : 'No network.'}`, '');
124
+ `## Kind: ${k}`, '', KIND_ROLE[k], '', `- Handed: ${code(keys).join(', ')}.`, `- ${keys.includes('storage') ? "Storage: your plugin's own files, when it asks for storage (`permissions.storage`)." : 'No storage.'}`, `- ${keys.includes('package') ? "Package files: read-only, the files your plugin ships under `assets: { dir }` (`ctx.package.read`)." : 'No package files.'}`, `- ${keys.includes('annex') ? "The person's saved data: `ctx.annex('user')`, when your plugin holds `applet:annex:user` and your own applet is open (a person's request or press in its mounted frame caused the call); an event or lifecycle hook, the schedule tick and a routine run find it closed, and its methods reject." : "No saved data (`ctx.annex`) — a task is pure."}`, `- ${keys.includes('fetch') ? 'Network: only the hosts your plugin declares (`permissions.network.hosts`) and an admin left allowed.' : 'No network.'}`, '');
125
125
  }
126
126
  lines.push('## Permission groups', '', 'A package asks for permissions in three groups, and the admin reviews and grants each group on its own. ' +
127
127
  'A grant is always bounded by the person acting.', '', '- **In a session** (`permissions.session`, or a widget\'s `scopes`): what a frame may do in the session it is mounted in.', '- **Outside a session, its applet** (`permissions.applet`, `permissions.storage.perUser`): what the package\'s applet may do with the person\'s library. A widget declaration may never ask for these, and `applet.sessions.genres` may name only the package\'s own genres.', '- **On this pub** (`permissions.storage`, `network`, `media`): the sandbox\'s own reach.', '', '| Key | Group | What it grants | Declared as |', '|---|---|---|---|', ...PERMISSION_KEY_ROWS.map((r) => `| \`${r.key}\` | ${r.group} | ${r.grants} | ${r.declaredAs} |`), '');