@serene-pub/sdk 0.6.0-pr-6 โ†’ 0.6.0-pr-7

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 (68) hide show
  1. package/dist/actions.d.ts +23 -0
  2. package/dist/actions.js +36 -1
  3. package/dist/annexFields.d.ts +28 -1
  4. package/dist/annexFields.js +47 -5
  5. package/dist/attributes.d.ts +50 -1
  6. package/dist/attributes.js +31 -0
  7. package/dist/builder.d.ts +2 -2
  8. package/dist/builder.js +2 -2
  9. package/dist/cadences.d.ts +7 -0
  10. package/dist/cadences.js +7 -0
  11. package/dist/capabilities.d.ts +13 -2
  12. package/dist/capabilities.js +28 -1
  13. package/dist/component.d.ts +5 -0
  14. package/dist/componentClient.d.ts +42 -6
  15. package/dist/componentWire.js +22 -4
  16. package/dist/declarations.d.ts +15 -0
  17. package/dist/declarations.js +29 -0
  18. package/dist/descriptors.d.ts +103 -2
  19. package/dist/descriptors.js +87 -5
  20. package/dist/events.d.ts +164 -0
  21. package/dist/events.js +67 -0
  22. package/dist/extension.d.ts +127 -3
  23. package/dist/extension.js +43 -0
  24. package/dist/genres.d.ts +20 -2
  25. package/dist/genres.js +40 -4
  26. package/dist/hookGrants.d.ts +14 -0
  27. package/dist/hookGrants.js +11 -10
  28. package/dist/hooks.d.ts +15 -2
  29. package/dist/hostElements.d.ts +1 -1
  30. package/dist/hostElements.js +8 -2
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.js +8 -0
  33. package/dist/jsonSchema.js +14 -2
  34. package/dist/libraryDraft.d.ts +27 -0
  35. package/dist/libraryDraft.js +25 -0
  36. package/dist/lorebookFile.d.ts +44 -0
  37. package/dist/lorebookFile.js +202 -0
  38. package/dist/pluginHarness.d.ts +50 -2
  39. package/dist/pluginHarness.js +65 -4
  40. package/dist/pluginPermissions.d.ts +15 -1
  41. package/dist/pluginPermissions.js +29 -2
  42. package/dist/receiverRules.js +9 -0
  43. package/dist/rulesetDocument.d.ts +21 -0
  44. package/dist/rulesetDocument.js +64 -2
  45. package/dist/rulesetSections.d.ts +37 -3
  46. package/dist/rulesetSections.js +47 -8
  47. package/dist/sessionDossier.d.ts +33 -0
  48. package/dist/settings.d.ts +74 -4
  49. package/dist/settings.js +293 -4
  50. package/dist/shapes.d.ts +40 -0
  51. package/dist/shapes.js +48 -1
  52. package/dist/speech.d.ts +333 -0
  53. package/dist/speech.js +199 -0
  54. package/dist/storage.d.ts +44 -0
  55. package/dist/storyTime.d.ts +25 -1
  56. package/dist/storyTime.js +42 -2
  57. package/dist/surfaces.d.ts +15 -2
  58. package/dist/template.d.ts +19 -1
  59. package/dist/template.js +25 -11
  60. package/dist/ties.d.ts +1 -0
  61. package/dist/ties.js +2 -1
  62. package/dist/userAnnex.d.ts +126 -0
  63. package/dist/userAnnex.js +214 -0
  64. package/dist/values.js +6 -0
  65. package/dist/widgets.d.ts +465 -8
  66. package/dist/widgets.js +198 -3
  67. package/host-elements.d.ts +5 -3
  68. package/package.json +1 -1
package/dist/actions.d.ts CHANGED
@@ -100,6 +100,25 @@ export interface CollectedText {
100
100
  * @ruling R-20
101
101
  */
102
102
  ifEmpty?: I18n;
103
+ /**
104
+ * Ready-made answers the modal offers as chips above the box; choosing one
105
+ * fills the box with its `value`. `common` ones show first, the rest sit
106
+ * behind a "More" disclosure. `icon` is a lucide kebab name. Display text.
107
+ */
108
+ suggestions?: Array<{
109
+ value: string;
110
+ label: I18n;
111
+ icon?: string;
112
+ common?: boolean;
113
+ }>;
114
+ /** `session`: the viewer's last answer to this action is remembered per session and offered next time. */
115
+ remember?: (typeof TEXT_REMEMBER)[number];
116
+ /**
117
+ * A one-line preview drawn under the box while it holds a value:
118
+ * `{subject}` is the first words of the message the action was pressed on,
119
+ * `{value}` the box's text. Display text.
120
+ */
121
+ preview?: I18n;
103
122
  }
104
123
  /**
105
124
  * The cast members an action collects before it fires: a multiselect over
@@ -165,6 +184,10 @@ export declare const CLOCK_STEP_MAX = 10000;
165
184
  * @experimental
166
185
  */
167
186
  export declare function clockStepRefusal(raw: unknown): string | null;
187
+ /** The most suggestions one collected text may offer. @experimental */
188
+ export declare const MAX_TEXT_SUGGESTIONS = 40;
189
+ /** Where a collected text's last value is remembered (per viewer). @experimental */
190
+ export declare const TEXT_REMEMBER: readonly ['session'];
168
191
  /**
169
192
  * The venues a `world` action may appear in: never a form, the extra tab or a
170
193
  * widget.
package/dist/actions.js CHANGED
@@ -95,7 +95,19 @@ export function clockStepRefusal(raw) {
95
95
  /** The keys `ActionDecl.collects` may carry, and each request's own keys. */
96
96
  const COLLECTS_KEYS = ['text', 'recipients', 'clockStep'];
97
97
  const COLLECTED_CLOCK_STEP_KEYS = ['label', 'default'];
98
- const COLLECTED_TEXT_KEYS = ['need', 'label', 'placeholder', 'ifEmpty'];
98
+ const COLLECTED_TEXT_KEYS = [
99
+ 'need',
100
+ 'label',
101
+ 'placeholder',
102
+ 'ifEmpty',
103
+ 'suggestions',
104
+ 'remember',
105
+ 'preview',
106
+ ];
107
+ /** The most suggestions one collected text may offer. @experimental */
108
+ export const MAX_TEXT_SUGGESTIONS = 40;
109
+ /** Where a collected text's last value is remembered (per viewer). @experimental */
110
+ export const TEXT_REMEMBER = ['session'];
99
111
  const COLLECTED_RECIPIENTS_KEYS = ['label', 'min', 'max', 'overwrites'];
100
112
  /**
101
113
  * The venues a `world` action may appear in: never a form, the extra tab or a
@@ -305,6 +317,29 @@ export function collectsFindings(raw, where) {
305
317
  `empty submit does ('The room decides.')`);
306
318
  else
307
319
  out.push(...i18nFindings(t.ifEmpty, `${at}.ifEmpty`));
320
+ out.push(...i18nFindings(t.preview, `${at}.preview`));
321
+ if (t.remember !== undefined && !TEXT_REMEMBER.includes(t.remember))
322
+ out.push(`${at}.remember is one of ${TEXT_REMEMBER.join(', ')} โ€” where the last answer is remembered`);
323
+ if (t.suggestions !== undefined) {
324
+ const sg = t.suggestions;
325
+ if (!Array.isArray(sg) || sg.length === 0 || sg.length > MAX_TEXT_SUGGESTIONS)
326
+ out.push(`${at}.suggestions is a list of 1 to ${MAX_TEXT_SUGGESTIONS} { value, label, icon?, common? }`);
327
+ else
328
+ sg.forEach((x, i) => {
329
+ const w = `${at}.suggestions[${i}]`;
330
+ if (!x || typeof x !== 'object' || Array.isArray(x))
331
+ return void out.push(`${w} is { value, label, icon?, common? }`);
332
+ const o = x;
333
+ unknownKeys(o, ['value', 'label', 'icon', 'common'], w);
334
+ if (typeof o.value !== 'string' || !o.value.trim())
335
+ out.push(`${w}.value is the text the chip fills in โ€” a non-empty string`);
336
+ out.push(...i18nFindings(o.label, `${w}.label`, { required: true }));
337
+ if (o.icon !== undefined && (typeof o.icon !== 'string' || !/^[a-z0-9]+(-[a-z0-9]+)*$/.test(o.icon)))
338
+ out.push(`${w}.icon is a lucide kebab name ('smile')`);
339
+ if (o.common !== undefined && typeof o.common !== 'boolean')
340
+ out.push(`${w}.common is a boolean`);
341
+ });
342
+ }
308
343
  }
309
344
  }
310
345
  if (c.recipients !== undefined) {
@@ -84,6 +84,22 @@ export interface AnnexFieldDecl {
84
84
  readonly act?: readonly string[];
85
85
  /** The genre id whose sessions offer it; absent is every session the package is on. */
86
86
  readonly genre?: string;
87
+ /**
88
+ * ๐Ÿšง Which annex holds the value (M0, SHAPES L9): `session` โ€” the
89
+ * **session annex**, as every field before; `lorebook` โ€” the **lorebook
90
+ * annex**, the book's own document under the same owner. Absent reads as
91
+ * `session`.
92
+ * ๐Ÿšง (M2b) `user` โ€” the **user annex**: the acting person's own documents
93
+ * under the same owner. A user-scoped field's `key` is an exact key
94
+ * (`profile`) or a family ending in `/` (`saves/` covers `saves/<anything>`);
95
+ * its `shape` applies to each document; `act`, `see` and `genre` are refused
96
+ * on it (only the person and the package reach those documents).
97
+ * โš  Not an attribute's `scope` (`session` | `world`, whether a stat
98
+ * survives sessions) โ€” the annex's own question, which document.
99
+ */
100
+ readonly scope?: 'session' | 'lorebook' | 'user';
101
+ /** ๐Ÿšง The value follows the player into the next chapter (M0, F5): a `next-chapter` session copies it. */
102
+ readonly nextChapter?: true;
87
103
  /** What a listing calls the action. Default: the key. */
88
104
  readonly label?: I18n;
89
105
  readonly description?: I18n;
@@ -98,6 +114,10 @@ export type AnnexFieldInput = {
98
114
  genre?: {
99
115
  readonly id: string;
100
116
  } | string;
117
+ /** ๐Ÿšง `session` (the default) or `lorebook` โ€” {@link AnnexFieldDecl.scope}. */
118
+ scope?: 'session' | 'lorebook' | 'user';
119
+ /** ๐Ÿšง The value follows the player into the next chapter โ€” {@link AnnexFieldDecl.nextChapter}. */
120
+ nextChapter?: true;
101
121
  label?: I18n;
102
122
  description?: I18n;
103
123
  };
@@ -159,11 +179,18 @@ export declare const annexOwners: () => string[];
159
179
  export declare const annexDeclarationOf: (owner: string) => readonly AnnexFieldDecl[] | undefined;
160
180
  /**
161
181
  * The fields of a declaration in force for a session of `genre`: every
162
- * unscoped field and the ones scoped to that genre. With no genre โ€” a
182
+ * unscoped field and the ones scoped to that genre (a `user`-scoped field
183
+ * never โ€” it lives in no session). With no genre โ€” a
163
184
  * document judged before it knows its session โ€” every field, whatever genre
164
185
  * it is scoped to. Pure. @experimental
165
186
  */
166
187
  export declare function annexFieldsInGenre(fields: readonly AnnexFieldDecl[], genre?: string): AnnexFieldDecl[];
188
+ /**
189
+ * ๐Ÿšง (M2b) The declared field covering a user annex key: the exact key first,
190
+ * then the longest family (`saves/`) that prefixes it. Only `scope: 'user'`
191
+ * fields are considered. Pure. @experimental
192
+ */
193
+ export declare function userAnnexFieldFor(fields: readonly AnnexFieldDecl[], key: string): AnnexFieldDecl | undefined;
167
194
  /** Whether a declared field may be set by a person, through its ready-made action. @experimental */
168
195
  export declare const isSettableAnnexField: (f: Pick<AnnexFieldDecl, 'act'>) => boolean;
169
196
  /**
@@ -53,6 +53,7 @@ import { dataAudienceFindings, isParticipantRef } from './participants.js';
53
53
  import { checkSchema, checkValues } from './settings.js';
54
54
  import { i18nFindings } from './i18n.js';
55
55
  import { isDataRef } from './refs.js';
56
+ import { userAnnexKeyRefusal } from './userAnnex.js';
56
57
  /** An annex field's key: a lowercase kebab token, the second half of its action identity. @experimental */
57
58
  export const ANNEX_FIELD_KEY = /^[a-z][a-z0-9-]*$/;
58
59
  /**
@@ -88,7 +89,13 @@ export function annexFieldFindings(raw, at = 'annexFields') {
88
89
  const f = raw;
89
90
  const where = `${at}[${typeof f.key === 'string' ? f.key : '?'}]`;
90
91
  const out = [];
91
- if (typeof f.key !== 'string' || !ANNEX_FIELD_KEY.test(f.key))
92
+ if (f.scope === 'user') {
93
+ const bare = typeof f.key === 'string' && f.key.endsWith('/') ? f.key.slice(0, -1) : f.key;
94
+ const why = userAnnexKeyRefusal(bare);
95
+ if (why)
96
+ out.push(`${where}: ${why} A user-scoped field's key is an exact key ('profile') or a family ending in '/' ('saves/').`);
97
+ }
98
+ else if (typeof f.key !== 'string' || !ANNEX_FIELD_KEY.test(f.key))
92
99
  out.push(`${where}: 'key' is a lowercase kebab token (${ANNEX_FIELD_KEY.source}) โ€” the field sits in ` +
93
100
  `your own package's annex document, so it never names an owner`);
94
101
  const shape = f.shape;
@@ -98,13 +105,23 @@ export function annexFieldFindings(raw, at = 'annexFields') {
98
105
  out.push(`${where}: the shape holds a secret โ€” the annex never keeps credentials or personal data ` +
99
106
  `(R61); keep a secret in plugin settings`);
100
107
  else
101
- for (const finding of checkSchema({ [String(f.key)]: shape }))
108
+ for (const finding of checkSchema({ [f.scope === 'user' ? 'value' : String(f.key)]: shape }))
102
109
  if (finding.severity === 'error')
103
110
  out.push(`${where}: ${finding.message} โ€” ${finding.fix}`);
104
111
  const see = dataAudienceFindings(f.see);
105
112
  if (see)
106
113
  out.push(`${where}.see: ${see}`);
107
- if (f.act !== undefined) {
114
+ if (f.scope === 'user') {
115
+ if (f.act !== undefined)
116
+ out.push(`${where}.act: a user-scoped field has no 'act' โ€” only the person and the package reach a user annex document, and no widget press sets one`);
117
+ if (f.see !== undefined && !(Array.isArray(f.see) && f.see.length === 0))
118
+ out.push(`${where}.see: a user-scoped field has no 'see' โ€” only the person and the package reach a user annex document`);
119
+ if (f.genre !== undefined)
120
+ out.push(`${where}.genre: a user-scoped field is not bound to a genre โ€” a person's documents follow them across sessions`);
121
+ if (f.nextChapter !== undefined)
122
+ out.push(`${where}.nextChapter: a user-scoped field is not part of a session, so nothing follows into a chapter`);
123
+ }
124
+ if (f.act !== undefined && f.scope !== 'user') {
108
125
  if (!Array.isArray(f.act) || !f.act.length)
109
126
  out.push(`${where}.act: a non-empty list of participant references โ€” who may set the value`);
110
127
  else
@@ -120,6 +137,11 @@ export function annexFieldFindings(raw, at = 'annexFields') {
120
137
  if (typeof g !== 'string' || !/^[a-z0-9.-]+:genre\/[a-z0-9.-]+/.test(g))
121
138
  out.push(`${where}.genre: a genre โ€” the value genre() returned, or its id ('acme.dice:genre/table')`);
122
139
  }
140
+ if (f.scope !== undefined && f.scope !== 'session' && f.scope !== 'lorebook' && f.scope !== 'user')
141
+ out.push(`${where}.scope: 'session' (the session annex, the default), 'lorebook' (the lorebook annex) or 'user' (the user annex) โ€” ` +
142
+ `'${String(f.scope)}' is neither`);
143
+ if (f.nextChapter !== undefined && f.nextChapter !== true)
144
+ out.push(`${where}.nextChapter: true or absent โ€” the value follows the player into the next chapter`);
123
145
  out.push(...i18nFindings(f.label, `${where}.label`));
124
146
  out.push(...i18nFindings(f.description, `${where}.description`));
125
147
  return out;
@@ -141,6 +163,8 @@ export function annexField(d) {
141
163
  see: Object.freeze([...(d.see ?? [])]),
142
164
  ...(d.act !== undefined ? { act: Object.freeze([...d.act]) } : {}),
143
165
  ...(d.genre !== undefined ? { genre: typeof d.genre === 'string' ? d.genre : d.genre.id } : {}),
166
+ ...(d.scope !== undefined ? { scope: d.scope } : {}),
167
+ ...(d.nextChapter !== undefined ? { nextChapter: d.nextChapter } : {}),
144
168
  ...(d.label !== undefined ? { label: d.label } : {}),
145
169
  ...(d.description !== undefined ? { description: d.description } : {}),
146
170
  });
@@ -246,12 +270,30 @@ export const annexOwners = () => [...declarations.keys()];
246
270
  export const annexDeclarationOf = (owner) => declarations.get(owner);
247
271
  /**
248
272
  * The fields of a declaration in force for a session of `genre`: every
249
- * unscoped field and the ones scoped to that genre. With no genre โ€” a
273
+ * unscoped field and the ones scoped to that genre (a `user`-scoped field
274
+ * never โ€” it lives in no session). With no genre โ€” a
250
275
  * document judged before it knows its session โ€” every field, whatever genre
251
276
  * it is scoped to. Pure. @experimental
252
277
  */
253
278
  export function annexFieldsInGenre(fields, genre) {
254
- return fields.filter((f) => f.genre === undefined || genre === undefined || f.genre === genre);
279
+ return fields.filter((f) => f.scope !== 'user' && (f.genre === undefined || genre === undefined || f.genre === genre));
280
+ }
281
+ /**
282
+ * ๐Ÿšง (M2b) The declared field covering a user annex key: the exact key first,
283
+ * then the longest family (`saves/`) that prefixes it. Only `scope: 'user'`
284
+ * fields are considered. Pure. @experimental
285
+ */
286
+ export function userAnnexFieldFor(fields, key) {
287
+ const user = fields.filter((f) => f.scope === 'user');
288
+ const exact = user.find((f) => f.key === key);
289
+ if (exact)
290
+ return exact;
291
+ let best;
292
+ for (const f of user)
293
+ if (f.key.endsWith('/') && key.startsWith(f.key) && key.length > f.key.length)
294
+ if (!best || f.key.length > best.key.length)
295
+ best = f;
296
+ return best;
255
297
  }
256
298
  /** Whether a declared field may be set by a person, through its ready-made action. @experimental */
257
299
  export const isSettableAnnexField = (f) => !!f.act?.length;
@@ -161,6 +161,33 @@ export declare const derivations: Readonly<{
161
161
  requiresFrom: false;
162
162
  description: "A LiquidJS expression on the declaration, evaluated over the state pinned at run start.";
163
163
  }>;
164
+ /**
165
+ * The clock's part of the day, by the book's own calendar `periods` (default
166
+ * morning 5 ยท day 12 ยท dusk 18 ยท night 22). Absent when the clock has no hour.
167
+ */
168
+ readonly dayPeriod: Readonly<{
169
+ id: "core:derive/day-period@1";
170
+ requiresFrom: false;
171
+ description: "The part of the day the story clock is in, by the calendar's periods.";
172
+ }>;
173
+ /**
174
+ * The clock's season, by the book's own calendar `seasons`. Absent without
175
+ * seasons, months, or a clock with a month and day.
176
+ */
177
+ readonly season: Readonly<{
178
+ id: "core:derive/season@1";
179
+ requiresFrom: false;
180
+ description: "The season the story clock is in, by the calendar's seasons.";
181
+ }>;
182
+ /**
183
+ * The clock's part of the day over the default periods always (morning, day,
184
+ * dusk, night), whatever the calendar declares.
185
+ */
186
+ readonly timeOfDay: Readonly<{
187
+ id: "core:derive/time-of-day@1";
188
+ requiresFrom: false;
189
+ description: "The default part of the day (morning, day, dusk, night) the story clock is in.";
190
+ }>;
164
191
  }>;
165
192
  /** @experimental */
166
193
  export type DerivationId = (typeof derivations)[keyof typeof derivations]['id'];
@@ -216,7 +243,14 @@ export interface SlotConfig {
216
243
  * holds words and lore references only.
217
244
  */
218
245
  repertoire?: string;
219
- /** `derived`: which computation, and the slot it reads. */
246
+ /**
247
+ * `derived`: which computation, and the slot it reads.
248
+ *
249
+ * ๐Ÿšง On a slot that is NOT `derived` it names the slot's **derived default**:
250
+ * the reading a read uses when no layer holds a value, before the
251
+ * declaration's `default`. A hand write wins. Read order: layers, derived
252
+ * default, declaration default.
253
+ */
220
254
  derivation?: string;
221
255
  from?: SlotId;
222
256
  [key: string]: unknown;
@@ -481,6 +515,21 @@ export interface AttributeSlotProps {
481
515
  descriptor: string;
482
516
  /** Which owner kinds may carry it. */
483
517
  appliesTo: readonly SlotAppliesTo[];
518
+ /**
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,
522
+ * dated on its timeline (`lorebook`, `cast_member`, `location`). Absent:
523
+ * `session`. A ruleset attribute's `scope` lands here. The player's own
524
+ * (`owner: 'player'` on a ruleset attribute) is a `cast` slot read on the
525
+ * player's seat. Declared only until lane T3.
526
+ */
527
+ scope?: 'session' | 'world';
528
+ /**
529
+ * ๐Ÿšง This follows the player into the next chapter: a `next-chapter`
530
+ * session seeds its value from the session it follows (M0, F5).
531
+ */
532
+ nextChapter?: true;
484
533
  /** The base configuration every attachment starts from. */
485
534
  config?: SlotConfig;
486
535
  /** The value a read falls back to when no layer has one. */
@@ -169,6 +169,33 @@ export const derivations = Object.freeze({
169
169
  requiresFrom: false,
170
170
  description: 'A LiquidJS expression on the declaration, evaluated over the state pinned at run start.',
171
171
  }),
172
+ /**
173
+ * The clock's part of the day, by the book's own calendar `periods` (default
174
+ * morning 5 ยท day 12 ยท dusk 18 ยท night 22). Absent when the clock has no hour.
175
+ */
176
+ dayPeriod: Object.freeze({
177
+ id: 'core:derive/day-period@1',
178
+ requiresFrom: false,
179
+ description: "The part of the day the story clock is in, by the calendar's periods.",
180
+ }),
181
+ /**
182
+ * The clock's season, by the book's own calendar `seasons`. Absent without
183
+ * seasons, months, or a clock with a month and day.
184
+ */
185
+ season: Object.freeze({
186
+ id: 'core:derive/season@1',
187
+ requiresFrom: false,
188
+ description: "The season the story clock is in, by the calendar's seasons.",
189
+ }),
190
+ /**
191
+ * The clock's part of the day over the default periods always (morning, day,
192
+ * dusk, night), whatever the calendar declares.
193
+ */
194
+ timeOfDay: Object.freeze({
195
+ id: 'core:derive/time-of-day@1',
196
+ requiresFrom: false,
197
+ description: "The default part of the day (morning, day, dusk, night) the story clock is in.",
198
+ }),
172
199
  });
173
200
  /** @experimental */
174
201
  export const getDerivation = (id) => Object.values(derivations).find((d) => d.id === id);
@@ -841,6 +868,10 @@ function checkSlotDeclaration(id, props) {
841
868
  if (!props.appliesTo?.length)
842
869
  throw new Error(`${id} declares no appliesTo. Say whether it attaches to 'cast', to 'world', to ` +
843
870
  `'location', or to several โ€” a slot nothing may carry can never hold a value.`);
871
+ if (props.scope !== undefined && props.scope !== 'session' && props.scope !== 'world')
872
+ throw new Error(`${id} declares scope '${String(props.scope)}'. Say 'session' โ€” its values end with the session โ€” or 'world' โ€” they live on the book.`);
873
+ if (props.nextChapter !== undefined && props.nextChapter !== true)
874
+ throw new Error(`${id}: \`nextChapter\` is true or absent โ€” the value follows the player into the next chapter.`);
844
875
  if (props.type === 'enum' && !(props.config?.of ?? fieldSlotConfig(slotField(props)).of)?.length)
845
876
  throw new Error(`${id} is an enum with no options. Declare config.of โ€” the closed set is what ` +
846
877
  `makes it a chip rather than a text field.`);
package/dist/builder.d.ts CHANGED
@@ -805,7 +805,7 @@ export declare class PresetBuilder<Nodes extends Record<string, PortDecl> = {}>
805
805
  prompts(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
806
806
  /** A template **and its engine** โ€” the engine travels on the value (src/engines.ts). */
807
807
  template(nodeKey: keyof Nodes & string, value: TemplateValue): this;
808
- /** Generation parameters: a reference to a named config, or field overrides on top. */
808
+ /** Generation parameters: a reference to a named config, `{ seedKey }`. */
809
809
  sampling(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
810
810
  /** Node toggles and the review position. */
811
811
  settings(nodeKey: keyof Nodes & string, value: Record<string, unknown>): this;
@@ -881,7 +881,7 @@ export declare class SpecBuilder<Nodes extends Record<string, PortDecl> = {}, A
881
881
  * ```ts
882
882
  * .defaults((d) => d
883
883
  * .prompts('generate', { system: STORY_SYSTEM })
884
- * .sampling('generate', slot.sampling('core:sampling/story')))
884
+ * .sampling('generate', { seedKey: 'sampling-default' }))
885
885
  * ```
886
886
  * Stored where the shipped default author preset always was
887
887
  * (`presets[slug: 'default', default: true]`), so a host reading that
package/dist/builder.js CHANGED
@@ -528,7 +528,7 @@ export class PresetBuilder {
528
528
  template(nodeKey, value) {
529
529
  return this.set(nodeKey, 'template', value);
530
530
  }
531
- /** Generation parameters: a reference to a named config, or field overrides on top. */
531
+ /** Generation parameters: a reference to a named config, `{ seedKey }`. */
532
532
  sampling(nodeKey, value) {
533
533
  return this.set(nodeKey, 'sampling', value);
534
534
  }
@@ -694,7 +694,7 @@ export class SpecBuilder extends ChainBuilder {
694
694
  * ```ts
695
695
  * .defaults((d) => d
696
696
  * .prompts('generate', { system: STORY_SYSTEM })
697
- * .sampling('generate', slot.sampling('core:sampling/story')))
697
+ * .sampling('generate', { seedKey: 'sampling-default' }))
698
698
  * ```
699
699
  * Stored where the shipped default author preset always was
700
700
  * (`presets[slug: 'default', default: true]`), so a host reading that
@@ -431,6 +431,13 @@ export declare const timelineCron: (o: {
431
431
  unit: StoryTimeUnit;
432
432
  maxJump?: CadenceSpan;
433
433
  }) => CadenceRef;
434
+ /**
435
+ * ๐Ÿšง Once each story day (M0, SHAPES L3): `timelineCron({ every: 1,
436
+ * unit: 'days' })` by name โ€” what the weather routine and a nightly diary
437
+ * run on. A helper over the Timeline Cron, not a cadence of its own.
438
+ * @experimental
439
+ */
440
+ export declare const afterEachDay: () => CadenceRef;
434
441
  /** At set moments on the system clock or the story calendar (R20). @experimental */
435
442
  export declare const schedule: (o: {
436
443
  clock: 'system' | 'story';
package/dist/cadences.js CHANGED
@@ -723,6 +723,13 @@ export const timelineCron = (o) => freezeRef(TIMELINE_CRON.id, {
723
723
  unit: o?.unit,
724
724
  ...(o?.maxJump ? { maxJump: { ...o.maxJump } } : {}),
725
725
  });
726
+ /**
727
+ * ๐Ÿšง Once each story day (M0, SHAPES L3): `timelineCron({ every: 1,
728
+ * unit: 'days' })` by name โ€” what the weather routine and a nightly diary
729
+ * run on. A helper over the Timeline Cron, not a cadence of its own.
730
+ * @experimental
731
+ */
732
+ export const afterEachDay = () => timelineCron({ every: 1, unit: 'days' });
726
733
  /** At set moments on the system clock or the story calendar (R20). @experimental */
727
734
  export const schedule = (o) => freezeRef(SCHEDULE.id, {
728
735
  clock: o?.clock,
@@ -414,7 +414,18 @@ export declare const FEATURES: readonly ['json_object', 'json_schema', 'strict_s
414
414
  * starts a new reply, the join then glues two beginnings together, and nothing
415
415
  * reports it. A connection that can only do that does not hold this.
416
416
  */
417
- 'continue_reply', 'wire_chat', 'wire_completion'];
417
+ 'continue_reply', 'wire_chat', 'wire_completion',
418
+ /**
419
+ * ๐Ÿšง Speech arrives while it is still being made (PLAN-speech-build S3,
420
+ * 2026-10-28) โ€” the first words play before the last are rendered. Banded
421
+ * (`BANDS.audio_streaming`): `native` โ€” the service streams audio itself;
422
+ * `emulated` โ€” it does not, and the HOST streams by splitting the line at its
423
+ * cue groups (`core:oracle/speak@1` makes one call per group anyway), handing
424
+ * each group's audio on as it lands; `none` โ€” one whole file, after the last
425
+ * group. โš  Not `streaming`: that one is TEXT arriving token by token.
426
+ * Phase 1 records it and plays whole files (build assumption A5).
427
+ */
428
+ 'audio_streaming'];
418
429
  /** ๐Ÿšง A feature core knows by name โ€” one of `FEATURES`, the KNOWN list. @experimental */
419
430
  export type KnownFeatureId = (typeof FEATURES)[number];
420
431
  /**
@@ -507,7 +518,7 @@ export declare const BAND_ORDER: readonly ["none", "emulated", "native"];
507
518
  * grade correctly: a plugin introduces a transform, and it is binary until
508
519
  * somebody says otherwise.
509
520
  *
510
- * The three listed here are exactly the keys of `EMULATABLE_VIA`, and that is
521
+ * The bands listed here are exactly the keys of `EMULATABLE_VIA`, and that is
511
522
  * not a coincidence. An `emulated` band exists precisely where Serene Pub can
512
523
  * supply the capability itself over a backend that cannot, which is what that
513
524
  * table records. `closure` raises through `gradeOf(id, BAND.emulated)`, so a
@@ -307,6 +307,17 @@ export const FEATURES = [
307
307
  'continue_reply',
308
308
  'wire_chat',
309
309
  'wire_completion',
310
+ /**
311
+ * ๐Ÿšง Speech arrives while it is still being made (PLAN-speech-build S3,
312
+ * 2026-10-28) โ€” the first words play before the last are rendered. Banded
313
+ * (`BANDS.audio_streaming`): `native` โ€” the service streams audio itself;
314
+ * `emulated` โ€” it does not, and the HOST streams by splitting the line at its
315
+ * cue groups (`core:oracle/speak@1` makes one call per group anyway), handing
316
+ * each group's audio on as it lands; `none` โ€” one whole file, after the last
317
+ * group. โš  Not `streaming`: that one is TEXT arriving token by token.
318
+ * Phase 1 records it and plays whole files (build assumption A5).
319
+ */
320
+ 'audio_streaming',
310
321
  ];
311
322
  /** Transforms contain `->`; features never do. The two spaces cannot collide. @internal */
312
323
  export const isTransformId = (id) => id.includes('->');
@@ -336,6 +347,13 @@ export const EMULATABLE_VIA = {
336
347
  json_object: ['json_schema', 'grammar'],
337
348
  json_schema: ['grammar'],
338
349
  tools: ['json_schema', 'grammar'],
350
+ /**
351
+ * ๐Ÿšง Emulated by core itself, via no backend feature (โ˜…A2, lane V
352
+ * 2026-10-28): the host splits a line at its cue groups. Empty, so
353
+ * `closure` never raises it โ€” an adapter declares `emulated` directly โ€” and
354
+ * the rule "only EMULATABLE_VIA keys have an emulated band" still holds.
355
+ */
356
+ audio_streaming: [],
339
357
  };
340
358
  /**
341
359
  * The band names core knows: what a grade MEANS, once you know the capability.
@@ -370,7 +388,7 @@ export const BAND_ORDER = [BAND.none, BAND.emulated, BAND.native];
370
388
  * grade correctly: a plugin introduces a transform, and it is binary until
371
389
  * somebody says otherwise.
372
390
  *
373
- * The three listed here are exactly the keys of `EMULATABLE_VIA`, and that is
391
+ * The bands listed here are exactly the keys of `EMULATABLE_VIA`, and that is
374
392
  * not a coincidence. An `emulated` band exists precisely where Serene Pub can
375
393
  * supply the capability itself over a backend that cannot, which is what that
376
394
  * table records. `closure` raises through `gradeOf(id, BAND.emulated)`, so a
@@ -382,6 +400,13 @@ export const BANDS = {
382
400
  json_object: [BAND.none, BAND.emulated, BAND.native],
383
401
  json_schema: [BAND.none, BAND.emulated, BAND.native],
384
402
  tools: [BAND.none, BAND.emulated, BAND.native],
403
+ /**
404
+ * ๐Ÿšง Its `EMULATABLE_VIA` entry is EMPTY, deliberately: its `emulated`
405
+ * band is supplied by the host splitting a line at its cue groups, which
406
+ * needs no other feature of the backend โ€” so an adapter declares
407
+ * `emulated` directly rather than having `closure` raise it.
408
+ */
409
+ audio_streaming: [BAND.none, BAND.emulated, BAND.native],
385
410
  };
386
411
  /** A capability nobody gave bands: it either works or it does not. @experimental */
387
412
  export const DEFAULT_BANDS = [BAND.none, BAND.native];
@@ -697,6 +722,8 @@ const FEATURE_LABELS = {
697
722
  // completion is that the model is handed one formatted string.
698
723
  wire_chat: 'Chat messages',
699
724
  wire_completion: 'Text completion',
725
+ // ๐Ÿšง The user's word: speech starts playing before the whole line is made.
726
+ audio_streaming: 'Streaming speech',
700
727
  };
701
728
  /**
702
729
  * What to show a person for a capability id.
@@ -47,4 +47,9 @@ export type { AttendanceV1, AttendeeV1, AuthorsNoteV1, AuthorsNoteValueV1, Histo
47
47
  export type { StoryTime, StoryTimeUnit } from './storyTime.js';
48
48
  /** The conversation dossier โ€” `session_full.v1`, for a widget granted `session:full`. */
49
49
  export type { SessionDossierV1 } from './sessionDossier.js';
50
+ /**
51
+ * ๐Ÿšง What a spoken line carries โ€” the S6 record core's messages widget reads
52
+ * under a line that was spoken (speech build, lane V 2026-10-28).
53
+ */
54
+ export type { CueMap, Inflection, SpokenAs, SpokenMeta, SpokenVoiceFrom } from './speech.js';
50
55
  //# sourceMappingURL=component.d.ts.map
@@ -18,7 +18,7 @@
18
18
  * vocabulary page, `guides/vocabulary.md`.
19
19
  * @ruling ยง3.5, C3
20
20
  */
21
- import type { MessageV1, WidgetBaseSection, WidgetData, WidgetEvent, WidgetRequestKind, WidgetRequests, WidgetScopedSections, WidgetScopedSectionValues, WidgetSectionScope, WidgetWriteGrant } from './widgets.js';
21
+ import type { AppletGrant, AppletRequestKind, MessageV1, SessionRequestKind, UiRequestKind, WidgetBaseSection, WidgetData, WidgetEvent, WidgetRequestKind, WidgetRequests, WidgetScopedSections, WidgetScopedSectionValues, WidgetSectionScope, WidgetWriteGrant } from './widgets.js';
22
22
  /**
23
23
  * Every base section of the envelope ({@link WidgetData}) but `channels`,
24
24
  * flat: the section's current version, `undefined` until the host posts it.
@@ -66,7 +66,7 @@ export interface ComponentSections extends ComponentBaseSections {
66
66
  * grant ({@link WidgetWriteGrant}) pushes no section of its own. Read one
67
67
  * with {@link ComponentContext.granted}.
68
68
  */
69
- grants?: readonly (WidgetSectionScope | WidgetWriteGrant)[];
69
+ grants?: readonly (WidgetSectionScope | WidgetWriteGrant | AppletGrant)[];
70
70
  /** The view state this widget saved last time, handed back once on mount. */
71
71
  state?: unknown;
72
72
  suspended: boolean;
@@ -87,8 +87,15 @@ export interface ComponentContext extends Readonly<ComponentSections> {
87
87
  subscribe(fn: (section: ComponentSection) => void): () => void;
88
88
  /** Widget events (`message:created`, `layout:changed`, โ€ฆ). */
89
89
  onEvent(fn: (event: WidgetEvent) => void): () => void;
90
- /** Press an action by key or identity, as the native `invoke` verb does. */
91
- invoke(key: string, args?: ComponentInvokeArgs): void;
90
+ /**
91
+ * Press an action by key or identity, as the native `invoke` verb does (the `session` API). Resolves โ€” never
92
+ * rejects โ€” when the host answers (M2b): for a session action when its run ENDS, `{ ok: true, result }` with a
93
+ * {@link WidgetInvokeResult} (`{ runId }`, or `{ runId, halted: true, reason }`), or `{ ok: false, error }` when it
94
+ * errored, was refused before any run (`'Wait for the reply to finish.'`) or was stopped (`'cancelled'`); a core
95
+ * verb, and a press that asks the person first, `{ ok: true }` at once; one of the package's own `pluginActions`,
96
+ * its handler's `out.main` as `result`. Every run's end also reaches every widget as the `run:ended` event.
97
+ */
98
+ invoke(key: string, args?: ComponentInvokeArgs): Promise<ComponentInvokeAnswer>;
92
99
  /**
93
100
  * โณ Fire a function by name โ€” a form block's press, whose identity the
94
101
  * outlet stamped and no venue need list (the native `action` verb).
@@ -104,8 +111,11 @@ export interface ComponentContext extends Readonly<ComponentSections> {
104
111
  * ๐Ÿšง The viewer's translation of one of the component's own English
105
112
  * strings โ€” the source until a translation arrives, when `subscribe` hears
106
113
  * `strings` and a redraw shows it.
114
+ * Precedence: the plugin's own catalog (`lang/<locale>.json`), then the app's
115
+ * translation, then the English source. `{0}`โ€ฆ`{n}` in the text are filled
116
+ * from `args` afterwards (a missing argument leaves `{n}` as written).
107
117
  */
108
- t(source: string): string;
118
+ t(source: string, ...args: ReadonlyArray<string | number>): string;
109
119
  /**
110
120
  * ๐Ÿšง Was `scope` โ€” or a write grant, `session:state:write`,
111
121
  * `channel:<slug>:write` โ€” granted? `true` or `false` once the host has
@@ -114,7 +124,7 @@ export interface ComponentContext extends Readonly<ComponentSections> {
114
124
  * A widget that asks `send`, `draft` or `set-attribute-value` checks its
115
125
  * write grant here before it offers the button.
116
126
  */
117
- granted(scope: WidgetSectionScope | WidgetWriteGrant): boolean | undefined;
127
+ granted(scope: WidgetSectionScope | WidgetWriteGrant | AppletGrant): boolean | undefined;
118
128
  /**
119
129
  * ๐Ÿšง The section a granted scope delivers, by the same string `scopes`
120
130
  * and `granted` take: `ctx.scope('session:state')` is the session's
@@ -124,6 +134,32 @@ export interface ComponentContext extends Readonly<ComponentSections> {
124
134
  */
125
135
  scope<S extends WidgetSectionScope>(scope: S): WidgetScopedSectionValues[WidgetScopedSections[S]['section']] | undefined;
126
136
  }
137
+ /** ๐Ÿšง What a component's `invoke` resolves to (M2b): the host's answer, never a rejection. @experimental */
138
+ export type ComponentInvokeAnswer = {
139
+ ok: true;
140
+ result?: unknown;
141
+ } | {
142
+ ok: false;
143
+ error: string;
144
+ };
145
+ /**
146
+ * ๐Ÿšง The component's members by **front-end API** (M2b, {@link FrontEndApi}) โ€” the same three groups as the frame
147
+ * protocol and the request kinds ({@link WIDGET_REQUEST_APIS}). A widget placed in a session's layout holds `ui` +
148
+ * `session`; an applet holds `ui` + `applet`, and `session` while mounted in one. `request` takes any kind and the
149
+ * host refuses one outside the mount's APIs, in words; these types say which kinds are whose.
150
+ * @experimental
151
+ */
152
+ export type ComponentUiApi = Pick<ComponentContext, 'subscribe' | 'onEvent' | 'saveState' | 'error' | 't' | 'granted' | 'theme' | 'locale' | 'viewer' | 'props' | 'settings' | 'layout'> & {
153
+ request<K extends UiRequestKind>(kind: K, params: WidgetRequests[K]['params']): Promise<WidgetRequests[K]['result']>;
154
+ };
155
+ /** ๐Ÿšง The `session` API of a component: the mounted session's sections, verbs and requests. @experimental */
156
+ export type ComponentSessionApi = Pick<ComponentContext, 'session' | 'channels' | 'messages' | 'actions' | 'annex' | 'turnOrder' | 'attendance' | 'scoped' | 'scope' | 'invoke' | 'action'> & {
157
+ request<K extends SessionRequestKind>(kind: K, params: WidgetRequests[K]['params']): Promise<WidgetRequests[K]['result']>;
158
+ };
159
+ /** ๐Ÿšง The `applet` API of a component: the person's library and the pub, by request. @experimental */
160
+ export type ComponentAppletApi = {
161
+ request<K extends AppletRequestKind>(kind: K, params: WidgetRequests[K]['params']): Promise<WidgetRequests[K]['result']>;
162
+ };
127
163
  /** What a component module exports: mount into `root`; return a cleanup. @experimental */
128
164
  export type ComponentMountFn = (root: HTMLElement, ctx: ComponentContext) => void | (() => void);
129
165
  /** Types a component's mount function; returns it unchanged. @experimental */