@serene-pub/sdk 0.6.0-pr-4 → 0.6.0-pr-5

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 (186) hide show
  1. package/README.md +23 -19
  2. package/dist/actions.d.ts +149 -67
  3. package/dist/actions.js +89 -35
  4. package/dist/annexFields.d.ts +8 -4
  5. package/dist/annexFields.js +5 -2
  6. package/dist/announce.d.ts +78 -28
  7. package/dist/announce.js +14 -5
  8. package/dist/attributes.d.ts +9 -6
  9. package/dist/attributes.js +9 -5
  10. package/dist/bands.d.ts +41 -6
  11. package/dist/bands.js +83 -33
  12. package/dist/builder.d.ts +161 -58
  13. package/dist/builder.js +128 -22
  14. package/dist/candidates.d.ts +5 -3
  15. package/dist/candidates.js +3 -2
  16. package/dist/clauses.d.ts +2 -1
  17. package/dist/clauses.js +2 -1
  18. package/dist/component.d.ts +24 -7
  19. package/dist/component.js +16 -6
  20. package/dist/componentBuild.d.ts +16 -5
  21. package/dist/componentBuild.js +14 -5
  22. package/dist/componentClient.d.ts +61 -30
  23. package/dist/componentClient.js +11 -1
  24. package/dist/componentImports.d.ts +8 -5
  25. package/dist/componentImports.js +23 -4
  26. package/dist/componentModule.js +2 -1
  27. package/dist/componentWire.d.ts +2 -1
  28. package/dist/componentWire.js +34 -2
  29. package/dist/config.d.ts +28 -14
  30. package/dist/config.js +20 -10
  31. package/dist/connections.d.ts +9 -4
  32. package/dist/connections.js +7 -4
  33. package/dist/declarations.d.ts +46 -17
  34. package/dist/declarations.js +46 -15
  35. package/dist/descriptors.d.ts +242 -97
  36. package/dist/descriptors.js +145 -41
  37. package/dist/dev.d.ts +6 -5
  38. package/dist/dev.js +6 -5
  39. package/dist/document.d.ts +74 -25
  40. package/dist/document.js +32 -11
  41. package/dist/dowry.d.ts +241 -0
  42. package/dist/dowry.js +315 -0
  43. package/dist/engines.d.ts +16 -7
  44. package/dist/engines.js +6 -4
  45. package/dist/eventMapLaws.d.ts +19 -8
  46. package/dist/eventMapLaws.js +9 -6
  47. package/dist/events.d.ts +101 -39
  48. package/dist/events.js +106 -33
  49. package/dist/executor.d.ts +122 -41
  50. package/dist/executor.js +188 -95
  51. package/dist/extension.d.ts +99 -35
  52. package/dist/extension.js +43 -9
  53. package/dist/facets.d.ts +2 -1
  54. package/dist/facets.js +4 -2
  55. package/dist/foldedSections.d.ts +4 -2
  56. package/dist/foldedSections.js +2 -1
  57. package/dist/genres.d.ts +123 -41
  58. package/dist/genres.js +127 -22
  59. package/dist/guardedConnection.d.ts +4 -3
  60. package/dist/guardedConnection.js +4 -3
  61. package/dist/handlebarsReach.d.ts +1 -1
  62. package/dist/handlebarsReach.js +1 -1
  63. package/dist/hash.d.ts +16 -5
  64. package/dist/hash.js +14 -4
  65. package/dist/hookGrants.d.ts +3 -2
  66. package/dist/hookGrants.js +6 -4
  67. package/dist/hooks.d.ts +21 -16
  68. package/dist/hooks.js +12 -10
  69. package/dist/hostElements.d.ts +41 -17
  70. package/dist/hostElements.js +49 -17
  71. package/dist/i18n.d.ts +5 -3
  72. package/dist/i18n.js +5 -3
  73. package/dist/identity.d.ts +4 -3
  74. package/dist/identity.js +4 -3
  75. package/dist/index.d.ts +5 -0
  76. package/dist/index.js +15 -0
  77. package/dist/layout.d.ts +36 -15
  78. package/dist/layout.js +2 -2
  79. package/dist/loadouts.d.ts +97 -0
  80. package/dist/loadouts.js +81 -0
  81. package/dist/media.d.ts +26 -4
  82. package/dist/media.js +2 -1
  83. package/dist/messageBlocks.d.ts +44 -32
  84. package/dist/messageBlocks.js +23 -18
  85. package/dist/migration.d.ts +16 -8
  86. package/dist/migration.js +14 -8
  87. package/dist/names.d.ts +2 -1
  88. package/dist/names.js +2 -1
  89. package/dist/nodeInput.d.ts +2 -1
  90. package/dist/nodeInput.js +2 -1
  91. package/dist/participants.d.ts +22 -15
  92. package/dist/participants.js +14 -12
  93. package/dist/personGate.d.ts +2 -1
  94. package/dist/personGate.js +2 -1
  95. package/dist/pluginHarness.d.ts +8 -3
  96. package/dist/pluginHarness.js +4 -2
  97. package/dist/pluginPermissions.d.ts +2 -1
  98. package/dist/pluginPermissions.js +12 -1
  99. package/dist/pluginRuleRef.d.ts +2 -2
  100. package/dist/pluginRuleRef.js +1 -1
  101. package/dist/predicates.d.ts +16 -11
  102. package/dist/predicates.js +7 -6
  103. package/dist/preview.d.ts +8 -3
  104. package/dist/preview.js +2 -1
  105. package/dist/promptBlocks.d.ts +5 -3
  106. package/dist/promptBlocks.js +5 -3
  107. package/dist/rankingDecisions.d.ts +2 -1
  108. package/dist/rankingDecisions.js +2 -1
  109. package/dist/receipt.d.ts +65 -29
  110. package/dist/receipt.js +9 -4
  111. package/dist/receiverRules.js +3 -2
  112. package/dist/refs.d.ts +34 -9
  113. package/dist/refs.js +33 -13
  114. package/dist/registry.d.ts +42 -23
  115. package/dist/registry.js +7 -5
  116. package/dist/review.d.ts +16 -5
  117. package/dist/review.js +11 -4
  118. package/dist/sampling.d.ts +54 -0
  119. package/dist/sampling.js +95 -3
  120. package/dist/sceneSettings.d.ts +312 -0
  121. package/dist/sceneSettings.js +425 -0
  122. package/dist/scope.d.ts +6 -4
  123. package/dist/scope.js +4 -3
  124. package/dist/scripts.d.ts +81 -14
  125. package/dist/scripts.js +90 -11
  126. package/dist/sessionDossier.d.ts +521 -0
  127. package/dist/sessionDossier.js +33 -0
  128. package/dist/sessionLayout.d.ts +303 -19
  129. package/dist/sessionLayout.js +354 -40
  130. package/dist/sessionSettings.d.ts +8 -5
  131. package/dist/settings.d.ts +45 -20
  132. package/dist/settings.js +19 -12
  133. package/dist/settingsSlot.d.ts +11 -8
  134. package/dist/settingsSlot.js +11 -8
  135. package/dist/shapes.d.ts +99 -36
  136. package/dist/shapes.js +101 -35
  137. package/dist/sheets.d.ts +4 -2
  138. package/dist/sheets.js +6 -3
  139. package/dist/statShapes.d.ts +2 -1
  140. package/dist/statShapes.js +2 -1
  141. package/dist/status.d.ts +13 -9
  142. package/dist/status.js +8 -6
  143. package/dist/storage.d.ts +2 -1
  144. package/dist/storage.js +2 -1
  145. package/dist/storyTime.d.ts +13 -7
  146. package/dist/storyTime.js +11 -6
  147. package/dist/strokes.d.ts +176 -0
  148. package/dist/strokes.js +281 -0
  149. package/dist/surfaces.d.ts +54 -25
  150. package/dist/surfaces.js +3 -3
  151. package/dist/template.d.ts +9 -5
  152. package/dist/template.js +5 -3
  153. package/dist/templateCheck.d.ts +2 -2
  154. package/dist/templateCheck.js +2 -2
  155. package/dist/templateFit.d.ts +37 -8
  156. package/dist/templateFit.js +92 -8
  157. package/dist/templateIds.d.ts +3 -3
  158. package/dist/templateIds.js +3 -3
  159. package/dist/templateScopeAt.d.ts +21 -11
  160. package/dist/templateScopeAt.js +21 -11
  161. package/dist/testing.d.ts +11 -4
  162. package/dist/testing.js +13 -5
  163. package/dist/tokenizers.d.ts +2 -2
  164. package/dist/tokenizers.js +2 -2
  165. package/dist/turnLock.d.ts +4 -2
  166. package/dist/turnLock.js +2 -1
  167. package/dist/turnOrder.d.ts +17 -11
  168. package/dist/turnOrder.js +9 -5
  169. package/dist/validate.d.ts +11 -8
  170. package/dist/validate.js +81 -10
  171. package/dist/values.d.ts +17 -8
  172. package/dist/values.js +11 -6
  173. package/dist/variables.d.ts +46 -7
  174. package/dist/variables.js +87 -6
  175. package/dist/verdicts.d.ts +20 -13
  176. package/dist/verdicts.js +17 -11
  177. package/dist/widgetDecls.d.ts +8 -4
  178. package/dist/widgetDecls.js +4 -2
  179. package/dist/widgets.d.ts +987 -94
  180. package/dist/widgets.js +93 -18
  181. package/dist/wire.d.ts +13 -6
  182. package/dist/wire.js +3 -3
  183. package/dist/worldinfo.d.ts +11 -6
  184. package/dist/worldinfo.js +8 -4
  185. package/host-elements.d.ts +13 -0
  186. package/package.json +1 -1
package/dist/bands.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Bands as template variables (typed templates P2, 2026-09-27).
2
+ * Bands as template variables.
3
3
  *
4
4
  * A **band** is the ranker's word for one source's slice of the context window
5
5
  * (`bandIntent`, candidates.ts). A source that puts its own band in the window
@@ -27,9 +27,10 @@
27
27
  * when the slot says `rendersBands` — every band declared upstream of the
28
28
  * named in-port, followed through any node that takes candidates in
29
29
  * (concatenation, fusion, ranking). `rendersAt` is that answer.
30
+ * @ruling typed templates P2 (2026-09-27)
30
31
  */
31
32
  import { getDefinition } from './descriptors.js';
32
- import { allVariables, getVariable } from './variables.js';
33
+ import { getVariable } from './variables.js';
33
34
  /**
34
35
  * The shape a candidates port carries. Written out rather than imported from
35
36
  * `shapes.ts`, which reaches the descriptor module this one is read from.
@@ -64,15 +65,7 @@ export const ASSEMBLE_OWN_TEMPLATE_NAMES = [
64
65
  ];
65
66
  /** The declared variable id of one band entry — a declaration, or its id as a registry row carries it. */
66
67
  const variableIdOf = (v) => typeof v === 'string' ? v : v?.id;
67
- /**
68
- * A **core** variable that already renders a top-level name, if any — the
69
- * names core's own nodes put in a template (`characters`, `scenario`, …). A
70
- * plugin variable sharing a root is not by itself a collision: two plugins'
71
- * bands meaning different things is, and the definitions check names both.
72
- */
73
- const otherVariableRendering = (key, id) => allVariables().find((v) => v.id !== id &&
74
- v.id.startsWith('core:') &&
75
- Object.prototype.hasOwnProperty.call(v.scope, key));
68
+ const hasOwn = (o, key) => Object.prototype.hasOwnProperty.call(o, key);
76
69
  /**
77
70
  * Refuse a definition's band declarations — at `describe…Definition`, where
78
71
  * the author is.
@@ -80,14 +73,18 @@ const otherVariableRendering = (key, id) => allVariables().find((v) => v.id !==
80
73
  * - the key is an identifier (a band is a template name);
81
74
  * - the variable is registered (`defineVariable` / `definePluginVariable`) and
82
75
  * its scope declares the key, because a layout renders `{ [key]: value }`;
83
- * - the key does not shadow a name core renders — Assemble's own, or a
84
- * core variable's that is not this band's own variable;
85
- * - no other registered definition declares the key with a different variable.
76
+ * - the key is not one of Assemble's own names.
77
+ *
78
+ * **Not refused here: a key some other definition, or some core variable,
79
+ * already uses** (owner ruling 2026-10-13, ★1). A key is a local name and
80
+ * means one variable *within one template's scope* — `bandsReaching` and
81
+ * `rendersAt` refuse two meanings meeting in one document, and law T1 reports
82
+ * it. Two pipelines that never meet may each mean their own `characterLore`.
86
83
  *
87
84
  * Each refusal names the fix.
88
85
  * @internal
89
86
  */
90
- export function checkBandDeclarations(d, others) {
87
+ export function checkBandDeclarations(d) {
91
88
  const bands = d.bands;
92
89
  for (const key of Object.keys(d.bandPorts ?? {}))
93
90
  if (!bands || !Object.prototype.hasOwnProperty.call(bands, key))
@@ -121,11 +118,6 @@ export function checkBandDeclarations(d, others) {
121
118
  throw new Error(`'${d.id}' declares band '${key}', which collides with Assemble's own '${key}' — a ` +
122
119
  `template reading {{{${key}}}} would get one or the other depending on order. ` +
123
120
  `Rename the band.`);
124
- const core = otherVariableRendering(key, id);
125
- if (core)
126
- throw new Error(`'${d.id}' declares band '${key}' as '${id}', which collides with '${core.id}' — that ` +
127
- `variable already renders the top-level name '${key}'. A band key means one thing; ` +
128
- `rename the band.`);
129
121
  const ports = d.bandPorts?.[key];
130
122
  if (ports !== undefined) {
131
123
  const out = Object.keys(d.ports?.out ?? {});
@@ -139,17 +131,71 @@ export function checkBandDeclarations(d, others) {
139
131
  `that publish the band's candidates in bandPorts, or leave '${key}' out of bandPorts ` +
140
132
  `if every out-port may carry it.`);
141
133
  }
142
- for (const other of others) {
143
- if (other.id === d.id)
144
- continue;
145
- const theirs = variableIdOf(other.bands?.[key]);
146
- if (theirs && theirs !== id)
147
- throw new Error(`'${d.id}' declares band '${key}' as '${id}', but '${other.id}' already declares ` +
148
- `'${key}' as '${theirs}'. A band key is a top-level template name and means one ` +
149
- `thing — rename one of the two bands.`);
134
+ }
135
+ }
136
+ /**
137
+ * What is wrong with a node rendering `key` as `id`, as the end of a sentence
138
+ * that begins with what renders it — or `undefined` when nothing is.
139
+ *
140
+ * The facts a band declaration states, asked of every rendered key: a layout
141
+ * is written against its variable's scope and renders `{ [key]: value }`, so
142
+ * a key the scope does not name reaches no layout, and a variable nobody
143
+ * registered has no layout, no type and no picker.
144
+ * @internal
145
+ */
146
+ export function rendersProblem(key, id) {
147
+ if (!isBandKey(key))
148
+ return (`'${key}', which is not an identifier — a rendered key is a top-level template name. ` +
149
+ `Rename it '${bandKeySuggestion(key)}'.`);
150
+ if (typeof id !== 'string' || !id)
151
+ return `'${key}' without a variable. Name the variable it renders: { ${key}: 'core:var/…@1' }.`;
152
+ const v = getVariable(id);
153
+ if (!v)
154
+ return (`'${key}' as '${id}', which is not registered. Declare it with definePluginVariable() ` +
155
+ `(defineVariable() in core) before the definition or spec that names it — the layout ` +
156
+ `picker and the template editor read it from the registry.`);
157
+ if (!hasOwn(v.scope, key))
158
+ return (`'${key}' as '${id}', whose scope does not declare '${key}' (it declares ` +
159
+ `${Object.keys(v.scope).map((k) => `'${k}'`).join(', ') || 'nothing'}). A layout renders ` +
160
+ `the value as {{{${key}}}}, so add '${key}' to the variable's scope.`);
161
+ if (ASSEMBLE_OWN_TEMPLATE_NAMES.includes(key))
162
+ return `'${key}', which collides with Assemble's own '${key}'. Render it under another name.`;
163
+ return undefined;
164
+ }
165
+ /**
166
+ * Refuse a definition's static `renders` (owner ruling 2026-10-13) — at
167
+ * `describe…Definition`, like its bands, and for the same reasons
168
+ * (`rendersProblem`). Until then nothing read a `renders` entry until a run
169
+ * did, and a key whose variable did not declare it rendered nothing.
170
+ * @internal
171
+ */
172
+ export function checkRendersDeclarations(d) {
173
+ for (const [slotName, slot] of Object.entries((d.slots ?? {}))) {
174
+ if (slot.kind !== 'variables')
175
+ continue;
176
+ for (const [key, id] of Object.entries(slot.renders ?? {})) {
177
+ const problem = rendersProblem(key, id);
178
+ if (problem)
179
+ throw new Error(`'${d.id}' slot '${slotName}' renders ${problem}`);
150
180
  }
151
181
  }
152
182
  }
183
+ /**
184
+ * What one placement's `variables` slot renders, before any band: the slot's
185
+ * static `renders`, with each key the **spec's own `renders`** names for this
186
+ * node (`NodeOpts.renders`, owner ruling 2026-10-13) re-pointed at the
187
+ * spec's variable. Only keys the slot already renders — the spec says what a
188
+ * key *means* here, it does not add keys; `validate()` reports one it names
189
+ * that no slot renders (law T1).
190
+ * @experimental
191
+ */
192
+ export function effectiveRenders(slot, node) {
193
+ const out = { ...(slot.renders ?? {}) };
194
+ for (const [key, id] of Object.entries(node?.renders ?? {}))
195
+ if (hasOwn(out, key))
196
+ out[key] = id;
197
+ return out;
198
+ }
153
199
  /** Two declarers naming one band differently, or a band shadowing a name the node renders. @experimental */
154
200
  export class BandCollisionError extends Error {
155
201
  }
@@ -233,17 +279,21 @@ export function bandsReaching(doc, nodeKey, port, describe = defaultDescribe) {
233
279
  * @experimental
234
280
  */
235
281
  export function rendersAt(doc, nodeKey, slot, describe) {
236
- const out = { ...(slot.renders ?? {}) };
282
+ // The spec's own `renders` for this node first: a band reaching a key the
283
+ // spec re-pointed has to agree with the spec, not with the definition.
284
+ const own = effectiveRenders(slot, doc.nodes.find((n) => n.key === nodeKey));
285
+ const out = { ...own };
237
286
  const from = slot.rendersBands?.from;
238
287
  if (!from)
239
288
  return out;
240
289
  const reaching = bandsReaching(doc, nodeKey, from, describe);
241
290
  for (const [band, { variable, declarer }] of Object.entries(reaching)) {
242
- const own = slot.renders?.[band];
243
- if (own !== undefined) {
244
- if (own !== variable)
291
+ const mine = own[band];
292
+ if (mine !== undefined) {
293
+ if (mine !== variable)
245
294
  throw new BandCollisionError(`band '${band}' declared by ${declarer} as '${variable}' collides with '${nodeKey}''s ` +
246
- `own '${band}', which it renders as '${own}'. Rename the band.`);
295
+ `own '${band}', which it renders as '${mine}'. Rename the band, or — if this ` +
296
+ `spec means that band here — say so on the node: renders: { ${band}: '${variable}' }.`);
247
297
  continue;
248
298
  }
249
299
  if (ASSEMBLE_OWN_TEMPLATE_NAMES.includes(band))