@serene-pub/sdk 0.6.0-pr-7 → 0.6.0-pr-9

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 (106) hide show
  1. package/dist/annexFields.d.ts +14 -0
  2. package/dist/annexFields.js +7 -0
  3. package/dist/announce.d.ts +62 -16
  4. package/dist/announce.js +90 -4
  5. package/dist/appletCard.d.ts +17 -0
  6. package/dist/appletCard.js +60 -0
  7. package/dist/attributes.d.ts +3 -3
  8. package/dist/attributes.js +1 -1
  9. package/dist/builder.d.ts +28 -13
  10. package/dist/builder.js +57 -5
  11. package/dist/cadences.d.ts +8 -1
  12. package/dist/cadences.js +27 -2
  13. package/dist/characterProfile.d.ts +137 -0
  14. package/dist/characterProfile.js +24 -0
  15. package/dist/component.d.ts +1 -1
  16. package/dist/componentImports.d.ts +1 -1
  17. package/dist/componentImports.js +2 -0
  18. package/dist/componentWire.js +28 -0
  19. package/dist/conditions.d.ts +5 -1
  20. package/dist/conditions.js +7 -0
  21. package/dist/declarations.d.ts +63 -1
  22. package/dist/declarations.js +176 -7
  23. package/dist/descriptors.d.ts +145 -6
  24. package/dist/descriptors.js +106 -5
  25. package/dist/document.d.ts +9 -1
  26. package/dist/document.js +44 -1
  27. package/dist/events.d.ts +82 -8
  28. package/dist/events.js +42 -5
  29. package/dist/executor.d.ts +27 -0
  30. package/dist/executor.js +32 -8
  31. package/dist/exposure.d.ts +35 -1
  32. package/dist/exposure.js +64 -2
  33. package/dist/extension.d.ts +30 -2
  34. package/dist/extension.js +3 -1
  35. package/dist/fit.d.ts +4 -1
  36. package/dist/fit.js +43 -1
  37. package/dist/functions.d.ts +7 -1
  38. package/dist/functions.js +3 -1
  39. package/dist/genres.d.ts +67 -2
  40. package/dist/genres.js +160 -8
  41. package/dist/hookGrants.js +10 -0
  42. package/dist/hostElements.d.ts +3 -3
  43. package/dist/hostElements.js +12 -4
  44. package/dist/index.d.ts +5 -0
  45. package/dist/index.js +10 -0
  46. package/dist/layout.d.ts +18 -0
  47. package/dist/libraryDraft.d.ts +2 -0
  48. package/dist/libraryDraft.js +5 -1
  49. package/dist/lorebookFile.d.ts +8 -0
  50. package/dist/lorebookFile.js +21 -0
  51. package/dist/participants.d.ts +83 -8
  52. package/dist/participants.js +9 -5
  53. package/dist/pluginPermissions.js +1 -1
  54. package/dist/promptBlocks.d.ts +5 -1
  55. package/dist/promptBlocks.js +23 -8
  56. package/dist/provisos.d.ts +92 -0
  57. package/dist/provisos.js +273 -0
  58. package/dist/receiverRules.js +1 -1
  59. package/dist/registrations.d.ts +154 -14
  60. package/dist/registrations.js +293 -23
  61. package/dist/registry.js +6 -3
  62. package/dist/repertoires.d.ts +13 -1
  63. package/dist/repertoires.js +5 -1
  64. package/dist/rulesetDocument.d.ts +11 -0
  65. package/dist/rulesetDocument.js +17 -0
  66. package/dist/rulesetSections.d.ts +12 -0
  67. package/dist/rulesetSections.js +8 -0
  68. package/dist/rulesets.js +6 -0
  69. package/dist/sceneSettings.d.ts +7 -1
  70. package/dist/sceneSettings.js +10 -5
  71. package/dist/sessionDossier.d.ts +159 -2
  72. package/dist/sessionLayout.d.ts +296 -85
  73. package/dist/sessionLayout.js +397 -133
  74. package/dist/sessionSettings.d.ts +18 -0
  75. package/dist/settings.d.ts +28 -1
  76. package/dist/settings.js +50 -2
  77. package/dist/shapes.d.ts +15 -1
  78. package/dist/shapes.js +15 -1
  79. package/dist/sheetLatitude.d.ts +148 -0
  80. package/dist/sheetLatitude.js +161 -0
  81. package/dist/speech.d.ts +14 -3
  82. package/dist/storyTime.d.ts +77 -1
  83. package/dist/storyTime.js +117 -8
  84. package/dist/surfaces.d.ts +49 -2
  85. package/dist/surfaces.js +3 -0
  86. package/dist/template.d.ts +38 -1
  87. package/dist/templateCheck.d.ts +24 -0
  88. package/dist/templateCheck.js +465 -10
  89. package/dist/templateFit.js +8 -1
  90. package/dist/templateIds.d.ts +6 -0
  91. package/dist/templateIds.js +9 -0
  92. package/dist/turnLock.d.ts +10 -1
  93. package/dist/turnLock.js +6 -1
  94. package/dist/turnOrder.d.ts +37 -4
  95. package/dist/turnOrder.js +49 -11
  96. package/dist/validate.d.ts +4 -2
  97. package/dist/validate.js +84 -11
  98. package/dist/variableLayouts.d.ts +160 -0
  99. package/dist/variableLayouts.js +202 -0
  100. package/dist/variables.d.ts +237 -20
  101. package/dist/variables.js +292 -33
  102. package/dist/widgetDecls.js +12 -0
  103. package/dist/widgets.d.ts +449 -47
  104. package/dist/widgets.js +31 -0
  105. package/host-elements.d.ts +4 -2
  106. package/package.json +1 -1
@@ -42,6 +42,11 @@
42
42
  export interface TurnMessage {
43
43
  id: number;
44
44
  speakerId: number | null;
45
+ /**
46
+ * 🚧 The speaker's cast member (the member behind `speakerId`), when the
47
+ * asker knows. What a `seated_member` owner matches on — never `speakerId`.
48
+ */
49
+ castMemberId?: number | null;
45
50
  /**
46
51
  * The **turn** the message belongs to — the run that created it — when
47
52
  * the asker knows. Optional: absent, the
@@ -63,7 +68,11 @@ export interface TurnMessage {
63
68
  * @experimental
64
69
  */
65
70
  export interface TurnOwner {
66
- kind: 'session' | 'session_cast';
71
+ /**
72
+ * `session_cast`'s `id` is the card — ⏳ removed in S5 of the seat-cast
73
+ * programme. 🚧 `seated_member`'s `id` is the cast member id.
74
+ */
75
+ kind: 'session' | 'session_cast' | 'seated_member';
67
76
  id: number;
68
77
  }
69
78
  /**
package/dist/turnLock.js CHANGED
@@ -44,8 +44,13 @@
44
44
  export function openAnchorFor(messages, owner) {
45
45
  if (owner.kind === 'session')
46
46
  return messages.length ? messages[messages.length - 1].id : null;
47
+ // A card id and a cast member id share one number range: a `seated_member`
48
+ // owner is matched on `castMemberId` alone, never on `speakerId`.
49
+ const matches = owner.kind === 'seated_member'
50
+ ? (m) => m.castMemberId === owner.id
51
+ : (m) => m.speakerId === owner.id;
47
52
  for (let i = messages.length - 1; i >= 0; i--)
48
- if (messages[i].speakerId === owner.id)
53
+ if (matches(messages[i]))
49
54
  return messages[i].id;
50
55
  return null;
51
56
  }
@@ -97,6 +97,12 @@ export interface TurnHistoryMessage {
97
97
  role: string;
98
98
  characterId?: number | null;
99
99
  personaId?: number | null;
100
+ /**
101
+ * 🚧 The speaker's cast member (the host's `cast_member_id` on the row).
102
+ * Read through the cast lookup (`refOfMember`) when one is given; absent,
103
+ * the card form is read (⏳ until S5 of the seat-cast programme).
104
+ */
105
+ castMemberId?: number | null;
100
106
  isHidden?: boolean | null;
101
107
  isNarratorResponse?: boolean | null;
102
108
  /**
@@ -114,9 +120,19 @@ export interface TurnHistoryMessage {
114
120
  * carries; null for a row from neither. The one reading of a sender —
115
121
  * the row that opens a round (`spokenRefsSince`) is read by it.
116
122
  *
123
+ * 🚧 `refOfMember` is the cast lookup: a cast member id → the seat's `ref`, as
124
+ * the cast entry whose `castMemberId` matches carries it. When the row has a
125
+ * `castMemberId` and the lookup returns a ref, that ref is the sender; it
126
+ * changes **identity only**, never whether a row is a sender (an assistant row
127
+ * never becomes one). Without the lookup the card form is read (⏳ until S5 of
128
+ * the seat-cast programme). A sender is always a player seat's line, so the
129
+ * lookup is asked for a `'player-seat'`.
130
+ *
117
131
  * @experimental 🚧 provisional with the turn-order vocabulary.
118
132
  */
119
- export declare function senderRefOf(m: Pick<TurnHistoryMessage, 'personaId' | 'speaker' | 'metadata'>): `character:${number}` | `player-seat:${number}` | null;
133
+ export declare function senderRefOf(m: Pick<TurnHistoryMessage, 'personaId' | 'castMemberId' | 'speaker' | 'metadata'>, refOfMember?: (castMemberId: number,
134
+ /** Which kind of seat the caller means; the lookup prefers a seat of that kind and falls back to any seat of the member. */
135
+ seatKind?: 'character-seat' | 'player-seat') => ParticipantRef | null | undefined): ParticipantRef | null;
120
136
  /**
121
137
  * The rows that count as turns: not hidden, not narration. Hidden rows and
122
138
  * narrator responses are outside the rotation entirely. A missing row (`null`
@@ -129,7 +145,8 @@ export declare function senderRefOf(m: Pick<TurnHistoryMessage, 'personaId' | 's
129
145
  export declare function countedTurns<M extends TurnHistoryMessage>(messages: readonly (M | null | undefined)[]): M[];
130
146
  /**
131
147
  * Which participants have already spoken since the person last did, as
132
- * references (`character:<id>`, `player-seat:<id>`, `envoy:<slug>`).
148
+ * references (`character:<id>`, 🚧 `seated-member:<id>`, `player-seat:<id>`,
149
+ * `envoy:<slug>`).
133
150
  *
134
151
  * Three readings, one per kind, each the fact that kind leaves in the
135
152
  * history: a character's id on a reply row, an envoy's reference on a reply
@@ -139,10 +156,20 @@ export declare function countedTurns<M extends TurnHistoryMessage>(messages: rea
139
156
  * envoy's reply marks no character. Before any user row the whole history is
140
157
  * one round, so a greeting counts as its character's turn.
141
158
  *
159
+ * 🚧 `refOfMember` is the cast lookup: a cast member id → the seat's `ref`, as
160
+ * the cast entry whose `castMemberId` matches carries it. A row with a
161
+ * `castMemberId` the lookup answers is read as that ref (a card-less member's
162
+ * reply too); otherwise the card form is read (⏳ until S5 of the seat-cast
163
+ * programme). It changes identity only, never whether a row counts. Without
164
+ * it the answer is as it was. A reply row asks the lookup for a `'character-seat'`,
165
+ * the opening person's row for a `'player-seat'`.
166
+ *
142
167
  * @experimental 🚧 provisional with the turn-order vocabulary.
143
168
  * @ruling PLAN-turn-order §4.4
144
169
  */
145
- export declare function spokenRefsSince(messages: readonly (TurnHistoryMessage | null | undefined)[]): Set<string>;
170
+ export declare function spokenRefsSince(messages: readonly (TurnHistoryMessage | null | undefined)[], refOfMember?: (castMemberId: number,
171
+ /** Which kind of seat the caller means; the lookup prefers a seat of that kind and falls back to any seat of the member. */
172
+ seatKind?: 'character-seat' | 'player-seat') => ParticipantRef | null | undefined): Set<string>;
146
173
  /**
147
174
  * Round robin — once per turn of the person's: every candidate that has not
148
175
  * spoken since the person last did, in candidate order, each entry
@@ -153,8 +180,14 @@ export declare function spokenRefsSince(messages: readonly (TurnHistoryMessage |
153
180
  * This is the rule `core:task/turn-round-robin@1` runs, and the fallback a
154
181
  * plugin's own strategy should use rather than carry a copy of it.
155
182
  *
183
+ * 🚧 `refOfMember` is the cast lookup, passed through to `spokenRefsSince`
184
+ * (see there, with its seat-kind hint); without it the card form is read (⏳ until
185
+ * S5 of the seat-cast programme).
186
+ *
156
187
  * @experimental 🚧 provisional with the turn-order vocabulary.
157
188
  * @ruling PLAN-turn-order §4.4
158
189
  */
159
- export declare function roundRobinOrder(candidates: readonly TurnCandidateV1[], messages: readonly (TurnHistoryMessage | null | undefined)[]): TurnEntryV1[];
190
+ export declare function roundRobinOrder(candidates: readonly TurnCandidateV1[], messages: readonly (TurnHistoryMessage | null | undefined)[], refOfMember?: (castMemberId: number,
191
+ /** Which kind of seat the caller means; the lookup prefers a seat of that kind and falls back to any seat of the member. */
192
+ seatKind?: 'character-seat' | 'player-seat') => ParticipantRef | null | undefined): TurnEntryV1[];
160
193
  //# sourceMappingURL=turnOrder.d.ts.map
package/dist/turnOrder.js CHANGED
@@ -65,13 +65,33 @@ const speakerRefOf = (m) => m.speaker ?? m.metadata?.speaker;
65
65
  * carries; null for a row from neither. The one reading of a sender —
66
66
  * the row that opens a round (`spokenRefsSince`) is read by it.
67
67
  *
68
+ * 🚧 `refOfMember` is the cast lookup: a cast member id → the seat's `ref`, as
69
+ * the cast entry whose `castMemberId` matches carries it. When the row has a
70
+ * `castMemberId` and the lookup returns a ref, that ref is the sender; it
71
+ * changes **identity only**, never whether a row is a sender (an assistant row
72
+ * never becomes one). Without the lookup the card form is read (⏳ until S5 of
73
+ * the seat-cast programme). A sender is always a player seat's line, so the
74
+ * lookup is asked for a `'player-seat'`.
75
+ *
68
76
  * @experimental 🚧 provisional with the turn-order vocabulary.
69
77
  */
70
- export function senderRefOf(m) {
71
- if (m.personaId != null)
72
- return `character:${m.personaId}`;
73
- const ref = speakerRefOf(m);
74
- return typeof ref === 'string' && /^player-seat:[1-9][0-9]*$/.test(ref) ? ref : null;
78
+ export function senderRefOf(m, refOfMember) {
79
+ const today = (() => {
80
+ if (m.personaId != null)
81
+ return `character:${m.personaId}`;
82
+ const ref = speakerRefOf(m);
83
+ return typeof ref === 'string' && /^player-seat:[1-9][0-9]*$/.test(ref)
84
+ ? ref
85
+ : null;
86
+ })();
87
+ if (!today)
88
+ return null;
89
+ if (m.castMemberId != null && refOfMember) {
90
+ const ref = refOfMember(m.castMemberId, 'player-seat');
91
+ if (ref)
92
+ return ref;
93
+ }
94
+ return today;
75
95
  }
76
96
  /**
77
97
  * The rows that count as turns: not hidden, not narration. Hidden rows and
@@ -93,7 +113,8 @@ const lastUserIndex = (turns) => {
93
113
  };
94
114
  /**
95
115
  * Which participants have already spoken since the person last did, as
96
- * references (`character:<id>`, `player-seat:<id>`, `envoy:<slug>`).
116
+ * references (`character:<id>`, 🚧 `seated-member:<id>`, `player-seat:<id>`,
117
+ * `envoy:<slug>`).
97
118
  *
98
119
  * Three readings, one per kind, each the fact that kind leaves in the
99
120
  * history: a character's id on a reply row, an envoy's reference on a reply
@@ -103,10 +124,18 @@ const lastUserIndex = (turns) => {
103
124
  * envoy's reply marks no character. Before any user row the whole history is
104
125
  * one round, so a greeting counts as its character's turn.
105
126
  *
127
+ * 🚧 `refOfMember` is the cast lookup: a cast member id → the seat's `ref`, as
128
+ * the cast entry whose `castMemberId` matches carries it. A row with a
129
+ * `castMemberId` the lookup answers is read as that ref (a card-less member's
130
+ * reply too); otherwise the card form is read (⏳ until S5 of the seat-cast
131
+ * programme). It changes identity only, never whether a row counts. Without
132
+ * it the answer is as it was. A reply row asks the lookup for a `'character-seat'`,
133
+ * the opening person's row for a `'player-seat'`.
134
+ *
106
135
  * @experimental 🚧 provisional with the turn-order vocabulary.
107
136
  * @ruling PLAN-turn-order §4.4
108
137
  */
109
- export function spokenRefsSince(messages) {
138
+ export function spokenRefsSince(messages, refOfMember) {
110
139
  const turns = countedTurns(messages);
111
140
  const at = lastUserIndex(turns);
112
141
  const out = new Set();
@@ -114,13 +143,18 @@ export function spokenRefsSince(messages) {
114
143
  const m = turns[i];
115
144
  if (m.role !== 'assistant')
116
145
  continue;
117
- if (m.characterId != null)
146
+ const memberRef = m.castMemberId != null && refOfMember
147
+ ? refOfMember(m.castMemberId, 'character-seat')
148
+ : null;
149
+ if (memberRef)
150
+ out.add(memberRef);
151
+ else if (m.characterId != null)
118
152
  out.add(`character:${m.characterId}`);
119
153
  const ref = speakerRefOf(m);
120
154
  if (typeof ref === 'string' && ref.startsWith('envoy:'))
121
155
  out.add(ref);
122
156
  }
123
- const sender = at >= 0 ? senderRefOf(turns[at]) : null;
157
+ const sender = at >= 0 ? senderRefOf(turns[at], refOfMember) : null;
124
158
  if (sender)
125
159
  out.add(sender);
126
160
  return out;
@@ -135,11 +169,15 @@ export function spokenRefsSince(messages) {
135
169
  * This is the rule `core:task/turn-round-robin@1` runs, and the fallback a
136
170
  * plugin's own strategy should use rather than carry a copy of it.
137
171
  *
172
+ * 🚧 `refOfMember` is the cast lookup, passed through to `spokenRefsSince`
173
+ * (see there, with its seat-kind hint); without it the card form is read (⏳ until
174
+ * S5 of the seat-cast programme).
175
+ *
138
176
  * @experimental 🚧 provisional with the turn-order vocabulary.
139
177
  * @ruling PLAN-turn-order §4.4
140
178
  */
141
- export function roundRobinOrder(candidates, messages) {
142
- const spoken = spokenRefsSince(messages);
179
+ export function roundRobinOrder(candidates, messages, refOfMember) {
180
+ const spoken = spokenRefsSince(messages, refOfMember);
143
181
  return candidates.filter((c) => !spoken.has(c.ref)).map((c) => ({ ref: c.ref, via: 'strategy' }));
144
182
  }
145
183
  //# sourceMappingURL=turnOrder.js.map
@@ -57,8 +57,10 @@ export declare function validate(doc: SpecDocument, options?: ValidateOptions):
57
57
  * · **an oracle** — only an oracle has a model's tokens to stream.
58
58
  *
59
59
  * A step status, step label and step purpose are display text, and a
60
- * step purpose sits only on a model call — an oracle whose definition declares
61
- * a `connection` slot (`isModelCall`; law `step purpose`, 2026-09-30).
60
+ * step purpose sits on any step of a document that calls no model at all; in
61
+ * one that calls a model (a node, or a swap a node lists, whose definition
62
+ * declares a `connection` slot — `isModelCall`) it sits only on a model call
63
+ * (law `step purpose`, 2026-09-30; widened 2026-11-12).
62
64
  * @internal
63
65
  * @ruling lair pass B3/B18, owner D6 and D5 (2026-09-27), W2 (2026-09-27), R-20
64
66
  */
package/dist/validate.js CHANGED
@@ -21,7 +21,7 @@ import { boundaryTriggerFindings } from './sceneSettings.js';
21
21
  import { templateLawFindings } from './templateFit.js';
22
22
  import { isSlotRef } from './refs.js';
23
23
  import { assignable, isStreaming, JSON_SHAPE } from './shapes.js';
24
- import { isModelCall, stepPurposeRefusal } from './builder.js';
24
+ import { isModelCall, specCallsModel, stepPurposeRefusal } from './builder.js';
25
25
  import { capabilityLabel, FEATURES, IO_KINDS, IO_KIND_TOKEN, isKnownIoKind, isTransformId, parseTransform, transformId, } from './capabilities.js';
26
26
  /**
27
27
  * The port shapes a spec may assemble field by field (`templateContext: {
@@ -1180,13 +1180,13 @@ export function validate(doc, options = {}) {
1180
1180
  }
1181
1181
  // ── assemble wiring — a prompt is assembled for the model call it feeds ───
1182
1182
  // `assemble@2` reads its `template` slot and the connection it renders for
1183
- // only when the spec wires them: unwired, the run halts on a real instance
1184
- // ("assemble has no template"), and once the template is wired a chat
1185
- // wire-mode connection is handed a prompt with no messages. Neither shows
1186
- // on a fixture host, so it is said here, where the author is (F3 docs
1187
- // gate, stalls 12 and 14). A warning, not an error: a host saves documents
1188
- // its own tests and older plugins built bare, and the run's own halt is
1189
- // the error.
1183
+ // only when the document wires them: unwired, the run halts on a real
1184
+ // instance ("assemble has no template"), and once the template is wired a
1185
+ // chat wire-mode connection is handed a prompt with no messages. Neither
1186
+ // shows on a fixture host. The builder's `build()` now supplies both, so
1187
+ // this warns on a document that did not come through the builder: hand
1188
+ // written, an older plugin's, or a host's own tests. A warning, not an
1189
+ // error: the run's own halt is the error.
1190
1190
  for (const n of doc.nodes) {
1191
1191
  if (n.definitionId !== 'core:task/assemble' || n.definitionVersion !== 2)
1192
1192
  continue;
@@ -1222,6 +1222,75 @@ export function validate(doc, options = {}) {
1222
1222
  fix: `add connection: slot.connectionOf('${generate.key}') to '${n.key}', so the prompt is written for the connection that sends it`,
1223
1223
  });
1224
1224
  }
1225
+ // ── firsthand (opt-in, 2026-11-15) — the reads agree ──────────────────────
1226
+ // `firsthandFor` leaves out what the speaker was not there for, on each of
1227
+ // three reads: session history, earlier scenes, history entries. Among the
1228
+ // read types the document holds, if one has a node wired with it and
1229
+ // another has none, the prompt would carry reads that disagree: warn on
1230
+ // every node of each unwired type. A wired history-entries node whose
1231
+ // `exclusions` reach no eligibility check leaves nothing out: warn on it.
1232
+ {
1233
+ const READS = [
1234
+ {
1235
+ id: 'core:query/session-history',
1236
+ reads: 'reads every message',
1237
+ fed: 'the session history',
1238
+ short: 'the history',
1239
+ },
1240
+ {
1241
+ id: 'core:query/earlier-scenes',
1242
+ reads: "reads every earlier scene's summary",
1243
+ fed: 'the earlier scenes',
1244
+ short: 'the earlier scenes',
1245
+ },
1246
+ {
1247
+ id: 'core:query/history-entries',
1248
+ reads: 'reads every history entry',
1249
+ fed: 'the history entries',
1250
+ short: 'the history entries',
1251
+ },
1252
+ ];
1253
+ const wiredFor = (n) => {
1254
+ const v = n.config?.firsthandFor;
1255
+ if (v !== undefined && v !== null && v !== false)
1256
+ return true;
1257
+ return doc.edges.some((e) => e.to === n.key && e.toPort.split('.')[0] === 'firsthandFor');
1258
+ };
1259
+ const present = READS.map((r) => ({
1260
+ ...r,
1261
+ nodes: doc.nodes.filter((n) => n.definitionId === r.id && n.definitionVersion === 1),
1262
+ })).filter((r) => r.nodes.length > 0);
1263
+ const feds = present.filter((r) => r.nodes.some(wiredFor));
1264
+ if (feds.length > 0)
1265
+ for (const r of present.filter((p) => !p.nodes.some(wiredFor)))
1266
+ for (const n of r.nodes) {
1267
+ const leaves = feds.length === 1 && feds[0].id === READS[0].id ? 'leaves' : 'leave';
1268
+ const names = feds.length === 1 && feds[0].short === 'the history' ? 'names' : 'name';
1269
+ f.push({
1270
+ law: 'firsthand 2026-11-15',
1271
+ severity: 'warning',
1272
+ nodeKey: n.key,
1273
+ message: `'${n.key}' ${r.reads}, while ${feds.map((x) => x.fed).join(' and ')} beside it ${leaves} out what the speaker was not there for`,
1274
+ fix: `wire firsthandFor (and firsthandBy, if ${feds.map((x) => x.short).join(' and ')} ${names} one) on '${n.key}' as on ${feds.map((x) => x.short).join(' and ')}`,
1275
+ });
1276
+ }
1277
+ for (const n of present.find((r) => r.id === 'core:query/history-entries')?.nodes ?? []) {
1278
+ if (!wiredFor(n))
1279
+ continue;
1280
+ const reaches = doc.edges.some((e) => e.from === n.key &&
1281
+ e.fromPort === 'exclusions' &&
1282
+ e.toPort.split('.')[0] === 'exclusions' &&
1283
+ doc.nodes.some((t) => t.key === e.to && t.definitionId === 'core:task/eligibility'));
1284
+ if (!reaches)
1285
+ f.push({
1286
+ law: 'firsthand 2026-11-15',
1287
+ severity: 'warning',
1288
+ nodeKey: n.key,
1289
+ message: `'${n.key}' leaves out the history entries the speaker was not there for, but its exclusions reach no eligibility check, so nothing is left out`,
1290
+ fix: `wire $.${n.key}.exclusions into the eligibility check's exclusions, beside the lore reads'`,
1291
+ });
1292
+ }
1293
+ }
1225
1294
  // ── T1 — a template fits where it is rendered (typed templates P5) ─────────
1226
1295
  // Collisions and forbidden kinds in a template node's scope, a band with
1227
1296
  // no variable, and — given the checker — every template source the
@@ -1255,8 +1324,10 @@ export function validate(doc, options = {}) {
1255
1324
  * · **an oracle** — only an oracle has a model's tokens to stream.
1256
1325
  *
1257
1326
  * A step status, step label and step purpose are display text, and a
1258
- * step purpose sits only on a model call — an oracle whose definition declares
1259
- * a `connection` slot (`isModelCall`; law `step purpose`, 2026-09-30).
1327
+ * step purpose sits on any step of a document that calls no model at all; in
1328
+ * one that calls a model (a node, or a swap a node lists, whose definition
1329
+ * declares a `connection` slot — `isModelCall`) it sits only on a model call
1330
+ * (law `step purpose`, 2026-09-30; widened 2026-11-12).
1260
1331
  * @internal
1261
1332
  * @ruling lair pass B3/B18, owner D6 and D5 (2026-09-27), W2 (2026-09-27), R-20
1262
1333
  */
@@ -1342,6 +1413,8 @@ export function streamingStepFindings(doc) {
1342
1413
  label: "write the step's name as the settings show it — a string ('Planner') or a locale map with 'en'",
1343
1414
  purpose: "write what this model call is for, in one or two plain sentences — a string or a locale map with 'en'",
1344
1415
  };
1416
+ // A purpose is allowed on any step of a document that calls no model at all, and only on a model call in one that does.
1417
+ const callsAModel = specCallsModel(doc.nodes);
1345
1418
  for (const n of doc.nodes) {
1346
1419
  for (const field of ['status', 'label', 'purpose']) {
1347
1420
  const text = n.expose?.[field];
@@ -1350,7 +1423,7 @@ export function streamingStepFindings(doc) {
1350
1423
  for (const message of i18nFindings(text, `'${n.key}' expose.${field}`))
1351
1424
  f.push({ law: 'R-20', severity: 'error', nodeKey: n.key, message, fix: FIX[field] });
1352
1425
  }
1353
- if (n.expose?.purpose === undefined)
1426
+ if (n.expose?.purpose === undefined || !callsAModel)
1354
1427
  continue;
1355
1428
  const def = getDefinition(`${n.definitionId}@${n.definitionVersion}`);
1356
1429
  if (def && !isModelCall(def))
@@ -0,0 +1,160 @@
1
+ /**
2
+ * 🚧 **Variable layouts by reference** — the name a context template, a
3
+ * preset and the pub use to point at one of a variable's layouts, and the
4
+ * typed builder a plugin ships one with.
5
+ *
6
+ * A variable is written out by one layout, chosen once for the whole pub; a
7
+ * preset may decide differently for its sessions, per variable; a context
8
+ * template that wants a different one names it in place:
9
+ *
10
+ * ```hbs
11
+ * {{{layout characters "core/json@1"}}}
12
+ * ```
13
+ * ```liquid
14
+ * {{ characters | layout: "core/json@1" }}
15
+ * ```
16
+ *
17
+ * ## The layout reference
18
+ *
19
+ * `<owner>/<slug>@<major>`: the owner is a plugin slug (`acme.dice`) or
20
+ * `core`, the slug is kebab-case, the major a positive integer and always
21
+ * written. Unique within its variable, so `core/json@1` names one layout of
22
+ * `characters` and another of `personas`.
23
+ *
24
+ * ⚠ Not a **template id** (`acme:template/omens-prose@1`), the row's
25
+ * app-wide identity. ⚠ Not a session layout (a genre's `layouts`).
26
+ * @experimental
27
+ * @ruling PLAN-variable-layouts-2026-11-10 ★4, ★7
28
+ */
29
+ import type { EngineId } from './engines.js';
30
+ import type { TemplateCheckOptions, TemplateScope } from './template.js';
31
+ import { type TemplateSeed } from './templateIds.js';
32
+ import type { VariableDecl } from './variables.js';
33
+ /**
34
+ * The slug half of a layout reference: kebab-case. Also what
35
+ * `TemplateSeed.slug` must read.
36
+ * @experimental
37
+ */
38
+ export declare const VARIABLE_LAYOUT_SLUG: RegExp;
39
+ /** The three parts of a layout reference. @experimental */
40
+ export interface VariableLayoutReferenceParts {
41
+ /** A plugin slug, or `core`. */
42
+ owner: string;
43
+ /** Kebab-case. */
44
+ slug: string;
45
+ /** A positive integer. */
46
+ major: number;
47
+ }
48
+ /**
49
+ * Split a layout reference, or `null` when it is not one.
50
+ * @experimental
51
+ */
52
+ export declare function parseVariableLayoutReference(value: unknown): VariableLayoutReferenceParts | null;
53
+ /**
54
+ * Write a layout reference from its parts. Throws, in words, on a part
55
+ * outside the grammar — the one place a reference is spelled.
56
+ * @experimental
57
+ */
58
+ export declare function formatVariableLayoutReference(parts: VariableLayoutReferenceParts): string;
59
+ /**
60
+ * The helper (Handlebars) and filter (Liquid) a context template names a
61
+ * layout with: `{{{layout characters "core/json@1"}}}`,
62
+ * `{{ characters | layout: "core/json@1" }}`. Inside a template no session
63
+ * layout can appear, so the bare word is unambiguous there.
64
+ * @experimental
65
+ */
66
+ export declare const VARIABLE_LAYOUT_HELPER = "layout";
67
+ /**
68
+ * 🚧 The helper (Handlebars) and filter (Liquid) that print a date value:
69
+ * `{{formatDate date}}`, `{{ date | formatDate }}`. Prints from the value
70
+ * alone (the calendar's spelling when it carries names); prints nothing for
71
+ * null or a value of the wrong shape. Named apart from the `date` field
72
+ * because a Handlebars `{{date}}` inside a row would call a helper named
73
+ * `date`, and Liquid already has a `date` filter.
74
+ * @experimental
75
+ */
76
+ export declare const FORMAT_DATE_HELPER = "formatDate";
77
+ /**
78
+ * 🚧 The helper / filter that prints a date delta: `{{formatDateDelta dateDelta}}`,
79
+ * `{{ dateDelta | formatDateDelta }}`. Prints from the value alone (sign, then
80
+ * year, month, day, time); prints nothing for null or a value of the wrong
81
+ * shape. Named apart from the `dateDelta` field for the reason
82
+ * `FORMAT_DATE_HELPER` is.
83
+ * @experimental
84
+ */
85
+ export declare const FORMAT_DATE_DELTA_HELPER = "formatDateDelta";
86
+ /**
87
+ * One layout a variable offers, as a `layout` call's completion and hover
88
+ * list it, and as the template check accepts it
89
+ * (`TemplateCheckOptions.variableLayoutOffers`).
90
+ * @experimental
91
+ */
92
+ export interface VariableLayoutOffer {
93
+ /** `core/json@1`. */
94
+ reference: string;
95
+ /** The layout's display name — `JSON`, `Titled JSON block`. */
96
+ label: string;
97
+ }
98
+ /**
99
+ * A variable id split into owner, name and major, or `null` when it is not
100
+ * one — `core:var/characters@1`. A camelCase name is tolerated: the variable
101
+ * registry does not refuse one, and the app kebabs it when it names a layout row.
102
+ * @internal
103
+ */
104
+ export declare function variableIdParts(id: unknown): {
105
+ owner: string;
106
+ name: string;
107
+ major: number;
108
+ } | null;
109
+ /**
110
+ * A new scope in which every root key `renders` maps carries `laidOutBy` — the
111
+ * variable that writes it out. `renders` is what `rendersAt()` returns (key →
112
+ * variable id). This is how a host tells the template check and the editor
113
+ * which keys are laid out. A key that is not a root of `scope` is skipped: the
114
+ * scope is the authority on names. A laid-out value is a string, so an `'any'`
115
+ * or `string[]` root becomes an optional string. Never mutates its input.
116
+ * @experimental
117
+ */
118
+ export declare function laidOutScope(scope: TemplateScope, renders: Readonly<Record<string, string>>): TemplateScope;
119
+ /**
120
+ * The layouts offered by the variable that writes `key` out
121
+ * (`scope[key].laidOutBy`) — for completion inside `layout characters "` and
122
+ * for hover. `[]` when the key isn't laid out, the offers are absent, or the
123
+ * variable offers none.
124
+ * @experimental
125
+ */
126
+ export declare function variableLayoutOffersFor(scope: TemplateScope, key: string, offers: TemplateCheckOptions['variableLayoutOffers']): readonly VariableLayoutOffer[];
127
+ /**
128
+ * What a plugin gives {@link variableLayout}.
129
+ * @experimental
130
+ */
131
+ export interface VariableLayoutInput {
132
+ /** Kebab-case — the slug of the layout reference `<plugin>/<slug>@<major>`. */
133
+ slug: string;
134
+ /** A positive integer. */
135
+ major: number;
136
+ /** The layout's display name — `Titled JSON block`. */
137
+ label: string;
138
+ /** The registered engine `source` is written in. */
139
+ engine: EngineId;
140
+ /** The template source, reading the variable's scope. */
141
+ source: string;
142
+ }
143
+ /**
144
+ * The typed builder of a variable layout's `TemplateSeed` — list the result in
145
+ * `defineExtension({ templates })`. `variable` is the value `defineVariable` /
146
+ * `definePluginVariable` returned, so a typo is a compile error; it may be
147
+ * another package's (a plugin may lay out `core:var/characters@1`).
148
+ *
149
+ * The seed's id is `<pluginId>:template/<variable name>-<slug>@<major>`. Throws,
150
+ * naming the plugin and the variable, on any part outside its grammar, and
151
+ * with the problems `templateSeedProblems` finds.
152
+ *
153
+ * ⚠ It does not check `source`: the template checker carries the engines and
154
+ * lives at `@serene-pub/sdk/template-check`, which this dependency-free module
155
+ * must not import. The packager (`variableSeedFindings`, `E_TEMPLATE_SCOPE`)
156
+ * and the instance's install check hold the source to the variable's scope.
157
+ * @experimental
158
+ */
159
+ export declare function variableLayout(pluginId: string, variable: VariableDecl, input: VariableLayoutInput): TemplateSeed;
160
+ //# sourceMappingURL=variableLayouts.d.ts.map