@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/events.js CHANGED
@@ -378,6 +378,34 @@ export const CORE_EVENTS = {
378
378
  payload: S.sessionChange,
379
379
  description: 'A message finished landing โ€” a send, a seeded greeting, a finished or stopped reply. Never a placeholder or a row still being written.',
380
380
  }),
381
+ /**
382
+ * ๐Ÿšง **Message settled** (speech follow-ups, A1, 2026-10-29): ONE per line
383
+ * a run wrote, emitted by core after that run closed its receipt โ€” the
384
+ * moment work that must never hold the line (reading it aloud) may start,
385
+ * as its own run.
386
+ *
387
+ * โš  Not `message-completed@1`, which fires per WRITE, during the run (a
388
+ * send, a seeded greeting, a finished or stopped reply). And not the
389
+ * session's **settle line** / `history-settled@1` (history fixed, Back no
390
+ * longer reaches it): always the qualified "message settled", never bare
391
+ * "settled". The payload is `MessageSettledPayload`.
392
+ *
393
+ * Off the ledger: it describes no write of its own (the line is already on
394
+ * record through `message-completed`), and a ledger row would reach every
395
+ * next reply's `sessionChanges` once per line saying nothing new. A
396
+ * declared root โ€” no outlet causes it, so no spec bound here can loop on it.
397
+ */
398
+ messageSettled: defineEvent({
399
+ slug: 'message-settled',
400
+ declaredRoot: true,
401
+ name: { en: 'Message settled' },
402
+ version: 1,
403
+ family: 'data',
404
+ carries: ['session', 'message'],
405
+ affectsUser: false,
406
+ payload: S.messageSettled,
407
+ description: 'A line a run wrote is settled: the run that wrote it has closed its receipt, so work that must not hold the line (reading it aloud) may start. One per line.',
408
+ }),
381
409
  /**
382
410
  * A seated participant's row changed โ€” switched on or off (`active`),
383
411
  * `position` or portrayal. Not add or remove: those stay
@@ -458,6 +486,45 @@ export const CORE_EVENTS = {
458
486
  payload: S.annexChange,
459
487
  description: "A pipeline's own session state changed โ€” its annex entry. The payload names the owner whose entry moved.",
460
488
  }),
489
+ /**
490
+ * ๐Ÿšง The session's rules were moved to another version of their ruleset
491
+ * (M0, SHAPES L4 Conversion), by `core:outlet/convert-ruleset@1` or
492
+ * the `sessions:convertRuleset` socket. The payload
493
+ * (`RulesetConversionPayload`) names the ruleset, both versions and what
494
+ * happened to the slots. Declared only until lane T4 emits it.
495
+ */
496
+ rulesetConverted: defineEvent({
497
+ slug: 'ruleset-converted',
498
+ name: { en: 'Ruleset converted' },
499
+ version: 1,
500
+ family: 'data',
501
+ carries: ['session'],
502
+ affectsUser: true,
503
+ causedBy: ['core:outlet/convert-ruleset'],
504
+ payload: S.rulesetConversion,
505
+ description: "The session's rules moved to another version of their ruleset: renamed slots re-keyed, removed ones retracted, added ones given their defaults.",
506
+ }),
507
+ /**
508
+ * ๐Ÿšง A **lorebook annex** document changed (M0, SHAPES L9): the
509
+ * lorebook twin of `annex-changed`, caused by
510
+ * `core:outlet/set-lorebook-annex@1` and
511
+ * `core:outlet/set-lorebook-annex-field@1`. The payload
512
+ * (`LorebookAnnexChangePayload`) names the book, the owner and the keys
513
+ * that moved, never the values.
514
+ * โš  Not `annex-changed`, which is the session annex's.
515
+ */
516
+ lorebookAnnexChanged: defineEvent({
517
+ slug: 'lorebook-annex-changed',
518
+ name: { en: 'Lorebook annex changed' },
519
+ version: 1,
520
+ family: 'data',
521
+ // A lorebook is not a session entity: the payload names the book, so nothing is carried.
522
+ carries: [],
523
+ affectsUser: true,
524
+ causedBy: ['core:outlet/set-lorebook-annex', 'core:outlet/set-lorebook-annex-field'],
525
+ payload: S.lorebookAnnexChange,
526
+ description: "An owner's document in a lorebook's annex changed. The payload names the book, the owner and the keys that moved.",
527
+ }),
461
528
  /**
462
529
  * ๐Ÿšง The session's **backdrop** changed: a pipeline set it through
463
530
  * `core:outlet/set-backdrop@1`, or a person set or cleared it from the
@@ -22,7 +22,7 @@
22
22
  * of what a plugin can do, or the permission model is a guess.
23
23
  * @ruling 03, 09, D-1, F6, 03 ยง3, 13/ยง30
24
24
  */
25
- import type { WidgetDecl } from './layout.js';
25
+ import type { WidgetDecl, WidgetScope } from './layout.js';
26
26
  import type { BuiltSpec } from './builder.js';
27
27
  import type { Descriptor } from './descriptors.js';
28
28
  import type { PluginSettings, SettingsSchema } from './settings.js';
@@ -38,6 +38,7 @@ import { type EventDeclarationInput, type StoredEventDeclaration, type ConfigDec
38
38
  import type { GenreDecl } from './genres.js';
39
39
  import { type AnnexFieldDecl } from './annexFields.js';
40
40
  import type { SurfacesDecl } from './surfaces.js';
41
+ import type { RulesetDocument } from './rulesetDocument.js';
41
42
  import { type VariableDecl } from './variables.js';
42
43
  import { type StoredSwapContribution, type SwapContribution } from './declarations.js';
43
44
  /**
@@ -185,8 +186,9 @@ export type ComponentFramework = (typeof COMPONENT_FRAMEWORKS)[number];
185
186
  export declare const component: (d: Omit<ComponentDecl, '__decl'>) => ComponentDecl;
186
187
  /**
187
188
  * The sandbox permissions a plugin declares, as against the ones the packager
188
- * compiles from its calls. Two axes only: **storage**, a private row/file store
189
- * with a quota, and **network**, an allowlist of hosts its Providers may reach.
189
+ * compiles from its calls. Three axes only: **storage**, a private row/file store
190
+ * with a quota, **network**, an allowlist of hosts its Providers may reach, and
191
+ * ๐Ÿšง **media**, what its frames may play unasked (M0).
190
192
  *
191
193
  * Nothing else belongs here. Resources and events are compiled โ€” an event
192
194
  * subscription is a call site the packager reads, so declaring one would let a
@@ -195,13 +197,91 @@ export declare const component: (d: Omit<ComponentDecl, '__decl'>) => ComponentD
195
197
  * @experimental
196
198
  */
197
199
  export interface DeclaredPermissions {
200
+ /**
201
+ * ๐Ÿšง `serve` (M0, SHAPES L12 Seams): globs over the plugin's own
202
+ * storage (`['worlds/**']`) its OWN frames may read, read-only and
203
+ * same-origin, at `/plugin-data/<pluginId>/<path>` โ€” never a listing.
204
+ * Compiled to one `storage-serve:<glob>` permission key per glob.
205
+ */
198
206
  storage?: {
199
207
  quotaBytes?: number;
208
+ serve?: string[];
209
+ /**
210
+ * ๐Ÿšง Per-user plugin storage (M2b): a private folder for each person, reached
211
+ * through the same API as `ctx.storage` at `ctx.storage.user`, resolved by
212
+ * core to the person acting (the presser, the viewer; a routine's session
213
+ * owner) โ€” never a user id the plugin names. `quotaBytes` is each person's
214
+ * own quota, in the same band as the plugin's. Compiled to the permission
215
+ * key `storage-per-user` (`storage-per-user:<bytes>` with a quota), in the
216
+ * **applet** permission group.
217
+ */
218
+ perUser?: {
219
+ quotaBytes?: number;
220
+ };
200
221
  };
201
222
  network?: {
202
223
  hosts?: string[];
203
224
  };
225
+ /**
226
+ * ๐Ÿšง Media the plugin's frames play (M0, SHAPES L8): `autoplay` โ€”
227
+ * the frame is allowed to start sound after the person's first gesture
228
+ * (`allow="autoplay"`). A third axis beside storage and network, because a
229
+ * frame's audio cannot be read off a call site either. Declared only until
230
+ * Compiled to the permission key `media:autoplay`; the server answers the
231
+ * frame document `Permissions-Policy: autoplay=()` without it.
232
+ */
233
+ media?: {
234
+ autoplay?: boolean;
235
+ };
236
+ /**
237
+ * ๐Ÿšง The **session** permission group (M2b): what the package's frames may do
238
+ * inside the session they are mounted in โ€” the same grants a widget's
239
+ * `scopes` names (`'session:state'`, `'lore'`, `'session:state:write'`,
240
+ * `'channel:<slug>:write'`, โ€ฆ), declared here for a frame that is not a
241
+ * widget declaration (a session view, an applet while mounted in a session).
242
+ * Compiled to the same `widget:<grant>` keys a widget's scopes compile to:
243
+ * one grant, one key. Shown to the admin as its own group.
244
+ */
245
+ session?: SessionPermissions;
246
+ /**
247
+ * ๐Ÿšง The **applet** permission group (M2b): what the package's applet may do with
248
+ * the person's library and the pub, outside any one session. Shown to the admin
249
+ * as its own group and granted apart from the session group; a widget
250
+ * declaration may never ask for it. Every grant is still bounded by the person
251
+ * acting. The server half of these requests lands in M2c.
252
+ */
253
+ applet?: AppletPermissions;
254
+ }
255
+ /** ๐Ÿšง The session permission group (M2b). See {@link DeclaredPermissions.session}. @experimental */
256
+ export interface SessionPermissions {
257
+ scopes?: readonly WidgetScope[];
258
+ }
259
+ /**
260
+ * ๐Ÿšง The applet permission group (M2b). See {@link DeclaredPermissions.applet}.
261
+ * Compiled keys: `applet:characters:<read|write>` ยท `applet:lorebooks:<read|write>` ยท
262
+ * `applet:sessions:<genre id>` (one per genre) ยท `applet:annex:user`.
263
+ * @experimental
264
+ */
265
+ export interface AppletPermissions {
266
+ /** The person's characters: `read` lists and reads them; `write` also creates and changes them, as that person. */
267
+ characters?: 'read' | 'write';
268
+ /** The person's lorebooks: `read`, or `write` (create, import, attach), as that person. */
269
+ lorebooks?: 'read' | 'write';
270
+ /**
271
+ * Sessions of the package's OWN genres that the person owns: list, open, start
272
+ * (through the app's start form), update and delete (through the app's confirm).
273
+ * Each id must be a genre this package declares; there is no "all genres".
274
+ */
275
+ sessions?: {
276
+ genres: readonly string[];
277
+ };
278
+ /** The user annex: a small document per person, under the plugin's own name. */
279
+ annex?: {
280
+ user?: boolean;
281
+ };
204
282
  }
283
+ /** ๐Ÿšง The levels an applet's library grant takes (M2b). @experimental */
284
+ export declare const APPLET_LIBRARY_LEVELS: readonly ['read', 'write'];
205
285
  /** The quota band an author may ask for. An instance clamps into its own. @experimental */
206
286
  export declare const MIN_STORAGE_QUOTA = 1024;
207
287
  /** @experimental */
@@ -451,6 +531,50 @@ export interface ExtensionDecl {
451
531
  * @ruling F10, 01 ยง9b
452
532
  */
453
533
  peerTypes?: string[];
534
+ /**
535
+ * ๐Ÿšง Content shipped beside `ui/`: images, audio, fonts, data. Served from
536
+ * disk, versioned, immutable at `/plugin-assets/<id>/<path>` (M0,
537
+ * SHAPES L2; `dir` conventionally `'assets'`); the packager carries the
538
+ * folder into the zip.
539
+ */
540
+ assets?: {
541
+ dir: string;
542
+ };
543
+ /**
544
+ * ๐Ÿšง Content the app imports FOR the package (M2c): `lorebooks` โ€” package-relative
545
+ * paths of lorebook files (the format Lorebooks โ€บ Import reads), each under the
546
+ * declared `assets.dir`, so it also ships as an asset. Once an admin has granted
547
+ * `permissions.applet.lorebooks: 'write'` and the plugin is enabled, core's own
548
+ * importer imports each file as the admin who enabled it โ€” once per version, a
549
+ * newer version arrives as a diff under the book's write mode, and uninstall
550
+ * keeps or deletes the books as the admin chooses. Nothing runs in the sandbox.
551
+ * `serene-pub check` refuses a path outside `assets.dir` (`E_PROVIDES_OUTSIDE_ASSETS`),
552
+ * a missing file (`E_PROVIDES_MISSING`), no `applet.lorebooks: 'write'`
553
+ * (`E_PROVIDES_UNGRANTED`) and a file the importer would refuse (`E_PROVIDES_INVALID`).
554
+ * @experimental (M2c)
555
+ */
556
+ provides?: {
557
+ lorebooks?: readonly string[];
558
+ };
559
+ /**
560
+ * ๐Ÿšง Rulesets shipped in the package, as ruleset documents (M0,
561
+ * SHAPES L4 Declaration): install and upgrade publish each as a `rulesets`
562
+ * row โ€” `origin: 'plugin'`, the plugin's slug its owner, the document's
563
+ * `version` its published version; uninstall retires the rows.
564
+ */
565
+ rulesets?: readonly RulesetDocument[];
566
+ /**
567
+ * ๐Ÿšง Handler-mediated actions OUTSIDE a session (M0, SHAPES L12
568
+ * Seams), by action name: `ctx.invoke('world.save', draft)` from a plugin
569
+ * page (`/x/<id>`) or a frame reaches `handler` with `params` checked
570
+ * against the schema. โš  Not a session **action** (a press in a session's
571
+ * actions list). `handler` is the id of a `query` or `outlet` definition
572
+ * this package implements.
573
+ */
574
+ pluginActions?: Record<string, {
575
+ params: SettingsSchema;
576
+ handler: string;
577
+ }>;
454
578
  }
455
579
  /**
456
580
  * What `defineExtension()` returns: the declaration with every reference read
package/dist/extension.js CHANGED
@@ -67,6 +67,8 @@ export const component = (d) => ({
67
67
  __decl: 'component',
68
68
  ...d,
69
69
  });
70
+ /** ๐Ÿšง The levels an applet's library grant takes (M2b). @experimental */
71
+ export const APPLET_LIBRARY_LEVELS = ['read', 'write'];
70
72
  /** The quota band an author may ask for. An instance clamps into its own. @experimental */
71
73
  export const MIN_STORAGE_QUOTA = 1024;
72
74
  /** @experimental */
@@ -95,6 +97,47 @@ export function permissionFindings(p) {
95
97
  `A pub clamps whatever it is handed, so a number outside the band is not a ` +
96
98
  `bigger grant โ€” it is a declaration that says something other than what you get.`);
97
99
  }
100
+ const perUser = p.storage?.perUser;
101
+ if (perUser !== undefined) {
102
+ const q = perUser?.quotaBytes;
103
+ if (typeof perUser !== 'object' ||
104
+ perUser === null ||
105
+ (q !== undefined &&
106
+ (typeof q !== 'number' || !Number.isFinite(q) || q < MIN_STORAGE_QUOTA || q > MAX_STORAGE_QUOTA)))
107
+ out.push(`permissions.storage.perUser.quotaBytes must be ${MIN_STORAGE_QUOTA}โ€ฆ${MAX_STORAGE_QUOTA} โ€” ` +
108
+ `each person's own quota, in the same band as the plugin's.`);
109
+ }
110
+ if (p.applet !== undefined) {
111
+ const a = p.applet;
112
+ if (!a || typeof a !== 'object' || Array.isArray(a))
113
+ out.push('permissions.applet is an object: { characters?, lorebooks?, sessions?, annex? }.');
114
+ else {
115
+ for (const k of Object.keys(a))
116
+ if (!['characters', 'lorebooks', 'sessions', 'annex'].includes(k))
117
+ out.push(`permissions.applet.${k} is not an applet permission (characters ยท lorebooks ยท sessions ยท annex).`);
118
+ for (const k of ['characters', 'lorebooks'])
119
+ if (a[k] !== undefined && !APPLET_LIBRARY_LEVELS.includes(a[k]))
120
+ out.push(`permissions.applet.${k} is 'read' or 'write'.`);
121
+ const sessions = a.sessions;
122
+ if (sessions !== undefined &&
123
+ (!sessions ||
124
+ !Array.isArray(sessions.genres) ||
125
+ sessions.genres.length === 0 ||
126
+ sessions.genres.some((g) => typeof g !== 'string' || !g)))
127
+ out.push(`permissions.applet.sessions needs { genres: [...] }: the ids of genres this package declares. ` +
128
+ `There is no "all genres" โ€” a plugin reaches only sessions of its own genres.`);
129
+ const annex = a.annex;
130
+ if (annex !== undefined && (!annex || typeof annex !== 'object' || (annex.user !== undefined && typeof annex.user !== 'boolean')))
131
+ out.push('permissions.applet.annex is { user?: boolean }.');
132
+ }
133
+ }
134
+ if (p.session !== undefined) {
135
+ const sc = p.session?.scopes;
136
+ if (!p.session || typeof p.session !== 'object' || (sc !== undefined && (!Array.isArray(sc) || sc.some((x) => typeof x !== 'string'))))
137
+ out.push("permissions.session is { scopes?: [...] } โ€” the same grants a widget's `scopes` names.");
138
+ else if (Array.isArray(sc) && sc.some((x) => x.startsWith('applet')))
139
+ out.push('permissions.session.scopes names an applet permission: declare it under permissions.applet.');
140
+ }
98
141
  if (p.network) {
99
142
  const hosts = p.network.hosts ?? [];
100
143
  if (!Array.isArray(hosts) || hosts.length === 0)
package/dist/genres.d.ts CHANGED
@@ -123,6 +123,8 @@ export declare const sessionEvents: Readonly<{
123
123
  readonly sceneSummaryApplied: 'core:event/scene-summary-applied@1';
124
124
  /** ๐Ÿšง The session's settle line moved (pr-6, pass 4). */
125
125
  readonly historySettled: 'core:event/history-settled@1';
126
+ /** ๐Ÿšง A line a run wrote is settled โ€” its run closed its receipt (speech follow-ups A1). Not `message-completed`, not the settle line. */
127
+ readonly messageSettled: 'core:event/message-settled@1';
126
128
  }>;
127
129
  /** @experimental */
128
130
  export type SessionEvent = (typeof sessionEvents)[keyof typeof sessionEvents];
@@ -381,12 +383,19 @@ export interface GenreDecl {
381
383
  * `recommended` with a `default` โ€” offered first, every other ruleset
382
384
  * still allowed. Absent, every ruleset is offered alike. (`only` was
383
385
  * `strict` until 2026-10-17: in the interface _strict_ means rigour.)
386
+ *
387
+ * ๐Ÿšง `autoConvert` (M0, SHAPES L4 Conversion): `true` converts a
388
+ * session pinned to an earlier version of its ruleset when it opens, with
389
+ * a notice; absent or `false` (the default), converting is the owner's
390
+ * press with a confirm.
384
391
  */
385
- readonly rulesets?: {
392
+ readonly rulesets?: ({
386
393
  readonly only: readonly string[];
387
394
  } | {
388
395
  readonly recommended: readonly string[];
389
396
  readonly default: string;
397
+ }) & {
398
+ readonly autoConvert?: boolean;
390
399
  };
391
400
  readonly summarize?: {
392
401
  /**
@@ -451,11 +460,14 @@ export interface GenreRigour {
451
460
  default: Rigour;
452
461
  }
453
462
  /** ๐Ÿšง The rulesets a genre names (`GenreDecl.rulesets`). @experimental */
454
- export type GenreRulesets = {
463
+ export type GenreRulesets = ({
455
464
  only: readonly string[];
456
465
  } | {
457
466
  recommended: readonly string[];
458
467
  default: string;
468
+ }) & {
469
+ /** ๐Ÿšง Convert an earlier-version session at open, with a notice โ€” see `GenreDecl.rulesets`. */
470
+ autoConvert?: boolean;
459
471
  };
460
472
  /**
461
473
  * ๐Ÿšง Why a genre's `rigour` or `rulesets` is refused, each finding opened by
@@ -571,6 +583,12 @@ export interface EnvoyDecl {
571
583
  * @ruling lair re-plan R6 (2026-09-28)
572
584
  */
573
585
  greeting?: EnvoyGreeting;
586
+ /** Casting tags for Auto voice picks (a hint only; the voicebank decides): a speaker role and the gender / age labels to prefer. */
587
+ casting?: {
588
+ role?: 'narrator-like' | 'speaker';
589
+ gender?: string;
590
+ age?: string;
591
+ };
574
592
  }
575
593
  /** An envoy's opening line and where it lands โ€” see `EnvoyDecl.greeting`. @experimental */
576
594
  export interface EnvoyGreeting {
package/dist/genres.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { widgetRef } from './widgetDecls.js';
2
2
  import { drawnWidgetIds, layoutWidgetIds, resolveWidgetAlias } from './sessionLayout.js';
3
- import { assertChannelDecls, assertMessageVerbFloors, assertSessionWrites, assertTurnControls, channelDecls, lorebookReadOptional, lorebookShapeFindings, widgetDeclsFindings, } from './descriptors.js';
3
+ import { assertChannelDecls, assertMessageVerbFloors, assertSessionWrites, assertTurnControls, SESSION_CREATION_MODES, channelDecls, lorebookReadOptional, lorebookShapeFindings, widgetDeclsFindings, } from './descriptors.js';
4
4
  import { assertSceneSettings, declaredScenePlace } from './sceneSettings.js';
5
+ import { storyCalendarProblems } from './storyTime.js';
5
6
  import { i18nFindings, localeMapOf } from './i18n.js';
6
7
  import { eventById, notADeclaredEvent } from './events.js';
7
8
  import { settingsSchemaFindings } from './settings.js';
@@ -124,6 +125,8 @@ export const sessionEvents = Object.freeze({
124
125
  sceneSummaryApplied: 'core:event/scene-summary-applied@1',
125
126
  /** ๐Ÿšง The session's settle line moved (pr-6, pass 4). */
126
127
  historySettled: 'core:event/history-settled@1',
128
+ /** ๐Ÿšง A line a run wrote is settled โ€” its run closed its receipt (speech follow-ups A1). Not `message-completed`, not the settle line. */
129
+ messageSettled: 'core:event/message-settled@1',
127
130
  });
128
131
  /**
129
132
  * ๐Ÿšง Does this genre's event surface have `event`? Its `events`, plus
@@ -175,6 +178,8 @@ export function genreRulesetFindings(id, props) {
175
178
  const only = rs?.only;
176
179
  const recommended = rs?.recommended;
177
180
  let ids = [];
181
+ if (rs?.autoConvert !== undefined && typeof rs.autoConvert !== 'boolean')
182
+ out.push(finding('bad-rulesets', `${id}.rulesets.autoConvert is '${String(rs.autoConvert)}'; say true or false.`));
178
183
  if (rs?.strict !== undefined)
179
184
  out.push(finding('bad-rulesets', `${id}.rulesets.strict is now 'only' (2026-10-17) โ€” say { only: [...] }.`));
180
185
  else if ((only === undefined) === (recommended === undefined))
@@ -559,6 +564,14 @@ export function genre(id, props) {
559
564
  assertSessionWrites(props.shape, id);
560
565
  assertTurnControls(props.shape, id);
561
566
  assertChannelDecls(props.shape, id);
567
+ {
568
+ const proposed = props.shape?.creationMode;
569
+ if (proposed !== undefined &&
570
+ !(proposed !== null &&
571
+ typeof proposed === 'object' &&
572
+ SESSION_CREATION_MODES.includes(proposed.propose)))
573
+ throw new Error(`${id} proposes creation mode ${JSON.stringify(proposed)}. A genre may propose one of 'new', 'new-world', 'branch' or 'next-chapter' โ€” { propose: 'next-chapter' } โ€” and never lock it.`);
574
+ }
562
575
  // โณ `lorebook: 'required'` (retired RF fix 2, 2026-10-23): accepted for
563
576
  // one release, warned here, and read as 'optional' in the declaration.
564
577
  for (const f of lorebookShapeFindings(props.shape, `${id}.shape.lorebook`))
@@ -567,6 +580,26 @@ export function genre(id, props) {
567
580
  // a mode or a trigger that does not read is an authoring mistake, not a
568
581
  // default to fall back to silently.
569
582
  assertSceneSettings(props.shape, id);
583
+ // The calendar an own book of this genre starts with (M0, SHAPES F2).
584
+ if (props.shape?.calendar !== undefined) {
585
+ const calendarProblems = storyCalendarProblems(props.shape.calendar, { declaration: true });
586
+ if (calendarProblems.length)
587
+ throw new Error(`${id}.shape.calendar: ${calendarProblems.join(' ')}`);
588
+ }
589
+ // Full screen is only ever proposed, and only for a genre with its own session view (M0, SHAPES L1).
590
+ if (props.shape?.fullscreen !== undefined) {
591
+ if (props.shape.fullscreen !== 'propose')
592
+ throw new Error(`${id}.shape.fullscreen: only 'propose' โ€” a genre proposes full screen and the viewer's choice wins; it never locks.`);
593
+ if (typeof props.shape.view !== 'string')
594
+ throw new Error(`${id}.shape.fullscreen proposes full screen without a session view. Declare shape.view (the plugin whose frame is the session view) or drop fullscreen.`);
595
+ }
596
+ // ๐Ÿšง An applet's frame is the genre's session view, mounted without a session (M2c, plan ยง6).
597
+ if (props.shape?.applet !== undefined) {
598
+ if (props.shape.applet !== true)
599
+ throw new Error(`${id}.shape.applet: only true โ€” the genre's frame is also a launcher outside any session; leave it out otherwise.`);
600
+ if (typeof props.shape.view !== 'string')
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
+ }
570
603
  assertScenePlaceDeclared(props, id);
571
604
  const events = { ...(props.events ?? {}) };
572
605
  // The turn-order write's own event is core-internal (PLAN-turn-order
@@ -754,9 +787,12 @@ export function withGenreDefaults(g, defaults) {
754
787
  registry.set(g.id, next);
755
788
  return next;
756
789
  }
757
- const freezeRulesets = (r) => 'only' in r
758
- ? { only: Object.freeze([...r.only]) }
759
- : { recommended: Object.freeze([...r.recommended]), default: r.default };
790
+ const freezeRulesets = (r) => {
791
+ const auto = r.autoConvert !== undefined ? { autoConvert: r.autoConvert } : {};
792
+ return 'only' in r
793
+ ? { only: Object.freeze([...r.only]), ...auto }
794
+ : { recommended: Object.freeze([...r.recommended]), default: r.default, ...auto };
795
+ };
760
796
  /**
761
797
  * Declared genres, by id.
762
798
  *
@@ -27,6 +27,20 @@ export declare const HOOK_CTX_KINDS: readonly HookCtxKind[];
27
27
  export interface HookCtxGrants {
28
28
  /** The extension's own namespaced files (`ctx.storage`). */
29
29
  storage: boolean;
30
+ /**
31
+ * The package's own shipped files, read-only (`ctx.package`). ๐Ÿšง (M2a)
32
+ * Granted exactly where `storage` is: reading what the package ships is the
33
+ * same reach as reading what it keeps, and a pure kind has neither.
34
+ */
35
+ package: boolean;
36
+ /**
37
+ * The acting person's own saved documents (`ctx.annex('user')`). ๐Ÿšง (M2b)
38
+ * Granted exactly where `storage` is: a task is pure (F11), so it has none.
39
+ * Present on the ctx of those kinds whether or not the extension holds
40
+ * `applet:annex:user` โ€” without it, or with no acting person, the methods
41
+ * reject with a sentence (the way `ctx.storage.user` does).
42
+ */
43
+ annex: boolean;
30
44
  /** Host-scoped network access (`ctx.fetch`). */
31
45
  fetch: boolean;
32
46
  }
@@ -24,19 +24,20 @@ export const HOOK_CTX_KINDS = [
24
24
  * is a script: the in-app script host hands one `{ random, log }` and a
25
25
  * plugin's link gets the same.
26
26
  * - **query**, **outlet**, **event**, **lifecycle** โ€” storage: an
27
- * extension's own files, no network.
28
- * - **oracle** โ€” storage and fetch. The one kind that calls out, which is what
27
+ * extension's own files, `package`: the files it ships, and `annex`: the acting
28
+ * person's saved documents (๐Ÿšง M2b); no network.
29
+ * - **oracle** โ€” storage, package and fetch. The one kind that calls out, which is what
29
30
  * `effects: 'external'` names.
30
31
  * @ruling F11, F32
31
32
  */
32
33
  const GRANTS = {
33
- task: { storage: false, fetch: false },
34
- 'chain-link': { storage: false, fetch: false },
35
- query: { storage: true, fetch: false },
36
- outlet: { storage: true, fetch: false },
37
- event: { storage: true, fetch: false },
38
- lifecycle: { storage: true, fetch: false },
39
- oracle: { storage: true, fetch: true },
34
+ task: { storage: false, package: false, annex: false, fetch: false },
35
+ 'chain-link': { storage: false, package: false, annex: false, fetch: false },
36
+ query: { storage: true, package: true, annex: true, fetch: false },
37
+ outlet: { storage: true, package: true, annex: true, fetch: false },
38
+ event: { storage: true, package: true, annex: true, fetch: false },
39
+ lifecycle: { storage: true, package: true, annex: true, fetch: false },
40
+ oracle: { storage: true, package: true, annex: true, fetch: true },
40
41
  };
41
42
  /** @internal */
42
43
  export function isHookCtxKind(v) {
@@ -65,6 +66,6 @@ const BASE_KEYS = ['random', 'now', 'log', 'signal'];
65
66
  */
66
67
  export function hookCtxKeysFor(kind) {
67
68
  const g = hookCtxGrants(kind);
68
- return [...BASE_KEYS.slice(0, 3), ...(g.storage ? ['storage'] : []), ...(g.fetch ? ['fetch'] : []), BASE_KEYS[3]];
69
+ return [...BASE_KEYS.slice(0, 3), ...(g.storage ? ['storage'] : []), ...(g.package ? ['package'] : []), ...(g.annex ? ['annex'] : []), ...(g.fetch ? ['fetch'] : []), BASE_KEYS[3]];
69
70
  }
70
71
  //# sourceMappingURL=hookGrants.js.map
package/dist/hooks.d.ts CHANGED
@@ -222,14 +222,27 @@ export interface LifecycleUpdateInput {
222
222
  * @experimental
223
223
  */
224
224
  export interface LifecycleMigrateInput {
225
- /** The session whose owner document this is. */
226
- sessionId: number;
225
+ /** โณ Transitional, session scope only: the session's id for a session document, absent for a lorebook document. Read `scope`. */
226
+ sessionId?: number;
227
227
  /** The version that last wrote it โ€” the owner's package version; '0.0.0' when none was recorded. */
228
228
  fromVersion: string;
229
229
  /** The version now running. */
230
230
  version: string;
231
231
  /** The owner document as stored โ€” the callback's own owner only. */
232
232
  document: Readonly<Record<string, unknown>>;
233
+ /**
234
+ * ๐Ÿšง Which annex the document lives in (M0, SHAPES L9 Migration):
235
+ * a session's (`{ kind: 'session', sessionId }`) or a lorebook's
236
+ * (`{ kind: 'lorebook', lorebookId }`). Absent reads as the session
237
+ * `sessionId` names: a host before M0 migrates session annexes only.
238
+ */
239
+ scope?: {
240
+ kind: 'session';
241
+ sessionId: number;
242
+ } | {
243
+ kind: 'lorebook';
244
+ lorebookId: number;
245
+ };
233
246
  }
234
247
  /**
235
248
  * A subscriber to a core event: **`(input, ctx)`**, like every other hook.
@@ -473,5 +473,5 @@ export declare function hostElementsDts(): string;
473
473
  * the suite says which to bump. `doc` strings are not the shape.
474
474
  * @ruling F1, R22
475
475
  */
476
- export declare const HOST_ELEMENTS_VERSION: '1.5';
476
+ export declare const HOST_ELEMENTS_VERSION: '1.8';
477
477
  //# sourceMappingURL=hostElements.d.ts.map
@@ -132,7 +132,13 @@ export const SP_HOST_ELEMENTS = {
132
132
  figure: plain('A self-contained figure โ€” a player and its caption (1.3).', ARIA),
133
133
  figcaption: plain("A figure's caption (1.3).", ARIA),
134
134
  audio: plain('๐Ÿšง A sound player (1.3, O11). `src` is an app media URL (`/media/โ€ฆ`) โ€” never another host, as `img`; `controls` draws the ' +
135
- 'browser\'s own; `preload` is `none` ยท `metadata` ยท `auto`. Name it (`aria-label`). `error` (nothing carried) is the file failing to load.', [...ARIA, 'src', 'controls', 'preload'], ['error']),
135
+ 'browser\'s own; `preload` is `none` ยท `metadata` ยท `auto`. Name it (`aria-label`). `error` (nothing carried) is the file failing to load. ' +
136
+ '๐Ÿšง `autoplay` (core\'s alone; speech build 2026-10-28) plays it once it loads, as far as the browser allows โ€” the newest spoken line under Read aloud: Make and play. ' +
137
+ '๐Ÿšง `loadedmetadata`, `play`, `pause`, `ended` and `timeupdate` (1.7; speech polish 2026-10-29) carry `{ currentTime, duration, paused }` โ€” seconds, seconds (0 until known), and whether it is paused; `timeupdate` arrives about four times a second. ' +
138
+ '๐Ÿšง `playing` (1.8; heading audio control 2026-10-29; core\'s alone) โ€” present, the page plays it; absent after present, the page pauses it. ' +
139
+ 'An element that lands without it is left alone, so `autoplay` still plays. A play the browser refuses is answered with a `pause` event. ' +
140
+ 'The page plays one sound at a time: another player starting pauses this one, and its `pause` arrives. ' +
141
+ 'The element\'s own `play` / `pause` / `ended` events stay the truth; to start over, draw a fresh element.', [...ARIA, 'src', 'controls', 'preload', 'autoplay', 'playing'], ['error', 'play', 'pause', 'ended', 'timeupdate', 'loadedmetadata']),
136
142
  video: plain('๐Ÿšง A moving-picture player (1.3, O11) โ€” `audio`\'s rules, and a `track` of captions inside it.', [...ARIA, 'src', 'controls', 'preload', 'width', 'height'], ['error']),
137
143
  track: plain("๐Ÿšง A video's timed text (1.3, O11): `kind` is `captions` ยท `subtitles` ยท `descriptions` ยท `chapters`; `src`, when given, the app's media.", ['kind', 'src', 'srclang', 'label', 'default']),
138
144
  // โ”€โ”€ host sp elements โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
@@ -743,5 +749,5 @@ export function hostElementsDts() {
743
749
  * the suite says which to bump. `doc` strings are not the shape.
744
750
  * @ruling F1, R22
745
751
  */
746
- export const HOST_ELEMENTS_VERSION = '1.5';
752
+ export const HOST_ELEMENTS_VERSION = '1.8';
747
753
  //# sourceMappingURL=hostElements.js.map
package/dist/index.d.ts CHANGED
@@ -52,6 +52,7 @@ export * from './strokes.js';
52
52
  export * from './dowry.js';
53
53
  export * from './statShapes.js';
54
54
  export * from './storyTime.js';
55
+ export * from './speech.js';
55
56
  export * from './sceneSettings.js';
56
57
  export * from './turnLock.js';
57
58
  export * from './scripts.js';
@@ -59,6 +60,7 @@ export * from './wire.js';
59
60
  export * from './preview.js';
60
61
  export * from './migration.js';
61
62
  export * from './extension.js';
63
+ export * from './lorebookFile.js';
62
64
  export * from './identity.js';
63
65
  export * from './events.js';
64
66
  export * from './eventMapLaws.js';
@@ -86,6 +88,7 @@ export * from './sessionDossier.js';
86
88
  export * from './composerStates.js';
87
89
  export * from './personGate.js';
88
90
  export * from './annexFields.js';
91
+ export * from './userAnnex.js';
89
92
  export * from './surfaces.js';
90
93
  export * from './layout.js';
91
94
  export * from './sessionLayout.js';
@@ -108,4 +111,5 @@ export * from './hash.js';
108
111
  export * from './pick.js';
109
112
  export * from './names.js';
110
113
  export * from './widgetDecls.js';
114
+ export * from './libraryDraft.js';
111
115
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -105,6 +105,9 @@ export * from './dowry.js';
105
105
  // one level down (a sheet names slots, a slot names its shape).
106
106
  export * from './statShapes.js';
107
107
  export * from './storyTime.js';
108
+ // ๐Ÿšง Speech (PLAN-speech-build S3, 2026-10-28): cues, inflection, the cue map,
109
+ // spoken metadata, the line template's scope and the two inflection variables.
110
+ export * from './speech.js';
108
111
  // ๐Ÿšง Scene settings (live scenes ยง4โ€“ยง5): how a session places its scene
109
112
  // boundaries and when a scene's summary runs; `SessionShape.scenes`.
110
113
  export * from './sceneSettings.js';
@@ -117,6 +120,7 @@ export * from './wire.js';
117
120
  export * from './preview.js';
118
121
  export * from './migration.js';
119
122
  export * from './extension.js';
123
+ export * from './lorebookFile.js';
120
124
  export * from './identity.js';
121
125
  export * from './events.js';
122
126
  export * from './eventMapLaws.js';
@@ -162,6 +166,8 @@ export * from './personGate.js';
162
166
  // Annex fields (2026-09-26): a declared key a widget sets through core's one
163
167
  // pipeline โ€” no pipeline per value. Imports participants/settings/i18n only.
164
168
  export * from './annexFields.js';
169
+ // ๐Ÿšง The user annex (M2b): a person's own versioned documents under an owner.
170
+ export * from './userAnnex.js';
165
171
  export * from './surfaces.js';
166
172
  // The widget declarations a layout places. Beside surfaces because it is the
167
173
  // other half of the same story: a surface is where a plugin renders, a widget
@@ -228,4 +234,6 @@ export * from './names.js';
228
234
  // executor's own `await import('./tokenizers.js')` stays a real split point โ€”
229
235
  // on it, every bundle that can see `run` would carry the registry.
230
236
  export * from './widgetDecls.js';
237
+ // ๐Ÿšง A drafted card or book read out of a reply (M2c path B): `readLibraryDraft`.
238
+ export * from './libraryDraft.js';
231
239
  //# sourceMappingURL=index.js.map