@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.
- package/README.md +23 -19
- package/dist/actions.d.ts +149 -67
- package/dist/actions.js +89 -35
- package/dist/annexFields.d.ts +8 -4
- package/dist/annexFields.js +5 -2
- package/dist/announce.d.ts +78 -28
- package/dist/announce.js +14 -5
- package/dist/attributes.d.ts +9 -6
- package/dist/attributes.js +9 -5
- package/dist/bands.d.ts +41 -6
- package/dist/bands.js +83 -33
- package/dist/builder.d.ts +161 -58
- package/dist/builder.js +128 -22
- package/dist/candidates.d.ts +5 -3
- package/dist/candidates.js +3 -2
- package/dist/clauses.d.ts +2 -1
- package/dist/clauses.js +2 -1
- package/dist/component.d.ts +24 -7
- package/dist/component.js +16 -6
- package/dist/componentBuild.d.ts +16 -5
- package/dist/componentBuild.js +14 -5
- package/dist/componentClient.d.ts +61 -30
- package/dist/componentClient.js +11 -1
- package/dist/componentImports.d.ts +8 -5
- package/dist/componentImports.js +23 -4
- package/dist/componentModule.js +2 -1
- package/dist/componentWire.d.ts +2 -1
- package/dist/componentWire.js +34 -2
- package/dist/config.d.ts +28 -14
- package/dist/config.js +20 -10
- package/dist/connections.d.ts +9 -4
- package/dist/connections.js +7 -4
- package/dist/declarations.d.ts +46 -17
- package/dist/declarations.js +46 -15
- package/dist/descriptors.d.ts +242 -97
- package/dist/descriptors.js +145 -41
- package/dist/dev.d.ts +6 -5
- package/dist/dev.js +6 -5
- package/dist/document.d.ts +74 -25
- package/dist/document.js +32 -11
- package/dist/dowry.d.ts +241 -0
- package/dist/dowry.js +315 -0
- package/dist/engines.d.ts +16 -7
- package/dist/engines.js +6 -4
- package/dist/eventMapLaws.d.ts +19 -8
- package/dist/eventMapLaws.js +9 -6
- package/dist/events.d.ts +101 -39
- package/dist/events.js +106 -33
- package/dist/executor.d.ts +122 -41
- package/dist/executor.js +188 -95
- package/dist/extension.d.ts +99 -35
- package/dist/extension.js +43 -9
- package/dist/facets.d.ts +2 -1
- package/dist/facets.js +4 -2
- package/dist/foldedSections.d.ts +4 -2
- package/dist/foldedSections.js +2 -1
- package/dist/genres.d.ts +123 -41
- package/dist/genres.js +127 -22
- package/dist/guardedConnection.d.ts +4 -3
- package/dist/guardedConnection.js +4 -3
- package/dist/handlebarsReach.d.ts +1 -1
- package/dist/handlebarsReach.js +1 -1
- package/dist/hash.d.ts +16 -5
- package/dist/hash.js +14 -4
- package/dist/hookGrants.d.ts +3 -2
- package/dist/hookGrants.js +6 -4
- package/dist/hooks.d.ts +21 -16
- package/dist/hooks.js +12 -10
- package/dist/hostElements.d.ts +41 -17
- package/dist/hostElements.js +49 -17
- package/dist/i18n.d.ts +5 -3
- package/dist/i18n.js +5 -3
- package/dist/identity.d.ts +4 -3
- package/dist/identity.js +4 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +15 -0
- package/dist/layout.d.ts +36 -15
- package/dist/layout.js +2 -2
- package/dist/loadouts.d.ts +97 -0
- package/dist/loadouts.js +81 -0
- package/dist/media.d.ts +26 -4
- package/dist/media.js +2 -1
- package/dist/messageBlocks.d.ts +44 -32
- package/dist/messageBlocks.js +23 -18
- package/dist/migration.d.ts +16 -8
- package/dist/migration.js +14 -8
- package/dist/names.d.ts +2 -1
- package/dist/names.js +2 -1
- package/dist/nodeInput.d.ts +2 -1
- package/dist/nodeInput.js +2 -1
- package/dist/participants.d.ts +22 -15
- package/dist/participants.js +14 -12
- package/dist/personGate.d.ts +2 -1
- package/dist/personGate.js +2 -1
- package/dist/pluginHarness.d.ts +8 -3
- package/dist/pluginHarness.js +4 -2
- package/dist/pluginPermissions.d.ts +2 -1
- package/dist/pluginPermissions.js +12 -1
- package/dist/pluginRuleRef.d.ts +2 -2
- package/dist/pluginRuleRef.js +1 -1
- package/dist/predicates.d.ts +16 -11
- package/dist/predicates.js +7 -6
- package/dist/preview.d.ts +8 -3
- package/dist/preview.js +2 -1
- package/dist/promptBlocks.d.ts +5 -3
- package/dist/promptBlocks.js +5 -3
- package/dist/rankingDecisions.d.ts +2 -1
- package/dist/rankingDecisions.js +2 -1
- package/dist/receipt.d.ts +65 -29
- package/dist/receipt.js +9 -4
- package/dist/receiverRules.js +3 -2
- package/dist/refs.d.ts +34 -9
- package/dist/refs.js +33 -13
- package/dist/registry.d.ts +42 -23
- package/dist/registry.js +7 -5
- package/dist/review.d.ts +16 -5
- package/dist/review.js +11 -4
- package/dist/sampling.d.ts +54 -0
- package/dist/sampling.js +95 -3
- package/dist/sceneSettings.d.ts +312 -0
- package/dist/sceneSettings.js +425 -0
- package/dist/scope.d.ts +6 -4
- package/dist/scope.js +4 -3
- package/dist/scripts.d.ts +81 -14
- package/dist/scripts.js +90 -11
- package/dist/sessionDossier.d.ts +521 -0
- package/dist/sessionDossier.js +33 -0
- package/dist/sessionLayout.d.ts +303 -19
- package/dist/sessionLayout.js +354 -40
- package/dist/sessionSettings.d.ts +8 -5
- package/dist/settings.d.ts +45 -20
- package/dist/settings.js +19 -12
- package/dist/settingsSlot.d.ts +11 -8
- package/dist/settingsSlot.js +11 -8
- package/dist/shapes.d.ts +99 -36
- package/dist/shapes.js +101 -35
- package/dist/sheets.d.ts +4 -2
- package/dist/sheets.js +6 -3
- package/dist/statShapes.d.ts +2 -1
- package/dist/statShapes.js +2 -1
- package/dist/status.d.ts +13 -9
- package/dist/status.js +8 -6
- package/dist/storage.d.ts +2 -1
- package/dist/storage.js +2 -1
- package/dist/storyTime.d.ts +13 -7
- package/dist/storyTime.js +11 -6
- package/dist/strokes.d.ts +176 -0
- package/dist/strokes.js +281 -0
- package/dist/surfaces.d.ts +54 -25
- package/dist/surfaces.js +3 -3
- package/dist/template.d.ts +9 -5
- package/dist/template.js +5 -3
- package/dist/templateCheck.d.ts +2 -2
- package/dist/templateCheck.js +2 -2
- package/dist/templateFit.d.ts +37 -8
- package/dist/templateFit.js +92 -8
- package/dist/templateIds.d.ts +3 -3
- package/dist/templateIds.js +3 -3
- package/dist/templateScopeAt.d.ts +21 -11
- package/dist/templateScopeAt.js +21 -11
- package/dist/testing.d.ts +11 -4
- package/dist/testing.js +13 -5
- package/dist/tokenizers.d.ts +2 -2
- package/dist/tokenizers.js +2 -2
- package/dist/turnLock.d.ts +4 -2
- package/dist/turnLock.js +2 -1
- package/dist/turnOrder.d.ts +17 -11
- package/dist/turnOrder.js +9 -5
- package/dist/validate.d.ts +11 -8
- package/dist/validate.js +81 -10
- package/dist/values.d.ts +17 -8
- package/dist/values.js +11 -6
- package/dist/variables.d.ts +46 -7
- package/dist/variables.js +87 -6
- package/dist/verdicts.d.ts +20 -13
- package/dist/verdicts.js +17 -11
- package/dist/widgetDecls.d.ts +8 -4
- package/dist/widgetDecls.js +4 -2
- package/dist/widgets.d.ts +987 -94
- package/dist/widgets.js +93 -18
- package/dist/wire.d.ts +13 -6
- package/dist/wire.js +3 -3
- package/dist/worldinfo.d.ts +11 -6
- package/dist/worldinfo.js +8 -4
- package/host-elements.d.ts +13 -0
- package/package.json +1 -1
package/dist/builder.js
CHANGED
|
@@ -1,32 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The builder
|
|
2
|
+
* The builder. Kind-named methods — `.inlet() .query() .task() .oracle()
|
|
3
3
|
* .outlet()` — so reading a spec top to bottom shows the effect taxonomy, and so
|
|
4
4
|
* the type system can enforce laws that a generic .step() could only find at
|
|
5
|
-
* validation time
|
|
6
|
-
* (R-14, ruled 2026-09-15).
|
|
5
|
+
* validation time. Clauses are `.gather() .each() .loop() .junction()`.
|
|
7
6
|
*
|
|
8
7
|
* The chain is a *value*. It compiles to a document; SP imports the document and
|
|
9
|
-
* never this code
|
|
8
|
+
* never this code.
|
|
10
9
|
*
|
|
11
10
|
* Every node method takes either a pinned constructor or a **callback that receives the
|
|
12
11
|
* scope** — `$ => C.assemble({ messages: $.history.messages })`. The callback form is
|
|
13
12
|
* preferred: it types the node key and the port, and it makes a forward reference
|
|
14
13
|
* impossible to write rather than a finding to read (src/scope.ts). Both forms compile
|
|
15
14
|
* to the same rows.
|
|
15
|
+
* @ruling 04 §4, 04 §4a, R-14 (2026-09-15), F6
|
|
16
16
|
*/
|
|
17
17
|
import { eventsLockFindings, swapFitFinding, } from './descriptors.js';
|
|
18
18
|
import { makeScope, ITEM } from './scope.js';
|
|
19
|
-
import { isDataRef, isSlotRef } from './refs.js';
|
|
19
|
+
import { isDataRef, isSlotRef, slot } from './refs.js';
|
|
20
20
|
import { assertSpecId, parseSpecId } from './identity.js';
|
|
21
21
|
import { TURN_ORDER_CHANGED_IS_INTERNAL, genreIdOf, sessionEvents } from './genres.js';
|
|
22
22
|
import { eventById, isSessionEventDecl, notADeclaredEvent, packageEventById } from './events.js';
|
|
23
23
|
import { i18nFindings } from './i18n.js';
|
|
24
|
+
import { rendersProblem } from './bands.js';
|
|
24
25
|
import { actionFindings, normalizeContributes, slashCollisions, } from './actions.js';
|
|
26
|
+
import { boundaryTriggerFindings } from './sceneSettings.js';
|
|
25
27
|
/**
|
|
26
|
-
*
|
|
28
|
+
* A placement's `renders`, checked against its definition and stored as ids
|
|
29
|
+
* — `undefined` when it says nothing, so a node that states none hashes as it
|
|
30
|
+
* always did.
|
|
31
|
+
*/
|
|
32
|
+
function rendersOf(key, pinned, renders) {
|
|
33
|
+
const out = {};
|
|
34
|
+
const slots = Object.values((pinned.slots ?? {}))
|
|
35
|
+
.filter((s) => s.kind === 'variables');
|
|
36
|
+
const rendered = slots.flatMap((s) => Object.keys(s.renders ?? {}));
|
|
37
|
+
for (const [k, v] of Object.entries(renders)) {
|
|
38
|
+
const id = typeof v === 'string' ? v : v?.id;
|
|
39
|
+
// Saying a key means what its definition already says is no statement:
|
|
40
|
+
// not stored, so it does not move the document's hash.
|
|
41
|
+
if (slots.some((s) => s.renders?.[k] === id))
|
|
42
|
+
continue;
|
|
43
|
+
if (!rendered.includes(k))
|
|
44
|
+
throw new Error(`node '${key}': renders names '${k}', which '${pinned.id}' does not render — a spec says ` +
|
|
45
|
+
`what a key means, it does not add one. It renders ${rendered.map((r) => `'${r}'`).join(', ') || 'nothing'}.`);
|
|
46
|
+
const problem = rendersProblem(k, id);
|
|
47
|
+
if (problem)
|
|
48
|
+
throw new Error(`node '${key}': renders ${problem}`);
|
|
49
|
+
out[k] = id;
|
|
50
|
+
}
|
|
51
|
+
return Object.keys(out).length ? out : undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The stored mark: swaps as ids, present only when non-empty and
|
|
27
55
|
* implying `session: true`, plus the streaming step and step status
|
|
28
|
-
*
|
|
56
|
+
* when stated; `undefined` when the mark says nothing, so a
|
|
29
57
|
* node that declares nothing hashes as it always did.
|
|
58
|
+
* @ruling R28, B3/B18
|
|
30
59
|
*/
|
|
31
60
|
function exposeOf(key, pinned, expose) {
|
|
32
61
|
if (expose.session === false && expose.swaps?.length)
|
|
@@ -71,10 +100,11 @@ export function isModelCall(def) {
|
|
|
71
100
|
export const stepPurposeRefusal = (key, definitionId) => `node '${key}': expose.purpose says what a model call is for, but ${definitionId} calls no model — ` +
|
|
72
101
|
`put the purpose on the oracle that does, or give this step a label instead`;
|
|
73
102
|
/**
|
|
74
|
-
* The swap list a node declares, refused where it cannot work
|
|
103
|
+
* The swap list a node declares, refused where it cannot work:
|
|
75
104
|
* a swap that does not fit would seat a node the spec's edges and config
|
|
76
105
|
* cannot feed, and a person would pick it and get a broken run with no
|
|
77
106
|
* sentence. Returns the stored form — definition ids.
|
|
107
|
+
* @ruling R28, R26
|
|
78
108
|
*/
|
|
79
109
|
function swapIds(key, pinned, swaps) {
|
|
80
110
|
const out = [];
|
|
@@ -176,6 +206,12 @@ class ChainBuilder {
|
|
|
176
206
|
const expose = opts?.expose ? exposeOf(key, node.descriptor, opts.expose) : undefined;
|
|
177
207
|
return expose ? { expose } : {};
|
|
178
208
|
})(),
|
|
209
|
+
// Only when stated, for the same reason as `expose`.
|
|
210
|
+
...(opts?.prefers && Object.keys(opts.prefers).length ? { prefers: { ...opts.prefers } } : {}),
|
|
211
|
+
...(() => {
|
|
212
|
+
const renders = opts?.renders ? rendersOf(key, node.descriptor, opts.renders) : undefined;
|
|
213
|
+
return renders ? { renders } : {};
|
|
214
|
+
})(),
|
|
179
215
|
});
|
|
180
216
|
return this;
|
|
181
217
|
}
|
|
@@ -196,10 +232,11 @@ class ChainBuilder {
|
|
|
196
232
|
return clause;
|
|
197
233
|
}
|
|
198
234
|
/**
|
|
199
|
-
* A **gather** clause: several chains collected and awaited together
|
|
200
|
-
* `mode` is a setting — by the equivalence law
|
|
235
|
+
* A **gather** clause: several chains collected and awaited together.
|
|
236
|
+
* `mode` is a setting — by the equivalence law parallel and sequential
|
|
201
237
|
* are unobservable, which is why the construct is named for what it does
|
|
202
238
|
* (gather) and not for how (was `.async()`).
|
|
239
|
+
* @ruling 01 §4, C8
|
|
203
240
|
*/
|
|
204
241
|
gather(id, opts, fn) {
|
|
205
242
|
const qualified = this.qualify(id);
|
|
@@ -212,7 +249,10 @@ class ChainBuilder {
|
|
|
212
249
|
fn(new GatherBuilder(this.spec, qualified));
|
|
213
250
|
return this;
|
|
214
251
|
}
|
|
215
|
-
/**
|
|
252
|
+
/**
|
|
253
|
+
* An **each** clause: one contained chain, once per item of a list. Was `.map()`.
|
|
254
|
+
* @ruling 01 §4
|
|
255
|
+
*/
|
|
216
256
|
each(id, opts, fn) {
|
|
217
257
|
const qualified = this.qualify(id);
|
|
218
258
|
this.declareClause({
|
|
@@ -228,7 +268,7 @@ class ChainBuilder {
|
|
|
228
268
|
}
|
|
229
269
|
/**
|
|
230
270
|
* One contained chain, repeated while a declared port stays truthy — bounded by a
|
|
231
|
-
* mandatory `max
|
|
271
|
+
* mandatory `max`.
|
|
232
272
|
*
|
|
233
273
|
* This is the construct that makes tool-calling expressible on the spine. It is **not
|
|
234
274
|
* a back-edge**: like `each`, the repetition lives in the clause's declaration rather
|
|
@@ -237,6 +277,7 @@ class ChainBuilder {
|
|
|
237
277
|
* instead of a list length.
|
|
238
278
|
*
|
|
239
279
|
* Always sequential — each iteration depends on the last, so `mode` would be a lie.
|
|
280
|
+
* @ruling 01 §4a
|
|
240
281
|
*/
|
|
241
282
|
loop(id, opts, fn) {
|
|
242
283
|
const qualified = this.qualify(id);
|
|
@@ -265,18 +306,19 @@ class ChainBuilder {
|
|
|
265
306
|
}
|
|
266
307
|
/**
|
|
267
308
|
* A **junction** clause (was `.route()`): branches selected by declared
|
|
268
|
-
* predicates over a value on the spine
|
|
309
|
+
* predicates over a value on the spine. Any subset fires — one,
|
|
269
310
|
* several, or none — plus an optional `otherwise` that fires exactly when
|
|
270
311
|
* nothing else did. The decision is *data a task computed* (the value the
|
|
271
312
|
* junction is `on`); the branching is declaration; the receipt records
|
|
272
313
|
* every predicate's evaluation, fired and skipped alike. Not a back-edge
|
|
273
314
|
* and not code in the executor — the loop clause's whole argument, applied
|
|
274
|
-
* to fan-out.
|
|
315
|
+
* to fan-out. Branching exists as a declared junction; there are no
|
|
275
316
|
* back-edges.
|
|
276
317
|
*
|
|
277
318
|
* Skipped branches publish `halt('not selected')` results marked
|
|
278
319
|
* `fired: false`; the union's `ok`/`values` read the *fired* branches, so
|
|
279
|
-
* downstream folds see what ran, in declaration order
|
|
320
|
+
* downstream folds see what ran, in declaration order.
|
|
321
|
+
* @ruling 20 §10, 01 §4 amended, 13 §1
|
|
280
322
|
*/
|
|
281
323
|
junction(id, opts, fn) {
|
|
282
324
|
const qualified = this.qualify(id);
|
|
@@ -363,10 +405,11 @@ export class JunctionBuilder {
|
|
|
363
405
|
}
|
|
364
406
|
}
|
|
365
407
|
/**
|
|
366
|
-
* Slot-named methods, for the same reason the chain has kind-named ones
|
|
408
|
+
* Slot-named methods, for the same reason the chain has kind-named ones: the
|
|
367
409
|
* method names the slot, so setting a slot a node never declared is caught by name rather
|
|
368
410
|
* than becoming an override row that silently matches nothing.
|
|
369
411
|
* @experimental
|
|
412
|
+
* @ruling 04 §4a
|
|
370
413
|
*/
|
|
371
414
|
export class PresetBuilder {
|
|
372
415
|
preset;
|
|
@@ -377,7 +420,10 @@ export class PresetBuilder {
|
|
|
377
420
|
this.preset.values.push({ nodeKey, slot, value });
|
|
378
421
|
return this;
|
|
379
422
|
}
|
|
380
|
-
/**
|
|
423
|
+
/**
|
|
424
|
+
* Node behaviour knobs — retrieval `weight`, `minInclude`, `topK`.
|
|
425
|
+
* @ruling 12 §2
|
|
426
|
+
*/
|
|
381
427
|
params(nodeKey, value) {
|
|
382
428
|
return this.set(nodeKey, 'params', value);
|
|
383
429
|
}
|
|
@@ -397,6 +443,15 @@ export class PresetBuilder {
|
|
|
397
443
|
settings(nodeKey, value) {
|
|
398
444
|
return this.set(nodeKey, 'settings', value);
|
|
399
445
|
}
|
|
446
|
+
/**
|
|
447
|
+
* The **loadout** this model call runs on — `slot.loadout(id)` or the
|
|
448
|
+
* id itself. Unlike a connection this is allowed in an author preset: a
|
|
449
|
+
* loadout names no compute of the user's (a shipped one has no pair), it
|
|
450
|
+
* names the *kind* of engine, and the admin fills or merges it.
|
|
451
|
+
*/
|
|
452
|
+
loadout(nodeKey, value) {
|
|
453
|
+
return this.set(nodeKey, 'loadout', typeof value === 'string' ? slot.loadout(value) : value);
|
|
454
|
+
}
|
|
400
455
|
}
|
|
401
456
|
/** @experimental */
|
|
402
457
|
export class SpecBuilder extends ChainBuilder {
|
|
@@ -441,6 +496,11 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
441
496
|
const faults = actions.flatMap((a) => actionFindings({ ...a, genre: PENDING_GENRE }, id));
|
|
442
497
|
if (faults.length)
|
|
443
498
|
throw new Error(`spec '${id}' declares an action core cannot offer:\n · ${faults.join('\n · ')}`);
|
|
499
|
+
// 🚧 The boundary triggers (★9): their shape here; the channels
|
|
500
|
+
// against the genre where one is at hand (`summarizeScene`).
|
|
501
|
+
const triggerFaults = boundaryTriggerFindings(normalized.contributes?.boundaryTriggers, 'contributes.boundaryTriggers');
|
|
502
|
+
if (triggerFaults.length)
|
|
503
|
+
throw new Error(`spec '${id}' declares a boundary trigger core cannot watch:\n · ${triggerFaults.join('\n · ')}`);
|
|
444
504
|
}
|
|
445
505
|
super({
|
|
446
506
|
id,
|
|
@@ -466,7 +526,7 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
466
526
|
return this.add('outlet', key, node, opts);
|
|
467
527
|
}
|
|
468
528
|
/**
|
|
469
|
-
* A named configuration the spec ships with
|
|
529
|
+
* A named configuration the spec ships with. Declared **after** the nodes,
|
|
470
530
|
* so the node keys it addresses are the ones that exist — same accumulation the
|
|
471
531
|
* scope uses, so a typo is a compile error rather than a dead override row.
|
|
472
532
|
*
|
|
@@ -476,6 +536,7 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
476
536
|
* .prompts ('generate', { system: LORE_SYSTEM })
|
|
477
537
|
* .template('prompt', jinja(LORE_ASSEMBLY)))
|
|
478
538
|
* ```
|
|
539
|
+
* @ruling 12 §3a
|
|
479
540
|
*/
|
|
480
541
|
preset(slug, meta, fn) {
|
|
481
542
|
if (!SLUG.test(slug)) {
|
|
@@ -510,15 +571,16 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
510
571
|
return this;
|
|
511
572
|
}
|
|
512
573
|
/**
|
|
513
|
-
* Exactly one **inlet**, positionally first
|
|
574
|
+
* Exactly one **inlet**, positionally first. Enforced here rather than
|
|
514
575
|
* by the validator, so it is a throw at authoring time.
|
|
515
576
|
*
|
|
516
|
-
* The optional third argument is the **usage lock
|
|
577
|
+
* The optional third argument is the **usage lock**: the session
|
|
517
578
|
* event this inlet answers and the genre it serves. A session-event spec
|
|
518
579
|
* without it does not compile — required for now, and relaxing later
|
|
519
580
|
* (`genre: string[]`, `"*"`) is additive, never breaking. **The lock is the
|
|
520
|
-
* only subscription
|
|
581
|
+
* only subscription**: `.on()` and `subscribes` were deleted
|
|
521
582
|
* 2026-09-16 — nothing read them at dispatch.
|
|
583
|
+
* @ruling 01 §2, 24 §4, R-4, 09-B B5
|
|
522
584
|
*/
|
|
523
585
|
inlet(key, node, binding) {
|
|
524
586
|
// An event is named by value where a package declared it: its id.
|
|
@@ -625,13 +687,29 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
625
687
|
junction(id, opts, fn) {
|
|
626
688
|
return super.junction(id, opts, fn);
|
|
627
689
|
}
|
|
628
|
-
/**
|
|
690
|
+
/**
|
|
691
|
+
* Compile-time include — expanded here, so rows hold the flat chain.
|
|
692
|
+
* @ruling 16 §3a
|
|
693
|
+
*/
|
|
629
694
|
include(key, fragment) {
|
|
630
695
|
this.spec.includes.push({ key, fragmentId: fragment.id });
|
|
696
|
+
// The fragment's internal wiring moves with it: a reference that names one of
|
|
697
|
+
// its own nodes or clauses (or a clause's current item) is re-addressed under
|
|
698
|
+
// the prefix; a reference to anything outside the fragment is left alone.
|
|
699
|
+
const own = new Set();
|
|
700
|
+
for (const n of fragment.nodes)
|
|
701
|
+
own.add(n.key);
|
|
702
|
+
for (const b of fragment.clauses) {
|
|
703
|
+
own.add(b.id);
|
|
704
|
+
own.add(`${b.id}.${ITEM}`);
|
|
705
|
+
}
|
|
706
|
+
const rekey = (k) => (own.has(k) ? `${key}.${k}` : k);
|
|
707
|
+
const rewrite = (v) => rewriteFragmentRefs(v, rekey);
|
|
631
708
|
for (const n of fragment.nodes) {
|
|
632
709
|
this.spec.nodes.push({
|
|
633
710
|
...n,
|
|
634
711
|
key: `${key}.${n.key}`,
|
|
712
|
+
config: rewrite(n.config),
|
|
635
713
|
clauseId: n.clauseId ? `${key}.${n.clauseId}` : undefined,
|
|
636
714
|
position: this.spec.nodes.length,
|
|
637
715
|
});
|
|
@@ -640,6 +718,9 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
640
718
|
this.spec.clauses.push({
|
|
641
719
|
...b,
|
|
642
720
|
id: `${key}.${b.id}`,
|
|
721
|
+
...(b.over !== undefined ? { over: rewrite(b.over) } : {}),
|
|
722
|
+
...(b.on !== undefined ? { on: rewrite(b.on) } : {}),
|
|
723
|
+
...(b.repeatWhile !== undefined ? { repeatWhile: rewrite(b.repeatWhile) } : {}),
|
|
643
724
|
clauseId: b.clauseId ? `${key}.${b.clauseId}` : undefined,
|
|
644
725
|
position: this.spec.nodes.length,
|
|
645
726
|
});
|
|
@@ -660,6 +741,31 @@ const PENDING_GENRE = 'pending:genre/lock';
|
|
|
660
741
|
export function spec(id, meta) {
|
|
661
742
|
return new SpecBuilder(id, meta);
|
|
662
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Deep-copy `value`, re-addressing every `DataRef.node` and `SlotRef.ofNode`
|
|
746
|
+
* through `rekey`. Plain objects and arrays are walked; everything else is
|
|
747
|
+
* returned as is. Used by `include` to carry a fragment's internal wiring
|
|
748
|
+
* under its key prefix.
|
|
749
|
+
* @internal
|
|
750
|
+
*/
|
|
751
|
+
function rewriteFragmentRefs(value, rekey) {
|
|
752
|
+
const walk = (v) => {
|
|
753
|
+
if (isDataRef(v))
|
|
754
|
+
return { ...v, node: rekey(v.node) };
|
|
755
|
+
if (isSlotRef(v))
|
|
756
|
+
return v.ofNode !== undefined ? { ...v, ofNode: rekey(v.ofNode) } : { ...v };
|
|
757
|
+
if (Array.isArray(v))
|
|
758
|
+
return v.map(walk);
|
|
759
|
+
if (v && typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype) {
|
|
760
|
+
const out = {};
|
|
761
|
+
for (const [k, x] of Object.entries(v))
|
|
762
|
+
out[k] = walk(x);
|
|
763
|
+
return out;
|
|
764
|
+
}
|
|
765
|
+
return v;
|
|
766
|
+
};
|
|
767
|
+
return walk(value);
|
|
768
|
+
}
|
|
663
769
|
/** @experimental */
|
|
664
770
|
export function fragment(id, fn) {
|
|
665
771
|
const inner = {
|
package/dist/candidates.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The wire value of `core:shape/context-candidates@1`, and the one thing it
|
|
3
3
|
* carries besides candidates: each source's **band intent**.
|
|
4
4
|
*
|
|
5
|
-
* ## Queries declare, the ranker resolves (
|
|
5
|
+
* ## Queries declare, the ranker resolves (ruled 2026-09-15)
|
|
6
6
|
*
|
|
7
7
|
* *Per-source* intent — how much of the window a source wants (`share`), the
|
|
8
8
|
* most entries it may contribute (`maxEntries`), the fewest it keeps when room
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* the source, as ordinary `params`, and travels to the ranker as metadata on
|
|
12
12
|
* the candidates it publishes. The ranker declares only what is
|
|
13
13
|
* *cross-source*: how mechanisms and signals weigh, and how the shares
|
|
14
|
-
* normalise. A per-source map on the ranker is the design
|
|
14
|
+
* normalise. A per-source map on the ranker is the design that was rejected: it
|
|
15
15
|
* goes stale when a source is added, and a plugin source cannot participate
|
|
16
16
|
* without somebody editing it.
|
|
17
17
|
*
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* — a band no source declared falls back to the ranker's own table for the
|
|
43
43
|
* five core bands and is excluded with a receipt for any other, which is what
|
|
44
44
|
* makes a plugin source's participation a matter of publishing one element.
|
|
45
|
+
* @ruling 16 §5a, R-7 P5, 16 §5a
|
|
45
46
|
*/
|
|
46
47
|
/**
|
|
47
48
|
* How strongly a band resists being trimmed once its minimum is met.
|
|
@@ -64,7 +65,8 @@ export declare const isBandPriority: (v: unknown) => v is BandPriority;
|
|
|
64
65
|
export interface BandIntentFields {
|
|
65
66
|
/**
|
|
66
67
|
* The band's slice of the window, relative to every other band's. `0` is
|
|
67
|
-
* the band's off switch.
|
|
68
|
+
* the band's off switch. A share, never a weight.
|
|
69
|
+
* @ruling NOMENCLATURE §7
|
|
68
70
|
*/
|
|
69
71
|
share?: number;
|
|
70
72
|
/** The most entries this band may contribute. Absent means no ceiling. */
|
package/dist/candidates.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The wire value of `core:shape/context-candidates@1`, and the one thing it
|
|
3
3
|
* carries besides candidates: each source's **band intent**.
|
|
4
4
|
*
|
|
5
|
-
* ## Queries declare, the ranker resolves (
|
|
5
|
+
* ## Queries declare, the ranker resolves (ruled 2026-09-15)
|
|
6
6
|
*
|
|
7
7
|
* *Per-source* intent — how much of the window a source wants (`share`), the
|
|
8
8
|
* most entries it may contribute (`maxEntries`), the fewest it keeps when room
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* the source, as ordinary `params`, and travels to the ranker as metadata on
|
|
12
12
|
* the candidates it publishes. The ranker declares only what is
|
|
13
13
|
* *cross-source*: how mechanisms and signals weigh, and how the shares
|
|
14
|
-
* normalise. A per-source map on the ranker is the design
|
|
14
|
+
* normalise. A per-source map on the ranker is the design that was rejected: it
|
|
15
15
|
* goes stale when a source is added, and a plugin source cannot participate
|
|
16
16
|
* without somebody editing it.
|
|
17
17
|
*
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
* — a band no source declared falls back to the ranker's own table for the
|
|
43
43
|
* five core bands and is excluded with a receipt for any other, which is what
|
|
44
44
|
* makes a plugin source's participation a matter of publishing one element.
|
|
45
|
+
* @ruling 16 §5a, R-7 P5, 16 §5a
|
|
45
46
|
*/
|
|
46
47
|
/**
|
|
47
48
|
* How strongly a band resists being trimmed once its minimum is met.
|
package/dist/clauses.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A gather clause's execution mode, as a setting rather than only an authoring
|
|
3
|
-
* choice
|
|
3
|
+
* choice: `mode` is a setting, the construct is the clause.
|
|
4
4
|
*
|
|
5
5
|
* `gather` chains are declared `parallel` or `sequential` by whoever wrote the
|
|
6
6
|
* spec, and until now that was the end of it. But the right answer is not a
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* on exactly the terms `review` already uses (see `resolvePosition`): same
|
|
14
14
|
* `settings` slot, same precedence, same refusal to let an author forbid the
|
|
15
15
|
* override.
|
|
16
|
+
* @ruling R-14
|
|
16
17
|
*/
|
|
17
18
|
import type { I18n } from './descriptors.js';
|
|
18
19
|
/** @experimental */
|
package/dist/clauses.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A gather clause's execution mode, as a setting rather than only an authoring
|
|
3
|
-
* choice
|
|
3
|
+
* choice: `mode` is a setting, the construct is the clause.
|
|
4
4
|
*
|
|
5
5
|
* `gather` chains are declared `parallel` or `sequential` by whoever wrote the
|
|
6
6
|
* spec, and until now that was the end of it. But the right answer is not a
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* on exactly the terms `review` already uses (see `resolvePosition`): same
|
|
14
14
|
* `settings` slot, same precedence, same refusal to let an author forbid the
|
|
15
15
|
* override.
|
|
16
|
+
* @ruling R-14
|
|
16
17
|
*/
|
|
17
18
|
/** @experimental */
|
|
18
19
|
export const CLAUSE_MODES = ['parallel', 'sequential'];
|
package/dist/component.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@serene-pub/sdk/component` — what a COMPONENT imports from the SDK
|
|
3
|
-
*
|
|
2
|
+
* `@serene-pub/sdk/component` — what a COMPONENT imports from the SDK.
|
|
3
|
+
* Experimental: grows additively until SDK 1.0 freezes it.
|
|
4
4
|
*
|
|
5
5
|
* A component runs in a UI worker and may import only `COMPONENT_IMPORTS`
|
|
6
6
|
* (`componentImports.ts`). The SDK's root barrel is not on that list — it is
|
|
@@ -12,16 +12,26 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Every name here is the root barrel's own, re-exported: `import { x } from
|
|
14
14
|
* '@serene-pub/sdk'` and from this subpath are the same binding.
|
|
15
|
+
* @ruling §3.5, C6 P1
|
|
15
16
|
*/
|
|
16
17
|
/** An action's stable identity (a verb's key in a row or a palette). */
|
|
17
18
|
export { actionIdentity } from './identity.js';
|
|
18
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Display text: a plain string or a locale map, resolved.
|
|
21
|
+
* @ruling R-20
|
|
22
|
+
*/
|
|
19
23
|
export { i18nText, type I18n } from './i18n.js';
|
|
20
24
|
/** The empty turn order a widget starts from before the host's first push. */
|
|
21
25
|
export { EMPTY_TURN_ORDER, type TurnOrderV1 } from './turnOrder.js';
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The widget data contract's protocol version; the empty attendance a widget starts from.
|
|
28
|
+
* @ruling W10
|
|
29
|
+
*/
|
|
30
|
+
export { WIDGET_PROTOCOL, EMPTY_ATTENDANCE } from './widgets.js';
|
|
31
|
+
/**
|
|
32
|
+
* The folded sections a row's shown alternative carries, read from its metadata.
|
|
33
|
+
* @ruling B4
|
|
34
|
+
*/
|
|
25
35
|
export { foldedSectionsOf } from './foldedSections.js';
|
|
26
36
|
export type { ComponentContext } from './componentClient.js';
|
|
27
37
|
/** A declined `request`'s error, and the `code` it may carry. */
|
|
@@ -29,5 +39,12 @@ export type { RequestDeclined } from './componentWire.js';
|
|
|
29
39
|
export type { RequestDeclineCode } from './surfaces.js';
|
|
30
40
|
export type { HostKeyEventDetail } from './hostElements.js';
|
|
31
41
|
export type { StatusText, WidgetActionReason } from './status.js';
|
|
32
|
-
export type { AuthorsNoteV1, AuthorsNoteValueV1, FoldedSectionPartDataV1, FoldedSectionV1, LayoutV1, MessageErrorConnectionV1, MessageErrorV1, MessageMetadataV1, MessagePartV1, MessageSwipesV1, MessageV1, SessionCharactersV1, SessionEntryV1, SessionStateV1, ViewerV1, WidgetAction, WidgetEvent, WidgetEventKind, WidgetRequestKind, WidgetRequests, } from './widgets.js';
|
|
42
|
+
export type { AttendanceV1, AttendeeV1, AuthorsNoteV1, AuthorsNoteValueV1, HistoryEntriesV1, HistoryEntryV1, HistorySceneV1, FoldedSectionPartDataV1, FoldedSectionV1, LayoutV1, MessageErrorConnectionV1, MessageErrorV1, MessageMetadataV1, MessagePartV1, MessageSwipesV1, MessageV1, PlaceLinkV1, PlaceV1, SessionCharactersV1, SessionEntryV1, SessionPersonaV1, SessionPlacesV1, SessionStateV1, StatTrailChangeV1, StoryClockV1, WayV1, ViewerV1, WidgetAction, WidgetEvent, WidgetEventKind, WidgetRequestKind, WidgetRequests, } from './widgets.js';
|
|
43
|
+
/**
|
|
44
|
+
* 🚧 A story time and what a story clock steps by (Chronicle).
|
|
45
|
+
* @ruling W3
|
|
46
|
+
*/
|
|
47
|
+
export type { StoryTime, StoryTimeUnit } from './storyTime.js';
|
|
48
|
+
/** The conversation dossier — `session_full.v1`, for a widget granted `session:full`. */
|
|
49
|
+
export type { SessionDossierV1 } from './sessionDossier.js';
|
|
33
50
|
//# sourceMappingURL=component.d.ts.map
|
package/dist/component.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@serene-pub/sdk/component` — what a COMPONENT imports from the SDK
|
|
3
|
-
*
|
|
2
|
+
* `@serene-pub/sdk/component` — what a COMPONENT imports from the SDK.
|
|
3
|
+
* Experimental: grows additively until SDK 1.0 freezes it.
|
|
4
4
|
*
|
|
5
5
|
* A component runs in a UI worker and may import only `COMPONENT_IMPORTS`
|
|
6
6
|
* (`componentImports.ts`). The SDK's root barrel is not on that list — it is
|
|
@@ -12,16 +12,26 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Every name here is the root barrel's own, re-exported: `import { x } from
|
|
14
14
|
* '@serene-pub/sdk'` and from this subpath are the same binding.
|
|
15
|
+
* @ruling §3.5, C6 P1
|
|
15
16
|
*/
|
|
16
17
|
// ── runtime helpers ─────────────────────────────────────────────────────────
|
|
17
18
|
/** An action's stable identity (a verb's key in a row or a palette). */
|
|
18
19
|
export { actionIdentity } from './identity.js';
|
|
19
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Display text: a plain string or a locale map, resolved.
|
|
22
|
+
* @ruling R-20
|
|
23
|
+
*/
|
|
20
24
|
export { i18nText } from './i18n.js';
|
|
21
25
|
/** The empty turn order a widget starts from before the host's first push. */
|
|
22
26
|
export { EMPTY_TURN_ORDER } from './turnOrder.js';
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
/**
|
|
28
|
+
* The widget data contract's protocol version; the empty attendance a widget starts from.
|
|
29
|
+
* @ruling W10
|
|
30
|
+
*/
|
|
31
|
+
export { WIDGET_PROTOCOL, EMPTY_ATTENDANCE } from './widgets.js';
|
|
32
|
+
/**
|
|
33
|
+
* The folded sections a row's shown alternative carries, read from its metadata.
|
|
34
|
+
* @ruling B4
|
|
35
|
+
*/
|
|
26
36
|
export { foldedSectionsOf } from './foldedSections.js';
|
|
27
37
|
//# sourceMappingURL=component.js.map
|
package/dist/componentBuild.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* @experimental What a built component was built against. Additive: a reader ignores fields it does not know.
|
|
3
|
+
* @ruling F1
|
|
4
|
+
*/
|
|
2
5
|
export interface ComponentBuiltAgainst {
|
|
3
6
|
/** The widget protocol (`WIDGET_PROTOCOL`) the artifact speaks. */
|
|
4
7
|
widgetProtocol: number;
|
|
@@ -10,22 +13,29 @@ export interface ComponentBuiltAgainst {
|
|
|
10
13
|
componentClient?: string;
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
|
-
* @experimental
|
|
16
|
+
* @experimental
|
|
14
17
|
*
|
|
15
18
|
* The widget protocols this host mounts a component built for. A host that
|
|
16
19
|
* moves to a new protocol keeps the old one here for as long as it still
|
|
17
20
|
* speaks it; one it drops is refused, by name.
|
|
21
|
+
* @ruling F1
|
|
18
22
|
*/
|
|
19
23
|
export declare const HOST_WIDGET_PROTOCOLS: readonly number[];
|
|
20
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* @experimental The host-element vocabulary majors this host mounts a component built for.
|
|
26
|
+
* @ruling F1
|
|
27
|
+
*/
|
|
21
28
|
export declare const HOST_ELEMENTS_MAJORS: readonly number[];
|
|
22
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* @experimental The contract this SDK's build records: the two versions that decide.
|
|
31
|
+
* @ruling F1
|
|
32
|
+
*/
|
|
23
33
|
export declare function currentBuiltAgainst(versions?: {
|
|
24
34
|
sdk?: string;
|
|
25
35
|
componentClient?: string;
|
|
26
36
|
}): ComponentBuiltAgainst;
|
|
27
37
|
/**
|
|
28
|
-
* @experimental
|
|
38
|
+
* @experimental
|
|
29
39
|
*
|
|
30
40
|
* Why this host must NOT mount a component built against `builtAgainst`, as
|
|
31
41
|
* a sentence — or `undefined` when it may. Absent (`undefined` / `null`) is
|
|
@@ -39,6 +49,7 @@ export declare function currentBuiltAgainst(versions?: {
|
|
|
39
49
|
* {@link HOST_ELEMENTS_VERSION}).
|
|
40
50
|
*
|
|
41
51
|
* `host` defaults to this SDK's own contract.
|
|
52
|
+
* @ruling F1
|
|
42
53
|
*/
|
|
43
54
|
export declare function componentBuiltAgainstFinding(builtAgainst: unknown, host?: {
|
|
44
55
|
widgetProtocols?: readonly number[];
|
package/dist/componentBuild.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a built component was built AGAINST
|
|
2
|
+
* What a built component was built AGAINST: the host contract a
|
|
3
3
|
* compiled artifact assumes, recorded beside it so a host that has moved on
|
|
4
4
|
* refuses it with a sentence instead of mounting it into a failure nobody can
|
|
5
5
|
* read.
|
|
@@ -16,20 +16,28 @@
|
|
|
16
16
|
* (`components[].builtAgainst`) and by the in-app compiler on each compile.
|
|
17
17
|
* An entry WITHOUT one predates the record and is judged compatible — every
|
|
18
18
|
* component built before it was built for protocol 2, vocabulary 1.
|
|
19
|
+
* @ruling F1
|
|
19
20
|
*/
|
|
20
21
|
import { HOST_ELEMENTS_VERSION } from './hostElements.js';
|
|
21
22
|
import { WIDGET_PROTOCOL } from './widgets.js';
|
|
22
23
|
/**
|
|
23
|
-
* @experimental
|
|
24
|
+
* @experimental
|
|
24
25
|
*
|
|
25
26
|
* The widget protocols this host mounts a component built for. A host that
|
|
26
27
|
* moves to a new protocol keeps the old one here for as long as it still
|
|
27
28
|
* speaks it; one it drops is refused, by name.
|
|
29
|
+
* @ruling F1
|
|
28
30
|
*/
|
|
29
31
|
export const HOST_WIDGET_PROTOCOLS = Object.freeze([WIDGET_PROTOCOL]);
|
|
30
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* @experimental The host-element vocabulary majors this host mounts a component built for.
|
|
34
|
+
* @ruling F1
|
|
35
|
+
*/
|
|
31
36
|
export const HOST_ELEMENTS_MAJORS = Object.freeze([vocabularyMajor(HOST_ELEMENTS_VERSION)]);
|
|
32
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* @experimental The contract this SDK's build records: the two versions that decide.
|
|
39
|
+
* @ruling F1
|
|
40
|
+
*/
|
|
33
41
|
export function currentBuiltAgainst(versions = {}) {
|
|
34
42
|
return {
|
|
35
43
|
widgetProtocol: WIDGET_PROTOCOL,
|
|
@@ -46,7 +54,7 @@ function vocabularyMajor(v) {
|
|
|
46
54
|
}
|
|
47
55
|
const list = (xs) => (xs.length === 1 ? String(xs[0]) : `${xs.slice(0, -1).join(', ')} or ${xs[xs.length - 1]}`);
|
|
48
56
|
/**
|
|
49
|
-
* @experimental
|
|
57
|
+
* @experimental
|
|
50
58
|
*
|
|
51
59
|
* Why this host must NOT mount a component built against `builtAgainst`, as
|
|
52
60
|
* a sentence — or `undefined` when it may. Absent (`undefined` / `null`) is
|
|
@@ -60,6 +68,7 @@ const list = (xs) => (xs.length === 1 ? String(xs[0]) : `${xs.slice(0, -1).join(
|
|
|
60
68
|
* {@link HOST_ELEMENTS_VERSION}).
|
|
61
69
|
*
|
|
62
70
|
* `host` defaults to this SDK's own contract.
|
|
71
|
+
* @ruling F1
|
|
63
72
|
*/
|
|
64
73
|
export function componentBuiltAgainstFinding(builtAgainst, host = {}) {
|
|
65
74
|
if (builtAgainst === undefined || builtAgainst === null)
|