@serene-pub/sdk 0.6.0-pr-1

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 (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
package/dist/events.js ADDED
@@ -0,0 +1,633 @@
1
+ /**
2
+ * The event registry (01 §8 / F8, 13 §7 and §7g).
3
+ *
4
+ * No node emits: a write causes the event its outlet declares. Core's events are a
5
+ * closed set; a package declares its own with `defineSessionEvent()` and records one
6
+ * with the `record-event` write. Both kinds live in this registry.
7
+ *
8
+ * Two things here are deliberate and both were rulings, not conveniences:
9
+ *
10
+ * 1. **`slug` is the stable reference, not the id.** The primary key differs between
11
+ * instances because it autoincrements; the slug is what lets a seeded row be
12
+ * identified, synced and updated across instances and upgrades. Same convention
13
+ * belongs on every core-seeded registry — types, surfaces, shapes — so there is
14
+ * one identity convention rather than four.
15
+ *
16
+ * 2. **Two families.** A *data* event says something changed and carries write-target
17
+ * mappings, so it participates in the write → event → subscription cycle check.
18
+ * An *action* event says someone asked — a click, a scheduler tick. It has no write
19
+ * targets, so it drops out of the cycle graph instead of needing an exception.
20
+ * Without the distinction, `ui-action` would either blur F8's "occurrences core
21
+ * observes" or need a special case in the CTE.
22
+ */
23
+ import { refuseUnlessIdentical } from './hash.js';
24
+ import { S, getShape } from './shapes.js';
25
+ import { i18nFindings, i18nText } from './i18n.js';
26
+ const bySlug = new Map();
27
+ let nextId = 1;
28
+ /** @experimental */
29
+ export function defineEvent(def) {
30
+ const existing = bySlug.get(def.slug);
31
+ // Built against the id the slug already holds, so an identical re-declaration
32
+ // compares like for like and — the part that matters here rather than in the
33
+ // other registries — does not consume a second number from the sequence. The
34
+ // id is local; the slug is what syncs the row across instances, and a module
35
+ // re-evaluating must not renumber what it re-declares.
36
+ const e = { ...def, id: existing?.id ?? nextId, ownerPluginId: null };
37
+ if (existing)
38
+ refuseUnlessIdentical(existing, e, `duplicate event slug '${def.slug}' — slugs are unique because they are the ` +
39
+ `reference used to sync seeded rows across pubs (13 §7g)`);
40
+ if (def.family === 'action' && def.causedBy?.length) {
41
+ throw new Error(`action event '${def.slug}' declares causedBy. Action events are requests, not ` +
42
+ `consequences of a write — that is what keeps them out of the cycle graph (13 §7)`);
43
+ }
44
+ if (def.declaredRoot && def.causedBy?.length) {
45
+ throw new Error(`event '${def.slug}' is a declared root and declares causedBy — a root starts outside ` +
46
+ `every pipeline, so nothing writes it. Drop one of the two`);
47
+ }
48
+ if (!existing)
49
+ nextId++;
50
+ bySlug.set(def.slug, e);
51
+ return e;
52
+ }
53
+ /** @internal */
54
+ export const getEvent = (slug) => bySlug.get(slug);
55
+ /**
56
+ * The event an id names — core's (`core:event/message-completed@1`) or one a
57
+ * package declared — or `undefined`. Core's are keyed by bare slug, so the
58
+ * owner and version are checked here rather than trusted:
59
+ * `acme:event/message-completed@1` is not core's event.
60
+ * @experimental
61
+ */
62
+ export function eventById(id) {
63
+ const m = /^core:event\/([a-z0-9]+(?:-[a-z0-9]+)*)@(\d+)$/.exec(id);
64
+ if (!m)
65
+ return packageEventViews.get(id);
66
+ const e = bySlug.get(m[1]);
67
+ // Compared as written: `@01` is not `@1`, and would match no binding key.
68
+ return e && String(e.version) === m[2] ? e : undefined;
69
+ }
70
+ /**
71
+ * The sentence every door refuses an undeclared event with: a lock, a
72
+ * `causesEvent`, a recording. One wording, so a modder meets the same fix
73
+ * wherever the mistake was written.
74
+ * @experimental
75
+ */
76
+ export const notADeclaredEvent = (id) => `'${id}' is not a declared event — core defines its own, and a package declares one with ` +
77
+ `defineSessionEvent({ id, payload, … }) and names it in defineExtension({ events }).`;
78
+ /** @internal */
79
+ export const allEvents = () => [...bySlug.values()];
80
+ /**
81
+ * `owner:event/name@N` — the grammar every event key wears since R-4: a
82
+ * genre's event surface, a preset's `bindings` map and a spec's inlet lock
83
+ * are keyed by this and nothing else. The owner segment matches the genre
84
+ * id's (`core`, `acme.rp`); the name is lowercase-hyphenated; the version
85
+ * is a whole number.
86
+ * @experimental
87
+ */
88
+ export const EVENT_ID = /^[a-z0-9]+(?:[.-][a-z0-9]+)*:event\/[a-z0-9]+(?:-[a-z0-9]+)*@\d+$/;
89
+ /**
90
+ * Is this string an event id? A bare name (`message-respond`) is not, and a
91
+ * host that stored bare keys before the fold migrates them once — it never
92
+ * accepts a new one (plans/30 §U3 review, W6).
93
+ * @internal
94
+ */
95
+ export const isEventId = (id) => EVENT_ID.test(id);
96
+ /**
97
+ * The events the inter-spec cycle CTE reads (F9). Action events are excluded by
98
+ * construction rather than by an exception someone has to remember.
99
+ * @experimental
100
+ */
101
+ export const cycleRelevantEvents = () => allEvents().filter((e) => e.family === 'data');
102
+ /** @experimental */
103
+ export function _clearEvents() {
104
+ bySlug.clear();
105
+ packageEvents.clear();
106
+ packageEventViews.clear();
107
+ nextId = 1;
108
+ }
109
+ const packageEvents = new Map();
110
+ const packageEventViews = new Map();
111
+ /** The shape every recorded event reaches a listener in (see `RecordedEventPayload`). @experimental */
112
+ export const RECORDED_EVENT_SHAPE = 'core:shape/recorded-event@1';
113
+ /**
114
+ * Declare an event your package's pipelines record. The id is under
115
+ * your package's slug; the payload is a shape id, and a pipeline that records
116
+ * the event is checked against it at publish. Registered on declaration, so a
117
+ * spec's inlet may lock on it: `.inlet('e', C.sessionEvent.v1(), { genre,
118
+ * events: [guessed] })`.
119
+ * @experimental
120
+ */
121
+ export function defineSessionEvent(d) {
122
+ if (!EVENT_ID.test(d.id) || d.id.startsWith('core:') || /@0\d/.test(d.id))
123
+ throw new Error(`'${d.id}' is not an event id a package may declare — '<your slug>:event/<name>@<version>', ` +
124
+ `lowercase and hyphenated, the version a whole number; 'core:' is core's`);
125
+ const text = [...i18nFindings(d.name, 'name', { required: true }), ...i18nFindings(d.description, 'description')];
126
+ if (text.length)
127
+ throw new Error(`event '${d.id}': ${text.join('; ')}`);
128
+ if ('delivery' in d)
129
+ throw new Error(`event '${d.id}': an event has no 'delivery' — it is heard by everything in its scope. ` +
130
+ `Remove it, and keep anything secret in state, not in the event`);
131
+ const payloadId = typeof d.payload === 'string' ? d.payload : d.payload?.id;
132
+ if (!payloadId || !getShape(payloadId))
133
+ throw new Error(`event '${d.id}': payload '${String(payloadId)}' is not a registered shape — pass one of S.*`);
134
+ // The declaration travels as data in the manifest and a package's own
135
+ // shapes do not, so an instance could not re-declare the event.
136
+ if (!payloadId.startsWith('core:'))
137
+ throw new Error(`event '${d.id}': payload '${payloadId}' is your package's own shape, which an installed ` +
138
+ `package cannot carry yet — use S.json and check the payload in the listener`);
139
+ const decl = Object.freeze({
140
+ __decl: 'session-event',
141
+ id: d.id,
142
+ payload: payloadId,
143
+ name: d.name,
144
+ description: d.description,
145
+ domain: 'session',
146
+ });
147
+ const existing = packageEvents.get(d.id);
148
+ if (existing)
149
+ refuseUnlessIdentical(existing, decl, `event '${d.id}' is declared twice, differently`);
150
+ packageEvents.set(d.id, decl);
151
+ const [, version] = d.id.split('@');
152
+ packageEventViews.set(d.id, {
153
+ id: 0,
154
+ slug: d.id,
155
+ version: Number(version),
156
+ family: 'data',
157
+ affectsUser: false,
158
+ causedBy: ['core:outlet/record-event'],
159
+ payload: RECORDED_EVENT_SHAPE,
160
+ name: typeof d.name === 'string' ? { en: d.name } : d.name,
161
+ description: i18nText(d.description) ?? '',
162
+ ownerPluginId: null,
163
+ });
164
+ return decl;
165
+ }
166
+ /** The most a recording's payload may weigh, serialized — it rides every listener's inlet and the ledger. @experimental */
167
+ export const MAX_RECORDED_PAYLOAD_BYTES = 64 * 1024;
168
+ /**
169
+ * What is wrong with a value recorded as an event's payload, or undefined.
170
+ * The host's check at the write: plain JSON, within the size cap, and a
171
+ * string where the declared shape is text. Publish checks the wiring; this
172
+ * checks the value that actually arrived.
173
+ * @experimental
174
+ */
175
+ export function recordedPayloadFindings(shape, value) {
176
+ let json;
177
+ try {
178
+ json = JSON.stringify(value ?? null);
179
+ }
180
+ catch {
181
+ return 'the payload is not plain JSON (a cycle, or a value JSON cannot carry)';
182
+ }
183
+ if (json === undefined)
184
+ return 'the payload is not plain JSON';
185
+ const bytes = new TextEncoder().encode(json).length;
186
+ if (bytes > MAX_RECORDED_PAYLOAD_BYTES)
187
+ return `the payload is ${bytes} bytes; a recording carries at most ${MAX_RECORDED_PAYLOAD_BYTES}`;
188
+ if (shape === 'core:shape/text@1' && typeof value !== 'string')
189
+ return `the event's payload is text, and ${value === null || value === undefined ? 'nothing' : typeof value} arrived`;
190
+ return undefined;
191
+ }
192
+ /**
193
+ * Withdraw a package event, so an upgraded package may declare it again,
194
+ * differently. The host's to call on uninstall and reinstall.
195
+ * @internal
196
+ */
197
+ export function _withdrawSessionEvent(id) {
198
+ packageEvents.delete(id);
199
+ packageEventViews.delete(id);
200
+ }
201
+ /** A package event by id, or undefined. @experimental */
202
+ export const packageEventById = (id) => packageEvents.get(id);
203
+ /** Whether a value is an event declaration (so a literal can be written as its id). @experimental */
204
+ export const isSessionEventDecl = (v) => !!v && typeof v === 'object' && v.__decl === 'session-event';
205
+ // ── The closed core set — THE ONE registry (R-4, ruled 2026-09-15) ──────────
206
+ //
207
+ // The genre's session events (24 §5) are core events, folded in here from
208
+ // `genres.ts` 2026-09-16 (09-B B5): `core:event/session-created@1`,
209
+ // `…/message-respond@1`, `…/session-action@1`, `…/member-added@1`,
210
+ // `…/member-removed@1`. A preset binds a spec to one of these by id; the
211
+ // spec's inlet lock (`.inlet(key, node, { genre, event })`) is the only
212
+ // subscription there is. The DATA events core's outlets cause are here too, so
213
+ // a host projecting this set projects the whole registry and keeps no copy.
214
+ /** @experimental */
215
+ export const CORE_EVENTS = {
216
+ messageCreated: defineEvent({
217
+ slug: 'message-created',
218
+ name: { en: 'Message written' },
219
+ version: 1,
220
+ family: 'data',
221
+ affectsUser: true,
222
+ causedBy: ['core:outlet/create-message', 'core:outlet/seed-greetings'],
223
+ description: 'A message was written into a session.',
224
+ }),
225
+ /**
226
+ * A row was finished or rewritten by a pipeline's own write. A regenerate,
227
+ * a swipe's fresh alternative and an extend are THIS event with `verb`
228
+ * on the payload — `regenerate` · `swipe` · `extend` — rather than three
229
+ * events of their own (R-15, 2026-09-16): each is the genre's pipeline
230
+ * producing text plus core's rewrite of the row, and the rewrite is one
231
+ * outlet. A plain reply's finishing write carries no `verb`.
232
+ */
233
+ messageUpdated: defineEvent({
234
+ slug: 'message-updated',
235
+ name: { en: 'Message changed' },
236
+ version: 1,
237
+ family: 'data',
238
+ affectsUser: true,
239
+ causedBy: ['core:outlet/update-message', 'core:outlet/attach-image', 'core:outlet/attach-audio'],
240
+ payload: S.sessionChange,
241
+ description: 'An existing message was changed.',
242
+ }),
243
+ // ── The built-in writes (R-15, 2026-09-16) — DATA family, each caused ──
244
+ // by the core outlet that performs it. Every one carries what changed
245
+ // and what was lost, lands on the receipt as `emitted`, and is written to
246
+ // the session's changes so the next reply's inlet publishes it.
247
+ messageDeleted: defineEvent({
248
+ slug: 'message-deleted',
249
+ name: { en: 'Message deleted' },
250
+ version: 1,
251
+ family: 'data',
252
+ affectsUser: true,
253
+ causedBy: ['core:outlet/delete-message'],
254
+ payload: S.sessionChange,
255
+ description: 'A message was deleted. The payload carries what was lost — its content, role, speaker and metadata.',
256
+ }),
257
+ messageHidden: defineEvent({
258
+ slug: 'message-hidden',
259
+ name: { en: 'Message hidden or shown' },
260
+ version: 1,
261
+ family: 'data',
262
+ affectsUser: true,
263
+ causedBy: ['core:outlet/hide-message'],
264
+ payload: S.sessionChange,
265
+ description: 'A message was hidden from the prompt, or shown again. The payload says which.',
266
+ }),
267
+ messageEdited: defineEvent({
268
+ slug: 'message-edited',
269
+ name: { en: 'Message edited' },
270
+ version: 1,
271
+ family: 'data',
272
+ affectsUser: true,
273
+ causedBy: ['core:outlet/edit-message'],
274
+ payload: S.sessionChange,
275
+ description: "A person rewrote a settled message. The payload carries the previous content.",
276
+ }),
277
+ messageSwiped: defineEvent({
278
+ slug: 'message-swiped',
279
+ name: { en: 'Message swiped' },
280
+ version: 1,
281
+ family: 'data',
282
+ affectsUser: true,
283
+ causedBy: ['core:outlet/swipe-message'],
284
+ payload: S.sessionChange,
285
+ description: 'A different alternative of a message was selected, or a new one recorded. The payload carries the alternative that was showing and the index now selected.',
286
+ }),
287
+ /**
288
+ * A line's **shown sprite** changed (DESIGN-sprites §5.2): a sprite picker
289
+ * chose one after a reply, or a person changed it from the message menu.
290
+ * The payload names the line, the speaker, the `{ set, label }` now shown
291
+ * (null for none) and `source` — `picker` or `person`. What TTS line
292
+ * direction and any face-driven widget listen for.
293
+ */
294
+ spriteShown: defineEvent({
295
+ slug: 'sprite-shown',
296
+ name: { en: 'Sprite shown' },
297
+ version: 1,
298
+ family: 'data',
299
+ affectsUser: true,
300
+ causedBy: ['core:outlet/show-sprite'],
301
+ payload: S.sessionChange,
302
+ description: "A line's sprite changed — chosen by a sprite picker after a reply, or by a person. The payload carries the set and label now shown and who chose it.",
303
+ }),
304
+ /**
305
+ * Stop is not a write outlet: it is the run-level guarantee (R-17) —
306
+ * core finalises the row a cancelled run was filling — so it has no
307
+ * `causedBy`. Emitted by the host from that finalisation, and from the
308
+ * message's own Stop when it releases the row first.
309
+ */
310
+ messageStopped: defineEvent({
311
+ slug: 'message-stopped',
312
+ name: { en: 'Reply stopped' },
313
+ version: 1,
314
+ family: 'data',
315
+ affectsUser: true,
316
+ payload: S.sessionChange,
317
+ description: 'A reply was stopped while it was being written. The payload carries how much text had arrived.',
318
+ }),
319
+ sessionBranched: defineEvent({
320
+ slug: 'session-branched',
321
+ name: { en: 'Session branched' },
322
+ version: 1,
323
+ family: 'data',
324
+ affectsUser: true,
325
+ causedBy: ['core:outlet/branch-session'],
326
+ payload: S.sessionChange,
327
+ description: 'A session was branched at a message into a new session. The payload names the new session and the message it forked from.',
328
+ }),
329
+ // ── Turn order as event-driven state (PLAN-turn-order §4.1, 2026-09-21) ──
330
+ // The four events the turn-order spec answers or causes. Every session
331
+ // event's payload carries a `cause` (`EventCause`): who or what fired
332
+ // it, which is what the auto-advance listener keys on.
333
+ /**
334
+ * A row that is **not generating** landed: a user send, a seeded
335
+ * greeting, a finalised reply, a stopped reply. Never for a placeholder
336
+ * or a generating row — the reply's *completion* is the fact, not its
337
+ * opening. Distinct from `message-created` (which fires at the write,
338
+ * placeholder included) and `message-updated` (which also fires on an
339
+ * attach): this is the one event that means "there is a new settled
340
+ * turn to answer".
341
+ */
342
+ messageCompleted: defineEvent({
343
+ slug: 'message-completed',
344
+ name: { en: 'Message completed' },
345
+ version: 1,
346
+ family: 'data',
347
+ affectsUser: true,
348
+ causedBy: [
349
+ 'core:outlet/create-message',
350
+ 'core:outlet/seed-greetings',
351
+ 'core:outlet/update-message',
352
+ ],
353
+ payload: S.sessionChange,
354
+ description: 'A message finished landing — a send, a seeded greeting, a finished or stopped reply. Never a placeholder or a row still being written.',
355
+ }),
356
+ /**
357
+ * A seated participant's row changed — switched on or off (`active`),
358
+ * `position` or portrayal. Not add or remove: those stay
359
+ * `member-added` / `member-removed`. No `causedBy`: the cast toggles are
360
+ * socket writes, not an outlet's.
361
+ */
362
+ castChanged: defineEvent({
363
+ slug: 'cast-changed',
364
+ declaredRoot: true,
365
+ name: { en: 'Cast changed' },
366
+ version: 1,
367
+ family: 'data',
368
+ affectsUser: true,
369
+ payload: S.castChange,
370
+ description: 'A session character, persona or envoy row changed — switched on or off, position or portrayal. The payload names the participant and what moved.',
371
+ }),
372
+ /**
373
+ * The session row changed. Two origins: a person's settings write
374
+ * (`sessions:update` and the other settings sockets — name, scenario,
375
+ * lorebook, genre fields, preset, channels, tags; cause `settings`), and
376
+ * `core:outlet/advance-story-clock`, which moves the session's story
377
+ * clock (`changed: ['storyClock']`, cause `run`). The payload's `changed`
378
+ * lists the fields by name. `causedBy` names the outlet, so the event map
379
+ * draws the edge a spec bound here that advances the clock would loop
380
+ * on; it is therefore not a declared root, though a person's write also
381
+ * starts it (as the auto-advance listener also causes `message-respond`).
382
+ * ⚠ Never emitted by `writeTurnOrder`, which is raw SQL for exactly this
383
+ * reason (§3).
384
+ */
385
+ sessionUpdated: defineEvent({
386
+ slug: 'session-updated',
387
+ name: { en: 'Session updated' },
388
+ version: 1,
389
+ family: 'data',
390
+ affectsUser: true,
391
+ causedBy: ['core:outlet/advance-story-clock'],
392
+ payload: S.sessionChange,
393
+ description: "The session's settings changed — name, scenario, lorebook, genre fields, preset, channels or tags — or a pipeline moved its story clock. The payload lists which.",
394
+ }),
395
+ /**
396
+ * `metadata.turnOrder` was written by `core:outlet/set-turn-order@1`.
397
+ * **Core-internal**: the auto-advance listener and the
398
+ * `sessions:turnOrder` push read it; `genre()` refuses it in a genre's
399
+ * `events`, so no preset can bind a spec to it and the recompute cannot
400
+ * feed itself.
401
+ */
402
+ turnOrderChanged: defineEvent({
403
+ slug: 'turn-order-changed',
404
+ name: { en: 'Turn order changed' },
405
+ version: 1,
406
+ family: 'data',
407
+ affectsUser: true,
408
+ causedBy: ['core:outlet/set-turn-order'],
409
+ payload: S.turnOrderChanged,
410
+ description: "The session's turn order was recomputed and written. The payload carries the order as written and the cause that led to it.",
411
+ }),
412
+ /**
413
+ * A pipeline's annex entry changed: "my state changed", for any genre.
414
+ * A package writes its annex through `core:outlet/set-session-annex@1`
415
+ * and binds this; for a named happening of its own it declares an event
416
+ * and records it. Emitted only
417
+ * when the merged value differs from the stored one, so a spec that
418
+ * rewrites the same value cannot feed itself; the lineage caps stop the
419
+ * rest.
420
+ */
421
+ annexChanged: defineEvent({
422
+ slug: 'annex-changed',
423
+ name: { en: 'Annex changed' },
424
+ version: 1,
425
+ family: 'data',
426
+ affectsUser: true,
427
+ causedBy: ['core:outlet/set-session-annex', 'core:outlet/set-annex-field'],
428
+ payload: S.annexChange,
429
+ description: "A pipeline's own session state changed — its annex entry. The payload names the owner whose entry moved.",
430
+ }),
431
+ /**
432
+ * Not a write's event: the marker the `sessionChanges` list ends with when
433
+ * more than fifty changes waited between two replies (U5b review S1). The
434
+ * newest fifty are delivered and this one entry says how many older ones
435
+ * were not, so a pipeline can tell a full list from a truncated one. Never
436
+ * written to `session_changes` and never on a receipt's `emitted` — no
437
+ * `causedBy`, because no outlet causes it.
438
+ */
439
+ sessionChangesTruncated: defineEvent({
440
+ slug: 'session-changes-truncated',
441
+ name: { en: 'Session changes truncated' },
442
+ version: 1,
443
+ family: 'data',
444
+ affectsUser: false,
445
+ payload: S.sessionChange,
446
+ description: 'More session changes waited than one reply is handed. The newest fifty were delivered; the payload says how many older ones were dropped.',
447
+ }),
448
+ /**
449
+ * A **form** — a `choices` or `form` block a message carries — was
450
+ * addressed to a participant the AI portrays this turn (R-15 *Forms*;
451
+ * R-21 (5); 30 §U5d). Caused by the write that carried the block, and
452
+ * dispatched through the same path as the lifecycle events, so every
453
+ * answer run is a child of the run that asked (`parentRunId`,
454
+ * `rootRunId`, `depth`) and 01 §8's cycle caps hold: a form whose answer
455
+ * asks another form stops at the depth cap, receipted. A form addressed
456
+ * to a person is no event: the block waits for the click.
457
+ */
458
+ formAddressed: defineEvent({
459
+ slug: 'form-addressed',
460
+ name: { en: 'Form addressed' },
461
+ version: 1,
462
+ family: 'data',
463
+ affectsUser: false,
464
+ causedBy: ['core:outlet/create-message', 'core:outlet/update-message'],
465
+ payload: S.formAddressed,
466
+ description: 'A question or form in a message was addressed to a participant the AI portrays this turn — the genre\'s answer pipeline answers it. The payload names the message, the block, the action and the addressee.',
467
+ }),
468
+ /**
469
+ * A form was **answered** — by a click, or by the answer pipeline's
470
+ * outlet committing an oracle's answer exactly as a click would. Lands in
471
+ * the session's changes so the next reply's inlet sees it (`answer`,
472
+ * `addressee`, `blockId`, `action` on the payload).
473
+ */
474
+ formAnswered: defineEvent({
475
+ slug: 'form-answered',
476
+ name: { en: 'Form answered' },
477
+ version: 1,
478
+ family: 'data',
479
+ affectsUser: false,
480
+ causedBy: ['core:outlet/answer-form'],
481
+ payload: S.sessionChange,
482
+ description: 'A question or form in a message was answered. The payload carries the answer, who answered as whom, and the action it fired.',
483
+ }),
484
+ /**
485
+ * A form was **superseded** (plans/29 R-15 *Staleness and order*; 30
486
+ * §U5f): the channel head moved past the turn it was issued at before it
487
+ * was answered, and a press on it reached the door. Recorded ONCE per
488
+ * block, the first time the door sees it stale, so the next reply's
489
+ * inlet learns the question lapsed — not on every render, and never by a
490
+ * render. No outlet causes it: the door does, like the truncation marker.
491
+ */
492
+ formSuperseded: defineEvent({
493
+ slug: 'form-superseded',
494
+ name: { en: 'Form superseded' },
495
+ version: 1,
496
+ family: 'data',
497
+ affectsUser: false,
498
+ payload: S.sessionChange,
499
+ description: 'A question or form in a message was overtaken — the conversation moved on before it was answered, and a press on it was refused. The payload names the message and the block.',
500
+ }),
501
+ loreEntryCreated: defineEvent({
502
+ slug: 'lore-entry-created',
503
+ name: { en: 'Lore entry written' },
504
+ version: 1,
505
+ family: 'data',
506
+ affectsUser: true,
507
+ causedBy: ['core:outlet/create-lore-entry'],
508
+ description: 'A lorebook entry was written.',
509
+ }),
510
+ /**
511
+ * Two lore entries were linked (L2, 2026-09-17) — a room's exit, who keeps
512
+ * what, what stands near what.
513
+ *
514
+ * Its own event rather than `lore-entry-created`: a link is not an entry,
515
+ * nothing about it is created or changed, and a subscriber that wants to
516
+ * redraw a map wants exactly this and none of the writes that make rows.
517
+ *
518
+ * ⚠ It declares no payload shape — it rides the run's receipt as caused by
519
+ * the outlet, and the link itself (its name, its words both ways) is the
520
+ * outlet's `linkId` row, read where it is needed (places plan B2,
521
+ * 2026-09-29). An idempotent repeat that found the standing row wrote
522
+ * nothing, and causes no event (`written: false`).
523
+ */
524
+ loreLinkCreated: defineEvent({
525
+ slug: 'lore-link-created',
526
+ name: { en: 'Lore entries linked' },
527
+ version: 1,
528
+ family: 'data',
529
+ affectsUser: true,
530
+ causedBy: ['core:outlet/link-lore-entries'],
531
+ description: 'Two lorebook entries were linked.',
532
+ }),
533
+ graphProposalCreated: defineEvent({
534
+ slug: 'graph-proposal-created',
535
+ name: { en: 'Graph proposal filed' },
536
+ version: 1,
537
+ family: 'data',
538
+ affectsUser: true,
539
+ causedBy: ['core:outlet/graph-proposal'],
540
+ description: 'A narrative-graph proposal was filed for review.',
541
+ }),
542
+ // ── The session lifecycle (24 §5) — ACTION family: a person did it ──────
543
+ /** The create slot — required; exactly one pipeline per genre answers it. */
544
+ sessionCreated: defineEvent({
545
+ slug: 'session-created',
546
+ declaredRoot: true,
547
+ name: { en: 'Session created' },
548
+ version: 1,
549
+ family: 'action',
550
+ affectsUser: false,
551
+ description: "A session was created — the genre's create pipeline answers this.",
552
+ }),
553
+ /** The primary turn. A swipe is this pipeline re-run, not a new event. */
554
+ messageRespond: defineEvent({
555
+ slug: 'message-respond',
556
+ declaredRoot: true,
557
+ name: { en: 'Reply' },
558
+ version: 1,
559
+ family: 'action',
560
+ affectsUser: true,
561
+ description: 'A reply was asked for — the primary turn of a session.',
562
+ }),
563
+ /** Arbitrary buttons/triggers — the contributed functions surface (19 §3). */
564
+ sessionAction: defineEvent({
565
+ slug: 'session-action',
566
+ declaredRoot: true,
567
+ name: { en: 'Action' },
568
+ version: 1,
569
+ family: 'action',
570
+ affectsUser: true,
571
+ description: 'A person triggered a contributed action in a session.',
572
+ }),
573
+ memberAdded: defineEvent({
574
+ slug: 'member-added',
575
+ declaredRoot: true,
576
+ name: { en: 'Member joined' },
577
+ version: 1,
578
+ family: 'action',
579
+ affectsUser: false,
580
+ // A seat is a cast change (R31): `change: 'added'`, `ref` the member.
581
+ payload: S.castChange,
582
+ description: 'A character, persona or envoy joined a session; the payload carries which.',
583
+ }),
584
+ memberRemoved: defineEvent({
585
+ slug: 'member-removed',
586
+ declaredRoot: true,
587
+ name: { en: 'Member left' },
588
+ version: 1,
589
+ family: 'action',
590
+ affectsUser: false,
591
+ // An unseat is a cast change (R31): `change: 'removed'`, `ref` the member.
592
+ payload: S.castChange,
593
+ description: 'A character, persona or envoy left a session; the payload carries which.',
594
+ }),
595
+ /**
596
+ * A UI action asked for a run (13 §7). Carrying both users is what answers the
597
+ * budget-owner question without a separate rule: **budget and quota attach to the
598
+ * owner; the receipt's attribution records the trigger.** Group sessions need no
599
+ * special case.
600
+ *
601
+ * ⏳ Overlaps `session-action` since the fold (a contributed action IS a UI
602
+ * action). Kept because ruling 49 (`UiActionPayload`, the owner/trigger
603
+ * split) has no other home yet; nothing subscribes to it. Retire when the
604
+ * action model (30 §U5) gives the payload one.
605
+ */
606
+ uiAction: defineEvent({
607
+ slug: 'ui-action',
608
+ name: { en: 'Interface action' },
609
+ version: 1,
610
+ family: 'action',
611
+ affectsUser: true,
612
+ description: 'Someone asked for a run from the interface — a composer action, a message action, ' +
613
+ 'a re-roll. Payload: sessionId, ownerUserId, actorUserId, action, modeId, input.',
614
+ }),
615
+ /**
616
+ * The path for scheduled model work (13 §7c). No callable may call an oracle
617
+ * (F32), and lifecycle callbacks may not trigger pipelines, so nightly
618
+ * summarization subscribes here instead — which also puts it on the consent
619
+ * screen, where a lifecycle callback doing the same work would have been
620
+ * invisible. Serene Pub emits it hourly (`cadence: 'hourly'`, `scheduledFor`
621
+ * the ISO instant it was due, `scope: 'pub'`), only to subscribed,
622
+ * granted listeners; `SCHEDULED_WORK_PATH` names it.
623
+ */
624
+ scheduleTick: defineEvent({
625
+ slug: 'schedule-tick',
626
+ name: { en: 'Schedule tick' },
627
+ version: 1,
628
+ family: 'action',
629
+ affectsUser: false,
630
+ description: 'A declared cadence elapsed. Payload: cadence, scheduledFor, scope.',
631
+ }),
632
+ };
633
+ //# sourceMappingURL=events.js.map