@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
@@ -235,8 +235,25 @@ export function createComponentContext(port) {
235
235
  eventSubs.add(fn);
236
236
  return () => eventSubs.delete(fn);
237
237
  },
238
+ // 🚧 M2b: a component's invoke is answered as a frame's is (a `requestId`, then `response`): it resolves, never
239
+ // rejects — `{ ok: true, result? }` or `{ ok: false, error }` ({@link ComponentInvokeAnswer}).
238
240
  invoke(key, args = {}) {
239
- port.postMessage({ t: 'invoke', key, ...args });
241
+ const requestId = `i${++nextRequest}`;
242
+ let settle;
243
+ const answer = new Promise((resolve) => (settle = resolve));
244
+ pending.set(requestId, {
245
+ resolve: (result) => settle(result === undefined ? { ok: true } : { ok: true, result }),
246
+ reject: (e) => settle({ ok: false, error: e.message }),
247
+ });
248
+ // A payload that cannot cross still throws to the caller, as a port's would (and nothing waits on it).
249
+ try {
250
+ port.postMessage({ t: 'invoke', key, ...args, requestId });
251
+ }
252
+ catch (e) {
253
+ pending.delete(requestId);
254
+ throw e;
255
+ }
256
+ return answer;
240
257
  },
241
258
  saveState(state) {
242
259
  port.postMessage({ t: 'save-state', state });
@@ -259,16 +276,17 @@ export function createComponentContext(port) {
259
276
  : { t: 'request', requestId, what: kind, params });
260
277
  });
261
278
  },
262
- t(source) {
279
+ t(source, ...args) {
280
+ const fill = (text) => text.replace(/\{(\d+)\}/g, (whole, n) => Number(n) < args.length ? String(args[Number(n)]) : whole);
263
281
  const hit = strings.get(source);
264
282
  if (hit !== undefined)
265
- return hit;
283
+ return fill(hit);
266
284
  if (!asked.has(source)) {
267
285
  asked.add(source);
268
286
  misses.push(source);
269
287
  askLater();
270
288
  }
271
- return source;
289
+ return fill(source);
272
290
  },
273
291
  get viewer() {
274
292
  return data.viewer;
@@ -184,6 +184,21 @@ export declare function createPipelineFindings(genres: readonly GenreDecl[], pip
184
184
  * @experimental
185
185
  */
186
186
  export declare function genrePresetFindings(genres: readonly GenreDecl[], presets: readonly PresetDecl[]): string[];
187
+ /**
188
+ * 🚧 **Every genre ships exactly one create spec** (24 §3), counted the way an
189
+ * install counts it: a pipeline document whose inlet lock is
190
+ * `input.genre === <genre id>` and `input.event === 'core:event/session-created@1'`.
191
+ * A genre IS its create spec's published row, so a genre with none reaches no
192
+ * picker, and one with two has no single start. The ONE rule: the install's
193
+ * package reader and the packager (`serene-pub check`/`build`) both call it,
194
+ * so a package the packager passes is never refused here at install
195
+ * (2026-10-29). A registration a genre's defaults name is not counted — only
196
+ * the lock is.
197
+ * @experimental
198
+ */
199
+ export declare function genreCreateSpecFindings(genres: readonly {
200
+ id?: unknown;
201
+ }[], documents: readonly unknown[]): string[];
187
202
  /**
188
203
  * Contributed actions: each declaration sound, and one slash name
189
204
  * meaning one function across the whole package — the per-document check cannot
@@ -275,6 +275,35 @@ export function genrePresetFindings(genres, presets) {
275
275
  }
276
276
  return out;
277
277
  }
278
+ /**
279
+ * 🚧 **Every genre ships exactly one create spec** (24 §3), counted the way an
280
+ * install counts it: a pipeline document whose inlet lock is
281
+ * `input.genre === <genre id>` and `input.event === 'core:event/session-created@1'`.
282
+ * A genre IS its create spec's published row, so a genre with none reaches no
283
+ * picker, and one with two has no single start. The ONE rule: the install's
284
+ * package reader and the packager (`serene-pub check`/`build`) both call it,
285
+ * so a package the packager passes is never refused here at install
286
+ * (2026-10-29). A registration a genre's defaults name is not counted — only
287
+ * the lock is.
288
+ * @experimental
289
+ */
290
+ export function genreCreateSpecFindings(genres, documents) {
291
+ const out = [];
292
+ for (const g of genres) {
293
+ const id = g && typeof g.id === 'string' ? g.id : '';
294
+ if (!id)
295
+ continue;
296
+ const creates = documents.filter((d) => {
297
+ const input = d?.input;
298
+ return input?.genre === id && input?.event === 'core:event/session-created@1';
299
+ });
300
+ if (creates.length !== 1)
301
+ out.push(`genre '${id}' ships ${creates.length} create pipelines — every genre needs ` +
302
+ `exactly one spec answering 'core:event/session-created@1' (24 §3). A genre is its ` +
303
+ `create pipeline's published row, so a genre without one reaches no picker.`);
304
+ }
305
+ return out;
306
+ }
278
307
  /**
279
308
  * Contributed actions: each declaration sound, and one slash name
280
309
  * meaning one function across the whole package — the per-document check cannot
@@ -22,6 +22,8 @@ import type { WidgetDecl } from './layout.js';
22
22
  import type { MediaCapability } from './media.js';
23
23
  import { type DisplayKeys } from './hash.js';
24
24
  import { type SeamAddress } from './scripts.js';
25
+ import { type ParticipantRef } from './participants.js';
26
+ import { type StoryCalendar } from './storyTime.js';
25
27
  import { type SceneSettingsDecl } from './sceneSettings.js';
26
28
  /**
27
29
  * The node kinds (ruled 2026-09-14): **inlet** (where the run enters) ·
@@ -514,6 +516,20 @@ export type SessionWritePolicy = Record<SessionWrite, boolean>;
514
516
  * @experimental
515
517
  */
516
518
  export declare function resolveWrites(shape: unknown): SessionWritePolicy;
519
+ /** The library writes a genre may declare, in `SessionShape.writes.library`. @experimental */
520
+ export declare const LIBRARY_WRITES: readonly ['characters', 'lorebooks', 'sessions'];
521
+ /** @experimental */
522
+ export type LibraryWrite = (typeof LIBRARY_WRITES)[number];
523
+ /** Availability of every library write. @experimental */
524
+ export type LibraryWritePolicy = Record<LibraryWrite, boolean>;
525
+ /**
526
+ * What this shape lets a session's pipelines write into the library,
527
+ * resolved. Absent, unknown or unreadable is **all off**: a library write
528
+ * is opt-in. Only an explicit `true` allows one. Pure, and takes `unknown`
529
+ * like `resolveWrites`.
530
+ * @experimental
531
+ */
532
+ export declare function resolveLibraryWrites(shape: unknown): LibraryWritePolicy;
517
533
  /**
518
534
  * A `writes` declaration whose values are not booleans is refused — with a
519
535
  * sentence, at the declaration, where the author is. Shared by `register`
@@ -651,6 +667,23 @@ export interface PortDecl {
651
667
  * `$ref('history', 'messages')` with a string (see src/scope.ts). Both default to the
652
668
  * open `PortDecl`, so nothing that ignores the generics changes.
653
669
  */
670
+ /**
671
+ * 🚧 **A declared calendar** (M0, SHAPES F2): the calendar a genre gives
672
+ * the own books its sessions make — `SessionShape.calendar` — in the book's
673
+ * own shape (`StoryCalendar`, stored in `lorebooks.story_calendar`). Periods
674
+ * and seasons belong to the CALENDAR, never the genre (`StoryCalendar.periods`,
675
+ * `.seasons`): a book the session reads keeps its own in every session and
676
+ * genre that reads it, and this declaration is only where an own book starts.
677
+ * Absent `months`, the own book keeps core's own-book calendar (twelve
678
+ * months) with the declared `periods` and `seasons` laid on it; absent
679
+ * altogether, the own book is made as it always was.
680
+ * @experimental
681
+ */
682
+ export type CalendarDecl = Partial<StoryCalendar>;
683
+ /** 🚧 How a new session starts (M0, F5). @experimental */
684
+ export declare const SESSION_CREATION_MODES: readonly ['new', 'new-world', 'branch', 'next-chapter'];
685
+ /** @experimental */
686
+ export type SessionCreationMode = (typeof SESSION_CREATION_MODES)[number];
654
687
  /**
655
688
  * The chat-shape contract a mode-bearing input type carries. See
656
689
  * `Descriptor.shape` for the rules; this is the vocabulary.
@@ -826,6 +859,22 @@ export interface SessionShape {
826
859
  lore?: boolean;
827
860
  /** May a session of this genre open scenes? */
828
861
  scenes?: boolean;
862
+ /**
863
+ * The library writes a genre opts into — making or changing characters,
864
+ * making lorebooks and reading them into sessions. **Absent = all off**
865
+ * (unlike `lore` and `scenes`): a library write is something a genre
866
+ * asks for. Declaring it only lets the genre's pipelines try: the
867
+ * person's rights and their library write mode (Full, Review, Off)
868
+ * still decide each write.
869
+ */
870
+ library?: {
871
+ /** May a pipeline of this genre make or change characters? */
872
+ characters?: boolean;
873
+ /** May a pipeline of this genre make lorebooks, or read one into the session? */
874
+ lorebooks?: boolean;
875
+ /** May a pipeline of this genre read a lorebook into a session other than its own? */
876
+ sessions?: boolean;
877
+ };
829
878
  };
830
879
  /**
831
880
  * 🚧 How sessions of this genre place their **scene boundaries** while
@@ -849,6 +898,38 @@ export interface SessionShape {
849
898
  * @ruling 20 §12
850
899
  */
851
900
  view?: string;
901
+ /**
902
+ * 🚧 A declared session view may PROPOSE full screen (M0, SHAPES L1):
903
+ * the first open of a session of this genre enters full screen once, with
904
+ * the one-line notice "Press Esc to leave full screen."; the viewer's
905
+ * choice afterwards wins, stored as their own. Never `'lock'`. Meaningful
906
+ * only beside `view`. Answered by the session page (U2).
907
+ */
908
+ fullscreen?: 'propose';
909
+ /**
910
+ * 🚧 The genre's frame is also an **applet** (M2c, plan §6 · §9): the Sessions rail lists the plugin under **Apps**
911
+ * (one row per plugin, however many of its genres say so), and opening that row mounts the genre's `view` frame WITHOUT a
912
+ * session, full screen, holding the `ui` + `applet` front-end APIs — a launcher (New game, Continue, Load) that starts and
913
+ * opens ordinary sessions of the genre through the app's own start form and lists. Sessions › New › this genre opens the
914
+ * launcher (the generic start form stays one click away); an existing session of the genre opens straight to the session,
915
+ * never through the launcher. Meaningful only beside `view`; a widget may not declare it. Never a lock.
916
+ * (Ruled 2026-10-31: `applet: true`, not `presentation` — that word is the Messages widget's setting, R1.)
917
+ */
918
+ applet?: true;
919
+ /**
920
+ * 🚧 The creation mode the start form proposes for this genre (M0,
921
+ * F5) — a sequel genre proposes 'next-chapter'; the person may pick
922
+ * another. Never a lock.
923
+ */
924
+ creationMode?: {
925
+ propose: SessionCreationMode;
926
+ };
927
+ /**
928
+ * 🚧 The calendar an own book of this genre's sessions starts with (M0,
929
+ * SHAPES F2) — see {@link CalendarDecl}. Never written onto a book the
930
+ * session reads that is not its own.
931
+ */
932
+ calendar?: CalendarDecl;
852
933
  /**
853
934
  * The session's channels beyond the implicit `main` — filter
854
935
  * lanes inside one session. What renders a channel is the surface story
@@ -1009,8 +1090,19 @@ export declare const CHANNEL_LORE_ROLES: readonly ['story', 'aside', 'never'];
1009
1090
  export type ChannelLoreRole = (typeof CHANNEL_LORE_ROLES)[number];
1010
1091
  /** 🚧 Who reads a channel: every member (`all`, the default) or the session's owner alone (`owner`). @experimental */
1011
1092
  export declare const CHANNEL_AUDIENCES: readonly ['all', 'owner'];
1012
- /** @experimental */
1013
- export type ChannelAudience = (typeof CHANNEL_AUDIENCES)[number];
1093
+ /**
1094
+ * 🚧 Who reads a channel: one of {@link CHANNEL_AUDIENCES}, or (M0,
1095
+ * SHAPES L6) `{ participants }` — the participants named and nobody else:
1096
+ * through reads, the send door, `channel-lanes` and `session-history@1`; on a
1097
+ * `personal` lane mode it narrows per lane. ★6: it REPLACES the
1098
+ * private-messages gate — one mechanism, the word **audience**; *private
1099
+ * message* stays the interface's label for a lane whose audience is two
1100
+ * people.
1101
+ * @experimental
1102
+ */
1103
+ export type ChannelAudience = (typeof CHANNEL_AUDIENCES)[number] | {
1104
+ participants: readonly ParticipantRef[];
1105
+ };
1014
1106
  /** 🚧 Whose a channel's lanes are: the genre's (`shared`) or one per person (`personal`). @experimental */
1015
1107
  export declare const CHANNEL_LANE_MODES: readonly ['shared', 'personal'];
1016
1108
  /** @experimental */
@@ -1740,6 +1832,15 @@ export declare function getDefinition(id: string): Descriptor | undefined;
1740
1832
  export declare function allDefinitions(): Descriptor[];
1741
1833
  /** @experimental */
1742
1834
  export declare function _clearDefinitions(): void;
1835
+ /**
1836
+ * Take one node definition back out of this process's registry — a HOST's door, for
1837
+ * the declarations it registered from a plugin's stored manifest and replaces when
1838
+ * that plugin is reinstalled (the way `_withdrawVariable` serves a plugin's variables).
1839
+ * Refuses `core:` ids: core's definitions are this build's. An entry type is
1840
+ * `_withdrawEntryType`'s. Returns whether one was held.
1841
+ * @internal
1842
+ */
1843
+ export declare function _withdrawDefinition(id: string): boolean;
1743
1844
  /**
1744
1845
  * ## Why every `describe*` is generic over its slots
1745
1846
  *
@@ -23,6 +23,8 @@ import { authoredSlots } from './settingsSlot.js';
23
23
  // `scripts.ts` imports only types from here, so this runtime import starts no cycle.
24
24
  import { isScriptKindId, seamAddressOf } from './scripts.js';
25
25
  import { DEFAULT_CHANNEL, parseChannel } from './channels.js';
26
+ import { isParticipantRef } from './participants.js';
27
+ import { storyCalendarProblems } from './storyTime.js';
26
28
  import { assertSceneSettings } from './sceneSettings.js';
27
29
  // F39's registry door: `register()` hears `core:verdict/settings-travel` for
28
30
  // every declared out-port (01 §13). `verdicts.ts` reads only leaf
@@ -316,6 +318,25 @@ export function resolveWrites(shape) {
316
318
  const d = declared;
317
319
  return Object.fromEntries(SESSION_WRITES.map((w) => [w, d[w] !== false]));
318
320
  }
321
+ /** The library writes a genre may declare, in `SessionShape.writes.library`. @experimental */
322
+ export const LIBRARY_WRITES = ['characters', 'lorebooks', 'sessions'];
323
+ /**
324
+ * What this shape lets a session's pipelines write into the library,
325
+ * resolved. Absent, unknown or unreadable is **all off**: a library write
326
+ * is opt-in. Only an explicit `true` allows one. Pure, and takes `unknown`
327
+ * like `resolveWrites`.
328
+ * @experimental
329
+ */
330
+ export function resolveLibraryWrites(shape) {
331
+ const writes = shape && typeof shape === 'object'
332
+ ? (shape.writes ?? null)
333
+ : null;
334
+ const declared = writes && typeof writes === 'object'
335
+ ? (writes.library ?? null)
336
+ : null;
337
+ const d = (declared && typeof declared === 'object' ? declared : {});
338
+ return Object.fromEntries(LIBRARY_WRITES.map((w) => [w, d[w] === true]));
339
+ }
319
340
  /**
320
341
  * A `writes` declaration whose values are not booleans is refused — with a
321
342
  * sentence, at the declaration, where the author is. Shared by `register`
@@ -332,6 +353,18 @@ export function assertSessionWrites(shape, who) {
332
353
  throw new Error(`${who} declares a 'writes' that is not an object. A genre's writes are ` +
333
354
  `{ lore?: boolean; scenes?: boolean } — absent means both on, and only an ` +
334
355
  `explicit false takes one away (R-B).`);
356
+ const library = writes.library;
357
+ if (library !== undefined) {
358
+ if (!library || typeof library !== 'object' || Array.isArray(library))
359
+ throw new Error(`${who} declares a 'writes.library' that is not an object. It is ` +
360
+ `{ characters?: boolean; lorebooks?: boolean; sessions?: boolean } — absent means off.`);
361
+ const lib = library;
362
+ const badLib = LIBRARY_WRITES.filter((w) => lib[w] !== undefined && typeof lib[w] !== 'boolean');
363
+ if (badLib.length)
364
+ throw new Error(`${who} declares writes.library { ${badLib.map((w) => `${w}: ${JSON.stringify(lib[w])}`).join(', ')} }. ` +
365
+ `Each library write is a boolean or absent — absent means off, and only an ` +
366
+ `explicit true allows the write.`);
367
+ }
335
368
  const bad = SESSION_WRITES.filter((w) => writes[w] !== undefined && typeof writes[w] !== 'boolean');
336
369
  if (!bad.length)
337
370
  return;
@@ -474,6 +507,8 @@ export function assertMessageVerbFloors(shape, who) {
474
507
  `(R-15). A genre may switch off delete, hide or swipe, and may forbid retry, ` +
475
508
  `extend or stepBack; drop the floor from the declaration.`);
476
509
  }
510
+ /** 🚧 How a new session starts (M0, F5). @experimental */
511
+ export const SESSION_CREATION_MODES = ['new', 'new-world', 'branch', 'next-chapter'];
477
512
  /** 🚧 What a channel's lines are to a summary (pass 9 S1). @experimental */
478
513
  export const CHANNEL_LORE_ROLES = ['story', 'aside', 'never'];
479
514
  /** 🚧 Who reads a channel: every member (`all`, the default) or the session's owner alone (`owner`). @experimental */
@@ -554,7 +589,17 @@ export function channelDecls(shape) {
554
589
  export function channelAudience(shape, channel) {
555
590
  const slug = parseChannel(channel).slug;
556
591
  const decl = channelDecls(shape).find((d) => d.slug === slug);
557
- return decl?.audience === 'owner' ? 'owner' : 'all';
592
+ const audience = decl?.audience;
593
+ if (audience === 'owner')
594
+ return 'owner';
595
+ if (audience !== undefined &&
596
+ typeof audience === 'object' &&
597
+ audience !== null &&
598
+ Array.isArray(audience.participants) &&
599
+ audience.participants.length > 0 &&
600
+ audience.participants.every(isParticipantRef))
601
+ return audience;
602
+ return 'all';
558
603
  }
559
604
  /** 🚧 The lore role of `channel` (may be `slug:lane`; the slug decides), default resolved. @experimental */
560
605
  export function channelLoreRole(shape, channel) {
@@ -566,6 +611,14 @@ export function channelLoreRole(shape, channel) {
566
611
  ? 'story'
567
612
  : 'never';
568
613
  }
614
+ function assertShapeCalendar(shape, who) {
615
+ const calendar = shape?.calendar;
616
+ if (calendar === undefined)
617
+ return;
618
+ const problems = storyCalendarProblems(calendar, { declaration: true });
619
+ if (problems.length)
620
+ throw new Error(`${who}.shape.calendar: ${problems.join(' ')}`);
621
+ }
569
622
  /**
570
623
  * A channel declaration that cannot mean what it says is refused — with a
571
624
  * sentence, at the declaration, on the same terms as `assertMessageVerbFloors`.
@@ -614,10 +667,21 @@ export function assertChannelDecls(shape, who) {
614
667
  throw new Error(`${at} declares personal lanes. '${DEFAULT_CHANNEL}' is the channel every member ` +
615
668
  `reads; declare another channel for lanes of one person each.`);
616
669
  // 🚧 D6: who reads it — a mode, and two refusals where it cannot mean what it says.
617
- if (decl.audience !== undefined && !CHANNEL_AUDIENCES.includes(decl.audience))
618
- throw new Error(`${at} declares audience '${String(decl.audience)}'. A channel's audience is ` +
619
- `${CHANNEL_AUDIENCES.map((a) => `'${a}'`).join(' or ')} — every member, or the ` +
620
- `session's owner alone.`);
670
+ if (decl.audience !== undefined && typeof decl.audience === 'object') {
671
+ const people = decl.audience?.participants;
672
+ if (decl.audience === null || !Array.isArray(people) || people.length === 0)
673
+ throw new Error(`${at} declares audience ${JSON.stringify(decl.audience)}. A channel's audience is 'all', 'owner' or { participants: [ … ] } — every member, the session's owner alone, or the people named.`);
674
+ for (const r of people) {
675
+ if (!isParticipantRef(r))
676
+ throw new Error(`${at} declares audience participant '${String(r)}', which is not a participant reference — 'owner', 'user:<id>', 'character:<id>', 'player-seat:<id>' or 'envoy:<slug>'.`);
677
+ if (r === 'ai' || r === 'item' || r === 'run-owner')
678
+ throw new Error(`${at} declares audience participant '${r}', which is never a person. Pipelines read every channel already; name the people who may read it.`);
679
+ }
680
+ if (slug === DEFAULT_CHANNEL)
681
+ throw new Error(`${at} declares a participants audience. '${DEFAULT_CHANNEL}' is the channel every member reads; declare another channel for a conversation among a few.`);
682
+ }
683
+ else if (decl.audience !== undefined && !CHANNEL_AUDIENCES.includes(decl.audience))
684
+ throw new Error(`${at} declares audience '${String(decl.audience)}'. A channel's audience is 'all', 'owner' or { participants: [ … ] } — every member, the session's owner alone, or the people named.`);
621
685
  if (slug === DEFAULT_CHANNEL && decl.audience === 'owner')
622
686
  throw new Error(`${at} declares audience 'owner'. '${DEFAULT_CHANNEL}' is the channel every member ` +
623
687
  `reads; declare another channel for the owner alone — the Lair's Sanctum.`);
@@ -874,6 +938,7 @@ function register(d) {
874
938
  assertTurnControls(d.sessionShape, d.id);
875
939
  assertChannelDecls(d.sessionShape, d.id);
876
940
  assertSceneSettings(d.sessionShape, d.id);
941
+ assertShapeCalendar(d.sessionShape, d.id);
877
942
  // A finding, not a refusal: the fallback is documented (inference), the
878
943
  // omission is recorded, and `validate()` says it on every placement.
879
944
  const reviewFinding = reviewFieldsFinding(d);
@@ -1258,6 +1323,23 @@ export function _clearDefinitions() {
1258
1323
  types.clear();
1259
1324
  registrationFindings.clear();
1260
1325
  }
1326
+ /**
1327
+ * Take one node definition back out of this process's registry — a HOST's door, for
1328
+ * the declarations it registered from a plugin's stored manifest and replaces when
1329
+ * that plugin is reinstalled (the way `_withdrawVariable` serves a plugin's variables).
1330
+ * Refuses `core:` ids: core's definitions are this build's. An entry type is
1331
+ * `_withdrawEntryType`'s. Returns whether one was held.
1332
+ * @internal
1333
+ */
1334
+ export function _withdrawDefinition(id) {
1335
+ if (id.startsWith('core:'))
1336
+ throw new Error(`'${id}' is core's; it is never withdrawn`);
1337
+ const held = types.get(id);
1338
+ if (!held || held.kind === 'entry')
1339
+ return false;
1340
+ registrationFindings.delete(id);
1341
+ return types.delete(id);
1342
+ }
1261
1343
  // ── describe*Definition — one per kind, same shape, no modality anywhere ─────
1262
1344
  //
1263
1345
  // `describeInletDefinition · describeQueryDefinition · describeTaskDefinition ·
package/dist/events.d.ts CHANGED
@@ -266,6 +266,24 @@ export declare const CORE_EVENTS: {
266
266
  * turn to answer".
267
267
  */
268
268
  readonly messageCompleted: EventDef;
269
+ /**
270
+ * 🚧 **Message settled** (speech follow-ups, A1, 2026-10-29): ONE per line
271
+ * a run wrote, emitted by core after that run closed its receipt — the
272
+ * moment work that must never hold the line (reading it aloud) may start,
273
+ * as its own run.
274
+ *
275
+ * ⚠ Not `message-completed@1`, which fires per WRITE, during the run (a
276
+ * send, a seeded greeting, a finished or stopped reply). And not the
277
+ * session's **settle line** / `history-settled@1` (history fixed, Back no
278
+ * longer reaches it): always the qualified "message settled", never bare
279
+ * "settled". The payload is `MessageSettledPayload`.
280
+ *
281
+ * Off the ledger: it describes no write of its own (the line is already on
282
+ * record through `message-completed`), and a ledger row would reach every
283
+ * next reply's `sessionChanges` once per line saying nothing new. A
284
+ * declared root — no outlet causes it, so no spec bound here can loop on it.
285
+ */
286
+ readonly messageSettled: EventDef;
269
287
  /**
270
288
  * A seated participant's row changed — switched on or off (`active`),
271
289
  * `position` or portrayal. Not add or remove: those stay
@@ -306,6 +324,24 @@ export declare const CORE_EVENTS: {
306
324
  * rest.
307
325
  */
308
326
  readonly annexChanged: EventDef;
327
+ /**
328
+ * 🚧 The session's rules were moved to another version of their ruleset
329
+ * (M0, SHAPES L4 Conversion), by `core:outlet/convert-ruleset@1` or
330
+ * the `sessions:convertRuleset` socket. The payload
331
+ * (`RulesetConversionPayload`) names the ruleset, both versions and what
332
+ * happened to the slots. Declared only until lane T4 emits it.
333
+ */
334
+ readonly rulesetConverted: EventDef;
335
+ /**
336
+ * 🚧 A **lorebook annex** document changed (M0, SHAPES L9): the
337
+ * lorebook twin of `annex-changed`, caused by
338
+ * `core:outlet/set-lorebook-annex@1` and
339
+ * `core:outlet/set-lorebook-annex-field@1`. The payload
340
+ * (`LorebookAnnexChangePayload`) names the book, the owner and the keys
341
+ * that moved, never the values.
342
+ * ⚠ Not `annex-changed`, which is the session annex's.
343
+ */
344
+ readonly lorebookAnnexChanged: EventDef;
309
345
  /**
310
346
  * 🚧 The session's **backdrop** changed: a pipeline set it through
311
347
  * `core:outlet/set-backdrop@1`, or a person set or cleared it from the
@@ -595,6 +631,24 @@ export declare const coreEvents: {
595
631
  * turn to answer".
596
632
  */
597
633
  readonly messageCompleted: EventDef;
634
+ /**
635
+ * 🚧 **Message settled** (speech follow-ups, A1, 2026-10-29): ONE per line
636
+ * a run wrote, emitted by core after that run closed its receipt — the
637
+ * moment work that must never hold the line (reading it aloud) may start,
638
+ * as its own run.
639
+ *
640
+ * ⚠ Not `message-completed@1`, which fires per WRITE, during the run (a
641
+ * send, a seeded greeting, a finished or stopped reply). And not the
642
+ * session's **settle line** / `history-settled@1` (history fixed, Back no
643
+ * longer reaches it): always the qualified "message settled", never bare
644
+ * "settled". The payload is `MessageSettledPayload`.
645
+ *
646
+ * Off the ledger: it describes no write of its own (the line is already on
647
+ * record through `message-completed`), and a ledger row would reach every
648
+ * next reply's `sessionChanges` once per line saying nothing new. A
649
+ * declared root — no outlet causes it, so no spec bound here can loop on it.
650
+ */
651
+ readonly messageSettled: EventDef;
598
652
  /**
599
653
  * A seated participant's row changed — switched on or off (`active`),
600
654
  * `position` or portrayal. Not add or remove: those stay
@@ -635,6 +689,24 @@ export declare const coreEvents: {
635
689
  * rest.
636
690
  */
637
691
  readonly annexChanged: EventDef;
692
+ /**
693
+ * 🚧 The session's rules were moved to another version of their ruleset
694
+ * (M0, SHAPES L4 Conversion), by `core:outlet/convert-ruleset@1` or
695
+ * the `sessions:convertRuleset` socket. The payload
696
+ * (`RulesetConversionPayload`) names the ruleset, both versions and what
697
+ * happened to the slots. Declared only until lane T4 emits it.
698
+ */
699
+ readonly rulesetConverted: EventDef;
700
+ /**
701
+ * 🚧 A **lorebook annex** document changed (M0, SHAPES L9): the
702
+ * lorebook twin of `annex-changed`, caused by
703
+ * `core:outlet/set-lorebook-annex@1` and
704
+ * `core:outlet/set-lorebook-annex-field@1`. The payload
705
+ * (`LorebookAnnexChangePayload`) names the book, the owner and the keys
706
+ * that moved, never the values.
707
+ * ⚠ Not `annex-changed`, which is the session annex's.
708
+ */
709
+ readonly lorebookAnnexChanged: EventDef;
638
710
  /**
639
711
  * 🚧 The session's **backdrop** changed: a pipeline set it through
640
712
  * `core:outlet/set-backdrop@1`, or a person set or cleared it from the
@@ -924,6 +996,13 @@ export interface EventCause {
924
996
  runId?: string;
925
997
  /** On kind 'run': the run was fired by auto-advance. */
926
998
  auto?: boolean;
999
+ /**
1000
+ * 🚧 (M2c) On a change an **applet** made for the person (`update-session`,
1001
+ * an applet-opened start form or delete confirm): the package that asked.
1002
+ * The cause's `kind` stays the person's own (`settings`), so auto-advance
1003
+ * reads it as it reads their hand.
1004
+ */
1005
+ pluginId?: string;
927
1006
  }
928
1007
  /** @experimental */
929
1008
  export interface SessionChangePayload {
@@ -1071,6 +1150,91 @@ export interface AnnexChangePayload {
1071
1150
  /** The annex key that changed: a genre id, a plugin id, or `user:<slug>`. */
1072
1151
  owner: string;
1073
1152
  }
1153
+ /**
1154
+ * 🚧 The payload of `core:event/lorebook-annex-changed@1`
1155
+ * (`core:shape/lorebook-annex-change@1`, M0, SHAPES L9): which owner's
1156
+ * document in which book's **lorebook annex** changed, and its keys. The
1157
+ * values are not carried — a spec reads them through
1158
+ * `core:query/lorebook-annex@1`.
1159
+ * @experimental
1160
+ */
1161
+ export interface LorebookAnnexChangePayload {
1162
+ event: string;
1163
+ lorebookId: number;
1164
+ /** Present when a session wrote it. */
1165
+ sessionId?: number;
1166
+ at: number;
1167
+ cause?: EventCause;
1168
+ lineage?: RunLineage;
1169
+ /** The owner whose document moved: a genre id, a plugin id, or `user:<slug>`. */
1170
+ owner: string;
1171
+ /** The keys of that document the write changed. */
1172
+ keys: string[];
1173
+ }
1174
+ /**
1175
+ * 🚧 The payload of `core:event/message-settled@1`
1176
+ * (`core:shape/message-settled@1`, speech follow-ups A1): one line a run
1177
+ * wrote, once that run closed its receipt.
1178
+ *
1179
+ * ⚠ Not `message-completed@1` (per write, during the run), and not the
1180
+ * settle line / `history-settled@1` (history fixed).
1181
+ * @experimental
1182
+ */
1183
+ export interface MessageSettledPayload {
1184
+ event: string;
1185
+ sessionId: number;
1186
+ at: number;
1187
+ cause?: EventCause;
1188
+ lineage?: RunLineage;
1189
+ /** The line. */
1190
+ messageId: number;
1191
+ /** The channel the line is on (canonical; `main` when it names none). */
1192
+ channel: string;
1193
+ /**
1194
+ * The key of the node that wrote the line in the run that settled it (its
1195
+ * `pipeline_run_artifacts.node_key`); null for a line no node wrote (a
1196
+ * stopped reply whose placeholder the run's finalisation released).
1197
+ */
1198
+ step: string | null;
1199
+ /**
1200
+ * Which version of the line this is: the index of its active swipe
1201
+ * (`metadata.swipes.currentIdx`), 0 for a line never swiped. A regenerated
1202
+ * or swiped line settles again with a new revision.
1203
+ */
1204
+ revision: number;
1205
+ /** The participant reference that spoke it (`character:<id>`, `envoy:<slug>`, `user:<id>`, …); null for the narrator. */
1206
+ speakerRef: string | null;
1207
+ /** `reply` a character's or envoy's line, `narration` a narrator row, `user` a person's own saved send. */
1208
+ kind: 'reply' | 'narration' | 'user';
1209
+ }
1210
+ /**
1211
+ * 🚧 The payload of `core:event/ruleset-converted@1`
1212
+ * (`core:shape/ruleset-conversion@1`, M0, SHAPES L4 Conversion): the
1213
+ * session whose rules moved, from which version to which, and what happened
1214
+ * to the slots.
1215
+ * @experimental
1216
+ */
1217
+ export interface RulesetConversionPayload {
1218
+ event: string;
1219
+ sessionId: number;
1220
+ at: number;
1221
+ cause?: EventCause;
1222
+ lineage?: RunLineage;
1223
+ /** The ruleset, `<owner>:ruleset/<name>@<n>`. */
1224
+ rulesetId: string;
1225
+ /** The version the session played before (semver). */
1226
+ from: string;
1227
+ /** The version it plays now (semver). */
1228
+ to: string;
1229
+ slots: {
1230
+ /** Old slot id → new slot id, re-keyed. */
1231
+ renamed: Record<string, string>;
1232
+ /** Slot ids retracted. */
1233
+ removed: string[];
1234
+ /** Slot id → the default inserted for it. */
1235
+ added: Record<string, unknown>;
1236
+ };
1237
+ }
1074
1238
  /**
1075
1239
  * The payload of `core:event/turn-order-changed@1`
1076
1240
  * (`core:shape/turn-order-changed@1`): the order as