@serene-pub/sdk 0.6.0-pr-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
package/dist/shapes.js ADDED
@@ -0,0 +1,408 @@
1
+ /**
2
+ * Shapes — versioned edge/payload contracts (01 §1, §3).
3
+ *
4
+ * A shape is the unit of compatibility. Two nodes connect if the upstream port's
5
+ * shape is assignable to the downstream port's. Shapes are also connection kinds
6
+ * and sampling-config kinds (F17), which is what makes the system modality-agnostic:
7
+ * nothing anywhere switches on "is this an LLM".
8
+ * @public
9
+ */
10
+ const registry = new Map();
11
+ /** @experimental */
12
+ export function defineShape(def) {
13
+ registry.set(def.id, def);
14
+ return def.id;
15
+ }
16
+ /** @experimental */
17
+ export function getShape(id) {
18
+ return registry.get(id);
19
+ }
20
+ /** @experimental */
21
+ export function isStreaming(id) {
22
+ return registry.get(id)?.streaming === true;
23
+ }
24
+ /** The permissive sink: anything serializable may flow into a json port. @internal */
25
+ export const JSON_SHAPE = 'core:shape/json@1';
26
+ /** Assignability: identical, into json, or declared assignable (transitively). @internal */
27
+ export function assignable(from, to, seen = new Set()) {
28
+ if (from === to)
29
+ return true;
30
+ if (to === JSON_SHAPE)
31
+ return true;
32
+ if (seen.has(from))
33
+ return false;
34
+ seen.add(from);
35
+ const def = registry.get(from);
36
+ if (!def?.assignableTo)
37
+ return false;
38
+ return def.assignableTo.some((next) => assignable(next, to, seen));
39
+ }
40
+ /** Reset — test isolation only. @internal */
41
+ export function _clearShapes() {
42
+ registry.clear();
43
+ }
44
+ // ── Core shapes ─────────────────────────────────────────────────────────────
45
+ /** @public */
46
+ export const S = {
47
+ text: defineShape({ id: 'core:shape/text@1' }),
48
+ textStream: defineShape({
49
+ id: 'core:shape/text-stream@1',
50
+ assignableTo: ['core:shape/text@1'],
51
+ streaming: true,
52
+ }),
53
+ sessionScope: defineShape({ id: 'core:shape/session-scope@1' }),
54
+ /**
55
+ * Transcript rows — what `session-history@1` publishes on `main` and
56
+ * `messages` and what `process-messages@1` / `prose-transcript@1` read
57
+ * (declared so since 2026-09-17, U5d review W9; the port had said
58
+ * `context-candidates@1` since the SDK was vendored while the value was
59
+ * always rows, and `validate()` never ran over the catalog to say so).
60
+ *
61
+ * **Not assignable to `context-candidates@1`** (U5d review R-a, the same
62
+ * day; W9 had declared it one way). A transcript wired into a candidates
63
+ * port is a wiring the host silently drops: `concat-candidates` keys a
64
+ * row that is not a candidate as `undefined:<id>`, the ranker's `select`
65
+ * excludes it as `excluded_unknown_source`, and `assemble` handed rows
66
+ * as candidates halts on "no ranking decisions". The transcript's place
67
+ * in the window rides the **`band`** port — one intent element, which a
68
+ * spec concatenates in with the lore so the ranker reserves the
69
+ * conversation's slice — and the rows themselves go to
70
+ * `process-messages`. `validate()` says so (a warning naming the fix)
71
+ * rather than refusing, so a document built from the older corpus still
72
+ * compiles. The reverse was never declared either: a ranked candidates
73
+ * list is not a transcript, and a port that reads rows is handed rows.
74
+ */
75
+ messages: defineShape({ id: 'core:shape/messages@1' }),
76
+ candidates: defineShape({ id: 'core:shape/context-candidates@1' }),
77
+ renderedBlocks: defineShape({ id: 'core:shape/rendered-blocks@1' }),
78
+ assembled: defineShape({ id: 'core:shape/assembled-context@1' }),
79
+ /**
80
+ * What Assemble publishes after the allocation/formatting split (16 §7): ordered
81
+ * **blocks** with role, source, token count and a `why` trail — not prose. The
82
+ * Provider's `wire` slot turns it into whatever its connection actually wants.
83
+ *
84
+ * Assignable to `assembled-context@1` so existing specs keep connecting while core
85
+ * migrates; the reverse is not assignable, because a rendered string has already
86
+ * thrown away everything the panel and the budget need.
87
+ */
88
+ allocated: defineShape({
89
+ id: 'core:shape/allocated-context@1',
90
+ assignableTo: ['core:shape/assembled-context@1'],
91
+ }),
92
+ /**
93
+ * The object a context template renders against: characters, personas,
94
+ * scenario, the prompt texts, the resolved names.
95
+ *
96
+ * Its own shape rather than `json@1` so that a plugin supplying an alternative
97
+ * context builder has something to publish, and so a spec that wires the wrong
98
+ * node into Assemble's context port fails at publish rather than rendering a
99
+ * template full of blanks — which reads as a broken template, and sends the
100
+ * user to the wrong screen.
101
+ */
102
+ /**
103
+ * The chat's cast and prompt config, as rows — before any decision about who
104
+ * is shown or named. The input to the context builder, kept distinct from the
105
+ * built context so the two can be replaced independently.
106
+ */
107
+ sessionCast: defineShape({ id: 'core:shape/session-cast@1' }),
108
+ /**
109
+ * The MCP connection kind (14 §1). A connection whose shape is `mcp` is a
110
+ * Model Context Protocol server core talks to — foreign code SP speaks
111
+ * JSON-RPC with, never code SP loads. The shape doubles as the connection
112
+ * kind (F17), so only MCP connections are offerable on an MCP provider's
113
+ * connection slot.
114
+ */
115
+ mcp: defineShape({ id: 'core:shape/mcp@1' }),
116
+ templateContext: defineShape({ id: 'core:shape/template-context@1' }),
117
+ vector: defineShape({ id: 'core:shape/vector@1' }),
118
+ budget: defineShape({ id: 'core:shape/context-budget@1' }),
119
+ rowIds: defineShape({ id: 'core:shape/row-ids@1' }),
120
+ /**
121
+ * The output of an async block or a map (01 §1, 13 §1). An ordered list in
122
+ * **declaration order**, one entry per branch — never a merged object, because
123
+ * merging needs a field-collision policy and every such policy is wrong for
124
+ * somebody. `async` and `map` produce the same shape, so one equivalence
125
+ * harness covers both (F26).
126
+ */
127
+ branchResults: defineShape({ id: 'core:shape/branch-results@1' }),
128
+ /**
129
+ * What a **gate-eligible** Consumer publishes (13 §7j-b). Discriminated, because
130
+ * a write may in principle land as a proposal rather than a row — and a
131
+ * proposal id in a shared id space is indistinguishable from a real row id
132
+ * right up until the foreign key dangles.
133
+ *
134
+ * **Assignable to `row-ids@1`** since the 2026-09-15 rulings (09-B B4, R-17).
135
+ * It was deliberately not, and the reason was the `async` review position:
136
+ * a row proposed under it might never exist. That position is gone
137
+ * (`review.ts` — on or off, nothing between): `on` parks the run until the
138
+ * decision and a rejection halts it, so by the time any downstream node
139
+ * runs, the ids a committed result carries ARE row ids. That is what makes
140
+ * a create → update pair on one row inside one run legal, and it is how a
141
+ * pipeline owns its reply: a placeholder outlet straight after the inlet,
142
+ * and an `update-message` at the end that fills it.
143
+ */
144
+ writeResult: defineShape({
145
+ id: 'core:shape/write-result@1',
146
+ assignableTo: ['core:shape/row-ids@1'],
147
+ }),
148
+ /**
149
+ * A request to summarize something into a lore entry.
150
+ *
151
+ * Its own shape rather than `json@1` because it is what the summarize
152
+ * pipelines take as *input*, and 11 §2 matches an event's payload against a
153
+ * pipeline's Input contract by shape. A request typed as bare json would make
154
+ * every pipeline compatible with every event.
155
+ */
156
+ summarizeRequest: defineShape({ id: 'core:shape/summarize-request@1' }),
157
+ /**
158
+ * The ordered batch drafts phase 1 produces, before synthesis merges them.
159
+ *
160
+ * Ordered, and the order is load-bearing: the drafts are chronological
161
+ * slices of a conversation and synthesis reads them as a sequence. A shape
162
+ * that permitted reordering would turn a narrative into a pile of events.
163
+ */
164
+ drafts: defineShape({ id: 'core:shape/drafts@1' }),
165
+ /** Scenes with their messages, as the graph builder walks them. */
166
+ graphScenes: defineShape({ id: 'core:shape/graph-scenes@1' }),
167
+ /**
168
+ * A proposed set of graph nodes and relationships, before a person approves it.
169
+ *
170
+ * Distinct from anything holding row ids, for the reason `write-result@1`
171
+ * exists: a proposal is not yet a row, and a downstream node that treated it
172
+ * as one would wire a foreign key to something a reviewer may still reject.
173
+ */
174
+ graphProposal: defineShape({ id: 'core:shape/graph-proposal@1' }),
175
+ /**
176
+ * Who speaks next, and how that was decided (19 §5).
177
+ *
178
+ * Its own shape rather than `row-ids@1` because it is the swap-list
179
+ * membership test: a task whose `main` publishes this shape *is* a
180
+ * next-speaker strategy, and the dropdown is a SELECT over such rows — an
181
+ * extension's strategy appears beside core's by existing, the same way a
182
+ * chat mode does. The bundle carries `{speaker, characterId, strategy, via}`
183
+ * — the speaker as a participant reference beside the bare id (R-18 (3)) —
184
+ * and each rides its own port for wiring.
185
+ */
186
+ speakerSelection: defineShape({ id: 'core:shape/speaker-selection@1' }),
187
+ /**
188
+ * A participant reference (R-15, R-18 (3)): `character:<id>`,
189
+ * `envoy:<slug>`, `user:<id>`, or a role — see `participants.ts`.
190
+ *
191
+ * The inlet's `speaker` port and a turn strategy's carry this, so one
192
+ * port answers "who is speaking" for a library character and a genre's
193
+ * envoy alike. Not assignable to `row-ids@1` on purpose: a reference is a
194
+ * name, and a node that wants the bare character id keeps reading
195
+ * `characterId` until every reader speaks references.
196
+ */
197
+ participantRef: defineShape({ id: 'core:shape/participant-ref@1' }),
198
+ /**
199
+ * An ordered list of participant references, no duplicates (lair pass R3,
200
+ * 2026-09-28): the inlet's `recipients` — the cast members a press
201
+ * collected (`CollectedRecipients`). Its own id rather than `json@1` so a
202
+ * port that wants people is not handed any list. Consumed by
203
+ * `core:query/resolve-state-changes@1`'s `owners` (R10): the Whisper's
204
+ * one change, made on each recipient.
205
+ */
206
+ participantRefs: defineShape({ id: 'core:shape/participant-refs@1' }),
207
+ /**
208
+ * One **session change** (R-15, built 2026-09-16): the payload every
209
+ * built-in write's event carries — `{ event, sessionId, messageId, at,
210
+ * … }` plus what was lost or replaced (`lost` on a delete, `previous` on
211
+ * an edit or a swipe). The next reply's inlet publishes the changes since
212
+ * the last one as a list on its `sessionChanges` port, so a pipeline knows the
213
+ * history it sees has moved. See `SessionChangePayload` in events.ts.
214
+ *
215
+ * Its own id rather than `json@1`, for the reason `summarize-request@1`
216
+ * gives: `pipeline_event_registry.payload_shape` names it, and an event
217
+ * whose payload was bare json would match every inlet.
218
+ */
219
+ sessionChange: defineShape({ id: 'core:shape/session-change@1' }),
220
+ /**
221
+ * A **form addressed** to a participant the AI portrays (R-15 *Forms*;
222
+ * 30 §U5d): the payload of `core:event/form-addressed@1` — `{ sessionId,
223
+ * messageId, blockId, action, addressee }` (`FormAddressedPayload`,
224
+ * events.ts) — and what `core:inlet/form-addressed@1` publishes, port by
225
+ * port, with the block itself beside them. Its own id for the reason
226
+ * `session-change@1` has: the registry's `payload_shape` names it.
227
+ */
228
+ formAddressed: defineShape({ id: 'core:shape/form-addressed@1' }),
229
+ /**
230
+ * A **cast change** (PLAN-turn-order §4.1): the payload of
231
+ * `core:event/cast-changed@1` — `{ event, sessionId, at, cause, ref,
232
+ * change, value }` (`CastChangePayload`, events.ts). A seated
233
+ * participant was switched on or off, or its `position` or portrayal moved;
234
+ * a seat added or removed is `member-added` / `member-removed`, not
235
+ * this. Its own id for the reason `session-change@1` has.
236
+ */
237
+ castChange: defineShape({ id: 'core:shape/cast-change@1' }),
238
+ /**
239
+ * **Annex changed** (PLAN-turn-order §4.14, R30): the payload of
240
+ * `core:event/annex-changed@1` — `{ event, sessionId, at, cause, owner }`
241
+ * (`AnnexChangePayload`, events.ts). Names whose entry moved, never the
242
+ * value.
243
+ */
244
+ annexChange: defineShape({ id: 'core:shape/annex-change@1' }),
245
+ /** What a listener receives for an event a pipeline recorded: the envelope, the author's payload inside. */
246
+ recordedEvent: defineShape({ id: 'core:shape/recorded-event@1' }),
247
+ /**
248
+ * **Turn order changed** (§4.1): the payload of
249
+ * `core:event/turn-order-changed@1` — `{ event, sessionId, at, cause,
250
+ * runId, turnOrder }` (`TurnOrderChangedPayload`, events.ts), the
251
+ * document as `core:outlet/set-turn-order@1` wrote it. Core-internal:
252
+ * the auto-advance listener and the `sessions:turnOrder` push read it;
253
+ * a genre may not bind a spec to it.
254
+ */
255
+ turnOrderChanged: defineShape({ id: 'core:shape/turn-order-changed@1' }),
256
+ /**
257
+ * The session's **turn order** as state (§4.2): `TurnOrderV1` —
258
+ * `{ v, order, candidates, basedOnAt, computedAt, runId, event,
259
+ * strategy }`, stored at `sessions.metadata.turnOrder` and written by
260
+ * `core:outlet/set-turn-order@1` alone. Not the entries alone and not
261
+ * the candidates alone: the whole answer, with what it answered.
262
+ */
263
+ turnOrder: defineShape({ id: 'core:shape/turn-order@1' }),
264
+ /**
265
+ * **Turn candidates** (§4.2): `TurnCandidateV1[]` — the participants the
266
+ * pool admitted this run, in pool order. What `core:task/turn-pool@1`
267
+ * publishes, an orderer rewrites, and a strategy reads. Open objects:
268
+ * an orderer or a plugin may add keys and core passes them through.
269
+ */
270
+ turnCandidates: defineShape({ id: 'core:shape/turn-candidates@1' }),
271
+ /**
272
+ * **Turn entries** (§4.2): `TurnEntryV1[]` — prepared turns, each
273
+ * `{ ref, channel?, subject?, via }`. What a strategy publishes on
274
+ * `main` and `order`; the shape-based swap list keys a strategy on it,
275
+ * as it keyed one on `speaker-selection@1` before (that shape stays
276
+ * until the strategies are re-ported).
277
+ */
278
+ turnEntries: defineShape({ id: 'core:shape/turn-entries@1' }),
279
+ /**
280
+ * **Sprite choices** (DESIGN-sprites §5.2): what a line's speaker can show
281
+ * — `{ characterId, set, defaultSet, labels, last, decidedBy, text }`.
282
+ * `set` is the sprite set in force for the line (a session override, the
283
+ * cast member's amendment, or the card's default — `decidedBy` says
284
+ * which); `labels` are that set's sprite labels with an image; `last` is
285
+ * the speaker's previous shown sprite, for stickiness. What
286
+ * `core:query/sprites-for@1` publishes and every sprite picker reads.
287
+ */
288
+ spriteChoices: defineShape({ id: 'core:shape/sprite-choices@1' }),
289
+ /**
290
+ * **A sprite pick**: `{ set, label, score?, runnerUp?, held? } | null` — the
291
+ * sprite a picker chose for a line, or null for none. What every sprite
292
+ * picker publishes on `main`, so the shape-based swap list keys a picker on
293
+ * it exactly as it keys a turn strategy on `turn-entries@1`.
294
+ */
295
+ spritePick: defineShape({ id: 'core:shape/sprite-pick@1' }),
296
+ /**
297
+ * The **settings document** (§4.12): `SessionSettingsV1` — every
298
+ * setting a person can see in session settings, resolved once per run
299
+ * with the cascade applied (session > genre > core), and handed to the
300
+ * inlet as `session`. A spec reads `$.input.session.fields.tone` and
301
+ * never learns which table it came from.
302
+ */
303
+ sessionSettings: defineShape({ id: 'core:shape/session-settings@1' }),
304
+ /**
305
+ * A reference to stored media of any kind — the general port type.
306
+ *
307
+ * `image@1` and `audio@1` stay, and are assignable **to** this, so every
308
+ * spec wired to them keeps connecting while the general ports arrive. The
309
+ * reverse is not assignable: a port that accepts any media cannot be handed
310
+ * to one that has declared it only understands images. Same rule, and the
311
+ * same reason, as `allocated-context` → `assembled-context`.
312
+ */
313
+ media: defineShape({ id: 'core:shape/media-ref@1' }),
314
+ /** An ordered list of media references — what a multimodal request carries
315
+ * as its attachments. */
316
+ mediaList: defineShape({ id: 'core:shape/media-refs@1' }),
317
+ /**
318
+ * 🚧 **A transcript's attachments, by message** (PLAN-composer-attachments
319
+ * §3.5): `Record<messageId, HistoryAttachmentV1[]>` (media.ts) — each
320
+ * message's `core:image` / `core:file` parts, in part order. What
321
+ * `core:query/history-attachments@1` publishes and
322
+ * `core:task/place-attachments@1` reads, so each line's files travel with
323
+ * that line's own turn rather than with the request as a whole.
324
+ */
325
+ mediaByMessage: defineShape({ id: 'core:shape/media-by-message@1' }),
326
+ /**
327
+ * A reply's **folded sections** (B4; D5, 2026-09-27): `FoldedSectionV1[]`
328
+ * (widgets.ts) — each `{ kind, label, content }` or `{ kind, label, items }`,
329
+ * shown collapsed beside the body and never read into the prompt. What the
330
+ * message outlets' `sections` in-port takes.
331
+ */
332
+ foldedSections: defineShape({ id: 'core:shape/folded-sections@1' }),
333
+ audio: defineShape({
334
+ id: 'core:shape/audio@1',
335
+ assignableTo: ['core:shape/media-ref@1'],
336
+ }),
337
+ image: defineShape({
338
+ id: 'core:shape/image@1',
339
+ assignableTo: ['core:shape/media-ref@1'],
340
+ }),
341
+ json: defineShape({ id: 'core:shape/json@1' }),
342
+ /**
343
+ * What a ranker judged (PLAN-sdk-1.0 §3.9, R64): one `RankingDecisionV1`
344
+ * per candidate. A node whose out-port carries this shape is RECORDED by
345
+ * the host — core's rankers and a plugin's alike — into the ranking store.
346
+ * Reviewed with L1 (PLAN-sdk-1.0 §4 ✓); it carries `S`'s own tag.
347
+ */
348
+ decisions: defineShape({ id: 'core:shape/decisions@1' }),
349
+ // connection / sampling kinds — the same ids, which is the point (F17)
350
+ /**
351
+ * A model reply as an ordered list of typed parts (text, reasoning, media,
352
+ * tool calls) rather than a string — see `OutputPart` in media.ts for why
353
+ * that is now the honest shape of a completion.
354
+ *
355
+ * Assignable **to** `text-stream@1`, so a provider may start emitting parts
356
+ * without breaking a single spec wired to its text output: the degrade
357
+ * concatenates the prose and drops the rest. Not assignable in reverse,
358
+ * because by then the ordering and the media are gone — the same
359
+ * richer-to-poorer rule the allocated/assembled pair established.
360
+ */
361
+ partStream: defineShape({
362
+ id: 'core:shape/part-stream@1',
363
+ assignableTo: ['core:shape/text-stream@1'],
364
+ streaming: true,
365
+ }),
366
+ textGen: defineShape({ id: 'core:shape/text-gen@1' }),
367
+ /**
368
+ * Vector embedding — the connection kind, and deliberately **not** a
369
+ * sampling vocabulary (yet).
370
+ *
371
+ * It is absent from `SAMPLING_SCHEMAS` on purpose, and the reason is
372
+ * structural rather than unfinished work: every parameter an embedding call
373
+ * would take — input truncation, pooling, normalisation, output dimensions,
374
+ * the asymmetric query/passage prefixes E5/BGE/GTE want — changes what a
375
+ * *stored* vector means, and nothing records which setting produced the
376
+ * vectors already in the table. A text sampler affects one reply; an
377
+ * embedding parameter silently re-defines a whole persistent index against
378
+ * rows that will never be recomputed. That is the same re-index story the
379
+ * prefixes are held back for, so none of them ship until it is decided.
380
+ *
381
+ * What is left after removing those is either not per-invocation at all
382
+ * (model identity, transport, residency TTL — those belong to the
383
+ * connection) or has no consumer (nothing chunks a batch). An empty
384
+ * vocabulary is worse than no vocabulary here: `isKnownSamplingShape` in
385
+ * core admits any shape this record has a key for, so registering `{}`
386
+ * would let the write path accept a config that exists, looks saved, and
387
+ * can never send anything — the exact state that guard was written to
388
+ * refuse.
389
+ */
390
+ embeddings: defineShape({ id: 'core:shape/embeddings@1' }),
391
+ /**
392
+ * Named-entity recognition — the connection kind for a mention detector.
393
+ *
394
+ * Declared ahead of its adapter so the model side has a stable noun to
395
+ * name; core's extractor is dictionary-based and model-free today
396
+ * (`core:extract/entities-heuristic@1`), and takes no parameters at all
397
+ * beyond the text and the gazetteer.
398
+ *
399
+ * Like `embeddings`, and for the same two reasons, it has no entry in
400
+ * `SAMPLING_SCHEMAS`: its one real knob (how much of a passage the
401
+ * extractor is handed) is part of the annotation freshness triple, and an
402
+ * empty vocabulary would defeat core's do-nothing-config guard.
403
+ */
404
+ ner: defineShape({ id: 'core:shape/ner@1' }),
405
+ tts: defineShape({ id: 'core:shape/tts@1' }),
406
+ imageGen: defineShape({ id: 'core:shape/image-gen@1' }),
407
+ };
408
+ //# sourceMappingURL=shapes.js.map
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Attribute sheets — a named, ordered bundle of attribute slots.
3
+ *
4
+ * A slot says what one value is; a sheet says which values a thing has, and in
5
+ * what order they are read. *Adventure* is `hp`, `stamina`, `mood`, `trust`,
6
+ * `location`, `time-of-day`, `weather` — declared once, named by a genre,
7
+ * attached to an owner, and the same seven in the same order everywhere they
8
+ * appear. Owners hold sheets; the vocabulary of an owner is the union of the
9
+ * genre's sheets and the sheets down its chain, deduped by id.
10
+ *
11
+ * ## Why this is a registry of its own, beside the slots
12
+ *
13
+ * The two answer different questions. `attributes.ts` answers *may this value
14
+ * be stored?* and everything in it is about one value — bounds, options, what
15
+ * the model reads. This answers *what does this thing have?* and carries
16
+ * nothing about any one value beyond the three things naming it on a sheet
17
+ * decides. Folded into one registry, a single `get` would return two kinds of
18
+ * thing and a single `retire` would mean two different things to the rows
19
+ * underneath. The id grammar, the reserved owners and the origin rule are
20
+ * shared — imported from there, not restated here, so there is one answer to
21
+ * "who may claim this namespace" rather than two that agree today.
22
+ *
23
+ * ## Order is the declaration
24
+ *
25
+ * `slots` is a list and not a set. It is the order a panel draws, the order a
26
+ * state block renders to the model, and the order rules are evaluated in.
27
+ * Re-ordering a sheet is therefore a change to behaviour, inside the hash like
28
+ * any other, which is why the union a genre computes preserves the order rather
29
+ * than sorting it.
30
+ *
31
+ * ⚠ **Not a layout sheet.** §26 uses *sheet* for what a side zone becomes below
32
+ * `roomy`, and *More sheet* for the mobile overflow; those are places on a
33
+ * screen. Prose says the qualified word — *attribute sheet* — exactly as it
34
+ * does for an attribute slot, and the exported API says it too.
35
+ *
36
+ * ⚠ Never an *attachment* (that is a message part) and never a *template*
37
+ * (taken three times over already).
38
+ */
39
+ import type { I18n } from './descriptors.js';
40
+ import { type AttributeSlotDecl, type SlotAppliesTo, type SlotConfig, type SlotId, type SlotOrigin, type SlotValue } from './attributes.js';
41
+ /** `owner:sheet/name@N` — `core:sheet/adventure@1`, `acme.rp:sheet/tension@1`. @experimental */
42
+ export type SheetId = string;
43
+ /** @experimental */
44
+ export declare function assertSheetId(id: string): void;
45
+ /**
46
+ * One slot on a sheet, and the three things naming it here decides.
47
+ *
48
+ * Nothing else about the slot is restated: a sheet never says again what a
49
+ * value *is*, only what it is on this sheet. `config` is a **deviation** like
50
+ * every other layer's — the keys it changes and no others — so a sheet that
51
+ * raises a cap does not silently drop the options declared beside it.
52
+ * @experimental
53
+ */
54
+ export interface SheetSlotEntry {
55
+ id: SlotId;
56
+ /**
57
+ * A session of a genre carrying this sheet must have a value. With a
58
+ * `default` that is automatic; without one, creation refuses, and an
59
+ * upgrade that adds `required` with no default warns on the session rather
60
+ * than breaking it.
61
+ */
62
+ required?: boolean;
63
+ /**
64
+ * What it starts at, as this sheet's deviation from the declaration's own
65
+ * default. Checked against the slot when the sheet is declared: a default
66
+ * nothing may store is a session nobody can create, and finding that out at
67
+ * creation time means finding it out once per person.
68
+ */
69
+ default?: SlotValue;
70
+ /** This sheet's deviations from the declaration's config. */
71
+ config?: SlotConfig;
72
+ /**
73
+ * 🚧 Which owners carry the slot **on this sheet** — a narrowing of the
74
+ * declaration's own `appliesTo`, never a widening. Absent, every owner
75
+ * the declaration names. It is how a premade stat that fits more than
76
+ * one owner is put where a genre wants it: `location` on the world in
77
+ * Adventure, on each cast member in a genre whose characters can be in
78
+ * different places (owner ruling 2026-09-26).
79
+ */
80
+ appliesTo?: readonly SlotAppliesTo[];
81
+ }
82
+ /**
83
+ * 🚧 The owners a sheet entry puts its slot on: the entry's own narrowing, or
84
+ * the declaration's `appliesTo` when it states none. The one reader, so a host
85
+ * and a widget cannot disagree about whether a character carries it.
86
+ * @experimental
87
+ */
88
+ export declare const sheetSlotAppliesTo: (entry: Pick<SheetSlotEntry, 'appliesTo'>, decl: Pick<AttributeSlotDecl, 'appliesTo'>) => readonly SlotAppliesTo[];
89
+ /** @experimental */
90
+ export interface AttributeSheetProps {
91
+ /** The name a person reads. Display text: stripped from the content hash. */
92
+ label: I18n;
93
+ /** What the bundle is for, shown where it is offered. Display text: stripped. */
94
+ description?: I18n;
95
+ /** The slots it gathers, **in order** — see the file header on why order is content. */
96
+ slots: readonly SheetSlotEntry[];
97
+ }
98
+ /** @experimental */
99
+ export interface AttributeSheetDecl extends AttributeSheetProps {
100
+ readonly id: SheetId;
101
+ /** Which source it came through — the same two, on the same terms, as a slot's. */
102
+ readonly origin: SlotOrigin;
103
+ /** `stored` only: the account the row belongs to. */
104
+ readonly authorUserId?: number | string;
105
+ /** Retired: offered nowhere new, kept everywhere it already is. `stored` only. */
106
+ readonly retired?: boolean;
107
+ }
108
+ /**
109
+ * Display text this registry carries outside `i18n`/`description`.
110
+ *
111
+ * `label` only, and for once there is no model-facing counterpart to keep out:
112
+ * a sheet ships no prose to a prompt. What the model reads is each slot's own
113
+ * `descriptor`, hashed in that slot's declaration where it belongs.
114
+ * @experimental
115
+ */
116
+ export declare const SHEET_DISPLAY_KEYS: {
117
+ readonly display: readonly ['label'];
118
+ };
119
+ /**
120
+ * Declare an attribute sheet in code.
121
+ *
122
+ * Written **below** the slots it gathers, and that is not a style note: the
123
+ * slots have to be in the registry already, because a sheet naming one nothing
124
+ * declares is a vocabulary that validates against nothing.
125
+ * @experimental
126
+ */
127
+ export declare function defineAttributeSheet(id: SheetId, props: AttributeSheetProps): AttributeSheetDecl;
128
+ /** The plugin-facing door — same registration, minus the ability to claim core's namespace. @experimental */
129
+ export declare function definePluginAttributeSheet(pluginId: string, id: SheetId, props: AttributeSheetProps): AttributeSheetDecl;
130
+ /** The person-facing door, on the same reserved-owner terms as `defineStoredAttributeSlot`. @experimental */
131
+ export declare function defineStoredAttributeSheet(id: SheetId, props: AttributeSheetProps, meta: {
132
+ userId: number | string;
133
+ }): AttributeSheetDecl;
134
+ /** @experimental */
135
+ export declare const getAttributeSheet: (id: SheetId) => AttributeSheetDecl | undefined;
136
+ /** @experimental */
137
+ export declare const attributeSheets: () => AttributeSheetDecl[];
138
+ /** @experimental */
139
+ export declare function _clearAttributeSheets(): void;
140
+ /**
141
+ * Withdraw a package's sheet declaration — the sheet half of
142
+ * `_withdrawAttributeSlot`, on the same terms.
143
+ * @internal
144
+ */
145
+ export declare function _withdrawAttributeSheet(id: SheetId): boolean;
146
+ /**
147
+ * Retire a stored sheet: offered nowhere new, kept everywhere it already is.
148
+ *
149
+ * `stored` only, for the reason a slot is — a code sheet arrives and leaves
150
+ * with its package, and retiring one by hand would leave the registry saying
151
+ * something the installed code contradicts on the next boot.
152
+ * @experimental
153
+ */
154
+ export declare function retireAttributeSheet(id: SheetId): AttributeSheetDecl;
155
+ /** The reverse of `retireAttributeSheet`, with the same `stored`-only rule. @experimental */
156
+ export declare function reviveAttributeSheet(id: SheetId): AttributeSheetDecl;
157
+ /**
158
+ * The display-text findings of one sheet declaration (R-20): a sheet is
159
+ * offered by its `label`, so the label is required; the `description` is what
160
+ * a person reads under the offer. Run by the code door here and by the host's
161
+ * **write** door for an authored sheet, never by a reload.
162
+ * @experimental
163
+ */
164
+ export declare function attributeSheetDisplayFindings(id: SheetId, props: AttributeSheetProps): string[];
165
+ //# sourceMappingURL=sheets.d.ts.map