@serene-pub/sdk 0.6.0-pr-7 โ 0.6.0-pr-8
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/dist/annexFields.d.ts +14 -0
- package/dist/annexFields.js +7 -0
- package/dist/announce.d.ts +26 -13
- package/dist/announce.js +31 -0
- package/dist/appletCard.d.ts +17 -0
- package/dist/appletCard.js +60 -0
- package/dist/attributes.d.ts +3 -3
- package/dist/attributes.js +1 -1
- package/dist/builder.d.ts +23 -6
- package/dist/builder.js +57 -5
- package/dist/cadences.d.ts +11 -2
- package/dist/cadences.js +27 -2
- package/dist/characterProfile.d.ts +137 -0
- package/dist/characterProfile.js +24 -0
- package/dist/component.d.ts +1 -1
- package/dist/componentImports.d.ts +1 -1
- package/dist/componentImports.js +2 -0
- package/dist/declarations.js +4 -0
- package/dist/descriptors.d.ts +68 -3
- package/dist/descriptors.js +23 -0
- package/dist/document.d.ts +8 -0
- package/dist/document.js +44 -1
- package/dist/events.d.ts +35 -4
- package/dist/events.js +7 -3
- package/dist/executor.js +26 -5
- package/dist/extension.d.ts +17 -0
- package/dist/fit.d.ts +4 -1
- package/dist/fit.js +43 -1
- package/dist/functions.d.ts +7 -1
- package/dist/functions.js +3 -1
- package/dist/genres.d.ts +7 -0
- package/dist/genres.js +32 -1
- package/dist/hookGrants.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +9 -0
- package/dist/layout.d.ts +18 -0
- package/dist/libraryDraft.d.ts +2 -0
- package/dist/libraryDraft.js +5 -1
- package/dist/lorebookFile.d.ts +8 -0
- package/dist/lorebookFile.js +21 -0
- package/dist/participants.d.ts +53 -8
- package/dist/participants.js +9 -5
- package/dist/pluginPermissions.js +1 -1
- package/dist/promptBlocks.d.ts +5 -1
- package/dist/promptBlocks.js +23 -8
- package/dist/registry.js +6 -3
- package/dist/sceneSettings.d.ts +4 -0
- package/dist/sceneSettings.js +7 -4
- package/dist/sessionDossier.d.ts +57 -0
- package/dist/sessionLayout.d.ts +296 -85
- package/dist/sessionLayout.js +397 -133
- package/dist/settings.d.ts +28 -1
- package/dist/settings.js +50 -2
- package/dist/shapes.d.ts +6 -1
- package/dist/shapes.js +6 -1
- package/dist/sheetLatitude.d.ts +148 -0
- package/dist/sheetLatitude.js +161 -0
- package/dist/storyTime.js +6 -4
- package/dist/surfaces.d.ts +11 -1
- package/dist/template.d.ts +26 -1
- package/dist/templateCheck.d.ts +24 -0
- package/dist/templateCheck.js +299 -7
- package/dist/templateFit.js +4 -0
- package/dist/templateIds.d.ts +6 -0
- package/dist/templateIds.js +9 -0
- package/dist/turnLock.d.ts +10 -1
- package/dist/turnLock.js +6 -1
- package/dist/turnOrder.d.ts +37 -4
- package/dist/turnOrder.js +49 -11
- package/dist/validate.d.ts +4 -2
- package/dist/validate.js +15 -11
- package/dist/variableLayouts.d.ts +141 -0
- package/dist/variableLayouts.js +183 -0
- package/dist/variables.d.ts +35 -7
- package/dist/variables.js +34 -1
- package/dist/widgetDecls.js +12 -0
- package/dist/widgets.d.ts +384 -41
- package/dist/widgets.js +23 -0
- package/package.json +1 -1
package/dist/annexFields.d.ts
CHANGED
|
@@ -100,6 +100,18 @@ export interface AnnexFieldDecl {
|
|
|
100
100
|
readonly scope?: 'session' | 'lorebook' | 'user';
|
|
101
101
|
/** ๐ง The value follows the player into the next chapter (M0, F5): a `next-chapter` session copies it. */
|
|
102
102
|
readonly nextChapter?: true;
|
|
103
|
+
/**
|
|
104
|
+
* ๐ง The value stays when the turn that wrote it is replaced โ a swipe, a
|
|
105
|
+
* regenerate, a failed run โ and goes when the turn leaves (Back, delete).
|
|
106
|
+
* For a genre that tells a turn again from what it decided: its plan is not
|
|
107
|
+
* written again, so it must not be taken back. Absent means it goes with the
|
|
108
|
+
* turn either way. `session` scope only: only a session's annex is taken back
|
|
109
|
+
* with a turn.
|
|
110
|
+
* @experimental
|
|
111
|
+
* โ Not a cast member's _retold_ field (NOMENCLATURE ยง8 **retold** โ a card
|
|
112
|
+
* field told in the member's own words); a near-neighbour word.
|
|
113
|
+
*/
|
|
114
|
+
readonly keepOnRetell?: true;
|
|
103
115
|
/** What a listing calls the action. Default: the key. */
|
|
104
116
|
readonly label?: I18n;
|
|
105
117
|
readonly description?: I18n;
|
|
@@ -118,6 +130,8 @@ export type AnnexFieldInput = {
|
|
|
118
130
|
scope?: 'session' | 'lorebook' | 'user';
|
|
119
131
|
/** ๐ง The value follows the player into the next chapter โ {@link AnnexFieldDecl.nextChapter}. */
|
|
120
132
|
nextChapter?: true;
|
|
133
|
+
/** ๐ง The value stays when its turn is replaced โ {@link AnnexFieldDecl.keepOnRetell}. */
|
|
134
|
+
keepOnRetell?: true;
|
|
121
135
|
label?: I18n;
|
|
122
136
|
description?: I18n;
|
|
123
137
|
};
|
package/dist/annexFields.js
CHANGED
|
@@ -120,6 +120,8 @@ export function annexFieldFindings(raw, at = 'annexFields') {
|
|
|
120
120
|
out.push(`${where}.genre: a user-scoped field is not bound to a genre โ a person's documents follow them across sessions`);
|
|
121
121
|
if (f.nextChapter !== undefined)
|
|
122
122
|
out.push(`${where}.nextChapter: a user-scoped field is not part of a session, so nothing follows into a chapter`);
|
|
123
|
+
if (f.keepOnRetell !== undefined)
|
|
124
|
+
out.push(`${where}.keepOnRetell: a user-scoped field is not taken back with a turn, so there is nothing to keep โ only a session-scope field can keep its value`);
|
|
123
125
|
}
|
|
124
126
|
if (f.act !== undefined && f.scope !== 'user') {
|
|
125
127
|
if (!Array.isArray(f.act) || !f.act.length)
|
|
@@ -140,6 +142,10 @@ export function annexFieldFindings(raw, at = 'annexFields') {
|
|
|
140
142
|
if (f.scope !== undefined && f.scope !== 'session' && f.scope !== 'lorebook' && f.scope !== 'user')
|
|
141
143
|
out.push(`${where}.scope: 'session' (the session annex, the default), 'lorebook' (the lorebook annex) or 'user' (the user annex) โ ` +
|
|
142
144
|
`'${String(f.scope)}' is neither`);
|
|
145
|
+
if (f.scope === 'lorebook' && f.keepOnRetell !== undefined)
|
|
146
|
+
out.push(`${where}.keepOnRetell: a session-scope field only โ a lorebook-scope field's change is a lorebook write, and goes back with its turn as every lorebook write does`);
|
|
147
|
+
if (f.keepOnRetell !== undefined && f.keepOnRetell !== true)
|
|
148
|
+
out.push(`${where}.keepOnRetell: true or absent โ the value stays when its turn is told again`);
|
|
143
149
|
if (f.nextChapter !== undefined && f.nextChapter !== true)
|
|
144
150
|
out.push(`${where}.nextChapter: true or absent โ the value follows the player into the next chapter`);
|
|
145
151
|
out.push(...i18nFindings(f.label, `${where}.label`));
|
|
@@ -165,6 +171,7 @@ export function annexField(d) {
|
|
|
165
171
|
...(d.genre !== undefined ? { genre: typeof d.genre === 'string' ? d.genre : d.genre.id } : {}),
|
|
166
172
|
...(d.scope !== undefined ? { scope: d.scope } : {}),
|
|
167
173
|
...(d.nextChapter !== undefined ? { nextChapter: d.nextChapter } : {}),
|
|
174
|
+
...(d.keepOnRetell !== undefined ? { keepOnRetell: d.keepOnRetell } : {}),
|
|
168
175
|
...(d.label !== undefined ? { label: d.label } : {}),
|
|
169
176
|
...(d.description !== undefined ? { description: d.description } : {}),
|
|
170
177
|
});
|
package/dist/announce.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ export declare function specIdOf(v: unknown, where: string): string;
|
|
|
74
74
|
import { type GenreDecl, type GenreProps } from './genres.js';
|
|
75
75
|
import { type PresetRegistrationChanges, type RegistrationDecl } from './registrations.js';
|
|
76
76
|
import type { SettingValue } from './exposure.js';
|
|
77
|
+
import type { VariableId } from './variables.js';
|
|
77
78
|
import { type SessionEventDecl } from './events.js';
|
|
78
79
|
import { type ValueToolkit } from './values.js';
|
|
79
80
|
import type { ComponentDecl, Extension } from './extension.js';
|
|
@@ -310,18 +311,18 @@ export interface PresetDecl {
|
|
|
310
311
|
*/
|
|
311
312
|
settings?: Readonly<Record<string, SettingValue>>;
|
|
312
313
|
/**
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
*
|
|
314
|
+
* ๐ง Variable id โ layout reference (`{ 'core:var/characters@1': 'core/json@1' }`):
|
|
315
|
+
* this preset's sessions write that variable out with that layout instead of
|
|
316
|
+
* the pub's. A reference to a layout that isn't installed is accepted; the
|
|
317
|
+
* host skips it, renders the pub's layout and says so. โ Not a genre's
|
|
318
|
+
* `layouts` (session layouts) and not `settings`.
|
|
319
|
+
*/
|
|
320
|
+
variableLayouts?: Readonly<Record<VariableId, string>>;
|
|
321
|
+
/**
|
|
322
|
+
* @deprecated โณ Ignored. The instance offers a plugin's presets as soon as
|
|
323
|
+
* the plugin is enabled; an administrator may hide one afterwards, and that
|
|
324
|
+
* choice survives upgrades. Kept so existing packages still compile;
|
|
325
|
+
* removing it is the owner's call.
|
|
325
326
|
*/
|
|
326
327
|
enabled?: boolean;
|
|
327
328
|
}
|
|
@@ -437,7 +438,9 @@ export interface PresetInput {
|
|
|
437
438
|
};
|
|
438
439
|
/** ๐ง See `PresetDecl.settings` โ each a value, or `{ value, lock?, askAtStart? }`. */
|
|
439
440
|
settings?: Readonly<Record<string, SettingValue>>;
|
|
440
|
-
/**
|
|
441
|
+
/** ๐ง See `PresetDecl.variableLayouts`. */
|
|
442
|
+
variableLayouts?: Readonly<Record<VariableId, string>>;
|
|
443
|
+
/** @deprecated โณ Ignored โ presets are offered once the plugin is enabled. See `PresetDecl.enabled`. */
|
|
441
444
|
enabled?: boolean;
|
|
442
445
|
}
|
|
443
446
|
/**
|
|
@@ -492,6 +495,16 @@ export declare function requirementRanges(manifest: {
|
|
|
492
495
|
id?: string;
|
|
493
496
|
range: string;
|
|
494
497
|
}>;
|
|
498
|
+
/**
|
|
499
|
+
* What is wrong with a preset's `variableLayouts`, as sentences โ the one
|
|
500
|
+
* statement of the rule, for a preset that arrives as data (a manifest, a row)
|
|
501
|
+
* and for `preset()`. Empty when it is clean or absent.
|
|
502
|
+
* @experimental
|
|
503
|
+
*/
|
|
504
|
+
export declare function presetVariableLayoutFindings(preset: {
|
|
505
|
+
slug?: string;
|
|
506
|
+
variableLayouts?: unknown;
|
|
507
|
+
} | null | undefined): string[];
|
|
495
508
|
/**
|
|
496
509
|
* The stored form of a preset. Every reference is read down to its id and
|
|
497
510
|
* checked against what the value says: a binding's events against its spec's
|
package/dist/announce.js
CHANGED
|
@@ -33,6 +33,7 @@ const actionKeysOf = (v) => {
|
|
|
33
33
|
};
|
|
34
34
|
import { genre as makeGenre, genreIdOf, sessionEvents } from './genres.js';
|
|
35
35
|
import { registrationRange, } from './registrations.js';
|
|
36
|
+
import { parseVariableLayoutReference, variableIdParts } from './variableLayouts.js';
|
|
36
37
|
import { eventById, isEventId, isSessionEventDecl } from './events.js';
|
|
37
38
|
import { makeValueToolkit } from './values.js';
|
|
38
39
|
import { SAVE_MESSAGE_SPEC_ID } from './descriptors.js';
|
|
@@ -218,6 +219,32 @@ export function requirementRanges(manifest) {
|
|
|
218
219
|
return out;
|
|
219
220
|
}
|
|
220
221
|
const isBindingObject = (v) => !!v && typeof v === 'object' && 'spec' in v;
|
|
222
|
+
/**
|
|
223
|
+
* What is wrong with a preset's `variableLayouts`, as sentences โ the one
|
|
224
|
+
* statement of the rule, for a preset that arrives as data (a manifest, a row)
|
|
225
|
+
* and for `preset()`. Empty when it is clean or absent.
|
|
226
|
+
* @experimental
|
|
227
|
+
*/
|
|
228
|
+
export function presetVariableLayoutFindings(preset) {
|
|
229
|
+
const where = `preset '${preset?.slug ?? '?'}'`;
|
|
230
|
+
const map = preset?.variableLayouts;
|
|
231
|
+
if (map === undefined)
|
|
232
|
+
return [];
|
|
233
|
+
if (!map || typeof map !== 'object' || Array.isArray(map))
|
|
234
|
+
return [
|
|
235
|
+
`${where}.variableLayouts is a map from variable id to layout reference โ ` +
|
|
236
|
+
`{ 'core:var/characters@1': 'core/json@1' }`,
|
|
237
|
+
];
|
|
238
|
+
const findings = [];
|
|
239
|
+
for (const [key, value] of Object.entries(map)) {
|
|
240
|
+
if (!variableIdParts(key))
|
|
241
|
+
findings.push(`${where}.variableLayouts: '${key}' is not a variable id โ it reads 'core:var/characters@1'`);
|
|
242
|
+
else if (!parseVariableLayoutReference(value))
|
|
243
|
+
findings.push(`${where}.variableLayouts: '${key}' is given '${String(value)}', which is not a layout reference โ ` +
|
|
244
|
+
`it reads '<owner>/<slug>@<major>', such as 'core/json@1'`);
|
|
245
|
+
}
|
|
246
|
+
return findings;
|
|
247
|
+
}
|
|
221
248
|
/**
|
|
222
249
|
* The stored form of a preset. Every reference is read down to its id and
|
|
223
250
|
* checked against what the value says: a binding's events against its spec's
|
|
@@ -228,6 +255,9 @@ const isBindingObject = (v) => !!v && typeof v === 'object' && 'spec' in v;
|
|
|
228
255
|
export function preset(input) {
|
|
229
256
|
const where = `preset '${input?.slug}'`;
|
|
230
257
|
assertDisplayText(where, input);
|
|
258
|
+
const layoutFindings = presetVariableLayoutFindings(input);
|
|
259
|
+
if (layoutFindings.length)
|
|
260
|
+
throw new Error(layoutFindings[0]);
|
|
231
261
|
if (typeof input.genre === 'string')
|
|
232
262
|
throw new Error(`${where} names its genre as a string โ pass the genre value (import it), or use('${input.genre}')`);
|
|
233
263
|
const genre = isExternalRef(input.genre) ? input.genre.id : genreIdOf(input.genre);
|
|
@@ -360,6 +390,7 @@ export function preset(input) {
|
|
|
360
390
|
...(input.callsPerTurn !== undefined ? { callsPerTurn: assertCallsPerTurn(input.callsPerTurn, where) } : {}),
|
|
361
391
|
...(input.cast ? { cast: assertCastFloor(input.cast, where) } : {}),
|
|
362
392
|
...(input.settings && Object.keys(input.settings).length ? { settings: { ...input.settings } } : {}),
|
|
393
|
+
...(input.variableLayouts && Object.keys(input.variableLayouts).length ? { variableLayouts: { ...input.variableLayouts } } : {}),
|
|
363
394
|
};
|
|
364
395
|
}
|
|
365
396
|
const assertCallsPerTurn = (v, where) => {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ๐ง The one rule for a package's applet card (M2d), run by the packager
|
|
3
|
+
* (`serene-pub check`) and again by the instance's install over the stored
|
|
4
|
+
* manifest. Pure: the caller says which package files exist.
|
|
5
|
+
*
|
|
6
|
+
* Returns one finding per mistake, each with a `fix`: `E_APPLET_CARD_OUTSIDE_ASSETS`,
|
|
7
|
+
* `E_APPLET_CARD_MISSING`, `E_APPLET_CARD_BLURB_LONG`, `E_APPLET_CARD_WITHOUT_APPLET`.
|
|
8
|
+
* Empty when `appletCard` is undefined. Not a reader of files and not a layout
|
|
9
|
+
* check โ no aspect ratio is tested.
|
|
10
|
+
* @experimental (M2d)
|
|
11
|
+
*/
|
|
12
|
+
export declare function appletCardFindings(card: unknown, assetsDir: string | undefined, fileExists: (path: string) => boolean, hasAppletGenre: boolean): Array<{
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
fix: string;
|
|
16
|
+
}>;
|
|
17
|
+
//# sourceMappingURL=appletCard.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { i18nText } from './i18n.js';
|
|
2
|
+
/**
|
|
3
|
+
* ๐ง The one rule for a package's applet card (M2d), run by the packager
|
|
4
|
+
* (`serene-pub check`) and again by the instance's install over the stored
|
|
5
|
+
* manifest. Pure: the caller says which package files exist.
|
|
6
|
+
*
|
|
7
|
+
* Returns one finding per mistake, each with a `fix`: `E_APPLET_CARD_OUTSIDE_ASSETS`,
|
|
8
|
+
* `E_APPLET_CARD_MISSING`, `E_APPLET_CARD_BLURB_LONG`, `E_APPLET_CARD_WITHOUT_APPLET`.
|
|
9
|
+
* Empty when `appletCard` is undefined. Not a reader of files and not a layout
|
|
10
|
+
* check โ no aspect ratio is tested.
|
|
11
|
+
* @experimental (M2d)
|
|
12
|
+
*/
|
|
13
|
+
export function appletCardFindings(card, assetsDir, fileExists, hasAppletGenre) {
|
|
14
|
+
if (card === undefined)
|
|
15
|
+
return [];
|
|
16
|
+
const out = [];
|
|
17
|
+
const c = (card && typeof card === 'object' ? card : {});
|
|
18
|
+
const dir = assetsDir?.replace(/\/+$/, '');
|
|
19
|
+
for (const key of ['poster', 'logo']) {
|
|
20
|
+
const raw = c[key];
|
|
21
|
+
if (raw === undefined)
|
|
22
|
+
continue;
|
|
23
|
+
const shown = String(raw);
|
|
24
|
+
const safe = typeof raw === 'string' &&
|
|
25
|
+
!raw.startsWith('/') &&
|
|
26
|
+
!raw.includes('\\') &&
|
|
27
|
+
!raw.split('/').some((x) => !x || x === '.' || x === '..');
|
|
28
|
+
if (!safe || !dir || !raw.startsWith(`${dir}/`)) {
|
|
29
|
+
out.push({
|
|
30
|
+
code: 'E_APPLET_CARD_OUTSIDE_ASSETS',
|
|
31
|
+
message: `appletCard.${key} is '${shown}', which is not a file under the package's assets folder${dir ? ` '${dir}'` : ' (the package declares none)'}`,
|
|
32
|
+
fix: `declare assets: { dir: 'assets' } and put the picture under it โ 'assets/card/${key}.png'`,
|
|
33
|
+
});
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!fileExists(raw))
|
|
37
|
+
out.push({
|
|
38
|
+
code: 'E_APPLET_CARD_MISSING',
|
|
39
|
+
message: `appletCard.${key} names '${shown}', and the package has no such file`,
|
|
40
|
+
fix: `add the picture at that path, or remove appletCard.${key}`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (c.blurb !== undefined) {
|
|
44
|
+
const text = i18nText(c.blurb) ?? '';
|
|
45
|
+
if (text.length > 160)
|
|
46
|
+
out.push({
|
|
47
|
+
code: 'E_APPLET_CARD_BLURB_LONG',
|
|
48
|
+
message: `appletCard.blurb is ${text.length} characters; the card shows at most 160`,
|
|
49
|
+
fix: 'shorten it to one line of at most 160 characters',
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!hasAppletGenre)
|
|
53
|
+
out.push({
|
|
54
|
+
code: 'E_APPLET_CARD_WITHOUT_APPLET',
|
|
55
|
+
message: 'appletCard is declared, and no genre of this package presents as an applet',
|
|
56
|
+
fix: "add applet: true to a genre's shape, or remove appletCard",
|
|
57
|
+
});
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=appletCard.js.map
|
package/dist/attributes.d.ts
CHANGED
|
@@ -517,8 +517,8 @@ export interface AttributeSlotProps {
|
|
|
517
517
|
appliesTo: readonly SlotAppliesTo[];
|
|
518
518
|
/**
|
|
519
519
|
* ๐ง **What its values survive** (M0, SHAPES F1): `session` โ they
|
|
520
|
-
* die with the session (its session layer: `session`, `
|
|
521
|
-
* `player_seat`, `session_location`); `world` โ they live on the book,
|
|
520
|
+
* die with the session (its session layer: `session`, ๐ง `seated_member`, โณ
|
|
521
|
+
* `session_cast`, `player_seat`, `session_location`); `world` โ they live on the book,
|
|
522
522
|
* dated on its timeline (`lorebook`, `cast_member`, `location`). Absent:
|
|
523
523
|
* `session`. A ruleset attribute's `scope` lands here. The player's own
|
|
524
524
|
* (`owner: 'player'` on a ruleset attribute) is a `cast` slot read on the
|
|
@@ -977,7 +977,7 @@ export declare function applyListOp(current: readonly SlotListItem[] | null | un
|
|
|
977
977
|
* Whether a slot may attach to this kind of owner.
|
|
978
978
|
*
|
|
979
979
|
* The owner *kinds* the host stores (`card`, `cast_member`, `lorebook`,
|
|
980
|
-
* `session`, `session_cast`, `location`, `session_location`) collapse to the
|
|
980
|
+
* `session`, ๐ง `seated_member`, โณ `session_cast`, `location`, `session_location`) collapse to the
|
|
981
981
|
* three a declaration talks about: a lorebook and a session are the **world**,
|
|
982
982
|
* a location entry and its session layer are a **location**, everything that
|
|
983
983
|
* is somebody is the **cast**. A declaration should not have to know the
|
package/dist/attributes.js
CHANGED
|
@@ -1195,7 +1195,7 @@ export function applyListOp(current, op, items, config = {}) {
|
|
|
1195
1195
|
* Whether a slot may attach to this kind of owner.
|
|
1196
1196
|
*
|
|
1197
1197
|
* The owner *kinds* the host stores (`card`, `cast_member`, `lorebook`,
|
|
1198
|
-
* `session`, `session_cast`, `location`, `session_location`) collapse to the
|
|
1198
|
+
* `session`, ๐ง `seated_member`, โณ `session_cast`, `location`, `session_location`) collapse to the
|
|
1199
1199
|
* three a declaration talks about: a lorebook and a session are the **world**,
|
|
1200
1200
|
* a location entry and its session layer are a **location**, everything that
|
|
1201
1201
|
* is somebody is the **cast**. A declaration should not have to know the
|
package/dist/builder.d.ts
CHANGED
|
@@ -210,10 +210,13 @@ export interface BuiltNode {
|
|
|
210
210
|
* its legend among Advanced settings. Wins over the step status and the
|
|
211
211
|
* node definition's name. Any node may carry one.
|
|
212
212
|
* ยท `purpose` โ **the step purpose**: one or two plain sentences under
|
|
213
|
-
* that group's heading, saying what this model call is for.
|
|
214
|
-
* model
|
|
215
|
-
*
|
|
216
|
-
*
|
|
213
|
+
* that group's heading, saying what this model call is for. On a spec
|
|
214
|
+
* that calls no model at all it may sit on any step (the routines list
|
|
215
|
+
* prints the first one a routine's steps declare); on a spec that calls
|
|
216
|
+
* a model โ a node whose definition declares a `connection` slot
|
|
217
|
+
* (`isModelCall`), or one a node's `expose.swaps` lists โ only on a model
|
|
218
|
+
* call, because no other step heads a group. `build()` and `validate()`
|
|
219
|
+
* refuse the rest.
|
|
217
220
|
*
|
|
218
221
|
* Display text, hashed with the document like `status`: a spec that
|
|
219
222
|
* sets neither hashes as it always did.
|
|
@@ -492,7 +495,7 @@ export interface NodeOpts {
|
|
|
492
495
|
status?: I18n;
|
|
493
496
|
/** The step label: this step's name in settings โ see `BuiltNode.expose`. */
|
|
494
497
|
label?: I18n;
|
|
495
|
-
/** The step purpose: what this
|
|
498
|
+
/** The step purpose: what this step is for, under its settings heading โ see `BuiltNode.expose` for where it is allowed. */
|
|
496
499
|
purpose?: I18n;
|
|
497
500
|
/**
|
|
498
501
|
* ๐ง **The prompt choice's reach** (R54, 2026-10-21): `'owner'` offers
|
|
@@ -534,7 +537,21 @@ export declare function isModelCall(def: {
|
|
|
534
537
|
kind: string;
|
|
535
538
|
}>>;
|
|
536
539
|
}): boolean;
|
|
537
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* Whether a spec **calls a model at all**: any node whose definition `isModelCall`, or any definition
|
|
542
|
+
* a node lists in `expose.swaps` that does (a swap can seat a model call). A definition the registry
|
|
543
|
+
* does not know counts as none. Decides where a step purpose is allowed: on any step of a spec that
|
|
544
|
+
* calls no model, and only on a model call in one that does.
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
export declare function specCallsModel(nodes: readonly {
|
|
548
|
+
definitionId: string;
|
|
549
|
+
definitionVersion: number;
|
|
550
|
+
expose?: {
|
|
551
|
+
swaps?: readonly string[];
|
|
552
|
+
};
|
|
553
|
+
}[]): boolean;
|
|
554
|
+
/** The one sentence a misplaced step purpose is refused with, at `build()` and at `validate()`. @internal */
|
|
538
555
|
export declare const stepPurposeRefusal: (key: string, definitionId: string) => string;
|
|
539
556
|
/**
|
|
540
557
|
* A pinned constructor of a given kind. Constraining each method to its own kind makes
|
package/dist/builder.js
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* to the same rows.
|
|
15
15
|
* @ruling 04 ยง4, 04 ยง4a, R-14 (2026-09-15), F6
|
|
16
16
|
*/
|
|
17
|
-
import { eventsLockFindings, swapFitFinding, } from './descriptors.js';
|
|
17
|
+
import { eventsLockFindings, swapFitFinding, getDefinition, } from './descriptors.js';
|
|
18
18
|
import { makeScope, ITEM } from './scope.js';
|
|
19
|
-
import { isDataRef, isSlotRef, slot } from './refs.js';
|
|
19
|
+
import { collectDataRefs, 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';
|
|
@@ -70,8 +70,6 @@ function exposeOf(key, pinned, expose) {
|
|
|
70
70
|
if (bad.length)
|
|
71
71
|
throw new Error(bad[0]);
|
|
72
72
|
}
|
|
73
|
-
if (expose.purpose !== undefined && !isModelCall(pinned))
|
|
74
|
-
throw new Error(stepPurposeRefusal(key, pinned.id));
|
|
75
73
|
if (expose.promptReach !== undefined) {
|
|
76
74
|
if (expose.promptReach !== 'owner')
|
|
77
75
|
throw new Error(`node '${key}': expose.promptReach is 'owner' or absent โ an administrator's choice is the default`);
|
|
@@ -106,7 +104,21 @@ function exposeOf(key, pinned, expose) {
|
|
|
106
104
|
export function isModelCall(def) {
|
|
107
105
|
return def.kind === 'oracle' && Object.values(def.slots ?? {}).some((s) => s.kind === 'connection');
|
|
108
106
|
}
|
|
109
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Whether a spec **calls a model at all**: any node whose definition `isModelCall`, or any definition
|
|
109
|
+
* a node lists in `expose.swaps` that does (a swap can seat a model call). A definition the registry
|
|
110
|
+
* does not know counts as none. Decides where a step purpose is allowed: on any step of a spec that
|
|
111
|
+
* calls no model, and only on a model call in one that does.
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
export function specCallsModel(nodes) {
|
|
115
|
+
const calls = (id) => {
|
|
116
|
+
const def = getDefinition(id);
|
|
117
|
+
return def !== undefined && isModelCall(def);
|
|
118
|
+
};
|
|
119
|
+
return nodes.some((n) => calls(`${n.definitionId}@${n.definitionVersion}`) || (n.expose?.swaps ?? []).some(calls));
|
|
120
|
+
}
|
|
121
|
+
/** The one sentence a misplaced step purpose is refused with, at `build()` and at `validate()`. @internal */
|
|
110
122
|
export const stepPurposeRefusal = (key, definitionId) => `node '${key}': expose.purpose says what a model call is for, but ${definitionId} calls no model โ ` +
|
|
111
123
|
`put the purpose on the oracle that does, or give this step a label instead`;
|
|
112
124
|
/**
|
|
@@ -933,6 +945,16 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
933
945
|
return this;
|
|
934
946
|
}
|
|
935
947
|
build() {
|
|
948
|
+
// A step purpose is allowed on any step of a spec that calls no model, and only on a model
|
|
949
|
+
// call in one that does: a rule over the whole spec, so it is checked here, not per node.
|
|
950
|
+
if (this.spec.nodes.some((n) => n.expose?.purpose !== undefined) && specCallsModel(this.spec.nodes))
|
|
951
|
+
for (const n of this.spec.nodes) {
|
|
952
|
+
if (n.expose?.purpose === undefined)
|
|
953
|
+
continue;
|
|
954
|
+
const def = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
|
|
955
|
+
if (def && !isModelCall(def))
|
|
956
|
+
throw new Error(stepPurposeRefusal(n.key, def.id));
|
|
957
|
+
}
|
|
936
958
|
// ๐ง A pipeline mounted by registrations (the suits form) offers its
|
|
937
959
|
// actions where a registration includes them, so they carry no genre
|
|
938
960
|
// (D3). A spec that said nothing at its inlet still needs the lock.
|
|
@@ -942,6 +964,7 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
942
964
|
throw new Error(`spec '${this.spec.id}' contributes action '${orphan.key}' but has no inlet lock โ ` +
|
|
943
965
|
`register the action (register(spec.actions.${orphan.key}, spec)) and declare the inlet with ` +
|
|
944
966
|
`{ suits: [ โฆ ] }, or โณ lock it: .inlet(key, node, { genre, event })`);
|
|
967
|
+
supplyPromptStepWiring(this.spec);
|
|
945
968
|
// The handles, beside the document and never in it: non-enumerable,
|
|
946
969
|
// so nothing that serializes, hashes or compares a spec sees them.
|
|
947
970
|
Object.defineProperty(this.spec, 'actions', {
|
|
@@ -953,6 +976,35 @@ export class SpecBuilder extends ChainBuilder {
|
|
|
953
976
|
return this.spec;
|
|
954
977
|
}
|
|
955
978
|
}
|
|
979
|
+
/**
|
|
980
|
+
* Writes the wiring an `assemble@2` that feeds a model call leaves out:
|
|
981
|
+
* `template` becomes `slot.template()` and `connection` becomes
|
|
982
|
+
* `slot.connectionOf(<the model call it feeds>)`. A key the spec states is
|
|
983
|
+
* kept; only `undefined` ones are filled, so a second call changes nothing.
|
|
984
|
+
* Mirrors `validate()`'s `assemble wiring` law, over the built nodes (no
|
|
985
|
+
* edges yet): the model call is the first oracle, in node order, whose config
|
|
986
|
+
* reads this assemble's output and which `isModelCall`.
|
|
987
|
+
*/
|
|
988
|
+
function supplyPromptStepWiring(spec) {
|
|
989
|
+
for (const assemble of spec.nodes) {
|
|
990
|
+
if (assemble.definitionId !== 'core:task/assemble' || assemble.definitionVersion !== 2)
|
|
991
|
+
continue;
|
|
992
|
+
const modelCall = spec.nodes.find((n) => {
|
|
993
|
+
if (n.kind !== 'oracle')
|
|
994
|
+
return false;
|
|
995
|
+
if (!collectDataRefs(n.config).some(({ ref }) => ref.node === assemble.key))
|
|
996
|
+
return false;
|
|
997
|
+
const d = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
|
|
998
|
+
return d !== undefined && isModelCall(d);
|
|
999
|
+
});
|
|
1000
|
+
if (!modelCall)
|
|
1001
|
+
continue;
|
|
1002
|
+
if (assemble.config.template === undefined)
|
|
1003
|
+
assemble.config.template = slot.template();
|
|
1004
|
+
if (assemble.config.connection === undefined)
|
|
1005
|
+
assemble.config.connection = slot.connectionOf(modelCall.key);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
956
1008
|
/** The slug the declared defaults are stored under (`.defaults()`). @internal */
|
|
957
1009
|
export const DEFAULTS_SLUG = 'default';
|
|
958
1010
|
/**
|
package/dist/cadences.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* (`core:cadence/every-n-turns@1`) and **options** declared as fields, so a
|
|
14
14
|
* registration states it as `{ id, options }` (a `CadenceRef`): addressable,
|
|
15
15
|
* serializable, validated by the same field declarations an administrator's
|
|
16
|
-
* settings use (ยง11-3). Core's
|
|
16
|
+
* settings use (ยง11-3). Core's eleven are evaluated natively by the host
|
|
17
17
|
* (`evaluate: 'host'`); a plugin's cadence is a script of kind
|
|
18
18
|
* `core:script:cadence/due@1`, run in the sandbox.
|
|
19
19
|
*
|
|
@@ -48,7 +48,7 @@ import type { EntityKind } from './entities.js';
|
|
|
48
48
|
import { type FieldDecl } from './settings.js';
|
|
49
49
|
import { type I18n } from './i18n.js';
|
|
50
50
|
import { type ConditionDecl } from './conditions.js';
|
|
51
|
-
import { type EventDef, type SessionEventDecl } from './events.js';
|
|
51
|
+
import { type EventDef, type SessionEventDecl, type TurnSeatChange } from './events.js';
|
|
52
52
|
import { type StoryCalendar, type StoryTime, type StoryTimeUnit } from './storyTime.js';
|
|
53
53
|
/** ๐ง `core:event/turn-ended@1` โ a turn ended (R51). @experimental */
|
|
54
54
|
export declare const TURN_ENDED_EVENT: 'core:event/turn-ended@1';
|
|
@@ -336,6 +336,8 @@ export declare const EVERY_N_TURNS: CadenceDef;
|
|
|
336
336
|
/** @experimental */
|
|
337
337
|
export declare const AFTER_EACH_TURN: CadenceDef;
|
|
338
338
|
/** @experimental */
|
|
339
|
+
export declare const EVERY_N_ROUNDS: CadenceDef;
|
|
340
|
+
/** @experimental */
|
|
339
341
|
export declare const AFTER_EACH_ROUND: CadenceDef;
|
|
340
342
|
/** @experimental */
|
|
341
343
|
export declare const AFTER_EACH_SCENE: CadenceDef;
|
|
@@ -354,6 +356,7 @@ export declare const SCHEDULE: CadenceDef;
|
|
|
354
356
|
/** Core's cadences, by name. @experimental */
|
|
355
357
|
export declare const coreCadences: Readonly<{
|
|
356
358
|
everyNTurns: CadenceDef;
|
|
359
|
+
everyNRounds: CadenceDef;
|
|
357
360
|
afterEachTurn: CadenceDef;
|
|
358
361
|
afterEachRound: CadenceDef;
|
|
359
362
|
afterEachScene: CadenceDef;
|
|
@@ -394,6 +397,10 @@ export declare function cadenceCarries(ref: CadenceRef): EntityKind[];
|
|
|
394
397
|
export declare const everyNTurns: (o: {
|
|
395
398
|
n: number;
|
|
396
399
|
}) => CadenceRef;
|
|
400
|
+
/** Every `n` rounds โ the 2nd, the 4th, โฆ @experimental */
|
|
401
|
+
export declare const everyNRounds: (o: {
|
|
402
|
+
n: number;
|
|
403
|
+
}) => CadenceRef;
|
|
397
404
|
/** After every turn. @experimental */
|
|
398
405
|
export declare const afterEachTurn: () => CadenceRef;
|
|
399
406
|
/** After every round โ the "wait for everyone". @experimental */
|
|
@@ -568,6 +575,8 @@ export interface RoutineCause {
|
|
|
568
575
|
turnsBy?: Readonly<Record<string, number>>;
|
|
569
576
|
/** ๐ง `round-ended`: who spoke in the round, in order of first turn (R52). */
|
|
570
577
|
speakers?: readonly string[];
|
|
578
|
+
/** ๐ง `turn-ended`, when the genre declares `shape.turnSeatChanges: true`: the seats that changed since the previous turn (`TurnSeatChange`). */
|
|
579
|
+
turnSeatChanges?: readonly TurnSeatChange[];
|
|
571
580
|
actor?: string;
|
|
572
581
|
castMember?: string;
|
|
573
582
|
subject?: string;
|
package/dist/cadences.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* (`core:cadence/every-n-turns@1`) and **options** declared as fields, so a
|
|
14
14
|
* registration states it as `{ id, options }` (a `CadenceRef`): addressable,
|
|
15
15
|
* serializable, validated by the same field declarations an administrator's
|
|
16
|
-
* settings use (ยง11-3). Core's
|
|
16
|
+
* settings use (ยง11-3). Core's eleven are evaluated natively by the host
|
|
17
17
|
* (`evaluate: 'host'`); a plugin's cadence is a script of kind
|
|
18
18
|
* `core:script:cadence/due@1`, run in the sandbox.
|
|
19
19
|
*
|
|
@@ -357,7 +357,7 @@ function scheduleAtFindings(raw, clock, at) {
|
|
|
357
357
|
}
|
|
358
358
|
return out;
|
|
359
359
|
}
|
|
360
|
-
// โโ Core's
|
|
360
|
+
// โโ Core's eleven (PLAN-layering D2) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
361
361
|
const HOST = 'host';
|
|
362
362
|
/** @experimental */
|
|
363
363
|
export const EVERY_N_TURNS = defineCadence({
|
|
@@ -392,6 +392,20 @@ export const AFTER_EACH_TURN = defineCadence({
|
|
|
392
392
|
evaluate: HOST,
|
|
393
393
|
});
|
|
394
394
|
/** @experimental */
|
|
395
|
+
export const EVERY_N_ROUNDS = defineCadence({
|
|
396
|
+
id: 'core:cadence/every-n-rounds@1',
|
|
397
|
+
i18n: {
|
|
398
|
+
name: { en: 'Every few rounds' },
|
|
399
|
+
description: { en: 'Runs after every so many rounds of the session.' },
|
|
400
|
+
},
|
|
401
|
+
options: {
|
|
402
|
+
n: { type: 'integer', min: 1, max: 1000, default: 2, label: { en: 'Every how many rounds' } },
|
|
403
|
+
},
|
|
404
|
+
wakesOn: [ROUND_ENDED_EVENT],
|
|
405
|
+
carries: ['session'],
|
|
406
|
+
evaluate: HOST,
|
|
407
|
+
});
|
|
408
|
+
/** @experimental */
|
|
395
409
|
export const AFTER_EACH_ROUND = defineCadence({
|
|
396
410
|
id: 'core:cadence/after-each-round@1',
|
|
397
411
|
i18n: {
|
|
@@ -537,6 +551,7 @@ export const SCHEDULE = defineCadence({
|
|
|
537
551
|
/** Core's cadences, by name. @experimental */
|
|
538
552
|
export const coreCadences = Object.freeze({
|
|
539
553
|
everyNTurns: EVERY_N_TURNS,
|
|
554
|
+
everyNRounds: EVERY_N_ROUNDS,
|
|
540
555
|
afterEachTurn: AFTER_EACH_TURN,
|
|
541
556
|
afterEachRound: AFTER_EACH_ROUND,
|
|
542
557
|
afterEachScene: AFTER_EACH_SCENE,
|
|
@@ -692,6 +707,8 @@ const freezeRef = (id, options) => {
|
|
|
692
707
|
// โโ The ready-made cadences (each returns a `CadenceRef`) โโโโโโโโโโโโโโโโโโโ
|
|
693
708
|
/** Every `n` turns โ the 5th, the 10th, โฆ @experimental */
|
|
694
709
|
export const everyNTurns = (o) => freezeRef(EVERY_N_TURNS.id, { n: o?.n });
|
|
710
|
+
/** Every `n` rounds โ the 2nd, the 4th, โฆ @experimental */
|
|
711
|
+
export const everyNRounds = (o) => freezeRef(EVERY_N_ROUNDS.id, { n: o?.n });
|
|
695
712
|
/** After every turn. @experimental */
|
|
696
713
|
export const afterEachTurn = () => freezeRef(AFTER_EACH_TURN.id, {});
|
|
697
714
|
/** After every round โ the "wait for everyone". @experimental */
|
|
@@ -945,6 +962,14 @@ export function cadenceDue(ref, event, state = {}) {
|
|
|
945
962
|
? { due: true, state }
|
|
946
963
|
: no(state, `turn ${m.turn} is not a multiple of ${n}`);
|
|
947
964
|
}
|
|
965
|
+
case EVERY_N_ROUNDS.id: {
|
|
966
|
+
if (m.event !== ROUND_ENDED_EVENT)
|
|
967
|
+
break;
|
|
968
|
+
const n = isWhole(o.n) && o.n >= 1 ? o.n : 2;
|
|
969
|
+
return m.round >= 1 && m.round % n === 0
|
|
970
|
+
? { due: true, state }
|
|
971
|
+
: no(state, `round ${m.round} is not a multiple of ${n}`);
|
|
972
|
+
}
|
|
948
973
|
case AFTER_EACH_TURN.id:
|
|
949
974
|
case AFTER_EACH_ROUND.id:
|
|
950
975
|
case AFTER_EACH_SCENE.id:
|